[
  {
    "path": ".changeset/busy-goats-brush.md",
    "content": "---\n'@sveltejs/kit': patch\n---\n\nfix: don't request new data when `.refresh` is called on a query with no cache entry\n"
  },
  {
    "path": ".changeset/config.json",
    "content": "{\n\t\"$schema\": \"https://unpkg.com/@changesets/config@2.3.0/schema.json\",\n\t\"changelog\": [\"@svitejs/changesets-changelog-github-compact\", { \"repo\": \"sveltejs/kit\" }],\n\t\"commit\": false,\n\t\"linked\": [],\n\t\"access\": \"public\",\n\t\"baseBranch\": \"main\",\n\t\"bumpVersionsWithWorkspaceProtocolOnly\": true,\n\t\"ignore\": [\"!(@sveltejs/*)\"]\n}\n"
  },
  {
    "path": ".changeset/eight-sheep-unite.md",
    "content": "---\n'@sveltejs/kit': minor\n---\n\nbreaking: add `run()` method to queries, disallow awaiting queries outside render\n"
  },
  {
    "path": ".changeset/great-actors-stop.md",
    "content": "---\n'@sveltejs/kit': patch\n---\n\nfix: manage queries in their own `$effect.root`\n"
  },
  {
    "path": ".changeset/many-flowers-press.md",
    "content": "---\n'@sveltejs/kit': patch\n---\n\nfix: avoid `inlineDynamicImports` deprecation warning when building the service worker with Vite 8\n"
  },
  {
    "path": ".changeset/orange-queens-rush.md",
    "content": "---\n'@sveltejs/kit': minor\n---\n\nfeat: use `hydratable` for remote function transport\n"
  },
  {
    "path": ".changeset/silver-baths-camp.md",
    "content": "---\n'@sveltejs/kit': patch\n---\n\nfix: deduplicate same-cache-key `batch` calls during SSR\n"
  },
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\nend_of_line = lf\ninsert_final_newline = true\nindent_style = tab\nindent_size = 2\ncharset = utf-8\ntrim_trailing_whitespace = true"
  },
  {
    "path": ".eslint/no-runtime-to-exports-imports.js",
    "content": "// @ts-expect-error no types here\nimport path from 'node:path';\n\n/**\n * @type {import('eslint').Rule.RuleModule}\n */\nexport default {\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription: 'disallow relative imports from src/runtime to src/exports',\n\t\t\tcategory: 'Possible Errors',\n\t\t\trecommended: true\n\t\t},\n\t\tschema: [],\n\t\tmessages: {\n\t\t\tnoRuntimeToExportsImport:\n\t\t\t\t'Relative imports from src/runtime to src/exports are not allowed because they can cause Vite to resolve the same module both via regular Node and internal Vite. Use internal import maps or `@sveltejs/kit/internal` instead.'\n\t\t}\n\t},\n\n\tcreate(context) {\n\t\tconst filename = context.filename;\n\n\t\t// Only apply this rule to files in packages/kit/src/runtime\n\t\tconst in_runtime = filename.includes(path.join('packages', 'kit', 'src', 'runtime'));\n\n\t\tif (!in_runtime) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tImportDeclaration(node) {\n\t\t\t\tconst import_path = node.source.value;\n\n\t\t\t\t// Check if this is a relative import\n\t\t\t\tif (typeof import_path === 'string' && import_path.startsWith('.')) {\n\t\t\t\t\t// Resolve the import path relative to the current file\n\t\t\t\t\tconst current_dir = path.dirname(filename);\n\t\t\t\t\tconst resolved_path = path.resolve(current_dir, import_path);\n\n\t\t\t\t\t// Check if the resolved path points to src/exports\n\t\t\t\t\tconst exports_path = path.join('packages', 'kit', 'src', 'exports');\n\n\t\t\t\t\tif (resolved_path.includes(exports_path)) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode: node.source,\n\t\t\t\t\t\t\tmessageId: 'noRuntimeToExportsImport'\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n};\n"
  },
  {
    "path": ".gitattributes",
    "content": "* text=auto eol=lf\n/packages/**/test/** -linguist-detectable\n/packages/**/fixtures/** -linguist-detectable\n"
  },
  {
    "path": ".githooks/pre-push",
    "content": "#!/bin/sh\n\nset -e\n\npnpm install --frozen-lockfile\npnpm lint\npnpm check\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "open_collective: svelte\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.yml",
    "content": "name: \"\\U0001F41E Bug report\"\ndescription: Report an issue with SvelteKit\nbody:\n  - type: markdown\n    attributes:\n      value: |\n        Thanks for taking the time to fill out this bug report! **Before you start, make sure you have the latest versions of the packages you're using, including adapters.**\n  - type: textarea\n    id: bug-description\n    attributes:\n      label: Describe the bug\n      description: Please [check if bugs related to building are caused by Vite](https://github.com/sveltejs/kit#bug-reporting) and [file there](https://github.com/vitejs/vite/issues) if appropriate. If you intend to submit a PR for this issue, tell us in the description. Thanks!\n      placeholder: Bug description\n    validations:\n      required: true\n  - type: textarea\n    id: reproduction\n    attributes:\n      label: Reproduction\n      description: A link to a repository, or a fork of https://node.new/sveltekit, that reproduces the issue. Reproductions must be [short, self-contained and correct](http://sscce.org/) and must not contain files or code that aren't relevant to the issue — please do NOT just paste a link to your project. Explaining how to reproduce is generally not enough. It pushes the burden of creating a reproduction project onto a small set of volunteer maintainers and isn't scalable. If no reproduction is provided, the issue will be closed.\n      placeholder: Reproduction\n    validations:\n      required: true\n  - type: textarea\n    id: logs\n    attributes:\n      label: Logs\n      description: \"Please include browser console and server logs around the time this bug occurred. Please try not to insert an image but copy paste the log text.\"\n      render: Shell\n  - type: textarea\n    id: system-info\n    attributes:\n      label: System Info\n      description: Output of `npx envinfo --system --binaries --browsers --npmPackages \"{svelte,@sveltejs/*,vite}\"`\n      render: Shell\n      placeholder: System, Binaries, Browsers\n    validations:\n      required: true\n  - type: dropdown\n    id: severity\n    attributes:\n      label: Severity\n      options:\n        - annoyance\n        - serious, but I can work around it\n        - blocking an upgrade\n        - blocking all usage of SvelteKit\n    validations:\n      required: true\n  - type: textarea\n    id: additional-context\n    attributes:\n      label: Additional Information\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "content": "blank_issues_enabled: false\ncontact_links:\n  - name: Discord Chat\n    url: https://svelte.dev/chat\n    about: Ask questions and discuss with other SvelteKit users in real time.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.yml",
    "content": "name: \"Feature Request\"\ndescription: Suggest an idea for this project\nbody:\n  - type: markdown\n    attributes:\n      value: |\n        Thanks for taking the time to request this feature! If your feature request is complex or substantial enough to warrant in-depth discussion, maintainers may close the issue and ask you to open an [RFC](https://github.com/sveltejs/rfcs).\n  - type: textarea\n    id: problem\n    attributes:\n      label: Describe the problem\n      description: Please provide a clear and concise description the problem this feature would solve. The more information you can provide here, the better.\n      placeholder: I'm always frustrated when...\n    validations:\n      required: true\n  - type: textarea\n    id: solution\n    attributes:\n      label: Describe the proposed solution\n      description: Please provide a clear and concise description of what you would like to happen.\n      placeholder: I would like to see...\n    validations:\n      required: true\n  - type: textarea\n    id: alternatives\n    attributes:\n      label: Alternatives considered\n      description: \"Please provide a clear and concise description of any alternative solutions or features you've considered.\"\n  - type: dropdown\n    id: importance\n    attributes:\n      label: Importance\n      description: How important is this feature to you?\n      options:\n        - nice to have\n        - would make my life easier\n        - i cannot use SvelteKit without it\n    validations:\n      required: true\n  - type: textarea\n    id: additional-context\n    attributes:\n      label: Additional Information\n      description: Add any other context or screenshots about the feature request here.\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "closes #<!-- Add the related issue number here. Repeat this line for each additional issue it closes -->\n\n<!-- Explain the goal of the PR, why it is needed, and what has been changed to achieve that goal -->\n\n---\n\n### Please don't delete this checklist! Before submitting the PR, please make sure you do the following:\n- [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs\n- [ ] This message body should clearly illustrate what problems it solves.\n- [ ] Ideally, include a test that fails without this PR but passes with it.\n\n### Tests\n- [ ] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check`\n\n### Changesets\n- [ ] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`.\n\n### Edits\n\n- [ ] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.\n"
  },
  {
    "path": ".github/actions/platform-test/action.yml",
    "content": "name: 'Platform Test'\ndescription: 'Run Playwright tests against a deployed platform preview'\n\ninputs:\n  test-app-dir:\n    description: 'Path to the test app directory'\n    required: true\n  deployment-url:\n    description: 'URL of the deployed preview to test against'\n    required: true\n\nruns:\n  using: 'composite'\n  steps:\n    - name: Install Playwright\n      shell: bash\n      run: pnpm playwright install chromium --no-shell\n\n    - name: Run Playwright tests\n      shell: bash\n      working-directory: ${{ inputs.test-app-dir }}\n      env:\n        DEPLOYMENT_URL: ${{ inputs.deployment-url }}\n      run: pnpm test:platform\n\n    - name: Upload test artifacts\n      if: failure()\n      uses: actions/upload-artifact@v7\n      with:\n        name: platform-test-results-${{ github.job }}\n        path: ${{ inputs.test-app-dir }}/test-results\n        retention-days: 3\n"
  },
  {
    "path": ".github/actions/vercel-deploy/action.yml",
    "content": "name: 'Vercel Deploy'\ndescription: 'Set up the repo and deploy a test app to Vercel'\n\ninputs:\n  # Important: When setting up a new Vercel test app, make sure\n  # to set the root directory in the dashboard to the correct path.\n  # The `vercel deploy` command runs from the root of the repository,\n  # so it has to be able to look up the test app's dir in order to know\n  # what to deploy.\n  vercel-project-id:\n    description: 'Vercel project ID for the test app'\n    required: true\n  vercel-token:\n    description: 'Vercel authentication token'\n    required: true\n  vercel-org-id:\n    description: 'Vercel organization ID'\n    required: true\noutputs:\n  deployment-url:\n    description: 'URL of the deployed preview'\n    value: ${{ steps.deploy.outputs.url }}\n\nruns:\n  using: 'composite'\n  steps:\n    - uses: pnpm/action-setup@v5.0.0\n\n    - uses: actions/setup-node@v6\n      with:\n        node-version: 24\n        cache: pnpm\n\n    - name: Install dependencies\n      shell: bash\n      run: pnpm install --frozen-lockfile\n\n    - name: Install Vercel CLI\n      shell: bash\n      run: npm i -g vercel\n\n    - name: Deploy to Vercel\n      id: deploy\n      shell: bash\n      env:\n        VERCEL_TOKEN: ${{ inputs.vercel-token }}\n        VERCEL_ORG_ID: ${{ inputs.vercel-org-id }}\n        VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }}\n      run: echo \"url=$(vercel deploy --yes --token=\"$VERCEL_TOKEN\")\" >> \"$GITHUB_OUTPUT\"\n"
  },
  {
    "path": ".github/workflows/audit.yml",
    "content": "name: audit\n\non:\n  schedule:\n    - cron: \"0 5 * * *\" # daily 5AM\n\nenv:\n  # not needed for audit\n  PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'\n\npermissions:\n  contents: read # to fetch code (actions/checkout)\n\njobs:\n  Audit:\n    # prevents this action from running on forks\n    if: github.repository == 'sveltejs/kit'\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v6\n      - uses: pnpm/action-setup@v5.0.0\n      - uses: actions/setup-node@v6\n        with:\n          node-version: '24.x'\n          cache: pnpm\n      - run: pnpm install --frozen-lockfile\n      # check prod dependencies as these would affect users\n      - run: pnpm audit --prod\n"
  },
  {
    "path": ".github/workflows/autofix-lint.yml",
    "content": "name: Autofix Lint\n\non:\n  issue_comment:\n    types: [created]\n  workflow_dispatch:\n\npermissions: {}\n\njobs:\n  autofix-lint:\n    permissions:\n      contents: write # to push the generated types commit\n      pull-requests: read # to resolve the PR head ref\n    # prevents this action from running on forks\n    if: |\n      github.repository == 'sveltejs/kit' &&\n      (\n        github.event_name == 'workflow_dispatch' ||\n        (\n          github.event.issue.pull_request != null &&\n          github.event.comment.body == '/autofix' &&\n          contains(fromJSON('[\"OWNER\", \"MEMBER\", \"COLLABORATOR\"]'), github.event.comment.author_association)\n        )\n      )\n    runs-on: ubuntu-latest\n    steps:\n      - name: Get PR ref\n        if: github.event_name != 'workflow_dispatch'\n        id: pr\n        uses: actions/github-script@v8\n        with:\n          script: |\n            const { data: pull } = await github.rest.pulls.get({\n              owner: context.repo.owner,\n              repo: context.repo.repo,\n              pull_number: context.issue.number\n            });\n            if (pull.head.repo.full_name !== `${context.repo.owner}/${context.repo.repo}`) {\n              await github.rest.issues.createComment({\n                owner: context.repo.owner,\n                repo: context.repo.repo,\n                issue_number: context.issue.number,\n                body: 'Cannot autofix: this PR is from a forked repository. The autofix workflow can only push to branches within this repository.'\n              });\n              core.setFailed('PR is from a fork');\n            }\n            core.setOutput('ref', pull.head.ref);\n      - uses: actions/checkout@v6\n        if: github.event_name == 'workflow_dispatch' || steps.pr.outcome == 'success'\n        with:\n          ref: ${{ github.event_name == 'workflow_dispatch' && github.ref || steps.pr.outputs.ref }}\n      - uses: pnpm/action-setup@v5.0.0\n      - uses: actions/setup-node@v6\n        with:\n          node-version: 24\n          cache: pnpm\n      - run: pnpm install --frozen-lockfile\n      - name: Run prettier\n        run: pnpm format\n      - name: Generate types\n        run: pnpm -F @sveltejs/kit generate:types\n      - name: Commit changes\n        run: |\n          git config user.name \"github-actions[bot]\"\n          git config user.email \"github-actions[bot]@users.noreply.github.com\"\n          git add -A\n          git diff --staged --quiet || git commit -m \"chore: autofix lint\"\n          git push origin HEAD\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: CI\n\non:\n  push:\n    branches:\n      - main\n    paths-ignore: &paths_ignore\n      - '.changeset/**'\n      - '.githooks/**'\n      - '.github/ISSUE_TEMPLATE/**'\n      - '.github/copilot-instructions.md'\n      - '.github/FUNDING.yml'\n      - '.github/PULL_REQUEST_TEMPLATE.md'\n      - 'documentation/**'\n      - 'packages/*/CHANGELOG*.md'\n      - 'packages/kit/src/types/synthetic/**'\n      - 'AGENTS.md'\n      - 'CLAUDE.md'\n      - 'CONTRIBUTING.md'\n      - 'FUNDING.json'\n      - 'LICENSE'\n      - 'README.md'\n  pull_request:\n    paths-ignore: *paths_ignore\n\nenv:\n  # we call `pnpm playwright install` instead\n  PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'\n\n# cancel in-progress runs on new commits to same PR (gitub.event.number)\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.event.number || github.sha }}\n  cancel-in-progress: true\n\npermissions:\n  contents: read # to fetch code (actions/checkout)\n\njobs:\n  pkg-pr-new:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v6\n      - uses: pnpm/action-setup@v5.0.0\n      - uses: actions/setup-node@v6\n        with:\n          node-version: 24\n          cache: pnpm\n      - run: pnpm install --frozen-lockfile\n      - run: pnpm build\n      - run: pnpx pkg-pr-new publish --comment=off ./packages/*\n  lint-all:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v6\n      - uses: pnpm/action-setup@v5.0.0\n      - uses: actions/setup-node@v6\n        with:\n          node-version: 24\n          cache: pnpm\n      - run: pnpm install --frozen-lockfile\n      - run: pnpm run lint\n      - run: cd packages/kit && pnpm prepublishOnly && { [ \"`git status --porcelain=v1`\" == \"\" ] || (echo \"Generated types have changed — please run prepublishOnly locally and commit the changes after you have reviewed them\"; git diff; exit 1); }\n      - run: pnpm run check\n  test-kit:\n    runs-on: ${{ matrix.os }}\n    timeout-minutes: 30\n    strategy:\n      fail-fast: false\n      matrix:\n        include:\n          - node-version: 18\n            os: ubuntu-latest\n            e2e-browser: 'chromium'\n            vite: 'baseline'\n          - node-version: 20\n            os: ubuntu-latest\n            e2e-browser: 'chromium'\n            vite: 'current'\n          - node-version: 22\n            os: ubuntu-latest\n            e2e-browser: 'chromium'\n            vite: 'current'\n          - node-version: 24\n            os: ubuntu-latest\n            e2e-browser: 'chromium'\n            vite: 'current'\n          - node-version: 24\n            os: ubuntu-latest\n            e2e-browser: 'chromium'\n            vite: 'beta'\n    env:\n      KIT_E2E_BROWSER: ${{matrix.e2e-browser}}\n      MATRIX_VITE: ${{matrix.vite}}\n    steps:\n      - run: git config --global core.autocrlf false\n      - uses: actions/checkout@v6\n      - uses: pnpm/action-setup@v5.0.0\n      - uses: actions/setup-node@v6\n        with:\n          node-version: ${{ matrix.node-version }}\n          cache: pnpm\n      - run: pnpm install --frozen-lockfile\n      - name: setup overrides for matrix.vite\n        if: matrix.vite != 'current'\n        run:\n          | # copies catalogs.vite-xxx to overrides in pnpm-workspace.yaml so the subsequent `pnpm install` enforces them\n          yq -i '.overrides =.catalogs.\"vite-${{matrix.vite}}\"' pnpm-workspace.yaml\n          pnpm install --no-frozen-lockfile\n          git checkout pnpm-lock.yaml pnpm-workspace.yaml # revert changes to pnpm files to avoid cache key changes\n          pnpm --dir packages/kit ls vite\n      - run: pnpm playwright install ${{ matrix.e2e-browser }}\n      - run: pnpm run sync-all\n      - run: pnpm test:kit\n        env:\n          NODE_OPTIONS: ${{matrix.node-version == 22 && '--experimental-strip-types' || ''}} # allows loading svelte.config.ts\n      - name: Print flaky test report\n        run: node scripts/print-flaky-test-report.js\n      - name: Archive test results\n        if: failure()\n        shell: bash\n        run: find packages -type d -name test-results -not -empty | tar -czf test-results.tar.gz --files-from=-\n      - name: Upload test results\n        if: failure()\n        uses: actions/upload-artifact@v7\n        with:\n          retention-days: 3\n          name: test-failure-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}-vite-${{matrix.vite}}\n          path: test-results.tar.gz\n  test-kit-cross-browser:\n    runs-on: ${{ matrix.os }}\n    timeout-minutes: 30\n    strategy:\n      fail-fast: false\n      matrix:\n        include:\n          - node-version: 24\n            os: windows-latest\n            e2e-browser: 'chromium'\n            mode: 'dev'\n          - node-version: 24\n            os: ubuntu-latest\n            e2e-browser: 'firefox'\n            mode: 'dev'\n          - node-version: 24\n            os: macOS-latest\n            e2e-browser: 'webkit'\n            mode: 'dev'\n          - node-version: 24\n            os: windows-latest\n            e2e-browser: 'chromium'\n            mode: 'build'\n          - node-version: 24\n            os: ubuntu-latest\n            e2e-browser: 'firefox'\n            mode: 'build'\n          - node-version: 24\n            os: macOS-latest\n            e2e-browser: 'webkit'\n            mode: 'build'\n    env:\n      KIT_E2E_BROWSER: ${{matrix.e2e-browser}}\n    steps:\n      - run: git config --global core.autocrlf false\n      - uses: actions/checkout@v6\n      - uses: pnpm/action-setup@v5.0.0\n      - uses: actions/setup-node@v6\n        with:\n          node-version: ${{ matrix.node-version }}\n          cache: pnpm\n      - run: pnpm install --frozen-lockfile\n      - run: pnpm playwright install ${{ matrix.e2e-browser }}\n      - run: pnpm run sync-all\n      - run: pnpm test:cross-platform:${{ matrix.mode }}\n      - name: Print flaky test report\n        run: node scripts/print-flaky-test-report.js\n      - name: Archive test results\n        if: failure()\n        shell: bash\n        run: find packages -type d -name test-results -not -empty | tar -czf test-results-cross-platform-${{ matrix.mode }}.tar.gz --files-from=-\n      - name: Upload test results\n        if: failure()\n        uses: actions/upload-artifact@v7\n        with:\n          retention-days: 3\n          name: test-failure-cross-platform-${{ matrix.mode }}-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}\n          path: test-results-cross-platform-${{ matrix.mode }}.tar.gz\n  test-kit-server-side-route-resolution:\n    runs-on: ubuntu-latest\n    timeout-minutes: 30\n    strategy:\n      fail-fast: false\n      matrix:\n        include:\n          - mode: 'dev'\n          - mode: 'build'\n    steps:\n      - run: git config --global core.autocrlf false\n      - uses: actions/checkout@v6\n      - uses: pnpm/action-setup@v5.0.0\n      - uses: actions/setup-node@v6\n        with:\n          node-version: 24\n          cache: pnpm\n      - run: pnpm install --frozen-lockfile\n      - run: pnpm playwright install chromium --no-shell\n      - run: pnpm run sync-all\n      - run: pnpm test:server-side-route-resolution:${{ matrix.mode }}\n      - name: Print flaky test report\n        run: node scripts/print-flaky-test-report.js\n      - name: Archive test results\n        if: failure()\n        shell: bash\n        run: find packages -type d -name test-results -not -empty | tar -czf test-results-server-side-route-resolution-${{ matrix.mode }}.tar.gz --files-from=-\n      - name: Upload test results\n        if: failure()\n        uses: actions/upload-artifact@v7\n        with:\n          retention-days: 3\n          name: test-failure-server-side-route-resolution-${{ matrix.mode }}-${{ github.run_id }}\n          path: test-results-server-side-route-resolution-${{ matrix.mode }}.tar.gz\n  test-kit-svelte-async:\n    runs-on: ubuntu-latest\n    timeout-minutes: 30\n    strategy:\n      fail-fast: false\n      matrix:\n        include:\n          - mode: 'dev'\n          - mode: 'build'\n    steps:\n      - run: git config --global core.autocrlf false\n      - uses: actions/checkout@v6\n      - uses: pnpm/action-setup@v5.0.0\n      - uses: actions/setup-node@v6\n        with:\n          node-version: 24\n          cache: pnpm\n      - run: pnpm install --frozen-lockfile\n      - run: pnpm playwright install chromium --no-shell\n      - run: pnpm run sync-all\n      - run: pnpm test:svelte-async:${{ matrix.mode }}\n      - name: Print flaky test report\n        run: node scripts/print-flaky-test-report.js\n      - name: Archive test results\n        if: failure()\n        shell: bash\n        run: find packages -type d -name test-results -not -empty | tar -czf test-results-svelte-async-${{ matrix.mode }}.tar.gz --files-from=-\n      - name: Upload test results\n        if: failure()\n        uses: actions/upload-artifact@v7\n        with:\n          retention-days: 3\n          name: test-failure-svelte-async-${{ matrix.mode }}-${{ github.run_id }}\n          path: test-results-svelte-async-${{ matrix.mode }}.tar.gz\n  test-others:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        node-version: [18, 20, 22, 24]\n    steps:\n      - uses: actions/checkout@v6\n      - uses: pnpm/action-setup@v5.0.0\n      - uses: actions/setup-node@v6\n        with:\n          node-version: ${{matrix.node-version}}\n          cache: pnpm\n      # required for testing netlify edge functions\n      - uses: denoland/setup-deno@v2\n        with:\n          deno-version: ^2.2.4\n      - run: pnpm install --frozen-lockfile\n      - name: setup overrides for matrix.node\n        if: matrix.node-version == 18\n        run:\n          | # copies catalogs.node-xx to overrides in pnpm-workspace.yaml so the subsequent `pnpm install` enforces them\n          yq -i '.overrides =.catalogs.\"node-18\"' pnpm-workspace.yaml\n          pnpm install --no-frozen-lockfile\n          git checkout pnpm-lock.yaml pnpm-workspace.yaml # revert changes to pnpm files to avoid cache key changes\n          pnpm --dir packages/kit ls vite @sveltejs/vite-plugin-svelte\n      - run: pnpm playwright install chromium --no-shell\n      - run: cd packages/kit && pnpm prepublishOnly\n      - run: pnpm run test:others\n        env:\n          NODE_OPTIONS: ${{matrix.node-version == 22 && '--experimental-strip-types' || ''}} # allows loading svelte.config.ts\n"
  },
  {
    "path": ".github/workflows/platform-tests-all.yml",
    "content": "name: Platform Tests (All)\n\non:\n  workflow_dispatch:\n    inputs:\n      sha:\n        description: 'Commit SHA to test and update check status on'\n        required: false\n        default: ''\n\npermissions:\n  contents: write\n\njobs:\n  vercel:\n    uses: ./.github/workflows/platform-tests-vercel.yml\n    with:\n      sha: ${{ inputs.sha }}\n    secrets: inherit\n\n  report-status:\n    if: always()\n    needs: [vercel]\n    runs-on: ubuntu-latest\n    steps:\n      - name: Determine outcome\n        id: outcome\n        run: |\n          if [ \"${{ contains(needs.*.result, 'failure') }}\" = \"true\" ]; then\n            echo \"conclusion=failure\" >> \"$GITHUB_OUTPUT\"\n            echo \"title=Platform tests failed\" >> \"$GITHUB_OUTPUT\"\n            echo \"summary=One or more platform test jobs failed. See the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.\" >> \"$GITHUB_OUTPUT\"\n          elif [ \"${{ contains(needs.*.result, 'cancelled') }}\" = \"true\" ]; then\n            echo \"conclusion=cancelled\" >> \"$GITHUB_OUTPUT\"\n            echo \"title=Platform tests cancelled\" >> \"$GITHUB_OUTPUT\"\n            echo \"summary=Platform tests were cancelled before completing.\" >> \"$GITHUB_OUTPUT\"\n          else\n            echo \"conclusion=success\" >> \"$GITHUB_OUTPUT\"\n            echo \"title=Platform tests passed\" >> \"$GITHUB_OUTPUT\"\n            echo \"summary=All platform test jobs passed.\" >> \"$GITHUB_OUTPUT\"\n          fi\n\n      - name: Report results\n        env:\n          GH_TOKEN: ${{ github.token }}\n        run: |\n          gh api repos/${{ github.repository }}/dispatches \\\n            -f event_type=platform-tests-result \\\n            -f 'client_payload[sha]=${{ inputs.sha || github.sha }}' \\\n            -f 'client_payload[conclusion]=${{ steps.outcome.outputs.conclusion }}' \\\n            -f 'client_payload[title]=${{ steps.outcome.outputs.title }}' \\\n            -f 'client_payload[summary]=${{ steps.outcome.outputs.summary }}' \\\n            -f 'client_payload[details_url]=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'\n"
  },
  {
    "path": ".github/workflows/platform-tests-vercel.yml",
    "content": "name: Platform Tests (Vercel)\n\non:\n  workflow_dispatch:\n    inputs:\n      sha:\n        description: 'Commit SHA to test'\n        required: false\n        default: ''\n  workflow_call:\n    inputs:\n      sha:\n        description: 'Commit SHA to test'\n        required: false\n        type: string\n        default: ''\n\npermissions:\n  contents: read\n\nenv:\n  PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'\n\njobs:\n  test-basic:\n    if: github.repository == 'sveltejs/kit'\n    runs-on: ubuntu-latest\n    timeout-minutes: 15\n    environment: '@sveltejs/adapter-vercel platform tests'\n    steps:\n      - uses: actions/checkout@v6\n        with:\n          ref: ${{ inputs.sha || github.sha }}\n\n      - uses: ./.github/actions/vercel-deploy\n        id: deploy\n        with:\n          test-app-dir: packages/adapter-vercel/test/apps/basic\n          vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_BASIC }}\n          vercel-token: ${{ secrets.VERCEL_TOKEN }}\n          vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}\n\n      - uses: ./.github/actions/platform-test\n        with:\n          test-app-dir: packages/adapter-vercel/test/apps/basic\n          deployment-url: ${{ steps.deploy.outputs.deployment-url }}\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "name: Release\n\non:\n  push:\n    branches:\n      - main\n\nconcurrency:\n  # prevent two release workflows from running at once\n  # race conditions here can result in releases failing\n  group: ${{ github.workflow }}\n\npermissions: {}\njobs:\n  release:\n    # prevents this action from running on forks\n    if: github.repository == 'sveltejs/kit'\n    permissions:\n      contents: write # to create release (changesets/action)\n      id-token: write # OpenID Connect token needed for provenance\n      pull-requests: write # to create pull request (changesets/action)\n    name: Release\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout Repo\n        uses: actions/checkout@v6\n        with:\n          # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits\n          fetch-depth: 0\n      - uses: pnpm/action-setup@v5.0.0\n      - name: Setup Node.js\n        uses: actions/setup-node@v6\n        with:\n          node-version: 24.x\n          cache: pnpm\n\n      - run: pnpm install --frozen-lockfile\n\n      - name: Create Release Pull Request or Publish to npm\n        id: changesets\n        uses: changesets/action@v1\n        with:\n          # This expects you to have a script called release which does a build for your packages and calls changeset publish\n          publish: pnpm changeset:release\n          version: pnpm changeset:version\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          NPM_CONFIG_PROVENANCE: true\n\n      # TODO alert discord\n      # - name: Send a Slack notification if a publish happens\n      #   if: steps.changesets.outputs.published == 'true'\n      #   # You can do something when a publish happens.\n      #   run: my-slack-bot send-notification --message \"A new version of ${GITHUB_REPOSITORY} was published!\"\n"
  },
  {
    "path": ".gitignore",
    "content": ".DS_Store\nnode_modules\ndist\ntest-results/\npackage-lock.json\nyarn.lock\nvite.config.js.timestamp-*\n/packages/package/test/**/package\n/documentation/types.js\n.env\n.vercel_build_output\n.svelte-kit\n.cloudflare\n.pnpm-debug.log\n.netlify\n.turbo\n.vercel\n.test-tmp\nsymlink-from\n.idea/\n_tmp_flaky_test_output.txt\n"
  },
  {
    "path": ".npmrc",
    "content": "link-workspace-packages = true\nshell-emulator = true\n"
  },
  {
    "path": ".prettierrc",
    "content": "{\n\t\"useTabs\": true,\n\t\"singleQuote\": true,\n\t\"trailingComma\": \"none\",\n\t\"printWidth\": 100,\n\t\"plugins\": [\"prettier-plugin-svelte\"],\n\t\"overrides\": [\n\t\t{\n\t\t\t\"files\": [\"*.svelte\"],\n\t\t\t\"options\": {\n\t\t\t\t\"bracketSameLine\": false\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"files\": [\"packages/*/README.md\"],\n\t\t\t\"options\": {\n\t\t\t\t\"useTabs\": false,\n\t\t\t\t\"tabWidth\": 2\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"files\": [\n\t\t\t\t\"**/CHANGELOG.md\",\n\t\t\t\t\"**/vite.config.js.timestamp-*\",\n\t\t\t\t\"**/.netlify/**\",\n\t\t\t\t\"**/.svelte-kit/**\",\n\t\t\t\t\"**/.custom-out-dir/**\",\n\t\t\t\t\"**/test-results/**\",\n\t\t\t\t\"**/.vercel/**\",\n\t\t\t\t\"**/.wrangler/**\",\n\t\t\t\t\"documentation/**/*.md\",\n\t\t\t\t\"packages/package/test/fixtures/**/expected/**/*\",\n\t\t\t\t\"packages/package/test/watch/expected/**/*\",\n\t\t\t\t\"packages/package/test/watch/package/**/*\",\n\t\t\t\t\"packages/kit/src/core/postbuild/fixtures/**/*\",\n\t\t\t\t\"packages/adapter-cloudflare/test/apps/workers/dist/**/*\",\n\t\t\t\t\"packages/*/test/**/build/**\"\n\t\t\t],\n\t\t\t\"options\": {\n\t\t\t\t\"rangeEnd\": 0\n\t\t\t}\n\t\t}\n\t]\n}\n"
  },
  {
    "path": ".well-known/funding-manifest-urls",
    "content": "https://svelte.dev/funding.json\n\n"
  },
  {
    "path": "AGENTS.md",
    "content": "# SvelteKit Coding Agent Guide\n\nThis guide is for AI coding agents working in the SvelteKit monorepo.\n\n**Important:** Read and follow [`CONTRIBUTING.md`](./CONTRIBUTING.md) as well - it contains essential information about testing, code structure, and contribution guidelines that applies here.\n\n## Quick Reference\n\n### Essential Commands\n\n```bash\n# Initial setup (takes 3-4 minutes, set 10+ min timeout)\npnpm install --frozen-lockfile\n\n# Build all packages (~1-2 seconds)\npnpm build\n\n# Format code (~15 seconds)\npnpm run format\n\n# Lint (takes 2-3 minutes, set 5+ min timeout)\npnpm run lint\n\n# Type checking (takes 3-4 minutes, set 8+ min timeout)\npnpm run check\n```\n\n### Testing Commands\n\n```bash\n# Unit tests only (fastest - ~6 seconds)\npnpm -F @sveltejs/kit test:unit\n\n# Run a single unit test file\npnpm -F @sveltejs/kit test:unit:dev path/to/test.spec.js\n\n# Integration tests (10-30 minutes, set 60+ min timeout)\npnpm test:kit\n\n# A single integration test suite (name of suite found in packages/kit/test/apps/*/package.json)\npnpm -F {name-of-suite} test\n\n# Run single Playwright test (must use workdir - no pnpm -F shorthand)\ncd packages/kit/test/apps/basics && npx playwright test --grep \"test name\"\n\n# Other package tests (5-15 minutes, set 30+ min timeout)\npnpm test:others\n```\n\n### Pre-submission Checklist\n\nBefore opening a PR, **all of these must pass** (see also the [PR template](./.github/PULL_REQUEST_TEMPLATE.md)):\n\n1. `pnpm run format` - Auto-format code\n2. `pnpm run lint` - Check code style (don't cancel early)\n3. `pnpm run check` - Type checking (don't cancel early)\n4. `pnpm -F @sveltejs/kit test:unit` - Run unit tests\n5. For @sveltejs/kit changes: `pnpm -F @sveltejs/kit prepublishOnly` - Generate types\n6. Run `pnpm changeset` to document changes (prefix with `fix`, `feat`, `breaking`, or `chore`)\n\n## Code Style Examples\n\nThe coding style guidelines are in `CONTRIBUTING.md`. Here are additional examples:\n\n### Imports\n\n```javascript\n// JSDoc type imports at the top\n/** @import { Handle, RequestEvent } from '@sveltejs/kit' */\n\n// Named imports (no default exports)\nimport { HttpError, SvelteKitError } from '@sveltejs/kit/internal';\n```\n\n### Functions\n\n```javascript\n// Exported named functions (no default exports)\nexport function coalesce_to_error(err) {\n\t// Implementation\n}\n\n// JSDoc for all parameters and return types\n/**\n * @param {unknown} error\n * @returns {Error}\n */\nexport function coalesce_to_error(error) {\n\t// Implementation\n}\n\n// Use arrow functions for callbacks\nconst handler = (event) => {\n\t/* ... */\n};\n```\n\n### Error Handling\n\n```javascript\n// Type checking with instanceof\nif (error instanceof HttpError || error instanceof SvelteKitError) {\n\t// Handle\n}\n\n// Graceful fallbacks\nconst status = error?.status ?? 500;\n\n// Optional chaining and nullish coalescing\nconst content_type = request.headers.get('content-type')?.split(';', 1)[0];\n```\n\n### TypeScript/JSDoc\n\n- Use JSDoc annotations for all function parameters and return types\n- Complex types: `/** @type {Array<{ type: string, subtype: string }>} */`\n- Type casting when needed: `/** @type {Error} */ (err)`\n- Enable strict mode: `checkJs: true`, `strict: true` in tsconfig.json\n\n### Formatting (via Prettier)\n\n- **Tabs for indentation** (not spaces)\n- **Single quotes** for strings\n- **No trailing commas**\n- **100 character line width**\n- Files are auto-formatted by `pnpm run format`\n\n### Comments\n\n````javascript\n// JSDoc with usage examples for public APIs\n/**\n * Sequence multiple handle functions\n *\n * @example\n * ```js\n * export const handle = sequence(first, second);\n * ```\n *\n * @param {...Handle} handlers\n * @returns {Handle}\n */\n\n// Inline comments for clarifications\n// no match equals invalid header — ignore\n````\n\n## Key Packages\n\n- `@sveltejs/kit` - Main framework (`packages/kit/`)\n- `adapter-*` - Platform adapters (node, cloudflare, netlify, vercel, static, auto)\n- `@sveltejs/package` - Package building utilities\n- `@sveltejs/enhanced-img` - Enhanced image component\n- `@sveltejs/amp` - AMP support\n\n## Troubleshooting\n\n- **Browser tests fail**: `pnpm playwright install chromium`\n- **Build failures**: Ensure `pnpm install --frozen-lockfile` completed\n- **Type errors**: Run `pnpm -F @sveltejs/kit prepublishOnly`\n- **Lint issues**: Run `pnpm run format` first\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# SvelteKit Contributing Guide\n\n## Preparing\n\nThis is a monorepo, meaning the repo holds multiple packages. It requires the use of [pnpm](https://pnpm.io/). You can [install pnpm](https://pnpm.io/installation) with:\n\n```sh\nnpm i -g pnpm\n```\n\n`pnpm` commands run in the project's root directory will run on all sub-projects. You can checkout the code and install the dependencies with:\n\n```sh\ngit clone git@github.com:sveltejs/kit.git\ncd kit\npnpm install\n```\n\n## Testing Changes\n\n### Playground\n\nYou can use the playground at [`playgrounds/basic`](./playgrounds/basic/) to experiment with your changes to SvelteKit locally.\n\n### Linking local changes\n\nIf you want to test against an existing project, you can use [pnpm `overrides`](https://pnpm.io/package_json#pnpmoverrides) in that project:\n\n```jsonc\n{\n\t// ...\n\t\"pnpm\": {\n\t\t\"overrides\": {\n\t\t\t\"@sveltejs/kit\": \"link:../path/to/svelte-kit/packages/kit\",\n\t\t\t// additionally/optional the adapter you're using\n\t\t\t\"@sveltejs/adapter-auto\": \"link:../path/to/svelte-kit/packages/adapter-auto\"\n\t\t}\n\t}\n}\n```\n\n### Testing PR changes\n\nEach pull request will be built and published via [pkg.pr.new/](https://pkg.pr.new/). You can test the change by installing the package with your PR number:\n\n```\nnpm add https://pkg.pr.new/sveltejs/kit/@sveltejs/kit@YOUR_PR_NUMBER_GOES_HERE\n```\n\n## Code structure\n\nEntry points to be aware of are:\n\n- [`packages/package`](https://github.com/sveltejs/kit/tree/main/packages/package) - for the `svelte-package` command\n- [`packages/kit/src/core`](https://github.com/sveltejs/kit/tree/main/packages/kit/src/core) - code that's called at dev/build-time\n- [`packages/kit/src/core/sync`](https://github.com/sveltejs/kit/tree/main/packages/kit/src/core/sync) - for `svelte-kit sync`, which regenerates routing info and type definitions\n- [`packages/kit/src/runtime`](https://github.com/sveltejs/kit/tree/main/packages/kit/src/runtime) - code that's called at runtime\n- [`packages/kit/src/exports/vite`](https://github.com/sveltejs/kit/tree/main/packages/kit/src/exports/vite) - for all the Vite plugin related stuff\n- [`packages/adapter-[platform]`](https://github.com/sveltejs/kit/tree/main/packages) - for the various SvelteKit-provided adapters\n\n## Good first issues\n\nIf you're looking for an issue to tackle to get familiar with the codebase and test suite, the [**low hanging fruit**](https://github.com/sveltejs/kit/issues?q=is%3Aissue+is%3Aopen+label%3A%22low+hanging+fruit%22) label contains issues that ought to be relatively straightforward to fix. Check to see if a PR already exists for an issue before working on it!\n\nIssues that have a clear solution but which _may_ be slightly more involved have the [**ready to implement**](https://github.com/sveltejs/kit/issues?q=is%3Aissue+is%3Aopen+label%3A%22ready+to+implement%22) label.\n\nIssues with the [**soon**](https://github.com/sveltejs/kit/issues?q=is%3Aissue+is%3Aopen+milestone%3Asoon) milestone are higher priority than issues with the [**later**](https://github.com/sveltejs/kit/issues?q=is%3Aissue+is%3Aopen+milestone%3Alater+) label (though PRs for 'later' issues are still welcome, especially if you're affected by them).\n\n## Testing\n\nRun `pnpm test:kit` to run the tests from the `packages/kit` directory. You can also run `pnpm test:others` to run tests from all packages **except** the `packages/kit` directory. Browser tests live in subdirectories of `packages/kit/test` such as `packages/kit/test/apps/basics`.\n\nYou can run the tests for only a single package by first moving to that directory. E.g. `cd packages/kit`.\n\nFor some packages you must rebuild each time before running the tests if you've made code changes. These packages have a `build` command. Packages like `packages/kit` don't require a build step.\n\nTo run a single integration test or otherwise control the running of the tests locally see [the Playwright CLI docs](https://playwright.dev/docs/test-cli). Note that you will need to run these commands from the test project directory such as `packages/kit/test/apps/basics`.\n\nYou can run the test server with `cd packages/kit/test/apps/basics; pnpm run dev` to hit it with your browser. The Playwright Inspector offers similar functionality.\n\nYou may need to install some dependencies first, e.g. with `npx playwright install-deps` (which only works on Ubuntu).\n\nIf there are tests that fail on the CI, you can retrieve the failed screenshots by going to the summary page of the CI run. You can usually find this by clicking on \"Details\" of the check results, clicking \"Summary\" at the top-left corner, and then scrolling to the bottom \"Artifacts\" section to download the archive.\n\nIt is very easy to introduce flakiness in a browser test. If you try to fix the flakiness in a test, you can run it until failure to gain some confidence you've fixed the test with a command like:\n\n```\nnpx playwright test --workers=1 --repeat-each 1000 --max-failures 1 -g \"accepts a Request object\"\n```\n\n## Working on Vite and other dependencies\n\nIf you would like to test local changes to Vite or another dependency, you can build it and then use [`pnpm.overrides`](https://pnpm.io/package_json#pnpmoverrides). Please note that `pnpm.overrides` must be specified in the root `package.json` and you must first list the package as a dependency in the root `package.json`:\n\n```jsonc\n{\n\t// ...\n\t\"dependencies\": {\n\t\t\"vite\": \"^4.0.0\"\n\t},\n\t\"pnpm\": {\n\t\t\"overrides\": {\n\t\t\t\"vite\": \"link:../path/to/vite/packages/vite\"\n\t\t}\n\t}\n}\n```\n\n## Documentation changes\n\nAll documentation for SvelteKit is in the [`documentation` directory](https://github.com/sveltejs/kit/tree/main/documentation), and any improvements should be made as a Pull Request to this repository. The site itself is located in the [`sveltejs/svelte.dev` repo](https://github.com/sveltejs/svelte.dev) and can be run locally to preview changes.\n\n## Sending PRs\n\nWhen you open a PR, the [PR template](./.github/PULL_REQUEST_TEMPLATE.md) includes a checklist. Please read it carefully and don't delete it.\n\n**Run tests locally before submitting.** CI runs the full suite, but catching failures early saves time for everyone. At a minimum, run `pnpm format`, `pnpm lint`, `pnpm check`, and `pnpm -F @sveltejs/kit test:unit`.\n\n### Coding style\n\nThere are a few guidelines we follow:\n\n- Internal variables are written with `snake_case` while external APIs are written with `camelCase`\n- Provide a single object as the argument to public APIs. This object can have multiple properties\n- Avoid creating new test projects under `packages/kit/test/apps` but reuse an existing one when possible\n- Ensure `pnpm lint` and `pnpm check` pass. You can run `pnpm format` to format the code\n\nTo use the git hooks in the repo, which will save you from waiting for CI to tell you that you forgot to lint, run this:\n\n```sh\ngit config core.hookspath .githooks\n```\n\n### Generating changelogs\n\nFor changes to be reflected in package changelogs, run `pnpm changeset` and follow the prompts.\n\n### Type changes\n\nIf your PR changes the generated types of SvelteKit, run `pnpm generate:types` inside `packages/kit` and commit the new output (don't format it with Prettier!). Review the changes carefully to ensure there are no unwanted changes. If you don't commit type changes, CI will fail.\n\n## Releases\n\nThe [Changesets GitHub action](https://github.com/changesets/action#with-publishing) will create and update a PR that applies changesets and publishes new versions of changed packages to npm.\n\nNew packages will need to be published manually the first time if they are scoped to the `@sveltejs` organisation, by running this from the package directory:\n\n```sh\nnpm publish --access=public\n```\n"
  },
  {
    "path": "FUNDING.json",
    "content": "{\n\t\"drips\": {\n\t\t\"ethereum\": {\n\t\t\t\"ownedBy\": \"0xCE08E02c37d90d75C2bf7D9e55f7606C8DB80E70\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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."
  },
  {
    "path": "README.md",
    "content": "[![Chat](https://img.shields.io/discord/457912077277855764?label=chat&logo=discord)](https://svelte.dev/chat)\n\n# SvelteKit\n\nWeb development, streamlined. Read the [documentation](https://svelte.dev/docs/kit) to get started.\n\n### Packages\n\n| Package                                                                     | Changelog                                                     |\n| --------------------------------------------------------------------------- | ------------------------------------------------------------- |\n| [@sveltejs/kit](packages/kit)                                               | [Changelog](packages/kit/CHANGELOG.md)                        |\n| [@sveltejs/adapter-auto](packages/adapter-auto)                             | [Changelog](packages/adapter-auto/CHANGELOG.md)               |\n| [@sveltejs/adapter-cloudflare](packages/adapter-cloudflare)                 | [Changelog](packages/adapter-cloudflare/CHANGELOG.md)         |\n| [@sveltejs/adapter-netlify](packages/adapter-netlify)                       | [Changelog](packages/adapter-netlify/CHANGELOG.md)            |\n| [@sveltejs/adapter-node](packages/adapter-node)                             | [Changelog](packages/adapter-node/CHANGELOG.md)               |\n| [@sveltejs/adapter-static](packages/adapter-static)                         | [Changelog](packages/adapter-static/CHANGELOG.md)             |\n| [@sveltejs/adapter-vercel](packages/adapter-vercel)                         | [Changelog](packages/adapter-vercel/CHANGELOG.md)             |\n| [@sveltejs/amp](packages/amp)                                               | [Changelog](packages/amp/CHANGELOG.md)                        |\n| [@sveltejs/enhanced-img](packages/enhanced-img)                             | [Changelog](packages/enhanced-img/CHANGELOG.md)               |\n| [@sveltejs/package](packages/package)                                       | [Changelog](packages/package/CHANGELOG.md)                    |\n\n[Additional adapters](https://sveltesociety.dev/packages?category=sveltekit-adapters) are maintained by the community.\n\n## Bug reporting\n\nPlease make sure the issue you're reporting involves SvelteKit. Many issues related to how a project builds originate from [Vite](https://vitejs.dev/), which is used to build a SvelteKit project. You can create a new Vite project with `npm create vite@latest` for client-side only repros and `npm create vite-extra@latest` for SSR or library repros.\n\nIf an issue originates from Vite, please report it in the [Vite issue tracker](https://github.com/vitejs/vite/issues).\n\n## Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md) for information on how to develop SvelteKit locally.\n\n## Supporting Svelte\n\nSvelte is an MIT-licensed open source project with its ongoing development made possible entirely by fantastic volunteers. If you'd like to support their efforts, please consider:\n\n- [Becoming a backer on Open Collective](https://opencollective.com/svelte).\n\nFunds donated via Open Collective will be used for compensating expenses related to Svelte's development such as hosting costs. If sufficient donations are received, funds may also be used to support Svelte's development more directly.\n\n## License\n\n[MIT](https://github.com/sveltejs/kit/blob/main/LICENSE)\n"
  },
  {
    "path": "documentation/docs/10-getting-started/10-introduction.md",
    "content": "---\ntitle: Introduction\n---\n\n## Before we begin\n\n> [!NOTE] If you're new to Svelte or SvelteKit we recommend checking out the [interactive tutorial](/tutorial/kit).\n>\n> If you get stuck, reach out for help in the [Discord chatroom](/chat).\n\n## What is SvelteKit?\n\nSvelteKit is a framework for rapidly developing robust, performant web applications using [Svelte](../svelte). If you're coming from React, SvelteKit is similar to Next. If you're coming from Vue, SvelteKit is similar to Nuxt.\n\nTo learn more about the kinds of applications you can build with SvelteKit, see the [documentation regarding project types](project-types).\n\n## What is Svelte?\n\nIn short, Svelte is a way of writing user interface components — like a navigation bar, comment section, or contact form — that users see and interact with in their browsers. The Svelte compiler converts your components to JavaScript that can be run to render the HTML for the page and to CSS that styles the page. You don't need to know Svelte to understand the rest of this guide, but it will help. If you'd like to learn more, check out [the Svelte tutorial](/tutorial).\n\n## SvelteKit vs Svelte\n\nSvelte renders UI components. You can compose these components and render an entire page with just Svelte, but you need more than just Svelte to write an entire app.\n\nSvelteKit helps you build web apps while following modern best practices and providing solutions to common development challenges. It offers everything from basic functionalities — like a [router](glossary#Routing) that updates your UI when a link is clicked — to more advanced capabilities. Its extensive list of features includes [build optimizations](https://vitejs.dev/guide/features.html#build-optimizations) to load only the minimal required code; [offline support](service-workers); [preloading](link-options#data-sveltekit-preload-data) pages before user navigation; [configurable rendering](page-options) to handle different parts of your app on the server via [SSR](glossary#SSR), in the browser through [client-side rendering](glossary#CSR), or at build-time with [prerendering](glossary#Prerendering); [image optimization](images); and much more. Building an app with all the modern best practices is fiendishly complicated, but SvelteKit does all the boring stuff for you so that you can get on with the creative part.\n\nIt reflects changes to your code in the browser instantly to provide a lightning-fast and feature-rich development experience by leveraging [Vite](https://vitejs.dev/) with a [Svelte plugin](https://github.com/sveltejs/vite-plugin-svelte) to do [Hot Module Replacement (HMR)](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#hot).\n"
  },
  {
    "path": "documentation/docs/10-getting-started/20-creating-a-project.md",
    "content": "---\ntitle: Creating a project\n---\n\nThe easiest way to start building a SvelteKit app is to run `npx sv create`:\n\n```sh\nnpx sv create my-app\ncd my-app\nnpm run dev\n```\n\nThe first command will scaffold a new project in the `my-app` directory asking if you'd like to set up some basic tooling such as TypeScript. See [the CLI docs](/docs/cli/overview) for information about these options and [the integrations page](./integrations) for pointers on setting up additional tooling. `npm run dev` will then start the development server on [localhost:5173](http://localhost:5173) - make sure you install dependencies before running this if you didn't do so during project creation.\n\nThere are two basic concepts:\n\n- Each page of your app is a [Svelte](../svelte) component\n- You create pages by adding files to the `src/routes` directory of your project. These will be server-rendered so that a user's first visit to your app is as fast as possible, then a client-side app takes over\n\nTry editing the files to get a feel for how everything works.\n\n## Editor setup\n\nWe recommend using [Visual Studio Code (aka VS Code)](https://code.visualstudio.com/download) with [the Svelte extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode), but [support also exists for numerous other editors](https://sveltesociety.dev/collection/editor-support-c85c080efc292a34).\n"
  },
  {
    "path": "documentation/docs/10-getting-started/25-project-types.md",
    "content": "---\ntitle: Project types\n---\n\nSvelteKit offers configurable rendering, which allows you to build and deploy your project in several different ways. You can build all of the below types of applications and more with SvelteKit. Rendering settings are not mutually exclusive and you may choose the optimal manner with which to render different parts of your application.\n\nIf you don't have a particular way you'd like to build your application in mind, don't worry! The way your application is built, deployed, and rendered is controlled by which adapter you've chosen and a small amount of configuration and these can always be changed later. The [project structure](project-structure) and [routing](glossary#Routing) will be the same regardless of the project type that you choose.\n\n## Default rendering\n\nBy default, when a user visits a site, SvelteKit will render the first page with [server-side rendering (SSR)](glossary#SSR) and subsequent pages with [client-side rendering (CSR)](glossary#CSR). Using SSR for the initial render improves SEO and perceived performance of the initial page load. Client-side rendering then takes over and updates the page without having to rerender common components, which is typically faster and eliminates a flash when navigating between pages. Apps built with this hybrid rendering approach have also been called [transitional apps](https://www.youtube.com/watch?v=860d8usGC0o).\n\n## Static site generation\n\nYou can use SvelteKit as a [static site generator (SSG)](glossary#SSG) that fully [prerenders](glossary#Prerendering) your site with static rendering using [`adapter-static`](adapter-static). You may also use [the prerender option](page-options#prerender) to prerender only some pages and then choose a different adapter with which to dynamically server-render other pages.\n\nTools built solely to do static site generation may scale the prerendering process more efficiently during build when rendering a very large number of pages. When working with very large statically generated sites, you can avoid long build times with [Incremental Static Regeneration (ISR) if using `adapter-vercel`](adapter-vercel#Incremental-Static-Regeneration). And in contrast to purpose-built SSGs, SvelteKit allows for nicely mixing and matching different rendering types on different pages.\n\n## Single-page app\n\n[Single-page apps (SPAs)](glossary#SPA) exclusively use [client-side rendering (CSR)](glossary#CSR). You can [build single-page apps (SPAs)](single-page-apps) with SvelteKit. As with all types of SvelteKit applications, you can write your backend in SvelteKit or [another language or framework](#Separate-backend). If you are building an application with no backend or a [separate backend](#Separate-backend), you can simply skip over and ignore the parts of the docs talking about `server` files.\n\n## Multi-page app\n\nSvelteKit isn't typically used to build [traditional multi-page apps](glossary#MPA). However, in SvelteKit you can remove all JavaScript on a page with [`csr = false`](page-options#csr), which will render subsequent links on the server, or you can use [`data-sveltekit-reload`](link-options#data-sveltekit-reload) to render specific links on the server.\n\n## Separate backend\n\nIf your backend is written in another language such as Go, Java, PHP, Ruby, Rust, or C#, there are a couple of ways that you can deploy your application. The most recommended way would be to deploy your SvelteKit frontend separately from your backend utilizing `adapter-node` or a serverless adapter. Some users prefer not to have a separate process to manage and decide to deploy their application as a [single-page app (SPA)](single-page-apps) served by their backend server, but note that single-page apps have worse SEO and performance characteristics.\n\nIf you are using an external backend, you can simply skip over and ignore the parts of the docs talking about `server` files. You may also want to reference [the FAQ about how to make calls to a separate backend](faq#How-do-I-use-a-different-backend-API-server).\n\n## Serverless app\n\nSvelteKit apps are simple to run on serverless platforms. [The default zero config adapter](adapter-auto) will automatically run your app on a number of supported platforms or you can use [`adapter-vercel`](adapter-vercel), [`adapter-netlify`](adapter-netlify), or [`adapter-cloudflare`](adapter-cloudflare) to provide platform-specific configuration. And [community adapters](/packages#sveltekit-adapters) allow you to deploy your application to almost any serverless environment. Some of these adapters such as [`adapter-vercel`](adapter-vercel) and [`adapter-netlify`](adapter-netlify) offer an `edge` option, to support [edge rendering](glossary#Edge) for improved latency.\n\n## Your own server\n\nYou can deploy to your own server or VPS using [`adapter-node`](adapter-node).\n\n## Container\n\nYou can use [`adapter-node`](adapter-node) to run a SvelteKit app within a container such as Docker or LXC.\n\n## Library\n\nYou can create a library to be used by other Svelte apps with the [`@sveltejs/package`](packaging) add-on to SvelteKit by choosing the library option when running [`sv create`](/docs/cli/sv-create).\n\n## Offline app\n\nSvelteKit has full support for [service workers](service-workers) allowing you to build many types of applications such as offline apps and [progressive web apps](glossary#PWA).\n\n## Mobile app\n\nYou can turn a [SvelteKit SPA](single-page-apps) into a mobile app with [Tauri](https://v2.tauri.app/start/frontend/sveltekit/) or [Capacitor](https://capacitorjs.com/solution/svelte). Mobile features like the camera, geolocation, and push notifications are available via plugins for both platforms.\n\nThese mobile development platforms work by starting a local web server and then serving your application like a static host on your phone. You may find [`bundleStrategy: 'single'`](configuration#output) to be a helpful option to limit the number of requests made. E.g. at the time of writing, the Capacitor local server uses HTTP/1, which limits the number of concurrent connections.\n\n## Desktop app\n\nYou can turn a [SvelteKit SPA](single-page-apps) into a desktop app with [Tauri](https://v2.tauri.app/start/frontend/sveltekit/), [Wails](https://wails.io/docs/guides/sveltekit/), or [Electron](https://www.electronjs.org/).\n\n## Browser extension\n\nYou can build browser extensions using either [`adapter-static`](adapter-static) or [community adapters](/packages#sveltekit-adapters) specifically tailored towards browser extensions.\n\n## Embedded device\n\nBecause of its efficient rendering, Svelte can be run on low power devices. Embedded devices like microcontrollers and TVs may limit the number of concurrent connections. In order to reduce the number of concurrent requests, you may find [`bundleStrategy: 'single'`](configuration#output) to be a helpful option in this deployment configuration.\n"
  },
  {
    "path": "documentation/docs/10-getting-started/30-project-structure.md",
    "content": "---\ntitle: Project structure\n---\n\nA typical SvelteKit project looks like this:\n\n```tree\nmy-project/\n├ src/\n│ ├ lib/\n│ │ ├ server/\n│ │ │ └ [your server-only lib files]\n│ │ └ [your lib files]\n│ ├ params/\n│ │ └ [your param matchers]\n│ ├ routes/\n│ │ └ [your routes]\n│ ├ app.html\n│ ├ error.html\n│ ├ hooks.client.js\n│ ├ hooks.server.js\n│ ├ service-worker.js\n│ └ instrumentation.server.js\n├ static/\n│ └ [your static assets]\n├ tests/\n│ └ [your tests]\n├ package.json\n├ svelte.config.js\n├ tsconfig.json\n└ vite.config.js\n```\n\nYou'll also find common files like `.gitignore` and `.npmrc` (and `.prettierrc` and `eslint.config.js` and so on, if you chose those options when running `npx sv create`).\n\n## Project files\n\n### src\n\nThe `src` directory contains the meat of your project. Everything except `src/routes` and `src/app.html` is optional.\n\n- `lib` contains your library code (utilities and components), which can be imported via the [`$lib`]($lib) alias, or packaged up for distribution using [`svelte-package`](packaging)\n  - `server` contains your server-only library code. It can be imported by using the [`$lib/server`](server-only-modules) alias. SvelteKit will prevent you from importing these in client code.\n- `params` contains any [param matchers](advanced-routing#Matching) your app needs\n- `routes` contains the [routes](routing) of your application. You can also colocate other components that are only used within a single route here\n- `app.html` is your page template — an HTML document containing the following placeholders:\n  - `%sveltekit.head%` — `<link>` and `<script>` elements needed by the app, plus any `<svelte:head>` content\n  - `%sveltekit.body%` — the markup for a rendered page. This should live inside a `<div>` or other element, rather than directly inside `<body>`, to prevent bugs caused by browser extensions injecting elements that are then destroyed by the hydration process. SvelteKit will warn you in development if this is not the case\n  - `%sveltekit.assets%` — either [`paths.assets`](configuration#paths), if specified, or a relative path to [`paths.base`](configuration#paths)\n  - `%sveltekit.nonce%` — a [CSP](configuration#csp) nonce for manually included links and scripts, if used\n  - `%sveltekit.env.[NAME]%` - this will be replaced at render time with the `[NAME]` environment variable, which must begin with the [`publicPrefix`](configuration#env) (usually `PUBLIC_`). It will fallback to `''` if not matched.\n  - `%sveltekit.version%` — the app version, which can be specified with the [`version`](configuration#version) configuration\n- `error.html` is the page that is rendered when everything else fails. It can contain the following placeholders:\n  - `%sveltekit.status%` — the HTTP status\n  - `%sveltekit.error.message%` — the error message\n- `hooks.client.js` contains your client [hooks](hooks)\n- `hooks.server.js` contains your server [hooks](hooks)\n- `service-worker.js` contains your [service worker](service-workers)\n- `instrumentation.server.js` contains your [observability](observability) setup and instrumentation code\n  - Requires adapter support. If your adapter supports it, it is guaranteed to run prior to loading and running your application code.\n\n(Whether the project contains `.js` or `.ts` files depends on whether you opt to use TypeScript when you create your project.)\n\nIf you added [Vitest](https://vitest.dev) when you set up your project, your unit tests will live in the `src` directory with a `.test.js` extension.\n\n### static\n\nAny static assets that should be served without any alteration to the name — such as `robots.txt` — go in here. It's generally preferable to minimize the number of assets in `static/` and instead `import` them. Using an `import` allows [Vite's built-in handling](images#Vite's-built-in-handling) to give a unique name to an asset based on a hash of its contents so that it can be cached.\n\n### tests\n\nIf you added [Playwright](https://playwright.dev/) for browser testing when you set up your project, the tests will live in this directory.\n\n### package.json\n\nYour `package.json` file must include `@sveltejs/kit`, `svelte` and `vite` as `devDependencies`.\n\nWhen you create a project with `npx sv create`, you'll also notice that `package.json` includes `\"type\": \"module\"`. This means that `.js` files are interpreted as native JavaScript modules with `import` and `export` keywords. Legacy CommonJS files need a `.cjs` file extension.\n\n### svelte.config.js\n\nThis file contains your Svelte and SvelteKit [configuration](configuration).\n\n### tsconfig.json\n\nThis file (or `jsconfig.json`, if you prefer type-checked `.js` files over `.ts` files) configures TypeScript, if you added typechecking during `npx sv create`. Since SvelteKit relies on certain configuration being set a specific way, it generates its own `.svelte-kit/tsconfig.json` file which your own config `extends`. To make changes to top-level options such as `include` and `exclude`, we recommend extending the generated config; see the [`typescript.config` setting](configuration#typescript) for more details.\n\n### vite.config.js\n\nA SvelteKit project is really just a [Vite](https://vitejs.dev) project that uses the [`@sveltejs/kit/vite`](@sveltejs-kit-vite) plugin, along with any other [Vite configuration](https://vitejs.dev/config/).\n\n## Other files\n\n### .svelte-kit\n\nAs you develop and build your project, SvelteKit will generate files in a `.svelte-kit` directory (configurable as [`outDir`](configuration#outDir)). You can ignore its contents, and delete them at any time (they will be regenerated when you next `dev` or `build`).\n"
  },
  {
    "path": "documentation/docs/10-getting-started/40-web-standards.md",
    "content": "---\ntitle: Web standards\n---\n\nThroughout this documentation, you'll see references to the standard [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) that SvelteKit builds on top of. Rather than reinventing the wheel, we _use the platform_, which means your existing web development skills are applicable to SvelteKit. Conversely, time spent learning SvelteKit will help you be a better web developer elsewhere.\n\nThese APIs are available in all modern browsers and in many non-browser environments like Cloudflare Workers, Deno, and Vercel Functions. During development, and in [adapters](adapters) for Node-based environments (including AWS Lambda), they're made available via polyfills where necessary (for now, that is — Node is rapidly adding support for more web standards).\n\nIn particular, you'll get comfortable with the following:\n\n## Fetch APIs\n\nSvelteKit uses [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) for getting data from the network. It's available in [hooks](hooks) and [server routes](routing#server) as well as in the browser.\n\n> [!NOTE] A special version of `fetch` is available in [`load`](load) functions, [server hooks](hooks#Server-hooks) and [API routes](routing#server) for invoking endpoints directly during server-side rendering, without making an HTTP call, while preserving credentials. (To make credentialled fetches in server-side code outside `load`, you must explicitly pass `cookie` and/or `authorization` headers.) It also allows you to make relative requests, whereas server-side `fetch` normally requires a fully qualified URL.\n\nBesides `fetch` itself, the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) includes the following interfaces:\n\n### Request\n\nAn instance of [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) is accessible in [hooks](hooks) and [server routes](routing#server) as `event.request`. It contains useful methods like `request.json()` and `request.formData()` for getting data that was posted to an endpoint.\n\n### Response\n\nAn instance of [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) is returned from `await fetch(...)` and handlers in `+server.js` files. Fundamentally, a SvelteKit app is a machine for turning a `Request` into a `Response`.\n\n### Headers\n\nThe [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) interface allows you to read incoming `request.headers` and set outgoing `response.headers`. For example, you can get the `request.headers` as shown below, and use the [`json` convenience function](@sveltejs-kit#json) to send modified `response.headers`:\n\n```js\n// @errors: 2461\n/// file: src/routes/what-is-my-user-agent/+server.js\nimport { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET({ request }) {\n\t// log all headers\n\tconsole.log(...request.headers);\n\n\t// create a JSON Response using a header we received\n\treturn json({\n\t\t// retrieve a specific header\n\t\tuserAgent: request.headers.get('user-agent')\n\t}, {\n\t\t// set a header on the response\n\t\theaders: { 'x-custom-header': 'potato' }\n\t});\n}\n```\n\n## FormData\n\nWhen dealing with HTML native form submissions you'll be working with [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) objects.\n\n```js\n// @errors: 2461\n/// file: src/routes/hello/+server.js\nimport { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport async function POST(event) {\n\tconst body = await event.request.formData();\n\n\t// log all fields\n\tconsole.log([...body]);\n\n\treturn json({\n\t\t// get a specific field's value\n\t\tname: body.get('name') ?? 'world'\n\t});\n}\n```\n\n## Stream APIs\n\nMost of the time, your endpoints will return complete data, as in the `userAgent` example above. Sometimes, you may need to return a response that's too large to fit in memory in one go, or is delivered in chunks, and for this the platform provides [streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) — [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream), [WritableStream](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream) and [TransformStream](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream).\n\n## URL APIs\n\nURLs are represented by the [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) interface, which includes useful properties like `origin` and `pathname` (and, in the browser, `hash`). This interface shows up in various places — `event.url` in [hooks](hooks) and [server routes](routing#server), [`page.url`]($app-state) in [pages](routing#page), `from` and `to` in [`beforeNavigate` and `afterNavigate`]($app-navigation) and so on.\n\n### URLSearchParams\n\nWherever you encounter a URL, you can access query parameters via `url.searchParams`, which is an instance of [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams):\n\n```js\n// @filename: ambient.d.ts\ndeclare global {\n\tconst url: URL;\n}\n\nexport {};\n\n// @filename: index.js\n// ---cut---\nconst foo = url.searchParams.get('foo');\n```\n\n## Web Crypto\n\nThe [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is made available via the `crypto` global. It's used internally for [Content Security Policy](configuration#csp) headers, but you can also use it for things like generating UUIDs:\n\n```js\nconst uuid = crypto.randomUUID();\n```\n"
  },
  {
    "path": "documentation/docs/10-getting-started/index.md",
    "content": "---\ntitle: Getting started\n---\n"
  },
  {
    "path": "documentation/docs/20-core-concepts/10-routing.md",
    "content": "---\ntitle: Routing\n---\n\nAt the heart of SvelteKit is a _filesystem-based router_. The routes of your app — i.e. the URL paths that users can access — are defined by the directories in your codebase:\n\n- `src/routes` is the root route\n- `src/routes/about` creates an `/about` route\n- `src/routes/blog/[slug]` creates a route with a _parameter_, `slug`, that can be used to load data dynamically when a user requests a page like `/blog/hello-world`\n\n> [!NOTE] You can change `src/routes` to a different directory by editing the [project config](configuration).\n\nEach route directory contains one or more _route files_, which can be identified by their `+` prefix.\n\nWe'll introduce these files in a moment in more detail, but here are a few simple rules to help you remember how SvelteKit's routing works:\n\n* All files can run on the server\n* All files run on the client except `+server` files\n* `+layout` and `+error` files apply to subdirectories as well as the directory they live in\n\n## +page\n\n### +page.svelte\n\nA `+page.svelte` component defines a page of your app. By default, pages are rendered both on the server ([SSR](glossary#SSR)) for the initial request and in the browser ([CSR](glossary#CSR)) for subsequent navigation.\n\n```svelte\n<!--- file: src/routes/+page.svelte --->\n<h1>Hello and welcome to my site!</h1>\n<a href=\"/about\">About my site</a>\n```\n\n```svelte\n<!--- file: src/routes/about/+page.svelte --->\n<h1>About this site</h1>\n<p>TODO...</p>\n<a href=\"/\">Home</a>\n```\n\n> [!NOTE] SvelteKit uses `<a>` elements to navigate between routes, rather than a framework-specific `<Link>` component.\n\nPages can receive data from `load` functions via the `data` prop.\n\n```svelte\n<!--- file: src/routes/blog/[slug]/+page.svelte --->\n<script>\n\t/** @type {import('./$types').PageProps} */\n\tlet { data } = $props();\n</script>\n\n<h1>{data.title}</h1>\n<div>{@html data.content}</div>\n```\n\nAs of 2.24, pages also receive a `params` prop which is typed based on the route parameters. This is particularly useful alongside [remote functions](remote-functions):\n\n```svelte\n<!--- file: src/routes/blog/[slug]/+page.svelte --->\n<script>\n\timport { getPost } from '../blog.remote';\n\n\t/** @type {import('./$types').PageProps} */\n\tlet { params } = $props();\n\n\tconst post = $derived(await getPost(params.slug));\n</script>\n\n<h1>{post.title}</h1>\n<div>{@html post.content}</div>\n```\n\n> [!LEGACY]\n> `PageProps` was added in 2.16.0. In earlier versions, you had to type the `data` property manually with `PageData` instead, see [$types](#\\$types).\n>\n> In Svelte 4, you'd use `export let data` instead.\n\n### +page.js\n\nOften, a page will need to load some data before it can be rendered. For this, we add a `+page.js` module that exports a `load` function:\n\n```js\n/// file: src/routes/blog/[slug]/+page.js\nimport { error } from '@sveltejs/kit';\n\n/** @type {import('./$types').PageLoad} */\nexport function load({ params }) {\n\tif (params.slug === 'hello-world') {\n\t\treturn {\n\t\t\ttitle: 'Hello world!',\n\t\t\tcontent: 'Welcome to our blog. Lorem ipsum dolor sit amet...'\n\t\t};\n\t}\n\n\terror(404, 'Not found');\n}\n```\n\nThis function runs alongside `+page.svelte`, which means it runs on the server during server-side rendering and in the browser during client-side navigation. See [`load`](load) for full details of the API.\n\nAs well as `load`, `+page.js` can export values that configure the page's behaviour:\n\n- `export const prerender = true` or `false` or `'auto'`\n- `export const ssr = true` or `false`\n- `export const csr = true` or `false`\n\nYou can find more information about these in [page options](page-options).\n\n### +page.server.js\n\nIf your `load` function can only run on the server — for example, if it needs to fetch data from a database or you need to access private [environment variables]($env-static-private) like API keys — then you can rename `+page.js` to `+page.server.js` and change the `PageLoad` type to `PageServerLoad`.\n\n```js\n/// file: src/routes/blog/[slug]/+page.server.js\n\n// @filename: ambient.d.ts\ndeclare global {\n\tconst getPostFromDatabase: (slug: string) => {\n\t\ttitle: string;\n\t\tcontent: string;\n\t}\n}\n\nexport {};\n\n// @filename: index.js\n// ---cut---\nimport { error } from '@sveltejs/kit';\n\n/** @type {import('./$types').PageServerLoad} */\nexport async function load({ params }) {\n\tconst post = await getPostFromDatabase(params.slug);\n\n\tif (post) {\n\t\treturn post;\n\t}\n\n\terror(404, 'Not found');\n}\n```\n\nDuring client-side navigation, SvelteKit will load this data from the server, which means that the returned value must be serializable using [devalue](https://github.com/rich-harris/devalue). See [`load`](load) for full details of the API.\n\nLike `+page.js`, `+page.server.js` can export [page options](page-options) — `prerender`, `ssr` and `csr`.\n\nA `+page.server.js` file can also export _actions_. If `load` lets you read data from the server, `actions` let you write data _to_ the server using the `<form>` element. To learn how to use them, see the [form actions](form-actions) section.\n\n## +error\n\nIf an error occurs during `load`, SvelteKit will render a default error page. You can customise this error page on a per-route basis by adding an `+error.svelte` file:\n\n```svelte\n<!--- file: src/routes/blog/[slug]/+error.svelte --->\n<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.status}: {page.error.message}</h1>\n```\n\n> [!LEGACY]\n> `$app/state` was added in SvelteKit 2.12. If you're using an earlier version or are using Svelte 4, use `$app/stores` instead.\n\nSvelteKit will 'walk up the tree' looking for the closest error boundary — if the file above didn't exist it would try `src/routes/blog/+error.svelte` and then `src/routes/+error.svelte` before rendering the default error page. If _that_ fails (or if the error was thrown from the `load` function of the root `+layout`, which sits 'above' the root `+error`), SvelteKit will bail out and render a static fallback error page, which you can customise by creating a `src/error.html` file.\n\nIf the error occurs inside a `load` function in `+layout(.server).js`, the closest error boundary in the tree is an `+error.svelte` file _above_ that layout (not next to it).\n\nIf no route can be found (404), `src/routes/+error.svelte` (or the default error page, if that file does not exist) will be used.\n\n> [!NOTE] `+error.svelte` is _not_ used when an error occurs inside [`handle`](hooks#Server-hooks-handle) or a [+server.js](#server) request handler.\n\nYou can read more about error handling [here](errors).\n\n## +layout\n\nSo far, we've treated pages as entirely standalone components — upon navigation, the existing `+page.svelte` component will be destroyed, and a new one will take its place.\n\nBut in many apps, there are elements that should be visible on _every_ page, such as top-level navigation or a footer. Instead of repeating them in every `+page.svelte`, we can put them in _layouts_.\n\n### +layout.svelte\n\nTo create a layout that applies to every page, make a file called `src/routes/+layout.svelte`. The default layout (the one that SvelteKit uses if you don't bring your own) looks like this...\n\n```svelte\n<script>\n\tlet { children } = $props();\n</script>\n\n{@render children()}\n```\n\n...but we can add whatever markup, styles and behaviour we want. The only requirement is that the component includes a `@render` tag for the page content. For example, let's add a nav bar:\n\n```svelte\n<!--- file: src/routes/+layout.svelte --->\n<script>\n\tlet { children } = $props();\n</script>\n\n<nav>\n\t<a href=\"/\">Home</a>\n\t<a href=\"/about\">About</a>\n\t<a href=\"/settings\">Settings</a>\n</nav>\n\n{@render children()}\n```\n\nIf we create pages for `/`, `/about` and `/settings`...\n\n```html\n/// file: src/routes/+page.svelte\n<h1>Home</h1>\n```\n\n```html\n/// file: src/routes/about/+page.svelte\n<h1>About</h1>\n```\n\n```html\n/// file: src/routes/settings/+page.svelte\n<h1>Settings</h1>\n```\n\n...the nav will always be visible, and clicking between the three pages will only result in the `<h1>` being replaced.\n\nLayouts can be _nested_. Suppose we don't just have a single `/settings` page, but instead have nested pages like `/settings/profile` and `/settings/notifications` with a shared submenu (for a real-life example, see [github.com/settings](https://github.com/settings)).\n\nWe can create a layout that only applies to pages below `/settings` (while inheriting the root layout with the top-level nav):\n\n```svelte\n<!--- file: src/routes/settings/+layout.svelte --->\n<script>\n\t/** @type {import('./$types').LayoutProps} */\n\tlet { data, children } = $props();\n</script>\n\n<h1>Settings</h1>\n\n<div class=\"submenu\">\n\t{#each data.sections as section}\n\t\t<a href=\"/settings/{section.slug}\">{section.title}</a>\n\t{/each}\n</div>\n\n{@render children()}\n```\n\n> [!LEGACY]\n> `LayoutProps` was added in 2.16.0. In earlier versions, you had to [type the properties manually instead](#\\$types).\n\nYou can see how `data` is populated by looking at the `+layout.js` example in the next section just below.\n\nBy default, each layout inherits the layout above it. Sometimes that isn't what you want - in this case, [advanced layouts](advanced-routing#Advanced-layouts) can help you.\n\n### +layout.js\n\nJust like `+page.svelte` loading data from `+page.js`, your `+layout.svelte` component can get data from a [`load`](load) function in `+layout.js`.\n\n```js\n/// file: src/routes/settings/+layout.js\n/** @type {import('./$types').LayoutLoad} */\nexport function load() {\n\treturn {\n\t\tsections: [\n\t\t\t{ slug: 'profile', title: 'Profile' },\n\t\t\t{ slug: 'notifications', title: 'Notifications' }\n\t\t]\n\t};\n}\n```\n\nIf a `+layout.js` exports [page options](page-options) — `prerender`, `ssr` and `csr` — they will be used as defaults for child pages.\n\nData returned from a layout's `load` function is also available to all its child pages:\n\n```svelte\n<!--- file: src/routes/settings/profile/+page.svelte --->\n<script>\n\t/** @type {import('./$types').PageProps} */\n\tlet { data } = $props();\n\n\tconsole.log(data.sections); // [{ slug: 'profile', title: 'Profile' }, ...]\n</script>\n```\n\n> [!NOTE] Often, layout data is unchanged when navigating between pages. SvelteKit will intelligently rerun [`load`](load) functions when necessary.\n\n### +layout.server.js\n\nTo run your layout's `load` function on the server, move it to `+layout.server.js`, and change the `LayoutLoad` type to `LayoutServerLoad`.\n\nLike `+layout.js`, `+layout.server.js` can export [page options](page-options) — `prerender`, `ssr` and `csr`.\n\n## +server\n\nAs well as pages, you can define routes with a `+server.js` file (sometimes referred to as an 'API route' or an 'endpoint'), which gives you full control over the response. Your `+server.js` file exports functions corresponding to HTTP verbs like `GET`, `POST`, `PATCH`, `PUT`, `DELETE`, `OPTIONS`, and `HEAD` that take a [`RequestEvent`](@sveltejs-kit#RequestEvent) argument and return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.\n\nFor example we could create an `/api/random-number` route with a `GET` handler:\n\n```js\n/// file: src/routes/api/random-number/+server.js\nimport { error } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET({ url }) {\n\tconst min = Number(url.searchParams.get('min') ?? '0');\n\tconst max = Number(url.searchParams.get('max') ?? '1');\n\n\tconst d = max - min;\n\n\tif (isNaN(d) || d < 0) {\n\t\terror(400, 'min and max must be numbers, and min must be less than max');\n\t}\n\n\tconst random = min + Math.random() * d;\n\n\treturn new Response(String(random));\n}\n```\n\nThe first argument to `Response` can be a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream), making it possible to stream large amounts of data or create server-sent events (unless deploying to platforms that buffer responses, like AWS Lambda).\n\nYou can use the [`error`](@sveltejs-kit#error), [`redirect`](@sveltejs-kit#redirect) and [`json`](@sveltejs-kit#json) methods from `@sveltejs/kit` for convenience (but you don't have to).\n\nIf an error is thrown (either `error(...)` or an unexpected error), the response will be a JSON representation of the error or a fallback error page — which can be customised via `src/error.html` — depending on the `Accept` header. The [`+error.svelte`](#error) component will _not_ be rendered in this case. You can read more about error handling [here](errors).\n\n> [!NOTE] When creating an `OPTIONS` handler, note that Vite will inject `Access-Control-Allow-Origin` and `Access-Control-Allow-Methods` headers — these will not be present in production unless you add them.\n\n> [!NOTE] `+layout` files have no effect on `+server.js` files. If you want to run some logic before each request, add it to the server [`handle`](hooks#Server-hooks-handle) hook.\n\n### Receiving data\n\nBy exporting `POST`/`PUT`/`PATCH`/`DELETE`/`OPTIONS`/`HEAD` handlers, `+server.js` files can be used to create a complete API:\n\n```svelte\n<!--- file: src/routes/add/+page.svelte --->\n<script>\n\tlet a = $state(0);\n\tlet b = $state(0);\n\tlet total = $state(0);\n\n\tasync function add() {\n\t\tconst response = await fetch('/api/add', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: JSON.stringify({ a, b }),\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/json'\n\t\t\t}\n\t\t});\n\n\t\ttotal = await response.json();\n\t}\n</script>\n\n<input type=\"number\" bind:value={a}> +\n<input type=\"number\" bind:value={b}> =\n{total}\n\n<button onclick={add}>Calculate</button>\n```\n\n```js\n/// file: src/routes/api/add/+server.js\nimport { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport async function POST({ request }) {\n\tconst { a, b } = await request.json();\n\treturn json(a + b);\n}\n```\n\n> [!NOTE] In general, [form actions](form-actions) are a better way to submit data from the browser to the server.\n\n> [!NOTE] If a `GET` handler is exported, a `HEAD` request will return the `content-length` of the `GET` handler's response body.\n\n### Fallback method handler\n\nExporting the `fallback` handler will match any unhandled request methods, including methods like `MOVE` which have no dedicated export from `+server.js`.\n\n```js\n/// file: src/routes/api/add/+server.js\nimport { json, text } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport async function POST({ request }) {\n\tconst { a, b } = await request.json();\n\treturn json(a + b);\n}\n\n// This handler will respond to PUT, PATCH, DELETE, etc.\n/** @type {import('./$types').RequestHandler} */\nexport async function fallback({ request }) {\n\treturn text(`I caught your ${request.method} request!`);\n}\n```\n\n> [!NOTE] For `HEAD` requests, the `GET` handler takes precedence over the `fallback` handler.\n\n### Content negotiation\n\n`+server.js` files can be placed in the same directory as `+page` files, allowing the same route to be either a page or an API endpoint. To determine which, SvelteKit applies the following rules:\n\n- `PUT`/`PATCH`/`DELETE`/`OPTIONS` requests are always handled by `+server.js` since they do not apply to pages\n- `GET`/`POST`/`HEAD` requests are treated as page requests if the `accept` header prioritises `text/html` (in other words, it's a browser page request), else they are handled by `+server.js`.\n- Responses to `GET` requests will include a `Vary: Accept` header, so that proxies and browsers cache HTML and JSON responses separately.\n\n## $types\n\nThroughout the examples above, we've been importing types from a `$types.d.ts` file. This is a file SvelteKit creates for you in a hidden directory if you're using TypeScript (or JavaScript with JSDoc type annotations) to give you type safety when working with your root files.\n\nFor example, annotating `let { data } = $props()` with `PageProps` (or `LayoutProps`, for a `+layout.svelte` file) tells TypeScript that the type of `data` is whatever was returned from `load`:\n\n```svelte\n<!--- file: src/routes/blog/[slug]/+page.svelte --->\n<script>\n\t/** @type {import('./$types').PageProps} */\n\tlet { data } = $props();\n</script>\n```\n\n> [!NOTE]\n> The `PageProps` and `LayoutProps` types, added in 2.16.0, are a shortcut for typing the `data` prop as `PageData` or `LayoutData`, as well as other props, such as `form` for pages, or `children` for layouts. In earlier versions, you had to type these properties manually. For example, for a page:\n>\n> ```js\n> /// file: +page.svelte\n> /** @type {{ data: import('./$types').PageData, form: import('./$types').ActionData }} */\n> let { data, form } = $props();\n> ```\n>\n> Or, for a layout:\n>\n> ```js\n> /// file: +layout.svelte\n> /** @type {{ data: import('./$types').LayoutData, children: Snippet }} */\n> let { data, children } = $props();\n> ```\n\nIn turn, annotating the `load` function with `PageLoad`, `PageServerLoad`, `LayoutLoad` or `LayoutServerLoad` (for `+page.js`, `+page.server.js`, `+layout.js` and `+layout.server.js` respectively) ensures that `params` and the return value are correctly typed.\n\nIf you're using VS Code or any IDE that supports the language server protocol and TypeScript plugins then you can omit these types _entirely_! Svelte's IDE tooling will insert the correct types for you, so you'll get type checking without writing them yourself. It also works with our command line tool `svelte-check`.\n\nYou can read more about omitting `$types` in our [blog post](/blog/zero-config-type-safety) about it.\n\n## Other files\n\nAny other files inside a route directory are ignored by SvelteKit. This means you can colocate components and utility modules with the routes that need them.\n\nIf components and modules are needed by multiple routes, it's a good idea to put them in [`$lib`]($lib).\n\n## Further reading\n\n- [Tutorial: Routing](/tutorial/kit/pages)\n- [Tutorial: API routes](/tutorial/kit/get-handlers)\n- [Docs: Advanced routing](advanced-routing)\n"
  },
  {
    "path": "documentation/docs/20-core-concepts/20-load.md",
    "content": "---\ntitle: Loading data\n---\n\nBefore a [`+page.svelte`](routing#page-page.svelte) component (and its containing [`+layout.svelte`](routing#layout-layout.svelte) components) can be rendered, we often need to get some data. This is done by defining `load` functions.\n\n## Page data\n\nA `+page.svelte` file can have a sibling `+page.js` that exports a `load` function, the return value of which is available to the page via the `data` prop:\n\n```js\n/// file: src/routes/blog/[slug]/+page.js\n/** @type {import('./$types').PageLoad} */\nexport function load({ params }) {\n\treturn {\n\t\tpost: {\n\t\t\ttitle: `Title for ${params.slug} goes here`,\n\t\t\tcontent: `Content for ${params.slug} goes here`\n\t\t}\n\t};\n}\n```\n\n```svelte\n<!--- file: src/routes/blog/[slug]/+page.svelte --->\n<script>\n\t/** @type {import('./$types').PageProps} */\n\tlet { data } = $props();\n</script>\n\n<h1>{data.post.title}</h1>\n<div>{@html data.post.content}</div>\n```\n\n> [!LEGACY]\n> Before version 2.16.0, the props of a page and layout had to be typed individually:\n> ```js\n> /// file: +page.svelte\n> /** @type {{ data: import('./$types').PageData }} */\n> let { data } = $props();\n> ```\n>\n> In Svelte 4, you'd use `export let data` instead.\n\nThanks to the generated `$types` module, we get full type safety.\n\nA `load` function in a `+page.js` file runs both on the server and in the browser (unless combined with `export const ssr = false`, in which case it will [only run in the browser](page-options#ssr)). If your `load` function should _always_ run on the server (because it uses private environment variables, for example, or accesses a database) then it would go in a `+page.server.js` instead.\n\nA more realistic version of your blog post's `load` function, that only runs on the server and pulls data from a database, might look like this:\n\n```js\n/// file: src/routes/blog/[slug]/+page.server.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function getPost(slug: string): Promise<{ title: string, content: string }>\n}\n\n// @filename: index.js\n// ---cut---\nimport * as db from '$lib/server/database';\n\n/** @type {import('./$types').PageServerLoad} */\nexport async function load({ params }) {\n\treturn {\n\t\tpost: await db.getPost(params.slug)\n\t};\n}\n```\n\nNotice that the type changed from `PageLoad` to `PageServerLoad`, because server `load` functions can access additional arguments. To understand when to use `+page.js` and when to use `+page.server.js`, see [Universal vs server](load#Universal-vs-server).\n\n## Layout data\n\nYour `+layout.svelte` files can also load data, via `+layout.js` or `+layout.server.js`.\n\n```js\n/// file: src/routes/blog/[slug]/+layout.server.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function getPostSummaries(): Promise<Array<{ title: string, slug: string }>>\n}\n\n// @filename: index.js\n// ---cut---\nimport * as db from '$lib/server/database';\n\n/** @type {import('./$types').LayoutServerLoad} */\nexport async function load() {\n\treturn {\n\t\tposts: await db.getPostSummaries()\n\t};\n}\n```\n\n```svelte\n<!--- file: src/routes/blog/[slug]/+layout.svelte --->\n<script>\n\t/** @type {import('./$types').LayoutProps} */\n\tlet { data, children } = $props();\n</script>\n\n<main>\n\t<!-- +page.svelte is `@render`ed here -->\n\t{@render children()}\n</main>\n\n<aside>\n\t<h2>More posts</h2>\n\t<ul>\n\t\t{#each data.posts as post}\n\t\t\t<li>\n\t\t\t\t<a href=\"/blog/{post.slug}\">\n\t\t\t\t\t{post.title}\n\t\t\t\t</a>\n\t\t\t</li>\n\t\t{/each}\n\t</ul>\n</aside>\n```\n\n> [!LEGACY]\n> `LayoutProps` was added in 2.16.0. In earlier versions, properties had to be typed individually:\n> ```js\n> /// file: +layout.svelte\n> /** @type {{ data: import('./$types').LayoutData, children: Snippet }} */\n> let { data, children } = $props();\n> ```\n\nData returned from layout `load` functions is available to child `+layout.svelte` components and the `+page.svelte` component as well as the layout that it 'belongs' to.\n\n```svelte\n/// file: src/routes/blog/[slug]/+page.svelte\n<script>\n\t+++import { page } from '$app/state';+++\n\n\t/** @type {import('./$types').PageProps} */\n\tlet { data } = $props();\n\n+++\t// we can access `data.posts` because it's returned from\n\t// the parent layout `load` function\n\tlet index = $derived(data.posts.findIndex(post => post.slug === page.params.slug));\n\tlet next = $derived(data.posts[index + 1]);+++\n</script>\n\n<h1>{data.post.title}</h1>\n<div>{@html data.post.content}</div>\n\n+++{#if next}\n\t<p>Next post: <a href=\"/blog/{next.slug}\">{next.title}</a></p>\n{/if}+++\n```\n\n> [!NOTE] If multiple `load` functions return data with the same key, the last one 'wins' — the result of a layout `load` returning `{ a: 1, b: 2 }` and a page `load` returning `{ b: 3, c: 4 }` would be `{ a: 1, b: 3, c: 4 }`.\n\n## page.data\n\nThe `+page.svelte` component, and each `+layout.svelte` component above it, has access to its own data plus all the data from its parents.\n\nIn some cases, we might need the opposite — a parent layout might need to access page data or data from a child layout. For example, the root layout might want to access a `title` property returned from a `load` function in `+page.js` or `+page.server.js`. This can be done with `page.data`:\n\n```svelte\n<!--- file: src/routes/+layout.svelte --->\n<script>\n\timport { page } from '$app/state';\n</script>\n\n<svelte:head>\n\t<title>{page.data.title}</title>\n</svelte:head>\n```\n\nType information for `page.data` is provided by `App.PageData`.\n\n> [!LEGACY]\n> `$app/state` was added in SvelteKit 2.12. If you're using an earlier version or are using Svelte 4, use `$app/stores` instead.\n> It provides a `page` store with the same interface that you can subscribe to, e.g. `$page.data.title`.\n\n## Universal vs server\n\nAs we've seen, there are two types of `load` function:\n\n* `+page.js` and `+layout.js` files export _universal_ `load` functions that run both on the server and in the browser\n* `+page.server.js` and `+layout.server.js` files export _server_ `load` functions that only run server-side\n\nConceptually, they're the same thing, but there are some important differences to be aware of.\n\n### When does which load function run?\n\nServer `load` functions _always_ run on the server.\n\nBy default, universal `load` functions run on the server during SSR when the user first visits your page. They will then run again during hydration, reusing any responses from [fetch requests](#Making-fetch-requests). All subsequent invocations of universal `load` functions happen in the browser. You can customize the behavior through [page options](page-options). If you disable [server-side rendering](page-options#ssr), you'll get an SPA and universal `load` functions _always_ run on the client.\n\nIf a route contains both universal and server `load` functions, the server `load` runs first.\n\nA `load` function is invoked at runtime, unless you [prerender](page-options#prerender) the page — in that case, it's invoked at build time.\n\n### Input\n\nBoth universal and server `load` functions have access to properties describing the request (`params`, `route` and `url`) and various functions (`fetch`, `setHeaders`, `parent`, `depends` and `untrack`). These are described in the following sections.\n\nServer `load` functions are called with a `ServerLoadEvent`, which inherits `clientAddress`, `cookies`, `locals`, `platform` and `request` from `RequestEvent`.\n\nUniversal `load` functions are called with a `LoadEvent`, which has a `data` property. If you have `load` functions in both `+page.js` and `+page.server.js` (or `+layout.js` and `+layout.server.js`), the return value of the server `load` function is the `data` property of the universal `load` function's argument.\n\n### Output\n\nA universal `load` function can return an object containing any values, including things like custom classes and component constructors.\n\nA server `load` function must return data that can be serialized with [devalue](https://github.com/rich-harris/devalue) — anything that can be represented as JSON plus things like `BigInt`, `Date`, `Map`, `Set` and `RegExp`, or repeated/cyclical references — so that it can be transported over the network. Your data can include [promises](#Streaming-with-promises), in which case it will be streamed to browsers. If you need to serialize/deserialize custom types, use [transport hooks](hooks#Universal-hooks-transport).\n\n### When to use which\n\nServer `load` functions are convenient when you need to access data directly from a database or filesystem, or need to use private environment variables.\n\nUniversal `load` functions are useful when you need to `fetch` data from an external API and don't need private credentials, since SvelteKit can get the data directly from the API rather than going via your server. They are also useful when you need to return something that can't be serialized, such as a Svelte component constructor.\n\nIn rare cases, you might need to use both together — for example, you might need to return an instance of a custom class that was initialised with data from your server. When using both, the server `load` return value is _not_ passed directly to the page, but to the universal `load` function (as the `data` property):\n\n```js\n/// file: src/routes/+page.server.js\n/** @type {import('./$types').PageServerLoad} */\nexport async function load() {\n\treturn {\n\t\tserverMessage: 'hello from server load function'\n\t};\n}\n```\n\n```js\n/// file: src/routes/+page.js\n// @errors: 18047\n/** @type {import('./$types').PageLoad} */\nexport async function load({ data }) {\n\treturn {\n\t\tserverMessage: data.serverMessage,\n\t\tuniversalMessage: 'hello from universal load function'\n\t};\n}\n```\n\n## Using URL data\n\nOften the `load` function depends on the URL in one way or another. For this, the `load` function provides you with `url`, `route` and `params`.\n\n### url\n\nAn instance of [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL), containing properties like the `origin`, `hostname`, `pathname` and `searchParams` (which contains the parsed query string as a [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) object). `url.hash` cannot be accessed during `load`, since it is unavailable on the server.\n\n> [!NOTE] In some environments this is derived from request headers during server-side rendering. If you're using [adapter-node](adapter-node), for example, you may need to configure the adapter in order for the URL to be correct.\n\n### route\n\nContains the name of the current route directory, relative to `src/routes`:\n\n```js\n/// file: src/routes/a/[b]/[...c]/+page.js\n/** @type {import('./$types').PageLoad} */\nexport function load({ route }) {\n\tconsole.log(route.id); // '/a/[b]/[...c]'\n}\n```\n\n### params\n\n`params` is derived from `url.pathname` and `route.id`.\n\nGiven a `route.id` of `/a/[b]/[...c]` and a `url.pathname` of `/a/x/y/z`, the `params` object would look like this:\n\n```json\n{\n\t\"b\": \"x\",\n\t\"c\": \"y/z\"\n}\n```\n\n## Making fetch requests\n\nTo get data from an external API or a `+server.js` handler, you can use the provided `fetch` function, which behaves identically to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch) with a few additional features:\n\n- It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.\n- It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).\n- 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.\n- During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text`, `json` and `arrayBuffer` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](hooks#Server-hooks-handle).\n- During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request - if you received a warning in your browser console when using the browser `fetch` instead of the `load` `fetch`, this is why.\n\n```js\n/// file: src/routes/items/[id]/+page.js\n/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch, params }) {\n\tconst res = await fetch(`/api/items/${params.id}`);\n\tconst item = await res.json();\n\n\treturn { item };\n}\n```\n\n## Cookies\n\nA server `load` function can get and set [`cookies`](@sveltejs-kit#Cookies).\n\n```js\n/// file: src/routes/+layout.server.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function getUser(sessionid: string | undefined): Promise<{ name: string, avatar: string }>\n}\n\n// @filename: index.js\n// ---cut---\nimport * as db from '$lib/server/database';\n\n/** @type {import('./$types').LayoutServerLoad} */\nexport async function load({ cookies }) {\n\tconst sessionid = cookies.get('sessionid');\n\n\treturn {\n\t\tuser: await db.getUser(sessionid)\n\t};\n}\n```\n\nCookies will only be passed through the provided `fetch` function if the target host is the same as the SvelteKit application or a more specific subdomain of it.\n\nFor example, if SvelteKit is serving my.domain.com:\n- domain.com WILL NOT receive cookies\n- my.domain.com WILL receive cookies\n- api.domain.com WILL NOT receive cookies\n- sub.my.domain.com WILL receive cookies\n\nOther cookies will not be passed when `credentials: 'include'` is set, because SvelteKit does not know which domain which cookie belongs to (the browser does not pass this information along), so it's not safe to forward any of them. Use the [handleFetch hook](hooks#Server-hooks-handleFetch) to work around it.\n\n## Headers\n\nBoth server and universal `load` functions have access to a `setHeaders` function that, when running on the server, can set headers for the response. (When running in the browser, `setHeaders` has no effect.) This is useful if you want the page to be cached, for example:\n\n```js\n// @errors: 2322 1360\n/// file: src/routes/products/+page.js\n/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch, setHeaders }) {\n\tconst url = `https://cms.example.com/products.json`;\n\tconst response = await fetch(url);\n\n\t// Headers are only set during SSR, caching the page's HTML\n\t// for the same length of time as the underlying data.\n\tsetHeaders({\n\t\tage: response.headers.get('age'),\n\t\t'cache-control': response.headers.get('cache-control')\n\t});\n\n\treturn response.json();\n}\n```\n\nSetting the same header multiple times (even in separate `load` functions) is an error. You can only set a given header once using the `setHeaders` function. You cannot add a `set-cookie` header with `setHeaders` — use `cookies.set(name, value, options)` instead.\n\n## Using parent data\n\nOccasionally it's useful for a `load` function to access data from a parent `load` function, which can be done with `await parent()`:\n\n```js\n/// file: src/routes/+layout.js\n/** @type {import('./$types').LayoutLoad} */\nexport function load() {\n\treturn { a: 1 };\n}\n```\n\n```js\n/// file: src/routes/abc/+layout.js\n/** @type {import('./$types').LayoutLoad} */\nexport async function load({ parent }) {\n\tconst { a } = await parent();\n\treturn { b: a + 1 };\n}\n```\n\n```js\n/// file: src/routes/abc/+page.js\n/** @type {import('./$types').PageLoad} */\nexport async function load({ parent }) {\n\tconst { a, b } = await parent();\n\treturn { c: a + b };\n}\n```\n\n```svelte\n<!--- file: src/routes/abc/+page.svelte --->\n<script>\n\t/** @type {import('./$types').PageProps} */\n\tlet { data } = $props();\n</script>\n\n<!-- renders `1 + 2 = 3` -->\n<p>{data.a} + {data.b} = {data.c}</p>\n```\n\n> [!NOTE] Notice that the `load` function in `+page.js` receives the merged data from both layout `load` functions, not just the immediate parent.\n\nInside `+page.server.js` and `+layout.server.js`, `parent` returns data from parent `+layout.server.js` files.\n\nIn `+page.js` or `+layout.js` it will return data from parent `+layout.js` files. However, a missing `+layout.js` is treated as a `({ data }) => data` function, meaning that it will also return data from parent `+layout.server.js` files that are not 'shadowed' by a `+layout.js` file\n\nTake care not to introduce waterfalls when using `await parent()`. Here, for example, `getData(params)` does not depend on the result of calling `parent()`, so we should call it first to avoid a delayed render.\n\n```js\n/// file: +page.js\n// @filename: ambient.d.ts\ndeclare function getData(params: Record<string, string>): Promise<{ meta: any }>\n\n// @filename: index.js\n// ---cut---\n/** @type {import('./$types').PageLoad} */\nexport async function load({ params, parent }) {\n\t---const parentData = await parent();---\n\tconst data = await getData(params);\n\t+++const parentData = await parent();+++\n\n\treturn {\n\t\t...data,\n\t\tmeta: { ...parentData.meta, ...data.meta }\n\t};\n}\n```\n\n## Errors\n\nIf an error is thrown during `load`, the nearest [`+error.svelte`](routing#error) will be rendered. For [_expected_](errors#Expected-errors) errors, use the `error` helper from `@sveltejs/kit` to specify the HTTP status code and an optional message:\n\n```js\n/// file: src/routes/admin/+layout.server.js\n// @filename: ambient.d.ts\ndeclare namespace App {\n\tinterface Locals {\n\t\tuser?: {\n\t\t\tname: string;\n\t\t\tisAdmin: boolean;\n\t\t}\n\t}\n}\n\n// @filename: index.js\n// ---cut---\nimport { error } from '@sveltejs/kit';\n\n/** @type {import('./$types').LayoutServerLoad} */\nexport function load({ locals }) {\n\tif (!locals.user) {\n\t\terror(401, 'not logged in');\n\t}\n\n\tif (!locals.user.isAdmin) {\n\t\terror(403, 'not an admin');\n\t}\n}\n```\n\nCalling `error(...)` will throw an exception, making it easy to stop execution from inside helper functions.\n\nIf an [_unexpected_](errors#Unexpected-errors) error is thrown, SvelteKit will invoke [`handleError`](hooks#Shared-hooks-handleError) and treat it as a 500 Internal Error.\n\n> [!NOTE] [In SvelteKit 1.x](migrating-to-sveltekit-2#redirect-and-error-are-no-longer-thrown-by-you) you had to `throw` the error yourself\n\n## Redirects\n\nTo redirect users, use the `redirect` helper from `@sveltejs/kit` to specify the location to which they should be redirected alongside a `3xx` status code. Like `error(...)`, calling `redirect(...)` will throw an exception, making it easy to stop execution from inside helper functions.\n\n```js\n/// file: src/routes/user/+layout.server.js\n// @filename: ambient.d.ts\ndeclare namespace App {\n\tinterface Locals {\n\t\tuser?: {\n\t\t\tname: string;\n\t\t}\n\t}\n}\n\n// @filename: index.js\n// ---cut---\nimport { redirect } from '@sveltejs/kit';\n\n/** @type {import('./$types').LayoutServerLoad} */\nexport function load({ locals }) {\n\tif (!locals.user) {\n\t\tredirect(307, '/login');\n\t}\n}\n```\n\n> [!NOTE] Don't use `redirect()` inside a `try {...}` block, as the redirect will immediately trigger the catch statement.\n\nIn the browser, you can also navigate programmatically outside of a `load` function using [`goto`]($app-navigation#goto) from [`$app.navigation`]($app-navigation).\n\n> [!NOTE] [In SvelteKit 1.x](migrating-to-sveltekit-2#redirect-and-error-are-no-longer-thrown-by-you) you had to `throw` the `redirect` yourself\n\n## Streaming with promises\n\nWhen using a server `load`, promises will be streamed to the browser as they resolve. This is useful if you have slow, non-essential data, since you can start rendering the page before all the data is available:\n\n```js\n/// file: src/routes/blog/[slug]/+page.server.js\n// @filename: ambient.d.ts\ndeclare global {\n\tconst loadPost: (slug: string) => Promise<{ title: string, content: string }>;\n\tconst loadComments: (slug: string) => Promise<{ content: string }>;\n}\n\nexport {};\n\n// @filename: index.js\n// ---cut---\n/** @type {import('./$types').PageServerLoad} */\nexport async function load({ params }) {\n\treturn {\n\t\t// make sure the `await` happens at the end, otherwise we\n\t\t// can't start loading comments until we've loaded the post\n\t\tcomments: loadComments(params.slug),\n\t\tpost: await loadPost(params.slug)\n\t};\n}\n```\n\nThis is useful for creating skeleton loading states, for example:\n\n```svelte\n<!--- file: src/routes/blog/[slug]/+page.svelte --->\n<script>\n\t/** @type {import('./$types').PageProps} */\n\tlet { data } = $props();\n</script>\n\n<h1>{data.post.title}</h1>\n<div>{@html data.post.content}</div>\n\n{#await data.comments}\n\tLoading comments...\n{:then comments}\n\t{#each comments as comment}\n\t\t<p>{comment.content}</p>\n\t{/each}\n{:catch error}\n\t<p>error loading comments: {error.message}</p>\n{/await}\n```\n\nWhen streaming data, be careful to handle promise rejections correctly. More specifically, the server could crash with an \"unhandled promise rejection\" error if a lazy-loaded promise fails before rendering starts (at which point it's caught) and isn't handling the error in some way. When using SvelteKit's `fetch` directly in the `load` function, SvelteKit will handle this case for you. For other promises, it is enough to attach a noop-`catch` to the promise to mark it as handled.\n\n```js\n/// file: src/routes/+page.server.js\n/** @type {import('./$types').PageServerLoad} */\nexport function load({ fetch }) {\n\tconst ok_manual = Promise.reject();\n\tok_manual.catch(() => {});\n\n\treturn {\n\t\tok_manual,\n\t\tok_fetch: fetch('/fetch/that/could/fail'),\n\t\tdangerous_unhandled: Promise.reject()\n\t};\n}\n```\n\n> [!NOTE] On platforms that do not support streaming, such as AWS Lambda or Firebase, responses will be buffered. This means the page will only render once all promises resolve. If you are using a proxy (e.g. NGINX), make sure it does not buffer responses from the proxied server.\n\n> [!NOTE] Streaming data will only work when JavaScript is enabled. You should avoid returning promises from a universal `load` function if the page is server rendered, as these are _not_ streamed — instead, the promise is recreated when the function reruns in the browser.\n\n> [!NOTE] The headers and status code of a response cannot be changed once the response has started streaming, therefore you cannot `setHeaders` or throw redirects inside a streamed promise.\n\n> [!NOTE] [In SvelteKit 1.x](migrating-to-sveltekit-2#Top-level-promises-are-no-longer-awaited) top-level promises were automatically awaited, only nested promises were streamed.\n\n## Parallel loading\n\nWhen rendering (or navigating to) a page, SvelteKit runs all `load` functions concurrently, avoiding a waterfall of requests. During client-side navigation, the result of calling multiple server `load` functions are grouped into a single response. Once all `load` functions have returned, the page is rendered.\n\n## Rerunning load functions\n\nSvelteKit tracks the dependencies of each `load` function to avoid rerunning it unnecessarily during navigation.\n\nFor example, given a pair of `load` functions like these...\n\n```js\n/// file: src/routes/blog/[slug]/+page.server.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function getPost(slug: string): Promise<{ title: string, content: string }>\n}\n\n// @filename: index.js\n// ---cut---\nimport * as db from '$lib/server/database';\n\n/** @type {import('./$types').PageServerLoad} */\nexport async function load({ params }) {\n\treturn {\n\t\tpost: await db.getPost(params.slug)\n\t};\n}\n```\n\n```js\n/// file: src/routes/blog/[slug]/+layout.server.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function getPostSummaries(): Promise<Array<{ title: string, slug: string }>>\n}\n\n// @filename: index.js\n// ---cut---\nimport * as db from '$lib/server/database';\n\n/** @type {import('./$types').LayoutServerLoad} */\nexport async function load() {\n\treturn {\n\t\tposts: await db.getPostSummaries()\n\t};\n}\n```\n\n...the one in `+page.server.js` will rerun if we navigate from `/blog/trying-the-raw-meat-diet` to `/blog/i-regret-my-choices` because `params.slug` has changed. The one in `+layout.server.js` will not, because the data is still valid. In other words, we won't call `db.getPostSummaries()` a second time.\n\nA `load` function that calls `await parent()` will also rerun if a parent `load` function is rerun.\n\nDependency tracking does not apply _after_ the `load` function has returned — for example, accessing `params.x` inside a nested [promise](#Streaming-with-promises) will not cause the function to rerun when `params.x` changes. (Don't worry, you'll get a warning in development if you accidentally do this.) Instead, access the parameter in the main body of your `load` function.\n\nSearch parameters are tracked independently from the rest of the url. For example, accessing `event.url.searchParams.get(\"x\")` inside a `load` function will make that `load` function re-run when navigating from `?x=1` to `?x=2`, but not when navigating from `?x=1&y=1` to `?x=1&y=2`.\n\n### Untracking dependencies\n\nIn rare cases, you may wish to exclude something from the dependency tracking mechanism. You can do this with the provided `untrack` function:\n\n```js\n/// file: src/routes/+page.js\n/** @type {import('./$types').PageLoad} */\nexport async function load({ untrack, url }) {\n\t// Untrack url.pathname so that path changes don't trigger a rerun\n\tif (untrack(() => url.pathname === '/')) {\n\t\treturn { message: 'Welcome!' };\n\t}\n}\n```\n\n### Manual invalidation\n\nYou can also rerun `load` functions that apply to the current page using [`invalidate(url)`]($app-navigation#invalidate), which reruns all `load` functions that depend on `url`, and [`invalidateAll()`]($app-navigation#invalidateAll), which reruns every `load` function. Server load functions will never automatically depend on a fetched `url` to avoid leaking secrets to the client.\n\nA `load` function depends on `url` if it calls `fetch(url)` or `depends(url)`. Note that `url` can be a custom identifier that starts with `[a-z]:`:\n\n```js\n/// file: src/routes/random-number/+page.js\n/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch, depends }) {\n\t// load reruns when `invalidate('https://api.example.com/random-number')` is called...\n\tconst response = await fetch('https://api.example.com/random-number');\n\n\t// ...or when `invalidate('app:random')` is called\n\tdepends('app:random');\n\n\treturn {\n\t\tnumber: await response.json()\n\t};\n}\n```\n\n```svelte\n<!--- file: src/routes/random-number/+page.svelte --->\n<script>\n\timport { invalidate, invalidateAll } from '$app/navigation';\n\n\t/** @type {import('./$types').PageProps} */\n\tlet { data } = $props();\n\n\tfunction rerunLoadFunction() {\n\t\t// any of these will cause the `load` function to rerun\n\t\tinvalidate('app:random');\n\t\tinvalidate('https://api.example.com/random-number');\n\t\tinvalidate(url => url.href.includes('random-number'));\n\t\tinvalidateAll();\n\t}\n</script>\n\n<p>random number: {data.number}</p>\n<button onclick={rerunLoadFunction}>Update random number</button>\n```\n\n### When do load functions rerun?\n\nTo summarize, a `load` function will rerun in the following situations:\n\n- It references a property of `params` whose value has changed\n- It references a property of `url` (such as `url.pathname` or `url.search`) whose value has changed. Properties in `request.url` are _not_ tracked\n- It calls `url.searchParams.get(...)`, `url.searchParams.getAll(...)` or `url.searchParams.has(...)` and the parameter in question changes. Accessing other properties of `url.searchParams` will have the same effect as accessing `url.search`.\n- It calls `await parent()` and a parent `load` function reran\n- A child `load` function calls `await parent()` and is rerunning, and the parent is a server load function\n- It declared a dependency on a specific URL via [`fetch`](#Making-fetch-requests) (universal load only) or [`depends`](@sveltejs-kit#LoadEvent), and that URL was marked invalid with [`invalidate(url)`]($app-navigation#invalidate)\n- All active `load` functions were forcibly rerun with [`invalidateAll()`]($app-navigation#invalidateAll)\n\n`params` and `url` can change in response to a `<a href=\"..\">` link click, a [`<form>` interaction](form-actions#GET-vs-POST), a [`goto`]($app-navigation#goto) invocation, or a [`redirect`](@sveltejs-kit#redirect).\n\nNote that rerunning a `load` function will update the `data` prop inside the corresponding `+layout.svelte` or `+page.svelte`; it does _not_ cause the component to be recreated. As a result, internal state is preserved. If this isn't what you want, you can reset whatever you need to reset inside an [`afterNavigate`]($app-navigation#afterNavigate) callback, and/or wrap your component in a [`{#key ...}`](../svelte/key) block.\n\n## Implications for authentication\n\nA couple features of loading data have important implications for auth checks:\n- Layout `load` functions do not run on every request, such as during client side navigation between child routes. [(When do load functions rerun?)](load#Rerunning-load-functions-When-do-load-functions-rerun)\n- Layout and page `load` functions run concurrently unless `await parent()` is called. If a layout `load` throws, the page `load` function runs, but the client will not receive the returned data.\n\nThere are a few possible strategies to ensure an auth check occurs before protected code.\n\nTo prevent data waterfalls and preserve layout `load` caches:\n- Use [hooks](hooks) to protect multiple routes before any `load` functions run\n- Use auth guards directly in `+page.server.js` `load` functions for route specific protection\n\nPutting an auth guard in `+layout.server.js` requires all child pages to call `await parent()` before protected code. Unless every child page depends on returned data from `await parent()`, the other options will be more performant.\n\n## Using `getRequestEvent`\n\nWhen running server `load` functions, the `event` object passed to the function as an argument can also be retrieved with [`getRequestEvent`]($app-server#getRequestEvent). This allows shared logic (such as authentication guards) to access information about the current request without it needing to be passed around.\n\nFor example, you might have a function that requires users to be logged in, and redirects them to `/login` if not:\n\n```js\n/// file: src/lib/server/auth.js\n// @filename: ambient.d.ts\ninterface User {\n\tname: string;\n}\n\ndeclare namespace App {\n\tinterface Locals {\n\t\tuser?: User;\n\t}\n}\n\n// @filename: index.ts\n// ---cut---\nimport { redirect } from '@sveltejs/kit';\nimport { getRequestEvent } from '$app/server';\n\nexport function requireLogin() {\n\tconst { locals, url } = getRequestEvent();\n\n\t// assume `locals.user` is populated in `handle`\n\tif (!locals.user) {\n\t\tconst redirectTo = url.pathname + url.search;\n\t\tconst params = new URLSearchParams({ redirectTo });\n\n\t\tredirect(303, `/login?${params}`);\n\t}\n\n\treturn locals.user;\n}\n```\n\nNow, you can call `requireLogin` in any `load` function (or [form action](form-actions), for example) to guarantee that the user is logged in:\n\n```js\n/// file: +page.server.js\n// @filename: ambient.d.ts\n\ndeclare module '$lib/server/auth' {\n\tinterface User {\n\t\tname: string;\n\t}\n\n\texport function requireLogin(): User;\n}\n\n// @filename: index.ts\n// ---cut---\nimport { requireLogin } from '$lib/server/auth';\n\nexport function load() {\n\tconst user = requireLogin();\n\n\t// `user` is guaranteed to be a user object here, because otherwise\n\t// `requireLogin` would throw a redirect and we wouldn't get here\n\treturn {\n\t\tmessage: `hello ${user.name}!`\n\t};\n}\n```\n\n## Further reading\n\n- [Tutorial: Loading data](/tutorial/kit/page-data)\n- [Tutorial: Errors and redirects](/tutorial/kit/error-basics)\n- [Tutorial: Advanced loading](/tutorial/kit/await-parent)\n"
  },
  {
    "path": "documentation/docs/20-core-concepts/30-form-actions.md",
    "content": "---\ntitle: Form actions\n---\n\nA `+page.server.js` file can export _actions_, which allow you to `POST` data to the server using the `<form>` element.\n\nWhen using `<form>`, client-side JavaScript is optional, but you can easily _progressively enhance_ your form interactions with JavaScript to provide the best user experience.\n\n## Default actions\n\nIn the simplest case, a page declares a `default` action:\n\n```js\n/// file: src/routes/login/+page.server.js\n/** @satisfies {import('./$types').Actions} */\nexport const actions = {\n\tdefault: async (event) => {\n\t\t// TODO log the user in\n\t}\n};\n```\n\nTo invoke this action from the `/login` page, just add a `<form>` — no JavaScript needed:\n\n```svelte\n<!--- file: src/routes/login/+page.svelte --->\n<form method=\"POST\">\n\t<label>\n\t\tEmail\n\t\t<input name=\"email\" type=\"email\">\n\t</label>\n\t<label>\n\t\tPassword\n\t\t<input name=\"password\" type=\"password\">\n\t</label>\n\t<button>Log in</button>\n</form>\n```\n\nIf someone were to click the button, the browser would send the form data via `POST` request to the server, running the default action.\n\n> [!NOTE] Actions always use `POST` requests, since `GET` requests should never have side-effects.\n\nWe can also invoke the action from other pages (for example if there's a login widget in the nav in the root layout) by adding the `action` attribute, pointing to the page:\n\n```html\n/// file: src/routes/+layout.svelte\n<form method=\"POST\" action=\"/login\">\n\t<!-- content -->\n</form>\n```\n\n## Named actions\n\nInstead of one `default` action, a page can have as many named actions as it needs:\n\n```js\n/// file: src/routes/login/+page.server.js\n/** @satisfies {import('./$types').Actions} */\nexport const actions = {\n---\tdefault: async (event) => {---\n+++\tlogin: async (event) => {+++\n\t\t// TODO log the user in\n\t},\n+++\tregister: async (event) => {\n\t\t// TODO register the user\n\t}+++\n};\n```\n\nTo invoke a named action, add a query parameter with the name prefixed by a `/` character:\n\n```svelte\n<!--- file: src/routes/login/+page.svelte --->\n<form method=\"POST\" action=\"?/register\">\n```\n\n```svelte\n<!--- file: src/routes/+layout.svelte --->\n<form method=\"POST\" action=\"/login?/register\">\n```\n\nAs well as the `action` attribute, we can use the `formaction` attribute on a button to `POST` the same form data to a different action than the parent `<form>`:\n\n```svelte\n/// file: src/routes/login/+page.svelte\n<form method=\"POST\" +++action=\"?/login\"+++>\n\t<label>\n\t\tEmail\n\t\t<input name=\"email\" type=\"email\">\n\t</label>\n\t<label>\n\t\tPassword\n\t\t<input name=\"password\" type=\"password\">\n\t</label>\n\t<button>Log in</button>\n\t+++<button formaction=\"?/register\">Register</button>+++\n</form>\n```\n\n> [!NOTE] We can't have default actions next to named actions, because if you POST to a named action without a redirect, the query parameter is persisted in the URL, which means the next default POST would go through the named action from before.\n\n## Anatomy of an action\n\nEach action receives a `RequestEvent` object, allowing you to read the data with `request.formData()`. After processing the request (for example, logging the user in by setting a cookie), the action can respond with data that will be available through the `form` property on the corresponding page and through `page.form` app-wide until the next update.\n\n```js\n/// file: src/routes/login/+page.server.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/db';\n\n// @filename: index.js\n// ---cut---\nimport * as db from '$lib/server/db';\n\n/** @type {import('./$types').PageServerLoad} */\nexport async function load({ cookies }) {\n\tconst user = await db.getUserFromSession(cookies.get('sessionid'));\n\treturn { user };\n}\n\n/** @satisfies {import('./$types').Actions} */\nexport const actions = {\n\tlogin: async ({ cookies, request }) => {\n\t\tconst data = await request.formData();\n\t\tconst email = data.get('email');\n\t\tconst password = data.get('password');\n\n\t\tconst user = await db.getUser(email);\n\t\tcookies.set('sessionid', await db.createSession(user), { path: '/' });\n\n\t\treturn { success: true };\n\t},\n\tregister: async (event) => {\n\t\t// TODO register the user\n\t}\n};\n```\n\n```svelte\n<!--- file: src/routes/login/+page.svelte --->\n<script>\n\t/** @type {import('./$types').PageProps} */\n\tlet { data, form } = $props();\n</script>\n\n{#if form?.success}\n\t<!-- this message is ephemeral; it exists because the page was rendered in\n\t       response to a form submission. it will vanish if the user reloads -->\n\t<p>Successfully logged in! Welcome back, {data.user.name}</p>\n{/if}\n```\n\n> [!LEGACY]\n> `PageProps` was added in 2.16.0. In earlier versions, you had to type the `data` and `form` properties individually:\n> ```js\n> /// file: +page.svelte\n> /** @type {{ data: import('./$types').PageData, form: import('./$types').ActionData }} */\n> let { data, form } = $props();\n> ```\n>\n> In Svelte 4, you'd use `export let data` and `export let form` instead to declare properties.\n\n### Validation errors\n\nIf the request couldn't be processed because of invalid data, you can return validation errors — along with the previously submitted form values — back to the user so that they can try again. The `fail` function lets you return an HTTP status code (typically 400 or 422, in the case of validation errors) along with the data. The status code is available through `page.status` and the data through `form`:\n\n```js\n/// file: src/routes/login/+page.server.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/db';\n\n// @filename: index.js\n// ---cut---\n+++import { fail } from '@sveltejs/kit';+++\nimport * as db from '$lib/server/db';\n\n/** @satisfies {import('./$types').Actions} */\nexport const actions = {\n\tlogin: async ({ cookies, request }) => {\n\t\tconst data = await request.formData();\n\t\tconst email = data.get('email');\n\t\tconst password = data.get('password');\n\n+++\t\tif (!email) {\n\t\t\treturn fail(400, { email, missing: true });\n\t\t}+++\n\n\t\tconst user = await db.getUser(email);\n\n+++\t\tif (!user || user.password !== db.hash(password)) {\n\t\t\treturn fail(400, { email, incorrect: true });\n\t\t}+++\n\n\t\tcookies.set('sessionid', await db.createSession(user), { path: '/' });\n\n\t\treturn { success: true };\n\t},\n\tregister: async (event) => {\n\t\t// TODO register the user\n\t}\n};\n```\n\n> [!NOTE] Note that as a precaution, we only return the email back to the page — not the password.\n\n```svelte\n/// file: src/routes/login/+page.svelte\n<form method=\"POST\" action=\"?/login\">\n+++\t{#if form?.missing}<p class=\"error\">The email field is required</p>{/if}\n\t{#if form?.incorrect}<p class=\"error\">Invalid credentials!</p>{/if}+++\n\t<label>\n\t\tEmail\n\t\t<input name=\"email\" type=\"email\" +++value={form?.email ?? ''}+++>\n\t</label>\n\t<label>\n\t\tPassword\n\t\t<input name=\"password\" type=\"password\">\n\t</label>\n\t<button>Log in</button>\n\t<button formaction=\"?/register\">Register</button>\n</form>\n```\n\nThe returned data must be serializable as JSON. Beyond that, the structure is entirely up to you. For example, if you had multiple forms on the page, you could distinguish which `<form>` the returned `form` data referred to with an `id` property or similar.\n\n### Redirects\n\nRedirects (and errors) work exactly the same as in [`load`](load#Redirects):\n\n```js\n// @errors: 2345\n/// file: src/routes/login/+page.server.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/db';\n\n// @filename: index.js\n// ---cut---\nimport { fail, +++redirect+++ } from '@sveltejs/kit';\nimport * as db from '$lib/server/db';\n\n/** @satisfies {import('./$types').Actions} */\nexport const actions = {\n\tlogin: async ({ cookies, request, +++url+++ }) => {\n\t\tconst data = await request.formData();\n\t\tconst email = data.get('email');\n\t\tconst password = data.get('password');\n\n\t\tconst user = await db.getUser(email);\n\t\tif (!user) {\n\t\t\treturn fail(400, { email, missing: true });\n\t\t}\n\n\t\tif (user.password !== db.hash(password)) {\n\t\t\treturn fail(400, { email, incorrect: true });\n\t\t}\n\n\t\tcookies.set('sessionid', await db.createSession(user), { path: '/' });\n\n+++\t\tif (url.searchParams.has('redirectTo')) {\n\t\t\tredirect(303, url.searchParams.get('redirectTo'));\n\t\t}+++\n\n\t\treturn { success: true };\n\t},\n\tregister: async (event) => {\n\t\t// TODO register the user\n\t}\n};\n```\n\n## Loading data\n\nAfter an action runs, the page will be re-rendered (unless a redirect or an unexpected error occurs), with the action's return value available to the page as the `form` prop. This means that your page's `load` functions will run after the action completes.\n\nNote that `handle` runs before the action is invoked, and does not rerun before the `load` functions. This means that if, for example, you use `handle` to populate `event.locals` based on a cookie, you must update `event.locals` when you set or delete the cookie in an action:\n\n```js\n/// file: src/hooks.server.js\n// @filename: ambient.d.ts\ndeclare namespace App {\n\tinterface Locals {\n\t\tuser: {\n\t\t\tname: string;\n\t\t} | null\n\t}\n}\n\n// @filename: global.d.ts\ndeclare global {\n\tfunction getUser(sessionid: string | undefined): {\n\t\tname: string;\n\t};\n}\n\nexport {};\n\n// @filename: index.js\n// ---cut---\n/** @type {import('@sveltejs/kit').Handle} */\nexport async function handle({ event, resolve }) {\n\tevent.locals.user = await getUser(event.cookies.get('sessionid'));\n\treturn resolve(event);\n}\n```\n\n```js\n/// file: src/routes/account/+page.server.js\n// @filename: ambient.d.ts\ndeclare namespace App {\n\tinterface Locals {\n\t\tuser: {\n\t\t\tname: string;\n\t\t} | null\n\t}\n}\n\n// @filename: index.js\n// ---cut---\n/** @type {import('./$types').PageServerLoad} */\nexport function load(event) {\n\treturn {\n\t\tuser: event.locals.user\n\t};\n}\n\n/** @satisfies {import('./$types').Actions} */\nexport const actions = {\n\tlogout: async (event) => {\n\t\tevent.cookies.delete('sessionid', { path: '/' });\n\t\tevent.locals.user = null;\n\t}\n};\n```\n\n## Progressive enhancement\n\nIn the preceding sections we built a `/login` action that [works without client-side JavaScript](https://kryogenix.org/code/browser/everyonehasjs.html) — not a `fetch` in sight. That's great, but when JavaScript _is_ available we can progressively enhance our form interactions to provide a better user experience.\n\n### use:enhance\n\nThe easiest way to progressively enhance a form is to add the `use:enhance` action:\n\n```svelte\n/// file: src/routes/login/+page.svelte\n<script>\n\t+++import { enhance } from '$app/forms';+++\n\n\t/** @type {import('./$types').PageProps} */\n\tlet { form } = $props();\n</script>\n\n<form method=\"POST\" +++use:enhance+++>\n```\n\n> [!NOTE] `use:enhance` can only be used with forms that have `method=\"POST\"` and point to actions defined in a `+page.server.js` file. It will not work with `method=\"GET\"`, which is the default for forms without a specified method. Attempting to use `use:enhance` on forms without `method=\"POST\"` or posting to a `+server.js` endpoint will result in an error.\n\n> [!NOTE] Yes, it's a little confusing that the `enhance` action and `<form action>` are both called 'action'. These docs are action-packed. Sorry.\n\nWithout an argument, `use:enhance` will emulate the browser-native behaviour, just without the full-page reloads. It will:\n\n- update the `form` property, `page.form` and `page.status` on a successful or invalid response, but only if the action is on the same page you're submitting from. For example, if your form looks like `<form action=\"/somewhere/else\" ..>`, the `form` prop and the `page.form` state will _not_ be updated. This is because in the native form submission case you would be redirected to the page the action is on. If you want to have them updated either way, use [`applyAction`](#Progressive-enhancement-Customising-use:enhance)\n- reset the `<form>` element\n- invalidate all data using `invalidateAll` on a successful response\n- call `goto` on a redirect response\n- render the nearest `+error` boundary if an error occurs\n- [reset focus](accessibility#Focus-management) to the appropriate element\n\n### Customising use:enhance\n\nTo customise the behaviour, you can provide a `SubmitFunction` that runs immediately before the form is submitted, and (optionally) returns a callback that runs with the `ActionResult`.\n\n```svelte\n<form\n\tmethod=\"POST\"\n\tuse:enhance={({ formElement, formData, action, cancel, submitter }) => {\n\t\t// `formElement` is this `<form>` element\n\t\t// `formData` is its `FormData` object that's about to be submitted\n\t\t// `action` is the URL to which the form is posted\n\t\t// calling `cancel()` will prevent the submission\n\t\t// `submitter` is the `HTMLElement` that caused the form to be submitted\n\n\t\treturn async ({ result, update }) => {\n\t\t\t// `result` is an `ActionResult` object\n\t\t\t// `update` is a function which triggers the default logic that would be triggered if this callback wasn't set\n\t\t};\n\t}}\n>\n```\n\nYou can use these functions to show and hide loading UI, and so on.\n\nIf you return a callback, you override the default post-submission behavior. To get it back, call `update`, which accepts `invalidateAll` and `reset` parameters, or use `applyAction` on the result:\n\n```svelte\n/// file: src/routes/login/+page.svelte\n<script>\n\timport { enhance, +++applyAction+++ } from '$app/forms';\n\n\t/** @type {import('./$types').PageProps} */\n\tlet { form } = $props();\n</script>\n\n<form\n\tmethod=\"POST\"\n\tuse:enhance={({ formElement, formData, action, cancel }) => {\n\t\treturn async ({ result }) => {\n\t\t\t// `result` is an `ActionResult` object\n+++\t\t\tif (result.type === 'redirect') {\n\t\t\t\tgoto(result.location);\n\t\t\t} else {\n\t\t\t\tawait applyAction(result);\n\t\t\t}+++\n\t\t};\n\t}}\n>\n```\n\nThe behaviour of `applyAction(result)` depends on `result.type`:\n\n- `success`, `failure` — sets `page.status` to `result.status` and updates `form` and `page.form` to `result.data` (regardless of where you are submitting from, in contrast to `update` from `enhance`)\n- `redirect` — calls `goto(result.location, { invalidateAll: true })`\n- `error` — renders the nearest `+error` boundary with `result.error`\n\nIn all cases, [focus will be reset](accessibility#Focus-management).\n\n### Custom event listener\n\nWe can also implement progressive enhancement ourselves, without `use:enhance`, with a normal event listener on the `<form>`:\n\n```svelte\n<!--- file: src/routes/login/+page.svelte --->\n<script>\n\timport { invalidateAll, goto } from '$app/navigation';\n\timport { applyAction, deserialize } from '$app/forms';\n\n\t/** @type {import('./$types').PageProps} */\n\tlet { form } = $props();\n\n\t/** @param {SubmitEvent & { currentTarget: EventTarget & HTMLFormElement}} event */\n\tasync function handleSubmit(event) {\n\t\tevent.preventDefault();\n\t\tconst data = new FormData(event.currentTarget, event.submitter);\n\n\t\tconst response = await fetch(event.currentTarget.action, {\n\t\t\tmethod: 'POST',\n\t\t\tbody: data\n\t\t});\n\n\t\t/** @type {import('@sveltejs/kit').ActionResult} */\n\t\tconst result = deserialize(await response.text());\n\n\t\tif (result.type === 'success') {\n\t\t\t// rerun all `load` functions, following the successful update\n\t\t\tawait invalidateAll();\n\t\t}\n\n\t\tapplyAction(result);\n\t}\n</script>\n\n<form method=\"POST\" onsubmit={handleSubmit}>\n\t<!-- content -->\n</form>\n```\n\nNote that you need to `deserialize` the response before processing it further using the corresponding method from `$app/forms`. `JSON.parse()` isn't enough because form actions - like `load` functions - also support returning `Date` or `BigInt` objects.\n\nIf you have a `+server.js` alongside your `+page.server.js`, `fetch` requests will be routed there by default. To `POST` to an action in `+page.server.js` instead, use the custom `x-sveltekit-action` header:\n\n```js\n// @errors: 2532 2304\nconst response = await fetch(this.action, {\n\tmethod: 'POST',\n\tbody: data,\n+++\theaders: {\n\t\t'x-sveltekit-action': 'true'\n\t}+++\n});\n```\n\n## Alternatives\n\nForm actions are the preferred way to send data to the server, since they can be progressively enhanced, but you can also use [`+server.js`](routing#server) files to expose (for example) a JSON API. Here's how such an interaction could look like:\n\n```svelte\n<!--- file: src/routes/send-message/+page.svelte --->\n<script>\n\tfunction rerun() {\n\t\tfetch('/api/ci', {\n\t\t\tmethod: 'POST'\n\t\t});\n\t}\n</script>\n\n<button onclick={rerun}>Rerun CI</button>\n```\n\n```js\n// @errors: 2355 1360 2322\n/// file: src/routes/api/ci/+server.js\n/** @type {import('./$types').RequestHandler} */\nexport function POST() {\n\t// do something\n}\n```\n\n## GET vs POST\n\nAs we've seen, to invoke a form action you must use `method=\"POST\"`.\n\nSome forms don't need to `POST` data to the server — search inputs, for example. For these you can use `method=\"GET\"` (or, equivalently, no `method` at all), and SvelteKit will treat them like `<a>` elements, using the client-side router instead of a full page navigation:\n\n```html\n<form action=\"/search\">\n\t<label>\n\t\tSearch\n\t\t<input name=\"q\">\n\t</label>\n</form>\n```\n\nSubmitting this form will navigate to `/search?q=...` and invoke your load function but will not invoke an action. As with `<a>` elements, you can set the [`data-sveltekit-reload`](link-options#data-sveltekit-reload), [`data-sveltekit-replacestate`](link-options#data-sveltekit-replacestate), [`data-sveltekit-keepfocus`](link-options#data-sveltekit-keepfocus) and [`data-sveltekit-noscroll`](link-options#data-sveltekit-noscroll) attributes on the `<form>` to control the router's behaviour.\n\n## Further reading\n\n- [Tutorial: Forms](/tutorial/kit/the-form-element)\n"
  },
  {
    "path": "documentation/docs/20-core-concepts/40-page-options.md",
    "content": "---\ntitle: Page options\n---\n\nBy default, SvelteKit will render (or [prerender](glossary#Prerendering)) any component first on the server and send it to the client as HTML. It will then render the component again in the browser to make it interactive in a process called [_hydration_](glossary#Hydration). For this reason, you need to ensure that components can run in both places. SvelteKit will then initialize a [_router_](routing) that takes over subsequent navigations.\n\nYou can control each of these on a page-by-page basis by exporting options from [`+page.js`](routing#page-page.js) or [`+page.server.js`](routing#page-page.server.js), or for groups of pages using a shared [`+layout.js`](routing#layout-layout.js) or [`+layout.server.js`](routing#layout-layout.server.js). To define an option for the whole app, export it from the root layout. Child layouts and pages override values set in parent layouts, so — for example — you can enable prerendering for your entire app then disable it for pages that need to be dynamically rendered.\n\nYou can mix and match these options in different areas of your app. For example, you could prerender your marketing page for maximum speed, server-render your dynamic pages for SEO and accessibility and turn your admin section into an SPA by rendering it on the client only. This makes SvelteKit very versatile.\n\n## prerender\n\nIt's likely that at least some routes of your app can be represented as a simple HTML file generated at build time. These routes can be [_prerendered_](glossary#Prerendering).\n\n```js\n/// file: +page.js/+page.server.js/+server.js\nexport const prerender = true;\n```\n\nAlternatively, you can set `export const prerender = true` in your root `+layout.js` or `+layout.server.js` and prerender everything except pages that are explicitly marked as _not_ prerenderable:\n\n```js\n/// file: +page.js/+page.server.js/+server.js\nexport const prerender = false;\n```\n\nRoutes with `prerender = true` will be excluded from manifests used for dynamic SSR, making your server (or serverless/edge functions) smaller. In some cases you might want to prerender a route but also include it in the manifest (for example, with a route like `/blog/[slug]` where you want to prerender your most recent/popular content but server-render the long tail) — for these cases, there's a third option, 'auto':\n\n```js\n/// file: +page.js/+page.server.js/+server.js\nexport const prerender = 'auto';\n```\n\n> [!NOTE] If your entire app is suitable for prerendering, you can use [`adapter-static`](adapter-static), which will output files suitable for use with any static webserver.\n\nThe prerenderer will start at the root of your app and generate files for any prerenderable pages or `+server.js` routes it finds. Each page is scanned for `<a>` elements that point to other pages that are candidates for prerendering — because of this, you generally don't need to specify which pages should be accessed. If you _do_ need to specify which pages should be accessed by the prerenderer, you can do so with [`config.kit.prerender.entries`](configuration#prerender), or by exporting an [`entries`](#entries) function from your dynamic route.\n\nWhile prerendering, the value of `building` imported from [`$app/environment`]($app-environment) will be `true`.\n\n### Prerendering server routes\n\nUnlike the other page options, `prerender` also applies to `+server.js` files. These files are _not_ affected by layouts, but will inherit default values from the pages that fetch data from them, if any. For example if a `+page.js` contains this `load` function...\n\n```js\n/// file: +page.js\nexport const prerender = true;\n\n/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/my-server-route.json');\n\treturn await res.json();\n}\n```\n\n...then `src/routes/my-server-route.json/+server.js` will be treated as prerenderable if it doesn't contain its own `export const prerender = false`.\n\n### When not to prerender\n\nThe basic rule is this: for a page to be prerenderable, any two users hitting it directly must get the same content from the server.\n\n> [!NOTE] Not all pages are suitable for prerendering. Any content that is prerendered will be seen by all users. You can of course fetch personalized data in `onMount` in a prerendered page, but this may result in a poorer user experience since it will involve blank initial content or loading indicators.\n\nNote that you can still prerender pages that load data based on the page's parameters, such as a `src/routes/blog/[slug]/+page.svelte` route.\n\nAccessing [`url.searchParams`](load#Using-URL-data-url) during prerendering is forbidden. If you need to use it, ensure you are only doing so in the browser (for example in `onMount`).\n\nPages with [actions](form-actions) cannot be prerendered, because a server must be able to handle the action `POST` requests.\n\n### Route conflicts\n\nBecause prerendering writes to the filesystem, it isn't possible to have two endpoints that would cause a directory and a file to have the same name. For example, `src/routes/foo/+server.js` and `src/routes/foo/bar/+server.js` would try to create `foo` and `foo/bar`, which is impossible.\n\nFor that reason among others, it's recommended that you always include a file extension — `src/routes/foo.json/+server.js` and `src/routes/foo/bar.json/+server.js` would result in `foo.json` and `foo/bar.json` files living harmoniously side-by-side.\n\nFor _pages_, we skirt around this problem by writing `foo/index.html` instead of `foo`.\n\n### Troubleshooting\n\nIf you encounter an error like 'The following routes were marked as prerenderable, but were not prerendered' it's because the route in question (or a parent layout, if it's a page) has `export const prerender = true` but the page wasn't reached by the prerendering crawler and thus wasn't prerendered.\n\nSince these routes cannot be dynamically server-rendered, this will cause errors when people try to access the route in question. There are a few ways to fix it:\n\n* Ensure that SvelteKit can find the route by following links from [`config.kit.prerender.entries`](configuration#prerender) or the [`entries`](#entries) page option. Add links to dynamic routes (i.e. pages with `[parameters]` ) to this option if they are not found through crawling the other entry points, else they are not prerendered because SvelteKit doesn't know what value the parameters should have. Pages not marked as prerenderable will be ignored and their links to other pages will not be crawled, even if some of them would be prerenderable.\n* Ensure that SvelteKit can find the route by discovering a link to it from one of your other prerendered pages that have server-side rendering enabled.\n* Change `export const prerender = true` to `export const prerender = 'auto'`. Routes with `'auto'` can be dynamically server rendered\n\n## entries\n\nSvelteKit will discover pages to prerender automatically, by starting at _entry points_ and crawling them. By default, all your non-dynamic routes are considered entry points — for example, if you have these routes...\n\n```sh\n/             # non-dynamic\n/blog         # non-dynamic\n/blog/[slug]  # dynamic, because of `[slug]`\n```\n\n...SvelteKit will prerender `/` and `/blog`, and in the process discover links like `<a href=\"/blog/hello-world\">` which give it new pages to prerender.\n\nMost of the time, that's enough. In some situations, links to pages like `/blog/hello-world` might not exist (or might not exist on prerendered pages), in which case we need to tell SvelteKit about their existence.\n\nThis can be done with [`config.kit.prerender.entries`](configuration#prerender), or by exporting an `entries` function from a `+page.js`, a `+page.server.js` or a `+server.js` belonging to a dynamic route:\n\n```js\n/// file: src/routes/blog/[slug]/+page.server.js\n/** @type {import('./$types').EntryGenerator} */\nexport function entries() {\n\treturn [\n\t\t{ slug: 'hello-world' },\n\t\t{ slug: 'another-blog-post' }\n\t];\n}\n\nexport const prerender = true;\n```\n\n`entries` can be an `async` function, allowing you to (for example) retrieve a list of posts from a CMS or database, in the example above.\n\n## ssr\n\nNormally, SvelteKit renders your page on the server before sending that HTML to the client where it's [hydrated](glossary#Hydration). This is also required for prerendering to save the full contents of a page.\n\nIf you set `ssr` to `false`, it renders an empty 'shell' page instead. This is useful if your page is unable to be rendered on the server (because you use browser-only globals like `document` for example), but in most situations it's not recommended ([see appendix](glossary#SSR)).\n\n```js\n/// file: +page.js\nexport const ssr = false;\n// If both `ssr` and `csr` are `false`, nothing will be rendered!\n```\n\nIf you add `export const ssr = false` to your root `+layout.js`, your entire app will only be rendered on the client — which essentially means you turn your app into an [SPA](glossary#SPA). You should not do this if your goal is to build a [statically generated site](glossary#SSG).\n\n> [!NOTE] If all your page options are boolean or string literal values, SvelteKit will evaluate them statically. If not, it will import your `+page.js` or `+layout.js` file on the server (both at build time, and at runtime if your app isn't fully static) so it can evaluate the options. In the second case, browser-only code must not run when the module is loaded. In practice, this means you should import browser-only code in your `+page.svelte` or `+layout.svelte` file instead.\n\n## csr\n\nOrdinarily, SvelteKit [hydrates](glossary#Hydration) your server-rendered HTML into an interactive client-side-rendered (CSR) page. Some pages don't require JavaScript at all — many blog posts and 'about' pages fall into this category. In these cases you can disable CSR:\n\n```js\n/// file: +page.js\nexport const csr = false;\n// If both `csr` and `ssr` are `false`, nothing will be rendered!\n```\n\nDisabling CSR does not ship any JavaScript to the client. This means:\n\n* The webpage should work with HTML and CSS only.\n* `<script>` tags inside all Svelte components are removed.\n* `<form>` elements cannot be [progressively enhanced](form-actions#Progressive-enhancement).\n* Links are handled by the browser with a full-page navigation.\n* Hot Module Replacement (HMR) will be disabled.\n\nYou can enable `csr` during development (for example to take advantage of HMR) like so:\n\n```js\n/// file: +page.js\nimport { dev } from '$app/environment';\n\nexport const csr = dev;\n```\n\n## trailingSlash\n\nBy default, SvelteKit will remove trailing slashes from URLs — if you visit `/about/`, it will respond with a redirect to `/about`. You can change this behaviour with the `trailingSlash` option, which can be one of `'never'` (the default), `'always'`, or `'ignore'`.\n\nAs with other page options, you can export this value from a `+layout.js` or a `+layout.server.js` and it will apply to all child pages. You can also export the configuration from `+server.js` files.\n\n```js\n/// file: src/routes/+layout.js\nexport const trailingSlash = 'always';\n```\n\nThis option also affects [prerendering](#prerender). If `trailingSlash` is `always`, a route like `/about` will result in an `about/index.html` file, otherwise it will create `about.html`, mirroring static webserver conventions.\n\n> [!NOTE] Ignoring trailing slashes is not recommended — the semantics of relative paths differ between the two cases (`./y` from `/x` is `/y`, but from `/x/` is `/x/y`), and `/x` and `/x/` are treated as separate URLs which is harmful to SEO.\n\n## config\n\nWith the concept of [adapters](adapters), SvelteKit is able to run on a variety of platforms. Each of these might have specific configuration to further tweak the deployment — for example on Vercel you could choose to deploy some parts of your app on the edge and others on serverless environments.\n\n`config` is an object with key-value pairs at the top level. Beyond that, the concrete shape is dependent on the adapter you're using. Every adapter should provide a `Config` interface to import for type safety. Consult the documentation of your adapter for more information.\n\n```js\n// @filename: ambient.d.ts\ndeclare module 'some-adapter' {\n\texport interface Config { runtime: string }\n}\n\n// @filename: index.js\n// ---cut---\n/// file: src/routes/+page.js\n/** @type {import('some-adapter').Config} */\nexport const config = {\n\truntime: 'edge'\n};\n```\n\n`config` objects are merged at the top level (but _not_ deeper levels). This means you don't need to repeat all the values in a `+page.js` if you want to only override some of the values in the upper `+layout.js`. For example this layout configuration...\n\n```js\n/// file: src/routes/+layout.js\nexport const config = {\n\truntime: 'edge',\n\tregions: 'all',\n\tfoo: {\n\t\tbar: true\n\t}\n}\n```\n\n...is overridden by this page configuration...\n\n```js\n/// file: src/routes/+page.js\nexport const config = {\n\tregions: ['us1', 'us2'],\n\tfoo: {\n\t\tbaz: true\n\t}\n}\n```\n\n...which results in the config value `{ runtime: 'edge', regions: ['us1', 'us2'], foo: { baz: true } }` for that page.\n\n## Further reading\n\n- [Tutorial: Page options](/tutorial/kit/page-options)\n"
  },
  {
    "path": "documentation/docs/20-core-concepts/50-state-management.md",
    "content": "---\ntitle: State management\n---\n\nIf you're used to building client-only apps, state management in an app that spans server and client might seem intimidating. This section provides tips for avoiding some common gotchas.\n\n## Avoid shared state on the server\n\nBrowsers are _stateful_ — state is stored in memory as the user interacts with the application. Servers, on the other hand, are _stateless_ — the content of the response is determined entirely by the content of the request.\n\nConceptually, that is. In reality, servers are often long-lived and shared by multiple users. For that reason it's important not to store data in shared variables. For example, consider this code:\n\n```js\n// @errors: 7034 7005\n/// file: +page.server.js\nlet user;\n\n/** @type {import('./$types').PageServerLoad} */\nexport function load() {\n\treturn { user };\n}\n\n/** @satisfies {import('./$types').Actions} */\nexport const actions = {\n\tdefault: async ({ request }) => {\n\t\tconst data = await request.formData();\n\n\t\t// NEVER DO THIS!\n\t\tuser = {\n\t\t\tname: data.get('name'),\n\t\t\tembarrassingSecret: data.get('secret')\n\t\t};\n\t}\n}\n```\n\nThe `user` variable is shared by everyone who connects to this server. If Alice submitted an embarrassing secret, and Bob visited the page after her, Bob would know Alice's secret. In addition, when Alice returns to the site later in the day, the server may have restarted, losing her data.\n\nInstead, you should _authenticate_ the user using [`cookies`](load#Cookies) and persist the data to a database.\n\n## No side-effects in load\n\nFor the same reason, your `load` functions should be _pure_ — no side-effects (except maybe the occasional `console.log(...)`). For example, you might be tempted to write to a store or global state inside a `load` function so that you can use the value in your components:\n\n```js\n/// file: +page.js\n// @filename: ambient.d.ts\ndeclare module '$lib/user' {\n\texport const user: { set: (value: any) => void };\n}\n\n// @filename: index.js\n// ---cut---\nimport { user } from '$lib/user';\n\n/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst response = await fetch('/api/user');\n\n\t// NEVER DO THIS!\n\tuser.set(await response.json());\n}\n```\n\nAs with the previous example, this puts one user's information in a place that is shared by _all_ users. Instead, just return the data...\n\n```js\n/// file: +page.js\n/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst response = await fetch('/api/user');\n\n+++\treturn {\n\t\tuser: await response.json()\n\t};+++\n}\n```\n\n...and pass it around to the components that need it, or use [`page.data`](load#page.data).\n\nIf you're not using SSR, then there's no risk of accidentally exposing one user's data to another. But you should still avoid side-effects in your `load` functions — your application will be much easier to reason about without them.\n\n## Using state and stores with context\n\nYou might wonder how we're able to use `page.data` and other [app state]($app-state) (or [app stores]($app-stores)) if we can't use global state. The answer is that app state and app stores on the server use Svelte's [context API](/tutorial/svelte/context-api) — the state (or store) is attached to the component tree with `setContext`, and when you subscribe you retrieve it with `getContext`. We can do the same thing with our own state:\n\n```svelte\n<!--- file: src/routes/+layout.svelte --->\n<script>\n\timport { setContext } from 'svelte';\n\n\t/** @type {import('./$types').LayoutProps} */\n\tlet { data } = $props();\n\n\t// Pass a function referencing our state\n\t// to the context for child components to access\n\tsetContext('user', () => data.user);\n</script>\n```\n\n```svelte\n<!--- file: src/routes/user/+page.svelte --->\n<script>\n\timport { getContext } from 'svelte';\n\n\t// Retrieve user store from context\n\tconst user = getContext('user');\n</script>\n\n<p>Welcome {user().name}</p>\n```\n\n> [!NOTE] We're passing a function into `setContext` to keep reactivity across boundaries. Read more about it [here](/docs/svelte/$state#Passing-state-into-functions)\n\n> [!LEGACY]\n> You also use stores from `svelte/store` for this, but when using Svelte 5 it is recommended to make use of universal reactivity instead.\n\nUpdating the value of context-based state in deeper-level pages or components while the page is being rendered via SSR will not affect the value in the parent component because it has already been rendered by the time the state value is updated. In contrast, on the client (when CSR is enabled, which is the default) the value will be propagated and components, pages, and layouts higher in the hierarchy will react to the new value. Therefore, to avoid values 'flashing' during state updates during hydration, it is generally recommended to pass state down into components rather than up.\n\nIf you're not using SSR (and can guarantee that you won't need to use SSR in future) then you can safely keep state in a shared module, without using the context API.\n\n## Component and page state is preserved\n\nWhen you navigate around your application, SvelteKit reuses existing layout and page components. For example, if you have a route like this...\n\n```svelte\n<!--- file: src/routes/blog/[slug]/+page.svelte --->\n<script>\n\t/** @type {import('./$types').PageProps} */\n\tlet { data } = $props();\n\n\t// THIS CODE IS BUGGY!\n\tconst wordCount = data.content.split(' ').length;\n\tconst estimatedReadingTime = wordCount / 250;\n</script>\n\n<header>\n\t<h1>{data.title}</h1>\n\t<p>Reading time: {Math.round(estimatedReadingTime)} minutes</p>\n</header>\n\n<div>{@html data.content}</div>\n```\n\n...then navigating from `/blog/my-short-post` to `/blog/my-long-post` won't cause the layout, page and any other components within to be destroyed and recreated. Instead the `data` prop (and by extension `data.title` and `data.content`) will update (as it would with any other Svelte component) and, because the code isn't rerunning, lifecycle methods like `onMount` and `onDestroy` won't rerun and `estimatedReadingTime` won't be recalculated.\n\nInstead, we need to make the value [_reactive_](/tutorial/svelte/state):\n\n```svelte\n/// file: src/routes/blog/[slug]/+page.svelte\n<script>\n\t/** @type {import('./$types').PageProps} */\n\tlet { data } = $props();\n\n+++\tlet wordCount = $derived(data.content.split(' ').length);\n\tlet estimatedReadingTime = $derived(wordCount / 250);+++\n</script>\n```\n\n> [!NOTE] If your code in `onMount` and `onDestroy` has to run again after navigation you can use [afterNavigate]($app-navigation#afterNavigate) and [beforeNavigate]($app-navigation#beforeNavigate) respectively.\n\nReusing components like this means that things like sidebar scroll state are preserved, and you can easily animate between changing values. In the case that you do need to completely destroy and remount a component on navigation, you can use this pattern:\n\n```svelte\n<script>\n\timport { page } from '$app/state';\n</script>\n\n{#key page.url.pathname}\n\t<BlogPost title={data.title} content={data.title} />\n{/key}\n```\n\n## Storing state in the URL\n\nIf you have state that should survive a reload and/or affect SSR, such as filters or sorting rules on a table, URL search parameters (like `?sort=price&order=ascending`) are a good place to put them. You can put them in `<a href=\"...\">` or `<form action=\"...\">` attributes, or set them programmatically via `goto('?key=value')`. They can be accessed inside `load` functions via the `url` parameter, and inside components via `page.url.searchParams`.\n\n## Storing ephemeral state in snapshots\n\nSome UI state, such as 'is the accordion open?', is disposable — if the user navigates away or refreshes the page, it doesn't matter if the state is lost. In some cases, you _do_ want the data to persist if the user navigates to a different page and comes back, but storing the state in the URL or in a database would be overkill. For this, SvelteKit provides [snapshots](snapshots), which let you associate component state with a history entry.\n"
  },
  {
    "path": "documentation/docs/20-core-concepts/60-remote-functions.md",
    "content": "---\ntitle: Remote functions\n---\n\n<blockquote class=\"since note\">\n\t<p>Available since 2.27</p>\n</blockquote>\n\nRemote functions are a tool for type-safe communication between client and server. They can be _called_ anywhere in your app, but always _run_ on the server, meaning they can safely access [server-only modules](server-only-modules) containing things like environment variables and database clients.\n\nCombined with Svelte's experimental support for [`await`](/docs/svelte/await-expressions), it allows you to load and manipulate data directly inside your components.\n\nThis feature is currently experimental, meaning it is likely to contain bugs and is subject to change without notice. You must opt in by adding the `kit.experimental.remoteFunctions` option in your `svelte.config.js` and optionally, the `compilerOptions.experimental.async` option to use `await` in components:\n\n```js\n/// file: svelte.config.js\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\texperimental: {\n\t\t\t+++remoteFunctions: true+++\n\t\t}\n\t},\n\tcompilerOptions: {\n\t\texperimental: {\n\t\t\t+++async: true+++\n\t\t}\n\t}\n};\n\nexport default config;\n```\n\n## Overview\n\nRemote functions are exported from a `.remote.js` or `.remote.ts` file, and come in four flavours: `query`, `form`, `command` and `prerender`. On the client, the exported functions are transformed to `fetch` wrappers that invoke their counterparts on the server via a generated HTTP endpoint. Remote files can be placed anywhere in your `src` directory (except inside the `src/lib/server` directory), and third party libraries can provide them, too.\n\n## query\n\nThe `query` function allows you to read dynamic data from the server (for _static_ data, consider using [`prerender`](#prerender) instead):\n\n```js\n/// file: src/routes/blog/data.remote.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function sql(strings: TemplateStringsArray, ...values: any[]): Promise<any[]>;\n}\n// @filename: index.js\n// ---cut---\nimport { query } from '$app/server';\nimport * as db from '$lib/server/database';\n\nexport const getPosts = query(async () => {\n\tconst posts = await db.sql`\n\t\tSELECT title, slug\n\t\tFROM post\n\t\tORDER BY published_at\n\t\tDESC\n\t`;\n\n\treturn posts;\n});\n```\n\n> [!NOTE] Throughout this page, you'll see imports from fictional modules like `$lib/server/database` and `$lib/server/auth`. These are purely for illustrative purposes — you can use whatever database client and auth setup you like.\n>\n> The `db.sql` function above is a [tagged template function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) that escapes any interpolated values.\n\nThe query returned from `getPosts` works as a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves to `posts`:\n\n```svelte\n<!--- file: src/routes/blog/+page.svelte --->\n<script>\n\timport { getPosts } from './data.remote';\n</script>\n\n<h1>Recent posts</h1>\n\n<ul>\n\t{#each await getPosts() as { title, slug }}\n\t\t<li><a href=\"/blog/{slug}\">{title}</a></li>\n\t{/each}\n</ul>\n```\n\nUntil the promise resolves — and if it errors — the nearest [`<svelte:boundary>`](../svelte/svelte-boundary) will be invoked.\n\nWhile using `await` is recommended, as an alternative the query also has `loading`, `error` and `current` properties:\n\n```svelte\n<!--- file: src/routes/blog/+page.svelte --->\n<script>\n\timport { getPosts } from './data.remote';\n\n\tconst query = getPosts();\n</script>\n\n<h1>Recent posts</h1>\n\n{#if query.error}\n\t<p>oops!</p>\n{:else if query.loading}\n\t<p>loading...</p>\n{:else}\n\t<ul>\n\t\t{#each query.current as { title, slug }}\n\t\t\t<li><a href=\"/blog/{slug}\">{title}</a></li>\n\t\t{/each}\n\t</ul>\n{/if}\n```\n\n> [!NOTE] For the rest of this document, we'll use the `await` form.\n\n### Query arguments\n\nQuery functions can accept an argument, such as the `slug` of an individual post:\n\n```svelte\n<!--- file: src/routes/blog/[slug]/+page.svelte --->\n<script>\n\timport { getPost } from '../data.remote';\n\n\tlet { params } = $props();\n\n\tconst post = $derived(await getPost(params.slug));\n</script>\n\n<h1>{post.title}</h1>\n<div>{@html post.content}</div>\n```\n\nSince `getPost` exposes an HTTP endpoint, it's important to validate this argument to be sure that it's the correct type. For this, we can use any [Standard Schema](https://standardschema.dev/) validation library such as [Zod](https://zod.dev/) or [Valibot](https://valibot.dev/):\n\n```js\n/// file: src/routes/blog/data.remote.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function sql(strings: TemplateStringsArray, ...values: any[]): Promise<any[]>;\n}\n// @filename: index.js\n// ---cut---\nimport * as v from 'valibot';\nimport { error } from '@sveltejs/kit';\nimport { query } from '$app/server';\nimport * as db from '$lib/server/database';\n\nexport const getPosts = query(async () => { /* ... */ });\n\nexport const getPost = query(v.string(), async (slug) => {\n\tconst [post] = await db.sql`\n\t\tSELECT * FROM post\n\t\tWHERE slug = ${slug}\n\t`;\n\n\tif (!post) error(404, 'Not found');\n\treturn post;\n});\n```\n\nBoth the argument and the return value are serialized with [devalue](https://github.com/sveltejs/devalue), which handles types like `Date` and `Map` (and custom types defined in your [transport hook](hooks#Universal-hooks-transport)) in addition to JSON.\n\n### Refreshing queries\n\nAny query can be re-fetched via its `refresh` method, which retrieves the latest value from the server:\n\n```svelte\n<button onclick={() => getPosts().refresh()}>\n\tCheck for new posts\n</button>\n```\n\n> [!NOTE] Queries are cached while they're on the page, meaning `getPosts() === getPosts()`. This means you don't need a reference like `const posts = getPosts()` in order to update the query.\n\n## query.batch\n\n`query.batch` works like `query` except that it batches requests that happen within the same macrotask. This solves the so-called n+1 problem: rather than each query resulting in a separate database call (for example), simultaneous queries are grouped together.\n\nOn the server, the callback receives an array of the arguments the function was called with. It must return a function of the form `(input: Input, index: number) => Output`. SvelteKit will then call this with each of the input arguments to resolve the individual calls with their results.\n\n```js\n/// file: weather.remote.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function sql(strings: TemplateStringsArray, ...values: any[]): Promise<any[]>;\n}\n// @filename: index.js\n// ---cut---\nimport * as v from 'valibot';\nimport { query } from '$app/server';\nimport * as db from '$lib/server/database';\n\nexport const getWeather = query.batch(v.string(), async (cityIds) => {\n\tconst weather = await db.sql`\n\t\tSELECT * FROM weather\n\t\tWHERE city_id = ANY(${cityIds})\n\t`;\n\tconst lookup = new Map(weather.map(w => [w.city_id, w]));\n\n\treturn (cityId) => lookup.get(cityId);\n});\n```\n\n```svelte\n<!--- file: Weather.svelte --->\n<script>\n\timport CityWeather from './CityWeather.svelte';\n\timport { getWeather } from './weather.remote';\n\n\tlet { cities } = $props();\n\tlet limit = $state(5);\n</script>\n\n<h2>Weather</h2>\n\n{#each cities.slice(0, limit) as city}\n\t<h3>{city.name}</h3>\n\t<CityWeather weather={await getWeather(city.id)} />\n{/each}\n\n{#if cities.length > limit}\n\t<button onclick={() => limit += 5}>\n\t\tLoad more\n\t</button>\n{/if}\n```\n\n## form\n\nThe `form` function makes it easy to write data to the server. It takes a callback that receives `data` constructed from the submitted [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)...\n\n```ts\n/// file: src/routes/blog/data.remote.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function sql(strings: TemplateStringsArray, ...values: any[]): Promise<any[]>;\n}\n\ndeclare module '$lib/server/auth' {\n\tinterface User {\n\t\tname: string;\n\t}\n\n\t/**\n\t * Gets a user's info from their cookies, using `getRequestEvent`\n\t */\n\texport function getUser(): Promise<User | null>;\n}\n// @filename: index.js\n// ---cut---\nimport * as v from 'valibot';\nimport { error, redirect } from '@sveltejs/kit';\nimport { query, form } from '$app/server';\nimport * as db from '$lib/server/database';\nimport * as auth from '$lib/server/auth';\n\nexport const getPosts = query(async () => { /* ... */ });\n\nexport const getPost = query(v.string(), async (slug) => { /* ... */ });\n\nexport const createPost = form(\n\tv.object({\n\t\ttitle: v.pipe(v.string(), v.nonEmpty()),\n\t\tcontent:v.pipe(v.string(), v.nonEmpty())\n\t}),\n\tasync ({ title, content }) => {\n\t\t// Check the user is logged in\n\t\tconst user = await auth.getUser();\n\t\tif (!user) error(401, 'Unauthorized');\n\n\t\tconst slug = title.toLowerCase().replace(/ /g, '-');\n\n\t\t// Insert into the database\n\t\tawait db.sql`\n\t\t\tINSERT INTO post (slug, title, content)\n\t\t\tVALUES (${slug}, ${title}, ${content})\n\t\t`;\n\n\t\t// Redirect to the newly created page\n\t\tredirect(303, `/blog/${slug}`);\n\t}\n);\n```\n\n...and returns an object that can be spread onto a `<form>` element. The callback is called whenever the form is submitted.\n\n```svelte\n<!--- file: src/routes/blog/new/+page.svelte --->\n<script>\n\timport { createPost } from '../data.remote';\n</script>\n\n<h1>Create a new post</h1>\n\n<form {...createPost}>\n\t<!-- form content goes here -->\n\n\t<button>Publish!</button>\n</form>\n```\n\nThe form object contains `method` and `action` properties that allow it to work without JavaScript (i.e. it submits data and reloads the page). It also has an [attachment](/docs/svelte/@attach) that progressively enhances the form when JavaScript is available, submitting data *without* reloading the entire page.\n\nAs with `query`, if the callback uses the submitted `data`, it should be [validated](#query-Query-arguments) by passing a [Standard Schema](https://standardschema.dev) as the first argument to `form`.\n\n### Fields\n\nA form is composed of a set of _fields_, which are defined by the schema. In the case of `createPost`, we have two fields, `title` and `content`, which are both strings. To get the attributes for a field, call its `.as(...)` method, specifying which [input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#input_types) to use:\n\n```svelte\n<form {...createPost}>\n\t<label>\n\t\t<h2>Title</h2>\n\t\t+++<input {...createPost.fields.title.as('text')} />+++\n\t</label>\n\n\t<label>\n\t\t<h2>Write your post</h2>\n\t\t+++<textarea {...createPost.fields.content.as('text')}></textarea>+++\n\t</label>\n\n\t<button>Publish!</button>\n</form>\n```\n\nThese attributes allow SvelteKit to set the correct input type, set a `name` that is used to construct the `data` passed to the handler, populate the `value` of the form (for example following a failed submission, to save the user having to re-enter everything), and set the [`aria-invalid`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-invalid) state.\n\n> [!NOTE] The generated `name` attribute uses JS object notation (e.g. `nested.array[0].value`). String keys that require quotes such as `object['nested-array'][0].value` are not supported. Under the hood, boolean checkbox and number field names are prefixed with `b:` and `n:`, respectively, to signal SvelteKit to coerce the values from strings prior to validation.\n\nFields can be nested in objects and arrays, and their values can be strings, numbers, booleans or `File` objects. For example, if your schema looked like this...\n\n```js\n/// file: data.remote.js\nimport * as v from 'valibot';\nimport { form } from '$app/server';\n// ---cut---\nconst datingProfile = v.object({\n\tname: v.string(),\n\tphoto: v.file(),\n\tinfo: v.object({\n\t\theight: v.number(),\n\t\tlikesDogs: v.optional(v.boolean(), false)\n\t}),\n\tattributes: v.array(v.string())\n});\n\nexport const createProfile = form(datingProfile, (data) => { /* ... */ });\n```\n\n...your form could look like this:\n\n```svelte\n<script>\n\timport { createProfile } from './data.remote';\n\n\tconst { name, photo, info, attributes } = createProfile.fields;\n</script>\n\n<form {...createProfile} enctype=\"multipart/form-data\">\n\t<label>\n\t\t<input {...name.as('text')} /> Name\n\t</label>\n\n\t<label>\n\t\t<input {...photo.as('file')} /> Photo\n\t</label>\n\n\t<label>\n\t\t<input {...info.height.as('number')} /> Height (cm)\n\t</label>\n\n\t<label>\n\t\t<input {...info.likesDogs.as('checkbox')} /> I like dogs\n\t</label>\n\n\t<h2>My best attributes</h2>\n\t<input {...attributes[0].as('text')} />\n\t<input {...attributes[1].as('text')} />\n\t<input {...attributes[2].as('text')} />\n\n\t<button>submit</button>\n</form>\n```\n\nBecause our form contains a `file` input, we've added an `enctype=\"multipart/form-data\"` attribute. The values for `info.height` and `info.likesDogs` are coerced to a number and a boolean respectively.\n\n> [!NOTE] If a `checkbox` input is unchecked, the value is not included in the [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) object that SvelteKit constructs the data from. As such, we have to make the value optional in our schema. In Valibot that means using `v.optional(v.boolean(), false)` instead of just `v.boolean()`, whereas in Zod it would mean using `z.coerce.boolean<boolean>()`.\n\nIn the case of `radio` and `checkbox` inputs that all belong to the same field, the `value` must be specified as a second argument to `.as(...)`:\n\n```js\n/// file: data.remote.js\nimport * as v from 'valibot';\nimport { form } from '$app/server';\n// ---cut---\nexport const operatingSystems = /** @type {const} */ (['windows', 'mac', 'linux']);\nexport const languages = /** @type {const} */ (['html', 'css', 'js']);\n\nexport const survey = form(\n\tv.object({\n\t\toperatingSystem: v.picklist(operatingSystems),\n\t\tlanguages: v.optional(v.array(v.picklist(languages)), []),\n\t}),\n\t(data) => { /* ... */ },\n);\n```\n\n```svelte\n<form {...survey}>\n\t<h2>Which operating system do you use?</h2>\n\n\t{#each operatingSystems as os}\n\t\t<label>\n\t\t\t<input {...survey.fields.operatingSystem.as('radio', os)}>\n\t\t\t{os}\n\t\t</label>\n\t{/each}\n\n\t<h2>Which languages do you write code in?</h2>\n\n\t{#each languages as language}\n\t\t<label>\n\t\t\t<input {...survey.fields.languages.as('checkbox', language)}>\n\t\t\t{language}\n\t\t</label>\n\t{/each}\n\n\t<button>submit</button>\n</form>\n```\n\nAlternatively, you could use `select` and `select multiple`:\n\n```svelte\n<form {...survey}>\n\t<h2>Which operating system do you use?</h2>\n\n\t<select {...survey.fields.operatingSystem.as('select')}>\n\t\t{#each operatingSystems as os}\n\t\t\t<option>{os}</option>\n\t\t{/each}\n\t</select>\n\n\t<h2>Which languages do you write code in?</h2>\n\n\t<select {...survey.fields.languages.as('select multiple')}>\n\t\t{#each languages as language}\n\t\t\t<option>{language}</option>\n\t\t{/each}\n\t</select>\n\n\t<button>submit</button>\n</form>\n```\n\n> [!NOTE] As with unchecked `checkbox` inputs, if no selections are made then the data will be `undefined`. For this reason, the `languages` field uses `v.optional(v.array(...), [])` rather than just `v.array(...)`.\n\n### Programmatic validation\n\nIn addition to declarative schema validation, you can programmatically mark fields as invalid inside the form handler using the `invalid` helper from `@sveltejs/kit`. This is useful for cases where you can't know if something is valid until you try to perform some action.\n\n- It throws just like `redirect` or `error`\n- It accepts multiple arguments that can be strings (for issues relating to the form as a whole — these will only show up in `fields.allIssues()`) or standard-schema-compliant issues (for those relating to a specific field). Use the `issue` parameter for type-safe creation of such issues:\n\n```js\n/// file: src/routes/shop/data.remote.js\nimport * as v from 'valibot';\nimport { invalid } from '@sveltejs/kit';\nimport { form } from '$app/server';\nimport * as db from '$lib/server/database';\n\nexport const buyHotcakes = form(\n\tv.object({\n\t\tqty: v.pipe(\n\t\t\tv.number(),\n\t\t\tv.minValue(1, 'you must buy at least one hotcake')\n\t\t)\n\t}),\n\tasync (data, issue) => {\n\t\ttry {\n\t\t\tawait db.buy(data.qty);\n\t\t} catch (e) {\n\t\t\tif (e.code === 'OUT_OF_STOCK') {\n\t\t\t\tinvalid(\n\t\t\t\t\tissue.qty(`we don't have enough hotcakes`)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n);\n```\n\n### Validation\n\nIf the submitted data doesn't pass the schema, the callback will not run. Instead, each invalid field's `issues()` method will return an array of `{ message: string }` objects, and the `aria-invalid` attribute (returned from `as(...)`) will be set to `true`:\n\n```svelte\n<form {...createPost}>\n\t<label>\n\t\t<h2>Title</h2>\n\n+++\t\t{#each createPost.fields.title.issues() as issue}\n\t\t\t<p class=\"issue\">{issue.message}</p>\n\t\t{/each}+++\n\n\t\t<input {...createPost.fields.title.as('text')} />\n\t</label>\n\n\t<label>\n\t\t<h2>Write your post</h2>\n\n+++\t\t{#each createPost.fields.content.issues() as issue}\n\t\t\t<p class=\"issue\">{issue.message}</p>\n\t\t{/each}+++\n\n\t\t<textarea {...createPost.fields.content.as('text')}></textarea>\n\t</label>\n\n\t<button>Publish!</button>\n</form>\n```\n\nYou don't need to wait until the form is submitted to validate the data — you can call `validate()` programmatically, for example in an `oninput` callback (which will validate the data on every keystroke) or an `onchange` callback:\n\n```svelte\n<form {...createPost} oninput={() => createPost.validate()}>\n\t<!-- -->\n</form>\n```\n\nBy default, issues will be ignored if they belong to form controls that haven't yet been interacted with. To validate _all_ inputs, call `validate({ includeUntouched: true })`.\n\nFor client-side validation, you can specify a _preflight_ schema which will populate `issues()` and prevent data being sent to the server if the data doesn't validate:\n\n```svelte\n<script>\n\timport * as v from 'valibot';\n\timport { createPost } from '../data.remote';\n\n\tconst schema = v.object({\n\t\ttitle: v.pipe(v.string(), v.nonEmpty()),\n\t\tcontent: v.pipe(v.string(), v.nonEmpty())\n\t});\n</script>\n\n<h1>Create a new post</h1>\n\n<form {...+++createPost.preflight(schema)+++}>\n\t<!-- -->\n</form>\n```\n\n> [!NOTE] The preflight schema can be the same object as your server-side schema, if appropriate, though it won't be able to do server-side checks like 'this value already exists in the database'. Note that you cannot export a schema from a `.remote.ts` or `.remote.js` file, so the schema must either be exported from a shared module, or from a `<script module>` block in the component containing the `<form>`.\n\nTo get a list of _all_ issues, rather than just those belonging to a single field, you can use the `fields.allIssues()` method:\n\n```svelte\n{#each createPost.fields.allIssues() as issue}\n\t<p>{issue.message}</p>\n{/each}\n```\n\n### Getting/setting inputs\n\nEach field has a `value()` method that reflects its current value. As the user interacts with the form, it is automatically updated:\n\n```svelte\n<form {...createPost}>\n\t<!-- -->\n</form>\n\n<div class=\"preview\">\n\t<h2>{createPost.fields.title.value()}</h2>\n\t<div>{@html render(createPost.fields.content.value())}</div>\n</div>\n```\n\nAlternatively, `createPost.fields.value()` would return a `{ title, content }` object.\n\nYou can update a field (or a collection of fields) via the `set(...)` method:\n\n```svelte\n<script>\n\timport { createPost } from '../data.remote';\n\n\t// this...\n\tcreatePost.fields.set({\n\t\ttitle: 'My new blog post',\n\t\tcontent: 'Lorem ipsum dolor sit amet...'\n\t});\n\n\t// ...is equivalent to this:\n\tcreatePost.fields.title.set('My new blog post');\n\tcreatePost.fields.content.set('Lorem ipsum dolor sit amet');\n</script>\n```\n\n### Handling sensitive data\n\nIn the case of a non-progressively-enhanced form submission (i.e. where JavaScript is unavailable, for whatever reason) `value()` is also populated if the submitted data is invalid, so that the user does not need to fill the entire form out from scratch.\n\nYou can prevent sensitive data (such as passwords and credit card numbers) from being sent back to the user by using a name with a leading underscore:\n\n```svelte\n<form {...register}>\n\t<label>\n\t\tUsername\n\t\t<input {...register.fields.username.as('text')} />\n\t</label>\n\n\t<label>\n\t\tPassword\n\t\t<input +++{...register.fields._password.as('password')}+++ />\n\t</label>\n\n\t<button>Sign up!</button>\n</form>\n```\n\nIn this example, if the data does not validate, only the first `<input>` will be populated when the page reloads.\n\n### Single-flight mutations\n\nBy default, all queries used on the page (along with any `load` functions) are automatically refreshed following a successful form submission. This ensures that everything is up-to-date, but it's also inefficient: many queries will be unchanged, and it requires a second trip to the server to get the updated data.\n\nInstead, we can specify which queries should be refreshed in response to a particular form submission. This is called a _single-flight mutation_, and there are two ways to achieve it. The first is to refresh the query on the server, inside the form handler:\n\n```js\nimport * as v from 'valibot';\nimport { error, redirect } from '@sveltejs/kit';\nimport { query, form } from '$app/server';\nconst slug = '';\nconst post = { id: '' };\n/** @type {any} */\nconst externalApi = '';\n// ---cut---\nexport const getPosts = query(async () => { /* ... */ });\n\nexport const getPost = query(v.string(), async (slug) => { /* ... */ });\n\nexport const createPost = form(\n\tv.object({/* ... */}),\n\tasync (data) => {\n\t\t// form logic goes here...\n\n\t\t// Refresh `getPosts()` on the server, and send\n\t\t// the data back with the result of `createPost`\n\t\t+++await getPosts().refresh();+++\n\n\t\t// Redirect to the newly created page\n\t\tredirect(303, `/blog/${slug}`);\n\t}\n);\n\nexport const updatePost = form(\n\tv.object({/* ... */}),\n\tasync (data) => {\n\t\t// form logic goes here...\n\t\tconst result = externalApi.update(post);\n\n\t\t// The API already gives us the updated post,\n\t\t// no need to refresh it, we can set it directly\n\t\t+++await getPost(post.id).set(result);+++\n\t}\n);\n```\n\nThe second is to drive the single-flight mutation from the client, which we'll see in the section on [`enhance`](#form-enhance).\n\n### Returns and redirects\n\nThe example above uses [`redirect(...)`](@sveltejs-kit#redirect), which sends the user to the newly created page. Alternatively, the callback could return data, in which case it would be available as `createPost.result`:\n\n```ts\n/// file: src/routes/blog/data.remote.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function sql(strings: TemplateStringsArray, ...values: any[]): Promise<any[]>;\n}\n\ndeclare module '$lib/server/auth' {\n\tinterface User {\n\t\tname: string;\n\t}\n\n\t/**\n\t * Gets a user's info from their cookies, using `getRequestEvent`\n\t */\n\texport function getUser(): Promise<User | null>;\n}\n// @filename: index.js\nimport * as v from 'valibot';\nimport { error, redirect } from '@sveltejs/kit';\nimport { query, form } from '$app/server';\nimport * as db from '$lib/server/database';\nimport * as auth from '$lib/server/auth';\n\nexport const getPosts = query(async () => { /* ... */ });\n\nexport const getPost = query(v.string(), async (slug) => { /* ... */ });\n\n// ---cut---\nexport const createPost = form(\n\tv.object({/* ... */}),\n\tasync (data) => {\n\t\t// ...\n\n\t\treturn { success: true };\n\t}\n);\n```\n\n```svelte\n<!--- file: src/routes/blog/new/+page.svelte --->\n<script>\n\timport { createPost } from '../data.remote';\n</script>\n\n<h1>Create a new post</h1>\n\n<form {...createPost}>\n\t<!-- -->\n</form>\n\n{#if createPost.result?.success}\n\t<p>Successfully published!</p>\n{/if}\n```\n\nThis value is _ephemeral_ — it will vanish if you resubmit, navigate away, or reload the page.\n\n> [!NOTE] The `result` value need not indicate success — it can also contain validation errors, along with any data that should repopulate the form on page reload.\n\nIf an error occurs during submission, the nearest `+error.svelte` page will be rendered.\n\n### enhance\n\nWe can customize what happens when the form is submitted with the `enhance` method:\n\n```svelte\n<!--- file: src/routes/blog/new/+page.svelte --->\n<script>\n\timport { createPost } from '../data.remote';\n\timport { showToast } from '$lib/toast';\n</script>\n\n<h1>Create a new post</h1>\n\n<form {...createPost.enhance(async ({ form, data, submit }) => {\n\ttry {\n\t\tawait submit();\n\t\tform.reset();\n\n\t\tshowToast('Successfully published!');\n\t} catch (error) {\n\t\tshowToast('Oh no! Something went wrong');\n\t}\n})}>\n\t<!-- -->\n</form>\n```\n\n> When using `enhance`, the `<form>` is not automatically reset — you must call `form.reset()` if you want to clear the inputs.\n\nThe callback receives the `form` element, the `data` it contains, and a `submit` function.\n\nTo enable client-driven [single-flight mutations](#form-Single-flight-mutations), use `submit().updates(...)`. For example, if the `getPosts()` query was used on this page, we could refresh it like so:\n\n```ts\nimport type { RemoteQuery, RemoteQueryOverride } from '@sveltejs/kit';\ninterface Post {}\ndeclare function submit(): Promise<any> & {\n\tupdates(...queries: Array<RemoteQuery<any> | RemoteQueryOverride>): Promise<any>;\n}\n\ndeclare function getPosts(): RemoteQuery<Post[]>;\n// ---cut---\nawait submit().updates(getPosts());\n```\n\nWe can also _override_ the current data while the submission is ongoing:\n\n```ts\nimport type { RemoteQuery, RemoteQueryOverride } from '@sveltejs/kit';\ninterface Post {}\ndeclare function submit(): Promise<any> & {\n\tupdates(...queries: Array<RemoteQuery<any> | RemoteQueryOverride>): Promise<any>;\n}\n\ndeclare function getPosts(): RemoteQuery<Post[]>;\ndeclare const newPost: Post;\n// ---cut---\nawait submit().updates(\n\tgetPosts().withOverride((posts) => [newPost, ...posts])\n);\n```\n\nThe override will be applied immediately, and released when the submission completes (or fails).\n\n### Multiple instances of a form\n\nSome forms may be repeated as part of a list. In this case you can create separate instances of a form function via `for(id)` to achieve isolation.\n\n```svelte\n<!--- file: src/routes/todos/+page.svelte --->\n<script>\n\timport { getTodos, modifyTodo } from '../data.remote';\n</script>\n\n<h1>Todos</h1>\n\n{#each await getTodos() as todo}\n\t{@const modify = modifyTodo.for(todo.id)}\n\t<form {...modify}>\n\t\t<!-- -->\n\t\t<button disabled={!!modify.pending}>save changes</button>\n\t</form>\n{/each}\n```\n\n### Multiple submit buttons\n\nIt's possible for a `<form>` to have multiple submit buttons. For example, you might have a single form that allows you to log in or register depending on which button was clicked.\n\nTo accomplish this, add a field to your schema for the button value, and use `as('submit', value)` to bind it:\n\n```svelte\n<!--- file: src/routes/login/+page.svelte --->\n<script>\n\timport { loginOrRegister } from '$lib/auth';\n</script>\n\n<form {...loginOrRegister}>\n\t<label>\n\t\tYour username\n\t\t<input {...loginOrRegister.fields.username.as('text')} />\n\t</label>\n\n\t<label>\n\t\tYour password\n\t\t<input {...loginOrRegister.fields._password.as('password')} />\n\t</label>\n\n\t<button {...loginOrRegister.fields.action.as('submit', 'login')}>login</button>\n\t<button {...loginOrRegister.fields.action.as('submit', 'register')}>register</button>\n</form>\n```\n\nIn your form handler, you can check which button was clicked:\n\n```js\n/// file: $lib/auth.js\nimport * as v from 'valibot';\nimport { form } from '$app/server';\n\nexport const loginOrRegister = form(\n\tv.object({\n\t\tusername: v.string(),\n\t\t_password: v.string(),\n\t\taction: v.picklist(['login', 'register'])\n\t}),\n\tasync ({ username, _password, action }) => {\n\t\tif (action === 'login') {\n\t\t\t// handle login\n\t\t} else {\n\t\t\t// handle registration\n\t\t}\n\t}\n);\n```\n\n## command\n\nThe `command` function, like `form`, allows you to write data to the server. Unlike `form`, it's not specific to an element and can be called from anywhere.\n\n> [!NOTE] Prefer `form` where possible, since it gracefully degrades if JavaScript is disabled or fails to load.\n\nAs with `query` and `form`, if the function accepts an argument, it should be [validated](#query-Query-arguments) by passing a [Standard Schema](https://standardschema.dev) as the first argument to `command`.\n\n```ts\n/// file: likes.remote.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function sql(strings: TemplateStringsArray, ...values: any[]): Promise<any[]>;\n}\n// @filename: index.js\n// ---cut---\nimport * as v from 'valibot';\nimport { query, command } from '$app/server';\nimport * as db from '$lib/server/database';\n\nexport const getLikes = query(v.string(), async (id) => {\n\tconst [row] = await db.sql`\n\t\tSELECT likes\n\t\tFROM item\n\t\tWHERE id = ${id}\n\t`;\n\n\treturn row.likes;\n});\n\nexport const addLike = command(v.string(), async (id) => {\n\tawait db.sql`\n\t\tUPDATE item\n\t\tSET likes = likes + 1\n\t\tWHERE id = ${id}\n\t`;\n});\n```\n\nNow simply call `addLike`, from (for example) an event handler:\n\n```svelte\n<!--- file: +page.svelte --->\n<script>\n\timport { getLikes, addLike } from './likes.remote';\n\timport { showToast } from '$lib/toast';\n\n\tlet { item } = $props();\n</script>\n\n<button\n\tonclick={async () => {\n\t\ttry {\n\t\t\tawait addLike(item.id);\n\t\t} catch (error) {\n\t\t\tshowToast('Something went wrong!');\n\t\t}\n\t}}\n>\n\tadd like\n</button>\n\n<p>likes: {await getLikes(item.id)}</p>\n```\n\n> [!NOTE] Commands cannot be called during render.\n\n### Updating queries\n\nTo update `getLikes(item.id)`, or any other query, we need to tell SvelteKit _which_ queries need to be refreshed (unlike `form`, which by default invalidates everything, to approximate the behaviour of a native form submission).\n\nWe either do that inside the command itself...\n\n```js\n/// file: likes.remote.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function sql(strings: TemplateStringsArray, ...values: any[]): Promise<any[]>;\n}\n// @filename: index.js\n// ---cut---\nimport * as v from 'valibot';\nimport { query, command } from '$app/server';\nimport * as db from '$lib/server/database';\n// ---cut---\nexport const getLikes = query(v.string(), async (id) => { /* ... */ });\n\nexport const addLike = command(v.string(), async (id) => {\n\tawait db.sql`\n\t\tUPDATE item\n\t\tSET likes = likes + 1\n\t\tWHERE id = ${id}\n\t`;\n\n\t+++getLikes(id).refresh();+++\n\t// Just like within form functions you can also do\n\t// getLikes(id).set(...)\n\t// in case you have the result already\n});\n```\n\n...or when we call it:\n\n```ts\nimport { RemoteCommand, RemoteQueryFunction } from '@sveltejs/kit';\n\ninterface Item { id: string }\n\ndeclare const addLike: RemoteCommand<string, void>;\ndeclare const getLikes: RemoteQueryFunction<string, number>;\ndeclare function showToast(message: string): void;\ndeclare const item: Item;\n// ---cut---\ntry {\n\tawait addLike(item.id).+++updates(getLikes(item.id))+++;\n} catch (error) {\n\tshowToast('Something went wrong!');\n}\n```\n\nAs before, we can use `withOverride` for optimistic updates:\n\n```ts\nimport { RemoteCommand, RemoteQueryFunction } from '@sveltejs/kit';\n\ninterface Item { id: string }\n\ndeclare const addLike: RemoteCommand<string, void>;\ndeclare const getLikes: RemoteQueryFunction<string, number>;\ndeclare function showToast(message: string): void;\ndeclare const item: Item;\n// ---cut---\ntry {\n\tawait addLike(item.id).updates(\n\t\tgetLikes(item.id).+++withOverride((n) => n + 1)+++\n\t);\n} catch (error) {\n\tshowToast('Something went wrong!');\n}\n```\n\n## prerender\n\nThe `prerender` function is similar to `query`, except that it will be invoked at build time to prerender the result. Use this for data that changes at most once per redeployment.\n\n```js\n/// file: src/routes/blog/data.remote.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function sql(strings: TemplateStringsArray, ...values: any[]): Promise<any[]>;\n}\n// @filename: index.js\n// ---cut---\nimport { prerender } from '$app/server';\nimport * as db from '$lib/server/database';\n\nexport const getPosts = prerender(async () => {\n\tconst posts = await db.sql`\n\t\tSELECT title, slug\n\t\tFROM post\n\t\tORDER BY published_at\n\t\tDESC\n\t`;\n\n\treturn posts;\n});\n```\n\nYou can use `prerender` functions on pages that are otherwise dynamic, allowing for partial prerendering of your data. This results in very fast navigation, since prerendered data can live on a CDN along with your other static assets.\n\nIn the browser, prerendered data is saved using the [`Cache`](https://developer.mozilla.org/en-US/docs/Web/API/Cache) API. This cache survives page reloads, and will be cleared when the user first visits a new deployment of your app.\n\n> [!NOTE] When the entire page has `export const prerender = true`, you cannot use queries, as they are dynamic.\n\n### Prerender arguments\n\nAs with queries, prerender functions can accept an argument, which should be [validated](#query-Query-arguments) with a [Standard Schema](https://standardschema.dev/):\n\n```js\n/// file: src/routes/blog/data.remote.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function sql(strings: TemplateStringsArray, ...values: any[]): Promise<any[]>;\n}\n// @filename: index.js\n// ---cut---\nimport * as v from 'valibot';\nimport { error } from '@sveltejs/kit';\nimport { prerender } from '$app/server';\nimport * as db from '$lib/server/database';\n\nexport const getPosts = prerender(async () => { /* ... */ });\n\nexport const getPost = prerender(v.string(), async (slug) => {\n\tconst [post] = await db.sql`\n\t\tSELECT * FROM post\n\t\tWHERE slug = ${slug}\n\t`;\n\n\tif (!post) error(404, 'Not found');\n\treturn post;\n});\n```\n\nAny calls to `getPost(...)` found by SvelteKit's crawler while [prerendering pages](page-options#prerender) will be saved automatically, but you can also specify which values it should be called with using the `inputs` option:\n\n```js\n/// file: src/routes/blog/data.remote.js\nimport * as v from 'valibot';\nimport { prerender } from '$app/server';\n// ---cut---\n\nexport const getPost = prerender(\n\tv.string(),\n\tasync (slug) => { /* ... */ },\n\t{\n\t\tinputs: () => [\n\t\t\t'first-post',\n\t\t\t'second-post',\n\t\t\t'third-post'\n\t\t]\n\t}\n);\n```\n\nBy default, prerender functions are excluded from your server bundle, which means that you cannot call them with any arguments that were _not_ prerendered. You can set `dynamic: true` to change this behaviour:\n\n```js\n/// file: src/routes/blog/data.remote.js\nimport * as v from 'valibot';\nimport { prerender } from '$app/server';\n// ---cut---\n\nexport const getPost = prerender(\n\tv.string(),\n\tasync (slug) => { /* ... */ },\n\t{\n\t\t+++dynamic: true+++,\n\t\tinputs: () => [\n\t\t\t'first-post',\n\t\t\t'second-post',\n\t\t\t'third-post'\n\t\t]\n\t}\n);\n```\n\n## Handling validation errors\n\nAs long as _you're_ not passing invalid data to your remote functions, there are only two reasons why the argument passed to a `command`, `query` or `prerender` function would fail validation:\n\n- the function signature changed between deployments, and some users are currently on an older version of your app\n- someone is trying to attack your site by poking your exposed endpoints with bad data\n\nIn the second case, we don't want to give the attacker any help, so SvelteKit will generate a generic [400 Bad Request](https://http.dog/400) response. You can control the message by implementing the [`handleValidationError`](hooks#Server-hooks-handleValidationError) server hook, which, like [`handleError`](hooks#Shared-hooks-handleError), must return an [`App.Error`](errors#Type-safety) (which defaults to `{ message: string }`):\n\n```js\n/// file: src/hooks.server.ts\n/** @type {import('@sveltejs/kit').HandleValidationError} */\nexport function handleValidationError({ event, issues }) {\n\treturn {\n\t\tmessage: 'Nice try, hacker!'\n\t};\n}\n```\n\nIf you know what you're doing and want to opt out of validation, you can pass the string `'unchecked'` in place of a schema:\n\n```ts\n/// file: data.remote.ts\nimport { query } from '$app/server';\n\nexport const getStuff = query('unchecked', async ({ id }: { id: string }) => {\n\t// the shape might not actually be what TypeScript thinks\n\t// since bad actors might call this function with other arguments\n});\n```\n\n## Using `getRequestEvent`\n\nInside `query`, `form` and `command` you can use [`getRequestEvent`]($app-server#getRequestEvent) to get the current [`RequestEvent`](@sveltejs-kit#RequestEvent) object. This makes it easy to build abstractions for interacting with cookies, for example:\n\n```ts\n/// file: user.remote.ts\nimport { getRequestEvent, query } from '$app/server';\nimport { findUser } from '$lib/server/database';\n\nexport const getProfile = query(async () => {\n\tconst user = await getUser();\n\n\treturn {\n\t\tname: user.name,\n\t\tavatar: user.avatar\n\t};\n});\n\n// this query could be called from multiple places, but\n// the function will only run once per request\nconst getUser = query(async () => {\n\tconst { cookies } = getRequestEvent();\n\n\treturn await findUser(cookies.get('session_id'));\n});\n```\n\nNote that some properties of `RequestEvent` are different inside remote functions:\n\n- you cannot set headers (other than writing cookies, and then only inside `form` and `command` functions)\n- `route`, `params` and `url` relate to the page the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Queries are not re-run when the user navigates (unless the argument to the query changes as a result of navigation), and so you should be mindful of how you use these values. In particular, never use them to determine whether or not a user is authorized to access certain data.\n\n## Redirects\n\nInside `query`, `form` and `prerender` functions it is possible to use the [`redirect(...)`](@sveltejs-kit#redirect) function. It is *not* possible inside `command` functions, as you should avoid redirecting here. (If you absolutely have to, you can return a `{ redirect: location }` object and deal with it in the client.)\n"
  },
  {
    "path": "documentation/docs/20-core-concepts/index.md",
    "content": "---\ntitle: Core concepts\n---\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/10-building-your-app.md",
    "content": "---\ntitle: Building your app\n---\n\nBuilding a SvelteKit app happens in two stages, which both happen when you run `vite build` (usually via `npm run build`).\n\nFirstly, Vite creates an optimized production build of your server code, your browser code, and your service worker (if you have one). [Prerendering](page-options#prerender) is executed at this stage, if appropriate.\n\nSecondly, an _adapter_ takes this production build and tunes it for your target environment — more on this on the following pages.\n\n## During the build\n\nSvelteKit will load your `+page/layout(.server).js` files (and all files they import) for analysis during the build. Any code that should _not_ be executed at this stage must check that `building` from [`$app/environment`]($app-environment) is `false`:\n\n```js\n+++import { building } from '$app/environment';+++\nimport { initialiseDatabase } from '$lib/server/database';\n\n+++if (!building) {+++\n\tinitialiseDatabase();\n+++}+++\n\nexport function load() {\n\t// ...\n}\n```\n\n## Preview your app\n\nAfter building, you can view your production build locally with `vite preview` (via `npm run preview`). Note that this will run the app in Node, and so is not a perfect reproduction of your deployed app — adapter-specific adjustments like the [`platform` object](adapters#Platform-specific-context) do not apply to previews.\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/20-adapters.md",
    "content": "---\ntitle: Adapters\n---\n\nBefore you can deploy your SvelteKit app, you need to _adapt_ it for your deployment target. Adapters are small plugins that take the built app as input and generate output for deployment.\n\nOfficial adapters exist for a variety of platforms — these are documented on the following pages:\n\n- [`@sveltejs/adapter-cloudflare`](adapter-cloudflare) for Cloudflare Workers and Cloudflare Pages\n- [`@sveltejs/adapter-netlify`](adapter-netlify) for Netlify\n- [`@sveltejs/adapter-node`](adapter-node) for Node servers\n- [`@sveltejs/adapter-static`](adapter-static) for static site generation (SSG)\n- [`@sveltejs/adapter-vercel`](adapter-vercel) for Vercel\n\nAdditional [community-provided adapters](/packages#sveltekit-adapters) exist for other platforms.\n\n## Using adapters\n\nYour adapter is specified in `svelte.config.js`:\n\n```js\n/// file: svelte.config.js\n// @filename: ambient.d.ts\ndeclare module 'svelte-adapter-foo' {\n\tconst adapter: (opts: any) => import('@sveltejs/kit').Adapter;\n\texport default adapter;\n}\n\n// @filename: index.js\n// ---cut---\nimport adapter from 'svelte-adapter-foo';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\t// adapter options go here\n\t\t})\n\t}\n};\n\nexport default config;\n```\n\n## Platform-specific context\n\nSome adapters may have access to additional information about the request. For example, Cloudflare Workers can access an `env` object containing KV namespaces etc. This can be passed to the `RequestEvent` used in [hooks](hooks) and [server routes](routing#server) as the `platform` property — consult each adapter's documentation to learn more.\n\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/30-adapter-auto.md",
    "content": "---\ntitle: Zero-config deployments\n---\n\nWhen you create a new SvelteKit project with `npx sv create`, it installs [`adapter-auto`](https://github.com/sveltejs/kit/tree/main/packages/adapter-auto) by default. This adapter automatically installs and uses the correct adapter for supported environments when you deploy:\n\n- [`@sveltejs/adapter-cloudflare`](adapter-cloudflare) for [Cloudflare Pages](https://developers.cloudflare.com/pages/)\n- [`@sveltejs/adapter-netlify`](adapter-netlify) for [Netlify](https://netlify.com/)\n- [`@sveltejs/adapter-vercel`](adapter-vercel) for [Vercel](https://vercel.com/)\n- [`svelte-adapter-azure-swa`](https://github.com/geoffrich/svelte-adapter-azure-swa) for [Azure Static Web Apps](https://docs.microsoft.com/en-us/azure/static-web-apps/)\n- [`svelte-kit-sst`](https://github.com/sst/v2/tree/master/packages/svelte-kit-sst) for [AWS via SST](https://sst.dev/docs/start/aws/svelte)\n- [`@sveltejs/adapter-node`](adapter-node) for [Google Cloud Run](https://cloud.google.com/run)\n\nIt's recommended to install the appropriate adapter to your `devDependencies` once you've settled on a target environment, since this will add the adapter to your lockfile and slightly improve install times on CI.\n\n## Environment-specific configuration\n\nTo add configuration options, such as `{ edge: true }` in [`adapter-vercel`](adapter-vercel) and [`adapter-netlify`](adapter-netlify), you must install the underlying adapter — `adapter-auto` does not take any options.\n\n## Adding community adapters\n\nYou can add zero-config support for additional adapters by editing [adapters.js](https://github.com/sveltejs/kit/blob/main/packages/adapter-auto/adapters.js) and opening a pull request.\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/40-adapter-node.md",
    "content": "---\ntitle: Node servers\n---\n\nTo generate a standalone Node server, use [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node).\n\n## Usage\n\nInstall with `npm i -D @sveltejs/adapter-node`, then add the adapter to your `svelte.config.js`:\n\n```js\n// @errors: 2307\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-node';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n```\n\n## Deploying\n\nFirst, build your app with `npm run build`. This will create the production server in the output directory specified in the adapter options, defaulting to `build`.\n\nYou will need the output directory, the project's `package.json`, and the production dependencies in `node_modules` to run the application. Production dependencies can be generated by copying the `package.json` and `package-lock.json` and then running `npm ci --omit dev` (you can skip this step if your app doesn't have any dependencies). You can then start your app with this command:\n\n```sh\nnode build\n```\n\nDevelopment dependencies will be bundled into your app using [Rollup](https://rollupjs.org). To control whether a given package is bundled or externalised, place it in `devDependencies` or `dependencies` respectively in your `package.json`.\n\n### Compressing responses\n\nYou will typically want to compress responses coming from the server. If you're already deploying your server behind a reverse proxy for SSL or load balancing, it typically results in better performance to also handle compression at that layer since Node.js is single-threaded.\n\nHowever, if you're building a [custom server](#Custom-server) and do want to add a compression middleware there, note that we would recommend using [`@polka/compression`](https://www.npmjs.com/package/@polka/compression) since SvelteKit streams responses and the more popular `compression` package does not support streaming and may cause errors when used.\n\n## Environment variables\n\nIn `dev` and `preview`, SvelteKit will read environment variables from your `.env` file (or `.env.local`, or `.env.[mode]`, [as determined by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files).)\n\nIn production, `.env` files are _not_ automatically loaded. To do so, install `dotenv` in your project...\n\n```sh\nnpm install dotenv\n```\n\n...and invoke it before running the built app:\n\n```sh\nnode +++-r dotenv/config+++ build\n```\n\nIf you use Node.js v20.6+, you can use the [`--env-file`](https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs) flag instead:\n\n```sh\nnode +++--env-file=.env+++ build\n```\n\n### `PORT`, `HOST` and `SOCKET_PATH`\n\nBy default, the server will accept connections on `0.0.0.0` using port 3000. These can be customised with the `PORT` and `HOST` environment variables:\n\n```sh\nHOST=127.0.0.1 PORT=4000 node build\n```\n\nAlternatively, the server can be configured to accept connections on a specified socket path. When this is done using the `SOCKET_PATH` environment variable, the `HOST` and `PORT` environment variables will be disregarded.\n\n```sh\nSOCKET_PATH=/tmp/socket node build\n```\n\n### `ORIGIN`, `PROTOCOL_HEADER`, `HOST_HEADER`, and `PORT_HEADER`\n\nHTTP doesn't give SvelteKit a reliable way to know the URL that is currently being requested. The simplest way to tell SvelteKit where the app is being served is to set the `ORIGIN` environment variable:\n\n```sh\nORIGIN=https://my.site node build\n\n# or e.g. for local previewing and testing\nORIGIN=http://localhost:3000 node build\n```\n\nWith this, a request for the `/stuff` pathname will correctly resolve to `https://my.site/stuff`. Alternatively, you can specify headers that tell SvelteKit about the request protocol and host, from which it can construct the origin URL:\n\n```sh\nPROTOCOL_HEADER=x-forwarded-proto HOST_HEADER=x-forwarded-host node build\n```\n\n> [!NOTE] [`x-forwarded-proto`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto) and [`x-forwarded-host`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host) are de facto standard headers that forward the original protocol and host if you're using a reverse proxy (think load balancers and CDNs). You should only set these variables if your server is behind a trusted reverse proxy; otherwise, it'd be possible for clients to spoof these headers.\n>\n> If you're hosting your proxy on a non-standard port and your reverse proxy supports `x-forwarded-port`, you can also set `PORT_HEADER=x-forwarded-port`.\n\nIf `adapter-node` can't correctly determine the URL of your deployment, you may experience this error when using [form actions](form-actions):\n\n> [!NOTE] Cross-site POST form submissions are forbidden\n\n### `ADDRESS_HEADER` and `XFF_DEPTH`\n\nThe [`RequestEvent`](@sveltejs-kit#RequestEvent) object passed to hooks and endpoints includes an `event.getClientAddress()` function that returns the client's IP address. By default this is the connecting `remoteAddress`. If your server is behind one or more proxies (such as a load balancer), this value will contain the innermost proxy's IP address rather than the client's, so we need to specify an `ADDRESS_HEADER` to read the address from:\n\n```sh\nADDRESS_HEADER=True-Client-IP node build\n```\n\n> [!NOTE] Headers can easily be spoofed. As with `PROTOCOL_HEADER` and `HOST_HEADER`, you should [know what you're doing](https://adam-p.ca/blog/2022/03/x-forwarded-for/) before setting these.\n\nIf the `ADDRESS_HEADER` is `X-Forwarded-For`, the header value will contain a comma-separated list of IP addresses. The `XFF_DEPTH` environment variable should specify how many trusted proxies sit in front of your server. E.g. if there are three trusted proxies, proxy 3 will forward the addresses of the original connection and the first two proxies:\n\n```\n<client address>, <proxy 1 address>, <proxy 2 address>\n```\n\nSome guides will tell you to read the left-most address, but this leaves you [vulnerable to spoofing](https://adam-p.ca/blog/2022/03/x-forwarded-for/):\n\n```\n<spoofed address>, <client address>, <proxy 1 address>, <proxy 2 address>\n```\n\nWe instead read from the _right_, accounting for the number of trusted proxies. In this case, we would use `XFF_DEPTH=3`.\n\n> [!NOTE] If you need to read the left-most address instead (and don't care about spoofing) — for example, to offer a geolocation service, where it's more important for the IP address to be _real_ than _trusted_, you can do so by inspecting the `x-forwarded-for` header within your app.\n\n### `BODY_SIZE_LIMIT`\n\nThe maximum request body size to accept in bytes including while streaming. The body size can also be specified with a unit suffix for kilobytes (`K`), megabytes (`M`), or gigabytes (`G`). For example, `512K` or `1M`. Defaults to 512kb. You can disable this option with a value of `Infinity` (0 in older versions of the adapter) and implement a custom check in [`handle`](hooks#Server-hooks-handle) if you need something more advanced.\n\n### `SHUTDOWN_TIMEOUT`\n\nThe number of seconds to wait before forcefully closing any remaining connections after receiving a `SIGTERM` or `SIGINT` signal. Defaults to `30`. Internally the adapter calls [`closeAllConnections`](https://nodejs.org/api/http.html#servercloseallconnections). See [Graceful shutdown](#Graceful-shutdown) for more details.\n\n### `IDLE_TIMEOUT`\n\nWhen using systemd socket activation, `IDLE_TIMEOUT` specifies the number of seconds after which the app is automatically put to sleep when receiving no requests. If not set, the app runs continuously. See [Socket activation](#Socket-activation) for more details.\n\n### `KEEP_ALIVE_TIMEOUT` and `HEADERS_TIMEOUT`\n\nThe number of seconds for [`keepAliveTimeout`](https://nodejs.org/api/http.html#serverkeepalivetimeout) and [`headersTimeout`](https://nodejs.org/api/http.html#serverheaderstimeout).\n\n## Options\n\nThe adapter can be configured with various options:\n\n```js\n// @errors: 2307\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-node';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\t// default options are shown\n\t\t\tout: 'build',\n\t\t\tprecompress: true,\n\t\t\tenvPrefix: ''\n\t\t})\n\t}\n};\n\nexport default config;\n```\n\n### out\n\nThe directory to build the server to. It defaults to `build` — i.e. `node build` would start the server locally after it has been created.\n\n### precompress\n\nEnables precompressing using gzip and brotli for assets and prerendered pages. It defaults to `true`.\n\n### envPrefix\n\nIf you need to change the name of the environment variables used to configure the deployment (for example, to deconflict with environment variables you don't control), you can specify a prefix:\n\n```js\nenvPrefix: 'MY_CUSTOM_';\n```\n\n```sh\nMY_CUSTOM_HOST=127.0.0.1 \\\nMY_CUSTOM_PORT=4000 \\\nMY_CUSTOM_ORIGIN=https://my.site \\\nnode build\n```\n\n## Graceful shutdown\n\nBy default `adapter-node` gracefully shuts down the HTTP server when a `SIGTERM` or `SIGINT` signal is received. It will:\n\n1. reject new requests ([`server.close`](https://nodejs.org/api/http.html#serverclosecallback))\n2. wait for requests that have already been made but not received a response yet to finish and close connections once they become idle ([`server.closeIdleConnections`](https://nodejs.org/api/http.html#servercloseidleconnections))\n3. and finally, close any remaining connections that are still active after [`SHUTDOWN_TIMEOUT`](#Environment-variables-SHUTDOWN_TIMEOUT) seconds. ([`server.closeAllConnections`](https://nodejs.org/api/http.html#servercloseallconnections))\n\n> [!NOTE] If you want to customize this behaviour you can use a [custom server](#Custom-server).\n\nYou can listen to the `sveltekit:shutdown` event which is emitted after the HTTP server has closed all connections. Unlike Node's `exit` event, the `sveltekit:shutdown` event supports asynchronous operations and is always emitted when all connections are closed even if the server has dangling work such as open database connections.\n\n```js\n// @errors: 2304\nprocess.on('sveltekit:shutdown', async (reason) => {\n  await jobs.stop();\n  await db.close();\n});\n```\n\nThe parameter `reason` has one of the following values:\n\n- `SIGINT` - shutdown was triggered by a `SIGINT` signal\n- `SIGTERM` - shutdown was triggered by a `SIGTERM` signal\n- `IDLE` - shutdown was triggered by [`IDLE_TIMEOUT`](#Environment-variables-IDLE_TIMEOUT)\n\n## Socket activation\n\nMost Linux operating systems today use a modern process manager called systemd to start the server and run and manage services. You can configure your server to allocate a socket and start and scale your app on demand. This is called [socket activation](https://0pointer.de/blog/projects/socket-activated-containers.html). In this case, the OS will pass two environment variables to your app — `LISTEN_PID` and `LISTEN_FDS`. The adapter will then listen on file descriptor 3 which refers to a systemd socket unit that you will have to create.\n\n> [!NOTE] You can still use [`envPrefix`](#Options-envPrefix) with systemd socket activation. `LISTEN_PID` and `LISTEN_FDS` are always read without a prefix.\n\nTo take advantage of socket activation follow these steps.\n\n1. Run your app as a [systemd service](https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html). It can either run directly on the host system or inside a container (using Docker or a systemd portable service for example). If you additionally pass an [`IDLE_TIMEOUT`](#Environment-variables-IDLE_TIMEOUT) environment variable to your app it will gracefully shutdown if there are no requests for `IDLE_TIMEOUT` seconds. systemd will automatically start your app again when new requests are coming in.\n\n```ini\n/// file: /etc/systemd/system/myapp.service\n[Service]\nEnvironment=NODE_ENV=production IDLE_TIMEOUT=60\nExecStart=/usr/bin/node /usr/bin/myapp/build\n```\n\n2. Create an accompanying [socket unit](https://www.freedesktop.org/software/systemd/man/latest/systemd.socket.html). The adapter only accepts a single socket.\n\n```ini\n/// file: /etc/systemd/system/myapp.socket\n[Socket]\nListenStream=3000\n\n[Install]\nWantedBy=sockets.target\n```\n\n3. Make sure systemd has recognised both units by running `sudo systemctl daemon-reload`. Then enable the socket on boot and start it immediately using `sudo systemctl enable --now myapp.socket`. The app will then automatically start once the first request is made to `localhost:3000`.\n\n## Custom server\n\nThe adapter creates two files in your build directory — `index.js` and `handler.js`. Running `index.js` — e.g. `node build`, if you use the default build directory — will start a server on the configured port.\n\nAlternatively, you can import the `handler.js` file, which exports a handler suitable for use with [Express](https://github.com/expressjs/express), [Connect](https://github.com/senchalabs/connect) or [Polka](https://github.com/lukeed/polka) (or even just the built-in [`http.createServer`](https://nodejs.org/dist/latest/docs/api/http.html#httpcreateserveroptions-requestlistener)) and set up your own server:\n\n```js\n// @errors: 2307 7006\n/// file: my-server.js\nimport { handler } from './build/handler.js';\nimport express from 'express';\n\nconst app = express();\n\n// add a route that lives separately from the SvelteKit app\napp.get('/healthcheck', (req, res) => {\n\tres.end('ok');\n});\n\n// let SvelteKit handle everything else, including serving prerendered pages and static assets\napp.use(handler);\n\napp.listen(3000, () => {\n\tconsole.log('listening on port 3000');\n});\n```\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/50-adapter-static.md",
    "content": "---\ntitle: Static site generation\n---\n\nTo use SvelteKit as a static site generator (SSG), use [`adapter-static`](https://github.com/sveltejs/kit/tree/main/packages/adapter-static).\n\nThis will prerender your entire site as a collection of static files. If you'd like to prerender only some pages and dynamically server-render others, you will need to use a different adapter together with [the `prerender` option](page-options#prerender).\n\n## Usage\n\nInstall with `npm i -D @sveltejs/adapter-static`, then add the adapter to your `svelte.config.js`:\n\n```js\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-static';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\t// default options are shown. On some platforms\n\t\t\t// these options are set automatically — see below\n\t\t\tpages: 'build',\n\t\t\tassets: 'build',\n\t\t\tfallback: undefined,\n\t\t\tprecompress: false,\n\t\t\tstrict: true\n\t\t})\n\t}\n};\n\nexport default config;\n```\n\n...and add the [`prerender`](page-options#prerender) option to your root layout:\n\n```js\n/// file: src/routes/+layout.js\n// If you're using a fallback (i.e. SPA mode) you don't need to prerender all\n// pages by setting this here, but should prerender as many as possible to\n// avoid large performance and SEO impacts\nexport const prerender = true;\n```\n\n> [!NOTE] You must ensure SvelteKit's [`trailingSlash`](page-options#trailingSlash) option is set appropriately for your environment. If your host does not render `/a.html` upon receiving a request for `/a` then you will need to set `trailingSlash: 'always'` in your root layout to create `/a/index.html` instead.\n\n> [!NOTE] You must ensure SvelteKit's [`ssr`](page-options#ssr) option isn't set to `false`. Otherwise, prerendering will save an empty 'shell' page instead of the fully rendered content.\n\n## Zero-config support\n\nSome platforms have zero-config support (more to come in future):\n\n- [Vercel](https://vercel.com)\n\nOn these platforms, you should omit the adapter options so that `adapter-static` can provide the optimal configuration:\n\n```js\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-static';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter(---{...}---)\n\t}\n};\n\nexport default config;\n```\n\n## Options\n\n### pages\n\nThe directory to write prerendered pages to. It defaults to `build`.\n\n### assets\n\nThe directory to write static assets (the contents of `static`, plus client-side JS and CSS generated by SvelteKit) to. Ordinarily this should be the same as `pages`, and it will default to whatever the value of `pages` is, but in rare circumstances you might need to output pages and assets to separate locations.\n\n### fallback\n\nTo create a [single page app (SPA)](single-page-apps) you must specify the name of the fallback page to be generated by SvelteKit, which is used as the entry point for URLs that have not been prerendered. This is commonly `200.html`, but can vary depending on your deployment platform. You should avoid `index.html` where possible to avoid conflicting with a prerendered homepage. \n\n> This option has large negative performance and SEO impacts. It is only recommended in certain circumstances such as wrapping the site in a mobile app. See the [single page apps](single-page-apps) documentation for more details and alternatives.\n\n### precompress\n\nIf `true`, precompresses files with brotli and gzip. This will generate `.br` and `.gz` files.\n\n### strict\n\nBy default, `adapter-static` checks that either all pages and endpoints (if any) of your app were prerendered, or you have the `fallback` option set. This check exists to prevent you from accidentally publishing an app where some parts of it are not accessible, because they are not contained in the final output. If you know this is ok (for example when a certain page only exists conditionally), you can set `strict` to `false` to turn off this check.\n\n## GitHub Pages\n\nWhen building for [GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages), if your repo name is not equivalent to `your-username.github.io`, make sure to update [`config.kit.paths.base`](configuration#paths) to match your repo name. This is because the site will be served from `https://your-username.github.io/your-repo-name` rather than from the root.\n\nYou'll also want to generate a fallback `404.html` page to replace the default 404 page shown by GitHub Pages.\n\nA config for GitHub Pages might look like the following:\n\n```js\n// @errors: 2322\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-static';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\tfallback: '404.html'\n\t\t}),\n\t\tpaths: {\n\t\t\tbase: process.argv.includes('dev') ? '' : process.env.BASE_PATH\n\t\t}\n\t}\n};\n\nexport default config;\n```\n\nYou can use GitHub actions to automatically deploy your site to GitHub Pages when you make a change. Here's an example workflow:\n\n```yaml\n### file: .github/workflows/deploy.yml\nname: Deploy to GitHub Pages\n\non:\n  push:\n    branches: 'main'\n\njobs:\n  build_site:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v4\n\n      # If you're using pnpm, add this step then change the commands and cache key below to use `pnpm`\n      # - name: Install pnpm\n      #   uses: pnpm/action-setup@v3\n      #   with:\n      #     version: 8\n\n      - name: Install Node.js\n        uses: actions/setup-node@v4\n        with:\n          node-version: 20\n          cache: npm\n\n      - name: Install dependencies\n        run: npm i\n\n      - name: build\n        env:\n          BASE_PATH: '/${{ github.event.repository.name }}'\n        run: |\n          npm run build\n\n      - name: Upload Artifacts\n        uses: actions/upload-pages-artifact@v3\n        with:\n          # this should match the `pages` option in your adapter-static options\n          path: 'build/'\n\n  deploy:\n    needs: build_site\n    runs-on: ubuntu-latest\n\n    permissions:\n      pages: write\n      id-token: write\n\n    environment:\n      name: github-pages\n      url: ${{ steps.deployment.outputs.page_url }}\n\n    steps:\n      - name: Deploy\n        id: deployment\n        uses: actions/deploy-pages@v4\n```\n\nIf you're not using GitHub actions to deploy your site (for example, you're pushing the built site to its own repo), add an empty `.nojekyll` file in your `static` directory to prevent Jekyll from interfering.\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/55-single-page-apps.md",
    "content": "---\ntitle: Single-page apps\n---\n\nYou can turn a SvelteKit app into a fully client-rendered single-page app (SPA) by specifying a _fallback page_. This page will be served for any URLs that can't be served by other means such as returning a prerendered page.\n\n> [!NOTE] SPA mode has a large negative performance impact by forcing multiple network round trips (for the blank HTML document, then for the JavaScript, and then for any data needed for the page) before content can be shown. Unless you are serving the app from a local network (e.g. a mobile app that wraps a locally-served SPA) this will delay startup, especially when considering the latency of mobile devices. It also harms SEO by often causing sites to be downranked for performance (SPAs are much more likely to fail [Core Web Vitals](https://web.dev/explore/learn-core-web-vitals)), excluding search engines that don't render JS, and causing your site to receive less frequent updates from those that do. And finally, it makes your app inaccessible to users if JavaScript fails or is disabled (which happens [more often than you probably think](https://kryogenix.org/code/browser/everyonehasjs.html)).\n>\n> You can avoid these drawbacks by [prerendering](#Prerendering-individual-pages) as many pages as possible when using SPA mode (especially your homepage). If you can prerender all pages, you can simply use [static site generation](adapter-static) rather than a SPA. Otherwise, you should strongly consider using an adapter which supports server side rendering. SvelteKit has officially supported adapters for various providers with generous free tiers.\n\n## Usage\n\nFirst, disable SSR for the pages you don't want to prerender. These pages will be served via the fallback page; for example, to serve all pages via the fallback by default, you can update the root layout as shown below. You should [opt back into prerendering individual pages and directories](#Prerendering-individual-pages) where possible.\n```js\n/// file: src/routes/+layout.js\nexport const ssr = false;\n```\n\nIf you don't have any server-side logic (i.e. `+page.server.js`, `+layout.server.js` or `+server.js` files) you can use [`adapter-static`](adapter-static) to create your SPA. Install `adapter-static` with `npm i -D @sveltejs/adapter-static` and add it to your `svelte.config.js` with the `fallback` option:\n\n```js\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-static';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\tfallback: '200.html' // may differ from host to host\n\t\t})\n\t}\n};\n\nexport default config;\n```\n\nThe `fallback` page is an HTML page created by SvelteKit from your page template (e.g. `app.html`) that loads your app and navigates to the correct route. For example [Surge](https://surge.sh/help/adding-a-200-page-for-client-side-routing), a static web host, lets you add a `200.html` file that will handle any requests that don't correspond to static assets or prerendered pages.\n\nOn some hosts it may be something else entirely — consult your platform's documentation. We recommend avoiding `index.html` if possible as it may conflict with prerendering.\n\n> [!NOTE] Note that the fallback page will always contain absolute asset paths (i.e. beginning with `/` rather than `.`) regardless of the value of [`paths.relative`](configuration#paths), since it is used to respond to requests for arbitrary paths.\n\n## Prerendering individual pages\n\nIf you want certain pages to be prerendered, you can re-enable `ssr` alongside `prerender` for just those parts of your app:\n\n```js\n/// file: src/routes/my-prerendered-page/+page.js\nexport const prerender = true;\nexport const ssr = true;\n```\n\nYou won't need a Node server or server capable of running JavaScript to deploy this page. It will only server render your page while building your project for the purposes of outputting an `.html` page that can be served from any static web host.\n\n## Apache\n\nTo run an SPA on [Apache](https://httpd.apache.org/), you should add a `static/.htaccess` file to route requests to the fallback page:\n\n```\n<IfModule mod_rewrite.c>\n\tRewriteEngine On\n\tRewriteBase /\n\tRewriteRule ^200\\.html$ - [L]\n\tRewriteCond %{REQUEST_FILENAME} !-f\n\tRewriteCond %{REQUEST_FILENAME} !-d\n\tRewriteRule . /200.html [L]\n</IfModule>\n```\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/60-adapter-cloudflare.md",
    "content": "---\ntitle: Cloudflare\n---\n\nTo deploy to [Cloudflare Workers](https://workers.cloudflare.com/) or [Cloudflare Pages](https://pages.cloudflare.com/), use [`adapter-cloudflare`](https://github.com/sveltejs/kit/tree/main/packages/adapter-cloudflare).\n\nThis adapter will be installed by default when you use [`adapter-auto`](adapter-auto). If you plan on staying with Cloudflare, you can switch from [`adapter-auto`](adapter-auto) to using this adapter directly so that `event.platform` is emulated during local development, type declarations are automatically applied, and the ability to set Cloudflare-specific options is provided.\n\n## Comparisons\n\n- `adapter-cloudflare` – supports all SvelteKit features; builds for Cloudflare Workers Static Assets and Cloudflare Pages\n- `adapter-cloudflare-workers` – deprecated. Supports all SvelteKit features; builds for Cloudflare Workers Sites\n- `adapter-static` – only produces client-side static assets; compatible with Cloudflare Workers Static Assets and Cloudflare Pages\n\n## Usage\n\nInstall with `npm i -D @sveltejs/adapter-cloudflare`, then add the adapter to your `svelte.config.js`:\n\n```js\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-cloudflare';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\t// See below for an explanation of these options\n\t\t\tconfig: undefined,\n\t\t\tplatformProxy: {\n\t\t\t\tconfigPath: undefined,\n\t\t\t\tenvironment: undefined,\n\t\t\t\tpersist: undefined\n\t\t\t},\n\t\t\tfallback: 'plaintext',\n\t\t\troutes: {\n\t\t\t\tinclude: ['/*'],\n\t\t\t\texclude: ['<all>']\n\t\t\t}\n\t\t})\n\t}\n};\n\nexport default config;\n```\n\n## Options\n\n### config\n\nPath to your [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/configuration/). If you would like to use a Wrangler configuration filename other than `wrangler.jsonc`, `wrangler.json`, or `wrangler.toml` you can specify it using this option.\n\n### platformProxy\n\nPreferences for the emulated `platform.env` local bindings. See the [getPlatformProxy](https://developers.cloudflare.com/workers/wrangler/api/#parameters-1) Wrangler API documentation for a full list of options.\n\n### fallback\n\nWhether to render a plaintext 404.html page or a rendered SPA fallback page for non-matching asset requests.\n\nFor Cloudflare Workers, the default behaviour is to return a null-body 404-status response for non-matching assets requests. However, if the [`assets.not_found_handling`](https://developers.cloudflare.com/workers/static-assets/routing/#2-not_found_handling) Wrangler configuration setting is set to `\"404-page\"`, this page will be served if a request fails to match an asset. If `assets.not_found_handling` is set to `\"single-page-application\"`, the adapter will render a SPA fallback `index.html` page regardless of the `fallback` option specified.\n\nFor Cloudflare Pages, this page will only be served when a request that matches an entry in `routes.exclude` fails to match an asset.\n\nMost of the time `plaintext` is sufficient, but if you are using `routes.exclude` to manually exclude a set of prerendered pages without exceeding the 100 route limit, you may wish to use `spa` instead to avoid showing an unstyled 404 page to users.\n\nSee Cloudflare Pages' [Not Found behaviour](https://developers.cloudflare.com/pages/configuration/serving-pages/#not-found-behavior) for more info.\n\n### routes\n\nOnly for Cloudflare Pages. Allows you to customise the [`_routes.json`](https://developers.cloudflare.com/pages/functions/routing/#create-a-_routesjson-file) file generated by `adapter-cloudflare`.\n\n- `include` defines routes that will invoke a function, and defaults to `['/*']`\n- `exclude` defines routes that will _not_ invoke a function — this is a faster and cheaper way to serve your app's static assets. This array can include the following special values:\n\t- `<build>` contains your app's build artifacts (the files generated by Vite)\n\t- `<files>` contains the contents of your `static` directory\n\t- `<redirects>` contains a list of pathnames from your [`_redirects` file](https://developers.cloudflare.com/pages/configuration/redirects/) at the root\n\t- `<prerendered>` contains a list of prerendered pages\n\t- `<all>` (the default) contains all of the above\n\nYou can have up to 100 `include` and `exclude` rules combined. Generally you can omit the `routes` options, but if (for example) your `<prerendered>` paths exceed that limit, you may find it helpful to manually create an `exclude` list that includes `'/articles/*'` instead of the auto-generated `['/articles/foo', '/articles/bar', '/articles/baz', ...]`.\n\n## Cloudflare Workers\n\n### Basic configuration\n\nWhen building for Cloudflare Workers, this adapter expects to find a [Wrangler configuration file](https://developers.cloudflare.com/workers/configuration/sites/configuration/) in the project root. It should look something like this:\n\n```jsonc\n/// file: wrangler.jsonc\n{\n\t\"name\": \"<any-name-you-want>\",\n\t\"main\": \".svelte-kit/cloudflare/_worker.js\",\n\t\"compatibility_flags\": [\"nodejs_als\"],\n\t\"compatibility_date\": \"<YYYY-MM-DD>\",\n\t\"assets\": {\n\t\t\"binding\": \"ASSETS\",\n\t\t\"directory\": \".svelte-kit/cloudflare\",\n\t}\n}\n```\n\n### Deployment\n\nYou can use the Wrangler CLI to deploy your application by running `npx wrangler deploy` or use the [Cloudflare Git integration](https://developers.cloudflare.com/workers/ci-cd/builds/) to enable automatic builds and deployments on push.\n\n## Cloudflare Pages\n\n### Deployment\n\nPlease follow the [Get Started Guide](https://developers.cloudflare.com/pages/get-started/) for Cloudflare Pages to begin.\n\nIf you're using the [Git integration](https://developers.cloudflare.com/pages/get-started/git-integration/), your build settings should look like this:\n\n- Framework preset – SvelteKit\n- Build command – `npm run build` or `vite build`\n- Build output directory – `.svelte-kit/cloudflare`\n\n\nOnce configured, go to the **Runtime** section of your project settings, and add the `nodejs_als` compatibility flag to enable the [Node.js AsyncLocalStorage](https://developers.cloudflare.com/workers/configuration/compatibility-flags/#nodejs-asynclocalstorage). Alternatively, do this in your wrangler config using the `compatibility_flags` array.\n\n### Further reading\n\nYou may wish to refer to [Cloudflare's documentation for deploying a SvelteKit site on Cloudflare Pages](https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-kit-site/).\n\n### Notes\n\nFunctions contained in the [`/functions` directory](https://developers.cloudflare.com/pages/functions/routing/) at the project's root will _not_ be included in the deployment. Instead, functions should be implemented as [server endpoints](routing#server) in your SvelteKit app, which is compiled to a [single `_worker.js` file](https://developers.cloudflare.com/pages/functions/advanced-mode/).\n\n## Runtime APIs\n\nThe [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object contains your project's [bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/), which consist of KV/DO namespaces, etc. It is passed to SvelteKit via the `platform` property, along with [`ctx`](https://developers.cloudflare.com/workers/runtime-apis/context/), [`caches`](https://developers.cloudflare.com/workers/runtime-apis/cache/), and [`cf`](https://developers.cloudflare.com/workers/runtime-apis/request/#incomingrequestcfproperties), meaning that you can access it in hooks and endpoints:\n\n```js\n// @filename: ambient.d.ts\nimport { DurableObjectNamespace } from '@cloudflare/workers-types';\n\ndeclare global {\n\tnamespace App {\n\t\tinterface Platform {\n\t\t\tenv: {\n\t\t\t\tYOUR_DURABLE_OBJECT_NAMESPACE: DurableObjectNamespace;\n\t\t\t};\n\t\t}\n\t}\n}\n// @filename: +server.js\n// ---cut---\n// @errors: 2355 2322\n/// file: +server.js\n/** @type {import('./$types').RequestHandler} */\nexport async function POST({ request, platform }) {\n\tconst x = platform?.env.YOUR_DURABLE_OBJECT_NAMESPACE.idFromName('x');\n}\n```\n\n> [!NOTE] SvelteKit's built-in [`$env` module]($env-static-private) should be preferred for environment variables.\n\nTo make these types available to your app, install [`@cloudflare/workers-types`](https://www.npmjs.com/package/@cloudflare/workers-types) and reference them in your `src/app.d.ts`:\n\n```ts\n/// file: src/app.d.ts\n+++import { KVNamespace, DurableObjectNamespace } from '@cloudflare/workers-types';+++\n\ndeclare global {\n\tnamespace App {\n\t\tinterface Platform {\n+++\t\t\tenv: {\n\t\t\t\tYOUR_KV_NAMESPACE: KVNamespace;\n\t\t\t\tYOUR_DURABLE_OBJECT_NAMESPACE: DurableObjectNamespace;\n\t\t\t};+++\n\t\t}\n\t}\n}\n\nexport {};\n```\n\n### Testing locally\n\nCloudflare specific values in the `platform` property are emulated during dev and preview modes. Local [bindings](https://developers.cloudflare.com/workers/wrangler/configuration/#bindings) are created based on your [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/) and are used to populate `platform.env` during development and preview. Use the adapter config [`platformProxy` option](#Options-platformProxy) to change your preferences for the bindings.\n\nFor testing the build, you should use [Wrangler](https://developers.cloudflare.com/workers/wrangler/) version 4. Once you have built your site, run `wrangler dev .svelte-kit/cloudflare/_worker.js` if you're testing for Cloudflare Workers or `wrangler pages dev .svelte-kit/cloudflare` for Cloudflare Pages.\n\n## Headers and redirects\n\nThe [`_headers`](https://developers.cloudflare.com/pages/configuration/headers/) and [`_redirects`](https://developers.cloudflare.com/pages/configuration/redirects/) files, specific to Cloudflare, can be used for static asset responses (like images) by putting them into the project root folder.\n\nHowever, they will have no effect on responses dynamically rendered by SvelteKit, which should return custom headers or redirect responses from [server endpoints](routing#server) or with the [`handle`](hooks#Server-hooks-handle) hook.\n\n## Troubleshooting\n\n### Node.js compatibility\n\nIf you would like to enable [Node.js compatibility](https://developers.cloudflare.com/workers/runtime-apis/nodejs/), you can add the `nodejs_compat` compatibility flag to your Wrangler configuration file:\n\n```jsonc\n/// file: wrangler.jsonc\n{\n\t\"compatibility_flags\": [\"nodejs_compat\"]\n}\n```\n\n### Worker size limits\n\nWhen deploying your application, the server generated by SvelteKit is bundled into a single file. Wrangler will fail to publish your worker if it exceeds [the size limits](https://developers.cloudflare.com/workers/platform/limits/#worker-size) after minification. You're unlikely to hit this limit usually, but some large libraries can cause this to happen. In that case, you can try to reduce the size of your worker by only importing such libraries on the client side. See [the FAQ](./faq#How-do-I-use-a-client-side-library-accessing-document-or-window) for more information.\n\n### Accessing the file system\n\nYou can't use `fs` in Cloudflare Workers.\n\nInstead, use the [`read`]($app-server#read) function from `$app/server` to access your files. It works by fetching the file from the deployed public assets location.\n\nAlternatively, you can [prerender](page-options#prerender) the routes in question.\n\n## Migrating from Workers Sites\n\nCloudflare no longer recommends using [Workers Sites](https://developers.cloudflare.com/workers/configuration/sites/configuration/) and instead recommends using [Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/). To migrate, replace `@sveltejs/adapter-cloudflare-workers` with `@sveltejs/adapter-cloudflare` and remove all `site` configuration settings from your Wrangler configuration file, then add the `assets.directory` and `assets.binding` configuration settings:\n\n### svelte.config.js\n\n```js\n// @errors: 2307\n/// file: svelte.config.js\n---import adapter from '@sveltejs/adapter-cloudflare-workers';---\n+++import adapter from '@sveltejs/adapter-cloudflare';+++\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n```\n\n### wrangler.toml\n\n```toml\n/// file: wrangler.toml\n---site.bucket = \".cloudflare/public\"---\n+++assets.directory = \".cloudflare/public\"\nassets.binding = \"ASSETS\" # Exclude this if you don't have a `main` key configured.+++\n```\n\n### wrangler.jsonc\n\n```jsonc\n/// file: wrangler.jsonc\n{\n---\t\"site\": {\n\t\t\"bucket\": \".cloudflare/public\"\n\t},---\n+++\t\"assets\": {\n\t\t\"directory\": \".cloudflare/public\",\n\t\t\"binding\": \"ASSETS\" // Exclude this if you don't have a `main` key configured.\n\t}+++\n}\n```\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/70-adapter-cloudflare-workers.md",
    "content": "---\ntitle: Cloudflare Workers\n---\n\n> [!NOTE] `adapter-cloudflare-workers` has been deprecated in favour of [`adapter-cloudflare`](adapter-cloudflare). We recommend using `adapter-cloudflare` to deploy to Cloudflare Workers with [Static Assets](https://developers.cloudflare.com/workers/static-assets/) since Cloudflare Workers Sites will be deprecated in favour of it.\n\nTo deploy to [Cloudflare Workers](https://workers.cloudflare.com/) with [Workers Sites](https://developers.cloudflare.com/workers/configuration/sites/), use `adapter-cloudflare-workers`.\n\n## Usage\n\nInstall with `npm i -D @sveltejs/adapter-cloudflare-workers`, then add the adapter to your `svelte.config.js`:\n\n```js\n// @errors: 2307\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-cloudflare-workers';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\t// see below for options that can be set here\n\t\t})\n\t}\n};\n\nexport default config;\n```\n\n## Options\n\n### config\n\nPath to your [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/configuration/). If you would like to use a Wrangler configuration filename other than `wrangler.jsonc`, `wrangler.json`, or `wrangler.toml` you can specify it using this option.\n\n### platformProxy\n\nPreferences for the emulated `platform.env` local bindings. See the [getPlatformProxy](https://developers.cloudflare.com/workers/wrangler/api/#parameters-1) Wrangler API documentation for a full list of options.\n\n## Basic Configuration\n\nThis adapter expects to find a [Wrangler configuration file](https://developers.cloudflare.com/workers/configuration/sites/configuration/) in the project root. It should look something like this:\n\n```jsonc\n/// file: wrangler.jsonc\n{\n\t\"name\": \"<your-service-name>\",\n\t\"account_id\": \"<your-account-id>\",\n\t\"main\": \"./.cloudflare/worker.js\",\n\t\"site\": {\n\t\t\"bucket\": \"./.cloudflare/public\"\n\t},\n\t\"build\": {\n\t\t\"command\": \"npm run build\"\n\t},\n\t\"compatibility_date\": \"2021-11-12\"\n}\n```\n\n`<your-service-name>` can be anything. `<your-account-id>` can be found by running `wrangler whoami` using the Wrangler CLI tool or by logging into your [Cloudflare dashboard](https://dash.cloudflare.com) and grabbing it from the end of the URL:\n\n```\nhttps://dash.cloudflare.com/<your-account-id>/home\n```\n\n> [!NOTE] You should add the `.cloudflare` directory (or whichever directories you specified for `main` and `site.bucket`) and the `.wrangler` directory to your `.gitignore`.\n\nYou will need to install [Wrangler](https://developers.cloudflare.com/workers/wrangler/install-and-update/) and log in, if you haven't already:\n\n```sh\nnpm i -D wrangler\nwrangler login\n```\n\nThen, you can build your app and deploy it:\n\n```sh\nwrangler deploy\n```\n\n## Runtime APIs\n\nThe [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object contains your project's [bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/), which consist of KV/DO namespaces, etc. It is passed to SvelteKit via the `platform` property, along with [`ctx`](https://developers.cloudflare.com/workers/runtime-apis/context/), [`caches`](https://developers.cloudflare.com/workers/runtime-apis/cache/), and [`cf`](https://developers.cloudflare.com/workers/runtime-apis/request/#incomingrequestcfproperties), meaning that you can access it in hooks and endpoints:\n\n```js\n// @filename: ambient.d.ts\nimport { DurableObjectNamespace } from '@cloudflare/workers-types';\n\ndeclare global {\n\tnamespace App {\n\t\tinterface Platform {\n\t\t\tenv: {\n\t\t\t\tYOUR_DURABLE_OBJECT_NAMESPACE: DurableObjectNamespace;\n\t\t\t};\n\t\t}\n\t}\n}\n// @filename: +server.js\n// ---cut---\n// @errors: 2355 2322\n/// file: +server.js\n/** @type {import('./$types').RequestHandler} */\nexport async function POST({ request, platform }) {\n\tconst x = platform?.env.YOUR_DURABLE_OBJECT_NAMESPACE.idFromName('x');\n}\n```\n\n> [!NOTE] SvelteKit's built-in [`$env` module]($env-static-private) should be preferred for environment variables.\n\nTo make these types available to your app, install [`@cloudflare/workers-types`](https://www.npmjs.com/package/@cloudflare/workers-types) and reference them in your `src/app.d.ts`:\n\n```ts\n/// file: src/app.d.ts\n+++import { KVNamespace, DurableObjectNamespace } from '@cloudflare/workers-types';+++\n\ndeclare global {\n\tnamespace App {\n\t\tinterface Platform {\n+++\t\t\tenv?: {\n\t\t\t\tYOUR_KV_NAMESPACE: KVNamespace;\n\t\t\t\tYOUR_DURABLE_OBJECT_NAMESPACE: DurableObjectNamespace;\n\t\t\t};+++\n\t\t}\n\t}\n}\n\nexport {};\n```\n\n### Testing Locally\n\nCloudflare Workers specific values in the `platform` property are emulated during dev and preview modes. Local [bindings](https://developers.cloudflare.com/workers/wrangler/configuration/#bindings) are created based on your [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/) and are used to populate `platform.env` during development and preview. Use the adapter config [`platformProxy` option](#Options-platformProxy) to change your preferences for the bindings.\n\nFor testing the build, you should use [Wrangler](https://developers.cloudflare.com/workers/wrangler/) version 4. Once you have built your site, run `wrangler dev`.\n\n## Troubleshooting\n\n### Node.js compatibility\n\nIf you would like to enable [Node.js compatibility](https://developers.cloudflare.com/workers/runtime-apis/nodejs/), you can add the `nodejs_compat` compatibility flag to your Wrangler configuration file:\n\n```jsonc\n/// file: wrangler.jsonc\n{\n\t\"compatibility_flags\": [\"nodejs_compat\"]\n}\n```\n\n### Worker size limits\n\nWhen deploying your application, the server generated by SvelteKit is bundled into a single file. Wrangler will fail to publish your worker if it exceeds [the size limits](https://developers.cloudflare.com/workers/platform/limits/#worker-size) after minification. You're unlikely to hit this limit usually, but some large libraries can cause this to happen. In that case, you can try to reduce the size of your worker by only importing such libraries on the client side. See [the FAQ](./faq#How-do-I-use-a-client-side-library-accessing-document-or-window) for more information.\n\n### Accessing the file system\n\nYou can't use `fs` in Cloudflare Workers — you must [prerender](page-options#prerender) the routes in question.\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/80-adapter-netlify.md",
    "content": "---\ntitle: Netlify\n---\n\nTo deploy to Netlify, use [`adapter-netlify`](https://github.com/sveltejs/kit/tree/main/packages/adapter-netlify).\n\nThis adapter will be installed by default when you use [`adapter-auto`](adapter-auto), but adding it to your project allows you to specify Netlify-specific options.\n\n## Usage\n\nInstall with `npm i -D @sveltejs/adapter-netlify`, then add the adapter to your `svelte.config.js`:\n\n```js\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-netlify';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\t// default options are shown\n\t\tadapter: adapter({\n\t\t\t// if true, will create a Netlify Edge Function rather\n\t\t\t// than using standard Node-based functions\n\t\t\tedge: false,\n\n\t\t\t// if true, will split your app into multiple functions\n\t\t\t// instead of creating a single one for the entire app.\n\t\t\t// if `edge` is true, this option cannot be used\n\t\t\tsplit: false\n\t\t})\n\t}\n};\n\nexport default config;\n```\n\nThen, make sure you have a [netlify.toml](https://docs.netlify.com/configure-builds/file-based-configuration) file in the project root. This will determine where to write static assets based on the `build.publish` settings, as per this sample configuration:\n\n```toml\n[build]\n\tcommand = \"npm run build\"\n\tpublish = \"build\"\n```\n\nIf the `netlify.toml` file or the `build.publish` value is missing, a default value of `\"build\"` will be used. Note that if you have set the publish directory in the Netlify UI to something else then you will need to set it in `netlify.toml` too, or use the default value of `\"build\"`.\n\n### Node version\n\nNew projects will use the current Node LTS version by default. However, if you're upgrading a project you created a while ago it may be stuck on an older version. See [the Netlify docs](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript) for details on manually specifying a current Node version.\n\n## Netlify Edge Functions\n\nSvelteKit supports [Netlify Edge Functions](https://docs.netlify.com/build/edge-functions/overview/). If you pass the option `edge: true` to the `adapter` function, server-side rendering will happen in a Deno-based edge function that's deployed close to the site visitor. If set to `false` (the default), the site will deploy to Node-based Netlify Functions.\n\n```js\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-netlify';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\t// will create a Netlify Edge Function using Deno-based\n\t\t\t// rather than using standard Node-based functions\n\t\t\tedge: true\n\t\t})\n\t}\n};\n\nexport default config;\n```\n\n## Netlify alternatives to SvelteKit functionality\n\nYou may build your app using functionality provided directly by SvelteKit without relying on any Netlify functionality. Using the SvelteKit versions of these features will allow them to be used in dev mode, tested with integration tests, and to work with other adapters should you ever decide to switch away from Netlify. However, in some scenarios you may find it beneficial to use the Netlify versions of these features. One example would be if you're migrating an app that's already hosted on Netlify to SvelteKit.\n\n### `_headers` and `_redirects`\n\nThe [`_headers`](https://docs.netlify.com/routing/headers/#syntax-for-the-headers-file) and [`_redirects`](https://docs.netlify.com/routing/redirects/redirect-options/) files specific to Netlify can be used for static asset responses (like images) by putting them into the project root folder. You can also use [`[[redirects]]`](https://docs.netlify.com/routing/redirects/#syntax-for-the-netlify-configuration-file) in your `netlify.toml`.\n\n### Netlify Forms\n\n1. Create your Netlify HTML form as described [here](https://docs.netlify.com/forms/setup/#html-forms), e.g. as `/routes/contact/+page.svelte`. (Don't forget to add the hidden `form-name` input element!)\n2. Netlify's build bot parses your HTML files at deploy time, which means your form must be [prerendered](page-options#prerender) as HTML. You can either add `export const prerender = true` to your `contact.svelte` to prerender just that page or set the `kit.prerender.force: true` option to prerender all pages.\n3. If your Netlify form has a [custom success message](https://docs.netlify.com/forms/setup/#success-messages) like `<form netlify ... action=\"/success\">` then ensure the corresponding `/routes/success/+page.svelte` exists and is prerendered.\n\n### Netlify Functions\n\nWith this adapter, SvelteKit endpoints are hosted as [Netlify Functions](https://docs.netlify.com/functions/overview/). Netlify function handlers have additional context, including [Netlify Identity](https://docs.netlify.com/visitor-access/identity/) information. You can access this context via the `event.platform.context` field inside your hooks and `+page.server` or `+layout.server` endpoints. These are [serverless functions](https://docs.netlify.com/functions/overview/) when the `edge` property is `false` in the adapter config or [edge functions](https://docs.netlify.com/edge-functions/overview/#app) when it is `true`.\n\n```js\n// @errors: 2339\n// @filename: ambient.d.ts\n/// <reference types=\"@sveltejs/adapter-netlify\" />\n// @filename: +page.server.js\n// ---cut---\n/// file: +page.server.js\n/** @type {import('./$types').PageServerLoad} */\nexport const load = async (event) => {\n\tconst context = event.platform?.context;\n\tconsole.log(context); // shows up in your functions log in the Netlify app\n};\n```\n\nAdditionally, you can add your own Netlify functions by creating a directory for them and adding the configuration to your `netlify.toml` file. For example:\n\n```toml\n[build]\n\tcommand = \"npm run build\"\n\tpublish = \"build\"\n\n[functions]\n\tdirectory = \"functions\"\n```\n\n## Troubleshooting\n\n### Accessing the file system\n\nYou can't use `fs` in edge deployments.\n\nYou _can_ use it in serverless deployments, but it won't work as expected, since files are not copied from your project into your deployment. Instead, use the [`read`]($app-server#read) function from `$app/server` to access your files. It also works inside edge deployments by fetching the file from the deployed public assets location.\n\nAlternatively, you can [prerender](page-options#prerender) the routes in question.\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/90-adapter-vercel.md",
    "content": "---\ntitle: Vercel\n---\n\nTo deploy to Vercel, use [`adapter-vercel`](https://github.com/sveltejs/kit/tree/main/packages/adapter-vercel).\n\nThis adapter will be installed by default when you use [`adapter-auto`](adapter-auto), but adding it to your project allows you to specify Vercel-specific options.\n\n## Usage\n\nInstall with `npm i -D @sveltejs/adapter-vercel`, then add the adapter to your `svelte.config.js`:\n\n```js\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-vercel';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\t// see below for options that can be set here\n\t\t})\n\t}\n};\n\nexport default config;\n```\n\n## Deployment configuration\n\nTo control how your routes are deployed to Vercel as functions, you can specify deployment configuration, either through the option shown above or with [`export const config`](page-options#config) inside `+server.js`, `+page(.server).js` and `+layout(.server).js` files.\n\nFor example you could deploy one specific route as an individual serverless function, separate from the rest of your app:\n\n```js\n/// file: about/+page.js\n/** @type {import('@sveltejs/adapter-vercel').Config} */\nexport const config = {\n\tsplit: true\n};\n```\n\nThe following options apply to all functions:\n\n- `runtime`: `'edge'`, `'nodejs20.x'` or `'nodejs22.x'`. By default, the adapter will select the `'nodejs<version>.x'` corresponding to the Node version your project is configured to use on the Vercel dashboard\n  > [!NOTE] This option is deprecated and will be removed in a future version, at which point all your functions will use whichever Node version is specified in the project configuration on Vercel\n- `regions`: an array of [edge network regions](https://vercel.com/docs/concepts/edge-network/regions) (defaulting to `[\"iad1\"]` for serverless functions) or `'all'` if `runtime` is `edge` (its default). Note that multiple regions for serverless functions are only supported on Enterprise plans\n- `split`: if `true`, causes a route to be deployed as an individual function. If `split` is set to `true` at the adapter level, all routes will be deployed as individual functions\n\nAdditionally, the following option applies to edge functions:\n- `external`: an array of dependencies that esbuild should treat as external when bundling functions. This should only be used to exclude optional dependencies that will not run outside Node\n\nAnd the following option apply to serverless functions:\n- `memory`: the amount of memory available to the function. Defaults to `1024` Mb, and can be decreased to `128` Mb or [increased](https://vercel.com/docs/concepts/limits/overview#serverless-function-memory) in 64Mb increments up to `3008` Mb on Pro or Enterprise accounts\n- `maxDuration`: [maximum execution duration](https://vercel.com/docs/functions/runtimes#max-duration) of the function. Defaults to `10` seconds for Hobby accounts, `15` for Pro and `900` for Enterprise\n- `isr`: configuration Incremental Static Regeneration, described below\n\nConfiguration set in a layout applies to all the routes beneath that layout, unless overridden at a more granular level.\n\nIf your functions need to access data in a specific region, it's recommended that they be deployed in the same region (or close to it) for optimal performance.\n\n## Image Optimization\n\nYou may set the `images` config to control how Vercel builds your images. See the [image configuration reference](https://vercel.com/docs/build-output-api/v3/configuration#images) for full details. As an example, you may set:\n\n```js\n/// file: svelte.config.js\nimport adapter from '@sveltejs/adapter-vercel';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\timages: {\n\t\t\t\tsizes: [640, 828, 1200, 1920, 3840],\n\t\t\t\tformats: ['image/avif', 'image/webp'],\n\t\t\t\tminimumCacheTTL: 300,\n\t\t\t\tdomains: ['example-app.vercel.app'],\n\t\t\t}\n\t\t})\n\t}\n};\n\nexport default config;\n```\n\n## Incremental Static Regeneration\n\nVercel supports [Incremental Static Regeneration](https://vercel.com/docs/incremental-static-regeneration) (ISR), which provides the performance and cost advantages of prerendered content with the flexibility of dynamically rendered content.\n\n> [!NOTE] Use ISR only on routes where every visitor should see the same content (much like when you prerender). If there's anything user-specific happening (like session cookies), they should happen on the client via JavaScript only to not leak sensitive information across visits\n\nTo add ISR to a route, include the `isr` property in your `config` object:\n\n```js\nimport { BYPASS_TOKEN } from '$env/static/private';\n\n/** @type {import('@sveltejs/adapter-vercel').Config} */\nexport const config = {\n\tisr: {\n\t\texpiration: 60,\n\t\tbypassToken: BYPASS_TOKEN,\n\t\tallowQuery: ['search']\n\t}\n};\n```\n\n> [!NOTE] Using ISR on a route with `export const prerender = true` will have no effect, since the route is prerendered at build time\n\nThe `expiration` property is required; all others are optional. The properties are discussed in more detail below.\n\n### expiration\n\nThe expiration time (in seconds) before the cached asset will be re-generated by invoking the Serverless Function. Setting the value to `false` means it will never expire. In that case, you likely want to define a bypass token to re-generate on demand.\n\n### bypassToken\n\nA random token that can be provided in the URL to bypass the cached version of the asset, by requesting the asset with a `__prerender_bypass=<token>` cookie.\n\nMaking a `GET` or `HEAD` request with `x-prerender-revalidate: <token>` will force the asset to be re-validated.\n\nNote that the `BYPASS_TOKEN` string must be at least 32 characters long. You could generate one using the JavaScript console like so:\n\n```js\ncrypto.randomUUID();\n```\n\nSet this string as an environment variable on Vercel by logging in and going to your project then Settings > Environment Variables. For \"Key\" put `BYPASS_TOKEN` and for \"value\" use the string generated above, then hit \"Save\".\n\nTo get this key known about for local development, you can use the [Vercel CLI](https://vercel.com/docs/cli/env) by running the `vercel env pull` command locally like so:\n\n```sh\nvercel env pull .env.development.local\n```\n\n### allowQuery\n\nA list of valid query parameters that contribute to the cache key. Other parameters (such as utm tracking codes) will be ignored, ensuring that they do not result in content being re-generated unnecessarily. By default, query parameters are ignored.\n\n> [!NOTE] Pages that are  [prerendered](page-options#prerender) will ignore ISR configuration.\n\n## Environment variables\n\nVercel makes a set of [deployment-specific environment variables](https://vercel.com/docs/concepts/projects/environment-variables#system-environment-variables) available. Like other environment variables, these are accessible from `$env/static/private` and `$env/dynamic/private` (sometimes — more on that later), and inaccessible from their public counterparts. To access one of these variables from the client:\n\n```js\n/// file: +layout.server.js\nimport { VERCEL_COMMIT_REF } from '$env/static/private';\n\n/** @type {import('./$types').LayoutServerLoad} */\nexport function load() {\n\treturn {\n\t\tdeploymentGitBranch: VERCEL_COMMIT_REF\n\t};\n}\n```\n\n```svelte\n<!--- file: +layout.svelte --->\n<script>\n\t/** @type {import('./$types').LayoutProps} */\n\tlet { data } = $props();\n</script>\n\n<p>This staging environment was deployed from {data.deploymentGitBranch}.</p>\n```\n\nSince all of these variables are unchanged between build time and run time when building on Vercel, we recommend using `$env/static/private` — which will statically replace the variables, enabling optimisations like dead code elimination — rather than `$env/dynamic/private`.\n\n## Skew protection\n\nWhen a new version of your app is deployed, assets belonging to the previous version may no longer be accessible. If a user is actively using your app when this happens, it can cause errors when they navigate — this is known as _version skew_. SvelteKit mitigates this by detecting errors resulting from version skew and causing a hard reload to get the latest version of the app, but this will cause any client-side state to be lost. (You can also proactively mitigate it by observing [`updated.current`]($app-state#updated) from `$app/state`, which tells clients when a new version has been deployed.)\n\n[Skew protection](https://vercel.com/docs/deployments/skew-protection) is a Vercel feature that routes client requests to their original deployment. When a user visits your app, a cookie is set with the deployment ID, and any subsequent requests will be routed to that deployment for as long as skew protection is active. When they reload the page, they will get the newest deployment. (`updated.current` is exempted from this behaviour, and so will continue to report new deployments.) To enable it, visit the Advanced section of your project settings on Vercel.\n\nCookie-based skew protection comes with one caveat: if a user has multiple versions of your app open in multiple tabs, requests from older versions will be routed to the newer one, meaning they will fall back to SvelteKit's built-in skew protection.\n\n## Notes\n\n### Vercel utilities\n\nIf you need Vercel-specific utilities like `waitUntil`, use the package [`@vercel/functions`](https://vercel.com/docs/functions/functions-api-reference/vercel-functions-package).\n\n### Vercel functions\n\nIf you have Vercel functions contained in the `api` directory at the project's root, any requests for `/api/*` will _not_ be handled by SvelteKit. You should implement these as [API routes](routing#server) in your SvelteKit app instead, unless you need to use a non-JavaScript language in which case you will need to ensure that you don't have any `/api/*` routes in your SvelteKit app.\n\n### Node version\n\nProjects created before a certain date may default to using an older Node version than what SvelteKit currently requires. You can [change the Node version in your project settings](https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js#node.js-version).\n\n## Troubleshooting\n\n### Accessing the file system\n\nYou can't use `fs` in edge functions.\n\nYou _can_ use it in serverless functions, but it won't work as expected, since files are not copied from your project into your deployment. Instead, use the [`read`]($app-server#read) function from `$app/server` to access your files. It also works inside routes deployed as edge functions by fetching the file from the deployed public assets location.\n\nAlternatively, you can [prerender](page-options#prerender) the routes in question.\n\n### Deployment protection\n\nIf using [`read`]($app-server#read) in an edge function, SvelteKit will `fetch` the file in question from your deployment. If you are using [Deployment Protection](https://vercel.com/docs/deployment-protection), you must also enable [Protection Bypass for Automation](https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation) so that the request does not result in a [401 Unauthorized](https://http.dog/401) response.\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/99-writing-adapters.md",
    "content": "---\ntitle: Writing adapters\n---\n\nIf an adapter for your preferred environment doesn't yet exist, you can build your own. We recommend [looking at the source for an adapter](https://github.com/sveltejs/kit/tree/main/packages) to a platform similar to yours and copying it as a starting point.\n\nAdapter packages implement the following API, which creates an `Adapter`:\n\n```js\n// @errors: 2322\n// @filename: ambient.d.ts\ntype AdapterSpecificOptions = any;\n\n// @filename: index.js\n// ---cut---\n/** @param {AdapterSpecificOptions} options */\nexport default function (options) {\n\t/** @type {import('@sveltejs/kit').Adapter} */\n\tconst adapter = {\n\t\tname: 'adapter-package-name',\n\t\tasync adapt(builder) {\n\t\t\t// adapter implementation\n\t\t},\n\t\tasync emulate() {\n\t\t\treturn {\n\t\t\t\tasync platform({ config, prerender }) {\n\t\t\t\t\t// the returned object becomes `event.platform` during dev, build and\n\t\t\t\t\t// preview. Its shape is that of `App.Platform`\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tsupports: {\n\t\t\tread: ({ config, route }) => {\n\t\t\t\t// Return `true` if the route with the given `config` can use `read`\n\t\t\t\t// from `$app/server` in production, return `false` if it can't.\n\t\t\t\t// Or throw a descriptive error describing how to configure the deployment\n\t\t\t},\n\t\t\tinstrumentation: () => {\n\t\t\t\t// Return `true` if this adapter supports loading `instrumentation.server.js`.\n\t\t\t\t// Return `false if it can't, or throw a descriptive error.\n\t\t\t}\n\t\t}\n\t};\n\n\treturn adapter;\n}\n```\n\nOf these, `name` and `adapt` are required. `emulate` and `supports` are optional.\n\nWithin the `adapt` method, there are a number of things that an adapter should do:\n\n- Clear out the build directory\n- Write SvelteKit output with `builder.writeClient`, `builder.writeServer`, and `builder.writePrerendered`\n- Output code that:\n\t- Imports `Server` from `${builder.getServerDirectory()}/index.js`\n\t- Instantiates the app with a manifest generated with `builder.generateManifest({ relativePath })`\n\t- Listens for requests from the platform, converts them to a standard [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) if necessary, calls the `server.respond(request, { getClientAddress })` function to generate a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) and responds with it\n\t- expose any platform-specific information to SvelteKit via the `platform` option passed to `server.respond`\n\t- Globally shims `fetch` to work on the target platform, if necessary. SvelteKit provides a `@sveltejs/kit/node/polyfills` helper for platforms that can use `undici`\n- Bundle the output to avoid needing to install dependencies on the target platform, if necessary\n- Put the user's static files and the generated JS/CSS in the correct location for the target platform\n\nWhere possible, we recommend putting the adapter output under the `build/` directory with any intermediate output placed under `.svelte-kit/[adapter-name]`.\n"
  },
  {
    "path": "documentation/docs/25-build-and-deploy/index.md",
    "content": "---\ntitle: Build and deploy\n---\n"
  },
  {
    "path": "documentation/docs/30-advanced/10-advanced-routing.md",
    "content": "---\ntitle: Advanced routing\n---\n\n## Rest parameters\n\nIf the number of route segments is unknown, you can use rest syntax — for example you might implement GitHub's file viewer like so...\n\n```sh\n/[org]/[repo]/tree/[branch]/[...file]\n```\n\n...in which case a request for `/sveltejs/kit/tree/main/documentation/docs/04-advanced-routing.md` would result in the following parameters being available to the page:\n\n```js\n// @noErrors\n{\n\torg: 'sveltejs',\n\trepo: 'kit',\n\tbranch: 'main',\n\tfile: 'documentation/docs/04-advanced-routing.md'\n}\n```\n\n> [!NOTE] `src/routes/a/[...rest]/z/+page.svelte` will match `/a/z` (i.e. there's no parameter at all) as well as `/a/b/z` and `/a/b/c/z` and so on. Make sure you check that the value of the rest parameter is valid, for example using a [matcher](#Matching).\n\n### 404 pages\n\nRest parameters also allow you to render custom 404s. Given these routes...\n\n```tree\nsrc/routes/\n├ marx-brothers/\n│ ├ chico/\n│ ├ harpo/\n│ ├ groucho/\n│ └ +error.svelte\n└ +error.svelte\n```\n\n...the `marx-brothers/+error.svelte` file will _not_ be rendered if you visit `/marx-brothers/karl`, because no route was matched. If you want to render the nested error page, you should create a route that matches any `/marx-brothers/*` request, and return a 404 from it:\n\n```tree\nsrc/routes/\n├ marx-brothers/\n+++| ├ [...path]/+++\n│ ├ chico/\n│ ├ harpo/\n│ ├ groucho/\n│ └ +error.svelte\n└ +error.svelte\n```\n\n```js\n/// file: src/routes/marx-brothers/[...path]/+page.js\nimport { error } from '@sveltejs/kit';\n\n/** @type {import('./$types').PageLoad} */\nexport function load(event) {\n\terror(404, 'Not Found');\n}\n```\n\n> [!NOTE] If you don't handle 404 cases, they will appear in [`handleError`](hooks#Shared-hooks-handleError)\n\n## Optional parameters\n\nA route like `[lang]/home` contains a parameter named `lang` which is required. Sometimes it's beneficial to make these parameters optional, so that in this example both `home` and `en/home` point to the same page. You can do that by wrapping the parameter in another bracket pair: `[[lang]]/home`\n\nNote that an optional route parameter cannot follow a rest parameter (`[...rest]/[[optional]]`), since parameters are matched 'greedily' and the optional parameter would always be unused.\n\n## Matching\n\nA route like `src/routes/fruits/[page]` would match `/fruits/apple`, but it would also match `/fruits/rocketship`. We don't want that. You can ensure that route parameters are well-formed by adding a _matcher_ — which takes the parameter string (`\"apple\"` or `\"rocketship\"`) and returns `true` if it is valid — to your `src/params` directory...\n\n```js\n/// file: src/params/fruit.js\n/**\n * @param {string} param\n * @return {param is ('apple' | 'orange')}\n * @satisfies {import('@sveltejs/kit').ParamMatcher}\n */\nexport function match(param) {\n\treturn param === 'apple' || param === 'orange';\n}\n```\n\n...and augmenting your routes:\n\n```\nsrc/routes/fruits/[page+++=fruit+++]\n```\n\nIf the pathname doesn't match, SvelteKit will try to match other routes (using the sort order specified below), before eventually returning a 404.\n\nEach module in the `params` directory corresponds to a matcher, with the exception of `*.test.js` and `*.spec.js` files which may be used to unit test your matchers.\n\n> [!NOTE] Matchers run both on the server and in the browser.\n\n## Sorting\n\nIt's possible for multiple routes to match a given path. For example each of these routes would match `/foo-abc`:\n\n```sh\nsrc/routes/[...catchall]/+page.svelte\nsrc/routes/[[a=x]]/+page.svelte\nsrc/routes/[b]/+page.svelte\nsrc/routes/foo-[c]/+page.svelte\nsrc/routes/foo-abc/+page.svelte\n```\n\nSvelteKit needs to know which route is being requested. To do so, it sorts them according to the following rules...\n\n- More specific routes are higher priority (e.g. a route with no parameters is more specific than a route with one dynamic parameter, and so on)\n- Parameters with [matchers](#Matching) (`[name=type]`) are higher priority than those without (`[name]`)\n- `[[optional]]` and `[...rest]` parameters are ignored unless they are the final part of the route, in which case they are treated with lowest priority. In other words `x/[[y]]/z` is treated equivalently to `x/z` for the purposes of sorting\n- Ties are resolved alphabetically\n\n...resulting in this ordering, meaning that `/foo-abc` will invoke `src/routes/foo-abc/+page.svelte`, and `/foo-def` will invoke `src/routes/foo-[c]/+page.svelte` rather than less specific routes:\n\n```sh\nsrc/routes/foo-abc/+page.svelte\nsrc/routes/foo-[c]/+page.svelte\nsrc/routes/[[a=x]]/+page.svelte\nsrc/routes/[b]/+page.svelte\nsrc/routes/[...catchall]/+page.svelte\n```\n\n## Encoding\n\nSome characters can't be used on the filesystem — `/` on Linux and Mac, `\\ / : * ? \" < > |` on Windows. The `#` and `%` characters have special meaning in URLs, and the `[ ] ( )` characters have special meaning to SvelteKit, so these also can't be used directly as part of your route.\n\nTo use these characters in your routes, you can use hexadecimal escape sequences, which have the format `[x+nn]` where `nn` is a hexadecimal character code:\n\n- `\\` — `[x+5c]`\n- `/` — `[x+2f]`\n- `:` — `[x+3a]`\n- `*` — `[x+2a]`\n- `?` — `[x+3f]`\n- `\"` — `[x+22]`\n- `<` — `[x+3c]`\n- `>` — `[x+3e]`\n- `|` — `[x+7c]`\n- `#` — `[x+23]`\n- `%` — `[x+25]`\n- `[` — `[x+5b]`\n- `]` — `[x+5d]`\n- `(` — `[x+28]`\n- `)` — `[x+29]`\n\nFor example, to create a `/smileys/:-)` route, you would create a `src/routes/smileys/[x+3a]-[x+29]/+page.svelte` file.\n\nYou can determine the hexadecimal code for a character with JavaScript:\n\n```js\n':'.charCodeAt(0).toString(16); // '3a', hence '[x+3a]'\n```\n\nYou can also use Unicode escape sequences. Generally you won't need to as you can use the unencoded character directly, but if — for some reason — you can't have a filename with an emoji in it, for example, then you can use the escaped characters. In other words, these are equivalent:\n\n```\nsrc/routes/[u+d83e][u+dd2a]/+page.svelte\nsrc/routes/🤪/+page.svelte\n```\n\nThe format for a Unicode escape sequence is `[u+nnnn]` where `nnnn` is a valid value between `0000` and `10ffff`. (Unlike JavaScript string escaping, there's no need to use surrogate pairs to represent code points above `ffff`.) To learn more about Unicode encodings, consult [Programming with Unicode](https://unicodebook.readthedocs.io/unicode_encodings.html).\n\n> [!NOTE] Since TypeScript [struggles](https://github.com/microsoft/TypeScript/issues/13399) with directories with a leading `.` character, you may find it useful to encode these characters when creating e.g. [`.well-known`](https://en.wikipedia.org/wiki/Well-known_URI) routes: `src/routes/[x+2e]well-known/...`\n\n## Advanced layouts\n\nBy default, the _layout hierarchy_ mirrors the _route hierarchy_. In some cases, that might not be what you want.\n\n### (group)\n\nPerhaps you have some routes that are 'app' routes that should have one layout (e.g. `/dashboard` or `/item`), and others that are 'marketing' routes that should have a different layout (`/about` or `/testimonials`). We can group these routes with a directory whose name is wrapped in parentheses — unlike normal directories, `(app)` and `(marketing)` do not affect the URL pathname of the routes inside them:\n\n```tree\nsrc/routes/\n+++│ (app)/+++\n│ ├ dashboard/\n│ ├ item/\n│ └ +layout.svelte\n+++│ (marketing)/+++\n│ ├ about/\n│ ├ testimonials/\n│ └ +layout.svelte\n├ admin/\n└ +layout.svelte\n```\n\nYou can also put a `+page` directly inside a `(group)`, for example if `/` should be an `(app)` or a `(marketing)` page.\n\n### Breaking out of layouts\n\nThe root layout applies to every page of your app — if omitted, it defaults to `{@render children()}`. If you want some pages to have a different layout hierarchy than the rest, then you can put your entire app inside one or more groups _except_ the routes that should not inherit the common layouts.\n\nIn the example above, the `/admin` route does not inherit either the `(app)` or `(marketing)` layouts.\n\n### +page@\n\nPages can break out of the current layout hierarchy on a route-by-route basis. Suppose we have an `/item/[id]/embed` route inside the `(app)` group from the previous example:\n\n```tree\nsrc/routes/\n├ (app)/\n│ ├ item/\n│ │ ├ [id]/\n│ │ │ ├ embed/\n+++│ │ │ │ └ +page.svelte+++\n│ │ │ └ +layout.svelte\n│ │ └ +layout.svelte\n│ └ +layout.svelte\n└ +layout.svelte\n```\n\nOrdinarily, this would inherit the root layout, the `(app)` layout, the `item` layout and the `[id]` layout. We can reset to one of those layouts by appending `@` followed by the segment name — or, for the root layout, the empty string. In this example, we can choose from the following options:\n\n- `+page@[id].svelte` - inherits from `src/routes/(app)/item/[id]/+layout.svelte`\n- `+page@item.svelte` - inherits from `src/routes/(app)/item/+layout.svelte`\n- `+page@(app).svelte` - inherits from `src/routes/(app)/+layout.svelte`\n- `+page@.svelte` - inherits from `src/routes/+layout.svelte`\n\n```tree\nsrc/routes/\n├ (app)/\n│ ├ item/\n│ │ ├ [id]/\n│ │ │ ├ embed/\n+++│ │ │ │ └ +page@(app).svelte+++\n│ │ │ └ +layout.svelte\n│ │ └ +layout.svelte\n│ └ +layout.svelte\n└ +layout.svelte\n```\n\n### +layout@\n\nLike pages, layouts can _themselves_ break out of their parent layout hierarchy, using the same technique. For example, a `+layout@.svelte` component would reset the hierarchy for all its child routes.\n\n```\nsrc/routes/\n├ (app)/\n│ ├ item/\n│ │ ├ [id]/\n│ │ │ ├ embed/\n│ │ │ │ └ +page.svelte  // uses (app)/item/[id]/+layout.svelte\n│ │ │ ├ +layout.svelte  // inherits from (app)/item/+layout@.svelte\n│ │ │ └ +page.svelte    // uses (app)/item/+layout@.svelte\n│ │ └ +layout@.svelte   // inherits from root layout, skipping (app)/+layout.svelte\n│ └ +layout.svelte\n└ +layout.svelte\n```\n\n### When to use layout groups\n\nNot all use cases are suited for layout grouping, nor should you feel compelled to use them. It might be that your use case would result in complex `(group)` nesting, or that you don't want to introduce a `(group)` for a single outlier. It's perfectly fine to use other means such as composition (reusable `load` functions or Svelte components) or if-statements to achieve what you want. The following example shows a layout that rewinds to the root layout and reuses components and functions that other layouts can also use:\n\n```svelte\n<!--- file: src/routes/nested/route/+layout@.svelte --->\n<script>\n\timport ReusableLayout from '$lib/ReusableLayout.svelte';\n\tlet { data, children } = $props();\n</script>\n\n<ReusableLayout {data}>\n\t{@render children()}\n</ReusableLayout>\n```\n\n```js\n/// file: src/routes/nested/route/+layout.js\n// @filename: ambient.d.ts\ndeclare module \"$lib/reusable-load-function\" {\n\texport function reusableLoad(event: import('@sveltejs/kit').LoadEvent): Promise<Record<string, any>>;\n}\n// @filename: index.js\n// ---cut---\nimport { reusableLoad } from '$lib/reusable-load-function';\n\n/** @type {import('./$types').PageLoad} */\nexport function load(event) {\n\t// Add additional logic here, if needed\n\treturn reusableLoad(event);\n}\n```\n\n## Further reading\n\n- [Tutorial: Advanced Routing](/tutorial/kit/optional-params)\n"
  },
  {
    "path": "documentation/docs/30-advanced/20-hooks.md",
    "content": "---\ntitle: Hooks\n---\n\n'Hooks' are app-wide functions you declare that SvelteKit will call in response to specific events, giving you fine-grained control over the framework's behaviour.\n\nThere are three hooks files, all optional:\n\n- `src/hooks.server.js` — your app's server hooks\n- `src/hooks.client.js` — your app's client hooks\n- `src/hooks.js` — your app's hooks that run on both the client and server\n\nCode in these modules will run when the application starts up, making them useful for initializing database clients and so on.\n\n## Server hooks\n\nThe following hooks can be added to `src/hooks.server.js`:\n\n### handle\n\nThis function runs every time the SvelteKit server receives a [request](web-standards#Fetch-APIs-Request) — whether that happens while the app is running, or during [prerendering](page-options#prerender) — and determines the [response](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).\n\n```js\n/// file: src/hooks.server.js\n/** @type {import('@sveltejs/kit').Handle} */\nexport async function handle({ event, resolve }) {\n\tif (event.url.pathname.startsWith('/custom')) {\n\t\treturn new Response('custom response');\n\t}\n\n\tconst response = await resolve(event);\n\treturn response;\n}\n```\n\n> [!NOTE] Requests for static assets — which includes pages that were already prerendered — are _not_ handled by SvelteKit.\n\nIf unimplemented, defaults to `({ event, resolve }) => resolve(event)`.\n\nDuring prerendering, SvelteKit crawls your pages for links and renders each route it finds. Rendering the route invokes the `handle` function (and all other route dependencies, like `load`). If you need to exclude some code from running during this phase, check that the app is not [`building`]($app-environment#building) beforehand.\n\n### locals\n\nTo add custom data to the request, which is passed to handlers in `+server.js` and server `load` functions, populate the `event.locals` object, as shown below.\n\n```js\n/// file: src/hooks.server.js\n// @filename: ambient.d.ts\ntype User = {\n\tname: string;\n}\n\ndeclare namespace App {\n\tinterface Locals {\n\t\tuser: User;\n\t}\n}\n\nconst getUserInformation: (cookie: string | void) => Promise<User>;\n\n// @filename: index.js\n// ---cut---\n/** @type {import('@sveltejs/kit').Handle} */\nexport async function handle({ event, resolve }) {\n\tevent.locals.user = await getUserInformation(event.cookies.get('sessionid'));\n\n\tconst response = await resolve(event);\n\n\t// Note that modifying response headers isn't always safe.\n\t// Response objects can have immutable headers\n\t// (e.g. Response.redirect() returned from an endpoint).\n\t// Modifying immutable headers throws a TypeError.\n\t// In that case, clone the response or avoid creating a\n\t// response object with immutable headers.\n\tresponse.headers.set('x-custom-header', 'potato');\n\n\treturn response;\n}\n```\n\nYou can define multiple `handle` functions and execute them with [the `sequence` helper function](@sveltejs-kit-hooks).\n\n`resolve` also supports a second, optional parameter that gives you more control over how the response will be rendered. That parameter is an object that can have the following fields:\n\n- `transformPageChunk(opts: { html: string, done: boolean }): MaybePromise<string | undefined>` — 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.\n- `filterSerializedResponseHeaders(name: string, value: string): boolean` — determines which headers should be included in serialized responses when a `load` function loads a resource with `fetch`. By default, none will be included.\n- `preload(input: { type: 'js' | 'css' | 'font' | 'asset', path: string }): boolean` — determines what files should be added to the `<head>` tag to preload it. The method is called with each file that was found at build time while constructing the code chunks — so if you for example have `import './styles.css` in your `+page.svelte`, `preload` will be called with the resolved path to that CSS file when visiting that page. Note that in dev mode `preload` is _not_ called, since it depends on analysis that happens at build time. Preloading can improve performance by downloading assets sooner, but it can also hurt if too much is downloaded unnecessarily. By default, `js` and `css` files will be preloaded. `asset` files are not preloaded at all currently, but we may add this later after evaluating feedback.\n\n```js\n/// file: src/hooks.server.js\n/** @type {import('@sveltejs/kit').Handle} */\nexport async function handle({ event, resolve }) {\n\tconst response = await resolve(event, {\n\t\ttransformPageChunk: ({ html }) => html.replace('old', 'new'),\n\t\tfilterSerializedResponseHeaders: (name) => name.startsWith('x-'),\n\t\tpreload: ({ type, path }) => type === 'js' || path.includes('/important/')\n\t});\n\n\treturn response;\n}\n```\n\nNote that `resolve(...)` will never throw an error, it will always return a `Promise<Response>` with the appropriate status code. If an error is thrown elsewhere during `handle`, it is treated as fatal, and SvelteKit will respond with a JSON representation of the error or a fallback error page — which can be customised via `src/error.html` — depending on the `Accept` header. You can read more about error handling [here](errors).\n\n### handleFetch\n\nThis function allows you to modify (or replace) the result of an [`event.fetch`](load#Making-fetch-requests) call that runs on the server (or during prerendering) inside an endpoint, `load`, `action`, `handle`, `handleError` or `reroute`.\n\nFor example, your `load` function might make a request to a public URL like `https://api.yourapp.com` when the user performs a client-side navigation to the respective page, but during SSR it might make sense to hit the API directly (bypassing whatever proxies and load balancers sit between it and the public internet).\n\n```js\n/// file: src/hooks.server.js\n/** @type {import('@sveltejs/kit').HandleFetch} */\nexport async function handleFetch({ request, fetch }) {\n\tif (request.url.startsWith('https://api.yourapp.com/')) {\n\t\t// clone the original request, but change the URL\n\t\trequest = new Request(\n\t\t\trequest.url.replace('https://api.yourapp.com/', 'http://localhost:9999/'),\n\t\t\trequest\n\t\t);\n\t}\n\n\treturn fetch(request);\n}\n```\n\nRequests made with `event.fetch` follow the browser's credentials model — for same-origin requests, `cookie` and `authorization` headers are forwarded unless the `credentials` option is set to `\"omit\"`. For cross-origin requests, `cookie` will be included if the request URL belongs to a subdomain of the app — for example if your app is on `my-domain.com`, and your API is on `api.my-domain.com`, cookies will be included in the request.\n\nThere is one caveat: if your app and your API are on sibling subdomains — `www.my-domain.com` and `api.my-domain.com` for example — then a cookie belonging to a common parent domain like `my-domain.com` will _not_ be included, because SvelteKit has no way to know which domain the cookie belongs to. In these cases you will need to manually include the cookie using `handleFetch`:\n\n```js\n/// file: src/hooks.server.js\n// @errors: 2345\n/** @type {import('@sveltejs/kit').HandleFetch} */\nexport async function handleFetch({ event, request, fetch }) {\n\tif (request.url.startsWith('https://api.my-domain.com/')) {\n\t\trequest.headers.set('cookie', event.request.headers.get('cookie'));\n\t}\n\n\treturn fetch(request);\n}\n```\n\n### handleValidationError\n\nThis hook is called when a remote function is called with an argument that does not match the provided [Standard Schema](https://standardschema.dev/). It must return an object matching the shape of [`App.Error`](types#Error).\n\nSay you have a remote function that expects a string as its argument ...\n\n```js\n/// file: todos.remote.js\nimport * as v from 'valibot';\nimport { query } from '$app/server';\n\nexport const getTodo = query(v.string(), (id) => {\n\t// implementation...\n});\n```\n\n...but it is called with something that doesn't match the schema — such as a number (e.g. `await getTodos(1)`) — then validation will fail, the server will respond with a [400 status code](https://http.dog/400), and the function will throw with the message 'Bad Request'.\n\nTo customise this message and add additional properties to the error object, implement `handleValidationError`:\n\n```js\n/// file: src/hooks.server.js\n/** @type {import('@sveltejs/kit').HandleValidationError} */\nexport function handleValidationError({ issues }) {\n\treturn {\n\t\tmessage: 'No thank you'\n\t};\n}\n```\n\nBe thoughtful about what information you expose here, as the most likely reason for validation to fail is that someone is sending malicious requests to your server.\n\n## Shared hooks\n\nThe following can be added to `src/hooks.server.js` _and_ `src/hooks.client.js`:\n\n### handleError\n\nIf an [unexpected error](errors#Unexpected-errors) is thrown during loading, rendering, or from an endpoint, this function will be called with the `error`, `event`, `status` code and `message`. This allows for two things:\n\n- you can log the error\n- you can generate a custom representation of the error that is safe to show to users, omitting sensitive details like messages and stack traces. The returned value, which defaults to `{ message }`, becomes the value of `page.error`.\n\nFor errors thrown from your code (or library code called by your code) the status will be 500 and the message will be \"Internal Error\". While `error.message` may contain sensitive information that should not be exposed to users, `message` is safe (albeit meaningless to the average user).\n\nTo add more information to the `page.error` object in a type-safe way, you can customize the expected shape by declaring an `App.Error` interface (which must include `message: string`, to guarantee sensible fallback behavior). This allows you to — for example — append a tracking ID for users to quote in correspondence with your technical support staff:\n\n```ts\n/// file: src/app.d.ts\ndeclare global {\n\tnamespace App {\n\t\tinterface Error {\n\t\t\tmessage: string;\n\t\t\terrorId: string;\n\t\t}\n\t}\n}\n\nexport {};\n```\n\n```js\n/// file: src/hooks.server.js\n// @errors: 2322 2353\n// @filename: ambient.d.ts\ndeclare module '@sentry/sveltekit' {\n\texport const init: (opts: any) => void;\n\texport const captureException: (error: any, opts: any) => void;\n}\n\n// @filename: index.js\n// ---cut---\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({/*...*/})\n\n/** @type {import('@sveltejs/kit').HandleServerError} */\nexport async function handleError({ error, event, status, message }) {\n\tconst errorId = crypto.randomUUID();\n\n\t// example integration with https://sentry.io/\n\tSentry.captureException(error, {\n\t\textra: { event, errorId, status }\n\t});\n\n\treturn {\n\t\tmessage: 'Whoops!',\n\t\terrorId\n\t};\n}\n```\n\n```js\n/// file: src/hooks.client.js\n// @errors: 2322 2353\n// @filename: ambient.d.ts\ndeclare module '@sentry/sveltekit' {\n\texport const init: (opts: any) => void;\n\texport const captureException: (error: any, opts: any) => void;\n}\n\n// @filename: index.js\n// ---cut---\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({/*...*/})\n\n/** @type {import('@sveltejs/kit').HandleClientError} */\nexport async function handleError({ error, event, status, message }) {\n\tconst errorId = crypto.randomUUID();\n\n\t// example integration with https://sentry.io/\n\tSentry.captureException(error, {\n\t\textra: { event, errorId, status }\n\t});\n\n\treturn {\n\t\tmessage: 'Whoops!',\n\t\terrorId\n\t};\n}\n```\n\n> [!NOTE] In `src/hooks.client.js`, the type of `handleError` is `HandleClientError` instead of `HandleServerError`, and `event` is a `NavigationEvent` rather than a `RequestEvent`.\n\nThis function is not called for _expected_ errors (those thrown with the [`error`](@sveltejs-kit#error) function imported from `@sveltejs/kit`).\n\nDuring development, if an error occurs because of a syntax error in your Svelte code, the passed in error has a `frame` property appended highlighting the location of the error.\n\n> [!NOTE] Make sure that `handleError` _never_ throws an error\n\n### init\n\nThis function runs once, when the server is created or the app starts in the browser, and is a useful place to do asynchronous work such as initializing a database connection.\n\n> [!NOTE] If your environment supports top-level await, the `init` function is really no different from writing your initialisation logic at the top level of the module, but some environments — most notably, Safari — don't.\n\n```js\n// @errors: 2307\n/// file: src/hooks.server.js\nimport * as db from '$lib/server/database';\n\n/** @type {import('@sveltejs/kit').ServerInit} */\nexport async function init() {\n\tawait db.connect();\n}\n```\n\n> [!NOTE]\n> In the browser, asynchronous work in `init` will delay hydration, so be mindful of what you put in there.\n\n## Universal hooks\n\nThe following can be added to `src/hooks.js`. Universal hooks run on both server and client (not to be confused with shared hooks, which are environment-specific).\n\n### reroute\n\nThis function runs before `handle` and allows you to change how URLs are translated into routes. The returned pathname (which defaults to `url.pathname`) is used to select the route and its parameters.\n\nFor example, you might have a `src/routes/[[lang]]/about/+page.svelte` page, which should be accessible as `/en/about` or `/de/ueber-uns` or `/fr/a-propos`. You could implement this with `reroute`:\n\n```js\n// @errors: 2345 2304\n/// file: src/hooks.js\n\n/** @type {Record<string, string>} */\nconst translated = {\n\t'/en/about': '/en/about',\n\t'/de/ueber-uns': '/de/about',\n\t'/fr/a-propos': '/fr/about',\n};\n\n/** @type {import('@sveltejs/kit').Reroute} */\nexport function reroute({ url }) {\n\tif (url.pathname in translated) {\n\t\treturn translated[url.pathname];\n\t}\n}\n```\n\nThe `lang` parameter will be correctly derived from the returned pathname.\n\nUsing `reroute` will _not_ change the contents of the browser's address bar, or the value of `event.url`.\n\nSince version 2.18, the `reroute` hook can be asynchronous, allowing it to (for example) fetch data from your backend to decide where to reroute to. Use this carefully and make sure it's fast, as it will delay navigation otherwise. If you need to fetch data, use the `fetch` provided as an argument. It has the [same benefits](load#Making-fetch-requests) as the `fetch` provided to `load` functions, with the caveat that `params` and `id` are unavailable to [`handleFetch`](#Server-hooks-handleFetch) because the route is not yet known.\n\n```js\n// @errors: 2345 2304\n/// file: src/hooks.js\n\n/** @type {import('@sveltejs/kit').Reroute} */\nexport async function reroute({ url, fetch }) {\n\t// Ask a special endpoint within your app about the destination\n\tif (url.pathname === '/api/reroute') return;\n\n\tconst api = new URL('/api/reroute', url);\n\tapi.searchParams.set('pathname', url.pathname);\n\n\tconst result = await fetch(api).then(r => r.json());\n\treturn result.pathname;\n}\n```\n\n\n> [!NOTE] `reroute` is considered a pure, idempotent function. As such, it must always return the same output for the same input and not have side effects. Under these assumptions, SvelteKit caches the result of `reroute` on the client so it is only called once per unique URL.\n\n### transport\n\nThis is a collection of _transporters_, which allow you to pass custom types — returned from `load` and form actions — across the server/client boundary. Each transporter contains an `encode` function, which encodes values on the server (or returns a falsy value for anything that isn't an instance of the type) and a corresponding `decode` function:\n\n```js\n// @errors: 2307\n/// file: src/hooks.js\nimport { Vector } from '$lib/math';\n\n/** @type {import('@sveltejs/kit').Transport} */\nexport const transport = {\n\tVector: {\n\t\tencode: (value) => value instanceof Vector && [value.x, value.y],\n\t\tdecode: ([x, y]) => new Vector(x, y)\n\t}\n};\n```\n\n\n## Further reading\n\n- [Tutorial: Hooks](/tutorial/kit/handle)\n"
  },
  {
    "path": "documentation/docs/30-advanced/25-errors.md",
    "content": "---\ntitle: Errors\n---\n\nErrors are an inevitable fact of software development. SvelteKit handles errors differently depending on where they occur, what kind of errors they are, and the nature of the incoming request.\n\n## Error objects\n\nSvelteKit distinguishes between expected and unexpected errors, both of which are represented as simple `{ message: string }` objects by default.\n\nYou can add additional properties, like a `code` or a tracking `id`, as shown in the examples below. (When using TypeScript this requires you to redefine the `Error` type as described in  [type safety](errors#Type-safety)).\n\n## Expected errors\n\nAn _expected_ error is one created with the [`error`](@sveltejs-kit#error) helper imported from `@sveltejs/kit`:\n\n```js\n/// file: src/routes/blog/[slug]/+page.server.js\n// @filename: ambient.d.ts\ndeclare module '$lib/server/database' {\n\texport function getPost(slug: string): Promise<{ title: string, content: string } | undefined>\n}\n\n// @filename: index.js\n// ---cut---\nimport { error } from '@sveltejs/kit';\nimport * as db from '$lib/server/database';\n\n/** @type {import('./$types').PageServerLoad} */\nexport async function load({ params }) {\n\tconst post = await db.getPost(params.slug);\n\n\tif (!post) {\n\t\terror(404, {\n\t\t\tmessage: 'Not found'\n\t\t});\n\t}\n\n\treturn { post };\n}\n```\n\nThis throws an exception that SvelteKit catches, causing it to set the response status code to 404 and render an [`+error.svelte`](routing#error) component, where `page.error` is the object provided as the second argument to `error(...)`.\n\n```svelte\n<!--- file: src/routes/+error.svelte --->\n<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.error.message}</h1>\n```\n\n> [!LEGACY]\n> `$app/state` was added in SvelteKit 2.12. If you're using an earlier version or are using Svelte 4, use `$app/stores` instead.\n\nYou can add extra properties to the error object if needed...\n\n```js\n// @filename: ambient.d.ts\ndeclare global {\n\tnamespace App {\n\t\tinterface Error {\n\t\t\tmessage: string;\n\t\t\tcode: string;\n\t\t}\n\t}\n}\nexport {}\n\n// @filename: index.js\nimport { error } from '@sveltejs/kit';\n// ---cut---\nerror(404, {\n\tmessage: 'Not found',\n\t+++code: 'NOT_FOUND'+++\n});\n```\n\n...otherwise, for convenience, you can pass a string as the second argument:\n\n```js\nimport { error } from '@sveltejs/kit';\n// ---cut---\n---error(404, { message: 'Not found' });---\n+++error(404, 'Not found');+++\n```\n\n> [!NOTE] [In SvelteKit 1.x](migrating-to-sveltekit-2#redirect-and-error-are-no-longer-thrown-by-you) you had to `throw` the `error` yourself\n\n## Unexpected errors\n\nAn _unexpected_ error is any other exception that occurs while handling a request. Since these can contain sensitive information, unexpected error messages and stack traces are not exposed to users.\n\nBy default, unexpected errors are printed to the console (or, in production, your server logs), while the error that is exposed to the user has a generic shape:\n\n```json\n{ \"message\": \"Internal Error\" }\n```\n\nUnexpected errors will go through the [`handleError`](hooks#Shared-hooks-handleError) hook, where you can add your own error handling — for example, sending errors to a reporting service, or returning a custom error object which becomes `page.error`.\n\n## Rendering errors\n\nOrdinarily, if an error happens during server-side rendering (for example inside a component's `<script>` block or template), SvelteKit will return a 500 error page.\n\nSince SvelteKit 2.54 and Svelte 5.53, you can change this by enabling the experimental `handleRenderingErrors` option in your config:\n\n```js\n/// file: svelte.config.js\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\texperimental: {\n\t\t\thandleRenderingErrors: true\n\t\t}\n\t}\n};\n\nexport default config;\n```\n\nWhen this is enabled, SvelteKit will wrap your route components in an error boundary. If an error occurs during rendering, the nearest [`+error.svelte`](routing#error) page will be shown, just as if the error had occurred in a `load` function.\n\nThe error is first passed to [`handleError`](hooks#Shared-hooks-handleError), allowing you to report it and transform it, before the resulting object is passed to the `+error.svelte` component.\n\n> [!NOTE]\n> Since rendering errors occur after the page has started rendering, and multiple boundaries could in parallel catch distinct errors, the [`page`]($app-state#page) object (and its `error` property) will not be updated. Instead, the error is passed directly to the `+error.svelte` component as a prop.\n\n```svelte\n<!--- file: +error.svelte --->\n<script>\n\tlet { error } = $props();\n</script>\n\n<h1>{error.message}</h1>\n```\n\nThe same applies for other error boundaries you define in your code:\n\n```svelte\n<svelte:boundary>\n\t...\n\t{#snippet failed(error: App.Error)}\n\t\t<!-- error went through handleError and is of type App.Error -->\n\t\t{error.message}\n\t{/snippet}\n</svelte:boundary>\n```\n\n## Responses\n\nIf an error occurs inside `handle` or inside a [`+server.js`](routing#server) request handler, SvelteKit will respond with either a fallback error page or a JSON representation of the error object, depending on the request's `Accept` headers.\n\nYou can customise the fallback error page by adding a `src/error.html` file:\n\n```html\n<!DOCTYPE html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<title>%sveltekit.error.message%</title>\n\t</head>\n\t<body>\n\t\t<h1>My custom error page</h1>\n\t\t<p>Status: %sveltekit.status%</p>\n\t\t<p>Message: %sveltekit.error.message%</p>\n\t</body>\n</html>\n```\n\nSvelteKit will replace `%sveltekit.status%` and `%sveltekit.error.message%` with their corresponding values.\n\nIf the error instead occurs inside a `load` function while rendering a page, SvelteKit will render the [`+error.svelte`](routing#error) component nearest to where the error occurred. If the error occurs inside a `load` function in `+layout(.server).js`, the closest error boundary in the tree is an `+error.svelte` file _above_ that layout (not next to it).\n\nThe exception is when the error occurs inside the root `+layout.js` or `+layout.server.js`, since the root layout would ordinarily _contain_ the `+error.svelte` component. In this case, SvelteKit uses the fallback error page.\n\n## Type safety\n\nIf you're using TypeScript and need to customize the shape of errors, you can do so by declaring an `App.Error` interface in your app (by convention, in `src/app.d.ts`, though it can live anywhere that TypeScript can 'see'):\n\n```ts\n/// file: src/app.d.ts\ndeclare global {\n\tnamespace App {\n\t\tinterface Error {\n+++\t\t\tcode: string;\n\t\t\tid: string;+++\n\t\t}\n\t}\n}\n\nexport {};\n```\n\nThis interface always includes a `message: string` property.\n\n## Further reading\n\n- [Tutorial: Errors and redirects](/tutorial/kit/error-basics)\n- [Tutorial: Hooks](/tutorial/kit/handle)\n"
  },
  {
    "path": "documentation/docs/30-advanced/30-link-options.md",
    "content": "---\ntitle: Link options\n---\n\nIn SvelteKit, `<a>` elements (rather than framework-specific `<Link>` components) are used to navigate between the routes of your app. If the user clicks on a link whose `href` is 'owned' by the app (as opposed to, say, a link to an external site) then SvelteKit will navigate to the new page by importing its code and then calling any `load` functions it needs to fetch data.\n\nYou can customise the behaviour of links with `data-sveltekit-*` attributes. These can be applied to the `<a>` itself, or to a parent element.\n\nThese options also apply to `<form>` elements with [`method=\"GET\"`](form-actions#GET-vs-POST).\n\n## data-sveltekit-preload-data\n\nBefore the browser registers that the user has clicked on a link, we can detect that they've hovered the mouse over it (on desktop) or that a `touchstart` or `mousedown` event was triggered. In both cases, we can make an educated guess that a `click` event is coming.\n\nSvelteKit can use this information to get a head start on importing the code and fetching the page's data, which can give us an extra couple of hundred milliseconds — the difference between a user interface that feels laggy and one that feels snappy.\n\nWe can control this behaviour with the `data-sveltekit-preload-data` attribute, which can have one of two values:\n\n- `\"hover\"` means that preloading will start if the mouse comes to a rest over a link. On mobile, preloading begins on `touchstart`\n- `\"tap\"` means that preloading will start as soon as a `touchstart` or `mousedown` event is registered\n\nThe default project template has a `data-sveltekit-preload-data=\"hover\"` attribute applied to the `<body>` element in `src/app.html`, meaning that every link is preloaded on hover by default:\n\n```html\n<body data-sveltekit-preload-data=\"hover\">\n\t<div style=\"display: contents\">%sveltekit.body%</div>\n</body>\n```\n\nSometimes, calling `load` when the user hovers over a link might be undesirable, either because it's likely to result in false positives (a click needn't follow a hover) or because data is updating very quickly and a delay could mean staleness.\n\nIn these cases, you can specify the `\"tap\"` value, which causes SvelteKit to call `load` only when the user taps or clicks on a link:\n\n```html\n<a data-sveltekit-preload-data=\"tap\" href=\"/stonks\">\n\tGet current stonk values\n</a>\n```\n\n> [!NOTE] You can also programmatically invoke `preloadData` from `$app/navigation`.\n\nData will never be preloaded if the user has chosen reduced data usage, meaning [`navigator.connection.saveData`](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/saveData) is `true`.\n\n## data-sveltekit-preload-code\n\nEven in cases where you don't want to preload _data_ for a link, it can be beneficial to preload the _code_. The `data-sveltekit-preload-code` attribute works similarly to `data-sveltekit-preload-data`, except that it can take one of four values, in decreasing 'eagerness':\n\n- `\"eager\"` means that links will be preloaded straight away\n- `\"viewport\"` means that links will be preloaded once they enter the viewport\n- `\"hover\"` - as above, except that only code is preloaded\n- `\"tap\"` - as above, except that only code is preloaded\n\nNote that `viewport` and `eager` only apply to links that are present in the DOM immediately following navigation — if a link is added later (in an `{#if ...}` block, for example) it will not be preloaded until triggered by `hover` or `tap`. This is to avoid performance pitfalls resulting from aggressively observing the DOM for changes.\n\n> [!NOTE] Since preloading code is a prerequisite for preloading data, this attribute will only have an effect if it specifies a more eager value than any `data-sveltekit-preload-data` attribute that is present.\n\nAs with `data-sveltekit-preload-data`, this attribute will be ignored if the user has chosen reduced data usage.\n\n## data-sveltekit-reload\n\nOccasionally, we need to tell SvelteKit not to handle a link, but allow the browser to handle it. Adding a `data-sveltekit-reload` attribute to a link...\n\n```html\n<a data-sveltekit-reload href=\"/path\">Path</a>\n```\n\n...will cause a full-page navigation when the link is clicked.\n\nLinks with a `rel=\"external\"` attribute will receive the same treatment. In addition, they will be ignored during [prerendering](page-options#prerender).\n\n## data-sveltekit-replacestate\n\nSometimes you don't want navigation to create a new entry in the browser's session history. Adding a `data-sveltekit-replacestate` attribute to a link...\n\n```html\n<a data-sveltekit-replacestate href=\"/path\">Path</a>\n```\n\n...will replace the current `history` entry rather than creating a new one with `pushState` when the link is clicked.\n\n## data-sveltekit-keepfocus\n\nSometimes you don't want [focus to be reset](accessibility#Focus-management) after navigation. For example, maybe you have a search form that submits as the user is typing, and you want to keep focus on the text input.  Adding a `data-sveltekit-keepfocus` attribute to it...\n\n```html\n<form data-sveltekit-keepfocus>\n\t<input type=\"text\" name=\"query\">\n</form>\n```\n\n...will cause the currently focused element to retain focus after navigation. In general, avoid using this attribute on links, since the focused element would be the `<a>` tag (and not a previously focused element) and screen reader and other assistive technology users often expect focus to be moved after a navigation. You should also only use this attribute on elements that still exist after navigation. If the element no longer exists, the user's focus will be lost, making for a confusing experience for assistive technology users.\n\n## data-sveltekit-noscroll\n\nWhen navigating to internal links, SvelteKit mirrors the browser's default navigation behaviour: it will change the scroll position to 0,0 so that the user is at the very top left of the page (unless the link includes a `#hash`, in which case it will scroll to the element with a matching ID).\n\nIn certain cases, you may wish to disable this behaviour. Adding a `data-sveltekit-noscroll` attribute to a link...\n\n```html\n<a href=\"path\" data-sveltekit-noscroll>Path</a>\n```\n\n...will prevent scrolling after the link is clicked.\n\n## Disabling options\n\nTo disable any of these options inside an element where they have been enabled, use the `\"false\"` value:\n\n```html\n<div data-sveltekit-preload-data>\n\t<!-- these links will be preloaded -->\n\t<a href=\"/a\">a</a>\n\t<a href=\"/b\">b</a>\n\t<a href=\"/c\">c</a>\n\n\t<div data-sveltekit-preload-data=\"false\">\n\t\t<!-- these links will NOT be preloaded -->\n\t\t<a href=\"/d\">d</a>\n\t\t<a href=\"/e\">e</a>\n\t\t<a href=\"/f\">f</a>\n\t</div>\n</div>\n```\n\nTo apply an attribute to an element conditionally, do this:\n\n```svelte\n<div data-sveltekit-preload-data={condition ? 'hover' : false}>\n```\n"
  },
  {
    "path": "documentation/docs/30-advanced/40-service-workers.md",
    "content": "---\ntitle: Service workers\n---\n\nService workers act as proxy servers that handle network requests inside your app. This makes it possible to make your app work offline, but even if you don't need offline support (or can't realistically implement it because of the type of app you're building), it's often worth using service workers to speed up navigation by precaching your built JS and CSS.\n\nIn SvelteKit, if you have a `src/service-worker.js` file (or `src/service-worker/index.js`) it will be bundled and automatically registered.\n\nYou can [disable automatic registration](configuration#serviceWorker) if you need to register the service worker with your own logic or use another solution. The default registration looks something like this:\n\n```js\nif ('serviceWorker' in navigator) {\n\taddEventListener('load', function () {\n\t\tnavigator.serviceWorker.register('./path/to/service-worker.js');\n\t});\n}\n```\n\n## Inside the service worker\n\nInside the service worker you have access to the [`$service-worker` module]($service-worker), which provides you with the paths to all static assets, build files and prerendered pages. You're also provided with an app version string, which you can use for creating a unique cache name, and the deployment's `base` path. If your Vite config specifies `define` (used for global variable replacements), this will be applied to service workers as well as your server/client builds.\n\nThe following example caches the built app and any files in `static` eagerly, and caches all other requests as they happen. This would make each page work offline once visited.\n\n```js\n/// file: src/service-worker.js\n// Disables access to DOM typings like `HTMLElement` which are not available\n// inside a service worker and instantiates the correct globals\n/// <reference no-default-lib=\"true\"/>\n/// <reference lib=\"esnext\" />\n/// <reference lib=\"webworker\" />\n\n// Ensures that the `$service-worker` import has proper type definitions\n/// <reference types=\"@sveltejs/kit\" />\n\n// Only necessary if you have an import from `$env/static/public`\n/// <reference types=\"../.svelte-kit/ambient.d.ts\" />\n\nimport { build, files, version } from '$service-worker';\n\n// This gives `self` the correct types\nconst self = /** @type {ServiceWorkerGlobalScope} */ (/** @type {unknown} */ (globalThis.self));\n\n// Create a unique cache name for this deployment\nconst CACHE = `cache-${version}`;\n\nconst ASSETS = [\n\t...build, // the app itself\n\t...files  // everything in `static`\n];\n\nself.addEventListener('install', (event) => {\n\t// Create a new cache and add all files to it\n\tasync function addFilesToCache() {\n\t\tconst cache = await caches.open(CACHE);\n\t\tawait cache.addAll(ASSETS);\n\t}\n\n\tevent.waitUntil(addFilesToCache());\n});\n\nself.addEventListener('activate', (event) => {\n\t// Remove previous cached data from disk\n\tasync function deleteOldCaches() {\n\t\tfor (const key of await caches.keys()) {\n\t\t\tif (key !== CACHE) await caches.delete(key);\n\t\t}\n\t}\n\n\tevent.waitUntil(deleteOldCaches());\n});\n\nself.addEventListener('fetch', (event) => {\n\t// ignore POST requests etc\n\tif (event.request.method !== 'GET') return;\n\n\tasync function respond() {\n\t\tconst url = new URL(event.request.url);\n\t\tconst cache = await caches.open(CACHE);\n\n\t\t// `build`/`files` can always be served from the cache\n\t\tif (ASSETS.includes(url.pathname)) {\n\t\t\tconst response = await cache.match(url.pathname);\n\n\t\t\tif (response) {\n\t\t\t\treturn response;\n\t\t\t}\n\t\t}\n\n\t\t// for everything else, try the network first, but\n\t\t// fall back to the cache if we're offline\n\t\ttry {\n\t\t\tconst response = await fetch(event.request);\n\n\t\t\t// if we're offline, fetch can return a value that is not a Response\n\t\t\t// instead of throwing - and we can't pass this non-Response to respondWith\n\t\t\tif (!(response instanceof Response)) {\n\t\t\t\tthrow new Error('invalid response from fetch');\n\t\t\t}\n\n\t\t\tif (response.status === 200) {\n\t\t\t\tcache.put(event.request, response.clone());\n\t\t\t}\n\n\t\t\treturn response;\n\t\t} catch (err) {\n\t\t\tconst response = await cache.match(event.request);\n\n\t\t\tif (response) {\n\t\t\t\treturn response;\n\t\t\t}\n\n\t\t\t// if there's no cache, then just error out\n\t\t\t// as there is nothing we can do to respond to this request\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tevent.respondWith(respond());\n});\n```\n\n> [!NOTE] Be careful when caching! In some cases, stale data might be worse than data that's unavailable while offline. Since browsers will empty caches if they get too full, you should also be careful about caching large assets like video files.\n\n## During development\n\nThe service worker is bundled for production, but not during development. For that reason, only browsers that support [modules in service workers](https://web.dev/es-modules-in-sw) will be able to use them at dev time. If you are manually registering your service worker, you will need to pass the `{ type: 'module' }` option in development:\n\n```js\nimport { dev } from '$app/environment';\n\nnavigator.serviceWorker.register('/service-worker.js', {\n\ttype: dev ? 'module' : 'classic'\n});\n```\n\n> [!NOTE] `build` and `prerendered` are empty arrays during development\n\n## Other solutions\n\nSvelteKit's service worker implementation is designed to be easy to work with and is probably a good solution for most users. However, outside of SvelteKit, many PWA applications leverage the [Workbox](https://web.dev/learn/pwa/workbox) library. If you're used to using Workbox you may prefer [Vite PWA plugin](https://vite-pwa-org.netlify.app/frameworks/sveltekit.html).\n\n## References\n\nFor more general information on service workers, we recommend [the MDN web docs](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers).\n"
  },
  {
    "path": "documentation/docs/30-advanced/50-server-only-modules.md",
    "content": "---\ntitle: Server-only modules\n---\n\nLike a good friend, SvelteKit keeps your secrets. When writing your backend and frontend in the same repository, it can be easy to accidentally import sensitive data into your front-end code (environment variables containing API keys, for example). SvelteKit provides a way to prevent this entirely: server-only modules.\n\n## Private environment variables\n\nThe [`$env/static/private`]($env-static-private) and [`$env/dynamic/private`]($env-dynamic-private) modules can only be imported into modules that only run on the server, such as [`hooks.server.js`](hooks#Server-hooks) or [`+page.server.js`](routing#page-page.server.js).\n\n## Server-only utilities\n\nThe [`$app/server`]($app-server) module, which contains a [`read`]($app-server#read) function for reading assets from the filesystem, can likewise only be imported by code that runs on the server.\n\n## Your modules\n\nYou can make your own modules server-only in two ways:\n\n- adding `.server` to the filename, e.g. `secrets.server.js`\n- placing them in `$lib/server`, e.g. `$lib/server/secrets.js`\n\n## How it works\n\nAny time you have public-facing code that imports server-only code (whether directly or indirectly)...\n\n```js\n// @errors: 7005\n/// file: $lib/server/secrets.js\nexport const atlantisCoordinates = [/* redacted */];\n```\n\n```js\n// @errors: 2307 7006 7005\n/// file: src/routes/utils.js\nexport { atlantisCoordinates } from '$lib/server/secrets.js';\n\nexport const add = (a, b) => a + b;\n```\n\n```html\n/// file: src/routes/+page.svelte\n<script>\n\timport { add } from './utils.js';\n</script>\n```\n\n...SvelteKit will error:\n\n```\nCannot import $lib/server/secrets.ts into code that runs in the browser, as this could leak sensitive information.\n\n src/routes/+page.svelte imports\n  src/routes/utils.js imports\n   $lib/server/secrets.ts\n\nIf you're only using the import as a type, change it to `import type`.\n```\n\nEven though the public-facing code — `src/routes/+page.svelte` — only uses the `add` export and not the secret `atlantisCoordinates` export, the secret code could end up in JavaScript that the browser downloads, and so the import chain is considered unsafe.\n\nThis feature also works with dynamic imports, even interpolated ones like ``await import(`./${foo}.js`)``.\n\n> [!NOTE] Unit testing frameworks like Vitest do not distinguish between server-only and public-facing code. For this reason, illegal import detection is disabled when running tests, as determined by `process.env.TEST === 'true'`.\n\n## Further reading\n\n- [Tutorial: Environment variables](/tutorial/kit/env-static-private)\n"
  },
  {
    "path": "documentation/docs/30-advanced/65-snapshots.md",
    "content": "---\ntitle: Snapshots\n---\n\nEphemeral DOM state — like scroll positions on sidebars, the content of `<input>` elements and so on — is discarded when you navigate from one page to another.\n\nFor example, if the user fills out a form but navigates away and then back before submitting, or if the user refreshes the page, the values they filled in will be lost. In cases where it's valuable to preserve that input, you can take a _snapshot_ of DOM state, which can then be restored if the user navigates back.\n\nTo do this, export a `snapshot` object with `capture` and `restore` methods from a `+page.svelte` or `+layout.svelte`:\n\n```svelte\n<!--- file: +page.svelte --->\n<script>\n\tlet comment = $state('');\n\n\t/** @type {import('./$types').Snapshot<string>} */\n\texport const snapshot = {\n\t\tcapture: () => comment,\n\t\trestore: (value) => comment = value\n\t};\n</script>\n\n<form method=\"POST\">\n\t<label for=\"comment\">Comment</label>\n\t<textarea id=\"comment\" bind:value={comment} />\n\t<button>Post comment</button>\n</form>\n```\n\nWhen you navigate away from this page, the `capture` function is called immediately before the page updates, and the returned value is associated with the current entry in the browser's history stack. If you navigate back, the `restore` function is called with the stored value as soon as the page is updated.\n\nThe data must be serializable as JSON so that it can be persisted to `sessionStorage`. This allows the state to be restored when the page is reloaded, or when the user navigates back from a different site.\n\n> [!NOTE] Avoid returning very large objects from `capture` — once captured, objects will be retained in memory for the duration of the session, and in extreme cases may be too large to persist to `sessionStorage`.\n"
  },
  {
    "path": "documentation/docs/30-advanced/67-shallow-routing.md",
    "content": "---\ntitle: Shallow routing\n---\n\nAs you navigate around a SvelteKit app, you create _history entries_. Clicking the back and forward buttons traverses through this list of entries, re-running any `load` functions and replacing page components as necessary.\n\nSometimes, it's useful to create history entries _without_ navigating. For example, you might want to show a modal dialog that the user can dismiss by navigating back. This is particularly valuable on mobile devices, where swipe gestures are often more natural than interacting directly with the UI. In these cases, a modal that is _not_ associated with a history entry can be a source of frustration, as a user may swipe backwards in an attempt to dismiss it and find themselves on the wrong page.\n\nSvelteKit makes this possible with the [`pushState`]($app-navigation#pushState) and [`replaceState`]($app-navigation#replaceState) functions, which allow you to associate state with a history entry without navigating. For example, to implement a history-driven modal:\n\n```svelte\n<!--- file: +page.svelte --->\n<script>\n\timport { pushState } from '$app/navigation';\n\timport { page } from '$app/state';\n\timport Modal from './Modal.svelte';\n\n\tfunction showModal() {\n\t\tpushState('', {\n\t\t\tshowModal: true\n\t\t});\n\t}\n</script>\n\n{#if page.state.showModal}\n\t<Modal close={() => history.back()} />\n{/if}\n```\n\nThe modal can be dismissed by navigating back (unsetting `page.state.showModal`) or by interacting with it in a way that causes the `close` callback to run, which will navigate back programmatically.\n\n## API\n\nThe first argument to `pushState` is the URL, relative to the current URL. To stay on the current URL, use `''`.\n\nThe second argument is the new page state, which can be accessed via the [page object]($app-state#page) as `page.state`. You can make page state type-safe by declaring an [`App.PageState`](types#PageState) interface (usually in `src/app.d.ts`).\n\nTo set page state without creating a new history entry, use `replaceState` instead of `pushState`.\n\n> [!LEGACY]\n> `page.state` from `$app/state` was added in SvelteKit 2.12. If you're using an earlier version or are using Svelte 4, use `$page.state` from `$app/stores` instead.\n\n## Loading data for a route\n\nWhen shallow routing, you may want to render another `+page.svelte` inside the current page. For example, clicking on a photo thumbnail could pop up the detail view without navigating to the photo page.\n\nFor this to work, you need to load the data that the `+page.svelte` expects. A convenient way to do this is to use [`preloadData`]($app-navigation#preloadData) inside the `click` handler of an `<a>` element. If the element (or a parent) uses [`data-sveltekit-preload-data`](link-options#data-sveltekit-preload-data), the data will have already been requested, and `preloadData` will reuse that request.\n\n```svelte\n<!--- file: src/routes/photos/+page.svelte --->\n<script>\n\timport { preloadData, pushState, goto } from '$app/navigation';\n\timport { page } from '$app/state';\n\timport Modal from './Modal.svelte';\n\timport PhotoPage from './[id]/+page.svelte';\n\n\tlet { data } = $props();\n</script>\n\n{#each data.thumbnails as thumbnail}\n\t<a\n\t\thref=\"/photos/{thumbnail.id}\"\n\t\tonclick={async (e) => {\n\t\t\tif (innerWidth < 640        // bail if the screen is too small\n\t\t\t\t|| e.shiftKey             // or the link is opened in a new window\n\t\t\t\t|| e.metaKey || e.ctrlKey // or a new tab (mac: metaKey, win/linux: ctrlKey)\n\t\t\t\t// should also consider clicking with a mouse scroll wheel\n\t\t\t) return;\n\n\t\t\t// prevent navigation\n\t\t\te.preventDefault();\n\n\t\t\tconst { href } = e.currentTarget;\n\n\t\t\t// run `load` functions (or rather, get the result of the `load` functions\n\t\t\t// that are already running because of `data-sveltekit-preload-data`)\n\t\t\tconst result = await preloadData(href);\n\n\t\t\tif (result.type === 'loaded' && result.status === 200) {\n\t\t\t\tpushState(href, { selected: result.data });\n\t\t\t} else {\n\t\t\t\t// something bad happened! try navigating\n\t\t\t\tgoto(href);\n\t\t\t}\n\t\t}}\n\t>\n\t\t<img alt={thumbnail.alt} src={thumbnail.src} />\n\t</a>\n{/each}\n\n{#if page.state.selected}\n\t<Modal onclose={() => history.back()}>\n\t\t<!-- pass page data to the +page.svelte component,\n\t\t     just like SvelteKit would on navigation -->\n\t\t<PhotoPage data={page.state.selected} />\n\t</Modal>\n{/if}\n```\n\n## Caveats\n\nDuring server-side rendering, `page.state` is always an empty object. The same is true for the first page the user lands on — if the user reloads the page (or returns from another document), state will _not_ be applied until they navigate.\n\nShallow routing is a feature that requires JavaScript to work. Be mindful when using it and try to think of sensible fallback behavior in case JavaScript isn't available.\n"
  },
  {
    "path": "documentation/docs/30-advanced/68-observability.md",
    "content": "---\ntitle: Observability\n---\n\n<blockquote class=\"since note\">\n\t<p>Available since 2.31</p>\n</blockquote>\n\nSometimes, you may need to observe how your application is behaving in order to improve performance or find the root cause of a pesky bug. To help with this, SvelteKit can emit server-side [OpenTelemetry](https://opentelemetry.io) spans for the following:\n\n- The [`handle`](hooks#Server-hooks-handle) hook and `handle` functions running in a [`sequence`](@sveltejs-kit-hooks#sequence) (these will show up as children of each other and the root `handle` hook)\n- Server [`load`](load) functions and universal `load` functions when they're run on the server\n- [Form actions](form-actions)\n- [Remote functions](remote-functions)\n\nJust telling SvelteKit to emit spans won't get you far, though — you need to actually collect them somewhere to be able to view them. SvelteKit provides `src/instrumentation.server.ts` as a place to write your tracing setup and instrumentation code. It's guaranteed to be run prior to your application code being imported, providing your deployment platform supports it and your adapter is aware of it.\n\nBoth of these features are currently experimental, meaning they are likely to contain bugs and are subject to change without notice. You must opt in by adding the `kit.experimental.tracing.server` and `kit.experimental.instrumentation.server` option in your `svelte.config.js`:\n\n```js\n/// file: svelte.config.js\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\texperimental: {\n\t\t\t+++tracing: {\n\t\t\t\tserver: true\n\t\t\t},\n\t\t\tinstrumentation: {\n\t\t\t\tserver: true\n\t\t\t}+++\n\t\t}\n\t}\n};\n\nexport default config;\n```\n\n> [!NOTE] Tracing — and more significantly, observability instrumentation — can have a nontrivial overhead. Before you go all-in on tracing, consider whether or not you really need it, or if it might be more appropriate to turn it on in development and preview environments only.\n\n## Augmenting the built-in tracing\n\nSvelteKit provides access to the `root` span and the `current` span on the request event. The root span is the one associated with your root `handle` function, and the current span could be associated with `handle`, `load`, a form action, or a remote function, depending on the context. You can annotate these spans with any attributes you wish to record:\n\n```js\n/// file: $lib/authenticate.ts\n\n// @filename: ambient.d.ts\ndeclare module '$lib/auth-core' {\n\texport function getAuthenticatedUser(): Promise<{ id: string }>\n}\n\n// @filename: index.js\n// ---cut---\nimport { getRequestEvent } from '$app/server';\nimport { getAuthenticatedUser } from '$lib/auth-core';\n\nasync function authenticate() {\n\tconst user = await getAuthenticatedUser();\n\tconst event = getRequestEvent();\n\tevent.tracing.root.setAttribute('userId', user.id);\n}\n```\n\n## Development quickstart\n\nTo view your first trace, you'll need to set up a local collector. We'll use [Jaeger](https://www.jaegertracing.io/docs/getting-started/) in this example, as they provide an easy-to-use quickstart command. Once your collector is running locally:\n\n- Turn on the experimental flags mentioned earlier in your `svelte.config.js` file\n- Use your package manager to install the dependencies you'll need:\n  ```sh\n  npm i @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node @opentelemetry/exporter-trace-otlp-proto import-in-the-middle\n  ```\n- Create `src/instrumentation.server.js` with the following:\n\n```js\n/// file: src/instrumentation.server.js\nimport { NodeSDK } from '@opentelemetry/sdk-node';\nimport { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';\nimport { createAddHookMessageChannel } from 'import-in-the-middle';\nimport { register } from 'node:module';\n\nconst { registerOptions } = createAddHookMessageChannel();\nregister('import-in-the-middle/hook.mjs', import.meta.url, registerOptions);\n\nconst sdk = new NodeSDK({\n\tserviceName: 'test-sveltekit-tracing',\n\ttraceExporter: new OTLPTraceExporter(),\n\tinstrumentations: [getNodeAutoInstrumentations()]\n});\n\nsdk.start();\n```\n\nNow, server-side requests will begin generating traces, which you can view in Jaeger's web console at [localhost:16686](http://localhost:16686).\n\n## `@opentelemetry/api`\n\nSvelteKit uses `@opentelemetry/api` to generate its spans. This is declared as an optional peer dependency so that users not needing traces see no impact on install size or runtime performance. In most cases, if you're configuring your application to collect SvelteKit's spans, you'll end up installing a library like `@opentelemetry/sdk-node` or `@vercel/otel`, which in turn depend on `@opentelemetry/api`, which will satisfy SvelteKit's dependency as well. If you see an error from SvelteKit telling you it can't find `@opentelemetry/api`, it may just be because you haven't set up your trace collection yet. If you _have_ done that and are still seeing the error, you can install `@opentelemetry/api` yourself. \n"
  },
  {
    "path": "documentation/docs/30-advanced/70-packaging.md",
    "content": "---\ntitle: Packaging\n---\n\nYou can use SvelteKit to build apps as well as component libraries, using the `@sveltejs/package` package (`npx sv create` has an option to set this up for you).\n\nWhen you're creating an app, the contents of `src/routes` is the public-facing stuff; [`src/lib`]($lib) contains your app's internal library.\n\nA component library has the exact same structure as a SvelteKit app, except that `src/lib` is the public-facing bit, and your root `package.json` is used to publish the package. `src/routes` might be a documentation or demo site that accompanies the library, or it might just be a sandbox you use during development.\n\nRunning the `svelte-package` command from `@sveltejs/package` will take the contents of `src/lib` and generate a `dist` directory (which can be [configured](#Options)) containing the following:\n\n- All the files in `src/lib`. Svelte components will be preprocessed, TypeScript files will be transpiled to JavaScript.\n- Type definitions (`d.ts` files) which are generated for Svelte, JavaScript and TypeScript files. You need to install `typescript >= 4.0.0` for this. Type definitions are placed next to their implementation, hand-written `d.ts` files are copied over as is. You can [disable generation](#Options), but we strongly recommend against it — people using your library might use TypeScript, for which they require these type definition files.\n\n> [!NOTE] `@sveltejs/package` version 1 generated a `package.json`. This is no longer the case and it will now use the `package.json` from your project and validate that it is correct instead. If you're still on version 1, see [this PR](https://github.com/sveltejs/kit/pull/8922) for migration instructions.\n\n## Anatomy of a package.json\n\nSince you're now building a library for public use, the contents of your `package.json` will become more important. Through it, you configure the entry points of your package, which files are published to npm, and which dependencies your library has. Let's go through the most important fields one by one.\n\n### name\n\nThis is the name of your package. It will be available for others to install using that name, and visible on `https://npmjs.com/package/<name>`.\n\n```json\n{\n\t\"name\": \"your-library\"\n}\n```\n\nRead more about it [here](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#name).\n\n### license\n\nEvery package should have a license field so people know how they are allowed to use it. A very popular license which is also very permissive in terms of distribution and reuse without warranty is `MIT`.\n\n```json\n{\n\t\"license\": \"MIT\"\n}\n```\n\nRead more about it [here](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#license). Note that you should also include a `LICENSE` file in your package.\n\n### files\n\nThis tells npm which files it will pack up and upload to npm. It should contain your output folder (`dist` by default). Your `package.json` and `README` and `LICENSE` will always be included, so you don't need to specify them.\n\n```json\n{\n\t\"files\": [\"dist\"]\n}\n```\n\nTo exclude unnecessary files (such as unit tests, or modules that are only imported from `src/routes` etc) you can add them to an `.npmignore` file. This will result in smaller packages that are faster to install.\n\nRead more about it [here](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#files).\n\n### exports\n\nThe `\"exports\"` field contains the package's entry points. If you set up a new library project through `npx sv create`, it's set to a single export, the package root:\n\n```json\n{\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n```\n\nThis tells bundlers and tooling that your package only has one entry point, the root, and everything should be imported through that, like this:\n\n```js\n// @errors: 2307\nimport { Something } from 'your-library';\n```\n\nThe `types` and `svelte` keys are [export conditions](https://nodejs.org/api/packages.html#conditional-exports). They tell tooling what file to import when they look up the `your-library` import:\n\n- TypeScript sees the `types` condition and looks up the type definition file. If you don't publish type definitions, omit this condition.\n- Svelte-aware tooling sees the `svelte` condition and knows this is a Svelte component library. If you publish a library that does not export any Svelte components and that could also work in non-Svelte projects (for example a Svelte store library), you can replace this condition with `default`.\n\n> [!NOTE] Previous versions of `@sveltejs/package` also added a `package.json` export. This is no longer part of the template because all tooling can now deal with a `package.json` not being explicitly exported.\n\nYou can adjust `exports` to your liking and provide more entry points. For example, if instead of a `src/lib/index.js` file that re-exported components you wanted to expose a `src/lib/Foo.svelte` component directly, you could create the following export map...\n\n```json\n{\n\t\"exports\": {\n\t\t\"./Foo.svelte\": {\n\t\t\t\"types\": \"./dist/Foo.svelte.d.ts\",\n\t\t\t\"svelte\": \"./dist/Foo.svelte\"\n\t\t}\n\t}\n}\n```\n\n...and a consumer of your library could import the component like so:\n\n```js\n// @filename: ambient.d.ts\ndeclare module 'your-library/Foo.svelte';\n\n// @filename: index.js\n// ---cut---\nimport Foo from 'your-library/Foo.svelte';\n```\n\n> [!NOTE] Beware that doing this will need additional care if you provide type definitions. Read more about the caveat [here](#TypeScript)\n\nIn general, each key of the exports map is the path the user will have to use to import something from your package, and the value is the path to the file that will be imported or a map of export conditions which in turn contains these file paths.\n\nRead more about `exports` [here](https://nodejs.org/docs/latest-v18.x/api/packages.html#package-entry-points).\n\n### svelte\n\nThis is a legacy field that enabled tooling to recognise Svelte component libraries. It's no longer necessary when using the `svelte` [export condition](#Anatomy-of-a-package.json-exports), but for backwards compatibility with outdated tooling that doesn't yet know about export conditions it's good to keep it around. It should point towards your root entry point.\n\n```json\n{\n\t\"svelte\": \"./dist/index.js\"\n}\n```\n\n### sideEffects\n\nThe `sideEffects` field in `package.json` is used by bundlers to determine if a module may contain code that has side effects. A module is considered to have side effects if it makes changes that are observable from other scripts outside the module when it's imported. For example, side effects include modifying global variables or the prototype of built-in JavaScript objects. Because a side effect could potentially affect the behavior of other parts of the application, these files/modules will be included in the final bundle regardless of whether their exports are used in the application. It is a best practice to avoid side effects in your code.\n\nSetting the `sideEffects` field in `package.json` can help the bundler to be more aggressive in eliminating unused exports from the final bundle, a process known as tree-shaking. This results in smaller and more efficient bundles. Different bundlers handle `sideEffects` in various manners. While not necessary for Vite, we recommend that libraries state that all CSS files have side effects so that your library will be [compatible with webpack](https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free). This is the configuration that comes with newly created projects:\n\n```json\n/// file: package.json\n{\n\t\"sideEffects\": [\"**/*.css\"]\n}\n```\n\n> [!NOTE] If the scripts in your library have side effects, ensure that you update the `sideEffects` field. All scripts are marked as side effect free by default in newly created projects. If a file with side effects is incorrectly marked as having no side effects, it can result in broken functionality.\n\nIf your package has files with side effects, you can specify them in an array:\n\n```json\n/// file: package.json\n{\n    \"sideEffects\": [\n    \t\"**/*.css\",\n    \t\"./dist/sideEffectfulFile.js\"\n    ]\n}\n```\n\nThis will treat only the specified files as having side effects.\n\n## TypeScript\n\nYou should ship type definitions for your library even if you don't use TypeScript yourself so that people who do get proper intellisense when using your library. `@sveltejs/package` makes the process of generating types mostly opaque to you. By default, when packaging your library, type definitions are auto-generated for JavaScript, TypeScript and Svelte files. All you need to ensure is that the `types` condition in the [exports](#Anatomy-of-a-package.json-exports) map points to the correct files. When initialising a library project through `npx sv create`, this is automatically set up for the root export.\n\nIf you have something else than a root export however — for example providing a `your-library/foo` import — you need to take additional care for providing type definitions. Unfortunately, TypeScript by default will _not_ resolve the `types` condition for an export like `{ \"./foo\": { \"types\": \"./dist/foo.d.ts\", ... }}`. Instead, it will search for a `foo.d.ts` relative to the root of your library (i.e. `your-library/foo.d.ts` instead of `your-library/dist/foo.d.ts`). To fix this, you have two options:\n\nThe first option is to require people using your library to set the `moduleResolution` option in their `tsconfig.json` (or `jsconfig.json`) to `bundler` (available since TypeScript 5, the best and recommended option in the future), `node16` or `nodenext`. This opts TypeScript into actually looking at the exports map and resolving the types correctly.\n\nThe second option is to (ab)use the `typesVersions` feature from TypeScript to wire up the types. This is a field inside `package.json` TypeScript uses to check for different type definitions depending on the TypeScript version, and also contains a path mapping feature for that. We leverage that path mapping feature to get what we want. For the mentioned `foo` export above, the corresponding `typesVersions` looks like this:\n\n```json\n{\n\t\"exports\": {\n\t\t\"./foo\": {\n\t\t\t\"types\": \"./dist/foo.d.ts\",\n\t\t\t\"svelte\": \"./dist/foo.js\"\n\t\t}\n\t},\n\t\"typesVersions\": {\n\t\t\">4.0\": {\n\t\t\t\"foo\": [\"./dist/foo.d.ts\"]\n\t\t}\n\t}\n}\n```\n\n`>4.0` tells TypeScript to check the inner map if the used TypeScript version is greater than 4 (which should in practice always be true). The inner map tells TypeScript that the typings for `your-library/foo` are found within `./dist/foo.d.ts`, which essentially replicates the `exports` condition. You also have `*` as a wildcard at your disposal to make many type definitions at once available without repeating yourself. Note that if you opt into `typesVersions` you have to declare all type imports through it, including the root import (which is defined as `\"index.d.ts\": [..]`).\n\nYou can read more about that feature [here](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#version-selection-with-typesversions).\n\n## Best practices\n\nYou should avoid using SvelteKit-specific modules like `$app/environment` in your packages unless you intend for them to only be consumable by other SvelteKit projects. E.g. rather than using `import { browser } from '$app/environment'` you could use `import { BROWSER } from 'esm-env'` ([see esm-env docs](https://github.com/benmccann/esm-env)). You may also wish to pass in things like the current URL or a navigation action as a prop rather than relying directly on `$app/state`, `$app/navigation`, etc. Writing your app in this more generic fashion will also make it easier to set up tools for testing, UI demos and so on.\n\nEnsure that you add [aliases](configuration#alias) via `svelte.config.js` (not `vite.config.js` or `tsconfig.json`), so that they are processed by `svelte-package`.\n\nYou should think carefully about whether or not the changes you make to your package are a bug fix, a new feature, or a breaking change, and update the package version accordingly. Note that if you remove any paths from `exports` or any `export` conditions inside them from your existing library, that should be regarded as a breaking change.\n\n```json\n{\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n// changing `svelte` to `default` is a breaking change:\n---\t\t\t\"svelte\": \"./dist/index.js\"---\n+++\t\t\t\"default\": \"./dist/index.js\"+++\n\t\t},\n// removing this is a breaking change:\n---\t\t\"./foo\": {\n\t\t\t\"types\": \"./dist/foo.d.ts\",\n\t\t\t\"svelte\": \"./dist/foo.js\",\n\t\t\t\"default\": \"./dist/foo.js\"\n\t\t},---\n// adding this is ok:\n+++\t\t\"./bar\": {\n\t\t\t\"types\": \"./dist/bar.d.ts\",\n\t\t\t\"svelte\": \"./dist/bar.js\",\n\t\t\t\"default\": \"./dist/bar.js\"\n\t\t}+++\n\t}\n}\n```\n\n## Source maps\n\nYou can create so-called declaration maps (`d.ts.map` files) by setting `\"declarationMap\": true` in your `tsconfig.json`. This will allow editors such as VS Code to go to the original `.ts` or `.svelte` file when using features like _Go to Definition_. This means you also need to publish your source files alongside your dist folder in a way that the relative path inside the declaration files leads to a file on disk. Assuming that you have all your library code inside `src/lib` as suggested by Svelte's CLI, this is as simple as adding `src/lib` to `files` in your `package.json`:\n\n```json\n{\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"!dist/**/*.test.*\",\n\t\t\"!dist/**/*.spec.*\",\n\t\t+++\"src/lib\",\n\t\t\"!src/lib/**/*.test.*\",\n\t\t\"!src/lib/**/*.spec.*\"+++\n\t]\n}\n```\n\n## Options\n\n`svelte-package` accepts the following options:\n\n- `-w`/`--watch` — watch files in `src/lib` for changes and rebuild the package\n- `-i`/`--input` — the input directory which contains all the files of the package. Defaults to `src/lib`\n- `-o`/`--output` — the output directory where the processed files are written to. Your `package.json`'s `exports` should point to files inside there, and the `files` array should include that folder. Defaults to `dist`\n- `-p`/`--preserve-output` — prevent deletion of the output directory before packaging. Defaults to `false`, which means that the output directory will be emptied first\n- `-t`/`--types` — whether or not to create type definitions (`d.ts` files). We strongly recommend doing this as it fosters ecosystem library quality. Defaults to `true`\n- `--tsconfig` - the path to a tsconfig or jsconfig. When not provided, searches for the next upper tsconfig/jsconfig in the workspace path.\n\n## Publishing\n\nTo publish the generated package:\n\n```sh\nnpm publish\n```\n\n## Caveats\n\nAll relative file imports need to be fully specified, adhering to Node's ESM algorithm. This means that for a file like `src/lib/something/index.js`, you must include the filename with the extension:\n\n```js\n// @errors: 2307\nimport { something } from './something+++/index.js+++';\n```\n\nIf you are using TypeScript, you need to import `.ts` files the same way, but using a `.js` file ending, _not_ a `.ts` file ending. (This is a TypeScript design decision outside our control.) Setting `\"moduleResolution\": \"NodeNext\"` in your `tsconfig.json` or `jsconfig.json` will help you with this.\n\nAll files except Svelte files (preprocessed) and TypeScript files (transpiled to JavaScript) are copied across as-is.\n"
  },
  {
    "path": "documentation/docs/30-advanced/index.md",
    "content": "---\ntitle: Advanced\n---\n"
  },
  {
    "path": "documentation/docs/40-best-practices/03-auth.md",
    "content": "---\ntitle: Auth\n---\n\nAuth refers to authentication and authorization, which are common needs when building a web application. Authentication means verifying that the user is who they say they are based on their provided credentials. Authorization means determining which actions they are allowed to take.\n\n## Sessions vs tokens\n\nAfter the user has provided their credentials such as a username and password, we want to allow them to use the application without needing to provide their credentials again for future requests. Users are commonly authenticated on subsequent requests with either a session identifier or signed token such as a JSON Web Token (JWT).\n\nSession IDs are most commonly stored in a database. They can be immediately revoked, but require a database query to be made on each request.\n\nIn contrast, JWT generally are not checked against a datastore, which means they cannot be immediately revoked. The advantage of this method is improved latency and reduced load on your datastore.\n\n## Integration points\n\nAuth [cookies](@sveltejs-kit#Cookies) can be checked inside [server hooks](hooks#Server-hooks). If a user is found matching the provided credentials, the user information can be stored in [`locals`](hooks#Server-hooks-locals).\n\n## Libraries\n\nThe [Svelte CLI](/docs/cli) gives the option to [set up Better Auth](https://svelte.dev/docs/cli/better-auth) with a new project or add it to an existing project.\n\n## Guides\n\nIf you'd like to implement your own auth system, [the Lucia auth guide](https://lucia-auth.com/) provides a reference for session-based web app auth with SvelteKit examples.\n"
  },
  {
    "path": "documentation/docs/40-best-practices/05-performance.md",
    "content": "---\ntitle: Performance\n---\n\nOut of the box, SvelteKit does a lot of work to make your applications as performant as possible:\n\n- Code-splitting, so that only the code you need for the current page is loaded\n- Asset preloading, so that 'waterfalls' (of files requesting other files) are prevented\n- File hashing, so that your assets can be cached forever\n- Request coalescing, so that data fetched from separate server `load` functions is grouped into a single HTTP request\n- Parallel loading, so that separate universal `load` functions fetch data simultaneously\n- Data inlining, so that requests made with `fetch` during server rendering can be replayed in the browser without issuing a new request\n- Conservative invalidation, so that `load` functions are only re-run when necessary\n- Prerendering (configurable on a per-route basis, if necessary) so that pages without dynamic data can be served instantaneously\n- Link preloading, so that data and code requirements for a client-side navigation are eagerly anticipated\n\nNevertheless, we can't (yet) eliminate all sources of slowness. To eke out maximum performance, you should be mindful of the following tips.\n\n## Diagnosing issues\n\nGoogle's [PageSpeed Insights](https://pagespeed.web.dev/) and (for more advanced analysis) [WebPageTest](https://www.webpagetest.org/) are excellent ways to understand the performance characteristics of a site that is already deployed to the internet.\n\nYour browser also includes useful developer tools for analysing your site, whether deployed or running locally:\n\n* Chrome - [Lighthouse](https://developer.chrome.com/docs/lighthouse/overview#devtools), [Network](https://developer.chrome.com/docs/devtools/network), and [Performance](https://developer.chrome.com/docs/devtools/performance) devtools\n* Edge - [Lighthouse](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/lighthouse/lighthouse-tool), [Network](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/network/), and [Performance](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/evaluate-performance/) devtools\n* Firefox - [Network](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/) and [Performance](https://hacks.mozilla.org/2022/03/performance-tool-in-firefox-devtools-reloaded/) devtools\n* Safari - [enhancing the performance of your webpage](https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/Web_Inspector_Tutorial/EnhancingyourWebpagesPerformance/EnhancingyourWebpagesPerformance.html)\n\nNote that your site running locally in `dev` mode will exhibit different behaviour than your production app, so you should do performance testing in [preview](building-your-app#Preview-your-app) mode after building.\n\n### Instrumenting\n\nIf you see in the network tab of your browser that an API call is taking a long time and you'd like to understand why, you may consider instrumenting your backend with a tool like [OpenTelemetry](https://opentelemetry.io/) or [Server-Timing headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing).\n\n## Optimizing assets\n\n### Images\n\nReducing the size of image files is often one of the most impactful changes you can make to a site's performance. Svelte provides the `@sveltejs/enhanced-img` package, detailed on the [images](images) page, for making this easier. Additionally, Lighthouse is useful for identifying the worst offenders.\n\n### Videos\n\nVideo files can be very large, so extra care should be taken to ensure that they're optimized:\n\n- Compress videos with tools such as [Handbrake](https://handbrake.fr/). Consider converting the videos to web-friendly formats such as `.webm` or `.mp4`.\n- You can [lazy-load videos](https://web.dev/articles/lazy-loading-video) located below the fold with `preload=\"none\"` (though note that this will slow down playback when the user _does_ initiate it).\n- Strip the audio track out of muted videos using a tool like [FFmpeg](https://ffmpeg.org/).\n\n### Fonts\n\nSvelteKit automatically preloads critical `.js` and `.css` files when the user visits a page, but it does _not_ preload fonts by default, since this may cause unnecessary files (such as font weights that are referenced by your CSS but not actually used on the current page) to be downloaded. Having said that, preloading fonts correctly can make a big difference to how fast your site feels. In your [`handle`](hooks#Server-hooks-handle) hook, you can call `resolve` with a `preload` filter that includes your fonts.\n\nYou can reduce the size of font files by [subsetting](https://web.dev/learn/performance/optimize-web-fonts#subset_your_web_fonts) your fonts.\n\n## Reducing code size\n\n### Svelte version\n\nWe recommend running the latest version of Svelte. Svelte 5 is smaller and faster than Svelte 4, which is smaller and faster than Svelte 3.\n\n### Packages\n\n[`rollup-plugin-visualizer`](https://www.npmjs.com/package/rollup-plugin-visualizer) can be helpful for identifying which packages are contributing the most to the size of your site. You may also find opportunities to remove code by manually inspecting the build output (use `build: { minify: false }` in your [Vite config](https://vitejs.dev/config/build-options.html#build-minify) to make the output readable, but remember to undo that before deploying your app), or via the network tab of your browser's devtools.\n\n### External scripts\n\nTry to minimize the number of third-party scripts running in the browser. For example, instead of using JavaScript-based analytics consider using server-side implementations, such as those offered by many platforms with SvelteKit adapters including [Cloudflare](https://www.cloudflare.com/web-analytics/), [Netlify](https://docs.netlify.com/monitor-sites/site-analytics/), and [Vercel](https://vercel.com/docs/analytics).\n\nTo run third party scripts in a web worker (which avoids blocking the main thread), use [Partytown's SvelteKit integration](https://partytown.builder.io/sveltekit).\n\n### Selective loading\n\nCode imported with static `import` declarations will be automatically bundled with the rest of your page. If there is a piece of code you need only when some condition is met, use the dynamic `import(...)` form to selectively lazy-load the component.\n\n## Navigation\n\n### Preloading\n\nYou can speed up client-side navigations by eagerly preloading the necessary code and data, using [link options](link-options). This is configured by default on the `<body>` element when you create a new SvelteKit app.\n\n### Non-essential data\n\nFor slow-loading data that isn't needed immediately, the object returned from your `load` function can contain promises rather than the data itself. For server `load` functions, this will cause the data to [stream](load#Streaming-with-promises) in after the navigation (or initial page load).\n\n### Preventing waterfalls\n\nOne of the biggest performance killers is what is referred to as a _waterfall_, which is a series of requests that is made sequentially. This can happen on the server or in the browser, but is especially costly when dealing with data that has to travel further or across slower networks, such as a mobile user making a call to a distant server.\n\nIn the browser, waterfalls can occur when your HTML kicks off request chains such as requesting JS which requests CSS which requests a background image and web font. SvelteKit will largely solve this class of problems for you by adding [`modulepreload`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/modulepreload) tags or headers, but you should view [the network tab in your devtools](#Diagnosing-issues) to check whether additional resources need to be preloaded.\n- Pay special attention to this if you use [web fonts](#Optimizing-assets-Fonts) since they need to be handled manually.\n- Enabling [single page app (SPA) mode](single-page-apps) will cause such waterfalls. With SPA mode, an empty page is generated, which fetches JavaScript, which ultimately loads and renders the page. This results in extra network round trips before a single pixel can be displayed.\n\nWaterfalls can also occur on calls to the backend whether made from the browser or server. E.g. if a universal `load` function makes an API call to fetch the current user, then uses the details from that response to fetch a list of saved items, and then uses _that_ response to fetch the details for each item, the browser will end up making multiple sequential requests. This is deadly for performance, especially for users that are physically located far from your backend.\n- Avoid this issue by using [server `load` functions](load#Universal-vs-server) to make requests to backend services that are dependencies from the server rather than from the browser. Note, however, that server `load` functions are also not immune to waterfalls (though they are much less costly since they rarely involve round trips with high latency). For example, if you query a database to get the current user and then use that data to make a second query for a list of saved items, it will typically be more performant to issue a single query with a database join.\n\n## Hosting\n\nYour frontend should be located in the same data center as your backend to minimize latency. For sites with no central backend, many SvelteKit adapters support deploying to the _edge_, which means handling each user's requests from a nearby server. This can reduce load times significantly. Some adapters even support [configuring deployment on a per-route basis](page-options#config). You should also consider serving images from a CDN (which are typically edge networks) — the hosts for many SvelteKit adapters will do this automatically.\n\nEnsure your host uses HTTP/2 or newer. Vite's code splitting creates numerous small files for improved cacheability, which results in excellent performance, but this does assume that your files can be loaded in parallel with HTTP/2.\n\n## Further reading\n\nFor the most part, building a performant SvelteKit app is the same as building any performant web app. You should be able to apply information from general performance resources such as [Core Web Vitals](https://web.dev/explore/learn-core-web-vitals) to any web experience you build.\n"
  },
  {
    "path": "documentation/docs/40-best-practices/06-icons.md",
    "content": "---\ntitle: Icons\n---\n\n## CSS\n\nA great way to use icons is to define them purely via CSS. Iconify offers support for [many popular icon sets](https://icon-sets.iconify.design/) that [can be included via CSS](https://iconify.design/docs/usage/css/). This method can also be used with popular CSS frameworks by leveraging the Iconify [Tailwind CSS plugin](https://iconify.design/docs/usage/css/tailwind/) or [UnoCSS plugin](https://iconify.design/docs/usage/css/unocss/). As opposed to libraries based on Svelte components, it doesn't require each icon to be imported into your `.svelte` file.\n\n## Svelte\n\nThere are many [icon libraries for Svelte](/packages#icons). When choosing an icon library, it is recommended to avoid those that provide a `.svelte` file per icon, as these libraries can have thousands of `.svelte` files which really slow down [Vite's dependency optimization](https://vite.dev/guide/dep-pre-bundling.html). This can become especially pathological if the icons are imported both via an umbrella import and subpath import [as described in the `vite-plugin-svelte` FAQ](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#what-is-going-on-with-vite-and-pre-bundling-dependencies).\n"
  },
  {
    "path": "documentation/docs/40-best-practices/07-images.md",
    "content": "---\ntitle: Images\n---\n\nImages can have a big impact on your app's performance. For best results, you should optimize them by doing the following:\n\n- generate optimal formats like `.avif` and `.webp`\n- create different sizes for different screens\n- ensure that assets can be cached effectively\n\nDoing this manually is tedious. There are a variety of techniques you can use, depending on your needs and preferences.\n\n## Vite's built-in handling\n\n[Vite will automatically process imported assets](https://vitejs.dev/guide/assets.html) for improved performance. This includes assets referenced via the CSS `url()` function. Hashes will be added to the filenames so that they can be cached, and assets smaller than `assetsInlineLimit` will be inlined. Vite's asset handling is most often used for images, but is also useful for video, audio, etc.\n\n```svelte\n<script>\n\timport logo from '$lib/assets/logo.png';\n</script>\n\n<img alt=\"The project logo\" src={logo} />\n```\n\n## @sveltejs/enhanced-img\n\n`@sveltejs/enhanced-img` is a plugin offered on top of Vite's built-in asset handling. It provides plug and play image processing that serves smaller file formats like `avif` or `webp`, automatically sets the intrinsic `width` and `height` of the image to avoid layout shift, creates images of multiple sizes for various devices, and strips EXIF data for privacy. It will work in any Vite-based project including, but not limited to, SvelteKit projects.\n\n> [!NOTE] As a build plugin, `@sveltejs/enhanced-img` can only optimize files located on your machine during the build process. If you have an image located elsewhere (such as a path served from your database, CMS, or backend), please read about [loading images dynamically from a CDN](#Loading-images-dynamically-from-a-CDN).\n\n### Setup\n\nInstall:\n\n```sh\nnpm i -D @sveltejs/enhanced-img\n```\n\nAdjust `vite.config.js`:\n\n```js\nimport { sveltekit } from '@sveltejs/kit/vite';\n+++import { enhancedImages } from '@sveltejs/enhanced-img';+++\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n\tplugins: [\n\t\t+++enhancedImages(), // must come before the SvelteKit plugin+++\n\t\tsveltekit()\n\t]\n});\n```\n\nBuilding will take longer on the first build due to the computational expense of transforming images. However, the build output will be cached in `./node_modules/.cache/imagetools` so that subsequent builds will be fast.\n\n### Basic usage\n\nUse in your `.svelte` components by using `<enhanced:img>` rather than `<img>` and referencing the image file with a [Vite asset import](https://vitejs.dev/guide/assets.html#static-asset-handling) path:\n\n```svelte\n<enhanced:img src=\"./path/to/your/image.jpg\" alt=\"An alt text\" />\n```\n\nAt build time, your `<enhanced:img>` tag will be replaced with an `<img>` wrapped by a `<picture>` providing multiple image types and sizes. It's only possible to downscale images without losing quality, which means that you should provide the highest resolution image that you need — smaller versions will be generated for the various device types that may request an image.\n\nYou should provide your image at 2x resolution for HiDPI displays (a.k.a. retina displays). `<enhanced:img>` will automatically take care of serving smaller versions to smaller devices.\n\n> [!NOTE] if you wish to use a [tag name CSS selector](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Basic_selectors#type_selectors) in your `<style>` block you will need to write `enhanced\\:img` to escape the colon in the tag name.\n\n### Dynamically choosing an image\n\nYou can also manually import an image asset and pass it to an `<enhanced:img>`. This is useful when you have a collection of static images and would like to dynamically choose one or [iterate over them](https://github.com/sveltejs/kit/blob/0ab1733e394b6310895a1d3bf0f126ce34531170/sites/kit.svelte.dev/src/routes/home/Showcase.svelte). In this case you will need to update both the `import` statement and `<img>` element as shown below to indicate you'd like process them.\n\n```svelte\n<script>\n\timport MyImage from './path/to/your/image.jpg?enhanced';\n</script>\n\n<enhanced:img src={MyImage} alt=\"some alt text\" />\n```\n\nYou can also use [Vite's `import.meta.glob`](https://vitejs.dev/guide/features.html#glob-import). Note that you will have to specify `enhanced` via a [custom query](https://vitejs.dev/guide/features.html#custom-queries):\n\n```svelte\n<script>\n\tconst imageModules = import.meta.glob(\n\t\t'/path/to/assets/*.{avif,AVIF,gif,GIF,heif,HEIF,jpeg,JPEG,jpg,JPG,png,PNG,tiff,TIFF,webp,WEBP}',\n\t\t{\n\t\t\teager: true,\n\t\t\tquery: {\n\t\t\t\tenhanced: true\n\t\t\t}\n\t\t}\n\t)\n</script>\n\n{#each Object.entries(imageModules) as [_path, module]}\n\t<enhanced:img src={module.default} alt=\"some alt text\" />\n{/each}\n```\n\n> [!NOTE] svg images are currently only supported statically\n\n### Intrinsic Dimensions\n\n`width` and `height` are optional as they can be inferred from the source image and will be automatically added when the `<enhanced:img>` tag is preprocessed. With these attributes, the browser can reserve the correct amount of space, preventing [layout shift](https://web.dev/articles/cls). If you'd like to use a different `width` and `height` you can style the image with CSS. Because the preprocessor adds a `width` and `height` for you, if you'd like one of the dimensions to be automatically calculated then you will need to specify that:\n\n```svelte\n<style>\n\t.hero-image img {\n\t\twidth: var(--size);\n\t\theight: auto;\n\t}\n</style>\n```\n\n### `srcset` and `sizes`\n\nIf you have a large image, such as a hero image taking the width of the design, you should specify `sizes` so that smaller versions are requested on smaller devices. E.g. if you have a 1280px image you may want to specify something like:\n\n```svelte\n<enhanced:img src=\"./image.png\" sizes=\"min(1280px, 100vw)\"/>\n```\n\nIf `sizes` is specified, `<enhanced:img>` will generate small images for smaller devices and populate the `srcset` attribute.\n\nThe smallest picture generated automatically will have a width of 540px. If you'd like smaller images or would otherwise like to specify custom widths, you can do that with the `w` query parameter:\n```svelte\n<enhanced:img\n  src=\"./image.png?w=1280;640;400\"\n  sizes=\"(min-width:1920px) 1280px, (min-width:1080px) 640px, (min-width:768px) 400px\"\n/>\n```\n\nIf `sizes` is not provided, then a HiDPI/Retina image and a standard resolution image will be generated. The image you provide should be 2x the resolution you wish to display so that the browser can display that image on devices with a high [device pixel ratio](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio).\n\n### Per-image transforms\n\nBy default, enhanced images will be transformed to more efficient formats. However, you may wish to apply other transforms such as a blur, quality, flatten, or rotate operation. You can run per-image transforms by appending a query string:\n\n```svelte\n<enhanced:img src=\"./path/to/your/image.jpg?blur=15\" alt=\"An alt text\" />\n```\n\n[See the imagetools repo for the full list of directives](https://github.com/JonasKruckenberg/imagetools/blob/main/docs/directives.md).\n\n## Loading images dynamically from a CDN\n\nIn some cases, the images may not be accessible at build time — e.g. they may live inside a content management system or elsewhere.\n\nUsing a content delivery network (CDN) can allow you to optimize these images dynamically, and provides more flexibility with regards to sizes, but it may involve some setup overhead and usage costs. Depending on caching strategy, the browser may not be able to use a cached copy of the asset until a [304 response](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304) is received from the CDN. Building HTML to target CDNs allows using an `<img>` tag since the CDN can serve the appropriate format based on the `User-Agent` header, whereas build-time optimizations must produce `<picture>` tags with multiple sources. Finally, some CDNs may generate images lazily, which could have a negative performance impact for sites with low traffic and frequently changing images.\n\nCDNs can generally be used without any need for a library. However, there are a number of libraries with Svelte support that make it easier. [`@unpic/svelte`](https://unpic.pics/img/svelte/) is a CDN-agnostic library with support for a large number of providers. You may also find that specific CDNs like [Cloudinary](https://svelte.cloudinary.dev/) have Svelte support. Finally, some content management systems (CMS) which support Svelte (such as [Contentful](https://www.contentful.com/sveltekit-starter-guide/), [Storyblok](https://www.storyblok.com/docs/guides/svelte), and [Contentstack](https://www.contentstack.com/docs/developers/sample-apps/build-a-starter-website-with-sveltekit-and-contentstack)) have built-in support for image handling.\n\n## Best practices\n\n- For each image type, use the appropriate solution from those discussed above. You can mix and match all three solutions in one project. For example, you may use Vite's built-in handling to provide images for `<meta>` tags, display images on your homepage with `@sveltejs/enhanced-img`, and display user-submitted content with a dynamic approach.\n- Consider serving all images via CDN regardless of the image optimization types you use. CDNs reduce latency by distributing copies of static assets globally.\n- Your original images should have a good quality/resolution and should have 2x the width it will be displayed at to serve HiDPI devices. Image processing can size images down to save bandwidth when serving smaller screens, but it would be a waste of bandwidth to invent pixels to size images up.\n- For images which are much larger than the width of a mobile device (roughly 400px), such as a hero image taking the width of the page design, specify `sizes` so that smaller images can be served on smaller devices.\n- For important images, such as the [largest contentful paint (LCP)](https://web.dev/articles/lcp) image, set `fetchpriority=\"high\"` and avoid `loading=\"lazy\"` to prioritize loading as early as possible.\n- Give the image a container or styling so that it is constrained and does not jump around while the page is loading affecting your [cumulative layout shift (CLS)](https://web.dev/articles/cls). `width` and `height` help the browser to reserve space while the image is still loading, so `@sveltejs/enhanced-img` will add a `width` and `height` for you.\n- Always provide a good `alt` text. The Svelte compiler will warn you if you don't do this.\n- Do not use `em` or `rem` in `sizes` and change the default size of these measures. When used in `sizes` or `@media` queries, `em` and `rem` are both defined to mean the user's default `font-size`. For a `sizes` declaration like `sizes=\"(min-width: 768px) min(100vw, 108rem), 64rem\"`, the actual `em` or `rem` that controls how the image is laid out on the page can be different if changed by CSS. For example, do not do something like `html { font-size: 62.5%; }` as the slot reserved by the browser preloader will now end up being larger than the actual slot of the CSS object model once it has been created.\n"
  },
  {
    "path": "documentation/docs/40-best-practices/10-accessibility.md",
    "content": "---\ntitle: Accessibility\n---\n\nSvelteKit strives to provide an accessible platform for your app by default. Svelte's [compile-time accessibility checks](../svelte/compiler-warnings) will also apply to any SvelteKit application you build.\n\nHere's how SvelteKit's built-in accessibility features work and what you need to do to help these features to work as well as possible. Keep in mind that while SvelteKit provides an accessible foundation, you are still responsible for making sure your application code is accessible. If you're new to accessibility, see the [\"further reading\"](accessibility#Further-reading) section of this guide for additional resources.\n\nWe recognize that accessibility can be hard to get right. If you want to suggest improvements to how SvelteKit handles accessibility, please [open a GitHub issue](https://github.com/sveltejs/kit/issues).\n\n## Route announcements\n\nIn traditional server-rendered applications, every navigation (e.g. clicking on an `<a>` tag) triggers a full page reload. When this happens, screen readers and other assistive technology will read out the new page's title so that users understand that the page has changed.\n\nSince navigation between pages in SvelteKit happens without reloading the page (known as [client-side routing](glossary#Routing)), SvelteKit injects a [live region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) onto the page that will read out the new page name after each navigation. This determines the page name to announce by inspecting the `<title>` element.\n\nBecause of this behavior, every page in your app should have a unique, descriptive title. In SvelteKit, you can do this by placing a `<svelte:head>` element on each page:\n\n```svelte\n<!--- file: src/routes/+page.svelte --->\n<svelte:head>\n\t<title>Todo List</title>\n</svelte:head>\n```\n\nThis will allow screen readers and other assistive technology to identify the new page after a navigation occurs. Providing a descriptive title is also important for [SEO](seo#Manual-setup-title-and-meta).\n\n## Focus management\n\nIn traditional server-rendered applications, every navigation will reset focus to the top of the page. This ensures that people browsing the web with a keyboard or screen reader will start interacting with the page from the beginning.\n\nTo simulate this behavior during client-side routing, SvelteKit focuses the `<body>` element after each navigation and [enhanced form submission](form-actions#Progressive-enhancement). There is one exception - if an element with the [`autofocus`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus) attribute is present, SvelteKit will focus that element instead. Make sure to [consider the implications for assistive technology](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus#accessibility_considerations) when using that attribute.\n\nIf you want to customize SvelteKit's focus management, you can use the `afterNavigate` hook:\n\n```js\n/// <reference types=\"@sveltejs/kit\" />\n// ---cut---\nimport { afterNavigate } from '$app/navigation';\n\nafterNavigate(() => {\n\t/** @type {HTMLElement | null} */\n\tconst to_focus = document.querySelector('.focus-me');\n\tto_focus?.focus();\n});\n```\n\nYou can also programmatically navigate to a different page using the [`goto`]($app-navigation#goto) function. By default, this will have the same client-side routing behavior as clicking on a link. However, `goto` also accepts a `keepFocus` option that will preserve the currently-focused element instead of resetting focus. If you enable this option, make sure the currently-focused element still exists on the page after navigation. If the element no longer exists, the user's focus will be lost, making for a confusing experience for assistive technology users.\n\n## The \"lang\" attribute\n\nBy default, SvelteKit's page template sets the default language of the document to English. If your content is not in English, you should update the `<html>` element in `src/app.html` to have the correct [`lang`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang#accessibility) attribute. This will ensure that any assistive technology reading the document uses the correct pronunciation. For example, if your content is in German, you should update `app.html` to the following:\n\n```html\n/// file: src/app.html\n<html lang=\"de\">\n```\n\nIf your content is available in multiple languages, you should set the `lang` attribute based on the language of the current page. You can do this with SvelteKit's [handle hook](hooks#Server-hooks-handle):\n\n```html\n/// file: src/app.html\n<html lang=\"%lang%\">\n```\n\n```js\n/// file: src/hooks.server.js\n/**\n * @param {import('@sveltejs/kit').RequestEvent} event\n */\nfunction get_lang(event) {\n\treturn 'en';\n}\n// ---cut---\n/** @type {import('@sveltejs/kit').Handle} */\nexport function handle({ event, resolve }) {\n\treturn resolve(event, {\n\t\ttransformPageChunk: ({ html }) => html.replace('%lang%', get_lang(event))\n\t});\n}\n```\n\n## Further reading\n\nFor the most part, building an accessible SvelteKit app is the same as building an accessible web app. You should be able to apply information from the following general accessibility resources to any web experience you build:\n\n- [MDN Web Docs: Accessibility](https://developer.mozilla.org/en-US/docs/Learn/Accessibility)\n- [The A11y Project](https://www.a11yproject.com/)\n- [How to Meet WCAG (Quick Reference)](https://www.w3.org/WAI/WCAG21/quickref/)\n"
  },
  {
    "path": "documentation/docs/40-best-practices/20-seo.md",
    "content": "---\ntitle: SEO\n---\n\nThe most important aspect of SEO is to create high-quality content that is widely linked to from around the web. However, there are a few technical considerations for building sites that rank well.\n\n## Out of the box\n\n### SSR\n\nWhile search engines have got better in recent years at indexing content that was rendered with client-side JavaScript, server-side rendered content is indexed more frequently and reliably. SvelteKit employs SSR by default, and while you can disable it in [`handle`](hooks#Server-hooks-handle), you should leave it on unless you have a good reason not to.\n\n> [!NOTE] SvelteKit's rendering is highly configurable and you can implement [dynamic rendering](https://developers.google.com/search/docs/advanced/javascript/dynamic-rendering) if necessary. It's not generally recommended, since SSR has other benefits beyond SEO.\n\n### Performance\n\nSignals such as [Core Web Vitals](https://web.dev/vitals/#core-web-vitals) impact search engine ranking. Because Svelte and SvelteKit introduce minimal overhead, they make it easier to build high performance sites. You can test your site's performance using Google's [PageSpeed Insights](https://pagespeed.web.dev/) or [Lighthouse](https://developers.google.com/web/tools/lighthouse). With just a few key actions like using SvelteKit's default [hybrid rendering](glossary#Hybrid-app) mode and [optimizing your images](images), you can greatly improve your site's speed. Read [the performance page](performance) for more details.\n\n### Normalized URLs\n\nSvelteKit redirects pathnames with trailing slashes to ones without (or vice versa depending on your [configuration](page-options#trailingSlash)), as duplicate URLs are bad for SEO.\n\n## Manual setup\n\n### &lt;title&gt; and &lt;meta&gt;\n\nEvery page should have well-written and unique `<title>` and `<meta name=\"description\">` elements inside a [`<svelte:head>`](../svelte/svelte-head). Guidance on how to write descriptive titles and descriptions, along with other suggestions on making content understandable by search engines, can be found on Google's [Lighthouse SEO audits](https://web.dev/lighthouse-seo/) documentation.\n\n> [!NOTE] A common pattern is to return SEO-related `data` from page [`load`](load) functions, then use it (as [`page.data`]($app-state)) in a `<svelte:head>` in your root [layout](routing#layout).\n\n### Sitemaps\n\n[Sitemaps](https://developers.google.com/search/docs/advanced/sitemaps/build-sitemap) help search engines prioritize pages within your site, particularly when you have a large amount of content. You can create a sitemap dynamically using an endpoint:\n\n```js\n/// file: src/routes/sitemap.xml/+server.js\nexport async function GET() {\n\treturn new Response(\n\t\t`\n\t\t<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n\t\t<urlset\n\t\t\txmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n\t\t\txmlns:xhtml=\"http://www.w3.org/1999/xhtml\"\n\t\t\txmlns:mobile=\"http://www.google.com/schemas/sitemap-mobile/1.0\"\n\t\t\txmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"\n\t\t\txmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\n\t\t\txmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\n\t\t>\n\t\t\t<!-- <url> elements go here -->\n\t\t</urlset>`.trim(),\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/xml'\n\t\t\t}\n\t\t}\n\t);\n}\n```\n\n### AMP\n\nAn unfortunate reality of modern web development is that it is sometimes necessary to create an [Accelerated Mobile Pages (AMP)](https://amp.dev/) version of your site. In SvelteKit this can be done by setting the [`inlineStyleThreshold`](configuration#inlineStyleThreshold) option...\n\n```js\n/// file: svelte.config.js\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\t// since <link rel=\"stylesheet\"> isn't\n\t\t// allowed, inline all styles\n\t\tinlineStyleThreshold: Infinity\n\t}\n};\n\nexport default config;\n```\n\n...disabling `csr` in your root `+layout.js`/`+layout.server.js`...\n\n```js\n/// file: src/routes/+layout.server.js\nexport const csr = false;\n```\n\n...adding `amp` to your `app.html`\n\n```html\n<html amp>\n...\n```\n\n...and transforming the HTML using `transformPageChunk` along with `transform` imported from `@sveltejs/amp`:\n\n```js\n/// file: src/hooks.server.js\nimport * as amp from '@sveltejs/amp';\n\n/** @type {import('@sveltejs/kit').Handle} */\nexport async function handle({ event, resolve }) {\n\tlet buffer = '';\n\treturn await resolve(event, {\n\t\ttransformPageChunk: ({ html, done }) => {\n\t\t\tbuffer += html;\n\t\t\tif (done) return amp.transform(buffer);\n\t\t}\n\t});\n}\n```\n\nTo prevent shipping any unused CSS as a result of transforming the page to amp, we can use [`dropcss`](https://www.npmjs.com/package/dropcss):\n\n```js\n// @filename: ambient.d.ts\ndeclare module 'dropcss';\n\n// @filename: index.js\n// ---cut---\n/// file: src/hooks.server.js\n// @errors: 2307\nimport * as amp from '@sveltejs/amp';\nimport dropcss from 'dropcss';\n\n/** @type {import('@sveltejs/kit').Handle} */\nexport async function handle({ event, resolve }) {\n\tlet buffer = '';\n\n\treturn await resolve(event, {\n\t\ttransformPageChunk: ({ html, done }) => {\n\t\t\tbuffer += html;\n\n\t\t\tif (done) {\n\t\t\t\tlet css = '';\n\t\t\t\tconst markup = amp\n\t\t\t\t\t.transform(buffer)\n\t\t\t\t\t.replace('⚡', 'amp') // dropcss can't handle this character\n\t\t\t\t\t.replace(/<style amp-custom([^>]*?)>([^]+?)<\\/style>/, (match, attributes, contents) => {\n\t\t\t\t\t\tcss = contents;\n\t\t\t\t\t\treturn `<style amp-custom${attributes}></style>`;\n\t\t\t\t\t});\n\n\t\t\t\tcss = dropcss({ css, html: markup }).css;\n\t\t\t\treturn markup.replace('</style>', `${css}</style>`);\n\t\t\t}\n\t\t}\n\t});\n}\n\n```\n\n> [!NOTE] It's a good idea to use the `handle` hook to validate the transformed HTML using `amphtml-validator`, but only if you're prerendering pages since it's very slow.\n"
  },
  {
    "path": "documentation/docs/40-best-practices/index.md",
    "content": "---\ntitle: Best practices\n---\n"
  },
  {
    "path": "documentation/docs/60-appendix/10-faq.md",
    "content": "---\ntitle: Frequently asked questions\n---\n\n## Other resources\n\nPlease see [the Svelte FAQ](../svelte/faq) and [`vite-plugin-svelte` FAQ](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md) as well for the answers to questions deriving from those libraries.\n\n## What can I make with SvelteKit?\n\nSee [the documentation regarding project types](project-types) for more details.\n\n## How do I include details from package.json in my application?\n\nIf you'd like to include your application's version number or other information from `package.json` in your application, you can load JSON like so:\n\n```ts\n// @errors: 2732\n/// file: svelte.config.js\nimport pkg from './package.json' with { type: 'json' };\n```\n\n## How do I fix the error I'm getting trying to include a package?\n\nMost issues related to including a library are due to incorrect packaging. You can check if a library's packaging is compatible with Node.js by entering it into [the publint website](https://publint.dev/).\n\nHere are a few things to keep in mind when checking if a library is packaged correctly:\n\n- `exports` takes precedence over the other entry point fields such as `main` and `module`. Adding an `exports` field may not be backwards-compatible as it prevents deep imports.\n- ESM files should end with `.mjs` unless `\"type\": \"module\"` is set in which any case CommonJS files should end with `.cjs`.\n- `main` should be defined if `exports` is not. It should be either a CommonJS or ESM file and adhere to the previous bullet. If a `module` field is defined, it should refer to an ESM file.\n- Svelte components should be distributed as uncompiled `.svelte` files with any JS in the package written as ESM only. Custom script and style languages, like TypeScript and SCSS, should be preprocessed as vanilla JS and CSS respectively. We recommend using [`svelte-package`](./packaging) for packaging Svelte libraries, which will do this for you.\n\nLibraries work best in the browser with Vite when they distribute an ESM version, especially if they are dependencies of a Svelte component library. You may wish to suggest to library authors that they provide an ESM version. However, CommonJS (CJS) dependencies should work as well since, by default, [`vite-plugin-svelte` will ask Vite to pre-bundle them](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#what-is-going-on-with-vite-and-pre-bundling-dependencies) using `esbuild` to convert them to ESM.\n\nIf you are still encountering issues we recommend searching both [the Vite issue tracker](https://github.com/vitejs/vite/issues) and the issue tracker of the library in question. Sometimes issues can be worked around by fiddling with the [`optimizeDeps`](https://vitejs.dev/config/#dep-optimization-options) or [`ssr`](https://vitejs.dev/config/#ssr-options) config values though we recommend this as only a short-term workaround in favor of fixing the library in question.\n\n## How do I use the view transitions API?\n\nWhile SvelteKit does not have any specific integration with [view transitions](https://developer.chrome.com/docs/web-platform/view-transitions/), you can call `document.startViewTransition` in [`onNavigate`]($app-navigation#onNavigate) to trigger a view transition on every client-side navigation.\n\n```js\n// @errors: 2339 2810\nimport { onNavigate } from '$app/navigation';\n\nonNavigate((navigation) => {\n\tif (!document.startViewTransition) return;\n\n\treturn new Promise((resolve) => {\n\t\tdocument.startViewTransition(async () => {\n\t\t\tresolve();\n\t\t\tawait navigation.complete;\n\t\t});\n\t});\n});\n```\n\nFor more, see [\"Unlocking view transitions\"](/blog/view-transitions) on the Svelte blog.\n\n## How do I set up a database?\n\nPut the code to query your database in a [server route](./routing#server) - don't query the database in .svelte files. You can create a `db.js` or similar that sets up a connection immediately and makes the client accessible throughout the app as a singleton. You can execute any one-time setup code in `hooks.server.js` and import your database helpers into any endpoint that needs them.\n\nYou can use [the Svelte CLI](/docs/cli/overview) to automatically set up database integrations.\n\n## How do I use a client-side library accessing `document` or `window`?\n\nIf you need access to the `document` or `window` variables or otherwise need code to run only on the client-side you can wrap it in a `browser` check:\n\n```js\n/// <reference types=\"@sveltejs/kit\" />\n// ---cut---\nimport { browser } from '$app/environment';\n\nif (browser) {\n\t// client-only code here\n}\n```\n\nYou can also run code in `onMount` if you'd like to run it after the component has been first rendered to the DOM:\n\n```js\n// @filename: ambient.d.ts\n// @lib: ES2015\ndeclare module 'some-browser-only-library';\n\n// @filename: index.js\n// ---cut---\nimport { onMount } from 'svelte';\n\nonMount(async () => {\n\tconst { method } = await import('some-browser-only-library');\n\tmethod('hello world');\n});\n```\n\nIf the library you'd like to use is side-effect free you can also statically import it and it will be tree-shaken out in the server-side build where `onMount` will be automatically replaced with a no-op:\n\n```js\n// @filename: ambient.d.ts\n// @lib: ES2015\ndeclare module 'some-browser-only-library';\n\n// @filename: index.js\n// ---cut---\nimport { onMount } from 'svelte';\nimport { method } from 'some-browser-only-library';\n\nonMount(() => {\n\tmethod('hello world');\n});\n```\n\nFinally, you may also consider using an `{#await}` block:\n```svelte\n<!--- file: index.svelte --->\n<script>\n\timport { browser } from '$app/environment';\n\n\tconst ComponentConstructor = browser ?\n\t\timport('some-browser-only-library').then((module) => module.Component) :\n\t\tnew Promise(() => {});\n</script>\n\n{#await ComponentConstructor}\n\t<p>Loading...</p>\n{:then component}\n\t<svelte:component this={component} />\n{:catch error}\n\t<p>Something went wrong: {error.message}</p>\n{/await}\n```\n\n## How do I use a different backend API server?\n\nYou can use [`event.fetch`](./load#Making-fetch-requests) to request data from an external API server, but be aware that you would need to deal with [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), which will result in complications such as generally requiring requests to be preflighted resulting in higher latency. Requests to a separate subdomain may also increase latency due to an additional DNS lookup, TLS setup, etc. If you wish to use this method, you may find [`handleFetch`](./hooks#Server-hooks-handleFetch) helpful.\n\nAnother approach is to set up a proxy to bypass CORS headaches. In production, you would rewrite a path like `/api` to the API server; for local development, use Vite's [`server.proxy`](https://vitejs.dev/config/server-options.html#server-proxy) option.\n\nHow to set up rewrites in production will depend on your deployment platform. If rewrites aren't an option, you could alternatively add an [API route](./routing#server):\n\n```js\n/// file: src/routes/api/[...path]/+server.js\n/** @type {import('./$types').RequestHandler} */\nexport function GET({ params, url }) {\n\treturn fetch(`https://example.com/${params.path + url.search}`);\n}\n```\n\n(Note that you may also need to proxy `POST`/`PATCH` etc requests, and forward `request.headers`, depending on your needs.)\n\n## How do I use middleware?\n\n`adapter-node` builds a middleware that you can use with your own server for production mode. In dev, you can add middleware to Vite by using a Vite plugin. For example:\n\n```js\n// @errors: 2322\n// @filename: ambient.d.ts\ndeclare module '@sveltejs/kit/vite'; // TODO this feels unnecessary, why can't it 'see' the declarations?\n\n// @filename: index.js\n// ---cut---\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').Plugin} */\nconst myPlugin = {\n\tname: 'log-request-middleware',\n\tconfigureServer(server) {\n\t\tserver.middlewares.use((req, res, next) => {\n\t\t\tconsole.log(`Got request ${req.url}`);\n\t\t\tnext();\n\t\t});\n\t}\n};\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [myPlugin, sveltekit()]\n};\n\nexport default config;\n```\n\nSee [Vite's `configureServer` docs](https://vitejs.dev/guide/api-plugin.html#configureserver) for more details including how to control ordering.\n\n## How do I use Yarn?\n\n### Does it work with Yarn 2?\n\nSort of. The Plug'n'Play feature, aka 'pnp', is broken (it deviates from the Node module resolution algorithm, and [doesn't yet work with native JavaScript modules](https://github.com/yarnpkg/berry/issues/638) which SvelteKit — along with an [increasing number of packages](https://github.com/wooorm/npm-esm-vs-cjs) — uses). You can use `nodeLinker: 'node-modules'` in your [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc#nodeLinker) file to disable pnp, but it's probably easier to just use npm or [pnpm](https://pnpm.io/), which is similarly fast and efficient but without the compatibility headaches.\n\n### How do I use with Yarn 3?\n\nCurrently ESM Support within the latest Yarn (version 3) is considered [experimental](https://github.com/yarnpkg/berry/pull/2161).\n\nThe below seems to work although your results may vary. First create a new application:\n\n```sh\nyarn create svelte myapp\ncd myapp\n```\n\nAnd enable Yarn Berry:\n\n```sh\nyarn set version berry\nyarn install\n```\n\nOne of the more interesting features of Yarn Berry is the ability to have a single global cache for packages, instead of having multiple copies for each project on the disk. However, setting `enableGlobalCache` to true causes building to fail, so it is recommended to add the following to the `.yarnrc.yml` file:\n\n```yaml\nnodeLinker: node-modules\n```\n\nThis will cause packages to be downloaded into a local node_modules directory but avoids the above problem and is your best bet for using version 3 of Yarn at this point in time.\n"
  },
  {
    "path": "documentation/docs/60-appendix/20-integrations.md",
    "content": "---\ntitle: Integrations\n---\n\n## `vitePreprocess`\n\n[`vitePreprocess`](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/preprocess.md) preprocesses `<style>` and `<script>` tags in `.svelte` files.\n\n```js\n// svelte.config.js\nimport { vitePreprocess } from '@sveltejs/vite-plugin-svelte';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n  preprocess: [\n    vitePreprocess({\n      style: true,      // default value\n      script: false     // default value\n    })\n  ]\n};\n\nexport default config;\n```\n\n### `style`\n\nUse `vitePreprocess()` to enable CSS preprocessors in `<style>` tags: PostCSS, SCSS, Less, Stylus, and SugarSS.\n\n### `script`\n\nUse `vitePreprocess({ script: true })` if: \n- your project is before Svelte 5\n- you are using advanced TypeScript features that emit code _(check [`vitePreprocess`](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/preprocess.md) documentation)_\n\n> [!NOTE]\nTypeScript is supported natively in Svelte 5, so if you are using Svelte 5 and you don't need to use advanced TypeScript features that emit code, you probably don't need to use `vitePreprocess`.\n\n## Add-ons\n\nRun [`npx sv add`](/docs/cli/sv-add) to set up many different complex integrations with a single command including:\n- prettier (formatting)\n- eslint (linting)\n- vitest (unit testing)\n- playwright (e2e testing)\n- lucia (auth)\n- tailwind (CSS)\n- drizzle (DB)\n- paraglide (i18n)\n- mdsvex (markdown)\n- storybook (frontend workshop)\n\n## Packages\n\nCheck out [the packages page](/packages) for a curated set of high quality Svelte packages. You can also see [sveltesociety.dev](https://sveltesociety.dev/) for additional libraries, templates, and resources.\n\n## Additional integrations\n\n### `svelte-preprocess`\n\n`svelte-preprocess` has some additional functionality not found in `vitePreprocess` such as support for Pug, Babel, and global styles. However, `vitePreprocess` may be faster and require less configuration, so it is used by default. Note that CoffeeScript is [not supported](https://github.com/sveltejs/kit/issues/2920#issuecomment-996469815) by SvelteKit.\n\nYou will need to install `svelte-preprocess` with `npm i -D svelte-preprocess` and [add it to your `svelte.config.js`](https://github.com/sveltejs/svelte-preprocess/blob/main/docs/usage.md#with-svelte-config). After that, you will often need to [install the corresponding library](https://github.com/sveltejs/svelte-preprocess/blob/main/docs/getting-started.md) such as `npm i -D sass` or `npm i -D less`.\n\n## Vite plugins\n\nSince SvelteKit projects are built with Vite, you can use Vite plugins to enhance your project. See a list of available plugins at [`vitejs/awesome-vite`](https://github.com/vitejs/awesome-vite?tab=readme-ov-file#plugins).\n\n## Integration FAQs\n\n[The SvelteKit FAQ](./faq) answers many questions about how to do X with SvelteKit, which may be helpful if you still have questions.\n"
  },
  {
    "path": "documentation/docs/60-appendix/25-debugging.md",
    "content": "---\ntitle: Breakpoint Debugging\n---\n\nIn addition to the [`@debug`](../svelte/@debug) tag, you can also debug Svelte and SvelteKit projects using breakpoints within various tools and development environments. This includes both frontend and backend code.\n\nThe following guides assume your JavaScript runtime environment is Node.js.\n\n## Visual Studio Code\n\nWith the built-in debug terminal, you can set up breakpoints in source files within VSCode.\n\n1. Open the command palette: `CMD/Ctrl` + `Shift` + `P`.\n2. Find and launch \"Debug: JavaScript Debug Terminal\".\n3. Start your project using the debug terminal. For example: `npm run dev`.\n4. Set some breakpoints in your client or server-side source code.\n5. Trigger the breakpoint.\n\n### Launch via debug pane\n\nYou may alternatively set up a `.vscode/launch.json` in your project. To set one up automatically:\n\n1. Go to the \"Run and Debug\" pane.\n2. In the \"Run\" select menu, choose \"Node.js...\".\n3. Select the \"run script\" that corresponds to your project, such as \"Run script: dev\".\n4. Press the \"Start debugging\" play button, or hit `F5` to begin breakpoint debugging.\n\nHere's an example `launch.json`:\n\n```json\n{\n\t\"version\": \"0.2.0\",\n\t\"configurations\": [\n\t\t{\n\t\t\t\"command\": \"npm run dev\",\n\t\t\t\"name\": \"Run development server\",\n\t\t\t\"request\": \"launch\",\n\t\t\t\"type\": \"node-terminal\"\n\t\t}\n\t]\n}\n```\n\nFurther reading: <https://code.visualstudio.com/docs/editor/debugging>.\n\n## Other Editors\n\nIf you use a different editor, these community guides might be useful for you:\n\n- [WebStorm Svelte: Debug Your Application](https://www.jetbrains.com/help/webstorm/svelte.html#ws_svelte_debug)\n- [Debugging JavaScript Frameworks in Neovim](https://theosteiner.de/debugging-javascript-frameworks-in-neovim)\n\n## Google Chrome and Microsoft Edge Developer Tools\n\nIt's possible to debug Node.js applications using a browser-based debugger.\n\n> [!NOTE] Note this only works with debugging client-side SvelteKit source maps.\n\n1. Run the `--inspect` flag when starting the Vite server with Node.js. For instance: `NODE_OPTIONS=\"--inspect\" npm run dev`\n2. Open your site in a new tab. Typically at `localhost:5173`.\n3. Open your browser's dev tools, and click on the \"Open dedicated DevTools for Node.js\" icon near the top-left. It should display the Node.js logo.\n4. Set up breakpoints and debug your application.\n\nYou may alternatively open the debugger devtools by navigating to `chrome://inspect` in Google Chrome, or `edge://inspect` in Microsoft Edge.\n\n## References\n\n- [Debugging Node.js](https://nodejs.org/en/learn/getting-started/debugging)\n"
  },
  {
    "path": "documentation/docs/60-appendix/30-migrating-to-sveltekit-2.md",
    "content": "---\ntitle: Migrating to SvelteKit v2\n---\n\nUpgrading from SvelteKit version 1 to version 2 should be mostly seamless. There are a few breaking changes to note, which are listed here. You can use `npx sv migrate sveltekit-2` to migrate some of these changes automatically.\n\nWe highly recommend upgrading to the most recent 1.x version before upgrading to 2.0, so that you can take advantage of targeted deprecation warnings. We also recommend [updating to Svelte 4](../svelte/v4-migration-guide) first: Later versions of SvelteKit 1.x support it, and SvelteKit 2.0 requires it.\n\n## `redirect` and `error` are no longer thrown by you\n\nPreviously, you had to `throw` the values returned from `error(...)` and `redirect(...)` yourself. In SvelteKit 2 this is no longer the case — calling the functions is sufficient.\n\n```js\nimport { error } from '@sveltejs/kit'\n\n// ...\n---throw error(500, 'something went wrong');---\n+++error(500, 'something went wrong');+++\n```\n\n`svelte-migrate` will do these changes automatically for you.\n\nIf the error or redirect is thrown inside a `try {...}` block (hint: don't do this!), you can distinguish them from unexpected errors using [`isHttpError`](@sveltejs-kit#isHttpError) and [`isRedirect`](@sveltejs-kit#isRedirect) imported from `@sveltejs/kit`.\n\n## path is required when setting cookies\n\nWhen receiving a `Set-Cookie` header that doesn't specify a `path`, browsers will [set the cookie path](https://www.rfc-editor.org/rfc/rfc6265#section-5.1.4) to the parent of the resource in question. This behaviour isn't particularly helpful or intuitive, and frequently results in bugs because the developer expected the cookie to apply to the domain as a whole.\n\nAs of SvelteKit 2.0, you need to set a `path` when calling `cookies.set(...)`, `cookies.delete(...)` or `cookies.serialize(...)` so that there's no ambiguity. Most of the time, you probably want to use `path: '/'`, but you can set it to whatever you like, including relative paths — `''` means 'the current path', `'.'` means 'the current directory'.\n\n```js\n/** @type {import('./$types').PageServerLoad} */\nexport function load({ cookies }) {\n\tcookies.set(name, value, +++{ path: '/' }+++);\n\treturn { response }\n}\n```\n\n`svelte-migrate` will add comments highlighting the locations that need to be adjusted.\n\n## Top-level promises are no longer awaited\n\nIn SvelteKit version 1, if the top-level properties of the object returned from a `load` function were promises, they were automatically awaited. With the introduction of [streaming](/blog/streaming-snapshots-sveltekit) this behavior became a bit awkward as it forces you to nest your streamed data one level deep.\n\nAs of version 2, SvelteKit no longer differentiates between top-level and non-top-level promises. To get back the blocking behavior, use `await` (with `Promise.all` to prevent waterfalls, where appropriate):\n\n```js\n// @filename: ambient.d.ts\ndeclare const url: string;\n\n// @filename: index.js\n// ---cut---\n// If you have a single promise\n/** @type {import('./$types').PageServerLoad} */\nexport +++async+++ function load({ fetch }) {\n\tconst response = +++await+++ fetch(url).then(r => r.json());\n\treturn { response }\n}\n```\n\n```js\n// @filename: ambient.d.ts\ndeclare const url1: string;\ndeclare const url2: string;\n\n// @filename: index.js\n// ---cut---\n// If you have multiple promises\n/** @type {import('./$types').PageServerLoad} */\nexport +++async+++ function load({ fetch }) {\n---\tconst a = fetch(url1).then(r => r.json());---\n---\tconst b = fetch(url2).then(r => r.json());---\n+++\tconst [a, b] = await Promise.all([\n\t  fetch(url1).then(r => r.json()),\n\t  fetch(url2).then(r => r.json()),\n\t]);+++\n\treturn { a, b };\n}\n```\n\n## goto(...) changes\n\n`goto(...)` no longer accepts external URLs. To navigate to an external URL, use `window.location.href = url`. The `state` object now determines `$page.state` and must adhere to the `App.PageState` interface, if declared. See [shallow routing](shallow-routing) for more details.\n\n## paths are now relative by default\n\nIn SvelteKit 1, `%sveltekit.assets%` in your `app.html` was replaced with a relative path by default (i.e. `.` or `..` or `../..` etc, depending on the path being rendered) during server-side rendering unless the [`paths.relative`](configuration#paths) config option was explicitly set to `false`. The same was true for `base` and `assets` imported from `$app/paths`, but only if the `paths.relative` option was explicitly set to `true`.\n\nThis inconsistency is fixed in version 2. Paths are either always relative or always absolute, depending on the value of [`paths.relative`](configuration#paths). It defaults to `true` as this results in more portable apps: if the `base` is something other than the app expected (as is the case when viewed on the [Internet Archive](https://archive.org/), for example) or unknown at build time (as is the case when deploying to [IPFS](https://ipfs.tech/) and so on), fewer things are likely to break.\n\n## Server fetches are not trackable anymore\n\nPreviously it was possible to track URLs from `fetch`es on the server in order to rerun load functions. This poses a possible security risk (private URLs leaking), and for this reason it was behind the `dangerZone.trackServerFetches` setting, which is now removed.\n\n## `preloadCode` arguments must be prefixed with `base`\n\nSvelteKit exposes two functions, [`preloadCode`]($app-navigation#preloadCode) and [`preloadData`]($app-navigation#preloadData), for programmatically loading the code and data associated with a particular path. In version 1, there was a subtle inconsistency — the path passed to `preloadCode` did not need to be prefixed with the `base` path (if set), while the path passed to `preloadData` did.\n\nThis is fixed in SvelteKit 2 — in both cases, the path should be prefixed with `base` if it is set.\n\nAdditionally, `preloadCode` now takes a single argument rather than _n_ arguments.\n\n## `resolvePath` has been removed\n\nSvelteKit 1 included a function called `resolvePath` which allows you to resolve a route ID (like `/blog/[slug]`) and a set of parameters (like `{ slug: 'hello' }`) to a pathname. Unfortunately the return value didn't include the `base` path, limiting its usefulness in cases where `base` was set.\n\nFor this reason, SvelteKit 2 replaces `resolvePath` with a (slightly better named) function called `resolveRoute`, which is imported from `$app/paths` and which takes `base` into account.\n\n```js\n---import { resolvePath } from '@sveltejs/kit';\nimport { base } from '$app/paths';---\n+++import { resolveRoute } from '$app/paths';+++\n\n---const path = base + resolvePath('/blog/[slug]', { slug });---\n+++const path = resolveRoute('/blog/[slug]', { slug });+++\n```\n\n`svelte-migrate` will do the method replacement for you, though if you later prepend the result with `base`, you need to remove that yourself.\n\n## Improved error handling\n\nErrors are handled inconsistently in SvelteKit 1. Some errors trigger the `handleError` hook but there is no good way to discern their status (for example, the only way to tell a 404 from a 500 is by seeing if `event.route.id` is `null`), while others (such as 405 errors for `POST` requests to pages without actions) don't trigger `handleError` at all, but should. In the latter case, the resulting `$page.error` will deviate from the [`App.Error`](types#Error) type, if it is specified.\n\nSvelteKit 2 cleans this up by calling `handleError` hooks with two new properties: `status` and `message`. For errors thrown from your code (or library code called by your code) the status will be `500` and the message will be `Internal Error`. While `error.message` may contain sensitive information that should not be exposed to users, `message` is safe.\n\n## Dynamic environment variables cannot be used during prerendering\n\nThe `$env/dynamic/public` and `$env/dynamic/private` modules provide access to _run time_ environment variables, as opposed to the _build time_ environment variables exposed by `$env/static/public` and `$env/static/private`.\n\nDuring prerendering in SvelteKit 1, they are one and the same. This means that prerendered pages that make use of 'dynamic' environment variables are really 'baking in' build time values, which is incorrect. Worse, `$env/dynamic/public` is populated in the browser with these stale values if the user happens to land on a prerendered page before navigating to dynamically-rendered pages.\n\nBecause of this, dynamic environment variables can no longer be read during prerendering in SvelteKit 2 — you should use the `static` modules instead. If the user lands on a prerendered page, SvelteKit will request up-to-date values for `$env/dynamic/public` from the server (by default from a module called `/_app/env.js`) instead of reading them from the server-rendered HTML.\n\n## `form` and `data` have been removed from `use:enhance` callbacks\n\nIf you provide a callback to [`use:enhance`](form-actions#Progressive-enhancement-use:enhance), it will be called with an object containing various useful properties.\n\nIn SvelteKit 1, those properties included `form` and `data`. These were deprecated some time ago in favour of `formElement` and `formData`, and have been removed altogether in SvelteKit 2.\n\n## Forms containing file inputs must use `multipart/form-data`\n\nIf a form contains an `<input type=\"file\">` but does not have an `enctype=\"multipart/form-data\"` attribute, non-JS submissions will omit the file. SvelteKit 2 will throw an error if it encounters a form like this during a `use:enhance` submission to ensure that your forms work correctly when JavaScript is not present.\n\n## Generated `tsconfig.json` is more strict\n\nPreviously, the generated `tsconfig.json` was trying its best to still produce a somewhat valid config when your `tsconfig.json` included `paths` or `baseUrl`. In SvelteKit 2, the validation is more strict and will warn when you use either `paths` or `baseUrl` in your `tsconfig.json`. These settings are used to generate path aliases and you should use [the `alias` config](configuration#alias) option in your `svelte.config.js` instead, to also create a corresponding alias for the bundler.\n\n## `getRequest` no longer throws errors\n\nThe `@sveltejs/kit/node` module exports helper functions for use in Node environments, including `getRequest` which turns a Node [`ClientRequest`](https://nodejs.org/api/http.html#class-httpclientrequest) into a standard [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) object.\n\nIn SvelteKit 1, `getRequest` could throw if the `Content-Length` header exceeded the specified size limit. In SvelteKit 2, the error will not be thrown until later, when the request body (if any) is being read. This enables better diagnostics and simpler code.\n\n## `vitePreprocess` is no longer exported from `@sveltejs/kit/vite`\n\nSince `@sveltejs/vite-plugin-svelte` is now a peer dependency, SvelteKit 2 no longer re-exports `vitePreprocess`. You should import it directly from `@sveltejs/vite-plugin-svelte`.\n\n## Updated dependency requirements\n\nSvelteKit 2 requires Node `18.13` or higher, and the following minimum dependency versions:\n\n- `svelte@4`\n- `vite@5`\n- `typescript@5`\n- `@sveltejs/vite-plugin-svelte@3` (this is now required as a `peerDependency` of SvelteKit — previously it was directly depended upon)\n- `@sveltejs/adapter-cloudflare@3` (if you're using these adapters)\n- `@sveltejs/adapter-cloudflare-workers@2`\n- `@sveltejs/adapter-netlify@3`\n- `@sveltejs/adapter-node@2`\n- `@sveltejs/adapter-static@3`\n- `@sveltejs/adapter-vercel@4`\n\n`svelte-migrate` will update your `package.json` for you.\n\nAs part of the TypeScript upgrade, the generated `tsconfig.json` (the one your `tsconfig.json` extends from) now uses `\"moduleResolution\": \"bundler\"` (which is recommended by the TypeScript team, as it properly resolves types from packages with an `exports` map in package.json) and `verbatimModuleSyntax` (which replaces the existing `importsNotUsedAsValues ` and `preserveValueImports` flags — if you have those in your `tsconfig.json`, remove them. `svelte-migrate` will do this for you).\n\n## SvelteKit 2.12: $app/stores deprecated\n\nSvelteKit 2.12 introduced `$app/state` based on the [Svelte 5 runes API](/docs/svelte/what-are-runes). `$app/state` provides everything that `$app/stores` provides but with more flexibility as to where and how you use it. Most importantly, the `page` object is now fine-grained, e.g. updates to `page.state` will not invalidate `page.data` and vice-versa.\n\nAs a consequence, `$app/stores` is deprecated and subject to be removed in SvelteKit 3. We recommend [upgrading to Svelte 5](/docs/svelte/v5-migration-guide), if you haven't already, and then migrate away from `$app/stores`. Most of the replacements should be pretty simple: Replace the `$app/stores` import with `$app/state` and remove the `$` prefixes from the usage sites.\n\n```svelte\n<script>\n\t---import { page } from '$app/stores';---\n\t+++import { page } from '$app/state';+++\n</script>\n\n---{$page.data}---\n+++{page.data}+++\n```\n\nUse `npx sv migrate app-state` to auto-migrate most of your `$app/stores` usages inside `.svelte` components.\n"
  },
  {
    "path": "documentation/docs/60-appendix/40-migrating.md",
    "content": "---\ntitle: Migrating from Sapper\nrank: 1\n---\n\nSvelteKit is the successor to Sapper and shares many elements of its design.\n\nIf you have an existing Sapper app that you plan to migrate to SvelteKit, there are a number of changes you will need to make. You may find it helpful to view [some examples](additional-resources#Examples) while migrating.\n\n## package.json\n\n### type: \"module\"\n\nAdd `\"type\": \"module\"` to your `package.json`. You can do this step separately from the rest as part of an incremental migration if you are using Sapper 0.29.3\nor newer.\n\n### dependencies\n\nRemove `polka` or `express`, if you're using one of those, and any middleware such as `sirv` or `compression`.\n\n### devDependencies\n\nRemove `sapper` from your `devDependencies` and replace it with `@sveltejs/kit` and whichever [adapter](adapters) you plan to use (see [next section](migrating#Project-files-Configuration)).\n\n### scripts\n\nAny scripts that reference `sapper` should be updated:\n\n- `sapper build` should become `vite build` using the Node [adapter](adapters)\n- `sapper export` should become `vite build` using the static [adapter](adapters)\n- `sapper dev` should become `vite dev`\n- `node __sapper__/build` should become `node build`\n\n## Project files\n\nThe bulk of your app, in `src/routes`, can be left where it is, but several project files will need to be moved or updated.\n\n### Configuration\n\nYour `webpack.config.js` or `rollup.config.js` should be replaced with a `svelte.config.js`, as documented [here](configuration). Svelte preprocessor options should be moved to `config.preprocess`.\n\nYou will need to add an [adapter](adapters). `sapper build` is roughly equivalent to [adapter-node](adapter-node) while `sapper export` is roughly equivalent to [adapter-static](adapter-static), though you might prefer to use an adapter designed for the platform you're deploying to.\n\nIf you were using plugins for filetypes that are not automatically handled by [Vite](https://vitejs.dev), you will need to find Vite equivalents and add them to the [Vite config](project-structure#Project-files-vite.config.js).\n\n### src/client.js\n\nThis file has no equivalent in SvelteKit. Any custom logic (beyond `sapper.start(...)`) should be expressed in your `+layout.svelte` file, inside an `onMount` callback.\n\n### src/server.js\n\nWhen using `adapter-node` the equivalent is a [custom server](adapter-node#Custom-server). Otherwise, this file has no direct equivalent, since SvelteKit apps can run in serverless environments.\n\n### src/service-worker.js\n\nMost imports from `@sapper/service-worker` have equivalents in [`$service-worker`]($service-worker):\n\n- `files` is unchanged\n- `routes` has been removed\n- `shell` is now `build`\n- `timestamp` is now `version`\n\n### src/template.html\n\nThe `src/template.html` file should be renamed `src/app.html`.\n\nRemove `%sapper.base%`, `%sapper.scripts%` and `%sapper.styles%`. Replace `%sapper.head%` with `%sveltekit.head%` and `%sapper.html%` with `%sveltekit.body%`. The `<div id=\"sapper\">` is no longer necessary.\n\n### src/node_modules\n\nA common pattern in Sapper apps is to put your internal library in a directory inside `src/node_modules`. This doesn't work with Vite, so we use [`src/lib`]($lib) instead.\n\n## Pages and layouts\n\n### Renamed files\n\nRoutes now are made up of the folder name exclusively to remove ambiguity, the folder names leading up to a `+page.svelte` correspond to the route. See [the routing docs](routing) for an overview. The following shows a old/new comparison:\n\n| Old                       | New                       |\n| ------------------------- | ------------------------- |\n| routes/about/index.svelte | routes/about/+page.svelte |\n| routes/about.svelte       | routes/about/+page.svelte |\n\nYour custom error page component should be renamed from `_error.svelte` to `+error.svelte`. Any `_layout.svelte` files should likewise be renamed `+layout.svelte`. [Any other files are ignored](routing#Other-files).\n\n### Imports\n\nThe `goto`, `prefetch` and `prefetchRoutes` imports from `@sapper/app` should be replaced with `goto`, `preloadData` and `preloadCode` imports respectively from [`$app/navigation`]($app-navigation).\n\nThe `stores` import from `@sapper/app` should be replaced — see the [Stores](migrating#Pages-and-layouts-Stores) section below.\n\nAny files you previously imported from directories in `src/node_modules` will need to be replaced with [`$lib`]($lib) imports.\n\n### Preload\n\nAs before, pages and layouts can export a function that allows data to be loaded before rendering takes place.\n\nThis function has been renamed from `preload` to [`load`](load), it now lives in a `+page.js` (or `+layout.js`) next to its `+page.svelte` (or `+layout.svelte`), and its API has changed. Instead of two arguments — `page` and `session` — there is a single `event` argument.\n\nThere is no more `this` object, and consequently no `this.fetch`, `this.error` or `this.redirect`. Instead, you can get [`fetch`](load#Making-fetch-requests) from the input methods, and both [`error`](load#Errors) and [`redirect`](load#Redirects) are now thrown.\n\n### Stores\n\nIn Sapper, you would get references to provided stores like so:\n\n```js\n// @filename: ambient.d.ts\ndeclare module '@sapper/app';\n\n// @filename: index.js\n// ---cut---\nimport { stores } from '@sapper/app';\nconst { preloading, page, session } = stores();\n```\n\nThe `page` store still exists; `preloading` has been replaced with a `navigating` store that contains `from` and `to` properties. `page` now has `url` and `params` properties, but no `path` or `query`.\n\nYou access them differently in SvelteKit. `stores` is now `getStores`, but in most cases it is unnecessary since you can import `navigating`, and `page` directly from [`$app/stores`]($app-stores). If you're on Svelte 5 and SvelteKit 2.12 or higher, consider using [`$app/state`]($app-state) instead.\n\n### Routing\n\nRegex routes are no longer supported. Instead, use [advanced route matching](advanced-routing#Matching).\n\n### Segments\n\nPreviously, layout components received a `segment` prop indicating the child segment. This has been removed; you should use the more flexible `$page.url.pathname` (or `page.url.pathname`) value to derive the segment you're interested in.\n\n### URLs\n\nIn Sapper, all relative URLs were resolved against the base URL — usually `/`, unless the `basepath` option was used — rather than against the current page.\n\nThis caused problems and is no longer the case in SvelteKit. Instead, relative URLs are resolved against the current page (or the destination page, for `fetch` URLs in `load` functions) instead. In most cases, it's easier to use root-relative (i.e. starts with `/`) URLs, since their meaning is not context-dependent.\n\n### &lt;a&gt; attributes\n\n- `sapper:prefetch` is now `data-sveltekit-preload-data`\n- `sapper:noscroll` is now `data-sveltekit-noscroll`\n\n## Endpoints\n\nIn Sapper, [server routes](routing#server) received the `req` and `res` objects exposed by Node's `http` module (or the augmented versions provided by frameworks like Polka and Express).\n\nSvelteKit is designed to be agnostic as to where the app is running — it could be running on a Node server, but could equally be running on a serverless platform or in a Cloudflare Worker. For that reason, you no longer interact directly with `req` and `res`. Your endpoints will need to be updated to match the new signature.\n\nTo support this environment-agnostic behavior, `fetch` is now available in the global context, so you don't need to import `node-fetch`, `cross-fetch`, or similar server-side fetch implementations in order to use it.\n\n## Integrations\n\nSee [integrations](./integrations) for detailed information about integrations.\n\n### HTML minifier\n\nSapper includes `html-minifier` by default. SvelteKit does not include this, but you can add it as a prod dependency and then use it through a [hook](hooks#Server-hooks-handle):\n\n```js\n// @filename: ambient.d.ts\n/// <reference types=\"@sveltejs/kit\" />\ndeclare module 'html-minifier';\n\n// @filename: index.js\n// ---cut---\nimport { minify } from 'html-minifier';\nimport { building } from '$app/environment';\n\nconst minification_options = {\n\tcollapseBooleanAttributes: true,\n\tcollapseWhitespace: true,\n\tconservativeCollapse: true,\n\tdecodeEntities: true,\n\thtml5: true,\n\tignoreCustomComments: [/^#/],\n\tminifyCSS: true,\n\tminifyJS: false,\n\tremoveAttributeQuotes: true,\n\tremoveComments: false, // some hydration code needs comments, so leave them in\n\tremoveOptionalTags: true,\n\tremoveRedundantAttributes: true,\n\tremoveScriptTypeAttributes: true,\n\tremoveStyleLinkTypeAttributes: true,\n\tsortAttributes: true,\n\tsortClassName: true\n};\n\n/** @type {import('@sveltejs/kit').Handle} */\nexport async function handle({ event, resolve }) {\n\tlet page = '';\n\n\treturn resolve(event, {\n\t\ttransformPageChunk: ({ html, done }) => {\n\t\t\tpage += html;\n\t\t\tif (done) {\n\t\t\t\treturn building ? minify(page, minification_options) : page;\n\t\t\t}\n\t\t}\n\t});\n}\n```\n\nNote that `prerendering` is `false` when using `vite preview` to test the production build of the site, so to verify the results of minifying, you'll need to inspect the built HTML files directly.\n"
  },
  {
    "path": "documentation/docs/60-appendix/50-additional-resources.md",
    "content": "---\ntitle: Additional resources\n---\n\n## FAQs\n\nPlease see the [SvelteKit FAQ](faq) for solutions to common issues and helpful tips and tricks.\n\nThe [Svelte FAQ](../svelte/faq) and [`vite-plugin-svelte` FAQ](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md) may also be helpful for questions deriving from those libraries.\n\n## Examples\n\nWe've written and published a few different SvelteKit sites as examples:\n\n- [`sveltejs/realworld`](https://github.com/sveltejs/realworld) contains an example blog site\n- [A HackerNews clone](https://github.com/sveltejs/sites/tree/master/sites/hn.svelte.dev)\n- [`svelte.dev`](https://github.com/sveltejs/svelte.dev)\n\nSvelteKit users have also published plenty of examples on GitHub, under the [#sveltekit](https://github.com/topics/sveltekit) and [#sveltekit-template](https://github.com/topics/sveltekit-template) topics, as well as on [the Svelte Society site](https://sveltesociety.dev/recipe/sveltekit-templates-and-examples-e789ed397e7f38fc). Note that these have not been vetted by the maintainers and may not be up to date.\n\n## Support\n\nYou can ask for help on [Discord](/chat) and [StackOverflow](https://stackoverflow.com/questions/tagged/sveltekit). Please first search for information related to your issue in the FAQ, Google or another search engine, issue tracker, and Discord chat history in order to be respectful of others' time. There are many more people asking questions than answering them, so this will help in allowing the community to grow in a scalable fashion.\n"
  },
  {
    "path": "documentation/docs/60-appendix/60-glossary.md",
    "content": "---\ntitle: Glossary\n---\n\nThe core of SvelteKit provides a highly configurable rendering engine. This section describes some of the terms used when discussing rendering. A reference for setting these options is provided in the documentation above.\n\n## CSR\n\nClient-side rendering (CSR) is the generation of the page contents in the web browser using JavaScript.\n\nIn SvelteKit, client-side rendering will be used by default, but you can turn off JavaScript with [the `csr = false` page option](page-options#csr).\n\n## Edge\n\nRendering on the edge refers to rendering an application in a content delivery network (CDN) near the user. Edge rendering allows the request and response for a page to travel a shorter distance thus improving latency.\n\n## Hybrid app\n\nSvelteKit uses a hybrid rendering mode by default where it loads the initial HTML from the server (SSR), and then updates the page contents on subsequent navigations via client-side rendering (CSR).\n\n## Hydration\n\nSvelte components store some state and update the DOM when the state is updated. When fetching data during SSR, by default SvelteKit will store this data and transmit it to the client along with the server-rendered HTML. The components can then be initialized on the client with that data without having to call the same API endpoints again. Svelte will then check that the DOM is in the expected state and attach event listeners in a process called hydration. Once the components are fully hydrated, they can react to changes to their properties just like any newly created Svelte component.\n\nIn SvelteKit, pages will be hydrated by default, but you can turn off JavaScript with [the `csr = false` page option](page-options#csr).\n\n## ISR\n\nIncremental static regeneration (ISR) allows you to generate static pages on your site as visitors request those pages without redeploying. This may reduces build times compared to [SSG](#SSG) sites with a large number of pages. You can do [ISR with `adapter-vercel`](adapter-vercel#Incremental-Static-Regeneration).\n\n## MPA\n\nTraditional applications that render each page view on the server — such as those written in languages other than JavaScript — are often referred to as multi-page apps (MPA).\n\n## Prerendering\n\nPrerendering means computing the contents of a page at build time and saving the HTML for display. This approach has the same benefits as traditional server-rendered pages, but avoids recomputing the page for each visitor and so scales nearly for free as the number of visitors increases. The tradeoff is that the build process is more expensive and prerendered content can only be updated by building and deploying a new version of the application.\n\nFor content to be prerenderable, any two users hitting it directly must get the same content from the server, and the page must not contain [actions](form-actions). Note that you can still prerender content that is loaded based on the page's parameters as long as all users will be seeing the same prerendered content. Prerendering all of your pages is also known as [Static Site Generation](#SSG).\n\nPre-rendered pages are not limited to static content. You can build personalized pages if user-specific data is fetched and rendered client-side. This is subject to the caveat that you will experience the downsides of not doing SSR for that content as discussed above.\n\nIn SvelteKit, you can control prerendering with [the `prerender` page option](page-options#prerender) and [`prerender` config](configuration#prerender) in `svelte.config.js`.\n\n\n## PWA\n\nA progressive web app (PWA) is an app that's built using web APIs and technologies, but functions like a mobile or desktop app. Sites served as [PWAs can be installed](https://web.dev/learn/pwa/installation), allowing you to add a shortcut to the application on your launcher, home screen, or start menu. Many PWAs will utilize [service workers](service-workers) to build offline capabilities.\n\n## Routing\n\nBy default, when you navigate to a new page (by clicking on a link or using the browser's forward or back buttons), SvelteKit will intercept the attempted navigation and handle it instead of allowing the browser to send a request to the server for the destination page. SvelteKit will then update the displayed contents on the client by rendering the component for the new page, which in turn can make calls to the necessary API endpoints. This process of updating the page on the client in response to attempted navigation is called client-side routing.\n\nIn SvelteKit, client-side routing will be used by default, but you can skip it with [`data-sveltekit-reload`](link-options#data-sveltekit-reload).\n\n## SPA\n\nA single-page app (SPA) is an application in which all requests to the server load a single HTML file which then does client-side rendering based on the requested URL. All navigation is handled on the client-side in a process called client-side routing with per-page contents being updated and common layout elements remaining largely unchanged. Throughout this site, when we refer to a SPA, we use this definition where a SPA simply serves an empty shell on the initial request. It should not be confused with a [hybrid app](#Hybrid-app), which serves HTML on the initial request. It has a large performance impact by forcing two network round trips before rendering can begin. Because SPA mode has large negative performance and SEO impacts, it is recommended only in very limited circumstances such as when being wrapped in a mobile app.\n\nIn SvelteKit, you can [build SPAs with `adapter-static`](single-page-apps).\n\n## SSG\n\nStatic Site Generation (SSG) is a term that refers to a site where every page is prerendered. One benefit of fully prerendering a site is that you do not need to maintain or pay for servers to perform SSR. Once generated, the site can be served from CDNs, leading to great “time to first byte” performance. This delivery model is often referred to as JAMstack.\n\nIn SvelteKit, you can do static site generation by using [`adapter-static`](adapter-static) or by configuring every page to be [prerendered](#Prerendering) using [the `prerender` page option](page-options#prerender) or [`prerender` config](configuration#prerender) in `svelte.config.js`.\n\n## SSR\n\nServer-side rendering (SSR) is the generation of the page contents on the server. Returning the page contents from the server via SSR or prerendering is highly preferred for performance and SEO. It significantly improves performance by avoiding the introduction of extra round trips necessary in a SPA, and makes your app accessible to users if JavaScript fails or is disabled (which happens [more often than you probably think](https://kryogenix.org/code/browser/everyonehasjs.html)). While some search engines can index content that is dynamically generated on the client-side, it is likely to take longer even in these cases.\n\nIn SvelteKit, pages are server-side rendered by default. You can disable SSR with [the `ssr` page option](page-options#ssr).\n"
  },
  {
    "path": "documentation/docs/60-appendix/index.md",
    "content": "---\ntitle: Appendix\n---\n"
  },
  {
    "path": "documentation/docs/98-reference/10-@sveltejs-kit.md",
    "content": "---\ntitle: @sveltejs/kit\n---\n\n> MODULE: @sveltejs/kit\n\n## Private types\n\nThe following are referenced by the public types documented above, but cannot be imported directly:\n\n> TYPES: Private types\n"
  },
  {
    "path": "documentation/docs/98-reference/15-@sveltejs-kit-hooks.md",
    "content": "---\ntitle: @sveltejs/kit/hooks\n---\n\n> MODULE: @sveltejs/kit/hooks\n"
  },
  {
    "path": "documentation/docs/98-reference/15-@sveltejs-kit-node-polyfills.md",
    "content": "---\ntitle: @sveltejs/kit/node/polyfills\n---\n\n> MODULE: @sveltejs/kit/node/polyfills\n"
  },
  {
    "path": "documentation/docs/98-reference/15-@sveltejs-kit-node.md",
    "content": "---\ntitle:  @sveltejs/kit/node\n---\n\n> MODULE: @sveltejs/kit/node\n"
  },
  {
    "path": "documentation/docs/98-reference/15-@sveltejs-kit-vite.md",
    "content": "---\ntitle:  @sveltejs/kit/vite\n---\n\n> MODULE: @sveltejs/kit/vite\n"
  },
  {
    "path": "documentation/docs/98-reference/20-$app-environment.md",
    "content": "---\ntitle: $app/environment\n---\n\n> MODULE: $app/environment\n"
  },
  {
    "path": "documentation/docs/98-reference/20-$app-forms.md",
    "content": "---\ntitle: $app/forms\n---\n\n> MODULE: $app/forms\n"
  },
  {
    "path": "documentation/docs/98-reference/20-$app-navigation.md",
    "content": "---\ntitle: $app/navigation\n---\n\n> MODULE: $app/navigation\n"
  },
  {
    "path": "documentation/docs/98-reference/20-$app-paths.md",
    "content": "---\ntitle: $app/paths\n---\n\n> MODULE: $app/paths\n"
  },
  {
    "path": "documentation/docs/98-reference/20-$app-server.md",
    "content": "---\ntitle: $app/server\n---\n\n> MODULE: $app/server\n"
  },
  {
    "path": "documentation/docs/98-reference/20-$app-state.md",
    "content": "---\ntitle: $app/state\n---\n\nSvelteKit makes three read-only state objects available via the `$app/state` module — `page`, `navigating` and `updated`.\n\n> [!NOTE]\n> This module was added in 2.12. If you're using an earlier version of SvelteKit, use [`$app/stores`]($app-stores) instead.\n\n> MODULE: $app/state\n"
  },
  {
    "path": "documentation/docs/98-reference/20-$app-stores.md",
    "content": "---\ntitle: $app/stores\n---\n\nThis module contains store-based equivalents of the exports from [`$app/state`]($app-state). If you're using SvelteKit 2.12 or later, use that module instead.\n\n> MODULE: $app/stores\n"
  },
  {
    "path": "documentation/docs/98-reference/20-$app-types.md",
    "content": "---\ntitle: $app/types\n---\n\nThis module contains generated types for the routes in your app.\n\n<blockquote class=\"since note\">\n\t<p>Available since 2.26</p>\n</blockquote>\n\n```js\n// @noErrors\nimport type { RouteId, RouteParams, LayoutParams } from '$app/types';\n```\n\n## Asset\n\nA union of all the filenames of assets contained in your `static` directory, plus a `string` wildcard for asset paths generated from `import` declarations.\n\n<div class=\"ts-block\">\n\n```dts\ntype Asset = '/favicon.png' | '/robots.txt' | (string & {});\n```\n\n</div>\n\n## RouteId\n\nA union of all the route IDs in your app. Used for `page.route.id` and `event.route.id`.\n\n<div class=\"ts-block\">\n\n```dts\ntype RouteId = '/' | '/my-route' | '/my-other-route/[param]';\n```\n\n</div>\n\n## Pathname\n\nA union of all valid pathnames in your app.\n\n<div class=\"ts-block\">\n\n```dts\ntype Pathname = '/' | '/my-route' | `/my-other-route/${string}` & {};\n```\n\n</div>\n\n## ResolvedPathname\n\nSimilar to `Pathname`, but possibly prefixed with a [base path](configuration#paths). Used for `page.url.pathname`.\n\n<div class=\"ts-block\">\n\n```dts\ntype ResolvedPathname = `${'' | `/${string}`}/` | `${'' | `/${string}`}/my-route` | `${'' | `/${string}`}/my-other-route/${string}` | {};\n```\n\n</div>\n\n## RouteParams\n\nA utility for getting the parameters associated with a given route.\n\n```ts\n// @errors: 2552\ntype BlogParams = RouteParams<'/blog/[slug]'>; // { slug: string }\n```\n\n<div class=\"ts-block\">\n\n```dts\ntype RouteParams<T extends RouteId> = { /* generated */ } | Record<string, never>;\n```\n\n</div>\n\n## LayoutParams\n\nA utility for getting the parameters associated with a given layout, which is similar to `RouteParams` but also includes optional parameters for any child route.\n\n<div class=\"ts-block\">\n\n```dts\ntype RouteParams<T extends RouteId> = { /* generated */ } | Record<string, never>;\n```\n\n</div>\n"
  },
  {
    "path": "documentation/docs/98-reference/25-$env-dynamic-private.md",
    "content": "---\ntitle: $env/dynamic/private\n---\n\n> MODULE: $env/dynamic/private\n"
  },
  {
    "path": "documentation/docs/98-reference/25-$env-dynamic-public.md",
    "content": "---\ntitle: $env/dynamic/public\n---\n\n> MODULE: $env/dynamic/public\n"
  },
  {
    "path": "documentation/docs/98-reference/25-$env-static-private.md",
    "content": "---\ntitle: $env/static/private\n---\n\n> MODULE: $env/static/private\n"
  },
  {
    "path": "documentation/docs/98-reference/25-$env-static-public.md",
    "content": "---\ntitle: $env/static/public\n---\n\n> MODULE: $env/static/public\n"
  },
  {
    "path": "documentation/docs/98-reference/26-$lib.md",
    "content": "---\ntitle: $lib\n---\n\nSvelteKit automatically makes files under `src/lib` available using the `$lib` import alias.\n\n```svelte\n<!--- file: src/lib/Component.svelte --->\nA reusable component\n```\n\n```svelte\n<!--- file: src/routes/+page.svelte --->\n<script>\n    import Component from '$lib/Component.svelte';\n</script>\n\n<Component />\n```\n"
  },
  {
    "path": "documentation/docs/98-reference/27-$service-worker.md",
    "content": "---\ntitle: $service-worker\n---\n\n> MODULE: $service-worker\n"
  },
  {
    "path": "documentation/docs/98-reference/50-configuration.md",
    "content": "---\ntitle: Configuration\n---\n\nYour project's configuration lives in a `svelte.config.js` file at the root of your project. As well as SvelteKit, this config object is used by other tooling that integrates with Svelte such as editor extensions.\n\n```js\n/// file: svelte.config.js\n// @filename: ambient.d.ts\ndeclare module '@sveltejs/adapter-auto' {\n\tconst plugin: () => import('@sveltejs/kit').Adapter;\n\texport default plugin;\n}\n\n// @filename: index.js\n// ---cut---\nimport adapter from '@sveltejs/adapter-auto';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n```\n\n## Config\n\n> TYPES: Configuration#Config\n\n## KitConfig\n\nThe `kit` property configures SvelteKit, and can have the following properties:\n\n> EXPANDED_TYPES: Configuration#KitConfig\n"
  },
  {
    "path": "documentation/docs/98-reference/52-cli.md",
    "content": "---\ntitle: Command Line Interface\n---\n\nSvelteKit projects use [Vite](https://vitejs.dev), meaning you'll mostly use its CLI (albeit via `npm run dev/build/preview` scripts):\n\n- `vite dev` — start a development server\n- `vite build` — build a production version of your app\n- `vite preview` — run the production version locally\n\nHowever SvelteKit includes its own CLI for initialising your project:\n\n## svelte-kit sync\n\n`svelte-kit sync` creates the `tsconfig.json` and all generated types (which you can import as `./$types` inside routing files) for your project. When you create a new project, it is listed as the `prepare` script and will be run automatically as part of the npm lifecycle, so you should not ordinarily have to run this command.\n"
  },
  {
    "path": "documentation/docs/98-reference/54-types.md",
    "content": "---\ntitle: Types\n---\n\n## Generated types\n\nThe `RequestHandler` and `Load` types both accept a `Params` argument allowing you to type the `params` object. For example this endpoint expects `foo`, `bar` and `baz` params:\n\n```js\n/// file: src/routes/[foo]/[bar]/[baz]/+server.js\n// @errors: 2355 2322 1360\n/** @type {import('@sveltejs/kit').RequestHandler<{\n    foo: string;\n    bar: string;\n    baz: string\n  }>} */\nexport async function GET({ params }) {\n\t// ...\n}\n```\n\nNeedless to say, this is cumbersome to write out, and less portable (if you were to rename the `[foo]` directory to `[qux]`, the type would no longer reflect reality).\n\nTo solve this problem, SvelteKit generates `.d.ts` files for each of your endpoints and pages:\n\n```ts\n/// file: .svelte-kit/types/src/routes/[foo]/[bar]/[baz]/$types.d.ts\n/// link: true\nimport type * as Kit from '@sveltejs/kit';\n\ntype RouteParams = {\n\tfoo: string;\n\tbar: string;\n\tbaz: string;\n};\n\nexport type RequestHandler = Kit.RequestHandler<RouteParams>;\nexport type PageLoad = Kit.Load<RouteParams>;\n```\n\nThese files can be imported into your endpoints and pages as siblings, thanks to the [`rootDirs`](https://www.typescriptlang.org/tsconfig#rootDirs) option in your TypeScript configuration:\n\n```js\n/// file: src/routes/[foo]/[bar]/[baz]/+server.js\n// @filename: $types.d.ts\nimport type * as Kit from '@sveltejs/kit';\n\ntype RouteParams = {\n\tfoo: string;\n\tbar: string;\n\tbaz: string;\n}\n\nexport type RequestHandler = Kit.RequestHandler<RouteParams>;\n\n// @filename: index.js\n// @errors: 2355 2322\n// ---cut---\n/** @type {import('./$types').RequestHandler} */\nexport async function GET({ params }) {\n\t// ...\n}\n```\n\n```js\n/// file: src/routes/[foo]/[bar]/[baz]/+page.js\n// @filename: $types.d.ts\nimport type * as Kit from '@sveltejs/kit';\n\ntype RouteParams = {\n\tfoo: string;\n\tbar: string;\n\tbaz: string;\n}\n\nexport type PageLoad = Kit.Load<RouteParams>;\n\n// @filename: index.js\n// @errors: 2355\n// ---cut---\n/** @type {import('./$types').PageLoad} */\nexport async function load({ params, fetch }) {\n\t// ...\n}\n```\n\nThe return types of the load functions are then available through the `$types` module as `PageData` and `LayoutData` respectively, while the union of the return values of all `Actions` is available as `ActionData`.\n\nStarting with version 2.16.0, two additional helper types are provided: `PageProps` defines `data: PageData`, as well as `form: ActionData`, when there are actions defined, while `LayoutProps` defines `data: LayoutData`, as well as `children: Snippet`.\n\n```svelte\n<!--- file: src/routes/+page.svelte --->\n<script>\n\t/** @type {import('./$types').PageProps} */\n\tlet { data, form } = $props();\n</script>\n```\n\n> [!LEGACY]\n> Before 2.16.0:\n> ```svelte\n> <!--- file: src/routes/+page.svelte --->\n> <script>\n> \t/** @type {{ data: import('./$types').PageData, form: import('./$types').ActionData }} */\n> \tlet { data, form } = $props();\n> </script>\n> ```\n>\n> Using Svelte 4:\n> ```svelte\n> <!--- file: src/routes/+page.svelte --->\n> <script>\n>   /** @type {import('./$types').PageData} */\n>   export let data;\n>   /** @type {import('./$types').ActionData} */\n>   export let form;\n> </script>\n> ```\n\n> [!NOTE] For this to work, your own `tsconfig.json` or `jsconfig.json` should extend from the generated `.svelte-kit/tsconfig.json` (where `.svelte-kit` is your [`outDir`](configuration#outDir)):\n>\n> `{ \"extends\": \"./.svelte-kit/tsconfig.json\" }`\n\n### Default tsconfig.json\n\nThe generated `.svelte-kit/tsconfig.json` file contains a mixture of options. Some are generated programmatically based on your project configuration, and should generally not be overridden without good reason:\n\n```json\n/// file: .svelte-kit/tsconfig.json\n{\n\t\"compilerOptions\": {\n\t\t\"paths\": {\n\t\t\t\"$lib\": [\"../src/lib\"],\n\t\t\t\"$lib/*\": [\"../src/lib/*\"]\n\t\t},\n\t\t\"rootDirs\": [\"..\", \"./types\"]\n\t},\n\t\"include\": [\n\t\t\"ambient.d.ts\",\n\t\t\"non-ambient.d.ts\",\n\t\t\"./types/**/$types.d.ts\",\n\t\t\"../vite.config.js\",\n\t\t\"../vite.config.ts\",\n\t\t\"../src/**/*.js\",\n\t\t\"../src/**/*.ts\",\n\t\t\"../src/**/*.svelte\",\n\t\t\"../tests/**/*.js\",\n\t\t\"../tests/**/*.ts\",\n\t\t\"../tests/**/*.svelte\"\n\t],\n\t\"exclude\": [\n\t\t\"../node_modules/**\",\n\t\t\"../src/service-worker.js\",\n\t\t\"../src/service-worker/**/*.js\",\n\t\t\"../src/service-worker.ts\",\n\t\t\"../src/service-worker/**/*.ts\",\n\t\t\"../src/service-worker.d.ts\",\n\t\t\"../src/service-worker/**/*.d.ts\"\n\t]\n}\n```\n\nOthers are required for SvelteKit to work properly, and should also be left untouched unless you know what you're doing:\n\n```json\n/// file: .svelte-kit/tsconfig.json\n{\n\t\"compilerOptions\": {\n\t\t// this ensures that types are explicitly\n\t\t// imported with `import type`, which is\n\t\t// necessary as Svelte/Vite cannot\n\t\t// otherwise compile components correctly\n\t\t\"verbatimModuleSyntax\": true,\n\n\t\t// Vite compiles one TypeScript module\n\t\t// at a time, rather than compiling\n\t\t// the entire module graph\n\t\t\"isolatedModules\": true,\n\n\t\t// Tell TS it's used only for type-checking\n\t\t\"noEmit\": true,\n\n\t\t// This ensures both `vite build`\n\t\t// and `svelte-package` work correctly\n\t\t\"lib\": [\"esnext\", \"DOM\", \"DOM.Iterable\"],\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"module\": \"esnext\",\n\t\t\"target\": \"esnext\"\n\t}\n}\n```\n\nUse the [`typescript.config` setting](configuration#typescript) in `svelte.config.js` to extend or modify the generated `tsconfig.json`.\n\n## $lib\n\nThis is a simple alias to `src/lib`. It allows you to access common components and utility modules without `../../../../` nonsense.\n\n### $lib/server\n\nA subdirectory of `$lib`. SvelteKit will prevent you from importing any modules in `$lib/server` into client-side code. See [server-only modules](server-only-modules).\n\n## app.d.ts\n\nThe `app.d.ts` file is home to the ambient types of your apps, i.e. types that are available without explicitly importing them.\n\nAlways part of this file is the `App` namespace. This namespace contains several types that influence the shape of certain SvelteKit features you interact with.\n\n> TYPES: App\n"
  },
  {
    "path": "documentation/docs/98-reference/index.md",
    "content": "---\ntitle: Reference\n---\n"
  },
  {
    "path": "documentation/docs/index.md",
    "content": "---\ntitle: SvelteKit\n---\n"
  },
  {
    "path": "eslint.config.js",
    "content": "import svelte_config from '@sveltejs/eslint-config';\nimport noRuntimeToExportsImports from './.eslint/no-runtime-to-exports-imports.js';\n\n/** @type {import('eslint').Linter.Config[]} */\nexport default [\n\t...svelte_config,\n\t{\n\t\trules: {\n\t\t\t'no-undef': 'off'\n\t\t}\n\t},\n\t{\n\t\tfiles: ['packages/kit/src/runtime/**/*.js'],\n\t\tplugins: {\n\t\t\t'kit-custom': {\n\t\t\t\trules: {\n\t\t\t\t\t'no-runtime-to-exports-imports': noRuntimeToExportsImports\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\trules: {\n\t\t\t'kit-custom/no-runtime-to-exports-imports': 'error'\n\t\t}\n\t},\n\t{\n\t\tignores: [\n\t\t\t'**/.svelte-kit',\n\t\t\t'**/.netlify',\n\t\t\t'**/.vercel',\n\t\t\t'**/.wrangler',\n\t\t\t'**/test-results',\n\t\t\t'**/dist',\n\t\t\t'**/.custom-out-dir',\n\t\t\t'packages/adapter-*/files',\n\t\t\t'packages/kit/src/core/config/fixtures/multiple', // dir contains svelte config with multiple extensions tripping eslint\n\t\t\t'packages/kit/types/index.d.ts', // generated file\n\t\t\t'packages/*/test/**/build/**',\n\t\t\t'packages/package/test/fixtures/typescript-svelte-config/expected',\n\t\t\t'packages/package/test/errors/**/*',\n\t\t\t'packages/package/test/fixtures/**/*'\n\t\t]\n\t},\n\t{\n\t\tlanguageOptions: {\n\t\t\tparserOptions: {\n\t\t\t\tprojectService: true\n\t\t\t}\n\t\t},\n\t\trules: {\n\t\t\t'@typescript-eslint/await-thenable': 'error',\n\t\t\t'@typescript-eslint/no-unused-expressions': 'off',\n\t\t\t'@typescript-eslint/require-await': 'error',\n\t\t\t'@typescript-eslint/no-floating-promises': 'error'\n\t\t},\n\t\tignores: [\n\t\t\t'packages/adapter-cloudflare/test/apps/**/*',\n\t\t\t'packages/adapter-netlify/test/apps/**/*',\n\t\t\t'packages/adapter-node/rollup.config.js',\n\t\t\t'packages/adapter-node/tests/smoke.spec_disabled.js',\n\t\t\t'packages/adapter-static/test/apps/**/*',\n\t\t\t'packages/adapter-vercel/test/apps/**/*',\n\t\t\t'packages/kit/src/core/sync/create_manifest_data/test/samples/**/*',\n\t\t\t'packages/kit/test/apps/**/*',\n\t\t\t'packages/kit/test/build-errors/**/*',\n\t\t\t'packages/kit/test/prerendering/**/*',\n\t\t\t'packages/test-redirect-importer/index.js',\n\t\t\t'packages/adapter-netlify/test/preview.js'\n\t\t]\n\t}\n];\n"
  },
  {
    "path": "package.json",
    "content": "{\n\t\"name\": \"kit-monorepo\",\n\t\"version\": \"0.0.1\",\n\t\"description\": \"monorepo for @sveltejs/kit and friends\",\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"test:kit\": \"pnpm run --dir packages/kit test\",\n\t\t\"test:cross-platform:dev\": \"pnpm run --dir packages/kit test:cross-platform:dev\",\n\t\t\"test:cross-platform:build\": \"pnpm run --dir packages/kit test:cross-platform:build\",\n\t\t\"test:server-side-route-resolution:dev\": \"pnpm run --dir packages/kit test:server-side-route-resolution:dev\",\n\t\t\"test:server-side-route-resolution:build\": \"pnpm run --dir packages/kit test:server-side-route-resolution:build\",\n\t\t\"test:svelte-async:dev\": \"pnpm run --dir packages/kit test:svelte-async:dev\",\n\t\t\"test:svelte-async:build\": \"pnpm run --dir packages/kit test:svelte-async:build\",\n\t\t\"test:vite-ecosystem-ci\": \"pnpm --dir packages/kit test\",\n\t\t\"test:others\": \"pnpm -r --filter='./packages/*' --filter=!./packages/kit/ --workspace-concurrency=1 test\",\n\t\t\"check\": \"pnpm -r prepublishOnly && pnpm -r check\",\n\t\t\"lint\": \"pnpm -r lint && eslint --cache --cache-location node_modules/.eslintcache 'packages/**/*.js'\",\n\t\t\"format\": \"pnpm -r format\",\n\t\t\"precommit\": \"pnpm format && pnpm lint\",\n\t\t\"changeset:version\": \"changeset version && pnpm -r generate:version && git add --all\",\n\t\t\"changeset:release\": \"changeset publish\",\n\t\t\"build\": \"pnpm --filter '@sveltejs/*' -r build\",\n\t\t\"sync-all\": \"node scripts/sync-all.js\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@changesets/cli\": \"catalog:\",\n\t\t\"@playwright/test\": \"catalog:\",\n\t\t\"@sveltejs/eslint-config\": \"catalog:\",\n\t\t\"@svitejs/changesets-changelog-github-compact\": \"catalog:\",\n\t\t\"eslint\": \"catalog:\",\n\t\t\"prettier\": \"catalog:\",\n\t\t\"prettier-plugin-svelte\": \"catalog:\"\n\t},\n\t\"packageManager\": \"pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be\",\n\t\"engines\": {\n\t\t\"pnpm\": \">=9.0.0\"\n\t},\n\t\"pnpm\": {\n\t\t\"onlyBuiltDependencies\": [\n\t\t\t\"@parcel/watcher\",\n\t\t\t\"esbuild\",\n\t\t\t\"protobufjs\",\n\t\t\t\"rolldown\",\n\t\t\t\"sharp\",\n\t\t\t\"svelte-preprocess\",\n\t\t\t\"unix-dgram\",\n\t\t\t\"workerd\"\n\t\t]\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-auto/.gitignore",
    "content": ".DS_Store\nnode_modules\n"
  },
  {
    "path": "packages/adapter-auto/CHANGELOG.md",
    "content": "# @sveltejs/adapter-auto\n\n## 7.0.1\n### Patch Changes\n\n\n- feat: update adapter-netlify to version 6 ([`77ab341`](https://github.com/sveltejs/kit/commit/77ab3414d548c79bf106408881c397c6039ee885))\n\n## 7.0.0\n### Major Changes\n\n\n- feat: update adapter-vercel to version 6 ([#14737](https://github.com/sveltejs/kit/pull/14737))\n\n## 6.1.1\n### Patch Changes\n\n\n- chore: update \"homepage\" field in package.json ([#14579](https://github.com/sveltejs/kit/pull/14579))\n\n## 6.1.0\n### Minor Changes\n\n\n- feat: add Deno as a supported package manager ([#14163](https://github.com/sveltejs/kit/pull/14163))\n\n\n### Patch Changes\n\n- Updated dependencies [[`ece3906`](https://github.com/sveltejs/kit/commit/ece3906e11ab0eeac3778abc4666f2145f98f22e), [`5ac9d27`](https://github.com/sveltejs/kit/commit/5ac9d2737263364c9b6e63b115b7aa9792bd1b3f), [`fed6331`](https://github.com/sveltejs/kit/commit/fed6331722a3ea47df9dd8ab01ba23f549fe5385), [`69f4e5f`](https://github.com/sveltejs/kit/commit/69f4e5feacfee429025e78b0e1e0a7b2e0639dc9), [`6b34122`](https://github.com/sveltejs/kit/commit/6b34122b4446da545d261ad96217016412b16510), [`9493537`](https://github.com/sveltejs/kit/commit/949353793a2d27e7cc44dddbdbcf40639b33a4b7), [`f67ba09`](https://github.com/sveltejs/kit/commit/f67ba09e43a598e20d7f8bba62bbc0547fd3f8b1)]:\n  - @sveltejs/kit@2.28.0\n\n## 6.0.2\n### Patch Changes\n\n\n- chore: add `.git` to the end of `package.json` repository url ([#14134](https://github.com/sveltejs/kit/pull/14134))\n\n- Updated dependencies [[`c968aef`](https://github.com/sveltejs/kit/commit/c968aef5727f978244d5160657b4a7ac651384ae)]:\n  - @sveltejs/kit@2.27.3\n\n## 6.0.1\n### Patch Changes\n\n\n- chore: remove `import-meta-resolve` dependency ([#13629](https://github.com/sveltejs/kit/pull/13629))\n\n- Updated dependencies [[`bd1c04662332cbafa843c35a2e783486116af3d5`](https://github.com/sveltejs/kit/commit/bd1c04662332cbafa843c35a2e783486116af3d5), [`09f61ec2a14573e27769edb403c58aea5433a39f`](https://github.com/sveltejs/kit/commit/09f61ec2a14573e27769edb403c58aea5433a39f), [`09f61ec2a14573e27769edb403c58aea5433a39f`](https://github.com/sveltejs/kit/commit/09f61ec2a14573e27769edb403c58aea5433a39f)]:\n  - @sveltejs/kit@2.21.0\n\n## 6.0.0\n### Major Changes\n\n\n- feat: upgrade `@sveltejs/adapter-cloudflare` to version 7 ([#13661](https://github.com/sveltejs/kit/pull/13661))\n\n## 5.0.0\n### Major Changes\n\n\n- feat: update Netlify and Cloudflare Pages major versions ([#13615](https://github.com/sveltejs/kit/pull/13615))\n\n## 4.0.0\n### Major Changes\n\n\n- feat: update Vercel, Cloudflare Pages, and Netlify adapter major versions ([#13142](https://github.com/sveltejs/kit/pull/13142))\n\n\n### Patch Changes\n\n- Updated dependencies [[`1bedcc1cfc1f2d85946c1423f60faa8a2a56148b`](https://github.com/sveltejs/kit/commit/1bedcc1cfc1f2d85946c1423f60faa8a2a56148b), [`e201fa9380a00e072a80a2dcab56de3d77e5b67c`](https://github.com/sveltejs/kit/commit/e201fa9380a00e072a80a2dcab56de3d77e5b67c), [`f3f08582d41b08c3fd1daf742e5703d9cdca7823`](https://github.com/sveltejs/kit/commit/f3f08582d41b08c3fd1daf742e5703d9cdca7823), [`d4bcfccb4503b12fe76140dbb6cfddc81f9419fc`](https://github.com/sveltejs/kit/commit/d4bcfccb4503b12fe76140dbb6cfddc81f9419fc), [`d09bc033123903f359c1ad6fd3a6d8d7fc19298a`](https://github.com/sveltejs/kit/commit/d09bc033123903f359c1ad6fd3a6d8d7fc19298a)]:\n  - @sveltejs/kit@2.15.3\n\n## 3.3.1\n### Patch Changes\n\n\n- docs: update URLs for new svelte.dev site ([#12857](https://github.com/sveltejs/kit/pull/12857))\n\n- Updated dependencies [[`dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46`](https://github.com/sveltejs/kit/commit/dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46), [`4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d`](https://github.com/sveltejs/kit/commit/4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d), [`3a9b78f04786898ca93f6d4b75ab18d26bc45192`](https://github.com/sveltejs/kit/commit/3a9b78f04786898ca93f6d4b75ab18d26bc45192), [`723eb8b31e6a22c82f730c30e485386c8676b746`](https://github.com/sveltejs/kit/commit/723eb8b31e6a22c82f730c30e485386c8676b746), [`8ec471c875345b751344e67580ff1b772ef2735b`](https://github.com/sveltejs/kit/commit/8ec471c875345b751344e67580ff1b772ef2735b)]:\n  - @sveltejs/kit@2.7.3\n\n## 3.3.0\n### Minor Changes\n\n\n- feat: add support for Bun package manager ([#12854](https://github.com/sveltejs/kit/pull/12854))\n\n## 3.2.5\n### Patch Changes\n\n\n- fix: import `node:process` instead of using globals ([#12641](https://github.com/sveltejs/kit/pull/12641))\n\n- Updated dependencies [[`e798ef718f163bed4f93e1918bd8294f765376ad`](https://github.com/sveltejs/kit/commit/e798ef718f163bed4f93e1918bd8294f765376ad)]:\n  - @sveltejs/kit@2.5.28\n\n## 3.2.4\n### Patch Changes\n\n\n- chore: configure provenance in a simpler manner ([#12570](https://github.com/sveltejs/kit/pull/12570))\n\n- Updated dependencies [[`087a43d391fc38b8c008fb39a804dc6988974101`](https://github.com/sveltejs/kit/commit/087a43d391fc38b8c008fb39a804dc6988974101)]:\n  - @sveltejs/kit@2.5.22\n\n## 3.2.3\n### Patch Changes\n\n\n- chore: package provenance ([#12567](https://github.com/sveltejs/kit/pull/12567))\n\n- Updated dependencies [[`4930a8443caa53bcecee7b690cd28e429b1c8a20`](https://github.com/sveltejs/kit/commit/4930a8443caa53bcecee7b690cd28e429b1c8a20)]:\n  - @sveltejs/kit@2.5.21\n\n## 3.2.2\n\n### Patch Changes\n\n- chore: add keywords for discovery in npm search ([#12330](https://github.com/sveltejs/kit/pull/12330))\n\n- Updated dependencies [[`25acb1d9fce998dccd8050b93cf4142c2b082611`](https://github.com/sveltejs/kit/commit/25acb1d9fce998dccd8050b93cf4142c2b082611), [`642c4a4aff4351b786fe6274aa2f0bf7d905faf9`](https://github.com/sveltejs/kit/commit/642c4a4aff4351b786fe6274aa2f0bf7d905faf9), [`0a0e9aa897123ebec50af08e9385b2ca4fc5bb28`](https://github.com/sveltejs/kit/commit/0a0e9aa897123ebec50af08e9385b2ca4fc5bb28)]:\n  - @sveltejs/kit@2.5.11\n\n## 3.2.1\n\n### Patch Changes\n\n- fix: bump import-meta-resolve to remove deprecation warnings ([#12240](https://github.com/sveltejs/kit/pull/12240))\n\n- Updated dependencies [[`460d4526c80358958e58a2451fe1b663fdc656e9`](https://github.com/sveltejs/kit/commit/460d4526c80358958e58a2451fe1b663fdc656e9), [`16cd900c304e0cf0f16b484aa61a5ba0531d8751`](https://github.com/sveltejs/kit/commit/16cd900c304e0cf0f16b484aa61a5ba0531d8751)]:\n  - @sveltejs/kit@2.5.10\n\n## 3.2.0\n\n### Minor Changes\n\n- feat: add support for Google Cloud Run ([#12015](https://github.com/sveltejs/kit/pull/12015))\n\n## 3.1.1\n\n### Patch Changes\n\n- fix: better error message when using `read` ([#11689](https://github.com/sveltejs/kit/pull/11689))\n\n## 3.1.0\n\n### Minor Changes\n\n- feat: bump Azure adapter version ([#11496](https://github.com/sveltejs/kit/pull/11496))\n\n## 3.0.1\n\n### Patch Changes\n\n- chore: update primary branch from master to main ([`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d))\n\n- Updated dependencies [[`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d), [`16961e8cd3fa6a7f382153b1ff056bc2aae9b31b`](https://github.com/sveltejs/kit/commit/16961e8cd3fa6a7f382153b1ff056bc2aae9b31b), [`197e01f95652f511160f38b37b9da73a124ecd48`](https://github.com/sveltejs/kit/commit/197e01f95652f511160f38b37b9da73a124ecd48), [`102e4a5ae5b29624302163faf5a20c94a64a5b2c`](https://github.com/sveltejs/kit/commit/102e4a5ae5b29624302163faf5a20c94a64a5b2c), [`f8e3d8b9728c9f1ab63389342c31d7246b6f9db6`](https://github.com/sveltejs/kit/commit/f8e3d8b9728c9f1ab63389342c31d7246b6f9db6)]:\n  - @sveltejs/kit@2.0.4\n\n## 3.0.0\n\n### Major Changes\n\n- breaking: require SvelteKit 2 ([#11316](https://github.com/sveltejs/kit/pull/11316))\n\n## 2.1.1\n\n### Patch Changes\n\n- chore(deps): update dependency `import-meta-resolve` to v4 ([#10970](https://github.com/sveltejs/kit/pull/10970))\n\n- Updated dependencies [[`072430ec5`](https://github.com/sveltejs/kit/commit/072430ec5c64782cd25c750f40534fea9cab4b40)]:\n  - @sveltejs/kit@1.27.3\n\n## 2.1.0\n\n### Minor Changes\n\n- [feat] support AWS via SST ([#9874](https://github.com/sveltejs/kit/pull/9874))\n\n## 2.0.1\n\n### Patch Changes\n\n- chore: update dependency `import-meta-resolve` to v3 ([#9758](https://github.com/sveltejs/kit/pull/9758))\n\n- Updated dependencies [[`aae5992e4`](https://github.com/sveltejs/kit/commit/aae5992e4568d93b477befe02b4018a59a298262), [`415358258`](https://github.com/sveltejs/kit/commit/415358258797911a8406c3b1e569b7cdcae6b207)]:\n  - @sveltejs/kit@1.15.8\n\n## 2.0.0\n\n### Major Changes\n\n- breaking: bump `@sveltejs/kit` peer dependency ([#8740](https://github.com/sveltejs/kit/pull/8740))\n\n### Patch Changes\n\n- Updated dependencies [[`c7648f66`](https://github.com/sveltejs/kit/commit/c7648f6608a413e2654625cbd30f890d2148cf13), [`63613bf1`](https://github.com/sveltejs/kit/commit/63613bf194c18ce50e111585ad770fc93f9e43c7), [`d1f7655e`](https://github.com/sveltejs/kit/commit/d1f7655efdff70d91f94fe0cb0de50ed2511b5e5)]:\n  - @sveltejs/kit@1.5.0\n\n## 1.0.3\n\n### Patch Changes\n\n- fix: pin adapter versions ([#8874](https://github.com/sveltejs/kit/pull/8874))\n\n- Updated dependencies [[`f8dd7754`](https://github.com/sveltejs/kit/commit/f8dd7754ea21b11063613aac7d0d6cd98fc28b8e), [`fafe7d5f`](https://github.com/sveltejs/kit/commit/fafe7d5f033b249d554879b5ab7bc641f0ace362), [`e56a13c6`](https://github.com/sveltejs/kit/commit/e56a13c68a7d885f83f519c43f3510f10fee4ca5), [`02bd767d`](https://github.com/sveltejs/kit/commit/02bd767d3277a840b480fe94444cd1c886ef519b), [`97d68b13`](https://github.com/sveltejs/kit/commit/97d68b1381c1e0d052a0978824e96b9f50d248a9), [`2ef9b7d1`](https://github.com/sveltejs/kit/commit/2ef9b7d124809ce6a9804abbeaa4647a99fac97c), [`64a279f7`](https://github.com/sveltejs/kit/commit/64a279f7f92dcd4855af83fcbb09ea5ba1521ee8)]:\n  - @sveltejs/kit@1.4.0\n\n## 1.0.2\n\n### Patch Changes\n\n- docs: move adapter docs to site ([#8531](https://github.com/sveltejs/kit/pull/8531))\n\n## 1.0.1\n\n### Patch Changes\n\n- chore: remove superfluous main field from package.json ([#8519](https://github.com/sveltejs/kit/pull/8519))\n\n- Updated dependencies [[`7e2d3405`](https://github.com/sveltejs/kit/commit/7e2d34056e99f371e22406d941b764df365a2649)]:\n  - @sveltejs/kit@1.1.1\n\n## 1.0.0\n\n### Major Changes\n\nFirst major release, see below for the history of changes that lead up to this.\nStarting from now all releases follow semver and changes will be listed as Major/Minor/Patch\n\n## 1.0.0-next.91\n\n### Patch Changes\n\n- chore: add peerDependencies, add more specific next version ([#8141](https://github.com/sveltejs/kit/pull/8141))\n\n## 1.0.0-next.90\n\n### Patch Changes\n\n- Upgrade dependencies ([#7852](https://github.com/sveltejs/kit/pull/7852))\n\n## 1.0.0-next.89\n\n### Patch Changes\n\n- defer adapter installation until actually needed ([#7739](https://github.com/sveltejs/kit/pull/7739))\n\n## 1.0.0-next.88\n\n### Patch Changes\n\n- feat: install adapters on demand ([#7462](https://github.com/sveltejs/kit/pull/7462))\n\n## 1.0.0-next.87\n\n### Patch Changes\n\n- Updated dependencies [[`7259ed67`](https://github.com/sveltejs/kit/commit/7259ed67c2bee882135bcf43577611bab6903f90)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.84\n  - @sveltejs/adapter-vercel@1.0.0-next.81\n\n## 1.0.0-next.86\n\n### Patch Changes\n\n- update dependencies ([#7355](https://github.com/sveltejs/kit/pull/7355))\n- Updated dependencies [[`e141513d`](https://github.com/sveltejs/kit/commit/e141513dd395466cc2e1649c8c9bfe36c0633846)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.40\n  - @sveltejs/adapter-netlify@1.0.0-next.83\n  - @sveltejs/adapter-vercel@1.0.0-next.81\n\n## 1.0.0-next.85\n\n### Patch Changes\n\n- Updated dependencies [[`97d45c0c`](https://github.com/sveltejs/kit/commit/97d45c0cca9c06e71f91a0777d4748f96d400b4d)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.82\n  - @sveltejs/adapter-vercel@1.0.0-next.80\n\n## 1.0.0-next.84\n\n### Patch Changes\n\n- Updated dependencies [[`8d83708a`](https://github.com/sveltejs/kit/commit/8d83708ab021e367dc0eaa3ed57daf30a56497d7)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.80\n  - @sveltejs/adapter-netlify@1.0.0-next.81\n\n## 1.0.0-next.83\n\n### Patch Changes\n\n- Updated dependencies [[`b4c26809`](https://github.com/sveltejs/kit/commit/b4c268091b246befb1cb028875781285c9ff4aa5)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.39\n  - @sveltejs/adapter-netlify@1.0.0-next.81\n  - @sveltejs/adapter-vercel@1.0.0-next.79\n\n## 1.0.0-next.82\n\n### Patch Changes\n\n- Updated dependencies [[`b5a0991c`](https://github.com/sveltejs/kit/commit/b5a0991c1692ff87d04be0cdb0a562a20de113a1)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.80\n  - @sveltejs/adapter-vercel@1.0.0-next.78\n\n## 1.0.0-next.81\n\n### Patch Changes\n\n- Updated dependencies [[`2555e64b`](https://github.com/sveltejs/kit/commit/2555e64be5ca8433c623e7838dc9c570ad024aed)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.79\n  - @sveltejs/adapter-vercel@1.0.0-next.77\n\n## 1.0.0-next.80\n\n### Patch Changes\n\n- Updated dependencies [[`d0e63d44`](https://github.com/sveltejs/kit/commit/d0e63d445e19e2df7a5e7d35f42b2ba1ae5e5745)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.38\n\n## 1.0.0-next.79\n\n### Patch Changes\n\n- Updated dependencies [[`ae8225d4`](https://github.com/sveltejs/kit/commit/ae8225d4e547c8bc07d82e516dd49315eddb56c3)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.37\n  - @sveltejs/adapter-netlify@1.0.0-next.78\n  - @sveltejs/adapter-vercel@1.0.0-next.77\n\n## 1.0.0-next.78\n\n### Patch Changes\n\n- Updated dependencies [[`737160d8`](https://github.com/sveltejs/kit/commit/737160d88cd96323eeac317ed08b4f0d6d83c482)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.77\n  - @sveltejs/adapter-netlify@1.0.0-next.78\n\n## 1.0.0-next.77\n\n### Patch Changes\n\n- Updated dependencies [[`e40acb56`](https://github.com/sveltejs/kit/commit/e40acb561e32a2ee5bcb6d289ebd1284d7af247b)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.36\n\n## 1.0.0-next.76\n\n### Patch Changes\n\n- Updated dependencies [[`ae2e4bf2`](https://github.com/sveltejs/kit/commit/ae2e4bf2c5fe0aeba4cba21d51362837f66d1949)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.35\n\n## 1.0.0-next.75\n\n### Patch Changes\n\n- Updated dependencies [[`fc1834b7`](https://github.com/sveltejs/kit/commit/fc1834b79ac85066ccb0f995958276628f944147)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.34\n  - @sveltejs/adapter-netlify@1.0.0-next.78\n  - @sveltejs/adapter-vercel@1.0.0-next.76\n\n## 1.0.0-next.74\n\n### Patch Changes\n\n- feat: support Azure SWA ([#6761](https://github.com/sveltejs/kit/pull/6761))\n- Updated dependencies [[`2040baee`](https://github.com/sveltejs/kit/commit/2040baee98cf85fe542e1e38a9fb60ede3f95f1d)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.75\n  - @sveltejs/adapter-netlify@1.0.0-next.77\n\n## 1.0.0-next.73\n\n### Patch Changes\n\n- Updated dependencies [[`b32b3ac9`](https://github.com/sveltejs/kit/commit/b32b3ac9c05efebfab5651de9bf5cdd0d4d54c12), [`ee5777e3`](https://github.com/sveltejs/kit/commit/ee5777e33695d2ddf1742a5e1d0144674d48d2d3)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.33\n  - @sveltejs/adapter-netlify@1.0.0-next.77\n  - @sveltejs/adapter-vercel@1.0.0-next.74\n\n## 1.0.0-next.72\n\n### Patch Changes\n\n- Updated dependencies [[`f1e762bf`](https://github.com/sveltejs/kit/commit/f1e762bff16acc56b0d1e10c9cadeada0d25017d)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.73\n  - @sveltejs/adapter-netlify@1.0.0-next.76\n\n## 1.0.0-next.71\n\n### Patch Changes\n\n- Updated dependencies [[`6b06da84`](https://github.com/sveltejs/kit/commit/6b06da84b2454f42cbf7e8bcb643169af74428db)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.76\n  - @sveltejs/adapter-vercel@1.0.0-next.72\n\n## 1.0.0-next.70\n\n### Patch Changes\n\n- Updated dependencies [[`4b48d1bd`](https://github.com/sveltejs/kit/commit/4b48d1bd5005dc8e059b17fa42f0d08674aad30c)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.72\n  - @sveltejs/adapter-netlify@1.0.0-next.75\n\n## 1.0.0-next.69\n\n### Patch Changes\n\n- Updated dependencies [[`c530d337`](https://github.com/sveltejs/kit/commit/c530d33793a228fac684c71ed7926e6217101a90)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.75\n  - @sveltejs/adapter-vercel@1.0.0-next.71\n\n## 1.0.0-next.68\n\n### Patch Changes\n\n- Updated dependencies [[`331e0a80`](https://github.com/sveltejs/kit/commit/331e0a80b5e63f75c8226ddc93d0b0beefd40de3)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.70\n  - @sveltejs/adapter-netlify@1.0.0-next.74\n\n## 1.0.0-next.67\n\n### Patch Changes\n\n- Updated dependencies [[`ddd3b630`](https://github.com/sveltejs/kit/commit/ddd3b630090cd098a1038a56765e570339697830)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.69\n  - @sveltejs/adapter-netlify@1.0.0-next.73\n\n## 1.0.0-next.66\n\n### Patch Changes\n\n- Updated dependencies [[`64449a71`](https://github.com/sveltejs/kit/commit/64449a7138b9b5bce913dce1290bd6ff8a44c906)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.32\n  - @sveltejs/adapter-netlify@1.0.0-next.72\n  - @sveltejs/adapter-vercel@1.0.0-next.68\n\n## 1.0.0-next.65\n\n### Patch Changes\n\n- Updated dependencies [[`4bd84b32`](https://github.com/sveltejs/kit/commit/4bd84b326889f71c2ebaacfc7f0f1b3a19017a4c)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.67\n  - @sveltejs/adapter-netlify@1.0.0-next.71\n\n## 1.0.0-next.64\n\n### Patch Changes\n\n- Updated dependencies [[`b1a40552`](https://github.com/sveltejs/kit/commit/b1a40552aa6d9bd16d1f2bb5d7359dcc0101d2ea)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.31\n  - @sveltejs/adapter-netlify@1.0.0-next.71\n  - @sveltejs/adapter-vercel@1.0.0-next.66\n\n## 1.0.0-next.63\n\n### Patch Changes\n\n- Updated dependencies [[`81917206`](https://github.com/sveltejs/kit/commit/819172065cdda6c695f3fb48e60fa451c1caaae6)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.30\n  - @sveltejs/adapter-netlify@1.0.0-next.70\n  - @sveltejs/adapter-vercel@1.0.0-next.65\n\n## 1.0.0-next.62\n\n### Patch Changes\n\n- Updated dependencies [[`2a9c1925`](https://github.com/sveltejs/kit/commit/2a9c19252912d61bd840441fe80dc13366af41f7)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.64\n  - @sveltejs/adapter-netlify@1.0.0-next.69\n\n## 1.0.0-next.61\n\n### Patch Changes\n\n- Updated dependencies [[`bbb8a8e0`](https://github.com/sveltejs/kit/commit/bbb8a8e0f0d2ca6513ecc8da5964877acbebf4b7)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.63\n\n## 1.0.0-next.60\n\n### Patch Changes\n\n- Updated dependencies [[`5e7ca20d`](https://github.com/sveltejs/kit/commit/5e7ca20d79682416fb11aefc3f3abe0f1878d188)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.29\n  - @sveltejs/adapter-netlify@1.0.0-next.69\n  - @sveltejs/adapter-vercel@1.0.0-next.62\n\n## 1.0.0-next.59\n\n### Patch Changes\n\n- Updated dependencies [[`d090a59b`](https://github.com/sveltejs/kit/commit/d090a59b89114f5f4ec605149f28a1e1748358ea)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.61\n\n## 1.0.0-next.58\n\n### Patch Changes\n\n- Updated dependencies [[`cdbce6b1`](https://github.com/sveltejs/kit/commit/cdbce6b10e960a8839916ab5db11c79b450541f7)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.28\n\n## 1.0.0-next.57\n\n### Patch Changes\n\n- Updated dependencies [[`10f2105d`](https://github.com/sveltejs/kit/commit/10f2105d5d33640cfd7365b3747c131a90281834)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.27\n\n## 1.0.0-next.56\n\n### Patch Changes\n\n- Updated dependencies [[`31fbb1cb`](https://github.com/sveltejs/kit/commit/31fbb1cb4dc9fd29edff5993bb85da8863b54e79)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.68\n\n## 1.0.0-next.55\n\n### Patch Changes\n\n- chore: upgrade TypeScript to 4.7.4 ([#5414](https://github.com/sveltejs/kit/pull/5414))\n- Updated dependencies [[`3799a89e`](https://github.com/sveltejs/kit/commit/3799a89e7913b71da4dab749ec1423215c4a20a1)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.26\n  - @sveltejs/adapter-netlify@1.0.0-next.67\n  - @sveltejs/adapter-vercel@1.0.0-next.60\n\n## 1.0.0-next.54\n\n### Patch Changes\n\n- Updated dependencies [[`320777aa`](https://github.com/sveltejs/kit/commit/320777aad1f0d2141e36738fc440589e3232304d)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.25\n\n## 1.0.0-next.53\n\n### Patch Changes\n\n- Updated dependencies [[`8883ab72`](https://github.com/sveltejs/kit/commit/8883ab72bf2a9ce1815ef8ebd5eb7b028cd5a6dd)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.24\n  - @sveltejs/adapter-netlify@1.0.0-next.66\n  - @sveltejs/adapter-vercel@1.0.0-next.59\n\n## 1.0.0-next.52\n\n### Patch Changes\n\n- Updated dependencies [[`c399840e`](https://github.com/sveltejs/kit/commit/c399840ecaa33d84e396b6d4c6658c240d248455)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.59\n  - @sveltejs/adapter-netlify@1.0.0-next.65\n\n## 1.0.0-next.51\n\n### Patch Changes\n\n- Updated dependencies [[`1974386d`](https://github.com/sveltejs/kit/commit/1974386d001beff62d92ca1d174a06c5681d3158)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.65\n  - @sveltejs/adapter-vercel@1.0.0-next.58\n\n## 1.0.0-next.50\n\n### Patch Changes\n\n- Update dependencies ([#5121](https://github.com/sveltejs/kit/pull/5121))\n- Updated dependencies [[`821592f3`](https://github.com/sveltejs/kit/commit/821592f36e4e507cbfa5a0e0a1ee99be9991e827)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.23\n  - @sveltejs/adapter-netlify@1.0.0-next.64\n  - @sveltejs/adapter-vercel@1.0.0-next.58\n\n## 1.0.0-next.49\n\n### Patch Changes\n\n- Update adapter entrypoint typings to be NodeNext/ESNext-compatible ([#5111](https://github.com/sveltejs/kit/pull/5111))\n- Updated dependencies [[`7d5fb308`](https://github.com/sveltejs/kit/commit/7d5fb3083a428c4b045d7845138efdb40e1ebad8)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.22\n  - @sveltejs/adapter-netlify@1.0.0-next.63\n  - @sveltejs/adapter-vercel@1.0.0-next.57\n\n## 1.0.0-next.48\n\n### Patch Changes\n\n- Updated dependencies [[`60370cc2`](https://github.com/sveltejs/kit/commit/60370cc242ff0879401d3b10eb38e9c22e41b7ab), [`f0fb175d`](https://github.com/sveltejs/kit/commit/f0fb175dda834807dc51964105e4ecce33c4ad0b)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.56\n  - @sveltejs/adapter-cloudflare@1.0.0-next.21\n  - @sveltejs/adapter-netlify@1.0.0-next.62\n\n## 1.0.0-next.47\n\n### Patch Changes\n\n- Add types to pkg.exports ([#5045](https://github.com/sveltejs/kit/pull/5045))\n- Updated dependencies [[`9b13c61c`](https://github.com/sveltejs/kit/commit/9b13c61c68ac4fe601e0a95cf958f7b63fa7a754)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.20\n  - @sveltejs/adapter-netlify@1.0.0-next.61\n  - @sveltejs/adapter-vercel@1.0.0-next.55\n\n## 1.0.0-next.46\n\n### Patch Changes\n\n- Updated dependencies [[`e3c9073a`](https://github.com/sveltejs/kit/commit/e3c9073a8b43f1dd4aa871639b61cb974a1f110e)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.60\n  - @sveltejs/adapter-vercel@1.0.0-next.54\n\n## 1.0.0-next.45\n\n### Patch Changes\n\n- Updated dependencies [[`c660143a`](https://github.com/sveltejs/kit/commit/c660143ad2b90ea3a1ae18247c553da2538750a0)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.59\n  - @sveltejs/adapter-vercel@1.0.0-next.54\n\n## 1.0.0-next.44\n\n### Patch Changes\n\n- Updated dependencies [[`a452bd83`](https://github.com/sveltejs/kit/commit/a452bd83ac5feb27040a1cb364395c9ae5c04107)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.53\n\n## 1.0.0-next.43\n\n### Patch Changes\n\n- Updated dependencies [[`0efa319d`](https://github.com/sveltejs/kit/commit/0efa319d0a03c180a66845d1a4933589084ddb48), [`3d34924c`](https://github.com/sveltejs/kit/commit/3d34924c3f3c1af75c326c6d92cdbfb263f0492a), [`e685c5ae`](https://github.com/sveltejs/kit/commit/e685c5aecdefbc57fcbec5624ed43fd7dd01a037)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.58\n  - @sveltejs/adapter-vercel@1.0.0-next.52\n\n## 1.0.0-next.42\n\n### Patch Changes\n\n- Updated dependencies [[`7609ad07`](https://github.com/sveltejs/kit/commit/7609ad0759c895600198eaf4345d735c7c6d1166), [`7609ad07`](https://github.com/sveltejs/kit/commit/7609ad0759c895600198eaf4345d735c7c6d1166)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.51\n  - @sveltejs/adapter-netlify@1.0.0-next.57\n\n## 1.0.0-next.41\n\n### Patch Changes\n\n- Updated dependencies [[`3b83249b`](https://github.com/sveltejs/kit/commit/3b83249ba22353ccfe592d265d2c3b8b71c2c224)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.57\n  - @sveltejs/adapter-vercel@1.0.0-next.50\n\n## 1.0.0-next.40\n\n### Patch Changes\n\n- Updated dependencies [[`f9c30302`](https://github.com/sveltejs/kit/commit/f9c30302d8639983ea2e13bf532f34dbaa78d199)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.19\n  - @sveltejs/adapter-netlify@1.0.0-next.56\n  - @sveltejs/adapter-vercel@1.0.0-next.50\n\n## 1.0.0-next.39\n\n### Patch Changes\n\n- Updated dependencies [[`6821d642`](https://github.com/sveltejs/kit/commit/6821d642478c692ed028e91d8d08c9754aa1db2f)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.50\n  - @sveltejs/adapter-netlify@1.0.0-next.55\n\n## 1.0.0-next.38\n\n### Patch Changes\n\n- Updated dependencies [[`40e50322`](https://github.com/sveltejs/kit/commit/40e50322cd4487d818198f879b90166eccd31c78)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.55\n\n## 1.0.0-next.37\n\n### Patch Changes\n\n- Updated dependencies [[`f862a784`](https://github.com/sveltejs/kit/commit/f862a7844349ab3a233fdc67e0cc8025fde385c6)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.54\n  - @sveltejs/adapter-vercel@1.0.0-next.49\n\n## 1.0.0-next.36\n\n### Patch Changes\n\n- Updated dependencies [[`f15af292`](https://github.com/sveltejs/kit/commit/f15af292f5e91dac4cd526f9ad538b5d593505ce), [`e82fe2b5`](https://github.com/sveltejs/kit/commit/e82fe2b519d3dd84aa77cdd62f4b251874019a6b)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.49\n  - @sveltejs/adapter-netlify@1.0.0-next.53\n\n## 1.0.0-next.35\n\n### Patch Changes\n\n- Updated dependencies [[`467cdb97`](https://github.com/sveltejs/kit/commit/467cdb9713e7d6a3355a35ffb5ee17bcd58a9c30), [`b228fb5b`](https://github.com/sveltejs/kit/commit/b228fb5b119641dca59dcb57d94700ebe3b79155), [`41db4a36`](https://github.com/sveltejs/kit/commit/41db4a36f3673c4b174d872a47afd1efd0db35c4)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.48\n  - @sveltejs/adapter-cloudflare@1.0.0-next.18\n  - @sveltejs/adapter-netlify@1.0.0-next.52\n\n## 1.0.0-next.34\n\n### Patch Changes\n\n- Updated dependencies [[`316943fc`](https://github.com/sveltejs/kit/commit/316943fc2ea3272060636e12eccac430667fc562), [`08bb98c8`](https://github.com/sveltejs/kit/commit/08bb98c8d4f3431bf3e43faeec08ec9669b70e51)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.17\n  - @sveltejs/adapter-netlify@1.0.0-next.51\n  - @sveltejs/adapter-vercel@1.0.0-next.47\n\n## 1.0.0-next.33\n\n### Patch Changes\n\n- Updated dependencies [[`268ee6b9`](https://github.com/sveltejs/kit/commit/268ee6b921ee9cab9f5995b6c5144b3d903ed02a)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.16\n  - @sveltejs/adapter-netlify@1.0.0-next.51\n  - @sveltejs/adapter-vercel@1.0.0-next.47\n\n## 1.0.0-next.32\n\n### Patch Changes\n\n- Select adapter immediately ([#4299](https://github.com/sveltejs/kit/pull/4299))\n- Updated dependencies []:\n  - @sveltejs/adapter-netlify@1.0.0-next.50\n  - @sveltejs/adapter-vercel@1.0.0-next.46\n\n## 1.0.0-next.31\n\n### Patch Changes\n\n- Updated dependencies [[`8aa2920b`](https://github.com/sveltejs/kit/commit/8aa2920b9a05ab2907ee2ffbe9f273ab8e2dbc69)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.15\n  - @sveltejs/adapter-netlify@1.0.0-next.50\n  - @sveltejs/adapter-vercel@1.0.0-next.46\n\n## 1.0.0-next.30\n\n### Patch Changes\n\n- Updated dependencies [[`8c08aa50`](https://github.com/sveltejs/kit/commit/8c08aa505a0b5238cdc2fbe8408b89ff495da1f7)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.49\n  - @sveltejs/adapter-cloudflare@1.0.0-next.14\n  - @sveltejs/adapter-vercel@1.0.0-next.45\n\n## 1.0.0-next.29\n\n### Patch Changes\n\n- Updated dependencies [[`dcb856f8`](https://github.com/sveltejs/kit/commit/dcb856f89ccc5c823fa604fb20e75d88323f83ca)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.48\n  - @sveltejs/adapter-vercel@1.0.0-next.45\n  - @sveltejs/adapter-cloudflare@1.0.0-next.14\n\n## 1.0.0-next.28\n\n### Patch Changes\n\n- Updated dependencies [[`c1bf43e4`](https://github.com/sveltejs/kit/commit/c1bf43e4cc34f565089d82f8579e46ea12ae618e)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.47\n  - @sveltejs/adapter-cloudflare@1.0.0-next.14\n  - @sveltejs/adapter-vercel@1.0.0-next.44\n\n## 1.0.0-next.27\n\n### Patch Changes\n\n- Bumping versions again ([#4090](https://github.com/sveltejs/kit/pull/4090))\n- Updated dependencies [[`69401762`](https://github.com/sveltejs/kit/commit/694017624ec8f1abaad7ebefb867bb065f7adf05)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.14\n\n## 1.0.0-next.26\n\n### Patch Changes\n\n- Attempt to force @next version bump ([#4088](https://github.com/sveltejs/kit/pull/4088))\n- Updated dependencies [[`46f44a61`](https://github.com/sveltejs/kit/commit/46f44a61624bed525e393e669da9b7db566a1e18)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.13\n\n## 1.0.0-next.25\n\n### Patch Changes\n\n- Attempt to bump @next version of adapter-auto ([#4082](https://github.com/sveltejs/kit/pull/4082))\n\n## 1.0.0-next.24\n\n### Patch Changes\n\n- Updated dependencies [[`f223f91a`](https://github.com/sveltejs/kit/commit/f223f91ab8346fb8fc376393603956e72baa6369)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.12\n  - @sveltejs/adapter-netlify@1.0.0-next.46\n  - @sveltejs/adapter-vercel@1.0.0-next.44\n\n## 1.0.0-next.23\n\n### Patch Changes\n\n- Updated dependencies [[`9ee49342`](https://github.com/sveltejs/kit/commit/9ee493426a5571b20d5d84eb59b4b7ded9f3438d)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.11\n  - @sveltejs/adapter-netlify@1.0.0-next.45\n  - @sveltejs/adapter-vercel@1.0.0-next.43\n\n## 1.0.0-next.22\n\n### Patch Changes\n\n- Updated dependencies [[`b05c9f13`](https://github.com/sveltejs/kit/commit/b05c9f13ec4b61053962b99a62794ee3831bf345)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.43\n\n## 1.0.0-next.21\n\n### Patch Changes\n\n- Updated dependencies [[`68fd6843`](https://github.com/sveltejs/kit/commit/68fd684344a0650420a5b9bffa1c91333dcbaa98)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.42\n  - @sveltejs/adapter-cloudflare@1.0.0-next.10\n  - @sveltejs/adapter-netlify@1.0.0-next.45\n\n## 1.0.0-next.20\n\n### Patch Changes\n\n- fix links pointing to multi-page docs ([#3815](https://github.com/sveltejs/kit/pull/3815))\n- Updated dependencies []:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.10\n  - @sveltejs/adapter-netlify@1.0.0-next.45\n  - @sveltejs/adapter-vercel@1.0.0-next.41\n\n## 1.0.0-next.19\n\n### Patch Changes\n\n- Updated dependencies [[`b33f75a4`](https://github.com/sveltejs/kit/commit/b33f75a4edc49d345baf3f6a5bd232232223dcc5)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.10\n  - @sveltejs/adapter-netlify@1.0.0-next.45\n  - @sveltejs/adapter-vercel@1.0.0-next.41\n\n## 1.0.0-next.18\n\n### Patch Changes\n\n- Updated dependencies [[`48f48162`](https://github.com/sveltejs/kit/commit/48f481626908377aa156a4cc4e177d2d7d663c81)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.40\n  - @sveltejs/adapter-cloudflare@1.0.0-next.9\n  - @sveltejs/adapter-netlify@1.0.0-next.44\n\n## 1.0.0-next.17\n\n### Patch Changes\n\n- Updated dependencies [[`667bc815`](https://github.com/sveltejs/kit/commit/667bc8152d094c4537cfc3329dba7c6bb4b9eac1)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.9\n  - @sveltejs/adapter-netlify@1.0.0-next.44\n  - @sveltejs/adapter-vercel@1.0.0-next.39\n\n## 1.0.0-next.16\n\n### Patch Changes\n\n- Updated dependencies [[`90664c9d`](https://github.com/sveltejs/kit/commit/90664c9dd9749086ac0b34aa2acd625174af80cf)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.44\n  - @sveltejs/adapter-cloudflare@1.0.0-next.8\n  - @sveltejs/adapter-vercel@1.0.0-next.39\n\n## 1.0.0-next.15\n\n### Patch Changes\n\n- Updated dependencies [[`1795843a`](https://github.com/sveltejs/kit/commit/1795843ac8551cc06009bd5868c7ef2a65c00200)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.43\n\n## 1.0.0-next.14\n\n### Patch Changes\n\n- Updated dependencies [[`4d58e10c`](https://github.com/sveltejs/kit/commit/4d58e10c36cab47d40c161a87c82512bebeb6b90)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.42\n  - @sveltejs/adapter-cloudflare@1.0.0-next.8\n  - @sveltejs/adapter-vercel@1.0.0-next.39\n\n## 1.0.0-next.13\n\n### Patch Changes\n\n- Updated dependencies [[`ee906a3b`](https://github.com/sveltejs/kit/commit/ee906a3b2b103e4523eb1b6bb13f04d03eb35238)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.8\n  - @sveltejs/adapter-netlify@1.0.0-next.41\n  - @sveltejs/adapter-vercel@1.0.0-next.39\n\n## 1.0.0-next.12\n\n### Patch Changes\n\n- Updated dependencies [[`49114b9a`](https://github.com/sveltejs/kit/commit/49114b9a37e93335b027865e68fa4d58a0a7a2e5)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.40\n  - @sveltejs/adapter-vercel@1.0.0-next.38\n  - @sveltejs/adapter-cloudflare@1.0.0-next.7\n\n## 1.0.0-next.11\n\n### Patch Changes\n\n- Allow `__fetchPolyfill()` to run several times ([#3377](https://github.com/sveltejs/kit/pull/3377))\n- Updated dependencies [[`7569bb27`](https://github.com/sveltejs/kit/commit/7569bb27a640c2bbff6ac02a4c44fdf456bdc227)]:\n  - @sveltejs/adapter-netlify@1.0.0-next.39\n  - @sveltejs/adapter-vercel@1.0.0-next.37\n\n## 1.0.0-next.10\n\n### Patch Changes\n\n- Updated dependencies [[`e100b426`](https://github.com/sveltejs/kit/commit/e100b4269f159016d7235869d002b8a623d8066b)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.7\n  - @sveltejs/adapter-netlify@1.0.0-next.38\n  - @sveltejs/adapter-vercel@1.0.0-next.36\n\n## 1.0.0-next.9\n\n### Patch Changes\n\n- Updated dependencies [[`0f6196fd`](https://github.com/sveltejs/kit/commit/0f6196fd52d59b20df661743dee274e0040813b8)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.6\n\n## 1.0.0-next.8\n\n### Patch Changes\n\n- Updated dependencies [[`a34370c1`](https://github.com/sveltejs/kit/commit/a34370c14af0179b0194deae3050330379cf138d)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.35\n  - @sveltejs/adapter-cloudflare@1.0.0-next.5\n  - @sveltejs/adapter-netlify@1.0.0-next.37\n\n## 1.0.0-next.7\n\n### Patch Changes\n\n- Updated dependencies [[`a1c02e15`](https://github.com/sveltejs/kit/commit/a1c02e158ae324953c1588aefeae35eee23280bf)]:\n  - @sveltejs/adapter-vercel@1.0.0-next.34\n\n## 1.0.0-next.6\n\n### Patch Changes\n\n- Overhaul adapter API ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- Updated dependencies [[`ecb423b5`](https://github.com/sveltejs/kit/commit/ecb423b54d459be8c0693c723799be4171369afd), [`ecb423b5`](https://github.com/sveltejs/kit/commit/ecb423b54d459be8c0693c723799be4171369afd), [`c096899f`](https://github.com/sveltejs/kit/commit/c096899f12c96de34811b6f9ebfc1601d39daa2e), [`ecb423b5`](https://github.com/sveltejs/kit/commit/ecb423b54d459be8c0693c723799be4171369afd), [`ecb423b5`](https://github.com/sveltejs/kit/commit/ecb423b54d459be8c0693c723799be4171369afd)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.5\n  - @sveltejs/adapter-netlify@1.0.0-next.37\n  - @sveltejs/adapter-vercel@1.0.0-next.33\n\n## 1.0.0-next.5\n\n### Patch Changes\n\n- Updated dependencies [[`ad321f8d`](https://github.com/sveltejs/kit/commit/ad321f8d7dadf3f5b874d5aa434776a968e1bc8b)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.4\n  - @sveltejs/adapter-netlify@1.0.0-next.36\n  - @sveltejs/adapter-vercel@1.0.0-next.32\n\n## 1.0.0-next.4\n\n### Patch Changes\n\n- Updated dependencies [[`318072b7`](https://github.com/sveltejs/kit/commit/318072b786fe018507ae13df6da2f0bb693587e8)]:\n  - @sveltejs/adapter-cloudflare@1.0.0-next.3\n  - @sveltejs/adapter-netlify@1.0.0-next.36\n  - @sveltejs/adapter-vercel@1.0.0-next.32\n\n## 1.0.0-next.3\n\n### Patch Changes\n\n- Remove ANSI codes ([#2897](https://github.com/sveltejs/kit/pull/2897))\n\n* Fix platform detection order ([#2897](https://github.com/sveltejs/kit/pull/2897))\n\n## 1.0.0-next.2\n\n### Patch Changes\n\n- Add missing file to adapter-auto package ([#2891](https://github.com/sveltejs/kit/pull/2891))\n\n## 1.0.0-next.1\n\n### Patch Changes\n\n- Force republish ([#2885](https://github.com/sveltejs/kit/pull/2885))\n\n## 1.0.0-next.0\n\n### Patch Changes\n\n- Add adapter-auto ([#2867](https://github.com/sveltejs/kit/pull/2867))\n"
  },
  {
    "path": "packages/adapter-auto/README.md",
    "content": "# adapter-auto\n\nAutomatically chooses the SvelteKit adapter for your current environment, if possible.\n\n## Docs\n\n[Docs](https://svelte.dev/docs/kit/adapter-auto)\n\n## Changelog\n\n[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/adapter-auto/CHANGELOG.md).\n"
  },
  {
    "path": "packages/adapter-auto/adapters.js",
    "content": "import process from 'node:process';\n\n// List of adapters to check for. `version` is used to pin the installed adapter version and should point\n// to the latest version of the adapter that is compatible with adapter-auto's current peerDependency version of SvelteKit.\nexport const adapters = [\n\t{\n\t\tname: 'Vercel',\n\t\ttest: () => !!process.env.VERCEL,\n\t\tmodule: '@sveltejs/adapter-vercel',\n\t\tversion: '6'\n\t},\n\t{\n\t\tname: 'Cloudflare Pages',\n\t\ttest: () => !!process.env.CF_PAGES,\n\t\tmodule: '@sveltejs/adapter-cloudflare',\n\t\tversion: '7'\n\t},\n\t{\n\t\tname: 'Netlify',\n\t\ttest: () => !!process.env.NETLIFY,\n\t\tmodule: '@sveltejs/adapter-netlify',\n\t\tversion: '6'\n\t},\n\t{\n\t\tname: 'Azure Static Web Apps',\n\t\ttest: () => process.env.GITHUB_ACTION_REPOSITORY === 'Azure/static-web-apps-deploy',\n\t\tmodule: 'svelte-adapter-azure-swa',\n\t\tversion: '0.20'\n\t},\n\t{\n\t\tname: 'AWS via SST',\n\t\ttest: () => !!process.env.SST,\n\t\tmodule: 'svelte-kit-sst',\n\t\tversion: '2'\n\t},\n\t{\n\t\tname: 'Google Cloud Run',\n\t\ttest: () => !!process.env.GCP_BUILDPACKS,\n\t\tmodule: '@sveltejs/adapter-node',\n\t\tversion: '5'\n\t}\n];\n"
  },
  {
    "path": "packages/adapter-auto/index.d.ts",
    "content": "import { Adapter } from '@sveltejs/kit';\n\nexport default function plugin(): Adapter;\n"
  },
  {
    "path": "packages/adapter-auto/index.js",
    "content": "import { execSync } from 'node:child_process';\nimport { adapters } from './adapters.js';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport process from 'node:process';\n\n/**\n * @template T\n * @template {keyof T} K\n * @typedef {Partial<Omit<T, K>> & Required<Pick<T, K>>} PartialExcept\n */\n\n/**\n * We use a custom `Builder` type here to support the minimum version of SvelteKit.\n * @typedef {PartialExcept<import('@sveltejs/kit').Builder, 'log' | 'rimraf' | 'mkdirp' | 'config' | 'prerendered' | 'routes' | 'createEntries' | 'generateFallback' | 'generateEnvModule' | 'generateManifest' | 'getBuildDirectory' | 'getClientDirectory' | 'getServerDirectory' | 'getAppPath' | 'writeClient' | 'writePrerendered' | 'writePrerendered' | 'writeServer' | 'copy' | 'compress'>} Builder2_0_0\n */\n\n/** @type {Record<string, (name: string, version: string) => string>} */\nconst commands = {\n\tnpm: (name, version) => `npm install -D ${name}@${version}`,\n\tpnpm: (name, version) => `pnpm add -D ${name}@${version}`,\n\tyarn: (name, version) => `yarn add -D ${name}@${version}`,\n\tbun: (name, version) => `bun add -D ${name}@${version}`,\n\tdeno: (name, version) => `deno install -D npm:${name}@${version}`\n};\n\nfunction detect_lockfile() {\n\tlet dir = process.cwd();\n\n\t/** @param {string} file */\n\tconst exists = (file) => fs.existsSync(path.join(dir, file));\n\n\tdo {\n\t\tif (exists('pnpm-lock.yaml')) return 'pnpm';\n\t\tif (exists('yarn.lock')) return 'yarn';\n\t\tif (exists('package-lock.json')) return 'npm';\n\t\tif (exists('bun.lockb') || exists('bun.lock')) return 'bun';\n\t\tif (exists('deno.lock')) return 'deno';\n\t} while (dir !== (dir = path.dirname(dir)));\n\n\treturn 'npm';\n}\n\nfunction detect_package_manager() {\n\tconst manager = detect_lockfile();\n\n\ttry {\n\t\texecSync(`${manager} --version`);\n\t\treturn manager;\n\t} catch {\n\t\treturn 'npm';\n\t}\n}\n\n/**\n * Resolves a peer dependency relative to the current CWD. Duplicated with `packages/kit`\n * @param {string} dependency\n */\nfunction resolve_peer(dependency) {\n\tlet [name, ...parts] = dependency.split('/');\n\tif (name[0] === '@') name += `/${parts.shift()}`;\n\n\tlet dir = process.cwd();\n\n\twhile (!fs.existsSync(`${dir}/node_modules/${name}/package.json`)) {\n\t\tif (dir === (dir = path.dirname(dir))) {\n\t\t\tthrow new Error(\n\t\t\t\t`Could not resolve peer dependency \"${name}\" relative to your project — please install it and try again.`\n\t\t\t);\n\t\t}\n\t}\n\n\tconst pkg_dir = `${dir}/node_modules/${name}`;\n\tconst pkg = JSON.parse(fs.readFileSync(`${pkg_dir}/package.json`, 'utf-8'));\n\n\tconst subpackage = ['.', ...parts].join('/');\n\n\tlet exported = pkg.exports[subpackage];\n\n\twhile (typeof exported !== 'string') {\n\t\tif (!exported) {\n\t\t\tthrow new Error(`Could not find valid \"${subpackage}\" export in ${name}/package.json`);\n\t\t}\n\n\t\texported = exported['import'] ?? exported['default'];\n\t}\n\n\treturn path.resolve(pkg_dir, exported);\n}\n\n/** @typedef {import('@sveltejs/kit').Adapter} Adapter */\n\n/**\n * @returns {Promise<Adapter | undefined>} The corresponding adapter for the current environment if found otherwise undefined\n */\nasync function get_adapter() {\n\tconst match = adapters.find((candidate) => candidate.test());\n\n\tif (!match) return;\n\n\t/** @type {string} */\n\tlet resolved;\n\n\ttry {\n\t\tresolved = resolve_peer(match.module);\n\t} catch {\n\t\tconst package_manager = detect_package_manager();\n\t\tconst command = commands[package_manager](match.module, match.version);\n\n\t\ttry {\n\t\t\tconsole.log(`Installing ${match.module}...`);\n\n\t\t\texecSync(command, {\n\t\t\t\tstdio: 'inherit',\n\t\t\t\tenv: {\n\t\t\t\t\t...process.env,\n\t\t\t\t\tNODE_ENV: undefined\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tresolved = resolve_peer(match.module);\n\n\t\t\tconsole.log(`Successfully installed ${match.module}.`);\n\t\t\tconsole.warn(\n\t\t\t\t`\\nIf you plan to continue deploying to ${match.name}, consider replacing @sveltejs/adapter-auto with ${match.module}. This will give you faster installs and more control over deployment configuration.\\n`\n\t\t\t);\n\t\t} catch (e) {\n\t\t\tthrow new Error(\n\t\t\t\t`Could not install ${match.module}. Please install it yourself by adding it to your package.json's devDependencies and try building your project again.`,\n\t\t\t\t{ cause: e }\n\t\t\t);\n\t\t}\n\t}\n\n\t/** @type {{ default: () => Adapter }} */\n\tconst module = await import(resolved);\n\n\tconst adapter = module.default();\n\n\treturn {\n\t\t...adapter,\n\t\tadapt: (builder) => {\n\t\t\tbuilder.log.info(`Detected environment: ${match.name}. Using ${match.module}`);\n\t\t\treturn adapter.adapt(builder);\n\t\t}\n\t};\n}\n\n/** @type {() => Adapter} */\nexport default () => ({\n\tname: '@sveltejs/adapter-auto',\n\t/** @param {Builder2_0_0} builder */\n\tadapt: async (builder) => {\n\t\tconst adapter = await get_adapter();\n\n\t\tif (adapter) return adapter.adapt(/** @type {import('@sveltejs/kit').Builder} */ (builder));\n\n\t\tbuilder.log.warn(\n\t\t\t'Could not detect a supported production environment. See https://svelte.dev/docs/kit/adapters to learn how to configure your app to run on the platform of your choosing'\n\t\t);\n\t},\n\tsupports: {\n\t\tread: () => {\n\t\t\tsupports_error(\n\t\t\t\t'The read function imported from $app/server only works in certain environments'\n\t\t\t);\n\t\t},\n\t\tinstrumentation: () => {\n\t\t\tsupports_error('`instrumentation.server.js` only works in certain environments');\n\t\t}\n\t}\n});\n\n/**\n * @param {string} message\n * @returns {never}\n * @throws {Error}\n */\nfunction supports_error(message) {\n\tthrow new Error(\n\t\t`${message}. Since you're using @sveltejs/adapter-auto, SvelteKit cannot determine whether it will work when your app is deployed. Please replace it with an adapter tailored to your target environment.`\n\t);\n}\n"
  },
  {
    "path": "packages/adapter-auto/package.json",
    "content": "{\n\t\"name\": \"@sveltejs/adapter-auto\",\n\t\"version\": \"7.0.1\",\n\t\"description\": \"Automatically chooses the SvelteKit adapter for your current environment, if possible.\",\n\t\"keywords\": [\n\t\t\"adapter\",\n\t\t\"automatically\",\n\t\t\"deploy\",\n\t\t\"hosting\",\n\t\t\"platform\",\n\t\t\"svelte\",\n\t\t\"sveltekit\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/sveltejs/kit.git\",\n\t\t\"directory\": \"packages/adapter-auto\"\n\t},\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://svelte.dev/docs/kit/adapter-auto\",\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./index.d.ts\",\n\t\t\t\"import\": \"./index.js\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"types\": \"index.d.ts\",\n\t\"files\": [\n\t\t\"files\",\n\t\t\"index.js\",\n\t\t\"index.d.ts\",\n\t\t\"adapters.js\"\n\t],\n\t\"scripts\": {\n\t\t\"lint\": \"prettier --check .\",\n\t\t\"format\": \"pnpm lint --write\",\n\t\t\"check\": \"tsc\",\n\t\t\"test\": \"vitest run\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"@types/node\": \"catalog:\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@sveltejs/kit\": \"^2.0.0\"\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-auto/test/adapters.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport { adapters } from '../adapters.js';\nimport { existsSync, readFileSync } from 'node:fs';\n\ntest('adapter versions are up to date', () => {\n\tfor (const adapter of adapters) {\n\t\tconst dir = adapter.module.replace('@sveltejs/', '');\n\t\tconst package_json = `../${dir}/package.json`;\n\t\tif (!existsSync(package_json)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst adapter_version = JSON.parse(readFileSync(package_json, 'utf-8')).version;\n\t\tconst [major] = adapter_version.split('.');\n\t\tassert.equal(adapter.version, major, `${adapter.name} adapter is outdated`);\n\t}\n});\n"
  },
  {
    "path": "packages/adapter-auto/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"noImplicitAny\": true,\n\t\t\"strictNullChecks\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"node16\",\n\t\t\"moduleResolution\": \"node16\",\n\t\t\"baseUrl\": \".\"\n\t},\n\t\"include\": [\"**/*.js\"]\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/.gitignore",
    "content": "/files\n"
  },
  {
    "path": "packages/adapter-cloudflare/CHANGELOG.md",
    "content": "# @sveltejs/adapter-cloudflare\n\n## 7.2.8\n### Patch Changes\n\n\n- fix: skip comment lines in `_redirects` file ([#15325](https://github.com/sveltejs/kit/pull/15325))\n\n- Updated dependencies [[`e87efba`](https://github.com/sveltejs/kit/commit/e87efba90aeb04227e6a1a5e9017989e7f1c78dc), [`71ddbc7`](https://github.com/sveltejs/kit/commit/71ddbc7ff19a612cfcd483f3b7ba58586372528b), [`1bae374`](https://github.com/sveltejs/kit/commit/1bae374e2e106eb82502afd1ddf0167d66f224a1), [`20dfadf`](https://github.com/sveltejs/kit/commit/20dfadfbef312b4e750318aa871aebbfcb4396a4), [`8c2384a`](https://github.com/sveltejs/kit/commit/8c2384a346825d54eb4281f9da854388fb4d81b3)]:\n  - @sveltejs/kit@2.52.1\n\n## 7.2.7\n### Patch Changes\n\n\n- fix: error if `_routes.json` is in the `/static` public directory ([#12821](https://github.com/sveltejs/kit/pull/12821))\n\n\n- fix: correctly handle pathnames found in the `_redirects` file ([#12821](https://github.com/sveltejs/kit/pull/12821))\n\n- Updated dependencies [[`37293a5`](https://github.com/sveltejs/kit/commit/37293a5c913b014e823bc823f2c8c6da38b88d6e), [`5d05ca6`](https://github.com/sveltejs/kit/commit/5d05ca6f606cf68417e4ed1ccb68cd77383f1f0f), [`ed69b77`](https://github.com/sveltejs/kit/commit/ed69b77cf9ef1af088008ff559f8de2e2a2f6bf4), [`b1fc959`](https://github.com/sveltejs/kit/commit/b1fc95966e0aeee689fdae71fa488c34b4806303), [`159aece`](https://github.com/sveltejs/kit/commit/159aece0654db020f95bc414f6a21f25fbc5f22f), [`c690579`](https://github.com/sveltejs/kit/commit/c690579620e131cd077ded0bc8e55090d3681d35), [`dc8cf2d`](https://github.com/sveltejs/kit/commit/dc8cf2defa71dd987437895eb89587c724f6e9bb), [`ace2116`](https://github.com/sveltejs/kit/commit/ace2116d95e13293dbc1e26b5b7d780202fd02dd), [`0f38f49`](https://github.com/sveltejs/kit/commit/0f38f498e0e7052db7b8cfe9ea892e7882a67b66)]:\n  - @sveltejs/kit@2.51.0\n\n## 7.2.6\n### Patch Changes\n\n\n- fix: ensure manifest paths are relative when building worker ([#15163](https://github.com/sveltejs/kit/pull/15163))\n\n- Updated dependencies [[`46c1ebd`](https://github.com/sveltejs/kit/commit/46c1ebd9f662f0de499e921bfee2661316449e9d), [`2dd74c8`](https://github.com/sveltejs/kit/commit/2dd74c8c86ae4855c3e9d74d8cf241e86dcd5b36), [`8871b54`](https://github.com/sveltejs/kit/commit/8871b5444413d0c7d7ef4d260996c3b5c359d0b8)]:\n  - @sveltejs/kit@2.50.1\n\n## 7.2.5\n### Patch Changes\n\n\n- fix: await `init` on every request to prevent race condition ([#15161](https://github.com/sveltejs/kit/pull/15161))\n\n- Updated dependencies [[`81cd545`](https://github.com/sveltejs/kit/commit/81cd545dd78b60ee994a04d8abacb58bf63584d7), [`d9ae9b0`](https://github.com/sveltejs/kit/commit/d9ae9b00b14f5574d109f3fd548f960594346226), [`8ed8155`](https://github.com/sveltejs/kit/commit/8ed8155215b9a74012fecffb942ad9a793b274e5)]:\n  - @sveltejs/kit@2.49.5\n\n## 7.2.4\n### Patch Changes\n\n\n- chore: update \"homepage\" field in package.json ([#14579](https://github.com/sveltejs/kit/pull/14579))\n\n## 7.2.3\n### Patch Changes\n\n\n- fix: improve the error message when `read(...)` fails ([#14306](https://github.com/sveltejs/kit/pull/14306))\n\n## 7.2.2\n### Patch Changes\n\n\n- chore: update error message link to the Workers Sites migration guide ([#14237](https://github.com/sveltejs/kit/pull/14237))\n\n- Updated dependencies [[`b2c5d02`](https://github.com/sveltejs/kit/commit/b2c5d02994a6d83275d6fb3645e6f9a2518c8d20), [`0bf6185`](https://github.com/sveltejs/kit/commit/0bf6185748d7b777fa8b8d37cef331be92ecedde), [`b2c5d02`](https://github.com/sveltejs/kit/commit/b2c5d02994a6d83275d6fb3645e6f9a2518c8d20), [`c5f7139`](https://github.com/sveltejs/kit/commit/c5f713951e41af2000f21929d42eb9d30c9d3a5c)]:\n  - @sveltejs/kit@2.34.1\n\n## 7.2.1\n### Patch Changes\n\n\n- fix: avoid erroring on builder properties that only exist on the latest version of SvelteKit ([#14233](https://github.com/sveltejs/kit/pull/14233))\n\n- Updated dependencies [[`f2db41c`](https://github.com/sveltejs/kit/commit/f2db41c0d3a0aefbb080ab6a9aa5822b3e41625c)]:\n  - @sveltejs/kit@2.31.1\n\n## 7.2.0\n### Minor Changes\n\n\n- feat: add `instrumentation.server.ts` for tracing and observability setup ([#13899](https://github.com/sveltejs/kit/pull/13899))\n\n\n### Patch Changes\n\n- Updated dependencies [[`f635678`](https://github.com/sveltejs/kit/commit/f63567812505597b1edc3e01010eca622b03b126), [`f635678`](https://github.com/sveltejs/kit/commit/f63567812505597b1edc3e01010eca622b03b126)]:\n  - @sveltejs/kit@2.31.0\n\n## 7.1.3\n### Patch Changes\n\n\n- chore: add `.git` to the end of `package.json` repository url ([#14134](https://github.com/sveltejs/kit/pull/14134))\n\n- Updated dependencies [[`c968aef`](https://github.com/sveltejs/kit/commit/c968aef5727f978244d5160657b4a7ac651384ae)]:\n  - @sveltejs/kit@2.27.3\n\n## 7.1.2\n### Patch Changes\n\n\n- fix: resolve the absolute path of the Wrangler config setting `assets.directory` in case the config file is in a different directory than the root project ([#14036](https://github.com/sveltejs/kit/pull/14036))\n\n- Updated dependencies [[`793ae28`](https://github.com/sveltejs/kit/commit/793ae28a339ca33b7e27f14158b1726bfeedd729)]:\n  - @sveltejs/kit@2.27.0\n\n## 7.1.1\n### Patch Changes\n\n\n- fix: support assets-only workers in wrangler validation ([#14019](https://github.com/sveltejs/kit/pull/14019))\n\n- Updated dependencies [[`fda0165`](https://github.com/sveltejs/kit/commit/fda0165804011d221bb196a26565eea3e08b9d42)]:\n  - @sveltejs/kit@2.25.2\n\n## 7.1.0\n### Minor Changes\n\n\n- feat: add support for `read` imported from `$app/server` ([#13859](https://github.com/sveltejs/kit/pull/13859))\n\n\n### Patch Changes\n\n\n- fix: include missing utils file ([#14009](https://github.com/sveltejs/kit/pull/14009))\n\n\n- fix: correctly warn users when assets key is missing ([#13844](https://github.com/sveltejs/kit/pull/13844))\n\n- Updated dependencies [[`e5ce8bb`](https://github.com/sveltejs/kit/commit/e5ce8bb42ea020b88bd0a4ff18dc600745657541), [`cf88369`](https://github.com/sveltejs/kit/commit/cf883692fa0e163cff6b1a2f9b17a568af14124d)]:\n  - @sveltejs/kit@2.25.0\n\n## 7.0.5\n### Patch Changes\n\n\n- fix: deprecate `platform.context` in favor of `platform.ctx` to align with Cloudflare's naming convention ([#13856](https://github.com/sveltejs/kit/pull/13856))\n\n- Updated dependencies [[`bcdaf21`](https://github.com/sveltejs/kit/commit/bcdaf215c2182524e7678a1049a5f1ccbbe71e21)]:\n  - @sveltejs/kit@2.22.3\n\n## 7.0.4\n### Patch Changes\n\n\n- fix: address build failure when using `paths.base` (#13769) ([#13846](https://github.com/sveltejs/kit/pull/13846))\n\n- Updated dependencies [[`6a6538c4bd937667a56ef5f6673cdef3f2ea7a77`](https://github.com/sveltejs/kit/commit/6a6538c4bd937667a56ef5f6673cdef3f2ea7a77), [`6261a877ae97ff85d07277c51391d925ed1bd096`](https://github.com/sveltejs/kit/commit/6261a877ae97ff85d07277c51391d925ed1bd096), [`e7b57e74bdea976ae070562bda76d4bb78cdb6da`](https://github.com/sveltejs/kit/commit/e7b57e74bdea976ae070562bda76d4bb78cdb6da), [`408e1f5c2ae593b460861098e8e01f945af395ab`](https://github.com/sveltejs/kit/commit/408e1f5c2ae593b460861098e8e01f945af395ab), [`c6cd8c3a5ed96d423a65af5cb5468e3e963cfb54`](https://github.com/sveltejs/kit/commit/c6cd8c3a5ed96d423a65af5cb5468e3e963cfb54), [`1a406752aafc2b80d9ccb49f15ebc10301c84480`](https://github.com/sveltejs/kit/commit/1a406752aafc2b80d9ccb49f15ebc10301c84480), [`6c442395a8e6656ff49ecd4041d8e12ed65e80dd`](https://github.com/sveltejs/kit/commit/6c442395a8e6656ff49ecd4041d8e12ed65e80dd)]:\n  - @sveltejs/kit@2.21.3\n\n## 7.0.3\n### Patch Changes\n\n\n- chore(deps): upgrade @cloudflare/workers-types to 4.20250507.0 ([#13773](https://github.com/sveltejs/kit/pull/13773))\n\n## 7.0.2\n### Patch Changes\n\n\n- chore(deps): upgrade @cloudflare/workers-types to 4.20250415.0 ([#13716](https://github.com/sveltejs/kit/pull/13716))\n\n- Updated dependencies [[`c51fb554416e0c4a21655c1d79e834f69743d1d5`](https://github.com/sveltejs/kit/commit/c51fb554416e0c4a21655c1d79e834f69743d1d5)]:\n  - @sveltejs/kit@2.20.8\n\n## 7.0.1\n### Patch Changes\n\n\n- fix: correctly write the worker to the `pages_build_output_dir` path if set in the Wrangler configuration path ([#13671](https://github.com/sveltejs/kit/pull/13671))\n\n\n- fix: correctly resolve paths provided by the Wrangler config on Windows ([#13671](https://github.com/sveltejs/kit/pull/13671))\n\n- Updated dependencies [[`7fd7bcb7142e7d0d2dd64174fa1a94d56a45d643`](https://github.com/sveltejs/kit/commit/7fd7bcb7142e7d0d2dd64174fa1a94d56a45d643)]:\n  - @sveltejs/kit@2.20.4\n\n## 7.0.0\n### Major Changes\n\n\n- feat: support specifically building for Cloudflare Workers Static Assets ([#13634](https://github.com/sveltejs/kit/pull/13634))\n\n\n### Patch Changes\n\n\n- chore: remove `esbuild` as dependency ([#13633](https://github.com/sveltejs/kit/pull/13633))\n\n- Updated dependencies [[`370e9f95c1d6efd5393f73d2dbef68143b27f681`](https://github.com/sveltejs/kit/commit/370e9f95c1d6efd5393f73d2dbef68143b27f681)]:\n  - @sveltejs/kit@2.20.3\n\n## 6.0.1\n### Patch Changes\n\n\n- fix: revert writing server files to the cloudflare build directory ([#13622](https://github.com/sveltejs/kit/pull/13622))\n\n## 6.0.0\n### Major Changes\n\n\n- fix: copy the `_headers` and `_redirects` files from the project root instead of the `/static` directory ([#13227](https://github.com/sveltejs/kit/pull/13227))\n\n\n### Patch Changes\n\n\n- fix: write server files to the cloudflare build directory ([#13610](https://github.com/sveltejs/kit/pull/13610))\n\n## 5.1.0\n### Minor Changes\n\n\n- feat: support wrangler 4 ([#13580](https://github.com/sveltejs/kit/pull/13580))\n\n\n### Patch Changes\n\n- Updated dependencies [[`001bc04dece9b0983efc2187225772c19d135345`](https://github.com/sveltejs/kit/commit/001bc04dece9b0983efc2187225772c19d135345)]:\n  - @sveltejs/kit@2.19.2\n\n## 5.0.3\n### Patch Changes\n\n\n- fix: exclude the dynamic route `/_app/env.js` from the adapter config `routes.exclude` special value `<build>` ([#13411](https://github.com/sveltejs/kit/pull/13411))\n\n- Updated dependencies [[`9612a60a0277aef0ab4723a0e7ed8dd03a7ffb95`](https://github.com/sveltejs/kit/commit/9612a60a0277aef0ab4723a0e7ed8dd03a7ffb95), [`3d88ae33fc14b08a1d48c2cb7315739c8cfcd9fd`](https://github.com/sveltejs/kit/commit/3d88ae33fc14b08a1d48c2cb7315739c8cfcd9fd)]:\n  - @sveltejs/kit@2.17.2\n\n## 5.0.2\n### Patch Changes\n\n\n- fix: prevent Vitest from hanging, which was not fully addressed in [#12830](https://github.com/sveltejs/kit/pull/12830) ([#13373](https://github.com/sveltejs/kit/pull/13373))\n\n- Updated dependencies [[`09296d0f19c8d1ff57d699e637bd1beabb69d438`](https://github.com/sveltejs/kit/commit/09296d0f19c8d1ff57d699e637bd1beabb69d438), [`d62ed39a431f0db3db4dd90bf6b17ed2a2a2de79`](https://github.com/sveltejs/kit/commit/d62ed39a431f0db3db4dd90bf6b17ed2a2a2de79), [`f30352f874790b9de0bd0eba985a21aef23e158e`](https://github.com/sveltejs/kit/commit/f30352f874790b9de0bd0eba985a21aef23e158e), [`180fa3467e195065c0a25206c6328a908e6952d7`](https://github.com/sveltejs/kit/commit/180fa3467e195065c0a25206c6328a908e6952d7), [`5906e9708965b848b468d0014999c36272dc8d50`](https://github.com/sveltejs/kit/commit/5906e9708965b848b468d0014999c36272dc8d50), [`d62ed39a431f0db3db4dd90bf6b17ed2a2a2de79`](https://github.com/sveltejs/kit/commit/d62ed39a431f0db3db4dd90bf6b17ed2a2a2de79)]:\n  - @sveltejs/kit@2.17.0\n\n## 5.0.1\n### Patch Changes\n\n\n- fix: prevent vitest from hanging ([#12830](https://github.com/sveltejs/kit/pull/12830))\n\n- Updated dependencies [[`1bedcc1cfc1f2d85946c1423f60faa8a2a56148b`](https://github.com/sveltejs/kit/commit/1bedcc1cfc1f2d85946c1423f60faa8a2a56148b), [`e201fa9380a00e072a80a2dcab56de3d77e5b67c`](https://github.com/sveltejs/kit/commit/e201fa9380a00e072a80a2dcab56de3d77e5b67c), [`f3f08582d41b08c3fd1daf742e5703d9cdca7823`](https://github.com/sveltejs/kit/commit/f3f08582d41b08c3fd1daf742e5703d9cdca7823), [`d4bcfccb4503b12fe76140dbb6cfddc81f9419fc`](https://github.com/sveltejs/kit/commit/d4bcfccb4503b12fe76140dbb6cfddc81f9419fc), [`d09bc033123903f359c1ad6fd3a6d8d7fc19298a`](https://github.com/sveltejs/kit/commit/d09bc033123903f359c1ad6fd3a6d8d7fc19298a)]:\n  - @sveltejs/kit@2.15.3\n\n## 5.0.0\n### Major Changes\n\n\n- feat: remove esbuild step ([#13132](https://github.com/sveltejs/kit/pull/13132))\n\n\n### Patch Changes\n\n- Updated dependencies [[`12ce7eb19fb57907e3db29ef981a8c7a0afc4b6f`](https://github.com/sveltejs/kit/commit/12ce7eb19fb57907e3db29ef981a8c7a0afc4b6f), [`528af75f846f971ef64e4d109ac5e22fca046b90`](https://github.com/sveltejs/kit/commit/528af75f846f971ef64e4d109ac5e22fca046b90)]:\n  - @sveltejs/kit@2.15.1\n\n## 4.9.0\n### Minor Changes\n\n\n- feat: generate `.assetsignore` file for use with Cloudflare Workers Static Assets ([#13109](https://github.com/sveltejs/kit/pull/13109))\n\n\n### Patch Changes\n\n- Updated dependencies [[`20f2720aa3455f38fa2630a33d52f7532da27fce`](https://github.com/sveltejs/kit/commit/20f2720aa3455f38fa2630a33d52f7532da27fce)]:\n  - @sveltejs/kit@2.13.0\n\n## 4.8.0\n### Minor Changes\n\n\n- chore: upgrade esbuild to 0.24.0 ([#12270](https://github.com/sveltejs/kit/pull/12270))\n\n\n### Patch Changes\n\n- Updated dependencies [[`d030f4bb285e70844d09b3f0c87809bae43014b8`](https://github.com/sveltejs/kit/commit/d030f4bb285e70844d09b3f0c87809bae43014b8), [`67dd214863cbc5852eb0e8512efbb7bad5358e8a`](https://github.com/sveltejs/kit/commit/67dd214863cbc5852eb0e8512efbb7bad5358e8a)]:\n  - @sveltejs/kit@2.9.0\n\n## 4.7.4\n### Patch Changes\n\n\n- docs: update URLs for new svelte.dev site ([#12857](https://github.com/sveltejs/kit/pull/12857))\n\n- Updated dependencies [[`dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46`](https://github.com/sveltejs/kit/commit/dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46), [`4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d`](https://github.com/sveltejs/kit/commit/4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d), [`3a9b78f04786898ca93f6d4b75ab18d26bc45192`](https://github.com/sveltejs/kit/commit/3a9b78f04786898ca93f6d4b75ab18d26bc45192), [`723eb8b31e6a22c82f730c30e485386c8676b746`](https://github.com/sveltejs/kit/commit/723eb8b31e6a22c82f730c30e485386c8676b746), [`8ec471c875345b751344e67580ff1b772ef2735b`](https://github.com/sveltejs/kit/commit/8ec471c875345b751344e67580ff1b772ef2735b)]:\n  - @sveltejs/kit@2.7.3\n\n## 4.7.3\n### Patch Changes\n\n\n- fix: correctly handle relative paths when fetching assets on the server ([#12113](https://github.com/sveltejs/kit/pull/12113))\n\n- Updated dependencies [[`df48fc6ede3859beabaae9fd7c6f722215bb8a42`](https://github.com/sveltejs/kit/commit/df48fc6ede3859beabaae9fd7c6f722215bb8a42), [`5780deba8e3ebd0e2b0abea029068ad0c6daf6ad`](https://github.com/sveltejs/kit/commit/5780deba8e3ebd0e2b0abea029068ad0c6daf6ad), [`6f9aefdb8699fc126d76a88471602cb9a80822eb`](https://github.com/sveltejs/kit/commit/6f9aefdb8699fc126d76a88471602cb9a80822eb), [`8aa95b4b3431e79f62f580abdcdcb157b4de86cd`](https://github.com/sveltejs/kit/commit/8aa95b4b3431e79f62f580abdcdcb157b4de86cd)]:\n  - @sveltejs/kit@2.7.0\n\n## 4.7.2\n### Patch Changes\n\n\n- chore: configure provenance in a simpler manner ([#12570](https://github.com/sveltejs/kit/pull/12570))\n\n- Updated dependencies [[`087a43d391fc38b8c008fb39a804dc6988974101`](https://github.com/sveltejs/kit/commit/087a43d391fc38b8c008fb39a804dc6988974101)]:\n  - @sveltejs/kit@2.5.22\n\n## 4.7.1\n### Patch Changes\n\n\n- chore: package provenance ([#12567](https://github.com/sveltejs/kit/pull/12567))\n\n- Updated dependencies [[`4930a8443caa53bcecee7b690cd28e429b1c8a20`](https://github.com/sveltejs/kit/commit/4930a8443caa53bcecee7b690cd28e429b1c8a20)]:\n  - @sveltejs/kit@2.5.21\n\n## 4.7.0\n### Minor Changes\n\n\n- feat: generate static `_redirects` for Cloudflare Pages ([#12199](https://github.com/sveltejs/kit/pull/12199))\n\n\n### Patch Changes\n\n\n- fix: correctly return static assets if base path is set ([#12075](https://github.com/sveltejs/kit/pull/12075))\n\n## 4.6.1\n### Patch Changes\n\n\n- fix: copy `.eot`, `.otf`, `.ttf`, `.woff`, and `woff2` font files when bundling ([#12439](https://github.com/sveltejs/kit/pull/12439))\n\n## 4.6.0\n### Minor Changes\n\n\n- chore(deps): upgrade to esbuild 0.21 ([#12415](https://github.com/sveltejs/kit/pull/12415))\n\n\n### Patch Changes\n\n- Updated dependencies [[`84298477a014ec471839adf7a4448d91bc7949e4`](https://github.com/sveltejs/kit/commit/84298477a014ec471839adf7a4448d91bc7949e4), [`5645614f497931f587b7cb8b3c885fce892a6a72`](https://github.com/sveltejs/kit/commit/5645614f497931f587b7cb8b3c885fce892a6a72), [`84298477a014ec471839adf7a4448d91bc7949e4`](https://github.com/sveltejs/kit/commit/84298477a014ec471839adf7a4448d91bc7949e4)]:\n  - @sveltejs/kit@2.5.18\n\n## 4.5.0\n\n### Minor Changes\n\n- feat: validate that no `_routes.json` is present to avoid overwriting it ([#12360](https://github.com/sveltejs/kit/pull/12360))\n\n### Patch Changes\n\n- Updated dependencies [[`121836fcbf6c615fd18c79a12203613ddbe49acf`](https://github.com/sveltejs/kit/commit/121836fcbf6c615fd18c79a12203613ddbe49acf)]:\n  - @sveltejs/kit@2.5.17\n\n## 4.4.1\n\n### Patch Changes\n\n- chore: add keywords for discovery in npm search ([#12330](https://github.com/sveltejs/kit/pull/12330))\n\n- Updated dependencies [[`25acb1d9fce998dccd8050b93cf4142c2b082611`](https://github.com/sveltejs/kit/commit/25acb1d9fce998dccd8050b93cf4142c2b082611), [`642c4a4aff4351b786fe6274aa2f0bf7d905faf9`](https://github.com/sveltejs/kit/commit/642c4a4aff4351b786fe6274aa2f0bf7d905faf9), [`0a0e9aa897123ebec50af08e9385b2ca4fc5bb28`](https://github.com/sveltejs/kit/commit/0a0e9aa897123ebec50af08e9385b2ca4fc5bb28)]:\n  - @sveltejs/kit@2.5.11\n\n## 4.4.0\n\n### Minor Changes\n\n- chore(deps): upgrade esbuild ([#12118](https://github.com/sveltejs/kit/pull/12118))\n\n### Patch Changes\n\n- Updated dependencies [[`bbab296f6fcc05af6b999182798bcdedabbaa4c9`](https://github.com/sveltejs/kit/commit/bbab296f6fcc05af6b999182798bcdedabbaa4c9)]:\n  - @sveltejs/kit@2.5.6\n\n## 4.3.0\n\n### Minor Changes\n\n- feat: support platform emulation configuration via the `platformProxy` adapter option ([#12011](https://github.com/sveltejs/kit/pull/12011))\n\n## 4.2.1\n\n### Patch Changes\n\n- fix: add `workerd` to esbuild conditions ([#12069](https://github.com/sveltejs/kit/pull/12069))\n\n## 4.2.0\n\n### Minor Changes\n\n- feat: emulate Cloudflare Workers bindings and incoming request properties in `event.platform` for `dev` and `preview` ([#11974](https://github.com/sveltejs/kit/pull/11974))\n\n### Patch Changes\n\n- Updated dependencies [[`4562275ed42964148df03c79434172024897c08c`](https://github.com/sveltejs/kit/commit/4562275ed42964148df03c79434172024897c08c)]:\n  - @sveltejs/kit@2.5.4\n\n## 4.1.0\n\n### Minor Changes\n\n- feat: more helpful errors when using incompatible Node modules ([#11673](https://github.com/sveltejs/kit/pull/11673))\n\n- feat: support compatible node modules without prefixes ([#11672](https://github.com/sveltejs/kit/pull/11672))\n\n- feat: Add Node.js compatibility ([#10544](https://github.com/sveltejs/kit/pull/10544))\n\n### Patch Changes\n\n- Updated dependencies [[`288f731c8a5b20cadb9e219f9583f3f16bf8c7b8`](https://github.com/sveltejs/kit/commit/288f731c8a5b20cadb9e219f9583f3f16bf8c7b8)]:\n  - @sveltejs/kit@2.4.0\n\n## 4.0.2\n\n### Patch Changes\n\n- chore(deps): update dependency worktop to v0.8.0-next.18 ([#11618](https://github.com/sveltejs/kit/pull/11618))\n\n## 4.0.1\n\n### Patch Changes\n\n- chore: upgrade esbuild to 0.19.11 ([#11632](https://github.com/sveltejs/kit/pull/11632))\n\n## 4.0.0\n\n### Major Changes\n\n- breaking: generate plaintext 404.html instead of SPA-style fallback page ([#11596](https://github.com/sveltejs/kit/pull/11596))\n\n### Patch Changes\n\n- Updated dependencies [[`2137717ea8592c310ada93490feabbd9eea125ea`](https://github.com/sveltejs/kit/commit/2137717ea8592c310ada93490feabbd9eea125ea)]:\n  - @sveltejs/kit@2.3.3\n\n## 3.0.2\n\n### Patch Changes\n\n- fix: serve static files in `_app` from function, if not already handled ([#11593](https://github.com/sveltejs/kit/pull/11593))\n\n- Updated dependencies [[`553e14c8320ad9c6ebb3c554c35f1482755c9555`](https://github.com/sveltejs/kit/commit/553e14c8320ad9c6ebb3c554c35f1482755c9555), [`48576de0dc8b1fbbab7954113004540ea4e76935`](https://github.com/sveltejs/kit/commit/48576de0dc8b1fbbab7954113004540ea4e76935)]:\n  - @sveltejs/kit@2.3.2\n\n## 3.0.1\n\n### Patch Changes\n\n- chore: update primary branch from master to main ([`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d))\n\n- Updated dependencies [[`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d), [`16961e8cd3fa6a7f382153b1ff056bc2aae9b31b`](https://github.com/sveltejs/kit/commit/16961e8cd3fa6a7f382153b1ff056bc2aae9b31b), [`197e01f95652f511160f38b37b9da73a124ecd48`](https://github.com/sveltejs/kit/commit/197e01f95652f511160f38b37b9da73a124ecd48), [`102e4a5ae5b29624302163faf5a20c94a64a5b2c`](https://github.com/sveltejs/kit/commit/102e4a5ae5b29624302163faf5a20c94a64a5b2c), [`f8e3d8b9728c9f1ab63389342c31d7246b6f9db6`](https://github.com/sveltejs/kit/commit/f8e3d8b9728c9f1ab63389342c31d7246b6f9db6)]:\n  - @sveltejs/kit@2.0.4\n\n## 3.0.0\n\n### Major Changes\n\n- breaking: require SvelteKit 2 ([#11316](https://github.com/sveltejs/kit/pull/11316))\n\n- chore: upgrade esbuild ([#11122](https://github.com/sveltejs/kit/pull/11122))\n\n## 2.3.4\n\n### Patch Changes\n\n- fix: retain URL query string for trailing slash redirects to prerendered pages ([#11142](https://github.com/sveltejs/kit/pull/11142))\n\n- Updated dependencies [[`a7f8bdcfa`](https://github.com/sveltejs/kit/commit/a7f8bdcfabce5cda85dd073a21d0afb6138a7a08), [`a4d91304e`](https://github.com/sveltejs/kit/commit/a4d91304eebc08bf2e748d83a46d3548a546e3ab)]:\n  - @sveltejs/kit@1.27.7\n\n## 2.3.3\n\n### Patch Changes\n\n- fix: correctly include `config.kit.paths.base` ([#10604](https://github.com/sveltejs/kit/pull/10604))\n\n- Updated dependencies [[`7c37a2fb3`](https://github.com/sveltejs/kit/commit/7c37a2fb3bff0f47f817bc8049b454abe591b8a0), [`998fe2f19`](https://github.com/sveltejs/kit/commit/998fe2f19833df4ffc08f29e924cc8e1591f7734), [`23721d1fb`](https://github.com/sveltejs/kit/commit/23721d1fbed04083069f07c068289282819ff4cb), [`32afba695`](https://github.com/sveltejs/kit/commit/32afba695088b946aefe96da75b36de9b0667fbe)]:\n  - @sveltejs/kit@1.23.0\n\n## 2.3.2\n\n### Patch Changes\n\n- fix: mark `cloudflare:` packages as external ([#10404](https://github.com/sveltejs/kit/pull/10404))\n\n- Updated dependencies [[`0f0049810`](https://github.com/sveltejs/kit/commit/0f00498100361ef0a4ea8b0b4e8465e442fa22a6), [`6f36aefe1`](https://github.com/sveltejs/kit/commit/6f36aefe13bf55cfaef14166c60ecee989061ddd)]:\n  - @sveltejs/kit@1.22.4\n\n## 2.3.1\n\n### Patch Changes\n\n- chore: upgrade to esbuild 0.18.11 ([#10330](https://github.com/sveltejs/kit/pull/10330))\n\n- Updated dependencies [[`23d1df702`](https://github.com/sveltejs/kit/commit/23d1df702f0fd77983040404352d8d83fd1dd8a1), [`486a971fe`](https://github.com/sveltejs/kit/commit/486a971fe7c375aae1585f1fa2505e28f86f4b8e)]:\n  - @sveltejs/kit@1.22.2\n\n## 2.3.0\n\n### Minor Changes\n\n- feat: add cloudflare's `request.cf` object to the `event.platform` property ([#9978](https://github.com/sveltejs/kit/pull/9978))\n\n### Patch Changes\n\n- Updated dependencies [[`4aa976e50`](https://github.com/sveltejs/kit/commit/4aa976e5018664ee333629c5f2f6edacab9d868a), [`c1d34584f`](https://github.com/sveltejs/kit/commit/c1d34584f2404b9c80a547c8138264cac2a813b6), [`1c0423b65`](https://github.com/sveltejs/kit/commit/1c0423b655b7d5909e405d9d15025dc75e71a04f), [`7499d8f31`](https://github.com/sveltejs/kit/commit/7499d8f31195473d2c955f1280e097ac95995efa), [`81af6baf9`](https://github.com/sveltejs/kit/commit/81af6baf9b6f6e8f14212958eb393677db09320a), [`86dd16cc1`](https://github.com/sveltejs/kit/commit/86dd16cc10c35c4b723a4e7f77e654452aa0965e), [`195e9ac22`](https://github.com/sveltejs/kit/commit/195e9ac2233776ecf1aff7dadbadd7226f68e8dd)]:\n  - @sveltejs/kit@1.19.0\n\n## 2.2.4\n\n### Patch Changes\n\n- fix: require explicit cache-control header for caching ([#9885](https://github.com/sveltejs/kit/pull/9885))\n\n## 2.2.3\n\n### Patch Changes\n\n- fix: Copy .wasm files during build ([#9909](https://github.com/sveltejs/kit/pull/9909))\n\n- Updated dependencies [[`50acb22ca`](https://github.com/sveltejs/kit/commit/50acb22caf2901283e044cdfda36db6f07b3e0ae), [`2e6da9496`](https://github.com/sveltejs/kit/commit/2e6da9496bdace2c65040b9d1845c44801ca868c), [`a81106b3a`](https://github.com/sveltejs/kit/commit/a81106b3a817829c41e048207d6253e63988c58c), [`a6338a0b1`](https://github.com/sveltejs/kit/commit/a6338a0b124f54bda7ba3fe64be1d6173e118d00), [`4a85b7f08`](https://github.com/sveltejs/kit/commit/4a85b7f0820d35c7830c00afe1df3c94fcbf8c3d), [`26d2b7f8f`](https://github.com/sveltejs/kit/commit/26d2b7f8f5ca29c60ef61b936ff86deaeb1636ce), [`bc70b4e63`](https://github.com/sveltejs/kit/commit/bc70b4e636fcbd9593356996bf737e014ff8c238), [`ab9f57721`](https://github.com/sveltejs/kit/commit/ab9f57721fca146af7c4eb41f4875fafa5dfc0d2)]:\n  - @sveltejs/kit@1.17.0\n\n## 2.2.2\n\n### Patch Changes\n\n- fix: respect response status code for caching in `adapter-cloudflare` ([#9820](https://github.com/sveltejs/kit/pull/9820))\n\n## 2.2.1\n\n### Patch Changes\n\n- chore: update all dependencies with minor version bumps ([#9761](https://github.com/sveltejs/kit/pull/9761))\n\n## 2.2.0\n\n### Minor Changes\n\n- feat: generate `404.html` ([#9294](https://github.com/sveltejs/kit/pull/9294))\n\n- feat: use `es2022` target ([#9293](https://github.com/sveltejs/kit/pull/9293))\n\n### Patch Changes\n\n- Updated dependencies [[`2b647fd8`](https://github.com/sveltejs/kit/commit/2b647fd85be028bc5775894567ee8b13f91411a7), [`fbe4fe76`](https://github.com/sveltejs/kit/commit/fbe4fe768140abac09bd66edd12c77787cafc2c5), [`744dc81c`](https://github.com/sveltejs/kit/commit/744dc81c6b0d8cade087df733c6d3d3f1281e68c)]:\n  - @sveltejs/kit@1.10.0\n\n## 2.1.0\n\n### Minor Changes\n\n- feat: allow custom `include` and `exclude` rules in `_routes.json` ([#9111](https://github.com/sveltejs/kit/pull/9111))\n\n## 2.0.2\n\n### Patch Changes\n\n- fix: exclude `_headers` and `_redirects` files from Cloudflare Pages static request list ([#9042](https://github.com/sveltejs/kit/pull/9042))\n\n- fix: remove redundant cloudflare worker static asset serving ([#9040](https://github.com/sveltejs/kit/pull/9040))\n\n- Updated dependencies [[`19c0e62a`](https://github.com/sveltejs/kit/commit/19c0e62a6bd281e656061b453973c35fa2dd9d3d)]:\n  - @sveltejs/kit@1.5.7\n\n## 2.0.1\n\n### Patch Changes\n\n- fix: correctly check URL pathname with Cloudflare adapter ([#8733](https://github.com/sveltejs/kit/pull/8733))\n\n- Updated dependencies [[`eba8fb09`](https://github.com/sveltejs/kit/commit/eba8fb0929b35edea1ca7867b816abd184d8f8f7), [`c14f3aeb`](https://github.com/sveltejs/kit/commit/c14f3aeb32f3e78c8454e9b89f85a0650b7683c4)]:\n  - @sveltejs/kit@1.3.6\n\n## 2.0.0\n\n### Major Changes\n\n- breaking: append `_headers` instead of overwriting ([#8693](https://github.com/sveltejs/kit/pull/8693))\n\n## 1.1.0\n\n### Minor Changes\n\n- feat: include as many static assets as possible in exclude list ([#8422](https://github.com/sveltejs/kit/pull/8422))\n\n### Patch Changes\n\n- Updated dependencies [[`06a56ae5`](https://github.com/sveltejs/kit/commit/06a56ae587795113b17fec559ab49c93f40861e8), [`06a56ae5`](https://github.com/sveltejs/kit/commit/06a56ae587795113b17fec559ab49c93f40861e8), [`2726e7c2`](https://github.com/sveltejs/kit/commit/2726e7c2d6d086e6200f9edecbeecf0d38eef873)]:\n  - @sveltejs/kit@1.2.0\n\n## 1.0.4\n\n### Patch Changes\n\n- docs: move adapter docs to site ([#8531](https://github.com/sveltejs/kit/pull/8531))\n\n## 1.0.3\n\n### Patch Changes\n\n- chore: remove superfluous main field from package.json ([#8519](https://github.com/sveltejs/kit/pull/8519))\n\n- Updated dependencies [[`7e2d3405`](https://github.com/sveltejs/kit/commit/7e2d34056e99f371e22406d941b764df365a2649)]:\n  - @sveltejs/kit@1.1.1\n\n## 1.0.2\n\n### Patch Changes\n\n- fix: don't load ambient worker types ([#8483](https://github.com/sveltejs/kit/pull/8483))\n\n## 1.0.1\n\n### Patch Changes\n\n- docs: add note about inability to access file system at runtime ([#8441](https://github.com/sveltejs/kit/pull/8441))\n\n- Updated dependencies [[`9c01c32e`](https://github.com/sveltejs/kit/commit/9c01c32ef72bbed630fadcb8283f8f8533ced5e1), [`b6ca02a6`](https://github.com/sveltejs/kit/commit/b6ca02a684dbf13a3138b552e2d2be64697f2254), [`130abe43`](https://github.com/sveltejs/kit/commit/130abe43cef2cfbaf922aa16b20cbd4332a07c15), [`c4137536`](https://github.com/sveltejs/kit/commit/c4137536f2c6572eaeec1a82ccea0852f5be6b98), [`40464efa`](https://github.com/sveltejs/kit/commit/40464efab172a17f0b637d7dadea30d77ef1ed10), [`ce028470`](https://github.com/sveltejs/kit/commit/ce0284708184198efdd30f3ff72fd579cef830b4)]:\n  - @sveltejs/kit@1.0.12\n\n## 1.0.0\n\n### Major Changes\n\nFirst major release, see below for the history of changes that lead up to this.\nStarting from now all releases follow semver and changes will be listed as Major/Minor/Patch\n\n## 1.0.0-next.45\n\n### Patch Changes\n\n- breaking: remove warnings/errors about removed/changed APIs ([#8019](https://github.com/sveltejs/kit/pull/8019))\n- Updated dependencies [[`f42604a2`](https://github.com/sveltejs/kit/commit/f42604a2b4c04026d3d8bad95807720b79529539)]:\n  - @sveltejs/kit@1.0.0-next.589\n\n## 1.0.0-next.44\n\n### Patch Changes\n\n- chore: add peerDependencies, add more specific next version ([#8141](https://github.com/sveltejs/kit/pull/8141))\n\n## 1.0.0-next.43\n\n### Patch Changes\n\n- fix: revert platform change from browser to neutral ([#8122](https://github.com/sveltejs/kit/pull/8122))\n\n## 1.0.0-next.42\n\n### Patch Changes\n\n- fix: set esbuild platform to neutral ([#8083](https://github.com/sveltejs/kit/pull/8083))\n\n## 1.0.0-next.41\n\n### Patch Changes\n\n- update esbuild to ^0.16.3 ([#7543](https://github.com/sveltejs/kit/pull/7543))\n\n## 1.0.0-next.40\n\n### Patch Changes\n\n- update dependencies ([#7355](https://github.com/sveltejs/kit/pull/7355))\n\n## 1.0.0-next.39\n\n### Patch Changes\n\n- Use config.kit.paths.base prefix for static assets ([#4448](https://github.com/sveltejs/kit/pull/4448))\n\n## 1.0.0-next.38\n\n### Patch Changes\n\n- Ensure all excluded paths in `_routes.json` start with / ([#6952](https://github.com/sveltejs/kit/pull/6952))\n\n## 1.0.0-next.37\n\n### Patch Changes\n\n- Support Cloudflare Pages `_routes.json` specification ([#6530](https://github.com/sveltejs/kit/pull/6530))\n\n## 1.0.0-next.36\n\n### Patch Changes\n\n- Include ambient.d.ts files in adapter packages. ([#6917](https://github.com/sveltejs/kit/pull/6917))\n\n## 1.0.0-next.35\n\n### Patch Changes\n\n- fix: return 404 instead of 200 for missing assets ([#6879](https://github.com/sveltejs/kit/pull/6879))\n\n## 1.0.0-next.34\n\n### Patch Changes\n\n- chore: bump esbuild ([#6829](https://github.com/sveltejs/kit/pull/6829))\n\n## 1.0.0-next.33\n\n### Patch Changes\n\n- Update to esbuild 0.15 ([#6740](https://github.com/sveltejs/kit/pull/6740))\n\n## 1.0.0-next.32\n\n### Patch Changes\n\n- feat: Moved hooks.js initialization from Server.respond into Server.init ([#6179](https://github.com/sveltejs/kit/pull/6179))\n\n## 1.0.0-next.31\n\n### Patch Changes\n\n- Initialise `env` ([#5663](https://github.com/sveltejs/kit/pull/5663))\n\n## 1.0.0-next.30\n\n### Patch Changes\n\n- breaking: remove writeStatic to align with Vite ([#5618](https://github.com/sveltejs/kit/pull/5618))\n\n## 1.0.0-next.29\n\n### Patch Changes\n\n- Update dependencies ([#5005](https://github.com/sveltejs/kit/pull/5005))\n\n## 1.0.0-next.28\n\n### Patch Changes\n\n- breaking: Don't pass arbitrary options to esbuild ([#4639](https://github.com/sveltejs/kit/pull/4639))\n\n## 1.0.0-next.27\n\n### Patch Changes\n\n- Expose App interfaces ([#5386](https://github.com/sveltejs/kit/pull/5386))\n\n## 1.0.0-next.26\n\n### Patch Changes\n\n- chore: upgrade TypeScript to 4.7.4 ([#5414](https://github.com/sveltejs/kit/pull/5414))\n\n## 1.0.0-next.25\n\n### Patch Changes\n\n- Expose Cloudflare Worker Cache API through `caches` in Platform ([#5081](https://github.com/sveltejs/kit/pull/5081))\n\n## 1.0.0-next.24\n\n### Patch Changes\n\n- Generate sourcemaps for server-side functions when bundling with esbuild ([#5258](https://github.com/sveltejs/kit/pull/5258))\n\n## 1.0.0-next.23\n\n### Patch Changes\n\n- Update dependencies ([#5121](https://github.com/sveltejs/kit/pull/5121))\n\n## 1.0.0-next.22\n\n### Patch Changes\n\n- Update adapter entrypoint typings to be NodeNext/ESNext-compatible ([#5111](https://github.com/sveltejs/kit/pull/5111))\n\n## 1.0.0-next.21\n\n### Patch Changes\n\n- only serve `_app/immutable` with immutable cache header, not `_app/version.json` ([#5051](https://github.com/sveltejs/kit/pull/5051))\n\n## 1.0.0-next.20\n\n### Patch Changes\n\n- Add types to pkg.exports ([#5045](https://github.com/sveltejs/kit/pull/5045))\n\n## 1.0.0-next.19\n\n### Patch Changes\n\n- breaking: Remove try-catch around server.respond ([#4738](https://github.com/sveltejs/kit/pull/4738))\n\n## 1.0.0-next.18\n\n### Patch Changes\n\n- chore: more restrictive cache lookup & save conditions ([#4669](https://github.com/sveltejs/kit/pull/4669))\n\n## 1.0.0-next.17\n\n### Patch Changes\n\n- Check for Cache match sooner; use `worktop` for types & Cache operations ([#4453](https://github.com/sveltejs/kit/pull/4453))\n- Add cloudflare cache to store responses with a cache header. ([#4412](https://github.com/sveltejs/kit/pull/4412))\n\n## 1.0.0-next.16\n\n### Patch Changes\n\n- Provide getClientAddress function ([#4289](https://github.com/sveltejs/kit/pull/4289))\n\n## 1.0.0-next.15\n\n### Patch Changes\n\n- breaking: replace builder.prerender() with builder.writePrerendered() and builder.prerendered ([#4192](https://github.com/sveltejs/kit/pull/4192)) ([#4229](https://github.com/sveltejs/kit/pull/4229))\n\n## 1.0.0-next.14\n\n### Patch Changes\n\n- Bumping versions again ([#4090](https://github.com/sveltejs/kit/pull/4090))\n\n## 1.0.0-next.13\n\n### Patch Changes\n\n- Attempt to force @next version bump ([#4088](https://github.com/sveltejs/kit/pull/4088))\n\n## 1.0.0-next.12\n\n### Patch Changes\n\n- breaking: rename `app.render` to `server.respond` ([#4034](https://github.com/sveltejs/kit/pull/4034))\n\n## 1.0.0-next.11\n\n### Patch Changes\n\n- Add `context` to `event.platform` object ([#3868](https://github.com/sveltejs/kit/pull/3868))\n\n## 1.0.0-next.10\n\n### Patch Changes\n\n- update to Vite 2.8 and esbuild 0.14 ([#3791](https://github.com/sveltejs/kit/pull/3791))\n\n## 1.0.0-next.9\n\n### Patch Changes\n\n- Pass `env` object to SvelteKit via `platform` ([#3429](https://github.com/sveltejs/kit/pull/3429))\n\n## 1.0.0-next.8\n\n### Patch Changes\n\n- Breaking: change app.render signature to (request: Request) => Promise<Response> ([#3384](https://github.com/sveltejs/kit/pull/3384))\n\n## 1.0.0-next.7\n\n### Patch Changes\n\n- Add immutable cache headers to generated assets ([#3222](https://github.com/sveltejs/kit/pull/3222))\n\n## 1.0.0-next.6\n\n### Patch Changes\n\n- use posix to resolve relative path ([#3214](https://github.com/sveltejs/kit/pull/3214))\n\n## 1.0.0-next.5\n\n### Patch Changes\n\n- Overhaul adapter API ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- Remove esbuild options ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- Update adapters to provide app.render with a url ([#3133](https://github.com/sveltejs/kit/pull/3133))\n\n## 1.0.0-next.4\n\n### Patch Changes\n\n- Updated Cloudflare adapter to allow static files with spaces (eg. \"Example File.pdf\") to be accessed. ([#3047](https://github.com/sveltejs/kit/pull/3047))\n\n## 1.0.0-next.3\n\n### Patch Changes\n\n- update to esbuild 0.13.15 and other dependency updates ([#2957](https://github.com/sveltejs/kit/pull/2957))\n\n## 1.0.0-next.2\n\n### Patch Changes\n\n- Allow `npm publish` to succeed via `publishConfig.access` config ([#2834](https://github.com/sveltejs/kit/pull/2834))\n\n## 1.0.0-next.1\n\n### Patch Changes\n\n- Add new `adapter-cloudflare` package for Cloudflare Pages with Workers integration ([#2815](https://github.com/sveltejs/kit/pull/2815))\n\n## 1.0.0-next.0\n\n- Initial release\n"
  },
  {
    "path": "packages/adapter-cloudflare/README.md",
    "content": "# adapter-cloudflare\n\n[Adapter](https://svelte.dev/docs/kit/building-your-app) for building SvelteKit applications on [Cloudflare Workers](https://developers.cloudflare.com/workers/) with [static assets](https://developers.cloudflare.com/workers/static-assets/) or [Cloudflare Pages](https://developers.cloudflare.com/pages/) with [Workers integration](https://developers.cloudflare.com/pages/functions/).\n\n## Docs\n\n[Docs](https://svelte.dev/docs/kit/adapter-cloudflare)\n\n## Changelog\n\n[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/adapter-cloudflare/CHANGELOG.md).\n"
  },
  {
    "path": "packages/adapter-cloudflare/ambient.d.ts",
    "content": "import {\n\tCacheStorage,\n\tIncomingRequestCfProperties,\n\tExecutionContext\n} from '@cloudflare/workers-types';\n\ndeclare global {\n\tnamespace App {\n\t\texport interface Platform {\n\t\t\tenv: unknown;\n\t\t\tctx: ExecutionContext;\n\t\t\t/** @deprecated Use `ctx` instead */\n\t\t\tcontext: ExecutionContext;\n\t\t\tcaches: CacheStorage;\n\t\t\tcf?: IncomingRequestCfProperties;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/index.d.ts",
    "content": "import { Adapter } from '@sveltejs/kit';\nimport './ambient.js';\nimport { GetPlatformProxyOptions } from 'wrangler';\n\nexport default function plugin(options?: AdapterOptions): Adapter;\n\nexport interface AdapterOptions {\n\t/**\n\t * Path to your [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/configuration/).\n\t */\n\tconfig?: string;\n\t/**\n\t * Whether to render a plaintext 404.html page or a rendered SPA fallback page\n\t * for non-matching asset requests.\n\t *\n\t * For Cloudflare Workers, the default behaviour is to return a null-body\n\t * 404-status response for non-matching assets requests. However, if the\n\t * [`assets.not_found_handling`](https://developers.cloudflare.com/workers/static-assets/routing/#2-not_found_handling)\n\t * Wrangler configuration setting is set to `\"404-page\"`, this page will be\n\t * served if a request fails to match an asset. If `assets.not_found_handling`\n\t * is set to `\"single-page-application\"`, the adapter will render a SPA fallback\n\t * `index.html` page regardless of the `fallback` option specified.\n\t *\n\t * For Cloudflare Pages, this page will only be served when a request that\n\t * matches an entry in `routes.exclude` fails to match an asset.\n\t *\n\t * Most of the time `plaintext` is sufficient, but if you are using `routes.exclude` to manually\n\t * exclude a set of prerendered pages without exceeding the 100 route limit, you may wish to\n\t * use `spa` instead to avoid showing an unstyled 404 page to users.\n\t *\n\t * See [Cloudflare Pages' Not Found behavior](https://developers.cloudflare.com/pages/configuration/serving-pages/#not-found-behavior) for more info.\n\t *\n\t * @default 'plaintext'\n\t */\n\tfallback?: 'plaintext' | 'spa';\n\n\t/**\n\t * Only for Cloudflare Pages. Customize the automatically-generated [`_routes.json`](https://developers.cloudflare.com/pages/platform/functions/routing/#create-a-_routesjson-file) file.\n\t */\n\troutes?: {\n\t\t/**\n\t\t * Routes that will be invoked by functions. Accepts wildcards.\n\t\t * @default [\"/*\"]\n\t\t */\n\t\tinclude?: string[];\n\n\t\t/**\n\t\t * Routes that will not be invoked by functions. Accepts wildcards.\n\t\t * `exclude` takes priority over `include`.\n\t\t *\n\t\t * To have the adapter automatically exclude certain things, you can use these placeholders:\n\t\t *\n\t\t * - `<build>` to exclude build artifacts (files generated by Vite)\n\t\t * - `<files>` for the contents of your `static` directory\n\t\t * - `<prerendered>` for prerendered routes\n\t\t * - `<all>` to exclude all of the above\n\t\t *\n\t\t * @default [\"<all>\"]\n\t\t */\n\t\texclude?: string[];\n\t};\n\n\t/**\n\t * Config object passed to [`getPlatformProxy`](https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy)\n\t * during development and preview.\n\t */\n\tplatformProxy?: GetPlatformProxyOptions;\n}\n\n/**\n * The JSON format of the {@link https://developers.cloudflare.com/pages/functions/routing/#create-a-_routesjson-file | `_routes.json`}\n * file that controls when the Cloudflare Pages Function is invoked.\n */\nexport interface RoutesJSONSpec {\n\tversion: 1;\n\tdescription: string;\n\tinclude: string[];\n\texclude: string[];\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/index.js",
    "content": "import { VERSION } from '@sveltejs/kit';\nimport { copyFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\nimport { getPlatformProxy, unstable_readConfig } from 'wrangler';\nimport {\n\tis_building_for_cloudflare_pages,\n\tvalidate_worker_settings,\n\tget_routes_json,\n\tparse_redirects\n} from './utils.js';\n\nconst name = '@sveltejs/adapter-cloudflare';\nconst [kit_major, kit_minor] = VERSION.split('.');\n\n/** @type {import('./index.js').default} */\nexport default function (options = {}) {\n\treturn {\n\t\tname,\n\t\t/** @param {Builder2_0_0} builder */\n\t\tasync adapt(builder) {\n\t\t\tif (\n\t\t\t\texistsSync('_routes.json') ||\n\t\t\t\texistsSync(`${builder.config.kit.files.assets}/_routes.json`)\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Cloudflare Pages' _routes.json should be configured in svelte.config.js. See https://svelte.dev/docs/kit/adapter-cloudflare#Options-routes\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (existsSync(`${builder.config.kit.files.assets}/_headers`)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The _headers file should be placed in the project root rather than the ${builder.config.kit.files.assets} directory`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (existsSync(`${builder.config.kit.files.assets}/_redirects`)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The _redirects file should be placed in the project root rather than the ${builder.config.kit.files.assets} directory`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst { wrangler_config, building_for_cloudflare_pages } = validate_wrangler_config(\n\t\t\t\toptions.config\n\t\t\t);\n\n\t\t\tlet dest = builder.getBuildDirectory('cloudflare');\n\t\t\tlet worker_dest = `${dest}/_worker.js`;\n\t\t\tlet assets_binding = 'ASSETS';\n\n\t\t\tif (building_for_cloudflare_pages) {\n\t\t\t\tif (wrangler_config.pages_build_output_dir) {\n\t\t\t\t\tdest = wrangler_config.pages_build_output_dir;\n\t\t\t\t\tworker_dest = `${dest}/_worker.js`;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (wrangler_config.main) {\n\t\t\t\t\tworker_dest = wrangler_config.main;\n\t\t\t\t}\n\t\t\t\tif (wrangler_config.assets?.directory) {\n\t\t\t\t\t// wrangler doesn't resolve `assets.directory` to an absolute path unlike\n\t\t\t\t\t// `main` and `pages_build_output_dir` so we need to do it ourselves here\n\t\t\t\t\tconst parent_dir = wrangler_config.configPath\n\t\t\t\t\t\t? path.dirname(path.resolve(wrangler_config.configPath))\n\t\t\t\t\t\t: process.cwd();\n\t\t\t\t\tdest = path.resolve(parent_dir, wrangler_config.assets.directory);\n\t\t\t\t}\n\t\t\t\tif (wrangler_config.assets?.binding) {\n\t\t\t\t\tassets_binding = wrangler_config.assets.binding;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst files = fileURLToPath(new URL('./files', import.meta.url).href);\n\t\t\tconst tmp = builder.getBuildDirectory('cloudflare-tmp');\n\n\t\t\tbuilder.rimraf(dest);\n\t\t\tbuilder.rimraf(worker_dest);\n\n\t\t\tbuilder.mkdirp(dest);\n\t\t\tbuilder.mkdirp(tmp);\n\n\t\t\t// client assets and prerendered pages\n\t\t\tconst assets_dest = `${dest}${builder.config.kit.paths.base}`;\n\t\t\tbuilder.mkdirp(assets_dest);\n\t\t\tif (\n\t\t\t\tbuilding_for_cloudflare_pages ||\n\t\t\t\twrangler_config.assets?.not_found_handling === '404-page'\n\t\t\t) {\n\t\t\t\t// generate plaintext 404.html first which can then be overridden by prerendering, if the user defined such a page.\n\t\t\t\t// This file is served when a request fails to match an asset.\n\t\t\t\t// If we're building for Cloudflare Pages, it's only served when a request matches an entry in `routes.exclude`\n\t\t\t\tconst fallback = path.join(assets_dest, '404.html');\n\t\t\t\tif (options.fallback === 'spa') {\n\t\t\t\t\tawait builder.generateFallback(fallback);\n\t\t\t\t} else {\n\t\t\t\t\twriteFileSync(fallback, 'Not Found');\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst client_assets = builder.writeClient(assets_dest);\n\t\t\tbuilder.writePrerendered(assets_dest);\n\t\t\tif (\n\t\t\t\t!building_for_cloudflare_pages &&\n\t\t\t\twrangler_config.assets?.not_found_handling === 'single-page-application'\n\t\t\t) {\n\t\t\t\tawait builder.generateFallback(path.join(assets_dest, 'index.html'));\n\t\t\t}\n\n\t\t\t// worker\n\t\t\tconst worker_dest_dir = path.dirname(worker_dest);\n\t\t\twriteFileSync(\n\t\t\t\t`${tmp}/manifest.js`,\n\t\t\t\t`export const manifest = ${builder.generateManifest({ relativePath: path.posix.relative(tmp, builder.getServerDirectory()) })};\\n\\n` +\n\t\t\t\t\t`export const prerendered = new Set(${JSON.stringify(builder.prerendered.paths)});\\n\\n` +\n\t\t\t\t\t`export const base_path = ${JSON.stringify(builder.config.kit.paths.base)};\\n`\n\t\t\t);\n\t\t\tbuilder.copy(`${files}/worker.js`, worker_dest, {\n\t\t\t\treplace: {\n\t\t\t\t\t// the paths returned by the Wrangler config might be Windows paths,\n\t\t\t\t\t// so we need to convert them to POSIX paths or else the backslashes\n\t\t\t\t\t// will be interpreted as escape characters and create an incorrect import path.\n\t\t\t\t\t// We also need to ensure the relative imports start with ./ since Wrangler\n\t\t\t\t\t// errors if a relative import looks like a package import\n\t\t\t\t\tSERVER: `./${posixify(path.relative(worker_dest_dir, builder.getServerDirectory()))}/index.js`,\n\t\t\t\t\tMANIFEST: `./${posixify(path.relative(worker_dest_dir, tmp))}/manifest.js`,\n\t\t\t\t\tASSETS: assets_binding\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (builder.hasServerInstrumentationFile?.()) {\n\t\t\t\tbuilder.instrument?.({\n\t\t\t\t\tentrypoint: worker_dest,\n\t\t\t\t\tinstrumentation: `${builder.getServerDirectory()}/instrumentation.server.js`\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// _headers\n\t\t\tconst headers_src = '_headers';\n\t\t\tconst headers_dest = `${dest}/_headers`;\n\t\t\tif (existsSync(headers_src)) {\n\t\t\t\tcopyFileSync(headers_src, headers_dest);\n\t\t\t}\n\t\t\twriteFileSync(headers_dest, generate_headers(builder.getAppPath()), { flag: 'a' });\n\n\t\t\t// _redirects\n\t\t\tconst redirects_src = '_redirects';\n\t\t\tconst redirects_dest = `${dest}/_redirects`;\n\t\t\tif (existsSync(redirects_src)) {\n\t\t\t\tcopyFileSync(redirects_src, redirects_dest);\n\t\t\t}\n\t\t\tif (builder.prerendered.redirects.size > 0) {\n\t\t\t\twriteFileSync(redirects_dest, generate_redirects(builder.prerendered.redirects), {\n\t\t\t\t\tflag: 'a'\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (building_for_cloudflare_pages) {\n\t\t\t\t// _routes.json\n\n\t\t\t\t// we need to add the source paths found in the `_redirects` file to the\n\t\t\t\t// `_routes.json` file so that Cloudflare knows it shouldn't invoke the\n\t\t\t\t// Worker but instead let the rules in the `_redirects` file take over.\n\t\t\t\t/** @type {string[]} */\n\t\t\t\tlet redirects = [];\n\t\t\t\tif (existsSync(redirects_dest)) {\n\t\t\t\t\tconst redirect_rules = readFileSync(redirects_dest, 'utf8');\n\t\t\t\t\tredirects = parse_redirects(redirect_rules);\n\t\t\t\t}\n\n\t\t\t\twriteFileSync(\n\t\t\t\t\t`${dest}/_routes.json`,\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\tget_routes_json(builder, client_assets, redirects, options.routes ?? {}),\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t'\\t'\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\twriteFileSync(`${dest}/.assetsignore`, generate_assetsignore(), { flag: 'a' });\n\t\t\t}\n\t\t},\n\t\temulate() {\n\t\t\t// we want to invoke `getPlatformProxy` only once, but await it only when it is accessed.\n\t\t\t// If we would await it here, it would hang indefinitely because the platform proxy only resolves once a request happens\n\t\t\tconst get_emulated = async () => {\n\t\t\t\tconst proxy = await getPlatformProxy(options.platformProxy);\n\t\t\t\tconst platform = /** @type {App.Platform} */ ({\n\t\t\t\t\tenv: proxy.env,\n\t\t\t\t\tctx: proxy.ctx,\n\t\t\t\t\tcontext: proxy.ctx, // deprecated in favor of ctx\n\t\t\t\t\tcaches: proxy.caches,\n\t\t\t\t\tcf: proxy.cf\n\t\t\t\t});\n\t\t\t\t/** @type {Record<string, any>} */\n\t\t\t\tconst env = {};\n\t\t\t\tconst prerender_platform = /** @type {App.Platform} */ (/** @type {unknown} */ ({ env }));\n\t\t\t\tfor (const key in proxy.env) {\n\t\t\t\t\tObject.defineProperty(env, key, {\n\t\t\t\t\t\tget: () => {\n\t\t\t\t\t\t\tthrow new Error(`Cannot access platform.env.${key} in a prerenderable route`);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn { platform, prerender_platform };\n\t\t\t};\n\n\t\t\t/** @type {{ platform: App.Platform, prerender_platform: App.Platform }} */\n\t\t\tlet emulated;\n\n\t\t\treturn {\n\t\t\t\tplatform: async ({ prerender }) => {\n\t\t\t\t\temulated ??= await get_emulated();\n\t\t\t\t\treturn prerender ? emulated.prerender_platform : emulated.platform;\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tsupports: {\n\t\t\tread: ({ route }) => {\n\t\t\t\t// TODO bump peer dep in next adapter major to simplify this\n\t\t\t\tif (kit_major === '2' && kit_minor < '25') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${name}: Cannot use \\`read\\` from \\`$app/server\\` in route \\`${route.id}\\` when using SvelteKit < 2.25.0`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tinstrumentation: () => true\n\t\t}\n\t};\n}\n\n/**\n * @param {string} app_dir\n * @returns {string}\n */\nfunction generate_headers(app_dir) {\n\treturn `\n# === START AUTOGENERATED SVELTE IMMUTABLE HEADERS ===\n/${app_dir}/*\n  X-Robots-Tag: noindex\n\tCache-Control: no-cache\n/${app_dir}/immutable/*\n  ! Cache-Control\n\tCache-Control: public, immutable, max-age=31536000\n# === END AUTOGENERATED SVELTE IMMUTABLE HEADERS ===\n`.trimEnd();\n}\n\n/**\n * @param {Map<string, { status: number; location: string }>} redirects\n * @returns {string}\n */\nfunction generate_redirects(redirects) {\n\tconst rules = Array.from(\n\t\tredirects.entries(),\n\t\t([path, redirect]) => `${path} ${redirect.location} ${redirect.status}`\n\t).join('\\n');\n\n\treturn `\n# === START AUTOGENERATED SVELTE PRERENDERED REDIRECTS ===\n${rules}\n# === END AUTOGENERATED SVELTE PRERENDERED REDIRECTS ===\n`.trimEnd();\n}\n\n/**\n * @returns {string}\n */\nfunction generate_assetsignore() {\n\t// this comes from https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/templates-experimental/svelte/templates/static/.assetsignore\n\treturn `\n_worker.js\n_routes.json\n_headers\n_redirects\n`.trimEnd();\n}\n\n/**\n * @param {string | undefined} config_file\n * @returns {{\n * \twrangler_config: import('wrangler').Unstable_Config,\n * \tbuilding_for_cloudflare_pages: boolean\n * }}\n */\nfunction validate_wrangler_config(config_file = undefined) {\n\tconst wrangler_config = unstable_readConfig({ config: config_file });\n\n\tconst building_for_cloudflare_pages = is_building_for_cloudflare_pages(wrangler_config);\n\n\t// we don't need to validate the config if we're building for Cloudflare Pages\n\t// because the `main` and `assets` values cannot be changed there\n\tif (!building_for_cloudflare_pages) {\n\t\tvalidate_worker_settings(wrangler_config);\n\t}\n\n\treturn {\n\t\twrangler_config,\n\t\tbuilding_for_cloudflare_pages\n\t};\n}\n\n/** @param {string} str */\nfunction posixify(str) {\n\treturn str.replace(/\\\\/g, '/');\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/internal.d.ts",
    "content": "declare module 'SERVER' {\n\texport { Server } from '@sveltejs/kit';\n}\n\ndeclare module 'MANIFEST' {\n\timport { SSRManifest } from '@sveltejs/kit';\n\n\texport const manifest: SSRManifest;\n\texport const prerendered: Set<string>;\n\texport const app_path: string;\n\texport const base_path: string;\n}\n\ntype PartialExcept<T, K extends keyof T> = Partial<Omit<T, K>> & Required<Pick<T, K>>;\n\n/**\n * We use a custom `Builder` type here to ensure compatibility with the minimum version of SvelteKit.\n */\ntype Builder2_0_0 = PartialExcept<\n\timport('@sveltejs/kit').Builder,\n\t| 'log'\n\t| 'rimraf'\n\t| 'mkdirp'\n\t| 'config'\n\t| 'prerendered'\n\t| 'routes'\n\t| 'createEntries'\n\t| 'generateFallback'\n\t| 'generateEnvModule'\n\t| 'generateManifest'\n\t| 'getBuildDirectory'\n\t| 'getClientDirectory'\n\t| 'getServerDirectory'\n\t| 'getAppPath'\n\t| 'writeClient'\n\t| 'writePrerendered'\n\t| 'writePrerendered'\n\t| 'writeServer'\n\t| 'copy'\n\t| 'compress'\n>;\n"
  },
  {
    "path": "packages/adapter-cloudflare/package.json",
    "content": "{\n\t\"name\": \"@sveltejs/adapter-cloudflare\",\n\t\"version\": \"7.2.8\",\n\t\"description\": \"Adapts SvelteKit applications for Cloudflare Workers or Cloudflare Pages\",\n\t\"keywords\": [\n\t\t\"adapter\",\n\t\t\"cloudflare pages\",\n\t\t\"deploy\",\n\t\t\"hosting\",\n\t\t\"svelte\",\n\t\t\"sveltekit\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/sveltejs/kit.git\",\n\t\t\"directory\": \"packages/adapter-cloudflare\"\n\t},\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://svelte.dev/docs/kit/adapter-cloudflare\",\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./index.d.ts\",\n\t\t\t\"import\": \"./index.js\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"types\": \"index.d.ts\",\n\t\"files\": [\n\t\t\"files\",\n\t\t\"index.js\",\n\t\t\"utils.js\",\n\t\t\"index.d.ts\",\n\t\t\"ambient.d.ts\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"esbuild src/worker.js --bundle --outfile=files/worker.js --external:SERVER --external:MANIFEST --external:cloudflare:workers --format=esm\",\n\t\t\"lint\": \"prettier --check .\",\n\t\t\"format\": \"pnpm lint --write\",\n\t\t\"check\": \"tsc --skipLibCheck\",\n\t\t\"test:unit\": \"vitest run\",\n\t\t\"test:e2e\": \"pnpm build && pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test\",\n\t\t\"test\": \"pnpm test:unit && pnpm test:e2e\",\n\t\t\"prepublishOnly\": \"pnpm build\"\n\t},\n\t\"dependencies\": {\n\t\t\"@cloudflare/workers-types\": \"^4.20250507.0\",\n\t\t\"worktop\": \"0.8.0-next.18\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@playwright/test\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@types/node\": \"catalog:\",\n\t\t\"esbuild\": \"catalog:\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@sveltejs/kit\": \"^2.0.0\",\n\t\t\"wrangler\": \"^4.0.0\"\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/src/worker.js",
    "content": "import { Server } from 'SERVER';\nimport { manifest, prerendered, base_path } from 'MANIFEST';\nimport { env } from 'cloudflare:workers';\nimport * as Cache from 'worktop/cfw.cache';\n\nconst server = new Server(manifest);\n\nconst app_path = `/${manifest.appPath}`;\n\nconst immutable = `${app_path}/immutable/`;\nconst version_file = `${app_path}/version.json`;\n\n/**\n * We don't know the origin until we receive a request, but\n * that's guaranteed to happen before we call `read`\n * @type {string}\n */\nlet origin;\n\nconst initialized = server.init({\n\t// @ts-expect-error env contains environment variables and bindings\n\tenv,\n\tread: async (file) => {\n\t\tconst url = `${origin}/${file}`;\n\t\tconst response = await /** @type {{ ASSETS: { fetch: typeof fetch } }} */ (env).ASSETS.fetch(\n\t\t\turl\n\t\t);\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(\n\t\t\t\t`read(...) failed: could not fetch ${url} (${response.status} ${response.statusText})`\n\t\t\t);\n\t\t}\n\n\t\treturn response.body;\n\t}\n});\n\nexport default {\n\t/**\n\t * @param {Request} req\n\t * @param {{ ASSETS: { fetch: typeof fetch } }} env\n\t * @param {ExecutionContext} ctx\n\t * @returns {Promise<Response>}\n\t */\n\tasync fetch(req, env, ctx) {\n\t\tif (!origin) {\n\t\t\torigin = new URL(req.url).origin;\n\t\t}\n\n\t\t// always await initialization to prevent race condition with concurrent requests\n\t\tawait initialized;\n\n\t\t// skip cache if \"cache-control: no-cache\" in request\n\t\tlet pragma = req.headers.get('cache-control') || '';\n\t\tlet res = !pragma.includes('no-cache') && (await Cache.lookup(req));\n\t\tif (res) return res;\n\n\t\tlet { pathname, search } = new URL(req.url);\n\t\ttry {\n\t\t\tpathname = decodeURIComponent(pathname);\n\t\t} catch {\n\t\t\t// ignore invalid URI\n\t\t}\n\n\t\tconst stripped_pathname = pathname.replace(/\\/$/, '');\n\n\t\t// files in /static, the service worker, and Vite imported server assets\n\t\tlet is_static_asset = false;\n\t\tconst filename = stripped_pathname.slice(base_path.length + 1);\n\t\tif (filename) {\n\t\t\tis_static_asset =\n\t\t\t\tmanifest.assets.has(filename) ||\n\t\t\t\tmanifest.assets.has(filename + '/index.html') ||\n\t\t\t\tfilename in manifest._.server_assets ||\n\t\t\t\tfilename + '/index.html' in manifest._.server_assets;\n\t\t}\n\n\t\tlet location = pathname.at(-1) === '/' ? stripped_pathname : pathname + '/';\n\n\t\tif (\n\t\t\tis_static_asset ||\n\t\t\tprerendered.has(pathname) ||\n\t\t\tpathname === version_file ||\n\t\t\tpathname.startsWith(immutable)\n\t\t) {\n\t\t\tres = await env.ASSETS.fetch(req);\n\t\t} else if (location && prerendered.has(location)) {\n\t\t\t// trailing slash redirect for prerendered pages\n\t\t\tif (search) location += search;\n\t\t\tres = new Response('', {\n\t\t\t\tstatus: 308,\n\t\t\t\theaders: {\n\t\t\t\t\tlocation\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\t// dynamically-generated pages\n\t\t\tres = await server.respond(req, {\n\t\t\t\tplatform: {\n\t\t\t\t\tenv,\n\t\t\t\t\tctx,\n\t\t\t\t\tcontext: ctx, // deprecated in favor of ctx\n\t\t\t\t\t// @ts-expect-error webworker types from worktop are not compatible with Cloudflare Workers types\n\t\t\t\t\tcaches,\n\t\t\t\t\t// @ts-expect-error the type is correct but ts is confused because platform.cf uses the type from index.ts while req.cf uses the type from index.d.ts\n\t\t\t\t\tcf: req.cf\n\t\t\t\t},\n\t\t\t\tgetClientAddress() {\n\t\t\t\t\treturn /** @type {string} */ (req.headers.get('cf-connecting-ip'));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// write to `Cache` only if response is not an error,\n\t\t// let `Cache.save` handle the Cache-Control and Vary headers\n\t\tpragma = res.headers.get('cache-control') || '';\n\t\treturn pragma && res.status < 400 ? Cache.save(req, res, ctx) : res;\n\t}\n};\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/.gitignore",
    "content": ".DS_Store\nnode_modules\n/.svelte-kit\n/.wrangler"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/package.json",
    "content": "{\n\t\"name\": \"test-cloudflare-pages\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"wrangler pages dev .svelte-kit/cloudflare --port 8787\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"test\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"server-side-dep\": \"file:server-side-dep\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"vite\": \"catalog:\",\n\t\t\"wrangler\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/server-side-dep/index.d.ts",
    "content": "export function sum(a: number, b: number): number;\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/server-side-dep/index.js",
    "content": "/** @type {import('./index.js').sum} */\nexport function sum(a, b) {\n\treturn a + b;\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/server-side-dep/package.json",
    "content": "{\n\t\"name\": \"server-side-dep\",\n\t\"version\": \"0.0.1\",\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"default\": \"./index.js\",\n\t\t\t\"types\": \"./index.d.ts\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/src/routes/+page.server.js",
    "content": "// this tests that Wrangler can correctly resolve and bundle server-side dependencies\nimport { sum } from 'server-side-dep';\n\nexport function load() {\n\treturn {\n\t\tsum: sum(1, 2)\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/src/routes/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>Sum: {data.sum}</h1>\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/svelte.config.js",
    "content": "import adapter from '../../../index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/test/test.js",
    "content": "import { expect, test } from '@playwright/test';\n\ntest('worker', async ({ page }) => {\n\tawait page.goto('/');\n\tawait expect(page.locator('h1')).toContainText('Sum: 3');\n});\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"moduleResolution\": \"bundler\"\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/pages/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tplugins: [sveltekit()]\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/.gitignore",
    "content": ".DS_Store\nnode_modules\n/.svelte-kit\n/.wrangler\n/dist"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/config/wrangler.jsonc",
    "content": "// we've moved the wrangler config away from the root of the project\n// to test that the adapter still resolves the paths correctly\n{\n\t\"$schema\": \"../node_modules/wrangler/config-schema.json\",\n\t\"main\": \"../dist/index.js\",\n\t\"assets\": {\n\t\t\"directory\": \"../dist/public\",\n\t\t\"binding\": \"ASSETS\"\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/package.json",
    "content": "{\n\t\"name\": \"test-cloudflare-workers\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"wrangler dev dist/index.js\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"test:dev\": \"DEV=true playwright test\",\n\t\t\"test:build\": \"playwright test\",\n\t\t\"test\": \"pnpm test:dev && pnpm test:build\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"server-side-dep\": \"file:server-side-dep\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"vite\": \"catalog:\",\n\t\t\"wrangler\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/server-side-dep/index.d.ts",
    "content": "export function sum(a: number, b: number): number;\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/server-side-dep/index.js",
    "content": "/** @type {import('./index.js').sum} */\nexport function sum(a, b) {\n\treturn a + b;\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/server-side-dep/package.json",
    "content": "{\n\t\"name\": \"server-side-dep\",\n\t\"version\": \"0.0.1\",\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"default\": \"./index.js\",\n\t\t\t\"types\": \"./index.d.ts\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/src/app.d.ts",
    "content": "// TODO: remove this in 3.0 once svelte.config.js is included by the generated tsconfig.json\n// this ensures we get the ambient types from the adapter\nimport '../../../../index.js';\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/src/routes/+page.server.js",
    "content": "// this tests that Wrangler can correctly resolve and bundle server-side dependencies\nimport { sum } from 'server-side-dep';\n\nexport function load() {\n\treturn {\n\t\tsum: sum(1, 2)\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/src/routes/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>Sum: {data.sum}</h1>\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/src/routes/ctx/+server.js",
    "content": "export function GET({ platform }) {\n\treturn new Response(platform?.ctx.waitUntil ? 'ctx works' : 'ctx does not work');\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/src/routes/read/+server.js",
    "content": "import { read } from '$app/server';\nimport file from './file.txt?url';\n\nexport function GET() {\n\treturn read(file);\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/src/routes/read/file.txt",
    "content": "Hello! This file is read by `read` from `$app/server`.\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/svelte.config.js",
    "content": "import adapter from '../../../index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\tconfig: 'config/wrangler.jsonc'\n\t\t})\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/test/test.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { expect, test } from '@playwright/test';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\ntest('worker', async ({ page }) => {\n\tawait page.goto('/');\n\tawait expect(page.locator('h1')).toContainText('Sum: 3');\n});\n\ntest('ctx', async ({ request }) => {\n\tconst res = await request.get('/ctx');\n\texpect(await res.text()).toBe('ctx works');\n});\n\ntest('read from $app/server works', async ({ request }) => {\n\tconst content = fs.readFileSync(path.resolve(__dirname, '../src/routes/read/file.txt'), 'utf-8');\n\tconst response = await request.get('/read');\n\texpect(await response.text()).toBe(content);\n});\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"moduleResolution\": \"bundler\"\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/apps/workers/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tplugins: [sveltekit()]\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-cloudflare/test/utils.js",
    "content": "import { devices } from '@playwright/test';\nimport process from 'node:process';\nimport { number_from_env } from '../../../test-utils/index.js';\n\n/** @type {import('@playwright/test').PlaywrightTestConfig} */\nexport const config = {\n\tforbidOnly: !!process.env.CI,\n\t// generous timeouts on CI\n\ttimeout: process.env.CI ? 45000 : 15000,\n\twebServer: {\n\t\tcommand: process.env.DEV ? 'pnpm dev' : 'pnpm build && pnpm preview',\n\t\tport: process.env.DEV ? 5173 : 8787\n\t},\n\tretries: process.env.CI ? 2 : number_from_env('KIT_E2E_RETRIES', 0),\n\tprojects: [\n\t\t{\n\t\t\tname: 'chromium'\n\t\t}\n\t],\n\tuse: {\n\t\t...devices['Desktop Chrome'],\n\t\tscreenshot: 'only-on-failure',\n\t\ttrace: 'retain-on-failure',\n\t\tchannel: 'chromium'\n\t},\n\tworkers: process.env.CI ? 2 : number_from_env('KIT_E2E_WORKERS', undefined),\n\treporter: 'list',\n\ttestDir: 'test',\n\ttestMatch: /(.+\\.)?(test|spec)\\.[jt]s/\n};\n"
  },
  {
    "path": "packages/adapter-cloudflare/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"noImplicitAny\": true,\n\t\t\"strictNullChecks\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"node16\",\n\t\t\"moduleResolution\": \"node16\",\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../kit/types/index\"]\n\t\t},\n\t\t// taken from the Cloudflare Workers TypeScript template https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/templates/hello-world/ts/tsconfig.json\n\t\t\"lib\": [\"es2021\"],\n\t\t\"types\": [\"@cloudflare/workers-types\"]\n\t},\n\t\"include\": [\n\t\t\"index.js\",\n\t\t\"utils.js\",\n\t\t\"utils.spec.js\",\n\t\t\"test/utils.js\",\n\t\t\"internal.d.ts\",\n\t\t\"src/worker.js\"\n\t]\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/utils.js",
    "content": "import process from 'node:process';\n\n/**\n * @param {import('wrangler').Unstable_Config} wrangler_config\n * @returns {boolean}\n */\nexport function is_building_for_cloudflare_pages(wrangler_config) {\n\tif (process.env.CF_PAGES || wrangler_config.pages_build_output_dir) {\n\t\treturn true;\n\t}\n\n\tif (wrangler_config.main || wrangler_config.assets) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * @param {import('wrangler').Unstable_Config} wrangler_config\n */\nexport function validate_worker_settings(wrangler_config) {\n\tconst config_path = wrangler_config.configPath || 'your wrangler.jsonc file';\n\n\t// we don't support workers sites\n\tif (wrangler_config.site) {\n\t\tthrow new Error(\n\t\t\t`You must remove all \\`site\\` keys in ${config_path}. Consult https://svelte.dev/docs/kit/adapter-cloudflare#Migrating-from-Workers-Sites`\n\t\t);\n\t}\n\n\t// we need the `assets.directory` key so that the static assets are deployed\n\tif ((wrangler_config.main || wrangler_config.assets) && !wrangler_config.assets?.directory) {\n\t\tthrow new Error(\n\t\t\t`You must specify the \\`assets.directory\\` key in ${config_path}. Consult https://developers.cloudflare.com/workers/static-assets/binding/#directory`\n\t\t);\n\t}\n\n\t// we need the `assets.binding` key so that the Worker can access the static assets\n\tif (wrangler_config.main && !wrangler_config.assets?.binding) {\n\t\tthrow new Error(\n\t\t\t`You must specify the \\`assets.binding\\` key in ${config_path} before deploying your Worker. Consult https://developers.cloudflare.com/workers/static-assets/binding/#binding`\n\t\t);\n\t}\n\n\t// the user might have forgot the `main` key or should remove the `assets.binding`\n\t// key to deploy static assets without a Worker\n\tif (!wrangler_config.main && wrangler_config.assets?.binding) {\n\t\tthrow new Error(\n\t\t\t`You must specify the \\`main\\` key in ${config_path} if you want to deploy a Worker alongside your static assets. Otherwise, remove the \\`assets.binding\\` key if you only want to deploy static assets.`\n\t\t);\n\t}\n}\n\n/**\n * Extracts the redirect source from each line of a [_redirects](https://developers.cloudflare.com/pages/configuration/redirects/)\n * file so we can exclude them in [_routes.json](https://developers.cloudflare.com/pages/functions/routing/#create-a-_routesjson-file)\n * to ensure the redirect is invoked instead of the Cloudflare Worker.\n * @param {string} file_contents\n * @returns {string[]}\n */\nexport function parse_redirects(file_contents) {\n\t/** @type {string[]} */\n\tconst redirects = [];\n\n\tfor (const line of file_contents.split('\\n')) {\n\t\tconst content = line.trim();\n\t\tif (!content || content.startsWith('#')) continue;\n\n\t\tconst [pathname] = line.split(' ');\n\t\t// pathnames with placeholders are not supported\n\t\tif (!pathname || pathname.includes('/:')) {\n\t\t\tthrow new Error(`The following _redirects rule cannot be excluded by _routes.json: ${line}`);\n\t\t}\n\t\tredirects.push(pathname);\n\t}\n\n\treturn redirects;\n}\n\n/**\n * Generates the [_routes.json](https://developers.cloudflare.com/pages/functions/routing/#create-a-_routesjson-file)\n * file that dictates which routes invoke the Cloudflare Worker.\n * @param {Builder2_0_0} builder\n * @param {string[]} client_assets\n * @param {string[]} redirects\n * @param {import('./index.js').AdapterOptions['routes']} routes\n * @returns {import('./index.js').RoutesJSONSpec}\n */\nexport function get_routes_json(builder, client_assets, redirects, routes) {\n\tconst include = routes?.include ?? ['/*'];\n\tlet exclude = routes?.exclude ?? ['<all>'];\n\n\tif (!Array.isArray(include) || !Array.isArray(exclude)) {\n\t\tthrow new Error('routes.include and routes.exclude must be arrays');\n\t}\n\n\tif (include?.length === 0) {\n\t\tthrow new Error('routes.include must contain at least one route');\n\t}\n\n\tif (include?.length > 100) {\n\t\tthrow new Error('routes.include must contain 100 or fewer routes');\n\t}\n\n\t/** @type {Set<string>} */\n\tconst transformed_rules = new Set();\n\tfor (const rule of exclude) {\n\t\tif (rule === '<all>') {\n\t\t\ttransformed_rules.add('<build>');\n\t\t\ttransformed_rules.add('<files>');\n\t\t\ttransformed_rules.add('<prerendered>');\n\t\t\ttransformed_rules.add('<redirects>');\n\t\t} else {\n\t\t\ttransformed_rules.add(rule);\n\t\t}\n\t}\n\n\t/** @type {Set<string>} */\n\tconst excluded_routes = new Set();\n\tfor (const rule of transformed_rules) {\n\t\tif (rule === '<build>') {\n\t\t\tconst app_path = builder.getAppPath();\n\t\t\texcluded_routes.add(`/${app_path}/version.json`);\n\t\t\texcluded_routes.add(`/${app_path}/immutable/*`);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (rule === '<files>') {\n\t\t\tfor (const file of client_assets) {\n\t\t\t\tif (file.startsWith(`${builder.config.kit.appDir}/`)) continue;\n\t\t\t\texcluded_routes.add(`${builder.config.kit.paths.base}/${file}`);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (rule === '<prerendered>') {\n\t\t\tbuilder.prerendered.paths.forEach((path) => excluded_routes.add(path));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (rule === '<redirects>') {\n\t\t\tredirects.forEach((path) => excluded_routes.add(path));\n\t\t\tcontinue;\n\t\t}\n\n\t\texcluded_routes.add(rule);\n\t}\n\texclude = Array.from(excluded_routes);\n\n\tconst excess = include.length + exclude.length - 100;\n\tif (excess > 0) {\n\t\tbuilder.log.warn(\n\t\t\t`Cloudflare Pages Functions' includes/excludes exceeds _routes.json limits (see https://developers.cloudflare.com/pages/platform/functions/routing/#limits). Dropping ${excess} exclude rules — this will cause unnecessary function invocations.`\n\t\t);\n\t\texclude.length -= excess;\n\t}\n\n\treturn {\n\t\tversion: 1,\n\t\tdescription: 'Generated by @sveltejs/adapter-cloudflare',\n\t\tinclude,\n\t\texclude\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-cloudflare/utils.spec.js",
    "content": "import { describe, test, vi, expect } from 'vitest';\nimport {\n\tis_building_for_cloudflare_pages,\n\tvalidate_worker_settings,\n\tget_routes_json,\n\tparse_redirects\n} from './utils.js';\n\ndescribe('detects Cloudflare Pages project', () => {\n\ttest('by default', () => {\n\t\texpect(\n\t\t\tis_building_for_cloudflare_pages(/** @type {import('wrangler').Unstable_Config} */ ({}))\n\t\t).toBe(true);\n\t});\n\n\ttest('CF_PAGES environment variable', () => {\n\t\tvi.stubEnv('CF_PAGES', '1');\n\t\tconst result = is_building_for_cloudflare_pages(\n\t\t\t/** @type {import('wrangler').Unstable_Config} */ ({})\n\t\t);\n\t\tvi.unstubAllEnvs();\n\t\texpect(result).toBe(true);\n\t});\n\n\ttest('empty Wrangler configuration file', () => {\n\t\texpect(\n\t\t\tis_building_for_cloudflare_pages(\n\t\t\t\t/** @type {import('wrangler').Unstable_Config} */ ({\n\t\t\t\t\tconfigPath: 'wrangler.jsonc'\n\t\t\t\t})\n\t\t\t)\n\t\t).toBe(true);\n\t});\n\n\ttest('pages_build_output_dir config key', () => {\n\t\texpect(\n\t\t\tis_building_for_cloudflare_pages(\n\t\t\t\t/** @type {import('wrangler').Unstable_Config} */ ({\n\t\t\t\t\tconfigPath: 'wrangler.jsonc',\n\t\t\t\t\tpages_build_output_dir: 'dist'\n\t\t\t\t})\n\t\t\t)\n\t\t).toBe(true);\n\t});\n});\n\ndescribe('detects Cloudflare Workers project', () => {\n\ttest('main config key', () => {\n\t\texpect(\n\t\t\tis_building_for_cloudflare_pages(\n\t\t\t\t/** @type {import('wrangler').Unstable_Config} */ ({\n\t\t\t\t\tconfigPath: 'wrangler.jsonc',\n\t\t\t\t\tmain: 'dist/index.js'\n\t\t\t\t})\n\t\t\t)\n\t\t).toBe(false);\n\t});\n\n\ttest('assets config key', () => {\n\t\texpect(\n\t\t\tis_building_for_cloudflare_pages(\n\t\t\t\t/** @type {import('wrangler').Unstable_Config} */ ({\n\t\t\t\t\tconfigPath: 'wrangler.jsonc',\n\t\t\t\t\tassets: {\n\t\t\t\t\t\tdirectory: 'dist/assets'\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).toBe(false);\n\t});\n});\n\ndescribe('validates Wrangler config', () => {\n\ttest('Worker and static assets', () => {\n\t\texpect(() =>\n\t\t\tvalidate_worker_settings(\n\t\t\t\t/** @type {import('wrangler').Unstable_Config} */ ({\n\t\t\t\t\tconfigPath: 'wrangler.jsonc',\n\t\t\t\t\tmain: 'dist/index.js',\n\t\t\t\t\tassets: {\n\t\t\t\t\t\tdirectory: 'dist/assets',\n\t\t\t\t\t\tbinding: 'ASSETS'\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).not.toThrow();\n\t});\n\n\ttest('static assets only', () => {\n\t\texpect(() =>\n\t\t\tvalidate_worker_settings(\n\t\t\t\t/** @type {import('wrangler').Unstable_Config} */ ({\n\t\t\t\t\tconfigPath: 'wrangler.jsonc',\n\t\t\t\t\tassets: {\n\t\t\t\t\t\tdirectory: 'dist/assets'\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).not.toThrow();\n\t});\n\n\ttest('missing `assets.directory` key', () => {\n\t\texpect(() =>\n\t\t\tvalidate_worker_settings(\n\t\t\t\t/** @type {import('wrangler').Unstable_Config} */ ({\n\t\t\t\t\tconfigPath: 'wrangler.jsonc',\n\t\t\t\t\tmain: 'dist/index.js',\n\t\t\t\t\tassets: {\n\t\t\t\t\t\tbinding: 'ASSETS'\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).toThrow(\n\t\t\t`You must specify the \\`assets.directory\\` key in wrangler.jsonc. Consult https://developers.cloudflare.com/workers/static-assets/binding/#directory`\n\t\t);\n\t});\n\n\ttest('missing `assets.binding` key', () => {\n\t\texpect(() =>\n\t\t\tvalidate_worker_settings(\n\t\t\t\t/** @type {import('wrangler').Unstable_Config} */ ({\n\t\t\t\t\tconfigPath: 'wrangler.jsonc',\n\t\t\t\t\tmain: 'dist/index.js',\n\t\t\t\t\tassets: {\n\t\t\t\t\t\tdirectory: 'dist/assets'\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).toThrow(\n\t\t\t`You must specify the \\`assets.binding\\` key in wrangler.jsonc before deploying your Worker. Consult https://developers.cloudflare.com/workers/static-assets/binding/#binding`\n\t\t);\n\t});\n\n\ttest('missing `main` key or should remove `assets.binding` key', () => {\n\t\texpect(() =>\n\t\t\tvalidate_worker_settings(\n\t\t\t\t/** @type {import('wrangler').Unstable_Config} */ ({\n\t\t\t\t\tconfigPath: 'wrangler.jsonc',\n\t\t\t\t\tassets: {\n\t\t\t\t\t\tdirectory: 'dist/assets',\n\t\t\t\t\t\tbinding: 'ASSETS'\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).toThrow(\n\t\t\t`You must specify the \\`main\\` key in wrangler.jsonc if you want to deploy a Worker alongside your static assets. Otherwise, remove the \\`assets.binding\\` key if you only want to deploy static assets.`\n\t\t);\n\t});\n});\n\ntest('ignores comments in _redirects file', () => {\n\tconst redirects = parse_redirects(\n\t\t`\n# This is a comment\n/home301 / 301\n  # Indented comment\n/blog/* https://blog.my.domain/:splat\n`.trim()\n\t);\n\n\texpect(redirects).toEqual(['/home301', '/blog/*']);\n});\n\ntest('parses _redirects file', () => {\n\tconst redirects = parse_redirects(\n\t\t`\n/home301 / 301\n/notrailing/ /nottrailing 301\n\n/blog/* https://blog.my.domain/:splat\n`.trim()\n\t);\n\n\texpect(redirects).toEqual(['/home301', '/notrailing/', '/blog/*']);\n});\n\ntest('generates a _routes.json file', () => {\n\tconst routes = get_routes_json(\n\t\t{\n\t\t\tgetAppPath: () => 'base-path/_app',\n\t\t\tconfig: {\n\t\t\t\tkit: {\n\t\t\t\t\tappDir: '_app',\n\t\t\t\t\tpaths: {\n\t\t\t\t\t\tbase: '/base-path',\n\t\t\t\t\t\tassets: '',\n\t\t\t\t\t\trelative: true\n\t\t\t\t\t},\n\t\t\t\t\talias: {},\n\t\t\t\t\tcsrf: {\n\t\t\t\t\t\tcheckOrigin: true,\n\t\t\t\t\t\ttrustedOrigins: []\n\t\t\t\t\t},\n\t\t\t\t\tembedded: false,\n\t\t\t\t\tfiles: {\n\t\t\t\t\t\tsrc: 'src',\n\t\t\t\t\t\tassets: 'static',\n\t\t\t\t\t\thooks: {\n\t\t\t\t\t\t\tclient: 'src/hooks.client.js',\n\t\t\t\t\t\t\tserver: 'src/hooks.server.js',\n\t\t\t\t\t\t\tuniversal: 'src/hooks.js'\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlib: 'src/lib',\n\t\t\t\t\t\tparams: 'src/params',\n\t\t\t\t\t\troutes: 'src/routes',\n\t\t\t\t\t\tserviceWorker: 'src/service-worker.js',\n\t\t\t\t\t\tappTemplate: 'src/app.html',\n\t\t\t\t\t\terrorTemplate: 'src/error.html'\n\t\t\t\t\t},\n\t\t\t\t\tinlineStyleThreshold: 0,\n\t\t\t\t\tmoduleExtensions: ['.js', '.ts'],\n\t\t\t\t\tcsp: {\n\t\t\t\t\t\tmode: 'auto',\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tdirectives: {},\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\treportOnly: {}\n\t\t\t\t\t},\n\t\t\t\t\tenv: {\n\t\t\t\t\t\tdir: '.',\n\t\t\t\t\t\tpublicPrefix: 'PUBLIC_',\n\t\t\t\t\t\tprivatePrefix: ''\n\t\t\t\t\t},\n\t\t\t\t\toutDir: '.svelte-kit'\n\t\t\t\t}\n\t\t\t},\n\t\t\tprerendered: {\n\t\t\t\tpaths: ['/base-path/prerendered'],\n\t\t\t\tpages: new Map(),\n\t\t\t\tassets: new Map(),\n\t\t\t\tredirects: new Map()\n\t\t\t}\n\t\t},\n\t\t['_app/immutable/this-should-not-be-excluded.js', 'robots.txt'],\n\t\t['/base-path/redirect'],\n\t\tundefined\n\t);\n\n\texpect(routes).toEqual({\n\t\tversion: 1,\n\t\tdescription: 'Generated by @sveltejs/adapter-cloudflare',\n\t\tinclude: ['/*'],\n\t\texclude: [\n\t\t\t'/base-path/_app/version.json',\n\t\t\t'/base-path/_app/immutable/*',\n\t\t\t'/base-path/robots.txt',\n\t\t\t'/base-path/prerendered',\n\t\t\t'/base-path/redirect'\n\t\t]\n\t});\n});\n\ntest('truncates excess _routes.json exclude rules', () => {\n\tconst routes = get_routes_json(\n\t\t{\n\t\t\t// @ts-ignore\n\t\t\tlog: {\n\t\t\t\twarn: console.warn\n\t\t\t},\n\t\t\tgetAppPath: () => 'base-path/_app',\n\t\t\tconfig: {\n\t\t\t\tkit: {\n\t\t\t\t\tappDir: '_app',\n\t\t\t\t\tpaths: {\n\t\t\t\t\t\tbase: '/base-path',\n\t\t\t\t\t\tassets: '',\n\t\t\t\t\t\trelative: true\n\t\t\t\t\t},\n\t\t\t\t\talias: {},\n\t\t\t\t\tcsrf: {\n\t\t\t\t\t\tcheckOrigin: true,\n\t\t\t\t\t\ttrustedOrigins: []\n\t\t\t\t\t},\n\t\t\t\t\tembedded: false,\n\t\t\t\t\tfiles: {\n\t\t\t\t\t\tsrc: 'src',\n\t\t\t\t\t\tassets: 'static',\n\t\t\t\t\t\thooks: {\n\t\t\t\t\t\t\tclient: 'src/hooks.client.js',\n\t\t\t\t\t\t\tserver: 'src/hooks.server.js',\n\t\t\t\t\t\t\tuniversal: 'src/hooks.js'\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlib: 'src/lib',\n\t\t\t\t\t\tparams: 'src/params',\n\t\t\t\t\t\troutes: 'src/routes',\n\t\t\t\t\t\tserviceWorker: 'src/service-worker.js',\n\t\t\t\t\t\tappTemplate: 'src/app.html',\n\t\t\t\t\t\terrorTemplate: 'src/error.html'\n\t\t\t\t\t},\n\t\t\t\t\tinlineStyleThreshold: 0,\n\t\t\t\t\tmoduleExtensions: ['.js', '.ts'],\n\t\t\t\t\tcsp: {\n\t\t\t\t\t\tmode: 'auto',\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tdirectives: {},\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\treportOnly: {}\n\t\t\t\t\t},\n\t\t\t\t\tenv: {\n\t\t\t\t\t\tdir: '.',\n\t\t\t\t\t\tpublicPrefix: 'PUBLIC_',\n\t\t\t\t\t\tprivatePrefix: ''\n\t\t\t\t\t},\n\t\t\t\t\toutDir: '.svelte-kit'\n\t\t\t\t}\n\t\t\t},\n\t\t\tprerendered: {\n\t\t\t\tpaths: Array.from({ length: 100 }, (_, i) => `/base-path/blog/post/${i + 1}`),\n\t\t\t\tpages: new Map(),\n\t\t\t\tassets: new Map(),\n\t\t\t\tredirects: new Map()\n\t\t\t}\n\t\t},\n\t\t['_app/immutable/this-should-not-be-excluded.js', 'robots.txt'],\n\t\t[],\n\t\tundefined\n\t);\n\n\texpect(routes).toEqual({\n\t\tversion: 1,\n\t\tdescription: 'Generated by @sveltejs/adapter-cloudflare',\n\t\tinclude: ['/*'],\n\t\texclude: [\n\t\t\t'/base-path/_app/version.json',\n\t\t\t'/base-path/_app/immutable/*',\n\t\t\t'/base-path/robots.txt'\n\t\t].concat(Array.from({ length: 96 }, (_, i) => `/base-path/blog/post/${i + 1}`))\n\t});\n});\n"
  },
  {
    "path": "packages/adapter-netlify/.gitignore",
    "content": ".DS_Store\nnode_modules\n/files\n"
  },
  {
    "path": "packages/adapter-netlify/CHANGELOG.md",
    "content": "# @sveltejs/adapter-netlify\n\n## 6.0.4\n### Patch Changes\n\n\n- fix: generate a catch-all function that handles remote function requests and unknown routes when the app is configured to use split functions ([#15375](https://github.com/sveltejs/kit/pull/15375))\n\n## 6.0.3\n### Patch Changes\n\n\n- fix: correctly route requests to server load functions when the adapter is configured to used split functions ([#15367](https://github.com/sveltejs/kit/pull/15367))\n\n## 6.0.2\n### Patch Changes\n\n\n- fix: prefix param matcher with alphabetical characters so that it works with URLPattern matching ([#15332](https://github.com/sveltejs/kit/pull/15332))\n\n- Updated dependencies [[`3e607b3`](https://github.com/sveltejs/kit/commit/3e607b314aec9e5f278d32847945b8b6323e1cb8), [`62991c8`](https://github.com/sveltejs/kit/commit/62991c81db4f50ccfb08a9ac5e05ccba4ddab59e), [`f47c01b`](https://github.com/sveltejs/kit/commit/f47c01bd8100328c24fdb8522fe35913b0735f35)]:\n  - @sveltejs/kit@2.52.2\n\n## 6.0.1\n### Patch Changes\n\n\n- fix: export Netlify config directly from the instrumented serverless function ([#15335](https://github.com/sveltejs/kit/pull/15335))\n\n- Updated dependencies [[`e87efba`](https://github.com/sveltejs/kit/commit/e87efba90aeb04227e6a1a5e9017989e7f1c78dc), [`71ddbc7`](https://github.com/sveltejs/kit/commit/71ddbc7ff19a612cfcd483f3b7ba58586372528b), [`1bae374`](https://github.com/sveltejs/kit/commit/1bae374e2e106eb82502afd1ddf0167d66f224a1), [`20dfadf`](https://github.com/sveltejs/kit/commit/20dfadfbef312b4e750318aa871aebbfcb4396a4), [`8c2384a`](https://github.com/sveltejs/kit/commit/8c2384a346825d54eb4281f9da854388fb4d81b3)]:\n  - @sveltejs/kit@2.52.1\n\n## 6.0.0\n### Major Changes\n\n\n- breaking: `platform.context` is now the [modern Netlify Functions ([#15203](https://github.com/sveltejs/kit/pull/15203))\n  context](https://docs.netlify.com/build/functions/api/#netlify-specific-context-object)\n  \n  Previously, this was the [AWS Lambda-style\n  context](https://github.com/netlify/primitives/blob/c1ae30f2745f0a73e26e83334695e205a04ab47d/packages/functions/prod/src/function/handler_context.ts).\n  \n  If you were using this in your app (unlikely), you will need to update your code to read from new fields.\n\n### Minor Changes\n\n\n- feat: Migrate to the modern Netlify Functions API ([#15203](https://github.com/sveltejs/kit/pull/15203))\n  \n  The Netlify adapter now generates \"v2\" Netlify Functions, which uses modern standards (ESM, `Request`, `Response`) instead of the legacy \"Lambda-compatible\" or \"v1\" format. Under the hood, this greatly simplifies the adapter code and improves maintainability.\n  \n  For more details on features this unlocks for your SvelteKit app, see\n  https://developers.netlify.com/guides/migrating-to-the-modern-netlify-functions/.\n\n- feat: allow configuring redirects in `netlify.toml` ([#15203](https://github.com/sveltejs/kit/pull/15203))\n  \n  The limitation of only being able to configure redirects via the `_redirects` file has been removed.\n\n### Patch Changes\n\n\n- fix: populate `App.Platform` with `context` property ([#15203](https://github.com/sveltejs/kit/pull/15203))\n\n- Updated dependencies [[`37293a5`](https://github.com/sveltejs/kit/commit/37293a5c913b014e823bc823f2c8c6da38b88d6e), [`5d05ca6`](https://github.com/sveltejs/kit/commit/5d05ca6f606cf68417e4ed1ccb68cd77383f1f0f), [`ed69b77`](https://github.com/sveltejs/kit/commit/ed69b77cf9ef1af088008ff559f8de2e2a2f6bf4), [`b1fc959`](https://github.com/sveltejs/kit/commit/b1fc95966e0aeee689fdae71fa488c34b4806303), [`159aece`](https://github.com/sveltejs/kit/commit/159aece0654db020f95bc414f6a21f25fbc5f22f), [`c690579`](https://github.com/sveltejs/kit/commit/c690579620e131cd077ded0bc8e55090d3681d35), [`dc8cf2d`](https://github.com/sveltejs/kit/commit/dc8cf2defa71dd987437895eb89587c724f6e9bb), [`ace2116`](https://github.com/sveltejs/kit/commit/ace2116d95e13293dbc1e26b5b7d780202fd02dd), [`0f38f49`](https://github.com/sveltejs/kit/commit/0f38f498e0e7052db7b8cfe9ea892e7882a67b66)]:\n  - @sveltejs/kit@2.51.0\n\n## 5.2.4\n### Patch Changes\n\n\n- chore: update \"homepage\" field in package.json ([#14579](https://github.com/sveltejs/kit/pull/14579))\n\n## 5.2.3\n### Patch Changes\n\n\n- fix: improve the error message when `read(...)` fails from an edge function ([#14306](https://github.com/sveltejs/kit/pull/14306))\n\n## 5.2.2\n### Patch Changes\n\n\n- fix: include remote functions when deploying to Netlify edge functions ([#14214](https://github.com/sveltejs/kit/pull/14214))\n\n- Updated dependencies [[`c8f7ac3`](https://github.com/sveltejs/kit/commit/c8f7ac38e9ae1763e7880a29b7f7df01df964a6d), [`107f767`](https://github.com/sveltejs/kit/commit/107f767e3a1a54187527defb29dce753c4f5fa3f)]:\n  - @sveltejs/kit@2.33.1\n\n## 5.2.1\n### Patch Changes\n\n\n- fix: avoid erroring on builder properties that only exist on the latest version of SvelteKit ([#14233](https://github.com/sveltejs/kit/pull/14233))\n\n- Updated dependencies [[`f2db41c`](https://github.com/sveltejs/kit/commit/f2db41c0d3a0aefbb080ab6a9aa5822b3e41625c)]:\n  - @sveltejs/kit@2.31.1\n\n## 5.2.0\n### Minor Changes\n\n\n- feat: add `instrumentation.server.ts` for tracing and observability setup ([#13899](https://github.com/sveltejs/kit/pull/13899))\n\n\n### Patch Changes\n\n- Updated dependencies [[`f635678`](https://github.com/sveltejs/kit/commit/f63567812505597b1edc3e01010eca622b03b126), [`f635678`](https://github.com/sveltejs/kit/commit/f63567812505597b1edc3e01010eca622b03b126)]:\n  - @sveltejs/kit@2.31.0\n\n## 5.1.1\n### Patch Changes\n\n\n- chore: add `.git` to the end of `package.json` repository url ([#14134](https://github.com/sveltejs/kit/pull/14134))\n\n- Updated dependencies [[`c968aef`](https://github.com/sveltejs/kit/commit/c968aef5727f978244d5160657b4a7ac651384ae)]:\n  - @sveltejs/kit@2.27.3\n\n## 5.1.0\n### Minor Changes\n\n\n- feat: add support for `read` imported from `$app/server` in edge functions ([#13859](https://github.com/sveltejs/kit/pull/13859))\n\n\n### Patch Changes\n\n- Updated dependencies [[`e5ce8bb`](https://github.com/sveltejs/kit/commit/e5ce8bb42ea020b88bd0a4ff18dc600745657541), [`cf88369`](https://github.com/sveltejs/kit/commit/cf883692fa0e163cff6b1a2f9b17a568af14124d)]:\n  - @sveltejs/kit@2.25.0\n\n## 5.0.2\n### Patch Changes\n\n\n- chore(deps): upgrade to esbuild 0.25.4 ([#13770](https://github.com/sveltejs/kit/pull/13770))\n\n## 5.0.1\n### Patch Changes\n\n\n- chore(deps): upgrade esbuild to 0.25.2 ([#13716](https://github.com/sveltejs/kit/pull/13716))\n\n- Updated dependencies [[`c51fb554416e0c4a21655c1d79e834f69743d1d5`](https://github.com/sveltejs/kit/commit/c51fb554416e0c4a21655c1d79e834f69743d1d5)]:\n  - @sveltejs/kit@2.20.8\n\n## 5.0.0\n### Major Changes\n\n\n- fix: error if the `_headers` and `_redirects` files are in the `/static` directory instead of the project root ([#13227](https://github.com/sveltejs/kit/pull/13227))\n\n## 4.4.2\n### Patch Changes\n\n\n- fix: correctly import manifest on Windows machines ([#13495](https://github.com/sveltejs/kit/pull/13495))\n\n- Updated dependencies [[`28cf64589a331ea4770c0883216c5e16d1de7496`](https://github.com/sveltejs/kit/commit/28cf64589a331ea4770c0883216c5e16d1de7496), [`ef1e8047225e7a79c6d121d8ed1a571e5ea44f08`](https://github.com/sveltejs/kit/commit/ef1e8047225e7a79c6d121d8ed1a571e5ea44f08), [`2e6527b92875976b79cc00e7b75ee0ad8b69a239`](https://github.com/sveltejs/kit/commit/2e6527b92875976b79cc00e7b75ee0ad8b69a239), [`0c0172e1463218fe63a67c587173bb3065a53c49`](https://github.com/sveltejs/kit/commit/0c0172e1463218fe63a67c587173bb3065a53c49)]:\n  - @sveltejs/kit@2.17.3\n\n## 4.4.1\n### Patch Changes\n\n\n- fix: avoid unnecessary Netlify edge function invocations for static files, which resolves a conflict between Netlify Edge Functions and Netlify Identity ([#12052](https://github.com/sveltejs/kit/pull/12052))\n\n## 4.4.0\n### Minor Changes\n\n\n- chore: upgrade esbuild to 0.24.0 ([#12270](https://github.com/sveltejs/kit/pull/12270))\n\n\n### Patch Changes\n\n- Updated dependencies [[`d030f4bb285e70844d09b3f0c87809bae43014b8`](https://github.com/sveltejs/kit/commit/d030f4bb285e70844d09b3f0c87809bae43014b8), [`67dd214863cbc5852eb0e8512efbb7bad5358e8a`](https://github.com/sveltejs/kit/commit/67dd214863cbc5852eb0e8512efbb7bad5358e8a)]:\n  - @sveltejs/kit@2.9.0\n\n## 4.3.6\n### Patch Changes\n\n\n- docs: update URLs for new svelte.dev site ([#12857](https://github.com/sveltejs/kit/pull/12857))\n\n- Updated dependencies [[`dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46`](https://github.com/sveltejs/kit/commit/dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46), [`4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d`](https://github.com/sveltejs/kit/commit/4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d), [`3a9b78f04786898ca93f6d4b75ab18d26bc45192`](https://github.com/sveltejs/kit/commit/3a9b78f04786898ca93f6d4b75ab18d26bc45192), [`723eb8b31e6a22c82f730c30e485386c8676b746`](https://github.com/sveltejs/kit/commit/723eb8b31e6a22c82f730c30e485386c8676b746), [`8ec471c875345b751344e67580ff1b772ef2735b`](https://github.com/sveltejs/kit/commit/8ec471c875345b751344e67580ff1b772ef2735b)]:\n  - @sveltejs/kit@2.7.3\n\n## 4.3.5\n### Patch Changes\n\n\n- fix: correctly handle relative paths when fetching assets on the server ([#12113](https://github.com/sveltejs/kit/pull/12113))\n\n- Updated dependencies [[`df48fc6ede3859beabaae9fd7c6f722215bb8a42`](https://github.com/sveltejs/kit/commit/df48fc6ede3859beabaae9fd7c6f722215bb8a42), [`5780deba8e3ebd0e2b0abea029068ad0c6daf6ad`](https://github.com/sveltejs/kit/commit/5780deba8e3ebd0e2b0abea029068ad0c6daf6ad), [`6f9aefdb8699fc126d76a88471602cb9a80822eb`](https://github.com/sveltejs/kit/commit/6f9aefdb8699fc126d76a88471602cb9a80822eb), [`8aa95b4b3431e79f62f580abdcdcb157b4de86cd`](https://github.com/sveltejs/kit/commit/8aa95b4b3431e79f62f580abdcdcb157b4de86cd)]:\n  - @sveltejs/kit@2.7.0\n\n## 4.3.4\n### Patch Changes\n\n\n- fix: import `node:process` instead of using globals ([#12641](https://github.com/sveltejs/kit/pull/12641))\n\n- Updated dependencies [[`e798ef718f163bed4f93e1918bd8294f765376ad`](https://github.com/sveltejs/kit/commit/e798ef718f163bed4f93e1918bd8294f765376ad)]:\n  - @sveltejs/kit@2.5.28\n\n## 4.3.3\n### Patch Changes\n\n\n- chore: configure provenance in a simpler manner ([#12570](https://github.com/sveltejs/kit/pull/12570))\n\n- Updated dependencies [[`087a43d391fc38b8c008fb39a804dc6988974101`](https://github.com/sveltejs/kit/commit/087a43d391fc38b8c008fb39a804dc6988974101)]:\n  - @sveltejs/kit@2.5.22\n\n## 4.3.2\n### Patch Changes\n\n\n- chore: package provenance ([#12567](https://github.com/sveltejs/kit/pull/12567))\n\n- Updated dependencies [[`4930a8443caa53bcecee7b690cd28e429b1c8a20`](https://github.com/sveltejs/kit/commit/4930a8443caa53bcecee7b690cd28e429b1c8a20)]:\n  - @sveltejs/kit@2.5.21\n\n## 4.3.1\n### Patch Changes\n\n\n- fix: copy `.eot`, `.otf`, `.ttf`, `.woff`, and `woff2` font files when bundling ([#12439](https://github.com/sveltejs/kit/pull/12439))\n\n## 4.3.0\n### Minor Changes\n\n\n- chore(deps): upgrade to esbuild 0.21 ([#12415](https://github.com/sveltejs/kit/pull/12415))\n\n\n### Patch Changes\n\n- Updated dependencies [[`84298477a014ec471839adf7a4448d91bc7949e4`](https://github.com/sveltejs/kit/commit/84298477a014ec471839adf7a4448d91bc7949e4), [`5645614f497931f587b7cb8b3c885fce892a6a72`](https://github.com/sveltejs/kit/commit/5645614f497931f587b7cb8b3c885fce892a6a72), [`84298477a014ec471839adf7a4448d91bc7949e4`](https://github.com/sveltejs/kit/commit/84298477a014ec471839adf7a4448d91bc7949e4)]:\n  - @sveltejs/kit@2.5.18\n\n## 4.2.1\n\n### Patch Changes\n\n- chore: update to @rollup/plugin-commonjs@26 ([#12326](https://github.com/sveltejs/kit/pull/12326))\n\n- chore: add keywords for discovery in npm search ([#12330](https://github.com/sveltejs/kit/pull/12330))\n\n- Updated dependencies [[`25acb1d9fce998dccd8050b93cf4142c2b082611`](https://github.com/sveltejs/kit/commit/25acb1d9fce998dccd8050b93cf4142c2b082611), [`642c4a4aff4351b786fe6274aa2f0bf7d905faf9`](https://github.com/sveltejs/kit/commit/642c4a4aff4351b786fe6274aa2f0bf7d905faf9), [`0a0e9aa897123ebec50af08e9385b2ca4fc5bb28`](https://github.com/sveltejs/kit/commit/0a0e9aa897123ebec50af08e9385b2ca4fc5bb28)]:\n  - @sveltejs/kit@2.5.11\n\n## 4.2.0\n\n### Minor Changes\n\n- chore(deps): upgrade esbuild ([#12118](https://github.com/sveltejs/kit/pull/12118))\n\n### Patch Changes\n\n- Updated dependencies [[`bbab296f6fcc05af6b999182798bcdedabbaa4c9`](https://github.com/sveltejs/kit/commit/bbab296f6fcc05af6b999182798bcdedabbaa4c9)]:\n  - @sveltejs/kit@2.5.6\n\n## 4.1.0\n\n### Minor Changes\n\n- feat: allow Node.js built-in modules when targeting edge functions ([#11675](https://github.com/sveltejs/kit/pull/11675))\n\n### Patch Changes\n\n- Updated dependencies [[`36dc54ac740b8b4c6a2b904a1d0aadd8923a875c`](https://github.com/sveltejs/kit/commit/36dc54ac740b8b4c6a2b904a1d0aadd8923a875c), [`5dae3676b8cc6f8ee0def57340e6a6e591bafecd`](https://github.com/sveltejs/kit/commit/5dae3676b8cc6f8ee0def57340e6a6e591bafecd), [`ada595908b5501b8f4ac30c89c0d6314f364fde3`](https://github.com/sveltejs/kit/commit/ada595908b5501b8f4ac30c89c0d6314f364fde3), [`e228f8997840b89c6248e1c5df6f3108008a06be`](https://github.com/sveltejs/kit/commit/e228f8997840b89c6248e1c5df6f3108008a06be)]:\n  - @sveltejs/kit@2.4.1\n\n## 4.0.0\n\n### Major Changes\n\n- breaking: update peer dependency on `@sveltejs/kit` ([#11649](https://github.com/sveltejs/kit/pull/11649))\n\n### Minor Changes\n\n- feat: support `read` from `$app/server` ([#11649](https://github.com/sveltejs/kit/pull/11649))\n\n### Patch Changes\n\n- Updated dependencies [[`288f731c8a5b20cadb9e219f9583f3f16bf8c7b8`](https://github.com/sveltejs/kit/commit/288f731c8a5b20cadb9e219f9583f3f16bf8c7b8)]:\n  - @sveltejs/kit@2.4.0\n\n## 3.0.2\n\n### Patch Changes\n\n- chore: upgrade esbuild to 0.19.11 ([#11632](https://github.com/sveltejs/kit/pull/11632))\n\n## 3.0.1\n\n### Patch Changes\n\n- chore: update primary branch from master to main ([`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d))\n\n- Updated dependencies [[`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d), [`16961e8cd3fa6a7f382153b1ff056bc2aae9b31b`](https://github.com/sveltejs/kit/commit/16961e8cd3fa6a7f382153b1ff056bc2aae9b31b), [`197e01f95652f511160f38b37b9da73a124ecd48`](https://github.com/sveltejs/kit/commit/197e01f95652f511160f38b37b9da73a124ecd48), [`102e4a5ae5b29624302163faf5a20c94a64a5b2c`](https://github.com/sveltejs/kit/commit/102e4a5ae5b29624302163faf5a20c94a64a5b2c), [`f8e3d8b9728c9f1ab63389342c31d7246b6f9db6`](https://github.com/sveltejs/kit/commit/f8e3d8b9728c9f1ab63389342c31d7246b6f9db6)]:\n  - @sveltejs/kit@2.0.4\n\n## 3.0.0\n\n### Major Changes\n\n- breaking: require SvelteKit 2 ([#11316](https://github.com/sveltejs/kit/pull/11316))\n\n- chore: upgrade esbuild ([#11122](https://github.com/sveltejs/kit/pull/11122))\n\n## 2.0.8\n\n### Patch Changes\n\n- chore: upgrade to esbuild 0.18.11 ([#10330](https://github.com/sveltejs/kit/pull/10330))\n\n- Updated dependencies [[`23d1df702`](https://github.com/sveltejs/kit/commit/23d1df702f0fd77983040404352d8d83fd1dd8a1), [`486a971fe`](https://github.com/sveltejs/kit/commit/486a971fe7c375aae1585f1fa2505e28f86f4b8e)]:\n  - @sveltejs/kit@1.22.2\n\n## 2.0.7\n\n### Patch Changes\n\n- chore: update all dependencies with minor version bumps ([#9761](https://github.com/sveltejs/kit/pull/9761))\n\n## 2.0.6\n\n### Patch Changes\n\n- docs: remove comment discourage direct use of adapters ([#9344](https://github.com/sveltejs/kit/pull/9344))\n\n- Updated dependencies [[`b575287d`](https://github.com/sveltejs/kit/commit/b575287d063562868d7726f6451352aa43a63453), [`8114c658`](https://github.com/sveltejs/kit/commit/8114c658c0bc053198ff76704c002cfeb8225e2a), [`620f5605`](https://github.com/sveltejs/kit/commit/620f56058de0993e776c146db4c19fca97b9cb39), [`6a91e887`](https://github.com/sveltejs/kit/commit/6a91e887ee4c1bef8aabfafbf1ab6079113c2832), [`1c32723a`](https://github.com/sveltejs/kit/commit/1c32723a52beca0c5aa895b1114341da78d92eaf), [`0f863bbc`](https://github.com/sveltejs/kit/commit/0f863bbc957ab2ed37b04ebd839fc864b945034d), [`78b4a1bb`](https://github.com/sveltejs/kit/commit/78b4a1bb5e1ae11a894d70a0a28cc344ea0b1284), [`66b2f4ef`](https://github.com/sveltejs/kit/commit/66b2f4ef03a5dd60da2757edde4effcfdf3183cf), [`5dada256`](https://github.com/sveltejs/kit/commit/5dada256dc05674a18946f8f19db1f25ba91aeaf), [`a71b5e69`](https://github.com/sveltejs/kit/commit/a71b5e69ef37ce46e8e8590d537036cb7e267d51), [`daad7e48`](https://github.com/sveltejs/kit/commit/daad7e48b175245cbb7efd0e255263bfb52a5ee6), [`18d330b1`](https://github.com/sveltejs/kit/commit/18d330b16330d76c4b2991839c6b4462d5a4163f), [`18d7e81a`](https://github.com/sveltejs/kit/commit/18d7e81a9892e718c3cd07b2366a60f2e09561ab)]:\n  - @sveltejs/kit@1.11.0\n\n## 2.0.5\n\n### Patch Changes\n\n- chore: support newest version of undici ([#9005](https://github.com/sveltejs/kit/pull/9005))\n\n- Updated dependencies [[`6cdf54d1`](https://github.com/sveltejs/kit/commit/6cdf54d1f3561348d87f35ddc8330081919eb839)]:\n  - @sveltejs/kit@1.7.1\n\n## 2.0.4\n\n### Patch Changes\n\n- fix: Root route data endpoint redirect when using split routes ([#9006](https://github.com/sveltejs/kit/pull/9006))\n\n- Updated dependencies [[`74cfa8d5`](https://github.com/sveltejs/kit/commit/74cfa8d5f1f13f81759e20e90f4ff86a4f96040d), [`bfa2b6ec`](https://github.com/sveltejs/kit/commit/bfa2b6ec88a6d522d87c924d7c466c01e142e66e)]:\n  - @sveltejs/kit@1.5.6\n\n## 2.0.3\n\n### Patch Changes\n\n- chore: simplify functions-internal cleanup ([#8953](https://github.com/sveltejs/kit/pull/8953))\n\n- fix: correctly compare routes when generating split functions ([#8952](https://github.com/sveltejs/kit/pull/8952))\n\n- Updated dependencies [[`0abb8ebf`](https://github.com/sveltejs/kit/commit/0abb8ebffc6121f81c2bbfa0a0f68866d4cc1627), [`bef54f63`](https://github.com/sveltejs/kit/commit/bef54f63d2315066d30e8f1bcf471ddf2bd72c35), [`51cd6e64`](https://github.com/sveltejs/kit/commit/51cd6e643178e3a113fc2c3e8a63755bcbfe902d), [`930c8e4e`](https://github.com/sveltejs/kit/commit/930c8e4ee2e3046ed1b622777dafa23029a19fe5), [`ee8066fc`](https://github.com/sveltejs/kit/commit/ee8066fcb29ed1e7e3ab513cabb7997e38c984f2), [`49d2ec62`](https://github.com/sveltejs/kit/commit/49d2ec62e6385694f11701bf2fa411d07449344c), [`eb943565`](https://github.com/sveltejs/kit/commit/eb943565a4324dbed3da5a581924ca91a24366de)]:\n  - @sveltejs/kit@1.5.3\n\n## 2.0.2\n\n### Patch Changes\n\n- fix: preserve functions-internal folder so that auto-generated functions are not removed when ntl build is run ([#8899](https://github.com/sveltejs/kit/pull/8899))\n\n- Updated dependencies [[`1960296d`](https://github.com/sveltejs/kit/commit/1960296da62fdd4ad8e8bb7286940b98fbe8db0f), [`1beb19cb`](https://github.com/sveltejs/kit/commit/1beb19cb487bd6d719048f0feedcb2fbee91a005), [`b915dfe9`](https://github.com/sveltejs/kit/commit/b915dfe9d16a930246a469c9aea8c1a84e5157ba), [`a402d50b`](https://github.com/sveltejs/kit/commit/a402d50b33eba2a937d09e635275c319061ce678)]:\n  - @sveltejs/kit@1.5.1\n\n## 2.0.1\n\n### Patch Changes\n\n- chore: throw helpful migration error ([#8915](https://github.com/sveltejs/kit/pull/8915))\n\n## 2.0.0\n\n### Major Changes\n\n- breaking: bump `@sveltejs/kit` peer dependency ([#8740](https://github.com/sveltejs/kit/pull/8740))\n\n### Patch Changes\n\n- Updated dependencies [[`c7648f66`](https://github.com/sveltejs/kit/commit/c7648f6608a413e2654625cbd30f890d2148cf13), [`63613bf1`](https://github.com/sveltejs/kit/commit/63613bf194c18ce50e111585ad770fc93f9e43c7), [`d1f7655e`](https://github.com/sveltejs/kit/commit/d1f7655efdff70d91f94fe0cb0de50ed2511b5e5)]:\n  - @sveltejs/kit@1.5.0\n\n## 1.0.5\n\n### Patch Changes\n\n- chore: update link to docs for missing netlify.toml warning ([#8673](https://github.com/sveltejs/kit/pull/8673))\n\n- Updated dependencies [[`24d2efe4`](https://github.com/sveltejs/kit/commit/24d2efe4e5b641b9caacf21ba77a42f812b3b120)]:\n  - @sveltejs/kit@1.2.4\n\n## 1.0.4\n\n### Patch Changes\n\n- docs: move adapter docs to site ([#8531](https://github.com/sveltejs/kit/pull/8531))\n\n## 1.0.3\n\n### Patch Changes\n\n- fix: publish missing files ([#8532](https://github.com/sveltejs/kit/pull/8532))\n\n## 1.0.2\n\n### Patch Changes\n\n- chore: remove superfluous main field from package.json ([#8519](https://github.com/sveltejs/kit/pull/8519))\n\n- Updated dependencies [[`7e2d3405`](https://github.com/sveltejs/kit/commit/7e2d34056e99f371e22406d941b764df365a2649)]:\n  - @sveltejs/kit@1.1.1\n\n## 1.0.1\n\n### Patch Changes\n\n- docs: add note about inability to access file system at runtime ([#8441](https://github.com/sveltejs/kit/pull/8441))\n\n- Updated dependencies [[`9c01c32e`](https://github.com/sveltejs/kit/commit/9c01c32ef72bbed630fadcb8283f8f8533ced5e1), [`b6ca02a6`](https://github.com/sveltejs/kit/commit/b6ca02a684dbf13a3138b552e2d2be64697f2254), [`130abe43`](https://github.com/sveltejs/kit/commit/130abe43cef2cfbaf922aa16b20cbd4332a07c15), [`c4137536`](https://github.com/sveltejs/kit/commit/c4137536f2c6572eaeec1a82ccea0852f5be6b98), [`40464efa`](https://github.com/sveltejs/kit/commit/40464efab172a17f0b637d7dadea30d77ef1ed10), [`ce028470`](https://github.com/sveltejs/kit/commit/ce0284708184198efdd30f3ff72fd579cef830b4)]:\n  - @sveltejs/kit@1.0.12\n\n## 1.0.0\n\n### Major Changes\n\nFirst major release, see below for the history of changes that lead up to this.\nStarting from now all releases follow semver and changes will be listed as Major/Minor/Patch\n\n## 1.0.0-next.88\n\n### Patch Changes\n\n- chore: add peerDependencies, add more specific next version ([#8141](https://github.com/sveltejs/kit/pull/8141))\n\n## 1.0.0-next.87\n\n### Patch Changes\n\n- fix: revert platform change from browser to neutral ([#8122](https://github.com/sveltejs/kit/pull/8122))\n\n## 1.0.0-next.86\n\n### Patch Changes\n\n- fix: set esbuild platform to neutral ([#8083](https://github.com/sveltejs/kit/pull/8083))\n\n## 1.0.0-next.85\n\n### Patch Changes\n\n- update esbuild to ^0.16.3 ([#7543](https://github.com/sveltejs/kit/pull/7543))\n\n## 1.0.0-next.84\n\n### Patch Changes\n\n- Add information about edge functions and `event.platform` ([#7498](https://github.com/sveltejs/kit/pull/7498))\n\n## 1.0.0-next.83\n\n### Patch Changes\n\n- update dependencies ([#7355](https://github.com/sveltejs/kit/pull/7355))\n\n## 1.0.0-next.82\n\n### Patch Changes\n\n- Drop CJS version of adapter-netlify ([#7401](https://github.com/sveltejs/kit/pull/7401))\n\n## 1.0.0-next.81\n\n### Patch Changes\n\n- Use config.kit.paths.base prefix for static assets ([#4448](https://github.com/sveltejs/kit/pull/4448))\n\n## 1.0.0-next.80\n\n### Patch Changes\n\n- Transfer server data as devalue-encoded JSON ([#7177](https://github.com/sveltejs/kit/pull/7177))\n\n## 1.0.0-next.79\n\n### Patch Changes\n\n- fix: clear out build directory when running `adapter-netlify` ([#7159](https://github.com/sveltejs/kit/pull/7159))\n\n## 1.0.0-next.78\n\n### Patch Changes\n\n- chore: bump esbuild ([#6829](https://github.com/sveltejs/kit/pull/6829))\n\n## 1.0.0-next.77\n\n### Patch Changes\n\n- Update to esbuild 0.15 ([#6740](https://github.com/sveltejs/kit/pull/6740))\n- feat: only generate ESM functions ([#6760](https://github.com/sveltejs/kit/pull/6760))\n\n## 1.0.0-next.76\n\n### Patch Changes\n\n- Update adapter to only glob files ([#6492](https://github.com/sveltejs/kit/pull/6492))\n\n## 1.0.0-next.75\n\n### Patch Changes\n\n- Use devalue to serialize server-only `load` return values ([#6318](https://github.com/sveltejs/kit/pull/6318))\n\n## 1.0.0-next.74\n\n### Patch Changes\n\n- Don't use top-level-await, as it is not supported right now ([#6360](https://github.com/sveltejs/kit/pull/6360))\n\n## 1.0.0-next.73\n\n### Patch Changes\n\n- Run `server.init()` for edge functions ([#6327](https://github.com/sveltejs/kit/pull/6327))\n\n## 1.0.0-next.72\n\n### Patch Changes\n\n- feat: Moved hooks.js initialization from Server.respond into Server.init ([#6179](https://github.com/sveltejs/kit/pull/6179))\n\n## 1.0.0-next.71\n\n### Patch Changes\n\n- Initialise `env` ([#5663](https://github.com/sveltejs/kit/pull/5663))\n\n## 1.0.0-next.70\n\n### Patch Changes\n\n- breaking: remove writeStatic to align with Vite ([#5618](https://github.com/sveltejs/kit/pull/5618))\n\n## 1.0.0-next.69\n\n### Patch Changes\n\n- Update dependencies ([#5005](https://github.com/sveltejs/kit/pull/5005))\n\n## 1.0.0-next.68\n\n### Patch Changes\n\n- feat: get client IP from Context object rather than the request header ([#5473](https://github.com/sveltejs/kit/pull/5473))\n\n## 1.0.0-next.67\n\n### Patch Changes\n\n- chore: upgrade TypeScript to 4.7.4 ([#5414](https://github.com/sveltejs/kit/pull/5414))\n\n## 1.0.0-next.66\n\n### Patch Changes\n\n- Generate sourcemaps for server-side functions when bundling with esbuild ([#5258](https://github.com/sveltejs/kit/pull/5258))\n\n## 1.0.0-next.65\n\n### Patch Changes\n\n- fix: add redirects for routes containing `__data.json` suffix ([#5180](https://github.com/sveltejs/kit/pull/5180))\n\n## 1.0.0-next.64\n\n### Patch Changes\n\n- Update dependencies ([#5121](https://github.com/sveltejs/kit/pull/5121))\n\n## 1.0.0-next.63\n\n### Patch Changes\n\n- Update adapter entrypoint typings to be NodeNext/ESNext-compatible ([#5111](https://github.com/sveltejs/kit/pull/5111))\n\n## 1.0.0-next.62\n\n### Patch Changes\n\n- only serve `_app/immutable` with immutable cache header, not `_app/version.json` ([#5051](https://github.com/sveltejs/kit/pull/5051))\n\n## 1.0.0-next.61\n\n### Patch Changes\n\n- Add types to pkg.exports ([#5045](https://github.com/sveltejs/kit/pull/5045))\n\n## 1.0.0-next.60\n\n### Patch Changes\n\n- Encode binary responses as base64 ([#5048](https://github.com/sveltejs/kit/pull/5048))\n\n## 1.0.0-next.59\n\n### Patch Changes\n\n- breaking: replace @sveltejs/kit/install-fetch with @sveltejs/kit/node/polyfills ([#4934](https://github.com/sveltejs/kit/pull/4934))\n\n## 1.0.0-next.58\n\n### Patch Changes\n\n- docs: explain how to change node version ([#4921](https://github.com/sveltejs/kit/pull/4921))\n\n## 1.0.0-next.57\n\n### Patch Changes\n\n- Copy existing `_redirects` file before appending function redirects ([#4890](https://github.com/sveltejs/kit/pull/4890))\n\n## 1.0.0-next.56\n\n### Patch Changes\n\n- breaking: Remove try-catch around server.respond ([#4738](https://github.com/sveltejs/kit/pull/4738))\n\n## 1.0.0-next.55\n\n### Patch Changes\n\n- Fix adapter-netlify edge functions ([#4702](https://github.com/sveltejs/kit/pull/4702))\n\n## 1.0.0-next.54\n\n### Patch Changes\n\n- Ensure tmp dir is created ([#4694](https://github.com/sveltejs/kit/pull/4694))\n\n## 1.0.0-next.53\n\n### Patch Changes\n\n- Ensure build directory exists before writing \\_redirects ([#4676](https://github.com/sveltejs/kit/pull/4676))\n\n## 1.0.0-next.52\n\n### Patch Changes\n\n- Adds support for Netlify Edge Functions ([#4657](https://github.com/sveltejs/kit/pull/4657))\n\n## 1.0.0-next.51\n\n### Patch Changes\n\n- Provide getClientAddress function ([#4289](https://github.com/sveltejs/kit/pull/4289))\n\n## 1.0.0-next.50\n\n### Patch Changes\n\n- breaking: replace builder.prerender() with builder.writePrerendered() and builder.prerendered ([#4192](https://github.com/sveltejs/kit/pull/4192)) ([#4229](https://github.com/sveltejs/kit/pull/4229))\n\n## 1.0.0-next.49\n\n### Patch Changes\n\n- Add Netlify Functions context as `event.platform.context` ([#4145](https://github.com/sveltejs/kit/pull/4145))\n\n## 1.0.0-next.48\n\n### Patch Changes\n\n- Rename `__fetch_polyfill` to `installFetch` ([#4111](https://github.com/sveltejs/kit/pull/4111))\n\n## 1.0.0-next.47\n\n### Patch Changes\n\n- Fix incorrect set-cookie header handling on adapter-netlify ([#4096](https://github.com/sveltejs/kit/pull/4096))\n\n## 1.0.0-next.46\n\n### Patch Changes\n\n- breaking: rename `app.render` to `server.respond` ([#4034](https://github.com/sveltejs/kit/pull/4034))\n\n## 1.0.0-next.45\n\n### Patch Changes\n\n- update to Vite 2.8 and esbuild 0.14 ([#3791](https://github.com/sveltejs/kit/pull/3791))\n\n## 1.0.0-next.44\n\n### Patch Changes\n\n- Fix string replacement in CJS builds ([#3546](https://github.com/sveltejs/kit/pull/3546))\n\n## 1.0.0-next.43\n\n### Patch Changes\n\n- Bump version to trigger rebuild with set-cookie support ([#3529](https://github.com/sveltejs/kit/pull/3529))\n\n## 1.0.0-next.42\n\n### Patch Changes\n\n- Avoid setting the body of the request when the request method is GET or HEAD ([#3459](https://github.com/sveltejs/kit/pull/3459))\n\n## 1.0.0-next.41\n\n### Patch Changes\n\n- Breaking: change app.render signature to (request: Request) => Promise<Response> ([#3384](https://github.com/sveltejs/kit/pull/3384))\n\n## 1.0.0-next.40\n\n### Patch Changes\n\n- Polyfill fetch before running any app code ([#3400](https://github.com/sveltejs/kit/pull/3400))\n\n## 1.0.0-next.39\n\n### Patch Changes\n\n- Allow `__fetchPolyfill()` to run several times ([#3377](https://github.com/sveltejs/kit/pull/3377))\n\n## 1.0.0-next.38\n\n### Patch Changes\n\n- Add immutable cache headers to generated assets ([#3222](https://github.com/sveltejs/kit/pull/3222))\n\n## 1.0.0-next.37\n\n### Patch Changes\n\n- Overhaul adapter API ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- Update adapters to provide app.render with a url ([#3133](https://github.com/sveltejs/kit/pull/3133))\n- Add experimental function splitting ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- Don't bundle final output ([#2931](https://github.com/sveltejs/kit/pull/2931))\n\n## 1.0.0-next.36\n\n### Patch Changes\n\n- update to esbuild 0.13.15 and other dependency updates ([#2957](https://github.com/sveltejs/kit/pull/2957))\n\n## 1.0.0-next.35\n\n### Patch Changes\n\n- fix: adapter-netlify: handle undefined body ([#2682](https://github.com/sveltejs/kit/pull/2682))\n\n## 1.0.0-next.34\n\n### Patch Changes\n\n- fix: encode UInt8Array response bodies as base64 ([#2630](https://github.com/sveltejs/kit/pull/2630))\n\n## 1.0.0-next.33\n\n### Patch Changes\n\n- update dependencies ([#2574](https://github.com/sveltejs/kit/pull/2574))\n\n## 1.0.0-next.32\n\n### Patch Changes\n\n- update to vite 2.6.0 and esbuild 0.13 ([#2522](https://github.com/sveltejs/kit/pull/2522))\n\n## 1.0.0-next.31\n\n### Patch Changes\n\n- chore: add links to repository and homepage to package.json ([#2425](https://github.com/sveltejs/kit/pull/2425))\n\n## 1.0.0-next.30\n\n### Patch Changes\n\n- chore: export package.json from adapters ([#2351](https://github.com/sveltejs/kit/pull/2351))\n\n## 1.0.0-next.29\n\n### Patch Changes\n\n- Deploy generated Netlify entrypoint to the internal functions directory. This allows it to co-exist with other Netlify functions. ([#2113](https://github.com/sveltejs/kit/pull/2113))\n\n## 1.0.0-next.28\n\n### Patch Changes\n\n- Ensure the raw body is an Uint8Array before passing it to request handlers ([#2215](https://github.com/sveltejs/kit/pull/2215))\n\n## 1.0.0-next.27\n\n### Patch Changes\n\n- 94b34fa6: [breaking] standardize final output dir as /build (vs /.svelte-kit) ([#2109](https://github.com/sveltejs/kit/pull/2109))\n\n## 1.0.0-next.26\n\n### Patch Changes\n\n- 4cb4e749: update build output locations ([#2058](https://github.com/sveltejs/kit/pull/2058))\n- d81de603: revert adapters automatically updating .gitignore ([#1924](https://github.com/sveltejs/kit/pull/1924))\n\n## 1.0.0-next.25\n\n### Patch Changes\n\n- e9f78999: fix: include esbuild config in adapter type definition ([#1954](https://github.com/sveltejs/kit/pull/1954))\n\n## 1.0.0-next.24\n\n### Patch Changes\n\n- e6995797: feat(adapters): expose esbuild configuration ([#1914](https://github.com/sveltejs/kit/pull/1914))\n\n## 1.0.0-next.23\n\n### Patch Changes\n\n- 67ca3a39: return the correct headers ([#1913](https://github.com/sveltejs/kit/pull/1913))\n\n## 1.0.0-next.22\n\n### Patch Changes\n\n- 9461178: Use multivalue headers to set multiple cookies ([#1906](https://github.com/sveltejs/kit/pull/1906))\n\n## 1.0.0-next.21\n\n### Patch Changes\n\n- 4720b67: Default body parsing to binary ([#1890](https://github.com/sveltejs/kit/pull/1890))\n\n## 1.0.0-next.20\n\n### Patch Changes\n\n- 7faf52f: Update and consolidate checks for binary body types ([#1687](https://github.com/sveltejs/kit/pull/1687))\n\n## 1.0.0-next.19\n\n### Patch Changes\n\n- 2ac5781: Use esbuild inject API to insert shims ([#1822](https://github.com/sveltejs/kit/pull/1822))\n\n## 1.0.0-next.18\n\n### Patch Changes\n\n- 9f0c54a: Externalize app initialization to adapters ([#1804](https://github.com/sveltejs/kit/pull/1804))\n\n## 1.0.0-next.17\n\n### Patch Changes\n\n- c51ab7d: Upgrade esbuild to ^0.12.5 ([#1627](https://github.com/sveltejs/kit/pull/1627))\n\n## 1.0.0-next.16\n\n### Patch Changes\n\n- edc307d: Remove peerDependencies due to pnpm bug ([#1621](https://github.com/sveltejs/kit/pull/1621))\n- 2636e68: Attempt to fix peerDependencies specification ([#1620](https://github.com/sveltejs/kit/pull/1620))\n- 3b988a4: Allow `_redirects` to be placed in root directory ([#1586](https://github.com/sveltejs/kit/pull/1586))\n\n## 1.0.0-next.15\n\n### Patch Changes\n\n- 028abd9: Pass validated svelte config to adapter adapt function ([#1559](https://github.com/sveltejs/kit/pull/1559))\n- Updated dependencies [6372690]\n- Updated dependencies [c3d36a3]\n- Updated dependencies [bf77940]\n- Updated dependencies [2172469]\n- Updated dependencies [028abd9]\n  - @sveltejs/kit@1.0.0-next.110\n\n## 1.0.0-next.14\n\n### Patch Changes\n\n- f59530f: Allow custom redirects for Netlify Adapter\n- 71e293d: change toml parser to support dotted keys and other language features added after the TOML v0.4.0 spec ([#1509](https://github.com/sveltejs/kit/pull/1509))\n- 1ba1784: Prevent adapter from splitting query params if they contain commas ([#1467](https://github.com/sveltejs/kit/pull/1467))\n- dca4946: Make kit a peerDependency of the adapters ([#1505](https://github.com/sveltejs/kit/pull/1505))\n- Updated dependencies [261ee1c]\n- Updated dependencies [ec156c6]\n- Updated dependencies [586785d]\n  - @sveltejs/kit@1.0.0-next.109\n\n## 1.0.0-next.13\n\n### Patch Changes\n\n- dad93fc: Fix workspace dependencies ([#1434](https://github.com/sveltejs/kit/pull/1434))\n- Updated dependencies [dad93fc]\n- Updated dependencies [37fc04f]\n  - @sveltejs/kit@1.0.0-next.108\n\n## 1.0.0-next.12\n\n### Patch Changes\n\n- 11e7840: Ensure rawBody is a string or Uint8Array ([#1382](https://github.com/sveltejs/kit/pull/1382))\n- Updated dependencies [11e7840]\n- Updated dependencies [11e7840]\n- Updated dependencies [9e20873]\n- Updated dependencies [2562ca0]\n  - @sveltejs/kit@1.0.0-next.103\n\n## 1.0.0-next.11\n\n### Patch Changes\n\n- c6fde99: Convert to ESM ([#1323](https://github.com/sveltejs/kit/pull/1323))\n- Updated dependencies [694f5de]\n- Updated dependencies [0befffb]\n- Updated dependencies [c6fde99]\n  - @sveltejs/kit@1.0.0-next.97\n\n## 1.0.0-next.10\n\n### Patch Changes\n\n- 2e72a94: Add type declarations ([#1230](https://github.com/sveltejs/kit/pull/1230))\n- Updated dependencies [82955ec]\n  - @sveltejs/kit@1.0.0-next.91\n\n## 1.0.0-next.9\n\n### Patch Changes\n\n- d3cb858: Convert body to string, unless type is octet-stream ([#1121](https://github.com/sveltejs/kit/pull/1121))\n- Updated dependencies [4af45e1]\n  - @sveltejs/kit@1.0.0-next.82\n\n## 1.0.0-next.8\n\n### Patch Changes\n\n- 1237eb3: Fix dependencies ([#1109](https://github.com/sveltejs/kit/pull/1109))\n- 1237eb3: Pass rawBody from netlify adapter ([#1109](https://github.com/sveltejs/kit/pull/1109))\n- Updated dependencies [1237eb3]\n- Updated dependencies [1237eb3]\n  - @sveltejs/kit@1.0.0-next.81\n\n## 1.0.0-next.7\n\n### Patch Changes\n\n- 0db2cf7: Fix serverless function ([#1102](https://github.com/sveltejs/kit/pull/1102))\n\n## 1.0.0-next.6\n\n### Patch Changes\n\n- 7a4b351: Bundle serverless functions with esbuild ([#1091](https://github.com/sveltejs/kit/pull/1091))\n\n## 1.0.0-next.5\n\n### Patch Changes\n\n- 6e27880: Move server-side fetch to adapters instead of build step ([#1066](https://github.com/sveltejs/kit/pull/1066))\n\n## 1.0.0-next.4\n\n### Patch Changes\n\n- 8805c6d: Pass adapters directly to svelte.config.cjs ([#579](https://github.com/sveltejs/kit/pull/579))\n\n## 1.0.0-next.3\n\n### Patch Changes\n\n- f35a5cd: Change adapter signature ([#505](https://github.com/sveltejs/kit/pull/505))\n\n## 1.0.0-next.2\n\n### Patch Changes\n\n- 512b8c9: adapter-netlify: Use CJS entrypoint ([#485](https://github.com/sveltejs/kit/pull/485))\n\n## 1.0.0-next.1\n\n### Patch Changes\n\n- Fix adapters and convert to ES modules\n\n## 0.0.13\n\n### Patch Changes\n\n- Add svelte-kit start command\n\n## 0.0.12\n\n### Patch Changes\n\n- b475ed4: Overhaul adapter API - fixes #166 ([#180](https://github.com/sveltejs/kit/pull/180))\n\n## 0.0.11\n\n### Patch Changes\n\n- 67eaeea: Move app-utils stuff into subpackages\n\n## 0.0.10\n\n### Patch Changes\n\n- Use setup\n\n## 0.0.9\n\n### Patch Changes\n\n- 0320208: Rename 'server route' to 'endpoint'\n- 5ca907c: Use shared mkdirp helper\n\n## 0.0.8\n\n### Patch Changes\n\n- various\n"
  },
  {
    "path": "packages/adapter-netlify/README.md",
    "content": "# adapter-netlify\n\nA SvelteKit adapter that creates a Netlify app.\n\n## Docs\n\n[Docs](https://svelte.dev/docs/kit/adapter-netlify)\n\n## Changelog\n\n[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/adapter-netlify/CHANGELOG.md).\n"
  },
  {
    "path": "packages/adapter-netlify/ambient.d.ts",
    "content": "declare global {\n\tnamespace App {\n\t\texport interface Platform {\n\t\t\tcontext: import('@netlify/functions').Context;\n\t\t}\n\t}\n}\n\nexport {};\n"
  },
  {
    "path": "packages/adapter-netlify/index.d.ts",
    "content": "import { Adapter } from '@sveltejs/kit';\nimport './ambient.d.ts';\n\nexport default function plugin(opts?: { split?: boolean; edge?: boolean }): Adapter;\n"
  },
  {
    "path": "packages/adapter-netlify/index.js",
    "content": "/** @import { BuildOptions } from 'esbuild' */\nimport { appendFileSync, existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, resolve, posix } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { builtinModules } from 'node:module';\nimport process from 'node:process';\nimport esbuild from 'esbuild';\nimport toml from '@iarna/toml';\n\n/**\n * @typedef {{\n *   build?: { publish?: string }\n *   functions?: { node_bundler?: 'zisi' | 'esbuild' }\n * } & toml.JsonMap} NetlifyConfig\n */\n\nconst name = '@sveltejs/adapter-netlify';\nconst files = fileURLToPath(new URL('./files', import.meta.url).href);\n\nconst edge_set_in_env_var =\n\tprocess.env.NETLIFY_SVELTEKIT_USE_EDGE === 'true' ||\n\tprocess.env.NETLIFY_SVELTEKIT_USE_EDGE === '1';\n\nconst FUNCTION_PREFIX = 'sveltekit-';\n\n/** @type {import('./index.js').default} */\nexport default function ({ split = false, edge = edge_set_in_env_var } = {}) {\n\treturn {\n\t\tname,\n\t\t/** @param {import('@sveltejs/kit').Builder} builder */\n\t\tasync adapt(builder) {\n\t\t\tif (!builder.routes) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'@sveltejs/adapter-netlify >=2.x (possibly installed through @sveltejs/adapter-auto) requires @sveltejs/kit version 1.5 or higher. ' +\n\t\t\t\t\t\t'Either downgrade the adapter or upgrade @sveltejs/kit'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (existsSync(`${builder.config.kit.files.assets}/_headers`)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The _headers file should be placed in the project root rather than the ${builder.config.kit.files.assets} directory`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (existsSync(`${builder.config.kit.files.assets}/_redirects`)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The _redirects file should be placed in the project root rather than the ${builder.config.kit.files.assets} directory`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst netlify_config = get_netlify_config();\n\n\t\t\t// \"build\" is the default publish directory when Netlify detects SvelteKit\n\t\t\tconst publish = get_publish_directory(netlify_config, builder) || 'build';\n\n\t\t\t// empty out existing build directories\n\t\t\tbuilder.rimraf(publish);\n\t\t\tbuilder.rimraf('.netlify/edge-functions');\n\t\t\tbuilder.rimraf('.netlify/server');\n\t\t\tbuilder.rimraf('.netlify/package.json');\n\t\t\tbuilder.rimraf('.netlify/serverless.js');\n\n\t\t\tif (existsSync('.netlify/functions-internal')) {\n\t\t\t\tfor (const file of readdirSync('.netlify/functions-internal')) {\n\t\t\t\t\tif (file.startsWith(FUNCTION_PREFIX)) {\n\t\t\t\t\t\tbuilder.rimraf(join('.netlify/functions-internal', file));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbuilder.log.minor(`Publishing to \"${publish}\"`);\n\n\t\t\tbuilder.log.minor('Copying assets...');\n\t\t\tconst publish_dir = `${publish}${builder.config.kit.paths.base}`;\n\t\t\tbuilder.writeClient(publish_dir);\n\t\t\tbuilder.writePrerendered(publish_dir);\n\n\t\t\tbuilder.log.minor('Writing custom headers...');\n\t\t\tconst headers_file = join(publish, '_headers');\n\t\t\tbuilder.copy('_headers', headers_file);\n\t\t\tappendFileSync(\n\t\t\t\theaders_file,\n\t\t\t\t`\\n\\n/${builder.getAppPath()}/immutable/*\\n  cache-control: public\\n  cache-control: immutable\\n  cache-control: max-age=31536000\\n`\n\t\t\t);\n\n\t\t\tif (edge) {\n\t\t\t\tif (split) {\n\t\t\t\t\tthrow new Error('Cannot use `split: true` alongside `edge: true`');\n\t\t\t\t}\n\n\t\t\t\tawait generate_edge_functions({ builder });\n\t\t\t} else {\n\t\t\t\tgenerate_lambda_functions({ builder, split, publish });\n\t\t\t}\n\t\t},\n\n\t\tsupports: {\n\t\t\tread: () => true,\n\t\t\tinstrumentation: () => true\n\t\t}\n\t};\n}\n/**\n * @param { object } params\n * @param {import('@sveltejs/kit').Builder} params.builder\n */\nasync function generate_edge_functions({ builder }) {\n\tconst tmp = builder.getBuildDirectory('netlify-tmp');\n\tbuilder.rimraf(tmp);\n\tbuilder.mkdirp(tmp);\n\n\tbuilder.mkdirp('.netlify/edge-functions');\n\n\tbuilder.log.minor('Generating Edge Function...');\n\tconst relativePath = posix.relative(tmp, builder.getServerDirectory());\n\n\tbuilder.copy(`${files}/edge.js`, `${tmp}/entry.js`, {\n\t\treplace: {\n\t\t\t'0SERVER': `${relativePath}/index.js`,\n\t\t\tMANIFEST: './manifest.js'\n\t\t}\n\t});\n\n\tconst manifest = builder.generateManifest({\n\t\trelativePath\n\t});\n\n\twriteFileSync(`${tmp}/manifest.js`, `export const manifest = ${manifest};\\n`);\n\n\t/** @type {{ assets: Set<string> }} */\n\t// we have to prepend the file:// protocol because Windows doesn't support absolute path imports\n\tconst { assets } = (await import(`file://${tmp}/manifest.js`)).manifest;\n\n\tconst path = '/*';\n\t// We only need to specify paths without the trailing slash because\n\t// Netlify will handle the optional trailing slash for us\n\tconst excluded = [\n\t\t// Contains static files\n\t\t`/${builder.getAppPath()}/immutable/*`,\n\t\t`/${builder.getAppPath()}/version.json`,\n\t\t...builder.prerendered.paths,\n\t\t...Array.from(assets).flatMap((asset) => {\n\t\t\tif (asset.endsWith('/index.html')) {\n\t\t\t\tconst dir = asset.replace(/\\/index\\.html$/, '');\n\t\t\t\treturn [\n\t\t\t\t\t`${builder.config.kit.paths.base}/${asset}`,\n\t\t\t\t\t`${builder.config.kit.paths.base}/${dir}`\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn `${builder.config.kit.paths.base}/${asset}`;\n\t\t}),\n\t\t// Should not be served by SvelteKit at all\n\t\t'/.netlify/*'\n\t];\n\n\t/** @type {import('@netlify/edge-functions').Manifest} */\n\tconst edge_manifest = {\n\t\tfunctions: [\n\t\t\t{\n\t\t\t\tfunction: 'render',\n\t\t\t\tpath,\n\t\t\t\texcludedPath: /** @type {`/${string}`[]} */ (excluded)\n\t\t\t}\n\t\t],\n\t\tversion: 1\n\t};\n\n\t/** @type {BuildOptions} */\n\tconst esbuild_config = {\n\t\tbundle: true,\n\t\tformat: 'esm',\n\t\tplatform: 'browser',\n\t\tsourcemap: 'linked',\n\t\ttarget: 'es2020',\n\t\tloader: {\n\t\t\t'.wasm': 'copy',\n\t\t\t'.woff': 'copy',\n\t\t\t'.woff2': 'copy',\n\t\t\t'.ttf': 'copy',\n\t\t\t'.eot': 'copy',\n\t\t\t'.otf': 'copy'\n\t\t},\n\t\t// Node built-ins are allowed, but must be prefixed with `node:`\n\t\t// https://docs.netlify.com/edge-functions/api/#runtime-environment\n\t\texternal: builtinModules.map((id) => `node:${id}`),\n\t\talias: Object.fromEntries(builtinModules.map((id) => [id, `node:${id}`]))\n\t};\n\tawait Promise.all([\n\t\tesbuild.build({\n\t\t\tentryPoints: [`${tmp}/entry.js`],\n\t\t\toutfile: '.netlify/edge-functions/render.js',\n\t\t\t...esbuild_config\n\t\t}),\n\t\tbuilder.hasServerInstrumentationFile() &&\n\t\t\tesbuild.build({\n\t\t\t\tentryPoints: [`${builder.getServerDirectory()}/instrumentation.server.js`],\n\t\t\t\toutfile: '.netlify/edge/instrumentation.server.js',\n\t\t\t\t...esbuild_config\n\t\t\t})\n\t]);\n\n\tif (builder.hasServerInstrumentationFile()) {\n\t\tbuilder.instrument({\n\t\t\tentrypoint: '.netlify/edge-functions/render.js',\n\t\t\tinstrumentation: '.netlify/edge/instrumentation.server.js',\n\t\t\tstart: '.netlify/edge/start.js'\n\t\t});\n\t}\n\n\twriteFileSync('.netlify/edge-functions/manifest.json', JSON.stringify(edge_manifest));\n}\n/**\n * @param { object } params\n * @param {import('@sveltejs/kit').Builder} params.builder\n * @param { string } params.publish\n * @param { boolean } params.split\n */\nfunction generate_lambda_functions({ builder, publish, split }) {\n\tbuilder.mkdirp('.netlify/functions-internal/.svelte-kit');\n\n\tbuilder.writeServer('.netlify/server');\n\n\tconst replace = {\n\t\t'0SERVER': './server/index.js' // digit prefix prevents CJS build from using this as a variable name, which would also get replaced\n\t};\n\n\tbuilder.copy(files, '.netlify', { replace, filter: (name) => !name.endsWith('edge.js') });\n\n\tbuilder.log.minor('Generating serverless functions...');\n\n\tif (split) {\n\t\tconst seen = new Set();\n\n\t\tfor (let i = 0; i < builder.routes.length; i++) {\n\t\t\tconst route = builder.routes[i];\n\t\t\tif (route.prerender === true) continue;\n\n\t\t\tconst routes = [route];\n\n\t\t\t/** @type {string[]} */\n\t\t\tconst parts = [];\n\n\t\t\t// The parts should conform to URLPattern syntax\n\t\t\t// https://docs.netlify.com/build/functions/get-started/?fn-language=ts&data-tab=TypeScript#route-requests\n\t\t\tfor (const segment of route.segments) {\n\t\t\t\tif (segment.rest) {\n\t\t\t\t\tparts.push('*');\n\t\t\t\t} else if (segment.dynamic) {\n\t\t\t\t\t// URLPattern requires params to start with letters\n\t\t\t\t\tparts.push(`:param${parts.length}`);\n\t\t\t\t} else {\n\t\t\t\t\tparts.push(segment.content);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Netlify handles trailing slashes for us, so we don't need to include them in the pattern\n\t\t\tconst pattern = `/${parts.join('/')}`;\n\t\t\tconst name =\n\t\t\t\tFUNCTION_PREFIX + (parts.join('-').replace(/[:.]/g, '_').replace('*', '__rest') || 'index');\n\n\t\t\t// skip routes with identical patterns, they were already folded into another function\n\t\t\tif (seen.has(pattern)) continue;\n\n\t\t\tconst patterns = [pattern, `${pattern === '/' ? '' : pattern}/__data.json`];\n\t\t\tpatterns.forEach((p) => seen.add(p));\n\n\t\t\t// figure out which lower priority routes should be considered fallbacks\n\t\t\tfor (let j = i + 1; j < builder.routes.length; j += 1) {\n\t\t\t\tconst other = builder.routes[j];\n\t\t\t\tif (other.prerender === true) continue;\n\n\t\t\t\tif (matches(route.segments, other.segments)) {\n\t\t\t\t\troutes.push(other);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tgenerate_serverless_function({\n\t\t\t\tbuilder,\n\t\t\t\troutes,\n\t\t\t\tpatterns,\n\t\t\t\tname\n\t\t\t});\n\t\t}\n\n\t\tgenerate_serverless_function({\n\t\t\tbuilder,\n\t\t\troutes: [],\n\t\t\tpatterns: ['/*'],\n\t\t\tname: `${FUNCTION_PREFIX}catch-all`,\n\t\t\texclude: Array.from(seen)\n\t\t});\n\t} else {\n\t\tgenerate_serverless_function({\n\t\t\tbuilder,\n\t\t\troutes: undefined,\n\t\t\tpatterns: ['/*'],\n\t\t\tname: `${FUNCTION_PREFIX}render`\n\t\t});\n\t}\n\n\t// Copy user's custom _redirects file if it exists\n\tif (existsSync('_redirects')) {\n\t\tbuilder.log.minor('Copying user redirects...');\n\t\tconst redirects_file = join(publish, '_redirects');\n\t\tbuilder.copy('_redirects', redirects_file);\n\t}\n}\n\nfunction get_netlify_config() {\n\tif (!existsSync('netlify.toml')) return null;\n\n\ttry {\n\t\treturn /** @type {NetlifyConfig} */ (toml.parse(readFileSync('netlify.toml', 'utf-8')));\n\t} catch (err) {\n\t\terr.message = `Error parsing netlify.toml: ${err.message}`;\n\t\tthrow err;\n\t}\n}\n\n/**\n * @param {NetlifyConfig | null} netlify_config\n * @param {import('@sveltejs/kit').Builder} builder\n **/\nfunction get_publish_directory(netlify_config, builder) {\n\tif (netlify_config) {\n\t\tif (!netlify_config.build?.publish) {\n\t\t\tbuilder.log.minor('No publish directory specified in netlify.toml, using default');\n\t\t\treturn;\n\t\t}\n\n\t\tif (resolve(netlify_config.build.publish) === process.cwd()) {\n\t\t\tthrow new Error(\n\t\t\t\t'The publish directory cannot be set to the site root. Please change it to another value such as \"build\" in netlify.toml.'\n\t\t\t);\n\t\t}\n\t\treturn netlify_config.build.publish;\n\t}\n\n\tbuilder.log.warn(\n\t\t'No netlify.toml found. Using default publish directory. Consult https://svelte.dev/docs/kit/adapter-netlify#usage for more details'\n\t);\n}\n\n/**\n * @typedef {{ rest: boolean, dynamic: boolean, content: string }} RouteSegment\n */\n\n/**\n * @param {RouteSegment[]} a\n * @param {RouteSegment[]} b\n * @returns {boolean}\n */\nfunction matches(a, b) {\n\tif (a[0] && b[0]) {\n\t\tif (b[0].rest) {\n\t\t\tif (b.length === 1) return true;\n\n\t\t\tconst next_b = b.slice(1);\n\n\t\t\tfor (let i = 0; i < a.length; i += 1) {\n\t\t\t\tif (matches(a.slice(i), next_b)) return true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!b[0].dynamic) {\n\t\t\tif (!a[0].dynamic && a[0].content !== b[0].content) return false;\n\t\t}\n\n\t\tif (a.length === 1 && b.length === 1) return true;\n\t\treturn matches(a.slice(1), b.slice(1));\n\t} else if (a[0]) {\n\t\treturn a.length === 1 && a[0].rest;\n\t} else {\n\t\treturn b.length === 1 && b[0].rest;\n\t}\n}\n\n/**\n *\n * @param {{\n *   builder: import('@sveltejs/kit').Builder,\n *   routes: import('@sveltejs/kit').RouteDefinition[] | undefined,\n *   patterns: string[],\n *   name: string,\n *   exclude?: string[]\n * }} opts\n */\nfunction generate_serverless_function({ builder, routes, patterns, name, exclude }) {\n\tconst manifest = builder.generateManifest({\n\t\trelativePath: '../server',\n\t\troutes\n\t});\n\n\tconst fn = generate_serverless_function_module(manifest);\n\tconst config = generate_config_export(patterns, exclude);\n\n\tif (builder.hasServerInstrumentationFile()) {\n\t\twriteFileSync(`.netlify/functions-internal/${name}.mjs`, fn);\n\t\tbuilder.instrument({\n\t\t\tentrypoint: `.netlify/functions-internal/${name}.mjs`,\n\t\t\tinstrumentation: '.netlify/server/instrumentation.server.js',\n\t\t\tstart: `.netlify/functions-start/${name}.start.mjs`,\n\t\t\tmodule: {\n\t\t\t\tgenerateText: generate_traced_module(config)\n\t\t\t}\n\t\t});\n\t} else {\n\t\twriteFileSync(`.netlify/functions-internal/${name}.mjs`, `${fn}\\n${config}`);\n\t}\n}\n\n/**\n * @param {string} manifest\n * @returns {string}\n */\nfunction generate_serverless_function_module(manifest) {\n\treturn `\\\nimport { init } from '../serverless.js';\n\nexport default init(${manifest});\n`;\n}\n\n/**\n * @param {string[]} patterns\n * @param {string[]} [exclude]\n * @returns {string}\n */\nfunction generate_config_export(patterns, exclude = []) {\n\t// TODO: add a human friendly name for the function https://docs.netlify.com/build/frameworks/frameworks-api/#configuration-options-2\n\treturn `\\\nexport const config = {\n\tpath: [${patterns.map((s) => JSON.stringify(s)).join(', ')}],\n\texcludedPath: [${['/.netlify/*', ...exclude].map((s) => JSON.stringify(s)).join(', ')}],\n\tpreferStatic: true\n};\n`;\n}\n\n/**\n * @param {string} config\n * @returns {(opts: { instrumentation: string; start: string }) => string}\n */\nfunction generate_traced_module(config) {\n\treturn ({ instrumentation, start }) => {\n\t\treturn `\\\nimport './${instrumentation}';\nconst { default: _0 } = await import('./${start}');\nexport { _0 as default };\n\n${config}`;\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-netlify/internal.d.ts",
    "content": "declare module '0SERVER' {\n\texport { Server } from '@sveltejs/kit';\n}\n\ndeclare module 'MANIFEST' {\n\timport { SSRManifest } from '@sveltejs/kit';\n\n\texport const manifest: SSRManifest;\n}\n"
  },
  {
    "path": "packages/adapter-netlify/package.json",
    "content": "{\n\t\"name\": \"@sveltejs/adapter-netlify\",\n\t\"version\": \"6.0.4\",\n\t\"description\": \"A SvelteKit adapter that creates a Netlify app\",\n\t\"keywords\": [\n\t\t\"adapter\",\n\t\t\"deploy\",\n\t\t\"hosting\",\n\t\t\"netlify\",\n\t\t\"svelte\",\n\t\t\"sveltekit\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/sveltejs/kit.git\",\n\t\t\"directory\": \"packages/adapter-netlify\"\n\t},\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://svelte.dev/docs/kit/adapter-netlify\",\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./index.d.ts\",\n\t\t\t\"import\": \"./index.js\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"types\": \"index.d.ts\",\n\t\"files\": [\n\t\t\"files\",\n\t\t\"index.js\",\n\t\t\"index.d.ts\",\n\t\t\"ambient.d.ts\"\n\t],\n\t\"scripts\": {\n\t\t\"dev\": \"rollup -cw\",\n\t\t\"build\": \"rollup -c\",\n\t\t\"check\": \"tsc\",\n\t\t\"lint\": \"prettier --check .\",\n\t\t\"format\": \"pnpm lint --write\",\n\t\t\"test\": \"pnpm test:integration\",\n\t\t\"test:unit\": \"vitest run\",\n\t\t\"test:integration\": \"pnpm build && pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test\",\n\t\t\"prepublishOnly\": \"pnpm build\"\n\t},\n\t\"dependencies\": {\n\t\t\"@iarna/toml\": \"^2.2.5\",\n\t\t\"esbuild\": \"^0.25.4\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@netlify/dev\": \"catalog:\",\n\t\t\"@netlify/edge-functions\": \"catalog:\",\n\t\t\"@netlify/functions\": \"catalog:\",\n\t\t\"@netlify/node-cookies\": \"^0.1.0\",\n\t\t\"@netlify/types\": \"^2.1.0\",\n\t\t\"@rollup/plugin-commonjs\": \"catalog:\",\n\t\t\"@rollup/plugin-json\": \"catalog:\",\n\t\t\"@rollup/plugin-node-resolve\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"@types/node\": \"catalog:\",\n\t\t\"rollup\": \"^4.59.0\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@sveltejs/kit\": \"^2.31.0\"\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-netlify/rollup.config.js",
    "content": "import { nodeResolve } from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport { rmSync } from 'node:fs';\n\n/**\n * @param {string} filepath\n * @returns {import('rollup').Plugin}\n */\nfunction clearOutput(filepath) {\n\treturn {\n\t\tname: 'clear-output',\n\t\tbuildStart: {\n\t\t\torder: 'pre',\n\t\t\tsequential: true,\n\t\t\thandler() {\n\t\t\t\trmSync(filepath, { recursive: true, force: true });\n\t\t\t}\n\t\t}\n\t};\n}\n\n/** @type {import('rollup').RollupOptions} */\nconst config = {\n\tinput: {\n\t\tserverless: 'src/serverless.js',\n\t\tshims: 'src/shims.js',\n\t\tedge: 'src/edge.js'\n\t},\n\toutput: {\n\t\tdir: 'files',\n\t\tformat: 'esm'\n\t},\n\t// @ts-ignore https://github.com/rollup/plugins/issues/1329\n\tplugins: [clearOutput('files'), nodeResolve({ preferBuiltins: true }), commonjs(), json()],\n\texternal: (id) => id === '0SERVER' || id === 'MANIFEST' || id.startsWith('node:'),\n\tpreserveEntrySignatures: 'exports-only'\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-netlify/src/edge.js",
    "content": "import { Server } from '0SERVER';\nimport { manifest } from 'MANIFEST';\n\nconst server = new Server(manifest);\n\n/**\n * We don't know the origin until we receive a request, but\n * that's guaranteed to happen before we call `read`\n * @type {string}\n */\nlet origin;\n\nconst initialized = server.init({\n\t// @ts-ignore\n\tenv: Deno.env.toObject(),\n\tread: async (file) => {\n\t\tconst url = `${origin}/${file}`;\n\t\tconst response = await fetch(url);\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(\n\t\t\t\t`read(...) failed: could not fetch ${url} (${response.status} ${response.statusText})`\n\t\t\t);\n\t\t}\n\n\t\treturn response.body;\n\t}\n});\n\n/** @type {import('@netlify/edge-functions').EdgeFunction} */\nexport default async function handler(request, context) {\n\tif (!origin) {\n\t\torigin = new URL(request.url).origin;\n\t\tawait initialized;\n\t}\n\n\treturn server.respond(request, {\n\t\tplatform: { context },\n\t\tgetClientAddress() {\n\t\t\treturn context.ip;\n\t\t}\n\t});\n}\n"
  },
  {
    "path": "packages/adapter-netlify/src/serverless.js",
    "content": "import './shims';\nimport { Server } from '0SERVER';\nimport { createReadableStream } from '@sveltejs/kit/node';\nimport process from 'node:process';\n\n/**\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n * @returns {(request: Request, context: import('@netlify/functions').Context) => Promise<Response>}\n */\nexport function init(manifest) {\n\tconst server = new Server(manifest);\n\n\t/** @type {Promise<void> | null} */\n\tlet init_promise = server.init({\n\t\tenv: /** @type {Record<string, string>} */ (process.env),\n\t\tread: (file) => createReadableStream(`.netlify/server/${file}`)\n\t});\n\n\treturn async (request, context) => {\n\t\tif (init_promise !== null) {\n\t\t\tawait init_promise;\n\t\t\tinit_promise = null;\n\t\t}\n\n\t\treturn server.respond(request, {\n\t\t\tplatform: { context },\n\t\t\tgetClientAddress() {\n\t\t\t\treturn context.ip;\n\t\t\t}\n\t\t});\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-netlify/src/shims.js",
    "content": "import { installPolyfills } from '@sveltejs/kit/node/polyfills';\ninstallPolyfills();\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/.gitignore",
    "content": ".DS_Store\nnode_modules\n/.svelte-kit\n/.netlify\n/build\ndeno.lock"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/netlify.toml",
    "content": "[build]\npublish = \"build\"\n\n# TODO: remove this after we refactor to the Netlify frameworks API\n# we are purposely misusing the user functions config to discover our framework\n# build output because our adapter still outputs using an older API but the new\n# Netlify dev server adheres to the new API\n[functions]\ndirectory = \".netlify/functions-internal\"\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/package.json",
    "content": "{\n\t\"name\": \"test-netlify-basic\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"node ../../preview.js\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"test\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/src/instrumentation.server.js",
    "content": "// this is just here to make sure the changes resulting from it work\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/src/routes/read/+server.js",
    "content": "import { read } from '$app/server';\nimport file from './file.txt?url';\n\nexport function GET() {\n\treturn read(file);\n}\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/src/routes/read/file.txt",
    "content": "Hello! This file is read by `read` from `$app/server`.\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/svelte.config.js",
    "content": "import adapter from '../../../index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter(),\n\t\texperimental: {\n\t\t\tinstrumentation: {\n\t\t\t\tserver: true\n\t\t\t}\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/test/test.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { expect, test } from '@playwright/test';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\ntest('read from $app/server works', async ({ request }) => {\n\tconst content = fs.readFileSync(path.resolve(__dirname, '../src/routes/read/file.txt'), 'utf-8');\n\tconst response = await request.get('/read');\n\texpect(await response.text()).toBe(content);\n});\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"moduleResolution\": \"bundler\"\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/basic/vite.config.ts",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport type { UserConfig } from 'vite';\n\nconst config: UserConfig = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tplugins: [sveltekit()]\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/.gitignore",
    "content": ".DS_Store\nnode_modules\n/.svelte-kit\n/.netlify\n/build\ndeno.lock"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/netlify.toml",
    "content": "[build]\npublish = \"build\"\n\n# TODO: remove these once we overhaul the Netlify adapter to use the new edge declarations https://docs.netlify.com/build/edge-functions/declarations/#declare-edge-functions-inline\n\n# defaults to \"netlify/edge-functions\" (without the . prefix)\nedge_functions = \".netlify/edge-functions\"\n\n# the dev server doesn't read the manifest.json in edge-functions so we need\n# to explicitly declare this here\n[[edge_functions]]\npath = \"/*\"\nfunction = \"render\"\nexcludedPath = [\"/_app/immutable/*\", \"/_app/version.json\", \"/.netlify/*\"]\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/package.json",
    "content": "{\n\t\"name\": \"test-netlify-edge\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"node ../../preview.js\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"test\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/src/routes/read/+server.js",
    "content": "import { read } from '$app/server';\nimport file from './file.txt?url';\n\nexport function GET() {\n\treturn read(file);\n}\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/src/routes/read/file.txt",
    "content": "Hello! This file is read by `read` from `$app/server`.\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/svelte.config.js",
    "content": "import adapter from '../../../index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\tedge: true\n\t\t})\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/test/test.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { expect, test } from '@playwright/test';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\ntest('read from $app/server works', async ({ request }) => {\n\tconst content = fs.readFileSync(path.resolve(__dirname, '../src/routes/read/file.txt'), 'utf-8');\n\tconst response = await request.get('/read');\n\texpect(await response.text()).toBe(content);\n});\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"moduleResolution\": \"bundler\"\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/edge/vite.config.ts",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport type { UserConfig } from 'vite';\n\nconst config: UserConfig = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tplugins: [sveltekit()]\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/.gitignore",
    "content": ".DS_Store\nnode_modules\n/.svelte-kit\n/.netlify\n/build\ndeno.lock"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/netlify.toml",
    "content": "[build]\npublish = \"build\"\n\n# TODO: remove this after we refactor to the Netlify frameworks API\n# we are purposely misusing the user functions config to discover our framework\n# build output because our adapter still outputs using an older API but the new\n# Netlify dev server adheres to the new API\n[functions]\ndirectory = \".netlify/functions-internal\"\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/package.json",
    "content": "{\n\t\"name\": \"test-netlify-split\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"node ../../preview.js\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"test\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/src/instrumentation.server.js",
    "content": "// this is just here to make sure the changes resulting from it work\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/src/routes/+error.svelte",
    "content": "<script lang=\"ts\">\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.status}: {page.error?.message}</h1>\n\n<p>Custom default error page</p>\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/src/routes/dynamic/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport { resolve } from '$app/paths';\n</script>\n\n<a href={resolve('/dynamic/[id]', { id: '1' })}>go to dynamic</a>\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/src/routes/dynamic/[id]/+page.server.js",
    "content": "/** @type {import(\"./$types\").PageServerLoad} */\nexport function load({ params }) {\n\treturn {\n\t\tid: params.id\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/src/routes/dynamic/[id]/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport type { PageData } from './$types';\n\n\texport let data: PageData;\n</script>\n\n<!-- Netlify uses URLPattern for routing and we want to test that our dynamic param configuration works with it -->\n<p>id: {data.id}</p>\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/src/routes/remote/query/+page.js",
    "content": "// test that the client can fetch the remote function data even with split functions enabled\nexport const ssr = false;\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/src/routes/remote/query/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\timport { getData } from './example.remote';\n\n\tlet data = $state.raw(new Promise(() => {}));\n\tonMount(() => {\n\t\tdata = getData();\n\t});\n</script>\n\n<svelte:boundary>\n\t<p>a: {(await data).a}</p>\n\n\t{#snippet pending()}\n\t\tLoading...\n\t{/snippet}\n</svelte:boundary>\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/src/routes/remote/query/example.remote.js",
    "content": "import { query } from '$app/server';\n\nexport const getData = query(() => {\n\treturn { a: 1 };\n});\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/svelte.config.js",
    "content": "import adapter from '../../../index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tcompilerOptions: { experimental: { async: true } },\n\tkit: {\n\t\tadapter: adapter({ split: true }),\n\t\texperimental: {\n\t\t\tinstrumentation: {\n\t\t\t\tserver: true\n\t\t\t},\n\t\t\tremoteFunctions: true\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/test/test.js",
    "content": "import { expect, test } from '@playwright/test';\n\ntest('routes to routes with dynamic params', async ({ page }) => {\n\tawait page.goto('/dynamic/123');\n\tawait expect(page.locator('p')).toHaveText('id: 123');\n});\n\ntest('client-side navigation fetches server load function data', async ({ page }) => {\n\tawait page.goto('/dynamic');\n\tawait page.click('a');\n\tawait expect(page.locator('p')).toHaveText('id: 1');\n});\n\ntest('falls back to catch all function if no routes match', async ({ page }) => {\n\tawait page.goto('/non-existent');\n\tawait expect(page.locator('p')).toHaveText('Custom default error page');\n});\n\ntest('client-side fetch for query remote function data', async ({ page }) => {\n\tawait page.goto('/remote/query');\n\tawait expect(page.locator('p')).toHaveText('a: 1');\n});\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"moduleResolution\": \"bundler\"\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/adapter-netlify/test/apps/split/vite.config.ts",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport type { UserConfig } from 'vite';\n\nconst config: UserConfig = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tplugins: [sveltekit()]\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-netlify/test/preview.js",
    "content": "// This allows us to run `netlify dev` without installing the Netlify CLI\n// Don't include this file in type checking because @netlify/dev has transitive imports with type errors\nimport { NetlifyDev } from '@netlify/dev';\nimport http from 'node:http';\nimport process from 'node:process';\nimport { getRequest, setResponse } from '@sveltejs/kit/node';\n\nconst netlifyDev = new NetlifyDev({});\n\nconst serverReady = netlifyDev.start();\n\nconst port = process.env.PORT ? +process.env.PORT : 8888;\nconst base = `http://localhost:${port}`;\n\nhttp\n\t.createServer(async (req, res) => {\n\t\tawait serverReady;\n\t\tconst request = await getRequest({ request: req, base });\n\t\tconst response =\n\t\t\t(await netlifyDev.handle(request)) ?? new Response('Not Found', { status: 404 });\n\t\tawait setResponse(res, response);\n\t})\n\t.listen(port);\nconsole.log(`Netlify Dev listening on http://localhost:${port}`);\n"
  },
  {
    "path": "packages/adapter-netlify/test/utils.js",
    "content": "import { devices } from '@playwright/test';\nimport process from 'node:process';\nimport { number_from_env } from '../../../test-utils/index.js';\n\n/** @type {import('@playwright/test').PlaywrightTestConfig} */\nexport const config = {\n\tforbidOnly: !!process.env.CI,\n\t// generous timeouts on CI\n\ttimeout: process.env.CI ? 45000 : 15000,\n\twebServer: {\n\t\tcommand: 'pnpm build && pnpm preview',\n\t\tport: 8888\n\t},\n\tretries: process.env.CI ? 2 : number_from_env('KIT_E2E_RETRIES', 0),\n\tprojects: [\n\t\t{\n\t\t\tname: 'chromium'\n\t\t}\n\t],\n\tuse: {\n\t\t...devices['Desktop Chrome'],\n\t\tscreenshot: 'only-on-failure',\n\t\ttrace: 'retain-on-failure',\n\t\tchannel: 'chromium'\n\t},\n\tworkers: process.env.CI ? 2 : number_from_env('KIT_E2E_WORKERS', undefined),\n\treporter: 'list',\n\ttestDir: 'test',\n\ttestMatch: /(.+\\.)?(test|spec)\\.[jt]s/\n};\n"
  },
  {
    "path": "packages/adapter-netlify/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"noImplicitAny\": true,\n\t\t\"strictNullChecks\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"node16\",\n\t\t\"moduleResolution\": \"node16\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../kit/types/index\"]\n\t\t}\n\t},\n\t\"include\": [\"*.js\", \"src/**/*.js\", \"internal.d.ts\", \"test/utils.js\"]\n}\n"
  },
  {
    "path": "packages/adapter-node/.gitignore",
    "content": ".DS_Store\nnode_modules\n/files\ncoverage/\n"
  },
  {
    "path": "packages/adapter-node/CHANGELOG.md",
    "content": "# @sveltejs/adapter-node\n\n## 5.5.4\n### Patch Changes\n\n\n- chore(deps): bump rollup to 4.59.0 ([#15433](https://github.com/sveltejs/kit/pull/15433))\n\n## 5.5.3\n### Patch Changes\n\n\n- fix: validate `ORIGIN` env var at startup ([#15045](https://github.com/sveltejs/kit/pull/15045))\n\n\n- chore(deps): update dependency `@rollup/plugin-commonjs` to v29 ([#14856](https://github.com/sveltejs/kit/pull/14856))\n\n- Updated dependencies [[`37293a5`](https://github.com/sveltejs/kit/commit/37293a5c913b014e823bc823f2c8c6da38b88d6e), [`5d05ca6`](https://github.com/sveltejs/kit/commit/5d05ca6f606cf68417e4ed1ccb68cd77383f1f0f), [`ed69b77`](https://github.com/sveltejs/kit/commit/ed69b77cf9ef1af088008ff559f8de2e2a2f6bf4), [`b1fc959`](https://github.com/sveltejs/kit/commit/b1fc95966e0aeee689fdae71fa488c34b4806303), [`159aece`](https://github.com/sveltejs/kit/commit/159aece0654db020f95bc414f6a21f25fbc5f22f), [`c690579`](https://github.com/sveltejs/kit/commit/c690579620e131cd077ded0bc8e55090d3681d35), [`dc8cf2d`](https://github.com/sveltejs/kit/commit/dc8cf2defa71dd987437895eb89587c724f6e9bb), [`ace2116`](https://github.com/sveltejs/kit/commit/ace2116d95e13293dbc1e26b5b7d780202fd02dd), [`0f38f49`](https://github.com/sveltejs/kit/commit/0f38f498e0e7052db7b8cfe9ea892e7882a67b66)]:\n  - @sveltejs/kit@2.51.0\n\n## 5.5.2\n### Patch Changes\n\n\n- fix: disable gzip and brotli when precompress=false ([#15182](https://github.com/sveltejs/kit/pull/15182))\n\n- Updated dependencies [[`46c1ebd`](https://github.com/sveltejs/kit/commit/46c1ebd9f662f0de499e921bfee2661316449e9d), [`2dd74c8`](https://github.com/sveltejs/kit/commit/2dd74c8c86ae4855c3e9d74d8cf241e86dcd5b36), [`8871b54`](https://github.com/sveltejs/kit/commit/8871b5444413d0c7d7ef4d260996c3b5c359d0b8)]:\n  - @sveltejs/kit@2.50.1\n\n## 5.5.1\n### Patch Changes\n\n\n- fix: add validations for protocol, host, and port header values ([`d9ae9b0`](https://github.com/sveltejs/kit/commit/d9ae9b00b14f5574d109f3fd548f960594346226))\n\n- Updated dependencies [[`81cd545`](https://github.com/sveltejs/kit/commit/81cd545dd78b60ee994a04d8abacb58bf63584d7), [`d9ae9b0`](https://github.com/sveltejs/kit/commit/d9ae9b00b14f5574d109f3fd548f960594346226), [`8ed8155`](https://github.com/sveltejs/kit/commit/8ed8155215b9a74012fecffb942ad9a793b274e5)]:\n  - @sveltejs/kit@2.49.5\n\n## 5.5.0\n### Minor Changes\n\n\n- feat: add env vars for keepAliveTimeout and headersTimeout ([#15125](https://github.com/sveltejs/kit/pull/15125))\n\n## 5.4.0\n### Minor Changes\n\n\n- feat: add [`signal`](https://developer.mozilla.org/en-US/docs/Web/API/Request/signal) property to request ([#14715](https://github.com/sveltejs/kit/pull/14715))\n\n\n### Patch Changes\n\n- Updated dependencies [[`9c933a2`](https://github.com/sveltejs/kit/commit/9c933a29e64c04db03e9150fa4e2d74a894d3d12), [`dedda71`](https://github.com/sveltejs/kit/commit/dedda7184dc04543e2ba6ea3e7f50b3836505463)]:\n  - @sveltejs/kit@2.47.0\n\n## 5.3.3\n### Patch Changes\n\n\n- chore: update \"homepage\" field in package.json ([#14579](https://github.com/sveltejs/kit/pull/14579))\n\n## 5.3.2\n### Patch Changes\n\n\n- fix: bump bundled sirv version to 3.0.2 ([#14385](https://github.com/sveltejs/kit/pull/14385))\n\n- Updated dependencies [[`e6c3171`](https://github.com/sveltejs/kit/commit/e6c317150d330413a7691c1b00dc94ce121fdb89)]:\n  - @sveltejs/kit@2.38.0\n\n## 5.3.1\n### Patch Changes\n\n\n- fix: avoid erroring on builder properties that only exist on the latest version of SvelteKit ([#14233](https://github.com/sveltejs/kit/pull/14233))\n\n- Updated dependencies [[`f2db41c`](https://github.com/sveltejs/kit/commit/f2db41c0d3a0aefbb080ab6a9aa5822b3e41625c)]:\n  - @sveltejs/kit@2.31.1\n\n## 5.3.0\n### Minor Changes\n\n\n- feat: add `instrumentation.server.ts` for tracing and observability setup ([#13899](https://github.com/sveltejs/kit/pull/13899))\n\n\n### Patch Changes\n\n- Updated dependencies [[`f635678`](https://github.com/sveltejs/kit/commit/f63567812505597b1edc3e01010eca622b03b126), [`f635678`](https://github.com/sveltejs/kit/commit/f63567812505597b1edc3e01010eca622b03b126)]:\n  - @sveltejs/kit@2.31.0\n\n## 5.2.16\n### Patch Changes\n\n\n- fix: handling of PROTOCOL_HEADER and HOST_HEADER env vars ([#14221](https://github.com/sveltejs/kit/pull/14221))\n\n- Updated dependencies [[`ea95533`](https://github.com/sveltejs/kit/commit/ea9553380a9f1b5f3b2fcf3bebd15f900c51d77c)]:\n  - @sveltejs/kit@2.30.1\n\n## 5.2.15\n### Patch Changes\n\n\n- fix: fallback to `host` header if header specified by `HOST_HEADER` is not in request headers ([#11154](https://github.com/sveltejs/kit/pull/11154))\n\n- Updated dependencies [[`6ab60e5`](https://github.com/sveltejs/kit/commit/6ab60e509f28e13dae9e15a4af340e92ec6fcdf3), [`bfdb564`](https://github.com/sveltejs/kit/commit/bfdb5643968f201ead51d890207b9c42e400a227), [`94b30c4`](https://github.com/sveltejs/kit/commit/94b30c468ce6f6d1fa0aa985d86ef9216cff83f2)]:\n  - @sveltejs/kit@2.30.0\n\n## 5.2.14\n### Patch Changes\n\n\n- chore: add `.git` to the end of `package.json` repository url ([#14134](https://github.com/sveltejs/kit/pull/14134))\n\n- Updated dependencies [[`c968aef`](https://github.com/sveltejs/kit/commit/c968aef5727f978244d5160657b4a7ac651384ae)]:\n  - @sveltejs/kit@2.27.3\n\n## 5.2.13\n### Patch Changes\n\n\n- fix: remove unnecessary static directory serving middleware ([#13953](https://github.com/sveltejs/kit/pull/13953))\n\n- Updated dependencies [[`bcdaf21`](https://github.com/sveltejs/kit/commit/bcdaf215c2182524e7678a1049a5f1ccbbe71e21)]:\n  - @sveltejs/kit@2.22.3\n\n## 5.2.12\n### Patch Changes\n\n\n- fix: include ambient type declarations ([#12088](https://github.com/sveltejs/kit/pull/12088))\n\n- Updated dependencies [[`d440c68acac67ed64eea4b9bda267e229303db7b`](https://github.com/sveltejs/kit/commit/d440c68acac67ed64eea4b9bda267e229303db7b), [`6774ebc34330b12ae8c0cae08e98b577d819fffb`](https://github.com/sveltejs/kit/commit/6774ebc34330b12ae8c0cae08e98b577d819fffb), [`777c8ef11f17d2ab48aee0f2347c051663da5826`](https://github.com/sveltejs/kit/commit/777c8ef11f17d2ab48aee0f2347c051663da5826), [`f451f6c4a3dbbc73dc86667c6ff89ab2f46ca9d2`](https://github.com/sveltejs/kit/commit/f451f6c4a3dbbc73dc86667c6ff89ab2f46ca9d2), [`34a03ff16af29e917abebb649b31eadfc40a98a0`](https://github.com/sveltejs/kit/commit/34a03ff16af29e917abebb649b31eadfc40a98a0), [`1c77e283896058084c1cb5752d9ec207987a585e`](https://github.com/sveltejs/kit/commit/1c77e283896058084c1cb5752d9ec207987a585e), [`04958cca5905aaeeff367c9e4a5ce6e90fc64779`](https://github.com/sveltejs/kit/commit/04958cca5905aaeeff367c9e4a5ce6e90fc64779), [`9dc5c0e3e01a3c07010e9996688169be68e1dde8`](https://github.com/sveltejs/kit/commit/9dc5c0e3e01a3c07010e9996688169be68e1dde8), [`00e1a7621de554054d068e4525a9e505d1c2e588`](https://github.com/sveltejs/kit/commit/00e1a7621de554054d068e4525a9e505d1c2e588), [`9fcd1e7574197fa6e7ac000a030378d877cb8837`](https://github.com/sveltejs/kit/commit/9fcd1e7574197fa6e7ac000a030378d877cb8837), [`e541a4057a00f5ab6740fb51b7f88f17776da50a`](https://github.com/sveltejs/kit/commit/e541a4057a00f5ab6740fb51b7f88f17776da50a), [`37f72fbb075b481de8263f62c77125333735f382`](https://github.com/sveltejs/kit/commit/37f72fbb075b481de8263f62c77125333735f382), [`b60707ca8e755be95c86490122aa1b792b9bd6be`](https://github.com/sveltejs/kit/commit/b60707ca8e755be95c86490122aa1b792b9bd6be), [`699f4405c752261cf46c1ad32e4dbadceaffc75b`](https://github.com/sveltejs/kit/commit/699f4405c752261cf46c1ad32e4dbadceaffc75b), [`e2a4538c48295cde06f64fb8c7f0b333fbf95496`](https://github.com/sveltejs/kit/commit/e2a4538c48295cde06f64fb8c7f0b333fbf95496), [`a91ba1f326b6e244503de9a010771d942b461dad`](https://github.com/sveltejs/kit/commit/a91ba1f326b6e244503de9a010771d942b461dad)]:\n  - @sveltejs/kit@2.16.0\n\n## 5.2.11\n### Patch Changes\n\n\n- chore(deps): update dependency @rollup/plugin-node-resolve to v16 ([#13164](https://github.com/sveltejs/kit/pull/13164))\n\n- Updated dependencies [[`19823dd716568140011eaa86110bb8868f0e2513`](https://github.com/sveltejs/kit/commit/19823dd716568140011eaa86110bb8868f0e2513), [`5d30191d13a596bda50e27e54522c10f3f6461e3`](https://github.com/sveltejs/kit/commit/5d30191d13a596bda50e27e54522c10f3f6461e3)]:\n  - @sveltejs/kit@2.12.2\n\n## 5.2.10\n### Patch Changes\n\n\n- chore: append http on listening address ([#13146](https://github.com/sveltejs/kit/pull/13146))\n\n- Updated dependencies [[`11a9f66922199ee5925cc71c0efc513376753754`](https://github.com/sveltejs/kit/commit/11a9f66922199ee5925cc71c0efc513376753754), [`3d9e03a8a55a539b02c76d44df4874e4642bbd17`](https://github.com/sveltejs/kit/commit/3d9e03a8a55a539b02c76d44df4874e4642bbd17)]:\n  - @sveltejs/kit@2.11.0\n\n## 5.2.9\n### Patch Changes\n\n\n- docs: update URLs for new svelte.dev site ([#12857](https://github.com/sveltejs/kit/pull/12857))\n\n- Updated dependencies [[`dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46`](https://github.com/sveltejs/kit/commit/dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46), [`4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d`](https://github.com/sveltejs/kit/commit/4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d), [`3a9b78f04786898ca93f6d4b75ab18d26bc45192`](https://github.com/sveltejs/kit/commit/3a9b78f04786898ca93f6d4b75ab18d26bc45192), [`723eb8b31e6a22c82f730c30e485386c8676b746`](https://github.com/sveltejs/kit/commit/723eb8b31e6a22c82f730c30e485386c8676b746), [`8ec471c875345b751344e67580ff1b772ef2735b`](https://github.com/sveltejs/kit/commit/8ec471c875345b751344e67580ff1b772ef2735b)]:\n  - @sveltejs/kit@2.7.3\n\n## 5.2.8\n### Patch Changes\n\n\n- chore: upgrade @rollup/plugin-commonjs to 28.0.1 ([#12817](https://github.com/sveltejs/kit/pull/12817))\n\n## 5.2.7\n### Patch Changes\n\n\n- chore: upgrade to sirv 3.0 ([#12796](https://github.com/sveltejs/kit/pull/12796))\n\n- Updated dependencies [[`dbc9c9486f962af7dbd9123d12d8a6829700d00f`](https://github.com/sveltejs/kit/commit/dbc9c9486f962af7dbd9123d12d8a6829700d00f), [`96642d234d1f5e961e919da725a1f6188e8aba2c`](https://github.com/sveltejs/kit/commit/96642d234d1f5e961e919da725a1f6188e8aba2c)]:\n  - @sveltejs/kit@2.7.1\n\n## 5.2.6\n### Patch Changes\n\n\n- fix: use `node:` imports to support Deno ([#12785](https://github.com/sveltejs/kit/pull/12785))\n\n## 5.2.5\n### Patch Changes\n\n\n- chore: upgrade rollup plugins ([#12706](https://github.com/sveltejs/kit/pull/12706))\n\n- Updated dependencies [[`a233f53f28fcb4c3ea63d2faf156fba09a18456c`](https://github.com/sveltejs/kit/commit/a233f53f28fcb4c3ea63d2faf156fba09a18456c), [`5b40b04608023a3fcb6c601a5f2d36485ce07196`](https://github.com/sveltejs/kit/commit/5b40b04608023a3fcb6c601a5f2d36485ce07196)]:\n  - @sveltejs/kit@2.6.0\n\n## 5.2.4\n### Patch Changes\n\n\n- chore: upgrade polka to 1.0.0-next.28 ([#12693](https://github.com/sveltejs/kit/pull/12693))\n\n## 5.2.3\n### Patch Changes\n\n\n- fix: import `node:process` instead of using globals ([#12641](https://github.com/sveltejs/kit/pull/12641))\n\n- Updated dependencies [[`e798ef718f163bed4f93e1918bd8294f765376ad`](https://github.com/sveltejs/kit/commit/e798ef718f163bed4f93e1918bd8294f765376ad)]:\n  - @sveltejs/kit@2.5.28\n\n## 5.2.2\n### Patch Changes\n\n\n- chore: configure provenance in a simpler manner ([#12570](https://github.com/sveltejs/kit/pull/12570))\n\n- Updated dependencies [[`087a43d391fc38b8c008fb39a804dc6988974101`](https://github.com/sveltejs/kit/commit/087a43d391fc38b8c008fb39a804dc6988974101)]:\n  - @sveltejs/kit@2.5.22\n\n## 5.2.1\n### Patch Changes\n\n\n- chore: package provenance ([#12567](https://github.com/sveltejs/kit/pull/12567))\n\n- Updated dependencies [[`4930a8443caa53bcecee7b690cd28e429b1c8a20`](https://github.com/sveltejs/kit/commit/4930a8443caa53bcecee7b690cd28e429b1c8a20)]:\n  - @sveltejs/kit@2.5.21\n\n## 5.2.0\n\n### Minor Changes\n\n- feat: add unit suffixes to the `BODY_SIZE_LIMIT` environment variable ([#11680](https://github.com/sveltejs/kit/pull/11680))\n\n### Patch Changes\n\n- Updated dependencies [[`121836fcbf6c615fd18c79a12203613ddbe49acf`](https://github.com/sveltejs/kit/commit/121836fcbf6c615fd18c79a12203613ddbe49acf)]:\n  - @sveltejs/kit@2.5.17\n\n## 5.1.1\n\n### Patch Changes\n\n- fix: do not create more than one shutdown timeout ([#12359](https://github.com/sveltejs/kit/pull/12359))\n\n- Updated dependencies [[`835ebf6ce9979203992cca30f434b3785afae818`](https://github.com/sveltejs/kit/commit/835ebf6ce9979203992cca30f434b3785afae818)]:\n  - @sveltejs/kit@2.5.16\n\n## 5.1.0\n\n### Minor Changes\n\n- feat: add shutdown event ([#12153](https://github.com/sveltejs/kit/pull/12153))\n\n### Patch Changes\n\n- fix: close keep-alive connections as soon as possible during graceful shutdown rather than accepting new requests ([#12153](https://github.com/sveltejs/kit/pull/12153))\n\n## 5.0.2\n\n### Patch Changes\n\n- chore: update to @rollup/plugin-commonjs@26 ([#12326](https://github.com/sveltejs/kit/pull/12326))\n\n- chore(deps): update dependency @rollup/plugin-commonjs to v26 ([`9aa59db67080248eb22fd227e7a491102b011c47`](https://github.com/sveltejs/kit/commit/9aa59db67080248eb22fd227e7a491102b011c47))\n\n- chore: add keywords for discovery in npm search ([#12330](https://github.com/sveltejs/kit/pull/12330))\n\n- Updated dependencies [[`25acb1d9fce998dccd8050b93cf4142c2b082611`](https://github.com/sveltejs/kit/commit/25acb1d9fce998dccd8050b93cf4142c2b082611), [`642c4a4aff4351b786fe6274aa2f0bf7d905faf9`](https://github.com/sveltejs/kit/commit/642c4a4aff4351b786fe6274aa2f0bf7d905faf9), [`0a0e9aa897123ebec50af08e9385b2ca4fc5bb28`](https://github.com/sveltejs/kit/commit/0a0e9aa897123ebec50af08e9385b2ca4fc5bb28)]:\n  - @sveltejs/kit@2.5.11\n\n## 5.0.1\n\n### Patch Changes\n\n- fix: regression preventing built application from starting ([#11960](https://github.com/sveltejs/kit/pull/11960))\n\n## 5.0.0\n\n### Major Changes\n\n- breaking: add graceful shutdown ([#11653](https://github.com/sveltejs/kit/pull/11653))\n\n- breaking: change default value of `precompress` option to true to serve precompressed assets by default ([#11945](https://github.com/sveltejs/kit/pull/11945))\n\n### Minor Changes\n\n- feat: add systemd socket activation ([#11653](https://github.com/sveltejs/kit/pull/11653))\n\n### Patch Changes\n\n- Updated dependencies [[`873a09eac86817d1cbb53bf3f9c8842d7346d20d`](https://github.com/sveltejs/kit/commit/873a09eac86817d1cbb53bf3f9c8842d7346d20d), [`30c78f223a4f9e6c4547d087338a8b8cc477ba55`](https://github.com/sveltejs/kit/commit/30c78f223a4f9e6c4547d087338a8b8cc477ba55)]:\n  - @sveltejs/kit@2.5.3\n\n## 4.0.1\n\n### Patch Changes\n\n- fix: return 400 response if request construction fails ([#11713](https://github.com/sveltejs/kit/pull/11713))\n\n- Updated dependencies [[`f56781fa47a0f958b228e4a51bb3cbf173854f12`](https://github.com/sveltejs/kit/commit/f56781fa47a0f958b228e4a51bb3cbf173854f12)]:\n  - @sveltejs/kit@2.4.3\n\n## 4.0.0\n\n### Major Changes\n\n- breaking: update peer dependency on `@sveltejs/kit` ([#11649](https://github.com/sveltejs/kit/pull/11649))\n\n### Minor Changes\n\n- feat: support `read` from `$app/server` ([#11649](https://github.com/sveltejs/kit/pull/11649))\n\n### Patch Changes\n\n- Updated dependencies [[`288f731c8a5b20cadb9e219f9583f3f16bf8c7b8`](https://github.com/sveltejs/kit/commit/288f731c8a5b20cadb9e219f9583f3f16bf8c7b8)]:\n  - @sveltejs/kit@2.4.0\n\n## 3.0.3\n\n### Patch Changes\n\n- fix: return 400 response if request construction fails\n\n## 3.0.2\n\n### Patch Changes\n\n- fix: return 400 response if request construction fails\n\n## 3.0.1\n\n### Patch Changes\n\n- chore: upgrade rollup to 4.9.5 ([#11632](https://github.com/sveltejs/kit/pull/11632))\n\n## 3.0.0\n\n### Major Changes\n\n- breaking: allow any numeric value for `BODY_SIZE_LIMIT`, and interpret literally. Use `Infinity` rather than `0` for unrestricted body sizes ([#11589](https://github.com/sveltejs/kit/pull/11589))\n\n## 2.1.2\n\n### Patch Changes\n\n- fix: return 400 response if request construction fails\n\n## 2.1.1\n\n### Patch Changes\n\n- fix: correctly handle BODY_SIZE_LIMIT=0 ([#11574](https://github.com/sveltejs/kit/pull/11574))\n\n## 2.1.0\n\n### Minor Changes\n\n- feat: add `PORT_HEADER` env var for reverse proxies with non-standard ports ([#11249](https://github.com/sveltejs/kit/pull/11249))\n\n### Patch Changes\n\n- Updated dependencies [[`9556abae4ba28c02ba468735beb9eb868876a9a1`](https://github.com/sveltejs/kit/commit/9556abae4ba28c02ba468735beb9eb868876a9a1), [`8468af597c6240f7a3687ef1ed3873990b944f8c`](https://github.com/sveltejs/kit/commit/8468af597c6240f7a3687ef1ed3873990b944f8c)]:\n  - @sveltejs/kit@2.1.1\n\n## 2.0.2\n\n### Patch Changes\n\n- fix: upgrade `sirv` and `mrmime` to modernize javascript mime type ([#11419](https://github.com/sveltejs/kit/pull/11419))\n\n- Updated dependencies [[`b999cfdea24e72043505e032ed9d621590896263`](https://github.com/sveltejs/kit/commit/b999cfdea24e72043505e032ed9d621590896263), [`2a091dcbbdf7d2a70a38316638e16761bd1b9b59`](https://github.com/sveltejs/kit/commit/2a091dcbbdf7d2a70a38316638e16761bd1b9b59)]:\n  - @sveltejs/kit@2.0.5\n\n## 2.0.1\n\n### Patch Changes\n\n- chore: update primary branch from master to main ([`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d))\n\n- Updated dependencies [[`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d), [`16961e8cd3fa6a7f382153b1ff056bc2aae9b31b`](https://github.com/sveltejs/kit/commit/16961e8cd3fa6a7f382153b1ff056bc2aae9b31b), [`197e01f95652f511160f38b37b9da73a124ecd48`](https://github.com/sveltejs/kit/commit/197e01f95652f511160f38b37b9da73a124ecd48), [`102e4a5ae5b29624302163faf5a20c94a64a5b2c`](https://github.com/sveltejs/kit/commit/102e4a5ae5b29624302163faf5a20c94a64a5b2c), [`f8e3d8b9728c9f1ab63389342c31d7246b6f9db6`](https://github.com/sveltejs/kit/commit/f8e3d8b9728c9f1ab63389342c31d7246b6f9db6)]:\n  - @sveltejs/kit@2.0.4\n\n## 2.0.0\n\n### Major Changes\n\n- breaking: require SvelteKit 2 peer dependency ([#11289](https://github.com/sveltejs/kit/pull/11289))\n\n- breaking: remove polyfill option. fetch APIs will now always come from the platform being used. File and crypto APIs will be polyfilled if not available ([#11172](https://github.com/sveltejs/kit/pull/11172))\n\n- chore: upgrade rollup ([#11122](https://github.com/sveltejs/kit/pull/11122))\n\n## 1.3.1\n\n### Patch Changes\n\n- fix: build output stuck on top level await ([#10314](https://github.com/sveltejs/kit/pull/10314))\n\n- Updated dependencies [[`c1ad5b2f8`](https://github.com/sveltejs/kit/commit/c1ad5b2f84762a34adb327a0e309792603b405b3), [`67a0d869b`](https://github.com/sveltejs/kit/commit/67a0d869b3221925c3f456127205a4aee0b28e85), [`4d7f38fa1`](https://github.com/sveltejs/kit/commit/4d7f38fa18c75991bca3f723cdc50d8a67036f83), [`42c9b935e`](https://github.com/sveltejs/kit/commit/42c9b935e49fbbeff7065d1b2a31986c0b814956), [`42c9b935e`](https://github.com/sveltejs/kit/commit/42c9b935e49fbbeff7065d1b2a31986c0b814956)]:\n  - @sveltejs/kit@1.22.0\n\n## 1.3.0\n\n### Minor Changes\n\n- chore: remove build step for adapter node ([#10041](https://github.com/sveltejs/kit/pull/10041))\n\n- feat: load sourcemaps so that they can be merged to point to original sourcefiles ([#10041](https://github.com/sveltejs/kit/pull/10041))\n\n### Patch Changes\n\n- fix: do not crash server if specified `ADDRESS_HEADER` is missing from a request ([#10285](https://github.com/sveltejs/kit/pull/10285))\n\n## 1.2.4\n\n### Patch Changes\n\n- chore: update all dependencies with minor version bumps ([#9761](https://github.com/sveltejs/kit/pull/9761))\n\n## 1.2.3\n\n### Patch Changes\n\n- fix: only send cache header when static resource is 200 ([#9394](https://github.com/sveltejs/kit/pull/9394))\n\n- Updated dependencies [[`385bd49e`](https://github.com/sveltejs/kit/commit/385bd49efb6890078dcdb523fdf5b621fe1c3e72), [`29ffc785`](https://github.com/sveltejs/kit/commit/29ffc78560a99ce387b10a24f48b7f01205f51e7), [`d257d37d`](https://github.com/sveltejs/kit/commit/d257d37d3cac94f30befa9fe38c2987f84fb551a), [`c45c35e7`](https://github.com/sveltejs/kit/commit/c45c35e7b40837cd1bea3fc26cfb831478e03c00), [`75e2c6f7`](https://github.com/sveltejs/kit/commit/75e2c6f7c8376685317b669767c7767fd21670eb), [`1c085780`](https://github.com/sveltejs/kit/commit/1c08578031395377a98b365a27eb9587594dd06e)]:\n  - @sveltejs/kit@1.12.0\n\n## 1.2.2\n\n### Patch Changes\n\n- fix: add `BODY_SIZE_LIMIT` to the list of recognized env variables ([#9326](https://github.com/sveltejs/kit/pull/9326))\n\n- Updated dependencies [[`b575287d`](https://github.com/sveltejs/kit/commit/b575287d063562868d7726f6451352aa43a63453), [`8114c658`](https://github.com/sveltejs/kit/commit/8114c658c0bc053198ff76704c002cfeb8225e2a), [`620f5605`](https://github.com/sveltejs/kit/commit/620f56058de0993e776c146db4c19fca97b9cb39), [`6a91e887`](https://github.com/sveltejs/kit/commit/6a91e887ee4c1bef8aabfafbf1ab6079113c2832), [`1c32723a`](https://github.com/sveltejs/kit/commit/1c32723a52beca0c5aa895b1114341da78d92eaf), [`0f863bbc`](https://github.com/sveltejs/kit/commit/0f863bbc957ab2ed37b04ebd839fc864b945034d), [`78b4a1bb`](https://github.com/sveltejs/kit/commit/78b4a1bb5e1ae11a894d70a0a28cc344ea0b1284), [`66b2f4ef`](https://github.com/sveltejs/kit/commit/66b2f4ef03a5dd60da2757edde4effcfdf3183cf), [`5dada256`](https://github.com/sveltejs/kit/commit/5dada256dc05674a18946f8f19db1f25ba91aeaf), [`a71b5e69`](https://github.com/sveltejs/kit/commit/a71b5e69ef37ce46e8e8590d537036cb7e267d51), [`daad7e48`](https://github.com/sveltejs/kit/commit/daad7e48b175245cbb7efd0e255263bfb52a5ee6), [`18d330b1`](https://github.com/sveltejs/kit/commit/18d330b16330d76c4b2991839c6b4462d5a4163f), [`18d7e81a`](https://github.com/sveltejs/kit/commit/18d7e81a9892e718c3cd07b2366a60f2e09561ab)]:\n  - @sveltejs/kit@1.11.0\n\n## 1.2.1\n\n### Patch Changes\n\n- fix: use `node` export condition when bundling ([#9276](https://github.com/sveltejs/kit/pull/9276))\n\n- Updated dependencies [[`1e2c8269`](https://github.com/sveltejs/kit/commit/1e2c82697d501c88c6027722ea9b106e09a0eb6d)]:\n  - @sveltejs/kit@1.9.3\n\n## 1.2.0\n\n### Minor Changes\n\n- add polyfill option ([#8991](https://github.com/sveltejs/kit/pull/8991))\n\n### Patch Changes\n\n- Updated dependencies [[`74cfa8d5`](https://github.com/sveltejs/kit/commit/74cfa8d5f1f13f81759e20e90f4ff86a4f96040d), [`bfa2b6ec`](https://github.com/sveltejs/kit/commit/bfa2b6ec88a6d522d87c924d7c466c01e142e66e)]:\n  - @sveltejs/kit@1.5.6\n\n## 1.1.8\n\n### Patch Changes\n\n- fix: use `strictRequires: true` when bundling output ([#8958](https://github.com/sveltejs/kit/pull/8958))\n\n- Updated dependencies [[`0abb8ebf`](https://github.com/sveltejs/kit/commit/0abb8ebffc6121f81c2bbfa0a0f68866d4cc1627), [`bef54f63`](https://github.com/sveltejs/kit/commit/bef54f63d2315066d30e8f1bcf471ddf2bd72c35), [`51cd6e64`](https://github.com/sveltejs/kit/commit/51cd6e643178e3a113fc2c3e8a63755bcbfe902d), [`930c8e4e`](https://github.com/sveltejs/kit/commit/930c8e4ee2e3046ed1b622777dafa23029a19fe5), [`ee8066fc`](https://github.com/sveltejs/kit/commit/ee8066fcb29ed1e7e3ab513cabb7997e38c984f2), [`49d2ec62`](https://github.com/sveltejs/kit/commit/49d2ec62e6385694f11701bf2fa411d07449344c), [`eb943565`](https://github.com/sveltejs/kit/commit/eb943565a4324dbed3da5a581924ca91a24366de)]:\n  - @sveltejs/kit@1.5.3\n\n## 1.1.7\n\n### Patch Changes\n\n- fix: make serve_prerendered middleware work with node http server ([#8890](https://github.com/sveltejs/kit/pull/8890))\n\n- Updated dependencies [[`c7648f66`](https://github.com/sveltejs/kit/commit/c7648f6608a413e2654625cbd30f890d2148cf13), [`63613bf1`](https://github.com/sveltejs/kit/commit/63613bf194c18ce50e111585ad770fc93f9e43c7), [`d1f7655e`](https://github.com/sveltejs/kit/commit/d1f7655efdff70d91f94fe0cb0de50ed2511b5e5)]:\n  - @sveltejs/kit@1.5.0\n\n## 1.1.6\n\n### Patch Changes\n\n- fix: correctly redirect trailing slashes for `adapter-node` ([#8857](https://github.com/sveltejs/kit/pull/8857))\n\n## 1.1.5\n\n### Patch Changes\n\n- docs: fix link in README ([#8854](https://github.com/sveltejs/kit/pull/8854))\n\n- Updated dependencies [[`7cdb7a65`](https://github.com/sveltejs/kit/commit/7cdb7a65819342c6d334c79defc697d531d5cbf4)]:\n  - @sveltejs/kit@1.3.10\n\n## 1.1.4\n\n### Patch Changes\n\n- docs: move adapter docs to site ([#8531](https://github.com/sveltejs/kit/pull/8531))\n\n## 1.1.3\n\n### Patch Changes\n\n- fix: publish missing files ([#8532](https://github.com/sveltejs/kit/pull/8532))\n\n## 1.1.2\n\n### Patch Changes\n\n- chore: remove superfluous main field from package.json ([#8519](https://github.com/sveltejs/kit/pull/8519))\n\n- Updated dependencies [[`7e2d3405`](https://github.com/sveltejs/kit/commit/7e2d34056e99f371e22406d941b764df365a2649)]:\n  - @sveltejs/kit@1.1.1\n\n## 1.1.1\n\n### Patch Changes\n\n- docs: add info about custom cleanup before server exits ([#8455](https://github.com/sveltejs/kit/pull/8455))\n\n- Updated dependencies [[`9c01c32e`](https://github.com/sveltejs/kit/commit/9c01c32ef72bbed630fadcb8283f8f8533ced5e1), [`b6ca02a6`](https://github.com/sveltejs/kit/commit/b6ca02a684dbf13a3138b552e2d2be64697f2254), [`130abe43`](https://github.com/sveltejs/kit/commit/130abe43cef2cfbaf922aa16b20cbd4332a07c15), [`c4137536`](https://github.com/sveltejs/kit/commit/c4137536f2c6572eaeec1a82ccea0852f5be6b98), [`40464efa`](https://github.com/sveltejs/kit/commit/40464efab172a17f0b637d7dadea30d77ef1ed10), [`ce028470`](https://github.com/sveltejs/kit/commit/ce0284708184198efdd30f3ff72fd579cef830b4)]:\n  - @sveltejs/kit@1.0.12\n\n## 1.1.0\n\n### Minor Changes\n\n- feat: add original request object as `event.platform.req` ([#8171](https://github.com/sveltejs/kit/pull/8171))\n\n### Patch Changes\n\n- Updated dependencies [[`5426901a`](https://github.com/sveltejs/kit/commit/5426901a710f5e412bd8d3bf2c78bd9df283b2a2)]:\n  - @sveltejs/kit@1.0.5\n\n## 1.0.1\n\n### Patch Changes\n\n- chore: update dependency @rollup/plugin-json to v6 ([#8204](https://github.com/sveltejs/kit/pull/8204))\n  - Note: plugin-json v6 fails your build for parse errors that only logged a warning with v5. We consider this a bugfix as only healthy input should result in a successful build.\n- chore(deps): update dependency @rollup/plugin-commonjs to v24 ([#8216](https://github.com/sveltejs/kit/pull/8216))\n- Updated dependencies [[`fab0de4f`](https://github.com/sveltejs/kit/commit/fab0de4f06ac5b1e9b049e106889b193975c1c29), [`89b8d94b`](https://github.com/sveltejs/kit/commit/89b8d94b1b20d586e1ca525c30d07587c3f2d8f2)]:\n  - @sveltejs/kit@1.0.2\n\n## 1.0.0\n\n### Major Changes\n\nFirst major release, see below for the history of changes that lead up to this.\nStarting from now all releases follow semver and changes will be listed as Major/Minor/Patch\n\n## 1.0.0-next.106\n\n### Patch Changes\n\n- breaking: remove warnings/errors about removed/changed APIs ([#8019](https://github.com/sveltejs/kit/pull/8019))\n- Updated dependencies [[`f42604a2`](https://github.com/sveltejs/kit/commit/f42604a2b4c04026d3d8bad95807720b79529539)]:\n  - @sveltejs/kit@1.0.0-next.589\n\n## 1.0.0-next.105\n\n### Patch Changes\n\n- chore: add peerDependencies, add more specific next version ([#8141](https://github.com/sveltejs/kit/pull/8141))\n\n## 1.0.0-next.104\n\n### Patch Changes\n\n- update rollup to ^3.7.0 ([#7543](https://github.com/sveltejs/kit/pull/7543))\n\n## 1.0.0-next.103\n\n### Patch Changes\n\n- Update docs with example of loading environment variables ([#8020](https://github.com/sveltejs/kit/pull/8020))\n\n## 1.0.0-next.102\n\n### Patch Changes\n\n- docs: update reference to `getClientAddress()` ([#7907](https://github.com/sveltejs/kit/pull/7907))\n\n## 1.0.0-next.101\n\n### Patch Changes\n\n- Update docs ([#7744](https://github.com/sveltejs/kit/pull/7744))\n\n## 1.0.0-next.100\n\n### Patch Changes\n\n- update dependencies ([#7355](https://github.com/sveltejs/kit/pull/7355))\n\n## 1.0.0-next.99\n\n### Patch Changes\n\n- fix: take into account deep exports for external packages ([#7311](https://github.com/sveltejs/kit/pull/7311))\n\n## 1.0.0-next.98\n\n### Patch Changes\n\n- Use config.kit.paths.base prefix for static assets ([#4448](https://github.com/sveltejs/kit/pull/4448))\n\n## 1.0.0-next.97\n\n### Patch Changes\n\n- chore: update dependency @rollup/plugin-json to v5 ([#7204](https://github.com/sveltejs/kit/pull/7204))\n\n## 1.0.0-next.96\n\n### Patch Changes\n\n- Disable builtin modules warning ([#7031](https://github.com/sveltejs/kit/pull/7031))\n\n## 1.0.0-next.95\n\n### Patch Changes\n\n- Redact error message if `getRequest` fails ([#6936](https://github.com/sveltejs/kit/pull/6936))\n\n## 1.0.0-next.94\n\n### Patch Changes\n\n- Add missing Rollup dependency ([#6927](https://github.com/sveltejs/kit/pull/6927))\n\n## 1.0.0-next.93\n\n### Patch Changes\n\n- Bundle with rollup instead of esbuild ([#6896](https://github.com/sveltejs/kit/pull/6896))\n\n## 1.0.0-next.92\n\n### Patch Changes\n\n- chore: bump esbuild ([#6829](https://github.com/sveltejs/kit/pull/6829))\n\n## 1.0.0-next.91\n\n### Patch Changes\n\n- Allow streaming when `BODY_SIZE_LIMIT` is set ([#6702](https://github.com/sveltejs/kit/pull/6702))\n\n## 1.0.0-next.90\n\n### Patch Changes\n\n- Update to esbuild 0.15 ([#6740](https://github.com/sveltejs/kit/pull/6740))\n- Improve performance by compressing in parallel ([#6710](https://github.com/sveltejs/kit/pull/6710))\n\n## 1.0.0-next.89\n\n### Patch Changes\n\n- breaking: request creation cleanup ([#6681](https://github.com/sveltejs/kit/pull/6681))\n- breaking: limit adapter-node request size ([#6684](https://github.com/sveltejs/kit/pull/6684))\n\n## 1.0.0-next.88\n\n### Patch Changes\n\n- Bundle non-production dependencies with esbuild ([#6372](https://github.com/sveltejs/kit/pull/6372))\n\n## 1.0.0-next.87\n\n### Patch Changes\n\n- feat: Moved hooks.js initialization from Server.respond into Server.init ([#6179](https://github.com/sveltejs/kit/pull/6179))\n\n## 1.0.0-next.86\n\n### Patch Changes\n\n- Move `compress` logic to `Builder` API ([#5822](https://github.com/sveltejs/kit/pull/5822))\n\n## 1.0.0-next.85\n\n### Patch Changes\n\n- Initialise `env` ([#5663](https://github.com/sveltejs/kit/pull/5663))\n\n## 1.0.0-next.84\n\n### Patch Changes\n\n- Set Vite's publicDir and correctly serve public assets earlier in pipeline ([#5686](https://github.com/sveltejs/kit/pull/5686))\n\n## 1.0.0-next.83\n\n### Patch Changes\n\n- set Vite's `publicDir` option ([#5648](https://github.com/sveltejs/kit/pull/5648))\n\n## 1.0.0-next.82\n\n### Patch Changes\n\n- breaking: remove writeStatic to align with Vite ([#5618](https://github.com/sveltejs/kit/pull/5618))\n\n## 1.0.0-next.81\n\n### Patch Changes\n\n- breaking: remove compression middleware from adapter-node output server ([#5506](https://github.com/sveltejs/kit/pull/5506))\n\n## 1.0.0-next.80\n\n### Patch Changes\n\n- Update dependencies ([#5005](https://github.com/sveltejs/kit/pull/5005))\n\n## 1.0.0-next.79\n\n### Patch Changes\n\n- chore: upgrade TypeScript to 4.7.4 ([#5414](https://github.com/sveltejs/kit/pull/5414))\n\n## 1.0.0-next.78\n\n### Patch Changes\n\n- Update dependencies ([#5121](https://github.com/sveltejs/kit/pull/5121))\n\n## 1.0.0-next.77\n\n### Patch Changes\n\n- Update adapter entrypoint typings to be NodeNext/ESNext-compatible ([#5111](https://github.com/sveltejs/kit/pull/5111))\n\n## 1.0.0-next.76\n\n### Patch Changes\n\n- only serve `_app/immutable` with immutable cache header, not `_app/version.json` ([#5051](https://github.com/sveltejs/kit/pull/5051))\n\n## 1.0.0-next.75\n\n### Patch Changes\n\n- Add types to pkg.exports ([#5045](https://github.com/sveltejs/kit/pull/5045))\n\n## 1.0.0-next.74\n\n### Patch Changes\n\n- breaking: replace @sveltejs/kit/install-fetch with @sveltejs/kit/node/polyfills ([#4934](https://github.com/sveltejs/kit/pull/4934))\n\n## 1.0.0-next.73\n\n### Patch Changes\n\n- breaking: rename `xForwardedForIndex` to `XFF_DEPTH` and make it an environment variable ([#4332](https://github.com/sveltejs/kit/pull/4332))\n- breaking: Replace `options.env` with `options.envPrefix` ([#4360](https://github.com/sveltejs/kit/pull/4360))\n\n## 1.0.0-next.72\n\n### Patch Changes\n\n- Provide getClientAddress function ([#4289](https://github.com/sveltejs/kit/pull/4289))\n\n## 1.0.0-next.71\n\n### Patch Changes\n\n- breaking: replace builder.prerender() with builder.writePrerendered() and builder.prerendered ([#4192](https://github.com/sveltejs/kit/pull/4192)) ([#4229](https://github.com/sveltejs/kit/pull/4229))\n\n## 1.0.0-next.70\n\n### Patch Changes\n\n- Rename `__fetch_polyfill` to `installFetch` ([#4111](https://github.com/sveltejs/kit/pull/4111))\n\n## 1.0.0-next.69\n\n### Patch Changes\n\n- breaking: rename `app.render` to `server.respond` ([#4034](https://github.com/sveltejs/kit/pull/4034))\n\n## 1.0.0-next.68\n\n### Patch Changes\n\n- `precompress` option also compress wasm files ([#3812](https://github.com/sveltejs/kit/pull/3812))\n\n## 1.0.0-next.67\n\n### Patch Changes\n\n- Bump version to trigger rebuild with set-cookie support ([#3529](https://github.com/sveltejs/kit/pull/3529))\n\n## 1.0.0-next.66\n\n### Patch Changes\n\n- fix usage of `ORIGIN` environment variable ([#3448](https://github.com/sveltejs/kit/pull/3448))\n\n## 1.0.0-next.65\n\n### Patch Changes\n\n- fix: rename `BASE` to `ORIGIN` and fix config handling ([#3423](https://github.com/sveltejs/kit/pull/3423))\n\n## 1.0.0-next.64\n\n### Patch Changes\n\n- breaking: change app.render signature to (request: Request) => Promise<Response> ([#3384](https://github.com/sveltejs/kit/pull/3384))\n- breaking: Remove protocol/host configuration options from Kit to adapter-node ([#3384](https://github.com/sveltejs/kit/pull/3384))\n\n## 1.0.0-next.63\n\n### Patch Changes\n\n- Polyfill fetch before running any app code ([#3400](https://github.com/sveltejs/kit/pull/3400))\n\n## 1.0.0-next.62\n\n### Patch Changes\n\n- Allow `__fetchPolyfill()` to run several times ([#3377](https://github.com/sveltejs/kit/pull/3377))\n\n## 1.0.0-next.61\n\n### Patch Changes\n\n- chore: update dependency sirv to v2 ([#3263](https://github.com/sveltejs/kit/pull/3263))\n\n## 1.0.0-next.60\n\n### Patch Changes\n\n- Don't cache non-hashed static assets in adapter-node ([#3193](https://github.com/sveltejs/kit/pull/3193))\n- Only set cache-control: immutable when appropriate ([#3196](https://github.com/sveltejs/kit/pull/3196))\n\n## 1.0.0-next.59\n\n### Patch Changes\n\n- Fix types ([#3181](https://github.com/sveltejs/kit/pull/3181))\n- Check if directory exists, before compressing ([#3179](https://github.com/sveltejs/kit/pull/3179))\n\n## 1.0.0-next.58\n\n### Patch Changes\n\n- fix: only add handlers for directories that exist ([#3148](https://github.com/sveltejs/kit/pull/3148))\n\n## 1.0.0-next.57\n\n### Patch Changes\n\n- Overhaul adapter API ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- Update adapters to provide app.render with a url ([#3133](https://github.com/sveltejs/kit/pull/3133))\n- Don't bundle final output ([#2931](https://github.com/sveltejs/kit/pull/2931))\n\n## 1.0.0-next.56\n\n### Patch Changes\n\n- update to esbuild 0.13.15 and other dependency updates ([#2957](https://github.com/sveltejs/kit/pull/2957))\n\n## 1.0.0-next.55\n\n### Patch Changes\n\n- breaking: drop Node 12 support ([#2604](https://github.com/sveltejs/kit/pull/2604))\n\n## 1.0.0-next.54\n\n### Patch Changes\n\n- update dependencies ([#2574](https://github.com/sveltejs/kit/pull/2574))\n\n## 1.0.0-next.53\n\n### Patch Changes\n\n- Don't crash when receiving malformed URLs ([#2533](https://github.com/sveltejs/kit/pull/2533))\n\n## 1.0.0-next.52\n\n### Patch Changes\n\n- update to vite 2.6.0 and esbuild 0.13 ([#2522](https://github.com/sveltejs/kit/pull/2522))\n\n## 1.0.0-next.51\n\n### Patch Changes\n\n- fix: regression where builds not using `entryPoint` stopped having `middlewares.js` external ([#2484](https://github.com/sveltejs/kit/pull/2484))\n\n## 1.0.0-next.50\n\n### Patch Changes\n\n- fix: Correctly treat `middlewares.js` as external when using `entryPoint` option ([#2482](https://github.com/sveltejs/kit/pull/2482))\n\n## 1.0.0-next.49\n\n### Patch Changes\n\n- update dependencies ([#2447](https://github.com/sveltejs/kit/pull/2447))\n\n## 1.0.0-next.48\n\n### Patch Changes\n\n- chore: add links to repository and homepage to package.json ([#2425](https://github.com/sveltejs/kit/pull/2425))\n\n## 1.0.0-next.47\n\n### Patch Changes\n\n- feat: add entryPoint option for custom servers ([#2414](https://github.com/sveltejs/kit/pull/2414))\n\n## 1.0.0-next.46\n\n### Patch Changes\n\n- Clear output directory before adapting ([#2388](https://github.com/sveltejs/kit/pull/2388))\n\n## 1.0.0-next.45\n\n### Patch Changes\n\n- chore: export package.json from adapters ([#2351](https://github.com/sveltejs/kit/pull/2351))\n\n## 1.0.0-next.44\n\n### Patch Changes\n\n- feat: expose handler to allow use in custom server\n\n## 1.0.0-next.43\n\n### Patch Changes\n\n- fix: provide default port only if path not provided ([#2244](https://github.com/sveltejs/kit/pull/2244))\n\n## 1.0.0-next.42\n\n### Patch Changes\n\n- fix: bump polka and sirv again to address unicode handling bug\n\n## 1.0.0-next.41\n\n### Patch Changes\n\n- fix: upgrade polka and sirv. fixes handling of URLs with unicode characters ([#2191](https://github.com/sveltejs/kit/pull/2191))\n\n## 1.0.0-next.40\n\n### Patch Changes\n\n- fix: handle paths consistently between dev and various production adapters ([#2171](https://github.com/sveltejs/kit/pull/2171))\n\n* [feat] allow node adapter to configure listen path ([#2048](https://github.com/sveltejs/kit/pull/2048))\n\n## 1.0.0-next.39\n\n### Patch Changes\n\n- 94b34fa6: [breaking] standardize final output dir as /build (vs /.svelte-kit) ([#2109](https://github.com/sveltejs/kit/pull/2109))\n\n## 1.0.0-next.38\n\n### Patch Changes\n\n- a12beb04: [fix] update broken file path ([#2096](https://github.com/sveltejs/kit/pull/2096))\n\n## 1.0.0-next.37\n\n### Patch Changes\n\n- b3e7c8b3: [chore] update build output location ([#2082](https://github.com/sveltejs/kit/pull/2082))\n\n## 1.0.0-next.36\n\n### Patch Changes\n\n- d81de603: revert adapters automatically updating .gitignore ([#1924](https://github.com/sveltejs/kit/pull/1924))\n\n## 1.0.0-next.35\n\n### Patch Changes\n\n- e9f78999: fix: include esbuild config in adapter type definition ([#1954](https://github.com/sveltejs/kit/pull/1954))\n\n## 1.0.0-next.34\n\n### Patch Changes\n\n- e6995797: feat(adapters): expose esbuild configuration ([#1914](https://github.com/sveltejs/kit/pull/1914))\n\n## 1.0.0-next.33\n\n### Patch Changes\n\n- 463199c: Handle Uint8Array bodies from endpoints ([#1875](https://github.com/sveltejs/kit/pull/1875))\n- 0db0889: log both host and port ([#1877](https://github.com/sveltejs/kit/pull/1877))\n\n## 1.0.0-next.32\n\n### Patch Changes\n\n- 2ac5781: Use esbuild inject API to insert shims ([#1822](https://github.com/sveltejs/kit/pull/1822))\n\n## 1.0.0-next.31\n\n### Patch Changes\n\n- c639586: Check if '[out]/prerendered' exists, before precompressing ([#1806](https://github.com/sveltejs/kit/pull/1806))\n\n## 1.0.0-next.30\n\n### Patch Changes\n\n- 9f0c54a: Externalize app initialization to adapters ([#1804](https://github.com/sveltejs/kit/pull/1804))\n\n## 1.0.0-next.29\n\n### Patch Changes\n\n- aa5cf15: Fix regression caused by writing `env.js` to the wrong path ([#1756](https://github.com/sveltejs/kit/pull/1756))\n\n## 1.0.0-next.28\n\n### Patch Changes\n\n- 1c8bdba: Allow the environment variables containing the host and port to serve on to be customised ([#1754](https://github.com/sveltejs/kit/pull/1754))\n\n## 1.0.0-next.27\n\n### Patch Changes\n\n- 926481f: precompress assets and prerendered pages (html,js,json,css,svg,xml) ([#1693](https://github.com/sveltejs/kit/pull/1693))\n- 318cdd7: Only cache files in config.kit.appDir ([#1416](https://github.com/sveltejs/kit/pull/1416))\n\n## 1.0.0-next.26\n\n### Patch Changes\n\n- 9a7195b: Allow sirv to looks for precompiled gzip and brotli files by default ([#1672](https://github.com/sveltejs/kit/pull/1672))\n- 53f3322: Fix build when using TypeScript and there is a `tsconfig.json` with `target: 'es2019'` or earlier ([#1675](https://github.com/sveltejs/kit/pull/1675))\n\n## 1.0.0-next.25\n\n### Patch Changes\n\n- 0b780a6: Bundle server-side app during adapt phase ([#1648](https://github.com/sveltejs/kit/pull/1648))\n\n## 1.0.0-next.24\n\n### Patch Changes\n\n- edc307d: Remove peerDependencies due to pnpm bug ([#1621](https://github.com/sveltejs/kit/pull/1621))\n- 2636e68: Attempt to fix peerDependencies specification ([#1620](https://github.com/sveltejs/kit/pull/1620))\n\n## 1.0.0-next.23\n\n### Patch Changes\n\n- c3d36a3: ensure `content-length` limit respected; handle `getRawBody` error(s) ([#1528](https://github.com/sveltejs/kit/pull/1528))\n- bf77940: bump `polka` and `sirv` dependency versions ([#1548](https://github.com/sveltejs/kit/pull/1548))\n- 028abd9: Pass validated svelte config to adapter adapt function ([#1559](https://github.com/sveltejs/kit/pull/1559))\n- Updated dependencies [6372690]\n- Updated dependencies [c3d36a3]\n- Updated dependencies [bf77940]\n- Updated dependencies [2172469]\n- Updated dependencies [028abd9]\n  - @sveltejs/kit@1.0.0-next.110\n\n## 1.0.0-next.22\n\n### Patch Changes\n\n- dca4946: Make kit a peerDependency of the adapters ([#1505](https://github.com/sveltejs/kit/pull/1505))\n- Updated dependencies [261ee1c]\n- Updated dependencies [ec156c6]\n- Updated dependencies [586785d]\n  - @sveltejs/kit@1.0.0-next.109\n\n## 1.0.0-next.21\n\n### Patch Changes\n\n- dad93fc: Fix workspace dependencies ([#1434](https://github.com/sveltejs/kit/pull/1434))\n\n## 1.0.0-next.20\n\n### Patch Changes\n\n- 9b448a6: Rename @sveltejs/kit/http to @sveltejs/kit/node ([#1391](https://github.com/sveltejs/kit/pull/1391))\n\n## 1.0.0-next.19\n\n### Patch Changes\n\n- 0e09581: Make host configurable via process.env.HOST ([#1366](https://github.com/sveltejs/kit/pull/1366))\n\n## 1.0.0-next.18\n\n### Patch Changes\n\n- c6fde99: Convert to ESM ([#1323](https://github.com/sveltejs/kit/pull/1323))\n\n## 1.0.0-next.17\n\n### Patch Changes\n\n- 2e72a94: Add type declarations ([#1230](https://github.com/sveltejs/kit/pull/1230))\n\n## 1.0.0-next.16\n\n### Patch Changes\n\n- 1237eb3: Use getRawBody ([#1109](https://github.com/sveltejs/kit/pull/1109))\n\n## 1.0.0-next.15\n\n### Patch Changes\n\n- 7a4b351: Use install-fetch helper ([#1091](https://github.com/sveltejs/kit/pull/1091))\n\n## 1.0.0-next.14\n\n### Patch Changes\n\n- 8e61e84: Include missing entrypoint ([#1071](https://github.com/sveltejs/kit/pull/1071))\n\n## 1.0.0-next.13\n\n### Patch Changes\n\n- 6e27880: Move server-side fetch to adapters instead of build step ([#1066](https://github.com/sveltejs/kit/pull/1066))\n\n## 1.0.0-next.12\n\n### Patch Changes\n\n- feb2db7: Fix fatal error when trying to parse URLs of incoming requests ([#802](https://github.com/sveltejs/kit/pull/802))\n\n## 1.0.0-next.11\n\n### Patch Changes\n\n- ca33a35: Fix adapter-vercel query parsing and update adapter-node's ([#774](https://github.com/sveltejs/kit/pull/774))\n\n## 1.0.0-next.10\n\n### Patch Changes\n\n- 8024178: remove @sveltejs/app-utils ([#600](https://github.com/sveltejs/kit/pull/600))\n\n## 1.0.0-next.9\n\n### Patch Changes\n\n- 8805c6d: Pass adapters directly to svelte.config.cjs ([#579](https://github.com/sveltejs/kit/pull/579))\n\n## 1.0.0-next.8\n\n### Patch Changes\n\n- 9212aa5: Add options to adapter-node, and add adapter types ([#531](https://github.com/sveltejs/kit/pull/531))\n\n## 1.0.0-next.7\n\n### Patch Changes\n\n- f35a5cd: Change adapter signature ([#505](https://github.com/sveltejs/kit/pull/505))\n\n## 1.0.0-next.6\n\n### Patch Changes\n\n- c3cf3f3: Bump deps ([#492](https://github.com/sveltejs/kit/pull/492))\n\n## 1.0.0-next.5\n\n### Patch Changes\n\n- 222fe9d: Compress adapter-node responses ([#367](https://github.com/sveltejs/kit/pull/367))\n\n## 1.0.0-next.4\n\n### Patch Changes\n\n- Make adapter node work under esm\n\n## 1.0.0-next.3\n\n### Patch Changes\n\n- ab2367d: Convert to ESM ([#387](https://github.com/sveltejs/kit/pull/387))\n\n## 1.0.0-next.2\n\n### Patch Changes\n\n- Fix adapters and convert to ES modules\n\n## 1.0.0-next.1\n\n### Patch Changes\n\n- 13e8fa3: Make adapter-node work\n\n## 0.0.18\n\n### Patch Changes\n\n- b3ac507: Add missing pkg.files\n\n## 0.0.17\n\n### Patch Changes\n\n- Add svelte-kit start command\n\n## 0.0.16\n\n### Patch Changes\n\n- Make paths and target configurable\n\n## 0.0.15\n\n### Patch Changes\n\n- b475ed4: Overhaul adapter API - fixes #166 ([#180](https://github.com/sveltejs/kit/pull/180))\n- Updated dependencies [b475ed4]\n  - @sveltejs/app-utils@0.0.18\n\n## 0.0.14\n\n### Patch Changes\n\n- Updated dependencies [3bdf33b]\n  - @sveltejs/app-utils@0.0.17\n\n## 0.0.13\n\n### Patch Changes\n\n- 67eaeea: Move app-utils stuff into subpackages\n- Updated dependencies [67eaeea]\n  - @sveltejs/app-utils@0.0.16\n\n## 0.0.12\n\n### Patch Changes\n\n- a163000: Parse body on incoming requests\n- Updated dependencies [a163000]\n  - @sveltejs/app-utils@0.0.15\n\n## 0.0.11\n\n### Patch Changes\n\n- Use setup module\n- Updated dependencies [undefined]\n- Updated dependencies [undefined]\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.14\n\n## 0.0.10\n\n### Patch Changes\n\n- Updated dependencies [undefined]\n- Updated dependencies [96c06d8]\n  - @sveltejs/app-utils@0.0.13\n\n## 0.0.9\n\n### Patch Changes\n\n- 0320208: Rename 'server route' to 'endpoint'\n- 026acd2: Accommodate missing build/prerendered directory\n- 8b63057: Let sirv add must-revalidate\n- Updated dependencies [0320208]\n- Updated dependencies [5ca907c]\n  - @sveltejs/app-utils@0.0.12\n\n## 0.0.8\n\n### Patch Changes\n\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.11\n\n## 0.0.7\n\n### Patch Changes\n\n- 19323e9: Fix prerendering\n- Updated dependencies [19323e9]\n  - @sveltejs/app-utils@0.0.10\n\n## 0.0.6\n\n### Patch Changes\n\n- Updated dependencies [90a98ae]\n  - @sveltejs/app-utils@0.0.9\n\n## 0.0.5\n\n### Patch Changes\n\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.8\n\n## 0.0.4\n\n### Patch Changes\n\n- various\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.7\n"
  },
  {
    "path": "packages/adapter-node/LICENSE",
    "content": "Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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."
  },
  {
    "path": "packages/adapter-node/README.md",
    "content": "# @sveltejs/adapter-node\n\n[Adapter](https://svelte.dev/docs/kit/adapters) for SvelteKit apps that generates a standalone Node server.\n\n## Docs\n\n[Docs](https://svelte.dev/docs/kit/adapter-node)\n\n## Changelog\n\n[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/adapter-node/CHANGELOG.md).\n\n## License\n\n[MIT](LICENSE)\n"
  },
  {
    "path": "packages/adapter-node/ambient.d.ts",
    "content": "import http from 'node:http';\n\ndeclare global {\n\tnamespace App {\n\t\texport interface Platform {\n\t\t\t/**\n\t\t\t * The original Node request object (https://nodejs.org/api/http.html#class-httpincomingmessage)\n\t\t\t */\n\t\t\treq: http.IncomingMessage;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-node/index.d.ts",
    "content": "import { Adapter } from '@sveltejs/kit';\nimport './ambient.js';\n\ndeclare global {\n\tconst ENV_PREFIX: string;\n\tconst PRECOMPRESS: boolean;\n}\n\ninterface AdapterOptions {\n\tout?: string;\n\tprecompress?: boolean;\n\tenvPrefix?: string;\n}\n\nexport default function plugin(options?: AdapterOptions): Adapter;\n"
  },
  {
    "path": "packages/adapter-node/index.js",
    "content": "import { readFileSync, writeFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { rollup } from 'rollup';\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\n\n/**\n * @template T\n * @template {keyof T} K\n * @typedef {Partial<Omit<T, K>> & Required<Pick<T, K>>} PartialExcept\n */\n\n/**\n * We use a custom `Builder` type here to support the minimum version of SvelteKit.\n * @typedef {PartialExcept<import('@sveltejs/kit').Builder, 'log' | 'rimraf' | 'mkdirp' | 'config' | 'prerendered' | 'routes' | 'createEntries' | 'findServerAssets' | 'generateFallback' | 'generateEnvModule' | 'generateManifest' | 'getBuildDirectory' | 'getClientDirectory' | 'getServerDirectory' | 'getAppPath' | 'writeClient' | 'writePrerendered' | 'writePrerendered' | 'writeServer' | 'copy' | 'compress'>} Builder2_4_0\n */\n\nconst files = fileURLToPath(new URL('./files', import.meta.url).href);\n\n/** @type {import('./index.js').default} */\nexport default function (opts = {}) {\n\tconst { out = 'build', precompress = true, envPrefix = '' } = opts;\n\n\treturn {\n\t\tname: '@sveltejs/adapter-node',\n\t\t/** @param {Builder2_4_0} builder */\n\t\tasync adapt(builder) {\n\t\t\tconst tmp = builder.getBuildDirectory('adapter-node');\n\n\t\t\tbuilder.rimraf(out);\n\t\t\tbuilder.rimraf(tmp);\n\t\t\tbuilder.mkdirp(tmp);\n\n\t\t\tbuilder.log.minor('Copying assets');\n\t\t\tbuilder.writeClient(`${out}/client${builder.config.kit.paths.base}`);\n\t\t\tbuilder.writePrerendered(`${out}/prerendered${builder.config.kit.paths.base}`);\n\n\t\t\tif (precompress) {\n\t\t\t\tbuilder.log.minor('Compressing assets');\n\t\t\t\tawait Promise.all([\n\t\t\t\t\tbuilder.compress(`${out}/client`),\n\t\t\t\t\tbuilder.compress(`${out}/prerendered`)\n\t\t\t\t]);\n\t\t\t}\n\n\t\t\tbuilder.log.minor('Building server');\n\n\t\t\tbuilder.writeServer(tmp);\n\n\t\t\twriteFileSync(\n\t\t\t\t`${tmp}/manifest.js`,\n\t\t\t\t[\n\t\t\t\t\t`export const manifest = ${builder.generateManifest({ relativePath: './' })};`,\n\t\t\t\t\t`export const prerendered = new Set(${JSON.stringify(builder.prerendered.paths)});`,\n\t\t\t\t\t`export const base = ${JSON.stringify(builder.config.kit.paths.base)};`\n\t\t\t\t].join('\\n\\n')\n\t\t\t);\n\n\t\t\tconst pkg = JSON.parse(readFileSync('package.json', 'utf8'));\n\n\t\t\t/** @type {Record<string, string>} */\n\t\t\tconst input = {\n\t\t\t\tindex: `${tmp}/index.js`,\n\t\t\t\tmanifest: `${tmp}/manifest.js`\n\t\t\t};\n\n\t\t\tif (builder.hasServerInstrumentationFile?.()) {\n\t\t\t\tinput['instrumentation.server'] = `${tmp}/instrumentation.server.js`;\n\t\t\t}\n\n\t\t\t// we bundle the Vite output so that deployments only need\n\t\t\t// their production dependencies. Anything in devDependencies\n\t\t\t// will get included in the bundled code\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput,\n\t\t\t\texternal: [\n\t\t\t\t\t// dependencies could have deep exports, so we need a regex\n\t\t\t\t\t...Object.keys(pkg.dependencies || {}).map((d) => new RegExp(`^${d}(\\\\/.*)?$`))\n\t\t\t\t],\n\t\t\t\tplugins: [\n\t\t\t\t\tnodeResolve({\n\t\t\t\t\t\tpreferBuiltins: true,\n\t\t\t\t\t\texportConditions: ['node']\n\t\t\t\t\t}),\n\t\t\t\t\t// @ts-ignore https://github.com/rollup/plugins/issues/1329\n\t\t\t\t\tcommonjs({ strictRequires: true }),\n\t\t\t\t\t// @ts-ignore https://github.com/rollup/plugins/issues/1329\n\t\t\t\t\tjson()\n\t\t\t\t]\n\t\t\t});\n\n\t\t\tawait bundle.write({\n\t\t\t\tdir: `${out}/server`,\n\t\t\t\tformat: 'esm',\n\t\t\t\tsourcemap: true,\n\t\t\t\tchunkFileNames: 'chunks/[name]-[hash].js'\n\t\t\t});\n\n\t\t\tbuilder.copy(files, out, {\n\t\t\t\treplace: {\n\t\t\t\t\tENV: './env.js',\n\t\t\t\t\tHANDLER: './handler.js',\n\t\t\t\t\tMANIFEST: './server/manifest.js',\n\t\t\t\t\tSERVER: './server/index.js',\n\t\t\t\t\tSHIMS: './shims.js',\n\t\t\t\t\tENV_PREFIX: JSON.stringify(envPrefix),\n\t\t\t\t\tPRECOMPRESS: JSON.stringify(precompress)\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (builder.hasServerInstrumentationFile?.()) {\n\t\t\t\tbuilder.instrument?.({\n\t\t\t\t\tentrypoint: `${out}/index.js`,\n\t\t\t\t\tinstrumentation: `${out}/server/instrumentation.server.js`,\n\t\t\t\t\tmodule: {\n\t\t\t\t\t\texports: ['path', 'host', 'port', 'server']\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\n\t\tsupports: {\n\t\t\tread: () => true,\n\t\t\tinstrumentation: () => true\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-node/internal.d.ts",
    "content": "declare module 'ENV' {\n\texport function env(key: string, fallback?: any): string;\n\texport function timeout_env(key: string, fallback?: any): number | undefined;\n}\n\ndeclare module 'HANDLER' {\n\texport const handler: import('polka').Middleware;\n}\n\ndeclare module 'MANIFEST' {\n\timport { SSRManifest } from '@sveltejs/kit';\n\n\texport const base: string;\n\texport const manifest: SSRManifest;\n\texport const prerendered: Set<string>;\n}\n\ndeclare module 'SERVER' {\n\texport { Server } from '@sveltejs/kit';\n}\n"
  },
  {
    "path": "packages/adapter-node/package.json",
    "content": "{\n\t\"name\": \"@sveltejs/adapter-node\",\n\t\"version\": \"5.5.4\",\n\t\"description\": \"Adapter for SvelteKit apps that generates a standalone Node server\",\n\t\"keywords\": [\n\t\t\"adapter\",\n\t\t\"deploy\",\n\t\t\"hosting\",\n\t\t\"node.js\",\n\t\t\"svelte\",\n\t\t\"sveltekit\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/sveltejs/kit.git\",\n\t\t\"directory\": \"packages/adapter-node\"\n\t},\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://svelte.dev/docs/kit/adapter-node\",\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./index.d.ts\",\n\t\t\t\"import\": \"./index.js\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"types\": \"index.d.ts\",\n\t\"files\": [\n\t\t\"files\",\n\t\t\"index.js\",\n\t\t\"index.d.ts\",\n\t\t\"ambient.d.ts\"\n\t],\n\t\"scripts\": {\n\t\t\"dev\": \"rollup -cw\",\n\t\t\"build\": \"rollup -c\",\n\t\t\"test\": \"vitest run\",\n\t\t\"check\": \"tsc\",\n\t\t\"lint\": \"prettier --check .\",\n\t\t\"format\": \"pnpm lint --write\",\n\t\t\"prepublishOnly\": \"pnpm build\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@polka/url\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"@types/node\": \"catalog:\",\n\t\t\"polka\": \"catalog:\",\n\t\t\"sirv\": \"^3.0.2\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"dependencies\": {\n\t\t\"@rollup/plugin-commonjs\": \"^29.0.0\",\n\t\t\"@rollup/plugin-json\": \"^6.1.0\",\n\t\t\"@rollup/plugin-node-resolve\": \"^16.0.0\",\n\t\t\"rollup\": \"^4.59.0\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@sveltejs/kit\": \"^2.4.0\"\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-node/rollup.config.js",
    "content": "import { nodeResolve } from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport { builtinModules } from 'node:module';\nimport { rmSync } from 'node:fs';\n\n/**\n * @param {string} filepath\n * @returns {import('rollup').Plugin}\n */\nfunction clearOutput(filepath) {\n\treturn {\n\t\tname: 'clear-output',\n\t\tbuildStart: {\n\t\t\torder: 'pre',\n\t\t\tsequential: true,\n\t\t\thandler() {\n\t\t\t\trmSync(filepath, { recursive: true, force: true });\n\t\t\t}\n\t\t}\n\t};\n}\n\n/**\n * @returns {import('rollup').Plugin}\n */\nfunction prefixBuiltinModules() {\n\treturn {\n\t\tname: 'prefix-built-in-modules',\n\t\tresolveId(source) {\n\t\t\tif (builtinModules.includes(source)) {\n\t\t\t\treturn { id: 'node:' + source, external: true };\n\t\t\t}\n\t\t}\n\t};\n}\n\nexport default [\n\t{\n\t\tinput: 'src/index.js',\n\t\toutput: {\n\t\t\tfile: 'files/index.js',\n\t\t\tformat: 'esm'\n\t\t},\n\t\tplugins: [\n\t\t\tclearOutput('files/index.js'),\n\t\t\tnodeResolve({ preferBuiltins: true }),\n\t\t\tcommonjs(),\n\t\t\tjson(),\n\t\t\tprefixBuiltinModules()\n\t\t],\n\t\texternal: ['ENV', 'HANDLER']\n\t},\n\t{\n\t\tinput: 'src/env.js',\n\t\toutput: {\n\t\t\tfile: 'files/env.js',\n\t\t\tformat: 'esm'\n\t\t},\n\t\tplugins: [\n\t\t\tclearOutput('files/env.js'),\n\t\t\tnodeResolve(),\n\t\t\tcommonjs(),\n\t\t\tjson(),\n\t\t\tprefixBuiltinModules()\n\t\t],\n\t\texternal: ['HANDLER']\n\t},\n\t{\n\t\tinput: 'src/handler.js',\n\t\toutput: {\n\t\t\tfile: 'files/handler.js',\n\t\t\tformat: 'esm',\n\t\t\tinlineDynamicImports: true\n\t\t},\n\t\tplugins: [\n\t\t\tclearOutput('files/handler.js'),\n\t\t\tnodeResolve(),\n\t\t\tcommonjs(),\n\t\t\tjson(),\n\t\t\tprefixBuiltinModules()\n\t\t],\n\t\texternal: ['ENV', 'MANIFEST', 'SERVER', 'SHIMS']\n\t},\n\t{\n\t\tinput: 'src/shims.js',\n\t\toutput: {\n\t\t\tfile: 'files/shims.js',\n\t\t\tformat: 'esm'\n\t\t},\n\t\tplugins: [clearOutput('files/shims.js'), nodeResolve(), commonjs(), prefixBuiltinModules()]\n\t}\n];\n"
  },
  {
    "path": "packages/adapter-node/src/env.js",
    "content": "/* global ENV_PREFIX */\nimport process from 'node:process';\n\nconst expected = new Set([\n\t'SOCKET_PATH',\n\t'HOST',\n\t'PORT',\n\t'ORIGIN',\n\t'XFF_DEPTH',\n\t'ADDRESS_HEADER',\n\t'PROTOCOL_HEADER',\n\t'HOST_HEADER',\n\t'PORT_HEADER',\n\t'BODY_SIZE_LIMIT',\n\t'SHUTDOWN_TIMEOUT',\n\t'IDLE_TIMEOUT',\n\t'KEEP_ALIVE_TIMEOUT',\n\t'HEADERS_TIMEOUT'\n]);\n\nconst expected_unprefixed = new Set(['LISTEN_PID', 'LISTEN_FDS']);\n\nif (ENV_PREFIX) {\n\tfor (const name in process.env) {\n\t\tif (name.startsWith(ENV_PREFIX)) {\n\t\t\tconst unprefixed = name.slice(ENV_PREFIX.length);\n\t\t\tif (!expected.has(unprefixed)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`You should change envPrefix (${ENV_PREFIX}) to avoid conflicts with existing environment variables — unexpectedly saw ${name}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * @param {string} name\n * @param {any} fallback\n */\nexport function env(name, fallback) {\n\tconst prefix = expected_unprefixed.has(name) ? '' : ENV_PREFIX;\n\tconst prefixed = prefix + name;\n\treturn prefixed in process.env ? process.env[prefixed] : fallback;\n}\n\nconst integer_regexp = /^\\d+$/;\n\n/**\n * Throw a consistently-structured parsing error for environment variables.\n * @param {string} name\n * @param {any} value\n * @param {string} description\n * @returns {never}\n */\nfunction parsing_error(name, value, description) {\n\tthrow new Error(\n\t\t`Invalid value for environment variable ${name}: ${JSON.stringify(value)} (${description})`\n\t);\n}\n\n/**\n * Check the environment for a timeout value (non-negative integer) in seconds.\n * @param {string} name\n * @param {number} [fallback]\n * @returns {number | undefined}\n */\nexport function timeout_env(name, fallback) {\n\tconst raw = env(name, fallback);\n\tif (!raw) {\n\t\treturn fallback;\n\t}\n\n\tif (!integer_regexp.test(raw)) {\n\t\tparsing_error(name, raw, 'should be a non-negative integer');\n\t}\n\n\tconst parsed = Number.parseInt(raw, 10);\n\n\t// We don't technically need to check `Number.isNaN` because the value already passed the regexp test.\n\t// However, just in case there's some new codepath introduced somewhere down the line, it's probably good\n\t// to stick this in here.\n\tif (Number.isNaN(parsed)) {\n\t\tparsing_error(name, raw, 'should be a non-negative integer');\n\t}\n\n\tif (parsed < 0) {\n\t\tparsing_error(name, raw, 'should be a non-negative integer');\n\t}\n\n\treturn parsed;\n}\n"
  },
  {
    "path": "packages/adapter-node/src/handler.js",
    "content": "import 'SHIMS';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport sirv from 'sirv';\nimport { fileURLToPath } from 'node:url';\nimport { parse as polka_url_parser } from '@polka/url';\nimport { getRequest, setResponse, createReadableStream } from '@sveltejs/kit/node';\nimport { Server } from 'SERVER';\nimport { manifest, prerendered, base } from 'MANIFEST';\nimport { env } from 'ENV';\nimport { parse_as_bytes, parse_origin } from '../utils.js';\n\n/* global ENV_PREFIX */\n/* global PRECOMPRESS */\n\nconst server = new Server(manifest);\n\n// parse_origin validates ORIGIN and throws descriptive errors for invalid values\nconst origin = parse_origin(env('ORIGIN', undefined));\n\nconst xff_depth = parseInt(env('XFF_DEPTH', '1'));\nconst address_header = env('ADDRESS_HEADER', '').toLowerCase();\nconst protocol_header = env('PROTOCOL_HEADER', '').toLowerCase();\nconst host_header = env('HOST_HEADER', '').toLowerCase();\nconst port_header = env('PORT_HEADER', '').toLowerCase();\n\nconst body_size_limit = parse_as_bytes(env('BODY_SIZE_LIMIT', '512K'));\n\nif (isNaN(body_size_limit)) {\n\tthrow new Error(\n\t\t`Invalid BODY_SIZE_LIMIT: '${env('BODY_SIZE_LIMIT')}'. Please provide a numeric value.`\n\t);\n}\n\nconst dir = path.dirname(fileURLToPath(import.meta.url));\n\nconst asset_dir = `${dir}/client${base}`;\n\nawait server.init({\n\tenv: /** @type {Record<string, string>} */ (process.env),\n\tread: (file) => createReadableStream(`${asset_dir}/${file}`)\n});\n\n/**\n * @param {string} path\n * @param {boolean} client\n */\nfunction serve(path, client = false) {\n\treturn fs.existsSync(path)\n\t\t? sirv(path, {\n\t\t\t\tetag: true,\n\t\t\t\tgzip: PRECOMPRESS,\n\t\t\t\tbrotli: PRECOMPRESS,\n\t\t\t\tsetHeaders: client\n\t\t\t\t\t? (res, pathname) => {\n\t\t\t\t\t\t\t// only apply to build directory, not e.g. version.json\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpathname.startsWith(`/${manifest.appPath}/immutable/`) &&\n\t\t\t\t\t\t\t\tres.statusCode === 200\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tres.setHeader('cache-control', 'public,max-age=31536000,immutable');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined\n\t\t\t})\n\t\t: undefined;\n}\n\n// required because the static file server ignores trailing slashes\n/** @returns {import('polka').Middleware} */\nfunction serve_prerendered() {\n\tconst handler = serve(path.join(dir, 'prerendered'));\n\n\treturn (req, res, next) => {\n\t\tlet { pathname, search, query } = polka_url_parser(req);\n\n\t\ttry {\n\t\t\tpathname = decodeURIComponent(pathname);\n\t\t} catch {\n\t\t\t// ignore invalid URI\n\t\t}\n\n\t\tif (prerendered.has(pathname)) {\n\t\t\treturn handler?.(req, res, next);\n\t\t}\n\n\t\t// remove or add trailing slash as appropriate\n\t\tlet location = pathname.at(-1) === '/' ? pathname.slice(0, -1) : pathname + '/';\n\t\tif (prerendered.has(location)) {\n\t\t\tif (query) location += search;\n\t\t\tres.writeHead(308, { location }).end();\n\t\t} else {\n\t\t\tvoid next();\n\t\t}\n\t};\n}\n\n/** @type {import('polka').Middleware} */\nconst ssr = async (req, res) => {\n\t/** @type {Request} */\n\tlet request;\n\n\ttry {\n\t\trequest = await getRequest({\n\t\t\tbase: origin || get_origin(req.headers),\n\t\t\trequest: req,\n\t\t\tbodySizeLimit: body_size_limit\n\t\t});\n\t} catch {\n\t\tres.statusCode = 400;\n\t\tres.end('Bad Request');\n\t\treturn;\n\t}\n\n\tawait setResponse(\n\t\tres,\n\t\tawait server.respond(request, {\n\t\t\tplatform: { req },\n\t\t\tgetClientAddress: () => {\n\t\t\t\tif (address_header) {\n\t\t\t\t\tif (!(address_header in req.headers)) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Address header was specified with ${\n\t\t\t\t\t\t\t\tENV_PREFIX + 'ADDRESS_HEADER'\n\t\t\t\t\t\t\t}=${address_header} but is absent from request`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst value = /** @type {string} */ (req.headers[address_header]) || '';\n\n\t\t\t\t\tif (address_header === 'x-forwarded-for') {\n\t\t\t\t\t\tconst addresses = value.split(',');\n\n\t\t\t\t\t\tif (xff_depth < 1) {\n\t\t\t\t\t\t\tthrow new Error(`${ENV_PREFIX + 'XFF_DEPTH'} must be a positive integer`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (xff_depth > addresses.length) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`${ENV_PREFIX + 'XFF_DEPTH'} is ${xff_depth}, but only found ${\n\t\t\t\t\t\t\t\t\taddresses.length\n\t\t\t\t\t\t\t\t} addresses`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn addresses[addresses.length - xff_depth].trim();\n\t\t\t\t\t}\n\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\treq.connection?.remoteAddress ||\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treq.connection?.socket?.remoteAddress ||\n\t\t\t\t\treq.socket?.remoteAddress ||\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\treq.info?.remoteAddress\n\t\t\t\t);\n\t\t\t}\n\t\t})\n\t);\n};\n\n/** @param {import('polka').Middleware[]} handlers */\nfunction sequence(handlers) {\n\t/** @type {import('polka').Middleware} */\n\treturn (req, res, next) => {\n\t\t/**\n\t\t * @param {number} i\n\t\t * @returns {ReturnType<import('polka').Middleware>}\n\t\t */\n\t\tfunction handle(i) {\n\t\t\tif (i < handlers.length) {\n\t\t\t\treturn handlers[i](req, res, () => handle(i + 1));\n\t\t\t} else {\n\t\t\t\treturn next();\n\t\t\t}\n\t\t}\n\n\t\treturn handle(0);\n\t};\n}\n\n/**\n * @param {string} name\n * @param {string | string[] | undefined} value\n * @returns {string | undefined}\n */\nfunction normalise_header(name, value) {\n\tif (!name) return undefined;\n\tif (Array.isArray(value)) {\n\t\tif (value.length === 0) return undefined;\n\t\tif (value.length === 1) return value[0];\n\t\tthrow new Error(\n\t\t\t`Multiple values provided for ${name} header where only one expected: ${value}`\n\t\t);\n\t}\n\treturn value;\n}\n\n/**\n * @param {import('http').IncomingHttpHeaders} headers\n * @returns {string}\n */\nfunction get_origin(headers) {\n\tconst protocol = decodeURIComponent(\n\t\tnormalise_header(protocol_header, headers[protocol_header]) || 'https'\n\t);\n\n\t// this helps us avoid host injections through the protocol header\n\tif (protocol.includes(':')) {\n\t\tthrow new Error(\n\t\t\t`The ${protocol_header} header specified ${protocol} which is an invalid because it includes \\`:\\`. It should only contain the protocol scheme (e.g. \\`https\\`)`\n\t\t);\n\t}\n\n\tconst host =\n\t\tnormalise_header(host_header, headers[host_header]) ||\n\t\tnormalise_header('host', headers['host']);\n\tif (!host) {\n\t\tconst header_names = host_header ? `${host_header} or host headers` : 'host header';\n\t\tthrow new Error(\n\t\t\t`Could not determine host. The request must have a value provided by the ${header_names}`\n\t\t);\n\t}\n\n\tconst port = normalise_header(port_header, headers[port_header]);\n\tif (port && isNaN(+port)) {\n\t\tthrow new Error(\n\t\t\t`The ${port_header} header specified ${port} which is an invalid port because it is not a number. The value should only contain the port number (e.g. 443)`\n\t\t);\n\t}\n\n\treturn port ? `${protocol}://${host}:${port}` : `${protocol}://${host}`;\n}\n\nexport const handler = sequence(\n\t/** @type {(import('sirv').RequestHandler | import('polka').Middleware)[]} */\n\t([serve(path.join(dir, 'client'), true), serve_prerendered(), ssr].filter(Boolean))\n);\n"
  },
  {
    "path": "packages/adapter-node/src/index.js",
    "content": "import http from 'node:http';\nimport process from 'node:process';\nimport { handler } from 'HANDLER';\nimport { env, timeout_env } from 'ENV';\nimport polka from 'polka';\n\nexport const path = env('SOCKET_PATH', false);\nexport const host = env('HOST', '0.0.0.0');\nexport const port = env('PORT', !path && '3000');\n\nconst shutdown_timeout = parseInt(env('SHUTDOWN_TIMEOUT', '30'));\nconst idle_timeout = parseInt(env('IDLE_TIMEOUT', '0'));\nconst listen_pid = parseInt(env('LISTEN_PID', '0'));\nconst listen_fds = parseInt(env('LISTEN_FDS', '0'));\n// https://www.freedesktop.org/software/systemd/man/latest/sd_listen_fds.html\nconst SD_LISTEN_FDS_START = 3;\n\nif (listen_pid !== 0 && listen_pid !== process.pid) {\n\tthrow new Error(`received LISTEN_PID ${listen_pid} but current process id is ${process.pid}`);\n}\nif (listen_fds > 1) {\n\tthrow new Error(\n\t\t`only one socket is allowed for socket activation, but LISTEN_FDS was set to ${listen_fds}`\n\t);\n}\n\nconst socket_activation = listen_pid === process.pid && listen_fds === 1;\n\nlet requests = 0;\n/** @type {NodeJS.Timeout | void} */\nlet shutdown_timeout_id;\n/** @type {NodeJS.Timeout | void} */\nlet idle_timeout_id;\n\n// Initialize the HTTP server here so that we can set properties before starting to listen.\n// Otherwise, polka delays creating the server until listen() is called. Settings these\n// properties after the server has started listening could lead to race conditions.\nconst httpServer = http.createServer();\n\nconst keep_alive_timeout = timeout_env('KEEP_ALIVE_TIMEOUT');\nif (keep_alive_timeout !== undefined) {\n\t// Convert the keep-alive timeout from seconds to milliseconds (the unit Node.js expects).\n\thttpServer.keepAliveTimeout = keep_alive_timeout * 1000;\n}\n\nconst headers_timeout = timeout_env('HEADERS_TIMEOUT');\nif (headers_timeout !== undefined) {\n\t// Convert the headers timeout from seconds to milliseconds (the unit Node.js expects).\n\thttpServer.headersTimeout = headers_timeout * 1000;\n}\n\nconst server = polka({ server: httpServer }).use(handler);\n\nif (socket_activation) {\n\tserver.listen({ fd: SD_LISTEN_FDS_START }, () => {\n\t\tconsole.log(`Listening on file descriptor ${SD_LISTEN_FDS_START}`);\n\t});\n} else {\n\tserver.listen({ path, host, port }, () => {\n\t\tconsole.log(`Listening on ${path || `http://${host}:${port}`}`);\n\t});\n}\n\n/** @param {'SIGINT' | 'SIGTERM' | 'IDLE'} reason */\nfunction graceful_shutdown(reason) {\n\tif (shutdown_timeout_id) return;\n\n\t// If a connection was opened with a keep-alive header close() will wait for the connection to\n\t// time out rather than close it even if it is not handling any requests, so call this first\n\thttpServer.closeIdleConnections();\n\n\thttpServer.close((error) => {\n\t\t// occurs if the server is already closed\n\t\tif (error) return;\n\n\t\tif (shutdown_timeout_id) {\n\t\t\tclearTimeout(shutdown_timeout_id);\n\t\t}\n\t\tif (idle_timeout_id) {\n\t\t\tclearTimeout(idle_timeout_id);\n\t\t}\n\n\t\t// @ts-expect-error custom events cannot be typed\n\t\tprocess.emit('sveltekit:shutdown', reason);\n\t});\n\n\tshutdown_timeout_id = setTimeout(() => httpServer.closeAllConnections(), shutdown_timeout * 1000);\n}\n\nhttpServer.on(\n\t'request',\n\t/** @param {import('node:http').IncomingMessage} req */\n\t(req) => {\n\t\trequests++;\n\n\t\tif (socket_activation && idle_timeout_id) {\n\t\t\tidle_timeout_id = clearTimeout(idle_timeout_id);\n\t\t}\n\n\t\treq.on('close', () => {\n\t\t\trequests--;\n\n\t\t\tif (shutdown_timeout_id) {\n\t\t\t\t// close connections as soon as they become idle, so they don't accept new requests\n\t\t\t\thttpServer.closeIdleConnections();\n\t\t\t}\n\t\t\tif (requests === 0 && socket_activation && idle_timeout) {\n\t\t\t\tidle_timeout_id = setTimeout(() => graceful_shutdown('IDLE'), idle_timeout * 1000);\n\t\t\t}\n\t\t});\n\t}\n);\n\nprocess.on('SIGTERM', graceful_shutdown);\nprocess.on('SIGINT', graceful_shutdown);\n\nexport { server };\n"
  },
  {
    "path": "packages/adapter-node/src/shims.js",
    "content": "import { installPolyfills } from '@sveltejs/kit/node/polyfills';\ninstallPolyfills();\n"
  },
  {
    "path": "packages/adapter-node/tests/env.spec.ts",
    "content": "import { afterEach, expect, test, describe, vi } from 'vitest';\nimport { timeout_env } from '../src/env.js';\n\nvi.hoisted(() => {\n\tvi.stubGlobal('ENV_PREFIX', '');\n});\n\ndescribe('timeout_env', () => {\n\tafterEach(() => {\n\t\tvi.unstubAllEnvs();\n\t});\n\n\ttest('parses zero correctly', () => {\n\t\tvi.stubEnv('TIMEOUT', '0');\n\n\t\tconst timeout = timeout_env('TIMEOUT');\n\t\texpect(timeout).toBe(0);\n\t});\n\n\ttest('parses positive integers correctly', () => {\n\t\tvi.stubEnv('TIMEOUT', '60');\n\n\t\tconst timeout = timeout_env('TIMEOUT');\n\t\texpect(timeout).toBe(60);\n\t});\n\n\ttest('returns the fallback when variable is not set', () => {\n\t\tconst timeout = timeout_env('TIMEOUT', 30);\n\t\texpect(timeout).toBe(30);\n\t});\n\n\ttest('returns undefined when variable is not set and no fallback is provided', () => {\n\t\tconst timeout = timeout_env('TIMEOUT');\n\t\texpect(timeout).toBeUndefined();\n\t});\n\n\ttest('throws an error for negative integers', () => {\n\t\tvi.stubEnv('TIMEOUT', '-10');\n\n\t\texpect(() => timeout_env('TIMEOUT')).toThrow(\n\t\t\t'Invalid value for environment variable TIMEOUT: \"-10\" (should be a non-negative integer)'\n\t\t);\n\t});\n\n\ttest('throws an error for non-integer values', () => {\n\t\tvi.stubEnv('TIMEOUT', 'abc');\n\n\t\texpect(() => timeout_env('TIMEOUT')).toThrow(\n\t\t\t'Invalid value for environment variable TIMEOUT: \"abc\" (should be a non-negative integer)'\n\t\t);\n\t});\n});\n"
  },
  {
    "path": "packages/adapter-node/tests/smoke.spec_disabled.js",
    "content": "import process from 'node:process';\nimport { assert, test } from 'vitest';\nimport { create_kit_middleware } from '../src/handler.js';\nimport fetch from 'node-fetch';\nimport polka from 'polka';\n\nconst { PORT = 3000 } = process.env;\nconst DEFAULT_SERVER_OPTS = { render: () => {} };\n\nasync function startServer(opts = DEFAULT_SERVER_OPTS) {\n\treturn new Promise((fulfil, reject) => {\n\t\tconst server = polka().use(create_kit_middleware(opts));\n\t\tserver.listen(PORT, (err) => {\n\t\t\tif (err) {\n\t\t\t\treject(err);\n\t\t\t}\n\t\t\tfulfil(server);\n\t\t});\n\t});\n}\n\ntest('starts a server', async () => {\n\tconst server = await startServer();\n\tassert.ok('server started');\n\tserver.server.close();\n});\n\ntest('serves a 404', async () => {\n\tconst server = await startServer();\n\tconst res = await fetch(`http://localhost:${PORT}/nothing`);\n\tassert.equal(res.status, 404);\n\tserver.server.close();\n});\n\ntest('responses with the rendered status code', async () => {\n\tconst server = await startServer({\n\t\trender: () => {\n\t\t\treturn {\n\t\t\t\theaders: 'wow',\n\t\t\t\tstatus: 203,\n\t\t\t\tbody: 'ok'\n\t\t\t};\n\t\t}\n\t});\n\tconst res = await fetch(`http://localhost:${PORT}/wow`);\n\tassert.equal(res.status, 203);\n\tserver.server.close();\n});\n\ntest('passes through umlaut as encoded path', async () => {\n\tconst server = await startServer({\n\t\trender: (incoming) => {\n\t\t\treturn {\n\t\t\t\tstatus: 200,\n\t\t\t\tbody: incoming.path\n\t\t\t};\n\t\t}\n\t});\n\tconst res = await fetch(`http://localhost:${PORT}/%C3%BCber-uns`);\n\tassert.equal(await res.text(), '/%C3%BCber-uns');\n\tserver.server.close();\n});\n\ntest('serve a 400 when we have a malformed url', async () => {\n\tconst server = await startServer();\n\tconst res = await fetch(`http://localhost:${PORT}//`);\n\tassert.equal(res.status, 400);\n\tserver.server.close();\n});\n\ntest.run();\n"
  },
  {
    "path": "packages/adapter-node/tests/utils.spec.ts",
    "content": "import { expect, test, describe } from 'vitest';\nimport { parse_as_bytes, parse_origin } from '../utils.js';\n\ndescribe('parse_as_bytes', () => {\n\ttest.each([\n\t\t['200', 200],\n\t\t['512K', 512 * 1024],\n\t\t['200M', 200 * 1024 * 1024],\n\t\t['1G', 1024 * 1024 * 1024],\n\t\t['Infinity', Infinity],\n\t\t['asdf', NaN]\n\t] as const)('parses correctly', (input, expected) => {\n\t\tconst actual = parse_as_bytes(input);\n\t\texpect(actual, `Testing input '${input}'`).toBe(expected);\n\t});\n});\n\ndescribe('parse_origin', () => {\n\ttest.each([\n\t\t['http://localhost:3000', 'http://localhost:3000'],\n\t\t['https://example.com', 'https://example.com'],\n\t\t['http://192.168.1.1:8080', 'http://192.168.1.1:8080'],\n\t\t['https://my-site.com', 'https://my-site.com'],\n\t\t['http://localhost', 'http://localhost'],\n\t\t// Default ports are normalized by URL.origin per WHATWG URL standard\n\t\t['https://example.com:443', 'https://example.com'],\n\t\t['http://example.com:80', 'http://example.com'],\n\t\t[undefined, undefined]\n\t] as const)('normalizes %s to %s', (input, expected) => {\n\t\texpect(parse_origin(input)).toBe(expected);\n\t});\n\n\ttest.each([\n\t\t['http://localhost:3000/path', 'http://localhost:3000'],\n\t\t['http://localhost:3000?query=1', 'http://localhost:3000'],\n\t\t['http://localhost:3000#hash', 'http://localhost:3000'],\n\t\t['https://example.com/path/to/page', 'https://example.com'],\n\t\t['https://example.com:443/path?query=1#hash', 'https://example.com']\n\t] as const)('strips path/query/hash from %s to get %s', (input, expected) => {\n\t\texpect(parse_origin(input)).toBe(expected);\n\t});\n\n\ttest.each(['localhost:3000', 'example.com', '', '   ', 'ftp://localhost:3000'] as const)(\n\t\t'throws error for invalid origin: %s',\n\t\t(input) => {\n\t\t\texpect(() => parse_origin(input)).toThrow('Invalid ORIGIN');\n\t\t}\n\t);\n});\n"
  },
  {
    "path": "packages/adapter-node/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"noImplicitAny\": true,\n\t\t\"strictNullChecks\": true,\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"node16\",\n\t\t\"moduleResolution\": \"node16\",\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../kit/types/index\"]\n\t\t}\n\t},\n\t\"include\": [\n\t\t\"index.js\",\n\t\t\"src/**/*.js\",\n\t\t\"tests/**/*.js\",\n\t\t\"tests/**/*.ts\",\n\t\t\"internal.d.ts\",\n\t\t\"utils.js\"\n\t],\n\t\"exclude\": [\"tests/smoke.spec_disabled.js\"]\n}\n"
  },
  {
    "path": "packages/adapter-node/utils.js",
    "content": "/**\n * Parses the given value into number of bytes.\n *\n * @param {string} value - Size in bytes. Can also be specified with a unit suffix kilobytes (K), megabytes (M), or gigabytes (G).\n * @returns {number}\n */\nexport function parse_as_bytes(value) {\n\tconst multiplier =\n\t\t{\n\t\t\tK: 1024,\n\t\t\tM: 1024 * 1024,\n\t\t\tG: 1024 * 1024 * 1024\n\t\t}[value[value.length - 1]?.toUpperCase()] ?? 1;\n\treturn Number(multiplier != 1 ? value.substring(0, value.length - 1) : value) * multiplier;\n}\n\n/**\n * Parses and validates an origin URL.\n *\n * @param {string | undefined} value - Origin URL with http:// or https:// protocol\n * @returns {string | undefined} The validated origin, or undefined if value is undefined\n * @throws {Error} If value is provided but invalid\n */\nexport function parse_origin(value) {\n\tif (value === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst trimmed = value.trim();\n\n\tlet url;\n\ttry {\n\t\turl = new URL(trimmed);\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Invalid ORIGIN: '${trimmed}'. ` +\n\t\t\t\t`ORIGIN must be a valid URL with http:// or https:// protocol. ` +\n\t\t\t\t`For example: 'http://localhost:3000' or 'https://my.site'`,\n\t\t\t{ cause: error }\n\t\t);\n\t}\n\n\tif (url.protocol !== 'http:' && url.protocol !== 'https:') {\n\t\tthrow new Error(\n\t\t\t`Invalid ORIGIN: '${trimmed}'. ` +\n\t\t\t\t`Only http:// and https:// protocols are supported. ` +\n\t\t\t\t`Received protocol: ${url.protocol}`\n\t\t);\n\t}\n\n\treturn url.origin;\n}\n"
  },
  {
    "path": "packages/adapter-static/.gitignore",
    "content": ".DS_Store\nnode_modules\n.svelte-kit\nbuild\n"
  },
  {
    "path": "packages/adapter-static/CHANGELOG.md",
    "content": "# @sveltejs/adapter-static\n\n## 3.0.10\n### Patch Changes\n\n\n- chore: update \"homepage\" field in package.json ([#14579](https://github.com/sveltejs/kit/pull/14579))\n\n## 3.0.9\n### Patch Changes\n\n\n- chore: add `.git` to the end of `package.json` repository url ([#14134](https://github.com/sveltejs/kit/pull/14134))\n\n- Updated dependencies [[`c968aef`](https://github.com/sveltejs/kit/commit/c968aef5727f978244d5160657b4a7ac651384ae)]:\n  - @sveltejs/kit@2.27.3\n\n## 3.0.8\n### Patch Changes\n\n\n- fix: use optional chaining when checking router type ([#13218](https://github.com/sveltejs/kit/pull/13218))\n\n## 3.0.7\n### Patch Changes\n\n\n- fix: allow dynamic routes with missing fallback in hash mode ([#13213](https://github.com/sveltejs/kit/pull/13213))\n\n## 3.0.6\n### Patch Changes\n\n\n- docs: update URLs for new svelte.dev site ([#12857](https://github.com/sveltejs/kit/pull/12857))\n\n- Updated dependencies [[`dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46`](https://github.com/sveltejs/kit/commit/dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46), [`4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d`](https://github.com/sveltejs/kit/commit/4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d), [`3a9b78f04786898ca93f6d4b75ab18d26bc45192`](https://github.com/sveltejs/kit/commit/3a9b78f04786898ca93f6d4b75ab18d26bc45192), [`723eb8b31e6a22c82f730c30e485386c8676b746`](https://github.com/sveltejs/kit/commit/723eb8b31e6a22c82f730c30e485386c8676b746), [`8ec471c875345b751344e67580ff1b772ef2735b`](https://github.com/sveltejs/kit/commit/8ec471c875345b751344e67580ff1b772ef2735b)]:\n  - @sveltejs/kit@2.7.3\n\n## 3.0.5\n### Patch Changes\n\n\n- fix: import `node:process` instead of using globals ([#12641](https://github.com/sveltejs/kit/pull/12641))\n\n- Updated dependencies [[`e798ef718f163bed4f93e1918bd8294f765376ad`](https://github.com/sveltejs/kit/commit/e798ef718f163bed4f93e1918bd8294f765376ad)]:\n  - @sveltejs/kit@2.5.28\n\n## 3.0.4\n### Patch Changes\n\n\n- chore: configure provenance in a simpler manner ([#12570](https://github.com/sveltejs/kit/pull/12570))\n\n- Updated dependencies [[`087a43d391fc38b8c008fb39a804dc6988974101`](https://github.com/sveltejs/kit/commit/087a43d391fc38b8c008fb39a804dc6988974101)]:\n  - @sveltejs/kit@2.5.22\n\n## 3.0.3\n### Patch Changes\n\n\n- chore: package provenance ([#12567](https://github.com/sveltejs/kit/pull/12567))\n\n- Updated dependencies [[`4930a8443caa53bcecee7b690cd28e429b1c8a20`](https://github.com/sveltejs/kit/commit/4930a8443caa53bcecee7b690cd28e429b1c8a20)]:\n  - @sveltejs/kit@2.5.21\n\n## 3.0.2\n\n### Patch Changes\n\n- chore: add keywords for discovery in npm search ([#12330](https://github.com/sveltejs/kit/pull/12330))\n\n- Updated dependencies [[`25acb1d9fce998dccd8050b93cf4142c2b082611`](https://github.com/sveltejs/kit/commit/25acb1d9fce998dccd8050b93cf4142c2b082611), [`642c4a4aff4351b786fe6274aa2f0bf7d905faf9`](https://github.com/sveltejs/kit/commit/642c4a4aff4351b786fe6274aa2f0bf7d905faf9), [`0a0e9aa897123ebec50af08e9385b2ca4fc5bb28`](https://github.com/sveltejs/kit/commit/0a0e9aa897123ebec50af08e9385b2ca4fc5bb28)]:\n  - @sveltejs/kit@2.5.11\n\n## 3.0.1\n\n### Patch Changes\n\n- chore: update primary branch from master to main ([`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d))\n\n- Updated dependencies [[`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d), [`16961e8cd3fa6a7f382153b1ff056bc2aae9b31b`](https://github.com/sveltejs/kit/commit/16961e8cd3fa6a7f382153b1ff056bc2aae9b31b), [`197e01f95652f511160f38b37b9da73a124ecd48`](https://github.com/sveltejs/kit/commit/197e01f95652f511160f38b37b9da73a124ecd48), [`102e4a5ae5b29624302163faf5a20c94a64a5b2c`](https://github.com/sveltejs/kit/commit/102e4a5ae5b29624302163faf5a20c94a64a5b2c), [`f8e3d8b9728c9f1ab63389342c31d7246b6f9db6`](https://github.com/sveltejs/kit/commit/f8e3d8b9728c9f1ab63389342c31d7246b6f9db6)]:\n  - @sveltejs/kit@2.0.4\n\n## 3.0.0\n\n### Major Changes\n\n- breaking: update SvelteKit peer dependency to version 2 ([#11277](https://github.com/sveltejs/kit/pull/11277))\n\n## 2.0.3\n\n### Patch Changes\n\n- fix: correctly list dynamic routes in error log ([#10443](https://github.com/sveltejs/kit/pull/10443))\n\n## 2.0.2\n\n### Patch Changes\n\n- fix: update broken link in error message ([`118ce5a0`](https://github.com/sveltejs/kit/commit/118ce5a07a3a984353c3fc858b34c67e9e560fa0))\n\n- Updated dependencies [[`748a8720`](https://github.com/sveltejs/kit/commit/748a8720fea8ea938576041207b81e19bb8f7dff)]:\n  - @sveltejs/kit@1.15.3\n\n## 2.0.1\n\n### Patch Changes\n\n- fix: generate fallback page before compressing ([#8972](https://github.com/sveltejs/kit/pull/8972))\n\n- Updated dependencies [[`0abb8ebf`](https://github.com/sveltejs/kit/commit/0abb8ebffc6121f81c2bbfa0a0f68866d4cc1627), [`bef54f63`](https://github.com/sveltejs/kit/commit/bef54f63d2315066d30e8f1bcf471ddf2bd72c35), [`51cd6e64`](https://github.com/sveltejs/kit/commit/51cd6e643178e3a113fc2c3e8a63755bcbfe902d), [`930c8e4e`](https://github.com/sveltejs/kit/commit/930c8e4ee2e3046ed1b622777dafa23029a19fe5), [`ee8066fc`](https://github.com/sveltejs/kit/commit/ee8066fcb29ed1e7e3ab513cabb7997e38c984f2), [`49d2ec62`](https://github.com/sveltejs/kit/commit/49d2ec62e6385694f11701bf2fa411d07449344c), [`eb943565`](https://github.com/sveltejs/kit/commit/eb943565a4324dbed3da5a581924ca91a24366de)]:\n  - @sveltejs/kit@1.5.3\n\n## 2.0.0\n\n### Major Changes\n\n- breaking: bump `@sveltejs/kit` peer dependency ([#8740](https://github.com/sveltejs/kit/pull/8740))\n\n### Patch Changes\n\n- Updated dependencies [[`c7648f66`](https://github.com/sveltejs/kit/commit/c7648f6608a413e2654625cbd30f890d2148cf13), [`63613bf1`](https://github.com/sveltejs/kit/commit/63613bf194c18ce50e111585ad770fc93f9e43c7), [`d1f7655e`](https://github.com/sveltejs/kit/commit/d1f7655efdff70d91f94fe0cb0de50ed2511b5e5)]:\n  - @sveltejs/kit@1.5.0\n\n## 1.0.6\n\n### Patch Changes\n\n- docs: fix link in README ([#8854](https://github.com/sveltejs/kit/pull/8854))\n\n- Updated dependencies [[`7cdb7a65`](https://github.com/sveltejs/kit/commit/7cdb7a65819342c6d334c79defc697d531d5cbf4)]:\n  - @sveltejs/kit@1.3.10\n\n## 1.0.5\n\n### Patch Changes\n\n- docs: move adapter docs to site ([#8531](https://github.com/sveltejs/kit/pull/8531))\n\n## 1.0.4\n\n### Patch Changes\n\n- fix: publish missing files ([#8532](https://github.com/sveltejs/kit/pull/8532))\n\n## 1.0.3\n\n### Patch Changes\n\n- chore: remove superfluous main field from package.json ([#8519](https://github.com/sveltejs/kit/pull/8519))\n\n- Updated dependencies [[`7e2d3405`](https://github.com/sveltejs/kit/commit/7e2d34056e99f371e22406d941b764df365a2649)]:\n  - @sveltejs/kit@1.1.1\n\n## 1.0.2\n\n### Patch Changes\n\n- docs: clarify that you can build SPAs with adapter-static ([#8502](https://github.com/sveltejs/kit/pull/8502))\n\n## 1.0.1\n\n### Patch Changes\n\n- fix: match `adapter-vercel` logic for serving prerendered content ([#8332](https://github.com/sveltejs/kit/pull/8332))\n\n## 1.0.0\n\n### Major Changes\n\nFirst major release, see below for the history of changes that lead up to this.\nStarting from now all releases follow semver and changes will be listed as Major/Minor/Patch\n\n## 1.0.0-next.50\n\n### Patch Changes\n\n- chore: add peerDependencies, add more specific next version ([#8141](https://github.com/sveltejs/kit/pull/8141))\n\n## 1.0.0-next.49\n\n### Patch Changes\n\n- breaking: replace automatic fallback generation with `builder.generateFallback(fallback)` ([#8013](https://github.com/sveltejs/kit/pull/8013))\n\n## 1.0.0-next.48\n\n### Patch Changes\n\n- Update README ([#7480](https://github.com/sveltejs/kit/pull/7480))\n\n## 1.0.0-next.47\n\n### Patch Changes\n\n- update dependencies ([#7355](https://github.com/sveltejs/kit/pull/7355))\n\n## 1.0.0-next.46\n\n### Patch Changes\n\n- Make options object optional ([#7341](https://github.com/sveltejs/kit/pull/7341))\n\n## 1.0.0-next.45\n\n### Patch Changes\n\n- feat: more info about prerendering errors, add strict option to adapter-static ([#7264](https://github.com/sveltejs/kit/pull/7264))\n\n## 1.0.0-next.44\n\n### Patch Changes\n\n- fix error message ([#7108](https://github.com/sveltejs/kit/pull/7108))\n\n## 1.0.0-next.43\n\n### Patch Changes\n\n- Improve performance by compressing in parallel ([#6710](https://github.com/sveltejs/kit/pull/6710))\n\n## 1.0.0-next.42\n\n### Patch Changes\n\n- docs: more specific error message when prerendering fails ([#6577](https://github.com/sveltejs/kit/pull/6577))\n\n## 1.0.0-next.41\n\n### Patch Changes\n\n- Better error when encountering not-fully-prerenderable routes ([#6474](https://github.com/sveltejs/kit/pull/6474))\n\n## 1.0.0-next.40\n\n### Patch Changes\n\n- breaking: require all routes to be prerenderable when not using fallback option ([#6392](https://github.com/sveltejs/kit/pull/6392))\n\n## 1.0.0-next.39\n\n### Patch Changes\n\n- Move `compress` logic to `Builder` API ([#5822](https://github.com/sveltejs/kit/pull/5822))\n\n## 1.0.0-next.38\n\n### Patch Changes\n\n- breaking: remove writeStatic to align with Vite ([#5618](https://github.com/sveltejs/kit/pull/5618))\n\n## 1.0.0-next.37\n\n### Patch Changes\n\n- breaking: Throws when correctly configured to run as a static site of a SPA ([#5562](https://github.com/sveltejs/kit/pull/5562))\n\n## 1.0.0-next.36\n\n### Patch Changes\n\n- Remove ENABLE_VC_BUILD check, use v3 build output API for all apps deployed to Vercel ([#5514](https://github.com/sveltejs/kit/pull/5514))\n\n## 1.0.0-next.35\n\n### Patch Changes\n\n- chore: upgrade TypeScript to 4.7.4 ([#5414](https://github.com/sveltejs/kit/pull/5414))\n\n## 1.0.0-next.34\n\n### Patch Changes\n\n- Update dependencies ([#5121](https://github.com/sveltejs/kit/pull/5121))\n\n## 1.0.0-next.33\n\n### Patch Changes\n\n- Update adapter entrypoint typings to be NodeNext/ESNext-compatible ([#5111](https://github.com/sveltejs/kit/pull/5111))\n\n## 1.0.0-next.32\n\n### Patch Changes\n\n- Add types to pkg.exports ([#5045](https://github.com/sveltejs/kit/pull/5045))\n\n## 1.0.0-next.31\n\n### Patch Changes\n\n- Tweak fallback page README ([#4954](https://github.com/sveltejs/kit/pull/4954))\n\n## 1.0.0-next.30\n\n### Patch Changes\n\n- Bump version to trigger README update on npm ([#4875](https://github.com/sveltejs/kit/pull/4875))\n\n## 1.0.0-next.29\n\n### Patch Changes\n\n- breaking: replace builder.prerender() with builder.writePrerendered() and builder.prerendered ([#4192](https://github.com/sveltejs/kit/pull/4192)) ([#4229](https://github.com/sveltejs/kit/pull/4229))\n\n## 1.0.0-next.28\n\n### Patch Changes\n\n- breaking: remove `createIndexFiles` option, derive from `trailingSlash` instead ([#3801](https://github.com/sveltejs/kit/pull/3801))\n\n## 1.0.0-next.27\n\n### Patch Changes\n\n- `precompress` option also compress wasm files ([#3790](https://github.com/sveltejs/kit/pull/3790))\n\n## 1.0.0-next.26\n\n### Patch Changes\n\n- Log adapter-static output directories ([#3274](https://github.com/sveltejs/kit/pull/3274))\n\n## 1.0.0-next.25\n\n### Patch Changes\n\n- chore: update dependency sirv to v2 ([#3263](https://github.com/sveltejs/kit/pull/3263))\n\n## 1.0.0-next.24\n\n### Patch Changes\n\n- Overhaul adapter API ([#2931](https://github.com/sveltejs/kit/pull/2931))\n\n## 1.0.0-next.23\n\n### Patch Changes\n\n- add precompress option to adapter-static ([#3079](https://github.com/sveltejs/kit/pull/3079))\n\n## 1.0.0-next.22\n\n### Patch Changes\n\n- update to esbuild 0.13.15 and other dependency updates ([#2957](https://github.com/sveltejs/kit/pull/2957))\n\n## 1.0.0-next.21\n\n### Patch Changes\n\n- update dependencies ([#2574](https://github.com/sveltejs/kit/pull/2574))\n\n## 1.0.0-next.20\n\n### Patch Changes\n\n- chore: upgrade to Svelte 3.43.0\" ([#2474](https://github.com/sveltejs/kit/pull/2474))\n\n## 1.0.0-next.19\n\n### Patch Changes\n\n- chore: add links to repository and homepage to package.json ([#2425](https://github.com/sveltejs/kit/pull/2425))\n\n## 1.0.0-next.18\n\n### Patch Changes\n\n- chore: export package.json from adapters ([#2351](https://github.com/sveltejs/kit/pull/2351))\n\n## 1.0.0-next.17\n\n### Patch Changes\n\n- Clear output before adapting ([#2260](https://github.com/sveltejs/kit/pull/2260))\n\n## 1.0.0-next.16\n\n### Patch Changes\n\n- 94b34fa6: [breaking] standardize final output dir as /build (vs /.svelte-kit) ([#2109](https://github.com/sveltejs/kit/pull/2109))\n\n## 1.0.0-next.15\n\n### Patch Changes\n\n- b3e7c8b3: [chore] update build output location ([#2082](https://github.com/sveltejs/kit/pull/2082))\n\n## 1.0.0-next.14\n\n### Patch Changes\n\n- d81de603: revert adapters automatically updating .gitignore ([#1924](https://github.com/sveltejs/kit/pull/1924))\n\n## 1.0.0-next.13\n\n### Patch Changes\n\n- edc307d: Remove peerDependencies due to pnpm bug ([#1621](https://github.com/sveltejs/kit/pull/1621))\n- 2636e68: Attempt to fix peerDependencies specification ([#1620](https://github.com/sveltejs/kit/pull/1620))\n\n## 1.0.0-next.12\n\n### Patch Changes\n\n- bf77940: bump `polka` and `sirv` dependency versions ([#1548](https://github.com/sveltejs/kit/pull/1548))\n- 028abd9: Pass validated svelte config to adapter adapt function ([#1559](https://github.com/sveltejs/kit/pull/1559))\n- Updated dependencies [6372690]\n- Updated dependencies [c3d36a3]\n- Updated dependencies [bf77940]\n- Updated dependencies [2172469]\n- Updated dependencies [028abd9]\n  - @sveltejs/kit@1.0.0-next.110\n\n## 1.0.0-next.11\n\n### Patch Changes\n\n- dca4946: Make kit a peerDependency of the adapters ([#1505](https://github.com/sveltejs/kit/pull/1505))\n- Updated dependencies [261ee1c]\n- Updated dependencies [ec156c6]\n- Updated dependencies [586785d]\n  - @sveltejs/kit@1.0.0-next.109\n\n## 1.0.0-next.10\n\n### Patch Changes\n\n- dad93fc: Fix workspace dependencies ([#1434](https://github.com/sveltejs/kit/pull/1434))\n\n## 1.0.0-next.9\n\n### Patch Changes\n\n- d871213: Remove Vite dependency from apps ([#1374](https://github.com/sveltejs/kit/pull/1374))\n\n## 1.0.0-next.8\n\n### Patch Changes\n\n- c6fde99: Convert to ESM ([#1323](https://github.com/sveltejs/kit/pull/1323))\n\n## 1.0.0-next.7\n\n### Patch Changes\n\n- 2e72a94: Add type declarations ([#1230](https://github.com/sveltejs/kit/pull/1230))\n\n## 1.0.0-next.6\n\n### Patch Changes\n\n- 6f2b4a6: Remove references to npm start ([#1196](https://github.com/sveltejs/kit/pull/1196))\n\n## 1.0.0-next.5\n\n### Patch Changes\n\n- 4131467: Prerender fallback page for SPAs ([#1181](https://github.com/sveltejs/kit/pull/1181))\n\n## 1.0.0-next.4\n\n### Patch Changes\n\n- 8805c6d: Pass adapters directly to svelte.config.cjs ([#579](https://github.com/sveltejs/kit/pull/579))\n\n## 1.0.0-next.3\n\n### Patch Changes\n\n- f35a5cd: Change adapter signature ([#505](https://github.com/sveltejs/kit/pull/505))\n\n## 1.0.0-next.2\n\n### Patch Changes\n\n- Fix adapters and convert to ES modules\n\n## 1.0.0-next.1\n\n### Patch Changes\n\n- Support options\n\n## 0.0.17\n\n### Patch Changes\n\n- Add svelte-kit start command\n\n## 0.0.16\n\n### Patch Changes\n\n- Remove unnecessary prepublish script\n\n## 0.0.15\n\n### Patch Changes\n\n- b475ed4: Overhaul adapter API - fixes #166 ([#180](https://github.com/sveltejs/kit/pull/180))\n\n## 0.0.14\n\n### Patch Changes\n\n- Updated dependencies [3bdf33b]\n  - @sveltejs/app-utils@0.0.17\n\n## 0.0.13\n\n### Patch Changes\n\n- 67eaeea: Move app-utils stuff into subpackages\n- Updated dependencies [67eaeea]\n  - @sveltejs/app-utils@0.0.16\n\n## 0.0.12\n\n### Patch Changes\n\n- Updated dependencies [a163000]\n  - @sveltejs/app-utils@0.0.15\n\n## 0.0.11\n\n### Patch Changes\n\n- Updated dependencies [undefined]\n- Updated dependencies [undefined]\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.14\n\n## 0.0.10\n\n### Patch Changes\n\n- Updated dependencies [undefined]\n- Updated dependencies [96c06d8]\n  - @sveltejs/app-utils@0.0.13\n\n## 0.0.9\n\n### Patch Changes\n\n- Updated dependencies [0320208]\n- Updated dependencies [5ca907c]\n  - @sveltejs/app-utils@0.0.12\n\n## 0.0.8\n\n### Patch Changes\n\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.11\n\n## 0.0.7\n\n### Patch Changes\n\n- Updated dependencies [19323e9]\n  - @sveltejs/app-utils@0.0.10\n\n## 0.0.6\n\n### Patch Changes\n\n- Updated dependencies [90a98ae]\n  - @sveltejs/app-utils@0.0.9\n\n## 0.0.5\n\n### Patch Changes\n\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.8\n\n## 0.0.4\n\n### Patch Changes\n\n- various\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.7\n"
  },
  {
    "path": "packages/adapter-static/LICENSE",
    "content": "Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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."
  },
  {
    "path": "packages/adapter-static/README.md",
    "content": "# @sveltejs/adapter-static\n\n[Adapter](https://svelte.dev/docs/kit/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://svelte.dev/docs/kit/page-options#prerender).\n\n## Docs\n\n[Docs](https://svelte.dev/docs/kit/adapter-static)\n\n## Changelog\n\n[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/adapter-static/CHANGELOG.md).\n\n## License\n\n[MIT](LICENSE)\n"
  },
  {
    "path": "packages/adapter-static/index.d.ts",
    "content": "import { Adapter } from '@sveltejs/kit';\n\nexport interface AdapterOptions {\n\tpages?: string;\n\tassets?: string;\n\tfallback?: string;\n\tprecompress?: boolean;\n\tstrict?: boolean;\n}\n\nexport default function plugin(options?: AdapterOptions): Adapter;\n"
  },
  {
    "path": "packages/adapter-static/index.js",
    "content": "import path from 'node:path';\nimport { platforms } from './platforms.js';\n\n/** @type {import('./index.js').default} */\nexport default function (options) {\n\treturn {\n\t\tname: '@sveltejs/adapter-static',\n\t\t/** @param {import('./internal.js').Builder2_0_0} builder */\n\t\tasync adapt(builder) {\n\t\t\tif (!options?.fallback && builder.config.kit.router?.type !== 'hash') {\n\t\t\t\tconst dynamic_routes = builder.routes.filter((route) => route.prerender !== true);\n\t\t\t\tif (dynamic_routes.length > 0 && options?.strict !== false) {\n\t\t\t\t\tconst prefix = path.relative('.', builder.config.kit.files.routes);\n\t\t\t\t\tconst has_param_routes = builder.routes.some((route) => route.id.includes('['));\n\t\t\t\t\tconst config_option =\n\t\t\t\t\t\thas_param_routes || JSON.stringify(builder.config.kit.prerender.entries) !== '[\"*\"]'\n\t\t\t\t\t\t\t? `  - adjust the \\`prerender.entries\\` config option ${\n\t\t\t\t\t\t\t\t\thas_param_routes\n\t\t\t\t\t\t\t\t\t\t? '(routes with parameters are not part of entry points by default)'\n\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t} — see https://svelte.dev/docs/kit/configuration#prerender for more info.`\n\t\t\t\t\t\t\t: '';\n\n\t\t\t\t\tbuilder.log.error(\n\t\t\t\t\t\t`@sveltejs/adapter-static: all routes must be fully prerenderable, but found the following routes that are dynamic:\n${dynamic_routes.map((route) => `  - ${path.posix.join(prefix, route.id)}`).join('\\n')}\n\nYou have the following options:\n  - set the \\`fallback\\` option — see https://svelte.dev/docs/kit/single-page-apps#usage for more info.\n  - add \\`export const prerender = true\\` to your root \\`+layout.js/.ts\\` or \\`+layout.server.js/.ts\\` file. This will try to prerender all pages.\n  - add \\`export const prerender = true\\` to any \\`+server.js/ts\\` files that are not fetched by page \\`load\\` functions.\n${config_option}\n  - 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.\n\nIf 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.\nSee https://svelte.dev/docs/kit/page-options#prerender for more details`\n\t\t\t\t\t);\n\t\t\t\t\tthrow new Error('Encountered dynamic routes');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst platform = platforms.find((platform) => platform.test());\n\n\t\t\tif (platform) {\n\t\t\t\tif (options) {\n\t\t\t\t\tbuilder.log.warn(\n\t\t\t\t\t\t`Detected ${platform.name}. Please remove adapter-static options to enable zero-config mode`\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tbuilder.log.info(`Detected ${platform.name}, using zero-config mode`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\t// @ts-ignore\n\t\t\t\tpages = 'build',\n\t\t\t\tassets = pages,\n\t\t\t\tfallback,\n\t\t\t\tprecompress\n\t\t\t} = options ?? platform?.defaults ?? /** @type {import('./index.js').AdapterOptions} */ ({});\n\n\t\t\tbuilder.rimraf(assets);\n\t\t\tbuilder.rimraf(pages);\n\n\t\t\tbuilder.generateEnvModule();\n\t\t\tbuilder.writeClient(assets);\n\t\t\tbuilder.writePrerendered(pages);\n\n\t\t\tif (fallback) {\n\t\t\t\tawait builder.generateFallback(path.join(pages, fallback));\n\t\t\t}\n\n\t\t\tif (precompress) {\n\t\t\t\tbuilder.log.minor('Compressing assets and pages');\n\t\t\t\tif (pages === assets) {\n\t\t\t\t\tawait builder.compress(assets);\n\t\t\t\t} else {\n\t\t\t\t\tawait Promise.all([builder.compress(assets), builder.compress(pages)]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (pages === assets) {\n\t\t\t\tbuilder.log(`Wrote site to \"${pages}\"`);\n\t\t\t} else {\n\t\t\t\tbuilder.log(`Wrote pages to \"${pages}\" and assets to \"${assets}\"`);\n\t\t\t}\n\n\t\t\tif (!options) platform?.done(builder);\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-static/internal.d.ts",
    "content": "/**\n * Utility type that makes all properties optional except for the specified keys\n */\nexport type PartialExcept<T, K extends keyof T> = Partial<Omit<T, K>> & Required<Pick<T, K>>;\n\n/**\n * We use a custom `Builder` type here to support the minimum version of SvelteKit.\n */\nexport type Builder2_0_0 = PartialExcept<\n\timport('@sveltejs/kit').Builder,\n\t| 'log'\n\t| 'rimraf'\n\t| 'mkdirp'\n\t| 'config'\n\t| 'prerendered'\n\t| 'routes'\n\t| 'createEntries'\n\t| 'generateFallback'\n\t| 'generateEnvModule'\n\t| 'generateManifest'\n\t| 'getBuildDirectory'\n\t| 'getClientDirectory'\n\t| 'getServerDirectory'\n\t| 'getAppPath'\n\t| 'writeClient'\n\t| 'writePrerendered'\n\t| 'writeServer'\n\t| 'copy'\n\t| 'compress'\n>;\n"
  },
  {
    "path": "packages/adapter-static/package.json",
    "content": "{\n\t\"name\": \"@sveltejs/adapter-static\",\n\t\"version\": \"3.0.10\",\n\t\"description\": \"Adapter for SvelteKit apps that prerenders your entire site as a collection of static files\",\n\t\"keywords\": [\n\t\t\"adapter\",\n\t\t\"deploy\",\n\t\t\"hosting\",\n\t\t\"ssg\",\n\t\t\"static site generation\",\n\t\t\"svelte\",\n\t\t\"sveltekit\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/sveltejs/kit.git\",\n\t\t\"directory\": \"packages/adapter-static\"\n\t},\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://svelte.dev/docs/kit/adapter-static\",\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./index.d.ts\",\n\t\t\t\"import\": \"./index.js\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"types\": \"index.d.ts\",\n\t\"files\": [\n\t\t\"index.js\",\n\t\t\"index.d.ts\",\n\t\t\"platforms.js\"\n\t],\n\t\"scripts\": {\n\t\t\"lint\": \"prettier --check .\",\n\t\t\"check\": \"tsc\",\n\t\t\"format\": \"pnpm lint --write\",\n\t\t\"test\": \"pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@playwright/test\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"@types/node\": \"catalog:\",\n\t\t\"sirv\": \"^3.0.0\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@sveltejs/kit\": \"^2.0.0\"\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-static/platforms.js",
    "content": "import fs from 'node:fs';\nimport process from 'node:process';\n\n/**\n * @typedef {{\n *   name: string;\n *   test: () => boolean;\n *   defaults: import('./index.js').AdapterOptions;\n *   done: (builder: import('./internal.js').Builder2_0_0) => void;\n * }}\n * Platform */\n\n// This function is duplicated in adapter-vercel\n/** @param {import('./internal.js').Builder2_0_0} builder */\nfunction static_vercel_config(builder) {\n\t/** @type {any[]} */\n\tconst prerendered_redirects = [];\n\n\t/** @type {Record<string, { path: string }>} */\n\tconst overrides = {};\n\n\tfor (const [src, redirect] of builder.prerendered.redirects) {\n\t\tprerendered_redirects.push({\n\t\t\tsrc,\n\t\t\theaders: {\n\t\t\t\tLocation: redirect.location\n\t\t\t},\n\t\t\tstatus: redirect.status\n\t\t});\n\t}\n\n\tfor (const [path, page] of builder.prerendered.pages) {\n\t\tif (path.endsWith('/') && path !== '/') {\n\t\t\tprerendered_redirects.push(\n\t\t\t\t{ src: path, dest: path.slice(0, -1) },\n\t\t\t\t{ src: path.slice(0, -1), status: 308, headers: { Location: path } }\n\t\t\t);\n\n\t\t\toverrides[page.file] = { path: path.slice(1, -1) };\n\t\t} else {\n\t\t\toverrides[page.file] = { path: path.slice(1) };\n\t\t}\n\t}\n\n\treturn {\n\t\tversion: 3,\n\t\troutes: [\n\t\t\t...prerendered_redirects,\n\t\t\t{\n\t\t\t\tsrc: `/${builder.getAppPath()}/immutable/.+`,\n\t\t\t\theaders: {\n\t\t\t\t\t'cache-control': 'public, immutable, max-age=31536000'\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\thandle: 'filesystem'\n\t\t\t}\n\t\t],\n\t\toverrides\n\t};\n}\n\n/** @type {Platform[]} */\nexport const platforms = [\n\t{\n\t\tname: 'Vercel',\n\t\ttest: () => !!process.env.VERCEL,\n\t\tdefaults: {\n\t\t\tpages: '.vercel/output/static'\n\t\t},\n\t\tdone: (builder) => {\n\t\t\tconst config = static_vercel_config(builder);\n\t\t\tfs.writeFileSync('.vercel/output/config.json', JSON.stringify(config, null, '  '));\n\t\t}\n\t}\n];\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/.gitignore",
    "content": ".DS_Store\nnode_modules\n/.svelte-kit\n/build\n/functions\n!/.env"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/package.json",
    "content": "{\n\t\"name\": \"~TODO~\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"sirv -p 5173 -s 200.html build\",\n\t\t\"test\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"sirv-cli\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/global.d.ts",
    "content": "/// <reference types=\"@sveltejs/kit\" />\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/routes/+layout.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/routes/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/routes/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/endpoint/implicit.json');\n\treturn await res.json();\n}\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/routes/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>This page was prerendered</h1>\n<p>answer: {data.answer}</p>\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/routes/endpoint/explicit.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport const prerender = true;\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\treturn json({ answer: 42 });\n}\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/routes/endpoint/implicit.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n// no export const prerender here, it should be prerendered by virtue\n// of being fetched from a prerendered page\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\treturn json({ answer: 42 });\n}\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/routes/public-env/+page.svelte",
    "content": "<script>\n\timport { browser } from '$app/environment';\n\timport { PUBLIC_ANSWER } from '$env/static/public';\n\timport { env } from '$env/dynamic/public';\n</script>\n\n<h1>The answer is {PUBLIC_ANSWER}</h1>\n\n{#if browser}\n\t<h2>The dynamic answer is {env.PUBLIC_ANSWER}</h2>\n{/if}\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/routes/server-emitted-asset/+page.server.js",
    "content": "import src from './image.jpg';\n\nexport function load() {\n\treturn {\n\t\tsrc\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/src/routes/server-emitted-asset/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<img src={data.src} alt=\"birb\" />\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/svelte.config.js",
    "content": "import adapter from '../../../index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/test/test.js",
    "content": "import * as fs from 'node:fs';\nimport process from 'node:process';\nimport { expect, test } from '@playwright/test';\n\nconst cwd = process.cwd();\n\ntest('generates HTML files', () => {\n\texpect(fs.existsSync(`${cwd}/build/index.html`)).toBeTruthy();\n});\n\ntest('prerenders a page', async ({ page }) => {\n\tawait page.goto('/');\n\texpect(await page.textContent('h1')).toEqual('This page was prerendered');\n\texpect(await page.textContent('p')).toEqual('answer: 42');\n});\n\ntest('prerenders an unreferenced endpoint with explicit `prerender` setting', async () => {\n\texpect(fs.existsSync(`${cwd}/build/endpoint/explicit.json`)).toBeTruthy();\n});\n\ntest('prerenders a referenced endpoint with implicit `prerender` setting', async () => {\n\texpect(fs.existsSync(`${cwd}/build/endpoint/implicit.json`)).toBeTruthy();\n});\n\ntest('exposes public env vars to the client', async ({ page }) => {\n\tawait page.goto('/public-env');\n\texpect(await page.textContent('h1')).toEqual('The answer is 42');\n\texpect(await page.textContent('h2')).toEqual('The dynamic answer is 42');\n});\n"
  },
  {
    "path": "packages/adapter-static/test/apps/prerendered/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tplugins: [sveltekit()]\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/.gitignore",
    "content": ".DS_Store\nnode_modules\n/.svelte-kit\n/build\n/functions\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/jsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"include\": [\"src/**/*.d.ts\", \"src/**/*.js\", \"src/**/*.svelte\"]\n}\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/package.json",
    "content": "{\n\t\"name\": \"~TODO~\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build --mode staging\",\n\t\t\"preview\": \"sirv -p 5173 -s 200.html build\",\n\t\t\"test\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"sirv-cli\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/src/routes/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.status}</h1>\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/src/routes/+layout.svelte",
    "content": "<nav>\n\t<a href=\"/\">home</a>\n\t<a href=\"/about\">about</a>\n</nav>\n\n<slot />\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/src/routes/+page.svelte",
    "content": "<h1>This page was not prerendered</h1>\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/src/routes/about/+page.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/src/routes/about/+page.svelte",
    "content": "<h1>This page was prerendered</h1>\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/src/routes/fallback/[...rest]/+page.svelte",
    "content": "<script>\n\timport { PUBLIC_VALUE } from '$env/static/public';\n</script>\n\n<h1>the fallback page was rendered</h1>\n\n<b>{PUBLIC_VALUE}</b>\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/svelte.config.js",
    "content": "import adapter from '../../../index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter({\n\t\t\tfallback: '200.html'\n\t\t})\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/test/test.js",
    "content": "import * as fs from 'node:fs';\nimport process from 'node:process';\nimport { expect, test } from '@playwright/test';\n\nconst cwd = process.cwd();\n\ntest('generates a fallback page', async ({ page }) => {\n\texpect(fs.existsSync(`${cwd}/build/200.html`)).toBeTruthy();\n\n\tawait page.goto('/fallback/a/b/c');\n\texpect(await page.textContent('h1')).toEqual('the fallback page was rendered');\n});\n\ntest('does not prerender pages without prerender=true', () => {\n\texpect(fs.existsSync(`${cwd}/build/index.html`)).toBeFalsy();\n});\n\ntest('prerenders page with prerender=true', () => {\n\texpect(fs.existsSync(`${cwd}/build/about.html`)).toBeTruthy();\n});\n\ntest('renders content in fallback page when JS runs', async ({ page }) => {\n\tawait page.goto('/');\n\texpect(await page.textContent('h1')).toEqual('This page was not prerendered');\n});\n\ntest('renders error page for missing page', async ({ page }) => {\n\tawait page.goto('/nosuchpage');\n\texpect(await page.textContent('h1')).toEqual('404');\n});\n\ntest('uses correct environment variables for fallback page (mode = staging)', async ({ page }) => {\n\tawait page.goto('/fallback/x/y/z');\n\texpect(await page.textContent('b')).toEqual('42');\n});\n"
  },
  {
    "path": "packages/adapter-static/test/apps/spa/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tplugins: [sveltekit()]\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-static/test/utils.js",
    "content": "import { devices } from '@playwright/test';\nimport process from 'node:process';\nimport { number_from_env } from '../../../test-utils/index.js';\n\n/** @type {import('@playwright/test').PlaywrightTestConfig} */\nexport const config = {\n\tforbidOnly: !!process.env.CI,\n\t// generous timeouts on CI\n\ttimeout: process.env.CI ? 45000 : 15000,\n\twebServer: {\n\t\tcommand: 'pnpm build && pnpm preview',\n\t\tport: 5173\n\t},\n\tretries: process.env.CI ? 2 : number_from_env('KIT_E2E_RETRIES', 0),\n\tprojects: [\n\t\t{\n\t\t\tname: 'chromium'\n\t\t}\n\t],\n\tuse: {\n\t\t...devices['Desktop Chrome'],\n\t\tscreenshot: 'only-on-failure',\n\t\ttrace: 'retain-on-failure',\n\t\tchannel: 'chromium'\n\t},\n\tworkers: process.env.CI ? 2 : number_from_env('KIT_E2E_WORKERS', undefined),\n\treporter: 'list',\n\ttestDir: 'test',\n\ttestMatch: /(.+\\.)?(test|spec)\\.[jt]s/\n};\n"
  },
  {
    "path": "packages/adapter-static/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"noImplicitAny\": true,\n\t\t\"strictNullChecks\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"node16\",\n\t\t\"moduleResolution\": \"node16\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../kit/types/index\"]\n\t\t}\n\t},\n\t\"include\": [\"index.js\", \"internal.d.ts\", \"test/utils.js\"]\n}\n"
  },
  {
    "path": "packages/adapter-vercel/.gitignore",
    "content": ".DS_Store\nnode_modules\n"
  },
  {
    "path": "packages/adapter-vercel/CHANGELOG.md",
    "content": "# @sveltejs/adapter-vercel\n\n## 6.3.3\n### Patch Changes\n\n\n- fix: ensure build does not copy Vercel build environment system files ([#15400](https://github.com/sveltejs/kit/pull/15400))\n\n## 6.3.2\n### Patch Changes\n\n\n- fix: 404 for immutable assets that don't match static files ([`c67da8a`](https://github.com/sveltejs/kit/commit/c67da8ab6380349b30c353247688369eaef58c05))\n\n- Updated dependencies [[`3e607b3`](https://github.com/sveltejs/kit/commit/3e607b314aec9e5f278d32847945b8b6323e1cb8), [`62991c8`](https://github.com/sveltejs/kit/commit/62991c81db4f50ccfb08a9ac5e05ccba4ddab59e), [`f47c01b`](https://github.com/sveltejs/kit/commit/f47c01bd8100328c24fdb8522fe35913b0735f35)]:\n  - @sveltejs/kit@2.52.2\n\n## 6.3.1\n### Patch Changes\n\n\n- feat: show remote function calls under the /_app/remote route in observability ([#15098](https://github.com/sveltejs/kit/pull/15098))\n\n\n- fix: prevent isr routes from handling remote function calls ([#15098](https://github.com/sveltejs/kit/pull/15098))\n\n- Updated dependencies [[`46c1ebd`](https://github.com/sveltejs/kit/commit/46c1ebd9f662f0de499e921bfee2661316449e9d), [`2dd74c8`](https://github.com/sveltejs/kit/commit/2dd74c8c86ae4855c3e9d74d8cf241e86dcd5b36), [`8871b54`](https://github.com/sveltejs/kit/commit/8871b5444413d0c7d7ef4d260996c3b5c359d0b8)]:\n  - @sveltejs/kit@2.50.1\n\n## 6.3.0\n### Minor Changes\n\n\n- chore: mark `RequestContext` as deprecated and refer to `@vercel/functions` ([#14725](https://github.com/sveltejs/kit/pull/14725))\n\n\n### Patch Changes\n\n- Updated dependencies [[`e67613c`](https://github.com/sveltejs/kit/commit/e67613cf0dde5b7b22e7ef2e2fa2d9171505c784), [`a5c313e`](https://github.com/sveltejs/kit/commit/a5c313e026659874981868fe9628ed6a311dcc06), [`06de550`](https://github.com/sveltejs/kit/commit/06de5506b6db0e39e2ded47e239af39f64d647a8)]:\n  - @sveltejs/kit@2.49.3\n\n## 6.2.0\n### Minor Changes\n\n\n- feat: Node 24 support ([#14982](https://github.com/sveltejs/kit/pull/14982))\n\n## 6.1.2\n### Patch Changes\n\n\n- chore(deps): upgrade to `@vercel/nft` version 1.0.0 to reduce dependencies ([#14950](https://github.com/sveltejs/kit/pull/14950))\n\n- Updated dependencies [[`0889a2a`](https://github.com/sveltejs/kit/commit/0889a2aa897b64194bc55183d7224df65d8147c1), [`2ff3951`](https://github.com/sveltejs/kit/commit/2ff3951e79e59b522c648138c846f31ad858d5b0), [`5b30755`](https://github.com/sveltejs/kit/commit/5b30755a1d84a1054370b211e56d576e3c96d442)]:\n  - @sveltejs/kit@2.48.7\n\n## 6.1.1\n### Patch Changes\n\n\n- chore: improve runtime config parsing ([#14838](https://github.com/sveltejs/kit/pull/14838))\n\n- Updated dependencies [[`cd72d94`](https://github.com/sveltejs/kit/commit/cd72d942a75eed2c1c2ee4b9d6cba5829a4fdb7a), [`53b1b73`](https://github.com/sveltejs/kit/commit/53b1b73256d5b314b1e08ff13f920d520c4a6aed), [`2ccc638`](https://github.com/sveltejs/kit/commit/2ccc63806fa4049c0c05ebc43dce8905e355ed5a)]:\n  - @sveltejs/kit@2.48.3\n\n## 6.1.0\n### Minor Changes\n\n\n- feat: Add experimental support for Bun runtime ([#14817](https://github.com/sveltejs/kit/pull/14817))\n\n\n### Patch Changes\n\n- Updated dependencies [[`102aecf`](https://github.com/sveltejs/kit/commit/102aecfd228dd632664d748b9e87bc6d219294c4)]:\n  - @sveltejs/kit@2.48.1\n\n## 6.0.0\n### Major Changes\n\n\n- breaking: remove Node polyfills (and by extension support for Node 18) ([#14732](https://github.com/sveltejs/kit/pull/14732))\n\n\n### Minor Changes\n\n\n- feat: parse isr.expiration, allowing it to be a string ([#14691](https://github.com/sveltejs/kit/pull/14691))\n\n\n### Patch Changes\n\n- Updated dependencies [[`9c933a2`](https://github.com/sveltejs/kit/commit/9c933a29e64c04db03e9150fa4e2d74a894d3d12), [`dedda71`](https://github.com/sveltejs/kit/commit/dedda7184dc04543e2ba6ea3e7f50b3836505463)]:\n  - @sveltejs/kit@2.47.0\n\n## 5.10.3\n### Patch Changes\n\n\n- chore: update \"homepage\" field in package.json ([#14579](https://github.com/sveltejs/kit/pull/14579))\n\n## 5.10.2\n### Patch Changes\n\n\n- fix: ensure `read` works in an edge function that has deployment protection. Protection bypass automation must be enabled ([#14147](https://github.com/sveltejs/kit/pull/14147))\n\n- Updated dependencies [[`c8f7ac3`](https://github.com/sveltejs/kit/commit/c8f7ac38e9ae1763e7880a29b7f7df01df964a6d), [`107f767`](https://github.com/sveltejs/kit/commit/107f767e3a1a54187527defb29dce753c4f5fa3f)]:\n  - @sveltejs/kit@2.33.1\n\n## 5.10.1\n### Patch Changes\n\n\n- chore: deprecate `runtime` config ([#14253](https://github.com/sveltejs/kit/pull/14253))\n\n## 5.10.0\n### Minor Changes\n\n\n- feat: use web standard `fetch` export ([#14251](https://github.com/sveltejs/kit/pull/14251))\n\n\n### Patch Changes\n\n- Updated dependencies [[`1d04a77`](https://github.com/sveltejs/kit/commit/1d04a7786725d2d8c412268c36722e55f841fdfe), [`5db4cd4`](https://github.com/sveltejs/kit/commit/5db4cd46489d72471a99a8677a9faf32324b9d7e)]:\n  - @sveltejs/kit@2.32.0\n\n## 5.9.1\n### Patch Changes\n\n\n- fix: avoid erroring on builder properties that only exist on the latest version of SvelteKit ([#14233](https://github.com/sveltejs/kit/pull/14233))\n\n- Updated dependencies [[`f2db41c`](https://github.com/sveltejs/kit/commit/f2db41c0d3a0aefbb080ab6a9aa5822b3e41625c)]:\n  - @sveltejs/kit@2.31.1\n\n## 5.9.0\n### Minor Changes\n\n\n- feat: add `instrumentation.server.ts` for tracing and observability setup ([#13899](https://github.com/sveltejs/kit/pull/13899))\n\n\n### Patch Changes\n\n- Updated dependencies [[`f635678`](https://github.com/sveltejs/kit/commit/f63567812505597b1edc3e01010eca622b03b126), [`f635678`](https://github.com/sveltejs/kit/commit/f63567812505597b1edc3e01010eca622b03b126)]:\n  - @sveltejs/kit@2.31.0\n\n## 5.8.2\n### Patch Changes\n\n\n- chore: add `.git` to the end of `package.json` repository url ([#14134](https://github.com/sveltejs/kit/pull/14134))\n\n- Updated dependencies [[`c968aef`](https://github.com/sveltejs/kit/commit/c968aef5727f978244d5160657b4a7ac651384ae)]:\n  - @sveltejs/kit@2.27.3\n\n## 5.8.1\n### Patch Changes\n\n\n- chore(deps): update dependency @vercel/nft to ^0.30.0 ([#14033](https://github.com/sveltejs/kit/pull/14033))\n\n## 5.8.0\n### Minor Changes\n\n\n- feat: add support for `read` imported from `$app/server` in edge functions ([#13859](https://github.com/sveltejs/kit/pull/13859))\n\n\n### Patch Changes\n\n- Updated dependencies [[`e5ce8bb`](https://github.com/sveltejs/kit/commit/e5ce8bb42ea020b88bd0a4ff18dc600745657541), [`cf88369`](https://github.com/sveltejs/kit/commit/cf883692fa0e163cff6b1a2f9b17a568af14124d)]:\n  - @sveltejs/kit@2.25.0\n\n## 5.7.2\n### Patch Changes\n\n\n- chore(deps): upgrade to esbuild 0.25.4 ([#13770](https://github.com/sveltejs/kit/pull/13770))\n\n## 5.7.1\n### Patch Changes\n\n\n- chore(deps): upgrade esbuild to 0.25.2 ([#13716](https://github.com/sveltejs/kit/pull/13716))\n\n\n- fix: include the `edge-light` bundling condition when building edge functions ([#13720](https://github.com/sveltejs/kit/pull/13720))\n\n- Updated dependencies [[`c51fb554416e0c4a21655c1d79e834f69743d1d5`](https://github.com/sveltejs/kit/commit/c51fb554416e0c4a21655c1d79e834f69743d1d5)]:\n  - @sveltejs/kit@2.20.8\n\n## 5.7.0\n### Minor Changes\n\n\n- feat: create symlink functions for each route, for better observability ([#13679](https://github.com/sveltejs/kit/pull/13679))\n\n\n### Patch Changes\n\n- Updated dependencies [[`7fd7bcb7142e7d0d2dd64174fa1a94d56a45d643`](https://github.com/sveltejs/kit/commit/7fd7bcb7142e7d0d2dd64174fa1a94d56a45d643)]:\n  - @sveltejs/kit@2.20.4\n\n## 5.6.3\n### Patch Changes\n\n\n- chore(deps): upgrade @vercel/nft to fix glob deprecation warnings ([`b1e9781a6dff41841d8e1509311d948421956746`](https://github.com/sveltejs/kit/commit/b1e9781a6dff41841d8e1509311d948421956746))\n\n## 5.6.2\n### Patch Changes\n\n\n- fix: change server-side route resolution endpoint ([#13461](https://github.com/sveltejs/kit/pull/13461))\n\n- Updated dependencies [[`9612a60a0277aef0ab4723a0e7ed8dd03a7ffb95`](https://github.com/sveltejs/kit/commit/9612a60a0277aef0ab4723a0e7ed8dd03a7ffb95), [`3d88ae33fc14b08a1d48c2cb7315739c8cfcd9fd`](https://github.com/sveltejs/kit/commit/3d88ae33fc14b08a1d48c2cb7315739c8cfcd9fd)]:\n  - @sveltejs/kit@2.17.2\n\n## 5.6.1\n### Patch Changes\n\n\n- fix: correct edge function path for route resolution endpoint ([#13409](https://github.com/sveltejs/kit/pull/13409))\n\n## 5.6.0\n### Minor Changes\n\n\n- feat: generate edge function dedicated to server side route resolution when using that option in SvelteKit ([#13379](https://github.com/sveltejs/kit/pull/13379))\n\n\n### Patch Changes\n\n- Updated dependencies [[`09296d0f19c8d1ff57d699e637bd1beabb69d438`](https://github.com/sveltejs/kit/commit/09296d0f19c8d1ff57d699e637bd1beabb69d438), [`d62ed39a431f0db3db4dd90bf6b17ed2a2a2de79`](https://github.com/sveltejs/kit/commit/d62ed39a431f0db3db4dd90bf6b17ed2a2a2de79), [`f30352f874790b9de0bd0eba985a21aef23e158e`](https://github.com/sveltejs/kit/commit/f30352f874790b9de0bd0eba985a21aef23e158e), [`180fa3467e195065c0a25206c6328a908e6952d7`](https://github.com/sveltejs/kit/commit/180fa3467e195065c0a25206c6328a908e6952d7), [`5906e9708965b848b468d0014999c36272dc8d50`](https://github.com/sveltejs/kit/commit/5906e9708965b848b468d0014999c36272dc8d50), [`d62ed39a431f0db3db4dd90bf6b17ed2a2a2de79`](https://github.com/sveltejs/kit/commit/d62ed39a431f0db3db4dd90bf6b17ed2a2a2de79)]:\n  - @sveltejs/kit@2.17.0\n\n## 5.5.3\n### Patch Changes\n\n\n- fix: include ambient type declarations ([#12088](https://github.com/sveltejs/kit/pull/12088))\n\n- Updated dependencies [[`d440c68acac67ed64eea4b9bda267e229303db7b`](https://github.com/sveltejs/kit/commit/d440c68acac67ed64eea4b9bda267e229303db7b), [`6774ebc34330b12ae8c0cae08e98b577d819fffb`](https://github.com/sveltejs/kit/commit/6774ebc34330b12ae8c0cae08e98b577d819fffb), [`777c8ef11f17d2ab48aee0f2347c051663da5826`](https://github.com/sveltejs/kit/commit/777c8ef11f17d2ab48aee0f2347c051663da5826), [`f451f6c4a3dbbc73dc86667c6ff89ab2f46ca9d2`](https://github.com/sveltejs/kit/commit/f451f6c4a3dbbc73dc86667c6ff89ab2f46ca9d2), [`34a03ff16af29e917abebb649b31eadfc40a98a0`](https://github.com/sveltejs/kit/commit/34a03ff16af29e917abebb649b31eadfc40a98a0), [`1c77e283896058084c1cb5752d9ec207987a585e`](https://github.com/sveltejs/kit/commit/1c77e283896058084c1cb5752d9ec207987a585e), [`04958cca5905aaeeff367c9e4a5ce6e90fc64779`](https://github.com/sveltejs/kit/commit/04958cca5905aaeeff367c9e4a5ce6e90fc64779), [`9dc5c0e3e01a3c07010e9996688169be68e1dde8`](https://github.com/sveltejs/kit/commit/9dc5c0e3e01a3c07010e9996688169be68e1dde8), [`00e1a7621de554054d068e4525a9e505d1c2e588`](https://github.com/sveltejs/kit/commit/00e1a7621de554054d068e4525a9e505d1c2e588), [`9fcd1e7574197fa6e7ac000a030378d877cb8837`](https://github.com/sveltejs/kit/commit/9fcd1e7574197fa6e7ac000a030378d877cb8837), [`e541a4057a00f5ab6740fb51b7f88f17776da50a`](https://github.com/sveltejs/kit/commit/e541a4057a00f5ab6740fb51b7f88f17776da50a), [`37f72fbb075b481de8263f62c77125333735f382`](https://github.com/sveltejs/kit/commit/37f72fbb075b481de8263f62c77125333735f382), [`b60707ca8e755be95c86490122aa1b792b9bd6be`](https://github.com/sveltejs/kit/commit/b60707ca8e755be95c86490122aa1b792b9bd6be), [`699f4405c752261cf46c1ad32e4dbadceaffc75b`](https://github.com/sveltejs/kit/commit/699f4405c752261cf46c1ad32e4dbadceaffc75b), [`e2a4538c48295cde06f64fb8c7f0b333fbf95496`](https://github.com/sveltejs/kit/commit/e2a4538c48295cde06f64fb8c7f0b333fbf95496), [`a91ba1f326b6e244503de9a010771d942b461dad`](https://github.com/sveltejs/kit/commit/a91ba1f326b6e244503de9a010771d942b461dad)]:\n  - @sveltejs/kit@2.16.0\n\n## 5.5.2\n### Patch Changes\n\n\n- chore: upgrade `@vercel/nft` to 0.27.9 ([#13129](https://github.com/sveltejs/kit/pull/13129))\n\n- Updated dependencies [[`9fc5ff3339e543b956f7ce5eb31267fa73ee332a`](https://github.com/sveltejs/kit/commit/9fc5ff3339e543b956f7ce5eb31267fa73ee332a), [`85b57168189fa16fe966434ec50cc19425cab275`](https://github.com/sveltejs/kit/commit/85b57168189fa16fe966434ec50cc19425cab275)]:\n  - @sveltejs/kit@2.10.0\n\n## 5.5.1\n### Patch Changes\n\n\n- chore: upgrade @vercel/nft to 0.27.7 ([#13082](https://github.com/sveltejs/kit/pull/13082))\n\n- Updated dependencies [[`78404dfe1eb346723eefc183278b85f25485b419`](https://github.com/sveltejs/kit/commit/78404dfe1eb346723eefc183278b85f25485b419)]:\n  - @sveltejs/kit@2.9.1\n\n## 5.5.0\n### Minor Changes\n\n\n- chore: upgrade esbuild to 0.24.0 ([#12270](https://github.com/sveltejs/kit/pull/12270))\n\n\n### Patch Changes\n\n- Updated dependencies [[`d030f4bb285e70844d09b3f0c87809bae43014b8`](https://github.com/sveltejs/kit/commit/d030f4bb285e70844d09b3f0c87809bae43014b8), [`67dd214863cbc5852eb0e8512efbb7bad5358e8a`](https://github.com/sveltejs/kit/commit/67dd214863cbc5852eb0e8512efbb7bad5358e8a)]:\n  - @sveltejs/kit@2.9.0\n\n## 5.4.8\n### Patch Changes\n\n\n- chore: support building with Node 22 ([#13043](https://github.com/sveltejs/kit/pull/13043))\n\n- Updated dependencies [[`570562b74d9e9f295d9b617478088a650f51e96b`](https://github.com/sveltejs/kit/commit/570562b74d9e9f295d9b617478088a650f51e96b), [`1358cccd52190df3c74bdd8970dbfb06ffc4ec72`](https://github.com/sveltejs/kit/commit/1358cccd52190df3c74bdd8970dbfb06ffc4ec72)]:\n  - @sveltejs/kit@2.8.2\n\n## 5.4.7\n### Patch Changes\n\n\n- fix: disregard presence/absence of trailing slash in prerendered redirect ([#12966](https://github.com/sveltejs/kit/pull/12966))\n\n- Updated dependencies [[`92b2686314a7dbebee1761c3da7719d599f003c7`](https://github.com/sveltejs/kit/commit/92b2686314a7dbebee1761c3da7719d599f003c7)]:\n  - @sveltejs/kit@2.8.0\n\n## 5.4.6\n### Patch Changes\n\n\n- docs: update URLs for new svelte.dev site ([#12857](https://github.com/sveltejs/kit/pull/12857))\n\n- Updated dependencies [[`dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46`](https://github.com/sveltejs/kit/commit/dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46), [`4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d`](https://github.com/sveltejs/kit/commit/4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d), [`3a9b78f04786898ca93f6d4b75ab18d26bc45192`](https://github.com/sveltejs/kit/commit/3a9b78f04786898ca93f6d4b75ab18d26bc45192), [`723eb8b31e6a22c82f730c30e485386c8676b746`](https://github.com/sveltejs/kit/commit/723eb8b31e6a22c82f730c30e485386c8676b746), [`8ec471c875345b751344e67580ff1b772ef2735b`](https://github.com/sveltejs/kit/commit/8ec471c875345b751344e67580ff1b772ef2735b)]:\n  - @sveltejs/kit@2.7.3\n\n## 5.4.5\n### Patch Changes\n\n\n- fix: updated `@default` annotation for runtime ([#12717](https://github.com/sveltejs/kit/pull/12717))\n\n- Updated dependencies [[`3591411e880ed5337123c66365433afe8c2f747b`](https://github.com/sveltejs/kit/commit/3591411e880ed5337123c66365433afe8c2f747b), [`2292170ecba27c70600fae0c2adc473ac9d938e8`](https://github.com/sveltejs/kit/commit/2292170ecba27c70600fae0c2adc473ac9d938e8), [`809983f377f0b18c4651a8a4f3af7b69c0df20ab`](https://github.com/sveltejs/kit/commit/809983f377f0b18c4651a8a4f3af7b69c0df20ab)]:\n  - @sveltejs/kit@2.6.3\n\n## 5.4.4\n### Patch Changes\n\n\n- fix: import `node:process` instead of using globals ([#12641](https://github.com/sveltejs/kit/pull/12641))\n\n- Updated dependencies [[`e798ef718f163bed4f93e1918bd8294f765376ad`](https://github.com/sveltejs/kit/commit/e798ef718f163bed4f93e1918bd8294f765376ad)]:\n  - @sveltejs/kit@2.5.28\n\n## 5.4.3\n### Patch Changes\n\n\n- chore: configure provenance in a simpler manner ([#12570](https://github.com/sveltejs/kit/pull/12570))\n\n- Updated dependencies [[`087a43d391fc38b8c008fb39a804dc6988974101`](https://github.com/sveltejs/kit/commit/087a43d391fc38b8c008fb39a804dc6988974101)]:\n  - @sveltejs/kit@2.5.22\n\n## 5.4.2\n### Patch Changes\n\n\n- chore: package provenance ([#12567](https://github.com/sveltejs/kit/pull/12567))\n\n- Updated dependencies [[`4930a8443caa53bcecee7b690cd28e429b1c8a20`](https://github.com/sveltejs/kit/commit/4930a8443caa53bcecee7b690cd28e429b1c8a20)]:\n  - @sveltejs/kit@2.5.21\n\n## 5.4.1\n### Patch Changes\n\n\n- fix: copy `.eot`, `.otf`, `.ttf`, `.woff`, and `woff2` font files when bundling ([#12439](https://github.com/sveltejs/kit/pull/12439))\n\n## 5.4.0\n### Minor Changes\n\n\n- chore(deps): upgrade to esbuild 0.21 ([#12415](https://github.com/sveltejs/kit/pull/12415))\n\n\n### Patch Changes\n\n- Updated dependencies [[`84298477a014ec471839adf7a4448d91bc7949e4`](https://github.com/sveltejs/kit/commit/84298477a014ec471839adf7a4448d91bc7949e4), [`5645614f497931f587b7cb8b3c885fce892a6a72`](https://github.com/sveltejs/kit/commit/5645614f497931f587b7cb8b3c885fce892a6a72), [`84298477a014ec471839adf7a4448d91bc7949e4`](https://github.com/sveltejs/kit/commit/84298477a014ec471839adf7a4448d91bc7949e4)]:\n  - @sveltejs/kit@2.5.18\n\n## 5.3.2\n\n### Patch Changes\n\n- fix: remove `images` from route-level config ([#12280](https://github.com/sveltejs/kit/pull/12280))\n\n- chore: add keywords for discovery in npm search ([#12330](https://github.com/sveltejs/kit/pull/12330))\n\n- Updated dependencies [[`25acb1d9fce998dccd8050b93cf4142c2b082611`](https://github.com/sveltejs/kit/commit/25acb1d9fce998dccd8050b93cf4142c2b082611), [`642c4a4aff4351b786fe6274aa2f0bf7d905faf9`](https://github.com/sveltejs/kit/commit/642c4a4aff4351b786fe6274aa2f0bf7d905faf9), [`0a0e9aa897123ebec50af08e9385b2ca4fc5bb28`](https://github.com/sveltejs/kit/commit/0a0e9aa897123ebec50af08e9385b2ca4fc5bb28)]:\n  - @sveltejs/kit@2.5.11\n\n## 5.3.1\n\n### Patch Changes\n\n- chore(deps): upgrade to `@vercel/nft` version 0.27.1 ([#12274](https://github.com/sveltejs/kit/pull/12274))\n\n## 5.3.0\n\n### Minor Changes\n\n- chore(deps): upgrade esbuild ([#12118](https://github.com/sveltejs/kit/pull/12118))\n\n### Patch Changes\n\n- Updated dependencies [[`bbab296f6fcc05af6b999182798bcdedabbaa4c9`](https://github.com/sveltejs/kit/commit/bbab296f6fcc05af6b999182798bcdedabbaa4c9)]:\n  - @sveltejs/kit@2.5.6\n\n## 5.2.0\n\n### Minor Changes\n\n- feat: add framework metadata in Vercel build output files ([#11800](https://github.com/sveltejs/kit/pull/11800))\n\n- feat: implement version skew protection ([#11987](https://github.com/sveltejs/kit/pull/11987))\n\n## 5.1.1\n\n### Patch Changes\n\n- fix: handle optional and rest routes for incremental static regeneration (ISR) correctly ([#11928](https://github.com/sveltejs/kit/pull/11928))\n\n## 5.1.0\n\n### Minor Changes\n\n- feat: allow compatible subset of Node.js built-in modules when targeting edge functions ([#11675](https://github.com/sveltejs/kit/pull/11675))\n\n### Patch Changes\n\n- Updated dependencies [[`36dc54ac740b8b4c6a2b904a1d0aadd8923a875c`](https://github.com/sveltejs/kit/commit/36dc54ac740b8b4c6a2b904a1d0aadd8923a875c), [`5dae3676b8cc6f8ee0def57340e6a6e591bafecd`](https://github.com/sveltejs/kit/commit/5dae3676b8cc6f8ee0def57340e6a6e591bafecd), [`ada595908b5501b8f4ac30c89c0d6314f364fde3`](https://github.com/sveltejs/kit/commit/ada595908b5501b8f4ac30c89c0d6314f364fde3), [`e228f8997840b89c6248e1c5df6f3108008a06be`](https://github.com/sveltejs/kit/commit/e228f8997840b89c6248e1c5df6f3108008a06be)]:\n  - @sveltejs/kit@2.4.1\n\n## 5.0.0\n\n### Major Changes\n\n- breaking: update peer dependency on `@sveltejs/kit` ([#11649](https://github.com/sveltejs/kit/pull/11649))\n\n### Minor Changes\n\n- feat: support `read` from `$app/server` ([#11649](https://github.com/sveltejs/kit/pull/11649))\n\n### Patch Changes\n\n- Updated dependencies [[`288f731c8a5b20cadb9e219f9583f3f16bf8c7b8`](https://github.com/sveltejs/kit/commit/288f731c8a5b20cadb9e219f9583f3f16bf8c7b8)]:\n  - @sveltejs/kit@2.4.0\n\n## 4.0.5\n\n### Patch Changes\n\n- chore: upgrade esbuild to 0.19.11 ([#11632](https://github.com/sveltejs/kit/pull/11632))\n\n## 4.0.4\n\n### Patch Changes\n\n- fix: update @vercel/nft to 0.26.1 ([#11508](https://github.com/sveltejs/kit/pull/11508))\n\n## 4.0.3\n\n### Patch Changes\n\n- chore: update primary branch from master to main ([`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d))\n\n- Updated dependencies [[`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d), [`16961e8cd3fa6a7f382153b1ff056bc2aae9b31b`](https://github.com/sveltejs/kit/commit/16961e8cd3fa6a7f382153b1ff056bc2aae9b31b), [`197e01f95652f511160f38b37b9da73a124ecd48`](https://github.com/sveltejs/kit/commit/197e01f95652f511160f38b37b9da73a124ecd48), [`102e4a5ae5b29624302163faf5a20c94a64a5b2c`](https://github.com/sveltejs/kit/commit/102e4a5ae5b29624302163faf5a20c94a64a5b2c), [`f8e3d8b9728c9f1ab63389342c31d7246b6f9db6`](https://github.com/sveltejs/kit/commit/f8e3d8b9728c9f1ab63389342c31d7246b6f9db6)]:\n  - @sveltejs/kit@2.0.4\n\n## 4.0.2\n\n### Patch Changes\n\n- fix: remove broken node 16 support ([#11328](https://github.com/sveltejs/kit/pull/11328))\n\n## 4.0.1\n\n### Patch Changes\n\n- chore(deps): update `@vercel/nft` ([#11281](https://github.com/sveltejs/kit/pull/11281))\n\n## 4.0.0\n\n### Major Changes\n\n- breaking: require SvelteKit 2 peer dependency ([#11289](https://github.com/sveltejs/kit/pull/11289))\n\n- chore: upgrade esbuild ([#11122](https://github.com/sveltejs/kit/pull/11122))\n\n### Minor Changes\n\n- feat: expose vercel image optimization config in adapter config ([#8667](https://github.com/sveltejs/kit/pull/8667))\n\n## 3.1.0\n\n### Minor Changes\n\n- feat: add support for nodejs20.x ([#11067](https://github.com/sveltejs/kit/pull/11067))\n\n## 3.0.3\n\n### Patch Changes\n\n- chore: upgrade to @vercel/nft version 0.23.0 ([#10445](https://github.com/sveltejs/kit/pull/10445))\n\n- Updated dependencies [[`0f0049810`](https://github.com/sveltejs/kit/commit/0f00498100361ef0a4ea8b0b4e8465e442fa22a6), [`6f36aefe1`](https://github.com/sveltejs/kit/commit/6f36aefe13bf55cfaef14166c60ecee989061ddd)]:\n  - @sveltejs/kit@1.22.4\n\n## 3.0.2\n\n### Patch Changes\n\n- chore: upgrade to esbuild 0.18.11 ([#10330](https://github.com/sveltejs/kit/pull/10330))\n\n- Updated dependencies [[`23d1df702`](https://github.com/sveltejs/kit/commit/23d1df702f0fd77983040404352d8d83fd1dd8a1), [`486a971fe`](https://github.com/sveltejs/kit/commit/486a971fe7c375aae1585f1fa2505e28f86f4b8e)]:\n  - @sveltejs/kit@1.22.2\n\n## 3.0.1\n\n### Patch Changes\n\n- fix: stop incorrectly warning users that crons don't match paths ([#10074](https://github.com/sveltejs/kit/pull/10074))\n\n- Updated dependencies [[`d4de2049c`](https://github.com/sveltejs/kit/commit/d4de2049cd05c7b32cfbe1b0e63b58f345f13372)]:\n  - @sveltejs/kit@1.20.1\n\n## 3.0.0\n\n### Major Changes\n\n- breaking: remove obsolete `envVarsInUse` option ([#9942](https://github.com/sveltejs/kit/pull/9942))\n\n### Patch Changes\n\n- fix: Copy .wasm files during build ([#9944](https://github.com/sveltejs/kit/pull/9944))\n\n- Updated dependencies [[`50acb22ca`](https://github.com/sveltejs/kit/commit/50acb22caf2901283e044cdfda36db6f07b3e0ae), [`2e6da9496`](https://github.com/sveltejs/kit/commit/2e6da9496bdace2c65040b9d1845c44801ca868c), [`a81106b3a`](https://github.com/sveltejs/kit/commit/a81106b3a817829c41e048207d6253e63988c58c), [`a6338a0b1`](https://github.com/sveltejs/kit/commit/a6338a0b124f54bda7ba3fe64be1d6173e118d00), [`4a85b7f08`](https://github.com/sveltejs/kit/commit/4a85b7f0820d35c7830c00afe1df3c94fcbf8c3d), [`26d2b7f8f`](https://github.com/sveltejs/kit/commit/26d2b7f8f5ca29c60ef61b936ff86deaeb1636ce), [`bc70b4e63`](https://github.com/sveltejs/kit/commit/bc70b4e636fcbd9593356996bf737e014ff8c238), [`ab9f57721`](https://github.com/sveltejs/kit/commit/ab9f57721fca146af7c4eb41f4875fafa5dfc0d2)]:\n  - @sveltejs/kit@1.17.0\n\n## 2.4.3\n\n### Patch Changes\n\n- chore: update all dependencies with minor version bumps ([#9761](https://github.com/sveltejs/kit/pull/9761))\n\n## 2.4.2\n\n### Patch Changes\n\n- fix: construct correct pathname for isr from route with nested params ([#9470](https://github.com/sveltejs/kit/pull/9470))\n\n- Updated dependencies [[`84a5250d`](https://github.com/sveltejs/kit/commit/84a5250d5fe80a87eb7df5569e76a1dde857aa82), [`95e95828`](https://github.com/sveltejs/kit/commit/95e95828f444a35ca3f71eb1350c6630895c02c9), [`367067f5`](https://github.com/sveltejs/kit/commit/367067f547bb78c61f511e88b9361632862cb4ee), [`e9dd2559`](https://github.com/sveltejs/kit/commit/e9dd2559445958c2fdcb4faa2d94bccac2f1f950), [`ae2f4a8c`](https://github.com/sveltejs/kit/commit/ae2f4a8caacfb671db159f3cdce0894beb485b4f)]:\n  - @sveltejs/kit@1.15.7\n\n## 2.4.1\n\n### Patch Changes\n\n- fix: create separate functions for ISR routes ([#9504](https://github.com/sveltejs/kit/pull/9504))\n\n## 2.4.0\n\n### Minor Changes\n\n- feat: warn when prerender setting makes isr config useless ([#9436](https://github.com/sveltejs/kit/pull/9436))\n\n### Patch Changes\n\n- fix: don't show cron warning when everything's valid ([#9436](https://github.com/sveltejs/kit/pull/9436))\n\n- fix: allow to set isr to false to clear isr config in leafs ([#9436](https://github.com/sveltejs/kit/pull/9436))\n\n## 2.3.2\n\n### Patch Changes\n\n- fix: throw error if `isr` is combined with `runtime: 'edge'` ([#9432](https://github.com/sveltejs/kit/pull/9432))\n\n- Updated dependencies [[`385bd49e`](https://github.com/sveltejs/kit/commit/385bd49efb6890078dcdb523fdf5b621fe1c3e72), [`29ffc785`](https://github.com/sveltejs/kit/commit/29ffc78560a99ce387b10a24f48b7f01205f51e7), [`d257d37d`](https://github.com/sveltejs/kit/commit/d257d37d3cac94f30befa9fe38c2987f84fb551a), [`c45c35e7`](https://github.com/sveltejs/kit/commit/c45c35e7b40837cd1bea3fc26cfb831478e03c00), [`75e2c6f7`](https://github.com/sveltejs/kit/commit/75e2c6f7c8376685317b669767c7767fd21670eb), [`1c085780`](https://github.com/sveltejs/kit/commit/1c08578031395377a98b365a27eb9587594dd06e)]:\n  - @sveltejs/kit@1.12.0\n\n## 2.3.1\n\n### Patch Changes\n\n- docs: remove comment discourage direct use of adapters ([#9344](https://github.com/sveltejs/kit/pull/9344))\n\n- Updated dependencies [[`b575287d`](https://github.com/sveltejs/kit/commit/b575287d063562868d7726f6451352aa43a63453), [`8114c658`](https://github.com/sveltejs/kit/commit/8114c658c0bc053198ff76704c002cfeb8225e2a), [`620f5605`](https://github.com/sveltejs/kit/commit/620f56058de0993e776c146db4c19fca97b9cb39), [`6a91e887`](https://github.com/sveltejs/kit/commit/6a91e887ee4c1bef8aabfafbf1ab6079113c2832), [`1c32723a`](https://github.com/sveltejs/kit/commit/1c32723a52beca0c5aa895b1114341da78d92eaf), [`0f863bbc`](https://github.com/sveltejs/kit/commit/0f863bbc957ab2ed37b04ebd839fc864b945034d), [`78b4a1bb`](https://github.com/sveltejs/kit/commit/78b4a1bb5e1ae11a894d70a0a28cc344ea0b1284), [`66b2f4ef`](https://github.com/sveltejs/kit/commit/66b2f4ef03a5dd60da2757edde4effcfdf3183cf), [`5dada256`](https://github.com/sveltejs/kit/commit/5dada256dc05674a18946f8f19db1f25ba91aeaf), [`a71b5e69`](https://github.com/sveltejs/kit/commit/a71b5e69ef37ce46e8e8590d537036cb7e267d51), [`daad7e48`](https://github.com/sveltejs/kit/commit/daad7e48b175245cbb7efd0e255263bfb52a5ee6), [`18d330b1`](https://github.com/sveltejs/kit/commit/18d330b16330d76c4b2991839c6b4462d5a4163f), [`18d7e81a`](https://github.com/sveltejs/kit/commit/18d7e81a9892e718c3cd07b2366a60f2e09561ab)]:\n  - @sveltejs/kit@1.11.0\n\n## 2.3.0\n\n### Minor Changes\n\n- feat: provide access to request context via `event.platform` ([#9280](https://github.com/sveltejs/kit/pull/9280))\n\n### Patch Changes\n\n- Updated dependencies [[`2b647fd8`](https://github.com/sveltejs/kit/commit/2b647fd85be028bc5775894567ee8b13f91411a7), [`fbe4fe76`](https://github.com/sveltejs/kit/commit/fbe4fe768140abac09bd66edd12c77787cafc2c5), [`744dc81c`](https://github.com/sveltejs/kit/commit/744dc81c6b0d8cade087df733c6d3d3f1281e68c)]:\n  - @sveltejs/kit@1.10.0\n\n## 2.2.1\n\n### Patch Changes\n\n- fix: add catch-all route for 404s ([#9265](https://github.com/sveltejs/kit/pull/9265))\n\n## 2.2.0\n\n### Minor Changes\n\n- feat: validate that Vercel cron paths match an API path ([#9145](https://github.com/sveltejs/kit/pull/9145))\n\n## 2.1.1\n\n### Patch Changes\n\n- fix: move catch-all-regex to the end ([#9185](https://github.com/sveltejs/kit/pull/9185))\n\n- fix: temporarily disable streaming when ISR is used ([#9197](https://github.com/sveltejs/kit/pull/9197))\n\n## 2.1.0\n\n### Minor Changes\n\n- feat: enable experimental response streaming ([#9144](https://github.com/sveltejs/kit/pull/9144))\n\n## 2.0.4\n\n### Patch Changes\n\n- fix: add leading / to isr routes ([#9100](https://github.com/sveltejs/kit/pull/9100))\n\n## 2.0.3\n\n### Patch Changes\n\n- fix: get ISR working on Vercel ([#9063](https://github.com/sveltejs/kit/pull/9063))\n\n## 2.0.2\n\n### Patch Changes\n\n- fix: mark `expiration` as required ([#8943](https://github.com/sveltejs/kit/pull/8943))\n\n- Updated dependencies [[`1960296d`](https://github.com/sveltejs/kit/commit/1960296da62fdd4ad8e8bb7286940b98fbe8db0f), [`1beb19cb`](https://github.com/sveltejs/kit/commit/1beb19cb487bd6d719048f0feedcb2fbee91a005), [`b915dfe9`](https://github.com/sveltejs/kit/commit/b915dfe9d16a930246a469c9aea8c1a84e5157ba), [`a402d50b`](https://github.com/sveltejs/kit/commit/a402d50b33eba2a937d09e635275c319061ce678)]:\n  - @sveltejs/kit@1.5.1\n\n## 2.0.1\n\n### Patch Changes\n\n- chore: throw helpful migration error ([#8915](https://github.com/sveltejs/kit/pull/8915))\n\n## 2.0.0\n\n### Major Changes\n\n- breaking: bump `@sveltejs/kit` peer dependency ([#8740](https://github.com/sveltejs/kit/pull/8740))\n\n### Minor Changes\n\n- feat: support route-level configuration options ([#8740](https://github.com/sveltejs/kit/pull/8740))\n\n### Patch Changes\n\n- Updated dependencies [[`c7648f66`](https://github.com/sveltejs/kit/commit/c7648f6608a413e2654625cbd30f890d2148cf13), [`63613bf1`](https://github.com/sveltejs/kit/commit/63613bf194c18ce50e111585ad770fc93f9e43c7), [`d1f7655e`](https://github.com/sveltejs/kit/commit/d1f7655efdff70d91f94fe0cb0de50ed2511b5e5)]:\n  - @sveltejs/kit@1.5.0\n\n## 1.0.6\n\n### Patch Changes\n\n- fix: add trailing slash -> no trailing slash redirect for prerendered pages ([#8766](https://github.com/sveltejs/kit/pull/8766))\n\n- Updated dependencies [[`438e4318`](https://github.com/sveltejs/kit/commit/438e4318e96f3e192e273b95d20ee8f590e99829)]:\n  - @sveltejs/kit@1.3.4\n\n## 1.0.5\n\n### Patch Changes\n\n- docs: move adapter docs to site ([#8531](https://github.com/sveltejs/kit/pull/8531))\n\n## 1.0.4\n\n### Patch Changes\n\n- fix: publish missing files ([#8532](https://github.com/sveltejs/kit/pull/8532))\n\n## 1.0.3\n\n### Patch Changes\n\n- chore: remove superfluous main field from package.json ([#8519](https://github.com/sveltejs/kit/pull/8519))\n\n- Updated dependencies [[`7e2d3405`](https://github.com/sveltejs/kit/commit/7e2d34056e99f371e22406d941b764df365a2649)]:\n  - @sveltejs/kit@1.1.1\n\n## 1.0.2\n\n### Patch Changes\n\n- docs: add note about inability to access file system at runtime ([#8441](https://github.com/sveltejs/kit/pull/8441))\n\n- Updated dependencies [[`9c01c32e`](https://github.com/sveltejs/kit/commit/9c01c32ef72bbed630fadcb8283f8f8533ced5e1), [`b6ca02a6`](https://github.com/sveltejs/kit/commit/b6ca02a684dbf13a3138b552e2d2be64697f2254), [`130abe43`](https://github.com/sveltejs/kit/commit/130abe43cef2cfbaf922aa16b20cbd4332a07c15), [`c4137536`](https://github.com/sveltejs/kit/commit/c4137536f2c6572eaeec1a82ccea0852f5be6b98), [`40464efa`](https://github.com/sveltejs/kit/commit/40464efab172a17f0b637d7dadea30d77ef1ed10), [`ce028470`](https://github.com/sveltejs/kit/commit/ce0284708184198efdd30f3ff72fd579cef830b4)]:\n  - @sveltejs/kit@1.0.12\n\n## 1.0.1\n\n### Patch Changes\n\n- fix: only apply immutable cache-control headers to immutable assets ([#8332](https://github.com/sveltejs/kit/pull/8332))\n\n## 1.0.0\n\n### Major Changes\n\nFirst major release, see below for the history of changes that lead up to this.\nStarting from now all releases follow semver and changes will be listed as Major/Minor/Patch\n\n## 1.0.0-next.88\n\n### Patch Changes\n\n- chore: add peerDependencies, add more specific next version ([#8141](https://github.com/sveltejs/kit/pull/8141))\n\n## 1.0.0-next.87\n\n### Patch Changes\n\n- fix: revert platform change from browser to neutral ([#8122](https://github.com/sveltejs/kit/pull/8122))\n\n## 1.0.0-next.86\n\n### Patch Changes\n\n- fix: set esbuild platform to neutral ([#8083](https://github.com/sveltejs/kit/pull/8083))\n\n## 1.0.0-next.85\n\n### Patch Changes\n\n- update esbuild to ^0.16.3 ([#7543](https://github.com/sveltejs/kit/pull/7543))\n\n## 1.0.0-next.84\n\n### Patch Changes\n\n- fix: Write redirects for prerendered pages with trailing slashes ([#7747](https://github.com/sveltejs/kit/pull/7747))\n\n## 1.0.0-next.83\n\n### Patch Changes\n\n- fix: handle root route for split config ([#7741](https://github.com/sveltejs/kit/pull/7741))\n\n## 1.0.0-next.82\n\n### Patch Changes\n\n- Handle redirects inside SvelteKit ([#7719](https://github.com/sveltejs/kit/pull/7719))\n\n## 1.0.0-next.81\n\n### Patch Changes\n\n- update dependencies ([#7355](https://github.com/sveltejs/kit/pull/7355))\n\n## 1.0.0-next.80\n\n### Patch Changes\n\n- fix: don't fail on unknown error message ([#7312](https://github.com/sveltejs/kit/pull/7312))\n\n## 1.0.0-next.79\n\n### Patch Changes\n\n- Use config.kit.paths.base prefix for static assets ([#4448](https://github.com/sveltejs/kit/pull/4448))\n\n## 1.0.0-next.78\n\n### Patch Changes\n\n- Transfer server data as devalue-encoded JSON ([#7177](https://github.com/sveltejs/kit/pull/7177))\n\n## 1.0.0-next.77\n\n### Patch Changes\n\n- Redact error message if `getRequest` fails ([#6936](https://github.com/sveltejs/kit/pull/6936))\n\n## 1.0.0-next.76\n\n### Patch Changes\n\n- chore: bump esbuild ([#6829](https://github.com/sveltejs/kit/pull/6829))\n\n## 1.0.0-next.75\n\n### Patch Changes\n\n- Ignore warnings when traced file fails to parse ([#6810](https://github.com/sveltejs/kit/pull/6810))\n\n## 1.0.0-next.74\n\n### Patch Changes\n\n- Update to esbuild 0.15 ([#6740](https://github.com/sveltejs/kit/pull/6740))\n\n## 1.0.0-next.73\n\n### Patch Changes\n\n- breaking: request creation cleanup ([#6681](https://github.com/sveltejs/kit/pull/6681))\n\n## 1.0.0-next.72\n\n### Patch Changes\n\n- Fix `global is not defined` runtime error building with `edge: true` option ([#6425](https://github.com/sveltejs/kit/pull/6425))\n\n## 1.0.0-next.71\n\n### Patch Changes\n\n- Use devalue to serialize server-only `load` return values ([#6318](https://github.com/sveltejs/kit/pull/6318))\n\n## 1.0.0-next.70\n\n### Patch Changes\n\n- Don't use top-level-await, as it is not supported right now ([#6360](https://github.com/sveltejs/kit/pull/6360))\n\n## 1.0.0-next.69\n\n### Patch Changes\n\n- Run `server.init()` for edge functions ([#6327](https://github.com/sveltejs/kit/pull/6327))\n\n## 1.0.0-next.68\n\n### Patch Changes\n\n- feat: Moved hooks.js initialization from Server.respond into Server.init ([#6179](https://github.com/sveltejs/kit/pull/6179))\n\n## 1.0.0-next.67\n\n### Patch Changes\n\n- Use `platform: 'browser'` for esbuild in Vercel Edge Functions. ([#6109](https://github.com/sveltejs/kit/pull/6109))\n\n## 1.0.0-next.66\n\n### Patch Changes\n\n- Initialise `env` ([#5663](https://github.com/sveltejs/kit/pull/5663))\n\n## 1.0.0-next.65\n\n### Patch Changes\n\n- breaking: remove writeStatic to align with Vite ([#5618](https://github.com/sveltejs/kit/pull/5618))\n\n## 1.0.0-next.64\n\n### Patch Changes\n\n- Don't remove .vercel/output directory ([#5555](https://github.com/sveltejs/kit/pull/5555))\n\n## 1.0.0-next.63\n\n### Patch Changes\n\n- Print friendlier message if adapter-vercel fails to resolve dependencies ([#5551](https://github.com/sveltejs/kit/pull/5551))\n\n## 1.0.0-next.62\n\n### Patch Changes\n\n- Update dependencies ([#5005](https://github.com/sveltejs/kit/pull/5005))\n\n## 1.0.0-next.61\n\n### Patch Changes\n\n- Remove ENABLE_VC_BUILD check, use v3 build output API for all apps deployed to Vercel ([#5514](https://github.com/sveltejs/kit/pull/5514))\n\n## 1.0.0-next.60\n\n### Patch Changes\n\n- chore: upgrade TypeScript to 4.7.4 ([#5414](https://github.com/sveltejs/kit/pull/5414))\n\n## 1.0.0-next.59\n\n### Patch Changes\n\n- Add sourcemap generation for the generated functions ([#5197](https://github.com/sveltejs/kit/pull/5197))\n\n## 1.0.0-next.58\n\n### Patch Changes\n\n- Update dependencies ([#5121](https://github.com/sveltejs/kit/pull/5121))\n\n## 1.0.0-next.57\n\n### Patch Changes\n\n- Update adapter entrypoint typings to be NodeNext/ESNext-compatible ([#5111](https://github.com/sveltejs/kit/pull/5111))\n\n## 1.0.0-next.56\n\n### Patch Changes\n\n- Use @vercel/nft to include dependencies in lambda without bundling with esbuild, when using v3 build output API ([#4969](https://github.com/sveltejs/kit/pull/4969))\n\n* only serve `_app/immutable` with immutable cache header, not `_app/version.json` ([#5051](https://github.com/sveltejs/kit/pull/5051))\n\n## 1.0.0-next.55\n\n### Patch Changes\n\n- Add types to pkg.exports ([#5045](https://github.com/sveltejs/kit/pull/5045))\n\n## 1.0.0-next.54\n\n### Patch Changes\n\n- breaking: replace @sveltejs/kit/install-fetch with @sveltejs/kit/node/polyfills ([#4934](https://github.com/sveltejs/kit/pull/4934))\n\n## 1.0.0-next.53\n\n### Patch Changes\n\n- Revert to cjs mode when building for lambda ([#4967](https://github.com/sveltejs/kit/pull/4967))\n\n## 1.0.0-next.52\n\n### Patch Changes\n\n- breaking: drop Node 14 support ([#4922](https://github.com/sveltejs/kit/pull/4922))\n\n* Use general purpose Edge Functions instead of piggybacking Middleware for Edge Deployment + fix split mode ([#4883](https://github.com/sveltejs/kit/pull/4883))\n\n## 1.0.0-next.51\n\n### Patch Changes\n\n- Support for Node.js 16 ([#4904](https://github.com/sveltejs/kit/pull/4904))\n- The output of serverless now is ESM instead of CJS ([#4904](https://github.com/sveltejs/kit/pull/4904))\n\n## 1.0.0-next.50\n\n### Patch Changes\n\n- Fix `edge: true, split: true` build error for root routes when deploying to Vercel ([#4731](https://github.com/sveltejs/kit/pull/4731))\n\n## 1.0.0-next.49\n\n### Patch Changes\n\n- Remove unused target option from config.json ([#4678](https://github.com/sveltejs/kit/pull/4678))\n\n## 1.0.0-next.48\n\n### Patch Changes\n\n- Support build output API, with edge functions and code-splitting ([#4663](https://github.com/sveltejs/kit/pull/4663))\n\n## 1.0.0-next.47\n\n### Patch Changes\n\n- Provide getClientAddress function ([#4289](https://github.com/sveltejs/kit/pull/4289))\n\n## 1.0.0-next.46\n\n### Patch Changes\n\n- breaking: replace builder.prerender() with builder.writePrerendered() and builder.prerendered ([#4192](https://github.com/sveltejs/kit/pull/4192)) ([#4229](https://github.com/sveltejs/kit/pull/4229))\n\n## 1.0.0-next.45\n\n### Patch Changes\n\n- Rename `__fetch_polyfill` to `installFetch` ([#4111](https://github.com/sveltejs/kit/pull/4111))\n\n## 1.0.0-next.44\n\n### Patch Changes\n\n- breaking: rename `app.render` to `server.respond` ([#4034](https://github.com/sveltejs/kit/pull/4034))\n\n## 1.0.0-next.43\n\n### Patch Changes\n\n- Add prerendered routes to config ([#3822](https://github.com/sveltejs/kit/pull/3822))\n\n## 1.0.0-next.42\n\n### Patch Changes\n\n- Clean URLs and handle trailingSlash configuration ([#3820](https://github.com/sveltejs/kit/pull/3820))\n\n## 1.0.0-next.41\n\n### Patch Changes\n\n- update to Vite 2.8 and esbuild 0.14 ([#3791](https://github.com/sveltejs/kit/pull/3791))\n\n## 1.0.0-next.40\n\n### Patch Changes\n\n- Expose external option ([#3614](https://github.com/sveltejs/kit/pull/3614))\n\n## 1.0.0-next.39\n\n### Patch Changes\n\n- Breaking: change app.render signature to (request: Request) => Promise<Response> ([#3384](https://github.com/sveltejs/kit/pull/3384))\n\n## 1.0.0-next.38\n\n### Patch Changes\n\n- Polyfill fetch before running any app code ([#3400](https://github.com/sveltejs/kit/pull/3400))\n\n## 1.0.0-next.37\n\n### Patch Changes\n\n- Allow `__fetchPolyfill()` to run several times ([#3377](https://github.com/sveltejs/kit/pull/3377))\n\n## 1.0.0-next.36\n\n### Patch Changes\n\n- Add immutable cache headers to generated assets ([#3222](https://github.com/sveltejs/kit/pull/3222))\n\n## 1.0.0-next.35\n\n### Patch Changes\n\n- Use path.posix to resolve routes for esmodules ([#3200](https://github.com/sveltejs/kit/pull/3200))\n\n## 1.0.0-next.34\n\n### Patch Changes\n\n- Revert to v1 filesystem API ([#3149](https://github.com/sveltejs/kit/pull/3149))\n\n## 1.0.0-next.33\n\n### Patch Changes\n\n- Overhaul adapter API ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- Remove esbuild options ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- Update adapters to provide app.render with a url ([#3133](https://github.com/sveltejs/kit/pull/3133))\n\n## 1.0.0-next.32\n\n### Patch Changes\n\n- update to esbuild 0.13.15 and other dependency updates ([#2957](https://github.com/sveltejs/kit/pull/2957))\n\n## 1.0.0-next.31\n\n### Patch Changes\n\n- update dependencies ([#2574](https://github.com/sveltejs/kit/pull/2574))\n\n## 1.0.0-next.30\n\n### Patch Changes\n\n- update to vite 2.6.0 and esbuild 0.13 ([#2522](https://github.com/sveltejs/kit/pull/2522))\n\n## 1.0.0-next.29\n\n### Patch Changes\n\n- chore: add links to repository and homepage to package.json ([#2425](https://github.com/sveltejs/kit/pull/2425))\n\n## 1.0.0-next.28\n\n### Patch Changes\n\n- chore: export package.json from adapters ([#2351](https://github.com/sveltejs/kit/pull/2351))\n\n## 1.0.0-next.27\n\n### Patch Changes\n\n- d81de603: revert adapters automatically updating .gitignore ([#1924](https://github.com/sveltejs/kit/pull/1924))\n\n## 1.0.0-next.26\n\n### Patch Changes\n\n- e9f78999: fix: include esbuild config in adapter type definition ([#1954](https://github.com/sveltejs/kit/pull/1954))\n\n## 1.0.0-next.25\n\n### Patch Changes\n\n- e6995797: feat(adapters): expose esbuild configuration ([#1914](https://github.com/sveltejs/kit/pull/1914))\n\n## 1.0.0-next.24\n\n### Patch Changes\n\n- 2ac5781: Use esbuild inject API to insert shims ([#1822](https://github.com/sveltejs/kit/pull/1822))\n\n## 1.0.0-next.23\n\n### Patch Changes\n\n- 9f0c54a: Externalize app initialization to adapters ([#1804](https://github.com/sveltejs/kit/pull/1804))\n\n## 1.0.0-next.22\n\n### Patch Changes\n\n- c51ab7d: Upgrade esbuild to ^0.12.5 ([#1627](https://github.com/sveltejs/kit/pull/1627))\n\n## 1.0.0-next.21\n\n### Patch Changes\n\n- edc307d: Remove peerDependencies due to pnpm bug ([#1621](https://github.com/sveltejs/kit/pull/1621))\n- 2636e68: Attempt to fix peerDependencies specification ([#1620](https://github.com/sveltejs/kit/pull/1620))\n\n## 1.0.0-next.20\n\n### Patch Changes\n\n- c3d36a3: ensure `content-length` limit respected; handle `getRawBody` error(s) ([#1528](https://github.com/sveltejs/kit/pull/1528))\n- 028abd9: Pass validated svelte config to adapter adapt function ([#1559](https://github.com/sveltejs/kit/pull/1559))\n- Updated dependencies [6372690]\n- Updated dependencies [c3d36a3]\n- Updated dependencies [bf77940]\n- Updated dependencies [2172469]\n- Updated dependencies [028abd9]\n  - @sveltejs/kit@1.0.0-next.110\n\n## 1.0.0-next.19\n\n### Patch Changes\n\n- dca4946: Make kit a peerDependency of the adapters ([#1505](https://github.com/sveltejs/kit/pull/1505))\n- Updated dependencies [261ee1c]\n- Updated dependencies [ec156c6]\n- Updated dependencies [586785d]\n  - @sveltejs/kit@1.0.0-next.109\n\n## 1.0.0-next.18\n\n### Patch Changes\n\n- dad93fc: Fix workspace dependencies ([#1434](https://github.com/sveltejs/kit/pull/1434))\n- Updated dependencies [dad93fc]\n- Updated dependencies [37fc04f]\n  - @sveltejs/kit@1.0.0-next.108\n\n## 1.0.0-next.17\n\n### Patch Changes\n\n- 9b448a6: Rename @sveltejs/kit/http to @sveltejs/kit/node ([#1391](https://github.com/sveltejs/kit/pull/1391))\n- Updated dependencies [9b448a6]\n  - @sveltejs/kit@1.0.0-next.104\n\n## 1.0.0-next.16\n\n### Patch Changes\n\n- c6fde99: Convert to ESM ([#1323](https://github.com/sveltejs/kit/pull/1323))\n- Updated dependencies [694f5de]\n- Updated dependencies [0befffb]\n- Updated dependencies [c6fde99]\n  - @sveltejs/kit@1.0.0-next.97\n\n## 1.0.0-next.15\n\n### Patch Changes\n\n- 2e72a94: Add type declarations ([#1230](https://github.com/sveltejs/kit/pull/1230))\n- Updated dependencies [82955ec]\n  - @sveltejs/kit@1.0.0-next.91\n\n## 1.0.0-next.14\n\n### Patch Changes\n\n- 59f9277: fix body parsing ([#1146](https://github.com/sveltejs/kit/pull/1146))\n\n## 1.0.0-next.13\n\n### Patch Changes\n\n- 1237eb3: Fix dependencies ([#1109](https://github.com/sveltejs/kit/pull/1109))\n- 1237eb3: Use getRawBody in adapter-vercel ([#1109](https://github.com/sveltejs/kit/pull/1109))\n- Updated dependencies [1237eb3]\n- Updated dependencies [1237eb3]\n  - @sveltejs/kit@1.0.0-next.81\n\n## 1.0.0-next.12\n\n### Patch Changes\n\n- 7a4b351: Bundle serverless functions with esbuild ([#1091](https://github.com/sveltejs/kit/pull/1091))\n\n## 1.0.0-next.11\n\n### Patch Changes\n\n- 6e27880: Move server-side fetch to adapters instead of build step ([#1066](https://github.com/sveltejs/kit/pull/1066))\n\n## 1.0.0-next.10\n\n### Patch Changes\n\n- feb2db7: Simplify parsing of URLS of incoming requests ([#802](https://github.com/sveltejs/kit/pull/802))\n\n## 1.0.0-next.9\n\n### Patch Changes\n\n- ca33a35: Fix adapter-vercel query parsing and update adapter-node's ([#774](https://github.com/sveltejs/kit/pull/774))\n\n## 1.0.0-next.8\n\n### Patch Changes\n\n- 8024178: remove @sveltejs/app-utils ([#600](https://github.com/sveltejs/kit/pull/600))\n\n## 1.0.0-next.7\n\n### Patch Changes\n\n- 17e82eb: Fix adapter-vercel imports ([#588](https://github.com/sveltejs/kit/pull/588))\n\n## 1.0.0-next.6\n\n### Patch Changes\n\n- 8805c6d: Pass adapters directly to svelte.config.cjs ([#579](https://github.com/sveltejs/kit/pull/579))\n\n## 1.0.0-next.5\n\n### Patch Changes\n\n- f35a5cd: Change adapter signature ([#505](https://github.com/sveltejs/kit/pull/505))\n\n## 1.0.0-next.4\n\n### Patch Changes\n\n- c3cf3f3: Bump deps ([#492](https://github.com/sveltejs/kit/pull/492))\n- d742029: Fix mixed usage of CJS and ESM ([#483](https://github.com/sveltejs/kit/pull/483))\n- Updated dependencies [c3cf3f3]\n  - @sveltejs/app-utils@1.0.0-next.3\n\n## 1.0.0-next.3\n\n### Patch Changes\n\n- 8123929: Fix adapter-vercel using the wrong directory ([#450](https://github.com/sveltejs/kit/pull/450))\n- Updated dependencies [73dd998]\n- Updated dependencies [b800049]\n  - @sveltejs/app-utils@1.0.0-next.2\n\n## 1.0.0-next.2\n\n### Patch Changes\n\n- Fix adapters and convert to ES modules\n\n## 1.0.0-next.1\n\n### Patch Changes\n\n- Update to new adapter API\n\n## 0.0.3\n\n### Patch Changes\n\n- 67eaeea: Move app-utils stuff into subpackages\n\n## 0.0.2\n\n### Patch Changes\n\n- Use setup\n\n## 0.0.1\n\n### Patch Changes\n\n- 0320208: Rename 'server route' to 'endpoint'\n- 5ca907c: Use shared mkdirp helper\n"
  },
  {
    "path": "packages/adapter-vercel/README.md",
    "content": "# adapter-vercel\n\nA SvelteKit adapter that creates a Vercel app.\n\n## Docs\n\n[Docs](https://svelte.dev/docs/kit/adapter-vercel)\n\n## Changelog\n\n[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/adapter-vercel/CHANGELOG.md).\n"
  },
  {
    "path": "packages/adapter-vercel/ambient.d.ts",
    "content": "import type { RequestContext } from './index.js';\n\ndeclare global {\n\tnamespace App {\n\t\texport interface Platform {\n\t\t\t/**\n\t\t\t * `context` is only available in Edge Functions\n\t\t\t *\n\t\t\t * @deprecated Vercel's context is deprecated. Use [`@vercel/functions`](https://vercel.com/docs/functions/functions-api-reference/vercel-functions-package) instead.\n\t\t\t */\n\t\t\tcontext?: RequestContext;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-vercel/files/edge.js",
    "content": "/* eslint-disable n/prefer-global/process --\n Vercel Edge Runtime does not support node:process */\nimport { Server } from 'SERVER';\nimport { manifest } from 'MANIFEST';\n\nconst server = new Server(manifest);\n\n/** @type {HeadersInit | undefined} */\nlet read_headers;\nif (process.env.VERCEL_AUTOMATION_BYPASS_SECRET) {\n\tread_headers = {\n\t\t'x-vercel-protection-bypass': process.env.VERCEL_AUTOMATION_BYPASS_SECRET\n\t};\n}\n\n/**\n * We don't know the origin until we receive a request, but\n * that's guaranteed to happen before we call `read`\n * @type {string}\n */\nlet origin;\n\nconst initialized = server.init({\n\tenv: /** @type {Record<string, string>} */ (process.env),\n\tread: async (file) => {\n\t\tconst url = `${origin}/${file}`;\n\t\tconst response = await fetch(url, {\n\t\t\t// we need to add a bypass header if the user has deployment protection enabled\n\t\t\t// see https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation\n\t\t\theaders: read_headers\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status === 401) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Please enable Protection Bypass for Automation: https://svelte.dev/docs/kit/adapter-vercel#Troubleshooting-Deployment-protection`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// belt and braces — not sure how we could end up here\n\t\t\tthrow new Error(\n\t\t\t\t`read(...) failed: could not fetch ${url} (${response.status} ${response.statusText})`\n\t\t\t);\n\t\t}\n\n\t\treturn response.body;\n\t}\n});\n\n/**\n * @param {Request} request\n * @param {import('../index.js').RequestContext} context\n */\nexport default async (request, context) => {\n\tif (!origin) {\n\t\torigin = new URL(request.url).origin;\n\t\tawait initialized;\n\t}\n\n\treturn server.respond(request, {\n\t\tgetClientAddress() {\n\t\t\treturn /** @type {string} */ (request.headers.get('x-forwarded-for'));\n\t\t},\n\t\tplatform: {\n\t\t\tcontext\n\t\t}\n\t});\n};\n"
  },
  {
    "path": "packages/adapter-vercel/files/serverless.js",
    "content": "import { createReadableStream } from '@sveltejs/kit/node';\nimport { Server } from 'SERVER';\nimport { manifest } from 'MANIFEST';\nimport process from 'node:process';\n\nconst server = new Server(manifest);\n\nawait server.init({\n\tenv: /** @type {Record<string, string>} */ (process.env),\n\tread: createReadableStream\n});\n\nconst DATA_SUFFIX = '/__data.json';\n\nexport default {\n\t/**\n\t * @param {Request} request\n\t * @returns {Promise<Response>}\n\t */\n\tfetch(request) {\n\t\t// If this is an ISR request, the requested pathname is encoded\n\t\t// as a search parameter, so we need to extract it\n\t\tconst url = new URL(request.url);\n\t\tlet pathname = url.searchParams.get('__pathname');\n\n\t\tif (pathname) {\n\t\t\t// Optional routes' pathname replacements look like `/foo/$1/bar` which means we could end up with an url like /foo//bar\n\t\t\tpathname = pathname.replace(/\\/+/g, '/');\n\n\t\t\turl.pathname = pathname + (url.pathname.endsWith(DATA_SUFFIX) ? DATA_SUFFIX : '');\n\t\t\turl.searchParams.delete('__pathname');\n\n\t\t\trequest = new Request(url, request);\n\t\t}\n\n\t\treturn server.respond(request, {\n\t\t\tgetClientAddress() {\n\t\t\t\treturn /** @type {string} */ (request.headers.get('x-forwarded-for'));\n\t\t\t}\n\t\t});\n\t}\n};\n"
  },
  {
    "path": "packages/adapter-vercel/index.d.ts",
    "content": "import { Adapter } from '@sveltejs/kit';\nimport './ambient.js';\nimport { RuntimeConfigKey } from './utils.js';\n\nexport default function plugin(config?: Config): Adapter;\n\nexport interface ServerlessConfig {\n\t/**\n\t * Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs22.x'`, `'nodejs24.x'` etc).\n\t * @default Same as the build environment\n\t */\n\truntime?: Exclude<RuntimeConfigKey, 'edge'>;\n\t/**\n\t * To which regions to deploy the app. A list of regions.\n\t * More info: https://vercel.com/docs/concepts/edge-network/regions\n\t */\n\tregions?: string[];\n\t/**\n\t * Maximum execution duration (in seconds) that will be allowed for the Serverless Function.\n\t * Serverless only.\n\t */\n\tmaxDuration?: number;\n\t/**\n\t * Amount of memory (RAM in MB) that will be allocated to the Serverless Function.\n\t * Serverless only.\n\t */\n\tmemory?: number;\n\t/**\n\t * If `true`, this route will always be deployed as its own separate function\n\t */\n\tsplit?: boolean;\n\n\t/**\n\t * [Incremental Static Regeneration](https://vercel.com/docs/concepts/incremental-static-regeneration/overview) configuration.\n\t * Serverless only.\n\t */\n\tisr?:\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Expiration time (in seconds) before the cached asset will be re-generated by invoking the Serverless Function. Setting the value to `false` means it will never expire.\n\t\t\t\t */\n\t\t\t\texpiration: number | string | false;\n\t\t\t\t/**\n\t\t\t\t * Random token that can be provided in the URL to bypass the cached version of the asset, by requesting the asset\n\t\t\t\t * with a __prerender_bypass=<token> cookie.\n\t\t\t\t *\n\t\t\t\t * Making a `GET` or `HEAD` request with `x-prerender-revalidate: <token>` will force the asset to be re-validated.\n\t\t\t\t */\n\t\t\t\tbypassToken?: string;\n\t\t\t\t/**\n\t\t\t\t * List of query string parameter names that will be cached independently. If an empty array, query values are not considered for caching. If undefined each unique query value is cached independently\n\t\t\t\t */\n\t\t\t\tallowQuery?: string[] | undefined;\n\t\t  }\n\t\t| false;\n}\n\ntype ImageFormat = 'image/avif' | 'image/webp';\n\ntype RemotePattern = {\n\tprotocol?: 'http' | 'https';\n\thostname: string;\n\tport?: string;\n\tpathname?: string;\n};\n\ntype ImagesConfig = {\n\tsizes: number[];\n\tdomains: string[];\n\tremotePatterns?: RemotePattern[];\n\tminimumCacheTTL?: number; // seconds\n\tformats?: ImageFormat[];\n\tdangerouslyAllowSVG?: boolean;\n\tcontentSecurityPolicy?: string;\n\tcontentDispositionType?: string;\n};\n\n/** @deprecated */\nexport interface EdgeConfig {\n\t/**\n\t * Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs22.x'`, `'nodejs24.x'` etc).\n\t */\n\truntime?: 'edge';\n\t/**\n\t * To which regions to deploy the app. A list of regions or `'all'`.\n\t * More info: https://vercel.com/docs/concepts/edge-network/regions\n\t */\n\tregions?: string[] | 'all';\n\t/**\n\t * List of packages that should not be bundled into the Edge Function.\n\t * Edge only.\n\t */\n\texternal?: string[];\n\t/**\n\t * If `true`, this route will always be deployed as its own separate function\n\t */\n\tsplit?: boolean;\n}\n\nexport type Config = (EdgeConfig | ServerlessConfig) & {\n\t/**\n\t * https://vercel.com/docs/build-output-api/v3/configuration#images\n\t */\n\timages?: ImagesConfig;\n};\n\n// we copy the RequestContext interface from `@vercel/edge` because that package can't co-exist with `@types/node`.\n// see https://github.com/sveltejs/kit/pull/9280#issuecomment-1452110035\n\n/**\n * An extension to the standard `Request` object that is passed to every Edge Function.\n *\n * @deprecated - use [`@vercel/functions`](https://vercel.com/docs/functions/functions-api-reference/vercel-functions-package) instead.\n *\n * @example\n * ```ts\n * import type { RequestContext } from '@vercel/edge';\n *\n * export default async function handler(request: Request, ctx: RequestContext): Promise<Response> {\n *   // ctx is the RequestContext\n * }\n * ```\n */\nexport interface RequestContext {\n\t/**\n\t * A method that can be used to keep the function running after a response has been sent.\n\t * This is useful when you have an async task that you want to keep running even after the\n\t * response has been sent and the request has ended.\n\t *\n\t * @example\n\t *\n\t * <caption>Sending an internal error to an error tracking service</caption>\n\t *\n\t * ```ts\n\t * import type { RequestContext } from '@vercel/edge';\n\t *\n\t * export async function handleRequest(request: Request, ctx: RequestContext): Promise<Response> {\n\t *  try {\n\t *    return await myFunctionThatReturnsResponse();\n\t *  } catch (e) {\n\t *    ctx.waitUntil((async () => {\n\t *      // report this error to your error tracking service\n\t *      await fetch('https://my-error-tracking-service.com', {\n\t *        method: 'POST',\n\t *        body: JSON.stringify({\n\t *          stack: e.stack,\n\t *          message: e.message,\n\t *          name: e.name,\n\t *          url: request.url,\n\t *        }),\n\t *      });\n\t *    })());\n\t *    return new Response('Internal Server Error', { status: 500 });\n\t *  }\n\t * }\n\t * ```\n\t */\n\twaitUntil(\n\t\t/**\n\t\t * A promise that will be kept alive until it resolves or rejects.\n\t\t */ promise: Promise<unknown>\n\t): void;\n}\n"
  },
  {
    "path": "packages/adapter-vercel/index.js",
    "content": "/** @import { BuildOptions } from 'esbuild' */\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\nimport { nodeFileTrace } from '@vercel/nft';\nimport esbuild from 'esbuild';\nimport { get_pathname, parse_isr_expiration, pattern_to_src, resolve_runtime } from './utils.js';\nimport { VERSION } from '@sveltejs/kit';\n\n/**\n * @template T\n * @template {keyof T} K\n * @typedef {Partial<Omit<T, K>> & Required<Pick<T, K>>} PartialExcept\n */\n\n/**\n * We use a custom `Builder` type here to support the minimum version of SvelteKit.\n * @typedef {PartialExcept<import('@sveltejs/kit').Builder, 'log' | 'rimraf' | 'mkdirp' | 'config' | 'prerendered' | 'routes' | 'createEntries' | 'findServerAssets' | 'generateFallback' | 'generateEnvModule' | 'generateManifest' | 'getBuildDirectory' | 'getClientDirectory' | 'getServerDirectory' | 'getAppPath' | 'writeClient' | 'writePrerendered' | 'writePrerendered' | 'writeServer' | 'copy' | 'compress'>} Builder2_4_0\n */\n\nconst name = '@sveltejs/adapter-vercel';\nconst INTERNAL = '![-]'; // this name is guaranteed not to conflict with user routes\n\nconst [kit_major, kit_minor] = VERSION.split('.');\n\n// https://vercel.com/docs/functions/edge-functions/edge-runtime#compatible-node.js-modules\nconst compatible_node_modules = ['async_hooks', 'events', 'buffer', 'assert', 'util'];\n\n/** @type {import('./index.js').default} **/\nconst plugin = function (defaults = {}) {\n\tif ('edge' in defaults) {\n\t\tthrow new Error(\"{ edge: true } has been removed in favour of { runtime: 'edge' }\");\n\t}\n\n\treturn {\n\t\tname,\n\t\t/** @param {Builder2_4_0} builder */\n\t\tasync adapt(builder) {\n\t\t\tif (!builder.routes) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'@sveltejs/adapter-vercel >=2.x (possibly installed through @sveltejs/adapter-auto) requires @sveltejs/kit version 1.5 or higher. ' +\n\t\t\t\t\t\t'Either downgrade the adapter or upgrade @sveltejs/kit'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst dir = '.vercel/output';\n\t\t\tconst tmp = builder.getBuildDirectory('vercel-tmp');\n\n\t\t\tbuilder.rimraf(dir);\n\t\t\tbuilder.rimraf(tmp);\n\n\t\t\tif (fs.existsSync('vercel.json')) {\n\t\t\t\tconst vercel_file = fs.readFileSync('vercel.json', 'utf-8');\n\t\t\t\tconst vercel_config = JSON.parse(vercel_file);\n\t\t\t\tvalidate_vercel_json(builder, vercel_config);\n\t\t\t}\n\n\t\t\tconst files = fileURLToPath(new URL('./files', import.meta.url).href);\n\n\t\t\tconst dirs = {\n\t\t\t\tstatic: `${dir}/static${builder.config.kit.paths.base}`,\n\t\t\t\tfunctions: `${dir}/functions`\n\t\t\t};\n\n\t\t\tbuilder.log.minor('Copying assets...');\n\n\t\t\tbuilder.writeClient(dirs.static);\n\t\t\tbuilder.writePrerendered(dirs.static);\n\n\t\t\tconst static_config = static_vercel_config(builder, defaults, dirs.static);\n\n\t\t\tbuilder.log.minor('Generating serverless function...');\n\n\t\t\t/**\n\t\t\t * @param {string} name\n\t\t\t * @param {import('./index.js').ServerlessConfig} config\n\t\t\t * @param {import('@sveltejs/kit').RouteDefinition<import('./index.js').Config>[]} routes\n\t\t\t */\n\t\t\tasync function generate_serverless_function(name, config, routes) {\n\t\t\t\tconst dir = `${dirs.functions}/${name}.func`;\n\n\t\t\t\tconst relativePath = path.posix.relative(tmp, builder.getServerDirectory());\n\t\t\t\tbuilder.copy(`${files}/serverless.js`, `${tmp}/index.js`, {\n\t\t\t\t\treplace: {\n\t\t\t\t\t\tSERVER: `${relativePath}/index.js`,\n\t\t\t\t\t\tMANIFEST: './manifest.js'\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (builder.hasServerInstrumentationFile?.()) {\n\t\t\t\t\tbuilder.instrument?.({\n\t\t\t\t\t\tentrypoint: `${tmp}/index.js`,\n\t\t\t\t\t\tinstrumentation: `${builder.getServerDirectory()}/instrumentation.server.js`\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\twrite(\n\t\t\t\t\t`${tmp}/manifest.js`,\n\t\t\t\t\t`export const manifest = ${builder.generateManifest({ relativePath, routes })};\\n`\n\t\t\t\t);\n\n\t\t\t\tawait create_function_bundle(builder, `${tmp}/index.js`, dir, config);\n\n\t\t\t\tfor (const asset of builder.findServerAssets(routes)) {\n\t\t\t\t\t// TODO use symlinks, once Build Output API supports doing so\n\t\t\t\t\tbuilder.copy(`${builder.getServerDirectory()}/${asset}`, `${dir}/${asset}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet warned = false;\n\n\t\t\t/**\n\t\t\t * @param {string} name\n\t\t\t * @param {import('./index.js').EdgeConfig} config\n\t\t\t * @param {import('@sveltejs/kit').RouteDefinition<import('./index.js').EdgeConfig>[]} routes\n\t\t\t */\n\t\t\tasync function generate_edge_function(name, config, routes) {\n\t\t\t\tif (!warned) {\n\t\t\t\t\twarned = true;\n\t\t\t\t\tbuilder.log.warn(\n\t\t\t\t\t\t`The \\`runtime: 'edge'\\` option is deprecated, and will be removed in a future version of adapter-vercel`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst tmp = builder.getBuildDirectory(`vercel-tmp/${name}`);\n\t\t\t\tconst relativePath = path.posix.relative(tmp, builder.getServerDirectory());\n\n\t\t\t\tbuilder.copy(`${files}/edge.js`, `${tmp}/edge.js`, {\n\t\t\t\t\treplace: {\n\t\t\t\t\t\tSERVER: `${relativePath}/index.js`,\n\t\t\t\t\t\tMANIFEST: './manifest.js'\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\twrite(\n\t\t\t\t\t`${tmp}/manifest.js`,\n\t\t\t\t\t`export const manifest = ${builder.generateManifest({ relativePath, routes })};\\n`\n\t\t\t\t);\n\n\t\t\t\ttry {\n\t\t\t\t\tconst outdir = `${dirs.functions}/${name}.func`;\n\t\t\t\t\t/** @type {BuildOptions} */\n\t\t\t\t\tconst esbuild_config = {\n\t\t\t\t\t\t// minimum Node.js version supported is v14.6.0 that is mapped to ES2019\n\t\t\t\t\t\t// https://edge-runtime.vercel.app/features/polyfills\n\t\t\t\t\t\t// TODO verify the latest ES version the edge runtime supports\n\t\t\t\t\t\ttarget: 'es2020',\n\t\t\t\t\t\tbundle: true,\n\t\t\t\t\t\tplatform: 'browser',\n\t\t\t\t\t\tconditions: [\n\t\t\t\t\t\t\t// Vercel's Edge runtime key https://runtime-keys.proposal.wintercg.org/#edge-light\n\t\t\t\t\t\t\t'edge-light',\n\t\t\t\t\t\t\t// re-include these since they are included by default when no conditions are specified\n\t\t\t\t\t\t\t// https://esbuild.github.io/api/#conditions\n\t\t\t\t\t\t\t'module'\n\t\t\t\t\t\t],\n\t\t\t\t\t\tformat: 'esm',\n\t\t\t\t\t\texternal: [\n\t\t\t\t\t\t\t...compatible_node_modules,\n\t\t\t\t\t\t\t...compatible_node_modules.map((id) => `node:${id}`),\n\t\t\t\t\t\t\t...(config.external || [])\n\t\t\t\t\t\t],\n\t\t\t\t\t\tsourcemap: 'linked',\n\t\t\t\t\t\tbanner: { js: 'globalThis.global = globalThis;' },\n\t\t\t\t\t\tloader: {\n\t\t\t\t\t\t\t'.wasm': 'copy',\n\t\t\t\t\t\t\t'.woff': 'copy',\n\t\t\t\t\t\t\t'.woff2': 'copy',\n\t\t\t\t\t\t\t'.ttf': 'copy',\n\t\t\t\t\t\t\t'.eot': 'copy',\n\t\t\t\t\t\t\t'.otf': 'copy'\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tconst result = await esbuild.build({\n\t\t\t\t\t\tentryPoints: [`${tmp}/edge.js`],\n\t\t\t\t\t\toutfile: `${outdir}/index.js`,\n\t\t\t\t\t\t...esbuild_config\n\t\t\t\t\t});\n\n\t\t\t\t\tlet instrumentation_result;\n\t\t\t\t\tif (builder.hasServerInstrumentationFile?.()) {\n\t\t\t\t\t\tinstrumentation_result = await esbuild.build({\n\t\t\t\t\t\t\tentryPoints: [`${builder.getServerDirectory()}/instrumentation.server.js`],\n\t\t\t\t\t\t\toutfile: `${outdir}/instrumentation.server.js`,\n\t\t\t\t\t\t\t...esbuild_config\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tbuilder.instrument?.({\n\t\t\t\t\t\t\tentrypoint: `${outdir}/index.js`,\n\t\t\t\t\t\t\tinstrumentation: `${outdir}/instrumentation.server.js`,\n\t\t\t\t\t\t\tmodule: {\n\t\t\t\t\t\t\t\tgenerateText: generate_traced_edge_module\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tconst warnings = instrumentation_result\n\t\t\t\t\t\t? [...result.warnings, ...instrumentation_result.warnings]\n\t\t\t\t\t\t: result.warnings;\n\n\t\t\t\t\tif (warnings.length > 0) {\n\t\t\t\t\t\tconst formatted = await esbuild.formatMessages(warnings, {\n\t\t\t\t\t\t\tkind: 'warning',\n\t\t\t\t\t\t\tcolor: true\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconsole.error(formatted.join('\\n'));\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconst error = /** @type {import('esbuild').BuildFailure} */ (err);\n\t\t\t\t\tfor (const e of error.errors) {\n\t\t\t\t\t\tfor (const node of e.notes) {\n\t\t\t\t\t\t\tconst match =\n\t\t\t\t\t\t\t\t/The package \"(.+)\" wasn't found on the file system but is built into node/.exec(\n\t\t\t\t\t\t\t\t\tnode.text\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (match) {\n\t\t\t\t\t\t\t\tnode.text = `Cannot use \"${match[1]}\" when deploying to Vercel Edge Functions.`;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst formatted = await esbuild.formatMessages(error.errors, {\n\t\t\t\t\t\tkind: 'error',\n\t\t\t\t\t\tcolor: true\n\t\t\t\t\t});\n\n\t\t\t\t\tconsole.error(formatted.join('\\n'));\n\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Bundling with esbuild failed with ${error.errors.length} ${\n\t\t\t\t\t\t\terror.errors.length === 1 ? 'error' : 'errors'\n\t\t\t\t\t\t}`,\n\t\t\t\t\t\t{ cause: err }\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\twrite(\n\t\t\t\t\t`${dirs.functions}/${name}.func/.vc-config.json`,\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\truntime: config.runtime,\n\t\t\t\t\t\t\tregions: config.regions,\n\t\t\t\t\t\t\tentrypoint: 'index.js',\n\t\t\t\t\t\t\tframework: {\n\t\t\t\t\t\t\t\tslug: 'sveltekit',\n\t\t\t\t\t\t\t\tversion: VERSION\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t'\\t'\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/** @type {Map<string, { i: number, config: import('./index.js').Config, routes: import('@sveltejs/kit').RouteDefinition<import('./index.js').Config>[] }>} */\n\t\t\tconst groups = new Map();\n\n\t\t\t/** @type {Map<string, { hash: string, route_id: string }>} */\n\t\t\tconst conflicts = new Map();\n\n\t\t\t/** @type {Map<string, string>} */\n\t\t\tconst functions = new Map();\n\n\t\t\t/** @type {Map<import('@sveltejs/kit').RouteDefinition<import('./index.js').Config>, { expiration: number | false, bypassToken: string | undefined, allowQuery: string[], group: number, passQuery: true }>} */\n\t\t\tconst isr_config = new Map();\n\n\t\t\t/** @type {Set<string>} */\n\t\t\tconst ignored_isr = new Set();\n\n\t\t\t// group routes by config\n\t\t\tfor (const route of builder.routes) {\n\t\t\t\tconst runtime = resolve_runtime(defaults.runtime, route.config.runtime);\n\t\t\t\tconst config = { ...defaults, ...route.config, runtime };\n\n\t\t\t\tif (is_prerendered(route)) {\n\t\t\t\t\tif (config.isr) {\n\t\t\t\t\t\tignored_isr.add(route.id);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (config.isr) {\n\t\t\t\t\tconst directory = path.relative('.', builder.config.kit.files.routes + route.id);\n\n\t\t\t\t\tif (runtime === 'edge') {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`${directory}: Routes using \\`isr\\` must use a Node.js or Bun runtime (for example 'nodejs24.x' or 'experimental_bun1.x')`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (config.isr.allowQuery?.includes('__pathname')) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`${directory}: \\`__pathname\\` is a reserved query parameter for \\`isr.allowQuery\\``\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tisr_config.set(route, {\n\t\t\t\t\t\texpiration: config.isr.expiration,\n\t\t\t\t\t\tbypassToken: config.isr.bypassToken,\n\t\t\t\t\t\tallowQuery: ['__pathname', ...(config.isr.allowQuery ?? [])],\n\t\t\t\t\t\tgroup: isr_config.size + 1,\n\t\t\t\t\t\tpassQuery: true\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst hash = hash_config(config);\n\n\t\t\t\t// first, check there are no routes with incompatible configs that will be merged\n\t\t\t\tconst pattern = route.pattern.toString();\n\t\t\t\tconst existing = conflicts.get(pattern);\n\t\t\t\tif (existing) {\n\t\t\t\t\tif (existing.hash !== hash) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`The ${route.id} and ${existing.route_id} routes must be merged into a single function that matches the ${route.pattern} regex, but they have incompatible configs. You must either rename one of the routes, or make their configs match.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconflicts.set(pattern, { hash, route_id: route.id });\n\t\t\t\t}\n\n\t\t\t\t// then, create a group for each config\n\t\t\t\tconst id = config.split ? `${hash}-${groups.size}` : hash;\n\t\t\t\tlet group = groups.get(id);\n\t\t\t\tif (!group) {\n\t\t\t\t\tgroup = { i: groups.size, config, routes: [] };\n\t\t\t\t\tgroups.set(id, group);\n\t\t\t\t}\n\n\t\t\t\tgroup.routes.push(route);\n\t\t\t}\n\n\t\t\tif (ignored_isr.size) {\n\t\t\t\tbuilder.log.warn(\n\t\t\t\t\t'\\nWarning: The following routes have an ISR config which is ignored because the route is prerendered:'\n\t\t\t\t);\n\n\t\t\t\tfor (const ignored of ignored_isr) {\n\t\t\t\t\tconsole.log(`    - ${ignored}`);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t'Either remove the \"prerender\" option from these routes to use ISR, or remove the ISR config.\\n'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst singular = groups.size === 1;\n\n\t\t\tfor (const group of groups.values()) {\n\t\t\t\tconst generate_function =\n\t\t\t\t\tgroup.config.runtime === 'edge' ? generate_edge_function : generate_serverless_function;\n\n\t\t\t\t// generate one function for the group\n\t\t\t\tconst name = singular ? `${INTERNAL}/catchall` : `${INTERNAL}/${group.i}`;\n\n\t\t\t\tawait generate_function(\n\t\t\t\t\tname,\n\t\t\t\t\t/** @type {any} */ (group.config),\n\t\t\t\t\t/** @type {import('@sveltejs/kit').RouteDefinition<any>[]} */ (group.routes)\n\t\t\t\t);\n\n\t\t\t\tfor (const route of group.routes) {\n\t\t\t\t\tfunctions.set(route.pattern.toString(), name);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!singular) {\n\t\t\t\t// we need to create a catch-all route so that 404s are handled\n\t\t\t\t// by SvelteKit rather than Vercel\n\n\t\t\t\tconst runtime = resolve_runtime(defaults.runtime);\n\t\t\t\tconst generate_function =\n\t\t\t\t\truntime === 'edge' ? generate_edge_function : generate_serverless_function;\n\n\t\t\t\tawait generate_function(\n\t\t\t\t\t`${INTERNAL}/catchall`,\n\t\t\t\t\t/** @type {any} */ ({ ...defaults, runtime }),\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (builder.config.kit.experimental.remoteFunctions) {\n\t\t\t\t// Ensure remote functions are always handled by the catchall route, which will be symlinked to /_app/remote.\n\t\t\t\t// This stops them from being affected by ISR config from other routes that match /[...rest] (ref: #15085)\n\t\t\t\t// and also makes them show as handled by `/_app/remote` in Vercel's observability.\n\n\t\t\t\tconst app_path = builder.getAppPath();\n\t\t\t\tconst remote_dir = path.join(dirs.functions, app_path, 'remote'); // Usually .vercel/output/functions/_app/remote\n\t\t\t\tconst remote_symlink_path = `${remote_dir}.func`;\n\n\t\t\t\t// Handle remote functions with the catchall route as it won't have any ISR settings\n\t\t\t\tconst target = path.join(dirs.functions, INTERNAL, 'catchall.func');\n\n\t\t\t\t// Ensure the parent directory exists before symlinking\n\t\t\t\tbuilder.mkdirp(path.join(dirs.functions, app_path));\n\n\t\t\t\tconst relative = path.relative(path.dirname(remote_symlink_path), target);\n\n\t\t\t\tfs.symlinkSync(relative, remote_symlink_path);\n\n\t\t\t\tstatic_config.routes.push({\n\t\t\t\t\tsrc: `/${app_path}/remote/.+`,\n\t\t\t\t\tdest: `/${app_path}/remote` // Maps to /![-]/catchall via the symlink\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfor (const route of builder.routes) {\n\t\t\t\tif (is_prerendered(route)) continue;\n\n\t\t\t\tconst pattern = route.pattern.toString();\n\t\t\t\tconst src = pattern_to_src(pattern);\n\t\t\t\tconst name = functions.get(pattern);\n\n\t\t\t\tconst isr = isr_config.get(route);\n\t\t\t\tif (isr) {\n\t\t\t\t\tconst isr_name = route.id.slice(1) || '__root__'; // should we check that __root__ isn't a route?\n\t\t\t\t\tconst base = `${dirs.functions}/${isr_name}`;\n\t\t\t\t\tbuilder.mkdirp(base);\n\n\t\t\t\t\tconst target = `${dirs.functions}/${name}.func`;\n\t\t\t\t\tconst relative = path.relative(path.dirname(base), target);\n\n\t\t\t\t\t// create a symlink to the actual function, but use the\n\t\t\t\t\t// route name so that we can derive the correct URL\n\t\t\t\t\tfs.symlinkSync(relative, `${base}.func`);\n\t\t\t\t\tfs.symlinkSync(`../${relative}`, `${base}/__data.json.func`);\n\n\t\t\t\t\tconst pathname = get_pathname(route);\n\t\t\t\t\tconst json = JSON.stringify(\n\t\t\t\t\t\t{ ...isr, expiration: parse_isr_expiration(isr.expiration, route.id) },\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t'\\t'\n\t\t\t\t\t);\n\n\t\t\t\t\twrite(`${base}.prerender-config.json`, json);\n\t\t\t\t\twrite(`${base}/__data.json.prerender-config.json`, json);\n\n\t\t\t\t\tconst q = `?__pathname=/${pathname}`;\n\n\t\t\t\t\tstatic_config.routes.push({\n\t\t\t\t\t\tsrc: src + '$',\n\t\t\t\t\t\tdest: `/${isr_name}${q}`\n\t\t\t\t\t});\n\n\t\t\t\t\tstatic_config.routes.push({\n\t\t\t\t\t\tsrc: src + '/__data.json$',\n\t\t\t\t\t\tdest: `/${isr_name}/__data.json${q}`\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t// Create a symlink for each route to the main function for better observability\n\t\t\t\t\t// (without this, every request appears to go through `/![-]`)\n\n\t\t\t\t\t// Use 'index' for the root route's filesystem representation\n\t\t\t\t\t// Use an empty string ('') for the root route's destination name part in Vercel config\n\t\t\t\t\tconst is_root = route.id === '/';\n\t\t\t\t\tconst route_fs_name = is_root ? 'index' : route.id.slice(1);\n\t\t\t\t\tconst route_dest_name = is_root ? '' : route.id.slice(1);\n\n\t\t\t\t\t// Define paths using path.join for safety\n\t\t\t\t\tconst base_dir = path.join(dirs.functions, route_fs_name); // e.g., .vercel/output/functions/index\n\t\t\t\t\t// The main symlink should be named based on the route, adjacent to its potential directory\n\t\t\t\t\tconst main_symlink_path = `${base_dir}.func`; // e.g., .vercel/output/functions/index.func\n\t\t\t\t\t// The data symlink goes inside the directory\n\t\t\t\t\tconst data_symlink_path = path.join(base_dir, '__data.json.func'); // e.g., .vercel/output/functions/index/__data.json.func\n\n\t\t\t\t\tconst target = path.join(dirs.functions, `${name}.func`); // The actual function directory e.g., .vercel/output/functions/![-].func\n\n\t\t\t\t\t// Ensure the directory for the data endpoint symlink exists (e.g., functions/index/)\n\t\t\t\t\tbuilder.mkdirp(base_dir);\n\n\t\t\t\t\t// Calculate relative paths FROM the directory containing the symlink TO the target\n\t\t\t\t\tconst relative_for_main = path.relative(path.dirname(main_symlink_path), target);\n\t\t\t\t\tconst relative_for_data = path.relative(path.dirname(data_symlink_path), target); // This is path.relative(base_dir, target)\n\n\t\t\t\t\t// Create symlinks\n\t\t\t\t\tfs.symlinkSync(relative_for_main, main_symlink_path); // Creates functions/index.func -> ![-].func\n\t\t\t\t\tfs.symlinkSync(relative_for_data, data_symlink_path); // Creates functions/index/__data.json.func -> ../![-].func\n\n\t\t\t\t\t// Add route to the config\n\t\t\t\t\tstatic_config.routes.push({\n\t\t\t\t\t\tsrc: src + '(?:/__data.json)?$', // Matches the incoming request path\n\t\t\t\t\t\tdest: `/${route_dest_name}` // Maps to the function: '/' for root, '/about' for about, etc.\n\t\t\t\t\t\t// Vercel uses this dest to find the corresponding .func dir/symlink\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// optional chaining to support older versions that don't have this setting yet\n\t\t\tif (builder.config.kit.router?.resolution === 'server') {\n\t\t\t\t// Create a separate edge function just for server-side route resolution.\n\t\t\t\t// By omitting all routes we're ensuring it's small (the routes will still be available\n\t\t\t\t// to the route resolution, because it does not rely on the server routing manifest)\n\t\t\t\tawait generate_edge_function(\n\t\t\t\t\t`${builder.config.kit.appDir}/route`,\n\t\t\t\t\t{\n\t\t\t\t\t\texternal: 'external' in defaults ? defaults.external : undefined,\n\t\t\t\t\t\truntime: 'edge'\n\t\t\t\t\t},\n\t\t\t\t\t[]\n\t\t\t\t);\n\n\t\t\t\tstatic_config.routes.push({\n\t\t\t\t\tsrc: `${builder.config.kit.paths.base}/(|.+/)__route\\\\.js`,\n\t\t\t\t\tdest: `${builder.config.kit.paths.base}/${builder.config.kit.appDir}/route`\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Catch-all route must come at the end, otherwise it will swallow all other routes,\n\t\t\t// including ISR aliases if there is only one function\n\t\t\tstatic_config.routes.push({ src: '/.*', dest: `/${INTERNAL}/catchall` });\n\n\t\t\tbuilder.log.minor('Writing routes...');\n\n\t\t\twrite(`${dir}/config.json`, JSON.stringify(static_config, null, '\\t'));\n\t\t},\n\n\t\tsupports: {\n\t\t\tread: ({ config, route }) => {\n\t\t\t\tconst runtime = config.runtime ?? defaults.runtime;\n\n\t\t\t\t// TODO bump peer dep in next adapter major to simplify this\n\t\t\t\tif (runtime === 'edge' && kit_major === '2' && kit_minor < '25') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${name}: Cannot use \\`read\\` from \\`$app/server\\` in route \\`${route.id}\\` configured with \\`runtime: 'edge'\\` and SvelteKit < 2.25.0`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tinstrumentation: () => true\n\t\t}\n\t};\n};\n\n/** @param {import('./index.js').EdgeConfig & import('./index.js').ServerlessConfig} config */\nfunction hash_config(config) {\n\treturn [\n\t\tconfig.runtime ?? '',\n\t\tconfig.external ?? '',\n\t\tconfig.regions ?? '',\n\t\tconfig.memory ?? '',\n\t\tconfig.maxDuration ?? '',\n\t\t!!config.isr // need to distinguish ISR from non-ISR functions, because ISR functions can't use streaming mode\n\t].join('/');\n}\n\n/**\n * @param {string} file\n * @param {string} data\n */\nfunction write(file, data) {\n\ttry {\n\t\tfs.mkdirSync(path.dirname(file), { recursive: true });\n\t} catch {\n\t\t// do nothing\n\t}\n\n\tfs.writeFileSync(file, data);\n}\n\n// This function is duplicated in adapter-static\n/**\n * @param {Builder2_4_0} builder\n * @param {import('./index.js').Config} config\n * @param {string} dir\n */\nfunction static_vercel_config(builder, config, dir) {\n\t/** @type {any[]} */\n\tconst prerendered_redirects = [];\n\n\t/** @type {Record<string, { path: string }>} */\n\tconst overrides = {};\n\n\t/** @type {import('./index.js').ImagesConfig | undefined} */\n\tconst images = config.images;\n\n\tfor (let [src, redirect] of builder.prerendered.redirects) {\n\t\tif (src.replace(/\\/$/, '') === redirect.location.replace(/\\/$/, '')) {\n\t\t\t// ignore the extreme edge case of a `/foo` -> `/foo/` redirect,\n\t\t\t// which would only arise if the response was generated by a\n\t\t\t// `handle` hook or outside the app altogether (since you\n\t\t\t// can't declaratively create both routes)\n\t\t} else {\n\t\t\t// redirect both `/foo` and `/foo/` to `redirect.location`\n\t\t\tsrc = src.replace(/\\/?$/, '/?');\n\t\t}\n\n\t\tprerendered_redirects.push({\n\t\t\tsrc,\n\t\t\theaders: {\n\t\t\t\tLocation: redirect.location\n\t\t\t},\n\t\t\tstatus: redirect.status\n\t\t});\n\t}\n\n\tfor (const [path, page] of builder.prerendered.pages) {\n\t\tlet overrides_path = path.slice(1);\n\n\t\tif (path !== '/') {\n\t\t\t/** @type {string | undefined} */\n\t\t\tlet counterpart_route = path + '/';\n\n\t\t\tif (path.endsWith('/')) {\n\t\t\t\tcounterpart_route = path.slice(0, -1);\n\t\t\t\toverrides_path = path.slice(1, -1);\n\t\t\t}\n\n\t\t\tprerendered_redirects.push(\n\t\t\t\t{ src: path, dest: counterpart_route },\n\t\t\t\t{ src: counterpart_route, status: 308, headers: { Location: path } }\n\t\t\t);\n\t\t}\n\n\t\toverrides[page.file] = { path: overrides_path };\n\t}\n\n\tconst routes = [\n\t\t// Strip any user-supplied __pathname query parameter; SvelteKit reserves\n\t\t// this for ISR handlers\n\t\t{\n\t\t\tsrc: '.*',\n\t\t\tcontinue: true,\n\t\t\ttransforms: [\n\t\t\t\t{\n\t\t\t\t\ttype: 'request.query',\n\t\t\t\t\top: 'delete',\n\t\t\t\t\ttarget: { key: '__pathname' }\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t...prerendered_redirects,\n\t\t{\n\t\t\tsrc: `/${builder.getAppPath()}/immutable/.+`,\n\t\t\theaders: {\n\t\t\t\t'cache-control': 'public, immutable, max-age=31536000'\n\t\t\t}\n\t\t}\n\t];\n\n\t// https://vercel.com/docs/deployments/skew-protection\n\tif (process.env.VERCEL_SKEW_PROTECTION_ENABLED) {\n\t\troutes.push({\n\t\t\tsrc: '/.*',\n\t\t\thas: [\n\t\t\t\t{\n\t\t\t\t\ttype: 'header',\n\t\t\t\t\tkey: 'Sec-Fetch-Dest',\n\t\t\t\t\tvalue: 'document'\n\t\t\t\t}\n\t\t\t],\n\t\t\theaders: {\n\t\t\t\t'Set-Cookie': `__vdpl=${process.env.VERCEL_DEPLOYMENT_ID}; Path=${builder.config.kit.paths.base}/; SameSite=Strict; Secure; HttpOnly`\n\t\t\t},\n\t\t\tcontinue: true\n\t\t});\n\n\t\t// this is a dreadful hack that is necessary until the Vercel Build Output API\n\t\t// allows you to set multiple cookies for a single route. essentially, since we\n\t\t// know that the entry file will be requested immediately, we can set the second\n\t\t// cookie in _that_ response rather than the document response\n\t\tconst base = `${dir}/${builder.config.kit.appDir}/immutable/entry`;\n\t\tconst entry = fs.readdirSync(base).find((file) => file.startsWith('start.'));\n\n\t\tif (!entry) {\n\t\t\tthrow new Error('Could not find entry point');\n\t\t}\n\n\t\troutes.splice(-2, 0, {\n\t\t\tsrc: `/${builder.getAppPath()}/immutable/entry/${entry}`,\n\t\t\theaders: {\n\t\t\t\t'Set-Cookie': `__vdpl=; Path=/${builder.getAppPath()}/version.json; SameSite=Strict; Secure; HttpOnly`\n\t\t\t},\n\t\t\tcontinue: true\n\t\t});\n\t}\n\n\troutes.push({\n\t\thandle: 'filesystem'\n\t});\n\n\t// Prevent incorrect caching: if a request to /_app/immutable/* doesn't match\n\t// a static file, return 404 instead of falling through to dynamic routes.\n\t// Otherwise, we could accidentally immutably cache dynamic content served\n\t// by the fallback function.\n\troutes.push({\n\t\tsrc: `/${builder.getAppPath()}/immutable/.+`,\n\t\tstatus: 404,\n\t\tcontinue: false\n\t});\n\n\treturn {\n\t\tversion: 3,\n\t\troutes,\n\t\toverrides,\n\t\timages\n\t};\n}\n\n/**\n * @param {Builder2_4_0} builder\n * @param {string} entry\n * @param {string} dir\n * @param {import('./index.js').ServerlessConfig} config\n */\nasync function create_function_bundle(builder, entry, dir, config) {\n\tfs.rmSync(dir, { force: true, recursive: true });\n\n\tlet base = entry;\n\twhile (base !== (base = path.dirname(base)));\n\n\tconst traced = await nodeFileTrace([entry], { base });\n\n\t/** @type {Map<string, string[]>} */\n\tconst resolution_failures = new Map();\n\n\ttraced.warnings.forEach((error) => {\n\t\t// pending https://github.com/vercel/nft/issues/284\n\t\tif (error.message.startsWith('Failed to resolve dependency node:')) return;\n\n\t\t// parse errors are likely not js and can safely be ignored,\n\t\t// such as this html file in \"main\" meant for nw instead of node:\n\t\t// https://github.com/vercel/nft/issues/311\n\t\tif (error.message.startsWith('Failed to parse')) return;\n\n\t\tif (error.message.startsWith('Failed to resolve dependency')) {\n\t\t\tconst match = /Cannot find module '(.+?)' loaded from (.+)/;\n\t\t\tconst [, module, importer] = match.exec(error.message) ?? [, error.message, '(unknown)'];\n\n\t\t\tif (!resolution_failures.has(importer)) {\n\t\t\t\tresolution_failures.set(importer, []);\n\t\t\t}\n\n\t\t\t/** @type {string[]} */ (resolution_failures.get(importer)).push(module);\n\t\t} else {\n\t\t\tthrow error;\n\t\t}\n\t});\n\n\tif (resolution_failures.size > 0) {\n\t\tconst cwd = process.cwd();\n\t\tbuilder.log.warn(\n\t\t\t'Warning: The following modules failed to locate dependencies that may (or may not) be required for your app to work:'\n\t\t);\n\n\t\tfor (const [importer, modules] of resolution_failures) {\n\t\t\tconsole.error(`  ${path.relative(cwd, importer)}`);\n\t\t\tfor (const module of modules) {\n\t\t\t\tconsole.error(`    - \\u001B[1m\\u001B[36m${module}\\u001B[39m\\u001B[22m`);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst files = Array.from(traced.fileList);\n\n\t// find common ancestor directory\n\t/** @type {string[]} */\n\tlet common_parts = files[0]?.split(path.sep) ?? [];\n\n\tfor (let i = 1; i < files.length; i += 1) {\n\t\tconst file = files[i];\n\t\tconst parts = file.split(path.sep);\n\n\t\tfor (let j = 0; j < common_parts.length; j += 1) {\n\t\t\tif (parts[j] !== common_parts[j]) {\n\t\t\t\tcommon_parts = common_parts.slice(0, j);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst ancestor = base + common_parts.join(path.sep);\n\n\tfor (const file of traced.fileList) {\n\t\tconst source = base + file;\n\t\tconst dest = path.join(dir, path.relative(ancestor, source));\n\n\t\tconst stats = fs.statSync(source);\n\t\tconst is_dir = stats.isDirectory();\n\n\t\tconst realpath = fs.realpathSync(source);\n\n\t\ttry {\n\t\t\tfs.mkdirSync(path.dirname(dest), { recursive: true });\n\t\t} catch {\n\t\t\t// do nothing\n\t\t}\n\n\t\tif (source !== realpath) {\n\t\t\tconst realdest = path.join(dir, path.relative(ancestor, realpath));\n\t\t\tfs.symlinkSync(path.relative(path.dirname(dest), realdest), dest, is_dir ? 'dir' : 'file');\n\t\t} else if (!is_dir) {\n\t\t\tfs.copyFileSync(source, dest);\n\t\t}\n\t}\n\n\twrite(\n\t\t`${dir}/.vc-config.json`,\n\t\tJSON.stringify(\n\t\t\t{\n\t\t\t\truntime: config.runtime,\n\t\t\t\tregions: config.regions,\n\t\t\t\tmemory: config.memory,\n\t\t\t\tmaxDuration: config.maxDuration,\n\t\t\t\thandler: path.relative(base + ancestor, entry),\n\t\t\t\tlauncherType: 'Nodejs',\n\t\t\t\texperimentalResponseStreaming: !config.isr,\n\t\t\t\tframework: {\n\t\t\t\t\tslug: 'sveltekit',\n\t\t\t\t\tversion: VERSION\n\t\t\t\t}\n\t\t\t},\n\t\t\tnull,\n\t\t\t'\\t'\n\t\t)\n\t);\n\n\twrite(`${dir}/package.json`, JSON.stringify({ type: 'module' }));\n}\n\n/**\n *\n * @param {Builder2_4_0} builder\n * @param {any} vercel_config\n */\nfunction validate_vercel_json(builder, vercel_config) {\n\tif (builder.routes.length > 0 && !builder.routes[0].api) {\n\t\t// bail — we're on an older SvelteKit version that doesn't\n\t\t// populate `route.api.methods`, so we can't check\n\t\t// to see if cron paths are valid\n\t\treturn;\n\t}\n\n\tconst crons = /** @type {Array<unknown>} */ (\n\t\tArray.isArray(vercel_config?.crons) ? vercel_config.crons : []\n\t);\n\n\t/** For a route to be considered 'valid', it must be an API route with a GET handler */\n\tconst valid_routes = builder.routes.filter((route) => route.api.methods.includes('GET'));\n\n\t/** @type {Array<string>} */\n\tconst unmatched_paths = [];\n\n\tfor (const cron of crons) {\n\t\tif (typeof cron !== 'object' || cron === null || !('path' in cron)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst { path } = cron;\n\t\tif (typeof path !== 'string') {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!valid_routes.some((route) => route.pattern.test(path))) {\n\t\t\tunmatched_paths.push(path);\n\t\t}\n\t}\n\n\tif (unmatched_paths.length) {\n\t\tbuilder.log.warn(\n\t\t\t'\\nWarning: vercel.json defines cron tasks that use paths that do not correspond to an API route with a GET handler (ignore this if the request is handled in your `handle` hook):'\n\t\t);\n\n\t\tfor (const path of unmatched_paths) {\n\t\t\tconsole.log(`    - ${path}`);\n\t\t}\n\n\t\tconsole.log('');\n\t}\n}\n\n/** @param {import('@sveltejs/kit').RouteDefinition} route */\nfunction is_prerendered(route) {\n\treturn (\n\t\troute.prerender === true ||\n\t\t(route.prerender === 'auto' && route.segments.every((segment) => !segment.dynamic))\n\t);\n}\n\n/**\n * @param {{ instrumentation: string; start: string }} opts\n */\nfunction generate_traced_edge_module({ instrumentation, start }) {\n\treturn `\\\nimport './${instrumentation}';\nconst promise = import('./${start}');\n\n/**\n * @param {import('http').IncomingMessage} req\n * @param {import('http').ServerResponse} res\n */\nexport default async (req, res) => {\n\tconst { default: handler } = await promise;\n\treturn handler(req, res);\n}\n`;\n}\n\nexport default plugin;\n"
  },
  {
    "path": "packages/adapter-vercel/internal.d.ts",
    "content": "declare module 'SERVER' {\n\texport { Server } from '@sveltejs/kit';\n}\n\ndeclare module 'MANIFEST' {\n\timport { SSRManifest } from '@sveltejs/kit';\n\texport const manifest: SSRManifest;\n}\n"
  },
  {
    "path": "packages/adapter-vercel/package.json",
    "content": "{\n\t\"name\": \"@sveltejs/adapter-vercel\",\n\t\"version\": \"6.3.3\",\n\t\"description\": \"A SvelteKit adapter that creates a Vercel app\",\n\t\"keywords\": [\n\t\t\"adapter\",\n\t\t\"deploy\",\n\t\t\"hosting\",\n\t\t\"svelte\",\n\t\t\"sveltekit\",\n\t\t\"vercel\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/sveltejs/kit.git\",\n\t\t\"directory\": \"packages/adapter-vercel\"\n\t},\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://svelte.dev/docs/kit/adapter-vercel\",\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./index.d.ts\",\n\t\t\t\"import\": \"./index.js\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"types\": \"index.d.ts\",\n\t\"files\": [\n\t\t\"files\",\n\t\t\"index.js\",\n\t\t\"utils.js\",\n\t\t\"index.d.ts\",\n\t\t\"ambient.d.ts\"\n\t],\n\t\"scripts\": {\n\t\t\"lint\": \"prettier --check .\",\n\t\t\"format\": \"pnpm lint --write\",\n\t\t\"check\": \"tsc\",\n\t\t\"test\": \"vitest run\"\n\t},\n\t\"dependencies\": {\n\t\t\"@vercel/nft\": \"^1.3.2\",\n\t\t\"esbuild\": \"^0.25.4\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"@types/node\": \"catalog:\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@sveltejs/kit\": \"^2.4.0\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=20.0\"\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/package.json",
    "content": "{\n\t\"name\": \"test-vercel-basic\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"test:platform\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:*\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/app.d.ts",
    "content": "// See https://svelte.dev/docs/kit/types#app.d.ts\n// for information about these interfaces\ndeclare global {\n\tnamespace App {\n\t\t// interface Error {}\n\t\t// interface Locals {}\n\t\t// interface PageData {}\n\t\t// interface PageState {}\n\t\t// interface Platform {}\n\t}\n}\n\nexport {};\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body data-sveltekit-preload-data=\"hover\">\n\t\t<div style=\"display: contents\">%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/+layout.svelte",
    "content": "<script lang=\"ts\">\n\tlet { children } = $props();\n</script>\n\n{@render children()}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/+page.svelte",
    "content": "<h1>Hello from SvelteKit on Vercel</h1>\n\n<nav>\n\t<a href=\"/server-data\">Server Data</a>\n\t<a href=\"/isr\">ISR</a>\n\t<a href=\"/isr/hello\">ISR Dynamic</a>\n\t<a href=\"/prerendered\">Prerendered</a>\n\t<a href=\"/deep/nested/route\">Deep Nested</a>\n</nav>\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/api/json/+server.ts",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json({ ok: true });\n}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/deep/nested/route/+page.server.ts",
    "content": "export function load({ url }) {\n\treturn {\n\t\tdepth: url.pathname.split('/').length - 1,\n\t\tpath: url.pathname\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/deep/nested/route/+page.svelte",
    "content": "<script lang=\"ts\">\n\tlet { data } = $props();\n</script>\n\n<h1>Deep nested route</h1>\n<p id=\"depth\">{data.depth}</p>\n<p id=\"path\">{data.path}</p>\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/isr/+page.server.ts",
    "content": "export const config = {\n\tisr: {\n\t\texpiration: 60\n\t}\n};\n\nexport function load() {\n\treturn {\n\t\trendered_at: Date.now()\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/isr/+page.svelte",
    "content": "<script lang=\"ts\">\n\tlet { data } = $props();\n</script>\n\n<h1>ISR Page</h1>\n<p id=\"rendered-at\">{data.rendered_at}</p>\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/isr/[slug]/+page.server.ts",
    "content": "export const config = {\n\tisr: {\n\t\texpiration: 60\n\t}\n};\n\nexport function load({ params }) {\n\treturn {\n\t\tslug: params.slug,\n\t\trendered_at: Date.now()\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/isr/[slug]/+page.svelte",
    "content": "<script lang=\"ts\">\n\tlet { data } = $props();\n</script>\n\n<h1>ISR: {data.slug}</h1>\n<p id=\"rendered-at\">{data.rendered_at}</p>\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/prerendered/+page.server.ts",
    "content": "export const prerender = true;\n\nexport function load() {\n\treturn {\n\t\tmessage: 'this page is prerendered'\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/prerendered/+page.svelte",
    "content": "<script lang=\"ts\">\n\tlet { data } = $props();\n</script>\n\n<h1>{data.message}</h1>\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/read/+server.ts",
    "content": "import { read } from '$app/server';\nimport file from './file.txt?url';\n\nexport function GET() {\n\treturn read(file);\n}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/read/file.txt",
    "content": "Hello from $app/server read\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/server-data/+page.server.ts",
    "content": "export function load() {\n\treturn {\n\t\tmessage: 'loaded on server',\n\t\ttimestamp: Date.now()\n\t};\n}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/src/routes/server-data/+page.svelte",
    "content": "<script lang=\"ts\">\n\tlet { data } = $props();\n</script>\n\n<h1>{data.message}</h1>\n<p id=\"timestamp\">{data.timestamp}</p>\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/svelte.config.js",
    "content": "import adapter from '../../../index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/test/test.ts",
    "content": "import { expect, test } from '@playwright/test';\n\ntest('basic page renders', async ({ page }) => {\n\tawait page.goto('/');\n\tawait expect(page.locator('h1')).toContainText('Hello from SvelteKit on Vercel');\n});\n\ntest('server-side data loading works', async ({ page }) => {\n\tawait page.goto('/server-data');\n\tawait expect(page.locator('h1')).toContainText('loaded on server');\n\tconst timestamp = await page.locator('#timestamp').textContent();\n\texpect(Number(timestamp)).toBeGreaterThan(0);\n});\n\ntest('API routes work', async ({ request }) => {\n\tconst response = await request.get('/api/json');\n\texpect(response.ok()).toBe(true);\n\tconst data = await response.json();\n\texpect(data.ok).toBe(true);\n});\n\ntest('$app/server read works', async ({ request }) => {\n\tconst response = await request.get('/read');\n\texpect(response.ok()).toBe(true);\n\tconst text = await response.text();\n\texpect(text).toContain('Hello from $app/server read');\n});\n\ntest('ISR route serves cached response', async ({ request }) => {\n\t// first request warms the cache\n\tconst first = await request.get('/isr');\n\texpect(first.ok()).toBe(true);\n\tconst first_html = await first.text();\n\tconst first_match = first_html.match(/id=\"rendered-at\">(\\d+)</);\n\texpect(first_match).not.toBeNull();\n\tconst first_rendered_at = first_match![1];\n\n\t// second request should be served from ISR cache (same rendered_at)\n\tconst second = await request.get('/isr');\n\texpect(second.ok()).toBe(true);\n\tconst second_html = await second.text();\n\tconst second_match = second_html.match(/id=\"rendered-at\">(\\d+)</);\n\texpect(second_match).not.toBeNull();\n\tconst second_rendered_at = second_match![1];\n\n\texpect(first_rendered_at).toBe(second_rendered_at);\n});\n\ntest('ISR dynamic route serves cached response per slug', async ({ request }) => {\n\t// warm the cache for /isr/alpha\n\tconst first = await request.get('/isr/alpha');\n\texpect(first.ok()).toBe(true);\n\tconst first_html = await first.text();\n\texpect(first_html).toContain('ISR: alpha');\n\tconst first_match = first_html.match(/id=\"rendered-at\">(\\d+)</);\n\texpect(first_match).not.toBeNull();\n\tconst alpha_rendered_at = first_match![1];\n\n\t// second request to same slug should return cached response\n\tconst second = await request.get('/isr/alpha');\n\tconst second_html = await second.text();\n\tconst second_match = second_html.match(/id=\"rendered-at\">(\\d+)</);\n\texpect(second_match![1]).toBe(alpha_rendered_at);\n\n\t// different slug should be independently rendered\n\tconst beta = await request.get('/isr/beta');\n\texpect(beta.ok()).toBe(true);\n\tconst beta_html = await beta.text();\n\texpect(beta_html).toContain('ISR: beta');\n});\n\ntest('prerendered page works', async ({ page }) => {\n\tawait page.goto('/prerendered');\n\tawait expect(page.locator('h1')).toContainText('this page is prerendered');\n});\n\ntest('prerendered page trailing slash redirects', async ({ request }) => {\n\tconst response = await request.get('/prerendered/', { maxRedirects: 0 });\n\texpect(response.status()).toBe(308);\n\texpect(response.headers()['location']).toBe('/prerendered');\n});\n\ntest('deeply nested route works', async ({ page }) => {\n\tawait page.goto('/deep/nested/route');\n\tawait expect(page.locator('h1')).toContainText('Deep nested route');\n\texpect(await page.locator('#depth').textContent()).toBe('3');\n\texpect(await page.locator('#path').textContent()).toBe('/deep/nested/route');\n});\n\ntest('client-side navigation works (validates __data.json)', async ({ page }) => {\n\tawait page.goto('/');\n\tawait expect(page.locator('h1')).toContainText('Hello from SvelteKit on Vercel');\n\n\t// click a link to trigger client-side navigation (fetches __data.json)\n\tawait page.click('a[href=\"/server-data\"]');\n\tawait expect(page.locator('h1')).toContainText('loaded on server');\n\n\t// navigate to another page via client-side nav\n\tawait page.goBack();\n\tawait expect(page.locator('h1')).toContainText('Hello from SvelteKit on Vercel');\n\n\tawait page.click('a[href=\"/deep/nested/route\"]');\n\tawait expect(page.locator('h1')).toContainText('Deep nested route');\n});\n\ntest('client-side navigation to ISR routes works', async ({ page }) => {\n\tawait page.goto('/');\n\n\tawait page.click('a[href=\"/isr/hello\"]');\n\tawait expect(page.locator('h1')).toContainText('ISR: hello');\n});\n\ntest('client-side navigation to prerendered routes works', async ({ page }) => {\n\tawait page.goto('/');\n\n\tawait page.click('a[href=\"/prerendered\"]');\n\tawait expect(page.locator('h1')).toContainText('this page is prerendered');\n});\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"rewriteRelativeImportExtensions\": true,\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"moduleResolution\": \"bundler\"\n\t}\n}\n"
  },
  {
    "path": "packages/adapter-vercel/test/apps/basic/vite.config.ts",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n\tplugins: [sveltekit()]\n});\n"
  },
  {
    "path": "packages/adapter-vercel/test/utils.js",
    "content": "import { devices } from '@playwright/test';\nimport process from 'node:process';\n\nif (!process.env.DEPLOYMENT_URL) {\n\tthrow new Error('DEPLOYMENT_URL environment variable is required');\n}\n\n/** @type {import('@playwright/test').PlaywrightTestConfig} */\nexport const config = {\n\tforbidOnly: !!process.env.CI,\n\ttimeout: process.env.CI ? 45000 : 15000,\n\tretries: process.env.CI ? 2 : 0,\n\tprojects: [{ name: 'chromium' }],\n\tuse: {\n\t\t...devices['Desktop Chrome'],\n\t\tbaseURL: process.env.DEPLOYMENT_URL,\n\t\tscreenshot: 'only-on-failure',\n\t\ttrace: 'retain-on-failure',\n\t\tchannel: 'chromium'\n\t},\n\tworkers: process.env.CI ? 2 : undefined,\n\treporter: 'list',\n\ttestDir: 'test',\n\ttestMatch: /(.+\\.)?(test|spec)\\.[jt]s/\n};\n"
  },
  {
    "path": "packages/adapter-vercel/test/utils.spec.js",
    "content": "import { assert, test, describe } from 'vitest';\nimport { get_pathname, parse_isr_expiration, pattern_to_src, resolve_runtime } from '../utils.js';\n\n// workaround so that TypeScript doesn't follow that import which makes it pick up that file and then error on missing import aliases\nconst { parse_route_id } = await import(\n\tnew URL('../../kit/src/' + 'utils/routing.js', import.meta.url).href\n);\n\n/**\n * @param {import('@sveltejs/kit').RouteDefinition<any>['segments']} segments\n * @param {string} expected\n */\nfunction run_get_pathname_test(segments, expected) {\n\tconst route = /** @type {import('@sveltejs/kit').RouteDefinition<any>} */ ({ segments });\n\tassert.equal(get_pathname(route), expected);\n}\n\ntest('get_pathname for simple route', () => {\n\trun_get_pathname_test([{ content: 'foo', dynamic: false, rest: false }], 'foo');\n});\n\ntest('get_pathname for simple route with multiple segments', () => {\n\trun_get_pathname_test(\n\t\t[\n\t\t\t{ content: 'foo', dynamic: false, rest: false },\n\t\t\t{ content: 'bar', dynamic: false, rest: false }\n\t\t],\n\t\t'foo/bar'\n\t);\n});\n\ntest('get_pathname for route with parameters', () => {\n\trun_get_pathname_test(\n\t\t[\n\t\t\t{ content: 'foo', dynamic: false, rest: false },\n\t\t\t{ content: '[bar]', dynamic: true, rest: false }\n\t\t],\n\t\t'foo/$1'\n\t);\n});\n\ntest('get_pathname for route with parameters within segment', () => {\n\trun_get_pathname_test(\n\t\t[\n\t\t\t{ content: 'foo-[bar]', dynamic: true, rest: false },\n\t\t\t{ content: '[baz]-buz', dynamic: true, rest: false }\n\t\t],\n\t\t'foo-$1/$2-buz'\n\t);\n});\n\ntest('get_pathname for route with optional parameters within segment', () => {\n\trun_get_pathname_test(\n\t\t[\n\t\t\t{ content: 'foo-[[bar]]', dynamic: true, rest: false },\n\t\t\t{ content: '[[baz]]-buz', dynamic: true, rest: false }\n\t\t],\n\t\t'foo-$1/$2-buz'\n\t);\n});\n\ntest('get_pathname for route with rest parameter', () => {\n\trun_get_pathname_test(\n\t\t[\n\t\t\t{ content: 'foo', dynamic: false, rest: false },\n\t\t\t{ content: '[[...rest]]', dynamic: true, rest: true }\n\t\t],\n\t\t'foo$1'\n\t);\n});\n\ntest('get_pathname for route with required and rest parameter', () => {\n\trun_get_pathname_test(\n\t\t[\n\t\t\t{ content: '[foo]', dynamic: true, rest: false },\n\t\t\t{ content: '[...rest]', dynamic: true, rest: true }\n\t\t],\n\t\t'$1$2'\n\t);\n});\n\ntest('get_pathname for route with required and optional parameter', () => {\n\trun_get_pathname_test(\n\t\t[\n\t\t\t{ content: '[foo]', dynamic: true, rest: false },\n\t\t\t{ content: '[[optional]]', dynamic: true, rest: true }\n\t\t],\n\t\t'$1$2'\n\t);\n});\n\ntest('get_pathname for route with required and optional parameter', () => {\n\trun_get_pathname_test(\n\t\t[\n\t\t\t{ content: '[foo]', dynamic: true, rest: false },\n\t\t\t{ content: '[[...rest]]', dynamic: true, rest: true },\n\t\t\t{ content: 'bar', dynamic: false, rest: false }\n\t\t],\n\t\t'$1$2/bar'\n\t);\n});\n\n/**\n * @param {string} route_id\n * @param {string} expected\n */\nfunction run_pattern_to_src_test(route_id, expected) {\n\tconst { pattern } = parse_route_id(route_id);\n\tassert.equal(pattern_to_src(pattern.toString()), expected);\n}\n\ntest('pattern_to_src for simple route', () => {\n\trun_pattern_to_src_test('/', '^/?');\n});\n\ntest('pattern_to_src for route with parameters', () => {\n\trun_pattern_to_src_test('/foo/[bar]', '^/foo/([^/]+?)/?');\n});\n\ntest('pattern_to_src for route with optional parameters', () => {\n\trun_pattern_to_src_test('/foo/[[bar]]', '^/foo(/[^/]+)?/?');\n});\n\ntest('pattern_to_src for route with optional parameter in the middle', () => {\n\trun_pattern_to_src_test('/foo/[[bar]]/baz', '^/foo(/[^/]+)?/baz/?');\n});\n\ntest('pattern_to_src for route with rest parameter', () => {\n\trun_pattern_to_src_test('/foo/[...bar]', '^/foo(/[^]*)?/?');\n});\n\ntest('pattern_to_src for route with rest parameter in the middle', () => {\n\trun_pattern_to_src_test('/foo/[...bar]/baz', '^/foo(/[^]*)?/baz/?');\n});\n\ndescribe('parse_isr_expiration', () => {\n\ttest.each(\n\t\t/** @type {const} */ ([\n\t\t\t[1, 1],\n\t\t\t['1', 1],\n\t\t\t[false, false],\n\t\t\t['false', false]\n\t\t])\n\t)('works for valid inputs ($0)', (input, output) => {\n\t\tconst result = parse_isr_expiration(input, '/isr');\n\t\tassert.equal(result, output);\n\t});\n\n\ttest('does not allow floats', () => {\n\t\tassert.throws(() => parse_isr_expiration(1.5, '/isr'), /should be an integer, in \\/isr/);\n\t});\n\n\ttest('does not allow `true`', () => {\n\t\tconst val = /** @type {false} */ (true);\n\t\tassert.throws(() => parse_isr_expiration(val, '/isr'), /should be an integer, in \\/isr/);\n\t});\n\n\ttest('does not allow negative numbers', () => {\n\t\tassert.throws(() => parse_isr_expiration(-1, '/isr'), /should be non-negative, in \\/isr/);\n\t});\n\n\ttest('does not allow strings that do not parse to valid numbers', () => {\n\t\tassert.throws(\n\t\t\t() => parse_isr_expiration('foo', '/isr'),\n\t\t\t/value was a string but could not be parsed as an integer, in \\/isr/\n\t\t);\n\t});\n\n\ttest('does not allow strings that parse to floats', () => {\n\t\tassert.throws(\n\t\t\t() => parse_isr_expiration('1.1', '/isr'),\n\t\t\t/value was a string but could not be parsed as an integer, in \\/isr/\n\t\t);\n\t});\n});\n\ndescribe('resolve_runtime', () => {\n\ttest('prefers override_key over default_key', () => {\n\t\tconst result = resolve_runtime('nodejs20.x', 'experimental_bun1.x');\n\t\tassert.equal(result, 'bun1.x');\n\t});\n\n\ttest('uses default_key when override_key is undefined', () => {\n\t\tconst result = resolve_runtime('experimental_bun1.x');\n\t\tassert.equal(result, 'bun1.x');\n\t});\n\n\ttest('throws an error when resolving to an invalid runtime', () => {\n\t\tassert.throws(() => resolve_runtime('node18.x', undefined), /Unsupported runtime: node18.x/);\n\t});\n});\n"
  },
  {
    "path": "packages/adapter-vercel/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true,\n\t\t\"noImplicitAny\": true,\n\t\t\"strictNullChecks\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"node16\",\n\t\t\"moduleResolution\": \"node16\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../kit/types/index\"]\n\t\t}\n\t},\n\t\"include\": [\"*.js\", \"files/**/*.js\", \"internal.d.ts\", \"test/**/*.js\"]\n}\n"
  },
  {
    "path": "packages/adapter-vercel/utils.js",
    "content": "import process from 'node:process';\n\n/** @param {import(\"@sveltejs/kit\").RouteDefinition<any>} route */\nexport function get_pathname(route) {\n\tlet i = 1;\n\n\tconst pathname = route.segments\n\t\t.map((segment) => {\n\t\t\tif (!segment.dynamic) {\n\t\t\t\treturn '/' + segment.content;\n\t\t\t}\n\n\t\t\tconst parts = segment.content.split(/\\[(.+?)\\](?!\\])/);\n\n\t\t\tif (\n\t\t\t\tparts.length === 3 &&\n\t\t\t\t!parts[0] &&\n\t\t\t\t!parts[2] &&\n\t\t\t\t(parts[1].startsWith('...') || parts[1][0] === '[')\n\t\t\t) {\n\t\t\t\t// Special case: segment is a single optional or rest parameter.\n\t\t\t\t// In that case we don't prepend a slash (also see comment in pattern_to_src).\n\t\t\t\treturn `$${i++}`;\n\t\t\t} else {\n\t\t\t\treturn (\n\t\t\t\t\t'/' +\n\t\t\t\t\tparts\n\t\t\t\t\t\t.map((content, j) => {\n\t\t\t\t\t\t\tif (j % 2) {\n\t\t\t\t\t\t\t\treturn `$${i++}`;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn content;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join('')\n\t\t\t\t);\n\t\t\t}\n\t\t})\n\t\t.join('');\n\n\treturn pathname[0] === '/' ? pathname.slice(1) : pathname;\n}\n\n/**\n * Adjusts the stringified route regex for Vercel's routing system\n * @param {string} pattern stringified route regex\n */\nexport function pattern_to_src(pattern) {\n\tlet src = pattern\n\t\t// remove leading / and trailing $/\n\t\t.slice(1, -2)\n\t\t// replace escaped \\/ with /\n\t\t.replace(/\\\\\\//g, '/');\n\n\t// replace the root route \"^/\" with \"^/?\"\n\tif (src === '^/') {\n\t\tsrc = '^/?';\n\t}\n\n\t// Move non-capturing groups that swallow slashes into their following capturing groups.\n\t// This is necessary because during ISR we're using the regex to construct the __pathname\n\t// query parameter: In case of a route like [required]/[...rest] we need to turn them\n\t// into $1$2 and not $1/$2, because if [...rest] is empty, we don't want to have a trailing\n\t// slash in the __pathname query parameter which wasn't there in the original URL, as that\n\t// could result in a false trailing slash redirect in the SvelteKit runtime, leading to infinite redirects.\n\tsrc = src.replace(/\\(\\?:\\/\\((.+?)\\)\\)/g, '(/$1)');\n\n\treturn src;\n}\n\nconst integer = /^\\d+$/;\n\n/**\n * @param {false | string | number} value\n * @param {string} route_id\n * @returns {number | false}\n */\nexport function parse_isr_expiration(value, route_id) {\n\tif (value === false || value === 'false') return false; // 1 year\n\n\t/** @param {string} desc */\n\tconst err = (desc) => {\n\t\tthrow new Error(\n\t\t\t`Invalid isr.expiration value: ${JSON.stringify(value)} (${desc}, in ${route_id})`\n\t\t);\n\t};\n\n\tlet parsed;\n\tif (typeof value === 'string') {\n\t\tif (!integer.test(value)) {\n\t\t\terr('value was a string but could not be parsed as an integer');\n\t\t}\n\t\tparsed = Number.parseInt(value, 10);\n\t} else {\n\t\tif (!Number.isInteger(value)) {\n\t\t\terr('should be an integer');\n\t\t}\n\t\tparsed = value;\n\t}\n\n\tif (Number.isNaN(parsed)) {\n\t\terr('should be a number');\n\t}\n\tif (parsed < 0) {\n\t\terr('should be non-negative');\n\t}\n\treturn parsed;\n}\n\n/**\n * @param {string | undefined} default_key\n * @param {string | undefined} [override_key]\n * @returns {RuntimeKey}\n */\nexport function resolve_runtime(default_key, override_key) {\n\tconst key = (override_key ?? default_key ?? get_default_runtime()).replace('experimental_', '');\n\tassert_is_valid_runtime(key);\n\treturn key;\n}\n\nconst valid_node_versions = [20, 22, 24];\nconst formatter = new Intl.ListFormat('en', { type: 'disjunction' });\n\n/** @returns {RuntimeKey} */\nfunction get_default_runtime() {\n\t// TODO may someday need to auto-detect Bun, but this will be complicated because you may want to run your build\n\t// with Bun but not have your serverless runtime be in Bun. Vercel will likely have to attach something to `globalThis` or similar\n\t// to tell us what the bun configuration is.\n\tconst major = Number(process.version.slice(1).split('.')[0]);\n\n\tif (!valid_node_versions.includes(major)) {\n\t\tthrow new Error(\n\t\t\t`Unsupported Node.js version: ${process.version}. Please use Node ${formatter.format(valid_node_versions.map((v) => `${v}`))} to build your project, or explicitly specify a runtime in your adapter configuration.`\n\t\t);\n\t}\n\n\treturn `nodejs${/** @type {20 | 22 | 24} */ (major)}.x`;\n}\n\nconst valid_runtimes = /** @type {const} */ ([\n\t'nodejs20.x',\n\t'nodejs22.x',\n\t'nodejs24.x',\n\t'bun1.x',\n\t'edge'\n]);\n\n/**\n * @param {string} key\n * @returns {asserts key is RuntimeKey}\n */\nfunction assert_is_valid_runtime(key) {\n\tif (!valid_runtimes.includes(/** @type {RuntimeKey} */ (key))) {\n\t\tthrow new Error(\n\t\t\t`Unsupported runtime: ${key}. Supported runtimes are: ${valid_runtimes.join(', ')}. See the Node.js Version section in your Vercel project settings for info on the currently supported versions.`\n\t\t);\n\t}\n}\n\n/** @typedef {Exclude<RuntimeKey, 'bun1.x'> | 'experimental_bun1.x'} RuntimeConfigKey */\n/** @typedef {typeof valid_runtimes[number]} RuntimeKey */\n"
  },
  {
    "path": "packages/amp/.gitignore",
    "content": ""
  },
  {
    "path": "packages/amp/CHANGELOG.md",
    "content": "# @sveltejs/amp\n\n## 1.1.5\n### Patch Changes\n\n\n- chore: add `.git` to the end of `package.json` repository url ([#14134](https://github.com/sveltejs/kit/pull/14134))\n\n- Updated dependencies [[`c968aef`](https://github.com/sveltejs/kit/commit/c968aef5727f978244d5160657b4a7ac651384ae)]:\n  - @sveltejs/kit@2.27.3\n\n## 1.1.4\n### Patch Changes\n\n\n- docs: update URLs for new svelte.dev site ([#12857](https://github.com/sveltejs/kit/pull/12857))\n\n- Updated dependencies [[`dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46`](https://github.com/sveltejs/kit/commit/dcbe4222a194c5f90cfc0fc020cf065f7a4e4c46), [`4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d`](https://github.com/sveltejs/kit/commit/4cdbf76fbbf0c0ce7f574ef69c8daddcf954d39d), [`3a9b78f04786898ca93f6d4b75ab18d26bc45192`](https://github.com/sveltejs/kit/commit/3a9b78f04786898ca93f6d4b75ab18d26bc45192), [`723eb8b31e6a22c82f730c30e485386c8676b746`](https://github.com/sveltejs/kit/commit/723eb8b31e6a22c82f730c30e485386c8676b746), [`8ec471c875345b751344e67580ff1b772ef2735b`](https://github.com/sveltejs/kit/commit/8ec471c875345b751344e67580ff1b772ef2735b)]:\n  - @sveltejs/kit@2.7.3\n\n## 1.1.3\n### Patch Changes\n\n\n- chore: configure provenance in a simpler manner ([#12570](https://github.com/sveltejs/kit/pull/12570))\n\n- Updated dependencies [[`087a43d391fc38b8c008fb39a804dc6988974101`](https://github.com/sveltejs/kit/commit/087a43d391fc38b8c008fb39a804dc6988974101)]:\n  - @sveltejs/kit@2.5.22\n\n## 1.1.2\n### Patch Changes\n\n\n- chore: package provenance ([#12567](https://github.com/sveltejs/kit/pull/12567))\n\n- Updated dependencies [[`4930a8443caa53bcecee7b690cd28e429b1c8a20`](https://github.com/sveltejs/kit/commit/4930a8443caa53bcecee7b690cd28e429b1c8a20)]:\n  - @sveltejs/kit@2.5.21\n\n## 1.1.1\n\n### Patch Changes\n\n- chore: add keywords for discovery in npm search ([#12330](https://github.com/sveltejs/kit/pull/12330))\n\n- Updated dependencies [[`25acb1d9fce998dccd8050b93cf4142c2b082611`](https://github.com/sveltejs/kit/commit/25acb1d9fce998dccd8050b93cf4142c2b082611), [`642c4a4aff4351b786fe6274aa2f0bf7d905faf9`](https://github.com/sveltejs/kit/commit/642c4a4aff4351b786fe6274aa2f0bf7d905faf9), [`0a0e9aa897123ebec50af08e9385b2ca4fc5bb28`](https://github.com/sveltejs/kit/commit/0a0e9aa897123ebec50af08e9385b2ca4fc5bb28)]:\n  - @sveltejs/kit@2.5.11\n\n## 1.1.0\n\n### Minor Changes\n\n- feat: allow SvelteKit 2 as peer dependency ([#11233](https://github.com/sveltejs/kit/pull/11233))\n\n## 1.0.2\n\n### Patch Changes\n\n- fix: publish missing files ([#8532](https://github.com/sveltejs/kit/pull/8532))\n\n## 1.0.1\n\n### Patch Changes\n\n- chore: remove superfluous main field from package.json ([#8519](https://github.com/sveltejs/kit/pull/8519))\n\n- Updated dependencies [[`7e2d3405`](https://github.com/sveltejs/kit/commit/7e2d34056e99f371e22406d941b764df365a2649)]:\n  - @sveltejs/kit@1.1.1\n\n## 1.0.0\n\n### Major Changes\n\nFirst major release, see below for the history of changes that lead up to this.\nStarting from now all releases follow semver and changes will be listed as Major/Minor/Patch\n\n## 1.0.0-next.3\n\n### Patch Changes\n\n- chore: add peerDependencies, add more specific next version ([#8141](https://github.com/sveltejs/kit/pull/8141))\n\n## 1.0.0-next.2\n\n### Patch Changes\n\n- Amend boilerplate to match current recommendations ([#7184](https://github.com/sveltejs/kit/pull/7184))\n\n## 1.0.0-next.1\n\n### Patch Changes\n\n- Add types to pkg.exports ([#5045](https://github.com/sveltejs/kit/pull/5045))\n"
  },
  {
    "path": "packages/amp/index.d.ts",
    "content": "export function transform(html: string): string;\n"
  },
  {
    "path": "packages/amp/index.js",
    "content": "// https://amp.dev/documentation/guides-and-tutorials/learn/spec/amp-boilerplate/\nconst boilerplate = `\n\t<link rel=\"preload\" as=\"script\" href=\"https://cdn.ampproject.org/v0.js\" />\n\t<script async src=\"https://cdn.ampproject.org/v0.js\"></script>\n\t<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>\n`;\n\n/** @param {string} html */\nexport function transform(html) {\n\treturn html\n\t\t.replace(/<style([^]+?)<\\/style>/, (match, $1) => `<style amp-custom${$1}</style>`)\n\t\t.replace(/<script[^]+?<\\/script>/g, '')\n\t\t.replace(/<link[^>]+>/g, (match) => {\n\t\t\tif (/rel=('|\")?stylesheet\\1/.test(match)) {\n\t\t\t\tif (/ disabled /.test(match)) return '';\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'An AMP document cannot contain <link rel=\"stylesheet\"> — ensure that inlineStyleThreshold is set to Infinity, and remove links from your page template and <svelte:head> elements'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn match;\n\t\t})\n\t\t.replace(/<meta[^>]+>/g, (match) => {\n\t\t\tif (match.includes('http-equiv')) return '';\n\t\t\treturn match;\n\t\t})\n\t\t.replace('</head>', boilerplate + '</head>');\n}\n"
  },
  {
    "path": "packages/amp/package.json",
    "content": "{\n\t\"name\": \"@sveltejs/amp\",\n\t\"version\": \"1.1.5\",\n\t\"description\": \"AMP integration for SvelteKit\",\n\t\"keywords\": [\n\t\t\"accelerated mobile pages\",\n\t\t\"amp\",\n\t\t\"svelte\",\n\t\t\"sveltekit\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/sveltejs/kit.git\",\n\t\t\"directory\": \"packages/amp\"\n\t},\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://svelte.dev\",\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./index.d.ts\",\n\t\t\t\"import\": \"./index.js\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"types\": \"index.d.ts\",\n\t\"files\": [\n\t\t\"index.js\",\n\t\t\"index.d.ts\"\n\t],\n\t\"scripts\": {\n\t\t\"check\": \"tsc\",\n\t\t\"lint\": \"prettier --check .\",\n\t\t\"format\": \"pnpm lint --write\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"typescript\": \"^5.3.3\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@sveltejs/kit\": \"^1.0.0 || ^2.0.0\"\n\t}\n}\n"
  },
  {
    "path": "packages/amp/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"node16\",\n\t\t\"moduleResolution\": \"node16\",\n\t\t\"allowSyntheticDefaultImports\": true\n\t}\n}\n"
  },
  {
    "path": "packages/enhanced-img/.prettierignore",
    "content": "test/Output.svelte\n"
  },
  {
    "path": "packages/enhanced-img/CHANGELOG.md",
    "content": "# @sveltejs/enhanced-img\n\n## 0.10.4\n### Patch Changes\n\n\n- chore: add support for vite-plugin-svelte 7 ([#15539](https://github.com/sveltejs/kit/pull/15539))\n\n## 0.10.3\n### Patch Changes\n\n\n- fix: use jpg as a fallback format when source doesn't have an alpha channel ([#15243](https://github.com/sveltejs/kit/pull/15243))\n\n## 0.10.2\n### Patch Changes\n\n\n- fix: upgrade vite-imagetools to 9.0.3 for fix to caching bug ([#15305](https://github.com/sveltejs/kit/pull/15305))\n\n## 0.10.1\n### Patch Changes\n\n\n- fix: replace erroneous `import.meta.DEV` with `import.meta.env.DEV` in generated code ([#15285](https://github.com/sveltejs/kit/pull/15285))\n\n## 0.10.0\n### Minor Changes\n\n\n- feat: re-export the `Picture` type from `vite-imagetools` ([#15225](https://github.com/sveltejs/kit/pull/15225))\n\n## 0.9.3\n### Patch Changes\n\n\n- fix: ensure compatibility with vite-plugin-svelte@7 (use api.filter instead of api.idFilter) ([#15179](https://github.com/sveltejs/kit/pull/15179))\n\n## 0.9.2\n### Patch Changes\n\n\n- chore: remove duplicate caching layer ([#14988](https://github.com/sveltejs/kit/pull/14988))\n\n## 0.9.1\n### Patch Changes\n\n\n- fix: update vite-imagetools for caching fixes to avoid crashes ([#14976](https://github.com/sveltejs/kit/pull/14976))\n\n## 0.9.0\n### Minor Changes\n\n\n- chore(deps): update dependency vite-imagetools to v9 ([#14608](https://github.com/sveltejs/kit/pull/14608))\n\n## 0.8.5\n### Patch Changes\n\n\n- fix: warn rather than crash when non-enhanced image dynamically passed to `enhanced:img` ([#14845](https://github.com/sveltejs/kit/pull/14845))\n\n## 0.8.4\n### Patch Changes\n\n\n- fix: add script block only when there are imports to add ([#14604](https://github.com/sveltejs/kit/pull/14604))\n\n## 0.8.3\n### Patch Changes\n\n\n- chore: update \"homepage\" field in package.json ([#14579](https://github.com/sveltejs/kit/pull/14579))\n\n## 0.8.2\n### Patch Changes\n\n\n- chore: upgrade sharp to 0.34.4 ([#14478](https://github.com/sveltejs/kit/pull/14478))\n\n## 0.8.1\n### Patch Changes\n\n\n- fix(perf): correctly apply id filter from vite-plugin-svelte ([#14248](https://github.com/sveltejs/kit/pull/14248))\n\n## 0.8.0\n### Minor Changes\n\n\n- breaking: upgrade to vite-imagetools 8 to auto-rotate images ([#14172](https://github.com/sveltejs/kit/pull/14172))\n\n## 0.7.1\n### Patch Changes\n\n\n- chore: add `.git` to the end of `package.json` repository url ([#14134](https://github.com/sveltejs/kit/pull/14134))\n\n## 0.7.0\n### Minor Changes\n\n\n- breaking: use new filters and enhancements from `vite-plugin-svelte`. Requires `vite >= 6.3` and `vite-plugin-svelte >= 6.0`. ([#13967](https://github.com/sveltejs/kit/pull/13967))\n\n## 0.6.1\n### Patch Changes\n\n\n- feat: allow `vite-plugin-svelte` 6 peer dependency ([#13921](https://github.com/sveltejs/kit/pull/13921))\n\n## 0.6.0\n### Minor Changes\n\n\n- feat: add validation to ensure plugin occurs in correct order ([`1c3f36dc10265fb79c64643c3d7a91469d34e697`](https://github.com/sveltejs/kit/commit/1c3f36dc10265fb79c64643c3d7a91469d34e697))\n\n## 0.5.1\n### Patch Changes\n\n\n- chore(deps): upgrade sharp to 0.34.1 ([#13611](https://github.com/sveltejs/kit/pull/13611))\n\n## 0.5.0\n### Minor Changes\n\n\n- feat: add support for targeting `enhanced\\:img` in CSS ([#13617](https://github.com/sveltejs/kit/pull/13617))\n\n## 0.4.4\n### Patch Changes\n\n\n- fix: handle duplicate SVG images ([`8073d7c7dcc391d406c658729221a18ac6f18102`](https://github.com/sveltejs/kit/commit/8073d7c7dcc391d406c658729221a18ac6f18102))\n\n## 0.4.3\n### Patch Changes\n\n\n- fix: properly handle multiple SVGs ([#13127](https://github.com/sveltejs/kit/pull/13127))\n\n## 0.4.2\n### Patch Changes\n\n\n- feat: set intrinsic width and height for SVGs ([#13126](https://github.com/sveltejs/kit/pull/13126))\n\n\n- perf: directly inline values since Svelte no longer inlines variables into template ([#13035](https://github.com/sveltejs/kit/pull/13035))\n\n## 0.4.1\n### Patch Changes\n\n\n- fix: correctly handle `<enhanced:img />` elements nested in other DOM elements ([#12945](https://github.com/sveltejs/kit/pull/12945))\n\n## 0.4.0\n### Minor Changes\n\n\n- breaking: require Svelte 5 ([#12822](https://github.com/sveltejs/kit/pull/12822))\n\n## 0.3.10\n### Patch Changes\n\n\n- docs: update URLs for new svelte.dev site ([#12857](https://github.com/sveltejs/kit/pull/12857))\n\n## 0.3.9\n### Patch Changes\n\n\n- chore: upgrade svelte-parse-markup ([#12793](https://github.com/sveltejs/kit/pull/12793))\n\n## 0.3.8\n### Patch Changes\n\n\n- fix: import `node:process` instead of using globals ([#12641](https://github.com/sveltejs/kit/pull/12641))\n\n## 0.3.7\n### Patch Changes\n\n\n- fix: avoid duplicating width/height attributes ([#12673](https://github.com/sveltejs/kit/pull/12673))\n\n## 0.3.6\n### Patch Changes\n\n\n- fix: address Svelte 5 warning ([`ec04dae73702c99652e4972d2b7363f2c11ccf5a`](https://github.com/sveltejs/kit/commit/ec04dae73702c99652e4972d2b7363f2c11ccf5a))\n\n## 0.3.5\n### Patch Changes\n\n\n- perf: hoist vite asset declarations to module block ([#12627](https://github.com/sveltejs/kit/pull/12627))\n\n## 0.3.4\n### Patch Changes\n\n\n- perf: apply performance optimization to dev srcset ([#12621](https://github.com/sveltejs/kit/pull/12621))\n\n## 0.3.3\n### Patch Changes\n\n\n- chore: configure provenance in a simpler manner ([#12570](https://github.com/sveltejs/kit/pull/12570))\n\n## 0.3.2\n### Patch Changes\n\n\n- chore: package provenance ([#12567](https://github.com/sveltejs/kit/pull/12567))\n\n\n- fix: ensure src attribute is properly formed ([`65931f276ac2102032e3032c864a472eee19b7bb`](https://github.com/sveltejs/kit/commit/65931f276ac2102032e3032c864a472eee19b7bb))\n\n## 0.3.1\n### Patch Changes\n\n\n- fix: make `*?enhanced` imports available in the ambient context ([#12363](https://github.com/sveltejs/kit/pull/12363))\n\n## 0.3.0\n\n### Minor Changes\n\n- breaking: return plugin synchronously from `enhancedImages()` ([#12297](https://github.com/sveltejs/kit/pull/12297))\n\n### Patch Changes\n\n- chore: add keywords for discovery in npm search ([#12330](https://github.com/sveltejs/kit/pull/12330))\n\n## 0.2.1\n\n### Patch Changes\n\n- fix: use correct type for `*?enhanced` imports ([#12224](https://github.com/sveltejs/kit/pull/12224))\n\n## 0.2.0\n\n### Minor Changes\n\n- feat: upgrade vite-imagetools to v7. caches build output by default ([#12055](https://github.com/sveltejs/kit/pull/12055))\n\n## 0.1.9\n\n### Patch Changes\n\n- fix: support shorthand attribute syntax ([#11884](https://github.com/sveltejs/kit/pull/11884))\n\n## 0.1.8\n\n### Patch Changes\n\n- fix: correct images cache key to avoid collisions when images have same name ([#11602](https://github.com/sveltejs/kit/pull/11602))\n\n## 0.1.7\n\n### Patch Changes\n\n- chore: update primary branch from master to main ([`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d))\n\n- fix: throw an error if image cannot be resolved ([#11346](https://github.com/sveltejs/kit/pull/11346))\n\n- fix: attempt to address issues accessing images on filesystem ([#11403](https://github.com/sveltejs/kit/pull/11403))\n\n## 0.1.6\n\n### Patch Changes\n\n- chore: upgrade vite-imagetools ([#11122](https://github.com/sveltejs/kit/pull/11122))\n\n## 0.1.5\n\n### Patch Changes\n\n- fix: correctly generate client-side code ([#11059](https://github.com/sveltejs/kit/pull/11059))\n\n## 0.1.4\n\n### Patch Changes\n\n- fix: avoid creating conflicting import statements ([#11047](https://github.com/sveltejs/kit/pull/11047))\n\n## 0.1.3\n\n### Patch Changes\n\n- fix: only resolve images if optimizable ([#11041](https://github.com/sveltejs/kit/pull/11041))\n\n## 0.1.2\n\n### Patch Changes\n\n- fix: refresh in dev mode when an image changes ([#11033](https://github.com/sveltejs/kit/pull/11033))\n\n- fix: auto-import of svg images ([`4426daebe`](https://github.com/sveltejs/kit/commit/4426daebe1d345f60554225e3f12ea932b0110e4))\n\n## 0.1.1\n\n### Patch Changes\n\n- feat: add experimental `@sveltejs/enhanced-img` package ([#10788](https://github.com/sveltejs/kit/pull/10788))\n"
  },
  {
    "path": "packages/enhanced-img/README.md",
    "content": "# `@sveltejs/enhanced-img`\n\nA Vite plugin which runs a Svelte preprocessor to locate images and then transform them at build-time.\n\n**WARNING**: This package is experimental. It uses pre-1.0 versioning and may introduce breaking changes with every minor version release.\n\n## Docs\n\n[Docs](https://svelte.dev/docs/kit/images)\n\n## Changelog\n\n[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/enhanced-img/CHANGELOG.md).\n\n## Acknowledgements\n\nWe'd like to thank the author of `svelte-preprocess-import-assets`, which this code is partially based off of. We'd also like to thank the authors of `vite-imagetools` which is used in `@sveltejs/enhanced-img`.\n"
  },
  {
    "path": "packages/enhanced-img/package.json",
    "content": "{\n\t\"name\": \"@sveltejs/enhanced-img\",\n\t\"version\": \"0.10.4\",\n\t\"description\": \"Image optimization for your Svelte apps\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/sveltejs/kit.git\",\n\t\t\"directory\": \"packages/enhanced-img\"\n\t},\n\t\"keywords\": [\n\t\t\"component\",\n\t\t\"enhanced\",\n\t\t\"image\",\n\t\t\"preprocessor\",\n\t\t\"plugin\",\n\t\t\"svelte\",\n\t\t\"sveltekit\",\n\t\t\"vite\"\n\t],\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://svelte.dev/docs/kit/images#sveltejs-enhanced-img\",\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"lint\": \"prettier --check .\",\n\t\t\"check\": \"tsc\",\n\t\t\"format\": \"prettier --write .\",\n\t\t\"test\": \"pnpm test:unit && pnpm test:integration\",\n\t\t\"test:unit\": \"vitest run\",\n\t\t\"test:integration\": \"pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test\"\n\t},\n\t\"files\": [\n\t\t\"src\",\n\t\t\"types\"\n\t],\n\t\"exports\": {\n\t\t\"types\": \"./types/index.d.ts\",\n\t\t\"import\": \"./src/index.js\"\n\t},\n\t\"types\": \"types/index.d.ts\",\n\t\"dependencies\": {\n\t\t\"magic-string\": \"^0.30.5\",\n\t\t\"sharp\": \"^0.34.1\",\n\t\t\"svelte-parse-markup\": \"^0.1.5\",\n\t\t\"vite-imagetools\": \"^9.0.3\",\n\t\t\"zimmerframe\": \"^1.1.2\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"@types/estree\": \"catalog:\",\n\t\t\"@types/node\": \"catalog:\",\n\t\t\"rollup\": \"^4.59.0\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"typescript\": \"^5.6.3\",\n\t\t\"vite\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@sveltejs/vite-plugin-svelte\": \"^6.0.0 || ^7.0.0\",\n\t\t\"svelte\": \"^5.0.0\",\n\t\t\"vite\": \"^6.3.0 || >=7.0.0\"\n\t}\n}\n"
  },
  {
    "path": "packages/enhanced-img/src/index.js",
    "content": "import process from 'node:process';\nimport { imagetools } from 'vite-imagetools';\nimport { image_plugin } from './vite-plugin.js';\n\n/**\n * @returns {import('vite').Plugin[]}\n */\nexport function enhancedImages() {\n\tconst imagetools_instance = imagetools_plugin();\n\treturn !process.versions.webcontainer\n\t\t? [image_plugin(imagetools_instance), imagetools_instance]\n\t\t: [];\n}\n\n/**\n * @param {import('sharp').Metadata} meta\n * @returns {string}\n */\nfunction fallback_format(meta) {\n\tif (meta.pages && meta.pages > 1) {\n\t\treturn meta.format === 'tiff' ? 'tiff' : 'gif';\n\t}\n\tif (meta.hasAlpha) {\n\t\treturn 'png';\n\t}\n\treturn 'jpg';\n}\n\nfunction imagetools_plugin() {\n\t/** @type {Partial<import('vite-imagetools').VitePluginOptions>} */\n\tconst imagetools_opts = {\n\t\tdefaultDirectives: async ({ pathname, searchParams: qs }, metadata) => {\n\t\t\tif (!qs.has('enhanced')) return new URLSearchParams();\n\n\t\t\tconst meta = await metadata();\n\t\t\tconst img_width = qs.get('imgWidth');\n\t\t\tconst width = img_width ? parseInt(img_width) : meta.width;\n\n\t\t\tif (!width) {\n\t\t\t\tconsole.warn(`Could not determine width of image ${pathname}`);\n\t\t\t\treturn new URLSearchParams();\n\t\t\t}\n\n\t\t\tconst { widths, kind } = get_widths(width, qs.get('imgSizes'));\n\t\t\treturn new URLSearchParams({\n\t\t\t\tas: 'picture',\n\t\t\t\tformat: `avif;webp;${fallback_format(meta)}`,\n\t\t\t\tw: widths.join(';'),\n\t\t\t\t...(kind === 'x' && !qs.has('w') && { basePixels: widths[0].toString() })\n\t\t\t});\n\t\t},\n\t\tnamedExports: false\n\t};\n\n\t// TODO: should we make formats or sizes configurable besides just letting people override defaultDirectives?\n\t// TODO: generate img rather than picture if only a single format is provided\n\t//     by resolving the directives for the URL in the preprocessor\n\treturn imagetools(imagetools_opts);\n}\n\n/**\n * @param {number} width\n * @param {string | null} sizes\n * @returns {{ widths: number[]; kind: 'w' | 'x' }}\n */\nfunction get_widths(width, sizes) {\n\t// We don't really know what the user wants here. But if they have an image that's really big\n\t// then we can probably assume they're always displaying it full viewport/breakpoint.\n\t// If the user is displaying a responsive image then the size usually doesn't change that much\n\t// Instead, the number of columns in the design may reduce and the image may take a greater\n\t// fraction of the screen.\n\t// Assume if they're bothering to specify sizes that it's going to take most of the screen\n\t// as that's the case where an image may be rendered at very different sizes. Otherwise, it's\n\t// probably a responsive image and a single size is okay (two when accounting for HiDPI).\n\tif (sizes) {\n\t\t// Use common device sizes. Doesn't hurt to include larger sizes as the user will rarely\n\t\t// provide an image that large.\n\t\t// https://screensiz.es/\n\t\t// https://gs.statcounter.com/screen-resolution-stats (note: logical. we want physical)\n\t\t// Include 1080 because lighthouse uses a moto g4 with 360 logical pixels and 3x pixel ratio.\n\t\tconst widths = [540, 768, 1080, 1366, 1536, 1920, 2560, 3000, 4096, 5120];\n\t\twidths.push(width);\n\t\treturn { widths, kind: 'w' };\n\t}\n\n\t// Don't need more than 2x resolution. Note that due to this optimization, pixel density\n\t// descriptors will often end up being cheaper as many mobile devices have pixel density ratios\n\t// near 3 which would cause larger images to be chosen on mobile when using sizes.\n\n\t// Most OLED screens that say they are 3x resolution, are actually 3x in the green color, but\n\t// only 1.5x in the red and blue colors. Showing a 3x resolution image in the app vs a 2x\n\t// resolution image will be visually the same, though the 3x image takes significantly more\n\t// data. Even true 3x resolution screens are wasteful as the human eye cannot see that level of\n\t// detail without something like a magnifying glass.\n\t// https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html\n\treturn { widths: [Math.round(width / 2), width], kind: 'x' };\n}\n"
  },
  {
    "path": "packages/enhanced-img/src/vite-plugin.js",
    "content": "/** @import { AST } from 'svelte/compiler' */\nimport { existsSync } from 'node:fs';\nimport path from 'node:path';\nimport MagicString from 'magic-string';\nimport sharp from 'sharp';\nimport { parse } from 'svelte-parse-markup';\nimport { walk } from 'zimmerframe';\n\n// TODO: expose this in vite-imagetools rather than duplicating it\nconst OPTIMIZABLE = /^[^?]+\\.(avif|heif|gif|jpeg|jpg|png|tiff|webp)(\\?.*)?$/;\n\n/**\n * Creates the Svelte image plugin.\n * @param {import('vite').Plugin<void>} imagetools_plugin\n * @returns {import('vite').Plugin<void>}\n */\nexport function image_plugin(imagetools_plugin) {\n\t/** @type {import('vite').ResolvedConfig} */\n\tlet vite_config;\n\n\tconst name = 'vite-plugin-enhanced-img-markup';\n\n\t/** @type {import('vite').Plugin<void>} */\n\tconst plugin = {\n\t\tname,\n\t\tconfigResolved(config) {\n\t\t\tvite_config = config;\n\t\t\tconst svelteConfigPlugin = config.plugins.find((p) => p.name === 'vite-plugin-svelte:config');\n\t\t\tif (!svelteConfigPlugin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'@sveltejs/enhanced-img requires @sveltejs/vite-plugin-svelte 6 or higher to be installed'\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst api = svelteConfigPlugin.api;\n\t\t\t// @ts-expect-error plugin.transform is defined below before configResolved is called\n\t\t\tplugin.transform.filter.id = (api.filter ?? api.idFilter).id; // TODO: idFilter was used by earlier versions of vite-plugin-svelte@6, remove when @7 is required\n\t\t},\n\t\ttransform: {\n\t\t\torder: 'pre', // puts it before vite-plugin-svelte:compile\n\t\t\tfilter: {\n\t\t\t\tcode: /<enhanced:img/ // code filter must match in addition to the id filter set in configResolved hook above\n\t\t\t},\n\n\t\t\tasync handler(content, filename) {\n\t\t\t\tconst plugin_context = this;\n\t\t\t\tconst s = new MagicString(content);\n\t\t\t\tconst ast = parse(content, { filename, modern: true });\n\n\t\t\t\t/**\n\t\t\t\t * Import path to import name\n\t\t\t\t * e.g. ./foo.png => __IMPORTED_ASSET_0__\n\t\t\t\t * @type {Map<string, string>}\n\t\t\t\t */\n\t\t\t\tconst imports = new Map();\n\n\t\t\t\t/**\n\t\t\t\t * @param {import('svelte/compiler').AST.RegularElement} node\n\t\t\t\t * @param {AST.Text | AST.ExpressionTag} src_attribute\n\t\t\t\t * @returns {Promise<void>}\n\t\t\t\t */\n\t\t\t\tasync function update_element(node, src_attribute) {\n\t\t\t\t\tif (src_attribute.type === 'ExpressionTag') {\n\t\t\t\t\t\tconst start =\n\t\t\t\t\t\t\t'end' in src_attribute.expression\n\t\t\t\t\t\t\t\t? src_attribute.expression.end\n\t\t\t\t\t\t\t\t: src_attribute.expression.range?.[0];\n\t\t\t\t\t\tconst end =\n\t\t\t\t\t\t\t'start' in src_attribute.expression\n\t\t\t\t\t\t\t\t? src_attribute.expression.start\n\t\t\t\t\t\t\t\t: src_attribute.expression.range?.[1];\n\n\t\t\t\t\t\tif (typeof start !== 'number' || typeof end !== 'number') {\n\t\t\t\t\t\t\tthrow new Error('ExpressionTag has no range');\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst src_var_name = content.substring(start, end).trim();\n\n\t\t\t\t\t\ts.update(node.start, node.end, dynamic_img_to_picture(content, node, src_var_name));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst original_url = src_attribute.raw.trim();\n\t\t\t\t\tlet url = original_url;\n\n\t\t\t\t\tif (OPTIMIZABLE.test(url)) {\n\t\t\t\t\t\tconst sizes = get_attr_value(node, 'sizes');\n\t\t\t\t\t\tconst width = get_attr_value(node, 'width');\n\t\t\t\t\t\turl += url.includes('?') ? '&' : '?';\n\t\t\t\t\t\tif (sizes && 'raw' in sizes) {\n\t\t\t\t\t\t\turl += 'imgSizes=' + encodeURIComponent(sizes.raw) + '&';\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (width && 'raw' in width) {\n\t\t\t\t\t\t\turl += 'imgWidth=' + encodeURIComponent(width.raw) + '&';\n\t\t\t\t\t\t}\n\t\t\t\t\t\turl += 'enhanced';\n\t\t\t\t\t}\n\n\t\t\t\t\t// resolves the import so that we can build the entire picture template string and don't\n\t\t\t\t\t// need any logic blocks\n\t\t\t\t\tconst resolved_id = (await plugin_context.resolve(url, filename))?.id;\n\t\t\t\t\tif (!resolved_id) {\n\t\t\t\t\t\tconst query_index = url.indexOf('?');\n\t\t\t\t\t\tconst file_path = query_index >= 0 ? url.substring(0, query_index) : url;\n\t\t\t\t\t\tif (existsSync(path.resolve(vite_config.publicDir, file_path))) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Could not locate ${file_path}. Please move it to be located relative to the page in the routes directory or reference it beginning with /static/. See https://vitejs.dev/guide/assets for more details on referencing assets.`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Could not locate ${file_path}. See https://vitejs.dev/guide/assets for more details on referencing assets.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (OPTIMIZABLE.test(url)) {\n\t\t\t\t\t\tconst image = await process_id(resolved_id, plugin_context, imagetools_plugin);\n\t\t\t\t\t\ts.update(node.start, node.end, img_to_picture(content, node, image));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst metadata = await sharp(resolved_id).metadata();\n\t\t\t\t\t\t// this must come after the await so that we don't hand off processing between getting\n\t\t\t\t\t\t// the imports.size and incrementing the imports.size\n\t\t\t\t\t\tconst name = imports.get(original_url) || '__IMPORTED_ASSET_' + imports.size + '__';\n\t\t\t\t\t\tif (!metadata.width || !metadata.height) {\n\t\t\t\t\t\t\tconsole.warn(`Could not determine intrinsic dimensions for ${resolved_id}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst new_markup = `<img ${serialize_img_attributes(content, node.attributes, {\n\t\t\t\t\t\t\tsrc: `{${name}}`,\n\t\t\t\t\t\t\twidth: metadata.width,\n\t\t\t\t\t\t\theight: metadata.height\n\t\t\t\t\t\t})} />`;\n\t\t\t\t\t\ts.update(node.start, node.end, new_markup);\n\t\t\t\t\t\timports.set(original_url, name);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * @type {Array<ReturnType<typeof update_element>>}\n\t\t\t\t */\n\t\t\t\tconst pending_ast_updates = [];\n\n\t\t\t\twalk(/** @type {import('svelte/compiler').AST.TemplateNode} */ (ast), null, {\n\t\t\t\t\tRegularElement(node, { next }) {\n\t\t\t\t\t\tif ('name' in node && node.name === 'enhanced:img') {\n\t\t\t\t\t\t\t// Compare node tag match\n\t\t\t\t\t\t\tconst src = get_attr_value(node, 'src');\n\n\t\t\t\t\t\t\tif (!src || typeof src === 'boolean') return;\n\n\t\t\t\t\t\t\tpending_ast_updates.push(update_element(node, src));\n\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tnext();\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tawait Promise.all(pending_ast_updates);\n\n\t\t\t\t// add imports\n\t\t\t\tif (imports.size) {\n\t\t\t\t\tlet text = '';\n\t\t\t\t\tfor (const [path, import_name] of imports.entries()) {\n\t\t\t\t\t\ttext += `\\timport ${import_name} from \"${path}\";\\n`;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ast.instance) {\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\ts.appendLeft(ast.instance.content.start, text);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ts.prepend(`<script>${text}</script>\\n`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (ast.css) {\n\t\t\t\t\tconst css = content.substring(ast.css.start, ast.css.end);\n\t\t\t\t\tconst modified = css.replaceAll('enhanced\\\\:img', 'img');\n\t\t\t\t\tif (modified !== css) {\n\t\t\t\t\t\ts.update(ast.css.start, ast.css.end, modified);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcode: s.toString(),\n\t\t\t\t\tmap: s.generateMap({ hires: 'boundary' })\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t};\n\treturn plugin;\n}\n\n/**\n * @param {string} resolved_id\n * @param {import('vite').Rollup.PluginContext} plugin_context\n * @param {import('vite').Plugin} imagetools_plugin\n * @returns {Promise<import('vite-imagetools').Picture>}\n */\nasync function process_id(resolved_id, plugin_context, imagetools_plugin) {\n\tif (!imagetools_plugin.load) {\n\t\tthrow new Error('Invalid instance of vite-imagetools. Could not find load method.');\n\t}\n\tconst hook = imagetools_plugin.load;\n\tconst handler = typeof hook === 'object' ? hook.handler : hook;\n\tconst module_info = await handler.call(plugin_context, resolved_id);\n\tif (!module_info) {\n\t\tthrow new Error(`Could not load ${resolved_id}`);\n\t}\n\tconst code = typeof module_info === 'string' ? module_info : module_info.code;\n\treturn parse_object(code.replace('export default', '').replace(/;$/, '').trim());\n}\n\n/**\n * @param {string} str\n */\nexport function parse_object(str) {\n\tconst updated = str\n\t\t.replaceAll(/{(\\n\\s*)?/gm, '{\"')\n\t\t.replaceAll(':', '\":')\n\t\t.replaceAll(/,(\\n\\s*)?([^ ])/g, ',\"$2');\n\ttry {\n\t\treturn JSON.parse(updated);\n\t} catch {\n\t\tthrow new Error(`Failed parsing string to object: ${str}`);\n\t}\n}\n\n/**\n * @param {import('../types/internal.js').TemplateNode} node\n * @param {string} attr\n * @returns {AST.Text | AST.ExpressionTag | undefined}\n */\nfunction get_attr_value(node, attr) {\n\tif (!('type' in node) || !('attributes' in node)) return;\n\tconst attribute = node.attributes.find(\n\t\t/** @param {any} v */ (v) => v.type === 'Attribute' && v.name === attr\n\t);\n\n\tif (!attribute || !('value' in attribute) || typeof attribute.value === 'boolean') return;\n\n\t// Check if value is an array and has at least one element\n\tif (Array.isArray(attribute.value)) {\n\t\tif (attribute.value.length > 0) return attribute.value[0];\n\t\treturn;\n\t}\n\n\t// If it's not an array or is empty, return the value as is\n\treturn attribute.value;\n}\n\n/**\n * @param {string} content\n * @param {import('../types/internal.js').Attribute[]} attributes\n * @param {{\n *   src: string,\n *   width?: string | number,\n *   height?: string | number\n * }} details\n */\nfunction serialize_img_attributes(content, attributes, details) {\n\tconst attribute_strings = attributes.map((attribute) => {\n\t\tif ('name' in attribute && attribute.name === 'src') {\n\t\t\treturn `src=${details.src}`;\n\t\t}\n\t\treturn content.substring(attribute.start, attribute.end);\n\t});\n\n\t/** @type {number | undefined} */\n\tlet user_width;\n\t/** @type {number | undefined} */\n\tlet user_height;\n\tfor (const attribute of attributes) {\n\t\tif ('name' in attribute && 'value' in attribute) {\n\t\t\tconst value = Array.isArray(attribute.value) ? attribute.value[0] : attribute.value;\n\t\t\tif (typeof value === 'object' && 'raw' in value) {\n\t\t\t\tif (attribute.name === 'width') user_width = parseInt(value.raw);\n\t\t\t\tif (attribute.name === 'height') user_height = parseInt(value.raw);\n\t\t\t}\n\t\t}\n\t}\n\tif (details.width && details.height) {\n\t\tif (!user_width && !user_height) {\n\t\t\tattribute_strings.push(`width=${details.width}`);\n\t\t\tattribute_strings.push(`height=${details.height}`);\n\t\t} else if (!user_width && user_height) {\n\t\t\tattribute_strings.push(\n\t\t\t\t`width=${Math.round(\n\t\t\t\t\t(stringToNumber(details.width) * user_height) / stringToNumber(details.height)\n\t\t\t\t)}`\n\t\t\t);\n\t\t} else if (!user_height && user_width) {\n\t\t\tattribute_strings.push(\n\t\t\t\t`height=${Math.round(\n\t\t\t\t\t(stringToNumber(details.height) * user_width) / stringToNumber(details.width)\n\t\t\t\t)}`\n\t\t\t);\n\t\t}\n\t}\n\n\treturn attribute_strings.join(' ');\n}\n\n/**\n * @param {string|number} param\n */\nfunction stringToNumber(param) {\n\treturn typeof param === 'string' ? parseInt(param) : param;\n}\n\n/**\n * @param {string} content\n * @param {import('svelte/compiler').AST.RegularElement} node\n * @param {import('vite-imagetools').Picture} image\n */\nfunction img_to_picture(content, node, image) {\n\t/** @type {import('../types/internal.js').Attribute[]} */\n\tconst attributes = node.attributes;\n\tconst index = attributes.findIndex(\n\t\t(attribute) => 'name' in attribute && attribute.name === 'sizes'\n\t);\n\tlet sizes_string = '';\n\tif (index >= 0) {\n\t\tsizes_string = ' ' + content.substring(attributes[index].start, attributes[index].end);\n\t\tattributes.splice(index, 1);\n\t}\n\n\tlet res = '<picture>';\n\n\tfor (const [format, srcset] of Object.entries(image.sources)) {\n\t\tres += `<source srcset=${to_value(srcset)}${sizes_string} type=\"image/${format}\" />`;\n\t}\n\n\tres += `<img ${serialize_img_attributes(content, attributes, {\n\t\tsrc: to_value(image.img.src),\n\t\twidth: image.img.w,\n\t\theight: image.img.h\n\t})} />`;\n\n\treturn res + '</picture>';\n}\n\n/**\n * @param {string} src\n */\nfunction to_value(src) {\n\t// __VITE_ASSET__ needs to be contained in double quotes to work with Vite asset plugin\n\treturn src.startsWith('__VITE_ASSET__') ? `{\"${src}\"}` : `\"${src}\"`;\n}\n\n/**\n * For images like `<img src={manually_imported} />`\n * @param {string} content\n * @param {import('svelte/compiler').AST.RegularElement} node\n * @param {string} src_var_name\n */\nfunction dynamic_img_to_picture(content, node, src_var_name) {\n\tconst attributes = node.attributes;\n\t/**\n\t * @param attribute_name {string}\n\t */\n\tfunction index(attribute_name) {\n\t\treturn attributes.findIndex(\n\t\t\t(attribute) => 'name' in attribute && attribute.name === attribute_name\n\t\t);\n\t}\n\tconst size_index = index('sizes');\n\tconst width_index = index('width');\n\tconst height_index = index('height');\n\tlet sizes_string = '';\n\tif (size_index >= 0) {\n\t\tsizes_string =\n\t\t\t' ' + content.substring(attributes[size_index].start, attributes[size_index].end);\n\t\tattributes.splice(size_index, 1);\n\t}\n\n\treturn `{#if typeof ${src_var_name} === 'string'}\n\t{#if import.meta.env.DEV && ${!width_index && !height_index}}\n\t\t{${src_var_name}} was not enhanced. Cannot determine dimensions.\n\t{:else}\n\t\t<img ${serialize_img_attributes(content, attributes, {\n\t\t\tsrc: `{${src_var_name}}`\n\t\t})} />\n\t{/if}\n{:else}\n\t<picture>\n\t\t{#each Object.entries(${src_var_name}.sources) as [format, srcset]}\n\t\t\t<source {srcset}${sizes_string} type={'image/' + format} />\n\t\t{/each}\n\t\t<img ${serialize_img_attributes(content, attributes, {\n\t\t\tsrc: `{${src_var_name}.img.src}`,\n\t\t\twidth: `{${src_var_name}.img.w}`,\n\t\t\theight: `{${src_var_name}.img.h}`\n\t\t})} />\n\t</picture>\n{/if}`;\n}\n"
  },
  {
    "path": "packages/enhanced-img/test/Input.svelte",
    "content": "<script lang=\"ts\">\n\timport manual_image1 from './no.png';\n\timport manual_image2 from './no.svg';\n\n\tconst src = manual_image1;\n\tconst images = [manual_image1, manual_image2];\n\tconst get_image = (image_key: number) => images[image_key];\n\n\tlet foo: string = 'bar';\n</script>\n\n{foo}\n\n<img src=\"./dev.png\" alt=\"non-enhanced test\" />\n\n<enhanced:img src=\"./dev.png\" alt=\"dev test\" />\n\n<div>\n\t<enhanced:img src=\"./dev.png\" alt=\"nested test\" />\n</div>\n\n<enhanced:img src=\"./prod.png\" alt=\"production test\" />\n\n<enhanced:img src=\"./dev.png\" width=\"5\" height=\"10\" alt=\"dimensions test\" />\n\n<enhanced:img src=\"./dev.png?blur=5\" alt=\"directive test\" />\n\n<enhanced:img src=\"./dev.png\" {...{ foo }} alt=\"spread attributes test\" />\n\n<enhanced:img\n\tsrc=\"./dev.png?w=1024,640,320\"\n\tsizes=\"(min-width: 60rem) 80vw, (min-width: 40rem) 90vw, 100vw\"\n\talt=\"sizes test\"\n/>\n\n<enhanced:img\n\tsrc=\"./dev.png\"\n\tonclick={() => (foo = 'clicked an image!')}\n\talt=\"event handler test\"\n/>\n\n<enhanced:img src=\"$lib/dev.png\" alt=\"alias test\" />\n\n<enhanced:img src=\"/src/dev.png\" alt=\"absolute path test\" />\n\n<enhanced:img {src} alt=\"attribute shorthand test\" />\n\n{#each images as image}\n\t<enhanced:img src={image} alt=\"opt-in test\" />\n{/each}\n\n{#each images as _, i}\n\t<enhanced:img src={get_image(i)} alt=\"opt-in test\" />\n{/each}\n\n<picture>\n\t<source src=\"./dev.avif\" />\n\t<source srcset=\"./dev.avif 500v ./bar.avif 100v\" />\n\t<source srcset=\"./dev.avif, ./bar.avif 1v\" />\n</picture>\n"
  },
  {
    "path": "packages/enhanced-img/test/Output.svelte",
    "content": "<script lang=\"ts\">\n\t\n\timport manual_image1 from './no.png';\n\t\n\timport manual_image2 from './no.svg';\n\n\tconst src = manual_image1;\n\tconst images = [manual_image1, manual_image2];\n\tconst get_image = (image_key: number) => images[image_key];\n\n\tlet foo: string = 'bar';\n</script>\n\n{foo}\n\n<img src=\"./dev.png\" alt=\"non-enhanced test\" />\n\n<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=\"/7\" alt=\"dev test\" width=1440 height=1440 /></picture>\n\n<div>\n\t<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=\"/7\" alt=\"nested test\" width=1440 height=1440 /></picture>\n</div>\n\n<picture><source srcset={\"__VITE_ASSET__2AM7_y_a__ 1440w, __VITE_ASSET__2AM7_y_b__ 960w\"} type=\"image/avif\" /><source srcset={\"__VITE_ASSET__2AM7_y_c__ 1440w, __VITE_ASSET__2AM7_y_d__ 960w\"} type=\"image/webp\" /><source srcset={\"__VITE_ASSET__2AM7_y_e__ 1440w, __VITE_ASSET__2AM7_y_f__ 960w\"} type=\"image/png\" /><img src={\"__VITE_ASSET__2AM7_y_g__\"} alt=\"production test\" width=1440 height=1440 /></picture>\n\n<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=\"/7\" width=\"5\" height=\"10\" alt=\"dimensions test\" /></picture>\n\n<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=\"/7\" alt=\"directive test\" width=1440 height=1440 /></picture>\n\n<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=\"/7\" {...{ foo }} alt=\"spread attributes test\" width=1440 height=1440 /></picture>\n\n<picture><source srcset=\"/1 1440w, /2 960w\" sizes=\"(min-width: 60rem) 80vw, (min-width: 40rem) 90vw, 100vw\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" sizes=\"(min-width: 60rem) 80vw, (min-width: 40rem) 90vw, 100vw\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" sizes=\"(min-width: 60rem) 80vw, (min-width: 40rem) 90vw, 100vw\" type=\"image/png\" /><img src=\"/7\" alt=\"sizes test\" width=1440 height=1440 /></picture>\n\n<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=\"/7\" onclick={() => (foo = 'clicked an image!')} alt=\"event handler test\" width=1440 height=1440 /></picture>\n\n<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=\"/7\" alt=\"alias test\" width=1440 height=1440 /></picture>\n\n<picture><source srcset=\"/1 1440w, /2 960w\" type=\"image/avif\" /><source srcset=\"/3 1440w, /4 960w\" type=\"image/webp\" /><source srcset=\"5 1440w, /6 960w\" type=\"image/png\" /><img src=\"/7\" alt=\"absolute path test\" width=1440 height=1440 /></picture>\n\n{#if typeof src === 'string'}\n\t{#if \n\timport.meta.env.DEV && false}\n\t\t{src} was not enhanced. Cannot determine dimensions.\n\t{:else}\n\t\t<img src={src} alt=\"attribute shorthand test\" />\n\t{/if}\n{:else}\n\t<picture>\n\t\t{#each Object.entries(src.sources) as [format, srcset]}\n\t\t\t<source {srcset} type={'image/' + format} />\n\t\t{/each}\n\t\t<img src={src.img.src} alt=\"attribute shorthand test\" width={src.img.w} height={src.img.h} />\n\t</picture>\n{/if}\n\n{#each images as image}\n\t{#if typeof image === 'string'}\n\t{#if \n\timport.meta.env.DEV && false}\n\t\t{image} was not enhanced. Cannot determine dimensions.\n\t{:else}\n\t\t<img src={image} alt=\"opt-in test\" />\n\t{/if}\n{:else}\n\t<picture>\n\t\t{#each Object.entries(image.sources) as [format, srcset]}\n\t\t\t<source {srcset} type={'image/' + format} />\n\t\t{/each}\n\t\t<img src={image.img.src} alt=\"opt-in test\" width={image.img.w} height={image.img.h} />\n\t</picture>\n{/if}\n{/each}\n\n{#each images as _, i}\n\t{#if typeof get_image(i) === 'string'}\n\t{#if \n\timport.meta.env.DEV && false}\n\t\t{get_image(i)} was not enhanced. Cannot determine dimensions.\n\t{:else}\n\t\t<img src={get_image(i)} alt=\"opt-in test\" />\n\t{/if}\n{:else}\n\t<picture>\n\t\t{#each Object.entries(get_image(i).sources) as [format, srcset]}\n\t\t\t<source {srcset} type={'image/' + format} />\n\t\t{/each}\n\t\t<img src={get_image(i).img.src} alt=\"opt-in test\" width={get_image(i).img.w} height={get_image(i).img.h} />\n\t</picture>\n{/if}\n{/each}\n\n<picture>\n\t<source src=\"./dev.avif\" />\n\t<source srcset=\"./dev.avif 500v ./bar.avif 100v\" />\n\t<source srcset=\"./dev.avif, ./bar.avif 1v\" />\n</picture>\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/jsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"include\": [\"src/**/*.d.ts\", \"src/**/*.js\", \"src/**/*.svelte\"]\n}\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/package.json",
    "content": "{\n\t\"name\": \"enhanced-img-basics\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"test\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/enhanced-img\": \"workspace:^\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/src/routes/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.status}</h1>\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/src/routes/+layout.svelte",
    "content": "<script>\n\t/** @type {{children?: import('svelte').Snippet}} */\n\tlet { children } = $props();\n</script>\n\n{@render children?.()}\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/src/routes/+page.svelte",
    "content": "<script>\n\timport logo from './logo.png?enhanced';\n</script>\n\n<!-- standard image -->\n<enhanced:img id=\"birds\" src=\"./birds.jpg\" alt=\"birds\" />\n\n<!-- svg over inline size -->\n<enhanced:img id=\"playwright\" src=\"./playwright-logo.svg\" alt=\"Playwright logo\" />\n\n<!-- dynamic image -->\n<enhanced:img id=\"logo\" src={logo} alt=\"Svelte logo\" />\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/test/test.js",
    "content": "import { expect, test } from '@playwright/test';\nimport process from 'node:process';\nconst is_node18 = process.versions.node.startsWith('18.');\n// TODO: remove with SvelteKit 3\ntest.skip(is_node18, 'enhanced-img requires vite-plugin-svelte@6 which requires node20');\ntest('images are properly rendered', async ({ page }) => {\n\tawait page.goto('/');\n\n\tconst birdsImg = page.locator('#birds');\n\tawait expect(birdsImg).toBeVisible();\n\tawait expect(birdsImg).toHaveAttribute('alt', 'birds');\n\n\tconst logoImg = page.locator('#logo');\n\tawait expect(logoImg).toBeVisible();\n\tawait expect(logoImg).toHaveAttribute('alt', 'Svelte logo');\n\n\tconst playwrightImg = page.locator('#playwright');\n\tawait expect(playwrightImg).toBeVisible();\n\tawait expect(playwrightImg).toHaveAttribute('alt', 'Playwright logo');\n});\n"
  },
  {
    "path": "packages/enhanced-img/test/apps/basics/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { enhancedImages } from '../../../src/index.js';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tplugins: [enhancedImages(), sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../kit/src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/enhanced-img/test/markup-plugin.spec.js",
    "content": "import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { expect, it } from 'vitest';\nimport { image_plugin, parse_object } from '../src/vite-plugin.js';\n\nconst resolve = /** @param {string} file */ (file) => path.resolve(__dirname, file);\n\nit('Image preprocess snapshot test', async () => {\n\tconst filename = 'Input.svelte';\n\tconst vite_plugin = image_plugin({\n\t\tname: 'vite-imagetools-mock',\n\t\tload(id) {\n\t\t\tif (id.includes('dev')) {\n\t\t\t\treturn 'export default {sources:{avif:\"/1 1440w, /2 960w\",webp:\"/3 1440w, /4 960w\",png:\"5 1440w, /6 960w\"},img:{src:\"/7\",w:1440,h:1440}};';\n\t\t\t} else if (id.includes('prod')) {\n\t\t\t\treturn 'export default {sources:{avif:\"__VITE_ASSET__2AM7_y_a__ 1440w, __VITE_ASSET__2AM7_y_b__ 960w\",webp:\"__VITE_ASSET__2AM7_y_c__ 1440w, __VITE_ASSET__2AM7_y_d__ 960w\",png:\"__VITE_ASSET__2AM7_y_e__ 1440w, __VITE_ASSET__2AM7_y_f__ 960w\"},img:{src:\"__VITE_ASSET__2AM7_y_g__\",w:1440,h:1440}};';\n\t\t\t}\n\t\t\tthrow new Error(`unrecognized id ${id}`);\n\t\t}\n\t});\n\tconst plugin_context = /** @type {import('vite').Rollup.TransformPluginContext} */ (\n\t\t/** @type {unknown} */ ({\n\t\t\t// @ts-ignore\n\t\t\tresolve(url) {\n\t\t\t\treturn { id: url };\n\t\t\t}\n\t\t})\n\t);\n\tconst transform =\n\t\t/** @type {(this: import('vite').Rollup.TransformPluginContext, code: string, id: string, options?: {ssr?: boolean;}) => Promise<import('vite').Rollup.TransformResult>} */ (\n\t\t\t// @ts-expect-error fails until vite is updated\n\t\t\tvite_plugin.transform.handler\n\t\t);\n\tconst transformed = await transform.call(\n\t\tplugin_context,\n\t\tawait fs.readFile(resolve(filename), { encoding: 'utf-8' }),\n\t\tfilename\n\t);\n\tif (!transformed) throw new Error('transform unexpectedly returned no results');\n\tif (typeof transformed === 'string') throw new Error('transform did not return a sourcemap');\n\tif (!transformed.code) throw new Error('transform did not return any code');\n\n\t// Make imports readable\n\tconst ouput = transformed.code.replace(/import/g, '\\n\\timport');\n\n\tawait expect(ouput).toMatchFileSnapshot('./Output.svelte');\n});\n\nit('parses a minimized object', () => {\n\tconst parsed = parse_object(\n\t\t'{sources:{avif:\"/@imagetools/aa851ecbdef6d98bef38810ea9212d3d4cd9712c 1440w, /@imagetools/f5bc22df4071ea198fea2206d55b7bf5f5fc83e6 960w\",webp:\"/@imagetools/e8afd7da22a03ee0ae914cbfac6c714bded6daaf 1440w, /@imagetools/a5a1cd19d9fdd0754c3dc5122798c31ad3586041 960w\",png:\"/@imagetools/216a9a139bef55f2d6d70f91bcffe8584152136b 1440w, /@imagetools/e060ca6e665a6e50a24d00e3a7be2a7c96fdeb64 960w\"},img:{src:\"/@imagetools/216a9a139bef55f2d6d70f91bcffe8584152136b\",w:1440,h:1440}}'\n\t);\n\texpect(parsed).toBeDefined();\n});\n\nit('parses a non-minimized object', () => {\n\tconst parsed = parse_object(\n\t\t`{\n\t\t\tsources: {\n\t\t\t\tavif: \"__VITE_ASSET__f63692be__ 1440w, __VITE_ASSET__7c12aaf8__ 960w\",\n\t\t\t\twebp: \"__VITE_ASSET__60e1d553__ 1440w, __VITE_ASSET__d0e3c982__ 960w\",\n\t\t\t\tpng: \"__VITE_ASSET__ac99f329__ 1440w, __VITE_ASSET__33d52b23__ 960w\"\n\t\t\t},\n\t\t\timg: {\n\t\t\t\tsrc: \"__VITE_ASSET__ac99f329__\",\n\t\t\t\tw: 1440,\n\t\t\t\th: 1440\n\t\t\t}\n\t\t}`\n\t);\n\texpect(parsed).toBeDefined();\n});\n"
  },
  {
    "path": "packages/enhanced-img/test/utils.js",
    "content": "import { devices } from '@playwright/test';\nimport process from 'node:process';\nimport { number_from_env } from '../../../test-utils/index.js';\n\n// TODO: remove with SvelteKit 3\nconst is_node18 = process.versions.node.startsWith('18.');\n/** @type {import('@playwright/test').PlaywrightTestConfig} */\nexport const config = {\n\tforbidOnly: !!process.env.CI,\n\t// generous timeouts on CI\n\ttimeout: process.env.CI ? 45000 : 15000,\n\twebServer: is_node18\n\t\t? undefined\n\t\t: {\n\t\t\t\t// do not try to build on node18\n\t\t\t\tcommand: 'pnpm build && pnpm preview',\n\t\t\t\tport: 4173\n\t\t\t},\n\tretries: process.env.CI ? 2 : number_from_env('KIT_E2E_RETRIES', 0),\n\tprojects: [\n\t\t{\n\t\t\tname: 'chromium'\n\t\t}\n\t],\n\tuse: {\n\t\t...devices['Desktop Chrome'],\n\t\tscreenshot: 'only-on-failure',\n\t\ttrace: 'retain-on-failure',\n\t\tchannel: 'chromium'\n\t},\n\tworkers: process.env.CI ? 2 : number_from_env('KIT_E2E_WORKERS', undefined),\n\treporter: 'list',\n\ttestDir: 'test',\n\ttestMatch: /(.+\\.)?(test|spec)\\.[jt]s/\n};\n"
  },
  {
    "path": "packages/enhanced-img/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"node16\",\n\t\t\"moduleResolution\": \"node16\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"paths\": {\n\t\t\t\"types\": [\"./types/index\"],\n\t\t\t\"types/*\": [\"./types/*\"]\n\t\t},\n\t\t\"noUnusedLocals\": true,\n\t\t\"noUnusedParameters\": true\n\t},\n\t\"include\": [\"src/**/*\", \"types/**/*\", \"test/**/*\"]\n}\n"
  },
  {
    "path": "packages/enhanced-img/types/ambient.d.ts",
    "content": "declare module '*?enhanced' {\n\timport type { Picture } from 'vite-imagetools';\n\n\tconst value: Picture;\n\texport default value;\n}\n"
  },
  {
    "path": "packages/enhanced-img/types/index.d.ts",
    "content": "import type { HTMLImgAttributes } from 'svelte/elements';\nimport type { Plugin } from 'vite';\nimport type { Picture } from 'vite-imagetools';\nimport './ambient.js';\n\nexport { Picture };\n\ntype EnhancedImgAttributes = Omit<HTMLImgAttributes, 'src'> & { src: string | Picture };\n\n// https://svelte.dev/docs/svelte/typescript#enhancing-built-in-dom-types\ndeclare module 'svelte/elements' {\n\texport interface SvelteHTMLElements {\n\t\t'enhanced:img': EnhancedImgAttributes;\n\t}\n}\n\nexport function enhancedImages(): Promise<Plugin[]>;\n"
  },
  {
    "path": "packages/enhanced-img/types/internal.d.ts",
    "content": "import type { AST } from 'svelte/compiler';\n\ntype ElementLike =\n\t| AST.Component\n\t| AST.TitleElement\n\t| AST.SlotElement\n\t| AST.RegularElement\n\t| AST.SvelteBody\n\t| AST.SvelteComponent\n\t| AST.SvelteDocument\n\t| AST.SvelteElement\n\t| AST.SvelteFragment\n\t| AST.SvelteHead\n\t| AST.SvelteOptionsRaw\n\t| AST.SvelteSelf\n\t| AST.SvelteWindow;\n\ntype Tag = AST.ExpressionTag | AST.HtmlTag | AST.ConstTag | AST.DebugTag | AST.RenderTag;\n\ntype Directive =\n\t| AST.AnimateDirective\n\t| AST.BindDirective\n\t| AST.ClassDirective\n\t| AST.LetDirective\n\t| AST.OnDirective\n\t| AST.StyleDirective\n\t| AST.TransitionDirective\n\t| AST.UseDirective;\n\ntype Block = AST.EachBlock | AST.IfBlock | AST.AwaitBlock | AST.KeyBlock | AST.SnippetBlock;\n\nexport type TemplateNode = AST.Text | Tag | ElementLike | AST.Comment | Block;\n\nexport type Attribute = AST.RegularElement['attributes'][number];\n"
  },
  {
    "path": "packages/kit/.gitignore",
    "content": ".DS_Store\n/node_modules/\n/test/**/build\n!/src/core/adapt/fixtures/*/.svelte-kit\n!/test/node_modules\n/test/apps/basics/test/errors.json\n/types/*.map\n.custom-out-dir\n\n# these are already ignored by the top level .gitignore\n# repeating them here as a faux .prettierignore\n/.svelte-kit/\n/dist/\n"
  },
  {
    "path": "packages/kit/.prettierignore",
    "content": "/types\n/src/runtime/components/svelte-5/layout.svelte\n.svelte-kit\n.custom-out-dir\ntest-results\n/test/apps/basics/test/errors.json\n/test/build-errors/apps/syntax-error/src/routes/+page.svelte\n"
  },
  {
    "path": "packages/kit/CHANGELOG-pre-1.md",
    "content": "# Changelog for pre 1.0 versions\n\n## 1.0.0-next.589\n\n### Patch Changes\n\n- breaking: remove warnings/errors about removed/changed APIs ([#8019](https://github.com/sveltejs/kit/pull/8019))\n\n## 1.0.0-next.588\n\n### Patch Changes\n\n- fix: remove obsolete generated types correctly ([#8149](https://github.com/sveltejs/kit/pull/8149))\n\n## 1.0.0-next.587\n\n### Patch Changes\n\n- breaking: prerender shells when ssr false and prerender not false ([#8131](https://github.com/sveltejs/kit/pull/8131))\n\n## 1.0.0-next.586\n\n### Patch Changes\n\n- fix: don't de/encode initial and explicit string headers ([#8113](https://github.com/sveltejs/kit/pull/8113))\n\n## 1.0.0-next.585\n\n### Patch Changes\n\n- fix: remove unused elements from default error component ([#8110](https://github.com/sveltejs/kit/pull/8110))\n\n## 1.0.0-next.584\n\n### Patch Changes\n\n- fix: load errorTemplate from correct location ([#8096](https://github.com/sveltejs/kit/pull/8096))\n- More robust manifest error recovery ([#8095](https://github.com/sveltejs/kit/pull/8095))\n\n## 1.0.0-next.583\n\n### Patch Changes\n\n- restart vite dev-server on svelte config change ([#8087](https://github.com/sveltejs/kit/pull/8087))\n- Set correct `$page.status` when using `enhance` and result is of type `'error'` ([#8073](https://github.com/sveltejs/kit/pull/8073))\n- fix: ensure export conditions are resolve through Vite ([#8092](https://github.com/sveltejs/kit/pull/8092))\n- fix: don't crash Vite dev server on manifest error ([#8093](https://github.com/sveltejs/kit/pull/8093))\n\n## 1.0.0-next.582\n\n### Patch Changes\n\n- fix: improve split between Vite plugins ([#8055](https://github.com/sveltejs/kit/pull/8055))\n- fix: set Vite base URL ([#8046](https://github.com/sveltejs/kit/pull/8046))\n- add declaration for vitePreprocess reexport ([#8053](https://github.com/sveltejs/kit/pull/8053))\n\n## 1.0.0-next.581\n\n### Patch Changes\n\n- feat: vitePreprocess ([#8036](https://github.com/sveltejs/kit/pull/8036))\n\n## 1.0.0-next.580\n\n### Patch Changes\n\n- breaking: throw an error on invalid load response ([#8003](https://github.com/sveltejs/kit/pull/8003))\n- fix: allow SvelteKit to be used without bundling ([#7950](https://github.com/sveltejs/kit/pull/7950))\n\n## 1.0.0-next.579\n\n### Patch Changes\n\n- breaking: update svelte peerDependency to ^3.54.0 ([#7543](https://github.com/sveltejs/kit/pull/7543))\n- update esbuild to ^0.16.3 ([#7543](https://github.com/sveltejs/kit/pull/7543))\n- breaking: upgrade to Vite 4 ([#7543](https://github.com/sveltejs/kit/pull/7543))\n\n## 1.0.0-next.578\n\n### Patch Changes\n\n- fix: respect fetch cache option ([#8024](https://github.com/sveltejs/kit/pull/8024))\n- breaking: rename invalid() to fail() and ValidationError to ActionFailure ([#8012](https://github.com/sveltejs/kit/pull/8012))\n- breaking: replace automatic fallback generation with `builder.generateFallback(fallback)` ([#8013](https://github.com/sveltejs/kit/pull/8013))\n\n## 1.0.0-next.577\n\n### Patch Changes\n\n- breaking: add embedded option, turned off by default ([#7969](https://github.com/sveltejs/kit/pull/7969))\n\n## 1.0.0-next.576\n\n### Patch Changes\n\n- breaking: make `sveltekit()` return a promise of array of Vite plugins ([#7994](https://github.com/sveltejs/kit/pull/7994))\n\n## 1.0.0-next.575\n\n### Patch Changes\n\n- fix: throw error when using enhance on GET forms ([#7948](https://github.com/sveltejs/kit/pull/7948))\n- breaking: strip `__data.json` from url ([#7979](https://github.com/sveltejs/kit/pull/7979))\n\n## 1.0.0-next.574\n\n### Patch Changes\n\n- feat: split Vite plugin in two ([#7990](https://github.com/sveltejs/kit/pull/7990))\n\n## 1.0.0-next.573\n\n### Patch Changes\n\n- fix: adjust ActionData type ([#7962](https://github.com/sveltejs/kit/pull/7962))\n- breaking: disallow unknown exports (except when starting with an underscore) from `+(layout|page)(.server)?.js` and `+server.js` files ([#7878](https://github.com/sveltejs/kit/pull/7878))\n- fix: continuous optionals should not throw conflict error ([#7939](https://github.com/sveltejs/kit/pull/7939))\n- fix `enhance` error message when form action doesn't exist or csrf is enabled ([#7958](https://github.com/sveltejs/kit/pull/7958))\n\n## 1.0.0-next.572\n\n### Minor Changes\n\n- Checks that element is not null before reading getAttribute ([#7930](https://github.com/sveltejs/kit/pull/7930))\n\n### Patch Changes\n\n- chore: update `magic-string` ([#7931](https://github.com/sveltejs/kit/pull/7931))\n- add $app and $env to optimizeDeps.exclude so that libraries using these work correctly when prebundled ([#7933](https://github.com/sveltejs/kit/pull/7933))\n- reload dev page on change of app.html ([#7944](https://github.com/sveltejs/kit/pull/7944))\n\n## 1.0.0-next.571\n\n### Patch Changes\n\n- fix: use searchParams for x-sveltekit-invalidated ([#7912](https://github.com/sveltejs/kit/pull/7912))\n- fix: correct Vite config merging with force option ([#7911](https://github.com/sveltejs/kit/pull/7911))\n- fix: rebuild manifest when client hooks or param matcher file is added/removed ([#7915](https://github.com/sveltejs/kit/pull/7915))\n\n## 1.0.0-next.570\n\n### Patch Changes\n\n- Remove prepublishOnly script ([#7893](https://github.com/sveltejs/kit/pull/7893))\n\n## 1.0.0-next.569\n\n### Patch Changes\n\n- Ignore elements that are no longer in the document ([#7881](https://github.com/sveltejs/kit/pull/7881))\n- breaking: Use client-side routing for `<form method=\"GET\">` ([#7828](https://github.com/sveltejs/kit/pull/7828))\n\n## 1.0.0-next.568\n\n### Patch Changes\n\n- fix: add migration hint for renamed methods ([#7874](https://github.com/sveltejs/kit/pull/7874))\n\n## 1.0.0-next.567\n\n### Patch Changes\n\n- Co-locate synthetic types with other Kit types ([#7864](https://github.com/sveltejs/kit/pull/7864))\n\n## 1.0.0-next.566\n\n### Patch Changes\n\n- Add more type documentation ([#7003](https://github.com/sveltejs/kit/pull/7003))\n- breaking: move SubmitFunction into @sveltejs/kit ([#7003](https://github.com/sveltejs/kit/pull/7003))\n\n## 1.0.0-next.565\n\n### Patch Changes\n\n- breaking: Replace `data-sveltekit-prefetch` with `-preload-code` and `-preload-data` ([#7776](https://github.com/sveltejs/kit/pull/7776))\n- breaking: Rename `prefetch` to `preloadData` and `prefetchRoutes` to `preloadCode` ([#7776](https://github.com/sveltejs/kit/pull/7776))\n\n## 1.0.0-next.564\n\n### Patch Changes\n\n- chore: upgrade undici ([#7830](https://github.com/sveltejs/kit/pull/7830))\n- Make `$page.url` resilient against mutations ([#7827](https://github.com/sveltejs/kit/pull/7827))\n\n## 1.0.0-next.563\n\n### Patch Changes\n\n- feat: allow handleError to return a promise ([#7780](https://github.com/sveltejs/kit/pull/7780))\n- breaking: remove `format` option from `generateManifest(...)` ([#7820](https://github.com/sveltejs/kit/pull/7820))\n\n## 1.0.0-next.562\n\n### Patch Changes\n\n- fix: handle redirects in handle hook while processing data request ([#7797](https://github.com/sveltejs/kit/pull/7797))\n- Make touchstart listener passive ([#7818](https://github.com/sveltejs/kit/pull/7818))\n- breaking: remove `getStaticDirectory()` from builder API ([#7809](https://github.com/sveltejs/kit/pull/7809))\n- Make console.warn wrapper named rather than anonymous ([#7811](https://github.com/sveltejs/kit/pull/7811))\n\n## 1.0.0-next.561\n\n### Patch Changes\n\n- Upgrade vite-plugin-svelte to ^1.3.1 ([#7760](https://github.com/sveltejs/kit/pull/7760))\n\n## 1.0.0-next.560\n\n### Patch Changes\n\n- breaking: Rename `prerendering` to `building`, remove `config.kit.prerender.enabled` ([#7762](https://github.com/sveltejs/kit/pull/7762))\n\n## 1.0.0-next.559\n\n### Patch Changes\n\n- Roll over non-matching optional parameters instead of 404ing ([#7753](https://github.com/sveltejs/kit/pull/7753))\n- fix: enable Vite's modulePreload.polyfill ([#7770](https://github.com/sveltejs/kit/pull/7770))\n\n## 1.0.0-next.558\n\n### Patch Changes\n\n- breaking: Disallow error status codes outside 400-599 ([#7767](https://github.com/sveltejs/kit/pull/7767))\n- breaking: Make client-side router ignore links outside %sveltekit.body% ([#7766](https://github.com/sveltejs/kit/pull/7766))\n\n## 1.0.0-next.557\n\n### Patch Changes\n\n- external fetch calls: ensure serialized cookie values are url-encoded [#7736] ([#7736](https://github.com/sveltejs/kit/pull/7736))\n\n## 1.0.0-next.556\n\n### Patch Changes\n\n- fix: preserve Vite CLI opts ([#7749](https://github.com/sveltejs/kit/pull/7749))\n\n## 1.0.0-next.555\n\n### Patch Changes\n\n- Made `config.kit.outDir` able to be located in `node_modules` ([#7707](https://github.com/sveltejs/kit/pull/7707))\n\n## 1.0.0-next.554\n\n### Patch Changes\n\n- create stronger types for dynamically generated env modules ([#7735](https://github.com/sveltejs/kit/pull/7735))\n- breaking: Make `trailingSlash` a page option, rather than configuration ([#7719](https://github.com/sveltejs/kit/pull/7719))\n- Handle hash links with non-ASCII characters when prerendering ([#7729](https://github.com/sveltejs/kit/pull/7729))\n- Ignore popstate events from outside the router ([#7721](https://github.com/sveltejs/kit/pull/7721))\n\n## 1.0.0-next.553\n\n### Patch Changes\n\n- Prevent Vite from nuking logs on startup ([#7724](https://github.com/sveltejs/kit/pull/7724))\n\n## 1.0.0-next.552\n\n### Patch Changes\n\n- Don't hardcode version in client bundle ([#7694](https://github.com/sveltejs/kit/pull/7694))\n- Allow .d.ts files to have a + prefix ([#7682](https://github.com/sveltejs/kit/pull/7682))\n- Expose version from `$app/environment` ([#7689](https://github.com/sveltejs/kit/pull/7689))\n- fix: export HttpError/Redirect interface ([#7701](https://github.com/sveltejs/kit/pull/7701))\n- fix: don't preload fonts by default ([#7704](https://github.com/sveltejs/kit/pull/7704))\n- Always set `Accept` and `Accept-Language` headers when making a self-request ([#7722](https://github.com/sveltejs/kit/pull/7722))\n- fix: adjust interfaces to fix type errors ([#7718](https://github.com/sveltejs/kit/pull/7718))\n\n## 1.0.0-next.551\n\n### Patch Changes\n\n- Add `Access-Control-Allow-Origin: *` to static assets in dev ([#7688](https://github.com/sveltejs/kit/pull/7688))\n- Ignore presence of `keepfocus` and `noscroll` in `goto` options if correctly-cased options are also present ([#7678](https://github.com/sveltejs/kit/pull/7678))\n\n## 1.0.0-next.550\n\n### Patch Changes\n\n- feat: preload fonts and add preload customization ([#4963](https://github.com/sveltejs/kit/pull/4963))\n\n## 1.0.0-next.549\n\n### Patch Changes\n\n- Always apply Node polyfills ([#7675](https://github.com/sveltejs/kit/pull/7675))\n\n## 1.0.0-next.548\n\n### Patch Changes\n\n- Only apply polyfills where necessary ([#7668](https://github.com/sveltejs/kit/pull/7668))\n\n## 1.0.0-next.547\n\n### Patch Changes\n\n- fix: safely join url segments in manifest ([#7653](https://github.com/sveltejs/kit/pull/7653))\n- breaking: use devalue to (de)serialize action data ([#7494](https://github.com/sveltejs/kit/pull/7494))\n- Warn if `%sveltekit.body%` is direct child of `<body>` ([#7652](https://github.com/sveltejs/kit/pull/7652))\n\n## 1.0.0-next.546\n\n### Patch Changes\n\n- fix outdated config error ([#7649](https://github.com/sveltejs/kit/pull/7649))\n- breaking: use hex/unicode escape sequences for encoding special characters in route directory names ([#7644](https://github.com/sveltejs/kit/pull/7644))\n- fix `beforeNavigate` description — `routeId` -> `route.id` ([#7643](https://github.com/sveltejs/kit/pull/7643))\n\n## 1.0.0-next.545\n\n### Patch Changes\n\n- fix: prerendering path and layout fixes ([#7639](https://github.com/sveltejs/kit/pull/7639))\n- fix: add Promise return type to the `enhance` action ([#7629](https://github.com/sveltejs/kit/pull/7629))\n\n## 1.0.0-next.544\n\n### Patch Changes\n\n- breaking: narrow down possible status codes for redirects to 300-308 ([#7615](https://github.com/sveltejs/kit/pull/7615))\n- feat: add fallback component for layouts without one ([#7619](https://github.com/sveltejs/kit/pull/7619))\n\n## 1.0.0-next.543\n\n### Patch Changes\n\n- Don't print search params error when prerendering fallback page ([#7598](https://github.com/sveltejs/kit/pull/7598))\n- allow async function for `enhance` action parameter ([#7608](https://github.com/sveltejs/kit/pull/7608))\n- Run service worker during development ([#7597](https://github.com/sveltejs/kit/pull/7597))\n- feat: support throwing redirect in handle ([#7612](https://github.com/sveltejs/kit/pull/7612))\n- Workaround for the DOM clobbering for use:enhance ([#7599](https://github.com/sveltejs/kit/pull/7599))\n- fix: don't cache prefetch errors ([#7610](https://github.com/sveltejs/kit/pull/7610))\n\n## 1.0.0-next.542\n\n### Patch Changes\n\n- Add support for linking to <a name=\"hash\"> tags ([#7596](https://github.com/sveltejs/kit/pull/7596))\n- breaking: don't run beforeNavigate during redirects ([#7588](https://github.com/sveltejs/kit/pull/7588))\n- fix: respect autofocus following navigation or enhanced form submit ([#6643](https://github.com/sveltejs/kit/pull/6643))\n\n## 1.0.0-next.541\n\n### Minor Changes\n\n- fix: don't clean build and output directories when using `--watch` ([#7516](https://github.com/sveltejs/kit/pull/7516))\n\n### Patch Changes\n\n- fix: handle expected errors thrown in handle hook correctly ([#7566](https://github.com/sveltejs/kit/pull/7566))\n\n## 1.0.0-next.540\n\n### Patch Changes\n\n- Serve prerendered non-page files when running preview ([#7576](https://github.com/sveltejs/kit/pull/7576))\n- fix: caching takes now into account the body payload ([#7546](https://github.com/sveltejs/kit/pull/7546))\n- fix: handle locked readable stream when reading body ([#7565](https://github.com/sveltejs/kit/pull/7565))\n- fix: prefetch should ignore links ignored by the router ([#7580](https://github.com/sveltejs/kit/pull/7580))\n- fix: migration error when using $page.routeId ([#7574](https://github.com/sveltejs/kit/pull/7574))\n- prevent loading of illegal modules in the browser, rather than during SSR ([#7507](https://github.com/sveltejs/kit/pull/7507))\n- fix: prevent double decoding of path segment ([#7550](https://github.com/sveltejs/kit/pull/7550))\n\n## 1.0.0-next.539\n\n### Patch Changes\n\n- Omit prerendered routes from server manifest ([#7541](https://github.com/sveltejs/kit/pull/7541))\n\n## 1.0.0-next.538\n\n### Patch Changes\n\n- feat: enable caching for `__data.json` requests ([#7532](https://github.com/sveltejs/kit/pull/7532))\n- fix: prevent double decoding of params ([#7521](https://github.com/sveltejs/kit/pull/7521))\n- fix: take into account Request input when serializing fetch data ([#7531](https://github.com/sveltejs/kit/pull/7531))\n- fix: better cookie warning checks ([#7528](https://github.com/sveltejs/kit/pull/7528))\n\n## 1.0.0-next.537\n\n### Patch Changes\n\n- feat: better navigation interfaces ([#7529](https://github.com/sveltejs/kit/pull/7529))\n\n## 1.0.0-next.536\n\n### Patch Changes\n\n- custom aliases resolved in service worker builds ([#7500](https://github.com/sveltejs/kit/pull/7500))\n\n## 1.0.0-next.535\n\n### Patch Changes\n\n- breaking: call beforeNavigate once with type unload on external navigation, rename type 'load' to 'enter' and type 'unload' to 'leave', add 'willUnload' property ([#6813](https://github.com/sveltejs/kit/pull/6813))\n\n## 1.0.0-next.534\n\n### Patch Changes\n\n- breaking: more consistent casing for goto options ([#7502](https://github.com/sveltejs/kit/pull/7502))\n- breaking: replace routeId with route.id ([#7450](https://github.com/sveltejs/kit/pull/7450))\n- Fix nullish data node reference ([#7503](https://github.com/sveltejs/kit/pull/7503))\n\n## 1.0.0-next.533\n\n### Patch Changes\n\n- fix: bump required Vite version and address warning ([#7491](https://github.com/sveltejs/kit/pull/7491))\n\n## 1.0.0-next.532\n\n### Patch Changes\n\n- Bump devalue version ([#7466](https://github.com/sveltejs/kit/pull/7466))\n\n## 1.0.0-next.531\n\n### Patch Changes\n\n- breaking: change `config.kit.prerender.onError` to `handleHttpError`, and check for invalid fragment links ([#7375](https://github.com/sveltejs/kit/pull/7375))\n- fix escaping bug in crawler ([#7375](https://github.com/sveltejs/kit/pull/7375))\n\n## 1.0.0-next.530\n\n### Patch Changes\n\n- fix: fetch erroring on Cloudflare ([#7453](https://github.com/sveltejs/kit/pull/7453))\n- Only simulate CORS errors for shared load functions ([#7454](https://github.com/sveltejs/kit/pull/7454))\n\n## 1.0.0-next.529\n\n### Patch Changes\n\n- fix: better type generation for load functions with different return values ([#7425](https://github.com/sveltejs/kit/pull/7425))\n- fix: correctly strip data suffix at root page ([#7445](https://github.com/sveltejs/kit/pull/7445))\n- update dependencies ([#7355](https://github.com/sveltejs/kit/pull/7355))\n\n## 1.0.0-next.528\n\n### Patch Changes\n\n- Restore `req.url` to `req.originalUrl` in dev and preview ([#7343](https://github.com/sveltejs/kit/pull/7343))\n\n## 1.0.0-next.527\n\n### Patch Changes\n\n- fix: harmonize cookie path and add dev time warnings ([#7416](https://github.com/sveltejs/kit/pull/7416))\n- feat: add invalidateAll option to goto ([#7407](https://github.com/sveltejs/kit/pull/7407))\n\n## 1.0.0-next.526\n\n### Patch Changes\n\n- declare function type with named syntax ([#7396](https://github.com/sveltejs/kit/pull/7396))\n- fix: optional params can be undefined ([#7379](https://github.com/sveltejs/kit/pull/7379))\n- fix: support undici 5.12.0 and pin it ([#7412](https://github.com/sveltejs/kit/pull/7412))\n- chore: upgrade to vite-plugin-svelte 1.1.0 and enable prebundleSvelteLibraries ([#7388](https://github.com/sveltejs/kit/pull/7388))\n- Show more descriptive error if data returned from `load` is a non-POJO ([#7386](https://github.com/sveltejs/kit/pull/7386))\n\n## 1.0.0-next.525\n\n### Patch Changes\n\n- Always avoid caching form submission on enhanced forms ([#7350](https://github.com/sveltejs/kit/pull/7350))\n\n## 1.0.0-next.524\n\n### Patch Changes\n\n- fix: get type gen working again ([#7370](https://github.com/sveltejs/kit/pull/7370))\n- fix: don't run matchers for empty optional params ([#7346](https://github.com/sveltejs/kit/pull/7346))\n\n## 1.0.0-next.523\n\n### Patch Changes\n\n- fix: split route ids into correct segments ([#7367](https://github.com/sveltejs/kit/pull/7367))\n\n## 1.0.0-next.522\n\n### Patch Changes\n\n- docs: rewrite load docs ([#7174](https://github.com/sveltejs/kit/pull/7174))\n- breaking: Prefix all route IDs with / ([#7338](https://github.com/sveltejs/kit/pull/7338))\n\n## 1.0.0-next.521\n\n### Patch Changes\n\n- feat: add reset option to update method of enhance ([#7326](https://github.com/sveltejs/kit/pull/7326))\n- breaking: remove global fetch override when prerendering ([#7318](https://github.com/sveltejs/kit/pull/7318))\n- Improve error message when prefetching fails ([#7314](https://github.com/sveltejs/kit/pull/7314))\n\n## 1.0.0-next.520\n\n### Patch Changes\n\n- fix: ensure serialized headers check is always applied ([#7221](https://github.com/sveltejs/kit/pull/7221))\n\n## 1.0.0-next.519\n\n### Patch Changes\n\n- breaking: throw error when routes conflict ([#7051](https://github.com/sveltejs/kit/pull/7051))\n- feat: implement optional route params ([#7051](https://github.com/sveltejs/kit/pull/7051))\n\n## 1.0.0-next.518\n\n### Patch Changes\n\n- Enable removal of non-browser code from client builds ([#7296](https://github.com/sveltejs/kit/pull/7296))\n- feat: more info about prerendering errors, add strict option to adapter-static ([#7264](https://github.com/sveltejs/kit/pull/7264))\n\n## 1.0.0-next.517\n\n### Patch Changes\n\n- fix: more informative serialization error messages ([#7303](https://github.com/sveltejs/kit/pull/7303))\n- fix: add `$types` to includes for better DX ([#7301](https://github.com/sveltejs/kit/pull/7301))\n\n## 1.0.0-next.516\n\n### Patch Changes\n\n- fix: better navigation protocol check ([#7067](https://github.com/sveltejs/kit/pull/7067))\n- fix: forward cookie headers on etag response ([#7256](https://github.com/sveltejs/kit/pull/7256))\n- Properly resolve absolute paths to relative on server build ([#7252](https://github.com/sveltejs/kit/pull/7252))\n\n## 1.0.0-next.515\n\n### Patch Changes\n\n- Account for relative path to routes in `config.kit.files.routes` ([#7223](https://github.com/sveltejs/kit/pull/7223))\n- Use config.kit.paths.base prefix for static assets ([#4448](https://github.com/sveltejs/kit/pull/4448))\n\n## 1.0.0-next.514\n\n### Patch Changes\n\n- add helpful error message for `throw invalid()` in form actions ([#7225](https://github.com/sveltejs/kit/pull/7225))\n\n## 1.0.0-next.513\n\n### Patch Changes\n\n- Transfer server data as devalue-encoded JSON ([#7177](https://github.com/sveltejs/kit/pull/7177))\n- fix: remove groups from segments for adapters ([#7222](https://github.com/sveltejs/kit/pull/7222))\n\n## 1.0.0-next.512\n\n### Patch Changes\n\n- Fix parsing content-type header for actions ([#7195](https://github.com/sveltejs/kit/pull/7195))\n- fix: reset form in use:enhance after successful submit ([#7207](https://github.com/sveltejs/kit/pull/7207))\n- fix: auto-update commented PageError ([#7189](https://github.com/sveltejs/kit/pull/7189))\n\n## 1.0.0-next.511\n\n### Patch Changes\n\n- perf: render head links before other content ([#7160](https://github.com/sveltejs/kit/pull/7160))\n\n## 1.0.0-next.510\n\n### Patch Changes\n\n- Add `fetch` to `RequestEvent` ([#7113](https://github.com/sveltejs/kit/pull/7113))\n\n## 1.0.0-next.509\n\n### Patch Changes\n\n- Apply define config to service worker ([#7140](https://github.com/sveltejs/kit/pull/7140))\n- chore: Skip removing HTTP/2 pseudo-headers, which is no longer necessary with undici ([#7142](https://github.com/sveltejs/kit/pull/7142))\n- bump devalue to version 4 ([#7147](https://github.com/sveltejs/kit/pull/7147))\n\n## 1.0.0-next.508\n\n### Patch Changes\n\n- chore: Upgrade undici so that we can use its multipart form data parsing instead of node-fetch's ([#7131](https://github.com/sveltejs/kit/pull/7131))\n\n## 1.0.0-next.507\n\n### Patch Changes\n\n- Allow TypedArray request bodies in `fetch` in `load` ([#7065](https://github.com/sveltejs/kit/pull/7065))\n- Use `FormData` polyfill from `undici` rather than `node-fetch` ([#7065](https://github.com/sveltejs/kit/pull/7065))\n\n## 1.0.0-next.506\n\n### Patch Changes\n\n- Default to insecure cookies when serving on http://localhost ([#7090](https://github.com/sveltejs/kit/pull/7090))\n- docs: explain ramifications of base path ([#7095](https://github.com/sveltejs/kit/pull/7095))\n- fix: decode routeIds in headers for prerendering ([#7097](https://github.com/sveltejs/kit/pull/7097))\n- feat: provide `update` to `use:enhance` callback ([#7083](https://github.com/sveltejs/kit/pull/7083))\n\n## 1.0.0-next.505\n\n### Patch Changes\n\n- fix: handle form action returning nothing; handle page.(server).js without load functions ([#7050](https://github.com/sveltejs/kit/pull/7050))\n- fix: add `RequestEvent` to `$types` when `+layout.server.js` present ([#7063](https://github.com/sveltejs/kit/pull/7063))\n\n## 1.0.0-next.504\n\n### Patch Changes\n\n- Add the submitter value with name to formData for use:enhance ([#7012](https://github.com/sveltejs/kit/pull/7012))\n\n## 1.0.0-next.503\n\n### Patch Changes\n\n- Added form property to \\$page store ([#6986](https://github.com/sveltejs/kit/pull/6986))\n- Throw an error if prerenderable routes are not prerendered ([#6974](https://github.com/sveltejs/kit/pull/6974))\n\n## 1.0.0-next.502\n\n### Patch Changes\n\n- fix: prevent data types from becoming type `never`, notice moved/deleted files ([#7002](https://github.com/sveltejs/kit/pull/7002))\n- Allow ActionData to be undefined ([#6994](https://github.com/sveltejs/kit/pull/6994))\n- Respect `config.kit.env.dir` when running `vite preview` ([#7001](https://github.com/sveltejs/kit/pull/7001))\n- Only run postinstall script if package.json exists ([#6998](https://github.com/sveltejs/kit/pull/6998))\n- Use custom x-sveltekit-action header to route enhanced form submissions to +page.server.js over +server.js ([#6997](https://github.com/sveltejs/kit/pull/6997))\n\n## 1.0.0-next.501\n\n### Patch Changes\n\n- fix: unwrap promises for load function data on the client ([#6972](https://github.com/sveltejs/kit/pull/6972))\n\n## 1.0.0-next.500\n\n### Patch Changes\n\n- Allow prerendered pages to link to non-prerenderable endpoints ([#6977](https://github.com/sveltejs/kit/pull/6977))\n- fix: handle SPA root data loading error ([#6918](https://github.com/sveltejs/kit/pull/6918))\n\n## 1.0.0-next.499\n\n### Patch Changes\n\n- breaking: rename App.PageError to App.Error ([#6963](https://github.com/sveltejs/kit/pull/6963))\n\n## 1.0.0-next.498\n\n### Patch Changes\n\n- chdir before attempting postinstall ([#6969](https://github.com/sveltejs/kit/pull/6969))\n\n## 1.0.0-next.497\n\n### Patch Changes\n\n- Add origin header for non-GET and external requests made with server-side fetch ([#6901](https://github.com/sveltejs/kit/pull/6901))\n\n## 1.0.0-next.496\n\n### Patch Changes\n\n- fix: update page status when applying action ([#6942](https://github.com/sveltejs/kit/pull/6942))\n- fix: apply redirect/error logic for `use:enhance` ([#6828](https://github.com/sveltejs/kit/pull/6828))\n\n## 1.0.0-next.495\n\n### Patch Changes\n\n- Run `svelte-kit sync` in all workspace directories during postinstall ([#6949](https://github.com/sveltejs/kit/pull/6949))\n\n## 1.0.0-next.494\n\n### Patch Changes\n\n- Fix fetch type ([#6955](https://github.com/sveltejs/kit/pull/6955))\n- Add csp wasm-unsafe-eval keyword ([#6958](https://github.com/sveltejs/kit/pull/6958))\n- Register service worker with relative URL ([#6954](https://github.com/sveltejs/kit/pull/6954))\n\n## 1.0.0-next.493\n\n### Patch Changes\n\n- fix: allow missing routes folder ([#6944](https://github.com/sveltejs/kit/pull/6944))\n- Only forward set-cookie headers for internal fetches ([#6923](https://github.com/sveltejs/kit/pull/6923))\n\n## 1.0.0-next.492\n\n### Patch Changes\n\n- fix: add missing depends function to ServerLoadEvent type ([#6935](https://github.com/sveltejs/kit/pull/6935))\n- Redact error message if `getRequest` fails ([#6936](https://github.com/sveltejs/kit/pull/6936))\n- Add cookies.serialize method ([#6925](https://github.com/sveltejs/kit/pull/6925))\n- Always apply cookies, not just for matched routes ([#6925](https://github.com/sveltejs/kit/pull/6925))\n- fix: tighten up navigation and invalidation logic ([#6924](https://github.com/sveltejs/kit/pull/6924))\n- Respond with 413 if request body is too large ([#6936](https://github.com/sveltejs/kit/pull/6936))\n\n## 1.0.0-next.491\n\n### Patch Changes\n\n- fix: symlink routes ([#6796](https://github.com/sveltejs/kit/pull/6796))\n\n## 1.0.0-next.490\n\n### Patch Changes\n\n- fix `write_types` on windows using posixify() ([#6913](https://github.com/sveltejs/kit/pull/6913))\n- Prevent caching of `__data.js` files ([#6904](https://github.com/sveltejs/kit/pull/6904))\n- Make url property getters non-enumerable ([#6909](https://github.com/sveltejs/kit/pull/6909))\n\n## 1.0.0-next.489\n\n### Patch Changes\n\n- fix: tighten up handling and documentation around 404 ([#6897](https://github.com/sveltejs/kit/pull/6897))\n\n## 1.0.0-next.488\n\n### Patch Changes\n\n- Decode HTML entities in `href` attributes when crawling ([#6891](https://github.com/sveltejs/kit/pull/6891))\n\n## 1.0.0-next.487\n\n### Patch Changes\n\n- feat: allow +server.js files next to +page files ([#6773](https://github.com/sveltejs/kit/pull/6773))\n\n## 1.0.0-next.486\n\n### Patch Changes\n\n- fix: handle jsdoc without tags while generating proxy types ([#6884](https://github.com/sveltejs/kit/pull/6884))\n\n## 1.0.0-next.485\n\n### Patch Changes\n\n- fix to ActionData type generation ([#6869](https://github.com/sveltejs/kit/pull/6869))\n- The return type of cookies.get is string|undefined #6865 ([#6867](https://github.com/sveltejs/kit/pull/6867))\n\n## 1.0.0-next.484\n\n### Patch Changes\n\n- fix: forward cookies from fetch on redirect response ([#6833](https://github.com/sveltejs/kit/pull/6833))\n- adding missing `@types/cookie` dependency ([#6818](https://github.com/sveltejs/kit/pull/6818))\n- fix `write_types` on windows ([#6843](https://github.com/sveltejs/kit/pull/6843))\n\n## 1.0.0-next.483\n\n### Patch Changes\n\n- fix: various `cookies` fixes and improvements ([#6811](https://github.com/sveltejs/kit/pull/6811))\n\n## 1.0.0-next.482\n\n### Patch Changes\n\n- fix: ActionData type ([#6748](https://github.com/sveltejs/kit/pull/6748))\n- fix: reuse server data while not reusing client load ([#6778](https://github.com/sveltejs/kit/pull/6778))\n- fix: update current.url on hashchange ([#6802](https://github.com/sveltejs/kit/pull/6802))\n- Change illegal import message to reference public-facing code rather than client-side code ([#6646](https://github.com/sveltejs/kit/pull/6646))\n- fix: silence prop warnings ([#6798](https://github.com/sveltejs/kit/pull/6798))\n- chore: Refactor graph analysis for better unit tests ([#6727](https://github.com/sveltejs/kit/pull/6727))\n- fix: error when using `paths.base` and `import` assets ([#6769](https://github.com/sveltejs/kit/pull/6769))\n\n## 1.0.0-next.481\n\n### Patch Changes\n\n- fix: docs links in generated and published types ([#6741](https://github.com/sveltejs/kit/pull/6741))\n\n## 1.0.0-next.480\n\n### Patch Changes\n\n- breaking: make action passed to enhance function a URL instead of a string ([#6678](https://github.com/sveltejs/kit/pull/6678))\n\n## 1.0.0-next.479\n\n### Patch Changes\n\n- breaking: request creation cleanup ([#6681](https://github.com/sveltejs/kit/pull/6681))\n- breaking: limit adapter-node request size ([#6684](https://github.com/sveltejs/kit/pull/6684))\n\n## 1.0.0-next.478\n\n### Patch Changes\n\n- breaking: hooks file renames; error shape defined through handleError ([#6675](https://github.com/sveltejs/kit/pull/6675))\n- breaking: remove element property; enhance can only be used on form elements ([#6662](https://github.com/sveltejs/kit/pull/6662))\n\n## 1.0.0-next.477\n\n### Patch Changes\n\n- breaking: prevent import of `$lib/server` modules in client-facing code ([#6623](https://github.com/sveltejs/kit/pull/6623))\n- breaking: change sveltekit.message to sveltekit.error.message ([#6659](https://github.com/sveltejs/kit/pull/6659))\n- breaking: apply 304 logic after handle, so handle receives original response from resolve ([#6639](https://github.com/sveltejs/kit/pull/6639))\n\n## 1.0.0-next.476\n\n### Patch Changes\n\n- breaking: change use:enhance signature to support `<button formaction>` ([#6633](https://github.com/sveltejs/kit/pull/6633))\n\n## 1.0.0-next.475\n\n### Patch Changes\n\n- cookies.delete fix #6609 ([#6622](https://github.com/sveltejs/kit/pull/6622))\n- feat: provide `SubmitFunction` type ([#6613](https://github.com/sveltejs/kit/pull/6613))\n- fix: address Vite warning when using base or asset path ([#6621](https://github.com/sveltejs/kit/pull/6621))\n\n## 1.0.0-next.474\n\n### Patch Changes\n\n- breaking: disallow default and named actions next to each other ([#6615](https://github.com/sveltejs/kit/pull/6615))\n\n## 1.0.0-next.473\n\n### Patch Changes\n\n- fix: pass `form` prop to pages ([#6611](https://github.com/sveltejs/kit/pull/6611))\n\n## 1.0.0-next.472\n\n### Patch Changes\n\n- breaking: add API for interacting with cookies ([#6593](https://github.com/sveltejs/kit/pull/6593))\n- breaking: Replace `POST`/`PUT`/`PATCH`/`DELETE` in `+page.server.js` with `export const actions` ([#6469](https://github.com/sveltejs/kit/pull/6469))\n\n## 1.0.0-next.471\n\n### Patch Changes\n\n- breaking: Allow users to designate modules as server-only ([#6422](https://github.com/sveltejs/kit/pull/6422))\n- breaking: exclude headers from serialized responses by default, add `filterSerializedResponseHeaders` `resolve` option ([#6569](https://github.com/sveltejs/kit/pull/6569))\n\n## 1.0.0-next.470\n\n### Patch Changes\n\n- Bump vite-plugin-svelte and required vite version ([#6583](https://github.com/sveltejs/kit/pull/6583))\n- feat: Support for `$env/dynamic/*` in Vite ecosystem tools ([#6454](https://github.com/sveltejs/kit/pull/6454))\n- breaking: Replace `externalFetch` with `handleFetch` ([#6565](https://github.com/sveltejs/kit/pull/6565))\n\n## 1.0.0-next.469\n\n### Patch Changes\n\n- disable `rollupOptions.output.hoistTransitiveImports` by default ([#6560](https://github.com/sveltejs/kit/pull/6560))\n\n## 1.0.0-next.468\n\n### Patch Changes\n\n- breaking: simulate CORS errors in server-side fetch ([#6550](https://github.com/sveltejs/kit/pull/6550))\n\n## 1.0.0-next.467\n\n### Patch Changes\n\n- breaking: prevent server-side fetch from reading files with # character in the filename ([#6549](https://github.com/sveltejs/kit/pull/6549))\n\n## 1.0.0-next.466\n\n### Patch Changes\n\n- breaking: change Navigation type to include from/to.params and from/to.routeId ([#6552](https://github.com/sveltejs/kit/pull/6552))\n- Warn about incorrect data-sveltekit-x values ([#6546](https://github.com/sveltejs/kit/pull/6546))\n\n## 1.0.0-next.465\n\n### Patch Changes\n\n- feat: add `type` to navigation object ([#6537](https://github.com/sveltejs/kit/pull/6537))\n\n## 1.0.0-next.464\n\n### Patch Changes\n\n- Fix server manifest generation ([#6507](https://github.com/sveltejs/kit/pull/6507))\n- Silently skip prefetching of external URLs when using `data-sveltekit-prefetch`. Warn like before when calling `prefetch()` for external URLs. ([#6518](https://github.com/sveltejs/kit/pull/6518))\n\n## 1.0.0-next.463\n\n### Patch Changes\n\n- fix peer dependency warning on vite-3.1.0-beta.1 ([#6512](https://github.com/sveltejs/kit/pull/6512))\n- breaking: respect cache-control max-age on the client for initially fetched responses ([#6461](https://github.com/sveltejs/kit/pull/6461))\n\n## 1.0.0-next.462\n\n### Patch Changes\n\n- breaking: block cross-site form POSTs by default. disable with config.kit.csrf.checkOrigin ([#6510](https://github.com/sveltejs/kit/pull/6510))\n\n## 1.0.0-next.461\n\n### Patch Changes\n\n- breaking: call `invalidate(fn)` predicates with a URL instead of a string ([#6493](https://github.com/sveltejs/kit/pull/6493))\n- Prefer JSON responses when returning errors if accept header is `*/*` ([#6497](https://github.com/sveltejs/kit/pull/6497))\n- breaking: replace invalidate() with invalidateAll() ([#6493](https://github.com/sveltejs/kit/pull/6493))\n\n## 1.0.0-next.460\n\n### Patch Changes\n\n- breaking: Remove sveltekit:start event ([#6484](https://github.com/sveltejs/kit/pull/6484))\n\n## 1.0.0-next.459\n\n### Patch Changes\n\n- Prevent validation_errors from being serialized twice ([#6468](https://github.com/sveltejs/kit/pull/6468))\n\n## 1.0.0-next.458\n\n### Patch Changes\n\n- breaking: catch and render raw response when unexpected error occurs in endpoint ([#6434](https://github.com/sveltejs/kit/pull/6434))\n\n## 1.0.0-next.457\n\n### Patch Changes\n\n- Print error if resolveOpts.ssr is set ([#6475](https://github.com/sveltejs/kit/pull/6475))\n\n## 1.0.0-next.456\n\n### Patch Changes\n\n- Apply `data-sveltekit-prefetch/noscroll/reload` to all child `<a>` elements ([#6442](https://github.com/sveltejs/kit/pull/6442))\n- fix: Saving the root route will write types now ([#6450](https://github.com/sveltejs/kit/pull/6450))\n\n## 1.0.0-next.455\n\n### Patch Changes\n\n- bump vite-plugin-svelte to 1.0.3 to fix an issue with svelte-inspector in vite 3.1 ([#6443](https://github.com/sveltejs/kit/pull/6443))\n- chore: bump ts version and ensure it works with latest changes ([#6428](https://github.com/sveltejs/kit/pull/6428))\n- breaking: `ssr/hydrate/router/prerender.default` are now configurable in `+page(.server).js` and `+layout(.server).js` ([#6197](https://github.com/sveltejs/kit/pull/6197))\n- breaking: add `error.html` page, rename `kit.config.files.template` to `kit.config.files.appTemplate` ([#6367](https://github.com/sveltejs/kit/pull/6367))\n- breaking: merge resolve options when using sequence helper ([#6401](https://github.com/sveltejs/kit/pull/6401))\n- breaking: replace `router`/`hydrate` page options with `csr` ([#6446](https://github.com/sveltejs/kit/pull/6446))\n- breaking: add `prerender = 'auto'` option, and extend `prerender` option to endpoints ([#6392](https://github.com/sveltejs/kit/pull/6392))\n\n## 1.0.0-next.454\n\n### Patch Changes\n\n- breaking: Replace `sveltekit:*` with valid HTML attributes like `data-sveltekit-*` ([#6170](https://github.com/sveltejs/kit/pull/6170))\n\n## 1.0.0-next.453\n\n### Patch Changes\n\n- Include type descriptions for ambient declarations ([#6416](https://github.com/sveltejs/kit/pull/6416))\n\n## 1.0.0-next.452\n\n### Patch Changes\n\n- breaking: remove App.PrivateEnv and App.PublicEnv in favour of generated types ([#6413](https://github.com/sveltejs/kit/pull/6413))\n\n## 1.0.0-next.451\n\n### Patch Changes\n\n- Prevent infinite reloads on `/` when root `+layout.server.js` exports `load` ([#6405](https://github.com/sveltejs/kit/pull/6405))\n\n## 1.0.0-next.450\n\n### Patch Changes\n\n- breaking: require Vite 3.1.0-beta.1 ([#6398](https://github.com/sveltejs/kit/pull/6398))\n\n## 1.0.0-next.449\n\n### Patch Changes\n\n- fix: silence unused type hints in generated proxy files ([#6391](https://github.com/sveltejs/kit/pull/6391))\n\n## 1.0.0-next.448\n\n### Patch Changes\n\n- prevent test suites from getting published ([#6386](https://github.com/sveltejs/kit/pull/6386))\n- fix: remove unnecessary JSON serialization of server data ([#6382](https://github.com/sveltejs/kit/pull/6382))\n- breaking: require Node 16.14 ([#6388](https://github.com/sveltejs/kit/pull/6388))\n\n## 1.0.0-next.447\n\n### Patch Changes\n\n- Use devalue to serialize server-only `load` return values ([#6318](https://github.com/sveltejs/kit/pull/6318))\n\n## 1.0.0-next.446\n\n### Patch Changes\n\n- fix: encode if root layout has server load ([#6352](https://github.com/sveltejs/kit/pull/6352))\n\n## 1.0.0-next.445\n\n### Patch Changes\n\n- breaking: rename `$app/env` to `$app/environment`, to disambiguate with `$env/...` ([#6334](https://github.com/sveltejs/kit/pull/6334))\n\n## 1.0.0-next.444\n\n### Patch Changes\n\n- set errors on root component ([#6330](https://github.com/sveltejs/kit/pull/6330))\n- fix: do not call server and update `$page.data` unnecessarily ([#6311](https://github.com/sveltejs/kit/pull/6311))\n\n## 1.0.0-next.443\n\n### Patch Changes\n\n- fix: prevent unused types warning ([#6293](https://github.com/sveltejs/kit/pull/6293))\n- fix: don't reuse server load data from previous page if current doesn't have a load function ([#6309](https://github.com/sveltejs/kit/pull/6309))\n\n## 1.0.0-next.442\n\n### Patch Changes\n\n- fix: handle case where parent() refers to missing load function ([#6282](https://github.com/sveltejs/kit/pull/6282))\n\n## 1.0.0-next.441\n\n### Patch Changes\n\n- fix: Set `errors` prop on all layout/leaf components, not just page that happens to be deepest ([#6279](https://github.com/sveltejs/kit/pull/6279))\n- Fix route sorting with groups ([#6288](https://github.com/sveltejs/kit/pull/6288))\n\n## 1.0.0-next.440\n\n### Patch Changes\n\n- fix: type tweaks ([#6271](https://github.com/sveltejs/kit/pull/6271))\n- Correctly determine whether route uses server data ([#6275](https://github.com/sveltejs/kit/pull/6275))\n\n## 1.0.0-next.439\n\n### Patch Changes\n\n- feat: add App.PageData type ([#6226](https://github.com/sveltejs/kit/pull/6226))\n\n## 1.0.0-next.438\n\n### Patch Changes\n\n- more granular URL property tracking during load ([#6237](https://github.com/sveltejs/kit/pull/6237))\n- breaking: change event.clientAddress to event.getClientAddress() ([#6237](https://github.com/sveltejs/kit/pull/6237))\n- Remove all enumerable getters from RequestEvent and LoadEvent ([#6237](https://github.com/sveltejs/kit/pull/6237))\n\n## 1.0.0-next.437\n\n### Patch Changes\n\n- fix: only generate blank non-SSR pages when prerendering is enabled ([#6251](https://github.com/sveltejs/kit/pull/6251))\n\n## 1.0.0-next.436\n\n### Patch Changes\n\n- fix: prerender routes in a (group) ([#6232](https://github.com/sveltejs/kit/pull/6232))\n\n## 1.0.0-next.435\n\n### Patch Changes\n\n- fix: allow `@` route breakouts to layouts in `[foo]` or `(foo)` directories ([#6224](https://github.com/sveltejs/kit/pull/6224))\n\n## 1.0.0-next.434\n\n### Patch Changes\n\n- Always create `$types` for a route with a layout, leaf or endpoint ([#6222](https://github.com/sveltejs/kit/pull/6222))\n\n## 1.0.0-next.433\n\n### Patch Changes\n\n- feat: Moved hooks.js initialization from Server.respond into Server.init ([#6179](https://github.com/sveltejs/kit/pull/6179))\n\n## 1.0.0-next.432\n\n### Patch Changes\n\n- breaking: implement new layout system (see the PR for migration instructions) ([#6174](https://github.com/sveltejs/kit/pull/6174))\n\n## 1.0.0-next.431\n\n### Patch Changes\n\n- feat: Avoid running load on the server unnecessarily ([#6056](https://github.com/sveltejs/kit/pull/6056))\n\n## 1.0.0-next.430\n\n### Patch Changes\n\n- feat: Added config.kit.env.dir, which allows users to set a directory to search for .env files ([#6175](https://github.com/sveltejs/kit/pull/6175))\n\n## 1.0.0-next.429\n\n### Patch Changes\n\n- fix: Prevent import of `$env/*/private` in client ([#6018](https://github.com/sveltejs/kit/pull/6018))\n- Fix vite.config.ts \"Cannot find module '@sveltejs/kit/vite' or its corresponding type declarations.\" ([#6140](https://github.com/sveltejs/kit/pull/6140))\n\n## 1.0.0-next.428\n\n### Patch Changes\n\n- Allow `$app/stores` to be used from anywhere on the browser ([#6100](https://github.com/sveltejs/kit/pull/6100))\n- use `enumerable: false` on \"[x] no longer exists\" getters so that they are not triggered by spreading ([#6105](https://github.com/sveltejs/kit/pull/6105))\n- Fix pattern matching for routes starting with an encoded `@` symbol ([#6110](https://github.com/sveltejs/kit/pull/6110))\n- Fix typos in generating `LayoutServerLoad.{name}` type ([#6123](https://github.com/sveltejs/kit/pull/6123))\n- Fix sorting of files into +layout, +error, everything else. ([#6108](https://github.com/sveltejs/kit/pull/6108))\n- Add test folder to generated tsconfig ([#6085](https://github.com/sveltejs/kit/pull/6085))\n\n## 1.0.0-next.427\n\n### Patch Changes\n\n- Throw error if browser.hydrate is false and browser.router is true ([#6086](https://github.com/sveltejs/kit/pull/6086))\n\n## 1.0.0-next.426\n\n### Patch Changes\n\n- Avoid using [].at(-1) in the client ([#6082](https://github.com/sveltejs/kit/pull/6082))\n\n## 1.0.0-next.425\n\n### Patch Changes\n\n- Silence more unknown prop warnings coming from SvelteKit ([#6078](https://github.com/sveltejs/kit/pull/6078))\n\n## 1.0.0-next.424\n\n### Patch Changes\n\n- prevent duplicate module ids by disabling optimizeDeps for @sveltejs/kit ([#6057](https://github.com/sveltejs/kit/pull/6057))\n- Generate types when Svelte file missing, fix layout params ([#6066](https://github.com/sveltejs/kit/pull/6066))\n- Silence unknown prop warnings coming from SvelteKit ([#6071](https://github.com/sveltejs/kit/pull/6071))\n\n## 1.0.0-next.423\n\n### Patch Changes\n\n- Accumulate data from parent layouts into `export let data` ([#6050](https://github.com/sveltejs/kit/pull/6050))\n\n## 1.0.0-next.422\n\n### Patch Changes\n\n- breaking: remove ability for `+page.server.js` to respond to `GET` requests with JSON ([#6007](https://github.com/sveltejs/kit/pull/6007))\n- Handle `throw error/redirect` in `+server.js` ([#6028](https://github.com/sveltejs/kit/pull/6028))\n- handle `set-cookie` in `setHeaders` ([#6033](https://github.com/sveltejs/kit/pull/6033))\n- Handle windows paths and regexp chars in kit.alias ([#6034](https://github.com/sveltejs/kit/pull/6034))\n- Make errors type in Action type less restrictive ([#6022](https://github.com/sveltejs/kit/pull/6022))\n- Check that data is serializable ([#5987](https://github.com/sveltejs/kit/pull/5987))\n- Fix parent data type for layouts referencing named layouts in the same folder ([#6025](https://github.com/sveltejs/kit/pull/6025))\n\n## 1.0.0-next.421\n\n### Patch Changes\n\n- Respect `export const prerender = false` in `+page.server.js` ([#6012](https://github.com/sveltejs/kit/pull/6012))\n\n## 1.0.0-next.420\n\n### Patch Changes\n\n- fix: support linked `@sveltejs/kit` project in Vite 3.0.3+ ([#5861](https://github.com/sveltejs/kit/pull/5861))\n\n## 1.0.0-next.419\n\n### Patch Changes\n\n- Return a 303 response when a `POST` handler provides a `location` ([#5989](https://github.com/sveltejs/kit/pull/5989))\n- Generate `__data.json` files for server-side redirects when prerendering ([#5997](https://github.com/sveltejs/kit/pull/5997))\n- chore: remove chokidar as dependency of kit ([#5996](https://github.com/sveltejs/kit/pull/5996))\n- Use relative asset paths where possible ([#4250](https://github.com/sveltejs/kit/pull/4250))\n\n## 1.0.0-next.418\n\n### Patch Changes\n\n- Prevent double import of env modules ([#5955](https://github.com/sveltejs/kit/pull/5955))\n- Tighten up params typings, fix load function typings, add event typings to generated types ([#5974](https://github.com/sveltejs/kit/pull/5974))\n\n## 1.0.0-next.417\n\n### Patch Changes\n\n- Render pages without a .svelte file in their proper layout/error files ([#5972](https://github.com/sveltejs/kit/pull/5972))\n\n## 1.0.0-next.416\n\n### Patch Changes\n\n- fix: allow additional keys in svelte.config.js ([#5961](https://github.com/sveltejs/kit/pull/5961))\n\n## 1.0.0-next.415\n\n### Patch Changes\n\n- breaking: Remove session object ([#5946](https://github.com/sveltejs/kit/pull/5946))\n\n## 1.0.0-next.414\n\n### Patch Changes\n\n- Correctly provide server parent data ([#5916](https://github.com/sveltejs/kit/pull/5916))\n\n## 1.0.0-next.413\n\n### Patch Changes\n\n- feat: `$env/static/*` are now virtual to prevent writing sensitive values to disk ([#5825](https://github.com/sveltejs/kit/pull/5825))\n\n## 1.0.0-next.412\n\n### Patch Changes\n\n- Lazy load Svelte components to reenable no-ssr use cases ([#5930](https://github.com/sveltejs/kit/pull/5930))\n\n## 1.0.0-next.411\n\n### Patch Changes\n\n- Hydration validation errors ([#5918](https://github.com/sveltejs/kit/pull/5918))\n- Handle function without params when writing TS proxy ([#5928](https://github.com/sveltejs/kit/pull/5928))\n- fix: prevent `Content-Length` header from being incorrectly inherited by requests made from `load`'s `fetch` during SSR ([#5922](https://github.com/sveltejs/kit/pull/5922))\n- Provide helpful error message on invalid named layout reference ([#5912](https://github.com/sveltejs/kit/pull/5912))\n\n## 1.0.0-next.410\n\n### Patch Changes\n\n- Fix generated path extension for `AwaitedProperties` ([#5917](https://github.com/sveltejs/kit/pull/5917))\n\n## 1.0.0-next.409\n\n### Patch Changes\n\n- make generated type import path ends in `.js` ([#5907](https://github.com/sveltejs/kit/pull/5907))\n\n## 1.0.0-next.408\n\n### Patch Changes\n\n- Only search for layout name in basename ([#5897](https://github.com/sveltejs/kit/pull/5897))\n\n## 1.0.0-next.407\n\n### Patch Changes\n\n- Allow actions to return undefined ([#5892](https://github.com/sveltejs/kit/pull/5892))\n- fix: avoid manifest collisions ([#5874](https://github.com/sveltejs/kit/pull/5874))\n- Make package command remove `publishConfig.directory` from generated package.json ([#5848](https://github.com/sveltejs/kit/pull/5848))\n\n## 1.0.0-next.406\n\n### Patch Changes\n\n- breaking: Overhaul filesystem-based router (https://github.com/sveltejs/kit/discussions/5774) ([#5778](https://github.com/sveltejs/kit/pull/5778))\n- breaking: Change load API (https://github.com/sveltejs/kit/discussions/5774) ([#5778](https://github.com/sveltejs/kit/pull/5778))\n\n## 1.0.0-next.405\n\n### Patch Changes\n\n- Move `compress` logic to `Builder` API ([#5822](https://github.com/sveltejs/kit/pull/5822))\n- feat: implement Link header ([#5735](https://github.com/sveltejs/kit/pull/5735))\n\n## 1.0.0-next.404\n\n### Patch Changes\n\n- Build server without removing `sveltekit` Vite plugin ([#5839](https://github.com/sveltejs/kit/pull/5839))\n\n## 1.0.0-next.403\n\n### Patch Changes\n\n- chore: upgrade to Undici 5.8.1 ([#5804](https://github.com/sveltejs/kit/pull/5804))\n\n## 1.0.0-next.402\n\n### Patch Changes\n\n- fix: Import analysis doesn't get stuck in an infinite loop when encountering cyclical imports ([#5794](https://github.com/sveltejs/kit/pull/5794))\n\n## 1.0.0-next.401\n\n### Patch Changes\n\n- fix: chdir to user's application directory before running postinstall sync ([#5771](https://github.com/sveltejs/kit/pull/5771))\n\n## 1.0.0-next.400\n\n### Patch Changes\n\n- More robust path aliasing ([#5582](https://github.com/sveltejs/kit/pull/5582))\n\n## 1.0.0-next.399\n\n### Patch Changes\n\n- Use @sveltejs/kit postinstall lifecycle hook to invoke 'svelte-kit sync' instead of prepare in projects created by create-svelte ([#5760](https://github.com/sveltejs/kit/pull/5760))\n\n## 1.0.0-next.398\n\n### Patch Changes\n\n- Check url protocol to avoid mailto links navigated by kit in mobile devices ([#5726](https://github.com/sveltejs/kit/pull/5726))\n- fix: Windows correctly errors on `$env/*/private` imports and Illegal module analysis in dev ignores non-js|ts|svelte files ([#5739](https://github.com/sveltejs/kit/pull/5739))\n- feat: include reference to `@sveltejs/kit` types in ambient file ([#5745](https://github.com/sveltejs/kit/pull/5745))\n\n## 1.0.0-next.397\n\n### Patch Changes\n\n- load env before importing hooks during dev ([#5728](https://github.com/sveltejs/kit/pull/5728))\n- Add DOM.Iterable to default tsconfig ([#5734](https://github.com/sveltejs/kit/pull/5734))\n\n## 1.0.0-next.396\n\n### Patch Changes\n\n- fix: Environment variable generated types ([#5719](https://github.com/sveltejs/kit/pull/5719))\n\n## 1.0.0-next.395\n\n### Patch Changes\n\n- Add `$env/static/private`, `$env/static/public`, `$env/dynamic/private` and `$env/dynamic/public` modules ([#5663](https://github.com/sveltejs/kit/pull/5663))\n\n## 1.0.0-next.394\n\n### Patch Changes\n\n- Set Vite's publicDir and correctly serve public assets earlier in pipeline ([#5686](https://github.com/sveltejs/kit/pull/5686))\n- prerender in a subprocess ([#5678](https://github.com/sveltejs/kit/pull/5678))\n\n## 1.0.0-next.393\n\n### Patch Changes\n\n- Prevent needless prop updates causing rerenders ([#5671](https://github.com/sveltejs/kit/pull/5671))\n- Support custom Vite config locations ([#5705](https://github.com/sveltejs/kit/pull/5705))\n- Prevent rerender when route state did not change ([#5654](https://github.com/sveltejs/kit/pull/5654))\n\n## 1.0.0-next.392\n\n### Patch Changes\n\n- Revert publicDir change from 1.0.0-next.387 ([#5683](https://github.com/sveltejs/kit/pull/5683))\n\n## 1.0.0-next.391\n\n### Patch Changes\n\n- breaking: replace transformPage with transformPageChunk ([#5657](https://github.com/sveltejs/kit/pull/5657))\n\n## 1.0.0-next.390\n\n### Patch Changes\n\n- fix: vite dev no longer covers errors ([#5563](https://github.com/sveltejs/kit/pull/5563))\n\n## 1.0.0-next.389\n\n### Patch Changes\n\n- Only normalise internal URLs ([#5645](https://github.com/sveltejs/kit/pull/5645))\n\n## 1.0.0-next.388\n\n### Patch Changes\n\n- Reset stack traces to avoid double-fix ([#5644](https://github.com/sveltejs/kit/pull/5644))\n\n## 1.0.0-next.387\n\n### Patch Changes\n\n- set Vite's `publicDir` option ([#5648](https://github.com/sveltejs/kit/pull/5648))\n- Normalize paths inside prerenderer, so they are correct inside \\$service-worker ([#5641](https://github.com/sveltejs/kit/pull/5641))\n\n## 1.0.0-next.386\n\n### Patch Changes\n\n- Ensure private cache when something is returned from getSession hook ([#5640](https://github.com/sveltejs/kit/pull/5640))\n- fix: transform link[rel=icon] to be absolute to avoid console error when navigating ([#5583](https://github.com/sveltejs/kit/pull/5583))\n\n## 1.0.0-next.385\n\n### Patch Changes\n\n- Make 404 error more helpful if paths.base is missing ([#5622](https://github.com/sveltejs/kit/pull/5622))\n- fix: decode parameters on client ([`d02f1f25`](https://github.com/sveltejs/kit/commit/d02f1f25ac8acb29e21a06b94418c333928fb9bb))\n- Add config.kit.prerender.origin ([#5627](https://github.com/sveltejs/kit/pull/5627))\n\n## 1.0.0-next.384\n\n### Patch Changes\n\n- Respect custom Vite mode in SSR build ([#5602](https://github.com/sveltejs/kit/pull/5602))\n- breaking: remove mode, prod and server from \\$app/env ([#5602](https://github.com/sveltejs/kit/pull/5602))\n\n## 1.0.0-next.383\n\n### Patch Changes\n\n- Add formData method in superclass rather than monkey-patch ([#5629](https://github.com/sveltejs/kit/pull/5629))\n\n## 1.0.0-next.382\n\n### Patch Changes\n\n- fix: change Vite's output directory from `_app` to client ([#5620](https://github.com/sveltejs/kit/pull/5620))\n\n## 1.0.0-next.381\n\n### Patch Changes\n\n- Handle errors in Node streams ([#5616](https://github.com/sveltejs/kit/pull/5616))\n\n## 1.0.0-next.380\n\n### Patch Changes\n\n- Handle circular dependencies in dynamic imports ([#5619](https://github.com/sveltejs/kit/pull/5619))\n- fix: handle binary data when prerendering ([#5497](https://github.com/sveltejs/kit/pull/5497))\n- breaking: remove writeStatic to align with Vite ([#5618](https://github.com/sveltejs/kit/pull/5618))\n- Reset navigating store upon return to site with a bfcache hit ([#5613](https://github.com/sveltejs/kit/pull/5613))\n\n## 1.0.0-next.379\n\n### Patch Changes\n\n- Use define instead of import.meta.env.VITE_SVELTEKIT_FOO for internal values ([#5594](https://github.com/sveltejs/kit/pull/5594))\n\n## 1.0.0-next.378\n\n### Patch Changes\n\n- Pause Node streams as necessary when converting to ReadableStream ([#5587](https://github.com/sveltejs/kit/pull/5587))\n- improve vite version check to work with custom resolutions, eg. pnpm overrides ([#5586](https://github.com/sveltejs/kit/pull/5586))\n\n## 1.0.0-next.377\n\n### Patch Changes\n\n- breaking: Endpoint method names uppercased to match HTTP specifications ([#5513](https://github.com/sveltejs/kit/pull/5513))\n\n## 1.0.0-next.376\n\n### Patch Changes\n\n- fix: ensure completed_build is reset ([#5541](https://github.com/sveltejs/kit/pull/5541))\n\n## 1.0.0-next.375\n\n### Patch Changes\n\n- fix: don't try adapting if build failed ([#5536](https://github.com/sveltejs/kit/pull/5536))\n- Render generic error page if `__layout` returns error while rendering full error page ([#4665](https://github.com/sveltejs/kit/pull/4665))\n\n## 1.0.0-next.374\n\n### Patch Changes\n\n- removed `vite` key from config definition ([#5530](https://github.com/sveltejs/kit/pull/5530))\n- Render page with correct status code when non-get endpoint returns validation error ([#4328](https://github.com/sveltejs/kit/pull/4328))\n\n## 1.0.0-next.373\n\n### Patch Changes\n\n- breaking: require vite 3 ([#5005](https://github.com/sveltejs/kit/pull/5005))\n\n## 1.0.0-next.372\n\n### Patch Changes\n\n- ignore invalid accept header values instead of throwing an error ([#5502](https://github.com/sveltejs/kit/pull/5502))\n- support CSP report-only mode ([#5496](https://github.com/sveltejs/kit/pull/5496))\n\n## 1.0.0-next.371\n\n### Patch Changes\n\n- Pin vite-plugin-svelte to 1.0.0-next.49 ([#5498](https://github.com/sveltejs/kit/pull/5498))\n\n## 1.0.0-next.370\n\n### Patch Changes\n\n- Don't automatically buffer request bodies ([#5442](https://github.com/sveltejs/kit/pull/5442))\n\n## 1.0.0-next.369\n\n### Patch Changes\n\n- skip closeBundle hook during dev to prevent errors on restart ([#5466](https://github.com/sveltejs/kit/pull/5466))\n- Normalize paths on prefetch (fixes [#5457](https://github.com/sveltejs/kit/issues/5457)) ([#5458](https://github.com/sveltejs/kit/pull/5458))\n- clearer error on bad matcher names ([#5460](https://github.com/sveltejs/kit/pull/5460))\n\n## 1.0.0-next.368\n\n### Patch Changes\n\n- fix: adapt in closeBundle ([#5439](https://github.com/sveltejs/kit/pull/5439))\n\n## 1.0.0-next.367\n\n### Patch Changes\n\n- fix: allow Vite plugins to output mutable assets ([#5416](https://github.com/sveltejs/kit/pull/5416))\n\n## 1.0.0-next.366\n\n### Patch Changes\n\n- reset selection in setTimeout after navigating, to ensure correct behaviour in Firefox ([#5058](https://github.com/sveltejs/kit/pull/5058))\n\n## 1.0.0-next.365\n\n### Patch Changes\n\n- Serve static assets before routes in dev, but only if in an allowed directory ([#5070](https://github.com/sveltejs/kit/pull/5070))\n- breaking: Allow %-encoded filenames ([#5056](https://github.com/sveltejs/kit/pull/5056))\n\n## 1.0.0-next.364\n\n### Patch Changes\n\n- breaking: Use Vite defaults for port and strictPort ([#5392](https://github.com/sveltejs/kit/pull/5392))\n- Use anonymous function in service worker init script to support legacy browsers ([#5417](https://github.com/sveltejs/kit/pull/5417))\n\n## 1.0.0-next.363\n\n### Patch Changes\n\n- chore: upgrade TypeScript to 4.7.4 ([#5414](https://github.com/sveltejs/kit/pull/5414))\n\n## 1.0.0-next.362\n\n### Patch Changes\n\n- Updated undici to fix #5383 ([#5420](https://github.com/sveltejs/kit/pull/5420))\n\n## 1.0.0-next.361\n\n### Patch Changes\n\n- breaking: require Node 16.9 ([#5395](https://github.com/sveltejs/kit/pull/5395))\n- remove FLoC protection, now that we vanquished Google ([#5018](https://github.com/sveltejs/kit/pull/5018))\n- Prevent `Connection` header from being incorrectly inherited by requests made from `load`'s `fetch` during SSR ([#5393](https://github.com/sveltejs/kit/pull/5393))\n- Returns errors from page endpoints as JSON where appropriate ([#5314](https://github.com/sveltejs/kit/pull/5314))\n- Allow body to be a binary ReadableStream ([#5407](https://github.com/sveltejs/kit/pull/5407))\n\n## 1.0.0-next.360\n\n### Patch Changes\n\n- fix: support conditional Vite configs ([#5376](https://github.com/sveltejs/kit/pull/5376))\n- Allow server restart when config changed ([#5379](https://github.com/sveltejs/kit/pull/5379))\n- Include dynamically imported styles during SSR ([#5138](https://github.com/sveltejs/kit/pull/5138))\n\n## 1.0.0-next.359\n\n### Patch Changes\n\n- Adjust type imports to satisfy TS NodeNext moduleResolution ([#5360](https://github.com/sveltejs/kit/pull/5360))\n- breaking: require vite.config.js ([#5332](https://github.com/sveltejs/kit/pull/5332))\n- breaking: graduate @sveltejs/kit/vite from experimental ([#5332](https://github.com/sveltejs/kit/pull/5332))\n- breaking: switch to vite CLI for dev, build, and preview commands ([#5332](https://github.com/sveltejs/kit/pull/5332))\n\n## 1.0.0-next.358\n\n### Patch Changes\n\n- Only exit process in closeBundle hook if prerender is enabled ([#5356](https://github.com/sveltejs/kit/pull/5356))\n- fix: don't log warning if root is configured ([#5330](https://github.com/sveltejs/kit/pull/5330))\n\n## 1.0.0-next.357\n\n### Patch Changes\n\n- breaking: change endpointExtensions to moduleExtensions, and use to filter param matchers ([#5085](https://github.com/sveltejs/kit/pull/5085))\n- fix server crash when accessing a malformed URI ([#5246](https://github.com/sveltejs/kit/pull/5246))\n\n## 1.0.0-next.356\n\n### Patch Changes\n\n- Stream request bodies ([#5291](https://github.com/sveltejs/kit/pull/5291))\n- Enable multipart formdata parsing with node-fetch ([#5292](https://github.com/sveltejs/kit/pull/5292))\n- fix: allow user to set dev port ([#5303](https://github.com/sveltejs/kit/pull/5303))\n- breaking: use undici instead of node-fetch ([#5117](https://github.com/sveltejs/kit/pull/5117))\n\n## 1.0.0-next.355\n\n### Patch Changes\n\n- chore: Prerendering URL is now a subclass instead of a proxy ([#5278](https://github.com/sveltejs/kit/pull/5278))\n- fix: support vite.config.js on Windows ([#5265](https://github.com/sveltejs/kit/pull/5265))\n- Allow both string and URL as the first argument of `$app/navigation#goto` ([#5282](https://github.com/sveltejs/kit/pull/5282))\n- rename `goto(href)` to `goto(url)` ([#5286](https://github.com/sveltejs/kit/pull/5286))\n- Add types for @sveltejs/kit/experimental/vite ([#5266](https://github.com/sveltejs/kit/pull/5266))\n- fix: port flag doesn't work in preview ([#5284](https://github.com/sveltejs/kit/pull/5284))\n\n## 1.0.0-next.354\n\n### Patch Changes\n\n- Added `server` and `prod` env variables ([#5251](https://github.com/sveltejs/kit/pull/5251))\n\n## 1.0.0-next.353\n\n### Patch Changes\n\n- Expose Vite plugin as @sveltejs/kit/experimental/vite ([#5094](https://github.com/sveltejs/kit/pull/5094))\n\n## 1.0.0-next.352\n\n### Patch Changes\n\n- fix manifest not updating when adding routes ([#5157](https://github.com/sveltejs/kit/pull/5157))\n\n## 1.0.0-next.351\n\n### Patch Changes\n\n- fix: URL instance methods now work in `load` ([#5183](https://github.com/sveltejs/kit/pull/5183))\n- Upgrade vite-plugin-svelte ([`4e4625ea`](https://github.com/sveltejs/kit/commit/4e4625ea6d9a084bc767ae216704aacd95fe8730))\n\n## 1.0.0-next.350\n\n### Patch Changes\n\n- breaking: revert removal of `kit.browser.hydrate` ([#5178](https://github.com/sveltejs/kit/pull/5178))\n\n## 1.0.0-next.349\n\n### Patch Changes\n\n- breaking: remove kit.browser.hydrate config in favor of compilerOptions.hydratable ([#5155](https://github.com/sveltejs/kit/pull/5155))\n- chore: upgrade to Vite 2.9.10 ([#5170](https://github.com/sveltejs/kit/pull/5170))\n\n## 1.0.0-next.348\n\n### Patch Changes\n\n- Disallow access to `__data.json` for standalone endpoints ([#5149](https://github.com/sveltejs/kit/pull/5149))\n- chore: introduce `KitConfig` type ([#5141](https://github.com/sveltejs/kit/pull/5141))\n- Prevent incorrect redirect for `__data.json` request with `trailingSlash: 'always'` ([#5149](https://github.com/sveltejs/kit/pull/5149))\n\n## 1.0.0-next.347\n\n### Patch Changes\n\n- Update dependencies ([#5121](https://github.com/sveltejs/kit/pull/5121))\n- allow symlinked static assets in dev ([#5089](https://github.com/sveltejs/kit/pull/5089))\n\n## 1.0.0-next.346\n\n### Patch Changes\n\n- chore: provide Vite config via plugin ([#5073](https://github.com/sveltejs/kit/pull/5073))\n- Reload page to recover from HMR errors ([#5108](https://github.com/sveltejs/kit/pull/5108))\n- chore: shared Vite build config ([#5105](https://github.com/sveltejs/kit/pull/5105))\n- fix `BodyValidator` handling for nested object literals ([#5118](https://github.com/sveltejs/kit/pull/5118))\n- fix: don't set `credentials` to `undefined` in server-side `fetch` ([#5116](https://github.com/sveltejs/kit/pull/5116))\n\n## 1.0.0-next.345\n\n### Patch Changes\n\n- Prevent component double mounting caused by HMR invalidation ([#4891](https://github.com/sveltejs/kit/pull/4891))\n- Only recreate manifest when files inside `config.kit.files.routes` are added or deleted ([#5076](https://github.com/sveltejs/kit/pull/5076))\n\n## 1.0.0-next.344\n\n### Patch Changes\n\n- fix: svelte-kit sync no longer permanently deletes the types directory ([#5063](https://github.com/sveltejs/kit/pull/5063))\n- chore: trigger sync and other setup from plugin ([#5067](https://github.com/sveltejs/kit/pull/5067))\n- Update `engines` to specify that Node 16.7 is required ([#5062](https://github.com/sveltejs/kit/pull/5062))\n- only serve `_app/immutable` with immutable cache header, not `_app/version.json` ([#5051](https://github.com/sveltejs/kit/pull/5051))\n\n## 1.0.0-next.343\n\n### Patch Changes\n\n- chore: return config from server start methods ([#5043](https://github.com/sveltejs/kit/pull/5043))\n\n## 1.0.0-next.342\n\n### Patch Changes\n\n- ensure static assets are only served if correct case is used ([#5047](https://github.com/sveltejs/kit/pull/5047))\n- breaking: stop suppressing `/favicon.ico` requests, handle them as a valid route ([#5046](https://github.com/sveltejs/kit/pull/5046))\n- don't warn about window.fetch during hydration ([#5041](https://github.com/sveltejs/kit/pull/5041))\n\n## 1.0.0-next.341\n\n### Patch Changes\n\n- fix: page store correct after navigation when an identical route with a different hash had been prefetched ([#5039](https://github.com/sveltejs/kit/pull/5039))\n- breaking: replace @sveltejs/kit/install-fetch with @sveltejs/kit/node/polyfills ([#4934](https://github.com/sveltejs/kit/pull/4934))\n- fix: Prerendered pages fail if they access session. ([#4811](https://github.com/sveltejs/kit/pull/4811))\n\n## 1.0.0-next.340\n\n### Patch Changes\n\n- feat: Pages marked for prerendering fail during ssr at runtime ([#4812](https://github.com/sveltejs/kit/pull/4812))\n- Throw load validation errors so that they are caught by handleError ([#4953](https://github.com/sveltejs/kit/pull/4953))\n- Allow symlinked directories in the routes folder ([#4957](https://github.com/sveltejs/kit/pull/4957))\n- breaking: Rename LoadInput to LoadEvent ([#5015](https://github.com/sveltejs/kit/pull/5015))\n- allow disableScrollHandling to be called in afterNavigate ([#4948](https://github.com/sveltejs/kit/pull/4948))\n- Add `config.kit.alias` ([#4964](https://github.com/sveltejs/kit/pull/4964))\n- use namespace import for vite to support upcoming vite 3.0 esm ([#5030](https://github.com/sveltejs/kit/pull/5030))\n\n## 1.0.0-next.339\n\n### Patch Changes\n\n- breaking: resolve relative urls from the target page when using load's fetch ([#5025](https://github.com/sveltejs/kit/pull/5025))\n- fix: `svelte-kit sync` gracefully handles a nonexistent routes folder ([#5020](https://github.com/sveltejs/kit/pull/5020))\n- breaking: Replace `%svelte.body%` with `%sveltekit.body%`, etc. ([#5016](https://github.com/sveltejs/kit/pull/5016))\n\n## 1.0.0-next.338\n\n### Patch Changes\n\n- breaking: remove amp config option in favour of amp.transform helper function ([#4710](https://github.com/sveltejs/kit/pull/4710))\n- breaking: accessing url.hash from load now results in a helpful error ([#4983](https://github.com/sveltejs/kit/pull/4983))\n\n## 1.0.0-next.337\n\n### Patch Changes\n\n- fix: don't watch `outDir`, except for the `generated` directory ([#4997](https://github.com/sveltejs/kit/pull/4997))\n- Warn if load uses window.fetch ([#4958](https://github.com/sveltejs/kit/pull/4958))\n- Only run `viteServeStaticMiddleware` after server has attempted response ([#4974](https://github.com/sveltejs/kit/pull/4974))\n\n## 1.0.0-next.336\n\n### Patch Changes\n\n- Pass config to vite-plugin-svelte instead of reloading it ([#4760](https://github.com/sveltejs/kit/pull/4760))\n- fix FOUC regression during dev ([#4990](https://github.com/sveltejs/kit/pull/4990))\n- move `RequestEvent` and `ResolveOptions` as public types ([#4809](https://github.com/sveltejs/kit/pull/4809))\n- breaking: write generated types to `__types` directories ([#4705](https://github.com/sveltejs/kit/pull/4705))\n\n## 1.0.0-next.335\n\n### Patch Changes\n\n- breaking: change data-hydrate to data-sveltekit-hydrate ([#4972](https://github.com/sveltejs/kit/pull/4972))\n- Fix default port override ([#4970](https://github.com/sveltejs/kit/pull/4970))\n\n## 1.0.0-next.334\n\n### Patch Changes\n\n- fix: deduplicate injected css during dev ([#4920](https://github.com/sveltejs/kit/pull/4920))\n\n## 1.0.0-next.333\n\n### Patch Changes\n\n- breaking: delay automatic service worker registration until load event ([#4950](https://github.com/sveltejs/kit/pull/4950))\n\n## 1.0.0-next.332\n\n### Patch Changes\n\n- Revert dev command default options ([#4949](https://github.com/sveltejs/kit/pull/4949))\n\n## 1.0.0-next.331\n\n### Patch Changes\n\n- fix `BodyValidator` for nested interfaces ([#4939](https://github.com/sveltejs/kit/pull/4939))\n- breaking: drop Node 14 support ([#4922](https://github.com/sveltejs/kit/pull/4922))\n- only skip files that were already written when prerendering ([#4928](https://github.com/sveltejs/kit/pull/4928))\n- Set default options for dev command ([#4932](https://github.com/sveltejs/kit/pull/4932))\n\n## 1.0.0-next.330\n\n### Patch Changes\n\n- Fix Safari scroll bug on ssr:false page reload ([#4846](https://github.com/sveltejs/kit/pull/4846))\n\n## 1.0.0-next.329\n\n### Patch Changes\n\n- fix: stop flash of unstyled content when using CSS flavours ([#4882](https://github.com/sveltejs/kit/pull/4882))\n- delegate `RequestHandler` generics `Body` validation ([#4897](https://github.com/sveltejs/kit/pull/4897))\n- feat: more specific types for `kit.prerender.entries` config ([#4880](https://github.com/sveltejs/kit/pull/4880))\n- Prevent unhandled rejections when loading page modules ([#4732](https://github.com/sveltejs/kit/pull/4732))\n\n## 1.0.0-next.328\n\n### Patch Changes\n\n- Print useful 404 response when requesting unprefixed path in preview ([#4751](https://github.com/sveltejs/kit/pull/4751))\n- Prevent naive path normalization during prerendering ([#4761](https://github.com/sveltejs/kit/pull/4761))\n\n## 1.0.0-next.327\n\n### Patch Changes\n\n- generate tsconfig when running svelte-kit package ([#4824](https://github.com/sveltejs/kit/pull/4824))\n\n## 1.0.0-next.326\n\n### Patch Changes\n\n- breaking: add lib, module, and target to generated tsconfig ([#4791](https://github.com/sveltejs/kit/pull/4791))\n\n## 1.0.0-next.325\n\n### Patch Changes\n\n- Display network logs in node 18 ([#4778](https://github.com/sveltejs/kit/pull/4778))\n\n## 1.0.0-next.324\n\n### Patch Changes\n\n- Throw errors on encountering named layout in directory ([#4756](https://github.com/sveltejs/kit/pull/4756))\n\n## 1.0.0-next.323\n\n### Patch Changes\n\n- Default to target: node14.8, so that top-level await is supported in user code ([#4742](https://github.com/sveltejs/kit/pull/4742))\n- Only complain about missing \\$lib paths in tsconfig if src/lib exists ([#4735](https://github.com/sveltejs/kit/pull/4735))\n- Include all assets in `$service-worker` build, not just CSS ([#4744](https://github.com/sveltejs/kit/pull/4744))\n\n## 1.0.0-next.322\n\n### Patch Changes\n\n- Copy dotfiles from .svelte-kit/output ([#4725](https://github.com/sveltejs/kit/pull/4725))\n- breaking: Ignore `trailingSlash` for endpoint requests, apply `trailingSlash` to pages consistently ([#4699](https://github.com/sveltejs/kit/pull/4699))\n\n## 1.0.0-next.321\n\n### Patch Changes\n\n- Tweak error message for non-validating base paths ([#4713](https://github.com/sveltejs/kit/pull/4713))\n- breaking: Supplying an empty `--host` option to `preview` exposes the server to both ipv4 and ipv6 networks ([#4729](https://github.com/sveltejs/kit/pull/4729))\n- throw error on encountering infinite layout loop ([#4730](https://github.com/sveltejs/kit/pull/4730))\n\n## 1.0.0-next.320\n\n### Patch Changes\n\n- breaking: Replace `maxage` with `cache` in `LoadOutput` ([#4690](https://github.com/sveltejs/kit/pull/4690))\n\n## 1.0.0-next.319\n\n### Patch Changes\n\n- Add --watch flag to svelte-kit package ([#4658](https://github.com/sveltejs/kit/pull/4658))\n\n## 1.0.0-next.318\n\n### Patch Changes\n\n- fix broken AdapterEntry type ([#4674](https://github.com/sveltejs/kit/pull/4674))\n\n## 1.0.0-next.317\n\n### Patch Changes\n\n- Navigation to current URL is no longer a no-op ([#4664](https://github.com/sveltejs/kit/pull/4664))\n- builder.createEntries returns a promise that awaits complete() callbacks ([#4663](https://github.com/sveltejs/kit/pull/4663))\n- navigation store resets to null after aborted nav ([#4664](https://github.com/sveltejs/kit/pull/4664))\n\n## 1.0.0-next.316\n\n### Patch Changes\n\n- `invalidate` with `predicate` function ([#4636](https://github.com/sveltejs/kit/pull/4636))\n\n## 1.0.0-next.315\n\n### Patch Changes\n\n- Apply set-cookie headers from page dependencies ([#4588](https://github.com/sveltejs/kit/pull/4588))\n- Include disallowed method name in 405 response, include Allow header ([#4614](https://github.com/sveltejs/kit/pull/4614))\n- apply updated `props.page` when update or goto page ([#4392](https://github.com/sveltejs/kit/pull/4392))\n- rename `data-svelte` attribute to `data-sveltekit` ([#4641](https://github.com/sveltejs/kit/pull/4641))\n\n## 1.0.0-next.314\n\n### Patch Changes\n\n- Custom `load` `dependencies` in `LoadOutput` ([#4536](https://github.com/sveltejs/kit/pull/4536))\n- Made LoadInput and LoadOutput types public, merged ErrorLoad and Load declarations ([#4515](https://github.com/sveltejs/kit/pull/4515))\n\n## 1.0.0-next.313\n\n### Patch Changes\n\n- add `platform` to requests triggered by `fetch` in `load` during SSR ([#4599](https://github.com/sveltejs/kit/pull/4599))\n\n## 1.0.0-next.312\n\n### Patch Changes\n\n- Only render fallback when prerendering is enabled ([#4604](https://github.com/sveltejs/kit/pull/4604))\n\n## 1.0.0-next.311\n\n### Patch Changes\n\n- Skip client-side navigation for links with sveltekit:reload ([#4545](https://github.com/sveltejs/kit/pull/4545))\n- breaking: Skip prerendering for rel=\"external\" links ([#4545](https://github.com/sveltejs/kit/pull/4545))\n\n## 1.0.0-next.310\n\n### Patch Changes\n\n- Remove credentials when creating request object in server-side fetch ([#4548](https://github.com/sveltejs/kit/pull/4548))\n\n## 1.0.0-next.309\n\n### Patch Changes\n\n- Fix session store subscription tracking during SSR ([#4550](https://github.com/sveltejs/kit/pull/4550))\n\n## 1.0.0-next.308\n\n### Patch Changes\n\n- Remove `static` directory from Vite's control ([#4535](https://github.com/sveltejs/kit/pull/4535))\n\n## 1.0.0-next.307\n\n### Patch Changes\n\n- Allow index files to use named layouts ([#4527](https://github.com/sveltejs/kit/pull/4527))\n- Respect ssr option when rendering 404 page ([#4513](https://github.com/sveltejs/kit/pull/4513))\n- Remove unimplemented option from CLI ([#4507](https://github.com/sveltejs/kit/pull/4507))\n- Move MaybePromise from RequestHandlerOutput to RequestHandler return value ([#4519](https://github.com/sveltejs/kit/pull/4519))\n\n## 1.0.0-next.306\n\n### Patch Changes\n\n- Hint if `paths.base` is missing in dev ([#4510](https://github.com/sveltejs/kit/pull/4510))\n- Respect `paths.base` when using `--open` ([#4510](https://github.com/sveltejs/kit/pull/4510))\n- breaking: Add named layouts, remove `__layout.reset` ([#4388](https://github.com/sveltejs/kit/pull/4388))\n\n## 1.0.0-next.305\n\n### Patch Changes\n\n- Generate correct types for routes with parameter matchers ([#4472](https://github.com/sveltejs/kit/pull/4472))\n\n## 1.0.0-next.304\n\n### Patch Changes\n\n- Upgrade to Vite 2.9 ([#4468](https://github.com/sveltejs/kit/pull/4468))\n- allow files and directories named `__tests__` and `__test__` in the routes directory ([#4438](https://github.com/sveltejs/kit/pull/4438))\n- Create fallback page when prerendering is disabled ([#4443](https://github.com/sveltejs/kit/pull/4443))\n\n## 1.0.0-next.303\n\n### Patch Changes\n\n- fix: don't use client-side navigation when clicking on a link to the same path on a different origin ([#4433](https://github.com/sveltejs/kit/pull/4433))\n\n## 1.0.0-next.302\n\n### Patch Changes\n\n- fix: don't redirect to external URLs when normalizing paths ([#4414](https://github.com/sveltejs/kit/pull/4414))\n- Fix error link for fallthrough replacement ([#4408](https://github.com/sveltejs/kit/pull/4408))\n\n## 1.0.0-next.301\n\n### Patch Changes\n\n- Skip svelte-kit sync if no config file exists yet ([#4372](https://github.com/sveltejs/kit/pull/4372))\n\n## 1.0.0-next.300\n\n### Patch Changes\n\n- fix: correctly populate `event.url.host` in dev mode when using `--https` ([#4364](https://github.com/sveltejs/kit/pull/4364))\n- fix rest param type generation ([#4361](https://github.com/sveltejs/kit/pull/4361))\n- breaking: Rename validators to matchers ([#4358](https://github.com/sveltejs/kit/pull/4358))\n\n## 1.0.0-next.299\n\n### Patch Changes\n\n- Populate fallback page when trailingSlash is \"always\" ([#4351](https://github.com/sveltejs/kit/pull/4351))\n- Expose `event.routeId` and `page.routeId` ([#4345](https://github.com/sveltejs/kit/pull/4345))\n- breaking: remove fallthrough routes ([#4330](https://github.com/sveltejs/kit/pull/4330))\n- Add param validators ([#4334](https://github.com/sveltejs/kit/pull/4334))\n- breaking: disallow \\$ character in dynamic parameters ([#4334](https://github.com/sveltejs/kit/pull/4334))\n- Populate event.params before calling handle ([#4344](https://github.com/sveltejs/kit/pull/4344))\n\n## 1.0.0-next.298\n\n### Patch Changes\n\n- fix: correctly detect removal of route ([#4333](https://github.com/sveltejs/kit/pull/4333))\n\n## 1.0.0-next.297\n\n### Patch Changes\n\n- breaking: allow `InputProps` and `OutputProps` to be typed separately in generated `Load` ([#4305](https://github.com/sveltejs/kit/pull/4305))\n- allow `Output` to be typed in generated `RequestHandler` ([#4305](https://github.com/sveltejs/kit/pull/4305))\n- breaking: require adapters to supply a getClientAddress function ([#4289](https://github.com/sveltejs/kit/pull/4289))\n- Allow page endpoint without GET handler ([#4318](https://github.com/sveltejs/kit/pull/4318))\n- Return 404 when fetching missing data during prerender ([#4324](https://github.com/sveltejs/kit/pull/4324))\n- expose client IP address as event.clientAddress ([#4289](https://github.com/sveltejs/kit/pull/4289))\n\n## 1.0.0-next.296\n\n### Patch Changes\n\n- Allow adapter.adapt to be synchronous ([#4299](https://github.com/sveltejs/kit/pull/4299))\n- Make `manifest.mimeTypes` part of the public API ([#4302](https://github.com/sveltejs/kit/pull/4302))\n- load hooks after server initialisation, to ensure `prerendering` is correct ([#4322](https://github.com/sveltejs/kit/pull/4322))\n\n## 1.0.0-next.295\n\n### Patch Changes\n\n- fix error message for invalid request object ([#4277](https://github.com/sveltejs/kit/pull/4277))\n- Handle explicit redirects from endpoints ([#4260](https://github.com/sveltejs/kit/pull/4260))\n- Allow routes with the same name as fallback components ([#4284](https://github.com/sveltejs/kit/pull/4284))\n\n## 1.0.0-next.294\n\n### Patch Changes\n\n- breaking: Replace timestamp in \\$service-worker with version ([#4213](https://github.com/sveltejs/kit/pull/4213))\n- Remove declared `$lib` module ([#4227](https://github.com/sveltejs/kit/pull/4227))\n\n## 1.0.0-next.293\n\n### Patch Changes\n\n- Expose Server and SSRManifest as public types ([#4220](https://github.com/sveltejs/kit/pull/4220))\n- fetch `version.json` relative to `paths.assets`, if set ([#4234](https://github.com/sveltejs/kit/pull/4234))\n\n## 1.0.0-next.292\n\n### Patch Changes\n\n- Prevent Vite from copying static assets if directory is called \"public\" ([#4214](https://github.com/sveltejs/kit/pull/4214))\n- Add sync CLI command ([#4182](https://github.com/sveltejs/kit/pull/4182))\n- breaking: expose entire config to adapters, rather than just appDir and trailingSlash ([#4192](https://github.com/sveltejs/kit/pull/4192))\n- breaking: replace builder.prerender() with builder.writePrerendered() and builder.prerendered ([#4192](https://github.com/sveltejs/kit/pull/4192))\n- breaking: prerender pages during build, regardless of adapter ([#4192](https://github.com/sveltejs/kit/pull/4192))\n- Add config.kit.prerender.default option ([#4192](https://github.com/sveltejs/kit/pull/4192))\n- Ensure props are loaded from matching endpoint during client-side navigation ([#4203](https://github.com/sveltejs/kit/pull/4203))\n- Use prerendered pages in svelte-kit preview ([#4192](https://github.com/sveltejs/kit/pull/4192))\n- Upgrade to TypeScript 4.6 ([#4190](https://github.com/sveltejs/kit/pull/4190))\n- Fix `svelte-kit preview` ([#4207](https://github.com/sveltejs/kit/pull/4207))\n- Make prerendered paths available to service workers ([#4192](https://github.com/sveltejs/kit/pull/4192))\n- Update history immediately before updating DOM ([#4191](https://github.com/sveltejs/kit/pull/4191))\n- Add config.kit.endpointExtensions option ([#4197](https://github.com/sveltejs/kit/pull/4197))\n\n## 1.0.0-next.291\n\n### Patch Changes\n\n- Focus on `body` instead of `html` on navigation due to issues on Firefox ([#4184](https://github.com/sveltejs/kit/pull/4184))\n\n## 1.0.0-next.290\n\n### Patch Changes\n\n- Add config.kit.outDir ([#4176](https://github.com/sveltejs/kit/pull/4176))\n- breaking: allow `InputProps` and `OutputProps` to be typed separately in `Load` ([#4160](https://github.com/sveltejs/kit/pull/4160))\n\n## 1.0.0-next.289\n\n### Patch Changes\n\n- Only fall back to full page reload if pathname has changed ([#4116](https://github.com/sveltejs/kit/pull/4116))\n- Generate types for each page/endpoint ([#4120](https://github.com/sveltejs/kit/pull/4120))\n- Extend user tsconfig from generated .svelte-kit/tsconfig.json ([#4118](https://github.com/sveltejs/kit/pull/4118))\n\n## 1.0.0-next.288\n\n### Patch Changes\n\n- Fix XSS vulnerability on SSR pages with fetched data on `load()` ([#4128](https://github.com/sveltejs/kit/pull/4128))\n- breaking: `tabindex=\"-1\"` is no longer added to `<body>`; `<html>` only briefly receives it during navigation ([#4140](https://github.com/sveltejs/kit/pull/4140))\n- `RequestHandlerOutput` accepts body when it has or maybe is `undefined` ([#4152](https://github.com/sveltejs/kit/pull/4152))\n\n## 1.0.0-next.287\n\n### Patch Changes\n\n- breaking: Rename `__fetch_polyfill` to `installFetch`, remove fetch exports ([#4111](https://github.com/sveltejs/kit/pull/4111))\n\n## 1.0.0-next.286\n\n### Patch Changes\n\n- Prevent double-fixing of error stack traces in dev mode ([#4041](https://github.com/sveltejs/kit/pull/4041))\n- Expose Navigation type ([#4076](https://github.com/sveltejs/kit/pull/4076))\n- add new `Page` type ([#4076](https://github.com/sveltejs/kit/pull/4076))\n- breaking: separate public from private-but-documented types ([#4104](https://github.com/sveltejs/kit/pull/4104))\n\n## 1.0.0-next.285\n\n### Patch Changes\n\n- breaking: referer header sent by fetch in load matches page's referer header, not the page itself ([#4070](https://github.com/sveltejs/kit/pull/4070))\n- breaking: remove sveltekit:navigation-{start,end} events ([#4070](https://github.com/sveltejs/kit/pull/4070))\n- breaking: defer pushState until navigation occurs ([#4070](https://github.com/sveltejs/kit/pull/4070))\n\n## 1.0.0-next.284\n\n### Patch Changes\n\n- Disable meta http-equiv tags for static amp configuration ([#4073](https://github.com/sveltejs/kit/pull/4073))\n- Ignore click event if url does not have origin (e.g. `mailto:`, `tel:`) ([#4072](https://github.com/sveltejs/kit/pull/4072))\n\n## 1.0.0-next.283\n\n### Patch Changes\n\n- create `__data.json` for pathnames with trailing slashes, including `/` ([#4066](https://github.com/sveltejs/kit/pull/4066))\n\n## 1.0.0-next.282\n\n### Patch Changes\n\n- fix: remove private methods to make Safari 14.1 work ([#4054](https://github.com/sveltejs/kit/pull/4054))\n\n## 1.0.0-next.281\n\n### Patch Changes\n\n- Allow the `transformPage` resolve option to return a promise ([#4036](https://github.com/sveltejs/kit/pull/4036))\n\n## 1.0.0-next.280\n\n### Patch Changes\n\n- breaking: rename `app.render` to `server.respond` ([#4034](https://github.com/sveltejs/kit/pull/4034))\n- breaking: allow providing `Params` type argument for `RequestHandler` ([#3989](https://github.com/sveltejs/kit/pull/3989))\n\n## 1.0.0-next.279\n\n### Patch Changes\n\n- Fix escaped html attributes ([#4015](https://github.com/sveltejs/kit/pull/4015))\n\n## 1.0.0-next.278\n\n### Patch Changes\n\n- breaking: Crawl rel=\"external\" links when prerendering ([#3826](https://github.com/sveltejs/kit/pull/3826))\n\n## 1.0.0-next.277\n\n### Patch Changes\n\n- Fall back to full page reload if link href does not match route manifest ([#3969](https://github.com/sveltejs/kit/pull/3969))\n- Update page store without rerunning load when hash changes ([#3975](https://github.com/sveltejs/kit/pull/3975))\n\n## 1.0.0-next.276\n\n### Patch Changes\n\n- Track scroll position without scroll listener, and recover on reload ([#3938](https://github.com/sveltejs/kit/pull/3938))\n\n## 1.0.0-next.275\n\n### Patch Changes\n\n- Invalidate shadow endpoint data when URL changes ([#3925](https://github.com/sveltejs/kit/pull/3925))\n\n## 1.0.0-next.274\n\n### Patch Changes\n\n- Set `$page.url` to current URL in browser ([#3942](https://github.com/sveltejs/kit/pull/3942))\n\n## 1.0.0-next.273\n\n### Patch Changes\n\n- Correctly identify readable node streams ([#3941](https://github.com/sveltejs/kit/pull/3941))\n- remove 'Shadow' from error message ([#3943](https://github.com/sveltejs/kit/pull/3943))\n\n## 1.0.0-next.272\n\n### Patch Changes\n\n- Make shadow endpoint `event.url` consistent between server and client navigation ([#3780](https://github.com/sveltejs/kit/pull/3780))\n- Prevent duplicated history when navigating via hash link ([#3931](https://github.com/sveltejs/kit/pull/3931))\n\n## 1.0.0-next.271\n\n### Patch Changes\n\n- Add `transformPage` option to `resolve` ([#3914](https://github.com/sveltejs/kit/pull/3914))\n\n## 1.0.0-next.270\n\n### Patch Changes\n\n- handle HEAD requests in endpoints ([#3903](https://github.com/sveltejs/kit/pull/3903))\n- Use shadow endpoint without defining a `get` endpoint ([#3816](https://github.com/sveltejs/kit/pull/3816))\n\n## 1.0.0-next.269\n\n### Patch Changes\n\n- Ensure handleError hook is called for shadow endpoint errors ([#3879](https://github.com/sveltejs/kit/pull/3879))\n\n## 1.0.0-next.268\n\n### Patch Changes\n\n- refactor: use one escape function for json in html script body instead of two slightly different ([#3804](https://github.com/sveltejs/kit/pull/3804))\n\n## 1.0.0-next.267\n\n### Patch Changes\n\n- Set cookies when redirecting from shadow endpoint ([#3874](https://github.com/sveltejs/kit/pull/3874))\n\n## 1.0.0-next.266\n\n### Patch Changes\n\n- fix casing of `.DS_Store` in the default config for `serviceWorker` ([#3823](https://github.com/sveltejs/kit/pull/3823))\n- fix: avoid mutating response `Headers` ([#3829](https://github.com/sveltejs/kit/pull/3829))\n\n## 1.0.0-next.265\n\n### Patch Changes\n\n- breaking: remove `createIndexFiles` option, derive from `trailingSlash` instead ([#3801](https://github.com/sveltejs/kit/pull/3801))\n- Pass trailingSlash config to adapters ([#3820](https://github.com/sveltejs/kit/pull/3820))\n\n## 1.0.0-next.264\n\n### Patch Changes\n\n- fix links pointing to multi-page docs ([#3815](https://github.com/sveltejs/kit/pull/3815))\n- upgrade to TypeScript 4.5 ([#3809](https://github.com/sveltejs/kit/pull/3809))\n\n## 1.0.0-next.263\n\n### Patch Changes\n\n- Handle numeric headers ([#3716](https://github.com/sveltejs/kit/pull/3716))\n- fix: replace broken escaping with a working version ([#3798](https://github.com/sveltejs/kit/pull/3798))\n\n## 1.0.0-next.262\n\n### Patch Changes\n\n- update to Vite 2.8 and esbuild 0.14 ([#3791](https://github.com/sveltejs/kit/pull/3791))\n\n## 1.0.0-next.261\n\n### Patch Changes\n\n- Prevent full reload when router navigates and only removes hash ([#3757](https://github.com/sveltejs/kit/pull/3757))\n- fixes shadow hydration escaping ([#3793](https://github.com/sveltejs/kit/pull/3793))\n- fixes an error with fetching shadow endpoints if they are ending with '/' ([#3740](https://github.com/sveltejs/kit/pull/3740))\n\n## 1.0.0-next.260\n\n### Patch Changes\n\n- Allow Response object to be returned without properties showing up in object constructor ([#3697](https://github.com/sveltejs/kit/pull/3697))\n- Implement shadow endpoints ([#3679](https://github.com/sveltejs/kit/pull/3679))\n\n## 1.0.0-next.259\n\n### Patch Changes\n\n- Prevent `Host` header from being incorrectly inherited by requests made from `load`'s `fetch` during SSR ([#3690](https://github.com/sveltejs/kit/pull/3690))\n\n## 1.0.0-next.258\n\n### Patch Changes\n\n- Update \\$app/stores page.stuff to use App.Stuff ([#3686](https://github.com/sveltejs/kit/pull/3686))\n\n## 1.0.0-next.257\n\n### Patch Changes\n\n- Rename JSONString type to JSONValue ([#3683](https://github.com/sveltejs/kit/pull/3683))\n- Add App namespace for app-level types ([#3670](https://github.com/sveltejs/kit/pull/3670))\n- breaking: remove target option ([#3674](https://github.com/sveltejs/kit/pull/3674))\n\n## 1.0.0-next.256\n\n### Patch Changes\n\n- fix regression in parsing HTML when crawling for pre-rendering ([#3677](https://github.com/sveltejs/kit/pull/3677))\n\n## 1.0.0-next.255\n\n### Patch Changes\n\n- fix parsing during pre-render crawl when there are HTML attributes without a value ([#3668](https://github.com/sveltejs/kit/pull/3668))\n- Correctly populate asset manifest when generating service worker ([#3673](https://github.com/sveltejs/kit/pull/3673))\n\n## 1.0.0-next.254\n\n### Patch Changes\n\n- Add version config and expose updated store ([#3412](https://github.com/sveltejs/kit/pull/3412))\n- fix: update types to match changes to Vite config handling ([#3662](https://github.com/sveltejs/kit/pull/3662))\n\n## 1.0.0-next.253\n\n### Patch Changes\n\n- Allow config.kit.vite to be an async function ([#3565](https://github.com/sveltejs/kit/pull/3565))\n- Include page request headers in server-side fetches ([#3631](https://github.com/sveltejs/kit/pull/3631))\n\n## 1.0.0-next.252\n\n### Patch Changes\n\n- remove nonexistent `url` store from `$app/stores` ambient types ([#3640](https://github.com/sveltejs/kit/pull/3640))\n\n## 1.0.0-next.251\n\n### Patch Changes\n\n- Handle non-compliant ReadableStream implementations ([#3624](https://github.com/sveltejs/kit/pull/3624))\n\n## 1.0.0-next.250\n\n### Patch Changes\n\n- breaking: move `config.kit.hydrate` and `config.kit.router` to `config.kit.browser` ([#3578](https://github.com/sveltejs/kit/pull/3578))\n- add `prerender.createIndexFiles` option ([#2632](https://github.com/sveltejs/kit/pull/2632))\n\n## 1.0.0-next.249\n\n### Patch Changes\n\n- Include service worker in manifest ([#3570](https://github.com/sveltejs/kit/pull/3570))\n- Add kit.routes config to customise public/private modules ([#3576](https://github.com/sveltejs/kit/pull/3576))\n\n## 1.0.0-next.248\n\n### Patch Changes\n\n- Decode fetched resources before checking against manifest when prerendering ([#3571](https://github.com/sveltejs/kit/pull/3571))\n- breaking: remove -H and (conflicting) -h shortcuts from CLI ([#3573](https://github.com/sveltejs/kit/pull/3573))\n\n## 1.0.0-next.247\n\n### Patch Changes\n\n- fix handling an incoming request from HTTP/2 ([#3572](https://github.com/sveltejs/kit/pull/3572))\n\n## 1.0.0-next.246\n\n### Patch Changes\n\n- `svelte-kit package` gives clearer error message when svelte2tsx and typescript are not installed ([#3562](https://github.com/sveltejs/kit/pull/3562))\n- `svelte-kit package` errors when lib directory does not exist ([#3562](https://github.com/sveltejs/kit/pull/3562))\n- chore: refactor AMP validation ([#3554](https://github.com/sveltejs/kit/pull/3554))\n\n## 1.0.0-next.245\n\n### Patch Changes\n\n- Allow adapters to pass in `platform` object ([#3429](https://github.com/sveltejs/kit/pull/3429))\n- favicon.ico is now requestable ([#3559](https://github.com/sveltejs/kit/pull/3559))\n\n## 1.0.0-next.244\n\n### Patch Changes\n\n- fix: reading from same response body twice during prerender (#3473) ([#3521](https://github.com/sveltejs/kit/pull/3521))\n- Add CSP support ([#3499](https://github.com/sveltejs/kit/pull/3499))\n- chore: remove InternalHandle ([#3541](https://github.com/sveltejs/kit/pull/3541))\n- Force Vite to use HTTP/1 in dev mode, so `dev --https` works again ([#3553](https://github.com/sveltejs/kit/pull/3553))\n\n## 1.0.0-next.243\n\n### Patch Changes\n\n- fix: hydrate real HTTP requests ([#3547](https://github.com/sveltejs/kit/pull/3547))\n\n## 1.0.0-next.242\n\n### Patch Changes\n\n- reinstate `EndpointOutput` generic ([#3537](https://github.com/sveltejs/kit/pull/3537))\n\n## 1.0.0-next.241\n\n### Patch Changes\n\n- `svelte-kit package` only encodes text files ([#3522](https://github.com/sveltejs/kit/pull/3522))\n\n## 1.0.0-next.240\n\n### Patch Changes\n\n- Error if handle hook returns something other than a Response ([#3496](https://github.com/sveltejs/kit/pull/3496))\n- allow setting multiple set-cookie headers ([#3502](https://github.com/sveltejs/kit/pull/3502))\n- fixed prerendering with base path configured ([#3500](https://github.com/sveltejs/kit/pull/3500))\n\n## 1.0.0-next.239\n\n### Patch Changes\n\n- Insert <meta http-equiv> cache-control header when prerendering ([#3493](https://github.com/sveltejs/kit/pull/3493))\n\n## 1.0.0-next.238\n\n### Patch Changes\n\n- Escape prerendered redirect locations, instead of encoding them ([#3456](https://github.com/sveltejs/kit/pull/3456))\n\n## 1.0.0-next.237\n\n### Patch Changes\n\n- Type compilerOptions as CompileOptions instead of any ([#3486](https://github.com/sveltejs/kit/pull/3486))\n\n## 1.0.0-next.236\n\n### Patch Changes\n\n- The redirect property returned from a module's load function must now be a properly encoded URI string value. ([#3404](https://github.com/sveltejs/kit/pull/3404))\n\n## 1.0.0-next.235\n\n### Patch Changes\n\n- register service worker regardless of hydrate/router option ([#3435](https://github.com/sveltejs/kit/pull/3435))\n\n## 1.0.0-next.234\n\n### Patch Changes\n\n- Allow endpoints to return a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response), or an object with [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) ([docs](https://svelte.dev/docs/kit/routing#endpoints), [#3384](https://github.com/sveltejs/kit/pull/3384))\n- breaking: Expose standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object to endpoints and hooks. `method`, `headers`, and `body` now accessed through `request` field ([docs](https://svelte.dev/docs/kit/routing#endpoints), [#3384](https://github.com/sveltejs/kit/pull/3384))\n- breaking: change `app.render` signature to (request: Request) => Promise<Response> ([#3384](https://github.com/sveltejs/kit/pull/3384))\n- breaking: move protocol/host configuration options from Kit to adapter-node ([#3384](https://github.com/sveltejs/kit/pull/3384))\n\n## 1.0.0-next.233\n\n### Patch Changes\n\n- fix: refactor navigation singletons to avoid storing undefined reference ([#3374](https://github.com/sveltejs/kit/pull/3374))\n- fix: add media=\"(max-width: 0)\" to prevent stylesheets from downloading ([#3396](https://github.com/sveltejs/kit/pull/3396))\n\n## 1.0.0-next.232\n\n### Patch Changes\n\n- Preserve explicit ETag header ([#3348](https://github.com/sveltejs/kit/pull/3348))\n- fix: ignore hash links during prerendering (again) ([#3367](https://github.com/sveltejs/kit/pull/3367))\n\n## 1.0.0-next.231\n\n### Patch Changes\n\n- Handle requests for /basepath ([#3345](https://github.com/sveltejs/kit/pull/3345))\n- Allow \\_\\_fetch_polyfill() to run several times ([#3357](https://github.com/sveltejs/kit/pull/3357))\n- Handle static assets with /basepath in svelte-kit dev ([#3346](https://github.com/sveltejs/kit/pull/3346))\n\n## 1.0.0-next.230\n\n### Patch Changes\n\n- Log errors to stderr rather than stdout ([#3328](https://github.com/sveltejs/kit/pull/3328))\n\n## 1.0.0-next.229\n\n### Patch Changes\n\n- The path to a service worker is now rebased to the app's base path ([#3319](https://github.com/sveltejs/kit/pull/3319))\n\n## 1.0.0-next.228\n\n### Patch Changes\n\n- Throw on accessing url.search/searchParams from page store during prerendering ([#3314](https://github.com/sveltejs/kit/pull/3314))\n- Preserve relevant headers when serving 304s ([#3313](https://github.com/sveltejs/kit/pull/3313))\n\n## 1.0.0-next.227\n\n### Patch Changes\n\n- Adds beforeNavigate/afterNavigate lifecycle functions ([#3293](https://github.com/sveltejs/kit/pull/3293))\n\n## 1.0.0-next.226\n\n### Patch Changes\n\n- Fix srcset parsing ([#3301](https://github.com/sveltejs/kit/pull/3301))\n- Change ReadOnlyFormData behavior to mimic the spec's FormData interface ([#3302](https://github.com/sveltejs/kit/pull/3302))\n\n## 1.0.0-next.225\n\n### Patch Changes\n\n- add inlineStyleThreshold option, below which stylesheets are inlined into the page ([#2620](https://github.com/sveltejs/kit/pull/2620))\n\n## 1.0.0-next.224\n\n### Patch Changes\n\n- More robust crawling of prerendered pages ([#3288](https://github.com/sveltejs/kit/pull/3288))\n\n## 1.0.0-next.223\n\n### Patch Changes\n\n- Add methodOverride option for submitting PUT/PATCH/DELETE/etc with <form> elements ([#2989](https://github.com/sveltejs/kit/pull/2989))\n\n## 1.0.0-next.222\n\n### Patch Changes\n\n- Remove `config.kit.ssr` and `export const ssr` in favour of `ssr` parameter for `resolve` function in `handle` ([#2804](https://github.com/sveltejs/kit/pull/2804))\n\n## 1.0.0-next.221\n\n### Patch Changes\n\n- Add returned stuff from pages into \\$page store ([#3252](https://github.com/sveltejs/kit/pull/3252))\n- Fallthrough is now explicit and layout components now also support fallthrough ([#3217](https://github.com/sveltejs/kit/pull/3217))\n\n## 1.0.0-next.220\n\n### Patch Changes\n\n- url hash is now properly reflected in page store ([#3273](https://github.com/sveltejs/kit/pull/3273))\n- Strip hash fragments from URLs during prerendering ([#3251](https://github.com/sveltejs/kit/pull/3251))\n- Allow prefixes and suffixes around rest parameters ([#3240](https://github.com/sveltejs/kit/pull/3240))\n\n## 1.0.0-next.219\n\n### Patch Changes\n\n- Render error page if error happens in handle hook ([#3239](https://github.com/sveltejs/kit/pull/3239))\n- chore: update dependency sirv to v2 ([#3263](https://github.com/sveltejs/kit/pull/3263))\n\n## 1.0.0-next.218\n\n### Patch Changes\n\n- Expose appDir to adapters ([#3222](https://github.com/sveltejs/kit/pull/3222))\n- Replace %svelte.assets% with relative path ([#3234](https://github.com/sveltejs/kit/pull/3234))\n\n## 1.0.0-next.217\n\n### Patch Changes\n\n- Improve error message when svelte.config.js is not found ([#3219](https://github.com/sveltejs/kit/pull/3219))\n- Support more text content types ([#2781](https://github.com/sveltejs/kit/pull/2781))\n\n## 1.0.0-next.216\n\n### Patch Changes\n\n- make html template optional for `svelte-kit package` ([#3161](https://github.com/sveltejs/kit/pull/3161))\n- Allow multiple different headers returned from one endpoint ([#3201](https://github.com/sveltejs/kit/pull/3201))\n\n## 1.0.0-next.215\n\n### Patch Changes\n\n- Fix hash change focus behaviour ([#3177](https://github.com/sveltejs/kit/pull/3177))\n\n## 1.0.0-next.214\n\n### Patch Changes\n\n- breaking: Add `disableScrollHandling` function (see https://svelte.dev/docs/kit/modules#$app-navigation) ([#3182](https://github.com/sveltejs/kit/pull/3182))\n\n## 1.0.0-next.213\n\n### Patch Changes\n\n- Don't register service worker if there is none ([#3170](https://github.com/sveltejs/kit/pull/3170))\n- Fix url pathname for prerenders ([#3178](https://github.com/sveltejs/kit/pull/3178))\n\n## 1.0.0-next.212\n\n### Patch Changes\n\n- Add status and error to page store ([#3096](https://github.com/sveltejs/kit/pull/3096))\n- Fix dev prebundling scanner ([#3169](https://github.com/sveltejs/kit/pull/3169))\n- Sort rest endpoints before pages ([#3168](https://github.com/sveltejs/kit/pull/3168))\n\n## 1.0.0-next.211\n\n### Patch Changes\n\n- Use Vite's filewatcher in dev mode instead of creating a new one\n\n## 1.0.0-next.210\n\n### Patch Changes\n\n- Add path/query error getters in prod mode ([#3151](https://github.com/sveltejs/kit/pull/3151))\n\n## 1.0.0-next.209\n\n### Patch Changes\n\n- Bundle SSR renderer with app ([#3144](https://github.com/sveltejs/kit/pull/3144))\n\n## 1.0.0-next.208\n\n### Patch Changes\n\n- Overhaul adapter API ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- Replace config.kit.hostHeader with config.kit.headers.host, add config.kit.headers.protocol ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- Replace page.host with page.origin ([#2931](https://github.com/sveltejs/kit/pull/2931))\n- fix: load CSS before JS preloads\n- Error if adapter provides wrong input to app.render ([#3133](https://github.com/sveltejs/kit/pull/3133))\n- Replace [request|page].[origin|path|query] with url object ([#3133](https://github.com/sveltejs/kit/pull/3133))\n\n## 1.0.0-next.207\n\n### Patch Changes\n\n- Add serviceWorker.register option ([#2988](https://github.com/sveltejs/kit/pull/2988))\n\n## 1.0.0-next.206\n\n### Patch Changes\n\n- Handle `Headers` instance in server-side `fetch` ([#3034](https://github.com/sveltejs/kit/pull/3034))\n\n## 1.0.0-next.205\n\n### Patch Changes\n\n- Add `config.kit.prerender.concurrency` setting ([#3120](https://github.com/sveltejs/kit/pull/3120))\n\n## 1.0.0-next.204\n\n### Patch Changes\n\n- fix `<Route> received an unexpected slot \"default\"` warning ([#3115](https://github.com/sveltejs/kit/pull/3115))\n\n## 1.0.0-next.203\n\n### Patch Changes\n\n- Update vite-plugin-svelte to 1.0.0-next.32 ([#3048](https://github.com/sveltejs/kit/pull/3048))\n- fix `sveltekit:prefetch` mouse detection ([#2995](https://github.com/sveltejs/kit/pull/2995))\n- Sort rest routes alphabetically ([#3093](https://github.com/sveltejs/kit/pull/3093))\n- Fix invalid amp-install-serviceworker ([#3075](https://github.com/sveltejs/kit/pull/3075))\n\n## 1.0.0-next.202\n\n### Patch Changes\n\n- fix: upgrade to Vite 2.7 ([#3018](https://github.com/sveltejs/kit/pull/3018))\n- Allow absolute file paths given to package.dir ([#3012](https://github.com/sveltejs/kit/pull/3012))\n- update to esbuild 0.13.15 and other dependency updates ([#2957](https://github.com/sveltejs/kit/pull/2957))\n\n## 1.0.0-next.201\n\n### Patch Changes\n\n- Ignore mailto: and tel: links ([#2915](https://github.com/sveltejs/kit/pull/2915))\n\n## 1.0.0-next.200\n\n### Patch Changes\n\n- Follow redirects when prerendering ([#2832](https://github.com/sveltejs/kit/pull/2832))\n- Fix types reference in exports in package.json ([#2896](https://github.com/sveltejs/kit/pull/2896))\n\n## 1.0.0-next.199\n\n### Patch Changes\n\n- fix: support etag W/ prefix ([#2709](https://github.com/sveltejs/kit/pull/2709))\n- fix: revert #2819 and add code comment ([#2883](https://github.com/sveltejs/kit/pull/2883))\n- Don't create empty dirs when packaging ([#2831](https://github.com/sveltejs/kit/pull/2831))\n- feat: Use `event.composedPath` to find anchors for prefetching and routing ([#2769](https://github.com/sveltejs/kit/pull/2769))\n\n## 1.0.0-next.198\n\n### Patch Changes\n\n- Register custom service worker for AMP ([#2265](https://github.com/sveltejs/kit/pull/2265))\n\n## 1.0.0-next.197\n\n### Patch Changes\n\n- fix: prevent text unselection for keepfocus ([#2857](https://github.com/sveltejs/kit/pull/2857))\n- fix: use defaults when no opts passed to router ([#2819](https://github.com/sveltejs/kit/pull/2819))\n\n## 1.0.0-next.196\n\n### Patch Changes\n\n- remove all selection before navigating to the next page ([#2755](https://github.com/sveltejs/kit/pull/2755))\n- fix: properly scroll if body has margin ([#2761](https://github.com/sveltejs/kit/pull/2761))\n\n## 1.0.0-next.195\n\n### Patch Changes\n\n- fix: increase scroll debounce timeout ([#2749](https://github.com/sveltejs/kit/pull/2749))\n- fix: do not set inlineDynamicImports ([#2753](https://github.com/sveltejs/kit/pull/2753))\n\n## 1.0.0-next.194\n\n### Patch Changes\n\n- fix: correct message when serving with strict:false ([#2726](https://github.com/sveltejs/kit/pull/2726))\n- fix: reset scroll when navigated from scrolled page ([#2735](https://github.com/sveltejs/kit/pull/2735))\n\n## 1.0.0-next.193\n\n### Patch Changes\n\n- fix: upgrade minor deps. fetch-blob 3.1.3 needed for Netlify deploys ([#2714](https://github.com/sveltejs/kit/pull/2714))\n- fix: scroll to elements provided via URL hash ([#2668](https://github.com/sveltejs/kit/pull/2668))\n\n## 1.0.0-next.192\n\n### Patch Changes\n\n- fix: allow overriding inlineDynamicImports ([#2702](https://github.com/sveltejs/kit/pull/2702))\n\n## 1.0.0-next.191\n\n### Patch Changes\n\n- Return the copied files from the adapter's copy\\_ utils. ([#2674](https://github.com/sveltejs/kit/pull/2674))\n- fix: avoid infinite loop if no routes found ([#2614](https://github.com/sveltejs/kit/pull/2614))\n- security: upgrade to Vite 2.6.12, specify allow list, and print warning ([#2691](https://github.com/sveltejs/kit/pull/2691))\n\n## 1.0.0-next.190\n\n### Patch Changes\n\n- fix: upgrade to Vite 2.6.11 ([#2683](https://github.com/sveltejs/kit/pull/2683))\n- Return an array of written files when prerendering. ([#2675](https://github.com/sveltejs/kit/pull/2675))\n\n## 1.0.0-next.189\n\n### Patch Changes\n\n- breaking: only route pages on the client-side ([#2656](https://github.com/sveltejs/kit/pull/2656))\n\n## 1.0.0-next.188\n\n### Patch Changes\n\n- fix: fire navigation-end event only at end of navigation ([#2649](https://github.com/sveltejs/kit/pull/2649))\n- fix: allow passing certificates via config ([#2622](https://github.com/sveltejs/kit/pull/2622))\n\n## 1.0.0-next.187\n\n### Patch Changes\n\n- Fix prerendering when paths.base but not paths.assets is specified ([#2643](https://github.com/sveltejs/kit/pull/2643))\n\n## 1.0.0-next.186\n\n### Patch Changes\n\n- chore: upgrade to Vite 2.6.10 ([#2634](https://github.com/sveltejs/kit/pull/2634))\n\n## 1.0.0-next.185\n\n### Patch Changes\n\n- Update vite-plugin-svelte to 1.0.0-next.30 ([#2626](https://github.com/sveltejs/kit/pull/2626))\n- fix: allow users to override build target ([#2618](https://github.com/sveltejs/kit/pull/2618))\n\n## 1.0.0-next.184\n\n### Patch Changes\n\n- breaking: drop Node 12 support ([#2604](https://github.com/sveltejs/kit/pull/2604))\n\n## 1.0.0-next.183\n\n### Patch Changes\n\n- fix XSS vulnerability in `page.path` and `page.params` during SSR ([#2597](https://github.com/sveltejs/kit/pull/2597))\n\n## 1.0.0-next.182\n\n### Patch Changes\n\n- fix: fixes for firing of hashchange event ([#2591](https://github.com/sveltejs/kit/pull/2591))\n\n## 1.0.0-next.181\n\n### Patch Changes\n\n- fix: improve type of `init` ([#2544](https://github.com/sveltejs/kit/pull/2544))\n- update dependencies ([#2574](https://github.com/sveltejs/kit/pull/2574))\n- fix: implement support for hashchange event ([#2590](https://github.com/sveltejs/kit/pull/2590))\n- chore: upgrade to Vite 2.6.7 ([#2586](https://github.com/sveltejs/kit/pull/2586))\n\n## 1.0.0-next.180\n\n### Patch Changes\n\n- fix: don't expose prerender options ([#2543](https://github.com/sveltejs/kit/pull/2543))\n- chore: upgrade to Vite 2.6.3\" ([#2557](https://github.com/sveltejs/kit/pull/2557))\n- upgrade commonjs plugin for better ignoreTryCatch default ([#2539](https://github.com/sveltejs/kit/pull/2539))\n\n## 1.0.0-next.179\n\n### Patch Changes\n\n- Fix escaping of URLs of endpoint responses serialized into SSR response ([#2534](https://github.com/sveltejs/kit/pull/2534))\n\n## 1.0.0-next.178\n\n### Patch Changes\n\n- fix: restore functioning of --host CLI flag with no arg ([#2525](https://github.com/sveltejs/kit/pull/2525))\n\n## 1.0.0-next.177\n\n### Patch Changes\n\n- update to vite 2.6.0 and esbuild 0.13 ([#2522](https://github.com/sveltejs/kit/pull/2522))\n- fix browser-only redirect during load. ([#2462](https://github.com/sveltejs/kit/pull/2462))\n\n## 1.0.0-next.176\n\n### Patch Changes\n\n- feat: allow using Vite's `strict.port: false` option ([#2507](https://github.com/sveltejs/kit/pull/2507))\n- fix: allow passing in https certs again' ([#2512](https://github.com/sveltejs/kit/pull/2512))\n\n## 1.0.0-next.175\n\n### Patch Changes\n\n- chore: upgrade node-fetch to 3.0.0 final ([#2422](https://github.com/sveltejs/kit/pull/2422))\n- fix: don't override application focus and scroll ([#2489](https://github.com/sveltejs/kit/pull/2489))\n\n## 1.0.0-next.174\n\n### Patch Changes\n\n- Fix script and style tags without attributes crashing svelte-kit package ([#2492](https://github.com/sveltejs/kit/pull/2492))\n\n## 1.0.0-next.173\n\n### Patch Changes\n\n- Exports and files property in config.kit.package now accepts a function rather than an object ([#2430](https://github.com/sveltejs/kit/pull/2430))\n- Renamed property exclude to files in config.kit.serviceWorker and now accepts a function instead ([#2430](https://github.com/sveltejs/kit/pull/2430))\n- Remove lang tag when packaging ([#2486](https://github.com/sveltejs/kit/pull/2486))\n\n## 1.0.0-next.172\n\n### Patch Changes\n\n- chore: upgrade to Svelte 3.43.0\" ([#2474](https://github.com/sveltejs/kit/pull/2474))\n- breaking: rename the `context` parameter of the load function to `stuff` ([#2439](https://github.com/sveltejs/kit/pull/2439))\n\n## 1.0.0-next.171\n\n### Patch Changes\n\n- Fix preview when `kit.paths.base` is set. ([#2409](https://github.com/sveltejs/kit/pull/2409))\n- Resolve \\$lib alias when packaging ([#2453](https://github.com/sveltejs/kit/pull/2453))\n\n## 1.0.0-next.170\n\n### Patch Changes\n\n- Fix prerendering/adapter-static failing when `kit.paths.base` was set. ([#2407](https://github.com/sveltejs/kit/pull/2407))\n\n## 1.0.0-next.169\n\n### Patch Changes\n\n- Add \"svelte\" field to package.json when running package command ([#2431](https://github.com/sveltejs/kit/pull/2431))\n- fix: revert #2354 and fix double character decoding a different way ([#2435](https://github.com/sveltejs/kit/pull/2435))\n- feat: use the Vite server options in dev mode ([#2232](https://github.com/sveltejs/kit/pull/2232))\n- update dependencies ([#2447](https://github.com/sveltejs/kit/pull/2447))\n\n## 1.0.0-next.168\n\n### Patch Changes\n\n- fix: encodeURI during prerender ([#2427](https://github.com/sveltejs/kit/pull/2427))\n- chore: add links to repository and homepage to package.json ([#2425](https://github.com/sveltejs/kit/pull/2425))\n\n## 1.0.0-next.167\n\n### Patch Changes\n\n- Update vite-plugin-svelte to 1.0.0-next.24 ([#2423](https://github.com/sveltejs/kit/pull/2423))\n- Add a generic argument to allow typing Body from hooks ([#2413](https://github.com/sveltejs/kit/pull/2413))\n\n## 1.0.0-next.166\n\n### Patch Changes\n\n- chore: upgrade Vite to 2.5.7\n- fix: deeply-nested error components render with correct layout ([#2389](https://github.com/sveltejs/kit/pull/2389))\n- Update vite-plugin-svelte to 1.0.0-next.23 ([#2402](https://github.com/sveltejs/kit/pull/2402))\n- fix: pass along set-cookie headers during SSR ([#2362](https://github.com/sveltejs/kit/pull/2362))\n\n## 1.0.0-next.165\n\n### Patch Changes\n\n- chore: upgrade Vite\n- breaking: rename prerender.pages config option to prerender.entries ([#2380](https://github.com/sveltejs/kit/pull/2380))\n- fix: anchor tag inside svg ([#2286](https://github.com/sveltejs/kit/pull/2286))\n\n## 1.0.0-next.164\n\n### Patch Changes\n\n- fix: error components render with correct layout client-side as well as server-side ([#2378](https://github.com/sveltejs/kit/pull/2378))\n- refactor `import.meta.env` usage in `$app/stores.js` to use `$app/env.js` to DRY code and make mocking easier ([#2353](https://github.com/sveltejs/kit/pull/2353))\n- Trim `.js` extensions in package exports field ([#2345](https://github.com/sveltejs/kit/pull/2345))\n\n## 1.0.0-next.163\n\n### Patch Changes\n\n- Update vite-plugin-svelte to 1.0.0-next.22 ([#2370](https://github.com/sveltejs/kit/pull/2370))\n- fix: load function should not leak props to other components ([#2356](https://github.com/sveltejs/kit/pull/2356))\n- packaging merge exports field by default ([#2327](https://github.com/sveltejs/kit/pull/2327))\n- fix: don't decode URL when finding matching route ([#2354](https://github.com/sveltejs/kit/pull/2354))\n\n## 1.0.0-next.162\n\n### Patch Changes\n\n- Enable nested dependency optimization by updating to @sveltejs/vite-plugin-svelte@1.0.0-next.21 ([#2343](https://github.com/sveltejs/kit/pull/2343))\n\n## 1.0.0-next.161\n\n### Patch Changes\n\n- Allow service workers to access files using the \\$lib alias ([#2326](https://github.com/sveltejs/kit/pull/2326))\n- fix: remove Vite workaround now that dev deps can be bundled ([#2340](https://github.com/sveltejs/kit/pull/2340))\n- support using arrays for kit.vite.resolve.alias ([#2328](https://github.com/sveltejs/kit/pull/2328))\n\n## 1.0.0-next.160\n\n### Patch Changes\n\n- fix: upgrade to Vite 2.5.2 to fix URL decoding ([#2323](https://github.com/sveltejs/kit/pull/2323))\n- Add `@sveltejs/kit` to `noExternal` in dev server as well ([#2332](https://github.com/sveltejs/kit/pull/2332))\n\n## 1.0.0-next.159\n\n### Patch Changes\n\n- Add `@sveltejs/kit` to noExternal to resolve hooks module in dev server ([#2306](https://github.com/sveltejs/kit/pull/2306))\n- fix: HMR on Windows ([#2315](https://github.com/sveltejs/kit/pull/2315))\n\n## 1.0.0-next.158\n\n### Patch Changes\n\n- avoid setting rawBody/body to an empty Uint8Array when a load's fetch function is called with no body during SSR ([#2295](https://github.com/sveltejs/kit/pull/2295))\n\n## 1.0.0-next.157\n\n### Patch Changes\n\n- chore: separate RequestHeaders and ResponseHeaders types ([#2248](https://github.com/sveltejs/kit/pull/2248))\n- fix: don't de-indent user-rendered HTML ([#2292](https://github.com/sveltejs/kit/pull/2292))\n\n## 1.0.0-next.156\n\n### Patch Changes\n\n- allow any top-level keys in svelte config ([#2267](https://github.com/sveltejs/kit/pull/2267))\n- Exclude emitted declarations on packaging ([#2247](https://github.com/sveltejs/kit/pull/2247))\n\n## 1.0.0-next.155\n\n### Patch Changes\n\n- chore: export App types ([#2259](https://github.com/sveltejs/kit/pull/2259))\n\n## 1.0.0-next.154\n\n### Patch Changes\n\n- Upgrade to Vite 2.5.0 ([#2231](https://github.com/sveltejs/kit/pull/2231))\n\n## 1.0.0-next.153\n\n### Patch Changes\n\n- rename serverFetch to externalFetch ([#2110](https://github.com/sveltejs/kit/pull/2110))\n\n## 1.0.0-next.152\n\n### Patch Changes\n\n- Check ports usage in a more cross-platform way in dev server error logging ([#2209](https://github.com/sveltejs/kit/pull/2209))\n- Ensure the raw body is an Uint8Array before passing it to request handlers ([#2215](https://github.com/sveltejs/kit/pull/2215))\n\n## 1.0.0-next.151\n\n### Patch Changes\n\n- fix new route discovery in dev server ([#2198](https://github.com/sveltejs/kit/pull/2198))\n\n## 1.0.0-next.150\n\n### Patch Changes\n\n- fix: match route against decoded path on client ([#2206](https://github.com/sveltejs/kit/pull/2206))\n\n## 1.0.0-next.149\n\n### Patch Changes\n\n- export `HandleError` type ([#2200](https://github.com/sveltejs/kit/pull/2200))\n- fix: match regex against route only once ([#2203](https://github.com/sveltejs/kit/pull/2203))\n\n## 1.0.0-next.148\n\n### Patch Changes\n\n- update svelte peerDependency to 3.39.0 ([#2182](https://github.com/sveltejs/kit/pull/2182))\n- Add hook to handle errors ([#2193](https://github.com/sveltejs/kit/pull/2193))\n- Use /\\_svelte_kit_assets when serving apps with specified paths.assets locally ([#2189](https://github.com/sveltejs/kit/pull/2189))\n- Serve from basepath in svelte-kit dev/preview ([#2189](https://github.com/sveltejs/kit/pull/2189))\n- Disallow non-absolute paths.assets option ([#2189](https://github.com/sveltejs/kit/pull/2189))\n- Allow `EndpointOutput` response body objects to have a `toJSON` property ([#2170](https://github.com/sveltejs/kit/pull/2170))\n\n## 1.0.0-next.147\n\n### Patch Changes\n\n- fix: handle paths consistently between dev and various production adapters ([#2171](https://github.com/sveltejs/kit/pull/2171))\n- Replace function properties by methods on type declarations ([#2158](https://github.com/sveltejs/kit/pull/2158))\n- fix: fallback should still be generated when prerender is disabled ([#2128](https://github.com/sveltejs/kit/pull/2128))\n- update vite-plugin-svelte to 1.0.0-next.16 ([#2179](https://github.com/sveltejs/kit/pull/2179))\n- Set optimizeDeps.entries to [] when building service worker ([#2180](https://github.com/sveltejs/kit/pull/2180))\n\n## 1.0.0-next.146\n\n### Patch Changes\n\n- fix: enable Vite pre-bundling except for Svelte packages ([#2137](https://github.com/sveltejs/kit/pull/2137))\n\n## 1.0.0-next.145\n\n### Patch Changes\n\n- feat: detect if app tries to access query with prerender enabled ([#2104](https://github.com/sveltejs/kit/pull/2104))\n\n## 1.0.0-next.144\n\n### Patch Changes\n\n- 241dd623: fix: point at true dev entry point\n\n## 1.0.0-next.143\n\n### Patch Changes\n\n- 8c0ffb8f: fix: provide explicit JS entry point for Vite dev mode ([#2134](https://github.com/sveltejs/kit/pull/2134))\n- c3c25ee0: fix: take into account page-level options on error pages ([#2117](https://github.com/sveltejs/kit/pull/2117))\n\n## 1.0.0-next.142\n\n### Patch Changes\n\n- aed1bd07: fix: fully initialize router before rendering ([#2089](https://github.com/sveltejs/kit/pull/2089))\n- 970bb04c: restore reverted config changes ([#2093](https://github.com/sveltejs/kit/pull/2093))\n\n## 1.0.0-next.141\n\n### Patch Changes\n\n- d109a394: fix: successfully load nested error pages ([#2076](https://github.com/sveltejs/kit/pull/2076))\n- fab67c94: fix: successfully handle client errors ([#2077](https://github.com/sveltejs/kit/pull/2077))\n- 943f5288: fix: solve regression parsing unicode URLs ([#2078](https://github.com/sveltejs/kit/pull/2078))\n- 4435a659: fix: allow endpoint shadowing to work ([#2074](https://github.com/sveltejs/kit/pull/2074))\n- ee73a265: fix: correctly do fallthrough in simple case ([#2072](https://github.com/sveltejs/kit/pull/2072))\n\n## 1.0.0-next.140\n\n### Patch Changes\n\n- e55bc44a: fix: revert change to rendering options ([#2008](https://github.com/sveltejs/kit/pull/2008))\n- d81de603: revert adapters automatically updating .gitignore ([#1924](https://github.com/sveltejs/kit/pull/1924))\n- 5911b1c7: fix: consider protocol-relative URLs as external ([#2062](https://github.com/sveltejs/kit/pull/2062))\n\n## 1.0.0-next.139\n\n### Patch Changes\n\n- 883d4b85: Add public API to let adapters update .gitignore ([#1924](https://github.com/sveltejs/kit/pull/1924))\n- 8cbe3b05: Change `force` to `onError` in prerender config options ([#2030](https://github.com/sveltejs/kit/pull/2030))\n- 1b18a844: Don't check external links on prerender ([#1679](https://github.com/sveltejs/kit/pull/1679))\n- 7645399a: fix: correctly pass Vite options in preview mode ([#2036](https://github.com/sveltejs/kit/pull/2036))\n\n## 1.0.0-next.138\n\n### Patch Changes\n\n- d6563169: chore: prefer interfaces to types ([#2010](https://github.com/sveltejs/kit/pull/2010))\n- b18a45c1: explicitly set compilerOptions.hydratable to config.kit.hydrate ([#2024](https://github.com/sveltejs/kit/pull/2024))\n- 538de3eb- feat: More powerful and configurable rendering options ([#2008](https://github.com/sveltejs/kit/pull/2008))\n- 20dad18a: Remove the `prerender.force` option in favor of `prerender.onError` ([#2007](https://github.com/sveltejs/kit/pull/2007))\n\n## 1.0.0-next.137\n\n### Patch Changes\n\n- bce1d76a: chore: improved typing for runtime and tests ([#1995](https://github.com/sveltejs/kit/pull/1995))\n- 2a1e9795: chore: enable TypeScript strict mode ([#1998](https://github.com/sveltejs/kit/pull/1998))\n\n## 1.0.0-next.136\n\n### Patch Changes\n\n- 69b92ec1: chore: improved typing on core library ([#1993](https://github.com/sveltejs/kit/pull/1993))\n\n## 1.0.0-next.135\n\n### Patch Changes\n\n- 3b293f2a: update svelte to 3.40 and vite-plugin-svelte to 1.0.0-next.14 ([#1992](https://github.com/sveltejs/kit/pull/1992))\n- 34b923d1: chore: stricter TypeScript checking ([#1989](https://github.com/sveltejs/kit/pull/1989))\n\n## 1.0.0-next.134\n\n### Patch Changes\n\n- e1e5920a: fix: correctly find links during prerendering ([#1984](https://github.com/sveltejs/kit/pull/1984))\n- c7db715e: Handle errors with incorrect type ([#1983](https://github.com/sveltejs/kit/pull/1983))\n\n## 1.0.0-next.133\n\n### Patch Changes\n\n- 68190496: chore: Vite to ^2.4.3, vite-plugin-svelte to ^1.0.0-next.13 ([#1969](https://github.com/sveltejs/kit/pull/1969))\n- 0cbcd7c3: fix: correctly detect external fetches ([#1980](https://github.com/sveltejs/kit/pull/1980))\n- 51ec789f: Scrolling to an anchor via a hash now supports `scroll-*` CSS properties ([#1972](https://github.com/sveltejs/kit/pull/1972))\n\n## 1.0.0-next.132\n\n### Patch Changes\n\n- 7b440b2b: Fix URL resolution for server-side fetch ([#1953](https://github.com/sveltejs/kit/pull/1953))\n\n## 1.0.0-next.131\n\n### Patch Changes\n\n- 0bc1b309: Minor optimization in parse_body ([#1916](https://github.com/sveltejs/kit/pull/1916))\n\n## 1.0.0-next.130\n\n### Patch Changes\n\n- 53e9285d: feat(config): Friendlier error messages for common errors ([#1910](https://github.com/sveltejs/kit/pull/1910))\n- 41da1ebe: Handle 4xx and 5xx statuses without requiring `Error` instance ([#1811](https://github.com/sveltejs/kit/pull/1811))\n- 073fc3b5: feat(cli): respect NODE_ENV when set by user ([#1915](https://github.com/sveltejs/kit/pull/1915))\n\n## 1.0.0-next.129\n\n### Patch Changes\n\n- e246455: Passthrough server-side fetch cookies for most same-origin scenarios ([#1847](https://github.com/sveltejs/kit/pull/1847))\n\n## 1.0.0-next.128\n\n### Patch Changes\n\n- 27e9067: Better error messages when something goes wrong while emitting types ([#1903](https://github.com/sveltejs/kit/pull/1903))\n- 277029d: Change index.js exports to directory exports when packaging ([#1905](https://github.com/sveltejs/kit/pull/1905))\n\n## 1.0.0-next.127\n\n### Patch Changes\n\n- bb3ae21: Fix endpoint validation to allow returning string for all content types ([#1900](https://github.com/sveltejs/kit/pull/1900))\n\n## 1.0.0-next.126\n\n### Patch Changes\n\n- 4720b67: Default body parsing to binary ([#1890](https://github.com/sveltejs/kit/pull/1890))\n- 6da07b8: fix returning null from endpoints ([#1886](https://github.com/sveltejs/kit/pull/1886))\n\n## 1.0.0-next.125\n\n### Patch Changes\n\n- 7faf52f: Update and consolidate checks for binary body types ([#1687](https://github.com/sveltejs/kit/pull/1687))\n- f854b89: Replace return type of Buffer with Uint8Array ([#1876](https://github.com/sveltejs/kit/pull/1876))\n- f854b89: Remove Incoming from public types ([#1876](https://github.com/sveltejs/kit/pull/1876))\n\n## 1.0.0-next.124\n\n### Patch Changes\n\n- 34d2049: handle undefined body on endpoint output ([#1808](https://github.com/sveltejs/kit/pull/1808))\n- c826016: add config.kit.package.emitTypes ([#1852](https://github.com/sveltejs/kit/pull/1852))\n- 8854e2f: Bump vite-plugin-svelte to 1.0.0-next.12 ([#1869](https://github.com/sveltejs/kit/pull/1869))\n- af1aa54: copy essential root files on `svelte-kit package` ([#1747](https://github.com/sveltejs/kit/pull/1747))\n- 872840a: Pass along custom properties added to Error ([#1821](https://github.com/sveltejs/kit/pull/1821))\n- 868f97a: Preserve README casing and package.json contents on svelte-kit package ([#1735](https://github.com/sveltejs/kit/pull/1735))\n\n## 1.0.0-next.123\n\n### Patch Changes\n\n- 4b25615: Fix ReadOnlyFormData keys and values method implementation ([#1837](https://github.com/sveltejs/kit/pull/1837))\n- 64f749d: ServiceWorker files exclusion support available through svelte.config.js ([#1645](https://github.com/sveltejs/kit/pull/1645))\n- 4d2fec5: Enable Vite's server.fs.strict by default ([#1842](https://github.com/sveltejs/kit/pull/1842))\n- 1ec368a: Expose Vite.js mode from \\$app/env ([#1789](https://github.com/sveltejs/kit/pull/1789))\n\n## 1.0.0-next.122\n\n### Patch Changes\n\n- d09a4e1: Surface Svelte compiler errors ([#1827](https://github.com/sveltejs/kit/pull/1827))\n- 79b4fe2: Update Vite to ^2.4.1 ([#1834](https://github.com/sveltejs/kit/pull/1834))\n- 2ac5781: Use esbuild inject API to insert shims ([#1822](https://github.com/sveltejs/kit/pull/1822))\n\n## 1.0.0-next.121\n\n### Patch Changes\n\n- 939188e: Use UTF-8 encoding for JSON endpoint responses by default ([#1669](https://github.com/sveltejs/kit/pull/1669))\n- 5b3e1e6: Add types generation to svelte-kit package command ([#1646](https://github.com/sveltejs/kit/pull/1646))\n- 8affef2: Fix type errors inside ReadOnlyFormData that didn't allow it to be used inside for..of loops ([#1830](https://github.com/sveltejs/kit/pull/1830))\n\n## 1.0.0-next.120\n\n### Patch Changes\n\n- 9fbaeda: fix attribute validation in generated script tag ([#1768](https://github.com/sveltejs/kit/pull/1768))\n- 9f0c54a: Externalize app initialization to adapters ([#1804](https://github.com/sveltejs/kit/pull/1804))\n- 0d69e55: Add generic type for session ([#1791](https://github.com/sveltejs/kit/pull/1791))\n- 325c223: Improve RequestHandler and EndpointOutput type declarations. ([#1778](https://github.com/sveltejs/kit/pull/1778))\n- 6ef148d: Generate service worker registration code even with `router` and `hydration` disabled ([#1724](https://github.com/sveltejs/kit/pull/1724))\n- ae3ef19: Fail if config.kit.appDir starts or ends with a slash ([#1695](https://github.com/sveltejs/kit/pull/1695))\n\n## 1.0.0-next.119\n\n### Patch Changes\n\n- 064f848: Implement serverFetch hook\n- 882fb12: Add keepfocus option to goto\n\n## 1.0.0-next.118\n\n### Patch Changes\n\n- 5418254: Fix regex for getting links to crawl during prerendering ([#1743](https://github.com/sveltejs/kit/pull/1743))\n\n## 1.0.0-next.117\n\n### Patch Changes\n\n- 828732c: Specify actual Svelte version requirement ([#1751](https://github.com/sveltejs/kit/pull/1751))\n\n## 1.0.0-next.116\n\n### Patch Changes\n\n- ea8cd54: chore(kit): correct `engines` constraint ([#1696](https://github.com/sveltejs/kit/pull/1696))\n- aedec24: Ensure router is initialized before parsing location ([#1691](https://github.com/sveltejs/kit/pull/1691))\n- c7d5ce4: update vite to 2.3.8 and unpin ([#1715](https://github.com/sveltejs/kit/pull/1715))\n- d259bca: Stricter regex for getting element attributes during prerendering ([#1700](https://github.com/sveltejs/kit/pull/1700))\n\n## 1.0.0-next.115\n\n### Patch Changes\n\n- 523c3e2: Allow vite.alias to be an array ([#1640](https://github.com/sveltejs/kit/pull/1640))\n- 6fd46d1: \\* update vite-plugin-svelte to 1.0.0-next.11 and use its named export ([#1673](https://github.com/sveltejs/kit/pull/1673))\n  - update vite to 2.3.7\n- dc56d3c: Fix navigation when `base` path is set and validate that option's value ([#1666](https://github.com/sveltejs/kit/pull/1666))\n\n## 1.0.0-next.114\n\n### Patch Changes\n\n- 5aa64ab: fix: SSL for HMR websockets #844 ([#1517](https://github.com/sveltejs/kit/pull/1517))\n- fae75f1: add optional state parameter for goto function ([#1643](https://github.com/sveltejs/kit/pull/1643))\n- fbd5f8a: package command can now transpile TypeScript files ([#1633](https://github.com/sveltejs/kit/pull/1633))\n\n## 1.0.0-next.113\n\n### Patch Changes\n\n- 045c45c: update vite to 2.3.6 ([#1625](https://github.com/sveltejs/kit/pull/1625))\n\n## 1.0.0-next.112\n\n### Patch Changes\n\n- cbe029e: Allow non-lowercase 'content-type' header in ssr fetch requests ([#1463](https://github.com/sveltejs/kit/pull/1463))\n- 1bf1a02: Make it possible to type context, page params and props for LoadInput and LoadOutput ([#1447](https://github.com/sveltejs/kit/pull/1447))\n\n## 1.0.0-next.111\n\n### Patch Changes\n\n- eae1b1d: Rename handle's render parameter to resolve ([#1566](https://github.com/sveltejs/kit/pull/1566))\n\n## 1.0.0-next.110\n\n### Patch Changes\n\n- 6372690: Add svelte-kit package command ([#1499](https://github.com/sveltejs/kit/pull/1499))\n- c3d36a3: ensure `content-length` limit respected; handle `getRawBody` error(s) ([#1528](https://github.com/sveltejs/kit/pull/1528))\n- bf77940: bump `polka` and `sirv` dependency versions ([#1548](https://github.com/sveltejs/kit/pull/1548))\n- 2172469: Upgrade to Vite 2.3.4 ([#1580](https://github.com/sveltejs/kit/pull/1580))\n- 028abd9: Pass validated svelte config to adapter adapt function ([#1559](https://github.com/sveltejs/kit/pull/1559))\n\n## 1.0.0-next.109\n\n### Patch Changes\n\n- 261ee1c: Update compatible Node versions ([#1470](https://github.com/sveltejs/kit/pull/1470))\n- ec156c6: let hash only changes be handled by router ([#830](https://github.com/sveltejs/kit/pull/830))\n- 586785d: Allow passing HTTPS key pair in Vite section of config ([#1456](https://github.com/sveltejs/kit/pull/1456))\n\n## 1.0.0-next.108\n\n### Patch Changes\n\n- dad93fc: Fix workspace dependencies ([#1434](https://github.com/sveltejs/kit/pull/1434))\n- 37fc04f: Ignore URLs that the app does not own ([#1487](https://github.com/sveltejs/kit/pull/1487))\n\n## 1.0.0-next.107\n\n### Patch Changes\n\n- ad83d40: update vite to ^2.3.1 ([#1429](https://github.com/sveltejs/kit/pull/1429))\n\n## 1.0.0-next.106\n\n### Patch Changes\n\n- fe0531d: temporarily pin vite to version 2.2.4 until issues with 2.3.0 are resolved ([#1423](https://github.com/sveltejs/kit/pull/1423))\n\n## 1.0.0-next.105\n\n### Patch Changes\n\n- f3c50a0: Bump Vite to 2.3.0 ([#1413](https://github.com/sveltejs/kit/pull/1413))\n- cfd6c3c: Use rendered CSS for AMP pages ([#1408](https://github.com/sveltejs/kit/pull/1408))\n- 9a2cc0a: Add trailingSlash: 'never' | 'always' | 'ignore' option ([#1404](https://github.com/sveltejs/kit/pull/1404))\n\n## 1.0.0-next.104\n\n### Patch Changes\n\n- 9b448a6: Rename @sveltejs/kit/http to @sveltejs/kit/node ([#1391](https://github.com/sveltejs/kit/pull/1391))\n\n## 1.0.0-next.103\n\n### Patch Changes\n\n- 11e7840: Generate ETags for binary response bodies ([#1382](https://github.com/sveltejs/kit/pull/1382))\n- 11e7840: Update request/response body types ([#1382](https://github.com/sveltejs/kit/pull/1382))\n- 9e20873: Allow ServerResponse to have non-static set of headers ([#1375](https://github.com/sveltejs/kit/pull/1375))\n- 2562ca0: Account for POST bodies when serializing fetches ([#1385](https://github.com/sveltejs/kit/pull/1385))\n\n## 1.0.0-next.102\n\n### Patch Changes\n\n- b5ff7f5: Rename \\$layout to \\_\\_layout etc ([#1370](https://github.com/sveltejs/kit/pull/1370))\n- d871213: Make Vite a prod dep of SvelteKit ([#1374](https://github.com/sveltejs/kit/pull/1374))\n\n## 1.0.0-next.101\n\n### Patch Changes\n\n- f5e626d: Reference Vite/Svelte types inside Kit types ([#1319](https://github.com/sveltejs/kit/pull/1319))\n\n## 1.0.0-next.100\n\n### Patch Changes\n\n- 9890492: Use TypedArray.set to copy from Uint8Array when getting raw body in core/http ([#1349](https://github.com/sveltejs/kit/pull/1349))\n\n## 1.0.0-next.99\n\n### Patch Changes\n\n- 051c026: Remove getContext in favour of request.locals ([#1332](https://github.com/sveltejs/kit/pull/1332))\n\n## 1.0.0-next.98\n\n### Patch Changes\n\n- d279e36: Add invalidate(url) API for rerunning load functions ([#1303](https://github.com/sveltejs/kit/pull/1303))\n\n## 1.0.0-next.97\n\n### Patch Changes\n\n- 694f5de: Fixes `navigating` store type ([#1322](https://github.com/sveltejs/kit/pull/1322))\n- 0befffb: Rename .svelte to .svelte-kit ([#1321](https://github.com/sveltejs/kit/pull/1321))\n- c6fde99: Switch to ESM in config files ([#1323](https://github.com/sveltejs/kit/pull/1323))\n\n## 1.0.0-next.96\n\n### Patch Changes\n\n- 63eff1a: Add prerendering to \\$app/env typings ([#1316](https://github.com/sveltejs/kit/pull/1316))\n\n## 1.0.0-next.95\n\n### Patch Changes\n\n- 16cca89: Export AdapterUtils type for use in adapters ([#1300](https://github.com/sveltejs/kit/pull/1300))\n- f3ef93d: Not calling JSON.stringify on endpoint's body if it's a string and the content-type header denotes json ([#1272](https://github.com/sveltejs/kit/pull/1272))\n- 5023e98: Remove 'Navigated to' text from announcer' ([#1305](https://github.com/sveltejs/kit/pull/1305))\n- b4d0d6c: Normalize keys of headers from server side requests\n- 08ebcb5: Add esm config support ([#936](https://github.com/sveltejs/kit/pull/936))\n- 427e8e0: Validate template file on startup ([#1304](https://github.com/sveltejs/kit/pull/1304))\n\n## 1.0.0-next.94\n\n### Patch Changes\n\n- 72c78a4: Handle URLs that need to be decoded ([#1273](https://github.com/sveltejs/kit/pull/1273))\n\n## 1.0.0-next.93\n\n### Patch Changes\n\n- 353afa1: Disable FLoC by default ([#1267](https://github.com/sveltejs/kit/pull/1267))\n\n## 1.0.0-next.92\n\n### Patch Changes\n\n- 354e384: Allow FormData to be passed as RequestHandler type Body argument ([#1256](https://github.com/sveltejs/kit/pull/1256))\n- b1bfe83: Show error page on unknown initial path. Fixes #1190.\n\n## 1.0.0-next.91\n\n### Patch Changes\n\n- 82955ec: fix: adapt to svelte ids without ?import in vite 2.2.3\n\n## 1.0.0-next.90\n\n### Patch Changes\n\n- ac60208: Exit process after adapting ([#1212](https://github.com/sveltejs/kit/pull/1212))\n\n## 1.0.0-next.89\n\n### Patch Changes\n\n- 927e63c: update the error message of prerender to optionally include the parent variable ([#1200](https://github.com/sveltejs/kit/pull/1200))\n\n## 1.0.0-next.88\n\n### Patch Changes\n\n- 6f2b4a6: Remove references to npm start ([#1196](https://github.com/sveltejs/kit/pull/1196))\n\n## 1.0.0-next.87\n\n### Patch Changes\n\n- 4131467: Prerender fallback page for SPAs ([#1181](https://github.com/sveltejs/kit/pull/1181))\n\n## 1.0.0-next.86\n\n### Patch Changes\n\n- 2130087: Support multiple rel values on anchor tag ([#884](https://github.com/sveltejs/kit/pull/884))\n- ba732ff: Report errors in hooks.js ([#1178](https://github.com/sveltejs/kit/pull/1178))\n- a2f3f4b: Rename `start` to `preview` in the CLI and package scripts\n\n## 1.0.0-next.85\n\n### Patch Changes\n\n- 4645ad5: Force Vite to bundle Svelte component libraries in SSR ([#1148](https://github.com/sveltejs/kit/pull/1148))\n- abf0248: Fix \\$service-worker types\n\n## 1.0.0-next.84\n\n### Patch Changes\n\n- 5c2665f: Prevent ...rest parameters from swallowing earlier characters ([#1128](https://github.com/sveltejs/kit/pull/1128))\n- 4e1c4ea: Omit modulepreload links from pages with no JS ([#1131](https://github.com/sveltejs/kit/pull/1131))\n- 5d864a6: Fix RequestHandler return type\n- e1313d0: Make response.body optional\n\n## 1.0.0-next.83\n\n### Patch Changes\n\n- a4a1075: Work around apparent Cloudflare Workers platform bugs ([#1123](https://github.com/sveltejs/kit/pull/1123))\n\n## 1.0.0-next.82\n\n### Patch Changes\n\n- 4af45e1: Remove usage of node built-ins from runtime ([#1117](https://github.com/sveltejs/kit/pull/1117))\n\n## 1.0.0-next.81\n\n### Patch Changes\n\n- 1237eb3: Expose rawBody on request, and expect rawBody from adapters ([#1109](https://github.com/sveltejs/kit/pull/1109))\n- 1237eb3: Expose getRawBody from kit/http ([#1109](https://github.com/sveltejs/kit/pull/1109))\n\n## 1.0.0-next.80\n\n### Patch Changes\n\n- 7a4b351: Expose install-fetch subpackage for adapters to use ([#1091](https://github.com/sveltejs/kit/pull/1091))\n\n## 1.0.0-next.79\n\n### Patch Changes\n\n- d3abd97: Fix Windows build output containing backward slashes ([#1096](https://github.com/sveltejs/kit/pull/1096))\n\n## 1.0.0-next.78\n\n### Patch Changes\n\n- 6e27880: Move server-side fetch to adapters instead of build step ([#1066](https://github.com/sveltejs/kit/pull/1066))\n- 61d7fa0: Better error logging ([#1062](https://github.com/sveltejs/kit/pull/1062))\n- 041b706: Implement layout resets ([#1061](https://github.com/sveltejs/kit/pull/1061))\n- 148819a: Use latest vite-plugin-svelte ([#1057](https://github.com/sveltejs/kit/pull/1057))\n- 9d54eed: Make sveltekit:prefetch a noop if <a> has no href ([#1060](https://github.com/sveltejs/kit/pull/1060))\n\n## 1.0.0-next.77\n\n### Patch Changes\n\n- fee388a: Include CSS for entry point/generated component ([#1053](https://github.com/sveltejs/kit/pull/1053))\n\n## 1.0.0-next.76\n\n### Patch Changes\n\n- f870909: Pin vite-plugin-svelte version ([#1026](https://github.com/sveltejs/kit/pull/1026))\n- de2466f: Fix stale prerendering bug ([#1040](https://github.com/sveltejs/kit/pull/1040))\n\n## 1.0.0-next.75\n\n### Patch Changes\n\n- 0c02dc0: Use global URLSearchParams instead of import from node url ([#1020](https://github.com/sveltejs/kit/pull/1020))\n- 8021d6b: Fix default error page ([#1021](https://github.com/sveltejs/kit/pull/1021))\n- 11ec751: Fix build warnings about missing exports in hooks file ([#1003](https://github.com/sveltejs/kit/pull/1003))\n\n## 1.0.0-next.74\n\n### Patch Changes\n\n- 4c45784: Add ambient types to published files ([#980](https://github.com/sveltejs/kit/pull/980))\n\n## 1.0.0-next.73\n\n### Patch Changes\n\n- 1007f67: Allow non-root \\$error.svelte components ([#901](https://github.com/sveltejs/kit/pull/901))\n- ca108a6: Change `handle` hook from positional arguments to named arguments ([#959](https://github.com/sveltejs/kit/pull/959))\n\n## 1.0.0-next.72\n\n### Patch Changes\n\n- 1d5228c: Make --open option work with --https ([#921](https://github.com/sveltejs/kit/pull/921))\n- 39b6967: Add ambient type definitions for \\$app imports ([#917](https://github.com/sveltejs/kit/pull/917))\n- 1d5228c: Make --open option work on WSL ([#921](https://github.com/sveltejs/kit/pull/921))\n- bb2d97d: Fix argument type for RequestHandler ([#914](https://github.com/sveltejs/kit/pull/914))\n\n## 1.0.0-next.71\n\n### Patch Changes\n\n- 108c26c: Always return a response from render function in handle ([#847](https://github.com/sveltejs/kit/pull/847))\n\n## 1.0.0-next.70\n\n### Patch Changes\n\n- 6d9f7b1: Only include CSS on an SSR'd page ([#839](https://github.com/sveltejs/kit/pull/839))\n- 6ecfa2c: Remove duplicate &lt;style&gt; element ([#845](https://github.com/sveltejs/kit/pull/845))\n\n## 1.0.0-next.69\n\n### Patch Changes\n\n- 4d2cd62: Add prerendering to \\$app/env ([#833](https://github.com/sveltejs/kit/pull/833))\n- e2eeeea: Call load when path changes if page.path is used ([#838](https://github.com/sveltejs/kit/pull/838))\n- 50b5526: Pass through credentials when fetching in load ([#835](https://github.com/sveltejs/kit/pull/835))\n- 6384af6: Only inline data if hydrate=true ([#837](https://github.com/sveltejs/kit/pull/837))\n\n## 1.0.0-next.68\n\n### Patch Changes\n\n- 24fab19: Add --https flag to dev and start ([#462](https://github.com/sveltejs/kit/pull/462))\n- ba4f9b7: Check port, only expose to network with --host flag ([#819](https://github.com/sveltejs/kit/pull/819))\n\n## 1.0.0-next.67\n\n### Patch Changes\n\n- 679e997: Fix client-side redirect loop detection ([#811](https://github.com/sveltejs/kit/pull/811))\n- 8d453c8: Specify minimum Node version number in @sveltejs/kit and add .npmrc to enforce it ([#787](https://github.com/sveltejs/kit/pull/787))\n- 78aec0c: Detect service worker support\n- f33a22c: Make ...rest parameters optional ([#768](https://github.com/sveltejs/kit/pull/768))\n\n## 1.0.0-next.66\n\n### Patch Changes\n\n- d9ce2a2: Correct response type for fetch ([#799](https://github.com/sveltejs/kit/pull/799))\n\n## 1.0.0-next.65\n\n### Patch Changes\n\n- c0b9873: Always apply layout props when hydrating ([#794](https://github.com/sveltejs/kit/pull/794))\n- b8a8e53: Add type to config.kit.vite ([#786](https://github.com/sveltejs/kit/pull/786))\n- 9b09bcc: Prevent XSS when serializing fetch results ([#769](https://github.com/sveltejs/kit/pull/769))\n\n## 1.0.0-next.64\n\n### Patch Changes\n\n- 7f58512: Prevent Vite prebundling from crashing on startup ([#759](https://github.com/sveltejs/kit/pull/759))\n\n## 1.0.0-next.63\n\n### Patch Changes\n\n- 31f94fe: Add ssr, router and hydrate options\n\n## 1.0.0-next.62\n\n### Patch Changes\n\n- 864c3d4: Assets imported from css and js/ts files are emitted as files instead of being inlined ([#461](https://github.com/sveltejs/kit/pull/461))\n\n## 1.0.0-next.61\n\n### Patch Changes\n\n- 4b2c97e: Initialise router with history.state\n\n## 1.0.0-next.60\n\n### Patch Changes\n\n- 84e9023: Fix host property ([#657](https://github.com/sveltejs/kit/pull/657))\n- 272148b: Rename \\$service-worker::assets to files, per the docs ([#658](https://github.com/sveltejs/kit/pull/658))\n- d5071c5: Hydrate initial page before starting router ([#654](https://github.com/sveltejs/kit/pull/654))\n- 4a1c04a: More accurate MODULE_NOT_FOUND errors ([#665](https://github.com/sveltejs/kit/pull/665))\n- d881b7e: Replace setup with hooks ([#670](https://github.com/sveltejs/kit/pull/670))\n\n## 1.0.0-next.59\n\n### Patch Changes\n\n- 826f39e: Make prefetching work ([#620](https://github.com/sveltejs/kit/pull/620))\n\n## 1.0.0-next.58\n\n### Patch Changes\n\n- 26893b0: Allow first argument to fetch in load to be a request ([#619](https://github.com/sveltejs/kit/pull/619))\n- 924db15: Add copy function to Builder.js ([#630](https://github.com/sveltejs/kit/pull/630))\n\n## 1.0.0-next.57\n\n### Patch Changes\n\n- 391189f: Check for options.initiator in correct place ([#615](https://github.com/sveltejs/kit/pull/615))\n\n## 1.0.0-next.56\n\n### Patch Changes\n\n- 82cbe2b: Shrink client manifest ([#593](https://github.com/sveltejs/kit/pull/593))\n- 8024178: remove @sveltejs/app-utils ([#600](https://github.com/sveltejs/kit/pull/600))\n\n## 1.0.0-next.55\n\n### Patch Changes\n\n- d0a7019: switch to @sveltejs/vite-plugin-svelte ([#584](https://github.com/sveltejs/kit/pull/584))\n- 8a88fad: Replace regex routes with fallthrough routes ([#583](https://github.com/sveltejs/kit/pull/583))\n\n## 1.0.0-next.54\n\n### Patch Changes\n\n- 3037530: Create history entry for initial route ([#582](https://github.com/sveltejs/kit/pull/582))\n- 04f17f5: Prevent erronous <style>undefined</style> ([#578](https://github.com/sveltejs/kit/pull/578))\n- 8805c6d: Pass adapters directly to svelte.config.cjs ([#579](https://github.com/sveltejs/kit/pull/579))\n\n## 1.0.0-next.53\n\n### Patch Changes\n\n- 9cf2f21: Only require page components to export prerender ([#577](https://github.com/sveltejs/kit/pull/577))\n- e860de0: Invalidate page when query changes ([#575](https://github.com/sveltejs/kit/pull/575))\n- 7bb1cf0: Disable vite-plugin-svelte transform cache ([#576](https://github.com/sveltejs/kit/pull/576))\n\n## 1.0.0-next.52\n\n### Patch Changes\n\n- ac3669e: Move Vite config into svelte.config.cjs ([#569](https://github.com/sveltejs/kit/pull/569))\n\n## 1.0.0-next.51\n\n### Patch Changes\n\n- 34a00f9: Bypass router on hydration ([#563](https://github.com/sveltejs/kit/pull/563))\n\n## 1.0.0-next.50\n\n### Patch Changes\n\n- 0512fd1: Remove startGlobal option ([#559](https://github.com/sveltejs/kit/pull/559))\n- 9212aa5: Add options to adapter-node, and add adapter types ([#531](https://github.com/sveltejs/kit/pull/531))\n- 0512fd1: Fire custom events for start, and navigation start/end ([#559](https://github.com/sveltejs/kit/pull/559))\n\n## 1.0.0-next.49\n\n### Patch Changes\n\n- ab28c0a: kit: include missing types.d.ts ([#538](https://github.com/sveltejs/kit/pull/538))\n- c76c9bf: Upgrade Vite ([#544](https://github.com/sveltejs/kit/pull/544))\n\n## 1.0.0-next.48\n\n### Patch Changes\n\n- e37a302: Make getSession future-proof ([#524](https://github.com/sveltejs/kit/pull/524))\n\n## 1.0.0-next.47\n\n### Patch Changes\n\n- 5554acc: Add \\$lib alias ([#511](https://github.com/sveltejs/kit/pull/511))\n- 5cd6f11: bump vite-plugin-svelte to 0.11.0 ([#513](https://github.com/sveltejs/kit/pull/513))\n\n## 1.0.0-next.46\n\n### Patch Changes\n\n- f35a5cd: Change adapter signature ([#505](https://github.com/sveltejs/kit/pull/505))\n\n## 1.0.0-next.45\n\n### Patch Changes\n\n- 925638a: Remove endpoints from the files built for the client ([#490](https://github.com/sveltejs/kit/pull/490))\n- c3cf3f3: Bump deps ([#492](https://github.com/sveltejs/kit/pull/492))\n- 625747d: kit: bundle @sveltejs/kit into built application ([#486](https://github.com/sveltejs/kit/pull/486))\n- Updated dependencies [c3cf3f3]\n  - @sveltejs/vite-plugin-svelte@1.0.0-next.3\n\n## 1.0.0-next.44\n\n### Patch Changes\n\n- e6449d2: Fix AMP styles for real ([#494](https://github.com/sveltejs/kit/pull/494))\n\n## 1.0.0-next.43\n\n### Patch Changes\n\n- 672e9be: Fix AMP styles, again ([#491](https://github.com/sveltejs/kit/pull/491))\n\n## 1.0.0-next.42\n\n### Patch Changes\n\n- 0f54ebc: Fix AMP styles ([#488](https://github.com/sveltejs/kit/pull/488))\n\n## 1.0.0-next.41\n\n### Patch Changes\n\n- 4aa5a73: Future-proof prepare argument ([#471](https://github.com/sveltejs/kit/pull/471))\n- 58dc400: Call correct set_paths function ([#487](https://github.com/sveltejs/kit/pull/487))\n- 2322291: Update to node-fetch@3\n\n## 1.0.0-next.40\n\n### Patch Changes\n\n- 4c5fd3c: Include layout/error styles in SSR ([#472](https://github.com/sveltejs/kit/pull/472))\n\n## 1.0.0-next.39\n\n### Patch Changes\n\n- b7fdb0d: Skip pre-bundling ([#468](https://github.com/sveltejs/kit/pull/468))\n\n## 1.0.0-next.38\n\n### Patch Changes\n\n- 15402b1: Add service worker support ([#463](https://github.com/sveltejs/kit/pull/463))\n- 0c630b5: Ignore dynamically imported components when constructing styles in dev mode ([#443](https://github.com/sveltejs/kit/pull/443))\n- ac06af5: Fix svelte-kit adapt for Windows ([#435](https://github.com/sveltejs/kit/pull/435))\n- 061fa46: Implement improved redirect API\n- b800049: Include type declarations ([#442](https://github.com/sveltejs/kit/pull/442))\n- 07c6de4: Use posix paths in manifest even on Windows ([#436](https://github.com/sveltejs/kit/pull/436))\n- 27ba872: Error if preload function exists ([#455](https://github.com/sveltejs/kit/pull/455))\n- 0c630b5: Add default paths in case singletons module is invalidated ([#443](https://github.com/sveltejs/kit/pull/443))\n- 73dd998: Allow custom extensions ([#411](https://github.com/sveltejs/kit/pull/411))\n\n## 1.0.0-next.37\n\n### Patch Changes\n\n- 230c6d9: Indicate which request failed, if fetch fails inside load function ([#427](https://github.com/sveltejs/kit/pull/427))\n- f1bc218: Run adapt via svelte-kit build ([#430](https://github.com/sveltejs/kit/pull/430))\n- 6850ddc: Fix svelte-kit start for Windows ([#425](https://github.com/sveltejs/kit/pull/425))\n\n## 1.0.0-next.36\n\n### Patch Changes\n\n- 7b70a33: Force version bump so that Kit uses updated vite-plugin-svelte ([#419](https://github.com/sveltejs/kit/pull/419))\n\n## 1.0.0-next.35\n\n### Patch Changes\n\n- Use Vite\n- Fix Windows issues\n- Preserve load context during navigation\n- Return error from load\n\n## 1.0.0-next.34\n\n### Patch Changes\n\n- Fix adapters and convert to ES modules\n\n## 1.0.0-next.33\n\n### Patch Changes\n\n- 474070e: Better errors when modules cannot be found ([#381](https://github.com/sveltejs/kit/pull/381))\n\n## 1.0.0-next.32\n\n### Patch Changes\n\n- Convert everything to ESM\n\n## 1.0.0-next.31\n\n### Patch Changes\n\n- b6c2434: app.js -> app.cjs ([#362](https://github.com/sveltejs/kit/pull/362))\n\n## 1.0.0-next.30\n\n### Patch Changes\n\n- 00cbaf6: Rename `_.config.js` to `_.config.cjs` ([#356](https://github.com/sveltejs/kit/pull/356))\n\n## 1.0.0-next.29\n\n### Patch Changes\n\n- 4c0edce: Use addEventListener instead of onload ([#347](https://github.com/sveltejs/kit/pull/347))\n\n## 1.0.0-next.28\n\n### Patch Changes\n\n- 4353025: Prevent infinite loop when fetching bad URLs inside error responses ([#340](https://github.com/sveltejs/kit/pull/340))\n- 2860065: Handle assets path when prerendering ([#341](https://github.com/sveltejs/kit/pull/341))\n\n## 1.0.0-next.27\n\n### Patch Changes\n\n- Fail build if prerender errors\n- Hide logging behind --verbose option\n\n## 1.0.0-next.26\n\n### Patch Changes\n\n- Fix svelte-announcer CSS\n\n## 1.0.0-next.25\n\n### Patch Changes\n\n- Surface stack traces for endpoint/page rendering errors\n\n## 1.0.0-next.24\n\n### Patch Changes\n\n- 26643df: Account for config.paths when prerendering ([#322](https://github.com/sveltejs/kit/pull/322))\n\n## 1.0.0-next.23\n\n### Patch Changes\n\n- 9b758aa: Upgrade to Snowpack 3 ([#321](https://github.com/sveltejs/kit/pull/321))\n\n## 1.0.0-next.22\n\n### Patch Changes\n\n- bb68595: use readFileSync instead of createReadStream ([#320](https://github.com/sveltejs/kit/pull/320))\n\n## 1.0.0-next.21\n\n### Patch Changes\n\n- 217e4cc: Set paths to empty string before prerender ([#317](https://github.com/sveltejs/kit/pull/317))\n\n## 1.0.0-next.20\n\n### Patch Changes\n\n- ccf4aa7: Implement prerender config ([#315](https://github.com/sveltejs/kit/pull/315))\n\n## 1.0.0-next.19\n\n### Patch Changes\n\n- deda984: Make navigating store contain from and to properties ([#313](https://github.com/sveltejs/kit/pull/313))\n\n## 1.0.0-next.18\n\n### Patch Changes\n\n- c29b61e: Announce page changes ([#311](https://github.com/sveltejs/kit/pull/311))\n- 72da270: Reset focus properly ([#309](https://github.com/sveltejs/kit/pull/309))\n\n## 1.0.0-next.17\n\n### Patch Changes\n\n- f7dea55: Set process.env.NODE_ENV when invoking via the CLI ([#304](https://github.com/sveltejs/kit/pull/304))\n\n## 1.0.0-next.16\n\n### Patch Changes\n\n- Remove temporary logging\n- Add sveltekit:prefetch and sveltekit:noscroll\n\n## 1.0.0-next.15\n\n### Patch Changes\n\n- 6d1bb11: Fix AMP CSS ([#286](https://github.com/sveltejs/kit/pull/286))\n- d8b53af: Ignore $layout and $error files when finding static paths\n- Better scroll tracking\n\n## 1.0.0-next.14\n\n### Patch Changes\n\n- Fix dev loader\n\n## 1.0.0-next.13\n\n### Patch Changes\n\n- 1ea4d6b: More robust CSS extraction ([#279](https://github.com/sveltejs/kit/pull/279))\n\n## 1.0.0-next.12\n\n### Patch Changes\n\n- e7c88dd: Tweak AMP validation screen\n\n## 1.0.0-next.11\n\n### Patch Changes\n\n- a31f218: Fix SSR loader invalidation ([#277](https://github.com/sveltejs/kit/pull/277))\n\n## 1.0.0-next.10\n\n### Patch Changes\n\n- 8b14d29: Omit svelte-data scripts from AMP pages ([#276](https://github.com/sveltejs/kit/pull/276))\n\n## 1.0.0-next.9\n\n### Patch Changes\n\n- f5fa223: AMP support ([#274](https://github.com/sveltejs/kit/pull/274))\n- 47f2ee1: Always remove trailing slashes ([#267](https://github.com/sveltejs/kit/pull/267))\n- 1becb94: Replace preload with load\n\n## 1.0.0-next.8\n\n### Patch Changes\n\n- 15dd751: Use meta http-equiv=refresh ([#256](https://github.com/sveltejs/kit/pull/256))\n- be7e031: Fix handling of static files ([#258](https://github.com/sveltejs/kit/pull/258))\n- ed6b8fd: Implement \\$app/env ([#251](https://github.com/sveltejs/kit/pull/251))\n\n## 1.0.0-next.7\n\n### Patch Changes\n\n- 76705b0: make HMR work outside localhost ([#246](https://github.com/sveltejs/kit/pull/246))\n\n## 1.0.0-next.6\n\n### Patch Changes\n\n- 0e45255: Move options behind kit namespace, change paths -> kit.files ([#236](https://github.com/sveltejs/kit/pull/236))\n- fa7f2b2: Implement live bindings for SSR code ([#245](https://github.com/sveltejs/kit/pull/245))\n\n## 1.0.0-next.5\n\n### Patch Changes\n\n- Return dependencies from render\n\n## 1.0.0-next.4\n\n### Patch Changes\n\n- af01b0d: Move renderer out of app assets folder\n\n## 1.0.0-next.3\n\n### Patch Changes\n\n- Add paths to manifest, for static prerendering\n\n## 1.0.0-next.2\n\n### Patch Changes\n\n- Fix typo causing misnamed assets folder\n\n## 1.0.0-next.1\n\n### Patch Changes\n\n- a4bc090: Transform exported functions correctly ([#225](https://github.com/sveltejs/kit/pull/225))\n- 00bbf98: Fix nested layouts ([#227](https://github.com/sveltejs/kit/pull/227))\n\n## 0.0.31-next.0\n\n### Patch Changes\n\n- ffd7bba: Fix SSR cache invalidation ([#217](https://github.com/sveltejs/kit/pull/217))\n\n## 0.0.30\n\n### Patch Changes\n\n- Add back stores(), but with deprecation warning\n- Rename stores.preloading to stores.navigating\n- Rewrite routing logic\n\n## 0.0.29\n\n### Patch Changes\n\n- 10872cc: Normalize request.query ([#196](https://github.com/sveltejs/kit/pull/196))\n\n## 0.0.28\n\n### Patch Changes\n\n- Add svelte-kit start command\n\n## 0.0.27\n\n### Patch Changes\n\n- rename CLI to svelte-kit\n- 0904e22: rename svelte CLI to svelte-kit ([#186](https://github.com/sveltejs/kit/pull/186))\n- Validate route responses\n- Make paths and target configurable\n\n## 0.0.26\n\n### Patch Changes\n\n- b475ed4: Overhaul adapter API - fixes #166 ([#180](https://github.com/sveltejs/kit/pull/180))\n- Updated dependencies [b475ed4]\n  - @sveltejs/app-utils@0.0.18\n\n## 0.0.25\n\n### Patch Changes\n\n- Updated dependencies [3bdf33b]\n  - @sveltejs/app-utils@0.0.17\n\n## 0.0.24\n\n### Patch Changes\n\n- 67eaeea: Move app-utils stuff into subpackages\n- 7f8df30: Move kit runtime code, expose via \\$app aliases\n- Updated dependencies [67eaeea]\n  - @sveltejs/app-utils@0.0.16\n\n## 0.0.23\n\n### Patch Changes\n\n- a163000: Parse body on incoming requests\n- a346eab: Copy over latest Sapper router code ([#6](https://github.com/sveltejs/kit/pull/6))\n- Updated dependencies [a163000]\n  - @sveltejs/app-utils@0.0.15\n\n## 0.0.22\n\n### Patch Changes\n\n- Force bump version\n\n## 0.0.21\n\n### Patch Changes\n\n- Build setup entry point\n- Work around pkg.exports constraint\n- Respond with 500s if render fails\n- Updated dependencies [undefined]\n- Updated dependencies [undefined]\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.14\n\n## 0.0.20\n\n### Patch Changes\n\n- Pass setup module to renderer\n- Bump Snowpack version\n- Updated dependencies [undefined]\n- Updated dependencies [96c06d8]\n  - @sveltejs/app-utils@0.0.13\n\n## 0.0.19\n\n### Patch Changes\n\n- fa9d7ce: Handle import.meta in SSR module loader\n- 0320208: Rename 'server route' to 'endpoint'\n- b9444d2: Update to Snowpack 2.15\n- 5ca907c: Use shared mkdirp helper\n- Updated dependencies [0320208]\n- Updated dependencies [5ca907c]\n  - @sveltejs/app-utils@0.0.12\n\n## 0.0.18\n\n### Patch Changes\n\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.11\n\n## 0.0.17\n\n### Patch Changes\n\n- 19323e9: Update Snowpack\n- Updated dependencies [19323e9]\n  - @sveltejs/app-utils@0.0.10\n\n## 0.0.16\n\n### Patch Changes\n\n- Updated dependencies [90a98ae]\n  - @sveltejs/app-utils@0.0.9\n\n## 0.0.15\n\n### Patch Changes\n\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.8\n\n## 0.0.14\n\n### Patch Changes\n\n- various\n- Updated dependencies [undefined]\n  - @sveltejs/app-utils@0.0.7\n"
  },
  {
    "path": "packages/kit/CHANGELOG.md",
    "content": "# @sveltejs/kit\n\n## 2.55.0\n### Minor Changes\n\n\n- feat: page and layout params with matchers are now type narrowed in `$app/types`, leading to better type safety when working with params in `$app/types`, `$app/state`, and hooks. ([#15502](https://github.com/sveltejs/kit/pull/15502))\n\n## 2.54.0\n### Minor Changes\n\n\n- feat: allow error boundaries to catch errors on the server ([#15308](https://github.com/sveltejs/kit/pull/15308))\n\n\n### Patch Changes\n\n\n- chore: upgrade `devalue` ([#15535](https://github.com/sveltejs/kit/pull/15535))\n\n\n- fix: don't wait for remote functions that are not awaited in the template ([#15280](https://github.com/sveltejs/kit/pull/15280))\n\n\n- feat: allow `resolve()` to accept pathnames with a search string and/or hash ([#15458](https://github.com/sveltejs/kit/pull/15458))\n\n\n- chore: remove deprecation warnings for `config.kit.files.*` options when validating the Svelte config file ([#15482](https://github.com/sveltejs/kit/pull/15482))\n\n\n- fix: handles form target attribute in remote form redirects ([#15457](https://github.com/sveltejs/kit/pull/15457))\n\n## 2.53.4\n### Patch Changes\n\n\n- fix: avoid Vite warning about unknown `codeSplitting` option ([#15451](https://github.com/sveltejs/kit/pull/15451))\n\n## 2.53.3\n### Patch Changes\n\n\n- fix: prevent overlapping file metadata in remote functions `form` ([`faba869`](https://github.com/sveltejs/kit/commit/faba869db3644077169bf5d7c6e41fd5f3d6c65e))\n\n## 2.53.2\n### Patch Changes\n\n\n- fix: server-render nested form value sets ([#15378](https://github.com/sveltejs/kit/pull/15378))\n\n\n- fix: use deep partial types for form remote functions `.value()` and `.set(...)` ([#14837](https://github.com/sveltejs/kit/pull/14837))\n\n\n- fix: provide correct url info to remote functions ([#15418](https://github.com/sveltejs/kit/pull/15418))\n\n\n- fix: allow optional types for remote query/command/prerender functions ([#15293](https://github.com/sveltejs/kit/pull/15293))\n\n\n- fix: allow commands in more places ([#15288](https://github.com/sveltejs/kit/pull/15288))\n\n## 2.53.1\n### Patch Changes\n\n\n- fix: address warning about `inlineDynamicImports` when using Vite 8 ([#15403](https://github.com/sveltejs/kit/pull/15403))\n\n## 2.53.0\n### Minor Changes\n\n\n- feat: support Vite 8 ([#15024](https://github.com/sveltejs/kit/pull/15024))\n\n\n### Patch Changes\n\n\n- fix: remove event listeners on form attachment cleanup ([#15286](https://github.com/sveltejs/kit/pull/15286))\n\n\n- fix: apply queries refreshed in a form remote function when a redirect is thrown ([#15362](https://github.com/sveltejs/kit/pull/15362))\n\n## 2.52.2\n### Patch Changes\n\n\n- fix: validate `form` file information to prevent amplification attacks ([`3e607b3`](https://github.com/sveltejs/kit/commit/3e607b314aec9e5f278d32847945b8b6323e1cb8))\n\n\n- chore: upgrade `devalue` and `svelte` ([#15339](https://github.com/sveltejs/kit/pull/15339))\n\n\n- fix: parse file offset table more strictly ([`f47c01b`](https://github.com/sveltejs/kit/commit/f47c01bd8100328c24fdb8522fe35913b0735f35))\n\n## 2.52.1\n### Patch Changes\n\n\n- fix: clear stale preflight issues on subsequent valid form submissions ([#15281](https://github.com/sveltejs/kit/pull/15281))\n\n\n- chore: remove dependency on `sade` ([#15272](https://github.com/sveltejs/kit/pull/15272))\n\n\n- fix: include `.txt` files in precompression ([#15259](https://github.com/sveltejs/kit/pull/15259))\n\n\n- fix: escape backticks and dollar signs when creating inlined css ([#15320](https://github.com/sveltejs/kit/pull/15320))\n\n\n- fix: increment `form.pending` count before preflight validation ([#15279](https://github.com/sveltejs/kit/pull/15279))\n\n## 2.52.0\n### Minor Changes\n\n\n- feat: `match` function to map a path back to a route id and params ([#14997](https://github.com/sveltejs/kit/pull/14997))\n\n\n### Patch Changes\n\n\n- fix: respect scroll-margin when navigating to a url-supplied anchor ([#15246](https://github.com/sveltejs/kit/pull/15246))\n\n\n- fix: `resolve` will narrow types to follow trailing slash page settings ([#15027](https://github.com/sveltejs/kit/pull/15027))\n\n## 2.51.0\n### Minor Changes\n\n\n- feat: add `scroll` property to `NavigationTarget` in navigation callbacks ([#15248](https://github.com/sveltejs/kit/pull/15248))\n  \n  Navigation callbacks (`beforeNavigate`, `onNavigate`, and `afterNavigate`) now include scroll position information via the `scroll` property on `from` and `to` targets:\n  \n  - `from.scroll`: The scroll position at the moment navigation was triggered\n  - `to.scroll`: In `beforeNavigate` and `onNavigate`, this is populated for `popstate` navigations (back/forward) with the scroll position that will be restored, and `null` for other navigation types. In `afterNavigate`, this is always the final scroll position after navigation completed.\n  \n  This enables use cases like animating transitions based on the target scroll position when using browser back/forward navigation.\n\n- feat: `hydratable`'s injected script now works with CSP ([#15048](https://github.com/sveltejs/kit/pull/15048))\n\n\n### Patch Changes\n\n\n- fix: put preloads before styles ([#15232](https://github.com/sveltejs/kit/pull/15232))\n\n\n- fix: suppress false-positive inner content warning when children prop is forwarded to a child component ([#15269](https://github.com/sveltejs/kit/pull/15269))\n\n\n- fix: `fetch` not working when URL is same host but different than `paths.base` ([#15291](https://github.com/sveltejs/kit/pull/15291))\n\n\n- fix: navigate to hash link when base element is present ([#15236](https://github.com/sveltejs/kit/pull/15236))\n\n\n- fix: avoid triggering `handleError` when redirecting in a remote function ([#15222](https://github.com/sveltejs/kit/pull/15222))\n\n\n- fix: include `test` directory in generated `tsconfig.json` alongside existing `tests` entry ([#15254](https://github.com/sveltejs/kit/pull/15254))\n\n\n- fix: generate `tsconfig.json` using the value of `kit.files.src` ([#15253](https://github.com/sveltejs/kit/pull/15253))\n\n## 2.50.2\n### Patch Changes\n\n\n- fix: ensure inlined CSS follows `paths.assets` and `paths.relative` settings ([#15153](https://github.com/sveltejs/kit/pull/15153))\n\n\n- fix: emit script CSP nonces when `unsafe-inline` is present if `strict-dynamic` is also present ([#15221](https://github.com/sveltejs/kit/pull/15221))\n\n\n- fix: re-export browser/dev from esm-env ([#15206](https://github.com/sveltejs/kit/pull/15206))\n\n\n- fix: use validated args in batch resolver in both csr and ssr ([#15215](https://github.com/sveltejs/kit/pull/15215))\n\n\n- fix: ensure CSS inlining includes components that are conditionally rendered ([#15153](https://github.com/sveltejs/kit/pull/15153))\n\n\n- fix: only match rest params with matchers when the matcher matches ([#15216](https://github.com/sveltejs/kit/pull/15216))\n\n\n- fix: properly handle percent-encoded anchors (e.g. `<a href=\"#sparkles-%E2%9C%A8\">`) during prerendering. ([#15231](https://github.com/sveltejs/kit/pull/15231))\n\n## 2.50.1\n### Patch Changes\n\n\n- fix: include `hooks.server` and `hooks.universal` as explicit Vite build inputs to ensure assets imported by hooks files are correctly discovered ([#15178](https://github.com/sveltejs/kit/pull/15178))\n\n\n- fix: improves fields type for generic components ([#14974](https://github.com/sveltejs/kit/pull/14974))\n\n\n- fix: preload links if href changes ([#15191](https://github.com/sveltejs/kit/pull/15191))\n\n## 2.50.0\n### Minor Changes\n\n\n- breaking: remove `buttonProps` from experimental remote form functions; use e.g. `<button {...myForm.fields.action.as('submit', 'register')}>Register</button>` button instead ([#15144](https://github.com/sveltejs/kit/pull/15144))\n\n## 2.49.5\n### Patch Changes\n\n\n- fix: avoid overriding Vite default `base` when running Vitest 4 ([#14866](https://github.com/sveltejs/kit/pull/14866))\n\n\n- fix: ensure url decoded pathnames are not mistaken as rerouted requests ([`d9ae9b0`](https://github.com/sveltejs/kit/commit/d9ae9b00b14f5574d109f3fd548f960594346226))\n\n\n- fix: add length checks to remote forms ([`8ed8155`](https://github.com/sveltejs/kit/commit/8ed8155215b9a74012fecffb942ad9a793b274e5))\n\n## 2.49.4\n### Patch Changes\n\n\n- fix: support instrumentation for `vite preview` ([#15105](https://github.com/sveltejs/kit/pull/15105))\n\n\n- fix: support for `URLSearchParams.has(name, value)` overload ([#15076](https://github.com/sveltejs/kit/pull/15076))\n\n\n- fix: put forking behind `experimental.forkPreloads` ([#15135](https://github.com/sveltejs/kit/pull/15135))\n\n## 2.49.3\n### Patch Changes\n\n\n- fix: avoid false-positive Vite config overridden warning when using Vitest 4 ([#15121](https://github.com/sveltejs/kit/pull/15121))\n\n\n- fix: add `typescript` as an optional peer dependency ([#15074](https://github.com/sveltejs/kit/pull/15074))\n\n\n- fix: use hasOwn check when deep-setting object properties ([#15127](https://github.com/sveltejs/kit/pull/15127))\n\n## 2.49.2\n### Patch Changes\n\n\n- fix: Stop re-loading already-loaded CSS during server-side route resolution ([#15014](https://github.com/sveltejs/kit/pull/15014))\n\n\n- fix: posixify the instrumentation file import on Windows ([#14993](https://github.com/sveltejs/kit/pull/14993))\n\n\n- fix: Correctly handle shared memory when decoding binary form data ([#15028](https://github.com/sveltejs/kit/pull/15028))\n\n## 2.49.1\n### Patch Changes\n\n\n- fix: suppress `state_referenced_locally` warnings in `.svelte-kit/generated/root.svelte` ([#15013](https://github.com/sveltejs/kit/pull/15013))\n\n\n- fix: TypeError when doing response.clone() in page load ([#15005](https://github.com/sveltejs/kit/pull/15005))\n\n## 2.49.0\n### Minor Changes\n\n\n- feat: stream file uploads inside `form` remote functions allowing form data to be accessed before large files finish uploading ([#14775](https://github.com/sveltejs/kit/pull/14775))\n\n## 2.48.8\n### Patch Changes\n\n\n- breaking: `invalid` now must be imported from `@sveltejs/kit` ([#14768](https://github.com/sveltejs/kit/pull/14768))\n\n\n- breaking: remove `submitter` option from experimental form `validate()` method, always provide default submitter ([#14762](https://github.com/sveltejs/kit/pull/14762))\n\n## 2.48.7\n### Patch Changes\n\n\n- fix: allow multiple `server-timing` headers ([#14700](https://github.com/sveltejs/kit/pull/14700))\n\n\n- fix: allow access to root-level issues in schema-less forms ([#14893](https://github.com/sveltejs/kit/pull/14893))\n\n\n- fix: allow hosting hash-based apps from non-index.html files ([#14825](https://github.com/sveltejs/kit/pull/14825))\n\n## 2.48.6\n### Patch Changes\n\n\n- fix: clear issues upon passing validation ([#14683](https://github.com/sveltejs/kit/pull/14683))\n\n\n- fix: don't use fork of unrelated route ([#14947](https://github.com/sveltejs/kit/pull/14947))\n\n\n- fix: prevent type errors when optional `@opentelemetry/api` dependency isn't installed ([#14949](https://github.com/sveltejs/kit/pull/14949))\n\n\n- fix: preserve `this` when invoking standard validator ([#14943](https://github.com/sveltejs/kit/pull/14943))\n\n\n- fix: treat client/universal hooks as entrypoints for illegal server import detection ([#14876](https://github.com/sveltejs/kit/pull/14876))\n\n\n- fix: correct query `.set` and `.refresh` behavior in commands ([#14877](https://github.com/sveltejs/kit/pull/14877))\n\n\n- fix: improved the accuracy of the types of the output of `field.as('...')` ([#14908](https://github.com/sveltejs/kit/pull/14908))\n\n## 2.48.5\n### Patch Changes\n\n\n- fix: wait an extra microtask in dev before calling `$_init_$` ([#14799](https://github.com/sveltejs/kit/pull/14799))\n\n\n- fix: discard preload fork before creating a new one ([#14865](https://github.com/sveltejs/kit/pull/14865))\n\n\n- fix: delete `RemoteFormAllIssue`, add `path` to `RemoteFormIssue` ([#14864](https://github.com/sveltejs/kit/pull/14864))\n\n## 2.48.4\n### Patch Changes\n\n\n- fix: adjust query's promise implementation to properly allow chaining ([#14859](https://github.com/sveltejs/kit/pull/14859))\n\n\n- fix: make prerender cache work, including in development ([#14860](https://github.com/sveltejs/kit/pull/14860))\n\n## 2.48.3\n### Patch Changes\n\n\n- fix: include hash when using `resolve` with hash routing enabled ([#14786](https://github.com/sveltejs/kit/pull/14786))\n\n\n- fix: `afterNavigate` callback not running after hydration when experimental async is enabled ([#14644](https://github.com/sveltejs/kit/pull/14644))\n  fix: Snapshot `restore` method not called after reload when experimental async is enabled\n\n- fix: expose `issue.path` in `.allIssues()` ([#14784](https://github.com/sveltejs/kit/pull/14784))\n\n## 2.48.2\n### Patch Changes\n\n\n- fix: update DOM before running navigate callbacks ([#14829](https://github.com/sveltejs/kit/pull/14829))\n\n## 2.48.1\n### Patch Changes\n\n\n- fix: wait for commit promise instead of `settled` ([#14818](https://github.com/sveltejs/kit/pull/14818))\n\n## 2.48.0\n### Minor Changes\n\n\n- feat: use experimental `fork` API when available ([#14793](https://github.com/sveltejs/kit/pull/14793))\n\n\n### Patch Changes\n\n\n- fix: await for `settled` instead of `tick` in navigate ([#14800](https://github.com/sveltejs/kit/pull/14800))\n\n## 2.47.3\n### Patch Changes\n\n\n- fix: avoid hanging when `error()` is used while streaming promises from a server `load` function ([#14722](https://github.com/sveltejs/kit/pull/14722))\n\n\n- chore: treeshake load function code if we know it's unused ([#14764](https://github.com/sveltejs/kit/pull/14764))\n\n\n- fix: `RecursiveFormFields` type for recursive or unknown schemas ([#14734](https://github.com/sveltejs/kit/pull/14734))\n\n\n- fix: rework internal representation of form value to be `$state` ([#14771](https://github.com/sveltejs/kit/pull/14771))\n\n## 2.47.2\n### Patch Changes\n\n\n- fix: streamed promise not resolving when another load function returns a fast resolving promise ([#14753](https://github.com/sveltejs/kit/pull/14753))\n\n\n- chore: allow to run preflight validation only ([#14744](https://github.com/sveltejs/kit/pull/14744))\n\n\n- fix: update overload to set `invalid` type to schema input ([#14748](https://github.com/sveltejs/kit/pull/14748))\n\n## 2.47.1\n### Patch Changes\n\n\n- fix: allow `read` to be used at the top-level of remote function files ([#14672](https://github.com/sveltejs/kit/pull/14672))\n\n\n- fix: more robust remote files generation ([#14682](https://github.com/sveltejs/kit/pull/14682))\n\n## 2.47.0\n### Minor Changes\n\n\n- feat: add [`signal`](https://developer.mozilla.org/en-US/docs/Web/API/Request/signal) property to request ([#14715](https://github.com/sveltejs/kit/pull/14715))\n\n\n### Patch Changes\n\n\n- fix: resolve remote module syntax errors with trailing expressions ([#14728](https://github.com/sveltejs/kit/pull/14728))\n\n## 2.46.5\n### Patch Changes\n\n\n- fix: ensure `form` remote functions' `fields.set` triggers reactivity ([#14661](https://github.com/sveltejs/kit/pull/14661))\n\n## 2.46.4\n### Patch Changes\n\n\n- fix: prevent access of Svelte 5-only `untrack` function ([#14658](https://github.com/sveltejs/kit/pull/14658))\n\n## 2.46.3\n### Patch Changes\n\n\n- fix: merge `field.set(...)` calls ([#14651](https://github.com/sveltejs/kit/pull/14651))\n\n\n- fix: don't automatically reset form after an enhanced submission ([#14626](https://github.com/sveltejs/kit/pull/14626))\n\n\n- fix: normalize path strings when updating field values ([#14649](https://github.com/sveltejs/kit/pull/14649))\n\n## 2.46.2\n### Patch Changes\n\n\n- fix: prevent code execution order issues around SvelteKit's `env` modules ([#14637](https://github.com/sveltejs/kit/pull/14637))\n\n## 2.46.1\n### Patch Changes\n\n\n- fix: use `$derived` for form fields ([#14621](https://github.com/sveltejs/kit/pull/14621))\n\n\n- docs: remove `@example` blocks to allow docs to deploy ([#14636](https://github.com/sveltejs/kit/pull/14636))\n\n\n- fix: require a value with `submit` and `hidden` fields ([#14635](https://github.com/sveltejs/kit/pull/14635))\n\n\n- fix: delete hydration cache on effect teardown ([#14611](https://github.com/sveltejs/kit/pull/14611))\n\n## 2.46.0\n### Minor Changes\n\n\n- feat: imperative form validation ([#14624](https://github.com/sveltejs/kit/pull/14624))\n\n\n### Patch Changes\n\n\n- fix: wait a tick before collecting form data for validation ([#14631](https://github.com/sveltejs/kit/pull/14631))\n\n\n- fix: prevent code execution order issues around SvelteKit's `env` modules ([#14632](https://github.com/sveltejs/kit/pull/14632))\n\n## 2.45.0\n### Minor Changes\n\n\n- feat: `form.for(id)` now implicitly sets id on form object ([#14623](https://github.com/sveltejs/kit/pull/14623))\n\n\n### Patch Changes\n\n\n- fix: allow `fetch` in remote function without emitting a warning ([#14610](https://github.com/sveltejs/kit/pull/14610))\n\n## 2.44.0\n### Minor Changes\n\n\n- feat: expose `event.route` and `event.url` to remote functions ([#14606](https://github.com/sveltejs/kit/pull/14606))\n\n\n- breaking: update experimental `form` API ([#14481](https://github.com/sveltejs/kit/pull/14481))\n\n\n### Patch Changes\n\n\n- fix: don't crawl error responses during prerendering ([#14596](https://github.com/sveltejs/kit/pull/14596))\n\n## 2.43.8\n### Patch Changes\n\n\n- fix: HMR for `query` ([#14587](https://github.com/sveltejs/kit/pull/14587))\n\n\n- fix: avoid client modules while traversing dependencies to prevent FOUC during dev ([#14577](https://github.com/sveltejs/kit/pull/14577))\n\n\n- fix: skip prebundling of .remote.js files ([#14583](https://github.com/sveltejs/kit/pull/14583))\n\n\n- fix: more robust remote file pattern matching ([#14578](https://github.com/sveltejs/kit/pull/14578))\n\n## 2.43.7\n### Patch Changes\n\n\n- fix: correctly type the `result` of `form` remote functions that do not accept data ([#14573](https://github.com/sveltejs/kit/pull/14573))\n\n\n- fix: force remote module chunks to isolate themselves ([#14571](https://github.com/sveltejs/kit/pull/14571))\n\n## 2.43.6\n### Patch Changes\n\n\n- fix: ensure cache key is consistent between client/server ([#14563](https://github.com/sveltejs/kit/pull/14563))\n\n\n- fix: keep resolve relative to initial base during prerender ([#14533](https://github.com/sveltejs/kit/pull/14533))\n\n\n- fix: avoid including `HEAD` twice when an unhandled HTTP method is used in a request to a `+server` handler that has both a `GET` handler and a `HEAD` handler ([#14564](https://github.com/sveltejs/kit/pull/14564))\n\n\n- fix: smoothscroll to deep link ([#14569](https://github.com/sveltejs/kit/pull/14569))\n\n## 2.43.5\n### Patch Changes\n\n\n- fix: fall back to non-relative resolution when calling `resolve(...)` outside an event context ([#14532](https://github.com/sveltejs/kit/pull/14532))\n\n## 2.43.4\n### Patch Changes\n\n\n- fix: Webcontainer AsyncLocalStorage workaround ([#14526](https://github.com/sveltejs/kit/pull/14526))\n\n## 2.43.3\n### Patch Changes\n\n\n- fix: Webcontainer AsyncLocalStorage workaround ([#14521](https://github.com/sveltejs/kit/pull/14521))\n\n\n- fix: include the value of form submitters on `form` remote functions ([#14475](https://github.com/sveltejs/kit/pull/14475))\n\n## 2.43.2\n### Patch Changes\n\n\n- fix: ensure rendering starts off synchronously ([#14517](https://github.com/sveltejs/kit/pull/14517))\n\n\n- fix: keep serialized remote data alive until navigation ([#14508](https://github.com/sveltejs/kit/pull/14508))\n\n## 2.43.1\n### Patch Changes\n\n\n- fix: consistently use bare import for internals ([#14506](https://github.com/sveltejs/kit/pull/14506))\n\n## 2.43.0\n### Minor Changes\n\n\n- feat: experimental async SSR ([#14447](https://github.com/sveltejs/kit/pull/14447))\n\n\n### Patch Changes\n\n\n- fix: ensure `__SVELTEKIT_PAYLOAD__.data` is accessed safely ([#14491](https://github.com/sveltejs/kit/pull/14491))\n\n\n- fix: create separate cache entries for non-exported remote function queries ([#14499](https://github.com/sveltejs/kit/pull/14499))\n\n## 2.42.2\n### Patch Changes\n\n\n- fix: prevent loops in postbuild analysis phase ([#14450](https://github.com/sveltejs/kit/pull/14450))\n\n\n- fix: handle nested object fields in form data ([#14469](https://github.com/sveltejs/kit/pull/14469))\n\n\n- fix: robustify form helper types ([#14463](https://github.com/sveltejs/kit/pull/14463))\n\n\n- fix: avoid running the `init` hook during builds if there's nothing to prerender ([#14464](https://github.com/sveltejs/kit/pull/14464))\n\n\n- fix: ensure SSR rendering gets request store context ([#14476](https://github.com/sveltejs/kit/pull/14476))\n\n## 2.42.1\n### Patch Changes\n\n\n- fix: ensure environment setup is in its own chunk ([#14441](https://github.com/sveltejs/kit/pull/14441))\n\n## 2.42.0\n### Minor Changes\n\n\n- feat: enhance remote form functions with schema support, `input` and `issues` properties ([#14383](https://github.com/sveltejs/kit/pull/14383))\n\n\n- breaking: remote form functions get passed a parsed POJO instead of a `FormData` object now ([#14383](https://github.com/sveltejs/kit/pull/14383))\n\n## 2.41.0\n### Minor Changes\n\n\n- feat: add `%sveltekit.version%` to `app.html` ([#12132](https://github.com/sveltejs/kit/pull/12132))\n\n\n### Patch Changes\n\n\n- fix: allow remote functions to return custom types serialized with `transport` hooks ([#14435](https://github.com/sveltejs/kit/pull/14435))\n\n\n- fix: fulfil `beforeNavigate` `complete` when redirected ([#12896](https://github.com/sveltejs/kit/pull/12896))\n\n## 2.40.0\n### Minor Changes\n\n\n- feat: include `event` property on popstate/link/form navigation ([#14307](https://github.com/sveltejs/kit/pull/14307))\n\n\n### Patch Changes\n\n\n- fix: respect `replaceState`/`keepFocus`/`noScroll` when a navigation results in a redirect ([#14424](https://github.com/sveltejs/kit/pull/14424))\n\n\n- fix: invalidate preload cache when invalidateAll is true ([#14420](https://github.com/sveltejs/kit/pull/14420))\n\n## 2.39.1\n### Patch Changes\n\n\n- fix: more robust remote function code transformation ([#14418](https://github.com/sveltejs/kit/pull/14418))\n\n## 2.39.0\n### Minor Changes\n\n\n- feat: lazy discovery of remote functions ([#14293](https://github.com/sveltejs/kit/pull/14293))\n\n\n### Patch Changes\n\n\n- fix: layout load data not serialized on error page ([#14395](https://github.com/sveltejs/kit/pull/14395))\n\n\n- fix: fail prerendering when remote function fails ([#14365](https://github.com/sveltejs/kit/pull/14365))\n\n\n- fix: treat handle hook redirect as part of remote function call as json redirect ([#14362](https://github.com/sveltejs/kit/pull/14362))\n\n## 2.38.1\n### Patch Changes\n\n\n- fix: enable redirects from queries ([#14400](https://github.com/sveltejs/kit/pull/14400))\n\n\n- fix: remove empty nodes from serialized server load data ([#14404](https://github.com/sveltejs/kit/pull/14404))\n\n\n- fix: allow commands from within endpoints ([#14343](https://github.com/sveltejs/kit/pull/14343))\n\n## 2.38.0\n### Minor Changes\n\n\n- feat: add new remote function `query.batch` ([#14272](https://github.com/sveltejs/kit/pull/14272))\n\n## 2.37.1\n### Patch Changes\n\n\n- fix: serialize server `load` data before passing to universal `load`, to handle mutations and promises ([#14298](https://github.com/sveltejs/kit/pull/14298))\n\n\n- fix: resolve_route prevent dropping a trailing slash of id ([#14294](https://github.com/sveltejs/kit/pull/14294))\n\n\n- fix: assign correct status code to form submission error on the client ([#14345](https://github.com/sveltejs/kit/pull/14345))\n\n\n- fix: un-proxy `form.result` ([#14346](https://github.com/sveltejs/kit/pull/14346))\n\n## 2.37.0\n### Minor Changes\n\n\n- feat: automatically resolve `query.refresh()` promises on the server ([#14332](https://github.com/sveltejs/kit/pull/14332))\n\n\n- feat: allow query.set() to be called on the server ([#14304](https://github.com/sveltejs/kit/pull/14304))\n\n\n### Patch Changes\n\n\n- fix: disable CSRF checks in dev ([#14335](https://github.com/sveltejs/kit/pull/14335))\n\n\n- fix: allow redirects to external URLs from within form functions ([#14329](https://github.com/sveltejs/kit/pull/14329))\n\n\n- fix: add type definitions for `query.set()` method to override the value of a remote query function ([#14303](https://github.com/sveltejs/kit/pull/14303))\n\n\n- fix: ensure uniqueness of `form.for(...)` across form functions ([#14327](https://github.com/sveltejs/kit/pull/14327))\n\n## 2.36.3\n### Patch Changes\n\n\n- fix: bump devalue ([#14323](https://github.com/sveltejs/kit/pull/14323))\n\n\n- chore: consolidate dev checks to use `esm-env` instead of a `__SVELTEKIT_DEV__` global ([#14308](https://github.com/sveltejs/kit/pull/14308))\n\n\n- fix: reset form inputs by default when using remote form functions ([#14322](https://github.com/sveltejs/kit/pull/14322))\n\n## 2.36.2\n### Patch Changes\n\n\n- chore: make config deprecation warnings more visible ([#14281](https://github.com/sveltejs/kit/pull/14281))\n\n\n- chore: remove redundant Not Found error message ([#14289](https://github.com/sveltejs/kit/pull/14289))\n\n\n- chore: deprecate `csrf.checkOrigin` in favour of `csrf.trustedOrigins: ['*']` ([#14281](https://github.com/sveltejs/kit/pull/14281))\n\n## 2.36.1\n### Patch Changes\n\n\n- fix: ensure importing from `$app/navigation` works in test files ([#14195](https://github.com/sveltejs/kit/pull/14195))\n\n## 2.36.0\n### Minor Changes\n\n\n- feat: add `csrf.trustedOrigins` configuration ([#14021](https://github.com/sveltejs/kit/pull/14021))\n\n\n### Patch Changes\n\n\n- fix: correctly decode custom types streamed from a server load function ([#14261](https://github.com/sveltejs/kit/pull/14261))\n\n\n- fix: add trailing slash pathname when generating typed routes ([#14065](https://github.com/sveltejs/kit/pull/14065))\n\n## 2.35.0\n### Minor Changes\n\n\n- feat: better server-side error logging ([#13990](https://github.com/sveltejs/kit/pull/13990))\n\n\n### Patch Changes\n\n\n- fix: ensure static error page is loaded correctly for custom user errors ([#13952](https://github.com/sveltejs/kit/pull/13952))\n\n## 2.34.1\n### Patch Changes\n\n\n- fix: support multiple cookies with the same name across different paths and domains ([`b2c5d02`](https://github.com/sveltejs/kit/commit/b2c5d02994a6d83275d6fb3645e6f9a2518c8d20))\n\n\n- fix: add link header when preloading font ([#14200](https://github.com/sveltejs/kit/pull/14200))\n\n\n- fix: `cookies.get(...)` returns `undefined` for a just-deleted cookie ([`b2c5d02`](https://github.com/sveltejs/kit/commit/b2c5d02994a6d83275d6fb3645e6f9a2518c8d20))\n\n\n- fix: load env before prerender ([`c5f7139`](https://github.com/sveltejs/kit/commit/c5f713951e41af2000f21929d42eb9d30c9d3a5c))\n\n## 2.34.0\n### Minor Changes\n\n\n- feat: allow dynamic `env` access during prerender ([#14243](https://github.com/sveltejs/kit/pull/14243))\n\n\n### Patch Changes\n\n\n- fix: clone `fetch` responses so that headers are mutable ([#13942](https://github.com/sveltejs/kit/pull/13942))\n\n\n- fix: serialize server `load` data before passing to universal `load`, to handle mutations ([#14268](https://github.com/sveltejs/kit/pull/14268))\n\n\n- fix: allow `asset(...)` to be used with imported assets ([#14270](https://github.com/sveltejs/kit/pull/14270))\n\n## 2.33.1\n### Patch Changes\n\n\n- fix: make paths in .css assets relative ([#14262](https://github.com/sveltejs/kit/pull/14262))\n\n\n- fix: avoid copying SSR stylesheets to client assets ([#13069](https://github.com/sveltejs/kit/pull/13069))\n\n## 2.33.0\n### Minor Changes\n\n\n- feat: configure error reporting when routes marked as prerendable were not prerendered ([#11702](https://github.com/sveltejs/kit/pull/11702))\n\n\n### Patch Changes\n\n\n- fix: use correct flag for server tracing ([#14250](https://github.com/sveltejs/kit/pull/14250))\n\n\n- fix: correct type names for new `handleUnseenRoutes` option ([#14254](https://github.com/sveltejs/kit/pull/14254))\n\n\n- chore: Better docs and error message for missing `@opentelemetry/api` dependency ([#14250](https://github.com/sveltejs/kit/pull/14250))\n\n## 2.32.0\n### Minor Changes\n\n\n- feat: inline load fetch `response.body` stream data as base64 in page ([#11473](https://github.com/sveltejs/kit/pull/11473))\n\n\n### Patch Changes\n\n\n- fix: better error when `.remote.ts` files are used without the `experimental.remoteFunctions` flag ([#14225](https://github.com/sveltejs/kit/pull/14225))\n\n## 2.31.1\n### Patch Changes\n\n\n- fix: pass options to resolve in resolveId hook ([#14223](https://github.com/sveltejs/kit/pull/14223))\n\n## 2.31.0\n### Minor Changes\n\n\n- feat: OpenTelemetry tracing for `handle`, `sequence`, form actions, remote functions, and `load` functions running on the server ([#13899](https://github.com/sveltejs/kit/pull/13899))\n\n\n- feat: add `instrumentation.server.ts` for tracing and observability setup ([#13899](https://github.com/sveltejs/kit/pull/13899))\n\n## 2.30.1\n### Patch Changes\n\n\n- chore: generate `$app/types` in a more Typescript-friendly way ([#14207](https://github.com/sveltejs/kit/pull/14207))\n\n## 2.30.0\n### Minor Changes\n\n\n- feat: allow to specify options for the service worker in `svelte.config.js` ([#13578](https://github.com/sveltejs/kit/pull/13578))\n\n\n### Patch Changes\n\n\n- fix: ensure buttonProps.enhance works on buttons with nested text ([#14199](https://github.com/sveltejs/kit/pull/14199))\n\n\n- fix: pass validation issues specifically to avoid non-enumerable spreading error ([#14197](https://github.com/sveltejs/kit/pull/14197))\n\n## 2.29.1\n### Patch Changes\n\n\n- chore: allow remote functions in all of the src directory ([#14198](https://github.com/sveltejs/kit/pull/14198))\n\n## 2.29.0\n### Minor Changes\n\n\n- feat: add a `kit.files.src` option ([#14152](https://github.com/sveltejs/kit/pull/14152))\n\n\n### Patch Changes\n\n\n- fix: don't treat `$lib/server.ts` or `$lib/server_whatever.ts` as server-only modules, only `$lib/server/**` ([#14191](https://github.com/sveltejs/kit/pull/14191))\n\n\n- fix: make illegal server-only import errors actually useful ([#14155](https://github.com/sveltejs/kit/pull/14155))\n\n\n- chore: deprecate `config.kit.files` options ([#14152](https://github.com/sveltejs/kit/pull/14152))\n\n\n- fix: avoid warning if page options in a Svelte file belongs to a comment ([#14180](https://github.com/sveltejs/kit/pull/14180))\n\n## 2.28.0\n### Minor Changes\n\n\n- feat: add `RouteId` and `RouteParams` to NavigationTarget interface ([#14167](https://github.com/sveltejs/kit/pull/14167))\n\n\n- feat: add `pending` property to forms and commands ([#14137](https://github.com/sveltejs/kit/pull/14137))\n\n\n### Patch Changes\n\n\n- fix: `fetch` imported assets during prerender ([#12201](https://github.com/sveltejs/kit/pull/12201))\n\n\n- chore: refactor redundant base64 encoding/decoding functions ([#14160](https://github.com/sveltejs/kit/pull/14160))\n\n\n- fix: use correct cache result when fetching same url multiple times ([#12355](https://github.com/sveltejs/kit/pull/12355))\n\n\n- fix: don't refresh queries automatically when running commands ([#14170](https://github.com/sveltejs/kit/pull/14170))\n\n\n- fix: avoid writing remote function bundle to disk when treeshaking prerendered queries ([#14161](https://github.com/sveltejs/kit/pull/14161))\n\n## 2.27.3\n### Patch Changes\n\n\n- chore: add `.git` to the end of `package.json` repository url ([#14134](https://github.com/sveltejs/kit/pull/14134))\n\n## 2.27.2\n### Patch Changes\n\n\n- fix: ensure `form()` remote functions work when the app is configured to a single output ([#14127](https://github.com/sveltejs/kit/pull/14127))\n\n\n- fix: use the configured base path when calling remote functions from the client ([#14106](https://github.com/sveltejs/kit/pull/14106))\n\n## 2.27.1\n### Patch Changes\n\n\n- fix: correctly type remote function input parameters from a schema ([#14098](https://github.com/sveltejs/kit/pull/14098))\n\n\n- fix: match URL-encoded newlines in rest route params ([#14102](https://github.com/sveltejs/kit/pull/14102))\n\n\n- fix: correctly spell server-side in error messages ([#14101](https://github.com/sveltejs/kit/pull/14101))\n\n## 2.27.0\n### Minor Changes\n\n\n- feat: remote functions ([#13986](https://github.com/sveltejs/kit/pull/13986))\n\n## 2.26.1\n### Patch Changes\n\n\n- fix: posixify internal app server path ([#14049](https://github.com/sveltejs/kit/pull/14049))\n\n\n- fix: ignore route groups when generating typed routes ([#14050](https://github.com/sveltejs/kit/pull/14050))\n\n## 2.26.0\n### Minor Changes\n\n\n- feat: better type-safety for `page.route.id`, `page.params`, `page.url.pathname` and various other places ([#13864](https://github.com/sveltejs/kit/pull/13864))\n\n\n- feat: `resolve(...)` and `asset(...)` helpers for resolving paths ([#13864](https://github.com/sveltejs/kit/pull/13864))\n\n\n- feat: Add `$app/types` module with `Asset`, `RouteId`, `Pathname`, `ResolvedPathname` `RouteParams<T>` and `LayoutParams<T>` ([#13864](https://github.com/sveltejs/kit/pull/13864))\n\n## 2.25.2\n### Patch Changes\n\n\n- fix: correctly set URL when navigating during an ongoing navigation ([#14004](https://github.com/sveltejs/kit/pull/14004))\n\n## 2.25.1\n### Patch Changes\n\n\n- fix: add missing params property ([#14012](https://github.com/sveltejs/kit/pull/14012))\n\n## 2.25.0\n### Minor Changes\n\n\n- feat: support asynchronous `read` implementations from adapters ([#13859](https://github.com/sveltejs/kit/pull/13859))\n\n\n### Patch Changes\n\n\n- fix: log when no Svelte config file has been found to avoid confusion ([#14001](https://github.com/sveltejs/kit/pull/14001))\n\n## 2.24.0\n### Minor Changes\n\n\n- feat: typed `params` prop for page/layout components ([#13999](https://github.com/sveltejs/kit/pull/13999))\n\n\n### Patch Changes\n\n\n- fix: treeshake internal `storage.get` helper ([#13998](https://github.com/sveltejs/kit/pull/13998))\n\n## 2.23.0\n### Minor Changes\n\n\n- feat: support svelte.config.ts ([#13935](https://github.com/sveltejs/kit/pull/13935))\n  \n  > **NOTE**\n  >\n  > Your runtime has to support importing TypeScript files for `svelte.config.ts` to work.\n  > In Node.js, the feature is supported with the `--experimental-strip-types` flag starting in Node 22.6.0 and supported without a flag starting in Node 23.6.0.\n\n### Patch Changes\n\n\n- fix: extend `vite-plugin-svelte`'s `Config` type instead of duplicating it ([#13982](https://github.com/sveltejs/kit/pull/13982))\n\n\n- fix: regression with `rolldown-vite` not bundling a single JS file for single and inline apps ([#13941](https://github.com/sveltejs/kit/pull/13941))\n\n## 2.22.5\n### Patch Changes\n\n\n- fix: re-add `@sveltejs/kit` to `optimizeDeps.exclude` ([#13983](https://github.com/sveltejs/kit/pull/13983))\n\n## 2.22.4\n### Patch Changes\n\n\n- fix: force `$app/*` modules to be bundled ([#13977](https://github.com/sveltejs/kit/pull/13977))\n\n## 2.22.3\n### Patch Changes\n\n\n- fix: don't bundle `@sveltejs/kit` ([#13971](https://github.com/sveltejs/kit/pull/13971))\n\n## 2.22.2\n### Patch Changes\n\n\n- fix: use fallback if `untrack` doesn't exist in svelte package ([#13933](https://github.com/sveltejs/kit/pull/13933))\n\n\n- fix: warning for chrome devtools requests now suggests sv instead of vite plugin ([#13905](https://github.com/sveltejs/kit/pull/13905))\n\n## 2.22.1\n### Patch Changes\n\n\n- fix: prevent infinite loop when calling `pushState`/`replaceState` in `$effect` ([#13914](https://github.com/sveltejs/kit/pull/13914))\n\n\n- chore: use `manualChunks` to bundle single and inline apps with Rolldown ([#13915](https://github.com/sveltejs/kit/pull/13915))\n\n## 2.22.0\n### Minor Changes\n\n\n- feat: add support for Vite 7 and Rolldown. See https://vite.dev/guide/rolldown.html#how-to-try-rolldown for details about how to try experimental Rolldown support. You will also need `vite-plugin-svelte@^6.0.0-next.0` and `vite@^7.0.0-beta.0`. Compilation should be faster using Rolldown, but with larger bundle sizes until additional tree-shaking is implemented in Rolldown. See [#13738](https://github.com/sveltejs/kit/issues/13738) for ongoing work. ([#13747](https://github.com/sveltejs/kit/pull/13747))\n\n## 2.21.5\n### Patch Changes\n\n\n- fix: correctly set the sequential focus navigation point when using hash routing ([#13884](https://github.com/sveltejs/kit/pull/13884))\n\n\n- fix: regression when resetting focus and the URL hash contains selector combinators or separators ([#13884](https://github.com/sveltejs/kit/pull/13884))\n\n## 2.21.4\n### Patch Changes\n\n\n- fix: correctly access transport decoders on the client when building for a single or inline output app ([#13871](https://github.com/sveltejs/kit/pull/13871))\n\n## 2.21.3\n### Patch Changes\n\n\n- fix: correctly invalidate static analysis cache of child nodes when modifying a universal `+layout` file during dev ([#13793](https://github.com/sveltejs/kit/pull/13793))\n\n\n- fix: correctly set sequential focus navigation starting point after navigation ([#10856](https://github.com/sveltejs/kit/pull/10856))\n\n\n- fix: suppress console spam for chrome devtools requests ([#13830](https://github.com/sveltejs/kit/pull/13830))\n\n\n- fix: avoid externalising packages that depend on `@sveltejs/kit` so that libraries can also use `redirect` and `error` helpers ([#13843](https://github.com/sveltejs/kit/pull/13843))\n\n\n- fix: correctly run `deserialize` on the server ([#13686](https://github.com/sveltejs/kit/pull/13686))\n\n\n- fix: correctly inline stylesheets of components dynamically imported in a universal load function if they are below the configured inlineStyleThreshold ([#13723](https://github.com/sveltejs/kit/pull/13723))\n\n## 2.21.2\n### Patch Changes\n\n\n- fix: omit stack when logging 404 errors ([#13848](https://github.com/sveltejs/kit/pull/13848))\n\n## 2.21.1\n### Patch Changes\n\n\n- chore: clarify which functions `handleFetch` affects ([#13788](https://github.com/sveltejs/kit/pull/13788))\n\n\n- fix: ensure `$env` and `$app/environment` are correctly set while analysing server nodes ([#13790](https://github.com/sveltejs/kit/pull/13790))\n\n## 2.21.0\n### Minor Changes\n\n\n- feat: allow running client-side code at the top-level of universal pages/layouts when SSR is disabled and page options are only boolean or string literals ([#13684](https://github.com/sveltejs/kit/pull/13684))\n\n\n### Patch Changes\n\n\n- chore: remove `import-meta-resolve` dependency ([#13629](https://github.com/sveltejs/kit/pull/13629))\n\n\n- fix: remove component code from server nodes that are never used for SSR ([#13684](https://github.com/sveltejs/kit/pull/13684))\n\n## 2.20.8\n### Patch Changes\n\n\n- fix: ensure that `ssr` and `csr` page options apply to error pages rendered as a result of a load function error on the server ([#13695](https://github.com/sveltejs/kit/pull/13695))\n\n## 2.20.7\n### Patch Changes\n\n\n- fix: regression when serializing server data ([#13709](https://github.com/sveltejs/kit/pull/13709))\n\n## 2.20.6\n### Patch Changes\n\n\n- fix: escape names of tracked search parameters ([`d3300c6a67908590266c363dba7b0835d9a194cf`](https://github.com/sveltejs/kit/commit/d3300c6a67908590266c363dba7b0835d9a194cf))\n\n## 2.20.5\n### Patch Changes\n\n\n- allow `HandleServerError` hook to access `getRequestEvent` ([#13666](https://github.com/sveltejs/kit/pull/13666))\n\n\n- fix: prevent Rollup warnings for undefined hooks ([#13687](https://github.com/sveltejs/kit/pull/13687))\n\n## 2.20.4\n### Patch Changes\n\n\n- chore: remove internal class-replacement hack that isn't needed anymore ([#13664](https://github.com/sveltejs/kit/pull/13664))\n\n## 2.20.3\n### Patch Changes\n\n\n- fix: only call `afterNavigate` once on app start when SSR is disabled ([#13593](https://github.com/sveltejs/kit/pull/13593))\n\n## 2.20.2\n### Patch Changes\n\n\n- fix: allow non-prerendered API endpoint calls during reroute when prerendering ([#13616](https://github.com/sveltejs/kit/pull/13616))\n\n## 2.20.1\n### Patch Changes\n\n\n- fix: avoid using top-level await ([#13607](https://github.com/sveltejs/kit/pull/13607))\n\n## 2.20.0\n### Minor Changes\n\n\n- feat: add `getRequestEvent` to `$app/server` ([#13582](https://github.com/sveltejs/kit/pull/13582))\n\n## 2.19.2\n### Patch Changes\n\n\n- fix: lazily load CSS for dynamically imported components ([#13564](https://github.com/sveltejs/kit/pull/13564))\n\n## 2.19.1\n### Patch Changes\n\n\n- fix: allow reroute to point to prerendered route ([#13575](https://github.com/sveltejs/kit/pull/13575))\n\n## 2.19.0\n### Minor Changes\n\n\n- feat: provide `fetch` to `reroute` ([#13549](https://github.com/sveltejs/kit/pull/13549))\n\n\n### Patch Changes\n\n\n- chore: cache reroute results ([#13548](https://github.com/sveltejs/kit/pull/13548))\n\n## 2.18.0\n### Minor Changes\n\n\n- feat: allow async `reroute` ([#13520](https://github.com/sveltejs/kit/pull/13520))\n\n\n- feat: provide `normalizeUrl` helper ([#13539](https://github.com/sveltejs/kit/pull/13539))\n\n\n### Patch Changes\n\n\n- fix: correct navigation history with hash router and ensure load functions are rerun on user changes to URL hash ([#13492](https://github.com/sveltejs/kit/pull/13492))\n\n\n- fix: include universal load assets as server assets ([#13531](https://github.com/sveltejs/kit/pull/13531))\n\n\n- fix: Include root layout and error nodes even when apps have only prerendered pages ([#13522](https://github.com/sveltejs/kit/pull/13522))\n\n\n- fix: correctly preload data on `mousedown`/`touchstart` if code was preloaded on hover ([#13530](https://github.com/sveltejs/kit/pull/13530))\n\n## 2.17.3\n### Patch Changes\n\n\n- fix: avoid simulated CORS errors with non-HTTP URLs ([#13493](https://github.com/sveltejs/kit/pull/13493))\n\n\n- fix: correctly preload links on `mousedown`/`touchstart` ([#13486](https://github.com/sveltejs/kit/pull/13486))\n\n\n- fix: load CSS when using server-side route resolution ([#13498](https://github.com/sveltejs/kit/pull/13498))\n\n\n- fix: correctly find shared entry-point CSS files during inlining ([#13431](https://github.com/sveltejs/kit/pull/13431))\n\n## 2.17.2\n### Patch Changes\n\n\n- fix: add promise return type to the `enhance` action callback ([#13420](https://github.com/sveltejs/kit/pull/13420))\n\n\n- fix: change server-side route resolution endpoint ([#13461](https://github.com/sveltejs/kit/pull/13461))\n\n## 2.17.1\n### Patch Changes\n\n\n- fix: make route resolution imports root-relative if `paths.relative` option is `false` ([#13412](https://github.com/sveltejs/kit/pull/13412))\n\n## 2.17.0\n### Minor Changes\n\n\n- feat: validate values for `cache-control` and `content-type` headers in dev mode ([#13114](https://github.com/sveltejs/kit/pull/13114))\n\n\n- feat: support server-side route resolution ([#13379](https://github.com/sveltejs/kit/pull/13379))\n\n\n### Patch Changes\n\n\n- chore: don't error during development when using `use:enhance` with `+server` as some third party libraries make it possible to POST forms to it ([#13397](https://github.com/sveltejs/kit/pull/13397))\n\n\n- fix: skip hooks for server fetch to prerendered routes ([#13377](https://github.com/sveltejs/kit/pull/13377))\n\n\n- fix: ignore non-entry-point CSS files during inlining ([#13395](https://github.com/sveltejs/kit/pull/13395))\n\n\n- fix: default server fetch to use prerendered paths ([#13377](https://github.com/sveltejs/kit/pull/13377))\n\n## 2.16.1\n### Patch Changes\n\n\n- fix: avoid overwriting headers for sub-requests made while loading the error page ([#13341](https://github.com/sveltejs/kit/pull/13341))\n\n\n- fix: correctly resolve index file entrypoints such as `src/service-worker/index.js` ([#13354](https://github.com/sveltejs/kit/pull/13354))\n\n\n- fix: correctly handle relative anchors when using the hash router ([#13356](https://github.com/sveltejs/kit/pull/13356))\n\n## 2.16.0\n### Minor Changes\n\n\n- feat: add ability to invalidate a custom identifier on `goto()` ([#13256](https://github.com/sveltejs/kit/pull/13256))\n\n\n- feat: remove the `postinstall` script to support pnpm 10 ([#13304](https://github.com/sveltejs/kit/pull/13304))\n  \n  NOTE: users should add `\"prepare\": \"svelte-kit sync`\" to their `package.json` in order to avoid the following warning upon first running Vite:\n  ```\n  ▲ [WARNING] Cannot find base config file \"./.svelte-kit/tsconfig.json\" [tsconfig.json]\n  \n      tsconfig.json:2:12:\n        2 │   \"extends\": \"./.svelte-kit/tsconfig.json\",\n          ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n  ```\n\n- feat: provide `PageProps` and `LayoutProps` types ([#13308](https://github.com/sveltejs/kit/pull/13308))\n\n\n### Patch Changes\n\n\n- perf: shorten chunk file names ([#13003](https://github.com/sveltejs/kit/pull/13003))\n\n\n- fix: strip internal data before passing URL to `reroute` ([#13092](https://github.com/sveltejs/kit/pull/13092))\n\n\n- fix: support absolute URLs and reroutes with `data-sveltekit-preload-code=\"viewport\"` ([#12217](https://github.com/sveltejs/kit/pull/12217))\n\n\n- fix: use current `window.fetch` for server load fetch requests ([#13315](https://github.com/sveltejs/kit/pull/13315))\n\n\n- fix: resolve symlinks when handling routes ([#12740](https://github.com/sveltejs/kit/pull/12740))\n\n\n- fix: prevent infinite reload when using the hash router and previewing `/index.html` ([#13296](https://github.com/sveltejs/kit/pull/13296))\n\n\n- fix: service worker base path in dev mode ([#12577](https://github.com/sveltejs/kit/pull/12577))\n\n\n- chore: error during development when using `use:enhance` with `+server` ([#13197](https://github.com/sveltejs/kit/pull/13197))\n\n\n- chore: add most common status codes to `redirect()` JS documentation ([#13301](https://github.com/sveltejs/kit/pull/13301))\n\n\n- fix: correctly link to assets inlined by the `inlineStyleThreshold` option ([#13068](https://github.com/sveltejs/kit/pull/13068))\n\n\n- fix: fall back to importing dynamic dependencies relative to SvelteKit package ([#12532](https://github.com/sveltejs/kit/pull/12532))\n\n\n- fix: use arrow function types over bound funcs ([#12955](https://github.com/sveltejs/kit/pull/12955))\n\n\n- fix: correctly navigate when hash router is enabled and the browser encodes extra hashes ([#13321](https://github.com/sveltejs/kit/pull/13321))\n\n## 2.15.3\n### Patch Changes\n\n\n- fix: fix race-condition when not using SSR when pressing back before initial load ([#12925](https://github.com/sveltejs/kit/pull/12925))\n\n\n- fix: remove \":$\" from virtual module ids to allow dev server to work with proxies ([#12157](https://github.com/sveltejs/kit/pull/12157))\n\n\n- fix: upgrade esm-env to remove warning when NODE_ENV is not set ([#13291](https://github.com/sveltejs/kit/pull/13291))\n\n\n- fix: handle `Redirect` thrown from root layout load function when client-side navigating to a non-existent page ([#12005](https://github.com/sveltejs/kit/pull/12005))\n\n\n- fix: make param matchers generated type import end with `.js` ([#13286](https://github.com/sveltejs/kit/pull/13286))\n\n## 2.15.2\n### Patch Changes\n\n\n- fix: correctly notify page store subscribers ([#13205](https://github.com/sveltejs/kit/pull/13205))\n\n\n- fix: prerender data when there is no server load but the `trailingSlash` option is set from the server ([#13262](https://github.com/sveltejs/kit/pull/13262))\n\n\n- fix: correctly remove navigation callbacks when returning function in onNavigate ([#13241](https://github.com/sveltejs/kit/pull/13241))\n\n## 2.15.1\n### Patch Changes\n\n\n- fix: add CSP hashes/nonces to inline styles when using `bundleStrategy: 'inline'` ([#13232](https://github.com/sveltejs/kit/pull/13232))\n\n\n- fix: silence dev/prod warning during sync ([#13244](https://github.com/sveltejs/kit/pull/13244))\n\n## 2.15.0\n### Minor Changes\n\n\n- feat: add `bundleStrategy: 'inline'` option ([#13193](https://github.com/sveltejs/kit/pull/13193))\n\n## 2.14.1\n### Patch Changes\n\n\n- fix: do not mutate URL during reroute logic ([#13222](https://github.com/sveltejs/kit/pull/13222))\n\n## 2.14.0\n### Minor Changes\n\n\n- feat: add hash-based routing option ([#13191](https://github.com/sveltejs/kit/pull/13191))\n\n\n### Patch Changes\n\n\n- fix: create new URL when calling `goto(...)`, to handle case where URL is mutated ([#13196](https://github.com/sveltejs/kit/pull/13196))\n\n## 2.13.0\n### Minor Changes\n\n\n- feat: add `bundleStrategy: 'split' | 'single'` option ([#13173](https://github.com/sveltejs/kit/pull/13173))\n\n## 2.12.2\n### Patch Changes\n\n\n- fix: correctly resolve no hooks file when a similarly named directory exists ([#13188](https://github.com/sveltejs/kit/pull/13188))\n\n\n- fix: correctly resolve `$app/state` on the server with Vite 5 ([#13192](https://github.com/sveltejs/kit/pull/13192))\n\n## 2.12.1\n### Patch Changes\n\n\n- fix: replace `navigating.current.<x>` with `navigating.<x>` ([#13174](https://github.com/sveltejs/kit/pull/13174))\n\n## 2.12.0\n### Minor Changes\n\n\n- feat: add `$app/state` module ([#13140](https://github.com/sveltejs/kit/pull/13140))\n\n\n### Patch Changes\n\n\n- chore: specify the route ID in the error message during development when making a form action request to a route without form actions ([#13167](https://github.com/sveltejs/kit/pull/13167))\n\n## 2.11.1\n### Patch Changes\n\n\n- fix: adhere to Vite `build.minify` setting when building the service worker ([#13143](https://github.com/sveltejs/kit/pull/13143))\n\n## 2.11.0\n### Minor Changes\n\n\n- feat: transport custom types across the server/client boundary ([#13149](https://github.com/sveltejs/kit/pull/13149))\n\n\n### Patch Changes\n\n\n- fix: correctly resolve hooks file when a similarly named directory exists ([#13144](https://github.com/sveltejs/kit/pull/13144))\n\n## 2.10.1\n### Patch Changes\n\n\n- fix: export `init` hook from `get_hooks` ([#13136](https://github.com/sveltejs/kit/pull/13136))\n\n## 2.10.0\n### Minor Changes\n\n\n- feat: server and client `init` hook ([#13103](https://github.com/sveltejs/kit/pull/13103))\n\n\n### Patch Changes\n\n\n- fix: prevent hooks exported from `hooks.js` from overwriting hooks from `hooks.server.js` ([#13104](https://github.com/sveltejs/kit/pull/13104))\n\n## 2.9.1\n### Patch Changes\n\n\n- fix: correctly match route groups preceding optional parameters ([#13099](https://github.com/sveltejs/kit/pull/13099))\n\n## 2.9.0\n### Minor Changes\n\n\n- feat: Vite 6 support ([#12270](https://github.com/sveltejs/kit/pull/12270))\n\n\n### Patch Changes\n\n\n- fix: transform link[rel='shortcut icon'] and link[rel='apple-touch-icon'] to be absolute to avoid console error when navigating ([#13077](https://github.com/sveltejs/kit/pull/13077))\n\n## 2.8.5\n### Patch Changes\n\n\n- fix: don't hydrate when falling back to error page ([#13056](https://github.com/sveltejs/kit/pull/13056))\n\n## 2.8.4\n### Patch Changes\n\n\n- fix: update inline css url generation for FOUC prevention in dev ([#13007](https://github.com/sveltejs/kit/pull/13007))\n\n## 2.8.3\n### Patch Changes\n\n\n- fix: ensure error messages are escaped ([#13050](https://github.com/sveltejs/kit/pull/13050))\n\n\n- fix: escape values included in dev 404 page ([#13039](https://github.com/sveltejs/kit/pull/13039))\n\n## 2.8.2\n### Patch Changes\n\n\n- fix: prevent duplicate fetch request when using Request with load function's fetch ([#13023](https://github.com/sveltejs/kit/pull/13023))\n\n\n- fix: do not override default cookie decoder to allow users to override the `cookie` library version ([#13037](https://github.com/sveltejs/kit/pull/13037))\n\n## 2.8.1\n### Patch Changes\n\n\n- fix: only add nonce to `script-src-elem`, `style-src-attr` and `style-src-elem` CSP directives when `unsafe-inline` is not present ([#11613](https://github.com/sveltejs/kit/pull/11613))\n\n\n- fix: support HTTP/2 in dev and production. Revert the changes from [#12907](https://github.com/sveltejs/kit/pull/12907) to downgrade HTTP/2 to TLS as now being unnecessary ([#12989](https://github.com/sveltejs/kit/pull/12989))\n\n## 2.8.0\n### Minor Changes\n\n\n- feat: add helper to identify `ActionFailure` objects ([#12878](https://github.com/sveltejs/kit/pull/12878))\n\n## 2.7.7\n### Patch Changes\n\n\n- fix: update link in JSDoc ([#12963](https://github.com/sveltejs/kit/pull/12963))\n\n## 2.7.6\n### Patch Changes\n\n\n- fix: update broken links in JSDoc ([#12960](https://github.com/sveltejs/kit/pull/12960))\n\n## 2.7.5\n### Patch Changes\n\n\n- fix: warn on invalid cookie name characters ([#12806](https://github.com/sveltejs/kit/pull/12806))\n\n\n- fix: when using `@vitejs/plugin-basic-ssl`, set a no-op proxy config to downgrade from HTTP/2 to TLS since `undici` does not yet enable HTTP/2 by default ([#12907](https://github.com/sveltejs/kit/pull/12907))\n\n## 2.7.4\n### Patch Changes\n\n\n- fix: ensure element is focused after subsequent clicks of the same hash link ([#12866](https://github.com/sveltejs/kit/pull/12866))\n\n\n- fix: avoid preload if event default was prevented for `touchstart` and `mousedown` events ([#12887](https://github.com/sveltejs/kit/pull/12887))\n\n\n- fix: avoid reloading behaviour for hash links with data-sveltekit-reload if the hash is on the same page ([#12866](https://github.com/sveltejs/kit/pull/12866))\n\n## 2.7.3\n### Patch Changes\n\n\n- fix: include importer in illegal import error message ([#12820](https://github.com/sveltejs/kit/pull/12820))\n\n\n- fix: don't try reading assets directly that aren't present ([#12876](https://github.com/sveltejs/kit/pull/12876))\n\n\n- fix: decode non-latin characters when previewing prerendered pages ([#12874](https://github.com/sveltejs/kit/pull/12874))\n\n\n- fix: better error message when a `Result` is returned from a form action ([#12829](https://github.com/sveltejs/kit/pull/12829))\n\n\n- docs: update URLs for new svelte.dev site ([#12857](https://github.com/sveltejs/kit/pull/12857))\n\n## 2.7.2\n### Patch Changes\n\n\n- fix: use absolute links in JSDoc comments ([#12718](https://github.com/sveltejs/kit/pull/12718))\n\n## 2.7.1\n### Patch Changes\n\n\n- chore: upgrade to sirv 3.0 ([#12796](https://github.com/sveltejs/kit/pull/12796))\n\n\n- fix: warn when form action responses are lost because SSR is off ([#12063](https://github.com/sveltejs/kit/pull/12063))\n\n## 2.7.0\n### Minor Changes\n\n\n- feat: update service worker when new version is detected ([#12448](https://github.com/sveltejs/kit/pull/12448))\n\n\n### Patch Changes\n\n\n- fix: correctly handle relative paths when fetching assets on the server ([#12113](https://github.com/sveltejs/kit/pull/12113))\n\n\n- fix: decode non ASCII anchor hashes when scrolling into view ([#12699](https://github.com/sveltejs/kit/pull/12699))\n\n\n- fix: page response missing CSP and Link headers when return promise in `load` ([#12418](https://github.com/sveltejs/kit/pull/12418))\n\n## 2.6.4\n### Patch Changes\n\n\n- fix: only preload links that have a different URL than the current page ([#12773](https://github.com/sveltejs/kit/pull/12773))\n\n\n- fix: revert change to replace version in generateBundle ([#12779](https://github.com/sveltejs/kit/pull/12779))\n\n\n- fix: catch stack trace fixing errors thrown in web containers ([#12775](https://github.com/sveltejs/kit/pull/12775))\n\n\n- fix: use absolute links in JSDoc comments ([#12772](https://github.com/sveltejs/kit/pull/12772))\n\n## 2.6.3\n### Patch Changes\n\n\n- fix: ensure a changing `version` doesn't affect the hashes for chunks without any actual code changes ([#12700](https://github.com/sveltejs/kit/pull/12700))\n\n\n- fix: prevent crash when logging URL search params in a server load function ([#12763](https://github.com/sveltejs/kit/pull/12763))\n\n\n- chore: revert update dependency cookie to ^0.7.0 ([#12767](https://github.com/sveltejs/kit/pull/12767))\n\n## 2.6.2\n### Patch Changes\n\n\n- chore(deps): update dependency cookie to ^0.7.0 ([#12746](https://github.com/sveltejs/kit/pull/12746))\n\n## 2.6.1\n### Patch Changes\n\n\n- fix: better error message when calling push/replaceState before router is initialized ([#11968](https://github.com/sveltejs/kit/pull/11968))\n\n## 2.6.0\n### Minor Changes\n\n\n- feat: support typed arrays in `load` functions ([#12716](https://github.com/sveltejs/kit/pull/12716))\n\n\n### Patch Changes\n\n\n- fix: open a new tab for `<form target=\"_blank\">` and `<button formtarget=\"_blank\"> submissions ([#11936](https://github.com/sveltejs/kit/pull/11936))\n\n## 2.5.28\n### Patch Changes\n\n\n- fix: import `node:process` instead of using globals ([#12641](https://github.com/sveltejs/kit/pull/12641))\n\n## 2.5.27\n### Patch Changes\n\n\n- fix: asynchronously instantiate components when using Svelte 5 ([#12613](https://github.com/sveltejs/kit/pull/12613))\n\n\n- fix: use `{@render ...}` tag when generating default fallback page for svelte 5 apps ([#12653](https://github.com/sveltejs/kit/pull/12653))\n\n\n- fix: emulate `event.platform` even when the route does not exist ([#12513](https://github.com/sveltejs/kit/pull/12513))\n\n## 2.5.26\n### Patch Changes\n\n\n- fix: exclude service worker directory from tsconfig ([#12196](https://github.com/sveltejs/kit/pull/12196))\n\n## 2.5.25\n### Patch Changes\n\n\n- chore: upgrade dts-buddy to 0.5.3 ([`6056ba30e29ac5747c356fbf1a42dd71f2c4aa1f`](https://github.com/sveltejs/kit/commit/6056ba30e29ac5747c356fbf1a42dd71f2c4aa1f))\n\n## 2.5.24\n### Patch Changes\n\n\n- extend peer dependency range for @sveltejs/vite-plugin-svelte to include 4.0.0-next for improved svelte5 support ([#12593](https://github.com/sveltejs/kit/pull/12593))\n\n## 2.5.23\n### Patch Changes\n\n\n- fix: use dynamic components in `root.svelte` instead of `svelte:component` for svelte 5 ([#12584](https://github.com/sveltejs/kit/pull/12584))\n\n## 2.5.22\n### Patch Changes\n\n\n- chore: configure provenance in a simpler manner ([#12570](https://github.com/sveltejs/kit/pull/12570))\n\n## 2.5.21\n### Patch Changes\n\n\n- chore: package provenance ([#12567](https://github.com/sveltejs/kit/pull/12567))\n\n## 2.5.20\n### Patch Changes\n\n\n- fix: set revalidate cache header on 404'd static assets ([#12530](https://github.com/sveltejs/kit/pull/12530))\n\n## 2.5.19\n### Patch Changes\n\n\n- fix: Svelte 5 - ignore `binding_non_reactive` warning in generated root component (you also need to update to `svelte@5.0.0-next.204`) ([#12524](https://github.com/sveltejs/kit/pull/12524))\n\n## 2.5.18\n### Patch Changes\n\n\n- fix: respect HTML attributes `enctype` and `formenctype` for forms with `use:enhance` ([#12198](https://github.com/sveltejs/kit/pull/12198))\n\n\n- fix: prevent client import error when a `hooks.server` file imports a private environment variable ([#12195](https://github.com/sveltejs/kit/pull/12195))\n\n\n- fix: set default `Content-Type` header to `application/x-www-form-urlencoded` for `POST` form submissions with `use:enhance` to align with native form behaviour ([#12198](https://github.com/sveltejs/kit/pull/12198))\n\n## 2.5.17\n\n### Patch Changes\n\n- chore: update package description ([#11846](https://github.com/sveltejs/kit/pull/11846))\n\n## 2.5.16\n\n### Patch Changes\n\n- fix: determine local Svelte version more reliably ([#12350](https://github.com/sveltejs/kit/pull/12350))\n\n## 2.5.15\n\n### Patch Changes\n\n- fix: always decode asset URLs ([#12352](https://github.com/sveltejs/kit/pull/12352))\n\n## 2.5.14\n\n### Patch Changes\n\n- fix: read non-encoded data URIs ([#12347](https://github.com/sveltejs/kit/pull/12347))\n\n## 2.5.13\n\n### Patch Changes\n\n- fix: decode asset URLs in dev when reading them, but for real this time ([#12344](https://github.com/sveltejs/kit/pull/12344))\n\n## 2.5.12\n\n### Patch Changes\n\n- fix: decode asset URLs in dev when reading them ([#12341](https://github.com/sveltejs/kit/pull/12341))\n\n## 2.5.11\n\n### Patch Changes\n\n- fix: hrefs that start with `config.prerender.origin` are now crawled ([#12277](https://github.com/sveltejs/kit/pull/12277))\n\n- chore: add keywords for discovery in npm search ([#12330](https://github.com/sveltejs/kit/pull/12330))\n\n- fix: handle whitespace in HTTP Accept header ([#12292](https://github.com/sveltejs/kit/pull/12292))\n\n## 2.5.10\n\n### Patch Changes\n\n- fix: exclude server files from optimizeDeps.entries ([#12242](https://github.com/sveltejs/kit/pull/12242))\n\n- fix: bump import-meta-resolve to remove deprecation warnings ([#12240](https://github.com/sveltejs/kit/pull/12240))\n\n## 2.5.9\n\n### Patch Changes\n\n- fix: yield main thread before navigating ([#12225](https://github.com/sveltejs/kit/pull/12225))\n\n- fix: correctly handle aliases to files in the `.svelte-kit` directory ([#12220](https://github.com/sveltejs/kit/pull/12220))\n\n## 2.5.8\n\n### Patch Changes\n\n- fix: prevent excessive Vite dependency optimizations on navigation ([#12182](https://github.com/sveltejs/kit/pull/12182))\n\n## 2.5.7\n\n### Patch Changes\n\n- chore(deps): update devalue to v5 ignore non-enumerable symbols during serialization ([#12141](https://github.com/sveltejs/kit/pull/12141))\n\n## 2.5.6\n\n### Patch Changes\n\n- fix: avoid incorrectly un- and re-escaping cookies collected during a server-side `fetch` ([#11904](https://github.com/sveltejs/kit/pull/11904))\n\n## 2.5.5\n\n### Patch Changes\n\n- fix: only hydrate when page is server-rendered ([#12050](https://github.com/sveltejs/kit/pull/12050))\n\n## 2.5.4\n\n### Patch Changes\n\n- fix: prevent navigation when `data-sveltekit-preload-data` fails to fetch due to network error ([#11944](https://github.com/sveltejs/kit/pull/11944))\n\n## 2.5.3\n\n### Patch Changes\n\n- fix: revert tsconfig change that includes svelte.config.js ([#11908](https://github.com/sveltejs/kit/pull/11908))\n\n- fix: exclude server worker from tsconfig again ([#11727](https://github.com/sveltejs/kit/pull/11727))\n\n## 2.5.2\n\n### Patch Changes\n\n- fix: tsconfig includes should cover svelte.config.js ([#11886](https://github.com/sveltejs/kit/pull/11886))\n\n## 2.5.1\n\n### Patch Changes\n\n- fix: prevent stale values after invalidation ([#11870](https://github.com/sveltejs/kit/pull/11870))\n\n- fix: prevent false positive `history.pushState` and `history.replaceState` warnings ([#11858](https://github.com/sveltejs/kit/pull/11858))\n\n- fix: relax status code types ([#11781](https://github.com/sveltejs/kit/pull/11781))\n\n- fix: `popstate` navigations take `pushState` navigations into account ([#11765](https://github.com/sveltejs/kit/pull/11765))\n\n## 2.5.0\n\n### Minor Changes\n\n- feat: dev/preview/prerender platform emulation ([#11730](https://github.com/sveltejs/kit/pull/11730))\n\n### Patch Changes\n\n- fix: strip `/@fs` prefix correctly on Windows when invoking `read()` in dev mode ([#11728](https://github.com/sveltejs/kit/pull/11728))\n\n## 2.4.3\n\n### Patch Changes\n\n- fix: only disallow body with GET/HEAD ([#11710](https://github.com/sveltejs/kit/pull/11710))\n\n## 2.4.2\n\n### Patch Changes\n\n- fix: ignore bodies sent with non-PUT/PATCH/POST requests ([#11708](https://github.com/sveltejs/kit/pull/11708))\n\n## 2.4.1\n\n### Patch Changes\n\n- fix: use Vite's default value for `build.target` and respect override supplied by user ([#11688](https://github.com/sveltejs/kit/pull/11688))\n\n- fix: properly decode base64 strings inside `read` ([#11682](https://github.com/sveltejs/kit/pull/11682))\n\n- fix: default route config to `{}` for feature checking ([#11685](https://github.com/sveltejs/kit/pull/11685))\n\n- fix: handle `onNavigate` callbacks correctly ([#11678](https://github.com/sveltejs/kit/pull/11678))\n\n## 2.4.0\n\n### Minor Changes\n\n- feat: add `$app/server` module with `read` function for reading assets from filesystem ([#11649](https://github.com/sveltejs/kit/pull/11649))\n\n## 2.3.5\n\n### Patch Changes\n\n- fix: log a warning if fallback page overwrites prerendered page ([#11661](https://github.com/sveltejs/kit/pull/11661))\n\n## 2.3.4\n\n### Patch Changes\n\n- fix: don't stash away original `history` methods so other libs can monkeypatch it ([#11657](https://github.com/sveltejs/kit/pull/11657))\n\n## 2.3.3\n\n### Patch Changes\n\n- fix: remove internal `__sveltekit/` module declarations from types ([#11620](https://github.com/sveltejs/kit/pull/11620))\n\n## 2.3.2\n\n### Patch Changes\n\n- fix: return plaintext 404 for anything under appDir ([#11597](https://github.com/sveltejs/kit/pull/11597))\n\n- fix: populate dynamic public env without using top-level await, which fails in Safari ([#11601](https://github.com/sveltejs/kit/pull/11601))\n\n## 2.3.1\n\n### Patch Changes\n\n- fix: amend onNavigate type ([#11599](https://github.com/sveltejs/kit/pull/11599))\n\n- fix: better error message when peer dependency cannot be found ([#11598](https://github.com/sveltejs/kit/pull/11598))\n\n## 2.3.0\n\n### Minor Changes\n\n- feat: add `reroute` hook ([#11537](https://github.com/sveltejs/kit/pull/11537))\n\n## 2.2.2\n\n### Patch Changes\n\n- fix: only add nonce to `style-src` CSP directive when `unsafe-inline` is not present ([#11575](https://github.com/sveltejs/kit/pull/11575))\n\n## 2.2.1\n\n### Patch Changes\n\n- feat: add CSP support for style-src-elem ([#11562](https://github.com/sveltejs/kit/pull/11562))\n\n- fix: address CSP conflicts with sha/nonce during dev ([#11562](https://github.com/sveltejs/kit/pull/11562))\n\n## 2.2.0\n\n### Minor Changes\n\n- feat: expose `$env/static/public` in service workers ([#10994](https://github.com/sveltejs/kit/pull/10994))\n\n### Patch Changes\n\n- fix: reload page on startup if `document.URL` contains credentials ([#11179](https://github.com/sveltejs/kit/pull/11179))\n\n## 2.1.2\n\n### Patch Changes\n\n- fix: restore invalid route error message during build process ([#11559](https://github.com/sveltejs/kit/pull/11559))\n\n## 2.1.1\n\n### Patch Changes\n\n- fix: respect the trailing slash option when navigating from the basepath root page ([#11388](https://github.com/sveltejs/kit/pull/11388))\n\n- chore: shrink error messages shipped to client ([#11551](https://github.com/sveltejs/kit/pull/11551))\n\n## 2.1.0\n\n### Minor Changes\n\n- feat: make client router treeshakeable ([#11340](https://github.com/sveltejs/kit/pull/11340))\n\n### Patch Changes\n\n- chore: reduce client bundle size ([#11547](https://github.com/sveltejs/kit/pull/11547))\n\n## 2.0.8\n\n### Patch Changes\n\n- fix: always scroll to top when clicking a # or #top link ([`099608c428a49504785eab3afe3b2e76a9317bdf`](https://github.com/sveltejs/kit/commit/099608c428a49504785eab3afe3b2e76a9317bdf))\n\n- fix: add nonce or hash to \"script-src-elem\", \"style-src-attr\" and \"style-src-elem\" if defined in CSP config ([#11485](https://github.com/sveltejs/kit/pull/11485))\n\n- fix: decode server data with `stream: true` during client-side navigation ([#11409](https://github.com/sveltejs/kit/pull/11409))\n\n- fix: capture scroll position when using `pushState` ([#11540](https://github.com/sveltejs/kit/pull/11540))\n\n- chore: use peer dependencies when linked ([#11433](https://github.com/sveltejs/kit/pull/11433))\n\n## 2.0.7\n\n### Patch Changes\n\n- chore: removed deprecated config.package type ([#11462](https://github.com/sveltejs/kit/pull/11462))\n\n## 2.0.6\n\n### Patch Changes\n\n- fix: allow dynamic env access when building but not prerendering ([#11436](https://github.com/sveltejs/kit/pull/11436))\n\n## 2.0.5\n\n### Patch Changes\n\n- fix: render SPA shell when SSR is turned off and there is no server data ([#11405](https://github.com/sveltejs/kit/pull/11405))\n\n- fix: upgrade `sirv` and `mrmime` to modernize javascript mime type ([#11419](https://github.com/sveltejs/kit/pull/11419))\n\n## 2.0.4\n\n### Patch Changes\n\n- chore: update primary branch from master to main ([`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d))\n\n- fix: adjust missing inner content warning ([#11394](https://github.com/sveltejs/kit/pull/11394))\n\n- fix: prevent esbuild adding phantom exports to service worker ([#11400](https://github.com/sveltejs/kit/pull/11400))\n\n- fix: goto type include state ([#11398](https://github.com/sveltejs/kit/pull/11398))\n\n- fix: ensure assets are served gzip in preview ([#11377](https://github.com/sveltejs/kit/pull/11377))\n\n## 2.0.3\n\n### Patch Changes\n\n- fix: reinstantiate state parameter for goto ([#11342](https://github.com/sveltejs/kit/pull/11342))\n\n## 2.0.2\n\n### Patch Changes\n\n- fix: prevent endless SPA 404 loop ([#11354](https://github.com/sveltejs/kit/pull/11354))\n\n## 2.0.1\n\n### Patch Changes\n\n- fix: correctly handle trailing slash redirect when navigating from the root page ([#11357](https://github.com/sveltejs/kit/pull/11357))\n\n## 2.0.0\n\n### Major Changes\n\n- breaking: remove top-level promise awaiting ([#11176](https://github.com/sveltejs/kit/pull/11176))\n\n- breaking: prevent use of dynamic env vars during prerendering, serve env vars dynamically ([#11277](https://github.com/sveltejs/kit/pull/11277))\n\n- breaking: remove deprecated `use:enhance` callback values ([#11282](https://github.com/sveltejs/kit/pull/11282))\n\n- breaking: turn `error` and `redirect` into commands ([#11165](https://github.com/sveltejs/kit/pull/11165))\n\n- breaking: the type for `depends` now requires a `:` as part of the string ([#11201](https://github.com/sveltejs/kit/pull/11201))\n\n- breaking: remove baseUrl fallback from generated tsconfig ([#11294](https://github.com/sveltejs/kit/pull/11294))\n\n- breaking: fail if route with +page and +server is marked prerenderable ([#11256](https://github.com/sveltejs/kit/pull/11256))\n\n- breaking: remove `resolvePath` in favour of `resolveRoute` from `$app/paths` ([#11265](https://github.com/sveltejs/kit/pull/11265))\n\n- breaking: drop support for Svelte 3 ([#11168](https://github.com/sveltejs/kit/pull/11168))\n\n- breaking: require Vite 5.0.3+ ([#11122](https://github.com/sveltejs/kit/pull/11122))\n\n- breaking: generate `__data.json` files as sibling to `.html` files ([#11269](https://github.com/sveltejs/kit/pull/11269))\n\n- breaking: fail if +page and +server have mismatched config ([#11256](https://github.com/sveltejs/kit/pull/11256))\n\n- breaking: error if form without multipart/form-data enctype contains a file input ([#11282](https://github.com/sveltejs/kit/pull/11282))\n\n- breaking: require paths pass to preloadCode to be prefixed with basepath ([#11259](https://github.com/sveltejs/kit/pull/11259))\n\n- breaking: `@sveltejs/vite-plugin-svelte` is now a peer dependency and will need to be installed in each project using SvelteKit ([#11184](https://github.com/sveltejs/kit/pull/11184))\n\n- breaking: stop re-exporting vitePreprocess ([#11297](https://github.com/sveltejs/kit/pull/11297))\n\n- breaking: require path option when setting/deleting/serializing cookies ([#11240](https://github.com/sveltejs/kit/pull/11240))\n\n- breaking: tighten up error handling ([#11289](https://github.com/sveltejs/kit/pull/11289))\n\n- breaking: remove state option from goto in favor of shallow routing ([#11307](https://github.com/sveltejs/kit/pull/11307))\n\n- breaking: disallow external navigation with `goto` ([#11207](https://github.com/sveltejs/kit/pull/11207))\n\n- breaking: upgrade to TypeScript 5. Default `moduleResolution` to `bundler` in user projects to be permissive in consuming and `NodeNext` when running `package` to be strict in distributing ([#11160](https://github.com/sveltejs/kit/pull/11160))\n\n- breaking: undefined is no longer a valid value for paths.relative ([#11185](https://github.com/sveltejs/kit/pull/11185))\n\n- breaking: require Node 18.13 or newer ([#11172](https://github.com/sveltejs/kit/pull/11172))\n\n- breaking: fix path resolution ([#11276](https://github.com/sveltejs/kit/pull/11276))\n\n- breaking: remove `dangerZone.trackServerFetches` ([#11235](https://github.com/sveltejs/kit/pull/11235))\n\n### Minor Changes\n\n- feat: add untrack to load ([#11311](https://github.com/sveltejs/kit/pull/11311))\n\n- feat: implement shallow routing ([#11307](https://github.com/sveltejs/kit/pull/11307))\n\n- feat: provide SvelteKit html typings ([#11222](https://github.com/sveltejs/kit/pull/11222))\n\n- feat: redact internal stack trace when reporting config errors ([#11292](https://github.com/sveltejs/kit/pull/11292))\n\n- feat: allow for fine grained invalidation of search params ([#11258](https://github.com/sveltejs/kit/pull/11258))\n\n### Patch Changes\n\n- fix: prerender optional parameters as empty when `entries` contains `'*'` ([#11178](https://github.com/sveltejs/kit/pull/11178))\n\n- fix: resolve route config correctly ([#11256](https://github.com/sveltejs/kit/pull/11256))\n\n- fix: import Svelte types from svelte/compiler ([#11188](https://github.com/sveltejs/kit/pull/11188))\n\n- fix: reset invalid resources after a successful invalidation ([#11268](https://github.com/sveltejs/kit/pull/11268))\n\n- fix: Adjust fail method and ActionFailure type ([#11260](https://github.com/sveltejs/kit/pull/11260))\n\n- chore(deps): upgrade cookies dependency ([#11189](https://github.com/sveltejs/kit/pull/11189))\n\n## 1.30.3\n\n### Patch Changes\n\n- fix: correct documentation for beforeNavigate ([#11300](https://github.com/sveltejs/kit/pull/11300))\n\n## 1.30.2\n\n### Patch Changes\n\n- fix: revert recent 'correctly return 415' and 'correctly return 404' changes ([#11295](https://github.com/sveltejs/kit/pull/11295))\n\n## 1.30.1\n\n### Patch Changes\n\n- fix: prerendered root page with `paths.base` config uses correct trailing slash option ([#10763](https://github.com/sveltejs/kit/pull/10763))\n\n- fix: correctly return 404 when a form action is not found ([#11278](https://github.com/sveltejs/kit/pull/11278))\n\n## 1.30.0\n\n### Minor Changes\n\n- feat: inline `response.arrayBuffer()` during ssr ([#10535](https://github.com/sveltejs/kit/pull/10535))\n\n### Patch Changes\n\n- fix: allow `\"false\"` value for preload link options ([#10555](https://github.com/sveltejs/kit/pull/10555))\n\n- fix: call worker `unref` instead of `terminate` ([#10120](https://github.com/sveltejs/kit/pull/10120))\n\n- fix: correctly analyse exported server API methods during build ([#11019](https://github.com/sveltejs/kit/pull/11019))\n\n- fix: avoid error when back navigating before page is initialized ([#10636](https://github.com/sveltejs/kit/pull/10636))\n\n- fix: allow service-worker.js to import assets ([#9285](https://github.com/sveltejs/kit/pull/9285))\n\n- fix: distinguish better between not-found and internal-error ([#11131](https://github.com/sveltejs/kit/pull/11131))\n\n## 1.29.1\n\n### Patch Changes\n\n- fix: correctly return 415 when unexpected content types are submitted to actions ([#11255](https://github.com/sveltejs/kit/pull/11255))\n\n- chore: deprecate `preloadCode` calls with multiple arguments ([#11266](https://github.com/sveltejs/kit/pull/11266))\n\n## 1.29.0\n\n### Minor Changes\n\n- feat: add `resolveRoute` to `$app/paths`, deprecate `resolvePath` ([#11261](https://github.com/sveltejs/kit/pull/11261))\n\n## 1.28.0\n\n### Minor Changes\n\n- chore: deprecate top level promise await behaviour ([#11175](https://github.com/sveltejs/kit/pull/11175))\n\n### Patch Changes\n\n- fix: resolve relative cookie paths before storing ([#11253](https://github.com/sveltejs/kit/pull/11253))\n\n- chore: deprecate cookies.set/delete without path option ([#11237](https://github.com/sveltejs/kit/pull/11237))\n\n- fix: make sure promises from fetch handle errors ([#11228](https://github.com/sveltejs/kit/pull/11228))\n\n## 1.27.7\n\n### Patch Changes\n\n- fix: set runes option in generated root ([#11111](https://github.com/sveltejs/kit/pull/11111))\n\n- fix: retain URL query string for trailing slash redirects to prerendered pages ([#11142](https://github.com/sveltejs/kit/pull/11142))\n\n## 1.27.6\n\n### Patch Changes\n\n- fix: use runes in generated root when detecting Svelte 5 ([#11028](https://github.com/sveltejs/kit/pull/11028))\n\n- fix: correctly prerender pages that use browser globals and have SSR turned off ([#11032](https://github.com/sveltejs/kit/pull/11032))\n\n- fix: correctly show 404 for prerendered dynamic routes when navigating client-side without a root layout server load ([#11025](https://github.com/sveltejs/kit/pull/11025))\n\n## 1.27.5\n\n### Patch Changes\n\n- fix: add vite.config.js to included files in generated tsconfig ([#10788](https://github.com/sveltejs/kit/pull/10788))\n\n- fix: cache location.origin on startup ([#11004](https://github.com/sveltejs/kit/pull/11004))\n\n## 1.27.4\n\n### Patch Changes\n\n- fix: generate `__data.json` for prerendered pages when SSR is turned off ([#10988](https://github.com/sveltejs/kit/pull/10988))\n\n- chore: add experimental compatibility for Svelte 5 ([#11002](https://github.com/sveltejs/kit/pull/11002))\n\n## 1.27.3\n\n### Patch Changes\n\n- fix: use correct environment file for rendering spa fallback page ([#10963](https://github.com/sveltejs/kit/pull/10963))\n\n## 1.27.2\n\n### Patch Changes\n\n- fix: missing `File` Node polyfill for Node version 18.11.0+ ([#10948](https://github.com/sveltejs/kit/pull/10948))\n\n## 1.27.1\n\n### Patch Changes\n\n- fix: only apply some polyfills below node 18.11 ([#10920](https://github.com/sveltejs/kit/pull/10920))\n\n## 1.27.0\n\n### Minor Changes\n\n- feat: add `invalidateAll` boolean option to `enhance` callback ([#9889](https://github.com/sveltejs/kit/pull/9889))\n\n## 1.26.0\n\n### Minor Changes\n\n- feat: infer route parameter type from matcher's guard check if applicable ([#10755](https://github.com/sveltejs/kit/pull/10755))\n\n### Patch Changes\n\n- fix: basic mime type handling for prerendered pages in preview ([#10851](https://github.com/sveltejs/kit/pull/10851))\n\n- chore: use just a single library (mrmime) for mime type handling ([#10851](https://github.com/sveltejs/kit/pull/10851))\n\n- chore: bump undici to address security issue ([#10885](https://github.com/sveltejs/kit/pull/10885))\n\n- fix: follow whatwg fetch spec for handling redirect loops ([#10857](https://github.com/sveltejs/kit/pull/10857))\n\n- fix: use `window.fetch` in `load` functions to allow libraries to patch it ([#10009](https://github.com/sveltejs/kit/pull/10009))\n\n- chore(deps): update dependency undici to ~5.26.0 ([#10860](https://github.com/sveltejs/kit/pull/10860))\n\n## 1.25.2\n\n### Patch Changes\n\n- fix: correctly update `$page.url.hash` when navigating history ([#10843](https://github.com/sveltejs/kit/pull/10843))\n\n- fix: strip virtual module prefix from error messages ([#10776](https://github.com/sveltejs/kit/pull/10776))\n\n- fix: cancel ongoing navigation when the browser back button is hit to prevent an incorrect page from being rendered ([#10727](https://github.com/sveltejs/kit/pull/10727))\n\n- fix: only remove Vite manifest when copying files ([#10782](https://github.com/sveltejs/kit/pull/10782))\n\n## 1.25.1\n\n### Patch Changes\n\n- fix: correct line numbers in stack trace ([#10769](https://github.com/sveltejs/kit/pull/10769))\n\n- fix: correctly return 404 when navigating to a missing page and the root layout fetches a prerendered endpoint ([#10565](https://github.com/sveltejs/kit/pull/10565))\n\n- fix: allow optional param in middle of route ([#10736](https://github.com/sveltejs/kit/pull/10736))\n\n- chore: update `undici` ([#10641](https://github.com/sveltejs/kit/pull/10641))\n\n## 1.25.0\n\n### Minor Changes\n\n- feat: add server endpoint catch-all method handler `fallback` ([#9755](https://github.com/sveltejs/kit/pull/9755))\n\n### Patch Changes\n\n- fix: allow calling `fetch` for any scheme ([#10699](https://github.com/sveltejs/kit/pull/10699))\n\n## 1.24.1\n\n### Patch Changes\n\n- fix: mark aborted/cancelled navigation as handled ([#10666](https://github.com/sveltejs/kit/pull/10666))\n\n## 1.24.0\n\n### Minor Changes\n\n- feat: onNavigate lifecycle function ([#9605](https://github.com/sveltejs/kit/pull/9605))\n\n### Patch Changes\n\n- fix: Use Proxy to track usage of client side load `event.route` ([#10576](https://github.com/sveltejs/kit/pull/10576))\n\n## 1.23.1\n\n### Patch Changes\n\n- fix: process globs in `pkg.workspaces` ([#10625](https://github.com/sveltejs/kit/pull/10625))\n\n## 1.23.0\n\n### Minor Changes\n\n- feat: add warning for mistyped route filenames ([#10558](https://github.com/sveltejs/kit/pull/10558))\n\n- feat: accept `URL` in `redirect` ([#10570](https://github.com/sveltejs/kit/pull/10570))\n\n### Patch Changes\n\n- fix: adjust the type of `Navigation[\"type\"]` ([#10599](https://github.com/sveltejs/kit/pull/10599))\n\n- fix: allow logging `$page.url` during prerendering ([#10567](https://github.com/sveltejs/kit/pull/10567))\n\n## 1.22.6\n\n### Patch Changes\n\n- fix: correctly restore trailing slash in url pathname for data requests ([#10475](https://github.com/sveltejs/kit/pull/10475))\n\n- fix: load trailing slash option from server even when there's no load function ([#10475](https://github.com/sveltejs/kit/pull/10475))\n\n## 1.22.5\n\n### Patch Changes\n\n- fix: make server assets available during `vite preview` ([#10511](https://github.com/sveltejs/kit/pull/10511))\n\n- chore: upgrade `undici` to 5.23.0 ([#10240](https://github.com/sveltejs/kit/pull/10240))\n\n## 1.22.4\n\n### Patch Changes\n\n- fix: prevent duplicate module preload ([#10442](https://github.com/sveltejs/kit/pull/10442))\n\n- docs: Elaborate on credentialed `fetch` behaviour ([#10421](https://github.com/sveltejs/kit/pull/10421))\n\n## 1.22.3\n\n### Patch Changes\n\n- fix: gracefully handle server endpoints that return `Response`s with immutable `Headers` ([#10367](https://github.com/sveltejs/kit/pull/10367))\n\n## 1.22.2\n\n### Patch Changes\n\n- fix: wait a tick before announcing new page title ([#10363](https://github.com/sveltejs/kit/pull/10363))\n\n- feat: more helpful error for preview if build output doesn't exist ([#10337](https://github.com/sveltejs/kit/pull/10337))\n\n## 1.22.1\n\n### Patch Changes\n\n- perf: only have Vite generate relative paths when required ([#10287](https://github.com/sveltejs/kit/pull/10287))\n\n## 1.22.0\n\n### Minor Changes\n\n- feat: add `HEAD` server method ([#9753](https://github.com/sveltejs/kit/pull/9753))\n\n- feat: support caching of responses with `Vary` header (except for `Vary: *`) ([#9993](https://github.com/sveltejs/kit/pull/9993))\n\n### Patch Changes\n\n- fix: avoid running load function on invalid requests ([#9752](https://github.com/sveltejs/kit/pull/9752))\n\n- fix: update page store when URL hash is changed from the address bar ([#10202](https://github.com/sveltejs/kit/pull/10202))\n\n- fix: include `Vary: Accept` header to fix browser caching of adjacent pages and endpoints ([#9993](https://github.com/sveltejs/kit/pull/9993))\n\n## 1.21.0\n\n### Minor Changes\n\n- feat: add `event.isSubRequest` boolean indicating whether this is a call to one of the app's own APIs during SSR (or prerendering) ([#10170](https://github.com/sveltejs/kit/pull/10170))\n\n- feat: add `privatePrefix` to `config.kit.env` ([#9996](https://github.com/sveltejs/kit/pull/9996))\n\n- feat: export `VERSION` from `@sveltejs/kit` ([#9969](https://github.com/sveltejs/kit/pull/9969))\n\n### Patch Changes\n\n- docs: update inline NavigationType documentation ([#10269](https://github.com/sveltejs/kit/pull/10269))\n\n- perf: cache dynamic imports of nodes ([#10080](https://github.com/sveltejs/kit/pull/10080))\n\n## 1.20.5\n\n### Patch Changes\n\n- fix: batch synchronous invalidate invocations ([#10145](https://github.com/sveltejs/kit/pull/10145))\n\n- fix: allow rest params to be empty in resolvePath ([#10146](https://github.com/sveltejs/kit/pull/10146))\n\n- fix: correctly close dialogs when form is enhanced ([#10093](https://github.com/sveltejs/kit/pull/10093))\n\n- fix: precompress filter ([#10185](https://github.com/sveltejs/kit/pull/10185))\n\n## 1.20.4\n\n### Patch Changes\n\n- fix: remove reference to tiny-glob from postinstall script ([#10174](https://github.com/sveltejs/kit/pull/10174))\n\n## 1.20.3\n\n### Patch Changes\n\n- chore: remove `tiny-glob` as a dependency ([#10166](https://github.com/sveltejs/kit/pull/10166))\n\n- fix: don't import types from `svelte/internal` ([#10172](https://github.com/sveltejs/kit/pull/10172))\n\n- fix: don't skip rest parameter's matcher when there is a non-matching optional parameter ([#10020](https://github.com/sveltejs/kit/pull/10020))\n\n- fix: ensure `fetch` respects headers from provided `Request` ([#10136](https://github.com/sveltejs/kit/pull/10136))\n\n## 1.20.2\n\n### Patch Changes\n\n- fix: ensure optional routes with matchers and catch-all match correctly ([#9987](https://github.com/sveltejs/kit/pull/9987))\n\n- fix: disallow `actions` export from a `+layout.server` file ([#10046](https://github.com/sveltejs/kit/pull/10046))\n\n- fix: remove scrollbars from default error page ([#10059](https://github.com/sveltejs/kit/pull/10059))\n\n## 1.20.1\n\n### Patch Changes\n\n- fix: don't copy public folder in service worker build ([#10082](https://github.com/sveltejs/kit/pull/10082))\n\n## 1.20.0\n\n### Minor Changes\n\n- feat: support Svelte 4 ([#10048](https://github.com/sveltejs/kit/pull/10048))\n\n## 1.19.0\n\n### Minor Changes\n\n- feat: allow link options to be set to `\"true\"` and `\"false\"` ([#10039](https://github.com/sveltejs/kit/pull/10039))\n\n- feat: add `resolvePath` export for building relative paths from route IDs and parameters ([#9949](https://github.com/sveltejs/kit/pull/9949))\n\n### Patch Changes\n\n- fix: prevent history change when clicking same hash link ([#10032](https://github.com/sveltejs/kit/pull/10032))\n\n- fix: gracefully handle server endpoints that return `Response`s with immutable `Headers` when prerendering ([#10030](https://github.com/sveltejs/kit/pull/10030))\n\n- fix: do not add content-security-policy meta element if content is empty ([#10026](https://github.com/sveltejs/kit/pull/10026))\n\n- docs: correct `ResolveOptions['preload']` inline documentation ([#10037](https://github.com/sveltejs/kit/pull/10037))\n\n- fix: avoid creating update check timer on the server ([#10015](https://github.com/sveltejs/kit/pull/10015))\n\n## 1.18.0\n\n### Minor Changes\n\n- security: Stop implicitly tracking URLs as dependencies in server-side `load`s ([#9945](https://github.com/sveltejs/kit/pull/9945))\n\n## 1.17.1\n\n### Patch Changes\n\n- fix: ensure styles are loaded in dev mode for routes containing special characters ([#9894](https://github.com/sveltejs/kit/pull/9894))\n\n- feat: warn users when enhancing forms with files but no `enctype=\"multipart/form-data\"` ([#9888](https://github.com/sveltejs/kit/pull/9888))\n\n## 1.17.0\n\n### Minor Changes\n\n- feat: unshadow `data` and `form` in `enhance` and warn about future deprecation when used in `dev` mode ([#9902](https://github.com/sveltejs/kit/pull/9902))\n\n- feat: crawl URLs in `<meta>` tags ([#9900](https://github.com/sveltejs/kit/pull/9900))\n\n### Patch Changes\n\n- fix: avoid trying to inline raw or url css imports ([#9925](https://github.com/sveltejs/kit/pull/9925))\n\n- feat: prerender in worker rather than subprocess to support Deno ([#9919](https://github.com/sveltejs/kit/pull/9919))\n\n- perf: add `<script>` to prerendered redirects for faster redirects ([#9911](https://github.com/sveltejs/kit/pull/9911))\n\n- fix: add typing for `vitePlugin` to `Config` ([#9946](https://github.com/sveltejs/kit/pull/9946))\n\n- fix: stop setting Kit cookie defaults on cookies parsed from headers ([#9908](https://github.com/sveltejs/kit/pull/9908))\n\n- fix: only skip hydration with vite overlay if current page is an error ([#9892](https://github.com/sveltejs/kit/pull/9892))\n\n## 1.16.3\n\n### Patch Changes\n\n- fix: entry generation with mixed segments ([#9879](https://github.com/sveltejs/kit/pull/9879))\n\n- fix: use `focusVisible: false` to prevent unwanted focus ring on navigation ([#9861](https://github.com/sveltejs/kit/pull/9861))\n\n## 1.16.2\n\n### Patch Changes\n\n- fix: support Node 20 ([`6e2efcf62`](https://github.com/sveltejs/kit/commit/6e2efcf627ce8d179c941212d761aa93568b1724))\n\n- fix: reset focus synchronously on navigation ([#9837](https://github.com/sveltejs/kit/pull/9837))\n\n## 1.16.1\n\n### Patch Changes\n\n- fix: realign state.branch on the client on first load ([#9754](https://github.com/sveltejs/kit/pull/9754))\n\n- fix: update `$page.data` correctly after invalidate ([#9798](https://github.com/sveltejs/kit/pull/9798))\n\n- fix: file not found in manifest ([#9846](https://github.com/sveltejs/kit/pull/9846))\n\n## 1.16.0\n\n### Minor Changes\n\n- feat: route-level entry generators via `export const entries` ([#9571](https://github.com/sveltejs/kit/pull/9571))\n\n## 1.15.11\n\n### Patch Changes\n\n- chore: more compact representation for invalidated search param ([#9708](https://github.com/sveltejs/kit/pull/9708))\n\n- chore: fix import path to app script on windows ([#9743](https://github.com/sveltejs/kit/pull/9743))\n\n- fix: make $app/navigation more resilient to bundler reordering ([#9808](https://github.com/sveltejs/kit/pull/9808))\n\n- fix: page load `fetch()` now accepts the same input types for the body as the native fetch function ([#9801](https://github.com/sveltejs/kit/pull/9801))\n\n- fix: handle preload and filterSerializedResponseHeaders in sequence function ([#9741](https://github.com/sveltejs/kit/pull/9741))\n\n## 1.15.10\n\n### Patch Changes\n\n- fix: log whole error object in default handleError ([#9791](https://github.com/sveltejs/kit/pull/9791))\n\n## 1.15.9\n\n### Patch Changes\n\n- fix: correctly replace state when `data-sveltekit-replacestate` is used with a hash link ([#9751](https://github.com/sveltejs/kit/pull/9751))\n\n- fix: compute trailing slash on page server / data request ([#9738](https://github.com/sveltejs/kit/pull/9738))\n\n- fix: update vite-plugin-svelte to fix windows resolution issue ([#9769](https://github.com/sveltejs/kit/pull/9769))\n\n## 1.15.8\n\n### Patch Changes\n\n- chore: revert undici pin and upgrade version ([#9740](https://github.com/sveltejs/kit/pull/9740))\n\n- chore: upgrade vite-plugin-svelte for resolve improvements and warnings ([#9742](https://github.com/sveltejs/kit/pull/9742))\n\n## 1.15.7\n\n### Patch Changes\n\n- fix: provide better error when prerendered routes conflict with each other ([#9692](https://github.com/sveltejs/kit/pull/9692))\n\n- fix: prevent false positive warnings for fetch in Firefox and Safari ([#9680](https://github.com/sveltejs/kit/pull/9680))\n\n- fix: allow embedding two pages generated into the same page in \"embedded\" mode ([#9610](https://github.com/sveltejs/kit/pull/9610))\n\n- fix: don't include prerendered routes in default generateManifest ([#9471](https://github.com/sveltejs/kit/pull/9471))\n\n- fix: better error messages for handleable prerender failures ([#9621](https://github.com/sveltejs/kit/pull/9621))\n\n## 1.15.6\n\n### Patch Changes\n\n- fix: use correct relative paths when rendering base path ([#9343](https://github.com/sveltejs/kit/pull/9343))\n\n- fix: handle redirect thrown in handle hook in response to form action ([#9658](https://github.com/sveltejs/kit/pull/9658))\n\n- fix: do not call beforeNavigate for download links ([#9660](https://github.com/sveltejs/kit/pull/9660))\n\n## 1.15.5\n\n### Patch Changes\n\n- fix: correct allow header methods list for 405s ([#9655](https://github.com/sveltejs/kit/pull/9655))\n\n- fix: prevent routes/layouts from having conflicting files through resets or different extensions ([#9590](https://github.com/sveltejs/kit/pull/9590))\n\n- fix: prevent unhandled exceptions for invalid header values ([#9638](https://github.com/sveltejs/kit/pull/9638))\n\n## 1.15.4\n\n### Patch Changes\n\n- fix: gracefully handle failure to load hooks.server.js ([#9641](https://github.com/sveltejs/kit/pull/9641))\n\n- feat: set sourcemapIgnoreList to filter out non-source directories ([#9619](https://github.com/sveltejs/kit/pull/9619))\n\n## 1.15.3\n\n### Patch Changes\n\n- fix: prevent building duplicate CSS files ([#9382](https://github.com/sveltejs/kit/pull/9382))\n\n## 1.15.2\n\n### Patch Changes\n\n- fix: address security advisory [CVE-2023-29008](https://github.com/sveltejs/kit/security/advisories/GHSA-gv7g-x59x-wf8f) by doing a case-insensitive comparison when checking header value ([`ba436c66`](https://github.com/sveltejs/kit/commit/ba436c6685e751d968a960fbda65f24cf7a82e9f))\n\n## 1.15.1\n\n### Patch Changes\n\n- fix: pin undici to 5.20.0 ([#9591](https://github.com/sveltejs/kit/pull/9591))\n\n- fix: address security advisory [CVE-2023-29003](https://github.com/sveltejs/kit/security/advisories/GHSA-5p75-vc5g-8rv2) by including `text/plain` and `PUT`/`PATCH`/`DELETE` requests in set of blocked cross-origin requests for CSRF protection ([`bb2253d5`](https://github.com/sveltejs/kit/commit/bb2253d51d00aba2e4353952d4fb0dcde6c77123))\n\n## 1.15.0\n\n### Minor Changes\n\n- feat: expose stronger typed `SubmitFunction` through `./$types` ([#9201](https://github.com/sveltejs/kit/pull/9201))\n\n### Patch Changes\n\n- fix: throw error when file can't be found in Vite manifest ([#9558](https://github.com/sveltejs/kit/pull/9558))\n\n- fix: make `error.message` enumerable when sending `ssrLoadModule` error to client ([#9440](https://github.com/sveltejs/kit/pull/9440))\n\n- fix: pass `publicDir` Vite config in SSR ([#9565](https://github.com/sveltejs/kit/pull/9565))\n\n- fix: balance parentheses in error about wrong content type for action ([#9513](https://github.com/sveltejs/kit/pull/9513))\n\n## 1.14.0\n\n### Minor Changes\n\n- feat: add HMR to fallback error pages during dev ([#9497](https://github.com/sveltejs/kit/pull/9497))\n\n### Patch Changes\n\n- fix: add `submitter` type to `SubmitFunction` ([#9484](https://github.com/sveltejs/kit/pull/9484))\n\n## 1.13.0\n\n### Minor Changes\n\n- feat: add dark mode styles to default error page ([#9460](https://github.com/sveltejs/kit/pull/9460))\n\n### Patch Changes\n\n- fix: recover from errors during dev by reloading ([#9441](https://github.com/sveltejs/kit/pull/9441))\n\n## 1.12.0\n\n### Minor Changes\n\n- feat: expose submitter in use:enhance SubmitFunction ([#9425](https://github.com/sveltejs/kit/pull/9425))\n\n- feat: add data-sveltekit-keepfocus and data-sveltekit-replacestate options to links (requires Svelte version 3.56 for type-checking with `svelte-check`) ([#9019](https://github.com/sveltejs/kit/pull/9019))\n\n### Patch Changes\n\n- fix: don't start debugger on 404s ([#9424](https://github.com/sveltejs/kit/pull/9424))\n\n- fix: handle srcset attributes with newline after comma ([#9388](https://github.com/sveltejs/kit/pull/9388))\n\n- fix: allow tsconfig to extend multiple other tsconfigs ([#9413](https://github.com/sveltejs/kit/pull/9413))\n\n- chore: update Undici to 5.21.0 ([#9417](https://github.com/sveltejs/kit/pull/9417))\n\n## 1.11.0\n\n### Minor Changes\n\n- feat: pause on debugger when falling back to full page reload during development ([#9305](https://github.com/sveltejs/kit/pull/9305))\n\n- feat: expose `base` via `$service-worker`, make paths relative ([#9250](https://github.com/sveltejs/kit/pull/9250))\n\n### Patch Changes\n\n- fix: don't automatically prerender non-SSR'd pages ([#9352](https://github.com/sveltejs/kit/pull/9352))\n\n- fix: use 308 responses for trailing slash redirects, instead of 301s ([#9351](https://github.com/sveltejs/kit/pull/9351))\n\n- fix: remove buggy cookie path detection ([#9298](https://github.com/sveltejs/kit/pull/9298))\n\n- fix: don't prevent `beforeNavigate` callbacks from running following a cancelled unloading navigation ([#9347](https://github.com/sveltejs/kit/pull/9347))\n\n- fix: persist DOM state on beforeunload ([#9345](https://github.com/sveltejs/kit/pull/9345))\n\n- fix: redirect to path with/without trailing slash when previewing prerendered pages ([#9353](https://github.com/sveltejs/kit/pull/9353))\n\n- fix: avoid FOUC when using CSS modules in dev ([#9323](https://github.com/sveltejs/kit/pull/9323))\n\n- fix: don't skip required parameters after missing optional parameters ([#9331](https://github.com/sveltejs/kit/pull/9331))\n\n- fix: account for server-emitted assets when prerenering ([#9349](https://github.com/sveltejs/kit/pull/9349))\n\n- fix: deal with fast consecutive promise resolutions when streaming ([#9332](https://github.com/sveltejs/kit/pull/9332))\n\n- chore: replace deprecated property access in preparation for TS 5.0 ([#9361](https://github.com/sveltejs/kit/pull/9361))\n\n## 1.10.1\n\n### Patch Changes\n\n- fix: respect `<base>` when crawling ([#9257](https://github.com/sveltejs/kit/pull/9257))\n\n- fix: scroll before resetting focus, to avoid flash of unscrolled content ([#9311](https://github.com/sveltejs/kit/pull/9311))\n\n- fix: omit hash from global during development ([#9310](https://github.com/sveltejs/kit/pull/9310))\n\n## 1.10.0\n\n### Minor Changes\n\n- feat: add `cookies.getAll` ([#9287](https://github.com/sveltejs/kit/pull/9287))\n\n### Patch Changes\n\n- fix: always include `<link rel=\"stylesheet\">`, even for stylesheets excluded from Link headers ([#9255](https://github.com/sveltejs/kit/pull/9255))\n\n- fix: preserve form state when submitting a second time ([#9267](https://github.com/sveltejs/kit/pull/9267))\n\n## 1.9.3\n\n### Patch Changes\n\n- fix: successive optional route parameters can now be empty ([#9266](https://github.com/sveltejs/kit/pull/9266))\n\n## 1.9.2\n\n### Patch Changes\n\n- fix: correct undefined reference to global var with Vitest ([#9252](https://github.com/sveltejs/kit/pull/9252))\n\n## 1.9.1\n\n### Patch Changes\n\n- feat: warn when calling depends(...) with special URI scheme ([#9246](https://github.com/sveltejs/kit/pull/9246))\n\n## 1.9.0\n\n### Minor Changes\n\n- feat: add `paths.relative` option to control interpretation of `paths.assets` and `paths.base` ([#9220](https://github.com/sveltejs/kit/pull/9220))\n\n## 1.8.8\n\n### Patch Changes\n\n- fix: always add `@sveltejs/kit` to `noExternal` for ssr build ([#9242](https://github.com/sveltejs/kit/pull/9242))\n- feat: add `api.methods` and `page.methods` to `builder.routes` ([#9145](https://github.com/sveltejs/kit/pull/9145))\n\n## 1.8.7\n\n### Patch Changes\n\n- fix: correct not found message when setting `paths.base` ([#9232](https://github.com/sveltejs/kit/pull/9232))\n\n## 1.8.6\n\n### Patch Changes\n\n- fix: bundle SvelteKit when using Vitest ([#9172](https://github.com/sveltejs/kit/pull/9172))\n\n## 1.8.5\n\n### Patch Changes\n\n- fix: allow relative fetch to endpoint outside app from within `handle` ([#9198](https://github.com/sveltejs/kit/pull/9198))\n\n## 1.8.4\n\n### Patch Changes\n\n- fix: include .mjs files in precompression ([#9179](https://github.com/sveltejs/kit/pull/9179))\n\n- fix: revert mjs extension usage by default, make it an option ([#9179](https://github.com/sveltejs/kit/pull/9179))\n\n- chore: dummy changeset to force a release ([#9207](https://github.com/sveltejs/kit/pull/9207))\n\n## 1.8.3\n\n### Patch Changes\n\n- fix: use a proprietary content-type to ensure response is not buffered ([#9142](https://github.com/sveltejs/kit/pull/9142))\n\n## 1.8.2\n\n### Patch Changes\n\n- fix: append newline to trigger script evaluation ([#9139](https://github.com/sveltejs/kit/pull/9139))\n\n## 1.8.1\n\n### Patch Changes\n\n- fix: encode streamed chunks ([#9136](https://github.com/sveltejs/kit/pull/9136))\n\n## 1.8.0\n\n### Minor Changes\n\n- feat: implement streaming promises for server load functions ([#8901](https://github.com/sveltejs/kit/pull/8901))\n\n### Patch Changes\n\n- fix: set public env before starting app ([#8957](https://github.com/sveltejs/kit/pull/8957))\n\n- fix: preload modules on Safari ([#8957](https://github.com/sveltejs/kit/pull/8957))\n\n- fix: make `assets` work in client when app is served from a subfolder ([#8957](https://github.com/sveltejs/kit/pull/8957))\n\n## 1.7.2\n\n### Patch Changes\n\n- fix: return correct asset list from `builder.writeClient()` ([#9095](https://github.com/sveltejs/kit/pull/9095))\n\n## 1.7.1\n\n### Patch Changes\n\n- fix: deploy server assets. Only works with Vite 4.1+ ([#9073](https://github.com/sveltejs/kit/pull/9073))\n\n## 1.7.0\n\n### Minor Changes\n\n- feat: richer error message for invalid exports ([#9055](https://github.com/sveltejs/kit/pull/9055))\n\n### Patch Changes\n\n- chore: throw more helpful error when encoding uri fails during prerendering ([#9053](https://github.com/sveltejs/kit/pull/9053))\n\n## 1.6.0\n\n### Minor Changes\n\n- feat: add `OPTIONS` server method ([#8731](https://github.com/sveltejs/kit/pull/8731))\n\n### Patch Changes\n\n- fix: solve `missing \"./paths\" specifier in \"@sveltejs/kit\" package` error occurring in all projects ([#9050](https://github.com/sveltejs/kit/pull/9050))\n\n## 1.5.7\n\n### Patch Changes\n\n- fix: use internal alias that won't collide with user aliases ([#9022](https://github.com/sveltejs/kit/pull/9022))\n\n## 1.5.6\n\n### Patch Changes\n\n- fix: ssr defaults preventing minification for client build ([#9012](https://github.com/sveltejs/kit/pull/9012))\n\n- fix: client-side trailing slash redirect when preloading data ([#8982](https://github.com/sveltejs/kit/pull/8982))\n\n## 1.5.5\n\n### Patch Changes\n\n- fix: warn after failed data preloads in dev ([#8985](https://github.com/sveltejs/kit/pull/8985))\n\n## 1.5.4\n\n### Patch Changes\n\n- fix: support all relevant vite cli flags ([#8977](https://github.com/sveltejs/kit/pull/8977))\n\n## 1.5.3\n\n### Patch Changes\n\n- docs: clarify that `version.name` should be deterministic ([#8956](https://github.com/sveltejs/kit/pull/8956))\n\n- fix: correctly include exported http methods in allow header ([#8968](https://github.com/sveltejs/kit/pull/8968))\n\n- chore: polyfill File from node:buffer ([#8925](https://github.com/sveltejs/kit/pull/8925))\n\n- fix: provide helpful error/warning when calling `fetch` during render ([#8551](https://github.com/sveltejs/kit/pull/8551))\n\n- fix: print useful error when subscribing to SvelteKit's stores at the wrong time during SSR ([#8960](https://github.com/sveltejs/kit/pull/8960))\n\n- fix: ignore external links when automatically preloading ([#8961](https://github.com/sveltejs/kit/pull/8961))\n\n- chore: refactor fallback generation ([#8972](https://github.com/sveltejs/kit/pull/8972))\n\n## 1.5.2\n\n### Patch Changes\n\n- fix: always default `paths.assets` to `paths.base` ([#8928](https://github.com/sveltejs/kit/pull/8928))\n\n## 1.5.1\n\n### Patch Changes\n\n- fix: pick up config from endpoints ([#8933](https://github.com/sveltejs/kit/pull/8933))\n\n- fix: don't reuse previous server load cache when there's no server load function ([#8893](https://github.com/sveltejs/kit/pull/8893))\n\n- fix: deduplicate paths in tsconfig ([#8880](https://github.com/sveltejs/kit/pull/8880))\n\n- docs: clarify version management feature ([#8941](https://github.com/sveltejs/kit/pull/8941))\n\n## 1.5.0\n\n### Minor Changes\n\n- feat: support route-level configuration ([#8740](https://github.com/sveltejs/kit/pull/8740))\n\n- feat: add snapshot mechanism for preserving ephemeral DOM state ([#8710](https://github.com/sveltejs/kit/pull/8710))\n\n### Patch Changes\n\n- chore(deps): update dependency undici to v5.18.0 ([#8884](https://github.com/sveltejs/kit/pull/8884))\n\n## 1.4.0\n\n### Minor Changes\n\n- feat: allow $app/paths to be used without an app ([#8838](https://github.com/sveltejs/kit/pull/8838))\n\n### Patch Changes\n\n- fix: ensure types of all form actions are accessible even if differing ([#8877](https://github.com/sveltejs/kit/pull/8877))\n\n- fix: correctly handle HttpErrors on the client side ([#8829](https://github.com/sveltejs/kit/pull/8829))\n\n- docs: discourage use of `goto` with external URLs ([#8837](https://github.com/sveltejs/kit/pull/8837))\n\n- fix: prevent crawling empty urls (`<img src=\"\">`) ([#8883](https://github.com/sveltejs/kit/pull/8883))\n\n- fix: correctly serialize request url when using load `fetch` ([#8876](https://github.com/sveltejs/kit/pull/8876))\n\n- fix: ensure endpoints can fetch endpoints on the same host but not part of the application ([#8869](https://github.com/sveltejs/kit/pull/8869))\n\n## 1.3.10\n\n### Patch Changes\n\n- fix: preserve build error messages ([#8846](https://github.com/sveltejs/kit/pull/8846))\n\n## 1.3.9\n\n### Patch Changes\n\n- fix: output errors properly if pages fail to compile ([#8813](https://github.com/sveltejs/kit/pull/8813))\n\n## 1.3.8\n\n### Patch Changes\n\n- fix: remove Vite manifest before running adapter ([#8815](https://github.com/sveltejs/kit/pull/8815))\n\n## 1.3.7\n\n### Patch Changes\n\n- fix: only show prerendering message when actually prerendering ([#8809](https://github.com/sveltejs/kit/pull/8809))\n\n- fix: handle anchors with special chars when navigating ([#8806](https://github.com/sveltejs/kit/pull/8806))\n\n- fix: await finalise hook and run it only once ([#8817](https://github.com/sveltejs/kit/pull/8817))\n\n## 1.3.6\n\n### Patch Changes\n\n- fix: allow rest parameters to follow multiple optional - or not - parameters ([#8761](https://github.com/sveltejs/kit/pull/8761))\n\n- fix: consider headers when constructing request hash ([#8754](https://github.com/sveltejs/kit/pull/8754))\n\n## 1.3.5\n\n### Patch Changes\n\n- docs: fix typo ([#8790](https://github.com/sveltejs/kit/pull/8790))\n\n- fix: build error on layout with missing leaves ([#8792](https://github.com/sveltejs/kit/pull/8792))\n\n- fix: handle hash links with non-ASCII characters when navigating ([#8767](https://github.com/sveltejs/kit/pull/8767))\n\n## 1.3.4\n\n### Patch Changes\n\n- chore: bump devalue ([#8789](https://github.com/sveltejs/kit/pull/8789))\n\n## 1.3.3\n\n### Patch Changes\n\n- fix: forward `process.env` to child process ([#8777](https://github.com/sveltejs/kit/pull/8777))\n\n## 1.3.2\n\n### Patch Changes\n\n- fix: take base path into account when preloading code ([#8748](https://github.com/sveltejs/kit/pull/8748))\n\n## 1.3.1\n\n### Patch Changes\n\n- fix: only fetch `__data.json` files for routes with a server `load` function ([#8636](https://github.com/sveltejs/kit/pull/8636))\n\n- fix: add `ignoreDeprecations` flag for TS 5.x ([#8718](https://github.com/sveltejs/kit/pull/8718))\n\n- fix: install polyfills when analysing code ([#8636](https://github.com/sveltejs/kit/pull/8636))\n\n## 1.3.0\n\n### Minor Changes\n\n- feat: allow generated tsconfig to be modified ([#8606](https://github.com/sveltejs/kit/pull/8606))\n\n### Patch Changes\n\n- fix: skip navigation hooks on popstate events when only hash changed ([#8730](https://github.com/sveltejs/kit/pull/8730))\n\n## 1.2.10\n\n### Patch Changes\n\n- chore: restrict methods allowed for POST ([#8721](https://github.com/sveltejs/kit/pull/8721))\n\n- fix: provide proper error when POSTing to a missing page endpoint ([#8714](https://github.com/sveltejs/kit/pull/8714))\n\n## 1.2.9\n\n### Patch Changes\n\n- fix: reapply exports alignment after Vite dependency optimizations ([#8690](https://github.com/sveltejs/kit/pull/8690))\n\n## 1.2.8\n\n### Patch Changes\n\n- fix: include base path in path to start script ([#8651](https://github.com/sveltejs/kit/pull/8651))\n\n## 1.2.7\n\n### Patch Changes\n\n- fix: set headers when throwing redirect in handle ([#8648](https://github.com/sveltejs/kit/pull/8648))\n\n## 1.2.6\n\n### Patch Changes\n\n- fix: allow importing assets while using base path ([#8683](https://github.com/sveltejs/kit/pull/8683))\n\n## 1.2.5\n\n### Patch Changes\n\n- fix: check for wrong return values from form actions ([#8553](https://github.com/sveltejs/kit/pull/8553))\n\n## 1.2.4\n\n### Patch Changes\n\n- chore: update undici to v5.16.0 ([#8668](https://github.com/sveltejs/kit/pull/8668))\n\n## 1.2.3\n\n### Patch Changes\n\n- fix: set environment variables before postbuild analysis ([#8647](https://github.com/sveltejs/kit/pull/8647))\n\n## 1.2.2\n\n### Patch Changes\n\n- fix: focus management after navigation ([#8466](https://github.com/sveltejs/kit/pull/8466))\n\n## 1.2.1\n\n### Patch Changes\n\n- feat: throw error if cookie exceeds size limit ([#8591](https://github.com/sveltejs/kit/pull/8591))\n\n## 1.2.0\n\n### Minor Changes\n\n- feat: add `text(...)` helper for generating text responses ([#8371](https://github.com/sveltejs/kit/pull/8371))\n\n- feat: enable access to public env within app.html ([#8449](https://github.com/sveltejs/kit/pull/8449))\n\n- fix: add `Content-Length` header to SvelteKit-generated responses ([#8371](https://github.com/sveltejs/kit/pull/8371))\n\n## 1.1.4\n\n### Patch Changes\n\n- fix: squelch unknown prop warning for `+error.svelte` components ([#8593](https://github.com/sveltejs/kit/pull/8593))\n\n## 1.1.3\n\n### Patch Changes\n\n- docs: explain how to add ambient typings ([#8558](https://github.com/sveltejs/kit/pull/8558))\n\n- fix: ignore `target=\"_blank\"` links ([#8563](https://github.com/sveltejs/kit/pull/8563))\n\n## 1.1.2\n\n### Patch Changes\n\n- fix: correct link in types documentation ([#8557](https://github.com/sveltejs/kit/pull/8557))\n\n- fix: correctly detect changed data ([#8377](https://github.com/sveltejs/kit/pull/8377))\n\n- fix: only generate type definitions with `sync` command ([#8552](https://github.com/sveltejs/kit/pull/8552))\n\n- fix: remove baseUrl to prevent wrong TypeScript auto imports if possible ([#8568](https://github.com/sveltejs/kit/pull/8568))\n\n## 1.1.1\n\n### Patch Changes\n\n- chore: upgrade devalue ([#8520](https://github.com/sveltejs/kit/pull/8520))\n\n## 1.1.0\n\n### Minor Changes\n\n- feat: warn when usage of page options in `.svelte` files or missing `<slot />` in layout is detected ([#8475](https://github.com/sveltejs/kit/pull/8475))\n\n### Patch Changes\n\n- fix: exit postbuild step with code 0 ([#8514](https://github.com/sveltejs/kit/pull/8514))\n\n- fix: only run missing page check in dev mode ([#8515](https://github.com/sveltejs/kit/pull/8515))\n\n- fix: avoid input name clobbering form method check ([#8471](https://github.com/sveltejs/kit/pull/8471))\n\n- fix: exclude service worker from tsconfig ([#8508](https://github.com/sveltejs/kit/pull/8508))\n\n- fix: provide better error message in case of missing `+page.svelte` ([#8478](https://github.com/sveltejs/kit/pull/8478))\n\n## 1.0.13\n\n### Patch Changes\n\n- chore: separate generated from non-generated server code ([#8429](https://github.com/sveltejs/kit/pull/8429))\n\n## 1.0.12\n\n### Patch Changes\n\n- fix: make prerendered endpoint callable from non-prerendered server load ([#8453](https://github.com/sveltejs/kit/pull/8453))\n\n- docs: add links to http status codes ([#8480](https://github.com/sveltejs/kit/pull/8480))\n\n- fix: prerender page when prerender set to 'auto' and ssr set to true ([#8481](https://github.com/sveltejs/kit/pull/8481))\n\n- fix: prevent false positive warnings for fetch uses in firefox ([#8456](https://github.com/sveltejs/kit/pull/8456))\n\n- fix: check version on node fetch fail ([#8487](https://github.com/sveltejs/kit/pull/8487))\n\n- fix: avoid unnecessary $page store updates ([#8457](https://github.com/sveltejs/kit/pull/8457))\n\n## 1.0.11\n\n### Patch Changes\n\n- feat: warn that hydration may break if comments are removed from HTML ([#8423](https://github.com/sveltejs/kit/pull/8423))\n- fix: ignore `<a>` elements with no `href` attribute when refocusing after navigation ([#8418](https://github.com/sveltejs/kit/pull/8418))\n- fix: invalidate dependencies implicitly added by `fetch` in server load functions ([#8420](https://github.com/sveltejs/kit/pull/8420))\n\n## 1.0.10\n\n### Patch Changes\n\n- fix: skip inline cache when vary header is present ([#8406](https://github.com/sveltejs/kit/pull/8406))\n\n## 1.0.9\n\n### Patch Changes\n\n- fix: add `assetFileNames` to worker rollup options ([#8384](https://github.com/sveltejs/kit/pull/8384))\n\n## 1.0.8\n\n### Patch Changes\n\n- feat: error in dev mode if global `fetch` is used with relative URL ([#8370](https://github.com/sveltejs/kit/pull/8370))\n- fix: disable illegal import detection when running unit tests ([#8365](https://github.com/sveltejs/kit/pull/8365))\n- fix: only prerender a given dependency once ([#8376](https://github.com/sveltejs/kit/pull/8376))\n- fix: `updated.check()` type changed to `Promise<boolean>` ([#8400](https://github.com/sveltejs/kit/pull/8400))\n- fix: don't strip body in no-cors mode on the server ([#8412](https://github.com/sveltejs/kit/pull/8412))\n- fix: quote 'script' in CSP directives ([#8372](https://github.com/sveltejs/kit/pull/8372))\n- fix: correctly compare route ids for load change detection ([#8399](https://github.com/sveltejs/kit/pull/8399))\n- fix: don't add nonce attribute to `<link>` elements ([#8369](https://github.com/sveltejs/kit/pull/8369))\n\n## 1.0.7\n\n### Patch Changes\n\n- fix: ignore `*.test.js` and `*.spec.js` files in `params` directory ([#8250](https://github.com/sveltejs/kit/pull/8250))\n\n## 1.0.6\n\n### Patch Changes\n\n- fix: guarantee that `$page.route` has the correct shape ([#8359](https://github.com/sveltejs/kit/pull/8359))\n\n## 1.0.5\n\n### Patch Changes\n\n- fix: update typings of `event.platform` to be possibly undefined ([#8232](https://github.com/sveltejs/kit/pull/8232))\n\n## 1.0.4\n\n### Patch Changes\n\n- fix: don't polyfill undici if using Deno or Bun ([#8338](https://github.com/sveltejs/kit/pull/8338))\n\n## 1.0.3\n\n### Patch Changes\n\n- feat: include submitter's value when progressively enhancing `<form method=\"get\">` ([#8273](https://github.com/sveltejs/kit/pull/8273))\n\n## 1.0.2\n\n### Patch Changes\n\n- fix: correct `filterSerializedResponseHeaders` error message ([#8348](https://github.com/sveltejs/kit/pull/8348))\n- fix: correct form action redirect status code ([#8210](https://github.com/sveltejs/kit/pull/8210))\n\n## 1.0.1\n\n### Patch Changes\n\n- fix: explicitly mark Node 17.x as not supported ([#8174](https://github.com/sveltejs/kit/pull/8174))\n\n## 1.0.0\n\n### Major Changes\n\nFirst major release, see [CHANGELOG-pre-1.md](CHANGELOG-pre-1.md) for the history of changes that lead up to this.\nStarting from now all releases follow semver and changes will be listed as Major/Minor/Patch\n"
  },
  {
    "path": "packages/kit/README.md",
    "content": "# The fastest way to build Svelte apps\n\nThis is the [SvelteKit](https://svelte.dev/docs/kit) framework and CLI.\n\nThe quickest way to get started is via the [sv](https://npmjs.com/package/sv) package:\n\n```sh\nnpx sv create my-app\ncd my-app\nnpm install\nnpm run dev\n```\n\nSee the [documentation](https://svelte.dev/docs/kit) to learn more.\n\n## Changelog\n\n[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/kit/CHANGELOG.md).\n"
  },
  {
    "path": "packages/kit/kit.vitest.config.js",
    "content": "import { fileURLToPath } from 'node:url';\nimport { defineConfig } from 'vitest/config';\n\n// this file needs a custom name so that the numerous test subprojects don't all pick it up\nexport default defineConfig({\n\tdefine: {\n\t\t__SVELTEKIT_SERVER_TRACING_ENABLED__: false\n\t},\n\tserver: {\n\t\twatch: {\n\t\t\tignored: ['**/node_modules/**', '**/.svelte-kit/**']\n\t\t}\n\t},\n\ttest: {\n\t\talias: {\n\t\t\t'__sveltekit/paths': fileURLToPath(new URL('./test/mocks/path.js', import.meta.url))\n\t\t},\n\t\tpool: 'threads',\n\t\tmaxWorkers: 1,\n\t\tinclude: ['src/**/*.spec.js'],\n\t\texclude: [\n\t\t\t'**/node_modules/**',\n\t\t\t'**/.svelte-kit/**',\n\t\t\t'**/.{idea,git,cache,output,temp}/**',\n\t\t\t'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*'\n\t\t]\n\t}\n});\n"
  },
  {
    "path": "packages/kit/package.json",
    "content": "{\n\t\"name\": \"@sveltejs/kit\",\n\t\"version\": \"2.55.0\",\n\t\"description\": \"SvelteKit is the fastest way to build Svelte apps\",\n\t\"keywords\": [\n\t\t\"framework\",\n\t\t\"official\",\n\t\t\"svelte\",\n\t\t\"sveltekit\",\n\t\t\"vite\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/sveltejs/kit.git\",\n\t\t\"directory\": \"packages/kit\"\n\t},\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://svelte.dev\",\n\t\"type\": \"module\",\n\t\"dependencies\": {\n\t\t\"@standard-schema/spec\": \"^1.0.0\",\n\t\t\"@sveltejs/acorn-typescript\": \"^1.0.5\",\n\t\t\"@types/cookie\": \"^0.6.0\",\n\t\t\"acorn\": \"^8.14.1\",\n\t\t\"cookie\": \"^0.6.0\",\n\t\t\"devalue\": \"^5.6.4\",\n\t\t\"esm-env\": \"^1.2.2\",\n\t\t\"kleur\": \"^4.1.5\",\n\t\t\"magic-string\": \"^0.30.5\",\n\t\t\"mrmime\": \"^2.0.0\",\n\t\t\"set-cookie-parser\": \"^3.0.0\",\n\t\t\"sirv\": \"^3.0.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@opentelemetry/api\": \"^1.0.0\",\n\t\t\"@playwright/test\": \"catalog:\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"@types/connect\": \"catalog:\",\n\t\t\"@types/node\": \"catalog:\",\n\t\t\"@types/set-cookie-parser\": \"catalog:\",\n\t\t\"dts-buddy\": \"catalog:\",\n\t\t\"rollup\": \"^4.59.0\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-preprocess\": \"catalog:\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vite\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@sveltejs/vite-plugin-svelte\": \"^3.0.0 || ^4.0.0-next.1 || ^5.0.0 || ^6.0.0-next.0 || ^7.0.0\",\n\t\t\"@opentelemetry/api\": \"^1.0.0\",\n\t\t\"svelte\": \"^4.0.0 || ^5.0.0-next.0\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vite\": \"^5.0.3 || ^6.0.0 || ^7.0.0-beta.0 || ^8.0.0\"\n\t},\n\t\"peerDependenciesMeta\": {\n\t\t\"@opentelemetry/api\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"typescript\": {\n\t\t\t\"optional\": true\n\t\t}\n\t},\n\t\"bin\": {\n\t\t\"svelte-kit\": \"svelte-kit.js\"\n\t},\n\t\"files\": [\n\t\t\"src\",\n\t\t\"!src/**/*.spec.js\",\n\t\t\"!src/core/**/fixtures\",\n\t\t\"!src/core/**/test\",\n\t\t\"types\",\n\t\t\"svelte-kit.js\"\n\t],\n\t\"scripts\": {\n\t\t\"lint\": \"prettier --config ../../.prettierrc --check .\",\n\t\t\"check\": \"tsc && cd ./test/types && tsc\",\n\t\t\"check:all\": \"tsc && pnpm -r --filter=\\\"./**\\\" check\",\n\t\t\"format\": \"prettier --config ../../.prettierrc --write .\",\n\t\t\"test\": \"pnpm test:unit && pnpm test:integration\",\n\t\t\"test:integration\": \"pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test\",\n\t\t\"test:cross-platform:dev\": \"pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test:cross-platform:dev\",\n\t\t\"test:cross-platform:build\": \"pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test:cross-platform:build\",\n\t\t\"test:server-side-route-resolution:dev\": \"pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test:server-side-route-resolution:dev\",\n\t\t\"test:server-side-route-resolution:build\": \"pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test:server-side-route-resolution:build\",\n\t\t\"test:svelte-async:dev\": \"pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test:svelte-async:dev\",\n\t\t\"test:svelte-async:build\": \"pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\\\"./test/**\\\" test:svelte-async:build\",\n\t\t\"test:unit:dev\": \"vitest --config kit.vitest.config.js run\",\n\t\t\"test:unit:prod\": \"NODE_ENV=production vitest --config kit.vitest.config.js run csp.spec.js cookie.spec.js\",\n\t\t\"test:unit\": \"pnpm test:unit:dev && pnpm test:unit:prod\",\n\t\t\"prepublishOnly\": \"pnpm generate:types\",\n\t\t\"generate:version\": \"node scripts/generate-version.js\",\n\t\t\"generate:types\": \"node scripts/generate-dts.js\"\n\t},\n\t\"imports\": {\n\t\t\"#app/paths\": {\n\t\t\t\"browser\": \"./src/runtime/app/paths/client.js\",\n\t\t\t\"default\": \"./src/runtime/app/paths/server.js\"\n\t\t}\n\t},\n\t\"exports\": {\n\t\t\"./package.json\": \"./package.json\",\n\t\t\".\": {\n\t\t\t\"types\": \"./types/index.d.ts\",\n\t\t\t\"import\": \"./src/exports/index.js\"\n\t\t},\n\t\t\"./internal\": {\n\t\t\t\"types\": \"./types/index.d.ts\",\n\t\t\t\"import\": \"./src/exports/internal/index.js\"\n\t\t},\n\t\t\"./internal/server\": {\n\t\t\t\"types\": \"./types/index.d.ts\",\n\t\t\t\"import\": \"./src/exports/internal/server.js\"\n\t\t},\n\t\t\"./node\": {\n\t\t\t\"types\": \"./types/index.d.ts\",\n\t\t\t\"import\": \"./src/exports/node/index.js\"\n\t\t},\n\t\t\"./node/polyfills\": {\n\t\t\t\"types\": \"./types/index.d.ts\",\n\t\t\t\"import\": \"./src/exports/node/polyfills.js\"\n\t\t},\n\t\t\"./hooks\": {\n\t\t\t\"types\": \"./types/index.d.ts\",\n\t\t\t\"import\": \"./src/exports/hooks/index.js\"\n\t\t},\n\t\t\"./vite\": {\n\t\t\t\"types\": \"./types/index.d.ts\",\n\t\t\t\"import\": \"./src/exports/vite/index.js\"\n\t\t}\n\t},\n\t\"types\": \"types/index.d.ts\",\n\t\"engines\": {\n\t\t\"node\": \">=18.13\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/scripts/cp.js",
    "content": "import { copy } from '../src/utils/filesystem.js';\nimport process from 'node:process';\n\nconst [src, dest] = process.argv.slice(2);\n\ncopy(src, dest);\n"
  },
  {
    "path": "packages/kit/scripts/generate-dts.js",
    "content": "import { createBundle } from 'dts-buddy';\nimport { readFileSync } from 'node:fs';\n\nawait createBundle({\n\toutput: 'types/index.d.ts',\n\tmodules: {\n\t\t'@sveltejs/kit': 'src/exports/public.d.ts',\n\t\t'@sveltejs/kit/hooks': 'src/exports/hooks/index.js',\n\t\t'@sveltejs/kit/node': 'src/exports/node/index.js',\n\t\t'@sveltejs/kit/node/polyfills': 'src/exports/node/polyfills.js',\n\t\t'@sveltejs/kit/vite': 'src/exports/vite/index.js',\n\t\t'$app/environment': 'src/runtime/app/environment/types.d.ts',\n\t\t'$app/forms': 'src/runtime/app/forms.js',\n\t\t'$app/navigation': 'src/runtime/app/navigation.js',\n\t\t'$app/paths': 'src/runtime/app/paths/public.d.ts',\n\t\t'$app/server': 'src/runtime/app/server/index.js',\n\t\t'$app/state': 'src/runtime/app/state/index.js',\n\t\t'$app/stores': 'src/runtime/app/stores.js'\n\t},\n\tinclude: ['src']\n});\n\n// dts-buddy doesn't inline imports of module declaration in ambient-private.d.ts but also doesn't include them, resulting in broken types - guard against that\nconst types = readFileSync('./types/index.d.ts', 'utf-8');\nif (types.includes('__sveltekit/')) {\n\tthrow new Error(\n\t\t'Found __sveltekit/ in types/index.d.ts - make sure to hide internal modules by not just reexporting them. Contents:\\n\\n' +\n\t\t\ttypes\n\t);\n}\n"
  },
  {
    "path": "packages/kit/scripts/generate-version.js",
    "content": "import fs from 'node:fs';\n\nconst pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));\n\nfs.writeFileSync(\n\t'./src/version.js',\n\t`// generated during release, do not modify\\n\\n/** @type {string} */\\nexport const VERSION = '${pkg.version}';\\n`\n);\n"
  },
  {
    "path": "packages/kit/src/cli.js",
    "content": "import fs from 'node:fs';\nimport process from 'node:process';\nimport { parseArgs } from 'node:util';\nimport colors from 'kleur';\nimport { load_config } from './core/config/index.js';\nimport { coalesce_to_error } from './utils/error.js';\n\n/** @param {unknown} e */\nfunction handle_error(e) {\n\tconst error = coalesce_to_error(e);\n\n\tif (error.name === 'SyntaxError') throw error;\n\n\tconsole.error(colors.bold().red(`> ${error.message}`));\n\tif (error.stack) {\n\t\tconsole.error(colors.gray(error.stack.split('\\n').slice(1).join('\\n')));\n\t}\n\n\tprocess.exit(1);\n}\n\nconst pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));\n\nconst help = `\n  Usage: svelte-kit <command> [options]\n\n  Commands:\n    sync        Synchronise generated type definitions\n\n  Options:\n    --version, -v   Show version number\n    --help, -h      Show this help message\n\n  Sync Options:\n    --mode <mode>   Specify a mode for loading environment variables (default: development)\n`;\n\nlet parsed;\ntry {\n\tparsed = parseArgs({\n\t\toptions: {\n\t\t\tversion: { type: 'boolean', short: 'v' },\n\t\t\thelp: { type: 'boolean', short: 'h' },\n\t\t\tmode: { type: 'string', default: 'development' }\n\t\t},\n\t\tallowPositionals: true,\n\t\tstrict: true\n\t});\n} catch (err) {\n\tconst error = /** @type {Error} */ (err);\n\tconsole.error(colors.bold().red(`> ${error.message}`));\n\tconsole.log(help);\n\tprocess.exit(1);\n}\n\nconst { values, positionals } = parsed;\n\nif (values.version) {\n\tconsole.log(pkg.version);\n\tprocess.exit(0);\n}\n\nif (values.help) {\n\tconsole.log(help);\n\tprocess.exit(0);\n}\n\nconst command = positionals[0];\n\nif (!command) {\n\tconsole.log(help);\n\tprocess.exit(0);\n}\n\nif (command === 'sync') {\n\tconst config_files = ['js', 'ts']\n\t\t.map((ext) => `svelte.config.${ext}`)\n\t\t.filter((f) => fs.existsSync(f));\n\tif (config_files.length === 0) {\n\t\tconsole.warn(`Missing Svelte config file in ${process.cwd()} — skipping`);\n\t\tprocess.exit(0);\n\t}\n\n\ttry {\n\t\tconst config = await load_config();\n\t\tconst sync = await import('./core/sync/sync.js');\n\t\tsync.all_types(config, values.mode);\n\t} catch (error) {\n\t\thandle_error(error);\n\t}\n} else {\n\tconsole.error(colors.bold().red(`> Unknown command: ${command}`));\n\tconsole.log(help);\n\tprocess.exit(1);\n}\n"
  },
  {
    "path": "packages/kit/src/constants.js",
    "content": "/**\n * A fake asset path used in `vite dev` and `vite preview`, so that we can\n * serve local assets while verifying that requests are correctly prefixed\n */\nexport const SVELTE_KIT_ASSETS = '/_svelte_kit_assets';\n\nexport const GENERATED_COMMENT = '// this file is generated — do not edit it\\n';\n\nexport const ENDPOINT_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD'];\n\nexport const MUTATIVE_METHODS = ['POST', 'PUT', 'PATCH', 'DELETE'];\n\nexport const PAGE_METHODS = ['GET', 'POST', 'HEAD'];\n"
  },
  {
    "path": "packages/kit/src/core/adapt/builder.js",
    "content": "/** @import { Builder } from '@sveltejs/kit' */\n/** @import { ResolvedConfig } from 'vite' */\n/** @import { RouteDefinition } from '@sveltejs/kit' */\n/** @import { RouteData, ValidatedConfig, BuildData, ServerMetadata, ServerMetadataRoute, Prerendered, PrerenderMap, Logger, RemoteChunk } from 'types' */\nimport colors from 'kleur';\nimport { createReadStream, createWriteStream, existsSync, statSync } from 'node:fs';\nimport { extname, resolve, join, dirname, relative } from 'node:path';\nimport { pipeline } from 'node:stream';\nimport { promisify } from 'node:util';\nimport zlib from 'node:zlib';\nimport { copy, rimraf, mkdirp, posixify } from '../../utils/filesystem.js';\nimport { generate_manifest } from '../generate_manifest/index.js';\nimport { get_route_segments } from '../../utils/routing.js';\nimport { get_env } from '../../exports/vite/utils.js';\nimport generate_fallback from '../postbuild/fallback.js';\nimport { write } from '../sync/utils.js';\nimport { list_files } from '../utils.js';\nimport { find_server_assets } from '../generate_manifest/find_server_assets.js';\nimport { reserved } from '../env.js';\n\nconst pipe = promisify(pipeline);\nconst extensions = ['.html', '.js', '.mjs', '.json', '.css', '.svg', '.xml', '.wasm', '.txt'];\n\n/**\n * Creates the Builder which is passed to adapters for building the application.\n * @param {{\n *   config: ValidatedConfig;\n *   build_data: BuildData;\n *   server_metadata: ServerMetadata;\n *   route_data: RouteData[];\n *   prerendered: Prerendered;\n *   prerender_map: PrerenderMap;\n *   log: Logger;\n *   vite_config: ResolvedConfig;\n *   remotes: RemoteChunk[]\n * }} opts\n * @returns {Builder}\n */\nexport function create_builder({\n\tconfig,\n\tbuild_data,\n\tserver_metadata,\n\troute_data,\n\tprerendered,\n\tprerender_map,\n\tlog,\n\tvite_config,\n\tremotes\n}) {\n\t/** @type {Map<RouteDefinition, RouteData>} */\n\tconst lookup = new Map();\n\n\t/**\n\t * Rather than exposing the internal `RouteData` type, which is subject to change,\n\t * we expose a stable type that adapters can use to group/filter routes\n\t */\n\tconst routes = route_data.map((route) => {\n\t\tconst { config, methods, page, api } = /** @type {ServerMetadataRoute} */ (\n\t\t\tserver_metadata.routes.get(route.id)\n\t\t);\n\n\t\t/** @type {RouteDefinition} */\n\t\tconst facade = {\n\t\t\tid: route.id,\n\t\t\tapi,\n\t\t\tpage,\n\t\t\tsegments: get_route_segments(route.id).map((segment) => ({\n\t\t\t\tdynamic: segment.includes('['),\n\t\t\t\trest: segment.includes('[...'),\n\t\t\t\tcontent: segment\n\t\t\t})),\n\t\t\tpattern: route.pattern,\n\t\t\tprerender: prerender_map.get(route.id) ?? false,\n\t\t\tmethods,\n\t\t\tconfig\n\t\t};\n\n\t\tlookup.set(facade, route);\n\n\t\treturn facade;\n\t});\n\n\treturn {\n\t\tlog,\n\t\trimraf,\n\t\tmkdirp,\n\t\tcopy,\n\n\t\tconfig,\n\t\tprerendered,\n\t\troutes,\n\n\t\tasync compress(directory) {\n\t\t\tif (!existsSync(directory)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst files = list_files(directory, (file) => extensions.includes(extname(file))).map(\n\t\t\t\t(file) => resolve(directory, file)\n\t\t\t);\n\n\t\t\tawait Promise.all(\n\t\t\t\tfiles.flatMap((file) => [compress_file(file, 'gz'), compress_file(file, 'br')])\n\t\t\t);\n\t\t},\n\n\t\tasync createEntries(fn) {\n\t\t\tconst seen = new Set();\n\n\t\t\tfor (let i = 0; i < route_data.length; i += 1) {\n\t\t\t\tconst route = route_data[i];\n\t\t\t\tif (prerender_map.get(route.id) === true) continue;\n\t\t\t\tconst { id, filter, complete } = fn(routes[i]);\n\n\t\t\t\tif (seen.has(id)) continue;\n\t\t\t\tseen.add(id);\n\n\t\t\t\tconst group = [route];\n\n\t\t\t\t// figure out which lower priority routes should be considered fallbacks\n\t\t\t\tfor (let j = i + 1; j < route_data.length; j += 1) {\n\t\t\t\t\tif (prerender_map.get(routes[j].id) === true) continue;\n\t\t\t\t\tif (filter(routes[j])) {\n\t\t\t\t\t\tgroup.push(route_data[j]);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst filtered = new Set(group);\n\n\t\t\t\t// heuristic: if /foo/[bar] is included, /foo/[bar].json should\n\t\t\t\t// also be included, since the page likely needs the endpoint\n\t\t\t\t// TODO is this still necessary, given the new way of doing things?\n\t\t\t\tfiltered.forEach((route) => {\n\t\t\t\t\tif (route.page) {\n\t\t\t\t\t\tconst endpoint = route_data.find((candidate) => candidate.id === route.id + '.json');\n\n\t\t\t\t\t\tif (endpoint) {\n\t\t\t\t\t\t\tfiltered.add(endpoint);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tif (filtered.size > 0) {\n\t\t\t\t\tawait complete({\n\t\t\t\t\t\tgenerateManifest: ({ relativePath }) =>\n\t\t\t\t\t\t\tgenerate_manifest({\n\t\t\t\t\t\t\t\tbuild_data,\n\t\t\t\t\t\t\t\tprerendered: [],\n\t\t\t\t\t\t\t\trelative_path: relativePath,\n\t\t\t\t\t\t\t\troutes: Array.from(filtered),\n\t\t\t\t\t\t\t\tremotes\n\t\t\t\t\t\t\t})\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tfindServerAssets(route_data) {\n\t\t\treturn find_server_assets(\n\t\t\t\tbuild_data,\n\t\t\t\troute_data.map((route) => /** @type {import('types').RouteData} */ (lookup.get(route)))\n\t\t\t);\n\t\t},\n\n\t\tasync generateFallback(dest) {\n\t\t\tconst manifest_path = `${config.kit.outDir}/output/server/manifest-full.js`;\n\t\t\tconst env = get_env(config.kit.env, vite_config.mode);\n\n\t\t\tconst fallback = await generate_fallback({\n\t\t\t\tmanifest_path,\n\t\t\t\tenv: { ...env.private, ...env.public }\n\t\t\t});\n\n\t\t\tif (existsSync(dest)) {\n\t\t\t\tconsole.log(\n\t\t\t\t\tcolors\n\t\t\t\t\t\t.bold()\n\t\t\t\t\t\t.yellow(\n\t\t\t\t\t\t\t`Overwriting ${dest} with fallback page. Consider using a different name for the fallback.`\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\twrite(dest, fallback);\n\t\t},\n\n\t\tgenerateEnvModule() {\n\t\t\tconst dest = `${config.kit.outDir}/output/prerendered/dependencies/${config.kit.appDir}/env.js`;\n\t\t\tconst env = get_env(config.kit.env, vite_config.mode);\n\n\t\t\twrite(dest, `export const env=${JSON.stringify(env.public)}`);\n\t\t},\n\n\t\tgenerateManifest({ relativePath, routes: subset }) {\n\t\t\treturn generate_manifest({\n\t\t\t\tbuild_data,\n\t\t\t\tprerendered: prerendered.paths,\n\t\t\t\trelative_path: relativePath,\n\t\t\t\troutes: subset\n\t\t\t\t\t? subset.map((route) => /** @type {import('types').RouteData} */ (lookup.get(route)))\n\t\t\t\t\t: route_data.filter((route) => prerender_map.get(route.id) !== true),\n\t\t\t\tremotes\n\t\t\t});\n\t\t},\n\n\t\tgetBuildDirectory(name) {\n\t\t\treturn `${config.kit.outDir}/${name}`;\n\t\t},\n\n\t\tgetClientDirectory() {\n\t\t\treturn `${config.kit.outDir}/output/client`;\n\t\t},\n\n\t\tgetServerDirectory() {\n\t\t\treturn `${config.kit.outDir}/output/server`;\n\t\t},\n\n\t\tgetAppPath() {\n\t\t\treturn build_data.app_path;\n\t\t},\n\n\t\twriteClient(dest) {\n\t\t\treturn copy(`${config.kit.outDir}/output/client`, dest, {\n\t\t\t\t// avoid making vite build artefacts public\n\t\t\t\tfilter: (basename) => basename !== '.vite'\n\t\t\t});\n\t\t},\n\n\t\twritePrerendered(dest) {\n\t\t\tconst source = `${config.kit.outDir}/output/prerendered`;\n\n\t\t\treturn [\n\t\t\t\t...copy(`${source}/pages`, dest),\n\t\t\t\t...copy(`${source}/dependencies`, dest),\n\t\t\t\t...copy(`${source}/data`, dest)\n\t\t\t];\n\t\t},\n\n\t\twriteServer(dest) {\n\t\t\treturn copy(`${config.kit.outDir}/output/server`, dest);\n\t\t},\n\n\t\thasServerInstrumentationFile() {\n\t\t\treturn existsSync(`${config.kit.outDir}/output/server/instrumentation.server.js`);\n\t\t},\n\n\t\tinstrument({\n\t\t\tentrypoint,\n\t\t\tinstrumentation,\n\t\t\tstart = join(dirname(entrypoint), 'start.js'),\n\t\t\tmodule = {\n\t\t\t\texports: ['default']\n\t\t\t}\n\t\t}) {\n\t\t\tif (!existsSync(instrumentation)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Instrumentation file ${instrumentation} not found. This is probably a bug in your adapter.`\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!existsSync(entrypoint)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Entrypoint file ${entrypoint} not found. This is probably a bug in your adapter.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tcopy(entrypoint, start);\n\t\t\tif (existsSync(`${entrypoint}.map`)) {\n\t\t\t\tcopy(`${entrypoint}.map`, `${start}.map`);\n\t\t\t}\n\n\t\t\tconst relative_instrumentation = posixify(relative(dirname(entrypoint), instrumentation));\n\t\t\tconst relative_start = posixify(relative(dirname(entrypoint), start));\n\n\t\t\tconst facade =\n\t\t\t\t'generateText' in module\n\t\t\t\t\t? module.generateText({\n\t\t\t\t\t\t\tinstrumentation: relative_instrumentation,\n\t\t\t\t\t\t\tstart: relative_start\n\t\t\t\t\t\t})\n\t\t\t\t\t: create_instrumentation_facade({\n\t\t\t\t\t\t\tinstrumentation: relative_instrumentation,\n\t\t\t\t\t\t\tstart: relative_start,\n\t\t\t\t\t\t\texports: module.exports\n\t\t\t\t\t\t});\n\n\t\t\trimraf(entrypoint);\n\t\t\twrite(entrypoint, facade);\n\t\t}\n\t};\n}\n\n/**\n * @param {string} file\n * @param {'gz' | 'br'} format\n */\nasync function compress_file(file, format = 'gz') {\n\tconst compress =\n\t\tformat == 'br'\n\t\t\t? zlib.createBrotliCompress({\n\t\t\t\t\tparams: {\n\t\t\t\t\t\t[zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,\n\t\t\t\t\t\t[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,\n\t\t\t\t\t\t[zlib.constants.BROTLI_PARAM_SIZE_HINT]: statSync(file).size\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t: zlib.createGzip({ level: zlib.constants.Z_BEST_COMPRESSION });\n\n\tconst source = createReadStream(file);\n\tconst destination = createWriteStream(`${file}.${format}`);\n\n\tawait pipe(source, compress, destination);\n}\n\n/**\n * Given a list of exports, generate a facade that:\n * - Imports the instrumentation file\n * - Imports `exports` from the entrypoint (dynamically, if `tla` is true)\n * - Re-exports `exports` from the entrypoint\n *\n * `default` receives special treatment: It will be imported as `default` and exported with `export default`.\n *\n * @param {{ instrumentation: string; start: string; exports: string[] }} opts\n * @returns {string}\n */\nfunction create_instrumentation_facade({ instrumentation, start, exports }) {\n\tconst import_instrumentation = `import './${instrumentation}';`;\n\n\tlet alias_index = 0;\n\tconst aliases = new Map();\n\n\tfor (const name of exports.filter((name) => reserved.has(name))) {\n\t\t/*\n\t\t * you can do evil things like `export { c as class }`.\n\t\t * in order to import these, you need to alias them, and then un-alias them when re-exporting\n\t\t * this map will allow us to generate the following:\n\t\t * import { class as _1 } from 'entrypoint';\n\t\t * export { _1 as class };\n\t\t */\n\t\tlet alias = `_${alias_index++}`;\n\t\twhile (exports.includes(alias)) {\n\t\t\talias = `_${alias_index++}`;\n\t\t}\n\n\t\taliases.set(name, alias);\n\t}\n\n\tconst import_statements = [];\n\tconst export_statements = [];\n\n\tfor (const name of exports) {\n\t\tconst alias = aliases.get(name);\n\t\tif (alias) {\n\t\t\timport_statements.push(`${name}: ${alias}`);\n\t\t\texport_statements.push(`${alias} as ${name}`);\n\t\t} else {\n\t\t\timport_statements.push(`${name}`);\n\t\t\texport_statements.push(`${name}`);\n\t\t}\n\t}\n\n\tconst entrypoint_facade = [\n\t\t`const { ${import_statements.join(', ')} } = await import('./${start}');`,\n\t\texport_statements.length > 0 ? `export { ${export_statements.join(', ')} };` : ''\n\t]\n\t\t.filter(Boolean)\n\t\t.join('\\n');\n\n\treturn `${import_instrumentation}\\n${entrypoint_facade}`;\n}\n"
  },
  {
    "path": "packages/kit/src/core/adapt/builder.spec.js",
    "content": "import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs';\nimport { join, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { assert, expect, test } from 'vitest';\nimport { create_builder } from './builder.js';\nimport { posixify } from '../../utils/filesystem.js';\nimport { list_files } from '../utils.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = join(__filename, '..');\n\ntest('copy files', () => {\n\tconst cwd = join(__dirname, 'fixtures/basic');\n\tconst outDir = join(cwd, '.svelte-kit');\n\n\t/** @type {import('@sveltejs/kit').Config} */\n\tconst mocked = {\n\t\textensions: ['.svelte'],\n\t\tkit: {\n\t\t\tappDir: '_app',\n\t\t\tfiles: {\n\t\t\t\tassets: join(__dirname, 'fixtures/basic/static')\n\t\t\t},\n\t\t\toutDir\n\t\t}\n\t};\n\n\tconst builder = create_builder({\n\t\tconfig: /** @type {import('types').ValidatedConfig} */ (mocked),\n\t\t// @ts-expect-error\n\t\tbuild_data: {},\n\t\t// @ts-expect-error\n\t\tserver_metadata: {},\n\t\troute_data: [],\n\t\t// @ts-expect-error\n\t\tprerendered: {\n\t\t\tpaths: []\n\t\t},\n\t\t// @ts-expect-error\n\t\tprerender_map: {},\n\t\t// @ts-expect-error\n\t\tlog: {}\n\t});\n\n\tconst dest = join(__dirname, 'output');\n\n\trmSync(dest, { recursive: true, force: true });\n\n\texpect(builder.writeClient(dest)).toEqual(list_files(dest).map(posixify));\n\texpect(\n\t\tlist_files(`${outDir}/output/client`).filter((file) => !file.startsWith('.vite/'))\n\t).toEqual(list_files(dest));\n\n\trmSync(dest, { recursive: true, force: true });\n\n\texpect(builder.writeServer(dest)).toEqual(list_files(dest).map(posixify));\n\texpect(list_files(`${outDir}/output/server`)).toEqual(list_files(dest));\n\n\trmSync(dest, { force: true, recursive: true });\n});\n\ntest('compress files', async () => {\n\t// @ts-expect-error - we don't need the whole config for this test\n\tconst builder = create_builder({\n\t\troute_data: []\n\t});\n\n\tconst target = fileURLToPath(new URL('./fixtures/compress/foo.css', import.meta.url));\n\trmSync(target + '.br', { force: true });\n\trmSync(target + '.gz', { force: true });\n\tawait builder.compress(dirname(target));\n\tassert.ok(existsSync(target + '.br'));\n\tassert.ok(existsSync(target + '.gz'));\n});\n\ntest('instrument generates facade with posix paths', () => {\n\tconst fixtureDir = join(__dirname, 'fixtures/instrument');\n\tconst dest = join(__dirname, 'output');\n\n\trmSync(dest, { recursive: true, force: true });\n\tmkdirSync(join(dest, 'server'), { recursive: true });\n\tcopyFileSync(join(fixtureDir, 'index.js'), join(dest, 'index.js'));\n\tcopyFileSync(\n\t\tjoin(fixtureDir, 'server/instrumentation.server.js'),\n\t\tjoin(dest, 'server/instrumentation.server.js')\n\t);\n\n\tconst entrypoint = join(dest, 'index.js');\n\tconst instrumentation = join(dest, 'server', 'instrumentation.server.js');\n\n\t// @ts-expect-error - we don't need the whole config for this test\n\tconst builder = create_builder({ route_data: [] });\n\n\tbuilder.instrument({\n\t\tentrypoint,\n\t\tinstrumentation,\n\t\tmodule: { exports: ['default'] }\n\t});\n\n\t// Read the generated facade\n\tconst facade = readFileSync(entrypoint, 'utf-8');\n\n\t// Verify it uses forward slashes (not backslashes)\n\t// On Windows, path.relative() returns 'server\\instrumentation.server.js'\n\t// The fix ensures this becomes 'server/instrumentation.server.js'\n\texpect(facade).toContain(\"import './server/instrumentation.server.js'\");\n\texpect(facade).not.toContain('\\\\');\n\n\t// Cleanup\n\trmSync(dest, { recursive: true, force: true });\n});\n"
  },
  {
    "path": "packages/kit/src/core/adapt/fixtures/.gitignore",
    "content": "compress/*.br\ncompress/*.gz\n"
  },
  {
    "path": "packages/kit/src/core/adapt/fixtures/basic/static/answer.md",
    "content": "42\n"
  },
  {
    "path": "packages/kit/src/core/adapt/fixtures/compress/foo.css",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/adapt/fixtures/instrument/index.js",
    "content": "export default {};\n"
  },
  {
    "path": "packages/kit/src/core/adapt/fixtures/instrument/server/instrumentation.server.js",
    "content": "export {};\n"
  },
  {
    "path": "packages/kit/src/core/adapt/index.js",
    "content": "import colors from 'kleur';\nimport { create_builder } from './builder.js';\n\n/**\n * @param {import('types').ValidatedConfig} config\n * @param {import('types').BuildData} build_data\n * @param {import('types').ServerMetadata} server_metadata\n * @param {import('types').Prerendered} prerendered\n * @param {import('types').PrerenderMap} prerender_map\n * @param {import('types').Logger} log\n * @param {import('types').RemoteChunk[]} remotes\n * @param {import('vite').ResolvedConfig} vite_config\n */\nexport async function adapt(\n\tconfig,\n\tbuild_data,\n\tserver_metadata,\n\tprerendered,\n\tprerender_map,\n\tlog,\n\tremotes,\n\tvite_config\n) {\n\t// This is only called when adapter is truthy, so the cast is safe\n\tconst { name, adapt } = /** @type {import('@sveltejs/kit').Adapter} */ (config.kit.adapter);\n\n\tconsole.log(colors.bold().cyan(`\\n> Using ${name}`));\n\n\tconst builder = create_builder({\n\t\tconfig,\n\t\tbuild_data,\n\t\tserver_metadata,\n\t\troute_data: build_data.manifest_data.routes.filter((route) => route.page || route.endpoint),\n\t\tprerendered,\n\t\tprerender_map,\n\t\tlog,\n\t\tremotes,\n\t\tvite_config\n\t});\n\n\tawait adapt(builder);\n\n\tlog.success('done');\n}\n"
  },
  {
    "path": "packages/kit/src/core/config/default-error.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<title>%sveltekit.error.message%</title>\n\n\t\t<style>\n\t\t\tbody {\n\t\t\t\t--bg: white;\n\t\t\t\t--fg: #222;\n\t\t\t\t--divider: #ccc;\n\t\t\t\tbackground: var(--bg);\n\t\t\t\tcolor: var(--fg);\n\t\t\t\tfont-family:\n\t\t\t\t\tsystem-ui,\n\t\t\t\t\t-apple-system,\n\t\t\t\t\tBlinkMacSystemFont,\n\t\t\t\t\t'Segoe UI',\n\t\t\t\t\tRoboto,\n\t\t\t\t\tOxygen,\n\t\t\t\t\tUbuntu,\n\t\t\t\t\tCantarell,\n\t\t\t\t\t'Open Sans',\n\t\t\t\t\t'Helvetica Neue',\n\t\t\t\t\tsans-serif;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t.error {\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t\tmax-width: 32rem;\n\t\t\t\tmargin: 0 1rem;\n\t\t\t}\n\n\t\t\t.status {\n\t\t\t\tfont-weight: 200;\n\t\t\t\tfont-size: 3rem;\n\t\t\t\tline-height: 1;\n\t\t\t\tposition: relative;\n\t\t\t\ttop: -0.05rem;\n\t\t\t}\n\n\t\t\t.message {\n\t\t\t\tborder-left: 1px solid var(--divider);\n\t\t\t\tpadding: 0 0 0 1rem;\n\t\t\t\tmargin: 0 0 0 1rem;\n\t\t\t\tmin-height: 2.5rem;\n\t\t\t\tdisplay: flex;\n\t\t\t\talign-items: center;\n\t\t\t}\n\n\t\t\t.message h1 {\n\t\t\t\tfont-weight: 400;\n\t\t\t\tfont-size: 1em;\n\t\t\t\tmargin: 0;\n\t\t\t}\n\n\t\t\t@media (prefers-color-scheme: dark) {\n\t\t\t\tbody {\n\t\t\t\t\t--bg: #222;\n\t\t\t\t\t--fg: #ddd;\n\t\t\t\t\t--divider: #666;\n\t\t\t\t}\n\t\t\t}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<div class=\"error\">\n\t\t\t<span class=\"status\">%sveltekit.status%</span>\n\t\t\t<div class=\"message\">\n\t\t\t\t<h1>%sveltekit.error.message%</h1>\n\t\t\t</div>\n\t\t</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/src/core/config/fixtures/custom-src/svelte.config.js",
    "content": "export default {\n\tkit: {\n\t\tfiles: {\n\t\t\tsrc: 'source'\n\t\t}\n\t}\n};\n"
  },
  {
    "path": "packages/kit/src/core/config/fixtures/default/svelte.config.js",
    "content": "export default {};\n"
  },
  {
    "path": "packages/kit/src/core/config/fixtures/export-string/svelte.config.js",
    "content": "export default 'invalid';\n"
  },
  {
    "path": "packages/kit/src/core/config/fixtures/multiple/svelte.config.js",
    "content": "export default {};\n"
  },
  {
    "path": "packages/kit/src/core/config/fixtures/multiple/svelte.config.ts",
    "content": "// invalid export is on purpose to ensure that this file is not preferred over svelte.config.js\nexport default 'invalid';\n"
  },
  {
    "path": "packages/kit/src/core/config/fixtures/typescript/svelte.config.ts",
    "content": "export default {};\n"
  },
  {
    "path": "packages/kit/src/core/config/index.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport * as url from 'node:url';\nimport options from './options.js';\n\n/**\n * Loads the template (src/app.html by default) and validates that it has the\n * required content.\n * @param {string} cwd\n * @param {import('types').ValidatedConfig} config\n */\nexport function load_template(cwd, { kit }) {\n\tconst { env, files } = kit;\n\n\tconst relative = path.relative(cwd, files.appTemplate);\n\n\tif (!fs.existsSync(files.appTemplate)) {\n\t\tthrow new Error(`${relative} does not exist`);\n\t}\n\n\tconst contents = fs.readFileSync(files.appTemplate, 'utf8');\n\n\tconst expected_tags = ['%sveltekit.head%', '%sveltekit.body%'];\n\texpected_tags.forEach((tag) => {\n\t\tif (contents.indexOf(tag) === -1) {\n\t\t\tthrow new Error(`${relative} is missing ${tag}`);\n\t\t}\n\t});\n\n\tfor (const match of contents.matchAll(/%sveltekit\\.env\\.([^%]+)%/g)) {\n\t\tif (!match[1].startsWith(env.publicPrefix)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Environment variables in ${relative} must start with ${env.publicPrefix} (saw %sveltekit.env.${match[1]}%)`\n\t\t\t);\n\t\t}\n\t}\n\n\treturn contents;\n}\n\n/**\n * Loads the error page (src/error.html by default) if it exists.\n * Falls back to a generic error page content.\n * @param {import('types').ValidatedConfig} config\n */\nexport function load_error_page(config) {\n\tlet { errorTemplate } = config.kit.files;\n\n\t// Don't do this inside resolving the config, because that would mean\n\t// adding/removing error.html isn't detected and would require a restart.\n\tif (!fs.existsSync(config.kit.files.errorTemplate)) {\n\t\terrorTemplate = url.fileURLToPath(new URL('./default-error.html', import.meta.url));\n\t}\n\n\treturn fs.readFileSync(errorTemplate, 'utf-8');\n}\n\n/**\n * Loads and validates Svelte config file\n * @param {{ cwd?: string }} options\n * @returns {Promise<import('types').ValidatedConfig>}\n */\nexport async function load_config({ cwd = process.cwd() } = {}) {\n\tconst config_files = ['js', 'ts']\n\t\t.map((ext) => path.join(cwd, `svelte.config.${ext}`))\n\t\t.filter((f) => fs.existsSync(f));\n\n\tif (config_files.length === 0) {\n\t\tconsole.log(\n\t\t\t`No Svelte config file found in ${cwd} - using SvelteKit's default configuration without an adapter.`\n\t\t);\n\t\treturn process_config({}, { cwd });\n\t}\n\tconst config_file = config_files[0];\n\tif (config_files.length > 1) {\n\t\tconsole.log(\n\t\t\t`Found multiple Svelte config files in ${cwd}: ${config_files.map((f) => path.basename(f)).join(', ')}. Using ${path.basename(config_file)}`\n\t\t);\n\t}\n\tconst config = await import(`${url.pathToFileURL(config_file).href}?ts=${Date.now()}`);\n\n\ttry {\n\t\treturn process_config(config.default, { cwd });\n\t} catch (e) {\n\t\tconst error = /** @type {Error} */ (e);\n\n\t\t// redact the stack trace — it's not helpful to users\n\t\terror.stack = `Could not load ${config_file}: ${error.message}\\n`;\n\t\tthrow error;\n\t}\n}\n\n/**\n * @param {import('@sveltejs/kit').Config} config\n * @returns {import('types').ValidatedConfig}\n */\nfunction process_config(config, { cwd = process.cwd() } = {}) {\n\tconst validated = validate_config(config);\n\n\tvalidated.kit.outDir = path.resolve(cwd, validated.kit.outDir);\n\n\tfor (const key in validated.kit.files) {\n\t\tif (key === 'hooks') {\n\t\t\tvalidated.kit.files.hooks.client = path.resolve(cwd, validated.kit.files.hooks.client);\n\t\t\tvalidated.kit.files.hooks.server = path.resolve(cwd, validated.kit.files.hooks.server);\n\t\t\tvalidated.kit.files.hooks.universal = path.resolve(cwd, validated.kit.files.hooks.universal);\n\t\t} else {\n\t\t\t// @ts-expect-error\n\t\t\tvalidated.kit.files[key] = path.resolve(cwd, validated.kit.files[key]);\n\t\t}\n\t}\n\n\treturn validated;\n}\n\n/**\n * @param {import('@sveltejs/kit').Config} config\n * @returns {import('types').ValidatedConfig}\n */\nexport function validate_config(config) {\n\tif (typeof config !== 'object') {\n\t\tthrow new Error(\n\t\t\t'The Svelte config file must have a configuration object as its default export. See https://svelte.dev/docs/kit/configuration'\n\t\t);\n\t}\n\n\tconst validated = options(config, 'config');\n\tconst files = validated.kit.files;\n\n\tfiles.hooks.client ??= path.join(files.src, 'hooks.client');\n\tfiles.hooks.server ??= path.join(files.src, 'hooks.server');\n\tfiles.hooks.universal ??= path.join(files.src, 'hooks');\n\tfiles.lib ??= path.join(files.src, 'lib');\n\tfiles.params ??= path.join(files.src, 'params');\n\tfiles.routes ??= path.join(files.src, 'routes');\n\tfiles.serviceWorker ??= path.join(files.src, 'service-worker');\n\tfiles.appTemplate ??= path.join(files.src, 'app.html');\n\tfiles.errorTemplate ??= path.join(files.src, 'error.html');\n\n\tif (validated.kit.router.resolution === 'server') {\n\t\tif (validated.kit.router.type === 'hash') {\n\t\t\tthrow new Error(\n\t\t\t\t\"The `router.resolution` option cannot be 'server' if `router.type` is 'hash'\"\n\t\t\t);\n\t\t}\n\t\tif (validated.kit.output.bundleStrategy !== 'split') {\n\t\t\tthrow new Error(\n\t\t\t\t\"The `router.resolution` option cannot be 'server' if `output.bundleStrategy` is 'inline' or 'single'\"\n\t\t\t);\n\t\t}\n\t}\n\n\treturn validated;\n}\n"
  },
  {
    "path": "packages/kit/src/core/config/index.spec.js",
    "content": "import { join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { assert, expect, test } from 'vitest';\nimport { validate_config, load_config } from './index.js';\nimport process from 'node:process';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = join(__filename, '..');\n\n/**\n * mutates and remove keys from an object when check callback returns true\n * @param {Record<string, any>} o any object\n * @param {([key, value]: [string, any]) => boolean} check callback with access\n * \t\tto the key-value pair and returns a boolean that decides the deletion of key\n */\nfunction remove_keys(o, check) {\n\tfor (const key in o) {\n\t\tif (!Object.hasOwnProperty.call(o, key)) continue;\n\t\tif (check([key, o[key]])) delete o[key];\n\t\tconst nested = typeof o[key] === 'object' && !Array.isArray(o[key]);\n\t\tif (nested) remove_keys(o[key], check);\n\t}\n}\n\nconst directive_defaults = {\n\t'child-src': undefined,\n\t'default-src': undefined,\n\t'frame-src': undefined,\n\t'worker-src': undefined,\n\t'connect-src': undefined,\n\t'font-src': undefined,\n\t'img-src': undefined,\n\t'manifest-src': undefined,\n\t'media-src': undefined,\n\t'object-src': undefined,\n\t'prefetch-src': undefined,\n\t'script-src': undefined,\n\t'script-src-elem': undefined,\n\t'script-src-attr': undefined,\n\t'style-src': undefined,\n\t'style-src-elem': undefined,\n\t'style-src-attr': undefined,\n\t'base-uri': undefined,\n\tsandbox: undefined,\n\t'form-action': undefined,\n\t'frame-ancestors': undefined,\n\t'navigate-to': undefined,\n\t'report-uri': undefined,\n\t'report-to': undefined,\n\t'require-trusted-types-for': undefined,\n\t'trusted-types': undefined,\n\t'upgrade-insecure-requests': false,\n\t'require-sri-for': undefined,\n\t'block-all-mixed-content': false,\n\t'plugin-types': undefined,\n\treferrer: undefined\n};\n\nconst get_defaults = (prefix = '') => ({\n\textensions: ['.svelte'],\n\tkit: {\n\t\tadapter: null,\n\t\talias: {},\n\t\tappDir: '_app',\n\t\tcsp: {\n\t\t\tmode: 'auto',\n\t\t\tdirectives: directive_defaults,\n\t\t\treportOnly: directive_defaults\n\t\t},\n\t\tcsrf: {\n\t\t\tcheckOrigin: true,\n\t\t\ttrustedOrigins: []\n\t\t},\n\t\tembedded: false,\n\t\tenv: {\n\t\t\tdir: process.cwd(),\n\t\t\tpublicPrefix: 'PUBLIC_',\n\t\t\tprivatePrefix: ''\n\t\t},\n\t\texperimental: {\n\t\t\ttracing: { server: false },\n\t\t\tinstrumentation: { server: false },\n\t\t\tremoteFunctions: false,\n\t\t\tforkPreloads: false,\n\t\t\thandleRenderingErrors: false\n\t\t},\n\t\tfiles: {\n\t\t\tsrc: join(prefix, 'src'),\n\t\t\tassets: join(prefix, 'static'),\n\t\t\thooks: {\n\t\t\t\tclient: join(prefix, 'src/hooks.client'),\n\t\t\t\tserver: join(prefix, 'src/hooks.server'),\n\t\t\t\tuniversal: join(prefix, 'src/hooks')\n\t\t\t},\n\t\t\tlib: join(prefix, 'src/lib'),\n\t\t\tparams: join(prefix, 'src/params'),\n\t\t\troutes: join(prefix, 'src/routes'),\n\t\t\tserviceWorker: join(prefix, 'src/service-worker'),\n\t\t\tappTemplate: join(prefix, 'src/app.html'),\n\t\t\terrorTemplate: join(prefix, 'src/error.html')\n\t\t},\n\t\tinlineStyleThreshold: 0,\n\t\tmoduleExtensions: ['.js', '.ts'],\n\t\toutput: { preloadStrategy: 'modulepreload', bundleStrategy: 'split' },\n\t\toutDir: join(prefix, '.svelte-kit'),\n\t\trouter: {\n\t\t\ttype: 'pathname',\n\t\t\tresolution: 'client'\n\t\t},\n\t\tserviceWorker: {\n\t\t\tregister: true\n\t\t},\n\t\ttypescript: {},\n\t\tpaths: {\n\t\t\tbase: '',\n\t\t\tassets: '',\n\t\t\trelative: true\n\t\t},\n\t\tprerender: {\n\t\t\tconcurrency: 1,\n\t\t\tcrawl: true,\n\t\t\tentries: ['*'],\n\t\t\torigin: 'http://sveltekit-prerender'\n\t\t},\n\t\tversion: {\n\t\t\tname: Date.now().toString(),\n\t\t\tpollInterval: 0\n\t\t}\n\t}\n});\n\ntest('fills in defaults', () => {\n\tconst validated = validate_config({});\n\n\tassert.equal(validated.kit.serviceWorker.files(''), true);\n\n\tremove_keys(validated, ([, v]) => typeof v === 'function');\n\n\tconst defaults = get_defaults();\n\tdefaults.kit.version.name = validated.kit.version.name;\n\n\texpect(validated).toEqual(defaults);\n});\n\ntest('errors on invalid values', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\t// @ts-expect-error - given value expected to throw\n\t\t\t\tappDir: 42\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.appDir should be a string, if specified$/);\n});\n\ntest('errors on invalid nested values', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\tfiles: {\n\t\t\t\t\t// @ts-expect-error - given value expected to throw\n\t\t\t\t\tpotato: 'blah'\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^Unexpected option config\\.kit\\.files\\.potato$/);\n});\n\ntest('does not error on invalid top-level values', () => {\n\tassert.doesNotThrow(() => {\n\t\tvalidate_config({\n\t\t\tonwarn: () => {}\n\t\t});\n\t});\n});\n\ntest('errors on extension without leading .', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\textensions: ['blah']\n\t\t});\n\t}, /Each member of config\\.extensions must start with '\\.' — saw 'blah'/);\n});\n\ntest('fills in partial blanks', () => {\n\tconst validated = validate_config({\n\t\tkit: {\n\t\t\tfiles: {\n\t\t\t\tassets: 'public'\n\t\t\t},\n\t\t\tversion: {\n\t\t\t\tname: '0'\n\t\t\t}\n\t\t}\n\t});\n\n\tassert.equal(validated.kit.serviceWorker.files(''), true);\n\n\tremove_keys(validated, ([, v]) => typeof v === 'function');\n\n\tconst config = get_defaults();\n\tconfig.kit.files.assets = 'public';\n\tconfig.kit.version.name = '0';\n\n\texpect(validated).toEqual(config);\n});\n\ntest('fails if kit.appDir is blank', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\tappDir: ''\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.appDir cannot be empty$/);\n});\n\ntest('fails if kit.appDir is only slash', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\tappDir: '/'\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.appDir cannot start or end with '\\/'. See https:\\/\\/svelte\\.dev\\/docs\\/kit\\/configuration$/);\n});\n\ntest('fails if kit.appDir starts with slash', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\tappDir: '/_app'\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.appDir cannot start or end with '\\/'. See https:\\/\\/svelte\\.dev\\/docs\\/kit\\/configuration$/);\n});\n\ntest('fails if kit.appDir ends with slash', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\tappDir: '_app/'\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.appDir cannot start or end with '\\/'. See https:\\/\\/svelte\\.dev\\/docs\\/kit\\/configuration$/);\n});\n\ntest('fails if paths.base is not root-relative', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\tpaths: {\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tbase: 'https://example.com/somewhere/else'\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.paths\\.base option must either be the empty string or a root-relative path that starts but doesn't end with '\\/'. See https:\\/\\/svelte\\.dev\\/docs\\/kit\\/configuration#paths$/);\n});\n\ntest(\"fails if paths.base ends with '/'\", () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\tpaths: {\n\t\t\t\t\tbase: '/github-pages/'\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.paths\\.base option must either be the empty string or a root-relative path that starts but doesn't end with '\\/'. See https:\\/\\/svelte\\.dev\\/docs\\/kit\\/configuration#paths$/);\n});\n\ntest('fails if paths.assets is relative', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\tpaths: {\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tassets: 'foo'\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.paths\\.assets option must be an absolute path, if specified. See https:\\/\\/svelte\\.dev\\/docs\\/kit\\/configuration#paths$/);\n});\n\ntest('fails if paths.assets has trailing slash', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\tpaths: {\n\t\t\t\t\tassets: 'https://cdn.example.com/stuff/'\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.paths\\.assets option must not end with '\\/'. See https:\\/\\/svelte\\.dev\\/docs\\/kit\\/configuration#paths$/);\n});\n\ntest('fails if prerender.entries are invalid', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\tprerender: {\n\t\t\t\t\t// @ts-expect-error - given value expected to throw\n\t\t\t\t\tentries: ['foo']\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^Each member of config\\.kit.prerender.entries must be either '\\*' or an absolute path beginning with '\\/' — saw 'foo'$/);\n});\n\n/**\n * @param {string} name\n * @param {import('@sveltejs/kit').KitConfig['paths']} input\n * @param {import('@sveltejs/kit').KitConfig['paths']} output\n */\nfunction validate_paths(name, input, output) {\n\ttest(name, () => {\n\t\texpect(\n\t\t\tvalidate_config({\n\t\t\t\tkit: {\n\t\t\t\t\tpaths: input\n\t\t\t\t}\n\t\t\t}).kit.paths\n\t\t).toEqual(output);\n\t});\n}\n\nvalidate_paths(\n\t'empty assets relative to base path',\n\t{\n\t\tbase: '/path/to/base'\n\t},\n\t{\n\t\tbase: '/path/to/base',\n\t\tassets: '',\n\t\trelative: true\n\t}\n);\n\nvalidate_paths(\n\t'external assets',\n\t{\n\t\tassets: 'https://cdn.example.com'\n\t},\n\t{\n\t\tbase: '',\n\t\tassets: 'https://cdn.example.com',\n\t\trelative: true\n\t}\n);\n\nvalidate_paths(\n\t'external assets with base',\n\t{\n\t\tbase: '/path/to/base',\n\t\tassets: 'https://cdn.example.com'\n\t},\n\t{\n\t\tbase: '/path/to/base',\n\t\tassets: 'https://cdn.example.com',\n\t\trelative: true\n\t}\n);\n\ntest('load default config (esm)', async () => {\n\tconst cwd = join(__dirname, 'fixtures/default');\n\n\tconst config = await load_config({ cwd });\n\tremove_keys(config, ([, v]) => typeof v === 'function');\n\n\tconst defaults = get_defaults(cwd + '/');\n\tdefaults.kit.version.name = config.kit.version.name;\n\n\texpect(config).toEqual(defaults);\n});\n\ntest('load default config (esm) with .ts extensions', async () => {\n\tconst cwd = join(__dirname, 'fixtures/typescript');\n\n\tconst config = await load_config({ cwd });\n\tremove_keys(config, ([, v]) => typeof v === 'function');\n\n\tconst defaults = get_defaults(cwd + '/');\n\tdefaults.kit.version.name = config.kit.version.name;\n\n\texpect(config).toEqual(defaults);\n});\n\ntest('load .js config when both .js and .ts configs are present', async () => {\n\tconst cwd = join(__dirname, 'fixtures/multiple');\n\n\tconst config = await load_config({ cwd });\n\tremove_keys(config, ([, v]) => typeof v === 'function');\n\n\tconst defaults = get_defaults(cwd + '/');\n\tdefaults.kit.version.name = config.kit.version.name;\n\n\texpect(config).toEqual(defaults);\n});\n\ntest('errors on loading config with incorrect default export', async () => {\n\tlet message = null;\n\n\ttry {\n\t\tconst cwd = join(__dirname, 'fixtures', 'export-string');\n\t\tawait load_config({ cwd });\n\t} catch (/** @type {any} */ e) {\n\t\tmessage = e.message;\n\t}\n\n\tassert.equal(\n\t\tmessage,\n\t\t'The Svelte config file must have a configuration object as its default export. See https://svelte.dev/docs/kit/configuration'\n\t);\n});\n\ntest('accepts valid tracing values', () => {\n\tassert.doesNotThrow(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\texperimental: {\n\t\t\t\t\ttracing: { server: true }\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n\n\tassert.doesNotThrow(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\texperimental: {\n\t\t\t\t\ttracing: { server: false }\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n\n\tassert.doesNotThrow(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\texperimental: {\n\t\t\t\t\ttracing: undefined\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n});\n\ntest('errors on invalid tracing values', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\texperimental: {\n\t\t\t\t\t// @ts-expect-error - given value expected to throw\n\t\t\t\t\ttracing: true\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.experimental\\.tracing should be an object$/);\n\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\texperimental: {\n\t\t\t\t\t// @ts-expect-error - given value expected to throw\n\t\t\t\t\ttracing: 'server'\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.experimental\\.tracing should be an object$/);\n\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\texperimental: {\n\t\t\t\t\t// @ts-expect-error - given value expected to throw\n\t\t\t\t\ttracing: { server: 'invalid' }\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.experimental\\.tracing\\.server should be true or false, if specified$/);\n});\n\ntest('errors on invalid forkPreloads values', () => {\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\texperimental: {\n\t\t\t\t\t// @ts-expect-error - given value expected to throw\n\t\t\t\t\tforkPreloads: 'true'\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.experimental\\.forkPreloads should be true or false, if specified$/);\n\n\tassert.throws(() => {\n\t\tvalidate_config({\n\t\t\tkit: {\n\t\t\t\texperimental: {\n\t\t\t\t\t// @ts-expect-error - given value expected to throw\n\t\t\t\t\tforkPreloads: 1\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, /^config\\.kit\\.experimental\\.forkPreloads should be true or false, if specified$/);\n});\n\ntest('uses src prefix for other kit.files options', async () => {\n\tconst cwd = join(__dirname, 'fixtures/custom-src');\n\n\tconst config = await load_config({ cwd });\n\tremove_keys(config, ([, v]) => typeof v === 'function');\n\n\tconst defaults = get_defaults(cwd + '/');\n\tdefaults.kit.version.name = config.kit.version.name;\n\n\texpect(config.kit.files.lib).toEqual(join(cwd, 'source/lib'));\n});\n"
  },
  {
    "path": "packages/kit/src/core/config/options.js",
    "content": "import process from 'node:process';\nimport colors from 'kleur';\n\n/** @typedef {import('./types.js').Validator} Validator */\n\nconst directives = object({\n\t'child-src': string_array(),\n\t'default-src': string_array(),\n\t'frame-src': string_array(),\n\t'worker-src': string_array(),\n\t'connect-src': string_array(),\n\t'font-src': string_array(),\n\t'img-src': string_array(),\n\t'manifest-src': string_array(),\n\t'media-src': string_array(),\n\t'object-src': string_array(),\n\t'prefetch-src': string_array(),\n\t'script-src': string_array(),\n\t'script-src-elem': string_array(),\n\t'script-src-attr': string_array(),\n\t'style-src': string_array(),\n\t'style-src-elem': string_array(),\n\t'style-src-attr': string_array(),\n\t'base-uri': string_array(),\n\tsandbox: string_array(),\n\t'form-action': string_array(),\n\t'frame-ancestors': string_array(),\n\t'navigate-to': string_array(),\n\t'report-uri': string_array(),\n\t'report-to': string_array(),\n\t'require-trusted-types-for': string_array(),\n\t'trusted-types': string_array(),\n\t'upgrade-insecure-requests': boolean(false),\n\t'require-sri-for': string_array(),\n\t'block-all-mixed-content': boolean(false),\n\t'plugin-types': string_array(),\n\treferrer: string_array()\n});\n\n/** @type {Validator} */\nconst options = object(\n\t{\n\t\textensions: validate(['.svelte'], (input, keypath) => {\n\t\t\tif (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {\n\t\t\t\tthrow new Error(`${keypath} must be an array of strings`);\n\t\t\t}\n\n\t\t\tinput.forEach((extension) => {\n\t\t\t\tif (extension[0] !== '.') {\n\t\t\t\t\tthrow new Error(`Each member of ${keypath} must start with '.' — saw '${extension}'`);\n\t\t\t\t}\n\n\t\t\t\tif (!/^(\\.[a-z0-9]+)+$/i.test(extension)) {\n\t\t\t\t\tthrow new Error(`File extensions must be alphanumeric — saw '${extension}'`);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn input;\n\t\t}),\n\n\t\tkit: object({\n\t\t\tadapter: validate(null, (input, keypath) => {\n\t\t\t\tif (typeof input !== 'object' || !input.adapt) {\n\t\t\t\t\tlet message = `${keypath} should be an object with an \"adapt\" method`;\n\n\t\t\t\t\tif (Array.isArray(input) || typeof input === 'string') {\n\t\t\t\t\t\t// for the early adapter adopters\n\t\t\t\t\t\tmessage += ', rather than the name of an adapter';\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new Error(`${message}. See https://svelte.dev/docs/kit/adapters`);\n\t\t\t\t}\n\n\t\t\t\treturn input;\n\t\t\t}),\n\n\t\t\talias: validate({}, (input, keypath) => {\n\t\t\t\tif (typeof input !== 'object') {\n\t\t\t\t\tthrow new Error(`${keypath} should be an object`);\n\t\t\t\t}\n\n\t\t\t\tfor (const key in input) {\n\t\t\t\t\tassert_string(input[key], `${keypath}.${key}`);\n\t\t\t\t}\n\n\t\t\t\treturn input;\n\t\t\t}),\n\n\t\t\tappDir: validate('_app', (input, keypath) => {\n\t\t\t\tassert_string(input, keypath);\n\n\t\t\t\tif (input) {\n\t\t\t\t\tif (input.startsWith('/') || input.endsWith('/')) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\"config.kit.appDir cannot start or end with '/'. See https://svelte.dev/docs/kit/configuration\"\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`${keypath} cannot be empty`);\n\t\t\t\t}\n\n\t\t\t\treturn input;\n\t\t\t}),\n\n\t\t\tcsp: object({\n\t\t\t\tmode: list(['auto', 'hash', 'nonce']),\n\t\t\t\tdirectives,\n\t\t\t\treportOnly: directives\n\t\t\t}),\n\n\t\t\tcsrf: object({\n\t\t\t\tcheckOrigin: deprecate(\n\t\t\t\t\tboolean(true),\n\t\t\t\t\t(keypath) =>\n\t\t\t\t\t\t`\\`${keypath}\\` has been deprecated in favour of \\`csrf.trustedOrigins\\`. It will be removed in a future version`\n\t\t\t\t),\n\t\t\t\ttrustedOrigins: string_array([])\n\t\t\t}),\n\n\t\t\tembedded: boolean(false),\n\n\t\t\tenv: object({\n\t\t\t\tdir: string(process.cwd()),\n\t\t\t\tpublicPrefix: string('PUBLIC_'),\n\t\t\t\tprivatePrefix: string('')\n\t\t\t}),\n\n\t\t\texperimental: object({\n\t\t\t\ttracing: object({\n\t\t\t\t\tserver: boolean(false)\n\t\t\t\t}),\n\t\t\t\tinstrumentation: object({\n\t\t\t\t\tserver: boolean(false)\n\t\t\t\t}),\n\t\t\t\tremoteFunctions: boolean(false),\n\t\t\t\tforkPreloads: boolean(false),\n\t\t\t\thandleRenderingErrors: boolean(false)\n\t\t\t}),\n\n\t\t\tfiles: object({\n\t\t\t\tsrc: string('src'),\n\t\t\t\tassets: string('static'),\n\t\t\t\thooks: object({\n\t\t\t\t\tclient: string(null),\n\t\t\t\t\tserver: string(null),\n\t\t\t\t\tuniversal: string(null)\n\t\t\t\t}),\n\t\t\t\tlib: string(null),\n\t\t\t\tparams: string(null),\n\t\t\t\troutes: string(null),\n\t\t\t\tserviceWorker: string(null),\n\t\t\t\tappTemplate: string(null),\n\t\t\t\terrorTemplate: string(null)\n\t\t\t}),\n\n\t\t\tinlineStyleThreshold: number(0),\n\n\t\t\tmoduleExtensions: string_array(['.js', '.ts']),\n\n\t\t\toutDir: string('.svelte-kit'),\n\n\t\t\toutput: object({\n\t\t\t\tpreloadStrategy: list(['modulepreload', 'preload-js', 'preload-mjs']),\n\t\t\t\tbundleStrategy: list(['split', 'single', 'inline'])\n\t\t\t}),\n\n\t\t\tpaths: object({\n\t\t\t\tbase: validate('', (input, keypath) => {\n\t\t\t\t\tassert_string(input, keypath);\n\n\t\t\t\t\tif (input !== '' && (input.endsWith('/') || !input.startsWith('/'))) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`${keypath} option must either be the empty string or a root-relative path that starts but doesn't end with '/'. See https://svelte.dev/docs/kit/configuration#paths`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn input;\n\t\t\t\t}),\n\t\t\t\tassets: validate('', (input, keypath) => {\n\t\t\t\t\tassert_string(input, keypath);\n\n\t\t\t\t\tif (input) {\n\t\t\t\t\t\tif (!/^[a-z]+:\\/\\//.test(input)) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`${keypath} option must be an absolute path, if specified. See https://svelte.dev/docs/kit/configuration#paths`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (input.endsWith('/')) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`${keypath} option must not end with '/'. See https://svelte.dev/docs/kit/configuration#paths`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn input;\n\t\t\t\t}),\n\t\t\t\trelative: boolean(true)\n\t\t\t}),\n\n\t\t\tprerender: object({\n\t\t\t\tconcurrency: number(1),\n\t\t\t\tcrawl: boolean(true),\n\t\t\t\tentries: validate(['*'], (input, keypath) => {\n\t\t\t\t\tif (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {\n\t\t\t\t\t\tthrow new Error(`${keypath} must be an array of strings`);\n\t\t\t\t\t}\n\n\t\t\t\t\tinput.forEach((page) => {\n\t\t\t\t\t\tif (page !== '*' && page[0] !== '/') {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Each member of ${keypath} must be either '*' or an absolute path beginning with '/' — saw '${page}'`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\treturn input;\n\t\t\t\t}),\n\n\t\t\t\thandleHttpError: validate(\n\t\t\t\t\t(/** @type {any} */ { message }) => {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\tmessage +\n\t\t\t\t\t\t\t\t'\\nTo suppress or handle this error, implement `handleHttpError` in https://svelte.dev/docs/kit/configuration#prerender'\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\t(input, keypath) => {\n\t\t\t\t\t\tif (typeof input === 'function') return input;\n\t\t\t\t\t\tif (['fail', 'warn', 'ignore'].includes(input)) return input;\n\t\t\t\t\t\tthrow new Error(`${keypath} should be \"fail\", \"warn\", \"ignore\" or a custom function`);\n\t\t\t\t\t}\n\t\t\t\t),\n\n\t\t\t\thandleMissingId: validate(\n\t\t\t\t\t(/** @type {any} */ { message }) => {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\tmessage +\n\t\t\t\t\t\t\t\t'\\nTo suppress or handle this error, implement `handleMissingId` in https://svelte.dev/docs/kit/configuration#prerender'\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\t(input, keypath) => {\n\t\t\t\t\t\tif (typeof input === 'function') return input;\n\t\t\t\t\t\tif (['fail', 'warn', 'ignore'].includes(input)) return input;\n\t\t\t\t\t\tthrow new Error(`${keypath} should be \"fail\", \"warn\", \"ignore\" or a custom function`);\n\t\t\t\t\t}\n\t\t\t\t),\n\n\t\t\t\thandleEntryGeneratorMismatch: validate(\n\t\t\t\t\t(/** @type {any} */ { message }) => {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\tmessage +\n\t\t\t\t\t\t\t\t'\\nTo suppress or handle this error, implement `handleEntryGeneratorMismatch` in https://svelte.dev/docs/kit/configuration#prerender'\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\t(input, keypath) => {\n\t\t\t\t\t\tif (typeof input === 'function') return input;\n\t\t\t\t\t\tif (['fail', 'warn', 'ignore'].includes(input)) return input;\n\t\t\t\t\t\tthrow new Error(`${keypath} should be \"fail\", \"warn\", \"ignore\" or a custom function`);\n\t\t\t\t\t}\n\t\t\t\t),\n\n\t\t\t\thandleUnseenRoutes: validate(\n\t\t\t\t\t(/** @type {any} */ { message }) => {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\tmessage +\n\t\t\t\t\t\t\t\t'\\nTo suppress or handle this error, implement `handleUnseenRoutes` in https://svelte.dev/docs/kit/configuration#prerender'\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\t(input, keypath) => {\n\t\t\t\t\t\tif (typeof input === 'function') return input;\n\t\t\t\t\t\tif (['fail', 'warn', 'ignore'].includes(input)) return input;\n\t\t\t\t\t\tthrow new Error(`${keypath} should be \"fail\", \"warn\", \"ignore\" or a custom function`);\n\t\t\t\t\t}\n\t\t\t\t),\n\n\t\t\t\torigin: validate('http://sveltekit-prerender', (input, keypath) => {\n\t\t\t\t\tassert_string(input, keypath);\n\n\t\t\t\t\tlet origin;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\torigin = new URL(input).origin;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthrow new Error(`${keypath} must be a valid origin`);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (input !== origin) {\n\t\t\t\t\t\tthrow new Error(`${keypath} must be a valid origin (${origin} rather than ${input})`);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn origin;\n\t\t\t\t})\n\t\t\t}),\n\n\t\t\trouter: object({\n\t\t\t\ttype: list(['pathname', 'hash']),\n\t\t\t\tresolution: list(['client', 'server'])\n\t\t\t}),\n\n\t\t\tserviceWorker: object({\n\t\t\t\tregister: boolean(true),\n\t\t\t\t// options could be undefined but if it is defined we only validate that\n\t\t\t\t// it's an object since the type comes from the browser itself\n\t\t\t\toptions: validate(undefined, object({}, true)),\n\t\t\t\tfiles: fun((filename) => !/\\.DS_Store/.test(filename))\n\t\t\t}),\n\n\t\t\ttypescript: object({\n\t\t\t\tconfig: fun((config) => config)\n\t\t\t}),\n\n\t\t\tversion: object({\n\t\t\t\tname: string(Date.now().toString()),\n\t\t\t\tpollInterval: number(0)\n\t\t\t})\n\t\t})\n\t},\n\ttrue\n);\n\n/**\n * @param {Validator} fn\n * @param {(keypath: string) => string} get_message\n * @returns {Validator}\n */\nfunction deprecate(\n\tfn,\n\tget_message = (keypath) =>\n\t\t`The \\`${keypath}\\` option is deprecated, and will be removed in a future version`\n) {\n\treturn (input, keypath) => {\n\t\tif (input !== undefined) {\n\t\t\tconsole.warn(colors.bold().yellow(get_message(keypath)));\n\t\t}\n\n\t\treturn fn(input, keypath);\n\t};\n}\n\n/**\n * @param {Record<string, Validator>} children\n * @param {boolean} [allow_unknown]\n * @returns {Validator}\n */\nfunction object(children, allow_unknown = false) {\n\treturn (input, keypath) => {\n\t\t/** @type {Record<string, any>} */\n\t\tconst output = {};\n\n\t\tif ((input && typeof input !== 'object') || Array.isArray(input)) {\n\t\t\tthrow new Error(`${keypath} should be an object`);\n\t\t}\n\n\t\tfor (const key in input) {\n\t\t\tif (!(key in children)) {\n\t\t\t\tif (allow_unknown) {\n\t\t\t\t\toutput[key] = input[key];\n\t\t\t\t} else {\n\t\t\t\t\tlet message = `Unexpected option ${keypath}.${key}`;\n\n\t\t\t\t\t// special case\n\t\t\t\t\tif (keypath === 'config.kit' && key in options) {\n\t\t\t\t\t\tmessage += ` (did you mean config.${key}?)`;\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new Error(message);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const key in children) {\n\t\t\tconst validator = children[key];\n\t\t\toutput[key] = validator(input && input[key], `${keypath}.${key}`);\n\t\t}\n\n\t\treturn output;\n\t};\n}\n\n/**\n * @param {any} fallback\n * @param {(value: any, keypath: string) => any} fn\n * @returns {Validator}\n */\nfunction validate(fallback, fn) {\n\treturn (input, keypath) => {\n\t\treturn input === undefined ? fallback : fn(input, keypath);\n\t};\n}\n\n/**\n * @param {string | null} fallback\n * @param {boolean} allow_empty\n * @returns {Validator}\n */\nfunction string(fallback, allow_empty = true) {\n\treturn validate(fallback, (input, keypath) => {\n\t\tassert_string(input, keypath);\n\n\t\tif (!allow_empty && input === '') {\n\t\t\tthrow new Error(`${keypath} cannot be empty`);\n\t\t}\n\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {string[] | undefined} [fallback]\n * @returns {Validator}\n */\nfunction string_array(fallback) {\n\treturn validate(fallback, (input, keypath) => {\n\t\tif (!Array.isArray(input) || input.some((value) => typeof value !== 'string')) {\n\t\t\tthrow new Error(`${keypath} must be an array of strings, if specified`);\n\t\t}\n\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {number} fallback\n * @returns {Validator}\n */\nfunction number(fallback) {\n\treturn validate(fallback, (input, keypath) => {\n\t\tif (typeof input !== 'number') {\n\t\t\tthrow new Error(`${keypath} should be a number, if specified`);\n\t\t}\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {boolean} fallback\n * @returns {Validator}\n */\nfunction boolean(fallback) {\n\treturn validate(fallback, (input, keypath) => {\n\t\tif (typeof input !== 'boolean') {\n\t\t\tthrow new Error(`${keypath} should be true or false, if specified`);\n\t\t}\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {string[]} options\n * @returns {Validator}\n */\nfunction list(options, fallback = options[0]) {\n\treturn validate(fallback, (input, keypath) => {\n\t\tif (!options.includes(input)) {\n\t\t\t// prettier-ignore\n\t\t\tconst msg = options.length > 2\n\t\t\t\t? `${keypath} should be one of ${options.slice(0, -1).map(input => `\"${input}\"`).join(', ')} or \"${options[options.length - 1]}\"`\n\t\t\t\t: `${keypath} should be either \"${options[0]}\" or \"${options[1]}\"`;\n\n\t\t\tthrow new Error(msg);\n\t\t}\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {(...args: any) => any} fallback\n * @returns {Validator}\n */\nfunction fun(fallback) {\n\treturn validate(fallback, (input, keypath) => {\n\t\tif (typeof input !== 'function') {\n\t\t\tthrow new Error(`${keypath} should be a function, if specified`);\n\t\t}\n\t\treturn input;\n\t});\n}\n\n/**\n * @param {string} input\n * @param {string} keypath\n */\nfunction assert_string(input, keypath) {\n\tif (typeof input !== 'string') {\n\t\tthrow new Error(`${keypath} should be a string, if specified`);\n\t}\n}\n\nexport default options;\n"
  },
  {
    "path": "packages/kit/src/core/config/types.d.ts",
    "content": "export type Validator<T = any> = (input: T, keypath: string) => T;\n"
  },
  {
    "path": "packages/kit/src/core/env.js",
    "content": "import { GENERATED_COMMENT } from '../constants.js';\nimport { dedent } from './sync/utils.js';\nimport { runtime_base } from './utils.js';\n\n/**\n * @typedef {'public' | 'private'} EnvType\n */\n\n/**\n * @param {string} id\n * @param {Record<string, string>} env\n * @returns {string}\n */\nexport function create_static_module(id, env) {\n\t/** @type {string[]} */\n\tconst declarations = [];\n\n\tfor (const key in env) {\n\t\tif (!valid_identifier.test(key) || reserved.has(key)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst comment = `/** @type {import('${id}').${key}} */`;\n\t\tconst declaration = `export const ${key} = ${JSON.stringify(env[key])};`;\n\n\t\tdeclarations.push(`${comment}\\n${declaration}`);\n\t}\n\n\treturn GENERATED_COMMENT + declarations.join('\\n\\n');\n}\n\n/**\n * @param {EnvType} type\n * @param {Record<string, string> | undefined} dev_values If in a development mode, values to pre-populate the module with.\n */\nexport function create_dynamic_module(type, dev_values) {\n\tif (dev_values) {\n\t\tconst keys = Object.entries(dev_values).map(\n\t\t\t([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v)}`\n\t\t);\n\t\treturn `export const env = {\\n${keys.join(',\\n')}\\n}`;\n\t}\n\treturn `export { ${type}_env as env } from '${runtime_base}/shared-server.js';`;\n}\n\n/**\n * @param {EnvType} id\n * @param {import('types').Env} env\n * @returns {string}\n */\nexport function create_static_types(id, env) {\n\tconst declarations = Object.keys(env[id])\n\t\t.filter((k) => valid_identifier.test(k))\n\t\t.map((k) => `export const ${k}: string;`);\n\n\treturn dedent`\n\t\tdeclare module '$env/static/${id}' {\n\t\t\t${declarations.join('\\n')}\n\t\t}\n\t`;\n}\n\n/**\n * @param {EnvType} id\n * @param {import('types').Env} env\n * @param {{\n * \tpublic_prefix: string;\n * \tprivate_prefix: string;\n * }} prefixes\n * @returns {string}\n */\nexport function create_dynamic_types(id, env, { public_prefix, private_prefix }) {\n\tconst properties = Object.keys(env[id])\n\t\t.filter((k) => valid_identifier.test(k))\n\t\t.map((k) => `${k}: string;`);\n\n\tconst public_prefixed = `[key: \\`${public_prefix}\\${string}\\`]`;\n\tconst private_prefixed = `[key: \\`${private_prefix}\\${string}\\`]`;\n\n\tif (id === 'private') {\n\t\tif (public_prefix) {\n\t\t\tproperties.push(`${public_prefixed}: undefined;`);\n\t\t}\n\t\tproperties.push(`${private_prefixed}: string | undefined;`);\n\t} else {\n\t\tif (private_prefix) {\n\t\t\tproperties.push(`${private_prefixed}: undefined;`);\n\t\t}\n\t\tproperties.push(`${public_prefixed}: string | undefined;`);\n\t}\n\n\treturn dedent`\n\t\tdeclare module '$env/dynamic/${id}' {\n\t\t\texport const env: {\n\t\t\t\t${properties.join('\\n')}\n\t\t\t}\n\t\t}\n\t`;\n}\n\nexport const reserved = new Set([\n\t'do',\n\t'if',\n\t'in',\n\t'for',\n\t'let',\n\t'new',\n\t'try',\n\t'var',\n\t'case',\n\t'else',\n\t'enum',\n\t'eval',\n\t'null',\n\t'this',\n\t'true',\n\t'void',\n\t'with',\n\t'await',\n\t'break',\n\t'catch',\n\t'class',\n\t'const',\n\t'false',\n\t'super',\n\t'throw',\n\t'while',\n\t'yield',\n\t'delete',\n\t'export',\n\t'import',\n\t'public',\n\t'return',\n\t'static',\n\t'switch',\n\t'typeof',\n\t'default',\n\t'extends',\n\t'finally',\n\t'package',\n\t'private',\n\t'continue',\n\t'debugger',\n\t'function',\n\t'arguments',\n\t'interface',\n\t'protected',\n\t'implements',\n\t'instanceof'\n]);\n\nexport const valid_identifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n"
  },
  {
    "path": "packages/kit/src/core/generate_manifest/find_server_assets.js",
    "content": "import { find_deps } from '../../exports/vite/build/utils.js';\n\n/**\n * Finds all the assets that are imported by server files associated with `routes`\n * @param {import('types').BuildData} build_data\n * @param {import('types').RouteData[]} routes\n */\nexport function find_server_assets(build_data, routes) {\n\t/**\n\t * All nodes actually used in the routes definition (prerendered routes are omitted).\n\t * Root layout/error is always included as they are needed for 404 and root errors.\n\t * @type {Set<any>}\n\t */\n\tconst used_nodes = new Set([0, 1]);\n\n\t/** @type {Set<string>} */\n\tconst server_assets = new Set();\n\n\t/** @param {string} id */\n\tfunction add_assets(id) {\n\t\tif (id in build_data.server_manifest) {\n\t\t\tconst deps = find_deps(build_data.server_manifest, id, false);\n\t\t\tfor (const asset of deps.assets) {\n\t\t\t\tserver_assets.add(asset);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const route of routes) {\n\t\tif (route.page) {\n\t\t\tfor (const i of route.page.layouts) used_nodes.add(i);\n\t\t\tfor (const i of route.page.errors) used_nodes.add(i);\n\t\t\tused_nodes.add(route.page.leaf);\n\t\t}\n\n\t\tif (route.endpoint) {\n\t\t\tadd_assets(route.endpoint.file);\n\t\t}\n\t}\n\n\tfor (const n of used_nodes) {\n\t\tconst node = build_data.manifest_data.nodes[n];\n\t\tif (node?.universal) add_assets(node.universal);\n\t\tif (node?.server) add_assets(node.server);\n\t}\n\n\tif (build_data.manifest_data.hooks.server) {\n\t\tadd_assets(build_data.manifest_data.hooks.server);\n\t}\n\n\tif (build_data.manifest_data.hooks.universal) {\n\t\tadd_assets(build_data.manifest_data.hooks.universal);\n\t}\n\n\treturn Array.from(server_assets);\n}\n"
  },
  {
    "path": "packages/kit/src/core/generate_manifest/index.js",
    "content": "/** @import { RemoteChunk } from 'types' */\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport * as mime from 'mrmime';\nimport { s } from '../../utils/misc.js';\nimport { get_mime_lookup } from '../utils.js';\nimport { resolve_symlinks } from '../../exports/vite/build/utils.js';\nimport { compact } from '../../utils/array.js';\nimport { join_relative } from '../../utils/filesystem.js';\nimport { dedent } from '../sync/utils.js';\nimport { find_server_assets } from './find_server_assets.js';\nimport { uneval } from 'devalue';\n\n/**\n * Generates the data used to write the server-side manifest.js file. This data is used in the Vite\n * build process, to power routing, etc.\n * @param {{\n *   build_data: import('types').BuildData;\n *   prerendered: string[];\n *   relative_path: string;\n *   routes: import('types').RouteData[];\n *   remotes: RemoteChunk[];\n * }} opts\n */\nexport function generate_manifest({ build_data, prerendered, relative_path, routes, remotes }) {\n\t/**\n\t * @type {Map<any, number>} The new index of each node in the filtered nodes array\n\t */\n\tconst reindexed = new Map();\n\t/**\n\t * All nodes actually used in the routes definition (prerendered routes are omitted).\n\t * Root layout/error is always included as they are needed for 404 and root errors.\n\t * @type {Set<any>}\n\t */\n\tconst used_nodes = new Set([0, 1]);\n\n\tconst server_assets = find_server_assets(build_data, routes);\n\n\tfor (const route of routes) {\n\t\tif (route.page) {\n\t\t\tfor (const i of route.page.layouts) used_nodes.add(i);\n\t\t\tfor (const i of route.page.errors) used_nodes.add(i);\n\t\t\tused_nodes.add(route.page.leaf);\n\t\t}\n\t}\n\n\tconst node_paths = compact(\n\t\tbuild_data.manifest_data.nodes.map((_, i) => {\n\t\t\tif (used_nodes.has(i)) {\n\t\t\t\treindexed.set(i, reindexed.size);\n\t\t\t\treturn join_relative(relative_path, `/nodes/${i}.js`);\n\t\t\t}\n\t\t})\n\t);\n\n\t/** @type {(path: string) => string} */\n\tconst loader = (path) => `__memo(() => import('${path}'))`;\n\n\tconst assets = build_data.manifest_data.assets.map((asset) => asset.file);\n\tif (build_data.service_worker) {\n\t\tassets.push(build_data.service_worker);\n\t}\n\n\t// In case of server-side route resolution, we need to include all matchers. Prerendered routes are not part\n\t// of the server manifest, and they could reference matchers that then would not be included.\n\tconst matchers = new Set(\n\t\tbuild_data.client?.nodes ? Object.keys(build_data.manifest_data.matchers) : undefined\n\t);\n\n\t/** @param {Array<number | undefined>} indexes */\n\tfunction get_nodes(indexes) {\n\t\tconst string = indexes.map((n) => reindexed.get(n) ?? '').join(',');\n\n\t\t// since JavaScript ignores trailing commas, we need to insert a dummy\n\t\t// comma so that the array has the correct length if the last item\n\t\t// is undefined\n\t\treturn `[${string},]`;\n\t}\n\n\tconst mime_types = get_mime_lookup(build_data.manifest_data);\n\n\t/** @type {Record<string, number>} */\n\tconst files = {};\n\tfor (const file of server_assets) {\n\t\tfiles[file] = fs.statSync(path.resolve(build_data.out_dir, 'server', file)).size;\n\n\t\tconst ext = path.extname(file);\n\t\tmime_types[ext] ??= mime.lookup(ext) || '';\n\t}\n\n\t// prettier-ignore\n\t// String representation of\n\t/** @template {import('@sveltejs/kit').SSRManifest} T */\n\tconst manifest_expr = dedent`\n\t\t{\n\t\t\tappDir: ${s(build_data.app_dir)},\n\t\t\tappPath: ${s(build_data.app_path)},\n\t\t\tassets: new Set(${s(assets)}),\n\t\t\tmimeTypes: ${s(mime_types)},\n\t\t\t_: {\n\t\t\t\tclient: ${uneval(build_data.client)},\n\t\t\t\tnodes: [\n\t\t\t\t\t${(node_paths).map(loader).join(',\\n')}\n\t\t\t\t],\n\t\t\t\tremotes: {\n\t\t\t\t\t${remotes.map((remote) => `'${remote.hash}': ${loader(join_relative(relative_path, `chunks/remote-${remote.hash}.js`))}`).join(',\\n')}\n\t\t\t\t},\n\t\t\t\troutes: [\n\t\t\t\t\t${routes.map(route => {\n\t\t\t\t\t\tif (!route.page && !route.endpoint) return;\n\n\t\t\t\t\t\troute.params.forEach(param => {\n\t\t\t\t\t\t\tif (param.matcher) matchers.add(param.matcher);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn dedent`\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: ${s(route.id)},\n\t\t\t\t\t\t\t\tpattern: ${route.pattern},\n\t\t\t\t\t\t\t\tparams: ${s(route.params)},\n\t\t\t\t\t\t\t\tpage: ${route.page ? `{ layouts: ${get_nodes(route.page.layouts)}, errors: ${get_nodes(route.page.errors)}, leaf: ${reindexed.get(route.page.leaf)} }` : 'null'},\n\t\t\t\t\t\t\t\tendpoint: ${route.endpoint ? loader(join_relative(relative_path, resolve_symlinks(build_data.server_manifest, route.endpoint.file).chunk.file)) : 'null'}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t`;\n\t\t\t\t\t}).filter(Boolean).join(',\\n')}\n\t\t\t\t],\n\t\t\t\tprerendered_routes: new Set(${s(prerendered)}),\n\t\t\t\tmatchers: async () => {\n\t\t\t\t\t${Array.from(\n\t\t\t\t\t\tmatchers,\n\t\t\t\t\t\ttype => `const { match: ${type} } = await import ('${(join_relative(relative_path, `/entries/matchers/${type}.js`))}')`\n\t\t\t\t\t).join('\\n')}\n\t\t\t\t\treturn { ${Array.from(matchers).join(', ')} };\n\t\t\t\t},\n\t\t\t\tserver_assets: ${s(files)}\n\t\t\t}\n\t\t}\n\t`;\n\n\t// Memoize the loaders to prevent Node from doing unnecessary work\n\t// on every dynamic import call\n\treturn dedent`\n\t\t(() => {\n\t\tfunction __memo(fn) {\n\t\t\tlet value;\n\t\t\treturn () => value ??= (value = fn());\n\t\t}\n\n\t\treturn ${manifest_expr}\n\t\t})()\n\t`;\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/analyse.js",
    "content": "/** @import { RemoteChunk } from 'types' */\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { validate_server_exports } from '../../utils/exports.js';\nimport { load_config } from '../config/index.js';\nimport { forked } from '../../utils/fork.js';\nimport { installPolyfills } from '../../exports/node/polyfills.js';\nimport { ENDPOINT_METHODS } from '../../constants.js';\nimport { filter_env } from '../../utils/env.js';\nimport { has_server_load, resolve_route } from '../../utils/routing.js';\nimport { check_feature } from '../../utils/features.js';\nimport { createReadableStream } from '@sveltejs/kit/node';\nimport { PageNodes } from '../../utils/page_nodes.js';\nimport { build_server_nodes } from '../../exports/vite/build/build_server.js';\n\nexport default forked(import.meta.url, analyse);\n\n/**\n * @param {{\n *   hash: boolean;\n *   manifest_path: string;\n *   manifest_data: import('types').ManifestData;\n *   server_manifest: import('vite').Manifest;\n *   tracked_features: Record<string, string[]>;\n *   env: Record<string, string>;\n *   out: string;\n *   output_config: import('types').RecursiveRequired<import('types').ValidatedConfig['kit']['output']>;\n *   remotes: RemoteChunk[];\n * }} opts\n */\nasync function analyse({\n\thash,\n\tmanifest_path,\n\tmanifest_data,\n\tserver_manifest,\n\ttracked_features,\n\tenv,\n\tout,\n\toutput_config,\n\tremotes\n}) {\n\t/** @type {import('@sveltejs/kit').SSRManifest} */\n\tconst manifest = (await import(pathToFileURL(manifest_path).href)).manifest;\n\n\t/** @type {import('types').ValidatedKitConfig} */\n\tconst config = (await load_config()).kit;\n\n\tconst server_root = join(config.outDir, 'output');\n\n\t/** @type {import('types').ServerInternalModule} */\n\tconst internal = await import(pathToFileURL(`${server_root}/server/internal.js`).href);\n\n\tinstallPolyfills();\n\n\t// configure `import { building } from '$app/environment'` —\n\t// essential we do this before analysing the code\n\tinternal.set_building();\n\n\t// set env, `read`, and `manifest`, in case they're used in initialisation\n\tconst { publicPrefix: public_prefix, privatePrefix: private_prefix } = config.env;\n\tconst private_env = filter_env(env, private_prefix, public_prefix);\n\tconst public_env = filter_env(env, public_prefix, private_prefix);\n\tinternal.set_private_env(private_env);\n\tinternal.set_public_env(public_env);\n\tinternal.set_manifest(manifest);\n\tinternal.set_read_implementation((file) => createReadableStream(`${server_root}/server/${file}`));\n\n\t// first, build server nodes without the client manifest so we can analyse it\n\tbuild_server_nodes(out, config, manifest_data, server_manifest, null, null, null, output_config);\n\n\t/** @type {import('types').ServerMetadata} */\n\tconst metadata = {\n\t\tnodes: [],\n\t\troutes: new Map(),\n\t\tremotes: new Map()\n\t};\n\n\tconst nodes = await Promise.all(manifest._.nodes.map((loader) => loader()));\n\n\t// analyse nodes\n\tfor (const node of nodes) {\n\t\tif (hash && node.universal) {\n\t\t\tconst options = Object.keys(node.universal).filter((o) => o !== 'load');\n\t\t\tif (options.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Page options are ignored when \\`router.type === 'hash'\\` (${node.universal_id} has ${options\n\t\t\t\t\t\t.filter((o) => o !== 'load')\n\t\t\t\t\t\t.map((o) => `'${o}'`)\n\t\t\t\t\t\t.join(', ')})`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tmetadata.nodes[node.index] = {\n\t\t\thas_server_load: has_server_load(node),\n\t\t\thas_universal_load: node.universal?.load !== undefined\n\t\t};\n\t}\n\n\t// analyse routes\n\tfor (const route of manifest._.routes) {\n\t\tconst page =\n\t\t\troute.page &&\n\t\t\tanalyse_page(\n\t\t\t\troute.page.layouts.map((n) => (n === undefined ? n : nodes[n])),\n\t\t\t\tnodes[route.page.leaf]\n\t\t\t);\n\n\t\tconst endpoint = route.endpoint && analyse_endpoint(route, await route.endpoint());\n\n\t\tif (page?.prerender && endpoint?.prerender) {\n\t\t\tthrow new Error(`Cannot prerender a route with both +page and +server files (${route.id})`);\n\t\t}\n\n\t\tif (page?.config && endpoint?.config) {\n\t\t\tfor (const key in { ...page.config, ...endpoint.config }) {\n\t\t\t\tif (JSON.stringify(page.config[key]) !== JSON.stringify(endpoint.config[key])) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Mismatched route config for ${route.id} — the +page and +server files must export the same config, if any`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst route_config = page?.config ?? endpoint?.config ?? {};\n\t\tconst prerender = page?.prerender ?? endpoint?.prerender;\n\n\t\tif (prerender !== true) {\n\t\t\tfor (const feature of list_features(\n\t\t\t\troute,\n\t\t\t\tmanifest_data,\n\t\t\t\tserver_manifest,\n\t\t\t\ttracked_features\n\t\t\t)) {\n\t\t\t\tcheck_feature(route.id, route_config, feature, config.adapter);\n\t\t\t}\n\t\t}\n\n\t\tconst page_methods = page?.methods ?? [];\n\t\tconst api_methods = endpoint?.methods ?? [];\n\t\tconst entries = page?.entries ?? endpoint?.entries;\n\n\t\tmetadata.routes.set(route.id, {\n\t\t\tconfig: route_config,\n\t\t\tmethods: Array.from(new Set([...page_methods, ...api_methods])),\n\t\t\tpage: {\n\t\t\t\tmethods: page_methods\n\t\t\t},\n\t\t\tapi: {\n\t\t\t\tmethods: api_methods\n\t\t\t},\n\t\t\tprerender,\n\t\t\tentries:\n\t\t\t\tentries && (await entries()).map((entry_object) => resolve_route(route.id, entry_object))\n\t\t});\n\t}\n\n\t// analyse remotes\n\tfor (const remote of remotes) {\n\t\tconst loader = manifest._.remotes[remote.hash];\n\t\tconst { default: functions } = await loader();\n\n\t\tconst exports = new Map();\n\n\t\tfor (const name in functions) {\n\t\t\tconst internals = /** @type {import('types').RemoteInternals} */ (functions[name].__);\n\t\t\tconst type = internals.type;\n\n\t\t\texports.set(name, {\n\t\t\t\ttype,\n\t\t\t\tdynamic: type !== 'prerender' || internals.dynamic\n\t\t\t});\n\t\t}\n\n\t\tmetadata.remotes.set(remote.hash, exports);\n\t}\n\n\treturn { metadata };\n}\n\n/**\n * @param {import('types').SSRRoute} route\n * @param {import('types').SSREndpoint} mod\n */\nfunction analyse_endpoint(route, mod) {\n\tvalidate_server_exports(mod, route.id);\n\n\tif (mod.prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) {\n\t\tthrow new Error(\n\t\t\t`Cannot prerender a +server file with POST, PATCH, PUT, or DELETE (${route.id})`\n\t\t);\n\t}\n\n\t/** @type {Array<import('types').HttpMethod | '*'>} */\n\tconst methods = [];\n\n\tfor (const method of /** @type {import('types').HttpMethod[]} */ (ENDPOINT_METHODS)) {\n\t\tif (mod[method]) methods.push(method);\n\t}\n\n\tif (mod.fallback) {\n\t\tmethods.push('*');\n\t}\n\n\treturn {\n\t\tconfig: mod.config,\n\t\tentries: mod.entries,\n\t\tmethods,\n\t\tprerender: mod.prerender ?? false\n\t};\n}\n\n/**\n * @param {Array<import('types').SSRNode | undefined>} layouts\n * @param {import('types').SSRNode} leaf\n */\nfunction analyse_page(layouts, leaf) {\n\t/** @type {Array<'GET' | 'POST'>} */\n\tconst methods = ['GET'];\n\tif (leaf.server?.actions) methods.push('POST');\n\n\tconst nodes = new PageNodes([...layouts, leaf]);\n\tnodes.validate();\n\n\treturn {\n\t\tconfig: nodes.get_config(),\n\t\tentries: leaf.universal?.entries ?? leaf.server?.entries,\n\t\tmethods,\n\t\tprerender: nodes.prerender()\n\t};\n}\n\n/**\n * @param {import('types').SSRRoute} route\n * @param {import('types').ManifestData} manifest_data\n * @param {import('vite').Manifest} server_manifest\n * @param {Record<string, string[]>} tracked_features\n */\nfunction list_features(route, manifest_data, server_manifest, tracked_features) {\n\tconst features = new Set();\n\n\tconst route_data = /** @type {import('types').RouteData} */ (\n\t\tmanifest_data.routes.find((r) => r.id === route.id)\n\t);\n\n\tconst visited = new Set();\n\t/** @param {string} id */\n\tfunction visit(id) {\n\t\tif (visited.has(id)) return;\n\t\tvisited.add(id);\n\n\t\tconst chunk = server_manifest[id];\n\t\tif (!chunk) return;\n\n\t\tif (chunk.file in tracked_features) {\n\t\t\tfor (const feature of tracked_features[chunk.file]) {\n\t\t\t\tfeatures.add(feature);\n\t\t\t}\n\t\t}\n\n\t\tif (chunk.imports) {\n\t\t\tfor (const id of chunk.imports) {\n\t\t\t\tvisit(id);\n\t\t\t}\n\t\t}\n\t}\n\n\tlet page_node = route_data?.leaf;\n\twhile (page_node) {\n\t\tif (page_node.server) visit(page_node.server);\n\t\tpage_node = page_node.parent ?? null;\n\t}\n\n\tif (route_data.endpoint) {\n\t\tvisit(route_data.endpoint.file);\n\t}\n\n\tif (manifest_data.hooks.server) {\n\t\t// TODO if hooks.server.js imports `read`, it will be in the entry chunk\n\t\t// we don't currently account for that case\n\t\tvisit(manifest_data.hooks.server);\n\t}\n\n\treturn Array.from(features);\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/crawl.js",
    "content": "import { resolve, decode_uri } from '../../utils/url.js';\nimport { decode } from './entities.js';\n\nconst DOCTYPE = 'DOCTYPE';\nconst CDATA_OPEN = '[CDATA[';\nconst CDATA_CLOSE = ']]>';\nconst COMMENT_OPEN = '--';\nconst COMMENT_CLOSE = '-->';\n\nconst TAG_OPEN = /[a-zA-Z]/;\nconst TAG_CHAR = /[a-zA-Z0-9]/;\nconst ATTRIBUTE_NAME = /[^\\t\\n\\f />\"'=]/;\n\nconst WHITESPACE = /[\\s\\n\\r]/;\n\nconst CRAWLABLE_META_NAME_ATTRS = new Set([\n\t'og:url',\n\t'og:image',\n\t'og:image:url',\n\t'og:image:secure_url',\n\t'og:video',\n\t'og:video:url',\n\t'og:video:secure_url',\n\t'og:audio',\n\t'og:audio:url',\n\t'og:audio:secure_url',\n\t'twitter:image'\n]);\n\n/**\n * @param {string} html\n * @param {string} base\n */\nexport function crawl(html, base) {\n\t/** @type {string[]} */\n\tconst ids = [];\n\n\t/** @type {string[]} */\n\tconst hrefs = [];\n\n\tlet i = 0;\n\tmain: while (i < html.length) {\n\t\tconst char = html[i];\n\n\t\tif (char === '<') {\n\t\t\tif (html[i + 1] === '!') {\n\t\t\t\ti += 2;\n\n\t\t\t\tif (html.slice(i, i + DOCTYPE.length).toUpperCase() === DOCTYPE) {\n\t\t\t\t\ti += DOCTYPE.length;\n\t\t\t\t\twhile (i < html.length) {\n\t\t\t\t\t\tif (html[i++] === '>') {\n\t\t\t\t\t\t\tcontinue main;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// skip cdata\n\t\t\t\tif (html.slice(i, i + CDATA_OPEN.length) === CDATA_OPEN) {\n\t\t\t\t\ti += CDATA_OPEN.length;\n\t\t\t\t\twhile (i < html.length) {\n\t\t\t\t\t\tif (html.slice(i, i + CDATA_CLOSE.length) === CDATA_CLOSE) {\n\t\t\t\t\t\t\ti += CDATA_CLOSE.length;\n\t\t\t\t\t\t\tcontinue main;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ti += 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// skip comments\n\t\t\t\tif (html.slice(i, i + COMMENT_OPEN.length) === COMMENT_OPEN) {\n\t\t\t\t\ti += COMMENT_OPEN.length;\n\t\t\t\t\twhile (i < html.length) {\n\t\t\t\t\t\tif (html.slice(i, i + COMMENT_CLOSE.length) === COMMENT_CLOSE) {\n\t\t\t\t\t\t\ti += COMMENT_CLOSE.length;\n\t\t\t\t\t\t\tcontinue main;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ti += 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// parse opening tags\n\t\t\tconst start = ++i;\n\t\t\tif (TAG_OPEN.test(html[start])) {\n\t\t\t\twhile (i < html.length) {\n\t\t\t\t\tif (!TAG_CHAR.test(html[i])) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\ti += 1;\n\t\t\t\t}\n\n\t\t\t\tconst tag = html.slice(start, i).toUpperCase();\n\n\t\t\t\t/** @type {Record<string, string>} */\n\t\t\t\tconst attributes = {};\n\n\t\t\t\tif (tag === 'SCRIPT' || tag === 'STYLE') {\n\t\t\t\t\twhile (i < html.length) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thtml[i] === '<' &&\n\t\t\t\t\t\t\thtml[i + 1] === '/' &&\n\t\t\t\t\t\t\thtml.slice(i + 2, i + 2 + tag.length).toUpperCase() === tag\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue main;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ti += 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\twhile (i < html.length) {\n\t\t\t\t\tconst start = i;\n\n\t\t\t\t\tconst char = html[start];\n\t\t\t\t\tif (char === '>') break;\n\n\t\t\t\t\tif (ATTRIBUTE_NAME.test(char)) {\n\t\t\t\t\t\ti += 1;\n\n\t\t\t\t\t\twhile (i < html.length) {\n\t\t\t\t\t\t\tif (!ATTRIBUTE_NAME.test(html[i])) {\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\ti += 1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst name = html.slice(start, i).toLowerCase();\n\n\t\t\t\t\t\twhile (WHITESPACE.test(html[i])) i += 1;\n\n\t\t\t\t\t\tif (html[i] === '=') {\n\t\t\t\t\t\t\ti += 1;\n\t\t\t\t\t\t\twhile (WHITESPACE.test(html[i])) i += 1;\n\n\t\t\t\t\t\t\tlet value;\n\n\t\t\t\t\t\t\tif (html[i] === \"'\" || html[i] === '\"') {\n\t\t\t\t\t\t\t\tconst quote = html[i++];\n\n\t\t\t\t\t\t\t\tconst start = i;\n\t\t\t\t\t\t\t\tlet escaped = false;\n\n\t\t\t\t\t\t\t\twhile (i < html.length) {\n\t\t\t\t\t\t\t\t\tif (escaped) {\n\t\t\t\t\t\t\t\t\t\tescaped = false;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tconst char = html[i];\n\n\t\t\t\t\t\t\t\t\t\tif (html[i] === quote) {\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tif (char === '\\\\') {\n\t\t\t\t\t\t\t\t\t\t\tescaped = true;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\ti += 1;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tvalue = html.slice(start, i);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst start = i;\n\t\t\t\t\t\t\t\twhile (html[i] !== '>' && !WHITESPACE.test(html[i])) i += 1;\n\t\t\t\t\t\t\t\tvalue = html.slice(start, i);\n\n\t\t\t\t\t\t\t\ti -= 1;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tvalue = decode(value);\n\t\t\t\t\t\t\tattributes[name] = value;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ti -= 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ti += 1;\n\t\t\t\t}\n\n\t\t\t\tconst { href, id, name, property, rel, src, srcset, content } = attributes;\n\n\t\t\t\tif (href) {\n\t\t\t\t\tif (tag === 'BASE') {\n\t\t\t\t\t\tbase = resolve(base, href);\n\t\t\t\t\t} else if (!rel || !/\\bexternal\\b/i.test(rel)) {\n\t\t\t\t\t\threfs.push(resolve(base, href));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (id) {\n\t\t\t\t\tids.push(decode_uri(id));\n\t\t\t\t}\n\n\t\t\t\tif (name && tag === 'A') {\n\t\t\t\t\tids.push(decode_uri(name));\n\t\t\t\t}\n\n\t\t\t\tif (src) {\n\t\t\t\t\threfs.push(resolve(base, src));\n\t\t\t\t}\n\n\t\t\t\tif (srcset) {\n\t\t\t\t\tlet value = srcset;\n\t\t\t\t\tconst candidates = [];\n\t\t\t\t\tlet insideURL = true;\n\t\t\t\t\tvalue = value.trim();\n\t\t\t\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\t\t\t\tif (value[i] === ',' && (!insideURL || (insideURL && WHITESPACE.test(value[i + 1])))) {\n\t\t\t\t\t\t\tcandidates.push(value.slice(0, i));\n\t\t\t\t\t\t\tvalue = value.substring(i + 1).trim();\n\t\t\t\t\t\t\ti = 0;\n\t\t\t\t\t\t\tinsideURL = true;\n\t\t\t\t\t\t} else if (WHITESPACE.test(value[i])) {\n\t\t\t\t\t\t\tinsideURL = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcandidates.push(value);\n\t\t\t\t\tfor (const candidate of candidates) {\n\t\t\t\t\t\tconst src = candidate.split(WHITESPACE)[0];\n\t\t\t\t\t\tif (src) hrefs.push(resolve(base, src));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (tag === 'META' && content) {\n\t\t\t\t\tconst attr = name ?? property;\n\n\t\t\t\t\tif (attr && CRAWLABLE_META_NAME_ATTRS.has(attr)) {\n\t\t\t\t\t\threfs.push(resolve(base, content));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ti += 1;\n\t}\n\n\treturn { ids, hrefs };\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/crawl.spec.js",
    "content": "import fs from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { expect, test } from 'vitest';\nimport { crawl } from './crawl.js';\n\nconst fixtures = fileURLToPath(new URL('./fixtures', import.meta.url));\n\ntest.each(fs.readdirSync(fixtures))('%s', (fixture) => {\n\tconst input = fs.readFileSync(`${fixtures}/${fixture}/input.html`, 'utf8');\n\tconst expected = JSON.parse(fs.readFileSync(`${fixtures}/${fixture}/output.json`, 'utf8'));\n\tconst output = crawl(input, '/');\n\texpect(output).toEqual(expected);\n});\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/entities.js",
    "content": "/**\n * A list of all named HTML entities, from https://html.spec.whatwg.org/multipage/named-characters.html\n * @type {Record<string, string>}\n */\nconst entities = {\n\tAElig: 'Æ',\n\t'AElig;': 'Æ',\n\tAMP: '&',\n\t'AMP;': '&',\n\tAacute: 'Á',\n\t'Aacute;': 'Á',\n\t'Abreve;': 'Ă',\n\tAcirc: 'Â',\n\t'Acirc;': 'Â',\n\t'Acy;': 'А',\n\t'Afr;': '𝔄',\n\tAgrave: 'À',\n\t'Agrave;': 'À',\n\t'Alpha;': 'Α',\n\t'Amacr;': 'Ā',\n\t'And;': '⩓',\n\t'Aogon;': 'Ą',\n\t'Aopf;': '𝔸',\n\t'ApplyFunction;': '⁡',\n\tAring: 'Å',\n\t'Aring;': 'Å',\n\t'Ascr;': '𝒜',\n\t'Assign;': '≔',\n\tAtilde: 'Ã',\n\t'Atilde;': 'Ã',\n\tAuml: 'Ä',\n\t'Auml;': 'Ä',\n\t'Backslash;': '∖',\n\t'Barv;': '⫧',\n\t'Barwed;': '⌆',\n\t'Bcy;': 'Б',\n\t'Because;': '∵',\n\t'Bernoullis;': 'ℬ',\n\t'Beta;': 'Β',\n\t'Bfr;': '𝔅',\n\t'Bopf;': '𝔹',\n\t'Breve;': '˘',\n\t'Bscr;': 'ℬ',\n\t'Bumpeq;': '≎',\n\t'CHcy;': 'Ч',\n\tCOPY: '©',\n\t'COPY;': '©',\n\t'Cacute;': 'Ć',\n\t'Cap;': '⋒',\n\t'CapitalDifferentialD;': 'ⅅ',\n\t'Cayleys;': 'ℭ',\n\t'Ccaron;': 'Č',\n\tCcedil: 'Ç',\n\t'Ccedil;': 'Ç',\n\t'Ccirc;': 'Ĉ',\n\t'Cconint;': '∰',\n\t'Cdot;': 'Ċ',\n\t'Cedilla;': '¸',\n\t'CenterDot;': '·',\n\t'Cfr;': 'ℭ',\n\t'Chi;': 'Χ',\n\t'CircleDot;': '⊙',\n\t'CircleMinus;': '⊖',\n\t'CirclePlus;': '⊕',\n\t'CircleTimes;': '⊗',\n\t'ClockwiseContourIntegral;': '∲',\n\t'CloseCurlyDoubleQuote;': '”',\n\t'CloseCurlyQuote;': '’',\n\t'Colon;': '∷',\n\t'Colone;': '⩴',\n\t'Congruent;': '≡',\n\t'Conint;': '∯',\n\t'ContourIntegral;': '∮',\n\t'Copf;': 'ℂ',\n\t'Coproduct;': '∐',\n\t'CounterClockwiseContourIntegral;': '∳',\n\t'Cross;': '⨯',\n\t'Cscr;': '𝒞',\n\t'Cup;': '⋓',\n\t'CupCap;': '≍',\n\t'DD;': 'ⅅ',\n\t'DDotrahd;': '⤑',\n\t'DJcy;': 'Ђ',\n\t'DScy;': 'Ѕ',\n\t'DZcy;': 'Џ',\n\t'Dagger;': '‡',\n\t'Darr;': '↡',\n\t'Dashv;': '⫤',\n\t'Dcaron;': 'Ď',\n\t'Dcy;': 'Д',\n\t'Del;': '∇',\n\t'Delta;': 'Δ',\n\t'Dfr;': '𝔇',\n\t'DiacriticalAcute;': '´',\n\t'DiacriticalDot;': '˙',\n\t'DiacriticalDoubleAcute;': '˝',\n\t'DiacriticalGrave;': '`',\n\t'DiacriticalTilde;': '˜',\n\t'Diamond;': '⋄',\n\t'DifferentialD;': 'ⅆ',\n\t'Dopf;': '𝔻',\n\t'Dot;': '¨',\n\t'DotDot;': '⃜',\n\t'DotEqual;': '≐',\n\t'DoubleContourIntegral;': '∯',\n\t'DoubleDot;': '¨',\n\t'DoubleDownArrow;': '⇓',\n\t'DoubleLeftArrow;': '⇐',\n\t'DoubleLeftRightArrow;': '⇔',\n\t'DoubleLeftTee;': '⫤',\n\t'DoubleLongLeftArrow;': '⟸',\n\t'DoubleLongLeftRightArrow;': '⟺',\n\t'DoubleLongRightArrow;': '⟹',\n\t'DoubleRightArrow;': '⇒',\n\t'DoubleRightTee;': '⊨',\n\t'DoubleUpArrow;': '⇑',\n\t'DoubleUpDownArrow;': '⇕',\n\t'DoubleVerticalBar;': '∥',\n\t'DownArrow;': '↓',\n\t'DownArrowBar;': '⤓',\n\t'DownArrowUpArrow;': '⇵',\n\t'DownBreve;': '̑',\n\t'DownLeftRightVector;': '⥐',\n\t'DownLeftTeeVector;': '⥞',\n\t'DownLeftVector;': '↽',\n\t'DownLeftVectorBar;': '⥖',\n\t'DownRightTeeVector;': '⥟',\n\t'DownRightVector;': '⇁',\n\t'DownRightVectorBar;': '⥗',\n\t'DownTee;': '⊤',\n\t'DownTeeArrow;': '↧',\n\t'Downarrow;': '⇓',\n\t'Dscr;': '𝒟',\n\t'Dstrok;': 'Đ',\n\t'ENG;': 'Ŋ',\n\tETH: 'Ð',\n\t'ETH;': 'Ð',\n\tEacute: 'É',\n\t'Eacute;': 'É',\n\t'Ecaron;': 'Ě',\n\tEcirc: 'Ê',\n\t'Ecirc;': 'Ê',\n\t'Ecy;': 'Э',\n\t'Edot;': 'Ė',\n\t'Efr;': '𝔈',\n\tEgrave: 'È',\n\t'Egrave;': 'È',\n\t'Element;': '∈',\n\t'Emacr;': 'Ē',\n\t'EmptySmallSquare;': '◻',\n\t'EmptyVerySmallSquare;': '▫',\n\t'Eogon;': 'Ę',\n\t'Eopf;': '𝔼',\n\t'Epsilon;': 'Ε',\n\t'Equal;': '⩵',\n\t'EqualTilde;': '≂',\n\t'Equilibrium;': '⇌',\n\t'Escr;': 'ℰ',\n\t'Esim;': '⩳',\n\t'Eta;': 'Η',\n\tEuml: 'Ë',\n\t'Euml;': 'Ë',\n\t'Exists;': '∃',\n\t'ExponentialE;': 'ⅇ',\n\t'Fcy;': 'Ф',\n\t'Ffr;': '𝔉',\n\t'FilledSmallSquare;': '◼',\n\t'FilledVerySmallSquare;': '▪',\n\t'Fopf;': '𝔽',\n\t'ForAll;': '∀',\n\t'Fouriertrf;': 'ℱ',\n\t'Fscr;': 'ℱ',\n\t'GJcy;': 'Ѓ',\n\tGT: '>',\n\t'GT;': '>',\n\t'Gamma;': 'Γ',\n\t'Gammad;': 'Ϝ',\n\t'Gbreve;': 'Ğ',\n\t'Gcedil;': 'Ģ',\n\t'Gcirc;': 'Ĝ',\n\t'Gcy;': 'Г',\n\t'Gdot;': 'Ġ',\n\t'Gfr;': '𝔊',\n\t'Gg;': '⋙',\n\t'Gopf;': '𝔾',\n\t'GreaterEqual;': '≥',\n\t'GreaterEqualLess;': '⋛',\n\t'GreaterFullEqual;': '≧',\n\t'GreaterGreater;': '⪢',\n\t'GreaterLess;': '≷',\n\t'GreaterSlantEqual;': '⩾',\n\t'GreaterTilde;': '≳',\n\t'Gscr;': '𝒢',\n\t'Gt;': '≫',\n\t'HARDcy;': 'Ъ',\n\t'Hacek;': 'ˇ',\n\t'Hat;': '^',\n\t'Hcirc;': 'Ĥ',\n\t'Hfr;': 'ℌ',\n\t'HilbertSpace;': 'ℋ',\n\t'Hopf;': 'ℍ',\n\t'HorizontalLine;': '─',\n\t'Hscr;': 'ℋ',\n\t'Hstrok;': 'Ħ',\n\t'HumpDownHump;': '≎',\n\t'HumpEqual;': '≏',\n\t'IEcy;': 'Е',\n\t'IJlig;': 'Ĳ',\n\t'IOcy;': 'Ё',\n\tIacute: 'Í',\n\t'Iacute;': 'Í',\n\tIcirc: 'Î',\n\t'Icirc;': 'Î',\n\t'Icy;': 'И',\n\t'Idot;': 'İ',\n\t'Ifr;': 'ℑ',\n\tIgrave: 'Ì',\n\t'Igrave;': 'Ì',\n\t'Im;': 'ℑ',\n\t'Imacr;': 'Ī',\n\t'ImaginaryI;': 'ⅈ',\n\t'Implies;': '⇒',\n\t'Int;': '∬',\n\t'Integral;': '∫',\n\t'Intersection;': '⋂',\n\t'InvisibleComma;': '⁣',\n\t'InvisibleTimes;': '⁢',\n\t'Iogon;': 'Į',\n\t'Iopf;': '𝕀',\n\t'Iota;': 'Ι',\n\t'Iscr;': 'ℐ',\n\t'Itilde;': 'Ĩ',\n\t'Iukcy;': 'І',\n\tIuml: 'Ï',\n\t'Iuml;': 'Ï',\n\t'Jcirc;': 'Ĵ',\n\t'Jcy;': 'Й',\n\t'Jfr;': '𝔍',\n\t'Jopf;': '𝕁',\n\t'Jscr;': '𝒥',\n\t'Jsercy;': 'Ј',\n\t'Jukcy;': 'Є',\n\t'KHcy;': 'Х',\n\t'KJcy;': 'Ќ',\n\t'Kappa;': 'Κ',\n\t'Kcedil;': 'Ķ',\n\t'Kcy;': 'К',\n\t'Kfr;': '𝔎',\n\t'Kopf;': '𝕂',\n\t'Kscr;': '𝒦',\n\t'LJcy;': 'Љ',\n\tLT: '<',\n\t'LT;': '<',\n\t'Lacute;': 'Ĺ',\n\t'Lambda;': 'Λ',\n\t'Lang;': '⟪',\n\t'Laplacetrf;': 'ℒ',\n\t'Larr;': '↞',\n\t'Lcaron;': 'Ľ',\n\t'Lcedil;': 'Ļ',\n\t'Lcy;': 'Л',\n\t'LeftAngleBracket;': '⟨',\n\t'LeftArrow;': '←',\n\t'LeftArrowBar;': '⇤',\n\t'LeftArrowRightArrow;': '⇆',\n\t'LeftCeiling;': '⌈',\n\t'LeftDoubleBracket;': '⟦',\n\t'LeftDownTeeVector;': '⥡',\n\t'LeftDownVector;': '⇃',\n\t'LeftDownVectorBar;': '⥙',\n\t'LeftFloor;': '⌊',\n\t'LeftRightArrow;': '↔',\n\t'LeftRightVector;': '⥎',\n\t'LeftTee;': '⊣',\n\t'LeftTeeArrow;': '↤',\n\t'LeftTeeVector;': '⥚',\n\t'LeftTriangle;': '⊲',\n\t'LeftTriangleBar;': '⧏',\n\t'LeftTriangleEqual;': '⊴',\n\t'LeftUpDownVector;': '⥑',\n\t'LeftUpTeeVector;': '⥠',\n\t'LeftUpVector;': '↿',\n\t'LeftUpVectorBar;': '⥘',\n\t'LeftVector;': '↼',\n\t'LeftVectorBar;': '⥒',\n\t'Leftarrow;': '⇐',\n\t'Leftrightarrow;': '⇔',\n\t'LessEqualGreater;': '⋚',\n\t'LessFullEqual;': '≦',\n\t'LessGreater;': '≶',\n\t'LessLess;': '⪡',\n\t'LessSlantEqual;': '⩽',\n\t'LessTilde;': '≲',\n\t'Lfr;': '𝔏',\n\t'Ll;': '⋘',\n\t'Lleftarrow;': '⇚',\n\t'Lmidot;': 'Ŀ',\n\t'LongLeftArrow;': '⟵',\n\t'LongLeftRightArrow;': '⟷',\n\t'LongRightArrow;': '⟶',\n\t'Longleftarrow;': '⟸',\n\t'Longleftrightarrow;': '⟺',\n\t'Longrightarrow;': '⟹',\n\t'Lopf;': '𝕃',\n\t'LowerLeftArrow;': '↙',\n\t'LowerRightArrow;': '↘',\n\t'Lscr;': 'ℒ',\n\t'Lsh;': '↰',\n\t'Lstrok;': 'Ł',\n\t'Lt;': '≪',\n\t'Map;': '⤅',\n\t'Mcy;': 'М',\n\t'MediumSpace;': ' ',\n\t'Mellintrf;': 'ℳ',\n\t'Mfr;': '𝔐',\n\t'MinusPlus;': '∓',\n\t'Mopf;': '𝕄',\n\t'Mscr;': 'ℳ',\n\t'Mu;': 'Μ',\n\t'NJcy;': 'Њ',\n\t'Nacute;': 'Ń',\n\t'Ncaron;': 'Ň',\n\t'Ncedil;': 'Ņ',\n\t'Ncy;': 'Н',\n\t'NegativeMediumSpace;': '​',\n\t'NegativeThickSpace;': '​',\n\t'NegativeThinSpace;': '​',\n\t'NegativeVeryThinSpace;': '​',\n\t'NestedGreaterGreater;': '≫',\n\t'NestedLessLess;': '≪',\n\t'NewLine;': '\\n',\n\t'Nfr;': '𝔑',\n\t'NoBreak;': '⁠',\n\t'NonBreakingSpace;': ' ',\n\t'Nopf;': 'ℕ',\n\t'Not;': '⫬',\n\t'NotCongruent;': '≢',\n\t'NotCupCap;': '≭',\n\t'NotDoubleVerticalBar;': '∦',\n\t'NotElement;': '∉',\n\t'NotEqual;': '≠',\n\t'NotEqualTilde;': '≂̸',\n\t'NotExists;': '∄',\n\t'NotGreater;': '≯',\n\t'NotGreaterEqual;': '≱',\n\t'NotGreaterFullEqual;': '≧̸',\n\t'NotGreaterGreater;': '≫̸',\n\t'NotGreaterLess;': '≹',\n\t'NotGreaterSlantEqual;': '⩾̸',\n\t'NotGreaterTilde;': '≵',\n\t'NotHumpDownHump;': '≎̸',\n\t'NotHumpEqual;': '≏̸',\n\t'NotLeftTriangle;': '⋪',\n\t'NotLeftTriangleBar;': '⧏̸',\n\t'NotLeftTriangleEqual;': '⋬',\n\t'NotLess;': '≮',\n\t'NotLessEqual;': '≰',\n\t'NotLessGreater;': '≸',\n\t'NotLessLess;': '≪̸',\n\t'NotLessSlantEqual;': '⩽̸',\n\t'NotLessTilde;': '≴',\n\t'NotNestedGreaterGreater;': '⪢̸',\n\t'NotNestedLessLess;': '⪡̸',\n\t'NotPrecedes;': '⊀',\n\t'NotPrecedesEqual;': '⪯̸',\n\t'NotPrecedesSlantEqual;': '⋠',\n\t'NotReverseElement;': '∌',\n\t'NotRightTriangle;': '⋫',\n\t'NotRightTriangleBar;': '⧐̸',\n\t'NotRightTriangleEqual;': '⋭',\n\t'NotSquareSubset;': '⊏̸',\n\t'NotSquareSubsetEqual;': '⋢',\n\t'NotSquareSuperset;': '⊐̸',\n\t'NotSquareSupersetEqual;': '⋣',\n\t'NotSubset;': '⊂⃒',\n\t'NotSubsetEqual;': '⊈',\n\t'NotSucceeds;': '⊁',\n\t'NotSucceedsEqual;': '⪰̸',\n\t'NotSucceedsSlantEqual;': '⋡',\n\t'NotSucceedsTilde;': '≿̸',\n\t'NotSuperset;': '⊃⃒',\n\t'NotSupersetEqual;': '⊉',\n\t'NotTilde;': '≁',\n\t'NotTildeEqual;': '≄',\n\t'NotTildeFullEqual;': '≇',\n\t'NotTildeTilde;': '≉',\n\t'NotVerticalBar;': '∤',\n\t'Nscr;': '𝒩',\n\tNtilde: 'Ñ',\n\t'Ntilde;': 'Ñ',\n\t'Nu;': 'Ν',\n\t'OElig;': 'Œ',\n\tOacute: 'Ó',\n\t'Oacute;': 'Ó',\n\tOcirc: 'Ô',\n\t'Ocirc;': 'Ô',\n\t'Ocy;': 'О',\n\t'Odblac;': 'Ő',\n\t'Ofr;': '𝔒',\n\tOgrave: 'Ò',\n\t'Ograve;': 'Ò',\n\t'Omacr;': 'Ō',\n\t'Omega;': 'Ω',\n\t'Omicron;': 'Ο',\n\t'Oopf;': '𝕆',\n\t'OpenCurlyDoubleQuote;': '“',\n\t'OpenCurlyQuote;': '‘',\n\t'Or;': '⩔',\n\t'Oscr;': '𝒪',\n\tOslash: 'Ø',\n\t'Oslash;': 'Ø',\n\tOtilde: 'Õ',\n\t'Otilde;': 'Õ',\n\t'Otimes;': '⨷',\n\tOuml: 'Ö',\n\t'Ouml;': 'Ö',\n\t'OverBar;': '‾',\n\t'OverBrace;': '⏞',\n\t'OverBracket;': '⎴',\n\t'OverParenthesis;': '⏜',\n\t'PartialD;': '∂',\n\t'Pcy;': 'П',\n\t'Pfr;': '𝔓',\n\t'Phi;': 'Φ',\n\t'Pi;': 'Π',\n\t'PlusMinus;': '±',\n\t'Poincareplane;': 'ℌ',\n\t'Popf;': 'ℙ',\n\t'Pr;': '⪻',\n\t'Precedes;': '≺',\n\t'PrecedesEqual;': '⪯',\n\t'PrecedesSlantEqual;': '≼',\n\t'PrecedesTilde;': '≾',\n\t'Prime;': '″',\n\t'Product;': '∏',\n\t'Proportion;': '∷',\n\t'Proportional;': '∝',\n\t'Pscr;': '𝒫',\n\t'Psi;': 'Ψ',\n\tQUOT: '\"',\n\t'QUOT;': '\"',\n\t'Qfr;': '𝔔',\n\t'Qopf;': 'ℚ',\n\t'Qscr;': '𝒬',\n\t'RBarr;': '⤐',\n\tREG: '®',\n\t'REG;': '®',\n\t'Racute;': 'Ŕ',\n\t'Rang;': '⟫',\n\t'Rarr;': '↠',\n\t'Rarrtl;': '⤖',\n\t'Rcaron;': 'Ř',\n\t'Rcedil;': 'Ŗ',\n\t'Rcy;': 'Р',\n\t'Re;': 'ℜ',\n\t'ReverseElement;': '∋',\n\t'ReverseEquilibrium;': '⇋',\n\t'ReverseUpEquilibrium;': '⥯',\n\t'Rfr;': 'ℜ',\n\t'Rho;': 'Ρ',\n\t'RightAngleBracket;': '⟩',\n\t'RightArrow;': '→',\n\t'RightArrowBar;': '⇥',\n\t'RightArrowLeftArrow;': '⇄',\n\t'RightCeiling;': '⌉',\n\t'RightDoubleBracket;': '⟧',\n\t'RightDownTeeVector;': '⥝',\n\t'RightDownVector;': '⇂',\n\t'RightDownVectorBar;': '⥕',\n\t'RightFloor;': '⌋',\n\t'RightTee;': '⊢',\n\t'RightTeeArrow;': '↦',\n\t'RightTeeVector;': '⥛',\n\t'RightTriangle;': '⊳',\n\t'RightTriangleBar;': '⧐',\n\t'RightTriangleEqual;': '⊵',\n\t'RightUpDownVector;': '⥏',\n\t'RightUpTeeVector;': '⥜',\n\t'RightUpVector;': '↾',\n\t'RightUpVectorBar;': '⥔',\n\t'RightVector;': '⇀',\n\t'RightVectorBar;': '⥓',\n\t'Rightarrow;': '⇒',\n\t'Ropf;': 'ℝ',\n\t'RoundImplies;': '⥰',\n\t'Rrightarrow;': '⇛',\n\t'Rscr;': 'ℛ',\n\t'Rsh;': '↱',\n\t'RuleDelayed;': '⧴',\n\t'SHCHcy;': 'Щ',\n\t'SHcy;': 'Ш',\n\t'SOFTcy;': 'Ь',\n\t'Sacute;': 'Ś',\n\t'Sc;': '⪼',\n\t'Scaron;': 'Š',\n\t'Scedil;': 'Ş',\n\t'Scirc;': 'Ŝ',\n\t'Scy;': 'С',\n\t'Sfr;': '𝔖',\n\t'ShortDownArrow;': '↓',\n\t'ShortLeftArrow;': '←',\n\t'ShortRightArrow;': '→',\n\t'ShortUpArrow;': '↑',\n\t'Sigma;': 'Σ',\n\t'SmallCircle;': '∘',\n\t'Sopf;': '𝕊',\n\t'Sqrt;': '√',\n\t'Square;': '□',\n\t'SquareIntersection;': '⊓',\n\t'SquareSubset;': '⊏',\n\t'SquareSubsetEqual;': '⊑',\n\t'SquareSuperset;': '⊐',\n\t'SquareSupersetEqual;': '⊒',\n\t'SquareUnion;': '⊔',\n\t'Sscr;': '𝒮',\n\t'Star;': '⋆',\n\t'Sub;': '⋐',\n\t'Subset;': '⋐',\n\t'SubsetEqual;': '⊆',\n\t'Succeeds;': '≻',\n\t'SucceedsEqual;': '⪰',\n\t'SucceedsSlantEqual;': '≽',\n\t'SucceedsTilde;': '≿',\n\t'SuchThat;': '∋',\n\t'Sum;': '∑',\n\t'Sup;': '⋑',\n\t'Superset;': '⊃',\n\t'SupersetEqual;': '⊇',\n\t'Supset;': '⋑',\n\tTHORN: 'Þ',\n\t'THORN;': 'Þ',\n\t'TRADE;': '™',\n\t'TSHcy;': 'Ћ',\n\t'TScy;': 'Ц',\n\t'Tab;': '\\t',\n\t'Tau;': 'Τ',\n\t'Tcaron;': 'Ť',\n\t'Tcedil;': 'Ţ',\n\t'Tcy;': 'Т',\n\t'Tfr;': '𝔗',\n\t'Therefore;': '∴',\n\t'Theta;': 'Θ',\n\t'ThickSpace;': '  ',\n\t'ThinSpace;': ' ',\n\t'Tilde;': '∼',\n\t'TildeEqual;': '≃',\n\t'TildeFullEqual;': '≅',\n\t'TildeTilde;': '≈',\n\t'Topf;': '𝕋',\n\t'TripleDot;': '⃛',\n\t'Tscr;': '𝒯',\n\t'Tstrok;': 'Ŧ',\n\tUacute: 'Ú',\n\t'Uacute;': 'Ú',\n\t'Uarr;': '↟',\n\t'Uarrocir;': '⥉',\n\t'Ubrcy;': 'Ў',\n\t'Ubreve;': 'Ŭ',\n\tUcirc: 'Û',\n\t'Ucirc;': 'Û',\n\t'Ucy;': 'У',\n\t'Udblac;': 'Ű',\n\t'Ufr;': '𝔘',\n\tUgrave: 'Ù',\n\t'Ugrave;': 'Ù',\n\t'Umacr;': 'Ū',\n\t'UnderBar;': '_',\n\t'UnderBrace;': '⏟',\n\t'UnderBracket;': '⎵',\n\t'UnderParenthesis;': '⏝',\n\t'Union;': '⋃',\n\t'UnionPlus;': '⊎',\n\t'Uogon;': 'Ų',\n\t'Uopf;': '𝕌',\n\t'UpArrow;': '↑',\n\t'UpArrowBar;': '⤒',\n\t'UpArrowDownArrow;': '⇅',\n\t'UpDownArrow;': '↕',\n\t'UpEquilibrium;': '⥮',\n\t'UpTee;': '⊥',\n\t'UpTeeArrow;': '↥',\n\t'Uparrow;': '⇑',\n\t'Updownarrow;': '⇕',\n\t'UpperLeftArrow;': '↖',\n\t'UpperRightArrow;': '↗',\n\t'Upsi;': 'ϒ',\n\t'Upsilon;': 'Υ',\n\t'Uring;': 'Ů',\n\t'Uscr;': '𝒰',\n\t'Utilde;': 'Ũ',\n\tUuml: 'Ü',\n\t'Uuml;': 'Ü',\n\t'VDash;': '⊫',\n\t'Vbar;': '⫫',\n\t'Vcy;': 'В',\n\t'Vdash;': '⊩',\n\t'Vdashl;': '⫦',\n\t'Vee;': '⋁',\n\t'Verbar;': '‖',\n\t'Vert;': '‖',\n\t'VerticalBar;': '∣',\n\t'VerticalLine;': '|',\n\t'VerticalSeparator;': '❘',\n\t'VerticalTilde;': '≀',\n\t'VeryThinSpace;': ' ',\n\t'Vfr;': '𝔙',\n\t'Vopf;': '𝕍',\n\t'Vscr;': '𝒱',\n\t'Vvdash;': '⊪',\n\t'Wcirc;': 'Ŵ',\n\t'Wedge;': '⋀',\n\t'Wfr;': '𝔚',\n\t'Wopf;': '𝕎',\n\t'Wscr;': '𝒲',\n\t'Xfr;': '𝔛',\n\t'Xi;': 'Ξ',\n\t'Xopf;': '𝕏',\n\t'Xscr;': '𝒳',\n\t'YAcy;': 'Я',\n\t'YIcy;': 'Ї',\n\t'YUcy;': 'Ю',\n\tYacute: 'Ý',\n\t'Yacute;': 'Ý',\n\t'Ycirc;': 'Ŷ',\n\t'Ycy;': 'Ы',\n\t'Yfr;': '𝔜',\n\t'Yopf;': '𝕐',\n\t'Yscr;': '𝒴',\n\t'Yuml;': 'Ÿ',\n\t'ZHcy;': 'Ж',\n\t'Zacute;': 'Ź',\n\t'Zcaron;': 'Ž',\n\t'Zcy;': 'З',\n\t'Zdot;': 'Ż',\n\t'ZeroWidthSpace;': '​',\n\t'Zeta;': 'Ζ',\n\t'Zfr;': 'ℨ',\n\t'Zopf;': 'ℤ',\n\t'Zscr;': '𝒵',\n\taacute: 'á',\n\t'aacute;': 'á',\n\t'abreve;': 'ă',\n\t'ac;': '∾',\n\t'acE;': '∾̳',\n\t'acd;': '∿',\n\tacirc: 'â',\n\t'acirc;': 'â',\n\tacute: '´',\n\t'acute;': '´',\n\t'acy;': 'а',\n\taelig: 'æ',\n\t'aelig;': 'æ',\n\t'af;': '⁡',\n\t'afr;': '𝔞',\n\tagrave: 'à',\n\t'agrave;': 'à',\n\t'alefsym;': 'ℵ',\n\t'aleph;': 'ℵ',\n\t'alpha;': 'α',\n\t'amacr;': 'ā',\n\t'amalg;': '⨿',\n\tamp: '&',\n\t'amp;': '&',\n\t'and;': '∧',\n\t'andand;': '⩕',\n\t'andd;': '⩜',\n\t'andslope;': '⩘',\n\t'andv;': '⩚',\n\t'ang;': '∠',\n\t'ange;': '⦤',\n\t'angle;': '∠',\n\t'angmsd;': '∡',\n\t'angmsdaa;': '⦨',\n\t'angmsdab;': '⦩',\n\t'angmsdac;': '⦪',\n\t'angmsdad;': '⦫',\n\t'angmsdae;': '⦬',\n\t'angmsdaf;': '⦭',\n\t'angmsdag;': '⦮',\n\t'angmsdah;': '⦯',\n\t'angrt;': '∟',\n\t'angrtvb;': '⊾',\n\t'angrtvbd;': '⦝',\n\t'angsph;': '∢',\n\t'angst;': 'Å',\n\t'angzarr;': '⍼',\n\t'aogon;': 'ą',\n\t'aopf;': '𝕒',\n\t'ap;': '≈',\n\t'apE;': '⩰',\n\t'apacir;': '⩯',\n\t'ape;': '≊',\n\t'apid;': '≋',\n\t'apos;': \"'\",\n\t'approx;': '≈',\n\t'approxeq;': '≊',\n\taring: 'å',\n\t'aring;': 'å',\n\t'ascr;': '𝒶',\n\t'ast;': '*',\n\t'asymp;': '≈',\n\t'asympeq;': '≍',\n\tatilde: 'ã',\n\t'atilde;': 'ã',\n\tauml: 'ä',\n\t'auml;': 'ä',\n\t'awconint;': '∳',\n\t'awint;': '⨑',\n\t'bNot;': '⫭',\n\t'backcong;': '≌',\n\t'backepsilon;': '϶',\n\t'backprime;': '‵',\n\t'backsim;': '∽',\n\t'backsimeq;': '⋍',\n\t'barvee;': '⊽',\n\t'barwed;': '⌅',\n\t'barwedge;': '⌅',\n\t'bbrk;': '⎵',\n\t'bbrktbrk;': '⎶',\n\t'bcong;': '≌',\n\t'bcy;': 'б',\n\t'bdquo;': '„',\n\t'becaus;': '∵',\n\t'because;': '∵',\n\t'bemptyv;': '⦰',\n\t'bepsi;': '϶',\n\t'bernou;': 'ℬ',\n\t'beta;': 'β',\n\t'beth;': 'ℶ',\n\t'between;': '≬',\n\t'bfr;': '𝔟',\n\t'bigcap;': '⋂',\n\t'bigcirc;': '◯',\n\t'bigcup;': '⋃',\n\t'bigodot;': '⨀',\n\t'bigoplus;': '⨁',\n\t'bigotimes;': '⨂',\n\t'bigsqcup;': '⨆',\n\t'bigstar;': '★',\n\t'bigtriangledown;': '▽',\n\t'bigtriangleup;': '△',\n\t'biguplus;': '⨄',\n\t'bigvee;': '⋁',\n\t'bigwedge;': '⋀',\n\t'bkarow;': '⤍',\n\t'blacklozenge;': '⧫',\n\t'blacksquare;': '▪',\n\t'blacktriangle;': '▴',\n\t'blacktriangledown;': '▾',\n\t'blacktriangleleft;': '◂',\n\t'blacktriangleright;': '▸',\n\t'blank;': '␣',\n\t'blk12;': '▒',\n\t'blk14;': '░',\n\t'blk34;': '▓',\n\t'block;': '█',\n\t'bne;': '=⃥',\n\t'bnequiv;': '≡⃥',\n\t'bnot;': '⌐',\n\t'bopf;': '𝕓',\n\t'bot;': '⊥',\n\t'bottom;': '⊥',\n\t'bowtie;': '⋈',\n\t'boxDL;': '╗',\n\t'boxDR;': '╔',\n\t'boxDl;': '╖',\n\t'boxDr;': '╓',\n\t'boxH;': '═',\n\t'boxHD;': '╦',\n\t'boxHU;': '╩',\n\t'boxHd;': '╤',\n\t'boxHu;': '╧',\n\t'boxUL;': '╝',\n\t'boxUR;': '╚',\n\t'boxUl;': '╜',\n\t'boxUr;': '╙',\n\t'boxV;': '║',\n\t'boxVH;': '╬',\n\t'boxVL;': '╣',\n\t'boxVR;': '╠',\n\t'boxVh;': '╫',\n\t'boxVl;': '╢',\n\t'boxVr;': '╟',\n\t'boxbox;': '⧉',\n\t'boxdL;': '╕',\n\t'boxdR;': '╒',\n\t'boxdl;': '┐',\n\t'boxdr;': '┌',\n\t'boxh;': '─',\n\t'boxhD;': '╥',\n\t'boxhU;': '╨',\n\t'boxhd;': '┬',\n\t'boxhu;': '┴',\n\t'boxminus;': '⊟',\n\t'boxplus;': '⊞',\n\t'boxtimes;': '⊠',\n\t'boxuL;': '╛',\n\t'boxuR;': '╘',\n\t'boxul;': '┘',\n\t'boxur;': '└',\n\t'boxv;': '│',\n\t'boxvH;': '╪',\n\t'boxvL;': '╡',\n\t'boxvR;': '╞',\n\t'boxvh;': '┼',\n\t'boxvl;': '┤',\n\t'boxvr;': '├',\n\t'bprime;': '‵',\n\t'breve;': '˘',\n\tbrvbar: '¦',\n\t'brvbar;': '¦',\n\t'bscr;': '𝒷',\n\t'bsemi;': '⁏',\n\t'bsim;': '∽',\n\t'bsime;': '⋍',\n\t'bsol;': '\\\\',\n\t'bsolb;': '⧅',\n\t'bsolhsub;': '⟈',\n\t'bull;': '•',\n\t'bullet;': '•',\n\t'bump;': '≎',\n\t'bumpE;': '⪮',\n\t'bumpe;': '≏',\n\t'bumpeq;': '≏',\n\t'cacute;': 'ć',\n\t'cap;': '∩',\n\t'capand;': '⩄',\n\t'capbrcup;': '⩉',\n\t'capcap;': '⩋',\n\t'capcup;': '⩇',\n\t'capdot;': '⩀',\n\t'caps;': '∩︀',\n\t'caret;': '⁁',\n\t'caron;': 'ˇ',\n\t'ccaps;': '⩍',\n\t'ccaron;': 'č',\n\tccedil: 'ç',\n\t'ccedil;': 'ç',\n\t'ccirc;': 'ĉ',\n\t'ccups;': '⩌',\n\t'ccupssm;': '⩐',\n\t'cdot;': 'ċ',\n\tcedil: '¸',\n\t'cedil;': '¸',\n\t'cemptyv;': '⦲',\n\tcent: '¢',\n\t'cent;': '¢',\n\t'centerdot;': '·',\n\t'cfr;': '𝔠',\n\t'chcy;': 'ч',\n\t'check;': '✓',\n\t'checkmark;': '✓',\n\t'chi;': 'χ',\n\t'cir;': '○',\n\t'cirE;': '⧃',\n\t'circ;': 'ˆ',\n\t'circeq;': '≗',\n\t'circlearrowleft;': '↺',\n\t'circlearrowright;': '↻',\n\t'circledR;': '®',\n\t'circledS;': 'Ⓢ',\n\t'circledast;': '⊛',\n\t'circledcirc;': '⊚',\n\t'circleddash;': '⊝',\n\t'cire;': '≗',\n\t'cirfnint;': '⨐',\n\t'cirmid;': '⫯',\n\t'cirscir;': '⧂',\n\t'clubs;': '♣',\n\t'clubsuit;': '♣',\n\t'colon;': ':',\n\t'colone;': '≔',\n\t'coloneq;': '≔',\n\t'comma;': ',',\n\t'commat;': '@',\n\t'comp;': '∁',\n\t'compfn;': '∘',\n\t'complement;': '∁',\n\t'complexes;': 'ℂ',\n\t'cong;': '≅',\n\t'congdot;': '⩭',\n\t'conint;': '∮',\n\t'copf;': '𝕔',\n\t'coprod;': '∐',\n\tcopy: '©',\n\t'copy;': '©',\n\t'copysr;': '℗',\n\t'crarr;': '↵',\n\t'cross;': '✗',\n\t'cscr;': '𝒸',\n\t'csub;': '⫏',\n\t'csube;': '⫑',\n\t'csup;': '⫐',\n\t'csupe;': '⫒',\n\t'ctdot;': '⋯',\n\t'cudarrl;': '⤸',\n\t'cudarrr;': '⤵',\n\t'cuepr;': '⋞',\n\t'cuesc;': '⋟',\n\t'cularr;': '↶',\n\t'cularrp;': '⤽',\n\t'cup;': '∪',\n\t'cupbrcap;': '⩈',\n\t'cupcap;': '⩆',\n\t'cupcup;': '⩊',\n\t'cupdot;': '⊍',\n\t'cupor;': '⩅',\n\t'cups;': '∪︀',\n\t'curarr;': '↷',\n\t'curarrm;': '⤼',\n\t'curlyeqprec;': '⋞',\n\t'curlyeqsucc;': '⋟',\n\t'curlyvee;': '⋎',\n\t'curlywedge;': '⋏',\n\tcurren: '¤',\n\t'curren;': '¤',\n\t'curvearrowleft;': '↶',\n\t'curvearrowright;': '↷',\n\t'cuvee;': '⋎',\n\t'cuwed;': '⋏',\n\t'cwconint;': '∲',\n\t'cwint;': '∱',\n\t'cylcty;': '⌭',\n\t'dArr;': '⇓',\n\t'dHar;': '⥥',\n\t'dagger;': '†',\n\t'daleth;': 'ℸ',\n\t'darr;': '↓',\n\t'dash;': '‐',\n\t'dashv;': '⊣',\n\t'dbkarow;': '⤏',\n\t'dblac;': '˝',\n\t'dcaron;': 'ď',\n\t'dcy;': 'д',\n\t'dd;': 'ⅆ',\n\t'ddagger;': '‡',\n\t'ddarr;': '⇊',\n\t'ddotseq;': '⩷',\n\tdeg: '°',\n\t'deg;': '°',\n\t'delta;': 'δ',\n\t'demptyv;': '⦱',\n\t'dfisht;': '⥿',\n\t'dfr;': '𝔡',\n\t'dharl;': '⇃',\n\t'dharr;': '⇂',\n\t'diam;': '⋄',\n\t'diamond;': '⋄',\n\t'diamondsuit;': '♦',\n\t'diams;': '♦',\n\t'die;': '¨',\n\t'digamma;': 'ϝ',\n\t'disin;': '⋲',\n\t'div;': '÷',\n\tdivide: '÷',\n\t'divide;': '÷',\n\t'divideontimes;': '⋇',\n\t'divonx;': '⋇',\n\t'djcy;': 'ђ',\n\t'dlcorn;': '⌞',\n\t'dlcrop;': '⌍',\n\t'dollar;': '$',\n\t'dopf;': '𝕕',\n\t'dot;': '˙',\n\t'doteq;': '≐',\n\t'doteqdot;': '≑',\n\t'dotminus;': '∸',\n\t'dotplus;': '∔',\n\t'dotsquare;': '⊡',\n\t'doublebarwedge;': '⌆',\n\t'downarrow;': '↓',\n\t'downdownarrows;': '⇊',\n\t'downharpoonleft;': '⇃',\n\t'downharpoonright;': '⇂',\n\t'drbkarow;': '⤐',\n\t'drcorn;': '⌟',\n\t'drcrop;': '⌌',\n\t'dscr;': '𝒹',\n\t'dscy;': 'ѕ',\n\t'dsol;': '⧶',\n\t'dstrok;': 'đ',\n\t'dtdot;': '⋱',\n\t'dtri;': '▿',\n\t'dtrif;': '▾',\n\t'duarr;': '⇵',\n\t'duhar;': '⥯',\n\t'dwangle;': '⦦',\n\t'dzcy;': 'џ',\n\t'dzigrarr;': '⟿',\n\t'eDDot;': '⩷',\n\t'eDot;': '≑',\n\teacute: 'é',\n\t'eacute;': 'é',\n\t'easter;': '⩮',\n\t'ecaron;': 'ě',\n\t'ecir;': '≖',\n\tecirc: 'ê',\n\t'ecirc;': 'ê',\n\t'ecolon;': '≕',\n\t'ecy;': 'э',\n\t'edot;': 'ė',\n\t'ee;': 'ⅇ',\n\t'efDot;': '≒',\n\t'efr;': '𝔢',\n\t'eg;': '⪚',\n\tegrave: 'è',\n\t'egrave;': 'è',\n\t'egs;': '⪖',\n\t'egsdot;': '⪘',\n\t'el;': '⪙',\n\t'elinters;': '⏧',\n\t'ell;': 'ℓ',\n\t'els;': '⪕',\n\t'elsdot;': '⪗',\n\t'emacr;': 'ē',\n\t'empty;': '∅',\n\t'emptyset;': '∅',\n\t'emptyv;': '∅',\n\t'emsp13;': ' ',\n\t'emsp14;': ' ',\n\t'emsp;': ' ',\n\t'eng;': 'ŋ',\n\t'ensp;': ' ',\n\t'eogon;': 'ę',\n\t'eopf;': '𝕖',\n\t'epar;': '⋕',\n\t'eparsl;': '⧣',\n\t'eplus;': '⩱',\n\t'epsi;': 'ε',\n\t'epsilon;': 'ε',\n\t'epsiv;': 'ϵ',\n\t'eqcirc;': '≖',\n\t'eqcolon;': '≕',\n\t'eqsim;': '≂',\n\t'eqslantgtr;': '⪖',\n\t'eqslantless;': '⪕',\n\t'equals;': '=',\n\t'equest;': '≟',\n\t'equiv;': '≡',\n\t'equivDD;': '⩸',\n\t'eqvparsl;': '⧥',\n\t'erDot;': '≓',\n\t'erarr;': '⥱',\n\t'escr;': 'ℯ',\n\t'esdot;': '≐',\n\t'esim;': '≂',\n\t'eta;': 'η',\n\teth: 'ð',\n\t'eth;': 'ð',\n\teuml: 'ë',\n\t'euml;': 'ë',\n\t'euro;': '€',\n\t'excl;': '!',\n\t'exist;': '∃',\n\t'expectation;': 'ℰ',\n\t'exponentiale;': 'ⅇ',\n\t'fallingdotseq;': '≒',\n\t'fcy;': 'ф',\n\t'female;': '♀',\n\t'ffilig;': 'ﬃ',\n\t'fflig;': 'ﬀ',\n\t'ffllig;': 'ﬄ',\n\t'ffr;': '𝔣',\n\t'filig;': 'ﬁ',\n\t'fjlig;': 'fj',\n\t'flat;': '♭',\n\t'fllig;': 'ﬂ',\n\t'fltns;': '▱',\n\t'fnof;': 'ƒ',\n\t'fopf;': '𝕗',\n\t'forall;': '∀',\n\t'fork;': '⋔',\n\t'forkv;': '⫙',\n\t'fpartint;': '⨍',\n\tfrac12: '½',\n\t'frac12;': '½',\n\t'frac13;': '⅓',\n\tfrac14: '¼',\n\t'frac14;': '¼',\n\t'frac15;': '⅕',\n\t'frac16;': '⅙',\n\t'frac18;': '⅛',\n\t'frac23;': '⅔',\n\t'frac25;': '⅖',\n\tfrac34: '¾',\n\t'frac34;': '¾',\n\t'frac35;': '⅗',\n\t'frac38;': '⅜',\n\t'frac45;': '⅘',\n\t'frac56;': '⅚',\n\t'frac58;': '⅝',\n\t'frac78;': '⅞',\n\t'frasl;': '⁄',\n\t'frown;': '⌢',\n\t'fscr;': '𝒻',\n\t'gE;': '≧',\n\t'gEl;': '⪌',\n\t'gacute;': 'ǵ',\n\t'gamma;': 'γ',\n\t'gammad;': 'ϝ',\n\t'gap;': '⪆',\n\t'gbreve;': 'ğ',\n\t'gcirc;': 'ĝ',\n\t'gcy;': 'г',\n\t'gdot;': 'ġ',\n\t'ge;': '≥',\n\t'gel;': '⋛',\n\t'geq;': '≥',\n\t'geqq;': '≧',\n\t'geqslant;': '⩾',\n\t'ges;': '⩾',\n\t'gescc;': '⪩',\n\t'gesdot;': '⪀',\n\t'gesdoto;': '⪂',\n\t'gesdotol;': '⪄',\n\t'gesl;': '⋛︀',\n\t'gesles;': '⪔',\n\t'gfr;': '𝔤',\n\t'gg;': '≫',\n\t'ggg;': '⋙',\n\t'gimel;': 'ℷ',\n\t'gjcy;': 'ѓ',\n\t'gl;': '≷',\n\t'glE;': '⪒',\n\t'gla;': '⪥',\n\t'glj;': '⪤',\n\t'gnE;': '≩',\n\t'gnap;': '⪊',\n\t'gnapprox;': '⪊',\n\t'gne;': '⪈',\n\t'gneq;': '⪈',\n\t'gneqq;': '≩',\n\t'gnsim;': '⋧',\n\t'gopf;': '𝕘',\n\t'grave;': '`',\n\t'gscr;': 'ℊ',\n\t'gsim;': '≳',\n\t'gsime;': '⪎',\n\t'gsiml;': '⪐',\n\tgt: '>',\n\t'gt;': '>',\n\t'gtcc;': '⪧',\n\t'gtcir;': '⩺',\n\t'gtdot;': '⋗',\n\t'gtlPar;': '⦕',\n\t'gtquest;': '⩼',\n\t'gtrapprox;': '⪆',\n\t'gtrarr;': '⥸',\n\t'gtrdot;': '⋗',\n\t'gtreqless;': '⋛',\n\t'gtreqqless;': '⪌',\n\t'gtrless;': '≷',\n\t'gtrsim;': '≳',\n\t'gvertneqq;': '≩︀',\n\t'gvnE;': '≩︀',\n\t'hArr;': '⇔',\n\t'hairsp;': ' ',\n\t'half;': '½',\n\t'hamilt;': 'ℋ',\n\t'hardcy;': 'ъ',\n\t'harr;': '↔',\n\t'harrcir;': '⥈',\n\t'harrw;': '↭',\n\t'hbar;': 'ℏ',\n\t'hcirc;': 'ĥ',\n\t'hearts;': '♥',\n\t'heartsuit;': '♥',\n\t'hellip;': '…',\n\t'hercon;': '⊹',\n\t'hfr;': '𝔥',\n\t'hksearow;': '⤥',\n\t'hkswarow;': '⤦',\n\t'hoarr;': '⇿',\n\t'homtht;': '∻',\n\t'hookleftarrow;': '↩',\n\t'hookrightarrow;': '↪',\n\t'hopf;': '𝕙',\n\t'horbar;': '―',\n\t'hscr;': '𝒽',\n\t'hslash;': 'ℏ',\n\t'hstrok;': 'ħ',\n\t'hybull;': '⁃',\n\t'hyphen;': '‐',\n\tiacute: 'í',\n\t'iacute;': 'í',\n\t'ic;': '⁣',\n\ticirc: 'î',\n\t'icirc;': 'î',\n\t'icy;': 'и',\n\t'iecy;': 'е',\n\tiexcl: '¡',\n\t'iexcl;': '¡',\n\t'iff;': '⇔',\n\t'ifr;': '𝔦',\n\tigrave: 'ì',\n\t'igrave;': 'ì',\n\t'ii;': 'ⅈ',\n\t'iiiint;': '⨌',\n\t'iiint;': '∭',\n\t'iinfin;': '⧜',\n\t'iiota;': '℩',\n\t'ijlig;': 'ĳ',\n\t'imacr;': 'ī',\n\t'image;': 'ℑ',\n\t'imagline;': 'ℐ',\n\t'imagpart;': 'ℑ',\n\t'imath;': 'ı',\n\t'imof;': '⊷',\n\t'imped;': 'Ƶ',\n\t'in;': '∈',\n\t'incare;': '℅',\n\t'infin;': '∞',\n\t'infintie;': '⧝',\n\t'inodot;': 'ı',\n\t'int;': '∫',\n\t'intcal;': '⊺',\n\t'integers;': 'ℤ',\n\t'intercal;': '⊺',\n\t'intlarhk;': '⨗',\n\t'intprod;': '⨼',\n\t'iocy;': 'ё',\n\t'iogon;': 'į',\n\t'iopf;': '𝕚',\n\t'iota;': 'ι',\n\t'iprod;': '⨼',\n\tiquest: '¿',\n\t'iquest;': '¿',\n\t'iscr;': '𝒾',\n\t'isin;': '∈',\n\t'isinE;': '⋹',\n\t'isindot;': '⋵',\n\t'isins;': '⋴',\n\t'isinsv;': '⋳',\n\t'isinv;': '∈',\n\t'it;': '⁢',\n\t'itilde;': 'ĩ',\n\t'iukcy;': 'і',\n\tiuml: 'ï',\n\t'iuml;': 'ï',\n\t'jcirc;': 'ĵ',\n\t'jcy;': 'й',\n\t'jfr;': '𝔧',\n\t'jmath;': 'ȷ',\n\t'jopf;': '𝕛',\n\t'jscr;': '𝒿',\n\t'jsercy;': 'ј',\n\t'jukcy;': 'є',\n\t'kappa;': 'κ',\n\t'kappav;': 'ϰ',\n\t'kcedil;': 'ķ',\n\t'kcy;': 'к',\n\t'kfr;': '𝔨',\n\t'kgreen;': 'ĸ',\n\t'khcy;': 'х',\n\t'kjcy;': 'ќ',\n\t'kopf;': '𝕜',\n\t'kscr;': '𝓀',\n\t'lAarr;': '⇚',\n\t'lArr;': '⇐',\n\t'lAtail;': '⤛',\n\t'lBarr;': '⤎',\n\t'lE;': '≦',\n\t'lEg;': '⪋',\n\t'lHar;': '⥢',\n\t'lacute;': 'ĺ',\n\t'laemptyv;': '⦴',\n\t'lagran;': 'ℒ',\n\t'lambda;': 'λ',\n\t'lang;': '⟨',\n\t'langd;': '⦑',\n\t'langle;': '⟨',\n\t'lap;': '⪅',\n\tlaquo: '«',\n\t'laquo;': '«',\n\t'larr;': '←',\n\t'larrb;': '⇤',\n\t'larrbfs;': '⤟',\n\t'larrfs;': '⤝',\n\t'larrhk;': '↩',\n\t'larrlp;': '↫',\n\t'larrpl;': '⤹',\n\t'larrsim;': '⥳',\n\t'larrtl;': '↢',\n\t'lat;': '⪫',\n\t'latail;': '⤙',\n\t'late;': '⪭',\n\t'lates;': '⪭︀',\n\t'lbarr;': '⤌',\n\t'lbbrk;': '❲',\n\t'lbrace;': '{',\n\t'lbrack;': '[',\n\t'lbrke;': '⦋',\n\t'lbrksld;': '⦏',\n\t'lbrkslu;': '⦍',\n\t'lcaron;': 'ľ',\n\t'lcedil;': 'ļ',\n\t'lceil;': '⌈',\n\t'lcub;': '{',\n\t'lcy;': 'л',\n\t'ldca;': '⤶',\n\t'ldquo;': '“',\n\t'ldquor;': '„',\n\t'ldrdhar;': '⥧',\n\t'ldrushar;': '⥋',\n\t'ldsh;': '↲',\n\t'le;': '≤',\n\t'leftarrow;': '←',\n\t'leftarrowtail;': '↢',\n\t'leftharpoondown;': '↽',\n\t'leftharpoonup;': '↼',\n\t'leftleftarrows;': '⇇',\n\t'leftrightarrow;': '↔',\n\t'leftrightarrows;': '⇆',\n\t'leftrightharpoons;': '⇋',\n\t'leftrightsquigarrow;': '↭',\n\t'leftthreetimes;': '⋋',\n\t'leg;': '⋚',\n\t'leq;': '≤',\n\t'leqq;': '≦',\n\t'leqslant;': '⩽',\n\t'les;': '⩽',\n\t'lescc;': '⪨',\n\t'lesdot;': '⩿',\n\t'lesdoto;': '⪁',\n\t'lesdotor;': '⪃',\n\t'lesg;': '⋚︀',\n\t'lesges;': '⪓',\n\t'lessapprox;': '⪅',\n\t'lessdot;': '⋖',\n\t'lesseqgtr;': '⋚',\n\t'lesseqqgtr;': '⪋',\n\t'lessgtr;': '≶',\n\t'lesssim;': '≲',\n\t'lfisht;': '⥼',\n\t'lfloor;': '⌊',\n\t'lfr;': '𝔩',\n\t'lg;': '≶',\n\t'lgE;': '⪑',\n\t'lhard;': '↽',\n\t'lharu;': '↼',\n\t'lharul;': '⥪',\n\t'lhblk;': '▄',\n\t'ljcy;': 'љ',\n\t'll;': '≪',\n\t'llarr;': '⇇',\n\t'llcorner;': '⌞',\n\t'llhard;': '⥫',\n\t'lltri;': '◺',\n\t'lmidot;': 'ŀ',\n\t'lmoust;': '⎰',\n\t'lmoustache;': '⎰',\n\t'lnE;': '≨',\n\t'lnap;': '⪉',\n\t'lnapprox;': '⪉',\n\t'lne;': '⪇',\n\t'lneq;': '⪇',\n\t'lneqq;': '≨',\n\t'lnsim;': '⋦',\n\t'loang;': '⟬',\n\t'loarr;': '⇽',\n\t'lobrk;': '⟦',\n\t'longleftarrow;': '⟵',\n\t'longleftrightarrow;': '⟷',\n\t'longmapsto;': '⟼',\n\t'longrightarrow;': '⟶',\n\t'looparrowleft;': '↫',\n\t'looparrowright;': '↬',\n\t'lopar;': '⦅',\n\t'lopf;': '𝕝',\n\t'loplus;': '⨭',\n\t'lotimes;': '⨴',\n\t'lowast;': '∗',\n\t'lowbar;': '_',\n\t'loz;': '◊',\n\t'lozenge;': '◊',\n\t'lozf;': '⧫',\n\t'lpar;': '(',\n\t'lparlt;': '⦓',\n\t'lrarr;': '⇆',\n\t'lrcorner;': '⌟',\n\t'lrhar;': '⇋',\n\t'lrhard;': '⥭',\n\t'lrm;': '‎',\n\t'lrtri;': '⊿',\n\t'lsaquo;': '‹',\n\t'lscr;': '𝓁',\n\t'lsh;': '↰',\n\t'lsim;': '≲',\n\t'lsime;': '⪍',\n\t'lsimg;': '⪏',\n\t'lsqb;': '[',\n\t'lsquo;': '‘',\n\t'lsquor;': '‚',\n\t'lstrok;': 'ł',\n\tlt: '<',\n\t'lt;': '<',\n\t'ltcc;': '⪦',\n\t'ltcir;': '⩹',\n\t'ltdot;': '⋖',\n\t'lthree;': '⋋',\n\t'ltimes;': '⋉',\n\t'ltlarr;': '⥶',\n\t'ltquest;': '⩻',\n\t'ltrPar;': '⦖',\n\t'ltri;': '◃',\n\t'ltrie;': '⊴',\n\t'ltrif;': '◂',\n\t'lurdshar;': '⥊',\n\t'luruhar;': '⥦',\n\t'lvertneqq;': '≨︀',\n\t'lvnE;': '≨︀',\n\t'mDDot;': '∺',\n\tmacr: '¯',\n\t'macr;': '¯',\n\t'male;': '♂',\n\t'malt;': '✠',\n\t'maltese;': '✠',\n\t'map;': '↦',\n\t'mapsto;': '↦',\n\t'mapstodown;': '↧',\n\t'mapstoleft;': '↤',\n\t'mapstoup;': '↥',\n\t'marker;': '▮',\n\t'mcomma;': '⨩',\n\t'mcy;': 'м',\n\t'mdash;': '—',\n\t'measuredangle;': '∡',\n\t'mfr;': '𝔪',\n\t'mho;': '℧',\n\tmicro: 'µ',\n\t'micro;': 'µ',\n\t'mid;': '∣',\n\t'midast;': '*',\n\t'midcir;': '⫰',\n\tmiddot: '·',\n\t'middot;': '·',\n\t'minus;': '−',\n\t'minusb;': '⊟',\n\t'minusd;': '∸',\n\t'minusdu;': '⨪',\n\t'mlcp;': '⫛',\n\t'mldr;': '…',\n\t'mnplus;': '∓',\n\t'models;': '⊧',\n\t'mopf;': '𝕞',\n\t'mp;': '∓',\n\t'mscr;': '𝓂',\n\t'mstpos;': '∾',\n\t'mu;': 'μ',\n\t'multimap;': '⊸',\n\t'mumap;': '⊸',\n\t'nGg;': '⋙̸',\n\t'nGt;': '≫⃒',\n\t'nGtv;': '≫̸',\n\t'nLeftarrow;': '⇍',\n\t'nLeftrightarrow;': '⇎',\n\t'nLl;': '⋘̸',\n\t'nLt;': '≪⃒',\n\t'nLtv;': '≪̸',\n\t'nRightarrow;': '⇏',\n\t'nVDash;': '⊯',\n\t'nVdash;': '⊮',\n\t'nabla;': '∇',\n\t'nacute;': 'ń',\n\t'nang;': '∠⃒',\n\t'nap;': '≉',\n\t'napE;': '⩰̸',\n\t'napid;': '≋̸',\n\t'napos;': 'ŉ',\n\t'napprox;': '≉',\n\t'natur;': '♮',\n\t'natural;': '♮',\n\t'naturals;': 'ℕ',\n\tnbsp: ' ',\n\t'nbsp;': ' ',\n\t'nbump;': '≎̸',\n\t'nbumpe;': '≏̸',\n\t'ncap;': '⩃',\n\t'ncaron;': 'ň',\n\t'ncedil;': 'ņ',\n\t'ncong;': '≇',\n\t'ncongdot;': '⩭̸',\n\t'ncup;': '⩂',\n\t'ncy;': 'н',\n\t'ndash;': '–',\n\t'ne;': '≠',\n\t'neArr;': '⇗',\n\t'nearhk;': '⤤',\n\t'nearr;': '↗',\n\t'nearrow;': '↗',\n\t'nedot;': '≐̸',\n\t'nequiv;': '≢',\n\t'nesear;': '⤨',\n\t'nesim;': '≂̸',\n\t'nexist;': '∄',\n\t'nexists;': '∄',\n\t'nfr;': '𝔫',\n\t'ngE;': '≧̸',\n\t'nge;': '≱',\n\t'ngeq;': '≱',\n\t'ngeqq;': '≧̸',\n\t'ngeqslant;': '⩾̸',\n\t'nges;': '⩾̸',\n\t'ngsim;': '≵',\n\t'ngt;': '≯',\n\t'ngtr;': '≯',\n\t'nhArr;': '⇎',\n\t'nharr;': '↮',\n\t'nhpar;': '⫲',\n\t'ni;': '∋',\n\t'nis;': '⋼',\n\t'nisd;': '⋺',\n\t'niv;': '∋',\n\t'njcy;': 'њ',\n\t'nlArr;': '⇍',\n\t'nlE;': '≦̸',\n\t'nlarr;': '↚',\n\t'nldr;': '‥',\n\t'nle;': '≰',\n\t'nleftarrow;': '↚',\n\t'nleftrightarrow;': '↮',\n\t'nleq;': '≰',\n\t'nleqq;': '≦̸',\n\t'nleqslant;': '⩽̸',\n\t'nles;': '⩽̸',\n\t'nless;': '≮',\n\t'nlsim;': '≴',\n\t'nlt;': '≮',\n\t'nltri;': '⋪',\n\t'nltrie;': '⋬',\n\t'nmid;': '∤',\n\t'nopf;': '𝕟',\n\tnot: '¬',\n\t'not;': '¬',\n\t'notin;': '∉',\n\t'notinE;': '⋹̸',\n\t'notindot;': '⋵̸',\n\t'notinva;': '∉',\n\t'notinvb;': '⋷',\n\t'notinvc;': '⋶',\n\t'notni;': '∌',\n\t'notniva;': '∌',\n\t'notnivb;': '⋾',\n\t'notnivc;': '⋽',\n\t'npar;': '∦',\n\t'nparallel;': '∦',\n\t'nparsl;': '⫽⃥',\n\t'npart;': '∂̸',\n\t'npolint;': '⨔',\n\t'npr;': '⊀',\n\t'nprcue;': '⋠',\n\t'npre;': '⪯̸',\n\t'nprec;': '⊀',\n\t'npreceq;': '⪯̸',\n\t'nrArr;': '⇏',\n\t'nrarr;': '↛',\n\t'nrarrc;': '⤳̸',\n\t'nrarrw;': '↝̸',\n\t'nrightarrow;': '↛',\n\t'nrtri;': '⋫',\n\t'nrtrie;': '⋭',\n\t'nsc;': '⊁',\n\t'nsccue;': '⋡',\n\t'nsce;': '⪰̸',\n\t'nscr;': '𝓃',\n\t'nshortmid;': '∤',\n\t'nshortparallel;': '∦',\n\t'nsim;': '≁',\n\t'nsime;': '≄',\n\t'nsimeq;': '≄',\n\t'nsmid;': '∤',\n\t'nspar;': '∦',\n\t'nsqsube;': '⋢',\n\t'nsqsupe;': '⋣',\n\t'nsub;': '⊄',\n\t'nsubE;': '⫅̸',\n\t'nsube;': '⊈',\n\t'nsubset;': '⊂⃒',\n\t'nsubseteq;': '⊈',\n\t'nsubseteqq;': '⫅̸',\n\t'nsucc;': '⊁',\n\t'nsucceq;': '⪰̸',\n\t'nsup;': '⊅',\n\t'nsupE;': '⫆̸',\n\t'nsupe;': '⊉',\n\t'nsupset;': '⊃⃒',\n\t'nsupseteq;': '⊉',\n\t'nsupseteqq;': '⫆̸',\n\t'ntgl;': '≹',\n\tntilde: 'ñ',\n\t'ntilde;': 'ñ',\n\t'ntlg;': '≸',\n\t'ntriangleleft;': '⋪',\n\t'ntrianglelefteq;': '⋬',\n\t'ntriangleright;': '⋫',\n\t'ntrianglerighteq;': '⋭',\n\t'nu;': 'ν',\n\t'num;': '#',\n\t'numero;': '№',\n\t'numsp;': ' ',\n\t'nvDash;': '⊭',\n\t'nvHarr;': '⤄',\n\t'nvap;': '≍⃒',\n\t'nvdash;': '⊬',\n\t'nvge;': '≥⃒',\n\t'nvgt;': '>⃒',\n\t'nvinfin;': '⧞',\n\t'nvlArr;': '⤂',\n\t'nvle;': '≤⃒',\n\t'nvlt;': '<⃒',\n\t'nvltrie;': '⊴⃒',\n\t'nvrArr;': '⤃',\n\t'nvrtrie;': '⊵⃒',\n\t'nvsim;': '∼⃒',\n\t'nwArr;': '⇖',\n\t'nwarhk;': '⤣',\n\t'nwarr;': '↖',\n\t'nwarrow;': '↖',\n\t'nwnear;': '⤧',\n\t'oS;': 'Ⓢ',\n\toacute: 'ó',\n\t'oacute;': 'ó',\n\t'oast;': '⊛',\n\t'ocir;': '⊚',\n\tocirc: 'ô',\n\t'ocirc;': 'ô',\n\t'ocy;': 'о',\n\t'odash;': '⊝',\n\t'odblac;': 'ő',\n\t'odiv;': '⨸',\n\t'odot;': '⊙',\n\t'odsold;': '⦼',\n\t'oelig;': 'œ',\n\t'ofcir;': '⦿',\n\t'ofr;': '𝔬',\n\t'ogon;': '˛',\n\tograve: 'ò',\n\t'ograve;': 'ò',\n\t'ogt;': '⧁',\n\t'ohbar;': '⦵',\n\t'ohm;': 'Ω',\n\t'oint;': '∮',\n\t'olarr;': '↺',\n\t'olcir;': '⦾',\n\t'olcross;': '⦻',\n\t'oline;': '‾',\n\t'olt;': '⧀',\n\t'omacr;': 'ō',\n\t'omega;': 'ω',\n\t'omicron;': 'ο',\n\t'omid;': '⦶',\n\t'ominus;': '⊖',\n\t'oopf;': '𝕠',\n\t'opar;': '⦷',\n\t'operp;': '⦹',\n\t'oplus;': '⊕',\n\t'or;': '∨',\n\t'orarr;': '↻',\n\t'ord;': '⩝',\n\t'order;': 'ℴ',\n\t'orderof;': 'ℴ',\n\tordf: 'ª',\n\t'ordf;': 'ª',\n\tordm: 'º',\n\t'ordm;': 'º',\n\t'origof;': '⊶',\n\t'oror;': '⩖',\n\t'orslope;': '⩗',\n\t'orv;': '⩛',\n\t'oscr;': 'ℴ',\n\toslash: 'ø',\n\t'oslash;': 'ø',\n\t'osol;': '⊘',\n\totilde: 'õ',\n\t'otilde;': 'õ',\n\t'otimes;': '⊗',\n\t'otimesas;': '⨶',\n\touml: 'ö',\n\t'ouml;': 'ö',\n\t'ovbar;': '⌽',\n\t'par;': '∥',\n\tpara: '¶',\n\t'para;': '¶',\n\t'parallel;': '∥',\n\t'parsim;': '⫳',\n\t'parsl;': '⫽',\n\t'part;': '∂',\n\t'pcy;': 'п',\n\t'percnt;': '%',\n\t'period;': '.',\n\t'permil;': '‰',\n\t'perp;': '⊥',\n\t'pertenk;': '‱',\n\t'pfr;': '𝔭',\n\t'phi;': 'φ',\n\t'phiv;': 'ϕ',\n\t'phmmat;': 'ℳ',\n\t'phone;': '☎',\n\t'pi;': 'π',\n\t'pitchfork;': '⋔',\n\t'piv;': 'ϖ',\n\t'planck;': 'ℏ',\n\t'planckh;': 'ℎ',\n\t'plankv;': 'ℏ',\n\t'plus;': '+',\n\t'plusacir;': '⨣',\n\t'plusb;': '⊞',\n\t'pluscir;': '⨢',\n\t'plusdo;': '∔',\n\t'plusdu;': '⨥',\n\t'pluse;': '⩲',\n\tplusmn: '±',\n\t'plusmn;': '±',\n\t'plussim;': '⨦',\n\t'plustwo;': '⨧',\n\t'pm;': '±',\n\t'pointint;': '⨕',\n\t'popf;': '𝕡',\n\tpound: '£',\n\t'pound;': '£',\n\t'pr;': '≺',\n\t'prE;': '⪳',\n\t'prap;': '⪷',\n\t'prcue;': '≼',\n\t'pre;': '⪯',\n\t'prec;': '≺',\n\t'precapprox;': '⪷',\n\t'preccurlyeq;': '≼',\n\t'preceq;': '⪯',\n\t'precnapprox;': '⪹',\n\t'precneqq;': '⪵',\n\t'precnsim;': '⋨',\n\t'precsim;': '≾',\n\t'prime;': '′',\n\t'primes;': 'ℙ',\n\t'prnE;': '⪵',\n\t'prnap;': '⪹',\n\t'prnsim;': '⋨',\n\t'prod;': '∏',\n\t'profalar;': '⌮',\n\t'profline;': '⌒',\n\t'profsurf;': '⌓',\n\t'prop;': '∝',\n\t'propto;': '∝',\n\t'prsim;': '≾',\n\t'prurel;': '⊰',\n\t'pscr;': '𝓅',\n\t'psi;': 'ψ',\n\t'puncsp;': ' ',\n\t'qfr;': '𝔮',\n\t'qint;': '⨌',\n\t'qopf;': '𝕢',\n\t'qprime;': '⁗',\n\t'qscr;': '𝓆',\n\t'quaternions;': 'ℍ',\n\t'quatint;': '⨖',\n\t'quest;': '?',\n\t'questeq;': '≟',\n\tquot: '\"',\n\t'quot;': '\"',\n\t'rAarr;': '⇛',\n\t'rArr;': '⇒',\n\t'rAtail;': '⤜',\n\t'rBarr;': '⤏',\n\t'rHar;': '⥤',\n\t'race;': '∽̱',\n\t'racute;': 'ŕ',\n\t'radic;': '√',\n\t'raemptyv;': '⦳',\n\t'rang;': '⟩',\n\t'rangd;': '⦒',\n\t'range;': '⦥',\n\t'rangle;': '⟩',\n\traquo: '»',\n\t'raquo;': '»',\n\t'rarr;': '→',\n\t'rarrap;': '⥵',\n\t'rarrb;': '⇥',\n\t'rarrbfs;': '⤠',\n\t'rarrc;': '⤳',\n\t'rarrfs;': '⤞',\n\t'rarrhk;': '↪',\n\t'rarrlp;': '↬',\n\t'rarrpl;': '⥅',\n\t'rarrsim;': '⥴',\n\t'rarrtl;': '↣',\n\t'rarrw;': '↝',\n\t'ratail;': '⤚',\n\t'ratio;': '∶',\n\t'rationals;': 'ℚ',\n\t'rbarr;': '⤍',\n\t'rbbrk;': '❳',\n\t'rbrace;': '}',\n\t'rbrack;': ']',\n\t'rbrke;': '⦌',\n\t'rbrksld;': '⦎',\n\t'rbrkslu;': '⦐',\n\t'rcaron;': 'ř',\n\t'rcedil;': 'ŗ',\n\t'rceil;': '⌉',\n\t'rcub;': '}',\n\t'rcy;': 'р',\n\t'rdca;': '⤷',\n\t'rdldhar;': '⥩',\n\t'rdquo;': '”',\n\t'rdquor;': '”',\n\t'rdsh;': '↳',\n\t'real;': 'ℜ',\n\t'realine;': 'ℛ',\n\t'realpart;': 'ℜ',\n\t'reals;': 'ℝ',\n\t'rect;': '▭',\n\treg: '®',\n\t'reg;': '®',\n\t'rfisht;': '⥽',\n\t'rfloor;': '⌋',\n\t'rfr;': '𝔯',\n\t'rhard;': '⇁',\n\t'rharu;': '⇀',\n\t'rharul;': '⥬',\n\t'rho;': 'ρ',\n\t'rhov;': 'ϱ',\n\t'rightarrow;': '→',\n\t'rightarrowtail;': '↣',\n\t'rightharpoondown;': '⇁',\n\t'rightharpoonup;': '⇀',\n\t'rightleftarrows;': '⇄',\n\t'rightleftharpoons;': '⇌',\n\t'rightrightarrows;': '⇉',\n\t'rightsquigarrow;': '↝',\n\t'rightthreetimes;': '⋌',\n\t'ring;': '˚',\n\t'risingdotseq;': '≓',\n\t'rlarr;': '⇄',\n\t'rlhar;': '⇌',\n\t'rlm;': '‏',\n\t'rmoust;': '⎱',\n\t'rmoustache;': '⎱',\n\t'rnmid;': '⫮',\n\t'roang;': '⟭',\n\t'roarr;': '⇾',\n\t'robrk;': '⟧',\n\t'ropar;': '⦆',\n\t'ropf;': '𝕣',\n\t'roplus;': '⨮',\n\t'rotimes;': '⨵',\n\t'rpar;': ')',\n\t'rpargt;': '⦔',\n\t'rppolint;': '⨒',\n\t'rrarr;': '⇉',\n\t'rsaquo;': '›',\n\t'rscr;': '𝓇',\n\t'rsh;': '↱',\n\t'rsqb;': ']',\n\t'rsquo;': '’',\n\t'rsquor;': '’',\n\t'rthree;': '⋌',\n\t'rtimes;': '⋊',\n\t'rtri;': '▹',\n\t'rtrie;': '⊵',\n\t'rtrif;': '▸',\n\t'rtriltri;': '⧎',\n\t'ruluhar;': '⥨',\n\t'rx;': '℞',\n\t'sacute;': 'ś',\n\t'sbquo;': '‚',\n\t'sc;': '≻',\n\t'scE;': '⪴',\n\t'scap;': '⪸',\n\t'scaron;': 'š',\n\t'sccue;': '≽',\n\t'sce;': '⪰',\n\t'scedil;': 'ş',\n\t'scirc;': 'ŝ',\n\t'scnE;': '⪶',\n\t'scnap;': '⪺',\n\t'scnsim;': '⋩',\n\t'scpolint;': '⨓',\n\t'scsim;': '≿',\n\t'scy;': 'с',\n\t'sdot;': '⋅',\n\t'sdotb;': '⊡',\n\t'sdote;': '⩦',\n\t'seArr;': '⇘',\n\t'searhk;': '⤥',\n\t'searr;': '↘',\n\t'searrow;': '↘',\n\tsect: '§',\n\t'sect;': '§',\n\t'semi;': ';',\n\t'seswar;': '⤩',\n\t'setminus;': '∖',\n\t'setmn;': '∖',\n\t'sext;': '✶',\n\t'sfr;': '𝔰',\n\t'sfrown;': '⌢',\n\t'sharp;': '♯',\n\t'shchcy;': 'щ',\n\t'shcy;': 'ш',\n\t'shortmid;': '∣',\n\t'shortparallel;': '∥',\n\tshy: '­',\n\t'shy;': '­',\n\t'sigma;': 'σ',\n\t'sigmaf;': 'ς',\n\t'sigmav;': 'ς',\n\t'sim;': '∼',\n\t'simdot;': '⩪',\n\t'sime;': '≃',\n\t'simeq;': '≃',\n\t'simg;': '⪞',\n\t'simgE;': '⪠',\n\t'siml;': '⪝',\n\t'simlE;': '⪟',\n\t'simne;': '≆',\n\t'simplus;': '⨤',\n\t'simrarr;': '⥲',\n\t'slarr;': '←',\n\t'smallsetminus;': '∖',\n\t'smashp;': '⨳',\n\t'smeparsl;': '⧤',\n\t'smid;': '∣',\n\t'smile;': '⌣',\n\t'smt;': '⪪',\n\t'smte;': '⪬',\n\t'smtes;': '⪬︀',\n\t'softcy;': 'ь',\n\t'sol;': '/',\n\t'solb;': '⧄',\n\t'solbar;': '⌿',\n\t'sopf;': '𝕤',\n\t'spades;': '♠',\n\t'spadesuit;': '♠',\n\t'spar;': '∥',\n\t'sqcap;': '⊓',\n\t'sqcaps;': '⊓︀',\n\t'sqcup;': '⊔',\n\t'sqcups;': '⊔︀',\n\t'sqsub;': '⊏',\n\t'sqsube;': '⊑',\n\t'sqsubset;': '⊏',\n\t'sqsubseteq;': '⊑',\n\t'sqsup;': '⊐',\n\t'sqsupe;': '⊒',\n\t'sqsupset;': '⊐',\n\t'sqsupseteq;': '⊒',\n\t'squ;': '□',\n\t'square;': '□',\n\t'squarf;': '▪',\n\t'squf;': '▪',\n\t'srarr;': '→',\n\t'sscr;': '𝓈',\n\t'ssetmn;': '∖',\n\t'ssmile;': '⌣',\n\t'sstarf;': '⋆',\n\t'star;': '☆',\n\t'starf;': '★',\n\t'straightepsilon;': 'ϵ',\n\t'straightphi;': 'ϕ',\n\t'strns;': '¯',\n\t'sub;': '⊂',\n\t'subE;': '⫅',\n\t'subdot;': '⪽',\n\t'sube;': '⊆',\n\t'subedot;': '⫃',\n\t'submult;': '⫁',\n\t'subnE;': '⫋',\n\t'subne;': '⊊',\n\t'subplus;': '⪿',\n\t'subrarr;': '⥹',\n\t'subset;': '⊂',\n\t'subseteq;': '⊆',\n\t'subseteqq;': '⫅',\n\t'subsetneq;': '⊊',\n\t'subsetneqq;': '⫋',\n\t'subsim;': '⫇',\n\t'subsub;': '⫕',\n\t'subsup;': '⫓',\n\t'succ;': '≻',\n\t'succapprox;': '⪸',\n\t'succcurlyeq;': '≽',\n\t'succeq;': '⪰',\n\t'succnapprox;': '⪺',\n\t'succneqq;': '⪶',\n\t'succnsim;': '⋩',\n\t'succsim;': '≿',\n\t'sum;': '∑',\n\t'sung;': '♪',\n\tsup1: '¹',\n\t'sup1;': '¹',\n\tsup2: '²',\n\t'sup2;': '²',\n\tsup3: '³',\n\t'sup3;': '³',\n\t'sup;': '⊃',\n\t'supE;': '⫆',\n\t'supdot;': '⪾',\n\t'supdsub;': '⫘',\n\t'supe;': '⊇',\n\t'supedot;': '⫄',\n\t'suphsol;': '⟉',\n\t'suphsub;': '⫗',\n\t'suplarr;': '⥻',\n\t'supmult;': '⫂',\n\t'supnE;': '⫌',\n\t'supne;': '⊋',\n\t'supplus;': '⫀',\n\t'supset;': '⊃',\n\t'supseteq;': '⊇',\n\t'supseteqq;': '⫆',\n\t'supsetneq;': '⊋',\n\t'supsetneqq;': '⫌',\n\t'supsim;': '⫈',\n\t'supsub;': '⫔',\n\t'supsup;': '⫖',\n\t'swArr;': '⇙',\n\t'swarhk;': '⤦',\n\t'swarr;': '↙',\n\t'swarrow;': '↙',\n\t'swnwar;': '⤪',\n\tszlig: 'ß',\n\t'szlig;': 'ß',\n\t'target;': '⌖',\n\t'tau;': 'τ',\n\t'tbrk;': '⎴',\n\t'tcaron;': 'ť',\n\t'tcedil;': 'ţ',\n\t'tcy;': 'т',\n\t'tdot;': '⃛',\n\t'telrec;': '⌕',\n\t'tfr;': '𝔱',\n\t'there4;': '∴',\n\t'therefore;': '∴',\n\t'theta;': 'θ',\n\t'thetasym;': 'ϑ',\n\t'thetav;': 'ϑ',\n\t'thickapprox;': '≈',\n\t'thicksim;': '∼',\n\t'thinsp;': ' ',\n\t'thkap;': '≈',\n\t'thksim;': '∼',\n\tthorn: 'þ',\n\t'thorn;': 'þ',\n\t'tilde;': '˜',\n\ttimes: '×',\n\t'times;': '×',\n\t'timesb;': '⊠',\n\t'timesbar;': '⨱',\n\t'timesd;': '⨰',\n\t'tint;': '∭',\n\t'toea;': '⤨',\n\t'top;': '⊤',\n\t'topbot;': '⌶',\n\t'topcir;': '⫱',\n\t'topf;': '𝕥',\n\t'topfork;': '⫚',\n\t'tosa;': '⤩',\n\t'tprime;': '‴',\n\t'trade;': '™',\n\t'triangle;': '▵',\n\t'triangledown;': '▿',\n\t'triangleleft;': '◃',\n\t'trianglelefteq;': '⊴',\n\t'triangleq;': '≜',\n\t'triangleright;': '▹',\n\t'trianglerighteq;': '⊵',\n\t'tridot;': '◬',\n\t'trie;': '≜',\n\t'triminus;': '⨺',\n\t'triplus;': '⨹',\n\t'trisb;': '⧍',\n\t'tritime;': '⨻',\n\t'trpezium;': '⏢',\n\t'tscr;': '𝓉',\n\t'tscy;': 'ц',\n\t'tshcy;': 'ћ',\n\t'tstrok;': 'ŧ',\n\t'twixt;': '≬',\n\t'twoheadleftarrow;': '↞',\n\t'twoheadrightarrow;': '↠',\n\t'uArr;': '⇑',\n\t'uHar;': '⥣',\n\tuacute: 'ú',\n\t'uacute;': 'ú',\n\t'uarr;': '↑',\n\t'ubrcy;': 'ў',\n\t'ubreve;': 'ŭ',\n\tucirc: 'û',\n\t'ucirc;': 'û',\n\t'ucy;': 'у',\n\t'udarr;': '⇅',\n\t'udblac;': 'ű',\n\t'udhar;': '⥮',\n\t'ufisht;': '⥾',\n\t'ufr;': '𝔲',\n\tugrave: 'ù',\n\t'ugrave;': 'ù',\n\t'uharl;': '↿',\n\t'uharr;': '↾',\n\t'uhblk;': '▀',\n\t'ulcorn;': '⌜',\n\t'ulcorner;': '⌜',\n\t'ulcrop;': '⌏',\n\t'ultri;': '◸',\n\t'umacr;': 'ū',\n\tuml: '¨',\n\t'uml;': '¨',\n\t'uogon;': 'ų',\n\t'uopf;': '𝕦',\n\t'uparrow;': '↑',\n\t'updownarrow;': '↕',\n\t'upharpoonleft;': '↿',\n\t'upharpoonright;': '↾',\n\t'uplus;': '⊎',\n\t'upsi;': 'υ',\n\t'upsih;': 'ϒ',\n\t'upsilon;': 'υ',\n\t'upuparrows;': '⇈',\n\t'urcorn;': '⌝',\n\t'urcorner;': '⌝',\n\t'urcrop;': '⌎',\n\t'uring;': 'ů',\n\t'urtri;': '◹',\n\t'uscr;': '𝓊',\n\t'utdot;': '⋰',\n\t'utilde;': 'ũ',\n\t'utri;': '▵',\n\t'utrif;': '▴',\n\t'uuarr;': '⇈',\n\tuuml: 'ü',\n\t'uuml;': 'ü',\n\t'uwangle;': '⦧',\n\t'vArr;': '⇕',\n\t'vBar;': '⫨',\n\t'vBarv;': '⫩',\n\t'vDash;': '⊨',\n\t'vangrt;': '⦜',\n\t'varepsilon;': 'ϵ',\n\t'varkappa;': 'ϰ',\n\t'varnothing;': '∅',\n\t'varphi;': 'ϕ',\n\t'varpi;': 'ϖ',\n\t'varpropto;': '∝',\n\t'varr;': '↕',\n\t'varrho;': 'ϱ',\n\t'varsigma;': 'ς',\n\t'varsubsetneq;': '⊊︀',\n\t'varsubsetneqq;': '⫋︀',\n\t'varsupsetneq;': '⊋︀',\n\t'varsupsetneqq;': '⫌︀',\n\t'vartheta;': 'ϑ',\n\t'vartriangleleft;': '⊲',\n\t'vartriangleright;': '⊳',\n\t'vcy;': 'в',\n\t'vdash;': '⊢',\n\t'vee;': '∨',\n\t'veebar;': '⊻',\n\t'veeeq;': '≚',\n\t'vellip;': '⋮',\n\t'verbar;': '|',\n\t'vert;': '|',\n\t'vfr;': '𝔳',\n\t'vltri;': '⊲',\n\t'vnsub;': '⊂⃒',\n\t'vnsup;': '⊃⃒',\n\t'vopf;': '𝕧',\n\t'vprop;': '∝',\n\t'vrtri;': '⊳',\n\t'vscr;': '𝓋',\n\t'vsubnE;': '⫋︀',\n\t'vsubne;': '⊊︀',\n\t'vsupnE;': '⫌︀',\n\t'vsupne;': '⊋︀',\n\t'vzigzag;': '⦚',\n\t'wcirc;': 'ŵ',\n\t'wedbar;': '⩟',\n\t'wedge;': '∧',\n\t'wedgeq;': '≙',\n\t'weierp;': '℘',\n\t'wfr;': '𝔴',\n\t'wopf;': '𝕨',\n\t'wp;': '℘',\n\t'wr;': '≀',\n\t'wreath;': '≀',\n\t'wscr;': '𝓌',\n\t'xcap;': '⋂',\n\t'xcirc;': '◯',\n\t'xcup;': '⋃',\n\t'xdtri;': '▽',\n\t'xfr;': '𝔵',\n\t'xhArr;': '⟺',\n\t'xharr;': '⟷',\n\t'xi;': 'ξ',\n\t'xlArr;': '⟸',\n\t'xlarr;': '⟵',\n\t'xmap;': '⟼',\n\t'xnis;': '⋻',\n\t'xodot;': '⨀',\n\t'xopf;': '𝕩',\n\t'xoplus;': '⨁',\n\t'xotime;': '⨂',\n\t'xrArr;': '⟹',\n\t'xrarr;': '⟶',\n\t'xscr;': '𝓍',\n\t'xsqcup;': '⨆',\n\t'xuplus;': '⨄',\n\t'xutri;': '△',\n\t'xvee;': '⋁',\n\t'xwedge;': '⋀',\n\tyacute: 'ý',\n\t'yacute;': 'ý',\n\t'yacy;': 'я',\n\t'ycirc;': 'ŷ',\n\t'ycy;': 'ы',\n\tyen: '¥',\n\t'yen;': '¥',\n\t'yfr;': '𝔶',\n\t'yicy;': 'ї',\n\t'yopf;': '𝕪',\n\t'yscr;': '𝓎',\n\t'yucy;': 'ю',\n\tyuml: 'ÿ',\n\t'yuml;': 'ÿ',\n\t'zacute;': 'ź',\n\t'zcaron;': 'ž',\n\t'zcy;': 'з',\n\t'zdot;': 'ż',\n\t'zeetrf;': 'ℨ',\n\t'zeta;': 'ζ',\n\t'zfr;': '𝔷',\n\t'zhcy;': 'ж',\n\t'zigrarr;': '⇝',\n\t'zopf;': '𝕫',\n\t'zscr;': '𝓏',\n\t'zwj;': '‍',\n\t'zwnj;': '‌'\n};\n\nconst numeric = /&#(x)?([0-9a-f]+);/i;\nconst named = new RegExp(\n\t`&(${Object.keys(entities)\n\t\t.sort((a, b) => b.length - a.length)\n\t\t.join('|')})`,\n\t'g'\n);\n\n/** @param {string} str */\nexport function decode(str) {\n\treturn str\n\t\t.replace(numeric, (_match, hex, code) => String.fromCharCode(hex ? parseInt(code, 16) : +code))\n\t\t.replace(named, (_match, entity) => entities[entity]);\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/entities.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport { decode } from './entities.js';\n\n/*\nTest cases shamelessly stolen from https://github.com/fb55/entities/blob/main/src/decode.spec.ts\nReproduced under BSD 2 license\n---\nCopyright (c) Felix Böhm\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,\nEVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\nconst tests = [\n\t{ input: '&amp;amp;', output: '&amp;' },\n\t{ input: '&amp;#38;', output: '&#38;' },\n\t{ input: '&amp;#x26;', output: '&#x26;' },\n\t{ input: '&amp;#X26;', output: '&#X26;' },\n\t{ input: '&#38;#38;', output: '&#38;' },\n\t{ input: '&#x26;#38;', output: '&#38;' },\n\t{ input: '&#X26;#38;', output: '&#38;' },\n\t{ input: '&#x3a;', output: ':' },\n\t{ input: '&#x3A;', output: ':' },\n\t{ input: '&#X3a;', output: ':' },\n\t{ input: '&#X3A;', output: ':' },\n\t{ input: '&>', output: '&>' },\n\t{ input: 'id=770&#anchor', output: 'id=770&#anchor' }\n];\n\nfor (const { input, output } of tests) {\n\ttest(input, () => {\n\t\tassert.equal(decode(input), output);\n\t});\n}\n\ntest('should HTML decode partial legacy entity', () => {\n\tassert.equal(decode('&timesbar'), '×bar');\n});\n\ntest('should HTML decode legacy entities according to spec', () => {\n\tassert.equal(decode('?&image_uri=1&ℑ=2&image=3'), '?&image_uri=1&ℑ=2&image=3');\n});\n\ntest('should back out of legacy entities', () => {\n\tassert.equal(decode('&ampa'), '&a');\n});\n\ntest('should parse &nbsp followed by < (#852)', () => {\n\tassert.equal(decode('&nbsp<'), '\\u00a0<');\n});\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fallback.js",
    "content": "import { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { installPolyfills } from '../../exports/node/polyfills.js';\nimport { load_config } from '../config/index.js';\nimport { forked } from '../../utils/fork.js';\n\nexport default forked(import.meta.url, generate_fallback);\n\n/**\n * @param {{\n *   manifest_path: string;\n *   env: Record<string, string>\n * }} opts\n */\nasync function generate_fallback({ manifest_path, env }) {\n\t/** @type {import('types').ValidatedKitConfig} */\n\tconst config = (await load_config()).kit;\n\n\tinstallPolyfills();\n\n\tconst server_root = join(config.outDir, 'output');\n\n\t/** @type {import('types').ServerInternalModule} */\n\tconst { set_building } = await import(pathToFileURL(`${server_root}/server/internal.js`).href);\n\n\t/** @type {import('types').ServerModule} */\n\tconst { Server } = await import(pathToFileURL(`${server_root}/server/index.js`).href);\n\n\t/** @type {import('@sveltejs/kit').SSRManifest} */\n\tconst manifest = (await import(pathToFileURL(manifest_path).href)).manifest;\n\n\tset_building();\n\n\tconst server = new Server(manifest);\n\tawait server.init({ env });\n\n\tconst response = await server.respond(new Request(config.prerender.origin + '/[fallback]'), {\n\t\tgetClientAddress: () => {\n\t\t\tthrow new Error('Cannot read clientAddress during prerendering');\n\t\t},\n\t\tprerendering: {\n\t\t\tfallback: true,\n\t\t\tdependencies: new Map(),\n\t\t\tremote_responses: new Map()\n\t\t},\n\t\tread: (file) => readFileSync(join(config.files.assets, file))\n\t});\n\n\tif (response.ok) {\n\t\treturn await response.text();\n\t}\n\n\tthrow new Error(`Could not create a fallback page — failed with status ${response.status}`);\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/base/input.html",
    "content": "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<base href=\"/base-path/\" />\n\t\t<link rel=\"stylesheet\" href=\"styles.css\" />\n\t\t<link rel=\"icon\" href=\"favicon.png\" />\n\t</head>\n\t<body>\n\t\t<a href=\"https://external.com\">https://external.com</a>\n\t\t<a href=\"wheee\">/wheee</a>\n\t\t<a data-sveltekit-preload-data href=\"wheee2\">/wheee</a>\n\t\t<a href=\"wheee3\" data-sveltekit-preload-data>/wheee</a>\n\t\t<a href=\"wheee4\">/wheee</a>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/base/output.json",
    "content": "{\n\t\"hrefs\": [\n\t\t\"/base-path/styles.css\",\n\t\t\"/base-path/favicon.png\",\n\t\t\"https://external.com/\",\n\t\t\"/base-path/wheee\",\n\t\t\"/base-path/wheee2\",\n\t\t\"/base-path/wheee3\",\n\t\t\"/base-path/wheee4\"\n\t],\n\t\"ids\": []\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/basic-href/input.html",
    "content": "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<link rel=\"stylesheet\" href=\"/styles.css\" />\n\t\t<link rel=\"icon\" href=\"/favicon.png\" />\n\t</head>\n\t<body>\n\t\t<a href=\"https://external.com\">https://external.com</a>\n\t\t<a href=\"/wheee\">/wheee</a>\n\t\t<a data-sveltekit-preload-data href=\"/wheee2\">/wheee</a>\n\t\t<a href=\"/wheee3\" data-sveltekit-preload-data>/wheee</a>\n\t\t<a href=\"/wheee4\">/wheee</a>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/basic-href/output.json",
    "content": "{\n\t\"hrefs\": [\n\t\t\"/styles.css\",\n\t\t\"/favicon.png\",\n\t\t\"https://external.com/\",\n\t\t\"/wheee\",\n\t\t\"/wheee2\",\n\t\t\"/wheee3\",\n\t\t\"/wheee4\"\n\t],\n\t\"ids\": []\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/basic-src/input.html",
    "content": "<!DOCTYPE html>\n<html>\n\t<head></head>\n\t<body>\n\t\t<img alt=\"A potato\" src=\"/potato.jpg\" />\n\t\t<img alt=\"empty\" src=\"\" />\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/basic-src/output.json",
    "content": "{\n\t\"hrefs\": [\"/potato.jpg\"],\n\t\"ids\": []\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/basic-srcset/input.html",
    "content": "<!DOCTYPE html>\n<html>\n\t<head></head>\n\t<body>\n\t\t<img\n\t\t\talt=\"A header\"\n\t\t\tsrc=\"header.png\"\n\t\t\tsrcset=\"https://example.com/w_200,q_100/header.png 200w, header640.png 640w, header960.png 960w, header1024.png 1024w, header.png\"\n\t\t/>\n\t\t<img\n\t\t\talt=\"Troublesome srcset\"\n\t\t\tsrc=\"issue-9369.png\"\n\t\t\tsrcset=\"/issue-9369_newline-after-comma-is-bad.png,\n\t\t\t\t\t\t\t/issue-9369_800px.png 800,\"\n\t\t/>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/basic-srcset/output.json",
    "content": "{\n\t\"hrefs\": [\n\t\t\"/header.png\",\n\t\t\"https://example.com/w_200,q_100/header.png\",\n\t\t\"/header640.png\",\n\t\t\"/header960.png\",\n\t\t\"/header1024.png\",\n\t\t\"/header.png\",\n\t\t\"/issue-9369.png\",\n\t\t\"/issue-9369_newline-after-comma-is-bad.png\",\n\t\t\"/issue-9369_800px.png\"\n\t],\n\t\"ids\": []\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/encoded-ids/input.html",
    "content": "<!DOCTYPE html>\n<html>\n\t<body>\n\t\t<a href=\"#sparkles-%E2%9C%A8\">✨</a>\n\t\t<h1 id=\"sparkles-%E2%9C%A8\">Title</h1>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/encoded-ids/output.json",
    "content": "{\n\t\"hrefs\": [\"/#sparkles-%E2%9C%A8\"],\n\t\"ids\": [\"sparkles-✨\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/href-with-character-reference/input.html",
    "content": "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<link rel=\"stylesheet\" href=\"/styles.css\" />\n\t\t<link rel=\"icon\" href=\"/favicon.png\" />\n\t</head>\n\t<body>\n\t\t<a href=\"/test&amp;ampersand\">/test&amp;ampersand</a>\n\t\t<a href=\"/test&quot;quotation\">/test&quot;quotation</a>\n\t\t<a href=\"/test&#9825;decimal\">/test&#9825;decimal</a>\n\t\t<a href=\"/test&#x2665;hex\">/test&#x2665;hex</a>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/href-with-character-reference/output.json",
    "content": "{\n\t\"hrefs\": [\n\t\t\"/styles.css\",\n\t\t\"/favicon.png\",\n\t\t\"/test&ampersand\",\n\t\t\"/test%22quotation\",\n\t\t\"/test%E2%99%A1decimal\",\n\t\t\"/test%E2%99%A5hex\"\n\t],\n\t\"ids\": []\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/ids/input.html",
    "content": "<h2 id=\"before\">before</h2>\n<span data-x='\"\\\\\"'>backslash</span>\n<h2 id=\"after\">after</h2>\n<h2 id=\"encöded\">\n\t<a href=\"#encöded\">encöded</a>\n</h2>\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/ids/output.json",
    "content": "{\n\t\"hrefs\": [\"/#enc%C3%B6ded\"],\n\t\"ids\": [\"before\", \"after\", \"encöded\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/include-rel-external/input.html",
    "content": "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<link rel=\"stylesheet\" href=\"/styles.css\" />\n\t\t<link rel=\"icon\" href=\"/favicon.png\" />\n\t</head>\n\t<body>\n\t\t<a href=\"https://external.com\">https://external.com</a>\n\t\t<a href=\"/wheee\" rel=\"external\">/wheee</a>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/include-rel-external/output.json",
    "content": "{\n\t\"hrefs\": [\"/styles.css\", \"/favicon.png\", \"https://external.com/\"],\n\t\"ids\": []\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/meta/input.html",
    "content": "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<meta name=\"description\" content=\"This is a description\" />\n\n\t\t<!--Only these should get crawled-->\n\t\t<meta content=\"https://external.com\" name=\"twitter:image\" />\n\t\t<meta name=\"og:image\" content=\"/og-image.jpg\" />\n\t\t<meta property=\"og:audio\" content=\"https://example.com/audio.mp3\" />\n\t\t<meta content=\"/video.mp4\" property=\"og:video\"/>\n\t</head>\n\t<body></body>\n</html>\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/meta/output.json",
    "content": "{\n\t\"hrefs\": [\n\t\t\"https://external.com/\",\n\t\t\"/og-image.jpg\",\n\t\t\"https://example.com/audio.mp3\",\n\t\t\"/video.mp4\"\n\t],\n\t\"ids\": []\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/unquoted-attributes/input.html",
    "content": "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<link rel=stylesheet href=/styles.css /> <link rel=icon href=/favicon.png />\n\t</head>\n\t<body>\n\t\t<a href=https://external.com>https://external.com</a>\n\t\t<a href=/wheee>/wheee</a>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/fixtures/unquoted-attributes/output.json",
    "content": "{\n\t\"hrefs\": [\"/styles.css\", \"/favicon.png\", \"https://external.com/\", \"/wheee\"],\n\t\"ids\": []\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/prerender.js",
    "content": "import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { installPolyfills } from '../../exports/node/polyfills.js';\nimport { mkdirp, posixify, walk } from '../../utils/filesystem.js';\nimport { decode_uri, is_root_relative, resolve } from '../../utils/url.js';\nimport { escape_html } from '../../utils/escape.js';\nimport { logger } from '../utils.js';\nimport { load_config } from '../config/index.js';\nimport { get_route_segments } from '../../utils/routing.js';\nimport { queue } from './queue.js';\nimport { crawl } from './crawl.js';\nimport { forked } from '../../utils/fork.js';\nimport * as devalue from 'devalue';\nimport { createReadableStream } from '@sveltejs/kit/node';\nimport generate_fallback from './fallback.js';\nimport { stringify_remote_arg } from '../../runtime/shared.js';\nimport { filter_env } from '../../utils/env.js';\n\nexport default forked(import.meta.url, prerender);\n\n// https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment\n// \"If fragment is the empty string, then return the special value top of the document.\"\n// ...and\n// \"If decodedFragment is an ASCII case-insensitive match for the string 'top', then return the top of the document.\"\nconst SPECIAL_HASHLINKS = new Set(['', 'top']);\n\n/**\n * @param {{\n *   hash: boolean;\n *   out: string;\n *   manifest_path: string;\n *   metadata: import('types').ServerMetadata;\n *   verbose: boolean;\n *   env: Record<string, string>\n * }} opts\n */\nasync function prerender({ hash, out, manifest_path, metadata, verbose, env }) {\n\t/** @type {import('@sveltejs/kit').SSRManifest} */\n\tconst manifest = (await import(pathToFileURL(manifest_path).href)).manifest;\n\n\t/** @type {import('types').ServerInternalModule} */\n\tconst internal = await import(pathToFileURL(`${out}/server/internal.js`).href);\n\n\t/** @type {import('types').ServerModule} */\n\tconst { Server } = await import(pathToFileURL(`${out}/server/index.js`).href);\n\n\t// configure `import { building } from '$app/environment'` —\n\t// essential we do this before analysing the code\n\tinternal.set_building();\n\tinternal.set_prerendering();\n\n\t/**\n\t * @template {{message: string}} T\n\t * @template {Omit<T, 'message'>} K\n\t * @param {import('types').Logger} log\n\t * @param {'fail' | 'warn' | 'ignore' | ((details: T) => void)} input\n\t * @param {(details: K) => string} format\n\t * @returns {(details: K) => void}\n\t */\n\tfunction normalise_error_handler(log, input, format) {\n\t\tswitch (input) {\n\t\t\tcase 'fail':\n\t\t\t\treturn (details) => {\n\t\t\t\t\tthrow new Error(format(details));\n\t\t\t\t};\n\t\t\tcase 'warn':\n\t\t\t\treturn (details) => {\n\t\t\t\t\tlog.error(format(details));\n\t\t\t\t};\n\t\t\tcase 'ignore':\n\t\t\t\treturn () => {};\n\t\t\tdefault:\n\t\t\t\t// @ts-expect-error TS thinks T might be of a different kind, but it's not\n\t\t\t\treturn (details) => input({ ...details, message: format(details) });\n\t\t}\n\t}\n\n\tconst OK = 2;\n\tconst REDIRECT = 3;\n\n\t/** @type {import('types').Prerendered} */\n\tconst prerendered = {\n\t\tpages: new Map(),\n\t\tassets: new Map(),\n\t\tredirects: new Map(),\n\t\tpaths: []\n\t};\n\n\t/** @type {import('types').PrerenderMap} */\n\tconst prerender_map = new Map();\n\n\tfor (const [id, { prerender }] of metadata.routes) {\n\t\tif (prerender !== undefined) {\n\t\t\tprerender_map.set(id, prerender);\n\t\t}\n\t}\n\n\t/** @type {Set<string>} */\n\tconst prerendered_routes = new Set();\n\n\t/** @type {import('types').ValidatedKitConfig} */\n\tconst config = (await load_config()).kit;\n\n\tif (hash) {\n\t\tconst fallback = await generate_fallback({\n\t\t\tmanifest_path,\n\t\t\tenv\n\t\t});\n\n\t\tconst file = output_filename('/', true);\n\t\tconst dest = `${config.outDir}/output/prerendered/pages/${file}`;\n\n\t\tmkdirp(dirname(dest));\n\t\twriteFileSync(dest, fallback);\n\n\t\tprerendered.pages.set('/', { file });\n\n\t\treturn { prerendered, prerender_map };\n\t}\n\n\tconst emulator = await config.adapter?.emulate?.();\n\n\t/** @type {import('types').Logger} */\n\tconst log = logger({ verbose });\n\n\tinstallPolyfills();\n\n\t/** @type {Map<string, string>} */\n\tconst saved = new Map();\n\n\tconst handle_http_error = normalise_error_handler(\n\t\tlog,\n\t\tconfig.prerender.handleHttpError,\n\t\t({ status, path, referrer, referenceType }) => {\n\t\t\tconst message =\n\t\t\t\tstatus === 404 && !path.startsWith(config.paths.base)\n\t\t\t\t\t? `${path} does not begin with \\`base\\`, which is configured in \\`paths.base\\` and can be imported from \\`$app/paths\\` - see https://svelte.dev/docs/kit/configuration#paths for more info`\n\t\t\t\t\t: path;\n\n\t\t\treturn `${status} ${message}${referrer ? ` (${referenceType} from ${referrer})` : ''}`;\n\t\t}\n\t);\n\n\tconst handle_missing_id = normalise_error_handler(\n\t\tlog,\n\t\tconfig.prerender.handleMissingId,\n\t\t({ path, id, referrers }) => {\n\t\t\treturn (\n\t\t\t\t`The following pages contain links to ${path}#${id}, but no element with id=\"${id}\" exists on ${path} - see the \\`handleMissingId\\` option in https://svelte.dev/docs/kit/configuration#prerender for more info:` +\n\t\t\t\treferrers.map((l) => `\\n  - ${l}`).join('')\n\t\t\t);\n\t\t}\n\t);\n\n\tconst handle_entry_generator_mismatch = normalise_error_handler(\n\t\tlog,\n\t\tconfig.prerender.handleEntryGeneratorMismatch,\n\t\t({ generatedFromId, entry, matchedId }) => {\n\t\t\treturn `The entries export from ${generatedFromId} generated entry ${entry}, which was matched by ${matchedId} - see the \\`handleEntryGeneratorMismatch\\` option in https://svelte.dev/docs/kit/configuration#prerender for more info.`;\n\t\t}\n\t);\n\n\tconst handle_not_prerendered_route = normalise_error_handler(\n\t\tlog,\n\t\tconfig.prerender.handleUnseenRoutes,\n\t\t({ routes }) => {\n\t\t\tconst list = routes.map((id) => `  - ${id}`).join('\\n');\n\t\t\treturn `The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app:\\n${list}\\n\\nSee the \\`handleUnseenRoutes\\` option in https://svelte.dev/docs/kit/configuration#prerender for more info.`;\n\t\t}\n\t);\n\n\tconst q = queue(config.prerender.concurrency);\n\n\t/**\n\t * @param {string} path\n\t * @param {boolean} is_html\n\t */\n\tfunction output_filename(path, is_html) {\n\t\tconst file = path.slice(config.paths.base.length + 1) || 'index.html';\n\n\t\tif (is_html && !file.endsWith('.html')) {\n\t\t\treturn file + (file.endsWith('/') ? 'index.html' : '.html');\n\t\t}\n\n\t\treturn file;\n\t}\n\n\tconst files = new Set(walk(`${out}/client`).map(posixify));\n\tfiles.add(`${config.appDir}/env.js`);\n\n\tconst immutable = `${config.appDir}/immutable`;\n\tif (existsSync(`${out}/server/${immutable}`)) {\n\t\tfor (const file of walk(`${out}/server/${immutable}`)) {\n\t\t\tfiles.add(posixify(`${config.appDir}/immutable/${file}`));\n\t\t}\n\t}\n\n\tconst remote_prefix = `${config.paths.base}/${config.appDir}/remote/`;\n\n\tconst seen = new Set();\n\tconst written = new Set();\n\tconst remote_responses = new Map();\n\n\t/** @type {Map<string, Set<string>>} */\n\tconst expected_hashlinks = new Map();\n\n\t/** @type {Map<string, string[]>} */\n\tconst actual_hashlinks = new Map();\n\n\t/**\n\t * @param {string | null} referrer\n\t * @param {string} decoded\n\t * @param {string} [encoded]\n\t * @param {string} [generated_from_id]\n\t */\n\tfunction enqueue(referrer, decoded, encoded, generated_from_id) {\n\t\tif (seen.has(decoded)) return;\n\t\tseen.add(decoded);\n\n\t\tconst file = decoded.slice(config.paths.base.length + 1);\n\t\tif (files.has(file)) return;\n\n\t\treturn q.add(() => visit(decoded, encoded || encodeURI(decoded), referrer, generated_from_id));\n\t}\n\n\t/**\n\t * @param {string} decoded\n\t * @param {string} encoded\n\t * @param {string?} referrer\n\t * @param {string} [generated_from_id]\n\t */\n\tasync function visit(decoded, encoded, referrer, generated_from_id) {\n\t\tif (!decoded.startsWith(config.paths.base)) {\n\t\t\thandle_http_error({ status: 404, path: decoded, referrer, referenceType: 'linked' });\n\t\t\treturn;\n\t\t}\n\n\t\t/** @type {Map<string, import('types').PrerenderDependency>} */\n\t\tconst dependencies = new Map();\n\n\t\tconst response = await server.respond(new Request(config.prerender.origin + encoded), {\n\t\t\tgetClientAddress() {\n\t\t\t\tthrow new Error('Cannot read clientAddress during prerendering');\n\t\t\t},\n\t\t\tprerendering: {\n\t\t\t\tdependencies,\n\t\t\t\tremote_responses\n\t\t\t},\n\t\t\tread: (file) => {\n\t\t\t\t// stuff we just wrote\n\t\t\t\tconst filepath = saved.get(file);\n\t\t\t\tif (filepath) return readFileSync(filepath);\n\n\t\t\t\t// Static assets emitted during build\n\t\t\t\tif (file.startsWith(config.appDir)) {\n\t\t\t\t\treturn readFileSync(`${out}/server/${file}`);\n\t\t\t\t}\n\n\t\t\t\t// stuff in `static`\n\t\t\t\treturn readFileSync(join(config.files.assets, file));\n\t\t\t},\n\t\t\temulator\n\t\t});\n\n\t\tconst encoded_id = response.headers.get('x-sveltekit-routeid');\n\t\tconst decoded_id = encoded_id && decode_uri(encoded_id);\n\t\tif (\n\t\t\tdecoded_id !== null &&\n\t\t\tgenerated_from_id !== undefined &&\n\t\t\tdecoded_id !== generated_from_id\n\t\t) {\n\t\t\thandle_entry_generator_mismatch({\n\t\t\t\tgeneratedFromId: generated_from_id,\n\t\t\t\tentry: decoded,\n\t\t\t\tmatchedId: decoded_id\n\t\t\t});\n\t\t}\n\n\t\tconst body = Buffer.from(await response.arrayBuffer());\n\n\t\tconst category = decoded.startsWith(remote_prefix) ? 'data' : 'pages';\n\t\tsave(category, response, body, decoded, encoded, referrer, 'linked');\n\n\t\tfor (const [dependency_path, result] of dependencies) {\n\t\t\t// this seems circuitous, but using new URL allows us to not care\n\t\t\t// whether dependency_path is encoded or not\n\t\t\tconst encoded_dependency_path = new URL(dependency_path, 'http://localhost').pathname;\n\t\t\tconst decoded_dependency_path = decode_uri(encoded_dependency_path);\n\n\t\t\tconst headers = Object.fromEntries(result.response.headers);\n\n\t\t\tconst prerender = headers['x-sveltekit-prerender'];\n\t\t\tif (prerender) {\n\t\t\t\tconst encoded_route_id = headers['x-sveltekit-routeid'];\n\t\t\t\tif (encoded_route_id != null) {\n\t\t\t\t\tconst route_id = decode_uri(encoded_route_id);\n\t\t\t\t\tconst existing_value = prerender_map.get(route_id);\n\t\t\t\t\tif (existing_value !== 'auto') {\n\t\t\t\t\t\tprerender_map.set(route_id, prerender === 'true' ? true : 'auto');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst body = result.body ?? new Uint8Array(await result.response.arrayBuffer());\n\n\t\t\tconst category = decoded_dependency_path.startsWith(remote_prefix) ? 'data' : 'dependencies';\n\n\t\t\tsave(\n\t\t\t\tcategory,\n\t\t\t\tresult.response,\n\t\t\t\tbody,\n\t\t\t\tdecoded_dependency_path,\n\t\t\t\tencoded_dependency_path,\n\t\t\t\tdecoded,\n\t\t\t\t'fetched'\n\t\t\t);\n\t\t}\n\n\t\t// avoid triggering `filterSerializeResponseHeaders` guard\n\t\tconst headers = Object.fromEntries(response.headers);\n\n\t\t// if it's a 200 HTML response, crawl it. Skip error responses, as we don't save those\n\t\tif (response.ok && config.prerender.crawl && headers['content-type'] === 'text/html') {\n\t\t\tconst { ids, hrefs } = crawl(body.toString(), decoded);\n\n\t\t\tactual_hashlinks.set(decoded, ids);\n\n\t\t\t/** @param {string} href */\n\t\t\tconst removePrerenderOrigin = (href) => {\n\t\t\t\tif (href.startsWith(config.prerender.origin)) {\n\t\t\t\t\tif (href === config.prerender.origin) return '/';\n\t\t\t\t\tif (href.at(config.prerender.origin.length) !== '/') return href;\n\t\t\t\t\treturn href.slice(config.prerender.origin.length);\n\t\t\t\t}\n\t\t\t\treturn href;\n\t\t\t};\n\n\t\t\tfor (const href of hrefs.map(removePrerenderOrigin)) {\n\t\t\t\tif (!is_root_relative(href)) continue;\n\n\t\t\t\tconst { pathname, search, hash } = new URL(href, 'http://localhost');\n\n\t\t\t\tif (search) {\n\t\t\t\t\t// TODO warn that query strings have no effect on statically-exported pages\n\t\t\t\t}\n\n\t\t\t\tif (hash) {\n\t\t\t\t\tconst key = decode_uri(pathname + hash);\n\n\t\t\t\t\tif (!expected_hashlinks.has(key)) {\n\t\t\t\t\t\texpected_hashlinks.set(key, new Set());\n\t\t\t\t\t}\n\n\t\t\t\t\t/** @type {Set<string>} */ (expected_hashlinks.get(key)).add(decoded);\n\t\t\t\t}\n\n\t\t\t\tvoid enqueue(decoded, decode_uri(pathname), pathname);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {'pages' | 'dependencies' | 'data'} category\n\t * @param {Response} response\n\t * @param {string | Uint8Array} body\n\t * @param {string} decoded\n\t * @param {string} encoded\n\t * @param {string | null} referrer\n\t * @param {'linked' | 'fetched'} referenceType\n\t */\n\tfunction save(category, response, body, decoded, encoded, referrer, referenceType) {\n\t\tconst response_type = Math.floor(response.status / 100);\n\t\tconst headers = Object.fromEntries(response.headers);\n\n\t\tconst type = headers['content-type'];\n\t\tconst is_html = response_type === REDIRECT || type === 'text/html';\n\n\t\tconst file = output_filename(decoded, is_html);\n\t\tconst dest = `${config.outDir}/output/prerendered/${category}/${file}`;\n\n\t\tif (written.has(file)) return;\n\n\t\tconst encoded_route_id = response.headers.get('x-sveltekit-routeid');\n\t\tconst route_id = encoded_route_id != null ? decode_uri(encoded_route_id) : null;\n\t\tif (route_id !== null) prerendered_routes.add(route_id);\n\n\t\tif (response_type === REDIRECT) {\n\t\t\tconst location = headers['location'];\n\n\t\t\tif (location) {\n\t\t\t\tconst resolved = resolve(encoded, location);\n\t\t\t\tif (is_root_relative(resolved)) {\n\t\t\t\t\tvoid enqueue(decoded, decode_uri(resolved), resolved);\n\t\t\t\t}\n\n\t\t\t\tif (!headers['x-sveltekit-normalize']) {\n\t\t\t\t\tmkdirp(dirname(dest));\n\n\t\t\t\t\tlog.warn(`${response.status} ${decoded} -> ${location}`);\n\n\t\t\t\t\twriteFileSync(\n\t\t\t\t\t\tdest,\n\t\t\t\t\t\t`<script>location.href=${devalue.uneval(\n\t\t\t\t\t\t\tlocation\n\t\t\t\t\t\t)};</script><meta http-equiv=\"refresh\" content=\"${escape_html(\n\t\t\t\t\t\t\t`0;url=${location}`,\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t)}\">`\n\t\t\t\t\t);\n\n\t\t\t\t\twritten.add(file);\n\n\t\t\t\t\tif (!prerendered.redirects.has(decoded)) {\n\t\t\t\t\t\tprerendered.redirects.set(decoded, {\n\t\t\t\t\t\t\tstatus: response.status,\n\t\t\t\t\t\t\tlocation: resolved\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tprerendered.paths.push(decoded);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlog.warn(`location header missing on redirect received from ${decoded}`);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (response.status === 200) {\n\t\t\tif (existsSync(dest) && statSync(dest).isDirectory()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot save ${decoded} as it is already a directory. See https://svelte.dev/docs/kit/page-options#prerender-route-conflicts for more information`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst dir = dirname(dest);\n\n\t\t\tif (existsSync(dir) && !statSync(dir).isDirectory()) {\n\t\t\t\tconst parent = decoded.split('/').slice(0, -1).join('/');\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot save ${decoded} as ${parent} is already a file. See https://svelte.dev/docs/kit/page-options#prerender-route-conflicts for more information`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tmkdirp(dir);\n\n\t\t\tlog.info(`${response.status} ${decoded}`);\n\t\t\twriteFileSync(dest, body);\n\t\t\twritten.add(file);\n\n\t\t\tif (is_html) {\n\t\t\t\tprerendered.pages.set(decoded, {\n\t\t\t\t\tfile\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tprerendered.assets.set(decoded, {\n\t\t\t\t\ttype\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tprerendered.paths.push(decoded);\n\t\t} else if (response_type !== OK) {\n\t\t\thandle_http_error({ status: response.status, path: decoded, referrer, referenceType });\n\t\t}\n\n\t\tmanifest.assets.add(file);\n\t\tsaved.set(file, dest);\n\t}\n\n\t/** @type {Array<{ id: string, entries: Array<string>}>} */\n\tconst route_level_entries = [];\n\tfor (const [id, { entries }] of metadata.routes.entries()) {\n\t\tif (entries) {\n\t\t\troute_level_entries.push({ id, entries });\n\t\t}\n\t}\n\n\tlet should_prerender = false;\n\n\tfor (const value of prerender_map.values()) {\n\t\tif (value) {\n\t\t\tshould_prerender = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// the user's remote function modules may reference environment variables,\n\t// `read` or the `manifest` at the top-level so we need to set them before\n\t// evaluating those modules to avoid potential runtime errors\n\tconst { publicPrefix: public_prefix, privatePrefix: private_prefix } = config.env;\n\tconst private_env = filter_env(env, private_prefix, public_prefix);\n\tconst public_env = filter_env(env, public_prefix, private_prefix);\n\tinternal.set_private_env(private_env);\n\tinternal.set_public_env(public_env);\n\tinternal.set_manifest(manifest);\n\tinternal.set_read_implementation((file) => createReadableStream(`${out}/server/${file}`));\n\n\t/** @type {Array<import('types').RemotePrerenderInternals>} */\n\tconst prerender_functions = [];\n\n\tfor (const loader of Object.values(manifest._.remotes)) {\n\t\tconst module = await loader();\n\n\t\tfor (const fn of Object.values(module.default)) {\n\t\t\tif (fn?.__?.type === 'prerender') {\n\t\t\t\tprerender_functions.push(fn.__);\n\t\t\t\tshould_prerender = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!should_prerender) {\n\t\treturn { prerendered, prerender_map };\n\t}\n\n\t// only run the server after the `should_prerender` check so that we\n\t// don't run the user's init hook unnecessarily\n\tconst server = new Server(manifest);\n\tawait server.init({\n\t\tenv,\n\t\tread: (file) => createReadableStream(`${config.outDir}/output/server/${file}`)\n\t});\n\n\tlog.info('Prerendering');\n\n\tfor (const entry of config.prerender.entries) {\n\t\tif (entry === '*') {\n\t\t\tfor (const [id, prerender] of prerender_map) {\n\t\t\t\tif (prerender) {\n\t\t\t\t\t// remove optional parameters from the route\n\t\t\t\t\tconst segments = get_route_segments(id).filter((segment) => !segment.startsWith('[['));\n\t\t\t\t\tconst processed_id = '/' + segments.join('/');\n\n\t\t\t\t\tif (processed_id.includes('[')) continue;\n\t\t\t\t\tconst path = `/${get_route_segments(processed_id).join('/')}`;\n\t\t\t\t\tvoid enqueue(null, config.paths.base + path);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tvoid enqueue(null, config.paths.base + entry);\n\t\t}\n\t}\n\n\tfor (const { id, entries } of route_level_entries) {\n\t\tfor (const entry of entries) {\n\t\t\tvoid enqueue(null, config.paths.base + entry, undefined, id);\n\t\t}\n\t}\n\n\tconst transport = (await internal.get_hooks()).transport ?? {};\n\tfor (const internals of prerender_functions) {\n\t\tif (internals.has_arg) {\n\t\t\tfor (const arg of (await internals.inputs?.()) ?? []) {\n\t\t\t\tvoid enqueue(\n\t\t\t\t\tnull,\n\t\t\t\t\tremote_prefix + internals.id + '/' + stringify_remote_arg(arg, transport)\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tvoid enqueue(null, remote_prefix + internals.id);\n\t\t}\n\t}\n\n\tawait q.done();\n\n\t// handle invalid fragment links\n\tfor (const [key, referrers] of expected_hashlinks) {\n\t\tconst index = key.indexOf('#');\n\t\tconst path = key.slice(0, index);\n\t\tconst id = key.slice(index + 1);\n\n\t\tconst hashlinks = actual_hashlinks.get(path);\n\t\t// ignore fragment links to pages that were not prerendered\n\t\tif (!hashlinks) continue;\n\n\t\tif (!hashlinks.includes(id) && !SPECIAL_HASHLINKS.has(id)) {\n\t\t\thandle_missing_id({ id, path, referrers: Array.from(referrers) });\n\t\t}\n\t}\n\n\t/** @type {string[]} */\n\tconst not_prerendered = [];\n\n\tfor (const [route_id, prerender] of prerender_map) {\n\t\tif (prerender === true && !prerendered_routes.has(route_id)) {\n\t\t\tnot_prerendered.push(route_id);\n\t\t}\n\t}\n\n\tif (not_prerendered.length > 0) {\n\t\thandle_not_prerendered_route({ routes: not_prerendered });\n\t}\n\n\treturn { prerendered, prerender_map };\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/queue.js",
    "content": "/** @import { PromiseWithResolvers } from '../../utils/promise.js' */\nimport { with_resolvers } from '../../utils/promise.js';\n\n/**\n * @typedef {{\n *   fn: () => Promise<any>,\n *   fulfil: (value: any) => void,\n *   reject: (error: Error) => void\n * }} Task\n */\n\n/** @param {number} concurrency */\nexport function queue(concurrency) {\n\t/** @type {Task[]} */\n\tconst tasks = [];\n\tconst { promise, resolve, reject } = /** @type {PromiseWithResolvers<void>} */ (with_resolvers());\n\n\tlet current = 0;\n\tlet closed = false;\n\n\tpromise.catch(() => {\n\t\t// this is necessary in case a catch handler is never added\n\t\t// to the done promise by the user\n\t});\n\n\tfunction dequeue() {\n\t\tif (current < concurrency) {\n\t\t\tconst task = tasks.shift();\n\n\t\t\tif (task) {\n\t\t\t\tcurrent += 1;\n\t\t\t\tconst promise = Promise.resolve(task.fn());\n\n\t\t\t\tvoid promise\n\t\t\t\t\t.then(task.fulfil, (err) => {\n\t\t\t\t\t\ttask.reject(err);\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t})\n\t\t\t\t\t.then(() => {\n\t\t\t\t\t\tcurrent -= 1;\n\t\t\t\t\t\tdequeue();\n\t\t\t\t\t});\n\t\t\t} else if (current === 0) {\n\t\t\t\tclosed = true;\n\t\t\t\tresolve();\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\t/** @param {() => any} fn */\n\t\tadd: (fn) => {\n\t\t\tif (closed) throw new Error('Cannot add tasks to a queue that has ended');\n\n\t\t\tconst promise = new Promise((fulfil, reject) => {\n\t\t\t\ttasks.push({ fn, fulfil, reject });\n\t\t\t});\n\n\t\t\tdequeue();\n\t\t\treturn promise;\n\t\t},\n\n\t\tdone: () => {\n\t\t\tif (current === 0) {\n\t\t\t\tclosed = true;\n\t\t\t\tresolve();\n\t\t\t}\n\n\t\t\treturn promise;\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/core/postbuild/queue.spec.js",
    "content": "import { assert, expect, test } from 'vitest';\nimport { queue } from './queue.js';\n\n/** @param {number} ms */\nfunction sleep(ms) {\n\treturn new Promise((f) => setTimeout(f, ms));\n}\n\ntest('q.add resolves to the correct value', async () => {\n\tconst q = queue(1);\n\n\tconst value = await q.add(() => 42);\n\tassert.equal(value, 42);\n});\n\ntest('q.add rejects if task rejects', async () => {\n\tconst q = queue(1);\n\n\ttry {\n\t\tawait q.add(async () => {\n\t\t\tawait sleep(1);\n\t\t\tthrow new Error('nope');\n\t\t});\n\n\t\tassert.ok(false);\n\t} catch (e) {\n\t\tassert.equal(/** @type {Error} */ (e).message, 'nope');\n\t}\n});\n\ntest('starts tasks in sequence', async () => {\n\tconst q = queue(2);\n\n\tconst promises = [];\n\n\t/** @type {Array<(value?: any) => void>} */\n\tconst fulfils = [];\n\n\tconst started = [false, false, false, false];\n\tconst finished = [false, false, false, false];\n\n\tfor (let i = 0; i < 4; i += 1) {\n\t\tpromises[i] = q\n\t\t\t.add(() => {\n\t\t\t\tstarted[i] = true;\n\t\t\t\treturn new Promise((f) => {\n\t\t\t\t\tfulfils.push(f);\n\t\t\t\t});\n\t\t\t})\n\t\t\t.then(() => {\n\t\t\t\tfinished[i] = true;\n\t\t\t});\n\t}\n\n\texpect(started).toEqual([true, true, false, false]);\n\texpect(finished).toEqual([false, false, false, false]);\n\n\tfulfils[0]();\n\tawait promises[0];\n\n\texpect(started).toEqual([true, true, true, false]);\n\texpect(finished).toEqual([true, false, false, false]);\n\n\tfulfils[1]();\n\tawait promises[1];\n\n\texpect(started).toEqual([true, true, true, true]);\n\texpect(finished).toEqual([true, true, false, false]);\n\n\tfulfils[2]();\n\tfulfils[3]();\n\tawait q.done();\n\n\texpect(finished).toEqual([true, true, true, true]);\n});\n\ntest('q.add fails if queue is already finished', async () => {\n\tconst q = queue(1);\n\tvoid q.add(() => {});\n\n\tawait q.done();\n\texpect(() => q.add(() => {})).throws(/Cannot add tasks to a queue that has ended/);\n});\n\ntest('q.done() resolves if nothing was added to the queue', async () => {\n\tconst q = queue(100);\n\tawait Promise.race([\n\t\tq.done(),\n\t\tsleep(1).then(() => {\n\t\t\tthrow new Error('Timed out');\n\t\t})\n\t]);\n});\n\ntest('q.done() rejects if task rejects', async () => {\n\tconst q = queue(1);\n\n\tq.add(async () => {\n\t\tawait sleep(1);\n\t\tthrow new Error('nope');\n\t}).catch((e) => {\n\t\tassert.equal(e.message, 'nope');\n\t});\n\n\ttry {\n\t\tawait q.done();\n\t\tassert.ok(false);\n\t} catch (e) {\n\t\tassert.equal(/** @type {Error} */ (e).message, 'nope');\n\t}\n});\n"
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/conflict.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/index.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport colors from 'kleur';\nimport { lookup } from 'mrmime';\nimport { list_files, runtime_directory } from '../../utils.js';\nimport { posixify, resolve_entry } from '../../../utils/filesystem.js';\nimport { parse_route_id } from '../../../utils/routing.js';\nimport { sort_routes } from './sort.js';\nimport { isSvelte5Plus } from '../utils.js';\nimport {\n\tcreate_node_analyser,\n\tget_page_options\n} from '../../../exports/vite/static_analysis/index.js';\n\n/**\n * Generates the manifest data used for the client-side manifest and types generation.\n * @param {{\n *   config: import('types').ValidatedConfig;\n *   fallback?: string;\n *   cwd?: string;\n * }} opts\n * @returns {import('types').ManifestData}\n */\nexport default function create_manifest_data({\n\tconfig,\n\tfallback = `${runtime_directory}/components/${isSvelte5Plus() ? 'svelte-5' : 'svelte-4'}`,\n\tcwd = process.cwd()\n}) {\n\tconst assets = create_assets(config);\n\tconst hooks = create_hooks(config, cwd);\n\tconst matchers = create_matchers(config, cwd);\n\tconst { nodes, routes } = create_routes_and_nodes(cwd, config, fallback);\n\n\tfor (const route of routes) {\n\t\tfor (const param of route.params) {\n\t\t\tif (param.matcher && !matchers[param.matcher]) {\n\t\t\t\tthrow new Error(`No matcher found for parameter '${param.matcher}' in route ${route.id}`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tassets,\n\t\thooks,\n\t\tmatchers,\n\t\tnodes,\n\t\troutes\n\t};\n}\n\n/**\n * @param {import('types').ValidatedConfig} config\n */\nexport function create_assets(config) {\n\treturn list_files(config.kit.files.assets).map((file) => ({\n\t\tfile,\n\t\tsize: fs.statSync(path.resolve(config.kit.files.assets, file)).size,\n\t\ttype: lookup(file) || null\n\t}));\n}\n\n/**\n * @param {import('types').ValidatedConfig} config\n * @param {string} cwd\n */\nfunction create_hooks(config, cwd) {\n\tconst client = resolve_entry(config.kit.files.hooks.client);\n\tconst server = resolve_entry(config.kit.files.hooks.server);\n\tconst universal = resolve_entry(config.kit.files.hooks.universal);\n\n\treturn {\n\t\tclient: client && posixify(path.relative(cwd, client)),\n\t\tserver: server && posixify(path.relative(cwd, server)),\n\t\tuniversal: universal && posixify(path.relative(cwd, universal))\n\t};\n}\n\n/**\n * @param {import('types').ValidatedConfig} config\n * @param {string} cwd\n */\nfunction create_matchers(config, cwd) {\n\tconst params_base = path.relative(cwd, config.kit.files.params);\n\n\t/** @type {Record<string, string>} */\n\tconst matchers = {};\n\tif (fs.existsSync(config.kit.files.params)) {\n\t\tfor (const file of fs.readdirSync(config.kit.files.params)) {\n\t\t\tconst ext = path.extname(file);\n\t\t\tif (!config.kit.moduleExtensions.includes(ext)) continue;\n\t\t\tconst type = file.slice(0, -ext.length);\n\n\t\t\tif (/^\\w+$/.test(type)) {\n\t\t\t\tconst matcher_file = path.join(params_base, file);\n\n\t\t\t\t// Disallow same matcher with different extensions\n\t\t\t\tif (matchers[type]) {\n\t\t\t\t\tthrow new Error(`Duplicate matchers: ${matcher_file} and ${matchers[type]}`);\n\t\t\t\t} else {\n\t\t\t\t\tmatchers[type] = matcher_file;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Allow for matcher test collocation\n\t\t\t\tif (type.endsWith('.test') || type.endsWith('.spec')) continue;\n\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Matcher names can only have underscores and alphanumeric characters — \"${file}\" is invalid`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn matchers;\n}\n\n/**\n * @param {import('types').ValidatedConfig} config\n * @param {string} cwd\n * @param {string} fallback\n */\nfunction create_routes_and_nodes(cwd, config, fallback) {\n\t/** @type {import('types').RouteData[]} */\n\tconst routes = [];\n\n\tconst routes_base = posixify(path.relative(cwd, config.kit.files.routes));\n\n\tconst valid_extensions = [...config.extensions, ...config.kit.moduleExtensions];\n\n\t/** @type {import('types').PageNode[]} */\n\tconst nodes = [];\n\n\tif (fs.existsSync(config.kit.files.routes)) {\n\t\t/**\n\t\t * @param {number} depth\n\t\t * @param {string} id\n\t\t * @param {string} segment\n\t\t * @param {import('types').RouteData | null} parent\n\t\t */\n\t\tconst walk = (depth, id, segment, parent) => {\n\t\t\tconst unescaped = id.replace(/\\[([ux])\\+([^\\]]+)\\]/gi, (match, type, code) => {\n\t\t\t\tif (match !== match.toLowerCase()) {\n\t\t\t\t\tthrow new Error(`Character escape sequence in ${id} must be lowercase`);\n\t\t\t\t}\n\n\t\t\t\tif (!/[0-9a-f]+/.test(code)) {\n\t\t\t\t\tthrow new Error(`Invalid character escape sequence in ${id}`);\n\t\t\t\t}\n\n\t\t\t\tif (type === 'x') {\n\t\t\t\t\tif (code.length !== 2) {\n\t\t\t\t\t\tthrow new Error(`Hexadecimal escape sequence in ${id} must be two characters`);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn String.fromCharCode(parseInt(code, 16));\n\t\t\t\t} else {\n\t\t\t\t\tif (code.length < 4 || code.length > 6) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unicode escape sequence in ${id} must be between four and six characters`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn String.fromCharCode(parseInt(code, 16));\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (/\\]\\[/.test(unescaped)) {\n\t\t\t\tthrow new Error(`Invalid route ${id} — parameters must be separated`);\n\t\t\t}\n\n\t\t\tif (count_occurrences('[', id) !== count_occurrences(']', id)) {\n\t\t\t\tthrow new Error(`Invalid route ${id} — brackets are unbalanced`);\n\t\t\t}\n\n\t\t\tif (/#/.test(segment)) {\n\t\t\t\t// Vite will barf on files with # in them\n\t\t\t\tthrow new Error(`Route ${id} should be renamed to ${id.replace(/#/g, '[x+23]')}`);\n\t\t\t}\n\n\t\t\tif (/\\[\\.\\.\\.\\w+\\]\\/\\[\\[/.test(id)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid route ${id} — an [[optional]] route segment cannot follow a [...rest] route segment`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (/\\[\\[\\.\\.\\./.test(id)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid route ${id} — a rest route segment is always optional, remove the outer square brackets`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst { pattern, params } = parse_route_id(id);\n\n\t\t\t/** @type {import('types').RouteData} */\n\t\t\tconst route = {\n\t\t\t\tid,\n\t\t\t\tparent,\n\n\t\t\t\tsegment,\n\t\t\t\tpattern,\n\t\t\t\tparams,\n\n\t\t\t\tlayout: null,\n\t\t\t\terror: null,\n\t\t\t\tleaf: null,\n\t\t\t\tpage: null,\n\t\t\t\tendpoint: null\n\t\t\t};\n\n\t\t\t// important to do this before walking children, so that child\n\t\t\t// routes appear later\n\t\t\troutes.push(route);\n\n\t\t\t// if we don't do this, the route map becomes unwieldy to console.log\n\t\t\tObject.defineProperty(route, 'parent', { enumerable: false });\n\n\t\t\tconst dir = path.join(cwd, routes_base, id);\n\n\t\t\t// We can't use withFileTypes because of a NodeJs bug which returns wrong results\n\t\t\t// with isDirectory() in case of symlinks: https://github.com/nodejs/node/issues/30646\n\t\t\tconst files = fs.readdirSync(dir).map((name) => ({\n\t\t\t\tis_dir: fs.statSync(path.join(dir, name)).isDirectory(),\n\t\t\t\tname\n\t\t\t}));\n\n\t\t\t// process files first\n\t\t\tfor (const file of files) {\n\t\t\t\tif (file.is_dir) continue;\n\n\t\t\t\tconst ext = valid_extensions.find((ext) => file.name.endsWith(ext));\n\t\t\t\tif (!ext) continue;\n\n\t\t\t\tif (!file.name.startsWith('+')) {\n\t\t\t\t\tconst name = file.name.slice(0, -ext.length);\n\t\t\t\t\t// check if it is a valid route filename but missing the + prefix\n\t\t\t\t\tconst typo =\n\t\t\t\t\t\t/^(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/.test(name) ||\n\t\t\t\t\t\t/^(?:(server)|(page(?:(@[a-zA-Z0-9_-]*))?(\\.server)?)|(layout(?:(@[a-zA-Z0-9_-]*))?(\\.server)?))$/.test(\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t);\n\t\t\t\t\tif (typo) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\tcolors\n\t\t\t\t\t\t\t\t.bold()\n\t\t\t\t\t\t\t\t.yellow(\n\t\t\t\t\t\t\t\t\t`Missing route file prefix. Did you mean +${file.name}?` +\n\t\t\t\t\t\t\t\t\t\t` at ${path.join(dir, file.name)}`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (file.name.endsWith('.d.ts')) {\n\t\t\t\t\tlet name = file.name.slice(0, -5);\n\t\t\t\t\tconst ext = valid_extensions.find((ext) => name.endsWith(ext));\n\t\t\t\t\tif (ext) name = name.slice(0, -ext.length);\n\n\t\t\t\t\tconst valid =\n\t\t\t\t\t\t/^\\+(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/.test(name) ||\n\t\t\t\t\t\t/^\\+(?:(server)|(page(?:(@[a-zA-Z0-9_-]*))?(\\.server)?)|(layout(?:(@[a-zA-Z0-9_-]*))?(\\.server)?))$/.test(\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif (valid) continue;\n\t\t\t\t}\n\n\t\t\t\tconst project_relative = posixify(path.relative(cwd, path.join(dir, file.name)));\n\n\t\t\t\tconst item = analyze(\n\t\t\t\t\tproject_relative,\n\t\t\t\t\tfile.name,\n\t\t\t\t\tconfig.extensions,\n\t\t\t\t\tconfig.kit.moduleExtensions\n\t\t\t\t);\n\n\t\t\t\tif (config.kit.router.type === 'hash' && item.kind === 'server') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Cannot use server-only files in an app with \\`router.type === 'hash': ${project_relative}`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * @param {string} type\n\t\t\t\t * @param {string} existing_file\n\t\t\t\t */\n\t\t\t\tfunction duplicate_files_error(type, existing_file) {\n\t\t\t\t\treturn new Error(\n\t\t\t\t\t\t`Multiple ${type} files found in ${routes_base}${route.id} : ${path.basename(\n\t\t\t\t\t\t\texisting_file\n\t\t\t\t\t\t)} and ${file.name}`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (item.kind === 'component') {\n\t\t\t\t\tif (item.is_error) {\n\t\t\t\t\t\troute.error = {\n\t\t\t\t\t\t\tdepth,\n\t\t\t\t\t\t\tcomponent: project_relative\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (item.is_layout) {\n\t\t\t\t\t\tif (!route.layout) {\n\t\t\t\t\t\t\troute.layout = { depth, child_pages: [] };\n\t\t\t\t\t\t} else if (route.layout.component) {\n\t\t\t\t\t\t\tthrow duplicate_files_error('layout component', route.layout.component);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\troute.layout.component = project_relative;\n\t\t\t\t\t\tif (item.uses_layout !== undefined) route.layout.parent_id = item.uses_layout;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!route.leaf) {\n\t\t\t\t\t\t\troute.leaf = { depth };\n\t\t\t\t\t\t} else if (route.leaf.component) {\n\t\t\t\t\t\t\tthrow duplicate_files_error('page component', route.leaf.component);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\troute.leaf.component = project_relative;\n\t\t\t\t\t\tif (item.uses_layout !== undefined) route.leaf.parent_id = item.uses_layout;\n\t\t\t\t\t}\n\t\t\t\t} else if (item.is_layout) {\n\t\t\t\t\tif (!route.layout) {\n\t\t\t\t\t\troute.layout = { depth, child_pages: [] };\n\t\t\t\t\t} else if (route.layout[item.kind]) {\n\t\t\t\t\t\tthrow duplicate_files_error(\n\t\t\t\t\t\t\titem.kind + ' layout module',\n\t\t\t\t\t\t\t/** @type {string} */ (route.layout[item.kind])\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\troute.layout[item.kind] = project_relative;\n\t\t\t\t} else if (item.is_page) {\n\t\t\t\t\tif (!route.leaf) {\n\t\t\t\t\t\troute.leaf = { depth };\n\t\t\t\t\t} else if (route.leaf[item.kind]) {\n\t\t\t\t\t\tthrow duplicate_files_error(\n\t\t\t\t\t\t\titem.kind + ' page module',\n\t\t\t\t\t\t\t/** @type {string} */ (route.leaf[item.kind])\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\troute.leaf[item.kind] = project_relative;\n\t\t\t\t} else {\n\t\t\t\t\tif (route.endpoint) {\n\t\t\t\t\t\tthrow duplicate_files_error('endpoint', route.endpoint.file);\n\t\t\t\t\t}\n\n\t\t\t\t\troute.endpoint = {\n\t\t\t\t\t\tfile: project_relative,\n\t\t\t\t\t\tpage_options: null // will be filled later\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// then handle children\n\t\t\tfor (const file of files) {\n\t\t\t\tif (file.is_dir) {\n\t\t\t\t\twalk(depth + 1, path.posix.join(id, file.name), file.name, route);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\twalk(0, '/', '', null);\n\n\t\tif (routes.length === 1) {\n\t\t\tconst root = routes[0];\n\t\t\tif (!root.leaf && !root.error && !root.layout && !root.endpoint) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'No routes found. If you are using a custom src/routes directory, make sure it is specified in your Svelte config file'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// If there's no routes directory, we'll just create a single empty route. This ensures the root layout and\n\t\t// error components are included in the manifest, which is needed for subsequent build/dev commands to work\n\t\troutes.push({\n\t\t\tid: '/',\n\t\t\tsegment: '',\n\t\t\tpattern: /^$/,\n\t\t\tparams: [],\n\t\t\tparent: null,\n\t\t\tlayout: null,\n\t\t\terror: null,\n\t\t\tleaf: null,\n\t\t\tpage: null,\n\t\t\tendpoint: null\n\t\t});\n\t}\n\n\tprevent_conflicts(routes);\n\n\tconst root = routes[0];\n\n\tif (!root.layout?.component) {\n\t\tif (!root.layout) root.layout = { depth: 0, child_pages: [] };\n\t\troot.layout.component = posixify(path.relative(cwd, `${fallback}/layout.svelte`));\n\t}\n\n\tif (!root.error?.component) {\n\t\tif (!root.error) root.error = { depth: 0 };\n\t\troot.error.component = posixify(path.relative(cwd, `${fallback}/error.svelte`));\n\t}\n\n\t// we do layouts/errors first as they are more likely to be reused,\n\t// and smaller indexes take fewer bytes. also, this guarantees that\n\t// the default error/layout are 0/1\n\tfor (const route of routes) {\n\t\tif (route.layout) {\n\t\t\tif (!route.layout?.component) {\n\t\t\t\troute.layout.component = posixify(path.relative(cwd, `${fallback}/layout.svelte`));\n\t\t\t}\n\t\t\tnodes.push(route.layout);\n\t\t}\n\t\tif (route.error) nodes.push(route.error);\n\t}\n\n\tfor (const route of routes) {\n\t\tif (route.leaf) nodes.push(route.leaf);\n\t}\n\n\tconst indexes = new Map(nodes.map((node, i) => [node, i]));\n\n\tconst node_analyser = create_node_analyser();\n\n\tfor (const route of routes) {\n\t\tif (!route.leaf) continue;\n\n\t\troute.page = {\n\t\t\tlayouts: [],\n\t\t\terrors: [],\n\t\t\tleaf: /** @type {number} */ (indexes.get(route.leaf))\n\t\t};\n\n\t\t/** @type {import('types').RouteData | null} */\n\t\tlet current_route = route;\n\t\tlet current_node = route.leaf;\n\t\tlet parent_id = route.leaf.parent_id;\n\n\t\twhile (current_route) {\n\t\t\tif (parent_id === undefined || current_route.segment === parent_id) {\n\t\t\t\tif (current_route.layout || current_route.error) {\n\t\t\t\t\troute.page.layouts.unshift(\n\t\t\t\t\t\tcurrent_route.layout ? indexes.get(current_route.layout) : undefined\n\t\t\t\t\t);\n\t\t\t\t\troute.page.errors.unshift(\n\t\t\t\t\t\tcurrent_route.error ? indexes.get(current_route.error) : undefined\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (current_route.layout) {\n\t\t\t\t\t/** @type {import('types').PageNode[]} */ (current_route.layout.child_pages).push(\n\t\t\t\t\t\troute.leaf\n\t\t\t\t\t);\n\t\t\t\t\tcurrent_node.parent = current_node = current_route.layout;\n\t\t\t\t\tparent_id = current_node.parent_id;\n\t\t\t\t} else {\n\t\t\t\t\tparent_id = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcurrent_route = current_route.parent;\n\t\t}\n\n\t\tif (parent_id !== undefined) {\n\t\t\tthrow new Error(`${current_node.component} references missing segment \"${parent_id}\"`);\n\t\t}\n\t}\n\n\tfor (const node of nodes) {\n\t\tnode.page_options = node_analyser.get_page_options(node);\n\t}\n\n\tfor (const route of routes) {\n\t\tif (route.endpoint) {\n\t\t\troute.endpoint.page_options = get_page_options(route.endpoint.file);\n\t\t}\n\t}\n\n\treturn {\n\t\tnodes,\n\t\troutes: sort_routes(routes)\n\t};\n}\n\n/**\n * @param {string} project_relative\n * @param {string} file\n * @param {string[]} component_extensions\n * @param {string[]} module_extensions\n * @returns {import('./types.js').RouteFile}\n */\nfunction analyze(project_relative, file, component_extensions, module_extensions) {\n\tconst component_extension = component_extensions.find((ext) => file.endsWith(ext));\n\tif (component_extension) {\n\t\tconst name = file.slice(0, -component_extension.length);\n\t\tconst pattern = /^\\+(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/;\n\t\tconst match = pattern.exec(name);\n\t\tif (!match) {\n\t\t\tthrow new Error(`Files prefixed with + are reserved (saw ${project_relative})`);\n\t\t}\n\n\t\treturn {\n\t\t\tkind: 'component',\n\t\t\tis_page: !!match[1],\n\t\t\tis_layout: !!match[3],\n\t\t\tis_error: !!match[5],\n\t\t\tuses_layout: match[2] ?? match[4]\n\t\t};\n\t}\n\n\tconst module_extension = module_extensions.find((ext) => file.endsWith(ext));\n\tif (module_extension) {\n\t\tconst name = file.slice(0, -module_extension.length);\n\t\tconst pattern =\n\t\t\t/^\\+(?:(server)|(page(?:(@[a-zA-Z0-9_-]*))?(\\.server)?)|(layout(?:(@[a-zA-Z0-9_-]*))?(\\.server)?))$/;\n\t\tconst match = pattern.exec(name);\n\t\tif (!match) {\n\t\t\tthrow new Error(`Files prefixed with + are reserved (saw ${project_relative})`);\n\t\t} else if (match[3] || match[6]) {\n\t\t\tthrow new Error(\n\t\t\t\t// prettier-ignore\n\t\t\t\t`Only Svelte files can reference named layouts. Remove '${match[3] || match[6]}' from ${file} (at ${project_relative})`\n\t\t\t);\n\t\t}\n\n\t\tconst kind = match[1] || match[4] || match[7] ? 'server' : 'universal';\n\n\t\treturn {\n\t\t\tkind,\n\t\t\tis_page: !!match[2],\n\t\t\tis_layout: !!match[5]\n\t\t};\n\t}\n\n\tthrow new Error(`Files and directories prefixed with + are reserved (saw ${project_relative})`);\n}\n\n/**\n * @param {string} needle\n * @param {string} haystack\n */\nfunction count_occurrences(needle, haystack) {\n\tlet count = 0;\n\tfor (let i = 0; i < haystack.length; i += 1) {\n\t\tif (haystack[i] === needle) count += 1;\n\t}\n\treturn count;\n}\n\n/** @param {import('types').RouteData[]} routes */\nfunction prevent_conflicts(routes) {\n\t/** @type {Map<string, string>} */\n\tconst lookup = new Map();\n\n\tfor (const route of routes) {\n\t\tif (!route.leaf && !route.endpoint) continue;\n\n\t\tconst normalized = normalize_route_id(route.id);\n\n\t\t// find all permutations created by optional parameters\n\t\tconst split = normalized.split(/<\\?(.+?)>/g);\n\n\t\tlet permutations = [/** @type {string} */ (split[0])];\n\n\t\t// turn `x/[[optional]]/y` into `x/y` and `x/[required]/y`\n\t\tfor (let i = 1; i < split.length; i += 2) {\n\t\t\tconst matcher = split[i];\n\t\t\tconst next = split[i + 1];\n\n\t\t\tpermutations = permutations.reduce((a, b) => {\n\t\t\t\ta.push(b + next);\n\t\t\t\tif (!(matcher === '*' && b.endsWith('//'))) a.push(b + `<${matcher}>${next}`);\n\t\t\t\treturn a;\n\t\t\t}, /** @type {string[]} */ ([]));\n\t\t}\n\n\t\tfor (const permutation of permutations) {\n\t\t\t// remove leading/trailing/duplicated slashes caused by prior\n\t\t\t// manipulation of optional parameters and (groups)\n\t\t\tconst key = permutation\n\t\t\t\t.replace(/\\/{2,}/, '/')\n\t\t\t\t.replace(/^\\//, '')\n\t\t\t\t.replace(/\\/$/, '');\n\n\t\t\tif (lookup.has(key)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The \"${lookup.get(key)}\" and \"${route.id}\" routes conflict with each other`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlookup.set(key, route.id);\n\t\t}\n\t}\n}\n\n/** @param {string} id */\nfunction normalize_route_id(id) {\n\treturn (\n\t\tid\n\t\t\t// remove groups\n\t\t\t.replace(/(?<=^|\\/)\\(.+?\\)(?=$|\\/)/g, '')\n\n\t\t\t.replace(/\\[[ux]\\+([0-9a-f]+)\\]/g, (_, x) =>\n\t\t\t\tString.fromCharCode(parseInt(x, 16)).replace(/\\//g, '%2f')\n\t\t\t)\n\n\t\t\t// replace `[param]` with `<*>`, `[param=x]` with `<x>`, and `[[param]]` with `<?*>`\n\t\t\t.replace(\n\t\t\t\t/\\[(?:(\\[)|(\\.\\.\\.))?.+?(=.+?)?\\]\\]?/g,\n\t\t\t\t(_, optional, rest, matcher) => `<${optional ? '?' : ''}${rest ?? ''}${matcher ?? '*'}>`\n\t\t\t)\n\t);\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/index.spec.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { assert, expect, test } from 'vitest';\nimport create_manifest_data from './index.js';\nimport { sort_routes } from './sort.js';\nimport { validate_config } from '../../config/index.js';\n\nconst cwd = fileURLToPath(new URL('./test', import.meta.url));\n\n/**\n * @param {string} dir\n * @param {import('@sveltejs/kit').Config} config\n */\nconst create = (dir, config = {}) => {\n\tconst initial = validate_config(config);\n\n\tinitial.kit.files.assets = path.resolve(cwd, 'static');\n\tinitial.kit.files.params = path.resolve(cwd, 'params');\n\tinitial.kit.files.routes = path.resolve(cwd, dir);\n\n\treturn create_manifest_data({\n\t\tconfig: /** @type {import('types').ValidatedConfig} */ (initial),\n\t\tfallback: cwd,\n\t\tcwd\n\t});\n};\n\nconst default_layout = {\n\tcomponent: 'layout.svelte'\n};\n\nconst default_error = {\n\tcomponent: 'error.svelte'\n};\n\n/** @param {import('types').PageNode} node */\nfunction simplify_node(node) {\n\t/** @type {import('types').PageNode} */\n\tconst simplified = {};\n\n\tif (node.component) simplified.component = node.component;\n\tif (node.universal) simplified.universal = node.universal;\n\tif (node.server) simplified.server = node.server;\n\tif (node.parent_id !== undefined) simplified.parent_id = node.parent_id;\n\n\treturn simplified;\n}\n\n/** @param {import('types').RouteData} route */\nfunction simplify_route(route) {\n\t/** @type {{ id: string, pattern: string, page?: import('types').PageNodeIndexes, endpoint?: { file: string } }} */\n\tconst simplified = {\n\t\tid: route.id,\n\t\tpattern: route.pattern.toString().replace(/\\\\\\//g, '/').replace(/\\\\\\./g, '.')\n\t};\n\n\tif (route.page) simplified.page = route.page;\n\tif (route.endpoint) simplified.endpoint = route.endpoint;\n\n\treturn simplified;\n}\n\ntest('creates routes', () => {\n\tconst { nodes, routes } = create('samples/basic');\n\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\tdefault_layout,\n\t\tdefault_error,\n\t\t{ component: 'samples/basic/+page.svelte' },\n\t\t{ component: 'samples/basic/about/+page.svelte' },\n\t\t{ component: 'samples/basic/blog/+page.svelte' },\n\t\t{ component: 'samples/basic/blog/[slug]/+page.svelte' }\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 2 }\n\t\t},\n\t\t{\n\t\t\tid: '/about',\n\t\t\tpattern: '/^/about/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 3 }\n\t\t},\n\t\t{\n\t\t\tid: '/blog.json',\n\t\t\tpattern: '/^/blog.json/?$/',\n\t\t\tendpoint: { file: 'samples/basic/blog.json/+server.js', page_options: null }\n\t\t},\n\t\t{\n\t\t\tid: '/blog',\n\t\t\tpattern: '/^/blog/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 4 }\n\t\t},\n\t\t{\n\t\t\tid: '/blog/[slug].json',\n\t\t\tpattern: '/^/blog/([^/]+?).json/?$/',\n\t\t\tendpoint: {\n\t\t\t\tfile: 'samples/basic/blog/[slug].json/+server.ts',\n\t\t\t\tpage_options: null\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tid: '/blog/[slug]',\n\t\t\tpattern: '/^/blog/([^/]+?)/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 5 }\n\t\t}\n\t]);\n});\n\nconst symlink_survived_git = fs\n\t.lstatSync(path.join(cwd, 'samples/symlinks/routes/foo'))\n\t.isSymbolicLink();\n\nconst test_symlinks = symlink_survived_git ? test : test.skip;\n\ntest_symlinks('creates symlinked routes', () => {\n\tconst { nodes, routes } = create('samples/symlinks/routes');\n\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\tdefault_layout,\n\t\tdefault_error,\n\t\t{ component: 'samples/symlinks/routes/+page.svelte' },\n\t\t{ component: 'samples/symlinks/routes/foo/+page.svelte' }\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 2 }\n\t\t},\n\n\t\t{\n\t\t\tid: '/foo',\n\t\t\tpattern: '/^/foo/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 3 }\n\t\t}\n\t]);\n});\n\ntest('creates routes with layout', () => {\n\tconst { nodes, routes } = create('samples/basic-layout');\n\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\t{ component: 'samples/basic-layout/+layout.svelte' },\n\t\tdefault_error,\n\t\t{ component: 'samples/basic-layout/foo/+layout.svelte' },\n\t\t{ component: 'samples/basic-layout/+page.svelte' },\n\t\t{ component: 'samples/basic-layout/foo/+page.svelte' }\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 3 }\n\t\t},\n\n\t\t{\n\t\t\tid: '/foo',\n\t\t\tpattern: '/^/foo/?$/',\n\t\t\tpage: { layouts: [0, 2], errors: [1, undefined], leaf: 4 }\n\t\t}\n\t]);\n});\n\ntest('succeeds when routes does not exist', () => {\n\tconst { nodes, routes } = create('samples/basic/routes');\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\t{ component: 'layout.svelte' },\n\t\t{ component: 'error.svelte' }\n\t]);\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^$/'\n\t\t}\n\t]);\n});\n\ntest('encodes invalid characters', () => {\n\tconst { nodes, routes } = create('samples/encoding');\n\n\tconst quote = { component: 'samples/encoding/[x+22]/+page.svelte' };\n\tconst hash = { component: 'samples/encoding/[x+23]/+page.svelte' };\n\tconst question_mark = { component: 'samples/encoding/[x+3f]/+page.svelte' };\n\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\tdefault_layout,\n\t\tdefault_error,\n\t\tquote,\n\t\thash,\n\t\tquestion_mark\n\t]);\n\n\texpect(routes.map((p) => p.pattern.toString())).toEqual(\n\t\t[/^\\/$/, /^\\/%3[Ff]\\/?$/, /^\\/%23\\/?$/, /^\\/\"\\/?$/].map((pattern) => pattern.toString())\n\t);\n});\n\ntest('sorts routes correctly', () => {\n\tconst expected = [\n\t\t'/',\n\t\t'/a',\n\t\t'/b',\n\t\t'/b/[required]',\n\t\t'/c',\n\t\t'/c/bar',\n\t\t'/c/b[x].json',\n\t\t'/c/b[x]',\n\t\t'/c/foo',\n\t\t'/d/e',\n\t\t'/d/e[...rest]',\n\t\t'/e/f',\n\t\t'/e/[...rest]/f',\n\t\t'/f/static[...rest]',\n\t\t'/f/[...rest]static',\n\t\t'/g/[[optional]]/static',\n\t\t'/g/[required]',\n\t\t'/g/[...rest]/[required]',\n\t\t'/h/a/b',\n\t\t'/h/a/[required]/b',\n\t\t'/h/a/[...rest]/b',\n\t\t'/x/[...rest]',\n\t\t'/[...rest]/x',\n\t\t'/[...rest]/x/[...deep_rest]/y',\n\t\t'/[...rest]/x/[...deep_rest]',\n\t\t'/[required=matcher]',\n\t\t'/[required]',\n\t\t'/[...rest]'\n\t];\n\n\tconst routes = /** @type {import('types').RouteData[]} */ (expected.map((id) => ({ id })));\n\n\tconst actual = sort_routes(routes.sort(() => (Math.random() > 0.5 ? 1 : -1))).map(\n\t\t(route) => route.id\n\t);\n\n\texpect(actual).toEqual(expected);\n});\n\ntest('sorts routes with rest correctly', () => {\n\tconst { nodes, routes } = create('samples/rest');\n\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\tdefault_layout,\n\t\tdefault_error,\n\t\t{\n\t\t\tcomponent: 'samples/rest/a/[...rest]/+page.svelte',\n\t\t\tserver: 'samples/rest/a/[...rest]/+page.server.js'\n\t\t},\n\t\t{\n\t\t\tcomponent: 'samples/rest/b/[...rest]/+page.svelte',\n\t\t\tserver: 'samples/rest/b/[...rest]/+page.server.ts'\n\t\t}\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/'\n\t\t},\n\t\t{\n\t\t\tid: '/a',\n\t\t\tpattern: '/^/a/?$/'\n\t\t},\n\t\t{\n\t\t\tid: '/a/[...rest]',\n\t\t\tpattern: '/^/a(?:/([^]*))?/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 2 }\n\t\t},\n\t\t{\n\t\t\tid: '/b',\n\t\t\tpattern: '/^/b/?$/'\n\t\t},\n\t\t{\n\t\t\tid: '/b/[...rest]',\n\t\t\tpattern: '/^/b(?:/([^]*))?/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 3 }\n\t\t}\n\t]);\n});\n\ntest('allows rest parameters inside segments', () => {\n\tconst { nodes, routes } = create('samples/rest-prefix-suffix');\n\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\tdefault_layout,\n\t\tdefault_error,\n\t\t{\n\t\t\tcomponent: 'samples/rest-prefix-suffix/prefix-[...rest]/+page.svelte'\n\t\t}\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/'\n\t\t},\n\t\t{\n\t\t\tid: '/prefix-[...rest]',\n\t\t\tpattern: '/^/prefix-([^]*?)/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 2 }\n\t\t},\n\t\t{\n\t\t\tid: '/[...rest].json',\n\t\t\tpattern: '/^/([^]*?).json/?$/',\n\t\t\tendpoint: {\n\t\t\t\tfile: 'samples/rest-prefix-suffix/[...rest].json/+server.js',\n\t\t\t\tpage_options: null\n\t\t\t}\n\t\t}\n\t]);\n});\n\ntest('optional parameters', () => {\n\tconst { nodes, routes } = create('samples/optional');\n\n\texpect(\n\t\tnodes\n\t\t\t.map(simplify_node)\n\t\t\t// for some reason linux and windows have a different order, which is why\n\t\t\t// we need sort the nodes using a sort function (doesn't work either without),\n\t\t\t// resulting in the following expected node order\n\t\t\t.sort((a, b) => a.component?.localeCompare(b.component ?? '') ?? 1)\n\t).toEqual([\n\t\tdefault_error,\n\t\tdefault_layout,\n\t\t{\n\t\t\tcomponent: 'samples/optional/[[optional]]/+page.svelte'\n\t\t},\n\t\t{\n\t\t\tcomponent: 'samples/optional/nested/[[optional]]/sub/+page.svelte'\n\t\t},\n\t\t{\n\t\t\tcomponent: 'samples/optional/prefix[[suffix]]/+page.svelte'\n\t\t}\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/'\n\t\t},\n\t\t{\n\t\t\tid: '/[[foo]]bar',\n\t\t\tpattern: '/^/([^/]*)?bar/?$/',\n\t\t\tendpoint: { file: 'samples/optional/[[foo]]bar/+server.js', page_options: null }\n\t\t},\n\t\t{ id: '/nested', pattern: '/^/nested/?$/' },\n\t\t{\n\t\t\tid: '/nested/[[optional]]/sub',\n\t\t\tpattern: '/^/nested(?:/([^/]+))?/sub/?$/',\n\t\t\tpage: {\n\t\t\t\tlayouts: [0],\n\t\t\t\terrors: [1],\n\t\t\t\t// see above, linux/windows difference -> find the index dynamically\n\t\t\t\tleaf: nodes.findIndex((node) => node.component?.includes('nested/[[optional]]'))\n\t\t\t}\n\t\t},\n\t\t{ id: '/nested/[[optional]]', pattern: '/^/nested(?:/([^/]+))?/?$/' },\n\t\t{\n\t\t\tid: '/prefix[[suffix]]',\n\t\t\tpattern: '/^/prefix([^/]*)?/?$/',\n\t\t\tpage: {\n\t\t\t\tlayouts: [0],\n\t\t\t\terrors: [1],\n\t\t\t\t// see above, linux/windows difference -> find the index dynamically\n\t\t\t\tleaf: nodes.findIndex((node) => node.component?.includes('prefix[[suffix]]'))\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tid: '/[[optional]]',\n\t\t\tpattern: '/^(?:/([^/]+))?/?$/',\n\t\t\tpage: {\n\t\t\t\tlayouts: [0],\n\t\t\t\terrors: [1],\n\t\t\t\t// see above, linux/windows difference -> find the index dynamically\n\t\t\t\tleaf: nodes.findIndex((node) => node.component?.includes('optional/[[optional]]'))\n\t\t\t}\n\t\t}\n\t]);\n});\n\ntest('nested optionals', () => {\n\tconst { nodes, routes } = create('samples/nested-optionals');\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\tdefault_layout,\n\t\tdefault_error,\n\t\t{ component: 'samples/nested-optionals/[[a]]/[[b]]/+page.svelte' }\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/'\n\t\t},\n\t\t{\n\t\t\tid: '/[[a]]/[[b]]',\n\t\t\tpattern: '/^(?:/([^/]+))?(?:/([^/]+))?/?$/',\n\t\t\tpage: {\n\t\t\t\tlayouts: [0],\n\t\t\t\terrors: [1],\n\t\t\t\tleaf: nodes.findIndex((node) => node.component?.includes('/[[a]]/[[b]]'))\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tid: '/[[a]]',\n\t\t\tpattern: '/^(?:/([^/]+))?/?$/'\n\t\t}\n\t]);\n});\n\ntest('group preceding optional parameters', () => {\n\tconst { nodes, routes } = create('samples/optional-group');\n\n\texpect(\n\t\tnodes\n\t\t\t.map(simplify_node)\n\t\t\t// for some reason linux and windows have a different order, which is why\n\t\t\t// we need sort the nodes using a sort function (doesn't work either without),\n\t\t\t// resulting in the following expected node order\n\t\t\t.sort((a, b) => a.component?.localeCompare(b.component ?? '') ?? 1)\n\t).toEqual([\n\t\tdefault_error,\n\t\tdefault_layout,\n\t\t{\n\t\t\tcomponent: 'samples/optional-group/[[optional]]/(group)/+page.svelte'\n\t\t}\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/'\n\t\t},\n\t\t{\n\t\t\tid: '/[[optional]]/(group)',\n\t\t\tpattern: '/^(?:/([^/]+))?/?$/',\n\t\t\tpage: {\n\t\t\t\tlayouts: [0],\n\t\t\t\terrors: [1],\n\t\t\t\t// see above, linux/windows difference -> find the index dynamically\n\t\t\t\tleaf: nodes.findIndex((node) =>\n\t\t\t\t\tnode.component?.includes('optional-group/[[optional]]/(group)')\n\t\t\t\t)\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tid: '/[[optional]]',\n\t\t\tpattern: '/^(?:/([^/]+))?/?$/'\n\t\t}\n\t]);\n});\n\ntest('ignores files and directories with leading underscores', () => {\n\tconst { routes } = create('samples/hidden-underscore');\n\n\texpect(routes.map((r) => r.endpoint?.file).filter(Boolean)).toEqual([\n\t\t'samples/hidden-underscore/e/f/g/h/+server.js'\n\t]);\n});\n\ntest('ignores files and directories with leading dots except .well-known', () => {\n\tconst { routes } = create('samples/hidden-dot');\n\n\texpect(routes.map((r) => r.endpoint?.file).filter(Boolean)).toEqual([\n\t\t'samples/hidden-dot/.well-known/dnt-policy.txt/+server.js'\n\t]);\n});\n\ntest('allows multiple slugs', () => {\n\tconst { routes } = create('samples/multiple-slugs');\n\n\texpect(routes.filter((route) => route.endpoint).map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/[file].[ext]',\n\t\t\tpattern: '/^/([^/]+?).([^/]+?)/?$/',\n\t\t\tendpoint: {\n\t\t\t\tfile: 'samples/multiple-slugs/[file].[ext]/+server.js',\n\t\t\t\tpage_options: null\n\t\t\t}\n\t\t}\n\t]);\n});\n\ntest('fails if dynamic params are not separated', () => {\n\tassert.throws(() => {\n\t\tcreate('samples/invalid-params');\n\t}, /Invalid route \\/\\[foo\\]\\[bar\\] — parameters must be separated/);\n});\n\ntest('ignores things that look like lockfiles', () => {\n\tconst { routes } = create('samples/lockfiles');\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/'\n\t\t},\n\t\t{\n\t\t\tid: '/foo',\n\t\t\tpattern: '/^/foo/?$/',\n\t\t\tendpoint: {\n\t\t\t\tfile: 'samples/lockfiles/foo/+server.js',\n\t\t\t\tpage_options: null\n\t\t\t}\n\t\t}\n\t]);\n});\n\ntest('works with custom extensions', () => {\n\tconst { nodes, routes } = create('samples/custom-extension', {\n\t\textensions: ['.jazz', '.beebop', '.funk', '.svelte']\n\t});\n\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\tdefault_layout,\n\t\tdefault_error,\n\t\t{ component: 'samples/custom-extension/+page.funk' },\n\t\t{ component: 'samples/custom-extension/about/+page.jazz' },\n\t\t{ component: 'samples/custom-extension/blog/+page.svelte' },\n\t\t{ component: 'samples/custom-extension/blog/[slug]/+page.beebop' }\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 2 }\n\t\t},\n\t\t{\n\t\t\tid: '/about',\n\t\t\tpattern: '/^/about/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 3 }\n\t\t},\n\t\t{\n\t\t\tid: '/blog.json',\n\t\t\tpattern: '/^/blog.json/?$/',\n\t\t\tendpoint: {\n\t\t\t\tfile: 'samples/custom-extension/blog.json/+server.js',\n\t\t\t\tpage_options: null\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tid: '/blog',\n\t\t\tpattern: '/^/blog/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 4 }\n\t\t},\n\t\t{\n\t\t\tid: '/blog/[slug].json',\n\t\t\tpattern: '/^/blog/([^/]+?).json/?$/',\n\t\t\tendpoint: {\n\t\t\t\tfile: 'samples/custom-extension/blog/[slug].json/+server.js',\n\t\t\t\tpage_options: null\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tid: '/blog/[slug]',\n\t\t\tpattern: '/^/blog/([^/]+?)/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 5 }\n\t\t}\n\t]);\n});\n\ntest('lists static assets', () => {\n\tconst { assets } = create('samples/basic');\n\n\texpect(assets).toEqual([\n\t\t{\n\t\t\tfile: 'bar/baz.txt',\n\t\t\tsize: 14,\n\t\t\ttype: 'text/plain'\n\t\t},\n\t\t{\n\t\t\tfile: 'foo.txt',\n\t\t\tsize: 9,\n\t\t\ttype: 'text/plain'\n\t\t}\n\t]);\n});\n\ntest('includes nested error components', () => {\n\tconst { nodes, routes } = create('samples/nested-errors');\n\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\tdefault_layout,\n\t\tdefault_error,\n\t\t{ component: 'samples/nested-errors/foo/+layout.svelte' },\n\t\t{ component: 'samples/nested-errors/foo/bar/+error.svelte' },\n\t\t{ component: 'samples/nested-errors/foo/bar/baz/+layout.svelte' },\n\t\t{ component: 'samples/nested-errors/foo/bar/baz/+error.svelte' },\n\t\t{ component: 'samples/nested-errors/foo/bar/baz/+page.svelte' }\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/'\n\t\t},\n\t\t{\n\t\t\tid: '/foo',\n\t\t\tpattern: '/^/foo/?$/'\n\t\t},\n\t\t{\n\t\t\tid: '/foo/bar',\n\t\t\tpattern: '/^/foo/bar/?$/'\n\t\t},\n\t\t{\n\t\t\tid: '/foo/bar/baz',\n\t\t\tpattern: '/^/foo/bar/baz/?$/',\n\t\t\tpage: { layouts: [0, 2, undefined, 4], errors: [1, undefined, 3, 5], leaf: 6 }\n\t\t}\n\t]);\n});\n\ntest('creates routes with named layouts', () => {\n\tconst { nodes, routes } = create('samples/named-layouts');\n\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\t// layouts\n\t\t{ component: 'samples/named-layouts/+layout.svelte' }, // 0\n\t\tdefault_error, // 1\n\t\t{\n\t\t\tcomponent: 'samples/named-layouts/(special)/+layout.svelte',\n\t\t\tuniversal: 'samples/named-layouts/(special)/+layout.js',\n\t\t\tserver: 'samples/named-layouts/(special)/+layout.server.js'\n\t\t}, // 2\n\t\t{ component: 'samples/named-layouts/(special)/(alsospecial)/+layout.svelte' }, // 3\n\t\t{ component: 'samples/named-layouts/a/+layout.svelte' }, // 4\n\t\t{ component: 'samples/named-layouts/b/c/+layout.svelte' }, // 5\n\t\t{ component: 'samples/named-layouts/b/d/(special)/+layout.svelte' }, // 6\n\t\t{ component: 'samples/named-layouts/b/d/(special)/(extraspecial)/+layout.svelte' }, // 7\n\n\t\t// pages\n\t\t{ component: 'samples/named-layouts/(special)/(alsospecial)/b/c/c1/+page.svelte' }, // 8\n\t\t{ component: 'samples/named-layouts/(special)/a/a2/+page.svelte' }, // 9\n\t\t{ component: 'samples/named-layouts/a/a1/+page.svelte' }, // 10\n\t\t{ component: 'samples/named-layouts/b/c/c2/+page@.svelte', parent_id: '' }, // 11\n\t\t{ component: 'samples/named-layouts/b/d/(special)/+page.svelte' }, // 12\n\t\t{ component: 'samples/named-layouts/b/d/(special)/(extraspecial)/d2/+page.svelte' }, // 13\n\t\t{\n\t\t\tcomponent: 'samples/named-layouts/b/d/(special)/(extraspecial)/d3/+page@(special).svelte',\n\t\t\tparent_id: '(special)'\n\t\t}, // 14\n\t\t{ component: 'samples/named-layouts/b/d/d1/+page.svelte' } // 15\n\t]);\n\n\texpect(routes.filter((route) => route.page).map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/a/a1',\n\t\t\tpattern: '/^/a/a1/?$/',\n\t\t\tpage: { layouts: [0, 4], errors: [1, undefined], leaf: 10 }\n\t\t},\n\t\t{\n\t\t\tid: '/(special)/a/a2',\n\t\t\tpattern: '/^/a/a2/?$/',\n\t\t\tpage: { layouts: [0, 2], errors: [1, undefined], leaf: 9 }\n\t\t},\n\t\t{\n\t\t\tid: '/(special)/(alsospecial)/b/c/c1',\n\t\t\tpattern: '/^/b/c/c1/?$/',\n\t\t\tpage: { layouts: [0, 2, 3], errors: [1, undefined, undefined], leaf: 8 }\n\t\t},\n\t\t{\n\t\t\tid: '/b/c/c2',\n\t\t\tpattern: '/^/b/c/c2/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 11 }\n\t\t},\n\t\t{\n\t\t\tid: '/b/d/(special)',\n\t\t\tpattern: '/^/b/d/?$/',\n\t\t\tpage: { layouts: [0, 6], errors: [1, undefined], leaf: 12 }\n\t\t},\n\t\t{\n\t\t\tid: '/b/d/d1',\n\t\t\tpattern: '/^/b/d/d1/?$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 15 }\n\t\t},\n\t\t{\n\t\t\tid: '/b/d/(special)/(extraspecial)/d2',\n\t\t\tpattern: '/^/b/d/d2/?$/',\n\t\t\tpage: { layouts: [0, 6, 7], errors: [1, undefined, undefined], leaf: 13 }\n\t\t},\n\t\t{\n\t\t\tid: '/b/d/(special)/(extraspecial)/d3',\n\t\t\tpattern: '/^/b/d/d3/?$/',\n\t\t\tpage: { layouts: [0, 6], errors: [1, undefined], leaf: 14 }\n\t\t}\n\t]);\n});\n\ntest('handles pages without .svelte file', () => {\n\tconst { nodes, routes } = create('samples/page-without-svelte-file');\n\n\texpect(nodes.map(simplify_node)).toEqual([\n\t\tdefault_layout,\n\t\tdefault_error,\n\t\t{ component: 'samples/page-without-svelte-file/error/+error.svelte' },\n\t\t{ component: 'samples/page-without-svelte-file/layout/+layout.svelte' },\n\t\t{ ...default_layout, universal: 'samples/page-without-svelte-file/layout/exists/+layout.js' },\n\t\t{ component: 'samples/page-without-svelte-file/+page.svelte' },\n\t\t{ universal: 'samples/page-without-svelte-file/error/[...path]/+page.js' },\n\t\t{ component: 'samples/page-without-svelte-file/layout/exists/+page.svelte' },\n\t\t{ server: 'samples/page-without-svelte-file/layout/redirect/+page.server.js' }\n\t]);\n\n\texpect(routes.map(simplify_route)).toEqual([\n\t\t{\n\t\t\tid: '/',\n\t\t\tpattern: '/^/$/',\n\t\t\tpage: { layouts: [0], errors: [1], leaf: 5 }\n\t\t},\n\t\t{\n\t\t\tid: '/error',\n\t\t\tpattern: '/^/error/?$/'\n\t\t},\n\t\t{\n\t\t\tid: '/error/[...path]',\n\t\t\tpattern: '/^/error(?:/([^]*))?/?$/',\n\t\t\tpage: { layouts: [0, undefined], errors: [1, 2], leaf: 6 }\n\t\t},\n\t\t{\n\t\t\tid: '/layout',\n\t\t\tpattern: '/^/layout/?$/'\n\t\t},\n\t\t{\n\t\t\tid: '/layout/exists',\n\t\t\tpattern: '/^/layout/exists/?$/',\n\t\t\tpage: { layouts: [0, 3, 4], errors: [1, undefined, undefined], leaf: 7 }\n\t\t},\n\t\t{\n\t\t\tid: '/layout/redirect',\n\t\t\tpattern: '/^/layout/redirect/?$/',\n\t\t\tpage: { layouts: [0, 3], errors: [1, undefined], leaf: 8 }\n\t\t}\n\t]);\n});\n\ntest('errors on missing layout', () => {\n\tassert.throws(\n\t\t() => create('samples/named-layout-missing'),\n\t\t/samples\\/named-layout-missing\\/\\+page@missing.svelte references missing segment \"missing\"/\n\t);\n});\n\ntest('errors on invalid named layout reference', () => {\n\tassert.throws(\n\t\t() => create('samples/invalid-named-layout-reference'),\n\t\t/Only Svelte files can reference named layouts. Remove '@' from \\+page@.js \\(at samples\\/invalid-named-layout-reference\\/x\\/\\+page@.js\\)/\n\t);\n});\n\ntest('creates param matchers', () => {\n\tconst { matchers } = create('samples/basic'); // directory doesn't matter for the test\n\n\texpect(matchers).toEqual({\n\t\tfoo: path.join('params', 'foo.js'),\n\t\tbar: path.join('params', 'bar.js')\n\t});\n});\n\ntest('errors on param matchers with bad names', () => {\n\tconst boogaloo = path.resolve(cwd, 'params', 'boo-galoo.js');\n\tfs.writeFileSync(boogaloo, '');\n\ttry {\n\t\tassert.throws(() => create('samples/basic'), /Matcher names can only have/);\n\t} finally {\n\t\tfs.unlinkSync(boogaloo);\n\t}\n});\n\ntest('errors on duplicate matchers', () => {\n\tconst ts_foo = path.resolve(cwd, 'params', 'foo.ts');\n\tfs.writeFileSync(ts_foo, '');\n\ttry {\n\t\tassert.throws(() => {\n\t\t\tcreate('samples/basic', {\n\t\t\t\tkit: {\n\t\t\t\t\tmoduleExtensions: ['.js', '.ts']\n\t\t\t\t}\n\t\t\t});\n\t\t}, /Duplicate matchers/);\n\t} finally {\n\t\tfs.unlinkSync(ts_foo);\n\t}\n});\n\ntest('prevents route conflicts between groups', () => {\n\tassert.throws(\n\t\t() => create('samples/conflicting-groups'),\n\t\t/The \"\\/\\(x\\)\\/a\" and \"\\/\\(y\\)\\/a\" routes conflict with each other/\n\t);\n});\n\ntest('errors with multiple layouts on same directory', () => {\n\tassert.throws(\n\t\t() => create('samples/multiple-layouts'),\n\t\t/^Multiple layout component files found in samples\\/multiple-layouts\\/ : \\+layout\\.svelte and \\+layout@\\.svelte/\n\t);\n});\n\ntest('errors with multiple pages on same directory', () => {\n\tassert.throws(\n\t\t() => create('samples/multiple-pages'),\n\t\t/^Multiple page component files found in samples\\/multiple-pages\\/ : \\+page\\.svelte and \\+page@\\.svelte/\n\t);\n});\n\ntest('errors with both ts and js handlers for the same route', () => {\n\tassert.throws(\n\t\t() => create('samples/conflicting-ts-js-handlers-page'),\n\t\t/^Multiple universal page module files found in samples\\/conflicting-ts-js-handlers-page\\/ : \\+page\\.js and \\+page\\.ts/\n\t);\n\n\tassert.throws(\n\t\t() => create('samples/conflicting-ts-js-handlers-layout'),\n\t\t/^Multiple server layout module files found in samples\\/conflicting-ts-js-handlers-layout\\/ : \\+layout\\.server\\.js and \\+layout\\.server\\.ts/\n\t);\n\n\tassert.throws(\n\t\t() => create('samples/conflicting-ts-js-handlers-server'),\n\t\t/^Multiple endpoint files found in samples\\/conflicting-ts-js-handlers-server\\/ : \\+server\\.js and \\+server\\.ts/\n\t);\n});\n"
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/sort.js",
    "content": "import { get_route_segments } from '../../../utils/routing.js';\n\n/**\n * @typedef {{\n *   type: 'static' | 'required' | 'optional' | 'rest';\n *   content: string;\n *   matched: boolean;\n * }} Part\n */\n\n/**\n * @typedef {Part[]} Segment\n */\n\nconst EMPTY = { type: 'static', content: '', matched: false };\n\n/** @param {import('types').RouteData[]} routes */\nexport function sort_routes(routes) {\n\t/** @type {Map<string, Part[]>} */\n\tconst segment_cache = new Map();\n\n\t/** @param {string} segment */\n\tfunction get_parts(segment) {\n\t\tif (!segment_cache.has(segment)) {\n\t\t\tsegment_cache.set(segment, split(segment));\n\t\t}\n\n\t\treturn segment_cache.get(segment);\n\t}\n\n\t/** @param {string} id */\n\tfunction split(id) {\n\t\t/** @type {Part[]} */\n\t\tconst parts = [];\n\n\t\tlet i = 0;\n\t\twhile (i <= id.length) {\n\t\t\tconst start = id.indexOf('[', i);\n\t\t\tif (start === -1) {\n\t\t\t\tparts.push({ type: 'static', content: id.slice(i), matched: false });\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tparts.push({ type: 'static', content: id.slice(i, start), matched: false });\n\n\t\t\tconst type = id[start + 1] === '[' ? 'optional' : id[start + 1] === '.' ? 'rest' : 'required';\n\t\t\tconst delimiter = type === 'optional' ? ']]' : ']';\n\t\t\tconst end = id.indexOf(delimiter, start);\n\n\t\t\tif (end === -1) {\n\t\t\t\tthrow new Error(`Invalid route ID ${id}`);\n\t\t\t}\n\n\t\t\tconst content = id.slice(start, (i = end + delimiter.length));\n\n\t\t\tparts.push({\n\t\t\t\ttype,\n\t\t\t\tcontent,\n\t\t\t\tmatched: content.includes('=')\n\t\t\t});\n\t\t}\n\n\t\treturn parts;\n\t}\n\n\treturn routes.sort((route_a, route_b) => {\n\t\tconst segments_a = split_route_id(route_a.id).map(get_parts);\n\t\tconst segments_b = split_route_id(route_b.id).map(get_parts);\n\n\t\tfor (let i = 0; i < Math.max(segments_a.length, segments_b.length); i += 1) {\n\t\t\tconst segment_a = segments_a[i] ?? [EMPTY];\n\t\t\tconst segment_b = segments_b[i] ?? [EMPTY];\n\n\t\t\tfor (let j = 0; j < Math.max(segment_a.length, segment_b.length); j += 1) {\n\t\t\t\tconst a = segment_a[j];\n\t\t\t\tconst b = segment_b[j];\n\n\t\t\t\t// first part of each segment is always static\n\t\t\t\t// (though it may be the empty string), then\n\t\t\t\t// it alternates between dynamic and static\n\t\t\t\t// (i.e. [foo][bar] is disallowed)\n\t\t\t\tconst dynamic = j % 2 === 1;\n\n\t\t\t\tif (dynamic) {\n\t\t\t\t\tif (!a) return -1;\n\t\t\t\t\tif (!b) return +1;\n\n\t\t\t\t\t// get the next static chunk, so we can handle [...rest] edge cases\n\t\t\t\t\tconst next_a = segment_a[j + 1].content || segments_a[i + 1]?.[0].content;\n\t\t\t\t\tconst next_b = segment_b[j + 1].content || segments_b[i + 1]?.[0].content;\n\n\t\t\t\t\t// `[...rest]/x` outranks `[...rest]`\n\t\t\t\t\tif (a.type === 'rest' && b.type === 'rest') {\n\t\t\t\t\t\tif (next_a && next_b) continue;\n\t\t\t\t\t\tif (next_a) return -1;\n\t\t\t\t\t\tif (next_b) return +1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// `[...rest]/x` outranks `[required]` or `[required]/[required]`\n\t\t\t\t\t// but not `[required]/x`\n\t\t\t\t\tif (a.type === 'rest') {\n\t\t\t\t\t\treturn next_a && !next_b ? -1 : +1;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (b.type === 'rest') {\n\t\t\t\t\t\treturn next_b && !next_a ? +1 : -1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// part with matcher outranks one without\n\t\t\t\t\tif (a.matched !== b.matched) {\n\t\t\t\t\t\treturn a.matched ? -1 : +1;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (a.type !== b.type) {\n\t\t\t\t\t\t// `[...rest]` has already been accounted for, so here\n\t\t\t\t\t\t// we're comparing between `[required]` and `[[optional]]`\n\t\t\t\t\t\tif (a.type === 'required') return -1;\n\t\t\t\t\t\tif (b.type === 'required') return +1;\n\t\t\t\t\t}\n\t\t\t\t} else if (a.content !== b.content) {\n\t\t\t\t\t// shallower path outranks deeper path\n\t\t\t\t\tif (a === EMPTY) return -1;\n\t\t\t\t\tif (b === EMPTY) return +1;\n\n\t\t\t\t\treturn sort_static(a.content, b.content);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn route_a.id < route_b.id ? +1 : -1;\n\t});\n}\n\n/** @param {string} id */\nfunction split_route_id(id) {\n\treturn get_route_segments(\n\t\tid\n\t\t\t// remove all [[optional]] parts unless they're at the very end\n\t\t\t// or it ends with a route group\n\t\t\t.replace(/\\[\\[[^\\]]+\\]\\](?!(?:\\/\\([^/]+\\))*$)/g, '')\n\t).filter(Boolean);\n}\n\n/**\n * Sort two strings lexicographically, except `foobar` outranks `foo`\n * @param {string} a\n * @param {string} b\n */\nfunction sort_static(a, b) {\n\tif (a === b) return 0;\n\n\tfor (let i = 0; true; i += 1) {\n\t\tconst char_a = a[i];\n\t\tconst char_b = b[i];\n\n\t\tif (char_a !== char_b) {\n\t\t\tif (char_a === undefined) return +1;\n\t\t\tif (char_b === undefined) return -1;\n\t\t\treturn char_a < char_b ? -1 : +1;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/params/bar.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/params/foo.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic/+page.d.ts",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic/about/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic/blog/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic/blog/[slug]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic/blog/[slug].json/+server.ts",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic/blog/default.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic/blog.json/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic-layout/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic-layout/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic-layout/foo/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/basic-layout/foo/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/conflicting-groups/(x)/a/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/conflicting-groups/(y)/a/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/conflicting-params/[slug1]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/conflicting-params/[slug2]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/conflicting-ts-js-handlers-layout/+layout.server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/conflicting-ts-js-handlers-layout/+layout.server.ts",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/conflicting-ts-js-handlers-page/+page.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/conflicting-ts-js-handlers-page/+page.ts",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/conflicting-ts-js-handlers-server/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/conflicting-ts-js-handlers-server/+server.ts",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/custom-extension/+page.funk",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/custom-extension/about/+page.jazz",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/custom-extension/blog/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/custom-extension/blog/[slug]/+page.beebop",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/custom-extension/blog/[slug].json/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/custom-extension/blog/_default.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/custom-extension/blog.json/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/declared-layout/+layout-foo.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/encoding/[x+22]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/encoding/[x+23]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/encoding/[x+3f]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/hidden-dot/.unknown/foo.txt.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/hidden-dot/.well-known/dnt-policy.txt/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/hidden-underscore/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/hidden-underscore/_foo.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/hidden-underscore/a/_b/c/d.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/hidden-underscore/e/f/g/h/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/hidden-underscore/i/_j.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/invalid-named-layout-reference/x/+page@.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/invalid-named-layout-reference/x/+page@.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/invalid-params/[foo][bar]/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/lockfiles/foo/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/lockfiles/foo/+server.js_tmp",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/multiple-layouts/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/multiple-layouts/+layout@.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/multiple-pages/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/multiple-pages/+page@.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/multiple-slugs/[file].[ext]/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layout-missing/+page@missing.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/(special)/(alsospecial)/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/(special)/(alsospecial)/b/c/c1/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/(special)/+layout.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/(special)/+layout.server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/(special)/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/(special)/a/a2/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/+layout.svelte",
    "content": "<!-- not referenced anywhere -->\n"
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/a/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/a/a1/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/b/c/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/b/c/c2/+page@.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/b/d/(special)/(extraspecial)/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/b/d/(special)/(extraspecial)/d2/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/b/d/(special)/(extraspecial)/d3/+page@(special).svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/b/d/(special)/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/b/d/(special)/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/named-layouts/b/d/d1/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/nested-errors/foo/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/nested-errors/foo/bar/+error.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/nested-errors/foo/bar/baz/+error.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/nested-errors/foo/bar/baz/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/nested-errors/foo/bar/baz/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/nested-optionals/[[a]]/[[b]]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/optional/[[foo]]bar/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/optional/[[optional]]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/optional/nested/[[optional]]/sub/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/optional/prefix[[suffix]]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/optional-group/[[optional]]/(group)/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/page-without-svelte-file/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/page-without-svelte-file/error/+error.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/page-without-svelte-file/error/[...path]/+page.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/page-without-svelte-file/layout/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/page-without-svelte-file/layout/exists/+layout.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/page-without-svelte-file/layout/exists/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/page-without-svelte-file/layout/redirect/+page.server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/rest/a/[...rest]/+page.server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/rest/a/[...rest]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/rest/b/[...rest]/+page.server.ts",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/rest/b/[...rest]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/rest-prefix-suffix/[...rest].json/+server.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/rest-prefix-suffix/prefix-[...rest]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/symlinks/bar/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/samples/symlinks/routes/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/static/bar/baz.txt",
    "content": "some more text"
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/test/static/foo.txt",
    "content": "some text"
  },
  {
    "path": "packages/kit/src/core/sync/create_manifest_data/types.d.ts",
    "content": "import { PageNode } from 'types';\n\ninterface Part {\n\tdynamic: boolean;\n\toptional: boolean;\n\trest: boolean;\n\ttype: string | null;\n}\n\ninterface RouteTreeNode {\n\terror: PageNode | undefined;\n\tlayout: PageNode | undefined;\n}\n\nexport type RouteTree = Map<string, RouteTreeNode>;\n\ninterface RouteComponent {\n\tkind: 'component';\n\tis_page: boolean;\n\tis_layout: boolean;\n\tis_error: boolean;\n\tuses_layout: string | undefined;\n}\n\ninterface RouteSharedModule {\n\tkind: 'universal';\n\tis_page: boolean;\n\tis_layout: boolean;\n}\n\ninterface RouteServerModule {\n\tkind: 'server';\n\tis_page: boolean;\n\tis_layout: boolean;\n}\n\nexport type RouteFile = RouteComponent | RouteSharedModule | RouteServerModule;\n"
  },
  {
    "path": "packages/kit/src/core/sync/sync.js",
    "content": "import path from 'node:path';\nimport create_manifest_data from './create_manifest_data/index.js';\nimport { write_client_manifest } from './write_client_manifest.js';\nimport { write_root } from './write_root.js';\nimport { write_tsconfig } from './write_tsconfig.js';\nimport { write_types, write_all_types } from './write_types/index.js';\nimport { write_ambient } from './write_ambient.js';\nimport { write_non_ambient } from './write_non_ambient.js';\nimport { write_server } from './write_server.js';\nimport {\n\tcreate_node_analyser,\n\tget_page_options\n} from '../../exports/vite/static_analysis/index.js';\n\n/**\n * Initialize SvelteKit's generated files that only depend on the config and mode.\n * @param {import('types').ValidatedConfig} config\n * @param {string} mode\n */\nexport function init(config, mode) {\n\twrite_tsconfig(config.kit);\n\twrite_ambient(config.kit, mode);\n}\n\n/**\n * Update SvelteKit's generated files\n * @param {import('types').ValidatedConfig} config\n */\nexport function create(config) {\n\tconst manifest_data = create_manifest_data({ config });\n\n\tconst output = path.join(config.kit.outDir, 'generated');\n\n\twrite_client_manifest(config.kit, manifest_data, `${output}/client`);\n\twrite_server(config, output);\n\twrite_root(manifest_data, config, output);\n\twrite_all_types(config, manifest_data);\n\twrite_non_ambient(config.kit, manifest_data);\n\n\treturn { manifest_data };\n}\n\n/**\n * Update SvelteKit's generated files in response to a single file content update.\n * Do not call this when the file in question was created/deleted.\n *\n * @param {import('types').ValidatedConfig} config\n * @param {import('types').ManifestData} manifest_data\n * @param {string} file\n */\nexport function update(config, manifest_data, file) {\n\tconst node_analyser = create_node_analyser();\n\n\tfor (const node of manifest_data.nodes) {\n\t\tnode.page_options = node_analyser.get_page_options(node);\n\t}\n\n\tfor (const route of manifest_data.routes) {\n\t\tif (route.endpoint) {\n\t\t\troute.endpoint.page_options = get_page_options(route.endpoint.file);\n\t\t}\n\t}\n\n\twrite_types(config, manifest_data, file);\n\twrite_non_ambient(config.kit, manifest_data);\n}\n\n/**\n * Run sync.init and sync.create in series, returning the result from sync.create.\n * @param {import('types').ValidatedConfig} config\n * @param {string} mode The Vite mode\n */\nexport function all(config, mode) {\n\tinit(config, mode);\n\treturn create(config);\n}\n\n/**\n * Run sync.init and then generate all type files.\n * @param {import('types').ValidatedConfig} config\n * @param {string} mode The Vite mode\n */\nexport function all_types(config, mode) {\n\tinit(config, mode);\n\tconst manifest_data = create_manifest_data({ config });\n\twrite_all_types(config, manifest_data);\n\twrite_non_ambient(config.kit, manifest_data);\n}\n\n/**\n * Regenerate __SERVER__/internal.js in response to src/{app.html,error.html,service-worker.js} changing\n * @param {import('types').ValidatedConfig} config\n */\nexport function server(config) {\n\twrite_server(config, path.join(config.kit.outDir, 'generated'));\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/ts.js",
    "content": "/** @type {import('typescript')} */\n// @ts-ignore\nexport let ts = undefined;\ntry {\n\tts = (await import('typescript')).default;\n} catch {}\n"
  },
  {
    "path": "packages/kit/src/core/sync/utils.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { mkdirp } from '../../utils/filesystem.js';\nimport { import_peer } from '../../utils/import.js';\n\n/** @type {{ VERSION: string }} */\nconst { VERSION } = await import_peer('svelte/compiler');\n\n/** @type {Map<string, string>} */\nconst previous_contents = new Map();\n\n/**\n * @param {string} file\n * @param {string} code\n */\nexport function write_if_changed(file, code) {\n\tif (code !== previous_contents.get(file)) {\n\t\twrite(file, code);\n\t}\n}\n\n/**\n * @param {string} file\n * @param {string} code\n */\nexport function write(file, code) {\n\tprevious_contents.set(file, code);\n\tmkdirp(path.dirname(file));\n\tfs.writeFileSync(file, code);\n}\n\n/** @type {WeakMap<TemplateStringsArray, { strings: string[], indents: string[] }>} */\nconst dedent_map = new WeakMap();\n\n/**\n * Allows indenting template strings without the extra indentation ending up in the result.\n * Still allows indentation of lines relative to one another in the template string.\n * @param {TemplateStringsArray} strings\n * @param {any[]} values\n */\nexport function dedent(strings, ...values) {\n\tlet dedented = dedent_map.get(strings);\n\n\tif (!dedented) {\n\t\tconst indentation = /** @type {RegExpExecArray} */ (/\\n?([ \\t]*)/.exec(strings[0]))[1];\n\t\tconst pattern = new RegExp(`^${indentation}`, 'gm');\n\n\t\tdedented = {\n\t\t\tstrings: strings.map((str) => str.replace(pattern, '')),\n\t\t\tindents: []\n\t\t};\n\n\t\tlet current = '\\n';\n\n\t\tfor (let i = 0; i < values.length; i += 1) {\n\t\t\tconst string = dedented.strings[i];\n\t\t\tconst match = /\\n([ \\t]*)$/.exec(string);\n\n\t\t\tif (match) current = match[0];\n\t\t\tdedented.indents[i] = current;\n\t\t}\n\n\t\tdedent_map.set(strings, dedented);\n\t}\n\n\tlet str = dedented.strings[0];\n\tfor (let i = 0; i < values.length; i += 1) {\n\t\tstr += String(values[i]).replace(/\\n/g, dedented.indents[i]) + dedented.strings[i + 1];\n\t}\n\n\tstr = str.trim();\n\n\treturn str;\n}\n\nexport function isSvelte5Plus() {\n\treturn Number(VERSION[0]) >= 5;\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_ambient.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { get_env } from '../../exports/vite/utils.js';\nimport { GENERATED_COMMENT } from '../../constants.js';\nimport { create_dynamic_types, create_static_types } from '../env.js';\nimport { write_if_changed } from './utils.js';\n\n// TODO these types should be described in a neutral place, rather than\n// inside either `packages/kit` or `svelte.dev/docs/kit`\nconst descriptions_dir = fileURLToPath(new URL('../../../src/types/synthetic', import.meta.url));\n\n/** @param {string} filename */\nfunction read_description(filename) {\n\tconst content = fs.readFileSync(`${descriptions_dir}/${filename}`, 'utf8');\n\treturn `/**\\n${content\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map((line) => ` * ${line}`)\n\t\t.join('\\n')}\\n */`;\n}\n\n/**\n * @param {import('types').Env} env\n * @param {{\n * \tpublic_prefix: string;\n * \tprivate_prefix: string;\n * }} prefixes\n */\nconst template = (env, prefixes) => `\n${GENERATED_COMMENT}\n\n/// <reference types=\"@sveltejs/kit\" />\n\n${read_description('$env+static+private.md')}\n${create_static_types('private', env)}\n\n${read_description('$env+static+public.md')}\n${create_static_types('public', env)}\n\n${read_description('$env+dynamic+private.md')}\n${create_dynamic_types('private', env, prefixes)}\n\n${read_description('$env+dynamic+public.md')}\n${create_dynamic_types('public', env, prefixes)}\n`;\n\n/**\n * Writes ambient declarations including types reference to @sveltejs/kit,\n * and the existing environment variables in process.env to\n * $env/static/private and $env/static/public\n * @param {import('types').ValidatedKitConfig} config\n * @param {string} mode The Vite mode\n */\nexport function write_ambient(config, mode) {\n\tconst env = get_env(config.env, mode);\n\tconst { publicPrefix: public_prefix, privatePrefix: private_prefix } = config.env;\n\n\twrite_if_changed(\n\t\tpath.join(config.outDir, 'ambient.d.ts'),\n\t\ttemplate(env, { public_prefix, private_prefix })\n\t);\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_client_manifest.js",
    "content": "import path from 'node:path';\nimport { relative_path, resolve_entry } from '../../utils/filesystem.js';\nimport { s } from '../../utils/misc.js';\nimport { dedent, isSvelte5Plus, write_if_changed } from './utils.js';\nimport colors from 'kleur';\n\n/**\n * Writes the client manifest to disk. The manifest is used to power the router. It contains the\n * list of routes and corresponding Svelte components (i.e. pages and layouts).\n * @param {import('types').ValidatedKitConfig} kit\n * @param {import('types').ManifestData} manifest_data\n * @param {string} output\n * @param {import('types').ServerMetadata['nodes']} [metadata] If this is omitted, we have to assume that all routes with a `+layout/page.server.js` file have a server load function\n */\nexport function write_client_manifest(kit, manifest_data, output, metadata) {\n\tconst client_routing = kit.router.resolution === 'client';\n\n\t/**\n\t * Creates a module that exports a `CSRPageNode`\n\t * @param {import('types').PageNode} node\n\t */\n\tfunction generate_node(node) {\n\t\tconst declarations = [];\n\n\t\tif (node.universal) {\n\t\t\tdeclarations.push(\n\t\t\t\t`import * as universal from ${s(relative_path(`${output}/nodes`, node.universal))};`,\n\t\t\t\t'export { universal };'\n\t\t\t);\n\t\t}\n\n\t\tif (node.component) {\n\t\t\tdeclarations.push(\n\t\t\t\t`export { default as component } from ${s(\n\t\t\t\t\trelative_path(`${output}/nodes`, node.component)\n\t\t\t\t)};`\n\t\t\t);\n\t\t}\n\n\t\treturn declarations.join('\\n');\n\t}\n\n\t/** @type {Map<import('types').PageNode, number>} */\n\tconst indices = new Map();\n\tconst nodes = manifest_data.nodes\n\t\t.map((node, i) => {\n\t\t\tindices.set(node, i);\n\n\t\t\twrite_if_changed(`${output}/nodes/${i}.js`, generate_node(node));\n\t\t\treturn `() => import('./nodes/${i}')`;\n\t\t})\n\t\t// If route resolution happens on the server, we only need the root layout and root error page\n\t\t// upfront, the rest is loaded on demand as the user navigates the app\n\t\t.slice(0, client_routing ? manifest_data.nodes.length : 2)\n\t\t.join(',\\n');\n\n\tconst layouts_with_server_load = new Set();\n\n\tlet dictionary = dedent`\n\t\t{\n\t\t\t${manifest_data.routes\n\t\t\t\t.map((route) => {\n\t\t\t\t\tif (route.page) {\n\t\t\t\t\t\tconst errors = route.page.errors.slice(1).map((n) => n ?? '');\n\t\t\t\t\t\tconst layouts = route.page.layouts.slice(1).map((n) => n ?? '');\n\n\t\t\t\t\t\twhile (layouts.at(-1) === '') layouts.pop();\n\t\t\t\t\t\twhile (errors.at(-1) === '') errors.pop();\n\n\t\t\t\t\t\tlet leaf_has_server_load = false;\n\t\t\t\t\t\tif (route.leaf) {\n\t\t\t\t\t\t\tif (metadata) {\n\t\t\t\t\t\t\t\tconst i = /** @type {number} */ (indices.get(route.leaf));\n\n\t\t\t\t\t\t\t\tleaf_has_server_load = metadata[i].has_server_load;\n\t\t\t\t\t\t\t} else if (route.leaf.server) {\n\t\t\t\t\t\t\t\tleaf_has_server_load = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Encode whether or not the route uses server data\n\t\t\t\t\t\t// using the ones' complement, to save space\n\t\t\t\t\t\tconst array = [`${leaf_has_server_load ? '~' : ''}${route.page.leaf}`];\n\n\t\t\t\t\t\t// Encode whether or not the layout uses server data.\n\t\t\t\t\t\t// It's a different method compared to pages because layouts\n\t\t\t\t\t\t// are reused across pages, so we save space by doing it this way.\n\t\t\t\t\t\troute.page.layouts.forEach((layout) => {\n\t\t\t\t\t\t\tif (layout == undefined) return;\n\n\t\t\t\t\t\t\tlet layout_has_server_load = false;\n\n\t\t\t\t\t\t\tif (metadata) {\n\t\t\t\t\t\t\t\tlayout_has_server_load = metadata[layout].has_server_load;\n\t\t\t\t\t\t\t} else if (manifest_data.nodes[layout].server) {\n\t\t\t\t\t\t\t\tlayout_has_server_load = true;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (layout_has_server_load) {\n\t\t\t\t\t\t\t\tlayouts_with_server_load.add(layout);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// only include non-root layout/error nodes if they exist\n\t\t\t\t\t\tif (layouts.length > 0 || errors.length > 0) array.push(`[${layouts.join(',')}]`);\n\t\t\t\t\t\tif (errors.length > 0) array.push(`[${errors.join(',')}]`);\n\n\t\t\t\t\t\treturn `${s(route.id)}: [${array.join(',')}]`;\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(',\\n')}\n\t\t}\n\t`;\n\n\tif (!client_routing) {\n\t\tdictionary = '{}';\n\t\tconst root_layout = layouts_with_server_load.has(0);\n\t\tlayouts_with_server_load.clear();\n\t\tif (root_layout) layouts_with_server_load.add(0);\n\t}\n\n\tconst client_hooks_file = resolve_entry(kit.files.hooks.client);\n\tconst universal_hooks_file = resolve_entry(kit.files.hooks.universal);\n\n\tconst typo = resolve_entry('src/+hooks.client');\n\tif (typo) {\n\t\tconsole.log(\n\t\t\tcolors\n\t\t\t\t.bold()\n\t\t\t\t.yellow(\n\t\t\t\t\t`Unexpected + prefix. Did you mean ${typo.split('/').at(-1)?.slice(1)}?` +\n\t\t\t\t\t\t` at ${path.resolve(typo)}`\n\t\t\t\t)\n\t\t);\n\t}\n\n\t// Stringified version of\n\t/** @type {import('../../runtime/client/types.js').SvelteKitApp} */\n\twrite_if_changed(\n\t\t`${output}/app.js`,\n\t\tdedent`\n\t\t\t${\n\t\t\t\tclient_hooks_file\n\t\t\t\t\t? `import * as client_hooks from '${relative_path(output, client_hooks_file)}';`\n\t\t\t\t\t: ''\n\t\t\t}\n\t\t\t${\n\t\t\t\tuniversal_hooks_file\n\t\t\t\t\t? `import * as universal_hooks from '${relative_path(output, universal_hooks_file)}';`\n\t\t\t\t\t: ''\n\t\t\t}\n\n\t\t\t${client_routing ? \"export { matchers } from './matchers.js';\" : 'export const matchers = {};'}\n\n\t\t\texport const nodes = [\n\t\t\t\t${nodes}\n\t\t\t];\n\n\t\t\texport const server_loads = [${[...layouts_with_server_load].join(',')}];\n\n\t\t\texport const dictionary = ${dictionary};\n\n\t\t\texport const hooks = {\n\t\t\t\thandleError: ${\n\t\t\t\t\tclient_hooks_file ? 'client_hooks.handleError || ' : ''\n\t\t\t\t}(({ error }) => { console.error(error) }),\n\t\t\t\t${client_hooks_file ? 'init: client_hooks.init,' : ''}\n\t\t\t\treroute: ${universal_hooks_file ? 'universal_hooks.reroute || ' : ''}(() => {}),\n\t\t\t\ttransport: ${universal_hooks_file ? 'universal_hooks.transport || ' : ''}{}\n\t\t\t};\n\n\t\t\texport const decoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.decode]));\n\t\t\texport const encoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.encode]));\n\n\t\t\texport const hash = ${s(kit.router.type === 'hash')};\n\n\t\t\texport const decode = (type, value) => decoders[type](value);\n\n\t\t\texport { default as root } from '../root.${isSvelte5Plus() ? 'js' : 'svelte'}';\n\t\t`\n\t);\n\n\tif (client_routing) {\n\t\t// write matchers to a separate module so that we don't\n\t\t// need to worry about name conflicts\n\t\tconst imports = [];\n\t\tconst matchers = [];\n\n\t\tfor (const key in manifest_data.matchers) {\n\t\t\tconst src = manifest_data.matchers[key];\n\n\t\t\timports.push(`import { match as ${key} } from ${s(relative_path(output, src))};`);\n\t\t\tmatchers.push(key);\n\t\t}\n\n\t\tconst module = imports.length\n\t\t\t? `${imports.join('\\n')}\\n\\nexport const matchers = { ${matchers.join(', ')} };`\n\t\t\t: 'export const matchers = {};';\n\n\t\twrite_if_changed(`${output}/matchers.js`, module);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_non_ambient.js",
    "content": "import path from 'node:path';\nimport { GENERATED_COMMENT } from '../../constants.js';\nimport { posixify } from '../../utils/filesystem.js';\nimport { write_if_changed } from './utils.js';\nimport { s } from '../../utils/misc.js';\nimport { get_route_segments } from '../../utils/routing.js';\n\nconst replace_optional_params = (/** @type {string} */ id) =>\n\tid.replace(/\\/\\[\\[[^\\]]+\\]\\]/g, '${string}');\nconst replace_required_params = (/** @type {string} */ id) =>\n\tid.replace(/\\/\\[[^\\]]+\\]/g, '/${string}');\n/** Convert route ID to pathname by removing layout groups */\nconst remove_group_segments = (/** @type {string} */ id) => {\n\treturn '/' + get_route_segments(id).join('/');\n};\n\n/**\n * Get pathnames to add based on trailingSlash settings\n * @param {string} pathname\n * @param {import('types').RouteData} route\n * @returns {string[]}\n */\nfunction get_pathnames_for_trailing_slash(pathname, route) {\n\tif (pathname === '/') {\n\t\treturn [pathname];\n\t}\n\n\t/** @type {Set<string>} */\n\tconst pathnames = new Set();\n\n\t/**\n\t * @param {{ trailingSlash?: import('types').TrailingSlash } | null | undefined} page_options\n\t */\n\tconst add_pathnames = (page_options) => {\n\t\tif (page_options === null || page_options?.trailingSlash === 'ignore') {\n\t\t\tpathnames.add(pathname);\n\t\t\tpathnames.add(pathname + '/');\n\t\t} else if (page_options?.trailingSlash === 'always') {\n\t\t\tpathnames.add(pathname + '/');\n\t\t} else {\n\t\t\tpathnames.add(pathname);\n\t\t}\n\t};\n\n\tif (route.leaf) add_pathnames(route.leaf.page_options ?? null);\n\tif (route.endpoint) add_pathnames(route.endpoint.page_options);\n\n\treturn Array.from(pathnames);\n}\n\n// `declare module \"svelte/elements\"` needs to happen in a non-ambient module, and dts-buddy generates one big ambient module,\n// so we can't add it there - therefore generate the typings ourselves here.\n// We're not using the `declare namespace svelteHTML` variant because that one doesn't augment the HTMLAttributes interface\n// people could use to type their own components.\n// The T generic is needed or else there's a \"all declarations must have identical type parameters\" error.\nconst template = `\n${GENERATED_COMMENT}\n\ndeclare module \"svelte/elements\" {\n\texport interface HTMLAttributes<T> {\n\t\t'data-sveltekit-keepfocus'?: true | '' | 'off' | undefined | null;\n\t\t'data-sveltekit-noscroll'?: true | '' | 'off' | undefined | null;\n\t\t'data-sveltekit-preload-code'?:\n\t\t\t| true\n\t\t\t| ''\n\t\t\t| 'eager'\n\t\t\t| 'viewport'\n\t\t\t| 'hover'\n\t\t\t| 'tap'\n\t\t\t| 'off'\n\t\t\t| undefined\n\t\t\t| null;\n\t\t'data-sveltekit-preload-data'?: true | '' | 'hover' | 'tap' | 'off' | undefined | null;\n\t\t'data-sveltekit-reload'?: true | '' | 'off' | undefined | null;\n\t\t'data-sveltekit-replacestate'?: true | '' | 'off' | undefined | null;\n\t}\n}\n\nexport {};\n`;\n\n/**\n * Generate app types interface extension\n * @param {import('types').ManifestData} manifest_data\n * @param {import('types').ValidatedKitConfig} config\n */\nfunction generate_app_types(manifest_data, config) {\n\t/** @param {string} matcher */\n\tconst path_to_matcher = (matcher) =>\n\t\tposixify(path.relative(config.outDir, path.join(config.files.params, matcher + '.js')));\n\n\t/** @type {Map<string, string>} */\n\tconst matcher_types = new Map();\n\n\t/** @param {string | undefined} matcher */\n\tconst get_matcher_type = (matcher) => {\n\t\tif (!matcher) return 'string';\n\n\t\tlet type = matcher_types.get(matcher);\n\t\tif (!type) {\n\t\t\ttype = `MatcherParam<typeof import('${path_to_matcher(matcher)}').match>`;\n\t\t\tmatcher_types.set(matcher, type);\n\t\t}\n\n\t\treturn type;\n\t};\n\n\t/** @param {Set<string> | null} matchers */\n\tconst get_matchers_type = (matchers) => {\n\t\tif (matchers === null) return 'string';\n\n\t\treturn Array.from(matchers)\n\t\t\t.map((matcher) => get_matcher_type(matcher))\n\t\t\t.join(' | ');\n\t};\n\n\t/** @type {Set<string>} */\n\tconst route_ids = new Set(manifest_data.routes.map((route) => route.id));\n\n\t/**\n\t * @param {string} id\n\t * @returns {string[]}\n\t */\n\tconst get_ancestor_route_ids = (id) => {\n\t\t/** @type {string[]} */\n\t\tconst ancestors = [];\n\n\t\tif (route_ids.has('/')) {\n\t\t\tancestors.push('/');\n\t\t}\n\n\t\tlet current = '';\n\t\tfor (const segment of id.slice(1).split('/')) {\n\t\t\tif (!segment) continue;\n\n\t\t\tcurrent += '/' + segment;\n\t\t\tif (route_ids.has(current)) {\n\t\t\t\tancestors.push(current);\n\t\t\t}\n\t\t}\n\n\t\treturn ancestors;\n\t};\n\n\t/** @type {Set<string>} */\n\tconst pathnames = new Set();\n\n\t/** @type {string[]} */\n\tconst dynamic_routes = [];\n\n\t/** @type {string[]} */\n\tconst layouts = [];\n\n\t/** @type {Map<string, Map<string, { optional: boolean, matchers: Set<string> | null }>>} */\n\tconst layout_params_by_route = new Map(\n\t\tmanifest_data.routes.map((route) => [\n\t\t\troute.id,\n\t\t\tnew Map(\n\t\t\t\troute.params.map((p) => [\n\t\t\t\t\tp.name,\n\t\t\t\t\t{ optional: p.optional, matchers: p.matcher ? new Set([p.matcher]) : null }\n\t\t\t\t])\n\t\t\t)\n\t\t])\n\t);\n\n\tfor (const route of manifest_data.routes) {\n\t\tconst ancestors = get_ancestor_route_ids(route.id);\n\n\t\tfor (const ancestor_id of ancestors) {\n\t\t\tconst ancestor_params = layout_params_by_route.get(ancestor_id);\n\t\t\tif (!ancestor_params) continue;\n\n\t\t\tfor (const p of route.params) {\n\t\t\t\tconst matcher = p.matcher ?? null;\n\t\t\t\tconst entry = ancestor_params.get(p.name);\n\t\t\t\tif (!entry) {\n\t\t\t\t\tancestor_params.set(p.name, {\n\t\t\t\t\t\toptional: true,\n\t\t\t\t\t\tmatchers: matcher === null ? null : new Set([matcher])\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (entry.matchers === null) continue;\n\n\t\t\t\tif (matcher === null) {\n\t\t\t\t\tentry.matchers = null;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tentry.matchers.add(matcher);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const route of manifest_data.routes) {\n\t\tconst pathname = remove_group_segments(route.id);\n\t\tlet normalized_pathname = pathname;\n\n\t\t/** @type {(path: string) => string} */\n\t\tlet serialise = s;\n\n\t\tif (route.params.length > 0) {\n\t\t\tconst params = route.params.map((p) => {\n\t\t\t\tconst type = get_matcher_type(p.matcher);\n\t\t\t\treturn `${p.name}${p.optional ? '?:' : ':'} ${type}`;\n\t\t\t});\n\t\t\tconst route_type = `${s(route.id)}: { ${params.join('; ')} }`;\n\n\t\t\tdynamic_routes.push(route_type);\n\n\t\t\tnormalized_pathname = replace_required_params(replace_optional_params(pathname));\n\t\t\tserialise = (p) => `\\`${p}\\` & {}`;\n\t\t}\n\n\t\tfor (const p of get_pathnames_for_trailing_slash(normalized_pathname, route)) {\n\t\t\tpathnames.add(serialise(p));\n\t\t}\n\n\t\tlet layout_type = 'Record<string, never>';\n\n\t\tconst layout_params = layout_params_by_route.get(route.id);\n\t\tif (layout_params) {\n\t\t\tconst params = Array.from(layout_params)\n\t\t\t\t.map(([name, { optional, matchers }]) => {\n\t\t\t\t\tconst type = get_matchers_type(matchers);\n\t\t\t\t\treturn `${name}${optional ? '?:' : ':'} ${type}`;\n\t\t\t\t})\n\t\t\t\t.join('; ');\n\n\t\t\tif (params.length > 0) layout_type = `{ ${params} }`;\n\t\t}\n\n\t\tlayouts.push(`${s(route.id)}: ${layout_type}`);\n\t}\n\n\tconst assets = manifest_data.assets.map((asset) => s('/' + asset.file));\n\n\treturn [\n\t\t'declare module \"$app/types\" {',\n\t\t'\\ttype MatcherParam<M> = M extends (param : string) => param is (infer U extends string) ? U : string;',\n\t\t'',\n\t\t'\\texport interface AppTypes {',\n\t\t`\\t\\tRouteId(): ${manifest_data.routes.map((r) => s(r.id)).join(' | ')};`,\n\t\t`\\t\\tRouteParams(): {\\n\\t\\t\\t${dynamic_routes.join(';\\n\\t\\t\\t')}\\n\\t\\t};`,\n\t\t`\\t\\tLayoutParams(): {\\n\\t\\t\\t${layouts.join(';\\n\\t\\t\\t')}\\n\\t\\t};`,\n\t\t`\\t\\tPathname(): ${Array.from(pathnames).join(' | ')};`,\n\t\t'\\t\\tResolvedPathname(): `${\"\" | `/${string}`}${ReturnType<AppTypes[\\'Pathname\\']>}`;',\n\t\t`\\t\\tAsset(): ${assets.concat('string & {}').join(' | ')};`,\n\t\t'\\t}',\n\t\t'}'\n\t].join('\\n');\n}\n\n/**\n * Writes non-ambient declarations to the output directory\n * @param {import('types').ValidatedKitConfig} config\n * @param {import('types').ManifestData} manifest_data\n */\nexport function write_non_ambient(config, manifest_data) {\n\tconst app_types = generate_app_types(manifest_data, config);\n\tconst content = [template, app_types].join('\\n\\n');\n\n\twrite_if_changed(path.join(config.outDir, 'non-ambient.d.ts'), content);\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_root.js",
    "content": "import { dedent, isSvelte5Plus, write_if_changed } from './utils.js';\n\n/**\n * @param {import('types').ManifestData} manifest_data\n * @param {import('types').ValidatedConfig} config\n * @param {string} output\n */\nexport function write_root(manifest_data, config, output) {\n\t// TODO remove default layout altogether\n\n\tconst use_boundaries = config.kit.experimental.handleRenderingErrors && isSvelte5Plus();\n\n\tconst max_depth = Math.max(\n\t\t...manifest_data.routes.map((route) =>\n\t\t\troute.page ? route.page.layouts.filter(Boolean).length + 1 : 0\n\t\t),\n\t\t1\n\t);\n\n\tconst levels = [];\n\tfor (let i = 0; i <= max_depth; i += 1) {\n\t\tlevels.push(i);\n\t}\n\n\tlet l = max_depth;\n\t/** @type {string} */\n\tlet pyramid;\n\n\tif (isSvelte5Plus() && use_boundaries) {\n\t\t// with the @const we force the data[depth] access to be derived, which is important to not fire updates needlessly\n\t\t// TODO in Svelte 5 we should rethink the client.js side, we can likely make data a $state and only update indexes that changed there, simplifying this a lot\n\t\tpyramid = dedent`\n\t\t\t{#snippet pyramid(depth)}\n\t\t\t\t{@const Pyramid = constructors[depth]}\n\t\t\t\t{#snippet failed(error)}\n\t\t\t\t\t{@const ErrorPage = errors[depth]}\n\t\t\t\t\t<ErrorPage {error} />\n\t\t\t\t{/snippet}\n\t\t\t\t<svelte:boundary failed={errors[depth] ? failed : undefined}>\n\t\t\t\t\t{#if constructors[depth + 1]}\n\t\t\t\t\t\t{@const d = data[depth]}\n\t\t\t\t\t\t<!-- svelte-ignore binding_property_non_reactive -->\n\t\t\t\t\t\t<Pyramid bind:this={components[depth]} data={d} {form} params={page.params}>\n\t\t\t\t\t\t\t{@render pyramid(depth + 1)}\n\t\t\t\t\t\t</Pyramid>\n\t\t\t\t\t{:else}\n\t\t\t\t\t\t{@const d = data[depth]}\n\t\t\t\t\t\t<!-- svelte-ignore binding_property_non_reactive -->\n\t\t\t\t\t\t<Pyramid bind:this={components[depth]} data={d} {form} params={page.params} {error} />\n\t\t\t\t\t{/if}\n\t\t\t\t</svelte:boundary>\n\t\t\t{/snippet}\n\n\t\t\t{@render pyramid(0)}\n\t\t`;\n\t} else {\n\t\tpyramid = dedent`\n\t${\n\t\tisSvelte5Plus()\n\t\t\t? `<!-- svelte-ignore binding_property_non_reactive -->\n\t\t<Pyramid_${l} bind:this={components[${l}]} data={data_${l}} {form} params={page.params} />`\n\t\t\t: `<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} {form} params={page.params} />`\n\t}`;\n\n\t\twhile (l--) {\n\t\t\tpyramid = dedent`\n\t\t\t{#if constructors[${l + 1}]}\n\t\t\t\t${\n\t\t\t\t\tisSvelte5Plus()\n\t\t\t\t\t\t? dedent`{@const Pyramid_${l} = constructors[${l}]}\n\t\t\t\t\t\t<!-- svelte-ignore binding_property_non_reactive -->\n\t\t\t\t\t\t<Pyramid_${l} bind:this={components[${l}]} data={data_${l}} {form} params={page.params}>\n\t\t\t\t\t\t\t${pyramid}\n\t\t\t\t\t\t</Pyramid_${l}>`\n\t\t\t\t\t\t: dedent`<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} params={page.params}>\n\t\t\t\t\t${pyramid}\n\t\t\t\t</svelte:component>`\n\t\t\t\t}\n\n\t\t\t{:else}\n\t\t\t\t${\n\t\t\t\t\tisSvelte5Plus()\n\t\t\t\t\t\t? dedent`\n\t\t\t\t\t{@const Pyramid_${l} = constructors[${l}]}\n\t\t\t\t\t<!-- svelte-ignore binding_property_non_reactive -->\n\t\t\t\t\t<Pyramid_${l} bind:this={components[${l}]} data={data_${l}} {form} params={page.params} />\n\t\t\t\t\t`\n\t\t\t\t\t\t: dedent`<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} {form} params={page.params} />`\n\t\t\t\t}\n\n\t\t\t{/if}\n\t\t`;\n\t\t}\n\t}\n\n\twrite_if_changed(\n\t\t`${output}/root.svelte`,\n\t\tdedent`\n\t\t\t<!-- This file is generated by @sveltejs/kit — do not edit it! -->\n\t\t\t${isSvelte5Plus() ? '<svelte:options runes={true} />' : ''}\n\t\t\t<script>\n\t\t\t\timport { setContext, ${isSvelte5Plus() ? '' : 'afterUpdate, '}onMount, tick } from 'svelte';\n\t\t\t\timport { browser } from '$app/environment';\n\n\t\t\t\t// stores\n\t\t\t\t${\n\t\t\t\t\tisSvelte5Plus()\n\t\t\t\t\t\t? dedent`\n\t\t\t\t\t\t\tlet { stores, page, constructors, components = [], form, ${use_boundaries ? 'errors = [], error, ' : ''}${levels\n\t\t\t\t\t\t\t\t.map((l) => `data_${l} = null`)\n\t\t\t\t\t\t\t\t.join(', ')} } = $props();\n\t\t\t\t\t\t\t${use_boundaries ? `let data = $derived({${levels.map((l) => `'${l}': data_${l}`).join(', ')}})` : ''}\n\t\t\t\t\t\t`\n\t\t\t\t\t\t: dedent`\n\t\t\t\t\t\t\texport let stores;\n\t\t\t\t\t\t\texport let page;\n\n\t\t\t\t\t\t\texport let constructors;\n\t\t\t\t\t\t\texport let components = [];\n\t\t\t\t\t\t\texport let form;\n\t\t\t\t\t\t\t${levels.map((l) => `export let data_${l} = null;`).join('\\n')}\n\t\t\t\t\t\t`\n\t\t\t\t}\n\n\t\t\t\tif (!browser) {\n\t\t\t\t\t// svelte-ignore state_referenced_locally\n\t\t\t\t\tsetContext('__svelte__', stores);\n\t\t\t\t}\n\n\t\t\t\t${\n\t\t\t\t\tisSvelte5Plus()\n\t\t\t\t\t\t? dedent`\n\t\t\t\t\t\t\tif (browser) {\n\t\t\t\t\t\t\t\t$effect.pre(() => stores.page.set(page));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// svelte-ignore state_referenced_locally\n\t\t\t\t\t\t\t\tstores.page.set(page);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t`\n\t\t\t\t\t\t: '$: stores.page.set(page);'\n\t\t\t\t}\n\t\t\t\t${\n\t\t\t\t\tisSvelte5Plus()\n\t\t\t\t\t\t? dedent`\n\t\t\t\t\t\t\t$effect(() => {\n\t\t\t\t\t\t\t\tstores;page;constructors;components;form;${use_boundaries ? 'errors;error;' : ''}${levels.map((l) => `data_${l}`).join(';')};\n\t\t\t\t\t\t\t\tstores.page.notify();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t`\n\t\t\t\t\t\t: 'afterUpdate(stores.page.notify);'\n\t\t\t\t}\n\n\t\t\t\tlet mounted = ${isSvelte5Plus() ? '$state(false)' : 'false'};\n\t\t\t\tlet navigated = ${isSvelte5Plus() ? '$state(false)' : 'false'};\n\t\t\t\tlet title = ${isSvelte5Plus() ? '$state(null)' : 'null'};\n\n\t\t\t\tonMount(() => {\n\t\t\t\t\tconst unsubscribe = stores.page.subscribe(() => {\n\t\t\t\t\t\tif (mounted) {\n\t\t\t\t\t\t\tnavigated = true;\n\t\t\t\t\t\t\ttick().then(() => {\n\t\t\t\t\t\t\t\ttitle = document.title || 'untitled page';\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tmounted = true;\n\t\t\t\t\treturn unsubscribe;\n\t\t\t\t});\n\n\t\t\t\t${isSvelte5Plus() ? `const Pyramid_${max_depth}=$derived(constructors[${max_depth}])` : ''}\n\t\t\t</script>\n\n\t\t\t${pyramid}\n\n\t\t\t{#if mounted}\n\t\t\t\t<div id=\"svelte-announcer\" aria-live=\"assertive\" aria-atomic=\"true\" style=\"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px\">\n\t\t\t\t\t{#if navigated}\n\t\t\t\t\t\t{title}\n\t\t\t\t\t{/if}\n\t\t\t\t</div>\n\t\t\t{/if}\n\t\t`\n\t);\n\n\tif (isSvelte5Plus()) {\n\t\twrite_if_changed(\n\t\t\t`${output}/root.js`,\n\t\t\tdedent`\n\t\t\timport { asClassComponent } from 'svelte/legacy';\n\t\t\timport Root from './root.svelte';\n\t\t\texport default asClassComponent(Root);\n\t\t`\n\t\t);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_server.js",
    "content": "import path from 'node:path';\nimport process from 'node:process';\nimport { hash } from '../../utils/hash.js';\nimport { posixify, resolve_entry } from '../../utils/filesystem.js';\nimport { s } from '../../utils/misc.js';\nimport { load_error_page, load_template } from '../config/index.js';\nimport { runtime_directory } from '../utils.js';\nimport { isSvelte5Plus, write_if_changed } from './utils.js';\nimport colors from 'kleur';\nimport { escape_html } from '../../utils/escape.js';\n\n/**\n * @param {{\n *   server_hooks: string | null;\n *   universal_hooks: string | null;\n *   config: import('types').ValidatedConfig;\n *   has_service_worker: boolean;\n *   runtime_directory: string;\n *   template: string;\n *   error_page: string;\n * }} opts\n */\nconst server_template = ({\n\tconfig,\n\tserver_hooks,\n\tuniversal_hooks,\n\thas_service_worker,\n\truntime_directory,\n\ttemplate,\n\terror_page\n}) => `\nimport root from '../root.${isSvelte5Plus() ? 'js' : 'svelte'}';\nimport { set_building, set_prerendering } from '__sveltekit/environment';\nimport { set_assets } from '$app/paths/internal/server';\nimport { set_manifest, set_read_implementation } from '__sveltekit/server';\nimport { set_private_env, set_public_env } from '${runtime_directory}/shared-server.js';\n\nexport const options = {\n\tapp_template_contains_nonce: ${template.includes('%sveltekit.nonce%')},\n\tasync: ${s(!!config.compilerOptions?.experimental?.async)},\n\tcsp: ${s(config.kit.csp)},\n\tcsrf_check_origin: ${s(config.kit.csrf.checkOrigin && !config.kit.csrf.trustedOrigins.includes('*'))},\n\tcsrf_trusted_origins: ${s(config.kit.csrf.trustedOrigins)},\n\tembedded: ${config.kit.embedded},\n\tenv_public_prefix: '${config.kit.env.publicPrefix}',\n\tenv_private_prefix: '${config.kit.env.privatePrefix}',\n\thash_routing: ${s(config.kit.router.type === 'hash')},\n\thooks: null, // added lazily, via \\`get_hooks\\`\n\tpreload_strategy: ${s(config.kit.output.preloadStrategy)},\n\troot,\n\tservice_worker: ${has_service_worker},\n\tservice_worker_options: ${config.kit.serviceWorker.register ? s(config.kit.serviceWorker.options) : 'null'},\n\tserver_error_boundaries: ${s(!!config.kit.experimental.handleRenderingErrors)},\n\ttemplates: {\n\t\tapp: ({ head, body, assets, nonce, env }) => ${s(template)\n\t\t\t.replace('%sveltekit.head%', '\" + head + \"')\n\t\t\t.replace('%sveltekit.body%', '\" + body + \"')\n\t\t\t.replace(/%sveltekit\\.assets%/g, '\" + assets + \"')\n\t\t\t.replace(/%sveltekit\\.nonce%/g, '\" + nonce + \"')\n\t\t\t.replace(/%sveltekit\\.version%/g, escape_html(config.kit.version.name))\n\t\t\t.replace(\n\t\t\t\t/%sveltekit\\.env\\.([^%]+)%/g,\n\t\t\t\t(_match, capture) => `\" + (env[${s(capture)}] ?? \"\") + \"`\n\t\t\t)},\n\t\terror: ({ status, message }) => ${s(error_page)\n\t\t\t.replace(/%sveltekit\\.status%/g, '\" + status + \"')\n\t\t\t.replace(/%sveltekit\\.error\\.message%/g, '\" + message + \"')}\n\t},\n\tversion_hash: ${s(hash(config.kit.version.name))}\n};\n\nexport async function get_hooks() {\n\tlet handle;\n\tlet handleFetch;\n\tlet handleError;\n\tlet handleValidationError;\n\tlet init;\n\t${server_hooks ? `({ handle, handleFetch, handleError, handleValidationError, init } = await import(${s(server_hooks)}));` : ''}\n\n\tlet reroute;\n\tlet transport;\n\t${universal_hooks ? `({ reroute, transport } = await import(${s(universal_hooks)}));` : ''}\n\n\treturn {\n\t\thandle,\n\t\thandleFetch,\n\t\thandleError,\n\t\thandleValidationError,\n\t\tinit,\n\t\treroute,\n\t\ttransport\n\t};\n}\n\nexport { set_assets, set_building, set_manifest, set_prerendering, set_private_env, set_public_env, set_read_implementation };\n`;\n\n// TODO need to re-run this whenever src/app.html or src/error.html are\n// created or changed, or src/service-worker.js is created or deleted.\n// Also, need to check that updating hooks.server.js works\n\n/**\n * Write server configuration to disk\n * @param {import('types').ValidatedConfig} config\n * @param {string} output\n */\nexport function write_server(config, output) {\n\tconst server_hooks_file = resolve_entry(config.kit.files.hooks.server);\n\tconst universal_hooks_file = resolve_entry(config.kit.files.hooks.universal);\n\n\tconst typo = resolve_entry('src/+hooks.server');\n\tif (typo) {\n\t\tconsole.log(\n\t\t\tcolors\n\t\t\t\t.bold()\n\t\t\t\t.yellow(\n\t\t\t\t\t`Unexpected + prefix. Did you mean ${typo.split('/').at(-1)?.slice(1)}?` +\n\t\t\t\t\t\t` at ${path.resolve(typo)}`\n\t\t\t\t)\n\t\t);\n\t}\n\n\t/** @param {string} file */\n\tfunction relative(file) {\n\t\treturn posixify(path.relative(`${output}/server`, file));\n\t}\n\n\t// Contains the stringified version of\n\t/** @type {import('types').SSROptions} */\n\twrite_if_changed(\n\t\t`${output}/server/internal.js`,\n\t\tserver_template({\n\t\t\tconfig,\n\t\t\tserver_hooks: server_hooks_file ? relative(server_hooks_file) : null,\n\t\t\tuniversal_hooks: universal_hooks_file ? relative(universal_hooks_file) : null,\n\t\t\thas_service_worker:\n\t\t\t\tconfig.kit.serviceWorker.register && !!resolve_entry(config.kit.files.serviceWorker),\n\t\t\truntime_directory: relative(runtime_directory),\n\t\t\ttemplate: load_template(process.cwd(), config),\n\t\t\terror_page: load_error_page(config)\n\t\t})\n\t);\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_tsconfig.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport colors from 'kleur';\nimport { posixify } from '../../utils/filesystem.js';\nimport { write_if_changed } from './utils.js';\n\n/**\n * @param {string} cwd\n * @param {string} file\n */\nfunction maybe_file(cwd, file) {\n\tconst resolved = path.resolve(cwd, file);\n\tif (fs.existsSync(resolved)) {\n\t\treturn resolved;\n\t}\n}\n\n/**\n * @param {string} file\n */\nfunction project_relative(file) {\n\treturn posixify(path.relative('.', file));\n}\n\n/**\n * @param {string} file\n */\nfunction remove_trailing_slashstar(file) {\n\tif (file.endsWith('/*')) {\n\t\treturn file.slice(0, -2);\n\t} else {\n\t\treturn file;\n\t}\n}\n\n/**\n * Generates the tsconfig that the user's tsconfig inherits from.\n * @param {import('types').ValidatedKitConfig} kit\n */\nexport function write_tsconfig(kit, cwd = process.cwd()) {\n\tconst out = path.join(kit.outDir, 'tsconfig.json');\n\n\tconst user_config = load_user_tsconfig(cwd);\n\tif (user_config) validate_user_config(cwd, out, user_config);\n\n\twrite_if_changed(out, JSON.stringify(get_tsconfig(kit), null, '\\t'));\n}\n\n/**\n * Generates the tsconfig that the user's tsconfig inherits from.\n * @param {import('types').ValidatedKitConfig} kit\n */\nexport function get_tsconfig(kit) {\n\t/** @param {string} file */\n\tconst config_relative = (file) => posixify(path.relative(kit.outDir, file));\n\n\tconst include = new Set([\n\t\t'ambient.d.ts', // careful: changing this name would be a breaking change, because it's referenced in the service-workers documentation\n\t\t'non-ambient.d.ts',\n\t\t'./types/**/$types.d.ts',\n\t\tconfig_relative('vite.config.js'),\n\t\tconfig_relative('vite.config.ts')\n\t]);\n\tconst src_includes = [kit.files.routes, kit.files.lib, kit.files.src].filter((dir) => {\n\t\tconst relative = path.relative(kit.files.src, dir);\n\t\treturn !relative || relative.startsWith('..');\n\t});\n\tfor (const dir of src_includes) {\n\t\tinclude.add(config_relative(`${dir}/**/*.js`));\n\t\tinclude.add(config_relative(`${dir}/**/*.ts`));\n\t\tinclude.add(config_relative(`${dir}/**/*.svelte`));\n\t}\n\n\t// Test folder is a special case - we advocate putting tests in a top-level test folder\n\t// and it's not configurable (should we make it?)\n\tconst test_folder = project_relative('test');\n\tinclude.add(config_relative(`${test_folder}/**/*.js`));\n\tinclude.add(config_relative(`${test_folder}/**/*.ts`));\n\tinclude.add(config_relative(`${test_folder}/**/*.svelte`));\n\tconst tests_folder = project_relative('tests');\n\tinclude.add(config_relative(`${tests_folder}/**/*.js`));\n\tinclude.add(config_relative(`${tests_folder}/**/*.ts`));\n\tinclude.add(config_relative(`${tests_folder}/**/*.svelte`));\n\n\tconst exclude = [config_relative('node_modules/**')];\n\t// Add service worker to exclude list so that worker types references in it don't spill over into the rest of the app\n\t// (i.e. suddenly ServiceWorkerGlobalScope would be available throughout the app, and some types might even clash)\n\tif (path.extname(kit.files.serviceWorker)) {\n\t\texclude.push(config_relative(kit.files.serviceWorker));\n\t} else {\n\t\texclude.push(config_relative(`${kit.files.serviceWorker}.js`));\n\t\texclude.push(config_relative(`${kit.files.serviceWorker}/**/*.js`));\n\t\texclude.push(config_relative(`${kit.files.serviceWorker}.ts`));\n\t\texclude.push(config_relative(`${kit.files.serviceWorker}/**/*.ts`));\n\t\texclude.push(config_relative(`${kit.files.serviceWorker}.d.ts`));\n\t\texclude.push(config_relative(`${kit.files.serviceWorker}/**/*.d.ts`));\n\t}\n\n\tconst config = {\n\t\tcompilerOptions: {\n\t\t\t// generated options\n\t\t\tpaths: {\n\t\t\t\t...get_tsconfig_paths(kit),\n\t\t\t\t'$app/types': ['./types/index.d.ts']\n\t\t\t},\n\t\t\trootDirs: [config_relative('.'), './types'],\n\n\t\t\t// essential options\n\t\t\t// svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript\n\t\t\t// to enforce using \\`import type\\` instead of \\`import\\` for Types.\n\t\t\t// Also, TypeScript doesn't know about import usages in the template because it only sees the\n\t\t\t// script of a Svelte file. Therefore preserve all value imports.\n\t\t\tverbatimModuleSyntax: true,\n\t\t\t// Vite compiles modules one at a time\n\t\t\tisolatedModules: true,\n\n\t\t\t// This is required for svelte-package to work as expected\n\t\t\t// Can be overwritten\n\t\t\tlib: ['esnext', 'DOM', 'DOM.Iterable'],\n\t\t\tmoduleResolution: 'bundler',\n\t\t\tmodule: 'esnext',\n\t\t\tnoEmit: true, // prevent tsconfig error \"overwriting input files\" - Vite handles the build and ignores this\n\t\t\ttarget: 'esnext'\n\t\t},\n\t\tinclude: [...include],\n\t\texclude\n\t};\n\n\treturn kit.typescript.config(config) ?? config;\n}\n\n/** @param {string} cwd */\nfunction load_user_tsconfig(cwd) {\n\tconst file = maybe_file(cwd, 'tsconfig.json') || maybe_file(cwd, 'jsconfig.json');\n\n\tif (!file) return;\n\n\t// we have to eval the file, since it's not parseable as JSON (contains comments)\n\tconst json = fs.readFileSync(file, 'utf-8');\n\n\treturn {\n\t\tkind: path.basename(file),\n\t\toptions: (0, eval)(`(${json})`)\n\t};\n}\n\n/**\n * @param {string} cwd\n * @param {string} out\n * @param {{ kind: string, options: any }} config\n */\nfunction validate_user_config(cwd, out, config) {\n\t// we need to check that the user's tsconfig extends the framework config\n\tconst extend = config.options.extends;\n\tconst extends_framework_config =\n\t\ttypeof extend === 'string'\n\t\t\t? path.resolve(cwd, extend) === out\n\t\t\t: Array.isArray(extend)\n\t\t\t\t? extend.some((e) => path.resolve(cwd, e) === out)\n\t\t\t\t: false;\n\n\tconst options = config.options.compilerOptions || {};\n\n\tif (extends_framework_config) {\n\t\tconst { paths, baseUrl } = options;\n\n\t\tif (baseUrl || paths) {\n\t\t\tconsole.warn(\n\t\t\t\tcolors\n\t\t\t\t\t.bold()\n\t\t\t\t\t.yellow(\n\t\t\t\t\t\t`You have specified a baseUrl and/or paths in your ${config.kind} which interferes with SvelteKit's auto-generated tsconfig.json. ` +\n\t\t\t\t\t\t\t'Remove it to avoid problems with intellisense. For path aliases, use `kit.alias` instead: https://svelte.dev/docs/kit/configuration#alias'\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} else {\n\t\tlet relative = posixify(path.relative('.', out));\n\t\tif (!relative.startsWith('./')) relative = './' + relative;\n\n\t\tconsole.warn(\n\t\t\tcolors\n\t\t\t\t.bold()\n\t\t\t\t.yellow(`Your ${config.kind} should extend the configuration generated by SvelteKit:`)\n\t\t);\n\t\tconsole.warn(`{\\n  \"extends\": \"${relative}\"\\n}`);\n\t}\n}\n\n// <something><optional /*>\nconst alias_regex = /^(.+?)(\\/\\*)?$/;\n// <path><optional /* or .fileending>\nconst value_regex = /^(.*?)((\\/\\*)|(\\.\\w+))?$/;\n\n/**\n * Generates tsconfig path aliases from kit's aliases.\n * Related to vite alias creation.\n *\n * @param {import('types').ValidatedKitConfig} config\n */\nfunction get_tsconfig_paths(config) {\n\t/** @param {string} file */\n\tconst config_relative = (file) => {\n\t\tlet relative_path = path.relative(config.outDir, file);\n\t\tif (!relative_path.startsWith('..')) {\n\t\t\trelative_path = './' + relative_path;\n\t\t}\n\t\treturn posixify(relative_path);\n\t};\n\n\tconst alias = { ...config.alias };\n\tif (fs.existsSync(project_relative(config.files.lib))) {\n\t\talias['$lib'] = project_relative(config.files.lib);\n\t}\n\n\t/** @type {Record<string, string[]>} */\n\tconst paths = {};\n\n\tfor (const [key, value] of Object.entries(alias)) {\n\t\tconst key_match = alias_regex.exec(key);\n\t\tif (!key_match) throw new Error(`Invalid alias key: ${key}`);\n\n\t\tconst value_match = value_regex.exec(value);\n\t\tif (!value_match) throw new Error(`Invalid alias value: ${value}`);\n\n\t\tconst rel_path = config_relative(remove_trailing_slashstar(value));\n\t\tconst slashstar = key_match[2];\n\n\t\tif (slashstar) {\n\t\t\tpaths[key] = [rel_path + '/*'];\n\t\t} else {\n\t\t\tpaths[key] = [rel_path];\n\t\t\tconst fileending = value_match[4];\n\n\t\t\tif (!fileending && !(key + '/*' in alias)) {\n\t\t\t\tpaths[key + '/*'] = [rel_path + '/*'];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn paths;\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_tsconfig.spec.js",
    "content": "import { assert, expect, test } from 'vitest';\nimport { validate_config } from '../config/index.js';\nimport { get_tsconfig } from './write_tsconfig.js';\n\ntest('Creates tsconfig path aliases from kit.alias', () => {\n\tconst { kit } = validate_config({\n\t\tkit: {\n\t\t\talias: {\n\t\t\t\tsimpleKey: 'simple/value',\n\t\t\t\tkey: 'value',\n\t\t\t\t'key/*': 'some/other/value/*',\n\t\t\t\tkeyToFile: 'path/to/file.ts',\n\t\t\t\t$routes: '.svelte-kit/types/src/routes'\n\t\t\t}\n\t\t}\n\t});\n\n\tconst { compilerOptions } = get_tsconfig(kit);\n\n\t// $lib isn't part of the outcome because there's a \"path exists\"\n\t// check in the implementation\n\texpect(compilerOptions.paths).toEqual({\n\t\t'$app/types': ['./types/index.d.ts'],\n\t\tsimpleKey: ['../simple/value'],\n\t\t'simpleKey/*': ['../simple/value/*'],\n\t\tkey: ['../value'],\n\t\t'key/*': ['../some/other/value/*'],\n\t\tkeyToFile: ['../path/to/file.ts'],\n\t\t$routes: ['./types/src/routes'],\n\t\t'$routes/*': ['./types/src/routes/*']\n\t});\n});\n\ntest('Allows generated tsconfig to be mutated', () => {\n\tconst { kit } = validate_config({\n\t\tkit: {\n\t\t\ttypescript: {\n\t\t\t\tconfig: (config) => {\n\t\t\t\t\tconfig.extends = 'some/other/tsconfig.json';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tconst config = get_tsconfig(kit);\n\n\t// @ts-expect-error\n\tassert.equal(config.extends, 'some/other/tsconfig.json');\n});\n\ntest('Allows generated tsconfig to be replaced', () => {\n\tconst { kit } = validate_config({\n\t\tkit: {\n\t\t\ttypescript: {\n\t\t\t\tconfig: (config) => ({\n\t\t\t\t\t...config,\n\t\t\t\t\textends: 'some/other/tsconfig.json'\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t});\n\n\tconst config = get_tsconfig(kit);\n\n\t// @ts-expect-error\n\tassert.equal(config.extends, 'some/other/tsconfig.json');\n});\n\ntest('Creates tsconfig include from kit.files', () => {\n\tconst { kit } = validate_config({\n\t\tkit: {\n\t\t\tfiles: {\n\t\t\t\tlib: 'app'\n\t\t\t}\n\t\t}\n\t});\n\n\tconst { include } = get_tsconfig(kit);\n\n\texpect(include).toEqual([\n\t\t'ambient.d.ts',\n\t\t'non-ambient.d.ts',\n\t\t'./types/**/$types.d.ts',\n\t\t'../vite.config.js',\n\t\t'../vite.config.ts',\n\t\t'../app/**/*.js',\n\t\t'../app/**/*.ts',\n\t\t'../app/**/*.svelte',\n\t\t'../src/**/*.js',\n\t\t'../src/**/*.ts',\n\t\t'../src/**/*.svelte',\n\t\t'../test/**/*.js',\n\t\t'../test/**/*.ts',\n\t\t'../test/**/*.svelte',\n\t\t'../tests/**/*.js',\n\t\t'../tests/**/*.ts',\n\t\t'../tests/**/*.svelte'\n\t]);\n});\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/index.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport MagicString from 'magic-string';\nimport { posixify, rimraf, walk } from '../../../utils/filesystem.js';\nimport { compact } from '../../../utils/array.js';\nimport { ts } from '../ts.js';\nconst remove_relative_parent_traversals = (/** @type {string} */ path) =>\n\tpath.replace(/\\.\\.\\//g, '');\nconst is_whitespace = (/** @type {string} */ char) => /\\s/.test(char);\n\n/**\n *  @typedef {{\n *   file_name: string;\n *   modified: boolean;\n *   code: string;\n *   exports: any[];\n *  } | null} Proxy\n *\n *  @typedef {{\n *   server: Proxy,\n *   universal: Proxy\n *  }} Proxies\n *\n *  @typedef {Map<import('types').PageNode, {route: import('types').RouteData, proxies: Proxies}>} RoutesMap\n */\n\nconst cwd = process.cwd();\n\n/**\n * Creates types for the whole manifest\n * @param {import('types').ValidatedConfig} config\n * @param {import('types').ManifestData} manifest_data\n */\nexport function write_all_types(config, manifest_data) {\n\tif (!ts) return;\n\n\tconst types_dir = `${config.kit.outDir}/types`;\n\n\t// empty out files that no longer need to exist\n\tconst routes_dir = remove_relative_parent_traversals(\n\t\tposixify(path.relative('.', config.kit.files.routes))\n\t);\n\tconst expected_directories = new Set(\n\t\tmanifest_data.routes.map((route) => path.join(routes_dir, route.id))\n\t);\n\n\tif (fs.existsSync(types_dir)) {\n\t\tfor (const file of walk(types_dir)) {\n\t\t\tconst dir = path.dirname(file);\n\t\t\tif (!expected_directories.has(dir)) {\n\t\t\t\trimraf(path.join(types_dir, file));\n\t\t\t}\n\t\t}\n\t}\n\n\t// Read/write meta data on each invocation, not once per node process,\n\t// it could be invoked by another process in the meantime.\n\tconst meta_data_file = `${types_dir}/route_meta_data.json`;\n\tconst has_meta_data = fs.existsSync(meta_data_file);\n\tconst meta_data = has_meta_data\n\t\t? /** @type {Record<string, string[]>} */ (JSON.parse(fs.readFileSync(meta_data_file, 'utf-8')))\n\t\t: {};\n\tconst routes_map = create_routes_map(manifest_data);\n\t// For each directory, write $types.d.ts\n\tfor (const route of manifest_data.routes) {\n\t\tif (!route.leaf && !route.layout && !route.endpoint) continue; // nothing to do\n\n\t\tconst outdir = path.join(config.kit.outDir, 'types', routes_dir, route.id);\n\n\t\t// check if the types are out of date\n\t\t/** @type {string[]} */\n\t\tconst input_files = [];\n\n\t\t/** @type {import('types').PageNode | null} */\n\t\tlet node = route.leaf;\n\t\twhile (node) {\n\t\t\tif (node.universal) input_files.push(node.universal);\n\t\t\tif (node.server) input_files.push(node.server);\n\t\t\tnode = node.parent ?? null;\n\t\t}\n\n\t\t/** @type {import('types').PageNode | null} */\n\t\tnode = route.layout;\n\t\twhile (node) {\n\t\t\tif (node.universal) input_files.push(node.universal);\n\t\t\tif (node.server) input_files.push(node.server);\n\t\t\tnode = node.parent ?? null;\n\t\t}\n\n\t\tif (route.endpoint) {\n\t\t\tinput_files.push(route.endpoint.file);\n\t\t}\n\n\t\ttry {\n\t\t\tfs.mkdirSync(outdir, { recursive: true });\n\t\t} catch {}\n\n\t\tconst output_files = compact(\n\t\t\tfs.readdirSync(outdir).map((name) => {\n\t\t\t\tconst stats = fs.statSync(path.join(outdir, name));\n\t\t\t\tif (stats.isDirectory()) return;\n\t\t\t\treturn {\n\t\t\t\t\tname,\n\t\t\t\t\tupdated: stats.mtimeMs\n\t\t\t\t};\n\t\t\t})\n\t\t);\n\n\t\tconst source_last_updated = Math.max(\n\t\t\t// ctimeMs includes move operations whereas mtimeMs does not\n\t\t\t...input_files.map((file) => fs.statSync(file).ctimeMs)\n\t\t);\n\t\tconst types_last_updated = Math.max(...output_files.map((file) => file.updated));\n\n\t\tconst should_generate =\n\t\t\t// source files were generated more recently than the types\n\t\t\tsource_last_updated > types_last_updated ||\n\t\t\t// no meta data file exists yet\n\t\t\t!has_meta_data ||\n\t\t\t// some file was deleted\n\t\t\t!meta_data[route.id]?.every((file) => input_files.includes(file));\n\n\t\tif (should_generate) {\n\t\t\t// track which old files end up being surplus to requirements\n\t\t\tconst to_delete = new Set(output_files.map((file) => file.name));\n\t\t\tupdate_types(config, routes_map, route, to_delete);\n\t\t\tmeta_data[route.id] = input_files;\n\t\t}\n\t}\n\n\tfs.writeFileSync(meta_data_file, JSON.stringify(meta_data, null, '\\t'));\n}\n\n/**\n * Creates types related to the given file. This should only be called\n * if the file in question was edited, not if it was created/deleted/moved.\n * @param {import('types').ValidatedConfig} config\n * @param {import('types').ManifestData} manifest_data\n * @param {string} file\n */\nexport function write_types(config, manifest_data, file) {\n\tif (!ts) return;\n\n\tif (!path.basename(file).startsWith('+')) {\n\t\t// Not a route file\n\t\treturn;\n\t}\n\n\tconst id = '/' + posixify(path.relative(config.kit.files.routes, path.dirname(file)));\n\n\tconst route = manifest_data.routes.find((route) => route.id === id);\n\tif (!route) return;\n\tif (!route.leaf && !route.layout && !route.endpoint) return; // nothing to do\n\n\tupdate_types(config, create_routes_map(manifest_data), route);\n}\n\n/**\n * Collect all leafs into a leaf -> route map\n * @param {import('types').ManifestData} manifest_data\n */\nfunction create_routes_map(manifest_data) {\n\t/** @type {RoutesMap} */\n\tconst map = new Map();\n\tfor (const route of manifest_data.routes) {\n\t\tif (route.leaf) {\n\t\t\tmap.set(route.leaf, { route, proxies: { server: null, universal: null } });\n\t\t}\n\t}\n\treturn map;\n}\n\n/**\n * Update types for a specific route\n * @param {import('types').ValidatedConfig} config\n * @param {RoutesMap} routes\n * @param {import('types').RouteData} route\n * @param {Set<string>} [to_delete]\n */\nfunction update_types(config, routes, route, to_delete = new Set()) {\n\tconst routes_dir = remove_relative_parent_traversals(\n\t\tposixify(path.relative('.', config.kit.files.routes))\n\t);\n\tconst outdir = path.join(config.kit.outDir, 'types', routes_dir, route.id);\n\n\t// now generate new types\n\tconst imports = [\"import type * as Kit from '@sveltejs/kit';\"];\n\n\t/** @type {string[]} */\n\tconst declarations = [];\n\n\t/** @type {string[]} */\n\tconst exports = [];\n\n\t// add 'Expand' helper\n\t// Makes sure a type is \"repackaged\" and therefore more readable\n\tdeclarations.push('type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;');\n\n\t// returns the predicate of a matcher's type guard - or string if there is no type guard\n\tdeclarations.push(\n\t\t'type MatcherParam<M> = M extends (param : string) => param is (infer U extends string) ? U : string;'\n\t);\n\n\tdeclarations.push(\n\t\t'type RouteParams = ' + generate_params_type(route.params, outdir, config) + ';'\n\t);\n\n\tif (route.params.length > 0) {\n\t\texports.push(\n\t\t\t'export type EntryGenerator = () => Promise<Array<RouteParams>> | Array<RouteParams>;'\n\t\t);\n\t}\n\n\tdeclarations.push(`type RouteId = '${route.id}';`);\n\n\t// 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\n\tif (route.layout || route.leaf) {\n\t\tdeclarations.push(\n\t\t\t// If T extends the empty object, void is also allowed as a return type\n\t\t\t'type MaybeWithVoid<T> = {} extends T ? T | void : T;',\n\n\t\t\t// Returns the key of the object whose values are required.\n\t\t\t'export type RequiredKeys<T> = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K; }[keyof T];',\n\n\t\t\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.\n\t\t\t// If none, void is also allowed as a return type.\n\t\t\t'type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Partial<Pick<App.PageData, keyof T & keyof App.PageData>> & Record<string, any>>',\n\n\t\t\t// null & {} == null, we need to prevent that in some situations\n\t\t\t'type EnsureDefined<T> = T extends null | undefined ? {} : T;',\n\n\t\t\t// Takes a union type and returns a union type where each type also has all properties\n\t\t\t// of all possible types (typed as undefined), making accessing them more ergonomic\n\t\t\t'type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;',\n\n\t\t\t// Re-export `Snapshot` from @sveltejs/kit — in future we could use this to infer <T> from the return type of `snapshot.capture`\n\t\t\t'export type Snapshot<T = any> = Kit.Snapshot<T>;'\n\t\t);\n\t}\n\n\tif (route.leaf) {\n\t\tlet route_info = routes.get(route.leaf);\n\t\tif (!route_info) {\n\t\t\t// This should be defined, but belts and braces\n\t\t\troute_info = { route, proxies: { server: null, universal: null } };\n\t\t\troutes.set(route.leaf, route_info);\n\t\t}\n\n\t\tconst {\n\t\t\tdeclarations: d,\n\t\t\texports: e,\n\t\t\tproxies\n\t\t} = process_node(route.leaf, outdir, true, route_info.proxies);\n\n\t\texports.push(...e);\n\t\tdeclarations.push(...d);\n\n\t\tif (proxies.server) {\n\t\t\troute_info.proxies.server = proxies.server;\n\t\t\tif (proxies.server?.modified) to_delete.delete(proxies.server.file_name);\n\t\t}\n\t\tif (proxies.universal) {\n\t\t\troute_info.proxies.universal = proxies.universal;\n\t\t\tif (proxies.universal?.modified) to_delete.delete(proxies.universal.file_name);\n\t\t}\n\n\t\tif (route.leaf.server) {\n\t\t\texports.push(\n\t\t\t\t'export type Action<OutputData extends Record<string, any> | void = Record<string, any> | void> = Kit.Action<RouteParams, OutputData, RouteId>'\n\t\t\t);\n\t\t\texports.push(\n\t\t\t\t'export type Actions<OutputData extends Record<string, any> | void = Record<string, any> | void> = Kit.Actions<RouteParams, OutputData, RouteId>'\n\t\t\t);\n\t\t}\n\n\t\tif (route.leaf.server) {\n\t\t\texports.push(\n\t\t\t\t'export type PageProps = { params: RouteParams; data: PageData; form: ActionData }'\n\t\t\t);\n\t\t} else {\n\t\t\texports.push('export type PageProps = { params: RouteParams; data: PageData }');\n\t\t}\n\t}\n\n\tif (route.layout) {\n\t\tlet all_pages_have_load = true;\n\t\t/** @type {import('types').RouteParam[]} */\n\t\tconst layout_params = [];\n\t\tconst ids = ['RouteId'];\n\n\t\troute.layout.child_pages?.forEach((page) => {\n\t\t\tconst leaf = routes.get(page);\n\t\t\tif (leaf) {\n\t\t\t\tif (leaf.route.page) ids.push(`\"${leaf.route.id}\"`);\n\n\t\t\t\tfor (const param of leaf.route.params) {\n\t\t\t\t\t// skip if already added\n\t\t\t\t\tif (layout_params.some((p) => p.name === param.name)) continue;\n\t\t\t\t\tlayout_params.push({ ...param, optional: true });\n\t\t\t\t}\n\n\t\t\t\tensureProxies(page, leaf.proxies);\n\n\t\t\t\tif (\n\t\t\t\t\t// Be defensive - if a proxy doesn't exist (because it couldn't be created), assume a load function exists.\n\t\t\t\t\t// If we didn't and it's a false negative, the user could wrongfully get a type error on layouts.\n\t\t\t\t\t(leaf.proxies.server && !leaf.proxies.server.exports.includes('load')) ||\n\t\t\t\t\t(leaf.proxies.universal && !leaf.proxies.universal.exports.includes('load'))\n\t\t\t\t) {\n\t\t\t\t\tall_pages_have_load = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!page.server && !page.universal) {\n\t\t\t\tall_pages_have_load = false;\n\t\t\t}\n\t\t});\n\n\t\tif (route.id === '/') {\n\t\t\t// root layout is used for fallback error page, where ID can be null\n\t\t\tids.push('null');\n\t\t}\n\n\t\tdeclarations.push(`type LayoutRouteId = ${ids.join(' | ')}`);\n\n\t\tdeclarations.push(\n\t\t\t'type LayoutParams = RouteParams & ' + generate_params_type(layout_params, outdir, config)\n\t\t);\n\n\t\tconst {\n\t\t\texports: e,\n\t\t\tdeclarations: d,\n\t\t\tproxies\n\t\t} = process_node(\n\t\t\troute.layout,\n\t\t\toutdir,\n\t\t\tfalse,\n\t\t\t{ server: null, universal: null },\n\t\t\tall_pages_have_load\n\t\t);\n\n\t\texports.push(...e);\n\t\tdeclarations.push(...d);\n\n\t\tif (proxies.server?.modified) to_delete.delete(proxies.server.file_name);\n\t\tif (proxies.universal?.modified) to_delete.delete(proxies.universal.file_name);\n\n\t\texports.push(\n\t\t\t'export type LayoutProps = { params: LayoutParams; data: LayoutData; children: import(\"svelte\").Snippet }'\n\t\t);\n\t}\n\n\tif (route.endpoint) {\n\t\texports.push('export type RequestHandler = Kit.RequestHandler<RouteParams, RouteId>;');\n\t}\n\n\tif (route.leaf?.server || route.layout?.server || route.endpoint) {\n\t\texports.push('export type RequestEvent = Kit.RequestEvent<RouteParams, RouteId>;');\n\t}\n\n\tconst output = [imports.join('\\n'), declarations.join('\\n'), exports.join('\\n')]\n\t\t.filter(Boolean)\n\t\t.join('\\n\\n');\n\n\tfs.writeFileSync(`${outdir}/$types.d.ts`, output);\n\tto_delete.delete('$types.d.ts');\n\n\tfor (const file of to_delete) {\n\t\tfs.unlinkSync(path.join(outdir, file));\n\t}\n}\n\n/**\n * @param {import('types').PageNode} node\n * @param {string} outdir\n * @param {boolean} is_page\n * @param {Proxies} proxies\n * @param {boolean} [all_pages_have_load]\n */\nfunction process_node(node, outdir, is_page, proxies, all_pages_have_load = true) {\n\tconst params = `${is_page ? 'Route' : 'Layout'}Params`;\n\tconst prefix = is_page ? 'Page' : 'Layout';\n\n\tconst route_id = is_page ? 'RouteId' : 'LayoutRouteId';\n\n\t/** @type {string[]} */\n\tconst declarations = [];\n\t/** @type {string[]} */\n\tconst exports = [];\n\n\t/** @type {string} */\n\tlet server_data;\n\t/** @type {string} */\n\tlet data;\n\n\tensureProxies(node, proxies);\n\n\tif (node.server) {\n\t\tconst basename = path.basename(node.server);\n\t\tconst proxy = proxies.server;\n\t\tif (proxy?.modified) {\n\t\t\tfs.writeFileSync(`${outdir}/proxy${basename}`, proxy.code);\n\t\t}\n\n\t\tserver_data = get_data_type(node.server, 'null', proxy, true);\n\n\t\tconst parent_type = `${prefix}ServerParentData`;\n\n\t\tdeclarations.push(`type ${parent_type} = ${get_parent_type(node, 'LayoutServerData')};`);\n\n\t\t// +page.js load present -> server can return all-optional data\n\t\tconst output_data_shape =\n\t\t\tnode.universal || (!is_page && all_pages_have_load)\n\t\t\t\t? 'Partial<App.PageData> & Record<string, any> | void'\n\t\t\t\t: `OutputDataShape<${parent_type}>`;\n\t\texports.push(\n\t\t\t`export type ${prefix}ServerLoad<OutputData extends ${output_data_shape} = ${output_data_shape}> = Kit.ServerLoad<${params}, ${parent_type}, OutputData, ${route_id}>;`\n\t\t);\n\n\t\texports.push(`export type ${prefix}ServerLoadEvent = Parameters<${prefix}ServerLoad>[0];`);\n\n\t\tif (is_page) {\n\t\t\tlet type = 'unknown';\n\t\t\tif (proxy && proxy.exports.includes('actions')) {\n\t\t\t\t// If the file wasn't tweaked, we can use the return type of the original file.\n\t\t\t\t// The advantage is that type updates are reflected without saving.\n\t\t\t\tconst from = proxy.modified\n\t\t\t\t\t? `./proxy${replace_ext_with_js(basename)}`\n\t\t\t\t\t: path_to_original(outdir, node.server);\n\n\t\t\t\texports.push(\n\t\t\t\t\t'type ExcludeActionFailure<T> = T extends Kit.ActionFailure<any> ? never : T extends void ? never : T;',\n\t\t\t\t\t'type ActionsSuccess<T extends Record<string, (...args: any) => any>> = { [Key in keyof T]: ExcludeActionFailure<Awaited<ReturnType<T[Key]>>>; }[keyof T];',\n\t\t\t\t\t'type ExtractActionFailure<T> = T extends Kit.ActionFailure<infer X>\t? X extends void ? never : X : never;',\n\t\t\t\t\t'type ActionsFailure<T extends Record<string, (...args: any) => any>> = { [Key in keyof T]: Exclude<ExtractActionFailure<Awaited<ReturnType<T[Key]>>>, void>; }[keyof T];',\n\t\t\t\t\t`type ActionsExport = typeof import('${from}').actions`,\n\t\t\t\t\t'export type SubmitFunction = Kit.SubmitFunction<Expand<ActionsSuccess<ActionsExport>>, Expand<ActionsFailure<ActionsExport>>>'\n\t\t\t\t);\n\n\t\t\t\ttype = 'Expand<Kit.AwaitedActions<ActionsExport>> | null';\n\t\t\t}\n\t\t\texports.push(`export type ActionData = ${type};`);\n\t\t}\n\t} else {\n\t\tserver_data = 'null';\n\t}\n\texports.push(`export type ${prefix}ServerData = ${server_data};`);\n\n\tconst parent_type = `${prefix}ParentData`;\n\tdeclarations.push(`type ${parent_type} = ${get_parent_type(node, 'LayoutData')};`);\n\n\tif (node.universal) {\n\t\tconst proxy = proxies.universal;\n\t\tif (proxy?.modified) {\n\t\t\tfs.writeFileSync(`${outdir}/proxy${path.basename(node.universal)}`, proxy.code);\n\t\t}\n\n\t\tconst type = get_data_type(\n\t\t\tnode.universal,\n\t\t\t`${parent_type} & EnsureDefined<${prefix}ServerData>`,\n\t\t\tproxy\n\t\t);\n\n\t\tdata = `Expand<Omit<${parent_type}, keyof ${type}> & OptionalUnion<EnsureDefined<${type}>>>`;\n\n\t\tconst output_data_shape =\n\t\t\t!is_page && all_pages_have_load\n\t\t\t\t? 'Partial<App.PageData> & Record<string, any> | void'\n\t\t\t\t: `OutputDataShape<${parent_type}>`;\n\t\texports.push(\n\t\t\t`export type ${prefix}Load<OutputData extends ${output_data_shape} = ${output_data_shape}> = Kit.Load<${params}, ${prefix}ServerData, ${parent_type}, OutputData, ${route_id}>;`\n\t\t);\n\n\t\texports.push(`export type ${prefix}LoadEvent = Parameters<${prefix}Load>[0];`);\n\t} else if (server_data === 'null') {\n\t\tdata = `Expand<${parent_type}>`;\n\t} else {\n\t\tdata = `Expand<Omit<${parent_type}, keyof ${prefix}ServerData> & EnsureDefined<${prefix}ServerData>>`;\n\t}\n\n\texports.push(`export type ${prefix}Data = ${data};`);\n\n\treturn { declarations, exports, proxies };\n\n\t/**\n\t * @param {string} file_path\n\t * @param {string} fallback\n\t * @param {Proxy} proxy\n\t * @param {boolean} expand\n\t */\n\tfunction get_data_type(file_path, fallback, proxy, expand = false) {\n\t\tif (proxy) {\n\t\t\tif (proxy.exports.includes('load')) {\n\t\t\t\t// If the file wasn't tweaked, we can use the return type of the original file.\n\t\t\t\t// The advantage is that type updates are reflected without saving.\n\t\t\t\tconst from = proxy.modified\n\t\t\t\t\t? `./proxy${replace_ext_with_js(path.basename(file_path))}`\n\t\t\t\t\t: path_to_original(outdir, file_path);\n\t\t\t\tconst type = `Kit.LoadProperties<Awaited<ReturnType<typeof import('${from}').load>>>`;\n\t\t\t\treturn expand ? `Expand<OptionalUnion<EnsureDefined<${type}>>>` : type;\n\t\t\t} else {\n\t\t\t\treturn fallback;\n\t\t\t}\n\t\t} else {\n\t\t\treturn 'unknown';\n\t\t}\n\t}\n}\n\n/**\n * This function populates the proxies object, if necessary and not already done.\n * Proxies are used to tweak the code of a file before it's typechecked.\n * They are needed in two places - when generating the types for a page or layout.\n * To not do the same work twice, we generate the proxies once and pass them around.\n *\n * @param {import('types').PageNode} node\n * @param {Proxies} proxies\n */\nfunction ensureProxies(node, proxies) {\n\tif (node.server && !proxies.server) {\n\t\tproxies.server = createProxy(node.server, true);\n\t}\n\n\tif (node.universal && !proxies.universal) {\n\t\tproxies.universal = createProxy(node.universal, false);\n\t}\n}\n\n/**\n * @param {string} file_path\n * @param {boolean} is_server\n * @returns {Proxy}\n */\nfunction createProxy(file_path, is_server) {\n\tconst proxy = tweak_types(fs.readFileSync(file_path, 'utf8'), is_server);\n\tif (proxy) {\n\t\treturn {\n\t\t\t...proxy,\n\t\t\tfile_name: `proxy${path.basename(file_path)}`\n\t\t};\n\t} else {\n\t\treturn null;\n\t}\n}\n\n/**\n * Get the parent type string by recursively looking up the parent layout and accumulate them to one type.\n * @param {import('types').PageNode} node\n * @param {string} type\n */\nfunction get_parent_type(node, type) {\n\tconst parent_imports = [];\n\n\tlet parent = node.parent;\n\n\twhile (parent) {\n\t\tconst d = node.depth - parent.depth;\n\t\t// unshift because we need it the other way round for the import string\n\t\tparent_imports.unshift(\n\t\t\t`${d === 0 ? '' : `import('${'../'.repeat(d)}${'$types.js'}').`}${type}`\n\t\t);\n\t\tparent = parent.parent;\n\t}\n\n\tlet parent_str = `EnsureDefined<${parent_imports[0] || '{}'}>`;\n\tfor (let i = 1; i < parent_imports.length; i++) {\n\t\t// Omit is necessary because a parent could have a property with the same key which would\n\t\t// cause a type conflict. At runtime the child overwrites the parent property in this case,\n\t\t// so reflect that in the type definition.\n\t\t// EnsureDefined is necessary because {something: string} & null becomes null.\n\t\t// Output types of server loads can be null but when passed in through the `parent` parameter they are the empty object instead.\n\t\tparent_str = `Omit<${parent_str}, keyof ${parent_imports[i]}> & EnsureDefined<${parent_imports[i]}>`;\n\t}\n\treturn parent_str;\n}\n\n/**\n * @param {string} outdir\n * @param {string} file_path\n */\nfunction path_to_original(outdir, file_path) {\n\treturn posixify(path.relative(outdir, path.join(cwd, replace_ext_with_js(file_path))));\n}\n\n/**\n * @param {string} file_path\n */\nfunction replace_ext_with_js(file_path) {\n\t// Another extension than `.js` (or nothing, but that fails with node16 moduleResolution)\n\t// will result in TS failing to lookup the file\n\tconst ext = path.extname(file_path);\n\treturn file_path.slice(0, -ext.length) + '.js';\n}\n\n/**\n * @param {import('types').RouteParam[]} params\n * @param {string} outdir\n * @param {import('types').ValidatedConfig} config\n */\nfunction generate_params_type(params, outdir, config) {\n\t/** @param {string} matcher */\n\tconst path_to_matcher = (matcher) =>\n\t\tposixify(path.relative(outdir, path.join(config.kit.files.params, matcher + '.js')));\n\n\treturn `{ ${params\n\t\t.map(\n\t\t\t(param) =>\n\t\t\t\t`${param.name}${param.optional ? '?' : ''}: ${\n\t\t\t\t\tparam.matcher\n\t\t\t\t\t\t? `MatcherParam<typeof import('${path_to_matcher(param.matcher)}').match>`\n\t\t\t\t\t\t: 'string'\n\t\t\t\t}`\n\t\t)\n\t\t.join('; ')} }`;\n}\n\n/**\n * @param {string} content\n * @param {boolean} is_server\n * @returns {Omit<NonNullable<Proxy>, 'file_name'> | null}\n */\nexport function tweak_types(content, is_server) {\n\tconst names = new Set(is_server ? ['load', 'actions'] : ['load']);\n\n\ttry {\n\t\tlet modified = false;\n\n\t\tconst ast = ts.createSourceFile(\n\t\t\t'filename.ts',\n\t\t\tcontent,\n\t\t\tts.ScriptTarget.Latest,\n\t\t\tfalse,\n\t\t\tts.ScriptKind.TS\n\t\t);\n\n\t\tconst code = new MagicString(content);\n\n\t\tconst exports = new Map();\n\n\t\tast.forEachChild((node) => {\n\t\t\tif (\n\t\t\t\tts.isExportDeclaration(node) &&\n\t\t\t\tnode.exportClause &&\n\t\t\t\tts.isNamedExports(node.exportClause)\n\t\t\t) {\n\t\t\t\tnode.exportClause.elements.forEach((element) => {\n\t\t\t\t\tconst exported = element.name;\n\t\t\t\t\tif (names.has(element.name.text)) {\n\t\t\t\t\t\tconst local = element.propertyName || element.name;\n\t\t\t\t\t\texports.set(exported.text, local.text);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tts.canHaveModifiers(node) &&\n\t\t\t\tts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)\n\t\t\t) {\n\t\t\t\tif (ts.isFunctionDeclaration(node) && node.name?.text && names.has(node.name?.text)) {\n\t\t\t\t\texports.set(node.name.text, node.name.text);\n\t\t\t\t}\n\n\t\t\t\tif (ts.isVariableStatement(node)) {\n\t\t\t\t\tnode.declarationList.declarations.forEach((declaration) => {\n\t\t\t\t\t\tif (ts.isIdentifier(declaration.name) && names.has(declaration.name.text)) {\n\t\t\t\t\t\t\texports.set(declaration.name.text, declaration.name.text);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t/**\n\t\t * @param {import('typescript').Node} node\n\t\t * @param {import('typescript').Node} value\n\t\t */\n\t\tfunction replace_jsdoc_type_tags(node, value) {\n\t\t\tlet _modified = false;\n\t\t\t// @ts-ignore\n\t\t\tif (node.jsDoc) {\n\t\t\t\t// @ts-ignore\n\t\t\t\tfor (const comment of node.jsDoc) {\n\t\t\t\t\tfor (const tag of comment.tags ?? []) {\n\t\t\t\t\t\tif (ts.isJSDocTypeTag(tag)) {\n\t\t\t\t\t\t\tconst is_fn =\n\t\t\t\t\t\t\t\tts.isFunctionDeclaration(value) ||\n\t\t\t\t\t\t\t\tts.isFunctionExpression(value) ||\n\t\t\t\t\t\t\t\tts.isArrowFunction(value);\n\n\t\t\t\t\t\t\tif (is_fn && value.parameters?.length > 0) {\n\t\t\t\t\t\t\t\tconst name = ts.isIdentifier(value.parameters[0].name)\n\t\t\t\t\t\t\t\t\t? value.parameters[0].name.text\n\t\t\t\t\t\t\t\t\t: 'event';\n\t\t\t\t\t\t\t\tcode.overwrite(tag.tagName.pos, tag.tagName.end, 'param');\n\t\t\t\t\t\t\t\tcode.prependRight(tag.typeExpression.pos + 1, 'Parameters<');\n\t\t\t\t\t\t\t\tcode.appendLeft(tag.typeExpression.end - 1, '>[0]');\n\t\t\t\t\t\t\t\tcode.appendLeft(tag.typeExpression.end, ` ${name}`);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcode.overwrite(tag.pos, tag.end, '');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t_modified = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tmodified = modified || _modified;\n\t\t\treturn _modified;\n\t\t}\n\n\t\tast.forEachChild((node) => {\n\t\t\tif (ts.isFunctionDeclaration(node) && node.name?.text && node.name?.text === 'load') {\n\t\t\t\t// remove JSDoc comment above `export function load ...`\n\t\t\t\treplace_jsdoc_type_tags(node, node);\n\t\t\t}\n\n\t\t\tif (ts.isVariableStatement(node)) {\n\t\t\t\t// remove JSDoc comment above `export const load = ...`\n\t\t\t\tif (\n\t\t\t\t\tts.isIdentifier(node.declarationList.declarations[0].name) &&\n\t\t\t\t\tnames.has(node.declarationList.declarations[0].name.text) &&\n\t\t\t\t\tnode.declarationList.declarations[0].initializer\n\t\t\t\t) {\n\t\t\t\t\treplace_jsdoc_type_tags(node, node.declarationList.declarations[0].initializer);\n\t\t\t\t}\n\n\t\t\t\tfor (const declaration of node.declarationList.declarations) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tts.isIdentifier(declaration.name) &&\n\t\t\t\t\t\tdeclaration.name.text === 'load' &&\n\t\t\t\t\t\tdeclaration.initializer\n\t\t\t\t\t) {\n\t\t\t\t\t\t// edge case — remove JSDoc comment above individual export\n\t\t\t\t\t\treplace_jsdoc_type_tags(declaration, declaration.initializer);\n\n\t\t\t\t\t\t// remove type from `export const load: Load ...`\n\t\t\t\t\t\tif (declaration.type) {\n\t\t\t\t\t\t\tlet a = declaration.type.pos;\n\t\t\t\t\t\t\tconst b = declaration.type.end;\n\t\t\t\t\t\t\twhile (is_whitespace(content[a])) a += 1;\n\n\t\t\t\t\t\t\tconst type = content.slice(a, b);\n\t\t\t\t\t\t\tcode.remove(declaration.name.end, declaration.type.end);\n\n\t\t\t\t\t\t\tconst rhs = declaration.initializer;\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trhs &&\n\t\t\t\t\t\t\t\t(ts.isArrowFunction(rhs) || ts.isFunctionExpression(rhs)) &&\n\t\t\t\t\t\t\t\trhs.parameters.length\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tconst arg = rhs.parameters[0];\n\t\t\t\t\t\t\t\tconst add_parens = content[arg.pos - 1] !== '(';\n\n\t\t\t\t\t\t\t\tif (add_parens) code.prependRight(arg.pos, '(');\n\n\t\t\t\t\t\t\t\tif (arg && !arg.type) {\n\t\t\t\t\t\t\t\t\tcode.appendLeft(\n\t\t\t\t\t\t\t\t\t\targ.name.end,\n\t\t\t\t\t\t\t\t\t\t`: Parameters<${type}>[0]` + (add_parens ? ')' : '')\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// prevent \"type X is imported but not used\" (isn't silenced by @ts-nocheck) when svelte-check runs\n\t\t\t\t\t\t\t\t\tcode.append(`;null as any as ${type};`);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// prevent \"type X is imported but not used\" (isn't silenced by @ts-nocheck) when svelte-check runs\n\t\t\t\t\t\t\t\tcode.append(`;null as any as ${type};`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tmodified = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tis_server &&\n\t\t\t\t\t\tts.isIdentifier(declaration.name) &&\n\t\t\t\t\t\tdeclaration.name?.text === 'actions' &&\n\t\t\t\t\t\tdeclaration.initializer\n\t\t\t\t\t) {\n\t\t\t\t\t\t// remove JSDoc comment from `export const actions = ..`\n\t\t\t\t\t\tconst removed = replace_jsdoc_type_tags(node, declaration.initializer);\n\t\t\t\t\t\t// ... and move type to each individual action\n\t\t\t\t\t\tif (removed) {\n\t\t\t\t\t\t\tconst rhs = declaration.initializer;\n\t\t\t\t\t\t\tif (ts.isObjectLiteralExpression(rhs)) {\n\t\t\t\t\t\t\t\tfor (const prop of rhs.properties) {\n\t\t\t\t\t\t\t\t\tif (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) {\n\t\t\t\t\t\t\t\t\t\tconst rhs = prop.initializer;\n\t\t\t\t\t\t\t\t\t\tconst replaced = replace_jsdoc_type_tags(prop, rhs);\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t!replaced &&\n\t\t\t\t\t\t\t\t\t\t\trhs &&\n\t\t\t\t\t\t\t\t\t\t\t(ts.isArrowFunction(rhs) || ts.isFunctionExpression(rhs)) &&\n\t\t\t\t\t\t\t\t\t\t\trhs.parameters?.[0]\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tconst name = ts.isIdentifier(rhs.parameters[0].name)\n\t\t\t\t\t\t\t\t\t\t\t\t? rhs.parameters[0].name.text\n\t\t\t\t\t\t\t\t\t\t\t\t: 'event';\n\t\t\t\t\t\t\t\t\t\t\tcode.prependRight(\n\t\t\t\t\t\t\t\t\t\t\t\trhs.pos,\n\t\t\t\t\t\t\t\t\t\t\t\t`/** @param {import('./$types').RequestEvent} ${name} */ `\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// remove type from `export const actions: Actions ...`\n\t\t\t\t\t\tif (declaration.type) {\n\t\t\t\t\t\t\tlet a = declaration.type.pos;\n\t\t\t\t\t\t\tconst b = declaration.type.end;\n\t\t\t\t\t\t\twhile (is_whitespace(content[a])) a += 1;\n\n\t\t\t\t\t\t\tconst type = content.slice(a, b);\n\t\t\t\t\t\t\tcode.remove(declaration.name.end, declaration.type.end);\n\t\t\t\t\t\t\tcode.append(`;null as any as ${type};`);\n\t\t\t\t\t\t\tmodified = true;\n\n\t\t\t\t\t\t\t// ... and move type to each individual action\n\t\t\t\t\t\t\tconst rhs = declaration.initializer;\n\t\t\t\t\t\t\tif (ts.isObjectLiteralExpression(rhs)) {\n\t\t\t\t\t\t\t\tfor (const prop of rhs.properties) {\n\t\t\t\t\t\t\t\t\tif (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) {\n\t\t\t\t\t\t\t\t\t\tconst rhs = prop.initializer;\n\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\trhs &&\n\t\t\t\t\t\t\t\t\t\t\t(ts.isArrowFunction(rhs) || ts.isFunctionExpression(rhs)) &&\n\t\t\t\t\t\t\t\t\t\t\trhs.parameters.length\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tconst arg = rhs.parameters[0];\n\t\t\t\t\t\t\t\t\t\t\tconst add_parens = content[arg.pos - 1] !== '(';\n\n\t\t\t\t\t\t\t\t\t\t\tif (add_parens) code.prependRight(arg.pos, '(');\n\n\t\t\t\t\t\t\t\t\t\t\tif (arg && !arg.type) {\n\t\t\t\t\t\t\t\t\t\t\t\tcode.appendLeft(\n\t\t\t\t\t\t\t\t\t\t\t\t\targ.name.end,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\": import('./$types').RequestEvent\" + (add_parens ? ')' : '')\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tif (modified) {\n\t\t\t// Ignore all type errors so they don't show up twice when svelte-check runs\n\t\t\t// Account for possible @ts-check which would overwrite @ts-nocheck\n\t\t\tif (code.original.startsWith('// @ts-check')) {\n\t\t\t\tcode.prependLeft('// @ts-check'.length, '\\n// @ts-nocheck\\n');\n\t\t\t} else {\n\t\t\t\tcode.prepend('// @ts-nocheck\\n');\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tmodified,\n\t\t\tcode: code.toString(),\n\t\t\texports: Array.from(exports.keys())\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/index.spec.js",
    "content": "import { execSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\nimport { assert, expect, test } from 'vitest';\nimport { rimraf } from '../../../utils/filesystem.js';\nimport create_manifest_data from '../create_manifest_data/index.js';\nimport { tweak_types, write_all_types } from './index.js';\nimport { write_non_ambient } from '../write_non_ambient.js';\nimport { validate_config } from '../../config/index.js';\n\nconst cwd = fileURLToPath(new URL('./test', import.meta.url));\n\n/**\n * @param {string} dir\n */\nfunction run_test(dir) {\n\trimraf(path.join(cwd, dir, '.svelte-kit'));\n\n\tconst initial = validate_config({});\n\n\tinitial.kit.files.assets = path.resolve(cwd, 'static');\n\tinitial.kit.files.params = path.resolve(cwd, dir, 'params');\n\tinitial.kit.files.routes = path.resolve(cwd, dir);\n\tinitial.kit.outDir = path.resolve(cwd, path.join(dir, '.svelte-kit'));\n\n\tconst manifest = create_manifest_data({\n\t\tconfig: /** @type {import('types').ValidatedConfig} */ (initial)\n\t});\n\n\twrite_all_types(initial, manifest);\n\twrite_non_ambient(initial.kit, manifest);\n}\n\ntest('Creates correct $types', { timeout: 60000 }, () => {\n\t// To save us from creating a real SvelteKit project for each of the tests,\n\t// we first run the type generation directly for each test case, and then\n\t// call `tsc` to check that the generated types are valid.\n\tconst directories = fs\n\t\t.readdirSync(cwd)\n\t\t.filter((dir) => fs.statSync(`${cwd}/${dir}`).isDirectory());\n\n\tfor (const dir of directories) {\n\t\trun_test(dir);\n\t\ttry {\n\t\t\t// we skip lib check if MATRIX_VITE is set and not 'current' because overrides for vite can cause type mismatches\n\t\t\tconst skipLibCheck = process.env.MATRIX_VITE != null && process.env.MATRIX_VITE !== 'current';\n\t\t\texecSync(`pnpm testtypes${skipLibCheck ? ' --skipLibCheck' : ''}`, {\n\t\t\t\tcwd: path.join(cwd, dir)\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tconsole.error(/** @type {any} */ (e).stdout.toString());\n\t\t\tthrow new Error(`${dir} type tests failed`, { cause: e });\n\t\t}\n\t}\n});\n\ntest('Rewrites types for a TypeScript module', () => {\n\tconst source = `\n\t\texport const load: Get = ({ params }) => {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t`;\n\n\tconst rewritten = tweak_types(source, false);\n\n\texpect(rewritten?.exports).toEqual(['load']);\n\tassert.equal(\n\t\trewritten?.code,\n\t\t`// @ts-nocheck\n\n\t\texport const load = ({ params }: Parameters<Get>[0]) => {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t`\n\t);\n});\n\ntest('Rewrites types for a TypeScript module without param', () => {\n\tconst source = `\n\t\texport const load: Get = () => {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t`;\n\n\tconst rewritten = tweak_types(source, false);\n\n\texpect(rewritten?.exports).toEqual(['load']);\n\tassert.equal(\n\t\trewritten?.code,\n\t\t`// @ts-nocheck\n\n\t\texport const load = () => {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t;null as any as Get;`\n\t);\n});\n\ntest('Rewrites types for a TypeScript module without param and jsdoc without types', () => {\n\tconst source = `\n\t\t/** test */\n\t\texport const load: Get = () => {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t`;\n\n\tconst rewritten = tweak_types(source, false);\n\n\texpect(rewritten?.exports).toEqual(['load']);\n\tassert.equal(\n\t\trewritten?.code,\n\t\t`// @ts-nocheck\n\n\t\t/** test */\n\t\texport const load = () => {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t;null as any as Get;`\n\t);\n});\n\ntest('Rewrites types for a JavaScript module with `function`', () => {\n\tconst source = `\n\t\t/** @type {import('./$types').Get} */\n\t\texport function load({ params }) {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t`;\n\n\tconst rewritten = tweak_types(source, false);\n\n\texpect(rewritten?.exports).toEqual(['load']);\n\tassert.equal(\n\t\trewritten?.code,\n\t\t`// @ts-nocheck\n\n\t\t/** @param {Parameters<import('./$types').Get>[0]} event */\n\t\texport function load({ params }) {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t`\n\t);\n});\n\ntest('Rewrites types for a JavaScript module with `const`', () => {\n\tconst source = `\n\t\t/** @type {import('./$types').Get} */\n\t\texport const load = ({ params }) => {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t`;\n\n\tconst rewritten = tweak_types(source, false);\n\n\texpect(rewritten?.exports).toEqual(['load']);\n\tassert.equal(\n\t\trewritten?.code,\n\t\t`// @ts-nocheck\n\n\t\t/** @param {Parameters<import('./$types').Get>[0]} event */\n\t\texport const load = ({ params }) => {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t`\n\t);\n});\n\ntest('Appends @ts-nocheck after @ts-check', () => {\n\tconst source = `// @ts-check\n\t\t/** @type {import('./$types').Get} */\n\t\texport const load = ({ params }) => {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t`;\n\n\tconst rewritten = tweak_types(source, false);\n\n\texpect(rewritten?.exports).toEqual(['load']);\n\tassert.equal(\n\t\trewritten?.code,\n\t\t`// @ts-check\n// @ts-nocheck\n\n\t\t/** @param {Parameters<import('./$types').Get>[0]} event */\n\t\texport const load = ({ params }) => {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t};\n\t`\n\t);\n});\n\ntest('Rewrites action types for a JavaScript module', () => {\n\tconst source = `\n\t\t/** @type {import('./$types').Actions} */\n\t\texport const actions = {\n\t\t\ta: () => {},\n\t\t\tb: (param) => {},\n\t\t\t/** @type {import('./$types').Action} */\n\t\t\tc: (param) => {},\n\t\t}\n\t`;\n\n\tconst rewritten = tweak_types(source, true);\n\n\texpect(rewritten?.exports).toEqual(['actions']);\n\tassert.equal(\n\t\trewritten?.code,\n\t\t`// @ts-nocheck\n\n\t\t/** */\n\t\texport const actions = {\n\t\t\ta: () => {},\n\t\t\tb:/** @param {import('./$types').RequestEvent} param */  (param) => {},\n\t\t\t/** @param {Parameters<import('./$types').Action>[0]} param */\n\t\t\tc: (param) => {},\n\t\t}\n\t`\n\t);\n});\n\ntest('Rewrites action types for a TypeScript module', () => {\n\tconst source = `\n\t\timport type { Actions, RequestEvent } from './$types';\n\n\t\texport const actions: Actions = {\n\t\t\ta: () => {},\n\t\t\tb: (param: RequestEvent) => {},\n\t\t\tc: (param) => {},\n\t\t}\n\t`;\n\n\tconst rewritten = tweak_types(source, true);\n\n\texpect(rewritten?.exports).toEqual(['actions']);\n\tassert.equal(\n\t\trewritten?.code,\n\t\t`// @ts-nocheck\n\n\t\timport type { Actions, RequestEvent } from './$types';\n\n\t\texport const actions = {\n\t\t\ta: () => {},\n\t\t\tb: (param: RequestEvent) => {},\n\t\t\tc: (param: import('./$types').RequestEvent) => {},\n\t\t}\n\t;null as any as Actions;`\n\t);\n});\n\ntest('Leaves satisfies operator untouched', () => {\n\tconst source = `\n\t\timport type { Actions, PageServerLoad, RequestEvent } from './$types';\n\t\texport function load({ params }) {\n\t\t\treturn {\n\t\t\t\ta: 1\n\t\t\t};\n\t\t} satisfies PageServerLoad\n\t\texport const actions = {\n\t\t\ta: () => {},\n\t\t\tb: (param: RequestEvent) => {},\n\t\t\tc: (param) => {},\n\t\t} satisfies Actions\n\t`;\n\n\tconst rewritten = tweak_types(source, true);\n\n\texpect(rewritten?.exports).toEqual(['load', 'actions']);\n\tassert.equal(rewritten?.modified, false);\n\tassert.equal(rewritten?.code, source);\n});\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/actions/+page.server.js",
    "content": "import { fail } from '../../../../../../src/exports/index.js';\n\nconst condition = false;\n\nexport const actions = {\n\tdefault: () => {\n\t\tif (condition) {\n\t\t\treturn fail(400, {\n\t\t\t\tfail: 'oops'\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true\n\t\t};\n\t},\n\tsuccessWithPayload: () => {\n\t\treturn {\n\t\t\tid: 42,\n\t\t\tusername: 'John Doe',\n\t\t\tprofession: 'Svelte specialist'\n\t\t};\n\t},\n\tsuccessWithoutPayload: () => {},\n\tfailWithPayload: () => {\n\t\treturn fail(400, {\n\t\t\treason: {\n\t\t\t\terror: {\n\t\t\t\t\tcode: /** @type {const} */ ('VALIDATION_FAILED')\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t},\n\tfailWithoutPayload: () => {\n\t\treturn fail(400);\n\t}\n};\n\n/**\n * Ordinarily this would live in a +page.svelte, but to make it easy to run the tests, we put it here.\n * The `export` is so that eslint doesn't throw a hissy fit about the unused variable\n * @type {import('./.svelte-kit/types/src/core/sync/write_types/test/actions/$types').SubmitFunction}\n */\nexport const submit = () => {\n\treturn ({ result }) => {\n\t\tif (result.type === 'success') {\n\t\t\t// @ts-expect-error does only exist on `failure` result\n\t\t\tresult.data?.fail;\n\t\t\t// @ts-expect-error unknown property\n\t\t\tresult.data?.something;\n\n\t\t\tif (result.data && 'success' in result.data) {\n\t\t\t\tresult.data.success === true;\n\t\t\t\t// @ts-expect-error should be of type `boolean`\n\t\t\t\tresult.data.success === 'success';\n\t\t\t\t// @ts-expect-error does not exist in this branch\n\t\t\t\tresult.data.id;\n\t\t\t}\n\n\t\t\tif (result.data && 'id' in result.data) {\n\t\t\t\tresult.data.id === 42;\n\t\t\t\t// @ts-expect-error should be of type `number`\n\t\t\t\tresult.data.id === 'John';\n\t\t\t\t// @ts-expect-error does not exist in this branch\n\t\t\t\tresult.data.success;\n\t\t\t}\n\t\t}\n\n\t\tif (result.type === 'failure') {\n\t\t\tresult.data;\n\t\t\t// @ts-expect-error does only exist on `success` result\n\t\t\tresult.data.success;\n\t\t\t// @ts-expect-error unknown property\n\t\t\tresult.data.unknown;\n\n\t\t\tif (result.data && 'fail' in result.data) {\n\t\t\t\tresult.data.fail === '';\n\t\t\t\t// @ts-expect-error does not exist in this branch\n\t\t\t\tresult.data.reason;\n\t\t\t}\n\n\t\t\tif (result.data && 'reason' in result.data) {\n\t\t\t\tresult.data.reason.error.code === 'VALIDATION_FAILED';\n\t\t\t\t// @ts-expect-error should be a const\n\t\t\t\tresult.data.reason.error.code === '';\n\t\t\t\t// @ts-expect-error does not exist in this branch\n\t\t\t\tresult.data.fail;\n\t\t\t}\n\t\t}\n\t};\n};\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/actions/package.json",
    "content": "{\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"testtypes\": \"tsc\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/actions/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"es2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../../../../../exports/public\"],\n\t\t\t\"types\": [\"../../../../../types/internal\"],\n\t\t\t\"$app/types\": [\"../../../../../types/ambient.d.ts\"]\n\t\t}\n\t},\n\t\"include\": [\"./**/*.js\", \"./**/*.ts\", \".svelte-kit/non-ambient.d.ts\"],\n\t\"exclude\": [\"..svelte-kit/**\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/+page.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/always/+page.server.js",
    "content": "export const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/always/endpoint/+server.js",
    "content": "export const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/always/layout/+layout.js",
    "content": "export const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/always/layout/inside/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/ignore/+page.server.js",
    "content": "export const trailingSlash = 'ignore';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/ignore/endpoint/+server.js",
    "content": "export const trailingSlash = 'ignore';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/ignore/layout/+layout.js",
    "content": "export const trailingSlash = 'ignore';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/ignore/layout/inside/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/mixed/+page.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/mixed/+server.js",
    "content": "export const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/never/+page.server.js",
    "content": "export const trailingSlash = 'never';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/never/endpoint/+server.js",
    "content": "export const trailingSlash = 'never';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/never/layout/+layout.js",
    "content": "export const trailingSlash = 'never';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/(group)/path-a/trailing-slash/never/layout/inside/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/+page.js",
    "content": "/** @type {import('$app/types').RouteId} */\nlet id;\n\n// okay\nid = '/';\nid = '/foo/[bar]/[baz]';\nid = '/(group)/path-a';\n\n// @ts-expect-error\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nid = '/nope';\n\n/** @type {import('$app/types').RouteParams<'/foo/[bar]/[baz]'>} */\nconst params = {\n\tbar: 'A',\n\tbaz: 'B'\n};\n\n// @ts-expect-error foo is not a param\nparams.foo;\nparams.bar; // okay\nparams.baz; // okay\n\n/** @type {import('$app/types').RouteParams<'/matcher-test/no-matcher/[locale]'>} */\nconst noMatcherPageParams = {\n\tlocale: 'fr' // any string\n};\n\n/** @type {import('$app/types').LayoutParams<'/matcher-test/no-matcher'>} */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst noMatcherLayoutParams = {};\n\nnoMatcherPageParams.locale = 'fr'; // any string\n\n/** @type {import('$app/types').RouteParams<'/matcher-test/with-matcher/[[locale=locale]]'>} */\nconst withMatcherPageParams = {};\n\n// @ts-expect-error locale should be \"en\" or \"nb\"\nwithMatcherPageParams.locale = 'fr';\nwithMatcherPageParams.locale = 'en'; // okay\nwithMatcherPageParams.locale = 'nb'; // okay\n\n/** @type {import('$app/types').LayoutParams<'/matcher-test/with-matcher'>} */\nconst withMatcherLayoutParams = {};\n\n// @ts-expect-error locale should be \"en\" or \"nb\"\nwithMatcherLayoutParams.locale = 'fr';\nwithMatcherLayoutParams.locale = 'en'; // okay\nwithMatcherLayoutParams.locale = 'nb'; // okay\n\n/** @type {import('$app/types').LayoutParams<'/matcher-test'>} */\nconst matcherParentLayoutParams = {};\n\nmatcherParentLayoutParams.locale = 'fr'; // any string\n\n/** @type {import('$app/types').Pathname} */\nlet pathname;\n\n// @ts-expect-error route doesn't exist\npathname = '/nope';\n// @ts-expect-error route doesn't exist\npathname = '/foo';\n// @ts-expect-error route doesn't exist\npathname = '/foo/';\npathname = '/foo/1/2'; // okay\npathname = '/foo/1/2/'; // okay\n\n// Test layout groups\npathname = '/path-a';\n// @ts-expect-error default trailing slash is never, so we should not have it here\npathname = '/path-a/';\n// @ts-expect-error layout group names are NOT part of the pathname type\npathname = '/(group)/path-a';\n\n// Test trailing-slash - always\npathname = '/path-a/trailing-slash/always/';\npathname = '/path-a/trailing-slash/always/endpoint/';\npathname = '/path-a/trailing-slash/always/layout/inside/';\n\n// Test trailing-slash - ignore\npathname = '/path-a/trailing-slash/ignore';\npathname = '/path-a/trailing-slash/ignore/';\npathname = '/path-a/trailing-slash/ignore/endpoint';\npathname = '/path-a/trailing-slash/ignore/endpoint/';\npathname = '/path-a/trailing-slash/ignore/layout/inside';\npathname = '/path-a/trailing-slash/ignore/layout/inside/';\n\n// Test trailing-slash - never (default)\npathname = '/path-a/trailing-slash/never';\npathname = '/path-a/trailing-slash/never/endpoint';\npathname = '/path-a/trailing-slash/never/layout/inside';\n\n// Test trailing-slash - always (endpoint) and never (page)\npathname = '/path-a/trailing-slash/mixed';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\npathname = '/path-a/trailing-slash/mixed/';\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/foo/[bar]/[baz]/+page.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/matcher-test/+page.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/matcher-test/no-matcher/[locale]/+page.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/matcher-test/with-matcher/[[locale=locale]]/+page.js",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/package.json",
    "content": "{\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"testtypes\": \"tsc\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/params/locale.js",
    "content": "/**\n * @param {string} param\n * @returns {param is \"en\" | \"nb\"}\n */\nexport const match = (param) => ['en', 'nb'].includes(param);\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/app-types/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"es2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../../../../../exports/public\"],\n\t\t\t\"types\": [\"../../../../../types/internal\"],\n\t\t\t\"$app/types\": [\"../../../../../types/ambient.d.ts\"]\n\t\t}\n\t},\n\t\"include\": [\"./**/*.js\", \"./**/*.ts\", \".svelte-kit/non-ambient.d.ts\"],\n\t\"exclude\": [\"..svelte-kit/**\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout/+layout.js",
    "content": "/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/layout/$types').LayoutLoad} */\nexport function load({ data }) {\n\tdata.server;\n\t// @ts-expect-error\n\tdata.shared;\n\treturn {\n\t\tshared: 'shared'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout/+layout.server.js",
    "content": "/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/layout/$types').LayoutServerLoad} */\nexport function load() {\n\treturn {\n\t\tserver: 'server'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout/+page.js",
    "content": "/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/layout/$types').PageLoad} */\nexport function load({ data }) {\n\tdata.pageServer;\n\t// @ts-expect-error\n\tdata.pageShared;\n\treturn {\n\t\tpageShared: 'pageShared'\n\t};\n}\n\n/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/layout/$types').PageData} */\nconst data = {\n\tshared: 'asd',\n\tpageShared: 'asd'\n};\ndata.shared;\ndata.pageShared;\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tpageServer: 'pageServer'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout/package.json",
    "content": "{\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"testtypes\": \"tsc\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"es2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../../../../../exports/public\"],\n\t\t\t\"types\": [\"../../../../../types/internal\"],\n\t\t\t\"$app/types\": [\"../../../../../types/ambient.d.ts\"]\n\t\t}\n\t},\n\t\"include\": [\"./**/*.js\", \"./**/*.ts\", \".svelte-kit/non-ambient.d.ts\"],\n\t\"exclude\": [\"..svelte-kit/**\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout-advanced/(main)/+layout.server.js",
    "content": "export function load() {\n\treturn {\n\t\tmain: 'main'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout-advanced/(main)/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout-advanced/(main)/+page.js",
    "content": "// test to see if layout adjusts correctly if +page.js exists, but no load function\n\n/** @type {import('../.svelte-kit/types/src/core/sync/write_types/test/layout-advanced/(main)/$types').PageData} */\nconst data = {\n\troot: ''\n};\ndata.root;\n// @ts-expect-error\ndata.main;\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout-advanced/(main)/+page@.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout-advanced/(main)/sub/+page.js",
    "content": "/** @type {import('../../.svelte-kit/types/src/core/sync/write_types/test/layout-advanced/(main)/sub/$types').PageLoad} */\nexport async function load({ parent }) {\n\tconst p = await parent();\n\tp.main;\n\tp.root;\n\t// @ts-expect-error\n\tp.sub;\n\treturn {\n\t\tsub: 'sub'\n\t};\n}\n\n/** @type {import('../../.svelte-kit/types/src/core/sync/write_types/test/layout-advanced/(main)/sub/$types').PageData} */\nconst data = {\n\tmain: '',\n\troot: '',\n\tsub: ''\n};\ndata.main;\ndata.root;\ndata.sub;\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout-advanced/(main)/sub/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout-advanced/+layout.js",
    "content": "export function load() {\n\treturn {\n\t\troot: 'root'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout-advanced/+layout.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout-advanced/package.json",
    "content": "{\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"testtypes\": \"tsc\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/layout-advanced/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"es2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../../../../../exports/public\"],\n\t\t\t\"types\": [\"../../../../../types/internal\"],\n\t\t\t\"$app/types\": [\"../../../../../types/ambient.d.ts\"]\n\t\t}\n\t},\n\t\"include\": [\"./**/*.js\", \"./**/*.ts\", \".svelte-kit/non-ambient.d.ts\"],\n\t\"exclude\": [\"..svelte-kit/**\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/param-type-inference/optional/[[optionalNarrowedParam=narrowed]]/+page.js",
    "content": "/* eslint-disable */\n\n/** @type {import('../../.svelte-kit/types/src/core/sync/write_types/test/param-type-inference/optional/[[optionalNarrowedParam=narrowed]]/$types').PageLoad} */\nexport function load({ params }) {\n\tif (params.optionalNarrowedParam) {\n\t\t/** @type {\"a\" | \"b\"} */\n\t\tlet a;\n\t\ta = params.optionalNarrowedParam;\n\t\treturn { a };\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/param-type-inference/package.json",
    "content": "{\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"testtypes\": \"tsc\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/param-type-inference/params/narrowed.js",
    "content": "/**\n * @param {string} param\n * @returns {param is \"a\" | \"b\"}\n */\nexport const match = (param) => ['a', 'b'].includes(param);\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/param-type-inference/params/not_narrowed.js",
    "content": "/* eslint-disable */\n\n/**\n * @param {string} param\n * @returns {boolean}\n */\nexport const match = (param) => true;\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/param-type-inference/required/+layout.js",
    "content": "/* eslint-disable */\n\n/** @type {import('../.svelte-kit/types/src/core/sync/write_types/test/param-type-inference/required/$types').LayoutLoad} */\nexport function load({ params }) {\n\tif (params.narrowedParam) {\n\t\t/** @type {\"a\" | \"b\"} */\n\t\tconst a = params.narrowedParam;\n\t}\n\n\tif (params.regularParam) {\n\t\t/** @type {\"a\" | \"b\"} */\n\t\tlet a;\n\n\t\t//@ts-expect-error\n\t\ta = params.regularParam;\n\n\t\t/** @type {string} b*/\n\t\tconst b = params.regularParam;\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/param-type-inference/required/[narrowedParam=narrowed]/+page.js",
    "content": "/* eslint-disable */\n\n/** @type {import('../../.svelte-kit/types/src/core/sync/write_types/test/param-type-inference/required/[narrowedParam=narrowed]/$types').PageLoad} */\nexport function load({ params }) {\n\t/** @type {\"a\" | \"b\"} */\n\tlet a;\n\ta = params.narrowedParam;\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/param-type-inference/required/[regularParam=not_narrowed]/+page.js",
    "content": "/* eslint-disable */\n\n/** @type {import('../../.svelte-kit/types/src/core/sync/write_types/test/param-type-inference/required/[regularParam=not_narrowed]/$types').PageLoad} */\nexport function load({ params }) {\n\t/** @type {string} a*/\n\tconst a = params.regularParam;\n\n\t/** @type {\"a\" | \"b\"} b*/\n\tlet b;\n\n\t//@ts-expect-error\n\tb = params.regularParam;\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/param-type-inference/spread/[...spread=narrowed]/+page.js",
    "content": "/* eslint-disable */\n\n/** @type {import('../../.svelte-kit/types/src/core/sync/write_types/test/param-type-inference/spread/[...spread=narrowed]/$types').PageLoad} */\nexport function load({ params }) {\n\t/** @type {\"a\" | \"b\"} */\n\tlet a;\n\ta = params.spread;\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/param-type-inference/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"es2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../../../../../exports/public\"],\n\t\t\t\"types\": [\"../../../../../types/internal\"],\n\t\t\t\"$app/types\": [\"../../../../../types/ambient.d.ts\"]\n\t\t}\n\t},\n\t\"include\": [\"./**/*.js\", \"./**/*.ts\", \".svelte-kit/non-ambient.d.ts\"],\n\t\"exclude\": [\"..svelte-kit/**\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-and-shared/+page.js",
    "content": "/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/simple-page-server-and-shared/$types').PageLoad} */\nexport function load({ data }) {\n\tdata.server;\n\t// @ts-expect-error\n\tdata.shared;\n\treturn {\n\t\tshared: 'shared'\n\t};\n}\n\n/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/simple-page-server-and-shared/$types').PageData} */\nconst data = {\n\tshared: 'asd'\n};\ndata.shared;\n// @ts-expect-error\ndata.server;\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-and-shared/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tserver: 'server'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-and-shared/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-and-shared/package.json",
    "content": "{\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"testtypes\": \"tsc\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-and-shared/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"es2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../../../../../exports/public\"],\n\t\t\t\"types\": [\"../../../../../types/internal\"],\n\t\t\t\"$app/types\": [\"../../../../../types/ambient.d.ts\"]\n\t\t}\n\t},\n\t\"include\": [\"./**/*.js\", \"./**/*.ts\", \".svelte-kit/non-ambient.d.ts\"],\n\t\"exclude\": [\"..svelte-kit/**\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-only/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tfoo: 'bar'\n\t};\n}\n\nexport const actions = {\n\tdefault: () => ({ action: 'bar' })\n};\n\n/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/simple-page-server-only/$types').PageData} */\nconst data = {\n\tfoo: 'asd'\n};\ndata.foo;\n// @ts-expect-error\ndata.bar;\n\n/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/simple-page-server-only/$types').ActionData} */\nconst actionData = { action: 'bar' };\nactionData.action;\n// @ts-expect-error\nactionData.foo;\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-only/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-only/package.json",
    "content": "{\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"testtypes\": \"tsc\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-only/sub/+page.server.js",
    "content": "/** @type {import('../.svelte-kit/types/src/core/sync/write_types/test/simple-page-server-only/sub/$types').PageServerLoad} */\nexport function load() {\n\tif (Math.random() > 0.5) {\n\t\treturn {\n\t\t\tfoo: 'bar'\n\t\t};\n\t}\n}\n\n/** @type {import('../.svelte-kit/types/src/core/sync/write_types/test/simple-page-server-only/sub/$types').PageData} */\nconst data = /** @type {any} */ ({\n\tfoo: 'bar'\n}); // the any cast prevents TypeScript from narrowing this to foo being defined\ndata.foo;\n// @ts-expect-error\ndata.foo.charAt(0);\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-only/sub/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-server-only/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"es2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../../../../../exports/public\"],\n\t\t\t\"types\": [\"../../../../../types/internal\"],\n\t\t\t\"$app/types\": [\"../../../../../types/ambient.d.ts\"]\n\t\t}\n\t},\n\t\"include\": [\"./**/*.js\", \"./**/*.ts\", \".svelte-kit/non-ambient.d.ts\"],\n\t\"exclude\": [\"..svelte-kit/**\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-shared-only/+page.js",
    "content": "export function load() {\n\treturn {\n\t\tshared: 'shared'\n\t};\n}\n\n/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/simple-page-shared-only/$types').PageData} */\nconst data = {\n\tshared: 'asd'\n};\ndata.shared;\n// @ts-expect-error\ndata.bar;\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-shared-only/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-shared-only/package.json",
    "content": "{\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"testtypes\": \"tsc\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-shared-only/sub/+page.js",
    "content": "/** @type {import('../.svelte-kit/types/src/core/sync/write_types/test/simple-page-shared-only/sub/$types').PageLoad} */\nexport function load() {\n\tif (Math.random() > 0.5) {\n\t\treturn {\n\t\t\tfoo: 'bar'\n\t\t};\n\t}\n}\n\n/** @type {import('../.svelte-kit/types/src/core/sync/write_types/test/simple-page-shared-only/sub/$types').PageData} */\nconst data = /** @type {any} */ ({\n\tfoo: 'bar'\n}); // the any cast prevents TypeScript from narrowing this to foo being defined\ndata.foo;\n// @ts-expect-error\ndata.foo.charAt(0);\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-shared-only/sub/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/simple-page-shared-only/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"es2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../../../../../exports/public\"],\n\t\t\t\"types\": [\"../../../../../types/internal\"],\n\t\t\t\"$app/types\": [\"../../../../../types/ambient.d.ts\"]\n\t\t}\n\t},\n\t\"include\": [\"./**/*.js\", \"./**/*.ts\", \".svelte-kit/non-ambient.d.ts\"],\n\t\"exclude\": [\"..svelte-kit/**\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs/+layout.js",
    "content": "/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/slugs/$types').LayoutLoad} */\nexport function load({ params }) {\n\tparams.optional;\n\tparams.rest;\n\tparams.slug;\n\t// @ts-expect-error\n\tparams.foo;\n\t// @ts-expect-error\n\tparams.optional.charAt(1);\n\t// @ts-expect-error\n\tparams.rest.charAt(1);\n\t// @ts-expect-error\n\tparams.slug.charAt(1);\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs/+layout.svelte",
    "content": "export function load() &lcub;&rcub;\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs/[...rest]/+page.js",
    "content": "/** @type {import('../.svelte-kit/types/src/core/sync/write_types/test/slugs/[...rest]/$types').PageLoad} */\nexport function load({ params }) {\n\tparams.rest.charAt(1);\n\t// @ts-expect-error\n\tparams.optional;\n\t// @ts-expect-error\n\tparams.slug;\n\n\treturn { rest: 'rest' };\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs/[...rest]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs/[slug]/+page.js",
    "content": "/** @type {import('../.svelte-kit/types/src/core/sync/write_types/test/slugs/[slug]/$types').PageLoad} */\nexport function load({ params }) {\n\tparams.slug.charAt(1);\n\t// @ts-expect-error\n\tparams.optional;\n\t// @ts-expect-error\n\tparams.rest;\n\n\treturn { slug: 'slug' };\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs/[slug]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs/package.json",
    "content": "{\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"testtypes\": \"tsc\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"es2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../../../../../exports/public\"],\n\t\t\t\"types\": [\"../../../../../types/internal\"],\n\t\t\t\"$app/types\": [\"../../../../../types/ambient.d.ts\"]\n\t\t}\n\t},\n\t\"include\": [\"./**/*.js\", \"./**/*.ts\", \".svelte-kit/non-ambient.d.ts\"],\n\t\"exclude\": [\"..svelte-kit/**\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs/x/[[optional]]/+page.js",
    "content": "/** @type {import('../../.svelte-kit/types/src/core/sync/write_types/test/slugs/x/[[optional]]/$types').PageLoad} */\nexport async function load({ parent, params }) {\n\tconst p = await parent();\n\t/** @type {NonNullable<typeof p>} */\n\tconst a = p;\n\t// @ts-expect-error\n\tp.foo;\n\t// @ts-expect-error\n\ta.foo;\n\n\tparams.optional;\n\tparams.optional?.charAt(1);\n\t// @ts-expect-error\n\tparams.optional.charAt(1);\n\t// @ts-expect-error\n\tparams.slug;\n\t// @ts-expect-error\n\tparams.rest;\n\n\treturn { optional: 'optional' };\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs/x/[[optional]]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/+layout.js",
    "content": "/** @type {import('./.svelte-kit/types/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/$types').LayoutLoad} */\nexport function load({ params }) {\n\tparams.rest;\n\tparams.slug;\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/+layout.svelte",
    "content": "export function load() &lcub;&rcub;\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/+layout.js",
    "content": "/** @type {import('../.svelte-kit/types/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/$types').LayoutLoad} */\nexport function load({ params }) {\n\tparams.rest;\n\t// @ts-expect-error\n\tparams.slug;\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/+layout.svelte",
    "content": "export function load() &lcub;&rcub;\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/[...rest]/+page.js",
    "content": "export function load() {\n\treturn { rest: 'rest' };\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/[...rest]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/[slug]/+page@.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/package.json",
    "content": "{\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"testtypes\": \"tsc\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"es2022\",\n\t\t\"moduleResolution\": \"bundler\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"../../../../../exports/public\"],\n\t\t\t\"types\": [\"../../../../../types/internal\"],\n\t\t\t\"$app/types\": [\"../../../../../types/ambient.d.ts\"]\n\t\t}\n\t},\n\t\"include\": [\"./**/*.js\", \"./**/*.ts\", \".svelte-kit/non-ambient.d.ts\"],\n\t\"exclude\": [\"..svelte-kit/**\"]\n}\n"
  },
  {
    "path": "packages/kit/src/core/utils.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\nimport colors from 'kleur';\nimport { posixify, to_fs } from '../utils/filesystem.js';\n\n/**\n * Resolved path of the `runtime` directory\n *\n * TODO Windows issue:\n * Vite or sth else somehow sets the driver letter inconsistently to lower or upper case depending on the run environment.\n * In playwright debug mode run through VS Code this a root-to-lowercase conversion is needed in order for the tests to run.\n * If we do this conversion in other cases it has the opposite effect though and fails.\n */\nexport const runtime_directory = posixify(fileURLToPath(new URL('../runtime', import.meta.url)));\n\n/**\n * This allows us to import SvelteKit internals that aren't exposed via `pkg.exports` in a\n * way that works whether `@sveltejs/kit` is installed inside the project's `node_modules`\n * or in a workspace root\n */\nexport const runtime_base = runtime_directory.startsWith(process.cwd())\n\t? `/${path.relative('.', runtime_directory)}`\n\t: to_fs(runtime_directory);\n\nfunction noop() {}\n\n/** @param {{ verbose: boolean }} opts */\nexport function logger({ verbose }) {\n\t/** @type {import('types').Logger} */\n\tconst log = (msg) => console.log(msg.replace(/^/gm, '  '));\n\n\t/** @param {string} msg */\n\tconst err = (msg) => console.error(msg.replace(/^/gm, '  '));\n\n\tlog.success = (msg) => log(colors.green(`✔ ${msg}`));\n\tlog.error = (msg) => err(colors.bold().red(msg));\n\tlog.warn = (msg) => log(colors.bold().yellow(msg));\n\n\tlog.minor = verbose ? (msg) => log(colors.grey(msg)) : noop;\n\tlog.info = verbose ? log : noop;\n\n\treturn log;\n}\n\n/** @param {import('types').ManifestData} manifest_data */\nexport function get_mime_lookup(manifest_data) {\n\t/** @type {Record<string, string>} */\n\tconst mime = {};\n\n\tmanifest_data.assets.forEach((asset) => {\n\t\tif (asset.type) {\n\t\t\tconst ext = path.extname(asset.file);\n\t\t\tmime[ext] = asset.type;\n\t\t}\n\t});\n\n\treturn mime;\n}\n\n/**\n * @param {string} dir\n * @param {(file: string) => boolean} [filter]\n */\nexport function list_files(dir, filter) {\n\t/** @type {string[]} */\n\tconst files = [];\n\n\t/** @param {string} current */\n\tfunction walk(current) {\n\t\tfor (const file of fs.readdirSync(path.resolve(dir, current))) {\n\t\t\tconst child = path.posix.join(current, file);\n\t\t\tif (fs.statSync(path.resolve(dir, child)).isDirectory()) {\n\t\t\t\twalk(child);\n\t\t\t} else {\n\t\t\t\tif (!filter || filter(child)) {\n\t\t\t\t\tfiles.push(child);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (fs.existsSync(dir)) walk('');\n\n\treturn files;\n}\n"
  },
  {
    "path": "packages/kit/src/exports/hooks/index.js",
    "content": "export { sequence } from './sequence.js';\n"
  },
  {
    "path": "packages/kit/src/exports/hooks/sequence.js",
    "content": "/** @import { Handle, RequestEvent, ResolveOptions } from '@sveltejs/kit' */\n/** @import { MaybePromise } from 'types' */\nimport {\n\tmerge_tracing,\n\tget_request_store,\n\twith_request_store\n} from '@sveltejs/kit/internal/server';\n\n/**\n * A helper function for sequencing multiple `handle` calls in a middleware-like manner.\n * The behavior for the `handle` options is as follows:\n * - `transformPageChunk` is applied in reverse order and merged\n * - `preload` is applied in forward order, the first option \"wins\" and no `preload` options after it are called\n * - `filterSerializedResponseHeaders` behaves the same as `preload`\n *\n * ```js\n * /// file: src/hooks.server.js\n * import { sequence } from '@sveltejs/kit/hooks';\n *\n * /// type: import('@sveltejs/kit').Handle\n * async function first({ event, resolve }) {\n * \tconsole.log('first pre-processing');\n * \tconst result = await resolve(event, {\n * \t\ttransformPageChunk: ({ html }) => {\n * \t\t\t// transforms are applied in reverse order\n * \t\t\tconsole.log('first transform');\n * \t\t\treturn html;\n * \t\t},\n * \t\tpreload: () => {\n * \t\t\t// this one wins as it's the first defined in the chain\n * \t\t\tconsole.log('first preload');\n * \t\t\treturn true;\n * \t\t}\n * \t});\n * \tconsole.log('first post-processing');\n * \treturn result;\n * }\n *\n * /// type: import('@sveltejs/kit').Handle\n * async function second({ event, resolve }) {\n * \tconsole.log('second pre-processing');\n * \tconst result = await resolve(event, {\n * \t\ttransformPageChunk: ({ html }) => {\n * \t\t\tconsole.log('second transform');\n * \t\t\treturn html;\n * \t\t},\n * \t\tpreload: () => {\n * \t\t\tconsole.log('second preload');\n * \t\t\treturn true;\n * \t\t},\n * \t\tfilterSerializedResponseHeaders: () => {\n * \t\t\t// this one wins as it's the first defined in the chain\n * \t\t\tconsole.log('second filterSerializedResponseHeaders');\n * \t\t\treturn true;\n * \t\t}\n * \t});\n * \tconsole.log('second post-processing');\n * \treturn result;\n * }\n *\n * export const handle = sequence(first, second);\n * ```\n *\n * The example above would print:\n *\n * ```\n * first pre-processing\n * first preload\n * second pre-processing\n * second filterSerializedResponseHeaders\n * second transform\n * first transform\n * second post-processing\n * first post-processing\n * ```\n *\n * @param {...Handle} handlers The chain of `handle` functions\n * @returns {Handle}\n */\nexport function sequence(...handlers) {\n\tconst length = handlers.length;\n\tif (!length) return ({ event, resolve }) => resolve(event);\n\n\treturn ({ event, resolve }) => {\n\t\tconst { state } = get_request_store();\n\t\treturn apply_handle(0, event, {});\n\n\t\t/**\n\t\t * @param {number} i\n\t\t * @param {RequestEvent} event\n\t\t * @param {ResolveOptions | undefined} parent_options\n\t\t * @returns {MaybePromise<Response>}\n\t\t */\n\t\tfunction apply_handle(i, event, parent_options) {\n\t\t\tconst handle = handlers[i];\n\n\t\t\treturn state.tracing.record_span({\n\t\t\t\tname: `sveltekit.handle.sequenced.${handle.name ? handle.name : i}`,\n\t\t\t\tattributes: {},\n\t\t\t\tfn: async (current) => {\n\t\t\t\t\tconst traced_event = merge_tracing(event, current);\n\t\t\t\t\treturn await with_request_store({ event: traced_event, state }, () =>\n\t\t\t\t\t\thandle({\n\t\t\t\t\t\t\tevent: traced_event,\n\t\t\t\t\t\t\tresolve: (event, options) => {\n\t\t\t\t\t\t\t\t/** @type {ResolveOptions['transformPageChunk']} */\n\t\t\t\t\t\t\t\tconst transformPageChunk = async ({ html, done }) => {\n\t\t\t\t\t\t\t\t\tif (options?.transformPageChunk) {\n\t\t\t\t\t\t\t\t\t\thtml = (await options.transformPageChunk({ html, done })) ?? '';\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (parent_options?.transformPageChunk) {\n\t\t\t\t\t\t\t\t\t\thtml = (await parent_options.transformPageChunk({ html, done })) ?? '';\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn html;\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t/** @type {ResolveOptions['filterSerializedResponseHeaders']} */\n\t\t\t\t\t\t\t\tconst filterSerializedResponseHeaders =\n\t\t\t\t\t\t\t\t\tparent_options?.filterSerializedResponseHeaders ??\n\t\t\t\t\t\t\t\t\toptions?.filterSerializedResponseHeaders;\n\n\t\t\t\t\t\t\t\t/** @type {ResolveOptions['preload']} */\n\t\t\t\t\t\t\t\tconst preload = parent_options?.preload ?? options?.preload;\n\n\t\t\t\t\t\t\t\treturn i < length - 1\n\t\t\t\t\t\t\t\t\t? apply_handle(i + 1, event, {\n\t\t\t\t\t\t\t\t\t\t\ttransformPageChunk,\n\t\t\t\t\t\t\t\t\t\t\tfilterSerializedResponseHeaders,\n\t\t\t\t\t\t\t\t\t\t\tpreload\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t: resolve(event, {\n\t\t\t\t\t\t\t\t\t\t\ttransformPageChunk,\n\t\t\t\t\t\t\t\t\t\t\tfilterSerializedResponseHeaders,\n\t\t\t\t\t\t\t\t\t\t\tpreload\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/exports/hooks/sequence.spec.js",
    "content": "/** @import { RequestEvent } from '@sveltejs/kit' */\n/** @import { RequestState } from 'types' */\nimport { assert, expect, test, vi } from 'vitest';\nimport { sequence } from './sequence.js';\nimport { installPolyfills } from '../node/polyfills.js';\nimport { noop_span } from '../../runtime/telemetry/noop.js';\n\nconst dummy_event = vi.hoisted(\n\t() =>\n\t\t/** @type {RequestEvent} */ ({\n\t\t\ttracing: {\n\t\t\t\troot: {}\n\t\t\t}\n\t\t})\n);\n\nvi.mock(import('@sveltejs/kit/internal/server'), async (actualPromise) => {\n\tconst actual = await actualPromise();\n\treturn {\n\t\t...actual,\n\t\tget_request_store: () => ({\n\t\t\tevent: dummy_event,\n\t\t\tstate: /** @type {RequestState} */ ({\n\t\t\t\ttracing: {\n\t\t\t\t\trecord_span: ({ fn }) => fn(noop_span)\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t};\n});\n\ninstallPolyfills();\n\ntest('applies handlers in sequence', async () => {\n\t/** @type {string[]} */\n\tconst order = [];\n\n\tconst handler = sequence(\n\t\tasync ({ event, resolve }) => {\n\t\t\torder.push('1a');\n\t\t\tconst response = await resolve(event);\n\t\t\torder.push('1b');\n\t\t\treturn response;\n\t\t},\n\t\tasync ({ event, resolve }) => {\n\t\t\torder.push('2a');\n\t\t\tconst response = await resolve(event);\n\t\t\torder.push('2b');\n\t\t\treturn response;\n\t\t},\n\t\tasync ({ event, resolve }) => {\n\t\t\torder.push('3a');\n\t\t\tconst response = await resolve(event);\n\t\t\torder.push('3b');\n\t\t\treturn response;\n\t\t}\n\t);\n\n\tconst response = new Response();\n\n\tassert.equal(await handler({ event: dummy_event, resolve: () => response }), response);\n\texpect(order).toEqual(['1a', '2a', '3a', '3b', '2b', '1b']);\n});\n\ntest('uses transformPageChunk option passed to non-terminal handle function', async () => {\n\tconst handler = sequence(\n\t\tasync ({ event, resolve }) => {\n\t\t\treturn resolve(event, {\n\t\t\t\ttransformPageChunk: ({ html, done }) => html + (done ? '-1-done' : '-1')\n\t\t\t});\n\t\t},\n\t\tasync ({ event, resolve }) => resolve(event),\n\t\tasync ({ event, resolve }) => resolve(event)\n\t);\n\n\tconst response = await handler({\n\t\tevent: dummy_event,\n\t\tresolve: async (_event, opts = {}) => {\n\t\t\tlet html = '';\n\n\t\t\tconst { transformPageChunk = ({ html }) => html } = opts;\n\n\t\t\thtml += await transformPageChunk({ html: '0', done: false });\n\t\t\thtml += await transformPageChunk({ html: ' 0', done: true });\n\n\t\t\treturn new Response(html);\n\t\t}\n\t});\n\n\tassert.equal(await response.text(), '0-1 0-1-done');\n});\n\ntest('merges transformPageChunk option', async () => {\n\tconst handler = sequence(\n\t\tasync ({ event, resolve }) => {\n\t\t\treturn resolve(event, {\n\t\t\t\ttransformPageChunk: ({ html, done }) => html + (done ? '-1-done' : '-1')\n\t\t\t});\n\t\t},\n\t\tasync ({ event, resolve }) => {\n\t\t\treturn resolve(event, {\n\t\t\t\ttransformPageChunk: ({ html, done }) => html + (done ? '-2-done' : '-2')\n\t\t\t});\n\t\t},\n\t\tasync ({ event, resolve }) => {\n\t\t\treturn resolve(event, {\n\t\t\t\ttransformPageChunk: ({ html, done }) => html + (done ? '-3-done' : '-3')\n\t\t\t});\n\t\t}\n\t);\n\n\tconst response = await handler({\n\t\tevent: dummy_event,\n\t\tresolve: async (_event, opts = {}) => {\n\t\t\tlet html = '';\n\n\t\t\tconst { transformPageChunk = ({ html }) => html } = opts;\n\n\t\t\thtml += await transformPageChunk({ html: '0', done: false });\n\t\t\thtml += await transformPageChunk({ html: ' 0', done: true });\n\n\t\t\treturn new Response(html);\n\t\t}\n\t});\n\n\tassert.equal(await response.text(), '0-3-2-1 0-3-done-2-done-1-done');\n});\n\ntest('uses first defined preload option', async () => {\n\tconst handler = sequence(\n\t\tasync ({ event, resolve }) => resolve(event),\n\t\tasync ({ event, resolve }) => {\n\t\t\treturn resolve(event, {\n\t\t\t\tpreload: ({ type }) => type === 'js'\n\t\t\t});\n\t\t},\n\t\tasync ({ event, resolve }) => {\n\t\t\treturn resolve(event, {\n\t\t\t\tpreload: () => true\n\t\t\t});\n\t\t}\n\t);\n\n\tconst response = await handler({\n\t\tevent: dummy_event,\n\t\tresolve: (_event, opts = {}) => {\n\t\t\tlet html = '';\n\n\t\t\tconst { preload = () => false } = opts;\n\n\t\t\thtml += preload({ path: '', type: 'js' });\n\t\t\thtml += preload({ path: '', type: 'css' });\n\n\t\t\treturn new Response(html);\n\t\t}\n\t});\n\n\tassert.equal(await response.text(), 'truefalse');\n});\n\ntest('uses first defined filterSerializedResponseHeaders option', async () => {\n\tconst handler = sequence(\n\t\tasync ({ event, resolve }) => resolve(event),\n\t\tasync ({ event, resolve }) => {\n\t\t\treturn resolve(event, {\n\t\t\t\tfilterSerializedResponseHeaders: (name) => name === 'a'\n\t\t\t});\n\t\t},\n\t\tasync ({ event, resolve }) => {\n\t\t\treturn resolve(event, {\n\t\t\t\tfilterSerializedResponseHeaders: () => true\n\t\t\t});\n\t\t}\n\t);\n\n\tconst response = await handler({\n\t\tevent: dummy_event,\n\t\tresolve: (_event, opts = {}) => {\n\t\t\tlet html = '';\n\n\t\t\tconst { filterSerializedResponseHeaders = () => false } = opts;\n\n\t\t\thtml += filterSerializedResponseHeaders('a', '');\n\t\t\thtml += filterSerializedResponseHeaders('b', '');\n\n\t\t\treturn new Response(html);\n\t\t}\n\t});\n\n\tassert.equal(await response.text(), 'truefalse');\n});\n"
  },
  {
    "path": "packages/kit/src/exports/index.js",
    "content": "/** @import { StandardSchemaV1 } from '@standard-schema/spec' */\n\nimport { HttpError, Redirect, ActionFailure, ValidationError } from './internal/index.js';\nimport { BROWSER, DEV } from 'esm-env';\nimport {\n\tadd_data_suffix,\n\tadd_resolution_suffix,\n\thas_data_suffix,\n\thas_resolution_suffix,\n\tstrip_data_suffix,\n\tstrip_resolution_suffix\n} from '../runtime/pathname.js';\nimport { text_encoder } from '../runtime/utils.js';\n\nexport { VERSION } from '../version.js';\n\n// TODO 3.0: remove these types as they are not used anymore (we can't remove them yet because that would be a breaking change)\n/**\n * @template {number} TNumber\n * @template {any[]} [TArray=[]]\n * @typedef {TNumber extends TArray['length'] ? TArray[number] : LessThan<TNumber, [...TArray, TArray['length']]>} LessThan\n */\n\n/**\n * @template {number} TStart\n * @template {number} TEnd\n * @typedef {Exclude<TEnd | LessThan<TEnd>, LessThan<TStart>>} NumericRange\n */\n\n// Keep the status codes as `number` because restricting to certain numbers makes it unnecessarily hard to use compared to the benefits\n// (we have runtime errors already to check for invalid codes). Also see https://github.com/sveltejs/kit/issues/11780\n\n// we have to repeat the JSDoc because the display for function overloads is broken\n// see https://github.com/microsoft/TypeScript/issues/55056\n\n/**\n * Throws an error with a HTTP status code and an optional message.\n * When called during request handling, this will cause SvelteKit to\n * return an error response without invoking `handleError`.\n * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.\n * @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.\n * @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.\n * @overload\n * @param {number} status\n * @param {App.Error} body\n * @return {never}\n * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling.\n * @throws {Error} If the provided status is invalid (not between 400 and 599).\n */\n/**\n * Throws an error with a HTTP status code and an optional message.\n * When called during request handling, this will cause SvelteKit to\n * return an error response without invoking `handleError`.\n * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.\n * @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.\n * @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.\n * @overload\n * @param {number} status\n * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} [body]\n * @return {never}\n * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling.\n * @throws {Error} If the provided status is invalid (not between 400 and 599).\n */\n/**\n * Throws an error with a HTTP status code and an optional message.\n * When called during request handling, this will cause SvelteKit to\n * return an error response without invoking `handleError`.\n * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.\n * @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.\n * @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.\n * @return {never}\n * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling.\n * @throws {Error} If the provided status is invalid (not between 400 and 599).\n */\nexport function error(status, body) {\n\tif ((!BROWSER || DEV) && (isNaN(status) || status < 400 || status > 599)) {\n\t\tthrow new Error(`HTTP error status codes must be between 400 and 599 — ${status} is invalid`);\n\t}\n\n\tthrow new HttpError(status, body);\n}\n\n/**\n * Checks whether this is an error thrown by {@link error}.\n * @template {number} T\n * @param {unknown} e\n * @param {T} [status] The status to filter for.\n * @return {e is (HttpError & { status: T extends undefined ? never : T })}\n */\nexport function isHttpError(e, status) {\n\tif (!(e instanceof HttpError)) return false;\n\treturn !status || e.status === status;\n}\n\n/**\n * Redirect a request. When called during request handling, SvelteKit will return a redirect response.\n * Make sure you're not catching the thrown redirect, which would prevent SvelteKit from handling it.\n *\n * Most common status codes:\n *  * `303 See Other`: redirect as a GET request (often used after a form POST request)\n *  * `307 Temporary Redirect`: redirect will keep the request method\n *  * `308 Permanent Redirect`: redirect will keep the request method, SEO will be transferred to the new page\n *\n * [See all redirect status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages)\n *\n * @param {300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number)} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308.\n * @param {string | URL} location The location to redirect to.\n * @throws {Redirect} This error instructs SvelteKit to redirect to the specified location.\n * @throws {Error} If the provided status is invalid.\n * @return {never}\n */\nexport function redirect(status, location) {\n\tif ((!BROWSER || DEV) && (isNaN(status) || status < 300 || status > 308)) {\n\t\tthrow new Error('Invalid status code');\n\t}\n\n\tthrow new Redirect(\n\t\t// @ts-ignore\n\t\tstatus,\n\t\tlocation.toString()\n\t);\n}\n\n/**\n * Checks whether this is a redirect thrown by {@link redirect}.\n * @param {unknown} e The object to check.\n * @return {e is Redirect}\n */\nexport function isRedirect(e) {\n\treturn e instanceof Redirect;\n}\n\n/**\n * Create a JSON `Response` object from the supplied data.\n * @param {any} data The value that will be serialized as JSON.\n * @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.\n */\nexport function json(data, init) {\n\t// TODO deprecate this in favour of `Response.json` when it's\n\t// more widely supported\n\tconst body = JSON.stringify(data);\n\n\t// we can't just do `text(JSON.stringify(data), init)` because\n\t// it will set a default `content-type` header. duplicated code\n\t// means less duplicated work\n\tconst headers = new Headers(init?.headers);\n\tif (!headers.has('content-length')) {\n\t\theaders.set('content-length', text_encoder.encode(body).byteLength.toString());\n\t}\n\n\tif (!headers.has('content-type')) {\n\t\theaders.set('content-type', 'application/json');\n\t}\n\n\treturn new Response(body, {\n\t\t...init,\n\t\theaders\n\t});\n}\n\n/**\n * Create a `Response` object from the supplied body.\n * @param {string} body The value that will be used as-is.\n * @param {ResponseInit} [init] Options such as `status` and `headers` that will be added to the response. A `Content-Length` header will be added automatically.\n */\nexport function text(body, init) {\n\tconst headers = new Headers(init?.headers);\n\tif (!headers.has('content-length')) {\n\t\tconst encoded = text_encoder.encode(body);\n\t\theaders.set('content-length', encoded.byteLength.toString());\n\t\treturn new Response(encoded, {\n\t\t\t...init,\n\t\t\theaders\n\t\t});\n\t}\n\n\treturn new Response(body, {\n\t\t...init,\n\t\theaders\n\t});\n}\n\n/**\n * Create an `ActionFailure` object. Call when form submission fails.\n * @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.\n * @overload\n * @param {number} status\n * @returns {import('./public.js').ActionFailure<undefined>}\n */\n/**\n * Create an `ActionFailure` object. Call when form submission fails.\n * @template [T=undefined]\n * @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.\n * @param {T} data Data associated with the failure (e.g. validation errors)\n * @overload\n * @param {number} status\n * @param {T} data\n * @returns {import('./public.js').ActionFailure<T>}\n */\n/**\n * Create an `ActionFailure` object. Call when form submission fails.\n * @param {number} status\n * @param {any} [data]\n * @returns {import('./public.js').ActionFailure<any>}\n */\nexport function fail(status, data) {\n\t// @ts-expect-error unique symbol missing\n\treturn new ActionFailure(status, data);\n}\n\n/**\n * Checks whether this is an action failure thrown by {@link fail}.\n * @param {unknown} e The object to check.\n * @return {e is import('./public.js').ActionFailure}\n */\nexport function isActionFailure(e) {\n\treturn e instanceof ActionFailure;\n}\n\n/**\n * Use this to throw a validation error to imperatively fail form validation.\n * Can be used in combination with `issue` passed to form actions to create field-specific issues.\n *\n * @example\n * ```ts\n * import { invalid } from '@sveltejs/kit';\n * import { form } from '$app/server';\n * import { tryLogin } from '$lib/server/auth';\n * import * as v from 'valibot';\n *\n * export const login = form(\n *   v.object({ name: v.string(), _password: v.string() }),\n *   async ({ name, _password }) => {\n *     const success = tryLogin(name, _password);\n *     if (!success) {\n *       invalid('Incorrect username or password');\n *     }\n *\n *     // ...\n *   }\n * );\n * ```\n * @param  {...(StandardSchemaV1.Issue | string)} issues\n * @returns {never}\n * @since 2.47.3\n */\nexport function invalid(...issues) {\n\tthrow new ValidationError(\n\t\tissues.map((issue) => (typeof issue === 'string' ? { message: issue } : issue))\n\t);\n}\n\n/**\n * Checks whether this is an validation error thrown by {@link invalid}.\n * @param {unknown} e The object to check.\n * @return {e is import('./public.js').ActionFailure}\n * @since 2.47.3\n */\nexport function isValidationError(e) {\n\treturn e instanceof ValidationError;\n}\n\n/**\n * Strips possible SvelteKit-internal suffixes and trailing slashes from the URL pathname.\n * Returns the normalized URL as well as a method for adding the potential suffix back\n * based on a new pathname (possibly including search) or URL.\n * ```js\n * import { normalizeUrl } from '@sveltejs/kit';\n *\n * const { url, denormalize } = normalizeUrl('/blog/post/__data.json');\n * console.log(url.pathname); // /blog/post\n * console.log(denormalize('/blog/post/a')); // /blog/post/a/__data.json\n * ```\n * @param {URL | string} url\n * @returns {{ url: URL, wasNormalized: boolean, denormalize: (url?: string | URL) => URL }}\n * @since 2.18.0\n */\nexport function normalizeUrl(url) {\n\turl = new URL(url, 'a://a');\n\n\tconst is_route_resolution = has_resolution_suffix(url.pathname);\n\tconst is_data_request = has_data_suffix(url.pathname);\n\tconst has_trailing_slash = url.pathname !== '/' && url.pathname.endsWith('/');\n\n\tif (is_route_resolution) {\n\t\turl.pathname = strip_resolution_suffix(url.pathname);\n\t} else if (is_data_request) {\n\t\turl.pathname = strip_data_suffix(url.pathname);\n\t} else if (has_trailing_slash) {\n\t\turl.pathname = url.pathname.slice(0, -1);\n\t}\n\n\treturn {\n\t\turl,\n\t\twasNormalized: is_data_request || is_route_resolution || has_trailing_slash,\n\t\tdenormalize: (new_url = url) => {\n\t\t\tnew_url = new URL(new_url, url);\n\t\t\tif (is_route_resolution) {\n\t\t\t\tnew_url.pathname = add_resolution_suffix(new_url.pathname);\n\t\t\t} else if (is_data_request) {\n\t\t\t\tnew_url.pathname = add_data_suffix(new_url.pathname);\n\t\t\t} else if (has_trailing_slash && !new_url.pathname.endsWith('/')) {\n\t\t\t\tnew_url.pathname += '/';\n\t\t\t}\n\t\t\treturn new_url;\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/exports/index.spec.js",
    "content": "import { normalizeUrl } from './index.js';\nimport { assert, describe, it } from 'vitest';\n\ndescribe('normalizeUrl', () => {\n\tit('noop for regular url', () => {\n\t\tconst original = new URL('http://example.com/foo/bar');\n\t\tconst { url, wasNormalized, denormalize } = normalizeUrl(original);\n\n\t\tassert.equal(wasNormalized, false);\n\t\tassert.equal(url.href, original.href);\n\t\tassert.equal(denormalize().href, original.href);\n\t\tassert.equal(denormalize('/baz').href, 'http://example.com/baz');\n\t\tassert.equal(\n\t\t\tdenormalize('?some=query#hash').href,\n\t\t\t'http://example.com/foo/bar?some=query#hash'\n\t\t);\n\t\tassert.equal(denormalize('http://somethingelse.com/').href, 'http://somethingelse.com/');\n\t\tassert.equal(\n\t\t\tdenormalize(new URL('http://somethingelse.com/')).href,\n\t\t\t'http://somethingelse.com/'\n\t\t);\n\t});\n\n\tit('should normalize trailing slash', () => {\n\t\tconst original = new URL('http://example.com/foo/bar/');\n\t\tconst { url, wasNormalized, denormalize } = normalizeUrl(original);\n\n\t\tassert.equal(wasNormalized, true);\n\t\tassert.equal(url.href, original.href.slice(0, -1));\n\t\tassert.equal(denormalize().href, original.href);\n\t\tassert.equal(denormalize('/baz').href, 'http://example.com/baz/');\n\t});\n\n\tit('should normalize data request route', () => {\n\t\tconst original = new URL('http://example.com/foo/__data.json');\n\t\tconst { url, wasNormalized, denormalize } = normalizeUrl(original);\n\n\t\tassert.equal(wasNormalized, true);\n\t\tassert.equal(url.href, 'http://example.com/foo');\n\t\tassert.equal(denormalize().href, original.href);\n\t\tassert.equal(denormalize('/baz').href, 'http://example.com/baz/__data.json');\n\t});\n\n\tit('should normalize route request route', () => {\n\t\tconst original = new URL('http://example.com/foo/__route.js');\n\t\tconst { url, wasNormalized, denormalize } = normalizeUrl(original);\n\n\t\tassert.equal(wasNormalized, true);\n\t\tassert.equal(url.href, 'http://example.com/foo');\n\t\tassert.equal(denormalize().href, original.href);\n\t\tassert.equal(denormalize('/baz').href, 'http://example.com/baz/__route.js');\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/exports/internal/event.js",
    "content": "/** @import { RequestEvent } from '@sveltejs/kit' */\n/** @import { RequestStore } from 'types' */\n/** @import { AsyncLocalStorage } from 'node:async_hooks' */\n\nimport { IN_WEBCONTAINER } from '../../runtime/server/constants.js';\n\n/** @type {RequestStore | null} */\nlet sync_store = null;\n\n/** @type {AsyncLocalStorage<RequestStore | null> | null} */\nlet als;\n\nimport('node:async_hooks')\n\t.then((hooks) => (als = new hooks.AsyncLocalStorage()))\n\t.catch(() => {\n\t\t// can't use AsyncLocalStorage, but can still call getRequestEvent synchronously.\n\t\t// this isn't behind `supports` because it's basically just StackBlitz (i.e.\n\t\t// in-browser usage) that doesn't support it AFAICT\n\t});\n\n/**\n * Returns the current `RequestEvent`. Can be used inside server hooks, server `load` functions, actions, and endpoints (and functions called by them).\n *\n * In environments without [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).\n * @since 2.20.0\n *\n * @returns {RequestEvent}\n */\nexport function getRequestEvent() {\n\tconst event = try_get_request_store()?.event;\n\n\tif (!event) {\n\t\tlet message =\n\t\t\t'Can only read the current request event inside functions invoked during `handle`, such as server `load` functions, actions, endpoints, and other server hooks.';\n\n\t\tif (!als) {\n\t\t\tmessage +=\n\t\t\t\t' In environments without `AsyncLocalStorage`, the event must be read synchronously, not after an `await`.';\n\t\t}\n\n\t\tthrow new Error(message);\n\t}\n\n\treturn event;\n}\n\nexport function get_request_store() {\n\tconst result = try_get_request_store();\n\tif (!result) {\n\t\tlet message = 'Could not get the request store.';\n\n\t\tif (als) {\n\t\t\tmessage += ' This is an internal error.';\n\t\t} else {\n\t\t\tmessage +=\n\t\t\t\t' In environments without `AsyncLocalStorage`, the request store (used by e.g. remote functions) must be accessed synchronously, not after an `await`.' +\n\t\t\t\t' If it was accessed synchronously then this is an internal error.';\n\t\t}\n\n\t\tthrow new Error(message);\n\t}\n\treturn result;\n}\n\nexport function try_get_request_store() {\n\treturn sync_store ?? als?.getStore() ?? null;\n}\n\n/**\n * @template T\n * @param {RequestStore | null} store\n * @param {() => T} fn\n */\nexport function with_request_store(store, fn) {\n\ttry {\n\t\tsync_store = store;\n\t\treturn als ? als.run(store, fn) : fn();\n\t} finally {\n\t\t// Since AsyncLocalStorage is not working in webcontainers, we don't reset `sync_store`\n\t\t// and handle only one request at a time in `src/runtime/server/index.js`.\n\t\tif (!IN_WEBCONTAINER) {\n\t\t\tsync_store = null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/exports/internal/index.js",
    "content": "/** @import { StandardSchemaV1 } from '@standard-schema/spec' */\n\nexport class HttpError {\n\t/**\n\t * @param {number} status\n\t * @param {{message: string} extends App.Error ? (App.Error | string | undefined) : App.Error} body\n\t */\n\tconstructor(status, body) {\n\t\tthis.status = status;\n\t\tif (typeof body === 'string') {\n\t\t\tthis.body = { message: body };\n\t\t} else if (body) {\n\t\t\tthis.body = body;\n\t\t} else {\n\t\t\tthis.body = { message: `Error: ${status}` };\n\t\t}\n\t}\n\n\ttoString() {\n\t\treturn JSON.stringify(this.body);\n\t}\n}\n\nexport class Redirect {\n\t/**\n\t * @param {300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308} status\n\t * @param {string} location\n\t */\n\tconstructor(status, location) {\n\t\tthis.status = status;\n\t\tthis.location = location;\n\t}\n}\n\n/**\n * 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.\n * `SvelteKitError` goes through `handleError`.\n * @extends Error\n */\nexport class SvelteKitError extends Error {\n\t/**\n\t * @param {number} status\n\t * @param {string} text\n\t * @param {string} message\n\t */\n\tconstructor(status, text, message) {\n\t\tsuper(message);\n\t\tthis.status = status;\n\t\tthis.text = text;\n\t}\n}\n\n/**\n * @template [T=undefined]\n */\nexport class ActionFailure {\n\t/**\n\t * @param {number} status\n\t * @param {T} data\n\t */\n\tconstructor(status, data) {\n\t\tthis.status = status;\n\t\tthis.data = data;\n\t}\n}\n\n/**\n * Error thrown when form validation fails imperatively\n */\nexport class ValidationError extends Error {\n\t/**\n\t * @param {StandardSchemaV1.Issue[]} issues\n\t */\n\tconstructor(issues) {\n\t\tsuper('Validation failed');\n\t\tthis.name = 'ValidationError';\n\t\tthis.issues = issues;\n\t}\n}\n\nexport { init_remote_functions } from './remote-functions.js';\n"
  },
  {
    "path": "packages/kit/src/exports/internal/remote-functions.js",
    "content": "/** @import { RemoteInternals } from 'types' */\n\n/** @type {RemoteInternals['type'][]} */\nconst types = ['command', 'form', 'prerender', 'query', 'query_batch'];\n\n/**\n * @param {Record<string, any>} module\n * @param {string} file\n * @param {string} hash\n */\nexport function init_remote_functions(module, file, hash) {\n\tif (module.default) {\n\t\tthrow new Error(\n\t\t\t`Cannot export \\`default\\` from a remote module (${file}) — please use named exports instead`\n\t\t);\n\t}\n\n\tfor (const [name, fn] of Object.entries(module)) {\n\t\tif (!types.includes(fn?.__?.type)) {\n\t\t\tthrow new Error(\n\t\t\t\t`\\`${name}\\` exported from ${file} is invalid — all exports from this file must be remote functions`\n\t\t\t);\n\t\t}\n\n\t\tfn.__.id = `${hash}/${name}`;\n\t\tfn.__.name = name;\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/exports/internal/server.js",
    "content": "/**\n * @template {{ tracing: { enabled: boolean, root: import('@opentelemetry/api').Span, current: import('@opentelemetry/api').Span } }} T\n * @param {T} event_like\n * @param {import('@opentelemetry/api').Span} current\n * @returns {T}\n */\nexport function merge_tracing(event_like, current) {\n\treturn {\n\t\t...event_like,\n\t\ttracing: {\n\t\t\t...event_like.tracing,\n\t\t\tcurrent\n\t\t}\n\t};\n}\n\nexport {\n\twith_request_store,\n\tgetRequestEvent,\n\tget_request_store,\n\ttry_get_request_store\n} from './event.js';\n"
  },
  {
    "path": "packages/kit/src/exports/node/index.js",
    "content": "import { createReadStream } from 'node:fs';\nimport { Readable } from 'node:stream';\nimport * as set_cookie_parser from 'set-cookie-parser';\nimport { SvelteKitError } from '../internal/index.js';\n\n/**\n * @param {import('http').IncomingMessage} req\n * @param {number} [body_size_limit]\n */\nfunction get_raw_body(req, body_size_limit) {\n\tconst h = req.headers;\n\n\tif (!h['content-type']) {\n\t\treturn null;\n\t}\n\n\tconst content_length = Number(h['content-length']);\n\n\t// check if no request body\n\tif (\n\t\t(req.httpVersionMajor === 1 && isNaN(content_length) && h['transfer-encoding'] == null) ||\n\t\tcontent_length === 0\n\t) {\n\t\treturn null;\n\t}\n\n\tif (req.destroyed) {\n\t\tconst readable = new ReadableStream();\n\t\tvoid readable.cancel();\n\t\treturn readable;\n\t}\n\n\tlet size = 0;\n\tlet cancelled = false;\n\n\treturn new ReadableStream({\n\t\tstart(controller) {\n\t\t\tif (body_size_limit !== undefined && content_length > body_size_limit) {\n\t\t\t\tlet message = `Content-length of ${content_length} exceeds limit of ${body_size_limit} bytes.`;\n\n\t\t\t\tif (body_size_limit === 0) {\n\t\t\t\t\t// https://github.com/sveltejs/kit/pull/11589\n\t\t\t\t\t// TODO this exists to aid migration — remove in a future version\n\t\t\t\t\tmessage += ' To disable body size limits, specify Infinity rather than 0.';\n\t\t\t\t}\n\n\t\t\t\tconst error = new SvelteKitError(413, 'Payload Too Large', message);\n\n\t\t\t\tcontroller.error(error);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treq.on('error', (error) => {\n\t\t\t\tcancelled = true;\n\t\t\t\tcontroller.error(error);\n\t\t\t});\n\n\t\t\treq.on('end', () => {\n\t\t\t\tif (cancelled) return;\n\t\t\t\tcontroller.close();\n\t\t\t});\n\n\t\t\treq.on('data', (chunk) => {\n\t\t\t\tif (cancelled) return;\n\n\t\t\t\tsize += chunk.length;\n\t\t\t\tif (size > content_length) {\n\t\t\t\t\tcancelled = true;\n\n\t\t\t\t\tconst constraint = content_length ? 'content-length' : 'BODY_SIZE_LIMIT';\n\t\t\t\t\tconst message = `request body size exceeded ${constraint} of ${content_length}`;\n\n\t\t\t\t\tconst error = new SvelteKitError(413, 'Payload Too Large', message);\n\t\t\t\t\tcontroller.error(error);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontroller.enqueue(chunk);\n\n\t\t\t\tif (controller.desiredSize === null || controller.desiredSize <= 0) {\n\t\t\t\t\treq.pause();\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tpull() {\n\t\t\treq.resume();\n\t\t},\n\n\t\tcancel(reason) {\n\t\t\tcancelled = true;\n\t\t\treq.destroy(reason);\n\t\t}\n\t});\n}\n\n/**\n * @param {{\n *   request: import('http').IncomingMessage;\n *   base: string;\n *   bodySizeLimit?: number;\n * }} options\n * @returns {Promise<Request>}\n */\n// TODO 3.0 make the signature synchronous?\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function getRequest({ request, base, bodySizeLimit }) {\n\tlet headers = /** @type {Record<string, string>} */ (request.headers);\n\tif (request.httpVersionMajor >= 2) {\n\t\t// the Request constructor rejects headers with ':' in the name\n\t\theaders = Object.assign({}, headers);\n\t\t// https://www.rfc-editor.org/rfc/rfc9113.html#section-8.3.1-2.3.5\n\t\tif (headers[':authority']) {\n\t\t\theaders.host = headers[':authority'];\n\t\t}\n\t\tdelete headers[':authority'];\n\t\tdelete headers[':method'];\n\t\tdelete headers[':path'];\n\t\tdelete headers[':scheme'];\n\t}\n\n\t// TODO: Whenever Node >=22 is minimum supported version, we can use `request.readableAborted`\n\t// @see https://github.com/nodejs/node/blob/5cf3c3e24c7257a0c6192ed8ef71efec8ddac22b/lib/internal/streams/readable.js#L1443-L1453\n\tconst controller = new AbortController();\n\tlet errored = false;\n\tlet end_emitted = false;\n\trequest.once('error', () => (errored = true));\n\trequest.once('end', () => (end_emitted = true));\n\trequest.once('close', () => {\n\t\tif ((errored || request.destroyed) && !end_emitted) {\n\t\t\tcontroller.abort();\n\t\t}\n\t});\n\n\treturn new Request(base + request.url, {\n\t\t// @ts-expect-error\n\t\tduplex: 'half',\n\t\tmethod: request.method,\n\t\theaders: Object.entries(headers),\n\t\tsignal: controller.signal,\n\t\tbody:\n\t\t\trequest.method === 'GET' || request.method === 'HEAD'\n\t\t\t\t? undefined\n\t\t\t\t: get_raw_body(request, bodySizeLimit)\n\t});\n}\n\n/**\n * @param {import('http').ServerResponse} res\n * @param {Response} response\n * @returns {Promise<void>}\n */\n// TODO 3.0 make the signature synchronous?\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function setResponse(res, response) {\n\tfor (const [key, value] of response.headers) {\n\t\ttry {\n\t\t\tres.setHeader(\n\t\t\t\tkey,\n\t\t\t\tkey === 'set-cookie'\n\t\t\t\t\t? set_cookie_parser.splitCookiesString(\n\t\t\t\t\t\t\t// This is absurd but necessary, TODO: investigate why\n\t\t\t\t\t\t\t/** @type {string}*/ (response.headers.get(key))\n\t\t\t\t\t\t)\n\t\t\t\t\t: value\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tres.getHeaderNames().forEach((name) => res.removeHeader(name));\n\t\t\tres.writeHead(500).end(String(error));\n\t\t\treturn;\n\t\t}\n\t}\n\n\tres.writeHead(response.status);\n\n\tif (!response.body) {\n\t\tres.end();\n\t\treturn;\n\t}\n\n\tif (response.body.locked) {\n\t\tres.end(\n\t\t\t'Fatal error: Response body is locked. ' +\n\t\t\t\t\"This can happen when the response was already read (for example through 'response.json()' or 'response.text()').\"\n\t\t);\n\t\treturn;\n\t}\n\n\tconst reader = response.body.getReader();\n\n\tif (res.destroyed) {\n\t\tvoid reader.cancel();\n\t\treturn;\n\t}\n\n\tconst cancel = (/** @type {Error|undefined} */ error) => {\n\t\tres.off('close', cancel);\n\t\tres.off('error', cancel);\n\n\t\t// If the reader has already been interrupted with an error earlier,\n\t\t// then it will appear here, it is useless, but it needs to be catch.\n\t\treader.cancel(error).catch(() => {});\n\t\tif (error) res.destroy(error);\n\t};\n\n\tres.on('close', cancel);\n\tres.on('error', cancel);\n\n\tvoid next();\n\tasync function next() {\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst { done, value } = await reader.read();\n\n\t\t\t\tif (done) break;\n\n\t\t\t\tif (!res.write(value)) {\n\t\t\t\t\tres.once('drain', next);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tres.end();\n\t\t} catch (error) {\n\t\t\tcancel(error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n}\n\n/**\n * Converts a file on disk to a readable stream\n * @param {string} file\n * @returns {ReadableStream}\n * @since 2.4.0\n */\nexport function createReadableStream(file) {\n\treturn /** @type {ReadableStream} */ (Readable.toWeb(createReadStream(file)));\n}\n"
  },
  {
    "path": "packages/kit/src/exports/node/polyfills.js",
    "content": "import buffer from 'node:buffer';\nimport { webcrypto as crypto } from 'node:crypto';\n\n// `buffer.File` was added in Node 18.13.0 while the `File` global was added in Node 20.0.0\nconst File = /** @type {import('node:buffer') & { File?: File}} */ (buffer).File;\n\n/** @type {Record<string, any>} */\nconst globals = {\n\tcrypto,\n\tFile\n};\n\n// exported for dev/preview and node environments\n/**\n * Make various web APIs available as globals:\n * - `crypto`\n * - `File`\n */\nexport function installPolyfills() {\n\tfor (const name in globals) {\n\t\tif (name in globalThis) continue;\n\n\t\tObject.defineProperty(globalThis, name, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t\tvalue: globals[name]\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/exports/public.d.ts",
    "content": "import 'svelte'; // pick up `declare module \"*.svelte\"`\nimport 'vite/client'; // pick up `declare module \"*.jpg\"`, etc.\nimport '../types/ambient.js';\n\nimport {\n\tAdapterEntry,\n\tCspDirectives,\n\tHttpMethod,\n\tLogger,\n\tMaybePromise,\n\tPrerendered,\n\tPrerenderEntryGeneratorMismatchHandlerValue,\n\tPrerenderHttpErrorHandlerValue,\n\tPrerenderMissingIdHandlerValue,\n\tPrerenderUnseenRoutesHandlerValue,\n\tPrerenderOption,\n\tRequestOptions,\n\tRouteSegment,\n\tDeepPartial,\n\tIsAny\n} from '../types/private.js';\nimport { BuildData, SSRNodeLoader, SSRRoute, ValidatedConfig } from 'types';\nimport { SvelteConfig } from '@sveltejs/vite-plugin-svelte';\nimport { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n\tRouteId as AppRouteId,\n\tLayoutParams as AppLayoutParams,\n\tResolvedPathname\n} from '$app/types';\n\nexport { PrerenderOption } from '../types/private.js';\n\n// @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore\ntype Span = import('@opentelemetry/api').Span;\n\n/**\n * [Adapters](https://svelte.dev/docs/kit/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.\n */\nexport interface Adapter {\n\t/**\n\t * The name of the adapter, using for logging. Will typically correspond to the package name.\n\t */\n\tname: string;\n\t/**\n\t * This function is called after SvelteKit has built your app.\n\t * @param builder An object provided by SvelteKit that contains methods for adapting the app\n\t */\n\tadapt: (builder: Builder) => MaybePromise<void>;\n\t/**\n\t * Checks called during dev and build to determine whether specific features will work in production with this adapter.\n\t */\n\tsupports?: {\n\t\t/**\n\t\t * Test support for `read` from `$app/server`.\n\t\t * @param details.config The merged route config\n\t\t */\n\t\tread?: (details: { config: any; route: { id: string } }) => boolean;\n\n\t\t/**\n\t\t * Test support for `instrumentation.server.js`. To pass, the adapter must support running `instrumentation.server.js` prior to the application code.\n\t\t * @since 2.31.0\n\t\t */\n\t\tinstrumentation?: () => boolean;\n\t};\n\t/**\n\t * Creates an `Emulator`, which allows the adapter to influence the environment\n\t * during dev, build and prerendering.\n\t */\n\temulate?: () => MaybePromise<Emulator>;\n}\n\nexport type LoadProperties<input extends Record<string, any> | void> = input extends void\n\t? undefined // needs to be undefined, because void will break intellisense\n\t: input extends Record<string, any>\n\t\t? input\n\t\t: unknown;\n\nexport type AwaitedActions<T extends Record<string, (...args: any) => any>> = OptionalUnion<\n\t{\n\t\t[Key in keyof T]: UnpackValidationError<Awaited<ReturnType<T[Key]>>>;\n\t}[keyof T]\n>;\n\n// Takes a union type and returns a union type where each type also has all properties\n// of all possible types (typed as undefined), making accessing them more ergonomic\ntype OptionalUnion<\n\tU extends Record<string, any>, // not unknown, else interfaces don't satisfy this constraint\n\tA extends keyof U = U extends U ? keyof U : never\n> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;\n\ndeclare const uniqueSymbol: unique symbol;\n\nexport interface ActionFailure<T = undefined> {\n\tstatus: number;\n\tdata: T;\n\t[uniqueSymbol]: true; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure\n}\n\ntype UnpackValidationError<T> =\n\tT extends ActionFailure<infer X>\n\t\t? X\n\t\t: T extends void\n\t\t\t? undefined // needs to be undefined, because void will corrupt union type\n\t\t\t: T;\n\n/**\n * This object is passed to the `adapt` function of adapters.\n * It contains various methods and properties that are useful for adapting the app.\n */\nexport interface Builder {\n\t/** Print messages to the console. `log.info` and `log.minor` are silent unless Vite's `logLevel` is `info`. */\n\tlog: Logger;\n\t/** Remove `dir` and all its contents. */\n\trimraf: (dir: string) => void;\n\t/** Create `dir` and any required parent directories. */\n\tmkdirp: (dir: string) => void;\n\n\t/** The fully resolved Svelte config. */\n\tconfig: ValidatedConfig;\n\t/** Information about prerendered pages and assets, if any. */\n\tprerendered: Prerendered;\n\t/** An array of all routes (including prerendered) */\n\troutes: RouteDefinition[];\n\n\t// TODO 3.0 remove this method\n\t/**\n\t * Create separate functions that map to one or more routes of your app.\n\t * @param fn A function that groups a set of routes into an entry point\n\t * @deprecated Use `builder.routes` instead\n\t */\n\tcreateEntries: (fn: (route: RouteDefinition) => AdapterEntry) => Promise<void>;\n\n\t/**\n\t * Find all the assets imported by server files belonging to `routes`\n\t */\n\tfindServerAssets: (routes: RouteDefinition[]) => string[];\n\n\t/**\n\t * Generate a fallback page for a static webserver to use when no route is matched. Useful for single-page apps.\n\t */\n\tgenerateFallback: (dest: string) => Promise<void>;\n\n\t/**\n\t * Generate a module exposing build-time environment variables as `$env/dynamic/public`.\n\t */\n\tgenerateEnvModule: () => void;\n\n\t/**\n\t * Generate a server-side manifest to initialise the SvelteKit [server](https://svelte.dev/docs/kit/@sveltejs-kit#Server) with.\n\t * @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\n\t */\n\tgenerateManifest: (opts: { relativePath: string; routes?: RouteDefinition[] }) => string;\n\n\t/**\n\t * Resolve a path to the `name` directory inside `outDir`, e.g. `/path/to/.svelte-kit/my-adapter`.\n\t * @param name path to the file, relative to the build directory\n\t */\n\tgetBuildDirectory: (name: string) => string;\n\t/** Get the fully resolved path to the directory containing client-side assets, including the contents of your `static` directory. */\n\tgetClientDirectory: () => string;\n\t/** Get the fully resolved path to the directory containing server-side code. */\n\tgetServerDirectory: () => string;\n\t/** Get the application path including any configured `base` path, e.g. `my-base-path/_app`. */\n\tgetAppPath: () => string;\n\n\t/**\n\t * Write client assets to `dest`.\n\t * @param dest the destination folder\n\t * @returns an array of files written to `dest`\n\t */\n\twriteClient: (dest: string) => string[];\n\t/**\n\t * Write prerendered files to `dest`.\n\t * @param dest the destination folder\n\t * @returns an array of files written to `dest`\n\t */\n\twritePrerendered: (dest: string) => string[];\n\t/**\n\t * Write server-side code to `dest`.\n\t * @param dest the destination folder\n\t * @returns an array of files written to `dest`\n\t */\n\twriteServer: (dest: string) => string[];\n\t/**\n\t * Copy a file or directory.\n\t * @param from the source file or directory\n\t * @param to the destination file or directory\n\t * @param opts.filter a function to determine whether a file or directory should be copied\n\t * @param opts.replace a map of strings to replace\n\t * @returns an array of files that were copied\n\t */\n\tcopy: (\n\t\tfrom: string,\n\t\tto: string,\n\t\topts?: {\n\t\t\tfilter?(basename: string): boolean;\n\t\t\treplace?: Record<string, string>;\n\t\t}\n\t) => string[];\n\n\t/**\n\t * Check if the server instrumentation file exists.\n\t * @returns true if the server instrumentation file exists, false otherwise\n\t * @since 2.31.0\n\t */\n\thasServerInstrumentationFile: () => boolean;\n\n\t/**\n\t * Instrument `entrypoint` with `instrumentation`.\n\t *\n\t * Renames `entrypoint` to `start` and creates a new module at\n\t * `entrypoint` which imports `instrumentation` and then dynamically imports `start`. This allows\n\t * the module hooks necessary for instrumentation libraries to be loaded prior to any application code.\n\t *\n\t * Caveats:\n\t * - \"Live exports\" will not work. If your adapter uses live exports, your users will need to manually import the server instrumentation on startup.\n\t * - If `tla` is `false`, OTEL auto-instrumentation may not work properly. Use it if your environment supports it.\n\t * - Use `hasServerInstrumentationFile` to check if the user has a server instrumentation file; if they don't, you shouldn't do this.\n\t *\n\t * @param options an object containing the following properties:\n\t * @param options.entrypoint the path to the entrypoint to trace.\n\t * @param options.instrumentation the path to the instrumentation file.\n\t * @param options.start the name of the start file. This is what `entrypoint` will be renamed to.\n\t * @param options.module configuration for the resulting entrypoint module.\n\t * @param options.module.exports\n\t * @param options.module.generateText a function that receives the relative paths to the instrumentation and start files, and generates the text of the module to be traced. If not provided, the default implementation will be used, which uses top-level await.\n\t * @since 2.31.0\n\t */\n\tinstrument: (args: {\n\t\tentrypoint: string;\n\t\tinstrumentation: string;\n\t\tstart?: string;\n\t\tmodule?:\n\t\t\t| {\n\t\t\t\t\texports: string[];\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\tgenerateText: (args: { instrumentation: string; start: string }) => string;\n\t\t\t  };\n\t}) => void;\n\n\t/**\n\t * Compress files in `directory` with gzip and brotli, where appropriate. Generates `.gz` and `.br` files alongside the originals.\n\t * @param {string} directory The directory containing the files to be compressed\n\t */\n\tcompress: (directory: string) => Promise<void>;\n}\n\n/**\n * An extension of [`vite-plugin-svelte`'s options](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#svelte-options).\n */\nexport interface Config extends SvelteConfig {\n\t/**\n\t * SvelteKit options.\n\t *\n\t * @see https://svelte.dev/docs/kit/configuration\n\t */\n\tkit?: KitConfig;\n\t/** Any additional options required by tooling that integrates with Svelte. */\n\t[key: string]: any;\n}\n\nexport interface Cookies {\n\t/**\n\t * Gets a cookie that was previously set with `cookies.set`, or from the request headers.\n\t * @param name the name of the cookie\n\t * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options)\n\t */\n\tget: (name: string, opts?: import('cookie').CookieParseOptions) => string | undefined;\n\n\t/**\n\t * Gets all cookies that were previously set with `cookies.set`, or from the request headers.\n\t * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options)\n\t */\n\tgetAll: (opts?: import('cookie').CookieParseOptions) => Array<{ name: string; value: string }>;\n\n\t/**\n\t * 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.\n\t *\n\t * 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`.\n\t *\n\t * 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\n\t * @param name the name of the cookie\n\t * @param value the cookie value\n\t * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options)\n\t */\n\tset: (\n\t\tname: string,\n\t\tvalue: string,\n\t\topts: import('cookie').CookieSerializeOptions & { path: string }\n\t) => void;\n\n\t/**\n\t * Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.\n\t *\n\t * 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\n\t * @param name the name of the cookie\n\t * @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)\n\t */\n\tdelete: (name: string, opts: import('cookie').CookieSerializeOptions & { path: string }) => void;\n\n\t/**\n\t * Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.\n\t *\n\t * 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`.\n\t *\n\t * 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\n\t *\n\t * @param name the name of the cookie\n\t * @param value the cookie value\n\t * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options)\n\t */\n\tserialize: (\n\t\tname: string,\n\t\tvalue: string,\n\t\topts: import('cookie').CookieSerializeOptions & { path: string }\n\t) => string;\n}\n\n/**\n * A collection of functions that influence the environment during dev, build and prerendering\n */\nexport interface Emulator {\n\t/**\n\t * A function that is called with the current route `config` and `prerender` option\n\t * and returns an `App.Platform` object\n\t */\n\tplatform?(details: { config: any; prerender: PrerenderOption }): MaybePromise<App.Platform>;\n}\n\nexport interface KitConfig {\n\t/**\n\t * Your [adapter](https://svelte.dev/docs/kit/adapters) is run when executing `vite build`. It determines how the output is converted for different platforms.\n\t * @default undefined\n\t */\n\tadapter?: Adapter;\n\t/**\n\t * An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript.\n\t *\n\t * ```js\n\t * /// file: svelte.config.js\n\t * /// type: import('@sveltejs/kit').Config\n\t * const config = {\n\t *   kit: {\n\t *     alias: {\n\t *       // this will match a file\n\t *       'my-file': 'path/to/my-file.js',\n\t *\n\t *       // this will match a directory and its contents\n\t *       // (`my-directory/x` resolves to `path/to/my-directory/x`)\n\t *       'my-directory': 'path/to/my-directory',\n\t *\n\t *       // an alias ending /* will only match\n\t *       // the contents of a directory, not the directory itself\n\t *       'my-directory/*': 'path/to/my-directory/*'\n\t *     }\n\t *   }\n\t * };\n\t * ```\n\t *\n\t * > [!NOTE] You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.\n\t * @default {}\n\t */\n\talias?: Record<string, string>;\n\t/**\n\t * The directory where SvelteKit keeps its stuff, including static assets (such as JS and CSS) and internally-used routes.\n\t *\n\t * If `paths.assets` is specified, there will be two app directories — `${paths.assets}/${appDir}` and `${paths.base}/${appDir}`.\n\t * @default \"_app\"\n\t */\n\tappDir?: string;\n\t/**\n\t * [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...\n\t *\n\t * ```js\n\t * /// file: svelte.config.js\n\t * /// type: import('@sveltejs/kit').Config\n\t * const config = {\n\t *   kit: {\n\t *     csp: {\n\t *       directives: {\n\t *         'script-src': ['self']\n\t *       },\n\t *       // must be specified with either the `report-uri` or `report-to` directives, or both\n\t *       reportOnly: {\n\t *         'script-src': ['self'],\n\t *         'report-uri': ['/']\n\t *       }\n\t *     }\n\t *   }\n\t * };\n\t *\n\t * export default config;\n\t * ```\n\t *\n\t * ...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.\n\t *\n\t * To add a nonce for scripts and links manually included in `src/app.html`, you may use the placeholder `%sveltekit.nonce%` (for example `<script nonce=\"%sveltekit.nonce%\">`).\n\t *\n\t * When pages are prerendered, the CSP header is added via a `<meta http-equiv>` tag (note that in this case, `frame-ancestors`, `report-uri` and `sandbox` directives will be ignored).\n\t *\n\t * > [!NOTE] When `mode` is `'auto'`, SvelteKit will use nonces for dynamically rendered pages and hashes for prerendered pages. Using nonces with prerendered pages is insecure and therefore forbidden.\n\t *\n\t * > [!NOTE] Note that most [Svelte transitions](https://svelte.dev/tutorial/svelte/transition) work by creating an inline `<style>` element. If you use these in your app, you must either leave the `style-src` directive unspecified or add `unsafe-inline`.\n\t *\n\t * If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle) to roll your own CSP.\n\t */\n\tcsp?: {\n\t\t/**\n\t\t * Whether to use hashes or nonces to restrict `<script>` and `<style>` elements. `'auto'` will use hashes for prerendered pages, and nonces for dynamically rendered pages.\n\t\t */\n\t\tmode?: 'hash' | 'nonce' | 'auto';\n\t\t/**\n\t\t * Directives that will be added to `Content-Security-Policy` headers.\n\t\t */\n\t\tdirectives?: CspDirectives;\n\t\t/**\n\t\t * Directives that will be added to `Content-Security-Policy-Report-Only` headers.\n\t\t */\n\t\treportOnly?: CspDirectives;\n\t};\n\t/**\n\t * Protection against [cross-site request forgery (CSRF)](https://owasp.org/www-community/attacks/csrf) attacks.\n\t */\n\tcsrf?: {\n\t\t/**\n\t\t * Whether to check the incoming `origin` header for `POST`, `PUT`, `PATCH`, or `DELETE` form submissions and verify that it matches the server's origin.\n\t\t *\n\t\t * To allow people to make `POST`, `PUT`, `PATCH`, or `DELETE` requests with a `Content-Type` of `application/x-www-form-urlencoded`, `multipart/form-data`, or `text/plain` to your app from other origins, you will need to disable this option. Be careful!\n\t\t * @default true\n\t\t * @deprecated Use `trustedOrigins: ['*']` instead\n\t\t */\n\t\tcheckOrigin?: boolean;\n\t\t/**\n\t\t * An array of origins that are allowed to make cross-origin form submissions to your app.\n\t\t *\n\t\t * Each origin should be a complete origin including protocol (e.g., `https://payment-gateway.com`).\n\t\t * This is useful for allowing trusted third-party services like payment gateways or authentication providers to submit forms to your app.\n\t\t *\n\t\t * If the array contains `'*'`, all origins will be trusted. This is generally not recommended!\n\t\t *\n\t\t * > [!NOTE] Only add origins you completely trust, as this bypasses CSRF protection for those origins.\n\t\t *\n\t\t * CSRF checks only apply in production, not in local development.\n\t\t * @default []\n\t\t * @example ['https://checkout.stripe.com', 'https://accounts.google.com']\n\t\t */\n\t\ttrustedOrigins?: string[];\n\t};\n\t/**\n\t * Whether or not the app is embedded inside a larger app. If `true`, SvelteKit will add its event listeners related to navigation etc on the parent of `%sveltekit.body%` instead of `window`, and will pass `params` from the server rather than inferring them from `location.pathname`.\n\t * Note that it is generally not supported to embed multiple SvelteKit apps on the same page and use client-side SvelteKit features within them (things such as pushing to the history state assume a single instance).\n\t * @default false\n\t */\n\tembedded?: boolean;\n\t/**\n\t * Environment variable configuration\n\t */\n\tenv?: {\n\t\t/**\n\t\t * The directory to search for `.env` files.\n\t\t * @default \".\"\n\t\t */\n\t\tdir?: string;\n\t\t/**\n\t\t * A prefix that signals that an environment variable is safe to expose to client-side code. See [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) and [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public). Note that Vite's [`envPrefix`](https://vitejs.dev/config/shared-options.html#envprefix) must be set separately if you are using Vite's environment variable handling - though use of that feature should generally be unnecessary.\n\t\t * @default \"PUBLIC_\"\n\t\t */\n\t\tpublicPrefix?: string;\n\t\t/**\n\t\t * A prefix that signals that an environment variable is unsafe to expose to client-side code. Environment variables matching neither the public nor the private prefix will be discarded completely. See [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) and [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private).\n\t\t * @default \"\"\n\t\t * @since 1.21.0\n\t\t */\n\t\tprivatePrefix?: string;\n\t};\n\t/** Experimental features. Here be dragons. These are not subject to semantic versioning, so breaking changes or removal can happen in any release. */\n\texperimental?: {\n\t\t/**\n\t\t * Options for enabling server-side [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions).\n\t\t * @default { server: false, serverFile: false }\n\t\t * @since 2.31.0\n\t\t */\n\t\ttracing?: {\n\t\t\t/**\n\t\t\t * Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions).\n\t\t\t * @default false\n\t\t\t * @since 2.31.0\n\t\t\t */\n\t\t\tserver?: boolean;\n\t\t};\n\n\t\t/**\n\t\t * @since 2.31.0\n\t\t */\n\t\tinstrumentation?: {\n\t\t\t/**\n\t\t\t * Enables `instrumentation.server.js` for tracing and observability instrumentation.\n\t\t\t * @default false\n\t\t\t * @since 2.31.0\n\t\t\t */\n\t\t\tserver?: boolean;\n\t\t};\n\n\t\t/**\n\t\t * Whether to enable the experimental remote functions feature. This feature is not yet stable and may be changed or removed at any time.\n\t\t * @default false\n\t\t */\n\t\tremoteFunctions?: boolean;\n\n\t\t/**\n\t\t * Whether to enable the experimental forked preloading feature using Svelte's fork API.\n\t\t * @default false\n\t\t */\n\t\tforkPreloads?: boolean;\n\n\t\t/**\n\t\t * Whether to enable the experimental handling of rendering errors.\n\t\t * When enabled, `<svelte:boundary>` is used to wrap components at each level\n\t\t * where there's an `+error.svelte`, rendering the error page if the component fails.\n\t\t * In addition, error boundaries also work on the server and the error object goes through `handleError`.\n\t\t * @default false\n\t\t */\n\t\thandleRenderingErrors?: boolean;\n\t};\n\t/**\n\t * Where to find various files within your project.\n\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t */\n\tfiles?: {\n\t\t/**\n\t\t * The location of your source code.\n\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t * @default \"src\"\n\t\t * @since 2.28\n\t\t */\n\t\tsrc?: string;\n\t\t/**\n\t\t * A place to put static files that should have stable URLs and undergo no processing, such as `favicon.ico` or `manifest.json`.\n\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t * @default \"static\"\n\t\t */\n\t\tassets?: string;\n\t\thooks?: {\n\t\t\t/**\n\t\t\t * The location of your client [hooks](https://svelte.dev/docs/kit/hooks).\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"src/hooks.client\"\n\t\t\t */\n\t\t\tclient?: string;\n\t\t\t/**\n\t\t\t * The location of your server [hooks](https://svelte.dev/docs/kit/hooks).\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"src/hooks.server\"\n\t\t\t */\n\t\t\tserver?: string;\n\t\t\t/**\n\t\t\t * The location of your universal [hooks](https://svelte.dev/docs/kit/hooks).\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"src/hooks\"\n\t\t\t * @since 2.3.0\n\t\t\t */\n\t\t\tuniversal?: string;\n\t\t};\n\t\t/**\n\t\t * Your app's internal library, accessible throughout the codebase as `$lib`.\n\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t * @default \"src/lib\"\n\t\t */\n\t\tlib?: string;\n\t\t/**\n\t\t * A directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching).\n\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t * @default \"src/params\"\n\t\t */\n\t\tparams?: string;\n\t\t/**\n\t\t * The files that define the structure of your app (see [Routing](https://svelte.dev/docs/kit/routing)).\n\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t * @default \"src/routes\"\n\t\t */\n\t\troutes?: string;\n\t\t/**\n\t\t * The location of your service worker's entry point (see [Service workers](https://svelte.dev/docs/kit/service-workers)).\n\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t * @default \"src/service-worker\"\n\t\t */\n\t\tserviceWorker?: string;\n\t\t/**\n\t\t * The location of the template for HTML responses.\n\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t * @default \"src/app.html\"\n\t\t */\n\t\tappTemplate?: string;\n\t\t/**\n\t\t * The location of the template for fallback error responses.\n\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t * @default \"src/error.html\"\n\t\t */\n\t\terrorTemplate?: string;\n\t};\n\t/**\n\t * Inline CSS inside a `<style>` block at the head of the HTML. This option is a number that specifies the maximum length of a CSS file in UTF-16 code units, as specified by the [String.length](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) property, to be inlined. All CSS files needed for the page that are smaller than this value are merged and inlined in a `<style>` block.\n\t *\n\t * > [!NOTE] This results in fewer initial requests and can improve your [First Contentful Paint](https://web.dev/first-contentful-paint) score. However, it generates larger HTML output and reduces the effectiveness of browser caches. Use it advisedly.\n\t * @default 0\n\t */\n\tinlineStyleThreshold?: number;\n\t/**\n\t * An array of file extensions that SvelteKit will treat as modules. Files with extensions that match neither `config.extensions` nor `config.kit.moduleExtensions` will be ignored by the router.\n\t * @default [\".js\", \".ts\"]\n\t */\n\tmoduleExtensions?: string[];\n\t/**\n\t * The directory that SvelteKit writes files to during `dev` and `build`. You should exclude this directory from version control.\n\t * @default \".svelte-kit\"\n\t */\n\toutDir?: string;\n\t/**\n\t * Options related to the build output format\n\t */\n\toutput?: {\n\t\t/**\n\t\t * SvelteKit will preload the JavaScript modules needed for the initial page to avoid import 'waterfalls', resulting in faster application startup. There\n\t\t * are three strategies with different trade-offs:\n\t\t * - `modulepreload` - uses `<link rel=\"modulepreload\">`. This delivers the best results in Chromium-based browsers, in Firefox 115+, and Safari 17+. It is ignored in older browsers.\n\t\t * - `preload-js` - uses `<link rel=\"preload\">`. Prevents waterfalls in Chromium and Safari, but Chromium will parse each module twice (once as a script, once as a module). Causes modules to be requested twice in Firefox. This is a good setting if you want to maximise performance for users on iOS devices at the cost of a very slight degradation for Chromium users.\n\t\t * - `preload-mjs` - uses `<link rel=\"preload\">` but with the `.mjs` extension which prevents double-parsing in Chromium. Some static webservers will fail to serve .mjs files with a `Content-Type: application/javascript` header, which will cause your application to break. If that doesn't apply to you, this is the option that will deliver the best performance for the largest number of users, until `modulepreload` is more widely supported.\n\t\t * @default \"modulepreload\"\n\t\t * @since 1.8.4\n\t\t */\n\t\tpreloadStrategy?: 'modulepreload' | 'preload-js' | 'preload-mjs';\n\t\t/**\n\t\t * The bundle strategy option affects how your app's JavaScript and CSS files are loaded.\n\t\t * - If `'split'`, splits the app up into multiple .js/.css files so that they are loaded lazily as the user navigates around the app. This is the default, and is recommended for most scenarios.\n\t\t * - If `'single'`, creates just one .js bundle and one .css file containing code for the entire app.\n\t\t * - If `'inline'`, inlines all JavaScript and CSS of the entire app into the HTML. The result is usable without a server (i.e. you can just open the file in your browser).\n\t\t *\n\t\t * When using `'split'`, you can also adjust the bundling behaviour by setting [`output.experimentalMinChunkSize`](https://rollupjs.org/configuration-options/#output-experimentalminchunksize) and [`output.manualChunks`](https://rollupjs.org/configuration-options/#output-manualchunks) inside your Vite config's [`build.rollupOptions`](https://vite.dev/config/build-options.html#build-rollupoptions).\n\t\t *\n\t\t * If you want to inline your assets, you'll need to set Vite's [`build.assetsInlineLimit`](https://vite.dev/config/build-options.html#build-assetsinlinelimit) option to an appropriate size then import your assets through Vite.\n\t\t *\n\t\t * ```js\n\t\t * /// file: vite.config.js\n\t\t * import { sveltekit } from '@sveltejs/kit/vite';\n\t\t * import { defineConfig } from 'vite';\n\t\t *\n\t\t * export default defineConfig({\n\t\t *   plugins: [sveltekit()],\n\t\t *   build: {\n\t\t *     // inline all imported assets\n\t\t *     assetsInlineLimit: Infinity\n\t\t *   }\n\t\t * });\n\t\t * ```\n\t\t *\n\t\t * ```svelte\n\t\t * /// file: src/routes/+layout.svelte\n\t\t * <script>\n\t\t *   // import the asset through Vite\n\t\t *   import favicon from './favicon.png';\n\t\t * </script>\n\t\t *\n\t\t * <svelte:head>\n\t\t *   <!-- this asset will be inlined as a base64 URL -->\n\t\t *   <link rel=\"icon\" href={favicon} />\n\t\t * </svelte:head>\n\t\t * ```\n\t\t * @default 'split'\n\t\t * @since 2.13.0\n\t\t */\n\t\tbundleStrategy?: 'split' | 'single' | 'inline';\n\t};\n\tpaths?: {\n\t\t/**\n\t\t * An absolute path that your app's files are served from. This is useful if your files are served from a storage bucket of some kind.\n\t\t * @default \"\"\n\t\t */\n\t\tassets?: '' | `http://${string}` | `https://${string}`;\n\t\t/**\n\t\t * A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`base` from `$app/paths`](https://svelte.dev/docs/kit/$app-paths#base) for that: `<a href=\"{base}/your-page\">Link</a>`. If you find yourself writing this often, it may make sense to extract this into a reusable component.\n\t\t * @default \"\"\n\t\t */\n\t\tbase?: '' | `/${string}`;\n\t\t/**\n\t\t * Whether to use relative asset paths.\n\t\t *\n\t\t * If `true`, `base` and `assets` imported from `$app/paths` will be replaced with relative asset paths during server-side rendering, resulting in more portable HTML.\n\t\t * If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL\n\t\t *\n\t\t * [Single-page app](https://svelte.dev/docs/kit/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.\n\t\t *\n\t\t * If your app uses a `<base>` element, you should set this to `false`, otherwise asset URLs will incorrectly be resolved against the `<base>` URL rather than the current page.\n\t\t *\n\t\t * In 1.0, `undefined` was a valid value, which was set by default. In that case, if `paths.assets` was not external, SvelteKit would replace `%sveltekit.assets%` with a relative path and use relative paths to reference build artifacts, but `base` and `assets` imported from `$app/paths` would be as specified in your config.\n\t\t *\n\t\t * @default true\n\t\t * @since 1.9.0\n\t\t */\n\t\trelative?: boolean;\n\t};\n\t/**\n\t * See [Prerendering](https://svelte.dev/docs/kit/page-options#prerender).\n\t */\n\tprerender?: {\n\t\t/**\n\t\t * How many pages can be prerendered simultaneously. JS is single-threaded, but in cases where prerendering performance is network-bound (for example loading content from a remote CMS) this can speed things up by processing other tasks while waiting on the network response.\n\t\t * @default 1\n\t\t */\n\t\tconcurrency?: number;\n\t\t/**\n\t\t * Whether SvelteKit should find pages to prerender by following links from `entries`.\n\t\t * @default true\n\t\t */\n\t\tcrawl?: boolean;\n\t\t/**\n\t\t * An array of pages to prerender, or start crawling from (if `crawl: true`). The `*` string includes all routes containing no required `[parameters]`  with optional parameters included as being empty (since SvelteKit doesn't know what value any parameters should have).\n\t\t * @default [\"*\"]\n\t\t */\n\t\tentries?: Array<'*' | `/${string}`>;\n\t\t/**\n\t\t * How to respond to HTTP errors encountered while prerendering the app.\n\t\t *\n\t\t * - `'fail'` — fail the build\n\t\t * - `'ignore'` - silently ignore the failure and continue\n\t\t * - `'warn'` — continue, but print a warning\n\t\t * - `(details) => void` — a custom error handler that takes a `details` object with `status`, `path`, `referrer`, `referenceType` and `message` properties. If you `throw` from this function, the build will fail\n\t\t *\n\t\t * ```js\n\t\t * /// file: svelte.config.js\n\t\t * /// type: import('@sveltejs/kit').Config\n\t\t * const config = {\n\t\t *   kit: {\n\t\t *     prerender: {\n\t\t *       handleHttpError: ({ path, referrer, message }) => {\n\t\t *         // ignore deliberate link to shiny 404 page\n\t\t *         if (path === '/not-found' && referrer === '/blog/how-we-built-our-404-page') {\n\t\t *           return;\n\t\t *         }\n\t\t *\n\t\t *         // otherwise fail the build\n\t\t *         throw new Error(message);\n\t\t *       }\n\t\t *     }\n\t\t *   }\n\t\t * };\n\t\t * ```\n\t\t *\n\t\t * @default \"fail\"\n\t\t * @since 1.15.7\n\t\t */\n\t\thandleHttpError?: PrerenderHttpErrorHandlerValue;\n\t\t/**\n\t\t * How to respond when hash links from one prerendered page to another don't correspond to an `id` on the destination page.\n\t\t *\n\t\t * - `'fail'` — fail the build\n\t\t * - `'ignore'` - silently ignore the failure and continue\n\t\t * - `'warn'` — continue, but print a warning\n\t\t * - `(details) => void` — a custom error handler that takes a `details` object with `path`, `id`, `referrers` and `message` properties. If you `throw` from this function, the build will fail\n\t\t *\n\t\t * @default \"fail\"\n\t\t * @since 1.15.7\n\t\t */\n\t\thandleMissingId?: PrerenderMissingIdHandlerValue;\n\t\t/**\n\t\t * How to respond when an entry generated by the `entries` export doesn't match the route it was generated from.\n\t\t *\n\t\t * - `'fail'` — fail the build\n\t\t * - `'ignore'` - silently ignore the failure and continue\n\t\t * - `'warn'` — continue, but print a warning\n\t\t * - `(details) => void` — a custom error handler that takes a `details` object with `generatedFromId`, `entry`, `matchedId` and `message` properties. If you `throw` from this function, the build will fail\n\t\t *\n\t\t * @default \"fail\"\n\t\t * @since 1.16.0\n\t\t */\n\t\thandleEntryGeneratorMismatch?: PrerenderEntryGeneratorMismatchHandlerValue;\n\t\t/**\n\t\t * How to respond when a route is marked as prerenderable but has not been prerendered.\n\t\t *\n\t\t * - `'fail'` — fail the build\n\t\t * - `'ignore'` - silently ignore the failure and continue\n\t\t * - `'warn'` — continue, but print a warning\n\t\t * - `(details) => void` — a custom error handler that takes a `details` object with a `routes` property which contains all routes that haven't been prerendered. If you `throw` from this function, the build will fail\n\t\t *\n\t\t * The default behavior is to fail the build. This may be undesirable when you know that some of your routes may never be reached under certain\n\t\t * circumstances such as a CMS not returning data for a specific area, resulting in certain routes never being reached.\n\t\t *\n\t\t * @default \"fail\"\n\t\t * @since 2.16.0\n\t\t */\n\t\thandleUnseenRoutes?: PrerenderUnseenRoutesHandlerValue;\n\t\t/**\n\t\t * The value of `url.origin` during prerendering; useful if it is included in rendered content.\n\t\t * @default \"http://sveltekit-prerender\"\n\t\t */\n\t\torigin?: string;\n\t};\n\trouter?: {\n\t\t/**\n\t\t * What type of client-side router to use.\n\t\t * - `'pathname'` is the default and means the current URL pathname determines the route\n\t\t * - `'hash'` means the route is determined by `location.hash`. In this case, SSR and prerendering are disabled. This is only recommended if `pathname` is not an option, for example because you don't control the webserver where your app is deployed.\n\t\t *   It comes with some caveats: you can't use server-side rendering (or indeed any server logic), and you have to make sure that the links in your app all start with #/, or they won't work. Beyond that, everything works exactly like a normal SvelteKit app.\n\t\t *\n\t\t * @default \"pathname\"\n\t\t * @since 2.14.0\n\t\t */\n\t\ttype?: 'pathname' | 'hash';\n\t\t/**\n\t\t * How to determine which route to load when navigating to a new page.\n\t\t *\n\t\t * By default, SvelteKit will serve a route manifest to the browser.\n\t\t * When navigating, this manifest is used (along with the `reroute` hook, if it exists) to determine which components to load and which `load` functions to run.\n\t\t * Because everything happens on the client, this decision can be made immediately. The drawback is that the manifest needs to be\n\t\t * loaded and parsed before the first navigation can happen, which may have an impact if your app contains many routes.\n\t\t *\n\t\t * Alternatively, SvelteKit can determine the route on the server. This means that for every navigation to a path that has not yet been visited, the server will be asked to determine the route.\n\t\t * This has several advantages:\n\t\t * - The client does not need to load the routing manifest upfront, which can lead to faster initial page loads\n\t\t * - The list of routes is hidden from public view\n\t\t * - The server has an opportunity to intercept each navigation (for example through a middleware), enabling (for example) A/B testing opaque to SvelteKit\n\n\t\t * The drawback is that for unvisited paths, resolution will take slightly longer (though this is mitigated by [preloading](https://svelte.dev/docs/kit/link-options#data-sveltekit-preload-data)).\n\t\t *\n\t\t * > [!NOTE] When using server-side route resolution and prerendering, the resolution is prerendered along with the route itself.\n\t\t *\n\t\t * @default \"client\"\n\t\t * @since 2.17.0\n\t\t */\n\t\tresolution?: 'client' | 'server';\n\t};\n\tserviceWorker?: {\n\t\t/**\n\t\t * Determine which files in your `static` directory will be available in `$service-worker.files`.\n\t\t * @default (filename) => !/\\.DS_Store/.test(filename)\n\t\t */\n\t\tfiles?: (file: string) => boolean;\n\t} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Whether to automatically register the service worker, if it exists.\n\t\t\t\t * @default true\n\t\t\t\t */\n\t\t\t\tregister: true;\n\t\t\t\t/**\n\t\t\t\t * Options for serviceWorker.register(\"...\", options);\n\t\t\t\t */\n\t\t\t\toptions?: RegistrationOptions;\n\t\t  }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Whether to automatically register the service worker, if it exists.\n\t\t\t\t * @default true\n\t\t\t\t */\n\t\t\t\tregister?: false;\n\t\t  }\n\t);\n\ttypescript?: {\n\t\t/**\n\t\t * A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.\n\t\t * This is useful for extending a shared `tsconfig.json` in a monorepo root, for example.\n\t\t *\n\t\t * Note that any paths configured here should be relative to the generated config file, which is written to `.svelte-kit/tsconfig.json`.\n\t\t *\n\t\t * @default (config) => config\n\t\t * @since 1.3.0\n\t\t */\n\t\tconfig?: (config: Record<string, any>) => Record<string, any> | void;\n\t};\n\t/**\n\t * Client-side navigation can be buggy if you deploy a new version of your app while people are using it. If the code for the new page is already loaded, it may have stale content; if it isn't, the app's route manifest may point to a JavaScript file that no longer exists.\n\t * SvelteKit helps you solve this problem through version management.\n\t * If SvelteKit encounters an error while loading the page and detects that a new version has been deployed (using the `name` specified here, which defaults to a timestamp of the build) it will fall back to traditional full-page navigation.\n\t * Not all navigations will result in an error though, for example if the JavaScript for the next page is already loaded. If you still want to force a full-page navigation in these cases, use techniques such as setting the `pollInterval` and then using `beforeNavigate`:\n\t * ```html\n\t * /// file: +layout.svelte\n\t * <script>\n\t *   import { beforeNavigate } from '$app/navigation';\n\t *   import { updated } from '$app/state';\n\t *\n\t *   beforeNavigate(({ willUnload, to }) => {\n\t *     if (updated.current && !willUnload && to?.url) {\n\t *       location.href = to.url.href;\n\t *     }\n\t *   });\n\t * </script>\n\t * ```\n\t *\n\t * If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of [`updated.current`](https://svelte.dev/docs/kit/$app-state#updated) `true` when it detects one.\n\t */\n\tversion?: {\n\t\t/**\n\t\t * 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.\n\t\t *\n\t\t * For example, to use the current commit hash, you could do use `git rev-parse HEAD`:\n\t\t *\n\t\t * ```js\n\t\t * /// file: svelte.config.js\n\t\t * import * as child_process from 'node:child_process';\n\t\t *\n\t\t * export default {\n\t\t *   kit: {\n\t\t *     version: {\n\t\t *       name: child_process.execSync('git rev-parse HEAD').toString().trim()\n\t\t *     }\n\t\t *   }\n\t\t * };\n\t\t * ```\n\t\t */\n\t\tname?: string;\n\t\t/**\n\t\t * The interval in milliseconds to poll for version changes. If this is `0`, no polling occurs.\n\t\t * @default 0\n\t\t */\n\t\tpollInterval?: number;\n\t};\n}\n\n/**\n * The [`handle`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle) hook runs every time the SvelteKit server receives a [request](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Request) and\n * determines the [response](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Response).\n * It receives an `event` object representing the request and a function called `resolve`, which renders the route and generates a `Response`.\n * This allows you to modify response headers or bodies, or bypass SvelteKit entirely (for implementing routes programmatically, for example).\n */\nexport type Handle = (input: {\n\tevent: RequestEvent;\n\tresolve: (event: RequestEvent, opts?: ResolveOptions) => MaybePromise<Response>;\n}) => MaybePromise<Response>;\n\n/**\n * The server-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while responding to a request.\n *\n * If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event.\n * Make sure that this function _never_ throws an error.\n */\nexport type HandleServerError = (input: {\n\terror: unknown;\n\tevent: RequestEvent;\n\tstatus: number;\n\tmessage: string;\n}) => MaybePromise<void | App.Error>;\n\n/**\n * The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleValidationError) hook runs when the argument to a remote function fails validation.\n *\n * It will be called with the validation issues and the event, and must return an object shape that matches `App.Error`.\n */\nexport type HandleValidationError<Issue extends StandardSchemaV1.Issue = StandardSchemaV1.Issue> =\n\t(input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<App.Error>;\n\n/**\n * The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while navigating.\n *\n * If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event.\n * Make sure that this function _never_ throws an error.\n */\nexport type HandleClientError = (input: {\n\terror: unknown;\n\tevent: NavigationEvent;\n\tstatus: number;\n\tmessage: string;\n}) => MaybePromise<void | App.Error>;\n\n/**\n * The [`handleFetch`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleFetch) hook allows you to modify (or replace) the result of an [`event.fetch`](https://svelte.dev/docs/kit/load#Making-fetch-requests) call that runs on the server (or during prerendering) inside an endpoint, `load`, `action`, `handle`, `handleError` or `reroute`.\n */\nexport type HandleFetch = (input: {\n\tevent: RequestEvent;\n\trequest: Request;\n\tfetch: typeof fetch;\n}) => MaybePromise<Response>;\n\n/**\n * The [`init`](https://svelte.dev/docs/kit/hooks#Shared-hooks-init) will be invoked before the server responds to its first request\n * @since 2.10.0\n */\nexport type ServerInit = () => MaybePromise<void>;\n\n/**\n * The [`init`](https://svelte.dev/docs/kit/hooks#Shared-hooks-init) will be invoked once the app starts in the browser\n * @since 2.10.0\n */\nexport type ClientInit = () => MaybePromise<void>;\n\n/**\n * The [`reroute`](https://svelte.dev/docs/kit/hooks#Universal-hooks-reroute) hook allows you to modify the URL before it is used to determine which route to render.\n * @since 2.3.0\n */\nexport type Reroute = (event: { url: URL; fetch: typeof fetch }) => MaybePromise<void | string>;\n\n/**\n * The [`transport`](https://svelte.dev/docs/kit/hooks#Universal-hooks-transport) hook allows you to transport custom types across the server/client boundary.\n *\n * Each transporter has a pair of `encode` and `decode` functions. On the server, `encode` determines whether a value is an instance of the custom type and, if so, returns a non-falsy encoding of the value which can be an object or an array (or `false` otherwise).\n *\n * In the browser, `decode` turns the encoding back into an instance of the custom type.\n *\n * ```ts\n * import type { Transport } from '@sveltejs/kit';\n *\n * declare class MyCustomType {\n * \tdata: any\n * }\n *\n * // hooks.js\n * export const transport: Transport = {\n * \tMyCustomType: {\n * \t\tencode: (value) => value instanceof MyCustomType && [value.data],\n * \t\tdecode: ([data]) => new MyCustomType(data)\n * \t}\n * };\n * ```\n * @since 2.11.0\n */\nexport type Transport = Record<string, Transporter>;\n\n/**\n * A member of the [`transport`](https://svelte.dev/docs/kit/hooks#Universal-hooks-transport) hook.\n */\nexport interface Transporter<\n\tT = any,\n\tU = Exclude<any, false | 0 | '' | null | undefined | typeof NaN>\n> {\n\tencode: (value: T) => false | U;\n\tdecode: (data: U) => T;\n}\n\n/**\n * The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://svelte.dev/docs/kit/types#Generated-types))\n * rather than using `Load` directly.\n */\nexport type Load<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tInputData extends Record<string, unknown> | null = Record<string, any> | null,\n\tParentData extends Record<string, unknown> = Record<string, any>,\n\tOutputData extends Record<string, unknown> | void = Record<string, any> | void,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> = (event: LoadEvent<Params, InputData, ParentData, RouteId>) => MaybePromise<OutputData>;\n\n/**\n * The generic form of `PageLoadEvent` and `LayoutLoadEvent`. You should import those from `./$types` (see [generated types](https://svelte.dev/docs/kit/types#Generated-types))\n * rather than using `LoadEvent` directly.\n */\nexport interface LoadEvent<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tData extends Record<string, unknown> | null = Record<string, any> | null,\n\tParentData extends Record<string, unknown> = Record<string, any>,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> extends NavigationEvent<Params, RouteId> {\n\t/**\n\t * `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features:\n\t *\n\t * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.\n\t * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).\n\t * - 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.\n\t * - 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://svelte.dev/docs/kit/hooks#Server-hooks-handle)\n\t * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.\n\t *\n\t * You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies)\n\t */\n\tfetch: typeof fetch;\n\t/**\n\t * Contains the data returned by the route's server `load` function (in `+layout.server.js` or `+page.server.js`), if any.\n\t */\n\tdata: Data;\n\t/**\n\t * 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:\n\t *\n\t *\t```js\n\t *\t/// file: src/routes/blog/+page.js\n\t *\texport async function load({ fetch, setHeaders }) {\n\t *\t\tconst url = `https://cms.example.com/articles.json`;\n\t *\t\tconst response = await fetch(url);\n\t *\n\t *\t\tsetHeaders({\n\t *\t\t\tage: response.headers.get('age'),\n\t *\t\t\t'cache-control': response.headers.get('cache-control')\n\t *\t\t});\n\t *\n\t *\t\treturn response.json();\n\t *\t}\n\t *\t```\n\t *\n\t * Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.\n\t *\n\t * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API in a server-only `load` function instead.\n\t *\n\t * `setHeaders` has no effect when a `load` function runs in the browser.\n\t */\n\tsetHeaders: (headers: Record<string, string>) => void;\n\t/**\n\t * `await parent()` returns data from parent `+layout.js` `load` functions.\n\t * 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.\n\t *\n\t * 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.\n\t */\n\tparent: () => Promise<ParentData>;\n\t/**\n\t * 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()`](https://svelte.dev/docs/kit/$app-navigation#invalidate) to cause `load` to rerun.\n\t *\n\t * 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`.\n\t *\n\t * 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).\n\t *\n\t * 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).\n\t *\n\t * 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.\n\t *\n\t * ```js\n\t * /// file: src/routes/+page.js\n\t * let count = 0;\n\t * export async function load({ depends }) {\n\t * \tdepends('increase:count');\n\t *\n\t * \treturn { count: count++ };\n\t * }\n\t * ```\n\t *\n\t * ```html\n\t * /// file: src/routes/+page.svelte\n\t * <script>\n\t * \timport { invalidate } from '$app/navigation';\n\t *\n\t * \tlet { data } = $props();\n\t *\n\t * \tconst increase = async () => {\n\t * \t\tawait invalidate('increase:count');\n\t * \t}\n\t * </script>\n\t *\n\t * <p>{data.count}<p>\n\t * <button on:click={increase}>Increase Count</button>\n\t * ```\n\t */\n\tdepends: (...deps: Array<`${string}:${string}`>) => void;\n\t/**\n\t * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example:\n\t *\n\t * ```js\n\t * /// file: src/routes/+page.server.js\n\t * export async function load({ untrack, url }) {\n\t * \t// Untrack url.pathname so that path changes don't trigger a rerun\n\t * \tif (untrack(() => url.pathname === '/')) {\n\t * \t\treturn { message: 'Welcome!' };\n\t * \t}\n\t * }\n\t * ```\n\t */\n\tuntrack: <T>(fn: () => T) => T;\n\n\t/**\n\t * Access to spans for tracing. If tracing is not enabled or the function is being run in the browser, these spans will do nothing.\n\t * @since 2.31.0\n\t */\n\ttracing: {\n\t\t/** Whether tracing is enabled. */\n\t\tenabled: boolean;\n\t\t/** The root span for the request. This span is named `sveltekit.handle.root`. */\n\t\troot: Span;\n\t\t/** The span associated with the current `load` function. */\n\t\tcurrent: Span;\n\t};\n}\n\nexport interface NavigationEvent<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> {\n\t/**\n\t * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object\n\t */\n\tparams: Params;\n\t/**\n\t * Info about the current route\n\t */\n\troute: {\n\t\t/**\n\t\t * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.\n\t\t */\n\t\tid: RouteId;\n\t};\n\t/**\n\t * The URL of the current page\n\t */\n\turl: URL;\n}\n\n/**\n * Information about the target of a specific navigation.\n */\nexport interface NavigationTarget<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> {\n\t/**\n\t * Parameters of the target page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.\n\t * Is `null` if the target is not part of the SvelteKit app (could not be resolved to a route).\n\t */\n\tparams: Params | null;\n\t/**\n\t * Info about the target route\n\t */\n\troute: {\n\t\t/**\n\t\t * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.\n\t\t */\n\t\tid: RouteId | null;\n\t};\n\t/**\n\t * The URL that is navigated to\n\t */\n\turl: URL;\n\t/**\n\t * The scroll position associated with this navigation.\n\t *\n\t * For the `from` target, this is the scroll position at the moment of navigation.\n\t *\n\t * For the `to` target, this represents the scroll position that will be or was restored:\n\t * - In `beforeNavigate` and `onNavigate`, this is only available for `popstate` navigations (back/forward button)\n\t *   and will be `null` for other navigation types, since the final scroll position isn't known\n\t *   ahead of time.\n\t * - In `afterNavigate`, this is always the scroll position that was applied after the navigation\n\t *   completed.\n\t */\n\tscroll: { x: number; y: number } | null;\n}\n\n/**\n * - `enter`: The app has hydrated/started\n * - `form`: The user submitted a `<form method=\"GET\">`\n * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring\n * - `link`: Navigation was triggered by a link click\n * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect\n * - `popstate`: Navigation was triggered by back/forward navigation\n */\nexport type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';\n\nexport interface NavigationBase {\n\t/**\n\t * Where navigation was triggered from\n\t */\n\tfrom: NavigationTarget | null;\n\t/**\n\t * Where navigation is going to/has gone to\n\t */\n\tto: NavigationTarget | null;\n\t/**\n\t * Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation).\n\t */\n\twillUnload: boolean;\n\t/**\n\t * A promise that resolves once the navigation is complete, and rejects if the navigation\n\t * fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve\n\t */\n\tcomplete: Promise<void>;\n}\n\nexport interface NavigationEnter extends NavigationBase {\n\t/**\n\t * The type of navigation:\n\t * - `enter`: The app has hydrated/started\n\t */\n\ttype: 'enter';\n\n\t/**\n\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t */\n\tdelta?: undefined;\n\n\t/**\n\t * Dispatched `Event` object when navigation occurred by `popstate` or `link`.\n\t */\n\tevent?: undefined;\n}\n\nexport type NavigationExternal = NavigationGoto | NavigationLeave;\n\nexport interface NavigationGoto extends NavigationBase {\n\t/**\n\t * The type of navigation:\n\t * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect\n\t */\n\ttype: 'goto';\n\n\t// TODO 3.0 remove this property, so that it only exists when type is 'popstate'\n\t// (would possibly be a breaking change to do it prior to that)\n\t/**\n\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t */\n\tdelta?: undefined;\n}\n\nexport interface NavigationLeave extends NavigationBase {\n\t/**\n\t * The type of navigation:\n\t * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring\n\t */\n\ttype: 'leave';\n\n\t// TODO 3.0 remove this property, so that it only exists when type is 'popstate'\n\t// (would possibly be a breaking change to do it prior to that)\n\t/**\n\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t */\n\tdelta?: undefined;\n}\n\nexport interface NavigationFormSubmit extends NavigationBase {\n\t/**\n\t * The type of navigation:\n\t * - `form`: The user submitted a `<form method=\"GET\">`\n\t */\n\ttype: 'form';\n\n\t/**\n\t * The `SubmitEvent` that caused the navigation\n\t */\n\tevent: SubmitEvent;\n\n\t// TODO 3.0 remove this property, so that it only exists when type is 'popstate'\n\t// (would possibly be a breaking change to do it prior to that)\n\t/**\n\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t */\n\tdelta?: undefined;\n}\n\nexport interface NavigationPopState extends NavigationBase {\n\t/**\n\t * The type of navigation:\n\t * - `popstate`: Navigation was triggered by back/forward navigation\n\t */\n\ttype: 'popstate';\n\n\t/**\n\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t */\n\tdelta: number;\n\n\t/**\n\t * The `PopStateEvent` that caused the navigation\n\t */\n\tevent: PopStateEvent;\n}\n\nexport interface NavigationLink extends NavigationBase {\n\t/**\n\t * The type of navigation:\n\t * - `link`: Navigation was triggered by a link click\n\t */\n\ttype: 'link';\n\n\t/**\n\t * The `PointerEvent` that caused the navigation\n\t */\n\tevent: PointerEvent;\n\n\t// TODO 3.0 remove this property, so that it only exists when type is 'popstate'\n\t// (would possibly be a breaking change to do it prior to that)\n\t/**\n\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t */\n\tdelta?: undefined;\n}\n\nexport type Navigation =\n\t| NavigationExternal\n\t| NavigationFormSubmit\n\t| NavigationPopState\n\t| NavigationLink;\n\n/**\n * The argument passed to [`beforeNavigate`](https://svelte.dev/docs/kit/$app-navigation#beforeNavigate) callbacks.\n */\nexport type BeforeNavigate = Navigation & {\n\t/**\n\t * Call this to prevent the navigation from starting.\n\t */\n\tcancel: () => void;\n};\n\n/**\n * The argument passed to [`onNavigate`](https://svelte.dev/docs/kit/$app-navigation#onNavigate) callbacks.\n */\nexport type OnNavigate = Navigation & {\n\ttype: Exclude<NavigationType, 'enter' | 'leave'>;\n\t/**\n\t * Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page.\n\t */\n\twillUnload: false;\n};\n\n/**\n * The argument passed to [`afterNavigate`](https://svelte.dev/docs/kit/$app-navigation#afterNavigate) callbacks.\n */\nexport type AfterNavigate = (Navigation | NavigationEnter) & {\n\ttype: Exclude<NavigationType, 'leave'>;\n\t/**\n\t * Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page.\n\t */\n\twillUnload: false;\n};\n\n/**\n * The shape of the [`page`](https://svelte.dev/docs/kit/$app-state#page) reactive object and the [`$page`](https://svelte.dev/docs/kit/$app-stores) store.\n */\nexport interface Page<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> {\n\t/**\n\t * The URL of the current page.\n\t */\n\turl: URL & { pathname: ResolvedPathname };\n\t/**\n\t * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.\n\t */\n\tparams: Params;\n\t/**\n\t * Info about the current route.\n\t */\n\troute: {\n\t\t/**\n\t\t * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.\n\t\t */\n\t\tid: RouteId;\n\t};\n\t/**\n\t * HTTP status code of the current page.\n\t */\n\tstatus: number;\n\t/**\n\t * The error object of the current page, if any. Filled from the `handleError` hooks.\n\t */\n\terror: App.Error | null;\n\t/**\n\t * The merged result of all data from all `load` functions on the current page. You can type a common denominator through `App.PageData`.\n\t */\n\tdata: App.PageData & Record<string, any>;\n\t/**\n\t * The page state, which can be manipulated using the [`pushState`](https://svelte.dev/docs/kit/$app-navigation#pushState) and [`replaceState`](https://svelte.dev/docs/kit/$app-navigation#replaceState) functions from `$app/navigation`.\n\t */\n\tstate: App.PageState;\n\t/**\n\t * Filled only after a form submission. See [form actions](https://svelte.dev/docs/kit/form-actions) for more info.\n\t */\n\tform: any;\n}\n\n/**\n * The shape of a param matcher. See [matching](https://svelte.dev/docs/kit/advanced-routing#Matching) for more info.\n */\nexport type ParamMatcher = (param: string) => boolean;\n\nexport interface RequestEvent<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> {\n\t/**\n\t * Get or set cookies related to the current request\n\t */\n\tcookies: Cookies;\n\t/**\n\t * `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features:\n\t *\n\t * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.\n\t * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).\n\t * - 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.\n\t * - 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://svelte.dev/docs/kit/hooks#Server-hooks-handle)\n\t * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.\n\t *\n\t * You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).\n\t */\n\tfetch: typeof fetch;\n\t/**\n\t * The client's IP address, set by the adapter.\n\t */\n\tgetClientAddress: () => string;\n\t/**\n\t * Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle).\n\t */\n\tlocals: App.Locals;\n\t/**\n\t * The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.\n\t */\n\tparams: Params;\n\t/**\n\t * Additional data made available through the adapter.\n\t */\n\tplatform: Readonly<App.Platform> | undefined;\n\t/**\n\t * The original request object.\n\t */\n\trequest: Request;\n\t/**\n\t * Info about the current route.\n\t */\n\troute: {\n\t\t/**\n\t\t * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.\n\t\t */\n\t\tid: RouteId;\n\t};\n\t/**\n\t * 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:\n\t *\n\t *\t```js\n\t *\t/// file: src/routes/blog/+page.js\n\t *\texport async function load({ fetch, setHeaders }) {\n\t *\t\tconst url = `https://cms.example.com/articles.json`;\n\t *\t\tconst response = await fetch(url);\n\t *\n\t *\t\tsetHeaders({\n\t *\t\t\tage: response.headers.get('age'),\n\t *\t\t\t'cache-control': response.headers.get('cache-control')\n\t *\t\t});\n\t *\n\t *\t\treturn response.json();\n\t *\t}\n\t *\t```\n\t *\n\t * Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.\n\t *\n\t * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API instead.\n\t */\n\tsetHeaders: (headers: Record<string, string>) => void;\n\t/**\n\t * The requested URL.\n\t */\n\turl: URL;\n\t/**\n\t * `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\n\t * related to the data request in this case. Use this property instead if the distinction is important to you.\n\t */\n\tisDataRequest: boolean;\n\t/**\n\t * `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.\n\t */\n\tisSubRequest: boolean;\n\n\t/**\n\t * Access to spans for tracing. If tracing is not enabled, these spans will do nothing.\n\t * @since 2.31.0\n\t */\n\ttracing: {\n\t\t/** Whether tracing is enabled. */\n\t\tenabled: boolean;\n\t\t/** The root span for the request. This span is named `sveltekit.handle.root`. */\n\t\troot: Span;\n\t\t/** The span associated with the current `handle` hook, `load` function, or form action. */\n\t\tcurrent: Span;\n\t};\n\n\t/**\n\t * `true` if the request comes from the client via a remote function. The `url` property will be stripped of the internal information\n\t * related to the data request in this case. Use this property instead if the distinction is important to you.\n\t */\n\tisRemoteRequest: boolean;\n}\n\n/**\n * 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.\n *\n * It receives `Params` as the first generic argument, which you can skip by using [generated types](https://svelte.dev/docs/kit/types#Generated-types) instead.\n */\nexport type RequestHandler<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> = (event: RequestEvent<Params, RouteId>) => MaybePromise<Response>;\n\nexport interface ResolveOptions {\n\t/**\n\t * Applies custom transforms to HTML. If `done` is true, it's the final chunk. Chunks are not guaranteed to be well-formed HTML\n\t * (they could include an element's opening tag but not its closing tag, for example)\n\t * but they will always be split at sensible boundaries such as `%sveltekit.head%` or layout/page components.\n\t * @param input the html chunk and the info if this is the last chunk\n\t */\n\ttransformPageChunk?: (input: { html: string; done: boolean }) => MaybePromise<string | undefined>;\n\t/**\n\t * Determines which headers should be included in serialized responses when a `load` function loads a resource with `fetch`.\n\t * By default, none will be included.\n\t * @param name header name\n\t * @param value header value\n\t */\n\tfilterSerializedResponseHeaders?: (name: string, value: string) => boolean;\n\t/**\n\t * Determines what should be added to the `<head>` tag to preload it.\n\t * By default, `js` and `css` files will be preloaded.\n\t * @param input the type of the file and its path\n\t */\n\tpreload?: (input: { type: 'font' | 'css' | 'js' | 'asset'; path: string }) => boolean;\n}\n\nexport interface RouteDefinition<Config = any> {\n\tid: string;\n\tapi: {\n\t\tmethods: Array<HttpMethod | '*'>;\n\t};\n\tpage: {\n\t\tmethods: Array<Extract<HttpMethod, 'GET' | 'POST'>>;\n\t};\n\tpattern: RegExp;\n\tprerender: PrerenderOption;\n\tsegments: RouteSegment[];\n\tmethods: Array<HttpMethod | '*'>;\n\tconfig: Config;\n}\n\nexport class Server {\n\tconstructor(manifest: SSRManifest);\n\tinit(options: ServerInitOptions): Promise<void>;\n\trespond(request: Request, options: RequestOptions): Promise<Response>;\n}\n\nexport interface ServerInitOptions {\n\t/** A map of environment variables. */\n\tenv: Record<string, string>;\n\t/** A function that turns an asset filename into a `ReadableStream`. Required for the `read` export from `$app/server` to work. */\n\tread?: (file: string) => MaybePromise<ReadableStream | null>;\n}\n\nexport interface SSRManifest {\n\tappDir: string;\n\tappPath: string;\n\t/** Static files from `kit.config.files.assets` and the service worker (if any). */\n\tassets: Set<string>;\n\tmimeTypes: Record<string, string>;\n\n\t/** private fields */\n\t_: {\n\t\tclient: NonNullable<BuildData['client']>;\n\t\tnodes: SSRNodeLoader[];\n\t\t/** hashed filename -> import to that file */\n\t\tremotes: Record<string, () => Promise<any>>;\n\t\troutes: SSRRoute[];\n\t\tprerendered_routes: Set<string>;\n\t\tmatchers: () => Promise<Record<string, ParamMatcher>>;\n\t\t/** A `[file]: size` map of all assets imported by server code. */\n\t\tserver_assets: Record<string, number>;\n\t};\n}\n\n/**\n * The generic form of `PageServerLoad` and `LayoutServerLoad`. You should import those from `./$types` (see [generated types](https://svelte.dev/docs/kit/types#Generated-types))\n * rather than using `ServerLoad` directly.\n */\nexport type ServerLoad<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tParentData extends Record<string, any> = Record<string, any>,\n\tOutputData extends Record<string, any> | void = Record<string, any> | void,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> = (event: ServerLoadEvent<Params, ParentData, RouteId>) => MaybePromise<OutputData>;\n\nexport interface ServerLoadEvent<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tParentData extends Record<string, any> = Record<string, any>,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> extends RequestEvent<Params, RouteId> {\n\t/**\n\t * `await parent()` returns data from parent `+layout.server.js` `load` functions.\n\t *\n\t * 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.\n\t */\n\tparent: () => Promise<ParentData>;\n\t/**\n\t * 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()`](https://svelte.dev/docs/kit/$app-navigation#invalidate) to cause `load` to rerun.\n\t *\n\t * 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`.\n\t *\n\t * 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).\n\t *\n\t * 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).\n\t *\n\t * 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.\n\t *\n\t * ```js\n\t * /// file: src/routes/+page.js\n\t * let count = 0;\n\t * export async function load({ depends }) {\n\t * \tdepends('increase:count');\n\t *\n\t * \treturn { count: count++ };\n\t * }\n\t * ```\n\t *\n\t * ```html\n\t * /// file: src/routes/+page.svelte\n\t * <script>\n\t * \timport { invalidate } from '$app/navigation';\n\t *\n\t * \tlet { data } = $props();\n\t *\n\t * \tconst increase = async () => {\n\t * \t\tawait invalidate('increase:count');\n\t * \t}\n\t * </script>\n\t *\n\t * <p>{data.count}<p>\n\t * <button on:click={increase}>Increase Count</button>\n\t * ```\n\t */\n\tdepends: (...deps: string[]) => void;\n\t/**\n\t * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example:\n\t *\n\t * ```js\n\t * /// file: src/routes/+page.js\n\t * export async function load({ untrack, url }) {\n\t * \t// Untrack url.pathname so that path changes don't trigger a rerun\n\t * \tif (untrack(() => url.pathname === '/')) {\n\t * \t\treturn { message: 'Welcome!' };\n\t * \t}\n\t * }\n\t * ```\n\t */\n\tuntrack: <T>(fn: () => T) => T;\n\n\t/**\n\t * Access to spans for tracing. If tracing is not enabled, these spans will do nothing.\n\t * @since 2.31.0\n\t */\n\ttracing: {\n\t\t/** Whether tracing is enabled. */\n\t\tenabled: boolean;\n\t\t/** The root span for the request. This span is named `sveltekit.handle.root`. */\n\t\troot: Span;\n\t\t/** The span associated with the current server `load` function. */\n\t\tcurrent: Span;\n\t};\n}\n\n/**\n * Shape of a form action method that is part of `export const actions = {...}` in `+page.server.js`.\n * See [form actions](https://svelte.dev/docs/kit/form-actions) for more information.\n */\nexport type Action<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tOutputData extends Record<string, any> | void = Record<string, any> | void,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> = (event: RequestEvent<Params, RouteId>) => MaybePromise<OutputData>;\n\n/**\n * Shape of the `export const actions = {...}` object in `+page.server.js`.\n * See [form actions](https://svelte.dev/docs/kit/form-actions) for more information.\n */\nexport type Actions<\n\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\tOutputData extends Record<string, any> | void = Record<string, any> | void,\n\tRouteId extends AppRouteId | null = AppRouteId | null\n> = Record<string, Action<Params, OutputData, RouteId>>;\n\n/**\n * When calling a form action via fetch, the response will be one of these shapes.\n * ```svelte\n * <form method=\"post\" use:enhance={() => {\n *   return ({ result }) => {\n * \t\t// result is of type ActionResult\n *   };\n * }}\n * ```\n */\nexport type ActionResult<\n\tSuccess extends Record<string, unknown> | undefined = Record<string, any>,\n\tFailure extends Record<string, unknown> | undefined = Record<string, any>\n> =\n\t| { type: 'success'; status: number; data?: Success }\n\t| { type: 'failure'; status: number; data?: Failure }\n\t| { type: 'redirect'; status: number; location: string }\n\t| { type: 'error'; status?: number; error: any };\n\n/**\n * The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.\n */\nexport interface HttpError {\n\t/** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses), in the range 400-599. */\n\tstatus: number;\n\t/** The content of the error. */\n\tbody: App.Error;\n}\n\n/**\n * The object returned by the [`redirect`](https://svelte.dev/docs/kit/@sveltejs-kit#redirect) function.\n */\nexport interface Redirect {\n\t/** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages), in the range 300-308. */\n\tstatus: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308;\n\t/** The location to redirect to. */\n\tlocation: string;\n}\n\nexport type SubmitFunction<\n\tSuccess extends Record<string, unknown> | undefined = Record<string, any>,\n\tFailure extends Record<string, unknown> | undefined = Record<string, any>\n> = (input: {\n\taction: URL;\n\tformData: FormData;\n\tformElement: HTMLFormElement;\n\tcontroller: AbortController;\n\tsubmitter: HTMLElement | null;\n\tcancel: () => void;\n}) => MaybePromise<\n\t| void\n\t| ((opts: {\n\t\t\tformData: FormData;\n\t\t\tformElement: HTMLFormElement;\n\t\t\taction: URL;\n\t\t\tresult: ActionResult<Success, Failure>;\n\t\t\t/**\n\t\t\t * Call this to get the default behavior of a form submission response.\n\t\t\t * @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission.\n\t\t\t * @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission.\n\t\t\t */\n\t\t\tupdate: (options?: { reset?: boolean; invalidateAll?: boolean }) => Promise<void>;\n\t  }) => MaybePromise<void>)\n>;\n\n/**\n * The type of `export const snapshot` exported from a page or layout component.\n */\nexport interface Snapshot<T = any> {\n\tcapture: () => T;\n\trestore: (snapshot: T) => void;\n}\n\n// If T is unknown or has an index signature, the types below will recurse indefinitely and create giant unions that TS can't handle\ntype WillRecurseIndefinitely<T> = unknown extends T ? true : string extends keyof T ? true : false;\n\n// Input type mappings for form fields\ntype InputTypeMap = {\n\ttext: string;\n\temail: string;\n\tpassword: string;\n\turl: string;\n\ttel: string;\n\tsearch: string;\n\tnumber: number;\n\trange: number;\n\tdate: string;\n\t'datetime-local': string;\n\ttime: string;\n\tmonth: string;\n\tweek: string;\n\tcolor: string;\n\tcheckbox: boolean | string[];\n\tradio: string;\n\tfile: File;\n\thidden: string;\n\tsubmit: string;\n\tbutton: string;\n\treset: string;\n\timage: string;\n\tselect: string;\n\t'select multiple': string[];\n\t'file multiple': File[];\n};\n\n// Valid input types for a given value type\nexport type RemoteFormFieldType<T> = {\n\t[K in keyof InputTypeMap]: T extends InputTypeMap[K] ? K : never;\n}[keyof InputTypeMap];\n\n// Input element properties based on type\ntype InputElementProps<T extends keyof InputTypeMap> = T extends 'checkbox' | 'radio'\n\t? {\n\t\t\tname: string;\n\t\t\ttype: T;\n\t\t\tvalue?: string;\n\t\t\t'aria-invalid': boolean | 'false' | 'true' | undefined;\n\t\t\tget checked(): boolean;\n\t\t\tset checked(value: boolean);\n\t\t}\n\t: T extends 'file'\n\t\t? {\n\t\t\t\tname: string;\n\t\t\t\ttype: 'file';\n\t\t\t\t'aria-invalid': boolean | 'false' | 'true' | undefined;\n\t\t\t\tget files(): FileList | null;\n\t\t\t\tset files(v: FileList | null);\n\t\t\t}\n\t\t: T extends 'select' | 'select multiple'\n\t\t\t? {\n\t\t\t\t\tname: string;\n\t\t\t\t\tmultiple: T extends 'select' ? false : true;\n\t\t\t\t\t'aria-invalid': boolean | 'false' | 'true' | undefined;\n\t\t\t\t\tget value(): string | number;\n\t\t\t\t\tset value(v: string | number);\n\t\t\t\t}\n\t\t\t: T extends 'text'\n\t\t\t\t? {\n\t\t\t\t\t\tname: string;\n\t\t\t\t\t\t'aria-invalid': boolean | 'false' | 'true' | undefined;\n\t\t\t\t\t\tget value(): string | number;\n\t\t\t\t\t\tset value(v: string | number);\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tname: string;\n\t\t\t\t\t\ttype: T;\n\t\t\t\t\t\t'aria-invalid': boolean | 'false' | 'true' | undefined;\n\t\t\t\t\t\tget value(): string | number;\n\t\t\t\t\t\tset value(v: string | number);\n\t\t\t\t\t};\n\ntype RemoteFormFieldMethods<T> = {\n\t/** The values that will be submitted */\n\tvalue(): DeepPartial<T>;\n\t/** Set the values that will be submitted */\n\tset(input: DeepPartial<T>): DeepPartial<T>;\n\t/** Validation issues, if any */\n\tissues(): RemoteFormIssue[] | undefined;\n};\n\nexport type RemoteFormFieldValue = string | string[] | number | boolean | File | File[];\n\ntype AsArgs<Type extends keyof InputTypeMap, Value> = Type extends 'checkbox'\n\t? Value extends string[]\n\t\t? [type: Type, value: Value[number] | (string & {})]\n\t\t: [type: Type]\n\t: Type extends 'radio' | 'submit' | 'hidden'\n\t\t? [type: Type, value: Value | (string & {})]\n\t\t: [type: Type];\n\n/**\n * Form field accessor type that provides name(), value(), and issues() methods\n */\nexport type RemoteFormField<Value extends RemoteFormFieldValue> = RemoteFormFieldMethods<Value> & {\n\t/**\n\t * Returns an object that can be spread onto an input element with the correct type attribute,\n\t * aria-invalid attribute if the field is invalid, and appropriate value/checked property getters/setters.\n\t * @example\n\t * ```svelte\n\t * <input {...myForm.fields.myString.as('text')} />\n\t * <input {...myForm.fields.myNumber.as('number')} />\n\t * <input {...myForm.fields.myBoolean.as('checkbox')} />\n\t * ```\n\t */\n\tas<T extends RemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;\n};\n\ntype RemoteFormFieldContainer<Value> = RemoteFormFieldMethods<Value> & {\n\t/** Validation issues belonging to this or any of the fields that belong to it, if any */\n\tallIssues(): RemoteFormIssue[] | undefined;\n};\n\ntype UnknownField<Value> = RemoteFormFieldMethods<Value> & {\n\t/** Validation issues belonging to this or any of the fields that belong to it, if any */\n\tallIssues(): RemoteFormIssue[] | undefined;\n\t/**\n\t * Returns an object that can be spread onto an input element with the correct type attribute,\n\t * aria-invalid attribute if the field is invalid, and appropriate value/checked property getters/setters.\n\t * @example\n\t * ```svelte\n\t * <input {...myForm.fields.myString.as('text')} />\n\t * <input {...myForm.fields.myNumber.as('number')} />\n\t * <input {...myForm.fields.myBoolean.as('checkbox')} />\n\t * ```\n\t */\n\tas<T extends RemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;\n} & {\n\t[key: string | number]: UnknownField<any>;\n};\n\ntype RemoteFormFieldsRoot<Input extends RemoteFormInput | void> =\n\tIsAny<Input> extends true\n\t\t? RecursiveFormFields\n\t\t: Input extends void\n\t\t\t? {\n\t\t\t\t\t/** Validation issues, if any */\n\t\t\t\t\tissues(): RemoteFormIssue[] | undefined;\n\t\t\t\t\t/** Validation issues belonging to this or any of the fields that belong to it, if any */\n\t\t\t\t\tallIssues(): RemoteFormIssue[] | undefined;\n\t\t\t\t}\n\t\t\t: RemoteFormFields<Input>;\n\n/**\n * Recursive type to build form fields structure with proxy access\n */\nexport type RemoteFormFields<T> =\n\tWillRecurseIndefinitely<T> extends true\n\t\t? RecursiveFormFields\n\t\t: NonNullable<T> extends string | number | boolean | File\n\t\t\t? RemoteFormField<NonNullable<T>>\n\t\t\t: T extends string[] | File[]\n\t\t\t\t? RemoteFormField<T> & { [K in number]: RemoteFormField<T[number]> }\n\t\t\t\t: T extends Array<infer U>\n\t\t\t\t\t? RemoteFormFieldContainer<T> & {\n\t\t\t\t\t\t\t[K in number]: RemoteFormFields<U>;\n\t\t\t\t\t\t}\n\t\t\t\t\t: RemoteFormFieldContainer<T> & {\n\t\t\t\t\t\t\t[K in keyof T]-?: RemoteFormFields<T[K]>;\n\t\t\t\t\t\t};\n\n// By breaking this out into its own type, we avoid the TS recursion depth limit\ntype RecursiveFormFields = RemoteFormFieldContainer<any> & {\n\t[key: string | number]: UnknownField<any>;\n};\n\ntype MaybeArray<T> = T | T[];\n\nexport interface RemoteFormInput {\n\t[key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput>;\n}\n\nexport interface RemoteFormIssue {\n\tmessage: string;\n\tpath: Array<string | number>;\n}\n\n// If the schema specifies `id` as a string or number, ensure that `for(...)`\n// only accepts that type. Otherwise, accept `string | number`\ntype ExtractId<Input> = Input extends { id: infer Id }\n\t? Id extends string | number\n\t\t? Id\n\t\t: string | number\n\t: string | number;\n\n/**\n * A function and proxy object used to imperatively create validation errors in form handlers.\n *\n * Access properties to create field-specific issues: `issue.fieldName('message')`.\n * The type structure mirrors the input data structure for type-safe field access.\n * Call `invalid(issue.foo(...), issue.nested.bar(...))` to throw a validation error.\n */\nexport type InvalidField<T> =\n\tWillRecurseIndefinitely<T> extends true\n\t\t? Record<string | number, any>\n\t\t: NonNullable<T> extends string | number | boolean | File\n\t\t\t? (message: string) => StandardSchemaV1.Issue\n\t\t\t: NonNullable<T> extends Array<infer U>\n\t\t\t\t? {\n\t\t\t\t\t\t[K in number]: InvalidField<U>;\n\t\t\t\t\t} & ((message: string) => StandardSchemaV1.Issue)\n\t\t\t\t: NonNullable<T> extends RemoteFormInput\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t[K in keyof T]-?: InvalidField<T[K]>;\n\t\t\t\t\t\t} & ((message: string) => StandardSchemaV1.Issue)\n\t\t\t\t\t: Record<string, never>;\n\n/**\n * A validation error thrown by `invalid`.\n */\nexport interface ValidationError {\n\t/** The validation issues */\n\tissues: StandardSchemaV1.Issue[];\n}\n\n/**\n * The return value of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.\n */\nexport type RemoteForm<Input extends RemoteFormInput | void, Output> = {\n\t/** Attachment that sets up an event handler that intercepts the form submission on the client to prevent a full page reload */\n\t[attachment: symbol]: (node: HTMLFormElement) => void;\n\tmethod: 'POST';\n\t/** The URL to send the form to. */\n\taction: string;\n\t/** Use the `enhance` method to influence what happens when the form is submitted. */\n\tenhance(\n\t\tcallback: (opts: {\n\t\t\tform: HTMLFormElement;\n\t\t\tdata: Input;\n\t\t\tsubmit: () => Promise<void> & {\n\t\t\t\tupdates: (...queries: Array<RemoteQuery<any> | RemoteQueryOverride>) => Promise<void>;\n\t\t\t};\n\t\t}) => void | Promise<void>\n\t): {\n\t\tmethod: 'POST';\n\t\taction: string;\n\t\t[attachment: symbol]: (node: HTMLFormElement) => void;\n\t};\n\t/**\n\t * Create an instance of the form for the given `id`.\n\t * The `id` is stringified and used for deduplication to potentially reuse existing instances.\n\t * Useful when you have multiple forms that use the same remote form action, for example in a loop.\n\t * ```svelte\n\t * {#each todos as todo}\n\t *\t{@const todoForm = updateTodo.for(todo.id)}\n\t *\t<form {...todoForm}>\n\t *\t\t{#if todoForm.result?.invalid}<p>Invalid data</p>{/if}\n\t *\t\t...\n\t *\t</form>\n\t *\t{/each}\n\t * ```\n\t */\n\tfor(id: ExtractId<Input>): Omit<RemoteForm<Input, Output>, 'for'>;\n\t/** Preflight checks */\n\tpreflight(schema: StandardSchemaV1<Input, any>): RemoteForm<Input, Output>;\n\t/** Validate the form contents programmatically */\n\tvalidate(options?: {\n\t\t/** Set this to `true` to also show validation issues of fields that haven't been touched yet. */\n\t\tincludeUntouched?: boolean;\n\t\t/** Set this to `true` to only run the `preflight` validation. */\n\t\tpreflightOnly?: boolean;\n\t}): Promise<void>;\n\t/** The result of the form submission */\n\tget result(): Output | undefined;\n\t/** The number of pending submissions */\n\tget pending(): number;\n\t/** Access form fields using object notation */\n\tfields: RemoteFormFieldsRoot<Input>;\n};\n\n/**\n * The return value of a remote `command` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.\n */\nexport type RemoteCommand<Input, Output> = {\n\t(arg: undefined extends Input ? Input | void : Input): Promise<Output> & {\n\t\tupdates(...queries: Array<RemoteQuery<any> | RemoteQueryOverride>): Promise<Output>;\n\t};\n\t/** The number of pending command executions */\n\tget pending(): number;\n};\n\nexport type RemoteResource<T> = Promise<T> & {\n\t/** The error in case the query fails. Most often this is a [`HttpError`](https://svelte.dev/docs/kit/@sveltejs-kit#HttpError) but it isn't guaranteed to be. */\n\tget error(): any;\n\t/** `true` before the first result is available and during refreshes */\n\tget loading(): boolean;\n} & (\n\t\t| {\n\t\t\t\t/** The current value of the query. Undefined until `ready` is `true` */\n\t\t\t\tget current(): undefined;\n\t\t\t\tready: false;\n\t\t  }\n\t\t| {\n\t\t\t\t/** The current value of the query. Undefined until `ready` is `true` */\n\t\t\t\tget current(): T;\n\t\t\t\tready: true;\n\t\t  }\n\t);\n\nexport type RemoteQuery<T> = RemoteResource<T> & {\n\t/**\n\t * Returns a plain promise with the result.\n\t * Unlike awaiting the resource directly, this can only be used _outside_ render\n\t * (i.e. in load functions, event handlers and so on)\n\t */\n\trun(): Promise<T>;\n\t/**\n\t * On the client, this function will update the value of the query without re-fetching it.\n\t *\n\t * On the server, this can be called in the context of a `command` or `form` and the specified data will accompany the action response back to the client.\n\t * This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.\n\t */\n\tset(value: T): void;\n\t/**\n\t * On the client, this function will re-fetch the query from the server.\n\t *\n\t * On the server, this can be called in the context of a `command` or `form` and the refreshed data will accompany the action response back to the client.\n\t * This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.\n\t */\n\trefresh(): Promise<void>;\n\t/**\n\t * Temporarily override the value of a query. This is used with the `updates` method of a [command](https://svelte.dev/docs/kit/remote-functions#command-Updating-queries) or [enhanced form submission](https://svelte.dev/docs/kit/remote-functions#form-enhance) to provide optimistic updates.\n\t *\n\t * ```svelte\n\t * <script>\n\t *   import { getTodos, addTodo } from './todos.remote.js';\n\t *   const todos = getTodos();\n\t * </script>\n\t *\n\t * <form {...addTodo.enhance(async ({ data, submit }) => {\n\t *   await submit().updates(\n\t *     todos.withOverride((todos) => [...todos, { text: data.get('text') }])\n\t *   );\n\t * })}>\n\t *   <input type=\"text\" name=\"text\" />\n\t *   <button type=\"submit\">Add Todo</button>\n\t * </form>\n\t * ```\n\t */\n\twithOverride(update: (current: T) => T): RemoteQueryOverride;\n};\n\nexport interface RemoteQueryOverride {\n\t_key: string;\n\trelease(): void;\n}\n\n/**\n * The return value of a remote `prerender` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.\n */\nexport type RemotePrerenderFunction<Input, Output> = (\n\targ: undefined extends Input ? Input | void : Input\n) => RemoteResource<Output>;\n\n/**\n * The return value of a remote `query` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.\n */\nexport type RemoteQueryFunction<Input, Output> = (\n\targ: undefined extends Input ? Input | void : Input\n) => RemoteQuery<Output>;\n\nexport * from './index.js';\n"
  },
  {
    "path": "packages/kit/src/exports/vite/build/build_server.js",
    "content": "import fs from 'node:fs';\nimport { mkdirp } from '../../../utils/filesystem.js';\nimport { create_function_as_string, filter_fonts, find_deps, resolve_symlinks } from './utils.js';\nimport { s } from '../../../utils/misc.js';\nimport { normalizePath } from 'vite';\nimport { basename } from 'node:path';\nimport { fix_css_urls } from '../../../utils/css.js';\n\n/**\n * @param {string} out\n * @param {import('types').ValidatedKitConfig} kit\n * @param {import('types').ManifestData} manifest_data\n * @param {import('vite').Manifest} server_manifest\n * @param {import('vite').Manifest | null} client_manifest\n * @param {string | null} assets_path\n * @param {import('vite').Rollup.RollupOutput['output'] | null} client_chunks\n * @param {import('types').RecursiveRequired<import('types').ValidatedConfig['kit']['output']>} output_config\n */\nexport function build_server_nodes(\n\tout,\n\tkit,\n\tmanifest_data,\n\tserver_manifest,\n\tclient_manifest,\n\tassets_path,\n\tclient_chunks,\n\toutput_config\n) {\n\tmkdirp(`${out}/server/nodes`);\n\tmkdirp(`${out}/server/stylesheets`);\n\n\t/**\n\t * Stylesheet names and their contents which are below the inline threshold\n\t * @type {Map<string, string>}\n\t */\n\tconst stylesheets_to_inline = new Map();\n\n\t/**\n\t * For CSS inlining, we either store a string or a function that returns the\n\t * styles with the correct relative URLs\n\t * @type {(css: string, eager_assets: Set<string>) => string}\n\t */\n\tlet prepare_css_for_inlining = (css) => s(css);\n\n\tif (client_chunks && kit.inlineStyleThreshold > 0 && output_config.bundleStrategy === 'split') {\n\t\tfor (const chunk of client_chunks) {\n\t\t\tif (chunk.type !== 'asset' || !chunk.fileName.endsWith('.css')) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst source = chunk.source.toString();\n\t\t\tif (source.length < kit.inlineStyleThreshold) {\n\t\t\t\tstylesheets_to_inline.set(chunk.fileName, source);\n\t\t\t}\n\t\t}\n\n\t\t// If the client CSS has URL references to assets, we need to adjust the\n\t\t// relative path so that they are correct when inlined into the document.\n\t\t// Although `paths.assets` is static, we need to pass in a fake path\n\t\t// `/_svelte_kit_assets` at runtime when running `vite preview`\n\t\tif (kit.paths.assets || kit.paths.relative) {\n\t\t\tconst static_assets = new Set(\n\t\t\t\tmanifest_data.assets.map((asset) => decodeURIComponent(asset.file))\n\t\t\t);\n\n\t\t\tconst segments = /** @type {string} */ (assets_path).split('/');\n\t\t\tconst static_asset_prefix = segments.map(() => '..').join('/') + '/';\n\n\t\t\tprepare_css_for_inlining = (css, eager_assets) => {\n\t\t\t\tconst transformed_css = fix_css_urls({\n\t\t\t\t\tcss,\n\t\t\t\t\tvite_assets: eager_assets,\n\t\t\t\t\tstatic_assets,\n\t\t\t\t\tpaths_assets: '${assets}',\n\t\t\t\t\tbase: '${base}',\n\t\t\t\t\tstatic_asset_prefix\n\t\t\t\t});\n\n\t\t\t\t// only convert to a function if we have adjusted any URLs\n\t\t\t\tif (css !== transformed_css) {\n\t\t\t\t\treturn create_function_as_string('css', ['assets', 'base'], transformed_css);\n\t\t\t\t}\n\n\t\t\t\treturn s(css);\n\t\t\t};\n\t\t}\n\t}\n\n\tfor (let i = 0; i < manifest_data.nodes.length; i++) {\n\t\tconst node = manifest_data.nodes[i];\n\n\t\t/** @type {string[]} */\n\t\tconst imports = [];\n\n\t\t// String representation of\n\t\t/** @type {import('types').SSRNode} */\n\t\t/** @type {string[]} */\n\t\tconst exports = [`export const index = ${i};`];\n\n\t\t/** @type {string[]} */\n\t\tlet imported = [];\n\n\t\t/** @type {string[]} */\n\t\tlet stylesheets = [];\n\n\t\t/** @type {string[]} */\n\t\tlet fonts = [];\n\n\t\t/** @type {Set<string>} */\n\t\tconst eager_assets = new Set();\n\n\t\tif (node.component && client_manifest) {\n\t\t\texports.push(\n\t\t\t\t'let component_cache;',\n\t\t\t\t`export const component = async () => component_cache ??= (await import('../${\n\t\t\t\t\tresolve_symlinks(server_manifest, node.component).chunk.file\n\t\t\t\t}')).default;`\n\t\t\t);\n\t\t}\n\n\t\tif (node.universal) {\n\t\t\tif (!!node.page_options && node.page_options.ssr === false) {\n\t\t\t\texports.push(`export const universal = ${s(node.page_options, null, 2)};`);\n\t\t\t} else {\n\t\t\t\timports.push(\n\t\t\t\t\t`import * as universal from '../${resolve_symlinks(server_manifest, node.universal).chunk.file}';`\n\t\t\t\t);\n\t\t\t\t// TODO: when building for analysis, explain why the file was loaded on the server if we fail to load it\n\t\t\t\texports.push('export { universal };');\n\t\t\t}\n\t\t\texports.push(`export const universal_id = ${s(node.universal)};`);\n\t\t}\n\n\t\tif (node.server) {\n\t\t\timports.push(\n\t\t\t\t`import * as server from '../${resolve_symlinks(server_manifest, node.server).chunk.file}';`\n\t\t\t);\n\t\t\texports.push('export { server };');\n\t\t\texports.push(`export const server_id = ${s(node.server)};`);\n\t\t}\n\n\t\tif (\n\t\t\tclient_manifest &&\n\t\t\t(node.universal || node.component) &&\n\t\t\toutput_config.bundleStrategy === 'split'\n\t\t) {\n\t\t\tconst entry_path = `${normalizePath(kit.outDir)}/generated/client-optimized/nodes/${i}.js`;\n\t\t\tconst entry = find_deps(client_manifest, entry_path, true);\n\n\t\t\t// Eagerly load client stylesheets and fonts imported by the SSR-ed page to avoid FOUC.\n\t\t\t// However, if it is not used during SSR (not present in the server manifest),\n\t\t\t// then it can be lazily loaded in the browser.\n\n\t\t\t/** @type {import('types').AssetDependencies | undefined} */\n\t\t\tlet component;\n\t\t\tif (node.component) {\n\t\t\t\tcomponent = find_deps(server_manifest, node.component, true);\n\t\t\t}\n\n\t\t\t/** @type {import('types').AssetDependencies | undefined} */\n\t\t\tlet universal;\n\t\t\tif (node.universal) {\n\t\t\t\tuniversal = find_deps(server_manifest, node.universal, true);\n\t\t\t}\n\n\t\t\t/** @type {Set<string>} */\n\t\t\tconst eager_css = new Set();\n\n\t\t\tentry.stylesheet_map.forEach((value, filepath) => {\n\t\t\t\t// pages and layouts are renamed to node indexes when optimised for the client\n\t\t\t\t// so we use the original filename instead to check against the server manifest\n\t\t\t\tif (filepath === entry_path) {\n\t\t\t\t\tfilepath = node.component ?? filepath;\n\t\t\t\t}\n\n\t\t\t\tif (component?.stylesheet_map.has(filepath) || universal?.stylesheet_map.has(filepath)) {\n\t\t\t\t\tvalue.css.forEach((file) => eager_css.add(file));\n\t\t\t\t\tvalue.assets.forEach((file) => eager_assets.add(file));\n\t\t\t\t}\n\t\t\t});\n\n\t\t\timported = entry.imports;\n\t\t\tstylesheets = Array.from(eager_css);\n\t\t\tfonts = filter_fonts(Array.from(eager_assets));\n\t\t}\n\n\t\texports.push(\n\t\t\t`export const imports = ${s(imported)};`,\n\t\t\t`export const stylesheets = ${s(stylesheets)};`,\n\t\t\t`export const fonts = ${s(fonts)};`\n\t\t);\n\n\t\t/**\n\t\t * Assets that have been processed by Vite (decoded and with the asset path stripped)\n\t\t * @type {Set<string>}\n\t\t */\n\t\tlet vite_assets = new Set();\n\n\t\t// Keep track of Vite asset filenames so that we avoid touching unrelated ones\n\t\t// when adjusting the inlined CSS\n\t\tif (stylesheets_to_inline.size && assets_path && eager_assets.size) {\n\t\t\tvite_assets = new Set(\n\t\t\t\tArray.from(eager_assets).map((asset) => {\n\t\t\t\t\treturn decodeURIComponent(asset.replace(`${assets_path}/`, ''));\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tif (stylesheets_to_inline.size) {\n\t\t\t/** @type {string[]} */\n\t\t\tconst inline_styles = [];\n\n\t\t\tstylesheets.forEach((file, i) => {\n\t\t\t\tif (stylesheets_to_inline.has(file)) {\n\t\t\t\t\tconst filename = basename(file);\n\t\t\t\t\tconst dest = `${out}/server/stylesheets/${filename}.js`;\n\n\t\t\t\t\tconst css = /** @type {string} */ (stylesheets_to_inline.get(file));\n\n\t\t\t\t\tfs.writeFileSync(\n\t\t\t\t\t\tdest,\n\t\t\t\t\t\t`// ${filename}\\nexport default ${prepare_css_for_inlining(css, vite_assets)};`\n\t\t\t\t\t);\n\t\t\t\t\tconst name = `stylesheet_${i}`;\n\t\t\t\t\timports.push(`import ${name} from '../stylesheets/${filename}.js';`);\n\t\t\t\t\tinline_styles.push(`\\t${s(file)}: ${name}`);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (inline_styles.length > 0) {\n\t\t\t\texports.push(`export const inline_styles = () => ({\\n${inline_styles.join(',\\n')}\\n});`);\n\t\t\t}\n\t\t}\n\n\t\tfs.writeFileSync(\n\t\t\t`${out}/server/nodes/${i}.js`,\n\t\t\t`${imports.join('\\n')}\\n\\n${exports.join('\\n')}\\n`\n\t\t);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/exports/vite/build/build_service_worker.js",
    "content": "import fs from 'node:fs';\nimport process from 'node:process';\nimport * as vite from 'vite';\nimport { dedent } from '../../../core/sync/utils.js';\nimport { s } from '../../../utils/misc.js';\nimport { get_config_aliases, strip_virtual_prefix, get_env, normalize_id } from '../utils.js';\nimport { create_static_module } from '../../../core/env.js';\nimport { env_static_public, service_worker } from '../module_ids.js';\n\n// @ts-ignore `vite.rolldownVersion` only exists in `rolldown-vite`\nconst is_rolldown = !!vite.rolldownVersion;\n\n/**\n * @param {string} out\n * @param {import('types').ValidatedKitConfig} kit\n * @param {import('vite').ResolvedConfig} vite_config\n * @param {import('types').ManifestData} manifest_data\n * @param {string} service_worker_entry_file\n * @param {import('types').Prerendered} prerendered\n * @param {import('vite').Manifest} client_manifest\n */\nexport async function build_service_worker(\n\tout,\n\tkit,\n\tvite_config,\n\tmanifest_data,\n\tservice_worker_entry_file,\n\tprerendered,\n\tclient_manifest\n) {\n\tconst build = new Set();\n\tfor (const key in client_manifest) {\n\t\tconst { file, css = [], assets = [] } = client_manifest[key];\n\t\tbuild.add(file);\n\t\tcss.forEach((file) => build.add(file));\n\t\tassets.forEach((file) => build.add(file));\n\t}\n\n\t// in a service worker, `location` is the location of the service worker itself,\n\t// which is guaranteed to be `<base>/service-worker.js`\n\tconst base = \"location.pathname.split('/').slice(0, -1).join('/')\";\n\n\tconst service_worker_code = dedent`\n\t\texport const base = /*@__PURE__*/ ${base};\n\n\t\texport const build = [\n\t\t\t${Array.from(build)\n\t\t\t\t.map((file) => `base + ${s(`/${file}`)}`)\n\t\t\t\t.join(',\\n')}\n\t\t];\n\n\t\texport const files = [\n\t\t\t${manifest_data.assets\n\t\t\t\t.filter((asset) => kit.serviceWorker.files(asset.file))\n\t\t\t\t.map((asset) => `base + ${s(`/${asset.file}`)}`)\n\t\t\t\t.join(',\\n')}\n\t\t];\n\n\t\texport const prerendered = [\n\t\t\t${prerendered.paths.map((path) => `base + ${s(path.replace(kit.paths.base, ''))}`).join(',\\n')}\n\t\t];\n\n\t\texport const version = ${s(kit.version.name)};\n\t`;\n\n\tconst env = get_env(kit.env, vite_config.mode);\n\n\t/**\n\t * @type {import('vite').Plugin}\n\t */\n\tconst sw_virtual_modules = {\n\t\tname: 'service-worker-build-virtual-modules',\n\t\tresolveId(id) {\n\t\t\tif (id.startsWith('$env/') || id.startsWith('$app/') || id === '$service-worker') {\n\t\t\t\t// ids with :$ don't work with reverse proxies like nginx\n\t\t\t\treturn `\\0virtual:${id.substring(1)}`;\n\t\t\t}\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith('\\0virtual:')) return;\n\n\t\t\tif (id === service_worker) {\n\t\t\t\treturn service_worker_code;\n\t\t\t}\n\n\t\t\tif (id === env_static_public) {\n\t\t\t\treturn create_static_module('$env/static/public', env.public);\n\t\t\t}\n\n\t\t\tconst normalized_cwd = vite.normalizePath(process.cwd());\n\t\t\tconst normalized_lib = vite.normalizePath(kit.files.lib);\n\t\t\tconst relative = normalize_id(id, normalized_lib, normalized_cwd);\n\t\t\tconst stripped = strip_virtual_prefix(relative);\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot import ${stripped} into service-worker code. Only the modules $service-worker and $env/static/public are available in service workers.`\n\t\t\t);\n\t\t}\n\t};\n\n\t/** @type {import('vite').InlineConfig} */\n\tconst config = {\n\t\tbuild: {\n\t\t\tmodulePreload: false,\n\t\t\trollupOptions: {\n\t\t\t\tinput: {\n\t\t\t\t\t'service-worker': service_worker_entry_file\n\t\t\t\t},\n\t\t\t\toutput: {\n\t\t\t\t\t// .mjs so that esbuild doesn't incorrectly inject `export` https://github.com/vitejs/vite/issues/15379\n\t\t\t\t\tentryFileNames: `service-worker.${is_rolldown ? 'js' : 'mjs'}`,\n\t\t\t\t\tassetFileNames: `${kit.appDir}/immutable/assets/[name].[hash][extname]`,\n\t\t\t\t\tinlineDynamicImports: !is_rolldown\n\t\t\t\t}\n\t\t\t},\n\t\t\toutDir: `${out}/client`,\n\t\t\temptyOutDir: false,\n\t\t\tminify: vite_config.build.minify\n\t\t},\n\t\tconfigFile: false,\n\t\tdefine: vite_config.define,\n\t\tpublicDir: false,\n\t\tplugins: [sw_virtual_modules],\n\t\tresolve: {\n\t\t\talias: [...get_config_aliases(kit)]\n\t\t},\n\t\texperimental: {\n\t\t\trenderBuiltUrl(filename) {\n\t\t\t\treturn {\n\t\t\t\t\truntime: `new URL(${JSON.stringify(filename)}, location.href).pathname`\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t};\n\n\t// we must reference Vite 8 options conditionally. Otherwise, older Vite\n\t// versions throw an error about unknown config options\n\tif (is_rolldown && config?.build?.rollupOptions?.output) {\n\t\t// @ts-ignore only available in Vite 8\n\t\tconfig.build.rollupOptions.output.codeSplitting = true;\n\t}\n\n\tawait vite.build(config);\n\n\t// rename .mjs to .js to avoid incorrect MIME types with ancient webservers\n\tif (!is_rolldown) {\n\t\tfs.renameSync(`${out}/client/service-worker.mjs`, `${out}/client/service-worker.js`);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/exports/vite/build/utils.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { normalizePath } from 'vite';\nimport { s } from '../../../utils/misc.js';\n\n/**\n * Adds transitive JS and CSS dependencies to the js and css inputs.\n * @param {import('vite').Manifest} manifest\n * @param {string} entry\n * @param {boolean} add_dynamic_css\n * @returns {import('types').AssetDependencies}\n */\nexport function find_deps(manifest, entry, add_dynamic_css) {\n\t/** @type {Set<string>} */\n\tconst seen = new Set();\n\n\t/** @type {Set<string>} */\n\tconst imports = new Set();\n\n\t/** @type {Set<string>} */\n\tconst stylesheets = new Set();\n\n\t/** @type {Set<string>} */\n\tconst imported_assets = new Set();\n\n\t/** @type {Map<string, { css: Set<string>; assets: Set<string> }>} */\n\tconst stylesheet_map = new Map();\n\n\t/**\n\t * @param {string} current\n\t * @param {boolean} add_js\n\t * @param {string} initial_importer\n\t * @param {number} dynamic_import_depth\n\t */\n\tfunction traverse(current, add_js, initial_importer, dynamic_import_depth) {\n\t\tif (seen.has(current)) return;\n\t\tseen.add(current);\n\n\t\tconst { chunk } = resolve_symlinks(manifest, current);\n\n\t\tif (add_js) imports.add(chunk.file);\n\n\t\tif (chunk.assets) {\n\t\t\tchunk.assets.forEach((asset) => imported_assets.add(asset));\n\t\t}\n\n\t\tif (chunk.css) {\n\t\t\tchunk.css.forEach((file) => stylesheets.add(file));\n\t\t}\n\n\t\tif (chunk.imports) {\n\t\t\tchunk.imports.forEach((file) =>\n\t\t\t\ttraverse(file, add_js, initial_importer, dynamic_import_depth)\n\t\t\t);\n\t\t}\n\n\t\tif (!add_dynamic_css) return;\n\n\t\tif ((chunk.css || chunk.assets) && dynamic_import_depth <= 1) {\n\t\t\t// group files based on the initial importer because if a file is only ever\n\t\t\t// a transitive dependency, it doesn't have a suitable name we can map back to\n\t\t\t// the server manifest\n\t\t\tif (stylesheet_map.has(initial_importer)) {\n\t\t\t\tconst { css, assets } = /** @type {{ css: Set<string>; assets: Set<string> }} */ (\n\t\t\t\t\tstylesheet_map.get(initial_importer)\n\t\t\t\t);\n\t\t\t\tif (chunk.css) chunk.css.forEach((file) => css.add(file));\n\t\t\t\tif (chunk.assets) chunk.assets.forEach((file) => assets.add(file));\n\t\t\t} else {\n\t\t\t\tstylesheet_map.set(initial_importer, {\n\t\t\t\t\tcss: new Set(chunk.css),\n\t\t\t\t\tassets: new Set(chunk.assets)\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (chunk.dynamicImports) {\n\t\t\tdynamic_import_depth++;\n\t\t\tchunk.dynamicImports.forEach((file) => {\n\t\t\t\ttraverse(file, false, file, dynamic_import_depth);\n\t\t\t});\n\t\t}\n\t}\n\n\tconst { chunk, file } = resolve_symlinks(manifest, entry);\n\n\ttraverse(file, true, entry, 0);\n\n\tconst assets = Array.from(imported_assets);\n\n\treturn {\n\t\tassets,\n\t\tfile: chunk.file,\n\t\timports: Array.from(imports),\n\t\tstylesheets: Array.from(stylesheets),\n\t\t// TODO do we need this separately?\n\t\tfonts: filter_fonts(assets),\n\t\tstylesheet_map\n\t};\n}\n\n/**\n * @param {import('vite').Manifest} manifest\n * @param {string} file\n */\nexport function resolve_symlinks(manifest, file) {\n\twhile (!manifest[file]) {\n\t\tconst next = normalizePath(path.relative('.', fs.realpathSync(file)));\n\t\tif (next === file) throw new Error(`Could not find file \"${file}\" in Vite manifest`);\n\t\tfile = next;\n\t}\n\n\tconst chunk = manifest[file];\n\n\treturn { chunk, file };\n}\n\n/**\n * @param {string[]} assets\n * @returns {string[]}\n */\nexport function filter_fonts(assets) {\n\treturn assets.filter((asset) => /\\.(woff2?|ttf|otf)$/.test(asset));\n}\n\n/**\n * @param {import('types').ValidatedKitConfig} config\n * @returns {string}\n */\nexport function assets_base(config) {\n\treturn (config.paths.assets || config.paths.base || '.') + '/';\n}\n\n/**\n * Writes a function with arguments used by a template literal.\n * This helps us store strings in a module and inject values at runtime.\n * @param {string} name The name of the function\n * @param {string[]} placeholder_names The names of the placeholders in the string\n * @param {string} str A string with placeholders such as \"Hello ${arg0}\".\n * \t\t\t\t\t\t\t\t\t\t It must have backticks and dollar signs escaped.\n * @returns {string} The function written as a string\n */\nexport function create_function_as_string(name, placeholder_names, str) {\n\tstr = s(str).slice(1, -1);\n\tconst args = placeholder_names ? placeholder_names.join(', ') : '';\n\treturn `function ${name}(${args}) { return \\`${str}\\`; }`;\n}\n"
  },
  {
    "path": "packages/kit/src/exports/vite/build/utils.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport { create_function_as_string } from './utils.js';\n\ntest('create_dynamic_string escapes backslashes', () => {\n\tconst input = \"div:after { content: '\\\\s'; }\";\n\tconst code = create_function_as_string('css', [], input);\n\tassert.equal(code, \"function css() { return `div:after { content: '\\\\\\\\s'; }`; }\");\n\n\tconst css = eval(`(${code})()`);\n\n\tassert.equal(css, input);\n});\n"
  },
  {
    "path": "packages/kit/src/exports/vite/dev/index.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { URL } from 'node:url';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport colors from 'kleur';\nimport sirv from 'sirv';\nimport { isCSSRequest, loadEnv, buildErrorMessage } from 'vite';\nimport { createReadableStream, getRequest, setResponse } from '../../../exports/node/index.js';\nimport { installPolyfills } from '../../../exports/node/polyfills.js';\nimport { coalesce_to_error } from '../../../utils/error.js';\nimport { from_fs, posixify, resolve_entry, to_fs } from '../../../utils/filesystem.js';\nimport { load_error_page } from '../../../core/config/index.js';\nimport { SVELTE_KIT_ASSETS } from '../../../constants.js';\nimport * as sync from '../../../core/sync/sync.js';\nimport { get_mime_lookup, runtime_base } from '../../../core/utils.js';\nimport { compact } from '../../../utils/array.js';\nimport { not_found } from '../utils.js';\nimport { SCHEME } from '../../../utils/url.js';\nimport { check_feature } from '../../../utils/features.js';\nimport { escape_html } from '../../../utils/escape.js';\n\nconst cwd = process.cwd();\n// vite-specifc queries that we should skip handling for css urls\nconst vite_css_query_regex = /(?:\\?|&)(?:raw|url|inline)(?:&|$)/;\n\n/**\n * @param {import('vite').ViteDevServer} vite\n * @param {import('vite').ResolvedConfig} vite_config\n * @param {import('types').ValidatedConfig} svelte_config\n * @param {() => Array<{ hash: string, file: string }>} get_remotes\n * @return {Promise<Promise<() => void>>}\n */\nexport async function dev(vite, vite_config, svelte_config, get_remotes) {\n\tinstallPolyfills();\n\n\tconst async_local_storage = new AsyncLocalStorage();\n\n\tglobalThis.__SVELTEKIT_TRACK__ = (label) => {\n\t\tconst context = async_local_storage.getStore();\n\t\tif (!context || context.prerender === true) return;\n\n\t\tcheck_feature(context.event.route.id, context.config, label, svelte_config.kit.adapter);\n\t};\n\n\tconst fetch = globalThis.fetch;\n\tglobalThis.fetch = (info, init) => {\n\t\tif (typeof info === 'string' && !SCHEME.test(info)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot use relative URL (${info}) with global fetch — use \\`event.fetch\\` instead: https://svelte.dev/docs/kit/web-standards#fetch-apis`\n\t\t\t);\n\t\t}\n\n\t\treturn fetch(info, init);\n\t};\n\n\tsync.init(svelte_config, vite_config.mode);\n\n\t/** @type {import('types').ManifestData} */\n\tlet manifest_data;\n\t/** @type {import('@sveltejs/kit').SSRManifest} */\n\tlet manifest;\n\n\t/** @type {Error | null} */\n\tlet manifest_error = null;\n\n\t/** @param {string} url */\n\tasync function loud_ssr_load_module(url) {\n\t\ttry {\n\t\t\treturn await vite.ssrLoadModule(url, { fixStacktrace: true });\n\t\t} catch (/** @type {any} */ err) {\n\t\t\tconst msg = buildErrorMessage(err, [colors.red(`Internal server error: ${err.message}`)]);\n\n\t\t\tif (!vite.config.logger.hasErrorLogged(err)) {\n\t\t\t\tvite.config.logger.error(msg, { error: err });\n\t\t\t}\n\n\t\t\tvite.ws.send({\n\t\t\t\ttype: 'error',\n\t\t\t\terr: {\n\t\t\t\t\t...err,\n\t\t\t\t\t// these properties are non-enumerable and will\n\t\t\t\t\t// not be serialized unless we explicitly include them\n\t\t\t\t\tmessage: err.message,\n\t\t\t\t\tstack: err.stack\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\t/** @param {string} id */\n\tasync function resolve(id) {\n\t\tconst url = id.startsWith('..') ? to_fs(path.posix.resolve(id)) : `/${id}`;\n\n\t\tconst module = await loud_ssr_load_module(url);\n\n\t\tconst module_node = await vite.moduleGraph.getModuleByUrl(url);\n\t\tif (!module_node) throw new Error(`Could not find node for ${url}`);\n\n\t\treturn { module, module_node, url };\n\t}\n\n\tfunction update_manifest() {\n\t\ttry {\n\t\t\t({ manifest_data } = sync.create(svelte_config));\n\n\t\t\tif (manifest_error) {\n\t\t\t\tmanifest_error = null;\n\t\t\t\tvite.ws.send({ type: 'full-reload' });\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tmanifest_error = /** @type {Error} */ (error);\n\n\t\t\tconsole.error(colors.bold().red(manifest_error.message));\n\t\t\tvite.ws.send({\n\t\t\t\ttype: 'error',\n\t\t\t\terr: {\n\t\t\t\t\tmessage: manifest_error.message ?? 'Invalid routes',\n\t\t\t\t\tstack: ''\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tmanifest = {\n\t\t\tappDir: svelte_config.kit.appDir,\n\t\t\tappPath: svelte_config.kit.appDir,\n\t\t\tassets: new Set(manifest_data.assets.map((asset) => asset.file)),\n\t\t\tmimeTypes: get_mime_lookup(manifest_data),\n\t\t\t_: {\n\t\t\t\tclient: {\n\t\t\t\t\tstart: `${runtime_base}/client/entry.js`,\n\t\t\t\t\tapp: `${to_fs(svelte_config.kit.outDir)}/generated/client/app.js`,\n\t\t\t\t\timports: [],\n\t\t\t\t\tstylesheets: [],\n\t\t\t\t\tfonts: [],\n\t\t\t\t\tuses_env_dynamic_public: true,\n\t\t\t\t\tnodes:\n\t\t\t\t\t\tsvelte_config.kit.router.resolution === 'client'\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: manifest_data.nodes.map((node, i) => {\n\t\t\t\t\t\t\t\t\tif (node.component || node.universal) {\n\t\t\t\t\t\t\t\t\t\treturn `${svelte_config.kit.paths.base}${to_fs(svelte_config.kit.outDir)}/generated/client/nodes/${i}.js`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t// `css` is not necessary in dev, as the JS file from `nodes` will reference the CSS file\n\t\t\t\t\troutes:\n\t\t\t\t\t\tsvelte_config.kit.router.resolution === 'client'\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: compact(\n\t\t\t\t\t\t\t\t\tmanifest_data.routes.map((route) => {\n\t\t\t\t\t\t\t\t\t\tif (!route.page) return;\n\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\tid: route.id,\n\t\t\t\t\t\t\t\t\t\t\tpattern: route.pattern,\n\t\t\t\t\t\t\t\t\t\t\tparams: route.params,\n\t\t\t\t\t\t\t\t\t\t\tlayouts: route.page.layouts.map((l) =>\n\t\t\t\t\t\t\t\t\t\t\t\tl !== undefined ? [!!manifest_data.nodes[l].server, l] : undefined\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\terrors: route.page.errors,\n\t\t\t\t\t\t\t\t\t\t\tleaf: [!!manifest_data.nodes[route.page.leaf].server, route.page.leaf]\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t\tserver_assets: new Proxy(\n\t\t\t\t\t{},\n\t\t\t\t\t{\n\t\t\t\t\t\thas: (_, /** @type {string} */ file) => fs.existsSync(from_fs(file)),\n\t\t\t\t\t\tget: (_, /** @type {string} */ file) => fs.statSync(from_fs(file)).size\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t\tnodes: manifest_data.nodes.map((node, index) => {\n\t\t\t\t\treturn async () => {\n\t\t\t\t\t\t/** @type {import('types').SSRNode} */\n\t\t\t\t\t\tconst result = {};\n\t\t\t\t\t\tresult.index = index;\n\t\t\t\t\t\tresult.universal_id = node.universal;\n\t\t\t\t\t\tresult.server_id = node.server;\n\n\t\t\t\t\t\t// these are unused in dev, but it's easier to include them\n\t\t\t\t\t\tresult.imports = [];\n\t\t\t\t\t\tresult.stylesheets = [];\n\t\t\t\t\t\tresult.fonts = [];\n\n\t\t\t\t\t\t/** @type {import('vite').ModuleNode[]} */\n\t\t\t\t\t\tconst module_nodes = [];\n\n\t\t\t\t\t\tif (node.component) {\n\t\t\t\t\t\t\tresult.component = async () => {\n\t\t\t\t\t\t\t\tconst { module_node, module } = await resolve(\n\t\t\t\t\t\t\t\t\t/** @type {string} */ (node.component)\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tmodule_nodes.push(module_node);\n\n\t\t\t\t\t\t\t\treturn module.default;\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (node.universal) {\n\t\t\t\t\t\t\tif (node.page_options?.ssr === false) {\n\t\t\t\t\t\t\t\tresult.universal = node.page_options;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// TODO: explain why the file was loaded on the server if we fail to load it\n\t\t\t\t\t\t\t\tconst { module, module_node } = await resolve(node.universal);\n\t\t\t\t\t\t\t\tmodule_nodes.push(module_node);\n\t\t\t\t\t\t\t\tresult.universal = module;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (node.server) {\n\t\t\t\t\t\t\tconst { module } = await resolve(node.server);\n\t\t\t\t\t\t\tresult.server = module;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// in dev we inline all styles to avoid FOUC. this gets populated lazily so that\n\t\t\t\t\t\t// components/stylesheets loaded via import() during `load` are included\n\t\t\t\t\t\tresult.inline_styles = async () => {\n\t\t\t\t\t\t\t/** @type {Set<import('vite').ModuleNode | import('vite').EnvironmentModuleNode>} */\n\t\t\t\t\t\t\tconst deps = new Set();\n\n\t\t\t\t\t\t\tfor (const module_node of module_nodes) {\n\t\t\t\t\t\t\t\tawait find_deps(vite, module_node, deps);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t/** @type {Record<string, string>} */\n\t\t\t\t\t\t\tconst styles = {};\n\n\t\t\t\t\t\t\tfor (const dep of deps) {\n\t\t\t\t\t\t\t\tif (isCSSRequest(dep.url) && !vite_css_query_regex.test(dep.url)) {\n\t\t\t\t\t\t\t\t\tconst inlineCssUrl = dep.url.includes('?')\n\t\t\t\t\t\t\t\t\t\t? dep.url.replace('?', '?inline&')\n\t\t\t\t\t\t\t\t\t\t: dep.url + '?inline';\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tconst mod = await vite.ssrLoadModule(inlineCssUrl);\n\t\t\t\t\t\t\t\t\t\tstyles[dep.url] = mod.default;\n\t\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t\t// this can happen with dynamically imported modules, I think\n\t\t\t\t\t\t\t\t\t\t// because the Vite module graph doesn't distinguish between\n\t\t\t\t\t\t\t\t\t\t// static and dynamic imports? TODO investigate, submit fix\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn styles;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t\tprerendered_routes: new Set(),\n\t\t\t\tget remotes() {\n\t\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t\tget_remotes().map((remote) => [\n\t\t\t\t\t\t\tremote.hash,\n\t\t\t\t\t\t\t() => vite.ssrLoadModule(remote.file).then((module) => ({ default: module }))\n\t\t\t\t\t\t])\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\troutes: compact(\n\t\t\t\t\tmanifest_data.routes.map((route) => {\n\t\t\t\t\t\tif (!route.page && !route.endpoint) return null;\n\n\t\t\t\t\t\tconst endpoint = route.endpoint;\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: route.id,\n\t\t\t\t\t\t\tpattern: route.pattern,\n\t\t\t\t\t\t\tparams: route.params,\n\t\t\t\t\t\t\tpage: route.page,\n\t\t\t\t\t\t\tendpoint: endpoint\n\t\t\t\t\t\t\t\t? async () => {\n\t\t\t\t\t\t\t\t\t\tconst url = path.resolve(cwd, endpoint.file);\n\t\t\t\t\t\t\t\t\t\treturn await loud_ssr_load_module(url);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\tendpoint_id: endpoint?.file\n\t\t\t\t\t\t};\n\t\t\t\t\t})\n\t\t\t\t),\n\t\t\t\tmatchers: async () => {\n\t\t\t\t\t/** @type {Record<string, import('@sveltejs/kit').ParamMatcher>} */\n\t\t\t\t\tconst matchers = {};\n\n\t\t\t\t\tfor (const key in manifest_data.matchers) {\n\t\t\t\t\t\tconst file = manifest_data.matchers[key];\n\t\t\t\t\t\tconst url = path.resolve(cwd, file);\n\t\t\t\t\t\tconst module = await vite.ssrLoadModule(url, { fixStacktrace: true });\n\n\t\t\t\t\t\tif (module.match) {\n\t\t\t\t\t\t\tmatchers[key] = module.match;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new Error(`${file} does not export a \\`match\\` function`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn matchers;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\t/** @param {Error} error */\n\tfunction fix_stack_trace(error) {\n\t\ttry {\n\t\t\tvite.ssrFixStacktrace(error);\n\t\t} catch {\n\t\t\t// ssrFixStacktrace can fail on StackBlitz web containers and we don't know why\n\t\t\t// by ignoring it the line numbers are wrong, but at least we can show the error\n\t\t}\n\t\treturn error.stack;\n\t}\n\n\tupdate_manifest();\n\n\t/**\n\t * @param {string} event\n\t * @param {(file: string) => void} cb\n\t */\n\tconst watch = (event, cb) => {\n\t\tvite.watcher.on(event, (file) => {\n\t\t\tif (\n\t\t\t\tfile.startsWith(svelte_config.kit.files.routes + path.sep) ||\n\t\t\t\tfile.startsWith(svelte_config.kit.files.params + path.sep) ||\n\t\t\t\tsvelte_config.kit.moduleExtensions.some((ext) => file.endsWith(`.remote${ext}`)) ||\n\t\t\t\t// in contrast to server hooks, client hooks are written to the client manifest\n\t\t\t\t// and therefore need rebuilding when they are added/removed\n\t\t\t\tfile.startsWith(svelte_config.kit.files.hooks.client)\n\t\t\t) {\n\t\t\t\tcb(file);\n\t\t\t}\n\t\t});\n\t};\n\t/** @type {NodeJS.Timeout | null } */\n\tlet timeout = null;\n\t/** @param {() => void} to_run */\n\tconst debounce = (to_run) => {\n\t\ttimeout && clearTimeout(timeout);\n\t\ttimeout = setTimeout(() => {\n\t\t\ttimeout = null;\n\t\t\tto_run();\n\t\t}, 100);\n\t};\n\n\t// flag to skip watchers if server is already restarting\n\tlet restarting = false;\n\n\t// Debounce add/unlink events because in case of folder deletion or moves\n\t// they fire in rapid succession, causing needless invocations.\n\t// These watchers only run for routes, param matchers, and client hooks.\n\twatch('add', () => debounce(update_manifest));\n\twatch('unlink', () => debounce(update_manifest));\n\twatch('change', (file) => {\n\t\t// Don't run for a single file if the whole manifest is about to get updated\n\t\t// Unless it's a file where the trailing slash page option might have changed\n\t\tif (timeout || restarting || !/\\+(page|layout|server).*$/.test(file)) return;\n\t\tsync.update(svelte_config, manifest_data, file);\n\t});\n\n\tconst { appTemplate, errorTemplate, serviceWorker, hooks } = svelte_config.kit.files;\n\n\t// vite client only executes a full reload if the triggering html file path is index.html\n\t// kit defaults to src/app.html, so unless user changed that to index.html\n\t// send the vite client a full-reload event without path being set\n\tif (appTemplate !== 'index.html') {\n\t\tvite.watcher.on('change', (file) => {\n\t\t\tif (file === appTemplate && !restarting) {\n\t\t\t\tvite.ws.send({ type: 'full-reload' });\n\t\t\t}\n\t\t});\n\t}\n\n\tvite.watcher.on('all', (_, file) => {\n\t\tif (\n\t\t\tfile === appTemplate ||\n\t\t\tfile === errorTemplate ||\n\t\t\tfile.startsWith(serviceWorker) ||\n\t\t\tfile.startsWith(hooks.server)\n\t\t) {\n\t\t\tsync.server(svelte_config);\n\t\t}\n\t});\n\n\tvite.watcher.on('change', async (file) => {\n\t\t// changing the svelte config requires restarting the dev server\n\t\t// the config is only read on start and passed on to vite-plugin-svelte\n\t\t// which needs up-to-date values to operate correctly\n\t\tif (file.match(/[/\\\\]svelte\\.config\\.[jt]s$/)) {\n\t\t\tconsole.log(`svelte config changed, restarting vite dev-server. changed file: ${file}`);\n\t\t\trestarting = true;\n\t\t\tawait vite.restart();\n\t\t}\n\t});\n\n\tconst assets = svelte_config.kit.paths.assets ? SVELTE_KIT_ASSETS : svelte_config.kit.paths.base;\n\tconst asset_server = sirv(svelte_config.kit.files.assets, {\n\t\tdev: true,\n\t\tetag: true,\n\t\tmaxAge: 0,\n\t\textensions: [],\n\t\tsetHeaders: (res) => {\n\t\t\tres.setHeader('access-control-allow-origin', '*');\n\t\t}\n\t});\n\n\tvite.middlewares.use((req, res, next) => {\n\t\tconst base = `${vite.config.server.https ? 'https' : 'http'}://${\n\t\t\treq.headers[':authority'] || req.headers.host\n\t\t}`;\n\n\t\tconst decoded = decodeURI(new URL(base + req.url).pathname);\n\n\t\tif (decoded.startsWith(assets)) {\n\t\t\tconst pathname = decoded.slice(assets.length);\n\t\t\tconst file = svelte_config.kit.files.assets + pathname;\n\n\t\t\tif (fs.existsSync(file) && !fs.statSync(file).isDirectory()) {\n\t\t\t\tif (has_correct_case(file, svelte_config.kit.files.assets)) {\n\t\t\t\t\treq.url = encodeURI(pathname); // don't need query/hash\n\t\t\t\t\tasset_server(req, res);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tnext();\n\t});\n\n\tconst env = loadEnv(vite_config.mode, svelte_config.kit.env.dir, '');\n\tconst emulator = await svelte_config.kit.adapter?.emulate?.();\n\n\treturn () => {\n\t\tconst serve_static_middleware = vite.middlewares.stack.find(\n\t\t\t(middleware) =>\n\t\t\t\t/** @type {function} */ (middleware.handle).name === 'viteServeStaticMiddleware'\n\t\t);\n\n\t\t// Vite will give a 403 on URLs like /test, /static, and /package.json preventing us from\n\t\t// serving routes with those names. See https://github.com/vitejs/vite/issues/7363\n\t\tremove_static_middlewares(vite.middlewares);\n\n\t\tvite.middlewares.use(async (req, res) => {\n\t\t\t// Vite's base middleware strips out the base path. Restore it\n\t\t\tconst original_url = req.url;\n\t\t\treq.url = req.originalUrl;\n\t\t\ttry {\n\t\t\t\tconst base = `${vite.config.server.https ? 'https' : 'http'}://${\n\t\t\t\t\treq.headers[':authority'] || req.headers.host\n\t\t\t\t}`;\n\n\t\t\t\tconst decoded = decodeURI(new URL(base + req.url).pathname);\n\t\t\t\tconst file = posixify(path.resolve(decoded.slice(svelte_config.kit.paths.base.length + 1)));\n\t\t\t\tconst is_file = fs.existsSync(file) && !fs.statSync(file).isDirectory();\n\t\t\t\tconst allowed =\n\t\t\t\t\t!vite_config.server.fs.strict ||\n\t\t\t\t\tvite_config.server.fs.allow.some((dir) => file.startsWith(dir));\n\n\t\t\t\tif (is_file && allowed) {\n\t\t\t\t\treq.url = original_url;\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tserve_static_middleware.handle(req, res);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!decoded.startsWith(svelte_config.kit.paths.base)) {\n\t\t\t\t\treturn not_found(req, res, svelte_config.kit.paths.base);\n\t\t\t\t}\n\n\t\t\t\tif (decoded === svelte_config.kit.paths.base + '/service-worker.js') {\n\t\t\t\t\tconst resolved = resolve_entry(svelte_config.kit.files.serviceWorker);\n\n\t\t\t\t\tif (resolved) {\n\t\t\t\t\t\tres.writeHead(200, {\n\t\t\t\t\t\t\t'content-type': 'application/javascript'\n\t\t\t\t\t\t});\n\t\t\t\t\t\tres.end(`import '${svelte_config.kit.paths.base}${to_fs(resolved)}';`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tres.writeHead(404);\n\t\t\t\t\t\tres.end('not found');\n\t\t\t\t\t}\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst resolved_instrumentation = resolve_entry(\n\t\t\t\t\tpath.join(svelte_config.kit.files.src, 'instrumentation.server')\n\t\t\t\t);\n\n\t\t\t\tif (resolved_instrumentation) {\n\t\t\t\t\tawait vite.ssrLoadModule(resolved_instrumentation);\n\t\t\t\t}\n\n\t\t\t\t// we have to import `Server` before calling `set_assets`\n\t\t\t\tconst { Server } = /** @type {import('types').ServerModule} */ (\n\t\t\t\t\tawait vite.ssrLoadModule(`${runtime_base}/server/index.js`, { fixStacktrace: true })\n\t\t\t\t);\n\n\t\t\t\tconst { set_fix_stack_trace } = await vite.ssrLoadModule(\n\t\t\t\t\t`${runtime_base}/shared-server.js`\n\t\t\t\t);\n\t\t\t\tset_fix_stack_trace(fix_stack_trace);\n\n\t\t\t\tconst { set_assets } = await vite.ssrLoadModule('$app/paths/internal/server');\n\t\t\t\tset_assets(assets);\n\n\t\t\t\tconst server = new Server(manifest);\n\n\t\t\t\tawait server.init({\n\t\t\t\t\tenv,\n\t\t\t\t\tread: (file) => createReadableStream(from_fs(file))\n\t\t\t\t});\n\n\t\t\t\tconst request = await getRequest({\n\t\t\t\t\tbase,\n\t\t\t\t\trequest: req\n\t\t\t\t});\n\n\t\t\t\tif (manifest_error) {\n\t\t\t\t\tconsole.error(colors.bold().red(manifest_error.message));\n\n\t\t\t\t\tconst error_page = load_error_page(svelte_config);\n\n\t\t\t\t\t/** @param {{ status: number; message: string }} opts */\n\t\t\t\t\tconst error_template = ({ status, message }) => {\n\t\t\t\t\t\treturn error_page\n\t\t\t\t\t\t\t.replace(/%sveltekit\\.status%/g, String(status))\n\t\t\t\t\t\t\t.replace(/%sveltekit\\.error\\.message%/g, escape_html(message));\n\t\t\t\t\t};\n\n\t\t\t\t\tres.writeHead(500, {\n\t\t\t\t\t\t'Content-Type': 'text/html; charset=utf-8'\n\t\t\t\t\t});\n\t\t\t\t\tres.end(\n\t\t\t\t\t\terror_template({ status: 500, message: manifest_error.message ?? 'Invalid routes' })\n\t\t\t\t\t);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst rendered = await server.respond(request, {\n\t\t\t\t\tgetClientAddress: () => {\n\t\t\t\t\t\tconst { remoteAddress } = req.socket;\n\t\t\t\t\t\tif (remoteAddress) return remoteAddress;\n\t\t\t\t\t\tthrow new Error('Could not determine clientAddress');\n\t\t\t\t\t},\n\t\t\t\t\tread: (file) => {\n\t\t\t\t\t\tif (file in manifest._.server_assets) {\n\t\t\t\t\t\t\treturn fs.readFileSync(from_fs(file));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn fs.readFileSync(path.join(svelte_config.kit.files.assets, file));\n\t\t\t\t\t},\n\t\t\t\t\tbefore_handle: (event, config, prerender) => {\n\t\t\t\t\t\tasync_local_storage.enterWith({ event, config, prerender });\n\t\t\t\t\t},\n\t\t\t\t\temulator\n\t\t\t\t});\n\n\t\t\t\tif (rendered.status === 404) {\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tserve_static_middleware.handle(req, res, () => {\n\t\t\t\t\t\tvoid setResponse(res, rendered);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tvoid setResponse(res, rendered);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconst error = coalesce_to_error(e);\n\t\t\t\tres.statusCode = 500;\n\t\t\t\tres.end(fix_stack_trace(error));\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * @param {import('connect').Server} server\n */\nfunction remove_static_middlewares(server) {\n\tconst static_middlewares = ['viteServeStaticMiddleware', 'viteServePublicMiddleware'];\n\tfor (let i = server.stack.length - 1; i > 0; i--) {\n\t\t// @ts-expect-error using internals\n\t\tif (static_middlewares.includes(server.stack[i].handle.name)) {\n\t\t\tserver.stack.splice(i, 1);\n\t\t}\n\t}\n}\n\n/**\n * @param {import('vite').ViteDevServer} vite\n * @param {import('vite').ModuleNode | import('vite').EnvironmentModuleNode} node\n * @param {Set<import('vite').ModuleNode | import('vite').EnvironmentModuleNode>} deps\n */\nasync function find_deps(vite, node, deps) {\n\t// since `ssrTransformResult.deps` contains URLs instead of `ModuleNode`s, this process is asynchronous.\n\t// instead of using `await`, we resolve all branches in parallel.\n\t/** @type {Promise<void>[]} */\n\tconst branches = [];\n\n\t/** @param {import('vite').ModuleNode | import('vite').EnvironmentModuleNode} node */\n\tasync function add(node) {\n\t\tif (!deps.has(node)) {\n\t\t\tdeps.add(node);\n\t\t\tawait find_deps(vite, node, deps);\n\t\t}\n\t}\n\n\t/** @param {string} url */\n\tasync function add_by_url(url) {\n\t\tconst node = await get_server_module_by_url(vite, url);\n\n\t\tif (node) {\n\t\t\tawait add(node);\n\t\t}\n\t}\n\n\tconst transform_result =\n\t\t/** @type {import('vite').ModuleNode} */ (node).ssrTransformResult || node.transformResult;\n\n\tif (transform_result) {\n\t\tif (transform_result.deps) {\n\t\t\ttransform_result.deps.forEach((url) => branches.push(add_by_url(url)));\n\t\t}\n\n\t\tif (transform_result.dynamicDeps) {\n\t\t\ttransform_result.dynamicDeps.forEach((url) => branches.push(add_by_url(url)));\n\t\t}\n\t} else {\n\t\tnode.importedModules.forEach((node) => branches.push(add(node)));\n\t}\n\n\tawait Promise.all(branches);\n}\n\n/**\n * @param {import('vite').ViteDevServer} vite\n * @param {string} url\n */\nfunction get_server_module_by_url(vite, url) {\n\treturn vite.environments\n\t\t? vite.environments.ssr.moduleGraph.getModuleByUrl(url)\n\t\t: vite.moduleGraph.getModuleByUrl(url, true);\n}\n\n/**\n * Determine if a file is being requested with the correct case,\n * to ensure consistent behaviour between dev and prod and across\n * operating systems. Note that we can't use realpath here,\n * because we don't want to follow symlinks\n * @param {string} file\n * @param {string} assets\n * @returns {boolean}\n */\nfunction has_correct_case(file, assets) {\n\tif (file === assets) return true;\n\n\tconst parent = path.dirname(file);\n\n\tif (fs.readdirSync(parent).includes(path.basename(file))) {\n\t\treturn has_correct_case(parent, assets);\n\t}\n\n\treturn false;\n}\n"
  },
  {
    "path": "packages/kit/src/exports/vite/index.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\n\nimport colors from 'kleur';\n\nimport { copy, mkdirp, posixify, read, resolve_entry, rimraf } from '../../utils/filesystem.js';\nimport { create_static_module, create_dynamic_module } from '../../core/env.js';\nimport * as sync from '../../core/sync/sync.js';\nimport { create_assets } from '../../core/sync/create_manifest_data/index.js';\nimport { runtime_directory, logger } from '../../core/utils.js';\nimport { load_config } from '../../core/config/index.js';\nimport { generate_manifest } from '../../core/generate_manifest/index.js';\nimport { build_server_nodes } from './build/build_server.js';\nimport { build_service_worker } from './build/build_service_worker.js';\nimport { assets_base, find_deps, resolve_symlinks } from './build/utils.js';\nimport { dev } from './dev/index.js';\nimport { preview } from './preview/index.js';\nimport {\n\terror_for_missing_config,\n\tget_config_aliases,\n\tget_env,\n\tnormalize_id,\n\tstackless\n} from './utils.js';\nimport { write_client_manifest } from '../../core/sync/write_client_manifest.js';\nimport prerender from '../../core/postbuild/prerender.js';\nimport analyse from '../../core/postbuild/analyse.js';\nimport { s } from '../../utils/misc.js';\nimport { hash } from '../../utils/hash.js';\nimport { dedent, isSvelte5Plus } from '../../core/sync/utils.js';\nimport {\n\tenv_dynamic_private,\n\tenv_dynamic_public,\n\tenv_static_private,\n\tenv_static_public,\n\tservice_worker,\n\tsveltekit_environment,\n\tsveltekit_server\n} from './module_ids.js';\nimport { import_peer } from '../../utils/import.js';\nimport { compact } from '../../utils/array.js';\nimport { should_ignore, has_children } from './static_analysis/utils.js';\n\nconst cwd = posixify(process.cwd());\n\n/** @type {import('./types.js').EnforcedConfig} */\nconst enforced_config = {\n\tappType: true,\n\tbase: true,\n\tbuild: {\n\t\tcssCodeSplit: true,\n\t\temptyOutDir: true,\n\t\tlib: {\n\t\t\tentry: true,\n\t\t\tname: true,\n\t\t\tformats: true\n\t\t},\n\t\tmanifest: true,\n\t\toutDir: true,\n\t\trollupOptions: {\n\t\t\tinput: true,\n\t\t\toutput: {\n\t\t\t\tformat: true,\n\t\t\t\tentryFileNames: true,\n\t\t\t\tchunkFileNames: true,\n\t\t\t\tassetFileNames: true\n\t\t\t},\n\t\t\tpreserveEntrySignatures: true\n\t\t},\n\t\tssr: true\n\t},\n\tpublicDir: true,\n\tresolve: {\n\t\talias: {\n\t\t\t$app: true,\n\t\t\t$lib: true,\n\t\t\t'$service-worker': true\n\t\t}\n\t},\n\troot: true\n};\n\nconst options_regex = /(export\\s+const\\s+(prerender|csr|ssr|trailingSlash))\\s*=/s;\n\n/** @type {Set<string>} */\nconst warned = new Set();\n\n/** @type {import('svelte/compiler').PreprocessorGroup} */\nconst warning_preprocessor = {\n\tscript: ({ content, filename }) => {\n\t\tif (!filename) return;\n\n\t\tconst basename = path.basename(filename);\n\t\tif (basename.startsWith('+page.') || basename.startsWith('+layout.')) {\n\t\t\tconst match = content.match(options_regex);\n\t\t\tif (match && match.index !== undefined && !should_ignore(content, match.index)) {\n\t\t\t\tconst fixed = basename.replace('.svelte', '(.server).js/ts');\n\n\t\t\t\tconst message =\n\t\t\t\t\t`\\n${colors.bold().red(path.relative('.', filename))}\\n` +\n\t\t\t\t\t`\\`${match[1]}\\` will be ignored — move it to ${fixed} instead. See https://svelte.dev/docs/kit/page-options for more information.`;\n\n\t\t\t\tif (!warned.has(message)) {\n\t\t\t\t\tconsole.log(message);\n\t\t\t\t\twarned.add(message);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tmarkup: ({ content, filename }) => {\n\t\tif (!filename) return;\n\n\t\tconst basename = path.basename(filename);\n\n\t\tif (basename.startsWith('+layout.') && !has_children(content, isSvelte5Plus())) {\n\t\t\tconst message =\n\t\t\t\t`\\n${colors.bold().red(path.relative('.', filename))}\\n` +\n\t\t\t\t`\\`<slot />\\`${isSvelte5Plus() ? ' or `{@render ...}` tag' : ''}` +\n\t\t\t\t' missing — inner content will not be rendered';\n\n\t\t\tif (!warned.has(message)) {\n\t\t\t\tconsole.log(message);\n\t\t\t\twarned.add(message);\n\t\t\t}\n\t\t}\n\t}\n};\n\n/**\n * Returns the SvelteKit Vite plugins.\n * @returns {Promise<import('vite').Plugin[]>}\n */\nexport async function sveltekit() {\n\tconst svelte_config = await load_config();\n\n\t/** @type {import('@sveltejs/vite-plugin-svelte').Options['preprocess']} */\n\tlet preprocess = svelte_config.preprocess;\n\tif (Array.isArray(preprocess)) {\n\t\tpreprocess = [...preprocess, warning_preprocessor];\n\t} else if (preprocess) {\n\t\tpreprocess = [preprocess, warning_preprocessor];\n\t} else {\n\t\tpreprocess = warning_preprocessor;\n\t}\n\n\t/** @type {import('@sveltejs/vite-plugin-svelte').Options} */\n\tconst vite_plugin_svelte_options = {\n\t\tconfigFile: false,\n\t\textensions: svelte_config.extensions,\n\t\tpreprocess,\n\t\tonwarn: svelte_config.onwarn,\n\t\tcompilerOptions: {\n\t\t\t// @ts-ignore - ignore this property when running `pnpm check` against Svelte 5 in the ecosystem CI\n\t\t\thydratable: isSvelte5Plus() ? undefined : true,\n\t\t\t...svelte_config.compilerOptions\n\t\t},\n\t\t...svelte_config.vitePlugin\n\t};\n\n\tconst { svelte } = await import_peer('@sveltejs/vite-plugin-svelte');\n\n\treturn [...svelte(vite_plugin_svelte_options), ...(await kit({ svelte_config }))];\n}\n\n// These variables live outside the `kit()` function because it is re-invoked by each Vite build\n\nlet secondary_build_started = false;\n\n/** @type {import('types').ManifestData} */\nlet manifest_data;\n\n/** @type {import('types').ServerMetadata | undefined} only set at build time once analysis is finished */\nlet build_metadata = undefined;\n\n/**\n * Returns the SvelteKit Vite plugin. Vite executes Rollup hooks as well as some of its own.\n * Background reading is available at:\n * - https://vitejs.dev/guide/api-plugin.html\n * - https://rollupjs.org/guide/en/#plugin-development\n *\n * You can get an idea of the lifecycle by looking at the flow charts here:\n * - https://rollupjs.org/guide/en/#build-hooks\n * - https://rollupjs.org/guide/en/#output-generation-hooks\n *\n * @param {{ svelte_config: import('types').ValidatedConfig }} options\n * @return {Promise<import('vite').Plugin[]>}\n */\nasync function kit({ svelte_config }) {\n\t/** @type {import('vite')} */\n\tconst vite = await import_peer('vite');\n\n\t// @ts-ignore `vite.rolldownVersion` only exists in `vite 8`\n\tconst is_rolldown = !!vite.rolldownVersion;\n\n\tconst { kit } = svelte_config;\n\tconst out = `${kit.outDir}/output`;\n\n\tconst version_hash = hash(kit.version.name);\n\n\t/** @type {import('vite').ResolvedConfig} */\n\tlet vite_config;\n\n\t/** @type {import('vite').ConfigEnv} */\n\tlet vite_config_env;\n\n\t/** @type {boolean} */\n\tlet is_build;\n\n\t/** @type {{ public: Record<string, string>; private: Record<string, string> }} */\n\tlet env;\n\n\t/** @type {() => Promise<void>} */\n\tlet finalise;\n\n\t/** @type {import('vite').UserConfig} */\n\tlet initial_config;\n\n\tconst service_worker_entry_file = resolve_entry(kit.files.serviceWorker);\n\tconst parsed_service_worker = path.parse(kit.files.serviceWorker);\n\n\tconst normalized_cwd = vite.normalizePath(cwd);\n\tconst normalized_lib = vite.normalizePath(kit.files.lib);\n\tconst normalized_node_modules = vite.normalizePath(path.resolve('node_modules'));\n\n\t/**\n\t * A map showing which features (such as `$app/server:read`) are defined\n\t * in which chunks, so that we can later determine which routes use which features\n\t * @type {Record<string, string[]>}\n\t */\n\tconst tracked_features = {};\n\n\tconst sourcemapIgnoreList = /** @param {string} relative_path */ (relative_path) =>\n\t\trelative_path.includes('node_modules') || relative_path.includes(kit.outDir);\n\n\t/** @type {import('vite').Plugin} */\n\tconst plugin_setup = {\n\t\tname: 'vite-plugin-sveltekit-setup',\n\n\t\t/**\n\t\t * Build the SvelteKit-provided Vite config to be merged with the user's vite.config.js file.\n\t\t * @see https://vitejs.dev/guide/api-plugin.html#config\n\t\t */\n\t\tconfig(config, config_env) {\n\t\t\tinitial_config = config;\n\t\t\tvite_config_env = config_env;\n\t\t\tis_build = config_env.command === 'build';\n\n\t\t\tenv = get_env(kit.env, vite_config_env.mode);\n\n\t\t\tconst allow = new Set([\n\t\t\t\tkit.files.lib,\n\t\t\t\tkit.files.routes,\n\t\t\t\tkit.outDir,\n\t\t\t\tpath.resolve('src'), // TODO this isn't correct if user changed all his files to sth else than src (like in test/options)\n\t\t\t\tpath.resolve('node_modules'),\n\t\t\t\tpath.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')\n\t\t\t]);\n\n\t\t\t// We can only add directories to the allow list, so we find out\n\t\t\t// if there's a client hooks file and pass its directory\n\t\t\tconst client_hooks = resolve_entry(kit.files.hooks.client);\n\t\t\tif (client_hooks) allow.add(path.dirname(client_hooks));\n\n\t\t\tconst generated = path.posix.join(kit.outDir, 'generated');\n\n\t\t\t// dev and preview config can be shared\n\t\t\t/** @type {import('vite').UserConfig} */\n\t\t\tconst new_config = {\n\t\t\t\tresolve: {\n\t\t\t\t\talias: [\n\t\t\t\t\t\t{ find: '__SERVER__', replacement: `${generated}/server` },\n\t\t\t\t\t\t{ find: '$app', replacement: `${runtime_directory}/app` },\n\t\t\t\t\t\t...get_config_aliases(kit)\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\troot: cwd,\n\t\t\t\tserver: {\n\t\t\t\t\tcors: { preflightContinue: true },\n\t\t\t\t\tfs: {\n\t\t\t\t\t\tallow: [...allow]\n\t\t\t\t\t},\n\t\t\t\t\tsourcemapIgnoreList,\n\t\t\t\t\twatch: {\n\t\t\t\t\t\tignored: [\n\t\t\t\t\t\t\t// Ignore all siblings of config.kit.outDir/generated\n\t\t\t\t\t\t\t`${posixify(kit.outDir)}/!(generated)`\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tpreview: {\n\t\t\t\t\tcors: { preflightContinue: true }\n\t\t\t\t},\n\t\t\t\toptimizeDeps: {\n\t\t\t\t\tentries: [\n\t\t\t\t\t\t`${kit.files.routes}/**/+*.{svelte,js,ts}`,\n\t\t\t\t\t\t`!${kit.files.routes}/**/+*server.*`\n\t\t\t\t\t],\n\t\t\t\t\texclude: [\n\t\t\t\t\t\t// Without this SvelteKit will be prebundled on the client, which means we end up with two versions of Redirect etc.\n\t\t\t\t\t\t// Also see https://github.com/sveltejs/kit/issues/5952#issuecomment-1218844057\n\t\t\t\t\t\t'@sveltejs/kit',\n\t\t\t\t\t\t// exclude kit features so that libraries using them work even when they are prebundled\n\t\t\t\t\t\t// this does not affect app code, just handling of imported libraries that use $app or $env\n\t\t\t\t\t\t'$app',\n\t\t\t\t\t\t'$env'\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\tssr: {\n\t\t\t\t\tnoExternal: [\n\t\t\t\t\t\t// This ensures that esm-env is inlined into the server output with the\n\t\t\t\t\t\t// export conditions resolved correctly through Vite. This prevents adapters\n\t\t\t\t\t\t// that bundle later on from resolving the export conditions incorrectly\n\t\t\t\t\t\t// and for example include browser-only code in the server output\n\t\t\t\t\t\t// because they for example use esbuild.build with `platform: 'browser'`\n\t\t\t\t\t\t'esm-env',\n\t\t\t\t\t\t// This forces `$app/*` modules to be bundled, since they depend on\n\t\t\t\t\t\t// virtual modules like `__sveltekit/environment` (this isn't a valid bare\n\t\t\t\t\t\t// import, but it works with vite-node's externalization logic, which\n\t\t\t\t\t\t// uses basic concatenation)\n\t\t\t\t\t\t'@sveltejs/kit/src/runtime'\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (kit.experimental.remoteFunctions) {\n\t\t\t\t// treat .remote.js files as empty for the purposes of prebundling\n\t\t\t\t// detects rolldown to avoid a warning message in vite 8 beta\n\t\t\t\tconst remote_id_filter = new RegExp(\n\t\t\t\t\t`.remote(${kit.moduleExtensions.join('|')})$`.replaceAll('.', '\\\\.')\n\t\t\t\t);\n\t\t\t\tnew_config.optimizeDeps ??= {}; // for some reason ts says this could be undefined even though it was set above\n\t\t\t\tif (is_rolldown) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tnew_config.optimizeDeps.rolldownOptions ??= {};\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tnew_config.optimizeDeps.rolldownOptions.plugins ??= [];\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tnew_config.optimizeDeps.rolldownOptions.plugins.push({\n\t\t\t\t\t\tname: 'vite-plugin-sveltekit-setup:optimize-remote-functions',\n\t\t\t\t\t\tload: {\n\t\t\t\t\t\t\tfilter: { id: remote_id_filter },\n\t\t\t\t\t\t\thandler() {\n\t\t\t\t\t\t\t\treturn '';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tnew_config.optimizeDeps.esbuildOptions ??= {};\n\t\t\t\t\tnew_config.optimizeDeps.esbuildOptions.plugins ??= [];\n\t\t\t\t\tnew_config.optimizeDeps.esbuildOptions.plugins.push({\n\t\t\t\t\t\tname: 'vite-plugin-sveltekit-setup:optimize-remote-functions',\n\t\t\t\t\t\tsetup(build) {\n\t\t\t\t\t\t\tbuild.onLoad({ filter: remote_id_filter }, () => ({ contents: '' }));\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst define = {\n\t\t\t\t__SVELTEKIT_APP_DIR__: s(kit.appDir),\n\t\t\t\t__SVELTEKIT_EMBEDDED__: s(kit.embedded),\n\t\t\t\t__SVELTEKIT_EXPERIMENTAL__REMOTE_FUNCTIONS__: s(kit.experimental.remoteFunctions),\n\t\t\t\t__SVELTEKIT_FORK_PRELOADS__: s(kit.experimental.forkPreloads),\n\t\t\t\t__SVELTEKIT_PATHS_ASSETS__: s(kit.paths.assets),\n\t\t\t\t__SVELTEKIT_PATHS_BASE__: s(kit.paths.base),\n\t\t\t\t__SVELTEKIT_PATHS_RELATIVE__: s(kit.paths.relative),\n\t\t\t\t__SVELTEKIT_CLIENT_ROUTING__: s(kit.router.resolution === 'client'),\n\t\t\t\t__SVELTEKIT_HASH_ROUTING__: s(kit.router.type === 'hash'),\n\t\t\t\t__SVELTEKIT_SERVER_TRACING_ENABLED__: s(kit.experimental.tracing.server),\n\t\t\t\t__SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__: s(kit.experimental.handleRenderingErrors)\n\t\t\t};\n\n\t\t\tif (is_build) {\n\t\t\t\tif (!new_config.build) new_config.build = {};\n\t\t\t\tnew_config.build.ssr = !secondary_build_started;\n\n\t\t\t\tnew_config.define = {\n\t\t\t\t\t...define,\n\t\t\t\t\t__SVELTEKIT_ADAPTER_NAME__: s(kit.adapter?.name),\n\t\t\t\t\t__SVELTEKIT_APP_VERSION_FILE__: s(`${kit.appDir}/version.json`),\n\t\t\t\t\t__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: s(kit.version.pollInterval),\n\t\t\t\t\t__SVELTEKIT_PAYLOAD__: new_config.build.ssr\n\t\t\t\t\t\t? '{}'\n\t\t\t\t\t\t: `globalThis.__sveltekit_${version_hash}`\n\t\t\t\t};\n\n\t\t\t\tif (!secondary_build_started) {\n\t\t\t\t\tmanifest_data = sync.all(svelte_config, config_env.mode).manifest_data;\n\t\t\t\t\t// During the initial server build we don't know yet\n\t\t\t\t\tnew_config.define.__SVELTEKIT_HAS_SERVER_LOAD__ = 'true';\n\t\t\t\t\tnew_config.define.__SVELTEKIT_HAS_UNIVERSAL_LOAD__ = 'true';\n\t\t\t\t} else {\n\t\t\t\t\tconst nodes = Object.values(\n\t\t\t\t\t\t/** @type {import('types').ServerMetadata} */ (build_metadata).nodes\n\t\t\t\t\t);\n\n\t\t\t\t\t// Through the finished analysis we can now check if any node has server or universal load functions\n\t\t\t\t\tconst has_server_load = nodes.some((node) => node.has_server_load);\n\t\t\t\t\tconst has_universal_load = nodes.some((node) => node.has_universal_load);\n\n\t\t\t\t\tnew_config.define.__SVELTEKIT_HAS_SERVER_LOAD__ = s(has_server_load);\n\t\t\t\t\tnew_config.define.__SVELTEKIT_HAS_UNIVERSAL_LOAD__ = s(has_universal_load);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnew_config.define = {\n\t\t\t\t\t...define,\n\t\t\t\t\t__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0',\n\t\t\t\t\t__SVELTEKIT_PAYLOAD__: 'globalThis.__sveltekit_dev',\n\t\t\t\t\t__SVELTEKIT_HAS_SERVER_LOAD__: 'true',\n\t\t\t\t\t__SVELTEKIT_HAS_UNIVERSAL_LOAD__: 'true'\n\t\t\t\t};\n\n\t\t\t\t// @ts-ignore this prevents a reference error if `client.js` is imported on the server\n\t\t\t\tglobalThis.__sveltekit_dev = {};\n\n\t\t\t\t// These Kit dependencies are packaged as CommonJS, which means they must always be externalized.\n\t\t\t\t// Without this, the tests will still pass but `pnpm dev` will fail in projects that link `@sveltejs/kit`.\n\t\t\t\t/** @type {NonNullable<import('vite').UserConfig['ssr']>} */ (new_config.ssr).external = [\n\t\t\t\t\t'cookie',\n\t\t\t\t\t'set-cookie-parser'\n\t\t\t\t];\n\t\t\t}\n\n\t\t\twarn_overridden_config(config, new_config);\n\n\t\t\treturn new_config;\n\t\t},\n\n\t\t/**\n\t\t * Stores the final config.\n\t\t */\n\t\tconfigResolved(config) {\n\t\t\tvite_config = config;\n\t\t}\n\t};\n\n\t/** @type {import('vite').Plugin} */\n\tconst plugin_virtual_modules = {\n\t\tname: 'vite-plugin-sveltekit-virtual-modules',\n\n\t\tresolveId(id, importer) {\n\t\t\tif (id === '__sveltekit/manifest') {\n\t\t\t\treturn `${kit.outDir}/generated/client-optimized/app.js`;\n\t\t\t}\n\n\t\t\t// If importing from a service-worker, only allow $service-worker & $env/static/public, but none of the other virtual modules.\n\t\t\t// This check won't catch transitive imports, but it will warn when the import comes from a service-worker directly.\n\t\t\t// Transitive imports will be caught during the build.\n\t\t\t// TODO move this logic to plugin_guard\n\t\t\tif (importer) {\n\t\t\t\tconst parsed_importer = path.parse(importer);\n\n\t\t\t\tconst importer_is_service_worker =\n\t\t\t\t\tparsed_importer.dir === parsed_service_worker.dir &&\n\t\t\t\t\tparsed_importer.name === parsed_service_worker.name;\n\n\t\t\t\tif (importer_is_service_worker && id !== '$service-worker' && id !== '$env/static/public') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Cannot import ${normalize_id(\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tnormalized_lib,\n\t\t\t\t\t\t\tnormalized_cwd\n\t\t\t\t\t\t)} into service-worker code. Only the modules $service-worker and $env/static/public are available in service workers.`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// treat $env/static/[public|private] as virtual\n\t\t\tif (id.startsWith('$env/') || id === '$service-worker') {\n\t\t\t\t// ids with :$ don't work with reverse proxies like nginx\n\t\t\t\treturn `\\0virtual:${id.substring(1)}`;\n\t\t\t}\n\n\t\t\tif (id === '__sveltekit/remote') {\n\t\t\t\treturn `${runtime_directory}/client/remote-functions/index.js`;\n\t\t\t}\n\n\t\t\tif (id.startsWith('__sveltekit/')) {\n\t\t\t\treturn `\\0virtual:${id}`;\n\t\t\t}\n\t\t},\n\n\t\tload(id, options) {\n\t\t\tconst browser = !options?.ssr;\n\n\t\t\tconst global = is_build\n\t\t\t\t? `globalThis.__sveltekit_${version_hash}`\n\t\t\t\t: 'globalThis.__sveltekit_dev';\n\n\t\t\tswitch (id) {\n\t\t\t\tcase env_static_private:\n\t\t\t\t\treturn create_static_module('$env/static/private', env.private);\n\n\t\t\t\tcase env_static_public:\n\t\t\t\t\treturn create_static_module('$env/static/public', env.public);\n\n\t\t\t\tcase env_dynamic_private:\n\t\t\t\t\treturn create_dynamic_module(\n\t\t\t\t\t\t'private',\n\t\t\t\t\t\tvite_config_env.command === 'serve' ? env.private : undefined\n\t\t\t\t\t);\n\n\t\t\t\tcase env_dynamic_public:\n\t\t\t\t\t// populate `$env/dynamic/public` from `window`\n\t\t\t\t\tif (browser) {\n\t\t\t\t\t\treturn `export const env = ${global}.env;`;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn create_dynamic_module(\n\t\t\t\t\t\t'public',\n\t\t\t\t\t\tvite_config_env.command === 'serve' ? env.public : undefined\n\t\t\t\t\t);\n\n\t\t\t\tcase service_worker:\n\t\t\t\t\treturn create_service_worker_module(svelte_config);\n\n\t\t\t\tcase sveltekit_environment: {\n\t\t\t\t\tconst { version } = svelte_config.kit;\n\n\t\t\t\t\treturn dedent`\n\t\t\t\t\t\texport const version = ${s(version.name)};\n\t\t\t\t\t\texport let building = false;\n\t\t\t\t\t\texport let prerendering = false;\n\n\t\t\t\t\t\texport function set_building() {\n\t\t\t\t\t\t\tbuilding = true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\texport function set_prerendering() {\n\t\t\t\t\t\t\tprerendering = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t}\n\n\t\t\t\tcase sveltekit_server: {\n\t\t\t\t\treturn dedent`\n\t\t\t\t\t\texport let read_implementation = null;\n\n\t\t\t\t\t\texport let manifest = null;\n\n\t\t\t\t\t\texport function set_read_implementation(fn) {\n\t\t\t\t\t\t\tread_implementation = fn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\texport function set_manifest(_) {\n\t\t\t\t\t\t\tmanifest = _;\n\t\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\t/** @type {Map<string, Set<string>>} */\n\tconst import_map = new Map();\n\tconst server_only_pattern = /.*\\.server\\..+/;\n\n\t/**\n\t * Ensures that client-side code can't accidentally import server-side code,\n\t * whether in `*.server.js` files, `$app/server`, `$lib/server`, or `$env/[static|dynamic]/private`\n\t * @type {import('vite').Plugin}\n\t */\n\tconst plugin_guard = {\n\t\tname: 'vite-plugin-sveltekit-guard',\n\n\t\t// Run this plugin before built-in resolution, so that relative imports\n\t\t// are added to the module graph\n\t\tenforce: 'pre',\n\n\t\tasync resolveId(id, importer, options) {\n\t\t\tif (importer && !importer.endsWith('index.html')) {\n\t\t\t\tconst resolved = await this.resolve(id, importer, { ...options, skipSelf: true });\n\n\t\t\t\tif (resolved) {\n\t\t\t\t\tconst normalized = normalize_id(resolved.id, normalized_lib, normalized_cwd);\n\n\t\t\t\t\tlet importers = import_map.get(normalized);\n\n\t\t\t\t\tif (!importers) {\n\t\t\t\t\t\timporters = new Set();\n\t\t\t\t\t\timport_map.set(normalized, importers);\n\t\t\t\t\t}\n\n\t\t\t\t\timporters.add(normalize_id(importer, normalized_lib, normalized_cwd));\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tload(id, options) {\n\t\t\tif (options?.ssr === true || process.env.TEST === 'true') {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// skip .server.js files outside the cwd or in node_modules, as the filename might not mean 'server-only module' in this context\n\t\t\tconst is_internal = id.startsWith(normalized_cwd) && !id.startsWith(normalized_node_modules);\n\n\t\t\tconst normalized = normalize_id(id, normalized_lib, normalized_cwd);\n\n\t\t\tconst is_server_only =\n\t\t\t\tnormalized === '$env/static/private' ||\n\t\t\t\tnormalized === '$env/dynamic/private' ||\n\t\t\t\tnormalized === '$app/server' ||\n\t\t\t\tnormalized.startsWith('$lib/server/') ||\n\t\t\t\t(is_internal && server_only_pattern.test(path.basename(id)));\n\n\t\t\tif (is_server_only) {\n\t\t\t\t// in dev, this doesn't exist, so we need to create it\n\t\t\t\tmanifest_data ??= sync.all(svelte_config, vite_config_env.mode).manifest_data;\n\n\t\t\t\t/** @type {Set<string>} */\n\t\t\t\tconst entrypoints = new Set();\n\t\t\t\tfor (const node of manifest_data.nodes) {\n\t\t\t\t\tif (node.component) entrypoints.add(node.component);\n\t\t\t\t\tif (node.universal) entrypoints.add(node.universal);\n\t\t\t\t}\n\n\t\t\t\tif (manifest_data.hooks.client) entrypoints.add(manifest_data.hooks.client);\n\t\t\t\tif (manifest_data.hooks.universal) entrypoints.add(manifest_data.hooks.universal);\n\n\t\t\t\tconst normalized = normalize_id(id, normalized_lib, normalized_cwd);\n\t\t\t\tconst chain = [normalized];\n\n\t\t\t\tlet current = normalized;\n\t\t\t\tlet includes_remote_file = false;\n\n\t\t\t\twhile (true) {\n\t\t\t\t\tconst importers = import_map.get(current);\n\t\t\t\t\tif (!importers) break;\n\n\t\t\t\t\tconst candidates = Array.from(importers).filter((importer) => !chain.includes(importer));\n\t\t\t\t\tif (candidates.length === 0) break;\n\n\t\t\t\t\tchain.push((current = candidates[0]));\n\n\t\t\t\t\tincludes_remote_file ||= svelte_config.kit.moduleExtensions.some((ext) => {\n\t\t\t\t\t\treturn current.endsWith(`.remote${ext}`);\n\t\t\t\t\t});\n\n\t\t\t\t\tif (entrypoints.has(current)) {\n\t\t\t\t\t\tconst pyramid = chain\n\t\t\t\t\t\t\t.reverse()\n\t\t\t\t\t\t\t.map((id, i) => {\n\t\t\t\t\t\t\t\treturn `${' '.repeat(i + 1)}${id}`;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join(' imports\\n');\n\n\t\t\t\t\t\tif (includes_remote_file) {\n\t\t\t\t\t\t\terror_for_missing_config(\n\t\t\t\t\t\t\t\t'remote functions',\n\t\t\t\t\t\t\t\t'kit.experimental.remoteFunctions',\n\t\t\t\t\t\t\t\t'true'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet message = `Cannot import ${normalized} into code that runs in the browser, as this could leak sensitive information.`;\n\t\t\t\t\t\tmessage += `\\n\\n${pyramid}`;\n\t\t\t\t\t\tmessage += `\\n\\nIf you're only using the import as a type, change it to \\`import type\\`.`;\n\n\t\t\t\t\t\tthrow stackless(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthrow new Error('An impossible situation occurred');\n\t\t\t}\n\t\t}\n\t};\n\n\t/** @type {import('vite').ViteDevServer} */\n\tlet dev_server;\n\n\t/** @type {Array<{ hash: string, file: string }>} */\n\tconst remotes = [];\n\n\t/** @type {Map<string, string>} Maps remote hash -> original module id */\n\tconst remote_original_by_hash = new Map();\n\n\t/** @type {Set<string>} Track which remote hashes have already been emitted */\n\tconst emitted_remote_hashes = new Set();\n\n\t/** @type {import('vite').Plugin} */\n\tconst plugin_remote = {\n\t\tname: 'vite-plugin-sveltekit-remote',\n\n\t\tresolveId(id) {\n\t\t\tif (id.startsWith('\\0sveltekit-remote:')) return id;\n\t\t},\n\n\t\tload(id) {\n\t\t\t// On-the-fly generated entry point for remote file just forwards the original module\n\t\t\t// We're not using manualChunks because it can cause problems with circular dependencies\n\t\t\t// (e.g. https://github.com/sveltejs/kit/issues/14679) and module ordering in general\n\t\t\t// (e.g. https://github.com/sveltejs/kit/issues/14590).\n\t\t\tif (id.startsWith('\\0sveltekit-remote:')) {\n\t\t\t\tconst hash_id = id.slice('\\0sveltekit-remote:'.length);\n\t\t\t\tconst original = remote_original_by_hash.get(hash_id);\n\t\t\t\tif (!original) throw new Error(`Expected to find metadata for remote file ${id}`);\n\t\t\t\treturn `import * as m from ${s(original)};\\nexport default m;`;\n\t\t\t}\n\t\t},\n\n\t\tconfigureServer(_dev_server) {\n\t\t\tdev_server = _dev_server;\n\t\t},\n\n\t\tasync transform(code, id, opts) {\n\t\t\tconst normalized = normalize_id(id, normalized_lib, normalized_cwd);\n\t\t\tif (!svelte_config.kit.moduleExtensions.some((ext) => normalized.endsWith(`.remote${ext}`))) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst file = posixify(path.relative(cwd, id));\n\t\t\tconst remote = {\n\t\t\t\thash: hash(file),\n\t\t\t\tfile\n\t\t\t};\n\n\t\t\tremotes.push(remote);\n\n\t\t\tif (opts?.ssr) {\n\t\t\t\t// we need to add an `await Promise.resolve()` because if the user imports this function\n\t\t\t\t// on the client AND in a load function when loading the client module we will trigger\n\t\t\t\t// an ssrLoadModule during dev. During a link preload, the module can be mistakenly\n\t\t\t\t// loaded and transformed twice and the first time all its exports would be undefined\n\t\t\t\t// triggering a dev server error. By adding a microtask we ensure that the module is fully loaded\n\n\t\t\t\t// Extra newlines to prevent syntax errors around missing semicolons or comments\n\t\t\t\tcode +=\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\tdedent`\n\t\t\t\t\timport * as $$_self_$$ from './${path.basename(id)}';\n\t\t\t\t\timport { init_remote_functions as $$_init_$$ } from '@sveltejs/kit/internal';\n\n\t\t\t\t\t${dev_server ? 'await Promise.resolve()' : ''}\n\n\t\t\t\t\t$$_init_$$($$_self_$$, ${s(file)}, ${s(remote.hash)});\n\n\t\t\t\t\tfor (const [name, fn] of Object.entries($$_self_$$)) {\n\t\t\t\t\t\tfn.__.id = ${s(remote.hash)} + '/' + name;\n\t\t\t\t\t\tfn.__.name = name;\n\t\t\t\t\t}\n\t\t\t\t`;\n\n\t\t\t\t// Emit a dedicated entry chunk for this remote in SSR builds (prod only)\n\t\t\t\tif (!dev_server) {\n\t\t\t\t\tremote_original_by_hash.set(remote.hash, id);\n\t\t\t\t\tif (!emitted_remote_hashes.has(remote.hash)) {\n\t\t\t\t\t\tthis.emitFile({\n\t\t\t\t\t\t\ttype: 'chunk',\n\t\t\t\t\t\t\tid: `\\0sveltekit-remote:${remote.hash}`,\n\t\t\t\t\t\t\tname: `remote-${remote.hash}`\n\t\t\t\t\t\t});\n\t\t\t\t\t\temitted_remote_hashes.add(remote.hash);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn code;\n\t\t\t}\n\n\t\t\t// For the client, read the exports and create a new module that only contains fetch functions with the correct metadata\n\n\t\t\t/** @type {Map<string, import('types').RemoteInternals['type']>} */\n\t\t\tconst map = new Map();\n\n\t\t\t// in dev, load the server module here (which will result in this hook\n\t\t\t// being called again with `opts.ssr === true` if the module isn't\n\t\t\t// already loaded) so we can determine what it exports\n\t\t\tif (dev_server) {\n\t\t\t\tconst module = await dev_server.ssrLoadModule(id);\n\n\t\t\t\tfor (const [name, value] of Object.entries(module)) {\n\t\t\t\t\tconst type = value?.__?.type;\n\t\t\t\t\tif (type) {\n\t\t\t\t\t\tmap.set(name, type);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// in prod, we already built and analysed the server code before\n\t\t\t// building the client code, so `remote_exports` is populated\n\t\t\telse if (build_metadata?.remotes) {\n\t\t\t\tconst exports = build_metadata?.remotes.get(remote.hash);\n\t\t\t\tif (!exports) throw new Error('Expected to find metadata for remote file ' + id);\n\n\t\t\t\tfor (const [name, value] of exports) {\n\t\t\t\t\tmap.set(name, value.type);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet namespace = '__remote';\n\t\t\tlet uid = 1;\n\t\t\twhile (map.has(namespace)) namespace = `__remote${uid++}`;\n\n\t\t\tconst exports = Array.from(map).map(([name, type]) => {\n\t\t\t\treturn `export const ${name} = ${namespace}.${type}('${remote.hash}/${name}');`;\n\t\t\t});\n\n\t\t\tlet result = `import * as ${namespace} from '__sveltekit/remote';\\n\\n${exports.join('\\n')}\\n`;\n\n\t\t\tif (dev_server) {\n\t\t\t\tresult += `\\nimport.meta.hot?.accept();\\n`;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcode: result\n\t\t\t};\n\t\t}\n\t};\n\n\t/** @type {import('vite').Plugin} */\n\tconst plugin_compile = {\n\t\tname: 'vite-plugin-sveltekit-compile',\n\n\t\t/**\n\t\t * Build the SvelteKit-provided Vite config to be merged with the user's vite.config.js file.\n\t\t * @see https://vitejs.dev/guide/api-plugin.html#config\n\t\t */\n\t\tconfig(config) {\n\t\t\t/** @type {import('vite').UserConfig} */\n\t\t\tlet new_config;\n\n\t\t\tconst kit_paths_base = kit.paths.base || '/';\n\n\t\t\tif (is_build) {\n\t\t\t\tconst ssr = /** @type {boolean} */ (config.build?.ssr);\n\t\t\t\tconst prefix = `${kit.appDir}/immutable`;\n\n\t\t\t\t/** @type {Record<string, string>} */\n\t\t\t\tconst input = {};\n\n\t\t\t\tif (ssr) {\n\t\t\t\t\tinput.index = `${runtime_directory}/server/index.js`;\n\t\t\t\t\tinput.internal = `${kit.outDir}/generated/server/internal.js`;\n\t\t\t\t\tinput['remote-entry'] = `${runtime_directory}/app/server/remote/index.js`;\n\n\t\t\t\t\t// add entry points for every endpoint...\n\t\t\t\t\tmanifest_data.routes.forEach((route) => {\n\t\t\t\t\t\tif (route.endpoint) {\n\t\t\t\t\t\t\tconst resolved = path.resolve(route.endpoint.file);\n\t\t\t\t\t\t\tconst relative = decodeURIComponent(path.relative(kit.files.routes, resolved));\n\t\t\t\t\t\t\tconst name = posixify(path.join('entries/endpoints', relative.replace(/\\.js$/, '')));\n\t\t\t\t\t\t\tinput[name] = resolved;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// ...and every component used by pages...\n\t\t\t\t\tmanifest_data.nodes.forEach((node) => {\n\t\t\t\t\t\tfor (const file of [node.component, node.universal, node.server]) {\n\t\t\t\t\t\t\tif (file) {\n\t\t\t\t\t\t\t\tconst resolved = path.resolve(file);\n\t\t\t\t\t\t\t\tconst relative = decodeURIComponent(path.relative(kit.files.routes, resolved));\n\n\t\t\t\t\t\t\t\tconst name = relative.startsWith('..')\n\t\t\t\t\t\t\t\t\t? posixify(path.join('entries/fallbacks', path.basename(file)))\n\t\t\t\t\t\t\t\t\t: posixify(path.join('entries/pages', relative.replace(/\\.js$/, '')));\n\t\t\t\t\t\t\t\tinput[name] = resolved;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// ...and every matcher\n\t\t\t\t\tObject.entries(manifest_data.matchers).forEach(([key, file]) => {\n\t\t\t\t\t\tconst name = posixify(path.join('entries/matchers', key));\n\t\t\t\t\t\tinput[name] = path.resolve(file);\n\t\t\t\t\t});\n\n\t\t\t\t\t// ...and the hooks files\n\t\t\t\t\tif (manifest_data.hooks.server) {\n\t\t\t\t\t\tinput['entries/hooks.server'] = path.resolve(manifest_data.hooks.server);\n\t\t\t\t\t}\n\t\t\t\t\tif (manifest_data.hooks.universal) {\n\t\t\t\t\t\tinput['entries/hooks.universal'] = path.resolve(manifest_data.hooks.universal);\n\t\t\t\t\t}\n\n\t\t\t\t\t// ...and the server instrumentation file\n\t\t\t\t\tconst server_instrumentation = resolve_entry(\n\t\t\t\t\t\tpath.join(kit.files.src, 'instrumentation.server')\n\t\t\t\t\t);\n\t\t\t\t\tif (server_instrumentation) {\n\t\t\t\t\t\tconst { adapter } = kit;\n\t\t\t\t\t\tif (adapter && !adapter.supports?.instrumentation?.()) {\n\t\t\t\t\t\t\tthrow new Error(`${server_instrumentation} is unsupported in ${adapter.name}.`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!kit.experimental.instrumentation.server) {\n\t\t\t\t\t\t\terror_for_missing_config(\n\t\t\t\t\t\t\t\t'`instrumentation.server.js`',\n\t\t\t\t\t\t\t\t'kit.experimental.instrumentation.server',\n\t\t\t\t\t\t\t\t'true'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinput['instrumentation.server'] = server_instrumentation;\n\t\t\t\t\t}\n\t\t\t\t} else if (svelte_config.kit.output.bundleStrategy !== 'split') {\n\t\t\t\t\tinput['bundle'] = `${runtime_directory}/client/bundle.js`;\n\t\t\t\t} else {\n\t\t\t\t\tinput['entry/start'] = `${runtime_directory}/client/entry.js`;\n\t\t\t\t\tinput['entry/app'] = `${kit.outDir}/generated/client-optimized/app.js`;\n\t\t\t\t\tmanifest_data.nodes.forEach((node, i) => {\n\t\t\t\t\t\tif (node.component || node.universal) {\n\t\t\t\t\t\t\tinput[`nodes/${i}`] = `${kit.outDir}/generated/client-optimized/nodes/${i}.js`;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// see the kit.output.preloadStrategy option for details on why we have multiple options here\n\t\t\t\tconst ext = kit.output.preloadStrategy === 'preload-mjs' ? 'mjs' : 'js';\n\n\t\t\t\t// We could always use a relative asset base path here, but it's better for performance not to.\n\t\t\t\t// E.g. Vite generates `new URL('/asset.png', import.meta).href` for a relative path vs just '/asset.png'.\n\t\t\t\t// That's larger and takes longer to run and also causes an HTML diff between SSR and client\n\t\t\t\t// causing us to do a more expensive hydration check.\n\t\t\t\tconst client_base =\n\t\t\t\t\tkit.paths.relative !== false || kit.paths.assets ? './' : kit_paths_base;\n\n\t\t\t\tconst inline = !ssr && svelte_config.kit.output.bundleStrategy === 'inline';\n\t\t\t\tconst split = ssr || svelte_config.kit.output.bundleStrategy === 'split';\n\n\t\t\t\tnew_config = {\n\t\t\t\t\tbase: ssr ? assets_base(kit) : client_base,\n\t\t\t\t\tbuild: {\n\t\t\t\t\t\tcopyPublicDir: !ssr,\n\t\t\t\t\t\tcssCodeSplit: svelte_config.kit.output.bundleStrategy !== 'inline',\n\t\t\t\t\t\tcssMinify: initial_config.build?.minify == null ? true : !!initial_config.build.minify,\n\t\t\t\t\t\tmanifest: true,\n\t\t\t\t\t\toutDir: `${out}/${ssr ? 'server' : 'client'}`,\n\t\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\t\tinput: inline ? input['bundle'] : input,\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\tformat: inline ? 'iife' : 'esm',\n\t\t\t\t\t\t\t\tname: `__sveltekit_${version_hash}.app`,\n\t\t\t\t\t\t\t\tentryFileNames: ssr ? '[name].js' : `${prefix}/[name].[hash].${ext}`,\n\t\t\t\t\t\t\t\tchunkFileNames: ssr ? 'chunks/[name].js' : `${prefix}/chunks/[hash].${ext}`,\n\t\t\t\t\t\t\t\tassetFileNames: `${prefix}/assets/[name].[hash][extname]`,\n\t\t\t\t\t\t\t\thoistTransitiveImports: false,\n\t\t\t\t\t\t\t\tsourcemapIgnoreList,\n\t\t\t\t\t\t\t\tinlineDynamicImports: is_rolldown ? undefined : !split\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpreserveEntrySignatures: 'strict',\n\t\t\t\t\t\t\tonwarn(warning, handler) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t(is_rolldown\n\t\t\t\t\t\t\t\t\t\t? warning.code === 'IMPORT_IS_UNDEFINED'\n\t\t\t\t\t\t\t\t\t\t: warning.code === 'MISSING_EXPORT') &&\n\t\t\t\t\t\t\t\t\twarning.id === `${kit.outDir}/generated/client-optimized/app.js`\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t// ignore e.g. undefined `handleError` hook when\n\t\t\t\t\t\t\t\t\t// referencing `client_hooks.handleError`\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\thandler(warning);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tssrEmitAssets: true,\n\t\t\t\t\t\ttarget: ssr ? 'node18.13' : undefined\n\t\t\t\t\t},\n\t\t\t\t\tpublicDir: kit.files.assets,\n\t\t\t\t\tworker: {\n\t\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\tentryFileNames: `${prefix}/workers/[name]-[hash].js`,\n\t\t\t\t\t\t\t\tchunkFileNames: `${prefix}/workers/chunks/[hash].js`,\n\t\t\t\t\t\t\t\tassetFileNames: `${prefix}/workers/assets/[name]-[hash][extname]`,\n\t\t\t\t\t\t\t\thoistTransitiveImports: false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\t// we must reference Vite 8 options conditionally. Otherwise, older Vite\n\t\t\t\t// versions throw an error about unknown config options\n\t\t\t\tif (is_rolldown && new_config?.build?.rollupOptions?.output) {\n\t\t\t\t\t// @ts-ignore only available in Vite 8\n\t\t\t\t\tnew_config.build.rollupOptions.output.codeSplitting = split;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnew_config = {\n\t\t\t\t\tappType: 'custom',\n\t\t\t\t\tbase: kit_paths_base,\n\t\t\t\t\tbuild: {\n\t\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\t\t// Vite dependency crawler needs an explicit JS entry point\n\t\t\t\t\t\t\t// even though server otherwise works without it\n\t\t\t\t\t\t\tinput: `${runtime_directory}/client/entry.js`\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tpublicDir: kit.files.assets\n\t\t\t\t};\n\t\t\t}\n\n\t\t\twarn_overridden_config(config, new_config);\n\n\t\t\treturn new_config;\n\t\t},\n\n\t\t/**\n\t\t * Adds the SvelteKit middleware to do SSR in dev mode.\n\t\t * @see https://vitejs.dev/guide/api-plugin.html#configureserver\n\t\t */\n\t\tasync configureServer(vite) {\n\t\t\treturn await dev(vite, vite_config, svelte_config, () => remotes);\n\t\t},\n\n\t\t/**\n\t\t * Adds the SvelteKit middleware to do SSR in preview mode.\n\t\t * @see https://vitejs.dev/guide/api-plugin.html#configurepreviewserver\n\t\t */\n\t\tconfigurePreviewServer(vite) {\n\t\t\treturn preview(vite, vite_config, svelte_config);\n\t\t},\n\n\t\t/**\n\t\t * Clears the output directories.\n\t\t */\n\t\tbuildStart() {\n\t\t\tif (secondary_build_started) return;\n\n\t\t\tif (is_build) {\n\t\t\t\tif (!vite_config.build.watch) {\n\t\t\t\t\trimraf(out);\n\t\t\t\t}\n\t\t\t\tmkdirp(out);\n\t\t\t}\n\t\t},\n\n\t\trenderChunk(code, chunk) {\n\t\t\tif (code.includes('__SVELTEKIT_TRACK__')) {\n\t\t\t\treturn {\n\t\t\t\t\t// Rolldown changes our single quotes to double quotes so we need it in the regex too\n\t\t\t\t\tcode: code.replace(/__SVELTEKIT_TRACK__\\(['\"](.+?)['\"]\\)/g, (_, label) => {\n\t\t\t\t\t\t(tracked_features[chunk.name + '.js'] ??= []).push(label);\n\t\t\t\t\t\t// put extra whitespace at the end of the comment to preserve the source size and avoid interfering with source maps\n\t\t\t\t\t\treturn `/* track ${label}            */`;\n\t\t\t\t\t}),\n\t\t\t\t\tmap: null // TODO we may need to generate a sourcemap in future\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t\tgenerateBundle() {\n\t\t\tif (vite_config.build.ssr) return;\n\n\t\t\tthis.emitFile({\n\t\t\t\ttype: 'asset',\n\t\t\t\tfileName: `${kit.appDir}/version.json`,\n\t\t\t\tsource: s({ version: kit.version.name })\n\t\t\t});\n\t\t},\n\n\t\t/**\n\t\t * Vite builds a single bundle. We need three bundles: client, server, and service worker.\n\t\t * The user's package.json scripts will invoke the Vite CLI to execute the server build. We\n\t\t * then use this hook to kick off builds for the client and service worker.\n\t\t */\n\t\twriteBundle: {\n\t\t\tsequential: true,\n\t\t\tasync handler(_options) {\n\t\t\t\tif (secondary_build_started) return; // only run this once\n\n\t\t\t\tconst verbose = vite_config.logLevel === 'info';\n\t\t\t\tconst log = logger({ verbose });\n\n\t\t\t\t/** @type {import('vite').Manifest} */\n\t\t\t\tconst server_manifest = JSON.parse(read(`${out}/server/.vite/manifest.json`));\n\n\t\t\t\t/** @type {import('types').BuildData} */\n\t\t\t\tconst build_data = {\n\t\t\t\t\tapp_dir: kit.appDir,\n\t\t\t\t\tapp_path: `${kit.paths.base.slice(1)}${kit.paths.base ? '/' : ''}${kit.appDir}`,\n\t\t\t\t\tmanifest_data,\n\t\t\t\t\tout_dir: out,\n\t\t\t\t\tservice_worker: service_worker_entry_file ? 'service-worker.js' : null, // TODO make file configurable?\n\t\t\t\t\tclient: null,\n\t\t\t\t\tserver_manifest\n\t\t\t\t};\n\n\t\t\t\tconst manifest_path = `${out}/server/manifest-full.js`;\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tmanifest_path,\n\t\t\t\t\t`export const manifest = ${generate_manifest({\n\t\t\t\t\t\tbuild_data,\n\t\t\t\t\t\tprerendered: [],\n\t\t\t\t\t\trelative_path: '.',\n\t\t\t\t\t\troutes: manifest_data.routes,\n\t\t\t\t\t\tremotes\n\t\t\t\t\t})};\\n`\n\t\t\t\t);\n\n\t\t\t\tlog.info('Analysing routes');\n\n\t\t\t\tconst { metadata } = await analyse({\n\t\t\t\t\thash: kit.router.type === 'hash',\n\t\t\t\t\tmanifest_path,\n\t\t\t\t\tmanifest_data,\n\t\t\t\t\tserver_manifest,\n\t\t\t\t\ttracked_features,\n\t\t\t\t\tenv: { ...env.private, ...env.public },\n\t\t\t\t\tout,\n\t\t\t\t\toutput_config: svelte_config.output,\n\t\t\t\t\tremotes\n\t\t\t\t});\n\n\t\t\t\tbuild_metadata = metadata;\n\n\t\t\t\tlog.info('Building app');\n\n\t\t\t\t// create client build\n\t\t\t\twrite_client_manifest(\n\t\t\t\t\tkit,\n\t\t\t\t\tmanifest_data,\n\t\t\t\t\t`${kit.outDir}/generated/client-optimized`,\n\t\t\t\t\tmetadata.nodes\n\t\t\t\t);\n\n\t\t\t\tsecondary_build_started = true;\n\n\t\t\t\tlet client_chunks;\n\n\t\t\t\ttry {\n\t\t\t\t\tconst bundle = /** @type {import('vite').Rollup.RollupOutput} */ (\n\t\t\t\t\t\tawait vite.build({\n\t\t\t\t\t\t\tconfigFile: vite_config.configFile,\n\t\t\t\t\t\t\t// CLI args\n\t\t\t\t\t\t\tmode: vite_config_env.mode,\n\t\t\t\t\t\t\tlogLevel: vite_config.logLevel,\n\t\t\t\t\t\t\tclearScreen: vite_config.clearScreen,\n\t\t\t\t\t\t\tbuild: {\n\t\t\t\t\t\t\t\tminify: initial_config.build?.minify,\n\t\t\t\t\t\t\t\tassetsInlineLimit: vite_config.build.assetsInlineLimit,\n\t\t\t\t\t\t\t\tsourcemap: vite_config.build.sourcemap\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\toptimizeDeps: {\n\t\t\t\t\t\t\t\tforce: vite_config.optimizeDeps.force\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\n\t\t\t\t\tclient_chunks = bundle.output;\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconst error =\n\t\t\t\t\t\te instanceof Error ? e : new Error(/** @type {any} */ (e).message ?? e ?? '<unknown>');\n\n\t\t\t\t\t// without this, errors that occur during the secondary build\n\t\t\t\t\t// will be logged twice\n\t\t\t\t\tthrow stackless(error.stack ?? error.message);\n\t\t\t\t}\n\n\t\t\t\t// We use `build.ssrEmitAssets` so that asset URLs created from\n\t\t\t\t// imports in server-only modules correspond to files in the build,\n\t\t\t\t// but we don't want to copy over CSS imports as these are already\n\t\t\t\t// accounted for in the client bundle. In most cases it would be\n\t\t\t\t// a no-op, but for SSR builds `url(...)` paths are handled\n\t\t\t\t// differently (relative for client, absolute for server)\n\t\t\t\t// resulting in different hashes, and thus duplication\n\t\t\t\tconst ssr_stylesheets = new Set(\n\t\t\t\t\tObject.values(server_manifest)\n\t\t\t\t\t\t.map((chunk) => chunk.css ?? [])\n\t\t\t\t\t\t.flat()\n\t\t\t\t);\n\n\t\t\t\tconst assets_path = `${kit.appDir}/immutable/assets`;\n\t\t\t\tconst server_assets = `${out}/server/${assets_path}`;\n\t\t\t\tconst client_assets = `${out}/client/${assets_path}`;\n\n\t\t\t\tif (fs.existsSync(server_assets)) {\n\t\t\t\t\tfor (const file of fs.readdirSync(server_assets)) {\n\t\t\t\t\t\tconst src = `${server_assets}/${file}`;\n\t\t\t\t\t\tconst dest = `${client_assets}/${file}`;\n\n\t\t\t\t\t\tif (fs.existsSync(dest) || ssr_stylesheets.has(`${assets_path}/${file}`)) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (file.endsWith('.css')) {\n\t\t\t\t\t\t\t// make absolute paths in CSS relative, for portability\n\t\t\t\t\t\t\tconst content = fs\n\t\t\t\t\t\t\t\t.readFileSync(src, 'utf-8')\n\t\t\t\t\t\t\t\t.replaceAll(`${kit.paths.base}/${assets_path}`, '.');\n\n\t\t\t\t\t\t\tfs.writeFileSync(src, content);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcopy(src, dest);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/** @type {import('vite').Manifest} */\n\t\t\t\tconst client_manifest = JSON.parse(read(`${out}/client/.vite/manifest.json`));\n\n\t\t\t\t/**\n\t\t\t\t * @param {string} entry\n\t\t\t\t * @param {boolean} [add_dynamic_css]\n\t\t\t\t */\n\t\t\t\tconst deps_of = (entry, add_dynamic_css = false) =>\n\t\t\t\t\tfind_deps(client_manifest, posixify(path.relative('.', entry)), add_dynamic_css);\n\n\t\t\t\tif (svelte_config.kit.output.bundleStrategy === 'split') {\n\t\t\t\t\tconst start = deps_of(`${runtime_directory}/client/entry.js`);\n\t\t\t\t\tconst app = deps_of(`${kit.outDir}/generated/client-optimized/app.js`);\n\n\t\t\t\t\tbuild_data.client = {\n\t\t\t\t\t\tstart: start.file,\n\t\t\t\t\t\tapp: app.file,\n\t\t\t\t\t\timports: [...start.imports, ...app.imports],\n\t\t\t\t\t\tstylesheets: [...start.stylesheets, ...app.stylesheets],\n\t\t\t\t\t\tfonts: [...start.fonts, ...app.fonts],\n\t\t\t\t\t\tuses_env_dynamic_public: client_chunks.some(\n\t\t\t\t\t\t\t(chunk) => chunk.type === 'chunk' && chunk.modules[env_dynamic_public]\n\t\t\t\t\t\t)\n\t\t\t\t\t};\n\n\t\t\t\t\t// In case of server-side route resolution, we create a purpose-built route manifest that is\n\t\t\t\t\t// similar to that on the client, with as much information computed upfront so that we\n\t\t\t\t\t// don't need to include any code of the actual routes in the server bundle.\n\t\t\t\t\tif (svelte_config.kit.router.resolution === 'server') {\n\t\t\t\t\t\tconst nodes = manifest_data.nodes.map((node, i) => {\n\t\t\t\t\t\t\tif (node.component || node.universal) {\n\t\t\t\t\t\t\t\tconst entry = `${kit.outDir}/generated/client-optimized/nodes/${i}.js`;\n\t\t\t\t\t\t\t\tconst deps = deps_of(entry, true);\n\t\t\t\t\t\t\t\tconst file = resolve_symlinks(\n\t\t\t\t\t\t\t\t\tclient_manifest,\n\t\t\t\t\t\t\t\t\t`${kit.outDir}/generated/client-optimized/nodes/${i}.js`\n\t\t\t\t\t\t\t\t).chunk.file;\n\n\t\t\t\t\t\t\t\treturn { file, css: deps.stylesheets };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbuild_data.client.nodes = nodes.map((node) => node?.file);\n\t\t\t\t\t\tbuild_data.client.css = nodes.map((node) => node?.css);\n\n\t\t\t\t\t\tbuild_data.client.routes = compact(\n\t\t\t\t\t\t\tmanifest_data.routes.map((route) => {\n\t\t\t\t\t\t\t\tif (!route.page) return;\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: route.id,\n\t\t\t\t\t\t\t\t\tpattern: route.pattern,\n\t\t\t\t\t\t\t\t\tparams: route.params,\n\t\t\t\t\t\t\t\t\tlayouts: route.page.layouts.map((l) =>\n\t\t\t\t\t\t\t\t\t\tl !== undefined ? [metadata.nodes[l].has_server_load, l] : undefined\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\terrors: route.page.errors,\n\t\t\t\t\t\t\t\t\tleaf: [metadata.nodes[route.page.leaf].has_server_load, route.page.leaf]\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst start = deps_of(`${runtime_directory}/client/bundle.js`);\n\n\t\t\t\t\tbuild_data.client = {\n\t\t\t\t\t\tstart: start.file,\n\t\t\t\t\t\timports: start.imports,\n\t\t\t\t\t\tstylesheets: start.stylesheets,\n\t\t\t\t\t\tfonts: start.fonts,\n\t\t\t\t\t\tuses_env_dynamic_public: client_chunks.some(\n\t\t\t\t\t\t\t(chunk) => chunk.type === 'chunk' && chunk.modules[env_dynamic_public]\n\t\t\t\t\t\t)\n\t\t\t\t\t};\n\n\t\t\t\t\tif (svelte_config.kit.output.bundleStrategy === 'inline') {\n\t\t\t\t\t\tconst style = /** @type {import('vite').Rollup.OutputAsset} */ (\n\t\t\t\t\t\t\tclient_chunks.find(\n\t\t\t\t\t\t\t\t(chunk) =>\n\t\t\t\t\t\t\t\t\tchunk.type === 'asset' &&\n\t\t\t\t\t\t\t\t\tchunk.names.length === 1 &&\n\t\t\t\t\t\t\t\t\tchunk.names[0] === 'style.css'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tbuild_data.client.inline = {\n\t\t\t\t\t\t\tscript: read(`${out}/client/${start.file}`),\n\t\t\t\t\t\t\tstyle: /** @type {string | undefined} */ (style?.source)\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// regenerate manifest now that we have client entry...\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tmanifest_path,\n\t\t\t\t\t`export const manifest = ${generate_manifest({\n\t\t\t\t\t\tbuild_data,\n\t\t\t\t\t\tprerendered: [],\n\t\t\t\t\t\trelative_path: '.',\n\t\t\t\t\t\troutes: manifest_data.routes,\n\t\t\t\t\t\tremotes\n\t\t\t\t\t})};\\n`\n\t\t\t\t);\n\n\t\t\t\t// regenerate nodes with the client manifest...\n\t\t\t\tbuild_server_nodes(\n\t\t\t\t\tout,\n\t\t\t\t\tkit,\n\t\t\t\t\tmanifest_data,\n\t\t\t\t\tserver_manifest,\n\t\t\t\t\tclient_manifest,\n\t\t\t\t\tassets_path,\n\t\t\t\t\tclient_chunks,\n\t\t\t\t\tsvelte_config.kit.output\n\t\t\t\t);\n\n\t\t\t\t// ...and prerender\n\t\t\t\tconst { prerendered, prerender_map } = await prerender({\n\t\t\t\t\thash: kit.router.type === 'hash',\n\t\t\t\t\tout,\n\t\t\t\t\tmanifest_path,\n\t\t\t\t\tmetadata,\n\t\t\t\t\tverbose,\n\t\t\t\t\tenv: { ...env.private, ...env.public }\n\t\t\t\t});\n\n\t\t\t\t// generate a new manifest that doesn't include prerendered pages\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\t`${out}/server/manifest.js`,\n\t\t\t\t\t`export const manifest = ${generate_manifest({\n\t\t\t\t\t\tbuild_data,\n\t\t\t\t\t\tprerendered: prerendered.paths,\n\t\t\t\t\t\trelative_path: '.',\n\t\t\t\t\t\troutes: manifest_data.routes.filter((route) => prerender_map.get(route.id) !== true),\n\t\t\t\t\t\tremotes\n\t\t\t\t\t})};\\n`\n\t\t\t\t);\n\n\t\t\t\tif (service_worker_entry_file) {\n\t\t\t\t\tif (kit.paths.assets) {\n\t\t\t\t\t\tthrow new Error('Cannot use service worker alongside config.kit.paths.assets');\n\t\t\t\t\t}\n\n\t\t\t\t\tlog.info('Building service worker');\n\n\t\t\t\t\tawait build_service_worker(\n\t\t\t\t\t\tout,\n\t\t\t\t\t\tkit,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...vite_config,\n\t\t\t\t\t\t\tbuild: {\n\t\t\t\t\t\t\t\t...vite_config.build,\n\t\t\t\t\t\t\t\tminify: initial_config.build?.minify ?? true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmanifest_data,\n\t\t\t\t\t\tservice_worker_entry_file,\n\t\t\t\t\t\tprerendered,\n\t\t\t\t\t\tclient_manifest\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// we need to defer this to closeBundle, so that adapters copy files\n\t\t\t\t// created by other Vite plugins\n\t\t\t\tfinalise = async () => {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`\\nRun ${colors\n\t\t\t\t\t\t\t.bold()\n\t\t\t\t\t\t\t.cyan('npm run preview')} to preview your production build locally.`\n\t\t\t\t\t);\n\n\t\t\t\t\tif (kit.adapter) {\n\t\t\t\t\t\tconst { adapt } = await import('../../core/adapt/index.js');\n\t\t\t\t\t\tawait adapt(\n\t\t\t\t\t\t\tsvelte_config,\n\t\t\t\t\t\t\tbuild_data,\n\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t\tprerendered,\n\t\t\t\t\t\t\tprerender_map,\n\t\t\t\t\t\t\tlog,\n\t\t\t\t\t\t\tremotes,\n\t\t\t\t\t\t\tvite_config\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log(colors.bold().yellow('\\nNo adapter specified'));\n\n\t\t\t\t\t\tconst link = colors.bold().cyan('https://svelte.dev/docs/kit/adapters');\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`See ${link} to learn how to configure your app to run on the platform of your choosing`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tsecondary_build_started = false;\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Runs the adapter.\n\t\t */\n\t\tcloseBundle: {\n\t\t\tsequential: true,\n\t\t\tasync handler() {\n\t\t\t\tif (!vite_config.build.ssr) return;\n\t\t\t\tawait finalise?.();\n\t\t\t}\n\t\t}\n\t};\n\n\treturn [\n\t\tplugin_setup,\n\t\tkit.experimental.remoteFunctions && plugin_remote,\n\t\tplugin_virtual_modules,\n\t\tplugin_guard,\n\t\tplugin_compile\n\t].filter((p) => !!p);\n}\n\n/**\n * @param {Record<string, any>} config\n * @param {Record<string, any>} resolved_config\n */\nfunction warn_overridden_config(config, resolved_config) {\n\tconst overridden = find_overridden_config(config, resolved_config, enforced_config, '', []);\n\n\tif (overridden.length > 0) {\n\t\tconsole.error(\n\t\t\tcolors.bold().red('The following Vite config options will be overridden by SvelteKit:') +\n\t\t\t\toverridden.map((key) => `\\n  - ${key}`).join('')\n\t\t);\n\t}\n}\n\n/**\n * @param {Record<string, any>} config\n * @param {Record<string, any>} resolved_config\n * @param {import('./types.js').EnforcedConfig} enforced_config\n * @param {string} path\n * @param {string[]} out used locally to compute the return value\n */\nfunction find_overridden_config(config, resolved_config, enforced_config, path, out) {\n\tif (config == null || resolved_config == null) {\n\t\treturn out;\n\t}\n\n\tfor (const key in enforced_config) {\n\t\tif (typeof config === 'object' && key in config && key in resolved_config) {\n\t\t\tconst enforced = enforced_config[key];\n\n\t\t\tif (enforced === true) {\n\t\t\t\tif (config[key] !== resolved_config[key]) {\n\t\t\t\t\tout.push(path + key);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfind_overridden_config(config[key], resolved_config[key], enforced, path + key + '.', out);\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n * @param {import('types').ValidatedConfig} config\n */\nconst create_service_worker_module = (config) => dedent`\n\tif (typeof self === 'undefined' || self instanceof ServiceWorkerGlobalScope === false) {\n\t\tthrow new Error('This module can only be imported inside a service worker');\n\t}\n\n\texport const build = [];\n\texport const files = [\n\t\t${create_assets(config)\n\t\t\t.filter((asset) => config.kit.serviceWorker.files(asset.file))\n\t\t\t.map((asset) => `${s(`${config.kit.paths.base}/${asset.file}`)}`)\n\t\t\t.join(',\\n')}\n\t];\n\texport const prerendered = [];\n\texport const version = ${s(config.kit.version.name)};\n`;\n"
  },
  {
    "path": "packages/kit/src/exports/vite/module_ids.js",
    "content": "import { fileURLToPath } from 'node:url';\nimport { posixify } from '../../utils/filesystem.js';\n\nexport const env_static_private = '\\0virtual:env/static/private';\nexport const env_static_public = '\\0virtual:env/static/public';\nexport const env_dynamic_private = '\\0virtual:env/dynamic/private';\nexport const env_dynamic_public = '\\0virtual:env/dynamic/public';\n\nexport const service_worker = '\\0virtual:service-worker';\n\nexport const sveltekit_environment = '\\0virtual:__sveltekit/environment';\nexport const sveltekit_server = '\\0virtual:__sveltekit/server';\n\nexport const app_server = posixify(\n\tfileURLToPath(new URL('../../runtime/app/server/index.js', import.meta.url))\n);\n"
  },
  {
    "path": "packages/kit/src/exports/vite/preview/index.js",
    "content": "import fs from 'node:fs';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { lookup } from 'mrmime';\nimport sirv from 'sirv';\nimport { loadEnv, normalizePath } from 'vite';\nimport { createReadableStream, getRequest, setResponse } from '../../../exports/node/index.js';\nimport { installPolyfills } from '../../../exports/node/polyfills.js';\nimport { SVELTE_KIT_ASSETS } from '../../../constants.js';\nimport { not_found } from '../utils.js';\n\n/** @typedef {import('http').IncomingMessage} Req */\n/** @typedef {import('http').ServerResponse} Res */\n/** @typedef {(req: Req, res: Res, next: () => void) => void} Handler */\n\n/**\n * @param {import('vite').PreviewServer} vite\n * @param {import('vite').ResolvedConfig} vite_config\n * @param {import('types').ValidatedConfig} svelte_config\n */\nexport async function preview(vite, vite_config, svelte_config) {\n\tinstallPolyfills();\n\n\tconst { paths } = svelte_config.kit;\n\tconst base = paths.base;\n\tconst assets = paths.assets ? SVELTE_KIT_ASSETS : paths.base;\n\n\tconst protocol = vite_config.preview.https ? 'https' : 'http';\n\n\tconst etag = `\"${Date.now()}\"`;\n\n\tconst dir = join(svelte_config.kit.outDir, 'output/server');\n\n\tif (!fs.existsSync(dir)) {\n\t\tthrow new Error(`Server files not found at ${dir}, did you run \\`build\\` first?`);\n\t}\n\n\tconst instrumentation = join(dir, 'instrumentation.server.js');\n\tif (fs.existsSync(instrumentation)) {\n\t\tawait import(pathToFileURL(instrumentation).href);\n\t}\n\n\t/** @type {import('types').ServerInternalModule} */\n\tconst { set_assets } = await import(pathToFileURL(join(dir, 'internal.js')).href);\n\n\t/** @type {import('types').ServerModule} */\n\tconst { Server } = await import(pathToFileURL(join(dir, 'index.js')).href);\n\n\tconst { manifest } = await import(pathToFileURL(join(dir, 'manifest.js')).href);\n\n\tset_assets(assets);\n\n\tconst server = new Server(manifest);\n\tawait server.init({\n\t\tenv: loadEnv(vite_config.mode, svelte_config.kit.env.dir, ''),\n\t\tread: (file) => createReadableStream(`${dir}/${file}`)\n\t});\n\n\tconst emulator = await svelte_config.kit.adapter?.emulate?.();\n\n\treturn () => {\n\t\t// Remove the base middleware. It screws with the URL.\n\t\t// It also only lets through requests beginning with the base path, so that requests beginning\n\t\t// with the assets URL never reach us. We could serve assets separately before the base\n\t\t// middleware, but we'd need that to occur after the compression and cors middlewares, so would\n\t\t// need to insert it manually into the stack, which would be at least as bad as doing this.\n\t\tfor (let i = vite.middlewares.stack.length - 1; i > 0; i--) {\n\t\t\t// @ts-expect-error using internals\n\t\t\tif (vite.middlewares.stack[i].handle.name === 'viteBaseMiddleware') {\n\t\t\t\tvite.middlewares.stack.splice(i, 1);\n\t\t\t}\n\t\t}\n\n\t\t// generated client assets and the contents of `static`\n\t\tvite.middlewares.use(\n\t\t\tscoped(\n\t\t\t\tassets,\n\t\t\t\tsirv(join(svelte_config.kit.outDir, 'output/client'), {\n\t\t\t\t\tsetHeaders: (res, pathname) => {\n\t\t\t\t\t\t// only apply to immutable directory, not e.g. version.json\n\t\t\t\t\t\tif (pathname.startsWith(`/${svelte_config.kit.appDir}/immutable`)) {\n\t\t\t\t\t\t\tres.setHeader('cache-control', 'public,max-age=31536000,immutable');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\tvite.middlewares.use((req, res, next) => {\n\t\t\tconst original_url = /** @type {string} */ (req.url);\n\t\t\tconst { pathname, search } = new URL(original_url, 'http://dummy');\n\n\t\t\t// if `paths.base === '/a/b/c`, then the root route is `/a/b/c/`,\n\t\t\t// regardless of the `trailingSlash` route option\n\t\t\tif (base.length > 1 && pathname === base) {\n\t\t\t\tlet location = base + '/';\n\t\t\t\tif (search) location += search;\n\t\t\t\tres.writeHead(307, {\n\t\t\t\t\tlocation\n\t\t\t\t});\n\t\t\t\tres.end();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (pathname.startsWith(base)) {\n\t\t\t\tnext();\n\t\t\t} else {\n\t\t\t\tres.statusCode = 404;\n\t\t\t\tnot_found(req, res, base);\n\t\t\t}\n\t\t});\n\n\t\t// prerendered dependencies\n\t\tvite.middlewares.use(\n\t\t\tscoped(base, mutable(join(svelte_config.kit.outDir, 'output/prerendered/dependencies')))\n\t\t);\n\n\t\t// prerendered pages (we can't just use sirv because we need to\n\t\t// preserve the correct trailingSlash behaviour)\n\t\tvite.middlewares.use(\n\t\t\tscoped(base, (req, res, next) => {\n\t\t\t\tlet if_none_match_value = req.headers['if-none-match'];\n\n\t\t\t\tif (if_none_match_value?.startsWith('W/\"')) {\n\t\t\t\t\tif_none_match_value = if_none_match_value.substring(2);\n\t\t\t\t}\n\n\t\t\t\tif (if_none_match_value === etag) {\n\t\t\t\t\tres.statusCode = 304;\n\t\t\t\t\tres.end();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { pathname, search } = new URL(/** @type {string} */ (req.url), 'http://dummy');\n\n\t\t\t\tconst dir = pathname.startsWith(`/${svelte_config.kit.appDir}/remote/`) ? 'data' : 'pages';\n\n\t\t\t\tlet filename = normalizePath(\n\t\t\t\t\tjoin(svelte_config.kit.outDir, `output/prerendered/${dir}` + pathname)\n\t\t\t\t);\n\n\t\t\t\ttry {\n\t\t\t\t\tfilename = decodeURI(filename);\n\t\t\t\t} catch {\n\t\t\t\t\t// malformed URI\n\t\t\t\t}\n\n\t\t\t\tlet prerendered = is_file(filename);\n\n\t\t\t\tif (!prerendered) {\n\t\t\t\t\tconst has_trailing_slash = pathname.endsWith('/');\n\t\t\t\t\tconst html_filename = `${filename}${has_trailing_slash ? 'index.html' : '.html'}`;\n\n\t\t\t\t\t/** @type {string | undefined} */\n\t\t\t\t\tlet redirect;\n\n\t\t\t\t\tif (is_file(html_filename)) {\n\t\t\t\t\t\tfilename = html_filename;\n\t\t\t\t\t\tprerendered = true;\n\t\t\t\t\t} else if (has_trailing_slash) {\n\t\t\t\t\t\tif (is_file(filename.slice(0, -1) + '.html')) {\n\t\t\t\t\t\t\tredirect = pathname.slice(0, -1);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (is_file(filename + '/index.html')) {\n\t\t\t\t\t\tredirect = pathname + '/';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (redirect) {\n\t\t\t\t\t\tif (search) redirect += search;\n\t\t\t\t\t\tres.writeHead(307, {\n\t\t\t\t\t\t\tlocation: redirect\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tres.end();\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (prerendered) {\n\t\t\t\t\tres.writeHead(200, {\n\t\t\t\t\t\t'content-type': lookup(pathname) || 'text/html',\n\t\t\t\t\t\tetag\n\t\t\t\t\t});\n\n\t\t\t\t\tfs.createReadStream(filename).pipe(res);\n\t\t\t\t} else {\n\t\t\t\t\tnext();\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\n\t\t// SSR\n\t\tvite.middlewares.use(async (req, res) => {\n\t\t\tconst host = req.headers[':authority'] || req.headers.host;\n\n\t\t\tconst request = await getRequest({\n\t\t\t\tbase: `${protocol}://${host}`,\n\t\t\t\trequest: req\n\t\t\t});\n\n\t\t\tawait setResponse(\n\t\t\t\tres,\n\t\t\t\tawait server.respond(request, {\n\t\t\t\t\tgetClientAddress: () => {\n\t\t\t\t\t\tconst { remoteAddress } = req.socket;\n\t\t\t\t\t\tif (remoteAddress) return remoteAddress;\n\t\t\t\t\t\tthrow new Error('Could not determine clientAddress');\n\t\t\t\t\t},\n\t\t\t\t\tread: (file) => {\n\t\t\t\t\t\tif (file in manifest._.server_assets) {\n\t\t\t\t\t\t\treturn fs.readFileSync(join(dir, file));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn fs.readFileSync(join(svelte_config.kit.files.assets, file));\n\t\t\t\t\t},\n\t\t\t\t\temulator\n\t\t\t\t})\n\t\t\t);\n\t\t});\n\t};\n}\n\n/**\n * @param {string} dir\n * @returns {Handler}\n */\nconst mutable = (dir) =>\n\tfs.existsSync(dir)\n\t\t? sirv(dir, {\n\t\t\t\tetag: true,\n\t\t\t\tmaxAge: 0\n\t\t\t})\n\t\t: (_req, _res, next) => next();\n\n/**\n * @param {string} scope\n * @param {Handler} handler\n * @returns {Handler}\n */\nfunction scoped(scope, handler) {\n\tif (scope === '') return handler;\n\n\treturn (req, res, next) => {\n\t\tif (req.url?.startsWith(scope)) {\n\t\t\tconst original_url = req.url;\n\t\t\treq.url = req.url.slice(scope.length);\n\t\t\thandler(req, res, () => {\n\t\t\t\treq.url = original_url;\n\t\t\t\tnext();\n\t\t\t});\n\t\t} else {\n\t\t\tnext();\n\t\t}\n\t};\n}\n\n/** @param {string} path */\nfunction is_file(path) {\n\treturn fs.existsSync(path) && !fs.statSync(path).isDirectory();\n}\n"
  },
  {
    "path": "packages/kit/src/exports/vite/static_analysis/index.js",
    "content": "import { tsPlugin } from '@sveltejs/acorn-typescript';\nimport { Parser } from 'acorn';\nimport { read } from '../../../utils/filesystem.js';\n\nconst valid_page_options_array = /** @type {const} */ ([\n\t'ssr',\n\t'prerender',\n\t'csr',\n\t'trailingSlash',\n\t'config',\n\t'entries',\n\t'load'\n]);\n\n/** @type {Set<string>} */\nconst valid_page_options = new Set(valid_page_options_array);\n\n/** @typedef {typeof valid_page_options_array[number]} ValidPageOption */\n/** @typedef {Partial<Record<ValidPageOption, any>>} PageOptions */\n\nconst skip_parsing_regex = new RegExp(\n\t`${Array.from(valid_page_options).join('|')}|(?:export[\\\\s\\\\n]+\\\\*[\\\\s\\\\n]+from)`\n);\n\nconst parser = Parser.extend(tsPlugin());\n\n/**\n * Collects page options from a +page.js/+layout.js file, ignoring reassignments\n * and using the declared value (except for load functions, for which the value is `true`).\n * Returns `null` if any export is too difficult to analyse.\n * @param {string} filename The name of the file to report when an error occurs\n * @param {string} input\n * @returns {PageOptions | null}\n */\nexport function statically_analyse_page_options(filename, input) {\n\t// if there's a chance there are no page exports or an unparseable\n\t// export all declaration, then we can skip the AST parsing which is expensive\n\tif (!skip_parsing_regex.test(input)) {\n\t\treturn {};\n\t}\n\n\ttry {\n\t\tconst source = parser.parse(input, {\n\t\t\tsourceType: 'module',\n\t\t\tecmaVersion: 'latest'\n\t\t});\n\n\t\t/** @type {Map<string, import('acorn').Literal['value']>} */\n\t\tconst page_options = new Map();\n\n\t\tfor (const statement of source.body) {\n\t\t\t// ignore export all declarations with aliases that are not page options\n\t\t\tif (\n\t\t\t\tstatement.type === 'ExportAllDeclaration' &&\n\t\t\t\tstatement.exported &&\n\t\t\t\t!valid_page_options.has(get_name(statement.exported))\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tstatement.type === 'ExportDefaultDeclaration' ||\n\t\t\t\tstatement.type === 'ExportAllDeclaration'\n\t\t\t) {\n\t\t\t\treturn null;\n\t\t\t} else if (statement.type !== 'ExportNamedDeclaration') {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (statement.specifiers.length) {\n\t\t\t\t/** @type {Map<string, string>} */\n\t\t\t\tconst export_specifiers = new Map();\n\t\t\t\tfor (const specifier of statement.specifiers) {\n\t\t\t\t\tconst exported_name = get_name(specifier.exported);\n\t\t\t\t\tif (!valid_page_options.has(exported_name)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (statement.source) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\texport_specifiers.set(get_name(specifier.local), exported_name);\n\t\t\t\t}\n\n\t\t\t\tfor (const statement of source.body) {\n\t\t\t\t\tswitch (statement.type) {\n\t\t\t\t\t\tcase 'ImportDeclaration': {\n\t\t\t\t\t\t\tfor (const import_specifier of statement.specifiers) {\n\t\t\t\t\t\t\t\tif (export_specifiers.has(import_specifier.local.name)) {\n\t\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'ExportNamedDeclaration':\n\t\t\t\t\t\tcase 'VariableDeclaration':\n\t\t\t\t\t\tcase 'FunctionDeclaration':\n\t\t\t\t\t\tcase 'ClassDeclaration': {\n\t\t\t\t\t\t\tconst declaration =\n\t\t\t\t\t\t\t\tstatement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n\n\t\t\t\t\t\t\tif (!declaration) {\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// class and function declarations\n\t\t\t\t\t\t\tif (declaration.type !== 'VariableDeclaration') {\n\t\t\t\t\t\t\t\tif (export_specifiers.has(declaration.id.name)) {\n\t\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfor (const variable_declarator of declaration.declarations) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tvariable_declarator.id.type !== 'Identifier' ||\n\t\t\t\t\t\t\t\t\t!export_specifiers.has(variable_declarator.id.name)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (variable_declarator.init?.type === 'Literal') {\n\t\t\t\t\t\t\t\t\tpage_options.set(\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ (export_specifiers.get(variable_declarator.id.name)),\n\t\t\t\t\t\t\t\t\t\tvariable_declarator.init.value\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\texport_specifiers.delete(variable_declarator.id.name);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Special case: We only want to know that 'load' is exported (in a way that doesn't cause truthy checks in other places to trigger)\n\t\t\t\t\t\t\t\tif (variable_declarator.id.name === 'load') {\n\t\t\t\t\t\t\t\t\tpage_options.set('load', null);\n\t\t\t\t\t\t\t\t\texport_specifiers.delete('load');\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// references a declaration we can't easily evaluate statically\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// there were some export specifiers that we couldn't resolve\n\t\t\t\tif (export_specifiers.size) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!statement.declaration) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// class and function declarations\n\t\t\tif (statement.declaration.type !== 'VariableDeclaration') {\n\t\t\t\tif (valid_page_options.has(statement.declaration.id.name)) {\n\t\t\t\t\t// Special case: We only want to know that 'load' is exported (in a way that doesn't cause truthy checks in other places to trigger)\n\t\t\t\t\tif (statement.declaration.id.name === 'load') {\n\t\t\t\t\t\tpage_options.set('load', null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const declaration of statement.declaration.declarations) {\n\t\t\t\tif (declaration.id.type !== 'Identifier') {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif (!valid_page_options.has(declaration.id.name)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (declaration.init?.type === 'Literal') {\n\t\t\t\t\tpage_options.set(declaration.id.name, declaration.init.value);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Special case: We only want to know that 'load' is exported (in a way that doesn't cause truthy checks in other places to trigger)\n\t\t\t\tif (declaration.id.name === 'load') {\n\t\t\t\t\tpage_options.set('load', null);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// references a declaration we can't easily evaluate statically\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\treturn Object.fromEntries(page_options);\n\t} catch (error) {\n\t\tif (error instanceof Error) {\n\t\t\terror.message = `Failed to statically analyse page options for ${filename}. ${error.message}`;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * @param {import('acorn').Identifier | import('acorn').Literal} node\n * @returns {string}\n */\nfunction get_name(node) {\n\treturn node.type === 'Identifier' ? node.name : /** @type {string} */ (node.value);\n}\n\n/**\n * Reads and statically analyses a file for page options\n * @param {string} filepath\n * @returns {PageOptions | null} Returns the page options for the file or `null` if unanalysable\n */\nexport function get_page_options(filepath) {\n\ttry {\n\t\tconst input = read(filepath);\n\t\tconst page_options = statically_analyse_page_options(filepath, input);\n\t\tif (page_options === null) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn page_options;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport function create_node_analyser() {\n\tconst static_exports = new Map();\n\n\t/**\n\t * @param {string | undefined} key\n\t * @param {PageOptions | null} page_options\n\t */\n\tconst cache = (key, page_options) => {\n\t\tif (key) static_exports.set(key, { page_options, children: [] });\n\t};\n\n\t/**\n\t * Computes the final page options (may include load function as `load: null`; special case) for a node (if possible). Otherwise, returns `null`.\n\t * @param {import('types').PageNode} node\n\t * @returns {PageOptions | null}\n\t */\n\tconst crawl = (node) => {\n\t\tconst key = node.universal || node.server;\n\t\tif (key && static_exports.has(key)) {\n\t\t\treturn { ...static_exports.get(key)?.page_options };\n\t\t}\n\n\t\t/** @type {PageOptions} */\n\t\tlet page_options = {};\n\n\t\tif (node.parent) {\n\t\t\tconst parent_options = crawl(node.parent);\n\n\t\t\tconst parent_key = node.parent.universal || node.parent.server;\n\t\t\tif (key && parent_key) {\n\t\t\t\tstatic_exports.get(parent_key)?.children.push(key);\n\t\t\t}\n\n\t\t\tif (parent_options === null) {\n\t\t\t\t// if the parent cannot be analysed, we can't know what page options\n\t\t\t\t// the child node inherits, so we also mark it as unanalysable\n\t\t\t\tcache(key, null);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tpage_options = { ...parent_options };\n\t\t}\n\n\t\tif (node.server) {\n\t\t\tconst server_page_options = get_page_options(node.server);\n\t\t\tif (server_page_options === null) {\n\t\t\t\tcache(key, null);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tpage_options = { ...page_options, ...server_page_options };\n\t\t}\n\n\t\tif (node.universal) {\n\t\t\tconst universal_page_options = get_page_options(node.universal);\n\t\t\tif (universal_page_options === null) {\n\t\t\t\tcache(key, null);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tpage_options = { ...page_options, ...universal_page_options };\n\t\t}\n\n\t\tcache(key, page_options);\n\n\t\treturn page_options;\n\t};\n\n\treturn {\n\t\tget_page_options: crawl\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/exports/vite/static_analysis/index.spec.js",
    "content": "import { expect, test } from 'vitest';\nimport { statically_analyse_page_options } from './index.js';\n\ntest.each([\n\t[\n\t\t'multi-line declarations',\n\t\t`\n      export const ssr = false;\n      export const csr = true;\n      export const prerender = 'auto';\n      export const trailingSlash = 'always';\n    `\n\t],\n\t[\n\t\t'single-line declarations',\n\t\t`\n      export const ssr = false, csr = true, prerender = 'auto', trailingSlash = 'always';\n    `\n\t]\n])('page option is assigned a literal value: %s', (_, input) => {\n\tconst exports = statically_analyse_page_options('', input);\n\texpect(exports).toEqual({ ssr: false, csr: true, prerender: 'auto', trailingSlash: 'always' });\n});\n\ntest.each([\n\t[\n\t\t'runtime value',\n\t\t`\n      export const ssr = process.env.SSR;\n      export const prerender = true;\n    `\n\t],\n\t[\n\t\t'object',\n\t\t`\n      export const ssr = false;\n      export const config = {\n        runtime: 'edge'\n      }\n    `\n\t],\n\t[\n\t\t'arrow function',\n\t\t`\n      export const prerender = true;\n      export const entries = () => {\n        return [\n          { slug: 'foo' }\n        ]\n      }\n    `\n\t],\n\t['export all declaration alias', \"export * as ssr from './foo'\"]\n])('fails when page option is assigned a dynamic value: %s', (_, input) => {\n\tconst exports = statically_analyse_page_options('', input);\n\texpect(exports).toEqual(null);\n});\n\ntest.each([\n\t['private export', \"export let _foo = 'bar'\"],\n\t['export all declaration alias', 'export * as bar from \"./foo\"'],\n\t['non-page option export', \"export const foo = 'bar'\"]\n])('ignores %s', (_, input) => {\n\tconst exports = statically_analyse_page_options('', input);\n\texpect(exports).toEqual({});\n});\n\ntest.each([\n\t['single line', \"export * from './foo';\"],\n\t['multiple lines', \"export\\n*\\nfrom\\n'./foo'\"],\n\t['whitespace', 'export    *      from \"./foo\";'],\n\t['multiple lines and whitespace', \"export   \\n  *\\n   from 'abc';  \"]\n])('fails when export all declaration is used: %s', (_, input) => {\n\tconst exports = statically_analyse_page_options('', input);\n\texpect(exports).toEqual(null);\n});\n\ntest.each([\n\t[\n\t\t'let',\n\t\t`\n      export let ssr = true;\n      export const prerender = true;\n    `\n\t],\n\t[\n\t\t'block scoped assignment',\n\t\t`\n      export let ssr = true;\n      export const prerender = true;\n      function foo() {\n        let ssr = true;\n        ssr = false;\n      }\n    `\n\t],\n\t[\n\t\t'switch case scoped assignment',\n\t\t`\n      export let ssr = true;\n      export const prerender = true;\n      switch (ssr) {\n        case true:\n          let ssr = true;\n          ssr = false;\n          break;\n      }\n    `\n\t],\n\t[\n\t\t'nested block scope assignment',\n\t\t`\n      export let ssr = true;\n      export const prerender = true;\n      function foo() {\n        let ssr = true;\n        {\n          ssr = false;\n        }\n      }\n    `\n\t],\n\t[\n\t\t'used as assignment value',\n\t\t`\n      export let ssr = true;\n      export const prerender = true;\n      let csr;\n      csr = ssr;\n    `\n\t]\n])('non-reassigned page options: %s', (_, input) => {\n\tconst exports = statically_analyse_page_options('', input);\n\texpect(exports).toEqual({ ssr: true, prerender: true });\n});\n\ntest.each([\n\t[\n\t\t'declaration',\n\t\t`\n      let ssr = false;\n      export { ssr };\n    `\n\t],\n\t[\n\t\t'export named declaration',\n\t\t`\n      export let foo = false;\n      export { foo as ssr };\n    `\n\t]\n])('export specifier references: %s', (_, input) => {\n\tconst exports = statically_analyse_page_options('', input);\n\texpect(exports).toEqual({ ssr: false });\n});\n\ntest.each([\n\t[\n\t\t'import specifier',\n\t\t`\n      import { ssr } from './foo';\n      export { ssr };\n    `\n\t],\n\t[\n\t\t'import default specifier',\n\t\t`\n      import ssr from './foo';\n      export { ssr };\n    `\n\t],\n\t[\n\t\t'import namespace specifier',\n\t\t`\n      import * as ssr from './foo';\n      export { ssr };\n    `\n\t],\n\t[\n\t\t'array destructured declaration',\n\t\t`\n      let { ssr } = { ssr: false };\n      export { ssr };\n    `\n\t]\n])('fails when export specifier references: %s', (_, input) => {\n\tconst exports = statically_analyse_page_options('', input);\n\texpect(exports).toEqual(null);\n});\n\ntest.each([\n\t['(function)', 'export async function load () { return {} }'],\n\t['(variable)', 'export const load = () => { return {} }']\n])('special-cases load function %s', (_, input) => {\n\tconst exports = statically_analyse_page_options('', input);\n\texpect(exports).toEqual({ load: null });\n});\n\ntest('special-cases load function (static analysis fails)', () => {\n\tconst input = `\n\texport const load = () => { return {} };\n\texport const ssr = process.env.SSR;\n\t`;\n\tconst exports = statically_analyse_page_options('', input);\n\texpect(exports).toEqual(null);\n});\n"
  },
  {
    "path": "packages/kit/src/exports/vite/static_analysis/utils.js",
    "content": "/**\n * Check if content has children rendering (slot, @render, or children prop forwarding)\n * @param {string} content - The markup content\n * @param {boolean} is_svelte_5_plus - Whether the project uses Svelte 5+\n * @returns {boolean}\n */\nexport function has_children(content, is_svelte_5_plus) {\n\treturn (\n\t\tcontent.includes('<slot') ||\n\t\t(is_svelte_5_plus &&\n\t\t\t(content.includes('{@render') ||\n\t\t\t\t// children may be forwarded to a child component as a prop\n\t\t\t\tcontent.includes('{children}') ||\n\t\t\t\tcontent.includes('children={')))\n\t);\n}\n\n/**\n * Check if a match position is within a comment or a string\n * @param {string} content - The full content\n * @param {number} match_index - The index where the match starts\n * @returns {boolean} - True if the match is within a comment\n */\nexport function should_ignore(content, match_index) {\n\t// Track if we're inside different types of quotes and comments\n\tlet in_single_quote = false;\n\tlet in_double_quote = false;\n\tlet in_template_literal = false;\n\tlet in_single_line_comment = false;\n\tlet in_multi_line_comment = false;\n\tlet in_html_comment = false;\n\n\tfor (let i = 0; i < match_index; i++) {\n\t\tconst char = content[i];\n\t\tconst next_two = content.slice(i, i + 2);\n\t\tconst next_four = content.slice(i, i + 4);\n\n\t\t// Handle end of single line comment\n\t\tif (in_single_line_comment && char === '\\n') {\n\t\t\tin_single_line_comment = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Handle end of multi-line comment\n\t\tif (in_multi_line_comment && next_two === '*/') {\n\t\t\tin_multi_line_comment = false;\n\t\t\ti++; // Skip the '/' part\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Handle end of HTML comment\n\t\tif (in_html_comment && content.slice(i, i + 3) === '-->') {\n\t\t\tin_html_comment = false;\n\t\t\ti += 2; // Skip the '-->' part\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If we're in any comment, skip processing\n\t\tif (in_single_line_comment || in_multi_line_comment || in_html_comment) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Handle escape sequences in strings\n\t\tif ((in_single_quote || in_double_quote || in_template_literal) && char === '\\\\') {\n\t\t\ti++; // Skip the escaped character\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Handle string boundaries\n\t\tif (!in_double_quote && !in_template_literal && char === \"'\") {\n\t\t\tin_single_quote = !in_single_quote;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!in_single_quote && !in_template_literal && char === '\"') {\n\t\t\tin_double_quote = !in_double_quote;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!in_single_quote && !in_double_quote && char === '`') {\n\t\t\tin_template_literal = !in_template_literal;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If we're inside any string, don't process comment delimiters\n\t\tif (in_single_quote || in_double_quote || in_template_literal) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Check for comment starts\n\t\tif (next_two === '//') {\n\t\t\tin_single_line_comment = true;\n\t\t\ti++; // Skip the second '/'\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (next_two === '/*') {\n\t\t\tin_multi_line_comment = true;\n\t\t\ti++; // Skip the '*'\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (next_four === '<!--') {\n\t\t\tin_html_comment = true;\n\t\t\ti += 3; // Skip the '<!--'\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn (\n\t\tin_single_line_comment ||\n\t\tin_multi_line_comment ||\n\t\tin_html_comment ||\n\t\tin_single_quote ||\n\t\tin_double_quote ||\n\t\tin_template_literal\n\t);\n}\n"
  },
  {
    "path": "packages/kit/src/exports/vite/static_analysis/utils.spec.js",
    "content": "import { expect, test, vi } from 'vitest';\nimport path from 'node:path';\nimport { should_ignore, has_children } from './utils.js';\n\n// Mock the colors module to avoid issues in tests\nvi.mock('kleur', () => ({\n\tdefault: {\n\t\tbold: () => ({ red: (/** @type {string} */ str) => str })\n\t}\n}));\n\n// We need to test the warning_preprocessor functionality\n// Since it's not exported, we'll recreate the relevant parts for testing\nconst options_regex = /(export\\s+const\\s+(prerender|csr|ssr|trailingSlash))\\s*=/s;\n\n/**\n * @param {string} content\n * @param {string} filename\n */\nfunction should_warn_for_content(content, filename) {\n\tconst basename = path.basename(filename);\n\tif (basename.startsWith('+page.') || basename.startsWith('+layout.')) {\n\t\tconst match = content.match(options_regex);\n\t\treturn match && match.index !== undefined && !should_ignore(content, match.index);\n\t}\n\treturn false;\n}\n\ntest.each([\n\t[\n\t\t'single-line comment with export const trailingSlash',\n\t\t'// export const trailingSlash = \"always\"',\n\t\t'+page.svelte',\n\t\tfalse\n\t],\n\t[\n\t\t'multi-line comment with export const trailingSlash',\n\t\t'/* export const trailingSlash = \"always\" */',\n\t\t'+page.svelte',\n\t\tfalse\n\t],\n\t[\n\t\t'HTML comment with export const trailingSlash',\n\t\t'<!-- export const trailingSlash = \"always\" -->',\n\t\t'+page.svelte',\n\t\tfalse\n\t],\n\t[\n\t\t'single-line comment with export const ssr',\n\t\t'// export const ssr = false',\n\t\t'+page.svelte',\n\t\tfalse\n\t],\n\t[\n\t\t'valid export const trailingSlash',\n\t\t'export const trailingSlash = \"always\"',\n\t\t'+page.svelte',\n\t\ttrue\n\t],\n\t['valid export const ssr', 'export const ssr = false', '+page.svelte', true],\n\t[\n\t\t'valid export const with spacing',\n\t\t'export const   trailingSlash   =   \"always\"',\n\t\t'+page.svelte',\n\t\ttrue\n\t],\n\t[\n\t\t'valid export on non-page file should not warn',\n\t\t'export const trailingSlash = \"always\"',\n\t\t'regular.svelte',\n\t\tfalse\n\t],\n\t[\n\t\t'comment followed by valid export',\n\t\t'// This is a comment\\nexport const trailingSlash = \"always\"',\n\t\t'+page.svelte',\n\t\ttrue // Should still warn for the valid export\n\t],\n\t[\n\t\t'valid export with trailing comment',\n\t\t'export const trailingSlash = \"always\" // with comment after',\n\t\t'+page.svelte',\n\t\ttrue\n\t],\n\t[\n\t\t'comment with */ inside - not actually nested',\n\t\t'/* comment with */ inside */ export const trailingSlash = \"always\"',\n\t\t'+page.svelte',\n\t\ttrue // This should warn because the export is not in a comment\n\t],\n\t[\n\t\t'multiple line comment spanning lines',\n\t\t'/*\\n * multi-line comment\\n * export const trailingSlash = \"always\"\\n */',\n\t\t'+page.svelte',\n\t\tfalse\n\t],\n\t[\n\t\t'multiple single-line comments',\n\t\t'// first comment\\n// export const trailingSlash = \"always\"\\n// third comment',\n\t\t'+page.svelte',\n\t\tfalse\n\t],\n\t[\n\t\t'HTML comment spanning multiple lines',\n\t\t'<!--\\n  export const trailingSlash = \"always\"\\n-->',\n\t\t'+page.svelte',\n\t\tfalse\n\t],\n\t[\n\t\t'edge case: comment delimiters in strings',\n\t\t'\"/*\"; export const trailingSlash = \"always\"; \"*/\"',\n\t\t'+page.svelte',\n\t\ttrue // Should warn because the export is not actually in a comment\n\t],\n\t[\n\t\t'escaped quotes in strings',\n\t\t'\"comment with \\\\\"/*\\\\\" inside\"; export const trailingSlash = \"always\"',\n\t\t'+page.svelte',\n\t\ttrue\n\t],\n\t[\n\t\t'single quotes with comment delimiters',\n\t\t\"'/*'; export const trailingSlash = 'always'; '*/'\",\n\t\t'+page.svelte',\n\t\ttrue\n\t],\n\t[\n\t\t'template literal with comment delimiters',\n\t\t'`/*`; export const trailingSlash = \"always\"; `*/`',\n\t\t'+page.svelte',\n\t\ttrue\n\t],\n\t[\n\t\t'real comment after string with comment delimiter',\n\t\t'\"fake /*\"; /* real comment with export const trailingSlash = \"always\" */',\n\t\t'+page.svelte',\n\t\tfalse\n\t],\n\t[\n\t\t'nested comment-like structures in strings',\n\t\t'\"/* /* nested */ */\"; export const trailingSlash = \"always\"',\n\t\t'+page.svelte',\n\t\ttrue\n\t],\n\t['page option match inside string', '\"export const trailingSlash = true\"', '+page.svelte', false],\n\t[\n\t\t'page option match inside template literal',\n\t\t'`${42}export const trailingSlash = true`',\n\t\t'+page.svelte',\n\t\tfalse\n\t]\n])('warning behavior: %s', (_description, content, filename, should_warn) => {\n\tconst result = should_warn_for_content(content, filename);\n\texpect(result).toBe(should_warn);\n});\n\ntest.each([\n\t['layout with @render children()', '{@render children()}', true],\n\t['layout with slot', '<slot />', true],\n\t['layout with named slot', '<slot name=\"default\" />', true],\n\t[\n\t\t'layout forwarding children as shorthand prop',\n\t\t'<script>\\n\\tlet { children } = $props();\\n</script>\\n<Layout {children} />',\n\t\ttrue\n\t],\n\t[\n\t\t'layout forwarding children as explicit prop',\n\t\t'<script>\\n\\tlet { children } = $props();\\n</script>\\n<Layout children={children} />',\n\t\ttrue\n\t],\n\t[\n\t\t'layout with no children handling',\n\t\t'<script>\\n\\tlet { data } = $props();\\n</script>\\n<div>{data}</div>',\n\t\tfalse\n\t],\n\t['empty layout', '', false]\n])('layout children detection: %s', (_description, content, expected) => {\n\texpect(has_children(content, true)).toBe(expected);\n});\n"
  },
  {
    "path": "packages/kit/src/exports/vite/types.d.ts",
    "content": "export interface EnforcedConfig {\n\t[key: string]: EnforcedConfig | true;\n}\n"
  },
  {
    "path": "packages/kit/src/exports/vite/utils.js",
    "content": "import path from 'node:path';\nimport { loadEnv } from 'vite';\nimport { posixify } from '../../utils/filesystem.js';\nimport { negotiate } from '../../utils/http.js';\nimport { filter_env } from '../../utils/env.js';\nimport { escape_html } from '../../utils/escape.js';\nimport { dedent } from '../../core/sync/utils.js';\nimport {\n\tapp_server,\n\tenv_dynamic_private,\n\tenv_dynamic_public,\n\tenv_static_private,\n\tenv_static_public,\n\tservice_worker\n} from './module_ids.js';\n\n/**\n * Transforms kit.alias to a valid vite.resolve.alias array.\n *\n * Related to tsconfig path alias creation.\n *\n * @param {import('types').ValidatedKitConfig} config\n * */\nexport function get_config_aliases(config) {\n\t/** @type {import('vite').Alias[]} */\n\tconst alias = [\n\t\t// For now, we handle `$lib` specially here rather than make it a default value for\n\t\t// `config.kit.alias` since it has special meaning for packaging, etc.\n\t\t{ find: '$lib', replacement: config.files.lib }\n\t];\n\n\tfor (let [key, value] of Object.entries(config.alias)) {\n\t\tvalue = posixify(value);\n\t\tif (value.endsWith('/*')) {\n\t\t\tvalue = value.slice(0, -2);\n\t\t}\n\t\tif (key.endsWith('/*')) {\n\t\t\t// Doing just `{ find: key.slice(0, -2) ,..}` would mean `import .. from \"key\"` would also be matched, which we don't want\n\t\t\talias.push({\n\t\t\t\tfind: new RegExp(`^${escape_for_regexp(key.slice(0, -2))}\\\\/(.+)$`),\n\t\t\t\treplacement: `${path.resolve(value)}/$1`\n\t\t\t});\n\t\t} else if (key + '/*' in config.alias) {\n\t\t\t// key and key/* both exist -> the replacement for key needs to happen _only_ on import .. from \"key\"\n\t\t\talias.push({\n\t\t\t\tfind: new RegExp(`^${escape_for_regexp(key)}$`),\n\t\t\t\treplacement: path.resolve(value)\n\t\t\t});\n\t\t} else {\n\t\t\talias.push({ find: key, replacement: path.resolve(value) });\n\t\t}\n\t}\n\n\treturn alias;\n}\n\n/**\n * @param {string} str\n */\nfunction escape_for_regexp(str) {\n\treturn str.replace(/[.*+?^${}()|[\\]\\\\]/g, (match) => '\\\\' + match);\n}\n\n/**\n * Load environment variables from process.env and .env files\n * @param {import('types').ValidatedKitConfig['env']} env_config\n * @param {string} mode\n */\nexport function get_env(env_config, mode) {\n\tconst { publicPrefix: public_prefix, privatePrefix: private_prefix } = env_config;\n\tconst env = loadEnv(mode, env_config.dir, '');\n\n\treturn {\n\t\tpublic: filter_env(env, public_prefix, private_prefix),\n\t\tprivate: filter_env(env, private_prefix, public_prefix)\n\t};\n}\n\n/**\n * @param {import('http').IncomingMessage} req\n * @param {import('http').ServerResponse} res\n * @param {string} base\n */\nexport function not_found(req, res, base) {\n\tconst type = negotiate(req.headers.accept ?? '*', ['text/plain', 'text/html']);\n\n\t// special case — handle `/` request automatically\n\tif (req.url === '/' && type === 'text/html') {\n\t\tres.statusCode = 307;\n\t\tres.setHeader('location', base);\n\t\tres.end();\n\t\treturn;\n\t}\n\n\tres.statusCode = 404;\n\n\tconst prefixed = base + req.url;\n\n\tif (type === 'text/html') {\n\t\tres.setHeader('Content-Type', 'text/html');\n\t\tres.end(\n\t\t\t`The server is configured with a public base URL of ${escape_html(\n\t\t\t\tbase\n\t\t\t)} - did you mean to visit <a href=\"${escape_html(prefixed, true)}\">${escape_html(\n\t\t\t\tprefixed\n\t\t\t)}</a> instead?`\n\t\t);\n\t} else {\n\t\tres.end(\n\t\t\t`The server is configured with a public base URL of ${escape_html(\n\t\t\t\tbase\n\t\t\t)} - did you mean to visit ${escape_html(prefixed)} instead?`\n\t\t);\n\t}\n}\n\nconst query_pattern = /\\?.*$/s;\n\n/**\n * Removes cwd/lib path from the start of the id\n * @param {string} id\n * @param {string} lib\n * @param {string} cwd\n */\nexport function normalize_id(id, lib, cwd) {\n\tid = id.replace(query_pattern, '');\n\n\tif (id.startsWith(lib)) {\n\t\tid = id.replace(lib, '$lib');\n\t}\n\n\tif (id.startsWith(cwd)) {\n\t\tid = path.relative(cwd, id);\n\t}\n\n\tif (id === app_server) {\n\t\treturn '$app/server';\n\t}\n\n\tif (id === env_static_private) {\n\t\treturn '$env/static/private';\n\t}\n\n\tif (id === env_static_public) {\n\t\treturn '$env/static/public';\n\t}\n\n\tif (id === env_dynamic_private) {\n\t\treturn '$env/dynamic/private';\n\t}\n\n\tif (id === env_dynamic_public) {\n\t\treturn '$env/dynamic/public';\n\t}\n\n\tif (id === service_worker) {\n\t\treturn '$service-worker';\n\t}\n\n\treturn posixify(id);\n}\n\n/**\n * For times when you need to throw an error, but without\n * displaying a useless stack trace (since the developer\n * can't do anything useful with it)\n * @param {string} message\n */\nexport function stackless(message) {\n\tconst error = new Error(message);\n\terror.stack = '';\n\treturn error;\n}\n\nexport const strip_virtual_prefix = /** @param {string} id */ (id) => id.replace('\\0virtual:', '');\n\n/**\n * For `error_for_missing_config('instrumentation.server.js', 'kit.experimental.instrumentation.server', true)`,\n * returns:\n *\n * ```\n * To enable `instrumentation.server.js`, add the following to your `svelte.config.js`:\n *\n *\\`\\`\\`js\n *\tkit:\n *\t\texperimental:\n *\t\t\tinstrumentation:\n *\t\t\t\tserver: true\n *\t\t\t}\n *\t\t}\n *\t}\n *\\`\\`\\`\n *```\n * @param {string} feature_name\n * @param {string} path\n * @param {string} value\n * @returns {never}\n */\nexport function error_for_missing_config(feature_name, path, value) {\n\tconst hole = '__HOLE__';\n\n\tconst result = path.split('.').reduce((acc, part, i, parts) => {\n\t\tconst indent = '  '.repeat(i);\n\t\tconst rhs = i === parts.length - 1 ? value : `{\\n${hole}\\n${indent}}`;\n\n\t\treturn acc.replace(hole, `${indent}${part}: ${rhs}`);\n\t}, hole);\n\n\tthrow stackless(\n\t\tdedent`\\\n\t\t\tTo enable ${feature_name}, add the following to your \\`svelte.config.js\\`:\n\n\t\t\t${result}\n\t\t`\n\t);\n}\n"
  },
  {
    "path": "packages/kit/src/exports/vite/utils.spec.js",
    "content": "import path from 'node:path';\nimport { expect, test } from 'vitest';\nimport { validate_config } from '../../core/config/index.js';\nimport { posixify } from '../../utils/filesystem.js';\nimport { dedent } from '../../core/sync/utils.js';\nimport { get_config_aliases, error_for_missing_config } from './utils.js';\n\ntest('transform kit.alias to resolve.alias', () => {\n\tconst config = validate_config({\n\t\tkit: {\n\t\t\talias: {\n\t\t\t\tsimpleKey: 'simple/value',\n\t\t\t\tkey: 'value',\n\t\t\t\t'key/*': 'value/*',\n\t\t\t\t$regexChar: 'windows\\\\path',\n\t\t\t\t'$regexChar/*': 'windows\\\\path\\\\*'\n\t\t\t}\n\t\t}\n\t});\n\n\tconst aliases = get_config_aliases(config.kit);\n\n\tconst transformed = aliases.map((entry) => {\n\t\tconst replacement = posixify(path.relative('.', entry.replacement));\n\n\t\treturn {\n\t\t\tfind: entry.find.toString(), // else assertion fails\n\t\t\treplacement\n\t\t};\n\t});\n\n\texpect(transformed).toEqual([\n\t\t{ find: '$lib', replacement: 'src/lib' },\n\t\t{ find: 'simpleKey', replacement: 'simple/value' },\n\t\t{ find: /^key$/.toString(), replacement: 'value' },\n\t\t{ find: /^key\\/(.+)$/.toString(), replacement: 'value/$1' },\n\t\t{ find: /^\\$regexChar$/.toString(), replacement: 'windows/path' },\n\t\t{ find: /^\\$regexChar\\/(.+)$/.toString(), replacement: 'windows/path/$1' }\n\t]);\n});\n\ntest('error_for_missing_config - simple single level config', () => {\n\texpect(() => error_for_missing_config('feature', 'kit.adapter', 'true')).toThrow(\n\t\tdedent`\n\t\t\tTo enable feature, add the following to your \\`svelte.config.js\\`:\n\n\t\t\tkit: {\n\t\t\t  adapter: true\n\t\t\t}\n\t\t`\n\t);\n});\n\ntest('error_for_missing_config - nested config', () => {\n\texpect(() =>\n\t\terror_for_missing_config(\n\t\t\t'instrumentation.server.js',\n\t\t\t'kit.experimental.instrumentation.server',\n\t\t\t'true'\n\t\t)\n\t).toThrow(\n\t\tdedent`\n\t\t\tTo enable instrumentation.server.js, add the following to your \\`svelte.config.js\\`:\n\n\t\t\tkit: {\n\t\t\t  experimental: {\n\t\t\t    instrumentation: {\n\t\t\t      server: true\n\t\t\t    }\n\t\t\t  }\n\t\t\t}\n\t\t`\n\t);\n});\n\ntest('error_for_missing_config - deeply nested config', () => {\n\texpect(() => error_for_missing_config('deep feature', 'a.b.c.d.e', '\"value\"')).toThrow(\n\t\tdedent`\n\t\t\tTo enable deep feature, add the following to your \\`svelte.config.js\\`:\n\n\t\t\ta: {\n\t\t\t  b: {\n\t\t\t    c: {\n\t\t\t      d: {\n\t\t\t        e: \"value\"\n\t\t\t      }\n\t\t\t    }\n\t\t\t  }\n\t\t\t}\n\t\t`\n\t);\n});\n\ntest('error_for_missing_config - two level config', () => {\n\texpect(() => error_for_missing_config('some feature', 'kit.someFeature', 'false')).toThrow(\n\t\tdedent`\n\t\t\tTo enable some feature, add the following to your \\`svelte.config.js\\`:\n\n\t\t\tkit: {\n\t\t\t  someFeature: false\n\t\t\t}\n\t\t`\n\t);\n});\n\ntest('error_for_missing_config - handles special characters in feature name', () => {\n\texpect(() =>\n\t\terror_for_missing_config('special-feature.js', 'kit.special', '{ enabled: true }')\n\t).toThrow(\n\t\tdedent`\n\t\t\tTo enable special-feature.js, add the following to your \\`svelte.config.js\\`:\n\n\t\t\tkit: {\n\t\t\t  special: { enabled: true }\n\t\t\t}\n\t\t`\n\t);\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/app/environment/index.js",
    "content": "export { BROWSER as browser, DEV as dev } from 'esm-env';\nexport { building, version } from '__sveltekit/environment';\n"
  },
  {
    "path": "packages/kit/src/runtime/app/environment/types.d.ts",
    "content": "/**\n * `true` if the app is running in the browser.\n */\nexport const browser: boolean;\n\n/**\n * Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`.\n */\nexport const dev: boolean;\n\n/**\n * SvelteKit analyses your app during the `build` step by running it. During this process, `building` is `true`. This also applies during prerendering.\n */\nexport const building: boolean;\n\n/**\n * The value of `config.kit.version.name`.\n */\nexport const version: string;\n"
  },
  {
    "path": "packages/kit/src/runtime/app/forms.js",
    "content": "import * as devalue from 'devalue';\nimport { BROWSER, DEV } from 'esm-env';\nimport { invalidateAll } from './navigation.js';\nimport { app as client_app, applyAction } from '../client/client.js';\nimport { app as server_app } from '../server/app.js';\n\nexport { applyAction };\n\n/**\n * Use this function to deserialize the response from a form submission.\n * Usage:\n *\n * ```js\n * import { deserialize } from '$app/forms';\n *\n * async function handleSubmit(event) {\n *   const response = await fetch('/form?/action', {\n *     method: 'POST',\n *     body: new FormData(event.target)\n *   });\n *\n *   const result = deserialize(await response.text());\n *   // ...\n * }\n * ```\n * @template {Record<string, unknown> | undefined} Success\n * @template {Record<string, unknown> | undefined} Failure\n * @param {string} result\n * @returns {import('@sveltejs/kit').ActionResult<Success, Failure>}\n */\nexport function deserialize(result) {\n\tconst parsed = JSON.parse(result);\n\n\tif (parsed.data) {\n\t\t// the decoders should never be initialised at the top-level because `app`\n\t\t// will not be initialised yet if `kit.output.bundleStrategy` is 'single' or 'inline'\n\t\tparsed.data = devalue.parse(parsed.data, BROWSER ? client_app.decoders : server_app.decoders);\n\t}\n\n\treturn parsed;\n}\n\n/**\n * Shallow clone an element, so that we can access e.g. `form.action` without worrying\n * that someone has added an `<input name=\"action\">` (https://github.com/sveltejs/kit/issues/7593)\n * @template {HTMLElement} T\n * @param {T} element\n * @returns {T}\n */\nfunction clone(element) {\n\treturn /** @type {T} */ (HTMLElement.prototype.cloneNode.call(element));\n}\n\n/**\n * This action enhances a `<form>` element that otherwise would work without JavaScript.\n *\n * The `submit` function is called upon submission with the given FormData and the `action` that should be triggered.\n * If `cancel` is called, the form will not be submitted.\n * You can use the abort `controller` to cancel the submission in case another one starts.\n * If a function is returned, that function is called with the response from the server.\n * If nothing is returned, the fallback will be used.\n *\n * If this function or its return value isn't set, it\n * - falls back to updating the `form` prop with the returned data if the action is on the same page as the form\n * - updates `page.status`\n * - resets the `<form>` element and invalidates all data in case of successful submission with no redirect response\n * - redirects in case of a redirect response\n * - redirects to the nearest error page in case of an unexpected error\n *\n * If you provide a custom function with a callback and want to use the default behavior, invoke `update` in your callback.\n * It accepts an options object\n * - `reset: false` if you don't want the `<form>` values to be reset after a successful submission\n * - `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission\n * @template {Record<string, unknown> | undefined} Success\n * @template {Record<string, unknown> | undefined} Failure\n * @param {HTMLFormElement} form_element The form element\n * @param {import('@sveltejs/kit').SubmitFunction<Success, Failure>} submit Submit callback\n */\nexport function enhance(form_element, submit = () => {}) {\n\tif (DEV && clone(form_element).method !== 'post') {\n\t\tthrow new Error('use:enhance can only be used on <form> fields with method=\"POST\"');\n\t}\n\n\t/**\n\t * @param {{\n\t *   action: URL;\n\t *   invalidateAll?: boolean;\n\t *   result: import('@sveltejs/kit').ActionResult;\n\t *   reset?: boolean\n\t * }} opts\n\t */\n\tconst fallback_callback = async ({\n\t\taction,\n\t\tresult,\n\t\treset = true,\n\t\tinvalidateAll: shouldInvalidateAll = true\n\t}) => {\n\t\tif (result.type === 'success') {\n\t\t\tif (reset) {\n\t\t\t\t// We call reset from the prototype to avoid DOM clobbering\n\t\t\t\tHTMLFormElement.prototype.reset.call(form_element);\n\t\t\t}\n\t\t\tif (shouldInvalidateAll) {\n\t\t\t\tawait invalidateAll();\n\t\t\t}\n\t\t}\n\n\t\t// For success/failure results, only apply action if it belongs to the\n\t\t// current page, otherwise `form` will be updated erroneously\n\t\tif (\n\t\t\tlocation.origin + location.pathname === action.origin + action.pathname ||\n\t\t\tresult.type === 'redirect' ||\n\t\t\tresult.type === 'error'\n\t\t) {\n\t\t\tawait applyAction(result);\n\t\t}\n\t};\n\n\t/** @param {SubmitEvent} event */\n\tasync function handle_submit(event) {\n\t\tconst method = event.submitter?.hasAttribute('formmethod')\n\t\t\t? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formMethod\n\t\t\t: clone(form_element).method;\n\t\tif (method !== 'post') return;\n\n\t\tevent.preventDefault();\n\n\t\tconst action = new URL(\n\t\t\t// We can't do submitter.formAction directly because that property is always set\n\t\t\tevent.submitter?.hasAttribute('formaction')\n\t\t\t\t? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formAction\n\t\t\t\t: clone(form_element).action\n\t\t);\n\n\t\tconst enctype = event.submitter?.hasAttribute('formenctype')\n\t\t\t? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formEnctype\n\t\t\t: clone(form_element).enctype;\n\n\t\tconst form_data = new FormData(form_element, event.submitter);\n\n\t\tif (DEV && enctype !== 'multipart/form-data') {\n\t\t\tfor (const value of form_data.values()) {\n\t\t\t\tif (value instanceof File) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Your form contains <input type=\"file\"> 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.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst controller = new AbortController();\n\n\t\tlet cancelled = false;\n\t\tconst cancel = () => (cancelled = true);\n\n\t\tconst callback =\n\t\t\t(await submit({\n\t\t\t\taction,\n\t\t\t\tcancel,\n\t\t\t\tcontroller,\n\t\t\t\tformData: form_data,\n\t\t\t\tformElement: form_element,\n\t\t\t\tsubmitter: event.submitter\n\t\t\t})) ?? fallback_callback;\n\t\tif (cancelled) return;\n\n\t\t/** @type {import('@sveltejs/kit').ActionResult} */\n\t\tlet result;\n\n\t\ttry {\n\t\t\tconst headers = new Headers({\n\t\t\t\taccept: 'application/json',\n\t\t\t\t'x-sveltekit-action': 'true'\n\t\t\t});\n\n\t\t\t// do not explicitly set the `Content-Type` header when sending `FormData`\n\t\t\t// or else it will interfere with the browser's header setting\n\t\t\t// see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest_API/Using_FormData_Objects#sect4\n\t\t\tif (enctype !== 'multipart/form-data') {\n\t\t\t\theaders.set(\n\t\t\t\t\t'Content-Type',\n\t\t\t\t\t/^(:?application\\/x-www-form-urlencoded|text\\/plain)$/.test(enctype)\n\t\t\t\t\t\t? enctype\n\t\t\t\t\t\t: 'application/x-www-form-urlencoded'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// @ts-expect-error `URLSearchParams(form_data)` is kosher, but typescript doesn't know that\n\t\t\tconst body = enctype === 'multipart/form-data' ? form_data : new URLSearchParams(form_data);\n\n\t\t\tconst response = await fetch(action, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders,\n\t\t\t\tcache: 'no-store',\n\t\t\t\tbody,\n\t\t\t\tsignal: controller.signal\n\t\t\t});\n\n\t\t\tresult = deserialize(await response.text());\n\t\t\tif (result.type === 'error') result.status = response.status;\n\t\t} catch (error) {\n\t\t\tif (/** @type {any} */ (error)?.name === 'AbortError') return;\n\t\t\tresult = { type: 'error', error };\n\t\t}\n\n\t\tawait callback({\n\t\t\taction,\n\t\t\tformData: form_data,\n\t\t\tformElement: form_element,\n\t\t\tupdate: (opts) =>\n\t\t\t\tfallback_callback({\n\t\t\t\t\taction,\n\t\t\t\t\tresult,\n\t\t\t\t\treset: opts?.reset,\n\t\t\t\t\tinvalidateAll: opts?.invalidateAll\n\t\t\t\t}),\n\t\t\t// @ts-expect-error generic constraints stuff we don't care about\n\t\t\tresult\n\t\t});\n\t}\n\n\t// @ts-expect-error\n\tHTMLFormElement.prototype.addEventListener.call(form_element, 'submit', handle_submit);\n\n\treturn {\n\t\tdestroy() {\n\t\t\t// @ts-expect-error\n\t\t\tHTMLFormElement.prototype.removeEventListener.call(form_element, 'submit', handle_submit);\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/app/navigation.js",
    "content": "export {\n\tafterNavigate,\n\tbeforeNavigate,\n\tdisableScrollHandling,\n\tgoto,\n\tinvalidate,\n\tinvalidateAll,\n\trefreshAll,\n\tonNavigate,\n\tpreloadCode,\n\tpreloadData,\n\tpushState,\n\treplaceState\n} from '../client/client.js';\n"
  },
  {
    "path": "packages/kit/src/runtime/app/paths/client.js",
    "content": "/** @import { Asset, RouteId, RouteIdWithSearchOrHash, Pathname, PathnameWithSearchOrHash, ResolvedPathname } from '$app/types' */\n/** @import { ResolveArgs } from './types.js' */\nimport { base, assets, hash_routing } from './internal/client.js';\nimport { resolve_route } from '../../../utils/routing.js';\nimport { get_navigation_intent } from '../../client/client.js';\n\n/**\n * Resolve the URL of an asset in your `static` directory, by prefixing it with [`config.kit.paths.assets`](https://svelte.dev/docs/kit/configuration#paths) if configured, or otherwise by prefixing it with the base path.\n *\n * During server rendering, the base path is relative and depends on the page currently being rendered.\n *\n * @example\n * ```svelte\n * <script>\n * \timport { asset } from '$app/paths';\n * </script>\n *\n * <img alt=\"a potato\" src={asset('/potato.jpg')} />\n * ```\n * @since 2.26\n *\n * @param {Asset} file\n * @returns {string}\n */\nexport function asset(file) {\n\treturn (assets || base) + file;\n}\n\nconst pathname_prefix = hash_routing ? '#' : '';\n\n/**\n * Resolve a pathname by prefixing it with the base path, if any, or resolve a route ID by populating dynamic segments with parameters.\n *\n * During server rendering, the base path is relative and depends on the page currently being rendered.\n *\n * @example\n * ```js\n * import { resolve } from '$app/paths';\n *\n * // using a pathname\n * const resolved = resolve(`/blog/hello-world`);\n *\n * // using a route ID plus parameters\n * const resolved = resolve('/blog/[slug]', {\n * \tslug: 'hello-world'\n * });\n * ```\n * @since 2.26\n *\n * @template {RouteIdWithSearchOrHash | PathnameWithSearchOrHash} T\n * @param {ResolveArgs<T>} args\n * @returns {ResolvedPathname}\n */\nexport function resolve(...args) {\n\t// The type error is correct here, and if someone doesn't pass params when they should there's a runtime error,\n\t// but we don't want to adjust the internal resolve_route function to accept `undefined`, hence the type cast.\n\treturn (\n\t\tbase + pathname_prefix + resolve_route(args[0], /** @type {Record<string, string>} */ (args[1]))\n\t);\n}\n\n/**\n * Match a path or URL to a route ID and extracts any parameters.\n *\n * @example\n * ```js\n * import { match } from '$app/paths';\n *\n * const route = await match('/blog/hello-world');\n *\n * if (route?.id === '/blog/[slug]') {\n * \tconst slug = route.params.slug;\n * \tconst response = await fetch(`/api/posts/${slug}`);\n * \tconst post = await response.json();\n * }\n * ```\n * @since 2.52.0\n *\n * @param {Pathname | URL | (string & {})} url\n * @returns {Promise<{ id: RouteId, params: Record<string, string> } | null>}\n */\nexport async function match(url) {\n\tif (typeof url === 'string') {\n\t\turl = new URL(url, location.href);\n\t}\n\n\tconst intent = await get_navigation_intent(url, false);\n\n\tif (intent) {\n\t\treturn {\n\t\t\tid: /** @type {RouteId} */ (intent.route.id),\n\t\t\tparams: intent.params\n\t\t};\n\t}\n\n\treturn null;\n}\n\nexport { base, assets, resolve as resolveRoute };\n"
  },
  {
    "path": "packages/kit/src/runtime/app/paths/index.js",
    "content": "export * from '#app/paths';\n"
  },
  {
    "path": "packages/kit/src/runtime/app/paths/internal/client.js",
    "content": "export const base = __SVELTEKIT_PAYLOAD__?.base ?? __SVELTEKIT_PATHS_BASE__;\nexport const assets = __SVELTEKIT_PAYLOAD__?.assets ?? base ?? __SVELTEKIT_PATHS_ASSETS__;\nexport const app_dir = __SVELTEKIT_APP_DIR__;\nexport const hash_routing = __SVELTEKIT_HASH_ROUTING__;\n"
  },
  {
    "path": "packages/kit/src/runtime/app/paths/internal/server.js",
    "content": "export let base = __SVELTEKIT_PATHS_BASE__;\nexport let assets = __SVELTEKIT_PATHS_ASSETS__ || base;\nexport const app_dir = __SVELTEKIT_APP_DIR__;\nexport const relative = __SVELTEKIT_PATHS_RELATIVE__;\n\nconst initial = { base, assets };\n\n/**\n * `base` could be overridden during rendering to be relative;\n * this one's the original non-relative base path\n */\nexport const initial_base = initial.base;\n\n/**\n * @param {{ base: string, assets: string }} paths\n */\nexport function override(paths) {\n\tbase = paths.base;\n\tassets = paths.assets;\n}\n\nexport function reset() {\n\tbase = initial.base;\n\tassets = initial.assets;\n}\n\n/** @param {string} path */\nexport function set_assets(path) {\n\tassets = initial.assets = path;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/app/paths/public.d.ts",
    "content": "import { RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname } from '$app/types';\nimport { ResolveArgs } from './types.js';\n\nexport { resolve, asset, match } from './client.js';\n\n/**\n * A string that matches [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths).\n *\n * Example usage: `<a href=\"{base}/your-page\">Link</a>`\n *\n * @deprecated Use [`resolve(...)`](https://svelte.dev/docs/kit/$app-paths#resolve) instead\n */\nexport let base: '' | `/${string}`;\n\n/**\n * An absolute path that matches [`config.kit.paths.assets`](https://svelte.dev/docs/kit/configuration#paths).\n *\n * > [!NOTE] 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.\n *\n * @deprecated Use [`asset(...)`](https://svelte.dev/docs/kit/$app-paths#asset) instead\n */\nexport let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit_assets';\n\n/**\n * @deprecated Use [`resolve(...)`](https://svelte.dev/docs/kit/$app-paths#resolve) instead\n */\nexport function resolveRoute<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash>(\n\t...args: ResolveArgs<T>\n): ResolvedPathname;\n"
  },
  {
    "path": "packages/kit/src/runtime/app/paths/server.js",
    "content": "import { base, assets, relative, initial_base } from './internal/server.js';\nimport { resolve_route, find_route } from '../../../utils/routing.js';\nimport { decode_pathname } from '../../../utils/url.js';\nimport { try_get_request_store } from '@sveltejs/kit/internal/server';\nimport { manifest } from '__sveltekit/server';\nimport { get_hooks } from '__SERVER__/internal.js';\n\n/** @type {import('./client.js').asset} */\nexport function asset(file) {\n\t// @ts-expect-error we use the `resolve` mechanism, but with the 'wrong' input\n\treturn assets && assets !== base ? assets + file : resolve(file);\n}\n\n/** @type {import('./client.js').resolve} */\nexport function resolve(id, params) {\n\tconst resolved = resolve_route(id, /** @type {Record<string, string>} */ (params));\n\n\tif (relative) {\n\t\tconst store = try_get_request_store();\n\n\t\tif (store && !store.state.prerendering?.fallback) {\n\t\t\tconst after_base = store.event.url.pathname.slice(initial_base.length);\n\t\t\tconst segments = after_base.split('/').slice(2);\n\t\t\tconst prefix = segments.map(() => '..').join('/') || '.';\n\n\t\t\treturn prefix + resolved;\n\t\t}\n\t}\n\n\treturn base + resolved;\n}\n\n/** @type {import('./client.js').match} */\nexport async function match(url) {\n\tconst store = try_get_request_store();\n\n\tif (typeof url === 'string') {\n\t\tconst origin = store?.event.url.origin ?? 'a://a';\n\t\turl = new URL(url, origin);\n\t}\n\n\tconst { reroute } = await get_hooks();\n\n\tlet resolved_path;\n\n\ttry {\n\t\tresolved_path = decode_pathname(\n\t\t\t(await reroute?.({ url: new URL(url), fetch: store?.event.fetch ?? fetch })) ?? url.pathname\n\t\t);\n\t} catch {\n\t\treturn null;\n\t}\n\n\tif (base && resolved_path.startsWith(base)) {\n\t\tresolved_path = resolved_path.slice(base.length) || '/';\n\t}\n\n\tconst matchers = await manifest._.matchers();\n\tconst result = find_route(resolved_path, manifest._.routes, matchers);\n\n\tif (result) {\n\t\treturn {\n\t\t\tid: /** @type {import('$app/types').RouteId} */ (result.route.id),\n\t\t\tparams: result.params\n\t\t};\n\t}\n\n\treturn null;\n}\n\nexport { base, assets, resolve as resolveRoute };\n"
  },
  {
    "path": "packages/kit/src/runtime/app/paths/types.d.ts",
    "content": "import {\n\tPathnameWithSearchOrHash,\n\tRouteId,\n\tRouteIdWithSearchOrHash,\n\tRouteParams\n} from '$app/types';\n\ntype StripSearchOrHash<T extends string> = T extends `${infer Pathname}?${string}`\n\t? Pathname\n\t: T extends `${infer Pathname}#${string}`\n\t\t? Pathname\n\t\t: T;\n\nexport type ResolveArgs<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash> =\n\tT extends RouteId\n\t\t? RouteParams<T> extends Record<string, never>\n\t\t\t? [route: T]\n\t\t\t: [route: T, params: RouteParams<T>]\n\t\t: StripSearchOrHash<T> extends infer U extends RouteId\n\t\t\t? RouteParams<U> extends Record<string, never>\n\t\t\t\t? [route: T]\n\t\t\t\t: [route: T, params: RouteParams<U>]\n\t\t\t: [route: T];\n"
  },
  {
    "path": "packages/kit/src/runtime/app/server/index.js",
    "content": "import { read_implementation, manifest } from '__sveltekit/server';\nimport { base } from '$app/paths';\nimport { DEV } from 'esm-env';\nimport { base64_decode } from '../../utils.js';\n\n/**\n * Read the contents of an imported asset from the filesystem\n * @example\n * ```js\n * import { read } from '$app/server';\n * import somefile from './somefile.txt';\n *\n * const asset = read(somefile);\n * const text = await asset.text();\n * ```\n * @param {string} asset\n * @returns {Response}\n * @since 2.4.0\n */\nexport function read(asset) {\n\t__SVELTEKIT_TRACK__('$app/server:read');\n\n\tif (!read_implementation) {\n\t\tthrow new Error(\n\t\t\t'No `read` implementation was provided. Please ensure that your adapter is up to date and supports this feature'\n\t\t);\n\t}\n\n\t// handle inline assets internally\n\tconst match = /^data:([^;,]+)?(;base64)?,/.exec(asset);\n\tif (match) {\n\t\tconst type = match[1] ?? 'application/octet-stream';\n\t\tconst data = asset.slice(match[0].length);\n\n\t\tif (match[2] !== undefined) {\n\t\t\tconst decoded = base64_decode(data);\n\n\t\t\t// @ts-ignore passing a Uint8Array to `new Response(...)` is fine\n\t\t\treturn new Response(decoded, {\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Length': decoded.byteLength.toString(),\n\t\t\t\t\t'Content-Type': type\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tconst decoded = decodeURIComponent(data);\n\n\t\treturn new Response(decoded, {\n\t\t\theaders: {\n\t\t\t\t'Content-Length': decoded.length.toString(),\n\t\t\t\t'Content-Type': type\n\t\t\t}\n\t\t});\n\t}\n\n\tconst file = decodeURIComponent(\n\t\tDEV && asset.startsWith('/@fs') ? asset : asset.slice(base.length + 1)\n\t);\n\n\tif (file in manifest._.server_assets) {\n\t\tconst length = manifest._.server_assets[file];\n\t\tconst type = manifest.mimeTypes[file.slice(file.lastIndexOf('.'))];\n\n\t\treturn new Response(read_implementation(file), {\n\t\t\theaders: {\n\t\t\t\t'Content-Length': '' + length,\n\t\t\t\t'Content-Type': type\n\t\t\t}\n\t\t});\n\t}\n\n\tthrow new Error(`Asset does not exist: ${file}`);\n}\n\nexport { getRequestEvent } from '@sveltejs/kit/internal/server';\n\nexport { query, prerender, command, form } from './remote/index.js';\n"
  },
  {
    "path": "packages/kit/src/runtime/app/server/remote/command.js",
    "content": "/** @import { RemoteCommand } from '@sveltejs/kit' */\n/** @import { MaybePromise, RemoteCommandInternals } from 'types' */\n/** @import { StandardSchemaV1 } from '@standard-schema/spec' */\nimport { get_request_store } from '@sveltejs/kit/internal/server';\nimport { create_validator, run_remote_function } from './shared.js';\nimport { MUTATIVE_METHODS } from '../../../../constants.js';\n\n/**\n * Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.\n *\n * @template Output\n * @overload\n * @param {() => Output} fn\n * @returns {RemoteCommand<void, Output>}\n * @since 2.27\n */\n/**\n * Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.\n *\n * @template Input\n * @template Output\n * @overload\n * @param {'unchecked'} validate\n * @param {(arg: Input) => Output} fn\n * @returns {RemoteCommand<Input, Output>}\n * @since 2.27\n */\n/**\n * Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.\n *\n * @template {StandardSchemaV1} Schema\n * @template Output\n * @overload\n * @param {Schema} validate\n * @param {(arg: StandardSchemaV1.InferOutput<Schema>) => Output} fn\n * @returns {RemoteCommand<StandardSchemaV1.InferInput<Schema>, Output>}\n * @since 2.27\n */\n/**\n * @template Input\n * @template Output\n * @param {any} validate_or_fn\n * @param {(arg?: Input) => Output} [maybe_fn]\n * @returns {RemoteCommand<Input, Output>}\n * @since 2.27\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function command(validate_or_fn, maybe_fn) {\n\t/** @type {(arg?: Input) => Output} */\n\tconst fn = maybe_fn ?? validate_or_fn;\n\n\t/** @type {(arg?: any) => MaybePromise<Input>} */\n\tconst validate = create_validator(validate_or_fn, maybe_fn);\n\n\t/** @type {RemoteCommandInternals} */\n\tconst __ = { type: 'command', id: '', name: '' };\n\n\t/** @type {RemoteCommand<Input, Output> & { __: RemoteCommandInternals }} */\n\tconst wrapper = (arg) => {\n\t\tconst { event, state } = get_request_store();\n\n\t\tif (!MUTATIVE_METHODS.includes(event.request.method)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot call a command (\\`${__.name}(${maybe_fn ? '...' : ''})\\`) from a ${event.request.method} handler`\n\t\t\t);\n\t\t}\n\n\t\tif (state.is_in_render) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot call a command (\\`${__.name}(${maybe_fn ? '...' : ''})\\`) during server-side rendering`\n\t\t\t);\n\t\t}\n\n\t\tstate.remote.refreshes ??= {};\n\n\t\tconst promise = Promise.resolve(\n\t\t\trun_remote_function(event, state, true, () => validate(arg), fn)\n\t\t);\n\n\t\t// @ts-expect-error\n\t\tpromise.updates = () => {\n\t\t\tthrow new Error(`Cannot call '${__.name}(...).updates(...)' on the server`);\n\t\t};\n\n\t\treturn /** @type {ReturnType<RemoteCommand<Input, Output>>} */ (promise);\n\t};\n\n\tObject.defineProperty(wrapper, '__', { value: __ });\n\n\t// On the server, pending is always 0\n\tObject.defineProperty(wrapper, 'pending', {\n\t\tget: () => 0\n\t});\n\n\treturn wrapper;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/app/server/remote/form.js",
    "content": "/** @import { RemoteFormInput, RemoteForm, InvalidField } from '@sveltejs/kit' */\n/** @import { InternalRemoteFormIssue, MaybePromise, RemoteFormInternals } from 'types' */\n/** @import { StandardSchemaV1 } from '@standard-schema/spec' */\nimport { get_request_store } from '@sveltejs/kit/internal/server';\nimport { DEV } from 'esm-env';\nimport {\n\tcreate_field_proxy,\n\tset_nested_value,\n\tthrow_on_old_property_access,\n\tdeep_set,\n\tnormalize_issue,\n\tflatten_issues\n} from '../../../form-utils.js';\nimport { get_cache, run_remote_function } from './shared.js';\nimport { ValidationError } from '@sveltejs/kit/internal';\n\n/**\n * Creates a form object that can be spread onto a `<form>` element.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.\n *\n * @template Output\n * @overload\n * @param {() => MaybePromise<Output>} fn\n * @returns {RemoteForm<void, Output>}\n * @since 2.27\n */\n/**\n * Creates a form object that can be spread onto a `<form>` element.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.\n *\n * @template {RemoteFormInput} Input\n * @template Output\n * @overload\n * @param {'unchecked'} validate\n * @param {(data: Input, issue: InvalidField<Input>) => MaybePromise<Output>} fn\n * @returns {RemoteForm<Input, Output>}\n * @since 2.27\n */\n/**\n * Creates a form object that can be spread onto a `<form>` element.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.\n *\n * @template {StandardSchemaV1<RemoteFormInput, Record<string, any>>} Schema\n * @template Output\n * @overload\n * @param {Schema} validate\n * @param {(data: StandardSchemaV1.InferOutput<Schema>, issue: InvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>} fn\n * @returns {RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>}\n * @since 2.27\n */\n/**\n * @template {RemoteFormInput} Input\n * @template Output\n * @param {any} validate_or_fn\n * @param {(data_or_issue: any, issue?: any) => MaybePromise<Output>} [maybe_fn]\n * @returns {RemoteForm<Input, Output>}\n * @since 2.27\n */\n/*@__NO_SIDE_EFFECTS__*/\n// @ts-ignore we don't want to prefix `fn` with an underscore, as that will be user-visible\nexport function form(validate_or_fn, maybe_fn) {\n\t/** @type {any} */\n\tconst fn = maybe_fn ?? validate_or_fn;\n\n\t/** @type {StandardSchemaV1 | null} */\n\tconst schema =\n\t\t!maybe_fn || validate_or_fn === 'unchecked' ? null : /** @type {any} */ (validate_or_fn);\n\n\t/**\n\t * @param {string | number | boolean} [key]\n\t */\n\tfunction create_instance(key) {\n\t\t/** @type {RemoteForm<Input, Output>} */\n\t\tconst instance = {};\n\n\t\tinstance.method = 'POST';\n\n\t\tObject.defineProperty(instance, 'enhance', {\n\t\t\tvalue: () => {\n\t\t\t\treturn { action: instance.action, method: instance.method };\n\t\t\t}\n\t\t});\n\n\t\t/** @type {RemoteFormInternals} */\n\t\tconst __ = {\n\t\t\ttype: 'form',\n\t\t\tname: '',\n\t\t\tid: '',\n\t\t\tfn: async (data, meta, form_data) => {\n\t\t\t\t// TODO 3.0 remove this warning\n\t\t\t\tif (DEV && !data) {\n\t\t\t\t\tconst error = () => {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'Remote form functions no longer get passed a FormData object. ' +\n\t\t\t\t\t\t\t\t\"`form` now has the same signature as `query` or `command`, i.e. it expects to be invoked like `form(schema, callback)` or `form('unchecked', callback)`. \" +\n\t\t\t\t\t\t\t\t'The payload of the callback function is now a POJO instead of a FormData object. See https://kit.svelte.dev/docs/remote-functions#form for details.'\n\t\t\t\t\t\t);\n\t\t\t\t\t};\n\t\t\t\t\tdata = {};\n\t\t\t\t\tfor (const key of [\n\t\t\t\t\t\t'append',\n\t\t\t\t\t\t'delete',\n\t\t\t\t\t\t'entries',\n\t\t\t\t\t\t'forEach',\n\t\t\t\t\t\t'get',\n\t\t\t\t\t\t'getAll',\n\t\t\t\t\t\t'has',\n\t\t\t\t\t\t'keys',\n\t\t\t\t\t\t'set',\n\t\t\t\t\t\t'values'\n\t\t\t\t\t]) {\n\t\t\t\t\t\tObject.defineProperty(data, key, { get: error });\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/** @type {{ submission: true, input?: Record<string, any>, issues?: InternalRemoteFormIssue[], result: Output }} */\n\t\t\t\tconst output = {};\n\n\t\t\t\t// make it possible to differentiate between user submission and programmatic `field.set(...)` updates\n\t\t\t\toutput.submission = true;\n\n\t\t\t\tconst { event, state } = get_request_store();\n\t\t\t\tconst validated = await schema?.['~standard'].validate(data);\n\n\t\t\t\tif (meta.validate_only) {\n\t\t\t\t\treturn validated?.issues?.map((issue) => normalize_issue(issue, true)) ?? [];\n\t\t\t\t}\n\n\t\t\t\tif (validated?.issues !== undefined) {\n\t\t\t\t\thandle_issues(output, validated.issues, form_data);\n\t\t\t\t} else {\n\t\t\t\t\tif (validated !== undefined) {\n\t\t\t\t\t\tdata = validated.value;\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.remote.refreshes ??= {};\n\n\t\t\t\t\tconst issue = create_issues();\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\toutput.result = await run_remote_function(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t() => data,\n\t\t\t\t\t\t\t(data) => (!maybe_fn ? fn() : fn(data, issue))\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (e instanceof ValidationError) {\n\t\t\t\t\t\t\thandle_issues(output, e.issues, form_data);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow e;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// We don't need to care about args or deduplicating calls, because uneval results are only relevant in full page reloads\n\t\t\t\t// where only one form submission is active at the same time\n\t\t\t\tif (!event.isRemoteRequest) {\n\t\t\t\t\tget_cache(__, state)[''] ??= { serialize: true, data: output };\n\t\t\t\t}\n\n\t\t\t\treturn output;\n\t\t\t}\n\t\t};\n\n\t\tObject.defineProperty(instance, '__', { value: __ });\n\n\t\tObject.defineProperty(instance, 'action', {\n\t\t\tget: () => `?/remote=${__.id}`,\n\t\t\tenumerable: true\n\t\t});\n\n\t\tObject.defineProperty(instance, 'fields', {\n\t\t\tget() {\n\t\t\t\treturn create_field_proxy(\n\t\t\t\t\t{},\n\t\t\t\t\t() => get_cache(__)?.['']?.data?.input ?? {},\n\t\t\t\t\t(path, value) => {\n\t\t\t\t\t\tconst cache = get_cache(__);\n\t\t\t\t\t\tconst entry = cache[''];\n\n\t\t\t\t\t\tif (entry?.data?.submission) {\n\t\t\t\t\t\t\t// don't override a submission\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (path.length === 0) {\n\t\t\t\t\t\t\t(cache[''] ??= { serialize: true, data: {} }).data.input = value;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst input = entry?.data?.input ?? {};\n\t\t\t\t\t\tdeep_set(input, path.map(String), value);\n\t\t\t\t\t\t(cache[''] ??= { serialize: true, data: {} }).data.input = input;\n\t\t\t\t\t},\n\t\t\t\t\t() => flatten_issues(get_cache(__)?.['']?.data?.issues ?? [])\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// TODO 3.0 remove\n\t\tif (DEV) {\n\t\t\tthrow_on_old_property_access(instance);\n\n\t\t\tObject.defineProperty(instance, 'buttonProps', {\n\t\t\t\tget() {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'`form.buttonProps` has been removed: Instead of `<button {...form.buttonProps}>, use `<button {...form.fields.action.as(\"submit\", \"value\")}>`.' +\n\t\t\t\t\t\t\t' See the PR for more info: https://github.com/sveltejs/kit/pull/14622'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tObject.defineProperty(instance, 'result', {\n\t\t\tget() {\n\t\t\t\ttry {\n\t\t\t\t\treturn get_cache(__)?.['']?.data?.result;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// On the server, pending is always 0\n\t\tObject.defineProperty(instance, 'pending', {\n\t\t\tget: () => 0\n\t\t});\n\n\t\tObject.defineProperty(instance, 'preflight', {\n\t\t\t// preflight is a noop on the server\n\t\t\tvalue: () => instance\n\t\t});\n\n\t\tObject.defineProperty(instance, 'validate', {\n\t\t\tvalue: () => {\n\t\t\t\tthrow new Error('Cannot call validate() on the server');\n\t\t\t}\n\t\t});\n\n\t\tif (key == undefined) {\n\t\t\tObject.defineProperty(instance, 'for', {\n\t\t\t\t/** @type {RemoteForm<any, any>['for']} */\n\t\t\t\tvalue: (key) => {\n\t\t\t\t\tconst { state } = get_request_store();\n\t\t\t\t\tconst cache_key = __.id + '|' + JSON.stringify(key);\n\t\t\t\t\tlet instance = (state.remote.forms ??= new Map()).get(cache_key);\n\n\t\t\t\t\tif (!instance) {\n\t\t\t\t\t\tinstance = create_instance(key);\n\t\t\t\t\t\tinstance.__.id = `${__.id}/${encodeURIComponent(JSON.stringify(key))}`;\n\t\t\t\t\t\tinstance.__.name = __.name;\n\n\t\t\t\t\t\tstate.remote.forms.set(cache_key, instance);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn instance;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn instance;\n\t}\n\n\treturn create_instance();\n}\n\n/**\n * @param {{ issues?: InternalRemoteFormIssue[], input?: Record<string, any>, result: any }} output\n * @param {readonly StandardSchemaV1.Issue[]} issues\n * @param {FormData | null} form_data - null if the form is progressively enhanced\n */\nfunction handle_issues(output, issues, form_data) {\n\toutput.issues = issues.map((issue) => normalize_issue(issue, true));\n\n\t// if it was a progressively-enhanced submission, we don't need\n\t// to return the input — it's already there\n\tif (form_data) {\n\t\toutput.input = {};\n\n\t\tfor (let key of form_data.keys()) {\n\t\t\t// redact sensitive fields\n\t\t\tif (/^[.\\]]?_/.test(key)) continue;\n\n\t\t\tconst is_array = key.endsWith('[]');\n\t\t\tconst values = form_data.getAll(key).filter((value) => typeof value === 'string');\n\n\t\t\tif (is_array) key = key.slice(0, -2);\n\n\t\t\tset_nested_value(\n\t\t\t\t/** @type {Record<string, any>} */ (output.input),\n\t\t\t\tkey,\n\t\t\t\tis_array ? values : values[0]\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Creates an invalid function that can be used to imperatively mark form fields as invalid\n * @returns {InvalidField<any>}\n */\nfunction create_issues() {\n\treturn /** @type {InvalidField<any>} */ (\n\t\tnew Proxy(\n\t\t\t/** @param {string} message */\n\t\t\t(message) => {\n\t\t\t\t// TODO 3.0 remove\n\t\t\t\tif (typeof message !== 'string') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'`invalid` should now be imported from `@sveltejs/kit` to throw validation issues. ' +\n\t\t\t\t\t\t\t\"The second parameter provided to the form function (renamed to `issue`) is still used to construct issues, e.g. `invalid(issue.field('message'))`. \" +\n\t\t\t\t\t\t\t'For more info see https://github.com/sveltejs/kit/pulls/14768'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn create_issue(message);\n\t\t\t},\n\t\t\t{\n\t\t\t\tget(target, prop) {\n\t\t\t\t\tif (typeof prop === 'symbol') return /** @type {any} */ (target)[prop];\n\n\t\t\t\t\treturn create_issue_proxy(prop, []);\n\t\t\t\t}\n\t\t\t}\n\t\t)\n\t);\n\n\t/**\n\t * @param {string} message\n\t * @param {(string | number)[]} path\n\t * @returns {StandardSchemaV1.Issue}\n\t */\n\tfunction create_issue(message, path = []) {\n\t\treturn {\n\t\t\tmessage,\n\t\t\tpath\n\t\t};\n\t}\n\n\t/**\n\t * Creates a proxy that builds up a path and returns a function to create an issue\n\t * @param {string | number} key\n\t * @param {(string | number)[]} path\n\t */\n\tfunction create_issue_proxy(key, path) {\n\t\tconst new_path = [...path, key];\n\n\t\t/**\n\t\t * @param {string} message\n\t\t * @returns {StandardSchemaV1.Issue}\n\t\t */\n\t\tconst issue_func = (message) => create_issue(message, new_path);\n\n\t\treturn new Proxy(issue_func, {\n\t\t\tget(target, prop) {\n\t\t\t\tif (typeof prop === 'symbol') return /** @type {any} */ (target)[prop];\n\n\t\t\t\t// Handle array access like invalid.items[0]\n\t\t\t\tif (/^\\d+$/.test(prop)) {\n\t\t\t\t\treturn create_issue_proxy(parseInt(prop, 10), new_path);\n\t\t\t\t}\n\n\t\t\t\t// Handle property access like invalid.field.nested\n\t\t\t\treturn create_issue_proxy(prop, new_path);\n\t\t\t}\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/app/server/remote/index.js",
    "content": "export { command } from './command.js';\nexport { form } from './form.js';\nexport { prerender } from './prerender.js';\nexport { query } from './query.js';\n"
  },
  {
    "path": "packages/kit/src/runtime/app/server/remote/prerender.js",
    "content": "/** @import { RemoteResource, RemotePrerenderFunction } from '@sveltejs/kit' */\n/** @import { RemotePrerenderInputsGenerator, RemotePrerenderInternals, MaybePromise } from 'types' */\n/** @import { StandardSchemaV1 } from '@standard-schema/spec' */\nimport { error, json } from '@sveltejs/kit';\nimport { DEV } from 'esm-env';\nimport { get_request_store } from '@sveltejs/kit/internal/server';\nimport { stringify, stringify_remote_arg } from '../../../shared.js';\nimport { app_dir, base } from '$app/paths/internal/server';\nimport {\n\tcreate_validator,\n\tget_cache,\n\tget_response,\n\tparse_remote_response,\n\trun_remote_function\n} from './shared.js';\n\n/**\n * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.\n *\n * @template Output\n * @overload\n * @param {() => MaybePromise<Output>} fn\n * @param {{ inputs?: RemotePrerenderInputsGenerator<void>, dynamic?: boolean }} [options]\n * @returns {RemotePrerenderFunction<void, Output>}\n * @since 2.27\n */\n/**\n * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.\n *\n * @template Input\n * @template Output\n * @overload\n * @param {'unchecked'} validate\n * @param {(arg: Input) => MaybePromise<Output>} fn\n * @param {{ inputs?: RemotePrerenderInputsGenerator<Input>, dynamic?: boolean }} [options]\n * @returns {RemotePrerenderFunction<Input, Output>}\n * @since 2.27\n */\n/**\n * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.\n *\n * @template {StandardSchemaV1} Schema\n * @template Output\n * @overload\n * @param {Schema} schema\n * @param {(arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>} fn\n * @param {{ inputs?: RemotePrerenderInputsGenerator<StandardSchemaV1.InferInput<Schema>>, dynamic?: boolean }} [options]\n * @returns {RemotePrerenderFunction<StandardSchemaV1.InferInput<Schema>, Output>}\n * @since 2.27\n */\n/**\n * @template Input\n * @template Output\n * @param {any} validate_or_fn\n * @param {any} [fn_or_options]\n * @param {{ inputs?: RemotePrerenderInputsGenerator<Input>, dynamic?: boolean }} [maybe_options]\n * @returns {RemotePrerenderFunction<Input, Output>}\n * @since 2.27\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function prerender(validate_or_fn, fn_or_options, maybe_options) {\n\tconst maybe_fn = typeof fn_or_options === 'function' ? fn_or_options : undefined;\n\n\t/** @type {typeof maybe_options} */\n\tconst options = maybe_options ?? (maybe_fn ? undefined : fn_or_options);\n\n\t/** @type {(arg?: Input) => MaybePromise<Output>} */\n\tconst fn = maybe_fn ?? validate_or_fn;\n\n\t/** @type {(arg?: any) => MaybePromise<Input>} */\n\tconst validate = create_validator(validate_or_fn, maybe_fn);\n\n\t/** @type {RemotePrerenderInternals} */\n\tconst __ = {\n\t\ttype: 'prerender',\n\t\tid: '',\n\t\tname: '',\n\t\thas_arg: !!maybe_fn,\n\t\tinputs: options?.inputs,\n\t\tdynamic: options?.dynamic\n\t};\n\n\t/** @type {RemotePrerenderFunction<Input, Output> & { __: RemotePrerenderInternals }} */\n\tconst wrapper = (arg) => {\n\t\t/** @type {Promise<Output> & Partial<RemoteResource<Output>>} */\n\t\tconst promise = (async () => {\n\t\t\tconst { event, state } = get_request_store();\n\t\t\tconst payload = stringify_remote_arg(arg, state.transport);\n\t\t\tconst id = __.id;\n\t\t\tconst url = `${base}/${app_dir}/remote/${id}${payload ? `/${payload}` : ''}`;\n\n\t\t\tif (!state.prerendering && !DEV && !event.isRemoteRequest) {\n\t\t\t\ttry {\n\t\t\t\t\treturn await get_response(__, arg, state, async () => {\n\t\t\t\t\t\tconst key = stringify_remote_arg(arg, state.transport);\n\t\t\t\t\t\tconst cache = get_cache(__, state);\n\n\t\t\t\t\t\t// TODO adapters can provide prerendered data more efficiently than\n\t\t\t\t\t\t// fetching from the public internet\n\t\t\t\t\t\tconst promise = (cache[key] ??= {\n\t\t\t\t\t\t\tserialize: true,\n\t\t\t\t\t\t\tdata: fetch(new URL(url, event.url.origin).href).then(async (response) => {\n\t\t\t\t\t\t\t\tif (!response.ok) {\n\t\t\t\t\t\t\t\t\tthrow new Error('Prerendered response not found');\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst prerendered = await response.json();\n\n\t\t\t\t\t\t\t\tif (prerendered.type === 'error') {\n\t\t\t\t\t\t\t\t\terror(prerendered.status, prerendered.error);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn prerendered.result;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}).data;\n\n\t\t\t\t\t\treturn parse_remote_response(await promise, state.transport);\n\t\t\t\t\t});\n\t\t\t\t} catch {\n\t\t\t\t\t// not available prerendered, fallback to normal function\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (state.prerendering?.remote_responses.has(url)) {\n\t\t\t\treturn /** @type {Promise<any>} */ (state.prerendering.remote_responses.get(url));\n\t\t\t}\n\n\t\t\tconst promise = get_response(__, arg, state, () =>\n\t\t\t\trun_remote_function(event, state, false, () => validate(arg), fn)\n\t\t\t);\n\n\t\t\tif (state.prerendering) {\n\t\t\t\tstate.prerendering.remote_responses.set(url, promise);\n\t\t\t}\n\n\t\t\tconst result = await promise;\n\n\t\t\tif (state.prerendering) {\n\t\t\t\tconst body = { type: 'result', result: stringify(result, state.transport) };\n\t\t\t\tstate.prerendering.dependencies.set(url, {\n\t\t\t\t\tbody: JSON.stringify(body),\n\t\t\t\t\tresponse: json(body)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// TODO this is missing error/loading/current/status\n\t\t\treturn result;\n\t\t})();\n\n\t\tpromise.catch(() => {});\n\n\t\treturn /** @type {RemoteResource<Output>} */ (promise);\n\t};\n\n\tObject.defineProperty(wrapper, '__', { value: __ });\n\n\treturn wrapper;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/app/server/remote/query.js",
    "content": "/** @import { RemoteQuery, RemoteQueryFunction } from '@sveltejs/kit' */\n/** @import { RemoteInternals, MaybePromise, RequestState, RemoteQueryBatchInternals, RemoteQueryInternals } from 'types' */\n/** @import { StandardSchemaV1 } from '@standard-schema/spec' */\nimport { get_request_store } from '@sveltejs/kit/internal/server';\nimport { create_remote_key, stringify, stringify_remote_arg } from '../../../shared.js';\nimport { prerendering } from '__sveltekit/environment';\nimport { create_validator, get_cache, get_response, run_remote_function } from './shared.js';\nimport { handle_error_and_jsonify } from '../../../server/utils.js';\nimport { HttpError, SvelteKitError } from '@sveltejs/kit/internal';\n\n/**\n * Creates a remote query. When called from the browser, the function will be invoked on the server via a `fetch` call.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.\n *\n * @template Output\n * @overload\n * @param {() => MaybePromise<Output>} fn\n * @returns {RemoteQueryFunction<void, Output>}\n * @since 2.27\n */\n/**\n * Creates a remote query. When called from the browser, the function will be invoked on the server via a `fetch` call.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.\n *\n * @template Input\n * @template Output\n * @overload\n * @param {'unchecked'} validate\n * @param {(arg: Input) => MaybePromise<Output>} fn\n * @returns {RemoteQueryFunction<Input, Output>}\n * @since 2.27\n */\n/**\n * Creates a remote query. When called from the browser, the function will be invoked on the server via a `fetch` call.\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.\n *\n * @template {StandardSchemaV1} Schema\n * @template Output\n * @overload\n * @param {Schema} schema\n * @param {(arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>} fn\n * @returns {RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output>}\n * @since 2.27\n */\n/**\n * @template Input\n * @template Output\n * @param {any} validate_or_fn\n * @param {(args?: Input) => MaybePromise<Output>} [maybe_fn]\n * @returns {RemoteQueryFunction<Input, Output>}\n * @since 2.27\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function query(validate_or_fn, maybe_fn) {\n\t/** @type {(arg?: Input) => Output} */\n\tconst fn = maybe_fn ?? validate_or_fn;\n\n\t/** @type {(arg?: any) => MaybePromise<Input>} */\n\tconst validate = create_validator(validate_or_fn, maybe_fn);\n\n\t/** @type {RemoteQueryInternals} */\n\tconst __ = { type: 'query', id: '', name: '' };\n\n\t/** @type {RemoteQueryFunction<Input, Output> & { __: RemoteQueryInternals }} */\n\tconst wrapper = (arg) => {\n\t\tif (prerendering) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot call query '${__.name}' while prerendering, as prerendered pages need static data. Use 'prerender' from $app/server instead`\n\t\t\t);\n\t\t}\n\n\t\tconst { event, state } = get_request_store();\n\n\t\treturn create_query_resource(__, arg, state, () =>\n\t\t\trun_remote_function(event, state, false, () => validate(arg), fn)\n\t\t);\n\t};\n\n\tObject.defineProperty(wrapper, '__', { value: __ });\n\n\treturn wrapper;\n}\n\n/**\n * Creates a batch query function that collects multiple calls and executes them in a single request\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.batch) for full documentation.\n *\n * @template Input\n * @template Output\n * @overload\n * @param {'unchecked'} validate\n * @param {(args: Input[]) => MaybePromise<(arg: Input, idx: number) => Output>} fn\n * @returns {RemoteQueryFunction<Input, Output>}\n * @since 2.35\n */\n/**\n * Creates a batch query function that collects multiple calls and executes them in a single request\n *\n * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.batch) for full documentation.\n *\n * @template {StandardSchemaV1} Schema\n * @template Output\n * @overload\n * @param {Schema} schema\n * @param {(args: StandardSchemaV1.InferOutput<Schema>[]) => MaybePromise<(arg: StandardSchemaV1.InferOutput<Schema>, idx: number) => Output>} fn\n * @returns {RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output>}\n * @since 2.35\n */\n/**\n * @template Input\n * @template Output\n * @param {any} validate_or_fn\n * @param {(args?: Input[]) => MaybePromise<(arg: Input, idx: number) => Output>} [maybe_fn]\n * @returns {RemoteQueryFunction<Input, Output>}\n * @since 2.35\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction batch(validate_or_fn, maybe_fn) {\n\t/** @type {(args?: Input[]) => MaybePromise<(arg: Input, idx: number) => Output>} */\n\tconst fn = maybe_fn ?? validate_or_fn;\n\n\t/** @type {(arg?: any) => MaybePromise<Input>} */\n\tconst validate = create_validator(validate_or_fn, maybe_fn);\n\n\t/** @type {RemoteQueryBatchInternals} */\n\tconst __ = {\n\t\ttype: 'query_batch',\n\t\tid: '',\n\t\tname: '',\n\t\trun: async (args, options) => {\n\t\t\tconst { event, state } = get_request_store();\n\n\t\t\treturn run_remote_function(\n\t\t\t\tevent,\n\t\t\t\tstate,\n\t\t\t\tfalse,\n\t\t\t\tasync () => Promise.all(args.map(validate)),\n\t\t\t\tasync (/** @type {any[]} */ input) => {\n\t\t\t\t\tconst get_result = await fn(input);\n\n\t\t\t\t\treturn Promise.all(\n\t\t\t\t\t\tinput.map(async (arg, i) => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst data = get_result(arg, i);\n\t\t\t\t\t\t\t\treturn { type: 'result', data: stringify(data, state.transport) };\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\t\t\t\terror: await handle_error_and_jsonify(event, state, options, error),\n\t\t\t\t\t\t\t\t\tstatus:\n\t\t\t\t\t\t\t\t\t\terror instanceof HttpError || error instanceof SvelteKitError\n\t\t\t\t\t\t\t\t\t\t\t? error.status\n\t\t\t\t\t\t\t\t\t\t\t: 500\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\t/** @type {Map<string, { arg: any, resolvers: Array<{resolve: (value: any) => void, reject: (error: any) => void}> }>} */\n\tlet batching = new Map();\n\n\t/** @type {RemoteQueryFunction<Input, Output> & { __: RemoteQueryBatchInternals }} */\n\tconst wrapper = (arg) => {\n\t\tif (prerendering) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot call query.batch '${__.name}' while prerendering, as prerendered pages need static data. Use 'prerender' from $app/server instead`\n\t\t\t);\n\t\t}\n\n\t\tconst { event, state } = get_request_store();\n\n\t\treturn create_query_resource(__, arg, state, () => {\n\t\t\t// Collect all the calls to the same query in the same macrotask,\n\t\t\t// then execute them as one backend request.\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst key = stringify_remote_arg(arg, state.transport);\n\t\t\t\tconst entry = batching.get(key);\n\n\t\t\t\tif (entry) {\n\t\t\t\t\tentry.resolvers.push({ resolve, reject });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbatching.set(key, {\n\t\t\t\t\targ,\n\t\t\t\t\tresolvers: [{ resolve, reject }]\n\t\t\t\t});\n\n\t\t\t\tif (batching.size > 1) return;\n\n\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\tconst batched = batching;\n\t\t\t\t\tbatching = new Map();\n\t\t\t\t\tconst entries = Array.from(batched.values());\n\t\t\t\t\tconst args = entries.map((entry) => entry.arg);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn await run_remote_function(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tasync () => Promise.all(args.map(validate)),\n\t\t\t\t\t\t\tasync (input) => {\n\t\t\t\t\t\t\t\tconst get_result = await fn(input);\n\n\t\t\t\t\t\t\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tconst result = get_result(input[i], i);\n\n\t\t\t\t\t\t\t\t\t\tfor (const resolver of entries[i].resolvers) {\n\t\t\t\t\t\t\t\t\t\t\tresolver.resolve(result);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t\tfor (const resolver of entries[i].resolvers) {\n\t\t\t\t\t\t\t\t\t\t\tresolver.reject(error);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfor (const entry of batched.values()) {\n\t\t\t\t\t\t\tfor (const resolver of entry.resolvers) {\n\t\t\t\t\t\t\t\tresolver.reject(error);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, 0);\n\t\t\t});\n\t\t});\n\t};\n\n\tObject.defineProperty(wrapper, '__', { value: __ });\n\n\treturn wrapper;\n}\n\n/**\n * @param {RemoteInternals} __\n * @param {any} arg\n * @param {RequestState} state\n * @param {() => Promise<any>} fn\n * @returns {RemoteQuery<any>}\n */\nfunction create_query_resource(__, arg, state, fn) {\n\t/** @type {Promise<any> | null} */\n\tlet promise = null;\n\n\tconst get_promise = () => {\n\t\treturn (promise ??= get_response(__, arg, state, fn));\n\t};\n\n\treturn {\n\t\t/** @type {Promise<any>['catch']} */\n\t\tcatch(onrejected) {\n\t\t\treturn get_promise().catch(onrejected);\n\t\t},\n\t\tcurrent: undefined,\n\t\terror: undefined,\n\t\t/** @type {Promise<any>['finally']} */\n\t\tfinally(onfinally) {\n\t\t\treturn get_promise().finally(onfinally);\n\t\t},\n\t\tloading: true,\n\t\tready: false,\n\t\trefresh() {\n\t\t\tconst refresh_context = get_refresh_context(__, 'refresh', arg);\n\t\t\tconst is_immediate_refresh = !refresh_context.cache[refresh_context.cache_key];\n\t\t\tconst value = is_immediate_refresh ? get_promise() : fn();\n\t\t\treturn update_refresh_value(refresh_context, value, is_immediate_refresh);\n\t\t},\n\t\trun() {\n\t\t\t// potential TODO: if we want to be able to run queries at the top level of modules / outside of the request context, we could technically remove\n\t\t\t// the requirement that `state` is defined, but that's kind of an annoying change to make, so we're going to wait on that until we have any sort of\n\t\t\t// concrete use case.\n\t\t\tif (!state.is_in_universal_load) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'On the server, .run() can only be called in universal `load` functions. Anywhere else, just await the query directly'\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn get_response(__, arg, state, fn);\n\t\t},\n\t\t/** @param {any} value */\n\t\tset(value) {\n\t\t\treturn update_refresh_value(get_refresh_context(__, 'set', arg), value);\n\t\t},\n\t\t/** @type {Promise<any>['then']} */\n\t\tthen(onfulfilled, onrejected) {\n\t\t\treturn get_promise().then(onfulfilled, onrejected);\n\t\t},\n\t\twithOverride() {\n\t\t\tthrow new Error(`Cannot call '${__.name}.withOverride()' on the server`);\n\t\t},\n\t\tget [Symbol.toStringTag]() {\n\t\t\treturn 'QueryResource';\n\t\t}\n\t};\n}\n\n// Add batch as a property to the query function\nObject.defineProperty(query, 'batch', { value: batch, enumerable: true });\n\n/**\n * @param {RemoteInternals} __\n * @param {'set' | 'refresh'} action\n * @param {any} [arg]\n * @returns {{ __: RemoteInternals; state: any; refreshes: Record<string, Promise<any>>; cache: Record<string, { serialize: boolean; data: any }>; refreshes_key: string; cache_key: string }}\n */\nfunction get_refresh_context(__, action, arg) {\n\tconst { state } = get_request_store();\n\tconst { refreshes } = state.remote;\n\n\tif (!refreshes) {\n\t\tconst name = __.type === 'query_batch' ? `query.batch '${__.name}'` : `query '${__.name}'`;\n\t\tthrow new Error(\n\t\t\t`Cannot call ${action} on ${name} because it is not executed in the context of a command/form remote function`\n\t\t);\n\t}\n\n\tconst cache = get_cache(__, state);\n\tconst cache_key = stringify_remote_arg(arg, state.transport);\n\tconst refreshes_key = create_remote_key(__.id, cache_key);\n\n\treturn { __, state, refreshes, refreshes_key, cache, cache_key };\n}\n\n/**\n * @param {{ __: RemoteInternals; refreshes: Record<string, Promise<any>>; cache: Record<string, { serialize: boolean; data: any }>; refreshes_key: string; cache_key: string }} context\n * @param {any} value\n * @param {boolean} [is_immediate_refresh=false]\n * @returns {Promise<void>}\n */\nfunction update_refresh_value(\n\t{ __, refreshes, refreshes_key, cache, cache_key },\n\tvalue,\n\tis_immediate_refresh = false\n) {\n\tconst promise = Promise.resolve(value);\n\n\tif (!is_immediate_refresh) {\n\t\tcache[cache_key] = { serialize: true, data: promise };\n\t}\n\n\tif (__.id) {\n\t\trefreshes[refreshes_key] = promise;\n\t}\n\n\treturn promise.then(() => {});\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/app/server/remote/shared.js",
    "content": "/** @import { RequestEvent } from '@sveltejs/kit' */\n/** @import { ServerHooks, MaybePromise, RequestState, RemoteInternals, RequestStore } from 'types' */\nimport { parse } from 'devalue';\nimport { error } from '@sveltejs/kit';\nimport { with_request_store, get_request_store } from '@sveltejs/kit/internal/server';\nimport {\n\tstringify_remote_arg,\n\tcreate_remote_key,\n\tstringify,\n\tunfriendly_hydratable\n} from '../../../shared.js';\n\n/**\n * @param {any} validate_or_fn\n * @param {(arg?: any) => any} [maybe_fn]\n * @returns {(arg?: any) => MaybePromise<any>}\n */\nexport function create_validator(validate_or_fn, maybe_fn) {\n\t// prevent functions without validators being called with arguments\n\tif (!maybe_fn) {\n\t\treturn (arg) => {\n\t\t\tif (arg !== undefined) {\n\t\t\t\terror(400, 'Bad Request');\n\t\t\t}\n\t\t};\n\t}\n\n\t// if 'unchecked', pass input through without validating\n\tif (validate_or_fn === 'unchecked') {\n\t\treturn (arg) => arg;\n\t}\n\n\t// use https://standardschema.dev validator if provided\n\tif ('~standard' in validate_or_fn) {\n\t\treturn async (arg) => {\n\t\t\t// Get event before async validation to ensure it's available in server environments without AsyncLocalStorage, too\n\t\t\tconst { event, state } = get_request_store();\n\t\t\t// access property and call method in one go to preserve potential this context\n\t\t\tconst result = await validate_or_fn['~standard'].validate(arg);\n\n\t\t\t// if the `issues` field exists, the validation failed\n\t\t\tif (result.issues) {\n\t\t\t\terror(\n\t\t\t\t\t400,\n\t\t\t\t\tawait state.handleValidationError({\n\t\t\t\t\t\tissues: result.issues,\n\t\t\t\t\t\tevent\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn result.value;\n\t\t};\n\t}\n\n\tthrow new Error(\n\t\t'Invalid validator passed to remote function. Expected \"unchecked\" or a Standard Schema (https://standardschema.dev)'\n\t);\n}\n\n/**\n * In case of a single remote function call, just returns the result.\n *\n * In case of a full page reload, returns the response for a remote function call,\n * either from the cache or by invoking the function.\n * Also saves an uneval'ed version of the result for later HTML inlining for hydration.\n *\n * @template {MaybePromise<any>} T\n * @param {RemoteInternals} internals\n * @param {any} arg\n * @param {RequestState} state\n * @param {() => Promise<T>} get_result\n * @returns {Promise<T>}\n */\nexport async function get_response(internals, arg, state, get_result) {\n\t// wait a beat, in case `myQuery().set(...)` or `myQuery().refresh()` is immediately called\n\t// eslint-disable-next-line @typescript-eslint/await-thenable\n\tawait 0;\n\n\tconst cache = get_cache(internals, state);\n\tconst key = stringify_remote_arg(arg, state.transport);\n\tconst entry = (cache[key] ??= {\n\t\tserialize: false,\n\t\tdata: get_result()\n\t});\n\n\tentry.serialize ||= !!state.is_in_universal_load;\n\n\tif (state.is_in_render && internals.id) {\n\t\tconst remote_key = create_remote_key(internals.id, key);\n\n\t\tPromise.resolve(entry.data)\n\t\t\t.then((value) => {\n\t\t\t\tvoid unfriendly_hydratable(remote_key, () => stringify(value, state.transport));\n\t\t\t})\n\t\t\t.catch(() => {});\n\t}\n\n\treturn entry.data;\n}\n\n/**\n * @param {any} data\n * @param {ServerHooks['transport']} transport\n */\nexport function parse_remote_response(data, transport) {\n\t/** @type {Record<string, any>} */\n\tconst revivers = {};\n\tfor (const key in transport) {\n\t\trevivers[key] = transport[key].decode;\n\t}\n\n\treturn parse(data, revivers);\n}\n\n/**\n * Like `with_event` but removes things from `event` you cannot see/call in remote functions, such as `setHeaders`.\n * @template T\n * @param {RequestEvent} event\n * @param {RequestState} state\n * @param {boolean} allow_cookies\n * @param {() => any} get_input\n * @param {(arg?: any) => T} fn\n */\nexport async function run_remote_function(event, state, allow_cookies, get_input, fn) {\n\t/** @type {RequestStore} */\n\tconst store = {\n\t\tevent: {\n\t\t\t...event,\n\t\t\tsetHeaders: () => {\n\t\t\t\tthrow new Error('setHeaders is not allowed in remote functions');\n\t\t\t},\n\t\t\tcookies: {\n\t\t\t\t...event.cookies,\n\t\t\t\tset: (name, value, opts) => {\n\t\t\t\t\tif (!allow_cookies) {\n\t\t\t\t\t\tthrow new Error('Cannot set cookies in `query` or `prerender` functions');\n\t\t\t\t\t}\n\n\t\t\t\t\tif (opts.path && !opts.path.startsWith('/')) {\n\t\t\t\t\t\tthrow new Error('Cookies set in remote functions must have an absolute path');\n\t\t\t\t\t}\n\n\t\t\t\t\treturn event.cookies.set(name, value, opts);\n\t\t\t\t},\n\t\t\t\tdelete: (name, opts) => {\n\t\t\t\t\tif (!allow_cookies) {\n\t\t\t\t\t\tthrow new Error('Cannot delete cookies in `query` or `prerender` functions');\n\t\t\t\t\t}\n\n\t\t\t\t\tif (opts.path && !opts.path.startsWith('/')) {\n\t\t\t\t\t\tthrow new Error('Cookies deleted in remote functions must have an absolute path');\n\t\t\t\t\t}\n\n\t\t\t\t\treturn event.cookies.delete(name, opts);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tstate: {\n\t\t\t...state,\n\t\t\tis_in_remote_function: true\n\t\t}\n\t};\n\n\t// In two parts, each with_event, so that runtimes without async local storage can still get the event at the start of the function\n\tconst input = await with_request_store(store, get_input);\n\treturn with_request_store(store, () => fn(input));\n}\n\n/**\n * @param {RemoteInternals} internals\n * @param {RequestState} state\n */\nexport function get_cache(internals, state = get_request_store().state) {\n\tlet cache = state.remote.data?.get(internals);\n\n\tif (cache === undefined) {\n\t\tcache = {};\n\t\t(state.remote.data ??= new Map()).set(internals, cache);\n\t}\n\n\treturn cache;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/app/state/client.js",
    "content": "import {\n\tpage as _page,\n\tnavigating as _navigating,\n\tupdated as _updated\n} from '../../client/state.svelte.js';\nimport { stores } from '../../client/client.js';\n\nexport const page = {\n\tget data() {\n\t\treturn _page.data;\n\t},\n\tget error() {\n\t\treturn _page.error;\n\t},\n\tget form() {\n\t\treturn _page.form;\n\t},\n\tget params() {\n\t\treturn _page.params;\n\t},\n\tget route() {\n\t\treturn _page.route;\n\t},\n\tget state() {\n\t\treturn _page.state;\n\t},\n\tget status() {\n\t\treturn _page.status;\n\t},\n\tget url() {\n\t\treturn _page.url;\n\t}\n};\n\nexport const navigating = {\n\tget from() {\n\t\treturn _navigating.current ? _navigating.current.from : null;\n\t},\n\tget to() {\n\t\treturn _navigating.current ? _navigating.current.to : null;\n\t},\n\tget type() {\n\t\treturn _navigating.current ? _navigating.current.type : null;\n\t},\n\tget willUnload() {\n\t\treturn _navigating.current ? _navigating.current.willUnload : null;\n\t},\n\tget delta() {\n\t\treturn _navigating.current ? _navigating.current.delta : null;\n\t},\n\tget complete() {\n\t\treturn _navigating.current ? _navigating.current.complete : null;\n\t}\n};\n\nObject.defineProperty(navigating, 'current', {\n\tget() {\n\t\t// between 2.12.0 and 2.12.1 `navigating.current` existed\n\t\tthrow new Error('Replace navigating.current.<prop> with navigating.<prop>');\n\t}\n});\n\nexport const updated = {\n\tget current() {\n\t\treturn _updated.current;\n\t},\n\tcheck: stores.updated.check\n};\n"
  },
  {
    "path": "packages/kit/src/runtime/app/state/index.js",
    "content": "import {\n\tpage as client_page,\n\tnavigating as client_navigating,\n\tupdated as client_updated\n} from './client.js';\nimport {\n\tpage as server_page,\n\tnavigating as server_navigating,\n\tupdated as server_updated\n} from './server.js';\nimport { BROWSER } from 'esm-env';\n\n/**\n * A read-only reactive object with information about the current page, serving several use cases:\n * - retrieving the combined `data` of all pages/layouts anywhere in your component tree (also see [loading data](https://svelte.dev/docs/kit/load))\n * - retrieving the current value of the `form` prop anywhere in your component tree (also see [form actions](https://svelte.dev/docs/kit/form-actions))\n * - retrieving the page state that was set through `goto`, `pushState` or `replaceState` (also see [goto](https://svelte.dev/docs/kit/$app-navigation#goto) and [shallow routing](https://svelte.dev/docs/kit/shallow-routing))\n * - retrieving metadata such as the URL you're on, the current route and its parameters, and whether or not there was an error\n *\n * ```svelte\n * <!--- file: +layout.svelte --->\n * <script>\n * \timport { page } from '$app/state';\n * </script>\n *\n * <p>Currently at {page.url.pathname}</p>\n *\n * {#if page.error}\n * \t<span class=\"red\">Problem detected</span>\n * {:else}\n * \t<span class=\"small\">All systems operational</span>\n * {/if}\n * ```\n *\n * Changes to `page` are available exclusively with runes. (The legacy reactivity syntax will not reflect any changes)\n *\n * ```svelte\n * <!--- file: +page.svelte --->\n * <script>\n * \timport { page } from '$app/state';\n * \tconst id = $derived(page.params.id); // This will correctly update id for usage on this page\n * \t$: badId = page.params.id; // Do not use; will never update after initial load\n * </script>\n * ```\n *\n * On the server, values can only be read during rendering (in other words _not_ in e.g. `load` functions). In the browser, the values can be read at any time.\n *\n * @type {import('@sveltejs/kit').Page}\n */\nexport const page = BROWSER ? client_page : server_page;\n\n/**\n * A read-only object representing an in-progress navigation, with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties.\n * Values are `null` when no navigation is occurring, or during server rendering.\n * @type {import('@sveltejs/kit').Navigation | { from: null, to: null, type: null, willUnload: null, delta: null, complete: null }}\n */\n// @ts-expect-error\nexport const navigating = BROWSER ? client_navigating : server_navigating;\n\n/**\n * A read-only reactive value that's initially `false`. If [`version.pollInterval`](https://svelte.dev/docs/kit/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update `current` to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.\n * @type {{ get current(): boolean; check(): Promise<boolean>; }}\n */\nexport const updated = BROWSER ? client_updated : server_updated;\n"
  },
  {
    "path": "packages/kit/src/runtime/app/state/server.js",
    "content": "import { DEV } from 'esm-env';\nimport { getContext } from 'svelte';\n\nfunction context() {\n\treturn getContext('__request__');\n}\n\n/** @param {string} name */\nfunction context_dev(name) {\n\ttry {\n\t\treturn context();\n\t} catch {\n\t\tthrow new Error(\n\t\t\t`Can only read '${name}' on the server during rendering (not in e.g. \\`load\\` functions), as it is bound to the current request via component context. This prevents state from leaking between users. ` +\n\t\t\t\t'For more information, see https://svelte.dev/docs/kit/state-management#avoid-shared-state-on-the-server'\n\t\t);\n\t}\n}\n\nexport const page = {\n\tget data() {\n\t\treturn (DEV ? context_dev('page.data') : context()).page.data;\n\t},\n\tget error() {\n\t\treturn (DEV ? context_dev('page.error') : context()).page.error;\n\t},\n\tget form() {\n\t\treturn (DEV ? context_dev('page.form') : context()).page.form;\n\t},\n\tget params() {\n\t\treturn (DEV ? context_dev('page.params') : context()).page.params;\n\t},\n\tget route() {\n\t\treturn (DEV ? context_dev('page.route') : context()).page.route;\n\t},\n\tget state() {\n\t\treturn (DEV ? context_dev('page.state') : context()).page.state;\n\t},\n\tget status() {\n\t\treturn (DEV ? context_dev('page.status') : context()).page.status;\n\t},\n\tget url() {\n\t\treturn (DEV ? context_dev('page.url') : context()).page.url;\n\t}\n};\n\nexport const navigating = {\n\tfrom: null,\n\tto: null,\n\ttype: null,\n\twillUnload: null,\n\tdelta: null,\n\tcomplete: null\n};\n\nexport const updated = {\n\tget current() {\n\t\treturn false;\n\t},\n\tcheck: () => {\n\t\tthrow new Error('Can only call updated.check() in the browser');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/src/runtime/app/stores.js",
    "content": "import { getContext } from 'svelte';\nimport { BROWSER, DEV } from 'esm-env';\nimport { stores as browser_stores } from '../client/client.js';\n\n/**\n * A function that returns all of the contextual stores. On the server, this must be called during component initialization.\n * Only use this if you need to defer store subscription until after the component has mounted, for some reason.\n *\n * @deprecated Use `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))\n */\nexport const getStores = () => {\n\tconst stores = BROWSER ? browser_stores : getContext('__svelte__');\n\n\treturn {\n\t\t/** @type {typeof page} */\n\t\tpage: {\n\t\t\tsubscribe: stores.page.subscribe\n\t\t},\n\t\t/** @type {typeof navigating} */\n\t\tnavigating: {\n\t\t\tsubscribe: stores.navigating.subscribe\n\t\t},\n\t\t/** @type {typeof updated} */\n\t\tupdated: stores.updated\n\t};\n};\n\n/**\n * A readable store whose value contains page data.\n *\n * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.\n *\n * @deprecated Use `page` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))\n * @type {import('svelte/store').Readable<import('@sveltejs/kit').Page>}\n */\nexport const page = {\n\tsubscribe(fn) {\n\t\tconst store = DEV ? get_store('page') : getStores().page;\n\t\treturn store.subscribe(fn);\n\t}\n};\n\n/**\n * A readable store.\n * When navigating starts, its value is a `Navigation` object with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties.\n * When navigating finishes, its value reverts to `null`.\n *\n * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.\n *\n * @deprecated Use `navigating` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))\n * @type {import('svelte/store').Readable<import('@sveltejs/kit').Navigation | null>}\n */\nexport const navigating = {\n\tsubscribe(fn) {\n\t\tconst store = DEV ? get_store('navigating') : getStores().navigating;\n\t\treturn store.subscribe(fn);\n\t}\n};\n\n/**\n * A readable store whose initial value is `false`. If [`version.pollInterval`](https://svelte.dev/docs/kit/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.\n *\n * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.\n *\n * @deprecated Use `updated` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))\n * @type {import('svelte/store').Readable<boolean> & { check(): Promise<boolean> }}\n */\nexport const updated = {\n\tsubscribe(fn) {\n\t\tconst store = DEV ? get_store('updated') : getStores().updated;\n\n\t\tif (BROWSER) {\n\t\t\tupdated.check = store.check;\n\t\t}\n\n\t\treturn store.subscribe(fn);\n\t},\n\tcheck: () => {\n\t\tthrow new Error(\n\t\t\tBROWSER\n\t\t\t\t? 'Cannot check updated store before subscribing'\n\t\t\t\t: 'Can only check updated store in browser'\n\t\t);\n\t}\n};\n\n/**\n * @template {keyof ReturnType<typeof getStores>} Name\n * @param {Name} name\n * @returns {ReturnType<typeof getStores>[Name]}\n */\nfunction get_store(name) {\n\ttry {\n\t\treturn getStores()[name];\n\t} catch {\n\t\tthrow new Error(\n\t\t\t`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.` +\n\t\t\t\t'For more information, see https://svelte.dev/docs/kit/state-management#avoid-shared-state-on-the-server'\n\t\t);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/bundle.js",
    "content": "/* if `bundleStrategy` is 'single' or 'inline', this file is used as the entry point */\n\nimport * as kit from './entry.js';\n\n// @ts-expect-error\nimport * as app from '__sveltekit/manifest';\n\n/**\n *\n * @param {HTMLElement} element\n * @param {import('./types.js').HydrateOptions} options\n */\nexport function start(element, options) {\n\tvoid kit.start(app, element, options);\n}\n\nexport { app };\n"
  },
  {
    "path": "packages/kit/src/runtime/client/client.js",
    "content": "/** @import { RemoteQueryCacheEntry } from './remote-functions/query.svelte.js' */\nimport { BROWSER, DEV } from 'esm-env';\nimport * as svelte from 'svelte';\nimport { HttpError, Redirect, SvelteKitError } from '@sveltejs/kit/internal';\nconst { onMount, tick } = svelte;\n// Svelte 4 and under don't have `untrack`, so we have to fallback if `untrack` is not exported\nconst untrack = svelte.untrack ?? ((value) => value());\nimport {\n\tdecode_params,\n\tdecode_pathname,\n\tstrip_hash,\n\tmake_trackable,\n\tnormalize_path\n} from '../../utils/url.js';\nimport { dev_fetch, initial_fetch, lock_fetch, subsequent_fetch, unlock_fetch } from './fetcher.js';\nimport { parse, parse_server_route } from './parse.js';\nimport * as storage from './session-storage.js';\nimport {\n\tfind_anchor,\n\tresolve_url,\n\tget_link_info,\n\tget_router_options,\n\tis_external_url,\n\torigin,\n\tscroll_state,\n\tnotifiable_store,\n\tcreate_updated_store,\n\tload_css\n} from './utils.js';\nimport { base } from '$app/paths';\nimport * as devalue from 'devalue';\nimport {\n\tHISTORY_INDEX,\n\tNAVIGATION_INDEX,\n\tPRELOAD_PRIORITIES,\n\tSCROLL_KEY,\n\tSTATES_KEY,\n\tSNAPSHOT_KEY,\n\tPAGE_URL_KEY\n} from './constants.js';\nimport { validate_page_exports } from '../../utils/exports.js';\nimport { compact } from '../../utils/array.js';\nimport {\n\tINVALIDATED_PARAM,\n\tTRAILING_SLASH_PARAM,\n\tvalidate_depends,\n\tvalidate_load_response\n} from '../shared.js';\nimport { get_message, get_status } from '../../utils/error.js';\nimport { writable } from 'svelte/store';\nimport { page, update, navigating } from './state.svelte.js';\nimport { add_data_suffix, add_resolution_suffix } from '../pathname.js';\nimport { noop_span } from '../telemetry/noop.js';\nimport { text_decoder } from '../utils.js';\n\nexport { load_css };\nconst ICON_REL_ATTRIBUTES = new Set(['icon', 'shortcut icon', 'apple-touch-icon']);\n\nlet errored = false;\n/**\n * Set via transformError, reset and read at the end of navigate.\n * Necessary because a navigation might succeed loading but during rendering\n * an error occurs, at which point the navigation result needs to be overridden with the error result.\n * TODO this is all very hacky, rethink for SvelteKit 3 where we can assume Svelte 5 and do an overhaul of client.js\n * @type {{ error: App.Error, status: number } | null}\n */\nlet rendering_error = null;\n\n// We track the scroll position associated with each history entry in sessionStorage,\n// rather than on history.state itself, because when navigation is driven by\n// popstate it's too late to update the scroll position associated with the\n// state we're navigating from\n/**\n * history index -> { x, y }\n * @type {Record<number, { x: number; y: number }>}\n */\nconst scroll_positions = storage.get(SCROLL_KEY) ?? {};\n\n/**\n * navigation index -> any\n * @type {Record<string, any[]>}\n */\nconst snapshots = storage.get(SNAPSHOT_KEY) ?? {};\n\nif (DEV && BROWSER) {\n\tlet warned = false;\n\n\tconst current_module_url = import.meta.url.split('?')[0]; // remove query params that vite adds to the URL when it is loaded from node_modules\n\n\tconst warn = () => {\n\t\tif (warned) return;\n\n\t\t// Rather than saving a pointer to the original history methods, which would prevent monkeypatching by other libs,\n\t\t// inspect the stack trace to see if we're being called from within SvelteKit.\n\t\tlet stack = new Error().stack?.split('\\n');\n\t\tif (!stack) return;\n\t\tif (!stack[0].includes('https:') && !stack[0].includes('http:')) stack = stack.slice(1); // Chrome includes the error message in the stack\n\t\tstack = stack.slice(2); // remove `warn` and the place where `warn` was called\n\t\t// Can be falsy if was called directly from an anonymous function\n\t\tif (stack[0]?.includes(current_module_url)) return;\n\n\t\twarned = true;\n\n\t\tconsole.warn(\n\t\t\t\"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.\"\n\t\t);\n\t};\n\n\tconst push_state = history.pushState;\n\thistory.pushState = (...args) => {\n\t\twarn();\n\t\treturn push_state.apply(history, args);\n\t};\n\n\tconst replace_state = history.replaceState;\n\thistory.replaceState = (...args) => {\n\t\twarn();\n\t\treturn replace_state.apply(history, args);\n\t};\n}\n\nexport const stores = {\n\turl: /* @__PURE__ */ notifiable_store({}),\n\tpage: /* @__PURE__ */ notifiable_store({}),\n\tnavigating: /* @__PURE__ */ writable(\n\t\t/** @type {import('@sveltejs/kit').Navigation | null} */ (null)\n\t),\n\tupdated: /* @__PURE__ */ create_updated_store()\n};\n\n/** @param {number} index */\nfunction update_scroll_positions(index) {\n\tscroll_positions[index] = scroll_state();\n}\n\n/**\n * @param {number} current_history_index\n * @param {number} current_navigation_index\n */\nfunction clear_onward_history(current_history_index, current_navigation_index) {\n\t// if we navigated back, then pushed a new state, we can\n\t// release memory by pruning the scroll/snapshot lookup\n\tlet i = current_history_index + 1;\n\twhile (scroll_positions[i]) {\n\t\tdelete scroll_positions[i];\n\t\ti += 1;\n\t}\n\n\ti = current_navigation_index + 1;\n\twhile (snapshots[i]) {\n\t\tdelete snapshots[i];\n\t\ti += 1;\n\t}\n}\n\n/**\n * Loads `href` the old-fashioned way, with a full page reload.\n * Returns a `Promise` that never resolves (to prevent any\n * subsequent work, e.g. history manipulation, from happening)\n * @param {URL} url\n * @param {boolean} [replace] If `true`, will replace the current `history` entry rather than creating a new one with `pushState`\n */\nfunction native_navigation(url, replace = false) {\n\tif (replace) {\n\t\tlocation.replace(url.href);\n\t} else {\n\t\tlocation.href = url.href;\n\t}\n\treturn new Promise(() => {});\n}\n\n/**\n * Checks whether a service worker is registered, and if it is,\n * tries to update it.\n */\nasync function update_service_worker() {\n\tif ('serviceWorker' in navigator) {\n\t\tconst registration = await navigator.serviceWorker.getRegistration(base || '/');\n\t\tif (registration) {\n\t\t\tawait registration.update();\n\t\t}\n\t}\n}\n\nfunction noop() {}\n\n/** @type {import('types').CSRRoute[]} All routes of the app. Only available when kit.router.resolution=client */\nlet routes;\n/** @type {import('types').CSRPageNodeLoader} */\nlet default_layout_loader;\n/** @type {import('types').CSRPageNodeLoader} */\nlet default_error_loader;\n/** @type {HTMLElement} */\nlet container;\n/** @type {HTMLElement} */\nlet target;\n\n/** @type {import('./types.js').SvelteKitApp} */\nexport let app;\n\n/**\n * Data that was serialized during SSR for queries/forms/commands.\n * This is cleared before client-side loads run.\n * @type {Record<string, any>}\n */\nexport let query_responses = {};\n\n/**\n * Data that was serialized during SSR for prerender functions.\n * This persists across client-side navigations.\n * @type {Record<string, any>}\n */\nexport let prerender_responses = {};\n\n/** @type {Array<((url: URL) => boolean)>} */\nconst invalidated = [];\n\n/**\n * An array of the `+layout.svelte` and `+page.svelte` component instances\n * that currently live on the page — used for capturing and restoring snapshots.\n * It's updated/manipulated through `bind:this` in `Root.svelte`.\n * @type {import('svelte').SvelteComponent[]}\n */\nconst components = [];\n\n/** @type {{id: string, token: {}, promise: Promise<import('./types.js').NavigationResult>, fork: Promise<import('svelte').Fork | null> | null} | null} */\nlet load_cache = null;\n\nfunction discard_load_cache() {\n\tvoid load_cache?.fork?.then((f) => f?.discard());\n\tload_cache = null;\n}\n\n/**\n * @type {Map<string, Promise<URL>>}\n * Cache for client-side rerouting, since it could contain async calls which we want to\n * avoid running multiple times which would slow down navigations (e.g. else preloading\n * wouldn't help because on navigation it would be called again). Since `reroute` should be\n * a pure function (i.e. always return the same) value it's safe to cache across navigations.\n * The server reroute calls don't need to be cached because they are called using `import(...)`\n * which is cached per the JS spec.\n */\nconst reroute_cache = new Map();\n\n/**\n * Note on before_navigate_callbacks, on_navigate_callbacks and after_navigate_callbacks:\n * do not re-assign as some closures keep references to these Sets\n */\n/** @type {Set<(navigation: import('@sveltejs/kit').BeforeNavigate) => void>} */\nconst before_navigate_callbacks = new Set();\n\n/** @type {Set<(navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>>} */\nconst on_navigate_callbacks = new Set();\n\n/** @type {Set<(navigation: import('@sveltejs/kit').AfterNavigate) => void>} */\nconst after_navigate_callbacks = new Set();\n\n/** @type {import('./types.js').NavigationState & { nav: import('@sveltejs/kit').NavigationEvent }} */\nlet current = {\n\tbranch: [],\n\terror: null,\n\t// @ts-ignore - we need the initial value to be null\n\turl: null,\n\t// @ts-ignore - we need the initial value to be null\n\tnav: null\n};\n\n/** this being true means we SSR'd */\nlet hydrated = false;\nlet started = false;\nlet autoscroll = true;\nlet updating = false;\nlet is_navigating = false;\nlet hash_navigating = false;\n/** True as soon as there happened one client-side navigation (excluding the SvelteKit-initialized initial one when in SPA mode) */\nlet has_navigated = false;\n\nlet force_invalidation = false;\n\n/** @type {import('svelte').SvelteComponent} */\nlet root;\n\n/** @type {number} keeping track of the history index in order to prevent popstate navigation events if needed */\nlet current_history_index;\n\n/** @type {number} */\nlet current_navigation_index;\n\n/** @type {{}} */\nlet token;\n\n/**\n * A set of tokens which are associated to current preloads.\n * If a preload becomes a real navigation, it's removed from the set.\n * If a preload token is in the set and the preload errors, the error\n * handling logic (for example reloading) is skipped.\n */\nconst preload_tokens = new Set();\n\n/** @type {Promise<void> | null} */\nexport let pending_invalidate;\n\n/**\n * @type {Map<string, RemoteQueryCacheEntry<any>>}\n * A map of id -> query internals with all queries that currently exist in the app.\n */\nexport const query_map = new Map();\n\n/**\n * @param {import('./types.js').SvelteKitApp} _app\n * @param {HTMLElement} _target\n * @param {Parameters<typeof _hydrate>[1]} [hydrate]\n */\nexport async function start(_app, _target, hydrate) {\n\tif (DEV && _target === document.body) {\n\t\tconsole.warn(\n\t\t\t'Placing %sveltekit.body% directly inside <body> 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<div style=\"display: contents\">\\n  %sveltekit.body%\\n</div>'\n\t\t);\n\t}\n\n\tif (__SVELTEKIT_PAYLOAD__) {\n\t\tquery_responses = __SVELTEKIT_PAYLOAD__.query ?? {};\n\t\tprerender_responses = __SVELTEKIT_PAYLOAD__.prerender ?? {};\n\t}\n\n\t// detect basic auth credentials in the current URL\n\t// https://github.com/sveltejs/kit/pull/11179\n\t// if so, refresh the page without credentials\n\tif (document.URL !== location.href) {\n\t\t// eslint-disable-next-line no-self-assign\n\t\tlocation.href = location.href;\n\t}\n\n\tapp = _app;\n\n\tawait _app.hooks.init?.();\n\n\troutes = __SVELTEKIT_CLIENT_ROUTING__ ? parse(_app) : [];\n\tcontainer = __SVELTEKIT_EMBEDDED__ ? _target : document.documentElement;\n\ttarget = _target;\n\n\t// we import the root layout/error nodes eagerly, so that\n\t// connectivity errors after initialisation don't nuke the app\n\tdefault_layout_loader = _app.nodes[0];\n\tdefault_error_loader = _app.nodes[1];\n\tvoid default_layout_loader();\n\tvoid default_error_loader();\n\n\tcurrent_history_index = history.state?.[HISTORY_INDEX];\n\tcurrent_navigation_index = history.state?.[NAVIGATION_INDEX];\n\n\tif (!current_history_index) {\n\t\t// we use Date.now() as an offset so that cross-document navigations\n\t\t// within the app don't result in data loss\n\t\tcurrent_history_index = current_navigation_index = Date.now();\n\n\t\t// create initial history entry, so we can return here\n\t\thistory.replaceState(\n\t\t\t{\n\t\t\t\t...history.state,\n\t\t\t\t[HISTORY_INDEX]: current_history_index,\n\t\t\t\t[NAVIGATION_INDEX]: current_navigation_index\n\t\t\t},\n\t\t\t''\n\t\t);\n\t}\n\n\t// if we reload the page, or Cmd-Shift-T back to it,\n\t// recover scroll position\n\tconst scroll = scroll_positions[current_history_index];\n\tfunction restore_scroll() {\n\t\tif (scroll) {\n\t\t\thistory.scrollRestoration = 'manual';\n\t\t\tscrollTo(scroll.x, scroll.y);\n\t\t}\n\t}\n\n\tif (hydrate) {\n\t\trestore_scroll();\n\n\t\tawait _hydrate(target, hydrate);\n\t} else {\n\t\tawait navigate({\n\t\t\ttype: 'enter',\n\t\t\turl: resolve_url(app.hash ? decode_hash(new URL(location.href)) : location.href),\n\t\t\treplace_state: true\n\t\t});\n\n\t\trestore_scroll();\n\t}\n\n\t_start_router();\n}\n\nasync function _invalidate(include_load_functions = true, reset_page_state = true) {\n\t// Accept all invalidations as they come, don't swallow any while another invalidation\n\t// is running because subsequent invalidations may make earlier ones outdated,\n\t// but batch multiple synchronous invalidations.\n\tawait (pending_invalidate ||= Promise.resolve());\n\tif (!pending_invalidate) return;\n\tpending_invalidate = null;\n\n\tconst nav_token = (token = {});\n\tconst intent = await get_navigation_intent(current.url, true);\n\n\t// Clear preload, it might be affected by the invalidation.\n\t// Also solves an edge case where a preload is triggered, the navigation for it\n\t// was then triggered and is still running while the invalidation kicks in,\n\t// at which point the invalidation should take over and \"win\".\n\tdiscard_load_cache();\n\n\t// Rerun queries\n\tif (force_invalidation) {\n\t\tquery_map.forEach(({ resource }) => {\n\t\t\tvoid resource.refresh?.();\n\t\t});\n\t}\n\n\tif (include_load_functions) {\n\t\tconst prev_state = page.state;\n\t\tconst navigation_result = intent && (await load_route(intent));\n\t\tif (!navigation_result || nav_token !== token) return;\n\n\t\tif (navigation_result.type === 'redirect') {\n\t\t\treturn _goto(\n\t\t\t\tnew URL(navigation_result.location, current.url).href,\n\t\t\t\t{ replaceState: true },\n\t\t\t\t1,\n\t\t\t\tnav_token\n\t\t\t);\n\t\t}\n\n\t\t// This is a bit hacky but allows us not having to pass that boolean around, making things harder to reason about\n\t\tif (!reset_page_state) {\n\t\t\tnavigation_result.props.page.state = prev_state;\n\t\t}\n\t\tupdate(navigation_result.props.page);\n\t\tcurrent = { ...navigation_result.state, nav: current.nav };\n\t\treset_invalidation();\n\t\troot.$set(navigation_result.props);\n\t} else {\n\t\treset_invalidation();\n\t}\n\n\t// Don't use allSettled yet because it's too new\n\tawait Promise.all([...query_map.values()].map(({ resource }) => resource)).catch(noop);\n}\n\nfunction reset_invalidation() {\n\tinvalidated.length = 0;\n\tforce_invalidation = false;\n}\n\n/** @param {number} index */\nfunction capture_snapshot(index) {\n\tif (components.some((c) => c?.snapshot)) {\n\t\tsnapshots[index] = components.map((c) => c?.snapshot?.capture());\n\t}\n}\n\n/** @param {number} index */\nfunction restore_snapshot(index) {\n\tsnapshots[index]?.forEach((value, i) => {\n\t\tcomponents[i]?.snapshot?.restore(value);\n\t});\n}\n\nfunction persist_state() {\n\tupdate_scroll_positions(current_history_index);\n\tstorage.set(SCROLL_KEY, scroll_positions);\n\n\tcapture_snapshot(current_navigation_index);\n\tstorage.set(SNAPSHOT_KEY, snapshots);\n}\n\n/**\n * @param {string | URL} url\n * @param {{ replaceState?: boolean; noScroll?: boolean; keepFocus?: boolean; invalidateAll?: boolean; invalidate?: Array<string | URL | ((url: URL) => boolean)>; state?: Record<string, any> }} options\n * @param {number} redirect_count\n * @param {{}} [nav_token]\n */\nexport async function _goto(url, options, redirect_count, nav_token) {\n\t/** @type {string[]} */\n\tlet query_keys;\n\n\t// Clear preload cache when invalidateAll is true to ensure fresh data\n\t// after form submissions or explicit invalidations\n\tif (options.invalidateAll) {\n\t\tdiscard_load_cache();\n\t}\n\n\tawait navigate({\n\t\ttype: 'goto',\n\t\turl: resolve_url(url),\n\t\tkeepfocus: options.keepFocus,\n\t\tnoscroll: options.noScroll,\n\t\treplace_state: options.replaceState,\n\t\tstate: options.state,\n\t\tredirect_count,\n\t\tnav_token,\n\t\taccept: () => {\n\t\t\tif (options.invalidateAll) {\n\t\t\t\tforce_invalidation = true;\n\t\t\t\tquery_keys = [...query_map.keys()];\n\t\t\t}\n\n\t\t\tif (options.invalidate) {\n\t\t\t\toptions.invalidate.forEach(push_invalidated);\n\t\t\t}\n\t\t}\n\t});\n\n\tif (options.invalidateAll) {\n\t\t// TODO the ticks shouldn't be necessary, something inside Svelte itself is buggy\n\t\t// when a query in a layout that still exists after page change is refreshed earlier than this\n\t\tvoid svelte\n\t\t\t.tick()\n\t\t\t.then(svelte.tick)\n\t\t\t.then(() => {\n\t\t\t\tquery_map.forEach(({ resource }, key) => {\n\t\t\t\t\t// Only refresh those that already existed on the old page\n\t\t\t\t\tif (query_keys?.includes(key)) {\n\t\t\t\t\t\tvoid resource.refresh?.();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t}\n}\n\n/** @param {import('./types.js').NavigationIntent} intent */\nasync function _preload_data(intent) {\n\t// Reuse the existing pending preload if it's for the same navigation.\n\t// Prevents an edge case where same preload is triggered multiple times,\n\t// then a later one is becoming the real navigation and the preload tokens\n\t// get out of sync.\n\tif (intent.id !== load_cache?.id) {\n\t\tdiscard_load_cache();\n\n\t\tconst preload = {};\n\t\tpreload_tokens.add(preload);\n\t\tload_cache = {\n\t\t\tid: intent.id,\n\t\t\ttoken: preload,\n\t\t\tpromise: load_route({ ...intent, preload }).then((result) => {\n\t\t\t\tpreload_tokens.delete(preload);\n\t\t\t\tif (result.type === 'loaded' && result.state.error) {\n\t\t\t\t\t// Don't cache errors, because they might be transient\n\t\t\t\t\tdiscard_load_cache();\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}),\n\t\t\tfork: null\n\t\t};\n\n\t\tif (__SVELTEKIT_FORK_PRELOADS__ && svelte.fork) {\n\t\t\tconst lc = load_cache;\n\n\t\t\tlc.fork = lc.promise.then((result) => {\n\t\t\t\t// if load_cache was discarded before load_cache.promise could\n\t\t\t\t// resolve, bail rather than creating an orphan fork\n\t\t\t\tif (lc === load_cache && result.type === 'loaded') {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn svelte.fork(() => {\n\t\t\t\t\t\t\troot.$set(result.props);\n\t\t\t\t\t\t\tupdate(result.props.page);\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// if it errors, it's because the experimental flag isn't enabled in Svelte\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t});\n\t\t}\n\t}\n\n\treturn load_cache.promise;\n}\n\n/**\n * @param {URL} url\n * @returns {Promise<void>}\n */\nasync function _preload_code(url) {\n\tconst route = (await get_navigation_intent(url, false))?.route;\n\n\tif (route) {\n\t\tawait Promise.all(\n\t\t\t/** @type {[has_server_load: boolean, node_loader: import('types').CSRPageNodeLoader][]} */ (\n\t\t\t\t[...route.layouts, route.leaf].filter(Boolean)\n\t\t\t).map((load) => load[1]())\n\t\t);\n\t}\n}\n\n/**\n * @param {import('./types.js').NavigationFinished} result\n * @param {HTMLElement} target\n * @param {boolean} hydrate\n */\nasync function initialize(result, target, hydrate) {\n\tif (DEV && result.state.error && document.querySelector('vite-error-overlay')) return;\n\n\t/** @type {import('@sveltejs/kit').NavigationEvent} */\n\tconst nav = {\n\t\tparams: current.params,\n\t\troute: { id: current.route?.id ?? null },\n\t\turl: new URL(location.href)\n\t};\n\n\tcurrent = {\n\t\t...result.state,\n\t\tnav\n\t};\n\n\tconst style = document.querySelector('style[data-sveltekit]');\n\tif (style) style.remove();\n\n\tObject.assign(page, /** @type {import('@sveltejs/kit').Page} */ (result.props.page));\n\n\troot = new app.root({\n\t\ttarget,\n\t\tprops: { ...result.props, stores, components },\n\t\thydrate,\n\t\t// @ts-ignore Svelte 5 specific: asynchronously instantiate the component, i.e. don't call flushSync\n\t\tsync: false,\n\t\t// @ts-ignore Svelte 5 specific: transformError allows to transform errors before they are passed to boundaries\n\t\ttransformError: __SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__\n\t\t\t? /** @param {unknown} e */ async (e) => {\n\t\t\t\t\tconst error = await handle_error(e, current.nav);\n\t\t\t\t\trendering_error = { error, status: get_status(e) };\n\t\t\t\t\tpage.error = error;\n\t\t\t\t\tpage.status = rendering_error.status;\n\t\t\t\t\treturn error;\n\t\t\t\t}\n\t\t\t: undefined\n\t});\n\n\t// Wait for a microtask in case svelte experimental async is enabled,\n\t// which causes component script blocks to run asynchronously\n\tvoid (await Promise.resolve());\n\n\trestore_snapshot(current_navigation_index);\n\n\tif (hydrate) {\n\t\t/** @type {import('@sveltejs/kit').AfterNavigate} */\n\t\tconst navigation = {\n\t\t\tfrom: null,\n\t\t\tto: {\n\t\t\t\t...nav,\n\t\t\t\tscroll: scroll_positions[current_history_index] ?? scroll_state()\n\t\t\t},\n\t\t\twillUnload: false,\n\t\t\ttype: 'enter',\n\t\t\tcomplete: Promise.resolve()\n\t\t};\n\n\t\tafter_navigate_callbacks.forEach((fn) => fn(navigation));\n\t}\n\n\tstarted = true;\n}\n\n/**\n *\n * @param {{\n *   url: URL;\n *   params: Record<string, string>;\n *   branch: Array<import('./types.js').BranchNode | undefined>;\n *   errors?: Array<import('types').CSRPageNodeLoader | undefined>;\n *   status: number;\n *   error: App.Error | null;\n *   route: import('types').CSRRoute | null;\n *   form?: Record<string, any> | null;\n * }} opts\n */\nasync function get_navigation_result_from_branch({\n\turl,\n\tparams,\n\tbranch,\n\terrors,\n\tstatus,\n\terror,\n\troute,\n\tform\n}) {\n\t/** @type {import('types').TrailingSlash} */\n\tlet slash = 'never';\n\n\t// if `paths.base === '/a/b/c`, then the root route is always `/a/b/c/`, regardless of\n\t// the `trailingSlash` route option, so that relative paths to JS and CSS work\n\tif (base && (url.pathname === base || url.pathname === base + '/')) {\n\t\tslash = 'always';\n\t} else {\n\t\tfor (const node of branch) {\n\t\t\tif (node?.slash !== undefined) slash = node.slash;\n\t\t}\n\t}\n\n\turl.pathname = normalize_path(url.pathname, slash);\n\t// eslint-disable-next-line no-self-assign\n\turl.search = url.search; // turn `/?` into `/`\n\n\t/** @type {import('./types.js').NavigationFinished} */\n\tconst result = {\n\t\ttype: 'loaded',\n\t\tstate: {\n\t\t\turl,\n\t\t\tparams,\n\t\t\tbranch,\n\t\t\terror,\n\t\t\troute\n\t\t},\n\t\tprops: {\n\t\t\t// @ts-ignore Somehow it's getting SvelteComponent and SvelteComponentDev mixed up\n\t\t\tconstructors: compact(branch).map((branch_node) => branch_node.node.component),\n\t\t\tpage: clone_page(page)\n\t\t}\n\t};\n\n\tif (errors && __SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__) {\n\t\tlet last_idx = -1;\n\t\tresult.props.errors = await Promise.all(\n\t\t\t// eslint-disable-next-line @typescript-eslint/await-thenable\n\t\t\tbranch\n\t\t\t\t.map((b, i) => {\n\t\t\t\t\tif (i === 0) return undefined; // root layout wraps root error component, not the other way around\n\t\t\t\t\tif (!b) return null;\n\n\t\t\t\t\ti--;\n\t\t\t\t\t// Find the closest error component up to the previous branch\n\t\t\t\t\twhile (i > last_idx + 1 && !errors[i]) i -= 1;\n\t\t\t\t\tlast_idx = i;\n\t\t\t\t\treturn errors[i]?.()\n\t\t\t\t\t\t.then((e) => e.component)\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t})\n\t\t\t\t// filter out indexes where there was no branch, but keep indexes where there was a branch but no error component\n\t\t\t\t.filter((e) => e !== null)\n\t\t);\n\t}\n\n\tif (error && __SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__) {\n\t\tresult.props.error = error;\n\t}\n\n\tif (form !== undefined) {\n\t\tresult.props.form = form;\n\t}\n\n\tlet data = {};\n\tlet data_changed = !page;\n\n\tlet p = 0;\n\n\tfor (let i = 0; i < Math.max(branch.length, current.branch.length); i += 1) {\n\t\tconst node = branch[i];\n\t\tconst prev = current.branch[i];\n\n\t\tif (node?.data !== prev?.data) data_changed = true;\n\t\tif (!node) continue;\n\n\t\tdata = { ...data, ...node.data };\n\n\t\t// Only set props if the node actually updated. This prevents needless rerenders.\n\t\tif (data_changed) {\n\t\t\tresult.props[`data_${p}`] = data;\n\t\t}\n\n\t\tp += 1;\n\t}\n\n\tconst page_changed =\n\t\t!current.url ||\n\t\turl.href !== current.url.href ||\n\t\tcurrent.error !== error ||\n\t\t(form !== undefined && form !== page.form) ||\n\t\tdata_changed;\n\n\tif (page_changed) {\n\t\tresult.props.page = {\n\t\t\terror,\n\t\t\tparams,\n\t\t\troute: {\n\t\t\t\tid: route?.id ?? null\n\t\t\t},\n\t\t\tstate: {},\n\t\t\tstatus,\n\t\t\turl: new URL(url),\n\t\t\tform: form ?? null,\n\t\t\t// The whole page store is updated, but this way the object reference stays the same\n\t\t\tdata: data_changed ? data : page.data\n\t\t};\n\t}\n\n\treturn result;\n}\n\n/**\n * Call the universal load function of the given node, if it exists.\n *\n * @param {{\n *   loader: import('types').CSRPageNodeLoader;\n * \t parent: () => Promise<Record<string, any>>;\n *   url: URL;\n *   params: Record<string, string>;\n *   route: { id: string | null };\n * \t server_data_node: import('./types.js').DataNode | null;\n * }} options\n * @returns {Promise<import('./types.js').BranchNode>}\n */\nasync function load_node({ loader, parent, url, params, route, server_data_node }) {\n\t/** @type {Record<string, any> | null} */\n\tlet data = null;\n\n\tlet is_tracking = true;\n\n\t/** @type {import('types').Uses} */\n\tconst uses = {\n\t\tdependencies: new Set(),\n\t\tparams: new Set(),\n\t\tparent: false,\n\t\troute: false,\n\t\turl: false,\n\t\tsearch_params: new Set()\n\t};\n\n\tconst node = await loader();\n\n\tif (DEV) {\n\t\tvalidate_page_exports(node.universal);\n\n\t\tif (node.universal && app.hash) {\n\t\t\tconst options = Object.keys(node.universal).filter((o) => o !== 'load');\n\n\t\t\tif (options.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Page options are ignored when \\`router.type === 'hash'\\` (${route.id} has ${options\n\t\t\t\t\t\t.filter((o) => o !== 'load')\n\t\t\t\t\t\t.map((o) => `'${o}'`)\n\t\t\t\t\t\t.join(', ')})`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (__SVELTEKIT_HAS_UNIVERSAL_LOAD__ && node.universal?.load) {\n\t\t/** @param {string[]} deps */\n\t\tfunction depends(...deps) {\n\t\t\tfor (const dep of deps) {\n\t\t\t\tif (DEV) validate_depends(/** @type {string} */ (route.id), dep);\n\n\t\t\t\tconst { href } = new URL(dep, url);\n\t\t\t\tuses.dependencies.add(href);\n\t\t\t}\n\t\t}\n\n\t\t/** @type {import('@sveltejs/kit').LoadEvent} */\n\t\tconst load_input = {\n\t\t\ttracing: { enabled: false, root: noop_span, current: noop_span },\n\t\t\troute: new Proxy(route, {\n\t\t\t\tget: (target, key) => {\n\t\t\t\t\tif (is_tracking) {\n\t\t\t\t\t\tuses.route = true;\n\t\t\t\t\t}\n\t\t\t\t\treturn target[/** @type {'id'} */ (key)];\n\t\t\t\t}\n\t\t\t}),\n\t\t\tparams: new Proxy(params, {\n\t\t\t\tget: (target, key) => {\n\t\t\t\t\tif (is_tracking) {\n\t\t\t\t\t\tuses.params.add(/** @type {string} */ (key));\n\t\t\t\t\t}\n\t\t\t\t\treturn target[/** @type {string} */ (key)];\n\t\t\t\t}\n\t\t\t}),\n\t\t\tdata: server_data_node?.data ?? null,\n\t\t\turl: make_trackable(\n\t\t\t\turl,\n\t\t\t\t() => {\n\t\t\t\t\tif (is_tracking) {\n\t\t\t\t\t\tuses.url = true;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t(param) => {\n\t\t\t\t\tif (is_tracking) {\n\t\t\t\t\t\tuses.search_params.add(param);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tapp.hash\n\t\t\t),\n\t\t\tasync fetch(resource, init) {\n\t\t\t\tif (resource instanceof Request) {\n\t\t\t\t\t// we're not allowed to modify the received `Request` object, so in order\n\t\t\t\t\t// to fixup relative urls we create a new equivalent `init` object instead\n\t\t\t\t\tinit = {\n\t\t\t\t\t\t// the request body must be consumed in memory until browsers\n\t\t\t\t\t\t// implement streaming request bodies and/or the body getter\n\t\t\t\t\t\tbody:\n\t\t\t\t\t\t\tresource.method === 'GET' || resource.method === 'HEAD'\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: await resource.blob(),\n\t\t\t\t\t\tcache: resource.cache,\n\t\t\t\t\t\tcredentials: resource.credentials,\n\t\t\t\t\t\t// the server sets headers to `undefined` if there are no headers but\n\t\t\t\t\t\t// the client defaults to an empty Headers object in the Request object.\n\t\t\t\t\t\t// To keep the two values in sync, we explicitly set the headers to `undefined`.\n\t\t\t\t\t\t// Also, not sure why, but sometimes 0 is evaluated as truthy so we need to\n\t\t\t\t\t\t// explicitly compare the headers length to a number here\n\t\t\t\t\t\theaders: [...resource.headers].length > 0 ? resource?.headers : undefined,\n\t\t\t\t\t\tintegrity: resource.integrity,\n\t\t\t\t\t\tkeepalive: resource.keepalive,\n\t\t\t\t\t\tmethod: resource.method,\n\t\t\t\t\t\tmode: resource.mode,\n\t\t\t\t\t\tredirect: resource.redirect,\n\t\t\t\t\t\treferrer: resource.referrer,\n\t\t\t\t\t\treferrerPolicy: resource.referrerPolicy,\n\t\t\t\t\t\tsignal: resource.signal,\n\t\t\t\t\t\t...init\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst { resolved, promise } = resolve_fetch_url(resource, init, url);\n\n\t\t\t\tif (is_tracking) {\n\t\t\t\t\tdepends(resolved.href);\n\t\t\t\t}\n\n\t\t\t\treturn promise;\n\t\t\t},\n\t\t\tsetHeaders: () => {}, // noop\n\t\t\tdepends,\n\t\t\tparent() {\n\t\t\t\tif (is_tracking) {\n\t\t\t\t\tuses.parent = true;\n\t\t\t\t}\n\t\t\t\treturn parent();\n\t\t\t},\n\t\t\tuntrack(fn) {\n\t\t\t\tis_tracking = false;\n\t\t\t\ttry {\n\t\t\t\t\treturn fn();\n\t\t\t\t} finally {\n\t\t\t\t\tis_tracking = true;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (DEV) {\n\t\t\ttry {\n\t\t\t\tlock_fetch();\n\t\t\t\tdata = (await node.universal.load.call(null, load_input)) ?? null;\n\t\t\t\tvalidate_load_response(data, `related to route '${route.id}'`);\n\t\t\t} finally {\n\t\t\t\tunlock_fetch();\n\t\t\t}\n\t\t} else {\n\t\t\tdata = (await node.universal.load.call(null, load_input)) ?? null;\n\t\t}\n\t}\n\n\treturn {\n\t\tnode,\n\t\tloader,\n\t\tserver: server_data_node,\n\t\tuniversal: node.universal?.load ? { type: 'data', data, uses } : null,\n\t\tdata: data ?? server_data_node?.data ?? null,\n\t\tslash: node.universal?.trailingSlash ?? server_data_node?.slash\n\t};\n}\n\n/**\n * @param {Request | string | URL} input\n * @param {RequestInit | undefined} init\n * @param {URL} url\n */\nfunction resolve_fetch_url(input, init, url) {\n\tlet requested = input instanceof Request ? input.url : input;\n\n\t// we must fixup relative urls so they are resolved from the target page\n\tconst resolved = new URL(requested, url);\n\n\t// match ssr serialized data url, which is important to find cached responses\n\tif (resolved.origin === url.origin) {\n\t\trequested = resolved.href.slice(url.origin.length);\n\t}\n\n\t// prerendered pages may be served from any origin, so `initial_fetch` urls shouldn't be resolved\n\tconst promise = started\n\t\t? subsequent_fetch(requested, resolved.href, init)\n\t\t: initial_fetch(requested, init);\n\n\treturn { resolved, promise };\n}\n\n/**\n * @param {boolean} parent_changed\n * @param {boolean} route_changed\n * @param {boolean} url_changed\n * @param {Set<string>} search_params_changed\n * @param {import('types').Uses | undefined} uses\n * @param {Record<string, string>} params\n */\nfunction has_changed(\n\tparent_changed,\n\troute_changed,\n\turl_changed,\n\tsearch_params_changed,\n\tuses,\n\tparams\n) {\n\tif (force_invalidation) return true;\n\n\tif (!uses) return false;\n\n\tif (uses.parent && parent_changed) return true;\n\tif (uses.route && route_changed) return true;\n\tif (uses.url && url_changed) return true;\n\n\tfor (const tracked_params of uses.search_params) {\n\t\tif (search_params_changed.has(tracked_params)) return true;\n\t}\n\n\tfor (const param of uses.params) {\n\t\tif (params[param] !== current.params[param]) return true;\n\t}\n\n\tfor (const href of uses.dependencies) {\n\t\tif (invalidated.some((fn) => fn(new URL(href)))) return true;\n\t}\n\n\treturn false;\n}\n\n/**\n * @param {import('types').ServerDataNode | import('types').ServerDataSkippedNode | null} node\n * @param {import('./types.js').DataNode | null} [previous]\n * @returns {import('./types.js').DataNode | null}\n */\nfunction create_data_node(node, previous) {\n\tif (node?.type === 'data') return node;\n\tif (node?.type === 'skip') return previous ?? null;\n\treturn null;\n}\n\n/**\n * @param {URL | null} old_url\n * @param {URL} new_url\n */\nfunction diff_search_params(old_url, new_url) {\n\tif (!old_url) return new Set(new_url.searchParams.keys());\n\n\tconst changed = new Set([...old_url.searchParams.keys(), ...new_url.searchParams.keys()]);\n\n\tfor (const key of changed) {\n\t\tconst old_values = old_url.searchParams.getAll(key);\n\t\tconst new_values = new_url.searchParams.getAll(key);\n\n\t\tif (\n\t\t\told_values.every((value) => new_values.includes(value)) &&\n\t\t\tnew_values.every((value) => old_values.includes(value))\n\t\t) {\n\t\t\tchanged.delete(key);\n\t\t}\n\t}\n\n\treturn changed;\n}\n\n/**\n * @param {Omit<import('./types.js').NavigationFinished['state'], 'branch'> & { error: App.Error }} opts\n * @returns {import('./types.js').NavigationFinished}\n */\nfunction preload_error({ error, url, route, params }) {\n\treturn {\n\t\ttype: 'loaded',\n\t\tstate: {\n\t\t\terror,\n\t\t\turl,\n\t\t\troute,\n\t\t\tparams,\n\t\t\tbranch: []\n\t\t},\n\t\tprops: {\n\t\t\tpage: clone_page(page),\n\t\t\tconstructors: []\n\t\t}\n\t};\n}\n\n/**\n * @param {import('./types.js').NavigationIntent & { preload?: {} }} intent\n * @returns {Promise<import('./types.js').NavigationResult>}\n */\nasync function load_route({ id, invalidating, url, params, route, preload }) {\n\tif (load_cache?.id === id) {\n\t\t// the preload becomes the real navigation\n\t\tpreload_tokens.delete(load_cache.token);\n\t\treturn load_cache.promise;\n\t}\n\n\tconst { errors, layouts, leaf } = route;\n\n\tconst loaders = [...layouts, leaf];\n\n\t// preload modules to avoid waterfall, but handle rejections\n\t// so they don't get reported to Sentry et al (we don't need\n\t// to act on the failures at this point)\n\terrors.forEach((loader) => loader?.().catch(() => {}));\n\tloaders.forEach((loader) => loader?.[1]().catch(() => {}));\n\n\t/** @type {import('types').ServerNodesResponse | import('types').ServerRedirectNode | null} */\n\tlet server_data = null;\n\tconst url_changed = current.url ? id !== get_page_key(current.url) : false;\n\tconst route_changed = current.route ? route.id !== current.route.id : false;\n\tconst search_params_changed = diff_search_params(current.url, url);\n\n\tlet parent_invalid = false;\n\n\tif (__SVELTEKIT_HAS_SERVER_LOAD__) {\n\t\tconst invalid_server_nodes = loaders.map((loader, i) => {\n\t\t\tconst previous = current.branch[i];\n\n\t\t\tconst invalid =\n\t\t\t\t!!loader?.[0] &&\n\t\t\t\t(previous?.loader !== loader[1] ||\n\t\t\t\t\thas_changed(\n\t\t\t\t\t\tparent_invalid,\n\t\t\t\t\t\troute_changed,\n\t\t\t\t\t\turl_changed,\n\t\t\t\t\t\tsearch_params_changed,\n\t\t\t\t\t\tprevious.server?.uses,\n\t\t\t\t\t\tparams\n\t\t\t\t\t));\n\n\t\t\tif (invalid) {\n\t\t\t\t// For the next one\n\t\t\t\tparent_invalid = true;\n\t\t\t}\n\n\t\t\treturn invalid;\n\t\t});\n\n\t\tif (invalid_server_nodes.some(Boolean)) {\n\t\t\ttry {\n\t\t\t\tserver_data = await load_data(url, invalid_server_nodes);\n\t\t\t} catch (error) {\n\t\t\t\tconst handled_error = await handle_error(error, { url, params, route: { id } });\n\n\t\t\t\tif (preload_tokens.has(preload)) {\n\t\t\t\t\treturn preload_error({ error: handled_error, url, params, route });\n\t\t\t\t}\n\n\t\t\t\treturn load_root_error_page({\n\t\t\t\t\tstatus: get_status(error),\n\t\t\t\t\terror: handled_error,\n\t\t\t\t\turl,\n\t\t\t\t\troute\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (server_data.type === 'redirect') {\n\t\t\t\treturn server_data;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst server_data_nodes = server_data?.nodes;\n\n\tlet parent_changed = false;\n\n\tconst branch_promises = loaders.map(async (loader, i) => {\n\t\tif (!loader) return;\n\n\t\t/** @type {import('./types.js').BranchNode | undefined} */\n\t\tconst previous = current.branch[i];\n\n\t\tconst server_data_node = server_data_nodes?.[i];\n\n\t\t// re-use data from previous load if it's still valid\n\t\tconst valid =\n\t\t\t(!server_data_node || server_data_node.type === 'skip') &&\n\t\t\tloader[1] === previous?.loader &&\n\t\t\t!has_changed(\n\t\t\t\tparent_changed,\n\t\t\t\troute_changed,\n\t\t\t\turl_changed,\n\t\t\t\tsearch_params_changed,\n\t\t\t\tprevious.universal?.uses,\n\t\t\t\tparams\n\t\t\t);\n\t\tif (valid) return previous;\n\n\t\tparent_changed = true;\n\n\t\tif (server_data_node?.type === 'error') {\n\t\t\t// rethrow and catch below\n\t\t\tthrow server_data_node;\n\t\t}\n\n\t\treturn load_node({\n\t\t\tloader: loader[1],\n\t\t\turl,\n\t\t\tparams,\n\t\t\troute,\n\t\t\tparent: async () => {\n\t\t\t\tconst data = {};\n\t\t\t\tfor (let j = 0; j < i; j += 1) {\n\t\t\t\t\tObject.assign(data, (await branch_promises[j])?.data);\n\t\t\t\t}\n\t\t\t\treturn data;\n\t\t\t},\n\t\t\tserver_data_node: create_data_node(\n\t\t\t\t// server_data_node is undefined if it wasn't reloaded from the server;\n\t\t\t\t// and if current loader uses server data, we want to reuse previous data.\n\t\t\t\tserver_data_node === undefined && loader[0] ? { type: 'skip' } : (server_data_node ?? null),\n\t\t\t\tloader[0] ? previous?.server : undefined\n\t\t\t)\n\t\t});\n\t});\n\n\t// if we don't do this, rejections will be unhandled\n\tfor (const p of branch_promises) p.catch(() => {});\n\n\t/** @type {Array<import('./types.js').BranchNode | undefined>} */\n\tconst branch = [];\n\n\tfor (let i = 0; i < loaders.length; i += 1) {\n\t\tif (loaders[i]) {\n\t\t\ttry {\n\t\t\t\tbranch.push(await branch_promises[i]);\n\t\t\t} catch (err) {\n\t\t\t\tif (err instanceof Redirect) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'redirect',\n\t\t\t\t\t\tlocation: err.location\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (preload_tokens.has(preload)) {\n\t\t\t\t\treturn preload_error({\n\t\t\t\t\t\terror: await handle_error(err, { params, url, route: { id: route.id } }),\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tparams,\n\t\t\t\t\t\troute\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tlet status = get_status(err);\n\t\t\t\t/** @type {App.Error} */\n\t\t\t\tlet error;\n\n\t\t\t\tif (server_data_nodes?.includes(/** @type {import('types').ServerErrorNode} */ (err))) {\n\t\t\t\t\t// this is the server error rethrown above, reconstruct but don't invoke\n\t\t\t\t\t// the client error handler; it should've already been handled on the server\n\t\t\t\t\tstatus = /** @type {import('types').ServerErrorNode} */ (err).status ?? status;\n\t\t\t\t\terror = /** @type {import('types').ServerErrorNode} */ (err).error;\n\t\t\t\t} else if (err instanceof HttpError) {\n\t\t\t\t\terror = err.body;\n\t\t\t\t} else {\n\t\t\t\t\t// Referenced node could have been removed due to redeploy, check\n\t\t\t\t\tconst updated = await stores.updated.check();\n\t\t\t\t\tif (updated) {\n\t\t\t\t\t\t// Before reloading, try to update the service worker if it exists\n\t\t\t\t\t\tawait update_service_worker();\n\t\t\t\t\t\treturn await native_navigation(url);\n\t\t\t\t\t}\n\n\t\t\t\t\terror = await handle_error(err, { params, url, route: { id: route.id } });\n\t\t\t\t}\n\n\t\t\t\tconst error_load = await load_nearest_error_page(i, branch, errors);\n\t\t\t\tif (error_load) {\n\t\t\t\t\treturn get_navigation_result_from_branch({\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tparams,\n\t\t\t\t\t\tbranch: branch.slice(0, error_load.idx).concat(error_load.node),\n\t\t\t\t\t\terrors,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\terror,\n\t\t\t\t\t\troute\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn await server_fallback(url, { id: route.id }, error, status);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// push an empty slot so we can rewind past gaps to the\n\t\t\t// layout that corresponds with an +error.svelte page\n\t\t\tbranch.push(undefined);\n\t\t}\n\t}\n\n\treturn get_navigation_result_from_branch({\n\t\turl,\n\t\tparams,\n\t\tbranch,\n\t\terrors,\n\t\tstatus: 200,\n\t\terror: null,\n\t\troute,\n\t\t// Reset `form` on navigation, but not invalidation\n\t\tform: invalidating ? undefined : null\n\t});\n}\n\n/**\n * @param {number} i Start index to backtrack from\n * @param {Array<import('./types.js').BranchNode | undefined>} branch Branch to backtrack\n * @param {Array<import('types').CSRPageNodeLoader | undefined>} errors All error pages for this branch\n * @returns {Promise<{idx: number; node: import('./types.js').BranchNode} | undefined>}\n */\nasync function load_nearest_error_page(i, branch, errors) {\n\twhile (i--) {\n\t\tif (errors[i]) {\n\t\t\tlet j = i;\n\t\t\twhile (!branch[j]) j -= 1;\n\t\t\ttry {\n\t\t\t\treturn {\n\t\t\t\t\tidx: j + 1,\n\t\t\t\t\tnode: {\n\t\t\t\t\t\tnode: await /** @type {import('types').CSRPageNodeLoader } */ (errors[i])(),\n\t\t\t\t\t\tloader: /** @type {import('types').CSRPageNodeLoader } */ (errors[i]),\n\t\t\t\t\t\tdata: {},\n\t\t\t\t\t\tserver: null,\n\t\t\t\t\t\tuniversal: null\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t} catch {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * @param {{\n *   status: number;\n *   error: App.Error;\n *   url: URL;\n *   route: { id: string | null }\n * }} opts\n * @returns {Promise<import('./types.js').NavigationFinished>}\n */\nasync function load_root_error_page({ status, error, url, route }) {\n\t/** @type {Record<string, string>} */\n\tconst params = {}; // error page does not have params\n\n\t/** @type {import('types').ServerDataNode | null} */\n\tlet server_data_node = null;\n\n\tif (__SVELTEKIT_HAS_SERVER_LOAD__) {\n\t\tconst default_layout_has_server_load = app.server_loads[0] === 0;\n\n\t\tif (default_layout_has_server_load) {\n\t\t\t// TODO post-https://github.com/sveltejs/kit/discussions/6124 we can use\n\t\t\t// existing root layout data\n\t\t\ttry {\n\t\t\t\tconst server_data = await load_data(url, [true]);\n\n\t\t\t\tif (\n\t\t\t\t\tserver_data.type !== 'data' ||\n\t\t\t\t\t(server_data.nodes[0] && server_data.nodes[0].type !== 'data')\n\t\t\t\t) {\n\t\t\t\t\tthrow 0;\n\t\t\t\t}\n\n\t\t\t\tserver_data_node = server_data.nodes[0] ?? null;\n\t\t\t} catch {\n\t\t\t\t// at this point we have no choice but to fall back to the server, if it wouldn't\n\t\t\t\t// bring us right back here, turning this into an endless loop\n\t\t\t\tif (url.origin !== origin || url.pathname !== location.pathname || hydrated) {\n\t\t\t\t\tawait native_navigation(url);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\ttry {\n\t\tconst root_layout = await load_node({\n\t\t\tloader: default_layout_loader,\n\t\t\turl,\n\t\t\tparams,\n\t\t\troute,\n\t\t\tparent: () => Promise.resolve({}),\n\t\t\tserver_data_node: create_data_node(server_data_node)\n\t\t});\n\n\t\t/** @type {import('./types.js').BranchNode} */\n\t\tconst root_error = {\n\t\t\tnode: await default_error_loader(),\n\t\t\tloader: default_error_loader,\n\t\t\tuniversal: null,\n\t\t\tserver: null,\n\t\t\tdata: null\n\t\t};\n\n\t\treturn get_navigation_result_from_branch({\n\t\t\turl,\n\t\t\tparams,\n\t\t\tbranch: [root_layout, root_error],\n\t\t\tstatus,\n\t\t\terror,\n\t\t\terrors: [],\n\t\t\troute: null\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof Redirect) {\n\t\t\t// @ts-expect-error TODO investigate this\n\t\t\treturn _goto(new URL(error.location, location.href), {}, 0);\n\t\t}\n\n\t\t// TODO: this falls back to the server when a server exists, but what about SPA mode?\n\t\tthrow error;\n\t}\n}\n\n/**\n * Resolve the relative rerouted URL for a client-side navigation\n * @param {URL} url\n * @returns {Promise<URL | undefined>}\n */\nasync function get_rerouted_url(url) {\n\tconst href = url.href;\n\n\tif (reroute_cache.has(href)) {\n\t\treturn reroute_cache.get(href);\n\t}\n\n\tlet rerouted;\n\n\ttry {\n\t\tconst promise = (async () => {\n\t\t\t// reroute could alter the given URL, so we pass a copy\n\t\t\tlet rerouted =\n\t\t\t\t(await app.hooks.reroute({\n\t\t\t\t\turl: new URL(url),\n\t\t\t\t\tfetch: async (input, init) => {\n\t\t\t\t\t\treturn resolve_fetch_url(input, init, url).promise;\n\t\t\t\t\t}\n\t\t\t\t})) ?? url;\n\n\t\t\tif (typeof rerouted === 'string') {\n\t\t\t\tconst tmp = new URL(url); // do not mutate the incoming URL\n\n\t\t\t\tif (app.hash) {\n\t\t\t\t\ttmp.hash = rerouted;\n\t\t\t\t} else {\n\t\t\t\t\ttmp.pathname = rerouted;\n\t\t\t\t}\n\n\t\t\t\trerouted = tmp;\n\t\t\t}\n\n\t\t\treturn rerouted;\n\t\t})();\n\n\t\treroute_cache.set(href, promise);\n\t\trerouted = await promise;\n\t} catch (e) {\n\t\treroute_cache.delete(href);\n\t\tif (DEV) {\n\t\t\t// in development, print the error...\n\t\t\tconsole.error(e);\n\n\t\t\t// ...and pause execution, since otherwise we will immediately reload the page\n\t\t\tdebugger; // eslint-disable-line\n\t\t}\n\n\t\t// fall back to native navigation\n\t\treturn;\n\t}\n\n\treturn rerouted;\n}\n\n/**\n * Resolve the full info (which route, params, etc.) for a client-side navigation from the URL,\n * taking the reroute hook into account. If this isn't a client-side-navigation (or the URL is undefined),\n * returns undefined.\n * @param {URL | undefined} url\n * @param {boolean} invalidating\n * @returns {Promise<import('./types.js').NavigationIntent | undefined>}\n */\nexport async function get_navigation_intent(url, invalidating) {\n\tif (!url) return;\n\tif (is_external_url(url, base, app.hash)) return;\n\n\tif (__SVELTEKIT_CLIENT_ROUTING__) {\n\t\tconst rerouted = await get_rerouted_url(url);\n\t\tif (!rerouted) return;\n\n\t\tconst path = get_url_path(rerouted);\n\n\t\tfor (const route of routes) {\n\t\t\tconst params = route.exec(path);\n\n\t\t\tif (params) {\n\t\t\t\treturn {\n\t\t\t\t\tid: get_page_key(url),\n\t\t\t\t\tinvalidating,\n\t\t\t\t\troute,\n\t\t\t\t\tparams: decode_params(params),\n\t\t\t\t\turl\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t} else {\n\t\t/** @type {{ route?: import('types').CSRRouteServer, params: Record<string, string>}} */\n\t\tconst { route, params } = await import(\n\t\t\t/* @vite-ignore */\n\t\t\tadd_resolution_suffix(url.pathname)\n\t\t);\n\n\t\tif (!route) return;\n\n\t\treturn {\n\t\t\tid: get_page_key(url),\n\t\t\tinvalidating,\n\t\t\troute: parse_server_route(route, app.nodes),\n\t\t\tparams,\n\t\t\turl\n\t\t};\n\t}\n}\n\n/** @param {URL} url */\nfunction get_url_path(url) {\n\treturn (\n\t\tdecode_pathname(\n\t\t\tapp.hash ? url.hash.replace(/^#/, '').replace(/[?#].+/, '') : url.pathname.slice(base.length)\n\t\t) || '/'\n\t);\n}\n\n/** @param {URL} url */\nfunction get_page_key(url) {\n\treturn (app.hash ? url.hash.replace(/^#/, '') : url.pathname) + url.search;\n}\n\n/**\n * @param {{\n *   url: URL;\n *   type: import('@sveltejs/kit').Navigation[\"type\"];\n *   intent?: import('./types.js').NavigationIntent;\n *   delta?: number;\n *   event?: PopStateEvent | MouseEvent;\n *   scroll?: { x: number, y: number };\n * }} opts\n */\nfunction _before_navigate({ url, type, intent, delta, event, scroll }) {\n\tlet should_block = false;\n\n\tconst nav = create_navigation(current, intent, url, type, scroll ?? null);\n\n\tif (delta !== undefined) {\n\t\tnav.navigation.delta = delta;\n\t}\n\n\tif (event !== undefined) {\n\t\t// @ts-ignore\n\t\tnav.navigation.event = event;\n\t}\n\n\tconst cancellable = {\n\t\t...nav.navigation,\n\t\tcancel: () => {\n\t\t\tshould_block = true;\n\t\t\tnav.reject(new Error('navigation cancelled'));\n\t\t}\n\t};\n\n\tif (!is_navigating) {\n\t\t// Don't run the event during redirects\n\t\tbefore_navigate_callbacks.forEach((fn) => fn(cancellable));\n\t}\n\n\treturn should_block ? null : nav;\n}\n\n/**\n * @param {{\n *   type: import('@sveltejs/kit').NavigationType;\n *   url: URL;\n *   popped?: {\n *     state: Record<string, any>;\n *     scroll: { x: number, y: number };\n *     delta: number;\n *   };\n *   keepfocus?: boolean;\n *   noscroll?: boolean;\n *   replace_state?: boolean;\n *   state?: Record<string, any>;\n *   redirect_count?: number;\n *   nav_token?: {};\n *   accept?: () => void;\n *   block?: () => void;\n *   event?: Event\n * }} opts\n */\nasync function navigate({\n\ttype,\n\turl,\n\tpopped,\n\tkeepfocus,\n\tnoscroll,\n\treplace_state,\n\tstate = {},\n\tredirect_count = 0,\n\tnav_token = {},\n\taccept = noop,\n\tblock = noop,\n\tevent\n}) {\n\tconst prev_token = token;\n\ttoken = nav_token;\n\n\tconst intent = await get_navigation_intent(url, false);\n\tconst nav =\n\t\ttype === 'enter'\n\t\t\t? create_navigation(current, intent, url, type)\n\t\t\t: _before_navigate({\n\t\t\t\t\turl,\n\t\t\t\t\ttype,\n\t\t\t\t\tdelta: popped?.delta,\n\t\t\t\t\tintent,\n\t\t\t\t\tscroll: popped?.scroll,\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tevent\n\t\t\t\t});\n\n\tif (!nav) {\n\t\tblock();\n\t\tif (token === nav_token) token = prev_token;\n\t\treturn;\n\t}\n\n\t// store this before calling `accept()`, which may change the index\n\tconst previous_history_index = current_history_index;\n\tconst previous_navigation_index = current_navigation_index;\n\n\taccept();\n\n\tis_navigating = true;\n\n\tif (started && nav.navigation.type !== 'enter') {\n\t\tstores.navigating.set((navigating.current = nav.navigation));\n\t}\n\n\tlet navigation_result = intent && (await load_route(intent));\n\n\tif (!navigation_result) {\n\t\tif (is_external_url(url, base, app.hash)) {\n\t\t\tif (DEV && app.hash) {\n\t\t\t\t// Special case for hash mode during DEV: If someone accidentally forgets to use a hash for the link,\n\t\t\t\t// they would end up here in an endless loop. Fall back to error page in that case\n\t\t\t\tnavigation_result = await server_fallback(\n\t\t\t\t\turl,\n\t\t\t\t\t{ id: null },\n\t\t\t\t\tawait handle_error(\n\t\t\t\t\t\tnew SvelteKitError(\n\t\t\t\t\t\t\t404,\n\t\t\t\t\t\t\t'Not Found',\n\t\t\t\t\t\t\t`Not found: ${url.pathname} (did you forget the hash?)`\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\tparams: {},\n\t\t\t\t\t\t\troute: { id: null }\n\t\t\t\t\t\t}\n\t\t\t\t\t),\n\t\t\t\t\t404,\n\t\t\t\t\treplace_state\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\treturn await native_navigation(url, replace_state);\n\t\t\t}\n\t\t} else {\n\t\t\tnavigation_result = await server_fallback(\n\t\t\t\turl,\n\t\t\t\t{ id: null },\n\t\t\t\tawait handle_error(new SvelteKitError(404, 'Not Found', `Not found: ${url.pathname}`), {\n\t\t\t\t\turl,\n\t\t\t\t\tparams: {},\n\t\t\t\t\troute: { id: null }\n\t\t\t\t}),\n\t\t\t\t404,\n\t\t\t\treplace_state\n\t\t\t);\n\t\t}\n\t}\n\n\t// if this is an internal navigation intent, use the normalized\n\t// URL for the rest of the function\n\turl = intent?.url || url;\n\n\t// abort if user navigated during update\n\tif (token !== nav_token) {\n\t\tnav.reject(new Error('navigation aborted'));\n\t\treturn false;\n\t}\n\n\tif (navigation_result.type === 'redirect') {\n\t\t// whatwg fetch spec https://fetch.spec.whatwg.org/#http-redirect-fetch says to error after 20 redirects\n\t\tif (redirect_count < 20) {\n\t\t\tawait navigate({\n\t\t\t\ttype,\n\t\t\t\turl: new URL(navigation_result.location, url),\n\t\t\t\tpopped,\n\t\t\t\tkeepfocus,\n\t\t\t\tnoscroll,\n\t\t\t\treplace_state,\n\t\t\t\tstate,\n\t\t\t\tredirect_count: redirect_count + 1,\n\t\t\t\tnav_token\n\t\t\t});\n\n\t\t\tnav.fulfil(undefined);\n\t\t\treturn;\n\t\t}\n\n\t\tnavigation_result = await load_root_error_page({\n\t\t\tstatus: 500,\n\t\t\terror: await handle_error(new Error('Redirect loop'), {\n\t\t\t\turl,\n\t\t\t\tparams: {},\n\t\t\t\troute: { id: null }\n\t\t\t}),\n\t\t\turl,\n\t\t\troute: { id: null }\n\t\t});\n\t} else if (/** @type {number} */ (navigation_result.props.page.status) >= 400) {\n\t\tconst updated = await stores.updated.check();\n\t\tif (updated) {\n\t\t\t// Before reloading, try to update the service worker if it exists\n\t\t\tawait update_service_worker();\n\t\t\tawait native_navigation(url, replace_state);\n\t\t}\n\t}\n\n\t// reset invalidation only after a finished navigation. If there are redirects or\n\t// additional invalidations, they should get the same invalidation treatment\n\treset_invalidation();\n\n\tupdating = true;\n\n\tupdate_scroll_positions(previous_history_index);\n\tcapture_snapshot(previous_navigation_index);\n\n\t// ensure the url pathname matches the page's trailing slash option\n\tif (navigation_result.props.page.url.pathname !== url.pathname) {\n\t\turl.pathname = navigation_result.props.page.url.pathname;\n\t}\n\n\tstate = popped ? popped.state : state;\n\n\tif (!popped) {\n\t\t// this is a new navigation, rather than a popstate\n\t\tconst change = replace_state ? 0 : 1;\n\n\t\tconst entry = {\n\t\t\t[HISTORY_INDEX]: (current_history_index += change),\n\t\t\t[NAVIGATION_INDEX]: (current_navigation_index += change),\n\t\t\t[STATES_KEY]: state\n\t\t};\n\n\t\tconst fn = replace_state ? history.replaceState : history.pushState;\n\t\tfn.call(history, entry, '', url);\n\n\t\tif (!replace_state) {\n\t\t\tclear_onward_history(current_history_index, current_navigation_index);\n\t\t}\n\t}\n\n\t// also compare ids to avoid using wrong fork (e.g. a new one could've been added while navigating)\n\tconst load_cache_fork = intent && load_cache?.id === intent.id ? load_cache.fork : null;\n\t// reset preload synchronously after the history state has been set to avoid race conditions\n\tload_cache = null;\n\n\tnavigation_result.props.page.state = state;\n\n\t/**\n\t * @type {Promise<void> | undefined}\n\t */\n\tlet commit_promise;\n\tif (started) {\n\t\tconst after_navigate = (\n\t\t\tawait Promise.all(\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/await-thenable -- we need to await because they can be asynchronous\n\t\t\t\tArray.from(on_navigate_callbacks, (fn) =>\n\t\t\t\t\tfn(/** @type {import('@sveltejs/kit').OnNavigate} */ (nav.navigation))\n\t\t\t\t)\n\t\t\t)\n\t\t).filter(/** @returns {value is () => void} */ (value) => typeof value === 'function');\n\n\t\tif (after_navigate.length > 0) {\n\t\t\tfunction cleanup() {\n\t\t\t\tafter_navigate.forEach((fn) => {\n\t\t\t\t\tafter_navigate_callbacks.delete(fn);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tafter_navigate.push(cleanup);\n\n\t\t\tafter_navigate.forEach((fn) => {\n\t\t\t\tafter_navigate_callbacks.add(fn);\n\t\t\t});\n\t\t}\n\n\t\t// Type-casts are save because we know this resolved a proper SvelteKit route\n\t\tconst target = /** @type {import('@sveltejs/kit').NavigationTarget} */ (nav.navigation.to);\n\t\tcurrent = {\n\t\t\t...navigation_result.state,\n\t\t\tnav: {\n\t\t\t\tparams: /** @type {Record<string, any>} */ (target.params),\n\t\t\t\troute: target.route,\n\t\t\t\turl: target.url\n\t\t\t}\n\t\t};\n\n\t\t// reset url before updating page store\n\t\tif (navigation_result.props.page) {\n\t\t\tnavigation_result.props.page.url = url;\n\t\t}\n\n\t\tconst fork = load_cache_fork && (await load_cache_fork);\n\n\t\tif (fork) {\n\t\t\tcommit_promise = fork.commit();\n\t\t} else {\n\t\t\trendering_error = null; // TODO this can break with forks, rethink for SvelteKit 3 where we can assume Svelte 5\n\t\t\troot.$set(navigation_result.props);\n\t\t\t// Check for sync rendering error\n\t\t\tif (rendering_error) {\n\t\t\t\tObject.assign(navigation_result.props.page, rendering_error);\n\t\t\t}\n\t\t\tupdate(navigation_result.props.page);\n\n\t\t\tcommit_promise = svelte.settled?.();\n\t\t}\n\n\t\thas_navigated = true;\n\t} else {\n\t\tawait initialize(navigation_result, target, false);\n\t}\n\n\tconst { activeElement } = document;\n\n\tawait commit_promise;\n\n\t// TODO 3.0 remote — the double tick is probably necessary because\n\t// of some store shenanigans. `settled()` and `f.commit()`\n\t// should resolve after DOM updates in newer versions\n\tawait svelte.tick();\n\tawait svelte.tick();\n\n\t// we reset scroll before dealing with focus, to avoid a flash of unscrolled content\n\t/** @type {Element | null | ''} */\n\tlet deep_linked = null;\n\n\tif (autoscroll) {\n\t\tconst scroll = popped ? popped.scroll : noscroll ? scroll_state() : null;\n\t\tif (scroll) {\n\t\t\tscrollTo(scroll.x, scroll.y);\n\t\t} else if ((deep_linked = url.hash && document.getElementById(get_id(url)))) {\n\t\t\t// Here we use `scrollIntoView` on the element instead of `scrollTo`\n\t\t\t// because it natively supports the `scroll-margin` and `scroll-behavior`\n\t\t\t// CSS properties.\n\t\t\tdeep_linked.scrollIntoView();\n\t\t} else {\n\t\t\tscrollTo(0, 0);\n\t\t}\n\t}\n\n\tconst changed_focus =\n\t\t// reset focus only if any manual focus management didn't override it\n\t\tdocument.activeElement !== activeElement &&\n\t\t// also refocus when activeElement is body already because the\n\t\t// focus event might not have been fired on it yet\n\t\tdocument.activeElement !== document.body;\n\n\tif (!keepfocus && !changed_focus) {\n\t\t// We don't need to manually restore the scroll position if we're navigating\n\t\t// to a fragment identifier. It is automatically done for us when we set the\n\t\t// sequential navigation starting point with `location.replace`\n\t\treset_focus(url, !deep_linked);\n\t}\n\n\tautoscroll = true;\n\n\tif (navigation_result.props.page) {\n\t\t// Check for async rendering error\n\t\tif (rendering_error) {\n\t\t\tObject.assign(navigation_result.props.page, rendering_error);\n\t\t}\n\t\tObject.assign(page, navigation_result.props.page);\n\t}\n\n\tis_navigating = false;\n\n\tif (type === 'popstate') {\n\t\trestore_snapshot(current_navigation_index);\n\t}\n\n\tnav.fulfil(undefined);\n\n\t// Update to.scroll to the actual scroll position after navigation completed\n\tif (nav.navigation.to) {\n\t\tnav.navigation.to.scroll = scroll_state();\n\t}\n\n\tafter_navigate_callbacks.forEach((fn) =>\n\t\tfn(/** @type {import('@sveltejs/kit').AfterNavigate} */ (nav.navigation))\n\t);\n\n\tstores.navigating.set((navigating.current = null));\n\n\tupdating = false;\n}\n\n/**\n * Does a full page reload if it wouldn't result in an endless loop in the SPA case\n * @param {URL} url\n * @param {{ id: string | null }} route\n * @param {App.Error} error\n * @param {number} status\n * @param {boolean} [replace_state]\n * @returns {Promise<import('./types.js').NavigationFinished>}\n */\nasync function server_fallback(url, route, error, status, replace_state) {\n\tif (url.origin === origin && url.pathname === location.pathname && !hydrated) {\n\t\t// We would reload the same page we're currently on, which isn't hydrated,\n\t\t// which means no SSR, which means we would end up in an endless loop\n\t\treturn await load_root_error_page({\n\t\t\tstatus,\n\t\t\terror,\n\t\t\turl,\n\t\t\troute\n\t\t});\n\t}\n\n\tif (DEV && status !== 404) {\n\t\tconsole.error(\n\t\t\t'An error occurred while loading the page. This will cause a full page reload. (This message will only appear during development.)'\n\t\t);\n\n\t\tdebugger; // eslint-disable-line\n\t}\n\n\treturn await native_navigation(url, replace_state);\n}\n\nif (import.meta.hot) {\n\timport.meta.hot.on('vite:beforeUpdate', () => {\n\t\tif (current.error) location.reload();\n\t});\n}\n\n/** @typedef {(typeof PRELOAD_PRIORITIES)['hover'] | (typeof PRELOAD_PRIORITIES)['tap']} PreloadDataPriority */\n\nfunction setup_preload() {\n\t/** @type {NodeJS.Timeout} */\n\tlet mousemove_timeout;\n\t/** @type {{ element: Element | SVGAElement | undefined; href: string | SVGAnimatedString | undefined }} */\n\tlet current_a = { element: undefined, href: undefined };\n\t/** @type {PreloadDataPriority} */\n\tlet current_priority;\n\n\tcontainer.addEventListener('mousemove', (event) => {\n\t\tconst target = /** @type {Element} */ (event.target);\n\n\t\tclearTimeout(mousemove_timeout);\n\t\tmousemove_timeout = setTimeout(() => {\n\t\t\tvoid preload(target, PRELOAD_PRIORITIES.hover);\n\t\t}, 20);\n\t});\n\n\t/** @param {Event} event */\n\tfunction tap(event) {\n\t\tif (event.defaultPrevented) return;\n\t\tvoid preload(/** @type {Element} */ (event.composedPath()[0]), PRELOAD_PRIORITIES.tap);\n\t}\n\n\tcontainer.addEventListener('mousedown', tap);\n\tcontainer.addEventListener('touchstart', tap, { passive: true });\n\n\tconst observer = new IntersectionObserver(\n\t\t(entries) => {\n\t\t\tfor (const entry of entries) {\n\t\t\t\tif (entry.isIntersecting) {\n\t\t\t\t\tvoid _preload_code(new URL(/** @type {HTMLAnchorElement} */ (entry.target).href));\n\t\t\t\t\tobserver.unobserve(entry.target);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ threshold: 0 }\n\t);\n\n\t/**\n\t * @param {Element} element\n\t * @param {PreloadDataPriority} priority\n\t */\n\tasync function preload(element, priority) {\n\t\tconst a = find_anchor(element, container);\n\n\t\t// we don't want to preload data again if the user has already hovered/tapped\n\t\tconst interacted =\n\t\t\ta === current_a.element && a?.href === current_a.href && priority >= current_priority;\n\t\tif (!a || interacted) return;\n\n\t\tconst { url, external, download } = get_link_info(a, base, app.hash);\n\t\tif (external || download) return;\n\n\t\tconst options = get_router_options(a);\n\n\t\t// we don't want to preload data for a page we're already on\n\t\tconst same_url = url && get_page_key(current.url) === get_page_key(url);\n\t\tif (options.reload || same_url) return;\n\n\t\tif (priority <= options.preload_data) {\n\t\t\tcurrent_a = { element: a, href: a.href };\n\t\t\t// we don't want to preload data again on tap if we've already preloaded it on hover\n\t\t\tcurrent_priority = PRELOAD_PRIORITIES.tap;\n\n\t\t\tconst intent = await get_navigation_intent(url, false);\n\t\t\tif (!intent) return;\n\n\t\t\tif (DEV) {\n\t\t\t\tvoid _preload_data(intent).then((result) => {\n\t\t\t\t\tif (result.type === 'loaded' && result.state.error) {\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`Preloading data for ${intent.url.pathname} failed with the following error: ${result.state.error.message}\\n` +\n\t\t\t\t\t\t\t\t'If this error is transient, you can ignore it. Otherwise, consider disabling preloading for this route. ' +\n\t\t\t\t\t\t\t\t'This route was preloaded due to a data-sveltekit-preload-data attribute. ' +\n\t\t\t\t\t\t\t\t'See https://svelte.dev/docs/kit/link-options for more info'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tvoid _preload_data(intent);\n\t\t\t}\n\t\t} else if (priority <= options.preload_code) {\n\t\t\tcurrent_a = { element: a, href: a.href };\n\t\t\tcurrent_priority = priority;\n\t\t\tvoid _preload_code(/** @type {URL} */ (url));\n\t\t}\n\t}\n\n\tfunction after_navigate() {\n\t\tobserver.disconnect();\n\n\t\tfor (const a of container.querySelectorAll('a')) {\n\t\t\tconst { url, external, download } = get_link_info(a, base, app.hash);\n\t\t\tif (external || download) continue;\n\n\t\t\tconst options = get_router_options(a);\n\t\t\tif (options.reload) continue;\n\n\t\t\tif (options.preload_code === PRELOAD_PRIORITIES.viewport) {\n\t\t\t\tobserver.observe(a);\n\t\t\t}\n\n\t\t\tif (options.preload_code === PRELOAD_PRIORITIES.eager) {\n\t\t\t\tvoid _preload_code(/** @type {URL} */ (url));\n\t\t\t}\n\t\t}\n\t}\n\n\tafter_navigate_callbacks.add(after_navigate);\n\tafter_navigate();\n}\n\n/**\n * @param {unknown} error\n * @param {import('@sveltejs/kit').NavigationEvent} event\n * @returns {import('types').MaybePromise<App.Error>}\n */\nfunction handle_error(error, event) {\n\tif (error instanceof HttpError) {\n\t\treturn error.body;\n\t}\n\n\tif (DEV) {\n\t\terrored = true;\n\t\tconsole.warn('The next HMR update will cause the page to reload');\n\t}\n\n\tconst status = get_status(error);\n\tconst message = get_message(error);\n\n\treturn (\n\t\tapp.hooks.handleError({ error, event, status, message }) ?? /** @type {any} */ ({ message })\n\t);\n}\n\n/**\n * @template {Function} T\n * @param {Set<T>} callbacks\n * @param {T} callback\n */\nfunction add_navigation_callback(callbacks, callback) {\n\tonMount(() => {\n\t\tcallbacks.add(callback);\n\n\t\treturn () => {\n\t\t\tcallbacks.delete(callback);\n\t\t};\n\t});\n}\n\n/**\n * A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a URL.\n *\n * `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted.\n * @param {(navigation: import('@sveltejs/kit').AfterNavigate) => void} callback\n * @returns {void}\n */\nexport function afterNavigate(callback) {\n\tadd_navigation_callback(after_navigate_callbacks, callback);\n}\n\n/**\n * A navigation interceptor that triggers before we navigate to a URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls.\n *\n * 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.\n *\n * 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`.\n *\n * 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`.\n *\n * `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted.\n * @param {(navigation: import('@sveltejs/kit').BeforeNavigate) => void} callback\n * @returns {void}\n */\nexport function beforeNavigate(callback) {\n\tadd_navigation_callback(before_navigate_callbacks, callback);\n}\n\n/**\n * A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL except during full-page navigations.\n *\n * 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.\n *\n * 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.\n *\n * `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted.\n * @param {(navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>} callback\n * @returns {void}\n */\nexport function onNavigate(callback) {\n\tadd_navigation_callback(on_navigate_callbacks, callback);\n}\n\n/**\n * 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.\n * This is generally discouraged, since it breaks user expectations.\n * @returns {void}\n */\nexport function disableScrollHandling() {\n\tif (!BROWSER) {\n\t\tthrow new Error('Cannot call disableScrollHandling() on the server');\n\t}\n\n\tif (DEV && started && !updating) {\n\t\tthrow new Error('Can only disable scroll handling during navigation');\n\t}\n\n\tif (updating || !started) {\n\t\tautoscroll = false;\n\t}\n}\n\n/**\n * Allows you to navigate programmatically to a given route, with options such as keeping the current element focused.\n * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.\n *\n * For external URLs, use `window.location = url` instead of calling `goto(url)`.\n *\n * @param {string | URL} url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app.\n * @param {Object} [opts] Options related to the navigation\n * @param {boolean} [opts.replaceState] If `true`, will replace the current `history` entry rather than creating a new one with `pushState`\n * @param {boolean} [opts.noScroll] If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation\n * @param {boolean} [opts.keepFocus] If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body\n * @param {boolean} [opts.invalidateAll] If `true`, all `load` functions of the page will be rerun. See https://svelte.dev/docs/kit/load#rerunning-load-functions for more info on invalidation.\n * @param {Array<string | URL | ((url: URL) => boolean)>} [opts.invalidate] Causes any load functions to re-run if they depend on one of the urls\n * @param {App.PageState} [opts.state] An optional object that will be available as `page.state`\n * @returns {Promise<void>}\n */\nexport function goto(url, opts = {}) {\n\tif (!BROWSER) {\n\t\tthrow new Error('Cannot call goto(...) on the server');\n\t}\n\n\turl = new URL(resolve_url(url));\n\n\tif (url.origin !== origin) {\n\t\treturn Promise.reject(\n\t\t\tnew Error(\n\t\t\t\tDEV\n\t\t\t\t\t? `Cannot use \\`goto\\` with an external URL. Use \\`window.location = \"${url}\"\\` instead`\n\t\t\t\t\t: 'goto: invalid URL'\n\t\t\t)\n\t\t);\n\t}\n\n\treturn _goto(url, opts, 0);\n}\n\n/**\n * 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.\n *\n * 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).\n * To create a custom identifier, use a string beginning with `[a-z]+:` (e.g. `custom:state`) — this is a valid URL.\n *\n * The `function` argument can be used define a custom predicate. It receives the full `URL` and causes `load` to rerun if `true` is returned.\n * This can be useful if you want to invalidate based on a pattern instead of a exact match.\n *\n * ```ts\n * // Example: Match '/path' regardless of the query parameters\n * import { invalidate } from '$app/navigation';\n *\n * invalidate((url) => url.pathname === '/path');\n * ```\n * @param {string | URL | ((url: URL) => boolean)} resource The invalidated URL\n * @returns {Promise<void>}\n */\nexport function invalidate(resource) {\n\tif (!BROWSER) {\n\t\tthrow new Error('Cannot call invalidate(...) on the server');\n\t}\n\n\tpush_invalidated(resource);\n\n\treturn _invalidate();\n}\n\n/**\n * @param {string | URL | ((url: URL) => boolean)} resource The invalidated URL\n */\nfunction push_invalidated(resource) {\n\tif (typeof resource === 'function') {\n\t\tinvalidated.push(resource);\n\t} else {\n\t\tconst { href } = new URL(resource, location.href);\n\t\tinvalidated.push((url) => url.href === href);\n\t}\n}\n\n/**\n * Causes all `load` and `query` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated.\n * @returns {Promise<void>}\n */\nexport function invalidateAll() {\n\tif (!BROWSER) {\n\t\tthrow new Error('Cannot call invalidateAll() on the server');\n\t}\n\n\tforce_invalidation = true;\n\treturn _invalidate();\n}\n\n/**\n * Causes all currently active remote functions to refresh, and all `load` functions belonging to the currently active page to re-run (unless disabled via the option argument).\n * Returns a `Promise` that resolves when the page is subsequently updated.\n * @param {{ includeLoadFunctions?: boolean }} [options]\n * @returns {Promise<void>}\n */\nexport function refreshAll({ includeLoadFunctions = true } = {}) {\n\tif (!BROWSER) {\n\t\tthrow new Error('Cannot call refreshAll() on the server');\n\t}\n\n\tforce_invalidation = true;\n\treturn _invalidate(includeLoadFunctions, false);\n}\n\n/**\n * Programmatically preloads the given page, which means\n *  1. ensuring that the code for the page is loaded, and\n *  2. calling the page's load function with the appropriate options.\n *\n * This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `data-sveltekit-preload-data`.\n * If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.\n * Returns a Promise that resolves with the result of running the new route's `load` functions once the preload is complete.\n *\n * @param {string} href Page to preload\n * @returns {Promise<{ type: 'loaded'; status: number; data: Record<string, any> } | { type: 'redirect'; location: string }>}\n */\nexport async function preloadData(href) {\n\tif (!BROWSER) {\n\t\tthrow new Error('Cannot call preloadData(...) on the server');\n\t}\n\n\tconst url = resolve_url(href);\n\tconst intent = await get_navigation_intent(url, false);\n\n\tif (!intent) {\n\t\tthrow new Error(`Attempted to preload a URL that does not belong to this app: ${url}`);\n\t}\n\n\tconst result = await _preload_data(intent);\n\tif (result.type === 'redirect') {\n\t\treturn {\n\t\t\ttype: result.type,\n\t\t\tlocation: result.location\n\t\t};\n\t}\n\n\tconst { status, data } = result.props.page ?? page;\n\treturn { type: result.type, status, data };\n}\n\n/**\n * Programmatically imports the code for routes that haven't yet been fetched.\n * Typically, you might call this to speed up subsequent navigation.\n *\n * 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`).\n *\n * Unlike `preloadData`, this won't call `load` functions.\n * Returns a Promise that resolves when the modules have been imported.\n *\n * @param {string} pathname\n * @returns {Promise<void>}\n */\nexport async function preloadCode(pathname) {\n\tif (!BROWSER) {\n\t\tthrow new Error('Cannot call preloadCode(...) on the server');\n\t}\n\n\tconst url = new URL(pathname, current.url);\n\n\tif (DEV) {\n\t\tif (!pathname.startsWith('/')) {\n\t\t\tthrow new Error(\n\t\t\t\t'argument passed to preloadCode must be a pathname (i.e. \"/about\" rather than \"http://example.com/about\"'\n\t\t\t);\n\t\t}\n\n\t\tif (!pathname.startsWith(base)) {\n\t\t\tthrow new Error(\n\t\t\t\t`pathname passed to preloadCode must start with \\`paths.base\\` (i.e. \"${base}${pathname}\" rather than \"${pathname}\")`\n\t\t\t);\n\t\t}\n\n\t\tif (__SVELTEKIT_CLIENT_ROUTING__) {\n\t\t\tconst rerouted = await get_rerouted_url(url);\n\t\t\tif (!rerouted || !routes.find((route) => route.exec(get_url_path(rerouted)))) {\n\t\t\t\tthrow new Error(`'${pathname}' did not match any routes`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn _preload_code(url);\n}\n\n/**\n * 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://svelte.dev/docs/kit/shallow-routing).\n *\n * @param {string | URL} url\n * @param {App.PageState} state\n * @returns {void}\n */\nexport function pushState(url, state) {\n\tif (!BROWSER) {\n\t\tthrow new Error('Cannot call pushState(...) on the server');\n\t}\n\n\tif (DEV) {\n\t\tif (!started) {\n\t\t\tthrow new Error('Cannot call pushState(...) before router is initialized');\n\t\t}\n\n\t\ttry {\n\t\t\t// use `devalue.stringify` as a convenient way to ensure we exclude values that can't be properly rehydrated, such as custom class instances\n\t\t\tdevalue.stringify(state);\n\t\t} catch (error) {\n\t\t\t// @ts-expect-error\n\t\t\tthrow new Error(`Could not serialize state${error.path}`, { cause: error });\n\t\t}\n\t}\n\n\tupdate_scroll_positions(current_history_index);\n\n\tconst opts = {\n\t\t[HISTORY_INDEX]: (current_history_index += 1),\n\t\t[NAVIGATION_INDEX]: current_navigation_index,\n\t\t[PAGE_URL_KEY]: page.url.href,\n\t\t[STATES_KEY]: state\n\t};\n\n\thistory.pushState(opts, '', resolve_url(url));\n\thas_navigated = true;\n\n\tpage.state = state;\n\troot.$set({\n\t\t// we need to assign a new page object so that subscribers are correctly notified\n\t\tpage: untrack(() => clone_page(page))\n\t});\n\n\tclear_onward_history(current_history_index, current_navigation_index);\n}\n\n/**\n * 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://svelte.dev/docs/kit/shallow-routing).\n *\n * @param {string | URL} url\n * @param {App.PageState} state\n * @returns {void}\n */\nexport function replaceState(url, state) {\n\tif (!BROWSER) {\n\t\tthrow new Error('Cannot call replaceState(...) on the server');\n\t}\n\n\tif (DEV) {\n\t\tif (!started) {\n\t\t\tthrow new Error('Cannot call replaceState(...) before router is initialized');\n\t\t}\n\n\t\ttry {\n\t\t\t// use `devalue.stringify` as a convenient way to ensure we exclude values that can't be properly rehydrated, such as custom class instances\n\t\t\tdevalue.stringify(state);\n\t\t} catch (error) {\n\t\t\t// @ts-expect-error\n\t\t\tthrow new Error(`Could not serialize state${error.path}`, { cause: error });\n\t\t}\n\t}\n\n\tconst opts = {\n\t\t[HISTORY_INDEX]: current_history_index,\n\t\t[NAVIGATION_INDEX]: current_navigation_index,\n\t\t[PAGE_URL_KEY]: page.url.href,\n\t\t[STATES_KEY]: state\n\t};\n\n\thistory.replaceState(opts, '', resolve_url(url));\n\n\tpage.state = state;\n\troot.$set({\n\t\tpage: untrack(() => clone_page(page))\n\t});\n}\n\n/**\n * This action updates the `form` property of the current page with the given data and updates `page.status`.\n * In case of an error, it redirects to the nearest error page.\n * @template {Record<string, unknown> | undefined} Success\n * @template {Record<string, unknown> | undefined} Failure\n * @param {import('@sveltejs/kit').ActionResult<Success, Failure>} result\n * @returns {Promise<void>}\n */\nexport async function applyAction(result) {\n\tif (!BROWSER) {\n\t\tthrow new Error('Cannot call applyAction(...) on the server');\n\t}\n\n\tif (result.type === 'error') {\n\t\tawait set_nearest_error_page(result.error, result.status);\n\t} else if (result.type === 'redirect') {\n\t\tawait _goto(result.location, { invalidateAll: true }, 0);\n\t} else {\n\t\tpage.form = result.data;\n\t\tpage.status = result.status;\n\n\t\t/** @type {Record<string, any>} */\n\t\troot.$set({\n\t\t\t// this brings Svelte's view of the world in line with SvelteKit's\n\t\t\t// after use:enhance reset the form....\n\t\t\tform: null,\n\t\t\tpage: clone_page(page)\n\t\t});\n\n\t\t// ...so that setting the `form` prop takes effect and isn't ignored\n\t\tawait tick();\n\t\troot.$set({ form: result.data });\n\n\t\tif (result.type === 'success') {\n\t\t\treset_focus(page.url);\n\t\t}\n\t}\n}\n\n/**\n * @param {App.Error} error\n * @param {number} status\n */\nexport async function set_nearest_error_page(error, status = 500) {\n\tconst url = new URL(location.href);\n\n\tconst { branch, route } = current;\n\tif (!route) return;\n\n\tconst error_load = await load_nearest_error_page(current.branch.length, branch, route.errors);\n\tif (error_load) {\n\t\tconst navigation_result = await get_navigation_result_from_branch({\n\t\t\turl,\n\t\t\tparams: current.params,\n\t\t\tbranch: branch.slice(0, error_load.idx).concat(error_load.node),\n\t\t\tstatus,\n\t\t\terror,\n\t\t\t// do not set errors, we haven't changed the page so the previous ones are still current\n\t\t\troute\n\t\t});\n\n\t\tcurrent = { ...navigation_result.state, nav: current.nav };\n\n\t\troot.$set(navigation_result.props);\n\t\tupdate(navigation_result.props.page);\n\n\t\tvoid tick().then(() => reset_focus(current.url));\n\t}\n}\n\nfunction _start_router() {\n\thistory.scrollRestoration = 'manual';\n\n\t// Adopted from Nuxt.js\n\t// Reset scrollRestoration to auto when leaving page, allowing page reload\n\t// and back-navigation from other pages to use the browser to restore the\n\t// scrolling position.\n\taddEventListener('beforeunload', (e) => {\n\t\tlet should_block = false;\n\n\t\tpersist_state();\n\n\t\tif (!is_navigating) {\n\t\t\tconst nav = create_navigation(current, undefined, null, 'leave');\n\n\t\t\t// If we're navigating, beforeNavigate was already called. If we end up in here during navigation,\n\t\t\t// it's due to an external or full-page-reload link, for which we don't want to call the hook again.\n\t\t\t/** @type {import('@sveltejs/kit').BeforeNavigate} */\n\t\t\tconst navigation = {\n\t\t\t\t...nav.navigation,\n\t\t\t\tcancel: () => {\n\t\t\t\t\tshould_block = true;\n\t\t\t\t\tnav.reject(new Error('navigation cancelled'));\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tbefore_navigate_callbacks.forEach((fn) => fn(navigation));\n\t\t}\n\n\t\tif (should_block) {\n\t\t\te.preventDefault();\n\t\t\te.returnValue = '';\n\t\t} else {\n\t\t\thistory.scrollRestoration = 'auto';\n\t\t}\n\t});\n\n\taddEventListener('visibilitychange', () => {\n\t\tif (document.visibilityState === 'hidden') {\n\t\t\tpersist_state();\n\t\t}\n\t});\n\n\t// @ts-expect-error this isn't supported everywhere yet\n\tif (!navigator.connection?.saveData) {\n\t\tsetup_preload();\n\t}\n\n\t/** @param {MouseEvent} event */\n\tcontainer.addEventListener('click', async (event) => {\n\t\t// Adapted from https://github.com/visionmedia/page.js\n\t\t// MIT license https://github.com/visionmedia/page.js#license\n\t\tif (event.button || event.which !== 1) return;\n\t\tif (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n\t\tif (event.defaultPrevented) return;\n\n\t\tconst a = find_anchor(/** @type {Element} */ (event.composedPath()[0]), container);\n\t\tif (!a) return;\n\n\t\tconst { url, external, target, download } = get_link_info(a, base, app.hash);\n\t\tif (!url) return;\n\n\t\t// bail out before `beforeNavigate` if link opens in a different tab\n\t\tif (target === '_parent' || target === '_top') {\n\t\t\tif (window.parent !== window) return;\n\t\t} else if (target && target !== '_self') {\n\t\t\treturn;\n\t\t}\n\n\t\tconst options = get_router_options(a);\n\t\tconst is_svg_a_element = a instanceof SVGAElement;\n\n\t\t// Ignore URL protocols that differ to the current one and are not http(s) (e.g. `mailto:`, `tel:`, `myapp:`, etc.)\n\t\t// This may be wrong when the protocol is x: and the link goes to y:.. which should be treated as an external\n\t\t// navigation, but it's not clear how to handle that case and it's not likely to come up in practice.\n\t\t// MEMO: Without this condition, firefox will open mailer twice.\n\t\t// See:\n\t\t// - https://github.com/sveltejs/kit/issues/4045\n\t\t// - https://github.com/sveltejs/kit/issues/5725\n\t\t// - https://github.com/sveltejs/kit/issues/6496\n\t\tif (\n\t\t\t!is_svg_a_element &&\n\t\t\turl.protocol !== location.protocol &&\n\t\t\t!(url.protocol === 'https:' || url.protocol === 'http:')\n\t\t)\n\t\t\treturn;\n\n\t\tif (download) return;\n\n\t\tconst [nonhash, hash] = (app.hash ? url.hash.replace(/^#/, '') : url.href).split('#');\n\t\tconst same_pathname = nonhash === strip_hash(location);\n\n\t\t// Ignore the following but fire beforeNavigate\n\t\tif (external || (options.reload && (!same_pathname || !hash))) {\n\t\t\tif (_before_navigate({ url, type: 'link', event })) {\n\t\t\t\t// set `navigating` to `true` to prevent `beforeNavigate` callbacks\n\t\t\t\t// being called when the page unloads\n\t\t\t\tis_navigating = true;\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if new url only differs by hash and use the browser default behavior in that case\n\t\t// This will ensure the `hashchange` event is fired\n\t\t// Removing the hash does a full page navigation in the browser, so make sure a hash is present\n\t\tif (hash !== undefined && same_pathname) {\n\t\t\t// If we are trying to navigate to the same hash, we should only\n\t\t\t// attempt to scroll to that element and avoid any history changes.\n\t\t\t// Otherwise, this can cause Firefox to incorrectly assign a null\n\t\t\t// history state value without any signal that we can detect.\n\t\t\tconst [, current_hash] = current.url.href.split('#');\n\t\t\tif (current_hash === hash) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\t// We're already on /# and click on a link that goes to /#, or we're on\n\t\t\t\t// /#top and click on a link that goes to /#top. In those cases just go to\n\t\t\t\t// the top of the page, and avoid a history change.\n\t\t\t\tif (hash === '' || (hash === 'top' && a.ownerDocument.getElementById('top') === null)) {\n\t\t\t\t\tscrollTo({ top: 0 });\n\t\t\t\t} else {\n\t\t\t\t\tconst element = a.ownerDocument.getElementById(decodeURIComponent(hash));\n\t\t\t\t\tif (element) {\n\t\t\t\t\t\telement.scrollIntoView();\n\t\t\t\t\t\telement.focus();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// set this flag to distinguish between navigations triggered by\n\t\t\t// clicking a hash link and those triggered by popstate\n\t\t\thash_navigating = true;\n\n\t\t\tupdate_scroll_positions(current_history_index);\n\n\t\t\tupdate_url(url);\n\n\t\t\tif (!options.replace_state) return;\n\n\t\t\t// hashchange event shouldn't occur if the router is replacing state.\n\t\t\thash_navigating = false;\n\t\t}\n\n\t\tevent.preventDefault();\n\n\t\t// allow the browser to repaint before navigating —\n\t\t// this prevents INP scores being penalised\n\t\tawait new Promise((fulfil) => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tsetTimeout(fulfil, 0);\n\t\t\t});\n\n\t\t\tsetTimeout(fulfil, 100); // fallback for edge case where rAF doesn't fire because e.g. tab was backgrounded\n\t\t});\n\n\t\tawait navigate({\n\t\t\ttype: 'link',\n\t\t\turl,\n\t\t\tkeepfocus: options.keepfocus,\n\t\t\tnoscroll: options.noscroll,\n\t\t\treplace_state: options.replace_state ?? url.href === location.href,\n\t\t\tevent\n\t\t});\n\t});\n\n\tcontainer.addEventListener('submit', (event) => {\n\t\tif (event.defaultPrevented) return;\n\n\t\tconst form = /** @type {HTMLFormElement} */ (\n\t\t\tHTMLFormElement.prototype.cloneNode.call(event.target)\n\t\t);\n\n\t\tconst submitter = /** @type {HTMLButtonElement | HTMLInputElement | null} */ (event.submitter);\n\n\t\tconst target = submitter?.formTarget || form.target;\n\n\t\tif (target === '_blank') return;\n\n\t\tconst method = submitter?.formMethod || form.method;\n\n\t\tif (method !== 'get') return;\n\n\t\t// It is impossible to use form actions with hash router, so we just ignore handling them here\n\t\tconst url = new URL(\n\t\t\t(submitter?.hasAttribute('formaction') && submitter?.formAction) || form.action\n\t\t);\n\n\t\tif (is_external_url(url, base, false)) return;\n\n\t\tconst event_form = /** @type {HTMLFormElement} */ (event.target);\n\n\t\tconst options = get_router_options(event_form);\n\t\tif (options.reload) return;\n\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\tconst data = new FormData(event_form, submitter);\n\n\t\t// @ts-expect-error `URLSearchParams(fd)` is kosher, but typescript doesn't know that\n\t\turl.search = new URLSearchParams(data).toString();\n\n\t\tvoid navigate({\n\t\t\ttype: 'form',\n\t\t\turl,\n\t\t\tkeepfocus: options.keepfocus,\n\t\t\tnoscroll: options.noscroll,\n\t\t\treplace_state: options.replace_state ?? url.href === location.href,\n\t\t\tevent\n\t\t});\n\t});\n\n\taddEventListener('popstate', async (event) => {\n\t\tif (resetting_focus) return;\n\n\t\tif (event.state?.[HISTORY_INDEX]) {\n\t\t\tconst history_index = event.state[HISTORY_INDEX];\n\t\t\ttoken = {};\n\n\t\t\t// if a popstate-driven navigation is cancelled, we need to counteract it\n\t\t\t// with history.go, which means we end up back here, hence this check\n\t\t\tif (history_index === current_history_index) return;\n\n\t\t\tconst scroll = scroll_positions[history_index];\n\t\t\tconst state = event.state[STATES_KEY] ?? {};\n\t\t\tconst url = new URL(event.state[PAGE_URL_KEY] ?? location.href);\n\t\t\tconst navigation_index = event.state[NAVIGATION_INDEX];\n\t\t\tconst is_hash_change = current.url ? strip_hash(location) === strip_hash(current.url) : false;\n\t\t\tconst shallow =\n\t\t\t\tnavigation_index === current_navigation_index && (has_navigated || is_hash_change);\n\n\t\t\tif (shallow) {\n\t\t\t\t// We don't need to navigate, we just need to update scroll and/or state.\n\t\t\t\t// This happens with hash links and `pushState`/`replaceState`. The\n\t\t\t\t// exception is if we haven't navigated yet, since we could have\n\t\t\t\t// got here after a modal navigation then a reload\n\t\t\t\tif (state !== page.state) {\n\t\t\t\t\tpage.state = state;\n\t\t\t\t}\n\n\t\t\t\tupdate_url(url);\n\n\t\t\t\tscroll_positions[current_history_index] = scroll_state();\n\t\t\t\tif (scroll) scrollTo(scroll.x, scroll.y);\n\n\t\t\t\tcurrent_history_index = history_index;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst delta = history_index - current_history_index;\n\n\t\t\tawait navigate({\n\t\t\t\ttype: 'popstate',\n\t\t\t\turl,\n\t\t\t\tpopped: {\n\t\t\t\t\tstate,\n\t\t\t\t\tscroll,\n\t\t\t\t\tdelta\n\t\t\t\t},\n\t\t\t\taccept: () => {\n\t\t\t\t\tcurrent_history_index = history_index;\n\t\t\t\t\tcurrent_navigation_index = navigation_index;\n\t\t\t\t},\n\t\t\t\tblock: () => {\n\t\t\t\t\thistory.go(-delta);\n\t\t\t\t},\n\t\t\t\tnav_token: token,\n\t\t\t\tevent\n\t\t\t});\n\t\t} else {\n\t\t\t// since popstate event is also emitted when an anchor referencing the same\n\t\t\t// document is clicked, we have to check that the router isn't already handling\n\t\t\t// the navigation. otherwise we would be updating the page store twice.\n\t\t\tif (!hash_navigating) {\n\t\t\t\tconst url = new URL(location.href);\n\t\t\t\tupdate_url(url);\n\n\t\t\t\t// if the user edits the hash via the browser URL bar, trigger a full-page\n\t\t\t\t// reload to align with pathname router behavior\n\t\t\t\tif (app.hash) {\n\t\t\t\t\tlocation.reload();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\taddEventListener('hashchange', () => {\n\t\t// if the hashchange happened as a result of clicking on a link,\n\t\t// we need to update history, otherwise we have to leave it alone\n\t\tif (hash_navigating) {\n\t\t\thash_navigating = false;\n\t\t\thistory.replaceState(\n\t\t\t\t{\n\t\t\t\t\t...history.state,\n\t\t\t\t\t[HISTORY_INDEX]: ++current_history_index,\n\t\t\t\t\t[NAVIGATION_INDEX]: current_navigation_index\n\t\t\t\t},\n\t\t\t\t'',\n\t\t\t\tlocation.href\n\t\t\t);\n\t\t}\n\t});\n\n\t// fix link[rel=icon], because browsers will occasionally try to load relative\n\t// URLs after a pushState/replaceState, resulting in a 404 — see\n\t// https://github.com/sveltejs/kit/issues/3748#issuecomment-1125980897\n\tfor (const link of document.querySelectorAll('link')) {\n\t\tif (ICON_REL_ATTRIBUTES.has(link.rel)) {\n\t\t\tlink.href = link.href; // eslint-disable-line\n\t\t}\n\t}\n\n\taddEventListener('pageshow', (event) => {\n\t\t// If the user navigates to another site and then uses the back button and\n\t\t// bfcache hits, we need to set navigating to null, the site doesn't know\n\t\t// the navigation away from it was successful.\n\t\t// Info about bfcache here: https://web.dev/bfcache\n\t\tif (event.persisted) {\n\t\t\tstores.navigating.set((navigating.current = null));\n\t\t}\n\t});\n\n\t/**\n\t * @param {URL} url\n\t */\n\tfunction update_url(url) {\n\t\tcurrent.url = page.url = url;\n\t\tstores.page.set(clone_page(page));\n\t\tstores.page.notify();\n\t}\n}\n\n/**\n * @param {HTMLElement} target\n * @param {import('./types.js').HydrateOptions} opts\n */\nasync function _hydrate(\n\ttarget,\n\t{ status = 200, error, node_ids, params, route, server_route, data: server_data_nodes, form }\n) {\n\thydrated = true;\n\n\tconst url = new URL(location.href);\n\n\t/** @type {import('types').CSRRoute | undefined} */\n\tlet parsed_route;\n\n\tif (__SVELTEKIT_CLIENT_ROUTING__) {\n\t\tif (!__SVELTEKIT_EMBEDDED__) {\n\t\t\t// See https://github.com/sveltejs/kit/pull/4935#issuecomment-1328093358 for one motivation\n\t\t\t// of determining the params on the client side.\n\t\t\t({ params = {}, route = { id: null } } = (await get_navigation_intent(url, false)) || {});\n\t\t}\n\n\t\tparsed_route = routes.find(({ id }) => id === route.id);\n\t} else {\n\t\t// undefined in case of 404\n\t\tif (server_route) {\n\t\t\tparsed_route = route = parse_server_route(server_route, app.nodes);\n\t\t} else {\n\t\t\troute = { id: null };\n\t\t\tparams = {};\n\t\t}\n\t}\n\n\t/** @type {import('./types.js').NavigationFinished | undefined} */\n\tlet result;\n\tlet hydrate = true;\n\n\ttry {\n\t\tconst branch_promises = node_ids.map(async (n, i) => {\n\t\t\tconst server_data_node = server_data_nodes[i];\n\t\t\t// Type isn't completely accurate, we still need to deserialize uses\n\t\t\tif (server_data_node?.uses) {\n\t\t\t\tserver_data_node.uses = deserialize_uses(server_data_node.uses);\n\t\t\t}\n\n\t\t\treturn load_node({\n\t\t\t\tloader: app.nodes[n],\n\t\t\t\turl,\n\t\t\t\tparams,\n\t\t\t\troute,\n\t\t\t\tparent: async () => {\n\t\t\t\t\tconst data = {};\n\t\t\t\t\tfor (let j = 0; j < i; j += 1) {\n\t\t\t\t\t\tObject.assign(data, (await branch_promises[j]).data);\n\t\t\t\t\t}\n\t\t\t\t\treturn data;\n\t\t\t\t},\n\t\t\t\tserver_data_node: create_data_node(server_data_node)\n\t\t\t});\n\t\t});\n\n\t\t/** @type {Array<import('./types.js').BranchNode | undefined>} */\n\t\tconst branch = await Promise.all(branch_promises);\n\n\t\t// server-side will have compacted the branch, reinstate empty slots\n\t\t// so that error boundaries can be lined up correctly\n\t\tif (parsed_route) {\n\t\t\tconst layouts = parsed_route.layouts;\n\t\t\tfor (let i = 0; i < layouts.length; i++) {\n\t\t\t\tif (!layouts[i]) {\n\t\t\t\t\tbranch.splice(i, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tresult = await get_navigation_result_from_branch({\n\t\t\turl,\n\t\t\tparams,\n\t\t\tbranch,\n\t\t\tstatus,\n\t\t\terror,\n\t\t\terrors: parsed_route?.errors, // TODO load earlier?\n\t\t\tform,\n\t\t\troute: parsed_route ?? null\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof Redirect) {\n\t\t\t// this is a real edge case — `load` would need to return\n\t\t\t// a redirect but only in the browser\n\t\t\tawait native_navigation(new URL(error.location, location.href));\n\t\t\treturn;\n\t\t}\n\n\t\tresult = await load_root_error_page({\n\t\t\tstatus: get_status(error),\n\t\t\terror: await handle_error(error, { url, params, route }),\n\t\t\turl,\n\t\t\troute\n\t\t});\n\n\t\ttarget.textContent = '';\n\t\thydrate = false;\n\t} finally {\n\t\tquery_responses = {};\n\t}\n\n\tif (result.props.page) {\n\t\tresult.props.page.state = {};\n\t}\n\n\tawait initialize(result, target, hydrate);\n}\n\n/**\n * @param {URL} url\n * @param {boolean[]} invalid\n * @returns {Promise<import('types').ServerNodesResponse | import('types').ServerRedirectNode>}\n */\nasync function load_data(url, invalid) {\n\tconst data_url = new URL(url);\n\tdata_url.pathname = add_data_suffix(url.pathname);\n\tif (url.pathname.endsWith('/')) {\n\t\tdata_url.searchParams.append(TRAILING_SLASH_PARAM, '1');\n\t}\n\tif (DEV && url.searchParams.has(INVALIDATED_PARAM)) {\n\t\tthrow new Error(`Cannot used reserved query parameter \"${INVALIDATED_PARAM}\"`);\n\t}\n\tdata_url.searchParams.append(INVALIDATED_PARAM, invalid.map((i) => (i ? '1' : '0')).join(''));\n\n\t// use window.fetch directly to allow using a 3rd party-patched fetch implementation\n\tconst fetcher = DEV ? dev_fetch : window.fetch;\n\tconst res = await fetcher(data_url.href, {});\n\n\tif (!res.ok) {\n\t\t// error message is a JSON-stringified string which devalue can't handle at the top level\n\t\t// turn it into a HttpError to not call handleError on the client again (was already handled on the server)\n\t\t// if `__data.json` doesn't exist or the server has an internal error,\n\t\t// avoid parsing the HTML error page as a JSON\n\t\t/** @type {string | undefined} */\n\t\tlet message;\n\t\tif (res.headers.get('content-type')?.includes('application/json')) {\n\t\t\tmessage = await res.json();\n\t\t} else if (res.status === 404) {\n\t\t\tmessage = 'Not Found';\n\t\t} else if (res.status === 500) {\n\t\t\tmessage = 'Internal Error';\n\t\t}\n\t\tthrow new HttpError(res.status, message);\n\t}\n\n\t// TODO: fix eslint error / figure out if it actually applies to our situation\n\t// eslint-disable-next-line\n\treturn new Promise(async (resolve) => {\n\t\t/**\n\t\t * Map of deferred promises that will be resolved by a subsequent chunk of data\n\t\t * @type {Map<string, import('types').Deferred>}\n\t\t */\n\t\tconst deferreds = new Map();\n\t\tconst reader = /** @type {ReadableStream<Uint8Array>} */ (res.body).getReader();\n\n\t\t/**\n\t\t * @param {any} data\n\t\t */\n\t\tfunction deserialize(data) {\n\t\t\treturn devalue.unflatten(data, {\n\t\t\t\t...app.decoders,\n\t\t\t\tPromise: (id) => {\n\t\t\t\t\treturn new Promise((fulfil, reject) => {\n\t\t\t\t\t\tdeferreds.set(id, { fulfil, reject });\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tlet text = '';\n\n\t\twhile (true) {\n\t\t\t// Format follows ndjson (each line is a JSON object) or regular JSON spec\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done && !text) break;\n\n\t\t\ttext += !value && text ? '\\n' : text_decoder.decode(value, { stream: true }); // no value -> final chunk -> add a new line to trigger the last parse\n\n\t\t\twhile (true) {\n\t\t\t\tconst split = text.indexOf('\\n');\n\t\t\t\tif (split === -1) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst node = JSON.parse(text.slice(0, split));\n\t\t\t\ttext = text.slice(split + 1);\n\n\t\t\t\tif (node.type === 'redirect') {\n\t\t\t\t\treturn resolve(node);\n\t\t\t\t}\n\n\t\t\t\tif (node.type === 'data') {\n\t\t\t\t\t// This is the first (and possibly only, if no pending promises) chunk\n\t\t\t\t\tnode.nodes?.forEach((/** @type {any} */ node) => {\n\t\t\t\t\t\tif (node?.type === 'data') {\n\t\t\t\t\t\t\tnode.uses = deserialize_uses(node.uses);\n\t\t\t\t\t\t\tnode.data = deserialize(node.data);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve(node);\n\t\t\t\t} else if (node.type === 'chunk') {\n\t\t\t\t\t// This is a subsequent chunk containing deferred data\n\t\t\t\t\tconst { id, data, error } = node;\n\t\t\t\t\tconst deferred = /** @type {import('types').Deferred} */ (deferreds.get(id));\n\t\t\t\t\tdeferreds.delete(id);\n\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tdeferred.reject(deserialize(error));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdeferred.fulfil(deserialize(data));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\t// TODO edge case handling necessary? stream() read fails?\n}\n\n/**\n * @param {any} uses\n * @return {import('types').Uses}\n */\nfunction deserialize_uses(uses) {\n\treturn {\n\t\tdependencies: new Set(uses?.dependencies ?? []),\n\t\tparams: new Set(uses?.params ?? []),\n\t\tparent: !!uses?.parent,\n\t\troute: !!uses?.route,\n\t\turl: !!uses?.url,\n\t\tsearch_params: new Set(uses?.search_params ?? [])\n\t};\n}\n\n/**\n * This flag is used to avoid client-side navigation when we're only using\n * `location.replace()` to set focus.\n */\nlet resetting_focus = false;\n\n/**\n * @param {URL} url\n * @param {boolean} [scroll]\n */\nfunction reset_focus(url, scroll = true) {\n\tconst autofocus = document.querySelector('[autofocus]');\n\tif (autofocus) {\n\t\t// @ts-ignore\n\t\tautofocus.focus();\n\t} else {\n\t\t// Reset page selection and focus\n\n\t\t// Mimic the browsers' behaviour and set the sequential focus navigation\n\t\t// starting point to the fragment identifier.\n\t\tconst id = get_id(url);\n\t\tif (id && document.getElementById(id)) {\n\t\t\tconst { x, y } = scroll_state();\n\n\t\t\t// `element.focus()` doesn't work on Safari and Firefox Ubuntu so we need\n\t\t\t// to use this hack with `location.replace()` instead.\n\t\t\tsetTimeout(() => {\n\t\t\t\tconst history_state = history.state;\n\n\t\t\t\tresetting_focus = true;\n\t\t\t\tlocation.replace(new URL(`#${id}`, location.href));\n\n\t\t\t\t// Firefox has a bug that sets the history state to `null` so we need to\n\t\t\t\t// restore it after. See https://bugzilla.mozilla.org/show_bug.cgi?id=1199924\n\t\t\t\t// This is also needed to restore the original hash if we're using hash routing\n\t\t\t\thistory.replaceState(history_state, '', url);\n\n\t\t\t\t// If scroll management has already happened earlier, we need to restore\n\t\t\t\t// the scroll position after setting the sequential focus navigation starting point\n\t\t\t\tif (scroll) scrollTo(x, y);\n\t\t\t\tresetting_focus = false;\n\t\t\t});\n\t\t} else {\n\t\t\t// If the ID doesn't exist, we try to mimic browsers' behaviour as closely\n\t\t\t// as possible by targeting the first scrollable region. Unfortunately, it's\n\t\t\t// not a perfect match — e.g. shift-tabbing won't immediately cycle up from\n\t\t\t// the end of the page on Chromium\n\t\t\t// See https://html.spec.whatwg.org/multipage/interaction.html#get-the-focusable-area\n\t\t\tconst root = document.body;\n\t\t\tconst tabindex = root.getAttribute('tabindex');\n\n\t\t\troot.tabIndex = -1;\n\t\t\t// @ts-expect-error options.focusVisible is only supported in Firefox\n\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#browser_compatibility\n\t\t\troot.focus({ preventScroll: true, focusVisible: false });\n\n\t\t\t// restore `tabindex` as to prevent `root` from stealing input from elements\n\t\t\tif (tabindex !== null) {\n\t\t\t\troot.setAttribute('tabindex', tabindex);\n\t\t\t} else {\n\t\t\t\troot.removeAttribute('tabindex');\n\t\t\t}\n\t\t}\n\n\t\t// capture current selection, so we can compare the state after\n\t\t// snapshot restoration and afterNavigate callbacks have run\n\t\tconst selection = getSelection();\n\n\t\tif (selection && selection.type !== 'None') {\n\t\t\t/** @type {Range[]} */\n\t\t\tconst ranges = [];\n\n\t\t\tfor (let i = 0; i < selection.rangeCount; i += 1) {\n\t\t\t\tranges.push(selection.getRangeAt(i));\n\t\t\t}\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (selection.rangeCount !== ranges.length) return;\n\n\t\t\t\tfor (let i = 0; i < selection.rangeCount; i += 1) {\n\t\t\t\t\tconst a = ranges[i];\n\t\t\t\t\tconst b = selection.getRangeAt(i);\n\n\t\t\t\t\t// we need to do a deep comparison rather than just `a !== b` because\n\t\t\t\t\t// Safari behaves differently to other browsers\n\t\t\t\t\tif (\n\t\t\t\t\t\ta.commonAncestorContainer !== b.commonAncestorContainer ||\n\t\t\t\t\t\ta.startContainer !== b.startContainer ||\n\t\t\t\t\t\ta.endContainer !== b.endContainer ||\n\t\t\t\t\t\ta.startOffset !== b.startOffset ||\n\t\t\t\t\t\ta.endOffset !== b.endOffset\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// if the selection hasn't changed (as a result of an element being (auto)focused,\n\t\t\t\t// or a programmatic selection, we reset everything as part of the navigation)\n\t\t\t\t// fixes https://github.com/sveltejs/kit/issues/8439\n\t\t\t\tselection.removeAllRanges();\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * @template {import('@sveltejs/kit').NavigationType} T\n * @param {import('./types.js').NavigationState} current\n * @param {import('./types.js').NavigationIntent | undefined} intent\n * @param {URL | null} url\n * @param {T} type\n * @param {{ x: number, y: number } | null} [target_scroll] The scroll position for the target (for popstate navigations)\n */\nfunction create_navigation(current, intent, url, type, target_scroll = null) {\n\t/** @type {(value: any) => void} */\n\tlet fulfil;\n\n\t/** @type {(error: any) => void} */\n\tlet reject;\n\n\tconst complete = new Promise((f, r) => {\n\t\tfulfil = f;\n\t\treject = r;\n\t});\n\n\t// Handle any errors off-chain so that it doesn't show up as an unhandled rejection\n\tcomplete.catch(() => {});\n\n\t/** @type {(import('@sveltejs/kit').Navigation | import('@sveltejs/kit').AfterNavigate) & { type: T }} */\n\tconst navigation = /** @type {any} */ ({\n\t\tfrom: {\n\t\t\tparams: current.params,\n\t\t\troute: { id: current.route?.id ?? null },\n\t\t\turl: current.url,\n\t\t\tscroll: scroll_state()\n\t\t},\n\t\tto: url && {\n\t\t\tparams: intent?.params ?? null,\n\t\t\troute: { id: intent?.route?.id ?? null },\n\t\t\turl,\n\t\t\tscroll: target_scroll\n\t\t},\n\t\twillUnload: !intent,\n\t\ttype,\n\t\tcomplete\n\t});\n\n\treturn {\n\t\tnavigation,\n\t\t// @ts-expect-error\n\t\tfulfil,\n\t\t// @ts-expect-error\n\t\treject\n\t};\n}\n\n/**\n * TODO: remove this in 3.0 when the page store is also removed\n *\n * We need to assign a new page object so that subscribers are correctly notified.\n * However, spreading `{ ...page }` returns an empty object so we manually\n * assign to each property instead.\n *\n * @param {import('@sveltejs/kit').Page} page\n */\nfunction clone_page(page) {\n\treturn {\n\t\tdata: page.data,\n\t\terror: page.error,\n\t\tform: page.form,\n\t\tparams: page.params,\n\t\troute: page.route,\n\t\tstate: page.state,\n\t\tstatus: page.status,\n\t\turl: page.url\n\t};\n}\n\n/**\n * @param {URL} url\n * @returns {URL}\n */\nfunction decode_hash(url) {\n\tconst new_url = new URL(url);\n\t// Safari, for some reason, does change # to %23, when entered through the address bar\n\tnew_url.hash = decodeURIComponent(url.hash);\n\treturn new_url;\n}\n\n/**\n * @param {URL} url\n * @returns {string}\n */\nfunction get_id(url) {\n\tlet id;\n\n\tif (app.hash) {\n\t\tconst [, , second] = url.hash.split('#', 3);\n\t\tid = second ?? '';\n\t} else {\n\t\tid = url.hash.slice(1);\n\t}\n\n\treturn decodeURIComponent(id);\n}\n\nif (DEV) {\n\t// Nasty hack to silence harmless warnings the user can do nothing about\n\tconst console_warn = console.warn;\n\tconsole.warn = function warn(...args) {\n\t\tif (\n\t\t\targs.length === 1 &&\n\t\t\t/<(Layout|Page|Error)(_[\\w$]+)?> was created (with unknown|without expected) prop '(data|form)'/.test(\n\t\t\t\targs[0]\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconsole_warn(...args);\n\t};\n\n\tif (import.meta.hot) {\n\t\timport.meta.hot.on('vite:beforeUpdate', () => {\n\t\t\tif (errored) {\n\t\t\t\tlocation.reload();\n\t\t\t}\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/constants.js",
    "content": "export const SNAPSHOT_KEY = 'sveltekit:snapshot';\nexport const SCROLL_KEY = 'sveltekit:scroll';\nexport const STATES_KEY = 'sveltekit:states';\nexport const PAGE_URL_KEY = 'sveltekit:pageurl';\n\nexport const HISTORY_INDEX = 'sveltekit:history';\nexport const NAVIGATION_INDEX = 'sveltekit:navigation';\n\nexport const PRELOAD_PRIORITIES = /** @type {const} */ ({\n\ttap: 1,\n\thover: 2,\n\tviewport: 3,\n\teager: 4,\n\toff: -1,\n\tfalse: -1\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/client/entry.js",
    "content": "// we expose this as a separate entry point (rather than treating client.js as the entry point)\n// so that everything other than `start`/`load_css` can be treeshaken\nexport { start, load_css } from './client.js';\n"
  },
  {
    "path": "packages/kit/src/runtime/client/fetcher.js",
    "content": "import { BROWSER, DEV } from 'esm-env';\nimport { hash } from '../../utils/hash.js';\nimport { base64_decode } from '../utils.js';\n\nlet loading = 0;\n\n/** @type {typeof fetch} */\nconst native_fetch = BROWSER ? window.fetch : /** @type {any} */ (() => {});\n\nexport function lock_fetch() {\n\tloading += 1;\n}\n\nexport function unlock_fetch() {\n\tloading -= 1;\n}\n\nif (DEV && BROWSER) {\n\tlet can_inspect_stack_trace = false;\n\n\t// detect whether async stack traces work\n\t// eslint-disable-next-line @typescript-eslint/require-await\n\tconst check_stack_trace = async () => {\n\t\tconst stack = /** @type {string} */ (new Error().stack);\n\t\tcan_inspect_stack_trace = stack.includes('check_stack_trace');\n\t};\n\n\tvoid check_stack_trace();\n\n\t/**\n\t * @param {RequestInfo | URL} input\n\t * @param {RequestInit & Record<string, any> | undefined} init\n\t */\n\twindow.fetch = (input, init) => {\n\t\t// Check if fetch was called via load_node. the lock method only checks if it was called at the\n\t\t// same time, but not necessarily if it was called from `load`.\n\t\t// We use just the filename as the method name sometimes does not appear on the CI.\n\t\tconst url = input instanceof Request ? input.url : input.toString();\n\t\tconst stack_array = /** @type {string} */ (new Error().stack).split('\\n');\n\t\t// We need to do a cutoff because Safari and Firefox maintain the stack\n\t\t// across events and for example traces a `fetch` call triggered from a button\n\t\t// back to the creation of the event listener and the element creation itself,\n\t\t// where at some point client.js will show up, leading to false positives.\n\t\tconst cutoff = stack_array.findIndex((a) => a.includes('load@') || a.includes('at load'));\n\t\tconst stack = stack_array.slice(0, cutoff + 2).join('\\n');\n\n\t\tconst in_load_heuristic = can_inspect_stack_trace\n\t\t\t? stack.includes('src/runtime/client/client.js')\n\t\t\t: loading;\n\n\t\t// This flag is set in initial_fetch and subsequent_fetch\n\t\tconst used_kit_fetch = init?.__sveltekit_fetch__;\n\n\t\tif (in_load_heuristic && !used_kit_fetch) {\n\t\t\tconsole.warn(\n\t\t\t\t`Loading ${url} using \\`window.fetch\\`. For best results, use the \\`fetch\\` that is passed to your \\`load\\` function: https://svelte.dev/docs/kit/load#making-fetch-requests`\n\t\t\t);\n\t\t}\n\n\t\tconst method = input instanceof Request ? input.method : init?.method || 'GET';\n\n\t\tif (method !== 'GET') {\n\t\t\tcache.delete(build_selector(input));\n\t\t}\n\n\t\treturn native_fetch(input, init);\n\t};\n} else if (BROWSER) {\n\twindow.fetch = (input, init) => {\n\t\tconst method = input instanceof Request ? input.method : init?.method || 'GET';\n\n\t\tif (method !== 'GET') {\n\t\t\tcache.delete(build_selector(input));\n\t\t}\n\n\t\treturn native_fetch(input, init);\n\t};\n}\n\nconst cache = new Map();\n\n/**\n * Should be called on the initial run of load functions that hydrate the page.\n * Saves any requests with cache-control max-age to the cache.\n * @param {URL | string} resource\n * @param {RequestInit} [opts]\n */\nexport function initial_fetch(resource, opts) {\n\tconst selector = build_selector(resource, opts);\n\n\tconst script = document.querySelector(selector);\n\tif (script?.textContent) {\n\t\tscript.remove(); // In case multiple script tags match the same selector\n\t\tlet { body, ...init } = JSON.parse(script.textContent);\n\n\t\tconst ttl = script.getAttribute('data-ttl');\n\t\tif (ttl) cache.set(selector, { body, init, ttl: 1000 * Number(ttl) });\n\t\tconst b64 = script.getAttribute('data-b64');\n\t\tif (b64 !== null) {\n\t\t\t// Can't use native_fetch('data:...;base64,${body}')\n\t\t\t// csp can block the request\n\t\t\tbody = base64_decode(body);\n\t\t}\n\n\t\treturn Promise.resolve(new Response(body, init));\n\t}\n\n\treturn DEV ? dev_fetch(resource, opts) : window.fetch(resource, opts);\n}\n\n/**\n * Tries to get the response from the cache, if max-age allows it, else does a fetch.\n * @param {URL | string} resource\n * @param {string} resolved\n * @param {RequestInit} [opts]\n */\nexport function subsequent_fetch(resource, resolved, opts) {\n\tif (cache.size > 0) {\n\t\tconst selector = build_selector(resource, opts);\n\t\tconst cached = cache.get(selector);\n\t\tif (cached) {\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Request/cache#value\n\t\t\tif (\n\t\t\t\tperformance.now() < cached.ttl &&\n\t\t\t\t['default', 'force-cache', 'only-if-cached', undefined].includes(opts?.cache)\n\t\t\t) {\n\t\t\t\treturn new Response(cached.body, cached.init);\n\t\t\t}\n\n\t\t\tcache.delete(selector);\n\t\t}\n\t}\n\n\treturn DEV ? dev_fetch(resolved, opts) : window.fetch(resolved, opts);\n}\n\n/**\n * @param {RequestInfo | URL} resource\n * @param {RequestInit & Record<string, any> | undefined} opts\n */\nexport function dev_fetch(resource, opts) {\n\tconst patched_opts = { ...opts };\n\t// This assigns the __sveltekit_fetch__ flag and makes it non-enumerable\n\tObject.defineProperty(patched_opts, '__sveltekit_fetch__', {\n\t\tvalue: true,\n\t\twritable: true,\n\t\tconfigurable: true\n\t});\n\treturn window.fetch(resource, patched_opts);\n}\n\n/**\n * Build the cache key for a given request\n * @param {URL | RequestInfo} resource\n * @param {RequestInit} [opts]\n */\nfunction build_selector(resource, opts) {\n\tconst url = JSON.stringify(resource instanceof Request ? resource.url : resource);\n\n\tlet selector = `script[data-sveltekit-fetched][data-url=${url}]`;\n\n\tif (opts?.headers || opts?.body) {\n\t\t/** @type {import('types').StrictBody[]} */\n\t\tconst values = [];\n\n\t\tif (opts.headers) {\n\t\t\tvalues.push([...new Headers(opts.headers)].join(','));\n\t\t}\n\n\t\tif (opts.body && (typeof opts.body === 'string' || ArrayBuffer.isView(opts.body))) {\n\t\t\tvalues.push(opts.body);\n\t\t}\n\n\t\tselector += `[data-hash=\"${hash(...values)}\"]`;\n\t}\n\n\treturn selector;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/parse.js",
    "content": "import { exec, parse_route_id } from '../../utils/routing.js';\n\n/**\n * @param {import('./types.js').SvelteKitApp} app\n * @returns {import('types').CSRRoute[]}\n */\nexport function parse({ nodes, server_loads, dictionary, matchers }) {\n\tconst layouts_with_server_load = new Set(server_loads);\n\n\treturn Object.entries(dictionary).map(([id, [leaf, layouts, errors]]) => {\n\t\tconst { pattern, params } = parse_route_id(id);\n\n\t\t/** @type {import('types').CSRRoute} */\n\t\tconst route = {\n\t\t\tid,\n\t\t\t/** @param {string} path */\n\t\t\texec: (path) => {\n\t\t\t\tconst match = pattern.exec(path);\n\t\t\t\tif (match) return exec(match, params, matchers);\n\t\t\t},\n\t\t\terrors: [1, ...(errors || [])].map((n) => nodes[n]),\n\t\t\tlayouts: [0, ...(layouts || [])].map(create_layout_loader),\n\t\t\tleaf: create_leaf_loader(leaf)\n\t\t};\n\n\t\t// bit of a hack, but ensures that layout/error node lists are the same\n\t\t// length, without which the wrong data will be applied if the route\n\t\t// manifest looks like `[[a, b], [c,], d]`\n\t\troute.errors.length = route.layouts.length = Math.max(\n\t\t\troute.errors.length,\n\t\t\troute.layouts.length\n\t\t);\n\n\t\treturn route;\n\t});\n\n\t/**\n\t * @param {number} id\n\t * @returns {[boolean, import('types').CSRPageNodeLoader]}\n\t */\n\tfunction create_leaf_loader(id) {\n\t\t// whether or not the route uses the server data is\n\t\t// encoded using the ones' complement, to save space\n\t\tconst uses_server_data = id < 0;\n\t\tif (uses_server_data) id = ~id;\n\t\treturn [uses_server_data, nodes[id]];\n\t}\n\n\t/**\n\t * @param {number | undefined} id\n\t * @returns {[boolean, import('types').CSRPageNodeLoader] | undefined}\n\t */\n\tfunction create_layout_loader(id) {\n\t\t// whether or not the layout uses the server data is\n\t\t// encoded in the layouts array, to save space\n\t\treturn id === undefined ? id : [layouts_with_server_load.has(id), nodes[id]];\n\t}\n}\n\n/**\n * @param {import('types').CSRRouteServer} input\n * @param {import('types').CSRPageNodeLoader[]} app_nodes Will be modified if a new node is loaded that's not already in the array\n * @returns {import('types').CSRRoute}\n */\nexport function parse_server_route({ nodes, id, leaf, layouts, errors }, app_nodes) {\n\treturn {\n\t\tid,\n\t\texec: () => ({}), // dummy function; exec already happened on the server\n\t\t// By writing to app_nodes only when a loader at that index is not already defined,\n\t\t// we ensure that loaders have referential equality when they load the same node.\n\t\t// Code elsewhere in client.js relies on this referential equality to determine\n\t\t// if a loader is different and should therefore (re-)run.\n\t\terrors: errors.map((n) => (n ? (app_nodes[n] ||= nodes[n]) : undefined)),\n\t\tlayouts: layouts.map((n) => (n ? [n[0], (app_nodes[n[1]] ||= nodes[n[1]])] : undefined)),\n\t\tleaf: [leaf[0], (app_nodes[leaf[1]] ||= nodes[leaf[1]])]\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/remote-functions/command.svelte.js",
    "content": "/** @import { RemoteCommand, RemoteQueryOverride } from '@sveltejs/kit' */\n/** @import { RemoteFunctionResponse } from 'types' */\n/** @import { Query } from './query.svelte.js' */\nimport { app_dir, base } from '$app/paths/internal/client';\nimport * as devalue from 'devalue';\nimport { HttpError } from '@sveltejs/kit/internal';\nimport { app } from '../client.js';\nimport { stringify_remote_arg } from '../../shared.js';\nimport { get_remote_request_headers, refresh_queries, release_overrides } from './shared.svelte.js';\n\n/**\n * Client-version of the `command` function from `$app/server`.\n * @param {string} id\n * @returns {RemoteCommand<any, any>}\n */\nexport function command(id) {\n\t/** @type {number} */\n\tlet pending_count = $state(0);\n\n\t// Careful: This function MUST be synchronous (can't use the async keyword) because the return type has to be a promise with an updates() method.\n\t// If we make it async, the return type will be a promise that resolves to a promise with an updates() method, which is not what we want.\n\t/** @type {RemoteCommand<any, any>} */\n\tconst command_function = (arg) => {\n\t\t/** @type {Array<Query<any> | RemoteQueryOverride>} */\n\t\tlet updates = [];\n\n\t\t// Increment pending count when command starts\n\t\tpending_count++;\n\n\t\t// Noone should call commands during rendering but belts and braces.\n\t\t// Do this here, after await Svelte' reactivity context is gone.\n\t\tconst headers = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t...get_remote_request_headers()\n\t\t};\n\n\t\t/** @type {Promise<any> & { updates: (...args: any[]) => any }} */\n\t\tconst promise = (async () => {\n\t\t\ttry {\n\t\t\t\t// Wait a tick to give room for the `updates` method to be called\n\t\t\t\tawait Promise.resolve();\n\n\t\t\t\tconst response = await fetch(`${base}/${app_dir}/remote/${id}`, {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tpayload: stringify_remote_arg(arg, app.hooks.transport),\n\t\t\t\t\t\trefreshes: updates.map((u) => u._key)\n\t\t\t\t\t}),\n\t\t\t\t\theaders\n\t\t\t\t});\n\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\trelease_overrides(updates);\n\t\t\t\t\t// We only end up here in case of a network error or if the server has an internal error\n\t\t\t\t\t// (which shouldn't happen because we handle errors on the server and always send a 200 response)\n\t\t\t\t\tthrow new Error('Failed to execute remote function');\n\t\t\t\t}\n\n\t\t\t\tconst result = /** @type {RemoteFunctionResponse} */ (await response.json());\n\t\t\t\tif (result.type === 'redirect') {\n\t\t\t\t\trelease_overrides(updates);\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Redirects are not allowed in commands. Return a result instead and use goto on the client'\n\t\t\t\t\t);\n\t\t\t\t} else if (result.type === 'error') {\n\t\t\t\t\trelease_overrides(updates);\n\t\t\t\t\tthrow new HttpError(result.status ?? 500, result.error);\n\t\t\t\t} else {\n\t\t\t\t\tif (result.refreshes) {\n\t\t\t\t\t\trefresh_queries(result.refreshes, updates);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn devalue.parse(result.result, app.decoders);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\t// Decrement pending count when command completes\n\t\t\t\tpending_count--;\n\t\t\t}\n\t\t})();\n\n\t\tpromise.updates = (/** @type {any} */ ...args) => {\n\t\t\tupdates = args;\n\t\t\t// @ts-expect-error Don't allow updates to be called multiple times\n\t\t\tdelete promise.updates;\n\t\t\treturn promise;\n\t\t};\n\n\t\treturn promise;\n\t};\n\n\tObject.defineProperty(command_function, 'pending', {\n\t\tget: () => pending_count\n\t});\n\n\treturn command_function;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/remote-functions/form.svelte.js",
    "content": "/** @import { StandardSchemaV1 } from '@standard-schema/spec' */\n/** @import { RemoteFormInput, RemoteForm, RemoteQueryOverride } from '@sveltejs/kit' */\n/** @import { InternalRemoteFormIssue, RemoteFunctionResponse } from 'types' */\n/** @import { Query } from './query.svelte.js' */\nimport { app_dir, base } from '$app/paths/internal/client';\nimport * as devalue from 'devalue';\nimport { DEV } from 'esm-env';\nimport { HttpError } from '@sveltejs/kit/internal';\nimport { app, query_responses, _goto, set_nearest_error_page, invalidateAll } from '../client.js';\nimport { tick } from 'svelte';\nimport { refresh_queries, release_overrides } from './shared.svelte.js';\nimport { createAttachmentKey } from 'svelte/attachments';\nimport {\n\tconvert_formdata,\n\tflatten_issues,\n\tcreate_field_proxy,\n\tdeep_set,\n\tset_nested_value,\n\tthrow_on_old_property_access,\n\tbuild_path_string,\n\tnormalize_issue,\n\tserialize_binary_form,\n\tBINARY_FORM_CONTENT_TYPE\n} from '../../form-utils.js';\n\n/**\n * Merge client issues into server issues. Server issues are persisted unless\n * a client-issue exists for the same path, in which case the client-issue overrides it.\n * @param {FormData} form_data\n * @param {InternalRemoteFormIssue[]} current_issues\n * @param {InternalRemoteFormIssue[]} client_issues\n * @returns {InternalRemoteFormIssue[]}\n */\nfunction merge_with_server_issues(form_data, current_issues, client_issues) {\n\tconst merged = [\n\t\t...current_issues.filter(\n\t\t\t(issue) => issue.server && !client_issues.some((i) => i.name === issue.name)\n\t\t),\n\t\t...client_issues\n\t];\n\n\tconst keys = Array.from(form_data.keys());\n\n\treturn merged.sort((a, b) => keys.indexOf(a.name) - keys.indexOf(b.name));\n}\n\n/**\n * Client-version of the `form` function from `$app/server`.\n * @template {RemoteFormInput} T\n * @template U\n * @param {string} id\n * @returns {RemoteForm<T, U>}\n */\nexport function form(id) {\n\t/** @type {Map<any, { count: number, instance: RemoteForm<T, U> }>} */\n\t// eslint-disable-next-line svelte/prefer-svelte-reactivity -- we don't need reactivity for this\n\tconst instances = new Map();\n\n\t/** @param {string | number | boolean} [key] */\n\tfunction create_instance(key) {\n\t\tconst action_id_without_key = id;\n\t\tconst action_id = id + (key != undefined ? `/${JSON.stringify(key)}` : '');\n\t\tconst action = '?/remote=' + encodeURIComponent(action_id);\n\n\t\t/**\n\t\t * @type {Record<string, string | string[] | File | File[]>}\n\t\t */\n\t\tlet input = $state({});\n\n\t\t/** @type {InternalRemoteFormIssue[]} */\n\t\tlet raw_issues = $state.raw([]);\n\n\t\tconst issues = $derived(flatten_issues(raw_issues));\n\n\t\t/** @type {any} */\n\t\tlet result = $state.raw(query_responses[action_id]);\n\n\t\t/** @type {number} */\n\t\tlet pending_count = $state(0);\n\n\t\t/** @type {StandardSchemaV1 | undefined} */\n\t\tlet preflight_schema = undefined;\n\n\t\t/** @type {HTMLFormElement | null} */\n\t\tlet element = null;\n\n\t\t/** @type {Record<string, boolean>} */\n\t\tlet touched = {};\n\n\t\tlet submitted = false;\n\n\t\t/**\n\t\t * @param {FormData} form_data\n\t\t * @returns {Record<string, any>}\n\t\t */\n\t\tfunction convert(form_data) {\n\t\t\tconst data = convert_formdata(form_data);\n\t\t\tif (key !== undefined && !form_data.has('id')) {\n\t\t\t\tdata.id = key;\n\t\t\t}\n\t\t\treturn data;\n\t\t}\n\n\t\t/**\n\t\t * @param {HTMLFormElement} form\n\t\t * @param {FormData} form_data\n\t\t * @param {Parameters<RemoteForm<any, any>['enhance']>[0]} callback\n\t\t */\n\t\tasync function handle_submit(form, form_data, callback) {\n\t\t\tconst data = convert(form_data);\n\n\t\t\tsubmitted = true;\n\n\t\t\t// Increment pending count immediately so that `pending` reflects\n\t\t\t// the in-progress state during async preflight validation\n\t\t\tpending_count++;\n\n\t\t\tconst validated = await preflight_schema?.['~standard'].validate(data);\n\n\t\t\tif (validated?.issues) {\n\t\t\t\traw_issues = merge_with_server_issues(\n\t\t\t\t\tform_data,\n\t\t\t\t\traw_issues,\n\t\t\t\t\tvalidated.issues.map((issue) => normalize_issue(issue, false))\n\t\t\t\t);\n\t\t\t\tpending_count--;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Preflight passed - clear stale client-side preflight issues\n\t\t\tif (preflight_schema) {\n\t\t\t\traw_issues = raw_issues.filter((issue) => issue.server);\n\t\t\t}\n\n\t\t\t// TODO 3.0 remove this warning\n\t\t\tif (DEV) {\n\t\t\t\tconst error = () => {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Remote form functions no longer get passed a FormData object. The payload is now a POJO. See https://kit.svelte.dev/docs/remote-functions#form for details.'\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tfor (const key of [\n\t\t\t\t\t'append',\n\t\t\t\t\t'delete',\n\t\t\t\t\t'entries',\n\t\t\t\t\t'forEach',\n\t\t\t\t\t'get',\n\t\t\t\t\t'getAll',\n\t\t\t\t\t'has',\n\t\t\t\t\t'keys',\n\t\t\t\t\t'set',\n\t\t\t\t\t'values'\n\t\t\t\t]) {\n\t\t\t\t\tif (!(key in data)) {\n\t\t\t\t\t\tObject.defineProperty(data, key, { get: error });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tawait callback({\n\t\t\t\t\tform,\n\t\t\t\t\tdata,\n\t\t\t\t\tsubmit: () => submit(form_data)\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tconst error = e instanceof HttpError ? e.body : { message: /** @type {any} */ (e).message };\n\t\t\t\tconst status = e instanceof HttpError ? e.status : 500;\n\t\t\t\tvoid set_nearest_error_page(error, status);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * @param {FormData} data\n\t\t * @returns {Promise<any> & { updates: (...args: any[]) => any }}\n\t\t */\n\t\tfunction submit(data) {\n\t\t\t// Store a reference to the current instance and increment the usage count for the duration\n\t\t\t// of the request. This ensures that the instance is not deleted in case of an optimistic update\n\t\t\t// (e.g. when deleting an item in a list) that fails and wants to surface an error to the user afterwards.\n\t\t\t// If the instance would be deleted in the meantime, the error property would be assigned to the old,\n\t\t\t// no-longer-visible instance, so it would never be shown to the user.\n\t\t\tconst entry = instances.get(key);\n\t\t\tif (entry) {\n\t\t\t\tentry.count++;\n\t\t\t}\n\n\t\t\t/** @type {Array<Query<any> | RemoteQueryOverride>} */\n\t\t\tlet updates = [];\n\n\t\t\t/** @type {Promise<any> & { updates: (...args: any[]) => any }} */\n\t\t\tconst promise = (async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait Promise.resolve();\n\n\t\t\t\t\tconst { blob } = serialize_binary_form(convert(data), {\n\t\t\t\t\t\tremote_refreshes: updates.map((u) => u._key)\n\t\t\t\t\t});\n\n\t\t\t\t\tconst response = await fetch(`${base}/${app_dir}/remote/${action_id_without_key}`, {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t\t\t// Forms cannot be called during rendering, so it's save to use location here\n\t\t\t\t\t\t\t'x-sveltekit-pathname': location.pathname,\n\t\t\t\t\t\t\t'x-sveltekit-search': location.search\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: blob\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!response.ok) {\n\t\t\t\t\t\t// We only end up here in case of a network error or if the server has an internal error\n\t\t\t\t\t\t// (which shouldn't happen because we handle errors on the server and always send a 200 response)\n\t\t\t\t\t\tthrow new Error('Failed to execute remote function');\n\t\t\t\t\t}\n\n\t\t\t\t\tconst form_result = /** @type { RemoteFunctionResponse} */ (await response.json());\n\n\t\t\t\t\t// reset issues in case it's a redirect or error (but issues passed in that case)\n\t\t\t\t\traw_issues = [];\n\n\t\t\t\t\tif (form_result.type === 'result') {\n\t\t\t\t\t\t({ issues: raw_issues = [], result } = devalue.parse(form_result.result, app.decoders));\n\n\t\t\t\t\t\tif (issues.$) {\n\t\t\t\t\t\t\trelease_overrides(updates);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (form_result.refreshes) {\n\t\t\t\t\t\t\t\trefresh_queries(form_result.refreshes, updates);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tvoid invalidateAll();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (form_result.type === 'redirect') {\n\t\t\t\t\t\tconst refreshes = form_result.refreshes ?? '';\n\t\t\t\t\t\tconst invalidateAll = !refreshes && updates.length === 0;\n\t\t\t\t\t\tif (!invalidateAll) {\n\t\t\t\t\t\t\trefresh_queries(refreshes, updates);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Use internal version to allow redirects to external URLs\n\t\t\t\t\t\tvoid _goto(form_result.location, { invalidateAll }, 0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new HttpError(form_result.status ?? 500, form_result.error);\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tresult = undefined;\n\t\t\t\t\trelease_overrides(updates);\n\t\t\t\t\tthrow e;\n\t\t\t\t} finally {\n\t\t\t\t\t// Decrement pending count when submission completes\n\t\t\t\t\tpending_count--;\n\n\t\t\t\t\tvoid tick().then(() => {\n\t\t\t\t\t\tif (entry) {\n\t\t\t\t\t\t\tentry.count--;\n\t\t\t\t\t\t\tif (entry.count === 0) {\n\t\t\t\t\t\t\t\tinstances.delete(key);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})();\n\n\t\t\tpromise.updates = (...args) => {\n\t\t\t\tupdates = args;\n\t\t\t\treturn promise;\n\t\t\t};\n\n\t\t\treturn promise;\n\t\t}\n\n\t\t/** @type {RemoteForm<T, U>} */\n\t\tconst instance = {};\n\n\t\tinstance.method = 'POST';\n\t\tinstance.action = action;\n\n\t\t/** @param {Parameters<RemoteForm<any, any>['enhance']>[0]} callback */\n\t\tconst form_onsubmit = (callback) => {\n\t\t\t/** @param {SubmitEvent} event */\n\t\t\treturn async (event) => {\n\t\t\t\tconst form = /** @type {HTMLFormElement} */ (event.target);\n\t\t\t\tconst method = event.submitter?.hasAttribute('formmethod')\n\t\t\t\t\t? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formMethod\n\t\t\t\t\t: clone(form).method;\n\n\t\t\t\tif (method !== 'post') return;\n\n\t\t\t\t// eslint-disable-next-line svelte/prefer-svelte-reactivity\n\t\t\t\tconst action = new URL(\n\t\t\t\t\t// We can't do submitter.formAction directly because that property is always set\n\t\t\t\t\tevent.submitter?.hasAttribute('formaction')\n\t\t\t\t\t\t? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formAction\n\t\t\t\t\t\t: clone(form).action\n\t\t\t\t);\n\n\t\t\t\tif (action.searchParams.get('/remote') !== action_id) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst target = event.submitter?.hasAttribute('formtarget')\n\t\t\t\t\t? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formTarget\n\t\t\t\t\t: clone(form).target;\n\n\t\t\t\tif (target === '_blank') {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tconst form_data = new FormData(form, event.submitter);\n\n\t\t\t\tif (DEV) {\n\t\t\t\t\tvalidate_form_data(form_data, clone(form).enctype);\n\t\t\t\t}\n\n\t\t\t\tawait handle_submit(form, form_data, callback);\n\t\t\t};\n\t\t};\n\n\t\t/** @param {(event: SubmitEvent) => void} onsubmit */\n\t\tfunction create_attachment(onsubmit) {\n\t\t\treturn (/** @type {HTMLFormElement} */ form) => {\n\t\t\t\tif (element) {\n\t\t\t\t\tlet message = `A form object can only be attached to a single \\`<form>\\` element`;\n\t\t\t\t\tif (DEV && !key) {\n\t\t\t\t\t\tconst name = id.split('/').pop();\n\t\t\t\t\t\tmessage += `. To create multiple instances, use \\`${name}.for(key)\\``;\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new Error(message);\n\t\t\t\t}\n\n\t\t\t\telement = form;\n\n\t\t\t\ttouched = {};\n\n\t\t\t\tform.addEventListener('submit', onsubmit);\n\n\t\t\t\t/** @param {Event} e */\n\t\t\t\tconst handle_input = (e) => {\n\t\t\t\t\t// strictly speaking it can be an HTMLTextAreaElement or HTMLSelectElement\n\t\t\t\t\t// but that makes the types unnecessarily awkward\n\t\t\t\t\tconst element = /** @type {HTMLInputElement} */ (e.target);\n\n\t\t\t\t\tlet name = element.name;\n\t\t\t\t\tif (!name) return;\n\n\t\t\t\t\tconst is_array = name.endsWith('[]');\n\t\t\t\t\tif (is_array) name = name.slice(0, -2);\n\n\t\t\t\t\tconst is_file = element.type === 'file';\n\n\t\t\t\t\ttouched[name] = true;\n\n\t\t\t\t\tif (is_array) {\n\t\t\t\t\t\tlet value;\n\n\t\t\t\t\t\tif (element.tagName === 'SELECT') {\n\t\t\t\t\t\t\tvalue = Array.from(\n\t\t\t\t\t\t\t\telement.querySelectorAll('option:checked'),\n\t\t\t\t\t\t\t\t(e) => /** @type {HTMLOptionElement} */ (e).value\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst elements = /** @type {HTMLInputElement[]} */ (\n\t\t\t\t\t\t\t\tArray.from(form.querySelectorAll(`[name=\"${name}[]\"]`))\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (DEV) {\n\t\t\t\t\t\t\t\tfor (const e of elements) {\n\t\t\t\t\t\t\t\t\tif ((e.type === 'file') !== is_file) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t\t`Cannot mix and match file and non-file inputs under the same name (\"${element.name}\")`\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tvalue = is_file\n\t\t\t\t\t\t\t\t? elements.map((input) => Array.from(input.files ?? [])).flat()\n\t\t\t\t\t\t\t\t: elements.map((element) => element.value);\n\t\t\t\t\t\t\tif (element.type === 'checkbox') {\n\t\t\t\t\t\t\t\tvalue = /** @type {string[]} */ (value.filter((_, i) => elements[i].checked));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tset_nested_value(input, name, value);\n\t\t\t\t\t} else if (is_file) {\n\t\t\t\t\t\tif (DEV && element.multiple) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Can only use the \\`multiple\\` attribute when \\`name\\` includes a \\`[]\\` suffix — consider changing \"${name}\" to \"${name}[]\"`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst file = /** @type {HTMLInputElement & { files: FileList }} */ (element).files[0];\n\n\t\t\t\t\t\tif (file) {\n\t\t\t\t\t\t\tset_nested_value(input, name, file);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Remove the property by setting to undefined and clean up\n\t\t\t\t\t\t\tconst path_parts = name.split(/\\.|\\[|\\]/).filter(Boolean);\n\t\t\t\t\t\t\tlet current = /** @type {any} */ (input);\n\t\t\t\t\t\t\tfor (let i = 0; i < path_parts.length - 1; i++) {\n\t\t\t\t\t\t\t\tif (current[path_parts[i]] == null) return;\n\t\t\t\t\t\t\t\tcurrent = current[path_parts[i]];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdelete current[path_parts[path_parts.length - 1]];\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tset_nested_value(\n\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\telement.type === 'checkbox' && !element.checked ? null : element.value\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tname = name.replace(/^[nb]:/, '');\n\n\t\t\t\t\ttouched[name] = true;\n\t\t\t\t};\n\n\t\t\t\tform.addEventListener('input', handle_input);\n\n\t\t\t\tconst handle_reset = async () => {\n\t\t\t\t\t// need to wait a moment, because the `reset` event occurs before\n\t\t\t\t\t// the inputs are actually updated (so that it can be cancelled)\n\t\t\t\t\tawait tick();\n\n\t\t\t\t\tinput = convert_formdata(new FormData(form));\n\t\t\t\t};\n\n\t\t\t\tform.addEventListener('reset', handle_reset);\n\n\t\t\t\treturn () => {\n\t\t\t\t\tform.removeEventListener('submit', onsubmit);\n\t\t\t\t\tform.removeEventListener('input', handle_input);\n\t\t\t\t\tform.removeEventListener('reset', handle_reset);\n\t\t\t\t\telement = null;\n\t\t\t\t\tpreflight_schema = undefined;\n\t\t\t\t};\n\t\t\t};\n\t\t}\n\n\t\tinstance[createAttachmentKey()] = create_attachment(\n\t\t\tform_onsubmit(({ submit, form }) =>\n\t\t\t\tsubmit().then(() => {\n\t\t\t\t\tif (!issues.$) {\n\t\t\t\t\t\tform.reset();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\tlet validate_id = 0;\n\n\t\t// TODO 3.0 remove\n\t\tif (DEV) {\n\t\t\tthrow_on_old_property_access(instance);\n\n\t\t\tObject.defineProperty(instance, 'buttonProps', {\n\t\t\t\tget() {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'`form.buttonProps` has been removed: Instead of `<button {...form.buttonProps}>, use `<button {...form.fields.action.as(\"submit\", \"value\")}>`.' +\n\t\t\t\t\t\t\t' See the PR for more info: https://github.com/sveltejs/kit/pull/14622'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tObject.defineProperties(instance, {\n\t\t\tfields: {\n\t\t\t\tget: () =>\n\t\t\t\t\tcreate_field_proxy(\n\t\t\t\t\t\t{},\n\t\t\t\t\t\t() => input,\n\t\t\t\t\t\t(path, value) => {\n\t\t\t\t\t\t\tif (path.length === 0) {\n\t\t\t\t\t\t\t\tinput = value;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdeep_set(input, path.map(String), value);\n\n\t\t\t\t\t\t\t\tconst key = build_path_string(path);\n\t\t\t\t\t\t\t\ttouched[key] = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => issues\n\t\t\t\t\t)\n\t\t\t},\n\t\t\tresult: {\n\t\t\t\tget: () => result\n\t\t\t},\n\t\t\tpending: {\n\t\t\t\tget: () => pending_count\n\t\t\t},\n\t\t\tpreflight: {\n\t\t\t\t/** @type {RemoteForm<T, U>['preflight']} */\n\t\t\t\tvalue: (schema) => {\n\t\t\t\t\tpreflight_schema = schema;\n\t\t\t\t\treturn instance;\n\t\t\t\t}\n\t\t\t},\n\t\t\tvalidate: {\n\t\t\t\t/** @type {RemoteForm<any, any>['validate']} */\n\t\t\t\tvalue: async ({ includeUntouched = false, preflightOnly = false } = {}) => {\n\t\t\t\t\tif (!element) return;\n\n\t\t\t\t\tconst id = ++validate_id;\n\n\t\t\t\t\t// wait a tick in case the user is calling validate() right after set() which takes time to propagate\n\t\t\t\t\tawait tick();\n\n\t\t\t\t\tconst default_submitter = /** @type {HTMLElement | undefined} */ (\n\t\t\t\t\t\telement.querySelector('button:not([type]), [type=\"submit\"]')\n\t\t\t\t\t);\n\n\t\t\t\t\tconst form_data = new FormData(element, default_submitter);\n\n\t\t\t\t\t/** @type {InternalRemoteFormIssue[]} */\n\t\t\t\t\tlet array = [];\n\n\t\t\t\t\tconst data = convert(form_data);\n\n\t\t\t\t\tconst validated = await preflight_schema?.['~standard'].validate(data);\n\n\t\t\t\t\tif (validate_id !== id) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (validated?.issues) {\n\t\t\t\t\t\tarray = validated.issues.map((issue) => normalize_issue(issue, false));\n\t\t\t\t\t} else if (!preflightOnly) {\n\t\t\t\t\t\tconst response = await fetch(`${base}/${app_dir}/remote/${action_id_without_key}`, {\n\t\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t\t\t\t// Validation should not be and will not be called during rendering, so it's save to use location here\n\t\t\t\t\t\t\t\t'x-sveltekit-pathname': location.pathname,\n\t\t\t\t\t\t\t\t'x-sveltekit-search': location.search\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tbody: serialize_binary_form(data, {\n\t\t\t\t\t\t\t\tvalidate_only: true\n\t\t\t\t\t\t\t}).blob\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst result = await response.json();\n\n\t\t\t\t\t\tif (validate_id !== id) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (result.type === 'result') {\n\t\t\t\t\t\t\tarray = /** @type {InternalRemoteFormIssue[]} */ (\n\t\t\t\t\t\t\t\tdevalue.parse(result.result, app.decoders)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!includeUntouched && !submitted) {\n\t\t\t\t\t\tarray = array.filter((issue) => touched[issue.name]);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst is_server_validation = !validated?.issues && !preflightOnly;\n\n\t\t\t\t\traw_issues = is_server_validation\n\t\t\t\t\t\t? array\n\t\t\t\t\t\t: merge_with_server_issues(form_data, raw_issues, array);\n\t\t\t\t}\n\t\t\t},\n\t\t\tenhance: {\n\t\t\t\t/** @type {RemoteForm<any, any>['enhance']} */\n\t\t\t\tvalue: (callback) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\taction,\n\t\t\t\t\t\t[createAttachmentKey()]: create_attachment(form_onsubmit(callback))\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn instance;\n\t}\n\n\tconst instance = create_instance();\n\n\tObject.defineProperty(instance, 'for', {\n\t\t/** @type {RemoteForm<T, U>['for']} */\n\t\tvalue: (key) => {\n\t\t\tconst entry = instances.get(key) ?? { count: 0, instance: create_instance(key) };\n\n\t\t\ttry {\n\t\t\t\t$effect.pre(() => {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tentry.count--;\n\n\t\t\t\t\t\tvoid tick().then(() => {\n\t\t\t\t\t\t\tif (entry.count === 0) {\n\t\t\t\t\t\t\t\tinstances.delete(key);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tentry.count += 1;\n\t\t\t\tinstances.set(key, entry);\n\t\t\t} catch {\n\t\t\t\t// not in an effect context\n\t\t\t}\n\n\t\t\treturn entry.instance;\n\t\t}\n\t});\n\n\treturn instance;\n}\n\n/**\n * Shallow clone an element, so that we can access e.g. `form.action` without worrying\n * that someone has added an `<input name=\"action\">` (https://github.com/sveltejs/kit/issues/7593)\n * @template {HTMLElement} T\n * @param {T} element\n * @returns {T}\n */\nfunction clone(element) {\n\treturn /** @type {T} */ (HTMLElement.prototype.cloneNode.call(element));\n}\n\n/**\n * @param {FormData} form_data\n * @param {string} enctype\n */\nfunction validate_form_data(form_data, enctype) {\n\tfor (const key of form_data.keys()) {\n\t\tif (/^\\$[.[]?/.test(key)) {\n\t\t\tthrow new Error(\n\t\t\t\t'`$` is used to collect all FormData validation issues and cannot be used as the `name` of a form control'\n\t\t\t);\n\t\t}\n\t}\n\n\tif (enctype !== 'multipart/form-data') {\n\t\tfor (const value of form_data.values()) {\n\t\t\tif (value instanceof File) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Your form contains <input type=\"file\"> 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.'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/remote-functions/index.js",
    "content": "export { command } from './command.svelte.js';\nexport { form } from './form.svelte.js';\nexport { prerender } from './prerender.svelte.js';\nexport { query, query_batch } from './query.svelte.js';\n"
  },
  {
    "path": "packages/kit/src/runtime/client/remote-functions/prerender.svelte.js",
    "content": "/** @import { RemotePrerenderFunction } from '@sveltejs/kit' */\nimport { app_dir, base } from '$app/paths/internal/client';\nimport { version } from '__sveltekit/environment';\nimport * as devalue from 'devalue';\nimport { DEV } from 'esm-env';\nimport { app, prerender_responses } from '../client.js';\nimport { get_remote_request_headers, remote_request } from './shared.svelte.js';\nimport { create_remote_key, stringify_remote_arg } from '../../shared.js';\n\n// Initialize Cache API for prerender functions\nconst CACHE_NAME = DEV ? `sveltekit:${Date.now()}` : `sveltekit:${version}`;\n/** @type {Cache | undefined} */\nlet prerender_cache;\n\nconst prerender_cache_ready = (async () => {\n\tif (typeof caches !== 'undefined') {\n\t\ttry {\n\t\t\tprerender_cache = await caches.open(CACHE_NAME);\n\n\t\t\t// Clean up old cache versions\n\t\t\tconst cache_names = await caches.keys();\n\t\t\tfor (const cache_name of cache_names) {\n\t\t\t\tif (cache_name.startsWith('sveltekit:') && cache_name !== CACHE_NAME) {\n\t\t\t\t\tawait caches.delete(cache_name);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.warn('Failed to initialize SvelteKit cache:', error);\n\t\t}\n\t}\n})();\n\n/**\n * @param {string} url\n * @param {string} encoded\n */\nfunction put(url, encoded) {\n\treturn /** @type {Cache} */ (prerender_cache)\n\t\t.put(\n\t\t\turl,\n\t\t\t// We need to create a new response because the original response is already consumed\n\t\t\tnew Response(encoded, {\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json'\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t\t.catch(() => {\n\t\t\t// Nothing we can do here\n\t\t});\n}\n\n/**\n * @param {string} id\n * @returns {RemotePrerenderFunction<any, any>}\n */\nexport function prerender(id) {\n\treturn (arg) => {\n\t\tconst payload = stringify_remote_arg(arg, app.hooks.transport);\n\t\tconst cache_key = create_remote_key(id, payload);\n\n\t\tlet resource = prerender_resources.get(cache_key)?.deref();\n\n\t\tif (!resource) {\n\t\t\tresource = new Prerender(async () => {\n\t\t\t\tawait prerender_cache_ready;\n\n\t\t\t\tconst url = `${base}/${app_dir}/remote/${id}${payload ? `/${payload}` : ''}`;\n\n\t\t\t\tif (Object.hasOwn(prerender_responses, cache_key)) {\n\t\t\t\t\tconst data = prerender_responses[cache_key];\n\n\t\t\t\t\tif (prerender_cache) {\n\t\t\t\t\t\tvoid put(url, devalue.stringify(data, app.encoders));\n\t\t\t\t\t}\n\n\t\t\t\t\treturn data;\n\t\t\t\t}\n\n\t\t\t\t// Do this here, after await Svelte' reactivity context is gone.\n\t\t\t\tconst headers = get_remote_request_headers();\n\n\t\t\t\t// Check the Cache API first\n\t\t\t\tif (prerender_cache) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst cached_response = await prerender_cache.match(url);\n\n\t\t\t\t\t\tif (cached_response) {\n\t\t\t\t\t\t\tconst cached_result = await cached_response.text();\n\t\t\t\t\t\t\treturn devalue.parse(cached_result, app.decoders);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tvoid prerender_cache.delete(url);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst encoded = await remote_request(url, headers);\n\n\t\t\t\t// For successful prerender requests, save to cache\n\t\t\t\tif (prerender_cache) {\n\t\t\t\t\tvoid put(url, encoded);\n\t\t\t\t}\n\n\t\t\t\treturn devalue.parse(encoded, app.decoders);\n\t\t\t});\n\n\t\t\tprerender_resources.set(cache_key, new WeakRef(resource));\n\t\t\tprerender_resource_cleanup?.register(resource, cache_key);\n\t\t}\n\n\t\treturn resource;\n\t};\n}\n\n/** @type {Map<string, WeakRef<Prerender<any>>>} */\n// eslint-disable-next-line svelte/prefer-svelte-reactivity\nconst prerender_resources = new Map();\n\n/** @type {FinalizationRegistry<string> | null} */\nconst prerender_resource_cleanup =\n\ttypeof FinalizationRegistry === 'undefined'\n\t\t? null\n\t\t: new FinalizationRegistry((cache_key) => {\n\t\t\t\tconst ref = prerender_resources.get(cache_key);\n\t\t\t\tif (ref && ref.deref() === undefined) {\n\t\t\t\t\tprerender_resources.delete(cache_key);\n\t\t\t\t}\n\t\t\t});\n\n/**\n * @template T\n * @implements {Promise<T>}\n */\nclass Prerender {\n\t/** @type {Promise<T>} */\n\t#promise;\n\n\t#loading = $state(true);\n\t#ready = $state(false);\n\t/** @type {T | undefined} */\n\t#current = $state.raw();\n\n\t#error = $state.raw(undefined);\n\n\t/**\n\t * @param {() => Promise<T>} fn\n\t */\n\tconstructor(fn) {\n\t\tthis.#promise = fn().then(\n\t\t\t(value) => {\n\t\t\t\tthis.#loading = false;\n\t\t\t\tthis.#ready = true;\n\t\t\t\tthis.#current = value;\n\t\t\t\tthis.#error = undefined;\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tthis.#loading = false;\n\t\t\t\tthis.#error = error;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t *\n\t * @param {((value: any) => any) | null | undefined} onfulfilled\n\t * @param {((reason: any) => any) | null | undefined} [onrejected]\n\t * @returns\n\t */\n\tthen(onfulfilled, onrejected) {\n\t\treturn this.#promise.then(onfulfilled, onrejected);\n\t}\n\n\t/**\n\t * @param {((reason: any) => any) | null | undefined} onrejected\n\t */\n\tcatch(onrejected) {\n\t\treturn this.#promise.catch(onrejected);\n\t}\n\n\t/**\n\t * @param {(() => any) | null | undefined} onfinally\n\t */\n\tfinally(onfinally) {\n\t\treturn this.#promise.finally(onfinally);\n\t}\n\n\tget current() {\n\t\treturn this.#current;\n\t}\n\n\tget error() {\n\t\treturn this.#error;\n\t}\n\n\t/**\n\t * Returns true if the resource is loading.\n\t */\n\tget loading() {\n\t\treturn this.#loading;\n\t}\n\n\t/**\n\t * Returns true once the resource has been loaded.\n\t */\n\tget ready() {\n\t\treturn this.#ready;\n\t}\n\n\tget [Symbol.toStringTag]() {\n\t\treturn 'Prerender';\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/remote-functions/query.svelte.js",
    "content": "/** @import { RemoteQueryFunction } from '@sveltejs/kit' */\n/** @import { RemoteFunctionResponse } from 'types' */\nimport { app_dir, base } from '$app/paths/internal/client';\nimport { app, goto, query_map, query_responses } from '../client.js';\nimport { get_remote_request_headers, remote_request } from './shared.svelte.js';\nimport * as devalue from 'devalue';\nimport { HttpError, Redirect } from '@sveltejs/kit/internal';\nimport { DEV } from 'esm-env';\nimport { with_resolvers } from '../../../utils/promise.js';\nimport { tick, untrack } from 'svelte';\nimport { create_remote_key, stringify_remote_arg, unfriendly_hydratable } from '../../shared.js';\n\n/**\n * @template T\n * @typedef {{\n *   count: number;\n *   resource: Query<T>;\n *   cleanup: () => void;\n * }} RemoteQueryCacheEntry\n */\n\n/**\n * @returns {boolean} Returns `true` if we are in an effect\n */\nfunction is_in_effect() {\n\ttry {\n\t\t$effect.pre(() => {});\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * @param {string} id\n * @returns {RemoteQueryFunction<any, any>}\n */\nexport function query(id) {\n\tif (DEV) {\n\t\t// If this reruns as part of HMR, refresh the query\n\t\tfor (const [key, entry] of query_map) {\n\t\t\tif (key === id || key.startsWith(id + '/')) {\n\t\t\t\t// use optional chaining in case a prerender function was turned into a query\n\t\t\t\tvoid entry.resource.refresh?.();\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (arg) => {\n\t\treturn new QueryProxy(id, arg, async (key, payload) => {\n\t\t\tconst url = `${base}/${app_dir}/remote/${id}${payload ? `?payload=${payload}` : ''}`;\n\n\t\t\tconst serialized = await unfriendly_hydratable(key, () =>\n\t\t\t\tremote_request(url, get_remote_request_headers())\n\t\t\t);\n\n\t\t\treturn devalue.parse(serialized, app.decoders);\n\t\t});\n\t};\n}\n\n/**\n * @param {string} id\n * @returns {RemoteQueryFunction<any, any>}\n */\nexport function query_batch(id) {\n\t/** @type {Map<string, Array<{resolve: (value: any) => void, reject: (error: any) => void}>>} */\n\t// eslint-disable-next-line svelte/prefer-svelte-reactivity -- we don't need reactivity for this\n\tlet batching = new Map();\n\n\treturn (arg) => {\n\t\treturn new QueryProxy(id, arg, async (key, payload) => {\n\t\t\tconst serialized = await unfriendly_hydratable(key, () => {\n\t\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\t\t// create_remote_function caches identical calls, but in case a refresh to the same query is called multiple times this function\n\t\t\t\t\t// is invoked multiple times with the same payload, so we need to deduplicate here\n\t\t\t\t\tconst entry = batching.get(payload) ?? [];\n\t\t\t\t\tentry.push({ resolve, reject });\n\t\t\t\t\tbatching.set(payload, entry);\n\n\t\t\t\t\tif (batching.size > 1) return;\n\n\t\t\t\t\t// Do this here, after await Svelte' reactivity context is gone.\n\t\t\t\t\t// TODO is it possible to have batches of the same key\n\t\t\t\t\t// but in different forks/async contexts and in the same macrotask?\n\t\t\t\t\t// If so this would potentially be buggy\n\t\t\t\t\tconst headers = {\n\t\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t\t...get_remote_request_headers()\n\t\t\t\t\t};\n\n\t\t\t\t\t// Wait for the next macrotask - don't use microtask as Svelte runtime uses these to collect changes and flush them,\n\t\t\t\t\t// and flushes could reveal more queries that should be batched.\n\t\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\t\tconst batched = batching;\n\t\t\t\t\t\t// eslint-disable-next-line svelte/prefer-svelte-reactivity\n\t\t\t\t\t\tbatching = new Map();\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst response = await fetch(`${base}/${app_dir}/remote/${id}`, {\n\t\t\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\t\t\t\tpayloads: Array.from(batched.keys())\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\theaders\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (!response.ok) {\n\t\t\t\t\t\t\t\tthrow new Error('Failed to execute batch query');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst result = /** @type {RemoteFunctionResponse} */ (await response.json());\n\t\t\t\t\t\t\tif (result.type === 'error') {\n\t\t\t\t\t\t\t\tthrow new HttpError(result.status ?? 500, result.error);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (result.type === 'redirect') {\n\t\t\t\t\t\t\t\tawait goto(result.location);\n\t\t\t\t\t\t\t\tthrow new Redirect(307, result.location);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst results = devalue.parse(result.result, app.decoders);\n\n\t\t\t\t\t\t\t// Resolve individual queries\n\t\t\t\t\t\t\t// Maps guarantee insertion order so we can do it like this\n\t\t\t\t\t\t\tlet i = 0;\n\n\t\t\t\t\t\t\tfor (const resolvers of batched.values()) {\n\t\t\t\t\t\t\t\tfor (const { resolve, reject } of resolvers) {\n\t\t\t\t\t\t\t\t\tif (results[i].type === 'error') {\n\t\t\t\t\t\t\t\t\t\treject(new HttpError(results[i].status, results[i].error));\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tresolve(results[i].data);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t// Reject all queries in the batch\n\t\t\t\t\t\t\tfor (const resolver of batched.values()) {\n\t\t\t\t\t\t\t\tfor (const { reject } of resolver) {\n\t\t\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 0);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\treturn devalue.parse(serialized, app.decoders);\n\t\t});\n\t};\n}\n\n/**\n * @template T\n * @implements {Promise<T>}\n */\nexport class Query {\n\t/**\n\t * @readonly\n\t * @type {string}\n\t */\n\t_key;\n\n\t/** @type {() => Promise<T>} */\n\t#fn;\n\t#loading = $state(true);\n\t/** @type {Array<(value: undefined) => void>} */\n\t#latest = [];\n\n\t/** @type {boolean} */\n\t#ready = $state(false);\n\t/** @type {T | undefined} */\n\t#raw = $state.raw();\n\t/** @type {Promise<void> | null} */\n\t#promise = $state.raw(null);\n\t/** @type {Array<(old: T) => T>} */\n\t#overrides = $state([]);\n\n\t/** @type {T | undefined} */\n\t#current = $derived.by(() => {\n\t\t// don't reduce undefined value\n\t\tif (!this.#ready) return undefined;\n\n\t\treturn this.#overrides.reduce((v, r) => r(v), /** @type {T} */ (this.#raw));\n\t});\n\n\t#error = $state.raw(undefined);\n\n\t/** @type {Promise<T>['then']} */\n\t// @ts-expect-error TS doesn't understand that the promise returns something\n\t#then = $derived.by(() => {\n\t\tconst p = this.#get_promise();\n\t\tthis.#overrides.length;\n\n\t\treturn (resolve, reject) => {\n\t\t\tconst result = p.then(tick).then(() => /** @type {T} */ (this.#current));\n\n\t\t\tif (resolve || reject) {\n\t\t\t\treturn result.then(resolve, reject);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\t});\n\n\t/**\n\t * @param {string} key\n\t * @param {() => Promise<T>} fn\n\t */\n\tconstructor(key, fn) {\n\t\tthis._key = key;\n\t\tthis.#fn = fn;\n\t}\n\n\t#get_promise() {\n\t\tvoid untrack(() => (this.#promise ??= this.#run()));\n\t\treturn /** @type {Promise<T>} */ (this.#promise);\n\t}\n\n\t#start() {\n\t\t// there is a really weird bug with untrack and writes and initializations\n\t\t// every time you see this comment, try removing the `tick.then` here and see\n\t\t// if all the tests still pass with the latest svelte version\n\t\t// if they do, congrats, you can remove tick.then\n\t\tvoid tick().then(() => this.#get_promise());\n\t}\n\n\t#run() {\n\t\tthis.#loading = true;\n\n\t\tconst { promise, resolve, reject } = with_resolvers();\n\n\t\tthis.#latest.push(resolve);\n\n\t\tPromise.resolve(this.#fn())\n\t\t\t.then((value) => {\n\t\t\t\t// Skip the response if resource was refreshed with a later promise while we were waiting for this one to resolve\n\t\t\t\tconst idx = this.#latest.indexOf(resolve);\n\t\t\t\tif (idx === -1) return;\n\n\t\t\t\tthis.#latest.splice(0, idx).forEach((r) => r(undefined));\n\t\t\t\tthis.#ready = true;\n\t\t\t\tthis.#loading = false;\n\t\t\t\tthis.#raw = value;\n\t\t\t\tthis.#error = undefined;\n\n\t\t\t\tresolve(undefined);\n\t\t\t})\n\t\t\t.catch((e) => {\n\t\t\t\tconst idx = this.#latest.indexOf(resolve);\n\t\t\t\tif (idx === -1) return;\n\n\t\t\t\tthis.#latest.splice(0, idx).forEach((r) => r(undefined));\n\t\t\t\tthis.#error = e;\n\t\t\t\tthis.#loading = false;\n\t\t\t\treject(e);\n\t\t\t});\n\n\t\treturn promise;\n\t}\n\n\tget then() {\n\t\treturn this.#then;\n\t}\n\n\tget catch() {\n\t\tthis.#then;\n\t\treturn (/** @type {any} */ reject) => {\n\t\t\treturn this.#then(undefined, reject);\n\t\t};\n\t}\n\n\tget finally() {\n\t\tthis.#then;\n\t\treturn (/** @type {any} */ fn) => {\n\t\t\treturn this.#then(\n\t\t\t\t(value) => {\n\t\t\t\t\tfn();\n\t\t\t\t\treturn value;\n\t\t\t\t},\n\t\t\t\t(error) => {\n\t\t\t\t\tfn();\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t);\n\t\t};\n\t}\n\n\tget current() {\n\t\tthis.#start();\n\t\treturn this.#current;\n\t}\n\n\tget error() {\n\t\tthis.#start();\n\t\treturn this.#error;\n\t}\n\n\t/**\n\t * Returns true if the resource is loading or reloading.\n\t */\n\tget loading() {\n\t\tthis.#start();\n\t\treturn this.#loading;\n\t}\n\n\t/**\n\t * Returns true once the resource has been loaded for the first time.\n\t */\n\tget ready() {\n\t\tthis.#start();\n\t\treturn this.#ready;\n\t}\n\n\t/**\n\t * @returns {Promise<void>}\n\t */\n\trefresh() {\n\t\tdelete query_responses[this._key];\n\t\treturn (this.#promise = this.#run());\n\t}\n\n\t/**\n\t * @param {T} value\n\t */\n\tset(value) {\n\t\tthis.#ready = true;\n\t\tthis.#loading = false;\n\t\tthis.#error = undefined;\n\t\tthis.#raw = value;\n\t\tthis.#promise = Promise.resolve();\n\t}\n\n\t/**\n\t * @param {(old: T) => T} fn\n\t * @returns {{ _key: string, release: () => void }}\n\t */\n\twithOverride(fn) {\n\t\tthis.#overrides.push(fn);\n\n\t\treturn {\n\t\t\t_key: this._key,\n\t\t\trelease: () => {\n\t\t\t\tconst i = this.#overrides.indexOf(fn);\n\n\t\t\t\tif (i !== -1) {\n\t\t\t\t\tthis.#overrides.splice(i, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tget [Symbol.toStringTag]() {\n\t\treturn 'Query';\n\t}\n}\n\n/**\n * Manages the caching layer between the user and the actual {@link Query} instance.\n *\n * @template T\n * @implements {Promise<T>}\n */\nclass QueryProxy {\n\t_key;\n\t#payload;\n\t#fn;\n\t#active = true;\n\t/**\n\t * Whether this proxy was created in a tracking context.\n\t * @readonly\n\t */\n\t#tracking = is_in_effect();\n\n\t/**\n\t * @param {string} id\n\t * @param {any} arg\n\t * @param {(key: string, payload: string) => Promise<T>} fn\n\t */\n\tconstructor(id, arg, fn) {\n\t\tthis.#payload = stringify_remote_arg(arg, app.hooks.transport);\n\t\tthis._key = create_remote_key(id, this.#payload);\n\t\tthis.#fn = fn;\n\n\t\tif (!this.#tracking) {\n\t\t\tthis.#active = false;\n\t\t\treturn;\n\t\t}\n\n\t\tconst entry = this.#get_or_create_cache_entry();\n\n\t\t$effect.pre(() => () => {\n\t\t\tconst die = this.#release(entry);\n\t\t\tvoid tick().then(die);\n\t\t});\n\t}\n\n\t/** @returns {RemoteQueryCacheEntry<T>} */\n\t#get_or_create_cache_entry() {\n\t\tlet cached = query_map.get(this._key);\n\n\t\tif (!cached) {\n\t\t\tconst c = (cached = {\n\t\t\t\tcount: 0,\n\t\t\t\tresource: /** @type {Query<T>} */ (/** @type {unknown} */ (null)),\n\t\t\t\tcleanup: /** @type {() => void} */ (/** @type {unknown} */ (null))\n\t\t\t});\n\n\t\t\tc.cleanup = $effect.root(() => {\n\t\t\t\tc.resource = new Query(this._key, () => this.#fn(this._key, this.#payload));\n\t\t\t});\n\n\t\t\tquery_map.set(this._key, cached);\n\t\t}\n\n\t\tcached.count += 1;\n\n\t\treturn cached;\n\t}\n\n\t/**\n\t * @param {RemoteQueryCacheEntry<T>} entry\n\t * @param {boolean} [deactivate]\n\t * @returns\n\t */\n\t#release(entry, deactivate = true) {\n\t\tthis.#active &&= !deactivate;\n\t\tentry.count -= 1;\n\n\t\treturn () => {\n\t\t\t// have to get this again in case it was cleaned up by someone else, then re-added and now\n\t\t\t// we're cleaning it up. this seems extremely unlikely but it literally can't hurt\n\t\t\tconst cached = query_map.get(this._key);\n\t\t\tif (cached?.count === 0) {\n\t\t\t\tcached.cleanup();\n\t\t\t\tquery_map.delete(this._key);\n\t\t\t}\n\t\t};\n\t}\n\n\t#get_cached_query() {\n\t\t// TODO iterate on error messages\n\t\tif (!this.#tracking) {\n\t\t\tthrow new Error(\n\t\t\t\t'This query was not created in a reactive context and is limited to calling `.run`, `.refresh`, and `.set`.'\n\t\t\t);\n\t\t}\n\n\t\tif (!this.#active) {\n\t\t\tthrow new Error(\n\t\t\t\t'This query instance is no longer active and can no longer be used for reactive state access. ' +\n\t\t\t\t\t'This typically means you created the query in a tracking context and stashed it somewhere outside of a tracking context.'\n\t\t\t);\n\t\t}\n\n\t\tconst cached = query_map.get(this._key);\n\n\t\tif (!cached) {\n\t\t\t// The only case where `this.#active` can be `true` is when we've added an entry to `query_map`, and the\n\t\t\t// only way that entry can get removed is if this instance (and all others) have been deactivated.\n\t\t\t// So if we get here, someone (us, check git blame and point fingers) did `entry.count -= 1` improperly.\n\t\t\tthrow new Error(\n\t\t\t\t'No cached query found. This should be impossible. Please file a bug report.'\n\t\t\t);\n\t\t}\n\n\t\treturn cached.resource;\n\t}\n\n\t#safe_get_cached_query() {\n\t\treturn query_map.get(this._key)?.resource;\n\t}\n\n\tget current() {\n\t\treturn this.#get_cached_query().current;\n\t}\n\n\tget error() {\n\t\treturn this.#get_cached_query().error;\n\t}\n\n\tget loading() {\n\t\treturn this.#get_cached_query().loading;\n\t}\n\n\tget ready() {\n\t\treturn this.#get_cached_query().ready;\n\t}\n\n\trun() {\n\t\tif (is_in_effect()) {\n\t\t\tthrow new Error(\n\t\t\t\t'On the client, .run() can only be called outside render, e.g. in universal `load` functions and event handlers. In render, await the query directly'\n\t\t\t);\n\t\t}\n\n\t\tif (Object.hasOwn(query_responses, this._key)) {\n\t\t\treturn Promise.resolve(query_responses[this._key]);\n\t\t}\n\t\treturn this.#fn(this._key, this.#payload);\n\t}\n\n\trefresh() {\n\t\treturn this.#safe_get_cached_query()?.refresh() ?? Promise.resolve();\n\t}\n\n\t/** @type {Query<T>['set']} */\n\tset(value) {\n\t\tthis.#safe_get_cached_query()?.set(value);\n\t}\n\n\t/** @type {Query<T>['withOverride']} */\n\twithOverride(fn) {\n\t\tconst entry = this.#get_or_create_cache_entry();\n\t\tconst override = entry.resource.withOverride(fn);\n\n\t\treturn {\n\t\t\t_key: override._key,\n\t\t\trelease: () => {\n\t\t\t\toverride.release();\n\t\t\t\tthis.#release(entry, false)();\n\t\t\t}\n\t\t};\n\t}\n\n\t/** @type {Query<T>['then']} */\n\tget then() {\n\t\tconst cached = this.#get_cached_query();\n\t\treturn cached.then.bind(cached);\n\t}\n\n\t/** @type {Query<T>['catch']} */\n\tget catch() {\n\t\tconst cached = this.#get_cached_query();\n\t\treturn cached.catch.bind(cached);\n\t}\n\n\t/** @type {Query<T>['finally']} */\n\tget finally() {\n\t\tconst cached = this.#get_cached_query();\n\t\treturn cached.finally.bind(cached);\n\t}\n\n\tget [Symbol.toStringTag]() {\n\t\treturn 'QueryProxy';\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/remote-functions/shared.svelte.js",
    "content": "/** @import { RemoteQueryOverride } from '@sveltejs/kit' */\n/** @import { RemoteFunctionResponse } from 'types' */\n/** @import { Query } from './query.svelte.js' */\nimport * as devalue from 'devalue';\nimport { app, goto, query_map } from '../client.js';\nimport { HttpError, Redirect } from '@sveltejs/kit/internal';\nimport { untrack } from 'svelte';\nimport { navigating, page } from '../state.svelte.js';\n\n/**\n * @returns {{ 'x-sveltekit-pathname': string, 'x-sveltekit-search': string }}\n */\nexport function get_remote_request_headers() {\n\t// This will be the correct value of the current or soon-current url,\n\t// even in forks because it's state-based - therefore not using window.location.\n\t// Use untrack(...) to Avoid accidental reactive dependency on pathname/search\n\treturn untrack(() => {\n\t\tconst url = navigating.current?.to?.url ?? page.url;\n\n\t\treturn {\n\t\t\t'x-sveltekit-pathname': url.pathname,\n\t\t\t'x-sveltekit-search': url.search\n\t\t};\n\t});\n}\n\n/**\n * @param {string} url\n * @param {HeadersInit} headers\n */\nexport async function remote_request(url, headers) {\n\tconst response = await fetch(url, {\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json',\n\t\t\t...headers\n\t\t}\n\t});\n\n\tif (!response.ok) {\n\t\tthrow new HttpError(500, 'Failed to execute remote function');\n\t}\n\n\tconst result = /** @type {RemoteFunctionResponse} */ (await response.json());\n\n\tif (result.type === 'redirect') {\n\t\tawait goto(result.location);\n\t\tthrow new Redirect(307, result.location);\n\t}\n\n\tif (result.type === 'error') {\n\t\tthrow new HttpError(result.status ?? 500, result.error);\n\t}\n\n\treturn result.result;\n}\n\n/**\n * @param {Array<Query<any> | RemoteQueryOverride>} updates\n */\nexport function release_overrides(updates) {\n\tfor (const update of updates) {\n\t\tif ('release' in update) {\n\t\t\tupdate.release();\n\t\t}\n\t}\n}\n\n/**\n * @param {string} stringified_refreshes\n * @param {Array<Query<any> | RemoteQueryOverride>} updates\n */\nexport function refresh_queries(stringified_refreshes, updates = []) {\n\tconst refreshes = Object.entries(devalue.parse(stringified_refreshes, app.decoders));\n\n\t// `refreshes` is a superset of `updates`\n\tfor (const [key, value] of refreshes) {\n\t\t// If there was an optimistic update, release it right before we update the query\n\t\tconst update = updates.find((u) => u._key === key);\n\t\tif (update && 'release' in update) {\n\t\t\tupdate.release();\n\t\t}\n\t\t// Update the query with the new value\n\t\tconst entry = query_map.get(key);\n\t\tentry?.resource.set(value);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/session-storage.js",
    "content": "/**\n * Read a value from `sessionStorage`\n * @param {string} key\n * @param {(value: string) => any} parse\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function get(key, parse = JSON.parse) {\n\ttry {\n\t\treturn parse(sessionStorage[key]);\n\t} catch {\n\t\t// do nothing\n\t}\n}\n\n/**\n * Write a value to `sessionStorage`\n * @param {string} key\n * @param {any} value\n * @param {(value: any) => string} stringify\n */\nexport function set(key, value, stringify = JSON.stringify) {\n\tconst data = stringify(value);\n\ttry {\n\t\tsessionStorage[key] = data;\n\t} catch {\n\t\t// do nothing\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/state.svelte.js",
    "content": "import { onMount } from 'svelte';\nimport { updated_listener } from './utils.js';\n\n/** @type {import('@sveltejs/kit').Page} */\nexport let page;\n\n/** @type {{ current: import('@sveltejs/kit').Navigation | null }} */\nexport let navigating;\n\n/** @type {{ current: boolean }} */\nexport let updated;\n\n// this is a bootleg way to tell if we're in old svelte or new svelte\nconst is_legacy =\n\tonMount.toString().includes('$$') || /function \\w+\\(\\) \\{\\}/.test(onMount.toString());\n\nconst placeholder_url = 'a:';\n\nif (is_legacy) {\n\tpage = {\n\t\tdata: {},\n\t\tform: null,\n\t\terror: null,\n\t\tparams: {},\n\t\troute: { id: null },\n\t\tstate: {},\n\t\tstatus: -1,\n\t\turl: new URL(placeholder_url)\n\t};\n\tnavigating = { current: null };\n\tupdated = { current: false };\n} else {\n\tpage = new (class Page {\n\t\tdata = $state.raw({});\n\t\tform = $state.raw(null);\n\t\terror = $state.raw(null);\n\t\tparams = $state.raw({});\n\t\troute = $state.raw({ id: null });\n\t\tstate = $state.raw({});\n\t\tstatus = $state.raw(-1);\n\t\turl = $state.raw(new URL(placeholder_url));\n\t})();\n\n\tnavigating = new (class Navigating {\n\t\tcurrent = $state.raw(null);\n\t})();\n\n\tupdated = new (class Updated {\n\t\tcurrent = $state.raw(false);\n\t})();\n\tupdated_listener.v = () => (updated.current = true);\n}\n\n/**\n * @param {import('@sveltejs/kit').Page} new_page\n */\nexport function update(new_page) {\n\tObject.assign(page, new_page);\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/types.d.ts",
    "content": "import { SvelteComponent } from 'svelte';\nimport {\n\tClientHooks,\n\tCSRPageNode,\n\tCSRPageNodeLoader,\n\tCSRRoute,\n\tCSRRouteServer,\n\tServerDataNode,\n\tTrailingSlash,\n\tUses\n} from 'types';\nimport { Page, ParamMatcher } from '@sveltejs/kit';\n\nexport interface SvelteKitApp {\n\t/**\n\t * A list of all the error/layout/page nodes used in the app.\n\t * - In case of router.resolution=client, this is filled completely upfront.\n\t * - In case of router.resolution=server, this is filled with the root layout and root error page\n\t *   at the beginning and then filled up as the user navigates around the app, loading new nodes\n\t */\n\tnodes: CSRPageNodeLoader[];\n\n\t/**\n\t * A list of all layout node ids that have a server load function.\n\t * Pages are not present because it's shorter to encode it on the leaf itself.\n\t *\n\t * In case of router.resolution=server, this only contains one entry for the root layout.\n\t */\n\tserver_loads: number[];\n\n\t/**\n\t * A map of `[routeId: string]: [leaf, layouts, errors]` tuples, which\n\t * is parsed into an array of routes on startup. The numbers refer to the indices in `nodes`.\n\t * If the leaf number is negative, it means it does use a server load function and the complement is the node index.\n\t * The route layout and error nodes are not referenced, they are always number 0 and 1 and always apply.\n\t *\n\t * In case of router.resolution=server, this object is empty, as resolution happens on the server.\n\t */\n\tdictionary: Record<string, [leaf: number, layouts: number[], errors?: number[]]>;\n\n\t/**\n\t * A map of `[matcherName: string]: (..) => boolean`, which is used to match route parameters.\n\t *\n\t * In case of router.resolution=server, this object is empty, as resolution happens on the server.\n\t */\n\tmatchers: Record<string, ParamMatcher>;\n\n\thooks: ClientHooks;\n\n\tdecode: (type: string, value: any) => any;\n\n\tdecoders: Record<string, (data: any) => any>;\n\tencoders: Record<string, (data: any) => any>;\n\n\t/**\n\t * Whether or not we're using hash-based routing\n\t */\n\thash: boolean;\n\n\troot: typeof SvelteComponent;\n}\n\nexport type NavigationIntent = {\n\t/** `url.pathname + url.search`  */\n\tid: string;\n\t/** Whether we are invalidating or navigating */\n\tinvalidating: boolean;\n\t/** The route parameters */\n\tparams: Record<string, string>;\n\t/** The route that matches `path` */\n\troute: CSRRoute;\n\t/** The destination URL */\n\turl: URL;\n};\n\nexport type NavigationResult = NavigationRedirect | NavigationFinished;\n\nexport type NavigationRedirect = {\n\ttype: 'redirect';\n\tlocation: string;\n};\n\nexport type NavigationFinished = {\n\ttype: 'loaded';\n\tstate: NavigationState;\n\tprops: {\n\t\tconstructors: Array<typeof SvelteComponent>;\n\t\terrors?: Array<typeof SvelteComponent | undefined>;\n\t\tcomponents?: SvelteComponent[];\n\t\tpage: Page;\n\t\tform?: Record<string, any> | null;\n\t\terror?: App.Error;\n\t\t[key: `data_${number}`]: Record<string, any>;\n\t};\n};\n\nexport type BranchNode = {\n\tnode: CSRPageNode;\n\tloader: CSRPageNodeLoader;\n\tserver: DataNode | null;\n\tuniversal: DataNode | null;\n\tdata: Record<string, any> | null;\n\tslash?: TrailingSlash;\n};\n\nexport interface DataNode {\n\ttype: 'data';\n\tdata: Record<string, any> | null;\n\tuses: Uses;\n\tslash?: TrailingSlash;\n}\n\nexport interface NavigationState {\n\tbranch: Array<BranchNode | undefined>;\n\terror: App.Error | null;\n\tparams: Record<string, string>;\n\troute: CSRRoute | null;\n\turl: URL;\n}\n\nexport interface HydrateOptions {\n\tstatus: number;\n\terror: App.Error | null;\n\tnode_ids: number[];\n\tparams: Record<string, string>;\n\troute: { id: string | null };\n\t/** Only used when `router.resolution=server`; can then still be undefined in case of 404 */\n\tserver_route?: CSRRouteServer;\n\tdata: Array<ServerDataNode | null>;\n\tform: Record<string, any> | null;\n\t/** The results of all remote functions executed during SSR so that they can be reused during hydration */\n\tremote: Record<string, any>;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/client/utils.js",
    "content": "import { BROWSER, DEV } from 'esm-env';\nimport { writable } from 'svelte/store';\nimport { assets } from '$app/paths';\nimport { version } from '__sveltekit/environment';\nimport { PRELOAD_PRIORITIES } from './constants.js';\n\n/* global __SVELTEKIT_APP_VERSION_FILE__, __SVELTEKIT_APP_VERSION_POLL_INTERVAL__ */\n\nexport const origin = BROWSER ? location.origin : '';\n\n/** @param {string | URL} url */\nexport function resolve_url(url) {\n\tif (url instanceof URL) return url;\n\n\tlet baseURI = document.baseURI;\n\n\tif (!baseURI) {\n\t\tconst baseTags = document.getElementsByTagName('base');\n\t\tbaseURI = baseTags.length ? baseTags[0].href : document.URL;\n\t}\n\n\treturn new URL(url, baseURI);\n}\n\nexport function scroll_state() {\n\treturn {\n\t\tx: pageXOffset,\n\t\ty: pageYOffset\n\t};\n}\n\nconst warned = new WeakSet();\n\n/** @typedef {keyof typeof valid_link_options} LinkOptionName */\n\nconst valid_link_options = /** @type {const} */ ({\n\t'preload-code': ['', 'off', 'false', 'tap', 'hover', 'viewport', 'eager'],\n\t'preload-data': ['', 'off', 'false', 'tap', 'hover'],\n\tkeepfocus: ['', 'true', 'off', 'false'],\n\tnoscroll: ['', 'true', 'off', 'false'],\n\treload: ['', 'true', 'off', 'false'],\n\treplacestate: ['', 'true', 'off', 'false']\n});\n\n/**\n * @template {LinkOptionName} T\n * @typedef {typeof valid_link_options[T][number]} ValidLinkOptions\n */\n\n/**\n * @template {LinkOptionName} T\n * @param {Element} element\n * @param {T} name\n */\nfunction link_option(element, name) {\n\tconst value = /** @type {ValidLinkOptions<T> | null} */ (\n\t\telement.getAttribute(`data-sveltekit-${name}`)\n\t);\n\n\tif (DEV) {\n\t\tvalidate_link_option(element, name, value);\n\t}\n\n\treturn value;\n}\n\n/**\n * @template {LinkOptionName} T\n * @template {ValidLinkOptions<T> | null} U\n * @param {Element} element\n * @param {T} name\n * @param {U} value\n */\nfunction validate_link_option(element, name, value) {\n\tif (value === null) return;\n\n\t// @ts-expect-error - includes is dumb\n\tif (!warned.has(element) && !valid_link_options[name].includes(value)) {\n\t\tconsole.error(\n\t\t\t`Unexpected value for ${name} — should be one of ${valid_link_options[name]\n\t\t\t\t.map((option) => JSON.stringify(option))\n\t\t\t\t.join(', ')}`,\n\t\t\telement\n\t\t);\n\n\t\twarned.add(element);\n\t}\n}\n\nconst levels = {\n\t...PRELOAD_PRIORITIES,\n\t'': PRELOAD_PRIORITIES.hover\n};\n\n/**\n * @param {Element} element\n * @returns {Element | null}\n */\nfunction parent_element(element) {\n\tlet parent = element.assignedSlot ?? element.parentNode;\n\n\t// @ts-expect-error handle shadow roots\n\tif (parent?.nodeType === 11) parent = parent.host;\n\n\treturn /** @type {Element} */ (parent);\n}\n\n/**\n * @param {Element} element\n * @param {Element} target\n */\nexport function find_anchor(element, target) {\n\twhile (element && element !== target) {\n\t\tif (element.nodeName.toUpperCase() === 'A' && element.hasAttribute('href')) {\n\t\t\treturn /** @type {HTMLAnchorElement | SVGAElement} */ (element);\n\t\t}\n\n\t\telement = /** @type {Element} */ (parent_element(element));\n\t}\n}\n\n/**\n * @param {HTMLAnchorElement | SVGAElement} a\n * @param {string} base\n * @param {boolean} uses_hash_router\n */\nexport function get_link_info(a, base, uses_hash_router) {\n\t/** @type {URL | undefined} */\n\tlet url;\n\n\ttry {\n\t\turl = new URL(a instanceof SVGAElement ? a.href.baseVal : a.href, document.baseURI);\n\n\t\t// if the hash doesn't start with `#/` then it's probably linking to an id on the current page\n\t\tif (uses_hash_router && url.hash.match(/^#[^/]/)) {\n\t\t\tconst route = location.hash.split('#')[1] || '/';\n\t\t\turl.hash = `#${route}${url.hash}`;\n\t\t}\n\t} catch {}\n\n\tconst target = a instanceof SVGAElement ? a.target.baseVal : a.target;\n\n\tconst external =\n\t\t!url ||\n\t\t!!target ||\n\t\tis_external_url(url, base, uses_hash_router) ||\n\t\t(a.getAttribute('rel') || '').split(/\\s+/).includes('external');\n\n\tconst download = url?.origin === origin && a.hasAttribute('download');\n\n\treturn { url, external, target, download };\n}\n\n/**\n * @param {HTMLFormElement | HTMLAnchorElement | SVGAElement} element\n */\nexport function get_router_options(element) {\n\t/** @type {ValidLinkOptions<'keepfocus'> | null} */\n\tlet keepfocus = null;\n\n\t/** @type {ValidLinkOptions<'noscroll'> | null} */\n\tlet noscroll = null;\n\n\t/** @type {ValidLinkOptions<'preload-code'> | null} */\n\tlet preload_code = null;\n\n\t/** @type {ValidLinkOptions<'preload-data'> | null} */\n\tlet preload_data = null;\n\n\t/** @type {ValidLinkOptions<'reload'> | null} */\n\tlet reload = null;\n\n\t/** @type {ValidLinkOptions<'replacestate'> | null} */\n\tlet replace_state = null;\n\n\t/** @type {Element} */\n\tlet el = element;\n\n\twhile (el && el !== document.documentElement) {\n\t\tif (preload_code === null) preload_code = link_option(el, 'preload-code');\n\t\tif (preload_data === null) preload_data = link_option(el, 'preload-data');\n\t\tif (keepfocus === null) keepfocus = link_option(el, 'keepfocus');\n\t\tif (noscroll === null) noscroll = link_option(el, 'noscroll');\n\t\tif (reload === null) reload = link_option(el, 'reload');\n\t\tif (replace_state === null) replace_state = link_option(el, 'replacestate');\n\n\t\tel = /** @type {Element} */ (parent_element(el));\n\t}\n\n\t/** @param {string | null} value */\n\tfunction get_option_state(value) {\n\t\tswitch (value) {\n\t\t\tcase '':\n\t\t\tcase 'true':\n\t\t\t\treturn true;\n\t\t\tcase 'off':\n\t\t\tcase 'false':\n\t\t\t\treturn false;\n\t\t\tdefault:\n\t\t\t\treturn undefined;\n\t\t}\n\t}\n\n\treturn {\n\t\tpreload_code: levels[preload_code ?? 'off'],\n\t\tpreload_data: levels[preload_data ?? 'off'],\n\t\tkeepfocus: get_option_state(keepfocus),\n\t\tnoscroll: get_option_state(noscroll),\n\t\treload: get_option_state(reload),\n\t\treplace_state: get_option_state(replace_state)\n\t};\n}\n\n/** @param {any} value */\nexport function notifiable_store(value) {\n\tconst store = writable(value);\n\tlet ready = true;\n\n\tfunction notify() {\n\t\tready = true;\n\t\tstore.update((val) => val);\n\t}\n\n\t/** @param {any} new_value */\n\tfunction set(new_value) {\n\t\tready = false;\n\t\tstore.set(new_value);\n\t}\n\n\t/** @param {(value: any) => void} run */\n\tfunction subscribe(run) {\n\t\t/** @type {any} */\n\t\tlet old_value;\n\t\treturn store.subscribe((new_value) => {\n\t\t\tif (old_value === undefined || (ready && new_value !== old_value)) {\n\t\t\t\trun((old_value = new_value));\n\t\t\t}\n\t\t});\n\t}\n\n\treturn { notify, set, subscribe };\n}\n\nexport const updated_listener = {\n\tv: () => {}\n};\n\nexport function create_updated_store() {\n\tconst { set, subscribe } = writable(false);\n\n\tif (DEV || !BROWSER) {\n\t\treturn {\n\t\t\tsubscribe,\n\t\t\t// eslint-disable-next-line @typescript-eslint/require-await\n\t\t\tcheck: async () => false\n\t\t};\n\t}\n\n\tconst interval = __SVELTEKIT_APP_VERSION_POLL_INTERVAL__;\n\n\t/** @type {NodeJS.Timeout} */\n\tlet timeout;\n\n\t/** @type {() => Promise<boolean>} */\n\tasync function check() {\n\t\tclearTimeout(timeout);\n\n\t\tif (interval) timeout = setTimeout(check, interval);\n\n\t\ttry {\n\t\t\tconst res = await fetch(`${assets}/${__SVELTEKIT_APP_VERSION_FILE__}`, {\n\t\t\t\theaders: {\n\t\t\t\t\tpragma: 'no-cache',\n\t\t\t\t\t'cache-control': 'no-cache'\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (!res.ok) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst data = await res.json();\n\t\t\tconst updated = data.version !== version;\n\n\t\t\tif (updated) {\n\t\t\t\tset(true);\n\t\t\t\tupdated_listener.v();\n\t\t\t\tclearTimeout(timeout);\n\t\t\t}\n\n\t\t\treturn updated;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tif (interval) timeout = setTimeout(check, interval);\n\n\treturn {\n\t\tsubscribe,\n\t\tcheck\n\t};\n}\n\n/**\n * Is external if\n * - origin different\n * - path doesn't start with base\n * - uses hash router and pathname is more than base\n * @param {URL} url\n * @param {string} base\n * @param {boolean} hash_routing\n */\nexport function is_external_url(url, base, hash_routing) {\n\tif (url.origin !== origin || !url.pathname.startsWith(base)) {\n\t\treturn true;\n\t}\n\n\tif (hash_routing) {\n\t\treturn url.pathname !== location.pathname;\n\t}\n\n\treturn false;\n}\n\n/** @type {Set<string> | null} */\nlet seen = null;\n\n/**\n * Used for server-side resolution, to replicate Vite's CSS loading behaviour in production.\n *\n * Closely modelled after https://github.com/vitejs/vite/blob/3dd12f4724130fdf8ba44c6d3252ebdff407fd47/packages/vite/src/node/plugins/importAnalysisBuild.ts#L214\n * (which ideally we could just use directly, but it's not exported)\n * @param {string[]} deps\n */\nexport function load_css(deps) {\n\tif (__SVELTEKIT_CLIENT_ROUTING__) return;\n\n\tconst csp_nonce_meta = /** @type {HTMLMetaElement} */ (\n\t\tdocument.querySelector('meta[property=csp-nonce]')\n\t);\n\tconst csp_nonce = csp_nonce_meta?.nonce || csp_nonce_meta?.getAttribute('nonce');\n\n\tseen ??= new Set(\n\t\tArray.from(document.querySelectorAll('link[rel=\"stylesheet\"]')).map((link) => {\n\t\t\treturn /** @type {HTMLLinkElement} */ (link).href;\n\t\t})\n\t);\n\n\tfor (const dep of deps) {\n\t\tconst href = new URL(dep, document.baseURI).href;\n\n\t\tif (seen.has(href)) continue;\n\t\tseen.add(href);\n\n\t\tconst link = document.createElement('link');\n\t\tlink.rel = 'stylesheet';\n\t\tlink.crossOrigin = '';\n\t\tlink.href = dep;\n\t\tif (csp_nonce) {\n\t\t\tlink.setAttribute('nonce', csp_nonce);\n\t\t}\n\t\tdocument.head.appendChild(link);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/components/svelte-4/error.svelte",
    "content": "<script>\n\timport { page } from '$app/stores';\n</script>\n\n<h1>{$page.status}</h1>\n<p>{$page.error?.message}</p>\n"
  },
  {
    "path": "packages/kit/src/runtime/components/svelte-4/layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/src/runtime/components/svelte-5/error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.status}</h1>\n<p>{page.error?.message}</p>\n"
  },
  {
    "path": "packages/kit/src/runtime/components/svelte-5/layout.svelte",
    "content": "<script>\n  let { children } = $props();\n</script>\n\n{@render children()}\n"
  },
  {
    "path": "packages/kit/src/runtime/env/dynamic/private.js",
    "content": "export { private_env as env } from '../../shared-server.js';\n"
  },
  {
    "path": "packages/kit/src/runtime/env/dynamic/public.js",
    "content": "export { public_env as env } from '../../shared-server.js';\n"
  },
  {
    "path": "packages/kit/src/runtime/form-utils.js",
    "content": "/** @import { RemoteForm } from '@sveltejs/kit' */\n/** @import { BinaryFormMeta, InternalRemoteFormIssue } from 'types' */\n/** @import { StandardSchemaV1 } from '@standard-schema/spec' */\n\nimport { DEV } from 'esm-env';\nimport * as devalue from 'devalue';\nimport { text_decoder, text_encoder } from './utils.js';\nimport { SvelteKitError } from '@sveltejs/kit/internal';\n\n/**\n * Sets a value in a nested object using a path string, mutating the original object\n * @param {Record<string, any>} object\n * @param {string} path_string\n * @param {any} value\n */\nexport function set_nested_value(object, path_string, value) {\n\tif (path_string.startsWith('n:')) {\n\t\tpath_string = path_string.slice(2);\n\t\tvalue = value === '' ? undefined : parseFloat(value);\n\t} else if (path_string.startsWith('b:')) {\n\t\tpath_string = path_string.slice(2);\n\t\tvalue = value === 'on';\n\t}\n\n\tdeep_set(object, split_path(path_string), value);\n}\n\n/**\n * Convert `FormData` into a POJO\n * @param {FormData} data\n */\nexport function convert_formdata(data) {\n\t/** @type {Record<string, any>} */\n\tconst result = {};\n\n\tfor (let key of data.keys()) {\n\t\tconst is_array = key.endsWith('[]');\n\t\t/** @type {any[]} */\n\t\tlet values = data.getAll(key);\n\n\t\tif (is_array) key = key.slice(0, -2);\n\n\t\tif (values.length > 1 && !is_array) {\n\t\t\tthrow new Error(`Form cannot contain duplicated keys — \"${key}\" has ${values.length} values`);\n\t\t}\n\n\t\t// an empty `<input type=\"file\">` will submit a non-existent file, bizarrely\n\t\tvalues = values.filter(\n\t\t\t(entry) => typeof entry === 'string' || entry.name !== '' || entry.size > 0\n\t\t);\n\n\t\tif (key.startsWith('n:')) {\n\t\t\tkey = key.slice(2);\n\t\t\tvalues = values.map((v) => (v === '' ? undefined : parseFloat(/** @type {string} */ (v))));\n\t\t} else if (key.startsWith('b:')) {\n\t\t\tkey = key.slice(2);\n\t\t\tvalues = values.map((v) => v === 'on');\n\t\t}\n\n\t\tset_nested_value(result, key, is_array ? values : values[0]);\n\t}\n\n\treturn result;\n}\n\nexport const BINARY_FORM_CONTENT_TYPE = 'application/x-sveltekit-formdata';\nconst BINARY_FORM_VERSION = 0;\nconst HEADER_BYTES = 1 + 4 + 2;\n/**\n * The binary format is as follows:\n * - 1 byte: Format version\n * - 4 bytes: Length of the header (u32)\n * - 2 bytes: Length of the file offset table (u16)\n * - header: devalue.stringify([data, meta])\n * - file offset table: JSON.stringify([offset1, offset2, ...]) (empty if no files) (offsets start from the end of the table)\n * - file1, file2, ...\n * @param {Record<string, any>} data\n * @param {BinaryFormMeta} meta\n */\nexport function serialize_binary_form(data, meta) {\n\t/** @type {Array<BlobPart>} */\n\tconst blob_parts = [new Uint8Array([BINARY_FORM_VERSION])];\n\n\t/** @type {Array<[file: File, index: number]>} */\n\tconst files = [];\n\n\tif (!meta.remote_refreshes?.length) {\n\t\tdelete meta.remote_refreshes;\n\t}\n\n\tconst encoded_header = devalue.stringify([data, meta], {\n\t\tFile: (file) => {\n\t\t\tif (!(file instanceof File)) return;\n\n\t\t\tfiles.push([file, files.length]);\n\t\t\treturn [file.name, file.type, file.size, file.lastModified, files.length - 1];\n\t\t}\n\t});\n\n\tconst encoded_header_buffer = text_encoder.encode(encoded_header);\n\n\tlet encoded_file_offsets = '';\n\tif (files.length) {\n\t\t// Sort small files to the front\n\t\tfiles.sort(([a], [b]) => a.size - b.size);\n\n\t\t/** @type {Array<number>} */\n\t\tconst file_offsets = new Array(files.length);\n\t\tlet start = 0;\n\t\tfor (const [file, index] of files) {\n\t\t\tfile_offsets[index] = start;\n\t\t\tstart += file.size;\n\t\t}\n\t\tencoded_file_offsets = JSON.stringify(file_offsets);\n\t}\n\n\tconst length_buffer = new Uint8Array(4);\n\tconst length_view = new DataView(length_buffer.buffer);\n\n\tlength_view.setUint32(0, encoded_header_buffer.byteLength, true);\n\tblob_parts.push(length_buffer.slice());\n\n\tlength_view.setUint16(0, encoded_file_offsets.length, true);\n\tblob_parts.push(length_buffer.slice(0, 2));\n\n\tblob_parts.push(encoded_header_buffer);\n\tblob_parts.push(encoded_file_offsets);\n\n\tfor (const [file] of files) {\n\t\tblob_parts.push(file);\n\t}\n\n\treturn {\n\t\tblob: new Blob(blob_parts)\n\t};\n}\n\n/**\n * @param {Request} request\n * @returns {Promise<{ data: Record<string, any>; meta: BinaryFormMeta; form_data: FormData | null }>}\n */\nexport async function deserialize_binary_form(request) {\n\tif (request.headers.get('content-type') !== BINARY_FORM_CONTENT_TYPE) {\n\t\tconst form_data = await request.formData();\n\t\treturn { data: convert_formdata(form_data), meta: {}, form_data };\n\t}\n\tif (!request.body) {\n\t\tthrow deserialize_error('no body');\n\t}\n\tconst content_length = parseInt(request.headers.get('content-length') ?? '');\n\tif (Number.isNaN(content_length)) {\n\t\tthrow deserialize_error('invalid Content-Length header');\n\t}\n\n\tconst reader = request.body.getReader();\n\n\t/** @type {Array<Promise<Uint8Array<ArrayBuffer> | undefined>>} */\n\tconst chunks = [];\n\n\t/**\n\t * @param {number} index\n\t * @returns {Promise<Uint8Array<ArrayBuffer> | undefined>}\n\t */\n\tfunction get_chunk(index) {\n\t\tif (index in chunks) return chunks[index];\n\n\t\tlet i = chunks.length;\n\t\twhile (i <= index) {\n\t\t\tchunks[i] = reader.read().then((chunk) => chunk.value);\n\t\t\ti++;\n\t\t}\n\t\treturn chunks[index];\n\t}\n\n\t/**\n\t * @param {number} offset\n\t * @param {number} length\n\t * @returns {Promise<Uint8Array | null>}\n\t */\n\tasync function get_buffer(offset, length) {\n\t\t/** @type {Uint8Array} */\n\t\tlet start_chunk;\n\t\tlet chunk_start = 0;\n\t\t/** @type {number} */\n\t\tlet chunk_index;\n\t\tfor (chunk_index = 0; ; chunk_index++) {\n\t\t\tconst chunk = await get_chunk(chunk_index);\n\t\t\tif (!chunk) return null;\n\n\t\t\tconst chunk_end = chunk_start + chunk.byteLength;\n\t\t\t// If this chunk contains the target offset\n\t\t\tif (offset >= chunk_start && offset < chunk_end) {\n\t\t\t\tstart_chunk = chunk;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tchunk_start = chunk_end;\n\t\t}\n\t\t// If the buffer is completely contained in one chunk, do a subarray\n\t\tif (offset + length <= chunk_start + start_chunk.byteLength) {\n\t\t\treturn start_chunk.subarray(offset - chunk_start, offset + length - chunk_start);\n\t\t}\n\t\t// Otherwise, copy the data into a new buffer\n\t\tconst chunks = [start_chunk.subarray(offset - chunk_start)];\n\t\tlet cursor = start_chunk.byteLength - offset + chunk_start;\n\t\twhile (cursor < length) {\n\t\t\tchunk_index++;\n\t\t\tlet chunk = await get_chunk(chunk_index);\n\t\t\tif (!chunk) return null;\n\t\t\tif (chunk.byteLength > length - cursor) {\n\t\t\t\tchunk = chunk.subarray(0, length - cursor);\n\t\t\t}\n\t\t\tchunks.push(chunk);\n\t\t\tcursor += chunk.byteLength;\n\t\t}\n\t\tconst buffer = new Uint8Array(length);\n\t\tcursor = 0;\n\t\tfor (const chunk of chunks) {\n\t\t\tbuffer.set(chunk, cursor);\n\t\t\tcursor += chunk.byteLength;\n\t\t}\n\n\t\treturn buffer;\n\t}\n\n\tconst header = await get_buffer(0, HEADER_BYTES);\n\tif (!header) throw deserialize_error('too short');\n\n\tif (header[0] !== BINARY_FORM_VERSION) {\n\t\tthrow deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`);\n\t}\n\tconst header_view = new DataView(header.buffer, header.byteOffset, header.byteLength);\n\tconst data_length = header_view.getUint32(1, true);\n\n\tif (HEADER_BYTES + data_length > content_length) {\n\t\tthrow deserialize_error('data overflow');\n\t}\n\n\tconst file_offsets_length = header_view.getUint16(5, true);\n\n\tif (HEADER_BYTES + data_length + file_offsets_length > content_length) {\n\t\tthrow deserialize_error('file offset table overflow');\n\t}\n\n\t// Read the form data\n\tconst data_buffer = await get_buffer(HEADER_BYTES, data_length);\n\tif (!data_buffer) throw deserialize_error('data too short');\n\n\t/** @type {Array<number | undefined>} */\n\tlet file_offsets;\n\t/** @type {number} */\n\tlet files_start_offset;\n\tif (file_offsets_length > 0) {\n\t\t// Read the file offset table\n\t\tconst file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);\n\t\tif (!file_offsets_buffer) throw deserialize_error('file offset table too short');\n\n\t\tconst parsed_offsets = JSON.parse(text_decoder.decode(file_offsets_buffer));\n\n\t\tif (\n\t\t\t!Array.isArray(parsed_offsets) ||\n\t\t\tparsed_offsets.some((n) => typeof n !== 'number' || !Number.isInteger(n) || n < 0)\n\t\t) {\n\t\t\tthrow deserialize_error('invalid file offset table');\n\t\t}\n\n\t\tfile_offsets = /** @type {Array<number>} */ (parsed_offsets);\n\t\tfiles_start_offset = HEADER_BYTES + data_length + file_offsets_length;\n\t}\n\n\t/** @type {Array<{ offset: number, size: number }>} */\n\tconst file_spans = [];\n\tconst [data, meta] = devalue.parse(text_decoder.decode(data_buffer), {\n\t\tFile: ([name, type, size, last_modified, index]) => {\n\t\t\tif (\n\t\t\t\ttypeof name !== 'string' ||\n\t\t\t\ttypeof type !== 'string' ||\n\t\t\t\ttypeof size !== 'number' ||\n\t\t\t\ttypeof last_modified !== 'number' ||\n\t\t\t\ttypeof index !== 'number'\n\t\t\t) {\n\t\t\t\tthrow deserialize_error('invalid file metadata');\n\t\t\t}\n\n\t\t\tlet offset = file_offsets[index];\n\n\t\t\t// Check that the file offset table entry has not been already\n\t\t\t// used. If not, immediately mark it as used.\n\t\t\tif (offset === undefined) {\n\t\t\t\tthrow deserialize_error('duplicate file offset table index');\n\t\t\t}\n\t\t\tfile_offsets[index] = undefined;\n\n\t\t\toffset += files_start_offset;\n\t\t\tif (offset + size > content_length) {\n\t\t\t\tthrow deserialize_error('file data overflow');\n\t\t\t}\n\n\t\t\tfile_spans.push({ offset, size });\n\n\t\t\treturn new Proxy(new LazyFile(name, type, size, last_modified, get_chunk, offset), {\n\t\t\t\tgetPrototypeOf() {\n\t\t\t\t\t// Trick validators into thinking this is a normal File\n\t\t\t\t\treturn File.prototype;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\t// Sort file spans in increasing order primarily by offset\n\t// and secondarily by size (to allow 0-length files).\n\tfile_spans.sort((a, b) => a.offset - b.offset || a.size - b.size);\n\n\t// Check that file spans do not overlap and there are no gaps between them.\n\tfor (let i = 1; i < file_spans.length; i++) {\n\t\tconst previous = file_spans[i - 1];\n\t\tconst current = file_spans[i];\n\n\t\tconst previous_end = previous.offset + previous.size;\n\t\tif (previous_end < current.offset) {\n\t\t\tthrow deserialize_error('gaps in file data');\n\t\t}\n\t\tif (previous_end > current.offset) {\n\t\t\tthrow deserialize_error('overlapping file data');\n\t\t}\n\t}\n\n\t// Read the request body asyncronously so it doesn't stall\n\tvoid (async () => {\n\t\tlet has_more = true;\n\t\twhile (has_more) {\n\t\t\tconst chunk = await get_chunk(chunks.length);\n\t\t\thas_more = !!chunk;\n\t\t}\n\t})();\n\n\treturn { data, meta, form_data: null };\n}\n/**\n * @param {string} message\n */\nfunction deserialize_error(message) {\n\treturn new SvelteKitError(400, 'Bad Request', `Could not deserialize binary form: ${message}`);\n}\n\n/** @implements {File} */\nclass LazyFile {\n\t/** @type {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} */\n\t#get_chunk;\n\t/** @type {number} */\n\t#offset;\n\t/**\n\t * @param {string} name\n\t * @param {string} type\n\t * @param {number} size\n\t * @param {number} last_modified\n\t * @param {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} get_chunk\n\t * @param {number} offset\n\t */\n\tconstructor(name, type, size, last_modified, get_chunk, offset) {\n\t\tthis.name = name;\n\t\tthis.type = type;\n\t\tthis.size = size;\n\t\tthis.lastModified = last_modified;\n\t\tthis.webkitRelativePath = '';\n\t\tthis.#get_chunk = get_chunk;\n\t\tthis.#offset = offset;\n\n\t\t// TODO - hacky, required for private members to be accessed on proxy\n\t\tthis.arrayBuffer = this.arrayBuffer.bind(this);\n\t\tthis.bytes = this.bytes.bind(this);\n\t\tthis.slice = this.slice.bind(this);\n\t\tthis.stream = this.stream.bind(this);\n\t\tthis.text = this.text.bind(this);\n\t}\n\t/** @type {ArrayBuffer | undefined} */\n\t#buffer;\n\tasync arrayBuffer() {\n\t\tthis.#buffer ??= await new Response(this.stream()).arrayBuffer();\n\t\treturn this.#buffer;\n\t}\n\tasync bytes() {\n\t\treturn new Uint8Array(await this.arrayBuffer());\n\t}\n\t/**\n\t * @param {number=} start\n\t * @param {number=} end\n\t * @param {string=} contentType\n\t */\n\tslice(start = 0, end = this.size, contentType = this.type) {\n\t\t// https://github.com/nodejs/node/blob/a5f3cd8cb5ba9e7911d93c5fd3ebc6d781220dd8/lib/internal/blob.js#L240\n\t\tif (start < 0) {\n\t\t\tstart = Math.max(this.size + start, 0);\n\t\t} else {\n\t\t\tstart = Math.min(start, this.size);\n\t\t}\n\n\t\tif (end < 0) {\n\t\t\tend = Math.max(this.size + end, 0);\n\t\t} else {\n\t\t\tend = Math.min(end, this.size);\n\t\t}\n\t\tconst size = Math.max(end - start, 0);\n\t\tconst file = new LazyFile(\n\t\t\tthis.name,\n\t\t\tcontentType,\n\t\t\tsize,\n\t\t\tthis.lastModified,\n\t\t\tthis.#get_chunk,\n\t\t\tthis.#offset + start\n\t\t);\n\n\t\treturn file;\n\t}\n\tstream() {\n\t\tlet cursor = 0;\n\t\tlet chunk_index = 0;\n\t\treturn new ReadableStream({\n\t\t\tstart: async (controller) => {\n\t\t\t\tlet chunk_start = 0;\n\t\t\t\t/** @type {Uint8Array} */\n\t\t\t\tlet start_chunk;\n\t\t\t\tfor (chunk_index = 0; ; chunk_index++) {\n\t\t\t\t\tconst chunk = await this.#get_chunk(chunk_index);\n\t\t\t\t\tif (!chunk) return null;\n\n\t\t\t\t\tconst chunk_end = chunk_start + chunk.byteLength;\n\t\t\t\t\t// If this chunk contains the target offset\n\t\t\t\t\tif (this.#offset >= chunk_start && this.#offset < chunk_end) {\n\t\t\t\t\t\tstart_chunk = chunk;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tchunk_start = chunk_end;\n\t\t\t\t}\n\t\t\t\t// If the buffer is completely contained in one chunk, do a subarray\n\t\t\t\tif (this.#offset + this.size <= chunk_start + start_chunk.byteLength) {\n\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\tstart_chunk.subarray(this.#offset - chunk_start, this.#offset + this.size - chunk_start)\n\t\t\t\t\t);\n\t\t\t\t\tcontroller.close();\n\t\t\t\t} else {\n\t\t\t\t\tcontroller.enqueue(start_chunk.subarray(this.#offset - chunk_start));\n\t\t\t\t\tcursor = start_chunk.byteLength - this.#offset + chunk_start;\n\t\t\t\t}\n\t\t\t},\n\t\t\tpull: async (controller) => {\n\t\t\t\tchunk_index++;\n\t\t\t\tlet chunk = await this.#get_chunk(chunk_index);\n\t\t\t\tif (!chunk) {\n\t\t\t\t\tcontroller.error('incomplete file data');\n\t\t\t\t\tcontroller.close();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (chunk.byteLength > this.size - cursor) {\n\t\t\t\t\tchunk = chunk.subarray(0, this.size - cursor);\n\t\t\t\t}\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\tcursor += chunk.byteLength;\n\t\t\t\tif (cursor >= this.size) {\n\t\t\t\t\tcontroller.close();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\tasync text() {\n\t\treturn text_decoder.decode(await this.arrayBuffer());\n\t}\n}\n\nconst path_regex = /^[a-zA-Z_$]\\w*(\\.[a-zA-Z_$]\\w*|\\[\\d+\\])*$/;\n\n/**\n * @param {string} path\n */\nexport function split_path(path) {\n\tif (!path_regex.test(path)) {\n\t\tthrow new Error(`Invalid path ${path}`);\n\t}\n\n\treturn path.split(/\\.|\\[|\\]/).filter(Boolean);\n}\n\n/**\n * Check if a property key is dangerous and could lead to prototype pollution\n * @param {string} key\n */\nfunction check_prototype_pollution(key) {\n\tif (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n\t\tthrow new Error(\n\t\t\t`Invalid key \"${key}\"` +\n\t\t\t\t(DEV ? ': This key is not allowed to prevent prototype pollution.' : '')\n\t\t);\n\t}\n}\n\n/**\n * Sets a value in a nested object using an array of keys, mutating the original object.\n * @param {Record<string, any>} object\n * @param {string[]} keys\n * @param {any} value\n */\nexport function deep_set(object, keys, value) {\n\tlet current = object;\n\n\tfor (let i = 0; i < keys.length - 1; i += 1) {\n\t\tconst key = keys[i];\n\n\t\tcheck_prototype_pollution(key);\n\n\t\tconst is_array = /^\\d+$/.test(keys[i + 1]);\n\t\tconst exists = Object.hasOwn(current, key);\n\t\tconst inner = current[key];\n\n\t\tif (exists && is_array !== Array.isArray(inner)) {\n\t\t\tthrow new Error(`Invalid array key ${keys[i + 1]}`);\n\t\t}\n\n\t\tif (!exists) {\n\t\t\tcurrent[key] = is_array ? [] : {};\n\t\t}\n\n\t\tcurrent = current[key];\n\t}\n\n\tconst final_key = keys[keys.length - 1];\n\tcheck_prototype_pollution(final_key);\n\tcurrent[final_key] = value;\n}\n\n/**\n * @param {StandardSchemaV1.Issue} issue\n * @param {boolean} server Whether this issue came from server validation\n */\nexport function normalize_issue(issue, server = false) {\n\t/** @type {InternalRemoteFormIssue} */\n\tconst normalized = { name: '', path: [], message: issue.message, server };\n\n\tif (issue.path !== undefined) {\n\t\tlet name = '';\n\n\t\tfor (const segment of issue.path) {\n\t\t\tconst key = /** @type {string | number} */ (\n\t\t\t\ttypeof segment === 'object' ? segment.key : segment\n\t\t\t);\n\n\t\t\tnormalized.path.push(key);\n\n\t\t\tif (typeof key === 'number') {\n\t\t\t\tname += `[${key}]`;\n\t\t\t} else if (typeof key === 'string') {\n\t\t\t\tname += name === '' ? key : '.' + key;\n\t\t\t}\n\t\t}\n\n\t\tnormalized.name = name;\n\t}\n\n\treturn normalized;\n}\n\n/**\n * @param {InternalRemoteFormIssue[]} issues\n */\nexport function flatten_issues(issues) {\n\t/** @type {Record<string, InternalRemoteFormIssue[]>} */\n\tconst result = {};\n\n\tfor (const issue of issues) {\n\t\t(result.$ ??= []).push(issue);\n\n\t\tlet name = '';\n\n\t\tif (issue.path !== undefined) {\n\t\t\tfor (const key of issue.path) {\n\t\t\t\tif (typeof key === 'number') {\n\t\t\t\t\tname += `[${key}]`;\n\t\t\t\t} else if (typeof key === 'string') {\n\t\t\t\t\tname += name === '' ? key : '.' + key;\n\t\t\t\t}\n\n\t\t\t\t(result[name] ??= []).push(issue);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Gets a nested value from an object using a path array\n * @param {Record<string, any>} object\n * @param {(string | number)[]} path\n * @returns {any}\n */\n\nexport function deep_get(object, path) {\n\tlet current = object;\n\tfor (const key of path) {\n\t\tif (current == null || typeof current !== 'object') {\n\t\t\treturn current;\n\t\t}\n\t\tcurrent = current[key];\n\t}\n\treturn current;\n}\n\n/**\n * Creates a proxy-based field accessor for form data\n * @param {any} target - Function or empty POJO\n * @param {() => Record<string, any>} get_input - Function to get current input data\n * @param {(path: (string | number)[], value: any) => void} set_input - Function to set input data\n * @param {() => Record<string, InternalRemoteFormIssue[]>} get_issues - Function to get current issues\n * @param {(string | number)[]} path - Current access path\n * @returns {any} Proxy object with name(), value(), and issues() methods\n */\nexport function create_field_proxy(target, get_input, set_input, get_issues, path = []) {\n\tconst get_value = () => {\n\t\treturn deep_get(get_input(), path);\n\t};\n\n\treturn new Proxy(target, {\n\t\tget(target, prop) {\n\t\t\tif (typeof prop === 'symbol') return target[prop];\n\n\t\t\t// Handle array access like jobs[0]\n\t\t\tif (/^\\d+$/.test(prop)) {\n\t\t\t\treturn create_field_proxy({}, get_input, set_input, get_issues, [\n\t\t\t\t\t...path,\n\t\t\t\t\tparseInt(prop, 10)\n\t\t\t\t]);\n\t\t\t}\n\n\t\t\tconst key = build_path_string(path);\n\n\t\t\tif (prop === 'set') {\n\t\t\t\tconst set_func = function (/** @type {any} */ newValue) {\n\t\t\t\t\tset_input(path, newValue);\n\t\t\t\t\treturn newValue;\n\t\t\t\t};\n\t\t\t\treturn create_field_proxy(set_func, get_input, set_input, get_issues, [...path, prop]);\n\t\t\t}\n\n\t\t\tif (prop === 'value') {\n\t\t\t\treturn create_field_proxy(get_value, get_input, set_input, get_issues, [...path, prop]);\n\t\t\t}\n\n\t\t\tif (prop === 'issues' || prop === 'allIssues') {\n\t\t\t\tconst issues_func = () => {\n\t\t\t\t\tconst all_issues = get_issues()[key === '' ? '$' : key];\n\n\t\t\t\t\tif (prop === 'allIssues') {\n\t\t\t\t\t\treturn all_issues?.map((issue) => ({\n\t\t\t\t\t\t\tpath: issue.path,\n\t\t\t\t\t\t\tmessage: issue.message\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\n\t\t\t\t\treturn all_issues\n\t\t\t\t\t\t?.filter((issue) => issue.name === key)\n\t\t\t\t\t\t?.map((issue) => ({\n\t\t\t\t\t\t\tpath: issue.path,\n\t\t\t\t\t\t\tmessage: issue.message\n\t\t\t\t\t\t}));\n\t\t\t\t};\n\n\t\t\t\treturn create_field_proxy(issues_func, get_input, set_input, get_issues, [...path, prop]);\n\t\t\t}\n\n\t\t\tif (prop === 'as') {\n\t\t\t\t/**\n\t\t\t\t * @param {string} type\n\t\t\t\t * @param {string} [input_value]\n\t\t\t\t */\n\t\t\t\tconst as_func = (type, input_value) => {\n\t\t\t\t\tconst is_array =\n\t\t\t\t\t\ttype === 'file multiple' ||\n\t\t\t\t\t\ttype === 'select multiple' ||\n\t\t\t\t\t\t(type === 'checkbox' && typeof input_value === 'string');\n\n\t\t\t\t\tconst prefix =\n\t\t\t\t\t\ttype === 'number' || type === 'range'\n\t\t\t\t\t\t\t? 'n:'\n\t\t\t\t\t\t\t: type === 'checkbox' && !is_array\n\t\t\t\t\t\t\t\t? 'b:'\n\t\t\t\t\t\t\t\t: '';\n\n\t\t\t\t\t// Base properties for all input types\n\t\t\t\t\t/** @type {Record<string, any>} */\n\t\t\t\t\tconst base_props = {\n\t\t\t\t\t\tname: prefix + key + (is_array ? '[]' : ''),\n\t\t\t\t\t\tget 'aria-invalid'() {\n\t\t\t\t\t\t\tconst issues = get_issues();\n\t\t\t\t\t\t\treturn key in issues ? 'true' : undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// Add type attribute only for non-text inputs and non-select elements\n\t\t\t\t\tif (type !== 'text' && type !== 'select' && type !== 'select multiple') {\n\t\t\t\t\t\tbase_props.type = type === 'file multiple' ? 'file' : type;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Handle submit and hidden inputs\n\t\t\t\t\tif (type === 'submit' || type === 'hidden') {\n\t\t\t\t\t\tif (DEV) {\n\t\t\t\t\t\t\tif (!input_value) {\n\t\t\t\t\t\t\t\tthrow new Error(`\\`${type}\\` inputs must have a value`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn Object.defineProperties(base_props, {\n\t\t\t\t\t\t\tvalue: { value: input_value, enumerable: true }\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Handle select inputs\n\t\t\t\t\tif (type === 'select' || type === 'select multiple') {\n\t\t\t\t\t\treturn Object.defineProperties(base_props, {\n\t\t\t\t\t\t\tmultiple: { value: is_array, enumerable: true },\n\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\t\tget() {\n\t\t\t\t\t\t\t\t\treturn get_value();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Handle checkbox inputs\n\t\t\t\t\tif (type === 'checkbox' || type === 'radio') {\n\t\t\t\t\t\tif (DEV) {\n\t\t\t\t\t\t\tif (type === 'radio' && !input_value) {\n\t\t\t\t\t\t\t\tthrow new Error('Radio inputs must have a value');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (type === 'checkbox' && is_array && !input_value) {\n\t\t\t\t\t\t\t\tthrow new Error('Checkbox array inputs must have a value');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn Object.defineProperties(base_props, {\n\t\t\t\t\t\t\tvalue: { value: input_value ?? 'on', enumerable: true },\n\t\t\t\t\t\t\tchecked: {\n\t\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\t\tget() {\n\t\t\t\t\t\t\t\t\tconst value = get_value();\n\n\t\t\t\t\t\t\t\t\tif (type === 'radio') {\n\t\t\t\t\t\t\t\t\t\treturn value === input_value;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (is_array) {\n\t\t\t\t\t\t\t\t\t\treturn (value ?? []).includes(input_value);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn value;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Handle file inputs\n\t\t\t\t\tif (type === 'file' || type === 'file multiple') {\n\t\t\t\t\t\treturn Object.defineProperties(base_props, {\n\t\t\t\t\t\t\tmultiple: { value: is_array, enumerable: true },\n\t\t\t\t\t\t\tfiles: {\n\t\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\t\tget() {\n\t\t\t\t\t\t\t\t\tconst value = get_value();\n\n\t\t\t\t\t\t\t\t\t// Convert File/File[] to FileList-like object\n\t\t\t\t\t\t\t\t\tif (value instanceof File) {\n\t\t\t\t\t\t\t\t\t\t// In browsers, we can create a proper FileList using DataTransfer\n\t\t\t\t\t\t\t\t\t\tif (typeof DataTransfer !== 'undefined') {\n\t\t\t\t\t\t\t\t\t\t\tconst fileList = new DataTransfer();\n\t\t\t\t\t\t\t\t\t\t\tfileList.items.add(value);\n\t\t\t\t\t\t\t\t\t\t\treturn fileList.files;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t// Fallback for environments without DataTransfer\n\t\t\t\t\t\t\t\t\t\treturn { 0: value, length: 1 };\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (Array.isArray(value) && value.every((f) => f instanceof File)) {\n\t\t\t\t\t\t\t\t\t\tif (typeof DataTransfer !== 'undefined') {\n\t\t\t\t\t\t\t\t\t\t\tconst fileList = new DataTransfer();\n\t\t\t\t\t\t\t\t\t\t\tvalue.forEach((file) => fileList.items.add(file));\n\t\t\t\t\t\t\t\t\t\t\treturn fileList.files;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t// Fallback for environments without DataTransfer\n\t\t\t\t\t\t\t\t\t\t/** @type {any} */\n\t\t\t\t\t\t\t\t\t\tconst fileListLike = { length: value.length };\n\t\t\t\t\t\t\t\t\t\tvalue.forEach((file, index) => {\n\t\t\t\t\t\t\t\t\t\t\tfileListLike[index] = file;\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\treturn fileListLike;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Handle all other input types (text, number, etc.)\n\t\t\t\t\treturn Object.defineProperties(base_props, {\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\tget() {\n\t\t\t\t\t\t\t\tconst value = get_value();\n\t\t\t\t\t\t\t\treturn value != null ? String(value) : '';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\treturn create_field_proxy(as_func, get_input, set_input, get_issues, [...path, 'as']);\n\t\t\t}\n\n\t\t\t// Handle property access (nested fields)\n\t\t\treturn create_field_proxy({}, get_input, set_input, get_issues, [...path, prop]);\n\t\t}\n\t});\n}\n\n/**\n * Builds a path string from an array of path segments\n * @param {(string | number)[]} path\n * @returns {string}\n */\nexport function build_path_string(path) {\n\tlet result = '';\n\n\tfor (const segment of path) {\n\t\tif (typeof segment === 'number') {\n\t\t\tresult += `[${segment}]`;\n\t\t} else {\n\t\t\tresult += result === '' ? segment : '.' + segment;\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * @param {RemoteForm<any, any>} instance\n * @deprecated remove in 3.0\n */\nexport function throw_on_old_property_access(instance) {\n\tObject.defineProperty(instance, 'field', {\n\t\tvalue: (/** @type {string} */ name) => {\n\t\t\tconst new_name = name.endsWith('[]') ? name.slice(0, -2) : name;\n\t\t\tthrow new Error(\n\t\t\t\t`\\`form.field\\` has been removed: Instead of \\`<input name={form.field('${name}')} />\\` do \\`<input {...form.fields.${new_name}.as(type)} />\\``\n\t\t\t);\n\t\t}\n\t});\n\n\tfor (const property of ['input', 'issues']) {\n\t\tObject.defineProperty(instance, property, {\n\t\t\tget() {\n\t\t\t\tconst new_name = property === 'issues' ? 'issues' : 'value';\n\t\t\t\treturn new Proxy(\n\t\t\t\t\t{},\n\t\t\t\t\t{\n\t\t\t\t\t\tget(_, prop) {\n\t\t\t\t\t\t\tconst prop_string = typeof prop === 'string' ? prop : String(prop);\n\t\t\t\t\t\t\tconst old =\n\t\t\t\t\t\t\t\tprop_string.includes('[') || prop_string.includes('.')\n\t\t\t\t\t\t\t\t\t? `['${prop_string}']`\n\t\t\t\t\t\t\t\t\t: `.${prop_string}`;\n\t\t\t\t\t\t\tconst replacement = `.${prop_string}.${new_name}()`;\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`\\`form.${property}\\` has been removed: Instead of \\`form.${property}${old}\\` write \\`form.fields${replacement}\\``\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/form-utils.spec.js",
    "content": "import { beforeAll, describe, expect, test } from 'vitest';\nimport {\n\tBINARY_FORM_CONTENT_TYPE,\n\tconvert_formdata,\n\tdeep_set,\n\tdeserialize_binary_form,\n\tserialize_binary_form,\n\tsplit_path\n} from './form-utils.js';\nimport buffer from 'node:buffer';\nimport { text_encoder } from './utils.js';\n\ndescribe('split_path', () => {\n\tconst good = [\n\t\t{\n\t\t\tinput: 'foo',\n\t\t\toutput: ['foo']\n\t\t},\n\t\t{\n\t\t\tinput: 'foo.bar.baz',\n\t\t\toutput: ['foo', 'bar', 'baz']\n\t\t},\n\t\t{\n\t\t\tinput: 'foo[0][1][2]',\n\t\t\toutput: ['foo', '0', '1', '2']\n\t\t}\n\t];\n\n\tconst bad = ['[0]', 'foo.0', 'foo[bar]'];\n\n\tfor (const { input, output } of good) {\n\t\ttest(input, () => {\n\t\t\texpect(split_path(input)).toEqual(output);\n\t\t});\n\t}\n\n\tfor (const input of bad) {\n\t\ttest(input, () => {\n\t\t\texpect(() => split_path(input)).toThrowError(`Invalid path ${input}`);\n\t\t});\n\t}\n});\n\ndescribe('convert_formdata', () => {\n\ttest('converts a FormData object', () => {\n\t\tconst data = new FormData();\n\n\t\tdata.append('foo', 'foo');\n\n\t\tdata.append('object.nested.property', 'property');\n\t\tdata.append('array[]', 'a');\n\t\tdata.append('array[]', 'b');\n\t\tdata.append('array[]', 'c');\n\n\t\tconst converted = convert_formdata(data);\n\n\t\texpect(converted).toEqual({\n\t\t\tfoo: 'foo',\n\t\t\tobject: {\n\t\t\t\tnested: {\n\t\t\t\t\tproperty: 'property'\n\t\t\t\t}\n\t\t\t},\n\t\t\tarray: ['a', 'b', 'c']\n\t\t});\n\t});\n\n\ttest('handles multiple fields at the same nested level', () => {\n\t\tconst data = new FormData();\n\n\t\tdata.append('user.name.first', 'first');\n\t\tdata.append('user.name.last', 'last');\n\n\t\tconst converted = convert_formdata(data);\n\n\t\texpect(converted).toEqual({\n\t\t\tuser: {\n\t\t\t\tname: {\n\t\t\t\t\tfirst: 'first',\n\t\t\t\t\tlast: 'last'\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n\n\tconst pollution_attacks = [\n\t\t'__proto__.polluted',\n\t\t'constructor.polluted',\n\t\t'prototype.polluted',\n\t\t'user.__proto__.polluted',\n\t\t'user.constructor.polluted'\n\t];\n\n\tfor (const attack of pollution_attacks) {\n\t\ttest(`prevents prototype pollution: ${attack}`, () => {\n\t\t\tconst data = new FormData();\n\t\t\tdata.append(attack, 'bad');\n\t\t\texpect(() => convert_formdata(data)).toThrow(/Invalid key \"/);\n\t\t});\n\t}\n});\n\ndescribe('binary form serializer', () => {\n\tbeforeAll(() => {\n\t\t// TODO: remove after dropping support for Node 18\n\t\tif (!('File' in globalThis)) {\n\t\t\t// @ts-ignore\n\t\t\tglobalThis.File = buffer.File;\n\t\t}\n\t});\n\ttest.each([\n\t\t{\n\t\t\tdata: {},\n\t\t\tmeta: {}\n\t\t},\n\t\t{\n\t\t\tdata: { foo: 'foo', nested: { prop: 'prop' } },\n\t\t\tmeta: { pathname: '/foo', validate_only: true }\n\t\t}\n\t])('simple', async (input) => {\n\t\tconst { blob } = serialize_binary_form(input.data, input.meta);\n\t\tconst res = await deserialize_binary_form(\n\t\t\tnew Request('http://test', {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: blob,\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t'Content-Length': blob.size.toString()\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\t\texpect(res.form_data).toBeNull();\n\t\texpect(res.data).toEqual(input.data);\n\t\texpect(res.meta).toEqual(input.meta ?? {});\n\t});\n\ttest('file uploads', async () => {\n\t\tconst { blob } = serialize_binary_form(\n\t\t\t{\n\t\t\t\tsmall: new File(['a'], 'a.txt', { type: 'text/plain' }),\n\t\t\t\tlarge: new File([new Uint8Array(1024).fill('a'.charCodeAt(0))], 'large.txt', {\n\t\t\t\t\ttype: 'text/plain',\n\t\t\t\t\tlastModified: 100\n\t\t\t\t}),\n\t\t\t\tempty: new File([], 'empty.txt', { type: 'text/plain' })\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\t// Split the stream into 1 byte chunks to make sure all the chunking deserialization works\n\t\tconst stream = blob.stream().pipeThrough(\n\t\t\tnew TransformStream({\n\t\t\t\ttransform(chunk, controller) {\n\t\t\t\t\tfor (const byte of chunk) {\n\t\t\t\t\t\tcontroller.enqueue(new Uint8Array([byte]));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\t\tconst res = await deserialize_binary_form(\n\t\t\tnew Request('http://test', {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: stream,\n\t\t\t\t// @ts-expect-error duplex required in node\n\t\t\t\tduplex: 'half',\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t'Content-Length': blob.size.toString()\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\t\tconst { small, large, empty } = res.data;\n\t\texpect(empty.name).toBe('empty.txt');\n\t\texpect(empty.type).toBe('text/plain');\n\t\texpect(empty.size).toBe(0);\n\t\texpect(await empty.text()).toBe('');\n\t\texpect(small.name).toBe('a.txt');\n\t\texpect(small.type).toBe('text/plain');\n\t\texpect(small.size).toBe(1);\n\t\texpect(await small.text()).toBe('a');\n\n\t\texpect(large.name).toBe('large.txt');\n\t\texpect(large.type).toBe('text/plain');\n\t\texpect(large.size).toBe(1024);\n\t\texpect(large.lastModified).toBe(100);\n\t\tconst buffer = new Uint8Array(large.size);\n\t\tlet cursor = 0;\n\t\tfor await (const chunk of large.stream()) {\n\t\t\tbuffer.set(chunk, cursor);\n\t\t\tcursor += chunk.byteLength;\n\t\t}\n\t\texpect(buffer).toEqual(new Uint8Array(1024).fill('a'.charCodeAt(0)));\n\t\t// text should be callable after stream is consumed\n\t\texpect(await large.text()).toBe('a'.repeat(1024));\n\t});\n\ttest('LazyFile methods', async () => {\n\t\tconst { blob } = serialize_binary_form(\n\t\t\t{\n\t\t\t\tfile: new File(['Hello World'], 'a.txt')\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tconst res = await deserialize_binary_form(\n\t\t\tnew Request('http://test', {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: blob,\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t'Content-Length': blob.size.toString()\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\t\t/** @type {File} */\n\t\tconst file = res.data.file;\n\t\tconst expected = text_encoder.encode('Hello World');\n\t\texpect(await file.text()).toBe('Hello World');\n\t\texpect(await file.arrayBuffer()).toEqual(expected.buffer);\n\t\texpect(await file.bytes()).toEqual(expected);\n\t\texpect(await new Response(file.stream()).arrayBuffer()).toEqual(expected.buffer);\n\t\tconst ello_slice = file.slice(1, 5, 'test/content-type');\n\t\texpect(ello_slice.type).toBe('test/content-type');\n\t\texpect(await ello_slice.text()).toBe('ello');\n\t\tconst world_slice = file.slice(-5);\n\t\texpect(await world_slice.text()).toBe('World');\n\t\texpect(world_slice.type).toBe(file.type);\n\t});\n\n\ttest('throws when Content-Length is invalid', async () => {\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(\n\t\t\t\tnew Request('http://test', {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody: 'foo',\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).rejects.toThrow('invalid Content-Length header');\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(\n\t\t\t\tnew Request('http://test', {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody: 'foo',\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t\t'Content-Length': 'invalid'\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).rejects.toThrow('invalid Content-Length header');\n\t});\n\n\ttest('data length check', async () => {\n\t\tconst { blob } = serialize_binary_form(\n\t\t\t{\n\t\t\t\tfoo: 'bar'\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(\n\t\t\t\tnew Request('http://test', {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody: blob,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t\t'Content-Length': (blob.size - 1).toString()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).rejects.toThrow('data overflow');\n\t});\n\n\ttest('file offset table length check', async () => {\n\t\tconst { blob } = serialize_binary_form(\n\t\t\t{\n\t\t\t\tfile: new File([''], 'a.txt')\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(\n\t\t\t\tnew Request('http://test', {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody: blob,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t\t'Content-Length': (blob.size - 1).toString()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).rejects.toThrow('file offset table overflow');\n\t});\n\n\ttest('file length check', async () => {\n\t\tconst { blob } = serialize_binary_form(\n\t\t\t{\n\t\t\t\tfile: new File(['a'], 'a.txt')\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(\n\t\t\t\tnew Request('http://test', {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody: blob,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t\t'Content-Length': (blob.size - 1).toString()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).rejects.toThrow('file data overflow');\n\t});\n\n\ttest('does not preallocate large buffers for incomplete bodies', async () => {\n\t\tconst OriginalUint8Array = Uint8Array;\n\t\tconst header_bytes = 1 + 4 + 2;\n\t\tconst data_length = 32 * 1024 * 1024;\n\n\t\t// This test should fail on the vulnerable implementation. To make the overallocation observable,\n\t\t// temporarily guard allocations of large Uint8Arrays — the fixed code only allocates after reading\n\t\t// the full range, so it should not trip this guard for an incomplete body.\n\t\tclass GuardedUint8Array extends OriginalUint8Array {\n\t\t\t/** @param {...any} args */\n\t\t\tconstructor(...args) {\n\t\t\t\tif (typeof args[0] === 'number' && args[0] === data_length) {\n\t\t\t\t\tthrow new Error('EAGER_ALLOC');\n\t\t\t\t}\n\n\t\t\t\tif (args.length === 0) {\n\t\t\t\t\tsuper();\n\t\t\t\t} else if (args.length === 1) {\n\t\t\t\t\tsuper(/** @type {any} */ (args[0]));\n\t\t\t\t} else if (args.length === 2) {\n\t\t\t\t\tsuper(/** @type {any} */ (args[0]), /** @type {any} */ (args[1]));\n\t\t\t\t} else {\n\t\t\t\t\tsuper(\n\t\t\t\t\t\t/** @type {any} */ (args[0]),\n\t\t\t\t\t\t/** @type {any} */ (args[1]),\n\t\t\t\t\t\t/** @type {any} */ (args[2])\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/** @type {any} */ (globalThis).Uint8Array = GuardedUint8Array;\n\t\ttry {\n\t\t\t// First chunk must include at least 1 byte past the header so that `get_buffer(header_bytes, data_length)`\n\t\t\t// takes the multi-chunk path.\n\t\t\tconst first_chunk = new OriginalUint8Array(header_bytes + 1);\n\t\t\tfirst_chunk[0] = 0;\n\t\t\tconst header_view = new DataView(\n\t\t\t\tfirst_chunk.buffer,\n\t\t\t\tfirst_chunk.byteOffset,\n\t\t\t\tfirst_chunk.byteLength\n\t\t\t);\n\t\t\theader_view.setUint32(1, data_length, true);\n\t\t\theader_view.setUint16(5, 0, true);\n\n\t\t\tconst stream = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tcontroller.enqueue(first_chunk);\n\t\t\t\t\tcontroller.close();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tawait expect(\n\t\t\t\tdeserialize_binary_form(\n\t\t\t\t\tnew Request('http://test', {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tbody: stream,\n\t\t\t\t\t\t// @ts-expect-error duplex required in node\n\t\t\t\t\t\tduplex: 'half',\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t\t\t'Content-Length': (header_bytes + data_length).toString()\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t).rejects.toThrow('data too short');\n\t\t} finally {\n\t\t\t/** @type {any} */ (globalThis).Uint8Array = OriginalUint8Array;\n\t\t}\n\t});\n\n\ttest('rejects type confusion attack on file metadata', async () => {\n\t\t// Reproduces the attack from the vulnerability report: a crafted devalue payload\n\t\t// where File metadata contains nested arrays referencing a BigInt(1e308) instead\n\t\t// of primitive values. Without validation, arithmetic on `size` triggers recursive\n\t\t// array-to-string coercion causing CPU exhaustion.\n\t\t//\n\t\t// Uses the same payload structure as the original POC but with repeats=2\n\t\t// (enough to prove the fix, without risk of stalling if it regresses).\n\t\tconst repeats = 2;\n\n\t\tconst data = JSON.stringify([\n\t\t\t// Index 0: root array referencing File proxy objects at indices 10, 11\n\t\t\t[...Array(repeats)].map((_, i) => 10 + i),\n\t\t\t// Index 1: holey array [, , size] — devalue HOLE (-2) creates sparse entries\n\t\t\t// so the File reviver gets [undefined, undefined, <nested arrays>]\n\t\t\t[-2, -2, 2],\n\t\t\t// Indices 2–8: cascade of arrays referencing each other, amplifying traversal\n\t\t\t[3, 3, 3, 3, 3, 3, 3],\n\t\t\t[4, 4, 4, 4, 4, 4, 4],\n\t\t\t[5, 5, 5, 5, 5, 5, 5, 5],\n\t\t\t[6, 6, 6, 6, 6, 6, 6, 6],\n\t\t\t[7, 7, 7, 7, 7, 7, 7, 7],\n\t\t\t[8, 8, 8, 8, 8, 8, 8, 8],\n\t\t\t[9, 9, 9, 9, 9, 9, 9, 9],\n\t\t\t// Index 9: BigInt(1e308) — a 309-digit number, expensive to coerce to string\n\t\t\t['BigInt', 1e308],\n\t\t\t// Indices 10+: File objects referencing the holey array at index 1\n\t\t\t...Array(repeats).fill(['File', 1])\n\t\t]);\n\n\t\tconst file_offsets = JSON.stringify([0]);\n\t\tconst data_buf = text_encoder.encode(data);\n\t\tconst offsets_buf = text_encoder.encode(file_offsets);\n\t\tconst total = 7 + data_buf.length + offsets_buf.length;\n\t\tconst body = new Uint8Array(total);\n\t\tconst view = new DataView(body.buffer);\n\t\tbody[0] = 0;\n\t\tview.setUint32(1, data_buf.length, true);\n\t\tview.setUint16(5, offsets_buf.length, true);\n\t\tbody.set(data_buf, 7);\n\t\tbody.set(offsets_buf, 7 + data_buf.length);\n\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(\n\t\t\t\tnew Request('http://test', {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t\t'Content-Length': total.toString()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).rejects.toThrow('invalid file metadata');\n\t}, 1000);\n\n\ttest.each([\n\t\t{\n\t\t\tname: 'name is a number instead of string',\n\t\t\tpayload: '[[1,3],{\"file\":2},[\"File\",4],{},[5,6,7,8,9],123,\"text/plain\",0,0,0]'\n\t\t},\n\t\t{\n\t\t\tname: 'size is an array instead of number',\n\t\t\tpayload: '[[1,3],{\"file\":2},[\"File\",4],{},[5,6,7,8,9],\"a.txt\",\"text/plain\",[10,10,10],0,0,1]'\n\t\t},\n\t\t{\n\t\t\tname: 'last_modified is a string instead of number',\n\t\t\tpayload: '[[1,3],{\"file\":2},[\"File\",4],{},[5,6,7,8,9],\"a.txt\",\"text/plain\",0,\"bad\",0]'\n\t\t},\n\t\t{\n\t\t\tname: 'sparse/holey array (fields are undefined)',\n\t\t\tpayload: '[[1,3],{\"file\":2},[\"File\",4],{},[-2,-2,7],\"a.txt\",\"text/plain\",0]'\n\t\t}\n\t])('rejects invalid file metadata: $name', async ({ payload }) => {\n\t\tawait expect(deserialize_binary_form(build_raw_request(payload))).rejects.toThrow(\n\t\t\t'invalid file metadata'\n\t\t);\n\t});\n\n\ttest('rejects memory amplification attack via nested array in file offset table', async () => {\n\t\t// A crafted file offset table\n\t\t// containing a nested array like [[1e20,1e20,...,1e20]]. When file_offsets[0] is\n\t\t// added to a number, the inner array coerces to a ~273,000-char string. With\n\t\t// ~58,000 LazyFile instances from a 1MB payload, this requires ~14.7GB of memory.\n\t\t//\n\t\t// We use a small payload (13 values) that is enough to trigger the validation\n\t\t// error without risk of memory issues if the fix regresses.\n\t\tconst inner_count = 13;\n\t\tconst malicious_offsets = JSON.stringify([[...Array(inner_count).fill(1e20)]]);\n\n\t\t// Build a minimal binary form request with the malicious offset table\n\t\tconst data = '[[1,3],{\"file\":2},[\"File\",4],{},[5,6,7,8,9],\"a.txt\",\"text/plain\",0,0,0]';\n\t\tconst data_buf = text_encoder.encode(data);\n\t\tconst offsets_buf = text_encoder.encode(malicious_offsets);\n\t\tconst total = 7 + data_buf.length + offsets_buf.length + 1;\n\t\tconst body = new Uint8Array(total);\n\t\tconst view = new DataView(body.buffer);\n\t\tbody[0] = 0;\n\t\tview.setUint32(1, data_buf.length, true);\n\t\tview.setUint16(5, offsets_buf.length, true);\n\t\tbody.set(data_buf, 7);\n\t\tbody.set(offsets_buf, 7 + data_buf.length);\n\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(\n\t\t\t\tnew Request('http://test', {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t\t'Content-Length': total.toString()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t)\n\t\t).rejects.toThrow('invalid file offset table');\n\t}, 1000);\n\n\ttest.each([\n\t\t{\n\t\t\tname: 'nested array (amplification attack)',\n\t\t\toffsets: '[[1e20,1e20]]'\n\t\t},\n\t\t{\n\t\t\tname: 'non-integer float values',\n\t\t\toffsets: '[0, 1.5, 3]'\n\t\t},\n\t\t{\n\t\t\tname: 'negative values',\n\t\t\toffsets: '[0, -1, 2]'\n\t\t},\n\t\t{\n\t\t\tname: 'not an array (object)',\n\t\t\toffsets: '{\"0\": 0}'\n\t\t},\n\t\t{\n\t\t\tname: 'string values in array',\n\t\t\toffsets: '[\"0\", \"1\"]'\n\t\t}\n\t])('rejects invalid file offset table: $name', async ({ offsets }) => {\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(\n\t\t\t\tbuild_raw_request(\n\t\t\t\t\t'[[1,3],{\"file\":2},[\"File\",4],{},[5,6,7,8,9],\"a.txt\",\"text/plain\",0,0,0]',\n\t\t\t\t\toffsets\n\t\t\t\t)\n\t\t\t)\n\t\t).rejects.toThrow('invalid file offset table');\n\t});\n\n\t// Regression test for https://github.com/sveltejs/kit/issues/14971\n\ttest('DataView offset for shared memory', async () => {\n\t\tconst { blob } = serialize_binary_form({ a: 1 }, {});\n\t\tconst chunk = new Uint8Array(await blob.arrayBuffer());\n\t\t// Simulate a stream that has extra bytes at the start in the underlying buffer\n\t\tconst stream = new ReadableStream({\n\t\t\tstart(controller) {\n\t\t\t\tconst offset_buffer = new Uint8Array(chunk.byteLength + 10);\n\t\t\t\toffset_buffer.fill(255);\n\t\t\t\toffset_buffer.set(chunk, 10);\n\t\t\t\tcontroller.enqueue(offset_buffer.subarray(10));\n\t\t\t}\n\t\t});\n\n\t\tconst res = await deserialize_binary_form(\n\t\t\tnew Request('http://test', {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: stream,\n\t\t\t\t// @ts-expect-error duplex required in node\n\t\t\t\tduplex: 'half',\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t'Content-Length': blob.size.toString()\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\n\t\texpect(res.data).toEqual({ a: 1 });\n\t});\n\n\t/**\n\t * Build a binary form request with a raw devalue payload.\n\t * @param {string} devalue_data\n\t * @param {string} file_offsets_json\n\t */\n\tfunction build_raw_request(devalue_data, file_offsets_json = '[0]') {\n\t\tconst data_buf = text_encoder.encode(devalue_data);\n\t\tconst offsets_buf = text_encoder.encode(file_offsets_json);\n\t\tconst total = 7 + data_buf.length + offsets_buf.length + 1; // +1 for a fake file byte\n\t\tconst body = new Uint8Array(total);\n\t\tconst view = new DataView(body.buffer);\n\t\tbody[0] = 0;\n\t\tview.setUint32(1, data_buf.length, true);\n\t\tview.setUint16(5, offsets_buf.length, true);\n\t\tbody.set(data_buf, 7);\n\t\tbody.set(offsets_buf, 7 + data_buf.length);\n\t\treturn new Request('http://test', {\n\t\t\tmethod: 'POST',\n\t\t\tbody,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t'Content-Length': total.toString()\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Build a binary form request with a raw devalue payload and explicit file data.\n\t * @param {string} devalue_data\n\t * @param {string} file_offsets_json\n\t * @param {number} file_data_bytes - number of file data bytes to append\n\t */\n\tfunction build_raw_request_with_files(devalue_data, file_offsets_json, file_data_bytes) {\n\t\tconst data_buf = text_encoder.encode(devalue_data);\n\t\tconst offsets_buf = text_encoder.encode(file_offsets_json);\n\t\tconst total = 7 + data_buf.length + offsets_buf.length + file_data_bytes;\n\t\tconst body = new Uint8Array(total);\n\t\tconst view = new DataView(body.buffer);\n\t\tbody[0] = 0;\n\t\tview.setUint32(1, data_buf.length, true);\n\t\tview.setUint16(5, offsets_buf.length, true);\n\t\tbody.set(data_buf, 7);\n\t\tbody.set(offsets_buf, 7 + data_buf.length);\n\t\t// Fill file data region with 0x41 ('A')\n\t\tbody.fill(0x41, 7 + data_buf.length + offsets_buf.length);\n\t\treturn new Request('http://test', {\n\t\t\tmethod: 'POST',\n\t\t\tbody,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t'Content-Length': total.toString()\n\t\t\t}\n\t\t});\n\t}\n\n\ttest('rejects overlapping file data', async () => {\n\t\t// Two files that reference different offset table entries but whose byte\n\t\t// ranges overlap: file a at offset 0 with size 3, file b at offset 1 with size 3.\n\t\t// Devalue payload with two files:\n\t\t//   index 0: [1,3] - root [data, meta]\n\t\t//   index 1: {\"a\":2,\"b\":4} - data\n\t\t//   index 2: [\"File\",6] - file a reviver\n\t\t//   index 3: {} - meta\n\t\t//   index 4: [\"File\",7] - file b reviver\n\t\t//   index 5: (unused)\n\t\t//   index 6: [8,9,10,11,12] - file a params [name, type, size, last_modified, offset_index]\n\t\t//   index 7: [8,9,10,11,13] - file b params (different offset_index)\n\t\t//   index 8: \"a.txt\"\n\t\t//   index 9: \"text/plain\"\n\t\t//   index 10: 3 - size for both files\n\t\t//   index 11: 0 - last_modified\n\t\t//   index 12: 0 - offset table index 0\n\t\t//   index 13: 1 - offset table index 1\n\t\tconst payload =\n\t\t\t'[[1,3],{\"a\":2,\"b\":4},[\"File\",6],{},[\"File\",7],0,[8,9,10,11,12],[8,9,10,11,13],\"a.txt\",\"text/plain\",3,0,0,1]';\n\t\t// file_offsets: [0, 1] — file a starts at 0, file b starts at 1.\n\t\t// With size=3 each, they overlap (0..3 and 1..4).\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(build_raw_request_with_files(payload, '[0,1]', 4))\n\t\t).rejects.toThrow('overlapping file data');\n\t});\n\n\ttest('rejects duplicate file offset table index', async () => {\n\t\t// Two files that both reference offset table index 0.\n\t\t// Same devalue structure as above, but both files use offset_index=0.\n\t\tconst payload =\n\t\t\t'[[1,3],{\"a\":2,\"b\":4},[\"File\",6],{},[\"File\",7],0,[8,9,10,11,12],[8,9,10,11,12],\"a.txt\",\"text/plain\",1,0,0]';\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(build_raw_request_with_files(payload, '[0]', 1))\n\t\t).rejects.toThrow('duplicate file offset table index');\n\t});\n\n\ttest('rejects gaps in file data', async () => {\n\t\t// Two files with a gap between them: file a at offset 0 with size 1,\n\t\t// file b at offset 3 with size 1 — gap at bytes 1..3.\n\t\tconst payload =\n\t\t\t'[[1,3],{\"a\":2,\"b\":4},[\"File\",6],{},[\"File\",7],0,[8,9,10,11,12],[8,9,10,11,13],\"a.txt\",\"text/plain\",1,0,0,1]';\n\t\t// file_offsets: [0, 3] — file a at 0 (size 1), file b at 3 (size 1), gap at 1..3.\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(build_raw_request_with_files(payload, '[0,3]', 4))\n\t\t).rejects.toThrow('gaps in file data');\n\t});\n\n\ttest('rejects amplification attack via overlapping file data', async () => {\n\t\t// Simulates the vulnerability: many files all pointing to the same data region.\n\t\t// Without the fix, an attacker could craft a <1MB payload that appears to contain\n\t\t// 100+ GB of file data by reusing the same offset for every file entry.\n\t\tconst file_count = 100;\n\t\tconst file_size = 512;\n\n\t\t// Build a devalue payload with file_count files.\n\t\t// Layout:\n\t\t//   0: [1,2] — root [data, meta]\n\t\t//   1: [file_reviver_indices...] — data array\n\t\t//   2: {} — meta\n\t\t//   3: [\"File\", 4] — first file reviver, params at index 4\n\t\t//   4: [S, S+1, S+2, S+3, S+4] — first file params\n\t\t//   5: [\"File\", 6] — second file reviver, params at index 6\n\t\t//   6: [S, S+1, S+2, S+3, S+5] — second file params\n\t\t//   ...\n\t\t//   S: \"a.txt\" — shared name\n\t\t//   S+1: \"text/plain\" — shared type\n\t\t//   S+2: file_size — shared size\n\t\t//   S+3: 0 — shared last_modified\n\t\t//   S+4: 0 — offset index for file 0\n\t\t//   S+5: 1 — offset index for file 1\n\t\t//   ...\n\t\tconst entries = [];\n\t\tentries.push('[1,2]'); // 0: root\n\t\tconst file_reviver_indices = [];\n\t\tfor (let i = 0; i < file_count; i++) {\n\t\t\tfile_reviver_indices.push(3 + i * 2);\n\t\t}\n\t\tentries.push(`[${file_reviver_indices.join(',')}]`); // 1: data array\n\t\tentries.push('{}'); // 2: meta\n\n\t\tconst shared_start = 3 + file_count * 2;\n\t\tfor (let i = 0; i < file_count; i++) {\n\t\t\tconst params_idx = 3 + i * 2 + 1;\n\t\t\tentries.push(`[\"File\",${params_idx}]`);\n\t\t\tentries.push(\n\t\t\t\t`[${shared_start},${shared_start + 1},${shared_start + 2},${shared_start + 3},${shared_start + 4 + i}]`\n\t\t\t);\n\t\t}\n\n\t\t// Shared values\n\t\tentries.push('\"a.txt\"');\n\t\tentries.push('\"text/plain\"');\n\t\tentries.push(String(file_size));\n\t\tentries.push('0');\n\t\t// Per-file offset index values (each file gets a unique index into offset table)\n\t\tfor (let i = 0; i < file_count; i++) {\n\t\t\tentries.push(String(i));\n\t\t}\n\n\t\tconst payload = `[${entries.join(',')}]`;\n\t\t// All offset table entries point to 0 — the amplification vector\n\t\tconst offsets = JSON.stringify(new Array(file_count).fill(0));\n\n\t\tawait expect(\n\t\t\tdeserialize_binary_form(build_raw_request_with_files(payload, offsets, file_size))\n\t\t).rejects.toThrow('overlapping file data');\n\t}, 1000);\n\n\ttest('accepts valid payload with zero-length files', async () => {\n\t\t// Zero-length files should be valid — they all sit at the same offset with size 0.\n\t\t// This tests the secondary sort by size in the overlap check.\n\t\tconst { blob } = serialize_binary_form(\n\t\t\t{\n\t\t\t\ta: new File([], 'a.txt', { type: 'text/plain' }),\n\t\t\t\tb: new File([], 'b.txt', { type: 'text/plain' }),\n\t\t\t\tc: new File(['x'], 'c.txt', { type: 'text/plain' })\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tconst res = await deserialize_binary_form(\n\t\t\tnew Request('http://test', {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: blob,\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': BINARY_FORM_CONTENT_TYPE,\n\t\t\t\t\t'Content-Length': blob.size.toString()\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\t\texpect(res.data.a.size).toBe(0);\n\t\texpect(res.data.b.size).toBe(0);\n\t\texpect(res.data.c.size).toBe(1);\n\t\texpect(await res.data.c.text()).toBe('x');\n\t});\n});\n\ndescribe('deep_set', () => {\n\ttest('always creates own property', () => {\n\t\tconst target = {};\n\n\t\tdeep_set(target, ['toString', 'property'], 'hello');\n\n\t\t// @ts-ignore\n\t\texpect(target.toString.property).toBe('hello');\n\t\t// @ts-ignore\n\t\texpect(Object.prototype.toString.property).toBeUndefined();\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/pathname.js",
    "content": "const DATA_SUFFIX = '/__data.json';\nconst HTML_DATA_SUFFIX = '.html__data.json';\n\n/** @param {string} pathname */\nexport function has_data_suffix(pathname) {\n\treturn pathname.endsWith(DATA_SUFFIX) || pathname.endsWith(HTML_DATA_SUFFIX);\n}\n\n/** @param {string} pathname */\nexport function add_data_suffix(pathname) {\n\tif (pathname.endsWith('.html')) return pathname.replace(/\\.html$/, HTML_DATA_SUFFIX);\n\treturn pathname.replace(/\\/$/, '') + DATA_SUFFIX;\n}\n\n/** @param {string} pathname */\nexport function strip_data_suffix(pathname) {\n\tif (pathname.endsWith(HTML_DATA_SUFFIX)) {\n\t\treturn pathname.slice(0, -HTML_DATA_SUFFIX.length) + '.html';\n\t}\n\n\treturn pathname.slice(0, -DATA_SUFFIX.length);\n}\n\nconst ROUTE_SUFFIX = '/__route.js';\n\n/**\n * @param {string} pathname\n * @returns {boolean}\n */\nexport function has_resolution_suffix(pathname) {\n\treturn pathname.endsWith(ROUTE_SUFFIX);\n}\n\n/**\n * Convert a regular URL to a route to send to SvelteKit's server-side route resolution endpoint\n * @param {string} pathname\n * @returns {string}\n */\nexport function add_resolution_suffix(pathname) {\n\treturn pathname.replace(/\\/$/, '') + ROUTE_SUFFIX;\n}\n\n/**\n * @param {string} pathname\n * @returns {string}\n */\nexport function strip_resolution_suffix(pathname) {\n\treturn pathname.slice(0, -ROUTE_SUFFIX.length);\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/ambient.d.ts",
    "content": "declare module '__SERVER__/internal.js' {\n\texport const options: import('types').SSROptions;\n\texport const get_hooks: () => Promise<Partial<import('types').ServerHooks>>;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/app.js",
    "content": "/** @type {{ decoders: Record<string, (data: any) => any> }} */\nexport let app;\n\n/**\n * @param {{ decoders: Record<string, (data: any) => any> }} value\n */\nexport function set_app(value) {\n\tapp = value;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/constants.js",
    "content": "export const NULL_BODY_STATUS = [101, 103, 204, 205, 304];\n\n// eslint-disable-next-line n/prefer-global/process\nexport const IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer;\n"
  },
  {
    "path": "packages/kit/src/runtime/server/cookie.js",
    "content": "import { parse, serialize } from 'cookie';\nimport { DEV } from 'esm-env';\nimport { normalize_path, resolve } from '../../utils/url.js';\nimport { add_data_suffix } from '../pathname.js';\nimport { text_encoder } from '../utils.js';\n\n// eslint-disable-next-line no-control-regex -- control characters are invalid in cookie names\nconst INVALID_COOKIE_CHARACTER_REGEX = /[\\x00-\\x1F\\x7F()<>@,;:\"/[\\]?={} \\t]/;\n\n/**\n * Tracks all cookies set during dev mode so we can emit warnings\n * when we detect that there's likely cookie misusage due to wrong paths\n *\n * @type {Record<string, Set<string>>} */\nconst cookie_paths = {};\n\n/**\n * Cookies that are larger than this size (including the name and other\n * attributes) are discarded by browsers\n */\nconst MAX_COOKIE_SIZE = 4129;\n\n// TODO 3.0 remove this check\n/** @param {import('./page/types.js').Cookie['options']} options */\nfunction validate_options(options) {\n\tif (options?.path === undefined) {\n\t\tthrow new Error('You must specify a `path` when setting, deleting or serializing cookies');\n\t}\n}\n\n/**\n * Generates a unique key for a cookie based on its domain, path, and name in\n * the format: `<domain>/<path>?<name>`.\n * If domain is undefined, it will be omitted.\n * For example: `/?name`, `example.com/foo?name`.\n *\n * @param {string | undefined} domain\n * @param {string} path\n * @param {string} name\n * @returns {string}\n */\nfunction generate_cookie_key(domain, path, name) {\n\treturn `${domain || ''}${path}?${encodeURIComponent(name)}`;\n}\n\n/**\n * @param {Request} request\n * @param {URL} url\n */\nexport function get_cookies(request, url) {\n\tconst header = request.headers.get('cookie') ?? '';\n\tconst initial_cookies = parse(header, { decode: (value) => value });\n\n\t/** @type {string | undefined} */\n\tlet normalized_url;\n\n\t/** @type {Map<string, import('./page/types.js').Cookie>} */\n\tconst new_cookies = new Map();\n\n\t/** @type {import('cookie').CookieSerializeOptions} */\n\tconst defaults = {\n\t\thttpOnly: true,\n\t\tsameSite: 'lax',\n\t\tsecure: url.hostname === 'localhost' && url.protocol === 'http:' ? false : true\n\t};\n\n\t/** @type {import('@sveltejs/kit').Cookies} */\n\tconst cookies = {\n\t\t// The JSDoc param annotations appearing below for get, set and delete\n\t\t// are necessary to expose the `cookie` library types to\n\t\t// typescript users. `@type {import('@sveltejs/kit').Cookies}` above is not\n\t\t// sufficient to do so.\n\n\t\t/**\n\t\t * @param {string} name\n\t\t * @param {import('cookie').CookieParseOptions} [opts]\n\t\t */\n\t\tget(name, opts) {\n\t\t\t// Look for the most specific matching cookie from new_cookies\n\t\t\tconst best_match = Array.from(new_cookies.values())\n\t\t\t\t.filter((c) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tc.name === name &&\n\t\t\t\t\t\tdomain_matches(url.hostname, c.options.domain) &&\n\t\t\t\t\t\tpath_matches(url.pathname, c.options.path)\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t\t.sort((a, b) => b.options.path.length - a.options.path.length)[0];\n\n\t\t\tif (best_match) {\n\t\t\t\treturn best_match.options.maxAge === 0 ? undefined : best_match.value;\n\t\t\t}\n\n\t\t\tconst req_cookies = parse(header, { decode: opts?.decode });\n\t\t\tconst cookie = req_cookies[name]; // the decoded string or undefined\n\n\t\t\t// in development, if the cookie was set during this session with `cookies.set`,\n\t\t\t// but at a different path, warn the user. (ignore cookies from request headers,\n\t\t\t// since we don't know which path they were set at)\n\t\t\tif (DEV && !cookie) {\n\t\t\t\tconst paths = Array.from(cookie_paths[name] ?? []).filter((path) => {\n\t\t\t\t\t// we only care about paths that are _more_ specific than the current path\n\t\t\t\t\treturn path_matches(path, url.pathname) && path !== url.pathname;\n\t\t\t\t});\n\n\t\t\t\tif (paths.length > 0) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t// prettier-ignore\n\t\t\t\t\t\t`'${name}' cookie does not exist for ${url.pathname}, but was previously set at ${conjoin([...paths])}. Did you mean to set its 'path' to '/' instead?`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn cookie;\n\t\t},\n\n\t\t/**\n\t\t * @param {import('cookie').CookieParseOptions} [opts]\n\t\t */\n\t\tgetAll(opts) {\n\t\t\tconst cookies = parse(header, { decode: opts?.decode });\n\n\t\t\t// Group cookies by name and find the most specific one for each name\n\t\t\tconst lookup = new Map();\n\n\t\t\tfor (const c of new_cookies.values()) {\n\t\t\t\tif (\n\t\t\t\t\tdomain_matches(url.hostname, c.options.domain) &&\n\t\t\t\t\tpath_matches(url.pathname, c.options.path)\n\t\t\t\t) {\n\t\t\t\t\tconst existing = lookup.get(c.name);\n\n\t\t\t\t\t// If no existing cookie or this one has a more specific (longer) path, use this one\n\t\t\t\t\tif (!existing || c.options.path.length > existing.options.path.length) {\n\t\t\t\t\t\tlookup.set(c.name, c);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add the most specific cookies to the result\n\t\t\tfor (const c of lookup.values()) {\n\t\t\t\tcookies[c.name] = c.value;\n\t\t\t}\n\n\t\t\treturn Object.entries(cookies).map(([name, value]) => ({ name, value }));\n\t\t},\n\n\t\t/**\n\t\t * @param {string} name\n\t\t * @param {string} value\n\t\t * @param {import('./page/types.js').Cookie['options']} options\n\t\t */\n\t\tset(name, value, options) {\n\t\t\t// TODO: remove this check in 3.0\n\t\t\tconst illegal_characters = name.match(INVALID_COOKIE_CHARACTER_REGEX);\n\t\t\tif (illegal_characters) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`The cookie name \"${name}\" will be invalid in SvelteKit 3.0 as it contains ${illegal_characters.join(\n\t\t\t\t\t\t' and '\n\t\t\t\t\t)}. See RFC 2616 for more details https://datatracker.ietf.org/doc/html/rfc2616#section-2.2`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tvalidate_options(options);\n\t\t\tset_internal(name, value, { ...defaults, ...options });\n\t\t},\n\n\t\t/**\n\t\t * @param {string} name\n\t\t *  @param {import('./page/types.js').Cookie['options']} options\n\t\t */\n\t\tdelete(name, options) {\n\t\t\tvalidate_options(options);\n\t\t\tcookies.set(name, '', { ...options, maxAge: 0 });\n\t\t},\n\n\t\t/**\n\t\t * @param {string} name\n\t\t * @param {string} value\n\t\t *  @param {import('./page/types.js').Cookie['options']} options\n\t\t */\n\t\tserialize(name, value, options) {\n\t\t\tvalidate_options(options);\n\n\t\t\tlet path = options.path;\n\n\t\t\tif (!options.domain || options.domain === url.hostname) {\n\t\t\t\tif (!normalized_url) {\n\t\t\t\t\tthrow new Error('Cannot serialize cookies until after the route is determined');\n\t\t\t\t}\n\t\t\t\tpath = resolve(normalized_url, path);\n\t\t\t}\n\n\t\t\treturn serialize(name, value, { ...defaults, ...options, path });\n\t\t}\n\t};\n\n\t/**\n\t * @param {URL} destination\n\t * @param {string | null} header\n\t */\n\tfunction get_cookie_header(destination, header) {\n\t\t/** @type {Record<string, string>} */\n\t\tconst combined_cookies = {\n\t\t\t// cookies sent by the user agent have lowest precedence\n\t\t\t...initial_cookies\n\t\t};\n\n\t\t// cookies previous set during this event with cookies.set have higher precedence\n\t\tfor (const cookie of new_cookies.values()) {\n\t\t\tif (!domain_matches(destination.hostname, cookie.options.domain)) continue;\n\t\t\tif (!path_matches(destination.pathname, cookie.options.path)) continue;\n\n\t\t\tconst encoder = cookie.options.encode || encodeURIComponent;\n\t\t\tcombined_cookies[cookie.name] = encoder(cookie.value);\n\t\t}\n\n\t\t// explicit header has highest precedence\n\t\tif (header) {\n\t\t\tconst parsed = parse(header, { decode: (value) => value });\n\t\t\tfor (const name in parsed) {\n\t\t\t\tcombined_cookies[name] = parsed[name];\n\t\t\t}\n\t\t}\n\n\t\treturn Object.entries(combined_cookies)\n\t\t\t.map(([name, value]) => `${name}=${value}`)\n\t\t\t.join('; ');\n\t}\n\n\t/** @type {Array<() => void>} */\n\tconst internal_queue = [];\n\n\t/**\n\t * @param {string} name\n\t * @param {string} value\n\t * @param {import('./page/types.js').Cookie['options']} options\n\t */\n\tfunction set_internal(name, value, options) {\n\t\tif (!normalized_url) {\n\t\t\tinternal_queue.push(() => set_internal(name, value, options));\n\t\t\treturn;\n\t\t}\n\n\t\tlet path = options.path;\n\n\t\tif (!options.domain || options.domain === url.hostname) {\n\t\t\tpath = resolve(normalized_url, path);\n\t\t}\n\n\t\t// Generate unique key for cookie storage\n\t\tconst cookie_key = generate_cookie_key(options.domain, path, name);\n\t\tconst cookie = { name, value, options: { ...options, path } };\n\t\tnew_cookies.set(cookie_key, cookie);\n\n\t\tif (DEV) {\n\t\t\tconst serialized = serialize(name, value, cookie.options);\n\t\t\tif (text_encoder.encode(serialized).byteLength > MAX_COOKIE_SIZE) {\n\t\t\t\tthrow new Error(`Cookie \"${name}\" is too large, and will be discarded by the browser`);\n\t\t\t}\n\n\t\t\tcookie_paths[name] ??= new Set();\n\n\t\t\tif (!value) {\n\t\t\t\tcookie_paths[name].delete(path);\n\t\t\t} else {\n\t\t\t\tcookie_paths[name].add(path);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {import('types').TrailingSlash} trailing_slash\n\t */\n\tfunction set_trailing_slash(trailing_slash) {\n\t\tnormalized_url = normalize_path(url.pathname, trailing_slash);\n\t\tinternal_queue.forEach((fn) => fn());\n\t}\n\n\treturn { cookies, new_cookies, get_cookie_header, set_internal, set_trailing_slash };\n}\n\n/**\n * @param {string} hostname\n * @param {string} [constraint]\n */\nexport function domain_matches(hostname, constraint) {\n\tif (!constraint) return true;\n\n\tconst normalized = constraint[0] === '.' ? constraint.slice(1) : constraint;\n\n\tif (hostname === normalized) return true;\n\treturn hostname.endsWith('.' + normalized);\n}\n\n/**\n * @param {string} path\n * @param {string} [constraint]\n */\nexport function path_matches(path, constraint) {\n\tif (!constraint) return true;\n\n\tconst normalized = constraint.endsWith('/') ? constraint.slice(0, -1) : constraint;\n\n\tif (path === normalized) return true;\n\treturn path.startsWith(normalized + '/');\n}\n\n/**\n * @param {Headers} headers\n * @param {MapIterator<import('./page/types.js').Cookie>} cookies\n */\nexport function add_cookies_to_headers(headers, cookies) {\n\tfor (const new_cookie of cookies) {\n\t\tconst { name, value, options } = new_cookie;\n\t\theaders.append('set-cookie', serialize(name, value, options));\n\n\t\t// special case — for routes ending with .html, the route data lives in a sibling\n\t\t// `.html__data.json` file rather than a child `/__data.json` file, which means\n\t\t// we need to duplicate the cookie\n\t\tif (options.path.endsWith('.html')) {\n\t\t\tconst path = add_data_suffix(options.path);\n\t\t\theaders.append('set-cookie', serialize(name, value, { ...options, path }));\n\t\t}\n\t}\n}\n\n/**\n * @param {string[]} array\n */\nfunction conjoin(array) {\n\tif (array.length <= 2) return array.join(' and ');\n\treturn `${array.slice(0, -1).join(', ')} and ${array.at(-1)}`;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/cookie.spec.js",
    "content": "import process from 'node:process';\nimport { assert, expect, test, describe } from 'vitest';\nimport { domain_matches, path_matches, get_cookies } from './cookie.js';\nimport { installPolyfills } from '@sveltejs/kit/node/polyfills';\n\ninstallPolyfills();\n\nconst domains = {\n\tpositive: [\n\t\t['localhost'],\n\t\t['example.com', 'example.com'],\n\t\t['sub.example.com', 'example.com'],\n\t\t['example.com', '.example.com'],\n\t\t['sub.example.com', '.example.com']\n\t]\n};\n\nconst paths = {\n\tpositive: [['/'], ['/foo', '/'], ['/foo', '/foo'], ['/foo/', '/foo'], ['/foo', '/foo/']],\n\n\tnegative: [\n\t\t['/', '/foo'],\n\t\t['/food', '/foo']\n\t]\n};\n\n/** @param {{ href?: string, headers?: Record<string, string> }} href */\nconst cookies_setup = ({ href, headers } = {}) => {\n\tconst url = new URL(href || 'https://example.com');\n\tconst request = new Request(url, {\n\t\theaders: new Headers({\n\t\t\tcookie: 'a=b;',\n\t\t\t...headers\n\t\t})\n\t});\n\tconst result = get_cookies(request, url);\n\tresult.set_trailing_slash('ignore');\n\treturn result;\n};\n\ndescribe.skipIf(process.env.NODE_ENV === 'production')('cookies in dev', () => {\n\ttest('warns if cookie exceeds 4,129 bytes', () => {\n\t\ttry {\n\t\t\tconst { cookies } = cookies_setup();\n\t\t\tcookies.set('a', 'a'.repeat(4097), { path: '/' });\n\t\t} catch (e) {\n\t\t\tconst error = /** @type {Error} */ (e);\n\n\t\t\tassert.equal(error.message, 'Cookie \"a\" is too large, and will be discarded by the browser');\n\t\t}\n\t});\n});\n\ndescribe.skipIf(process.env.NODE_ENV !== 'production')('cookies in prod', () => {\n\tdomains.positive.forEach(([hostname, constraint]) => {\n\t\ttest(`${hostname} / ${constraint}`, () => {\n\t\t\tassert.ok(domain_matches(hostname, constraint));\n\t\t});\n\t});\n\n\tpaths.positive.forEach(([path, constraint]) => {\n\t\ttest(`${path} / ${constraint}`, () => {\n\t\t\tassert.ok(path_matches(path, constraint));\n\t\t});\n\t});\n\n\tpaths.negative.forEach(([path, constraint]) => {\n\t\ttest(`! ${path} / ${constraint}`, () => {\n\t\t\tassert.isFalse(path_matches(path, constraint));\n\t\t});\n\t});\n\n\ttest('a cookie should not be present after it is deleted', () => {\n\t\tconst { cookies } = cookies_setup();\n\t\tcookies.set('a', 'b', { path: '/' });\n\t\texpect(cookies.get('a')).toEqual('b');\n\t\tcookies.delete('a', { path: '/' });\n\t\tassert.isUndefined(cookies.get('a'));\n\t});\n\n\ttest('default values when set is called', () => {\n\t\tconst { cookies, new_cookies } = cookies_setup();\n\t\tcookies.set('a', 'b', { path: '/' });\n\t\tconst opts = new_cookies.get('/?a')?.options;\n\t\tassert.equal(opts?.secure, true);\n\t\tassert.equal(opts?.httpOnly, true);\n\t\tassert.equal(opts?.path, '/');\n\t\tassert.equal(opts?.sameSite, 'lax');\n\t});\n\n\ttest('default values when set is called on sub path', () => {\n\t\tconst { cookies, new_cookies } = cookies_setup({ href: 'https://example.com/foo/bar' });\n\t\tcookies.set('a', 'b', { path: '' });\n\t\tconst opts = new_cookies.get('/foo/bar?a')?.options;\n\t\tassert.equal(opts?.secure, true);\n\t\tassert.equal(opts?.httpOnly, true);\n\t\tassert.equal(opts?.path, '/foo/bar');\n\t\tassert.equal(opts?.sameSite, 'lax');\n\t});\n\n\ttest('default values when on localhost', () => {\n\t\tconst { cookies, new_cookies } = cookies_setup({ href: 'http://localhost:1234' });\n\t\tcookies.set('a', 'b', { path: '/' });\n\t\tconst opts = new_cookies.get('/?a')?.options;\n\t\tassert.equal(opts?.secure, false);\n\t});\n\n\ttest('overridden defaults when set is called', () => {\n\t\tconst { cookies, new_cookies } = cookies_setup();\n\t\tcookies.set('a', 'b', { secure: false, httpOnly: false, sameSite: 'strict', path: '/a/b/c' });\n\t\tconst opts = new_cookies.get('/a/b/c?a')?.options;\n\t\tassert.equal(opts?.secure, false);\n\t\tassert.equal(opts?.httpOnly, false);\n\t\tassert.equal(opts?.path, '/a/b/c');\n\t\tassert.equal(opts?.sameSite, 'strict');\n\t});\n\n\ttest('default values when delete is called', () => {\n\t\tconst { cookies, new_cookies } = cookies_setup();\n\t\tcookies.delete('a', { path: '/' });\n\t\tconst opts = new_cookies.get('/?a')?.options;\n\t\tassert.equal(opts?.secure, true);\n\t\tassert.equal(opts?.httpOnly, true);\n\t\tassert.equal(opts?.path, '/');\n\t\tassert.equal(opts?.sameSite, 'lax');\n\t\tassert.equal(opts?.maxAge, 0);\n\t});\n\n\ttest('overridden defaults when delete is called', () => {\n\t\tconst { cookies, new_cookies } = cookies_setup();\n\t\tcookies.delete('a', { secure: false, httpOnly: false, sameSite: 'strict', path: '/a/b/c' });\n\t\tconst opts = new_cookies.get('/a/b/c?a')?.options;\n\t\tassert.equal(opts?.secure, false);\n\t\tassert.equal(opts?.httpOnly, false);\n\t\tassert.equal(opts?.path, '/a/b/c');\n\t\tassert.equal(opts?.sameSite, 'strict');\n\t\tassert.equal(opts?.maxAge, 0);\n\t});\n\n\ttest('cannot override maxAge on delete', () => {\n\t\tconst { cookies, new_cookies } = cookies_setup();\n\t\tcookies.delete('a', { path: '/', maxAge: 1234 });\n\t\tconst opts = new_cookies.get('/?a')?.options;\n\t\tassert.equal(opts?.maxAge, 0);\n\t});\n\n\ttest('last cookie set with the same name wins', () => {\n\t\tconst { cookies, new_cookies } = cookies_setup();\n\t\tcookies.set('a', 'foo', { path: '/' });\n\t\tcookies.set('a', 'bar', { path: '/' });\n\t\tconst entry = new_cookies.get('/?a');\n\t\tassert.equal(entry?.value, 'bar');\n\t});\n\n\ttest('cookie names are case sensitive', () => {\n\t\tconst { cookies, new_cookies } = cookies_setup();\n\t\t// not that one should do this, but we follow the spec...\n\t\tcookies.set('a', 'foo', { path: '/' });\n\t\tcookies.set('A', 'bar', { path: '/' });\n\t\tconst entrya = new_cookies.get('/?a');\n\t\tconst entryA = new_cookies.get('/?A');\n\t\tassert.equal(entrya?.value, 'foo');\n\t\tassert.equal(entryA?.value, 'bar');\n\t});\n\n\ttest('serialized cookie header should be url-encoded', () => {\n\t\tconst href = 'https://example.com';\n\t\tconst { cookies, get_cookie_header } = cookies_setup({\n\t\t\thref,\n\t\t\theaders: {\n\t\t\t\tcookie: 'a=f%C3%BC; b=foo+bar' // a=fü\n\t\t\t}\n\t\t});\n\t\tcookies.set('c', 'fö', { path: '/' }); // should use default encoding\n\t\tcookies.set('d', 'fö', { path: '/', encode: () => 'öf' }); // should respect `encode`\n\t\tconst header = get_cookie_header(new URL(href), 'e=f%C3%A4; f=foo+bar');\n\t\tassert.equal(header, 'a=f%C3%BC; b=foo+bar; c=f%C3%B6; d=öf; e=f%C3%A4; f=foo+bar');\n\t});\n\n\ttest('get all cookies from header and set calls', () => {\n\t\tconst { cookies } = cookies_setup();\n\t\texpect(cookies.getAll()).toEqual([{ name: 'a', value: 'b' }]);\n\n\t\tcookies.set('a', 'foo', { path: '/' });\n\t\tcookies.set('a', 'bar', { path: '/' });\n\t\tcookies.set('b', 'baz', { path: '/' });\n\n\t\texpect(cookies.getAll()).toEqual([\n\t\t\t{ name: 'a', value: 'bar' },\n\t\t\t{ name: 'b', value: 'baz' }\n\t\t]);\n\t});\n\n\ttest(\"set_internal isn't affected by defaults\", () => {\n\t\tconst { cookies, new_cookies, set_internal } = cookies_setup({\n\t\t\thref: 'https://example.com/a/b/c'\n\t\t});\n\n\t\tconst options = {\n\t\t\tsecure: false,\n\t\t\thttpOnly: false,\n\t\t\tsameSite: /** @type {const} */ ('none'),\n\t\t\tpath: '/a/b/c'\n\t\t};\n\n\t\tset_internal('test', 'foo', options);\n\n\t\texpect(cookies.get('test')).toEqual('foo');\n\t\texpect(new_cookies.get('/a/b/c?test')?.options).toEqual(options);\n\t});\n\n\ttest('reproduce issue #13947: multiple cookies with same name but different paths', () => {\n\t\t// Test on root path to see if most specific cookie wins\n\t\tconst { cookies: root_cookies } = cookies_setup({ href: 'https://example.com/' });\n\t\troot_cookies.set('key', 'value_root', { path: '/' });\n\t\troot_cookies.set('key', 'value_foo', { path: '/foo' });\n\n\t\t// When on root path, should get the root cookie\n\t\texpect(root_cookies.get('key')).toEqual('value_root');\n\n\t\t// Test on /foo path to see if more specific cookie wins\n\t\tconst { cookies: foo_cookies } = cookies_setup({ href: 'https://example.com/foo' });\n\t\tfoo_cookies.set('key', 'value_root', { path: '/' });\n\t\tfoo_cookies.set('key', 'value_foo', { path: '/foo' });\n\n\t\t// When on /foo path, should get the more specific /foo cookie\n\t\texpect(foo_cookies.get('key')).toEqual('value_foo');\n\t});\n\n\ttest('cookies with same name but different domains work correctly', () => {\n\t\t// Test setting cookies with different domains (unique key storage should work)\n\t\tconst { cookies, new_cookies } = cookies_setup({ href: 'https://example.com/' });\n\n\t\tcookies.set('key', 'value1', { path: '/', domain: 'example.com' });\n\t\tcookies.set('key', 'value2', { path: '/', domain: 'sub.example.com' });\n\n\t\t// Both cookies should be stored with unique keys\n\t\texpect(new_cookies.get('example.com/?key')).toBeDefined();\n\t\texpect(new_cookies.get('sub.example.com/?key')).toBeDefined();\n\t\texpect(new_cookies.get('example.com/?key')?.value).toEqual('value1');\n\t\texpect(new_cookies.get('sub.example.com/?key')?.value).toEqual('value2');\n\t});\n\n\ttest('cookie path specificity: more specific paths win', () => {\n\t\tconst { cookies } = cookies_setup({ href: 'https://example.com/x/y/z' });\n\n\t\t// Set cookies with increasing path specificity\n\t\tcookies.set('n', '1', { path: '/' });\n\t\tcookies.set('n', '2', { path: '/x' });\n\t\tcookies.set('n', '3', { path: '/x/y' });\n\t\tcookies.set('n', '4', { path: '/x/y/z' });\n\n\t\t// Most specific path should win\n\t\texpect(cookies.get('n')).toEqual('4');\n\t});\n\n\ttest('backward compatibility: get without domain/path options still works', () => {\n\t\tconst { cookies } = cookies_setup();\n\n\t\t// Set a cookie the old way\n\t\tcookies.set('old-style', 'value', { path: '/' });\n\n\t\t// Should be retrievable without specifying path\n\t\texpect(cookies.get('old-style')).toEqual('value');\n\t});\n\n\ttest('getAll should return most specific cookie when multiple cookies have same name', () => {\n\t\t// This test demonstrates the bug: getAll doesn't respect path specificity like get() does\n\t\tconst { cookies } = cookies_setup({ href: 'https://example.com/foo/bar' });\n\n\t\t// Set cookies with the same name but different path specificity\n\t\t// Setting most specific first, then less specific ones to expose the bug\n\t\tcookies.set('duplicate', 'foobar_value', { path: '/foo/bar' }); // Most specific\n\t\tcookies.set('duplicate', 'root_value', { path: '/' }); // Least specific\n\t\tcookies.set('duplicate', 'foo_value', { path: '/foo' }); // Middle specificity\n\n\t\tconst all = cookies.getAll();\n\t\tconst duplicate = all.find((c) => c.name === 'duplicate');\n\n\t\texpect(duplicate?.value).toEqual('foobar_value');\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/server/data/index.js",
    "content": "import { text } from '@sveltejs/kit';\nimport { HttpError, SvelteKitError, Redirect } from '@sveltejs/kit/internal';\nimport { normalize_error } from '../../../utils/error.js';\nimport { once } from '../../../utils/functions.js';\nimport { server_data_serializer_json } from '../page/data_serializer.js';\nimport { load_server_data } from '../page/load_data.js';\nimport { handle_error_and_jsonify } from '../utils.js';\nimport { normalize_path } from '../../../utils/url.js';\nimport { text_encoder } from '../../utils.js';\n\n/**\n * @param {import('@sveltejs/kit').RequestEvent} event\n * @param {import('types').RequestState} event_state\n * @param {import('types').SSRRoute} route\n * @param {import('types').SSROptions} options\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n * @param {import('types').SSRState} state\n * @param {boolean[] | undefined} invalidated_data_nodes\n * @param {import('types').TrailingSlash} trailing_slash\n * @returns {Promise<Response>}\n */\nexport async function render_data(\n\tevent,\n\tevent_state,\n\troute,\n\toptions,\n\tmanifest,\n\tstate,\n\tinvalidated_data_nodes,\n\ttrailing_slash\n) {\n\tif (!route.page) {\n\t\t// requesting /__data.json should fail for a +server.js\n\t\treturn new Response(undefined, {\n\t\t\tstatus: 404\n\t\t});\n\t}\n\n\ttry {\n\t\tconst node_ids = [...route.page.layouts, route.page.leaf];\n\t\tconst invalidated = invalidated_data_nodes ?? node_ids.map(() => true);\n\n\t\tlet aborted = false;\n\n\t\tconst url = new URL(event.url);\n\t\turl.pathname = normalize_path(url.pathname, trailing_slash);\n\n\t\tconst new_event = { ...event, url };\n\n\t\tconst functions = node_ids.map((n, i) => {\n\t\t\treturn once(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\treturn /** @type {import('types').ServerDataSkippedNode} */ ({\n\t\t\t\t\t\t\ttype: 'skip'\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// == because it could be undefined (in dev) or null (in build, because of JSON.stringify)\n\t\t\t\t\tconst node = n == undefined ? n : await manifest._.nodes[n]();\n\t\t\t\t\t// load this. for the child, return as is. for the final result, stream things\n\t\t\t\t\treturn load_server_data({\n\t\t\t\t\t\tevent: new_event,\n\t\t\t\t\t\tevent_state,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tparent: async () => {\n\t\t\t\t\t\t\t/** @type {Record<string, any>} */\n\t\t\t\t\t\t\tconst data = {};\n\t\t\t\t\t\t\tfor (let j = 0; j < i; j += 1) {\n\t\t\t\t\t\t\t\tconst parent = /** @type {import('types').ServerDataNode | null} */ (\n\t\t\t\t\t\t\t\t\tawait functions[j]()\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (parent) {\n\t\t\t\t\t\t\t\t\tObject.assign(data, parent.data);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn data;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} catch (e) {\n\t\t\t\t\taborted = true;\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tconst promises = functions.map(async (fn, i) => {\n\t\t\tif (!invalidated[i]) {\n\t\t\t\treturn /** @type {import('types').ServerDataSkippedNode} */ ({\n\t\t\t\t\ttype: 'skip'\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn fn();\n\t\t});\n\n\t\tlet length = promises.length;\n\t\tconst nodes = await Promise.all(\n\t\t\tpromises.map((p, i) =>\n\t\t\t\tp.catch(async (error) => {\n\t\t\t\t\tif (error instanceof Redirect) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Math.min because array isn't guaranteed to resolve in order\n\t\t\t\t\tlength = Math.min(length, i + 1);\n\n\t\t\t\t\treturn /** @type {import('types').ServerErrorNode} */ ({\n\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\terror: await handle_error_and_jsonify(event, event_state, options, error),\n\t\t\t\t\t\tstatus:\n\t\t\t\t\t\t\terror instanceof HttpError || error instanceof SvelteKitError\n\t\t\t\t\t\t\t\t? error.status\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\tconst data_serializer = server_data_serializer_json(event, event_state, options);\n\t\tfor (let i = 0; i < nodes.length; i++) data_serializer.add_node(i, nodes[i]);\n\t\tconst { data, chunks } = data_serializer.get_data();\n\n\t\tif (!chunks) {\n\t\t\t// use a normal JSON response where possible, so we get `content-length`\n\t\t\t// and can use browser JSON devtools for easier inspecting\n\t\t\treturn json_response(data);\n\t\t}\n\n\t\treturn new Response(\n\t\t\tnew ReadableStream({\n\t\t\t\tasync start(controller) {\n\t\t\t\t\tcontroller.enqueue(text_encoder.encode(data));\n\t\t\t\t\tfor await (const chunk of chunks) {\n\t\t\t\t\t\tcontroller.enqueue(text_encoder.encode(chunk));\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.close();\n\t\t\t\t},\n\n\t\t\t\ttype: 'bytes'\n\t\t\t}),\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t// we use a proprietary content type to prevent buffering.\n\t\t\t\t\t// the `text` prefix makes it inspectable\n\t\t\t\t\t'content-type': 'text/sveltekit-data',\n\t\t\t\t\t'cache-control': 'private, no-store'\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t} catch (e) {\n\t\tconst error = normalize_error(e);\n\n\t\tif (error instanceof Redirect) {\n\t\t\treturn redirect_json_response(error);\n\t\t} else {\n\t\t\treturn json_response(await handle_error_and_jsonify(event, event_state, options, error), 500);\n\t\t}\n\t}\n}\n\n/**\n * @param {Record<string, any> | string} json\n * @param {number} [status]\n */\nfunction json_response(json, status = 200) {\n\treturn text(typeof json === 'string' ? json : JSON.stringify(json), {\n\t\tstatus,\n\t\theaders: {\n\t\t\t'content-type': 'application/json',\n\t\t\t'cache-control': 'private, no-store'\n\t\t}\n\t});\n}\n\n/**\n * @param {Redirect} redirect\n */\nexport function redirect_json_response(redirect) {\n\treturn json_response(\n\t\t/** @type {import('types').ServerRedirectNode} */ ({\n\t\t\ttype: 'redirect',\n\t\t\tlocation: redirect.location\n\t\t})\n\t);\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/endpoint.js",
    "content": "import { Redirect } from '@sveltejs/kit/internal';\nimport { with_request_store } from '@sveltejs/kit/internal/server';\nimport { ENDPOINT_METHODS, PAGE_METHODS } from '../../constants.js';\nimport { negotiate } from '../../utils/http.js';\nimport { method_not_allowed } from './utils.js';\n\n/**\n * @param {import('@sveltejs/kit').RequestEvent} event\n * @param {import('types').RequestState} event_state\n * @param {import('types').SSREndpoint} mod\n * @param {import('types').SSRState} state\n * @returns {Promise<Response>}\n */\nexport async function render_endpoint(event, event_state, mod, state) {\n\tconst method = /** @type {import('types').HttpMethod} */ (event.request.method);\n\n\tlet handler = mod[method] || mod.fallback;\n\n\tif (method === 'HEAD' && !mod.HEAD && mod.GET) {\n\t\thandler = mod.GET;\n\t}\n\n\tif (!handler) {\n\t\treturn method_not_allowed(mod, method);\n\t}\n\n\tconst prerender = mod.prerender ?? state.prerender_default;\n\n\tif (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) {\n\t\tthrow new Error('Cannot prerender endpoints that have mutative methods');\n\t}\n\n\tif (state.prerendering && !state.prerendering.inside_reroute && !prerender) {\n\t\tif (state.depth > 0) {\n\t\t\t// if request came from a prerendered page, bail\n\t\t\tthrow new Error(`${event.route.id} is not prerenderable`);\n\t\t} else {\n\t\t\t// if request came direct from the crawler, signal that\n\t\t\t// this route cannot be prerendered, but don't bail\n\t\t\treturn new Response(undefined, { status: 204 });\n\t\t}\n\t}\n\n\ttry {\n\t\tconst response = await with_request_store({ event, state: event_state }, () =>\n\t\t\thandler(/** @type {import('@sveltejs/kit').RequestEvent<Record<string, any>>} */ (event))\n\t\t);\n\n\t\tif (!(response instanceof Response)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid response from route ${event.url.pathname}: handler should return a Response object`\n\t\t\t);\n\t\t}\n\n\t\tif (state.prerendering && (!state.prerendering.inside_reroute || prerender)) {\n\t\t\t// The returned Response might have immutable Headers\n\t\t\t// so we should clone them before trying to mutate them.\n\t\t\t// We also need to clone the response body since it may be read twice during prerendering\n\t\t\tconst cloned = new Response(response.clone().body, {\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders: new Headers(response.headers)\n\t\t\t});\n\t\t\tcloned.headers.set('x-sveltekit-prerender', String(prerender));\n\n\t\t\tif (state.prerendering.inside_reroute && prerender) {\n\t\t\t\t// Without this, the route wouldn't be recorded as prerendered,\n\t\t\t\t// because there's nothing after reroute that would do that.\n\t\t\t\tcloned.headers.set(\n\t\t\t\t\t'x-sveltekit-routeid',\n\t\t\t\t\tencodeURI(/** @type {string} */ (event.route.id))\n\t\t\t\t);\n\t\t\t\tstate.prerendering.dependencies.set(event.url.pathname, { response: cloned, body: null });\n\t\t\t} else {\n\t\t\t\treturn cloned;\n\t\t\t}\n\t\t}\n\n\t\treturn response;\n\t} catch (e) {\n\t\tif (e instanceof Redirect) {\n\t\t\treturn new Response(undefined, {\n\t\t\t\tstatus: e.status,\n\t\t\t\theaders: { location: e.location }\n\t\t\t});\n\t\t}\n\n\t\tthrow e;\n\t}\n}\n\n/**\n * @param {import('@sveltejs/kit').RequestEvent} event\n */\nexport function is_endpoint_request(event) {\n\tconst { method, headers } = event.request;\n\n\t// These methods exist exclusively for endpoints\n\tif (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) {\n\t\treturn true;\n\t}\n\n\t// use:enhance uses a custom header to disambiguate\n\tif (method === 'POST' && headers.get('x-sveltekit-action') === 'true') return false;\n\n\t// GET/POST requests may be for endpoints or pages. We prefer endpoints if this isn't a text/html request\n\tconst accept = event.request.headers.get('accept') ?? '*/*';\n\treturn negotiate(accept, ['*', 'text/html']) !== 'text/html';\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/env_module.js",
    "content": "import { public_env } from '../shared-server.js';\n\n/** @type {string} */\nlet body;\n\n/** @type {string} */\nlet etag;\n\n/** @type {Headers} */\nlet headers;\n\n/**\n * @param {Request} request\n * @returns {Response}\n */\nexport function get_public_env(request) {\n\tbody ??= `export const env=${JSON.stringify(public_env)}`;\n\tetag ??= `W/${Date.now()}`;\n\theaders ??= new Headers({\n\t\t'content-type': 'application/javascript; charset=utf-8',\n\t\tetag\n\t});\n\n\tif (request.headers.get('if-none-match') === etag) {\n\t\treturn new Response(undefined, { status: 304, headers });\n\t}\n\n\treturn new Response(body, { headers });\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/fetch.js",
    "content": "import * as set_cookie_parser from 'set-cookie-parser';\nimport { respond } from './respond.js';\nimport * as paths from '$app/paths/internal/server';\nimport { read_implementation } from '__sveltekit/server';\nimport { has_prerendered_path } from './utils.js';\n\n/**\n * @param {{\n *   event: import('@sveltejs/kit').RequestEvent;\n *   options: import('types').SSROptions;\n *   manifest: import('@sveltejs/kit').SSRManifest;\n *   state: import('types').SSRState;\n *   get_cookie_header: (url: URL, header: string | null) => string;\n *   set_internal: (name: string, value: string, opts: import('./page/types.js').Cookie['options']) => void;\n * }} opts\n * @returns {typeof fetch}\n */\nexport function create_fetch({ event, options, manifest, state, get_cookie_header, set_internal }) {\n\t/**\n\t * @type {typeof fetch}\n\t */\n\tconst server_fetch = async (info, init) => {\n\t\tconst original_request = normalize_fetch_input(info, init, event.url);\n\n\t\t// some runtimes (e.g. Cloudflare) error if you access `request.mode`,\n\t\t// annoyingly, so we need to read the value from the `init` object instead\n\t\tlet mode = (info instanceof Request ? info.mode : init?.mode) ?? 'cors';\n\t\tlet credentials =\n\t\t\t(info instanceof Request ? info.credentials : init?.credentials) ?? 'same-origin';\n\n\t\treturn options.hooks.handleFetch({\n\t\t\tevent,\n\t\t\trequest: original_request,\n\t\t\tfetch: async (info, init) => {\n\t\t\t\tconst request = normalize_fetch_input(info, init, event.url);\n\n\t\t\t\tconst url = new URL(request.url);\n\n\t\t\t\tif (!request.headers.has('origin')) {\n\t\t\t\t\trequest.headers.set('origin', event.url.origin);\n\t\t\t\t}\n\n\t\t\t\tif (info !== original_request) {\n\t\t\t\t\tmode = (info instanceof Request ? info.mode : init?.mode) ?? 'cors';\n\t\t\t\t\tcredentials =\n\t\t\t\t\t\t(info instanceof Request ? info.credentials : init?.credentials) ?? 'same-origin';\n\t\t\t\t}\n\n\t\t\t\t// Remove Origin, according to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin#description\n\t\t\t\tif (\n\t\t\t\t\t(request.method === 'GET' || request.method === 'HEAD') &&\n\t\t\t\t\t((mode === 'no-cors' && url.origin !== event.url.origin) ||\n\t\t\t\t\t\turl.origin === event.url.origin)\n\t\t\t\t) {\n\t\t\t\t\trequest.headers.delete('origin');\n\t\t\t\t}\n\n\t\t\t\tconst decoded = decodeURIComponent(url.pathname);\n\n\t\t\t\tif (\n\t\t\t\t\turl.origin !== event.url.origin ||\n\t\t\t\t\t(paths.base && decoded !== paths.base && !decoded.startsWith(`${paths.base}/`))\n\t\t\t\t) {\n\t\t\t\t\t// Allow cookie passthrough for \"credentials: same-origin\" and \"credentials: include\"\n\t\t\t\t\t// if SvelteKit is serving my.domain.com:\n\t\t\t\t\t// -        domain.com WILL NOT receive cookies\n\t\t\t\t\t// -     my.domain.com WILL receive cookies\n\t\t\t\t\t// -    api.domain.dom WILL NOT receive cookies\n\t\t\t\t\t// - sub.my.domain.com WILL receive cookies\n\t\t\t\t\t// ports do not affect the resolution\n\t\t\t\t\t// leading dot prevents mydomain.com matching domain.com\n\t\t\t\t\t// Do not forward other cookies for \"credentials: include\" because we don't know\n\t\t\t\t\t// which cookie belongs to which domain (browser does not pass this info)\n\t\t\t\t\tif (`.${url.hostname}`.endsWith(`.${event.url.hostname}`) && credentials !== 'omit') {\n\t\t\t\t\t\tconst cookie = get_cookie_header(url, request.headers.get('cookie'));\n\t\t\t\t\t\tif (cookie) request.headers.set('cookie', cookie);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn fetch(request);\n\t\t\t\t}\n\n\t\t\t\t// handle fetch requests for static assets. e.g. prebaked data, etc.\n\t\t\t\t// we need to support everything the browser's fetch supports\n\t\t\t\tconst prefix = paths.assets || paths.base;\n\t\t\t\tconst filename = (\n\t\t\t\t\tdecoded.startsWith(prefix) ? decoded.slice(prefix.length) : decoded\n\t\t\t\t).slice(1);\n\t\t\t\tconst filename_html = `${filename}/index.html`; // path may also match path/index.html\n\n\t\t\t\tconst is_asset = manifest.assets.has(filename) || filename in manifest._.server_assets;\n\t\t\t\tconst is_asset_html =\n\t\t\t\t\tmanifest.assets.has(filename_html) || filename_html in manifest._.server_assets;\n\n\t\t\t\tif (is_asset || is_asset_html) {\n\t\t\t\t\tconst file = is_asset ? filename : filename_html;\n\n\t\t\t\t\tif (state.read) {\n\t\t\t\t\t\tconst type = is_asset\n\t\t\t\t\t\t\t? manifest.mimeTypes[filename.slice(filename.lastIndexOf('.'))]\n\t\t\t\t\t\t\t: 'text/html';\n\n\t\t\t\t\t\treturn new Response(state.read(file), {\n\t\t\t\t\t\t\theaders: type ? { 'content-type': type } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (read_implementation && file in manifest._.server_assets) {\n\t\t\t\t\t\tconst length = manifest._.server_assets[file];\n\t\t\t\t\t\tconst type = manifest.mimeTypes[file.slice(file.lastIndexOf('.'))];\n\n\t\t\t\t\t\treturn new Response(read_implementation(file), {\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t'Content-Length': '' + length,\n\t\t\t\t\t\t\t\t'Content-Type': type\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn await fetch(request);\n\t\t\t\t}\n\n\t\t\t\tif (has_prerendered_path(manifest, paths.base + decoded)) {\n\t\t\t\t\t// The path of something prerendered could match a different route\n\t\t\t\t\t// that is still in the manifest, leading to the wrong route being loaded.\n\t\t\t\t\t// We therefore bail early here. The prerendered logic is different for\n\t\t\t\t\t// each adapter, (except maybe for prerendered redirects)\n\t\t\t\t\t// so we need to make an actual HTTP request.\n\t\t\t\t\treturn await fetch(request);\n\t\t\t\t}\n\n\t\t\t\tif (credentials !== 'omit') {\n\t\t\t\t\tconst cookie = get_cookie_header(url, request.headers.get('cookie'));\n\t\t\t\t\tif (cookie) {\n\t\t\t\t\t\trequest.headers.set('cookie', cookie);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst authorization = event.request.headers.get('authorization');\n\t\t\t\t\tif (authorization && !request.headers.has('authorization')) {\n\t\t\t\t\t\trequest.headers.set('authorization', authorization);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!request.headers.has('accept')) {\n\t\t\t\t\trequest.headers.set('accept', '*/*');\n\t\t\t\t}\n\n\t\t\t\tif (!request.headers.has('accept-language')) {\n\t\t\t\t\trequest.headers.set(\n\t\t\t\t\t\t'accept-language',\n\t\t\t\t\t\t/** @type {string} */ (event.request.headers.get('accept-language'))\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst response = await internal_fetch(request, options, manifest, state);\n\n\t\t\t\tconst set_cookie = response.headers.get('set-cookie');\n\t\t\t\tif (set_cookie) {\n\t\t\t\t\tfor (const str of set_cookie_parser.splitCookiesString(set_cookie)) {\n\t\t\t\t\t\tconst { name, value, ...options } = set_cookie_parser.parseString(str, {\n\t\t\t\t\t\t\tdecodeValues: false\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst path = options.path ?? (url.pathname.split('/').slice(0, -1).join('/') || '/');\n\n\t\t\t\t\t\t// options.sameSite is string, something more specific is required - type cast is safe\n\t\t\t\t\t\tset_internal(name, value, {\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tencode: (value) => value,\n\t\t\t\t\t\t\t.../** @type {import('cookie').CookieSerializeOptions} */ (options)\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t}\n\t\t});\n\t};\n\n\t// Don't make this function `async`! Otherwise, the user has to `catch` promises they use for streaming responses or else\n\t// it will be an unhandled rejection. Instead, we add a `.catch(() => {})` ourselves below to prevent this from happening.\n\treturn (input, init) => {\n\t\t// See docs in fetch.js for why we need to do this\n\t\tconst response = server_fetch(input, init);\n\t\tresponse.catch(() => {});\n\t\treturn response;\n\t};\n}\n\n/**\n * @param {RequestInfo | URL} info\n * @param {RequestInit | undefined} init\n * @param {URL} url\n */\nfunction normalize_fetch_input(info, init, url) {\n\tif (info instanceof Request) {\n\t\treturn info;\n\t}\n\n\treturn new Request(typeof info === 'string' ? new URL(info, url) : info, init);\n}\n\n/**\n * @param {Request} request\n * @param {import('types').SSROptions} options\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n * @param {import('types').SSRState} state\n * @returns {Promise<Response>}\n */\nasync function internal_fetch(request, options, manifest, state) {\n\tif (request.signal) {\n\t\tif (request.signal.aborted) {\n\t\t\tthrow new DOMException('The operation was aborted.', 'AbortError');\n\t\t}\n\n\t\tlet remove_abort_listener = () => {};\n\t\t/** @type {Promise<never>} */\n\t\tconst abort_promise = new Promise((_, reject) => {\n\t\t\tconst on_abort = () => {\n\t\t\t\treject(new DOMException('The operation was aborted.', 'AbortError'));\n\t\t\t};\n\t\t\trequest.signal.addEventListener('abort', on_abort, { once: true });\n\t\t\tremove_abort_listener = () => request.signal.removeEventListener('abort', on_abort);\n\t\t});\n\n\t\tconst result = await Promise.race([\n\t\t\trespond(request, options, manifest, {\n\t\t\t\t...state,\n\t\t\t\tdepth: state.depth + 1\n\t\t\t}),\n\t\t\tabort_promise\n\t\t]);\n\t\tremove_abort_listener();\n\t\treturn result;\n\t} else {\n\t\treturn await respond(request, options, manifest, {\n\t\t\t...state,\n\t\t\tdepth: state.depth + 1\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/index.js",
    "content": "/** @import { PromiseWithResolvers } from '../../utils/promise.js' */\nimport { with_resolvers } from '../../utils/promise.js';\nimport { IN_WEBCONTAINER } from './constants.js';\nimport { respond } from './respond.js';\nimport { set_private_env, set_public_env } from '../shared-server.js';\nimport { options, get_hooks } from '__SERVER__/internal.js';\nimport { DEV } from 'esm-env';\nimport { filter_env } from '../../utils/env.js';\nimport { format_server_error } from './utils.js';\nimport { set_read_implementation, set_manifest } from '__sveltekit/server';\nimport { set_app } from './app.js';\n\n/** @type {Promise<any>} */\nlet init_promise;\n\n/** @type {Promise<void> | null} */\nlet current = null;\n\nexport class Server {\n\t/** @type {import('types').SSROptions} */\n\t#options;\n\n\t/** @type {import('@sveltejs/kit').SSRManifest} */\n\t#manifest;\n\n\t/** @param {import('@sveltejs/kit').SSRManifest} manifest */\n\tconstructor(manifest) {\n\t\t/** @type {import('types').SSROptions} */\n\t\tthis.#options = options;\n\t\tthis.#manifest = manifest;\n\n\t\t// Since AsyncLocalStorage is not working in webcontainers, we don't reset `sync_store`\n\t\t// in `src/exports/internal/event.js` and handle only one request at a time.\n\t\tif (IN_WEBCONTAINER) {\n\t\t\tconst respond = this.respond.bind(this);\n\n\t\t\t/** @type {typeof respond} */\n\t\t\tthis.respond = async (...args) => {\n\t\t\t\tconst { promise, resolve } = /** @type {PromiseWithResolvers<void>} */ (with_resolvers());\n\n\t\t\t\tconst previous = current;\n\t\t\t\tcurrent = promise;\n\n\t\t\t\tawait previous;\n\t\t\t\treturn respond(...args).finally(resolve);\n\t\t\t};\n\t\t}\n\n\t\tset_manifest(manifest);\n\t}\n\n\t/**\n\t * @param {import('@sveltejs/kit').ServerInitOptions} opts\n\t */\n\tasync init({ env, read }) {\n\t\t// Take care: Some adapters may have to call `Server.init` per-request to set env vars,\n\t\t// so anything that shouldn't be rerun should be wrapped in an `if` block to make sure it hasn't\n\t\t// been done already.\n\n\t\t// set env, in case it's used in initialisation\n\t\tconst { env_public_prefix, env_private_prefix } = this.#options;\n\n\t\tset_private_env(filter_env(env, env_private_prefix, env_public_prefix));\n\t\tset_public_env(filter_env(env, env_public_prefix, env_private_prefix));\n\n\t\tif (read) {\n\t\t\t// Wrap the read function to handle MaybePromise<ReadableStream>\n\t\t\t// and ensure the public API stays synchronous\n\t\t\t/** @param {string} file */\n\t\t\tconst wrapped_read = (file) => {\n\t\t\t\tconst result = read(file);\n\t\t\t\tif (result instanceof ReadableStream) {\n\t\t\t\t\treturn result;\n\t\t\t\t} else {\n\t\t\t\t\treturn new ReadableStream({\n\t\t\t\t\t\tasync start(controller) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst stream = await Promise.resolve(result);\n\t\t\t\t\t\t\t\tif (!stream) {\n\t\t\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst reader = stream.getReader();\n\n\t\t\t\t\t\t\t\twhile (true) {\n\t\t\t\t\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\t\t\t\t\tif (done) break;\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tcontroller.error(error);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tset_read_implementation(wrapped_read);\n\t\t}\n\n\t\t// During DEV and for some adapters this function might be called in quick succession,\n\t\t// so we need to make sure we're not invoking this logic (most notably the init hook) multiple times\n\t\tawait (init_promise ??= (async () => {\n\t\t\ttry {\n\t\t\t\tconst module = await get_hooks();\n\n\t\t\t\tthis.#options.hooks = {\n\t\t\t\t\thandle: module.handle || (({ event, resolve }) => resolve(event)),\n\t\t\t\t\thandleError:\n\t\t\t\t\t\tmodule.handleError ||\n\t\t\t\t\t\t(({ status, error, event }) => {\n\t\t\t\t\t\t\tconst error_message = format_server_error(\n\t\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\t\t/** @type {Error} */ (error),\n\t\t\t\t\t\t\t\tevent\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconsole.error(error_message);\n\t\t\t\t\t\t}),\n\t\t\t\t\thandleFetch: module.handleFetch || (({ request, fetch }) => fetch(request)),\n\t\t\t\t\thandleValidationError:\n\t\t\t\t\t\tmodule.handleValidationError ||\n\t\t\t\t\t\t(({ issues }) => {\n\t\t\t\t\t\t\tconsole.error('Remote function schema validation failed:', issues);\n\t\t\t\t\t\t\treturn { message: 'Bad Request' };\n\t\t\t\t\t\t}),\n\t\t\t\t\treroute: module.reroute || (() => {}),\n\t\t\t\t\ttransport: module.transport || {}\n\t\t\t\t};\n\n\t\t\t\tset_app({\n\t\t\t\t\tdecoders: module.transport\n\t\t\t\t\t\t? Object.fromEntries(Object.entries(module.transport).map(([k, v]) => [k, v.decode]))\n\t\t\t\t\t\t: {}\n\t\t\t\t});\n\n\t\t\t\tif (module.init) {\n\t\t\t\t\tawait module.init();\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tif (DEV) {\n\t\t\t\t\tthis.#options.hooks = {\n\t\t\t\t\t\thandle: () => {\n\t\t\t\t\t\t\tthrow e;\n\t\t\t\t\t\t},\n\t\t\t\t\t\thandleError: ({ error }) => console.error(error),\n\t\t\t\t\t\thandleFetch: ({ request, fetch }) => fetch(request),\n\t\t\t\t\t\thandleValidationError: () => {\n\t\t\t\t\t\t\treturn { message: 'Bad Request' };\n\t\t\t\t\t\t},\n\t\t\t\t\t\treroute: () => {},\n\t\t\t\t\t\ttransport: {}\n\t\t\t\t\t};\n\n\t\t\t\t\tset_app({\n\t\t\t\t\t\tdecoders: {}\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t}\n\t\t})());\n\t}\n\n\t/**\n\t * @param {Request} request\n\t * @param {import('types').RequestOptions} options\n\t */\n\tasync respond(request, options) {\n\t\treturn respond(request, this.#options, this.#manifest, {\n\t\t\t...options,\n\t\t\terror: false,\n\t\t\tdepth: 0\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/actions.js",
    "content": "/** @import { RequestEvent, ActionResult, Actions } from '@sveltejs/kit' */\n/** @import { SSROptions, SSRNode, ServerNode, ServerHooks } from 'types' */\nimport * as devalue from 'devalue';\nimport { DEV } from 'esm-env';\nimport { json } from '@sveltejs/kit';\nimport { HttpError, Redirect, ActionFailure, SvelteKitError } from '@sveltejs/kit/internal';\nimport { with_request_store, merge_tracing } from '@sveltejs/kit/internal/server';\nimport { get_status, normalize_error } from '../../../utils/error.js';\nimport { is_form_content_type, negotiate } from '../../../utils/http.js';\nimport { handle_error_and_jsonify } from '../utils.js';\nimport { record_span } from '../../telemetry/record_span.js';\n\n/** @param {RequestEvent} event */\nexport function is_action_json_request(event) {\n\tconst accept = negotiate(event.request.headers.get('accept') ?? '*/*', [\n\t\t'application/json',\n\t\t'text/html'\n\t]);\n\n\treturn accept === 'application/json' && event.request.method === 'POST';\n}\n\n/**\n * @param {RequestEvent} event\n * @param {import('types').RequestState} event_state\n * @param {SSROptions} options\n * @param {SSRNode['server'] | undefined} server\n */\nexport async function handle_action_json_request(event, event_state, options, server) {\n\tconst actions = server?.actions;\n\n\tif (!actions) {\n\t\tconst no_actions_error = new SvelteKitError(\n\t\t\t405,\n\t\t\t'Method Not Allowed',\n\t\t\t`POST method not allowed. No form actions exist for ${DEV ? `the page at ${event.route.id}` : 'this page'}`\n\t\t);\n\n\t\treturn action_json(\n\t\t\t{\n\t\t\t\ttype: 'error',\n\t\t\t\terror: await handle_error_and_jsonify(event, event_state, options, no_actions_error)\n\t\t\t},\n\t\t\t{\n\t\t\t\tstatus: no_actions_error.status,\n\t\t\t\theaders: {\n\t\t\t\t\t// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405\n\t\t\t\t\t// \"The server must generate an Allow header field in a 405 status code response\"\n\t\t\t\t\tallow: 'GET'\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\tcheck_named_default_separate(actions);\n\n\ttry {\n\t\tconst data = await call_action(event, event_state, actions);\n\n\t\tif (DEV) {\n\t\t\tvalidate_action_return(data);\n\t\t}\n\n\t\tif (data instanceof ActionFailure) {\n\t\t\treturn action_json({\n\t\t\t\ttype: 'failure',\n\t\t\t\tstatus: data.status,\n\t\t\t\t// @ts-expect-error we assign a string to what is supposed to be an object. That's ok\n\t\t\t\t// because we don't use the object outside, and this way we have better code navigation\n\t\t\t\t// through knowing where the related interface is used.\n\t\t\t\tdata: stringify_action_response(\n\t\t\t\t\tdata.data,\n\t\t\t\t\t/** @type {string} */ (event.route.id),\n\t\t\t\t\toptions.hooks.transport\n\t\t\t\t)\n\t\t\t});\n\t\t} else {\n\t\t\treturn action_json({\n\t\t\t\ttype: 'success',\n\t\t\t\tstatus: data ? 200 : 204,\n\t\t\t\t// @ts-expect-error see comment above\n\t\t\t\tdata: stringify_action_response(\n\t\t\t\t\tdata,\n\t\t\t\t\t/** @type {string} */ (event.route.id),\n\t\t\t\t\toptions.hooks.transport\n\t\t\t\t)\n\t\t\t});\n\t\t}\n\t} catch (e) {\n\t\tconst err = normalize_error(e);\n\n\t\tif (err instanceof Redirect) {\n\t\t\treturn action_json_redirect(err);\n\t\t}\n\n\t\treturn action_json(\n\t\t\t{\n\t\t\t\ttype: 'error',\n\t\t\t\terror: await handle_error_and_jsonify(\n\t\t\t\t\tevent,\n\t\t\t\t\tevent_state,\n\t\t\t\t\toptions,\n\t\t\t\t\tcheck_incorrect_fail_use(err)\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tstatus: get_status(err)\n\t\t\t}\n\t\t);\n\t}\n}\n\n/**\n * @param {HttpError | Error} error\n */\nexport function check_incorrect_fail_use(error) {\n\treturn error instanceof ActionFailure\n\t\t? new Error('Cannot \"throw fail()\". Use \"return fail()\"')\n\t\t: error;\n}\n\n/**\n * @param {Redirect} redirect\n */\nexport function action_json_redirect(redirect) {\n\treturn action_json({\n\t\ttype: 'redirect',\n\t\tstatus: redirect.status,\n\t\tlocation: redirect.location\n\t});\n}\n\n/**\n * @param {ActionResult} data\n * @param {ResponseInit} [init]\n */\nfunction action_json(data, init) {\n\treturn json(data, init);\n}\n\n/**\n * @param {RequestEvent} event\n */\nexport function is_action_request(event) {\n\treturn event.request.method === 'POST';\n}\n\n/**\n * @param {RequestEvent} event\n * @param {import('types').RequestState} event_state\n * @param {SSRNode['server'] | undefined} server\n * @returns {Promise<ActionResult>}\n */\nexport async function handle_action_request(event, event_state, server) {\n\tconst actions = server?.actions;\n\n\tif (!actions) {\n\t\t// TODO should this be a different error altogether?\n\t\tevent.setHeaders({\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405\n\t\t\t// \"The server must generate an Allow header field in a 405 status code response\"\n\t\t\tallow: 'GET'\n\t\t});\n\t\treturn {\n\t\t\ttype: 'error',\n\t\t\terror: new SvelteKitError(\n\t\t\t\t405,\n\t\t\t\t'Method Not Allowed',\n\t\t\t\t`POST method not allowed. No form actions exist for ${DEV ? `the page at ${event.route.id}` : 'this page'}`\n\t\t\t)\n\t\t};\n\t}\n\n\tcheck_named_default_separate(actions);\n\n\ttry {\n\t\tconst data = await call_action(event, event_state, actions);\n\n\t\tif (DEV) {\n\t\t\tvalidate_action_return(data);\n\t\t}\n\n\t\tif (data instanceof ActionFailure) {\n\t\t\treturn {\n\t\t\t\ttype: 'failure',\n\t\t\t\tstatus: data.status,\n\t\t\t\tdata: data.data\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\ttype: 'success',\n\t\t\t\tstatus: 200,\n\t\t\t\t// @ts-expect-error this will be removed upon serialization, so `undefined` is the same as omission\n\t\t\t\tdata\n\t\t\t};\n\t\t}\n\t} catch (e) {\n\t\tconst err = normalize_error(e);\n\n\t\tif (err instanceof Redirect) {\n\t\t\treturn {\n\t\t\t\ttype: 'redirect',\n\t\t\t\tstatus: err.status,\n\t\t\t\tlocation: err.location\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\ttype: 'error',\n\t\t\terror: check_incorrect_fail_use(err)\n\t\t};\n\t}\n}\n\n/**\n * @param {Actions} actions\n */\nfunction check_named_default_separate(actions) {\n\tif (actions.default && Object.keys(actions).length > 1) {\n\t\tthrow new Error(\n\t\t\t'When using named actions, the default action cannot be used. See the docs for more info: https://svelte.dev/docs/kit/form-actions#named-actions'\n\t\t);\n\t}\n}\n\n/**\n * @param {RequestEvent} event\n * @param {import('types').RequestState} event_state\n * @param {NonNullable<ServerNode['actions']>} actions\n * @throws {Redirect | HttpError | SvelteKitError | Error}\n */\nasync function call_action(event, event_state, actions) {\n\tconst url = new URL(event.request.url);\n\n\tlet name = 'default';\n\tfor (const param of url.searchParams) {\n\t\tif (param[0].startsWith('/')) {\n\t\t\tname = param[0].slice(1);\n\t\t\tif (name === 'default') {\n\t\t\t\tthrow new Error('Cannot use reserved action name \"default\"');\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tconst action = actions[name];\n\tif (!action) {\n\t\tthrow new SvelteKitError(404, 'Not Found', `No action with name '${name}' found`);\n\t}\n\n\tif (!is_form_content_type(event.request)) {\n\t\tthrow new SvelteKitError(\n\t\t\t415,\n\t\t\t'Unsupported Media Type',\n\t\t\t`Form actions expect form-encoded data — received ${event.request.headers.get(\n\t\t\t\t'content-type'\n\t\t\t)}`\n\t\t);\n\t}\n\n\treturn record_span({\n\t\tname: 'sveltekit.form_action',\n\t\tattributes: {\n\t\t\t'sveltekit.form_action.name': name,\n\t\t\t'http.route': event.route.id || 'unknown'\n\t\t},\n\t\tfn: async (current) => {\n\t\t\tconst traced_event = merge_tracing(event, current);\n\n\t\t\tconst result = await with_request_store({ event: traced_event, state: event_state }, () =>\n\t\t\t\taction(traced_event)\n\t\t\t);\n\n\t\t\tif (result instanceof ActionFailure) {\n\t\t\t\tcurrent.setAttributes({\n\t\t\t\t\t'sveltekit.form_action.result.type': 'failure',\n\t\t\t\t\t'sveltekit.form_action.result.status': result.status\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\t});\n}\n\n/** @param {any} data */\nfunction validate_action_return(data) {\n\tif (data instanceof Redirect) {\n\t\tthrow new Error('Cannot `return redirect(...)` — use `redirect(...)` instead');\n\t}\n\n\tif (data instanceof HttpError) {\n\t\tthrow new Error('Cannot `return error(...)` — use `error(...)` or `return fail(...)` instead');\n\t}\n}\n\n/**\n * Try to `devalue.uneval` the data object, and if it fails, return a proper Error with context\n * @param {any} data\n * @param {string} route_id\n * @param {ServerHooks['transport']} transport\n */\nexport function uneval_action_response(data, route_id, transport) {\n\tconst replacer = (/** @type {any} */ thing) => {\n\t\tfor (const key in transport) {\n\t\t\tconst encoded = transport[key].encode(thing);\n\t\t\tif (encoded) {\n\t\t\t\treturn `app.decode('${key}', ${devalue.uneval(encoded, replacer)})`;\n\t\t\t}\n\t\t}\n\t};\n\n\treturn try_serialize(data, (value) => devalue.uneval(value, replacer), route_id);\n}\n\n/**\n * Try to `devalue.stringify` the data object, and if it fails, return a proper Error with context\n * @param {any} data\n * @param {string} route_id\n * @param {ServerHooks['transport']} transport\n */\nfunction stringify_action_response(data, route_id, transport) {\n\tconst encoders = Object.fromEntries(\n\t\tObject.entries(transport).map(([key, value]) => [key, value.encode])\n\t);\n\n\treturn try_serialize(data, (value) => devalue.stringify(value, encoders), route_id);\n}\n\n/**\n * @param {any} data\n * @param {(data: any) => string} fn\n * @param {string} route_id\n */\nfunction try_serialize(data, fn, route_id) {\n\ttry {\n\t\treturn fn(data);\n\t} catch (e) {\n\t\t// If we're here, the data could not be serialized with devalue\n\t\tconst error = /** @type {any} */ (e);\n\n\t\t// if someone tries to use `json()` in their action\n\t\tif (data instanceof Response) {\n\t\t\tthrow new Error(\n\t\t\t\t`Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: \"invalid\" });`,\n\t\t\t\t{ cause: e }\n\t\t\t);\n\t\t}\n\n\t\t// if devalue could not serialize a property on the object, etc.\n\t\tif ('path' in error) {\n\t\t\tlet message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`;\n\t\t\tif (error.path !== '') message += ` (data.${error.path})`;\n\t\t\tthrow new Error(message, { cause: e });\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/crypto.js",
    "content": "import { text_encoder } from '../../utils.js';\n\n/**\n * SHA-256 hashing function adapted from https://bitwiseshiftleft.github.io/sjcl\n * modified and redistributed under BSD license\n * @param {string} data\n */\nexport function sha256(data) {\n\tif (!key[0]) precompute();\n\n\tconst out = init.slice(0);\n\tconst array = encode(data);\n\n\tfor (let i = 0; i < array.length; i += 16) {\n\t\tconst w = array.subarray(i, i + 16);\n\n\t\tlet tmp;\n\t\tlet a;\n\t\tlet b;\n\n\t\tlet out0 = out[0];\n\t\tlet out1 = out[1];\n\t\tlet out2 = out[2];\n\t\tlet out3 = out[3];\n\t\tlet out4 = out[4];\n\t\tlet out5 = out[5];\n\t\tlet out6 = out[6];\n\t\tlet out7 = out[7];\n\n\t\t/* Rationale for placement of |0 :\n\t\t * If a value can overflow is original 32 bits by a factor of more than a few\n\t\t * million (2^23 ish), there is a possibility that it might overflow the\n\t\t * 53-bit mantissa and lose precision.\n\t\t *\n\t\t * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that\n\t\t * propagates around the loop, and on the hash state out[]. I don't believe\n\t\t * that the clamps on out4 and on out0 are strictly necessary, but it's close\n\t\t * (for out4 anyway), and better safe than sorry.\n\t\t *\n\t\t * The clamps on out[] are necessary for the output to be correct even in the\n\t\t * common case and for short inputs.\n\t\t */\n\n\t\tfor (let i = 0; i < 64; i++) {\n\t\t\t// load up the input word for this round\n\n\t\t\tif (i < 16) {\n\t\t\t\ttmp = w[i];\n\t\t\t} else {\n\t\t\t\ta = w[(i + 1) & 15];\n\n\t\t\t\tb = w[(i + 14) & 15];\n\n\t\t\t\ttmp = w[i & 15] =\n\t\t\t\t\t(((a >>> 7) ^ (a >>> 18) ^ (a >>> 3) ^ (a << 25) ^ (a << 14)) +\n\t\t\t\t\t\t((b >>> 17) ^ (b >>> 19) ^ (b >>> 10) ^ (b << 15) ^ (b << 13)) +\n\t\t\t\t\t\tw[i & 15] +\n\t\t\t\t\t\tw[(i + 9) & 15]) |\n\t\t\t\t\t0;\n\t\t\t}\n\n\t\t\ttmp =\n\t\t\t\ttmp +\n\t\t\t\tout7 +\n\t\t\t\t((out4 >>> 6) ^ (out4 >>> 11) ^ (out4 >>> 25) ^ (out4 << 26) ^ (out4 << 21) ^ (out4 << 7)) +\n\t\t\t\t(out6 ^ (out4 & (out5 ^ out6))) +\n\t\t\t\tkey[i]; // | 0;\n\n\t\t\t// shift register\n\t\t\tout7 = out6;\n\t\t\tout6 = out5;\n\t\t\tout5 = out4;\n\n\t\t\tout4 = (out3 + tmp) | 0;\n\n\t\t\tout3 = out2;\n\t\t\tout2 = out1;\n\t\t\tout1 = out0;\n\n\t\t\tout0 =\n\t\t\t\t(tmp +\n\t\t\t\t\t((out1 & out2) ^ (out3 & (out1 ^ out2))) +\n\t\t\t\t\t((out1 >>> 2) ^\n\t\t\t\t\t\t(out1 >>> 13) ^\n\t\t\t\t\t\t(out1 >>> 22) ^\n\t\t\t\t\t\t(out1 << 30) ^\n\t\t\t\t\t\t(out1 << 19) ^\n\t\t\t\t\t\t(out1 << 10))) |\n\t\t\t\t0;\n\t\t}\n\n\t\tout[0] = (out[0] + out0) | 0;\n\t\tout[1] = (out[1] + out1) | 0;\n\t\tout[2] = (out[2] + out2) | 0;\n\t\tout[3] = (out[3] + out3) | 0;\n\t\tout[4] = (out[4] + out4) | 0;\n\t\tout[5] = (out[5] + out5) | 0;\n\t\tout[6] = (out[6] + out6) | 0;\n\t\tout[7] = (out[7] + out7) | 0;\n\t}\n\n\tconst bytes = new Uint8Array(out.buffer);\n\treverse_endianness(bytes);\n\n\treturn btoa(String.fromCharCode(...bytes));\n}\n\n/** The SHA-256 initialization vector */\nconst init = new Uint32Array(8);\n\n/** The SHA-256 hash key */\nconst key = new Uint32Array(64);\n\n/** Function to precompute init and key. */\nfunction precompute() {\n\t/** @param {number} x */\n\tfunction frac(x) {\n\t\treturn (x - Math.floor(x)) * 0x100000000;\n\t}\n\n\tlet prime = 2;\n\n\tfor (let i = 0; i < 64; prime++) {\n\t\tlet is_prime = true;\n\n\t\tfor (let factor = 2; factor * factor <= prime; factor++) {\n\t\t\tif (prime % factor === 0) {\n\t\t\t\tis_prime = false;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (is_prime) {\n\t\t\tif (i < 8) {\n\t\t\t\tinit[i] = frac(prime ** (1 / 2));\n\t\t\t}\n\n\t\t\tkey[i] = frac(prime ** (1 / 3));\n\n\t\t\ti++;\n\t\t}\n\t}\n}\n\n/** @param {Uint8Array} bytes */\nfunction reverse_endianness(bytes) {\n\tfor (let i = 0; i < bytes.length; i += 4) {\n\t\tconst a = bytes[i + 0];\n\t\tconst b = bytes[i + 1];\n\t\tconst c = bytes[i + 2];\n\t\tconst d = bytes[i + 3];\n\n\t\tbytes[i + 0] = d;\n\t\tbytes[i + 1] = c;\n\t\tbytes[i + 2] = b;\n\t\tbytes[i + 3] = a;\n\t}\n}\n\n/** @param {string} str */\nfunction encode(str) {\n\tconst encoded = text_encoder.encode(str);\n\tconst length = encoded.length * 8;\n\n\t// result should be a multiple of 512 bits in length,\n\t// with room for a 1 (after the data) and two 32-bit\n\t// words containing the original input bit length\n\tconst size = 512 * Math.ceil((length + 65) / 512);\n\tconst bytes = new Uint8Array(size / 8);\n\tbytes.set(encoded);\n\n\t// append a 1\n\tbytes[encoded.length] = 0b10000000;\n\n\treverse_endianness(bytes);\n\n\t// add the input bit length\n\tconst words = new Uint32Array(bytes.buffer);\n\twords[words.length - 2] = Math.floor(length / 0x100000000); // this will always be zero for us\n\twords[words.length - 1] = length;\n\n\treturn words;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/crypto.spec.js",
    "content": "import { webcrypto } from 'node:crypto';\nimport { assert, test } from 'vitest';\nimport { sha256 } from './crypto.js';\nimport { text_encoder } from '../../utils.js';\n\nconst inputs = [\n\t'hello world',\n\t'',\n\t'abcd',\n\t'the quick brown fox jumps over the lazy dog',\n\t'工欲善其事，必先利其器'\n];\n\ninputs.forEach((input) => {\n\ttest(input, async () => {\n\t\tconst expected_bytes = await webcrypto.subtle.digest('SHA-256', text_encoder.encode(input));\n\t\tconst expected = Buffer.from(expected_bytes).toString('base64');\n\n\t\tconst actual = sha256(input);\n\t\tassert.equal(actual, expected);\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/csp.js",
    "content": "import { DEV } from 'esm-env';\nimport { escape_html } from '../../../utils/escape.js';\nimport { sha256 } from './crypto.js';\n\nconst array = new Uint8Array(16);\n\nfunction generate_nonce() {\n\tcrypto.getRandomValues(array);\n\treturn btoa(String.fromCharCode(...array));\n}\n\nconst quoted = new Set([\n\t'self',\n\t'unsafe-eval',\n\t'unsafe-hashes',\n\t'unsafe-inline',\n\t'none',\n\t'strict-dynamic',\n\t'report-sample',\n\t'wasm-unsafe-eval',\n\t'script'\n]);\n\nconst crypto_pattern = /^(nonce|sha\\d\\d\\d)-/;\n\n// CSP and CSP Report Only are extremely similar with a few caveats\n// the easiest/DRYest way to express this is with some private encapsulation\nclass BaseProvider {\n\t/** @type {boolean} */\n\t#use_hashes;\n\n\t/** @type {boolean} */\n\t#script_needs_csp;\n\n\t/** @type {boolean} */\n\t#script_src_needs_csp;\n\n\t/** @type {boolean} */\n\t#script_src_elem_needs_csp;\n\n\t/** @type {boolean} */\n\t#style_needs_csp;\n\n\t/** @type {boolean} */\n\t#style_src_needs_csp;\n\n\t/** @type {boolean} */\n\t#style_src_attr_needs_csp;\n\n\t/** @type {boolean} */\n\t#style_src_elem_needs_csp;\n\n\t/** @type {import('types').CspDirectives} */\n\t#directives;\n\n\t/** @type {Set<import('types').Csp.Source>} */\n\t#script_src;\n\n\t/** @type {Set<import('types').Csp.Source>} */\n\t#script_src_elem;\n\n\t/** @type {Set<import('types').Csp.Source>} */\n\t#style_src;\n\n\t/** @type {Set<import('types').Csp.Source>} */\n\t#style_src_attr;\n\n\t/** @type {Set<import('types').Csp.Source>} */\n\t#style_src_elem;\n\n\t/** @type {boolean} */\n\tscript_needs_nonce;\n\n\t/** @type {boolean} */\n\tstyle_needs_nonce;\n\n\t/** @type {boolean} */\n\tscript_needs_hash;\n\n\t/** @type {string} */\n\t#nonce;\n\n\t/**\n\t * @param {boolean} use_hashes\n\t * @param {import('types').CspDirectives} directives\n\t * @param {string} nonce\n\t */\n\tconstructor(use_hashes, directives, nonce) {\n\t\tthis.#use_hashes = use_hashes;\n\t\tthis.#directives = DEV ? { ...directives } : directives; // clone in dev so we can safely mutate\n\n\t\tconst d = this.#directives;\n\n\t\tthis.#script_src = new Set();\n\t\tthis.#script_src_elem = new Set();\n\t\tthis.#style_src = new Set();\n\t\tthis.#style_src_attr = new Set();\n\t\tthis.#style_src_elem = new Set();\n\n\t\tconst effective_script_src = d['script-src'] || d['default-src'];\n\t\tconst script_src_elem = d['script-src-elem'];\n\t\tconst effective_style_src = d['style-src'] || d['default-src'];\n\t\tconst style_src_attr = d['style-src-attr'];\n\t\tconst style_src_elem = d['style-src-elem'];\n\n\t\tif (DEV) {\n\t\t\t// remove strict-dynamic in dev...\n\t\t\t// TODO reinstate this if we can figure out how to make strict-dynamic work\n\t\t\t// if (d['default-src']) {\n\t\t\t// \td['default-src'] = d['default-src'].filter((name) => name !== 'strict-dynamic');\n\t\t\t// \tif (d['default-src'].length === 0) delete d['default-src'];\n\t\t\t// }\n\n\t\t\t// if (d['script-src']) {\n\t\t\t// \td['script-src'] = d['script-src'].filter((name) => name !== 'strict-dynamic');\n\t\t\t// \tif (d['script-src'].length === 0) delete d['script-src'];\n\t\t\t// }\n\n\t\t\t// ...and add unsafe-inline so we can inject <style> elements\n\t\t\t// Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list, so we remove those during dev when injecting unsafe-inline\n\t\t\tif (effective_style_src && !effective_style_src.includes('unsafe-inline')) {\n\t\t\t\td['style-src'] = [\n\t\t\t\t\t...effective_style_src.filter(\n\t\t\t\t\t\t(value) => !(value.startsWith('sha256-') || value.startsWith('nonce-'))\n\t\t\t\t\t),\n\t\t\t\t\t'unsafe-inline'\n\t\t\t\t];\n\t\t\t}\n\n\t\t\tif (style_src_attr && !style_src_attr.includes('unsafe-inline')) {\n\t\t\t\td['style-src-attr'] = [\n\t\t\t\t\t...style_src_attr.filter(\n\t\t\t\t\t\t(value) => !(value.startsWith('sha256-') || value.startsWith('nonce-'))\n\t\t\t\t\t),\n\t\t\t\t\t'unsafe-inline'\n\t\t\t\t];\n\t\t\t}\n\n\t\t\tif (style_src_elem && !style_src_elem.includes('unsafe-inline')) {\n\t\t\t\td['style-src-elem'] = [\n\t\t\t\t\t...style_src_elem.filter(\n\t\t\t\t\t\t(value) => !(value.startsWith('sha256-') || value.startsWith('nonce-'))\n\t\t\t\t\t),\n\t\t\t\t\t'unsafe-inline'\n\t\t\t\t];\n\t\t\t}\n\t\t}\n\n\t\t/** @param {(import('types').Csp.Source | import('types').Csp.ActionSource)[] | undefined} directive */\n\t\tconst style_needs_csp = (directive) =>\n\t\t\t!!directive && !directive.some((value) => value === 'unsafe-inline');\n\n\t\t/** @param {(import('types').Csp.Source | import('types').Csp.ActionSource)[] | undefined} directive */\n\t\tconst script_needs_csp = (directive) =>\n\t\t\t!!directive &&\n\t\t\t(!directive.some((value) => value === 'unsafe-inline') ||\n\t\t\t\tdirective.some((value) => value === 'strict-dynamic'));\n\n\t\tthis.#script_src_needs_csp = script_needs_csp(effective_script_src);\n\t\tthis.#script_src_elem_needs_csp = script_needs_csp(script_src_elem);\n\t\tthis.#style_src_needs_csp = style_needs_csp(effective_style_src);\n\t\tthis.#style_src_attr_needs_csp = style_needs_csp(style_src_attr);\n\t\tthis.#style_src_elem_needs_csp = style_needs_csp(style_src_elem);\n\n\t\tthis.#script_needs_csp = this.#script_src_needs_csp || this.#script_src_elem_needs_csp;\n\t\tthis.#style_needs_csp =\n\t\t\t!DEV &&\n\t\t\t(this.#style_src_needs_csp ||\n\t\t\t\tthis.#style_src_attr_needs_csp ||\n\t\t\t\tthis.#style_src_elem_needs_csp);\n\n\t\tthis.script_needs_nonce = this.#script_needs_csp && !this.#use_hashes;\n\t\tthis.style_needs_nonce = this.#style_needs_csp && !this.#use_hashes;\n\t\tthis.script_needs_hash = this.#script_needs_csp && this.#use_hashes;\n\n\t\tthis.#nonce = nonce;\n\t}\n\n\t/** @param {string} content */\n\tadd_script(content) {\n\t\tif (!this.#script_needs_csp) return;\n\n\t\t/** @type {`nonce-${string}` | `sha256-${string}`} */\n\t\tconst source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;\n\n\t\tif (this.#script_src_needs_csp) {\n\t\t\tthis.#script_src.add(source);\n\t\t}\n\n\t\tif (this.#script_src_elem_needs_csp) {\n\t\t\tthis.#script_src_elem.add(source);\n\t\t}\n\t}\n\n\t/** @param {`sha256-${string}`[]} hashes */\n\tadd_script_hashes(hashes) {\n\t\tfor (const hash of hashes) {\n\t\t\tif (this.#script_src_needs_csp) {\n\t\t\t\tthis.#script_src.add(hash);\n\t\t\t}\n\t\t\tif (this.#script_src_elem_needs_csp) {\n\t\t\t\tthis.#script_src_elem.add(hash);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** @param {string} content */\n\tadd_style(content) {\n\t\tif (!this.#style_needs_csp) return;\n\n\t\t/** @type {`nonce-${string}` | `sha256-${string}`} */\n\t\tconst source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;\n\n\t\tif (this.#style_src_needs_csp) {\n\t\t\tthis.#style_src.add(source);\n\t\t}\n\n\t\tif (this.#style_src_attr_needs_csp) {\n\t\t\tthis.#style_src_attr.add(source);\n\t\t}\n\n\t\tif (this.#style_src_elem_needs_csp) {\n\t\t\t// this is the sha256 hash for the string \"/* empty */\"\n\t\t\t// adding it so that svelte does not break csp\n\t\t\t// see https://github.com/sveltejs/svelte/pull/7800\n\t\t\tconst sha256_empty_comment_hash = 'sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=';\n\t\t\tconst d = this.#directives;\n\n\t\t\tif (\n\t\t\t\td['style-src-elem'] &&\n\t\t\t\t!d['style-src-elem'].includes(sha256_empty_comment_hash) &&\n\t\t\t\t!this.#style_src_elem.has(sha256_empty_comment_hash)\n\t\t\t) {\n\t\t\t\tthis.#style_src_elem.add(sha256_empty_comment_hash);\n\t\t\t}\n\n\t\t\tif (source !== sha256_empty_comment_hash) {\n\t\t\t\tthis.#style_src_elem.add(source);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {boolean} [is_meta]\n\t */\n\tget_header(is_meta = false) {\n\t\tconst header = [];\n\n\t\t// due to browser inconsistencies, we can't append sources to default-src\n\t\t// (specifically, Firefox appears to not ignore nonce-{nonce} directives\n\t\t// on default-src), so we ensure that script-src and style-src exist\n\n\t\tconst directives = { ...this.#directives };\n\n\t\tif (this.#style_src.size > 0) {\n\t\t\tdirectives['style-src'] = [\n\t\t\t\t...(directives['style-src'] || directives['default-src'] || []),\n\t\t\t\t...this.#style_src\n\t\t\t];\n\t\t}\n\n\t\tif (this.#style_src_attr.size > 0) {\n\t\t\tdirectives['style-src-attr'] = [\n\t\t\t\t...(directives['style-src-attr'] || []),\n\t\t\t\t...this.#style_src_attr\n\t\t\t];\n\t\t}\n\n\t\tif (this.#style_src_elem.size > 0) {\n\t\t\tdirectives['style-src-elem'] = [\n\t\t\t\t...(directives['style-src-elem'] || []),\n\t\t\t\t...this.#style_src_elem\n\t\t\t];\n\t\t}\n\n\t\tif (this.#script_src.size > 0) {\n\t\t\tdirectives['script-src'] = [\n\t\t\t\t...(directives['script-src'] || directives['default-src'] || []),\n\t\t\t\t...this.#script_src\n\t\t\t];\n\t\t}\n\n\t\tif (this.#script_src_elem.size > 0) {\n\t\t\tdirectives['script-src-elem'] = [\n\t\t\t\t...(directives['script-src-elem'] || []),\n\t\t\t\t...this.#script_src_elem\n\t\t\t];\n\t\t}\n\n\t\tfor (const key in directives) {\n\t\t\tif (is_meta && (key === 'frame-ancestors' || key === 'report-uri' || key === 'sandbox')) {\n\t\t\t\t// these values cannot be used with a <meta> tag\n\t\t\t\t// TODO warn?\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// @ts-expect-error gimme a break typescript, `key` is obviously a member of internal_directives\n\t\t\tconst value = /** @type {string[] | true} */ (directives[key]);\n\n\t\t\tif (!value) continue;\n\n\t\t\tconst directive = [key];\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tvalue.forEach((value) => {\n\t\t\t\t\tif (quoted.has(value) || crypto_pattern.test(value)) {\n\t\t\t\t\t\tdirective.push(`'${value}'`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdirective.push(value);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\theader.push(directive.join(' '));\n\t\t}\n\n\t\treturn header.join('; ');\n\t}\n}\n\nclass CspProvider extends BaseProvider {\n\tget_meta() {\n\t\tconst content = this.get_header(true);\n\n\t\tif (!content) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn `<meta http-equiv=\"content-security-policy\" content=\"${escape_html(content, true)}\">`;\n\t}\n}\n\nclass CspReportOnlyProvider extends BaseProvider {\n\t/**\n\t * @param {boolean} use_hashes\n\t * @param {import('types').CspDirectives} directives\n\t * @param {string} nonce\n\t */\n\tconstructor(use_hashes, directives, nonce) {\n\t\tsuper(use_hashes, directives, nonce);\n\n\t\tif (Object.values(directives).filter((v) => !!v).length > 0) {\n\t\t\t// If we're generating content-security-policy-report-only,\n\t\t\t// if there are any directives, we need a report-uri or report-to (or both)\n\t\t\t// else it's just an expensive noop.\n\t\t\tconst has_report_to = directives['report-to']?.length ?? 0 > 0;\n\t\t\tconst has_report_uri = directives['report-uri']?.length ?? 0 > 0;\n\t\t\tif (!has_report_to && !has_report_uri) {\n\t\t\t\tthrow Error(\n\t\t\t\t\t'`content-security-policy-report-only` must be specified with either the `report-to` or `report-uri` directives, or both'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class Csp {\n\t/** @readonly */\n\tnonce = generate_nonce();\n\n\t/** @type {CspProvider} */\n\tcsp_provider;\n\n\t/** @type {CspReportOnlyProvider} */\n\treport_only_provider;\n\n\t/**\n\t * @param {import('./types.js').CspConfig} config\n\t * @param {import('./types.js').CspOpts} opts\n\t */\n\tconstructor({ mode, directives, reportOnly }, { prerender }) {\n\t\tconst use_hashes = mode === 'hash' || (mode === 'auto' && prerender);\n\t\tthis.csp_provider = new CspProvider(use_hashes, directives, this.nonce);\n\t\tthis.report_only_provider = new CspReportOnlyProvider(use_hashes, reportOnly, this.nonce);\n\t}\n\n\tget script_needs_hash() {\n\t\treturn this.csp_provider.script_needs_hash || this.report_only_provider.script_needs_hash;\n\t}\n\n\tget script_needs_nonce() {\n\t\treturn this.csp_provider.script_needs_nonce || this.report_only_provider.script_needs_nonce;\n\t}\n\n\tget style_needs_nonce() {\n\t\treturn this.csp_provider.style_needs_nonce || this.report_only_provider.style_needs_nonce;\n\t}\n\n\t/** @param {string} content */\n\tadd_script(content) {\n\t\tthis.csp_provider.add_script(content);\n\t\tthis.report_only_provider.add_script(content);\n\t}\n\n\t/** @param {`sha256-${string}`[]} hashes */\n\tadd_script_hashes(hashes) {\n\t\tthis.csp_provider.add_script_hashes(hashes);\n\t\tthis.report_only_provider.add_script_hashes(hashes);\n\t}\n\n\t/** @param {string} content */\n\tadd_style(content) {\n\t\tthis.csp_provider.add_style(content);\n\t\tthis.report_only_provider.add_style(content);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/csp.spec.js",
    "content": "import process from 'node:process';\nimport { webcrypto } from 'node:crypto';\nimport { assert, test, describe } from 'vitest';\nimport { Csp } from './csp.js';\n\n// TODO: remove after bumping peer dependency to require Node 20\nif (!globalThis.crypto) {\n\t// @ts-expect-error\n\tglobalThis.crypto = webcrypto;\n}\n\ndescribe.skipIf(process.env.NODE_ENV === 'production')('CSPs in dev', () => {\n\ttest('adds unsafe-inline styles', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'default-src': ['self'],\n\t\t\t\t\t'style-src-attr': ['self', 'sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc='],\n\t\t\t\t\t'style-src-elem': ['self', 'sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=']\n\t\t\t\t},\n\t\t\t\treportOnly: {\n\t\t\t\t\t'default-src': ['self'],\n\t\t\t\t\t'style-src-attr': ['self'],\n\t\t\t\t\t'style-src-elem': ['self'],\n\t\t\t\t\t'report-uri': ['/']\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_style('');\n\n\t\tassert.equal(\n\t\t\tcsp.csp_provider.get_header(),\n\t\t\t\"default-src 'self'; style-src-attr 'self' 'unsafe-inline'; style-src-elem 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'\"\n\t\t);\n\n\t\tassert.equal(\n\t\t\tcsp.report_only_provider.get_header(),\n\t\t\t\"default-src 'self'; style-src-attr 'self' 'unsafe-inline'; style-src-elem 'self' 'unsafe-inline'; report-uri /; style-src 'self' 'unsafe-inline'\"\n\t\t);\n\t});\n\n\ttest.skip('removes strict-dynamic', () => {\n\t\t['default-src', 'script-src'].forEach((name) => {\n\t\t\tconst csp = new Csp(\n\t\t\t\t{\n\t\t\t\t\tmode: 'hash',\n\t\t\t\t\tdirectives: {\n\t\t\t\t\t\t[name]: ['strict-dynamic']\n\t\t\t\t\t},\n\t\t\t\t\treportOnly: {\n\t\t\t\t\t\t[name]: ['strict-dynamic'],\n\t\t\t\t\t\t'report-uri': ['/']\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tprerender: false\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tcsp.add_script('');\n\n\t\t\tassert.equal(csp.csp_provider.get_header(), '');\n\t\t\tassert.equal(csp.report_only_provider.get_header(), '');\n\t\t});\n\t});\n});\n\ndescribe.skipIf(process.env.NODE_ENV !== 'production')('CSPs in prod', () => {\n\ttest('generates blank CSP header', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tassert.equal(csp.csp_provider.get_header(), '');\n\t\tassert.equal(csp.report_only_provider.get_header(), '');\n\t});\n\n\ttest('generates CSP header with directive', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'default-src': ['self']\n\t\t\t\t},\n\t\t\t\treportOnly: {\n\t\t\t\t\t'default-src': ['self'],\n\t\t\t\t\t'report-uri': ['/']\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tassert.equal(csp.csp_provider.get_header(), \"default-src 'self'\");\n\t\tassert.equal(csp.report_only_provider.get_header(), \"default-src 'self'; report-uri /\");\n\t});\n\n\ttest('generates CSP header with nonce', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'nonce',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'default-src': ['self']\n\t\t\t\t},\n\t\t\t\treportOnly: {\n\t\t\t\t\t'default-src': ['self'],\n\t\t\t\t\t'report-uri': ['/']\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_script('');\n\n\t\tassert.ok(\n\t\t\tcsp.csp_provider.get_header().startsWith(\"default-src 'self'; script-src 'self' 'nonce-\")\n\t\t);\n\t\tassert.ok(\n\t\t\tcsp.report_only_provider\n\t\t\t\t.get_header()\n\t\t\t\t.startsWith(\"default-src 'self'; report-uri /; script-src 'self' 'nonce-\")\n\t\t);\n\t});\n\n\ttest('skips nonce with unsafe-inline', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'nonce',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'default-src': ['unsafe-inline'],\n\t\t\t\t\t'script-src': ['unsafe-inline'],\n\t\t\t\t\t'script-src-elem': ['unsafe-inline'],\n\t\t\t\t\t'style-src': ['unsafe-inline'],\n\t\t\t\t\t'style-src-attr': ['unsafe-inline'],\n\t\t\t\t\t'style-src-elem': ['unsafe-inline']\n\t\t\t\t},\n\t\t\t\treportOnly: {\n\t\t\t\t\t'default-src': ['unsafe-inline'],\n\t\t\t\t\t'script-src': ['unsafe-inline'],\n\t\t\t\t\t'script-src-elem': ['unsafe-inline'],\n\t\t\t\t\t'style-src': ['unsafe-inline'],\n\t\t\t\t\t'style-src-attr': ['unsafe-inline'],\n\t\t\t\t\t'style-src-elem': ['unsafe-inline'],\n\t\t\t\t\t'report-uri': ['/']\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_script('');\n\t\tcsp.add_style('');\n\n\t\tassert.equal(\n\t\t\tcsp.csp_provider.get_header(),\n\t\t\t\"default-src 'unsafe-inline'; script-src 'unsafe-inline'; script-src-elem 'unsafe-inline'; style-src 'unsafe-inline'; style-src-attr 'unsafe-inline'; style-src-elem 'unsafe-inline'\"\n\t\t);\n\t\tassert.equal(\n\t\t\tcsp.report_only_provider.get_header(),\n\t\t\t\"default-src 'unsafe-inline'; script-src 'unsafe-inline'; script-src-elem 'unsafe-inline'; style-src 'unsafe-inline'; style-src-attr 'unsafe-inline'; style-src-elem 'unsafe-inline'; report-uri /\"\n\t\t);\n\t});\n\n\ttest('skips nonce in style-src when using unsafe-inline', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'nonce',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'style-src': ['self', 'unsafe-inline']\n\t\t\t\t},\n\t\t\t\treportOnly: {\n\t\t\t\t\t'style-src': ['self', 'unsafe-inline'],\n\t\t\t\t\t'report-uri': ['/']\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_style('');\n\n\t\tassert.equal(csp.csp_provider.get_header(), \"style-src 'self' 'unsafe-inline'\");\n\t\tassert.equal(\n\t\t\tcsp.report_only_provider.get_header(),\n\t\t\t\"style-src 'self' 'unsafe-inline'; report-uri /\"\n\t\t);\n\t});\n\n\ttest('skips hash with unsafe-inline', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'default-src': ['unsafe-inline']\n\t\t\t\t},\n\t\t\t\treportOnly: {\n\t\t\t\t\t'default-src': ['unsafe-inline'],\n\t\t\t\t\t'report-uri': ['/']\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_script('');\n\n\t\tassert.equal(csp.csp_provider.get_header(), \"default-src 'unsafe-inline'\");\n\t\tassert.equal(\n\t\t\tcsp.report_only_provider.get_header(),\n\t\t\t\"default-src 'unsafe-inline'; report-uri /\"\n\t\t);\n\t});\n\n\ttest('does not add empty comment hash to style-src-elem if already defined', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'style-src-elem': ['self', 'sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=']\n\t\t\t\t},\n\t\t\t\treportOnly: {\n\t\t\t\t\t'report-uri': ['/']\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_style('/* empty */');\n\n\t\tassert.equal(\n\t\t\tcsp.csp_provider.get_header(),\n\t\t\t\"style-src-elem 'self' 'sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc='\"\n\t\t);\n\t});\n\n\ttest('skips frame-ancestors, report-uri, sandbox from meta tags', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'default-src': ['self'],\n\t\t\t\t\t'frame-ancestors': ['self'],\n\t\t\t\t\t'report-uri': ['/csp-violation-report-endpoint/'],\n\t\t\t\t\tsandbox: ['allow-modals']\n\t\t\t\t},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tassert.equal(\n\t\t\tcsp.csp_provider.get_header(),\n\t\t\t\"default-src 'self'; frame-ancestors 'self'; report-uri /csp-violation-report-endpoint/; sandbox allow-modals\"\n\t\t);\n\n\t\tassert.equal(\n\t\t\tcsp.csp_provider.get_meta(),\n\t\t\t'<meta http-equiv=\"content-security-policy\" content=\"default-src \\'self\\'\">'\n\t\t);\n\t});\n\n\ttest('adds nonce style-src-attr and style-src-elem and nonce + sha to script-src-elem if necessary', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'auto',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'script-src-elem': ['self'],\n\t\t\t\t\t'style-src-attr': ['self'],\n\t\t\t\t\t'style-src-elem': ['self']\n\t\t\t\t},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_script('');\n\t\tcsp.add_style('');\n\n\t\tconst csp_header = csp.csp_provider.get_header();\n\t\tassert.ok(csp_header.includes(\"script-src-elem 'self' 'nonce-\"));\n\t\tassert.ok(csp_header.includes(\"style-src-attr 'self' 'nonce-\"));\n\t\tassert.ok(\n\t\t\tcsp_header.includes(\n\t\t\t\t\"style-src-elem 'self' 'sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=' 'nonce-\"\n\t\t\t)\n\t\t);\n\t});\n\n\ttest('adds hash to script-src-elem, style-src-attr and style-src-elem if necessary during prerendering', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'auto',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'script-src-elem': ['self'],\n\t\t\t\t\t'style-src-attr': ['self'],\n\t\t\t\t\t'style-src-elem': ['self']\n\t\t\t\t},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: true\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_script('');\n\t\tcsp.add_style('');\n\n\t\tconst csp_header = csp.csp_provider.get_header();\n\t\tassert.ok(\n\t\t\tcsp_header.includes(\n\t\t\t\t\"script-src-elem 'self' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='\"\n\t\t\t)\n\t\t);\n\t\tassert.ok(\n\t\t\tcsp_header.includes(\n\t\t\t\t\"style-src-attr 'self' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='\"\n\t\t\t)\n\t\t);\n\t\tassert.ok(\n\t\t\tcsp_header.includes(\n\t\t\t\t\"style-src-elem 'self' 'sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='\"\n\t\t\t)\n\t\t);\n\t});\n\n\ttest('uses hashes when prerendering', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'auto',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'script-src': ['self']\n\t\t\t\t},\n\t\t\t\treportOnly: {\n\t\t\t\t\t'script-src': ['self'],\n\t\t\t\t\t'report-uri': ['/']\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: true\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_script('');\n\n\t\tassert.equal(\n\t\t\tcsp.csp_provider.get_header(),\n\t\t\t\"script-src 'self' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='\"\n\t\t);\n\n\t\tassert.equal(\n\t\t\tcsp.report_only_provider.get_header(),\n\t\t\t\"script-src 'self' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='; report-uri /\"\n\t\t);\n\t});\n\n\ttest('always creates a nonce when template needs it', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tassert.ok(csp.nonce);\n\t});\n\n\ttest('throws when reportOnly contains directives but no report-uri or report-to', () => {\n\t\tassert.throws(() => {\n\t\t\tnew Csp(\n\t\t\t\t{\n\t\t\t\t\tmode: 'hash',\n\t\t\t\t\tdirectives: {},\n\t\t\t\t\treportOnly: {\n\t\t\t\t\t\t'script-src': ['self']\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tprerender: false\n\t\t\t\t}\n\t\t\t);\n\t\t}, '`content-security-policy-report-only` must be specified with either the `report-to` or `report-uri` directives, or both');\n\t});\n\n\ttest('add_script_hashes adds hashes to script-src', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'script-src': ['self']\n\t\t\t\t},\n\t\t\t\treportOnly: {\n\t\t\t\t\t'script-src': ['self'],\n\t\t\t\t\t'report-uri': ['/']\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: true\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_script_hashes(['sha256-abc123', 'sha256-def456']);\n\n\t\tconst csp_header = csp.csp_provider.get_header();\n\t\tassert.ok(csp_header.includes(\"'sha256-abc123'\"));\n\t\tassert.ok(csp_header.includes(\"'sha256-def456'\"));\n\n\t\tconst report_only_header = csp.report_only_provider.get_header();\n\t\tassert.ok(report_only_header.includes(\"'sha256-abc123'\"));\n\t\tassert.ok(report_only_header.includes(\"'sha256-def456'\"));\n\t});\n\n\ttest('add_script_hashes adds to script-src-elem when configured', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'script-src-elem': ['self']\n\t\t\t\t},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: true\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_script_hashes(['sha256-test123']);\n\n\t\tconst csp_header = csp.csp_provider.get_header();\n\t\tassert.ok(csp_header.includes(\"script-src-elem 'self' 'sha256-test123'\"));\n\t});\n\n\ttest('add_script_hashes deduplicates hashes', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'script-src': ['self']\n\t\t\t\t},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: true\n\t\t\t}\n\t\t);\n\n\t\tcsp.add_script_hashes(['sha256-abc123']);\n\t\tcsp.add_script_hashes(['sha256-abc123']);\n\n\t\tconst csp_header = csp.csp_provider.get_header();\n\t\tconst matches = csp_header.match(/'sha256-abc123'/g);\n\t\tassert.equal(matches?.length, 1);\n\t});\n\n\ttest('script_needs_hash returns true when using hashes', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'hash',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'script-src': ['self']\n\t\t\t\t},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: true\n\t\t\t}\n\t\t);\n\n\t\tassert.ok(csp.script_needs_hash);\n\t\tassert.ok(!csp.script_needs_nonce);\n\t});\n\n\ttest('script_needs_hash returns false when using nonces', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'nonce',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'script-src': ['self']\n\t\t\t\t},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{\n\t\t\t\tprerender: false\n\t\t\t}\n\t\t);\n\n\t\tassert.ok(!csp.script_needs_hash);\n\t\tassert.ok(csp.script_needs_nonce);\n\t});\n\n\ttest('adds nonce when both unsafe-inline and strict-dynamic are present', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'nonce',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'script-src': ['strict-dynamic', 'unsafe-inline']\n\t\t\t\t},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{ prerender: false }\n\t\t);\n\n\t\tcsp.add_script('');\n\n\t\tconst header = csp.csp_provider.get_header();\n\t\t// Should include nonce even though unsafe-inline is present,\n\t\t// because strict-dynamic causes browsers to ignore unsafe-inline\n\t\tassert.ok(header.includes(\"'nonce-\"));\n\t\tassert.ok(header.includes(\"'strict-dynamic'\"));\n\t\tassert.ok(header.includes(\"'unsafe-inline'\"));\n\t});\n\n\ttest('adds nonce with strict-dynamic in default-src', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'nonce',\n\t\t\t\tdirectives: {\n\t\t\t\t\t'default-src': ['strict-dynamic', 'unsafe-inline']\n\t\t\t\t},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{ prerender: false }\n\t\t);\n\n\t\tcsp.add_script('');\n\n\t\tconst header = csp.csp_provider.get_header();\n\t\t// Should include nonce even though unsafe-inline is present\n\t\tassert.ok(header.includes(\"'nonce-\"));\n\t\tassert.ok(header.includes(\"'strict-dynamic'\"));\n\t\tassert.ok(header.includes(\"'unsafe-inline'\"));\n\t});\n\n\ttest('strict-dynamic does not affect style-src', () => {\n\t\tconst csp = new Csp(\n\t\t\t{\n\t\t\t\tmode: 'nonce',\n\t\t\t\tdirectives: {\n\t\t\t\t\t// strict-dynamic only affects scripts, not styles per CSP spec\n\t\t\t\t\t'style-src': ['strict-dynamic', 'unsafe-inline']\n\t\t\t\t},\n\t\t\t\treportOnly: {}\n\t\t\t},\n\t\t\t{ prerender: false }\n\t\t);\n\n\t\tcsp.add_style('');\n\n\t\tconst header = csp.csp_provider.get_header();\n\t\t// Should NOT include nonce because strict-dynamic doesn't affect styles\n\t\t// and unsafe-inline is present\n\t\tassert.ok(!header.includes(\"'nonce-\"));\n\t\tassert.ok(header.includes(\"'strict-dynamic'\"));\n\t\tassert.ok(header.includes(\"'unsafe-inline'\"));\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/data_serializer.js",
    "content": "import * as devalue from 'devalue';\nimport { compact } from '../../../utils/array.js';\nimport { create_async_iterator } from '../../../utils/streaming.js';\nimport {\n\tclarify_devalue_error,\n\tget_global_name,\n\thandle_error_and_jsonify,\n\tserialize_uses\n} from '../utils.js';\n\n/**\n * If the serialized data contains promises, `chunks` will be an\n * async iterable containing their resolutions\n * @param {import('@sveltejs/kit').RequestEvent} event\n * @param {import('types').RequestState} event_state\n * @param {import('types').SSROptions} options\n * @returns {import('./types.js').ServerDataSerializer}\n */\nexport function server_data_serializer(event, event_state, options) {\n\tlet promise_id = 1;\n\tlet max_nodes = -1;\n\n\tconst iterator = create_async_iterator();\n\tconst global = get_global_name(options);\n\n\t/** @param {number} index */\n\tfunction get_replacer(index) {\n\t\t/** @param {any} thing */\n\t\treturn function replacer(thing) {\n\t\t\tif (typeof thing?.then === 'function') {\n\t\t\t\tconst id = promise_id++;\n\n\t\t\t\tconst promise = thing\n\t\t\t\t\t.then(/** @param {any} data */ (data) => ({ data }))\n\t\t\t\t\t.catch(\n\t\t\t\t\t\t/** @param {any} error */ async (error) => ({\n\t\t\t\t\t\t\terror: await handle_error_and_jsonify(event, event_state, options, error)\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t\t.then(\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * @param {{data: any; error: any}} result\n\t\t\t\t\t\t */\n\t\t\t\t\t\tasync ({ data, error }) => {\n\t\t\t\t\t\t\tlet str;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tstr = devalue.uneval(error ? [, error] : [data], replacer);\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\terror = await handle_error_and_jsonify(\n\t\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t\t\tevent_state,\n\t\t\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\t\t\tnew Error(`Failed to serialize promise while rendering ${event.route.id}`)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tstr = devalue.uneval([, error], replacer);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\tstr: `${global}.resolve(${id}, ${str.includes('app.decode') ? `(app) => ${str}` : `() => ${str}`})`\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\titerator.add(promise);\n\n\t\t\t\treturn `${global}.defer(${id})`;\n\t\t\t} else {\n\t\t\t\tfor (const key in options.hooks.transport) {\n\t\t\t\t\tconst encoded = options.hooks.transport[key].encode(thing);\n\t\t\t\t\tif (encoded) {\n\t\t\t\t\t\treturn `app.decode('${key}', ${devalue.uneval(encoded, replacer)})`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tconst strings = /** @type {string[]} */ ([]);\n\n\treturn {\n\t\tset_max_nodes(i) {\n\t\t\tmax_nodes = i;\n\t\t},\n\n\t\tadd_node(i, node) {\n\t\t\ttry {\n\t\t\t\tif (!node) {\n\t\t\t\t\tstrings[i] = 'null';\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t/** @type {any} */\n\t\t\t\tconst payload = { type: 'data', data: node.data, uses: serialize_uses(node) };\n\t\t\t\tif (node.slash) payload.slash = node.slash;\n\n\t\t\t\tstrings[i] = devalue.uneval(payload, get_replacer(i));\n\t\t\t} catch (e) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\te.path = e.path.slice(1);\n\t\t\t\tthrow new Error(clarify_devalue_error(event, /** @type {any} */ (e)), { cause: e });\n\t\t\t}\n\t\t},\n\n\t\tget_data(csp) {\n\t\t\tconst open = `<script${csp.script_needs_nonce ? ` nonce=\"${csp.nonce}\"` : ''}>`;\n\t\t\tconst close = `</script>\\n`;\n\n\t\t\treturn {\n\t\t\t\tdata: `[${compact(max_nodes > -1 ? strings.slice(0, max_nodes) : strings).join(',')}]`,\n\t\t\t\tchunks:\n\t\t\t\t\tpromise_id > 1\n\t\t\t\t\t\t? iterator.iterate(({ index, str }) => {\n\t\t\t\t\t\t\t\tif (max_nodes > -1 && index >= max_nodes) {\n\t\t\t\t\t\t\t\t\treturn '';\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn open + str + close;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: null\n\t\t\t};\n\t\t}\n\t};\n}\n\n/**\n * If the serialized data contains promises, `chunks` will be an\n * async iterable containing their resolutions\n * @param {import('@sveltejs/kit').RequestEvent} event\n * @param {import('types').RequestState} event_state\n * @param {import('types').SSROptions} options\n * @returns {import('./types.js').ServerDataSerializerJson}\n */\nexport function server_data_serializer_json(event, event_state, options) {\n\tlet promise_id = 1;\n\n\tconst iterator = create_async_iterator();\n\n\tconst reducers = {\n\t\t...Object.fromEntries(\n\t\t\tObject.entries(options.hooks.transport).map(([key, value]) => [key, value.encode])\n\t\t),\n\t\t/** @param {any} thing */\n\t\tPromise: (thing) => {\n\t\t\tif (typeof thing?.then !== 'function') {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst id = promise_id++;\n\n\t\t\t/** @type {'data' | 'error'} */\n\t\t\tlet key = 'data';\n\n\t\t\tconst promise = thing\n\t\t\t\t.catch(\n\t\t\t\t\t/** @param {any} e */ async (e) => {\n\t\t\t\t\t\tkey = 'error';\n\t\t\t\t\t\treturn handle_error_and_jsonify(event, event_state, options, /** @type {any} */ (e));\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\t.then(\n\t\t\t\t\t/** @param {any} value */\n\t\t\t\t\tasync (value) => {\n\t\t\t\t\t\tlet str;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tstr = devalue.stringify(value, reducers);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tconst error = await handle_error_and_jsonify(\n\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t\tevent_state,\n\t\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\t\tnew Error(`Failed to serialize promise while rendering ${event.route.id}`)\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tkey = 'error';\n\t\t\t\t\t\t\tstr = devalue.stringify(error, reducers);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn `{\"type\":\"chunk\",\"id\":${id},\"${key}\":${str}}\\n`;\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\titerator.add(promise);\n\n\t\t\treturn id;\n\t\t}\n\t};\n\n\tconst strings = /** @type {string[]} */ ([]);\n\n\treturn {\n\t\tadd_node(i, node) {\n\t\t\ttry {\n\t\t\t\tif (!node) {\n\t\t\t\t\tstrings[i] = 'null';\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (node.type === 'error' || node.type === 'skip') {\n\t\t\t\t\tstrings[i] = JSON.stringify(node);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tstrings[i] =\n\t\t\t\t\t`{\"type\":\"data\",\"data\":${devalue.stringify(node.data, reducers)},\"uses\":${JSON.stringify(\n\t\t\t\t\t\tserialize_uses(node)\n\t\t\t\t\t)}${node.slash ? `,\"slash\":${JSON.stringify(node.slash)}` : ''}}`;\n\t\t\t} catch (e) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\te.path = 'data' + e.path;\n\t\t\t\tthrow new Error(clarify_devalue_error(event, /** @type {any} */ (e)), { cause: e });\n\t\t\t}\n\t\t},\n\n\t\tget_data() {\n\t\t\treturn {\n\t\t\t\tdata: `{\"type\":\"data\",\"nodes\":[${strings.join(',')}]}\\n`,\n\t\t\t\tchunks: promise_id > 1 ? iterator.iterate() : null\n\t\t\t};\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/index.js",
    "content": "import { text } from '@sveltejs/kit';\nimport { HttpError, Redirect } from '@sveltejs/kit/internal';\nimport { compact } from '../../../utils/array.js';\nimport { get_status, normalize_error } from '../../../utils/error.js';\nimport { add_data_suffix } from '../../pathname.js';\nimport { redirect_response, static_error_page, handle_error_and_jsonify } from '../utils.js';\nimport {\n\thandle_action_json_request,\n\thandle_action_request,\n\tis_action_json_request,\n\tis_action_request\n} from './actions.js';\nimport { server_data_serializer, server_data_serializer_json } from './data_serializer.js';\nimport { load_data, load_server_data } from './load_data.js';\nimport { render_response } from './render.js';\nimport { respond_with_error } from './respond_with_error.js';\nimport { DEV } from 'esm-env';\nimport { get_remote_action, handle_remote_form_post } from '../remote.js';\nimport { PageNodes } from '../../../utils/page_nodes.js';\n\n/**\n * The maximum request depth permitted before assuming we're stuck in an infinite loop\n */\nconst MAX_DEPTH = 10;\n\n/**\n * @param {import('@sveltejs/kit').RequestEvent} event\n * @param {import('types').RequestState} event_state\n * @param {import('types').PageNodeIndexes} page\n * @param {import('types').SSROptions} options\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n * @param {import('types').SSRState} state\n * @param {import('../../../utils/page_nodes.js').PageNodes} nodes\n * @param {import('types').RequiredResolveOptions} resolve_opts\n * @returns {Promise<Response>}\n */\nexport async function render_page(\n\tevent,\n\tevent_state,\n\tpage,\n\toptions,\n\tmanifest,\n\tstate,\n\tnodes,\n\tresolve_opts\n) {\n\tif (state.depth > MAX_DEPTH) {\n\t\t// infinite request cycle detected\n\t\treturn text(`Not found: ${event.url.pathname}`, {\n\t\t\tstatus: 404 // TODO in some cases this should be 500. not sure how to differentiate\n\t\t});\n\t}\n\n\tif (is_action_json_request(event)) {\n\t\tconst node = await manifest._.nodes[page.leaf]();\n\t\treturn handle_action_json_request(event, event_state, options, node?.server);\n\t}\n\n\ttry {\n\t\tconst leaf_node = /** @type {import('types').SSRNode} */ (nodes.page());\n\n\t\tlet status = 200;\n\n\t\t/** @type {import('@sveltejs/kit').ActionResult | undefined} */\n\t\tlet action_result = undefined;\n\n\t\tif (is_action_request(event)) {\n\t\t\tconst remote_id = get_remote_action(event.url);\n\t\t\tif (remote_id) {\n\t\t\t\taction_result = await handle_remote_form_post(event, event_state, manifest, remote_id);\n\t\t\t} else {\n\t\t\t\t// for action requests, first call handler in +page.server.js\n\t\t\t\t// (this also determines status code)\n\t\t\t\taction_result = await handle_action_request(event, event_state, leaf_node.server);\n\t\t\t}\n\n\t\t\tif (action_result?.type === 'redirect') {\n\t\t\t\treturn redirect_response(action_result.status, action_result.location);\n\t\t\t}\n\t\t\tif (action_result?.type === 'error') {\n\t\t\t\tstatus = get_status(action_result.error);\n\t\t\t}\n\t\t\tif (action_result?.type === 'failure') {\n\t\t\t\tstatus = action_result.status;\n\t\t\t}\n\t\t}\n\n\t\t// it's crucial that we do this before returning the non-SSR response, otherwise\n\t\t// SvelteKit will erroneously believe that the path has been prerendered,\n\t\t// causing functions to be omitted from the manifest generated later\n\t\tconst should_prerender = nodes.prerender();\n\t\tif (should_prerender) {\n\t\t\tconst mod = leaf_node.server;\n\t\t\tif (mod?.actions) {\n\t\t\t\tthrow new Error('Cannot prerender pages with actions');\n\t\t\t}\n\t\t} else if (state.prerendering) {\n\t\t\t// if the page isn't marked as prerenderable, then bail out at this point\n\t\t\treturn new Response(undefined, {\n\t\t\t\tstatus: 204\n\t\t\t});\n\t\t}\n\n\t\t// if we fetch any endpoints while loading data for this page, they should\n\t\t// inherit the prerender option of the page\n\t\tstate.prerender_default = should_prerender;\n\n\t\tconst should_prerender_data = nodes.should_prerender_data();\n\t\tconst data_pathname = add_data_suffix(event.url.pathname);\n\n\t\t/** @type {import('./types.js').Fetched[]} */\n\t\tconst fetched = [];\n\n\t\tconst ssr = nodes.ssr();\n\t\tconst csr = nodes.csr();\n\n\t\t// renders an empty 'shell' page if SSR is turned off and if there is\n\t\t// no server data to prerender. As a result, the load functions and rendering\n\t\t// only occur client-side.\n\t\tif (ssr === false && !(state.prerendering && should_prerender_data)) {\n\t\t\t// if the user makes a request through a non-enhanced form, the returned value is lost\n\t\t\t// because there is no SSR or client-side handling of the response\n\t\t\tif (DEV && action_result && !event.request.headers.has('x-sveltekit-action')) {\n\t\t\t\tif (action_result.type === 'error') {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\"The form action returned an error, but +error.svelte wasn't rendered because SSR is off. To get the error page with CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance\"\n\t\t\t\t\t);\n\t\t\t\t} else if (action_result.data) {\n\t\t\t\t\t/// case: lost data\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\"The form action returned a value, but it isn't available in `page.form`, because SSR is off. To handle the returned value in CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn await render_response({\n\t\t\t\tbranch: [],\n\t\t\t\tfetched,\n\t\t\t\tpage_config: {\n\t\t\t\t\tssr: false,\n\t\t\t\t\tcsr\n\t\t\t\t},\n\t\t\t\tstatus,\n\t\t\t\terror: null,\n\t\t\t\tevent,\n\t\t\t\tevent_state,\n\t\t\t\toptions,\n\t\t\t\tmanifest,\n\t\t\t\tstate,\n\t\t\t\tresolve_opts,\n\t\t\t\tdata_serializer: server_data_serializer(event, event_state, options)\n\t\t\t});\n\t\t}\n\n\t\t/** @type {Array<import('./types.js').Loaded | null>} */\n\t\tconst branch = [];\n\n\t\t/** @type {Error | null} */\n\t\tlet load_error = null;\n\n\t\tconst data_serializer = server_data_serializer(event, event_state, options);\n\t\tconst data_serializer_json =\n\t\t\tstate.prerendering && should_prerender_data\n\t\t\t\t? server_data_serializer_json(event, event_state, options)\n\t\t\t\t: null;\n\n\t\t/** @type {Array<Promise<import('types').ServerDataNode | null>>} */\n\t\tconst server_promises = nodes.data.map((node, i) => {\n\t\t\tif (load_error) {\n\t\t\t\t// if an error happens immediately, don't bother with the rest of the nodes\n\t\t\t\tthrow load_error;\n\t\t\t}\n\n\t\t\treturn Promise.resolve().then(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tif (node === leaf_node && action_result?.type === 'error') {\n\t\t\t\t\t\t// we wait until here to throw the error so that we can use\n\t\t\t\t\t\t// any nested +error.svelte components that were defined\n\t\t\t\t\t\tthrow action_result.error;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst server_data = await load_server_data({\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\tevent_state,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tparent: async () => {\n\t\t\t\t\t\t\t/** @type {Record<string, any>} */\n\t\t\t\t\t\t\tconst data = {};\n\t\t\t\t\t\t\tfor (let j = 0; j < i; j += 1) {\n\t\t\t\t\t\t\t\tconst parent = await server_promises[j];\n\t\t\t\t\t\t\t\tif (parent) Object.assign(data, parent.data);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn data;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tif (node) {\n\t\t\t\t\t\tdata_serializer.add_node(i, server_data);\n\t\t\t\t\t}\n\n\t\t\t\t\tdata_serializer_json?.add_node(i, server_data);\n\n\t\t\t\t\treturn server_data;\n\t\t\t\t} catch (e) {\n\t\t\t\t\tload_error = /** @type {Error} */ (e);\n\t\t\t\t\tthrow load_error;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t/** @type {Array<Promise<Record<string, any> | null>>} */\n\t\tconst load_promises = nodes.data.map((node, i) => {\n\t\t\tif (load_error) throw load_error;\n\t\t\treturn Promise.resolve().then(async () => {\n\t\t\t\ttry {\n\t\t\t\t\treturn await load_data({\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\tevent_state,\n\t\t\t\t\t\tfetched,\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tparent: async () => {\n\t\t\t\t\t\t\tconst data = {};\n\t\t\t\t\t\t\tfor (let j = 0; j < i; j += 1) {\n\t\t\t\t\t\t\t\tObject.assign(data, await load_promises[j]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn data;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve_opts,\n\t\t\t\t\t\tserver_data_promise: server_promises[i],\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tcsr\n\t\t\t\t\t});\n\t\t\t\t} catch (e) {\n\t\t\t\t\tload_error = /** @type {Error} */ (e);\n\t\t\t\t\tthrow load_error;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t// if we don't do this, rejections will be unhandled\n\t\tfor (const p of server_promises) p.catch(() => {});\n\t\tfor (const p of load_promises) p.catch(() => {});\n\n\t\tfor (let i = 0; i < nodes.data.length; i += 1) {\n\t\t\tconst node = nodes.data[i];\n\n\t\t\tif (node) {\n\t\t\t\ttry {\n\t\t\t\t\tconst server_data = await server_promises[i];\n\t\t\t\t\tconst data = await load_promises[i];\n\n\t\t\t\t\tbranch.push({ node, server_data, data });\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconst err = normalize_error(e);\n\n\t\t\t\t\tif (err instanceof Redirect) {\n\t\t\t\t\t\tif (state.prerendering && should_prerender_data) {\n\t\t\t\t\t\t\tconst body = JSON.stringify({\n\t\t\t\t\t\t\t\ttype: 'redirect',\n\t\t\t\t\t\t\t\tlocation: err.location\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tstate.prerendering.dependencies.set(data_pathname, {\n\t\t\t\t\t\t\t\tresponse: text(body),\n\t\t\t\t\t\t\t\tbody\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn redirect_response(err.status, err.location);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst status = get_status(err);\n\t\t\t\t\tconst error = await handle_error_and_jsonify(event, event_state, options, err);\n\n\t\t\t\t\twhile (i--) {\n\t\t\t\t\t\tif (page.errors[i]) {\n\t\t\t\t\t\t\tconst index = /** @type {number} */ (page.errors[i]);\n\t\t\t\t\t\t\tconst node = await manifest._.nodes[index]();\n\n\t\t\t\t\t\t\tlet j = i;\n\t\t\t\t\t\t\twhile (!branch[j]) j -= 1;\n\n\t\t\t\t\t\t\tdata_serializer.set_max_nodes(j + 1);\n\n\t\t\t\t\t\t\tconst layouts = compact(branch.slice(0, j + 1));\n\t\t\t\t\t\t\tconst nodes = new PageNodes(layouts.map((layout) => layout.node));\n\t\t\t\t\t\t\tconst error_branch = layouts.concat({\n\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t\tserver_data: null\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn await render_response({\n\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t\tevent_state,\n\t\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\t\tmanifest,\n\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\tresolve_opts,\n\t\t\t\t\t\t\t\tpage_config: {\n\t\t\t\t\t\t\t\t\tssr: nodes.ssr(),\n\t\t\t\t\t\t\t\t\tcsr: nodes.csr()\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\terror_components: await load_error_components(\n\t\t\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\t\t\tssr,\n\t\t\t\t\t\t\t\t\terror_branch,\n\t\t\t\t\t\t\t\t\tpage,\n\t\t\t\t\t\t\t\t\tmanifest\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tbranch: error_branch,\n\t\t\t\t\t\t\t\tfetched,\n\t\t\t\t\t\t\t\tdata_serializer\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// if we're still here, it means the error happened in the root layout,\n\t\t\t\t\t// which means we have to fall back to error.html\n\t\t\t\t\treturn static_error_page(options, status, error.message);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// push an empty slot so we can rewind past gaps to the\n\t\t\t\t// layout that corresponds with an +error.svelte page\n\t\t\t\tbranch.push(null);\n\t\t\t}\n\t\t}\n\n\t\tif (state.prerendering && data_serializer_json) {\n\t\t\t// ndjson format\n\t\t\tlet { data, chunks } = data_serializer_json.get_data();\n\n\t\t\tif (chunks) {\n\t\t\t\tfor await (const chunk of chunks) {\n\t\t\t\t\tdata += chunk;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstate.prerendering.dependencies.set(data_pathname, {\n\t\t\t\tresponse: text(data),\n\t\t\t\tbody: data\n\t\t\t});\n\t\t}\n\n\t\treturn await render_response({\n\t\t\tevent,\n\t\t\tevent_state,\n\t\t\toptions,\n\t\t\tmanifest,\n\t\t\tstate,\n\t\t\tresolve_opts,\n\t\t\tpage_config: {\n\t\t\t\tcsr,\n\t\t\t\tssr\n\t\t\t},\n\t\t\tstatus,\n\t\t\terror: null,\n\t\t\tbranch: !ssr ? [] : compact(branch),\n\t\t\taction_result,\n\t\t\tfetched,\n\t\t\tdata_serializer: !ssr ? server_data_serializer(event, event_state, options) : data_serializer,\n\t\t\terror_components: await load_error_components(options, ssr, branch, page, manifest)\n\t\t});\n\t} catch (e) {\n\t\t// a remote function could have thrown a redirect during render\n\t\tif (e instanceof Redirect) {\n\t\t\treturn redirect_response(e.status, e.location);\n\t\t}\n\n\t\t// if we end up here, it means the data loaded successfully\n\t\t// but the page failed to render, or that a prerendering error occurred\n\t\treturn await respond_with_error({\n\t\t\tevent,\n\t\t\tevent_state,\n\t\t\toptions,\n\t\t\tmanifest,\n\t\t\tstate,\n\t\t\tstatus: e instanceof HttpError ? e.status : 500,\n\t\t\terror: e,\n\t\t\tresolve_opts\n\t\t});\n\t}\n}\n\n/**\n *\n * @param {import('types').SSROptions} options\n * @param {boolean} ssr\n * @param {Array<import('./types.js').Loaded | null>} branch\n * @param {import('types').PageNodeIndexes} page\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n */\nasync function load_error_components(options, ssr, branch, page, manifest) {\n\t/** @type {Array<import('types').SSRComponent | undefined> | undefined} */\n\tlet error_components;\n\n\tif (options.server_error_boundaries && ssr) {\n\t\tlet last_idx = -1;\n\t\terror_components = await Promise.all(\n\t\t\t// eslint-disable-next-line @typescript-eslint/await-thenable\n\t\t\tbranch\n\t\t\t\t.map((b, i) => {\n\t\t\t\t\tif (i === 0) return undefined; // root layout wraps root error component, not the other way around\n\t\t\t\t\tif (!b) return null;\n\n\t\t\t\t\ti--;\n\t\t\t\t\t// Find the closest error component up to the previous branch\n\t\t\t\t\twhile (i > last_idx + 1 && page.errors[i] === undefined) i -= 1;\n\t\t\t\t\tlast_idx = i;\n\n\t\t\t\t\tconst idx = page.errors[i];\n\t\t\t\t\tif (idx == null) return undefined;\n\n\t\t\t\t\treturn manifest._.nodes[idx]?.()\n\t\t\t\t\t\t.then((e) => e.component?.())\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t})\n\t\t\t\t// filter out indexes where there was no branch, but keep indexes where there was a branch but no error component\n\t\t\t\t.filter((e) => e !== null)\n\t\t);\n\t}\n\n\treturn error_components;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/load_data.js",
    "content": "import { DEV } from 'esm-env';\nimport { disable_search, make_trackable } from '../../../utils/url.js';\nimport { validate_depends, validate_load_response } from '../../shared.js';\nimport { with_request_store, merge_tracing } from '@sveltejs/kit/internal/server';\nimport { record_span } from '../../telemetry/record_span.js';\nimport { base64_encode, text_decoder } from '../../utils.js';\nimport { NULL_BODY_STATUS } from '../constants.js';\nimport { get_node_type } from '../utils.js';\n\n/**\n * Calls the user's server `load` function.\n * @param {{\n *   event: import('@sveltejs/kit').RequestEvent;\n *   event_state: import('types').RequestState;\n *   state: import('types').SSRState;\n *   node: import('types').SSRNode | undefined;\n *   parent: () => Promise<Record<string, any>>;\n * }} opts\n * @returns {Promise<import('types').ServerDataNode | null>}\n */\nexport async function load_server_data({ event, event_state, state, node, parent }) {\n\tif (!node?.server) return null;\n\n\tlet is_tracking = true;\n\n\tconst uses = {\n\t\tdependencies: new Set(),\n\t\tparams: new Set(),\n\t\tparent: false,\n\t\troute: false,\n\t\turl: false,\n\t\tsearch_params: new Set()\n\t};\n\n\tconst load = node.server.load;\n\t// TODO: shouldn't this be calculated using PageNodes? there could be a trailingSlash option on a layout\n\tconst slash = node.server.trailingSlash;\n\n\tif (!load) {\n\t\treturn { type: 'data', data: null, uses, slash };\n\t}\n\n\tconst url = make_trackable(\n\t\tevent.url,\n\t\t() => {\n\t\t\tif (DEV && done && !uses.url) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${node.server_id}: Accessing URL properties in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when the URL changes`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (is_tracking) {\n\t\t\t\tuses.url = true;\n\t\t\t}\n\t\t},\n\t\t(param) => {\n\t\t\tif (DEV && done && !uses.search_params.has(param)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${node.server_id}: Accessing URL properties in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when the URL changes`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (is_tracking) {\n\t\t\t\tuses.search_params.add(param);\n\t\t\t}\n\t\t}\n\t);\n\n\tif (state.prerendering) {\n\t\tdisable_search(url);\n\t}\n\n\tlet done = false;\n\n\tconst result = await record_span({\n\t\tname: 'sveltekit.load',\n\t\tattributes: {\n\t\t\t'sveltekit.load.node_id': node.server_id || 'unknown',\n\t\t\t'sveltekit.load.node_type': get_node_type(node.server_id),\n\t\t\t'sveltekit.load.environment': 'server',\n\t\t\t'http.route': event.route.id || 'unknown'\n\t\t},\n\t\tfn: async (current) => {\n\t\t\tconst traced_event = merge_tracing(event, current);\n\t\t\tconst result = await with_request_store({ event: traced_event, state: event_state }, () =>\n\t\t\t\tload.call(null, {\n\t\t\t\t\t...traced_event,\n\t\t\t\t\tfetch: (info, init) => {\n\t\t\t\t\t\tconst url = new URL(info instanceof Request ? info.url : info, event.url);\n\n\t\t\t\t\t\tif (DEV && done && !uses.dependencies.has(url.href)) {\n\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t`${node.server_id}: Calling \\`event.fetch(...)\\` in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when the dependency is invalidated`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Note: server fetches are not added to uses.depends due to security concerns\n\t\t\t\t\t\treturn event.fetch(info, init);\n\t\t\t\t\t},\n\t\t\t\t\t/** @param {string[]} deps */\n\t\t\t\t\tdepends: (...deps) => {\n\t\t\t\t\t\tfor (const dep of deps) {\n\t\t\t\t\t\t\tconst { href } = new URL(dep, event.url);\n\n\t\t\t\t\t\t\tif (DEV) {\n\t\t\t\t\t\t\t\tvalidate_depends(node.server_id || 'missing route ID', dep);\n\n\t\t\t\t\t\t\t\tif (done && !uses.dependencies.has(href)) {\n\t\t\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t\t\t`${node.server_id}: Calling \\`depends(...)\\` in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when the dependency is invalidated`\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tuses.dependencies.add(href);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tparams: new Proxy(event.params, {\n\t\t\t\t\t\tget: (target, key) => {\n\t\t\t\t\t\t\tif (DEV && done && typeof key === 'string' && !uses.params.has(key)) {\n\t\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t\t`${node.server_id}: Accessing \\`params.${String(\n\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t)}\\` in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when the param changes`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (is_tracking) {\n\t\t\t\t\t\t\t\tuses.params.add(key);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn target[/** @type {string} */ (key)];\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\tparent: async () => {\n\t\t\t\t\t\tif (DEV && done && !uses.parent) {\n\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t`${node.server_id}: Calling \\`parent(...)\\` in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when parent data changes`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (is_tracking) {\n\t\t\t\t\t\t\tuses.parent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn parent();\n\t\t\t\t\t},\n\t\t\t\t\troute: new Proxy(event.route, {\n\t\t\t\t\t\tget: (target, key) => {\n\t\t\t\t\t\t\tif (DEV && done && typeof key === 'string' && !uses.route) {\n\t\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t\t`${node.server_id}: Accessing \\`route.${String(\n\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t)}\\` in a promise handler after \\`load(...)\\` has returned will not cause the function to re-run when the route changes`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (is_tracking) {\n\t\t\t\t\t\t\t\tuses.route = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn target[/** @type {'id'} */ (key)];\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\turl,\n\t\t\t\t\tuntrack(fn) {\n\t\t\t\t\t\tis_tracking = false;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn fn();\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\tis_tracking = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t);\n\n\t\t\treturn result;\n\t\t}\n\t});\n\n\tif (DEV) {\n\t\tvalidate_load_response(result, `in ${node.server_id}`);\n\t}\n\n\tdone = true;\n\n\treturn {\n\t\ttype: 'data',\n\t\tdata: result ?? null,\n\t\tuses,\n\t\tslash\n\t};\n}\n\n/**\n * Calls the user's `load` function.\n * @param {{\n *   event: import('@sveltejs/kit').RequestEvent;\n *   event_state: import('types').RequestState;\n *   fetched: import('./types.js').Fetched[];\n *   node: import('types').SSRNode | undefined;\n *   parent: () => Promise<Record<string, any>>;\n *   resolve_opts: import('types').RequiredResolveOptions;\n *   server_data_promise: Promise<import('types').ServerDataNode | null>;\n *   state: import('types').SSRState;\n *   csr: boolean;\n * }} opts\n * @returns {Promise<Record<string, any | Promise<any>> | null>}\n */\nexport async function load_data({\n\tevent,\n\tevent_state,\n\tfetched,\n\tnode,\n\tparent,\n\tserver_data_promise,\n\tstate,\n\tresolve_opts,\n\tcsr\n}) {\n\tconst server_data_node = await server_data_promise;\n\n\tconst load = node?.universal?.load;\n\n\tif (!load) {\n\t\treturn server_data_node?.data ?? null;\n\t}\n\n\tconst result = await record_span({\n\t\tname: 'sveltekit.load',\n\t\tattributes: {\n\t\t\t'sveltekit.load.node_id': node.universal_id || 'unknown',\n\t\t\t'sveltekit.load.node_type': get_node_type(node.universal_id),\n\t\t\t'sveltekit.load.environment': 'server',\n\t\t\t'http.route': event.route.id || 'unknown'\n\t\t},\n\t\tfn: async (current) => {\n\t\t\tconst traced_event = merge_tracing(event, current);\n\t\t\tconst child_state = { ...event_state, is_in_universal_load: true };\n\n\t\t\treturn await with_request_store({ event: traced_event, state: child_state }, () =>\n\t\t\t\tload.call(null, {\n\t\t\t\t\turl: event.url,\n\t\t\t\t\tparams: event.params,\n\t\t\t\t\tdata: server_data_node?.data ?? null,\n\t\t\t\t\troute: event.route,\n\t\t\t\t\tfetch: create_universal_fetch(event, state, fetched, csr, resolve_opts),\n\t\t\t\t\tsetHeaders: event.setHeaders,\n\t\t\t\t\tdepends: () => {},\n\t\t\t\t\tparent,\n\t\t\t\t\tuntrack: (fn) => fn(),\n\t\t\t\t\ttracing: traced_event.tracing\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t});\n\n\tif (DEV) {\n\t\tvalidate_load_response(result, `in ${node.universal_id}`);\n\t}\n\n\treturn result ?? null;\n}\n\n/**\n * @param {Pick<import('@sveltejs/kit').RequestEvent, 'fetch' | 'url' | 'request' | 'route'>} event\n * @param {import('types').SSRState} state\n * @param {import('./types.js').Fetched[]} fetched\n * @param {boolean} csr\n * @param {Pick<Required<import('@sveltejs/kit').ResolveOptions>, 'filterSerializedResponseHeaders'>} resolve_opts\n * @returns {typeof fetch}\n */\nexport function create_universal_fetch(event, state, fetched, csr, resolve_opts) {\n\t/**\n\t * @param {URL | RequestInfo} input\n\t * @param {RequestInit} [init]\n\t */\n\tconst universal_fetch = async (input, init) => {\n\t\tconst cloned_body = input instanceof Request && input.body ? input.clone().body : null;\n\n\t\tconst cloned_headers =\n\t\t\tinput instanceof Request && [...input.headers].length\n\t\t\t\t? new Headers(input.headers)\n\t\t\t\t: init?.headers;\n\n\t\tlet response = await event.fetch(input, init);\n\n\t\tconst url = new URL(input instanceof Request ? input.url : input, event.url);\n\t\tconst same_origin = url.origin === event.url.origin;\n\n\t\t/** @type {import('types').PrerenderDependency} */\n\t\tlet dependency;\n\n\t\tif (same_origin) {\n\t\t\tif (state.prerendering) {\n\t\t\t\tdependency = { response, body: null };\n\t\t\t\tstate.prerendering.dependencies.set(url.pathname, dependency);\n\t\t\t}\n\t\t} else if (url.protocol === 'https:' || url.protocol === 'http:') {\n\t\t\t// simulate CORS errors and \"no access to body in no-cors mode\" server-side for consistency with client-side behaviour\n\t\t\tconst mode = input instanceof Request ? input.mode : (init?.mode ?? 'cors');\n\t\t\tif (mode === 'no-cors') {\n\t\t\t\tresponse = new Response('', {\n\t\t\t\t\tstatus: response.status,\n\t\t\t\t\tstatusText: response.statusText,\n\t\t\t\t\theaders: response.headers\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst acao = response.headers.get('access-control-allow-origin');\n\t\t\t\tif (!acao || (acao !== event.url.origin && acao !== '*')) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`CORS error: ${\n\t\t\t\t\t\t\tacao ? 'Incorrect' : 'No'\n\t\t\t\t\t\t} 'Access-Control-Allow-Origin' header is present on the requested resource`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/** @type {ReadableStream<Uint8Array>} */\n\t\tlet teed_body;\n\n\t\tconst proxy = new Proxy(response, {\n\t\t\tget(response, key, receiver) {\n\t\t\t\t/**\n\t\t\t\t * @param {string | undefined} body\n\t\t\t\t * @param {boolean} is_b64\n\t\t\t\t */\n\t\t\t\tasync function push_fetched(body, is_b64) {\n\t\t\t\t\tconst status_number = Number(response.status);\n\t\t\t\t\tif (isNaN(status_number)) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`response.status is not a number. value: \"${\n\t\t\t\t\t\t\t\tresponse.status\n\t\t\t\t\t\t\t}\" type: ${typeof response.status}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tfetched.push({\n\t\t\t\t\t\turl: same_origin ? url.href.slice(event.url.origin.length) : url.href,\n\t\t\t\t\t\tmethod: event.request.method,\n\t\t\t\t\t\trequest_body: /** @type {string | ArrayBufferView | undefined} */ (\n\t\t\t\t\t\t\tinput instanceof Request && cloned_body\n\t\t\t\t\t\t\t\t? await stream_to_string(cloned_body)\n\t\t\t\t\t\t\t\t: init?.body\n\t\t\t\t\t\t),\n\t\t\t\t\t\trequest_headers: cloned_headers,\n\t\t\t\t\t\tresponse_body: body,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t\tis_b64\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (key === 'body') {\n\t\t\t\t\tif (response.body === null) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (teed_body) {\n\t\t\t\t\t\treturn teed_body;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst [a, b] = response.body.tee();\n\n\t\t\t\t\tvoid (async () => {\n\t\t\t\t\t\tlet result = new Uint8Array();\n\n\t\t\t\t\t\tfor await (const chunk of a) {\n\t\t\t\t\t\t\tconst combined = new Uint8Array(result.length + chunk.length);\n\n\t\t\t\t\t\t\tcombined.set(result, 0);\n\t\t\t\t\t\t\tcombined.set(chunk, result.length);\n\n\t\t\t\t\t\t\tresult = combined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (dependency) {\n\t\t\t\t\t\t\tdependency.body = new Uint8Array(result);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvoid push_fetched(base64_encode(result), true);\n\t\t\t\t\t})();\n\n\t\t\t\t\treturn (teed_body = b);\n\t\t\t\t}\n\n\t\t\t\tif (key === 'arrayBuffer') {\n\t\t\t\t\treturn async () => {\n\t\t\t\t\t\tconst buffer = await response.arrayBuffer();\n\n\t\t\t\t\t\tconst bytes = new Uint8Array(buffer);\n\n\t\t\t\t\t\tif (dependency) {\n\t\t\t\t\t\t\tdependency.body = bytes;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (buffer instanceof ArrayBuffer) {\n\t\t\t\t\t\t\tawait push_fetched(base64_encode(bytes), true);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn buffer;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tasync function text() {\n\t\t\t\t\tconst body = await response.text();\n\n\t\t\t\t\tif (body === '' && NULL_BODY_STATUS.includes(response.status)) {\n\t\t\t\t\t\tawait push_fetched(undefined, false);\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!body || typeof body === 'string') {\n\t\t\t\t\t\tawait push_fetched(body, false);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dependency) {\n\t\t\t\t\t\tdependency.body = body;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn body;\n\t\t\t\t}\n\n\t\t\t\tif (key === 'text') {\n\t\t\t\t\treturn text;\n\t\t\t\t}\n\n\t\t\t\tif (key === 'json') {\n\t\t\t\t\treturn async () => {\n\t\t\t\t\t\tconst body = await text();\n\t\t\t\t\t\treturn body ? JSON.parse(body) : undefined;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst value = Reflect.get(response, key, response);\n\n\t\t\t\tif (value instanceof Function) {\n\t\t\t\t\t// On Node v24+, the Response object has a private element #state – we\n\t\t\t\t\t// need to bind this function to the response in order to allow it to\n\t\t\t\t\t// access this private element. Defining the name and length ensure it\n\t\t\t\t\t// is identical to the original function when introspected.\n\t\t\t\t\treturn Object.defineProperties(\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * @this {any}\n\t\t\t\t\t\t */\n\t\t\t\t\t\tfunction () {\n\t\t\t\t\t\t\treturn Reflect.apply(value, this === receiver ? response : this, arguments);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: { value: value.name },\n\t\t\t\t\t\t\tlength: { value: value.length }\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn value;\n\t\t\t}\n\t\t});\n\n\t\tif (csr) {\n\t\t\t// ensure that excluded headers can't be read\n\t\t\tconst get = response.headers.get;\n\t\t\tresponse.headers.get = (key) => {\n\t\t\t\tconst lower = key.toLowerCase();\n\t\t\t\tconst value = get.call(response.headers, lower);\n\t\t\t\tif (value && !lower.startsWith('x-sveltekit-')) {\n\t\t\t\t\tconst included = resolve_opts.filterSerializedResponseHeaders(lower, value);\n\t\t\t\t\tif (!included) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Failed to get response header \"${lower}\" — it must be included by the \\`filterSerializedResponseHeaders\\` option: https://svelte.dev/docs/kit/hooks#Server-hooks-handle (at ${event.route.id})`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn value;\n\t\t\t};\n\t\t}\n\n\t\treturn proxy;\n\t};\n\n\t// Don't make this function `async`! Otherwise, the user has to `catch` promises they use for streaming responses or else\n\t// it will be an unhandled rejection. Instead, we add a `.catch(() => {})` ourselves below to this from happening.\n\treturn (input, init) => {\n\t\t// See docs in fetch.js for why we need to do this\n\t\tconst response = universal_fetch(input, init);\n\t\tresponse.catch(() => {});\n\t\treturn response;\n\t};\n}\n\n/**\n * @param {ReadableStream<Uint8Array>} stream\n */\nasync function stream_to_string(stream) {\n\tlet result = '';\n\tconst reader = stream.getReader();\n\twhile (true) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) {\n\t\t\tbreak;\n\t\t}\n\t\tresult += text_decoder.decode(value);\n\t}\n\treturn result;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/load_data.spec.js",
    "content": "import { assert, expect, test } from 'vitest';\nimport { create_universal_fetch } from './load_data.js';\n\n/**\n * @param {Partial<Pick<import('@sveltejs/kit').RequestEvent, 'fetch' | 'url' | 'request' | 'route'>>} event\n */\nfunction create_fetch(event) {\n\t// eslint-disable-next-line @typescript-eslint/require-await\n\tevent.fetch = event.fetch || (async () => new Response('foo'));\n\tevent.request = event.request || new Request('doesnt:matter');\n\tevent.route = event.route || { id: 'foo' };\n\tevent.url = event.url || new URL('https://domain-a.com');\n\treturn create_universal_fetch(\n\t\t/** @type {Pick<import('@sveltejs/kit').RequestEvent, 'fetch' | 'url' | 'request' | 'route'>} */ (\n\t\t\tevent\n\t\t),\n\t\t{ getClientAddress: () => '', error: false, depth: 0 },\n\t\t[],\n\t\ttrue,\n\t\t{\n\t\t\tfilterSerializedResponseHeaders: () => false\n\t\t}\n\t);\n}\n\ntest('sets body to empty when mode is no-cors', async () => {\n\tconst fetch = create_fetch({});\n\tconst response = await fetch('https://domain-b.com', { mode: 'no-cors' });\n\tconst text = await response.text();\n\tassert.equal(text, '');\n});\n\ntest(\"keeps body when mode isn't no-cors on same domain\", async () => {\n\tconst fetch = create_fetch({});\n\tconst response = await fetch('https://domain-a.com');\n\tconst text = await response.text();\n\tassert.equal(text, 'foo');\n});\n\ntest('succeeds when acao header present on cors', async () => {\n\tconst fetch = create_fetch({\n\t\t// eslint-disable-next-line @typescript-eslint/require-await\n\t\tfetch: async () => new Response('foo', { headers: { 'access-control-allow-origin': '*' } })\n\t});\n\tconst response = await fetch('https://domain-a.com');\n\tconst text = await response.text();\n\tassert.equal(text, 'foo');\n});\n\ntest('errors when no acao header present on cors', async () => {\n\tconst fetch = create_fetch({});\n\n\tawait expect(async () => {\n\t\tconst response = await fetch('https://domain-b.com');\n\t\tawait response.text();\n\t}).rejects.toThrowError(\n\t\t\"CORS error: No 'Access-Control-Allow-Origin' header is present on the requested resource\"\n\t);\n});\n\ntest('succeeds when fetching from local scheme', async () => {\n\tconst fetch = create_fetch({});\n\tconst response = await fetch('data:text/plain;foo');\n\tconst text = await response.text();\n\tassert.equal(text, 'foo');\n});\n\ntest('errors when trying to access non-serialized request headers on the server', async () => {\n\tconst fetch = create_fetch({});\n\tconst response = await fetch('https://domain-a.com');\n\tassert.throws(\n\t\t() => response.headers.get('content-type'),\n\t\t/Failed to get response header \"content-type\" — it must be included by the `filterSerializedResponseHeaders` option/\n\t);\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/render.js",
    "content": "import * as devalue from 'devalue';\nimport { readable, writable } from 'svelte/store';\nimport { DEV } from 'esm-env';\nimport { isRedirect, text } from '@sveltejs/kit';\nimport * as paths from '$app/paths/internal/server';\nimport { hash } from '../../../utils/hash.js';\nimport { serialize_data } from './serialize_data.js';\nimport { s } from '../../../utils/misc.js';\nimport { Csp } from './csp.js';\nimport { uneval_action_response } from './actions.js';\nimport { public_env } from '../../shared-server.js';\nimport { SVELTE_KIT_ASSETS } from '../../../constants.js';\nimport { SCHEME } from '../../../utils/url.js';\nimport { create_server_routing_response, generate_route_object } from './server_routing.js';\nimport { add_resolution_suffix } from '../../pathname.js';\nimport { try_get_request_store, with_request_store } from '@sveltejs/kit/internal/server';\nimport { text_encoder } from '../../utils.js';\nimport { get_global_name, handle_error_and_jsonify } from '../utils.js';\nimport { create_remote_key } from '../../shared.js';\nimport { get_status } from '../../../utils/error.js';\n\n// TODO rename this function/module\n\nconst updated = {\n\t...readable(false),\n\tcheck: () => false\n};\n\n/**\n * Creates the HTML response.\n * @param {{\n *   branch: Array<import('./types.js').Loaded>;\n *   fetched: Array<import('./types.js').Fetched>;\n *   options: import('types').SSROptions;\n *   manifest: import('@sveltejs/kit').SSRManifest;\n *   state: import('types').SSRState;\n *   page_config: { ssr: boolean; csr: boolean };\n *   status: number;\n *   error: App.Error | null;\n *   event: import('@sveltejs/kit').RequestEvent;\n *   event_state: import('types').RequestState;\n *   resolve_opts: import('types').RequiredResolveOptions;\n *   action_result?: import('@sveltejs/kit').ActionResult;\n *   data_serializer: import('./types.js').ServerDataSerializer;\n *   error_components?: Array<import('types').SSRComponent | undefined>\n * }} opts\n */\nexport async function render_response({\n\tbranch,\n\tfetched,\n\toptions,\n\tmanifest,\n\tstate,\n\tpage_config,\n\tstatus,\n\terror = null,\n\tevent,\n\tevent_state,\n\tresolve_opts,\n\taction_result,\n\tdata_serializer,\n\terror_components\n}) {\n\tif (state.prerendering) {\n\t\tif (options.csp.mode === 'nonce') {\n\t\t\tthrow new Error('Cannot use prerendering if config.kit.csp.mode === \"nonce\"');\n\t\t}\n\n\t\tif (options.app_template_contains_nonce) {\n\t\t\tthrow new Error('Cannot use prerendering if page template contains %sveltekit.nonce%');\n\t\t}\n\t}\n\n\tconst { client } = manifest._;\n\n\tconst modulepreloads = new Set(client.imports);\n\tconst stylesheets = new Set(client.stylesheets);\n\tconst fonts = new Set(client.fonts);\n\n\t/**\n\t * The value of the Link header that is added to the response when not prerendering\n\t * @type {Set<string>}\n\t */\n\tconst link_headers = new Set();\n\n\t/** @type {Map<string, string>} */\n\t// TODO if we add a client entry point one day, we will need to include inline_styles with the entry, otherwise stylesheets will be linked even if they are below inlineStyleThreshold\n\tconst inline_styles = new Map();\n\n\t/** @type {ReturnType<typeof options.root.render>} */\n\tlet rendered;\n\n\tconst form_value =\n\t\taction_result?.type === 'success' || action_result?.type === 'failure'\n\t\t\t? (action_result.data ?? null)\n\t\t\t: null;\n\n\t/** @type {string} */\n\tlet base = paths.base;\n\n\t/** @type {string} */\n\tlet assets = paths.assets;\n\n\t/**\n\t * An expression that will evaluate in the client to determine the resolved base path.\n\t * We use a relative path when possible to support IPFS, the internet archive, etc.\n\t */\n\tlet base_expression = s(paths.base);\n\n\tconst csp = new Csp(options.csp, {\n\t\tprerender: !!state.prerendering\n\t});\n\n\t// if appropriate, use relative paths for greater portability\n\tif (paths.relative) {\n\t\tif (!state.prerendering?.fallback) {\n\t\t\tconst segments = event.url.pathname.slice(paths.base.length).split('/').slice(2);\n\n\t\t\tbase = segments.map(() => '..').join('/') || '.';\n\n\t\t\t// resolve e.g. '../..' against current location, then remove trailing slash\n\t\t\tbase_expression = `new URL(${s(base)}, location).pathname.slice(0, -1)`;\n\n\t\t\tif (!paths.assets || (paths.assets[0] === '/' && paths.assets !== SVELTE_KIT_ASSETS)) {\n\t\t\t\tassets = base;\n\t\t\t}\n\t\t} else if (options.hash_routing) {\n\t\t\t// we have to assume that we're in the right place\n\t\t\tbase_expression = \"new URL('.', location).pathname.slice(0, -1)\";\n\t\t}\n\t}\n\n\tif (page_config.ssr) {\n\t\t/** @type {Record<string, any>} */\n\t\tconst props = {\n\t\t\tstores: {\n\t\t\t\tpage: writable(null),\n\t\t\t\tnavigating: writable(null),\n\t\t\t\tupdated\n\t\t\t},\n\t\t\tconstructors: await Promise.all(\n\t\t\t\tbranch.map(({ node }) => {\n\t\t\t\t\tif (!node.component) {\n\t\t\t\t\t\t// Can only be the leaf, layouts have a fallback component generated\n\t\t\t\t\t\tthrow new Error(`Missing +page.svelte component for route ${event.route.id}`);\n\t\t\t\t\t}\n\t\t\t\t\treturn node.component();\n\t\t\t\t})\n\t\t\t),\n\t\t\tform: form_value\n\t\t};\n\n\t\tif (error_components) {\n\t\t\tif (error) {\n\t\t\t\tprops.error = error;\n\t\t\t}\n\t\t\tprops.errors = error_components;\n\t\t}\n\n\t\tlet data = {};\n\n\t\t// props_n (instead of props[n]) makes it easy to avoid\n\t\t// unnecessary updates for layout components\n\t\tfor (let i = 0; i < branch.length; i += 1) {\n\t\t\tdata = { ...data, ...branch[i].data };\n\t\t\tprops[`data_${i}`] = data;\n\t\t}\n\n\t\tprops.page = {\n\t\t\terror,\n\t\t\tparams: /** @type {Record<string, any>} */ (event.params),\n\t\t\troute: event.route,\n\t\t\tstatus,\n\t\t\turl: event.url,\n\t\t\tdata,\n\t\t\tform: form_value,\n\t\t\tstate: {}\n\t\t};\n\n\t\tconst render_opts = {\n\t\t\tcontext: new Map([\n\t\t\t\t[\n\t\t\t\t\t'__request__',\n\t\t\t\t\t{\n\t\t\t\t\t\tpage: props.page\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t]),\n\t\t\tcsp: csp.script_needs_nonce ? { nonce: csp.nonce } : { hash: csp.script_needs_hash },\n\t\t\ttransformError: error_components\n\t\t\t\t? /** @param {unknown} e */ async (e) => {\n\t\t\t\t\t\tif (isRedirect(e)) {\n\t\t\t\t\t\t\tthrow e;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst transformed = await handle_error_and_jsonify(event, event_state, options, e);\n\t\t\t\t\t\tprops.page.error = props.error = error = transformed;\n\t\t\t\t\t\tprops.page.status = status = get_status(e);\n\t\t\t\t\t\treturn transformed;\n\t\t\t\t\t}\n\t\t\t\t: undefined\n\t\t};\n\n\t\tconst fetch = globalThis.fetch;\n\n\t\ttry {\n\t\t\tif (DEV) {\n\t\t\t\tlet warned = false;\n\t\t\t\tglobalThis.fetch = (info, init) => {\n\t\t\t\t\tif (typeof info === 'string' && !SCHEME.test(info)) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Cannot call \\`fetch\\` eagerly during server-side rendering with relative URL (${info}) — put your \\`fetch\\` calls inside \\`onMount\\` or a \\`load\\` function instead`\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (!warned && !try_get_request_store()?.state.is_in_remote_function) {\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t'Avoid calling `fetch` eagerly during server-side rendering — put your `fetch` calls inside `onMount` or a `load` function instead'\n\t\t\t\t\t\t);\n\t\t\t\t\t\twarned = true;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn fetch(info, init);\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst state = { ...event_state, is_in_render: true };\n\n\t\t\trendered = await with_request_store({ event, state }, async () => {\n\t\t\t\t// use relative paths during rendering, so that the resulting HTML is as\n\t\t\t\t// portable as possible, but reset afterwards\n\t\t\t\tif (paths.relative) paths.override({ base, assets });\n\n\t\t\t\tconst maybe_promise = options.root.render(props, render_opts);\n\t\t\t\t// We have to invoke .then eagerly here in order to kick off rendering: it's only starting on access,\n\t\t\t\t// and `await maybe_promise` would eagerly access the .then property but call its function only after a tick, which is too late\n\t\t\t\t// for the paths.reset() below and for any eager getRequestEvent() calls during rendering without AsyncLocalStorage available.\n\t\t\t\tconst rendered =\n\t\t\t\t\toptions.async && 'then' in maybe_promise\n\t\t\t\t\t\t? /** @type {ReturnType<typeof options.root.render> & Promise<any>} */ (\n\t\t\t\t\t\t\t\tmaybe_promise\n\t\t\t\t\t\t\t).then((r) => r)\n\t\t\t\t\t\t: maybe_promise;\n\n\t\t\t\t// TODO 3.0 remove options.async\n\t\t\t\tif (options.async) {\n\t\t\t\t\t// we reset this synchronously, rather than after async rendering is complete,\n\t\t\t\t\t// to avoid cross-talk between requests. This is a breaking change for\n\t\t\t\t\t// anyone who opts into async SSR, since `base` and `assets` will no\n\t\t\t\t\t// longer be relative to the current pathname.\n\t\t\t\t\t// TODO 3.0 remove `base` and `assets` in favour of `resolve(...)` and `asset(...)`\n\t\t\t\t\tpaths.reset();\n\t\t\t\t}\n\n\t\t\t\tconst { head, html, css, hashes } = /** @type {ReturnType<typeof options.root.render>} */ (\n\t\t\t\t\toptions.async ? await rendered : rendered\n\t\t\t\t);\n\n\t\t\t\tif (hashes) {\n\t\t\t\t\tcsp.add_script_hashes(hashes.script);\n\t\t\t\t}\n\n\t\t\t\treturn { head, html, css, hashes };\n\t\t\t});\n\t\t} finally {\n\t\t\tif (DEV) {\n\t\t\t\tglobalThis.fetch = fetch;\n\t\t\t}\n\n\t\t\tpaths.reset(); // just in case `options.root.render(...)` failed\n\t\t}\n\n\t\tfor (const { node } of branch) {\n\t\t\tfor (const url of node.imports) modulepreloads.add(url);\n\t\t\tfor (const url of node.stylesheets) stylesheets.add(url);\n\t\t\tfor (const url of node.fonts) fonts.add(url);\n\n\t\t\tif (node.inline_styles && !client.inline) {\n\t\t\t\tObject.entries(await node.inline_styles()).forEach(([filename, css]) => {\n\t\t\t\t\tif (typeof css === 'string') {\n\t\t\t\t\t\tinline_styles.set(filename, css);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tinline_styles.set(filename, css(`${assets}/${paths.app_dir}/immutable/assets`, assets));\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t} else {\n\t\trendered = { head: '', html: '', css: { code: '', map: null }, hashes: { script: [] } };\n\t}\n\n\tconst head = new Head(rendered.head, !!state.prerendering);\n\tlet body = rendered.html;\n\n\t/** @param {string} path */\n\tconst prefixed = (path) => {\n\t\tif (path.startsWith('/')) {\n\t\t\t// Vite makes the start script available through the base path and without it.\n\t\t\t// We load it via the base path in order to support remote IDE environments which proxy\n\t\t\t// all URLs under the base path during development.\n\t\t\treturn paths.base + path;\n\t\t}\n\t\treturn `${assets}/${path}`;\n\t};\n\n\t// inline styles can come from `bundleStrategy: 'inline'` or `inlineStyleThreshold`\n\tconst style = client.inline\n\t\t? client.inline?.style\n\t\t: Array.from(inline_styles.values()).join('\\n');\n\n\tif (style) {\n\t\tconst attributes = DEV ? ['data-sveltekit'] : [];\n\t\tif (csp.style_needs_nonce) attributes.push(`nonce=\"${csp.nonce}\"`);\n\t\tcsp.add_style(style);\n\t\thead.add_style(style, attributes);\n\t}\n\n\tfor (const dep of stylesheets) {\n\t\tconst path = prefixed(dep);\n\n\t\tconst attributes = ['rel=\"stylesheet\"'];\n\n\t\tif (inline_styles.has(dep)) {\n\t\t\t// don't load stylesheets that are already inlined\n\t\t\t// include them in disabled state so that Vite can detect them and doesn't try to add them\n\t\t\tattributes.push('disabled', 'media=\"(max-width: 0)\"');\n\t\t} else {\n\t\t\tif (resolve_opts.preload({ type: 'css', path })) {\n\t\t\t\tlink_headers.add(`<${encodeURI(path)}>; rel=\"preload\"; as=\"style\"; nopush`);\n\t\t\t}\n\t\t}\n\n\t\thead.add_stylesheet(path, attributes);\n\t}\n\n\tfor (const dep of fonts) {\n\t\tconst path = prefixed(dep);\n\n\t\tif (resolve_opts.preload({ type: 'font', path })) {\n\t\t\tconst ext = dep.slice(dep.lastIndexOf('.') + 1);\n\n\t\t\thead.add_link_tag(path, ['rel=\"preload\"', 'as=\"font\"', `type=\"font/${ext}\"`, 'crossorigin']);\n\n\t\t\tlink_headers.add(\n\t\t\t\t`<${encodeURI(path)}>; rel=\"preload\"; as=\"font\"; type=\"font/${ext}\"; crossorigin; nopush`\n\t\t\t);\n\t\t}\n\t}\n\n\tconst global = get_global_name(options);\n\tconst { data, chunks } = data_serializer.get_data(csp);\n\n\tif (page_config.ssr && page_config.csr) {\n\t\tbody += `\\n\\t\\t\\t${fetched\n\t\t\t.map((item) =>\n\t\t\t\tserialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!state.prerendering)\n\t\t\t)\n\t\t\t.join('\\n\\t\\t\\t')}`;\n\t}\n\n\tif (page_config.csr) {\n\t\tconst route = manifest._.client.routes?.find((r) => r.id === event.route.id) ?? null;\n\n\t\tif (client.uses_env_dynamic_public && state.prerendering) {\n\t\t\tmodulepreloads.add(`${paths.app_dir}/env.js`);\n\t\t}\n\n\t\tif (!client.inline) {\n\t\t\tconst included_modulepreloads = Array.from(modulepreloads, (dep) => prefixed(dep)).filter(\n\t\t\t\t(path) => resolve_opts.preload({ type: 'js', path })\n\t\t\t);\n\n\t\t\tfor (const path of included_modulepreloads) {\n\t\t\t\t// see the kit.output.preloadStrategy option for details on why we have multiple options here\n\t\t\t\tlink_headers.add(`<${encodeURI(path)}>; rel=\"modulepreload\"; nopush`);\n\n\t\t\t\tif (options.preload_strategy !== 'modulepreload') {\n\t\t\t\t\thead.add_script_preload(path);\n\t\t\t\t} else {\n\t\t\t\t\thead.add_link_tag(path, ['rel=\"modulepreload\"']);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// prerender a `/path/to/page/__route.js` module\n\t\tif (manifest._.client.routes && state.prerendering && !state.prerendering.fallback) {\n\t\t\tconst pathname = add_resolution_suffix(event.url.pathname);\n\n\t\t\tstate.prerendering.dependencies.set(\n\t\t\t\tpathname,\n\t\t\t\tcreate_server_routing_response(route, event.params, new URL(pathname, event.url), manifest)\n\t\t\t);\n\t\t}\n\n\t\tconst blocks = [];\n\n\t\t// when serving a prerendered page in an app that uses $env/dynamic/public, we must\n\t\t// import the env.js module so that it evaluates before any user code can evaluate.\n\t\t// TODO revert to using top-level await once https://bugs.webkit.org/show_bug.cgi?id=242740 is fixed\n\t\t// https://github.com/sveltejs/kit/pull/11601\n\t\tconst load_env_eagerly = client.uses_env_dynamic_public && state.prerendering;\n\n\t\tconst properties = [`base: ${base_expression}`];\n\n\t\tif (paths.assets) {\n\t\t\tproperties.push(`assets: ${s(paths.assets)}`);\n\t\t}\n\n\t\tif (client.uses_env_dynamic_public) {\n\t\t\tproperties.push(`env: ${load_env_eagerly ? 'null' : s(public_env)}`);\n\t\t}\n\n\t\tif (chunks) {\n\t\t\tblocks.push('const deferred = new Map();');\n\n\t\t\tproperties.push(`defer: (id) => new Promise((fulfil, reject) => {\n\t\t\t\t\t\t\tdeferred.set(id, { fulfil, reject });\n\t\t\t\t\t\t})`);\n\n\t\t\tlet app_declaration = '';\n\n\t\t\tif (Object.keys(options.hooks.transport).length > 0) {\n\t\t\t\tif (client.inline) {\n\t\t\t\t\tapp_declaration = `const app = __sveltekit_${options.version_hash}.app.app;`;\n\t\t\t\t} else if (client.app) {\n\t\t\t\t\tapp_declaration = `const app = await import(${s(prefixed(client.app))});`;\n\t\t\t\t} else {\n\t\t\t\t\tapp_declaration = `const { app } = await import(${s(prefixed(client.start))});`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst prelude = app_declaration\n\t\t\t\t? `${app_declaration}\n\t\t\t\t\t\t\tconst [data, error] = fn(app);`\n\t\t\t\t: `const [data, error] = fn();`;\n\n\t\t\t// When resolving, the id might not yet be available due to the data\n\t\t\t// be evaluated upon init of kit, so we use a timeout to retry\n\t\t\tproperties.push(`resolve: async (id, fn) => {\n\t\t\t\t\t\t\t${prelude}\n\n\t\t\t\t\t\t\tconst try_to_resolve = () => {\n\t\t\t\t\t\t\t\tif (!deferred.has(id)) {\n\t\t\t\t\t\t\t\t\tsetTimeout(try_to_resolve, 0);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst { fulfil, reject } = deferred.get(id);\n\t\t\t\t\t\t\t\tdeferred.delete(id);\n\t\t\t\t\t\t\t\tif (error) reject(error);\n\t\t\t\t\t\t\t\telse fulfil(data);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttry_to_resolve();\n\t\t\t\t\t\t}`);\n\t\t}\n\n\t\t// create this before declaring `data`, which may contain references to `${global}`\n\t\tblocks.push(`${global} = {\n\t\t\t\t\t\t${properties.join(',\\n\\t\\t\\t\\t\\t\\t')}\n\t\t\t\t\t};`);\n\n\t\tconst args = ['element'];\n\n\t\tblocks.push('const element = document.currentScript.parentElement;');\n\n\t\tif (page_config.ssr) {\n\t\t\tconst serialized = { form: 'null', error: 'null' };\n\n\t\t\tif (form_value) {\n\t\t\t\tserialized.form = uneval_action_response(\n\t\t\t\t\tform_value,\n\t\t\t\t\t/** @type {string} */ (event.route.id),\n\t\t\t\t\toptions.hooks.transport\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (error) {\n\t\t\t\tserialized.error = devalue.uneval(error);\n\t\t\t}\n\n\t\t\tconst hydrate = [\n\t\t\t\t`node_ids: [${branch.map(({ node }) => node.index).join(', ')}]`,\n\t\t\t\t`data: ${data}`,\n\t\t\t\t`form: ${serialized.form}`,\n\t\t\t\t`error: ${serialized.error}`\n\t\t\t];\n\n\t\t\tif (status !== 200) {\n\t\t\t\thydrate.push(`status: ${status}`);\n\t\t\t}\n\n\t\t\tif (manifest._.client.routes) {\n\t\t\t\tif (route) {\n\t\t\t\t\tconst stringified = generate_route_object(route, event.url, manifest).replaceAll(\n\t\t\t\t\t\t'\\n',\n\t\t\t\t\t\t'\\n\\t\\t\\t\\t\\t\\t\\t'\n\t\t\t\t\t); // make output after it's put together with the rest more readable\n\t\t\t\t\thydrate.push(`params: ${devalue.uneval(event.params)}`, `server_route: ${stringified}`);\n\t\t\t\t}\n\t\t\t} else if (options.embedded) {\n\t\t\t\thydrate.push(`params: ${devalue.uneval(event.params)}`, `route: ${s(event.route)}`);\n\t\t\t}\n\n\t\t\tconst indent = '\\t'.repeat(load_env_eagerly ? 7 : 6);\n\t\t\targs.push(`{\\n${indent}\\t${hydrate.join(`,\\n${indent}\\t`)}\\n${indent}}`);\n\t\t}\n\n\t\tconst { remote } = event_state;\n\n\t\tlet serialized_query_data = '';\n\t\tlet serialized_prerender_data = '';\n\n\t\tif (remote.data) {\n\t\t\t/** @type {Record<string, any>} */\n\t\t\tconst query = {};\n\n\t\t\t/** @type {Record<string, any>} */\n\t\t\tconst prerender = {};\n\n\t\t\tfor (const [internals, cache] of remote.data) {\n\t\t\t\t// remote functions without an `id` aren't exported, and thus\n\t\t\t\t// cannot be called from the client\n\t\t\t\tif (!internals.id) continue;\n\n\t\t\t\tfor (const key in cache) {\n\t\t\t\t\tconst entry = cache[key];\n\n\t\t\t\t\tif (!entry.serialize) continue;\n\n\t\t\t\t\tconst remote_key = create_remote_key(internals.id, key);\n\n\t\t\t\t\tconst store = internals.type === 'prerender' ? prerender : query;\n\n\t\t\t\t\tif (event_state.remote.refreshes?.[remote_key] !== undefined) {\n\t\t\t\t\t\t// This entry was refreshed/set by a command or form action.\n\t\t\t\t\t\t// Always await it so the mutation result is serialized.\n\t\t\t\t\t\tstore[remote_key] = await entry.data;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Don't block the response on pending remote data - if a query\n\t\t\t\t\t\t// hasn't settled yet, it wasn't awaited in the template (or is behind a pending boundary).\n\t\t\t\t\t\tconst result = await Promise.race([\n\t\t\t\t\t\t\tPromise.resolve(entry.data).then(\n\t\t\t\t\t\t\t\t(v) => /** @type {const} */ ({ settled: true, value: v }),\n\t\t\t\t\t\t\t\t(e) => /** @type {const} */ ({ settled: true, error: e })\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tnew Promise((resolve) => {\n\t\t\t\t\t\t\t\tqueueMicrotask(() => resolve(/** @type {const} */ ({ settled: false })));\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tif (result.settled) {\n\t\t\t\t\t\t\tif ('error' in result) throw result.error;\n\t\t\t\t\t\t\tstore[remote_key] = result.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// TODO this is repeated in a few places — dedupe it\n\t\t\tconst replacer = (/** @type {any} */ thing) => {\n\t\t\t\tfor (const key in options.hooks.transport) {\n\t\t\t\t\tconst encoded = options.hooks.transport[key].encode(thing);\n\t\t\t\t\tif (encoded) {\n\t\t\t\t\t\treturn `app.decode('${key}', ${devalue.uneval(encoded, replacer)})`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (Object.keys(query).length > 0) {\n\t\t\t\tserialized_query_data = `${global}.query = ${devalue.uneval(query, replacer)};\\n\\n\\t\\t\\t\\t\\t\\t`;\n\t\t\t}\n\n\t\t\tif (Object.keys(prerender).length > 0) {\n\t\t\t\tserialized_prerender_data = `${global}.prerender = ${devalue.uneval(prerender, replacer)};\\n\\n\\t\\t\\t\\t\\t\\t`;\n\t\t\t}\n\t\t}\n\n\t\tconst serialized_remote_data = `${serialized_query_data}${serialized_prerender_data}`;\n\n\t\t// `client.app` is a proxy for `bundleStrategy === 'split'`\n\t\tconst boot = client.inline\n\t\t\t? `${client.inline.script}\n\n\t\t\t\t\t${serialized_remote_data}${global}.app.start(${args.join(', ')});`\n\t\t\t: client.app\n\t\t\t\t? `Promise.all([\n\t\t\t\t\t\timport(${s(prefixed(client.start))}),\n\t\t\t\t\t\timport(${s(prefixed(client.app))})\n\t\t\t\t\t]).then(([kit, app]) => {\n\t\t\t\t\t\t${serialized_remote_data}kit.start(app, ${args.join(', ')});\n\t\t\t\t\t});`\n\t\t\t\t: `import(${s(prefixed(client.start))}).then((app) => {\n\t\t\t\t\t\t${serialized_remote_data}app.start(${args.join(', ')})\n\t\t\t\t\t});`;\n\n\t\tif (load_env_eagerly) {\n\t\t\tblocks.push(`import(${s(`${base}/${paths.app_dir}/env.js`)}).then(({ env }) => {\n\t\t\t\t\t\t${global}.env = env;\n\n\t\t\t\t\t\t${boot.replace(/\\n/g, '\\n\\t')}\n\t\t\t\t\t});`);\n\t\t} else {\n\t\t\tblocks.push(boot);\n\t\t}\n\n\t\tif (options.service_worker) {\n\t\t\tlet opts = DEV ? \", { type: 'module' }\" : '';\n\t\t\tif (options.service_worker_options != null) {\n\t\t\t\tconst service_worker_options = { ...options.service_worker_options };\n\t\t\t\tif (DEV) {\n\t\t\t\t\tservice_worker_options.type = 'module';\n\t\t\t\t}\n\t\t\t\topts = `, ${s(service_worker_options)}`;\n\t\t\t}\n\n\t\t\t// we use an anonymous function instead of an arrow function to support\n\t\t\t// older browsers (https://github.com/sveltejs/kit/pull/5417)\n\t\t\tblocks.push(`if ('serviceWorker' in navigator) {\n\t\t\t\t\t\taddEventListener('load', function () {\n\t\t\t\t\t\t\tnavigator.serviceWorker.register('${prefixed('service-worker.js')}'${opts});\n\t\t\t\t\t\t});\n\t\t\t\t\t}`);\n\t\t}\n\n\t\tconst init_app = `\n\t\t\t\t{\n\t\t\t\t\t${blocks.join('\\n\\n\\t\\t\\t\\t\\t')}\n\t\t\t\t}\n\t\t\t`;\n\t\tcsp.add_script(init_app);\n\n\t\tbody += `\\n\\t\\t\\t<script${\n\t\t\tcsp.script_needs_nonce ? ` nonce=\"${csp.nonce}\"` : ''\n\t\t}>${init_app}</script>\\n\\t\\t`;\n\t}\n\n\tconst headers = new Headers({\n\t\t'x-sveltekit-page': 'true',\n\t\t'content-type': 'text/html'\n\t});\n\n\tif (state.prerendering) {\n\t\t// TODO read headers set with setHeaders and convert into http-equiv where possible\n\t\tconst csp_headers = csp.csp_provider.get_meta();\n\t\tif (csp_headers) {\n\t\t\thead.add_http_equiv(csp_headers);\n\t\t}\n\n\t\tif (state.prerendering.cache) {\n\t\t\thead.add_http_equiv(\n\t\t\t\t`<meta http-equiv=\"cache-control\" content=\"${state.prerendering.cache}\">`\n\t\t\t);\n\t\t}\n\t} else {\n\t\tconst csp_header = csp.csp_provider.get_header();\n\t\tif (csp_header) {\n\t\t\theaders.set('content-security-policy', csp_header);\n\t\t}\n\t\tconst report_only_header = csp.report_only_provider.get_header();\n\t\tif (report_only_header) {\n\t\t\theaders.set('content-security-policy-report-only', report_only_header);\n\t\t}\n\n\t\tif (link_headers.size) {\n\t\t\theaders.set('link', Array.from(link_headers).join(', '));\n\t\t}\n\t}\n\n\tconst html = options.templates.app({\n\t\thead: head.build(),\n\t\tbody,\n\t\tassets,\n\t\tnonce: /** @type {string} */ (csp.nonce),\n\t\tenv: public_env\n\t});\n\n\t// TODO flush chunks as early as we can\n\tconst transformed =\n\t\t(await resolve_opts.transformPageChunk({\n\t\t\thtml,\n\t\t\tdone: true\n\t\t})) || '';\n\n\tif (!chunks) {\n\t\theaders.set('etag', `\"${hash(transformed)}\"`);\n\t}\n\n\tif (DEV) {\n\t\tif (page_config.csr) {\n\t\t\tif (transformed.split('<!--').length < html.split('<!--').length) {\n\t\t\t\t// the \\u001B stuff is ANSI codes, so that we don't need to add a library to the runtime\n\t\t\t\t// https://svelte.dev/playground/1b3f49696f0c44c881c34587f2537aa2?version=4.2.19\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"\\u001B[1m\\u001B[31mRemoving comments in transformPageChunk can break Svelte's hydration\\u001B[39m\\u001B[22m\"\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tif (chunks) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'\\u001B[1m\\u001B[31mReturning promises from server `load` functions will only work if `csr === true`\\u001B[39m\\u001B[22m'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn !chunks\n\t\t? text(transformed, {\n\t\t\t\tstatus,\n\t\t\t\theaders\n\t\t\t})\n\t\t: new Response(\n\t\t\t\tnew ReadableStream({\n\t\t\t\t\tasync start(controller) {\n\t\t\t\t\t\tcontroller.enqueue(text_encoder.encode(transformed + '\\n'));\n\t\t\t\t\t\tfor await (const chunk of chunks) {\n\t\t\t\t\t\t\tif (chunk.length) controller.enqueue(text_encoder.encode(chunk));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t},\n\n\t\t\t\t\ttype: 'bytes'\n\t\t\t\t}),\n\t\t\t\t{\n\t\t\t\t\theaders\n\t\t\t\t}\n\t\t\t);\n}\n\nclass Head {\n\t#rendered;\n\t#prerendering;\n\t/** @type {string[]} */\n\t#http_equiv = [];\n\t/** @type {string[]} */\n\t#link_tags = [];\n\t/** @type {string[]} */\n\t#script_preloads = [];\n\t/** @type {string[]} */\n\t#style_tags = [];\n\t/** @type {string[]} */\n\t#stylesheet_links = [];\n\n\t/**\n\t * @param {string} rendered\n\t * @param {boolean} prerendering\n\t */\n\tconstructor(rendered, prerendering) {\n\t\tthis.#rendered = rendered;\n\t\tthis.#prerendering = prerendering;\n\t}\n\n\tbuild() {\n\t\treturn [\n\t\t\t...this.#http_equiv,\n\t\t\t...this.#link_tags,\n\t\t\t...this.#script_preloads,\n\t\t\tthis.#rendered,\n\t\t\t...this.#style_tags,\n\t\t\t...this.#stylesheet_links\n\t\t].join('\\n\\t\\t');\n\t}\n\n\t/**\n\t * @param {string} style\n\t * @param {string[]} attributes\n\t */\n\tadd_style(style, attributes) {\n\t\tthis.#style_tags.push(\n\t\t\t`<style${attributes.length ? ' ' + attributes.join(' ') : ''}>${style}</style>`\n\t\t);\n\t}\n\n\t/**\n\t * @param {string} href\n\t * @param {string[]} attributes\n\t */\n\tadd_stylesheet(href, attributes) {\n\t\tthis.#stylesheet_links.push(`<link href=\"${href}\" ${attributes.join(' ')}>`);\n\t}\n\n\t/** @param {string} href */\n\tadd_script_preload(href) {\n\t\tthis.#script_preloads.push(\n\t\t\t`<link rel=\"preload\" as=\"script\" crossorigin=\"anonymous\" href=\"${href}\">`\n\t\t);\n\t}\n\n\t/**\n\t * @param {string} href\n\t * @param {string[]} attributes\n\t */\n\tadd_link_tag(href, attributes) {\n\t\tif (!this.#prerendering) return;\n\t\tthis.#link_tags.push(`<link href=\"${href}\" ${attributes.join(' ')}>`);\n\t}\n\n\t/** @param {string} tag */\n\tadd_http_equiv(tag) {\n\t\tif (!this.#prerendering) return;\n\t\tthis.#http_equiv.push(tag);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/respond_with_error.js",
    "content": "import { Redirect } from '@sveltejs/kit/internal';\nimport { render_response } from './render.js';\nimport { load_data, load_server_data } from './load_data.js';\nimport { handle_error_and_jsonify, static_error_page, redirect_response } from '../utils.js';\nimport { get_status } from '../../../utils/error.js';\nimport { PageNodes } from '../../../utils/page_nodes.js';\nimport { server_data_serializer } from './data_serializer.js';\n\n/**\n * @typedef {import('./types.js').Loaded} Loaded\n */\n\n/**\n * @param {{\n *   event: import('@sveltejs/kit').RequestEvent;\n *   event_state: import('types').RequestState;\n *   options: import('types').SSROptions;\n *   manifest: import('@sveltejs/kit').SSRManifest;\n *   state: import('types').SSRState;\n *   status: number;\n *   error: unknown;\n *   resolve_opts: import('types').RequiredResolveOptions;\n * }} opts\n */\nexport async function respond_with_error({\n\tevent,\n\tevent_state,\n\toptions,\n\tmanifest,\n\tstate,\n\tstatus,\n\terror,\n\tresolve_opts\n}) {\n\t// reroute to the fallback page to prevent an infinite chain of requests.\n\tif (event.request.headers.get('x-sveltekit-error')) {\n\t\treturn static_error_page(options, status, /** @type {Error} */ (error).message);\n\t}\n\n\t/** @type {import('./types.js').Fetched[]} */\n\tconst fetched = [];\n\n\ttry {\n\t\tconst branch = [];\n\t\tconst default_layout = await manifest._.nodes[0](); // 0 is always the root layout\n\t\tconst nodes = new PageNodes([default_layout]);\n\t\tconst ssr = nodes.ssr();\n\t\tconst csr = nodes.csr();\n\t\tconst data_serializer = server_data_serializer(event, event_state, options);\n\n\t\tif (ssr) {\n\t\t\tstate.error = true;\n\n\t\t\tconst server_data_promise = load_server_data({\n\t\t\t\tevent,\n\t\t\t\tevent_state,\n\t\t\t\tstate,\n\t\t\t\tnode: default_layout,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/require-await\n\t\t\t\tparent: async () => ({})\n\t\t\t});\n\n\t\t\tconst server_data = await server_data_promise;\n\t\t\tdata_serializer.add_node(0, server_data);\n\n\t\t\tconst data = await load_data({\n\t\t\t\tevent,\n\t\t\t\tevent_state,\n\t\t\t\tfetched,\n\t\t\t\tnode: default_layout,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/require-await\n\t\t\t\tparent: async () => ({}),\n\t\t\t\tresolve_opts,\n\t\t\t\tserver_data_promise,\n\t\t\t\tstate,\n\t\t\t\tcsr\n\t\t\t});\n\n\t\t\tbranch.push(\n\t\t\t\t{\n\t\t\t\t\tnode: default_layout,\n\t\t\t\t\tserver_data,\n\t\t\t\t\tdata\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tnode: await manifest._.nodes[1](), // 1 is always the root error\n\t\t\t\t\tdata: null,\n\t\t\t\t\tserver_data: null\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn await render_response({\n\t\t\toptions,\n\t\t\tmanifest,\n\t\t\tstate,\n\t\t\tpage_config: {\n\t\t\t\tssr,\n\t\t\t\tcsr\n\t\t\t},\n\t\t\tstatus,\n\t\t\terror: await handle_error_and_jsonify(event, event_state, options, error),\n\t\t\tbranch,\n\t\t\terror_components: [],\n\t\t\tfetched,\n\t\t\tevent,\n\t\t\tevent_state,\n\t\t\tresolve_opts,\n\t\t\tdata_serializer\n\t\t});\n\t} catch (e) {\n\t\t// Edge case: If route is a 404 and the user redirects to somewhere from the root layout,\n\t\t// we end up here.\n\t\tif (e instanceof Redirect) {\n\t\t\treturn redirect_response(e.status, e.location);\n\t\t}\n\n\t\treturn static_error_page(\n\t\t\toptions,\n\t\t\tget_status(e),\n\t\t\t(await handle_error_and_jsonify(event, event_state, options, e)).message\n\t\t);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/serialize_data.js",
    "content": "import { escape_html } from '../../../utils/escape.js';\nimport { hash } from '../../../utils/hash.js';\n\n/**\n * Inside a script element, only `</script` and `<!--` hold special meaning to the HTML parser.\n *\n * The first closes the script element, so everything after is treated as raw HTML.\n * The second disables further parsing until `-->`, so the script element might be unexpectedly\n * kept open up until an unrelated HTML comment in the page.\n *\n * U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are escaped for the sake of pre-2018\n * browsers.\n *\n * @see tests for unsafe parsing examples.\n * @see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements\n * @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions\n * @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-state\n * @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-double-escaped-state\n * @see https://github.com/tc39/proposal-json-superset\n * @type {Record<string, string>}\n */\nconst replacements = {\n\t'<': '\\\\u003C',\n\t'\\u2028': '\\\\u2028',\n\t'\\u2029': '\\\\u2029'\n};\n\nconst pattern = new RegExp(`[${Object.keys(replacements).join('')}]`, 'g');\n\n/**\n * Generates a raw HTML string containing a safe script element carrying data and associated attributes.\n *\n * It escapes all the special characters needed to guarantee the element is unbroken, but care must\n * be taken to ensure it is inserted in the document at an acceptable position for a script element,\n * and that the resulting string isn't further modified.\n *\n * @param {import('./types.js').Fetched} fetched\n * @param {(name: string, value: string) => boolean} filter\n * @param {boolean} [prerendering]\n * @returns {string} The raw HTML of a script element carrying the JSON payload.\n * @example const html = serialize_data('/data.json', null, { foo: 'bar' });\n */\nexport function serialize_data(fetched, filter, prerendering = false) {\n\t/** @type {Record<string, string>} */\n\tconst headers = {};\n\n\tlet cache_control = null;\n\tlet age = null;\n\tlet varyAny = false;\n\n\tfor (const [key, value] of fetched.response.headers) {\n\t\tif (filter(key, value)) {\n\t\t\theaders[key] = value;\n\t\t}\n\n\t\tif (key === 'cache-control') cache_control = value;\n\t\telse if (key === 'age') age = value;\n\t\telse if (key === 'vary' && value.trim() === '*') varyAny = true;\n\t}\n\n\tconst payload = {\n\t\tstatus: fetched.response.status,\n\t\tstatusText: fetched.response.statusText,\n\t\theaders,\n\t\tbody: fetched.response_body\n\t};\n\n\tconst safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]);\n\n\tconst attrs = [\n\t\t'type=\"application/json\"',\n\t\t'data-sveltekit-fetched',\n\t\t`data-url=\"${escape_html(fetched.url, true)}\"`\n\t];\n\n\tif (fetched.is_b64) {\n\t\tattrs.push('data-b64');\n\t}\n\n\tif (fetched.request_headers || fetched.request_body) {\n\t\t/** @type {import('types').StrictBody[]} */\n\t\tconst values = [];\n\n\t\tif (fetched.request_headers) {\n\t\t\tvalues.push([...new Headers(fetched.request_headers)].join(','));\n\t\t}\n\n\t\tif (fetched.request_body) {\n\t\t\tvalues.push(fetched.request_body);\n\t\t}\n\n\t\tattrs.push(`data-hash=\"${hash(...values)}\"`);\n\t}\n\n\t// Compute the time the response should be cached, taking into account max-age and age.\n\t// Do not cache at all if a `Vary: *` header is present, as this indicates that the\n\t// cache is likely to get busted.\n\tif (!prerendering && fetched.method === 'GET' && cache_control && !varyAny) {\n\t\tconst match = /s-maxage=(\\d+)/g.exec(cache_control) ?? /max-age=(\\d+)/g.exec(cache_control);\n\t\tif (match) {\n\t\t\tconst ttl = +match[1] - +(age ?? '0');\n\t\t\tattrs.push(`data-ttl=\"${ttl}\"`);\n\t\t}\n\t}\n\n\treturn `<script ${attrs.join(' ')}>${safe_payload}</script>`;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/serialize_data.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport { serialize_data } from './serialize_data.js';\n\ntest('escapes slashes', () => {\n\tconst response_body = '</script><script>alert(\"xss\")';\n\n\tassert.equal(\n\t\tserialize_data(\n\t\t\t{\n\t\t\t\turl: 'foo',\n\t\t\t\tmethod: 'GET',\n\t\t\t\trequest_body: null,\n\t\t\t\tresponse_body,\n\t\t\t\tresponse: new Response(response_body)\n\t\t\t},\n\t\t\t() => false\n\t\t),\n\t\t'<script type=\"application/json\" data-sveltekit-fetched data-url=\"foo\">' +\n\t\t\t'{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"\\\\u003C/script>\\\\u003Cscript>alert(\\\\\"xss\\\\\")\"}' +\n\t\t\t'</script>'\n\t);\n});\n\ntest('escapes exclamation marks', () => {\n\tconst response_body = '<!--</script>...-->alert(\"xss\")';\n\n\tassert.equal(\n\t\tserialize_data(\n\t\t\t{\n\t\t\t\turl: 'foo',\n\t\t\t\tmethod: 'GET',\n\t\t\t\trequest_body: null,\n\t\t\t\tresponse_body,\n\t\t\t\tresponse: new Response(response_body)\n\t\t\t},\n\t\t\t() => false\n\t\t),\n\t\t'<script type=\"application/json\" data-sveltekit-fetched data-url=\"foo\">' +\n\t\t\t'{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"\\\\u003C!--\\\\u003C/script>...-->alert(\\\\\"xss\\\\\")\"}' +\n\t\t\t'</script>'\n\t);\n});\n\ntest('escapes the attribute values', () => {\n\tconst raw = 'an \"attr\" & a \\ud800';\n\tconst escaped = 'an &quot;attr&quot; &amp; a &#55296;';\n\tconst response_body = '';\n\tassert.equal(\n\t\tserialize_data(\n\t\t\t{\n\t\t\t\turl: raw,\n\t\t\t\tmethod: 'GET',\n\t\t\t\trequest_body: null,\n\t\t\t\tresponse_body,\n\t\t\t\tresponse: new Response(response_body)\n\t\t\t},\n\t\t\t() => false\n\t\t),\n\t\t`<script type=\"application/json\" data-sveltekit-fetched data-url=\"${escaped}\">{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"\"}</script>`\n\t);\n});\n\ntest('computes ttl using cache-control and age headers', () => {\n\tconst raw = 'an \"attr\" & a \\ud800';\n\tconst escaped = 'an &quot;attr&quot; &amp; a &#55296;';\n\tconst response_body = '';\n\tassert.equal(\n\t\tserialize_data(\n\t\t\t{\n\t\t\t\turl: raw,\n\t\t\t\tmethod: 'GET',\n\t\t\t\trequest_body: null,\n\t\t\t\tresponse_body,\n\t\t\t\tresponse: new Response(response_body, {\n\t\t\t\t\theaders: { 'cache-control': 'max-age=10', age: '1' }\n\t\t\t\t})\n\t\t\t},\n\t\t\t() => false\n\t\t),\n\t\t`<script type=\"application/json\" data-sveltekit-fetched data-url=\"${escaped}\" data-ttl=\"9\">{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"\"}</script>`\n\t);\n});\n\ntest(\"doesn't compute ttl when vary * header is present\", () => {\n\tconst raw = 'an \"attr\" & a \\ud800';\n\tconst escaped = 'an &quot;attr&quot; &amp; a &#55296;';\n\tconst response_body = '';\n\tassert.equal(\n\t\tserialize_data(\n\t\t\t{\n\t\t\t\turl: raw,\n\t\t\t\tmethod: 'GET',\n\t\t\t\trequest_body: null,\n\t\t\t\tresponse_body,\n\t\t\t\tresponse: new Response(response_body, {\n\t\t\t\t\theaders: { 'cache-control': 'max-age=10', vary: '*' }\n\t\t\t\t})\n\t\t\t},\n\t\t\t() => false\n\t\t),\n\t\t`<script type=\"application/json\" data-sveltekit-fetched data-url=\"${escaped}\">{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"\"}</script>`\n\t);\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/server_routing.js",
    "content": "import { base, assets, relative } from '$app/paths/internal/server';\nimport { text } from '@sveltejs/kit';\nimport { s } from '../../../utils/misc.js';\nimport { find_route } from '../../../utils/routing.js';\nimport { get_relative_path } from '../../utils.js';\n\n/**\n * @param {import('types').SSRClientRoute} route\n * @param {URL} url\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n * @returns {string}\n */\nexport function generate_route_object(route, url, manifest) {\n\tconst { errors, layouts, leaf } = route;\n\n\tconst nodes = [...errors, ...layouts.map((l) => l?.[1]), leaf[1]]\n\t\t.filter((n) => typeof n === 'number')\n\t\t.map((n) => `'${n}': () => ${create_client_import(manifest._.client.nodes?.[n], url)}`)\n\t\t.join(',\\n\\t\\t');\n\n\t// stringified version of\n\t/** @type {import('types').CSRRouteServer} */\n\treturn [\n\t\t`{\\n\\tid: ${s(route.id)}`,\n\t\t`errors: ${s(route.errors)}`,\n\t\t`layouts: ${s(route.layouts)}`,\n\t\t`leaf: ${s(route.leaf)}`,\n\t\t`nodes: {\\n\\t\\t${nodes}\\n\\t}\\n}`\n\t].join(',\\n\\t');\n}\n\n/**\n * @param {string | undefined} import_path\n * @param {URL} url\n */\nfunction create_client_import(import_path, url) {\n\tif (!import_path) return 'Promise.resolve({})';\n\n\t// During DEV, Vite will make the paths absolute (e.g. /@fs/...)\n\tif (import_path[0] === '/') {\n\t\treturn `import('${import_path}')`;\n\t}\n\n\t// During PROD, they're root-relative\n\tif (assets !== '') {\n\t\treturn `import('${assets}/${import_path}')`;\n\t}\n\n\tif (!relative) {\n\t\treturn `import('${base}/${import_path}')`;\n\t}\n\n\t// Else we make them relative to the server-side route resolution request\n\t// to support IPFS, the internet archive, etc.\n\tlet path = get_relative_path(url.pathname, `${base}/${import_path}`);\n\tif (path[0] !== '.') path = `./${path}`;\n\treturn `import('${path}')`;\n}\n\n/**\n * @param {string} resolved_path\n * @param {URL} url\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n * @returns {Promise<Response>}\n */\nexport async function resolve_route(resolved_path, url, manifest) {\n\tif (!manifest._.client.routes) {\n\t\treturn text('Server-side route resolution disabled', { status: 400 });\n\t}\n\n\tconst matchers = await manifest._.matchers();\n\tconst result = find_route(resolved_path, manifest._.client.routes, matchers);\n\n\treturn create_server_routing_response(result?.route ?? null, result?.params ?? {}, url, manifest)\n\t\t.response;\n}\n\n/**\n * @param {import('types').SSRClientRoute | null} route\n * @param {Partial<Record<string, string>>} params\n * @param {URL} url\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n * @returns {{response: Response, body: string}}\n */\nexport function create_server_routing_response(route, params, url, manifest) {\n\tconst headers = new Headers({\n\t\t'content-type': 'application/javascript; charset=utf-8'\n\t});\n\n\tif (route) {\n\t\tconst csr_route = generate_route_object(route, url, manifest);\n\t\tconst body = `${create_css_import(route, url, manifest)}\\nexport const route = ${csr_route}; export const params = ${JSON.stringify(params)};`;\n\n\t\treturn { response: text(body, { headers }), body };\n\t} else {\n\t\treturn { response: text('', { headers }), body: '' };\n\t}\n}\n\n/**\n * This function generates the client-side import for the CSS files that are\n * associated with the current route. Vite takes care of that when using\n * client-side route resolution, but for server-side resolution it does\n * not know about the CSS files automatically.\n *\n * @param {import('types').SSRClientRoute} route\n * @param {URL} url\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n * @returns {string}\n */\nfunction create_css_import(route, url, manifest) {\n\tconst { errors, layouts, leaf } = route;\n\n\tlet css = '';\n\n\tfor (const node of [...errors, ...layouts.map((l) => l?.[1]), leaf[1]]) {\n\t\tif (typeof node !== 'number') continue;\n\t\tconst node_css = manifest._.client.css?.[node];\n\t\tfor (const css_path of node_css ?? []) {\n\t\t\tcss += `'${assets || base}/${css_path}',`;\n\t\t}\n\t}\n\n\tif (!css) return '';\n\n\treturn `${create_client_import(/** @type {string} */ (manifest._.client.start), url)}.then(x => x.load_css([${css}]));`;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/page/types.d.ts",
    "content": "import { CookieSerializeOptions } from 'cookie';\nimport {\n\tCspDirectives,\n\tServerDataNode,\n\tSSRNode,\n\tServerDataSkippedNode,\n\tServerErrorNode\n} from 'types';\nimport { Csp } from './csp.js';\n\nexport interface Fetched {\n\turl: string;\n\tmethod: string;\n\trequest_body?: string | ArrayBufferView | null;\n\trequest_headers?: HeadersInit | undefined;\n\tresponse_body: string | undefined;\n\tresponse: Response;\n\tis_b64?: boolean;\n}\n\nexport type Loaded = {\n\tnode: SSRNode;\n\tdata: Record<string, any> | null;\n\tserver_data: ServerDataNode | null;\n};\n\ntype CspMode = 'hash' | 'nonce' | 'auto';\n\nexport interface CspConfig {\n\tmode: CspMode;\n\tdirectives: CspDirectives;\n\treportOnly: CspDirectives;\n}\n\nexport interface CspOpts {\n\tprerender: boolean;\n}\n\nexport interface Cookie {\n\tname: string;\n\tvalue: string;\n\toptions: CookieSerializeOptions & { path: string };\n}\n\nexport type ServerDataSerializer = {\n\tadd_node(i: number, node: ServerDataNode | null): void;\n\tget_data(csp: Csp): { data: string; chunks: AsyncIterable<string> | null };\n\tset_max_nodes(i: number): void;\n};\n\nexport type ServerDataSerializerJson = {\n\tadd_node(\n\t\ti: number,\n\t\tnode: ServerDataSkippedNode | ServerDataNode | ServerErrorNode | null | undefined\n\t): void;\n\tget_data(): { data: string; chunks: AsyncIterable<string> | null };\n};\n"
  },
  {
    "path": "packages/kit/src/runtime/server/remote.js",
    "content": "/** @import { ActionResult, RemoteForm, RequestEvent, SSRManifest } from '@sveltejs/kit' */\n/** @import { RemoteFormInternals, RemoteFunctionResponse, RemoteInternals, RequestState, SSROptions } from 'types' */\n\nimport { json, error } from '@sveltejs/kit';\nimport { HttpError, Redirect, SvelteKitError } from '@sveltejs/kit/internal';\nimport { with_request_store, merge_tracing } from '@sveltejs/kit/internal/server';\nimport { app_dir, base } from '$app/paths/internal/server';\nimport { is_form_content_type } from '../../utils/http.js';\nimport { parse_remote_arg, stringify } from '../shared.js';\nimport { handle_error_and_jsonify } from './utils.js';\nimport { normalize_error } from '../../utils/error.js';\nimport { check_incorrect_fail_use } from './page/actions.js';\nimport { DEV } from 'esm-env';\nimport { record_span } from '../telemetry/record_span.js';\nimport { deserialize_binary_form } from '../form-utils.js';\n\n/** @type {typeof handle_remote_call_internal} */\nexport async function handle_remote_call(event, state, options, manifest, id) {\n\treturn record_span({\n\t\tname: 'sveltekit.remote.call',\n\t\tattributes: {\n\t\t\t'sveltekit.remote.call.id': id\n\t\t},\n\t\tfn: (current) => {\n\t\t\tconst traced_event = merge_tracing(event, current);\n\t\t\treturn with_request_store({ event: traced_event, state }, () =>\n\t\t\t\thandle_remote_call_internal(traced_event, state, options, manifest, id)\n\t\t\t);\n\t\t}\n\t});\n}\n\n/**\n * @param {RequestEvent} event\n * @param {RequestState} state\n * @param {SSROptions} options\n * @param {SSRManifest} manifest\n * @param {string} id\n */\nasync function handle_remote_call_internal(event, state, options, manifest, id) {\n\tconst [hash, name, additional_args] = id.split('/');\n\tconst remotes = manifest._.remotes;\n\n\tif (!remotes[hash]) error(404);\n\n\tconst module = await remotes[hash]();\n\tconst fn = module.default[name];\n\n\tif (!fn) error(404);\n\n\t/** @type {RemoteInternals} */\n\tconst internals = fn.__;\n\tconst transport = options.hooks.transport;\n\n\tevent.tracing.current.setAttributes({\n\t\t'sveltekit.remote.call.type': internals.type,\n\t\t'sveltekit.remote.call.name': internals.name\n\t});\n\n\t/** @type {string[] | undefined} */\n\tlet form_client_refreshes;\n\n\ttry {\n\t\tif (internals.type === 'query_batch') {\n\t\t\tif (event.request.method !== 'POST') {\n\t\t\t\tthrow new SvelteKitError(\n\t\t\t\t\t405,\n\t\t\t\t\t'Method Not Allowed',\n\t\t\t\t\t`\\`query.batch\\` functions must be invoked via POST request, not ${event.request.method}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/** @type {{ payloads: string[] }} */\n\t\t\tconst { payloads } = await event.request.json();\n\n\t\t\tconst args = await Promise.all(\n\t\t\t\tpayloads.map((payload) => parse_remote_arg(payload, transport))\n\t\t\t);\n\n\t\t\tconst results = await with_request_store({ event, state }, () =>\n\t\t\t\tinternals.run(args, options)\n\t\t\t);\n\n\t\t\treturn json(\n\t\t\t\t/** @type {RemoteFunctionResponse} */ ({\n\t\t\t\t\ttype: 'result',\n\t\t\t\t\tresult: stringify(results, transport)\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tif (internals.type === 'form') {\n\t\t\tif (event.request.method !== 'POST') {\n\t\t\t\tthrow new SvelteKitError(\n\t\t\t\t\t405,\n\t\t\t\t\t'Method Not Allowed',\n\t\t\t\t\t`\\`form\\` functions must be invoked via POST request, not ${event.request.method}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (!is_form_content_type(event.request)) {\n\t\t\t\tthrow new SvelteKitError(\n\t\t\t\t\t415,\n\t\t\t\t\t'Unsupported Media Type',\n\t\t\t\t\t`\\`form\\` functions expect form-encoded data — received ${event.request.headers.get(\n\t\t\t\t\t\t'content-type'\n\t\t\t\t\t)}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst { data, meta, form_data } = await deserialize_binary_form(event.request);\n\n\t\t\tform_client_refreshes = meta.remote_refreshes;\n\n\t\t\t// If this is a keyed form instance (created via form.for(key)), add the key to the form data (unless already set)\n\t\t\t// Note that additional_args will only be set if the form is not enhanced, as enhanced forms transfer the key inside `data`.\n\t\t\tif (additional_args && !('id' in data)) {\n\t\t\t\tdata.id = JSON.parse(decodeURIComponent(additional_args));\n\t\t\t}\n\n\t\t\tconst fn = internals.fn;\n\t\t\tconst result = await with_request_store({ event, state }, () => fn(data, meta, form_data));\n\n\t\t\treturn json(\n\t\t\t\t/** @type {RemoteFunctionResponse} */ ({\n\t\t\t\t\ttype: 'result',\n\t\t\t\t\tresult: stringify(result, transport),\n\t\t\t\t\trefreshes: result.issues ? undefined : await serialize_refreshes(meta.remote_refreshes)\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tif (internals.type === 'command') {\n\t\t\t/** @type {{ payload: string, refreshes: string[] }} */\n\t\t\tconst { payload, refreshes } = await event.request.json();\n\t\t\tconst arg = parse_remote_arg(payload, transport);\n\t\t\tconst data = await with_request_store({ event, state }, () => fn(arg));\n\n\t\t\treturn json(\n\t\t\t\t/** @type {RemoteFunctionResponse} */ ({\n\t\t\t\t\ttype: 'result',\n\t\t\t\t\tresult: stringify(data, transport),\n\t\t\t\t\trefreshes: await serialize_refreshes(refreshes)\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tconst payload =\n\t\t\tinternals.type === 'prerender'\n\t\t\t\t? additional_args\n\t\t\t\t: /** @type {string} */ (\n\t\t\t\t\t\t// new URL(...) necessary because we're hiding the URL from the user in the event object\n\t\t\t\t\t\tnew URL(event.request.url).searchParams.get('payload')\n\t\t\t\t\t);\n\n\t\tconst data = await with_request_store({ event, state }, () =>\n\t\t\tfn(parse_remote_arg(payload, transport))\n\t\t);\n\n\t\treturn json(\n\t\t\t/** @type {RemoteFunctionResponse} */ ({\n\t\t\t\ttype: 'result',\n\t\t\t\tresult: stringify(data, transport)\n\t\t\t})\n\t\t);\n\t} catch (error) {\n\t\tif (error instanceof Redirect) {\n\t\t\treturn json(\n\t\t\t\t/** @type {RemoteFunctionResponse} */ ({\n\t\t\t\t\ttype: 'redirect',\n\t\t\t\t\tlocation: error.location,\n\t\t\t\t\trefreshes: await serialize_refreshes(form_client_refreshes)\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tconst status =\n\t\t\terror instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;\n\n\t\treturn json(\n\t\t\t/** @type {RemoteFunctionResponse} */ ({\n\t\t\t\ttype: 'error',\n\t\t\t\terror: await handle_error_and_jsonify(event, state, options, error),\n\t\t\t\tstatus\n\t\t\t}),\n\t\t\t{\n\t\t\t\t// By setting a non-200 during prerendering we fail the prerender process (unless handleHttpError handles it).\n\t\t\t\t// Errors at runtime will be passed to the client and are handled there\n\t\t\t\tstatus: state.prerendering ? status : undefined,\n\t\t\t\theaders: {\n\t\t\t\t\t'cache-control': 'private, no-store'\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * @param {string[]=} client_refreshes\n\t */\n\tasync function serialize_refreshes(client_refreshes) {\n\t\tconst refreshes = state.remote.refreshes ?? {};\n\n\t\tif (client_refreshes) {\n\t\t\tfor (const key of client_refreshes) {\n\t\t\t\tif (refreshes[key] !== undefined) continue;\n\n\t\t\t\tconst [hash, name, payload] = key.split('/');\n\n\t\t\t\tconst loader = manifest._.remotes[hash];\n\t\t\t\tconst fn = (await loader?.())?.default?.[name];\n\n\t\t\t\tif (!fn) error(400, 'Bad Request');\n\n\t\t\t\trefreshes[key] = with_request_store({ event, state }, () =>\n\t\t\t\t\tfn(parse_remote_arg(payload, transport))\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (Object.keys(refreshes).length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn stringify(\n\t\t\tObject.fromEntries(\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tObject.entries(refreshes).map(async ([key, promise]) => [key, await promise])\n\t\t\t\t)\n\t\t\t),\n\t\t\ttransport\n\t\t);\n\t}\n}\n\n/** @type {typeof handle_remote_form_post_internal} */\nexport async function handle_remote_form_post(event, state, manifest, id) {\n\treturn record_span({\n\t\tname: 'sveltekit.remote.form.post',\n\t\tattributes: {\n\t\t\t'sveltekit.remote.form.post.id': id\n\t\t},\n\t\tfn: (current) => {\n\t\t\tconst traced_event = merge_tracing(event, current);\n\t\t\treturn with_request_store({ event: traced_event, state }, () =>\n\t\t\t\thandle_remote_form_post_internal(traced_event, state, manifest, id)\n\t\t\t);\n\t\t}\n\t});\n}\n\n/**\n * @param {RequestEvent} event\n * @param {RequestState} state\n * @param {SSRManifest} manifest\n * @param {string} id\n * @returns {Promise<ActionResult>}\n */\nasync function handle_remote_form_post_internal(event, state, manifest, id) {\n\tconst [hash, name, action_id] = id.split('/');\n\tconst remotes = manifest._.remotes;\n\tconst module = await remotes[hash]?.();\n\n\tlet form = /** @type {RemoteForm<any, any>} */ (module?.default[name]);\n\n\tif (!form) {\n\t\tevent.setHeaders({\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405\n\t\t\t// \"The server must generate an Allow header field in a 405 status code response\"\n\t\t\tallow: 'GET'\n\t\t});\n\t\treturn {\n\t\t\ttype: 'error',\n\t\t\terror: new SvelteKitError(\n\t\t\t\t405,\n\t\t\t\t'Method Not Allowed',\n\t\t\t\t`POST method not allowed. No form actions exist for ${DEV ? `the page at ${event.route.id}` : 'this page'}`\n\t\t\t)\n\t\t};\n\t}\n\n\tif (action_id) {\n\t\t// @ts-expect-error\n\t\tform = with_request_store({ event, state }, () => form.for(JSON.parse(action_id)));\n\t}\n\n\ttry {\n\t\tconst fn = /** @type {RemoteFormInternals} */ (/** @type {any} */ (form).__).fn;\n\n\t\tconst { data, meta, form_data } = await deserialize_binary_form(event.request);\n\n\t\tif (action_id && !('id' in data)) {\n\t\t\tdata.id = JSON.parse(decodeURIComponent(action_id));\n\t\t}\n\n\t\tawait with_request_store({ event, state }, () => fn(data, meta, form_data));\n\n\t\t// We don't want the data to appear on `let { form } = $props()`, which is why we're not returning it.\n\t\t// It is instead available on `myForm.result`, setting of which happens within the remote `form` function.\n\t\treturn {\n\t\t\ttype: 'success',\n\t\t\tstatus: 200\n\t\t};\n\t} catch (e) {\n\t\tconst err = normalize_error(e);\n\n\t\tif (err instanceof Redirect) {\n\t\t\treturn {\n\t\t\t\ttype: 'redirect',\n\t\t\t\tstatus: err.status,\n\t\t\t\tlocation: err.location\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\ttype: 'error',\n\t\t\terror: check_incorrect_fail_use(err)\n\t\t};\n\t}\n}\n\n/**\n * @param {URL} url\n */\nexport function get_remote_id(url) {\n\treturn (\n\t\turl.pathname.startsWith(`${base}/${app_dir}/remote/`) &&\n\t\turl.pathname.replace(`${base}/${app_dir}/remote/`, '')\n\t);\n}\n\n/**\n * @param {URL} url\n */\nexport function get_remote_action(url) {\n\treturn url.searchParams.get('/remote');\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/respond.js",
    "content": "/** @import { RequestState } from 'types' */\nimport { DEV } from 'esm-env';\nimport { json, text } from '@sveltejs/kit';\nimport { Redirect, SvelteKitError } from '@sveltejs/kit/internal';\nimport { merge_tracing, with_request_store } from '@sveltejs/kit/internal/server';\nimport { base, app_dir } from '$app/paths/internal/server';\nimport { is_endpoint_request, render_endpoint } from './endpoint.js';\nimport { render_page } from './page/index.js';\nimport { render_response } from './page/render.js';\nimport { respond_with_error } from './page/respond_with_error.js';\nimport { is_form_content_type } from '../../utils/http.js';\nimport {\n\thandle_fatal_error,\n\thas_prerendered_path,\n\tmethod_not_allowed,\n\tredirect_response\n} from './utils.js';\nimport { decode_pathname, disable_search, normalize_path } from '../../utils/url.js';\nimport { find_route } from '../../utils/routing.js';\nimport { redirect_json_response, render_data } from './data/index.js';\nimport { add_cookies_to_headers, get_cookies } from './cookie.js';\nimport { create_fetch } from './fetch.js';\nimport { PageNodes } from '../../utils/page_nodes.js';\nimport { validate_server_exports } from '../../utils/exports.js';\nimport { action_json_redirect, is_action_json_request } from './page/actions.js';\nimport { INVALIDATED_PARAM, TRAILING_SLASH_PARAM } from '../shared.js';\nimport { get_public_env } from './env_module.js';\nimport { resolve_route } from './page/server_routing.js';\nimport { validateHeaders } from './validate-headers.js';\nimport {\n\tadd_data_suffix,\n\tadd_resolution_suffix,\n\thas_data_suffix,\n\thas_resolution_suffix,\n\tstrip_data_suffix,\n\tstrip_resolution_suffix\n} from '../pathname.js';\nimport { server_data_serializer } from './page/data_serializer.js';\nimport { get_remote_id, handle_remote_call } from './remote.js';\nimport { record_span } from '../telemetry/record_span.js';\nimport { otel } from '../telemetry/otel.js';\n\n/* global __SVELTEKIT_ADAPTER_NAME__ */\n\n/** @type {import('types').RequiredResolveOptions['transformPageChunk']} */\nconst default_transform = ({ html }) => html;\n\n/** @type {import('types').RequiredResolveOptions['filterSerializedResponseHeaders']} */\nconst default_filter = () => false;\n\n/** @type {import('types').RequiredResolveOptions['preload']} */\nconst default_preload = ({ type }) => type === 'js' || type === 'css';\n\nconst page_methods = new Set(['GET', 'HEAD', 'POST']);\n\nconst allowed_page_methods = new Set(['GET', 'HEAD', 'OPTIONS']);\n\nlet warned_on_devtools_json_request = false;\n\nexport const respond = propagate_context(internal_respond);\n\n/**\n * @param {Request} request\n * @param {import('types').SSROptions} options\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n * @param {import('types').SSRState} state\n * @returns {Promise<Response>}\n */\nexport async function internal_respond(request, options, manifest, state) {\n\t/** URL but stripped from the potential `/__data.json` suffix and its search param  */\n\tconst url = new URL(request.url);\n\n\tconst is_route_resolution_request = has_resolution_suffix(url.pathname);\n\tconst is_data_request = has_data_suffix(url.pathname);\n\tconst remote_id = get_remote_id(url);\n\n\tif (!DEV) {\n\t\tconst request_origin = request.headers.get('origin');\n\n\t\tif (remote_id) {\n\t\t\tif (request.method !== 'GET' && request_origin !== url.origin) {\n\t\t\t\tconst message = 'Cross-site remote requests are forbidden';\n\t\t\t\treturn json({ message }, { status: 403 });\n\t\t\t}\n\t\t} else if (options.csrf_check_origin) {\n\t\t\tconst forbidden =\n\t\t\t\tis_form_content_type(request) &&\n\t\t\t\t(request.method === 'POST' ||\n\t\t\t\t\trequest.method === 'PUT' ||\n\t\t\t\t\trequest.method === 'PATCH' ||\n\t\t\t\t\trequest.method === 'DELETE') &&\n\t\t\t\trequest_origin !== url.origin &&\n\t\t\t\t(!request_origin || !options.csrf_trusted_origins.includes(request_origin));\n\n\t\t\tif (forbidden) {\n\t\t\t\tconst message = `Cross-site ${request.method} form submissions are forbidden`;\n\t\t\t\tconst opts = { status: 403 };\n\n\t\t\t\tif (request.headers.get('accept') === 'application/json') {\n\t\t\t\t\treturn json({ message }, opts);\n\t\t\t\t}\n\n\t\t\t\treturn text(message, opts);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (options.hash_routing && url.pathname !== base + '/' && url.pathname !== '/[fallback]') {\n\t\treturn text('Not found', { status: 404 });\n\t}\n\n\t/** @type {boolean[] | undefined} */\n\tlet invalidated_data_nodes;\n\n\tif (is_route_resolution_request) {\n\t\t/**\n\t\t * If the request is for a route resolution, first modify the URL, then continue as normal\n\t\t * for path resolution, then return the route object as a JS file.\n\t\t */\n\t\turl.pathname = strip_resolution_suffix(url.pathname);\n\t} else if (is_data_request) {\n\t\turl.pathname =\n\t\t\tstrip_data_suffix(url.pathname) +\n\t\t\t\t(url.searchParams.get(TRAILING_SLASH_PARAM) === '1' ? '/' : '') || '/';\n\t\turl.searchParams.delete(TRAILING_SLASH_PARAM);\n\t\tinvalidated_data_nodes = url.searchParams\n\t\t\t.get(INVALIDATED_PARAM)\n\t\t\t?.split('')\n\t\t\t.map((node) => node === '1');\n\t\turl.searchParams.delete(INVALIDATED_PARAM);\n\t} else if (remote_id) {\n\t\turl.pathname = request.headers.get('x-sveltekit-pathname') ?? base;\n\t\turl.search = request.headers.get('x-sveltekit-search') ?? '';\n\t}\n\n\t/** @type {Record<string, string>} */\n\tconst headers = {};\n\n\tconst { cookies, new_cookies, get_cookie_header, set_internal, set_trailing_slash } = get_cookies(\n\t\trequest,\n\t\turl\n\t);\n\n\t/** @type {RequestState} */\n\tconst event_state = {\n\t\tprerendering: state.prerendering,\n\t\ttransport: options.hooks.transport,\n\t\thandleValidationError: options.hooks.handleValidationError,\n\t\ttracing: {\n\t\t\trecord_span\n\t\t},\n\t\tremote: {\n\t\t\tdata: null,\n\t\t\tforms: null,\n\t\t\trefreshes: null\n\t\t},\n\t\tis_in_remote_function: false,\n\t\tis_in_render: false,\n\t\tis_in_universal_load: false\n\t};\n\n\t/** @type {import('@sveltejs/kit').RequestEvent} */\n\tconst event = {\n\t\tcookies,\n\t\t// @ts-expect-error `fetch` needs to be created after the `event` itself\n\t\tfetch: null,\n\t\tgetClientAddress:\n\t\t\tstate.getClientAddress ||\n\t\t\t(() => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${__SVELTEKIT_ADAPTER_NAME__} does not specify getClientAddress. Please raise an issue`\n\t\t\t\t);\n\t\t\t}),\n\t\tlocals: {},\n\t\tparams: {},\n\t\tplatform: state.platform,\n\t\trequest,\n\t\troute: { id: null },\n\t\tsetHeaders: (new_headers) => {\n\t\t\tif (DEV) {\n\t\t\t\tvalidateHeaders(new_headers);\n\t\t\t}\n\n\t\t\tfor (const key in new_headers) {\n\t\t\t\tconst lower = key.toLowerCase();\n\t\t\t\tconst value = new_headers[key];\n\n\t\t\t\tif (lower === 'set-cookie') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Use `event.cookies.set(name, value, options)` instead of `event.setHeaders` to set cookies'\n\t\t\t\t\t);\n\t\t\t\t} else if (lower in headers) {\n\t\t\t\t\t// appendHeaders-style for Server-Timing https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Server-Timing\n\t\t\t\t\tif (lower === 'server-timing') {\n\t\t\t\t\t\theaders[lower] += ', ' + value;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(`\"${key}\" header is already set`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\theaders[lower] = value;\n\n\t\t\t\t\tif (state.prerendering && lower === 'cache-control') {\n\t\t\t\t\t\tstate.prerendering.cache = /** @type {string} */ (value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\turl,\n\t\tisDataRequest: is_data_request,\n\t\tisSubRequest: state.depth > 0,\n\t\tisRemoteRequest: !!remote_id\n\t};\n\n\tevent.fetch = create_fetch({\n\t\tevent,\n\t\toptions,\n\t\tmanifest,\n\t\tstate,\n\t\tget_cookie_header,\n\t\tset_internal\n\t});\n\n\tif (state.emulator?.platform) {\n\t\tevent.platform = await state.emulator.platform({\n\t\t\tconfig: {},\n\t\t\tprerender: !!state.prerendering?.fallback\n\t\t});\n\t}\n\n\tlet resolved_path = url.pathname;\n\n\tif (!remote_id) {\n\t\tconst prerendering_reroute_state = state.prerendering?.inside_reroute;\n\t\ttry {\n\t\t\t// For the duration or a reroute, disable the prerendering state as reroute could call API endpoints\n\t\t\t// which would end up in the wrong logic path if not disabled.\n\t\t\tif (state.prerendering) state.prerendering.inside_reroute = true;\n\n\t\t\t// reroute could alter the given URL, so we pass a copy\n\t\t\tresolved_path =\n\t\t\t\t(await options.hooks.reroute({ url: new URL(url), fetch: event.fetch })) ?? url.pathname;\n\t\t} catch {\n\t\t\treturn text('Internal Server Error', {\n\t\t\t\tstatus: 500\n\t\t\t});\n\t\t} finally {\n\t\t\tif (state.prerendering) state.prerendering.inside_reroute = prerendering_reroute_state;\n\t\t}\n\t}\n\n\ttry {\n\t\tresolved_path = decode_pathname(resolved_path);\n\t} catch {\n\t\treturn text('Malformed URI', { status: 400 });\n\t}\n\n\t// try to serve the rerouted prerendered resource if it exists\n\tif (\n\t\t// the resolved path has been decoded so it should be compared to the decoded url pathname\n\t\tresolved_path !== decode_pathname(url.pathname) &&\n\t\t!state.prerendering?.fallback &&\n\t\thas_prerendered_path(manifest, resolved_path)\n\t) {\n\t\tconst url = new URL(request.url);\n\t\turl.pathname = is_data_request\n\t\t\t? add_data_suffix(resolved_path)\n\t\t\t: is_route_resolution_request\n\t\t\t\t? add_resolution_suffix(resolved_path)\n\t\t\t\t: resolved_path;\n\n\t\ttry {\n\t\t\t// `fetch` automatically decodes the body, so we need to delete the related headers to not break the response\n\t\t\t// Also see https://github.com/sveltejs/kit/issues/12197 for more info (we should fix this more generally at some point)\n\t\t\tconst response = await fetch(url, request);\n\t\t\tconst headers = new Headers(response.headers);\n\t\t\tif (headers.has('content-encoding')) {\n\t\t\t\theaders.delete('content-encoding');\n\t\t\t\theaders.delete('content-length');\n\t\t\t}\n\n\t\t\treturn new Response(response.body, {\n\t\t\t\theaders,\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText\n\t\t\t});\n\t\t} catch (error) {\n\t\t\treturn await handle_fatal_error(event, event_state, options, error);\n\t\t}\n\t}\n\n\t/** @type {import('types').SSRRoute | null} */\n\tlet route = null;\n\n\tif (base && !state.prerendering?.fallback) {\n\t\tif (!resolved_path.startsWith(base)) {\n\t\t\treturn text('Not found', { status: 404 });\n\t\t}\n\t\tresolved_path = resolved_path.slice(base.length) || '/';\n\t}\n\n\tif (is_route_resolution_request) {\n\t\treturn resolve_route(resolved_path, new URL(request.url), manifest);\n\t}\n\n\tif (resolved_path === `/${app_dir}/env.js`) {\n\t\treturn get_public_env(request);\n\t}\n\n\tif (!remote_id && resolved_path.startsWith(`/${app_dir}`)) {\n\t\t// Ensure that 404'd static assets are not cached - some adapters might apply caching by default\n\t\tconst headers = new Headers();\n\t\theaders.set('cache-control', 'public, max-age=0, must-revalidate');\n\t\treturn text('Not found', { status: 404, headers });\n\t}\n\n\tif (!state.prerendering?.fallback) {\n\t\t// TODO this could theoretically break — should probably be inside a try-catch\n\t\tconst matchers = await manifest._.matchers();\n\t\tconst result = find_route(resolved_path, manifest._.routes, matchers);\n\n\t\tif (result) {\n\t\t\troute = result.route;\n\t\t\tevent.route = { id: route.id };\n\t\t\tevent.params = result.params;\n\t\t}\n\t}\n\n\t/** @type {import('types').RequiredResolveOptions} */\n\tlet resolve_opts = {\n\t\ttransformPageChunk: default_transform,\n\t\tfilterSerializedResponseHeaders: default_filter,\n\t\tpreload: default_preload\n\t};\n\n\t/** @type {import('types').TrailingSlash} */\n\tlet trailing_slash = 'never';\n\n\ttry {\n\t\t/** @type {PageNodes | undefined} */\n\t\tconst page_nodes = route?.page\n\t\t\t? new PageNodes(await load_page_nodes(route.page, manifest))\n\t\t\t: undefined;\n\n\t\t// determine whether we need to redirect to add/remove a trailing slash\n\t\tif (route && !remote_id) {\n\t\t\t// if `paths.base === '/a/b/c`, then the root route is `/a/b/c/`,\n\t\t\t// regardless of the `trailingSlash` route option\n\t\t\tif (url.pathname === base || url.pathname === base + '/') {\n\t\t\t\ttrailing_slash = 'always';\n\t\t\t} else if (page_nodes) {\n\t\t\t\tif (DEV) {\n\t\t\t\t\tpage_nodes.validate();\n\t\t\t\t}\n\t\t\t\ttrailing_slash = page_nodes.trailing_slash();\n\t\t\t} else if (route.endpoint) {\n\t\t\t\tconst node = await route.endpoint();\n\t\t\t\ttrailing_slash = node.trailingSlash ?? 'never';\n\t\t\t\tif (DEV) {\n\t\t\t\t\tvalidate_server_exports(node, /** @type {string} */ (route.endpoint_id));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!is_data_request) {\n\t\t\t\tconst normalized = normalize_path(url.pathname, trailing_slash);\n\n\t\t\t\tif (normalized !== url.pathname && !state.prerendering?.fallback) {\n\t\t\t\t\treturn new Response(undefined, {\n\t\t\t\t\t\tstatus: 308,\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t'x-sveltekit-normalize': '1',\n\t\t\t\t\t\t\tlocation:\n\t\t\t\t\t\t\t\t// ensure paths starting with '//' are not treated as protocol-relative\n\t\t\t\t\t\t\t\t(normalized.startsWith('//') ? url.origin + normalized : normalized) +\n\t\t\t\t\t\t\t\t(url.search === '?' ? '' : url.search)\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (state.before_handle || state.emulator?.platform) {\n\t\t\t\tlet config = {};\n\n\t\t\t\t/** @type {import('types').PrerenderOption} */\n\t\t\t\tlet prerender = false;\n\n\t\t\t\tif (route.endpoint) {\n\t\t\t\t\tconst node = await route.endpoint();\n\t\t\t\t\tconfig = node.config ?? config;\n\t\t\t\t\tprerender = node.prerender ?? prerender;\n\t\t\t\t} else if (page_nodes) {\n\t\t\t\t\tconfig = page_nodes.get_config() ?? config;\n\t\t\t\t\tprerender = page_nodes.prerender();\n\t\t\t\t}\n\n\t\t\t\tif (state.before_handle) {\n\t\t\t\t\tstate.before_handle(event, config, prerender);\n\t\t\t\t}\n\n\t\t\t\tif (state.emulator?.platform) {\n\t\t\t\t\tevent.platform = await state.emulator.platform({ config, prerender });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tset_trailing_slash(trailing_slash);\n\n\t\tif (state.prerendering && !state.prerendering.fallback && !state.prerendering.inside_reroute) {\n\t\t\tdisable_search(url);\n\t\t}\n\n\t\tconst response = await record_span({\n\t\t\tname: 'sveltekit.handle.root',\n\t\t\tattributes: {\n\t\t\t\t'http.route': event.route.id || 'unknown',\n\t\t\t\t'http.method': event.request.method,\n\t\t\t\t'http.url': event.url.href,\n\t\t\t\t'sveltekit.is_data_request': is_data_request,\n\t\t\t\t'sveltekit.is_sub_request': event.isSubRequest\n\t\t\t},\n\t\t\tfn: async (root_span) => {\n\t\t\t\tconst traced_event = {\n\t\t\t\t\t...event,\n\t\t\t\t\ttracing: {\n\t\t\t\t\t\tenabled: __SVELTEKIT_SERVER_TRACING_ENABLED__,\n\t\t\t\t\t\troot: root_span,\n\t\t\t\t\t\tcurrent: root_span\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\treturn await with_request_store({ event: traced_event, state: event_state }, () =>\n\t\t\t\t\toptions.hooks.handle({\n\t\t\t\t\t\tevent: traced_event,\n\t\t\t\t\t\tresolve: (event, opts) => {\n\t\t\t\t\t\t\treturn record_span({\n\t\t\t\t\t\t\t\tname: 'sveltekit.resolve',\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t'http.route': event.route.id || 'unknown'\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfn: (resolve_span) => {\n\t\t\t\t\t\t\t\t\t// counter-intuitively, we need to clear the event, so that it's not\n\t\t\t\t\t\t\t\t\t// e.g. accessible when loading modules needed to handle the request\n\t\t\t\t\t\t\t\t\treturn with_request_store(null, () =>\n\t\t\t\t\t\t\t\t\t\tresolve(merge_tracing(event, resolve_span), page_nodes, opts).then(\n\t\t\t\t\t\t\t\t\t\t\t(response) => {\n\t\t\t\t\t\t\t\t\t\t\t\t// add headers/cookies here, rather than inside `resolve`, so that we\n\t\t\t\t\t\t\t\t\t\t\t\t// can do it once for all responses instead of once per `return`\n\t\t\t\t\t\t\t\t\t\t\t\tfor (const key in headers) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tconst value = headers[key];\n\t\t\t\t\t\t\t\t\t\t\t\t\tresponse.headers.set(key, /** @type {string} */ (value));\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tadd_cookies_to_headers(response.headers, new_cookies.values());\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (state.prerendering && event.route.id !== null) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tresponse.headers.set('x-sveltekit-routeid', encodeURI(event.route.id));\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tresolve_span.setAttributes({\n\t\t\t\t\t\t\t\t\t\t\t\t\t'http.response.status_code': response.status,\n\t\t\t\t\t\t\t\t\t\t\t\t\t'http.response.body.size':\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresponse.headers.get('content-length') || 'unknown'\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\t\treturn response;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// respond with 304 if etag matches\n\t\tif (response.status === 200 && response.headers.has('etag')) {\n\t\t\tlet if_none_match_value = request.headers.get('if-none-match');\n\n\t\t\t// ignore W/ prefix https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match#directives\n\t\t\tif (if_none_match_value?.startsWith('W/\"')) {\n\t\t\t\tif_none_match_value = if_none_match_value.substring(2);\n\t\t\t}\n\n\t\t\tconst etag = /** @type {string} */ (response.headers.get('etag'));\n\n\t\t\tif (if_none_match_value === etag) {\n\t\t\t\tconst headers = new Headers({ etag });\n\n\t\t\t\t// https://datatracker.ietf.org/doc/html/rfc7232#section-4.1 + set-cookie\n\t\t\t\tfor (const key of [\n\t\t\t\t\t'cache-control',\n\t\t\t\t\t'content-location',\n\t\t\t\t\t'date',\n\t\t\t\t\t'expires',\n\t\t\t\t\t'vary',\n\t\t\t\t\t'set-cookie'\n\t\t\t\t]) {\n\t\t\t\t\tconst value = response.headers.get(key);\n\t\t\t\t\tif (value) headers.set(key, value);\n\t\t\t\t}\n\n\t\t\t\treturn new Response(undefined, {\n\t\t\t\t\tstatus: 304,\n\t\t\t\t\theaders\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Edge case: If user does `return Response(30x)` in handle hook while processing a data request,\n\t\t// we need to transform the redirect response to a corresponding JSON response.\n\t\tif (is_data_request && response.status >= 300 && response.status <= 308) {\n\t\t\tconst location = response.headers.get('location');\n\t\t\tif (location) {\n\t\t\t\treturn redirect_json_response(new Redirect(/** @type {any} */ (response.status), location));\n\t\t\t}\n\t\t}\n\n\t\treturn response;\n\t} catch (e) {\n\t\tif (e instanceof Redirect) {\n\t\t\tconst response =\n\t\t\t\tis_data_request || remote_id\n\t\t\t\t\t? redirect_json_response(e)\n\t\t\t\t\t: route?.page && is_action_json_request(event)\n\t\t\t\t\t\t? action_json_redirect(e)\n\t\t\t\t\t\t: redirect_response(e.status, e.location);\n\t\t\tadd_cookies_to_headers(response.headers, new_cookies.values());\n\t\t\treturn response;\n\t\t}\n\t\treturn await handle_fatal_error(event, event_state, options, e);\n\t}\n\n\t/**\n\t * @param {import('@sveltejs/kit').RequestEvent} event\n\t * @param {PageNodes | undefined} page_nodes\n\t * @param {import('@sveltejs/kit').ResolveOptions} [opts]\n\t */\n\tasync function resolve(event, page_nodes, opts) {\n\t\ttry {\n\t\t\tif (opts) {\n\t\t\t\tresolve_opts = {\n\t\t\t\t\ttransformPageChunk: opts.transformPageChunk || default_transform,\n\t\t\t\t\tfilterSerializedResponseHeaders: opts.filterSerializedResponseHeaders || default_filter,\n\t\t\t\t\tpreload: opts.preload || default_preload\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (options.hash_routing || state.prerendering?.fallback) {\n\t\t\t\treturn await render_response({\n\t\t\t\t\tevent,\n\t\t\t\t\tevent_state,\n\t\t\t\t\toptions,\n\t\t\t\t\tmanifest,\n\t\t\t\t\tstate,\n\t\t\t\t\tpage_config: { ssr: false, csr: true },\n\t\t\t\t\tstatus: 200,\n\t\t\t\t\terror: null,\n\t\t\t\t\tbranch: [],\n\t\t\t\t\tfetched: [],\n\t\t\t\t\tresolve_opts,\n\t\t\t\t\tdata_serializer: server_data_serializer(event, event_state, options)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (remote_id) {\n\t\t\t\treturn await handle_remote_call(event, event_state, options, manifest, remote_id);\n\t\t\t}\n\n\t\t\tif (route) {\n\t\t\t\tconst method = /** @type {import('types').HttpMethod} */ (event.request.method);\n\n\t\t\t\t/** @type {Response} */\n\t\t\t\tlet response;\n\n\t\t\t\tif (is_data_request) {\n\t\t\t\t\tresponse = await render_data(\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\tevent_state,\n\t\t\t\t\t\troute,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\tmanifest,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tinvalidated_data_nodes,\n\t\t\t\t\t\ttrailing_slash\n\t\t\t\t\t);\n\t\t\t\t} else if (route.endpoint && (!route.page || is_endpoint_request(event))) {\n\t\t\t\t\tresponse = await render_endpoint(event, event_state, await route.endpoint(), state);\n\t\t\t\t} else if (route.page) {\n\t\t\t\t\tif (!page_nodes) {\n\t\t\t\t\t\tthrow new Error('page_nodes not found. This should never happen');\n\t\t\t\t\t} else if (page_methods.has(method)) {\n\t\t\t\t\t\tresponse = await render_page(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\tevent_state,\n\t\t\t\t\t\t\troute.page,\n\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\tmanifest,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tpage_nodes,\n\t\t\t\t\t\t\tresolve_opts\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst allowed_methods = new Set(allowed_page_methods);\n\t\t\t\t\t\tconst node = await manifest._.nodes[route.page.leaf]();\n\t\t\t\t\t\tif (node?.server?.actions) {\n\t\t\t\t\t\t\tallowed_methods.add('POST');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (method === 'OPTIONS') {\n\t\t\t\t\t\t\t// This will deny CORS preflight requests implicitly because we don't\n\t\t\t\t\t\t\t// add the required CORS headers to the response.\n\t\t\t\t\t\t\tresponse = new Response(null, {\n\t\t\t\t\t\t\t\tstatus: 204,\n\t\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t\tallow: Array.from(allowed_methods.values()).join(', ')\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst mod = [...allowed_methods].reduce((acc, curr) => {\n\t\t\t\t\t\t\t\tacc[curr] = true;\n\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t}, /** @type {Record<string, any>} */ ({}));\n\t\t\t\t\t\t\tresponse = method_not_allowed(mod, method);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// a route will always have a page or an endpoint, but TypeScript doesn't know that\n\t\t\t\t\tthrow new Error('Route is neither page nor endpoint. This should never happen');\n\t\t\t\t}\n\n\t\t\t\t// If the route contains a page and an endpoint, we need to add a\n\t\t\t\t// `Vary: Accept` header to the response because of browser caching\n\t\t\t\tif (request.method === 'GET' && route.page && route.endpoint) {\n\t\t\t\t\tconst vary = response.headers\n\t\t\t\t\t\t.get('vary')\n\t\t\t\t\t\t?.split(',')\n\t\t\t\t\t\t?.map((v) => v.trim().toLowerCase());\n\t\t\t\t\tif (!(vary?.includes('accept') || vary?.includes('*'))) {\n\t\t\t\t\t\t// the returned response might have immutable headers,\n\t\t\t\t\t\t// so we have to clone them before trying to mutate them\n\t\t\t\t\t\tresponse = new Response(response.body, {\n\t\t\t\t\t\t\tstatus: response.status,\n\t\t\t\t\t\t\tstatusText: response.statusText,\n\t\t\t\t\t\t\theaders: new Headers(response.headers)\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresponse.headers.append('Vary', 'Accept');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t}\n\n\t\t\tif (state.error && event.isSubRequest) {\n\t\t\t\t// avoid overwriting the headers. This could be a same origin fetch request\n\t\t\t\t// to an external service from the root layout while rendering an error page\n\t\t\t\tconst headers = new Headers(request.headers);\n\t\t\t\theaders.set('x-sveltekit-error', 'true');\n\t\t\t\treturn await fetch(request, { headers });\n\t\t\t}\n\n\t\t\tif (state.error) {\n\t\t\t\treturn text('Internal Server Error', {\n\t\t\t\t\tstatus: 500\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// if this request came direct from the user, rather than\n\t\t\t// via our own `fetch`, render a 404 page\n\t\t\tif (state.depth === 0) {\n\t\t\t\t// In local development, Chrome requests this file for its 'automatic workspace folders' feature,\n\t\t\t\t// causing console spam. If users want to serve this file they can install\n\t\t\t\t// https://svelte.dev/docs/cli/devtools-json\n\t\t\t\tif (DEV && event.url.pathname === '/.well-known/appspecific/com.chrome.devtools.json') {\n\t\t\t\t\tif (!warned_on_devtools_json_request) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`\\nGoogle Chrome is requesting ${event.url.pathname} to automatically configure devtools project settings. To learn why, and how to prevent this message, see https://svelte.dev/docs/cli/devtools-json\\n`\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\twarned_on_devtools_json_request = true;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn new Response(undefined, { status: 404 });\n\t\t\t\t}\n\n\t\t\t\treturn await respond_with_error({\n\t\t\t\t\tevent,\n\t\t\t\t\tevent_state,\n\t\t\t\t\toptions,\n\t\t\t\t\tmanifest,\n\t\t\t\t\tstate,\n\t\t\t\t\tstatus: 404,\n\t\t\t\t\terror: new SvelteKitError(404, 'Not Found', `Not found: ${event.url.pathname}`),\n\t\t\t\t\tresolve_opts\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (state.prerendering) {\n\t\t\t\treturn text('not found', { status: 404 });\n\t\t\t}\n\n\t\t\t// we can't load the endpoint from our own manifest,\n\t\t\t// so we need to make an actual HTTP request\n\t\t\tconst response = await fetch(request);\n\n\t\t\t// clone the response so that headers are mutable (https://github.com/sveltejs/kit/issues/13857)\n\t\t\treturn new Response(response.body, response);\n\t\t} catch (e) {\n\t\t\t// TODO if `e` is instead named `error`, some fucked up Vite transformation happens\n\t\t\t// and I don't even know how to describe it. need to investigate at some point\n\n\t\t\t// HttpError from endpoint can end up here - TODO should it be handled there instead?\n\t\t\treturn await handle_fatal_error(event, event_state, options, e);\n\t\t} finally {\n\t\t\tevent.cookies.set = () => {\n\t\t\t\tthrow new Error('Cannot use `cookies.set(...)` after the response has been generated');\n\t\t\t};\n\n\t\t\tevent.setHeaders = () => {\n\t\t\t\tthrow new Error('Cannot use `setHeaders(...)` after the response has been generated');\n\t\t\t};\n\t\t}\n\t}\n}\n\n/**\n * @param {import('types').PageNodeIndexes} page\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n */\nexport function load_page_nodes(page, manifest) {\n\treturn Promise.all([\n\t\t// we use == here rather than === because [undefined] serializes as \"[null]\"\n\t\t...page.layouts.map((n) => (n == undefined ? n : manifest._.nodes[n]())),\n\t\tmanifest._.nodes[page.leaf]()\n\t]);\n}\n\n/**\n * It's likely that, in a distributed system, there are spans starting outside the SvelteKit server -- eg.\n * started on the frontend client, or in a service that calls the SvelteKit server. There are standardized\n * ways to represent this context in HTTP headers, so we can extract that context and run our tracing inside of it\n * so that when our traces are exported, they are associated with the correct parent context.\n * @param {typeof internal_respond} fn\n * @returns {typeof internal_respond}\n */\nfunction propagate_context(fn) {\n\treturn async (req, ...rest) => {\n\t\tif (otel === null) {\n\t\t\treturn fn(req, ...rest);\n\t\t}\n\n\t\tconst { propagation, context } = await otel;\n\t\tconst c = propagation.extract(context.active(), Object.fromEntries(req.headers));\n\t\treturn context.with(c, async () => {\n\t\t\treturn await fn(req, ...rest);\n\t\t});\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/utils.js",
    "content": "import { DEV } from 'esm-env';\nimport { json, text } from '@sveltejs/kit';\nimport { HttpError } from '@sveltejs/kit/internal';\nimport { with_request_store } from '@sveltejs/kit/internal/server';\nimport { coalesce_to_error, get_message, get_status } from '../../utils/error.js';\nimport { negotiate } from '../../utils/http.js';\nimport { fix_stack_trace } from '../shared-server.js';\nimport { ENDPOINT_METHODS } from '../../constants.js';\nimport { escape_html } from '../../utils/escape.js';\n\n/** @param {any} body */\nexport function is_pojo(body) {\n\tif (typeof body !== 'object') return false;\n\n\tif (body) {\n\t\tif (body instanceof Uint8Array) return false;\n\t\tif (body instanceof ReadableStream) return false;\n\t}\n\n\treturn true;\n}\n\n/**\n * @param {Partial<Record<import('types').HttpMethod, any>>} mod\n * @param {import('types').HttpMethod} method\n */\nexport function method_not_allowed(mod, method) {\n\treturn text(`${method} method not allowed`, {\n\t\tstatus: 405,\n\t\theaders: {\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405\n\t\t\t// \"The server must generate an Allow header field in a 405 status code response\"\n\t\t\tallow: allowed_methods(mod).join(', ')\n\t\t}\n\t});\n}\n\n/** @param {Partial<Record<import('types').HttpMethod, any>>} mod */\nexport function allowed_methods(mod) {\n\tconst allowed = ENDPOINT_METHODS.filter((method) => method in mod);\n\n\t// if there's no HEAD handler, but we have a GET handler, we respond to\n\t// HEAD requests using the GET handler and omit the response body.\n\tif ('GET' in mod && !('HEAD' in mod)) {\n\t\tallowed.push('HEAD');\n\t}\n\n\treturn allowed;\n}\n\n/**\n * @param {import('types').SSROptions} options\n */\nexport function get_global_name(options) {\n\treturn DEV ? '__sveltekit_dev' : `__sveltekit_${options.version_hash}`;\n}\n\n/**\n * Return as a response that renders the error.html\n *\n * @param {import('types').SSROptions} options\n * @param {number} status\n * @param {string} message\n */\nexport function static_error_page(options, status, message) {\n\tlet page = options.templates.error({ status, message: escape_html(message) });\n\n\tif (DEV) {\n\t\t// inject Vite HMR client, for easier debugging\n\t\tpage = page.replace('</head>', '<script type=\"module\" src=\"/@vite/client\"></script></head>');\n\t}\n\n\treturn text(page, {\n\t\theaders: { 'content-type': 'text/html; charset=utf-8' },\n\t\tstatus\n\t});\n}\n\n/**\n * @param {import('@sveltejs/kit').RequestEvent} event\n * @param {import('types').RequestState} state\n * @param {import('types').SSROptions} options\n * @param {unknown} error\n */\nexport async function handle_fatal_error(event, state, options, error) {\n\terror = error instanceof HttpError ? error : coalesce_to_error(error);\n\tconst status = get_status(error);\n\tconst body = await handle_error_and_jsonify(event, state, options, error);\n\n\t// ideally we'd use sec-fetch-dest instead, but Safari — quelle surprise — doesn't support it\n\tconst type = negotiate(event.request.headers.get('accept') || 'text/html', [\n\t\t'application/json',\n\t\t'text/html'\n\t]);\n\n\tif (event.isDataRequest || type === 'application/json') {\n\t\treturn json(body, {\n\t\t\tstatus\n\t\t});\n\t}\n\n\treturn static_error_page(options, status, body.message);\n}\n\n/**\n * @param {import('@sveltejs/kit').RequestEvent} event\n * @param {import('types').RequestState} state\n * @param {import('types').SSROptions} options\n * @param {any} error\n * @returns {Promise<App.Error>}\n */\nexport async function handle_error_and_jsonify(event, state, options, error) {\n\tif (error instanceof HttpError) {\n\t\t// @ts-expect-error custom user errors may not have a message field if App.Error is overwritten\n\t\treturn { message: 'Unknown Error', ...error.body };\n\t}\n\n\tif (DEV && typeof error == 'object') {\n\t\tfix_stack_trace(error);\n\t}\n\n\tconst status = get_status(error);\n\tconst message = get_message(error);\n\n\treturn (\n\t\t(await with_request_store({ event, state }, () =>\n\t\t\toptions.hooks.handleError({ error, event, status, message })\n\t\t)) ?? { message }\n\t);\n}\n\n/**\n * @param {number} status\n * @param {string} location\n */\nexport function redirect_response(status, location) {\n\tconst response = new Response(undefined, {\n\t\tstatus,\n\t\theaders: { location }\n\t});\n\treturn response;\n}\n\n/**\n * @param {import('@sveltejs/kit').RequestEvent} event\n * @param {Error & { path: string }} error\n */\nexport function clarify_devalue_error(event, error) {\n\tif (error.path) {\n\t\treturn (\n\t\t\t`Data returned from \\`load\\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path}). ` +\n\t\t\t`If you need to serialize/deserialize custom types, use transport hooks: https://svelte.dev/docs/kit/hooks#Universal-hooks-transport.`\n\t\t);\n\t}\n\n\tif (error.path === '') {\n\t\treturn `Data returned from \\`load\\` while rendering ${event.route.id} is not a plain object`;\n\t}\n\n\t// belt and braces — this should never happen\n\treturn error.message;\n}\n\n/**\n * @param {import('types').ServerDataNode} node\n */\nexport function serialize_uses(node) {\n\tconst uses = {};\n\n\tif (node.uses && node.uses.dependencies.size > 0) {\n\t\tuses.dependencies = Array.from(node.uses.dependencies);\n\t}\n\n\tif (node.uses && node.uses.search_params.size > 0) {\n\t\tuses.search_params = Array.from(node.uses.search_params);\n\t}\n\n\tif (node.uses && node.uses.params.size > 0) {\n\t\tuses.params = Array.from(node.uses.params);\n\t}\n\n\tif (node.uses?.parent) uses.parent = 1;\n\tif (node.uses?.route) uses.route = 1;\n\tif (node.uses?.url) uses.url = 1;\n\n\treturn uses;\n}\n\n/**\n * Returns `true` if the given path was prerendered\n * @param {import('@sveltejs/kit').SSRManifest} manifest\n * @param {string} pathname Should include the base and be decoded\n */\nexport function has_prerendered_path(manifest, pathname) {\n\treturn (\n\t\tmanifest._.prerendered_routes.has(pathname) ||\n\t\t(pathname.at(-1) === '/' && manifest._.prerendered_routes.has(pathname.slice(0, -1)))\n\t);\n}\n\n/**\n * Formats the error into a nice message with sanitized stack trace\n * @param {number} status\n * @param {Error} error\n * @param {import('@sveltejs/kit').RequestEvent} event\n */\nexport function format_server_error(status, error, event) {\n\tconst formatted_text = `\\n\\x1b[1;31m[${status}] ${event.request.method} ${event.url.pathname}\\x1b[0m`;\n\n\tif (status === 404) {\n\t\treturn formatted_text;\n\t}\n\n\treturn `${formatted_text}\\n${DEV ? clean_up_stack_trace(error) : error.stack}`;\n}\n\n/**\n * In dev, tidy up stack traces by making paths relative to the current project directory\n * @param {string} file\n */\nlet relative = (file) => file;\n\nif (DEV) {\n\ttry {\n\t\tconst path = await import('node:path');\n\t\tconst process = await import('node:process');\n\n\t\trelative = (file) => path.relative(process.cwd(), file);\n\t} catch {\n\t\t// do nothing\n\t}\n}\n\n/**\n * Provides a refined stack trace by excluding lines following the last occurrence of a line containing +page. +layout. or +server.\n * @param {Error} error\n */\nexport function clean_up_stack_trace(error) {\n\tconst stack_trace = (error.stack?.split('\\n') ?? []).map((line) => {\n\t\treturn line.replace(/\\((.+)(:\\d+:\\d+)\\)$/, (_, file, loc) => `(${relative(file)}${loc})`);\n\t});\n\n\t// progressive enhancement for people who haven't configured kit.files.src to something else\n\tconst last_line_from_src_code = stack_trace.findLastIndex((line) => /\\(src[\\\\/]/.test(line));\n\n\tif (last_line_from_src_code === -1) {\n\t\t// default to the whole stack trace\n\t\treturn error.stack;\n\t}\n\n\treturn stack_trace.slice(0, last_line_from_src_code + 1).join('\\n');\n}\n\n/**\n * Returns the filename without the extension. e.g., `+page.server`, `+page`, etc.\n * @param {string | undefined} node_id\n * @returns {string}\n */\nexport function get_node_type(node_id) {\n\tconst parts = node_id?.split('/');\n\tconst filename = parts?.at(-1);\n\tif (!filename) return 'unknown';\n\tconst dot_parts = filename.split('.');\n\treturn dot_parts.slice(0, -1).join('.');\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/validate-headers.js",
    "content": "/** @type {Set<string>} */\nconst VALID_CACHE_CONTROL_DIRECTIVES = new Set([\n\t'max-age',\n\t'public',\n\t'private',\n\t'no-cache',\n\t'no-store',\n\t'must-revalidate',\n\t'proxy-revalidate',\n\t's-maxage',\n\t'immutable',\n\t'stale-while-revalidate',\n\t'stale-if-error',\n\t'no-transform',\n\t'only-if-cached',\n\t'max-stale',\n\t'min-fresh'\n]);\n\nconst CONTENT_TYPE_PATTERN =\n\t/^(application|audio|example|font|haptics|image|message|model|multipart|text|video|x-[a-z]+)\\/[-+.\\w]+$/i;\n\n/** @type {Record<string, (value: string) => void>} */\nconst HEADER_VALIDATORS = {\n\t'cache-control': (value) => {\n\t\tconst error_suffix = `(While parsing \"${value}\".)`;\n\t\tconst parts = value.split(',').map((part) => part.trim());\n\t\tif (parts.some((part) => !part)) {\n\t\t\tthrow new Error(`\\`cache-control\\` header contains empty directives. ${error_suffix}`);\n\t\t}\n\n\t\tconst directives = parts.map((part) => part.split('=')[0].toLowerCase());\n\t\tconst invalid = directives.find((directive) => !VALID_CACHE_CONTROL_DIRECTIVES.has(directive));\n\t\tif (invalid) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid cache-control directive \"${invalid}\". Did you mean one of: ${[...VALID_CACHE_CONTROL_DIRECTIVES].join(', ')}? ${error_suffix}`\n\t\t\t);\n\t\t}\n\t},\n\n\t'content-type': (value) => {\n\t\tconst type = value.split(';')[0].trim();\n\t\tconst error_suffix = `(While parsing \"${value}\".)`;\n\t\tif (!CONTENT_TYPE_PATTERN.test(type)) {\n\t\t\tthrow new Error(`Invalid content-type value \"${type}\". ${error_suffix}`);\n\t\t}\n\t}\n};\n\n/**\n * @param {Record<string, string>} headers\n */\nexport function validateHeaders(headers) {\n\tfor (const [key, value] of Object.entries(headers)) {\n\t\tconst validator = HEADER_VALIDATORS[key.toLowerCase()];\n\t\ttry {\n\t\t\tvalidator?.(value);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tconsole.warn(`[SvelteKit] ${error.message}`);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/server/validate-headers.spec.js",
    "content": "import { describe, test, expect, beforeEach, vi } from 'vitest';\nimport { validateHeaders } from './validate-headers.js';\n\ndescribe('validateHeaders', () => {\n\tconst console_warn_spy = vi.spyOn(console, 'warn');\n\n\tbeforeEach(() => {\n\t\tvi.resetAllMocks();\n\t});\n\n\tdescribe('cache-control header', () => {\n\t\ttest('accepts valid directives', () => {\n\t\t\tvalidateHeaders({ 'cache-control': 'public, max-age=3600' });\n\t\t\texpect(console_warn_spy).not.toHaveBeenCalled();\n\t\t});\n\n\t\ttest('rejects invalid directives', () => {\n\t\t\tvalidateHeaders({ 'cache-control': 'public, maxage=3600' });\n\t\t\texpect(console_warn_spy).toHaveBeenCalledWith(\n\t\t\t\texpect.stringContaining('Invalid cache-control directive \"maxage\"')\n\t\t\t);\n\t\t});\n\n\t\ttest('rejects empty directives', () => {\n\t\t\tvalidateHeaders({ 'cache-control': 'public,, max-age=3600' });\n\t\t\texpect(console_warn_spy).toHaveBeenCalledWith(\n\t\t\t\texpect.stringContaining('`cache-control` header contains empty directives')\n\t\t\t);\n\n\t\t\tvalidateHeaders({ 'cache-control': 'public, , max-age=3600' });\n\t\t\texpect(console_warn_spy).toHaveBeenCalledWith(\n\t\t\t\texpect.stringContaining('`cache-control` header contains empty directives')\n\t\t\t);\n\t\t});\n\n\t\ttest('accepts multiple cache-control values', () => {\n\t\t\tvalidateHeaders({ 'cache-control': 'max-age=3600, s-maxage=7200' });\n\t\t\texpect(console_warn_spy).not.toHaveBeenCalled();\n\t\t});\n\t});\n\n\tdescribe('content-type header', () => {\n\t\ttest('accepts standard content types', () => {\n\t\t\tvalidateHeaders({ 'content-type': 'application/json' });\n\t\t\texpect(console_warn_spy).not.toHaveBeenCalled();\n\t\t});\n\n\t\ttest('accepts content types with parameters', () => {\n\t\t\tvalidateHeaders({ 'content-type': 'text/html; charset=utf-8' });\n\t\t\texpect(console_warn_spy).not.toHaveBeenCalled();\n\n\t\t\tvalidateHeaders({ 'content-type': 'application/javascript; charset=utf-8' });\n\t\t\texpect(console_warn_spy).not.toHaveBeenCalled();\n\t\t});\n\n\t\ttest('accepts vendor-specific content types', () => {\n\t\t\tvalidateHeaders({ 'content-type': 'x-custom/whatever' });\n\t\t\texpect(console_warn_spy).not.toHaveBeenCalled();\n\t\t});\n\n\t\ttest('rejects malformed content types', () => {\n\t\t\tvalidateHeaders({ 'content-type': 'invalid-content-type' });\n\t\t\texpect(console_warn_spy).toHaveBeenCalledWith(\n\t\t\t\texpect.stringContaining('Invalid content-type value \"invalid-content-type\"')\n\t\t\t);\n\t\t});\n\n\t\ttest('rejects invalid content type categories', () => {\n\t\t\tvalidateHeaders({ 'content-type': 'invalid/type; invalid=param' });\n\t\t\texpect(console_warn_spy).toHaveBeenCalledWith(\n\t\t\t\texpect.stringContaining('Invalid content-type value \"invalid/type\"')\n\t\t\t);\n\n\t\t\tvalidateHeaders({ 'content-type': 'bad/type; charset=utf-8' });\n\t\t\texpect(console_warn_spy).toHaveBeenCalledWith(\n\t\t\t\texpect.stringContaining('Invalid content-type value \"bad/type\"')\n\t\t\t);\n\t\t});\n\n\t\ttest('handles case-insensitive content-types', () => {\n\t\t\tvalidateHeaders({ 'content-type': 'TEXT/HTML; charset=utf-8' });\n\t\t\texpect(console_warn_spy).not.toHaveBeenCalled();\n\t\t});\n\t});\n\n\ttest('allows unknown headers', () => {\n\t\tvalidateHeaders({ 'x-custom-header': 'some-value' });\n\t\texpect(console_warn_spy).not.toHaveBeenCalled();\n\t});\n\n\ttest('handles multiple headers simultaneously', () => {\n\t\tvalidateHeaders({\n\t\t\t'cache-control': 'max-age=3600',\n\t\t\t'content-type': 'text/html',\n\t\t\t'x-custom': 'value'\n\t\t});\n\t\texpect(console_warn_spy).not.toHaveBeenCalled();\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/shared-server.js",
    "content": "/**\n * `$env/dynamic/private`\n * @type {Record<string, string>}\n */\nexport let private_env = {};\n\n/**\n * `$env/dynamic/public`\n * @type {Record<string, string>}\n */\nexport let public_env = {};\n\n/** @param {any} error */\nexport let fix_stack_trace = (error) => error?.stack;\n\n/** @type {(environment: Record<string, string>) => void} */\nexport function set_private_env(environment) {\n\tprivate_env = environment;\n}\n\n/** @type {(environment: Record<string, string>) => void} */\nexport function set_public_env(environment) {\n\tpublic_env = environment;\n}\n\n/** @param {(error: Error) => string} value */\nexport function set_fix_stack_trace(value) {\n\tfix_stack_trace = value;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/shared.js",
    "content": "/** @import { Transport } from '@sveltejs/kit' */\nimport * as devalue from 'devalue';\nimport { base64_decode, base64_encode, text_decoder } from './utils.js';\nimport * as svelte from 'svelte';\n\n/**\n * @param {string} route_id\n * @param {string} dep\n */\nexport function validate_depends(route_id, dep) {\n\tconst match = /^(moz-icon|view-source|jar):/.exec(dep);\n\tif (match) {\n\t\tconsole.warn(\n\t\t\t`${route_id}: Calling \\`depends('${dep}')\\` will throw an error in Firefox because \\`${match[1]}\\` is a special URI scheme`\n\t\t);\n\t}\n}\n\nexport const INVALIDATED_PARAM = 'x-sveltekit-invalidated';\n\nexport const TRAILING_SLASH_PARAM = 'x-sveltekit-trailing-slash';\n\n/**\n * @param {any} data\n * @param {string} [location_description]\n */\nexport function validate_load_response(data, location_description) {\n\tif (data != null && Object.getPrototypeOf(data) !== Object.prototype) {\n\t\tthrow new Error(\n\t\t\t`a load function ${location_description} returned ${\n\t\t\t\ttypeof data !== 'object'\n\t\t\t\t\t? `a ${typeof data}`\n\t\t\t\t\t: data instanceof Response\n\t\t\t\t\t\t? 'a Response object'\n\t\t\t\t\t\t: Array.isArray(data)\n\t\t\t\t\t\t\t? 'an array'\n\t\t\t\t\t\t\t: 'a non-plain object'\n\t\t\t}, but must return a plain object at the top level (i.e. \\`return {...}\\`)`\n\t\t);\n\t}\n}\n\n/**\n * Try to `devalue.stringify` the data object using the provided transport encoders.\n * @param {any} data\n * @param {Transport} transport\n */\nexport function stringify(data, transport) {\n\tconst encoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.encode]));\n\n\treturn devalue.stringify(data, encoders);\n}\n\n/**\n * Stringifies the argument (if any) for a remote function in such a way that\n * it is both a valid URL and a valid file name (necessary for prerendering).\n * @param {any} value\n * @param {Transport} transport\n */\nexport function stringify_remote_arg(value, transport) {\n\tif (value === undefined) return '';\n\n\t// If people hit file/url size limits, we can look into using something like compress_and_encode_text from svelte.dev beyond a certain size\n\tconst json_string = stringify(value, transport);\n\n\tconst bytes = new TextEncoder().encode(json_string);\n\treturn base64_encode(bytes).replaceAll('=', '').replaceAll('+', '-').replaceAll('/', '_');\n}\n\n/**\n * Parses the argument (if any) for a remote function\n * @param {string} string\n * @param {Transport} transport\n */\nexport function parse_remote_arg(string, transport) {\n\tif (!string) return undefined;\n\n\tconst json_string = text_decoder.decode(\n\t\t// no need to add back `=` characters, atob can handle it\n\t\tbase64_decode(string.replaceAll('-', '+').replaceAll('_', '/'))\n\t);\n\n\tconst decoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.decode]));\n\n\treturn devalue.parse(json_string, decoders);\n}\n\n/**\n * @param {string} id\n * @param {string} payload\n */\nexport function create_remote_key(id, payload) {\n\treturn id + '/' + payload;\n}\n\n/**\n * @template T\n * @param {string} key\n * @param {() => T} fn\n * @returns {T}\n * @deprecated TODO remove in SvelteKit 3.0\n */\nexport function unfriendly_hydratable(key, fn) {\n\tif (!svelte.hydratable) {\n\t\tthrow new Error('Remote functions require Svelte 5.44.0 or later');\n\t}\n\treturn svelte.hydratable(key, fn);\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/telemetry/noop.js",
    "content": "/** @import { Tracer, Span, SpanContext } from '@opentelemetry/api' */\n\n/**\n * Tracer implementation that does nothing (null object).\n * @type {Tracer}\n */\nexport const noop_tracer = {\n\t/**\n\t * @returns {Span}\n\t */\n\tstartSpan() {\n\t\treturn noop_span;\n\t},\n\n\t/**\n\t * @param {unknown} _name\n\t * @param {unknown} arg_1\n\t * @param {unknown} [arg_2]\n\t * @param {Function} [arg_3]\n\t * @returns {unknown}\n\t */\n\tstartActiveSpan(_name, arg_1, arg_2, arg_3) {\n\t\tif (typeof arg_1 === 'function') {\n\t\t\treturn arg_1(noop_span);\n\t\t}\n\t\tif (typeof arg_2 === 'function') {\n\t\t\treturn arg_2(noop_span);\n\t\t}\n\t\tif (typeof arg_3 === 'function') {\n\t\t\treturn arg_3(noop_span);\n\t\t}\n\t}\n};\n\n/**\n * @type {Span}\n */\nexport const noop_span = {\n\tspanContext() {\n\t\treturn noop_span_context;\n\t},\n\tsetAttribute() {\n\t\treturn this;\n\t},\n\tsetAttributes() {\n\t\treturn this;\n\t},\n\taddEvent() {\n\t\treturn this;\n\t},\n\tsetStatus() {\n\t\treturn this;\n\t},\n\tupdateName() {\n\t\treturn this;\n\t},\n\tend() {\n\t\treturn this;\n\t},\n\tisRecording() {\n\t\treturn false;\n\t},\n\trecordException() {\n\t\treturn this;\n\t},\n\taddLink() {\n\t\treturn this;\n\t},\n\taddLinks() {\n\t\treturn this;\n\t}\n};\n\n/**\n * @type {SpanContext}\n */\nconst noop_span_context = {\n\ttraceId: '',\n\tspanId: '',\n\ttraceFlags: 0\n};\n"
  },
  {
    "path": "packages/kit/src/runtime/telemetry/otel.disabled.spec.js",
    "content": "import { test, expect, vi } from 'vitest';\nimport { otel } from './otel.js';\n\nvi.hoisted(() => {\n\tvi.stubGlobal('__SVELTEKIT_SERVER_TRACING_ENABLED__', false);\n});\n\ntest('otel should be null when tracing is disabled', () => {\n\texpect(otel).toBeNull();\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/telemetry/otel.enabled.spec.js",
    "content": "import { test, expect, vi } from 'vitest';\nimport { otel } from './otel.js';\n\nvi.hoisted(() => {\n\tvi.stubGlobal('__SVELTEKIT_SERVER_TRACING_ENABLED__', true);\n});\n\ntest('otel should be defined when tracing is enabled', () => {\n\texpect(otel).not.toBeNull();\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/telemetry/otel.js",
    "content": "/** @import { Tracer, SpanStatusCode, PropagationAPI, ContextAPI } from '@opentelemetry/api' */\n\n/** @type {Promise<{ tracer: Tracer, SpanStatusCode: typeof SpanStatusCode, propagation: PropagationAPI, context: ContextAPI }> | null} */\nexport let otel = null;\n\nif (__SVELTEKIT_SERVER_TRACING_ENABLED__) {\n\totel = import('@opentelemetry/api')\n\t\t.then((module) => {\n\t\t\treturn {\n\t\t\t\ttracer: module.trace.getTracer('sveltekit'),\n\t\t\t\tpropagation: module.propagation,\n\t\t\t\tcontext: module.context,\n\t\t\t\tSpanStatusCode: module.SpanStatusCode\n\t\t\t};\n\t\t})\n\t\t.catch(() => {\n\t\t\tthrow new Error(\n\t\t\t\t'Tracing is enabled (see `config.kit.experimental.instrumentation.server` in your svelte.config.js), but `@opentelemetry/api` is not available. This error will likely resolve itself when you set up your tracing instrumentation in `instrumentation.server.js`. For more information, see https://svelte.dev/docs/kit/observability#opentelemetry-api'\n\t\t\t);\n\t\t});\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/telemetry/otel.missing.spec.js",
    "content": "import { test, expect, vi } from 'vitest';\n\nvi.hoisted(() => {\n\tvi.stubGlobal('__SVELTEKIT_SERVER_TRACING_ENABLED__', true);\n});\n\nvi.mock('@opentelemetry/api', () => {\n\tthrow new Error('Not available');\n});\n\ntest('otel should throw an error when tracing is enabled but @opentelemetry/api is not available', async () => {\n\tconst { otel } = await import('./otel.js');\n\tawait expect(otel).rejects.toThrow(\n\t\t'Tracing is enabled (see `config.kit.experimental.instrumentation.server` in your svelte.config.js), but `@opentelemetry/api` is not available. This error will likely resolve itself when you set up your tracing instrumentation in `instrumentation.server.js`. For more information, see https://svelte.dev/docs/kit/observability#opentelemetry-api'\n\t);\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/telemetry/record_span.disabled.spec.js",
    "content": "import { test, expect, vi } from 'vitest';\nimport { record_span } from './record_span.js';\nimport { noop_span } from './noop.js';\n\nvi.hoisted(() => {\n\tvi.stubGlobal('__SVELTEKIT_SERVER_TRACING_ENABLED__', false);\n});\n\ntest('it runs function with noop span if @opentelemetry/api is not available', async () => {\n\tconst fn = vi.fn().mockResolvedValue('result');\n\n\tconst result = await record_span({ name: 'test', attributes: {}, fn });\n\texpect(result).toBe('result');\n\texpect(fn).toHaveBeenCalledWith(noop_span);\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/telemetry/record_span.enabled.spec.js",
    "content": "/** @import { Span, Tracer } from '@opentelemetry/api' */\nimport { describe, test, expect, vi, beforeEach } from 'vitest';\nimport { record_span } from './record_span.js';\nimport { HttpError, Redirect } from '@sveltejs/kit/internal';\n\nvi.hoisted(() => {\n\tvi.stubGlobal('__SVELTEKIT_SERVER_TRACING_ENABLED__', true);\n});\n\nconst { tracer, span } = vi.hoisted(() => {\n\tconst mock_span = /** @type {Span} */ (\n\t\t/** @type {unknown} */ ({\n\t\t\tend: vi.fn(),\n\t\t\tsetAttributes: vi.fn(),\n\t\t\tsetStatus: vi.fn(),\n\t\t\trecordException: vi.fn()\n\t\t})\n\t);\n\n\tconst mock_tracer = /** @type {Tracer} */ ({\n\t\tstartActiveSpan: vi.fn((_name, _options, fn) => {\n\t\t\treturn fn(span);\n\t\t}),\n\t\tstartSpan: vi.fn((_name, _options, fn) => {\n\t\t\treturn fn(span);\n\t\t})\n\t});\n\n\treturn { tracer: mock_tracer, span: mock_span };\n});\n\nvi.mock(import('./otel.js'), async (original) => {\n\tconst { otel: unresolved_otel } = await original();\n\tconst otel = await unresolved_otel;\n\n\tif (otel === null) {\n\t\tthrow new Error('Problem setting up tests; otel is null');\n\t}\n\n\treturn {\n\t\totel: Promise.resolve({\n\t\t\ttracer,\n\t\t\tSpanStatusCode: otel.SpanStatusCode,\n\t\t\tpropagation: otel.propagation,\n\t\t\tcontext: otel.context\n\t\t})\n\t};\n});\n\ndescribe('record_span', () => {\n\tbeforeEach(() => {\n\t\tvi.resetAllMocks();\n\t});\n\n\ttest('successful function returns result, attaching correct attributes', async () => {\n\t\tconst fn = vi.fn(() => Promise.resolve('result'));\n\t\tconst result = await record_span({\n\t\t\tname: 'test',\n\t\t\tattributes: { 'test-attribute': true },\n\t\t\tfn\n\t\t});\n\t\texpect(result).toBe('result');\n\t\texpect(tracer.startActiveSpan).toHaveBeenCalledWith(\n\t\t\t'test',\n\t\t\t{ attributes: { 'test-attribute': true } },\n\t\t\texpect.any(Function)\n\t\t);\n\t\texpect(span.end).toHaveBeenCalled();\n\t});\n\n\ttest('HttpError sets correct attributes and re-throw, does set status for >=500', async () => {\n\t\tconst error = new HttpError(500, 'Found but badly');\n\t\tconst error_fn = vi.fn(() => Promise.reject(error));\n\n\t\tawait expect(\n\t\t\trecord_span({\n\t\t\t\tname: 'test',\n\t\t\t\tattributes: {},\n\t\t\t\tfn: error_fn\n\t\t\t})\n\t\t).rejects.toBe(error);\n\n\t\texpect(span.setAttributes).toHaveBeenCalledWith({\n\t\t\t'test.result.type': 'known_error',\n\t\t\t'test.result.status': 500,\n\t\t\t'test.result.message': 'Found but badly'\n\t\t});\n\t\texpect(span.recordException).toHaveBeenCalledWith({\n\t\t\tname: 'HttpError',\n\t\t\tmessage: 'Found but badly'\n\t\t});\n\t\texpect(span.setStatus).toHaveBeenCalledWith({\n\t\t\tcode: expect.any(Number),\n\t\t\tmessage: 'Found but badly'\n\t\t});\n\t\texpect(span.end).toHaveBeenCalled();\n\t});\n\n\ttest('HttpError sets correct attributes and re-throws, does not set status for <500', async () => {\n\t\tconst error = new HttpError(404, 'Not found');\n\t\tconst error_fn = vi.fn(() => Promise.reject(error));\n\n\t\tawait expect(\n\t\t\trecord_span({\n\t\t\t\tname: 'test',\n\t\t\t\tattributes: {},\n\t\t\t\tfn: error_fn\n\t\t\t})\n\t\t).rejects.toBe(error);\n\n\t\texpect(span.setAttributes).toHaveBeenCalledWith({\n\t\t\t'test.result.type': 'known_error',\n\t\t\t'test.result.status': 404,\n\t\t\t'test.result.message': 'Not found'\n\t\t});\n\t\texpect(span.end).toHaveBeenCalled();\n\t});\n\n\ttest('Redirect sets correct attributes and re-throws', async () => {\n\t\tconst error = new Redirect(302, '/redirect-location');\n\t\tconst error_fn = vi.fn(() => Promise.reject(error));\n\n\t\tawait expect(\n\t\t\trecord_span({\n\t\t\t\tname: 'test',\n\t\t\t\tattributes: {},\n\t\t\t\tfn: error_fn\n\t\t\t})\n\t\t).rejects.toBe(error);\n\n\t\texpect(span.setAttributes).toHaveBeenCalledWith({\n\t\t\t'test.result.type': 'redirect',\n\t\t\t'test.result.status': 302,\n\t\t\t'test.result.location': '/redirect-location'\n\t\t});\n\t\texpect(span.setStatus).not.toHaveBeenCalled();\n\t\texpect(span.end).toHaveBeenCalled();\n\t});\n\n\ttest('Generic Error sets correct attributes and re-throws', async () => {\n\t\tconst error = new Error('Something went wrong');\n\t\tconst error_fn = vi.fn(() => Promise.reject(error));\n\n\t\tawait expect(\n\t\t\trecord_span({\n\t\t\t\tname: 'test',\n\t\t\t\tattributes: {},\n\t\t\t\tfn: error_fn\n\t\t\t})\n\t\t).rejects.toThrow(error);\n\n\t\texpect(span.setAttributes).toHaveBeenCalledWith({\n\t\t\t'test.result.type': 'unknown_error'\n\t\t});\n\t\texpect(span.recordException).toHaveBeenCalledWith({\n\t\t\tname: 'Error',\n\t\t\tmessage: 'Something went wrong',\n\t\t\tstack: error.stack\n\t\t});\n\t\texpect(span.setStatus).toHaveBeenCalledWith({\n\t\t\tcode: expect.any(Number),\n\t\t\tmessage: 'Something went wrong'\n\t\t});\n\t\texpect(span.end).toHaveBeenCalled();\n\t});\n\n\ttest('Non-Error object sets correct attributes and re-throws', async () => {\n\t\tconst error = 'string error';\n\t\tconst error_fn = vi.fn(() => Promise.reject(error));\n\n\t\tawait expect(\n\t\t\trecord_span({\n\t\t\t\tname: 'test',\n\t\t\t\tattributes: {},\n\t\t\t\tfn: error_fn\n\t\t\t})\n\t\t).rejects.toThrow(error);\n\n\t\texpect(span.setAttributes).toHaveBeenCalledWith({\n\t\t\t'test.result.type': 'unknown_error'\n\t\t});\n\t\texpect(span.setStatus).toHaveBeenCalledWith({\n\t\t\tcode: expect.any(Number)\n\t\t});\n\t\texpect(span.end).toHaveBeenCalled();\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/runtime/telemetry/record_span.js",
    "content": "/** @import { RecordSpan } from 'types' */\nimport { HttpError, Redirect } from '@sveltejs/kit/internal';\nimport { noop_span } from './noop.js';\nimport { otel } from './otel.js';\n\n/** @type {RecordSpan} */\nexport async function record_span({ name, attributes, fn }) {\n\tif (otel === null) {\n\t\treturn fn(noop_span);\n\t}\n\n\tconst { SpanStatusCode, tracer } = await otel;\n\n\treturn tracer.startActiveSpan(name, { attributes }, async (span) => {\n\t\ttry {\n\t\t\treturn await fn(span);\n\t\t} catch (error) {\n\t\t\tif (error instanceof HttpError) {\n\t\t\t\tspan.setAttributes({\n\t\t\t\t\t[`${name}.result.type`]: 'known_error',\n\t\t\t\t\t[`${name}.result.status`]: error.status,\n\t\t\t\t\t[`${name}.result.message`]: error.body.message\n\t\t\t\t});\n\t\t\t\tif (error.status >= 500) {\n\t\t\t\t\tspan.recordException({\n\t\t\t\t\t\tname: 'HttpError',\n\t\t\t\t\t\tmessage: error.body.message\n\t\t\t\t\t});\n\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\t\t\t\tmessage: error.body.message\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if (error instanceof Redirect) {\n\t\t\t\tspan.setAttributes({\n\t\t\t\t\t[`${name}.result.type`]: 'redirect',\n\t\t\t\t\t[`${name}.result.status`]: error.status,\n\t\t\t\t\t[`${name}.result.location`]: error.location\n\t\t\t\t});\n\t\t\t} else if (error instanceof Error) {\n\t\t\t\tspan.setAttributes({\n\t\t\t\t\t[`${name}.result.type`]: 'unknown_error'\n\t\t\t\t});\n\t\t\t\tspan.recordException({\n\t\t\t\t\tname: error.name,\n\t\t\t\t\tmessage: error.message,\n\t\t\t\t\tstack: error.stack\n\t\t\t\t});\n\t\t\t\tspan.setStatus({\n\t\t\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\t\t\tmessage: error.message\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tspan.setAttributes({\n\t\t\t\t\t[`${name}.result.type`]: 'unknown_error'\n\t\t\t\t});\n\t\t\t\tspan.setStatus({ code: SpanStatusCode.ERROR });\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tspan.end();\n\t\t}\n\t});\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/utils.js",
    "content": "import { BROWSER } from 'esm-env';\n\nexport const text_encoder = new TextEncoder();\nexport const text_decoder = new TextDecoder();\n\n/**\n * Like node's path.relative, but without using node\n * @param {string} from\n * @param {string} to\n */\nexport function get_relative_path(from, to) {\n\tconst from_parts = from.split(/[/\\\\]/);\n\tconst to_parts = to.split(/[/\\\\]/);\n\tfrom_parts.pop(); // get dirname\n\n\twhile (from_parts[0] === to_parts[0]) {\n\t\tfrom_parts.shift();\n\t\tto_parts.shift();\n\t}\n\n\tlet i = from_parts.length;\n\twhile (i--) from_parts[i] = '..';\n\n\treturn from_parts.concat(to_parts).join('/');\n}\n\n/**\n * @param {Uint8Array} bytes\n * @returns {string}\n */\nexport function base64_encode(bytes) {\n\t// Using `Buffer` is faster than iterating\n\tif (!BROWSER && globalThis.Buffer) {\n\t\treturn globalThis.Buffer.from(bytes).toString('base64');\n\t}\n\n\tlet binary = '';\n\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\tbinary += String.fromCharCode(bytes[i]);\n\t}\n\n\treturn btoa(binary);\n}\n\n/**\n * @param {string} encoded\n * @returns {Uint8Array}\n */\nexport function base64_decode(encoded) {\n\t// Using `Buffer` is faster than iterating\n\tif (!BROWSER && globalThis.Buffer) {\n\t\tconst buffer = globalThis.Buffer.from(encoded, 'base64');\n\t\treturn new Uint8Array(buffer);\n\t}\n\n\tconst binary = atob(encoded);\n\tconst bytes = new Uint8Array(binary.length);\n\n\tfor (let i = 0; i < binary.length; i++) {\n\t\tbytes[i] = binary.charCodeAt(i);\n\t}\n\n\treturn bytes;\n}\n"
  },
  {
    "path": "packages/kit/src/runtime/utils.spec.js",
    "content": "import { afterEach, assert, beforeEach, describe, expect, test } from 'vitest';\nimport { base64_decode, base64_encode, text_encoder } from './utils.js';\n\nconst inputs = [\n\t'hello world',\n\t'',\n\t'abcd',\n\t'the quick brown fox jumps over the lazy dog',\n\t'工欲善其事，必先利其器'\n];\n\nconst buffer = globalThis.Buffer;\n\ndescribe('base64_encode', () => {\n\tbeforeEach(() => {\n\t\t// @ts-expect-error\n\t\tdelete globalThis.Buffer;\n\t});\n\n\tafterEach(() => {\n\t\tglobalThis.Buffer = buffer;\n\t});\n\n\ttest.each(inputs)('%s', (input) => {\n\t\tconst expected = buffer.from(input).toString('base64');\n\n\t\tconst actual = base64_encode(text_encoder.encode(input));\n\t\tassert.equal(actual, expected);\n\t});\n});\n\ndescribe('base64_decode', () => {\n\tbeforeEach(() => {\n\t\t// @ts-expect-error\n\t\tdelete globalThis.Buffer;\n\t});\n\n\tafterEach(() => {\n\t\tglobalThis.Buffer = buffer;\n\t});\n\n\ttest.each(inputs)('%s', (input) => {\n\t\tconst encoded = buffer.from(input).toString('base64');\n\n\t\tconst actual = base64_decode(encoded);\n\t\texpect(actual).toEqual(text_encoder.encode(input));\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/types/ambient-private.d.ts",
    "content": "/** Internal version of $app/environment */\ndeclare module '__sveltekit/environment' {\n\texport const building: boolean;\n\texport const prerendering: boolean;\n\texport const version: string;\n\texport function set_building(): void;\n\texport function set_prerendering(): void;\n}\n\n/** Internal version of $app/paths */\ndeclare module '__sveltekit/paths' {\n\texport let base: '' | `/${string}`;\n\texport let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit_assets';\n\texport let app_dir: string;\n\texport let relative: boolean;\n\texport function reset(): void;\n\texport function override(paths: { base: string; assets: string }): void;\n\texport function set_assets(path: string): void;\n}\n\n/** Internal version of $app/server */\ndeclare module '__sveltekit/server' {\n\timport { SSRManifest } from '@sveltejs/kit';\n\n\texport let manifest: SSRManifest;\n\texport function read_implementation(path: string): ReadableStream;\n\texport function set_manifest(manifest: SSRManifest): void;\n\texport function set_read_implementation(fn: (path: string) => ReadableStream): void;\n}\n"
  },
  {
    "path": "packages/kit/src/types/ambient.d.ts",
    "content": "/**\n * 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:\n *\n * ```ts\n * declare global {\n * \tnamespace App {\n * \t\t// interface Error {}\n * \t\t// interface Locals {}\n * \t\t// interface PageData {}\n * \t\t// interface PageState {}\n * \t\t// interface Platform {}\n * \t}\n * }\n *\n * export {};\n * ```\n *\n * The `export {}` line exists because without it, the file would be treated as an _ambient module_ which prevents you from adding `import` declarations.\n * If you need to add ambient `declare module` declarations, do so in a separate file like `src/ambient.d.ts`.\n *\n * By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions.\n */\ndeclare namespace App {\n\t/**\n\t * 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.\n\t */\n\texport interface Error {\n\t\tmessage: string;\n\t}\n\n\t/**\n\t * The interface that defines `event.locals`, which can be accessed in server [hooks](https://svelte.dev/docs/kit/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files.\n\t */\n\texport interface Locals {}\n\n\t/**\n\t * Defines the common shape of the [page.data state](https://svelte.dev/docs/kit/$app-state#page) and [$page.data store](https://svelte.dev/docs/kit/$app-stores#page) - that is, the data that is shared between all pages.\n\t * The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.\n\t * Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).\n\t */\n\texport interface PageData {}\n\n\t/**\n\t * The shape of the `page.state` object, which can be manipulated using the [`pushState`](https://svelte.dev/docs/kit/$app-navigation#pushState) and [`replaceState`](https://svelte.dev/docs/kit/$app-navigation#replaceState) functions from `$app/navigation`.\n\t */\n\texport interface PageState {}\n\n\t/**\n\t * If your adapter provides [platform-specific context](https://svelte.dev/docs/kit/adapters#Platform-specific-context) via `event.platform`, you can specify it here.\n\t */\n\texport interface Platform {}\n}\n\n/**\n * This module is only available to [service workers](https://svelte.dev/docs/kit/service-workers).\n */\ndeclare module '$service-worker' {\n\t/**\n\t * 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.\n\t * Note that there is a `base` but no `assets`, since service workers cannot be used if `config.kit.paths.assets` is specified.\n\t */\n\texport const base: string;\n\t/**\n\t * An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`.\n\t * During development, this is an empty array.\n\t */\n\texport const build: string[];\n\t/**\n\t * 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://svelte.dev/docs/kit/configuration#serviceWorker)\n\t */\n\texport const files: string[];\n\t/**\n\t * An array of pathnames corresponding to prerendered pages and endpoints.\n\t * During development, this is an empty array.\n\t */\n\texport const prerendered: string[];\n\t/**\n\t * See [`config.kit.version`](https://svelte.dev/docs/kit/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.\n\t */\n\texport const version: string;\n}\n\n/**\n * This module contains generated types for the routes in your app.\n */\ndeclare module '$app/types' {\n\t/**\n\t * Interface for all generated app types. This gets extended via declaration merging. DO NOT USE THIS INTERFACE DIRECTLY.\n\t */\n\texport interface AppTypes {\n\t\t// These are all functions so that we can leverage function overloads to get the correct type.\n\t\t// Using the return types directly would error with a \"not the same type\" error.\n\t\t// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces\n\t\tRouteId(): string;\n\t\tRouteParams(): Record<string, Record<string, string>>;\n\t\tLayoutParams(): Record<string, Record<string, string>>;\n\t\tPathname(): string;\n\t\tResolvedPathname(): string;\n\t\tAsset(): string;\n\t}\n\n\t/**\n\t * A union of all the route IDs in your app. Used for `page.route.id` and `event.route.id`.\n\t */\n\texport type RouteId = ReturnType<AppTypes['RouteId']>;\n\n\t/**\n\t * `RouteId`, but possibly suffixed with a search string and/or hash.\n\t */\n\texport type RouteIdWithSearchOrHash = RouteId | `${RouteId}?${string}` | `${RouteId}#${string}`;\n\n\t/**\n\t * A utility for getting the parameters associated with a given route.\n\t */\n\texport type RouteParams<T extends RouteId> = T extends keyof ReturnType<AppTypes['RouteParams']>\n\t\t? ReturnType<AppTypes['RouteParams']>[T]\n\t\t: Record<string, never>;\n\n\t/**\n\t * A utility for getting the parameters associated with a given layout, which is similar to `RouteParams` but also includes optional parameters for any child route.\n\t */\n\texport type LayoutParams<T extends RouteId> = T extends keyof ReturnType<AppTypes['LayoutParams']>\n\t\t? ReturnType<AppTypes['LayoutParams']>[T]\n\t\t: Record<string, never>;\n\n\t/**\n\t * A union of all valid pathnames in your app.\n\t */\n\texport type Pathname = ReturnType<AppTypes['Pathname']>;\n\n\t/**\n\t * `Pathname`, but possibly suffixed with a search string and/or hash.\n\t */\n\texport type PathnameWithSearchOrHash =\n\t\t| Pathname\n\t\t| `${Pathname}?${string}`\n\t\t| `${Pathname}#${string}`;\n\n\t/**\n\t * `Pathname`, but possibly prefixed with a base path. Used for `page.url.pathname`.\n\t */\n\texport type ResolvedPathname = ReturnType<AppTypes['ResolvedPathname']>;\n\n\t/**\n\t * A union of all the filenames of assets contained in your `static` directory.\n\t */\n\texport type Asset = ReturnType<AppTypes['Asset']>;\n}\n"
  },
  {
    "path": "packages/kit/src/types/global-private.d.ts",
    "content": "declare global {\n\tconst __SVELTEKIT_ADAPTER_NAME__: string;\n\tconst __SVELTEKIT_APP_DIR__: string;\n\tconst __SVELTEKIT_APP_VERSION_FILE__: string;\n\tconst __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: number;\n\tconst __SVELTEKIT_EMBEDDED__: boolean;\n\tconst __SVELTEKIT_PATHS_ASSETS__: string;\n\tconst __SVELTEKIT_PATHS_BASE__: string;\n\tconst __SVELTEKIT_PATHS_RELATIVE__: boolean;\n\t/** True if `config.kit.experimental.instrumentation.server` is `true` */\n\tconst __SVELTEKIT_SERVER_TRACING_ENABLED__: boolean;\n\t/** true if corresponding config option is set to true */\n\tconst __SVELTEKIT_EXPERIMENTAL__REMOTE_FUNCTIONS__: boolean;\n\t/** True if `config.kit.experimental.forkPreloads` is `true` */\n\tconst __SVELTEKIT_FORK_PRELOADS__: boolean;\n\t/** True if `config.kit.router.resolution === 'client'` */\n\tconst __SVELTEKIT_CLIENT_ROUTING__: boolean;\n\t/** True if `config.kit.router.type === 'hash'` */\n\tconst __SVELTEKIT_HASH_ROUTING__: boolean;\n\t/**\n\t * True if any node in the manifest has a server load function.\n\t * Used for treeshaking server load code from client bundles when no server loads exist.\n\t */\n\tconst __SVELTEKIT_HAS_SERVER_LOAD__: boolean;\n\t/**\n\t * True if any node in the manifest has a universal load function.\n\t * Used for treeshaking universal load code from client bundles when no universal loads exist.\n\t */\n\tconst __SVELTEKIT_HAS_UNIVERSAL_LOAD__: boolean;\n\t/** The `__sveltekit_abc123` object in the init `<script>` */\n\tconst __SVELTEKIT_PAYLOAD__: {\n\t\t/** The basepath, usually relative to the current page */\n\t\tbase: string;\n\t\t/** Path to externally-hosted assets */\n\t\tassets?: string;\n\t\t/** Public environment variables */\n\t\tenv?: Record<string, string>;\n\t\t/** Serialized data from query/form/command functions */\n\t\tquery?: Record<string, any>;\n\t\t/** Serialized data from prerender functions */\n\t\tprerender?: Record<string, any>;\n\t\t/** Create a placeholder promise */\n\t\tdefer?: (id: number) => Promise<any>;\n\t\t/** Resolve a placeholder promise */\n\t\tresolve?: (data: { id: number; data: any; error: any }) => void;\n\t};\n\t/**\n\t * This makes the use of specific features visible at both dev and build time, in such a\n\t * way that we can error when they are not supported by the target platform.\n\t *\n\t * During dev, `globalThis.__SVELTEKIT_TRACK__` is a function that grabs the current `event`\n\t * and route `config` (from an AsyncLocalStorage instance) and calls the relevant `supports`\n\t * function on the adapter (e.g. `adapter.supports.read(...)`).\n\t *\n\t * At build time, if the function containing the `__SVELTEKIT_TRACK__` call is untreeshaken,\n\t * we locate it in the `renderChunk` build hook and a) make a note of the chunk that contains\n\t * it and b) replace it with a comment. Later, we can use this information to establish\n\t * which routes use which feature, and use the same `adapter.supports.read(...)` function\n\t * to throw an error if the feature would fail in production.\n\t */\n\tvar __SVELTEKIT_TRACK__: (label: string) => void;\n\tvar __SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__: boolean;\n\tvar Bun: object;\n\tvar Deno: object;\n}\n\nexport {};\n"
  },
  {
    "path": "packages/kit/src/types/internal.d.ts",
    "content": "import { SvelteComponent } from 'svelte';\nimport {\n\tConfig,\n\tServerLoad,\n\tHandle,\n\tHandleServerError,\n\tKitConfig,\n\tLoad,\n\tRequestHandler,\n\tResolveOptions,\n\tServer,\n\tServerInitOptions,\n\tHandleFetch,\n\tActions,\n\tHandleClientError,\n\tReroute,\n\tRequestEvent,\n\tSSRManifest,\n\tEmulator,\n\tAdapter,\n\tServerInit,\n\tClientInit,\n\tTransport,\n\tHandleValidationError,\n\tRemoteFormIssue\n} from '@sveltejs/kit';\nimport {\n\tHttpMethod,\n\tMaybePromise,\n\tPrerenderOption,\n\tRequestOptions,\n\tTrailingSlash\n} from './private.js';\nimport { Span } from '@opentelemetry/api';\nimport type { PageOptions } from '../exports/vite/static_analysis/index.js';\n\nexport interface ServerModule {\n\tServer: typeof InternalServer;\n}\n\nexport interface ServerInternalModule {\n\tset_assets(path: string): void;\n\tset_building(): void;\n\tset_manifest(manifest: SSRManifest): void;\n\tset_prerendering(): void;\n\tset_private_env(environment: Record<string, string>): void;\n\tset_public_env(environment: Record<string, string>): void;\n\tset_read_implementation(implementation: (path: string) => ReadableStream): void;\n\tset_version(version: string): void;\n\tset_fix_stack_trace(fix_stack_trace: (error: unknown) => string): void;\n\tget_hooks: () => Promise<Record<string, any>>;\n}\n\nexport interface Asset {\n\tfile: string;\n\tsize: number;\n\ttype: string | null;\n}\n\nexport interface AssetDependencies {\n\tassets: string[];\n\tfile: string;\n\timports: string[];\n\tstylesheets: string[];\n\tfonts: string[];\n\tstylesheet_map: Map<string, { css: Set<string>; assets: Set<string> }>;\n}\n\nexport interface BuildData {\n\tapp_dir: string;\n\tapp_path: string;\n\tmanifest_data: ManifestData;\n\tout_dir: string;\n\tservice_worker: string | null;\n\tclient: {\n\t\t/** Path to the client entry point. */\n\t\tstart: string;\n\t\t/** Path to the generated `app.js` file that contains the client manifest. Only set in case of `bundleStrategy === 'split'`. */\n\t\tapp?: string;\n\t\t/** JS files that the client entry point relies on. */\n\t\timports: string[];\n\t\t/**\n\t\t * JS files that represent the entry points of the layouts/pages.\n\t\t * An entry is undefined if the layout/page has no component or universal file (i.e. only has a `.server.js` file).\n\t\t * Only set in case of `router.resolution === 'server'`.\n\t\t */\n\t\tnodes?: Array<string | undefined>;\n\t\t/**\n\t\t * CSS files referenced in the entry points of the layouts/pages.\n\t\t * An entry is undefined if the layout/page has no component or universal file (i.e. only has a `.server.js` file) or if has no CSS.\n\t\t * Only set in case of `router.resolution === 'server'`.\n\t\t */\n\t\tcss?: Array<string[] | undefined>;\n\t\t/**\n\t\t * Contains the client route manifest in a form suitable for the server which is used for server-side route resolution.\n\t\t * Notably, it contains all routes, regardless of whether they are prerendered or not (those are missing in the optimized server route manifest).\n\t\t * Only set in case of `router.resolution === 'server'`.\n\t\t */\n\t\troutes?: SSRClientRoute[];\n\t\tstylesheets: string[];\n\t\tfonts: string[];\n\t\tuses_env_dynamic_public: boolean;\n\t\t/** Only set in case of `bundleStrategy === 'inline'`. */\n\t\tinline?: {\n\t\t\tscript: string;\n\t\t\tstyle: string | undefined;\n\t\t};\n\t} | null;\n\tserver_manifest: import('vite').Manifest;\n}\n\nexport interface CSRPageNode {\n\tcomponent: typeof SvelteComponent;\n\tuniversal: {\n\t\tload?: Load;\n\t\ttrailingSlash?: TrailingSlash;\n\t};\n}\n\nexport type CSRPageNodeLoader = () => Promise<CSRPageNode>;\n\n/**\n * Definition of a client side route.\n * The boolean in the tuples indicates whether the route has a server load.\n */\nexport type CSRRoute = {\n\tid: string;\n\texec(path: string): undefined | Record<string, string>;\n\terrors: Array<CSRPageNodeLoader | undefined>;\n\tlayouts: Array<[has_server_load: boolean, node_loader: CSRPageNodeLoader] | undefined>;\n\tleaf: [has_server_load: boolean, node_loader: CSRPageNodeLoader];\n};\n\n/**\n * Definition of a client side route as transported via `<pathname>/__route.js` when using server-side route resolution.\n */\nexport type CSRRouteServer = {\n\tid: string;\n\terrors: Array<number | undefined>;\n\tlayouts: Array<[has_server_load: boolean, node_id: number] | undefined>;\n\tleaf: [has_server_load: boolean, node_id: number];\n\tnodes: Record<string, CSRPageNodeLoader>;\n};\n\nexport interface Deferred {\n\tfulfil: (value: any) => void;\n\treject: (error: Error) => void;\n}\n\nexport type GetParams = (match: RegExpExecArray) => Record<string, string>;\n\nexport interface ServerHooks {\n\thandleFetch: HandleFetch;\n\thandle: Handle;\n\thandleError: HandleServerError;\n\thandleValidationError: HandleValidationError;\n\treroute: Reroute;\n\ttransport: Transport;\n\tinit?: ServerInit;\n}\n\nexport interface ClientHooks {\n\thandleError: HandleClientError;\n\treroute: Reroute;\n\ttransport: Transport;\n\tinit?: ClientInit;\n}\n\nexport interface Env {\n\tprivate: Record<string, string>;\n\tpublic: Record<string, string>;\n}\n\nexport class InternalServer extends Server {\n\tinit(options: ServerInitOptions): Promise<void>;\n\trespond(\n\t\trequest: Request,\n\t\toptions: RequestOptions & {\n\t\t\tprerendering?: PrerenderOptions;\n\t\t\tread: (file: string) => NonSharedBuffer;\n\t\t\t/** A hook called before `handle` during dev, so that `AsyncLocalStorage` can be populated. */\n\t\t\tbefore_handle?: (event: RequestEvent, config: any, prerender: PrerenderOption) => void;\n\t\t\temulator?: Emulator;\n\t\t}\n\t): Promise<Response>;\n}\n\nexport interface ManifestData {\n\t/** Static files from `kit.config.files.assets`. */\n\tassets: Asset[];\n\thooks: {\n\t\tclient: string | null;\n\t\tserver: string | null;\n\t\tuniversal: string | null;\n\t};\n\tnodes: PageNode[];\n\troutes: RouteData[];\n\tmatchers: Record<string, string>;\n}\n\nexport interface RemoteChunk {\n\thash: string;\n\tfile: string;\n}\n\nexport interface PageNode {\n\tdepth: number;\n\t/** The `+page/layout.svelte`. */\n\tcomponent?: string; // TODO supply default component if it's missing (bit of an edge case)\n\t/** The `+page/layout.js/.ts`. */\n\tuniversal?: string;\n\t/** The `+page/layout.server.js/ts`. */\n\tserver?: string;\n\tparent_id?: string;\n\tparent?: PageNode;\n\t/** Filled with the pages that reference this layout (if this is a layout). */\n\tchild_pages?: PageNode[];\n\t/** The final page options for a node if it was statically analysable */\n\tpage_options?: PageOptions | null;\n}\n\nexport interface PrerenderDependency {\n\tresponse: Response;\n\tbody: null | string | Uint8Array;\n}\n\nexport interface PrerenderOptions {\n\tcache?: string; // including this here is a bit of a hack, but it makes it easy to add <meta http-equiv>\n\tfallback?: boolean;\n\tdependencies: Map<string, PrerenderDependency>;\n\t/**\n\t * For each key the (possibly still pending) result of a prerendered remote function.\n\t * Used to deduplicate requests to the same remote function with the same arguments.\n\t */\n\tremote_responses: Map<string, Promise<any>>;\n\t/** True for the duration of a call to the `reroute` hook */\n\tinside_reroute?: boolean;\n}\n\nexport type RecursiveRequired<T> = {\n\t// Recursive implementation of TypeScript's Required utility type.\n\t// Will recursively continue until it reaches a primitive or Function\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n\t[K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type\n\t\t? RecursiveRequired<T[K]> // recursively continue through.\n\t\t: T[K]; // Use the exact type for everything else\n};\n\nexport type RequiredResolveOptions = Required<ResolveOptions>;\n\nexport interface RouteParam {\n\tname: string;\n\tmatcher: string;\n\toptional: boolean;\n\trest: boolean;\n\tchained: boolean;\n}\n\n/**\n * Represents a route segment in the app. It can either be an intermediate node\n * with only layout/error pages, or a leaf, at which point either `page` and `leaf`\n * or `endpoint` is set.\n */\nexport interface RouteData {\n\tid: string;\n\tparent: RouteData | null;\n\n\tsegment: string;\n\tpattern: RegExp;\n\tparams: RouteParam[];\n\n\tlayout: PageNode | null;\n\terror: PageNode | null;\n\tleaf: PageNode | null;\n\n\tpage: {\n\t\tlayouts: Array<number | undefined>;\n\t\terrors: Array<number | undefined>;\n\t\tleaf: number;\n\t} | null;\n\n\tendpoint: {\n\t\tfile: string;\n\t\t/** The final page options for the endpoint if it was statically analysable */\n\t\tpage_options: PageOptions | null;\n\t} | null;\n}\n\nexport type ServerRedirectNode = {\n\ttype: 'redirect';\n\tlocation: string;\n};\n\nexport type ServerNodesResponse = {\n\ttype: 'data';\n\t/**\n\t * If `null`, then there was no load function <- TODO is this outdated now with the recent changes?\n\t */\n\tnodes: Array<ServerDataNode | ServerDataSkippedNode | ServerErrorNode | null>;\n};\n\nexport type RemoteFunctionResponse =\n\t| (ServerRedirectNode & {\n\t\t\t/** devalue'd Record<string, any> */\n\t\t\trefreshes?: string;\n\t  })\n\t| ServerErrorNode\n\t| {\n\t\t\ttype: 'result';\n\t\t\tresult: string;\n\t\t\t/** devalue'd Record<string, any> */\n\t\t\trefreshes: string | undefined;\n\t  };\n\n/**\n * Signals a successful response of the server `load` function.\n * The `uses` property tells the client when it's possible to reuse this data\n * in a subsequent request.\n */\nexport interface ServerDataNode {\n\ttype: 'data';\n\t/**\n\t * The serialized version of this contains a serialized representation of any deferred promises,\n\t * which will be resolved later through chunk nodes.\n\t */\n\tdata: Record<string, any> | null;\n\tuses: Uses;\n\tslash?: TrailingSlash;\n}\n\n/**\n * Resolved data/error of a deferred promise.\n */\nexport interface ServerDataChunkNode {\n\ttype: 'chunk';\n\tid: number;\n\tdata?: Record<string, any>;\n\terror?: any;\n}\n\n/**\n * Signals that the server `load` function was not run, and the\n * client should use what it has in memory.\n */\nexport interface ServerDataSkippedNode {\n\ttype: 'skip';\n}\n\n/**\n * Signals that the server `load` function failed.\n */\nexport interface ServerErrorNode {\n\ttype: 'error';\n\terror: App.Error;\n\t/**\n\t * Only set for HttpErrors.\n\t */\n\tstatus?: number;\n}\n\nexport interface ServerMetadataRoute {\n\tconfig: any;\n\tapi: {\n\t\tmethods: Array<HttpMethod | '*'>;\n\t};\n\tpage: {\n\t\tmethods: Array<'GET' | 'POST'>;\n\t};\n\tmethods: Array<HttpMethod | '*'>;\n\tprerender: PrerenderOption | undefined;\n\tentries: string[] | undefined;\n}\n\nexport interface ServerMetadata {\n\tnodes: Array<{\n\t\t/** Also `true` when using `trailingSlash`, because we need to do a server request in that case to get its value. */\n\t\thas_server_load: boolean;\n\t\thas_universal_load: boolean;\n\t}>;\n\troutes: Map<string, ServerMetadataRoute>;\n\t/** For each hashed remote file, a map of export name -> { type, dynamic }, where `dynamic` is `false` for non-dynamic prerender functions */\n\tremotes: Map<string, Map<string, { type: RemoteInternals['type']; dynamic: boolean }>>;\n}\n\nexport interface SSRComponent {\n\tdefault: {\n\t\trender(\n\t\t\tprops: Record<string, any>,\n\t\t\topts: { context: Map<any, any>; csp?: { nonce?: string; hash?: boolean } }\n\t\t): {\n\t\t\thtml: string;\n\t\t\thead: string;\n\t\t\tcss: {\n\t\t\t\tcode: string;\n\t\t\t\tmap: any; // TODO\n\t\t\t};\n\t\t\t/** Until we require all Svelte versions that support hashes, this might not be defined */\n\t\t\thashes?: {\n\t\t\t\tscript: Array<`sha256-${string}`>;\n\t\t\t};\n\t\t};\n\t};\n}\n\nexport type SSRComponentLoader = () => Promise<SSRComponent>;\n\nexport interface UniversalNode {\n\t/** Is `null` in case static analysis succeeds but the node is ssr=false */\n\tload?: Load;\n\tprerender?: PrerenderOption;\n\tssr?: boolean;\n\tcsr?: boolean;\n\ttrailingSlash?: TrailingSlash;\n\tconfig?: any;\n\tentries?: PrerenderEntryGenerator;\n}\n\nexport interface ServerNode {\n\tload?: ServerLoad;\n\tprerender?: PrerenderOption;\n\tssr?: boolean;\n\tcsr?: boolean;\n\ttrailingSlash?: TrailingSlash;\n\tactions?: Actions;\n\tconfig?: any;\n\tentries?: PrerenderEntryGenerator;\n}\n\nexport interface SSRNode {\n\t/** index into the `nodes` array in the generated `client/app.js`. */\n\tindex: number;\n\t/** external JS files that are loaded on the client. `imports[0]` is the entry point (e.g. `client/nodes/0.js`) */\n\timports: string[];\n\t/** external CSS files that are loaded on the client */\n\tstylesheets: string[];\n\t/** external font files that are loaded on the client */\n\tfonts: string[];\n\n\tuniversal_id?: string;\n\tserver_id?: string;\n\n\t/** inlined styles */\n\tinline_styles?(): MaybePromise<\n\t\tRecord<string, string | ((assets: string, base: string) => string)>\n\t>;\n\t/** Svelte component */\n\tcomponent?: SSRComponentLoader;\n\t/** +page.js or +layout.js */\n\tuniversal?: UniversalNode;\n\t/** +page.server.js, +layout.server.js, or +server.js */\n\tserver?: ServerNode;\n}\n\nexport type SSRNodeLoader = () => Promise<SSRNode>;\n\nexport interface SSROptions {\n\tapp_template_contains_nonce: boolean;\n\tasync: boolean;\n\tcsp: ValidatedConfig['kit']['csp'];\n\tcsrf_check_origin: boolean;\n\tcsrf_trusted_origins: string[];\n\tembedded: boolean;\n\tenv_public_prefix: string;\n\tenv_private_prefix: string;\n\thash_routing: boolean;\n\thooks: ServerHooks;\n\tpreload_strategy: ValidatedConfig['kit']['output']['preloadStrategy'];\n\troot: SSRComponent['default'];\n\tservice_worker: boolean;\n\tservice_worker_options: RegistrationOptions;\n\tserver_error_boundaries: boolean;\n\ttemplates: {\n\t\tapp(values: {\n\t\t\thead: string;\n\t\t\tbody: string;\n\t\t\tassets: string;\n\t\t\tnonce: string;\n\t\t\tenv: Record<string, string>;\n\t\t}): string;\n\t\terror(values: { message: string; status: number }): string;\n\t};\n\tversion_hash: string;\n}\n\nexport interface PageNodeIndexes {\n\terrors: Array<number | undefined>;\n\tlayouts: Array<number | undefined>;\n\tleaf: number;\n}\n\nexport type PrerenderEntryGenerator = () => MaybePromise<Array<Record<string, string>>>;\nexport type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Input[]>;\n\nexport type SSREndpoint = Partial<Record<HttpMethod, RequestHandler>> & {\n\tprerender?: PrerenderOption;\n\ttrailingSlash?: TrailingSlash;\n\tconfig?: any;\n\tentries?: PrerenderEntryGenerator;\n\tfallback?: RequestHandler;\n};\n\nexport interface SSRRoute {\n\tid: string;\n\tpattern: RegExp;\n\tparams: RouteParam[];\n\tpage: PageNodeIndexes | null;\n\tendpoint: (() => Promise<SSREndpoint>) | null;\n\tendpoint_id?: string;\n}\n\nexport interface SSRClientRoute {\n\tid: string;\n\tpattern: RegExp;\n\tparams: RouteParam[];\n\terrors: Array<number | undefined>;\n\tlayouts: Array<[has_server_load: boolean, node_id: number] | undefined>;\n\tleaf: [has_server_load: boolean, node_id: number];\n}\n\nexport interface SSRState {\n\tfallback?: string;\n\tgetClientAddress(): string;\n\t/**\n\t * True if we're currently attempting to render an error page.\n\t */\n\terror: boolean;\n\t/**\n\t * Allows us to prevent `event.fetch` from making infinitely looping internal requests.\n\t */\n\tdepth: number;\n\tplatform?: any;\n\tprerendering?: PrerenderOptions;\n\t/**\n\t * When fetching data from a +server.js endpoint in `load`, the page's\n\t * prerender option is inherited by the endpoint, unless overridden.\n\t */\n\tprerender_default?: PrerenderOption;\n\tread?: (file: string) => NonSharedBuffer;\n\t/**\n\t * Used to set up `__SVELTEKIT_TRACK__` which checks if a used feature is supported.\n\t * E.g. if `read` from `$app/server` is used, it checks whether the route's config is compatible.\n\t */\n\tbefore_handle?: (event: RequestEvent, config: any, prerender: PrerenderOption) => void;\n\temulator?: Emulator;\n}\n\nexport type StrictBody = string | ArrayBufferView;\n\nexport interface Uses {\n\tdependencies: Set<string>;\n\tparams: Set<string>;\n\tparent: boolean;\n\troute: boolean;\n\turl: boolean;\n\tsearch_params: Set<string>;\n}\n\nexport type ValidatedConfig = Config & {\n\tkit: ValidatedKitConfig;\n\textensions: string[];\n};\n\nexport type ValidatedKitConfig = Omit<RecursiveRequired<KitConfig>, 'adapter'> & {\n\tadapter?: Adapter;\n};\n\nexport type BinaryFormMeta = {\n\tremote_refreshes?: string[];\n\tvalidate_only?: boolean;\n};\n\ninterface BaseRemoteInternals {\n\ttype: string;\n\tid: string;\n\tname: string;\n}\n\nexport interface RemoteQueryInternals extends BaseRemoteInternals {\n\ttype: 'query';\n}\nexport interface RemoteQueryLiveInternals extends BaseRemoteInternals {\n\ttype: 'query_live';\n\trun(\n\t\tevent: RequestEvent,\n\t\tstate: RequestState,\n\t\targ: any\n\t): Promise<{ iterator: AsyncIterator<any>; cancel: () => void }>;\n}\n\nexport interface RemoteQueryBatchInternals extends BaseRemoteInternals {\n\ttype: 'query_batch';\n\trun: (args: any[], options: SSROptions) => Promise<any[]>;\n}\n\nexport interface RemoteCommandInternals extends BaseRemoteInternals {\n\ttype: 'command';\n}\n\nexport interface RemoteFormInternals extends BaseRemoteInternals {\n\ttype: 'form';\n\tfn(body: Record<string, any>, meta: BinaryFormMeta, form_data: FormData | null): Promise<any>;\n}\n\nexport interface RemotePrerenderInternals extends BaseRemoteInternals {\n\ttype: 'prerender';\n\thas_arg: boolean;\n\tdynamic?: boolean;\n\tinputs?: RemotePrerenderInputsGenerator;\n}\n\nexport type RemoteInternals =\n\t| RemoteQueryInternals\n\t| RemoteQueryLiveInternals\n\t| RemoteQueryBatchInternals\n\t| RemoteCommandInternals\n\t| RemoteFormInternals\n\t| RemotePrerenderInternals;\n\nexport interface InternalRemoteFormIssue extends RemoteFormIssue {\n\tname: string;\n\tpath: Array<string | number>;\n\tserver?: boolean;\n}\n\nexport type RecordSpan = <T>(options: {\n\tname: string;\n\tattributes: Record<string, any>;\n\tfn: (current: Span) => Promise<T>;\n}) => Promise<T>;\n\n/**\n * Internal state associated with the current `RequestEvent`,\n * used for tracking things like remote function calls\n */\nexport interface RequestState {\n\treadonly prerendering: PrerenderOptions | undefined;\n\treadonly transport: ServerHooks['transport'];\n\treadonly handleValidationError: ServerHooks['handleValidationError'];\n\treadonly tracing: {\n\t\trecord_span: RecordSpan;\n\t};\n\treadonly remote: {\n\t\tdata: null | Map<\n\t\t\tRemoteInternals,\n\t\t\tRecord<string, { serialize: boolean; data: MaybePromise<any> }>\n\t\t>;\n\t\tforms: null | Map<any, any>;\n\t\trefreshes: null | Record<string, Promise<any>>;\n\t};\n\treadonly is_in_remote_function: boolean;\n\treadonly is_in_render: boolean;\n\treadonly is_in_universal_load: boolean;\n}\n\nexport interface RequestStore {\n\tevent: RequestEvent;\n\tstate: RequestState;\n}\n\nexport * from '../exports/index.js';\nexport * from './private.js';\n"
  },
  {
    "path": "packages/kit/src/types/private.d.ts",
    "content": "// This module contains types that are visible in the documentation,\n// but which cannot be imported from `@sveltejs/kit`. Care should\n// be taken to avoid breaking changes when editing this file\n\nimport { RouteDefinition } from '@sveltejs/kit';\n\nexport interface AdapterEntry {\n\t/**\n\t * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.\n\t * For example, `/foo/a-[b]` and `/foo/[c]` are different routes, but would both\n\t * be represented in a Netlify _redirects file as `/foo/:param`, so they share an ID\n\t */\n\tid: string;\n\n\t/**\n\t * A function that compares the candidate route with the current route to determine\n\t * if it should be grouped with the current route.\n\t *\n\t * Use cases:\n\t * - Fallback pages: `/foo/[c]` is a fallback for `/foo/a-[b]`, and `/[...catchall]` is a fallback for all routes\n\t * - Grouping routes that share a common `config`: `/foo` should be deployed to the edge, `/bar` and `/baz` should be deployed to a serverless function\n\t */\n\tfilter(route: RouteDefinition): boolean;\n\n\t/**\n\t * A function that is invoked once the entry has been created. This is where you\n\t * should write the function to the filesystem and generate redirect manifests.\n\t */\n\tcomplete(entry: { generateManifest(opts: { relativePath: string }): string }): MaybePromise<void>;\n}\n\n// Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts\n//\n// MIT License\n//\n// Copyright (c) 2021-present, Joshua Hemphill\n// Copyright (c) 2021, Tecnico Corporation\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nexport namespace Csp {\n\ttype ActionSource = 'strict-dynamic' | 'report-sample';\n\ttype BaseSource =\n\t\t| 'self'\n\t\t| 'unsafe-eval'\n\t\t| 'unsafe-hashes'\n\t\t| 'unsafe-inline'\n\t\t| 'wasm-unsafe-eval'\n\t\t| 'none';\n\ttype CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;\n\ttype FrameSource = HostSource | SchemeSource | 'self' | 'none';\n\ttype HostNameScheme = `${string}.${string}` | 'localhost';\n\ttype HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`;\n\ttype HostProtocolSchemes = `${string}://` | '';\n\ttype HttpDelineator = '/' | '?' | '#' | '\\\\';\n\ttype PortScheme = `:${number}` | '' | ':*';\n\ttype SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:';\n\ttype Source = HostSource | SchemeSource | CryptoSource | BaseSource;\n\ttype Sources = Source[];\n}\n\nexport interface CspDirectives {\n\t'child-src'?: Csp.Sources;\n\t'default-src'?: Array<Csp.Source | Csp.ActionSource>;\n\t'frame-src'?: Csp.Sources;\n\t'worker-src'?: Csp.Sources;\n\t'connect-src'?: Csp.Sources;\n\t'font-src'?: Csp.Sources;\n\t'img-src'?: Csp.Sources;\n\t'manifest-src'?: Csp.Sources;\n\t'media-src'?: Csp.Sources;\n\t'object-src'?: Csp.Sources;\n\t'prefetch-src'?: Csp.Sources;\n\t'script-src'?: Array<Csp.Source | Csp.ActionSource>;\n\t'script-src-elem'?: Csp.Sources;\n\t'script-src-attr'?: Csp.Sources;\n\t'style-src'?: Array<Csp.Source | Csp.ActionSource>;\n\t'style-src-elem'?: Csp.Sources;\n\t'style-src-attr'?: Csp.Sources;\n\t'base-uri'?: Array<Csp.Source | Csp.ActionSource>;\n\tsandbox?: Array<\n\t\t| 'allow-downloads-without-user-activation'\n\t\t| 'allow-forms'\n\t\t| 'allow-modals'\n\t\t| 'allow-orientation-lock'\n\t\t| 'allow-pointer-lock'\n\t\t| 'allow-popups'\n\t\t| 'allow-popups-to-escape-sandbox'\n\t\t| 'allow-presentation'\n\t\t| 'allow-same-origin'\n\t\t| 'allow-scripts'\n\t\t| 'allow-storage-access-by-user-activation'\n\t\t| 'allow-top-navigation'\n\t\t| 'allow-top-navigation-by-user-activation'\n\t>;\n\t'form-action'?: Array<Csp.Source | Csp.ActionSource>;\n\t'frame-ancestors'?: Array<Csp.HostSource | Csp.SchemeSource | Csp.FrameSource>;\n\t'navigate-to'?: Array<Csp.Source | Csp.ActionSource>;\n\t'report-uri'?: string[];\n\t'report-to'?: string[];\n\n\t'require-trusted-types-for'?: Array<'script'>;\n\t'trusted-types'?: Array<'none' | 'allow-duplicates' | '*' | string>;\n\t'upgrade-insecure-requests'?: boolean;\n\n\t/** @deprecated */\n\t'require-sri-for'?: Array<'script' | 'style' | 'script style'>;\n\n\t/** @deprecated */\n\t'block-all-mixed-content'?: boolean;\n\n\t/** @deprecated */\n\t'plugin-types'?: Array<`${string}/${string}` | 'none'>;\n\n\t/** @deprecated */\n\treferrer?: Array<\n\t\t| 'no-referrer'\n\t\t| 'no-referrer-when-downgrade'\n\t\t| 'origin'\n\t\t| 'origin-when-cross-origin'\n\t\t| 'same-origin'\n\t\t| 'strict-origin'\n\t\t| 'strict-origin-when-cross-origin'\n\t\t| 'unsafe-url'\n\t\t| 'none'\n\t>;\n}\n\nexport type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS';\n\nexport interface Logger {\n\t(msg: string): void;\n\tsuccess(msg: string): void;\n\terror(msg: string): void;\n\twarn(msg: string): void;\n\tminor(msg: string): void;\n\tinfo(msg: string): void;\n}\n\nexport type MaybePromise<T> = T | Promise<T>;\n\nexport interface Prerendered {\n\t/**\n\t * 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`.\n\t */\n\tpages: Map<\n\t\tstring,\n\t\t{\n\t\t\t/** The location of the .html file relative to the output directory */\n\t\t\tfile: string;\n\t\t}\n\t>;\n\t/**\n\t * A map of `path` to `{ type }` objects.\n\t */\n\tassets: Map<\n\t\tstring,\n\t\t{\n\t\t\t/** The MIME type of the asset */\n\t\t\ttype: string;\n\t\t}\n\t>;\n\t/**\n\t * A map of redirects encountered during prerendering.\n\t */\n\tredirects: Map<\n\t\tstring,\n\t\t{\n\t\t\tstatus: number;\n\t\t\tlocation: string;\n\t\t}\n\t>;\n\t/** An array of prerendered paths (without trailing slashes, regardless of the trailingSlash config) */\n\tpaths: string[];\n}\n\nexport interface PrerenderHttpErrorHandler {\n\t(details: {\n\t\tstatus: number;\n\t\tpath: string;\n\t\treferrer: string | null;\n\t\treferenceType: 'linked' | 'fetched';\n\t\tmessage: string;\n\t}): void;\n}\n\nexport interface PrerenderMissingIdHandler {\n\t(details: { path: string; id: string; referrers: string[]; message: string }): void;\n}\n\nexport interface PrerenderEntryGeneratorMismatchHandler {\n\t(details: { generatedFromId: string; entry: string; matchedId: string; message: string }): void;\n}\n\nexport interface PrerenderUnseenRoutesHandler {\n\t(details: { routes: string[]; message: string }): void;\n}\n\nexport type PrerenderHttpErrorHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderHttpErrorHandler;\nexport type PrerenderMissingIdHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderMissingIdHandler;\nexport type PrerenderUnseenRoutesHandlerValue =\n\t| 'fail'\n\t| 'warn'\n\t| 'ignore'\n\t| PrerenderUnseenRoutesHandler;\nexport type PrerenderEntryGeneratorMismatchHandlerValue =\n\t| 'fail'\n\t| 'warn'\n\t| 'ignore'\n\t| PrerenderEntryGeneratorMismatchHandler;\n\nexport type PrerenderOption = boolean | 'auto';\n\nexport type PrerenderMap = Map<string, PrerenderOption>;\n\nexport interface RequestOptions {\n\tgetClientAddress(): string;\n\tplatform?: App.Platform;\n}\n\nexport interface RouteSegment {\n\tcontent: string;\n\tdynamic: boolean;\n\trest: boolean;\n}\n\n/** @default 'never' */\nexport type TrailingSlash = 'never' | 'always' | 'ignore';\n\nexport type DeepPartial<T> = T extends Record<PropertyKey, unknown> | unknown[]\n\t? {\n\t\t\t[K in keyof T]?: T[K] extends Record<PropertyKey, unknown> | unknown[]\n\t\t\t\t? DeepPartial<T[K]>\n\t\t\t\t: T[K];\n\t\t}\n\t: T | undefined;\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\n"
  },
  {
    "path": "packages/kit/src/types/synthetic/$env+dynamic+private.md",
    "content": "This module provides access to environment variables set _dynamically_ at runtime and that are limited to _private_ access.\n\n|         | Runtime                                                                    | Build time                                                               |\n| ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |\n| Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |\n| Public  | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public)   | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public)   |\n\nDynamic environment variables are 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://svelte.dev/docs/kit/cli)), this is equivalent to `process.env`.\n\n**_Private_ access:**\n\n- This module cannot be imported into client-side code\n- This module includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured)\n\n> [!NOTE] In `dev`, `$env/dynamic` includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter.\n\n> [!NOTE] To get correct types, 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:\n>\n> ```env\n> MY_FEATURE_FLAG=\n> ```\n>\n> You can override `.env` values from the command line like so:\n>\n> ```sh\n> MY_FEATURE_FLAG=\"enabled\" npm run dev\n> ```\n\nFor example, given the following runtime environment:\n\n```env\nENVIRONMENT=production\nPUBLIC_BASE_URL=http://site.com\n```\n\nWith the default `publicPrefix` and `privatePrefix`:\n\n```ts\nimport { env } from '$env/dynamic/private';\n\nconsole.log(env.ENVIRONMENT); // => \"production\"\nconsole.log(env.PUBLIC_BASE_URL); // => undefined\n```\n"
  },
  {
    "path": "packages/kit/src/types/synthetic/$env+dynamic+public.md",
    "content": "This module provides access to environment variables set _dynamically_ at runtime and that are _publicly_ accessible.\n\n|         | Runtime                                                                    | Build time                                                               |\n| ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |\n| Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |\n| Public  | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public)   | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public)   |\n\nDynamic environment variables are 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://svelte.dev/docs/kit/cli)), this is equivalent to `process.env`.\n\n**_Public_ access:**\n\n- This module _can_ be imported into client-side code\n- **Only** variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`) are included\n\n> [!NOTE] In `dev`, `$env/dynamic` includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter.\n\n> [!NOTE] To get correct types, 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:\n>\n> ```env\n> MY_FEATURE_FLAG=\n> ```\n>\n> You can override `.env` values from the command line like so:\n>\n> ```sh\n> MY_FEATURE_FLAG=\"enabled\" npm run dev\n> ```\n\nFor example, given the following runtime environment:\n\n```env\nENVIRONMENT=production\nPUBLIC_BASE_URL=http://example.com\n```\n\nWith the default `publicPrefix` and `privatePrefix`:\n\n```ts\nimport { env } from '$env/dynamic/public';\nconsole.log(env.ENVIRONMENT); // => undefined, not public\nconsole.log(env.PUBLIC_BASE_URL); // => \"http://example.com\"\n```\n\n```\n\n```\n"
  },
  {
    "path": "packages/kit/src/types/synthetic/$env+static+private.md",
    "content": "This module provides access to environment variables that are injected _statically_ into your bundle at build time and are limited to _private_ access.\n\n|         | Runtime                                                                    | Build time                                                               |\n| ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |\n| Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |\n| Public  | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public)   | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public)   |\n\nStatic environment variables are [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env` at build time and then statically injected into your bundle at build time, enabling optimisations like dead code elimination.\n\n**_Private_ access:**\n\n- This module cannot be imported into client-side code\n- This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured)\n\nFor example, given the following build time environment:\n\n```env\nENVIRONMENT=production\nPUBLIC_BASE_URL=http://site.com\n```\n\nWith the default `publicPrefix` and `privatePrefix`:\n\n```ts\nimport { ENVIRONMENT, PUBLIC_BASE_URL } from '$env/static/private';\n\nconsole.log(ENVIRONMENT); // => \"production\"\nconsole.log(PUBLIC_BASE_URL); // => throws error during build\n```\n\nThe above values will be the same _even if_ different values for `ENVIRONMENT` or `PUBLIC_BASE_URL` are set at runtime, as they are statically replaced in your code with their build time values.\n"
  },
  {
    "path": "packages/kit/src/types/synthetic/$env+static+public.md",
    "content": "This module provides access to environment variables that are injected _statically_ into your bundle at build time and are _publicly_ accessible.\n\n|         | Runtime                                                                    | Build time                                                               |\n| ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |\n| Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |\n| Public  | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public)   | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public)   |\n\nStatic environment variables are [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env` at build time and then statically injected into your bundle at build time, enabling optimisations like dead code elimination.\n\n**_Public_ access:**\n\n- This module _can_ be imported into client-side code\n- **Only** variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`) are included\n\nFor example, given the following build time environment:\n\n```env\nENVIRONMENT=production\nPUBLIC_BASE_URL=http://site.com\n```\n\nWith the default `publicPrefix` and `privatePrefix`:\n\n```ts\nimport { ENVIRONMENT, PUBLIC_BASE_URL } from '$env/static/public';\n\nconsole.log(ENVIRONMENT); // => throws error during build\nconsole.log(PUBLIC_BASE_URL); // => \"http://site.com\"\n```\n\nThe above values will be the same _even if_ different values for `ENVIRONMENT` or `PUBLIC_BASE_URL` are set at runtime, as they are statically replaced in your code with their build time values.\n"
  },
  {
    "path": "packages/kit/src/types/synthetic/$lib.md",
    "content": "This is a simple alias to `src/lib`, or whatever directory is specified as [`config.kit.files.lib`](https://svelte.dev/docs/kit/configuration#files). It allows you to access common components and utility modules without `../../../../` nonsense.\n\n### `$lib/server`\n\nA subdirectory of `$lib`. SvelteKit will prevent you from importing any modules in `$lib/server` into client-side code. See [server-only modules](https://svelte.dev/docs/kit/server-only-modules).\n"
  },
  {
    "path": "packages/kit/src/utils/array.js",
    "content": "/**\n * Removes nullish values from an array.\n *\n * @template T\n * @param {Array<T>} arr\n */\nexport function compact(arr) {\n\treturn arr.filter(/** @returns {val is NonNullable<T>} */ (val) => val != null);\n}\n"
  },
  {
    "path": "packages/kit/src/utils/css.js",
    "content": "import MagicString from 'magic-string';\nimport * as svelte from 'svelte/compiler';\nimport { escape_for_interpolation } from './escape.js';\n\n/** @typedef {ReturnType<typeof import('svelte/compiler').parseCss>['children']} StyleSheetChildren */\n\n/** @typedef {{ property: string; value: string; start: number; end: number; type: 'Declaration' }} Declaration */\n\nconst parse = svelte.parseCss\n\t? svelte.parseCss\n\t: /** @param {string} css */\n\t\t(css) => {\n\t\t\treturn /** @type {{ css: { children: StyleSheetChildren } }} */ (\n\t\t\t\tsvelte.parse(`<style>${css}</style>`)\n\t\t\t).css;\n\t\t};\n\nconst SKIP_PARSING_REGEX = /url\\(/i;\n\n/** Capture a single url(...) so we can process them one at a time */\nconst URL_FUNCTION_REGEX = /url\\(\\s*.*?\\)/gi;\n\n/** Captures the value inside a CSS url(...) */\nconst URL_PARAMETER_REGEX = /url\\(\\s*(['\"]?)(.*?)\\1\\s*\\)/i;\n\n/** Splits the URL if there's a query string or hash fragment */\nconst HASH_OR_QUERY_REGEX = /[#?]/;\n\n/**\n * Assets handled by Vite that are referenced in the stylesheet always start\n * with this prefix because Vite emits them into the same directory as the CSS file\n */\nconst VITE_ASSET_PREFIX = './';\n\nconst AST_OFFSET = '<style>'.length;\n\n/**\n * We need to fix the asset URLs in the CSS before we inline them into a document\n * because they are now relative to the document instead of the CSS file.\n * @param {{\n * \tcss: string;\n * \tvite_assets: Set<string>;\n * \tstatic_assets: Set<string>;\n * \tpaths_assets: string;\n * \tbase: string;\n * \tstatic_asset_prefix: string;\n * }} opts\n * @returns {string}\n */\nexport function fix_css_urls({\n\tcss,\n\tvite_assets,\n\tstatic_assets,\n\tpaths_assets,\n\tbase,\n\tstatic_asset_prefix\n}) {\n\t// skip parsing if there are no url(...) occurrences\n\tif (!SKIP_PARSING_REGEX.test(css)) {\n\t\treturn css;\n\t}\n\n\tcss = escape_for_interpolation(css);\n\n\t// safe guard in case of trailing slashes (but this should never happen)\n\tif (paths_assets.endsWith('/')) {\n\t\tpaths_assets = paths_assets.slice(0, -1);\n\t}\n\n\tif (base.endsWith('/')) {\n\t\tbase = base.slice(0, -1);\n\t}\n\n\tconst s = new MagicString(css);\n\n\tconst parsed = parse(css);\n\n\tfor (const child of parsed.children) {\n\t\tfind_declarations(child, (declaration) => {\n\t\t\tif (!SKIP_PARSING_REGEX.test) return;\n\n\t\t\tconst cleaned = tippex_comments_and_strings(declaration.value);\n\n\t\t\t/** @type {string} */\n\t\t\tlet new_value = declaration.value;\n\n\t\t\t/** @type {RegExpExecArray | null} */\n\t\t\tlet url_function_found;\n\t\t\tURL_FUNCTION_REGEX.lastIndex = 0;\n\t\t\twhile ((url_function_found = URL_FUNCTION_REGEX.exec(cleaned))) {\n\t\t\t\tconst [url_function] = url_function_found;\n\n\t\t\t\t// After finding a legitimate url(...), we want to operate on the original\n\t\t\t\t// that may have a string inside it\n\t\t\t\tconst original_url_function = declaration.value.slice(\n\t\t\t\t\turl_function_found.index,\n\t\t\t\t\turl_function_found.index + url_function.length\n\t\t\t\t);\n\n\t\t\t\tconst url_parameter_found = URL_PARAMETER_REGEX.exec(original_url_function);\n\t\t\t\tif (!url_parameter_found) continue;\n\n\t\t\t\tconst [, , url] = url_parameter_found;\n\t\t\t\tconst [url_without_hash_or_query] = url.split(HASH_OR_QUERY_REGEX);\n\n\t\t\t\t/** @type {string | undefined} */\n\t\t\t\tlet new_prefix;\n\n\t\t\t\t// Check if it's an asset processed by Vite...\n\t\t\t\tlet current_prefix = url_without_hash_or_query.slice(0, VITE_ASSET_PREFIX.length);\n\t\t\t\tlet filename = url_without_hash_or_query.slice(VITE_ASSET_PREFIX.length);\n\t\t\t\tconst decoded = decodeURIComponent(filename);\n\n\t\t\t\tif (current_prefix === VITE_ASSET_PREFIX && vite_assets.has(decoded)) {\n\t\t\t\t\tnew_prefix = paths_assets;\n\t\t\t\t} else {\n\t\t\t\t\t// ...or if it's from the static directory\n\t\t\t\t\tcurrent_prefix = url_without_hash_or_query.slice(0, static_asset_prefix.length);\n\t\t\t\t\tfilename = url_without_hash_or_query.slice(static_asset_prefix.length);\n\t\t\t\t\tconst decoded = decodeURIComponent(filename);\n\n\t\t\t\t\tif (current_prefix === static_asset_prefix && static_assets.has(decoded)) {\n\t\t\t\t\t\tnew_prefix = base;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!new_prefix) continue;\n\n\t\t\t\tnew_value = new_value.replace(`${current_prefix}${filename}`, `${new_prefix}/${filename}`);\n\t\t\t}\n\n\t\t\tif (declaration.value === new_value) return;\n\n\t\t\tif (!svelte.parseCss) {\n\t\t\t\tdeclaration.start = declaration.start - AST_OFFSET;\n\t\t\t\tdeclaration.end = declaration.end - AST_OFFSET;\n\t\t\t}\n\n\t\t\ts.update(declaration.start, declaration.end, `${declaration.property}: ${new_value}`);\n\t\t});\n\t}\n\n\treturn s.toString();\n}\n\n/**\n * @param {StyleSheetChildren[0]} rule\n * @param {(declaration: Declaration) => void} callback\n */\nfunction find_declarations(rule, callback) {\n\t// Vite already inlines relative @import rules, so we don't need to handle them here\n\tif (!rule.block) return;\n\n\tfor (const child of rule.block.children) {\n\t\tif (child.type !== 'Declaration') {\n\t\t\tfind_declarations(child, callback);\n\t\t\tcontinue;\n\t\t}\n\t\tcallback(child);\n\t}\n}\n\n/**\n * Replaces comment and string contents with whitespace.\n * @param {string} value\n * @returns {string}\n */\nexport function tippex_comments_and_strings(value) {\n\tlet new_value = '';\n\tlet escaped = false;\n\tlet in_comment = false;\n\n\t/** @type {null | '\"' | \"'\"} */\n\tlet quote_mark = null;\n\n\tlet i = 0;\n\twhile (i < value.length) {\n\t\tconst char = value[i];\n\n\t\tif (in_comment) {\n\t\t\tif (char === '*' && value[i + 1] === '/') {\n\t\t\t\tin_comment = false;\n\t\t\t\tnew_value += char;\n\t\t\t} else {\n\t\t\t\tnew_value += ' ';\n\t\t\t}\n\t\t} else if (!quote_mark && char === '/' && value[i + 1] === '*') {\n\t\t\tin_comment = true;\n\t\t\tnew_value += '/*';\n\t\t\ti++; // skip the '*' since we already added it\n\t\t} else if (escaped) {\n\t\t\tnew_value += ' ';\n\t\t\tescaped = false;\n\t\t} else if (quote_mark && char === '\\\\') {\n\t\t\tescaped = true;\n\t\t\tnew_value += ' ';\n\t\t} else if (char === quote_mark) {\n\t\t\tquote_mark = null;\n\t\t\tnew_value += char;\n\t\t} else if (quote_mark) {\n\t\t\tnew_value += ' ';\n\t\t} else if (quote_mark === null && (char === '\"' || char === \"'\")) {\n\t\t\tquote_mark = char;\n\t\t\tnew_value += char;\n\t\t} else {\n\t\t\tnew_value += char;\n\t\t}\n\n\t\ti++;\n\t}\n\n\treturn new_value;\n}\n"
  },
  {
    "path": "packages/kit/src/utils/css.spec.js",
    "content": "import { assert, describe, test } from 'vitest';\nimport { fix_css_urls, tippex_comments_and_strings } from './css.js';\n\ndescribe('fix_css_urls', () => {\n\tconst cdn_assets = 'https://cdn.example.com/_app/immutable/assets';\n\tconst cdn_base = 'https://cdn.example.com';\n\tconst local_assets = './_app/immutable/assets';\n\tconst local_base = '.';\n\n\ttest.each([\n\t\t{\n\t\t\tname: 'uses paths.assets for assets processed by Vite',\n\t\t\tcss: 'div { background: url(./image.png); }',\n\t\t\texpected: `div { background: url(${cdn_assets}/image.png); }`,\n\t\t\tvite_assets: ['image.png'],\n\t\t\tpaths_assets: cdn_assets,\n\t\t\tbase: cdn_base\n\t\t},\n\t\t{\n\t\t\tname: 'uses paths.base for static asset',\n\t\t\tcss: 'div { background: url(../../../image.png); }',\n\t\t\texpected: `div { background: url(${cdn_base}/image.png); }`,\n\t\t\tstatic_assets: ['image.png'],\n\t\t\tpaths_assets: cdn_assets,\n\t\t\tbase: cdn_base\n\t\t},\n\t\t{\n\t\t\tname: 'keeps single quotes',\n\t\t\tcss: \"div { background: url('../../../image.png'); }\",\n\t\t\texpected: `div { background: url('${cdn_base}/image.png'); }`,\n\t\t\tstatic_assets: ['image.png'],\n\t\t\tpaths_assets: cdn_assets,\n\t\t\tbase: cdn_base\n\t\t},\n\t\t{\n\t\t\tname: 'keeps double-quotes',\n\t\t\tcss: 'div { background: url(\"./image.png\"); }',\n\t\t\texpected: `div { background: url(\"${cdn_assets}/image.png\"); }`,\n\t\t\tvite_assets: ['image.png'],\n\t\t\tpaths_assets: cdn_assets,\n\t\t\tbase: cdn_base\n\t\t},\n\t\t{\n\t\t\tname: 'works with case-insensitive URL function',\n\t\t\tcss: 'div { background: uRl(./image.png); }',\n\t\t\texpected: `div { background: uRl(${cdn_assets}/image.png); }`,\n\t\t\tvite_assets: ['image.png'],\n\t\t\tpaths_assets: cdn_assets,\n\t\t\tbase: cdn_base\n\t\t},\n\t\t{\n\t\t\tname: 'works with multiple declarations',\n\t\t\tcss: `\n\t\t\t\tdiv {\n\t\t\t\t\tbackground: url(./bg.png);\n\t\t\t\t\tborder-image: url(./border.svg);\n\t\t\t\t\tmask: url(./mask.png);\n\t\t\t\t}\n\t\t\t`,\n\t\t\texpected: `\n\t\t\t\tdiv {\n\t\t\t\t\tbackground: url(${local_assets}/bg.png);\n\t\t\t\t\tborder-image: url(${local_assets}/border.svg);\n\t\t\t\t\tmask: url(${local_assets}/mask.png);\n\t\t\t\t}\n\t\t\t`,\n\t\t\tvite_assets: ['bg.png', 'border.svg', 'mask.png']\n\t\t},\n\t\t{\n\t\t\tname: 'ignores URL with leading slash',\n\t\t\tcss: 'div { background: url(/absolute/image.png); }',\n\t\t\texpected: 'div { background: url(/absolute/image.png); }'\n\t\t},\n\t\t{\n\t\t\tname: 'ignores URL with protocol',\n\t\t\tcss: `div { background: url(${cdn_base}/image.png); }`,\n\t\t\texpected: `div { background: url(${cdn_base}/image.png); }`\n\t\t},\n\t\t{\n\t\t\tname: 'ignores data URL',\n\t\t\tcss: 'div { background: url(data:image/png;base64,abc); }',\n\t\t\texpected: 'div { background: url(data:image/png;base64,abc); }'\n\t\t},\n\t\t{\n\t\t\tname: 'ignores URL prefixed with ./ but from the static directory',\n\t\t\tcss: 'div { background: url(./image.png); }',\n\t\t\texpected: 'div { background: url(./image.png); }',\n\t\t\tstatic_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'ignores URL prefixed with ../../../ but imported',\n\t\t\tcss: 'div { background: url(../../../image.png); }',\n\t\t\texpected: 'div { background: url(../../../image.png); }',\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'ignores URL prefixed with ../../../ but navigates to deeper levels',\n\t\t\tcss: 'div { background: url(../../../../image.png); }',\n\t\t\texpected: 'div { background: url(../../../../image.png); }'\n\t\t},\n\t\t{\n\t\t\tname: 'handles whitespace after opening parenthesis',\n\t\t\tcss: 'div { background: url( ./image.png); }',\n\t\t\texpected: `div { background: url( ${local_assets}/image.png); }`,\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'handles multiple spaces before quoted path',\n\t\t\tcss: 'div { background: url(  \"./image.png\"); }',\n\t\t\texpected: `div { background: url(  \"${local_assets}/image.png\"); }`,\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'handles tab before single-quoted path',\n\t\t\tcss: \"div { background: url(\\t'./image.png'); }\",\n\t\t\texpected: `div { background: url(\\t'${local_assets}/image.png'); }`,\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'handles url with query string',\n\t\t\tcss: 'div { background: url(./image.png?v=123); }',\n\t\t\texpected: `div { background: url(${local_assets}/image.png?v=123); }`,\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'handles url with hash fragment',\n\t\t\tcss: \"div { background: url('./image.png#section'); }\",\n\t\t\texpected: `div { background: url('${local_assets}/image.png#section'); }`,\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'handles url with both query string and fragment',\n\t\t\tcss: 'div { background: url(\"./image.png?a=1&b=2#anchor\"); }',\n\t\t\texpected: `div { background: url(\"${local_assets}/image.png?a=1&b=2#anchor\"); }`,\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'handles multiple URLs in a single declaration',\n\t\t\tcss: 'div { background: image-set(url(./a.png) 1x, url(./b.png) 2x); }',\n\t\t\texpected: `div { background: image-set(url(${local_assets}/a.png) 1x, url(${local_assets}/b.png) 2x); }`,\n\t\t\tvite_assets: ['a.png', 'b.png']\n\t\t},\n\t\t{\n\t\t\tname: 'ignores relative url without ./ prefix',\n\t\t\tcss: 'div { background: url(image.png); }',\n\t\t\texpected: 'div { background: url(image.png); }',\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'handles escaped quotes',\n\t\t\tcss: \"div::after { content: \\\"'\\\\\\\"\\\"; } div { background: url('./image.png?\\\\''); }\",\n\t\t\texpected: `div::after { content: \"'\\\\\"\"; } div { background: url('${local_assets}/image.png?\\\\''); }`,\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'handles escaped parenthesis',\n\t\t\tcss: \"div { background: url('./image.png?\\\\)'); }\",\n\t\t\texpected: `div { background: url('${local_assets}/image.png?\\\\)'); }`,\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'ignores url(...) inside a string',\n\t\t\tcss: \"div::after { content: 'url(./image.png)'; }\",\n\t\t\texpected: \"div::after { content: 'url(./image.png)'; }\",\n\t\t\tvite_assets: ['image.png']\n\t\t},\n\t\t{\n\t\t\tname: 'ignores url(...) inside a comment',\n\t\t\tcss: 'div::before { content: \"/*\"; } div { background: blue /* url(./image.png) */; }',\n\t\t\texpected: 'div::before { content: \"/*\"; } div { background: blue /* url(./image.png) */; }',\n\t\t\tvite_assets: ['image.png']\n\t\t}\n\t])(\n\t\t'$name',\n\t\t({\n\t\t\tcss,\n\t\t\texpected,\n\t\t\tvite_assets = [],\n\t\t\tstatic_assets = [],\n\t\t\tpaths_assets = local_assets,\n\t\t\tbase = local_base\n\t\t}) => {\n\t\t\tassert.equal(\n\t\t\t\tfix_css_urls({\n\t\t\t\t\tcss,\n\t\t\t\t\tvite_assets: new Set(vite_assets),\n\t\t\t\t\tstatic_assets: new Set(static_assets),\n\t\t\t\t\tpaths_assets,\n\t\t\t\t\tbase,\n\t\t\t\t\tstatic_asset_prefix: '../../../'\n\t\t\t\t}),\n\t\t\t\texpected\n\t\t\t);\n\t\t}\n\t);\n});\n\ndescribe('tippex_comments_and_strings', () => {\n\ttest.each([\n\t\t// Basic string handling\n\t\t[\"'hello'\", \"'     '\"],\n\t\t['\"hello\"', '\"     \"'],\n\t\t[\"''\", \"''\"],\n\t\t['\"\"', '\"\"'],\n\t\t[\"before 'inside' after\", \"before '      ' after\"],\n\n\t\t// Basic comment handling\n\t\t['/* comment */', '/*         */'],\n\t\t['/**/', '/**/'],\n\t\t['/* * */', '/*   */'],\n\t\t['before /* inside */ after', 'before /*        */ after'],\n\n\t\t// Escape sequences inside strings\n\t\t[\"'it\\\\'s'\", \"'     '\"],\n\t\t['\"say \\\\\"hi\\\\\"\"', '\"          \"'],\n\t\t[\"'test\\\\\\\\'\", \"'      '\"],\n\t\t[\"'a\\\\\\\\'\", \"'   '\"], // escaped backslash does not escape following quote\n\t\t[\"'a\\\\\\\\b'\", \"'    '\"], // escaped backslash followed by more content\n\n\t\t// Mixed quotes (no escaping needed)\n\t\t['\\'say \"hi\"\\'', \"'        '\"],\n\t\t['\"it\\'s\"', '\"    \"'],\n\n\t\t// Comment-like patterns inside strings (should not start comment)\n\t\t[\"'/* not a comment */'\", \"'                   '\"],\n\t\t['\"/* also not */\"', '\"              \"'],\n\n\t\t// String-like patterns inside comments (should not start string)\n\t\t[\"/* 'not a string' */\", '/*                */'],\n\t\t['/* \"also not\" */', '/*            */'],\n\n\t\t// Multiple constructs\n\t\t[\"'a' and 'b'\", \"' ' and ' '\"],\n\t\t['/* a */ and /* b */', '/*   */ and /*   */'],\n\t\t[\"'str' /* comment */\", \"'   ' /*         */\"],\n\t\t[\"/* comment */ 'string'\", \"/*         */ '      '\"],\n\n\t\t// Real CSS patterns\n\t\t['url(./image.png)', 'url(./image.png)'],\n\t\t[\"content: 'url(./fake.png)'\", \"content: '               '\"],\n\t\t['/* url(./x.png) */ url(./y.png)', '/*              */ url(./y.png)'],\n\t\t[\n\t\t\t\"background: url('./a.png') /* fallback */, url('./b.png')\",\n\t\t\t\"background: url('       ') /*          */, url('       ')\"\n\t\t],\n\n\t\t// Edge cases\n\t\t['a \\\\/* comment */', 'a \\\\/*         */'], // backslash outside string should not affect comment detection\n\t\t[\"'unterminated\", \"'            \"], // unterminated single-quoted string\n\t\t['\"unterminated', '\"            '], // unterminated double-quoted string\n\t\t['/* unterminated', '/*             '], // unterminated comment\n\t\t['/* start */', '/*       */'], // comment at start\n\t\t[\"'start'\", \"'     '\"], // string at start\n\t\t['   ', '   '], // whitespace preserved\n\t\t['', ''], // empty input\n\t\t[\"'\\\\\\\\\\\\\\\\'\", \"'    '\"], // consecutive escape sequences (two escaped backslashes)\n\t\t[\"'test\\\\\", \"'     \"] // escape at end of unterminated string\n\t])('%s → %s', (input, expected) => {\n\t\tconst result = tippex_comments_and_strings(input);\n\t\tassert.equal(result, expected);\n\t\tassert.equal(\n\t\t\tinput.length,\n\t\t\texpected.length,\n\t\t\t'test is correctly formed (input and expected lengths should always match)'\n\t\t);\n\t\tassert.equal(result.length, input.length, 'output length must equal input length');\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/utils/env.js",
    "content": "/**\n * @param {Record<string, string>} env\n * @param {string} allowed\n * @param {string} disallowed\n * @returns {Record<string, string>}\n */\nexport function filter_env(env, allowed, disallowed) {\n\treturn Object.fromEntries(\n\t\tObject.entries(env).filter(\n\t\t\t([k]) => k.startsWith(allowed) && (disallowed === '' || !k.startsWith(disallowed))\n\t\t)\n\t);\n}\n"
  },
  {
    "path": "packages/kit/src/utils/error.js",
    "content": "import { HttpError, SvelteKitError } from '@sveltejs/kit/internal';\n\n/**\n * @param {unknown} err\n * @return {Error}\n */\nexport function coalesce_to_error(err) {\n\treturn err instanceof Error ||\n\t\t(err && /** @type {any} */ (err).name && /** @type {any} */ (err).message)\n\t\t? /** @type {Error} */ (err)\n\t\t: new Error(JSON.stringify(err));\n}\n\n/**\n * This is an identity function that exists to make TypeScript less\n * paranoid about people throwing things that aren't errors, which\n * frankly is not something we should care about\n * @param {unknown} error\n */\nexport function normalize_error(error) {\n\treturn /** @type {import('../exports/internal/index.js').Redirect | HttpError | SvelteKitError | Error} */ (\n\t\terror\n\t);\n}\n\n/**\n * @param {unknown} error\n */\nexport function get_status(error) {\n\treturn error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;\n}\n\n/**\n * @param {unknown} error\n */\nexport function get_message(error) {\n\treturn error instanceof SvelteKitError ? error.text : 'Internal Error';\n}\n"
  },
  {
    "path": "packages/kit/src/utils/escape.js",
    "content": "/**\n * When inside a double-quoted attribute value, only `&` and `\"` hold special meaning.\n * @see https://html.spec.whatwg.org/multipage/parsing.html#attribute-value-(double-quoted)-state\n * @type {Record<string, string>}\n */\nconst escape_html_attr_dict = {\n\t'&': '&amp;',\n\t'\"': '&quot;'\n\t// Svelte also escapes < because the escape function could be called inside a `noscript` there\n\t// https://github.com/sveltejs/svelte/security/advisories/GHSA-8266-84wp-wv5c\n\t// However, that doesn't apply in SvelteKit\n};\n\n/**\n * @type {Record<string, string>}\n */\nconst escape_html_dict = {\n\t'&': '&amp;',\n\t'<': '&lt;'\n};\n\nconst surrogates = // high surrogate without paired low surrogate\n\t'[\\\\ud800-\\\\udbff](?![\\\\udc00-\\\\udfff])|' +\n\t// a valid surrogate pair, the only match with 2 code units\n\t// we match it so that we can match unpaired low surrogates in the same pass\n\t// TODO: use lookbehind assertions once they are widely supported: (?<![\\ud800-udbff])[\\udc00-\\udfff]\n\t'[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]|' +\n\t// unpaired low surrogate (see previous match)\n\t'[\\\\udc00-\\\\udfff]';\n\nconst escape_html_attr_regex = new RegExp(\n\t`[${Object.keys(escape_html_attr_dict).join('')}]|` + surrogates,\n\t'g'\n);\n\nconst escape_html_regex = new RegExp(\n\t`[${Object.keys(escape_html_dict).join('')}]|` + surrogates,\n\t'g'\n);\n\n/**\n * Escapes unpaired surrogates (which are allowed in js strings but invalid in HTML) and\n * escapes characters that are special.\n *\n * @param {string} str\n * @param {boolean} [is_attr]\n * @returns {string} escaped string\n * @example const html = `<tag data-value=\"${escape_html('value', true)}\">...</tag>`;\n */\nexport function escape_html(str, is_attr) {\n\tconst dict = is_attr ? escape_html_attr_dict : escape_html_dict;\n\tconst escaped_str = str.replace(is_attr ? escape_html_attr_regex : escape_html_regex, (match) => {\n\t\tif (match.length === 2) {\n\t\t\t// valid surrogate pair\n\t\t\treturn match;\n\t\t}\n\n\t\treturn dict[match] ?? `&#${match.charCodeAt(0)};`;\n\t});\n\n\treturn escaped_str;\n}\n\n/**\n * Escapes backticks and dollar signs so that they can be safely used in template literals.\n * @param {string} str\n * @returns {string} escaped string\n */\nexport function escape_for_interpolation(str) {\n\treturn str.replaceAll('`', '\\\\`').replaceAll('$', '\\\\$');\n}\n"
  },
  {
    "path": "packages/kit/src/utils/escape.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport { escape_for_interpolation, escape_html } from './escape.js';\n\ntest('escape_html_attr escapes special attribute characters', () => {\n\tassert.equal(\n\t\tescape_html('some \"values\" are &special here, <others> aren\\'t.', true),\n\t\t\"some &quot;values&quot; are &amp;special here, <others> aren't.\"\n\t);\n});\n\ntest('escape_html_attr escapes invalid surrogates', () => {\n\tassert.equal(escape_html('\\ud800\\udc00', true), '\\ud800\\udc00');\n\tassert.equal(escape_html('\\ud800', true), '&#55296;');\n\tassert.equal(escape_html('\\udc00', true), '&#56320;');\n\tassert.equal(escape_html('\\udc00\\ud800', true), '&#56320;&#55296;');\n\tassert.equal(escape_html('\\ud800\\ud800\\udc00', true), '&#55296;\\ud800\\udc00');\n\tassert.equal(escape_html('\\ud800\\udc00\\udc00', true), '\\ud800\\udc00&#56320;');\n\tassert.equal(escape_html('\\ud800\\ud800\\udc00\\udc00', true), '&#55296;\\ud800\\udc00&#56320;');\n});\n\ntest('escape_for_interpolation escapes both backticks and dollar signs', () => {\n\tassert.equal(\n\t\tescape_for_interpolation('div:after { content: \"` and ${example}`\"; }'),\n\t\t'div:after { content: \"\\\\` and \\\\${example}\\\\`\"; }'\n\t);\n});\n"
  },
  {
    "path": "packages/kit/src/utils/exports.js",
    "content": "/**\n * @param {Set<string>} expected\n */\nfunction validator(expected) {\n\t/**\n\t * @param {any} module\n\t * @param {string} [file]\n\t */\n\tfunction validate(module, file) {\n\t\tif (!module) return;\n\n\t\tfor (const key in module) {\n\t\t\tif (key[0] === '_' || expected.has(key)) continue; // key is valid in this module\n\n\t\t\tconst values = [...expected.values()];\n\n\t\t\tconst hint =\n\t\t\t\thint_for_supported_files(key, file?.slice(file.lastIndexOf('.'))) ??\n\t\t\t\t`valid exports are ${values.join(', ')}, or anything with a '_' prefix`;\n\n\t\t\tthrow new Error(`Invalid export '${key}'${file ? ` in ${file}` : ''} (${hint})`);\n\t\t}\n\t}\n\n\treturn validate;\n}\n\n/**\n * @param {string} key\n * @param {string} ext\n * @returns {string | void}\n */\nfunction hint_for_supported_files(key, ext = '.js') {\n\tconst supported_files = [];\n\n\tif (valid_layout_exports.has(key)) {\n\t\tsupported_files.push(`+layout${ext}`);\n\t}\n\n\tif (valid_page_exports.has(key)) {\n\t\tsupported_files.push(`+page${ext}`);\n\t}\n\n\tif (valid_layout_server_exports.has(key)) {\n\t\tsupported_files.push(`+layout.server${ext}`);\n\t}\n\n\tif (valid_page_server_exports.has(key)) {\n\t\tsupported_files.push(`+page.server${ext}`);\n\t}\n\n\tif (valid_server_exports.has(key)) {\n\t\tsupported_files.push(`+server${ext}`);\n\t}\n\n\tif (supported_files.length > 0) {\n\t\treturn `'${key}' is a valid export in ${supported_files.slice(0, -1).join(', ')}${\n\t\t\tsupported_files.length > 1 ? ' or ' : ''\n\t\t}${supported_files.at(-1)}`;\n\t}\n}\n\nconst valid_layout_exports = new Set([\n\t'load',\n\t'prerender',\n\t'csr',\n\t'ssr',\n\t'trailingSlash',\n\t'config'\n]);\nconst valid_page_exports = new Set([...valid_layout_exports, 'entries']);\nconst valid_layout_server_exports = new Set([...valid_layout_exports]);\nconst valid_page_server_exports = new Set([...valid_layout_server_exports, 'actions', 'entries']);\nconst valid_server_exports = new Set([\n\t'GET',\n\t'POST',\n\t'PATCH',\n\t'PUT',\n\t'DELETE',\n\t'OPTIONS',\n\t'HEAD',\n\t'fallback',\n\t'prerender',\n\t'trailingSlash',\n\t'config',\n\t'entries'\n]);\n\nexport const validate_layout_exports = validator(valid_layout_exports);\nexport const validate_page_exports = validator(valid_page_exports);\nexport const validate_layout_server_exports = validator(valid_layout_server_exports);\nexport const validate_page_server_exports = validator(valid_page_server_exports);\nexport const validate_server_exports = validator(valid_server_exports);\n"
  },
  {
    "path": "packages/kit/src/utils/exports.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport {\n\tvalidate_layout_exports,\n\tvalidate_layout_server_exports,\n\tvalidate_page_exports,\n\tvalidate_page_server_exports,\n\tvalidate_server_exports\n} from './exports.js';\n\n/**\n * @param {() => void} fn\n * @param {string} message\n */\nfunction check_error(fn, message) {\n\tlet error;\n\n\ttry {\n\t\tfn();\n\t} catch (e) {\n\t\terror = /** @type {Error} */ (e);\n\t}\n\n\tassert.equal(error?.message, message);\n}\n\ntest('validates +layout.js', () => {\n\tvalidate_layout_exports({\n\t\tload: () => {},\n\t\tprerender: false,\n\t\tcsr: false,\n\t\tssr: false,\n\t\ttrailingSlash: false,\n\t\tconfig: {}\n\t});\n\n\tvalidate_layout_exports({\n\t\t_unknown: () => {}\n\t});\n\n\tcheck_error(() => {\n\t\tvalidate_layout_exports({\n\t\t\tanswer: 42\n\t\t});\n\t}, \"Invalid export 'answer' (valid exports are load, prerender, csr, ssr, trailingSlash, config, or anything with a '_' prefix)\");\n\n\tcheck_error(() => {\n\t\tvalidate_layout_exports(\n\t\t\t{\n\t\t\t\tactions: {}\n\t\t\t},\n\t\t\t'src/routes/foo/+page.ts'\n\t\t);\n\t}, \"Invalid export 'actions' in src/routes/foo/+page.ts ('actions' is a valid export in +page.server.ts)\");\n\n\tcheck_error(() => {\n\t\tvalidate_layout_exports({\n\t\t\tGET: {}\n\t\t});\n\t}, \"Invalid export 'GET' ('GET' is a valid export in +server.js)\");\n});\n\ntest('validates +page.js', () => {\n\tvalidate_page_exports({\n\t\tload: () => {},\n\t\tprerender: false,\n\t\tcsr: false,\n\t\tssr: false,\n\t\ttrailingSlash: false,\n\t\tconfig: {},\n\t\tentries: () => {}\n\t});\n\n\tvalidate_page_exports({\n\t\t_unknown: () => {}\n\t});\n\n\tcheck_error(() => {\n\t\tvalidate_page_exports({\n\t\t\tanswer: 42\n\t\t});\n\t}, \"Invalid export 'answer' (valid exports are load, prerender, csr, ssr, trailingSlash, config, entries, or anything with a '_' prefix)\");\n\n\tcheck_error(() => {\n\t\tvalidate_page_exports(\n\t\t\t{\n\t\t\t\tactions: {}\n\t\t\t},\n\t\t\t'src/routes/foo/+page.ts'\n\t\t);\n\t}, \"Invalid export 'actions' in src/routes/foo/+page.ts ('actions' is a valid export in +page.server.ts)\");\n\n\tcheck_error(() => {\n\t\tvalidate_page_exports({\n\t\t\tGET: {}\n\t\t});\n\t}, \"Invalid export 'GET' ('GET' is a valid export in +server.js)\");\n});\n\ntest('validates +layout.server.js', () => {\n\tvalidate_layout_server_exports({\n\t\tload: () => {},\n\t\tprerender: false,\n\t\tcsr: false,\n\t\tssr: false,\n\t\ttrailingSlash: false,\n\t\tconfig: {}\n\t});\n\n\tvalidate_layout_server_exports({\n\t\t_unknown: () => {}\n\t});\n\n\tcheck_error(() => {\n\t\tvalidate_layout_server_exports({\n\t\t\tanswer: 42\n\t\t});\n\t}, \"Invalid export 'answer' (valid exports are load, prerender, csr, ssr, trailingSlash, config, or anything with a '_' prefix)\");\n\n\tcheck_error(() => {\n\t\tvalidate_layout_exports(\n\t\t\t{\n\t\t\t\tactions: {}\n\t\t\t},\n\t\t\t'src/routes/foo/+page.ts'\n\t\t);\n\t}, \"Invalid export 'actions' in src/routes/foo/+page.ts ('actions' is a valid export in +page.server.ts)\");\n\n\tcheck_error(() => {\n\t\tvalidate_layout_server_exports({\n\t\t\tPOST: {}\n\t\t});\n\t}, \"Invalid export 'POST' ('POST' is a valid export in +server.js)\");\n});\n\ntest('validates +page.server.js', () => {\n\tvalidate_page_server_exports({\n\t\tload: () => {},\n\t\tprerender: false,\n\t\tcsr: false,\n\t\tssr: false,\n\t\ttrailingSlash: false,\n\t\tconfig: {},\n\t\tactions: {},\n\t\tentries: () => {}\n\t});\n\n\tvalidate_page_server_exports({\n\t\t_unknown: () => {}\n\t});\n\n\tcheck_error(() => {\n\t\tvalidate_page_server_exports({\n\t\t\tanswer: 42\n\t\t});\n\t}, \"Invalid export 'answer' (valid exports are load, prerender, csr, ssr, trailingSlash, config, actions, entries, or anything with a '_' prefix)\");\n\n\tcheck_error(() => {\n\t\tvalidate_page_server_exports({\n\t\t\tPOST: {}\n\t\t});\n\t}, \"Invalid export 'POST' ('POST' is a valid export in +server.js)\");\n});\n\ntest('validates +server.js', () => {\n\tvalidate_server_exports({\n\t\tGET: () => {}\n\t});\n\n\tvalidate_server_exports({\n\t\t_unknown: () => {}\n\t});\n\n\tcheck_error(() => {\n\t\tvalidate_server_exports({\n\t\t\tanswer: 42\n\t\t});\n\t}, \"Invalid export 'answer' (valid exports are GET, POST, PATCH, PUT, DELETE, OPTIONS, HEAD, fallback, prerender, trailingSlash, config, entries, or anything with a '_' prefix)\");\n\n\tcheck_error(() => {\n\t\tvalidate_server_exports({\n\t\t\tcsr: false\n\t\t});\n\t}, \"Invalid export 'csr' ('csr' is a valid export in +layout.js, +page.js, +layout.server.js or +page.server.js)\");\n});\n"
  },
  {
    "path": "packages/kit/src/utils/features.js",
    "content": "/**\n * @param {string} route_id\n * @param {any} config\n * @param {string} feature\n * @param {import('@sveltejs/kit').Adapter | undefined} adapter\n */\nexport function check_feature(route_id, config, feature, adapter) {\n\tif (!adapter) return;\n\n\tswitch (feature) {\n\t\tcase '$app/server:read': {\n\t\t\tconst supported = adapter.supports?.read?.({\n\t\t\t\troute: { id: route_id },\n\t\t\t\tconfig\n\t\t\t});\n\n\t\t\tif (!supported) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot use \\`read\\` from \\`$app/server\\` in ${route_id} when using ${adapter.name}. Please ensure that your adapter is up to date and supports this feature.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/utils/filesystem.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\n\n/** @param {string} dir */\nexport function mkdirp(dir) {\n\ttry {\n\t\tfs.mkdirSync(dir, { recursive: true });\n\t} catch (/** @type {any} */ e) {\n\t\tif (e.code === 'EEXIST') {\n\t\t\tif (!fs.statSync(dir).isDirectory()) {\n\t\t\t\tthrow new Error(`Cannot create directory ${dir}, a file already exists at this position`, {\n\t\t\t\t\tcause: e\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthrow e;\n\t}\n}\n\n/** @param {string} path */\nexport function rimraf(path) {\n\tfs.rmSync(path, { force: true, recursive: true });\n}\n\n/**\n * @param {string} source\n * @param {string} target\n * @param {{\n *   filter?: (basename: string) => boolean;\n *   replace?: Record<string, string>;\n * }} opts\n */\nexport function copy(source, target, opts = {}) {\n\tif (!fs.existsSync(source)) return [];\n\n\t/** @type {string[]} */\n\tconst files = [];\n\n\tconst prefix = posixify(target) + '/';\n\n\tconst regex = opts.replace\n\t\t? new RegExp(`\\\\b(${Object.keys(opts.replace).join('|')})\\\\b`, 'g')\n\t\t: null;\n\n\t/**\n\t * @param {string} from\n\t * @param {string} to\n\t */\n\tfunction go(from, to) {\n\t\tif (opts.filter && !opts.filter(path.basename(from))) return;\n\n\t\tconst stats = fs.statSync(from);\n\n\t\tif (stats.isDirectory()) {\n\t\t\tfs.readdirSync(from).forEach((file) => {\n\t\t\t\tgo(path.join(from, file), path.join(to, file));\n\t\t\t});\n\t\t} else {\n\t\t\tmkdirp(path.dirname(to));\n\n\t\t\tif (opts.replace) {\n\t\t\t\tconst data = fs.readFileSync(from, 'utf-8');\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tto,\n\t\t\t\t\tdata.replace(\n\t\t\t\t\t\t/** @type {RegExp} */ (regex),\n\t\t\t\t\t\t(_match, key) => /** @type {Record<string, string>} */ (opts.replace)[key]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tfs.copyFileSync(from, to);\n\t\t\t}\n\n\t\t\tfiles.push(to === target ? posixify(path.basename(to)) : posixify(to).replace(prefix, ''));\n\t\t}\n\t}\n\n\tgo(source, target);\n\n\treturn files;\n}\n\n/**\n * Get a list of all files in a directory\n * @param {string} cwd - the directory to walk\n * @param {boolean} [dirs] - whether to include directories in the result\n * @returns {string[]} a list of all found files (and possibly directories) relative to `cwd`\n */\nexport function walk(cwd, dirs = false) {\n\t/** @type {string[]} */\n\tconst all_files = [];\n\n\t/** @param {string} dir */\n\tfunction walk_dir(dir) {\n\t\tconst files = fs.readdirSync(path.join(cwd, dir));\n\n\t\tfor (const file of files) {\n\t\t\tconst joined = path.join(dir, file);\n\t\t\tconst stats = fs.statSync(path.join(cwd, joined));\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\tif (dirs) all_files.push(joined);\n\t\t\t\twalk_dir(joined);\n\t\t\t} else {\n\t\t\t\tall_files.push(joined);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (walk_dir(''), all_files);\n}\n\n/** @param {string} str */\nexport function posixify(str) {\n\treturn str.replace(/\\\\/g, '/');\n}\n\n/**\n * Like `path.join`, but posixified and with a leading `./` if necessary\n * @param {string[]} str\n */\nexport function join_relative(...str) {\n\tlet result = posixify(path.join(...str));\n\tif (!result.startsWith('.')) {\n\t\tresult = `./${result}`;\n\t}\n\treturn result;\n}\n\n/**\n * Like `path.relative`, but always posixified and with a leading `./` if necessary.\n * Useful for JS imports so the path can safely reside inside of `node_modules`.\n * Otherwise paths could be falsely interpreted as package paths.\n * @param {string} from\n * @param {string} to\n */\nexport function relative_path(from, to) {\n\treturn join_relative(path.relative(from, to));\n}\n\n/**\n * Prepend given path with `/@fs` prefix\n * @param {string} str\n */\nexport function to_fs(str) {\n\tstr = posixify(str);\n\treturn `/@fs${\n\t\t// Windows/Linux separation - Windows starts with a drive letter, we need a / in front there\n\t\tstr.startsWith('/') ? '' : '/'\n\t}${str}`;\n}\n\n/**\n * Removes `/@fs` prefix from given path and posixifies it\n * @param {string} str\n */\nexport function from_fs(str) {\n\tstr = posixify(str);\n\tif (!str.startsWith('/@fs')) return str;\n\n\tstr = str.slice(4);\n\t// Windows/Linux separation - Windows starts with a drive letter, we need to strip the additional / here\n\treturn str[2] === ':' && /[A-Z]/.test(str[1]) ? str.slice(1) : str;\n}\n\n/**\n * Given an entry point like [cwd]/src/hooks, returns a filename like [cwd]/src/hooks.js or [cwd]/src/hooks/index.js\n * @param {string} entry\n * @returns {string|null}\n */\nexport function resolve_entry(entry) {\n\tif (fs.existsSync(entry)) {\n\t\tconst stats = fs.statSync(entry);\n\t\tif (stats.isFile()) {\n\t\t\treturn entry;\n\t\t}\n\n\t\tconst index = path.join(entry, 'index');\n\t\tif (fs.existsSync(index + '.js') || fs.existsSync(index + '.ts')) {\n\t\t\treturn resolve_entry(index);\n\t\t}\n\t}\n\n\tconst dir = path.dirname(entry);\n\n\tif (fs.existsSync(dir)) {\n\t\tconst base = path.basename(entry);\n\t\tconst files = fs.readdirSync(dir);\n\t\tconst found = files.find((file) => {\n\t\t\treturn file.replace(/\\.(js|ts)$/, '') === base && fs.statSync(path.join(dir, file)).isFile();\n\t\t});\n\n\t\tif (found) return path.join(dir, found);\n\t}\n\n\treturn null;\n}\n\n/** @param {string} file */\nexport function read(file) {\n\treturn fs.readFileSync(file, 'utf-8');\n}\n"
  },
  {
    "path": "packages/kit/src/utils/filesystem.spec.js",
    "content": "import { mkdtempSync, writeFileSync, readdirSync, mkdirSync, readFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { assert, expect, beforeEach, test } from 'vitest';\nimport { copy, mkdirp, resolve_entry } from './filesystem.js';\n\n/** @type {string} */\nlet source_dir;\n/** @type {string} */\nlet dest_dir;\n\nbeforeEach(() => {\n\tconst temp_dir = mkdtempSync(join(tmpdir(), 'kit-core-filesystem-'));\n\tsource_dir = join(temp_dir, 'source');\n\tdest_dir = join(temp_dir, 'dest');\n\tmkdirSync(source_dir);\n\tmkdirSync(dest_dir);\n});\n\n/**\n * @param {string} file\n * @param {string} contents\n */\nconst write = (file, contents) => {\n\tconst filepath = join(source_dir, file);\n\tmkdirp(dirname(filepath));\n\twriteFileSync(filepath, contents);\n};\n\ntest('without filter', () => {\n\twrite('file-one.js', '');\n\twrite('file-two.css', '');\n\twrite('file-three', '');\n\n\tcopy(source_dir, dest_dir);\n\n\tconst copied = readdirSync(dest_dir);\n\n\texpect(copied.sort()).toEqual(['file-one.js', 'file-two.css', 'file-three'].sort());\n});\n\ntest('filters out subdirectory contents', () => {\n\twrite('file-one.js', '');\n\twrite('file-two.css', '');\n\twrite('no-copy/do-not-copy.js', '');\n\n\tcopy(source_dir, dest_dir, {\n\t\tfilter: (f) => f !== 'no-copy'\n\t});\n\n\tconst copied = readdirSync(dest_dir);\n\n\texpect(copied.sort()).toEqual(['file-one.js', 'file-two.css'].sort());\n});\n\ntest('copies recursively', () => {\n\twrite('file-one.js', '');\n\twrite('file-two.css', '');\n\twrite('deep/a.js', '');\n\twrite('deep/b.js', '');\n\n\tcopy(source_dir, dest_dir);\n\n\tconst root = readdirSync(dest_dir);\n\n\texpect(root.sort()).toEqual(['file-one.js', 'file-two.css', 'deep'].sort());\n\n\tconst subdir = readdirSync(join(dest_dir, 'deep'));\n\n\texpect(subdir.sort()).toEqual(['a.js', 'b.js'].sort());\n});\n\ntest('returns a list of copied files', () => {\n\twrite('file-one.js', '');\n\twrite('file-two.css', '');\n\twrite('deep/a.js', '');\n\twrite('deep/b.js', '');\n\n\tlet file_list = copy(source_dir, dest_dir);\n\texpect(file_list.sort()).toEqual(\n\t\t['file-one.js', 'file-two.css', 'deep/a.js', 'deep/b.js'].sort()\n\t);\n\n\tfile_list = copy(`${source_dir}/file-one.js`, `${dest_dir}/file-one-renamed.js`);\n\texpect(file_list).toEqual(['file-one-renamed.js']);\n});\n\ntest('replaces strings', () => {\n\twrite('foo.md', 'the quick brown JUMPER jumps over the lazy JUMPEE');\n\tcopy(source_dir, dest_dir, {\n\t\treplace: {\n\t\t\tJUMPER: 'fox',\n\t\t\tJUMPEE: 'dog'\n\t\t}\n\t});\n\n\tassert.equal(\n\t\treadFileSync(join(dest_dir, 'foo.md'), 'utf8'),\n\t\t'the quick brown fox jumps over the lazy dog'\n\t);\n});\n\ntest('resolves index files', () => {\n\twrite(join('service-worker', 'index.js'), '');\n\n\texpect(resolve_entry(source_dir + '/service-worker')).toBe(\n\t\tjoin(source_dir, 'service-worker', 'index.js')\n\t);\n});\n\ntest('resolves entries that have an extension', () => {\n\twrite('hooks.js', '');\n\n\texpect(resolve_entry(join(source_dir, 'hooks.js'))).toBe(join(source_dir, 'hooks.js'));\n});\n\ntest('resolves universal hooks file when hooks folder exists', () => {\n\twrite(join('hooks', 'not-index.js'), '');\n\twrite('hooks.js', '');\n\n\texpect(resolve_entry(source_dir + '/hooks')).toBe(join(source_dir, 'hooks.js'));\n});\n\ntest('ignores hooks.server folder when resolving universal hooks file', () => {\n\twrite(join('hooks.server', 'index.js'), '');\n\n\texpect(resolve_entry(source_dir + '/hooks')).null;\n});\n\ntest('ignores hooks folder when resolving universal hooks file', () => {\n\twrite(join('hooks', 'hooks.server.js'), '');\n\n\texpect(resolve_entry(source_dir + '/hooks')).null;\n});\n"
  },
  {
    "path": "packages/kit/src/utils/fork.js",
    "content": "import { fileURLToPath } from 'node:url';\nimport { Worker, parentPort } from 'node:worker_threads';\nimport process from 'node:process';\n\n/**\n * Runs a task in a subprocess so any dangling stuff gets killed upon completion.\n * The subprocess needs to be the file `forked` is called in, and `forked` needs to be called eagerly at the top level.\n * @template T\n * @template U\n * @param {string} module `import.meta.url` of the file\n * @param {(opts: T) => Promise<U>} callback The function that is invoked in the subprocess\n * @returns {(opts: T) => Promise<U>} A function that when called starts the subprocess\n */\nexport function forked(module, callback) {\n\tif (process.env.SVELTEKIT_FORK && parentPort) {\n\t\tparentPort.on(\n\t\t\t'message',\n\t\t\t/** @param {any} data */ async (data) => {\n\t\t\t\tif (data?.type === 'args' && data.module === module) {\n\t\t\t\t\tparentPort?.postMessage({\n\t\t\t\t\t\ttype: 'result',\n\t\t\t\t\t\tmodule,\n\t\t\t\t\t\tpayload: await callback(data.payload)\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tparentPort.postMessage({ type: 'ready', module });\n\t}\n\n\t/**\n\t * @param {T} opts\n\t * @returns {Promise<U>}\n\t */\n\treturn function (opts) {\n\t\treturn new Promise((fulfil, reject) => {\n\t\t\tconst worker = new Worker(fileURLToPath(module), {\n\t\t\t\tenv: {\n\t\t\t\t\t...process.env,\n\t\t\t\t\tSVELTEKIT_FORK: 'true'\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tworker.on(\n\t\t\t\t'message',\n\t\t\t\t/** @param {any} data */ (data) => {\n\t\t\t\t\tif (data?.type === 'ready' && data.module === module) {\n\t\t\t\t\t\tworker.postMessage({\n\t\t\t\t\t\t\ttype: 'args',\n\t\t\t\t\t\t\tmodule,\n\t\t\t\t\t\t\tpayload: opts\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tif (data?.type === 'result' && data.module === module) {\n\t\t\t\t\t\tworker.unref();\n\t\t\t\t\t\tfulfil(data.payload);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tworker.on('exit', (code) => {\n\t\t\t\tif (code) {\n\t\t\t\t\treject(new Error(`Failed with code ${code}`));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/utils/functions.js",
    "content": "/**\n * @template T\n * @param {() => T} fn\n */\nexport function once(fn) {\n\tlet done = false;\n\n\t/** @type T */\n\tlet result;\n\n\treturn () => {\n\t\tif (done) return result;\n\t\tdone = true;\n\t\treturn (result = fn());\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/utils/hash.js",
    "content": "/**\n * Hash using djb2\n * @param {import('types').StrictBody[]} values\n */\nexport function hash(...values) {\n\tlet hash = 5381;\n\n\tfor (const value of values) {\n\t\tif (typeof value === 'string') {\n\t\t\tlet i = value.length;\n\t\t\twhile (i) hash = (hash * 33) ^ value.charCodeAt(--i);\n\t\t} else if (ArrayBuffer.isView(value)) {\n\t\t\tconst buffer = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n\t\t\tlet i = buffer.length;\n\t\t\twhile (i) hash = (hash * 33) ^ buffer[--i];\n\t\t} else {\n\t\t\tthrow new TypeError('value must be a string or TypedArray');\n\t\t}\n\t}\n\n\treturn (hash >>> 0).toString(36);\n}\n"
  },
  {
    "path": "packages/kit/src/utils/http.js",
    "content": "import { BINARY_FORM_CONTENT_TYPE } from '../runtime/form-utils.js';\n\n/**\n * Given an Accept header and a list of possible content types, pick\n * the most suitable one to respond with\n * @param {string} accept\n * @param {string[]} types\n */\nexport function negotiate(accept, types) {\n\t/** @type {Array<{ type: string, subtype: string, q: number, i: number }>} */\n\tconst parts = [];\n\n\taccept.split(',').forEach((str, i) => {\n\t\tconst match = /([^/ \\t]+)\\/([^; \\t]+)[ \\t]*(?:;[ \\t]*q=([0-9.]+))?/.exec(str);\n\n\t\t// no match equals invalid header — ignore\n\t\tif (match) {\n\t\t\tconst [, type, subtype, q = '1'] = match;\n\t\t\tparts.push({ type, subtype, q: +q, i });\n\t\t}\n\t});\n\n\tparts.sort((a, b) => {\n\t\tif (a.q !== b.q) {\n\t\t\treturn b.q - a.q;\n\t\t}\n\n\t\tif ((a.subtype === '*') !== (b.subtype === '*')) {\n\t\t\treturn a.subtype === '*' ? 1 : -1;\n\t\t}\n\n\t\tif ((a.type === '*') !== (b.type === '*')) {\n\t\t\treturn a.type === '*' ? 1 : -1;\n\t\t}\n\n\t\treturn a.i - b.i;\n\t});\n\n\tlet accepted;\n\tlet min_priority = Infinity;\n\n\tfor (const mimetype of types) {\n\t\tconst [type, subtype] = mimetype.split('/');\n\t\tconst priority = parts.findIndex(\n\t\t\t(part) =>\n\t\t\t\t(part.type === type || part.type === '*') &&\n\t\t\t\t(part.subtype === subtype || part.subtype === '*')\n\t\t);\n\n\t\tif (priority !== -1 && priority < min_priority) {\n\t\t\taccepted = mimetype;\n\t\t\tmin_priority = priority;\n\t\t}\n\t}\n\n\treturn accepted;\n}\n\n/**\n * Returns `true` if the request contains a `content-type` header with the given type\n * @param {Request} request\n * @param  {...string} types\n */\nfunction is_content_type(request, ...types) {\n\tconst type = request.headers.get('content-type')?.split(';', 1)[0].trim() ?? '';\n\treturn types.includes(type.toLowerCase());\n}\n\n/**\n * @param {Request} request\n */\nexport function is_form_content_type(request) {\n\t// These content types must be protected against CSRF\n\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/enctype\n\treturn is_content_type(\n\t\trequest,\n\t\t'application/x-www-form-urlencoded',\n\t\t'multipart/form-data',\n\t\t'text/plain',\n\t\tBINARY_FORM_CONTENT_TYPE\n\t);\n}\n"
  },
  {
    "path": "packages/kit/src/utils/http.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport { negotiate } from './http.js';\n\ntest('handle valid accept header value', () => {\n\tconst accept = 'text/html';\n\tassert.equal(negotiate(accept, ['text/html']), 'text/html');\n});\n\ntest('handle accept values with optional whitespace', () => {\n\t// according to RFC 9110, OWS (optional whitespace, aka a space or horizontal tab)\n\t// can occur before/after the `,` and the `;`.\n\tconst accept = 'application/some-thing-else, \\tapplication/json \\t; q=0.9  ,text/plain;q=0.1';\n\tassert.equal(negotiate(accept, ['application/json', 'text/plain']), 'application/json');\n});\n\ntest('handle invalid accept header value', () => {\n\tconst accept = 'text/html,*';\n\tassert.equal(negotiate(accept, ['text/html']), 'text/html');\n});\n"
  },
  {
    "path": "packages/kit/src/utils/import.js",
    "content": "import process from 'node:process';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * Resolves a peer dependency relative to the current CWD. Duplicated with `packages/adapter-auto`\n * @param {string} dependency\n */\nfunction resolve_peer(dependency) {\n\tlet [name, ...parts] = dependency.split('/');\n\tif (name[0] === '@') name += `/${parts.shift()}`;\n\n\tlet dir = process.cwd();\n\n\twhile (!fs.existsSync(`${dir}/node_modules/${name}/package.json`)) {\n\t\tif (dir === (dir = path.dirname(dir))) {\n\t\t\tthrow new Error(\n\t\t\t\t`Could not resolve peer dependency \"${name}\" relative to your project — please install it and try again.`\n\t\t\t);\n\t\t}\n\t}\n\n\tconst pkg_dir = `${dir}/node_modules/${name}`;\n\tconst pkg = JSON.parse(fs.readFileSync(`${pkg_dir}/package.json`, 'utf-8'));\n\n\tconst subpackage = ['.', ...parts].join('/');\n\n\tlet exported = pkg.exports[subpackage];\n\n\twhile (typeof exported !== 'string') {\n\t\tif (!exported) {\n\t\t\tthrow new Error(`Could not find valid \"${subpackage}\" export in ${name}/package.json`);\n\t\t}\n\n\t\texported = exported['import'] ?? exported['default'];\n\t}\n\n\treturn path.resolve(pkg_dir, exported);\n}\n\n/**\n * Resolve a dependency relative to the current working directory,\n * rather than relative to this package (but falls back to trying that, if necessary)\n * @param {string} dependency\n */\nexport async function import_peer(dependency) {\n\ttry {\n\t\treturn await import(resolve_peer(dependency));\n\t} catch {\n\t\treturn await import(dependency);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/utils/misc.js",
    "content": "export const s = JSON.stringify;\n"
  },
  {
    "path": "packages/kit/src/utils/page_nodes.js",
    "content": "import {\n\tvalidate_layout_exports,\n\tvalidate_layout_server_exports,\n\tvalidate_page_exports,\n\tvalidate_page_server_exports\n} from './exports.js';\n\nexport class PageNodes {\n\tdata;\n\n\t/**\n\t * @param {Array<import('types').SSRNode | undefined>} nodes\n\t */\n\tconstructor(nodes) {\n\t\tthis.data = nodes;\n\t}\n\n\tlayouts() {\n\t\treturn this.data.slice(0, -1);\n\t}\n\n\tpage() {\n\t\treturn this.data.at(-1);\n\t}\n\n\tvalidate() {\n\t\tfor (const layout of this.layouts()) {\n\t\t\tif (layout) {\n\t\t\t\tvalidate_layout_server_exports(layout.server, /** @type {string} */ (layout.server_id));\n\t\t\t\tvalidate_layout_exports(layout.universal, /** @type {string} */ (layout.universal_id));\n\t\t\t}\n\t\t}\n\n\t\tconst page = this.page();\n\t\tif (page) {\n\t\t\tvalidate_page_server_exports(page.server, /** @type {string} */ (page.server_id));\n\t\t\tvalidate_page_exports(page.universal, /** @type {string} */ (page.universal_id));\n\t\t}\n\t}\n\n\t/**\n\t * @template {'prerender' | 'ssr' | 'csr' | 'trailingSlash'} Option\n\t * @param {Option} option\n\t * @returns {Value | undefined}\n\t */\n\t#get_option(option) {\n\t\t/** @typedef {(import('types').UniversalNode | import('types').ServerNode)[Option]} Value */\n\n\t\treturn this.data.reduce((value, node) => {\n\t\t\treturn node?.universal?.[option] ?? node?.server?.[option] ?? value;\n\t\t}, /** @type {Value | undefined} */ (undefined));\n\t}\n\n\tcsr() {\n\t\treturn this.#get_option('csr') ?? true;\n\t}\n\n\tssr() {\n\t\treturn this.#get_option('ssr') ?? true;\n\t}\n\n\tprerender() {\n\t\treturn this.#get_option('prerender') ?? false;\n\t}\n\n\ttrailing_slash() {\n\t\treturn this.#get_option('trailingSlash') ?? 'never';\n\t}\n\n\tget_config() {\n\t\t/** @type {any} */\n\t\tlet current = {};\n\n\t\tfor (const node of this.data) {\n\t\t\tif (!node?.universal?.config && !node?.server?.config) continue;\n\n\t\t\tcurrent = {\n\t\t\t\t...current,\n\t\t\t\t// TODO: should we override the server config value with the universal value similar to other page options?\n\t\t\t\t...node?.universal?.config,\n\t\t\t\t...node?.server?.config\n\t\t\t};\n\t\t}\n\n\t\t// TODO 3.0 always return `current`? then we can get rid of `?? {}` in other places\n\t\treturn Object.keys(current).length ? current : undefined;\n\t}\n\n\tshould_prerender_data() {\n\t\treturn this.data.some(\n\t\t\t// prerender in case of trailingSlash because the client retrieves that value from the server\n\t\t\t(node) => node?.server?.load || node?.server?.trailingSlash !== undefined\n\t\t);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/utils/promise.js",
    "content": "/** @see https://github.com/microsoft/TypeScript/blob/904e7dd97dc8da1352c8e05d70829dff17c73214/src/lib/es2024.promise.d.ts */\n\n/**\n * @template T\n * @typedef {{\n *   promise: Promise<T>;\n *   resolve: (value: T | PromiseLike<T>) => void;\n *   reject: (reason?: any) => void;\n * }} PromiseWithResolvers<T>\n */\n\n/**\n * TODO: Whenever Node >21 is minimum supported version, we can use `Promise.withResolvers` to avoid this ceremony\n *\n * @template T\n * @returns {PromiseWithResolvers<T>}\n */\nexport function with_resolvers() {\n\tlet resolve;\n\tlet reject;\n\n\tconst promise = new Promise((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\n\t// @ts-expect-error `resolve` and `reject` are assigned!\n\treturn { promise, resolve, reject };\n}\n"
  },
  {
    "path": "packages/kit/src/utils/routing.js",
    "content": "import { BROWSER } from 'esm-env';\nimport { decode_params } from './url.js';\n\nconst param_pattern = /^(\\[)?(\\.\\.\\.)?(\\w+)(?:=(\\w+))?(\\])?$/;\n\n/**\n * Creates the regex pattern, extracts parameter names, and generates types for a route\n * @param {string} id\n */\nexport function parse_route_id(id) {\n\t/** @type {import('types').RouteParam[]} */\n\tconst params = [];\n\n\tconst pattern =\n\t\tid === '/'\n\t\t\t? /^\\/$/\n\t\t\t: new RegExp(\n\t\t\t\t\t`^${get_route_segments(id)\n\t\t\t\t\t\t.map((segment) => {\n\t\t\t\t\t\t\t// special case — /[...rest]/ could contain zero segments\n\t\t\t\t\t\t\tconst rest_match = /^\\[\\.\\.\\.(\\w+)(?:=(\\w+))?\\]$/.exec(segment);\n\t\t\t\t\t\t\tif (rest_match) {\n\t\t\t\t\t\t\t\tparams.push({\n\t\t\t\t\t\t\t\t\tname: rest_match[1],\n\t\t\t\t\t\t\t\t\tmatcher: rest_match[2],\n\t\t\t\t\t\t\t\t\toptional: false,\n\t\t\t\t\t\t\t\t\trest: true,\n\t\t\t\t\t\t\t\t\tchained: true\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn '(?:/([^]*))?';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// special case — /[[optional]]/ could contain zero segments\n\t\t\t\t\t\t\tconst optional_match = /^\\[\\[(\\w+)(?:=(\\w+))?\\]\\]$/.exec(segment);\n\t\t\t\t\t\t\tif (optional_match) {\n\t\t\t\t\t\t\t\tparams.push({\n\t\t\t\t\t\t\t\t\tname: optional_match[1],\n\t\t\t\t\t\t\t\t\tmatcher: optional_match[2],\n\t\t\t\t\t\t\t\t\toptional: true,\n\t\t\t\t\t\t\t\t\trest: false,\n\t\t\t\t\t\t\t\t\tchained: true\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn '(?:/([^/]+))?';\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!segment) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst parts = segment.split(/\\[(.+?)\\](?!\\])/);\n\t\t\t\t\t\t\tconst result = parts\n\t\t\t\t\t\t\t\t.map((content, i) => {\n\t\t\t\t\t\t\t\t\tif (i % 2) {\n\t\t\t\t\t\t\t\t\t\tif (content.startsWith('x+')) {\n\t\t\t\t\t\t\t\t\t\t\treturn escape(String.fromCharCode(parseInt(content.slice(2), 16)));\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tif (content.startsWith('u+')) {\n\t\t\t\t\t\t\t\t\t\t\treturn escape(\n\t\t\t\t\t\t\t\t\t\t\t\tString.fromCharCode(\n\t\t\t\t\t\t\t\t\t\t\t\t\t...content\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t.slice(2)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t.split('-')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t.map((code) => parseInt(code, 16))\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t// We know the match cannot be null in the browser because manifest generation\n\t\t\t\t\t\t\t\t\t\t// would have invoked this during build and failed if we hit an invalid\n\t\t\t\t\t\t\t\t\t\t// param/matcher name with non-alphanumeric character.\n\t\t\t\t\t\t\t\t\t\tconst match = /** @type {RegExpExecArray} */ (param_pattern.exec(content));\n\t\t\t\t\t\t\t\t\t\tif (!BROWSER && !match) {\n\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t\t\t`Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tconst [, is_optional, is_rest, name, matcher] = match;\n\t\t\t\t\t\t\t\t\t\t// It's assumed that the following invalid route id cases are already checked\n\t\t\t\t\t\t\t\t\t\t// - unbalanced brackets\n\t\t\t\t\t\t\t\t\t\t// - optional param following rest param\n\n\t\t\t\t\t\t\t\t\t\tparams.push({\n\t\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\t\tmatcher,\n\t\t\t\t\t\t\t\t\t\t\toptional: !!is_optional,\n\t\t\t\t\t\t\t\t\t\t\trest: !!is_rest,\n\t\t\t\t\t\t\t\t\t\t\tchained: is_rest ? i === 1 && parts[0] === '' : false\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\treturn is_rest ? '([^]*?)' : is_optional ? '([^/]*)?' : '([^/]+?)';\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn escape(content);\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.join('');\n\n\t\t\t\t\t\t\treturn '/' + result;\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join('')}/?$`\n\t\t\t\t);\n\n\treturn { pattern, params };\n}\n\nconst optional_param_regex = /\\/\\[\\[\\w+?(?:=\\w+)?\\]\\]/;\n\n/**\n * Removes optional params from a route ID.\n * @param {string} id\n * @returns The route id with optional params removed\n */\nexport function remove_optional_params(id) {\n\treturn id.replace(optional_param_regex, '');\n}\n\n/**\n * Returns `false` for `(group)` segments\n * @param {string} segment\n */\nfunction affects_path(segment) {\n\treturn segment !== '' && !/^\\([^)]+\\)$/.test(segment);\n}\n\n/**\n * Splits a route id into its segments, removing segments that\n * don't affect the path (i.e. groups). The root route is represented by `/`\n * and will be returned as `['']`.\n * @param {string} route\n * @returns string[]\n */\nexport function get_route_segments(route) {\n\treturn route.slice(1).split('/').filter(affects_path);\n}\n\n/**\n * @param {RegExpMatchArray} match\n * @param {import('types').RouteParam[]} params\n * @param {Record<string, import('@sveltejs/kit').ParamMatcher>} matchers\n */\nexport function exec(match, params, matchers) {\n\t/** @type {Record<string, string>} */\n\tconst result = {};\n\n\tconst values = match.slice(1);\n\tconst values_needing_match = values.filter((value) => value !== undefined);\n\n\tlet buffered = 0;\n\n\tfor (let i = 0; i < params.length; i += 1) {\n\t\tconst param = params[i];\n\t\tlet value = values[i - buffered];\n\n\t\t// in the `[[a=b]]/.../[...rest]` case, if one or more optional parameters\n\t\t// weren't matched, roll the skipped values into the rest\n\t\tif (param.chained && param.rest && buffered) {\n\t\t\tvalue = values\n\t\t\t\t.slice(i - buffered, i + 1)\n\t\t\t\t.filter((s) => s)\n\t\t\t\t.join('/');\n\n\t\t\tbuffered = 0;\n\t\t}\n\n\t\t// if `value` is undefined, it means this is an optional or rest parameter\n\t\tif (value === undefined) {\n\t\t\tif (param.rest) {\n\t\t\t\t// We need to allow the matcher to run so that it can decide if this optional rest param should be allowed to match\n\t\t\t\tvalue = '';\n\t\t\t} else {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tif (!param.matcher || matchers[param.matcher](value)) {\n\t\t\tresult[param.name] = value;\n\n\t\t\t// Now that the params match, reset the buffer if the next param isn't the [...rest]\n\t\t\t// and the next value is defined, otherwise the buffer will cause us to skip values\n\t\t\tconst next_param = params[i + 1];\n\t\t\tconst next_value = values[i + 1];\n\t\t\tif (next_param && !next_param.rest && next_param.optional && next_value && param.chained) {\n\t\t\t\tbuffered = 0;\n\t\t\t}\n\n\t\t\t// There are no more params and no more values, but all non-empty values have been matched\n\t\t\tif (\n\t\t\t\t!next_param &&\n\t\t\t\t!next_value &&\n\t\t\t\tObject.keys(result).length === values_needing_match.length\n\t\t\t) {\n\t\t\t\tbuffered = 0;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// in the `/[[a=b]]/...` case, if the value didn't satisfy the matcher,\n\t\t// keep track of the number of skipped optional parameters and continue\n\t\tif (param.optional && param.chained) {\n\t\t\tbuffered++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// otherwise, if the matcher returns `false`, the route did not match\n\t\treturn;\n\t}\n\n\tif (buffered) return;\n\treturn result;\n}\n\n/** @param {string} str */\nfunction escape(str) {\n\treturn (\n\t\tstr\n\t\t\t.normalize()\n\t\t\t// escape [ and ] before escaping other characters, since they are used in the replacements\n\t\t\t.replace(/[[\\]]/g, '\\\\$&')\n\t\t\t// replace %, /, ? and # with their encoded versions because decode_pathname leaves them untouched\n\t\t\t.replace(/%/g, '%25')\n\t\t\t.replace(/\\//g, '%2[Ff]')\n\t\t\t.replace(/\\?/g, '%3[Ff]')\n\t\t\t.replace(/#/g, '%23')\n\t\t\t// escape characters that have special meaning in regex\n\t\t\t.replace(/[.*+?^${}()|\\\\]/g, '\\\\$&')\n\t);\n}\n\nconst basic_param_pattern = /\\[(\\[)?(\\.\\.\\.)?(\\w+?)(?:=(\\w+))?\\]\\]?/g;\n\n/**\n * Populate a route ID with params to resolve a pathname.\n * @example\n * ```js\n * resolveRoute(\n *   `/blog/[slug]/[...somethingElse]`,\n *   {\n *     slug: 'hello-world',\n *     somethingElse: 'something/else'\n *   }\n * ); // `/blog/hello-world/something/else`\n * ```\n * @param {string} id\n * @param {Record<string, string | undefined>} params\n * @returns {string}\n */\nexport function resolve_route(id, params) {\n\tconst segments = get_route_segments(id);\n\tconst has_id_trailing_slash = id != '/' && id.endsWith('/');\n\n\treturn (\n\t\t'/' +\n\t\tsegments\n\t\t\t.map((segment) =>\n\t\t\t\tsegment.replace(basic_param_pattern, (_, optional, rest, name) => {\n\t\t\t\t\tconst param_value = params[name];\n\n\t\t\t\t\t// This is nested so TS correctly narrows the type\n\t\t\t\t\tif (!param_value) {\n\t\t\t\t\t\tif (optional) return '';\n\t\t\t\t\t\tif (rest && param_value !== undefined) return '';\n\t\t\t\t\t\tthrow new Error(`Missing parameter '${name}' in route ${id}`);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (param_value.startsWith('/') || param_value.endsWith('/'))\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Parameter '${name}' in route ${id} cannot start or end with a slash -- this would cause an invalid route like foo//bar`\n\t\t\t\t\t\t);\n\t\t\t\t\treturn param_value;\n\t\t\t\t})\n\t\t\t)\n\t\t\t.filter(Boolean)\n\t\t\t.join('/') +\n\t\t(has_id_trailing_slash ? '/' : '')\n\t);\n}\n\n/**\n * @param {import('types').SSRNode} node\n * @returns {boolean}\n */\nexport function has_server_load(node) {\n\treturn node.server?.load !== undefined || node.server?.trailingSlash !== undefined;\n}\n\n/**\n * Find the first route that matches the given path\n * @template {{pattern: RegExp, params: import('types').RouteParam[]}} Route\n * @param {string} path - The decoded pathname to match\n * @param {Route[]} routes\n * @param {Record<string, import('@sveltejs/kit').ParamMatcher>} matchers\n * @returns {{ route: Route, params: Record<string, string> } | null}\n */\nexport function find_route(path, routes, matchers) {\n\tfor (const route of routes) {\n\t\tconst match = route.pattern.exec(path);\n\t\tif (!match) continue;\n\n\t\tconst matched = exec(match, route.params, matchers);\n\t\tif (matched) {\n\t\t\treturn {\n\t\t\t\troute,\n\t\t\t\tparams: decode_params(matched)\n\t\t\t};\n\t\t}\n\t}\n\treturn null;\n}\n"
  },
  {
    "path": "packages/kit/src/utils/routing.spec.js",
    "content": "import { assert, expect, test, describe } from 'vitest';\nimport { exec, parse_route_id, resolve_route, find_route } from './routing.js';\n\ndescribe('parse_route_id', () => {\n\tconst tests = {\n\t\t'/': {\n\t\t\tpattern: /^\\/$/,\n\t\t\tparams: []\n\t\t},\n\t\t'/blog': {\n\t\t\tpattern: /^\\/blog\\/?$/,\n\t\t\tparams: []\n\t\t},\n\t\t'/blog.json': {\n\t\t\tpattern: /^\\/blog\\.json\\/?$/,\n\t\t\tparams: []\n\t\t},\n\t\t'/blog/[slug]': {\n\t\t\tpattern: /^\\/blog\\/([^/]+?)\\/?$/,\n\t\t\tparams: [{ name: 'slug', matcher: undefined, optional: false, rest: false, chained: false }]\n\t\t},\n\t\t'/blog/[slug].json': {\n\t\t\tpattern: /^\\/blog\\/([^/]+?)\\.json\\/?$/,\n\t\t\tparams: [{ name: 'slug', matcher: undefined, optional: false, rest: false, chained: false }]\n\t\t},\n\t\t'/blog/[[slug]]': {\n\t\t\tpattern: /^\\/blog(?:\\/([^/]+))?\\/?$/,\n\t\t\tparams: [{ name: 'slug', matcher: undefined, optional: true, rest: false, chained: true }]\n\t\t},\n\t\t'/blog/[[slug=type]]/sub': {\n\t\t\tpattern: /^\\/blog(?:\\/([^/]+))?\\/sub\\/?$/,\n\t\t\tparams: [{ name: 'slug', matcher: 'type', optional: true, rest: false, chained: true }]\n\t\t},\n\t\t'/blog/[[slug]].json': {\n\t\t\tpattern: /^\\/blog\\/([^/]*)?\\.json\\/?$/,\n\t\t\tparams: [{ name: 'slug', matcher: undefined, optional: true, rest: false, chained: false }]\n\t\t},\n\t\t'/[...catchall]': {\n\t\t\tpattern: /^(?:\\/([^]*))?\\/?$/,\n\t\t\tparams: [{ name: 'catchall', matcher: undefined, optional: false, rest: true, chained: true }]\n\t\t},\n\t\t'/foo/[...catchall]/bar': {\n\t\t\tpattern: /^\\/foo(?:\\/([^]*))?\\/bar\\/?$/,\n\t\t\tparams: [{ name: 'catchall', matcher: undefined, optional: false, rest: true, chained: true }]\n\t\t},\n\t\t'/matched/[id=uuid]': {\n\t\t\tpattern: /^\\/matched\\/([^/]+?)\\/?$/,\n\t\t\tparams: [{ name: 'id', matcher: 'uuid', optional: false, rest: false, chained: false }]\n\t\t},\n\t\t'/@-symbol/[id]': {\n\t\t\tpattern: /^\\/@-symbol\\/([^/]+?)\\/?$/,\n\t\t\tparams: [{ name: 'id', matcher: undefined, optional: false, rest: false, chained: false }]\n\t\t}\n\t};\n\n\tfor (const [key, expected] of Object.entries(tests)) {\n\t\ttest(key, () => {\n\t\t\tconst actual = parse_route_id(key);\n\n\t\t\texpect(actual.pattern.toString()).toEqual(expected.pattern.toString());\n\t\t\texpect(actual.params).toEqual(expected.params);\n\t\t});\n\t}\n});\n\ndescribe('exec', () => {\n\tconst tests = [\n\t\t{\n\t\t\troute: '/blog/[[slug]]/sub[[param]]',\n\t\t\tpath: '/blog/sub',\n\t\t\texpected: {}\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[[slug]]/sub[[param]]',\n\t\t\tpath: '/blog/slug/sub',\n\t\t\texpected: { slug: 'slug' }\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[[slug]]/sub[[param]]',\n\t\t\tpath: '/blog/slug/subparam',\n\t\t\texpected: { slug: 'slug', param: 'param' }\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[[slug]]/sub[[param]]',\n\t\t\tpath: '/blog/subparam',\n\t\t\texpected: { param: 'param' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug]]/[...rest]',\n\t\t\tpath: '/slug/rest/sub',\n\t\t\texpected: { slug: 'slug', rest: 'rest/sub' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug]]/[...rest]',\n\t\t\tpath: '/slug/rest',\n\t\t\texpected: { slug: 'slug', rest: 'rest' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug]]/[...rest]',\n\t\t\tpath: '/slug',\n\t\t\texpected: { slug: 'slug', rest: '' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug]]/[...rest]',\n\t\t\tpath: '/',\n\t\t\texpected: { rest: '' }\n\t\t},\n\t\t{\n\t\t\troute: '/[...rest]/path',\n\t\t\tpath: '/rest/path',\n\t\t\texpected: { rest: 'rest' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1]]/[[slug2]]',\n\t\t\tpath: '/slug1/slug2',\n\t\t\texpected: { slug1: 'slug1', slug2: 'slug2' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1]]/[[slug2]]',\n\t\t\tpath: '/slug1',\n\t\t\texpected: { slug1: 'slug1' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=matches]]',\n\t\t\tpath: '/',\n\t\t\texpected: {}\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=doesntmatch]]',\n\t\t\tpath: '/',\n\t\t\texpected: {}\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=matches]]/[[slug2=doesntmatch]]',\n\t\t\tpath: '/foo',\n\t\t\texpected: { slug1: 'foo' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=doesntmatch]]/[[slug2=doesntmatch]]',\n\t\t\tpath: '/foo',\n\t\t\texpected: undefined\n\t\t},\n\t\t{\n\t\t\troute: '/[...slug1=matches]',\n\t\t\tpath: '/',\n\t\t\texpected: { slug1: '' }\n\t\t},\n\t\t{\n\t\t\troute: '/[...slug1=doesntmatch]',\n\t\t\tpath: '/',\n\t\t\texpected: undefined\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug=doesntmatch]]/[...rest]',\n\t\t\tpath: '/foo',\n\t\t\texpected: { rest: 'foo' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=doesntmatch]]/[slug2]/[...rest]',\n\t\t\tpath: '/foo/bar/baz',\n\t\t\texpected: { slug2: 'foo', rest: 'bar/baz' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=doesntmatch]]/[slug2]/[...rest]/baz',\n\t\t\tpath: '/foo/bar/baz',\n\t\t\texpected: { slug2: 'foo', rest: 'bar' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[a=doesntmatch]]/[[b=doesntmatch]]/[[c=doesntmatch]]/[...d]',\n\t\t\tpath: '/a/b/c/d',\n\t\t\texpected: { d: 'a/b/c/d' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[a=doesntmatch]]/[b]/[...c]/[d]/e',\n\t\t\tpath: '/foo/bar/baz/qux/e',\n\t\t\texpected: { b: 'foo', c: 'bar/baz', d: 'qux' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=doesntmatch]]/[[slug2=doesntmatch]]/[...rest]',\n\t\t\tpath: '/foo/bar/baz',\n\t\t\texpected: { rest: 'foo/bar/baz' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=doesntmatch]]/[[slug2=matches]]/[[slug3=doesntmatch]]/[...rest].json',\n\t\t\tpath: '/foo/bar/baz.json',\n\t\t\texpected: { slug2: 'foo', rest: 'bar/baz' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[a=doesntmatch]]/[[b=matches]]/c',\n\t\t\tpath: '/a/b/c',\n\t\t\texpected: undefined\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=matches]]/[[slug2=matches]]/constant/[[slug3=matches]]',\n\t\t\tpath: '/a/b/constant/c',\n\t\t\texpected: { slug1: 'a', slug2: 'b', slug3: 'c' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=doesntmatch]]/[[slug2=matches]]/constant/[[slug3=matches]]',\n\t\t\tpath: '/b/constant/c',\n\t\t\texpected: { slug2: 'b', slug3: 'c' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=doesntmatch]]/[[slug2=matches]]/[[slug3=matches]]',\n\t\t\tpath: '/b/c',\n\t\t\texpected: { slug2: 'b', slug3: 'c' }\n\t\t},\n\t\t{\n\t\t\troute: '/[slug1]/[[lang=doesntmatch]]/[[page=matches]]',\n\t\t\tpath: '/a/2',\n\t\t\texpected: { slug1: 'a', lang: undefined, page: '2' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=doesntmatch]]/[slug2=matches]/[slug3]',\n\t\t\tpath: '/a/b/c',\n\t\t\texpected: undefined\n\t\t},\n\t\t{\n\t\t\troute: '/[[lang=doesntmatch]]/[asset=matches]/[[categoryType]]/[...categories]',\n\t\t\tpath: '/music',\n\t\t\texpected: { asset: 'music', categories: '' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[lang=doesntmatch]]/[asset=matches]/[[categoryType]]/[...categories]',\n\t\t\tpath: '/music/genre',\n\t\t\texpected: { asset: 'music', categoryType: 'genre', categories: '' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[lang=doesntmatch]]/[asset=matches]/[[categoryType]]/[...categories]',\n\t\t\tpath: '/music/genre/rock',\n\t\t\texpected: { asset: 'music', categoryType: 'genre', categories: 'rock' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[lang=doesntmatch]]/[asset=matches]/[[categoryType]]/[...categories]',\n\t\t\tpath: '/sfx/category/car/crash',\n\t\t\texpected: { asset: 'sfx', categoryType: 'category', categories: 'car/crash' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[lang=matches]]/[asset=matches]/[[categoryType]]/[...categories]',\n\t\t\tpath: '/es/sfx/category/car/crash',\n\t\t\texpected: { lang: 'es', asset: 'sfx', categoryType: 'category', categories: 'car/crash' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[slug1=doesntmatch]]/[...slug2=doesntmatch]',\n\t\t\tpath: '/a/b/c',\n\t\t\texpected: undefined\n\t\t},\n\t\t{\n\t\t\troute: '/[...a=doesntmatch]/[b]',\n\t\t\tpath: '/foo',\n\t\t\texpected: undefined\n\t\t},\n\t\t{\n\t\t\troute: '/[...a=matches]/[b]',\n\t\t\tpath: '/foo',\n\t\t\texpected: { a: '', b: 'foo' }\n\t\t},\n\t\t{\n\t\t\troute: '/[...a=doesntmatch]/[b]/[c]',\n\t\t\tpath: '/foo/bar',\n\t\t\texpected: undefined\n\t\t},\n\t\t{\n\t\t\troute: '/[...a=matches]/[b]/[c]',\n\t\t\tpath: '/foo/bar',\n\t\t\texpected: { a: '', b: 'foo', c: 'bar' }\n\t\t},\n\t\t{\n\t\t\troute: '/[...catchall]',\n\t\t\tpath: '/\\n',\n\t\t\texpected: { catchall: '\\n' }\n\t\t},\n\t\t{\n\t\t\troute: '/[[...catchall]]',\n\t\t\tpath: '/\\n',\n\t\t\texpected: { catchall: '\\n' }\n\t\t}\n\t];\n\n\tfor (const { path, route, expected } of tests) {\n\t\ttest(`exec extracts params correctly for ${path} from ${route}`, () => {\n\t\t\tconst { pattern, params } = parse_route_id(route);\n\t\t\tconst match = pattern.exec(path);\n\t\t\tif (!match) throw new Error(`Failed to match ${path}`);\n\t\t\tconst actual = exec(match, params, {\n\t\t\t\tmatches: () => true,\n\t\t\t\tdoesntmatch: () => false\n\t\t\t});\n\t\t\texpect(actual).toEqual(expected);\n\t\t});\n\t}\n});\n\ndescribe('resolve_route', () => {\n\tconst from_params_tests = [\n\t\t{\n\t\t\troute: '/blog/[one]/[two]',\n\t\t\tparams: { one: 'one', two: 'two' },\n\t\t\texpected: '/blog/one/two'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[one]/[two]/',\n\t\t\tparams: { one: 'one', two: 'two' },\n\t\t\texpected: '/blog/one/two/'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[one=matcher]/[...two]',\n\t\t\tparams: { one: 'one', two: 'two/three' },\n\t\t\texpected: '/blog/one/two/three'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[one=matcher]/[...two]/',\n\t\t\tparams: { one: 'one', two: 'two/three' },\n\t\t\texpected: '/blog/one/two/three/'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[one=matcher]/[[two]]',\n\t\t\tparams: { one: 'one' },\n\t\t\texpected: '/blog/one'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[one=matcher]/[[two]]/',\n\t\t\tparams: { one: 'one' },\n\t\t\texpected: '/blog/one/'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[one]/[two]-and-[three]',\n\t\t\tparams: { one: 'one', two: '2', three: '3' },\n\t\t\texpected: '/blog/one/2-and-3'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[one]/[two]-and-[three]/',\n\t\t\tparams: { one: 'one', two: '2', three: '3' },\n\t\t\texpected: '/blog/one/2-and-3/'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[...one]',\n\t\t\tparams: { one: '' },\n\t\t\texpected: '/blog'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[...one]/',\n\t\t\tparams: { one: '' },\n\t\t\texpected: '/blog/'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[one]/[...two]-not-three',\n\t\t\tparams: { one: 'one', two: 'two/2' },\n\t\t\texpected: '/blog/one/two/2-not-three'\n\t\t},\n\t\t{\n\t\t\troute: '/blog/[one]/[...two]-not-three/',\n\t\t\tparams: { one: 'one', two: 'two/2' },\n\t\t\texpected: '/blog/one/two/2-not-three/'\n\t\t}\n\t];\n\n\tfor (const { route, params, expected } of from_params_tests) {\n\t\ttest(`resolvePath generates correct path for ${route}`, () => {\n\t\t\tconst result = resolve_route(route, params);\n\t\t\tassert.equal(result, expected);\n\t\t});\n\t}\n\n\ttest('resolvePath errors on missing params for required param', () => {\n\t\texpect(() => resolve_route('/blog/[one]/[two]', { one: 'one' })).toThrow(\n\t\t\t\"Missing parameter 'two' in route /blog/[one]/[two]\"\n\t\t);\n\t});\n\n\ttest('resolvePath errors on params values starting or ending with slashes', () => {\n\t\tassert.throws(\n\t\t\t() => resolve_route('/blog/[one]/[two]', { one: 'one', two: '/two' }),\n\t\t\t\"Parameter 'two' in route /blog/[one]/[two] cannot start or end with a slash -- this would cause an invalid route like foo//bar\"\n\t\t);\n\t\tassert.throws(\n\t\t\t() => resolve_route('/blog/[one]/[two]', { one: 'one', two: 'two/' }),\n\t\t\t\"Parameter 'two' in route /blog/[one]/[two] cannot start or end with a slash -- this would cause an invalid route like foo//bar\"\n\t\t);\n\t});\n});\n\ndescribe('find_route', () => {\n\t/** @param {string} id */\n\tfunction create_route(id) {\n\t\tconst { pattern, params } = parse_route_id(id);\n\t\treturn { id, pattern, params };\n\t}\n\n\ttest('finds matching route', () => {\n\t\tconst routes = [create_route('/blog'), create_route('/blog/[slug]'), create_route('/about')];\n\n\t\tconst result = find_route('/blog/hello-world', routes, {});\n\t\tassert.equal(result?.route.id, '/blog/[slug]');\n\t\tassert.deepEqual(result?.params, { slug: 'hello-world' });\n\t});\n\n\ttest('returns first matching route', () => {\n\t\tconst routes = [create_route('/blog/[slug]'), create_route('/blog/[...rest]')];\n\n\t\tconst result = find_route('/blog/hello', routes, {});\n\t\tassert.equal(result?.route.id, '/blog/[slug]');\n\t});\n\n\ttest('returns null for no match', () => {\n\t\tconst routes = [create_route('/blog'), create_route('/about')];\n\n\t\tconst result = find_route('/contact', routes, {});\n\t\tassert.equal(result, null);\n\t});\n\n\ttest('respects matchers', () => {\n\t\tconst routes = [create_route('/blog/[slug=word]'), create_route('/blog/[slug]')];\n\t\t/** @type {Record<string, import('@sveltejs/kit').ParamMatcher>} */\n\t\tconst matchers = {\n\t\t\tword: (param) => /^\\w+$/.test(param)\n\t\t};\n\n\t\t// \"hello\" matches the word matcher\n\t\tconst result1 = find_route('/blog/hello', routes, matchers);\n\t\tassert.equal(result1?.route.id, '/blog/[slug=word]');\n\n\t\t// \"hello-world\" doesn't match word matcher, falls through to [slug]\n\t\tconst result2 = find_route('/blog/hello-world', routes, matchers);\n\t\tassert.equal(result2?.route.id, '/blog/[slug]');\n\t});\n\n\ttest('decodes params', () => {\n\t\tconst routes = [create_route('/blog/[slug]')];\n\n\t\tconst result = find_route('/blog/hello%20world', routes, {});\n\t\tassert.equal(result?.params.slug, 'hello world');\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/utils/streaming.js",
    "content": "import { with_resolvers } from './promise.js';\n\n/**\n * Create an async iterator and a function to push values into it\n * @template T\n * @returns {{\n *   iterate: (transform?: (input: T) => T) => AsyncIterable<T>;\n *   add: (promise: Promise<T>) => void;\n * }}\n */\nexport function create_async_iterator() {\n\tlet resolved = -1;\n\tlet returned = -1;\n\n\t/** @type {import('./promise.js').PromiseWithResolvers<T>[]} */\n\tconst deferred = [];\n\n\treturn {\n\t\titerate: (transform = (x) => x) => {\n\t\t\treturn {\n\t\t\t\t[Symbol.asyncIterator]() {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tnext: async () => {\n\t\t\t\t\t\t\tconst next = deferred[++returned];\n\t\t\t\t\t\t\tif (!next) return { value: null, done: true };\n\n\t\t\t\t\t\t\tconst value = await next.promise;\n\t\t\t\t\t\t\treturn { value: transform(value), done: false };\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tadd: (promise) => {\n\t\t\tdeferred.push(with_resolvers());\n\t\t\tvoid promise.then((value) => {\n\t\t\t\tdeferred[++resolved].resolve(value);\n\t\t\t});\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/src/utils/streaming.spec.js",
    "content": "import { expect, test } from 'vitest';\nimport { create_async_iterator } from './streaming.js';\n\ntest('works with fast consecutive promise resolutions', async () => {\n\tconst { iterate, add } = create_async_iterator();\n\n\tadd(Promise.resolve(1));\n\tadd(Promise.resolve(2));\n\n\tconst actual = [];\n\tfor await (const value of iterate((n) => n * 10)) {\n\t\tactual.push(value);\n\t}\n\n\texpect(actual).toEqual([10, 20]);\n});\n"
  },
  {
    "path": "packages/kit/src/utils/url.js",
    "content": "import { BROWSER, DEV } from 'esm-env';\n\n/**\n * Matches a URI scheme. See https://www.rfc-editor.org/rfc/rfc3986#section-3.1\n * @type {RegExp}\n */\nexport const SCHEME = /^[a-z][a-z\\d+\\-.]+:/i;\n\nconst internal = new URL('sveltekit-internal://');\n\n/**\n * @param {string} base\n * @param {string} path\n */\nexport function resolve(base, path) {\n\t// special case\n\tif (path[0] === '/' && path[1] === '/') return path;\n\n\tlet url = new URL(base, internal);\n\turl = new URL(path, url);\n\n\treturn url.protocol === internal.protocol ? url.pathname + url.search + url.hash : url.href;\n}\n\n/** @param {string} path */\nexport function is_root_relative(path) {\n\treturn path[0] === '/' && path[1] !== '/';\n}\n\n/**\n * @param {string} path\n * @param {import('types').TrailingSlash} trailing_slash\n */\nexport function normalize_path(path, trailing_slash) {\n\tif (path === '/' || trailing_slash === 'ignore') return path;\n\n\tif (trailing_slash === 'never') {\n\t\treturn path.endsWith('/') ? path.slice(0, -1) : path;\n\t} else if (trailing_slash === 'always' && !path.endsWith('/')) {\n\t\treturn path + '/';\n\t}\n\n\treturn path;\n}\n\n/**\n * Decode pathname excluding %25 to prevent further double decoding of params\n * @param {string} pathname\n */\nexport function decode_pathname(pathname) {\n\treturn pathname.split('%25').map(decodeURI).join('%25');\n}\n\n/** @param {Record<string, string>} params */\nexport function decode_params(params) {\n\tfor (const key in params) {\n\t\t// input has already been decoded by decodeURI\n\t\t// now handle the rest\n\t\tparams[key] = decodeURIComponent(params[key]);\n\t}\n\n\treturn params;\n}\n\n/**\n * The error when a URL is malformed is not very helpful, so we augment it with the URI\n * @param {string} uri\n */\nexport function decode_uri(uri) {\n\ttry {\n\t\treturn decodeURI(uri);\n\t} catch (e) {\n\t\tif (e instanceof Error) {\n\t\t\te.message = `Failed to decode URI: ${uri}\\n` + e.message;\n\t\t}\n\t\tthrow e;\n\t}\n}\n\n/**\n * Returns everything up to the first `#` in a URL\n * @param {{href: string}} url_like\n */\nexport function strip_hash({ href }) {\n\treturn href.split('#')[0];\n}\n\n/**\n * @param {URL} url\n * @param {() => void} callback\n * @param {(search_param: string) => void} search_params_callback\n * @param {boolean} [allow_hash]\n */\nexport function make_trackable(url, callback, search_params_callback, allow_hash = false) {\n\tconst tracked = new URL(url);\n\n\tObject.defineProperty(tracked, 'searchParams', {\n\t\tvalue: new Proxy(tracked.searchParams, {\n\t\t\tget(obj, key) {\n\t\t\t\tif (key === 'get' || key === 'getAll' || key === 'has') {\n\t\t\t\t\treturn (/** @type {string} */ param, /** @type {string[]} */ ...rest) => {\n\t\t\t\t\t\tsearch_params_callback(param);\n\t\t\t\t\t\treturn obj[key](param, ...rest);\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// if they try to access something different from what is in `tracked_search_params_properties`\n\t\t\t\t// we track the whole url (entries, values, keys etc)\n\t\t\t\tcallback();\n\n\t\t\t\tconst value = Reflect.get(obj, key);\n\t\t\t\treturn typeof value === 'function' ? value.bind(obj) : value;\n\t\t\t}\n\t\t}),\n\t\tenumerable: true,\n\t\tconfigurable: true\n\t});\n\n\t/**\n\t * URL properties that could change during the lifetime of the page,\n\t * which excludes things like `origin`\n\t */\n\tconst tracked_url_properties = ['href', 'pathname', 'search', 'toString', 'toJSON'];\n\tif (allow_hash) tracked_url_properties.push('hash');\n\n\tfor (const property of tracked_url_properties) {\n\t\tObject.defineProperty(tracked, property, {\n\t\t\tget() {\n\t\t\t\tcallback();\n\t\t\t\t// @ts-expect-error\n\t\t\t\treturn url[property];\n\t\t\t},\n\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true\n\t\t});\n\t}\n\n\tif (!BROWSER) {\n\t\t// @ts-ignore\n\t\ttracked[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => {\n\t\t\treturn inspect(url, opts);\n\t\t};\n\n\t\t// @ts-ignore\n\t\ttracked.searchParams[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => {\n\t\t\treturn inspect(url.searchParams, opts);\n\t\t};\n\t}\n\n\tif ((DEV || !BROWSER) && !allow_hash) {\n\t\tdisable_hash(tracked);\n\t}\n\n\treturn tracked;\n}\n\n/**\n * Disallow access to `url.hash` on the server and in `load`\n * @param {URL} url\n */\nfunction disable_hash(url) {\n\tallow_nodejs_console_log(url);\n\n\tObject.defineProperty(url, 'hash', {\n\t\tget() {\n\t\t\tthrow new Error(\n\t\t\t\t'Cannot access event.url.hash. Consider using `page.url.hash` inside a component instead'\n\t\t\t);\n\t\t}\n\t});\n}\n\n/**\n * Disallow access to `url.search` and `url.searchParams` during prerendering\n * @param {URL} url\n */\nexport function disable_search(url) {\n\tallow_nodejs_console_log(url);\n\n\tfor (const property of ['search', 'searchParams']) {\n\t\tObject.defineProperty(url, property, {\n\t\t\tget() {\n\t\t\t\tthrow new Error(`Cannot access url.${property} on a page with prerendering enabled`);\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Allow URL to be console logged, bypassing disabled properties.\n * @param {URL} url\n */\nfunction allow_nodejs_console_log(url) {\n\tif (!BROWSER) {\n\t\t// @ts-ignore\n\t\turl[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => {\n\t\t\treturn inspect(new URL(url), opts);\n\t\t};\n\t}\n}\n"
  },
  {
    "path": "packages/kit/src/utils/url.spec.js",
    "content": "import { assert, describe } from 'vitest';\nimport { resolve, normalize_path, make_trackable, disable_search } from './url.js';\n\ndescribe('resolve', (test) => {\n\ttest('resolves a root-relative path', () => {\n\t\tassert.equal(resolve('/a/b/c', '/x/y/z'), '/x/y/z');\n\t});\n\n\ttest('resolves a relative path without a leading .', () => {\n\t\tassert.equal(resolve('/a/b/c', 'd'), '/a/b/d');\n\t});\n\n\ttest('resolves a relative path with trailing /', () => {\n\t\tassert.equal(resolve('/a/b/c', 'd/'), '/a/b/d/');\n\t});\n\n\ttest('resolves a relative path with leading .', () => {\n\t\tassert.equal(resolve('/a/b/c', './d'), '/a/b/d');\n\t});\n\n\ttest('resolves a relative path with . in the middle', () => {\n\t\tassert.equal(resolve('/a/b/c', 'd/./e/./f'), '/a/b/d/e/f');\n\t});\n\n\ttest('resolves a relative path with leading ..', () => {\n\t\tassert.equal(resolve('/a/b/c', '../d'), '/a/d');\n\t});\n\n\ttest('resolves a relative path with .. in the middle', () => {\n\t\tassert.equal(resolve('/a/b/c', 'd/./e/../f'), '/a/b/d/f');\n\t});\n\n\ttest('resolves a relative path with extraneous leading ..', () => {\n\t\tassert.equal(resolve('/a/b/c', '../../../../../d'), '/d');\n\t});\n\n\ttest('resolves a root-relative path with .', () => {\n\t\tassert.equal(resolve('/a/b/c', '/x/./y/../z'), '/x/z');\n\t});\n\n\ttest('resolves a protocol-relative path', () => {\n\t\tassert.equal(resolve('/a/b/c', '//example.com/foo'), '//example.com/foo');\n\t});\n\n\ttest('resolves an absolute path', () => {\n\t\tassert.equal(resolve('/a/b/c', 'https://example.com/foo'), 'https://example.com/foo');\n\t});\n\n\ttest('handles schemes like tel: and mailto:', () => {\n\t\tassert.equal(resolve('/a/b/c', 'mailto:hello@svelte.dev'), 'mailto:hello@svelte.dev');\n\t});\n\n\ttest('resolves a fragment link', () => {\n\t\tassert.equal(resolve('/a/b/c', '#foo'), '/a/b/c#foo');\n\t});\n\n\ttest('resolves data: urls', () => {\n\t\tassert.equal(resolve('/a/b/c', 'data:text/plain,hello'), 'data:text/plain,hello');\n\t});\n\n\ttest('resolves empty string', () => {\n\t\tassert.equal(resolve('/a/b/c', ''), '/a/b/c');\n\t});\n\n\ttest('resolves .', () => {\n\t\tassert.equal(resolve('/a/b/c', '.'), '/a/b/');\n\t});\n});\n\ndescribe('normalize_path', (test) => {\n\ttest('normalizes paths', () => {\n\t\t/** @type {Record<string, { ignore: string, always: string, never: string }>} */\n\t\tconst paths = {\n\t\t\t'/': {\n\t\t\t\tignore: '/',\n\t\t\t\talways: '/',\n\t\t\t\tnever: '/'\n\t\t\t},\n\t\t\t'/foo': {\n\t\t\t\tignore: '/foo',\n\t\t\t\talways: '/foo/',\n\t\t\t\tnever: '/foo'\n\t\t\t},\n\t\t\t'/foo/': {\n\t\t\t\tignore: '/foo/',\n\t\t\t\talways: '/foo/',\n\t\t\t\tnever: '/foo'\n\t\t\t}\n\t\t};\n\n\t\tfor (const path in paths) {\n\t\t\tconst { ignore, always, never } = paths[path];\n\n\t\t\tassert.equal(normalize_path(path, 'ignore'), ignore);\n\t\t\tassert.equal(normalize_path(path, 'always'), always);\n\t\t\tassert.equal(normalize_path(path, 'never'), never);\n\t\t}\n\t});\n});\n\ndescribe('make_trackable', (test) => {\n\ttest('makes URL properties trackable', () => {\n\t\tlet tracked = false;\n\t\tconst url = make_trackable(\n\t\t\tnew URL('https://svelte.dev/docs/kit'),\n\t\t\t() => {\n\t\t\t\ttracked = true;\n\t\t\t},\n\t\t\t() => {}\n\t\t);\n\n\t\turl.origin;\n\t\tassert.ok(!tracked);\n\n\t\turl.pathname;\n\t\tassert.ok(tracked);\n\t});\n\n\ttest('throws an error when its hash property is accessed', () => {\n\t\tconst url = make_trackable(\n\t\t\tnew URL('https://svelte.dev/docs/kit'),\n\t\t\t() => {},\n\t\t\t() => {}\n\t\t);\n\n\t\tassert.throws(\n\t\t\t() => url.hash,\n\t\t\t/Cannot access event.url.hash. Consider using `page.url.hash` inside a component instead/\n\t\t);\n\t});\n\n\ttest('does not throw an error when its hash property is accessed if it is allowed', () => {\n\t\tlet tracked = false;\n\t\tconst url = make_trackable(\n\t\t\tnew URL('https://svelte.dev/docs/kit'),\n\t\t\t() => {\n\t\t\t\ttracked = true;\n\t\t\t},\n\t\t\t() => {},\n\t\t\ttrue\n\t\t);\n\n\t\turl.hash;\n\t\tassert.ok(tracked);\n\t});\n\n\ttest('track each search param separately if accessed directly', () => {\n\t\tlet tracked = false;\n\t\tconst tracked_search_params = new Set();\n\t\tconst url = make_trackable(\n\t\t\tnew URL('https://svelte.dev/docs/kit'),\n\t\t\t() => {\n\t\t\t\ttracked = true;\n\t\t\t},\n\t\t\t(search_param) => {\n\t\t\t\ttracked_search_params.add(search_param);\n\t\t\t}\n\t\t);\n\n\t\turl.searchParams.get('test');\n\t\tassert.ok(!tracked);\n\t\tassert.ok(tracked_search_params.has('test'));\n\n\t\turl.searchParams.getAll('test-getall');\n\t\tassert.ok(!tracked);\n\t\tassert.ok(tracked_search_params.has('test-getall'));\n\n\t\turl.searchParams.has('test-has');\n\t\tassert.ok(!tracked);\n\t\tassert.ok(tracked_search_params.has('test-has'));\n\n\t\turl.searchParams.entries();\n\t\tassert.ok(tracked);\n\t});\n\n\ttest('tracks search params when using has(name, value) overload', () => {\n\t\tlet tracked = false;\n\t\tconst tracked_search_params = new Set();\n\t\tconst url = make_trackable(\n\t\t\tnew URL('https://svelte.dev/docs/kit?foo=1&foo=2'),\n\t\t\t() => {\n\t\t\t\ttracked = true;\n\t\t\t},\n\t\t\t(search_param) => {\n\t\t\t\ttracked_search_params.add(search_param);\n\t\t\t}\n\t\t);\n\n\t\t// has(name, value) should track the param and return correct result\n\t\tassert.equal(url.searchParams.has('foo', '1'), true);\n\t\tassert.ok(!tracked);\n\t\tassert.ok(tracked_search_params.has('foo'));\n\n\t\t// value argument should be forwarded correctly (not just checking name existence)\n\t\tassert.equal(url.searchParams.has('foo', '3'), false);\n\t\tassert.ok(!tracked);\n\t});\n});\n\ndescribe('disable_search', (test) => {\n\ttest('throws an error when its search property is accessed', () => {\n\t\tconst url = new URL('https://svelte.dev/docs/kit');\n\t\tdisable_search(url);\n\n\t\t/** @type {Array<keyof URL>} */\n\t\tconst props = ['search', 'searchParams'];\n\t\tprops.forEach((prop) => {\n\t\t\tassert.throws(\n\t\t\t\t() => url[prop],\n\t\t\t\t`Cannot access url.${prop} on a page with prerendering enabled`\n\t\t\t);\n\t\t});\n\t});\n});\n"
  },
  {
    "path": "packages/kit/src/version.js",
    "content": "// generated during release, do not modify\n\n/** @type {string} */\nexport const VERSION = '2.55.0';\n"
  },
  {
    "path": "packages/kit/src/version.spec.js",
    "content": "import { fileURLToPath } from 'node:url';\nimport { readFileSync } from 'node:fs';\nimport { assert, describe, it } from 'vitest';\n\n// runs the version generation as a side-effect of importing\nimport '../scripts/generate-version.js';\n\ndescribe('@sveltejs/kit VERSION', async () => {\n\tit('should be the exact version from package.json');\n\tconst { VERSION } = await import('./version.js');\n\tconst pkg = JSON.parse(\n\t\treadFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf-8')\n\t);\n\tassert.equal(\n\t\tVERSION,\n\t\tpkg.version,\n\t\t'VERSION export in src/version.js does not equal version in package.json'\n\t);\n});\n"
  },
  {
    "path": "packages/kit/svelte-kit.js",
    "content": "#!/usr/bin/env node\nimport './src/cli.js';\n"
  },
  {
    "path": "packages/kit/test/.gitignore",
    "content": "!env/.env"
  },
  {
    "path": "packages/kit/test/ambient.d.ts",
    "content": "import { AfterNavigate, BeforeNavigate } from '@sveltejs/kit';\n\ndeclare global {\n\tinterface Window {\n\t\tnavigated: Promise<void>;\n\t\tstarted: boolean;\n\t}\n\n\tconst goto: (\n\t\thref: string,\n\t\topts?: {\n\t\t\treplaceState?: boolean;\n\t\t\tnoScroll?: boolean;\n\t\t}\n\t) => Promise<void>;\n\n\tconst invalidate: (url: string) => Promise<void>;\n\tconst preloadData: (url: string) => Promise<void>;\n\tconst beforeNavigate: (fn: (navigation: BeforeNavigate) => void | boolean) => void;\n\tconst afterNavigate: (fn: (navigation: AfterNavigate) => void) => void;\n\tconst preloadCode: (pathname: string) => Promise<void>;\n}\n\nexport {};\n"
  },
  {
    "path": "packages/kit/test/apps/amp/package.json",
    "content": "{\n\t\"name\": \"test-amp\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"pnpm test:dev && pnpm test:build\",\n\t\t\"test:dev\": \"DEV=true playwright test\",\n\t\t\"test:build\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/amp\": \"workspace:^\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"dropcss\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/amp/playwright.config.js",
    "content": "import { config } from '../../utils.js';\n\nif (config.webServer) {\n\tif (config.webServer instanceof Array) {\n\t\tthrow new Error('Expected a single web server');\n\t}\n\tconfig.webServer.timeout = 45000; // AMP validator needs a long time to get moving\n}\n\n// remove any projects with javaScriptEnabled\nconst projects = config.projects || [];\nfor (let i = projects.length - 1; i >= 0; i--) {\n\tif (projects[i]?.use?.javaScriptEnabled) {\n\t\tprojects.splice(i, 1);\n\t}\n}\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/app.d.ts",
    "content": "/// <reference types=\"@sveltejs/kit\" />\n\ndeclare module 'dropcss' {\n\tinterface Options {\n\t\thtml: string;\n\t\tcss: string;\n\n\t\tshouldDrop?: (selector: string) => boolean;\n\t\tdidRetain?: (selector: string) => void;\n\n\t\tkeepText?: boolean;\n\t}\n\n\texport default function dropcss(options: Options): { css: string };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\" amp>\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<link rel=\"canonical\" href=\"https://example.com\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div style=\"display: contents\">%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/hooks.server.js",
    "content": "import * as amp from '@sveltejs/amp';\nimport dropcss from 'dropcss';\n\n/** @type {import('@sveltejs/kit').Handle} */\nexport async function handle({ event, resolve }) {\n\tlet buffer = '';\n\n\treturn await resolve(event, {\n\t\ttransformPageChunk: ({ html, done }) => {\n\t\t\tbuffer += html;\n\n\t\t\tif (done) {\n\t\t\t\tlet css = '';\n\t\t\t\tconst markup = amp\n\t\t\t\t\t.transform(buffer)\n\t\t\t\t\t.replace('⚡', 'amp')\n\t\t\t\t\t.replace(/<style amp-custom([^>]*?)>([^]+?)<\\/style>/, (match, attributes, contents) => {\n\t\t\t\t\t\tcss = contents;\n\t\t\t\t\t\treturn `<style amp-custom${attributes}></style>`;\n\t\t\t\t\t});\n\n\t\t\t\tcss = dropcss({ css, html: markup }).css;\n\t\t\t\treturn markup.replace('</style>', `${css}</style>`);\n\t\t\t}\n\t\t}\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/+layout.js",
    "content": "export const csr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/+layout.svelte",
    "content": "<slot />\n<footer>footer</footer>\n\n<style>\n\tfooter {\n\t\tcolor: purple;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/http-equiv/cache-control/+page.js",
    "content": "export const prerender = true;\n\n/** @type {import('./$types').PageLoad} */\nexport function load({ setHeaders }) {\n\tsetHeaders({\n\t\t'cache-control': 'public, max-age=300'\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/http-equiv/cache-control/+page.svelte",
    "content": "<h1>the cache-control headers should be removed from this page</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/invalid/+page.svelte",
    "content": "<!-- svelte-ignore a11y-invalid-attribute -->\n<a href=\"javascript:void(0);\">invalid</a>\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/invalid/has-stylesheet/+page.svelte",
    "content": "<svelte:head>\n\t<link rel=\"stylesheet\" href=\"https://example.com/whatever\" />\n</svelte:head>\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/origin/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ url, fetch }) {\n\tconst res = await fetch('/origin.json');\n\tconst data = await res.json();\n\n\treturn {\n\t\torigin: url.origin,\n\t\tdata\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/origin/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p data-source=\"load\">{data.origin}</p>\n<p data-source=\"store\">{page.url.origin}</p>\n<p data-source=\"endpoint\">{data.data.origin}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/origin.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET({ url }) {\n\treturn json({ origin: url.origin });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/styles/+page.svelte",
    "content": "<script>\n\timport Unused from './Unused.svelte';\n\timport './imported.css';\n</script>\n\n{#if Math.random() <= 1}\n\t<p class=\"shouty\">this text is rendered</p>\n{:else}\n\t<Unused />\n{/if}\n\n<style>\n\tp {\n\t\tcolor: #ff3e00;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/styles/Unused.svelte",
    "content": "<p class=\"shouty\">this component will never be rendered</p>\n\n<style>\n\tp {\n\t\tcolor: #40b3ff;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/styles/imported.css",
    "content": ".shouty {\n\ttext-transform: uppercase;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/valid/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/valid.json');\n\tconst { answer } = await res.json();\n\treturn { answer };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/valid/+page.svelte",
    "content": "<script>\n\timport { browser, dev } from '$app/environment';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>Hello from the {browser ? 'client' : 'server'} in {dev ? 'dev' : 'prod'} mode!</h1>\n<h2>The answer is {data.answer}</h2>\n<p>This text is red</p>\n\n<style>\n\tp {\n\t\tcolor: red;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/amp/src/routes/valid.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json({ answer: 42 });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/amp/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tinlineStyleThreshold: Infinity\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/amp/test/test.js",
    "content": "import process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest('renders an AMP page', async ({ page, baseURL }) => {\n\tawait page.goto(`${baseURL}/valid`);\n\n\tawait expect(page.locator('h1')).toHaveText(\n\t\t`Hello from the server in ${process.env.DEV ? 'dev' : 'prod'} mode!`\n\t);\n\n\tawait expect(page.locator('h2')).toHaveText('The answer is 42');\n\n\t// should not include serialized data\n\texpect(await page.$('script[sveltekit\\\\:data-type=\"data\"]')).toBeNull();\n});\n\ntest('styles are applied', async ({ page, baseURL, get_computed_style }) => {\n\tawait page.goto(`${baseURL}/valid`);\n\n\texpect(await get_computed_style('p', 'color')).toEqual('rgb(255, 0, 0)');\n\texpect(await get_computed_style('footer', 'color')).toEqual('rgb(128, 0, 128)');\n});\n\ntest('sets origin', async ({ baseURL, page }) => {\n\tconst { origin } = new URL(/** @type {string} */ (baseURL));\n\n\tawait page.goto(`${baseURL}/origin`);\n\n\tawait expect(page.locator('[data-source=\"load\"]')).toHaveText(origin);\n\tawait expect(page.locator('[data-source=\"store\"]')).toHaveText(origin);\n\tawait expect(page.locator('[data-source=\"endpoint\"]')).toHaveText(origin);\n});\n\ntest('only includes CSS for rendered components', async ({ page, baseURL }) => {\n\tawait page.goto(`${baseURL}/styles`);\n\n\tconst style = await page.innerHTML('style[amp-custom]');\n\n\texpect(style).toContain('#ff3e00'); // rendered styles\n\texpect(style).toContain('uppercase'); // imported styles\n\texpect(style).not.toContain('#40b3ff'); // unrendered styles\n});\n\ntest('http-equiv tags are removed', async ({ page }) => {\n\tawait page.goto('/http-equiv/cache-control');\n\n\texpect(await page.textContent('h1')).toBe(\n\t\t'the cache-control headers should be removed from this page'\n\t);\n\texpect(await page.innerHTML('head')).not.toContain('http-equiv=\"cache-control\"');\n});\n\n// validation tests are skipped because amphtml-validator doesn't\n// play nicely with CI, and is also abominably slow, because\n// everything AMP-related is awful\ntest.skip('prints validation errors', async ({ page, baseURL }) => {\n\tawait page.goto(`${baseURL}/invalid`);\n\n\tconst body = await page.innerHTML('body');\n\n\texpect(body).toContain(\"Invalid URL protocol 'javascript:' for attribute 'href' in tag 'a'\");\n});\n\ntest.skip('throws error on encountering stylesheet links', async ({ page }) => {\n\tawait page.goto('/invalid/has-stylesheet');\n\n\texpect(await page.textContent('body')).toContain(\n\t\t'An AMP document cannot contain <link rel=\"stylesheet\"> — ensure that inlineStyleThreshold is set to Infinity, and remove links from your page template and <svelte:head> elements'\n\t);\n});\n"
  },
  {
    "path": "packages/kit/test/apps/amp/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/amp/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tclearScreen: false,\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/async/.gitignore",
    "content": "!/.env"
  },
  {
    "path": "packages/kit/test/apps/async/README.md",
    "content": "# sv\n\nEverything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).\n\n## Creating a project\n\nIf you're seeing this, you've probably already done this step. Congrats!\n\n```sh\n# create a new project in the current directory\nnpx sv create\n\n# create a new project in my-app\nnpx sv create my-app\n```\n\n## Developing\n\nOnce you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:\n\n```sh\nnpm run dev\n\n# or start the server and open the app in a new browser tab\nnpm run dev -- --open\n```\n\n## Building\n\nTo create a production version of your app:\n\n```sh\nnpm run build\n```\n\nYou can preview the production build with `npm run preview`.\n\n> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.\n"
  },
  {
    "path": "packages/kit/test/apps/async/package.json",
    "content": "{\n\t\"name\": \"test-async\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"pnpm test:dev && pnpm test:build\",\n\t\t\"test:dev\": \"DEV=true playwright test\",\n\t\t\"test:build\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"valibot\": \"catalog:\",\n\t\t\"vite\": \"catalog:\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/async/playwright.config.js",
    "content": "import process from 'node:process';\nimport { config } from '../../utils.js';\nimport { defineConfig } from '@playwright/test';\n\nexport default defineConfig({\n\t...config,\n\twebServer: {\n\t\tcommand: process.env.DEV ? `pnpm dev` : `pnpm build && pnpm preview`,\n\t\tport: process.env.DEV ? 5173 : 4173\n\t}\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body data-sveltekit-preload-data=\"hover\">\n\t\t<div style=\"display: contents\">%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/hooks.client.js",
    "content": "import { isRedirect } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').HandleClientError} */\nexport const handleError = ({ error: e, event, status, message }) => {\n\t// helps us catch sveltekit redirects thrown in component code\n\tif (isRedirect(e)) {\n\t\tthrow new Error(\"Redirects shouldn't trigger the handleError hook\");\n\t}\n\n\tconst error = /** @type {Error} */ (e);\n\n\treturn { message: `${error.message} (${status} ${message}, on ${event.url.pathname})` };\n};\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/hooks.js",
    "content": "import { Foo } from '$lib';\n\n/** @type {import(\"@sveltejs/kit\").Transport} */\nexport const transport = {\n\tFoo: {\n\t\tencode: (value) => value instanceof Foo && [value.message],\n\t\tdecode: ([message]) => new Foo(message)\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/hooks.server.js",
    "content": "import { isRedirect } from '@sveltejs/kit';\nimport { do_something } from './routes/remote/server-action/action.remote';\n\n/** @type {import('@sveltejs/kit').Handle} */\nexport async function handle({ event, resolve }) {\n\tif (event.url.pathname === '/remote/hook-command') {\n\t\ttry {\n\t\t\tconst result = await do_something('from-hook');\n\t\t\treturn new Response(JSON.stringify({ result }), {\n\t\t\t\theaders: { 'content-type': 'application/json' }\n\t\t\t});\n\t\t} catch (e) {\n\t\t\treturn new Response(JSON.stringify({ error: /** @type {Error} */ (e).message }), {\n\t\t\t\tstatus: 500,\n\t\t\t\theaders: { 'content-type': 'application/json' }\n\t\t\t});\n\t\t}\n\t}\n\treturn resolve(event);\n}\n\n/** @type {import('@sveltejs/kit').HandleValidationError} */\nexport const handleValidationError = ({ issues }) => {\n\treturn { message: issues[0].message };\n};\n\n/** @type {import('@sveltejs/kit').HandleServerError} */\nexport const handleError = ({ error: e, event, status, message }) => {\n\t// helps us catch sveltekit redirects thrown in component code\n\tif (isRedirect(e)) {\n\t\tthrow new Error(\"Redirects shouldn't trigger the handleError hook\");\n\t}\n\n\tconst error = /** @type {Error} */ (e);\n\n\treturn { message: `${error.message} (${status} ${message}, on ${event.url.pathname})` };\n};\n\n// @ts-ignore this doesn't exist in old Node TODO remove SvelteKit 3 (same in test-basics)\nPromise.withResolvers ??= () => {\n\tconst d = {};\n\td.promise = new Promise((resolve, reject) => {\n\t\td.resolve = resolve;\n\t\td.reject = reject;\n\t});\n\treturn d;\n};\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/lib/index.js",
    "content": "export class Foo {\n\tconstructor(message) {\n\t\tthis.message = message;\n\t}\n\n\tbar() {\n\t\treturn this.message + '!';\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\tlet { error } = $props();\n</script>\n\n<svelte:head>\n\t<title>Custom error page: {error.message}</title>\n</svelte:head>\n\n<h1>{page.status}</h1>\n\n<p id=\"message\">This is your custom error page saying: \"<b>{error.message}</b>\"</p>\n\n<style>\n\th1,\n\tp {\n\t\tmargin: 0 auto;\n\t}\n\n\th1 {\n\t\tfont-size: 2.8em;\n\t\tfont-weight: 700;\n\t\tmargin: 0 0 0.5em 0;\n\t\tcolor: red;\n\t}\n\n\tp {\n\t\tmargin: 1em auto;\n\t}\n\n\t@media (min-width: 480px) {\n\t\th1 {\n\t\t\tfont-size: 4em;\n\t\t}\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/+layout.svelte",
    "content": "<script lang=\"ts\">\n\timport { setup } from '../../../../setup.js';\n\n\tconst { children } = $props();\n\n\tsetup();\n</script>\n\n{@render children?.()}\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/+page.svelte",
    "content": "Starting point\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/+page.js",
    "content": "import { echo } from './query-command.remote';\n\nexport async function load() {\n\treturn {\n\t\techo_result: await echo('Hello world').run()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/+page.svelte",
    "content": "<script>\n\timport { browser } from '$app/environment';\n\timport { refreshAll } from '$app/navigation';\n\timport {\n\t\tadd,\n\t\tget_count,\n\t\tset_count,\n\t\tset_count_server_refresh,\n\t\tset_count_server_refresh_after_read,\n\t\tset_count_server_set,\n\t\tresolve_deferreds\n\t} from './query-command.remote.js';\n\timport { q } from './accessing-env.remote';\n\n\tconst { data } = $props();\n\n\tlet command_result = $state(null);\n\n\t// we just want it not to be treeshaken away\n\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions\n\tq;\n\n\tconst count = get_count();\n</script>\n\n<p id=\"echo-result\">{data.echo_result}</p>\n<p id=\"count-result\">\n\t{await count} / {count.current} ({count.loading})\n</p>\n<!-- this is just here to check that it is re-requested after the command -->\n{await add({ a: 2, b: 2 })}\n<p id=\"command-result\">{command_result}</p>\n\n<!-- Test pending state for commands -->\n{#if browser}\n\t<p id=\"command-pending\">Command pending: {set_count.pending}</p>\n{/if}\n\n<button onclick={() => set_count_server_refresh(0)} id=\"reset-btn\">reset</button>\n\n<button onclick={() => count.refresh()} id=\"refresh-btn\">Refresh</button>\n\n<button onclick={() => count.set(999)} id=\"set-btn\">Set</button>\n\n<button\n\tonclick={async () => {\n\t\tcommand_result = await set_count({ c: 2 });\n\t}}\n\tid=\"multiply-btn\"\n>\n\tcommand\n</button>\n<button\n\tonclick={async () => {\n\t\tcommand_result = await set_count({ c: 3 }).updates(count);\n\t}}\n\tid=\"multiply-refresh-btn\"\n>\n\tcommand (targeted refresh)\n</button>\n<button\n\tonclick={async () => {\n\t\tcommand_result = await set_count_server_refresh(4);\n\t}}\n\tid=\"multiply-server-refresh-btn\"\n>\n\tcommand (query server refresh)\n</button>\n<button\n\tonclick={async () => {\n\t\tcommand_result = await set_count_server_refresh_after_read(6);\n\t}}\n\tid=\"multiply-server-refresh-after-read-btn\"\n>\n\tcommand (query server refresh after read)\n</button>\n<button\n\tonclick={async () => {\n\t\t// slow, else test will not be able to see the override\n\t\t// (which we deliberately set to a wrong optimistic value to see it applied before the refresh)\n\t\tcommand_result = await set_count({ c: 5, slow: true }).updates(count.withOverride(() => 6));\n\t}}\n\tid=\"multiply-override-refresh-btn\"\n>\n\tcommand (override + refresh)\n</button>\n<button\n\tonclick={async () => {\n\t\t// deferred for pending state testing\n\t\tcommand_result = await set_count({ c: 7, deferred: true });\n\t}}\n\tid=\"command-deferred-btn\"\n>\n\tcommand (deferred)\n</button>\n<button\n\tonclick={async () => {\n\t\tcommand_result = await set_count_server_set(8);\n\t}}\n\tid=\"multiply-server-set-btn\"\n>\n\tcommand (query server set)\n</button>\n\n<button id=\"refresh-all\" onclick={() => refreshAll()}>refreshAll</button>\n<button id=\"refresh-remote-only\" onclick={() => refreshAll({ includeLoadFunctions: false })}>\n\trefreshAll (remote functions only)\n</button>\n<button id=\"resolve-deferreds\" onclick={() => resolve_deferreds()}>Resolve Deferreds</button>\n\n<a href=\"/remote/event\">/remote/event</a>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/accessing-env.remote.js",
    "content": "import { query } from '$app/server';\nimport { env } from '$env/dynamic/private';\nimport { env as public_env } from '$env/dynamic/public';\n\nif (!env.PRIVATE_DYNAMIC || !public_env.PUBLIC_DYNAMIC) {\n\t// This checks that dynamic env vars are available when prerendering remote functions\n\t// https://github.com/sveltejs/kit/pull/14219\n\t// and are not in the same chunk as this one\n\t// https://github.com/sveltejs/kit/issues/14439\n\tthrow new Error('Dynamic environment variables are not set up correctly');\n}\n\n// placeholder query that needs to be imported/used elsewhere so that bundling/chunking would include env setup if not setup correctly\nexport const q = query(() => {});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/batch/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport {\n\t\tget_todo,\n\t\tset_todo_title_server_refresh,\n\t\treset_todos,\n\t\tset_todo_title\n\t} from './batch.remote.js';\n\n\tconst todoIds = ['1', '2', '1', 'error'];\n\t// Need to write this outside at the top level to ensure tests succeed in non-async-mode\n\t// Else updates are not coming through properly because of state-created-inside-effects-not-updating logic in non-async mode\n\tconst todos = todoIds.map((id) => ({ id, promise: get_todo(id) }));\n</script>\n\n<h1>Query Batch Test</h1>\n\n<ul>\n\t{#each todos as { id, promise }, idx (idx)}\n\t\t<li>\n\t\t\t<svelte:boundary>\n\t\t\t\t<span id=\"batch-result-{idx + 1}\">{(await promise).title}</span>\n\n\t\t\t\t{#snippet failed(error)}\n\t\t\t\t\t<span id=\"batch-result-{idx + 1}\"\n\t\t\t\t\t\t>Error loading todo {id}: {(error as App.Error).message}</span\n\t\t\t\t\t>\n\t\t\t\t{/snippet}\n\t\t\t</svelte:boundary>\n\t\t</li>\n\t{/each}\n</ul>\n\n<button onclick={() => todoIds.forEach((id) => get_todo(id).refresh())}>refresh</button>\n<button\n\tonclick={async () => {\n\t\tawait set_todo_title({ id: '1', title: 'Buy cat food' });\n\t}}\n\tid=\"batch-set-btn\"\n>\n\tset first todo\n</button>\n<button\n\tonclick={async () => {\n\t\tawait set_todo_title_server_refresh({ id: '2', title: 'Walk the dog (refreshed)' });\n\t}}\n\tid=\"batch-refresh-btn\"\n>\n\trefresh second todo via command\n</button>\n<button\n\tonclick={async () => {\n\t\tawait reset_todos();\n\t}}\n\tid=\"batch-reset-btn\"\n>\n\treset todos\n</button>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/batch/batch.remote.js",
    "content": "import { command, query } from '$app/server';\nimport { error } from '@sveltejs/kit';\n\n/** @type {Array<[string, { id: string; title: string }]>} **/\nconst INITIAL_TODOS = [\n\t['1', { id: '1', title: 'Buy groceries' }],\n\t['2', { id: '2', title: 'Walk the dog' }]\n];\n\nlet todos = new Map(INITIAL_TODOS);\n\nexport const get_todo = query.batch('unchecked', (ids) => {\n\tif (new Set(ids).size !== ids.length) {\n\t\tthrow new Error(`batch queries must be deduplicated, but got ${JSON.stringify(ids)}`);\n\t}\n\n\treturn (id) => {\n\t\tif (id === 'error') return error(404, { message: 'Not found' });\n\n\t\treturn todos.get(id);\n\t};\n});\n\nexport const set_todo_title = command('unchecked', ({ id, title }) => {\n\tconst todo = { id, title };\n\ttodos.set(id, todo);\n\tget_todo(id).set(todo);\n\treturn todo;\n});\n\nexport const set_todo_title_server_refresh = command('unchecked', ({ id, title }) => {\n\tconst todo = { id, title };\n\ttodos.set(id, todo);\n\tget_todo(id).refresh();\n\treturn todo;\n});\n\nexport const reset_todos = command(() => {\n\ttodos = new Map(INITIAL_TODOS);\n\tfor (const [id, todo] of todos) {\n\t\tget_todo(id).set({ ...todo });\n\t}\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/batch-ssr/+page.svelte",
    "content": "<script>\n\timport { get_todo } from './batch.remote.js';\n\n\tconst todo_1 = get_todo('1');\n\tconst todo_2 = get_todo('2');\n\tconst todo_3 = get_todo('error');\n\n\tfunction get_message(error) {\n\t\tif (error instanceof Error) return error.message;\n\n\t\tif (typeof error === 'object' && error && 'message' in error) {\n\t\t\treturn String(error.message);\n\t\t}\n\n\t\treturn String(error);\n\t}\n</script>\n\n<p id=\"ssr-batch-result-1\">{(await todo_1).title}</p>\n<p id=\"ssr-batch-result-2\">{(await todo_2).title}</p>\n\n<svelte:boundary>\n\t<p id=\"ssr-batch-result-3\">{(await todo_3).title}</p>\n\n\t{#snippet failed(error)}\n\t\t<p id=\"ssr-batch-result-3\">{get_message(error)}</p>\n\t{/snippet}\n</svelte:boundary>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/batch-ssr/batch.remote.js",
    "content": "import { query } from '$app/server';\nimport { error } from '@sveltejs/kit';\n\n/** @type {ReadonlyMap<string, { id: string; title: string }>} */\nconst TODOS = new Map([\n\t['1', { id: '1', title: 'Buy groceries' }],\n\t['2', { id: '2', title: 'Walk the dog' }]\n]);\n\nexport const get_todo = query.batch('unchecked', (ids) => {\n\tif (new Set(ids).size !== ids.length) {\n\t\tthrow new Error(`batch queries must be deduplicated, but got ${JSON.stringify(ids)}`);\n\t}\n\n\treturn (id) => {\n\t\tif (id === 'error') return error(404, { message: 'Not found' });\n\n\t\treturn TODOS.get(id);\n\t};\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/batch-validation/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport { reverse } from './batch.remote.js';\n\n\tlet phrase = $state('ecrof eht esu');\n\tconst words = $derived(phrase.split(' ').reverse());\n</script>\n\n<div id=\"phrase\">\n\t{#each words as word, i}\n\t\t{await reverse(word)}{i === words.length - 1 ? '' : ' '}\n\t{/each}\n</div>\n<button onclick={() => (phrase = 'rehtaf ruoy ma i')}>get dramatic</button>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/batch-validation/batch.remote.js",
    "content": "import { query } from '$app/server';\nimport * as v from 'valibot';\n\nexport const reverse = query.batch(\n\tv.pipe(\n\t\tv.string(),\n\t\tv.transform((val) => val.split('').reverse().join(''))\n\t),\n\t() => {\n\t\treturn (x) => x;\n\t}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/dev/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport { resolve } from '$app/paths';\n</script>\n\n<a href={resolve('/remote/dev/preload')} data-sveltekit-preload-data=\"hover\">preload</a>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/dev/preload/+page.server.js",
    "content": "import { example } from './example.remote';\n\nexport const load = async () => {\n\treturn {\n\t\texample: await example('bar')\n\t};\n};\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/dev/preload/+page.svelte",
    "content": "<script>\n\timport { example } from './example.remote';\n\n\texport let data;\n</script>\n\n<p>{data.example}</p>\n<button onclick={async () => (data.example = await example('baz').run())}>Refresh</button>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/dev/preload/example.remote.js",
    "content": "import { query } from '$app/server';\nimport { schema } from './schema';\n\nexport const example = query(schema, async (param) => {\n\tawait new Promise((resolve) => setTimeout(resolve, 1000));\n\treturn 'foo' + param;\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/dev/preload/schema.js",
    "content": "import * as v from 'valibot';\n\nexport const schema = v.string();\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/event/+page.svelte",
    "content": "<script>\n\timport { get_event } from './data.remote.ts';\n\n\tconst event = await get_event();\n</script>\n\n<p data-id=\"route\">route: {event.route.id}</p>\n<p data-id=\"pathname\">pathname: {event.url.pathname}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/event/data.remote.ts",
    "content": "import { getRequestEvent, query } from '$app/server';\n\nexport const get_event = query(() => {\n\tconst { route, url } = getRequestEvent();\n\n\treturn {\n\t\troute,\n\t\turl\n\t};\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/[test_name]/+page.svelte",
    "content": "<script>\n\timport { get_message, set_message, resolve_deferreds } from './form.remote.ts';\n\n\tconst { params } = $props();\n\n\tconst message = get_message(params.test_name);\n\n\tconst scoped = set_message.for(`scoped:${params.test_name}`);\n\tconst enhanced = set_message.for(`enhanced:${params.test_name}`);\n</script>\n\n<p>message.current: {message.current}</p>\n\n<p>await get_message(): {await message}</p>\n\n<hr />\n\n<form data-unscoped {...set_message}>\n\t{#if set_message.fields.message.issues()}\n\t\t<p>{set_message.fields.message.issues()[0].message}</p>\n\t{/if}\n\n\t<input {...set_message.fields.message.as('text')} />\n\t<input {...set_message.fields.test_name.as('hidden', params.test_name)} />\n\n\t<button {...set_message.fields.action.as('submit', 'normal')}>set message</button>\n\t<button {...set_message.fields.action.as('submit', 'reverse')}>set reverse message</button>\n</form>\n\n<p>set_message.input.message: {set_message.fields.message.value()}</p>\n<p>set_message.pending: {set_message.pending}</p>\n<p>set_message.result: {set_message.result}</p>\n\n<hr />\n\n<form data-scoped {...scoped}>\n\t{#if scoped.fields.message.issues()}\n\t\t<p>{scoped.fields.message.issues()[0].message}</p>\n\t{/if}\n\n\t<input {...scoped.fields.message.as('text')} />\n\t<input {...scoped.fields.test_name.as('hidden', params.test_name)} />\n\t<button>set scoped message</button>\n</form>\n\n<p>scoped.input.message: {scoped.fields.message.value()}</p>\n<p>scoped.pending: {scoped.pending}</p>\n<p>scoped.result: {scoped.result}</p>\n\n<hr />\n\n<form\n\tdata-enhanced\n\t{...enhanced.enhance(async ({ data, submit }) => {\n\t\tawait submit().updates(\n\t\t\tget_message(params.test_name).withOverride(() => data.message + ' (override)')\n\t\t);\n\t})}\n>\n\t{#if enhanced.fields.message.issues()}\n\t\t<p>{enhanced.fields.message.issues()[0].message}</p>\n\t{/if}\n\n\t<input {...enhanced.fields.message.as('text')} />\n\t<input {...enhanced.fields.test_name.as('hidden', params.test_name)} />\n\t<button><span>set enhanced message</span></button>\n</form>\n\n<p>enhanced.input.message: {enhanced.fields.message.value()}</p>\n<p>enhanced.pending: {enhanced.pending}</p>\n<p>enhanced.result: {enhanced.result}</p>\n\n<hr />\n\n<form {...resolve_deferreds}>\n\t<button>resolve deferreds</button>\n\t<input {...resolve_deferreds.fields.test_name.as('hidden', params.test_name)} />\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/[test_name]/form.remote.ts",
    "content": "import { form, getRequestEvent, query } from '$app/server';\nimport { error, redirect } from '@sveltejs/kit';\nimport * as v from 'valibot';\n\nconst instances = new Map<\n\tstring,\n\t{ message: string; deferreds: Array<PromiseWithResolvers<void>> }\n>();\n\nexport const get_message = query(v.string(), (test_name) => {\n\treturn instances.get(test_name)?.message || 'initial';\n});\n\nexport const set_message = form(\n\tv.object({\n\t\ttest_name: v.string(),\n\t\tid: v.optional(v.string()),\n\t\tmessage: v.picklist(\n\t\t\t['hello', 'goodbye', 'unexpected error', 'expected error', 'redirect', 'backwards'],\n\t\t\t'message is invalid'\n\t\t),\n\t\tuppercase: v.optional(v.string()),\n\t\taction: v.optional(v.picklist(['normal', 'reverse']))\n\t}),\n\tasync (data) => {\n\t\tif (data.message === 'unexpected error') {\n\t\t\tthrow new Error('oops');\n\t\t}\n\n\t\tif (data.message === 'expected error') {\n\t\t\terror(500, 'oops');\n\t\t}\n\n\t\tif (data.message === 'redirect') {\n\t\t\tredirect(303, '/remote');\n\t\t}\n\n\t\tconst instance = instances.get(data.test_name) ?? { message: 'initial', deferreds: [] };\n\t\tinstances.set(data.test_name, instance);\n\n\t\tif (data.action === 'reverse') {\n\t\t\tinstance.message = data.message.split('').reverse().join('');\n\t\t} else {\n\t\t\tinstance.message = data.uppercase === 'true' ? data.message.toUpperCase() : data.message;\n\t\t}\n\n\t\tif (getRequestEvent().isRemoteRequest) {\n\t\t\tconst deferred = Promise.withResolvers<void>();\n\t\t\tinstance.deferreds.push(deferred);\n\t\t\tawait deferred.promise;\n\t\t}\n\n\t\treturn instance.message + (data.id ? ` (from: ${data.id})` : '');\n\t}\n);\n\nexport const set_reverse_message = form(\n\tv.object({ test_name: v.string(), message: v.string() }),\n\t(data) => {\n\t\tconst instance = instances.get(data.test_name) ?? { message: 'initial', deferreds: [] };\n\t\tinstances.set(data.test_name, instance);\n\t\tinstance.message = data.message.split('').reverse().join('');\n\t\treturn instance.message;\n\t}\n);\n\nexport const resolve_deferreds = form(v.object({ test_name: v.string() }), async (data) => {\n\tconst instance = instances.get(data.test_name);\n\tif (!instance) return;\n\n\tconst { deferreds } = instance;\n\tfor (const deferred of deferreds) {\n\t\tdeferred.resolve();\n\t}\n\tdeferreds.length = 0;\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/file-upload/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport { upload } from './form.remote';\n</script>\n\n<form {...upload} enctype=\"multipart/form-data\">\n\t<input {...upload.fields.text.as('hidden', 'Hello world')} />\n\t<p>File 1:</p>\n\t<input {...upload.fields.file1.as('file')} />\n\t<p>File 2:</p>\n\t<input {...upload.fields.file2.as('file')} />\n\t<label style:display=\"block\">\n\t\t<input {...upload.fields.read_files.as('checkbox')} />\n\t\tRead files\n\t</label>\n\t<br />\n\t<br />\n\t<button>Submit</button>\n</form>\n\n<pre>{JSON.stringify(upload.result)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/file-upload/form.remote.ts",
    "content": "import { form } from '$app/server';\nimport * as v from 'valibot';\n\nexport const upload = form(\n\tv.object({\n\t\ttext: v.string(),\n\t\tfile1: v.file(),\n\t\tfile2: v.file(),\n\t\tread_files: v.optional(v.boolean())\n\t}),\n\tasync (data) => {\n\t\tif (!data.read_files) {\n\t\t\treturn {\n\t\t\t\ttext: data.text,\n\t\t\t\tfile1: data.file1.size,\n\t\t\t\tfile2: data.file2.size\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\ttext: data.text,\n\t\t\tfile1: await data.file1.text(),\n\t\t\tfile2: await data.file2.text()\n\t\t};\n\t}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/for-duplicate/+page.svelte",
    "content": "<script>\n\timport { get_count, increment } from './form.remote.ts';\n\tconst count = get_count();\n</script>\n\n<p id=\"count\">{count.current}</p>\n\n<!-- this looks weird but forces the spread into being reactive -->\n<form {...increment.for((count.current || 1) && 'a').enhance(async ({ submit }) => await submit())}>\n\t<button type=\"submit\" id=\"submit\">Submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/for-duplicate/form.remote.ts",
    "content": "import { form, query } from '$app/server';\nimport * as v from 'valibot';\n\nlet count = 0;\n\nexport const get_count = query(() => count);\n\nexport const increment = form(v.object({}), async () => {\n\tcount++;\n\tawait get_count().refresh();\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/imperative/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport { set_message } from '../[test_name]/form.remote.js';\n\timport * as v from 'valibot';\n\n\tconst schema = v.object({\n\t\ttest_name: v.string(),\n\t\tmessage: v.picklist(\n\t\t\t['hello', 'goodbye', 'unexpected error', 'expected error', 'redirect'],\n\t\t\t'message is invalid'\n\t\t)\n\t});\n</script>\n\n<form {...set_message.preflight(schema)}>\n\t<label>\n\t\t<span>Message</span>\n\t\t<input {...set_message.fields.message.as('text')} />\n\t\t<input {...set_message.fields.test_name.as('hidden', 'imperative')} />\n\t</label>\n\n\t<p id=\"issue\">\n\t\t{set_message.fields.message.issues()?.[0]?.message ?? 'ok'}\n\t</p>\n\t<p id=\"value\">{set_message.fields.message.value()}</p>\n\n\t<button\n\t\tid=\"set-and-validate\"\n\t\ttype=\"button\"\n\t\ton:click={async () => {\n\t\t\tset_message.fields.message.set('hello');\n\t\t\tawait set_message.validate({ includeUntouched: true });\n\t\t}}\n\t>\n\t\tSet & validate\n\t</button>\n\t<button>Submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/preflight/+page.svelte",
    "content": "<script>\n\timport { tick } from 'svelte';\n\timport { get_number, set_number } from './form.remote.ts';\n\timport * as v from 'valibot';\n\n\tconst number = get_number();\n\n\tconst enhanced = set_number.for('enhanced');\n\n\tconst schema = v.object({\n\t\tnumber: v.pipe(v.number(), v.maxValue(20, 'too big'))\n\t});\n</script>\n\n<p>number.current: {number.current}</p>\n\n<p>await get_number(): {await number}</p>\n\n<hr />\n\n<form data-default {...set_number.preflight(schema)}>\n\t{#each set_number.fields.number.issues() as issue}\n\t\t<p>{issue.message}</p>\n\t{/each}\n\n\t<input {...set_number.fields.number.as('number')} />\n\t<button>set number</button>\n</form>\n\n<p>set_number.input.number: {set_number.fields.number.value()}</p>\n<p>set_number.pending: {set_number.pending}</p>\n<p>set_number.result: {set_number.result}</p>\n\n<hr />\n\n<form\n\tdata-enhanced\n\t{...enhanced.preflight(schema).enhance(async ({ submit }) => {\n\t\tawait tick();\n\t\tif (enhanced.fields.number.issues()) {\n\t\t\treturn;\n\t\t}\n\t\tawait submit();\n\t})}\n>\n\t{#each enhanced.fields.number.issues() as issue}\n\t\t<p>{issue.message}</p>\n\t{/each}\n\n\t<input {...enhanced.fields.number.as('number')} />\n\t<button><span>set enhanced number</span></button>\n</form>\n\n<p>enhanced.input.number: {enhanced.fields.number.value()}</p>\n<p>enhanced.pending: {enhanced.pending}</p>\n<p>enhanced.result: {enhanced.result}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/preflight/form.remote.ts",
    "content": "import { form, query } from '$app/server';\nimport * as v from 'valibot';\n\nlet number = 0;\n\nexport const get_number = query(() => {\n\treturn number;\n});\n\nexport const set_number = form(\n\tv.object({\n\t\tnumber: v.pipe(v.number(), v.minValue(10, 'too small'))\n\t}),\n\tasync (data) => {\n\t\tnumber = data.number;\n\t\tget_number().refresh();\n\t}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/preflight-only/+page.svelte",
    "content": "<script>\n\timport { get, set } from './form.remote.ts';\n\timport * as v from 'valibot';\n\n\tconst data = get();\n\n\tconst schema = v.object({\n\t\ta: v.pipe(v.string(), v.maxLength(7, 'a is too long')),\n\t\tb: v.string(),\n\t\tc: v.string()\n\t});\n</script>\n\n<p>a: {(await data).a}</p>\n<p>b: {(await data).b}</p>\n<p>c: {(await data).c}</p>\n\n<hr />\n\n<form\n\t{...set.preflight(schema)}\n\toninput={() => set.validate({ preflightOnly: true })}\n\tonchange={() => set.validate()}\n>\n\t<input {...set.fields.a.as('text')} />\n\t<input {...set.fields.b.as('text')} />\n\t<input {...set.fields.c.as('text')} />\n\n\t<button>submit</button>\n</form>\n\n<div class=\"issues\">\n\t{#each set.fields.allIssues() as issue}\n\t\t<p>{issue.message}</p>\n\t{/each}\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/preflight-only/form.remote.ts",
    "content": "import { form, query } from '$app/server';\nimport * as v from 'valibot';\n\nlet data = { a: '', b: '', c: '' };\n\nexport const get = query(() => {\n\treturn data;\n});\n\nexport const set = form(\n\tv.object({\n\t\ta: v.pipe(v.string(), v.minLength(3, 'a is too short')),\n\t\tb: v.pipe(v.string(), v.minLength(3, 'b is too short')),\n\t\tc: v.pipe(v.string(), v.minLength(3, 'c is too short'))\n\t}),\n\tasync (d) => {\n\t\tdata = d;\n\t}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/preflight-pending/+page.svelte",
    "content": "<script>\n\timport { create } from './form.remote.ts';\n\timport * as v from 'valibot';\n\n\tconst passing_schema = v.pipeAsync(\n\t\tv.object({\n\t\t\tname: v.string()\n\t\t}),\n\t\tv.checkAsync(async () => {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 500));\n\t\t\treturn true;\n\t\t}, 'async check failed')\n\t);\n\n\tconst failing_schema = v.pipeAsync(\n\t\tv.object({\n\t\t\tname: v.string()\n\t\t}),\n\t\tv.checkAsync(async () => {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 500));\n\t\t\treturn false;\n\t\t}, 'async check failed')\n\t);\n\n\tconst passing = create.for('passing');\n\tconst failing = create.for('failing');\n</script>\n\n<form data-passing {...passing.preflight(passing_schema)}>\n\t<input {...passing.fields.name.as('text')} value=\"test\" />\n\t<button>submit passing</button>\n</form>\n<p data-passing-pending>passing pending: {passing.pending}</p>\n<p data-passing-result>passing result: {passing.result}</p>\n\n<hr />\n\n<form data-failing {...failing.preflight(failing_schema)}>\n\t<input {...failing.fields.name.as('text')} value=\"test\" />\n\t<button>submit failing</button>\n</form>\n<p data-failing-pending>failing pending: {failing.pending}</p>\n{#each failing.fields.allIssues() as issue}\n\t<p data-failing-issue>{issue.message}</p>\n{/each}\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/preflight-pending/form.remote.ts",
    "content": "import { form } from '$app/server';\nimport * as v from 'valibot';\n\nexport const create = form(v.object({ name: v.string() }), async (data: { name: string }) => {\n\treturn 'created: ' + data.name;\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/redirect-target/+page.svelte",
    "content": "<script>\n\timport { redirectForm } from './form.remote.ts';\n</script>\n\n<form {...redirectForm.for('blank')} target=\"_blank\" data-testid=\"form-blank\">\n\t<button type=\"submit\">Submit blank</button>\n</form>\n\n<form {...redirectForm.for('same')} data-testid=\"form-same\">\n\t<button type=\"submit\">Submit same</button>\n</form>\n\n<form {...redirectForm.for('input')} data-testid=\"form-input-blank\">\n\t<input type=\"submit\" formtarget=\"_blank\" value=\"Submit input blank\" />\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/redirect-target/destination/+page.svelte",
    "content": "<h1>destination</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/redirect-target/form.remote.ts",
    "content": "import { form } from '$app/server';\nimport { redirect } from '@sveltejs/kit';\nimport { object, optional, string } from 'valibot';\n\nexport const redirectForm = form(\n\tobject({\n\t\tid: optional(string())\n\t}),\n\t() => {\n\t\tredirect(303, '/remote/form/redirect-target/destination');\n\t}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/select-untouched/+page.svelte",
    "content": "<script>\n\timport { myform } from './form.remote.ts';\n</script>\n\n<form {...myform}>\n\t<input {...myform.fields.message.as('text')} />\n\n\t<select {...myform.fields.number.as('select')}>\n\t\t<option>one</option>\n\t\t<option>two</option>\n\t\t<option>three</option>\n\t</select>\n\n\t<button>submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/select-untouched/form.remote.ts",
    "content": "import { form } from '$app/server';\nimport * as v from 'valibot';\n\nexport const myform = form(\n\tv.object({\n\t\tmessage: v.string(),\n\t\tnumber: v.picklist(['one', 'two', 'three'])\n\t}),\n\t(_data) => {}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/set-ssr/+page.svelte",
    "content": "<script>\n\timport { editData } from './form.remote';\n\n\tconst form = editData;\n\tform.fields.set({ description: 'ssr' });\n\tform.fields.description.set('nested');\n</script>\n\n<div id=\"description\">Description: {form.fields.description.value()}</div>\n\n<form {...form}>\n\t<input {...form.fields.name.as('text')} />\n\t<button type=\"submit\">Submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/set-ssr/form.remote.ts",
    "content": "import { form } from '$app/server';\nimport * as v from 'valibot';\n\nexport const editData = form(\n\tv.object({\n\t\tname: v.optional(v.string()),\n\t\tdescription: v.optional(v.string())\n\t}),\n\tasync (data) => {\n\t\treturn data;\n\t}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/submitter/+page.svelte",
    "content": "<script>\n\timport { my_form } from './form.remote.ts';\n</script>\n\n<form {...my_form}>\n\t<button {...my_form.fields.submitter.as('submit', 'hello')}>submit</button>\n</form>\n\n<p id=\"result\">{my_form.result}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/submitter/form.remote.ts",
    "content": "import { form } from '$app/server';\nimport * as v from 'valibot';\n\nexport const my_form = form(\n\tv.object({\n\t\tsubmitter: v.string()\n\t}),\n\tasync (data) => {\n\t\tconsole.log('!!!', data);\n\t\treturn data.submitter;\n\t}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/underscore/+page.svelte",
    "content": "<script>\n\timport { register } from './form.remote.ts';\n</script>\n\n<form {...register}>\n\t<input {...register.fields.username.as('text')} />\n\t<input {...register.fields._password.as('password')} />\n\n\t<button>submit</button>\n</form>\n\n<pre>{JSON.stringify(register.fields.issues(), null, '  ')}</pre>\n\n<style>\n\t[aria-invalid='true'] {\n\t\toutline: 2px solid red;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/underscore/form.remote.ts",
    "content": "import { form } from '$app/server';\nimport * as v from 'valibot';\n\nexport const register = form(\n\tv.object({\n\t\tusername: v.pipe(v.string(), v.minLength(8)),\n\t\t_password: v.pipe(v.string(), v.minLength(8))\n\t}),\n\tasync (data) => {}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/validate/+page.svelte",
    "content": "<script>\n\timport { issue_path_form, my_form, my_form_2 } from './form.remote.ts';\n\timport * as v from 'valibot';\n\n\tconst schema = v.object({\n\t\tfoo: v.picklist(['a', 'b', 'c']),\n\t\tbar: v.picklist(['d', 'e']),\n\t\tbutton: v.literal('submitter')\n\t});\n\n\tlet error = $state(false);\n</script>\n\n<form id=\"my-form\" {...my_form.preflight(schema)} oninput={() => my_form.validate()}>\n\t{#each my_form.fields.foo.issues() as issue}\n\t\t<p>{issue.message}</p>\n\t{/each}\n\n\t<input {...my_form.fields.foo.as('text')} />\n\n\t{#each my_form.fields.bar.issues() as issue}\n\t\t<p>{issue.message}</p>\n\t{/each}\n\n\t<input {...my_form.fields.bar.as('text')} />\n\n\t<button {...my_form.fields.button.as('submit', 'incorrect_value')}> submit </button>\n\n\t{#each my_form.fields.button.issues() as issue}\n\t\t<p>{issue.message}</p>\n\t{/each}\n\n\t<button {...my_form.fields.button.as('submit', 'submitter')}>\n\t\tsubmit (imperative validation)\n\t</button>\n</form>\n<button id=\"trigger-validate\" onclick={() => my_form.validate({ includeUntouched: true })}>\n\ttrigger validation\n</button>\n\n<form id=\"issue-path-form\" {...issue_path_form}>\n\t<input {...issue_path_form.fields.nested.value.as('text')} />\n\t<button\n\t\ttype=\"button\"\n\t\tid=\"validate\"\n\t\tonclick={() => issue_path_form.validate({ includeUntouched: true })}\n\t>\n\t\tValidate\n\t</button>\n\t<pre id=\"allIssues\">{JSON.stringify(issue_path_form.fields.allIssues())}</pre>\n</form>\n\n<form\n\tid=\"my-form-2\"\n\t{...my_form_2.enhance(async ({ submit }) => {\n\t\terror = false;\n\t\ttry {\n\t\t\tawait submit();\n\t\t} catch {\n\t\t\terror = true;\n\t\t}\n\t})}\n>\n\t{#each my_form_2.fields.baz.issues() as issue}\n\t\t<p>{issue.message}</p>\n\t{/each}\n\n\t<input {...my_form_2.fields.baz.as('text')} />\n\n\t<p data-error>{error ? 'An error occurred' : 'No error'}</p>\n\n\t<button>submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/validate/form.remote.ts",
    "content": "import { form } from '$app/server';\nimport { error, invalid } from '@sveltejs/kit';\nimport * as v from 'valibot';\n\nexport const my_form = form(\n\tv.object({\n\t\tfoo: v.picklist(['a', 'b', 'c']),\n\t\tbar: v.picklist(['d', 'e', 'f']),\n\t\tbutton: v.literal('submitter')\n\t}),\n\tasync (data, issue) => {\n\t\t// Test imperative validation\n\t\tif (data.foo === 'c') {\n\t\t\tinvalid(issue.foo('Imperative: foo cannot be c'));\n\t\t}\n\n\t\tconsole.log(data);\n\t}\n);\n\nexport const my_form_2 = form(\n\tv.object({\n\t\tbaz: v.picklist(['a', 'b'])\n\t}),\n\tasync ({ baz }) => {\n\t\tif (baz === 'a') error(400, 'Nope');\n\t}\n);\n\nexport const issue_path_form = form(\n\tv.object({\n\t\tnested: v.object({\n\t\t\tvalue: v.pipe(v.string(), v.minLength(3))\n\t\t})\n\t}),\n\tasync (data) => {\n\t\treturn data;\n\t}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/value/+page.svelte",
    "content": "<script>\n\timport { values } from './value.remote.ts';\n</script>\n\n<h1>Remote Form Value Test</h1>\n\n<form {...values}>\n\t<label>\n\t\tLeaf:\n\t\t<input {...values.fields.leaf.as('text')} />\n\t</label>\n\n\t<label>\n\t\tObject Leaf:\n\t\t<input {...values.fields.object.leaf.as('text')} />\n\t</label>\n\n\t<label>\n\t\tObject Array 0:\n\t\t<input {...values.fields.object.array[0].as('text')} />\n\t</label>\n\t<label>\n\t\tObject Array 1:\n\t\t<input {...values.fields.object.array[1].as('text')} />\n\t</label>\n\n\t<label>\n\t\tArray 0 Leaf:\n\t\t<input {...values.fields.array[0].leaf.as('text')} />\n\t</label>\n\t<label>\n\t\tArray 1 Leaf:\n\t\t<input {...values.fields.array[1].leaf.as('text')} />\n\t</label>\n\n\t<button>Submit</button>\n</form>\n\n<h2>Full Form Value</h2>\n<pre id=\"full-value\">{JSON.stringify(values.fields.value(), null, '  ')}</pre>\n\n<h2>Nested Object Value</h2>\n<pre id=\"object-value\">{JSON.stringify(values.fields.object.value(), null, '  ')}</pre>\n\n<h2>Array Value</h2>\n<pre id=\"array-value\">{JSON.stringify(values.fields.array.value(), null, '  ')}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/form/value/value.remote.ts",
    "content": "import { form } from '$app/server';\nimport * as v from 'valibot';\n\nexport const values = form(\n\tv.object({\n\t\tleaf: v.string(),\n\t\tobject: v.object({\n\t\t\tleaf: v.string(),\n\t\t\tarray: v.array(v.string())\n\t\t}),\n\t\tarray: v.array(\n\t\t\tv.object({\n\t\t\t\tleaf: v.string()\n\t\t\t})\n\t\t)\n\t}),\n\tasync (data) => {\n\t\treturn { success: true, data };\n\t}\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/prerender/+page.svelte",
    "content": "<script>\n\timport { prerendered, prerendered_entries, with_read } from './prerender.remote.js';\n\n\tlet prerendered_result = $state(null);\n\tlet live_result = $state(null);\n\tlet read_result = $state(null);\n</script>\n\n<a href=\"/remote/prerender/whole-page\">whole-page</a>\n<a href=\"/remote/prerender/functions-only\">functions-only</a>\n\n<button id=\"fetch-prerendered\" onclick={async () => (prerendered_result = await prerendered())}>\n\t{prerendered_result}\n</button>\n<button\n\tid=\"fetch-not-prerendered\"\n\tonclick={async () => (live_result = await prerendered_entries('d'))}\n>\n\t{live_result}\n</button>\n<button id=\"fetch-with-read\" onclick={async () => (read_result = await with_read())}>\n\t{read_result}\n</button>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/prerender/functions-only/+page.js",
    "content": "import { prerendered, prerendered_entries } from '../prerender.remote';\n\nexport async function load() {\n\tconst [r1, r2, r3, r4] = await Promise.all([\n\t\tprerendered_entries('a'),\n\t\tprerendered_entries('c'),\n\t\tprerendered_entries('中文'),\n\t\tprerendered()\n\t]);\n\n\treturn {\n\t\tr1,\n\t\tr2,\n\t\tr3,\n\t\tr4\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/prerender/functions-only/+page.svelte",
    "content": "<script>\n\tlet { data } = $props();\n</script>\n\n<p id=\"prerendered-data\">\n\t{data.r1}\n\t{data.r2}\n\t{data.r3}\n\t{data.r4}\n</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/prerender/prerender.remote.js",
    "content": "import { building, dev } from '$app/environment';\nimport { prerender, read } from '$app/server';\nimport text from './test.txt?url';\n\n// test that using `read()` at the top-level of a remote function file doesn't\n// throw an error when we evaluate the remote function files during build\nconst response = read(text);\nconst content = await response.text();\n\nexport const prerendered = prerender(() => {\n\tif (!building && !dev) {\n\t\tthrow new Error('this prerender should not be called at runtime in production');\n\t}\n\n\treturn 'yes';\n});\n\nexport const prerendered_entries = prerender(\n\t'unchecked',\n\t(x) => {\n\t\t// a,b directly through entries below, c indirectly through prerendering a page\n\t\tif (!building && !dev && ['a', 'b', 'c', '中文'].includes(x)) {\n\t\t\tthrow new Error(\n\t\t\t\t'prerender should not be called at runtime in production with parameter ' + x\n\t\t\t);\n\t\t}\n\n\t\treturn x;\n\t},\n\t{ inputs: () => ['a', 'b', /* to test correct encoding */ '中文'], dynamic: true }\n);\n\nexport const with_read = prerender(() => {\n\treturn content;\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/prerender/test.txt",
    "content": "test content from read()\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/prerender/whole-page/+page.js",
    "content": "import { prerendered, prerendered_entries } from '../prerender.remote';\n\nexport const prerender = true;\n\nexport async function load() {\n\tconst [r1, r2, r3, r4] = await Promise.all([\n\t\tprerendered_entries('a'),\n\t\tprerendered_entries('c'),\n\t\tprerendered_entries('中文'),\n\t\tprerendered()\n\t]);\n\n\treturn {\n\t\tr1,\n\t\tr2,\n\t\tr3,\n\t\tr4\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/prerender/whole-page/+page.svelte",
    "content": "<script>\n\tlet { data } = $props();\n</script>\n\n<p id=\"prerendered-data\">\n\t{data.r1}\n\t{data.r2}\n\t{data.r3}\n\t{data.r4}\n</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-boundary/+page.svelte",
    "content": "<script>\n\timport { get_delayed_data, get_fast_data } from './data.remote.js';\n\n\t// shouldn't block SSR since requested immediately but awaited inside pending boundary\n\tconst delayed = get_delayed_data();\n</script>\n\n<p id=\"fast-result\">{await get_fast_data()}</p>\n<svelte:boundary>\n\t{#snippet pending()}\n\t\t<p id=\"delayed-pending\">loading delayed</p>\n\t{/snippet}\n\t<p id=\"delayed-result\">{await delayed}</p>\n</svelte:boundary>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-boundary/data.remote.js",
    "content": "import { query } from '$app/server';\n\nexport const get_delayed_data = query(async () => {\n\tawait new Promise((resolve) => setTimeout(resolve, 2000));\n\treturn 'delayed data';\n});\n\nexport const get_fast_data = query(() => {\n\treturn 'fast data';\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-command.remote.js",
    "content": "import { command, query } from '$app/server';\n\nexport const echo = query('unchecked', (value) => value);\nexport const add = query('unchecked', ({ a, b }) => a + b);\n\nlet count = 0;\nconst deferreds = [];\n\nlet get_count_called = false;\nexport const get_count = query(() => {\n\tget_count_called = true;\n\treturn count;\n});\n\nexport const set_count = command('unchecked', async ({ c, slow = false, deferred = false }) => {\n\tif (deferred) {\n\t\tconst deferred = Promise.withResolvers();\n\t\tdeferreds.push(deferred);\n\t\tawait deferred.promise;\n\t} else if (slow) {\n\t\tawait new Promise((resolve) => setTimeout(resolve, 500));\n\t}\n\treturn (count = c);\n});\n\nexport const resolve_deferreds = command(() => {\n\tfor (const deferred of deferreds) {\n\t\tdeferred.resolve();\n\t}\n\tdeferreds.length = 0;\n});\n\nexport const set_count_server_refresh = command('unchecked', (c) => {\n\tcount = c;\n\tget_count().refresh();\n\treturn c;\n});\n\nexport const set_count_server_refresh_after_read = command('unchecked', async (c) => {\n\tawait get_count();\n\tcount = c;\n\tawait get_count().refresh();\n\treturn c;\n});\n\nexport const set_count_server_set = command('unchecked', async (c) => {\n\tget_count_called = false;\n\tcount = c;\n\tget_count().set(c);\n\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\tif (get_count_called) {\n\t\tthrow new Error('get_count should not have been called');\n\t}\n\treturn c;\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-non-exported/+page.svelte",
    "content": "<script>\n\timport { total } from './data.remote.ts';\n</script>\n\n<h1>{await total()}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-non-exported/data.remote.ts",
    "content": "import { query } from '$app/server';\n\nconst one = query(() => 1);\nconst two = query(() => 2);\n\nexport const total = query(async () => {\n\treturn (await one()) + (await two());\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-redirect/+page.svelte",
    "content": "<!-- TODO can remove this when preloading doesn't eagerly redirect -->\n<a data-sveltekit-preload-data=\"off\" href=\"/remote/query-redirect/from-page\">from page</a>\n<a data-sveltekit-preload-data=\"off\" href=\"/remote/query-redirect/from-common-layout\">from layout</a\n>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-redirect/from-common-layout/+layout.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\timport { layoutRedirect } from '../redirect.remote';\n\n\tlet { children } = $props();\n</script>\n\n<p id=\"layout-query\">\n\ton page {await layoutRedirect(page.url.pathname)} (== {page.url.pathname})\n</p>\n\n{@render children()}\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-redirect/from-common-layout/+page.svelte",
    "content": "<p>should never see this</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-redirect/from-common-layout/redirected/+page.svelte",
    "content": "<p id=\"redirected\">redirected</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-redirect/from-page/+page.svelte",
    "content": "<script>\n\timport { pageRedirect } from '../redirect.remote';\n</script>\n\n<svelte:boundary>\n\t{await pageRedirect()}\n\t<p>should never see this</p>\n</svelte:boundary>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-redirect/redirect.remote.js",
    "content": "import { query } from '$app/server';\nimport { redirect } from '@sveltejs/kit';\n\nexport const layoutRedirect = query('unchecked', (path) => {\n\tif (path !== '/remote/query-redirect/from-common-layout/redirected') {\n\t\tredirect(307, '/remote/query-redirect/from-common-layout/redirected');\n\t}\n\n\treturn path;\n});\n\nexport const pageRedirect = query(() => {\n\tredirect(307, '/remote/query-redirect/redirected');\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-redirect/redirected/+page.svelte",
    "content": "<p id=\"redirected\">redirected</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-runtime-errors/inactive/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport { tick } from 'svelte';\n\timport TrackedQuery from './TrackedQuery.svelte';\n\timport type { RemoteQuery } from '@sveltejs/kit';\n\n\tlet show_child = $state(true);\n\tlet status = $state('child mounted');\n\tlet result = $state('');\n\tlet stored: RemoteQuery<number>;\n\n\tfunction get_message(error) {\n\t\treturn error instanceof Error ? error.message : String(error);\n\t}\n</script>\n\n<p id=\"status\">{status}</p>\n<p id=\"result\">{result}</p>\n\n{#if show_child}\n\t<TrackedQuery expose={(query) => (stored = query)} />\n{/if}\n\n<button\n\tid=\"unmount\"\n\tonclick={async () => {\n\t\tshow_child = false;\n\t\tawait tick();\n\t\tstatus = 'child unmounted';\n\t}}\n>\n\tunmount child\n</button>\n\n<button\n\tid=\"read-current\"\n\tonclick={async () => {\n\t\ttry {\n\t\t\tawait stored;\n\t\t\tresult = 'success :(';\n\t\t} catch (error) {\n\t\t\tresult = get_message(error);\n\t\t}\n\t}}\n>\n\tread current\n</button>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-runtime-errors/inactive/TrackedQuery.svelte",
    "content": "<script lang=\"ts\">\n\timport type { RemoteQuery } from '@sveltejs/kit';\n\timport { get_count } from '../../query-command.remote.js';\n\n\tconst { expose }: { expose: (query: RemoteQuery<number>) => void } = $props();\n\n\tconst tracked = get_count();\n\t// svelte-ignore state_referenced_locally\n\texpose(tracked);\n</script>\n\n<p id=\"tracked-child\">tracked query ready</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-runtime-errors/not-tracked/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport type { RemoteQuery } from '@sveltejs/kit';\n\timport { get_count } from '../../query-command.remote.js';\n\n\tlet status = $state('idle');\n\tlet result = $state('');\n\tlet stored: RemoteQuery<number>;\n\n\tfunction get_message(error) {\n\t\treturn error instanceof Error ? error.message : String(error);\n\t}\n</script>\n\n<p id=\"status\">{status}</p>\n<p id=\"result\">{result}</p>\n\n<button\n\tid=\"create\"\n\tonclick={() => {\n\t\tstored = get_count();\n\t\tstatus = 'query created';\n\t}}\n>\n\tcreate query\n</button>\n\n<button\n\tid=\"run\"\n\tonclick={async () => {\n\t\tresult = String(await stored.run());\n\t\tstatus = 'query run';\n\t}}\n>\n\trun query\n</button>\n\n<button\n\tid=\"read-current\"\n\tonclick={async () => {\n\t\ttry {\n\t\t\tawait stored;\n\t\t\tresult = 'success! :(';\n\t\t} catch (error) {\n\t\t\tresult = get_message(error);\n\t\t}\n\t}}\n>\n\tread current\n</button>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/query-runtime-errors/run-in-render/+page.svelte",
    "content": "<script>\n\timport { get_count } from '../../query-command.remote.js';\n\n\tfunction get_message(error) {\n\t\tif (error instanceof Error) return error.message;\n\n\t\tif (typeof error === 'object' && error && 'message' in error) {\n\t\t\treturn String(error.message);\n\t\t}\n\n\t\treturn String(error);\n\t}\n</script>\n\n<svelte:boundary>\n\t<p>{get_count().run()}</p>\n\n\t{#snippet failed(error)}\n\t\t<p id=\"error\">{get_message(error)}</p>\n\t{/snippet}\n</svelte:boundary>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/server-action/+page.server.ts",
    "content": "import { do_something } from './action.remote';\n\nexport const actions = {\n\tdefault: async ({ request }) => {\n\t\tconst fields = await request.formData();\n\t\tconst result = await do_something(fields.get('input') as string);\n\t\treturn { result };\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/server-action/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n\n\tlet { form } = $props();\n</script>\n\n<p id=\"result\">{form?.result ?? ''}</p>\n\n<form method=\"POST\" use:enhance>\n\t<input type=\"hidden\" name=\"input\" value=\"hello\" />\n\t<button>submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/server-action/action.remote.ts",
    "content": "import * as v from 'valibot';\nimport { command } from '$app/server';\n\nexport const do_something = command(v.string(), (input) => {\n\treturn `action: ${input}`;\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/server-endpoint/+page.svelte",
    "content": "<script>\n\tlet result = $state('');\n</script>\n\n<p>{result}</p>\n\n<button\n\tonclick={() =>\n\t\tfetch('/remote/server-endpoint/api')\n\t\t\t.then((r) => r.json())\n\t\t\t.then((r) => (result = r.result))}\n>\n\tget\n</button>\n\n<button\n\tonclick={() =>\n\t\tfetch('/remote/server-endpoint/api', { method: 'POST' })\n\t\t\t.then((r) => r.json())\n\t\t\t.then((r) => (result = r.result))}\n>\n\tpost\n</button>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/server-endpoint/api/+server.ts",
    "content": "import { json } from '@sveltejs/kit';\nimport { add, get } from '../internal.remote';\n\nexport async function GET() {\n\tconst result = await get();\n\treturn json({ result });\n}\n\nexport async function POST() {\n\tconst result = await add(1);\n\treturn json({ result });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/server-endpoint/internal.remote.ts",
    "content": "import { command, query } from '$app/server';\n\nexport const get = query(() => {\n\treturn 'get';\n});\n\nexport const add = command('unchecked', () => {\n\treturn 'post';\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/server-load-command/+page.server.ts",
    "content": "import { do_something } from '../server-action/action.remote';\n\nexport async function load() {\n\tconst result = await do_something('test');\n\treturn { result };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/server-load-command/+page.svelte",
    "content": "<script>\n\tlet { data } = $props();\n</script>\n\n<p>{data.result}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/transport/+page.svelte",
    "content": "<script>\n\timport { greeting } from './data.remote.ts';\n</script>\n\n<h1>{(await greeting()).bar()}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/transport/data.remote.ts",
    "content": "import { query } from '$app/server';\nimport { Foo } from '$lib';\n\nexport const greeting = query(() => new Foo('hello from remote function'));\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/validation/+page.svelte",
    "content": "<script>\n\timport { isHttpError } from '@sveltejs/kit';\n\timport {\n\t\tvalidated_query_no_args,\n\t\tvalidated_query_with_arg,\n\t\tvalidated_prerendered_query_no_args,\n\t\tvalidated_prerendered_query_with_arg,\n\t\tvalidated_command_no_args,\n\t\tvalidated_command_with_arg,\n\t\tvalidated_batch_query_no_validation,\n\t\tvalidated_batch_query_with_validation\n\t} from './validation.remote.js';\n\n\tfunction validate_result(result) {\n\t\tif (result !== 'success') {\n\t\t\tthrow new Error('Remote function called with invalid arguments');\n\t\t}\n\t}\n\n\tlet status = $state('pending');\n</script>\n\n<p>{status}</p>\n\n<button\n\tonclick={async () => {\n\t\tstatus = 'pending';\n\t\ttry {\n\t\t\tvalidate_result(await validated_query_no_args().run());\n\t\t\tvalidate_result(await validated_prerendered_query_no_args());\n\t\t\tvalidate_result(await validated_command_no_args());\n\n\t\t\tvalidate_result(await validated_query_with_arg('valid').run());\n\t\t\tvalidate_result(await validated_prerendered_query_with_arg('valid'));\n\t\t\tvalidate_result(await validated_command_with_arg('valid'));\n\n\t\t\tvalidate_result(await validated_batch_query_no_validation('valid').run());\n\t\t\tvalidate_result(await validated_batch_query_with_validation('valid').run());\n\n\t\t\tstatus = 'success';\n\t\t} catch (e) {\n\t\t\tstatus = 'error';\n\t\t}\n\t}}\n>\n\tvalid\n</button>\n\n<button\n\tonclick={async () => {\n\t\tstatus = 'pending';\n\t\ttry {\n\t\t\t// @ts-expect-error\n\t\t\tawait validated_query_no_args('invalid').run();\n\t\t\tstatus = 'error';\n\t\t} catch {\n\t\t\ttry {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tawait validated_prerendered_query_no_args('invalid');\n\t\t\t\tstatus = 'error';\n\t\t\t} catch {\n\t\t\t\ttry {\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tawait validated_command_no_args('invalid');\n\t\t\t\t\tstatus = 'error';\n\t\t\t\t} catch {\n\t\t\t\t\tstatus = 'success';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}}\n>\n\tinvalid (arg when no args expected)\n</button>\n\n<button\n\tonclick={async () => {\n\t\tstatus = 'pending';\n\t\ttry {\n\t\t\t// @ts-expect-error\n\t\t\tawait validated_query_with_arg(1).run();\n\t\t\tstatus = 'error';\n\t\t} catch (e) {\n\t\t\tif (!isHttpError(e) || e.body.message !== 'Input must be a string') {\n\t\t\t\tstatus = 'wrong error message';\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tawait validated_prerendered_query_with_arg(1);\n\t\t\t\tstatus = 'error';\n\t\t\t} catch (e) {\n\t\t\t\tif (!isHttpError(e) || e.body.message !== 'Input must be a string') {\n\t\t\t\t\tstatus = 'wrong error message';\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tawait validated_command_with_arg(1);\n\t\t\t\t\tstatus = 'error';\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (!isHttpError(e) || e.body.message !== 'Input must be a string') {\n\t\t\t\t\t\tstatus = 'wrong error message';\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\tawait validated_batch_query_with_validation(123).run();\n\t\t\t\t\t\tstatus = 'error';\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (!isHttpError(e) || e.body.message !== 'Input must be a string') {\n\t\t\t\t\t\t\tstatus = 'wrong error message';\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstatus = 'success';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}}\n>\n\tinvalid (wrong arg type)\n</button>\n\n<button\n\tonclick={async () => {\n\t\tstatus = 'pending';\n\t\ttry {\n\t\t\t// @ts-expect-error\n\t\t\tvalidate_result(await validated_query_with_arg('valid', 'ignored').run());\n\t\t\t// @ts-expect-error\n\t\t\tvalidate_result(await validated_prerendered_query_with_arg('valid', 'ignored'));\n\t\t\t// @ts-expect-error\n\t\t\tvalidate_result(await validated_command_with_arg('valid', 'ignored'));\n\t\t\t// @ts-expect-error\n\t\t\tvalidate_result(await validated_batch_query_no_validation('valid', 'ignored').run());\n\n\t\t\tstatus = 'success';\n\t\t} catch (e) {\n\t\t\tstatus = 'error';\n\t\t}\n\t}}\n>\n\tignored (more than one arg, only one sent to backend)\n</button>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/remote/validation/validation.remote.js",
    "content": "import { command, prerender, query } from '$app/server';\n\n// poor man's schema to avoid a dev dependency on a validation library\nconst schema = /** @type {import(\"@standard-schema/spec\").StandardSchemaV1<string>} */ ({\n\t['~standard']: {\n\t\tvalidate: (value) => {\n\t\t\tif (typeof value !== 'string') {\n\t\t\t\treturn { issues: [{ message: 'Input must be a string' }] };\n\t\t\t}\n\t\t\treturn { value };\n\t\t}\n\t}\n});\n\nexport const validated_query_no_args = query((arg) => (arg === undefined ? 'success' : 'failure'));\nexport const validated_query_with_arg = query(schema, (...arg) =>\n\ttypeof arg[0] === 'string' && arg.length === 1 ? 'success' : 'failure'\n);\n\nexport const validated_prerendered_query_no_args = prerender((arg) =>\n\targ === undefined ? 'success' : 'failure'\n);\nexport const validated_prerendered_query_with_arg = prerender(\n\tschema,\n\t(...arg) => (typeof arg[0] === 'string' && arg.length === 1 ? 'success' : 'failure'),\n\t{\n\t\tinputs: () => ['a'],\n\t\tdynamic: true\n\t}\n);\n\nexport const validated_command_no_args = command((arg) =>\n\targ === undefined ? 'success' : 'failure'\n);\nexport const validated_command_with_arg = command(schema, (...arg) =>\n\ttypeof arg[0] === 'string' && arg.length === 1 ? 'success' : 'failure'\n);\n\nexport const validated_batch_query_no_validation = query.batch(\n\t'unchecked',\n\t(_) => (item) => (item === 'valid' ? 'success' : 'failure')\n);\n\nexport const validated_batch_query_with_validation = query.batch(\n\tschema,\n\t(_) => (item) => (typeof item === 'string' ? 'success' : 'failure')\n);\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/server-error-boundary/+layout.svelte",
    "content": "<script>\n\tlet { children } = $props();\n</script>\n\n<div id=\"nested-layout\">\n\t<h2>Nested Layout</h2>\n\t{@render children?.()}\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/server-error-boundary/+page.svelte",
    "content": "<script>\n\tthrow new Error('render error');\n</script>\n\n<h1>This should not be visible</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/server-error-boundary/nested/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\tlet { error } = $props();\n</script>\n\n<p id=\"nested-error-message\">\n\t<!-- page.error always !== error on hydration because the former comes from the SvelteKit SSR payload and the latter from the failed boundary hydration comment -->\n\tNested error: {error.message} | {page.error.message === error.message} | {page.status}\n</p>\n"
  },
  {
    "path": "packages/kit/test/apps/async/src/routes/server-error-boundary/nested/+page.svelte",
    "content": "<script>\n\tthrow new Error('nested render error');\n</script>\n\n<h1>This nested page should not be visible</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/async/static/robots.txt",
    "content": "# allow crawling everything by default\nUser-agent: *\nDisallow:\n"
  },
  {
    "path": "packages/kit/test/apps/async/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tcompilerOptions: {\n\t\texperimental: {\n\t\t\tasync: true\n\t\t}\n\t},\n\n\tkit: {\n\t\texperimental: {\n\t\t\tremoteFunctions: true,\n\t\t\thandleRenderingErrors: true,\n\t\t\tforkPreloads: true\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/async/test/client.test.js",
    "content": "import process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\nconst is_node18 = process.versions.node.startsWith('18.');\nimport { version as vite_version } from 'vite';\nconst is_vite5 = vite_version.startsWith('5.');\n\ntest.skip(({ javaScriptEnabled }) => !javaScriptEnabled);\n\ntest.describe('remote functions', () => {\n\ttest('preloading data works when the page component and server load both import a remote function', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\ttest.skip(!process.env.DEV, 'remote functions are only analysed in dev mode');\n\t\t// TODO: remove with SvelteKit 3\n\t\ttest.skip(is_node18 && is_vite5, 'vite5 in node18 fails to resolve remote function export');\n\t\tawait page.goto('/remote/dev');\n\t\tawait page.locator('a[href=\"/remote/dev/preload\"]').hover();\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\tawait clicknav('a[href=\"/remote/dev/preload\"]', { waitForURL: '/remote/dev/preload' });\n\t\tawait expect(page.locator('p')).toHaveText('foobar');\n\t\tawait page.getByRole('button', { name: 'Refresh' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('foobaz');\n\t});\n});\n\n// have to run in serial because commands mutate in-memory data on the server (should fix this at some point)\ntest.describe('remote function mutations', () => {\n\ttest.afterEach(async ({ page }) => {\n\t\tif (page.url().endsWith('/remote')) {\n\t\t\tawait page.click('#reset-btn');\n\t\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\t\t}\n\t});\n\n\ttest('query.set works', async ({ page }) => {\n\t\tawait page.goto('/remote');\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.click('#set-btn');\n\t\tawait expect(page.locator('#count-result')).toHaveText('999 / 999 (false)');\n\t\tawait page.waitForTimeout(100); // allow all requests to finish (in case there are query refreshes which shouldn't happen)\n\t\texpect(request_count).toBe(0);\n\t});\n\n\ttest('hydrated data is reused', async ({ page }) => {\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.goto('/remote');\n\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\t\t// only the calls in the template are done, not the one in the load function\n\t\texpect(request_count).toBe(0);\n\t});\n\n\ttest('hydrated batch data is reused', async ({ page }) => {\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.goto('/remote/batch-ssr');\n\t\tawait expect(page.locator('#ssr-batch-result-1')).toHaveText('Buy groceries');\n\t\tawait expect(page.locator('#ssr-batch-result-2')).toHaveText('Walk the dog');\n\t\tawait expect(page.locator('#ssr-batch-result-3')).toHaveText('Not found');\n\t\texpect(request_count).toBe(0);\n\t});\n\n\ttest('command returns correct sum but does not refresh data by default', async ({ page }) => {\n\t\tawait page.goto('/remote');\n\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.click('#multiply-btn');\n\t\tawait expect(page.locator('#command-result')).toHaveText('2');\n\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\t\tawait page.waitForTimeout(100); // allow all requests to finish\n\t\texpect(request_count).toBe(1); // 1 for the command, no refreshes\n\t});\n\n\ttest('command returns correct sum and does client-initiated single flight mutation', async ({\n\t\tpage\n\t}) => {\n\t\tawait page.goto('/remote');\n\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.click('#multiply-refresh-btn');\n\t\tawait expect(page.locator('#command-result')).toHaveText('3');\n\t\tawait expect(page.locator('#count-result')).toHaveText('3 / 3 (false)');\n\t\tawait page.waitForTimeout(100); // allow all requests to finish\n\t\texpect(request_count).toBe(1); // no query refreshes, since that happens as part of the command response\n\t});\n\n\ttest('command does server-initiated single flight mutation (refresh)', async ({ page }) => {\n\t\tawait page.goto('/remote');\n\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.click('#multiply-server-refresh-btn');\n\t\tawait expect(page.locator('#command-result')).toHaveText('4');\n\t\tawait expect(page.locator('#count-result')).toHaveText('4 / 4 (false)');\n\t\tawait page.waitForTimeout(100); // allow all requests to finish (in case there are query refreshes which shouldn't happen)\n\t\texpect(request_count).toBe(1); // no query refreshes, since that happens as part of the command response\n\t});\n\n\ttest('command refresh after reading query reruns the query', async ({ page }) => {\n\t\tawait page.goto('/remote');\n\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.click('#multiply-server-refresh-after-read-btn');\n\t\tawait expect(page.locator('#command-result')).toHaveText('6');\n\t\tawait expect(page.locator('#count-result')).toHaveText('6 / 6 (false)');\n\t\tawait page.waitForTimeout(100); // allow all requests to finish (in case there are query refreshes which shouldn't happen)\n\t\texpect(request_count).toBe(1);\n\t});\n\n\ttest('command does server-initiated single flight mutation (set)', async ({ page }) => {\n\t\tawait page.goto('/remote');\n\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.click('#multiply-server-set-btn');\n\t\tawait expect(page.locator('#command-result')).toHaveText('8');\n\t\tawait expect(page.locator('#count-result')).toHaveText('8 / 8 (false)');\n\t\tawait page.waitForTimeout(100); // allow all requests to finish (in case there are query refreshes which shouldn't happen)\n\t\texpect(request_count).toBe(1); // no query refreshes, since that happens as part of the command response\n\t});\n\n\ttest('command does client-initiated single flight mutation with override', async ({ page }) => {\n\t\tawait page.goto('/remote');\n\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.click('#multiply-override-refresh-btn');\n\t\tawait expect(page.locator('#count-result')).toHaveText('6 / 6 (false)');\n\t\tawait expect(page.locator('#command-result')).toHaveText('5');\n\t\tawait expect(page.locator('#count-result')).toHaveText('5 / 5 (false)');\n\t\tawait page.waitForTimeout(100); // allow all requests to finish (in case there are query refreshes which shouldn't happen)\n\t\texpect(request_count).toBe(1); // no query refreshes, since that happens as part of the command response\n\t});\n\n\ttest('query/command inside endpoint works', async ({ page }) => {\n\t\tawait page.goto('/remote/server-endpoint');\n\n\t\tawait page.getByRole('button', { name: 'get' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('get');\n\n\t\tawait page.getByRole('button', { name: 'post' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('post');\n\t});\n\n\ttest('command inside form action works', async ({ page }) => {\n\t\tawait page.goto('/remote/server-action');\n\n\t\tawait page.getByRole('button', { name: 'submit' }).click();\n\t\tawait expect(page.locator('#result')).toHaveText('action: hello');\n\t});\n\n\ttest('command inside handle hook works with POST', async ({ request }) => {\n\t\tconst response = await request.post('/remote/hook-command');\n\t\texpect(response.status()).toBe(200);\n\t\tconst data = await response.json();\n\t\texpect(data.result).toBe('action: from-hook');\n\t});\n\n\ttest('command is blocked inside load functions', async ({ page }) => {\n\t\tconst response = await page.goto('/remote/server-load-command');\n\t\texpect(response?.status()).toBe(500);\n\t\tawait expect(page.locator('#message')).toContainText('Cannot call a command');\n\t});\n\n\ttest('command is blocked inside handle hook with GET', async ({ request }) => {\n\t\tconst response = await request.get('/remote/hook-command');\n\t\texpect(response.status()).toBe(500);\n\t\tconst data = await response.json();\n\t\texpect(data.error).toContain('Cannot call a command');\n\t});\n\n\ttest('prerendered entries use prerender cache while live entries refetch', async ({ page }) => {\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\t\tawait page.goto('/remote/prerender');\n\n\t\tawait page.click('#fetch-prerendered');\n\t\tawait expect(page.locator('#fetch-prerendered')).toHaveText('yes');\n\t\texpect(request_count).toBe(1);\n\n\t\tawait page.click('#fetch-prerendered');\n\t\tawait expect(page.locator('#fetch-prerendered')).toHaveText('yes');\n\t\texpect(request_count).toBe(1);\n\n\t\tawait page.click('#fetch-not-prerendered');\n\t\tawait expect(page.locator('#fetch-not-prerendered')).toHaveText('d');\n\t\texpect(request_count).toBe(2);\n\t});\n\n\ttest('refreshAll reloads remote functions and load functions', async ({ page }) => {\n\t\tawait page.goto('/remote');\n\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.click('#refresh-all');\n\t\tawait page.waitForTimeout(100); // allow things to rerun\n\t\texpect(request_count).toBe(3);\n\t});\n\n\ttest('refreshAll({ includeLoadFunctions: false }) reloads remote functions only', async ({\n\t\tpage\n\t}) => {\n\t\tawait page.goto('/remote');\n\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.click('#refresh-remote-only');\n\t\tawait page.waitForTimeout(100); // allow things to rerun\n\t\texpect(request_count).toBe(2);\n\t});\n\n\ttest('command tracks pending state', async ({ page }) => {\n\t\tawait page.goto('/remote');\n\n\t\t// Initial pending should be 0\n\t\tawait expect(page.locator('#command-pending')).toHaveText('Command pending: 0');\n\n\t\t// Start a slow command - this will hang until we resolve it\n\t\tawait page.click('#command-deferred-btn');\n\n\t\t// Check that pending has incremented to 1\n\t\tawait expect(page.locator('#command-pending')).toHaveText('Command pending: 1');\n\n\t\t// Resolve the deferred command\n\t\tawait page.click('#resolve-deferreds');\n\n\t\t// Wait for the command to complete and pending to go back to 0\n\t\tawait expect(page.locator('#command-pending')).toHaveText('Command pending: 0');\n\t});\n\n\ttest('validation works', async ({ page }) => {\n\t\tawait page.goto('/remote/validation');\n\t\tawait expect(page.locator('p')).toHaveText('pending');\n\n\t\tawait page.click('button:nth-of-type(1)');\n\t\tawait expect(page.locator('p')).toHaveText('success');\n\n\t\tawait page.click('button:nth-of-type(2)');\n\t\tawait expect(page.locator('p')).toHaveText('success');\n\n\t\tawait page.click('button:nth-of-type(3)');\n\t\tawait expect(page.locator('p')).toHaveText('success');\n\n\t\tawait page.click('button:nth-of-type(4)');\n\t\tawait expect(page.locator('p')).toHaveText('success');\n\t});\n\n\ttest('fields.set updates DOM before validate', async ({ page }) => {\n\t\tawait page.goto('/remote/form/imperative');\n\n\t\tconst input = page.locator('input[name=\"message\"]');\n\t\tawait input.fill('123');\n\n\t\tawait page.locator('#set-and-validate').click();\n\n\t\tawait expect(input).toHaveValue('hello');\n\t\tawait expect(page.locator('#issue')).toHaveText('ok');\n\t});\n\n\ttest('command pending state is tracked correctly', async ({ page }) => {\n\t\tawait page.goto('/remote');\n\n\t\t// Initially no pending commands\n\t\tawait expect(page.locator('#command-pending')).toHaveText('Command pending: 0');\n\n\t\t// Start a slow command - this will hang until we resolve it\n\t\tawait page.click('#command-deferred-btn');\n\n\t\t// Check that pending has incremented to 1\n\t\tawait expect(page.locator('#command-pending')).toHaveText('Command pending: 1');\n\n\t\t// Resolve the deferred command\n\t\tawait page.click('#resolve-deferreds');\n\n\t\t// Wait for the command to complete and verify results\n\t\tawait expect(page.locator('#command-result')).toHaveText('7');\n\n\t\t// Verify pending count returns to 0\n\t\tawait expect(page.locator('#command-pending')).toHaveText('Command pending: 0');\n\t});\n\n\t// TODO once we have async SSR adjust the test and move this into test.js\n\ttest('query.batch works', async ({ page }) => {\n\t\tawait page.goto('/remote/batch');\n\n\t\tawait expect(page.locator('#batch-result-1')).toHaveText('Buy groceries');\n\t\tawait expect(page.locator('#batch-result-2')).toHaveText('Walk the dog');\n\t\tawait expect(page.locator('#batch-result-3')).toHaveText('Buy groceries');\n\t\tawait expect(page.locator('#batch-result-4')).toHaveText('Error loading todo error: Not found');\n\n\t\tlet request_count = 0;\n\t\tpage.on('request', (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0));\n\n\t\tawait page.click('button');\n\t\tawait page.waitForTimeout(100); // allow all requests to finish\n\t\texpect(request_count).toBe(1);\n\t});\n\n\ttest('query.batch set updates cache without extra request', async ({ page }) => {\n\t\tawait page.goto('/remote/batch');\n\t\tawait page.click('#batch-reset-btn');\n\t\tawait expect(page.locator('#batch-result-1')).toHaveText('Buy groceries');\n\n\t\tlet request_count = 0;\n\t\tconst handler = (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0);\n\t\tpage.on('request', handler);\n\n\t\tawait page.click('#batch-set-btn');\n\t\tawait expect(page.locator('#batch-result-1')).toHaveText('Buy cat food');\n\t\tawait page.waitForTimeout(100); // allow all requests to finish\n\t\texpect(request_count).toBe(1); // only the command request\n\t});\n\n\ttest('query.batch refresh in command reuses single flight', async ({ page }) => {\n\t\tawait page.goto('/remote/batch');\n\t\tawait page.click('#batch-reset-btn');\n\t\tawait expect(page.locator('#batch-result-2')).toHaveText('Walk the dog');\n\n\t\tlet request_count = 0;\n\t\tconst handler = (r) => (request_count += r.url().includes('/_app/remote') ? 1 : 0);\n\t\tpage.on('request', handler);\n\n\t\tawait page.click('#batch-refresh-btn');\n\t\tawait expect(page.locator('#batch-result-2')).toHaveText('Walk the dog (refreshed)');\n\t\tawait page.waitForTimeout(100); // allow all requests to finish\n\t\texpect(request_count).toBe(1); // only the command request\n\t});\n\n\ttest('query.batch resolver function always receives validated arguments', async ({ page }) => {\n\t\tawait page.goto('/remote/batch-validation');\n\n\t\tawait expect(page.locator('#phrase')).toHaveText('use the force');\n\t\tawait page.locator('button').click();\n\t\tawait expect(page.locator('#phrase')).toHaveText('i am your father');\n\t});\n\n\ttest.describe('query runtime guardrails', () => {\n\t\ttest('query created outside tracking context can run but cannot expose reactive state', async ({\n\t\t\tpage\n\t\t}) => {\n\t\t\tawait page.goto('/remote/query-runtime-errors/not-tracked');\n\n\t\t\tawait page.click('#create');\n\t\t\tawait expect(page.locator('#status')).toHaveText('query created');\n\n\t\t\tawait page.click('#run');\n\t\t\tawait expect(page.locator('#result')).toHaveText('0');\n\n\t\t\tawait page.click('#read-current');\n\t\t\tawait expect(page.locator('#result')).toContainText(\n\t\t\t\t'This query was not created in a reactive context'\n\t\t\t);\n\t\t});\n\n\t\ttest('query becomes inactive after its tracking context is destroyed', async ({ page }) => {\n\t\t\tawait page.goto('/remote/query-runtime-errors/inactive');\n\n\t\t\tawait expect(page.locator('#tracked-child')).toHaveText('tracked query ready');\n\t\t\tawait page.click('#unmount');\n\t\t\tawait expect(page.locator('#status')).toHaveText('child unmounted');\n\t\t\tawait expect(page.locator('#tracked-child')).toHaveCount(0);\n\n\t\t\tawait page.click('#read-current');\n\t\t\tawait expect(page.locator('#result')).toContainText(\n\t\t\t\t'This query instance is no longer active'\n\t\t\t);\n\t\t});\n\n\t\ttest('run is blocked during client render', async ({ page, app }) => {\n\t\t\tawait page.goto('/remote');\n\t\t\tawait app.goto('/remote/query-runtime-errors/run-in-render');\n\n\t\t\tawait expect(page.locator('#error')).toContainText(\n\t\t\t\t'On the client, .run() can only be called outside render'\n\t\t\t);\n\t\t});\n\t});\n\n\t// TODO ditto\n\ttest('query works with transport', async ({ page }) => {\n\t\tawait page.goto('/remote/transport');\n\n\t\tawait expect(page.locator('h1')).toHaveText('hello from remote function!');\n\t});\n\n\ttest('form.for() with enhance does not duplicate requests', async ({ page }) => {\n\t\tawait page.goto('/remote/form/for-duplicate');\n\n\t\tfor (let i = 1; i <= 3; i++) {\n\t\t\tawait page.click('#submit');\n\t\t\tawait expect(page.locator('#count')).toHaveText(String(i));\n\t\t}\n\t});\n});\n\ntest.describe('client error boundaries', () => {\n\ttest('catches client render error and shows root +error.svelte', async ({ page, app }) => {\n\t\tawait page.goto('/');\n\t\tawait app.goto('/server-error-boundary');\n\t\tawait expect(page.locator('#message')).toContainText(\n\t\t\t'render error (500 Internal Error, on /server-error-boundary)'\n\t\t);\n\t});\n\n\ttest('catches nested server render error and shows nested +error.svelte', async ({\n\t\tpage,\n\t\tapp\n\t}) => {\n\t\tawait page.goto('/');\n\t\tawait app.goto('/server-error-boundary/nested');\n\t\tawait expect(page.locator('#nested-error-message')).toContainText(\n\t\t\t'nested render error (500 Internal Error, on /server-error-boundary/nested) | true | 500'\n\t\t);\n\t\t// The nested layout should still be visible\n\t\tawait expect(page.locator('#nested-layout')).toBeVisible();\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/test/server.test.js",
    "content": "import process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\ntest.skip(({ javaScriptEnabled }) => javaScriptEnabled);\n\nconst root = path.resolve(fileURLToPath(import.meta.url), '..', '..');\n\ntest.describe('remote functions', () => {\n\ttest(\"doesn't write bundle to disk when treeshaking prerendered remote functions\", () => {\n\t\ttest.skip(!!process.env.DEV, 'skip when in dev mode');\n\t\texpect(fs.existsSync(path.join(root, 'dist'))).toBe(false);\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/test/test.js",
    "content": "import http from 'node:http';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\ntest.describe('remote functions', () => {\n\ttest('query returns correct data', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/remote');\n\t\tawait expect(page.locator('#echo-result')).toHaveText('Hello world');\n\t\tif (javaScriptEnabled) {\n\t\t\tawait expect(page.locator('#count-result')).toHaveText('0 / 0 (false)');\n\t\t}\n\t});\n\n\ttest('query.batch renders final values and errors on first load', async ({ page }) => {\n\t\tawait page.goto('/remote/batch-ssr');\n\n\t\tawait expect(page.locator('#ssr-batch-result-1')).toHaveText('Buy groceries');\n\t\tawait expect(page.locator('#ssr-batch-result-2')).toHaveText('Walk the dog');\n\t\tawait expect(page.locator('#ssr-batch-result-3')).toHaveText('Not found');\n\t\tawait expect(page.locator('body')).not.toContainText('Loading todo');\n\t});\n\n\ttest('run is blocked during server render', async ({ page }) => {\n\t\tawait page.goto('/remote/query-runtime-errors/run-in-render');\n\t\tawait expect(page.locator('#error')).toContainText(\n\t\t\t'On the server, .run() can only be called in universal `load` functions'\n\t\t);\n\t});\n\n\ttest('query redirects on page load (query in common layout)', async ({ page }) => {\n\t\tawait page.goto('/remote/query-redirect');\n\t\tawait page.click('a[href=\"/remote/query-redirect/from-common-layout\"]');\n\t\tawait expect(page.locator('#redirected')).toHaveText('redirected');\n\t\tawait expect(page.locator('#layout-query')).toHaveText(\n\t\t\t'on page /remote/query-redirect/from-common-layout/redirected (== /remote/query-redirect/from-common-layout/redirected)'\n\t\t);\n\t});\n\n\ttest('query redirects on page load (query on page)', async ({ page }) => {\n\t\tawait page.goto('/remote/query-redirect');\n\t\tawait page.click('a[href=\"/remote/query-redirect/from-page\"]');\n\t\tawait expect(page.locator('#redirected')).toHaveText('redirected');\n\t});\n\n\ttest(\"query that's awaited and throws a redirect doesn't trigger handleError hook\", async ({\n\t\tbaseURL\n\t}) => {\n\t\tconst { status, location } = await new Promise((fulfil, reject) => {\n\t\t\tconst request = http.get(`${baseURL}/remote/query-redirect/from-page`, (response) => {\n\t\t\t\tfulfil({\n\t\t\t\t\tstatus: response.statusCode,\n\t\t\t\t\tlocation: response.headers.location\n\t\t\t\t});\n\t\t\t\tresponse.resume();\n\t\t\t});\n\t\t\trequest.on('error', reject);\n\t\t});\n\n\t\texpect(status).toBe(307);\n\t\texpect(location).toBe('/remote/query-redirect/redirected');\n\t});\n\n\ttest('non-exported queries do not clobber each other', async ({ page }) => {\n\t\tawait page.goto('/remote/query-non-exported');\n\n\t\tawait expect(page.locator('h1')).toHaveText('3');\n\t});\n\n\ttest('queries can access the route/url of the page they were called from', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/remote');\n\n\t\tawait clicknav('[href=\"/remote/event\"]');\n\n\t\tawait expect(page.locator('[data-id=\"route\"]')).toHaveText('route: /remote/event');\n\t\tawait expect(page.locator('[data-id=\"pathname\"]')).toHaveText('pathname: /remote/event');\n\t});\n\n\ttest('form works', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto(`/remote/form/basic-${javaScriptEnabled}`);\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait expect(page.getByText('message.current:')).toHaveText('message.current: initial');\n\t\t}\n\t\tawait expect(page.getByText('await get_message():')).toHaveText('await get_message(): initial');\n\n\t\tawait page.fill('[data-unscoped] input', 'hello');\n\t\tawait page.getByText('set message').click();\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait expect(page.getByText('set_message.pending:')).toHaveText('set_message.pending: 1');\n\t\t\tawait page.getByText('resolve deferreds').click();\n\t\t\tawait expect(page.getByText('set_message.pending:')).toHaveText('set_message.pending: 0');\n\t\t\tawait expect(page.getByText('message.current:')).toHaveText('message.current: hello');\n\t\t}\n\n\t\tawait expect(page.getByText('await get_message():')).toHaveText('await get_message(): hello');\n\n\t\tawait expect(page.getByText('set_message.result')).toHaveText('set_message.result: hello');\n\t\tawait expect(page.locator('[data-unscoped] input[name=\"message\"]')).toHaveValue('');\n\t});\n\n\ttest('form submitters work', async ({ page }) => {\n\t\tawait page.goto('/remote/form/submitter');\n\n\t\tawait page.locator('button').click();\n\n\t\tawait expect(page.locator('#result')).toHaveText('hello');\n\t});\n\n\ttest('form updates inputs live', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/remote/form/live-update');\n\n\t\tawait page.fill('input', 'hello');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait expect(page.getByText('set_message.input.message:')).toHaveText(\n\t\t\t\t'set_message.input.message: hello'\n\t\t\t);\n\t\t}\n\n\t\tawait page.getByText('set message').click();\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.getByText('resolve deferreds').click();\n\t\t}\n\n\t\tawait expect(page.getByText('set_message.input.message:')).toHaveText(\n\t\t\t'set_message.input.message:'\n\t\t);\n\t});\n\n\ttest('form reports validation issues', async ({ page }) => {\n\t\tawait page.goto('/remote/form/validation-issues');\n\n\t\tawait page.fill('input', 'invalid');\n\t\tawait page.getByText('set message').click();\n\n\t\tawait page.getByText('message is invalid').waitFor();\n\t});\n\n\ttest('form handles unexpected error', async ({ page }) => {\n\t\tawait page.goto('/remote/form/unexpected-error');\n\n\t\tawait page.fill('input', 'unexpected error');\n\t\tawait page.getByText('set message').click();\n\n\t\tawait page\n\t\t\t.getByText(\n\t\t\t\t'This is your custom error page saying: \"oops (500 Internal Error, on /remote/form/unexpected-error)\"'\n\t\t\t)\n\t\t\t.waitFor();\n\t});\n\n\ttest('form handles expected error', async ({ page }) => {\n\t\tawait page.goto('/remote/form/expected-error');\n\n\t\tawait page.fill('input', 'expected error');\n\t\tawait page.getByText('set message').click();\n\n\t\tawait page.getByText('This is your custom error page saying: \"oops\"').waitFor();\n\t});\n\n\ttest('form redirects', async ({ page }) => {\n\t\tawait page.goto('/remote/form/redirect');\n\n\t\tawait page.fill('input', 'redirect');\n\t\tawait page.getByText('set message').click();\n\n\t\tawait page.waitForURL('/remote');\n\t});\n\n\ttest('remote form redirect opens in new tab when target=_blank', async ({ page }) => {\n\t\tawait page.goto('/remote/form/redirect-target');\n\n\t\tconst popup_promise = page.waitForEvent('popup', { timeout: 5000 });\n\n\t\tawait page.locator('[data-testid=\"form-blank\"] button').click();\n\n\t\tconst popup = await popup_promise;\n\t\tawait popup.waitForLoadState();\n\n\t\texpect(popup.url()).toContain('/remote/form/redirect-target/destination');\n\n\t\texpect(page.url()).toContain('/remote/form/redirect-target');\n\t\texpect(page.url()).not.toContain('/destination');\n\t});\n\n\ttest('remote form redirect navigates same tab without target=_blank', async ({ page }) => {\n\t\tawait page.goto('/remote/form/redirect-target');\n\n\t\tlet popup_opened = false;\n\t\tpage.on('popup', () => {\n\t\t\tpopup_opened = true;\n\t\t});\n\n\t\tawait page.locator('form:not([target]) button').click();\n\t\tawait page.waitForURL('**/remote/form/redirect-target/destination');\n\n\t\texpect(popup_opened).toBe(false);\n\t\texpect(page.url()).toContain('/remote/form/redirect-target/destination');\n\t});\n\n\ttest('remote form redirect opens in new tab when formtarget=_blank on input', async ({\n\t\tpage\n\t}) => {\n\t\tawait page.goto('/remote/form/redirect-target');\n\n\t\tconst popup_promise = page.waitForEvent('popup', { timeout: 5000 });\n\t\tawait page.locator('[data-testid=\"form-input-blank\"] input').click();\n\t\tconst popup = await popup_promise;\n\t\tawait popup.waitForLoadState();\n\n\t\texpect(popup.url()).toContain('/remote/form/redirect-target/destination');\n\t\texpect(page.url()).toContain('/remote/form/redirect-target');\n\t\texpect(page.url()).not.toContain('/destination');\n\t});\n\n\ttest('form multiple submit buttons work', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/remote/form/multiple-submit');\n\n\t\tawait page.fill('[data-unscoped] input', 'backwards');\n\t\tawait page.getByText('set reverse message').click();\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.getByText('resolve deferreds').click();\n\t\t\tawait page.getByText('message.current: sdrawkcab').waitFor();\n\t\t\tawait expect(page.getByText('await get_message():')).toHaveText(\n\t\t\t\t'await get_message(): sdrawkcab'\n\t\t\t);\n\t\t}\n\n\t\tawait expect(page.getByText('set_message.result')).toHaveText('set_message.result: sdrawkcab');\n\t});\n\n\ttest('form scoping with for(...) works', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/remote/form/form-scoped');\n\n\t\tawait page.fill('[data-scoped] input', 'hello');\n\t\tawait page.getByText('set scoped message').click();\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait expect(page.getByText('scoped.pending:')).toHaveText('scoped.pending: 1');\n\t\t\tawait page.getByText('resolve deferreds').click();\n\t\t\tawait expect(page.getByText('scoped.pending:')).toHaveText('scoped.pending: 0');\n\n\t\t\tawait page.getByText('message.current: hello').waitFor();\n\t\t\tawait expect(page.getByText('await get_message():')).toHaveText('await get_message(): hello');\n\t\t}\n\n\t\tawait expect(page.getByText('scoped.result')).toHaveText(\n\t\t\t'scoped.result: hello (from: scoped:form-scoped)'\n\t\t);\n\t\tawait expect(page.locator('[data-scoped] input[name=\"message\"]')).toHaveValue('');\n\t});\n\n\ttest('form enhance(...) works', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/remote/form/enhanced');\n\n\t\tawait page.fill('[data-enhanced] input', 'hello');\n\n\t\t// Click on the span inside the button to test the event.target vs event.currentTarget issue (#14159)\n\t\tawait page.locator('[data-enhanced] span').click();\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait expect(page.getByText('enhanced.pending:')).toHaveText('enhanced.pending: 1');\n\n\t\t\tawait page.getByText('message.current: hello (override)').waitFor();\n\n\t\t\tawait page.getByText('resolve deferreds').click();\n\t\t\tawait expect(page.getByText('enhanced.pending:')).toHaveText('enhanced.pending: 0');\n\t\t\tawait expect(page.getByText('await get_message():')).toHaveText('await get_message(): hello');\n\n\t\t\t// enhanced submission should not clear the input; the developer must do that at the appropriate time\n\t\t\tawait expect(page.locator('[data-enhanced] input[name=\"message\"]')).toHaveValue('hello');\n\t\t} else {\n\t\t\tawait expect(page.locator('[data-enhanced] input[name=\"message\"]')).toHaveValue('');\n\t\t}\n\n\t\tawait expect(page.getByText('enhanced.result')).toHaveText(\n\t\t\t'enhanced.result: hello (from: enhanced:enhanced)'\n\t\t);\n\t});\n\n\ttest('form preflight works', async ({ page, javaScriptEnabled }) => {\n\t\tif (!javaScriptEnabled) return;\n\n\t\tawait page.goto('/remote/form/preflight');\n\n\t\tfor (const enhanced of [true, false]) {\n\t\t\tconst form = page.locator(enhanced ? '[data-enhanced]' : '[data-default]');\n\t\t\tconst input = form.locator('input');\n\t\t\tconst button = page.getByText(enhanced ? 'set enhanced number' : 'set number');\n\n\t\t\tawait input.fill('21');\n\t\t\tawait button.click();\n\t\t\tawait form.getByText('too big').waitFor();\n\n\t\t\tawait input.fill('9');\n\t\t\tawait button.click();\n\t\t\tawait form.getByText('too small').waitFor();\n\t\t\tawait expect(form.getByText('too big')).not.toBeVisible();\n\n\t\t\tif (enhanced) {\n\t\t\t\t// one more time preflight-issue only so that we can test it's cleared\n\t\t\t\t// after it passes and before submission.\n\t\t\t\tawait input.fill('21');\n\t\t\t\tawait button.click();\n\t\t\t\tawait form.getByText('too big').waitFor();\n\t\t\t}\n\n\t\t\tawait input.fill('15');\n\t\t\tawait button.click();\n\t\t\tawait expect(page.getByText('number.current')).toHaveText('number.current: 15');\n\t\t}\n\t});\n\n\ttest('form pending is true immediately during async preflight', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tif (!javaScriptEnabled) return;\n\n\t\tawait page.goto('/remote/form/preflight-pending');\n\n\t\t// Test 1: async preflight that passes — pending should be true immediately\n\t\tawait expect(page.locator('[data-passing-pending]')).toHaveText('passing pending: 0');\n\n\t\tvoid page.click('[data-passing] button');\n\n\t\t// pending should be true immediately (before async preflight finishes)\n\t\tawait expect(page.locator('[data-passing-pending]')).toHaveText('passing pending: 1');\n\n\t\t// after submission completes, pending should return to 0\n\t\tawait expect(page.locator('[data-passing-pending]')).toHaveText('passing pending: 0', {\n\t\t\ttimeout: 5000\n\t\t});\n\t\tawait expect(page.locator('[data-passing-result]')).toContainText('created:');\n\n\t\t// Test 2: async preflight that fails — pending should be true during validation, then return to 0\n\t\tawait expect(page.locator('[data-failing-pending]')).toHaveText('failing pending: 0');\n\n\t\tvoid page.click('[data-failing] button');\n\n\t\t// pending should be true immediately\n\t\tawait expect(page.locator('[data-failing-pending]')).toHaveText('failing pending: 1');\n\n\t\t// after preflight fails, pending should return to 0 and issues should appear\n\t\tawait expect(page.locator('[data-failing-pending]')).toHaveText('failing pending: 0', {\n\t\t\ttimeout: 5000\n\t\t});\n\t\tawait expect(page.locator('[data-failing-issue]')).toHaveText('async check failed');\n\t});\n\n\ttest('form preflight-only validation works', async ({ page, javaScriptEnabled }) => {\n\t\tif (!javaScriptEnabled) return;\n\n\t\tawait page.goto('/remote/form/preflight-only');\n\n\t\tconst a = page.locator('[name=\"a\"]');\n\t\tconst button = page.locator('button');\n\t\tconst issues = page.locator('.issues');\n\n\t\tawait button.click();\n\t\tawait expect(issues).toContainText('a is too short');\n\t\tawait expect(issues).toContainText('b is too short');\n\t\tawait expect(issues).toContainText('c is too short');\n\n\t\tawait a.fill('aaaaaaaa');\n\t\tawait expect(issues).toContainText('a is too long');\n\n\t\t// server issues should be preserved...\n\t\tawait expect(issues).toContainText('b is too short');\n\t\tawait expect(issues).toContainText('c is too short');\n\n\t\t// ...unless overridden by client issues\n\t\tawait expect(issues).not.toContainText('a is too short');\n\t});\n\n\ttest('form validate works', async ({ page, javaScriptEnabled }) => {\n\t\tif (!javaScriptEnabled) return;\n\n\t\tawait page.goto('/remote/form/validate');\n\n\t\tconst myForm = page.locator('form#my-form');\n\t\tconst foo = page.locator('input[name=\"foo\"]');\n\t\tconst bar = page.locator('input[name=\"bar\"]');\n\t\tconst submit = page.locator('button:has-text(\"imperative validation\")');\n\n\t\tawait foo.fill('a');\n\t\tawait expect(myForm).not.toContainText('Invalid type: Expected');\n\n\t\tawait bar.fill('g');\n\t\tawait expect(myForm).toContainText('Invalid type: Expected (\"d\" | \"e\") but received \"g\"');\n\n\t\tawait bar.fill('d');\n\t\tawait expect(myForm).not.toContainText('Invalid type: Expected');\n\n\t\tawait page.locator('#trigger-validate').click();\n\t\tawait expect(myForm).toContainText(\n\t\t\t'Invalid type: Expected \"submitter\" but received \"incorrect_value\"'\n\t\t);\n\n\t\t// Test imperative validation\n\t\tawait foo.fill('c');\n\t\tawait bar.fill('d');\n\t\tawait submit.click();\n\t\tawait expect(myForm).toContainText('Imperative: foo cannot be c');\n\n\t\tconst nestedValue = page.locator('input[name=\"nested.value\"]');\n\t\tconst validate = page.locator('button#validate');\n\t\tconst allIssues = page.locator('#allIssues');\n\n\t\tawait nestedValue.fill('in');\n\t\tawait validate.click();\n\t\tawait expect(allIssues).toContainText('\"path\":[\"nested\",\"value\"]');\n\t});\n\n\ttest('form validation issues cleared', async ({ page, javaScriptEnabled }) => {\n\t\tif (!javaScriptEnabled) return;\n\n\t\tawait page.goto('/remote/form/validate');\n\n\t\tconst baz = page.locator('input[name=\"baz\"]');\n\t\tconst submit = page.locator('#my-form-2 button');\n\n\t\tawait baz.fill('c');\n\t\tawait submit.click();\n\t\tawait expect(page.locator('#my-form-2')).toContainText('Invalid type: Expected');\n\n\t\tawait baz.fill('a');\n\t\tawait submit.click();\n\t\tawait expect(page.locator('#my-form-2')).not.toContainText('Invalid type: Expected');\n\t\tawait expect(page.locator('[data-error]')).toHaveText('An error occurred');\n\n\t\tawait baz.fill('c');\n\t\tawait submit.click();\n\t\tawait expect(page.locator('#my-form-2')).toContainText('Invalid type: Expected');\n\n\t\tawait baz.fill('b');\n\t\tawait submit.click();\n\t\tawait expect(page.locator('#my-form-2')).not.toContainText('Invalid type: Expected');\n\t\tawait expect(page.locator('[data-error]')).toHaveText('No error');\n\t});\n\n\ttest('form inputs excludes underscore-prefixed fields', async ({ page, javaScriptEnabled }) => {\n\t\tif (javaScriptEnabled) return;\n\n\t\tawait page.goto('/remote/form/underscore');\n\n\t\tawait page.fill('input[name=\"username\"]', 'abcdefg');\n\t\tawait page.fill('input[name=\"_password\"]', 'pqrstuv');\n\t\tawait page.locator('button').click();\n\n\t\tawait expect(page.locator('input[name=\"username\"]')).toHaveValue('abcdefg');\n\t\tawait expect(page.locator('input[name=\"_password\"]')).toHaveValue('');\n\t});\n\n\ttest('prerendered entries not called in prod', async ({ page, clicknav }) => {\n\t\tawait page.goto('/remote/prerender');\n\t\tawait clicknav('[href=\"/remote/prerender/whole-page\"]');\n\t\tawait expect(page.locator('#prerendered-data')).toHaveText('a c 中文 yes');\n\n\t\tawait page.goto('/remote/prerender');\n\t\tawait clicknav('[href=\"/remote/prerender/functions-only\"]');\n\t\tawait expect(page.locator('#prerendered-data')).toHaveText('a c 中文 yes');\n\t});\n\n\ttest('form.fields.value() returns correct nested object structure', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tif (!javaScriptEnabled) return;\n\n\t\tawait page.goto('/remote/form/value');\n\n\t\t// Initially should be empty object or undefined values\n\t\tconst initialValue = await page.locator('#full-value').textContent();\n\t\texpect(JSON.parse(initialValue)).toEqual({});\n\n\t\t// Fill leaf field\n\t\tawait page.fill('input[name=\"leaf\"]', 'leaf-value');\n\t\tconst afterLeaf = await page.locator('#full-value').textContent();\n\t\texpect(JSON.parse(afterLeaf)).toEqual({\n\t\t\tleaf: 'leaf-value'\n\t\t});\n\n\t\t// Fill object.leaf field\n\t\tawait page.fill('input[name=\"object.leaf\"]', 'object-leaf-value');\n\t\tconst afterObjectLeaf = await page.locator('#full-value').textContent();\n\t\texpect(JSON.parse(afterObjectLeaf)).toEqual({\n\t\t\tleaf: 'leaf-value',\n\t\t\tobject: {\n\t\t\t\tleaf: 'object-leaf-value'\n\t\t\t}\n\t\t});\n\n\t\t// Fill object.array fields\n\t\tawait page.fill('input[name=\"object.array[0]\"]', 'array-item-1');\n\t\tconst afterArrayItem1 = await page.locator('#full-value').textContent();\n\t\texpect(JSON.parse(afterArrayItem1)).toEqual({\n\t\t\tleaf: 'leaf-value',\n\t\t\tobject: {\n\t\t\t\tleaf: 'object-leaf-value',\n\t\t\t\tarray: ['array-item-1']\n\t\t\t}\n\t\t});\n\n\t\tawait page.fill('input[name=\"object.array[1]\"]', 'array-item-2');\n\t\tconst afterArrayItem2 = await page.locator('#full-value').textContent();\n\t\texpect(JSON.parse(afterArrayItem2)).toEqual({\n\t\t\tleaf: 'leaf-value',\n\t\t\tobject: {\n\t\t\t\tleaf: 'object-leaf-value',\n\t\t\t\tarray: ['array-item-1', 'array-item-2']\n\t\t\t}\n\t\t});\n\n\t\t// Fill array[0].leaf field\n\t\tawait page.fill('input[name=\"array[0].leaf\"]', 'array-0-leaf');\n\t\tconst afterArray0 = await page.locator('#full-value').textContent();\n\t\texpect(JSON.parse(afterArray0)).toEqual({\n\t\t\tleaf: 'leaf-value',\n\t\t\tobject: {\n\t\t\t\tleaf: 'object-leaf-value',\n\t\t\t\tarray: ['array-item-1', 'array-item-2']\n\t\t\t},\n\t\t\tarray: [{ leaf: 'array-0-leaf' }]\n\t\t});\n\n\t\t// Fill array[1].leaf field\n\t\tawait page.fill('input[name=\"array[1].leaf\"]', 'array-1-leaf');\n\t\tconst afterArray1 = await page.locator('#full-value').textContent();\n\t\texpect(JSON.parse(afterArray1)).toEqual({\n\t\t\tleaf: 'leaf-value',\n\t\t\tobject: {\n\t\t\t\tleaf: 'object-leaf-value',\n\t\t\t\tarray: ['array-item-1', 'array-item-2']\n\t\t\t},\n\t\t\tarray: [{ leaf: 'array-0-leaf' }, { leaf: 'array-1-leaf' }]\n\t\t});\n\n\t\t// Test nested object value access\n\t\tconst objectValue = await page.locator('#object-value').textContent();\n\t\texpect(JSON.parse(objectValue)).toEqual({\n\t\t\tleaf: 'object-leaf-value',\n\t\t\tarray: ['array-item-1', 'array-item-2']\n\t\t});\n\n\t\t// Test array value access\n\t\tconst arrayValue = await page.locator('#array-value').textContent();\n\t\texpect(JSON.parse(arrayValue)).toEqual([{ leaf: 'array-0-leaf' }, { leaf: 'array-1-leaf' }]);\n\t});\n\n\ttest('nested field set is SSR rendered', async ({ page }) => {\n\t\tawait page.goto('/remote/form/set-ssr');\n\t\tawait expect(page.locator('#description')).toHaveText('Description: nested');\n\t});\n\n\ttest('selects are not nuked when unrelated controls change', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tif (!javaScriptEnabled) return;\n\n\t\tawait page.goto('/remote/form/select-untouched');\n\n\t\tawait page.fill('input', 'hello');\n\t\tawait expect(page.locator('select')).toHaveValue('one');\n\t});\n\ttest('file uploads work', async ({ page }) => {\n\t\tawait page.goto('/remote/form/file-upload');\n\n\t\tawait page.locator('input[name=\"file1\"]').setInputFiles({\n\t\t\tname: 'a.txt',\n\t\t\tmimeType: 'text/plain',\n\t\t\tbuffer: Buffer.from('a')\n\t\t});\n\t\tawait page.locator('input[name=\"file2\"]').setInputFiles({\n\t\t\tname: 'b.txt',\n\t\t\tmimeType: 'text/plain',\n\t\t\tbuffer: Buffer.from('b')\n\t\t});\n\t\tawait page.locator('input[type=\"checkbox\"]').check();\n\t\tawait page.locator('button').click();\n\n\t\tawait expect(page.locator('pre')).toHaveText(\n\t\t\tJSON.stringify({\n\t\t\t\ttext: 'Hello world',\n\t\t\t\tfile1: 'a',\n\t\t\t\tfile2: 'b'\n\t\t\t})\n\t\t);\n\t});\n\ttest('large file uploads work', async ({ page }) => {\n\t\tawait page.goto('/remote/form/file-upload');\n\n\t\tawait page.locator('input[name=\"file1\"]').setInputFiles({\n\t\t\tname: 'a.txt',\n\t\t\tmimeType: 'text/plain',\n\t\t\tbuffer: Buffer.alloc(1024 * 1024 * 10)\n\t\t});\n\t\tawait page.locator('input[name=\"file2\"]').setInputFiles({\n\t\t\tname: 'b.txt',\n\t\t\tmimeType: 'text/plain',\n\t\t\tbuffer: Buffer.from('b')\n\t\t});\n\t\tawait page.locator('button').click();\n\n\t\tawait expect(page.locator('pre')).toHaveText(\n\t\t\tJSON.stringify({\n\t\t\t\ttext: 'Hello world',\n\t\t\t\tfile1: 1024 * 1024 * 10,\n\t\t\t\tfile2: 1\n\t\t\t})\n\t\t);\n\t});\n\n\ttest('query stored as variable does not block SSR inside boundary', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tawait page.goto('/remote/query-boundary');\n\n\t\tawait expect(page.locator('#delayed-pending')).toHaveText('loading delayed');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait expect(page.locator('#delayed-result')).toHaveText('delayed data', {\n\t\t\t\ttimeout: 5000\n\t\t\t});\n\t\t}\n\t});\n});\n\ntest.describe('server error boundaries', () => {\n\ttest('catches server render error and shows root +error.svelte', async ({ page }) => {\n\t\tawait page.goto('/server-error-boundary');\n\t\tawait expect(page.locator('#message')).toContainText(\n\t\t\t'render error (500 Internal Error, on /server-error-boundary)'\n\t\t);\n\t});\n\n\ttest('catches nested server render error and shows nested +error.svelte', async ({ page }) => {\n\t\tawait page.goto('/server-error-boundary/nested');\n\t\tawait expect(page.locator('#nested-error-message')).toContainText(\n\t\t\t'nested render error (500 Internal Error, on /server-error-boundary/nested) | true | 500'\n\t\t);\n\t\t// The nested layout should still be visible\n\t\tawait expect(page.locator('#nested-layout')).toBeVisible();\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/async/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"noEmit\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t// TODO: remove when we start SvelteKit 3.0\n\t\t// concession change for vite5, importing a .remote.ts as .remote.js doesn't\n\t\t// work on node 18, allowing .ts import and changing the imported suffix works.\n\t\t\"allowImportingTsExtensions\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/async/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tclearScreen: false,\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/.gitignore",
    "content": "/test/errors.json\n!/.env\n/src/routes/routing/symlink-from\n/test/spans.jsonl"
  },
  {
    "path": "packages/kit/test/apps/basics/package.json",
    "content": "{\n\t\"name\": \"test-basics\",\n\t\"private\": true,\n\t\"version\": \"0.0.2-next.0\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"pnpm test:unit && pnpm test:dev && pnpm test:build\",\n\t\t\"test:dev\": \"node test/setup.js && DEV=true playwright test\",\n\t\t\"test:build\": \"node test/setup.js && PUBLIC_PRERENDERING=false playwright test\",\n\t\t\"test:cross-platform:dev\": \"node test/setup.js && DEV=true playwright test test/cross-platform/\",\n\t\t\"test:cross-platform:build\": \"node test/setup.js && playwright test test/cross-platform/\",\n\t\t\"test:server-side-route-resolution:dev\": \"node test/setup.js && DEV=true ROUTER_RESOLUTION=server playwright test\",\n\t\t\"test:server-side-route-resolution:build\": \"node test/setup.js && PUBLIC_PRERENDERING=false ROUTER_RESOLUTION=server playwright test\",\n\t\t\"test:svelte-async:dev\": \"node test/setup.js && DEV=true SVELTE_ASYNC=true playwright test\",\n\t\t\"test:svelte-async:build\": \"node test/setup.js && PUBLIC_PRERENDERING=false SVELTE_ASYNC=true playwright test\",\n\t\t\"test:unit\": \"vitest run\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@opentelemetry/api\": \"^1.9.0\",\n\t\t\"@opentelemetry/sdk-node\": \"catalog:\",\n\t\t\"@opentelemetry/sdk-trace-node\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"@vitest/browser-playwright\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"test-redirect-importer\": \"workspace:*\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"valibot\": \"catalog:\",\n\t\t\"vite\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/playwright.config.js",
    "content": "import process from 'node:process';\nimport { config } from '../../utils.js';\nimport { defineConfig } from '@playwright/test';\n\nexport default defineConfig({\n\t...config,\n\twebServer: {\n\t\tcommand: process.env.DEV ? `pnpm dev` : `pnpm build && pnpm preview`,\n\t\tport: process.env.DEV ? 5173 : 4173,\n\t\tenv: {\n\t\t\tPUBLIC_PRERENDERING: 'false',\n\t\t\tROUTER_RESOLUTION: process.env.ROUTER_RESOLUTION ?? 'client'\n\t\t}\n\t}\n});\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/app.d.ts",
    "content": "declare global {\n\tnamespace App {\n\t\tinterface Locals {\n\t\t\tanswer: number;\n\t\t\tname?: string;\n\t\t\tkey: string;\n\t\t\tparams: Record<string, string>;\n\t\t\turl?: URL;\n\t\t\tmessage?: string;\n\t\t}\n\n\t\tinterface PageState {\n\t\t\tactive?: boolean;\n\t\t\tcount?: number;\n\t\t}\n\t}\n}\n\nexport {};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<link rel=\"icon\" type=\"image/png\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"transform-page\" content=\"__REPLACEME__\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body class=\"%sveltekit.env.PUBLIC_THEME%\">\n\t\t<div>%sveltekit.body%</div>\n\t\t<a href=\"/routing/link-outside-app-target/target\">outside app target</a>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/error.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<title>Error</title>\n\t</head>\n\t<body>\n\t\t<h1>Error - %sveltekit.status%</h1>\n\t\t<p>This is the static error page with the following message: %sveltekit.error.message%</p>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/global.d.ts",
    "content": "declare global {\n\tinterface Window {\n\t\tinvalidated: boolean;\n\t\toops: string;\n\t\tpageContext: any;\n\t\tmounted: number;\n\t\tfulfil_navigation: (value: any) => void;\n\t\tpromise: Promise<any>;\n\t\tPUBLIC_DYNAMIC: string;\n\t}\n}\n\nexport {};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/hooks.client.js",
    "content": "import { env } from '$env/dynamic/public';\n\nwindow.PUBLIC_DYNAMIC = env.PUBLIC_DYNAMIC;\n\n/** @type{import(\"@sveltejs/kit\").HandleClientError} */\nexport function handleError({ error, event, status, message }) {\n\treturn event.url.pathname.endsWith('404-fallback')\n\t\t? undefined\n\t\t: { message: `${/** @type {Error} */ (error).message} (${status} ${message})` };\n}\n\nexport function init() {\n\tconsole.log('init hooks.client.js');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/hooks.js",
    "content": "import { browser } from '$app/environment';\nimport { Foo } from './lib';\n\nconst mapping = {\n\t'/reroute/basic/a': '/reroute/basic/b',\n\t'/reroute/client-only-redirect/a': '/reroute/client-only-redirect/b',\n\t'/reroute/preload-data/a': '/reroute/preload-data/b',\n\t'/reroute/invalidate/a': '/reroute/invalidate'\n};\n\n/** @type {import(\"@sveltejs/kit\").Reroute} */\nexport const reroute = ({ url, fetch }) => {\n\t//Try to rewrite the external url used in /reroute/external to the homepage - This should not work\n\tif (browser && url.href.startsWith('https://expired.badssl.com')) {\n\t\treturn '/';\n\t}\n\n\tif (url.pathname === '/reroute/error-handling/client-error') {\n\t\tif (browser) {\n\t\t\tthrow new Error('Client Error');\n\t\t} else {\n\t\t\treturn '/reroute/error-handling/client-error-rewritten';\n\t\t}\n\t}\n\n\tif (url.pathname === '/reroute/error-handling/server-error') {\n\t\tthrow new Error('Server Error - Should trigger 500 response');\n\t}\n\n\tif (url.pathname === '/reroute/async/a') {\n\t\treturn fetch('/reroute/api').then((r) => r.text());\n\t}\n\n\tif (url.pathname === '/reroute/async/c') {\n\t\treturn fetch('/reroute/api/prerendered').then((r) => r.text());\n\t}\n\n\tif (url.pathname === '/reroute/prerendered/to-destination') {\n\t\treturn '/reroute/prerendered/destination';\n\t}\n\n\tif (url.pathname in mapping) {\n\t\treturn mapping[url.pathname];\n\t}\n};\n\n/** @type {import(\"@sveltejs/kit\").Transport} */\nexport const transport = {\n\tFoo: {\n\t\tencode: (value) => value instanceof Foo && [value.message],\n\t\tdecode: ([message]) => new Foo(message)\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/hooks.server.js",
    "content": "import { building, dev } from '$app/environment';\nimport { error, isHttpError, redirect } from '@sveltejs/kit';\nimport { sequence } from '@sveltejs/kit/hooks';\nimport fs from 'node:fs';\nimport { COOKIE_NAME } from './routes/cookies/shared';\nimport { _set_from_init } from './routes/init-hooks/+page.server';\nimport { getRequestEvent } from '$app/server';\nimport { resolve } from '$app/paths';\n\n// @ts-ignore this doesn't exist in old Node\nPromise.withResolvers ??= () => {\n\tconst d = {};\n\td.promise = new Promise((resolve, reject) => {\n\t\td.resolve = resolve;\n\t\td.reject = reject;\n\t});\n\treturn d;\n};\n\n// check that this doesn't throw when called outside an event context\nresolve('/');\n\n/**\n * Transform an error into a POJO, by copying its `name`, `message`\n * and (in dev) `stack`, plus any custom properties, plus recursively\n * serialized `cause` properties.\n *\n * @param {Error} error\n */\nexport function error_to_pojo(error) {\n\tif (isHttpError(error)) {\n\t\treturn {\n\t\t\tstatus: error.status,\n\t\t\t...error.body\n\t\t};\n\t}\n\n\tconst { name, message, stack, ...custom } = error;\n\treturn { name, message, stack, ...custom };\n}\n\n/** @type {import('@sveltejs/kit').HandleServerError} */\nexport const handleError = ({ event, error: e, status, message }) => {\n\tconst error = /** @type {Error} */ (e);\n\t// TODO we do this because there's no other way (that i'm aware of)\n\t// to communicate errors back to the test suite. even if we could\n\t// capture stderr, attributing an error to a specific request\n\t// is trickier when things run concurrently\n\tconst errors = fs.existsSync('test/errors.json')\n\t\t? JSON.parse(fs.readFileSync('test/errors.json', 'utf8'))\n\t\t: {};\n\terrors[event.url.pathname] = error_to_pojo(error);\n\tfs.writeFileSync('test/errors.json', JSON.stringify(errors));\n\n\tif (event.url.pathname.startsWith('/get-request-event/')) {\n\t\tconst ev = getRequestEvent();\n\t\tmessage = ev.locals.message;\n\t}\n\n\treturn event.url.pathname.endsWith('404-fallback')\n\t\t? undefined\n\t\t: { message: `${error.message} (${status} ${message})` };\n};\n\nexport const handle = sequence(\n\t// eslint-disable-next-line prefer-arrow-callback -- this needs a name for tests\n\tfunction set_tracing_test_id({ event, resolve }) {\n\t\tconst test_id = !building && event.url.searchParams.get('test_id');\n\t\tif (test_id) {\n\t\t\tevent.tracing.root.setAttribute('test_id', test_id);\n\t\t}\n\t\treturn resolve(event);\n\t},\n\t({ event, resolve }) => {\n\t\tevent.locals.key = event.route.id;\n\t\tevent.locals.params = event.params;\n\t\tevent.locals.answer = 42;\n\t\treturn resolve(event);\n\t},\n\t({ event, resolve }) => {\n\t\tif (\n\t\t\tevent.request.url.includes('__data.json') &&\n\t\t\t(event.url.pathname.endsWith('__data.json') || !event.isDataRequest)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t'__data.json requests should have the suffix stripped from the URL and isDataRequest set to true'\n\t\t\t);\n\t\t}\n\t\treturn resolve(event);\n\t},\n\t({ event, resolve }) => {\n\t\tif (\n\t\t\tevent.request.headers.has('host') &&\n\t\t\t!event.request.headers.has('user-agent') !== event.isSubRequest\n\t\t) {\n\t\t\tthrow new Error('SSR API sub-requests should have isSubRequest set to true');\n\t\t}\n\t\treturn resolve(event);\n\t},\n\t({ event, resolve }) => {\n\t\tif (event.url.pathname.includes('fetch-credentialed')) {\n\t\t\t// Only get the cookie at the test where we know it's set to avoid polluting our logs with (correct) warnings\n\t\t\tevent.locals.name = /** @type {string} */ (event.cookies.get('name'));\n\t\t}\n\t\treturn resolve(event);\n\t},\n\tasync ({ event, resolve }) => {\n\t\tif (event.url.pathname === '/cookies/serialize') {\n\t\t\tevent.cookies.set('before', 'before', { path: '' });\n\t\t\tconst response = await resolve(event);\n\t\t\tresponse.headers.append(\n\t\t\t\t'set-cookie',\n\t\t\t\tevent.cookies.serialize('after', 'after', { path: '' })\n\t\t\t);\n\t\t\treturn response;\n\t\t}\n\t\treturn resolve(event);\n\t},\n\tasync ({ event, resolve }) => {\n\t\tif (event.url.pathname === '/errors/error-in-handle') {\n\t\t\tthrow new Error('Error in handle');\n\t\t} else if (event.url.pathname === '/errors/expected-error-in-handle') {\n\t\t\terror(500, 'Expected error in handle');\n\t\t}\n\n\t\tconst response = await resolve(event, {\n\t\t\ttransformPageChunk: event.url.pathname.startsWith('/transform-page-chunk')\n\t\t\t\t? ({ html }) => html.replace('__REPLACEME__', 'Worked!')\n\t\t\t\t: undefined\n\t\t});\n\n\t\ttry {\n\t\t\t// in some tests we fetch stuff with undici, and the headers are immutable.\n\t\t\t// we can safely ignore it in those cases\n\t\t\tresponse.headers.append('set-cookie', 'name=SvelteKit; path=/; HttpOnly');\n\t\t} catch {}\n\n\t\treturn response;\n\t},\n\tasync ({ event, resolve }) => {\n\t\tif (event.url.pathname.includes('/redirect/in-handle')) {\n\t\t\tif (event.url.search === '?throw') {\n\t\t\t\tredirect(307, event.url.origin + '/redirect/c');\n\t\t\t} else if (event.url.search.includes('cookies')) {\n\t\t\t\tevent.cookies.delete(COOKIE_NAME, { path: '/cookies' });\n\t\t\t\tredirect(307, event.url.origin + '/cookies');\n\t\t\t} else {\n\t\t\t\treturn new Response(undefined, { status: 307, headers: { location: '/redirect/c' } });\n\t\t\t}\n\t\t}\n\n\t\treturn resolve(event);\n\t},\n\tasync ({ event, resolve }) => {\n\t\tif (event.url.pathname === '/prerendering/prerendered-endpoint/from-handle-hook') {\n\t\t\treturn event.fetch('/prerendering/prerendered-endpoint/api');\n\t\t}\n\n\t\treturn resolve(event);\n\t},\n\tasync ({ event, resolve }) => {\n\t\tif (event.url.pathname === '/actions/redirect-in-handle' && event.request.method === 'POST') {\n\t\t\tredirect(303, '/actions/enhance');\n\t\t}\n\n\t\treturn resolve(event);\n\t},\n\tasync ({ event, resolve }) => {\n\t\tif (!dev && !building && event.url.pathname === '/prerendering/prerendered-endpoint/api') {\n\t\t\terror(\n\t\t\t\t500,\n\t\t\t\t`Server hooks should not be called for prerendered endpoints: isSubRequest=${event.isSubRequest}`\n\t\t\t);\n\t\t}\n\t\treturn resolve(event);\n\t},\n\tasync ({ event, resolve }) => {\n\t\tif (['/non-existent-route', '/non-existent-route-loop'].includes(event.url.pathname)) {\n\t\t\tevent.locals.url = new URL(event.request.url);\n\t\t}\n\t\treturn resolve(event);\n\t},\n\tasync ({ event, resolve }) => {\n\t\tif (event.url.pathname.startsWith('/get-request-event/')) {\n\t\t\tconst e = getRequestEvent();\n\n\t\t\tif (event !== e) {\n\t\t\t\tthrow new Error('event !== e');\n\t\t\t}\n\n\t\t\te.locals.message = 'hello from hooks.server.js';\n\t\t}\n\n\t\treturn resolve(event, {\n\t\t\t// needed for asset-preload tests\n\t\t\tpreload: () => true\n\t\t});\n\t}\n);\n\n/** @type {import('@sveltejs/kit').HandleFetch} */\nexport async function handleFetch({ request, fetch }) {\n\tif (request.url.endsWith('/server-fetch-request.json')) {\n\t\trequest = new Request(\n\t\t\trequest.url.replace('/server-fetch-request.json', '/server-fetch-request-modified.json'),\n\t\t\trequest\n\t\t);\n\t}\n\n\treturn fetch(request);\n}\n\nexport function init() {\n\t_set_from_init();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/instrumentation.server.js",
    "content": "/** @import {SpanExporter} from '@opentelemetry/sdk-trace-node' */\n/** @import {SpanData} from '../../../types' */\nimport { NodeSDK } from '@opentelemetry/sdk-node';\nimport { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';\nimport fs from 'node:fs';\n\n/** @implements {SpanExporter} */\nclass FilesystemSpanExporter {\n\t#path;\n\n\tconstructor(path) {\n\t\tfs.rmSync(path, { force: true });\n\t\tthis.#path = path;\n\t}\n\n\t/** @param {import('@opentelemetry/sdk-trace-node').ReadableSpan[]} spans */\n\texport(spans) {\n\t\t// spans have circular references so they can't be naively json-ified\n\t\tconst serialized_spans = spans.map((span) => {\n\t\t\tconst span_context = span.spanContext();\n\t\t\t/** @type {SpanData} */\n\t\t\tconst span_data = {\n\t\t\t\tname: span.name,\n\t\t\t\tstatus: span.status,\n\t\t\t\tstart_time: span.startTime,\n\t\t\t\tend_time: span.endTime,\n\t\t\t\tattributes: span.attributes,\n\t\t\t\tlinks: span.links,\n\t\t\t\ttrace_id: span_context.traceId,\n\t\t\t\tspan_id: span_context.spanId,\n\t\t\t\tparent_span_id: span.parentSpanContext?.spanId\n\t\t\t};\n\t\t\treturn JSON.stringify(span_data);\n\t\t});\n\n\t\tfs.appendFileSync(this.#path, serialized_spans.join('\\n') + '\\n');\n\t}\n\tshutdown() {\n\t\treturn Promise.resolve();\n\t}\n}\n\nconst filesystemSpanExporter = new FilesystemSpanExporter('test/spans.jsonl');\nconst spanProcessor = new SimpleSpanProcessor(filesystemSpanExporter);\nexport const sdk = new NodeSDK({\n\tspanProcessor\n});\nsdk.start();\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/lib/index.js",
    "content": "export class Foo {\n\tconstructor(message) {\n\t\tthis.message = message;\n\t}\n\n\tbar() {\n\t\treturn this.message + '!';\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/params/lowercase.js",
    "content": "export function match(param) {\n\treturn /^[a-z]+$/.test(param);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/params/numeric.js",
    "content": "export function match(param) {\n\treturn !isNaN(parseInt(param));\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/params/uppercase.js",
    "content": "export function match(param) {\n\treturn /^[A-Z]+$/.test(param);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<svelte:head>\n\t<title>Custom error page: {page.error.message}</title>\n</svelte:head>\n\n<h1>{page.status}</h1>\n\n<p id=\"message\">This is your custom error page saying: \"<b>{page.error.message}</b>\"</p>\n\n<style>\n\th1,\n\tp {\n\t\tmargin: 0 auto;\n\t}\n\n\th1 {\n\t\tfont-size: 2.8em;\n\t\tfont-weight: 700;\n\t\tmargin: 0 0 0.5em 0;\n\t\tcolor: red;\n\t}\n\n\tp {\n\t\tmargin: 1em auto;\n\t}\n\n\t@media (min-width: 480px) {\n\t\th1 {\n\t\t\tfont-size: 4em;\n\t\t}\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/+layout.js",
    "content": "/** @type {import('./$types').LayoutLoad} */\nexport async function load() {\n\t// Do NOT make this load function depend on something which would cause it to rerun\n\treturn {\n\t\tfoo: {\n\t\t\tbar: 'Custom layout'\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/+layout.server.js",
    "content": "import { error, redirect } from '@sveltejs/kit';\nimport { SOME_JSON } from '$env/static/private';\n\n// https://github.com/sveltejs/kit/issues/8646\nif (JSON.parse(SOME_JSON).answer !== 42) {\n\tthrow new Error('failed to parse env var');\n}\n\n/** @type {import('./$types').LayoutServerLoad} */\nexport async function load({ cookies, locals, fetch }) {\n\tif (locals.url?.pathname === '/non-existent-route') {\n\t\tawait fetch('/prerendering/prerendered-endpoint/api').then((r) => r.json());\n\t}\n\n\tif (locals.url?.pathname === '/non-existent-route-loop') {\n\t\tawait fetch('/non-existent-route-loop');\n\t}\n\n\tconst should_fail = cookies.get('fail-type');\n\tif (should_fail) {\n\t\tcookies.delete('fail-type', { path: '/' });\n\t\tif (should_fail === 'expected') {\n\t\t\terror(401, 'Not allowed');\n\t\t} else if (should_fail === 'unexpected') {\n\t\t\tthrow new Error('Failed to load');\n\t\t} else {\n\t\t\tredirect(307, '/load');\n\t\t}\n\t}\n\t// Do NOT make this load function depend on something which would cause it to rerun\n\treturn {\n\t\trootlayout: 'rootlayout'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/+layout.svelte",
    "content": "<script lang=\"ts\">\n\timport { setup } from '../../../../setup.js';\n\n\t/** @type {import('./$types').LayoutData} */\n\texport let data;\n\n\tsetup();\n</script>\n\n<slot />\n\n<footer>{data.foo.bar}</footer>\n\n<style>\n\tfooter {\n\t\tcolor: purple;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load}*/\nexport async function load({ fetch }) {\n\tconst res = await fetch('/answer.json');\n\tconst { answer } = await res.json();\n\treturn { answer };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/+page.svelte",
    "content": "<script>\n\timport './index.css';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>the answer is {data.answer}</h1>\n\n<a href=\"/routing/trailing-slash/never/\"\n\t>URL with trailing slash that should redirect to remove it</a\n>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/accessibility/+layout.svelte",
    "content": "<button>focus me</button>\n\n<nav>\n\t<a href=\"/accessibility/a\">a</a>\n\t<a href=\"/accessibility/b\">b</a>\n\t<a href=\"/accessibility/autofocus/a\">autofocus/a</a>\n\t<a href=\"/accessibility/autofocus/b\">autofocus/b</a>\n</nav>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/accessibility/a/+page.svelte",
    "content": "<svelte:head>\n\t<title>a</title>\n</svelte:head>\n\n<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/accessibility/autofocus/+layout.svelte",
    "content": "<slot />\n\n<!-- svelte-ignore a11y-autofocus -->\n<input autofocus />\n\n<a href=\"/\">Home</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/accessibility/autofocus/a/+page.svelte",
    "content": "<svelte:head>\n\t<title>a</title>\n</svelte:head>\n\n<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/accessibility/autofocus/b/+page.server.js",
    "content": "export const actions = {\n\tdefault() {}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/accessibility/autofocus/b/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n</script>\n\n<svelte:head>\n\t<title>b</title>\n</svelte:head>\n\n<h1>b</h1>\n\n<form method=\"POST\" use:enhance>\n\t<button id=\"submit\">submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/accessibility/b/+page.svelte",
    "content": "<svelte:head>\n\t<title>b</title>\n</svelte:head>\n\n<h1>b</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/accessibility/c/+page.server.js",
    "content": "export const actions = {\n\tdefault() {}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/accessibility/c/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n</script>\n\n<svelte:head>\n\t<title>c</title>\n</svelte:head>\n\n<h1>c</h1>\n\n<form method=\"POST\" use:enhance>\n\t<button id=\"submit\">submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/enhance/+page.server.js",
    "content": "import { error } from '@sveltejs/kit';\n\n/** @type {import('./$types').PageServerLoad} */\nexport function load({ cookies }) {\n\tconst enhance_counter = +(cookies.get('enhance-counter') ?? 0);\n\n\treturn {\n\t\tinitial: 'initial',\n\t\tenhance_counter\n\t};\n}\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tlogin: async ({ request }) => {\n\t\tconst fields = await request.formData();\n\t\treturn {\n\t\t\tresult: fields.get('username')\n\t\t};\n\t},\n\tregister: async ({ request }) => {\n\t\tconst fields = await request.formData();\n\t\treturn {\n\t\t\tresult: 'register: ' + fields.get('username')\n\t\t};\n\t},\n\tslow: async () => {\n\t\tawait new Promise((resolve) => setTimeout(resolve, 500));\n\t},\n\tsubmitter: async ({ request }) => {\n\t\tconst fields = await request.formData();\n\t\treturn {\n\t\t\tresult: 'submitter: ' + fields.get('submitter')\n\t\t};\n\t},\n\terror: () => {\n\t\terror(400, 'error');\n\t},\n\techo: async ({ request }) => {\n\t\tconst data = await request.formData();\n\n\t\treturn {\n\t\t\tmessage: data.get('message')\n\t\t};\n\t},\n\tcounter: async ({ cookies }) => {\n\t\tlet count = +(cookies.get('enhance-counter') ?? 0);\n\n\t\tcount += 1;\n\n\t\tcookies.set('enhance-counter', count + '', {\n\t\t\tpath: '/actions/enhance'\n\t\t});\n\n\t\treturn {};\n\t},\n\tsend_file: async ({ request }) => {\n\t\tconst data = await request.formData();\n\t\tconst file = data.get('file');\n\n\t\tif (file instanceof File) {\n\t\t\treturn {\n\t\t\t\tresult: 'file name:' + file.name\n\t\t\t};\n\t\t}\n\t\treturn {};\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/enhance/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n\timport { page } from '$app/state';\n\n\t/** @type {import('./$types').ActionData} */\n\texport let form;\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n\n\t/** @type {AbortController | undefined} */\n\tlet previous;\n\tlet count = 0;\n</script>\n\n<pre class=\"data1\">prop: {data.enhance_counter}, state: {page.data.enhance_counter}</pre>\n\n<pre class=\"formdata1\">{JSON.stringify(form)}</pre>\n<pre class=\"formdata2\">{JSON.stringify(page.form)}</pre>\n\n<form method=\"post\" action=\"?/login\" use:enhance>\n\t<input type=\"hidden\" name=\"action\" value=\"DOM clobbering\" />\n\t<input type=\"hidden\" name=\"reset\" value=\"DOM clobbering\" />\n\t<input name=\"username\" type=\"text\" />\n\t<button class=\"form1\">Submit</button>\n\t<button class=\"form1-register\" formAction=\"?/register\">Submit</button>\n\t<button class=\"form1-submitter\" formAction=\"?/submitter\" name=\"submitter\" value=\"foo\">\n\t\tSubmit\n\t</button>\n\t<button class=\"form1-error\" formAction=\"?/error\">Submit</button>\n</form>\n\n<span class=\"count\">{count}</span>\n<form\n\tmethod=\"post\"\n\taction=\"?/slow\"\n\tuse:enhance={({ controller }) => {\n\t\tprevious?.abort();\n\t\tprevious = controller;\n\t\treturn () => {\n\t\t\tcount++;\n\t\t};\n\t}}\n>\n\t<button class=\"form2\">Submit</button>\n</form>\n\n<form method=\"post\" action=\"?/echo\" use:enhance>\n\t<input name=\"message\" type=\"text\" value={form?.message ?? ''} />\n\t<button class=\"form3\">Submit</button>\n</form>\n\n<form action=\"?/counter\" method=\"post\" use:enhance>\n\t<button class=\"form4\">Submit</button>\n</form>\n\n<dialog id=\"dialog\" open>\n\t<form action=\"?/echo\" method=\"post\" use:enhance>\n\t\t<button formmethod=\"dialog\">Cancel</button>\n\t</form>\n</dialog>\n\n<form action=\"?/send_file\" method=\"post\" use:enhance>\n\t<input type=\"file\" name=\"file\" class=\"form-file-input\" />\n\n\t<button class=\"form-file-submit\" formenctype=\"multipart/form-data\" type=\"submit\">Submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/file-without-enctype/+page.server.js",
    "content": "export const actions = {\n\tdefault: async ({ request }) => {\n\t\tconst data = await request.formData();\n\t\tconsole.log(data.get('file'));\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/file-without-enctype/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n</script>\n\n<form method=\"POST\" use:enhance>\n\t<input name=\"file\" type=\"file\" />\n\t<button type=\"submit\">upload</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/form-errors/+page.server.js",
    "content": "import { fail } from '@sveltejs/kit';\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: async () => {\n\t\treturn fail(400, { errors: { message: 'an error occurred' } });\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/form-errors/+page.svelte",
    "content": "<script>\n\timport { browser } from '$app/environment';\n\n\t/** @type {import('./$types').ActionData} */\n\texport let form;\n\n\tconst hydrated_error_message = browser ? 'hydrated: ' + form?.errors?.message : '';\n</script>\n\n<form method=\"post\">\n\t<button type=\"submit\">Submit</button>\n</form>\n\n<p class=\"server-prop\">{form?.errors?.message}</p>\n\n<!-- needs to be like this else the selector is found too soon (before hydration) -->\n{#if hydrated_error_message}\n\t<p class=\"client-prop\">{hydrated_error_message}</p>\n{/if}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/form-errors/adjacent-error-boundary/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<pre style:color=\"red\">{page.error?.message}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/form-errors/adjacent-error-boundary/+page.server.js",
    "content": "import { error } from '@sveltejs/kit';\n\nexport const actions = {\n\tdefault: async () => {\n\t\terror(502, 'something went wrong');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/form-errors/adjacent-error-boundary/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n</script>\n\n<form method=\"POST\" use:enhance>\n\t<button type=\"submit\">submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/form-errors-persist-fields/+page.server.js",
    "content": "import { fail } from '@sveltejs/kit';\n\n/**\n * @type {import('./$types').Actions}\n */\nexport const actions = {\n\tdefault: async ({ request }) => {\n\t\tconst fields = await request.formData();\n\t\tfields.delete('password');\n\t\treturn fail(400, {\n\t\t\tvalues: Object.fromEntries(fields),\n\t\t\terrors: {\n\t\t\t\tmessage: 'invalid credentials'\n\t\t\t}\n\t\t});\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/form-errors-persist-fields/+page.svelte",
    "content": "<script>\n\timport { deserialize } from '$app/forms';\n\timport { browser } from '$app/environment';\n\n\t/** @type {import('./$types').ActionData} */\n\texport let form;\n\n\t$: hydrated_form_values = browser ? form?.values : '';\n\n\tasync function submit() {\n\t\tconst res = await fetch(this.action, {\n\t\t\tmethod: 'POST',\n\t\t\tbody: new FormData(this),\n\t\t\theaders: {\n\t\t\t\taccept: 'application/json'\n\t\t\t}\n\t\t});\n\t\t// @ts-expect-error don't bother with type narrowing work here\n\t\tconst { data } = deserialize(await res.text());\n\t\tform = data;\n\t}\n</script>\n\n<form method=\"post\" on:submit|preventDefault={submit}>\n\t<input type=\"text\" name=\"username\" value={form?.values?.username ?? ''} />\n\t<input type=\"password\" name=\"password\" />\n\t<button type=\"submit\">Submit</button>\n</form>\n\n<!-- needs to be like this else the selector is found too soon (before hydration) -->\n{#if hydrated_form_values}\n\t<pre class=\"client\">{JSON.stringify(hydrated_form_values)}</pre>\n{/if}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/invalidate-all/+layout.js",
    "content": "export function load() {\n\treturn {\n\t\tchanges_every_load: new Date()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/invalidate-all/+page.server.js",
    "content": "export function load({ url }) {\n\tconst invalidate_all = url.searchParams.get('invalidate_all') === 'true';\n\treturn {\n\t\tinvalidate_all\n\t};\n}\n\nexport const actions = {\n\tdefault: () => {}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/invalidate-all/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n\n\texport let data;\n\n\t/**\n\t * @param {HTMLFormElement} node\n\t */\n\tfunction enhanceWrapper(node) {\n\t\treturn enhance(\n\t\t\tnode,\n\t\t\t() =>\n\t\t\t\t({ update }) =>\n\t\t\t\t\tupdate({ invalidateAll: data.invalidate_all })\n\t\t);\n\t}\n</script>\n\n<form method=\"POST\" use:enhanceWrapper>\n\t<pre>{data.changes_every_load.toISOString()}</pre>\n\t<button type=\"submit\">invalidate</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/redirect/+page.server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('./$types').PageServerLoad} */\nexport function load() {\n\treturn {\n\t\tinitial: 'initial'\n\t};\n}\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: async () => {\n\t\tredirect(303, '/actions/enhance');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/redirect/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n</script>\n\n<form method=\"post\" use:enhance>\n\t<button>Submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/redirect-in-handle/+page.server.js",
    "content": "/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: async () => {\n\t\tthrow new Error('should never get here');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/redirect-in-handle/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n</script>\n\n<form method=\"post\" use:enhance>\n\t<button>Submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/success-data/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load() {\n\treturn {\n\t\tinitial: 'initial'\n\t};\n}\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: async ({ request }) => {\n\t\tconst fields = await request.formData();\n\t\treturn {\n\t\t\tresult: fields.get('username')\n\t\t};\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/success-data/+page.svelte",
    "content": "<script>\n\timport { deserialize } from '$app/forms';\n\n\t/** @type {import('./$types').ActionData} */\n\texport let form;\n\n\tasync function submit({ submitter }) {\n\t\tconst res = await fetch(this.action, {\n\t\t\tmethod: 'POST',\n\t\t\tbody:\n\t\t\t\tsubmitter.getAttribute('formenctype') === 'multipart/form-data'\n\t\t\t\t\t? new FormData(this)\n\t\t\t\t\t: new URLSearchParams({ username: this['username'].value }),\n\t\t\theaders: {\n\t\t\t\taccept: 'application/json'\n\t\t\t}\n\t\t});\n\t\t// @ts-expect-error don't bother with type narrowing work here\n\t\tconst { data } = deserialize(await res.text());\n\t\tform = data;\n\t}\n</script>\n\n<pre>{JSON.stringify(form)}</pre>\n\n<form method=\"post\" on:submit|preventDefault={submit}>\n\t<input name=\"username\" type=\"text\" />\n\t<button formenctype=\"multipart/form-data\">Submit</button>\n\t<button formenctype=\"application/x-www-form-urlencoded\">Submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/actions/update-form/+page.svelte",
    "content": "<script>\n\timport { applyAction } from '$app/forms';\n\timport { invalidateAll } from '$app/navigation';\n\n\texport let form;\n\tlet count = 0;\n\n\t/** @param {'success' | 'failure'} type */\n\tfunction update(type) {\n\t\tapplyAction({ type, status: 200, data: { count: count++ } });\n\t}\n\tfunction redirect() {\n\t\tapplyAction({ type: 'redirect', status: 303, location: '/' });\n\t}\n\tfunction error() {\n\t\tapplyAction({ type: 'error', error: { message: 'Unexpected Form Error' } });\n\t}\n</script>\n\n<pre>{JSON.stringify(form)}</pre>\n<button class=\"increment-success\" on:click={() => update('success')}>Increment (success)</button>\n<button class=\"increment-invalid\" on:click={() => update('failure')}>Increment (invalid)</button>\n<button class=\"invalidateAll\" on:click={invalidateAll}>Invalidate</button>\n<button class=\"redirect\" on:click={redirect}>Redirect</button>\n<button class=\"error\" on:click={error}>Error</button>\n<a href=\"/actions/enhance\">To enhance</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/adapter/dynamic/+page.server.js",
    "content": "export const prerender = false;\n\nexport const config = {\n\tmessage: 'hello from dynamic page'\n};\n\nexport function load({ platform }) {\n\treturn {\n\t\tplatform\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/adapter/dynamic/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<pre>{JSON.stringify(data.platform)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/adapter/prerendered/+page.server.js",
    "content": "export const prerender = true;\n\nexport const config = {\n\tmessage: 'hello from prerendered page'\n};\n\nexport function load({ platform }) {\n\treturn {\n\t\tplatform\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/adapter/prerendered/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<pre>{JSON.stringify(data.platform)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/anchor/+page.svelte",
    "content": "<h1>Welcome to a test project</h1>\n<a id=\"scroll-anchor\" href=\"#last-anchor-2\">Bottom of this page</a>\n<a id=\"non-ascii-anchor\" href=\"/anchor/anchor#go-to-encöded\">Anchor demo (non-ASCII)</a>\n<a id=\"special-char-anchor\" href=\"/anchor/anchor#go-to-.=\">Anchor demo (special characters)</a>\n<a id=\"first-anchor\" href=\"/anchor/anchor#go-to-element\">Anchor demo (first)</a>\n<div>Spacing</div>\n<a id=\"second-anchor\" href=\"/anchor/anchor#go-to-element\">Anchor demo (second)</a>\n<div>Spacing</div>\n<a id=\"third-anchor\" href=\"/anchor/anchor\">Anchor demo (third)</a>\n<div>Spacing</div>\n<a id=\"last-anchor\" href=\"/anchor/anchor#go-to-element\">Anchor demo (last)</a>\n<a id=\"last-anchor-2\" href=\"/anchor/anchor\">Anchor demo (last 2)</a>\n<a id=\"routing-page\" href=\"/routing/hashes/target\">Different page</a>\n<a id=\"to-scroll-margin\" href=\"/anchor/anchor#scroll-margin\">Scroll margin anchor</a>\n\n<style>\n\t:global(body) {\n\t\tbackground-color: tan;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t}\n\n\ta {\n\t\tdisplay: block;\n\t\tmargin: 20px;\n\t}\n\n\tdiv {\n\t\tbackground-color: hotpink;\n\t\theight: 180vh;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/anchor/anchor/+page.svelte",
    "content": "<div style=\"height: 180vh; background-color: hotpink;\">They (don't) see me...</div>\n<div style=\"height: 180vh; background-color: peru;\">\n\t<p id=\"go-to-element\">The browser scrolls to me</p>\n</div>\n<div style=\"height: 180vh; background-color: tomato;\">\n\t<p id=\"go-to-encöded\">The browser scrolls to me</p>\n</div>\n<div style=\"height: 180vh; background-color: honeydew;\">\n\t<p id=\"go-to-.=\" class=\"special-char-id\">The browser scrolls to me</p>\n</div>\n<div style=\"height: 180vh; background-color: lightblue;\">\n\t<p id=\"scroll-margin\" style=\"scroll-margin-top: 40px;\">The browser scrolls to me</p>\n</div>\n<a id=\"non-ascii-anchor\" href=\"#go-to-encöded\">Anchor demo (non-ASCII)</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/+page.svelte",
    "content": "<h1>Welcome to a test project</h1>\n<a href=\"/anchor-with-manual-scroll/anchor-onmount#go-to-element\">Anchor demo</a>\n\n<style>\n\t:global(body) {\n\t\tbackground-color: tan;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t}\n\n\ta {\n\t\tdisplay: block;\n\t\tmargin: 20px;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/anchor-afternavigate/+page.svelte",
    "content": "<script>\n\timport { afterNavigate, disableScrollHandling } from '$app/navigation';\n\n\tafterNavigate(() => {\n\t\tdisableScrollHandling();\n\t\tdocument.getElementById('abcde')?.scrollIntoView();\n\t});\n</script>\n\n<div style=\"height: 180vh; background-color: hotpink;\">They (don't) see me...</div>\n<div style=\"height: 180vh; background-color: peru;\">\n\t<p id=\"go-to-element\">The browser scrolls to me</p>\n</div>\n<p id=\"abcde\" style=\"height: 180vh; background-color: hotpink;\">I take precedence</p>\n<div></div>\n\n<a href=\"/anchor-with-manual-scroll/anchor-afternavigate?x=y#go-to-element\">reload me</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/anchor-onmount/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\timport { disableScrollHandling } from '$app/navigation';\n\n\tonMount(() => {\n\t\tdisableScrollHandling();\n\t\tdocument.getElementById('abcde')?.scrollIntoView();\n\t});\n</script>\n\n<div style=\"height: 180vh; background-color: hotpink;\">They (don't) see me...</div>\n<div style=\"height: 180vh; background-color: peru;\">\n\t<p id=\"go-to-element\">The browser scrolls to me</p>\n</div>\n<p id=\"abcde\" style=\"height: 180vh; background-color: hotpink;\">I take precedence</p>\n<div></div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/answer.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json({ answer: 42 });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/app-environment/+page.svelte",
    "content": "<script>\n\timport { version } from '$app/environment';\n</script>\n\n<h1>{version}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/asset-import/+page.svelte",
    "content": "<script>\n\timport small from './small.png';\n\timport large from './large.jpg';\n</script>\n\n<img alt=\"svelte\" src={small} />\n<img alt=\"potatoes\" src={large} />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/asset-preload/+page.svelte",
    "content": "<script>\n\timport './styles.css';\n</script>\n\n<h1>asset-preload</h1>\n\n<style>\n\th1 {\n\t\tfont-family: Shlop;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/asset-preload/prerendered/+page.server.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/asset-preload/prerendered/+page.svelte",
    "content": "<h1>asset-preload/prerendered</h1>\n\n<style>\n\t@import '../styles.css';\n\n\th1 {\n\t\tfont-family: Shlop;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/asset-preload/styles.css",
    "content": "@font-face {\n\t/* we need a font file that exceeds assetsInlineLimit */\n\tfont-family: 'Shlop';\n\tsrc: url(./shlop.woff2);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/caching/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ setHeaders }) {\n\tsetHeaders({\n\t\t'cache-control': 'public, max-age=30'\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/caching/+page.svelte",
    "content": "<h1>this page will be cached for 30 seconds</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/caching/server-data/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport async function load({ setHeaders }) {\n\tsetHeaders({\n\t\t'cache-control': 'public, max-age=30'\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/caching/server-data/+page.svelte",
    "content": "<h1>this page's __data.json will be cached for 30 seconds</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/content-length-header/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/content-type-header/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/+page.server.js",
    "content": "import { COOKIE_NAME } from './shared';\n\n/** @type {import('./$types').PageServerLoad} */\nexport function load(event) {\n\treturn {\n\t\tcookie: event.cookies.get(COOKIE_NAME)\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\nCookie: <span id=\"cookie-value\">{`${data.cookie}`}</span>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/collect-without-re-escaping/+page.js",
    "content": "import { browser } from '$app/environment';\n\n/** @type {import('@sveltejs/kit').Load}*/\nexport async function load({ fetch }) {\n\tif (!browser) {\n\t\t// We don't want the client-side collected cookie to clobber the\n\t\t// server-side collected cookie that we're actually testing.\n\t\tawait fetch('/cookies/collect-without-re-escaping/set-cookie');\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/collect-without-re-escaping/+page.svelte",
    "content": "<script>\n\timport { browser } from '$app/environment';\n</script>\n\n<p>{browser && document.cookie}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/collect-without-re-escaping/set-cookie/+server.js",
    "content": "/** @type {import('@sveltejs/kit').RequestHandler} */\nexport async function GET() {\n\treturn new Response(null, { headers: { 'set-cookie': 'cookie-special-characters=\"foo\"' } });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/delete/+server.js",
    "content": "import { redirect } from '@sveltejs/kit';\nimport { COOKIE_NAME } from '../shared';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport const GET = (event) => {\n\tevent.cookies.delete(COOKIE_NAME, { path: '/cookies' });\n\tredirect(303, '/cookies');\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/encoding/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load(event) {\n\treturn {\n\t\tencoding: event.cookies.get('encoding')\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/encoding/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\nCookie: <span id=\"cookie-value\">\n\t{data.encoding}\n</span>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/encoding/not-decoded-twice/+server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport const GET = (event) => {\n\tconst sneaky = 'teapot%2C%20jane%20austen';\n\tevent.cookies.set('encoding', sneaky, { path: '/cookies/encoding' });\n\tredirect(303, '/cookies/encoding');\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/encoding/set/+server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport const GET = (event) => {\n\tconst needsEncoding = 'teapot, jane austen';\n\tevent.cookies.set('encoding', needsEncoding, { path: '/cookies/encoding' });\n\tredirect(303, '/cookies/encoding');\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/enhanced/basic/+page.server.ts",
    "content": "export const load: import('./$types').PageServerLoad = (event) => {\n\tconst cookie = event.cookies.get('a');\n\treturn { cookie };\n};\n\nexport const actions: import('./$types').Actions = {\n\tsetTeapot: (event) => {\n\t\tevent.cookies.set('a', 'teapot', { path: '' });\n\t\treturn { lastSet: new Date().valueOf() };\n\t},\n\tsetJaneAusten: (event) => {\n\t\tevent.cookies.set('a', 'Jane Austen', { path: '' });\n\t\treturn { lastSet: new Date().valueOf() };\n\t},\n\tdelete: (event) => {\n\t\tevent.cookies.delete('a', { path: '' });\n\t\treturn { lastSet: new Date().valueOf() };\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/enhanced/basic/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\nCookie: <span id=\"cookie-value\">{`${data.cookie}`}</span>\n\n<form method=\"post\" action=\"?/setTeapot\" use:enhance>\n\t<button id=\"teapot\">Set cookie to \"teapot\"</button>\n</form>\n\n<form method=\"post\" action=\"?/setJaneAusten\" use:enhance>\n\t<button id=\"janeAusten\">Set cookie to \"Jane Austen\"</button>\n</form>\n\n<form method=\"post\" action=\"?/delete\" use:enhance>\n\t<button id=\"delete\">Delete cookie</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/forwarded-in-etag/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ cookies }) {\n\tcookies.set('foo', 'bar', { path: '', httpOnly: false });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/forwarded-in-etag/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\n\tlet cookies;\n\n\tonMount(() => {\n\t\tcookies = document.cookie;\n\t});\n</script>\n\n<button\n\ton:click={() => {\n\t\tdocument.cookie = 'foo=bar;expires=Thu, 01 Jan 1970 00:00:01 GMT;';\n\t\tlocation.reload();\n\t}}\n>\n\tDelete cookies and reload the page\n</button>\n\n<p>{cookies}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/nested/a/+page.server.js",
    "content": "import { COOKIE_NAME } from '../../shared';\n\n/** @type {import('./$types').PageServerLoad} */\nexport function load(event) {\n\tevent.cookies.set(COOKIE_NAME, 'teapot', {\n\t\tpath: ''\n\t});\n\n\treturn {\n\t\tcookie: event.cookies.get(COOKIE_NAME)\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/nested/a/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\nCookie: <span id=\"cookie-value\">{`${data.cookie}`}</span>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/nested/b/+page.server.js",
    "content": "import { COOKIE_NAME } from '../../shared';\n\n/** @type {import('./$types').PageServerLoad} */\nexport function load(event) {\n\treturn {\n\t\tcookie: event.cookies.get(COOKIE_NAME)\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/nested/b/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\nCookie: <span id=\"cookie-value\">{`${data.cookie}`}</span>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/serialize/+server.js",
    "content": "/** @type {import('@sveltejs/kit').RequestHandler} */\nexport const GET = ({ cookies }) => {\n\tconst response = new Response('success', {\n\t\tstatus: 200\n\t});\n\tresponse.headers.append('set-cookie', cookies.serialize('endpoint', 'endpoint', { path: '' }));\n\treturn response;\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/set/+server.js",
    "content": "import { redirect } from '@sveltejs/kit';\nimport { COOKIE_NAME } from '../shared';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport const GET = (event) => {\n\tevent.cookies.set(COOKIE_NAME, 'teapot', { path: '/cookies' });\n\tredirect(303, '/cookies');\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/set-in-layout/+layout.server.js",
    "content": "/** @type {import('./$types').LayoutServerLoad} */\nexport function load(event) {\n\tevent.cookies.set('a', 'i was set in the layout load', { path: '' });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/set-in-layout/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/set-in-layout/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load(event) {\n\treturn {\n\t\ta: event.cookies.get('a')\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/set-in-layout/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\nCookie: <span id=\"cookie-value\">{data.a}</span>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/set-more-than-one/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load(event) {\n\tevent.cookies.set('a', 'teapot', { path: '' });\n\tevent.cookies.set('b', 'jane austen', { path: '' });\n\n\treturn {\n\t\ta: event.cookies.get('a'),\n\t\tb: event.cookies.get('b')\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/set-more-than-one/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\nCookie: <span id=\"cookie-value\">{data.a} {data.b}</span>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cookies/shared.js",
    "content": "export const COOKIE_NAME = 'cookiesAPITest';\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/csrf/+server.js",
    "content": "/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\treturn new Response('ok', { status: 200 });\n}\n\n/** @type {import('./$types').RequestHandler} */\nexport function POST() {\n\treturn new Response('ok', { status: 200 });\n}\n\n/** @type {import('./$types').RequestHandler} */\nexport function PUT() {\n\treturn new Response('ok', { status: 200 });\n}\n\n/** @type {import('./$types').RequestHandler} */\nexport function PATCH() {\n\treturn new Response('ok', { status: 200 });\n}\n\n/** @type {import('./$types').RequestHandler} */\nexport function DELETE() {\n\treturn new Response('ok', { status: 200 });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/css/+page.svelte",
    "content": "<script>\n\timport './_styles.css';\n\timport './_manual.css?url';\n\timport './_manual.css?raw';\n\timport './_manual.css?inline';\n</script>\n\n<div class=\"styled\">this text is red</div>\n\n<div class=\"also-styled\">this text is blue</div>\n\n<div class=\"overridden\">this text is green</div>\n\n<div class=\"not\">this text is black</div>\n\n<a href=\"/css/other\">other</a>\n\n<style>\n\t.also-styled {\n\t\tcolor: blue;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/css/_base.css",
    "content": ".overridden {\n\tcolor: red;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/css/_manual.css",
    "content": ".not {\n\tcolor: blue;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/css/_styles.css",
    "content": "@import '_base.css';\n\n.styled {\n\tcolor: red;\n}\n\n.overridden {\n\tcolor: green;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/css/dynamic/+page.svelte",
    "content": "<script>\n\tlet Dynamic;\n</script>\n\n<button\n\ton:click={async () => {\n\t\tDynamic = (await import('./Dynamic.svelte')).default;\n\t}}>load component</button\n>\n\n<svelte:component this={Dynamic}></svelte:component>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/css/dynamic/Dynamic.svelte",
    "content": "<p>I'm dynamically imported</p>\n\n<style>\n\tp {\n\t\tcolor: blue;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/css/encöded/+page.svelte",
    "content": "<h1>this should be purple</h1>\n\n<style>\n\th1 {\n\t\tcolor: purple;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/css/other/+page.svelte",
    "content": "<h1>other</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cyclical-dynamic-import/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\n\tonMount(async () => {\n\t\tconst { is_even } = await import('./_is_even.js');\n\t\tconsole.log(is_even(5));\n\t});\n</script>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cyclical-dynamic-import/_is_even.js",
    "content": "export async function is_even(num) {\n\tconst { is_odd } = await import('./_is_odd.js');\n\tif (num === 0) return true;\n\treturn is_odd(num - 1);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/cyclical-dynamic-import/_is_odd.js",
    "content": "export async function is_odd(num) {\n\tconst { is_even } = await import('./_is_even.js');\n\tif (num === 1) return true;\n\treturn is_even(num - 1);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/noscroll/+page.svelte",
    "content": "<div style=\"height: 2000px; background: palegoldenrod\"></div>\n\n<a id=\"one\" href=\"/data-sveltekit/noscroll/target\" data-sveltekit-noscroll>one</a>\n\n<div data-sveltekit-noscroll>\n\t<a id=\"two\" href=\"/data-sveltekit/noscroll/target\">two</a>\n\t<a id=\"three\" href=\"/data-sveltekit/noscroll/target\" data-sveltekit-noscroll=\"off\">three</a>\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/noscroll/target/+page.svelte",
    "content": "<div style=\"height: 2000px; background: palegoldenrod\"></div>\n\n<h1>target</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-code/+page.svelte",
    "content": "<a id=\"eager\" href=\"/data-sveltekit/preload-code/target/eager\" data-sveltekit-preload-code=\"eager\"\n\t>eager</a\n>\n\n<div style=\"height: 200vh\"></div>\n\n<a\n\tid=\"viewport\"\n\thref=\"/data-sveltekit/preload-code/target/viewport\"\n\tdata-sveltekit-preload-code=\"viewport\">viewport</a\n>\n<a id=\"hover\" href=\"/data-sveltekit/preload-code/target/hover\" data-sveltekit-preload-code=\"hover\"\n\t>hover</a\n>\n<a id=\"tap\" href=\"/data-sveltekit/preload-code/target/tap\" data-sveltekit-preload-code=\"tap\">tap</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-code/target/eager/+page.js",
    "content": "export function load() {\n\treturn {\n\t\tname: 'eager'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-code/target/eager/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>{data.name}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-code/target/hover/+page.js",
    "content": "export function load() {\n\treturn {\n\t\tname: 'hover'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-code/target/hover/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>{data.name}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-code/target/tap/+page.js",
    "content": "export function load() {\n\treturn {\n\t\tname: 'tap'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-code/target/tap/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>{data.name}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-code/target/viewport/+page.js",
    "content": "export function load() {\n\treturn {\n\t\tname: 'hover'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-code/target/viewport/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>{data.name}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-data/+page.svelte",
    "content": "<script>\n\tlet x = 0;\n</script>\n\n<a id=\"one\" href=\"/data-sveltekit/preload-data/target\" data-sveltekit-preload-data>one</a>\n\n<div data-sveltekit-preload-data>\n\t<a id=\"two\" href=\"/data-sveltekit/preload-data/target\">two</a>\n\t<a id=\"three\" href=\"/data-sveltekit/preload-data/target\" data-sveltekit-preload-data=\"off\"\n\t\t>three</a\n\t>\n</div>\n\n<a id=\"tap\" href=\"/data-sveltekit/preload-data/target\" data-sveltekit-preload-data=\"tap\">tap</a>\n\n<a\n\tid=\"hover-then-tap\"\n\thref=\"/data-sveltekit/preload-data/target\"\n\tdata-sveltekit-preload-code=\"hover\"\n\tdata-sveltekit-preload-data=\"tap\">hover for code then tap for data</a\n>\n\n<a id=\"dynamic\" data-sveltekit-preload-data=\"hover\" href=\"/data-sveltekit/preload-data/target?x={x}\"\n\t>dynamic</a\n>\n<button id=\"change_dynamic\" type=\"button\" on:click={() => x++}>change dynamic</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-data/offline/+layout.server.js",
    "content": "export function load({ url }) {\n\treturn {\n\t\turl: url.toString()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-data/offline/+page.svelte",
    "content": "<a id=\"one\" href=\"/data-sveltekit/preload-data/offline/target\" data-sveltekit-preload-data>target</a\n>\n\n<a\n\tid=\"slow-navigation\"\n\thref=\"/data-sveltekit/preload-data/offline/slow-navigation\"\n\tdata-sveltekit-preload-data>slow-navigation</a\n>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-data/offline/slow-navigation/+page.server.js",
    "content": "export async function load() {\n\treturn new Promise((resolve) => {\n\t\tsetTimeout(resolve, 1000);\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-data/offline/slow-navigation/+page.svelte",
    "content": "<p>slow navigation</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-data/offline/target/+page.svelte",
    "content": "<p>target</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-data/target/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\ta: 1\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/preload-data/target/+page.svelte",
    "content": "<h1>this string should only appear in this preloaded file</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/reload/+page.svelte",
    "content": "<a id=\"one\" href=\"/data-sveltekit/reload/target\" data-sveltekit-reload>one</a>\n\n<div data-sveltekit-reload>\n\t<a id=\"two\" href=\"/data-sveltekit/reload/target\">two</a>\n\t<a id=\"three\" href=\"/data-sveltekit/reload/target\" data-sveltekit-reload=\"off\">three</a>\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/reload/hash/+page.svelte",
    "content": "<a href=\"#example\" data-sveltekit-reload>focus</a>\n<input id=\"example\" />\n<a href=\"/data-sveltekit/reload/hash/new\">new page</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/reload/hash/new/+page.svelte",
    "content": "<p>hello world</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/reload/target/+page.svelte",
    "content": "<h1>target</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/replacestate/+page.svelte",
    "content": "<a id=\"one\" href=\"/data-sveltekit/replacestate/target\" data-sveltekit-replacestate>one</a>\n\n<div data-sveltekit-replacestate>\n\t<a id=\"two\" href=\"/data-sveltekit/replacestate/target\">two</a>\n\t<a id=\"three\" href=\"/data-sveltekit/replacestate/target\" data-sveltekit-replacestate=\"off\">\n\t\tthree\n\t</a>\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/data-sveltekit/replacestate/target/+page.svelte",
    "content": "<h1>target</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/delete-route/+page.svelte",
    "content": "<script>\n\t/** @type {string} */\n\tlet status;\n\n\tfunction del() {\n\t\tfetch('delete-route/42.json', { method: 'DELETE' })\n\t\t\t.then((r) => r.json())\n\t\t\t.then(\n\t\t\t\t({ id }) => (status = `deleted ${id}`),\n\t\t\t\t(e) => (status = e.toString())\n\t\t\t);\n\t}\n</script>\n\n<button class=\"del\" on:click={del}>delete</button>\n\n{#if status}\n\t<h1>{status}</h1>\n{/if}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/delete-route/[id].json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function DELETE(event) {\n\treturn json({\n\t\tid: event.params.id\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/+page.svelte",
    "content": "<a href=\"/encoded/苗条\">苗条</a>\n<a href=\"/encoded/土豆\">土豆</a>\n<a href=\"/encoded/反应\">反应</a>\n<a href=\"/encoded/redirect\">Redirect</a>\n<a href=\"/encoded/@svelte\">@svelte</a>\n<a href=\"/encoded/test%2520me\">test%20me</a>\n<a href=\"/encoded/test%252fme\">test%2fme</a>\n<a href=\"/encoded/AC%2fDC\">AC/DC</a>\n<a href=\"/encoded/%5b\">[</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/@[username]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>@{page.params.username}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/[slug]/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport function load({ url, params }) {\n\treturn {\n\t\tpath: url.pathname,\n\t\tslug: params.slug\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/[slug]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>dynamic</h1>\n<h2>{data.path}: {data.slug}</h2>\n<h3>{page.url.pathname}: {page.params.slug}</h3>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/endpoint/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport async function GET() {\n\treturn json({\n\t\tfruit: '🍎🍇🍌'\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/+layout.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{decodeURIComponent(page.url.pathname.split('/').pop())}</h1>\n<slot />\n\n<a href=\"/encoded/escape-sequences/:-)\">:-)</a>\n<a href=\"/encoded/escape-sequences/%23\">#</a>\n<a href=\"/encoded/escape-sequences/%2F\">/</a>\n<a href=\"/encoded/escape-sequences/%3f\">?</a>\n<a href=\"/encoded/escape-sequences/苗\">苗</a>\n<a href=\"/encoded/escape-sequences/<\">&lt;</a>\n<a href=\"/encoded/escape-sequences/1<2\">1&lt;2</a>\n<a href=\"/encoded/escape-sequences/🤪\">🤪</a>\n<a href=\"/encoded/escape-sequences/%25\">%</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/[u+82d7]/+page.svelte",
    "content": "苗\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/[u+d83e][u+dd2a]/+page.svelte",
    "content": "🤪\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/[x+23]/+page.svelte",
    "content": "#\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/[x+25]/+page.svelte",
    "content": "%\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/[x+2f]/+page.svelte",
    "content": "/\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/[x+3a]-[x+29]/+page.svelte",
    "content": ":-)\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/[x+3c]/+page.svelte",
    "content": "&lt;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/[x+3f]/+page.svelte",
    "content": "?\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/escape-sequences/[x][x+3c][y]/+page.svelte",
    "content": "1&lt;2\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/redirect/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load() {\n\tredirect(307, 'redirected?embedded=' + encodeURIComponent('/苗条?foo=bar&fizz=buzz'));\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/redirect/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/redirected/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport function load({ url }) {\n\treturn {\n\t\t// nb: .get() on URLSearchParams does a decoding pass, so we should see the raw values.\n\t\tembedded: url.searchParams.get('embedded')\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/redirected/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<pre>{data.embedded}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/反应/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function load() {\n\tredirect(307, encodeURI('苗条'));\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/反应/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/苗条/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport function load({ url }) {\n\treturn {\n\t\tpath: url.pathname\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/encoded/苗条/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\t/** @type {{ data: import('./$types').PageData }} */\n\tlet { data } = $props();\n</script>\n\n<h1>static</h1>\n<h2>{data.path}</h2>\n<h3>{page.url.pathname}</h3>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-input/sha256/+server.js",
    "content": "import { createHash } from 'node:crypto';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport async function PUT({ request }) {\n\tconst hash = createHash('sha256');\n\tconst reader = request.body.getReader();\n\n\tfor (;;) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) break;\n\t\thash.update(value);\n\t\tawait new Promise((r) => setTimeout(r, 10));\n\t}\n\n\treturn new Response(hash.digest('base64url'));\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/+server.js",
    "content": "/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function OPTIONS() {\n\treturn new Response('ok');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/body/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET() {\n\treturn json({});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/fallback/+server.js",
    "content": "export function GET() {\n\treturn new Response('ok');\n}\n\nexport function fallback() {\n\treturn new Response('catch-all');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/fetch-asset/absolute/+server.js",
    "content": "import file_path from '../test.txt?url';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport async function GET({ url }) {\n\tconst absolute = new URL(file_path, url.origin);\n\n\tconst response = await fetch(absolute);\n\n\treturn new Response(response.body, {\n\t\theaders: {\n\t\t\t'Content-Type': response.headers.get('Content-Type')\n\t\t}\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/fetch-asset/relative/+server.js",
    "content": "import file_path from '../test.txt?url';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport async function GET({ fetch }) {\n\tconst response = await fetch(file_path);\n\n\treturn new Response(response.body, {\n\t\theaders: {\n\t\t\t'Content-Type': response.headers.get('Content-Type')\n\t\t}\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/fetch-asset/test.txt",
    "content": "Cos sie konczy, cos zaczyna"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/head-handler/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/head-handler/+server.js",
    "content": "// The GET handler is included alongside the HEAD handler to test that HEAD\n// is not included twice in the `allow` header list of allowed methods.\n// This is because HEAD is always allowed if GET is allowed too\nexport function GET() {\n\treturn new Response('Hello world!');\n}\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function HEAD() {\n\treturn new Response('', {\n\t\theaders: {\n\t\t\t'x-sveltekit-head-endpoint': 'true'\n\t\t}\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/head-write-error/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET({ setHeaders }) {\n\tsetHeaders({\n\t\t'x-test': '\\u001f'\n\t});\n\n\treturn json({});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/stream/+server.js",
    "content": "import { createHash, randomBytes } from 'node:crypto';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET() {\n\tconst data = randomBytes(1024 * 256);\n\tconst digest = createHash('sha256').update(data).digest('base64url');\n\n\tlet length = 0;\n\n\treturn new Response(\n\t\tnew ReadableStream(\n\t\t\t{\n\t\t\t\tpull(controller) {\n\t\t\t\t\tconst offset = data.byteOffset + length;\n\t\t\t\t\tconst chunk =\n\t\t\t\t\t\tdata.byteLength - length > controller.desiredSize\n\t\t\t\t\t\t\t? new Uint8Array(data.buffer, offset, controller.desiredSize)\n\t\t\t\t\t\t\t: new Uint8Array(data.buffer, offset);\n\n\t\t\t\t\tcontroller.enqueue(chunk);\n\n\t\t\t\t\tlength += chunk.byteLength;\n\n\t\t\t\t\tif (length >= data.byteLength) {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ highWaterMark: 1024 * 16 }\n\t\t),\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/octet-stream',\n\t\t\t\tdigest: `sha-256=${digest}`\n\t\t\t}\n\t\t}\n\t);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/stream-throw-error/+server.js",
    "content": "/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET() {\n\treturn new Response(\n\t\tnew ReadableStream({\n\t\t\tpull() {\n\t\t\t\tthrow Error('simulate error');\n\t\t\t}\n\t\t}),\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/octet-stream'\n\t\t\t}\n\t\t}\n\t);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/endpoint-output/stream-typeerror/+server.js",
    "content": "let errorName = 'null';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET({ url }) {\n\tif (url.searchParams.has('what')) {\n\t\tconst body = errorName;\n\t\terrorName = 'null';\n\t\treturn new Response(body);\n\t}\n\n\treturn new Response(\n\t\tnew ReadableStream({\n\t\t\tpull(controller) {\n\t\t\t\tcontroller.enqueue(42);\n\t\t\t},\n\n\t\t\tcancel(reason) {\n\t\t\t\terrorName = reason?.name;\n\t\t\t}\n\t\t}),\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/octet-stream'\n\t\t\t}\n\t\t}\n\t);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/env/+page.svelte",
    "content": "<a href=\"/env/includes\">Includes</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/env/includes/+page.server.js",
    "content": "import { PRIVATE_STATIC } from '$env/static/private';\nimport { env } from '$env/dynamic/private';\n\nexport function load() {\n\treturn {\n\t\tPRIVATE_STATIC,\n\t\tPRIVATE_DYNAMIC: env.PRIVATE_DYNAMIC\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/env/includes/+page.svelte",
    "content": "<script>\n\timport { PUBLIC_STATIC } from '$env/static/public';\n\timport { env } from '$env/dynamic/public';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p id=\"static-private\">PRIVATE_STATIC: {data.PRIVATE_STATIC}</p>\n<p id=\"dynamic-private\">PRIVATE_DYNAMIC: {data.PRIVATE_DYNAMIC}</p>\n\n<p id=\"static-public\">PUBLIC_STATIC: {PUBLIC_STATIC}</p>\n<p id=\"dynamic-public\">PUBLIC_DYNAMIC: {env.PUBLIC_DYNAMIC}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/+layout.js",
    "content": "import { error } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch, url }) {\n\tif (url.pathname.startsWith('/errors/error-in-layout')) {\n\t\tconst res = await fetch('/errors/error-in-layout/non-existent');\n\t\terror(/** @type {404} */ (res.status));\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/+layout.svelte",
    "content": "<slot />;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/clientside/+page.svelte",
    "content": "<script>\n\timport { browser } from '$app/environment';\n\n\tif (browser) {\n\t\tthrow new Error('Crashing now');\n\t}\n</script>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/endpoint/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/errors/endpoint.json');\n\tif (res.ok) {\n\t\treturn await res.json();\n\t} else {\n\t\tthrow new Error(String(res.status));\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/endpoint/+page.svelte",
    "content": "<h1>this text should not appear</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/endpoint-shadow/+page.server.js",
    "content": "/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function load() {\n\tthrow new Error('nope');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/endpoint-shadow/+page.svelte",
    "content": "<h1>this text should not appear</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/endpoint-shadow-not-ok/+page.server.js",
    "content": "import { error } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function load() {\n\terror(555, undefined);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/endpoint-shadow-not-ok/+page.svelte",
    "content": "<h1>this text should not appear</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/endpoint-throw-error/+server.js",
    "content": "import { error } from '@sveltejs/kit';\n\nexport function GET() {\n\terror(401, 'You shall not pass');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/endpoint-throw-redirect/+server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function GET() {\n\tredirect(302, '/');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/endpoint.json/+server.js",
    "content": "export function GET() {\n\tthrow new Error('nope');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/error-html/+page.svelte",
    "content": "<script>\n\t/** @param {string} type */\n\tasync function fail(type) {\n\t\tawait fetch(`/errors/error-html/make-root-fail?type=${type}`);\n\t\tif (type === 'redirect') {\n\t\t\tlocation.assign(location.href + '/404');\n\t\t} else {\n\t\t\tlocation.reload();\n\t\t}\n\t}\n</script>\n\n<button on:click={() => fail('unexpected')}>Unexpected</button>\n<button on:click={() => fail('expected')}>Expected</button>\n<button on:click={() => fail('redirect')}>Redirect</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/error-html/make-root-fail/+server.js",
    "content": "/**\n * @type {import('./$types').RequestHandler} param0\n */\nexport function GET({ cookies, url }) {\n\tcookies.set('fail-type', url.searchParams.get('type'), { path: '/' });\n\treturn new Response();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/error-in-handle/+page.svelte",
    "content": "<!-- this will never be rendered, because hooks.js will throw an error for this path -->\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/error-in-layout/+page.svelte",
    "content": "<h1>hello</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/init-error-endpoint/+server.js",
    "content": "import { building } from '$app/environment';\nimport { json } from '@sveltejs/kit';\n\nif (!building) {\n\t// @ts-expect-error\n\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions\n\tthisvariableisnotdefined;\n}\n\nexport function GET() {\n\treturn json({\n\t\tanswer: 42\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/invalid-load-response/+page.js",
    "content": "export function load() {\n\treturn ['nope'];\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/invalid-load-response/+page.svelte",
    "content": "<!-- this will never be rendered, load function returns something invalid -->\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/invalid-route-response/+server.js",
    "content": "export function GET() {\n\treturn 'this ought to be an object';\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/invalid-server-load-response/+page.server.js",
    "content": "export function load() {\n\treturn ['nope'];\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/invalid-server-load-response/+page.svelte",
    "content": "<!-- this will never be rendered, load function returns something invalid -->\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-client/+page.js",
    "content": "import { browser } from '$app/environment';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load() {\n\tif (browser) {\n\t\tthrow new Error('Crashing now');\n\t}\n\n\treturn {};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-client/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-client/+page.js",
    "content": "import { error } from '@sveltejs/kit';\n\n/** @type {import('./$types').PageLoad} */\nexport async function load() {\n\tif (typeof window !== 'undefined') {\n\t\terror(555, 'Not found');\n\t}\n\n\treturn {};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-client/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-page-options/+error.svelte",
    "content": "<script lang=\"ts\">\n\timport { page } from '$app/stores';\n</script>\n\n<h1>{$page.error.message}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-page-options/+layout.js",
    "content": "// disables csr for the error page\nexport const csr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-page-options/csr/+layout.js",
    "content": "export const csr = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-page-options/csr/+page.js",
    "content": "export function load() {\n\tthrow new Error('Crashing now');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-server/+page.js",
    "content": "import { error } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load() {\n\terror(555, 'Not found');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-server/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-server/layout-data/+error.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-server/layout-data/+layout.server.js",
    "content": "/** @type {import('./$types').LayoutServerLoad} */\nexport function load() {\n\treturn {\n\t\tanswer: 42\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-server/layout-data/+layout.svelte",
    "content": "<script lang=\"ts\">\n\t/** @type {import('./$types').LayoutData} */\n\texport let data;\n</script>\n\n<slot />\n\n<div id=\"error-layout-data\">{data.answer}</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-server/layout-data/+page.js",
    "content": "import { error } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load() {\n\terror(404, 'Not found');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-server/layout-data/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-string-server/+page.js",
    "content": "import { error } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load() {\n\terror(555, 'Not found');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-error-string-server/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-server/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load() {\n\tthrow new Error('Crashing now');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-server/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-status-without-error-client/+page.js",
    "content": "import { error } from '@sveltejs/kit';\n\nexport async function load() {\n\tif (typeof window !== 'undefined') {\n\t\terror(401, undefined);\n\t}\n\treturn {};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/load-status-without-error-client/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/missing-actions/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/module-scope-client/+page.svelte",
    "content": "<script context=\"module\">\n\timport { browser } from '$app/environment';\n\n\tif (browser) {\n\t\tthrow new Error('Crashing now');\n\t}\n</script>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/module-scope-server/+page.svelte",
    "content": "<script context=\"module\">\n\timport { dev } from '$app/environment';\n\n\tif (dev) {\n\t\t// can't throw in prod, the app won't start at all\n\t\tthrow new Error('Crashing now');\n\t}\n</script>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/nested-error-page/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\tlet answer = 42; // TODO migration leftover, was returned from load previously\n</script>\n\n<h1>Nested error page</h1>\n<p id=\"nested-error-status\">status: {page.status}</p>\n<p id=\"nested-error-message\">error.message: {page.error && page.error.message}</p>\n<p id=\"nested-error-loaded\">answer: {answer}</p>\n\n<style>\n\th1 {\n\t\tcolor: blue;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/nested-error-page/+page.svelte",
    "content": "<a href=\"/errors/nested-error-page/nope\">nope</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/nested-error-page/nope/+page.js",
    "content": "export async function load() {\n\tthrow new Error('nope');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/nested-error-page/nope/+page.svelte",
    "content": "<h1>should not see this</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<pre>{JSON.stringify(\n\t\t{\n\t\t\tstatus: page.status,\n\t\t\t...page.error\n\t\t},\n\t\tnull,\n\t\t'  '\n\t)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/+page.svelte",
    "content": "<a id=\"get-implicit\" href=\"/errors/page-endpoint/get-implicit\">GET (implicit)</a>\n<a id=\"get-explicit\" href=\"/errors/page-endpoint/get-explicit\">GET (explicit)</a>\n\n<form action=\"/errors/page-endpoint/post-implicit\" method=\"post\">\n\t<button type=\"submit\" id=\"post-implicit\">POST (implicit)</button>\n</form>\n\n<form action=\"/errors/page-endpoint/post-explicit\" method=\"post\">\n\t<button type=\"submit\" id=\"post-explicit\">POST (explicit)</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/_shared.js",
    "content": "export class FancyError extends Error {\n\tname = 'FancyError';\n\tfancy = true;\n\n\tconstructor(message, options) {\n\t\tsuper(message, options);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/get-explicit/+page.server.js",
    "content": "import { error } from '@sveltejs/kit';\n\nexport const load = () => {\n\terror(400, 'oops');\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/get-explicit/+page.svelte",
    "content": "<h1>if you see this something went wrong</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/get-implicit/+page.server.js",
    "content": "import { FancyError } from '../_shared.js';\n\nexport const load = () => {\n\tthrow new FancyError('oops');\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/get-implicit/+page.svelte",
    "content": "<h1>if you see this something went wrong</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/post-explicit/+page.server.js",
    "content": "import { error } from '@sveltejs/kit';\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: () => {\n\t\terror(400, 'oops');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/post-explicit/+page.svelte",
    "content": "<h1>if you see this something went wrong</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/post-implicit/+page.server.js",
    "content": "import { FancyError } from '../_shared.js';\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: () => {\n\t\tthrow new FancyError('oops');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/page-endpoint/post-implicit/+page.svelte",
    "content": "<h1>if you see this something went wrong</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/serverside/+page.svelte",
    "content": "<script>\n\timport { dev } from '$app/environment';\n\n\tif (dev) {\n\t\t// can't throw in prod, the app won't start at all\n\t\tthrow new Error('Crashing now');\n\t}\n</script>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/stack-trace/+page.svelte",
    "content": "<script>\n\timport bad from './_bad.js';\n</script>\n\n<h1>{bad}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/errors/stack-trace/_bad.js",
    "content": "const bad = foo().toUpperCase();\nexport default bad;\n\n// @ts-expect-error\n/** @returns {string} */\nfunction foo() {}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/get-request-event/+page.svelte",
    "content": "<a href=\"/get-request-event/with-message\">go</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/get-request-event/endpoint/+server.js",
    "content": "import { getRequestEvent } from '$app/server';\nimport { text } from '@sveltejs/kit';\n\nexport function GET() {\n\tconst event = getRequestEvent();\n\n\treturn text(event.locals.message);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/get-request-event/with-error/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.error.message}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/get-request-event/with-error/+page.server.js",
    "content": "export const load = async () => {\n\tthrow new Error('Crashing now');\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/get-request-event/with-message/+page.server.ts",
    "content": "import { getRequestEvent } from '$app/server';\n\nexport async function load() {\n\tconst e1 = getRequestEvent();\n\tawait Promise.resolve();\n\tconst e2 = getRequestEvent(); // check AsyncLocalStorage works\n\n\tif (e1 !== e2) {\n\t\tthrow new Error('e1 !== e2');\n\t}\n\n\treturn {\n\t\tmessage: e1.locals.message\n\t};\n}\n\nexport const actions = {\n\tdefault: async () => {\n\t\tconst { request } = getRequestEvent();\n\t\tconst data = await request.formData();\n\n\t\treturn {\n\t\t\tmessage: `from form: ${data.get('message')}`\n\t\t};\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/get-request-event/with-message/+page.svelte",
    "content": "<script>\n\tlet { data, form } = $props();\n</script>\n\n<h1>{form?.message ?? data.message}</h1>\n\n<form method=\"POST\">\n\t<input name=\"message\" />\n\t<button>submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/goto/+page.svelte",
    "content": "<script>\n\timport { goto } from '$app/navigation';\n\n\tlet message = '...';\n</script>\n\n<button\n\ton:click={async () => {\n\t\ttry {\n\t\t\tawait goto('https://example.com');\n\t\t} catch (e) {\n\t\t\tmessage = e.message;\n\t\t}\n\t}}>goto</button\n>\n\n<p>{message}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/goto/loadreplace1/+page.ts",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport const load = () => {\n\treturn redirect(302, '/goto/loadreplace2');\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/goto/loadreplace2/+page.ts",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport const load = () => {\n\treturn redirect(302, '/goto/loadreplace3');\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/goto/loadreplace3/+page.ts",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport const load = () => {\n\treturn redirect(302, '/goto/testfinish');\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/goto/testentry/+page.svelte",
    "content": "<h3>navigation test entry</h3>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/goto/testfinish/+page.svelte",
    "content": "<h3>navigation test finish</h3>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/goto/teststart/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport const load = ({ depends, url, untrack }) => {\n\tdepends('app:goto');\n\tif (untrack(() => url.searchParams.get('redirect') !== null)) {\n\t\treturn redirect(302, '/goto/loadreplace1');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/goto/teststart/+page.svelte",
    "content": "<h3>navigation test start</h3>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/headers/+page.svelte",
    "content": "<h1>headers</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/headers/class/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/headers/echo', {\n\t\theaders: new Headers({ foo: 'bar' })\n\t});\n\n\tconst { foo } = await res.json();\n\treturn {\n\t\tfoo\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/headers/class/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p>{data.foo}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/headers/echo/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET({ request }) {\n\t/** @type {Record<string, string>} */\n\tconst headers = {};\n\trequest.headers.forEach((value, key) => {\n\t\tif (key !== 'cookie') {\n\t\t\theaders[key] = value;\n\t\t}\n\t});\n\n\treturn json(headers);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/headers/set-cookie/+layout.server.js",
    "content": "/** @type {import('./$types').LayoutServerLoad} */\nexport function load({ cookies }) {\n\tcookies.set('cookie1', 'value1', {\n\t\tpath: '/headers/set-cookie',\n\t\tsecure: false // safari\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/headers/set-cookie/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/headers/set-cookie/sub/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ cookies }) {\n\tcookies.set('cookie2', 'value2', {\n\t\tpath: '',\n\t\tsecure: false // safari\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/headers/set-cookie/sub/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/iframes/+page.svelte",
    "content": "<a href=\"/iframes/nested/parent\">parent</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/iframes/nested/child/+page.svelte",
    "content": "<h1>Hello from the child</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/iframes/nested/parent/+page.svelte",
    "content": "<iframe title=\"Child content\" src=\"./child\"></iframe>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/immutable-headers/+page.js",
    "content": "// This file will trigger the vary-header code-path in `src/runtime/server/respond.js`\nexport function load() {\n\treturn { foo: 'bar' };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/immutable-headers/+server.js",
    "content": "export const GET = () => {\n\tconst response = new Response('foo');\n\t// this simulates immutable Response Headers, like those returned by undici\n\tObject.defineProperty(response.headers, 'append', { value: null });\n\tObject.defineProperty(response.headers, 'set', { value: null });\n\treturn response;\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/index.css",
    "content": "/* https://github.com/sveltejs/kit/issues/3997 */\nh1 {\n\tcolor: blue;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/init-hooks/+page.server.ts",
    "content": "let did_init_run = 0;\n\nexport function _set_from_init() {\n\tdid_init_run++;\n}\n\nexport function load() {\n\treturn {\n\t\tdid_init_run\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/init-hooks/+page.svelte",
    "content": "<script>\n\tconst { data } = $props();\n</script>\n\n<p>{data.did_init_run}</p>\n\n<a href=\"/init-hooks/navigate\">navigate</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/init-hooks/navigate/+page.svelte",
    "content": "navigated\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/interactivity/toggle-element/+page.svelte",
    "content": "<script>\n\tlet visible = true;\n\n\tfunction toggle() {\n\t\tvisible = !visible;\n\t}\n</script>\n\n{#if visible}\n\t<button on:click={toggle}>remove</button>\n\n\t<!-- svelte-ignore a11y-missing-attribute a11y-click-events-have-key-events a11y-no-static-element-interactions -->\n\t<a on:click={toggle}>remove</a>\n{:else}\n\t<button on:click={toggle}>add</button>\n\n\t<!-- svelte-ignore a11y-missing-attribute a11y-click-events-have-key-events a11y-no-static-element-interactions -->\n\t<a on:click={toggle}>add</a>\n{/if}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/keepfocus/+page.svelte",
    "content": "<script>\n\timport { goto } from '$app/navigation';\n\timport { page } from '$app/state';\n</script>\n\n<input\n\tid=\"input\"\n\ttype=\"text\"\n\tvalue={page.url.searchParams.get('foo')}\n\ton:input={(e) => {\n\t\tgoto('?foo=' + e.currentTarget?.value, { keepFocus: true });\n\t}}\n/>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/+page.js",
    "content": "import { browser } from '$app/environment';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load(pageContext) {\n\tif (browser) {\n\t\twindow.pageContext = pageContext;\n\t}\n\treturn { foo: 'bar' };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>bar == {data.foo}?</h1>\n\n<a href=\"/load/fetch-request\">fetch request</a>\n<a href=\"/load/fetch-relative\">fetch relative</a>\n<a href=\"/load/fetch-credentialed\">fetch credentialed</a>\n<a href=\"/load/fetch-request-headers\">fetch headers</a>\n<a href=\"/load/fetch-no-body\">fetch no body</a>\n<a href=\"/load/large-response\">large response</a>\n<a href=\"/load/raw-body\">raw body</a>\n<a href=\"/load/server-fetch-request\">server fetch request</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/[dynamic]/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ params, fetch }) {\n\tconst res = await fetch(`/load/${params.dynamic}.json`);\n\treturn await res.json();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/[dynamic]/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.name}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/[dynamic].json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET({ params }) {\n\treturn json({\n\t\tname: params.dynamic\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/accumulated/+page.svelte",
    "content": "<a href=\"/load/accumulated/with-page-data\">with page data</a>\n<a href=\"/load/accumulated/without-page-data\">without page data</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/accumulated/with-page-data/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport function load() {\n\treturn {\n\t\tpagedata: 'pagedata'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/accumulated/with-page-data/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>foo.bar: {data.foo.bar}</h1>\n<h2>pagedata: {data.pagedata}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/accumulated/without-page-data/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>foo.bar: {data.foo.bar}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/bust/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst resp = await fetch('/load/cache-control/bust/count');\n\treturn resp.json();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/bust/+page.svelte",
    "content": "<script>\n\timport { invalidate } from '$app/navigation';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n\n\tasync function update() {\n\t\tawait fetch('/load/cache-control/bust/increment');\n\t\tawait fetch('/load/cache-control/bust/count', { method: 'POST' });\n\t\tinvalidate('/load/cache-control/bust/count');\n\t}\n</script>\n\n<p class=\"counter\">Count is {data.count}</p>\n<button on:click={update}>update</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/bust/count/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET({ setHeaders, cookies }) {\n\tsetHeaders({ 'cache-control': 'public, max-age=4', age: '2' });\n\n\tconst count = +(cookies.get('cache-control-bust-count') ?? 0);\n\n\treturn json({ count });\n}\n\nexport function POST() {\n\treturn new Response();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/bust/increment/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET({ cookies }) {\n\tcookies.set(\n\t\t'cache-control-bust-count',\n\t\t+(cookies.get('cache-control-bust-count') ?? 0) + 1 + '',\n\t\t{ path: '/' }\n\t);\n\n\treturn json({});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/default/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst resp = await fetch('/load/cache-control/default/count');\n\treturn resp.json();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/default/+page.svelte",
    "content": "<script>\n\timport { invalidate } from '$app/navigation';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n\n\tlet ticker = 0;\n\tasync function update() {\n\t\tticker += 1;\n\t\tawait fetch('/load/cache-control/default/increment');\n\t\tawait invalidate('/load/cache-control/default/count');\n\t\tticker += 1;\n\t}\n</script>\n\n<p class=\"counter\">Count is {data.count}</p>\n<button on:click={update} data-ticker={ticker}>update</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/default/count/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET({ setHeaders, cookies }) {\n\tsetHeaders({ 'cache-control': 'public, max-age=4', age: '2' });\n\n\tconst count = +(cookies.get('cache-control-default-count') ?? 0);\n\n\treturn json({ count });\n}\n\nexport function POST() {\n\treturn new Response();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/default/increment/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET({ cookies }) {\n\tcookies.set(\n\t\t'cache-control-default-count',\n\t\t+(cookies.get('cache-control-default-count') ?? 0) + 1 + '',\n\t\t{ path: '/' }\n\t);\n\n\treturn json({});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/force/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst resp = await fetch('/load/cache-control/force/count', { cache: 'no-cache' });\n\treturn resp.json();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/force/+page.svelte",
    "content": "<script>\n\timport { invalidate } from '$app/navigation';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n\n\tasync function update() {\n\t\tawait fetch('/load/cache-control/force/increment');\n\t\tinvalidate('/load/cache-control/force/count');\n\t}\n</script>\n\n<p class=\"counter\">Count is {data.count}</p>\n<button on:click={update}>update</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/force/count/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET({ setHeaders, cookies }) {\n\tsetHeaders({ 'cache-control': 'public, max-age=4', age: '2' });\n\n\tconst count = +(cookies.get('cache-control-force-count') ?? 0);\n\n\treturn json({ count });\n}\n\nexport function POST() {\n\treturn new Response();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/cache-control/force/increment/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET({ cookies }) {\n\tcookies.set(\n\t\t'cache-control-force-count',\n\t\t+(cookies.get('cache-control-force-count') ?? 0) + 1 + '',\n\t\t{ path: '/' }\n\t);\n\n\treturn json({});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/change-detection/+layout.js",
    "content": "let count = 0;\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch, depends }) {\n\tconst res = await fetch('/load/change-detection/data.json');\n\tconst { type } = await res.json();\n\n\tcount += 1;\n\n\tdepends('custom:change-detection-layout');\n\n\treturn {\n\t\ttype,\n\t\tloads: count\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/change-detection/+layout.svelte",
    "content": "<script>\n\t/** @type {import('./$types').LayoutData} */\n\texport let data;\n</script>\n\n<h1>{data.type} loads: {data.loads}</h1>\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/change-detection/data.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json({\n\t\ttype: 'layout'\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/change-detection/one/[x]/+page.js",
    "content": "import { browser } from '$app/environment';\n\nlet count = 0;\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ params, setHeaders }) {\n\tif (browser) {\n\t\tcount += 1;\n\t}\n\n\t// Using setHeader has no effect on the client; testing that here\n\tsetHeaders({\n\t\t'cache-control': 'public, max-age=5'\n\t});\n\treturn {\n\t\tx: params.x,\n\t\tloads: count\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/change-detection/one/[x]/+page.svelte",
    "content": "<script>\n\timport { invalidate, invalidateAll } from '$app/navigation';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h2>x: {data.x}: {data.loads}</h2>\n\n<button\n\ton:click={async () => {\n\t\twindow.invalidated = false;\n\t\tawait invalidate((url) => url.pathname.includes('change-detection/data.json'));\n\t\twindow.invalidated = true;\n\t}}>invalidate change-detection/data.json</button\n>\n\n<button\n\ton:click={async () => {\n\t\twindow.invalidated = false;\n\t\tawait invalidateAll();\n\t\twindow.invalidated = true;\n\t}}>invalidate all</button\n>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/change-detection/two/[y]/+page.js",
    "content": "let count = 0;\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ params, setHeaders }) {\n\tcount += 1;\n\n\tsetHeaders({\n\t\t'cache-control': 'max-age=5'\n\t});\n\treturn {\n\t\ty: params.y,\n\t\tloads: count\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/change-detection/two/[y]/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h2>y: {data.y}: {data.loads}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/devalue/+page.svelte",
    "content": "<a href=\"/load/devalue/regex\">/load/devalue/regex</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/devalue/regex/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load() {\n\treturn {\n\t\tregex: /hello/\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/devalue/regex/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.regex.test('hello')}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/dynamic-import-styles/+page.js",
    "content": "export async function load() {\n\treturn {\n\t\tThing: (await import('./_/Thing.svelte')).default\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/dynamic-import-styles/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<svelte:component this={data.Thing} />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/dynamic-import-styles/_/Thing.svelte",
    "content": "<p id=\"thing\">this text is red</p>\n\n<style>\n\tp {\n\t\tcolor: red;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-abort-signal/+page.server.js",
    "content": "export async function load({ fetch }) {\n\tconst aborted_controller = new AbortController();\n\taborted_controller.abort();\n\n\tlet aborted_immediately = false;\n\ttry {\n\t\tawait fetch('/load/fetch-abort-signal/data', { signal: aborted_controller.signal });\n\t} catch (error) {\n\t\tif (error.name === 'AbortError') {\n\t\t\taborted_immediately = true;\n\t\t}\n\t}\n\n\tlet aborted_during_request = false;\n\ttry {\n\t\tawait fetch('/load/fetch-abort-signal/slow', { signal: AbortSignal.timeout(100) });\n\t} catch (error) {\n\t\tif (error.name === 'AbortError') {\n\t\t\taborted_during_request = true;\n\t\t}\n\t}\n\n\tconst successful_response = await fetch('/load/fetch-abort-signal/data');\n\tconst successful_data = await successful_response.json();\n\n\treturn {\n\t\taborted_immediately,\n\t\taborted_during_request,\n\t\tsuccessful_data\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-abort-signal/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<div>\n\t<h1>AbortSignal Test Results</h1>\n\t<p class=\"aborted-immediately\">Aborted immediately: {data.aborted_immediately}</p>\n\t<p class=\"aborted-during-request\">Aborted during request: {data.aborted_during_request}</p>\n\t<p class=\"successful-data\">Successful data: {JSON.stringify(data.successful_data)}</p>\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-abort-signal/data/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport async function GET() {\n\treturn json({ message: 'success', timestamp: Date.now() });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-abort-signal/slow/+server.js",
    "content": "export function GET() {\n\treturn new Promise(() => {});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-arraybuffer-b64/+page.js",
    "content": "export async function load({ fetch }) {\n\tconst res = await fetch('/load/fetch-arraybuffer-b64/data');\n\n\tconst l = await fetch('/load/fetch-arraybuffer-b64/data', {\n\t\tbody: Uint8Array.from(Array(256).fill(0), (_, i) => i),\n\t\tmethod: 'POST'\n\t});\n\n\treturn {\n\t\tdata: await res.arrayBuffer(),\n\t\tdata_long: await l.arrayBuffer()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-arraybuffer-b64/+page.svelte",
    "content": "<script>\n\texport let data;\n\n\t$: arr = [...new Uint8Array(data.data)];\n\n\tlet ok = 'Ok';\n\n\t$: {\n\t\tconst p = new Uint8Array(data.data_long);\n\t\tok = p.length === 256 ? 'Ok' : 'Wrong length';\n\n\t\tif (p.length === 256) {\n\t\t\tfor (let i = 0; i < p.length; i++) {\n\t\t\t\tif (p[i] !== i) {\n\t\t\t\t\tok = `Expected ${i} but got ${p[i]}`;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n</script>\n\n<span class=\"test-content\">{JSON.stringify(arr)}</span>\n\n<br />\n\n{ok}\n<span style=\"word-wrap: break-word;\">\n\t{JSON.stringify([...new Uint8Array(data.data_long)])}\n</span>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-arraybuffer-b64/data/+server.js",
    "content": "export const GET = () => {\n\treturn new Response(new Uint8Array([1, 2, 3, 4]));\n};\n\nexport const POST = async ({ request }) => {\n\treturn new Response(await request.arrayBuffer());\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-asset/+page.js",
    "content": "// we need both queries to prevent Vite from inlining the asset as base64 string on build\n// see https://github.com/vitejs/vite/issues/19562\nimport asset from './example.json?url&no-inline';\n\nexport async function load({ fetch }) {\n\tconst res = await fetch(asset);\n\tconst data = await res.json();\n\treturn data;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-asset/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p>{data.a}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-asset/example.json",
    "content": "{\n\t\"a\": \"1\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-body-stream-b64/+page.js",
    "content": "const body_stream_to_buffer = async (body) => {\n\tlet buffer = new Uint8Array();\n\tconst reader = body.getReader();\n\twhile (true) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (value != null) {\n\t\t\tconst newBuffer = new Uint8Array(buffer.length + value.length);\n\t\t\tnewBuffer.set(buffer, 0);\n\t\t\tnewBuffer.set(value, buffer.length);\n\t\t\tbuffer = newBuffer;\n\t\t}\n\t\tif (done) break;\n\t}\n\treturn buffer;\n};\n\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/fetch-body-stream-b64/data');\n\n\tconst l = await fetch('/load/fetch-body-stream-b64/data', {\n\t\tbody: Uint8Array.from(Array(256).fill(0), (_, i) => i),\n\t\tmethod: 'POST'\n\t});\n\n\treturn {\n\t\tdata: await body_stream_to_buffer(res.body),\n\t\tdata_long: await body_stream_to_buffer(l.body)\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-body-stream-b64/+page.svelte",
    "content": "<script>\n\texport let data;\n\n\t$: arr = [...new Uint8Array(data.data)];\n\n\tlet ok = 'Ok';\n\n\t$: {\n\t\tconst p = new Uint8Array(data.data_long);\n\t\tok = p.length === 256 ? 'Ok' : 'Wrong length';\n\n\t\tif (p.length === 256) {\n\t\t\tfor (let i = 0; i < p.length; i++) {\n\t\t\t\tif (p[i] !== i) {\n\t\t\t\t\tok = `Expected ${i} but got ${p[i]}`;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n</script>\n\n<span class=\"test-content\">{JSON.stringify(arr)}</span>\n\n<br />\n\n{ok}\n<span style=\"word-wrap: break-word;\">\n\t{JSON.stringify([...new Uint8Array(data.data_long)])}\n</span>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-body-stream-b64/data/+server.js",
    "content": "export const GET = () => {\n\treturn new Response(new Uint8Array([1, 2, 3, 4]));\n};\n\nexport const POST = async ({ request }) => {\n\treturn new Response(await request.arrayBuffer());\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-cache-control/+page.svelte",
    "content": "<a href=\"/load/fetch-cache-control/load-data\">load-data</a>\n\n<a href=\"/load/fetch-cache-control/headers-diff\">headers-diff</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-cache-control/headers-diff/+page.js",
    "content": "export async function load({ fetch, url }) {\n\tconst r1 = await fetch(url.pathname, {\n\t\theaders: {\n\t\t\t'x-foo': 'a'\n\t\t}\n\t}).then((r) => r.json());\n\n\tconst r2 = await fetch(url.pathname, {\n\t\theaders: {\n\t\t\t'x-foo': 'b'\n\t\t}\n\t}).then((r) => r.json());\n\n\treturn {\n\t\ta: r1,\n\t\tb: r2\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-cache-control/headers-diff/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<a href=\"/load/fetch-cache-control\">fetch-cache-control</a>\n\n<h2>{data.a.foo} / {data.b.foo}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-cache-control/headers-diff/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport async function GET({ request, setHeaders }) {\n\tsetHeaders({\n\t\t'cache-control': 'public, max-age=7'\n\t});\n\n\treturn json({\n\t\tfoo: request.headers.get('x-foo')\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-cache-control/load-data/+page.js",
    "content": "export async function load(event) {\n\tconst url = '/load/fetch-cache-control/load-data';\n\n\tconst res_fr = await event.fetch(url, {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json'\n\t\t},\n\t\tbody: JSON.stringify({ lang: 'fr' })\n\t});\n\tconst fr = await res_fr.json();\n\n\tconst res_hu = await event.fetch(url, {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json'\n\t\t},\n\t\tbody: JSON.stringify({ lang: 'hu' })\n\t});\n\n\tconst hu = await res_hu.json();\n\n\treturn { fr, hu };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-cache-control/load-data/+page.svelte",
    "content": "<script>\n\texport let data;\n\t$: ({ fr, hu } = data);\n</script>\n\n<a href=\"/load/fetch-cache-control\">fetch-cache-control</a>\n\n<h2>fr</h2>\n<div id=\"fr\">\n\t{JSON.stringify(fr)}\n</div>\n\n<h2>hu</h2>\n<div id=\"hu\">\n\t{JSON.stringify(hu)}\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-cache-control/load-data/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport async function POST({ request, setHeaders }) {\n\tsetHeaders({\n\t\t'cache-control': 'public, max-age=7'\n\t});\n\n\ttry {\n\t\tconst { lang } = await request.json();\n\t\tif (lang === 'fr') {\n\t\t\treturn json({ hi: 'bonjour' });\n\t\t} else if (lang === 'hu') {\n\t\t\treturn json({ hi: 'szia' });\n\t\t}\n\t} catch {}\n\n\t// default to english\n\treturn json({ hi: 'hello' });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-credentialed/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/fetch-credentialed.json');\n\n\t/** @type {any} */\n\tconst { name } = await res.json();\n\n\treturn {\n\t\tname\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-credentialed/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>Hello {data.name}!</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-credentialed.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET(event) {\n\treturn json({\n\t\tname: event.locals.name ?? 'Fail'\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-external-no-cookies/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch, url }) {\n\tconst port = url.searchParams.get('port');\n\tconst res = await fetch(`http://localhost:${port}`);\n\n\treturn await res.json();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-external-no-cookies/+page.svelte",
    "content": "<h1>hello</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-no-body/+page.js",
    "content": "export async function load({ fetch }) {\n\tconst response = await fetch('/load/fetch-no-body/endpoint');\n\n\treturn {\n\t\tok: response.ok,\n\t\tbody: await response.text()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-no-body/+page.svelte",
    "content": "<script>\n\tlet { data } = $props();\n</script>\n\n<h1>ok: {data.ok}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-no-body/endpoint/+server.js",
    "content": "export function GET() {\n\treturn new Response(undefined, {\n\t\tstatus: 204\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-origin-external/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch, url }) {\n\tconst port = url.searchParams.get('port');\n\tconst res = await fetch(`http://localhost:${port}`);\n\n\tconst { origin } = await res.json();\n\treturn { origin };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-origin-external/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>origin: {data.origin}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-origin-internal/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/fetch-origin-internal/resource', {\n\t\tmethod: 'POST'\n\t});\n\n\tconst { origin } = await res.json();\n\n\treturn { origin };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-origin-internal/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>origin: {data.origin}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-origin-internal/resource/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function POST({ request }) {\n\tconst origin = request.headers.get('origin');\n\treturn json({ origin });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-relative/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst get = await fetch('fetch-relative.json');\n\tconst post = await fetch('fetch-relative.json', { method: 'post', body: '?' });\n\n\treturn { ...(await get.json()), ...(await post.json()) };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-relative/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>the answer is {data.answer}</h1>\n<h2>the question was {data.question}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-relative.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\treturn json({\n\t\tanswer: 42\n\t});\n}\n\n/** @type {import('./$types').RequestHandler} */\nexport async function POST({ request }) {\n\treturn json({\n\t\tquestion: await request.text()\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-request/+page.js",
    "content": "import { browser } from '$app/environment';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst url = '/load/fetch-request.json';\n\n\t// this is contrived, but saves us faffing about with node-fetch here\n\tconst resource = browser ? new Request(url) : url;\n\n\tconst res = await fetch(resource);\n\tconst { answer } = await res.json();\n\n\treturn { answer };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-request/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>the answer is {data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-request-empty-headers/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ url, fetch }) {\n\tconst res = await fetch(new Request(url.origin + '/load/fetch-request.json'));\n\tconst { answer } = await res.json();\n\treturn { answer };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-request-empty-headers/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>the answer is {data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/fetch-request-headers/data');\n\n\treturn {\n\t\theaders: await res.json()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n\n\tconst json = JSON.stringify({\n\t\taccept: data.headers['accept'],\n\t\t'accept-language': data.headers['accept-language'],\n\t\tconnection: data.headers['connection'],\n\t\t'sec-fetch-dest': data.headers['sec-fetch-dest'],\n\t\t'sec-fetch-mode': data.headers['sec-fetch-mode'],\n\t\t'if-none-match': data.headers['if-none-match'],\n\t\treferer: data.headers['referer']\n\t});\n</script>\n\n<pre>{json}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/data/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET({ request }) {\n\treturn json(Object.fromEntries(request.headers));\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-request.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json({\n\t\tanswer: 42\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-response-headers/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst response = await fetch('/load/fetch-response-headers.json');\n\n\treturn {\n\t\tmessage: await response.text(),\n\t\tfoo: response.headers.get('x-foo')\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-response-headers/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.message}</h1>\n<h2>{data.foo}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-response-headers.json/+server.js",
    "content": "/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\treturn new Response('ok', {\n\t\theaders: {\n\t\t\t'x-foo': 'this should not appear'\n\t\t}\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-same-url/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch, url }) {\n\tconst results = [];\n\n\tfor (let i = 0; i < 3; i++) {\n\t\tconst res = await fetch(`${url.origin}/load/fetch-same-url/data.json`);\n\t\tconst json = await res.json();\n\t\tresults.push(json.result);\n\t}\n\n\treturn { results };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-same-url/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>the result is {data.results.join(',')}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/fetch-same-url/data.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nlet result = 0;\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\tresult++;\n\treturn json({ result });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/depends/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport function load({ data, depends }) {\n\tdepends('invalidate-depends:shared');\n\treturn {\n\t\tshared: new Date().getTime(),\n\t\t...data\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/depends/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ depends }) {\n\tdepends('invalidate-depends:server');\n\treturn {\n\t\tserver: new Date().getTime()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/depends/+page.svelte",
    "content": "<script>\n\timport { invalidate } from '$app/navigation';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p class=\"shared\">{data.shared}</p>\n<button\n\ttype=\"button\"\n\tclass=\"shared\"\n\ton:click={() => (window.promise = invalidate('invalidate-depends:shared'))}\n>\n\tinvalidate shared\n</button>\n\n<p class=\"server\">{data.server}</p>\n<button\n\ttype=\"button\"\n\tclass=\"server\"\n\ton:click={() => (window.promise = invalidate('invalidate-depends:server'))}\n>\n\tinvalidate server\n</button>\n\n<p class=\"neither\">neither</p>\n<button\n\ttype=\"button\"\n\tclass=\"neither\"\n\ton:click={() => (window.promise = invalidate('invalidate-depends:neither'))}\n>\n\tinvalidate neither\n</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/depends-goto/+layout.js",
    "content": "/** @type {import('./$types').LayoutLoad} */\nexport function load({ depends }) {\n\tdepends('invalidate-depends-goto:layout');\n\treturn {\n\t\tlayout: new Date().getTime()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/depends-goto/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport function load({ data, depends }) {\n\tdepends('invalidate-depends-goto:shared');\n\treturn {\n\t\tshared: new Date().getTime(),\n\t\t...data\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/depends-goto/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ depends }) {\n\tdepends('invalidate-depends-goto:server');\n\treturn {\n\t\tserver: new Date().getTime()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/depends-goto/+page.svelte",
    "content": "<script>\n\timport { goto } from '$app/navigation';\n\timport { page } from '$app/state';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p class=\"layout\">{data.layout}</p>\n<button\n\ttype=\"button\"\n\tclass=\"specified\"\n\ton:click={() =>\n\t\t(window.promise = goto(page.url.pathname, {\n\t\t\tinvalidate: ['invalidate-depends-goto:layout', 'invalidate-depends-goto:shared']\n\t\t}))}\n>\n\tinvalidate specified\n</button>\n\n<p class=\"server\">{data.server}</p>\n<button\n\ttype=\"button\"\n\tclass=\"server\"\n\ton:click={() =>\n\t\t(window.promise = goto(page.url.pathname, { invalidate: ['invalidate-depends-goto:server'] }))}\n>\n\tinvalidate server\n</button>\n\n<p class=\"shared\">{data.shared}</p>\n<button\n\ttype=\"button\"\n\tclass=\"shared\"\n\ton:click={() =>\n\t\t(window.promise = goto(page.url.pathname, { invalidate: ['invalidate-depends-goto:shared'] }))}\n>\n\tinvalidate shared\n</button>\n\n<p class=\"neither\">neither</p>\n<button\n\ttype=\"button\"\n\tclass=\"neither\"\n\ton:click={() =>\n\t\t(window.promise = goto(page.url.pathname, { invalidate: ['invalidate-depends-goto:neither'] }))}\n>\n\tinvalidate neither\n</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/forced/+layout.server.js",
    "content": "import { increment } from '../../state.js';\n\nexport const load = () => {\n\treturn {\n\t\ta: increment(import.meta.url)\n\t};\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/forced/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/forced/+page.server.js",
    "content": "import { increment } from '../../state.js';\nexport const load = () => {\n\treturn {\n\t\tb: increment(import.meta.url)\n\t};\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/forced/+page.svelte",
    "content": "<script>\n\timport { invalidateAll, goto } from '$app/navigation';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>a: {data.a}, b: {data.b}</h1>\n\n<button\n\tclass=\"invalidateall\"\n\ton:click={() => {\n\t\twindow.promise = invalidateAll();\n\t}}>invalidate</button\n>\n\n<button\n\tclass=\"goto\"\n\ton:click={() => {\n\t\twindow.promise = goto('/load/invalidation/forced?test', { invalidateAll: true });\n\t}}>goto</button\n>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/forced/reset-states/+server.js",
    "content": "import { reset_states } from '../../../state.js';\nimport { json } from '@sveltejs/kit';\n\nexport const POST = () => {\n\treturn json(reset_states(import.meta.url));\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/forced-goto/+layout.server.js",
    "content": "import { increment } from '../../state.js';\n\nexport const load = () => {\n\treturn {\n\t\ta: increment(import.meta.url)\n\t};\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/forced-goto/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/forced-goto/+page.server.js",
    "content": "import { increment } from '../../state.js';\nexport const load = () => {\n\treturn {\n\t\tb: increment(import.meta.url)\n\t};\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/forced-goto/+page.svelte",
    "content": "<script>\n\timport { invalidateAll, goto } from '$app/navigation';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>a: {data.a}, b: {data.b}</h1>\n\n<button\n\tclass=\"invalidateall\"\n\ton:click={() => {\n\t\twindow.promise = invalidateAll();\n\t}}>invalidate</button\n>\n\n<button\n\tclass=\"goto\"\n\ton:click={() => {\n\t\twindow.promise = goto('/load/invalidation/forced-goto?test', { invalidateAll: true });\n\t}}>goto</button\n>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/forced-goto/reset-states/+server.js",
    "content": "import { reset_states } from '../../../state.js';\nimport { json } from '@sveltejs/kit';\n\nexport const POST = () => {\n\treturn json(reset_states(import.meta.url));\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/invalidate-then-goto/+layout.server.js",
    "content": "/** @type {import('./$types').LayoutServerLoad} */\nexport function load({ depends }) {\n\tdepends('invalidate-depends:goto');\n\treturn {\n\t\tlayoutDate: new Date().getTime()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/invalidate-then-goto/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ url }) {\n\turl.searchParams.get('x');\n\treturn {\n\t\tpageDate: new Date().getTime()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/invalidate-then-goto/+page.svelte",
    "content": "<script>\n\timport { invalidate, goto } from '$app/navigation';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p class=\"layout\">{data.layoutDate}</p>\n<p class=\"page\">{data.pageDate}</p>\n<button\n\ttype=\"button\"\n\tclass=\"invalidate\"\n\ton:click={() => (window.promise = invalidate('invalidate-depends:goto'))}\n>\n\tinvalidate\n</button>\n<button\n\ttype=\"button\"\n\tclass=\"goto\"\n\ton:click={() => (window.promise = goto('/load/invalidation/invalidate-then-goto?x'))}\n>\n\tgoto\n</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/multiple/+layout.js",
    "content": "import { redirect } from '@sveltejs/kit';\nimport { get } from 'svelte/store';\nimport { get_layout, redirect_state } from './state';\n\n/** @type {import('./$types').LayoutLoad} */\nexport function load({ depends }) {\n\tdepends('invalid:layout');\n\n\tif (get(redirect_state) === 'running') {\n\t\tredirect_state.set('done');\n\t\tredirect(307, '/load/invalidation/multiple/redirect');\n\t}\n\n\treturn new Promise((resolve) =>\n\t\tsetTimeout(\n\t\t\t() =>\n\t\t\t\tresolve({\n\t\t\t\t\tcount_layout: get_layout(),\n\t\t\t\t\tredirect_mode: get(redirect_state)\n\t\t\t\t}),\n\t\t\tMath.random() * 500\n\t\t)\n\t);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/multiple/+layout.svelte",
    "content": "<script>\n\timport { invalidate, invalidateAll } from '$app/navigation';\n\timport { page } from '$app/state';\n\timport { increment_layout, increment_page } from './state';\n\n\t/** @param {string} str */\n\tasync function update(str) {\n\t\tif (str !== 'page') {\n\t\t\tincrement_layout();\n\t\t}\n\t\tif (str !== 'layout') {\n\t\t\tincrement_page();\n\t\t}\n\n\t\tif (str === 'all') {\n\t\t\tinvalidateAll();\n\t\t} else {\n\t\t\tinvalidate(`invalid:${str}`);\n\t\t}\n\t}\n</script>\n\n<button class=\"layout\" on:click={() => update('layout')}>Invalidate layout</button>\n<button class=\"page\" on:click={() => update('page')}>Invalidate page</button>\n<button class=\"all\" on:click={() => update('all')}>Invalidate all</button>\n\n<p>layout: {page.data.count_layout}, page: {page.data.count_page}</p>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/multiple/+page.js",
    "content": "import { get_page } from './state';\n\n/** @type {import('./$types').PageLoad} */\nexport function load({ depends }) {\n\tdepends('invalid:page');\n\treturn new Promise((resolve) =>\n\t\tsetTimeout(\n\t\t\t() =>\n\t\t\t\tresolve({\n\t\t\t\t\tcount_page: get_page()\n\t\t\t\t}),\n\t\t\tMath.random() * 500\n\t\t)\n\t);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/multiple/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/multiple/redirect/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\nimport { redirect_state } from '../state';\n\n/** @type {import('./$types').PageLoad} */\nexport async function load({ parent }) {\n\tconst { redirect_mode } = await parent();\n\tif (redirect_mode === 'start') {\n\t\tredirect_state.set('running');\n\t\tredirect(307, '/load/invalidation/multiple');\n\t}\n\tif (redirect_mode === 'running') {\n\t\tthrow new Error('Shouldnt get redirected here with state \"running\"');\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/multiple/redirect/+page.svelte",
    "content": "<script>\n\timport { invalidateAll } from '$app/navigation';\n\timport { redirect_state } from '../state';\n\n\tfunction redirect() {\n\t\tredirect_state.set('start');\n\t\tinvalidateAll();\n\t}\n</script>\n\n<button class=\"redirect\" on:click={redirect}>redirect</button>\n<p class=\"redirect-state\">Redirect state: {$redirect_state}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/multiple/state.js",
    "content": "import { writable } from 'svelte/store';\n\nlet count_layout = 0;\nlet count_page = 0;\n\nexport const redirect_state = writable('initial');\n\nexport function increment_layout() {\n\tcount_layout++;\n}\n\nexport function increment_page() {\n\tcount_page++;\n}\n\nexport function get_layout() {\n\treturn count_layout;\n}\n\nexport function get_page() {\n\treturn count_page;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/multiple-batched/+page.js",
    "content": "export const ssr = false;\n\nlet count = 0;\n\nexport function load({ depends }) {\n\tdepends('multiple:invalidations-go-brr');\n\treturn { count: count++ };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/multiple-batched/+page.svelte",
    "content": "<script>\n\timport { invalidate } from '$app/navigation';\n\n\texport let data;\n</script>\n\n<div>\n\t<button\n\t\tid=\"multiple-batched\"\n\t\ton:click={(event) => {\n\t\t\tconst btn = event.currentTarget;\n\t\t\tinvalidate('multiple:invalidations-go-brr');\n\t\t\tinvalidate('multiple:invalidations-go-brr');\n\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() => invalidate('multiple:invalidations-go-brr'))\n\t\t\t\t.then(() => {\n\t\t\t\t\tbtn.dataset.done = 'true';\n\t\t\t\t});\n\t\t}}>{data.count}</button\n\t>\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/params/+layout.js",
    "content": "/** @type {import('./$types').LayoutLoad} */\nexport function load({ params }) {\n\treturn {\n\t\ta: params.a,\n\t\tb: params.b\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/params/+layout.svelte",
    "content": "<script>\n\t/** @type {import('./$types').LayoutData} */\n\texport let data;\n</script>\n\n<slot />\n\n<pre>{JSON.stringify({\n\t\ta: data.a,\n\t\tb: data.b\n\t})}</pre>\n\n<a href=\"/load/invalidation/params/1\">1</a>\n<a href=\"/load/invalidation/params/1/x\">1/x</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/params/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/params/[a]/+page.svelte",
    "content": "<h1>[a]</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/params/[a]/[b]/+page.svelte",
    "content": "<h1>[a]/[b]</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/route/server/+layout.server.js",
    "content": "/** @type {import('./$types').LayoutServerLoad} */\nexport function load({ route }) {\n\treturn {\n\t\troute: { ...route }\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/route/server/+layout.svelte",
    "content": "<script>\n\t/** @type {import('./$types').LayoutData} */\n\texport let data;\n</script>\n\n<h1>route.id: {data.route.id}</h1>\n<slot />\n\n<a href=\"/load/invalidation/route/server/a\">/load/invalidation/route/server/a</a>\n<a href=\"/load/invalidation/route/server/b\">/load/invalidation/route/server/b</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/route/server/a/+page.svelte",
    "content": "<h2>a</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/route/server/b/+page.svelte",
    "content": "<h2>b</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/route/shared/+layout.js",
    "content": "/** @type {import('./$types').LayoutLoad} */\nexport function load({ route }) {\n\treturn { route, random: Math.random() };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/route/shared/+layout.svelte",
    "content": "<script>\n\t/** @type {import('./$types').LayoutData} */\n\texport let data;\n</script>\n\n<h1>route.id: {data.route.id}</h1>\n<h2>random id: {data.random}</h2>\n<slot />\n\n<a href=\"/load/invalidation/route/shared/a\">/load/invalidation/route/shared/a</a>\n<a href=\"/load/invalidation/route/shared/b\">/load/invalidation/route/shared/b</a>\n\n<a href=\"/load/invalidation/route/shared/unchanged-x\">/load/invalidation/route/shared/unchanged-x</a\n>\n<a href=\"/load/invalidation/route/shared/unchanged-y\">/load/invalidation/route/shared/unchanged-y</a\n>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/route/shared/[x]/+page.svelte",
    "content": "<p>[x]</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/route/shared/a/+page.svelte",
    "content": "<h2>a</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/route/shared/b/+page.svelte",
    "content": "<h2>b</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/search-params/server/+page.server.js",
    "content": "let count = 0;\n\nexport function load({ url }) {\n\turl.searchParams.get('a');\n\treturn {\n\t\tcount: count++\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/search-params/server/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<span>count: {data.count}</span>\n\n<a data-id=\"tracked\" href=\"?a={data.count + 1}\">Change tracked parameter</a>\n<a data-id=\"untracked\" href=\"?a={data.count}&b={data.count + 1}\">Change untracked parameter</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/search-params/universal/+page.js",
    "content": "let count = 0;\n\nexport function load({ url }) {\n\turl.searchParams.get('a');\n\treturn {\n\t\tcount: count++\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/search-params/universal/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<span>count: {data.count}</span>\n\n<a data-id=\"tracked\" href=\"?a={data.count + 1}\">Change tracked parameter</a>\n<a data-id=\"untracked\" href=\"?a={data.count}&b={data.count + 1}\">Change untracked parameter</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/server-fetch/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/invalidation/server-fetch/count.json');\n\treturn res.json();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/server-fetch/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p data-testid=\"count\">{data.count}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/server-fetch/count.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nlet count = 0;\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET({ url }) {\n\tif (url.searchParams.has('reset')) count = 0;\n\treturn json({ count: count++ });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/url/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ url }) {\n\treturn {\n\t\ta: url.searchParams.get('a')\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/invalidation/url/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.a}</h1>\n\n<a href=\"?a=1\">1</a>\n<a href=\"?a=2\">2</a>\n<a href=\"?a=3\">3</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/large-response/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/large-response/text.txt');\n\tconst text = await res.text();\n\n\treturn {\n\t\ttext\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/large-response/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>text.length is {data.text.length}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/large-response/text.txt/+server.js",
    "content": "const chunk_size = 50000;\nconst chunk_count = 100;\n\nlet chunk = '';\nfor (let i = 0; i < chunk_size; i += 1) {\n\tchunk += String(i % 10);\n}\n\nconst encoder = new TextEncoder();\n\nexport function GET() {\n\tlet i = 0;\n\n\treturn new Response(\n\t\tnew ReadableStream({\n\t\t\tpull: (controller) => {\n\t\t\t\tif (i++ < chunk_count) {\n\t\t\t\t\tcontroller.enqueue(encoder.encode(chunk));\n\t\t\t\t} else {\n\t\t\t\t\tcontroller.close();\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/mutated-url/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport function load({ url }) {\n\treturn {\n\t\tq: url.searchParams.get('q')\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/mutated-url/+page.svelte",
    "content": "<script>\n\timport { goto } from '$app/navigation';\n\timport { page } from '$app/state';\n\n\t/** @type {{ data: import('./$types').PageData }} */\n\tlet { data } = $props();\n\n\tfunction update_q() {\n\t\tpage.url.searchParams.set('q', 'updated');\n\t\tgoto(page.url);\n\t}\n</script>\n\n<h1>{data.q}</h1>\n<button on:click={update_q}>update q</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/no-server-load/+layout.svelte",
    "content": "<a href=\"/load/no-server-load/a\">a</a>\n<a href=\"/load/no-server-load/b\">b</a>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/no-server-load/a/+page.server.js",
    "content": "export const ssr = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/no-server-load/a/+page.svelte",
    "content": "<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/no-server-load/b/+page.server.js",
    "content": "export const ssr = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/no-server-load/b/+page.svelte",
    "content": "<h1>b</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/server/+layout.server.js",
    "content": "/** @type {import('./$types').LayoutServerLoad} */\nexport async function load() {\n\treturn {\n\t\tmessage: 'original'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/server/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/server/[x]/+layout.server.js",
    "content": "/** @type {import('./$types').LayoutServerLoad} */\nexport async function load({ params, parent }) {\n\tconst data = await parent();\n\treturn {\n\t\tmessage: `${data.message} + new`,\n\t\tx: params.x,\n\t\ty: params.y\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/server/[x]/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/server/[x]/[y]/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/server/[x]/[y]/[z]/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport async function load({ params, parent }) {\n\tconst { y } = await parent();\n\treturn {\n\t\ty: `${y} edited`,\n\t\tz: params.z\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/server/[x]/[y]/[z]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>message: {page.data.message}</h1>\n<pre>{JSON.stringify(page.data)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/shared/+layout.js",
    "content": "/** @type {import('./$types').LayoutLoad} */\nexport async function load() {\n\treturn {\n\t\tmessage: 'original'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/shared/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/shared/[x]/+layout.js",
    "content": "/** @type {import('./$types').LayoutLoad} */\nexport async function load({ params, parent }) {\n\tconst data = await parent();\n\treturn {\n\t\tmessage: `${data.message} + new`,\n\t\tx: params.x,\n\t\ty: params.y\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/shared/[x]/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/shared/[x]/[y]/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/shared/[x]/[y]/[z]/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ params, parent }) {\n\tconst { y } = await parent();\n\treturn {\n\t\ty: `${y} edited`,\n\t\tz: params.z\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/parent/shared/[x]/[y]/[z]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>message: {page.data.message}</h1>\n<pre>{JSON.stringify(page.data)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/props/+page.js",
    "content": "export async function load() {\n\tconst message = 'Hello from Index!';\n\treturn { message };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/props/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h3>Index</h3>\n\n<p>Data: {data.message}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/raw-body/+page.svelte",
    "content": "<a href=\"/load/raw-body/dataview\">DataView</a>\n<a href=\"/load/raw-body/string\">String</a>\n<a href=\"/load/raw-body/uint8array\">Uint8Array</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/raw-body/dataview/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst data = new TextEncoder().encode('{ \"oddly\" : { \"formatted\" : \"json\" } }');\n\tconst res = await fetch('/load/raw-body.json', {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'content-type': 'application/octet-stream'\n\t\t},\n\t\tbody: new DataView(data.buffer, data.byteOffset, data.byteLength)\n\t});\n\n\treturn await res.json();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/raw-body/dataview/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<pre class=\"parsed\">{JSON.stringify(data.body)}</pre>\n<pre class=\"raw\">{data.rawBody}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/raw-body/string/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/raw-body.json', {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'content-type': 'application/json'\n\t\t},\n\t\tbody: '{ \"oddly\" : { \"formatted\" : \"json\" } }'\n\t});\n\n\treturn await res.json();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/raw-body/string/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<pre class=\"parsed\">{JSON.stringify(data.body)}</pre>\n<pre class=\"raw\">{data.rawBody}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/raw-body/uint8array/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/raw-body.json', {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'content-type': 'application/octet-stream'\n\t\t},\n\t\tbody: new TextEncoder().encode('{ \"oddly\" : { \"formatted\" : \"json\" } }')\n\t});\n\n\treturn await res.json();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/raw-body/uint8array/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<pre class=\"parsed\">{JSON.stringify(data.body)}</pre>\n<pre class=\"raw\">{data.rawBody}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/raw-body.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport async function POST({ request }) {\n\tconst rawBody = await request.text();\n\tconst body = JSON.parse(rawBody);\n\n\treturn json({\n\t\tbody,\n\t\trawBody\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/relay/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/relay.json');\n\treturn {\n\t\tanswer: await res.json()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/relay/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/relay.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json('42');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch, data, url }) {\n\tconst { a } = data;\n\n\tconst res = await fetch(new URL('/load/serialization/fetched-from-shared.json', url.origin));\n\tconst { b } = await res.json();\n\n\t// check that this doesn't mutate the original object\n\t// and make the server data unserializable\n\t// @ts-expect-error\n\tdata.sum = () => a + b;\n\n\t// @ts-expect-error\n\treturn { a, b, c: data.sum() };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/serialization/fetched-from-server.json');\n\tconst { a } = await res.json();\n\treturn { a };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.a} + {data.b} = {data.c}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization/fetched-from-server.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\treturn json({ a: 1 });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization/fetched-from-shared.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\treturn json({ b: 2 });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization-empty-node/+error.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization-empty-node/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load() {\n\treturn { answer: 42 };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization-empty-node/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization-post/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\t/** @param {string} body */\n\tasync function post(body) {\n\t\tconst res = await fetch('/load/serialization-post.json', {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'text/plain'\n\t\t\t},\n\t\t\tbody\n\t\t});\n\n\t\treturn await res.text();\n\t}\n\tconst a = await post('x');\n\tconst b = await post('y');\n\n\treturn { a, b };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization-post/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>a: {data.a}</h1>\n<h2>b: {data.b}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization-post-request/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ url, fetch }) {\n\t/** @param {string} body */\n\tasync function post(body) {\n\t\tconst request = new Request(url.origin + '/load/serialization-post.json', {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'text/plain'\n\t\t\t},\n\t\t\tbody\n\t\t});\n\t\tconst res = await fetch(request);\n\n\t\treturn await res.text();\n\t}\n\tconst a = await post('x');\n\tconst b = await post('y');\n\n\treturn { a, b };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization-post-request/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>a: {data.a}</h1>\n<h2>b: {data.b}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/serialization-post.json/+server.js",
    "content": "/** @type {import('@sveltejs/kit').RequestHandler} */\nexport async function POST({ request }) {\n\tconst body = await request.text();\n\treturn new Response(body.toUpperCase());\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-data-nostore/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ url }) {\n\treturn {\n\t\tx: url.searchParams.get('x')\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-data-nostore/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>x: {data.x}</h1>\n<a href=\"/load/server-data-nostore?x=2\">2</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-data-reuse/no-load/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p>Page without load</p>\n\n<pre>{JSON.stringify(data)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-changing-parent/+layout.server.js",
    "content": "/** @type {import('./$types').LayoutServerLoad} */\nexport function load(input) {\n\treturn {\n\t\ttitle: input.url.pathname\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-changing-parent/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-changing-parent/no-load/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p>Page without load</p>\n\n<pre>{JSON.stringify(data)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-changing-parent/with-server-load/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load() {\n\treturn { server: true };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-changing-parent/with-server-load/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p>Page with server load</p>\n\n<pre>{JSON.stringify(data)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-server-load/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load() {\n\treturn { server: true };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-server-load/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p>Page with server load</p>\n\n<pre>{JSON.stringify(data)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-fetch-request/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ url, fetch }) {\n\tconst href = `http://localhost:${url.searchParams.get('port')}/server-fetch-request.json`;\n\n\tconst res = await fetch(href);\n\tconst { answer } = await res.json();\n\treturn { answer };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-fetch-request/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>the answer is {data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-log-search-param/+page.server.js",
    "content": "export function load({ url }) {\n\tconsole.log(url.searchParams);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-log-search-param/+page.svelte",
    "content": "<p>hello world</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-response-clone/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ url, fetch }) {\n\tconst href = new URL(url);\n\thref.pathname = '';\n\n\tconst res = await fetch(href);\n\tconst clonedRes = res.clone();\n\treturn { text: await clonedRes.text() };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/server-response-clone/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>the text is:</h1>\n\n<p>\n\t{data.text}\n</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/set-cookie-fetch/+page.js",
    "content": "export async function load({ fetch, url }) {\n\tawait fetch(`/load/set-cookie-fetch/a.json${url.search}`);\n\tconst res = await fetch('/load/set-cookie-fetch/b.json');\n\tconst { answer } = await res.json(); // need to read the response so it gets serialized\n\n\treturn { answer };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/set-cookie-fetch/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>the answer is {data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/set-cookie-fetch/a.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET({ url }) {\n\tconst answer = url.searchParams.get('answer') || '42';\n\n\treturn json(\n\t\t{},\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'set-cookie': `answer=${answer}; HttpOnly; Path=/load/set-cookie-fetch`\n\t\t\t}\n\t\t}\n\t);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/set-cookie-fetch/b.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET({ cookies }) {\n\tconst answer = +cookies.get('answer');\n\n\treturn json(\n\t\t{ answer },\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'set-cookie': `doubled=${answer * 2}; HttpOnly; Path=/load/set-cookie-fetch`\n\t\t\t}\n\t\t}\n\t);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/state.js",
    "content": "const counters = Object.create(null);\n\n/**\n * @param {string} import_meta_url (use import.meta.url)\n * @returns {number}\n */\nexport function increment(import_meta_url) {\n\tif (counters[import_meta_url] == null) {\n\t\tcounters[import_meta_url] = 0;\n\t}\n\treturn counters[import_meta_url]++;\n}\n\n/**\n * must be called from `foo/reset-states/+server.js`, resets all counters in foo\n * @param {string} import_meta_url\n */\nexport function reset_states(import_meta_url) {\n\tif (!import_meta_url.match(/reset-states\\/[+_]server\\.js$/)) {\n\t\t// allow _server for build entrypoint\n\t\tthrow new Error(\n\t\t\t'must be called from reset-states/+server.js but was called from ' + import_meta_url\n\t\t);\n\t}\n\tconst parent_dir = new URL(`${import_meta_url}/../..`).toString();\n\tObject.keys(counters)\n\t\t.filter((k) => k.startsWith(parent_dir))\n\t\t.forEach((k) => {\n\t\t\tcounters[k] = 0;\n\t\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/static-file-with-hash/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/load/assets/a#b.txt');\n\n\treturn {\n\t\tstatus: res.status\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/static-file-with-hash/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>status: {data.status}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged/+layout.server.js",
    "content": "import { increment } from './state.js';\n\nexport function load() {\n\treturn {\n\t\tcount: increment()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged/+layout.svelte",
    "content": "<!-- TODO remove this file post-https://github.com/sveltejs/kit/issues/5967 -->\n<slot />\n\n<ul>\n\t<li><a href=\"/load/unchanged/isolated/a\">/load/unchanged/isolated/a</a></li>\n\t<li><a href=\"/load/unchanged/isolated/b\">/load/unchanged/isolated/b</a></li>\n\t<li><a href=\"/load/unchanged/uses-parent/a\">/load/unchanged/uses-parent/a</a></li>\n\t<li><a href=\"/load/unchanged/uses-parent/b\">/load/unchanged/uses-parent/b</a></li>\n</ul>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged/+page.svelte",
    "content": "<a href=\"/load/unchanged/isolated/a\">isolated</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged/isolated/[slug]/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ params }) {\n\treturn {\n\t\tslug: params.slug\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged/isolated/[slug]/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>slug: {data.slug}</h1>\n<h2>count: {data.count}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged/state.js",
    "content": "let count = 0;\n\nexport function increment() {\n\treturn count++;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged-parent/+layout.server.js",
    "content": "import { increment } from './state.js';\n\nexport function load() {\n\treturn {\n\t\tcount: increment()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged-parent/+layout.svelte",
    "content": "<!-- TODO remove this file post-https://github.com/sveltejs/kit/issues/5967 -->\n<slot />\n\n<ul>\n\t<li><a href=\"/load/unchanged-parent/isolated/a\">/load/unchanged-parent/isolated/a</a></li>\n\t<li><a href=\"/load/unchanged-parent/isolated/b\">/load/unchanged-parent/isolated/b</a></li>\n\t<li><a href=\"/load/unchanged-parent/uses-parent/a\">/load/unchanged-parent/uses-parent/a</a></li>\n\t<li><a href=\"/load/unchanged-parent/uses-parent/b\">/load/unchanged-parent/uses-parent/b</a></li>\n</ul>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged-parent/+page.svelte",
    "content": "<a href=\"/load/unchanged-parent/uses-parent/a\">uses parent</a>\n<a href=\"/load/unchanged-parent/isolated/a\">isolated</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged-parent/state.js",
    "content": "let count = 0;\n\nexport function increment() {\n\treturn count++;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged-parent/uses-parent/[slug]/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport async function load({ params, parent }) {\n\tconst { count } = await parent();\n\n\treturn {\n\t\tdoubled: count * 2,\n\t\tslug: params.slug\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/unchanged-parent/uses-parent/[slug]/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>slug: {data.slug}</h1>\n<h2>count: {data.count}</h2>\n<h3>doubled: {data.doubled}</h3>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/url-hash/+page.js",
    "content": "export const load = ({ url }) => {\n\tconst hash = url.hash;\n\treturn { hash };\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/url-hash/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p id=\"hash\">\n\t{data.hash}\n</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/url-query-param/+page.js",
    "content": "export function load({ data, url }) {\n\treturn { ...data, currentClientState: url.searchParams.get('currentClientState') };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/url-query-param/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\ttextFromTheServer: 'This text comes from the server load function'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/url-query-param/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>Hello {page.data.currentClientState ?? ''}</h1>\n\n<p>{page.data.textFromTheServer}</p>\n\n<a href=\"/load/url-query-param?currentClientState=ABC\">ABC</a>\n<a href=\"/load/url-query-param?currentClientState=DEF\">DEF</a>\n<hr />\n<a href=\"/load/url-query-param\" data-sveltekit-reload>Reload site</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/url-to-string/+page.js",
    "content": "export const load = ({ url }) => {\n\turl.toString();\n\treturn {};\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/url-to-string/+page.svelte",
    "content": "<h1>I didn't break!</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/correct/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ url, fetch }) {\n\tconst res = await fetch(`${url.origin}/load/window-fetch/data.json`);\n\tconst { answer } = await res.json();\n\treturn { answer };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/correct/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/data.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\treturn json({\n\t\tanswer: 42\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/incorrect/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ url }) {\n\tconst res = await fetch(`${url.origin}/load/window-fetch/data.json`);\n\tconst { answer } = await res.json();\n\treturn { answer };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/incorrect/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/outside-load/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\timport { onMount } from 'svelte';\n\n\tlet answer = 0;\n\n\tonMount(async () => {\n\t\tconst res = await fetch(`${page.url.origin}/load/window-fetch/data.json`);\n\t\t({ answer } = await res.json());\n\t});\n</script>\n\n<h1>{answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/patching/+page.js",
    "content": "import { browser } from '$app/environment';\n\n/** @type {import('./$types').PageLoad} */\nexport async function load({ url, fetch }) {\n\t// simulate fetch being monkey-patched by a 3rd party library\n\t// run everything only in browser to avoid SSR caching\n\tif (browser) {\n\t\tconst original_fetch = window.fetch;\n\t\twindow.fetch = (input, init) => {\n\t\t\tconsole.log('Called a patched window.fetch');\n\t\t\treturn original_fetch(input, init);\n\t\t};\n\n\t\tconst res = await fetch(`${url.origin}/load/window-fetch/data.json`);\n\t\tconst { answer } = await res.json();\n\t\twindow.fetch = original_fetch;\n\t\treturn { answer };\n\t}\n\treturn {};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/patching/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/patching-server-load/+page.server.js",
    "content": "export async function load() {\n\treturn { msg: 'server load data' };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/patching-server-load/+page.svelte",
    "content": "<script>\n\timport { browser } from '$app/environment';\n\n\tif (browser) {\n\t\tconst original_fetch = window.fetch;\n\t\twindow.fetch = (input, init) => {\n\t\t\tconsole.log('Called a patched window.fetch for server load request');\n\t\t\treturn original_fetch(input, init);\n\t\t};\n\t}\n</script>\n\n<p>\n\tThe sole purpose of this page is to apply a `window.fetch` patch before navigating to the next\n\tpage. Click the link below to navigate to the next page with a server load function.\n</p>\n\n<a href=\"./patching-server-load-ii\">Go To Page with Server Load</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/patching-server-load-ii/+page.server.js",
    "content": "export async function load() {\n\treturn { msg: 'server load data' };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/load/window-fetch/patching-server-load-ii/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p>\n\tThis page makes a fetch request to the server to get the data from the server load function when\n\tusers navigate to it.\n</p>\n\n<h1>{data.msg}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/match/+page.server.js",
    "content": "import { match } from '$app/paths';\nimport { testPaths } from './const';\n\nexport async function load() {\n\tconst serverResults = await Promise.all(\n\t\ttestPaths.map(async (path) => ({ path, result: await match(path) }))\n\t);\n\n\treturn {\n\t\tserverResults\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/match/+page.svelte",
    "content": "<script>\n\timport { match } from '$app/paths';\n\timport { onMount } from 'svelte';\n\timport { testPaths } from './const';\n\n\tlet { data } = $props();\n\n\tconst clientResults = $state([]);\n\n\tonMount(async () => {\n\t\tfor (const path of testPaths) {\n\t\t\tconst result = await match(path);\n\t\t\tclientResults.push({ path, result });\n\t\t}\n\t});\n</script>\n\n<h1>Match Test</h1>\n\n<div id=\"server-results\">\n\t{#each data.serverResults as { path, result }}\n\t\t<div class=\"result\" data-path={path}>\n\t\t\t{JSON.stringify(result)}\n\t\t</div>\n\t{/each}\n</div>\n\n<div id=\"client-results\">\n\t{#each clientResults as { path, result }}\n\t\t<div class=\"result\" data-path={path}>\n\t\t\t{JSON.stringify(result)}\n\t\t</div>\n\t{/each}\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/match/const.ts",
    "content": "export const testPaths = [\n\t'/match/load/foo',\n\t'/match/slug/test-slug',\n\t'/match/slug/test-slug?from=query',\n\t'/match/not-a-real-route-that-exists',\n\t'/reroute/basic/a'\n];\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/match/load/foo/+page.svelte",
    "content": "bar\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/match/slug/[slug]/+page.svelte",
    "content": "slug\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/after-navigate/a/+page.svelte",
    "content": "<script>\n\timport { afterNavigate } from '$app/navigation';\n\n\t/** @type {import('@sveltejs/kit').NavigationTarget | null} */\n\tlet from;\n\n\t/** @type {import('@sveltejs/kit').NavigationTarget} */\n\tlet to;\n\n\tafterNavigate((navigation) => {\n\t\tfrom = navigation.from;\n\t\tto = navigation.to;\n\t});\n</script>\n\n<h1>{`${from?.url.pathname} -> ${to?.url.pathname}`}</h1>\n<a href=\"/navigation-lifecycle/after-navigate/b\">/b</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/after-navigate/b/+page.svelte",
    "content": "<script>\n\timport { afterNavigate } from '$app/navigation';\n\n\t/** @type {import('@sveltejs/kit').NavigationTarget | null} */\n\tlet from;\n\n\t/** @type {import('@sveltejs/kit').NavigationTarget} */\n\tlet to;\n\n\tafterNavigate((navigation) => {\n\t\tfrom = navigation.from;\n\t\tto = navigation.to;\n\t});\n</script>\n\n<h1>{from?.url.pathname} -> {to?.url.pathname}</h1>\n<a href=\"/navigation-lifecycle/after-navigate/a\">/a</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/after-navigate-properly-removed/+layout.svelte",
    "content": "<script>\n\timport { onNavigate } from '$app/navigation';\n\tlet { children } = $props();\n\n\tonNavigate(() => {\n\t\treturn () => {};\n\t});\n</script>\n\n{@render children()}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/after-navigate-properly-removed/a/+page.svelte",
    "content": "<script>\n\timport { afterNavigate } from '$app/navigation';\n\n\tafterNavigate(() => {\n\t\tconsole.log('after navigate called');\n\n\t\t/**\n\t\t * @type {HTMLElement}\n\t\t */\n\t\tconst el = document.querySelector('.nav-lifecycle-after-nav-removed-test-target');\n\n\t\tif (el) {\n\t\t\tel.innerText = 'true';\n\t\t}\n\t});\n</script>\n\n<h1>/A</h1>\n<a href=\"/navigation-lifecycle/after-navigate-properly-removed/a\">/a</a>\n<a href=\"/navigation-lifecycle/after-navigate-properly-removed/b\">/b</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/after-navigate-properly-removed/b/+page.svelte",
    "content": "<h1>/B</h1>\n<div>\n\twas called:\n\t<span class=\"nav-lifecycle-after-nav-removed-test-target\">false</span>\n</div>\n<a href=\"/navigation-lifecycle/after-navigate-properly-removed/a\">/a</a>\n<a href=\"/navigation-lifecycle/after-navigate-properly-removed/b\">/b</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/before-navigate/a/+page.svelte",
    "content": "<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/before-navigate/complete/+page.svelte",
    "content": "<script>\n\timport { beforeNavigate } from '$app/navigation';\n\n\tbeforeNavigate(({ complete }) => {\n\t\tcomplete.then(() => {\n\t\t\tconsole.log('complete');\n\t\t});\n\t});\n</script>\n\n<a href=\"/navigation-lifecycle/before-navigate/redirect\">redirect</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/before-navigate/event/+layout.svelte",
    "content": "<script>\n\timport { beforeNavigate } from '$app/navigation';\n\n\tlet { children } = $props();\n\n\tbeforeNavigate((navigation) => {\n\t\tif (navigation.type === 'link' || navigation.type === 'popstate') {\n\t\t\tconsole.log(\n\t\t\t\t`${navigation.event.type} ${navigation.from.url.pathname} -> ${navigation.to.url.pathname}`\n\t\t\t);\n\t\t}\n\t});\n</script>\n\n<a href=\"/navigation-lifecycle/before-navigate/event/a\">a</a>\n<a href=\"/navigation-lifecycle/before-navigate/event/b\">b</a>\n\n{@render children()}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/before-navigate/event/a/+page.svelte",
    "content": "<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/before-navigate/event/b/+page.svelte",
    "content": "<h1>b</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/before-navigate/hash-links/+page.svelte",
    "content": "<script>\n\timport { beforeNavigate } from '$app/navigation';\n\n\tlet before_navigate_ran = false;\n\n\tbeforeNavigate(() => {\n\t\tbefore_navigate_ran = true;\n\t});\n</script>\n\n<h1>before_navigate_ran: {before_navigate_ran}</h1>\n<a href=\"#x\">x</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/before-navigate/prevent-navigation/+page.svelte",
    "content": "<script>\n\timport { beforeNavigate } from '$app/navigation';\n\n\tlet times_triggered = 0;\n\tlet unload = false;\n\tlet navigation_type;\n\tbeforeNavigate(({ cancel, type, willUnload, to }) => {\n\t\ttimes_triggered++;\n\t\tunload = willUnload;\n\t\tnavigation_type = type;\n\t\tif (!to?.route.id?.includes('redirect')) {\n\t\t\tcancel();\n\t\t}\n\t});\n</script>\n\n<h1>prevent navigation</h1>\n<a href=\"/navigation-lifecycle/before-navigate/a\">a</a>\n<a href=\"/navigation-lifecycle/before-navigate/redirect\">redirect</a>\n<a href=\"/navigation-lifecycle/before-navigate/prevent-navigation?x=1\">self</a>\n<a href=\"https://google.com\" target=\"_blank\" rel=\"noreferrer\">_blank</a>\n<a href=\"https://google.de\">external</a>\n<!-- svelte-ignore a11y-invalid-attribute -->\n<a download href=\"\">external</a>\n<pre>{times_triggered} {unload} {`${navigation_type}`}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/before-navigate/redirect/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function load() {\n\tredirect(307, '/navigation-lifecycle/before-navigate/prevent-navigation');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/on-navigate/[x]/+page.svelte",
    "content": "<script>\n\timport { onNavigate } from '$app/navigation';\n\n\t/** @type {import('@sveltejs/kit').NavigationTarget} */\n\tlet from;\n\n\t/** @type {import('@sveltejs/kit').NavigationTarget} */\n\tlet to;\n\n\t/** @type {Omit<import('@sveltejs/kit').NavigationType, 'enter' | 'leave'>} */\n\tlet type;\n\n\tlet called_return = false;\n\n\tonNavigate((navigation) => {\n\t\tfrom = navigation.from;\n\t\tto = navigation.to;\n\t\ttype = navigation.type;\n\t});\n\n\tonNavigate(() => {\n\t\treturn () => {\n\t\t\tcalled_return = true;\n\t\t};\n\t});\n</script>\n\n<h1>{`${from?.url.pathname} -> ${to?.url.pathname}`} ({type ?? '...'}) {called_return}</h1>\n<a href=\"/navigation-lifecycle/on-navigate/b\">/b</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/scroll-state/a/+page.svelte",
    "content": "<script>\n\timport { beforeNavigate, onNavigate, afterNavigate } from '$app/navigation';\n\n\tbeforeNavigate((navigation) => {\n\t\tconsole.log(\n\t\t\t'beforeNavigate:' +\n\t\t\t\tJSON.stringify({\n\t\t\t\t\tfromScroll: navigation.from?.scroll,\n\t\t\t\t\ttoScroll: navigation.to?.scroll,\n\t\t\t\t\ttype: navigation.type\n\t\t\t\t})\n\t\t);\n\t});\n\n\tonNavigate((navigation) => {\n\t\tconsole.log(\n\t\t\t'onNavigate:' +\n\t\t\t\tJSON.stringify({\n\t\t\t\t\tfromScroll: navigation.from?.scroll,\n\t\t\t\t\ttoScroll: navigation.to?.scroll,\n\t\t\t\t\ttype: navigation.type\n\t\t\t\t})\n\t\t);\n\t});\n\n\tafterNavigate((navigation) => {\n\t\tconsole.log(\n\t\t\t'afterNavigate:' +\n\t\t\t\tJSON.stringify({\n\t\t\t\t\tfromScroll: navigation.from?.scroll,\n\t\t\t\t\ttoScroll: navigation.to?.scroll,\n\t\t\t\t\ttype: navigation.type\n\t\t\t\t})\n\t\t);\n\t});\n</script>\n\n<h1>Page A</h1>\n\n<div style=\"height: 100vh; background: linear-gradient(teal, cyan)\"></div>\n\n<a id=\"to-b\" href=\"/navigation-lifecycle/scroll-state/b\">Go to B</a>\n\n<div style=\"height: 100vh; background: linear-gradient(cyan, blue)\"></div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/navigation-lifecycle/scroll-state/b/+page.svelte",
    "content": "<script>\n\timport { beforeNavigate, onNavigate, afterNavigate } from '$app/navigation';\n\n\tbeforeNavigate((navigation) => {\n\t\tconsole.log(\n\t\t\t'beforeNavigate:' +\n\t\t\t\tJSON.stringify({\n\t\t\t\t\tfromScroll: navigation.from?.scroll,\n\t\t\t\t\ttoScroll: navigation.to?.scroll,\n\t\t\t\t\ttype: navigation.type\n\t\t\t\t})\n\t\t);\n\t});\n\n\tonNavigate((navigation) => {\n\t\tconsole.log(\n\t\t\t'onNavigate:' +\n\t\t\t\tJSON.stringify({\n\t\t\t\t\tfromScroll: navigation.from?.scroll,\n\t\t\t\t\ttoScroll: navigation.to?.scroll,\n\t\t\t\t\ttype: navigation.type\n\t\t\t\t})\n\t\t);\n\t});\n\n\tafterNavigate((navigation) => {\n\t\tconsole.log(\n\t\t\t'afterNavigate:' +\n\t\t\t\tJSON.stringify({\n\t\t\t\t\tfromScroll: navigation.from?.scroll,\n\t\t\t\t\ttoScroll: navigation.to?.scroll,\n\t\t\t\t\ttype: navigation.type\n\t\t\t\t})\n\t\t);\n\t});\n</script>\n\n<h1>Page B</h1>\n\n<div style=\"height: 100vh; background: linear-gradient(orange, yellow)\"></div>\n\n<a id=\"to-a\" href=\"/navigation-lifecycle/scroll-state/a\">Go to A</a>\n\n<div style=\"height: 100vh; background: linear-gradient(yellow, red)\"></div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/+layout.svelte",
    "content": "<slot />\n<p id=\"nested\">This is a nested layout component</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/+page.svelte",
    "content": "<h1>Hello from inside the nested layout component</h1>\n\n<div>\n\t<a href=\"/nested-layout/error\">error</a>\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/error/+page.js",
    "content": "import { error } from '@sveltejs/kit';\n\nexport function load() {\n\terror(500, 'Error');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/error/+page.svelte",
    "content": "<h1>Not shown</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/foo/+layout.svelte",
    "content": "<slot />\n<p id=\"nested-foo\">Nested layout foo</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/foo/bar/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>Nested error page</h1>\n<p id=\"nested-error-status\">status: {page.status}</p>\n<p id=\"nested-error-message\">error.message: {page.error.message}</p>\n\n<style>\n\th1 {\n\t\tcolor: blue;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/foo/bar/+layout.svelte",
    "content": "<slot />\n<p id=\"nested-bar\">Nested layout bar</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/foo/bar/nope/+page.js",
    "content": "export async function load() {\n\tthrow new Error('nope');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/foo/bar/nope/+page.svelte",
    "content": "<h1>should not see this</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/foo/baz/+page.svelte",
    "content": "<p id=\"baz\">baz</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/reset/+layout@.svelte",
    "content": "<h1>Layout reset</h1>\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/nested-layout/reset/+page.svelte",
    "content": "<h2>Hello</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-csr/+page.js",
    "content": "export const csr = false;\n\n/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/no-csr/data.json');\n\treturn await res.json();\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-csr/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>look ma no javascript</h1>\n<p>type: {data.type}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-csr/data.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json({\n\t\ttype: 'no-csr'\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/+layout.js",
    "content": "export const ssr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/+layout.svelte",
    "content": "<slot />;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/+page.svelte",
    "content": "<h1>content was rendered</h1>\n\n<a href=\"/no-ssr/other\">other</a>\n\n<style>\n\th1 {\n\t\tcolor: red;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/after-navigate/+page.svelte",
    "content": "<script>\n\timport { afterNavigate } from '$app/navigation';\n\n\tlet count = 0;\n\tlet type = '';\n\n\tafterNavigate((event) => {\n\t\tcount += 1;\n\t\ttype = event.type;\n\t});\n</script>\n\n<p>{type.toString()} {count}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/browser-only-global/+page.svelte",
    "content": "<script context=\"module\">\n\tdocument;\n</script>\n\n{document}\n\n<p>Works</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/margin/+page.svelte",
    "content": "<div class=\"container\">\n\t<span> ^this is not the top of the screen</span>\n\t<div class=\"spacer\"></div>\n</div>\n\n<style>\n\t.container {\n\t\tmargin-top: 300px;\n\t}\n\n\t.spacer {\n\t\theight: 1000px;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/other/+page.svelte",
    "content": "<h1>other</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/ssr-page-config/+page.js",
    "content": "export const ssr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/ssr-page-config/+page.svelte",
    "content": "<script context=\"module\">\n\tdocument;\n</script>\n\n{document}\n\n<p>Works</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/ssr-page-config/layout/+layout.js",
    "content": "export const ssr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/ssr-page-config/layout/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/ssr-page-config/layout/inherit/+page.svelte",
    "content": "<script context=\"module\">\n\tdocument;\n</script>\n\n{document}\n\n<p>Works</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/ssr-page-config/layout/overwrite/+page.js",
    "content": "export const ssr = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/no-ssr/ssr-page-config/layout/overwrite/+page.svelte",
    "content": "<script context=\"module\">\n\tdocument;\n</script>\n\n{document}\n\n<p>You shouldn't see this</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/node-analysis/+page.js",
    "content": "// this universal file causes the server node to be evaluated during static analysis\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/node-analysis/+page.server.js",
    "content": "// this module is evaluated when building the server nodes to determine its page options\n// Therefore, we need to ensure $env, etc. still works during this process so that it doesn't throw errors\n// when it's evaluated as `undefined`\n\nimport { env } from '$env/dynamic/public';\n\nif (!env.PUBLIC_DYNAMIC) {\n\tthrow Error('this should not happen');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/node-analysis/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/origin/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.url.origin}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/package.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json({\n\t\tworks: true\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/params-prop/+layout.svelte",
    "content": "<script>\n\tlet { children } = $props();\n</script>\n\n<a href=\"/params-prop/123\">123</a>\n<a href=\"/params-prop/456\">456</a>\n\n{@render children()}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/params-prop/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/params-prop/[x]/+page.svelte",
    "content": "<script>\n\tlet { params } = $props();\n</script>\n\n<p>x: {params.x}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/paths/+page.svelte",
    "content": "<script>\n\timport { base, assets } from '$app/paths';\n</script>\n\n<pre>{JSON.stringify({ base, assets })}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/paths/deeply/nested/+page.svelte",
    "content": "<script>\n\timport { base, assets } from '$app/paths';\n</script>\n\n<pre>{JSON.stringify({ base, assets })}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\tconst title = $derived(`${page.status}: ${page.error.message}`);\n</script>\n\n<h1>{title}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/env/+layout.svelte",
    "content": "<a href=\"/prerendering/env/prerendered\">prerendered</a>\n<a href=\"/prerendering/env/dynamic\">dynamic</a>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/env/dynamic/+page.svelte",
    "content": "<script>\n\timport { env } from '$env/dynamic/public';\n</script>\n\n<h2>prerendering: {env.PUBLIC_PRERENDERING}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/env/prerendered/+page.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/env/prerendered/+page.svelte",
    "content": "<h2>prerendered</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/log-url/+page.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/log-url/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\tlet error = false;\n\n\ttry {\n\t\tconsole.log(page);\n\t} catch (e) {\n\t\terror = true;\n\t}\n</script>\n\n<p>error: {error}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/mutative-endpoint/+page.js",
    "content": "export const prerender = 'auto';\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/mutative-endpoint/+page.server.ts",
    "content": "export const actions = {};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/mutative-endpoint/+page.svelte",
    "content": "<h1>I have a mutative endpoint!</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/no-ssr/+page.js",
    "content": "export const prerender = true;\nexport const ssr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/no-ssr/+page.svelte",
    "content": "<h1>Hello world!</h1>\n<p>{window.location.origin}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/prerendered-endpoint/+page.svelte",
    "content": "<a href=\"/prerendering/prerendered-endpoint/from-handle-hook\">through handle hook</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/prerendered-endpoint/api/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport const prerender = true;\n\nexport function GET() {\n\treturn json({ message: 'Im prerendered and called from a non-prerendered +page.server.js' });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/prerendered-endpoint/api-with-param/[option]/+server.js",
    "content": "import { building, dev } from '$app/environment';\nimport { error, json } from '@sveltejs/kit';\n\nexport const prerender = 'auto';\n\nexport function entries() {\n\treturn [\n\t\t{\n\t\t\toption: 'prerendered'\n\t\t}\n\t];\n}\n\nexport async function GET({ params: { option } }) {\n\tif ((await entries()).find((entry) => entry.option === option)) {\n\t\tif (dev || building) {\n\t\t\treturn json({ message: 'Im prerendered and called from a non-prerendered +page.server.js' });\n\t\t} else {\n\t\t\terror(500, 'I should not be called at runtime because I am prerendered');\n\t\t}\n\t}\n\treturn json({ message: 'Im not prerendered' });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/prerendered-endpoint/page/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/prerendering/prerendered-endpoint/api');\n\tconst json = await res.json();\n\treturn json;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/prerendered-endpoint/page/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>{data.message}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/prerendered-endpoint/proxy/+server.js",
    "content": "export async function GET({ fetch, url }) {\n\tif (url.searchParams.get('api-with-param-option') === 'prerendered') {\n\t\treturn await fetch('/prerendering/prerendered-endpoint/api-with-param/prerendered');\n\t}\n\n\treturn await fetch('/prerendering/prerendered-endpoint/api');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/中文/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/prerendering/中文/+page.ts",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/query/echo/+page.js",
    "content": "import { to_pojo } from './utils.js';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load({ url }) {\n\treturn {\n\t\tvalues: to_pojo(url.searchParams)\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/query/echo/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\timport { to_pojo } from './utils.js';\n\n\t/** @type {{ data: import('./$types').PageData }} */\n\tlet { data } = $props();\n</script>\n\n<pre id=\"one\">{JSON.stringify(data.values)}</pre>\n<pre id=\"two\">{JSON.stringify(to_pojo(page.url.searchParams))}</pre>\n\n<a href=\"/query/echo?bar=2\">?bar=2</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/query/echo/utils.js",
    "content": "/** @typedef {Record<string, string[]>} Query */\n\n/** @param {URLSearchParams} query */\nexport function to_pojo(query) {\n\t/** @type {Query}*/\n\tconst values = {};\n\n\tquery.forEach((value, key) => {\n\t\tif (!(key in values)) values[key] = [];\n\t\tvalues[key].push(value);\n\t});\n\n\treturn values;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/read-file/+page.server.js",
    "content": "import { dev } from '$app/environment';\nimport { read } from '$app/server';\nimport auto from './[auto].txt';\nimport url from './[url].txt?url';\nimport styles from './[styles].css?url';\n\n/** @type {Record<string, { default: string }>} */\nconst local_glob = import.meta.glob('./assets/**', {\n\tquery: '?url',\n\teager: true\n});\n\n/** @type {Record<string, { default: string }>} */\nconst external_glob = import.meta.glob('../../../../read-file-test/**', {\n\tquery: '?url',\n\teager: true\n});\n\nexport async function load() {\n\tif (!dev && !auto.startsWith('data:')) {\n\t\tthrow new Error('expected auto.txt to be inlined');\n\t}\n\n\treturn {\n\t\tauto: await read(auto).text(),\n\t\turl: await read(url).text(),\n\t\tstyles: await read(styles).text(),\n\t\tlocal_glob: await read(local_glob['./assets/[file].txt'].default).text(),\n\t\texternal_glob: await read(Object.values(external_glob)[0].default).text(),\n\t\tsvg: await read(local_glob['./assets/icon.svg'].default).text()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/read-file/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p data-testid=\"auto\">{data.auto}</p>\n<p data-testid=\"url\">{data.url}</p>\n<p data-testid=\"styles\">{data.styles}</p>\n<p data-testid=\"local_glob\">{data.local_glob}</p>\n<p data-testid=\"external_glob\">{data.external_glob}</p>\n<div data-testid=\"svg\">{@html data.svg}</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/read-file/[auto].txt",
    "content": "Imported without ?url 😎\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/read-file/[styles].css",
    "content": ".logo {\n\tbackground: url(../asset-import/large.jpg);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/read-file/[url].txt",
    "content": "Imported with ?url 😎\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/read-file/assets/[file].txt",
    "content": "Imported with ?url via glob 😎\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/+page.svelte",
    "content": "<h1>redirects</h1>\n<a href=\"/redirect/a\">a</a>\n<a href=\"/redirect/b\">b</a>\n\n<a href=\"/redirect/loopy/a\">a (loopy)</a>\n<a href=\"/redirect/loopy/b\">b (loopy)</a>\n\n<a href=\"/redirect/missing-status/a\">a (missing-status)</a>\n<a href=\"/redirect/missing-status/b\">b (missing-status)</a>\n\n<a href=\"/redirect/in-handle?throw\">in-handle (redirect)</a>\n<a href=\"/redirect/in-handle?response\">in-handle (return Response)</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/a/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function load() {\n\tredirect(307, './b');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/a/+page.svelte",
    "content": "<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/b/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function load() {\n\tredirect(307, './c');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/b/+page.svelte",
    "content": "<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/c/+page.svelte",
    "content": "<h1>c</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/in-handle/+page.server.js",
    "content": "export function load() {}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/in-handle/+page.svelte",
    "content": "<h1>in-handle</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/loopy/a/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function load() {\n\tredirect(307, './b');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/loopy/a/+page.svelte",
    "content": "<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/loopy/b/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function load() {\n\tredirect(307, './a');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/loopy/b/+page.svelte",
    "content": "<h1>b</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/missing-status/a/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function load() {\n\tredirect(undefined, './b');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/missing-status/a/+page.svelte",
    "content": "<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/missing-status/b/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function load() {\n\t// @ts-ignore\n\tredirect(555, './a');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/missing-status/b/+page.svelte",
    "content": "<h1>b</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect/package/+page.server.js",
    "content": "import { authenticate } from 'test-redirect-importer';\n\nexport function load() {\n\tauthenticate('/redirect/c');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect-on-load/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\nimport { browser } from '$app/environment';\n\nexport async function load() {\n\tif (browser) {\n\t\tredirect(303, '/redirect-on-load/redirected');\n\t}\n\n\treturn {};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect-on-load/+page.svelte",
    "content": "<h1>Woops!</h1>\n<p>You shouldn't be here. You should have been directed to /redirect!</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/redirect-on-load/redirected/+page.svelte",
    "content": "<h1>Hazaa!</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/api/+server.ts",
    "content": "import { text } from '@sveltejs/kit';\n\nexport function GET({ cookies }) {\n\treturn text(cookies.get('reroute-cookie') ? '/reroute/async/b' : '/reroute/async/a');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/api/[prerendered]/+server.ts",
    "content": "import { text } from '@sveltejs/kit';\n\n// This is inside a route with a route segment to ensure that the route is marked as prerendered\n// as part of reroute resolution even when no `entries` is given.\nexport const prerender = true;\n\nexport function GET() {\n\treturn text('/reroute/async/b');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/async/+page.svelte",
    "content": "<a href=\"/reroute/async/a\">Go to url that should be rewritten</a>\n<a href=\"/reroute/async/c\"\n\t>Go to url that should be rewritten and its reroute api call prerendered</a\n>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/async/+page.ts",
    "content": "// through this we test that the crawler during prerendering does not fail on\n// reroute calls that call non-prerendered endpoints.\nexport const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/async/a/+page.svelte",
    "content": "<h1>Should have been rewritten to <code>/reroute/async/b</code></h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/async/b/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>Successfully rewritten, URL should still show a: {page.url.pathname}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/basic/+page.svelte",
    "content": "<a href=\"/reroute/basic/a\">Go to url that should be rewritten</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/basic/a/+page.svelte",
    "content": "<h1>Should have been rewritten to <code>/reroute/basic/b</code></h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/basic/b/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>Successfully rewritten, URL should still show a: {page.url.pathname}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/client-only-redirect/+page.js",
    "content": "import { browser } from '$app/environment';\nimport { redirect } from '@sveltejs/kit';\n\nexport async function load() {\n\tif (browser) {\n\t\tredirect(302, '/reroute/client-only-redirect/a');\n\t}\n\n\treturn {};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/client-only-redirect/+page.svelte",
    "content": "<h1>Should be redirected</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/client-only-redirect/a/+page.svelte",
    "content": "<h1>Should have been rewritten to <code>/reroute/client-only-redirect/b</code></h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/client-only-redirect/b/+page.svelte",
    "content": "<h1>Successfully rewritten</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/error-handling/+page.svelte",
    "content": "<a href=\"/reroute/error-handling/client-error\" id=\"client-error\">Url with client error</a>\n<a href=\"/reroute/error-handling/server-error\" id=\"server-error\">Url with server error</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/error-handling/client-error/+page.svelte",
    "content": "<h1>\n\tThe rewrite on this page should fail in the browser, causing a full navigation that resolves to\n\t<code>/reroute/error-handling/client-error-rewritten</code>\n</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/error-handling/client-error-rewritten/+page.svelte",
    "content": "<h1>Full Navigation</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/error-handling/server-error/+page.svelte",
    "content": "<h1>Should be unreachable - 500 expected</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/external/+page.svelte",
    "content": "<a href=\"/reroute/external/rewritten\">Go to rewritten page</a>\n<a href=\"https://expired.badssl.com/\" data-test=\"external-url\">External Link</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/invalidate/+page.server.js",
    "content": "export function load({ isDataRequest }) {\n\treturn {\n\t\trequest: isDataRequest\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/invalidate/+page.svelte",
    "content": "<script>\n\timport { invalidateAll } from '$app/navigation';\n\n\texport let data;\n</script>\n\n<button on:click={async () => await invalidateAll()}>Invalidate</button>\n\n{#if data.request}\n\t<p>data request: {data.request}</p>\n{/if}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/preload-data/+page.svelte",
    "content": "<script>\n\timport { preloadData } from '$app/navigation';\n\tlet data = null;\n\n\tasync function onClick() {\n\t\tconst result = await preloadData('/reroute/preload-data/a');\n\t\tif (result.type === 'loaded') {\n\t\t\tdata = result.data;\n\t\t}\n\t}\n</script>\n\n<button on:click={onClick}>Preload</button>\n\n{#if data}\n\t<pre>{JSON.stringify(data, null, 2)}</pre>\n{/if}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/preload-data/a/+page.js",
    "content": "export async function load() {\n\treturn {\n\t\tsuccess: false\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/preload-data/b/+page.js",
    "content": "export async function load() {\n\treturn {\n\t\tsuccess: true\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/prerendered/+page.svelte",
    "content": "<a href=\"/reroute/prerendered/to-destination\">to prerendered page</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/prerendered/destination/+page.svelte",
    "content": "<h1>reroute that points to prerendered page works</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reroute/prerendered/destination/+page.ts",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reset-focus/+page.js",
    "content": "export const ssr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/reset-focus/+page.svelte",
    "content": "<button id=\"an:invalid+selector\">I have a weird ID but I should be focused</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>Great success!</h1>\n\n<a href=\"/routing/a\">a</a>\n<a href=\"/routing/ambiguous/ok.json\" rel=\"external\">ok</a>\n<a href=\"/routing/next-paint\">next-paint</a>\n<a href=\"/routing/symlink-from\">symlinked</a>\n<a href=\"http://localhost:{page.url.searchParams.get('port')}\">elsewhere</a>\n<a href=\"/static.json\">static.json</a>\n\n<a href=\"/routing/b\" data-sveltekit-reload>b</a>\n\n<div class=\"hydrate-test\"></div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/[slug]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.params.slug}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/a/+page.svelte",
    "content": "<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/ambiguous/[slug]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/ambiguous/[slug].json/+server.js",
    "content": "/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET(req) {\n\treturn new Response(req.params.slug);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/b/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst letter = await fetch('/routing/b.json').then((r) => r.json());\n\treturn { letter };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/b/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.letter}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/b.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json('b');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/cancellation/+layout.svelte",
    "content": "<slot />\n\n<a href=\"/routing/cancellation/a\">a</a>\n<a href=\"/routing/cancellation/b\">b</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/cancellation/+page.svelte",
    "content": "<h1>cancellation</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/cancellation/a/+page.js",
    "content": "import { browser } from '$app/environment';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load() {\n\tif (browser) {\n\t\tawait new Promise((f) => {\n\t\t\twindow.fulfil_navigation = f;\n\t\t});\n\t}\n\n\treturn {};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/cancellation/a/+page.svelte",
    "content": "<h1>this should not appear</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/cancellation/b/+page.svelte",
    "content": "<h1>b</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/client/bar/+page.svelte",
    "content": "<h1>bar</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/client/bar/b/+page.svelte",
    "content": "<h1>b</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/client/foo/+page.svelte",
    "content": "<h1>foo</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/const/+page.svelte",
    "content": "<h1>reserved words are okay as routes</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/content-negotiation/+page.server.js",
    "content": "export const actions = {\n\tdefault: () => {\n\t\treturn {\n\t\t\tsubmitted: true\n\t\t};\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/content-negotiation/+page.svelte",
    "content": "<script>\n\timport { enhance } from '$app/forms';\n\n\t/** @type {import('./$types').ActionData} */\n\texport let form;\n\n\tlet result;\n\n\t/** @param {string} method */\n\tasync function request(method) {\n\t\tresult = 'loading';\n\t\tconst response = await fetch('/routing/content-negotiation', { method });\n\t\tresult = await response.text();\n\t}\n</script>\n\n<p>Hi</p>\n<button on:click={() => request('GET')}>GET</button>\n<button on:click={() => request('PUT')}>PUT</button>\n<button on:click={() => request('PATCH')}>PATCH</button>\n<button on:click={() => request('POST')}>POST</button>\n<button on:click={() => request('DELETE')}>DELETE</button>\n<pre>{result}</pre>\n\n<form method=\"POST\" use:enhance>\n\t<button>Submit</button>\n</form>\n\n<p data-testid=\"form-result\">form.submitted: {form?.submitted}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/content-negotiation/+server.js",
    "content": "/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\treturn new Response('GET');\n}\n\n/** @type {import('./$types').RequestHandler} */\nexport function PUT() {\n\treturn new Response('PUT');\n}\n\n/** @type {import('./$types').RequestHandler} */\nexport function PATCH() {\n\treturn new Response('PATCH');\n}\n\n/** @type {import('./$types').RequestHandler} */\nexport function POST() {\n\treturn new Response('POST');\n}\n\n/** @type {import('./$types').RequestHandler} */\nexport function DELETE() {\n\treturn new Response('DELETE');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/dirs/bar/+page.svelte",
    "content": "<h1 class=\"bar\">bar</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/dirs/bar/[a]/+page.svelte",
    "content": "<h1>A page</h1>\n\n<a href=\"/routing/dirs/foo/xyz\">same segment</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/dirs/foo/+page.svelte",
    "content": "<h1>foo</h1>\n<a href=\"bar\">bar</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/dirs/foo/[b]/+page.svelte",
    "content": "<h1>B page</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/external-popstate/+page.svelte",
    "content": "<h1>hello</h1>\n\n<button\n\ton:click={() => {\n\t\thistory.pushState({}, '', '/routing/external-popstate/does-not-exist');\n\t}}>go to /routing/external-popstate/does-not-exist</button\n>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/focus/+page.svelte",
    "content": "<a href=\"/routing/focus/a#p\">click me!</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/focus/a/+page.svelte",
    "content": "<button>button 1</button>\n<button>button 2</button>\n<p id=\"p\">cannot be focused</p>\n<button id=\"button3\">button 3</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/form-get/+page.svelte",
    "content": "<script>\n\timport { afterNavigate } from '$app/navigation';\n\timport { page } from '$app/state';\n\n\tlet type = '...';\n\n\tafterNavigate((navigation) => {\n\t\ttype = /** @type {string} */ (navigation.type);\n\t});\n</script>\n\n<h1>{page.url.searchParams.get('q') ?? '...'}</h1>\n<h2>{type}</h2>\n<h3>{page.url.searchParams.get('foo') ?? '...'}</h3>\n\n<form>\n\t<input name=\"q\" />\n\t<button type=\"submit\" name=\"foo\" value=\"bar\">Submit</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/form-target-blank/+page.svelte",
    "content": "<form target=\"_blank\">\n\t<button>Inside form</button>\n</form>\n\n<form id=\"my-form\"></form>\n\n<button formtarget=\"_blank\" form=\"my-form\">Outside form</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/hashes/a/+page.svelte",
    "content": "<h1 id=\"hash-target\">a</h1>\n<a href=\"#hash-target\">hash link</a>\n<a href=\"/routing/hashes/b\">b</a>\n<a href=\"#replace-state\" data-sveltekit-replacestate>replace state</a>\n\n<a data-sveltekit-preload-data href=\"/routing/hashes/a\">/routing/hashes/a</a>\n<a data-sveltekit-preload-data href=\"#preload\">#preload</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/hashes/b/+page.svelte",
    "content": "<h1>b</h1>\n<button on:click={() => history.back()}>go back</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/hashes/base/+layout.svelte",
    "content": "<svelte:head>\n\t<base href=\"/\" />\n</svelte:head>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/hashes/base/+page.svelte",
    "content": "<a id=\"navigate\" href=\"/routing/hashes/base/a#x\">navigate</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/hashes/base/a/+page.svelte",
    "content": "<p id=\"x\">X</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/hashes/focus/+page.svelte",
    "content": "<a href=\"#example\">focus</a>\n<input id=\"example\" />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/hashes/pagestate/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\timport { onMount } from 'svelte';\n\n\t/** @type {string} */\n\tlet hash;\n\n\tonMount(set_hash);\n\n\tfunction set_hash() {\n\t\thash = window.location.hash;\n\t}\n</script>\n\n<svelte:window on:hashchange={set_hash} />\n\n<h1 id=\"window-hash\">{hash}</h1>\n<h1 id=\"page-url-hash\">{page.url.hash}</h1>\n\n<a href=\"#target\">Nav to hash</a>\n<a href=\"/routing/hashes/pagestate\">Nav to page</a>\n<div id=\"target\">Target</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/hashes/target/+page.svelte",
    "content": "<ol>\n\t<li><a href=\"#p1\">first paragraph</a></li>\n\t<li><a href=\"#p2\">second paragraph</a></li>\n</ol>\n\n<p tabindex=\"-1\" id=\"p1\">paragraph 1</p>\n<p tabindex=\"-1\" id=\"p2\">paragraph 2</p>\n\n<li><button>next focus element</button></li>\n\n<style>\n\tp:target {\n\t\tcolor: red;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/link-outside-app-target/source/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\timport { increment, count } from '../state.js';\n\n\tonMount(increment);\n</script>\n\n<h1>source: {count}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/link-outside-app-target/state.js",
    "content": "export let count = 0;\n\nexport function increment() {\n\tcount += 1;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/link-outside-app-target/target/+page.svelte",
    "content": "<script>\n\timport { count } from '../state.js';\n</script>\n\n<h1>target: {count}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/long-navigation/+page.svelte",
    "content": "<script>\n\timport { onNavigate } from '$app/navigation';\n\n\tonNavigate(() => new Promise((resolve) => setTimeout(resolve, 3000)));\n</script>\n\n<a href=\"/routing\">Go to routing</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/matched/+layout.svelte",
    "content": "<a href=\"/routing/matched/a\">/routing/matched/a</a>\n<a href=\"/routing/matched/B\">/routing/matched/B</a>\n<a href=\"/routing/matched/1\">/routing/matched/1</a>\n<a href=\"/routing/matched/everything-else\">/routing/matched/everything-else</a>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/matched/+page.svelte",
    "content": "<h1>Matchers</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/matched/[fallback]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>fallback: {page.params.fallback}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/matched/[letter=lowercase]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>lowercase: {page.params.letter}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/matched/[letter=uppercase]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>uppercase: {page.params.letter}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/matched/[number=numeric]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>number: {page.params.number}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/missing-href/+page.svelte",
    "content": "<script>\n\timport { afterNavigate } from '$app/navigation';\n\n\tlet count = 0;\n\n\tafterNavigate(() => {\n\t\tcount += 1;\n\t});\n</script>\n\n<!-- svelte-ignore a11y-missing-attribute -->\n<a data-testid=\"count\">count: {count}</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/next-paint/+page.svelte",
    "content": "<p>next-paint</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/params-in-handle/[x]/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET({ locals }) {\n\treturn json({\n\t\tkey: locals.key,\n\t\tparams: locals.params\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/preloading/hash-route/+page.js",
    "content": "let load_calls = 0;\n\nexport const load = () => {\n\tload_calls += 1;\n\treturn { calls: load_calls };\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/preloading/hash-route/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\timport { page } from '$app/state';\n\n\tlet { data } = $props();\n\n\tconst modal_contents = {\n\t\t'please-dont-show-me': {\n\t\t\ttitle: 'Oopsie'\n\t\t},\n\t\t'please-dont-show-me-jr': {\n\t\t\ttitle: 'Oopsie Jr.'\n\t\t}\n\t};\n\n\tlet modal = undefined;\n\n\tconst show_modal = () => {\n\t\tconst hash = page.url.hash.substring(1);\n\t\tmodal = modal_contents[hash];\n\t};\n\n\tonMount(show_modal);\n</script>\n\n<svelte:window on:popstate={show_modal} />\n\n<h1>{modal?.title ?? ''}</h1>\n<p>Loaded {data.calls} times.</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/preloading/preload-error/+page.js",
    "content": "let throw_error = false;\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load() {\n\tthrow_error = !throw_error;\n\tif (throw_error) {\n\t\tthrow new Error('error');\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/preloading/preload-error/+page.svelte",
    "content": "<p>hello</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/preloading/preloaded/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst message = await fetch('/routing/preloading/preloaded.json').then((r) => r.json());\n\treturn { message };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/preloading/preloaded/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.message}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/preloading/preloaded.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json('preloaded');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/prerendered/+layout.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/prerendered/trailing-slash/always/+page.js",
    "content": "export const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/prerendered/trailing-slash/always/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/prerendered/trailing-slash/ignore/+page.js",
    "content": "export const trailingSlash = 'ignore';\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/prerendered/trailing-slash/ignore/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/prerendered/trailing-slash/never/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/[...rest]/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport function load({ params }) {\n\tconst { rest } = params;\n\treturn { rest };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/[...rest]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\t/** @type {{ data: import('./$types').PageData }} */\n\tlet { data } = $props();\n</script>\n\n<h1>{page.params.rest}</h1>\n<h2>{data.rest}</h2>\n\n<a href=\"/routing/rest/xyz/abc/deep\">deep</a>\n<a href=\"/routing/rest/xyz/abc\">abc</a>\n<a href=\"/routing/rest/xyz/abc/def\">def</a>\n<a href=\"/routing/rest/xyz/abc/def/ghi\">ghi</a>\n<a href=\"/routing/rest\">empty</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/[...rest]/deep/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport function load({ params }) {\n\tconst { rest } = params;\n\treturn { rest };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/[...rest]/deep/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\t/** @type {{ data: import('./$types').PageData }} */\n\tlet { data } = $props();\n</script>\n\n<h1>{page.params.rest}</h1>\n<h2>{data.rest}</h2>\n\n<a href=\"/routing/rest/xyz/abc/qwe/deep.json\" rel=\"external\">deep</a>\n<a href=\"/routing/rest/xyz/abc\">back</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/[...rest]/deep.json/+server.js",
    "content": "/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET({ params }) {\n\treturn new Response(params.rest);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/complex/[...parts].json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET({ params }) {\n\treturn json({\n\t\tparts: params.parts\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/complex/prefix-[...parts]/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch, params }) {\n\tconst res = await fetch(`/routing/rest/complex/${params.parts}.json`);\n\tconst { parts } = await res.json();\n\treturn { parts };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/complex/prefix-[...parts]/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>parts: {data.parts}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/non-greedy/+layout.svelte",
    "content": "<h1>non-greedy</h1>\n\n<slot />\n\n<a href=\"/routing/rest/non-greedy/foo/one/two\">foo/one/two</a>\n<a href=\"/routing/rest/non-greedy/food/one/two\">food/one/two</a>\n<a href=\"/routing/rest/non-greedy/one-bar/two/three\">one-bar/two/three</a>\n<a href=\"/routing/rest/non-greedy/one-bard/two/three\">one-bard/two/three</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/non-greedy/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/non-greedy/[dynamic]-bar/[...rest]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h2>{JSON.stringify(page.params)}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/non-greedy/foo/[...rest]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h2>{JSON.stringify(page.params)}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/path/+layout.svelte",
    "content": "<a href=\"/routing/rest/path/one\">one</a>\n<a href=\"/routing/rest/path/two\">two</a>\n<a href=\"/routing/rest/path/three\">three</a>\n<a href=\"/routing/rest/path/four\">four</a>\n<a href=\"/routing/rest/path/five\">five</a>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/path/[...ignored]/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport function load({ url }) {\n\tconst { pathname: path } = url;\n\treturn { path };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/rest/path/[...ignored]/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>path: {data.path}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/route-id/+page.svelte",
    "content": "<a href=\"/routing/route-id/foo\">/routing/route-id/foo</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/route-id/[x]/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport function load({ route }) {\n\treturn { route };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/route-id/[x]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\t/** @type {{ data: import('./$types').PageData }} */\n\tlet { data } = $props();\n</script>\n\n<h1>route.id in load: {data.route.id}</h1>\n<h2>route.id in store: {page.route.id}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/shadow-dom/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\n\t/** @type {HTMLDivElement} */\n\tlet elem;\n\n\tonMount(() => {\n\t\tconst shadow = elem.attachShadow({ mode: 'open' });\n\t\tconst anchor = document.createElement('a');\n\t\tanchor.href = '/routing/a';\n\t\tanchor.innerHTML = '<slot>';\n\t\tshadow.appendChild(anchor);\n\t});\n</script>\n\n<div bind:this={elem}>\n\t<div id=\"clickme\">Hello world</div>\n</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/skipped/[one]/[two]/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport function load({ params }) {\n\treturn params;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/skipped/[one]/[two]/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.one}/{data.two}</h1>\n\n<a href=\"../y/1\" id=\"goto-y1\">next</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/slashes/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<a href=\"/routing/\">/routing/</a>\n<a href=\"/routing/?\">/routing/?</a>\n<a href=\"/routing/?foo=bar\">/routing/?foo=bar</a>\n<a href=\"http://localhost:{page.url.searchParams.get('port')}/with-slash/\">external</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/split-params/+page.svelte",
    "content": "<a href=\"/routing/split-params/x-y-z\">/routing/split-params/x-y-z</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/split-params/[a]-[b]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.params.a}</h1>\n<h2>{page.params.b}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/symlink-to/+page.svelte",
    "content": "<h1>symlinked</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash/+layout.js",
    "content": "export const ssr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash/+layout.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<ul data-sveltekit-preload-data=\"hover\">\n\t<li><a href=\"/routing/trailing-slash/always\">/always</a></li>\n\t<li><a href=\"/routing/trailing-slash/ignore/\">/ignore/</a></li>\n\t<li><a href=\"/routing/trailing-slash/never/\">/never/</a></li>\n</ul>\n\n<p>{page.url.pathname}</p>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash/always/+page.js",
    "content": "export const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash/always/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash/ignore/+page.js",
    "content": "export const trailingSlash = 'ignore';\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash/ignore/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash/never/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash-server/+layout.server.js",
    "content": "export function load({ url }) {\n\treturn {\n\t\tpathname: url.pathname\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash-server/+layout.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\tlet { data } = $props();\n</script>\n\n<ul>\n\t<li><a href=\"/routing/trailing-slash-server/always\">/always</a></li>\n\t<li><a href=\"/routing/trailing-slash-server/ignore\">/ignore</a></li>\n\t<li><a href=\"/routing/trailing-slash-server/ignore/\">/ignore/</a></li>\n\t<li><a href=\"/routing/trailing-slash-server/never/\">/never/</a></li>\n</ul>\n\n<p data-test-id=\"pathname-store\">{page.url.pathname}</p>\n<p data-test-id=\"pathname-data\">{data.pathname}</p>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash-server/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash-server/always/+page.server.js",
    "content": "export const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash-server/always/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash-server/ignore/+page.server.js",
    "content": "export const trailingSlash = 'ignore';\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash-server/ignore/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/routing/trailing-slash-server/never/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/scroll/cross-document/a/+page.svelte",
    "content": "<h1>a</h1>\n\n<div style=\"height: 200vh; background: teal\"></div>\n\n<a data-sveltekit-reload href=\"/scroll/cross-document/b\">b</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/scroll/cross-document/b/+page.svelte",
    "content": "<h1>b</h1>\n\n<a href=\"/scroll/cross-document/c\">c</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/scroll/cross-document/c/+page.svelte",
    "content": "<h1>c</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/scroll/push-state/+page.svelte",
    "content": "<script>\n\timport { pushState } from '$app/navigation';\n\timport { page } from '$app/state';\n\n\tfunction handleClick() {\n\t\tpushState('', { active: true });\n\t}\n</script>\n\n<a id=\"subpage-link\" href=\"/scroll/push-state/a\">Subpage</a>\n\n{#each { length: 20 } as _, n}\n\t<p>#{n}</p>\n{/each}\n\n<button id=\"shallow-button\" type=\"button\" on:click={handleClick}>Shallow</button>\n\n{#if page.state.active}\n\t<button id=\"back-button\" type=\"button\" on:click={() => history.back()}>Back</button>\n{/if}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/scroll/push-state/a/+page.svelte",
    "content": "<button id=\"back-button\" type=\"button\" on:click={() => history.back()}>Back</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/scroll/top/+page.svelte",
    "content": "<div style=\"width:100%; height: 200vh; background-color: goldenrod\"></div>\n<!-- svelte-ignore a11y-invalid-attribute -->\n<p><a href=\"#\">#</a></p>\n<p><a href=\"#top\">#top</a></p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/selection/+layout.svelte",
    "content": "<nav><a href=\"/selection/a\">a</a> <a href=\"/selection/b\">b</a></nav>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/selection/a/+page.svelte",
    "content": "<svelte:head>\n\t<title>a</title>\n</svelte:head>\n\n<h1>a</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/selection/b/+page.svelte",
    "content": "<svelte:head>\n\t<title>b</title>\n</svelte:head>\n\n<h1>b</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-basic/+page.server.js",
    "content": "import { Foo } from '../../lib';\n\nexport function load() {\n\treturn { foo: new Foo('It works') };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-basic/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport type { PageData } from './$types';\n\n\tlet { data }: { data: PageData } = $props();\n</script>\n\n<h1>{data.foo.bar()}</h1>\n<a href=\"/serialization-basic/child\">child page</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-basic/child/+page.server.js",
    "content": "import { Foo } from '../../../lib';\n\nexport function load() {\n\treturn { foo: new Foo('Client-side navigation also works') };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-basic/child/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport type { PageData } from './$types';\n\n\tlet { data }: { data: PageData } = $props();\n</script>\n\n<h1>{data.foo.bar()}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-form-enhanced/+page.server.js",
    "content": "import { Foo } from '../../lib';\n\n/** @satisfies {import('./$types').Actions} */\nexport const actions = {\n\tdefault: async () => {\n\t\treturn { foo: new Foo('It works') };\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-form-enhanced/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport { enhance } from '$app/forms';\n\n\tconst { form } = $props();\n</script>\n\n<form method=\"POST\" use:enhance>\n\t<button type=\"submit\">submit</button>\n</form>\n\n{#if form}\n\t<h1>{form?.foo?.bar()}</h1>\n{/if}\n\n<a href=\"/serialization-basic\">To basic form</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-form-non-enhanced/+page.server.js",
    "content": "import { Foo } from '../../lib';\n\n/** @satisfies {import('./$types').Actions} */\nexport const actions = {\n\tdefault: async () => {\n\t\treturn { foo: new Foo('It works') };\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-form-non-enhanced/+page.svelte",
    "content": "<script lang=\"ts\">\n\tconst { form } = $props();\n</script>\n\n<form method=\"POST\">\n\t<button type=\"submit\">submit</button>\n</form>\n\n<h1>{form?.foo?.bar()}</h1>\n\n<a href=\"/serialization-basic\">To basic form</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-form-non-enhanced/server-deserialize/+server.js",
    "content": "import { deserialize } from '$app/forms';\n\nexport async function GET({ fetch }) {\n\tconst response = await fetch('/serialization-form-non-enhanced', {\n\t\tmethod: 'POST',\n\t\tbody: new FormData(),\n\t\theaders: {\n\t\t\t'x-sveltekit-action': 'true'\n\t\t}\n\t});\n\tconst result = deserialize(await response.text());\n\n\tif (result.type === 'success' && result.data) {\n\t\treturn Response.json({\n\t\t\tdata: /** @type {import('../../../lib').Foo} */ (result.data.foo).bar()\n\t\t});\n\t}\n\n\treturn Response.json({});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-stream/+page.server.js",
    "content": "import { Foo } from '$lib';\n\nexport const load = () => {\n\treturn {\n\t\tfoo: Promise.resolve(new Foo('It works'))\n\t};\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/serialization-stream/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>\n\t{#await data.foo}\n\t\tLoading...\n\t{:then result}\n\t\t{result.bar()}\n\t{/await}\n</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/set-cookie/+server.js",
    "content": "export function GET() {\n\tconst headers = new Headers();\n\theaders.append('set-cookie', 'answer=42; HttpOnly');\n\theaders.append('set-cookie', 'problem=comma, separated, values; HttpOnly');\n\treturn new Response(undefined, {\n\t\theaders\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/+page.svelte",
    "content": "<a href=\"/shadowed/simple\">simple</a>\n<a href=\"/shadowed/redirect-get\">redirect-get</a>\n<a href=\"/shadowed/redirect-get-with-cookie\">redirect-get-with-cookie</a>\n<a href=\"/shadowed/redirect-get-with-cookie-from-fetch\">redirect-get-with-cookie-from-fetch</a>\n<a href=\"/shadowed/error-get\">error-get</a>\n<a href=\"/shadowed/no-get\">no-get</a>\n<a href=\"/shadowed/dynamic/foo\">dynamic/foo</a>\n<a href=\"/shadowed/missing-get\">missing-get</a>\n<a href=\"/shadowed/serialization\">serialization</a>\n\n<form action=\"/shadowed/redirect-post\" method=\"post\">\n\t<button type=\"submit\" id=\"redirect-post\">redirect</button>\n</form>\n\n<form action=\"/shadowed/redirect-post-with-cookie\" method=\"post\">\n\t<button type=\"submit\" id=\"redirect-post-with-cookie\">redirect</button>\n</form>\n\n<form action=\"/shadowed/error-post\" method=\"post\" enctype=\"multipart/form-data\">\n\t<input name=\"message\" value=\"posted data\" />\n\t<button type=\"submit\" id=\"error-post\">error</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/dynamic/[slug]/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ params }) {\n\treturn { ...params };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/dynamic/[slug]/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>slug: {data.slug}</h1>\n\n<a href=\"/shadowed/dynamic/foo\">foo</a>\n<a href=\"/shadowed/dynamic/bar\">bar</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/error-get/+page.server.js",
    "content": "import { error } from '@sveltejs/kit';\n\nexport function load() {\n\terror(404, undefined);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/error-get/+page.svelte",
    "content": "<h1>This should not be visible</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/error-post/+page.server.js",
    "content": "import { fail } from '@sveltejs/kit';\n\nexport function load() {\n\treturn {\n\t\tget_message: 'hello from get'\n\t};\n}\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: async ({ request }) => {\n\t\tconst fields = await request.formData();\n\t\treturn fail(400, {\n\t\t\terrors: { post_message: `echo: ${fields.get('message')}` }\n\t\t});\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/error-post/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\t/** @type {{ data: import('./$types').PageData, form: import('./$types').ActionData }} */\n\tlet { data, form } = $props();\n</script>\n\n<h1>{data.get_message} / {form?.errors?.post_message}</h1>\n<h2>status: {page.status}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/missing-get/+page.server.js",
    "content": "/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: () => {}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/missing-get/+page.svelte",
    "content": "<h1>post without get</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/no-get/+page.server.js",
    "content": "/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: () => {\n\t\treturn {};\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/no-get/+page.svelte",
    "content": "<h1>hello</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/parent/+layout.server.js",
    "content": "export function load() {\n\treturn { layout: 'layout' };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/parent/+layout.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h2>Layout data: {JSON.stringify(data)}</h2>\n<a href=\"/shadowed/parent?test\">Reload</a>\n<a href=\"/shadowed/parent/sub\">Sub</a>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/parent/+page.server.js",
    "content": "export async function load({ parent }) {\n\tconst data = await parent();\n\treturn { page: 'page', data };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/parent/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p>Page data: {JSON.stringify(data)}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/parent/sub/+page.server.js",
    "content": "export async function load({ parent }) {\n\tconst data = await parent();\n\treturn { sub: 'sub', data };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/parent/sub/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p>Page data: {JSON.stringify(data)}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/post-success-redirect/+page.server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: () => {\n\t\tredirect(303, '/shadowed/post-success-redirect/redirected');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/post-success-redirect/+page.svelte",
    "content": "<form method=\"POST\">\n\t<button>Click me</button>\n</form>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/post-success-redirect/redirected/+page.svelte",
    "content": "<h1>POST was successful</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect/+page.svelte",
    "content": "<a href=\"/shadowed/redirect/a\">redirect to c</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect/[a]/+page.server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function load() {\n\tredirect(302, '/shadowed/redirect/b');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect/[a]/+page.svelte",
    "content": "<h1>redirect</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect/b/+page.svelte",
    "content": "<h1>done</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-get/+page.server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport function load() {\n\tredirect(302, '/shadowed/redirected');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-get/+page.svelte",
    "content": "<h1>This should not be visible</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-get-with-cookie/+page.server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('./$types').PageServerLoad} */\nexport function load({ cookies }) {\n\tcookies.set('shadow-redirect', 'happy', {\n\t\tpath: '/shadowed',\n\t\tsecure: false // safari\n\t});\n\tredirect(302, '/shadowed/redirected');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-get-with-cookie/+page.svelte",
    "content": "<h1>This should not be visible</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-get-with-cookie-from-fetch/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tawait fetch('/shadowed/redirect-get-with-cookie-from-fetch/endpoint');\n\tredirect(302, '/shadowed/redirected');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-get-with-cookie-from-fetch/+page.svelte",
    "content": "<h1>This should not be visible</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-get-with-cookie-from-fetch/endpoint/+server.js",
    "content": "/** @type {import('./$types').RequestHandler} */\nexport function GET({ cookies }) {\n\tcookies.set('shadow-redirect-fetch', 'happy', {\n\t\tpath: '/',\n\t\tsecure: false // safari\n\t});\n\treturn new Response('ok');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-post/+page.server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: () => {\n\t\tredirect(302, '/shadowed/redirected');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-post/+page.svelte",
    "content": "<h1>This should not be visible</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-post-with-cookie/+page.server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: ({ cookies }) => {\n\t\tcookies.set('shadow-redirect', 'happy', {\n\t\t\tpath: '/shadowed',\n\t\t\tsecure: false // safari\n\t\t});\n\t\tredirect(302, '/shadowed/redirected');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirect-post-with-cookie/+page.svelte",
    "content": "<h1>This should not be visible</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirected/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tstatus: 'successful'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/redirected/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>Redirection was {data.status}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/same-render/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ url }) {\n\treturn { url: url.toString() };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/same-render/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>URL: {data.url}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/same-render-entry/+page.svelte",
    "content": "<a href=\"/shadowed/same-render?param1=value1\">Click here to navigate</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/serialization/+page.server.js",
    "content": "class Nope {\n\ttoString() {\n\t\treturn 'should not see me';\n\t}\n}\n\nexport function load() {\n\treturn {\n\t\tnope: new Nope()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/serialization/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.nope}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/simple/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load({ locals }) {\n\treturn {\n\t\tanswer: locals.answer\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/simple/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>The answer is {data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/simple/post/+page.server.js",
    "content": "/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: () => {}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shadowed/simple/post/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/push-state/+layout.svelte",
    "content": "<a href=\"/shallow-routing/push-state\">push-state</a>\n<a href=\"/shallow-routing/push-state/a\">a</a>\n<a href=\"/shallow-routing/push-state/b\">b</a>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/push-state/+page.js",
    "content": "export function load() {\n\treturn {\n\t\tnow: Date.now()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/push-state/+page.svelte",
    "content": "<script>\n\timport { invalidateAll, pushState } from '$app/navigation';\n\timport { page } from '$app/state';\n\n\tlet { data } = $props();\n\n\tfunction one() {\n\t\tpushState('', { active: true });\n\t}\n\n\tfunction two() {\n\t\tpushState('/shallow-routing/push-state/a', { active: true });\n\t}\n</script>\n\n<h1>parent</h1>\n\n<button data-id=\"one\" on:click={one}>push state on current page</button>\n<button data-id=\"two\" on:click={two}>push state on child page</button>\n<button data-id=\"invalidate\" on:click={invalidateAll}>invalidate all</button>\n\n<p>active: {page.state.active ?? false}</p>\n<span>{data.now}</span>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/push-state/a/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>a</h1>\n\n<p>active: {page.state.active ?? false}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/push-state/b/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>b</h1>\n\n<p>active: {page.state.active ?? false}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/push-state/effect/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport { pushState } from '$app/navigation';\n\n\tlet count = $state(0);\n\n\t$effect(() => {\n\t\tif (count) pushState('', { count });\n\t});\n</script>\n\n<p>count: {count}</p>\n<button onclick={() => count++}>Increment</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/replace-state/+layout.svelte",
    "content": "<a href=\"/shallow-routing/replace-state\">replace-state</a>\n<a href=\"/shallow-routing/replace-state/a\">a</a>\n<a href=\"/shallow-routing/replace-state/b\">b</a>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/replace-state/+page.svelte",
    "content": "<script>\n\timport { replaceState } from '$app/navigation';\n\timport { page } from '$app/state';\n\n\tfunction one() {\n\t\treplaceState('', { active: true });\n\t}\n\n\tfunction two() {\n\t\treplaceState('/shallow-routing/replace-state/a', { active: true });\n\t}\n</script>\n\n<h1>parent</h1>\n\n<button data-id=\"one\" on:click={one}>replace state on current page</button>\n<button data-id=\"two\" on:click={two}>replace state on child page</button>\n\n<p>active: {page.state.active ?? false}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/replace-state/a/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>a</h1>\n\n<p>active: {page.state.active ?? false}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/replace-state/b/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>b</h1>\n\n<p>active: {page.state.active ?? false}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/shallow-routing/replace-state/effect/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport { pushState as replaceState } from '$app/navigation';\n\n\tlet count = $state(0);\n\n\t$effect(() => {\n\t\tif (count) replaceState('', { count });\n\t});\n</script>\n\n<p>count: {count}</p>\n<button onclick={() => count++}>Increment</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/snapshot/+layout.svelte",
    "content": "<a href=\"/snapshot/a\">a</a>\n<a href=\"/snapshot/b\">b</a>\n<a href=\"/snapshot/c\" data-sveltekit-reload>c</a>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/snapshot/a/+page.svelte",
    "content": "<script>\n\tlet message = '';\n\n\t/** @type {import('./$types').Snapshot<string>} */\n\texport const snapshot = {\n\t\tcapture: () => message,\n\t\trestore: (snapshot) => (message = snapshot)\n\t};\n</script>\n\n<input bind:value={message} />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/snapshot/b/+page.svelte",
    "content": "<h1>b</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/snapshot/c/+page.svelte",
    "content": "<h1>c</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/src/[...anything]/+server.js",
    "content": "/** @type {import('./$types').RequestHandler} */\nexport function GET() {\n\treturn new Response('dynamically rendered file');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/client-access/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\tlet pathname = $state();\n</script>\n\n<h1>{`${pathname}`}</h1>\n\n<button\n\tonclick={() => {\n\t\tpathname = page.url.pathname;\n\t}}>click</button\n>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\timport { goto } from '$app/navigation';\n</script>\n\n<button id=\"reload-button\" on:click={() => goto(page.url.toString())}>Reload</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/+layout.js",
    "content": "export function load() {\n\treturn {\n\t\tname: 'SvelteKit',\n\t\tvalue: 123\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/+layout.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<div id=\"state-data\">{JSON.stringify(page.data)}</div>\n<div id=\"state-error\">{page.error?.message}</div>\n<div id=\"url-hash\">{page.url.hash}</div>\n\n<nav>\n\t<a href=\"/state/data/xxx\">xxx</a> <a href=\"/state/data/yyy\">yyy</a>\n\t<a href=\"/state/data/zzz\">zzz</a> <a href=\"/state/data/foo\">foo</a>\n</nav>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/[item]/+page.js",
    "content": "import { error } from '@sveltejs/kit';\n\n/** @type {import('./$types').PageLoad} */\nexport function load({ params }) {\n\tif (params.item === 'xxx') {\n\t\terror(500, 'Params = xxx');\n\t}\n\n\tif (params.item === 'yyy') {\n\t\terror(500, 'Params = yyy');\n\t}\n\n\treturn {\n\t\tpage: params.item,\n\t\tvalue: 456\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/[item]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/foo/+page.js",
    "content": "let is_first = true;\n\nexport function load({ url }) {\n\tif (url.searchParams.get('reset')) {\n\t\tis_first = true;\n\t\treturn {};\n\t}\n\n\tif (is_first) {\n\t\tis_first = false;\n\t\tthrow new Error('uh oh');\n\t}\n\n\treturn {\n\t\tfoo: true,\n\t\tnumber: 2\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/foo/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>data - foo</h1>\n<p>Number prop: {data.number}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/state-update/+layout.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\timport { untrack } from 'svelte';\n\n\tlet { children } = $props();\n\n\tlet previous = page.data;\n\tlet count = $state(0);\n\n\t$effect(() => {\n\t\tif (previous !== page.data) {\n\t\t\tuntrack(() => count++);\n\t\t}\n\t});\n</script>\n\n<p>page.data was updated {count} time(s)</p>\n<a href=\"/state/data/store-updates/a\">a</a>\n<a href=\"/state/data/store-updates/b\">b</a>\n\n{@render children()}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/state-update/a/+page.svelte",
    "content": "Page A\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/state-update/b/+page.svelte",
    "content": "Page B\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/state-update/same-keys/+layout.js",
    "content": "export function load() {\n\treturn {\n\t\tvalue: 'layout'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/state-update/same-keys/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/state-update/same-keys/same/+page.js",
    "content": "export function load() {\n\treturn {\n\t\tvalue: 'page'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/state-update/same-keys/same/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/state-update/same-keys/same-deep/nested/+page.js",
    "content": "export function load() {\n\treturn {\n\t\tvalue: 'page'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/data/state-update/same-keys/same-deep/nested/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/navigating/+layout.svelte",
    "content": "<script>\n\timport { navigating } from '$app/state';\n</script>\n\n<nav>\n\t<a href=\"/state/navigating/a\">a</a>\n\t<a href=\"/state/navigating/b\">b</a>\n\t<a href=\"/state/navigating/c\">c</a>\n</nav>\n\n<div id=\"nav-status\">\n\t{#if navigating.to}\n\t\t<!-- prettier-ignore -->\n\t\t<p id=\"navigating\">\n\t\t\tnavigating from {navigating.from.url.pathname} to {navigating.to.url.pathname} ({navigating.type})\n\t\t</p>\n\t{:else}\n\t\t<p id=\"not-navigating\">not currently navigating</p>\n\t{/if}\n</div>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/navigating/a/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load() {\n\tawait new Promise((f) => setTimeout(f, 250));\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/navigating/a/+page.svelte",
    "content": "<p>a</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/navigating/b/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load() {\n\tawait new Promise((f) => setTimeout(f, 250));\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/navigating/b/+page.svelte",
    "content": "<p>b</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/navigating/c/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load() {\n\tawait new Promise((f) => setTimeout(f, 1000));\n\treturn {};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/navigating/c/+page.svelte",
    "content": "<p>c</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/state/url/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\timport { goto } from '$app/navigation';\n\n\tconst q = $derived(page.url.searchParams.get('q') || undefined);\n</script>\n\n<button\n\ttype=\"button\"\n\tonclick={() => {\n\t\tpage.url.searchParams.set('q', 'test');\n\t\tgoto(page.url);\n\t}}>test</button\n>\n\n<p>{`${q}`}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/static/+page.svelte",
    "content": "<h1>hello</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/client-access/+page.svelte",
    "content": "<script>\n\timport { getStores } from '$app/stores';\n\n\tlet pathname;\n</script>\n\n<h1>{`${pathname}`}</h1>\n\n<button\n\ton:click={() => {\n\t\tgetStores().page.subscribe(($page) => (pathname = $page.url.pathname))();\n\t}}>click</button\n>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/stores';\n\timport { goto } from '$app/navigation';\n</script>\n\n<button id=\"reload-button\" on:click={() => goto($page.url.toString())}>Reload</button>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/+layout.js",
    "content": "export function load() {\n\treturn {\n\t\tname: 'SvelteKit',\n\t\tvalue: 123\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/+layout.svelte",
    "content": "<script>\n\timport { page } from '$app/stores';\n</script>\n\n<div id=\"store-data\">{JSON.stringify($page.data)}</div>\n<div id=\"store-error\">{$page.error?.message}</div>\n<div id=\"url-hash\">{$page.url.hash}</div>\n\n<nav>\n\t<a href=\"/store/data/xxx\">xxx</a> <a href=\"/store/data/yyy\">yyy</a>\n\t<a href=\"/store/data/zzz\">zzz</a> <a href=\"/store/data/foo\">foo</a>\n</nav>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/[item]/+page.js",
    "content": "import { error } from '@sveltejs/kit';\n\n/** @type {import('./$types').PageLoad} */\nexport function load({ params }) {\n\tif (params.item === 'xxx') {\n\t\terror(500, 'Params = xxx');\n\t}\n\n\tif (params.item === 'yyy') {\n\t\terror(500, 'Params = yyy');\n\t}\n\n\treturn {\n\t\tpage: params.item,\n\t\tvalue: 456\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/[item]/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/foo/+page.js",
    "content": "let is_first = true;\n\nexport function load({ url }) {\n\tif (url.searchParams.get('reset')) {\n\t\tis_first = true;\n\t\treturn {};\n\t}\n\n\tif (is_first) {\n\t\tis_first = false;\n\t\tthrow new Error('uh oh');\n\t}\n\n\treturn {\n\t\tfoo: true,\n\t\tnumber: 2\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/foo/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>data - foo</h1>\n<p>Number prop: {data.number}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/store-update/+layout.svelte",
    "content": "<script>\n\timport { page } from '$app/stores';\n\tlet previous = $page.data;\n\tlet count = 0;\n\t$: {\n\t\tif (previous !== $page.data) {\n\t\t\tcount++;\n\t\t}\n\t}\n</script>\n\n<p>$page.data was updated {count} time(s)</p>\n<a href=\"/store/data/store-updates/a\">a</a>\n<a href=\"/store/data/store-updates/b\">b</a>\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/store-update/a/+page.svelte",
    "content": "Page A\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/store-update/b/+page.svelte",
    "content": "Page B\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/store-update/same-keys/+layout.js",
    "content": "export function load() {\n\treturn {\n\t\tvalue: 'layout'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/store-update/same-keys/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/store-update/same-keys/same/+page.js",
    "content": "export function load() {\n\treturn {\n\t\tvalue: 'page'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/store-update/same-keys/same/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/store-update/same-keys/same-deep/nested/+page.js",
    "content": "export function load() {\n\treturn {\n\t\tvalue: 'page'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/data/store-update/same-keys/same-deep/nested/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/navigating/+layout.svelte",
    "content": "<script>\n\timport { navigating } from '$app/stores';\n</script>\n\n<nav>\n\t<a href=\"/store/navigating/a\">a</a>\n\t<a href=\"/store/navigating/b\">b</a>\n\t<a href=\"/store/navigating/c\">c</a>\n</nav>\n\n<div id=\"nav-status\">\n\t{#if $navigating}\n\t\t<p id=\"navigating\">\n\t\t\tnavigating from {$navigating.from.url.pathname} to {$navigating.to.url.pathname} ({$navigating.type})\n\t\t</p>\n\t{:else}\n\t\t<p id=\"not-navigating\">not currently navigating</p>\n\t{/if}\n</div>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/navigating/a/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load() {\n\tawait new Promise((f) => setTimeout(f, 250));\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/navigating/a/+page.svelte",
    "content": "<p>a</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/navigating/b/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load() {\n\tawait new Promise((f) => setTimeout(f, 250));\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/navigating/b/+page.svelte",
    "content": "<p>b</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/navigating/c/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load() {\n\tawait new Promise((f) => setTimeout(f, 1000));\n\treturn {};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/navigating/c/+page.svelte",
    "content": "<p>c</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/subscribe/+layout.svelte",
    "content": "<script>\n\timport { page } from '$app/stores';\n\timport { goto, pushState, replaceState, invalidate } from '$app/navigation';\n\timport { applyAction } from '$app/forms';\n\n\tlet { children } = $props();\n\n\tlet count = $state(0);\n\n\tpage.subscribe(() => {\n\t\tcount += 1;\n\t});\n</script>\n\n<p>{count}</p>\n\n<button\n\tonclick={() => {\n\t\tinvalidate('/state/subscribe');\n\t}}>invalidate</button\n>\n\n<button\n\tonclick={() => {\n\t\treplaceState(`/store/subscribe`, { active: true });\n\t}}>replaceState</button\n>\n\n<button\n\tonclick={() => {\n\t\tpushState(`/store/subscribe`, { active: false });\n\t}}>pushState</button\n>\n\n<button\n\tonclick={() => {\n\t\tgoto(`/store/subscribe`);\n\t}}>goto</button\n>\n\n<button\n\tonclick={() => {\n\t\tapplyAction({ type: 'success', status: 200 });\n\t}}>applyAction</button\n>\n\n{@render children()}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/store/subscribe/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/+page.svelte",
    "content": "<a href=\"/streaming/universal\">Universal</a>\n<a href=\"/streaming/server\">Server</a>\n<a href=\"/streaming/server-error\">Server Error</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/discarded-promise/+layout.server.js",
    "content": "export function load() {\n\treturn {\n\t\tpromise: Promise.resolve(42)\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/discarded-promise/+page.server.js",
    "content": "import { error } from '@sveltejs/kit';\n\nexport function load() {\n\terror(404);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/discarded-promise/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/server/+page.js",
    "content": "export function load({ data }) {\n\treturn { ...data };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/server/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\teager: 'eager',\n\t\tlazy: {\n\t\t\tsuccess: new Promise((resolve) => {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tresolve('success');\n\t\t\t\t}, 1000);\n\t\t\t}),\n\t\t\tfail: new Promise((_, reject) => {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\treject(new Error('fail'));\n\t\t\t\t}, 1000);\n\t\t\t})\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/server/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p class=\"eager\">{data.eager}</p>\n\n{#await data.lazy.success}\n\t<p class=\"loadingsuccess\">Loading success</p>\n{:then result}\n\t<p class=\"success\">{result}</p>\n{/await}\n\n{#await data.lazy.fail}\n\t<p class=\"loadingfail\">Loading fail</p>\n{:catch error}\n\t<p class=\"fail\">{error.message}</p>\n{/await}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/server/fast-n-slow/+layout.server.js",
    "content": "export function load() {\n\treturn { fast: Promise.resolve('fast') };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/server/fast-n-slow/+layout.svelte",
    "content": "<script>\n\t/** @type {import('./$types').LayoutData} */\n\texport let data;\n</script>\n\n{#await data.fast}\n\t<p class=\"loadingfast\">Loading fast</p>\n{:then result}\n\t<p class=\"fast\">{result}</p>\n{/await}\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/server/fast-n-slow/+page.server.js",
    "content": "export async function load() {\n\tconst ssrd = await new Promise((r) => setTimeout(() => r('ssrd'), 100));\n\tconst streamed = new Promise((r) => setTimeout(() => r('streamed'), 200));\n\treturn { ssrd, streamed };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/server/fast-n-slow/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p class=\"ssrd\">{data.ssrd}</p>\n\n{#await data.streamed}\n\t<p class=\"loadingstreamed\">Loading streamed</p>\n{:then result}\n\t<p class=\"streamed\">{result}</p>\n{/await}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/server-error/+page.server.js",
    "content": "// Tests the case where a lazy promise is rejected before the rendering started\nexport async function load({ fetch }) {\n\tconst eager = new Promise((resolve) => {\n\t\tsetTimeout(() => {\n\t\t\tresolve('eager');\n\t\t}, 100);\n\t});\n\n\treturn {\n\t\teager: await eager,\n\t\tlazy: {\n\t\t\tfail: fetch('http://localhost:1337/')\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/server-error/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p class=\"eager\">{data.eager}</p>\n\n{#await data.lazy.fail}\n\t<p class=\"loadingfail\">loading</p>\n{:catch}\n\t<p class=\"fail\">fail</p>\n{/await}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/universal/+page.js",
    "content": "export function load() {\n\treturn {\n\t\teager: 'eager',\n\t\tlazy: {\n\t\t\tsuccess: new Promise((resolve) => {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tresolve('success');\n\t\t\t\t}, 1000);\n\t\t\t}),\n\t\t\tfail: new Promise((_, reject) => {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\treject(new Error('fail'));\n\t\t\t\t}, 1000);\n\t\t\t})\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/streaming/universal/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p class=\"eager\">{data.eager}</p>\n\n{#await data.lazy.success}\n\t<p class=\"loadingsuccess\">Loading success</p>\n{:then result}\n\t<p class=\"success\">{result}</p>\n{/await}\n\n{#await data.lazy.fail}\n\t<p class=\"loadingfail\">Loading fail</p>\n{:catch error}\n\t<p class=\"fail\">{error.message}</p>\n{/await}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/tracing/http-error/+page.server.js",
    "content": "import { error } from '@sveltejs/kit';\n\nexport async function load() {\n\terror(500, 'Internal server error from tracing test');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/tracing/http-error/+page.svelte",
    "content": "<h1>This should not render due to load error</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/tracing/non-error-object/+page.server.js",
    "content": "export async function load() {\n\tthrow 'string error from tracing test';\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/tracing/one/two/three/[...four]/+page.svelte",
    "content": "<h1>Tracing</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/tracing/redirect/+page.server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport async function load({ url }) {\n\tredirect(307, `/tracing/one/two/three/four/five${url.search}`);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/tracing/regular-error/+page.server.js",
    "content": "export async function load() {\n\tthrow new Error('Regular error from tracing test');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/transform-page-chunk/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/treeshaking/browser/+page.svelte",
    "content": "<script>\n\timport { browser } from '$app/environment';\n</script>\n\n<p>\n\t{browser ? 'client' : 'server'}\n</p>\n<p>\n\tnegated: {!browser ? 'server' : 'client'}\n</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/treeshaking/dev/+page.svelte",
    "content": "<script>\n\timport { dev } from '$app/environment';\n</script>\n\n<p>{dev ? 'not prod' : 'prod'}</p>\n<p>negated: {!dev ? 'prod' : 'not prod'}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/unsafe-replacement/+page.js",
    "content": "export function load() {\n\treturn { escape: '$&' };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/unsafe-replacement/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n$& {data.escape}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/untrack/server/+layout.server.js",
    "content": "export function load({ url }) {\n\treturn {\n\t\turl: url.pathname\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/untrack/server/[x]/+page.server.js",
    "content": "export function load({ params, parent, url, untrack }) {\n\tuntrack(() => {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions\n\t\tparams.x;\n\t\tparent();\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions\n\t\turl.pathname;\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions\n\t\turl.search;\n\t});\n\n\treturn {\n\t\tid: Math.random()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/untrack/server/[x]/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p class=\"url\">{data.url}</p>\n<p class=\"id\">{data.id}</p>\n<a href=\"/untrack/server/2\">2</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/untrack/universal/+layout.js",
    "content": "export function load({ url }) {\n\treturn {\n\t\turl: url.pathname\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/untrack/universal/[x]/+page.js",
    "content": "export function load({ params, parent, url, untrack }) {\n\tuntrack(() => {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions\n\t\tparams.x;\n\t\tparent();\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions\n\t\turl.pathname;\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-expressions\n\t\turl.search;\n\t});\n\n\treturn {\n\t\tid: Math.random()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/untrack/universal/[x]/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p class=\"url\">{data.url}</p>\n<p class=\"id\">{data.id}</p>\n<a href=\"/untrack/universal/2\">2</a>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/use-action/+page.svelte",
    "content": "<h1>Welcome to a test project</h1>\n<a href=\"/use-action/focus-and-scroll\">Focus and scroll demo</a>\n\n<style>\n\t:global(body) {\n\t\tbackground-color: tan;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t}\n\n\ta {\n\t\tdisplay: block;\n\t\tmargin: 20px;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/use-action/focus-and-scroll/+page.svelte",
    "content": "<script>\n\timport { disableScrollHandling } from '$app/navigation';\n\n\tconst focusAndScroll = /** @param {HTMLInputElement} node */ (node) => {\n\t\tdisableScrollHandling();\n\n\t\tnode.focus();\n\t\tnode.scrollIntoView();\n\t};\n</script>\n\n<div>They (don't) see me scrollin'...</div>\n<div style=\"height: 180vh; background-color: peru;\">\n\t<label for=\"input\">Focus! </label>\n\t<input use:focusAndScroll id=\"input\" type=\"text\" />\n</div>\n<div style=\"height: 180vh; background-color: teal;\">They (not) focusin'</div>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst res = await fetch('/xss.json');\n\tconst user = await res.json();\n\treturn { user };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>user.name is {data.user.name}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss/[path]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1 id=\"one\">{page.params.path}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss/query/+page.js",
    "content": "import { to_pojo } from './utils.js';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load({ url }) {\n\treturn {\n\t\tvalues: to_pojo(url.searchParams)\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss/query/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\timport { to_pojo } from './utils.js';\n\n\t/** @type {{ data: import('./$types').PageData }} */\n\tlet { data } = $props();\n</script>\n\n<pre id=\"one\">{JSON.stringify(data.values)}</pre>\n<pre id=\"two\">{JSON.stringify(to_pojo(page.url.searchParams))}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss/query/utils.js",
    "content": "/** @typedef {Record<string, string[]>} Query */\n\n/** @param {URLSearchParams} query */\nexport function to_pojo(query) {\n\t/** @type {Query}*/\n\tconst values = {};\n\n\tquery.forEach((value, key) => {\n\t\tif (!(key in values)) values[key] = [];\n\t\tvalues[key].push(value);\n\t});\n\n\treturn values;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss/query-tracking/+page.server.js",
    "content": "export function load({ url }) {\n\tconst values = {};\n\n\tfor (const key of url.searchParams.keys()) {\n\t\tvalues[key] = url.searchParams.get(key);\n\t}\n\n\treturn {\n\t\tvalues\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss/query-tracking/+page.svelte",
    "content": "<p>check window.pwned</p>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss/shadow/+page.server.js",
    "content": "/** @type {import('./$types').PageServerLoad} */\nexport function load() {\n\tconst user = {\n\t\tname: '</script><script>window.pwned = 1</script>'\n\t};\n\treturn { user };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss/shadow/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>user.name is {data.user.name}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/routes/xss.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport function GET() {\n\treturn json({\n\t\tname: '</script><script>window.pwned = 1</script>'\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/src/service-worker.js",
    "content": "import { build, version } from '$service-worker';\nimport { PUBLIC_STATIC } from '$env/static/public';\n\nconst name = `cache-${version}-${PUBLIC_STATIC}`;\n\nself.addEventListener('install', (event) => {\n\t// @ts-expect-error\n\tevent.waitUntil(caches.open(name).then((cache) => cache.addAll(build)));\n});\n\nself.addEventListener('activate', (event) => {\n\t// @ts-expect-error\n\tevent.waitUntil(\n\t\tcaches.keys().then(async (keys) => {\n\t\t\tfor (const key of keys) {\n\t\t\t\tif (!key.includes(version)) caches.delete(key);\n\t\t\t}\n\t\t})\n\t);\n});\n\nself.addEventListener('fetch', (event) => {\n\t// @ts-expect-error\n\tconst { request } = event;\n\n\tif (request.method !== 'GET' || request.headers.has('range')) return;\n\n\tconst url = new URL(request.url);\n\tconst cached = caches.match(request);\n\n\tif (url.origin === location.origin && build.includes(url.pathname)) {\n\t\t// always return build files from cache\n\t\t// @ts-expect-error\n\t\tevent.respondWith(cached);\n\t} else if (url.protocol === 'https:' || location.hostname === 'localhost') {\n\t\t// hit the network for everything else...\n\t\tconst promise = fetch(request);\n\n\t\t// ...and cache successful responses...\n\t\tpromise.then((response) => {\n\t\t\t// cache successful responses\n\t\t\tif (response.ok && response.type === 'basic') {\n\t\t\t\tconst clone = response.clone();\n\t\t\t\tcaches.open(name).then((cache) => {\n\t\t\t\t\tcache.put(request, clone);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t// ...but if it fails, fall back to cache if available\n\t\t// @ts-expect-error\n\t\tevent.respondWith(promise.catch(() => cached || promise));\n\t}\n});\n"
  },
  {
    "path": "packages/kit/test/apps/basics/static/empty.js",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/basics/static/load/assets/a#b.txt",
    "content": "nope"
  },
  {
    "path": "packages/kit/test/apps/basics/static/load/foo.json",
    "content": "{\n\t\"name\": \"static file\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/static/static.json",
    "content": "\"static file\"\n"
  },
  {
    "path": "packages/kit/test/apps/basics/static/subdirectory/static.json",
    "content": "\"subdirectory file\"\n"
  },
  {
    "path": "packages/kit/test/apps/basics/static/symlink-to/hello.txt",
    "content": "hello"
  },
  {
    "path": "packages/kit/test/apps/basics/svelte.config.js",
    "content": "import process from 'node:process';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: {\n\t\t\tname: 'test-adapter',\n\t\t\tadapt(builder) {\n\t\t\t\tbuilder.instrument({\n\t\t\t\t\tentrypoint: `${builder.getServerDirectory()}/index.js`,\n\t\t\t\t\tinstrumentation: `${builder.getServerDirectory()}/instrumentation.server.js`,\n\t\t\t\t\tmodule: {\n\t\t\t\t\t\texports: ['Server']\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t\temulate() {\n\t\t\t\treturn {\n\t\t\t\t\tplatform({ config, prerender }) {\n\t\t\t\t\t\treturn { config, prerender };\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\t\tsupports: {\n\t\t\t\tread: () => true,\n\t\t\t\tinstrumentation: () => true\n\t\t\t}\n\t\t},\n\n\t\texperimental: {\n\t\t\tremoteFunctions: true,\n\t\t\ttracing: {\n\t\t\t\tserver: true\n\t\t\t},\n\t\t\tinstrumentation: {\n\t\t\t\tserver: true\n\t\t\t}\n\t\t},\n\n\t\tcsrf: {\n\t\t\tcheckOrigin: true,\n\t\t\ttrustedOrigins: ['https://trusted.example.com', 'https://payment-gateway.test']\n\t\t},\n\n\t\tprerender: {\n\t\t\tentries: [\n\t\t\t\t'*',\n\t\t\t\t'/routing/prerendered/trailing-slash/always/',\n\t\t\t\t'/routing/prerendered/trailing-slash/never',\n\t\t\t\t'/routing/prerendered/trailing-slash/ignore'\n\t\t\t],\n\t\t\thandleHttpError: ({ path, message }) => {\n\t\t\t\tif (path.includes('/reroute/async')) {\n\t\t\t\t\tthrow new Error('shouldnt error on ' + path);\n\t\t\t\t}\n\n\t\t\t\tconsole.warn(message);\n\t\t\t}\n\t\t},\n\t\tserviceWorker: {\n\t\t\t// TODO: remove this when Playwright starts using Firefox 147\n\t\t\t// Firefox only started supporting importing ES modules in service workers\n\t\t\t// as of Firefox 147 https://caniuse.com/?search=es+modules+in+service\n\t\t\tregister: process.env.KIT_E2E_BROWSER !== 'firefox',\n\t\t\toptions: {\n\t\t\t\tupdateViaCache: 'imports'\n\t\t\t}\n\t\t},\n\n\t\tversion: {\n\t\t\tname: 'TEST_VERSION'\n\t\t},\n\n\t\trouter: {\n\t\t\tresolution: /** @type {'client' | 'server'} */ (process.env.ROUTER_RESOLUTION) || 'client'\n\t\t}\n\t},\n\n\tcompilerOptions: {\n\t\texperimental: { async: process.env.SVELTE_ASYNC === 'true' }\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/basics/test/client.test.js",
    "content": "import process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.skip(({ javaScriptEnabled }) => !javaScriptEnabled);\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe('a11y', () => {\n\ttest('applies autofocus after an enhanced form submit', async ({ page }) => {\n\t\tawait page.goto('/accessibility/autofocus/b');\n\n\t\tawait page.click('#submit');\n\t\tawait page.waitForFunction(() => document.activeElement?.nodeName === 'INPUT', null, {\n\t\t\ttimeout: 1000\n\t\t});\n\t});\n});\n\ntest.describe('Caching', () => {\n\ttest('caches __data.json requests with invalidated search param', async ({ page, app }) => {\n\t\tawait page.goto('/');\n\t\tconst [, response] = await Promise.all([\n\t\t\tapp.goto('/caching/server-data'),\n\t\t\tpage.waitForResponse((request) =>\n\t\t\t\trequest.url().endsWith('server-data/__data.json?x-sveltekit-invalidated=01')\n\t\t\t)\n\t\t]);\n\t\texpect(response.headers()['cache-control']).toBe('public, max-age=30');\n\t});\n});\n\ntest.describe('Endpoints', () => {\n\ttest('calls a delete handler', async ({ page }) => {\n\t\tawait page.goto('/delete-route');\n\t\tawait page.locator('.del').click();\n\t\texpect(await page.innerHTML('h1')).toBe('deleted 42');\n\t});\n});\n\ntest.describe('Load', () => {\n\ttest('load function is only called when necessary', async ({ app, page }) => {\n\t\ttest.slow();\n\t\tawait page.goto('/load/change-detection/one/a');\n\t\texpect(await page.textContent('h1')).toBe('layout loads: 1');\n\t\texpect(await page.textContent('h2')).toBe('x: a: 1');\n\n\t\tawait app.goto('/load/change-detection/one/a?unused=whatever');\n\t\texpect(await page.textContent('h2')).toBe('x: a: 1');\n\n\t\tawait app.goto('/load/change-detection/two/b');\n\t\texpect(await page.textContent('h2')).toBe('y: b: 1');\n\n\t\tawait app.goto('/load/change-detection/one/a');\n\t\texpect(await page.textContent('h2')).toBe('x: a: 2');\n\n\t\tawait app.goto('/load/change-detection/one/b');\n\t\texpect(await page.textContent('h2')).toBe('x: b: 3');\n\n\t\tawait app.invalidate('/load/change-detection/data.json');\n\t\texpect(await page.textContent('h1')).toBe('layout loads: 2');\n\t\texpect(await page.textContent('h2')).toBe('x: b: 3');\n\n\t\tawait app.invalidate('/load/change-detection/data.json');\n\t\texpect(await page.textContent('h1')).toBe('layout loads: 3');\n\t\texpect(await page.textContent('h2')).toBe('x: b: 3');\n\n\t\tawait app.invalidate('custom:change-detection-layout');\n\t\texpect(await page.textContent('h1')).toBe('layout loads: 4');\n\t\texpect(await page.textContent('h2')).toBe('x: b: 3');\n\n\t\tawait page.click('button:has-text(\"invalidate change-detection/data.json\")');\n\t\tawait page.waitForFunction('window.invalidated');\n\t\texpect(await page.textContent('h1')).toBe('layout loads: 5');\n\t\texpect(await page.textContent('h2')).toBe('x: b: 3');\n\n\t\tawait page.click('button:has-text(\"invalidate all\")');\n\t\tawait page.waitForFunction('window.invalidated');\n\t\texpect(await page.textContent('h1')).toBe('layout loads: 6');\n\t\texpect(await page.textContent('h2')).toBe('x: b: 4');\n\t});\n\n\tif (process.env.DEV) {\n\t\ttest('accessing url.hash from load errors and suggests using page state', async ({ page }) => {\n\t\t\tawait page.goto('/load/url-hash#please-dont-send-me-to-load');\n\t\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t\t'This is your custom error page saying: \"Cannot access event.url.hash. Consider using `page.url.hash` inside a component instead (500 Internal Error)\"'\n\t\t\t);\n\t\t});\n\t}\n\n\ttest('url instance methods work in load', async ({ page }) => {\n\t\tawait page.goto('/load/url-to-string');\n\t\texpect(await page.textContent('h1')).toBe(\"I didn't break!\");\n\t});\n\n\ttest('server data from previous is not reused if next page has no load function', async ({\n\t\tpage,\n\t\tapp\n\t}) => {\n\t\tawait page.goto('/load/server-data-reuse/with-server-load');\n\t\texpect(await page.textContent('pre')).toBe(\n\t\t\tJSON.stringify({ foo: { bar: 'Custom layout' }, server: true })\n\t\t);\n\t\tawait app.goto('/load/server-data-reuse/no-load');\n\t\texpect(await page.textContent('pre')).toBe(JSON.stringify({ foo: { bar: 'Custom layout' } }));\n\n\t\tawait page.goto('/load/server-data-reuse/with-changing-parent/with-server-load');\n\t\texpect(await page.textContent('pre')).toBe(\n\t\t\tJSON.stringify({\n\t\t\t\tfoo: { bar: 'Custom layout' },\n\t\t\t\ttitle: '/load/server-data-reuse/with-changing-parent/with-server-load',\n\t\t\t\tserver: true\n\t\t\t})\n\t\t);\n\t\tawait app.goto('/load/server-data-reuse/with-changing-parent/no-load');\n\t\texpect(await page.textContent('pre')).toBe(\n\t\t\tJSON.stringify({\n\t\t\t\tfoo: { bar: 'Custom layout' },\n\t\t\t\ttitle: '/load/server-data-reuse/with-changing-parent/no-load'\n\t\t\t})\n\t\t);\n\t});\n\n\ttest('keeps server data when valid while not reusing client load data', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/load/url-query-param');\n\n\t\texpect(await page.textContent('h1')).toBe('Hello ');\n\t\texpect(await page.textContent('p')).toBe('This text comes from the server load function');\n\n\t\tawait clicknav('a[href=\"/load/url-query-param?currentClientState=ABC\"]');\n\t\texpect(await page.textContent('h1')).toBe('Hello ABC');\n\t\texpect(await page.textContent('p')).toBe('This text comes from the server load function');\n\n\t\tawait clicknav('a[href=\"/load/url-query-param?currentClientState=DEF\"]');\n\t\texpect(await page.textContent('h1')).toBe('Hello DEF');\n\t\texpect(await page.textContent('p')).toBe('This text comes from the server load function');\n\n\t\tawait clicknav('a[href=\"/load/url-query-param\"]');\n\t\texpect(await page.textContent('h1')).toBe('Hello ');\n\t\texpect(await page.textContent('p')).toBe('This text comes from the server load function');\n\t});\n\n\ttest('load does not call fetch if max-age allows it', async ({ page }) => {\n\t\tawait page.addInitScript(`\n\t\t\twindow.now = 0;\n\t\t\twindow.performance.now = () => now;\n\t\t`);\n\n\t\tawait page.goto('/load/cache-control/default');\n\n\t\tconst button = page.locator('button');\n\t\tconst p = page.locator('p.counter');\n\n\t\tawait button.click();\n\t\tawait expect(button).toHaveAttribute('data-ticker', '2');\n\t\tawait expect(p).toHaveText('Count is 0');\n\n\t\tawait page.evaluate('window.now = 2500');\n\n\t\tawait button.click();\n\t\tawait expect(button).toHaveAttribute('data-ticker', '4');\n\t\tawait expect(p).toHaveText('Count is 2');\n\t});\n\n\ttest('load does ignore ttl if fetch cache options says so', async ({ page }) => {\n\t\tawait page.goto('/load/cache-control/force');\n\t\tconst p = page.locator('p.counter');\n\t\tawait expect(p).toHaveText('Count is 0');\n\t\tawait page.locator('button').click();\n\t\tawait expect(p).toHaveText('Count is 1');\n\t});\n\n\ttest('load busts cache if non-GET request to resource is made', async ({ page }) => {\n\t\tawait page.goto('/load/cache-control/bust');\n\t\tconst p = page.locator('p.counter');\n\t\tawait expect(p).toHaveText('Count is 0');\n\t\tawait page.locator('button').click();\n\t\tawait expect(p).toHaveText('Count is 1');\n\t});\n\n\ttest('__data.json has cache-control: private, no-store', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/server-data-nostore?x=1');\n\n\t\tconst [response] = await Promise.all([\n\t\t\tpage.waitForResponse((response) => /__data\\.js/.test(response.url())),\n\t\t\tclicknav('[href=\"/load/server-data-nostore?x=2\"]')\n\t\t]);\n\n\t\texpect(response.headers()['cache-control']).toBe('private, no-store');\n\t});\n\n\ttest('cache with body hash', async ({ page, clicknav }) => {\n\t\t// 1. go to the page (first load, we expect the right data)\n\t\tawait page.goto('/load/fetch-cache-control/load-data');\n\t\texpect(await page.textContent('div#fr')).toBe(JSON.stringify({ hi: 'bonjour' }));\n\t\texpect(await page.textContent('div#hu')).toBe(JSON.stringify({ hi: 'szia' }));\n\n\t\t// 2. change to another route (client side)\n\t\tawait clicknav('[href=\"/load/fetch-cache-control\"]');\n\n\t\t// 3. come back to the original page (client side)\n\t\tlet did_request_data = false;\n\t\tpage.on('request', (request) => {\n\t\t\tif (request.url().endsWith('fetch-cache-control/load-data')) {\n\t\t\t\tdid_request_data = true;\n\t\t\t}\n\t\t});\n\t\tawait clicknav('[href=\"/load/fetch-cache-control/load-data\"]');\n\n\t\t// 4. data should still be the same (and cached)\n\t\texpect(await page.textContent('div#fr')).toBe(JSON.stringify({ hi: 'bonjour' }));\n\t\texpect(await page.textContent('div#hu')).toBe(JSON.stringify({ hi: 'szia' }));\n\t\texpect(did_request_data).toBe(false);\n\t});\n\n\ttest('do not use cache if headers are different', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/fetch-cache-control/headers-diff');\n\n\t\t// 1. We expect the right data\n\t\tawait expect(page.locator('h2')).toHaveText('a / b');\n\n\t\t// 2. Change to another route (client side)\n\t\tawait clicknav('[href=\"/load/fetch-cache-control\"]');\n\n\t\t// 3. Come back to the original page (client side)\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (request) => {\n\t\t\tconst url = request.url();\n\t\t\t// Headless Chrome re-requests the favicon.png on every URL change\n\t\t\tif (url.endsWith('/favicon.png')) return;\n\t\t\trequests.push(url);\n\t\t});\n\t\tawait clicknav('[href=\"/load/fetch-cache-control/headers-diff\"]');\n\n\t\t// 4. We expect the same data and no new request (except a navigation request in case of server-side route resolution) because it was cached.\n\t\tawait expect(page.locator('h2')).toHaveText('a / b');\n\t\texpect(requests.filter((r) => !r.includes('/__route.js'))).toEqual([]);\n\t});\n\n\ttest('use correct cache result when fetching same url multiple times', async ({ page }) => {\n\t\tawait page.goto('/load/fetch-same-url');\n\t\texpect(await page.textContent('h1')).toBe('the result is 1,2,3');\n\t});\n\n\ttest('permits 3rd party patching of fetch in universal load functions', async ({ page }) => {\n\t\t/** @type {string[]} */\n\t\tconst logs = [];\n\t\tpage.on('console', (msg) => {\n\t\t\tif (msg.type() === 'log') {\n\t\t\t\tlogs.push(msg.text());\n\t\t\t}\n\t\t});\n\n\t\tawait page.goto('/load/window-fetch/patching');\n\t\texpect(await page.textContent('h1')).toBe('42');\n\n\t\texpect(logs).toContain('Called a patched window.fetch');\n\t});\n\n\ttest('permits 3rd party patching of server load fetch requests', async ({ page }) => {\n\t\tconst logs = [];\n\t\tpage.on('console', (msg) => {\n\t\t\tif (msg.type() === 'log') {\n\t\t\t\tlogs.push(msg.text());\n\t\t\t}\n\t\t});\n\n\t\tawait page.goto('/load/window-fetch/patching-server-load');\n\n\t\tawait page.getByText('Go To Page with Server Load').click();\n\n\t\texpect(await page.textContent('h1')).toBe('server load data');\n\n\t\texpect(logs).toContain('Called a patched window.fetch for server load request');\n\t});\n\n\ttest('does not repeat fetch on hydration when using Request object', async ({ page }) => {\n\t\tconst requests = [];\n\t\tpage.on('request', (request) => {\n\t\t\tif (request.url().includes('/load/fetch-request.json')) {\n\t\t\t\trequests.push(request);\n\t\t\t}\n\t\t});\n\n\t\tawait page.goto('/load/fetch-request-empty-headers');\n\n\t\tconsole.log({ requests });\n\n\t\texpect(requests).toEqual([]);\n\t});\n\n\tif (process.env.DEV) {\n\t\ttest('using window.fetch causes a warning', async ({ page, baseURL }) => {\n\t\t\tawait Promise.all([\n\t\t\t\tpage.goto('/load/window-fetch/incorrect'),\n\t\t\t\tpage.waitForEvent('console', {\n\t\t\t\t\tpredicate: (message) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tmessage.text() ===\n\t\t\t\t\t\t\t`Loading ${baseURL}/load/window-fetch/data.json using \\`window.fetch\\`. For best results, use the \\`fetch\\` that is passed to your \\`load\\` function: https://svelte.dev/docs/kit/load#making-fetch-requests`\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\ttimeout: 3_000\n\t\t\t\t})\n\t\t\t]);\n\t\t\texpect(await page.textContent('h1')).toBe('42');\n\n\t\t\t/** @type {string[]} */\n\t\t\tconst warnings = [];\n\t\t\tpage.on('console', (msg) => {\n\t\t\t\tif (msg.type() === 'warning') {\n\t\t\t\t\twarnings.push(msg.text());\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tawait page.goto('/load/window-fetch/correct');\n\t\t\texpect(await page.textContent('h1')).toBe('42');\n\n\t\t\texpect(warnings).not.toContain(\n\t\t\t\t`Loading ${baseURL}/load/window-fetch/data.json using \\`window.fetch\\`. For best results, use the \\`fetch\\` that is passed to your \\`load\\` function: https://svelte.dev/docs/kit/load#making-fetch-requests`\n\t\t\t);\n\t\t});\n\t}\n\n\tif (!process.env.DEV) {\n\t\ttest('does not fetch __data.json if no server load function exists', async ({\n\t\t\tpage,\n\t\t\tclicknav\n\t\t}) => {\n\t\t\tawait page.goto('/load/no-server-load/a');\n\n\t\t\t/** @type {string[]} */\n\t\t\tconst pathnames = [];\n\t\t\tpage.on('request', (r) => pathnames.push(new URL(r.url()).pathname));\n\t\t\tawait clicknav('[href=\"/load/no-server-load/b\"]');\n\n\t\t\texpect(pathnames).not.toContain('/load/no-server-load/b/__data.json');\n\t\t});\n\t}\n});\n\ntest.describe('SPA mode / no SSR', () => {\n\ttest('applies generated component styles (hides announcer)', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tget_computed_style\n\t}) => {\n\t\tawait page.goto('/no-ssr');\n\t\tawait clicknav('[href=\"/no-ssr/other\"]');\n\n\t\texpect(await get_computed_style('#svelte-announcer', 'position')).toBe('absolute');\n\t});\n\n\ttest('Can use browser-only global on client-only page through ssr config in handle', async ({\n\t\tpage,\n\t\tread_errors\n\t}) => {\n\t\tawait page.goto('/no-ssr/browser-only-global');\n\t\tawait expect(page.locator('p')).toHaveText('Works');\n\t\texpect(read_errors('/no-ssr/browser-only-global')).toBe(undefined);\n\t});\n\n\ttest('can use browser-only global on client-only page through ssr config in +layout.js', async ({\n\t\tpage,\n\t\tread_errors\n\t}) => {\n\t\tawait page.goto('/no-ssr/ssr-page-config');\n\t\tawait expect(page.locator('p')).toHaveText('Works');\n\t\texpect(read_errors('/no-ssr/ssr-page-config')).toBe(undefined);\n\t});\n\n\ttest('can use browser-only global on client-only page through ssr config in +page.js', async ({\n\t\tpage,\n\t\tread_errors\n\t}) => {\n\t\tawait page.goto('/no-ssr/ssr-page-config/layout/inherit');\n\t\tawait expect(page.locator('p')).toHaveText('Works');\n\t\texpect(read_errors('/no-ssr/ssr-page-config/layout/inherit')).toBe(undefined);\n\t});\n\n\ttest('cannot use browser-only global on page because of ssr config in +page.js', async ({\n\t\tpage\n\t}) => {\n\t\tawait page.goto('/no-ssr/ssr-page-config/layout/overwrite');\n\t\tawait expect(page.locator('p')).toHaveText(\n\t\t\t'This is your custom error page saying: \"document is not defined (500 Internal Error)\"'\n\t\t);\n\t});\n\n\ttest('afterNavigate is only called once during start', async ({ page }) => {\n\t\tawait page.goto('/no-ssr/after-navigate');\n\t\tawait expect(page.locator('p')).toHaveText('enter 1');\n\t});\n});\n\n// TODO SvelteKit 3: remove these tests\ntest.describe('$app/stores', () => {\n\ttest('can use $app/stores from anywhere on client', async ({ page }) => {\n\t\tawait page.goto('/store/client-access');\n\t\tawait expect(page.locator('h1')).toHaveText('undefined');\n\t\tawait page.locator('button').click();\n\t\tawait expect(page.locator('h1')).toHaveText('/store/client-access');\n\t});\n\n\ttest('$page.data does not update if data is unchanged', async ({ page, app }) => {\n\t\tawait page.goto('/store/data/store-update/a');\n\t\tawait app.goto('/store/data/store-update/b');\n\t\tawait expect(page.locator('p')).toHaveText('$page.data was updated 0 time(s)');\n\t});\n\n\ttest('$page.data does update if keys did not change but data did', async ({ page, app }) => {\n\t\tawait page.goto('/store/data/store-update/same-keys/same');\n\t\tawait app.goto('/store/data/store-update/same-keys');\n\t\tawait expect(page.locator('p')).toHaveText('$page.data was updated 1 time(s)');\n\t});\n\n\ttest('$page.data does update if keys did not change but data did (2)', async ({ page, app }) => {\n\t\tawait page.goto('/store/data/store-update/same-keys/same-deep/nested');\n\t\tawait app.goto('/store/data/store-update/same-keys');\n\t\tawait expect(page.locator('p')).toHaveText('$page.data was updated 1 time(s)');\n\t});\n\n\ttest('page subscribers are notified when invalidate is called', async ({ page }) => {\n\t\tawait page.goto('/store/subscribe');\n\t\tawait expect(page.locator('p')).toHaveText('1');\n\t\tawait page.locator('button', { hasText: 'invalidate' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('2');\n\t\tawait page.locator('button', { hasText: 'invalidate' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('3');\n\t});\n\n\ttest('page subscribers are notified when replaceState is called', async ({ page }) => {\n\t\tawait page.goto('/store/subscribe');\n\t\tawait expect(page.locator('p')).toHaveText('1');\n\t\tawait page.locator('button', { hasText: 'replaceState' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('2');\n\t\tawait page.locator('button', { hasText: 'replaceState' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('3');\n\t});\n\n\ttest('page subscribers are notified when pushState is called', async ({ page }) => {\n\t\tawait page.goto('/store/subscribe');\n\t\tawait expect(page.locator('p')).toHaveText('1');\n\t\tawait page.locator('button', { hasText: 'pushState' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('2');\n\t\tawait page.locator('button', { hasText: 'pushState' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('3');\n\t});\n\n\ttest('page subscribers are notified when goto is called', async ({ page }) => {\n\t\tawait page.goto('/store/subscribe');\n\t\tawait expect(page.locator('p')).toHaveText('1');\n\t\tawait page.locator('button', { hasText: 'goto' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('2');\n\t\tawait page.locator('button', { hasText: 'goto' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('3');\n\t});\n\n\ttest('page subscribers are notified when applyAction is called', async ({ page }) => {\n\t\tawait page.goto('/store/subscribe');\n\t\tawait expect(page.locator('p')).toHaveText('1');\n\t\tawait page.locator('button', { hasText: 'applyAction' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('2');\n\t\tawait page.locator('button', { hasText: 'applyAction' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('3');\n\t});\n\n\ttest('page subscribers are notified only once after popstate', async ({ page }) => {\n\t\tawait page.goto('/store/subscribe');\n\t\tawait expect(page.locator('p')).toHaveText('1');\n\t\tawait page.locator('button', { hasText: 'pushState' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('2');\n\t\tawait page.goBack();\n\t\tawait expect(page.locator('p')).toHaveText('3');\n\t});\n});\n\ntest.describe('$app/state', () => {\n\ttest('can use $app/state from anywhere on client', async ({ page }) => {\n\t\tawait page.goto('/state/client-access');\n\t\tawait expect(page.locator('h1')).toHaveText('undefined');\n\t\tawait page.locator('button').click();\n\t\tawait expect(page.locator('h1')).toHaveText('/state/client-access');\n\t});\n\n\ttest('page.data does not update if data is unchanged', async ({ page, app }) => {\n\t\tawait page.goto('/state/data/state-update/a');\n\t\tawait app.goto('/state/data/state-update/b');\n\t\tawait expect(page.locator('p')).toHaveText('page.data was updated 0 time(s)');\n\t});\n\n\ttest('page.data does update if keys did not change but data did', async ({ page, app }) => {\n\t\tawait page.goto('/state/data/state-update/same-keys/same');\n\t\tawait app.goto('/state/data/state-update/same-keys');\n\t\tawait expect(page.locator('p')).toHaveText('page.data was updated 1 time(s)');\n\t});\n\n\ttest('page.data does update if keys did not change but data did (2)', async ({ page, app }) => {\n\t\tawait page.goto('/state/data/state-update/same-keys/same-deep/nested');\n\t\tawait app.goto('/state/data/state-update/same-keys');\n\t\tawait expect(page.locator('p')).toHaveText('page.data was updated 1 time(s)');\n\t});\n\n\ttest('page.url does update when used with goto', async ({ page }) => {\n\t\tawait page.goto('/state/url');\n\t\tawait expect(page.locator('p')).toHaveText('undefined');\n\t\tawait page.locator('button').click();\n\t\tawait expect(page.locator('p')).toHaveText('test');\n\t});\n});\n\ntest.describe('Invalidation', () => {\n\ttest('+layout.server.js does not re-run when downstream load functions are invalidated', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/load/unchanged/isolated/a');\n\t\texpect(await page.textContent('h1')).toBe('slug: a');\n\t\texpect(await page.textContent('h2')).toBe('count: 0');\n\n\t\tawait clicknav('[href=\"/load/unchanged/isolated/b\"]');\n\t\texpect(await page.textContent('h1')).toBe('slug: b');\n\t\texpect(await page.textContent('h2')).toBe('count: 0');\n\t});\n\n\ttest('+layout.server.js re-runs when await parent() is called from downstream load function', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/load/unchanged-parent/uses-parent/a');\n\t\texpect(await page.textContent('h1')).toBe('slug: a');\n\t\texpect(await page.textContent('h2')).toBe('count: 0');\n\t\texpect(await page.textContent('h3')).toBe('doubled: 0');\n\n\t\tawait clicknav('[href=\"/load/unchanged-parent/uses-parent/b\"]');\n\t\texpect(await page.textContent('h1')).toBe('slug: b');\n\t\texpect(await page.textContent('h2')).toBe('count: 0');\n\n\t\t// this looks wrong, but is actually the intended behaviour (the increment side-effect in a GET would be a bug in a real app)\n\t\texpect(await page.textContent('h3')).toBe('doubled: 2');\n\t});\n\n\ttest('load function re-runs when searchParams change', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/invalidation/url?a=1');\n\t\texpect(await page.textContent('h1')).toBe('1');\n\n\t\tawait clicknav('[href=\"?a=2\"]');\n\t\texpect(await page.textContent('h1')).toBe('2');\n\n\t\tawait clicknav('[href=\"?a=3\"]');\n\t\texpect(await page.textContent('h1')).toBe('3');\n\t});\n\n\ttest('load function only re-runs when tracked searchParams change (universal)', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/load/invalidation/search-params/universal?tracked=0');\n\t\texpect(await page.textContent('span')).toBe('count: 0');\n\t\tawait clicknav('[data-id=\"tracked\"]');\n\t\texpect(await page.textContent('span')).toBe('count: 1');\n\t\tawait clicknav('[data-id=\"untracked\"]');\n\t\texpect(await page.textContent('span')).toBe('count: 1');\n\t});\n\n\ttest('load function only re-runs when tracked searchParams change (server)', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/load/invalidation/search-params/server?tracked=0');\n\t\texpect(await page.textContent('span')).toBe('count: 0');\n\t\tawait clicknav('[data-id=\"tracked\"]');\n\t\texpect(await page.textContent('span')).toBe('count: 1');\n\t\tawait clicknav('[data-id=\"untracked\"]');\n\t\texpect(await page.textContent('span')).toBe('count: 1');\n\t});\n\n\ttest('server-only load functions are re-run following forced invalidation', async ({\n\t\tpage,\n\t\trequest,\n\t\tbaseURL\n\t}) => {\n\t\tconst res = await request.post(baseURL + '/load/invalidation/forced/reset-states');\n\t\texpect(res.ok()).toBe(true);\n\n\t\tawait page.goto('/load/invalidation/forced');\n\t\texpect(await page.textContent('h1')).toBe('a: 0, b: 0');\n\n\t\tawait page.click('button.invalidateall');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\texpect(await page.textContent('h1')).toBe('a: 1, b: 1');\n\n\t\tawait page.click('button.invalidateall');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\texpect(await page.textContent('h1')).toBe('a: 2, b: 2');\n\t});\n\n\ttest('server-only load functions are re-run following goto with forced invalidation', async ({\n\t\tpage,\n\t\trequest,\n\t\tbaseURL\n\t}) => {\n\t\tconst res = await request.post(baseURL + '/load/invalidation/forced-goto/reset-states');\n\t\texpect(res.ok()).toBe(true);\n\t\tawait page.goto('/load/invalidation/forced-goto');\n\t\texpect(await page.textContent('h1')).toBe('a: 0, b: 0');\n\n\t\tawait page.click('button.goto');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\texpect(await page.textContent('h1')).toBe('a: 1, b: 1');\n\t});\n\n\ttest('multiple invalidations run concurrently', async ({ page }) => {\n\t\tawait page.goto('/load/invalidation/multiple');\n\t\tawait expect(page.getByText('layout: 0, page: 0')).toBeVisible();\n\n\t\tawait page.click('button.layout');\n\t\tawait page.click('button.layout');\n\t\tawait page.click('button.page');\n\t\tawait page.click('button.page');\n\t\tawait page.click('button.layout');\n\t\tawait page.click('button.page');\n\t\tawait page.click('button.all');\n\t\tawait expect(page.getByText('layout: 4, page: 4')).toBeVisible();\n\t});\n\n\ttest('multiple synchronous invalidations are batched', async ({ page }) => {\n\t\tawait page.goto('/load/invalidation/multiple-batched');\n\t\tconst btn = page.locator('#multiple-batched');\n\t\tawait expect(btn).toHaveText('0');\n\n\t\tawait btn.click();\n\t\tawait expect(btn).toHaveAttribute('data-done', 'true');\n\t\tawait expect(btn).toHaveText('2');\n\t});\n\n\ttest('invalidateAll persists through redirects', async ({ page }) => {\n\t\tawait page.goto('/load/invalidation/multiple/redirect');\n\t\tawait page.locator('button.redirect').click();\n\t\tawait expect(page.locator('p.redirect-state')).toHaveText('Redirect state: done');\n\t});\n\n\ttest('+layout(.server).js is re-run when server dep is invalidated', async ({ page }) => {\n\t\tawait page.goto('/load/invalidation/depends');\n\t\tconst server = await page.textContent('p.server');\n\t\tconst shared = await page.textContent('p.shared');\n\t\texpect(server).toBeDefined();\n\t\texpect(shared).toBeDefined();\n\n\t\tawait page.click('button.server');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\tconst next_server = await page.textContent('p.server');\n\t\tconst next_shared = await page.textContent('p.shared');\n\t\texpect(server).not.toBe(next_server);\n\t\texpect(shared).not.toBe(next_shared);\n\n\t\tawait page.click('button.neither');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\texpect(await page.textContent('p.server')).toBe(next_server);\n\t\texpect(await page.textContent('p.shared')).toBe(next_shared);\n\t});\n\n\ttest('fetch in server load cannot be invalidated', async ({ page, app, request }) => {\n\t\t// legacy behavior was to track server dependencies -- this could leak secrets to the client (see github.com/sveltejs/kit/pull/9945)\n\t\t// we keep this test just to make sure the behavior stays the same.\n\t\tawait request.get('/load/invalidation/server-fetch/count.json?reset');\n\t\tawait page.goto('/load/invalidation/server-fetch');\n\t\tconst selector = '[data-testid=\"count\"]';\n\n\t\texpect(await page.textContent(selector)).toBe('1');\n\t\tawait app.invalidate('/load/invalidation/server-fetch/count.json');\n\t\texpect(await page.textContent(selector)).toBe('1');\n\t});\n\n\ttest('+layout.js is re-run when shared dep is invalidated', async ({ page }) => {\n\t\tawait page.goto('/load/invalidation/depends');\n\t\tconst server = await page.textContent('p.server');\n\t\tconst shared = await page.textContent('p.shared');\n\t\texpect(server).toBeDefined();\n\t\texpect(shared).toBeDefined();\n\n\t\tawait page.click('button.shared');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\tconst next_server = await page.textContent('p.server');\n\t\tconst next_shared = await page.textContent('p.shared');\n\t\texpect(server).toBe(next_server);\n\t\texpect(shared).not.toBe(next_shared);\n\n\t\tawait page.click('button.neither');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\texpect(await page.textContent('p.server')).toBe(next_server);\n\t\texpect(await page.textContent('p.shared')).toBe(next_shared);\n\t});\n\n\ttest('+page(.server).js is re-run when server dep is invalidated following goto', async ({\n\t\tpage\n\t}) => {\n\t\tawait page.goto('/load/invalidation/depends-goto');\n\t\tconst layout = await page.textContent('p.layout');\n\t\tconst server = await page.textContent('p.server');\n\t\tconst shared = await page.textContent('p.shared');\n\t\texpect(layout).toBeDefined();\n\t\texpect(server).toBeDefined();\n\t\texpect(shared).toBeDefined();\n\n\t\tawait page.click('button.server');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\tconst next_layout = await page.textContent('p.layout');\n\t\tconst next_server = await page.textContent('p.server');\n\t\tconst next_shared = await page.textContent('p.shared');\n\t\texpect(layout).toBe(next_layout);\n\t\texpect(server).not.toBe(next_server);\n\t\texpect(shared).not.toBe(next_shared);\n\n\t\tawait page.click('button.neither');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\texpect(await page.textContent('p.layout')).toBe(next_layout);\n\t\texpect(await page.textContent('p.server')).toBe(next_server);\n\t\texpect(await page.textContent('p.shared')).toBe(next_shared);\n\t});\n\n\ttest('+page.js is re-run when shared dep is invalidated following goto', async ({ page }) => {\n\t\tawait page.goto('/load/invalidation/depends-goto');\n\t\tconst layout = await page.textContent('p.layout');\n\t\tconst server = await page.textContent('p.server');\n\t\tconst shared = await page.textContent('p.shared');\n\t\texpect(layout).toBeDefined();\n\t\texpect(server).toBeDefined();\n\t\texpect(shared).toBeDefined();\n\n\t\tawait page.click('button.shared');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\tconst next_layout = await page.textContent('p.layout');\n\t\tconst next_server = await page.textContent('p.server');\n\t\tconst next_shared = await page.textContent('p.shared');\n\t\texpect(layout).toBe(next_layout);\n\t\texpect(server).toBe(next_server);\n\t\texpect(shared).not.toBe(next_shared);\n\n\t\tawait page.click('button.neither');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\texpect(await page.textContent('p.layout')).toBe(next_layout);\n\t\texpect(await page.textContent('p.server')).toBe(next_server);\n\t\texpect(await page.textContent('p.shared')).toBe(next_shared);\n\t});\n\n\ttest('Specified dependencies are re-run following goto', async ({ page }) => {\n\t\tawait page.goto('/load/invalidation/depends-goto');\n\t\tconst layout = await page.textContent('p.layout');\n\t\tconst server = await page.textContent('p.server');\n\t\tconst shared = await page.textContent('p.shared');\n\t\texpect(layout).toBeDefined();\n\t\texpect(server).toBeDefined();\n\t\texpect(shared).toBeDefined();\n\n\t\tawait page.click('button.specified');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\tconst next_layout = await page.textContent('p.layout');\n\t\tconst next_server = await page.textContent('p.server');\n\t\tconst next_shared = await page.textContent('p.shared');\n\t\texpect(layout).not.toBe(next_layout);\n\t\texpect(server).toBe(next_server);\n\t\texpect(shared).not.toBe(next_shared);\n\n\t\tawait page.click('button.neither');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\texpect(await page.textContent('p.layout')).toBe(next_layout);\n\t\texpect(await page.textContent('p.server')).toBe(next_server);\n\t\texpect(await page.textContent('p.shared')).toBe(next_shared);\n\t});\n\n\ttest('Parameter use is tracked even for routes that do not use the parameters', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/load/invalidation/params');\n\n\t\tawait clicknav('[href=\"/load/invalidation/params/1\"]');\n\t\texpect(await page.textContent('pre')).toBe('{\"a\":\"1\"}');\n\n\t\tawait clicknav('[href=\"/load/invalidation/params/1/x\"]');\n\t\texpect(await page.textContent('pre')).toBe('{\"a\":\"1\",\"b\":\"x\"}');\n\n\t\tawait page.goBack();\n\t\texpect(await page.textContent('pre')).toBe('{\"a\":\"1\"}');\n\t});\n\n\ttest('route.id use is tracked for server-only load functions', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/invalidation/route/server/a');\n\t\texpect(await page.textContent('h1')).toBe('route.id: /load/invalidation/route/server/a');\n\n\t\tawait clicknav('[href=\"/load/invalidation/route/server/b\"]');\n\t\texpect(await page.textContent('h1')).toBe('route.id: /load/invalidation/route/server/b');\n\t});\n\n\ttest('route.id use is tracked for shared load functions', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/invalidation/route/shared/a');\n\t\texpect(await page.textContent('h1')).toBe('route.id: /load/invalidation/route/shared/a');\n\n\t\tawait clicknav('[href=\"/load/invalidation/route/shared/b\"]');\n\t\texpect(await page.textContent('h1')).toBe('route.id: /load/invalidation/route/shared/b');\n\t});\n\n\ttest('route.id does not rerun layout if unchanged', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/invalidation/route/shared/unchanged-x');\n\t\texpect(await page.textContent('h1')).toBe('route.id: /load/invalidation/route/shared/[x]');\n\t\tconst id = await page.textContent('h2');\n\n\t\tawait clicknav('[href=\"/load/invalidation/route/shared/unchanged-y\"]');\n\t\texpect(await page.textContent('h1')).toBe('route.id: /load/invalidation/route/shared/[x]');\n\t\texpect(await page.textContent('h2')).toBe(id);\n\t});\n\n\ttest('page.url can safely be mutated', async ({ page }) => {\n\t\tawait page.goto('/load/mutated-url?q=initial');\n\t\tawait expect(page.getByText('initial')).toBeVisible();\n\n\t\tawait page.locator('button').click();\n\t\tawait expect(page.getByText('updated')).toBeVisible();\n\t});\n\n\ttest('goto after invalidation does not reset state', async ({ page }) => {\n\t\tawait page.goto('/load/invalidation/invalidate-then-goto');\n\t\tconst layout = await page.textContent('p.layout');\n\t\tconst _page = await page.textContent('p.page');\n\t\texpect(layout).toBeDefined();\n\t\texpect(_page).toBeDefined();\n\n\t\tawait page.click('button.invalidate');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\tconst next_layout_1 = await page.textContent('p.layout');\n\t\tconst next_page_1 = await page.textContent('p.page');\n\t\texpect(next_layout_1).not.toBe(layout);\n\t\texpect(next_page_1).toBe(_page);\n\n\t\tawait page.click('button.goto');\n\t\tawait page.evaluate(\n\t\t\t() => /** @type {Window & typeof globalThis & { promise: Promise<void> }} */ (window).promise\n\t\t);\n\t\tconst next_layout_2 = await page.textContent('p.layout');\n\t\tconst next_page_2 = await page.textContent('p.page');\n\t\texpect(next_layout_2).toBe(next_layout_1);\n\t\texpect(next_page_2).not.toBe(next_page_1);\n\t});\n});\n\ntest.describe('data-sveltekit attributes', () => {\n\ttest('data-sveltekit-preload-code', async ({ page }) => {\n\t\t/** @type {string[]} */\n\t\tconst responses = [];\n\n\t\tconst nodes_location = process.env.DEV\n\t\t\t? '.svelte-kit/generated/client/nodes/'\n\t\t\t: '/_app/immutable/nodes/';\n\n\t\tpage.on('response', async (response) => {\n\t\t\tconst url = response.url();\n\t\t\tif (url.includes(nodes_location)) {\n\t\t\t\tresponses.push(url);\n\t\t\t}\n\t\t});\n\n\t\t// eager\n\t\tawait page.goto('/data-sveltekit/preload-code');\n\t\tawait page.locator('#eager').hover();\n\t\tawait page.locator('#eager').dispatchEvent('touchstart');\n\t\t// expect 4 nodes on initial load: root layout, root error, current page, and eager preload\n\t\texpect(responses.length).toEqual(4);\n\n\t\t// viewport\n\t\tresponses.length = 0;\n\t\tpage.locator('#viewport').scrollIntoViewIfNeeded();\n\t\tawait page.locator('#viewport').hover();\n\t\tawait page.locator('#viewport').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(responses.length).toEqual(1);\n\n\t\t// hover\n\t\tresponses.length = 0;\n\t\tawait page.locator('#hover').hover();\n\t\tawait page.locator('#hover').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(responses.length).toEqual(1);\n\n\t\t// tap\n\t\tresponses.length = 0;\n\t\tawait page.locator('#tap').hover();\n\t\tawait page.locator('#tap').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(responses.length).toEqual(1);\n\t});\n\n\ttest('data-sveltekit-preload-data', async ({ page }) => {\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (req) => {\n\t\t\tif (req.resourceType() === 'script') {\n\t\t\t\treq\n\t\t\t\t\t.response()\n\t\t\t\t\t.then(\n\t\t\t\t\t\t(res) => res?.text(),\n\t\t\t\t\t\t() => ''\n\t\t\t\t\t)\n\t\t\t\t\t.then((text) => {\n\t\t\t\t\t\tif (text?.includes('this string should only appear in this preloaded file')) {\n\t\t\t\t\t\t\trequests.push(req.url());\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (req.url().includes('__data.json')) {\n\t\t\t\trequests.push(req.url());\n\t\t\t}\n\t\t});\n\n\t\tawait page.goto('/data-sveltekit/preload-data');\n\t\tawait page.locator('#one').hover();\n\t\tawait page.locator('#one').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(requests.length).toBe(2);\n\n\t\trequests.length = 0;\n\t\tawait page.goto('/data-sveltekit/preload-data');\n\t\tawait page.locator('#two').hover();\n\t\tawait page.locator('#two').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(requests.length).toBe(2);\n\n\t\trequests.length = 0;\n\t\tawait page.goto('/data-sveltekit/preload-data');\n\t\tawait page.locator('#three').hover();\n\t\tawait page.locator('#three').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(requests.length).toBe(0);\n\n\t\trequests.length = 0;\n\t\tawait page.goto('/data-sveltekit/preload-data');\n\t\tawait page.locator('#tap').hover();\n\t\tawait page.locator('#tap').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(requests.length).toBe(2);\n\n\t\trequests.length = 0;\n\t\tawait page.goto('/data-sveltekit/preload-data');\n\t\tawait page.locator('#dynamic').hover();\n\t\tawait page.locator('#dynamic').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(requests.length).toBe(2);\n\t\tawait page.waitForTimeout(100);\n\t\tawait page.locator('#dynamic').hover();\n\t\tawait page.locator('#dynamic').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(requests.length).toBe(2);\n\t\tawait page.locator('#change_dynamic').click();\n\t\tawait page.waitForTimeout(100);\n\t\tawait page.locator('#dynamic').hover();\n\t\tawait page.locator('#dynamic').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(requests.length).toBe(3);\n\t});\n\n\ttest('data-sveltekit-preload-data network failure does not trigger navigation', async ({\n\t\tpage,\n\t\tcontext,\n\t\tbrowserName\n\t}) => {\n\t\tawait page.goto('/data-sveltekit/preload-data/offline');\n\n\t\tawait context.setOffline(true);\n\n\t\tawait page.locator('#one').dispatchEvent('mousemove');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\n\t\tlet offline_url = /\\/data-sveltekit\\/preload-data\\/offline/;\n\t\tif (browserName === 'chromium') {\n\t\t\t// it's chrome-error://chromewebdata/ on ubuntu but not on windows\n\t\t\toffline_url = /chrome-error:\\/\\/chromewebdata\\/|\\/data-sveltekit\\/preload-data\\/offline/;\n\t\t}\n\t\texpect(page).toHaveURL(offline_url);\n\t});\n\n\ttest('data-sveltekit-preload-data error does not block user navigation', async ({\n\t\tpage,\n\t\tcontext,\n\t\tbrowserName\n\t}) => {\n\t\tawait page.goto('/data-sveltekit/preload-data/offline');\n\n\t\tawait context.setOffline(true);\n\n\t\tawait page.locator('#one').dispatchEvent('mousemove');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\n\t\texpect(page).toHaveURL('/data-sveltekit/preload-data/offline');\n\n\t\tawait page.locator('#one').dispatchEvent('click');\n\t\tawait page.waitForTimeout(100); // wait for navigation to start\n\t\tawait page.waitForLoadState('networkidle');\n\n\t\tlet offline_url = /\\/data-sveltekit\\/preload-data\\/offline/;\n\t\tif (browserName === 'chromium') {\n\t\t\t// it's chrome-error://chromewebdata/ on ubuntu but not on windows\n\t\t\toffline_url = /chrome-error:\\/\\/chromewebdata\\/|\\/data-sveltekit\\/preload-data\\/offline/;\n\t\t}\n\t\texpect(page).toHaveURL(offline_url);\n\t});\n\n\ttest('data-sveltekit-preload does not abort ongoing navigation', async ({ page }) => {\n\t\tawait page.goto('/data-sveltekit/preload-data/offline');\n\n\t\tawait page.locator('#slow-navigation').dispatchEvent('click');\n\t\tawait page.waitForTimeout(100); // wait for navigation to start\n\t\tawait page.locator('#slow-navigation').dispatchEvent('mousemove');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\n\t\texpect(page).toHaveURL('/data-sveltekit/preload-data/offline/slow-navigation');\n\t});\n\n\ttest('data-sveltekit-preload does not abort ongoing navigation #2', async ({ page }) => {\n\t\tawait page.goto('/data-sveltekit/preload-data/offline');\n\n\t\tawait page.locator('#slow-navigation').dispatchEvent('click');\n\t\tawait page.waitForTimeout(100); // wait for navigation to start\n\t\tawait page.locator('#one').dispatchEvent('mousemove');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\n\t\texpect(page).toHaveURL('/data-sveltekit/preload-data/offline/slow-navigation');\n\t\tawait expect(page.getByText('slow navigation', { exact: true })).toBeVisible();\n\t});\n\n\ttest('data-sveltekit-preload-data tap works after data-sveltekit-preload-code hover', async ({\n\t\tpage\n\t}) => {\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (req) => {\n\t\t\tif (req.resourceType() === 'script') {\n\t\t\t\treq\n\t\t\t\t\t.response()\n\t\t\t\t\t.then(\n\t\t\t\t\t\t(res) => res?.text(),\n\t\t\t\t\t\t() => ''\n\t\t\t\t\t)\n\t\t\t\t\t.then((text) => {\n\t\t\t\t\t\tif (text?.includes('this string should only appear in this preloaded file')) {\n\t\t\t\t\t\t\trequests.push(req.url());\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (req.url().includes('__data.json')) {\n\t\t\t\trequests.push(req.url());\n\t\t\t}\n\t\t});\n\n\t\tawait page.goto('/data-sveltekit/preload-data');\n\t\tawait page.locator('#hover-then-tap').hover();\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(requests.length).toBe(1);\n\n\t\tawait page.locator('#hover-then-tap').dispatchEvent('touchstart');\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\t\texpect(requests.length).toBe(2);\n\t});\n\n\ttest('data-sveltekit-reload', async ({ baseURL, page, clicknav }) => {\n\t\tawait page.goto('/data-sveltekit/reload');\n\t\tlet request_promise = page.waitForRequest(`${baseURL}/data-sveltekit/reload/target`);\n\t\tawait clicknav('#one');\n\t\tawait request_promise;\n\n\t\tawait page.goto('/data-sveltekit/reload');\n\t\trequest_promise = page.waitForRequest(`${baseURL}/data-sveltekit/reload/target`);\n\t\tawait clicknav('#two');\n\t\tawait request_promise;\n\n\t\tawait page.goto('/data-sveltekit/reload');\n\t\trequest_promise = page.waitForRequest(`${baseURL}/data-sveltekit/reload/target`, {\n\t\t\ttimeout: 1000\n\t\t});\n\t\trequest_promise.catch(() => {});\n\t\tawait clicknav('#three');\n\t\tawait expect(request_promise).rejects.toThrow();\n\t});\n\n\ttest('data-sveltekit-noscroll', async ({ page, clicknav }) => {\n\t\tawait page.goto('/data-sveltekit/noscroll');\n\t\t// await page.evaluate(() => window.scrollTo(0, 1000));\n\t\tawait clicknav('#one');\n\t\texpect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(1000);\n\n\t\tawait page.goto('/data-sveltekit/noscroll');\n\t\tawait clicknav('#two');\n\t\texpect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(1000);\n\n\t\tawait page.goto('/data-sveltekit/noscroll');\n\t\t// await page.evaluate(() => window.scrollTo(0, 1000));\n\t\tawait clicknav('#three');\n\t\texpect(await page.evaluate(() => window.scrollY)).toBe(0);\n\t});\n\n\ttest('data-sveltekit-replacestate', async ({ page, clicknav }) => {\n\t\tawait page.goto('/');\n\t\tawait page.goto('/data-sveltekit/replacestate');\n\t\tawait clicknav('#one');\n\t\tawait page.goBack();\n\t\tawait expect(page).not.toHaveURL(/replacestate/);\n\n\t\tawait page.goto('/');\n\t\tawait page.goto('/data-sveltekit/replacestate');\n\t\tawait clicknav('#two');\n\t\tawait page.goBack();\n\t\tawait expect(page).not.toHaveURL(/replacestate/);\n\n\t\tawait page.goto('/');\n\t\tawait page.goto('/data-sveltekit/replacestate');\n\t\tawait clicknav('#three');\n\t\tawait page.goBack();\n\t\tawait expect(page).toHaveURL(/replacestate$/);\n\t});\n});\n\ntest.describe('Content negotiation', () => {\n\ttest('+server.js next to +page.svelte works', async ({ page }) => {\n\t\tconst response = await page.goto('/routing/content-negotiation');\n\n\t\texpect(response?.headers()['vary']).toBe('Accept');\n\t\texpect(await page.textContent('p')).toBe('Hi');\n\n\t\tconst pre = page.locator('pre');\n\t\tfor (const method of ['GET', 'PUT', 'PATCH', 'POST', 'DELETE']) {\n\t\t\tawait page.click(`button:has-text(\"${method}\")`);\n\t\t\tawait expect(pre).toHaveText(method);\n\t\t}\n\t});\n\n\ttest('use:enhance uses action, not POST handler', async ({ page }) => {\n\t\tawait page.goto('/routing/content-negotiation');\n\n\t\tawait Promise.all([\n\t\t\tpage.waitForResponse('/routing/content-negotiation'),\n\t\t\tpage.click('button:has-text(\"Submit\")')\n\t\t]);\n\n\t\tawait expect(page.locator('[data-testid=\"form-result\"]')).toHaveText('form.submitted: true');\n\t});\n});\n\ntest.describe('env', () => {\n\ttest('can access public env in app.html', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\texpect(await page.locator('body').getAttribute('class')).toContain('groovy');\n\t});\n\n\ttest('can access public env in hooks.client.js', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\texpect(\n\t\t\tawait page.evaluate(\n\t\t\t\t() =>\n\t\t\t\t\t/** @type {Window & typeof globalThis & { PUBLIC_DYNAMIC: string }} */ (window)\n\t\t\t\t\t\t.PUBLIC_DYNAMIC\n\t\t\t)\n\t\t).toBe('accessible anywhere/evaluated at run time');\n\t});\n\n\ttest('uses correct dynamic env when navigating from prerendered page', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/prerendering/env/prerendered');\n\t\tawait clicknav('[href=\"/prerendering/env/dynamic\"]');\n\t\texpect(await page.locator('h2')).toHaveText('prerendering: false');\n\t});\n});\n\ntest.describe('Snapshots', () => {\n\ttest('recovers snapshotted data', async ({ page, clicknav }) => {\n\t\tawait page.goto('/snapshot/a');\n\n\t\tlet input = page.locator('input');\n\t\tawait input.type('hello');\n\n\t\tawait clicknav('[href=\"/snapshot/b\"]');\n\t\tawait page.goBack();\n\n\t\tinput = page.locator('input');\n\t\texpect(await input.inputValue()).toBe('hello');\n\n\t\tawait input.clear();\n\t\tawait input.type('works for cross-document navigations');\n\n\t\tawait clicknav('[href=\"/snapshot/c\"]');\n\t\tawait page.goBack();\n\t\texpect(await page.locator('input').inputValue()).toBe('works for cross-document navigations');\n\n\t\tinput = page.locator('input');\n\t\tawait input.clear();\n\t\tawait input.type('works for reloads');\n\n\t\tawait page.reload();\n\t\texpect(await page.locator('input').inputValue()).toBe('works for reloads');\n\t});\n});\n\ntest.describe('Streaming', () => {\n\ttest('Works for universal load functions (client nav)', async ({ page }) => {\n\t\tawait page.goto('/streaming');\n\t\tpage.click('[href=\"/streaming/universal\"]');\n\n\t\tawait expect(page.locator('p.eager')).toHaveText('eager');\n\t\texpect(page.locator('p.loadingsuccess')).toBeVisible();\n\t\texpect(page.locator('p.loadingfail')).toBeVisible();\n\n\t\tawait expect(page.locator('p.success')).toHaveText('success');\n\t\tawait expect(page.locator('p.fail')).toHaveText('fail');\n\t\texpect(page.locator('p.loadingsuccess')).toBeHidden();\n\t\texpect(page.locator('p.loadingfail')).toBeHidden();\n\t});\n\n\ttest('Works for server load functions (client nav)', async ({ page }) => {\n\t\tawait page.goto('/streaming');\n\t\tpage.click('[href=\"/streaming/server\"]');\n\n\t\tawait expect(page.locator('p.eager')).toHaveText('eager');\n\t\texpect(page.locator('p.loadingsuccess')).toBeVisible();\n\t\texpect(page.locator('p.loadingfail')).toBeVisible();\n\n\t\tawait expect(page.locator('p.success')).toHaveText('success', { timeout: 15000 });\n\t\tawait expect(page.locator('p.fail')).toHaveText('fail (500 Internal Error)', {\n\t\t\ttimeout: 15000\n\t\t});\n\t\texpect(page.locator('p.loadingsuccess')).toBeHidden();\n\t\texpect(page.locator('p.loadingfail')).toBeHidden();\n\t});\n\n\ttest('Catches fetch errors from server load functions (client nav)', async ({ page }) => {\n\t\tawait page.goto('/streaming');\n\t\tpage.click('[href=\"/streaming/server-error\"]');\n\n\t\tawait expect(page.locator('p.eager')).toHaveText('eager');\n\t\texpect(page.locator('p.fail')).toBeVisible();\n\t});\n\n\t// TODO `vite preview` buffers responses, causing these tests to fail\n\tif (process.env.DEV) {\n\t\ttest('Works for universal load functions (direct hit)', async ({ page }) => {\n\t\t\tpage.goto('/streaming/universal');\n\n\t\t\t// Write first assertion like this to control the retry interval. Else it might happen that\n\t\t\t// the test fails because the next retry is too late (probably uses a back-off strategy)\n\t\t\tawait expect(async () => {\n\t\t\t\texpect(await page.locator('p.eager').textContent()).toBe('eager');\n\t\t\t}).toPass({\n\t\t\t\tintervals: [100]\n\t\t\t});\n\n\t\t\texpect(page.locator('p.loadingsuccess')).toBeVisible();\n\t\t\texpect(page.locator('p.loadingfail')).toBeVisible();\n\n\t\t\tawait expect(page.locator('p.success')).toHaveText('success');\n\t\t\tawait expect(page.locator('p.fail')).toHaveText('fail');\n\t\t\texpect(page.locator('p.loadingsuccess')).toBeHidden();\n\t\t\texpect(page.locator('p.loadingfail')).toBeHidden();\n\t\t});\n\n\t\ttest('Works for server load functions (direct hit)', async ({ page }) => {\n\t\t\tpage.goto('/streaming/server');\n\n\t\t\t// Write first assertion like this to control the retry interval. Else it might happen that\n\t\t\t// the test fails because the next retry is too late (probably uses a back-off strategy)\n\t\t\tawait expect(async () => {\n\t\t\t\texpect(await page.locator('p.eager').textContent()).toBe('eager');\n\t\t\t}).toPass({\n\t\t\t\tintervals: [100]\n\t\t\t});\n\n\t\t\texpect(page.locator('p.loadingsuccess')).toBeVisible();\n\t\t\texpect(page.locator('p.loadingfail')).toBeVisible();\n\n\t\t\tawait expect(page.locator('p.success')).toHaveText('success');\n\t\t\tawait expect(page.locator('p.fail')).toHaveText('fail (500 Internal Error)');\n\t\t\texpect(page.locator('p.loadingsuccess')).toBeHidden();\n\t\t\texpect(page.locator('p.loadingfail')).toBeHidden();\n\t\t});\n\n\t\ttest('Works with a fast and a slow server load functions which (direct hit)', async ({\n\t\t\tpage\n\t\t}) => {\n\t\t\tawait page.goto('/streaming/server/fast-n-slow');\n\n\t\t\texpect(await page.locator('p.ssrd').textContent()).toBe('ssrd');\n\t\t\tawait expect(page.locator('p.fast')).toHaveText('fast');\n\t\t\tawait expect(page.locator('p.streamed')).toHaveText('streamed');\n\t\t});\n\n\t\ttest('Catches fetch errors from server load functions (direct hit)', async ({ page }) => {\n\t\t\tpage.goto('/streaming/server-error');\n\t\t\tawait expect(page.locator('p.eager')).toHaveText('eager');\n\t\t\tawait expect(page.locator('p.fail')).toHaveText('fail');\n\t\t});\n\t}\n});\n\ntest.describe('Actions', () => {\n\ttest('page state has correct data', async ({ page }) => {\n\t\tawait page.goto('/actions/enhance');\n\t\tconst pre = page.locator('pre.data1');\n\n\t\tawait expect(pre).toHaveText('prop: 0, state: 0');\n\t\tawait page.locator('.form4').click();\n\t\tawait expect(pre).toHaveText('prop: 1, state: 1');\n\t\tawait page.evaluate('window.svelte_tick()');\n\t\tawait expect(pre).toHaveText('prop: 1, state: 1');\n\t});\n});\n\ntest.describe('Assets', () => {\n\ttest('only one link per stylesheet', async ({ page }) => {\n\t\tif (process.env.DEV) return;\n\n\t\tawait page.goto('/');\n\n\t\texpect(\n\t\t\tawait page.evaluate(() => {\n\t\t\t\t/** @type {HTMLLinkElement[]} */\n\t\t\t\tconst links = Array.from(document.head.querySelectorAll('link[rel=stylesheet]'));\n\n\t\t\t\tfor (let i = 0; i < links.length; ) {\n\t\t\t\t\tconst link = links.shift();\n\t\t\t\t\tconst asset_name = link?.href.split('/').at(-1);\n\t\t\t\t\tif (asset_name && links.some((link) => link.href.includes(asset_name))) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t})\n\t\t).toBe(true);\n\t});\n});\n\ntest.describe('goto', () => {\n\ttest('goto fails with external URL', async ({ page }) => {\n\t\tawait page.goto('/goto');\n\t\tawait page.click('button');\n\n\t\tconst message = process.env.DEV\n\t\t\t? 'Cannot use `goto` with an external URL. Use `window.location = \"https://example.com/\"` instead'\n\t\t\t: 'goto: invalid URL';\n\t\tawait expect(page.locator('p')).toHaveText(message);\n\t});\n\n\ttest.describe('navigation and redirects should be consistent between web native and sveltekit based', () => {\n\t\tconst testEntryPage = '/goto/testentry';\n\t\tconst testStartPage = '/goto/teststart';\n\t\tconst testFinishPage = '/goto/testfinish';\n\t\tconst nonexistentPage = '/goto/nonexistent';\n\t\tconst loadReplacePage = '/goto/loadreplace1';\n\n\t\ttest.beforeEach(async ({ page }) => {\n\t\t\tawait page.goto(testEntryPage);\n\t\t\tawait page.goto(testStartPage);\n\n\t\t\tawait expect(page).toHaveURL(testStartPage);\n\t\t});\n\n\t\t/**\n\t\t * @param {string} from\n\t\t * @param {string} to\n\t\t * @returns {(page: import('@playwright/test').Page) => Promise<void>}\n\t\t */\n\t\tfunction makeExpectGoback(from, to) {\n\t\t\treturn async (page) => {\n\t\t\t\tawait expect(page).toHaveURL(from);\n\t\t\t\tawait page.goBack();\n\t\t\t\tawait expect(page).toHaveURL(to);\n\t\t\t};\n\t\t}\n\n\t\ttest.describe('navigating outside the app on sameorigin', () => {\n\t\t\ttest.describe('without replace', () => {\n\t\t\t\tconst expectGoback = makeExpectGoback(nonexistentPage, testStartPage);\n\n\t\t\t\ttest('app.goto', async ({ app, page }) => {\n\t\t\t\t\t// navigating to nonexistent page causes playwright's page context to be destroyed\n\t\t\t\t\t// thus this call throws an error unless caught\n\t\t\t\t\tawait app.goto(nonexistentPage, { replaceState: false }).catch(() => {});\n\t\t\t\t\tawait expectGoback(page);\n\t\t\t\t});\n\n\t\t\t\ttest('location.assign', async ({ page }) => {\n\t\t\t\t\tawait page.evaluate((url) => {\n\t\t\t\t\t\tlocation.assign(url);\n\t\t\t\t\t}, nonexistentPage);\n\t\t\t\t\tawait expectGoback(page);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\ttest.describe('with replace', () => {\n\t\t\t\tconst expectGoback = makeExpectGoback(nonexistentPage, testEntryPage);\n\n\t\t\t\ttest('app.goto', async ({ app, page }) => {\n\t\t\t\t\t// navigating to nonexistent page causes playwright's page context to be destroyed\n\t\t\t\t\t// thus this call throws an error unless caught\n\t\t\t\t\tawait app.goto(nonexistentPage, { replaceState: true }).catch(() => {});\n\t\t\t\t\tawait expectGoback(page);\n\t\t\t\t});\n\n\t\t\t\ttest('location.replace', async ({ page }) => {\n\t\t\t\t\tawait page.evaluate((url) => {\n\t\t\t\t\t\tlocation.replace(url);\n\t\t\t\t\t}, nonexistentPage);\n\t\t\t\t\tawait expectGoback(page);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\ttest.describe('redirect after invalidation', () => {\n\t\t\ttest.beforeEach(async ({ app }) => {\n\t\t\t\tawait app.goto(`${testStartPage}?redirect`, { replaceState: true });\n\t\t\t});\n\n\t\t\tconst expectGoback = makeExpectGoback(testFinishPage, testEntryPage);\n\n\t\t\ttest('app.invalidate', async ({ app, page }) => {\n\t\t\t\tawait app.invalidate('app:goto');\n\t\t\t\tawait expectGoback(page);\n\t\t\t});\n\n\t\t\ttest('location.reload', async ({ page }) => {\n\t\t\t\tawait page.evaluate(() => {\n\t\t\t\t\tlocation.reload();\n\t\t\t\t});\n\t\t\t\tawait expectGoback(page);\n\t\t\t});\n\t\t});\n\n\t\ttest.describe('navigating through redirect chain', () => {\n\t\t\ttest.describe('without replace', () => {\n\t\t\t\tconst expectGoback = makeExpectGoback(testFinishPage, testStartPage);\n\n\t\t\t\ttest('app.goto', async ({ app, page }) => {\n\t\t\t\t\tawait app.goto(loadReplacePage, { replaceState: false });\n\n\t\t\t\t\tawait expectGoback(page);\n\t\t\t\t});\n\n\t\t\t\ttest('location.assign', async ({ page }) => {\n\t\t\t\t\tawait page.evaluate((url) => {\n\t\t\t\t\t\tlocation.assign(url);\n\t\t\t\t\t}, loadReplacePage);\n\n\t\t\t\t\tawait expectGoback(page);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\ttest.describe('with replace', () => {\n\t\t\t\tconst expectGoback = makeExpectGoback(testFinishPage, testEntryPage);\n\n\t\t\t\ttest('app.goto', async ({ app, page }) => {\n\t\t\t\t\tawait app.goto(loadReplacePage, { replaceState: true });\n\n\t\t\t\t\tawait expectGoback(page);\n\t\t\t\t});\n\n\t\t\t\ttest('location.replace', async ({ page }) => {\n\t\t\t\t\tawait page.evaluate((url) => {\n\t\t\t\t\t\tlocation.replace(url);\n\t\t\t\t\t}, loadReplacePage);\n\n\t\t\t\t\tawait expectGoback(page);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t});\n});\n\ntest.describe('untrack', () => {\n\ttest('untracks server load function', async ({ page, clicknav }) => {\n\t\tawait page.goto('/untrack/server/1');\n\t\texpect(await page.textContent('p.url')).toBe('/untrack/server/1');\n\t\tconst id = await page.textContent('p.id');\n\t\tawait clicknav('a[href=\"/untrack/server/2\"]');\n\t\texpect(await page.textContent('p.url')).toBe('/untrack/server/2');\n\t\texpect(await page.textContent('p.id')).toBe(id);\n\t});\n\n\ttest('untracks universal load function', async ({ page, clicknav }) => {\n\t\tawait page.goto('/untrack/universal/1');\n\t\texpect(await page.textContent('p.url')).toBe('/untrack/universal/1');\n\t\tconst id = await page.textContent('p.id');\n\t\tawait clicknav('a[href=\"/untrack/universal/2\"]');\n\t\texpect(await page.textContent('p.url')).toBe('/untrack/universal/2');\n\t\texpect(await page.textContent('p.id')).toBe(id);\n\t});\n});\n\ntest.describe('Shallow routing', () => {\n\ttest('Pushes state to the current URL', async ({ page }) => {\n\t\tawait page.goto('/shallow-routing/push-state');\n\t\tawait expect(page.locator('p')).toHaveText('active: false');\n\n\t\tawait page.locator('[data-id=\"one\"]').click();\n\t\tawait expect(page.locator('p')).toHaveText('active: true');\n\n\t\tawait page.goBack();\n\t\tawait expect(page.locator('p')).toHaveText('active: false');\n\t});\n\n\ttest('Pushes state to a new URL', async ({ baseURL, page }) => {\n\t\tawait page.goto('/shallow-routing/push-state');\n\t\tawait expect(page.locator('p')).toHaveText('active: false');\n\n\t\tawait page.locator('[data-id=\"two\"]').click();\n\t\texpect(page.url()).toBe(`${baseURL}/shallow-routing/push-state/a`);\n\t\tawait expect(page.locator('h1')).toHaveText('parent');\n\t\tawait expect(page.locator('p')).toHaveText('active: true');\n\n\t\tawait page.reload();\n\t\tawait expect(page.locator('h1')).toHaveText('a');\n\t\tawait expect(page.locator('p')).toHaveText('active: false');\n\n\t\tawait page.goBack();\n\t\texpect(page.url()).toBe(`${baseURL}/shallow-routing/push-state`);\n\t\tawait expect(page.locator('h1')).toHaveText('parent');\n\t\tawait expect(page.locator('p')).toHaveText('active: false');\n\n\t\tawait page.goForward();\n\t\texpect(page.url()).toBe(`${baseURL}/shallow-routing/push-state/a`);\n\t\tawait expect(page.locator('h1')).toHaveText('parent');\n\t\tawait expect(page.locator('p')).toHaveText('active: true');\n\t});\n\n\ttest('Invalidates the correct route after pushing state to a new URL', async ({\n\t\tbaseURL,\n\t\tpage\n\t}) => {\n\t\tawait page.goto('/shallow-routing/push-state');\n\t\tawait expect(page.locator('p')).toHaveText('active: false');\n\n\t\tconst now = /** @type {string} */ (await page.locator('span').textContent());\n\n\t\tawait page.locator('[data-id=\"two\"]').click();\n\t\texpect(page.url()).toBe(`${baseURL}/shallow-routing/push-state/a`);\n\n\t\tawait page.locator('[data-id=\"invalidate\"]').click();\n\t\tawait expect(page.locator('h1')).toHaveText('parent');\n\t\tawait expect(page.locator('span')).not.toHaveText(now);\n\t});\n\n\ttest('Does not navigate when going back to shallow route', async ({ baseURL, page }) => {\n\t\tawait page.goto('/shallow-routing/push-state');\n\t\tawait page.locator('[data-id=\"two\"]').click();\n\t\tawait page.goBack();\n\t\tawait page.goForward();\n\n\t\texpect(page.url()).toBe(`${baseURL}/shallow-routing/push-state/a`);\n\t\tawait expect(page.locator('h1')).toHaveText('parent');\n\t\tawait expect(page.locator('p')).toHaveText('active: true');\n\t});\n\n\ttest('Replaces state on the current URL', async ({ baseURL, page, clicknav }) => {\n\t\tawait page.goto('/shallow-routing/replace-state/b');\n\t\tawait clicknav('[href=\"/shallow-routing/replace-state\"]');\n\n\t\tawait page.locator('[data-id=\"one\"]').click();\n\t\tawait expect(page.locator('p')).toHaveText('active: true');\n\n\t\tawait page.goBack();\n\t\texpect(page.url()).toBe(`${baseURL}/shallow-routing/replace-state/b`);\n\t\tawait expect(page.locator('h1')).toHaveText('b');\n\n\t\tawait page.goForward();\n\t\texpect(page.url()).toBe(`${baseURL}/shallow-routing/replace-state`);\n\t\tawait expect(page.locator('h1')).toHaveText('parent');\n\t\tawait expect(page.locator('p')).toHaveText('active: true');\n\t});\n\n\ttest('Replaces state on a new URL', async ({ baseURL, page, clicknav }) => {\n\t\tawait page.goto('/shallow-routing/replace-state/b');\n\t\tawait clicknav('[href=\"/shallow-routing/replace-state\"]');\n\n\t\tawait page.locator('[data-id=\"two\"]').click();\n\t\tawait expect(page.locator('p')).toHaveText('active: true');\n\n\t\tawait page.goBack();\n\t\texpect(page.url()).toBe(`${baseURL}/shallow-routing/replace-state/b`);\n\t\tawait expect(page.locator('h1')).toHaveText('b');\n\n\t\tawait page.goForward();\n\t\texpect(page.url()).toBe(`${baseURL}/shallow-routing/replace-state/a`);\n\t\tawait expect(page.locator('h1')).toHaveText('parent');\n\t\tawait expect(page.locator('p')).toHaveText('active: true');\n\t});\n\n\ttest('pushState does not loop infinitely in $effect', async ({ page }) => {\n\t\tawait page.goto('/shallow-routing/push-state/effect');\n\t\tawait expect(page.locator('p')).toHaveText('count: 0');\n\t\tawait page.locator('button').click();\n\t\tawait expect(page.locator('p')).toHaveText('count: 1');\n\t});\n\n\ttest('replaceState does not loop infinitely in $effect', async ({ page }) => {\n\t\tawait page.goto('/shallow-routing/replace-state/effect');\n\t\tawait expect(page.locator('p')).toHaveText('count: 0');\n\t\tawait page.locator('button').click();\n\t\tawait expect(page.locator('p')).toHaveText('count: 1');\n\t});\n});\n\ntest.describe('reroute', () => {\n\ttest('Apply reroute during client side navigation', async ({ page, clicknav }) => {\n\t\tawait page.goto('/reroute/basic');\n\t\tawait clicknav('a[href=\"/reroute/basic/a\"]', { waitForURL: '/reroute/basic/a' });\n\t\texpect(await page.textContent('h1')).toContain(\n\t\t\t'Successfully rewritten, URL should still show a: /reroute/basic/a'\n\t\t);\n\t});\n\n\ttest('Apply async reroute during client side navigation', async ({ page }) => {\n\t\tpage\n\t\t\t.context()\n\t\t\t.addCookies([{ name: 'reroute-cookie', value: 'yes', path: '/', domain: 'localhost' }]);\n\t\tawait page.goto('/reroute/async');\n\t\tawait page.click(\"a[href='/reroute/async/a']\");\n\t\texpect(await page.textContent('h1')).toContain(\n\t\t\t'Successfully rewritten, URL should still show a: /reroute/async/a'\n\t\t);\n\t});\n\n\ttest('Apply async prerendered reroute during client side navigation', async ({ page }) => {\n\t\tawait page.goto('/reroute/async');\n\t\tawait page.click(\"a[href='/reroute/async/c']\");\n\t\texpect(await page.textContent('h1')).toContain(\n\t\t\t'Successfully rewritten, URL should still show a: /reroute/async/c'\n\t\t);\n\t});\n\n\ttest('Apply reroute to prerendered page during client side navigation', async ({ page }) => {\n\t\tawait page.goto('/reroute/prerendered');\n\t\tawait page.click(\"a[href='/reroute/prerendered/to-destination']\");\n\t\texpect(await page.textContent('h1')).toContain('reroute that points to prerendered page works');\n\t});\n\n\ttest('Apply reroute after client-only redirects', async ({ page }) => {\n\t\tawait page.goto('/reroute/client-only-redirect');\n\t\texpect(await page.textContent('h1')).toContain('Successfully rewritten');\n\t});\n\n\ttest('Apply reroute to preload data', async ({ page }) => {\n\t\tif (process.env.SVELTE_ASYNC === 'true') return; // TODO investigate\n\t\tawait page.goto('/reroute/preload-data');\n\t\tawait page.click('button');\n\t\tawait page.waitForSelector('pre');\n\t\texpect(await page.textContent('pre')).toContain('\"success\": true');\n\t});\n\n\ttest('reroute does not get applied to external URLs', async ({ page }) => {\n\t\tawait page.goto('/reroute/external');\n\t\tconst current_url = new URL(page.url());\n\n\t\t// click the link with the text External URL\n\t\tawait page.click(\"a[data-test='external-url']\");\n\n\t\t// The URL should not have the same origin as the current URL\n\t\tconst new_url = new URL(page.url());\n\t\texpect(current_url.origin).not.toEqual(new_url.origin);\n\t});\n\n\ttest('Falls back to native navigation if reroute throws on the client', async ({ page }) => {\n\t\tawait page.goto('/reroute/error-handling');\n\n\t\t//click the link with the text External URL\n\t\tawait page.click('a#client-error');\n\n\t\texpect(await page.textContent('h1')).toContain('Full Navigation');\n\t});\n\n\ttest('reroute works with invalidate', async ({ page }) => {\n\t\tawait page.goto('/reroute/invalidate/a');\n\t\tawait page.click('button');\n\t\tawait expect(page.locator('p')).toHaveText('data request: true');\n\t});\n});\n\ntest.describe('init', () => {\n\ttest('init client hook is called once when the application start on the client', async ({\n\t\tpage\n\t}) => {\n\t\t/**\n\t\t * @type string[]\n\t\t */\n\t\tconst logs = [];\n\t\tpage.addListener('console', (message) => {\n\t\t\tif (message.type() === 'log') {\n\t\t\t\tlogs.push(message.text());\n\t\t\t}\n\t\t});\n\t\tconst log_event = page.waitForEvent('console');\n\t\tawait page.goto('/init-hooks');\n\t\tawait log_event;\n\t\texpect(logs).toStrictEqual(['init hooks.client.js']);\n\t\tawait page.getByRole('link').first().click();\n\t\tawait page.waitForLoadState('load');\n\t\texpect(logs).toStrictEqual(['init hooks.client.js']);\n\t});\n});\n\ntest.describe('INP', () => {\n\ttest('does not block next paint', async ({ page }) => {\n\t\t// Thanks to https://publishing-project.rivendellweb.net/measuring-performance-tasks-with-playwright/#interaction-to-next-paint-inp\n\t\tasync function measureInteractionToPaint(selector) {\n\t\t\treturn page.evaluate(async (selector) => {\n\t\t\t\treturn new Promise((resolve) => {\n\t\t\t\t\tconst startTime = performance.now();\n\t\t\t\t\tdocument.querySelector(selector).click();\n\t\t\t\t\trequestAnimationFrame(() => {\n\t\t\t\t\t\tconst endTime = performance.now();\n\t\t\t\t\t\tresolve(endTime - startTime);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}, selector);\n\t\t}\n\n\t\tawait page.goto('/routing');\n\n\t\tconst client = await page.context().newCDPSession(page);\n\t\tawait client.send('Emulation.setCPUThrottlingRate', { rate: 100 });\n\n\t\tconst time = await measureInteractionToPaint('a[href=\"/routing/next-paint\"]');\n\n\t\t// we may need to tweak this number, and the `rate` above,\n\t\t// depending on if this proves flaky\n\t\texpect(time).toBeLessThan(400);\n\t});\n});\n\ntest.describe('binding_property_non_reactive warn', () => {\n\ttest('warning is not thrown from the root of svelte', async ({ page }) => {\n\t\tlet is_warning_thrown = false;\n\t\tpage.on('console', (m) => {\n\t\t\tif (\n\t\t\t\tm.type() === 'warning' &&\n\t\t\t\tm.text().includes('binding_property_non_reactive `bind:this={components[0]}`')\n\t\t\t) {\n\t\t\t\tis_warning_thrown = true;\n\t\t\t}\n\t\t});\n\t\tawait page.goto('/');\n\t\texpect(is_warning_thrown).toBeFalsy();\n\t});\n});\n\ntest.describe('routing', () => {\n\ttest('navigating while navigation is in progress sets the correct URL', async ({ page }) => {\n\t\tawait page.goto('/routing/long-navigation');\n\t\tawait page.click('a[href=\"/routing\"]');\n\t\tawait page.click('a[href=\"/routing\"]');\n\t\tawait expect(page.locator('h1')).toHaveText('Great success!');\n\t\tawait expect(page).toHaveURL((url) => url.pathname === '/routing');\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/basics/test/cross-platform/client.test.js",
    "content": "import process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../../utils.js';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.skip(({ javaScriptEnabled }) => !javaScriptEnabled);\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe('a11y', () => {\n\ttest('resets focus', async ({ page, clicknav, browserName }) => {\n\t\tconst tab = browserName === 'webkit' ? 'Alt+Tab' : 'Tab';\n\n\t\tawait page.goto('/accessibility/a');\n\n\t\tawait clicknav('[href=\"/accessibility/b\"]', { waitForURL: '/accessibility/b' });\n\t\texpect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BODY');\n\t\tawait page.keyboard.press(tab);\n\n\t\texpect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BUTTON');\n\t\texpect(await page.evaluate(() => (document.activeElement || {}).textContent)).toBe('focus me');\n\n\t\tawait clicknav('[href=\"/accessibility/a\"]', { waitForURL: '/accessibility/a' });\n\t\texpect(await page.innerHTML('h1')).toBe('a');\n\t\texpect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BODY');\n\n\t\tawait page.keyboard.press(tab);\n\t\texpect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BUTTON');\n\t\texpect(await page.evaluate(() => (document.activeElement || {}).textContent)).toBe('focus me');\n\n\t\texpect(await page.evaluate(() => document.documentElement.getAttribute('tabindex'))).toBe(null);\n\t});\n\n\ttest('applies autofocus after a navigation', async ({ page, clicknav }) => {\n\t\tawait page.goto('/accessibility/autofocus/a');\n\n\t\tawait clicknav('[href=\"/accessibility/autofocus/b\"]', {\n\t\t\twaitForURL: '/accessibility/autofocus/b'\n\t\t});\n\t\texpect(await page.innerHTML('h1')).toBe('b');\n\t\texpect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('INPUT');\n\t});\n\n\ttest('sets focus for valid hash but invalid selector', async ({ page }) => {\n\t\tawait page.goto('/reset-focus#an:invalid+selector');\n\t\tawait expect(page.locator('button')).toBeFocused();\n\t});\n\n\ttest('announces client-side navigation', async ({ page, clicknav, javaScriptEnabled }) => {\n\t\tawait page.goto('/accessibility/a');\n\n\t\tconst has_live_region = (await page.innerHTML('body')).includes('aria-live');\n\n\t\tif (javaScriptEnabled) {\n\t\t\texpect(has_live_region).toBeTruthy();\n\n\t\t\t// live region should exist, but be empty\n\t\t\texpect(await page.innerText('[aria-live]')).toBe('');\n\n\t\t\tawait clicknav('[href=\"/accessibility/b\"]');\n\t\t\texpect(await page.innerText('[aria-live]')).toBe('b'); // TODO i18n\n\t\t} else {\n\t\t\texpect(has_live_region).toBeFalsy();\n\t\t}\n\t});\n\n\ttest('reset selection', async ({ page, clicknav }) => {\n\t\tawait page.goto('/selection/a');\n\n\t\texpect(\n\t\t\tawait page.evaluate(() => {\n\t\t\t\tconst range = document.createRange();\n\t\t\t\trange.selectNodeContents(document.body);\n\t\t\t\tconst selection = getSelection();\n\t\t\t\tif (selection) {\n\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\tselection.addRange(range);\n\t\t\t\t\treturn selection.rangeCount;\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t})\n\t\t).toBe(1);\n\n\t\tawait clicknav('[href=\"/selection/b\"]');\n\n\t\texpect(\n\t\t\tawait page.evaluate(() => {\n\t\t\t\tconst selection = getSelection();\n\t\t\t\tif (selection) {\n\t\t\t\t\treturn selection.rangeCount;\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t})\n\t\t).toBe(0);\n\t});\n\n\ttest('keepfocus works', async ({ page }) => {\n\t\tawait page.goto('/keepfocus');\n\n\t\tawait Promise.all([\n\t\t\tpage.type('#input', 'bar'),\n\t\t\tpage.waitForFunction(() => window.location.search === '?foo=bar')\n\t\t]);\n\t\tawait expect(page.locator('#input')).toBeFocused();\n\t});\n\n\ttest('autofocus from previous page is ignored', async ({ page, clicknav }) => {\n\t\tawait page.addInitScript(`\n\t\t\twindow.active = null;\n\t\t\twindow.addEventListener('focusin', () => window.active = document.activeElement);\n\t\t`);\n\n\t\tawait page.goto('/accessibility/autofocus/a');\n\t\tawait clicknav('[href=\"/\"]');\n\n\t\texpect(\n\t\t\tawait page.evaluate(\n\t\t\t\t// @ts-expect-error\n\t\t\t\t() => window.active?.nodeName\n\t\t\t)\n\t\t).toBe('BODY');\n\t\texpect(await page.evaluate(() => document.activeElement?.nodeName)).toBe('BODY');\n\t});\n});\n\ntest.describe('Navigation lifecycle functions', () => {\n\ttest('beforeNavigate prevents navigation triggered by link click', async ({ page, baseURL }) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/prevent-navigation');\n\n\t\tawait page.click('[href=\"/navigation-lifecycle/before-navigate/a\"]');\n\t\tawait page.waitForLoadState('networkidle');\n\n\t\texpect(page.url()).toBe(baseURL + '/navigation-lifecycle/before-navigate/prevent-navigation');\n\t\texpect(await page.innerHTML('pre')).toBe('1 false link');\n\t});\n\n\ttest('beforeNavigate prevents navigation to external', async ({ page, baseURL }) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/prevent-navigation');\n\t\tawait page.click('h1'); // The browsers block attempts to prevent navigation on a frame that's never had a user gesture.\n\n\t\tpage.on('dialog', (dialog) => dialog.dismiss());\n\n\t\tpage.click('a[href=\"https://google.de\"]'); // do NOT await this, promise only resolves after successful navigation, which never happens\n\t\tawait page.waitForTimeout(500);\n\t\tawait expect(page.locator('pre')).toHaveText('1 true link');\n\t\texpect(page.url()).toBe(baseURL + '/navigation-lifecycle/before-navigate/prevent-navigation');\n\t});\n\n\ttest('beforeNavigate prevents navigation triggered by goto', async ({ page, app, baseURL }) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/prevent-navigation');\n\t\tawait app.goto('/navigation-lifecycle/before-navigate/a');\n\t\texpect(page.url()).toBe(baseURL + '/navigation-lifecycle/before-navigate/prevent-navigation');\n\t\texpect(await page.innerHTML('pre')).toBe('1 false goto');\n\t});\n\n\ttest('beforeNavigate prevents navigation triggered by back button', async ({\n\t\tpage,\n\t\tapp,\n\t\tbaseURL\n\t}) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/a');\n\t\tawait app.goto('/navigation-lifecycle/before-navigate/prevent-navigation');\n\t\tawait page.click('h1'); // The browsers block attempts to prevent navigation on a frame that's never had a user gesture.\n\n\t\tawait page.goBack();\n\t\texpect(await page.innerHTML('pre')).toBe('1 false popstate');\n\t\texpect(page.url()).toBe(baseURL + '/navigation-lifecycle/before-navigate/prevent-navigation');\n\t});\n\n\ttest('beforeNavigate prevents unload', async ({ page }) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/prevent-navigation');\n\t\tawait page.click('h1'); // The browsers block attempts to prevent navigation on a frame that's never had a user gesture.\n\t\tconst type = new Promise((fulfil) => {\n\t\t\tpage.on('dialog', async (dialog) => {\n\t\t\t\tfulfil(dialog.type());\n\t\t\t\tawait dialog.dismiss();\n\t\t\t});\n\t\t});\n\n\t\tawait page.close({ runBeforeUnload: true });\n\t\texpect(await type).toBe('beforeunload');\n\t\texpect(await page.innerHTML('pre')).toBe('1 true leave');\n\t});\n\n\ttest('beforeNavigate is not triggered on redirect', async ({ page, baseURL }) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/prevent-navigation');\n\n\t\tawait page.click('[href=\"/navigation-lifecycle/before-navigate/redirect\"]');\n\t\tawait page.waitForLoadState('networkidle');\n\n\t\texpect(page.url()).toBe(baseURL + '/navigation-lifecycle/before-navigate/prevent-navigation');\n\t\texpect(await page.innerHTML('pre')).toBe('1 false link');\n\t});\n\n\ttest('beforeNavigate is not triggered on target=_blank', async ({ page, baseURL }) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/prevent-navigation');\n\n\t\tawait page.click('a[href=\"https://google.com\"]');\n\t\tawait page.waitForTimeout(500);\n\n\t\texpect(page.url()).toBe(baseURL + '/navigation-lifecycle/before-navigate/prevent-navigation');\n\t\texpect(await page.innerHTML('pre')).toBe('0 false undefined');\n\t});\n\n\ttest('beforeNavigate is not triggered on click or popstate for hash links', async ({ page }) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/hash-links');\n\n\t\tawait page.click('a[href=\"#x\"]');\n\t\tawait page.goBack();\n\t\texpect(await page.textContent('h1')).toBe('before_navigate_ran: false');\n\t});\n\n\ttest('beforeNavigate cancel() on an unloading navigation does not prevent subsequent beforeNavigate callbacks', async ({\n\t\tpage,\n\t\tapp\n\t}) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/prevent-navigation');\n\t\tawait page.click('h1'); // The browsers block attempts to prevent navigation on a frame that's never had a user gesture.\n\t\tpage.on('dialog', async (dialog) => {\n\t\t\tawait dialog.dismiss();\n\t\t});\n\t\tawait page.close({ runBeforeUnload: true });\n\t\tawait page.waitForTimeout(100);\n\t\tawait app.goto('/navigation-lifecycle/before-navigate/prevent-navigation?x=1');\n\n\t\texpect(await page.innerHTML('pre')).toBe('2 false goto');\n\t});\n\n\ttest('beforeNavigate is triggered after clicking a download link', async ({ page }) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/prevent-navigation');\n\n\t\tconst download = page.waitForEvent('download');\n\t\tawait page.locator('a[download]').click();\n\t\tawait (await download).cancel();\n\n\t\tawait expect(page.locator('pre')).toHaveText('0 false undefined');\n\n\t\tawait page.locator('a[href=\"/navigation-lifecycle/before-navigate/a\"]').click();\n\n\t\tawait expect(page.locator('pre')).toHaveText('1 false link');\n\t});\n\n\ttest(\"beforeNavigate's complete fulfills after redirect\", async ({ page, clicknav }) => {\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/complete');\n\t\tclicknav('a[href=\"/navigation-lifecycle/before-navigate/redirect\"]');\n\t\texpect(await page.waitForEvent('console', (msg) => msg.text() === 'complete')).toBeTruthy();\n\t});\n\n\ttest('afterNavigate calls callback', async ({ page, clicknav }) => {\n\t\tawait page.goto('/navigation-lifecycle/after-navigate/a');\n\t\texpect(await page.textContent('h1')).toBe(\n\t\t\t'undefined -> /navigation-lifecycle/after-navigate/a'\n\t\t);\n\n\t\tawait clicknav('[href=\"/navigation-lifecycle/after-navigate/b\"]');\n\t\texpect(await page.textContent('h1')).toBe(\n\t\t\t'/navigation-lifecycle/after-navigate/a -> /navigation-lifecycle/after-navigate/b'\n\t\t);\n\t});\n\n\ttest('onNavigate calls callback', async ({ page, clicknav }) => {\n\t\tawait page.goto('/navigation-lifecycle/on-navigate/a');\n\t\texpect(await page.textContent('h1')).toBe('undefined -> undefined (...) false');\n\n\t\tawait clicknav('[href=\"/navigation-lifecycle/on-navigate/b\"]');\n\t\texpect(await page.textContent('h1')).toBe(\n\t\t\t'/navigation-lifecycle/on-navigate/a -> /navigation-lifecycle/on-navigate/b (link) true'\n\t\t);\n\t});\n\n\ttest('onNavigate returned function is only called once', async ({ page, clicknav }) => {\n\t\tawait page.goto('/navigation-lifecycle/after-navigate-properly-removed/b');\n\t\tawait clicknav('[href=\"/navigation-lifecycle/after-navigate-properly-removed/a\"]');\n\t\tawait clicknav('[href=\"/navigation-lifecycle/after-navigate-properly-removed/b\"]');\n\n\t\texpect(await page.textContent('.nav-lifecycle-after-nav-removed-test-target')).toBe('false');\n\t});\n\n\ttest('navigation.event is populated', async ({ page, clicknav }) => {\n\t\t/** @type {string[]} */\n\t\tconst logs = [];\n\n\t\tawait page.goto('/navigation-lifecycle/before-navigate/event/a');\n\n\t\tpage.on('console', (message) => {\n\t\t\tlogs.push(message.text());\n\t\t});\n\n\t\tawait clicknav('[href=\"/navigation-lifecycle/before-navigate/event/b\"]');\n\n\t\texpect(logs).toEqual([\n\t\t\t'click /navigation-lifecycle/before-navigate/event/a -> /navigation-lifecycle/before-navigate/event/b'\n\t\t]);\n\n\t\tawait page.goBack();\n\n\t\texpect(logs).toEqual([\n\t\t\t'click /navigation-lifecycle/before-navigate/event/a -> /navigation-lifecycle/before-navigate/event/b',\n\t\t\t'popstate /navigation-lifecycle/before-navigate/event/b -> /navigation-lifecycle/before-navigate/event/a'\n\t\t]);\n\t});\n\n\ttest('scroll state is provided on initial page load', async ({ page }) => {\n\t\t/** @type {any} */\n\t\tlet afterNav;\n\t\tconst afterNavPromise = new Promise((resolve) => {\n\t\t\tpage.on('console', (msg) => {\n\t\t\t\tconst text = msg.text();\n\t\t\t\tif (text.startsWith('afterNavigate:')) {\n\t\t\t\t\tafterNav = JSON.parse(text.slice('afterNavigate:'.length));\n\t\t\t\t\tresolve(afterNav);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tawait page.goto('/navigation-lifecycle/scroll-state/a');\n\t\tawait afterNavPromise;\n\n\t\texpect(afterNav.fromScroll).toBe(undefined);\n\t\texpect(afterNav.toScroll).toEqual({ x: 0, y: 0 });\n\t\texpect(afterNav.type).toBe('enter');\n\t});\n\n\ttest('scroll state is provided on link navigation', async ({ page, clicknav, scroll_to }) => {\n\t\tawait page.goto('/navigation-lifecycle/scroll-state/a');\n\t\tawait scroll_to(0, 500);\n\n\t\tconst navPromise = new Promise((resolve) => {\n\t\t\t/** @type {any} */\n\t\t\tlet beforeNav, onNav, afterNav;\n\t\t\tpage.on('console', (msg) => {\n\t\t\t\tconst text = msg.text();\n\t\t\t\tif (text.startsWith('beforeNavigate:')) {\n\t\t\t\t\tbeforeNav = JSON.parse(text.slice('beforeNavigate:'.length));\n\t\t\t\t} else if (text.startsWith('onNavigate:')) {\n\t\t\t\t\tonNav = JSON.parse(text.slice('onNavigate:'.length));\n\t\t\t\t} else if (text.startsWith('afterNavigate:')) {\n\t\t\t\t\tafterNav = JSON.parse(text.slice('afterNavigate:'.length));\n\t\t\t\t}\n\n\t\t\t\tif (beforeNav && onNav && afterNav) resolve({ beforeNav, onNav, afterNav });\n\t\t\t});\n\t\t});\n\n\t\tawait clicknav('#to-b');\n\t\tconst { beforeNav, onNav, afterNav } = await navPromise;\n\n\t\texpect(beforeNav.fromScroll).toEqual({ x: 0, y: 500 });\n\t\texpect(beforeNav.toScroll).toBe(null);\n\t\texpect(beforeNav.type).toBe('link');\n\n\t\texpect(onNav.fromScroll).toEqual({ x: 0, y: 500 });\n\t\texpect(onNav.toScroll).toBe(null);\n\t\texpect(onNav.type).toBe('link');\n\n\t\texpect(afterNav.fromScroll).toEqual({ x: 0, y: 500 });\n\t\texpect(afterNav.toScroll).toEqual({ x: 0, y: 0 });\n\t\texpect(afterNav.type).toBe('link');\n\t});\n\n\ttest('scroll state is provided on popstate navigation', async ({ page, clicknav, scroll_to }) => {\n\t\tawait page.goto('/navigation-lifecycle/scroll-state/a');\n\t\tawait scroll_to(0, 500);\n\n\t\t/** @type {any} */\n\t\tlet afterNav;\n\t\tlet navPromise = new Promise((resolve) => {\n\t\t\tpage.on('console', (msg) => {\n\t\t\t\tconst text = msg.text();\n\t\t\t\tif (text.startsWith('afterNavigate:')) {\n\t\t\t\t\tafterNav = JSON.parse(text.slice('afterNavigate:'.length));\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tawait clicknav('#to-b');\n\t\tawait navPromise;\n\n\t\tconst savedScrollY = afterNav.fromScroll.y;\n\n\t\tnavPromise = new Promise((resolve) => {\n\t\t\t/** @type {any} */\n\t\t\tlet beforeNav, onNav, afterNav;\n\t\t\tpage.on('console', (msg) => {\n\t\t\t\tconst text = msg.text();\n\t\t\t\tif (text.startsWith('beforeNavigate:')) {\n\t\t\t\t\tbeforeNav = JSON.parse(text.slice('beforeNavigate:'.length));\n\t\t\t\t} else if (text.startsWith('onNavigate:')) {\n\t\t\t\t\tonNav = JSON.parse(text.slice('onNavigate:'.length));\n\t\t\t\t} else if (text.startsWith('afterNavigate:')) {\n\t\t\t\t\tafterNav = JSON.parse(text.slice('afterNavigate:'.length));\n\t\t\t\t}\n\n\t\t\t\tif (beforeNav && onNav && afterNav) resolve({ beforeNav, onNav, afterNav });\n\t\t\t});\n\t\t});\n\n\t\tawait page.goBack();\n\t\tawait page.waitForURL('/navigation-lifecycle/scroll-state/a');\n\t\t/** @type {any} */\n\t\tlet beforeNav, onNav;\n\t\t({ beforeNav, onNav, afterNav } = await navPromise);\n\n\t\texpect(beforeNav.fromScroll).toEqual({ x: 0, y: 0 });\n\t\texpect(beforeNav.toScroll).toEqual({ x: 0, y: savedScrollY });\n\t\texpect(beforeNav.type).toBe('popstate');\n\n\t\texpect(onNav.fromScroll).toEqual({ x: 0, y: 0 });\n\t\texpect(onNav.toScroll).toEqual({ x: 0, y: savedScrollY });\n\t\texpect(onNav.type).toBe('popstate');\n\n\t\texpect(afterNav.toScroll).toEqual({ x: 0, y: savedScrollY });\n\t\texpect(afterNav.type).toBe('popstate');\n\t});\n});\n\ntest.describe('Scrolling', () => {\n\ttest('url-supplied anchor works on direct page load', async ({ page, in_view }) => {\n\t\tawait page.goto('/anchor/anchor#go-to-element');\n\t\texpect(await in_view('#go-to-element')).toBe(true);\n\t});\n\n\ttest('url-supplied anchor works on navigation to page', async ({ page, in_view, clicknav }) => {\n\t\tawait page.goto('/anchor');\n\t\tawait clicknav('#first-anchor');\n\t\texpect(await in_view('#go-to-element')).toBe(true);\n\t});\n\n\ttest('url-supplied non-ascii anchor works on navigation to page', async ({\n\t\tpage,\n\t\tin_view,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/anchor');\n\t\tawait clicknav('#non-ascii-anchor');\n\t\texpect(await in_view('#go-to-encöded')).toBe(true);\n\t});\n\n\ttest('url-supplied non-ascii anchor works on navigation to page after manual scroll', async ({\n\t\tpage,\n\t\tin_view,\n\t\tclicknav,\n\t\tscroll_to\n\t}) => {\n\t\tawait page.goto('/anchor');\n\t\tawait clicknav('#non-ascii-anchor');\n\t\tawait scroll_to(0, 50);\n\t\tawait page.locator('#non-ascii-anchor').click();\n\t\texpect(await in_view('#go-to-encöded')).toBe(true);\n\t});\n\n\ttest('url-supplied anchor with special characters works on navigation to page', async ({\n\t\tpage,\n\t\tin_view,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/anchor');\n\t\tawait clicknav('#special-char-anchor');\n\t\texpect(await in_view('.special-char-id')).toBe(true);\n\t});\n\n\ttest('url-supplied anchor works when navigated from scrolled page', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tin_view\n\t}) => {\n\t\tawait page.goto('/anchor');\n\t\tawait clicknav('#second-anchor');\n\t\texpect(await in_view('#go-to-element')).toBe(true);\n\t});\n\n\ttest('no-anchor url will scroll to top when navigated from scrolled page', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/anchor');\n\t\tawait clicknav('#third-anchor');\n\t\texpect(await page.evaluate(() => scrollY)).toBe(0);\n\t});\n\n\ttest('url-supplied anchor works when navigated from bottom of page', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tin_view\n\t}) => {\n\t\tawait page.goto('/anchor');\n\t\tawait clicknav('#last-anchor');\n\t\texpect(await in_view('#go-to-element')).toBe(true);\n\t});\n\n\ttest('scrolling to url-supplied anchor respects scroll-margin', async ({ page, clicknav }) => {\n\t\tawait page.goto('/anchor');\n\t\tawait clicknav('#to-scroll-margin');\n\t\texpect(\n\t\t\tawait page.evaluate(\n\t\t\t\t() => document.getElementById('scroll-margin')?.getBoundingClientRect().top\n\t\t\t)\n\t\t).toBe(40);\n\t});\n\n\ttest('no-anchor url will scroll to top when navigated from bottom of page', async ({\n\t\tclicknav,\n\t\tpage\n\t}) => {\n\t\tawait page.goto('/anchor');\n\t\tawait clicknav('#last-anchor-2');\n\t\texpect(await page.evaluate(() => scrollY)).toBe(0);\n\t});\n\n\ttest('scroll is restored after hitting the back button', async ({ clicknav, page }) => {\n\t\tawait page.goto('/anchor');\n\t\tawait page.locator('#scroll-anchor').click();\n\t\tconst originalScrollY = /** @type {number} */ (await page.evaluate(() => scrollY));\n\t\tawait clicknav('#routing-page', { waitForURL: '/routing/hashes/target' });\n\n\t\tawait page.goBack();\n\t\tawait page.waitForURL('/anchor#last-anchor-2');\n\t\texpect(await page.evaluate(() => scrollY)).toEqual(originalScrollY);\n\n\t\tawait page.goBack();\n\t\tawait page.waitForURL('/anchor');\n\t\texpect(await page.evaluate(() => scrollY)).toEqual(0);\n\t});\n\n\ttest('scroll is restored after hitting the back button for an in-app cross-document navigation', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tscroll_to\n\t}) => {\n\t\tawait page.goto('/scroll/cross-document/a');\n\n\t\tconst rect = await page.locator('[href=\"/scroll/cross-document/b\"]').boundingBox();\n\t\tconst height = await page.evaluate(() => innerHeight);\n\t\tif (!rect) throw new Error('Could not determine bounding box');\n\n\t\tconst target_scroll_y = rect.y + rect.height - height;\n\t\tawait scroll_to(0, target_scroll_y);\n\n\t\tawait page.locator('[href=\"/scroll/cross-document/b\"]').click();\n\t\texpect(await page.textContent('h1')).toBe('b');\n\t\tawait page.waitForSelector('body.started');\n\n\t\tawait clicknav('[href=\"/scroll/cross-document/c\"]');\n\t\texpect(await page.textContent('h1')).toBe('c');\n\n\t\tawait page.goBack(); // client-side back\n\t\tawait page.goBack(); // native back\n\t\texpect(await page.textContent('h1')).toBe('a');\n\t\tawait page.waitForSelector('body.started');\n\n\t\tawait page.waitForTimeout(250); // needed for the test to fail reliably without the fix\n\n\t\tconst scroll_y = await page.evaluate(() => scrollY);\n\n\t\texpect(Math.abs(scroll_y - target_scroll_y)).toBeLessThan(50); // we need a few pixels wiggle room, because browsers\n\t});\n\n\ttest('url-supplied anchor is ignored with onMount() scrolling on direct page load', async ({\n\t\tpage,\n\t\tin_view\n\t}) => {\n\t\tawait page.goto('/anchor-with-manual-scroll/anchor-onmount#go-to-element');\n\t\texpect(await in_view('#abcde')).toBe(true);\n\t});\n\n\ttest('url-supplied anchor is ignored with afterNavigate() scrolling on direct page load', async ({\n\t\tpage,\n\t\tin_view,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/anchor-with-manual-scroll/anchor-afternavigate#go-to-element');\n\t\texpect(await in_view('#abcde')).toBe(true);\n\n\t\tawait clicknav('[href=\"/anchor-with-manual-scroll/anchor-afternavigate?x=y#go-to-element\"]');\n\t\texpect(await in_view('#abcde')).toBe(true);\n\t});\n\n\ttest('url-supplied anchor is ignored with onMount() scrolling on navigation to page', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tjavaScriptEnabled,\n\t\tin_view\n\t}) => {\n\t\tawait page.goto('/anchor-with-manual-scroll');\n\t\tawait clicknav('[href=\"/anchor-with-manual-scroll/anchor-onmount#go-to-element\"]');\n\t\tif (javaScriptEnabled) expect(await in_view('#abcde')).toBe(true);\n\t\telse expect(await in_view('#go-to-element')).toBe(true);\n\t});\n\n\ttest('app-supplied scroll and focus work on direct page load', async ({ page, in_view }) => {\n\t\tawait page.goto('/use-action/focus-and-scroll');\n\t\texpect(await in_view('#input')).toBe(true);\n\t\tawait expect(page.locator('#input')).toBeFocused();\n\t});\n\n\ttest('app-supplied scroll and focus work on navigation to page', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tin_view\n\t}) => {\n\t\tawait page.goto('/use-action');\n\t\tawait clicknav('[href=\"/use-action/focus-and-scroll\"]');\n\t\texpect(await in_view('#input')).toBe(true);\n\t\tawait expect(page.locator('input')).toBeFocused();\n\t});\n\n\ttest('scroll positions are recovered on reloading the page', async ({\n\t\tpage,\n\t\tapp,\n\t\tbrowserName,\n\t\tscroll_to\n\t}) => {\n\t\t// No idea why the workaround below works only in dev mode\n\t\t// A better solution would probably be to set fission.webContentIsolationStrategy: 1\n\t\t// in the Firefox preferences but the Playwright API to do so is incomprehensible\n\t\tif (!process.env.DEV && browserName === 'firefox') {\n\t\t\treturn;\n\t\t}\n\n\t\tawait page.goto('/anchor');\n\t\tawait scroll_to(0, 1000);\n\t\tawait app.goto('/anchor/anchor');\n\t\tawait scroll_to(0, 1000);\n\n\t\tawait page.reload();\n\t\tif (browserName === 'firefox') {\n\t\t\t// Firefox with Playwright pushed new history entry history after reload\n\t\t\t// See https://github.com/microsoft/playwright/issues/22640\n\t\t\tawait page.goBack();\n\t\t}\n\t\tawait page.waitForFunction(() => window.scrollY === 1000);\n\n\t\tconst waiter = page.waitForFunction(() => window.scrollY === 1000);\n\t\tawait page.goBack();\n\t\tawait waiter;\n\t});\n\n\ttest('scroll position is top of page on ssr:false reload', async ({ page }) => {\n\t\tawait page.goto('/no-ssr/margin');\n\t\texpect(await page.evaluate(() => window.scrollY)).toBe(0);\n\t\tawait page.reload();\n\t\texpect(await page.evaluate(() => window.scrollY)).toBe(0);\n\t});\n\n\ttest('clicking # or #top takes you to the top of the current page', async ({\n\t\tpage,\n\t\tscroll_to\n\t}) => {\n\t\tawait page.goto('/scroll/top');\n\n\t\tfor (const href of ['#', '#top']) {\n\t\t\tawait scroll_to(0, 1000);\n\t\t\tawait page.click(`a[href=\"${href}\"]`);\n\t\t\texpect(await page.evaluate(() => window.scrollY)).toBe(0);\n\n\t\t\tawait scroll_to(0, 1000);\n\t\t\tawait page.click(`a[href=\"${href}\"]`);\n\t\t\texpect(await page.evaluate(() => window.scrollY)).toBe(0);\n\t\t}\n\t});\n\n\ttest('Scroll position is correct after going back from a shallow route', async ({\n\t\tpage,\n\t\tscroll_to\n\t}) => {\n\t\tawait page.goto('/scroll/push-state');\n\t\tawait page.locator('#subpage-link').click();\n\t\tawait page.locator('#back-button').click();\n\n\t\tawait scroll_to(0, 9999);\n\n\t\tconst scroll = await page.evaluate(() => window.scrollY);\n\t\texpect(scroll).toBeGreaterThan(0);\n\n\t\tawait page.locator('#shallow-button').click();\n\t\tawait page.locator('#back-button').click();\n\n\t\texpect(await page.evaluate(() => window.scrollY)).toBe(scroll);\n\t});\n});\n\ntest.describe('CSS', () => {\n\ttest('applies generated component styles (hides announcer)', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tget_computed_style\n\t}) => {\n\t\tawait page.goto('/css');\n\t\tawait clicknav('[href=\"/css/other\"]');\n\n\t\texpect(await get_computed_style('#svelte-announcer', 'position')).toBe('absolute');\n\t});\n\n\ttest('dynamically imported components lazily load CSS', async ({ page, get_computed_style }) => {\n\t\tconst requests = [];\n\t\tpage.on('request', (request) => {\n\t\t\tconst url = request.url();\n\t\t\tif (url.includes('Dynamic') && url.endsWith('.css')) {\n\t\t\t\trequests.push(url);\n\t\t\t}\n\t\t});\n\n\t\tawait page.goto('/css/dynamic');\n\t\texpect(requests.length).toBe(0);\n\n\t\tawait page.locator('button').click();\n\t\tawait expect(page.locator('p')).toHaveText(\"I'm dynamically imported\");\n\t\texpect(await get_computed_style('p', 'color')).toBe('rgb(0, 0, 255)');\n\t\texpect(requests.length).toBe(1);\n\t});\n});\n\ntest.describe.serial('Errors', () => {\n\ttest('client-side load errors', async ({ page }) => {\n\t\tawait page.goto('/errors/load-client');\n\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Crashing now (500 Internal Error)\"'\n\t\t);\n\t});\n\n\ttest('client-side module context errors', async ({ page }) => {\n\t\tawait page.goto('/errors/module-scope-client');\n\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Crashing now (500 Internal Error)\"'\n\t\t);\n\t});\n\n\ttest('client-side error from load()', async ({ page }) => {\n\t\tawait page.goto('/errors/load-error-client');\n\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Not found\"'\n\t\t);\n\t\texpect(await page.innerHTML('h1')).toBe('555');\n\t});\n\n\ttest('client-side 4xx status without error from load()', async ({ page }) => {\n\t\tawait page.goto('/errors/load-status-without-error-client');\n\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Error: 401\"'\n\t\t);\n\t\texpect(await page.innerHTML('h1')).toBe('401');\n\t});\n\n\ttest('Root error falls back to error.html (unexpected error)', async ({ page, clicknav }) => {\n\t\tawait page.goto('/errors/error-html');\n\t\tawait clicknav('button:text-is(\"Unexpected\")');\n\n\t\texpect(await page.textContent('h1')).toBe('Error - 500');\n\t\texpect(await page.textContent('p')).toBe(\n\t\t\t'This is the static error page with the following message: Failed to load (500 Internal Error)'\n\t\t);\n\t});\n\n\ttest('Root error falls back to error.html (expected error)', async ({ page, clicknav }) => {\n\t\tawait page.goto('/errors/error-html');\n\t\tawait clicknav('button:text-is(\"Expected\")');\n\n\t\texpect(await page.textContent('h1')).toBe('Error - 401');\n\t\texpect(await page.textContent('p')).toBe(\n\t\t\t'This is the static error page with the following message: Not allowed'\n\t\t);\n\t});\n\n\ttest('Root 404 redirects somewhere due to root layout', async ({ page, baseURL, clicknav }) => {\n\t\tawait page.goto('/errors/error-html');\n\t\tawait clicknav('button:text-is(\"Redirect\")');\n\t\texpect(page.url()).toBe(baseURL + '/load');\n\t});\n});\n\ntest.describe('Prefetching', () => {\n\ttest('prefetches code programmatically', async ({ page, app }) => {\n\t\tawait page.goto('/routing/a');\n\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (r) => {\n\t\t\trequests.push(r.url());\n\t\t});\n\n\t\tawait app.preloadCode('/routing/b');\n\n\t\t// svelte request made is environment dependent\n\t\tif (process.env.DEV) {\n\t\t\texpect(requests.filter((req) => req.endsWith('routing/b/+page.js')).length).toBe(1);\n\t\t\texpect(requests.filter((req) => req.endsWith('routing/b/+page.svelte')).length).toBe(1);\n\t\t} else {\n\t\t\texpect(requests.filter((req) => /\\/_app\\/immutable\\/nodes\\/.*?.js$/.test(req)).length).toBe(\n\t\t\t\t1\n\t\t\t);\n\t\t}\n\n\t\tif (process.env.DEV) {\n\t\t\ttry {\n\t\t\t\tawait app.preloadCode('https://example.com');\n\t\t\t\tthrow new Error('Error was not thrown');\n\t\t\t} catch (/** @type {any} */ e) {\n\t\t\t\texpect(e.message).toMatch(\n\t\t\t\t\t'argument passed to preloadCode must be a pathname (i.e. \"/about\" rather than \"http://example.com/about\"'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t});\n\n\ttest('prefetches data programmatically', async ({ baseURL, page, app }) => {\n\t\tawait page.goto('/routing/a');\n\n\t\t/** @type {string[]} */\n\t\tlet requests = [];\n\t\tpage.on('request', (r) => {\n\t\t\tconst url = r.url();\n\t\t\t// Headless Chrome re-requests the favicon.png on every URL change\n\t\t\tif (url.endsWith('/favicon.png')) return;\n\t\t\trequests.push(url);\n\t\t});\n\n\t\t// also wait for network processing to complete, see\n\t\t// https://playwright.dev/docs/network#network-events\n\t\tawait Promise.all([\n\t\t\tpage.waitForResponse(`${baseURL}/routing/preloading/preloaded.json`),\n\t\t\tapp.preloadData('/routing/preloading/preloaded')\n\t\t]);\n\n\t\t// svelte request made is environment dependent\n\t\tif (process.env.DEV) {\n\t\t\texpect(requests.filter((req) => req.endsWith('+page.svelte')).length).toBe(1);\n\t\t} else {\n\t\t\t// the preload helper causes an additional request to be made in Firefox,\n\t\t\t// so we use toBeGreaterThan rather than toBe\n\t\t\texpect(requests.filter((req) => req.endsWith('.js')).length).toBeGreaterThan(0);\n\t\t}\n\n\t\texpect(requests).toContain(`${baseURL}/routing/preloading/preloaded.json`);\n\n\t\trequests = [];\n\t\tawait app.goto('/routing/preloading/preloaded');\n\t\texpect(requests).toEqual([]);\n\n\t\tawait expect(app.preloadData('https://example.com')).rejects.toThrowError(\n\t\t\t'Attempted to preload a URL that does not belong to this app'\n\t\t);\n\t});\n\n\ttest('chooses correct route when hash route is preloaded but regular route is clicked', async ({\n\t\tapp,\n\t\tpage\n\t}) => {\n\t\tawait page.goto('/routing/a');\n\t\tawait app.preloadData('/routing/preloading/hash-route#please-dont-show-me');\n\t\tawait app.goto('/routing/preloading/hash-route');\n\t\tawait expect(page.locator('h1')).not.toHaveText('Oopsie');\n\t});\n\n\ttest('same route hash links work more than once', async ({ page, clicknav, baseURL }) => {\n\t\tawait page.goto('/routing/hashes/a');\n\n\t\tawait clicknav('[href=\"#preload\"]', { waitForURL: `${baseURL}/routing/hashes/a#preload` });\n\n\t\tawait clicknav('[href=\"/routing/hashes/a\"]', { waitForURL: `${baseURL}/routing/hashes/a` });\n\t\tawait clicknav('[href=\"#preload\"]', { waitForURL: `${baseURL}/routing/hashes/a#preload` });\n\t});\n\n\ttest('does not rerun load on calls to duplicate preload hash route', async ({ app, page }) => {\n\t\tawait page.goto('/routing/a');\n\n\t\tawait app.preloadData('/routing/preloading/hash-route#please-dont-show-me');\n\t\tawait app.preloadData('/routing/preloading/hash-route#please-dont-show-me');\n\t\tawait app.goto('/routing/preloading/hash-route#please-dont-show-me');\n\t\tawait expect(page.locator('p')).toHaveText('Loaded 1 times.');\n\t});\n\n\ttest('does not rerun load on calls to different preload hash route', async ({ app, page }) => {\n\t\tawait page.goto('/routing/a');\n\n\t\tawait app.preloadData('/routing/preloading/hash-route#please-dont-show-me');\n\t\tawait app.preloadData('/routing/preloading/hash-route#please-dont-show-me-jr');\n\t\tawait app.goto('/routing/preloading/hash-route#please-dont-show-me');\n\t\tawait expect(page.locator('p')).toHaveText('Loaded 1 times.');\n\t});\n\n\ttest('does rerun load when preload errored', async ({ app, page }) => {\n\t\tawait page.goto('/routing/a');\n\n\t\tawait app.preloadData('/routing/preloading/preload-error');\n\t\tawait app.goto('/routing/preloading/preload-error');\n\t\tawait expect(page.locator('p')).toHaveText('hello');\n\t});\n});\n\ntest.describe('Routing', () => {\n\ttest('navigates to a new page without reloading', async ({ app, page, clicknav }) => {\n\t\tawait page.goto('/routing');\n\n\t\tawait app.preloadData('/routing/a').catch((e) => {\n\t\t\t// from error handler tests; ignore\n\t\t\tif (!e.message.includes('Crashing now')) throw e;\n\t\t});\n\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (r) => requests.push(r.url()));\n\n\t\tawait clicknav('a[href=\"/routing/a\"]');\n\t\texpect(await page.textContent('h1')).toBe('a');\n\n\t\texpect(requests.filter((url) => !url.endsWith('/favicon.png'))).toEqual([]);\n\t});\n\n\ttest('navigates programmatically', async ({ page, app }) => {\n\t\tawait page.goto('/routing/a');\n\t\tawait app.goto('/routing/b');\n\t\texpect(await page.textContent('h1')).toBe('b');\n\t});\n\n\ttest('page.url.hash is correctly set on page load', async ({ page }) => {\n\t\tawait page.goto('/routing/hashes/pagestate#target');\n\t\texpect(await page.textContent('#window-hash')).toBe('#target');\n\t\texpect(await page.textContent('#page-url-hash')).toBe('#target');\n\t});\n\n\ttest('page.url.hash is correctly set on navigation', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/hashes/pagestate');\n\t\tawait expect(page.locator('#window-hash')).toHaveText('');\n\t\tawait expect(page.locator('#page-url-hash')).toHaveText('');\n\t\tawait clicknav('[href=\"#target\"]');\n\t\tawait expect(page.locator('#window-hash')).toHaveText('#target');\n\t\tawait expect(page.locator('#page-url-hash')).toHaveText('#target');\n\t\tawait clicknav('[href=\"/routing/hashes/pagestate\"]');\n\t\tawait expect(page.locator('#window-hash')).toHaveText('#target'); // hashchange doesn't fire for these\n\t\tawait expect(page.locator('#page-url-hash')).toHaveText('');\n\t\tawait page.goBack();\n\t\tawait expect(page.locator('#window-hash')).toHaveText('#target');\n\t\tawait expect(page.locator('#page-url-hash')).toHaveText('#target');\n\t});\n\n\ttest('clicking on a hash link focuses the associated element', async ({ page }) => {\n\t\tawait page.goto('/routing/hashes/focus');\n\t\tawait page.locator('a[href=\"#example\"]').click();\n\t\tawait expect(page.getByRole('textbox')).toBeFocused();\n\t\t// check it still works when the hash is already present in the URL\n\t\tawait page.locator('a[href=\"#example\"]').click();\n\t\tawait expect(page.getByRole('textbox')).toBeFocused();\n\t});\n\n\ttest('backwards navigation works after clicking a hash link with data-sveltekit-reload', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tbaseURL\n\t}) => {\n\t\tawait page.goto('/data-sveltekit/reload/hash');\n\t\tawait clicknav('a[href=\"#example\"]', {\n\t\t\twaitForURL: `${baseURL}/data-sveltekit/reload/hash#example`\n\t\t});\n\t\tawait clicknav('a[href=\"/data-sveltekit/reload/hash/new\"]', {\n\t\t\twaitForURL: `${baseURL}/data-sveltekit/reload/hash/new`\n\t\t});\n\t\tawait page.goBack();\n\t\tawait page.waitForURL(`${baseURL}/data-sveltekit/reload/hash#example`);\n\t\tawait expect(page.getByRole('textbox')).toBeVisible();\n\t});\n\n\ttest('sequential focus navigation starting point is set correctly on navigation', async ({\n\t\tpage,\n\t\tbrowserName\n\t}) => {\n\t\tconst tab = browserName === 'webkit' ? 'Alt+Tab' : 'Tab';\n\t\tawait page.goto('/routing/focus');\n\t\tawait page.locator('[href=\"/routing/focus/a#p\"]').click();\n\t\tawait page.waitForURL('**/routing/focus/a#p');\n\t\texpect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BODY');\n\t\tawait page.keyboard.press(tab);\n\t\tawait expect(page.locator('#button3')).toBeFocused();\n\t});\n\n\ttest('back button returns to previous route when previous route was navigated to via hash anchor', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tbaseURL\n\t}) => {\n\t\tawait page.goto('/routing/hashes/a');\n\n\t\tawait page.locator('[href=\"#hash-target\"]').click();\n\t\tawait page.waitForURL(`${baseURL}/routing/hashes/a#hash-target`);\n\n\t\tawait clicknav('[href=\"/routing/hashes/b\"]');\n\t\tawait expect(page.locator('h1')).toHaveText('b');\n\t\tawait page.goBack();\n\t\tawait expect(page.locator('h1')).toHaveText('a');\n\t});\n\n\ttest('replaces state if the data-sveltekit-replacestate router option is specified for the hash link', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tbaseURL\n\t}) => {\n\t\tawait page.goto('/routing/hashes/a');\n\n\t\tawait clicknav('[href=\"#hash-target\"]', {\n\t\t\twaitForURL: `${baseURL}/routing/hashes/a#hash-target`\n\t\t});\n\n\t\tawait clicknav('[href=\"#replace-state\"]', {\n\t\t\twaitForURL: `${baseURL}/routing/hashes/a#replace-state`\n\t\t});\n\n\t\tawait page.goBack();\n\t\tawait page.waitForURL(`${baseURL}/routing/hashes/a`);\n\t});\n\n\ttest('navigating to a hash link works when base element is present', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tbaseURL\n\t}) => {\n\t\tawait page.goto('/routing/hashes/base');\n\n\t\tawait clicknav('#navigate');\n\n\t\tawait expect(page.locator('p')).toHaveText('X');\n\t\texpect(page.url()).toBe(`${baseURL}/routing/hashes/base/a#x`);\n\t});\n\n\ttest('does not normalize external path', async ({ page, start_server }) => {\n\t\tconst html_ok = '<html><head></head><body>ok</body></html>';\n\t\tconst { port } = await start_server((_req, res) => {\n\t\t\tres.end(html_ok);\n\t\t});\n\n\t\tawait page.goto(`/routing/slashes?port=${port}`);\n\t\tawait page.locator(`a[href=\"http://localhost:${port}/with-slash/\"]`).click();\n\t\texpect(await page.content()).toBe(html_ok);\n\t\texpect(page.url()).toBe(`http://localhost:${port}/with-slash/`);\n\t});\n\n\ttest('ignores popstate events from outside the router', async ({ page }) => {\n\t\tawait page.goto('/routing/external-popstate');\n\t\texpect(await page.textContent('h1')).toBe('hello');\n\n\t\tawait page.locator('button').click();\n\t\texpect(await page.textContent('h1')).toBe('hello');\n\n\t\tawait page.goBack();\n\t\texpect(await page.textContent('h1')).toBe('hello');\n\n\t\tawait page.goForward();\n\t\texpect(await page.textContent('h1')).toBe('hello');\n\t});\n\n\ttest('recognizes clicks outside the app target', async ({ page }) => {\n\t\tawait page.goto('/routing/link-outside-app-target/source');\n\n\t\tawait page.locator('[href=\"/routing/link-outside-app-target/target\"]').click();\n\t\tawait expect(page.locator('h1')).toHaveText('target: 1');\n\t});\n\n\ttest('responds to <form method=\"GET\"> submission without reload', async ({ page }) => {\n\t\t// wait until load to ensure that all in-flight requests are completed before\n\t\t// we start watching requests\n\t\tawait page.goto('/routing/form-get', { waitUntil: 'load' });\n\n\t\tawait expect(page.locator('h1')).toHaveText('...');\n\t\tawait expect(page.locator('h2')).toHaveText('enter');\n\t\tawait expect(page.locator('h3')).toHaveText('...');\n\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (request) => {\n\t\t\tconst url = request.url();\n\t\t\t// Headless Chrome re-requests the favicon.png on every URL change\n\t\t\tif (url.endsWith('/favicon.png')) return;\n\t\t\trequests.push(url);\n\t\t});\n\n\t\tawait page.locator('input').fill('updated');\n\t\tawait page.locator('button').click();\n\n\t\t// Filter out server-side route resolution request\n\t\tawait expect(page.locator('h1')).toHaveText('updated');\n\t\tawait expect(page.locator('h2')).toHaveText('form');\n\t\tawait expect(page.locator('h3')).toHaveText('bar');\n\t\texpect(requests.filter((r) => !r.includes('__route.js'))).toEqual([]);\n\t});\n\n\ttest('responds to <form target=\"_blank\"> submission with new tab', async ({ page }) => {\n\t\tawait page.goto('/routing/form-target-blank');\n\n\t\tlet tabs = page.context().pages();\n\t\texpect(tabs.length === 1);\n\n\t\tconst new_tab = page.waitForEvent('popup', { timeout: 1000 });\n\t\tawait page.locator('button', { hasText: 'Inside form' }).click();\n\t\tawait new_tab;\n\n\t\ttabs = page.context().pages();\n\t\texpect(tabs.length > 1);\n\t});\n\n\ttest('responds to <button formtarget=\"_blank\" submission with new tab', async ({ page }) => {\n\t\tawait page.goto('/routing/form-target-blank');\n\n\t\tlet tabs = page.context().pages();\n\t\texpect(tabs.length === 1);\n\n\t\tconst new_tab = page.waitForEvent('popup', { timeout: 1000 });\n\t\tawait page.locator('button', { hasText: 'Outside form' }).click();\n\t\tawait new_tab;\n\n\t\ttabs = page.context().pages();\n\t\texpect(tabs.length > 1);\n\t});\n\n\ttest('ignores links with no href', async ({ page }) => {\n\t\tawait page.goto('/routing/missing-href');\n\t\tconst selector = '[data-testid=\"count\"]';\n\n\t\texpect(await page.textContent(selector)).toBe('count: 1');\n\n\t\tawait page.locator(selector).click();\n\t\texpect(await page.textContent(selector)).toBe('count: 1');\n\t});\n\n\ttest('trailing slash redirect', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/trailing-slash');\n\n\t\tawait clicknav('a[href=\"/routing/trailing-slash/always\"]');\n\t\texpect(new URL(page.url()).pathname).toBe('/routing/trailing-slash/always/');\n\t\tawait expect(page.locator('p')).toHaveText('/routing/trailing-slash/always/');\n\n\t\tawait clicknav('a[href=\"/routing/trailing-slash/never/\"]');\n\t\texpect(new URL(page.url()).pathname).toBe('/routing/trailing-slash/never');\n\t\tawait expect(page.locator('p')).toHaveText('/routing/trailing-slash/never');\n\n\t\tawait clicknav('a[href=\"/routing/trailing-slash/ignore/\"]');\n\t\texpect(new URL(page.url()).pathname).toBe('/routing/trailing-slash/ignore/');\n\t\tawait expect(page.locator('p')).toHaveText('/routing/trailing-slash/ignore/');\n\t});\n\n\ttest('trailing slash redirect works when navigating from root page', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/');\n\t\tawait clicknav('a[href=\"/routing/trailing-slash/never/\"]');\n\t\texpect(new URL(page.url()).pathname).toBe('/routing/trailing-slash/never');\n\t\tawait expect(page.locator('p')).toHaveText('/routing/trailing-slash/never');\n\t});\n});\n\ntest.describe('Shadow DOM', () => {\n\ttest('client router captures anchors in shadow dom', async ({ app, page, clicknav }) => {\n\t\tawait page.goto('/routing/shadow-dom');\n\n\t\tawait app.preloadData('/routing/a').catch((e) => {\n\t\t\t// from error handler tests; ignore\n\t\t\tif (!e.message.includes('Crashing now')) throw e;\n\t\t});\n\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (r) => requests.push(r.url()));\n\n\t\tawait clicknav('div[id=\"clickme\"]');\n\t\texpect(await page.textContent('h1')).toBe('a');\n\n\t\texpect(requests.filter((url) => !url.endsWith('/favicon.png'))).toEqual([]);\n\t});\n});\n\ntest.describe('cookies', () => {\n\ttest('etag forwards cookies', async ({ page }) => {\n\t\tawait page.goto('/cookies/forwarded-in-etag');\n\t\tawait expect(page.locator('p')).toHaveText('foo=bar');\n\t\tawait page.locator('button').click();\n\t\tawait expect(page.locator('p')).toHaveText('foo=bar');\n\t});\n\n\ttest(\"fetch during SSR doesn't un- and re-escape cookies\", async ({ page }) => {\n\t\tawait page.goto('/cookies/collect-without-re-escaping');\n\t\tawait expect(page.locator('p')).toHaveText('cookie-special-characters=\"foo\"');\n\t});\n});\n\ntest.describe('Interactivity', () => {\n\ttest('click events on removed elements are ignored', async ({ page }) => {\n\t\tlet errored = false;\n\n\t\tpage.on('pageerror', (err) => {\n\t\t\tconsole.error(err);\n\t\t\terrored = true;\n\t\t});\n\n\t\tawait page.goto('/interactivity/toggle-element');\n\t\texpect(await page.textContent('button')).toBe('remove');\n\n\t\tawait page.locator('button').click();\n\t\texpect(await page.textContent('button')).toBe('add');\n\t\texpect(await page.textContent('a')).toBe('add');\n\n\t\tawait page.locator('a').filter({ hasText: 'add' }).click();\n\t\texpect(await page.textContent('a')).toBe('remove');\n\n\t\texpect(errored).toBe(false);\n\t});\n});\n\ntest.describe('Load', () => {\n\tif (process.env.DEV) {\n\t\ttest('using window.fetch does not cause false-positive warning', async ({ page, baseURL }) => {\n\t\t\t/** @type {string[]} */\n\t\t\tconst warnings = [];\n\t\t\tpage.on('console', (msg) => {\n\t\t\t\tif (msg.type() === 'warning') {\n\t\t\t\t\twarnings.push(msg.text());\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tawait page.goto('/load/window-fetch/outside-load');\n\t\t\texpect(await page.textContent('h1')).toBe('42');\n\n\t\t\texpect(warnings).not.toContain(\n\t\t\t\t`Loading ${baseURL}/load/window-fetch/data.json using \\`window.fetch\\`. For best results, use the \\`fetch\\` that is passed to your \\`load\\` function: https://svelte.dev/docs/kit/load#making-fetch-requests`\n\t\t\t);\n\t\t});\n\t}\n});\n"
  },
  {
    "path": "packages/kit/test/apps/basics/test/cross-platform/server.test.js",
    "content": "import { expect } from '@playwright/test';\nimport { test } from '../../../../utils.js';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.skip(({ javaScriptEnabled }) => javaScriptEnabled);\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe('Static files', () => {\n\ttest('Filenames are case-sensitive', async ({ request }) => {\n\t\tconst response = await request.get('/static.JSON');\n\t\texpect(response.status()).toBe(404);\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/basics/test/cross-platform/test.js",
    "content": "import process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../../utils.js';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe('CSS', () => {\n\t/**\n\t * @param {(selector: string, prop: string) => Promise<string>} get_computed_style\n\t */\n\tfunction check_styles(get_computed_style) {\n\t\ttest.step('applies imported styles', async () => {\n\t\t\texpect(await get_computed_style('.styled', 'color')).toBe('rgb(255, 0, 0)');\n\t\t});\n\n\t\ttest.step('applies imported styles in the correct order', async () => {\n\t\t\texpect(await get_computed_style('.overridden', 'color')).toBe('rgb(0, 128, 0)');\n\t\t});\n\n\t\ttest.step('applies layout styles', async () => {\n\t\t\texpect(await get_computed_style('footer', 'color')).toBe('rgb(128, 0, 128)');\n\t\t});\n\n\t\ttest.step('applies local styles', async () => {\n\t\t\texpect(await get_computed_style('.also-styled', 'color')).toBe('rgb(0, 0, 255)');\n\t\t});\n\n\t\ttest.step('does not apply raw and url', async () => {\n\t\t\texpect(await get_computed_style('.not', 'color')).toBe('rgb(0, 0, 0)');\n\t\t});\n\t}\n\n\ttest('applies styles correctly', async ({ page, get_computed_style }) => {\n\t\tawait page.goto('/css');\n\t\t// without this assertion, the WebKit browser seems to close before we can compute the styles\n\t\tawait expect(page.locator('.styled')).toBeVisible();\n\t\tcheck_styles(get_computed_style);\n\t});\n\n\ttest('applies styles correctly after client-side navigation', async ({\n\t\tpage,\n\t\tapp,\n\t\tget_computed_style,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tif (!javaScriptEnabled) return;\n\n\t\tawait page.goto('/');\n\t\tawait app.goto('/css');\n\n\t\tcheck_styles(get_computed_style);\n\t});\n\n\ttest('loads styles on routes with encoded characters', async ({ page, get_computed_style }) => {\n\t\tawait page.goto('/css/encöded');\n\t\texpect(await get_computed_style('h1', 'color')).toBe('rgb(128, 0, 128)');\n\t});\n});\n\ntest.describe('Shadowed pages', () => {\n\ttest('Loads props from an endpoint', async ({ page, clicknav }) => {\n\t\tawait page.goto('/shadowed');\n\t\tawait clicknav('[href=\"/shadowed/simple\"]');\n\t\texpect(await page.textContent('h1')).toBe('The answer is 42');\n\t});\n\n\ttest('Handles GET redirects', async ({ page, clicknav }) => {\n\t\tawait page.goto('/shadowed');\n\t\tawait clicknav('[href=\"/shadowed/redirect-get\"]');\n\t\texpect(await page.textContent('h1')).toBe('Redirection was successful');\n\t});\n\n\ttest('Handles GET redirects with cookies', async ({ page, context, clicknav }) => {\n\t\tawait page.goto('/shadowed');\n\t\tawait clicknav('[href=\"/shadowed/redirect-get-with-cookie\"]');\n\t\texpect(await page.textContent('h1')).toBe('Redirection was successful');\n\n\t\tconst cookies = await context.cookies();\n\t\texpect(cookies).toEqual(\n\t\t\texpect.arrayContaining([expect.objectContaining({ name: 'shadow-redirect', value: 'happy' })])\n\t\t);\n\t});\n\n\ttest('Handles GET redirects with cookies from fetch response', async ({\n\t\tpage,\n\t\tcontext,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/shadowed');\n\t\tawait clicknav('[href=\"/shadowed/redirect-get-with-cookie-from-fetch\"]');\n\t\texpect(await page.textContent('h1')).toBe('Redirection was successful');\n\n\t\tconst cookies = await context.cookies();\n\t\texpect(cookies).toEqual(\n\t\t\texpect.arrayContaining([\n\t\t\t\texpect.objectContaining({ name: 'shadow-redirect-fetch', value: 'happy' })\n\t\t\t])\n\t\t);\n\t});\n\n\ttest('Handles POST redirects', async ({ page, clicknav }) => {\n\t\tawait page.goto('/shadowed');\n\t\tawait clicknav('#redirect-post');\n\t\texpect(await page.textContent('h1')).toBe('Redirection was successful');\n\t});\n\n\ttest('Handles POST redirects with cookies', async ({ page, context, clicknav }) => {\n\t\tawait page.goto('/shadowed');\n\t\tawait clicknav('#redirect-post-with-cookie');\n\t\texpect(await page.textContent('h1')).toBe('Redirection was successful');\n\n\t\tconst cookies = await context.cookies();\n\t\texpect(cookies).toEqual(\n\t\t\texpect.arrayContaining([expect.objectContaining({ name: 'shadow-redirect', value: 'happy' })])\n\t\t);\n\t});\n\n\ttest('Handles POST success with returned location', async ({ page, clicknav }) => {\n\t\tawait page.goto('/shadowed/post-success-redirect');\n\t\tawait clicknav('button');\n\t\texpect(await page.textContent('h1')).toBe('POST was successful');\n\t});\n\n\ttest('Renders error page for 4xx and 5xx responses from GET', async ({ page, clicknav }) => {\n\t\tawait page.goto('/shadowed');\n\t\tawait clicknav('[href=\"/shadowed/error-get\"]');\n\t\texpect(await page.textContent('h1')).toBe('404');\n\t});\n\n\ttest('Merges bodies for 4xx and 5xx responses from non-GET', async ({ page }) => {\n\t\tawait page.goto('/shadowed');\n\t\tconst [response] = await Promise.all([page.waitForNavigation(), page.click('#error-post')]);\n\t\texpect(await page.textContent('h1')).toBe('hello from get / echo: posted data');\n\n\t\texpect(response?.status()).toBe(400);\n\t\texpect(await page.textContent('h2')).toBe('status: 400');\n\t});\n\n\ttest('Endpoint receives consistent URL', async ({ baseURL, page, clicknav }) => {\n\t\tawait page.goto('/shadowed/same-render-entry');\n\t\tawait clicknav('[href=\"/shadowed/same-render?param1=value1\"]');\n\t\texpect(await page.textContent('h1')).toBe(`URL: ${baseURL}/shadowed/same-render?param1=value1`);\n\t});\n\n\ttest('Works with missing get handler', async ({ page, clicknav }) => {\n\t\tawait page.goto('/shadowed');\n\t\tawait clicknav('[href=\"/shadowed/no-get\"]');\n\t\texpect(await page.textContent('h1')).toBe('hello');\n\t});\n\n\ttest('Invalidates shadow data when URL changes', async ({ page, clicknav }) => {\n\t\tawait page.goto('/shadowed');\n\t\tawait clicknav('[href=\"/shadowed/dynamic/foo\"]');\n\t\texpect(await page.textContent('h1')).toBe('slug: foo');\n\n\t\tawait clicknav('[href=\"/shadowed/dynamic/bar\"]');\n\t\texpect(await page.textContent('h1')).toBe('slug: bar');\n\n\t\tawait page.goto('/shadowed/dynamic/foo');\n\t\texpect(await page.textContent('h1')).toBe('slug: foo');\n\t\tawait clicknav('[href=\"/shadowed/dynamic/bar\"]');\n\t\texpect(await page.textContent('h1')).toBe('slug: bar');\n\t});\n\n\ttest('Shadow redirect', async ({ page, clicknav }) => {\n\t\tawait page.goto('/shadowed/redirect');\n\t\tawait clicknav('[href=\"/shadowed/redirect/a\"]');\n\t\texpect(await page.textContent('h1')).toBe('done');\n\t});\n\n\ttest('Endpoint without GET', async ({ page, clicknav, baseURL, javaScriptEnabled }) => {\n\t\tawait page.goto('/shadowed');\n\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (r) => requests.push(r.url()));\n\n\t\tawait clicknav('[href=\"/shadowed/missing-get\"]');\n\n\t\texpect(await page.textContent('h1')).toBe('post without get');\n\n\t\t// check that the router didn't fall back to the server\n\t\tif (javaScriptEnabled) {\n\t\t\texpect(requests).not.toContain(`${baseURL}/shadowed/missing-get`);\n\t\t}\n\t});\n\n\ttest('Parent data is present', async ({ page, clicknav }) => {\n\t\tawait page.goto('/shadowed/parent');\n\t\tawait expect(page.locator('h2')).toHaveText(\n\t\t\t'Layout data: {\"foo\":{\"bar\":\"Custom layout\"},\"layout\":\"layout\"}'\n\t\t);\n\t\tawait expect(page.locator('p')).toHaveText(\n\t\t\t'Page data: {\"foo\":{\"bar\":\"Custom layout\"},\"layout\":\"layout\",\"page\":\"page\",\"data\":{\"rootlayout\":\"rootlayout\",\"layout\":\"layout\"}}'\n\t\t);\n\n\t\tawait clicknav('[href=\"/shadowed/parent?test\"]');\n\t\tawait expect(page.locator('h2')).toHaveText(\n\t\t\t'Layout data: {\"foo\":{\"bar\":\"Custom layout\"},\"layout\":\"layout\"}'\n\t\t);\n\t\tawait expect(page.locator('p')).toHaveText(\n\t\t\t'Page data: {\"foo\":{\"bar\":\"Custom layout\"},\"layout\":\"layout\",\"page\":\"page\",\"data\":{\"rootlayout\":\"rootlayout\",\"layout\":\"layout\"}}'\n\t\t);\n\n\t\tawait clicknav('[href=\"/shadowed/parent/sub\"]');\n\t\tawait expect(page.locator('h2')).toHaveText(\n\t\t\t'Layout data: {\"foo\":{\"bar\":\"Custom layout\"},\"layout\":\"layout\"}'\n\t\t);\n\t\tawait expect(page.locator('p')).toHaveText(\n\t\t\t'Page data: {\"foo\":{\"bar\":\"Custom layout\"},\"layout\":\"layout\",\"sub\":\"sub\",\"data\":{\"rootlayout\":\"rootlayout\",\"layout\":\"layout\"}}'\n\t\t);\n\t});\n\n\tif (process.env.DEV) {\n\t\ttest('Data must be serializable', async ({ page, clicknav }) => {\n\t\t\tawait page.goto('/shadowed');\n\t\t\tawait clicknav('[href=\"/shadowed/serialization\"]');\n\n\t\t\texpect(await page.textContent('h1')).toBe('500');\n\t\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t\t'This is your custom error page saying: \"Data returned from `load` while rendering /shadowed/serialization is not serializable: Cannot stringify arbitrary non-POJOs (data.nope).' +\n\t\t\t\t\t' If you need to serialize/deserialize custom types, use transport hooks: https://svelte.dev/docs/kit/hooks#Universal-hooks-transport. (500 Internal Error)\"'\n\t\t\t);\n\t\t});\n\t}\n});\n\ntest.describe('Errors', () => {\n\tif (process.env.DEV) {\n\t\t// TODO these probably shouldn't have the full render treatment,\n\t\t// given that they will never be user-visible in prod\n\t\ttest('server-side errors', async ({ page }) => {\n\t\t\tawait page.goto('/errors/serverside');\n\n\t\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t\t'This is your custom error page saying: \"Crashing now (500 Internal Error)\"'\n\t\t\t);\n\t\t});\n\n\t\ttest('server-side module context errors', async ({ page }) => {\n\t\t\ttest.fixme();\n\n\t\t\tawait page.goto('/errors/module-scope-server');\n\n\t\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t\t'This is your custom error page saying: \"Crashing now\"'\n\t\t\t);\n\t\t});\n\n\t\ttest('errors on invalid load function response', async ({ page, app, javaScriptEnabled }) => {\n\t\t\tif (javaScriptEnabled) {\n\t\t\t\tawait page.goto('/');\n\t\t\t\tawait app.goto('/errors/invalid-load-response');\n\t\t\t} else {\n\t\t\t\tawait page.goto('/errors/invalid-load-response');\n\t\t\t}\n\n\t\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\n\t\t\tconst details = javaScriptEnabled\n\t\t\t\t? \"related to route '/errors/invalid-load-response'\"\n\t\t\t\t: 'in src/routes/errors/invalid-load-response/+page.js';\n\n\t\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t\t`This is your custom error page saying: \"a load function ${details} returned an array, but must return a plain object at the top level (i.e. \\`return {...}\\`) (500 Internal Error)\"`\n\t\t\t);\n\t\t});\n\n\t\ttest('errors on invalid server load function response', async ({\n\t\t\tpage,\n\t\t\tapp,\n\t\t\tjavaScriptEnabled\n\t\t}) => {\n\t\t\tif (javaScriptEnabled) {\n\t\t\t\tawait page.goto('/');\n\t\t\t\tawait app.goto('/errors/invalid-server-load-response');\n\t\t\t} else {\n\t\t\t\tawait page.goto('/errors/invalid-server-load-response');\n\t\t\t}\n\n\t\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\n\t\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t\t'This is your custom error page saying: \"a load function in src/routes/errors/invalid-server-load-response/+page.server.js returned an array, but must return a plain object at the top level (i.e. `return {...}`) (500 Internal Error)\"'\n\t\t\t);\n\t\t});\n\t}\n\n\ttest('server-side load errors', async ({ page, get_computed_style }) => {\n\t\tawait page.goto('/errors/load-server');\n\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Crashing now (500 Internal Error)\"'\n\t\t);\n\n\t\texpect(await get_computed_style('h1', 'color')).toBe('rgb(255, 0, 0)');\n\t});\n\n\ttest('404', async ({ page }) => {\n\t\tconst response = await page.goto('/why/would/anyone/fetch/this/url');\n\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Not found: /why/would/anyone/fetch/this/url (404 Not Found)\"'\n\t\t);\n\t\texpect(/** @type {Response} */ (response).status()).toBe(404);\n\t});\n\n\ttest('server-side error from load() is a string', async ({ page }) => {\n\t\tconst response = await page.goto('/errors/load-error-string-server');\n\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Not found\"'\n\t\t);\n\t\texpect(/** @type {Response} */ (response).status()).toBe(555);\n\t});\n\n\ttest('server-side error from load() is an Error', async ({ page }) => {\n\t\tconst response = await page.goto('/errors/load-error-server');\n\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Not found\"'\n\t\t);\n\t\texpect(/** @type {Response} */ (response).status()).toBe(555);\n\t});\n\n\ttest('server-side error from load() still has layout data', async ({ page }) => {\n\t\tawait page.goto('/errors/load-error-server/layout-data');\n\t\texpect(await page.textContent('#error-layout-data')).toBe('42');\n\t});\n\n\ttest('error in endpoint', async ({ page, read_errors }) => {\n\t\tconst res = await page.goto('/errors/endpoint');\n\n\t\t// should include stack trace\n\t\tconst lines = read_errors('/errors/endpoint.json').stack.split('\\n');\n\t\texpect(lines[0]).toMatch('nope');\n\n\t\tif (process.env.DEV) {\n\t\t\texpect(lines[1]).toMatch('endpoint.json');\n\t\t}\n\n\t\texpect(res && res.status()).toBe(500);\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"500 (500 Internal Error)\"'\n\t\t);\n\t});\n\n\ttest('error in shadow endpoint', async ({ page, read_errors }) => {\n\t\tconst res = await page.goto('/errors/endpoint-shadow');\n\n\t\t// should include stack trace\n\t\tconst lines = read_errors('/errors/endpoint-shadow').stack.split('\\n');\n\t\texpect(lines[0]).toMatch('nope');\n\n\t\tif (process.env.DEV) {\n\t\t\texpect(lines[1]).toMatch('+page.server.js:3:8');\n\t\t}\n\n\t\texpect(res && res.status()).toBe(500);\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"nope (500 Internal Error)\"'\n\t\t);\n\t});\n\n\ttest('not ok response from shadow endpoint', async ({ page, read_errors }) => {\n\t\tconst res = await page.goto('/errors/endpoint-shadow-not-ok');\n\n\t\texpect(read_errors('/errors/endpoint-shadow-not-ok')).toBeUndefined();\n\n\t\texpect(res && res.status()).toBe(555);\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Error: 555\"'\n\t\t);\n\t});\n\n\ttest('prerendering a page with a mutative page endpoint results in a catchable error', async ({\n\t\tpage\n\t}) => {\n\t\tawait page.goto('/prerendering/mutative-endpoint');\n\t\texpect(await page.textContent('h1')).toBe('500');\n\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Cannot prerender pages with actions (500 Internal Error)\"'\n\t\t);\n\t});\n\n\ttest('page endpoint GET thrown error message is preserved', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tread_errors\n\t}) => {\n\t\tawait page.goto('/errors/page-endpoint');\n\t\tawait clicknav('#get-implicit');\n\n\t\texpect(await page.textContent('pre')).toBe(\n\t\t\tJSON.stringify({ status: 500, message: 'oops (500 Internal Error)' }, null, '  ')\n\t\t);\n\n\t\tconst { status, name, message, stack, fancy } = read_errors(\n\t\t\t'/errors/page-endpoint/get-implicit'\n\t\t);\n\t\texpect(status).toBe(undefined);\n\t\texpect(name).toBe('FancyError');\n\t\texpect(message).toBe('oops');\n\t\texpect(fancy).toBe(true);\n\t\tif (process.env.DEV) {\n\t\t\tconst lines = stack.split('\\n');\n\t\t\texpect(lines[1]).toContain('+page.server.js:4:8');\n\t\t}\n\t});\n\n\ttest('page endpoint GET HttpError message is preserved', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tread_errors\n\t}) => {\n\t\tawait page.goto('/errors/page-endpoint');\n\t\tawait clicknav('#get-explicit');\n\n\t\texpect(await page.textContent('pre')).toBe(\n\t\t\tJSON.stringify({ status: 400, message: 'oops' }, null, '  ')\n\t\t);\n\n\t\tconst error = read_errors('/errors/page-endpoint/get-explicit');\n\t\texpect(error).toBe(undefined);\n\t});\n\n\ttest('page endpoint POST unexpected error message is preserved', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tread_errors\n\t}) => {\n\t\t// The case where we're submitting a POST request via a form.\n\t\t// It should show the __error template with our message.\n\t\tawait page.goto('/errors/page-endpoint');\n\t\tawait clicknav('#post-implicit');\n\n\t\texpect(await page.textContent('pre')).toBe(\n\t\t\tJSON.stringify({ status: 500, message: 'oops (500 Internal Error)' }, null, '  ')\n\t\t);\n\n\t\tconst { status, name, message, stack, fancy } = read_errors(\n\t\t\t'/errors/page-endpoint/post-implicit'\n\t\t);\n\n\t\texpect(status).toBe(undefined);\n\t\texpect(name).toBe('FancyError');\n\t\texpect(message).toBe('oops');\n\t\texpect(fancy).toBe(true);\n\t\tif (process.env.DEV) {\n\t\t\tconst lines = stack.split('\\n');\n\t\t\texpect(lines[1]).toContain('+page.server.js:6:9');\n\t\t}\n\t});\n\n\ttest('page endpoint POST HttpError error message is preserved', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tread_errors\n\t}) => {\n\t\t// The case where we're submitting a POST request via a form.\n\t\t// It should show the __error template with our message.\n\t\tawait page.goto('/errors/page-endpoint');\n\t\tawait clicknav('#post-explicit');\n\n\t\texpect(await page.textContent('pre')).toBe(\n\t\t\tJSON.stringify({ status: 400, message: 'oops' }, null, '  ')\n\t\t);\n\n\t\tconst error = read_errors('/errors/page-endpoint/post-explicit');\n\t\texpect(error).toBe(undefined);\n\t});\n});\n\ntest.describe('Headers', () => {\n\ttest('allows headers to be sent as a Headers class instead of a POJO', async ({ page }) => {\n\t\tawait page.goto('/headers/class');\n\t\texpect(await page.innerHTML('p')).toBe('bar');\n\t});\n});\n\ntest.describe('Redirects', () => {\n\ttest('redirect', async ({ baseURL, page, clicknav }) => {\n\t\tawait page.goto('/redirect');\n\n\t\tawait clicknav('[href=\"/redirect/a\"]');\n\n\t\tawait page.waitForURL('/redirect/c');\n\t\texpect(await page.textContent('h1')).toBe('c');\n\t\texpect(page.url()).toBe(`${baseURL}/redirect/c`);\n\n\t\tawait page.goBack();\n\t\texpect(page.url()).toBe(`${baseURL}/redirect`);\n\t});\n\n\ttest('prevents redirect loops', async ({ baseURL, page, javaScriptEnabled, browserName }) => {\n\t\tawait page.goto('/redirect');\n\n\t\tawait page.locator('[href=\"/redirect/loopy/a\"]').click();\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.waitForSelector('#message');\n\t\t\texpect(page.url()).toBe(`${baseURL}/redirect/loopy/a`);\n\t\t\texpect(await page.textContent('h1')).toBe('500');\n\t\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t\t'This is your custom error page saying: \"Redirect loop (500 Internal Error)\"'\n\t\t\t);\n\t\t} else {\n\t\t\t// there's not a lot we can do to handle server-side redirect loops\n\t\t\tif (browserName === 'chromium') {\n\t\t\t\texpect(page.url()).toBe('chrome-error://chromewebdata/');\n\t\t\t} else {\n\t\t\t\texpect(page.url()).toBe(`${baseURL}/redirect`);\n\t\t\t}\n\t\t}\n\t});\n\n\ttest('errors on missing status', async ({\n\t\tbaseURL,\n\t\tpage,\n\t\tclicknav,\n\t\tjavaScriptEnabled,\n\t\tread_errors\n\t}) => {\n\t\tawait page.goto('/redirect');\n\n\t\tawait clicknav('[href=\"/redirect/missing-status/a\"]');\n\n\t\tconst message = process.env.DEV || !javaScriptEnabled ? 'Invalid status code' : 'Redirect loop';\n\n\t\texpect(page.url()).toBe(`${baseURL}/redirect/missing-status/a`);\n\t\texpect(await page.textContent('h1')).toBe('500');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t`This is your custom error page saying: \"${message} (500 Internal Error)\"`\n\t\t);\n\n\t\tif (!javaScriptEnabled) {\n\t\t\t// handleError is not invoked for client-side navigation\n\t\t\tconst lines = read_errors('/redirect/missing-status/a').stack.split('\\n');\n\t\t\texpect(lines[0]).toBe(`Error: ${message}`);\n\t\t}\n\t});\n\n\ttest('errors on invalid status', async ({ baseURL, page, clicknav, javaScriptEnabled }) => {\n\t\tawait page.goto('/redirect');\n\n\t\tawait clicknav('[href=\"/redirect/missing-status/b\"]');\n\n\t\tconst message = process.env.DEV || !javaScriptEnabled ? 'Invalid status code' : 'Redirect loop';\n\n\t\texpect(page.url()).toBe(`${baseURL}/redirect/missing-status/b`);\n\t\texpect(await page.textContent('h1')).toBe('500');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t`This is your custom error page saying: \"${message} (500 Internal Error)\"`\n\t\t);\n\t});\n\n\ttest('redirect-on-load', async ({ baseURL, page, javaScriptEnabled }) => {\n\t\tconst redirected_to_url = javaScriptEnabled\n\t\t\t? `${baseURL}/redirect-on-load/redirected`\n\t\t\t: `${baseURL}/redirect-on-load`;\n\n\t\tawait Promise.all([page.waitForResponse(redirected_to_url), page.goto('/redirect-on-load')]);\n\n\t\texpect(page.url()).toBe(redirected_to_url);\n\n\t\tif (javaScriptEnabled) {\n\t\t\texpect(await page.textContent('h1')).toBe('Hazaa!');\n\t\t}\n\t});\n\n\ttest('redirect response in handle hook', async ({ baseURL, clicknav, page }) => {\n\t\tawait page.goto('/redirect');\n\n\t\tawait clicknav('[href=\"/redirect/in-handle?response\"]');\n\n\t\tawait page.waitForURL('/redirect/c');\n\t\texpect(await page.textContent('h1')).toBe('c');\n\t\texpect(page.url()).toBe(`${baseURL}/redirect/c`);\n\n\t\tawait page.goBack();\n\t\texpect(page.url()).toBe(`${baseURL}/redirect`);\n\t});\n\n\ttest('redirect in handle hook', async ({ baseURL, clicknav, page }) => {\n\t\tawait page.goto('/redirect');\n\n\t\tawait clicknav('[href=\"/redirect/in-handle?throw\"]');\n\n\t\tawait page.waitForURL('/redirect/c');\n\t\texpect(await page.textContent('h1')).toBe('c');\n\t\texpect(page.url()).toBe(`${baseURL}/redirect/c`);\n\n\t\tawait page.goBack();\n\t\texpect(page.url()).toBe(`${baseURL}/redirect`);\n\t});\n\n\ttest('sets cookies when redirect in handle hook', async ({ page, app, javaScriptEnabled }) => {\n\t\tawait page.goto('/cookies/set');\n\t\tlet span = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('teapot');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tconst [, response] = await Promise.all([\n\t\t\t\tapp.goto('/redirect/in-handle?throw&cookies'),\n\t\t\t\tpage.waitForResponse((request) =>\n\t\t\t\t\trequest.url().endsWith('in-handle/__data.json?throw=&cookies=&x-sveltekit-invalidated=01')\n\t\t\t\t)\n\t\t\t]);\n\t\t\texpect((await response.allHeaders())['set-cookie']).toBeDefined();\n\t\t}\n\n\t\tawait page.goto('/redirect/in-handle?throw&cookies');\n\t\tspan = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('undefined');\n\t});\n\n\ttest('works when used from another package', async ({ page }) => {\n\t\tawait page.goto('/redirect/package');\n\t\texpect(await page.textContent('h1')).toBe('c');\n\t});\n});\n\ntest.describe('Routing', () => {\n\ttest('redirects from /routing/ to /routing', async ({\n\t\tbaseURL,\n\t\tpage,\n\t\tclicknav,\n\t\tapp,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tawait page.goto('/routing/slashes');\n\n\t\tawait clicknav('a[href=\"/routing/\"]');\n\t\texpect(page.url()).toBe(`${baseURL}/routing`);\n\t\texpect(await page.textContent('h1')).toBe('Great success!');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.goto(`${baseURL}/routing/slashes`);\n\t\t\tawait app.goto('/routing/');\n\t\t\texpect(page.url()).toBe(`${baseURL}/routing`);\n\t\t\texpect(await page.textContent('h1')).toBe('Great success!');\n\t\t}\n\t});\n\n\ttest('redirects from /routing/? to /routing', async ({\n\t\tbaseURL,\n\t\tpage,\n\t\tclicknav,\n\t\tapp,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tawait page.goto('/routing/slashes');\n\n\t\tawait clicknav('a[href=\"/routing/?\"]');\n\t\texpect(page.url()).toBe(`${baseURL}/routing`);\n\t\texpect(await page.textContent('h1')).toBe('Great success!');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.goto(`${baseURL}/routing/slashes`);\n\t\t\tawait app.goto('/routing/?');\n\t\t\texpect(page.url()).toBe(`${baseURL}/routing`);\n\t\t\texpect(await page.textContent('h1')).toBe('Great success!');\n\t\t}\n\t});\n\n\ttest('redirects from /routing/?foo=bar to /routing?foo=bar', async ({\n\t\tbaseURL,\n\t\tpage,\n\t\tclicknav,\n\t\tapp,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tawait page.goto('/routing/slashes');\n\n\t\tawait clicknav('a[href=\"/routing/?foo=bar\"]');\n\t\texpect(page.url()).toBe(`${baseURL}/routing?foo=bar`);\n\t\texpect(await page.textContent('h1')).toBe('Great success!');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.goto(`${baseURL}/routing/slashes`);\n\t\t\tawait app.goto('/routing/?foo=bar');\n\t\t\texpect(page.url()).toBe(`${baseURL}/routing?foo=bar`);\n\t\t\texpect(await page.textContent('h1')).toBe('Great success!');\n\t\t}\n\t});\n\n\ttest('serves static route', async ({ page }) => {\n\t\tawait page.goto('/routing/a');\n\t\texpect(await page.textContent('h1')).toBe('a');\n\t});\n\n\ttest('serves static route from dir/index.html file', async ({ page }) => {\n\t\tawait page.goto('/routing/b');\n\t\texpect(await page.textContent('h1')).toBe('b');\n\t});\n\n\ttest('serves static route under client directory', async ({ baseURL, page }) => {\n\t\tawait page.goto('/routing/client/foo');\n\n\t\texpect(await page.textContent('h1')).toBe('foo');\n\n\t\tawait page.goto(`${baseURL}/routing/client/bar`);\n\t\texpect(await page.textContent('h1')).toBe('bar');\n\n\t\tawait page.goto(`${baseURL}/routing/client/bar/b`);\n\t\texpect(await page.textContent('h1')).toBe('b');\n\t});\n\n\ttest('serves dynamic route', async ({ page }) => {\n\t\tawait page.goto('/routing/test-slug');\n\t\texpect(await page.textContent('h1')).toBe('test-slug');\n\t});\n\n\ttest('does not attempt client-side navigation to server routes', async ({ page }) => {\n\t\tawait page.goto('/routing');\n\t\tawait page.locator('[href=\"/routing/ambiguous/ok.json\"]').click();\n\t\texpect(await page.textContent('body')).toBe('ok');\n\t});\n\n\ttest('does not attempt client-side navigation to links with data-sveltekit-reload', async ({\n\t\tbaseURL,\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/routing');\n\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (r) => requests.push(r.url()));\n\n\t\tawait clicknav('[href=\"/routing/b\"]');\n\t\texpect(await page.textContent('h1')).toBe('b');\n\t\texpect(requests).toContain(`${baseURL}/routing/b`);\n\t});\n\n\ttest('allows reserved words as route names', async ({ page }) => {\n\t\tawait page.goto('/routing/const');\n\t\texpect(await page.textContent('h1')).toBe('reserved words are okay as routes');\n\t});\n\n\ttest('resets the active element after navigation', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing');\n\t\tawait clicknav('[href=\"/routing/a\"]');\n\t\tawait page.waitForFunction(() => (document.activeElement || {}).nodeName == 'BODY');\n\t});\n\n\ttest('navigates between routes with empty parts', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/dirs/foo');\n\t\texpect(await page.textContent('h1')).toBe('foo');\n\t\tawait clicknav('[href=\"bar\"]');\n\t\texpect(await page.textContent('h1')).toBe('bar');\n\t});\n\n\ttest('navigates between dynamic routes with same segments', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/dirs/bar/xyz');\n\t\texpect(await page.textContent('h1')).toBe('A page');\n\n\t\tawait clicknav('[href=\"/routing/dirs/foo/xyz\"]');\n\t\texpect(await page.textContent('h1')).toBe('B page');\n\t});\n\n\ttest('invalidates page when a segment is skipped', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/skipped/x/1');\n\t\texpect(await page.textContent('h1')).toBe('x/1');\n\n\t\tawait clicknav('#goto-y1');\n\t\texpect(await page.textContent('h1')).toBe('y/1');\n\t});\n\n\ttest('back button returns to initial route', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing');\n\t\tawait clicknav('[href=\"/routing/a\"]');\n\n\t\tawait page.goBack();\n\t\texpect(await page.textContent('h1')).toBe('Great success!');\n\t});\n\n\ttest('focus works if page load has hash', async ({ page, browserName }) => {\n\t\tawait page.goto('/routing/hashes/target#p2');\n\n\t\tawait page.waitForSelector('#p2:focus');\n\t\tawait page.keyboard.press(browserName === 'webkit' ? 'Alt+Tab' : 'Tab');\n\t\tawait page.waitForSelector('button:focus');\n\t});\n\n\ttest('focus works when navigating to a hash on the same page', async ({ page, browserName }) => {\n\t\tawait page.goto('/routing/hashes/target');\n\n\t\tawait page.click('[href=\"#p2\"]');\n\t\tawait page.keyboard.press(browserName === 'webkit' ? 'Alt+Tab' : 'Tab');\n\n\t\texpect(await page.evaluate(() => (document.activeElement || {}).textContent)).toBe(\n\t\t\t'next focus element'\n\t\t);\n\t});\n\n\ttest(':target pseudo-selector works when navigating to a hash on the same page', async ({\n\t\tpage,\n\t\tget_computed_style\n\t}) => {\n\t\tawait page.goto('/routing/hashes/target#p1');\n\n\t\texpect(await get_computed_style('#p1', 'color')).toBe('rgb(255, 0, 0)');\n\t\tawait page.click('[href=\"#p2\"]');\n\t\texpect(await get_computed_style('#p2', 'color')).toBe('rgb(255, 0, 0)');\n\t});\n\n\ttest('last parameter in a segment wins in cases of ambiguity', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/split-params');\n\t\tawait clicknav('[href=\"/routing/split-params/x-y-z\"]');\n\t\texpect(await page.textContent('h1')).toBe('x');\n\t\texpect(await page.textContent('h2')).toBe('y-z');\n\t});\n\n\ttest('ignores navigation to URLs the app does not own', async ({ page, start_server }) => {\n\t\tconst { port } = await start_server((req, res) => res.end('ok'));\n\n\t\tawait page.goto(`/routing?port=${port}`);\n\t\tawait Promise.all([\n\t\t\tpage.click(`[href=\"http://localhost:${port}\"]`),\n\t\t\t// assert that the app can visit a URL not owned by the app without crashing\n\t\t\tpage.waitForURL(`http://localhost:${port}/`)\n\t\t]);\n\t});\n\n\ttest('navigates to ...rest', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/rest/abc/xyz');\n\n\t\texpect(await page.textContent('h1')).toBe('abc/xyz');\n\n\t\tawait clicknav('[href=\"/routing/rest/xyz/abc/def/ghi\"]');\n\t\texpect(await page.textContent('h1')).toBe('xyz/abc/def/ghi');\n\t\texpect(await page.textContent('h2')).toBe('xyz/abc/def/ghi');\n\n\t\tawait clicknav('[href=\"/routing/rest/xyz/abc/def\"]');\n\t\texpect(await page.textContent('h1')).toBe('xyz/abc/def');\n\t\texpect(await page.textContent('h2')).toBe('xyz/abc/def');\n\n\t\tawait clicknav('[href=\"/routing/rest/xyz/abc\"]');\n\t\texpect(await page.textContent('h1')).toBe('xyz/abc');\n\t\texpect(await page.textContent('h2')).toBe('xyz/abc');\n\n\t\tawait clicknav('[href=\"/routing/rest\"]');\n\t\texpect(await page.textContent('h1')).toBe('');\n\t\texpect(await page.textContent('h2')).toBe('');\n\n\t\tawait clicknav('[href=\"/routing/rest/xyz/abc/deep\"]');\n\t\texpect(await page.textContent('h1')).toBe('xyz/abc');\n\t\texpect(await page.textContent('h2')).toBe('xyz/abc');\n\n\t\tawait page.locator('[href=\"/routing/rest/xyz/abc/qwe/deep.json\"]').click();\n\t\texpect(await page.textContent('body')).toBe('xyz/abc/qwe');\n\t});\n\n\ttest('rest parameters do not swallow characters', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/rest/non-greedy');\n\n\t\tawait clicknav('[href=\"/routing/rest/non-greedy/foo/one/two\"]');\n\t\texpect(await page.textContent('h1')).toBe('non-greedy');\n\t\texpect(await page.textContent('h2')).toBe('{\"rest\":\"one/two\"}');\n\n\t\tawait clicknav('[href=\"/routing/rest/non-greedy/food/one/two\"]');\n\t\texpect(await page.textContent('h1')).not.toBe('non-greedy');\n\n\t\tawait page.goBack();\n\n\t\tawait clicknav('[href=\"/routing/rest/non-greedy/one-bar/two/three\"]');\n\t\texpect(await page.textContent('h1')).toBe('non-greedy');\n\t\texpect(await page.textContent('h2')).toBe('{\"dynamic\":\"one\",\"rest\":\"two/three\"}');\n\n\t\tawait clicknav('[href=\"/routing/rest/non-greedy/one-bard/two/three\"]');\n\t\texpect(await page.textContent('h1')).not.toBe('non-greedy');\n\t});\n\n\ttest('reloads when navigating between ...rest pages', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/rest/path/one');\n\t\texpect(await page.textContent('h1')).toBe('path: /routing/rest/path/one');\n\n\t\tawait clicknav('[href=\"/routing/rest/path/two\"]');\n\t\texpect(await page.textContent('h1')).toBe('path: /routing/rest/path/two');\n\n\t\tawait clicknav('[href=\"/routing/rest/path/three\"]');\n\t\texpect(await page.textContent('h1')).toBe('path: /routing/rest/path/three');\n\t});\n\n\ttest('allows rest routes to have prefixes and suffixes', async ({ page }) => {\n\t\tawait page.goto('/routing/rest/complex/prefix-one/two/three');\n\t\texpect(await page.textContent('h1')).toBe('parts: one/two/three');\n\t});\n\n\ttest('links to unmatched routes result in a full page navigation, not a 404', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/routing');\n\t\tawait clicknav('[href=\"/static.json\"]');\n\t\texpect(await page.textContent('body')).toBe('\"static file\"\\n');\n\t});\n\n\ttest('navigation is cancelled upon subsequent navigation', async ({\n\t\tbaseURL,\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/routing/cancellation');\n\t\tawait page.locator('[href=\"/routing/cancellation/a\"]').click();\n\t\tawait clicknav('[href=\"/routing/cancellation/b\"]');\n\n\t\texpect(await page.url()).toBe(`${baseURL}/routing/cancellation/b`);\n\n\t\tawait page.evaluate('window.fulfil_navigation && window.fulfil_navigation()');\n\t\texpect(await page.url()).toBe(`${baseURL}/routing/cancellation/b`);\n\t});\n\n\ttest('Relative paths are relative to the current URL', async ({ page, clicknav }) => {\n\t\tawait page.goto('/iframes');\n\t\tawait clicknav('[href=\"/iframes/nested/parent\"]');\n\n\t\texpect(await page.frameLocator('iframe').locator('h1').textContent()).toBe(\n\t\t\t'Hello from the child'\n\t\t);\n\t});\n\n\ttest('exposes page.route.id', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/route-id');\n\t\tawait clicknav('[href=\"/routing/route-id/foo\"]');\n\n\t\texpect(await page.textContent('h1')).toBe('route.id in load: /routing/route-id/[x]');\n\t\texpect(await page.textContent('h2')).toBe('route.id in store: /routing/route-id/[x]');\n\t});\n\n\ttest('serves a page that clashes with a root directory', async ({ page }) => {\n\t\tawait page.goto('/static');\n\t\texpect(await page.textContent('h1')).toBe('hello');\n\t});\n\n\ttest('shows \"Not Found\" in 404 case', async ({ page }) => {\n\t\tawait page.goto('/404-fallback');\n\t\texpect(await page.textContent('h1')).toBe('404');\n\t\texpect(await page.textContent('p')).toBe('This is your custom error page saying: \"Not Found\"');\n\t});\n\n\tif (process.platform !== 'win32') {\n\t\ttest('Respects symlinks', async ({ page, clicknav }) => {\n\t\t\tawait page.goto('/routing');\n\t\t\tawait clicknav('[href=\"/routing/symlink-from\"]');\n\n\t\t\texpect(await page.textContent('h1')).toBe('symlinked');\n\t\t});\n\t}\n\n\ttest('trailing slash server with config always', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/trailing-slash-server');\n\t\tawait clicknav('[href=\"/routing/trailing-slash-server/always\"]');\n\t\texpect(await page.textContent('[data-test-id=\"pathname-store\"]')).toBe(\n\t\t\t'/routing/trailing-slash-server/always/'\n\t\t);\n\t\texpect(await page.textContent('[data-test-id=\"pathname-data\"]')).toBe(\n\t\t\t'/routing/trailing-slash-server/always/'\n\t\t);\n\t});\n\n\ttest('trailing slash server with config ignore and no trailing slash in URL', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/routing/trailing-slash-server');\n\t\tawait clicknav('[href=\"/routing/trailing-slash-server/ignore\"]');\n\t\texpect(await page.textContent('[data-test-id=\"pathname-store\"]')).toBe(\n\t\t\t'/routing/trailing-slash-server/ignore'\n\t\t);\n\t\texpect(await page.textContent('[data-test-id=\"pathname-data\"]')).toBe(\n\t\t\t'/routing/trailing-slash-server/ignore'\n\t\t);\n\t});\n\n\ttest('trailing slash server with config ignore and trailing slash in URL', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/routing/trailing-slash-server');\n\t\tawait clicknav('[href=\"/routing/trailing-slash-server/ignore/\"]');\n\t\texpect(await page.textContent('[data-test-id=\"pathname-store\"]')).toBe(\n\t\t\t'/routing/trailing-slash-server/ignore/'\n\t\t);\n\t\texpect(await page.textContent('[data-test-id=\"pathname-data\"]')).toBe(\n\t\t\t'/routing/trailing-slash-server/ignore/'\n\t\t);\n\t});\n\n\ttest('trailing slash server with config never', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/trailing-slash-server');\n\t\tawait clicknav('[href=\"/routing/trailing-slash-server/never/\"]');\n\t\texpect(await page.textContent('[data-test-id=\"pathname-store\"]')).toBe(\n\t\t\t'/routing/trailing-slash-server/never'\n\t\t);\n\t\texpect(await page.textContent('[data-test-id=\"pathname-data\"]')).toBe(\n\t\t\t'/routing/trailing-slash-server/never'\n\t\t);\n\t});\n});\n\ntest.describe('XSS', () => {\n\ttest('replaces %sveltekit.xxx% tags safely', async ({ page }) => {\n\t\tawait page.goto('/unsafe-replacement');\n\n\t\tconst content = await page.textContent('body');\n\t\texpect(content).toMatch('$& $&');\n\t});\n\n\ttest('escapes inline data', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/xss');\n\n\t\texpect(await page.textContent('h1')).toBe(\n\t\t\t'user.name is </script><script>window.pwned = 1</script>'\n\t\t);\n\n\t\tif (!javaScriptEnabled) {\n\t\t\t// @ts-expect-error - check global injected variable\n\t\t\texpect(await page.evaluate(() => window.pwned)).toBeUndefined();\n\t\t}\n\t});\n\n\tconst uri_xss_payload = '</script><script>window.pwned=1</script>';\n\tconst uri_xss_payload_encoded = encodeURIComponent(uri_xss_payload);\n\n\ttest('no xss via dynamic route path', async ({ page }) => {\n\t\tawait page.goto(`/xss/${uri_xss_payload_encoded}`);\n\n\t\texpect(await page.textContent('h1')).toBe(uri_xss_payload);\n\n\t\t// @ts-expect-error - check global injected variable\n\t\texpect(await page.evaluate(() => window.pwned)).toBeUndefined();\n\t});\n\n\ttest('no xss via query param', async ({ page }) => {\n\t\tawait page.goto(`/xss/query?key=${uri_xss_payload_encoded}`);\n\n\t\texpect(await page.textContent('#one')).toBe(JSON.stringify({ key: [uri_xss_payload] }));\n\t\texpect(await page.textContent('#two')).toBe(JSON.stringify({ key: [uri_xss_payload] }));\n\n\t\t// @ts-expect-error - check global injected variable\n\t\texpect(await page.evaluate(() => window.pwned)).toBeUndefined();\n\t});\n\n\ttest('no xss via shadow endpoint', async ({ page }) => {\n\t\tawait page.goto('/xss/shadow');\n\n\t\t// @ts-expect-error - check global injected variable\n\t\texpect(await page.evaluate(() => window.pwned)).toBeUndefined();\n\t\texpect(await page.textContent('h1')).toBe(\n\t\t\t'user.name is </script><script>window.pwned = 1</script>'\n\t\t);\n\t});\n\n\ttest('no xss via tracked search parameters', async ({ page }) => {\n\t\t// https://github.com/sveltejs/kit/security/advisories/GHSA-6q87-84jw-cjhp\n\t\tawait page.goto('/xss/query-tracking?</script/><script>window.pwned%3D1</script/>');\n\n\t\t// @ts-expect-error - check global injected variable\n\t\texpect(await page.evaluate(() => window.pwned)).toBeUndefined();\n\t});\n});\n\ntest.describe('$app/server', () => {\n\ttest('can read a file', async ({ page }) => {\n\t\tawait page.goto('/read-file');\n\n\t\tconst auto = await page.textContent('[data-testid=\"auto\"]');\n\t\tconst url = await page.textContent('[data-testid=\"url\"]');\n\t\tconst styles = await page.textContent('[data-testid=\"styles\"]');\n\t\tconst local_glob = await page.textContent('[data-testid=\"local_glob\"]');\n\t\tconst external_glob = await page.textContent('[data-testid=\"external_glob\"]');\n\t\tconst svg = await page.innerHTML('[data-testid=\"svg\"]');\n\n\t\t// the emoji is there to check that base64 decoding works correctly\n\t\texpect(auto?.trim()).toBe('Imported without ?url 😎');\n\t\texpect(url?.trim()).toBe('Imported with ?url 😎');\n\t\texpect(local_glob?.trim()).toBe('Imported with ?url via glob 😎');\n\t\texpect(external_glob?.trim()).toBe(\n\t\t\t'Imported with url glob from the read-file test in basics. Placed here outside the app folder to force a /@fs prefix 😎'\n\t\t);\n\t\texpect(svg).toContain('<rect width=\"24\" height=\"24\" rx=\"2\" fill=\"#ff3e00\"></rect>');\n\n\t\t// check that paths in .css files are relative\n\t\texpect(styles).toContain('url(.');\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/basics/test/server.test.js",
    "content": "/** @import { ReadableSpan } from '@opentelemetry/sdk-trace-node' */\nimport process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\nimport { createHash, randomBytes } from 'node:crypto';\nimport fs from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport path from 'node:path';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.skip(({ javaScriptEnabled }) => javaScriptEnabled);\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe('Caching', () => {\n\ttest('caches pages', async ({ request }) => {\n\t\tconst response = await request.get('/caching');\n\t\texpect(response.headers()['cache-control']).toBe('public, max-age=30');\n\t});\n});\n\ntest.describe('Content-Type', () => {\n\ttest('sets Content-Type on page', async ({ request }) => {\n\t\tconst response = await request.get('/content-type-header');\n\t\texpect(response.headers()['content-type']).toBe('text/html');\n\t});\n});\n\ntest.describe('Content-Length', () => {\n\ttest('sets Content-Length on page', async ({ request }) => {\n\t\tconst response = await request.get('/content-length-header');\n\n\t\t// TODO this would ideally be a unit test of `Server`,\n\t\t// as would most of the tests in this file\n\t\tif (!response.headers()['content-encoding']) {\n\t\t\texpect(+response.headers()['content-length']).toBeGreaterThan(1000);\n\t\t}\n\t});\n});\n\ntest.describe('Cookies', () => {\n\ttest('does not forward cookies from external domains', async ({ request, start_server }) => {\n\t\tconst { port } = await start_server(async (req, res) => {\n\t\t\tif (req.url === '/') {\n\t\t\t\tres.writeHead(200, {\n\t\t\t\t\t'set-cookie': 'external=true',\n\t\t\t\t\t'access-control-allow-origin': '*'\n\t\t\t\t});\n\n\t\t\t\tres.end('ok');\n\t\t\t} else {\n\t\t\t\tres.writeHead(404);\n\t\t\t\tres.end('not found');\n\t\t\t}\n\t\t});\n\n\t\tconst response = await request.get(`/load/fetch-external-no-cookies?port=${port}`);\n\t\texpect(response.headers()['set-cookie']).not.toContain('external=true');\n\t});\n});\n\ntest.describe('CSRF', () => {\n\tif (process.env.DEV) {\n\t\treturn;\n\t}\n\n\ttest('Blocks requests with incorrect origin', async ({ baseURL }) => {\n\t\tconst content_types = [\n\t\t\t'application/x-www-form-urlencoded',\n\t\t\t'multipart/form-data',\n\t\t\t'text/plain',\n\t\t\t'text/plaiN'\n\t\t];\n\t\tconst methods = ['POST', 'PUT', 'PATCH', 'DELETE'];\n\t\tfor (const method of methods) {\n\t\t\tfor (const content_type of content_types) {\n\t\t\t\tconst res = await fetch(`${baseURL}/csrf`, {\n\t\t\t\t\tmethod,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'content-type': content_type\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tconst message = `request method: ${method}, content-type: ${content_type}`;\n\t\t\t\texpect(res.status, message).toBe(403);\n\t\t\t\texpect(await res.text(), message).toBe(\n\t\t\t\t\t`Cross-site ${method} form submissions are forbidden`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t});\n\n\ttest('Allows requests from same origin', async ({ baseURL }) => {\n\t\tconst url = new URL(baseURL);\n\t\tconst res = await fetch(`${baseURL}/csrf`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/x-www-form-urlencoded',\n\t\t\t\torigin: url.origin\n\t\t\t}\n\t\t});\n\t\texpect(res.status).toBe(200);\n\t\texpect(await res.text()).toBe('ok');\n\t});\n\n\ttest('Allows requests from allowed origins', async ({ baseURL }) => {\n\t\t// Test with trusted.example.com which is in trustedOrigins\n\t\tconst res1 = await fetch(`${baseURL}/csrf`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/x-www-form-urlencoded',\n\t\t\t\torigin: 'https://trusted.example.com'\n\t\t\t}\n\t\t});\n\t\texpect(res1.status).toBe(200);\n\t\texpect(await res1.text()).toBe('ok');\n\n\t\t// Test with payment-gateway.test which is also in trustedOrigins\n\t\tconst res2 = await fetch(`${baseURL}/csrf`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/x-www-form-urlencoded',\n\t\t\t\torigin: 'https://payment-gateway.test'\n\t\t\t}\n\t\t});\n\t\texpect(res2.status).toBe(200);\n\t\texpect(await res2.text()).toBe('ok');\n\t});\n\n\ttest('Blocks requests from non-allowed origins', async ({ baseURL }) => {\n\t\t// Test with origin not in trustedOrigins list\n\t\tconst res1 = await fetch(`${baseURL}/csrf`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/x-www-form-urlencoded',\n\t\t\t\torigin: 'https://malicious-site.com'\n\t\t\t}\n\t\t});\n\t\texpect(res1.status).toBe(403);\n\t\texpect(await res1.text()).toBe('Cross-site POST form submissions are forbidden');\n\n\t\t// Test with similar but not exact origin\n\t\tconst res2 = await fetch(`${baseURL}/csrf`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/x-www-form-urlencoded',\n\t\t\t\torigin: 'https://trusted.example.com.evil.com'\n\t\t\t}\n\t\t});\n\t\texpect(res2.status).toBe(403);\n\t\texpect(await res2.text()).toBe('Cross-site POST form submissions are forbidden');\n\n\t\t// Test subdomain attack (should be blocked)\n\t\tconst res3 = await fetch(`${baseURL}/csrf`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/x-www-form-urlencoded',\n\t\t\t\torigin: 'https://evil.trusted.example.com'\n\t\t\t}\n\t\t});\n\t\texpect(res3.status).toBe(403);\n\t\texpect(await res3.text()).toBe('Cross-site POST form submissions are forbidden');\n\t});\n\n\ttest('Allows GET requests regardless of origin', async ({ baseURL }) => {\n\t\tconst res = await fetch(`${baseURL}/csrf`, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/x-www-form-urlencoded',\n\t\t\t\torigin: 'https://any-origin.com'\n\t\t\t}\n\t\t});\n\t\texpect(res.status).toBe(200);\n\t});\n\n\ttest('Allows non-form content types regardless of origin', async ({ baseURL }) => {\n\t\tconst res = await fetch(`${baseURL}/csrf`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/json',\n\t\t\t\torigin: 'https://any-origin.com'\n\t\t\t}\n\t\t});\n\t\texpect(res.status).toBe(200);\n\t});\n\n\ttest('Allows all protected HTTP methods from allowed origins', async ({ baseURL }) => {\n\t\tconst methods = ['POST', 'PUT', 'PATCH', 'DELETE'];\n\t\tfor (const method of methods) {\n\t\t\tconst res = await fetch(`${baseURL}/csrf`, {\n\t\t\t\tmethod,\n\t\t\t\theaders: {\n\t\t\t\t\t'content-type': 'application/x-www-form-urlencoded',\n\t\t\t\t\torigin: 'https://trusted.example.com'\n\t\t\t\t}\n\t\t\t});\n\t\t\texpect(res.status, `Method ${method} should be allowed from trusted origin`).toBe(200);\n\t\t\texpect(await res.text(), `Method ${method} should return ok`).toBe('ok');\n\t\t}\n\t});\n\n\ttest('Handles undefined origin correctly', async ({ baseURL }) => {\n\t\t// Some requests may have null origin (e.g., from certain mobile apps)\n\t\tconst res = await fetch(`${baseURL}/csrf`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/x-www-form-urlencoded'\n\t\t\t}\n\t\t});\n\t\texpect(res.status).toBe(403);\n\t\texpect(await res.text()).toBe('Cross-site POST form submissions are forbidden');\n\t});\n});\n\ntest.describe('Endpoints', () => {\n\ttest('HEAD with matching headers but without body', async ({ request }) => {\n\t\tconst url = '/endpoint-output/body';\n\n\t\tconst responses = {\n\t\t\thead: await request.head(url),\n\t\t\tget: await request.get(url)\n\t\t};\n\n\t\tconst headers = {\n\t\t\thead: responses.head.headers(),\n\t\t\tget: responses.get.headers()\n\t\t};\n\n\t\texpect(responses.head.status()).toBe(200);\n\t\texpect(responses.get.status()).toBe(200);\n\t\texpect(await responses.head.text()).toBe('');\n\t\texpect(await responses.get.text()).toBe('{}');\n\n\t\t['date', 'transfer-encoding'].forEach((name) => {\n\t\t\tdelete headers.head[name];\n\t\t\tdelete headers.get[name];\n\t\t});\n\n\t\texpect(headers.head).toEqual(headers.get);\n\t});\n\n\ttest('Prerendered +server.js called from a non-prerendered +server.js works', async ({\n\t\tbaseURL\n\t}) => {\n\t\tconst res = await fetch(`${baseURL}/prerendering/prerendered-endpoint/proxy`);\n\n\t\texpect(res.status).toBe(200);\n\t\texpect(await res.json()).toStrictEqual({\n\t\t\tmessage: 'Im prerendered and called from a non-prerendered +page.server.js'\n\t\t});\n\t});\n\n\ttest('Partially Prerendered +server.js called from a non-prerendered +server.js works', async ({\n\t\tbaseURL\n\t}) => {\n\t\tfor (const [description, url] of [\n\t\t\t['direct', `${baseURL}/prerendering/prerendered-endpoint/api-with-param/prerendered`],\n\t\t\t[\n\t\t\t\t'proxied',\n\t\t\t\t`${baseURL}/prerendering/prerendered-endpoint/proxy?api-with-param-option=prerendered`\n\t\t\t]\n\t\t]) {\n\t\t\tawait test.step(description, async () => {\n\t\t\t\tconst res = await fetch(url);\n\n\t\t\t\texpect(res.status).toBe(200);\n\t\t\t\texpect(await res.json()).toStrictEqual({\n\t\t\t\t\tmessage: 'Im prerendered and called from a non-prerendered +page.server.js'\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t});\n\n\ttest('invalid request method returns allow header', async ({ request }) => {\n\t\tconst response = await request.post('/endpoint-output/body');\n\n\t\texpect(response.status()).toBe(405);\n\n\t\tconst allow_header = response.headers()['allow'];\n\t\texpect(allow_header).toMatch(/\\bGET\\b/);\n\t\texpect(allow_header).toMatch(/\\bHEAD\\b/);\n\t});\n\n\ttest('405 allow header has no duplicate methods listed', async ({ request }) => {\n\t\tconst response = await request.post('/endpoint-output/head-handler');\n\n\t\texpect(response.status()).toBe(405);\n\n\t\tconst allow_header = response.headers()['allow'];\n\t\tconst methods = allow_header.split(',').map((m) => m.trim());\n\t\tconst unique_methods = [...new Set(methods)];\n\n\t\texpect(methods).toEqual(unique_methods);\n\t});\n\n\t// TODO all the remaining tests in this section are really only testing\n\t// setResponse, since we're not otherwise changing anything on the response.\n\t// might be worth making these unit tests instead\n\ttest('multiple set-cookie on endpoints using GET', async ({ request }) => {\n\t\tconst response = await request.get('/set-cookie');\n\n\t\tconst cookies = response\n\t\t\t.headersArray()\n\t\t\t.filter((obj) => obj.name === 'set-cookie')\n\t\t\t.map((obj) => obj.value);\n\n\t\texpect(cookies).toEqual([\n\t\t\t'answer=42; HttpOnly',\n\t\t\t'problem=comma, separated, values; HttpOnly',\n\t\t\t'name=SvelteKit; path=/; HttpOnly'\n\t\t]);\n\t});\n\n\t// TODO see above\n\ttest('body can be a binary ReadableStream', async ({ request }) => {\n\t\tconst interruptedResponse = request.get('/endpoint-output/stream-throw-error');\n\t\tawait expect(interruptedResponse).rejects.toThrow('socket hang up');\n\n\t\tconst response = await request.get('/endpoint-output/stream');\n\t\tconst body = await response.body();\n\t\tconst digest = createHash('sha256').update(body).digest('base64url');\n\t\texpect(response.headers()['digest']).toEqual(`sha-256=${digest}`);\n\t});\n\n\t// TODO see above\n\ttest('stream can be canceled with TypeError', async ({ request }) => {\n\t\tconst responseBefore = await request.get('/endpoint-output/stream-typeerror?what');\n\t\texpect(await responseBefore.text()).toEqual('null');\n\n\t\tconst interruptedResponse = request.get('/endpoint-output/stream-typeerror');\n\t\tawait expect(interruptedResponse).rejects.toThrow('socket hang up');\n\n\t\tconst responseAfter = await request.get('/endpoint-output/stream-typeerror?what');\n\t\texpect(await responseAfter.text()).toEqual('TypeError');\n\t});\n\n\t// TODO see above\n\ttest('request body can be read slow', async ({ request }) => {\n\t\tconst data = randomBytes(1024 * 256);\n\t\tconst digest = createHash('sha256').update(data).digest('base64url');\n\t\tconst response = await request.put('/endpoint-input/sha256', { data });\n\t\texpect(await response.text()).toEqual(digest);\n\t});\n\n\t// TODO see above\n\ttest('invalid headers return a 500', async ({ request }) => {\n\t\tconst response = await request.get('/endpoint-output/head-write-error');\n\t\texpect(response.status()).toBe(500);\n\t\texpect(await response.text()).toMatch(\n\t\t\t'TypeError [ERR_INVALID_CHAR]: Invalid character in header content [\"x-test\"]'\n\t\t);\n\t});\n\n\ttest('OPTIONS handler', async ({ request }) => {\n\t\tconst url = '/endpoint-output';\n\n\t\tconst response = await request.fetch(url, {\n\t\t\tmethod: 'OPTIONS'\n\t\t});\n\n\t\texpect(response.status()).toBe(200);\n\t\texpect(await response.text()).toBe('ok');\n\t});\n\n\ttest('HEAD handler', async ({ request }) => {\n\t\tconst url = '/endpoint-output/head-handler';\n\n\t\tconst page_response = await request.fetch(url, {\n\t\t\tmethod: 'HEAD',\n\t\t\theaders: {\n\t\t\t\taccept: 'text/html'\n\t\t\t}\n\t\t});\n\n\t\texpect(page_response.status()).toBe(200);\n\t\texpect(await page_response.text()).toBe('');\n\t\texpect(page_response.headers()['x-sveltekit-page']).toBe('true');\n\n\t\tconst endpoint_response = await request.fetch(url, {\n\t\t\tmethod: 'HEAD',\n\t\t\theaders: {\n\t\t\t\taccept: 'application/json'\n\t\t\t}\n\t\t});\n\n\t\texpect(endpoint_response.status()).toBe(200);\n\t\texpect(await endpoint_response.text()).toBe('');\n\t\texpect(endpoint_response.headers()['x-sveltekit-head-endpoint']).toBe('true');\n\t});\n\n\ttest('catch-all handler', async ({ request }) => {\n\t\tconst url = '/endpoint-output/fallback';\n\n\t\tlet response = await request.fetch(url, {\n\t\t\tmethod: 'GET'\n\t\t});\n\n\t\texpect(response.status()).toBe(200);\n\t\texpect(await response.text()).toBe('ok');\n\n\t\tresponse = await request.fetch(url, {\n\t\t\tmethod: 'MOVE' // also works with arcane methods\n\t\t});\n\n\t\texpect(response.status()).toBe(200);\n\t\texpect(await response.text()).toBe('catch-all');\n\n\t\tresponse = await request.fetch(url, {\n\t\t\tmethod: 'OPTIONS'\n\t\t});\n\n\t\texpect(response.status()).toBe(200);\n\t\texpect(await response.text()).toBe('catch-all');\n\t});\n\n\ttest('can get assets using absolute path', async ({ request }) => {\n\t\tconst response = await request.get('/endpoint-output/fetch-asset/absolute');\n\t\texpect(response.status()).toBe(200);\n\t\texpect(response.headers()['content-type']).toBe('text/plain');\n\t\texpect(await response.text()).toBe('Cos sie konczy, cos zaczyna');\n\t});\n\n\ttest('can get assets using relative path', async ({ request }) => {\n\t\tconst response = await request.get('/endpoint-output/fetch-asset/relative');\n\t\texpect(response.status()).toBe(200);\n\t\texpect(response.headers()['content-type']).toBe('text/plain');\n\t\texpect(await response.text()).toBe('Cos sie konczy, cos zaczyna');\n\t});\n});\n\ntest.describe('Errors', () => {\n\ttest('invalid route response is handled', async ({ request }) => {\n\t\tconst response = await request.get('/errors/invalid-route-response');\n\n\t\texpect(/** @type {import('@playwright/test').APIResponse} */ (response).status()).toBe(500);\n\t\texpect(await response.text()).toMatch(\n\t\t\t'Invalid response from route /errors/invalid-route-response: handler should return a Response object'\n\t\t);\n\t});\n\n\ttest('unhandled http method', async ({ request }) => {\n\t\tconst response = await request.put('/errors/invalid-route-response');\n\n\t\texpect(response.status()).toBe(405);\n\t\texpect(await response.text()).toMatch('PUT method not allowed');\n\t});\n\n\ttest('error evaluating module', async ({ request }) => {\n\t\tconst response = await request.get('/errors/init-error-endpoint');\n\n\t\texpect(response.status()).toBe(500);\n\t\texpect(await response.text()).toMatch('thisvariableisnotdefined is not defined');\n\t});\n\n\ttest('returns 400 when accessing a malformed URI', async ({ page }) => {\n\t\tconst response = await page.goto('/%c0%ae%c0%ae/etc/passwd');\n\t\tif (process.env.DEV) {\n\t\t\t// Vite will return a 500 error code\n\t\t\t// We mostly want to make sure malformed requests don't bring down the whole server\n\t\t\texpect(/** @type {Response} */ (response).status()).toBeGreaterThanOrEqual(400);\n\t\t} else {\n\t\t\texpect(/** @type {Response} */ (response).status()).toBe(400);\n\t\t}\n\t});\n\n\ttest('stack traces are not fixed twice', async ({ page }) => {\n\t\tawait page.goto('/errors/stack-trace');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Cannot read properties of undefined (reading \\'toUpperCase\\') (500 Internal Error)\"'\n\t\t);\n\n\t\t// check the stack wasn't mutated\n\t\tawait page.goto('/errors/stack-trace');\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Cannot read properties of undefined (reading \\'toUpperCase\\') (500 Internal Error)\"'\n\t\t);\n\t});\n\n\ttest('error(...) in endpoint', async ({ request, read_errors }) => {\n\t\t// HTML\n\t\t{\n\t\t\tconst res = await request.get('/errors/endpoint-throw-error', {\n\t\t\t\theaders: {\n\t\t\t\t\taccept: 'text/html'\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst error = read_errors('/errors/endpoint-throw-error');\n\t\t\texpect(error).toBe(undefined);\n\n\t\t\texpect(res.status()).toBe(401);\n\t\t\texpect(await res.text()).toContain(\n\t\t\t\t'This is the static error page with the following message: You shall not pass'\n\t\t\t);\n\t\t}\n\n\t\t// JSON (default)\n\t\t{\n\t\t\tconst res = await request.get('/errors/endpoint-throw-error');\n\n\t\t\tconst error = read_errors('/errors/endpoint-throw-error');\n\t\t\texpect(error).toBe(undefined);\n\n\t\t\texpect(res.status()).toBe(401);\n\t\t\texpect(await res.json()).toEqual({\n\t\t\t\tmessage: 'You shall not pass'\n\t\t\t});\n\t\t}\n\t});\n\n\ttest('redirect(...) in endpoint', async ({ page, read_errors }) => {\n\t\tconst res = await page.goto('/errors/endpoint-throw-redirect');\n\t\texpect(res?.status()).toBe(200); // redirects are opaque to the browser\n\n\t\tconst error = read_errors('/errors/endpoint-throw-redirect');\n\t\texpect(error).toBe(undefined);\n\n\t\texpect(await page.textContent('h1')).toBe('the answer is 42');\n\t});\n\n\ttest('POST to missing page endpoint', async ({ request }) => {\n\t\tconst res = await request.post('/errors/missing-actions', {\n\t\t\theaders: {\n\t\t\t\taccept: 'text/html'\n\t\t\t}\n\t\t});\n\t\texpect(res?.status()).toBe(405);\n\n\t\tconst res_json = await request.post('/errors/missing-actions', {\n\t\t\theaders: {\n\t\t\t\taccept: 'application/json'\n\t\t\t}\n\t\t});\n\t\texpect(res_json?.status()).toBe(405);\n\t\texpect(await res_json.json()).toEqual({\n\t\t\ttype: 'error',\n\t\t\terror: {\n\t\t\t\tmessage: process.env.DEV\n\t\t\t\t\t? 'POST method not allowed. No form actions exist for the page at /errors/missing-actions (405 Method Not Allowed)'\n\t\t\t\t\t: 'POST method not allowed. No form actions exist for this page (405 Method Not Allowed)'\n\t\t\t}\n\t\t});\n\t});\n\n\ttest('error thrown in handle results in a rendered error page or JSON response', async ({\n\t\trequest\n\t}) => {\n\t\t// HTML\n\t\t{\n\t\t\tconst res = await request.get('/errors/error-in-handle', {\n\t\t\t\theaders: {\n\t\t\t\t\taccept: 'text/html'\n\t\t\t\t}\n\t\t\t});\n\n\t\t\texpect(res.status()).toBe(500);\n\t\t\texpect(await res.text()).toContain(\n\t\t\t\t'This is the static error page with the following message: Error in handle'\n\t\t\t);\n\t\t}\n\n\t\t// JSON (default)\n\t\t{\n\t\t\tconst res = await request.get('/errors/error-in-handle');\n\n\t\t\tconst error = await res.json();\n\n\t\t\texpect(error.stack).toBe(undefined);\n\t\t\texpect(res.status()).toBe(500);\n\t\t\texpect(error).toEqual({\n\t\t\t\tmessage: 'Error in handle (500 Internal Error)'\n\t\t\t});\n\t\t}\n\t});\n\n\ttest('expected error thrown in handle results in a rendered error page or JSON response', async ({\n\t\trequest\n\t}) => {\n\t\t// HTML\n\t\t{\n\t\t\tconst res = await request.get('/errors/expected-error-in-handle', {\n\t\t\t\theaders: {\n\t\t\t\t\taccept: 'text/html'\n\t\t\t\t}\n\t\t\t});\n\n\t\t\texpect(res.status()).toBe(500);\n\t\t\texpect(await res.text()).toContain(\n\t\t\t\t'This is the static error page with the following message: Expected error in handle'\n\t\t\t);\n\t\t}\n\n\t\t// JSON (default)\n\t\t{\n\t\t\tconst res = await request.get('/errors/expected-error-in-handle');\n\n\t\t\tconst error = await res.json();\n\n\t\t\texpect(error.stack).toBe(undefined);\n\t\t\texpect(res.status()).toBe(500);\n\t\t\texpect(error).toEqual({\n\t\t\t\tmessage: 'Expected error in handle'\n\t\t\t});\n\t\t}\n\t});\n\n\ttest('error thrown from load on the server respects page options when rendering the error page', async ({\n\t\trequest\n\t}) => {\n\t\tconst res = await request.get('/errors/load-error-page-options/csr');\n\t\texpect(res.status()).toBe(500);\n\t\tconst content = await res.text();\n\t\texpect(content).toContain('Crashing now');\n\t\t// the hydration script should not be present if the csr page option is respected\n\t\texpect(content).not.toContain('kit.start(app');\n\t});\n});\n\ntest.describe('Load', () => {\n\ttest('fetching a non-existent resource in root layout fails without hanging', async ({\n\t\trequest\n\t}) => {\n\t\tconst response = await request.get('/errors/error-in-layout');\n\t\texpect(await response.text()).toContain('Error: 404');\n\t});\n\n\ttest('fetch does not load a file with a # character', async ({ request }) => {\n\t\tconst response = await request.get('/load/static-file-with-hash');\n\t\texpect(await response.text()).toContain('status: 404');\n\t});\n\n\ttest('fetch reads universal load assets on the server', async ({ page }) => {\n\t\tawait page.goto('/load/fetch-asset');\n\t\tawait expect(page.locator('p')).toHaveText('1');\n\t});\n\n\ttest('includes origin header on non-GET internal request', async ({ page, baseURL }) => {\n\t\tawait page.goto('/load/fetch-origin-internal');\n\t\texpect(await page.textContent('h1')).toBe(`origin: ${new URL(baseURL).origin}`);\n\t});\n\n\ttest('includes origin header on external request', async ({ page, baseURL, start_server }) => {\n\t\tconst { port } = await start_server((req, res) => {\n\t\t\tif (req.url === '/') {\n\t\t\t\tres.writeHead(200, {\n\t\t\t\t\t'content-type': 'application/json',\n\t\t\t\t\t'access-control-allow-origin': '*'\n\t\t\t\t});\n\n\t\t\t\tres.end(JSON.stringify({ origin: req.headers.origin }));\n\t\t\t} else {\n\t\t\t\tres.writeHead(404);\n\t\t\t\tres.end('not found');\n\t\t\t}\n\t\t});\n\n\t\tawait page.goto(`/load/fetch-origin-external?port=${port}`);\n\t\texpect(await page.textContent('h1')).toBe(`origin: ${new URL(baseURL).origin}`);\n\t});\n\n\ttest('does not run when using invalid request methods', async ({ request }) => {\n\t\tconst load_url = '/load';\n\n\t\tlet response = await request.fetch(load_url, {\n\t\t\tmethod: 'OPTIONS'\n\t\t});\n\n\t\texpect(response.status()).toBe(204);\n\t\texpect(await response.text()).toBe('');\n\t\texpect(response.headers()['allow']).toBe('GET, HEAD, OPTIONS');\n\n\t\tconst actions_url = '/actions/enhance';\n\t\tresponse = await request.fetch(actions_url, {\n\t\t\tmethod: 'OPTIONS'\n\t\t});\n\n\t\texpect(response.status()).toBe(204);\n\t\texpect(await response.text()).toBe('');\n\t\texpect(response.headers()['allow']).toBe('GET, HEAD, OPTIONS, POST');\n\t});\n\n\ttest('allows logging URL search params', async ({ page }) => {\n\t\tawait page.goto('/load/server-log-search-param');\n\n\t\texpect(await page.textContent('p')).toBe('hello world');\n\t});\n});\n\ntest.describe('Routing', () => {\n\ttest('event.params are available in handle', async ({ request }) => {\n\t\tconst response = await request.get('/routing/params-in-handle/banana');\n\t\texpect(await response.json()).toStrictEqual({\n\t\t\tkey: '/routing/params-in-handle/[x]',\n\t\t\tparams: { x: 'banana' }\n\t\t});\n\t});\n\n\ttest('/favicon.ico is a valid route', async ({ request }) => {\n\t\tconst response = await request.get('/favicon.ico');\n\t\texpect(response.status()).toBe(200);\n\n\t\tconst data = await response.json();\n\t\texpect(data).toEqual({ surprise: 'lol' });\n\t});\n\n\ttest('Vite trailing slash redirect for prerendered pages retains URL query string', async ({\n\t\trequest\n\t}) => {\n\t\tif (process.env.DEV) return;\n\n\t\tlet response = await request.get('/routing/prerendered/trailing-slash/always?a=1');\n\t\texpect(new URL(response.url()).search).toBe('?a=1');\n\n\t\tresponse = await request.get('/routing/prerendered/trailing-slash/never/?a=1');\n\t\texpect(new URL(response.url()).search).toBe('?a=1');\n\n\t\tresponse = await request.get('/routing/prerendered/trailing-slash/ignore/?a=1');\n\t\texpect(new URL(response.url()).search).toBe('?a=1');\n\t});\n});\n\ntest.describe('Shadowed pages', () => {\n\ttest('Action can return undefined', async ({ baseURL, request }) => {\n\t\tconst response = await request.post('/shadowed/simple/post', {\n\t\t\tform: {},\n\t\t\theaders: {\n\t\t\t\taccept: 'application/json',\n\t\t\t\torigin: new URL(baseURL).origin\n\t\t\t}\n\t\t});\n\n\t\texpect(response.status()).toBe(200);\n\t\texpect(await response.json()).toEqual({ data: '-1', type: 'success', status: 204 });\n\t});\n});\n\ntest.describe('Static files', () => {\n\ttest('static files', async ({ request }) => {\n\t\tlet response = await request.get('/static.json');\n\t\texpect(await response.json()).toBe('static file');\n\n\t\tresponse = await request.get('/subdirectory/static.json');\n\t\texpect(await response.json()).toBe('subdirectory file');\n\n\t\texpect(response.headers()['access-control-allow-origin']).toBe('*');\n\n\t\tresponse = await request.get('/favicon.ico');\n\t\texpect(response.status()).toBe(200);\n\t});\n\n\ttest('does not use Vite to serve contents of static directory', async ({ request }) => {\n\t\tconst response = await request.get('/static/static.json');\n\t\texpect(response.status()).toBe(process.env.DEV ? 403 : 404);\n\t});\n\n\ttest('Vite serves assets in allowed directories', async ({ page, request }) => {\n\t\tawait page.goto('/asset-import');\n\t\tconst path = await page.getAttribute('img[alt=potatoes]', 'src');\n\t\tif (!path) throw new Error('Could not determine path');\n\n\t\tconst r1 = await request.get(path);\n\t\texpect(r1.status()).toBe(200);\n\t\texpect(await r1.text()).toBeTruthy();\n\n\t\t// check that we can fetch a route which overlaps with the name of a file\n\t\tconst r2 = await request.get('/package.json');\n\t\texpect(r2.status()).toBe(200);\n\t\texpect(await r2.json()).toEqual({ works: true });\n\t});\n\n\tif (process.platform !== 'win32') {\n\t\ttest('Serves symlinked asset', async ({ request }) => {\n\t\t\tconst response = await request.get('/symlink-from/hello.txt');\n\t\t\texpect(response.status()).toBe(200);\n\t\t\texpect(await response.text()).toBe('hello');\n\t\t});\n\t}\n});\n\ntest.describe('setHeaders', () => {\n\ttest('allows multiple set-cookie headers with different values', async ({ page }) => {\n\t\tconst response = await page.goto('/headers/set-cookie/sub');\n\t\tconst cookies = response ? (await response.allHeaders())['set-cookie'] : '';\n\n\t\texpect(cookies).toMatch('cookie1=value1');\n\t\texpect(cookies).toMatch('cookie2=value2');\n\t});\n});\n\ntest.describe('cookies', () => {\n\ttest('cookie.serialize created correct cookie header string', async ({ page }) => {\n\t\tconst response = await page.goto('/cookies/serialize');\n\t\tconst cookies = response ? await response.headerValue('set-cookie') : '';\n\n\t\texpect(cookies).toMatch('before=before');\n\t\texpect(cookies).toMatch('after=after');\n\t\texpect(cookies).toMatch('endpoint=endpoint');\n\t});\n});\n\ntest.describe('Miscellaneous', () => {\n\ttest('does not serve version.json with an immutable cache header', async ({ request }) => {\n\t\t// this isn't actually a great test, because caching behaviour is down to adapters.\n\t\t// but it's better than nothing\n\t\tconst response = await request.get('/_app/version.json');\n\t\tconst headers = response.headers();\n\t\texpect(headers['cache-control'] || '').not.toContain('immutable');\n\t});\n\n\ttest('handles responses with immutable headers', async ({ request }) => {\n\t\tconst response = await request.get('/immutable-headers');\n\t\texpect(response.status()).toBe(200);\n\t\texpect(await response.text()).toBe('foo');\n\t});\n\n\ttest('serves prerendered non-latin pages', async ({ request }) => {\n\t\tconst response = await request.get('/prerendering/中文');\n\t\texpect(response.status()).toBe(200);\n\t});\n});\n\ntest.describe('reroute', () => {\n\ttest('Apply reroute when directly accessing a page', async ({ page }) => {\n\t\tawait page.goto('/reroute/basic/a');\n\t\texpect(await page.textContent('h1')).toContain(\n\t\t\t'Successfully rewritten, URL should still show a: /reroute/basic/a'\n\t\t);\n\t});\n\n\ttest('Apply async reroute when directly accessing a page', async ({ page }) => {\n\t\tpage\n\t\t\t.context()\n\t\t\t.addCookies([{ name: 'reroute-cookie', value: 'yes', path: '/', domain: 'localhost' }]);\n\t\tawait page.goto('/reroute/async/a');\n\t\texpect(await page.textContent('h1')).toContain(\n\t\t\t'Successfully rewritten, URL should still show a: /reroute/async/a'\n\t\t);\n\t});\n\n\ttest('Apply async prerendered reroute when directly accessing a page', async ({ page }) => {\n\t\tawait page.goto('/reroute/async/c');\n\t\texpect(await page.textContent('h1')).toContain(\n\t\t\t'Successfully rewritten, URL should still show a: /reroute/async/c'\n\t\t);\n\t});\n\n\ttest('Apply reroute to prerendered page when directly accessing a page', async ({ page }) => {\n\t\tawait page.goto('/reroute/prerendered/to-destination');\n\t\texpect(await page.textContent('h1')).toContain('reroute that points to prerendered page works');\n\t});\n\n\ttest('Returns a 500 response if reroute throws an error on the server', async ({ page }) => {\n\t\tconst response = await page.goto('/reroute/error-handling/server-error');\n\t\texpect(response?.status()).toBe(500);\n\t});\n});\n\ntest.describe('init', () => {\n\ttest('init server hook is called once before the load function', async ({ page }) => {\n\t\tawait page.goto('/init-hooks');\n\t\tawait expect(page.locator('p')).toHaveText('1');\n\t\tawait page.reload();\n\t\tawait expect(page.locator('p')).toHaveText('1');\n\t});\n});\n\ntest.describe('getRequestEvent', () => {\n\ttest('getRequestEvent works in server endpoints', async ({ request }) => {\n\t\tconst response = await request.get('/get-request-event/endpoint');\n\t\texpect(await response.text()).toBe('hello from hooks.server.js');\n\t});\n});\n\ntest.describe('$app/forms', () => {\n\ttest('deserialize works on the server', async ({ request }) => {\n\t\tconst response = await request.get('/serialization-form-non-enhanced/server-deserialize');\n\t\texpect(await response.json()).toEqual({ data: 'It works!' });\n\t});\n});\n\nconst root = path.resolve(fileURLToPath(import.meta.url), '..', '..');\n\ntest.describe('$app/environment', () => {\n\ttest('treeshakes dev check', async () => {\n\t\ttest.skip(!!process.env.DEV, 'skip when in dev mode');\n\n\t\tconst code = fs.readFileSync(\n\t\t\tpath.join(root, '.svelte-kit/output/server/entries/pages/treeshaking/dev/_page.svelte.js'),\n\t\t\t'utf-8'\n\t\t);\n\t\texpect(code).not.toContain('not prod');\n\t});\n\n\ttest('treeshakes browser check', async () => {\n\t\ttest.skip(!!process.env.DEV, 'skip when in dev mode');\n\n\t\tconst code = fs.readFileSync(\n\t\t\tpath.join(\n\t\t\t\troot,\n\t\t\t\t'.svelte-kit/output/server/entries/pages/treeshaking/browser/_page.svelte.js'\n\t\t\t),\n\t\t\t'utf-8'\n\t\t);\n\t\texpect(code).not.toMatch('client');\n\t});\n});\n\ntest.describe('tracing', () => {\n\t// Helper function to find the resolve.root span deep in the handle.child chain\n\t/**\n\t * @param {import('../../../types.js').SpanTree} span\n\t * @returns {import('../../../types.js').SpanTree | null}\n\t */\n\tfunction find_resolve_root_span(span) {\n\t\tif (span.name === 'sveltekit.resolve') {\n\t\t\treturn span;\n\t\t}\n\t\tfor (const child of span.children || []) {\n\t\t\tconst found = find_resolve_root_span(child);\n\t\t\tif (found) return found;\n\t\t}\n\t\treturn null;\n\t}\n\n\tfunction rand() {\n\t\t// node 18 doesn't have crypto.randomUUID() and we run tests in node 18\n\t\treturn Math.random().toString(36).substring(2, 15);\n\t}\n\n\ttest('correct spans are created for a regular navigation', async ({ page, read_traces }) => {\n\t\tconst test_id = rand();\n\t\tawait page.goto(`/tracing/one/two/three/four/five?test_id=${test_id}`);\n\t\tconst traces = read_traces(test_id);\n\t\texpect(traces.length).toBeGreaterThan(0);\n\n\t\tconst trace = traces[0];\n\t\tconst trace_id = trace.trace_id;\n\n\t\t// Verify root span structure\n\t\texpect(trace).toEqual({\n\t\t\tname: 'sveltekit.handle.root',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/one/two/three/[...four]',\n\t\t\t\t'http.method': 'GET',\n\t\t\t\t'http.url': expect.stringContaining(`/tracing/one/two/three/four/five?test_id=${test_id}`),\n\t\t\t\t'sveltekit.is_data_request': false,\n\t\t\t\t'sveltekit.is_sub_request': false,\n\t\t\t\ttest_id\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tchildren: expect.arrayContaining([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: 'sveltekit.handle.sequenced.set_tracing_test_id',\n\t\t\t\t\tattributes: {}\n\t\t\t\t})\n\t\t\t])\n\t\t});\n\n\t\t// Find and verify the resolve.root span\n\t\tconst resolve_root_span = find_resolve_root_span(trace);\n\t\texpect(resolve_root_span).not.toBeNull();\n\t\texpect(resolve_root_span).toEqual({\n\t\t\tname: 'sveltekit.resolve',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/one/two/three/[...four]',\n\t\t\t\t'http.response.status_code': 200,\n\t\t\t\t'http.response.body.size': expect.stringMatching(/^\\d+$/)\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tparent_span_id: expect.any(String),\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tname: 'sveltekit.load',\n\t\t\t\t\tstatus: { code: 0 },\n\t\t\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t'sveltekit.load.node_id': 'src/routes/+layout.server.js',\n\t\t\t\t\t\t'sveltekit.load.node_type': '+layout.server',\n\t\t\t\t\t\t'sveltekit.load.environment': 'server',\n\t\t\t\t\t\t'http.route': '/tracing/one/two/three/[...four]'\n\t\t\t\t\t},\n\t\t\t\t\tlinks: [],\n\t\t\t\t\ttrace_id,\n\t\t\t\t\tspan_id: expect.any(String),\n\t\t\t\t\tparent_span_id: expect.any(String),\n\t\t\t\t\tchildren: []\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'sveltekit.load',\n\t\t\t\t\tstatus: { code: 0 },\n\t\t\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t'sveltekit.load.node_id': 'src/routes/+layout.js',\n\t\t\t\t\t\t'sveltekit.load.node_type': '+layout',\n\t\t\t\t\t\t'sveltekit.load.environment': 'server',\n\t\t\t\t\t\t'http.route': '/tracing/one/two/three/[...four]'\n\t\t\t\t\t},\n\t\t\t\t\tlinks: [],\n\t\t\t\t\ttrace_id,\n\t\t\t\t\tspan_id: expect.any(String),\n\t\t\t\t\tparent_span_id: expect.any(String),\n\t\t\t\t\tchildren: []\n\t\t\t\t}\n\t\t\t]\n\t\t});\n\t});\n\n\ttest('correct spans are created for HttpError', async ({ page, read_traces }) => {\n\t\tconst test_id = rand();\n\t\tconst response = await page.goto(`/tracing/http-error?test_id=${test_id}`);\n\t\texpect(response?.status()).toBe(500);\n\n\t\tconst traces = read_traces(test_id);\n\t\tconst trace_id = traces[0].trace_id;\n\t\tconst trace = traces[0];\n\n\t\t// Verify root span structure\n\t\texpect(trace).toEqual({\n\t\t\tname: 'sveltekit.handle.root',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/http-error',\n\t\t\t\t'http.method': 'GET',\n\t\t\t\t'http.url': expect.stringContaining(`/tracing/http-error?test_id=${test_id}`),\n\t\t\t\t'sveltekit.is_data_request': false,\n\t\t\t\t'sveltekit.is_sub_request': false,\n\t\t\t\ttest_id\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tchildren: expect.arrayContaining([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: 'sveltekit.handle.sequenced.set_tracing_test_id',\n\t\t\t\t\tattributes: {}\n\t\t\t\t})\n\t\t\t])\n\t\t});\n\n\t\t// Find and verify the resolve.root span\n\t\tconst resolve_root_span = find_resolve_root_span(trace);\n\t\texpect(resolve_root_span).not.toBeNull();\n\t\texpect(resolve_root_span).toEqual({\n\t\t\tname: 'sveltekit.resolve',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/http-error',\n\t\t\t\t'http.response.status_code': 500,\n\t\t\t\t'http.response.body.size': expect.stringMatching(/^\\d+$/)\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tparent_span_id: expect.any(String),\n\t\t\tchildren: expect.arrayContaining([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: 'sveltekit.load',\n\t\t\t\t\tstatus: { code: 2, message: 'Internal server error from tracing test' },\n\t\t\t\t\tattributes: expect.objectContaining({\n\t\t\t\t\t\t'sveltekit.load.node_id': 'src/routes/tracing/http-error/+page.server.js',\n\t\t\t\t\t\t'sveltekit.load.result.type': 'known_error',\n\t\t\t\t\t\t'sveltekit.load.result.status': 500,\n\t\t\t\t\t\t'sveltekit.load.result.message': 'Internal server error from tracing test'\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t])\n\t\t});\n\t});\n\n\ttest('correct spans are created for Redirect', async ({ page, read_traces }) => {\n\t\tconst test_id = rand();\n\t\tconst response = await page.goto(`/tracing/redirect?test_id=${test_id}`);\n\t\texpect(response?.status()).toBe(200);\n\n\t\tconst traces = read_traces(test_id);\n\t\texpect(traces).toHaveLength(2);\n\t\tconst redirect_trace_id = traces[0].trace_id;\n\t\tconst destination_trace_id = traces[1].trace_id;\n\n\t\tconst redirect_trace = traces[0];\n\t\tconst destination_trace = traces[1];\n\n\t\t// Verify redirect trace root span structure\n\t\texpect(redirect_trace).toEqual({\n\t\t\tname: 'sveltekit.handle.root',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/redirect',\n\t\t\t\t'http.method': 'GET',\n\t\t\t\t'http.url': expect.stringContaining(`/tracing/redirect?test_id=${test_id}`),\n\t\t\t\t'sveltekit.is_data_request': false,\n\t\t\t\t'sveltekit.is_sub_request': false,\n\t\t\t\ttest_id\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id: redirect_trace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tchildren: expect.arrayContaining([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: 'sveltekit.handle.sequenced.set_tracing_test_id',\n\t\t\t\t\tattributes: {}\n\t\t\t\t})\n\t\t\t])\n\t\t});\n\n\t\t// Find and verify the redirect resolve.root span\n\t\tconst redirect_resolve_root_span = find_resolve_root_span(redirect_trace);\n\t\texpect(redirect_resolve_root_span).not.toBeNull();\n\t\texpect(redirect_resolve_root_span).toEqual({\n\t\t\tname: 'sveltekit.resolve',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/redirect',\n\t\t\t\t'http.response.status_code': 307,\n\t\t\t\t'http.response.body.size': expect.stringMatching(/^\\d+$|^unknown$/)\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id: redirect_trace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tparent_span_id: expect.any(String),\n\t\t\tchildren: expect.arrayContaining([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: 'sveltekit.load',\n\t\t\t\t\tstatus: { code: 0 },\n\t\t\t\t\tattributes: expect.objectContaining({\n\t\t\t\t\t\t'sveltekit.load.node_id': 'src/routes/tracing/redirect/+page.server.js',\n\t\t\t\t\t\t'sveltekit.load.result.type': 'redirect',\n\t\t\t\t\t\t'sveltekit.load.result.status': 307,\n\t\t\t\t\t\t'sveltekit.load.result.location': `/tracing/one/two/three/four/five?test_id=${test_id}`\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t])\n\t\t});\n\n\t\t// Verify destination trace root span structure\n\t\texpect(destination_trace).toEqual({\n\t\t\tname: 'sveltekit.handle.root',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/one/two/three/[...four]',\n\t\t\t\t'http.method': 'GET',\n\t\t\t\t'http.url': expect.stringContaining(`/tracing/one/two/three/four/five?test_id=${test_id}`),\n\t\t\t\t'sveltekit.is_data_request': false,\n\t\t\t\t'sveltekit.is_sub_request': false,\n\t\t\t\ttest_id\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id: destination_trace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tchildren: expect.arrayContaining([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: 'sveltekit.handle.sequenced.set_tracing_test_id',\n\t\t\t\t\tattributes: {}\n\t\t\t\t})\n\t\t\t])\n\t\t});\n\n\t\t// Find and verify the destination resolve.root span\n\t\tconst destination_resolve_root_span = find_resolve_root_span(destination_trace);\n\t\texpect(destination_resolve_root_span).not.toBeNull();\n\t\texpect(destination_resolve_root_span).toEqual({\n\t\t\tname: 'sveltekit.resolve',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/one/two/three/[...four]',\n\t\t\t\t'http.response.status_code': 200,\n\t\t\t\t'http.response.body.size': expect.stringMatching(/^\\d+$/)\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id: destination_trace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tparent_span_id: expect.any(String),\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tname: 'sveltekit.load',\n\t\t\t\t\tstatus: { code: 0 },\n\t\t\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t'sveltekit.load.node_id': 'src/routes/+layout.server.js',\n\t\t\t\t\t\t'sveltekit.load.node_type': '+layout.server',\n\t\t\t\t\t\t'sveltekit.load.environment': 'server',\n\t\t\t\t\t\t'http.route': '/tracing/one/two/three/[...four]'\n\t\t\t\t\t},\n\t\t\t\t\tlinks: [],\n\t\t\t\t\ttrace_id: destination_trace_id,\n\t\t\t\t\tspan_id: expect.any(String),\n\t\t\t\t\tparent_span_id: expect.any(String),\n\t\t\t\t\tchildren: []\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'sveltekit.load',\n\t\t\t\t\tstatus: { code: 0 },\n\t\t\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t'sveltekit.load.node_id': 'src/routes/+layout.js',\n\t\t\t\t\t\t'sveltekit.load.node_type': '+layout',\n\t\t\t\t\t\t'sveltekit.load.environment': 'server',\n\t\t\t\t\t\t'http.route': '/tracing/one/two/three/[...four]'\n\t\t\t\t\t},\n\t\t\t\t\tlinks: [],\n\t\t\t\t\ttrace_id: destination_trace_id,\n\t\t\t\t\tspan_id: expect.any(String),\n\t\t\t\t\tparent_span_id: expect.any(String),\n\t\t\t\t\tchildren: []\n\t\t\t\t}\n\t\t\t]\n\t\t});\n\t});\n\n\ttest('correct spans are created for regular Error', async ({ page, read_traces }) => {\n\t\tconst test_id = rand();\n\t\tconst response = await page.goto(`/tracing/regular-error?test_id=${test_id}`);\n\t\texpect(response?.status()).toBe(500);\n\n\t\tconst traces = read_traces(test_id);\n\t\tconst trace_id = traces[0].trace_id;\n\t\tconst trace = traces[0];\n\n\t\t// Verify root span structure\n\t\texpect(trace).toEqual({\n\t\t\tname: 'sveltekit.handle.root',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/regular-error',\n\t\t\t\t'http.method': 'GET',\n\t\t\t\t'http.url': expect.stringContaining(`/tracing/regular-error?test_id=${test_id}`),\n\t\t\t\t'sveltekit.is_data_request': false,\n\t\t\t\t'sveltekit.is_sub_request': false,\n\t\t\t\ttest_id\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tchildren: expect.arrayContaining([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: 'sveltekit.handle.sequenced.set_tracing_test_id',\n\t\t\t\t\tattributes: {}\n\t\t\t\t})\n\t\t\t])\n\t\t});\n\n\t\t// Find and verify the resolve.root span\n\t\tconst resolve_root_span = find_resolve_root_span(trace);\n\t\texpect(resolve_root_span).not.toBeNull();\n\t\texpect(resolve_root_span).toEqual({\n\t\t\tname: 'sveltekit.resolve',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/regular-error',\n\t\t\t\t'http.response.status_code': 500,\n\t\t\t\t'http.response.body.size': expect.stringMatching(/^\\d+$/)\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tparent_span_id: expect.any(String),\n\t\t\tchildren: expect.arrayContaining([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: 'sveltekit.load',\n\t\t\t\t\tstatus: { code: 2, message: 'Regular error from tracing test' },\n\t\t\t\t\tattributes: expect.objectContaining({\n\t\t\t\t\t\t'sveltekit.load.node_id': 'src/routes/tracing/regular-error/+page.server.js',\n\t\t\t\t\t\t'sveltekit.load.result.type': 'unknown_error'\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t])\n\t\t});\n\t});\n\n\ttest('correct spans are created for non-error object', async ({ page, read_traces }) => {\n\t\tconst test_id = rand();\n\t\tconst response = await page.goto(`/tracing/non-error-object?test_id=${test_id}`);\n\t\texpect(response?.status()).toBe(500);\n\n\t\tconst traces = read_traces(test_id);\n\t\tconst trace_id = traces[0].trace_id;\n\t\tconst trace = traces[0];\n\n\t\t// Verify root span structure\n\t\texpect(trace).toEqual({\n\t\t\tname: 'sveltekit.handle.root',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/non-error-object',\n\t\t\t\t'http.method': 'GET',\n\t\t\t\t'http.url': expect.stringContaining(`/tracing/non-error-object?test_id=${test_id}`),\n\t\t\t\t'sveltekit.is_data_request': false,\n\t\t\t\t'sveltekit.is_sub_request': false,\n\t\t\t\ttest_id\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tchildren: expect.arrayContaining([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: 'sveltekit.handle.sequenced.set_tracing_test_id',\n\t\t\t\t\tattributes: {}\n\t\t\t\t})\n\t\t\t])\n\t\t});\n\n\t\t// Find and verify the resolve.root span\n\t\tconst resolve_root_span = find_resolve_root_span(trace);\n\t\texpect(resolve_root_span).not.toBeNull();\n\t\texpect(resolve_root_span).toEqual({\n\t\t\tname: 'sveltekit.resolve',\n\t\t\tstatus: { code: 0 },\n\t\t\tstart_time: [expect.any(Number), expect.any(Number)],\n\t\t\tend_time: [expect.any(Number), expect.any(Number)],\n\t\t\tattributes: {\n\t\t\t\t'http.route': '/tracing/non-error-object',\n\t\t\t\t'http.response.status_code': 500,\n\t\t\t\t'http.response.body.size': expect.stringMatching(/^\\d+$/)\n\t\t\t},\n\t\t\tlinks: [],\n\t\t\ttrace_id,\n\t\t\tspan_id: expect.any(String),\n\t\t\tparent_span_id: expect.any(String),\n\t\t\tchildren: expect.arrayContaining([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: 'sveltekit.load',\n\t\t\t\t\tstatus: { code: 2 },\n\t\t\t\t\tattributes: expect.objectContaining({\n\t\t\t\t\t\t'sveltekit.load.node_id': 'src/routes/tracing/non-error-object/+page.server.js',\n\t\t\t\t\t\t'sveltekit.load.result.type': 'unknown_error'\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t])\n\t\t});\n\t});\n});\n\ntest.describe('asset preload', () => {\n\tif (!process.env.DEV) {\n\t\ttest('injects Link headers', async ({ request }) => {\n\t\t\tconst response = await request.get('/asset-preload');\n\n\t\t\tconst header = response.headers()['link'];\n\n\t\t\texpect(header).toContain('rel=\"modulepreload\"');\n\t\t\texpect(header).toContain('as=\"font\"');\n\t\t});\n\n\t\ttest('does not inject Link headers on prerendered pages', async ({ request }) => {\n\t\t\tconst response = await request.get('/asset-preload/prerendered');\n\n\t\t\tconst header = response.headers()['link'];\n\t\t\texpect(header).toBeUndefined();\n\t\t});\n\n\t\ttest('injects <link> tags on prerendered pages', async ({ request }) => {\n\t\t\tconst response = await request.get('/asset-preload/prerendered');\n\n\t\t\tconst body = await response.text();\n\n\t\t\texpect(body).toContain('rel=\"modulepreload\"');\n\t\t\texpect(body).toContain('as=\"font\"');\n\t\t});\n\n\t\ttest('does not inject <link> tags on non-prerendered pages', async ({ request }) => {\n\t\t\tconst response = await request.get('/asset-preload');\n\n\t\t\tconst body = await response.text();\n\n\t\t\texpect(body).not.toContain('rel=\"modulepreload\"');\n\t\t\texpect(body).not.toContain('as=\"font\"');\n\t\t});\n\t}\n});\n\ntest.describe('Streaming', () => {\n\ttest(\"Discarded promises from server load functions don't hang SSR request\", async ({\n\t\trequest\n\t}) => {\n\t\tlet error;\n\t\ttry {\n\t\t\tawait request.get('/streaming/discarded-promise');\n\t\t} catch (e) {\n\t\t\terror = e;\n\t\t}\n\n\t\texpect(error).toBeUndefined();\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/basics/test/setup.js",
    "content": "import fs from 'node:fs';\nimport process from 'node:process';\n\nif (process.platform !== 'win32') {\n\tprocess.chdir('src/routes/routing');\n\tfs.rmSync('symlink-from', { recursive: true, force: true });\n\tfs.symlinkSync('symlink-to', 'symlink-from', 'dir');\n}\n\ntry {\n\tfs.unlinkSync('test/errors.json');\n} catch {}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/test/test.js",
    "content": "import process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.skip(() => process.env.KIT_E2E_BROWSER === 'webkit');\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe('adapter', () => {\n\ttest('populates event.platform for dynamic SSR', async ({ page }) => {\n\t\tawait page.goto('/adapter/dynamic');\n\t\tconst json = JSON.parse((await page.textContent('pre')) ?? '');\n\n\t\texpect(json).toEqual({\n\t\t\tconfig: {\n\t\t\t\tmessage: 'hello from dynamic page'\n\t\t\t},\n\t\t\tprerender: false\n\t\t});\n\t});\n\n\ttest('populates event.platform for prerendered page', async ({ page }) => {\n\t\tawait page.goto('/adapter/prerendered');\n\t\tconst json = JSON.parse((await page.textContent('pre')) ?? '');\n\n\t\texpect(json).toEqual({\n\t\t\tconfig: {\n\t\t\t\tmessage: 'hello from prerendered page'\n\t\t\t},\n\t\t\tprerender: true\n\t\t});\n\t});\n});\n\ntest.describe('Imports', () => {\n\t// https://github.com/sveltejs/kit/issues/461\n\ttest('handles static asset imports', async ({ baseURL, page }) => {\n\t\tawait page.goto('/asset-import');\n\n\t\tconst sources = await page.evaluate(() =>\n\t\t\tArray.from(document.querySelectorAll('img'), (img) => img.src)\n\t\t);\n\n\t\tif (process.env.DEV) {\n\t\t\texpect(sources).toEqual([\n\t\t\t\t`${baseURL}/src/routes/asset-import/small.png`,\n\t\t\t\t`${baseURL}/src/routes/asset-import/large.jpg`\n\t\t\t]);\n\t\t} else {\n\t\t\texpect(sources[0].startsWith('data:image/png;base64,')).toBeTruthy();\n\t\t\texpect(sources[1]).toMatch(/\\/_app\\/immutable\\/assets\\/large\\.[\\w-]+\\.jpg/);\n\t\t}\n\t});\n});\n\ntest.describe('Encoded paths', () => {\n\ttest('visits a route with non-ASCII character', async ({ page, clicknav }) => {\n\t\tawait page.goto('/encoded');\n\t\tawait clicknav('[href=\"/encoded/苗条\"]');\n\t\texpect(await page.innerHTML('h1')).toBe('static');\n\t\texpect(decodeURI(await page.innerHTML('h2'))).toBe('/encoded/苗条');\n\t\texpect(decodeURI(await page.innerHTML('h3'))).toBe('/encoded/苗条');\n\t});\n\n\ttest('visits a route with a doubly encoded space', async ({ page, clicknav }) => {\n\t\tawait page.goto('/encoded');\n\t\tawait clicknav('[href=\"/encoded/test%2520me\"]');\n\t\texpect(await page.innerHTML('h1')).toBe('dynamic');\n\t\texpect(await page.innerHTML('h2')).toBe('/encoded/test%2520me: test%20me');\n\t\texpect(await page.innerHTML('h3')).toBe('/encoded/test%2520me: test%20me');\n\t});\n\n\ttest('visits a route with a doubly encoded slash', async ({ page, clicknav }) => {\n\t\tawait page.goto('/encoded');\n\t\tawait clicknav('[href=\"/encoded/test%252fme\"]');\n\t\texpect(await page.innerHTML('h1')).toBe('dynamic');\n\t\texpect(await page.innerHTML('h2')).toBe('/encoded/test%252fme: test%2fme');\n\t\texpect(await page.innerHTML('h3')).toBe('/encoded/test%252fme: test%2fme');\n\t});\n\n\ttest('visits a route with an encoded slash', async ({ page, clicknav }) => {\n\t\tawait page.goto('/encoded');\n\t\tawait clicknav('[href=\"/encoded/AC%2fDC\"]');\n\t\texpect(await page.innerHTML('h1')).toBe('dynamic');\n\t\texpect(await page.innerHTML('h2')).toBe('/encoded/AC%2fDC: AC/DC');\n\t\texpect(await page.innerHTML('h3')).toBe('/encoded/AC%2fDC: AC/DC');\n\t});\n\n\ttest('visits a route with an encoded bracket', async ({ page, clicknav }) => {\n\t\tawait page.goto('/encoded');\n\t\tawait clicknav('[href=\"/encoded/%5b\"]');\n\t\texpect(await page.innerHTML('h1')).toBe('dynamic');\n\t\texpect(await page.innerHTML('h2')).toBe('/encoded/%5b: [');\n\t\texpect(await page.innerHTML('h3')).toBe('/encoded/%5b: [');\n\t});\n\n\ttest('visits a dynamic route with non-ASCII character', async ({ page, clicknav }) => {\n\t\tawait page.goto('/encoded');\n\t\tawait clicknav('[href=\"/encoded/土豆\"]');\n\t\texpect(await page.innerHTML('h1')).toBe('dynamic');\n\t\texpect(decodeURI(await page.innerHTML('h2'))).toBe('/encoded/土豆: 土豆');\n\t\texpect(decodeURI(await page.innerHTML('h3'))).toBe('/encoded/土豆: 土豆');\n\t});\n\n\ttest('redirects correctly with non-ASCII location', async ({ page, clicknav }) => {\n\t\tawait page.goto('/encoded');\n\n\t\tawait clicknav('[href=\"/encoded/反应\"]');\n\n\t\texpect(await page.innerHTML('h1')).toBe('static');\n\t\texpect(decodeURI(await page.innerHTML('h2'))).toBe('/encoded/苗条');\n\t\texpect(decodeURI(await page.innerHTML('h3'))).toBe('/encoded/苗条');\n\t});\n\n\ttest('redirects do not re-encode the redirect string', async ({ page, clicknav }) => {\n\t\tawait page.goto('/encoded');\n\n\t\tawait clicknav('[href=\"/encoded/redirect\"]');\n\n\t\t// check innerText instead of innerHTML because innerHTML would return the '&amp;' character reference instead of '&' character.\n\t\texpect(await page.innerText('pre')).toBe('/苗条?foo=bar&fizz=buzz');\n\t});\n\n\ttest('redirects do not re-encode the redirect string during ssr', async ({ page }) => {\n\t\tawait page.goto('/encoded/redirect');\n\n\t\t// check innerText instead of innerHTML because innerHTML would return the '&amp;' character reference instead of '&' character.\n\t\texpect(await page.innerText('pre')).toBe('/苗条?foo=bar&fizz=buzz');\n\t});\n\n\ttest('serializes JSON correctly', async ({ request }) => {\n\t\tconst response = await request.get('/encoded/endpoint');\n\t\texpect(await response.json()).toEqual({\n\t\t\tfruit: '🍎🍇🍌'\n\t\t});\n\t});\n\n\ttest('allows non-ASCII character in parameterized route segment', async ({ page, clicknav }) => {\n\t\tawait page.goto('/encoded');\n\t\tawait clicknav('[href=\"/encoded/@svelte\"]');\n\t\texpect(await page.textContent('h1')).toBe('@svelte');\n\t});\n\n\ttest('allows characters to be represented as escape sequences', async ({ page, clicknav }) => {\n\t\tawait page.goto('/encoded/escape-sequences');\n\n\t\tawait clicknav('[href=\"/encoded/escape-sequences/:-)\"]');\n\t\texpect(await page.textContent('h1')).toBe(':-)');\n\n\t\tawait clicknav('[href=\"/encoded/escape-sequences/%23\"]');\n\t\texpect(await page.textContent('h1')).toBe('#');\n\n\t\tawait clicknav('[href=\"/encoded/escape-sequences/%2F\"]');\n\t\texpect(await page.textContent('h1')).toBe('/');\n\n\t\tawait clicknav('[href=\"/encoded/escape-sequences/%3f\"]');\n\t\texpect(await page.textContent('h1')).toBe('?');\n\n\t\tawait clicknav('[href=\"/encoded/escape-sequences/%25\"]');\n\t\texpect(await page.textContent('h1')).toBe('%');\n\n\t\tawait clicknav('[href=\"/encoded/escape-sequences/<\"]');\n\t\texpect(await page.textContent('h1')).toBe('<');\n\n\t\tawait clicknav('[href=\"/encoded/escape-sequences/1<2\"]');\n\t\texpect(await page.textContent('h1')).toBe('1<2');\n\n\t\tawait clicknav('[href=\"/encoded/escape-sequences/苗\"]');\n\t\texpect(await page.textContent('h1')).toBe('苗');\n\n\t\tawait clicknav('[href=\"/encoded/escape-sequences/🤪\"]');\n\t\texpect(await page.textContent('h1')).toBe('🤪');\n\t});\n});\n\ntest.describe('$env', () => {\n\ttest('includes environment variables', async ({ page, clicknav }) => {\n\t\tawait page.goto('/env/includes');\n\n\t\texpect(await page.textContent('#static-private')).toBe(\n\t\t\t'PRIVATE_STATIC: accessible to server-side code/replaced at build time'\n\t\t);\n\t\texpect(await page.textContent('#dynamic-private')).toBe(\n\t\t\t'PRIVATE_DYNAMIC: accessible to server-side code/evaluated at run time'\n\t\t);\n\n\t\texpect(await page.textContent('#static-public')).toBe(\n\t\t\t'PUBLIC_STATIC: accessible anywhere/replaced at build time'\n\t\t);\n\t\texpect(await page.textContent('#dynamic-public')).toBe(\n\t\t\t'PUBLIC_DYNAMIC: accessible anywhere/evaluated at run time'\n\t\t);\n\n\t\tawait page.goto('/env');\n\t\tawait clicknav('[href=\"/env/includes\"]');\n\n\t\texpect(await page.textContent('#static-private')).toBe(\n\t\t\t'PRIVATE_STATIC: accessible to server-side code/replaced at build time'\n\t\t);\n\t\texpect(await page.textContent('#dynamic-private')).toBe(\n\t\t\t'PRIVATE_DYNAMIC: accessible to server-side code/evaluated at run time'\n\t\t);\n\n\t\texpect(await page.textContent('#static-public')).toBe(\n\t\t\t'PUBLIC_STATIC: accessible anywhere/replaced at build time'\n\t\t);\n\t\texpect(await page.textContent('#dynamic-public')).toBe(\n\t\t\t'PUBLIC_DYNAMIC: accessible anywhere/evaluated at run time'\n\t\t);\n\t});\n});\n\ntest.describe('Load', () => {\n\ttest('fetch in root index.svelte works', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\texpect(await page.textContent('h1')).toBe('the answer is 42');\n\t});\n\n\ttest('loads', async ({ page }) => {\n\t\tawait page.goto('/load');\n\t\texpect(await page.textContent('h1')).toBe('bar == bar?');\n\t});\n\n\ttest('GET fetches are serialized', async ({ page, javaScriptEnabled }) => {\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (r) => requests.push(r.url()));\n\n\t\tawait page.goto('/load/serialization');\n\n\t\tif (!javaScriptEnabled) {\n\t\t\t// by the time JS has run, hydration will have nuked these scripts\n\t\t\tconst script_contents = await page.innerHTML(\n\t\t\t\t'script[data-sveltekit-fetched][data-url=\"/load/serialization/fetched-from-shared.json\"]'\n\t\t\t);\n\n\t\t\tconst payload = '{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"{\\\\\"b\\\\\":2}\"}';\n\n\t\t\texpect(script_contents).toBe(payload);\n\t\t}\n\n\t\texpect(requests.some((r) => r.endsWith('/load/serialization/fetched-from-shared.json'))).toBe(\n\t\t\tfalse\n\t\t);\n\t});\n\n\ttest('Server data serialization removes empty nodes', async ({ page }) => {\n\t\tawait page.goto('/load/serialization-empty-node');\n\t\texpect(await page.textContent('h1')).toBe('42');\n\t});\n\n\ttest('POST fetches are serialized', async ({ page, javaScriptEnabled }) => {\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (r) => requests.push(r.url()));\n\n\t\tawait page.goto('/load/serialization-post');\n\n\t\texpect(await page.textContent('h1')).toBe('a: X');\n\t\texpect(await page.textContent('h2')).toBe('b: Y');\n\n\t\tif (!javaScriptEnabled) {\n\t\t\tconst payload_a = '{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"X\"}';\n\t\t\tconst payload_b = '{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"Y\"}';\n\t\t\t// by the time JS has run, hydration will have nuked these scripts\n\t\t\tconst script_contents_a = await page.innerHTML(\n\t\t\t\t'script[data-sveltekit-fetched][data-url=\"/load/serialization-post.json\"][data-hash=\"1vn6nlx\"]'\n\t\t\t);\n\t\t\tconst script_contents_b = await page.innerHTML(\n\t\t\t\t'script[data-sveltekit-fetched][data-url=\"/load/serialization-post.json\"][data-hash=\"1vn6nlw\"]'\n\t\t\t);\n\n\t\t\texpect(script_contents_a).toBe(payload_a);\n\t\t\texpect(script_contents_b).toBe(payload_b);\n\t\t}\n\n\t\texpect(requests.some((r) => r.endsWith('/load/serialization.json'))).toBe(false);\n\t});\n\n\ttest('POST fetches with Request init are serialized', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/load/serialization-post-request');\n\n\t\texpect(await page.textContent('h1')).toBe('a: X');\n\t\texpect(await page.textContent('h2')).toBe('b: Y');\n\n\t\tif (!javaScriptEnabled) {\n\t\t\tconst payload_a = '{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"X\"}';\n\t\t\tconst payload_b = '{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"Y\"}';\n\t\t\t// by the time JS has run, hydration will have nuked these scripts\n\t\t\tconst script_contents_a = await page.innerHTML(\n\t\t\t\t'script[data-sveltekit-fetched][data-url=\"/load/serialization-post.json\"][data-hash=\"1vn6nlx\"]'\n\t\t\t);\n\t\t\tconst script_contents_b = await page.innerHTML(\n\t\t\t\t'script[data-sveltekit-fetched][data-url=\"/load/serialization-post.json\"][data-hash=\"1vn6nlw\"]'\n\t\t\t);\n\n\t\t\texpect(script_contents_a).toBe(payload_a);\n\t\t\texpect(script_contents_b).toBe(payload_b);\n\t\t}\n\t});\n\n\ttest('fetches using an arraybuffer serialized with b64', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/load/fetch-arraybuffer-b64');\n\n\t\texpect(await page.textContent('.test-content')).toBe('[1,2,3,4]');\n\n\t\tif (!javaScriptEnabled) {\n\t\t\tconst payload = '{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"AQIDBA==\"}';\n\t\t\tconst post_payload =\n\t\t\t\t'{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==\"}';\n\n\t\t\tconst script_content = await page.innerHTML(\n\t\t\t\t'script[data-sveltekit-fetched][data-b64][data-url=\"/load/fetch-arraybuffer-b64/data\"]'\n\t\t\t);\n\t\t\tconst post_script_content = await page.innerHTML(\n\t\t\t\t'script[data-sveltekit-fetched][data-b64][data-url=\"/load/fetch-arraybuffer-b64/data\"][data-hash=\"16h3sp1\"]'\n\t\t\t);\n\n\t\t\texpect(script_content).toBe(payload);\n\t\t\texpect(post_script_content).toBe(post_payload);\n\t\t}\n\t});\n\n\ttest('fetches using a body stream serialized with b64', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/load/fetch-body-stream-b64');\n\n\t\texpect(await page.textContent('.test-content')).toBe('[1,2,3,4]');\n\n\t\tif (!javaScriptEnabled) {\n\t\t\tconst payload = '{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"AQIDBA==\"}';\n\t\t\tconst post_payload =\n\t\t\t\t'{\"status\":200,\"statusText\":\"\",\"headers\":{},\"body\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==\"}';\n\n\t\t\tconst script_content = await page.innerHTML(\n\t\t\t\t'script[data-sveltekit-fetched][data-b64][data-url=\"/load/fetch-body-stream-b64/data\"]'\n\t\t\t);\n\t\t\tconst post_script_content = await page.innerHTML(\n\t\t\t\t'script[data-sveltekit-fetched][data-b64][data-url=\"/load/fetch-body-stream-b64/data\"][data-hash=\"16h3sp1\"]'\n\t\t\t);\n\n\t\t\texpect(script_content).toBe(payload);\n\t\t\texpect(post_script_content).toBe(post_payload);\n\t\t}\n\t});\n\n\ttest('json string is returned', async ({ page }) => {\n\t\tawait page.goto('/load/relay');\n\t\texpect(await page.textContent('h1')).toBe('42');\n\t});\n\n\ttest('prefers static data over endpoint', async ({ page }) => {\n\t\tawait page.goto('/load/foo');\n\t\texpect(await page.textContent('h1')).toBe('static file');\n\t});\n\n\ttest('data is inherited', async ({ page, javaScriptEnabled, app }) => {\n\t\tfor (const kind of ['shared', 'server']) {\n\t\t\tawait page.goto(`/load/parent/${kind}/a/b/c`);\n\t\t\texpect(await page.textContent('h1')).toBe('message: original + new');\n\t\t\texpect(await page.textContent('pre')).toBe(\n\t\t\t\tJSON.stringify({\n\t\t\t\t\tfoo: { bar: 'Custom layout' },\n\t\t\t\t\tmessage: 'original + new',\n\t\t\t\t\tx: 'a',\n\t\t\t\t\ty: 'b edited',\n\t\t\t\t\tz: 'c'\n\t\t\t\t})\n\t\t\t);\n\n\t\t\tif (javaScriptEnabled) {\n\t\t\t\tawait app.goto(`/load/parent/${kind}/d/e/f`);\n\n\t\t\t\texpect(await page.textContent('h1')).toBe('message: original + new');\n\t\t\t\texpect(await page.textContent('pre')).toBe(\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\tfoo: { bar: 'Custom layout' },\n\t\t\t\t\t\tmessage: 'original + new',\n\t\t\t\t\t\tx: 'd',\n\t\t\t\t\t\ty: 'e edited',\n\t\t\t\t\t\tz: 'f'\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t});\n\n\ttest('fetch accepts a Request object', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load');\n\t\tawait clicknav('[href=\"/load/fetch-request\"]');\n\t\texpect(await page.textContent('h1')).toBe('the answer is 42');\n\t});\n\n\ttest('fetch resolves urls relatively to the target page', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load');\n\t\tawait clicknav('[href=\"/load/fetch-relative\"]');\n\t\texpect(await page.textContent('h1')).toBe('the answer is 42');\n\t\texpect(await page.textContent('h2')).toBe('the question was ?');\n\t});\n\n\ttest('handles large responses', async ({ page }) => {\n\t\tawait page.goto('/load');\n\n\t\tawait page.goto('/load/large-response');\n\t\texpect(await page.textContent('h1')).toBe('text.length is 5000000');\n\t});\n\n\ttest('handles external api', async ({ page, start_server }) => {\n\t\t/** @type {string[]} */\n\t\tconst requested_urls = [];\n\n\t\tconst { port } = await start_server(async (req, res) => {\n\t\t\trequested_urls.push(/** @type {string} */ (req.url));\n\n\t\t\tif (req.url === '/server-fetch-request-modified.json') {\n\t\t\t\tres.writeHead(200, {\n\t\t\t\t\t'Access-Control-Allow-Origin': '*',\n\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t});\n\n\t\t\t\tres.end(JSON.stringify({ answer: 42 }));\n\t\t\t} else {\n\t\t\t\tres.statusCode = 404;\n\t\t\t\tres.end('not found');\n\t\t\t}\n\t\t});\n\n\t\tawait page.goto(`/load/server-fetch-request?port=${port}`);\n\n\t\texpect(requested_urls).toEqual(['/server-fetch-request-modified.json']);\n\t\texpect(await page.textContent('h1')).toBe('the answer is 42');\n\t});\n\n\ttest('makes credentialed fetches to endpoints by default', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tif (javaScriptEnabled) return;\n\t\tawait page.goto('/load');\n\t\tawait clicknav('[href=\"/load/fetch-credentialed\"]');\n\t\texpect(await page.textContent('h1')).toBe('Hello SvelteKit!');\n\t});\n\n\ttest('includes correct page request headers', async ({\n\t\tbaseURL,\n\t\tpage,\n\t\tclicknav,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tawait page.goto('/load');\n\t\tawait clicknav('[href=\"/load/fetch-request-headers\"]');\n\n\t\tconst json = /** @type {string} */ (await page.textContent('pre'));\n\t\tconst headers = JSON.parse(json);\n\n\t\tif (javaScriptEnabled) {\n\t\t\texpect(headers).toEqual({\n\t\t\t\taccept: '*/*',\n\t\t\t\t'accept-language': 'en-US',\n\t\t\t\t// the referer will be the previous page in the client-side\n\t\t\t\t// navigation case\n\t\t\t\treferer: `${baseURL}/load`,\n\t\t\t\t// these headers aren't particularly useful, but they allow us to verify\n\t\t\t\t// that page headers are being forwarded\n\t\t\t\t'sec-fetch-dest': 'empty',\n\t\t\t\t'sec-fetch-mode': 'cors',\n\t\t\t\tconnection: 'keep-alive'\n\t\t\t});\n\t\t} else {\n\t\t\texpect(headers).toEqual({\n\t\t\t\taccept: '*/*',\n\t\t\t\t'accept-language': 'en-US'\n\t\t\t});\n\t\t}\n\t});\n\n\ttest('exposes rawBody as a DataView to endpoints', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/raw-body');\n\t\tawait clicknav('[href=\"/load/raw-body/dataview\"]');\n\n\t\texpect(await page.innerHTML('.parsed')).toBe('{\"oddly\":{\"formatted\":\"json\"}}');\n\t\texpect(await page.innerHTML('.raw')).toBe('{ \"oddly\" : { \"formatted\" : \"json\" } }');\n\t});\n\n\ttest('exposes rawBody as a string to endpoints', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/raw-body');\n\t\tawait clicknav('[href=\"/load/raw-body/string\"]');\n\n\t\texpect(await page.innerHTML('.parsed')).toBe('{\"oddly\":{\"formatted\":\"json\"}}');\n\t\texpect(await page.innerHTML('.raw')).toBe('{ \"oddly\" : { \"formatted\" : \"json\" } }');\n\t});\n\n\ttest('exposes rawBody as a Uint8Array to endpoints', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/raw-body');\n\t\tawait clicknav('[href=\"/load/raw-body/uint8array\"]');\n\n\t\texpect(await page.innerHTML('.parsed')).toBe('{\"oddly\":{\"formatted\":\"json\"}}');\n\t\texpect(await page.innerHTML('.raw')).toBe('{ \"oddly\" : { \"formatted\" : \"json\" } }');\n\t});\n\n\ttest('server-side fetch respects set-cookie header', async ({ page, context }) => {\n\t\tawait context.clearCookies();\n\n\t\tawait page.goto('/load/set-cookie-fetch');\n\t\texpect(await page.textContent('h1')).toBe('the answer is 42');\n\n\t\t/** @type {Record<string,string>} */\n\t\tconst cookies = {};\n\t\tfor (const cookie of await context.cookies()) {\n\t\t\tcookies[cookie.name] = cookie.value;\n\t\t}\n\n\t\texpect(cookies.answer).toBe('42');\n\t\texpect(cookies.doubled).toBe('84');\n\t});\n\n\ttest('CSS for dynamically imported components is reflected in server render', async ({\n\t\tpage,\n\t\tget_computed_style\n\t}) => {\n\t\tawait page.goto('/load/dynamic-import-styles');\n\n\t\texpect(await get_computed_style('#thing', 'color')).toBe('rgb(255, 0, 0)');\n\t});\n\n\ttest('page without load has access to layout data', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/accumulated');\n\n\t\tawait clicknav('[href=\"/load/accumulated/without-page-data\"]');\n\t\texpect(await page.textContent('h1')).toBe('foo.bar: Custom layout');\n\t});\n\n\ttest('page with load has access to layout data', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/accumulated');\n\n\t\tawait clicknav('[href=\"/load/accumulated/with-page-data\"]');\n\t\texpect(await page.textContent('h1')).toBe('foo.bar: Custom layout');\n\t\texpect(await page.textContent('h2')).toBe('pagedata: pagedata');\n\t});\n\n\ttest('Serializes non-JSON data', async ({ page, clicknav }) => {\n\t\tawait page.goto('/load/devalue');\n\t\tawait clicknav('[href=\"/load/devalue/regex\"]');\n\n\t\texpect(await page.textContent('h1')).toBe('true');\n\t});\n\n\ttest('Prerendered +server.js called from a non-prerendered +page.server.js works', async ({\n\t\tpage,\n\t\tapp,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.goto('/');\n\t\t\tawait app.goto('/prerendering/prerendered-endpoint/page');\n\t\t} else {\n\t\t\tawait page.goto('/prerendering/prerendered-endpoint/page');\n\t\t}\n\n\t\texpect(await page.textContent('h1')).toBe(\n\t\t\t'Im prerendered and called from a non-prerendered +page.server.js'\n\t\t);\n\t});\n\n\ttest('Prerendered +server.js called from a non-prerendered handle hook works', async ({\n\t\tclicknav,\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.goto('/prerendering/prerendered-endpoint');\n\t\t\tawait clicknav('a[href=\"/prerendering/prerendered-endpoint/from-handle-hook\"]');\n\t\t} else {\n\t\t\tawait page.goto('/prerendering/prerendered-endpoint/from-handle-hook');\n\t\t}\n\n\t\texpect(await page.textContent('html')).toBe(\n\t\t\t'{\"message\":\"Im prerendered and called from a non-prerendered +page.server.js\"}'\n\t\t);\n\t});\n\n\ttest('Logging page.url during prerendering works', async ({ page }) => {\n\t\tawait page.goto('/prerendering/log-url');\n\n\t\texpect(await page.textContent('p')).toBe('error: false');\n\t});\n\n\ttest('404 and root layout load fetch to prerendered endpoint works', async ({ page }) => {\n\t\tawait page.goto('/non-existent-route');\n\n\t\texpect(await page.textContent('h1')).toBe('404');\n\n\t\tawait page.goto('/non-existent-route-loop');\n\n\t\texpect(await page.textContent('h1')).toBe('404');\n\t});\n\n\ttest('AbortSignal works with internal fetch optimization', async ({ page }) => {\n\t\tawait page.goto('/load/fetch-abort-signal');\n\n\t\texpect(await page.textContent('.aborted-immediately')).toBe('Aborted immediately: true');\n\t\texpect(await page.textContent('.aborted-during-request')).toBe('Aborted during request: true');\n\t\texpect(await page.textContent('.successful-data')).toContain('\"message\":\"success\"');\n\t});\n\n\ttest('event.fetch handles response without body', async ({ page }) => {\n\t\tawait page.goto('/load/fetch-no-body');\n\t\texpect(await page.textContent('h1')).toBe('ok: true');\n\t});\n});\n\ntest.describe('Nested layouts', () => {\n\ttest('renders a nested layout', async ({ page }) => {\n\t\tawait page.goto('/nested-layout');\n\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.textContent('p')).toBe('This is a nested layout component');\n\t\texpect(await page.textContent('h1')).toBe('Hello from inside the nested layout component');\n\t});\n\n\ttest('renders errors in the right layout', async ({ page }) => {\n\t\tawait page.goto('/nested-layout/error');\n\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.$('p#nested')).toBeNull();\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Error\"'\n\t\t);\n\t\texpect(await page.textContent('h1')).toBe('500');\n\t});\n\n\ttest('renders errors in the right layout after client navigation', async ({ page, clicknav }) => {\n\t\tawait page.goto('/nested-layout/');\n\t\tawait clicknav('[href=\"/nested-layout/error\"]');\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.$('p#nested')).toBe(null);\n\t\texpect(await page.textContent('#message')).toBe(\n\t\t\t'This is your custom error page saying: \"Error\"'\n\t\t);\n\t\texpect(await page.textContent('h1')).toBe('500');\n\t});\n\n\ttest('renders deeply-nested errors in the right layout', async ({ page }) => {\n\t\tawait page.goto('/nested-layout/foo/bar/nope');\n\t\texpect(await page.textContent('footer')).toBe('Custom layout');\n\t\texpect(await page.$('p#nested')).not.toBeNull();\n\t\texpect(await page.$('p#nested-foo')).not.toBeNull();\n\t\texpect(await page.$('p#nested-bar')).not.toBeNull();\n\t\texpect(await page.textContent('#nested-error-message')).toBe(\n\t\t\t'error.message: nope (500 Internal Error)'\n\t\t);\n\t});\n\n\ttest('resets layout', async ({ page }) => {\n\t\tawait page.goto('/nested-layout/reset');\n\n\t\texpect(await page.textContent('h1')).toBe('Layout reset');\n\t\texpect(await page.textContent('h2')).toBe('Hello');\n\t\texpect(await page.$('#nested')).toBeNull();\n\t});\n\n\ttest('renders the closest error page', async ({ page, clicknav }) => {\n\t\tawait page.goto('/errors/nested-error-page');\n\n\t\tawait clicknav('[href=\"/errors/nested-error-page/nope\"]');\n\n\t\texpect(await page.textContent('h1')).toBe('Nested error page');\n\t\texpect(await page.textContent('#nested-error-status')).toBe('status: 500');\n\t\texpect(await page.textContent('#nested-error-message')).toBe(\n\t\t\t'error.message: nope (500 Internal Error)'\n\t\t);\n\t});\n});\n\ntest.describe('Page options', () => {\n\ttest('does not include <script> or <link rel=\"modulepreload\"> with csr=false', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tif (!javaScriptEnabled) {\n\t\t\tawait page.goto('/no-csr');\n\t\t\texpect(await page.textContent('h1')).toBe('look ma no javascript');\n\t\t\texpect(await page.$$('link[rel=\"modulepreload\"]')).toHaveLength(0);\n\n\t\t\t// ensure data wasn't inlined\n\t\t\texpect(await page.$$('script[sveltekit\\\\:data-type=\"data\"]')).toHaveLength(0);\n\t\t}\n\t});\n\n\ttest('does not SSR page with ssr=false', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/no-ssr');\n\n\t\tif (javaScriptEnabled) {\n\t\t\texpect(await page.textContent('h1')).toBe('content was rendered');\n\t\t} else {\n\t\t\texpect(await page.$('h1')).toBeNull();\n\t\t\texpect(await page.$('style[data-sveltekit]')).toBeNull();\n\t\t}\n\t});\n\n\ttest('does not SSR error page for 404s with ssr=false', async ({ request }) => {\n\t\tconst html = await request.get('/no-ssr/missing');\n\t\texpect(await html.text()).not.toContain('load function was called erroneously');\n\t});\n\n\t// TODO move this test somewhere more suitable\n\ttest('transformPageChunk can change the html output', async ({ page }) => {\n\t\tawait page.goto('/transform-page-chunk');\n\t\texpect(await page.getAttribute('meta[name=\"transform-page\"]', 'content')).toBe('Worked!');\n\t});\n\n\ttest('prerenders page that uses browser globals with ssr=false', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\ttest.skip(!!process.env.DEV, 'skip when in dev mode');\n\t\ttest.skip(!javaScriptEnabled, 'skip when JavaScript is disabled');\n\t\tawait page.goto('/prerendering/no-ssr');\n\t\tawait expect(page.getByText('Hello world!')).toBeVisible();\n\t});\n});\n\ntest.describe('$app/environment', () => {\n\ttest('includes version', async ({ page }) => {\n\t\tawait page.goto('/app-environment');\n\t\texpect(await page.textContent('h1')).toBe('TEST_VERSION');\n\t});\n});\n\ntest.describe('$app/paths', () => {\n\ttest('includes paths', async ({ page, javaScriptEnabled }) => {\n\t\ttest.skip(\n\t\t\tprocess.env.SVELTE_ASYNC === 'true',\n\t\t\t'does not work with async, should use new functions instead'\n\t\t);\n\t\tawait page.goto('/paths');\n\n\t\tlet base = javaScriptEnabled ? '' : '.';\n\t\texpect(await page.innerHTML('pre')).toBe(JSON.stringify({ base, assets: base }));\n\n\t\tawait page.goto('/paths/deeply/nested');\n\n\t\tbase = javaScriptEnabled ? '' : '../..';\n\t\texpect(await page.innerHTML('pre')).toBe(JSON.stringify({ base, assets: base }));\n\t});\n\n\t// some browsers will re-request assets after a `pushState`\n\t// https://github.com/sveltejs/kit/issues/3748#issuecomment-1125980897\n\ttest('replaces %sveltekit.assets% in template with relative path, and makes it absolute in the client', async ({\n\t\tbaseURL,\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\ttest.skip(\n\t\t\tprocess.env.SVELTE_ASYNC === 'true',\n\t\t\t'does not work with async, should use new functions instead'\n\t\t);\n\t\tconst absolute = `${baseURL}/favicon.png`;\n\n\t\tawait page.goto('/');\n\t\texpect(await page.getAttribute('link[rel=icon]', 'href')).toBe(\n\t\t\tjavaScriptEnabled ? absolute : './favicon.png'\n\t\t);\n\n\t\tawait page.goto('/routing');\n\t\texpect(await page.getAttribute('link[rel=icon]', 'href')).toBe(\n\t\t\tjavaScriptEnabled ? absolute : './favicon.png'\n\t\t);\n\n\t\tawait page.goto('/routing/rest/foo/bar/baz');\n\t\texpect(await page.getAttribute('link[rel=icon]', 'href')).toBe(\n\t\t\tjavaScriptEnabled ? absolute : '../../../../favicon.png'\n\t\t);\n\t});\n\n\ttest('match() returns route id and params for matching routes', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tawait page.goto('/match');\n\n\t\tconst samples = [\n\t\t\t{ path: '/match/load/foo', expected: { id: '/match/load/foo', params: {} } },\n\t\t\t{\n\t\t\t\tpath: '/match/slug/test-slug',\n\t\t\t\texpected: { id: '/match/slug/[slug]', params: { slug: 'test-slug' } }\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: '/match/slug/test-slug?from=query',\n\t\t\t\texpected: { id: '/match/slug/[slug]', params: { slug: 'test-slug' } }\n\t\t\t},\n\t\t\t{ path: '/match/not-a-real-route-that-exists', expected: null },\n\t\t\t{ path: '/reroute/basic/a', expected: { id: '/reroute/basic/b', params: {} } }\n\t\t];\n\n\t\tfor (const { path, expected } of samples) {\n\t\t\tconst results = javaScriptEnabled\n\t\t\t\t? page.locator('#client-results')\n\t\t\t\t: page.locator('#server-results');\n\t\t\tawait expect(results.locator(`[data-path=\"${path}\"]`)).toHaveText(JSON.stringify(expected));\n\t\t}\n\t});\n});\n\n// TODO SvelteKit 3: remove these tests\ntest.describe('$app/stores', () => {\n\ttest('can access page.url', async ({ baseURL, page }) => {\n\t\tawait page.goto('/origin');\n\t\texpect(await page.textContent('h1')).toBe(baseURL);\n\t});\n\n\ttest('page store contains data', async ({ page, clicknav }) => {\n\t\tawait page.goto('/store/data/www');\n\n\t\tconst foo = { bar: 'Custom layout' };\n\n\t\texpect(await page.textContent('#store-data')).toBe(\n\t\t\tJSON.stringify({ foo, name: 'SvelteKit', value: 456, page: 'www' })\n\t\t);\n\n\t\tawait clicknav('a[href=\"/store/data/zzz\"]');\n\t\texpect(await page.textContent('#store-data')).toBe(\n\t\t\tJSON.stringify({ foo, name: 'SvelteKit', value: 456, page: 'zzz' })\n\t\t);\n\n\t\tawait clicknav('a[href=\"/store/data/xxx\"]');\n\t\texpect(await page.textContent('#store-data')).toBe(\n\t\t\tJSON.stringify({ foo, name: 'SvelteKit', value: 123 })\n\t\t);\n\t\texpect(await page.textContent('#store-error')).toBe('Params = xxx');\n\n\t\tawait clicknav('a[href=\"/store/data/yyy\"]');\n\t\texpect(await page.textContent('#store-data')).toBe(\n\t\t\tJSON.stringify({ foo, name: 'SvelteKit', value: 123 })\n\t\t);\n\t\texpect(await page.textContent('#store-error')).toBe('Params = yyy');\n\t});\n\n\ttest('should load data after reloading by goto', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tawait page.goto('/store/data/foo?reset=true');\n\t\tconst stuff1 = { foo: { bar: 'Custom layout' }, name: 'SvelteKit', value: 123 };\n\t\tconst stuff2 = { ...stuff1, foo: true, number: 2 };\n\t\tconst stuff3 = { ...stuff2 };\n\t\tawait page.goto('/store/data/www');\n\n\t\tawait clicknav('a[href=\"/store/data/foo\"]');\n\t\texpect(JSON.parse((await page.textContent('#store-data')) ?? '')).toEqual(stuff1);\n\n\t\tawait clicknav('#reload-button');\n\t\texpect(JSON.parse((await page.textContent('#store-data')) ?? '')).toEqual(\n\t\t\tjavaScriptEnabled ? stuff2 : stuff1\n\t\t);\n\n\t\tawait clicknav('a[href=\"/store/data/zzz\"]');\n\t\tawait clicknav('a[href=\"/store/data/foo\"]');\n\t\texpect(JSON.parse((await page.textContent('#store-data')) ?? '')).toEqual(stuff3);\n\t});\n\n\ttest('navigating store contains from, to and type', async ({ app, page, javaScriptEnabled }) => {\n\t\tawait page.goto('/store/navigating/a');\n\n\t\texpect(await page.textContent('#nav-status')).toBe('not currently navigating');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait app.preloadCode('/store/navigating/b');\n\n\t\t\tconst res = await Promise.all([\n\t\t\t\tpage.click('a[href=\"/store/navigating/b\"]'),\n\t\t\t\tpage.textContent('#navigating')\n\t\t\t]);\n\n\t\t\texpect(res[1]).toBe('navigating from /store/navigating/a to /store/navigating/b (link)');\n\n\t\t\tawait page.waitForSelector('#not-navigating');\n\t\t\texpect(await page.textContent('#nav-status')).toBe('not currently navigating');\n\n\t\t\tawait Promise.all([\n\t\t\t\texpect(page.locator('#navigating')).toHaveText(\n\t\t\t\t\t'navigating from /store/navigating/b to /store/navigating/a (popstate)'\n\t\t\t\t),\n\t\t\t\tpage.goBack()\n\t\t\t]);\n\t\t}\n\t});\n\n\ttest('navigating store clears after aborted navigation', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/store/navigating/a');\n\n\t\texpect(await page.textContent('#nav-status')).toBe('not currently navigating');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.click('a[href=\"/store/navigating/c\"]');\n\t\t\tawait page.waitForTimeout(100); // gross, but necessary since no navigation occurs\n\t\t\tawait page.click('a[href=\"/store/navigating/a\"]');\n\n\t\t\tawait page.waitForSelector('#not-navigating', { timeout: 5000 });\n\t\t\texpect(await page.textContent('#nav-status')).toBe('not currently navigating');\n\t\t}\n\t});\n\n\ttest('should update page store when URL hash is changed through the address bar', async ({\n\t\tbaseURL,\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tconst href = `${baseURL}/store/data/zzz`;\n\t\tawait page.goto(href);\n\n\t\texpect(await page.textContent('#url-hash')).toBe('');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tfor (const urlHash of ['#1', '#2', '#5', '#8']) {\n\t\t\t\tawait page.evaluate(\n\t\t\t\t\t({ href, urlHash }) => {\n\t\t\t\t\t\tlocation.href = `${href}${urlHash}`;\n\t\t\t\t\t},\n\t\t\t\t\t{ href, urlHash }\n\t\t\t\t);\n\n\t\t\t\texpect(await page.textContent('#url-hash')).toBe(urlHash);\n\t\t\t}\n\t\t}\n\t});\n});\n\ntest.describe('$app/state', () => {\n\ttest('can access page.url', async ({ baseURL, page }) => {\n\t\tawait page.goto('/origin');\n\t\texpect(await page.textContent('h1')).toBe(baseURL);\n\t});\n\n\ttest('page state contains data', async ({ page, clicknav }) => {\n\t\tawait page.goto('/state/data/www');\n\n\t\tconst foo = { bar: 'Custom layout' };\n\n\t\texpect(await page.textContent('#state-data')).toBe(\n\t\t\tJSON.stringify({ foo, name: 'SvelteKit', value: 456, page: 'www' })\n\t\t);\n\n\t\tawait clicknav('a[href=\"/state/data/zzz\"]');\n\t\texpect(await page.textContent('#state-data')).toBe(\n\t\t\tJSON.stringify({ foo, name: 'SvelteKit', value: 456, page: 'zzz' })\n\t\t);\n\n\t\tawait clicknav('a[href=\"/state/data/xxx\"]');\n\t\texpect(await page.textContent('#state-data')).toBe(\n\t\t\tJSON.stringify({ foo, name: 'SvelteKit', value: 123 })\n\t\t);\n\t\texpect(await page.textContent('#state-error')).toBe('Params = xxx');\n\n\t\tawait clicknav('a[href=\"/state/data/yyy\"]');\n\t\texpect(await page.textContent('#state-data')).toBe(\n\t\t\tJSON.stringify({ foo, name: 'SvelteKit', value: 123 })\n\t\t);\n\t\texpect(await page.textContent('#state-error')).toBe('Params = yyy');\n\t});\n\n\ttest('should load data after reloading by goto', async ({\n\t\tpage,\n\t\tclicknav,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tawait page.goto('/state/data/foo?reset=true');\n\t\tconst stuff1 = { foo: { bar: 'Custom layout' }, name: 'SvelteKit', value: 123 };\n\t\tconst stuff2 = { ...stuff1, foo: true, number: 2 };\n\t\tconst stuff3 = { ...stuff2 };\n\t\tawait page.goto('/state/data/www');\n\n\t\tawait clicknav('a[href=\"/state/data/foo\"]');\n\t\texpect(JSON.parse((await page.textContent('#state-data')) ?? '')).toEqual(stuff1);\n\n\t\tawait clicknav('#reload-button');\n\t\texpect(JSON.parse((await page.textContent('#state-data')) ?? '')).toEqual(\n\t\t\tjavaScriptEnabled ? stuff2 : stuff1\n\t\t);\n\n\t\tawait clicknav('a[href=\"/state/data/zzz\"]');\n\t\tawait clicknav('a[href=\"/state/data/foo\"]');\n\t\texpect(JSON.parse((await page.textContent('#state-data')) ?? '')).toEqual(stuff3);\n\t});\n\n\ttest('navigating state contains from, to and type', async ({ app, page, javaScriptEnabled }) => {\n\t\tawait page.goto('/state/navigating/a');\n\n\t\texpect(await page.textContent('#nav-status')).toBe('not currently navigating');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait app.preloadCode('/state/navigating/b');\n\n\t\t\tconst res = await Promise.all([\n\t\t\t\tpage.click('a[href=\"/state/navigating/b\"]'),\n\t\t\t\tpage.textContent('#navigating')\n\t\t\t]);\n\n\t\t\texpect(res[1]).toBe('navigating from /state/navigating/a to /state/navigating/b (link)');\n\n\t\t\tawait page.waitForSelector('#not-navigating');\n\t\t\texpect(await page.textContent('#nav-status')).toBe('not currently navigating');\n\n\t\t\tawait Promise.all([\n\t\t\t\texpect(page.locator('#navigating')).toHaveText(\n\t\t\t\t\t'navigating from /state/navigating/b to /state/navigating/a (popstate)'\n\t\t\t\t),\n\t\t\t\tpage.goBack()\n\t\t\t]);\n\t\t}\n\t});\n\n\ttest('navigating state clears after aborted navigation', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/state/navigating/a');\n\n\t\texpect(await page.textContent('#nav-status')).toBe('not currently navigating');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.click('a[href=\"/state/navigating/c\"]');\n\t\t\tawait page.waitForTimeout(100); // gross, but necessary since no navigation occurs\n\t\t\tawait page.click('a[href=\"/state/navigating/a\"]');\n\n\t\t\tawait page.waitForSelector('#not-navigating', { timeout: 5000 });\n\t\t\texpect(await page.textContent('#nav-status')).toBe('not currently navigating');\n\t\t}\n\t});\n\n\ttest('should update page state when URL hash is changed through the address bar', async ({\n\t\tbaseURL,\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tconst href = `${baseURL}/state/data/zzz`;\n\t\tawait page.goto(href);\n\n\t\texpect(await page.textContent('#url-hash')).toBe('');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tfor (const urlHash of ['#1', '#2', '#5', '#8']) {\n\t\t\t\tawait page.evaluate(\n\t\t\t\t\t({ href, urlHash }) => {\n\t\t\t\t\t\tlocation.href = `${href}${urlHash}`;\n\t\t\t\t\t},\n\t\t\t\t\t{ href, urlHash }\n\t\t\t\t);\n\n\t\t\t\texpect(await page.textContent('#url-hash')).toBe(urlHash);\n\t\t\t}\n\t\t}\n\t});\n});\n\ntest.describe('searchParams', () => {\n\tconst tests = [\n\t\t{\n\t\t\tdescription: 'exposes query string parameters',\n\t\t\tsearch: '?foo=1',\n\t\t\texpected: { foo: ['1'] }\n\t\t},\n\t\t{\n\t\t\tdescription: 'value-less query parameter',\n\t\t\tsearch: '?foo',\n\t\t\texpected: { foo: [''] }\n\t\t},\n\t\t{\n\t\t\tdescription: 'duplicated query parameter',\n\t\t\tsearch: '?key=one&key=two',\n\t\t\texpected: { key: ['one', 'two'] }\n\t\t},\n\t\t{\n\t\t\tdescription: 'encoded query parameter',\n\t\t\tsearch: '?key=%26a=b',\n\t\t\texpected: { key: ['&a=b'] }\n\t\t}\n\t];\n\n\ttests.forEach(({ description, search, expected }) => {\n\t\ttest(description, async ({ page }) => {\n\t\t\tawait page.goto(`/query/echo${search}`);\n\n\t\t\tconst json = JSON.stringify(expected);\n\n\t\t\texpect(await page.textContent('#one')).toBe(json);\n\t\t\texpect(await page.textContent('#two')).toBe(json);\n\t\t});\n\t});\n\n\ttest('updates page on client-side nav', async ({ page, clicknav }) => {\n\t\tawait page.goto('/query/echo?foo=1');\n\n\t\tawait clicknav('[href=\"/query/echo?bar=2\"]');\n\n\t\tconst json = JSON.stringify({ bar: ['2'] });\n\n\t\texpect(await page.textContent('#one')).toBe(json);\n\t\texpect(await page.textContent('#two')).toBe(json);\n\t});\n});\n\ntest.describe('Matchers', () => {\n\ttest('Matches parameters', async ({ page, clicknav }) => {\n\t\tawait page.goto('/routing/matched');\n\n\t\tawait clicknav('[href=\"/routing/matched/a\"]');\n\t\texpect(await page.textContent('h1')).toBe('lowercase: a');\n\n\t\tawait clicknav('[href=\"/routing/matched/B\"]');\n\t\texpect(await page.textContent('h1')).toBe('uppercase: B');\n\n\t\tawait clicknav('[href=\"/routing/matched/1\"]');\n\t\texpect(await page.textContent('h1')).toBe('number: 1');\n\n\t\tawait clicknav('[href=\"/routing/matched/everything-else\"]');\n\t\texpect(await page.textContent('h1')).toBe('fallback: everything-else');\n\t});\n});\n\ntest.describe('Actions', () => {\n\ttest(\"invalidateAll = false doesn't invalidate all\", async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/actions/invalidate-all?invalidate_all=false');\n\t\tconst preSubmitContent = await page.locator('pre').textContent();\n\t\tawait page.click('button');\n\t\t// The value that should not change is time-based and might not have the granularity to change\n\t\t// if we don't give it time to\n\t\tawait page.waitForTimeout(1000);\n\t\tconst postSubmitContent = await page.locator('pre').textContent();\n\t\tif (!javaScriptEnabled) {\n\t\t\texpect(preSubmitContent).not.toBe(postSubmitContent);\n\t\t} else {\n\t\t\texpect(preSubmitContent).toBe(postSubmitContent);\n\t\t}\n\t});\n\n\ttest('invalidateAll = true does invalidate all', async ({ page }) => {\n\t\tawait page.goto('/actions/invalidate-all?invalidate_all=true');\n\t\tconst preSubmitContent = await page.locator('pre').textContent();\n\t\tawait page.click('button');\n\t\t// The value that should not change is time-based and might not have the granularity to change\n\t\t// if we don't give it time to\n\t\tawait page.waitForTimeout(1000);\n\t\tconst postSubmitContent = await page.locator('pre').textContent();\n\t\texpect(preSubmitContent).not.toBe(postSubmitContent);\n\t});\n\n\ttest('Submitting a form with a file input but no enctype=\"multipart/form-data\" throws an error', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\ttest.skip(!javaScriptEnabled, 'Skip when JavaScript is disabled');\n\t\ttest.skip(!process.env.DEV, 'Skip when not in dev mode');\n\t\tawait page.goto('/actions/file-without-enctype');\n\t\tconst error_promise = page.waitForEvent('pageerror');\n\t\tawait page.click('button');\n\t\tconst error = await error_promise;\n\t\texpect(error.message).toBe(\n\t\t\t'Your form contains <input type=\"file\"> 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.'\n\t\t);\n\t});\n\n\ttest('Error props are returned', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/actions/form-errors');\n\t\tawait page.click('button');\n\t\texpect(await page.textContent('p.server-prop')).toBe('an error occurred');\n\t\tif (javaScriptEnabled) {\n\t\t\texpect(await page.textContent('p.client-prop')).toBe('hydrated: an error occurred');\n\t\t}\n\t});\n\n\ttest('Form fields are persisted', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/actions/form-errors-persist-fields');\n\t\tawait page.locator('input[name=\"username\"]').fill('foo');\n\t\tawait page.locator('input[name=\"password\"]').fill('bar');\n\t\tawait Promise.all([\n\t\t\tpage.waitForRequest((request) =>\n\t\t\t\trequest.url().includes('/actions/form-errors-persist-fields')\n\t\t\t),\n\t\t\tpage.click('button')\n\t\t]);\n\t\texpect(await page.inputValue('input[name=\"username\"]')).toBe('foo');\n\t\tif (javaScriptEnabled) {\n\t\t\texpect(await page.inputValue('input[name=\"password\"]')).toBe('bar');\n\t\t\texpect(await page.textContent('pre')).toBe(JSON.stringify({ username: 'foo' }));\n\t\t} else {\n\t\t\texpect(await page.inputValue('input[name=\"password\"]')).toBe('');\n\t\t}\n\t});\n\n\ttest('Success data as form-data is returned', async ({ page }) => {\n\t\tawait page.goto('/actions/success-data');\n\n\t\texpect(await page.textContent('pre')).toBe(JSON.stringify(null));\n\n\t\tawait page.locator('input[name=\"username\"]').fill('foo');\n\t\tawait page.locator('button[formenctype=\"multipart/form-data\"]').click();\n\n\t\tawait expect(page.locator('pre')).toHaveText(JSON.stringify({ result: 'foo' }));\n\t});\n\n\ttest('Success data as form-urlencoded is returned', async ({ page }) => {\n\t\tawait page.goto('/actions/success-data');\n\n\t\texpect(await page.textContent('pre')).toBe(JSON.stringify(null));\n\n\t\tawait page.locator('input[name=\"username\"]').fill('bar');\n\t\tawait page.locator('button[formenctype=\"application/x-www-form-urlencoded\"]').click();\n\n\t\tawait expect(page.locator('pre')).toHaveText(JSON.stringify({ result: 'bar' }));\n\t});\n\n\ttest('applyAction updates form prop', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/actions/update-form');\n\t\texpect(await page.textContent('pre')).toBe(JSON.stringify(null));\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.locator('button.increment-success').click();\n\t\t\tawait expect(page.locator('pre')).toHaveText(JSON.stringify({ count: 0 }));\n\n\t\t\tawait page.locator('button.increment-invalid').click();\n\t\t\tawait expect(page.locator('pre')).toHaveText(JSON.stringify({ count: 1 }));\n\t\t}\n\t});\n\n\ttest('form prop stays after invalidation and is reset on navigation', async ({\n\t\tpage,\n\t\tapp,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tawait page.goto('/actions/update-form');\n\t\texpect(await page.textContent('pre')).toBe(JSON.stringify(null));\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.locator('button.increment-success').click();\n\t\t\tawait expect(page.locator('pre')).toHaveText(JSON.stringify({ count: 0 }));\n\n\t\t\tawait page.locator('button.invalidateAll').click();\n\t\t\tawait page.waitForTimeout(500);\n\t\t\tawait expect(page.locator('pre')).toHaveText(JSON.stringify({ count: 0 }));\n\t\t\tawait app.goto('/actions/enhance');\n\t\t} else {\n\t\t\tawait page.goto('/actions/enhance');\n\t\t}\n\n\t\texpect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));\n\t});\n\n\ttest('applyAction redirects', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/actions/update-form');\n\t\texpect(await page.textContent('pre')).toBe(JSON.stringify(null));\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.locator('button.redirect').click();\n\t\t\tawait expect(page.locator('footer')).toHaveText('Custom layout');\n\t\t}\n\t});\n\n\ttest('applyAction errors', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/actions/update-form');\n\t\texpect(await page.textContent('pre')).toBe(JSON.stringify(null));\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.locator('button.error').click();\n\t\t\tawait expect(page.locator('p')).toHaveText(\n\t\t\t\t'This is your custom error page saying: \"Unexpected Form Error\"'\n\t\t\t);\n\t\t}\n\t});\n\n\ttest('use:enhance', async ({ page }) => {\n\t\tawait page.goto('/actions/enhance');\n\n\t\texpect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));\n\t\texpect(await page.textContent('pre.formdata2')).toBe(JSON.stringify(null));\n\n\t\tawait page.locator('input[name=\"username\"]').fill('foo');\n\t\tawait page.locator('button.form1').click();\n\n\t\tawait expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ result: 'foo' }));\n\t\tawait expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ result: 'foo' }));\n\t\tawait expect(page.locator('input[name=username]')).toHaveValue('');\n\t});\n\n\ttest('use:enhance abort controller', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/actions/enhance');\n\n\t\texpect(await page.textContent('span.count')).toBe('0');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait Promise.all([\n\t\t\t\tpage.waitForRequest((request) => request.url().includes('/actions/enhance')),\n\t\t\t\tpage.click('button.form2'),\n\t\t\t\tpage.click('button.form2')\n\t\t\t]);\n\t\t\tawait page.waitForTimeout(500); // to make sure locator doesn't run exactly between submission 1 and 2\n\n\t\t\tawait expect(page.locator('span.count')).toHaveText('1');\n\t\t}\n\t});\n\n\ttest('use:enhance button with formAction', async ({ page }) => {\n\t\tawait page.goto('/actions/enhance');\n\n\t\texpect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));\n\n\t\tawait page.locator('input[name=\"username\"]').fill('foo');\n\t\tawait page.locator('button.form1-register').click();\n\n\t\tawait expect(page.locator('pre.formdata1')).toHaveText(\n\t\t\tJSON.stringify({ result: 'register: foo' })\n\t\t);\n\t});\n\n\ttest('use:enhance button with formAction dialog', async ({ page }) => {\n\t\tawait page.goto('/actions/enhance');\n\n\t\tawait page.locator('button[formmethod=\"dialog\"]').click();\n\n\t\tawait expect(page.locator('button[formmethod=\"dialog\"]')).not.toBeVisible();\n\t});\n\n\ttest('use:enhance button with name', async ({ page }) => {\n\t\tawait page.goto('/actions/enhance');\n\n\t\texpect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));\n\n\t\tawait Promise.all([\n\t\t\tpage.waitForRequest((request) => request.url().includes('/actions/enhance')),\n\t\t\tpage.click('button.form1-submitter')\n\t\t]);\n\n\t\tawait expect(page.locator('pre.formdata1')).toHaveText(\n\t\t\tJSON.stringify({ result: 'submitter: foo' })\n\t\t);\n\t});\n\n\ttest('use:enhance button with formenctype', async ({ page }) => {\n\t\tawait page.goto('/actions/enhance');\n\n\t\texpect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));\n\t\texpect(await page.textContent('pre.formdata2')).toBe(JSON.stringify(null));\n\n\t\tconst fileInput = page.locator('input[type=\"file\"].form-file-input');\n\n\t\tawait fileInput.setInputFiles({\n\t\t\tname: 'test-file.txt',\n\t\t\tmimeType: 'text/plain',\n\t\t\tbuffer: Buffer.from('this is test')\n\t\t});\n\n\t\tawait page.locator('button.form-file-submit').click();\n\n\t\tawait expect(page.locator('pre.formdata1')).toHaveText(\n\t\t\tJSON.stringify({ result: 'file name:test-file.txt' })\n\t\t);\n\t\tawait expect(page.locator('pre.formdata2')).toHaveText(\n\t\t\tJSON.stringify({ result: 'file name:test-file.txt' })\n\t\t);\n\t});\n\n\ttest('use:enhance has `application/x-www-form-urlencoded` as default value for `ContentType` request header', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\ttest.skip(!javaScriptEnabled, 'skip when JavaScript is disabled');\n\n\t\tawait page.goto('/actions/enhance');\n\n\t\texpect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));\n\t\texpect(await page.textContent('pre.formdata2')).toBe(JSON.stringify(null));\n\n\t\tawait page.locator('input[name=\"username\"]').fill('foo');\n\n\t\tconst [request] = await Promise.all([\n\t\t\tpage.waitForRequest('/actions/enhance?/login'),\n\t\t\tpage.locator('button.form1').click()\n\t\t]);\n\n\t\tconst requestHeaders = await request.allHeaders();\n\n\t\texpect(requestHeaders['content-type']).toBe('application/x-www-form-urlencoded');\n\n\t\tawait expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ result: 'foo' }));\n\t\tawait expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ result: 'foo' }));\n\t\tawait expect(page.locator('input[name=\"username\"]')).toHaveValue('');\n\t});\n\n\ttest('use:enhance does not clear form on second submit', async ({ page }) => {\n\t\tawait page.goto('/actions/enhance');\n\n\t\tawait page.locator('input[name=\"message\"]').fill('hello');\n\n\t\tawait page.locator('.form3').click();\n\t\tawait expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ message: 'hello' }));\n\t\tawait expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ message: 'hello' }));\n\n\t\tawait page.locator('.form3').click();\n\t\tawait page.waitForTimeout(0); // wait for next tick\n\t\tawait expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ message: 'hello' }));\n\t\tawait expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ message: 'hello' }));\n\t});\n\n\ttest('redirect', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/actions/redirect');\n\n\t\tpage.click('button');\n\n\t\tconst [redirect] = await Promise.all([\n\t\t\tpage.waitForResponse('/actions/redirect'),\n\t\t\tpage.waitForNavigation()\n\t\t]);\n\t\tif (javaScriptEnabled) {\n\t\t\texpect(await redirect.json()).toEqual({\n\t\t\t\ttype: 'redirect',\n\t\t\t\tlocation: '/actions/enhance',\n\t\t\t\tstatus: 303\n\t\t\t});\n\t\t} else {\n\t\t\texpect(redirect.status()).toBe(303);\n\t\t\texpect(redirect.headers()['location']).toBe('/actions/enhance');\n\t\t}\n\n\t\texpect(page.url()).toContain('/actions/enhance');\n\t});\n\n\ttest('redirect in handle', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/actions/redirect-in-handle');\n\n\t\tpage.click('button');\n\n\t\tconst [redirect] = await Promise.all([\n\t\t\tpage.waitForResponse('/actions/redirect-in-handle'),\n\t\t\tpage.waitForNavigation()\n\t\t]);\n\t\tif (javaScriptEnabled) {\n\t\t\texpect(await redirect.json()).toEqual({\n\t\t\t\ttype: 'redirect',\n\t\t\t\tlocation: '/actions/enhance',\n\t\t\t\tstatus: 303\n\t\t\t});\n\t\t} else {\n\t\t\texpect(redirect.status()).toBe(303);\n\t\t\texpect(redirect.headers()['location']).toBe('/actions/enhance');\n\t\t}\n\n\t\texpect(page.url()).toContain('/actions/enhance');\n\t});\n\n\ttest('page.status reflects error status', async ({ page }) => {\n\t\tawait page.goto('/actions/enhance');\n\n\t\tawait Promise.all([\n\t\t\tpage.waitForRequest((request) => request.url().includes('/actions/enhance')),\n\t\t\tpage.click('button.form1-error')\n\t\t]);\n\n\t\tawait expect(page.locator('h1')).toHaveText('400');\n\t});\n\n\ttest('errors are rendered at the correct level', async ({ page }) => {\n\t\tawait page.goto('/actions/form-errors/adjacent-error-boundary');\n\t\tawait page.locator('button').click();\n\n\t\tawait expect(page.locator('pre')).toHaveText('something went wrong');\n\t});\n\n\ttest('submitting application/json should return http status code 415', async ({\n\t\tbaseURL,\n\t\tpage\n\t}) => {\n\t\tconst response = await page.request.fetch(`${baseURL}/actions/form-errors`, {\n\t\t\tmethod: 'POST',\n\t\t\tdata: { foo: 'bar' },\n\t\t\theaders: {\n\t\t\t\tOrigin: `${baseURL}`\n\t\t\t}\n\t\t});\n\t\tconst { type, error } = await response.json();\n\t\texpect(type).toBe('error');\n\t\texpect(error.message).toBe(\n\t\t\t'Form actions expect form-encoded data — received application/json (415 Unsupported Media Type)'\n\t\t);\n\t\texpect(response.status()).toBe(415);\n\t});\n\n\ttest('submitting to a form action that does not exists, should return http status code 404', async ({\n\t\tbaseURL,\n\t\tpage\n\t}) => {\n\t\tconst response = await page.request.fetch(`${baseURL}/actions/enhance?/doesnt-exist`, {\n\t\t\tmethod: 'POST',\n\t\t\tdata: 'irrelevant',\n\t\t\theaders: {\n\t\t\t\tOrigin: `${baseURL}`\n\t\t\t}\n\t\t});\n\t\tconst { type, error } = await response.json();\n\t\texpect(type).toBe('error');\n\t\texpect(error.message).toBe(\"No action with name 'doesnt-exist' found (404 Not Found)\");\n\t\texpect(response.status()).toBe(404);\n\t});\n});\n\n// Run in serial to not pollute the log with (correct) cookie warnings\ntest.describe.serial('Cookies API', () => {\n\t// there's a problem running these tests in the CI with webkit,\n\t// since AFAICT the browser is using http://localhost and webkit won't\n\t// set a `Secure` cookie on that. So we don't run these cross-platform\n\n\ttest('sanity check for cookies', async ({ page }) => {\n\t\tawait page.goto('/cookies');\n\t\tconst span = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('undefined');\n\t});\n\n\ttest('set a cookie', async ({ page }) => {\n\t\tawait page.goto('/cookies/set');\n\t\tconst span = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('teapot');\n\t});\n\n\ttest('delete a cookie', async ({ page }) => {\n\t\tawait page.goto('/cookies/set');\n\t\tlet span = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('teapot');\n\t\tawait page.goto('/cookies/delete');\n\t\tspan = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('undefined');\n\t});\n\n\ttest('more than one cookie can be set in one request', async ({ page }) => {\n\t\tawait page.goto('/cookies/set-more-than-one');\n\t\tconst span = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('teapot');\n\t\texpect(await span.innerText()).toContain('jane austen');\n\t});\n\n\ttest('default encoding and decoding', async ({ page }) => {\n\t\tawait page.goto('/cookies/encoding/set');\n\t\tconst span = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('teapot, jane austen');\n\t});\n\n\ttest('not decoded twice', async ({ page }) => {\n\t\tawait page.goto('/cookies/encoding/not-decoded-twice');\n\t\tconst span = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('teapot%2C%20jane%20austen');\n\t});\n\n\ttest('can be set in +layout.server.js', async ({ page }) => {\n\t\tawait page.goto('/cookies/set-in-layout');\n\t\tconst span = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('i was set in the layout load');\n\t});\n\n\ttest('works with basic enhance', async ({ page }) => {\n\t\tawait page.goto('/cookies/enhanced/basic');\n\t\tconst span = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('undefined');\n\n\t\tawait page.locator('button#teapot').click();\n\t\tawait expect(page.locator('#cookie-value')).toHaveText('teapot');\n\n\t\t// setting a different value...\n\t\tawait page.locator('button#janeAusten').click();\n\t\tawait expect(page.locator('#cookie-value')).toHaveText('Jane Austen');\n\t});\n\n\ttest('cookies can be set with a path', async ({ page }) => {\n\t\tawait page.goto('/cookies/nested/a');\n\t\tlet span = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('teapot');\n\t\tawait page.goto('/cookies/nested/b');\n\t\tspan = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('undefined');\n\t\tawait page.goto('/cookies');\n\t\tspan = page.locator('#cookie-value');\n\t\texpect(await span.innerText()).toContain('undefined');\n\t});\n});\n\ntest.describe('Serialization', () => {\n\ttest('A custom data type can be serialized/deserialized', async ({ page, clicknav }) => {\n\t\tawait page.goto('/serialization-basic');\n\t\tawait expect(page.locator('h1')).toHaveText('It works!');\n\n\t\tawait clicknav('[href=\"/serialization-basic/child\"]');\n\t\tawait expect(page.locator('h1')).toHaveText('Client-side navigation also works!');\n\t});\n\n\ttest('A custom data type can be serialized/deserialized on POST', async ({ page }) => {\n\t\tawait page.goto('/serialization-form-non-enhanced');\n\t\tawait page.click('button');\n\t\tawait expect(page.locator('h1')).toHaveText('It works!');\n\n\t\t// Test navigating to the basic page works as intended\n\t\tawait page.locator('a').first().click();\n\t\tawait expect(page.locator('h1')).toHaveText('It works!');\n\t});\n\n\ttest('A custom data type can be serialized/deserialized on POST with use:enhance', async ({\n\t\tpage\n\t}) => {\n\t\tawait page.goto('/serialization-form-enhanced');\n\t\tawait page.click('button');\n\t\tawait expect(page.locator('h1')).toHaveText('It works!');\n\n\t\t// Test navigating to the basic page works as intended\n\t\tawait page.locator('a').first().click();\n\t\tawait expect(page.locator('h1')).toHaveText('It works!');\n\t});\n\n\ttest('works with streaming', async ({ page, javaScriptEnabled }) => {\n\t\ttest.skip(!javaScriptEnabled, 'skip when JavaScript is disabled');\n\n\t\tawait page.goto('/serialization-stream');\n\t\tawait expect(page.locator('h1', { hasText: 'It works!' })).toBeVisible();\n\t});\n});\n\ntest.describe('getRequestEvent', () => {\n\ttest('getRequestEvent works in hooks, load functions and actions', async ({ page, clicknav }) => {\n\t\tawait page.goto('/get-request-event');\n\t\tawait clicknav('[href=\"/get-request-event/with-message\"]');\n\n\t\texpect(await page.textContent('h1')).toBe('hello from hooks.server.js');\n\n\t\tawait page.locator('input[name=\"message\"]').fill('hello');\n\t\tawait page.click('button');\n\n\t\texpect(await page.textContent('h1')).toBe('from form: hello');\n\n\t\tawait page.goto('/get-request-event/with-error');\n\t\texpect(await page.textContent('h1')).toBe('Crashing now (500 hello from hooks.server.js)');\n\t});\n});\n\ntest.describe('params prop', () => {\n\ttest('params prop is passed to the page', async ({ page, clicknav }) => {\n\t\tawait page.goto('/params-prop');\n\n\t\tawait clicknav('[href=\"/params-prop/123\"]');\n\t\tawait expect(page.locator('p')).toHaveText('x: 123');\n\n\t\tawait clicknav('[href=\"/params-prop/456\"]');\n\t\tawait expect(page.locator('p')).toHaveText('x: 456');\n\t});\n});\n\ntest.describe('service worker option', () => {\n\ttest('pass the options to the service worker', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tconst content = await page.content();\n\t\tconst matching = content.match(/navigator\\.serviceWorker\\.register\\(.+?, (?<options>{.+?})\\)/);\n\t\tlet options = {};\n\t\tif (matching && matching.groups) {\n\t\t\toptions = JSON.parse(matching.groups.options);\n\t\t}\n\t\tif (process.env.DEV) {\n\t\t\texpect(options).toMatchObject({\n\t\t\t\ttype: 'module',\n\t\t\t\tupdateViaCache: 'imports'\n\t\t\t});\n\t\t} else {\n\t\t\texpect(options).toMatchObject({\n\t\t\t\tupdateViaCache: 'imports'\n\t\t\t});\n\t\t}\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/basics/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"noEmit\": true,\n\t\t\"resolveJsonModule\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/basics/unit-test/client.spec.js",
    "content": "import { expect, test } from 'vitest';\n\n// some users will import these modules to mock them in Vitest so we need to test\n// that importing them works\ntest('$app/navigation can be imported', async () => {\n\tawait expect(import('$app/navigation')).resolves.not.toThrow();\n});\n"
  },
  {
    "path": "packages/kit/test/apps/basics/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { playwright } from '@vitest/browser-playwright';\nimport { defineConfig } from 'vitest/config';\n\nexport default defineConfig({\n\tbuild: {\n\t\tminify: false\n\t},\n\tclearScreen: false,\n\toptimizeDeps: {\n\t\t// for CI, we need to explicitly prebundle deps, since\n\t\t// the reload confuses Playwright\n\t\tinclude: ['cookie']\n\t},\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t},\n\ttest: {\n\t\texpect: { requireAssertions: true },\n\t\tprojects: [\n\t\t\t{\n\t\t\t\textends: './vite.config.js',\n\t\t\t\ttest: {\n\t\t\t\t\tname: 'client',\n\t\t\t\t\tbrowser: {\n\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\tprovider: playwright(),\n\t\t\t\t\t\tinstances: [{ browser: 'chromium' }],\n\t\t\t\t\t\theadless: true\n\t\t\t\t\t},\n\t\t\t\t\tinclude: ['unit-test/**/*.spec.js']\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t}\n});\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/.gitignore",
    "content": "/test/errors.json\n!/.env\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/_test_dependencies/cjs-only/index.js",
    "content": "module.exports = {\n\tcjs: () => 'cjs'\n};\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/_test_dependencies/cjs-only/package.json",
    "content": "{\n\t\"version\": \"1.0.0\",\n\t\"private\": true,\n\t\"name\": \"e2e-test-dep-cjs-only\",\n\t\"main\": \"index.js\",\n\t\"files\": [\n\t\t\"index.js\"\n\t],\n\t\"type\": \"commonjs\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/package.json",
    "content": "{\n\t\"name\": \"test-dev-only\",\n\t\"private\": true,\n\t\"version\": \"0.0.2-next.0\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"DEV=true playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"e2e-test-dep-error\": \"file:./_test_dependencies/cjs-only\",\n\t\t\"e2e-test-dep-hooks\": \"file:./_test_dependencies/cjs-only\",\n\t\t\"e2e-test-dep-hooks-client\": \"file:./_test_dependencies/cjs-only\",\n\t\t\"e2e-test-dep-layout-server\": \"file:./_test_dependencies/cjs-only\",\n\t\t\"e2e-test-dep-layout-svelte\": \"file:./_test_dependencies/cjs-only\",\n\t\t\"e2e-test-dep-layout-universal\": \"file:./_test_dependencies/cjs-only\",\n\t\t\"e2e-test-dep-page-server\": \"file:./_test_dependencies/cjs-only\",\n\t\t\"e2e-test-dep-page-svelte\": \"file:./_test_dependencies/cjs-only\",\n\t\t\"e2e-test-dep-page-universal\": \"file:./_test_dependencies/cjs-only\",\n\t\t\"e2e-test-dep-server\": \"file:./_test_dependencies/cjs-only\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<link rel=\"icon\" type=\"image/png\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"transform-page\" content=\"__REPLACEME__\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body class=\"started\">\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/hooks.client.js",
    "content": "import cjs from 'e2e-test-dep-hooks-client';\ncjs.cjs();\n\n/** @type {import(\"@sveltejs/kit\").HandleClientError} */\nexport function handleError({ message }) {\n\treturn { message };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/hooks.js",
    "content": "import cjs from 'e2e-test-dep-hooks';\ncjs.cjs();\n\n/** @type {import(\"@sveltejs/kit\").Reroute} */\nexport function reroute({ url }) {\n\treturn url.pathname;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/hooks.server.js",
    "content": "/** @type {import(\"@sveltejs/kit\").HandleServerError} */\nexport function handleError({ error }) {\n\treturn { message: /**@type{any}*/ (error).message };\n}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/lib/server/blah/private.js",
    "content": "export const should_explode = 'boom';\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/lib/test.server.js",
    "content": "export const should_explode = 'boom';\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/+error.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<pre>{page.error.message}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/+layout.svelte",
    "content": "<script>\n\timport { setup } from '../../../../setup.js';\n\n\tsetup();\n</script>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\n\tlet message = '';\n\n\tonMount(() => {\n\t\tmessage = 'hello world!';\n\t});\n</script>\n\n<p>{message}</p>\n\n<a href=\"/optimize-deps\">Go to /optimize-deps</a>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/headers/invalid/+server.js",
    "content": "/** @type {import(\"@sveltejs/kit\").RequestHandler} */\nexport function GET({ setHeaders }) {\n\tsetHeaders({\n\t\t'cache-control': 'totally-invalid',\n\t\t'content-type': 'not-a-real-type'\n\t});\n\n\treturn new Response('Testing invalid headers');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/illegal-imports/env/dynamic-private/+page.svelte",
    "content": "<script>\n\timport { env } from '$env/dynamic/private';\n</script>\n\n<p>{env.SHOULD_EXPLODE}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/illegal-imports/env/static-private/+page.svelte",
    "content": "<script>\n\timport { SHOULD_EXPLODE } from '$env/static/private';\n</script>\n\n<p>{SHOULD_EXPLODE}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/illegal-imports/server-only-folder/static-import/+page.svelte",
    "content": "<script>\n\timport { should_explode } from '$lib/server/blah/private.js';\n</script>\n\n<p>{should_explode}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/illegal-imports/server-only-modules/illegal.server.js",
    "content": "export const should_explode = 'boom';\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/illegal-imports/server-only-modules/static-import/+page.svelte",
    "content": "<script>\n\timport { should_explode } from './foo';\n</script>\n\n<p>{should_explode}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/illegal-imports/server-only-modules/static-import/foo.js",
    "content": "export { should_explode } from '../illegal.server.js';\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/illegal-imports/server-only-modules/static-import-2/+page.svelte",
    "content": "<script>\n\timport { read } from '$app/server';\n\tread;\n</script>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/optimize-deps/+error.svelte",
    "content": "<script>\n\timport cjs from 'e2e-test-dep-error';\n\tcjs.cjs();\n</script>\n\n<slot />\n\n<p>this error page uses a new dependency</p>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/optimize-deps/+layout.js",
    "content": "import cjs from 'e2e-test-dep-layout-universal';\ncjs.cjs();\n\nexport function load() {}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/optimize-deps/+layout.server.js",
    "content": "import cjs from 'e2e-test-dep-layout-server';\ncjs.cjs();\n\nexport function load() {}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/optimize-deps/+layout.svelte",
    "content": "<script>\n\timport cjs from 'e2e-test-dep-layout-svelte';\n\tcjs.cjs();\n</script>\n\n<slot />\n\n<p>this layout uses a new dependency</p>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/optimize-deps/+page.js",
    "content": "import cjs from 'e2e-test-dep-page-universal';\ncjs.cjs();\n\nexport function load() {}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/optimize-deps/+page.server.js",
    "content": "import cjs from 'e2e-test-dep-page-server';\ncjs.cjs();\n\nexport function load() {}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/optimize-deps/+page.svelte",
    "content": "<script>\n\timport cjs from 'e2e-test-dep-page-svelte';\n\tcjs.cjs();\n</script>\n\n<p>this page uses a new dependency</p>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/optimize-deps/+server.js",
    "content": "import cjs from 'e2e-test-dep-server';\ncjs.cjs();\n\nexport function GET() {\n\treturn new Response('ok');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/request-abort/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\n\tlet result;\n\n\tfunction test_abort() {\n\t\tconst controller = new AbortController();\n\t\tfetch('/request-abort', { method: 'POST', signal: controller.signal }).then((r) => r.json());\n\t\tsetTimeout(() => {\n\t\t\tcontroller.abort();\n\t\t\tfetch('/request-abort', { headers: { accept: 'application/json' } }).then(\n\t\t\t\tasync (r) => (result = await r.json())\n\t\t\t);\n\t\t}, 50);\n\t}\n\n\tonMount(test_abort);\n</script>\n\n<pre>{JSON.stringify(result)}</pre>\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/src/routes/request-abort/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nlet aborted = false;\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport function GET() {\n\treturn json({ aborted });\n}\n\n/** @type {import('@sveltejs/kit').RequestHandler} */\nexport async function POST({ request }) {\n\trequest.signal.addEventListener('abort', () => (aborted = true));\n\tawait new Promise((r) => setTimeout(r, 1000));\n\treturn json({ ok: true });\n}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/test/test.js",
    "content": "import { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.describe.serial('Illegal imports', () => {\n\ttest.skip(({ javaScriptEnabled }) => !process.env.DEV || !javaScriptEnabled);\n\n\ttest('$env/dynamic/private is not importable from the client', async ({ page }) => {\n\t\tawait page.goto('/illegal-imports/env/dynamic-private', {\n\t\t\twait_for_started: false\n\t\t});\n\t\texpect(await page.textContent('.message-body'))\n\t\t\t.toBe(`Cannot import $env/dynamic/private into code that runs in the browser, as this could leak sensitive information.\n\n src/routes/illegal-imports/env/dynamic-private/+page.svelte imports\n  $env/dynamic/private\n\nIf you're only using the import as a type, change it to \\`import type\\`.`);\n\t});\n\n\ttest('$env/static/private is not importable from the client', async ({ page }) => {\n\t\tawait page.goto('/illegal-imports/env/static-private', {\n\t\t\twait_for_started: false\n\t\t});\n\t\texpect(await page.textContent('.message-body'))\n\t\t\t.toBe(`Cannot import $env/static/private into code that runs in the browser, as this could leak sensitive information.\n\n src/routes/illegal-imports/env/static-private/+page.svelte imports\n  $env/static/private\n\nIf you're only using the import as a type, change it to \\`import type\\`.`);\n\t});\n\n\ttest('server-only module is not importable from the client', async ({ page }) => {\n\t\tawait page.goto('/illegal-imports/server-only-modules/static-import', {\n\t\t\twait_for_started: false\n\t\t});\n\t\texpect(await page.textContent('.message-body'))\n\t\t\t.toBe(`Cannot import src/routes/illegal-imports/server-only-modules/illegal.server.js into code that runs in the browser, as this could leak sensitive information.\n\n src/routes/illegal-imports/server-only-modules/static-import/+page.svelte imports\n  src/routes/illegal-imports/server-only-modules/static-import/foo.js imports\n   src/routes/illegal-imports/server-only-modules/illegal.server.js\n\nIf you're only using the import as a type, change it to \\`import type\\`.`);\n\t});\n\n\ttest('$app/server module is not importable from the client', async ({ page }) => {\n\t\tawait page.goto('/illegal-imports/server-only-modules/static-import-2', {\n\t\t\twait_for_started: false\n\t\t});\n\t\texpect(await page.textContent('.message-body'))\n\t\t\t.toBe(`Cannot import $app/server into code that runs in the browser, as this could leak sensitive information.\n\n src/routes/illegal-imports/server-only-modules/static-import-2/+page.svelte imports\n  $app/server\n\nIf you're only using the import as a type, change it to \\`import type\\`.`);\n\t});\n\n\ttest('server-only folder is not importable from the client', async ({ page }) => {\n\t\tawait page.goto('/illegal-imports/server-only-folder/static-import', {\n\t\t\twait_for_started: false\n\t\t});\n\t\texpect(await page.textContent('.message-body'))\n\t\t\t.toBe(`Cannot import $lib/server/blah/private.js into code that runs in the browser, as this could leak sensitive information.\n\n src/routes/illegal-imports/server-only-folder/static-import/+page.svelte imports\n  $lib/server/blah/private.js\n\nIf you're only using the import as a type, change it to \\`import type\\`.`);\n\t});\n});\n\ntest.describe('Vite', () => {\n\ttest.skip(({ javaScriptEnabled }) => !process.env.DEV || !javaScriptEnabled);\n\n\ttest('optimizes +page.svelte dependencies', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tawait page.getByText('hello world!').waitFor();\n\n\t\tconst manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json');\n\t\tconst manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'));\n\n\t\texpect(manifest).toHaveProperty('optimized.e2e-test-dep-page-svelte');\n\t});\n\n\ttest('optimizes +page.js dependencies', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tawait page.getByText('hello world!').waitFor();\n\n\t\tconst manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json');\n\t\tconst manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'));\n\n\t\texpect(manifest).toHaveProperty('optimized.e2e-test-dep-page-universal');\n\t});\n\n\ttest('skips optimizing +page.server.js dependencies', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tawait page.getByText('hello world!').waitFor();\n\n\t\tconst manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json');\n\t\tconst manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'));\n\n\t\texpect(manifest).not.toHaveProperty('optimized.e2e-test-dep-page-server');\n\t});\n\n\ttest('optimizes +layout.svelte dependencies', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tawait page.getByText('hello world!').waitFor();\n\n\t\tconst manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json');\n\t\tconst manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'));\n\n\t\texpect(manifest).toHaveProperty('optimized.e2e-test-dep-layout-svelte');\n\t});\n\n\ttest('optimizes +layout.js dependencies', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tawait page.getByText('hello world!').waitFor();\n\n\t\tconst manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json');\n\t\tconst manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'));\n\n\t\texpect(manifest).toHaveProperty('optimized.e2e-test-dep-layout-universal');\n\t});\n\n\ttest('skips optimizing +layout.server.js dependencies', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tawait page.getByText('hello world!').waitFor();\n\n\t\tconst manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json');\n\t\tconst manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'));\n\n\t\texpect(manifest).not.toHaveProperty('optimized.e2e-test-dep-layout-server');\n\t});\n\n\ttest('optimizes +error.svelte dependencies', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tawait page.getByText('hello world!').waitFor();\n\n\t\tconst manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json');\n\t\tconst manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'));\n\n\t\texpect(manifest).toHaveProperty('optimized.e2e-test-dep-error');\n\t});\n\n\ttest('optimizes hooks.client.js dependencies', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tawait page.getByText('hello world!').waitFor();\n\n\t\tconst manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json');\n\t\tconst manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'));\n\n\t\texpect(manifest).toHaveProperty('optimized.e2e-test-dep-hooks-client');\n\t});\n\n\ttest('optimizes hooks.js dependencies', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tawait page.getByText('hello world!').waitFor();\n\n\t\tconst manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json');\n\t\tconst manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'));\n\n\t\texpect(manifest).toHaveProperty('optimized.e2e-test-dep-hooks');\n\t});\n});\n\ntest.describe('request abort', () => {\n\ttest.skip(({ javaScriptEnabled }) => !process.env.DEV || !javaScriptEnabled);\n\n\ttest('request.signal fires abort event', async ({ page }) => {\n\t\tawait page.goto('/request-abort');\n\t\tawait page.waitForTimeout(200);\n\t\texpect(await page.innerText('pre')).toBe('{\"aborted\":true}');\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"noEmit\": true,\n\t\t\"resolveJsonModule\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/dev-only/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tclearScreen: false,\n\toptimizeDeps: {\n\t\t// for CI, we need to explicitly prebundle deps, since\n\t\t// the reload confuses Playwright\n\t\tinclude: ['cookie']\n\t},\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/embed/.gitignore",
    "content": ".custom-out-dir\n!.env"
  },
  {
    "path": "packages/kit/test/apps/embed/package.json",
    "content": "{\n\t\"name\": \"test-embed\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"pnpm test:dev && pnpm test:build\",\n\t\t\"test:dev\": \"DEV=true playwright test\",\n\t\t\"test:build\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/embed/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/kit/test/apps/embed/src/app.html",
    "content": "%sveltekit.head%\n<div>%sveltekit.body%</div>\n"
  },
  {
    "path": "packages/kit/test/apps/embed/src/routes/+layout.svelte",
    "content": "<script>\n\timport { setup } from '../../../../setup.js';\n\n\tsetup();\n</script>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/embed/src/routes/embed/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\treturn {\n\t\ta: await fetch('/embed/a').then((x) => x.text()),\n\t\tb: await fetch('/embed/b').then((x) => x.text())\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/embed/src/routes/embed/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n{@html data.a}\n{@html data.b}\n"
  },
  {
    "path": "packages/kit/test/apps/embed/src/routes/embed/a/+page.svelte",
    "content": "<script>\n\timport { browser } from '$app/environment';\n</script>\n\n<h2 data-testid=\"a\">a ({browser ? 'browser' : 'server'})</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/embed/src/routes/embed/b/+page.svelte",
    "content": "<script>\n\timport { browser } from '$app/environment';\n</script>\n\n<h2 data-testid=\"b\">b ({browser ? 'browser' : 'server'})</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/embed/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tembedded: true\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/embed/test/test.js",
    "content": "import { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe('embed', () => {\n\ttest('serves embedded components in page', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/embed');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait expect(page.getByTestId('a')).toHaveText('a (browser)');\n\t\t\tawait expect(page.getByTestId('b')).toHaveText('b (browser)');\n\t\t} else {\n\t\t\texpect(await page.textContent('[data-testid=\"a\"]')).toBe('a (server)');\n\t\t\texpect(await page.textContent('[data-testid=\"b\"]')).toBe('b (server)');\n\t\t}\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/embed/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"noEmit\": true,\n\t\t\"resolveJsonModule\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/embed/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tclearScreen: false,\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/package.json",
    "content": "{\n\t\"name\": \"test-hash-based-routing\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"pnpm test:dev && pnpm test:build\",\n\t\t\"test:dev\": \"DEV=true playwright test\",\n\t\t\"test:build\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<link rel=\"icon\" type=\"image/png\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div style=\"display: contents\">%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/hooks.js",
    "content": "export function reroute({ url }) {\n\tif (url.hash === '#/reroute-a') {\n\t\t// works with leading hash...\n\t\treturn '#/rerouted';\n\t}\n\n\tif (url.hash === '#/reroute-b') {\n\t\t// ...and without\n\t\treturn '/rerouted';\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/+layout.js",
    "content": "export function load({ params, route, url }) {\n\treturn {\n\t\tparams,\n\t\troute,\n\t\turl: new URL(url)\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/+layout.svelte",
    "content": "<script>\n\timport { goto, pushState, replaceState } from '$app/navigation';\n\timport { setup } from '../../../../setup.js';\n\n\tsetup();\n\n\tlet { children } = $props();\n</script>\n\n<a href=\"/\">/</a>\n<a href=\"/#/a\">/#/a</a>\n<a href=\"/#/b\">/#/b</a>\n<a href=\"/#/a#b\">/#/a#b</a>\n<a href=\"/#/b/123\">/#/b/123</a>\n<a href=\"/#/b/456\">/#/b/456</a>\n<a href=\"/#/reroute-a\">/#/reroute-a</a>\n<a href=\"/#/reroute-b\">/#/reroute-b</a>\n<button data-goto onclick={() => goto('/#/b')}>goto /#/b</button>\n<button data-push onclick={() => pushState('/#/b', {})}>pushState /#/b</button>\n<button data-replace onclick={() => replaceState('/#/a#b', {})}>replaceState /#/a#b</button>\n\n{@render children()}\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/+page.svelte",
    "content": "<p>home</p>\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/a/+page.svelte",
    "content": "<p>a</p>\n<div id=\"b\">a#b</div>\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/anchor/+page.svelte",
    "content": "<a href=\"#test\">go to #test</a>\n\n<p id=\"test\">#test</p>\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/b/+page.svelte",
    "content": "<p>b</p>\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/b/[slug]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\tlet { data } = $props();\n</script>\n\n<p data-data>\n\t{JSON.stringify(data.params)}\n\t{data.route.id}\n\t{data.url.pathname + data.url.search + data.url.hash}\n</p>\n\n<p data-page>\n\t{JSON.stringify(page.params)}\n\t{page.route.id}\n\t{page.url.pathname + page.url.search + page.url.hash}\n</p>\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/focus/+page.svelte",
    "content": "<a href=\"#/focus/a#p\">click me!</a>\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/focus/a/+page.svelte",
    "content": "<button>button 1</button>\n<button>button 2</button>\n<p id=\"p\">cannot be focused</p>\n<button id=\"button3\">button 3</button>\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/rerouted/+page.svelte",
    "content": "<p>rerouted</p>\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/src/routes/resolve/+page.svelte",
    "content": "<script lang=\"ts\">\n\timport { resolve } from '$app/paths';\n</script>\n\n<a href={resolve('/')}>go to home</a>\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\trouter: { type: 'hash' }\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/test/test.js",
    "content": "import { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.skip(({ javaScriptEnabled }) => !javaScriptEnabled);\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe('hash based navigation', () => {\n\ttest('server rendering is disabled', async ({ request }) => {\n\t\tconst response = await request.get('/');\n\t\tconst text = await response.text();\n\n\t\texpect(text).not.toContain('<p');\n\t});\n\n\ttest('navigation works', async ({ page }) => {\n\t\tawait page.goto('/');\n\t\tawait expect(page.locator('p')).toHaveText('home');\n\n\t\tawait page.locator('a[href=\"/#/a\"]').click();\n\t\tawait expect(page.locator('p')).toHaveText('a');\n\t\tlet url = new URL(page.url());\n\t\texpect(url.pathname).toBe('/');\n\t\texpect(url.hash).toBe('#/a');\n\n\t\tawait page.locator('button[data-goto]').click();\n\t\tawait expect(page.locator('p')).toHaveText('b');\n\t\turl = new URL(page.url());\n\t\texpect(url.pathname).toBe('/');\n\t\texpect(url.hash).toBe('#/b');\n\n\t\tawait page.locator('a[href=\"/#/a#b\"]').click();\n\t\tawait expect(page.locator('p')).toHaveText('a');\n\t\turl = new URL(page.url());\n\t\texpect(url.pathname).toBe('/');\n\t\texpect(url.hash).toBe('#/a#b');\n\n\t\tawait page.locator('button[data-push]').click();\n\t\tawait expect(page.locator('p')).toHaveText('a');\n\t\turl = new URL(page.url());\n\t\texpect(url.pathname).toBe('/');\n\t\texpect(url.hash).toBe('#/b');\n\n\t\tawait page.locator('button[data-replace]').click();\n\t\tawait expect(page.locator('p')).toHaveText('a');\n\t\turl = new URL(page.url());\n\t\texpect(url.pathname).toBe('/');\n\t\texpect(url.hash).toBe('#/a#b');\n\t});\n\n\ttest('navigates to correct page on load', async ({ page }) => {\n\t\tawait page.goto('/#/a');\n\t\tawait expect(page.locator('p')).toHaveText('a');\n\t});\n\n\ttest('navigation works with URL encoded characters', async ({ page }) => {\n\t\tawait page.goto('/?query=%23abc#/%23test');\n\t\tawait expect(page.locator('p')).toHaveText('home');\n\t\t// hashchange event\n\t\tawait page.goto('/?query=%23abc#/a%23test');\n\t\tawait expect(page.locator('p')).toHaveText('a');\n\t});\n\n\ttest('route id and params are correct', async ({ page }) => {\n\t\tawait page.goto('/#/b/123');\n\t\tawait expect(page.locator('p[data-data]')).toHaveText('{\"slug\":\"123\"} /b/[slug] /#/b/123');\n\t\tawait expect(page.locator('p[data-page]')).toHaveText('{\"slug\":\"123\"} /b/[slug] /#/b/123');\n\n\t\tawait page.goto('/');\n\t\tawait page.locator('a[href=\"/#/b/456\"]').click();\n\t\tawait expect(page.locator('p[data-data]')).toHaveText('{\"slug\":\"456\"} /b/[slug] /#/b/456');\n\t\tawait expect(page.locator('p[data-page]')).toHaveText('{\"slug\":\"456\"} /b/[slug] /#/b/456');\n\t});\n\n\ttest('reroute works', async ({ page }) => {\n\t\tawait page.goto('/');\n\n\t\tawait page.locator('a[href=\"/#/reroute-a\"]').click();\n\t\tawait expect(page.locator('p')).toHaveText('rerouted');\n\t\tlet url = new URL(page.url());\n\t\texpect(url.hash).toBe('#/reroute-a');\n\n\t\tawait page.goto('/');\n\n\t\tawait page.locator('a[href=\"/#/reroute-b\"]').click();\n\t\tawait expect(page.locator('p')).toHaveText('rerouted');\n\t\turl = new URL(page.url());\n\t\texpect(url.hash).toBe('#/reroute-b');\n\t});\n\n\ttest('relative anchor works', async ({ page }) => {\n\t\tawait page.goto('/#/anchor');\n\n\t\tawait page.locator('a[href=\"#test\"]').click();\n\t\tawait page.waitForURL('#/anchor#test');\n\t\tawait expect(page.locator('#test')).toHaveText('#test');\n\t\tconst url = new URL(page.url());\n\t\texpect(url.hash).toBe('#/anchor#test');\n\t});\n\n\ttest('navigation history works', async ({ page }) => {\n\t\tawait page.goto('/');\n\n\t\tawait page.locator('a[href=\"/#/a\"]').click();\n\t\tawait page.waitForURL('/#/a');\n\n\t\tawait page.locator('a[href=\"/#/b\"]').click();\n\t\tawait page.waitForURL('/#/b');\n\n\t\tawait page.goBack();\n\t\texpect(page.locator('p')).toHaveText('a');\n\n\t\tawait page.goForward();\n\t\texpect(page.locator('p')).toHaveText('b');\n\t});\n\n\ttest('sequential focus navigation point is set correctly', async ({ page, browserName }) => {\n\t\tconst tab = browserName === 'webkit' ? 'Alt+Tab' : 'Tab';\n\t\tawait page.goto('/#/focus');\n\t\tawait page.locator('a[href=\"#/focus/a#p\"]').click();\n\t\tawait page.waitForURL('#/focus/a#p');\n\t\texpect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BODY');\n\t\tawait page.keyboard.press(tab);\n\t\tawait expect(page.locator('#button3')).toBeFocused();\n\t\tawait expect(page.locator('button[id=\"button3\"]')).toBeFocused();\n\t});\n\n\ttest('resolve works', async ({ page }) => {\n\t\tawait page.goto('/#/resolve');\n\t\tawait page.locator('a', { hasText: 'go to home' }).click();\n\t\tawait expect(page.locator('p')).toHaveText('home');\n\t\tconst url = new URL(page.url());\n\t\texpect(url.pathname).toBe('/');\n\t\texpect(url.hash).toBe('#/');\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"noEmit\": true,\n\t\t\"resolveJsonModule\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/hash-based-routing/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tclearScreen: false,\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t},\n\toptimizeDeps: {\n\t\texclude: ['svelte']\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/package.json",
    "content": "{\n\t\"name\": \"test-no-ssr\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"pnpm test:dev && pnpm test:build\",\n\t\t\"test:dev\": \"DEV=true playwright test\",\n\t\t\"test:build\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<link rel=\"icon\" type=\"image/png\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div style=\"display: contents\">%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/src/routes/+layout.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport const ssr = false;\n\nexport const load = ({ url }) => {\n\tif (url.pathname === '/redirect') {\n\t\tredirect(302, '/');\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/src/routes/+layout.server.js",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/no-ssr/src/routes/+layout.svelte",
    "content": "<script>\n\timport { setup } from '../../../../setup.js';\n\n\tsetup();\n</script>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/src/routes/+page.svelte",
    "content": "<h1>home</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/src/routes/browser-globals/+page.js",
    "content": "// `document` is only available in the browser and should cause the test to fail\n// if this file is imported on the server\nconst pathname = document.location.pathname;\n\nexport function load() {\n\treturn {\n\t\tpathname\n\t};\n}\n\nexport const ssr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/src/routes/browser-globals/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p>pathname: {data.pathname}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/test/test.js",
    "content": "import { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\ntest.skip(({ javaScriptEnabled }) => !javaScriptEnabled);\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest('navigating to a non-existent route renders the default error page', async ({ page }) => {\n\tawait page.goto('/non-existent-route');\n\texpect(await page.textContent('h1')).toBe('404');\n});\n\ntest('navigating to a non-existent route redirects if redirect in the root layout', async ({\n\tpage\n}) => {\n\tawait page.goto('/redirect');\n\texpect(await page.textContent('h1')).toBe('home');\n});\n\ntest('universal pages/layouts are not executed on the server', async ({ page }) => {\n\tawait page.goto('/browser-globals');\n\tawait expect(page.locator('p')).toHaveText('pathname: /browser-globals');\n});\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"noEmit\": true,\n\t\t\"resolveJsonModule\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/no-ssr/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tclearScreen: false,\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/options/.gitignore",
    "content": ".custom-out-dir\n!.env"
  },
  {
    "path": "packages/kit/test/apps/options/env-dir/.env",
    "content": "GO_AWAY_PLEASE=and thank you\nTOP_SECRET_SHH_PLS=shhhh\nMATCHES_NEITHER=should be discarded"
  },
  {
    "path": "packages/kit/test/apps/options/package.json",
    "content": "{\n\t\"name\": \"test-options\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev -c vite.custom.config.js\",\n\t\t\"build\": \"vite build -c vite.custom.config.js --mode custom\",\n\t\t\"preview\": \"vite preview -c vite.custom.config.js\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"pnpm test:dev && pnpm test:build\",\n\t\t\"test:dev\": \"DEV=true playwright test && DEV=true PATHS_ASSETS=https://cdn.example.com/stuff playwright test\",\n\t\t\"test:build\": \"playwright test && PATHS_ASSETS=https://cdn.example.com/stuff playwright test\",\n\t\t\"test:server-side-route-resolution:dev\": \"rm -rf test/errors.json && DEV=true ROUTER_RESOLUTION=server playwright test\",\n\t\t\"test:server-side-route-resolution:build\": \"rm -rf test/errors.json && ROUTER_RESOLUTION=server playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@fontsource/libre-barcode-128-text\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/playwright.config.js",
    "content": "import process from 'node:process';\nimport { config } from '../../utils.js';\nimport { defineConfig } from '@playwright/test';\n\nexport default defineConfig({\n\t...config,\n\twebServer: {\n\t\t...config.webServer,\n\t\tcommand: process.env.DEV ? `pnpm dev` : `pnpm build && pnpm preview`,\n\t\tenv: {\n\t\t\tROUTER_RESOLUTION: process.env.ROUTER_RESOLUTION ?? 'client',\n\t\t\tPATHS_ASSETS: process.env.PATHS_ASSETS ?? ''\n\t\t}\n\t}\n});\n"
  },
  {
    "path": "packages/kit/test/apps/options/public/answer.html",
    "content": "42\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/components/Message.svelte",
    "content": "<script>\n\timport { browser, dev } from '$app/environment';\n</script>\n\n<p>Hello from the {browser ? 'client' : 'server'} in {dev ? 'dev' : 'prod'} mode!</p>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/components/SharedCSS.svelte",
    "content": "<p>\n\tThis component is imported in multiple pages and therefore its CSS lands in a separate CSS chunk\n</p>\n\n<style>\n\tp {\n\t\tcolor: blue;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/components/SvelteLogo.svelte",
    "content": "<div class=\"svelte-logo\"></div>\n\n<style>\n\t.svelte-logo {\n\t\twidth: 107px;\n\t\theight: 128px;\n\t\tbackground: url('data:image/svg+xml;charset=UTF-8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"107\" height=\"128\" viewBox=\"0 0 107 128\"><title>svelte-logo</title><path d=\"M94.1566,22.8189c-10.4-14.8851-30.94-19.2971-45.7914-9.8348L22.2825,29.6078A29.9234,29.9234,0,0,0,8.7639,49.6506a31.5136,31.5136,0,0,0,3.1076,20.2318A30.0061,30.0061,0,0,0,7.3953,81.0653a31.8886,31.8886,0,0,0,5.4473,24.1157c10.4022,14.8865,30.9423,19.2966,45.7914,9.8348L84.7167,98.3921A29.9177,29.9177,0,0,0,98.2353,78.3493,31.5263,31.5263,0,0,0,95.13,58.117a30,30,0,0,0,4.4743-11.1824,31.88,31.88,0,0,0-5.4473-24.1157\" style=\"fill:%23ff3e00\"/><path d=\"M45.8171,106.5815A20.7182,20.7182,0,0,1,23.58,98.3389a19.1739,19.1739,0,0,1-3.2766-14.5025,18.1886,18.1886,0,0,1,.6233-2.4357l.4912-1.4978,1.3363.9815a33.6443,33.6443,0,0,0,10.203,5.0978l.9694.2941-.0893.9675a5.8474,5.8474,0,0,0,1.052,3.8781,6.2389,6.2389,0,0,0,6.6952,2.485,5.7449,5.7449,0,0,0,1.6021-.7041L69.27,76.281a5.4306,5.4306,0,0,0,2.4506-3.631,5.7948,5.7948,0,0,0-.9875-4.3712,6.2436,6.2436,0,0,0-6.6978-2.4864,5.7427,5.7427,0,0,0-1.6.7036l-9.9532,6.3449a19.0329,19.0329,0,0,1-5.2965,2.3259,20.7181,20.7181,0,0,1-22.2368-8.2427,19.1725,19.1725,0,0,1-3.2766-14.5024,17.9885,17.9885,0,0,1,8.13-12.0513L55.8833,23.7472a19.0038,19.0038,0,0,1,5.3-2.3287A20.7182,20.7182,0,0,1,83.42,29.6611a19.1739,19.1739,0,0,1,3.2766,14.5025,18.4,18.4,0,0,1-.6233,2.4357l-.4912,1.4978-1.3356-.98a33.6175,33.6175,0,0,0-10.2037-5.1l-.9694-.2942.0893-.9675a5.8588,5.8588,0,0,0-1.052-3.878,6.2389,6.2389,0,0,0-6.6952-2.485,5.7449,5.7449,0,0,0-1.6021.7041L37.73,51.719a5.4218,5.4218,0,0,0-2.4487,3.63,5.7862,5.7862,0,0,0,.9856,4.3717,6.2437,6.2437,0,0,0,6.6978,2.4864,5.7652,5.7652,0,0,0,1.602-.7041l9.9519-6.3425a18.978,18.978,0,0,1,5.2959-2.3278,20.7181,20.7181,0,0,1,22.2368,8.2427,19.1725,19.1725,0,0,1,3.2766,14.5024,17.9977,17.9977,0,0,1-8.13,12.0532L51.1167,104.2528a19.0038,19.0038,0,0,1-5.3,2.3287\" style=\"fill:%23fff\"/></svg>');\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/hooks.client.js",
    "content": ""
  },
  {
    "path": "packages/kit/test/apps/options/source/hooks.server.js",
    "content": "import { building } from '$app/environment';\nimport { env } from '$env/dynamic/private';\n\n// this verifies that dynamic env vars can be read during analysis phase\n// (it would fail if this app contained prerendered routes)\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst FOO = env.FOO;\n\n/** @type {import('@sveltejs/kit').Handle} */\nexport function handle({ event, resolve }) {\n\treturn resolve(event, {\n\t\t// this allows us to check that <link rel=\"stylesheet\"> is still added\n\t\t// to the DOM even if they're not included by `preload`\n\t\tpreload: ({ type }) => type !== 'css'\n\t});\n}\n\nexport function init() {\n\tif (building) {\n\t\tthrow new Error(\n\t\t\t'There are no prerendered pages or functions in this app so init() should not be called during the build'\n\t\t);\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/+layout.server.js",
    "content": "export const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/+layout.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\timport { setup } from '../../../../setup.js';\n\n\tsetup();\n\n\t// TODO: remove this when Svelte 5 addresses this issue https://github.com/sveltejs/svelte/issues/14438\n\tonMount(() => {\n\t\t// @ts-expect-error trustedTypes is a limited availability global\n\t\t// see https://developer.mozilla.org/en-US/docs/Web/API/Window/trustedTypes\n\t\tif (window.trustedTypes && trustedTypes.createPolicy) {\n\t\t\t// @ts-expect-error\n\t\t\ttrustedTypes.createPolicy('default', {\n\t\t\t\tcreateHTML: (/** @type {string} */ str) => str\n\t\t\t});\n\t\t}\n\t});\n</script>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/+page.svelte",
    "content": "<script>\n\timport Message from '$lib/Message.svelte';\n</script>\n\n<h2>We're on index.svelte</h2>\n<Message />\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/+server.js",
    "content": "export function GET() {\n\treturn new Response('root');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/base/+page.js",
    "content": "import { base, assets } from '$app/paths';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport async function load() {\n\treturn {\n\t\tpaths: {\n\t\t\tbase,\n\t\t\tassets\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/base/+page.svelte",
    "content": "<script>\n\timport SvelteLogo from '$lib/SvelteLogo.svelte';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n\n\tlet n = 0;\n</script>\n\n<SvelteLogo />\n\n<p data-source=\"base\">{data.paths.base}</p>\n<p data-source=\"assets\">{data.paths.assets}</p>\n\n<button on:click={() => (n += 1)}>clicks: {n}</button>\n\n{#if n === 1}\n\t<h2>button has been clicked 1 time</h2>\n{/if}\n\n<style>\n\tp {\n\t\tcolor: red;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/base/[slug]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\timport SvelteLogo from '$lib/SvelteLogo.svelte';\n</script>\n\n<SvelteLogo />\n\n<h2>{page.params.slug}</h2>\n\n<a href=\"/path-base/base/two\">/path-base/base/two</a>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/csp/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<svelte:head>\n\t<script src=\"http://localhost:{page.url.searchParams.get('port')}/blocked.js\"></script>\n</svelte:head>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/csp-hydratable/+page.svelte",
    "content": "<script>\n\timport { hydratable } from 'svelte';\n\n\tconst value = await hydratable('test-key', () => Promise.resolve('hydrated-value'));\n</script>\n\n<h1 id=\"hydratable-result\">{value}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/csp-with-stream/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tlazy: new Promise((resolve) => setTimeout(() => resolve(), 1000)).then(() => 'Moo Deng!')\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/csp-with-stream/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n{#await data.lazy}\n\tLoading...\n{:then value}\n\t<h2>{value}</h2>\n{/await}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/custom-extensions/+layout.svelte",
    "content": "<script>\n\timport { goto, preloadCode, preloadData } from '$app/navigation';\n\n\tif (typeof window !== 'undefined') {\n\t\tObject.assign(window, { goto, preloadCode, preloadData });\n\t}\n</script>\n\n<slot />\n\n<footer>Custom layout</footer>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/custom-extensions/+page.jesuslivesineveryone",
    "content": "<h2>Great success!</h2>\n\n<a href=\"a\">a</a>\n<a href=\"ambiguous/ok.json\">ok</a>\n<a href=\"echo-query?message\">ok</a>\n<a href=\"echo-query?p=one&p=two\">ok</a>\n\n<div class='hydrate-test'></div> \n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/custom-extensions/[slug]/+page.svelte.md",
    "content": "<script>import { page } from '$app/state';</script>\n\n<h2>{page.params.slug.toUpperCase()}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/custom-extensions/a/+page.svelte",
    "content": "<h2>a</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/custom-extensions/const/+page.whokilledthemuffinman",
    "content": "<h2>Tremendous!</h2> \n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/custom-extensions/unsafe-replacement/+page.svelte",
    "content": "<h2>Bazooom!</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/endpoint/+server.js",
    "content": "export function GET() {\n\treturn new Response('hi');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/endpoint-with-slash/+server.js",
    "content": "export function GET() {\n\treturn new Response('hi');\n}\n\nexport const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/env/+page.server.js",
    "content": "import { TOP_SECRET_SHH_PLS } from '$env/static/private';\nimport { env } from '$env/dynamic/private';\n\nexport function load() {\n\treturn {\n\t\tTOP_SECRET_SHH_PLS,\n\t\t// @ts-expect-error\n\t\tMATCHES_NEITHER: env.MATCHES_NEITHER || ''\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/env/+page.svelte",
    "content": "<script>\n\timport { GO_AWAY_PLEASE } from '$env/static/public';\n\texport let data;\n</script>\n\n<p id=\"public\">{GO_AWAY_PLEASE}</p>\n<p id=\"private\">{data.TOP_SECRET_SHH_PLS}</p>\n<p id=\"neither\">{data.MATCHES_NEITHER}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/error/+page.svelte",
    "content": "<!-- https://github.com/sveltejs/kit/issues/4186 -->\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/fetch/link-outside-base/+page.server.js",
    "content": "export async function load({ fetch }) {\n\tconst response = await fetch('/not-base-path/');\n\treturn {\n\t\tfetchUrl: response.url,\n\t\tfetchResponse: await response.text()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/fetch/link-outside-base/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageProps} */\n\tconst { data } = $props();\n</script>\n\n<p data-testid=\"fetch-url\">{data.fetchUrl}</p>\n<p data-testid=\"fetch-response\">{data.fetchResponse}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/fetch/link-root/+page.server.js",
    "content": "export async function load({ fetch }) {\n\t// fetch to root with trailing slash\n\tconst response1 = await fetch('/', { redirect: 'manual' });\n\t// fetch to root without trailing slash\n\tconst response2 = await fetch('', { redirect: 'manual' });\n\treturn {\n\t\tfetches: [\n\t\t\t{\n\t\t\t\turl: response1.url,\n\t\t\t\tresponse: await response1.text(),\n\t\t\t\tredirect: response1.headers.get('location')\n\t\t\t},\n\t\t\t{\n\t\t\t\turl: response2.url,\n\t\t\t\tresponse: await response2.text(),\n\t\t\t\tredirect: response2.headers.get('location')\n\t\t\t}\n\t\t]\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/fetch/link-root/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageProps} */\n\tconst { data } = $props();\n</script>\n\n<h2>Fetch URLs</h2>\n\n<dl>\n\t{#each data.fetches as item, index}\n\t\t<dt>fetch{index + 1}-url</dt>\n\t\t<dd data-testid={`fetch${index + 1}-url`}>{item.url}</dd>\n\t{/each}\n</dl>\n\n<h2>Fetch Responses</h2>\n<dl>\n\t{#each data.fetches as item, index}\n\t\t<dt>fetch{index + 1}-response</dt>\n\t\t<dd data-testid=\"fetch{index + 1}-response\">{item.response}</dd>\n\t{/each}\n</dl>\n\n<h2>Fetch Redirects</h2>\n<dl>\n\t{#each data.fetches as item, index}\n\t\t<dt>fetch{index + 1}-redirect</dt>\n\t\t<dd data-testid=\"fetch{index + 1}-redirect\">{item.redirect}</dd>\n\t{/each}\n</dl>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/fetch/link-root/+server.js",
    "content": "export function GET() {\n\treturn new Response('relative');\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/inline-style/+page.server.js",
    "content": "// test that the server-client stylesheet map is constructed correctly when\n// a page is imported. Importing a page causes Vite to associate the css with\n// a separate chunk instead of the page component itself\nimport.meta.glob('./import-meta/+page.svelte', { eager: true });\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/inline-style/+page.svelte",
    "content": "<script>\n\timport SharedCSS from '$lib/SharedCSS.svelte';\n\timport '@fontsource/libre-barcode-128-text';\n</script>\n\n<p>\n\tTest that the fontsource is referenced correctly, while the shared CSS in SharedCSS doesn't cause\n\tproblems\n</p>\n<SharedCSS />\n\n<style>\n\tp {\n\t\tfont-family: 'Libre Barcode 128 Text', sans-serif;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/inline-style/conditional-rendering/+page.svelte",
    "content": "<script>\n\timport Component from './Component.svelte';\n\n\tlet show = false;\n</script>\n\n<h1 id=\"always\">This is always rendered</h1>\n\n<button on:click={() => (show = !show)}>show component</button>\n\n{#if show}\n\t<Component />\n{/if}\n\n<style>\n\th1 {\n\t\tcolor: red;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/inline-style/conditional-rendering/Component.svelte",
    "content": "<p id=\"conditionally\">This is conditionally rendered</p>\n\n<style>\n\tp {\n\t\tcolor: blue;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/inline-style/dynamic-import/+page.js",
    "content": "export async function load() {\n\treturn {\n\t\tThing: (await import('./Thing.svelte')).default\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/inline-style/dynamic-import/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<svelte:component this={data.Thing} />\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/inline-style/dynamic-import/Thing.svelte",
    "content": "<p>I'm dynamically imported</p>\n\n<style>\n\tp {\n\t\tcolor: blue;\n\t\tfont-size: 20px;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/inline-style/import-meta/+page.svelte",
    "content": "<div>this page is being imported so its css is associated with a separate chunk</div>\n\n<style>\n\tdiv {\n\t\tcolor: pink;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/inline-style/static-dir/+page.svelte",
    "content": "<div></div>\n\n<p>\n\tAssets located in the static directory have their URL path transformed to '../../../asset.png'\n\tinstead of './asset.png' like most assets that go through Vite's static asset handling\n</p>\n\n<style>\n\tdiv {\n\t\tbackground: url(/favicon.png?v=1);\n\t\theight: 128px;\n\t\twidth: 128px;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/inline-style/url-encoded/+page.svelte",
    "content": "<p>testing if we correctly fix the asset URL in the CSS if it has URL encoded characters</p>\n\n<style>\n\tp {\n\t\tbackground: url('./愛.png');\n\t\theight: 128px;\n\t\twidth: 128px;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/match/+server.js",
    "content": "import { json } from '@sveltejs/kit';\nimport { match } from '$app/paths';\n\nconst test_paths = [\n\t'/path-base/resolve-route',\n\t'/path-base/resolve-route/resolved',\n\t'/path-base/not-a-real-route-that-exists'\n];\n\nexport async function GET() {\n\tconst results = await Promise.all(\n\t\ttest_paths.map(async (path) => ({ path, result: await match(path) }))\n\t);\n\n\treturn json(results);\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/mode/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tmode_from_endpoint: import.meta.env.MODE\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/mode/+page.svelte",
    "content": "<script>\n\timport { dev } from '$app/environment';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h2>\n\t{data.mode_from_endpoint} === {import.meta.env.MODE} === {dev ? 'development' : 'custom'}\n</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/on-navigate/+layout.svelte",
    "content": "<script>\n\timport { onNavigate } from '$app/navigation';\n\timport { resolve } from '$app/paths';\n\n\tlet { children } = $props();\n\n\tonNavigate((navigation) => {\n\t\tif (!document.startViewTransition || navigation.willUnload) return;\n\n\t\treturn new Promise((resolve) => {\n\t\t\tdocument.startViewTransition(async () => {\n\t\t\t\tresolve();\n\t\t\t\tawait navigation.complete;\n\t\t\t\tconsole.log('navigated');\n\t\t\t});\n\t\t});\n\t});\n</script>\n\n<ul>\n\t<li><a href={resolve('/on-navigate/a')}>a</a></li>\n\t<li><a href={resolve('/on-navigate/b')}>b</a></li>\n</ul>\n\n{@render children()}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/on-navigate/a/+page.svelte",
    "content": "<h1>Page A</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/on-navigate/b/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\n\t// @ts-ignore i guess svelte-check doesn't see the right config?\n\tawait new Promise((resolve) => setTimeout(resolve, 500));\n\n\tonMount(() => {\n\t\tconsole.log('mounted');\n\t});\n</script>\n\n<h1>Page B</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/page-endpoint/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tmessage: 'hi'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/page-endpoint/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h2>{data.message}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/preloading/+page.svelte",
    "content": "<a data-sveltekit-preload-data href=\"/path-base/preloading/preloaded\">click me</a>\n<a data-sveltekit-preload-code href=\"/path-base/preloading/code\">click me 2</a>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/preloading/code/+page.svelte",
    "content": "<h1>Should preload my code</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/preloading/preloaded/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tmessage: 'preloaded'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/preloading/preloaded/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.message}</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/resolve-route/+page.svelte",
    "content": "<script>\n\timport { resolveRoute } from '$app/paths';\n\timport SharedCss from '$lib/SharedCSS.svelte';\n</script>\n\n<SharedCss />\n<a data-id=\"target\" href={resolveRoute('/resolve-route/[foo]', { foo: 'resolved' })}>click me</a>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/resolve-route/[foo]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h2>{page.params.foo}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/routing/link-outside-app-target/source/+page.svelte",
    "content": "<script>\n\timport { onMount } from 'svelte';\n\timport { increment, count } from '../state.js';\n\n\tonMount(increment);\n</script>\n\n<h2>source: {count}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/routing/link-outside-app-target/state.js",
    "content": "export let count = 0;\n\nexport function increment() {\n\tcount += 1;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/routing/link-outside-app-target/target/+page.svelte",
    "content": "<script>\n\timport { count } from '../state.js';\n</script>\n\n<h2>target: {count}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/slash/+page.svelte",
    "content": "<script>\n\timport { base } from '$app/paths';\n\timport { page } from '$app/state';\n</script>\n\n<h2>{page.url.pathname}</h2>\n\n<a data-testid=\"child\" href=\"{base}/slash/child\">/slash/child</a>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/slash/child/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h2>{page.url.pathname}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/pages/test.txt",
    "content": "hello there world\n"
  },
  {
    "path": "packages/kit/test/apps/options/source/template.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<link rel=\"icon\" type=\"image/png\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<h1>I am in the template</h1>\n\t\t<div>%sveltekit.body%</div>\n\t\t<a href=\"/path-base/routing/link-outside-app-target/target/\">outside app target</a>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/options/svelte.config.js",
    "content": "import process from 'node:process';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\textensions: ['.jesuslivesineveryone', '.whokilledthemuffinman', '.svelte.md', '.svelte'],\n\tkit: {\n\t\tembedded: true,\n\t\tcsp: {\n\t\t\tdirectives: {\n\t\t\t\t'script-src': ['self'],\n\t\t\t\t'require-trusted-types-for': ['script']\n\t\t\t}\n\t\t},\n\t\tfiles: {\n\t\t\tassets: 'public',\n\t\t\tlib: 'source/components',\n\t\t\troutes: 'source/pages',\n\t\t\tappTemplate: 'source/template.html',\n\t\t\thooks: {\n\t\t\t\tclient: 'source/hooks.client.js',\n\t\t\t\tserver: 'source/hooks.server.js'\n\t\t\t},\n\t\t\t// while we specify a path for the service worker, we expect it to not exist in the test\n\t\t\tserviceWorker: 'source/service-worker'\n\t\t},\n\t\tappDir: '_wheee/nested',\n\t\tinlineStyleThreshold: 1024,\n\t\toutDir: '.custom-out-dir',\n\t\toutput: {\n\t\t\tpreloadStrategy: 'preload-mjs'\n\t\t},\n\t\tpaths: {\n\t\t\tbase: '/path-base',\n\t\t\t// @ts-expect-error our env var string can't match the https template literal\n\t\t\tassets: process.env.PATHS_ASSETS || ''\n\t\t},\n\t\tenv: {\n\t\t\tdir: './env-dir',\n\t\t\tpublicPrefix: 'GO_AWAY_',\n\t\t\tprivatePrefix: 'TOP_SECRET_SHH'\n\t\t},\n\t\trouter: {\n\t\t\tresolution: /** @type {'client' | 'server'} */ (process.env.ROUTER_RESOLUTION) || 'client'\n\t\t}\n\t},\n\tcompilerOptions: {\n\t\texperimental: {\n\t\t\tasync: true\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/options/test/paths-assets.test.js",
    "content": "import process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe('base path', () => {\n\ttest.skip(!process.env.PATHS_ASSETS);\n\n\ttest('serves a useful 404 when visiting unprefixed path', async ({ request }) => {\n\t\tconst html = await request.get('/slash/', { headers: { Accept: 'text/html' } });\n\t\texpect(html.status()).toBe(404);\n\t\texpect(await html.text()).toBe(\n\t\t\t'The server is configured with a public base URL of /path-base - did you mean to visit <a href=\"/path-base/slash/\">/path-base/slash/</a> instead?'\n\t\t);\n\n\t\tconst plain = await request.get('/slash/');\n\t\texpect(plain.status()).toBe(404);\n\t\texpect(await plain.text()).toBe(\n\t\t\t'The server is configured with a public base URL of /path-base - did you mean to visit /path-base/slash/ instead?'\n\t\t);\n\t});\n\n\ttest('serves /', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/path-base/');\n\n\t\texpect(await page.textContent('h1')).toBe('I am in the template');\n\t\texpect(await page.textContent('h2')).toBe(\"We're on index.svelte\");\n\n\t\tconst mode = process.env.DEV ? 'dev' : 'prod';\n\t\texpect(await page.textContent('p')).toBe(\n\t\t\t`Hello from the ${javaScriptEnabled ? 'client' : 'server'} in ${mode} mode!`\n\t\t);\n\t});\n\n\ttest('serves files in source directory', async ({ request, javaScriptEnabled }) => {\n\t\ttest.skip(!process.env.DEV || !javaScriptEnabled);\n\n\t\tconst response = await request.get('/path-base/source/pages/test.txt');\n\t\texpect(response.ok()).toBe(true);\n\t\texpect(await response.text()).toBe('hello there world\\n');\n\t});\n\n\ttest('paths available on server side', async ({ page }) => {\n\t\tawait page.goto('/path-base/base/');\n\t\texpect(await page.textContent('[data-source=\"base\"]')).toBe('/path-base');\n\t\texpect(await page.textContent('[data-source=\"assets\"]')).toBe('/_svelte_kit_assets');\n\t});\n\n\ttest('loads javascript', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/path-base/base/');\n\t\texpect(await page.textContent('button')).toBe('clicks: 0');\n\n\t\tif (javaScriptEnabled) {\n\t\t\tawait page.click('button');\n\t\t\texpect(await page.innerHTML('h2')).toBe('button has been clicked 1 time');\n\t\t}\n\t});\n\n\ttest('loads CSS', async ({ page, get_computed_style }) => {\n\t\tawait page.goto('/path-base/base/');\n\t\texpect(await get_computed_style('p', 'color')).toBe('rgb(255, 0, 0)');\n\t});\n\n\ttest('sets params correctly', async ({ page, clicknav }) => {\n\t\tawait page.goto('/path-base/base/one');\n\n\t\texpect(await page.textContent('h2')).toBe('one');\n\n\t\tawait clicknav('[href=\"/path-base/base/two\"]');\n\t\texpect(await page.textContent('h2')).toBe('two');\n\t});\n\n\ttest('resolveRoute accounts for base path', async ({ baseURL, page, clicknav }) => {\n\t\tawait page.goto('/path-base/resolve-route');\n\t\tawait clicknav('[data-id=target]');\n\t\texpect(page.url()).toBe(`${baseURL}/path-base/resolve-route/resolved/`);\n\t\texpect(await page.textContent('h2')).toBe('resolved');\n\t});\n\n\ttest('server load fetch without base path does not invoke the server', async ({\n\t\tpage,\n\t\tbaseURL\n\t}) => {\n\t\tawait page.goto('/path-base/fetch/link-outside-base/');\n\t\tawait expect(page.locator('[data-testid=\"fetch-url\"]')).toHaveText(`${baseURL}/not-base-path/`);\n\t\tawait expect(page.locator('[data-testid=\"fetch-response\"]')).toContainText(\n\t\t\t'did you mean to visit'\n\t\t);\n\t});\n\n\ttest('server load fetch to root does not invoke the server', async ({ page, baseURL }) => {\n\t\tawait page.goto('/path-base/fetch/link-root/');\n\t\t// fetch to root with trailing slash\n\t\tawait expect(page.locator('[data-testid=\"fetch1-url\"]')).toHaveText(`${baseURL}/`);\n\t\tif (process.env.DEV) {\n\t\t\tawait expect(page.locator('[data-testid=\"fetch1-redirect\"]')).toHaveText('/path-base');\n\t\t} else {\n\t\t\tawait expect(page.locator('[data-testid=\"fetch1-response\"]')).toContainText(\n\t\t\t\t'did you mean to visit'\n\t\t\t);\n\t\t}\n\n\t\t// fetch to root without trailing slash should be relative\n\t\tawait expect(page.locator('[data-testid=\"fetch2-url\"]')).toBeEmpty();\n\t\tawait expect(page.locator('[data-testid=\"fetch2-response\"]')).toHaveText('relative');\n\t});\n});\n\ntest.describe('assets path', () => {\n\ttest.skip(!process.env.PATHS_ASSETS);\n\n\ttest('serves static assets with correct prefix', async ({ page, request }) => {\n\t\tawait page.goto('/path-base/');\n\t\tconst href = await page.locator('link[rel=\"icon\"]').getAttribute('href');\n\n\t\tconst response = await request.get(href ?? '');\n\t\texpect(response.status()).toBe(200);\n\t});\n});\n\ntest.describe('inlineStyleThreshold', () => {\n\ttest('inlines CSS', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/path-base/base/');\n\t\tif (process.env.DEV) {\n\t\t\tconst ssr_style = await page.$('style[data-sveltekit]');\n\n\t\t\tif (javaScriptEnabled) {\n\t\t\t\t// <style data-sveltekit> is removed upon hydration\n\t\t\t\texpect(ssr_style).toBeNull();\n\t\t\t} else {\n\t\t\t\texpect(ssr_style).not.toBeNull();\n\t\t\t}\n\n\t\t\texpect(await page.$('link[rel=\"stylesheet\"]')).toBeNull();\n\t\t} else {\n\t\t\texpect(await page.$('style')).not.toBeNull();\n\t\t\texpect(await page.$('link[rel=\"stylesheet\"][disabled]')).not.toBeNull();\n\t\t\texpect(await page.$('link[rel=\"stylesheet\"]:not([disabled])')).not.toBeNull();\n\t\t}\n\t});\n\n\ttest('loads assets', async ({ page, javaScriptEnabled }) => {\n\t\ttest.skip(!!process.env.DEV || javaScriptEnabled);\n\n\t\tlet font_loaded = false;\n\t\tpage.on('response', (response) => {\n\t\t\tif (response.url().endsWith('.woff2') || response.url().endsWith('.woff')) {\n\t\t\t\tfont_loaded = response.ok();\n\t\t\t}\n\t\t});\n\t\tawait page.goto('/path-base/inline-style');\n\t\texpect(font_loaded).toBeTruthy();\n\t});\n\n\ttest('loads assets located in static directory', async ({ page, javaScriptEnabled }) => {\n\t\ttest.skip(!!process.env.DEV || javaScriptEnabled);\n\n\t\tlet image_loaded = false;\n\t\tpage.on('response', (response) => {\n\t\t\tif (response.url().endsWith('favicon.png?v=1')) {\n\t\t\t\timage_loaded = response.ok();\n\t\t\t}\n\t\t});\n\t\tawait page.goto('/path-base/inline-style/static-dir');\n\t\texpect(image_loaded).toBeTruthy();\n\t});\n\n\ttest('loads assets with URL encoded characters', async ({ page, javaScriptEnabled }) => {\n\t\ttest.skip(!!process.env.DEV || javaScriptEnabled);\n\n\t\tlet image_loaded = false;\n\t\tpage.on('response', (response) => {\n\t\t\tif (response.url().match(/%E6%84%9B\\.\\w+\\.png$/)) {\n\t\t\t\timage_loaded = response.ok();\n\t\t\t}\n\t\t});\n\t\tawait page.goto('/path-base/inline-style/url-encoded');\n\t\texpect(image_loaded).toBeTruthy();\n\t});\n\n\ttest('includes components dynamically imported in universal load', async ({\n\t\tpage,\n\t\tget_computed_style\n\t}) => {\n\t\ttest.skip(!!process.env.DEV);\n\n\t\tlet loaded_css = false;\n\t\tpage.on('response', (response) => {\n\t\t\tif (response.url().endsWith('.css')) {\n\t\t\t\tloaded_css = true;\n\t\t\t}\n\t\t});\n\t\tawait page.goto('/path-base/inline-style/dynamic-import');\n\t\tawait expect(page.locator('p')).toHaveText(\"I'm dynamically imported\");\n\t\texpect(loaded_css).toBe(false);\n\t\texpect(await get_computed_style('p', 'color')).toEqual('rgb(0, 0, 255)');\n\t});\n\n\ttest('includes conditionally rendered component styles', async ({\n\t\tpage,\n\t\tget_computed_style,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\ttest.skip(!!process.env.DEV || !javaScriptEnabled);\n\n\t\tawait page.goto('/path-base/inline-style/conditional-rendering');\n\t\tawait expect(page.locator('#always')).toBeVisible();\n\t\texpect(await get_computed_style('#always', 'color')).toBe('rgb(255, 0, 0)');\n\n\t\tawait page.locator('button', { hasText: 'show component' }).click();\n\t\tawait expect(page.locator('#conditionally')).toBeVisible();\n\t\texpect(await get_computed_style('#conditionally', 'color')).toBe('rgb(0, 0, 255)');\n\t});\n\n\ttest('places preload links before inlined styles', async ({ request }) => {\n\t\t// Skip in dev mode since inlineStyleThreshold works differently there\n\t\ttest.skip(!!process.env.DEV);\n\n\t\tconst response = await request.get('/path-base/base/');\n\t\tconst html = await response.text();\n\n\t\tconst preloadMatch = html.match(/<link[^>]+rel=\"preload\"/);\n\t\tconst styleMatch = html.match(/<style[^>]*>/);\n\n\t\texpect(preloadMatch).not.toBeNull();\n\t\texpect(styleMatch).not.toBeNull();\n\n\t\tconst preloadIndex = html.indexOf(preloadMatch[0]);\n\t\tconst styleIndex = html.indexOf(styleMatch[0]);\n\n\t\texpect(preloadIndex).toBeLessThan(styleIndex);\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/options/test/test.js",
    "content": "import * as http from 'node:http';\nimport process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.skip(!!process.env.PATHS_ASSETS);\n\ntest.describe('CSP', () => {\n\ttest('blocks script from external site', async ({ page, start_server }) => {\n\t\tconst { port } = await start_server((req, res) => {\n\t\t\tif (req.url === '/blocked.js') {\n\t\t\t\tres.writeHead(200, {\n\t\t\t\t\t'content-type': 'text/javascript'\n\t\t\t\t});\n\n\t\t\t\tres.end('window.pwned = true');\n\t\t\t} else {\n\t\t\t\tres.writeHead(404).end('not found');\n\t\t\t}\n\t\t});\n\n\t\tawait page.goto(`/path-base/csp?port=${port}`);\n\t\texpect(await page.evaluate('window.pwned')).toBe(undefined);\n\t});\n\n\ttest('ensure CSP header in stream response', async ({ page, javaScriptEnabled }) => {\n\t\tif (!javaScriptEnabled) return;\n\t\tconst response = await page.goto('/path-base/csp-with-stream');\n\t\texpect(response?.headers()['content-security-policy']).toMatch(\n\t\t\t/require-trusted-types-for 'script'/\n\t\t);\n\t\texpect(await page.textContent('h2')).toBe('Moo Deng!');\n\t});\n\n\ttest(\"quotes 'script'\", async ({ page }) => {\n\t\tconst response = await page.goto('/path-base');\n\t\texpect(response?.headers()['content-security-policy']).toMatch(\n\t\t\t/require-trusted-types-for 'script'/\n\t\t);\n\t});\n\n\ttest('allows hydratable scripts with CSP', async ({ request }) => {\n\t\tconst response = await request.get('/path-base/csp-hydratable');\n\t\tconst html = await response.text();\n\n\t\tconst csp_header = response.headers()['content-security-policy'];\n\t\texpect(csp_header).toBeDefined();\n\n\t\t// Extract nonce from CSP header (e.g., 'nonce-ABC123')\n\t\tconst nonce_match = csp_header.match(/'nonce-([^']+)'/);\n\t\texpect(nonce_match).not.toBeNull();\n\t\tconst nonce = nonce_match?.[1];\n\n\t\t// Find the hydratable script in the raw HTML - it sets up (window.__svelte ??= {}).h\n\t\tconst hydratable_script_match = html.match(\n\t\t\t/<script\\s+nonce=\"([^\"]+)\"[^>]*>[^<]*\\(window\\.__svelte \\?\\?= \\{\\}\\)\\.h/\n\t\t);\n\t\texpect(hydratable_script_match).not.toBeNull();\n\t\texpect(hydratable_script_match?.[1]).toBe(nonce);\n\t});\n});\n\ntest.describe('Custom extensions', () => {\n\ttest('works with arbitrary extensions', async ({ page }) => {\n\t\tawait page.goto('/path-base/custom-extensions/');\n\t\texpect(await page.textContent('h2')).toBe('Great success!');\n\t});\n\n\ttest('works with other arbitrary extensions', async ({ page }) => {\n\t\tawait page.goto('/path-base/custom-extensions/const');\n\t\texpect(await page.textContent('h2')).toBe('Tremendous!');\n\n\t\tawait page.goto('/path-base/custom-extensions/a');\n\n\t\texpect(await page.textContent('h2')).toBe('a');\n\n\t\tawait page.goto('/path-base/custom-extensions/test-slug');\n\n\t\texpect(await page.textContent('h2')).toBe('TEST-SLUG');\n\n\t\tawait page.goto('/path-base/custom-extensions/unsafe-replacement');\n\n\t\texpect(await page.textContent('h2')).toBe('Bazooom!');\n\t});\n});\n\ntest.describe('env', () => {\n\ttest('resolves downwards', async ({ page }) => {\n\t\tawait page.goto('/path-base/env');\n\t\texpect(await page.textContent('#public')).toBe('and thank you');\n\t});\n\ttest('respects private prefix', async ({ page }) => {\n\t\tawait page.goto('/path-base/env');\n\t\texpect(await page.textContent('#private')).toBe('shhhh');\n\t\texpect(await page.textContent('#neither')).toBe('');\n\t});\n});\n\ntest.describe('trailingSlash', () => {\n\ttest('adds trailing slash', async ({ baseURL, page, clicknav }) => {\n\t\t// we can't use Playwright's `request` here, because it resolves redirects\n\t\tconst status = await new Promise((fulfil, reject) => {\n\t\t\tconst request = http.get(`${baseURL}/path-base/slash`);\n\t\t\trequest.on('error', reject);\n\t\t\trequest.on('response', (response) => {\n\t\t\t\tfulfil(response.statusCode);\n\t\t\t});\n\t\t});\n\t\texpect(status).toBe(308);\n\n\t\tawait page.goto('/path-base/slash');\n\n\t\texpect(page.url()).toBe(`${baseURL}/path-base/slash/`);\n\t\texpect(await page.textContent('h2')).toBe('/path-base/slash/');\n\n\t\tawait clicknav('[data-testid=\"child\"]');\n\t\texpect(page.url()).toBe(`${baseURL}/path-base/slash/child/`);\n\t\texpect(await page.textContent('h2')).toBe('/path-base/slash/child/');\n\t});\n\n\ttest('removes trailing slash on endpoint', async ({ baseURL, request }) => {\n\t\tconst r1 = await request.get('/path-base/endpoint/');\n\t\texpect(r1.url()).toBe(`${baseURL}/path-base/endpoint`);\n\t\texpect(await r1.text()).toBe('hi');\n\n\t\tconst r2 = await request.get('/path-base/endpoint');\n\t\texpect(r2.url()).toBe(`${baseURL}/path-base/endpoint`);\n\t\texpect(await r2.text()).toBe('hi');\n\t});\n\n\ttest('adds trailing slash to endpoint', async ({ baseURL, request }) => {\n\t\tconst r1 = await request.get('/path-base/endpoint-with-slash');\n\t\texpect(r1.url()).toBe(`${baseURL}/path-base/endpoint-with-slash/`);\n\t\texpect(await r1.text()).toBe('hi');\n\n\t\tconst r2 = await request.get('/path-base/endpoint-with-slash/');\n\t\texpect(r2.url()).toBe(`${baseURL}/path-base/endpoint-with-slash/`);\n\t\texpect(await r2.text()).toBe('hi');\n\t});\n\n\ttest('can fetch data from page-endpoint', async ({ request }) => {\n\t\tconst r = await request.get('/path-base/page-endpoint/__data.json');\n\t\tconst data = await r.json();\n\n\t\texpect(data).toEqual({\n\t\t\ttype: 'data',\n\t\t\tnodes: [\n\t\t\t\t{ type: 'data', data: [null], uses: {}, slash: 'always' },\n\t\t\t\t{ type: 'data', data: [{ message: 1 }, 'hi'], uses: {} }\n\t\t\t]\n\t\t});\n\t});\n\n\ttest('accounts for trailingSlash when preloading', async ({ app, page, javaScriptEnabled }) => {\n\t\tif (!javaScriptEnabled) return;\n\n\t\tawait page.goto('/path-base/preloading');\n\n\t\t/** @type {string[]} */\n\t\tlet requests = [];\n\t\tpage.on('request', (r) => {\n\t\t\tconst url = r.url();\n\t\t\t// Headless Chrome re-requests the favicon.png on every URL change\n\t\t\tif (url.endsWith('/favicon.png')) return;\n\t\t\treturn requests.push(new URL(url).pathname);\n\t\t});\n\n\t\t// also wait for network processing to complete, see\n\t\t// https://playwright.dev/docs/network#network-events\n\t\tawait app.preloadCode('/path-base/preloading/preloaded');\n\n\t\t// svelte request made is environment dependent\n\t\tif (process.env.DEV) {\n\t\t\texpect(requests.filter((req) => req.endsWith('.svelte')).length).toBe(1);\n\t\t} else {\n\t\t\texpect(requests.filter((req) => req.endsWith('.mjs')).length).toBeGreaterThan(0);\n\t\t}\n\n\t\trequests = [];\n\t\tawait app.preloadData('/path-base/preloading/preloaded');\n\n\t\texpect(requests.includes('/path-base/preloading/preloaded/__data.json')).toBe(true);\n\n\t\trequests = [];\n\t\tawait app.goto('/path-base/preloading/preloaded');\n\t\texpect(requests).toEqual([]);\n\t});\n\n\ttest('accounts for base path when running data-sveltekit-preload-code', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\tif (!javaScriptEnabled) return;\n\n\t\tawait page.goto('/path-base/preloading');\n\n\t\t/** @type {string[]} */\n\t\tlet requests = [];\n\t\tpage.on('request', (r) => requests.push(new URL(r.url()).pathname));\n\n\t\tawait page.hover('a[href=\"/path-base/preloading/code\"]');\n\t\tawait page.waitForTimeout(100);\n\n\t\t// svelte request made is environment dependent\n\t\tif (process.env.DEV) {\n\t\t\texpect(requests.filter((req) => req.endsWith('.svelte')).length).toBe(1);\n\t\t} else {\n\t\t\texpect(requests.filter((req) => req.endsWith('.mjs')).length).toBeGreaterThan(0);\n\t\t}\n\n\t\trequests = [];\n\t\tawait page.click('a[href=\"/path-base/preloading/code\"]');\n\t\texpect(requests).toEqual([]);\n\t});\n});\n\ntest.describe('serviceWorker', () => {\n\ttest.skip(!!process.env.DEV);\n\n\ttest('does not register service worker if none created', async ({ page }) => {\n\t\tawait page.goto('/path-base/');\n\t\texpect(await page.content()).not.toMatch('navigator.serviceWorker');\n\t});\n});\n\ntest.describe('Vite options', () => {\n\ttest('Respects --mode', async ({ page }) => {\n\t\tawait page.goto('/path-base/mode');\n\n\t\tconst mode = process.env.DEV ? 'development' : 'custom';\n\t\texpect(await page.textContent('h2')).toBe(`${mode} === ${mode} === ${mode}`);\n\t});\n});\n\ntest.describe('$app/paths', () => {\n\ttest('match() works with base paths', async ({ request }) => {\n\t\tconst response = await request.get('/path-base/match');\n\n\t\texpect(await response.json()).toEqual([\n\t\t\t{\n\t\t\t\tpath: '/path-base/resolve-route',\n\t\t\t\tresult: { id: '/resolve-route', params: {} }\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: '/path-base/resolve-route/resolved',\n\t\t\t\tresult: { id: '/resolve-route/[foo]', params: { foo: 'resolved' } }\n\t\t\t},\n\t\t\t{ path: '/path-base/not-a-real-route-that-exists', result: null }\n\t\t]);\n\t});\n});\n\ntest.describe('Routing', () => {\n\ttest('ignores clicks outside the app target', async ({ page }) => {\n\t\tawait page.goto('/path-base/routing/link-outside-app-target/source/');\n\n\t\tawait page.click('[href=\"/path-base/routing/link-outside-app-target/target/\"]');\n\t\tawait expect(page.locator('h2')).toHaveText('target: 0');\n\t});\n});\n\ntest.describe('Async', () => {\n\ttest(\"updates the DOM before onNavigate's promise is resolved\", async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\ttest.skip(!javaScriptEnabled);\n\n\t\tawait page.goto('/path-base/on-navigate/a');\n\n\t\t/** @type {string[]} */\n\t\tconst logs = [];\n\t\tpage.on('console', (msg) => {\n\t\t\tlogs.push(msg.text());\n\t\t});\n\n\t\tawait page.getByRole('link', { name: 'b' }).click();\n\n\t\tawait expect(page.locator('h1', { hasText: 'Page B' })).toBeVisible();\n\t\texpect(logs).toEqual(['mounted', 'navigated']);\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/options/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t},\n\t\"extends\": \"./.custom-out-dir/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options/vite.custom.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false,\n\t\tassetsInlineLimit: 0\n\t},\n\tclearScreen: false,\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/README.md",
    "content": "This app exists to test options that are equivalent with the ones specified in the other `options` test app.\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/package.json",
    "content": "{\n\t\"name\": \"test-options-2\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"pnpm test:dev && pnpm test:build\",\n\t\t\"test:dev\": \"DEV=true playwright test\",\n\t\t\"test:build\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/adapter-node\": \"workspace:^\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"valibot\": \"catalog:\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div style=\"display: contents\">%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/hooks.js",
    "content": "import { Foo } from '$lib';\n\n/** @type {import(\"@sveltejs/kit\").Transport} */\nexport const transport = {\n\tFoo: {\n\t\tencode: (value) => value instanceof Foo && [value.message],\n\t\tdecode: ([message]) => new Foo(message)\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/lib/index.js",
    "content": "export class Foo {\n\tconstructor(message) {\n\t\tthis.message = message;\n\t}\n\n\tbar() {\n\t\treturn this.message + '!';\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/+layout.svelte",
    "content": "<script>\n\timport { setup } from '../../../../setup.js';\n\n\tsetup();\n</script>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/+page.svelte",
    "content": "<script>\n\timport { resolve, asset } from '$app/paths';\n</script>\n\n<h1>Hello</h1>\n\n<p data-testid=\"base\">base: {resolve('/')}</p>\n<p data-testid=\"assets\">assets: {asset('/')}</p>\n\n<a href={resolve('/hello')} data-testid=\"link\">Go to /hello</a>\n\n<style>\n\ta {\n\t\ttext-decoration: none;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/deeply/nested/page/+page.svelte",
    "content": "<script>\n\timport { resolve, asset } from '$app/paths';\n</script>\n\n<h1>Hello</h1>\n\n<p data-testid=\"base\">base: {resolve('/')}</p>\n<p data-testid=\"assets\">assets: {asset('/')}</p>\n\n<style>\n\tp {\n\t\tcolor: red;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/deserialize/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<p>{data.data.text}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/deserialize/+page.ts",
    "content": "import { deserialize } from '$app/forms';\n\nexport const ssr = false;\n\nexport function load() {\n\tconst result = deserialize(\n\t\tJSON.stringify({\n\t\t\ttype: 'success',\n\t\t\tstatus: 200,\n\t\t\tdata: '[{\"text\":1},\"Hello world!\"]'\n\t\t})\n\t);\n\n\treturn result;\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/env/+page.svelte",
    "content": "<script>\n\timport { PUBLIC_LOOK_IN_OPTIONS_2 } from '$env/static/public';\n\timport { env } from '$env/dynamic/public';\n</script>\n\n<p data-testid=\"static\">static: {PUBLIC_LOOK_IN_OPTIONS_2}</p>\n<p data-testid=\"dynamic\">dynamic: {env.PUBLIC_LOOK_IN_OPTIONS_2}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/hello/+page.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/hello/+page.svelte",
    "content": "<h1>Prerendered</h1>\n\n<style>\n\th1 {\n\t\tbackground-color: green;\n\t}\n</style>\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/remote/+page.svelte",
    "content": "<script>\n\timport { prerendered, get_count, set_count, set_count_form } from './count.remote.js';\n\n\tlet count = $state(null);\n\tlet prerendered_result = $state(null);\n</script>\n\n<p id=\"count\">{count}</p>\n\n<button onclick={async () => (count = await get_count().run())}>get count</button>\n\n<button onclick={async () => (count = await set_count(0))} id=\"reset-btn\">reset</button>\n\n<form\n\t{...set_count_form.enhance(async ({ submit }) => {\n\t\tawait submit().updates(get_count());\n\t\tcount = await get_count().run();\n\t})}\n>\n\t<input type=\"number\" name=\"count\" />\n\t<button>submit</button>\n</form>\n\n<button id=\"fetch-prerendered\" onclick={async () => (prerendered_result = await prerendered())}>\n\tget prerendered\n</button>\n\n<p id=\"prerendered\">{prerendered_result}</p>\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/remote/count.remote.js",
    "content": "import { building, dev } from '$app/environment';\nimport { command, form, prerender, query } from '$app/server';\nimport * as v from 'valibot';\n\nlet count = 0;\n\nexport const get_count = query(() => count);\n\nexport const set_count = command(\n\t'unchecked',\n\t/** @param {number} c */\n\tasync (c) => {\n\t\treturn (count = c);\n\t}\n);\n\nexport const prerendered = prerender(() => {\n\tif (!building && !dev) {\n\t\tthrow new Error('this prerender should not be called at runtime in production');\n\t}\n\n\treturn 'yes';\n});\n\nexport const set_count_form = form(v.object({ count: v.string() }), async (data) => {\n\treturn (count = parseInt(data.count));\n});\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/serialization-stream/+page.server.js",
    "content": "import { Foo } from '$lib';\n\nexport const load = () => {\n\treturn {\n\t\tfoo: Promise.resolve(new Foo('It works'))\n\t};\n};\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/serialization-stream/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>\n\t{#await data.foo}\n\t\tLoading...\n\t{:then result}\n\t\t{result.bar()}\n\t{/await}\n</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/trailing-slash-server/+page.svelte",
    "content": "<script>\n\timport { base } from '$app/paths';\n</script>\n\n<a href=\"{base}/trailing-slash-server/prerender\">{base}/trailing-slash-server/prerender</a>\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/trailing-slash-server/prerender/+page.server.js",
    "content": "export const trailingSlash = 'always';\nexport const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/routes/trailing-slash-server/prerender/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h2>{page.url.pathname}</h2>\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/src/service-worker.js",
    "content": "import { base, build, version } from '$service-worker';\nimport src from './image.jpg?url';\n\n//@ts-ignore\nself.base = base;\n//@ts-ignore\nself.build = build;\n//@ts-ignore\nself.image_src = src;\n\nconst name = `cache-${version}`;\n\nself.addEventListener('install', (event) => {\n\t// @ts-expect-error\n\tevent.waitUntil(caches.open(name).then((cache) => cache.addAll(build)));\n});\n\nself.addEventListener('activate', (event) => {\n\t// @ts-expect-error\n\tevent.waitUntil(\n\t\tcaches.keys().then(async (keys) => {\n\t\t\tfor (const key of keys) {\n\t\t\t\tif (!key.includes(version)) caches.delete(key);\n\t\t\t}\n\t\t})\n\t);\n});\n\nself.addEventListener('fetch', (event) => {\n\t// @ts-expect-error\n\tconst { request } = event;\n\n\tif (request.method !== 'GET' || request.headers.has('range')) return;\n\n\tconst url = new URL(request.url);\n\tconst cached = caches.match(request);\n\n\tif (url.origin === location.origin && build.includes(url.pathname)) {\n\t\t// always return build files from cache\n\t\t// @ts-expect-error\n\t\tevent.respondWith(cached);\n\t} else if (url.protocol === 'https:' || location.hostname === 'localhost') {\n\t\t// hit the network for everything else...\n\t\tconst promise = fetch(request);\n\n\t\t// ...and cache successful responses...\n\t\tpromise.then((response) => {\n\t\t\t// cache successful responses\n\t\t\tif (response.ok && response.type === 'basic') {\n\t\t\t\tconst clone = response.clone();\n\t\t\t\tcaches.open(name).then((cache) => {\n\t\t\t\t\tcache.put(request, clone);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t// ...but if it fails, fall back to cache if available\n\t\t// @ts-expect-error\n\t\tevent.respondWith(promise.catch(() => cached || promise));\n\t}\n});\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/static/answer.txt",
    "content": "42"
  },
  {
    "path": "packages/kit/test/apps/options-2/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tcompilerOptions: {\n\t\texperimental: {\n\t\t\tasync: true\n\t\t}\n\t},\n\tkit: {\n\t\tpaths: {\n\t\t\tbase: '/basepath',\n\t\t\trelative: true\n\t\t},\n\t\tserviceWorker: {\n\t\t\tregister: false\n\t\t},\n\t\tenv: {\n\t\t\tdir: '../../env'\n\t\t},\n\t\toutput: {\n\t\t\tbundleStrategy: 'single'\n\t\t},\n\t\texperimental: {\n\t\t\tremoteFunctions: true\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/test/test.js",
    "content": "import path from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe('env', () => {\n\ttest('resolves upwards', async ({ page }) => {\n\t\tawait page.goto('/basepath/env');\n\t\texpect(await page.textContent('[data-testid=\"static\"]')).toBe('static: resolves upwards!');\n\t\texpect(await page.textContent('[data-testid=\"dynamic\"]')).toBe('dynamic: resolves upwards!');\n\t});\n});\n\ntest.describe('paths', () => {\n\ttest('serves /basepath', async ({ page }) => {\n\t\tawait page.goto('/basepath');\n\t\texpect(await page.textContent('h1')).toBe('Hello');\n\t});\n\n\ttest('serves assets from /basepath', async ({ request }) => {\n\t\tconst response = await request.get('/basepath/answer.txt');\n\t\texpect(await response.text()).toBe('42');\n\t});\n\n\ttest('uses relative paths during SSR', async ({ page, javaScriptEnabled }) => {\n\t\tawait page.goto('/basepath');\n\n\t\tlet base = javaScriptEnabled ? '/basepath/' : './';\n\t\texpect(await page.textContent('[data-testid=\"base\"]')).toBe(`base: ${base}`);\n\t\texpect(await page.textContent('[data-testid=\"assets\"]')).toBe(`assets: ${base}`);\n\n\t\tawait page.goto('/basepath/deeply/nested/page');\n\n\t\tbase = javaScriptEnabled ? '/basepath/' : '../../';\n\t\texpect(await page.textContent('[data-testid=\"base\"]')).toBe(`base: ${base}`);\n\t\texpect(await page.textContent('[data-testid=\"assets\"]')).toBe(`assets: ${base}`);\n\t});\n\n\ttest('serves /basepath with trailing slash always', async ({ page }) => {\n\t\tawait page.goto('/basepath');\n\t\texpect(new URL(page.url()).pathname).toBe('/basepath/');\n\t});\n\n\ttest('respects trailing slash option when navigating from /basepath', async ({\n\t\tpage,\n\t\tclicknav\n\t}) => {\n\t\tawait page.goto('/basepath');\n\t\texpect(new URL(page.url()).pathname).toBe('/basepath/');\n\t\tawait clicknav('[data-testid=\"link\"]');\n\t\texpect(new URL(page.url()).pathname).toBe('/basepath/hello');\n\t});\n\n\ttest('query remote function from client accounts for base path', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\ttest.skip(!javaScriptEnabled);\n\n\t\tawait page.goto('/basepath/remote');\n\t\tawait expect(page.locator('#count')).toHaveText('');\n\t\tawait page.locator('button', { hasText: 'get count' }).click();\n\t\tawait expect(page.locator('#count')).toHaveText('0');\n\t});\n\n\ttest('prerender remote function from client accounts for base path', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\ttest.skip(!javaScriptEnabled);\n\n\t\tawait page.goto('/basepath/remote');\n\t\tawait expect(page.locator('#prerendered')).toHaveText('');\n\t\tawait page.locator('button', { hasText: 'get prerendered' }).click();\n\t\tawait expect(page.locator('#prerendered')).toHaveText('yes');\n\t});\n\n\ttest('command remote function from client accounts for base path', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\ttest.skip(!javaScriptEnabled);\n\n\t\tawait page.goto('/basepath/remote');\n\t\tawait expect(page.locator('#count')).toHaveText('');\n\t\tawait page.locator('button', { hasText: 'reset' }).click();\n\t\tawait expect(page.locator('#count')).toHaveText('0');\n\t});\n\n\ttest('form remote function from client accounts for base path', async ({\n\t\tpage,\n\t\tjavaScriptEnabled\n\t}) => {\n\t\ttest.skip(!javaScriptEnabled);\n\n\t\tawait page.goto('/basepath/remote');\n\t\tawait expect(page.locator('#count')).toHaveText('');\n\t\tawait page.locator('input').fill('1');\n\t\tawait page.locator('button', { hasText: 'submit' }).click();\n\t\tawait expect(page.locator('#count')).toHaveText('1');\n\t});\n});\n\ntest.describe('trailing slash', () => {\n\tif (!process.env.DEV) {\n\t\ttest('trailing slash server prerendered without server load', async ({\n\t\t\tpage,\n\t\t\tclicknav,\n\t\t\tjavaScriptEnabled\n\t\t}) => {\n\t\t\tif (!javaScriptEnabled) return;\n\n\t\t\tawait page.goto('/basepath/trailing-slash-server');\n\n\t\t\tawait clicknav('a[href=\"/basepath/trailing-slash-server/prerender\"]');\n\t\t\texpect(await page.textContent('h2')).toBe('/basepath/trailing-slash-server/prerender/');\n\t\t});\n\t}\n});\n\ntest.describe('Service worker', () => {\n\tif (process.env.DEV) {\n\t\ttest('import proxy /basepath/service-worker.js', async ({ request }) => {\n\t\t\tconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\t\t\tconst response = await request.get('/basepath/service-worker.js');\n\t\t\tconst content = await response.text();\n\t\t\texpect(content).toEqual(\n\t\t\t\t`import '${path.join('/basepath', '/@fs', __dirname, '../src/service-worker.js')}';`\n\t\t\t);\n\t\t});\n\n\t\treturn;\n\t}\n\n\ttest('build /basepath/service-worker.js', async ({ baseURL, request }) => {\n\t\tconst response = await request.get('/basepath/service-worker.js');\n\t\tconst content = await response.text();\n\n\t\tconst fn = new Function('self', 'location', content);\n\n\t\tconst self = {\n\t\t\taddEventListener: () => {},\n\t\t\tbase: null,\n\t\t\tbuild: null\n\t\t};\n\n\t\tconst pathname = '/basepath/service-worker.js';\n\n\t\tfn(self, {\n\t\t\thref: baseURL + pathname,\n\t\t\tpathname\n\t\t});\n\n\t\texpect(self.base).toBe('/basepath');\n\t\texpect(self.build?.[0]).toMatch(/\\/basepath\\/_app\\/immutable\\/bundle\\.[\\w-]+\\.js/);\n\t\texpect(self.image_src).toMatch(/\\/basepath\\/_app\\/immutable\\/assets\\/image\\.[\\w-]+\\.jpg/);\n\t});\n\n\ttest('does not register /basepath/service-worker.js', async ({ page }) => {\n\t\tawait page.goto('/basepath');\n\t\texpect(await page.content()).not.toMatch(/navigator\\.serviceWorker/);\n\t});\n});\n\ntest.describe(\"bundleStrategy: 'single'\", () => {\n\ttest.skip(({ javaScriptEnabled }) => !javaScriptEnabled || !!process.env.DEV);\n\n\ttest('loads a single js file and a single css file', async ({ page }) => {\n\t\t/** @type {string[]} */\n\t\tconst requests = [];\n\t\tpage.on('request', (r) => requests.push(new URL(r.url()).pathname));\n\n\t\tawait page.goto('/basepath');\n\n\t\tawait Promise.all([\n\t\t\tpage.waitForTimeout(100), // wait for preloading to start\n\t\t\tpage.waitForLoadState('networkidle') // wait for preloading to finish\n\t\t]);\n\n\t\texpect(requests.filter((req) => req.endsWith('.js')).length).toBe(1);\n\t\texpect(requests.filter((req) => req.endsWith('.css')).length).toBe(1);\n\t});\n\n\ttest('app.decoders is accessed only after app has been initialised', async ({ page }) => {\n\t\tawait page.goto('/basepath/deserialize');\n\t\tawait expect(page.locator('p')).toHaveText('Hello world!');\n\t});\n\n\ttest('serialization works with streaming', async ({ page }) => {\n\t\tawait page.goto('/basepath/serialization-stream');\n\t\tawait expect(page.locator('h1', { hasText: 'It works!' })).toBeVisible();\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options-2/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tclearScreen: false,\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/package.json",
    "content": "{\n\t\"name\": \"test-options-3\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/adapter-node\": \"workspace:^\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div style=\"display: contents\">%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/src/hooks.js",
    "content": "import { Foo } from '$lib';\n\n/** @type {import(\"@sveltejs/kit\").Transport} */\nexport const transport = {\n\tFoo: {\n\t\tencode: (value) => value instanceof Foo && [value.message],\n\t\tdecode: ([message]) => new Foo(message)\n\t}\n};\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/src/lib/index.js",
    "content": "export class Foo {\n\tconstructor(message) {\n\t\tthis.message = message;\n\t}\n\n\tbar() {\n\t\treturn this.message + '!';\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/src/routes/+layout.svelte",
    "content": "<script>\n\timport { setup } from '../../../../setup.js';\n\n\tsetup();\n</script>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/src/routes/serialization-stream/+page.server.js",
    "content": "import { Foo } from '$lib';\n\nexport const load = () => {\n\treturn {\n\t\tfoo: Promise.resolve(new Foo('It works'))\n\t};\n};\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/src/routes/serialization-stream/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>\n\t{#await data.foo}\n\t\tLoading...\n\t{:then result}\n\t\t{result.bar()}\n\t{/await}\n</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\toutput: {\n\t\t\tbundleStrategy: 'inline'\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/test/test.js",
    "content": "import process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest.describe(\"bundleStrategy: 'inline'\", () => {\n\ttest.skip(({ javaScriptEnabled }) => !javaScriptEnabled || !!process.env.DEV);\n\n\ttest('serialization works with streaming', async ({ page }) => {\n\t\tawait page.goto('/serialization-stream');\n\t\tawait expect(page.locator('h1', { hasText: 'It works!' })).toBeVisible();\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/options-3/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tclearScreen: false,\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/.gitignore",
    "content": "/test/errors.json\n!/.env\n/src/routes/routing/symlink-from"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/README.md",
    "content": "Please do not edit this app unless you're absolutely sure it's not going to affect the tests.\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/jsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"moduleResolution\": \"bundler\"\n\t}\n\t// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias\n\t// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files\n\t//\n\t// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes\n\t// from the referenced tsconfig.json - TypeScript does not merge them in\n}\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/package.json",
    "content": "{\n\t\"name\": \"test-prerendered-app-error-pages\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"type\": \"module\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"check\": \"svelte-kit sync && svelte-check --tsconfig ./jsconfig.json\",\n\t\t\"check:watch\": \"svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch\",\n\t\t\"test\": \"pnpm test:dev && pnpm test:build\",\n\t\t\"test:dev\": \"DEV=true playwright test\",\n\t\t\"test:build\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/src/app.d.ts",
    "content": "// See https://svelte.dev/docs/kit/types#app.d.ts\n// for information about these interfaces\ndeclare global {\n\tnamespace App {\n\t\t// interface Error {}\n\t\t// interface Locals {}\n\t\t// interface PageData {}\n\t\t// interface PageState {}\n\t\t// interface Platform {}\n\t}\n}\n\nexport {};\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body data-sveltekit-preload-data=\"hover\">\n\t\t<div style=\"display: contents\">%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/src/routes/+error.svelte",
    "content": "<p>This is your custom error page.</p>\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/src/routes/+layout.ts",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/src/routes/+page.svelte",
    "content": "<p>\n\tThis app exists to assert that an app with only prerendered routes successfully renders custom\n\terror pages.\n</p>\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/test/test.js",
    "content": "import { expect } from '@playwright/test';\nimport { test } from '../../../utils.js';\n\ntest.describe.configure({ mode: 'parallel' });\n\ntest('renders error page on nonexistent route', async ({ page }) => {\n\tawait page.goto('/nonexistent', { wait_for_started: false });\n\texpect(await page.textContent('p')).toBe('This is your custom error page.');\n});\n"
  },
  {
    "path": "packages/kit/test/apps/prerendered-app-error-pages/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n});\n"
  },
  {
    "path": "packages/kit/test/apps/read-file-test/[file].txt",
    "content": "Imported with url glob from the read-file test in basics. Placed here outside the app folder to force a /@fs prefix 😎\n"
  },
  {
    "path": "packages/kit/test/apps/test.svelte",
    "content": "<script>\n\tlet { foo = true }: { foo: boolean } = $props();\n</script>\n"
  },
  {
    "path": "packages/kit/test/apps/writes/.gitignore",
    "content": "/test/errors.json"
  },
  {
    "path": "packages/kit/test/apps/writes/package.json",
    "content": "{\n\t\"name\": \"test-writes\",\n\t\"private\": true,\n\t\"version\": \"0.0.2-next.0\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"pnpm test:dev && pnpm test:build\",\n\t\t\"test:dev\": \"DEV=true playwright test\",\n\t\t\"test:build\": \"playwright test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/writes/playwright.config.js",
    "content": "export { config as default } from '../../utils.js';\n"
  },
  {
    "path": "packages/kit/test/apps/writes/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<link rel=\"icon\" type=\"image/png\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div style=\"display: contents\">%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/apps/writes/src/global.d.ts",
    "content": "declare global {\n\tinterface Window {\n\t\tmounted: number;\n\t}\n}\n\nexport {};\n"
  },
  {
    "path": "packages/kit/test/apps/writes/src/routes/+layout.svelte",
    "content": "<script>\n\timport { setup } from '../../../../setup.js';\n\n\tsetup();\n</script>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/apps/writes/src/routes/double-mount/+page.svelte",
    "content": "<script context=\"module\">\n\timport { browser } from '$app/environment';\n\n\tif (browser) {\n\t\twindow.mounted = window.mounted || 0;\n\t}\n</script>\n\n<script>\n\timport { goto } from '$app/navigation';\n\timport { onMount } from 'svelte';\n\n\tlet mounted = 0;\n\n\tonMount(() => {\n\t\tmounted = window.mounted += 1;\n\t});\n</script>\n\n<h1>mounted: {browser ? mounted : 0}</h1>\n<button on:click={() => goto('/double-mount')}>click me</button>\n<span hidden>PLACEHOLDER:0</span>\n"
  },
  {
    "path": "packages/kit/test/apps/writes/src/routes/new-route/+page.svelte",
    "content": "<h1>Great success!</h1>\n"
  },
  {
    "path": "packages/kit/test/apps/writes/src/routes/universal/+page.js",
    "content": "document.body.style.backgroundColor = 'red';\n\nexport const ssr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/writes/src/routes/universal/+page.svelte",
    "content": "<p>hello world</p>\n"
  },
  {
    "path": "packages/kit/test/apps/writes/src/routes/universal/parent-changed/+layout.js",
    "content": "export const ssr = false;\n"
  },
  {
    "path": "packages/kit/test/apps/writes/src/routes/universal/parent-changed/+page.js",
    "content": "document.body.style.backgroundColor = 'red';\n"
  },
  {
    "path": "packages/kit/test/apps/writes/src/routes/universal/parent-changed/+page.svelte",
    "content": "<p>hello world</p>\n"
  },
  {
    "path": "packages/kit/test/apps/writes/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tprerender: {\n\t\t\thandleHttpError: 'warn'\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/apps/writes/test/test.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { expect } from '@playwright/test';\nimport { fileURLToPath } from 'node:url';\nimport { test } from '../../../utils.js';\n\n/** @typedef {import('@playwright/test').Response} Response */\n\ntest.describe.configure({ mode: 'serial' });\n\ntest.describe('Filesystem updates', () => {\n\tif (process.env.DEV) {\n\t\ttest('New route is immediately available in dev', async ({ page }) => {\n\t\t\tawait page.goto('/new-route');\n\n\t\t\t// hash the filename so that it won't conflict with\n\t\t\t// future test file that has the same name\n\t\t\tconst route = 'zzzz' + Date.now();\n\t\t\tconst content = 'Hello new route';\n\t\t\tconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\t\t\tconst filepath = path.join(__dirname, `../src/routes/new-route/${route}/+page.svelte`);\n\t\t\tconst dir = path.dirname(filepath);\n\n\t\t\ttry {\n\t\t\t\tfs.mkdirSync(dir);\n\t\t\t\tfs.writeFileSync(filepath, `<h1>${content}</h1>`);\n\t\t\t\tawait page.waitForTimeout(500); // this is the rare time we actually need waitForTimeout; we have no visibility into whether the module graph has been invalidated\n\t\t\t\tawait page.goto(`/new-route/${route}`);\n\n\t\t\t\texpect(await page.textContent('h1')).toBe(content);\n\t\t\t} finally {\n\t\t\t\tfs.rmSync(dir, { recursive: true });\n\t\t\t}\n\t\t});\n\t}\n\n\ttest('Components are not double-mounted', async ({ page, javaScriptEnabled }) => {\n\t\tconst file = fileURLToPath(new URL('../src/routes/double-mount/+page.svelte', import.meta.url));\n\t\tconst contents = fs.readFileSync(file, 'utf-8');\n\n\t\tconst mounted = javaScriptEnabled ? 1 : 0;\n\n\t\ttry {\n\t\t\t// we write to the file, to trigger HMR invalidation\n\t\t\tfs.writeFileSync(file, contents.replace(/PLACEHOLDER:\\d+/, `PLACEHOLDER:${Date.now()}`));\n\t\t\tawait page.goto('/double-mount');\n\t\t\texpect(await page.textContent('h1')).toBe(`mounted: ${mounted}`);\n\t\t\tawait page.click('button');\n\t\t\tawait page.waitForTimeout(100);\n\t\t\texpect(await page.textContent('h1')).toBe(`mounted: ${mounted}`);\n\t\t} finally {\n\t\t\tfs.writeFileSync(file, contents.replace(/PLACEHOLDER:\\d+/, 'PLACEHOLDER:0'));\n\t\t}\n\t});\n\n\ttest('Universal node is updated when page options change', async ({\n\t\tpage,\n\t\tjavaScriptEnabled,\n\t\tget_computed_style\n\t}) => {\n\t\ttest.skip(!process.env.DEV || !javaScriptEnabled);\n\n\t\tconst file = fileURLToPath(new URL('../src/routes/universal/+page.js', import.meta.url));\n\t\tconst contents = fs.readFileSync(file, 'utf-8');\n\n\t\ttry {\n\t\t\tfs.writeFileSync(file, contents.replace(/export const ssr = false;\\n/, ''));\n\t\t\tawait page.goto('/universal', { wait_for_started: false });\n\t\t\texpect(await get_computed_style('body', 'background-color')).not.toBe('rgb(255, 0, 0)');\n\t\t\tawait expect(page.locator('h1')).toHaveText('Internal Error');\n\t\t} finally {\n\t\t\tfs.writeFileSync(file, contents);\n\t\t}\n\n\t\tawait page.waitForTimeout(500); // this is the rare time we actually need waitForTimeout; we have no visibility into whether the module graph has been invalidated\n\t\t// a reload is required because Vite HMR doesn't trigger if the page has never loaded successfully\n\t\tawait page.reload();\n\t\texpect(await get_computed_style('body', 'background-color')).toBe('rgb(255, 0, 0)');\n\n\t\ttry {\n\t\t\tfs.writeFileSync(file, contents.replace(/export const ssr = .*;/, 'export const ssr = !1;'));\n\t\t\tawait page.waitForTimeout(500); // this is the rare time we actually need waitForTimeout; we have no visibility into whether the module graph has been invalidated\n\t\t\texpect(await get_computed_style('body', 'background-color')).not.toBe('rgb(255, 0, 0)');\n\t\t\tawait expect(page.locator('h1')).toHaveText('Internal Error');\n\t\t} finally {\n\t\t\tfs.writeFileSync(file, contents.replace(/\\\\nexport const ssr = false;\\\\n/, ''));\n\t\t}\n\t});\n\n\ttest('Universal node is updated when parent page options change', async ({\n\t\tpage,\n\t\tjavaScriptEnabled,\n\t\tget_computed_style\n\t}) => {\n\t\ttest.skip(!process.env.DEV || !javaScriptEnabled);\n\n\t\tconst file = fileURLToPath(\n\t\t\tnew URL('../src/routes/universal/parent-changed/+layout.js', import.meta.url)\n\t\t);\n\t\tconst contents = fs.readFileSync(file, 'utf-8');\n\n\t\ttry {\n\t\t\tawait page.goto('/universal/parent-changed');\n\t\t\texpect(await get_computed_style('body', 'background-color')).toBe('rgb(255, 0, 0)');\n\n\t\t\tfs.writeFileSync(file, contents.replace(/export const ssr = false;/, ''));\n\t\t\tawait page.waitForTimeout(500); // this is the rare time we actually need waitForTimeout; we have no visibility into whether the module graph has been invalidated\n\t\t\texpect(await get_computed_style('body', 'background-color')).not.toBe('rgb(255, 0, 0)');\n\t\t\tawait expect(page.locator('h1')).toHaveText('Internal Error');\n\t\t} finally {\n\t\t\tfs.writeFileSync(file, contents);\n\t\t}\n\t});\n});\n"
  },
  {
    "path": "packages/kit/test/apps/writes/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"noEmit\": true,\n\t\t\"resolveJsonModule\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/apps/writes/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\tclearScreen: false,\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/package.json",
    "content": "{\n\t\"name\": \"prerenderable-incorrect-fragment\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/adapter-auto\": \"workspace:^\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/src/routes/+layout.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/src/routes/[slug]/[notSpecific]/+page.ts",
    "content": "/** @type {import('./$types').EntryGenerator} */\nexport const entries = () => {\n\treturn [{ slug: 'whatever', notSpecific: 'specific' }];\n};\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/src/routes/[slug]/specific/+page.svelte",
    "content": "<div>This will be matched</div>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/svelte.config.js",
    "content": "import adapter from '../../../../../adapter-auto/index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\n\tclearScreen: false,\n\n\tlogLevel: 'silent',\n\n\tplugins: [sveltekit()],\n\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-remote-function-error/package.json",
    "content": "{\n\t\"name\": \"prerenderable-remote-function-error\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/adapter-auto\": \"workspace:^\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-remote-function-error/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-remote-function-error/src/routes/+layout.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-remote-function-error/src/routes/+page.svelte",
    "content": "<script>\n\timport { throws } from './data.remote.ts';\n</script>\n\n{#await throws() then value}\n\t{value}\n{/await}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-remote-function-error/src/routes/data.remote.ts",
    "content": "import { prerender } from '$app/server';\n\nexport const throws = prerender(() => {\n\tthrow new Error('remote function blew up');\n});\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-remote-function-error/svelte.config.js",
    "content": "import adapter from '../../../../../adapter-auto/index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter(),\n\n\t\texperimental: {\n\t\t\tremoteFunctions: true\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-remote-function-error/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"allowImportingTsExtensions\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerender-remote-function-error/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\n\tclearScreen: false,\n\n\tlogLevel: 'silent',\n\n\tplugins: [sveltekit()],\n\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/package.json",
    "content": "{\n\t\"name\": \"prerenderable-incorrect-fragment\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/adapter-auto\": \"workspace:^\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/src/routes/+layout.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/src/routes/+page.svelte",
    "content": "<a href=\"foo#missing\">missing</a>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/src/routes/foo/+page.svelte",
    "content": "<h1 id=\"exists\">foo</h1>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/svelte.config.js",
    "content": "import adapter from '../../../../../adapter-auto/index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\n\tclearScreen: false,\n\n\tlogLevel: 'silent',\n\n\tplugins: [sveltekit()],\n\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-not-prerendered/package.json",
    "content": "{\n\t\"name\": \"prerenderable-not-prerendered\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/adapter-auto\": \"workspace:^\",\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-not-prerendered/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-not-prerendered/src/routes/+page.svelte",
    "content": "<a href=\"/foo\">this page is not prerendered, so this link is not crawled</a>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-not-prerendered/src/routes/[x]/+page.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-not-prerendered/src/routes/[x]/+page.svelte",
    "content": "<h1>foo</h1>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-not-prerendered/svelte.config.js",
    "content": "import adapter from '../../../../../adapter-auto/index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-not-prerendered/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/prerenderable-not-prerendered/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\n\tclearScreen: false,\n\n\tlogLevel: 'silent',\n\n\tplugins: [sveltekit()],\n\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env/.env",
    "content": "SHOULD_EXPLODE=boom"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n!.env\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env/package.json",
    "content": "{\n\t\"name\": \"private-dynamic-env\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"check:watch\": \"svelte-check --watch\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env/src/routes/+page.svelte",
    "content": "<script>\n\timport { env } from '$env/dynamic/private';\n</script>\n\n<p>{env.SHOULD_EXPLODE}</p>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/.env",
    "content": "SHOULD_EXPLODE=boom"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n!.env\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json",
    "content": "{\n\t\"name\": \"private-dynamic-env-dynamic-import\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"check:watch\": \"svelte-check --watch\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/src/routes/+page.svelte",
    "content": "<script>\n\tconst p = import('$env/dynamic/private');\n</script>\n\n{#await p}\n\t<p>Awaiting...</p>\n{:then envModule}\n\t<p>{envModule.env.SHOULD_EXPLODE}</p>\n{/await}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env/.env",
    "content": "SHOULD_EXPLODE=boom"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n!.env\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env/package.json",
    "content": "{\n\t\"name\": \"private-static-env\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"check:watch\": \"svelte-check --watch\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env/src/routes/+page.svelte",
    "content": "<script>\n\timport { SHOULD_EXPLODE } from '$env/static/private';\n</script>\n\n<p>{SHOULD_EXPLODE}</p>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env-dynamic-import/.env",
    "content": "SHOULD_EXPLODE=boom"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env-dynamic-import/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n!.env\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env-dynamic-import/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json",
    "content": "{\n\t\"name\": \"private-static-env-dynamic-import\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"check:watch\": \"svelte-check --watch\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env-dynamic-import/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env-dynamic-import/src/routes/+page.svelte",
    "content": "<script>\n\tconst p = import('$env/static/private');\n</script>\n\n{#await p}\n\t<p>Awaiting...</p>\n{:then envModule}\n\t<p>{envModule.SHOULD_EXPLODE}</p>\n{/await}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env-dynamic-import/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env-dynamic-import/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/private-static-env-dynamic-import/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()]\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder/package.json",
    "content": "{\n\t\"name\": \"server-only-folder\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"check:watch\": \"svelte-check --watch\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder/src/lib/server/something/private.js",
    "content": "export const should_explode = 'boom';\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder/src/routes/+page.svelte",
    "content": "<script>\n\timport { should_explode } from '$lib/server/something/private.js';\n</script>\n\n<p>{should_explode}</p>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/package.json",
    "content": "{\n\t\"name\": \"server-only-folder-dynamic-import\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"check:watch\": \"svelte-check --watch\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/src/lib/server/something/private.js",
    "content": "export const should_explode = 'boom';\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/src/routes/+page.svelte",
    "content": "<script>\n\tconst mod = import('$lib/server/something/private.js');\n</script>\n\n{#await mod then resolved}\n\t<p>{resolved.should_explode}</p>\n{/await}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module/package.json",
    "content": "{\n\t\"name\": \"server-only-module\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"check:watch\": \"svelte-check --watch\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module/src/lib/test.server.js",
    "content": "export const should_explode = 'boom';\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module/src/routes/+page.svelte",
    "content": "<script>\n\timport { should_explode } from '$lib/test.server.js';\n</script>\n\n<p>{should_explode}</p>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module-dynamic-import/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module-dynamic-import/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module-dynamic-import/package.json",
    "content": "{\n\t\"name\": \"server-only-module-dynamic-import\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"check:watch\": \"svelte-check --watch\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module-dynamic-import/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module-dynamic-import/src/lib/test.server.js",
    "content": "export const should_explode = 'boom';\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module-dynamic-import/src/routes/+page.svelte",
    "content": "<script>\n\tconst mod = import('$lib/test.server.js');\n</script>\n\n{#await mod then resolved}\n\t<p>{resolved.should_explode}</p>\n{/await}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module-dynamic-import/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module-dynamic-import/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/server-only-module-dynamic-import/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/.env",
    "content": "PUBLIC_SHOULD_EXPLODE=boom"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n!.env\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/package.json",
    "content": "{\n\t\"name\": \"service-worker-dynamic-public-env\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"check:watch\": \"svelte-check --watch\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/src/routes/+page.svelte",
    "content": "<h1>Bonjour</h1>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/src/service-worker.js",
    "content": "import { env } from '$env/dynamic/public';\n\nconsole.log('Logging dynamic public env', env.PUBLIC_SHOULD_EXPLODE);\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-private-env/.env",
    "content": "SHOULD_EXPLODE=boom"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-private-env/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n!.env\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-private-env/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-private-env/package.json",
    "content": "{\n\t\"name\": \"service-worker-private-env\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"check:watch\": \"svelte-check --watch\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-private-env/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-private-env/src/routes/+page.svelte",
    "content": "<h1>Bonjour</h1>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-private-env/src/service-worker.js",
    "content": "import { env } from '$env/dynamic/private';\n\nconsole.log('Logging private env', env);\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-private-env/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-private-env/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/service-worker-private-env/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/syntax-error/.gitignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\n.env.*\n!.env.example\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/syntax-error/.npmrc",
    "content": "engine-strict=true\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/syntax-error/package.json",
    "content": "{\n\t\"name\": \"syntax-error\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/syntax-error/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t<div>%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/syntax-error/src/lib/test.server.js",
    "content": "export const should_explode = 'boom';\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/syntax-error/src/routes/+page.svelte",
    "content": "<div"
  },
  {
    "path": "packages/kit/test/build-errors/apps/syntax-error/svelte.config.js",
    "content": "/** @type {import('@sveltejs/kit').Config} */\nconst config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/syntax-error/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/apps/syntax-error/vite.config.js",
    "content": "import { sveltekit } from '@sveltejs/kit/vite';\nimport path from 'node:path';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tplugins: [sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/build-errors/env.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport { execSync } from 'node:child_process';\nimport path from 'node:path';\nimport process from 'node:process';\n\nconst timeout = 60_000;\n\n// ordinarily server-only modules are allowed during testing, since Vitest can't differentiate\n/** @type {Record<string, any>} */\nconst env = { ...process.env, TEST: false };\n\ntest('$env/dynamic/private is not statically importable from the client', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/private-dynamic-env'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout,\n\t\t\t\tenv\n\t\t\t}),\n\t\t/.*Cannot import \\$env\\/dynamic\\/private into code that runs in the browser.*/gs\n\t);\n});\n\ntest('$env/dynamic/private is not dynamically importable from the client', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/private-dynamic-env-dynamic-import'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout,\n\t\t\t\tenv\n\t\t\t}),\n\t\t/.*Cannot import \\$env\\/dynamic\\/private into code that runs in the browser.*/gs\n\t);\n});\n\ntest('$env/static/private is not statically importable from the client', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/private-static-env'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout,\n\t\t\t\tenv\n\t\t\t}),\n\t\t/.*Cannot import \\$env\\/static\\/private into code that runs in the browser.*/gs\n\t);\n});\n\ntest('$env/static/private is not dynamically importable from the client', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/private-static-env-dynamic-import'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout,\n\t\t\t\tenv\n\t\t\t}),\n\t\t/.*Cannot import \\$env\\/static\\/private into code that runs in the browser.*/gs\n\t);\n});\n\ntest('$env/dynamic/private is not importable from the service worker', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/service-worker-private-env'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout,\n\t\t\t\tenv\n\t\t\t}),\n\t\t/.*Cannot import \\$env\\/dynamic\\/private into service-worker code.*/gs\n\t);\n});\n\ntest('$env/dynamic/public is not importable from the service worker', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/service-worker-dynamic-public-env'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout,\n\t\t\t\tenv\n\t\t\t}),\n\t\t/.*Cannot import \\$env\\/dynamic\\/public into service-worker code.*/gs\n\t);\n});\n"
  },
  {
    "path": "packages/kit/test/build-errors/package.json",
    "content": "{\n\t\"name\": \"test-build-errors\",\n\t\"private\": true,\n\t\"version\": \"0.0.0-next.0\",\n\t\"scripts\": {\n\t\t\"test\": \"vitest run\",\n\t\t\"test:cross-platform:build\": \"vitest run\"\n\t},\n\t\"type\": \"module\",\n\t\"devDependencies\": {\n\t\t\"vitest\": \"catalog:\"\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/build-errors/prerender.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport { execSync } from 'node:child_process';\nimport path from 'node:path';\nimport { EOL } from 'node:os';\nimport process from 'node:process';\n\nconst timeout = 60_000;\n\ntest('prerenderable routes must be prerendered', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/prerenderable-not-prerendered'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout\n\t\t\t}),\n\t\t/The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app:\\r?\\n {2}- \\/\\[x\\]/gs\n\t);\n});\n\ntest('entry generators should match their own route', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/prerender-entry-generator-mismatch'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout\n\t\t\t}),\n\t\t`Error: The entries export from /[slug]/[notSpecific] generated entry /whatever/specific, which was matched by /[slug]/specific - see the \\`handleEntryGeneratorMismatch\\` option in https://svelte.dev/docs/kit/configuration#prerender for more info.${EOL}To suppress or handle this error, implement \\`handleEntryGeneratorMismatch\\` in https://svelte.dev/docs/kit/configuration#prerender`\n\t);\n});\n\ntest('an error in a `prerender` function should fail the build', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/prerender-remote-function-error'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout\n\t\t\t}),\n\t\t/remote function blew up/\n\t);\n});\n"
  },
  {
    "path": "packages/kit/test/build-errors/server-only.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport { execSync } from 'node:child_process';\nimport path from 'node:path';\nimport process from 'node:process';\n\nconst timeout = 60_000;\n\n// ordinarily server-only modules are allowed during testing, since Vitest can't differentiate\n/** @type {Record<string, any>} */\nconst env = { ...process.env, TEST: false };\n\ntest('$lib/*.server.* is not statically importable from the client', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/server-only-module'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout,\n\t\t\t\tenv\n\t\t\t}),\n\t\t/.*Cannot import \\$lib\\/test.server.js into code that runs in the browser.*/gs\n\t);\n});\n\ntest('$lib/*.server.* is not dynamically importable from the client', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/server-only-module-dynamic-import'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout,\n\t\t\t\tenv\n\t\t\t}),\n\t\t/.*Cannot import \\$lib\\/test.server.js into code that runs in the browser.*/gs\n\t);\n});\n\ntest('$lib/server/* is not statically importable from the client', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/server-only-folder'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout,\n\t\t\t\tenv\n\t\t\t}),\n\t\t/.*Cannot import \\$lib\\/server\\/something\\/private.js into code that runs in the browser.*/gs\n\t);\n});\n\ntest('$lib/server/* is not dynamically importable from the client', { timeout }, () => {\n\tassert.throws(\n\t\t() =>\n\t\t\texecSync('pnpm build', {\n\t\t\t\tcwd: path.join(process.cwd(), 'apps/server-only-folder-dynamic-import'),\n\t\t\t\tstdio: 'pipe',\n\t\t\t\ttimeout,\n\t\t\t\tenv\n\t\t\t}),\n\t\t/.*Cannot import \\$lib\\/server\\/something\\/private.js into code that runs in the browser.*/gs\n\t);\n});\n"
  },
  {
    "path": "packages/kit/test/build-errors/syntax-error.spec.js",
    "content": "import { assert, test } from 'vitest';\nimport { execSync } from 'node:child_process';\nimport path from 'node:path';\nimport process from 'node:process';\n\nconst timeout = 60_000;\n\ntest('$lib/*.server.* is not statically importable from the client', { timeout }, () => {\n\ttry {\n\t\texecSync('pnpm build', {\n\t\t\tcwd: path.join(process.cwd(), 'apps/syntax-error'),\n\t\t\tstdio: 'pipe',\n\t\t\ttimeout\n\t\t});\n\t} catch (err) {\n\t\tconst message = /** @type {Error} */ (err).message;\n\t\tassert.ok(\n\t\t\tmessage.includes('Unexpected end of input'),\n\t\t\t`received unexpected exception message ${message}`\n\t\t);\n\t\treturn;\n\t}\n\tthrow new Error();\n});\n"
  },
  {
    "path": "packages/kit/test/build-errors/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"esnext\",\n\t\t\"module\": \"esnext\",\n\t\t\"moduleResolution\": \"node\",\n\t\t\"allowSyntheticDefaultImports\": true\n\t},\n\t\"include\": [\"./*\"]\n}\n"
  },
  {
    "path": "packages/kit/test/github-flaky-warning-reporter.js",
    "content": "import { appendFileSync } from 'node:fs';\n\n/**\n * @class\n * @implements {import('@playwright/test/reporter').Reporter}\n */\nexport default class GithubFlakyWarningReporter {\n\t/**\n\t * @type {{ file: string; line: number; title: string; message: string; }[]}\n\t */\n\t_flaky = [];\n\n\tonBegin() {\n\t\tthis._flaky = [];\n\t}\n\t/**\n\t * @param test {import('@playwright/test/reporter').TestCase}\n\t */\n\tonTestEnd(test) {\n\t\tif (test.outcome() === 'flaky') {\n\t\t\tconst { file, line } = test.location;\n\t\t\tconst title = `flaky test: ${test.title}`;\n\t\t\tconst message = `retries: ${test.retries}`;\n\t\t\tthis._flaky.push({ file, line, title, message });\n\t\t}\n\t}\n\n\tonEnd() {\n\t\tconst output = this._flaky\n\t\t\t.map(\n\t\t\t\t({ file, line, title, message }) =>\n\t\t\t\t\t`::warning file=${file},line=${line},title=${title}::${message}\\n`\n\t\t\t)\n\t\t\t.join('');\n\n\t\tappendFileSync(new URL('../../../_tmp_flaky_test_output.txt', import.meta.url), output);\n\t}\n\n\tprintsToStdio() {\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "packages/kit/test/mocks/path.js",
    "content": "export const base = '';\nexport const assets = '';\nexport const app_dir = '_app';\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/.env",
    "content": "PRIVATE_STATIC=\"accessible to server-side code/replaced at build time\"\nPRIVATE_DYNAMIC=\"accessible to server-side code/evaluated at run time\"\n\nPUBLIC_STATIC=\"accessible anywhere/replaced at build time\"\nPUBLIC_DYNAMIC=\"accessible anywhere/evaluated at run time\"\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/.gitignore",
    "content": "!.env\n\nmissing_ids\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/globalSetup.js",
    "content": "import { execSync } from 'node:child_process';\n\nexport default function setup() {\n\texecSync('svelte-kit sync && pnpm run build');\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/package.json",
    "content": "{\n\t\"name\": \"prerendering-test-basics\",\n\t\"private\": true,\n\t\"version\": \"0.0.2-next.0\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"rm -rf ./missing_ids && mkdir ./missing_ids && vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"svelte-kit sync && vitest run\",\n\t\t\"test:cross-platform\": \"pnpm test\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/app.d.ts",
    "content": "/// <reference types=\"@sveltejs/kit\" />;\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t%sveltekit.body%\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/hooks.server.js",
    "content": "import { building } from '$app/environment';\n\nconst initial_building = building;\n\n/** @type {import('@sveltejs/kit').Handle} */\nexport const handle = async ({ event, resolve }) => {\n\tif (event.url.pathname === '/prerendering-true' && building) {\n\t\treturn await resolve(event, {\n\t\t\ttransformPageChunk: ({ html }) =>\n\t\t\t\thtml\n\t\t\t\t\t.replace('__INITIAL_PRERENDERING__', String(initial_building))\n\t\t\t\t\t.replace('__PRERENDERING__', String(building))\n\t\t});\n\t}\n\treturn await resolve(event, {\n\t\tfilterSerializedResponseHeaders: (name) => name === 'content-type'\n\t});\n};\n\n// this code is here to make sure that we kill the process\nsetInterval(() => {\n\tconsole.log('process is still alive');\n}, 5000);\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/(grouped)/grouped/+page.svelte",
    "content": "<h1>grouped</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/+layout.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tmessage: 'hello'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.message}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/encoding/[path]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.params.path} / {page.url.pathname}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/encoding/[path].json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n/** @type {import('./$types').RequestHandler} */\nexport function GET({ params }) {\n\treturn json({\n\t\tpath: params.path\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/encoding/path with spaces/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst a = await fetch('/encoding/path with spaces.json');\n\tconst b = await fetch('/encoding/path%20with%20encoded%20spaces.json');\n\n\treturn {\n\t\ta: await a.json(),\n\t\tb: await b.json()\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/encoding/path with spaces/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p id=\"a\">{data.a.path}</p>\n<p id=\"b\">{data.b.path}</p>\n\n<a href=\"/encoding/dynamic path with spaces\">dynamic path with spaces</a>\n<a href=\"/encoding/dynamic%20path%20with%20encoded%20spaces\">dynamic path with encoded spaces</a>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/encoding/redirect/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load() {\n\tredirect(307, '/encoding/redirected%20path%20with%20encoded%20spaces');\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/encoding/redirect/+page.svelte",
    "content": ""
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/encöded-hash-link/+page.svelte",
    "content": "<h2 id=\"encöded\">\n\t<a href=\"#encöded\">encöded</a>\n</h2>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/env/+page.server.js",
    "content": "import { PRIVATE_STATIC } from '$env/static/private';\n\nexport function load() {\n\treturn {\n\t\tPRIVATE_STATIC\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/env/+page.svelte",
    "content": "<script>\n\timport { PUBLIC_STATIC } from '$env/static/public';\n\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<p id=\"static-private\">PRIVATE_STATIC: {data.PRIVATE_STATIC}</p>\n<p id=\"static-public\">PUBLIC_STATIC: {PUBLIC_STATIC}</p>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-404/+page.js",
    "content": "/** @type {import('./$types').PageLoad} */\nexport async function load({ fetch }) {\n\tconst { status } = await fetch('/missing.json');\n\n\treturn { status };\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-404/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>status: {data.status}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-endpoint/also-not-buffered/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst url = '/fetch-endpoint/not-buffered.json';\n\tconst res = await fetch(url);\n\n\treturn {\n\t\theaders: res.headers\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-endpoint/also-not-buffered/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>content-type: {data.headers.get('content-type')}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-endpoint/buffered/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst url = '/fetch-endpoint/buffered.json';\n\tconst res = await fetch(url);\n\n\treturn await res.json();\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-endpoint/buffered/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>the answer is {data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-endpoint/buffered.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport async function GET() {\n\treturn json({ answer: 42 });\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-endpoint/not-buffered/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst url = '/fetch-endpoint/not-buffered.json';\n\tconst res = await fetch(url);\n\n\treturn {\n\t\theaders: res.headers\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-endpoint/not-buffered/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>content-type: {data.headers.get('content-type')}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-endpoint/not-buffered.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nlet called = false;\n\nexport async function GET() {\n\tif (called) throw new Error('should only be called once');\n\tcalled = true;\n\n\treturn json({ answer: 42 });\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-image/+page.svelte",
    "content": "<img src=\"/fetch-image/image.jpg\" alt=\"\" />\n<img src=\"/fetch-image/image.png\" alt=\"\" />\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/fetch-image/[...slug]/+server.js",
    "content": "import * as fs from 'node:fs';\n\nexport const prerender = true;\n\nexport async function GET({ params }) {\n\tconst slug = params.slug.split('/');\n\tconst extension = slug[0].split('.').pop();\n\n\tconst file = fs.readFileSync(`./static/image.${extension}`);\n\n\treturn new Response(file, {\n\t\theaders: {\n\t\t\t'Content-Type': 'image/' + extension\n\t\t}\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/immutable-headers/+server.js",
    "content": "export const prerender = true;\n\nexport const GET = () => {\n\tconst response = new Response('foo');\n\t// this simulates immutable Response Headers, like those returned by undici\n\tObject.defineProperty(response.headers, 'set', { value: null });\n\treturn response;\n};\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/load-file-with-spaces/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport async function load({ fetch }) {\n\tconst r1 = await fetch('/file%20with%20spaces.json');\n\tconst p1 = await r1.json();\n\n\tconst r2 = await fetch('/file with spaces.json');\n\tconst p2 = await r2.json();\n\n\tif (p1.answer !== p2.answer) {\n\t\tthrow new Error('oops');\n\t}\n\n\treturn p1;\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/load-file-with-spaces/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>answer: {data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/max-age/+page.js",
    "content": "/** @type {import('@sveltejs/kit').Load} */\nexport function load({ setHeaders }) {\n\tsetHeaders({\n\t\t'cache-control': 'max-age=300'\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/max-age/+page.svelte",
    "content": "<h1>This page will be cached for 5 minutes</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/missing-id/+page.svelte",
    "content": "<a href=\"#missing-id\">Bad link</a>\n<a href=\"#top\">Bad link</a>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/optional-params/[[optional]]/+page.svelte",
    "content": "<a href=\"/optional-params/with-value\">Path with Value</a>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/origin/+page.server.js",
    "content": "export const prerender = true;\n\nexport async function load({ fetch }) {\n\tconst res = await fetch('/origin/message.json');\n\tconst { message } = await res.json();\n\n\treturn {\n\t\tmessage\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/origin/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\n\t/** @type {{ data: import('./$types').PageData }} */\n\tlet { data } = $props();\n</script>\n\n<h1>{data.message}</h1>\n<h2>{page.url.origin}</h2>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/origin/message.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\n// TODO remove this when we're able to replace the global `fetch` call in the\n// neighbouring `+page.server.js` with SvelteKit's `fetch`\nexport const prerender = true;\n\nexport function GET() {\n\treturn json({\n\t\tmessage: 'hello'\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/page.html/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tmessage: 'hello'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/page.html/+page.svelte",
    "content": "<script>\n\texport let data;\n</script>\n\n<h1>{data.message}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/prerender-origin/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n\tconst href = new URL('/prerender-origin/dynamic', page.url.origin).href;\n</script>\n\n<a {href}>Please crawl this</a>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/prerender-origin/[dynamic]/+page.svelte",
    "content": "<h1>\n\tThis page will only be discovered if full hrefs that start with config.prerender.origin are\n\tcrawled\n</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/prerendering-true/+page.svelte",
    "content": "<h1>prerendering: __INITIAL_PRERENDERING__/__PRERENDERING__</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/redirect/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load() {\n\tredirect(301, 'https://example.com/redirected');\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/redirect-encoded/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load() {\n\tredirect(301, `https://example.com/redirected?returnTo=${encodeURIComponent('/foo?bar=baz')}`);\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/redirect-malicious/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load() {\n\tredirect(301, 'https://example.com/</' + 'script>alert(\"pwned\")');\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/redirect-relative/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load() {\n\tredirect(301, '/env');\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/redirect-server/+page.server.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load() {\n\tredirect(301, 'https://example.com/redirected');\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/resolve-relative/lv1/+page.svelte",
    "content": "<h1>level 1</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/resolve-relative/lv1/lv2/+page.svelte",
    "content": "<script>\n\timport { resolve } from '$app/paths';\n</script>\n\n<a id=\"resolved-link\" href={resolve('/resolve-relative/lv1')}>go up</a>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/shadowed-get/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tanswer: 42\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/shadowed-get/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>The answer is {data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/shadowed-get/ssr-off/+page.server.js",
    "content": "export const ssr = false;\n\nexport function load() {\n\treturn {\n\t\tanswer: 42\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/shadowed-get/ssr-off/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>The answer is {data.answer}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/shadowed-post/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tanswer: 42\n\t};\n}\n\n/** @type {import('./$types').Actions} */\nexport const actions = {\n\tdefault: () => {}\n};\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/shadowed-post/+page.svelte",
    "content": "<h1>This should not be visible</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/spa-shell/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\nexport const prerender = true;\n\nexport const ssr = false;\n\n/** @type {import('@sveltejs/kit').Load} */\nexport function load() {\n\tredirect(301, 'https://example.com/redirected');\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/spa-shell/+page.server.js",
    "content": "// spa shell should still prererender when +page.server.js exists but it has no load function\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/spa-shell/+page.svelte",
    "content": "<h1>this won't be prerendered</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/trailing-slash/+layout.js",
    "content": "export const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/trailing-slash/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/trailing-slash/+page.svelte",
    "content": "<h1>hello</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/trailing-slash/page/+page.server.js",
    "content": "export function load() {\n\treturn {\n\t\tmessage: 'hello'\n\t};\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/trailing-slash/page/+page.svelte",
    "content": "<script>\n\t/** @type {import('./$types').PageData} */\n\texport let data;\n</script>\n\n<h1>{data.message}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/trailing-slash/standalone-endpoint.json/+server.js",
    "content": "import { json } from '@sveltejs/kit';\n\nexport const prerender = true;\n\nexport async function GET() {\n\treturn json({ answer: 42 });\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/routes/初めまして/+page.svelte",
    "content": "<p>Test for characters that need to be en/decoded during prerendering</p>\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/src/service-worker.js",
    "content": "import process from 'node:process';\nimport { prerendered } from '$service-worker';\n\nconsole.log(prerendered);\n\nif (process.env.MY_ENV === 'MY_ENV DEFINED') {\n\tconsole.log(process.env.MY_ENV);\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/static/file with spaces.json",
    "content": "{ \"answer\": 42 }\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/svelte.config.js",
    "content": "import adapter from '../../../../adapter-static/index.js';\nimport { writeFileSync } from 'node:fs';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter(),\n\n\t\tprerender: {\n\t\t\thandleHttpError: 'warn',\n\t\t\torigin: 'http://prerender.origin',\n\t\t\thandleMissingId: ({ id }) => {\n\t\t\t\twriteFileSync('./missing_ids/index.jsonl', JSON.stringify(id) + ',', 'utf-8');\n\t\t\t}\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/test/tests.spec.js",
    "content": "import fs from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { assert, expect, test } from 'vitest';\nimport { replace_hydration_attrs } from '../../test-utils';\n\nconst build = fileURLToPath(new URL('../build', import.meta.url));\n\n/**\n * @overload\n * @param {string} file\n * @param {BufferEncoding} [encoding]\n * @returns {string}\n */\n/**\n * @overload\n * @param {string} file\n * @param {null} encoding\n * @returns {Buffer<ArrayBufferLike>}\n */\n/**\n * @param {string} file\n * @param {BufferEncoding | null} [encoding]\n * @returns {string | Buffer<ArrayBufferLike>}\n */\nconst read = (file, encoding = 'utf-8') => fs.readFileSync(`${build}/${file}`, encoding);\n\ntest('prerenders /', () => {\n\tconst content = read('index.html');\n\texpect(content).toMatch('<h1>hello</h1>');\n});\n\ntest('renders a redirect', () => {\n\tconst content = read('redirect.html');\n\tassert.equal(\n\t\tcontent,\n\t\t'<script>location.href=\"https://example.com/redirected\";</script><meta http-equiv=\"refresh\" content=\"0;url=https://example.com/redirected\">'\n\t);\n});\n\ntest('renders a server-side redirect', () => {\n\tconst html = read('redirect-server.html');\n\tassert.equal(\n\t\thtml,\n\t\t'<script>location.href=\"https://example.com/redirected\";</script><meta http-equiv=\"refresh\" content=\"0;url=https://example.com/redirected\">'\n\t);\n\n\tconst data = JSON.parse(read('redirect-server/__data.json'));\n\n\texpect(data).toEqual({\n\t\ttype: 'redirect',\n\t\tlocation: 'https://example.com/redirected'\n\t});\n});\n\ntest('does not double-encode redirect locations', () => {\n\tconst content = read('redirect-encoded.html');\n\tassert.equal(\n\t\tcontent,\n\t\t'<script>location.href=\"https://example.com/redirected?returnTo=%2Ffoo%3Fbar%3Dbaz\";</script><meta http-equiv=\"refresh\" content=\"0;url=https://example.com/redirected?returnTo=%2Ffoo%3Fbar%3Dbaz\">'\n\t);\n});\n\ntest('escapes characters in redirect', () => {\n\tconst content = read('redirect-malicious.html');\n\tassert.equal(\n\t\tcontent,\n\t\t'<script>location.href=\"https://example.com/\\\\u003C/script>alert(\\\\\"pwned\\\\\")\";</script><meta http-equiv=\"refresh\" content=\"0;url=https://example.com/</script>alert(&quot;pwned&quot;)\">'\n\t);\n});\n\ntest('renders a relative redirect', () => {\n\tconst content = read('redirect-relative.html');\n\tassert.equal(\n\t\tcontent,\n\t\t'<script>location.href=\"/env\";</script><meta http-equiv=\"refresh\" content=\"0;url=/env\">'\n\t);\n});\n\ntest('renders a shell when SSR is turned off and there is no server data', () => {\n\tconst content = read('spa-shell.html');\n\tassert.match(\n\t\tcontent,\n\t\t/<!doctype html>\\n<html lang=\"en\">([\\s]*?)<head>([\\s]*?)<meta charset=\"utf-8\" \\/>([\\s]*?)<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" \\/>([\\s\\S]*?)<\\/head>\\n([\\s]*?)<body>([\\s]*?)<script>([\\s\\S]*?)<\\/script>([\\s]*?)<\\/body>\\n<\\/html>/g\n\t);\n});\n\ntest('inserts http-equiv tag for cache-control headers', () => {\n\tconst content = read('max-age.html');\n\texpect(content).toMatch('<meta http-equiv=\"cache-control\" content=\"max-age=300\">');\n});\n\ntest('renders page with data from endpoint', () => {\n\tconst content = read('fetch-endpoint/buffered.html');\n\texpect(content).toMatch('<h1>the answer is 42</h1>');\n\n\tconst json = read('fetch-endpoint/buffered.json');\n\tassert.equal(json, JSON.stringify({ answer: 42 }));\n});\n\ntest('renders page with unbuffered data from endpoint', () => {\n\tconst content = read('fetch-endpoint/not-buffered.html');\n\texpect(content).toMatch('<h1>content-type: application/json</h1>');\n\n\tconst json = read('fetch-endpoint/not-buffered.json');\n\tassert.equal(json, JSON.stringify({ answer: 42 }));\n});\n\ntest('loads a file with spaces in the filename', () => {\n\tconst content = read('load-file-with-spaces.html');\n\texpect(content).toMatch('<h1>answer: 42</h1>');\n});\n\ntest('generates __data.json file for shadow endpoints', () => {\n\tlet data = JSON.parse(read('__data.json'));\n\texpect(data).toEqual({\n\t\ttype: 'data',\n\t\tnodes: [\n\t\t\tnull,\n\t\t\t{\n\t\t\t\ttype: 'data',\n\t\t\t\tdata: [{ message: 1 }, 'hello'],\n\t\t\t\tuses: {}\n\t\t\t}\n\t\t]\n\t});\n\n\tdata = JSON.parse(read('shadowed-get/__data.json'));\n\texpect(data).toEqual({\n\t\ttype: 'data',\n\t\tnodes: [\n\t\t\tnull,\n\t\t\t{\n\t\t\t\ttype: 'data',\n\t\t\t\tdata: [{ answer: 1 }, 42],\n\t\t\t\tuses: {}\n\t\t\t}\n\t\t]\n\t});\n});\n\ntest('generates __data.json file for shadow endpoints with ssr turned off', () => {\n\tconst data = JSON.parse(read('shadowed-get/ssr-off/__data.json'));\n\texpect(data).toEqual({\n\t\ttype: 'data',\n\t\tnodes: [\n\t\t\tnull,\n\t\t\t{\n\t\t\t\ttype: 'data',\n\t\t\t\tdata: [{ answer: 1 }, 42],\n\t\t\t\tuses: {}\n\t\t\t}\n\t\t]\n\t});\n});\n\ntest('does not prerender page with shadow endpoint with non-load handler', () => {\n\tassert.isFalse(fs.existsSync(`${build}/shadowed-post.html`));\n\tassert.isFalse(fs.existsSync(`${build}/shadowed-post/__data.json`));\n});\n\ntest('decodes paths when writing files', () => {\n\tlet content = read('encoding/path with spaces.html');\n\texpect(content).toMatch('<p id=\"a\">path with spaces</p>');\n\texpect(content).toMatch('<p id=\"b\">path with encoded spaces</p>');\n\n\tcontent = read('encoding/dynamic path with spaces.html');\n\texpect(content).toMatch(\n\t\t'<h1>dynamic path with spaces / /encoding/dynamic%20path%20with%20spaces</h1>'\n\t);\n\n\tcontent = read('encoding/dynamic path with encoded spaces.html');\n\texpect(content).toMatch(\n\t\t'<h1>dynamic path with encoded spaces / /encoding/dynamic%20path%20with%20encoded%20spaces</h1>'\n\t);\n\n\tcontent = read('encoding/redirected path with encoded spaces.html');\n\texpect(content).toMatch(\n\t\t'<h1>redirected path with encoded spaces / /encoding/redirected%20path%20with%20encoded%20spaces</h1>'\n\t);\n\n\tcontent = read('encoding/path with spaces.json');\n\tassert.equal(content, JSON.stringify({ path: 'path with spaces' }));\n\n\tcontent = read('encoding/path with encoded spaces.json');\n\tassert.equal(content, JSON.stringify({ path: 'path with encoded spaces' }));\n});\n\ntest('prerendering is set to true in root +layout.js', () => {\n\tconst content = replace_hydration_attrs(read('prerendering-true.html'));\n\texpect(content).toMatch('<h1>prerendering: true/true</h1>');\n});\n\ntest('fetching missing content results in a 404', () => {\n\tconst content = read('fetch-404.html');\n\texpect(content).toMatch('<h1>status: 404</h1>');\n});\n\ntest('prerenders binary data', async () => {\n\tassert.equal(Buffer.compare(read('fetch-image/image.jpg', null), read('image.jpg', null)), 0);\n\tassert.equal(Buffer.compare(read('fetch-image/image.png', null), read('image.png', null)), 0);\n});\n\ntest('generates relative link for resolve helper during prerender', () => {\n\tconst content = read('resolve-relative/lv1/lv2.html');\n\texpect(content).toMatch('href=\"../../resolve-relative/lv1\"');\n});\n\ntest('fetches data from local endpoint', () => {\n\tconst data = JSON.parse(read('origin/__data.json'));\n\n\texpect(data).toEqual({\n\t\ttype: 'data',\n\t\tnodes: [\n\t\t\tnull,\n\t\t\t{\n\t\t\t\ttype: 'data',\n\t\t\t\tdata: [{ message: 1 }, 'hello'],\n\t\t\t\tuses: {}\n\t\t\t}\n\t\t]\n\t});\n\tassert.equal(read('origin/message.json'), JSON.stringify({ message: 'hello' }));\n});\n\ntest('respects config.prerender.origin', () => {\n\tconst content = read('origin.html');\n\texpect(content).toMatch('<h2>http://prerender.origin</h2>');\n});\n\ntest('$env - includes environment variables', () => {\n\tconst content = read('env.html');\n\n\tassert.match(\n\t\tcontent,\n\t\t/.*PRIVATE_STATIC: accessible to server-side code\\/replaced at build time.*/gs\n\t);\n\n\tassert.match(content, /.*PUBLIC_STATIC: accessible anywhere\\/replaced at build time.*/gs);\n});\n\ntest('prerenders a page in a (group)', () => {\n\tconst content = replace_hydration_attrs(read('grouped.html'));\n\texpect(content).toMatch('<h1>grouped</h1>');\n});\n\ntest('injects relative service worker', () => {\n\tconst content = read('index.html');\n\texpect(content).toMatch(\"navigator.serviceWorker.register('./service-worker.js'\");\n});\n\ntest('define service worker variables', () => {\n\tconst content = read('service-worker.js');\n\texpect(content).toMatch('MY_ENV DEFINED');\n});\n\ntest('prerendered.paths omits trailing slashes for endpoints', () => {\n\tconst content = read('service-worker.js');\n\n\tfor (const path of [\n\t\t'/trailing-slash/page/',\n\t\t'/trailing-slash/page/__data.json',\n\t\t'/trailing-slash/standalone-endpoint.json'\n\t]) {\n\t\texpect(content, `Missing ${path}`).toMatch(`\"${path}\"`);\n\t}\n});\n\ntest('prerenders responses with immutable Headers', () => {\n\tconst content = read('immutable-headers');\n\texpect(content).toMatch('foo');\n});\n\ntest('prerenders paths with optional parameters with empty values', () => {\n\tconst content = read('optional-params.html');\n\texpect(content).includes('Path with Value');\n});\n\ntest('crawls links that start with config.prerender.origin', () => {\n\tconst content = read('prerender-origin/dynamic.html');\n\texpect(content).toBeTruthy();\n});\n\ntest('identifies missing ids', () => {\n\tconst missing_ids_file = fileURLToPath(new URL('../missing_ids/index.jsonl', import.meta.url));\n\tconst missing_ids_content = fs.readFileSync(missing_ids_file, 'utf-8');\n\tconst missing_ids = JSON.parse(`[${missing_ids_content.slice(0, -1)}]`);\n\texpect(missing_ids).toEqual(['missing-id']);\n});\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/basics/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vitest/config').ViteUserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\n\tclearScreen: false,\n\n\tlogLevel: 'silent',\n\n\tplugins: [sveltekit()],\n\n\tdefine: {\n\t\t'process.env.MY_ENV': '\"MY_ENV DEFINED\"'\n\t},\n\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t},\n\n\ttest: {\n\t\tglobalSetup: './globalSetup.js'\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/package.json",
    "content": "{\n\t\"name\": \"prerendering-test-options\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"svelte-kit sync && pnpm build && vitest run\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/public/robots.txt",
    "content": "# https://www.robotstxt.org/robotstxt.html\nUser-agent: *\nDisallow:"
  },
  {
    "path": "packages/kit/test/prerendering/options/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t%sveltekit.body%\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/src/routes/(group)/+page.svelte",
    "content": "<h1>hello</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/src/routes/+layout.js",
    "content": "export const prerender = true;\nexport const trailingSlash = 'always';\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/src/routes/+layout.svelte",
    "content": "<svelte:head>\n\t<link rel=\"alternate\" href=\"/path-base/rss.xml\" />\n</svelte:head>\n\n<slot />\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/src/routes/csp-hydratable/+page.svelte",
    "content": "<script>\n\timport { hydratable } from 'svelte';\n\n\tconst value = await hydratable('test-key', () => Promise.resolve('prerendered-value'));\n</script>\n\n<h1 id=\"hydratable-result\">{value}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/src/routes/nested/+page.svelte",
    "content": "<h1>nested hello</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/src/routes/rss.xml/+server.js",
    "content": "export function GET() {\n\treturn new Response('dynamic');\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/svelte.config.js",
    "content": "import adapter from '../../../../adapter-static/index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tcompilerOptions: {\n\t\texperimental: {\n\t\t\tasync: true\n\t\t}\n\t},\n\n\tkit: {\n\t\tadapter: adapter({\n\t\t\tfallback: '200.html'\n\t\t}),\n\n\t\tcsp: {\n\t\t\tdirectives: {\n\t\t\t\t'script-src': ['self']\n\t\t\t}\n\t\t},\n\n\t\tfiles: {\n\t\t\tassets: 'public'\n\t\t},\n\n\t\tpaths: {\n\t\t\tbase: '/path-base',\n\t\t\tassets: 'https://cdn.example.com/stuff'\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/test/tests.spec.js",
    "content": "import * as fs from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { assert, expect, test } from 'vitest';\nimport { replace_hydration_attrs } from '../../test-utils';\n\nconst build = fileURLToPath(new URL('../build', import.meta.url));\n\n/** @param {string} file */\nconst read = (file) => fs.readFileSync(`${build}/${file}`, 'utf-8');\n\ntest('prerenders /path-base', () => {\n\tconst content = replace_hydration_attrs(read('index.html'));\n\texpect(content).toMatch('<h1>hello</h1>');\n});\n\ntest('prerenders nested /path-base', () => {\n\tconst content = replace_hydration_attrs(read('nested/index.html'));\n\texpect(content).toMatch('<h1>nested hello</h1>');\n});\n\ntest('adds CSP headers via meta tag', () => {\n\tconst content = read('index.html');\n\texpect(content).toMatch(\n\t\t'<meta http-equiv=\"content-security-policy\" content=\"script-src \\'self\\' \\'sha256-'\n\t);\n});\n\ntest('does not copy `public` into `_app`', () => {\n\tassert.isFalse(fs.existsSync(`${build}/_app/robots.txt`));\n});\n\n// https://github.com/sveltejs/kit/issues/4340\ntest('populates fallback 200.html file', () => {\n\tconst content = read('200.html');\n\tassert.isNotEmpty(content);\n});\n\ntest('does not prerender linked +server.js route', () => {\n\tassert.isFalse(fs.existsSync(`${build}/rss.xml`));\n});\n\ntest('adds CSP hashes for hydratable scripts via meta tag', () => {\n\tconst content = read('csp-hydratable/index.html');\n\n\t// Verify the page rendered correctly\n\texpect(replace_hydration_attrs(content)).toMatch(\n\t\t'<h1 id=\"hydratable-result\">prerendered-value</h1>'\n\t);\n\n\t// This hash could change if Svelte changes how it generates hydratable script elements, but the alternative\n\t// (trying to extract the script block and hash it to compare) is more annoying than maybe at some point in the future\n\t// having to update this\n\texpect(content).toMatch(\n\t\t/<meta http-equiv=\"content-security-policy\" content=\".*'sha256-xWnzKGZbZBWKfvJVEFtrpB\\/s9zyyMDyQZt49JX2PAJQ='.*\"/\n\t);\n});\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/options/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false\n\t},\n\n\tclearScreen: false,\n\n\tlogLevel: 'silent',\n\n\tplugins: [sveltekit()],\n\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/package.json",
    "content": "{\n\t\"name\": \"prerendering-test-paths-base\",\n\t\"private\": true,\n\t\"version\": \"0.0.1\",\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"check\": \"svelte-kit sync && tsc && svelte-check\",\n\t\t\"test\": \"svelte-kit sync && pnpm build && vitest run\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:^\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.4\",\n\t\t\"vite\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"type\": \"module\"\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/app.d.ts",
    "content": "/// <reference types=\"@sveltejs/kit\" />;\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<base href=\"/path-base/\" />\n\t\t<link rel=\"icon\" href=\"favicon.png\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body>\n\t\t%sveltekit.body%\n\t</body>\n</html>\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/hooks.server.js",
    "content": ""
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/+layout.js",
    "content": "export const prerender = true;\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/+layout.svelte",
    "content": "<slot />\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/+page.svelte",
    "content": "<div>\n\t<h1>Main Page</h1>\n\t<a href=\"nested\">Nested Link</a>\n</div>\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/a/b/c/+page.svelte",
    "content": "<a href=\"a/b/d\">a/b/d</a>\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/a/b/d/+page.svelte",
    "content": "<a href=\"a/b/c\">a/b/c</a>\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/assets/+page.svelte",
    "content": "<script>\n\timport logo from './logo.svg';\n</script>\n\n<img src={logo} alt=\"Svelte logo\" />\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/assets/emitted/+page.server.js",
    "content": "// @ts-ignore\nimport url from './message.csv?url';\n\nexport async function load({ fetch }) {\n\tconst response = await fetch(url);\n\tconst message = await response.text();\n\treturn { message };\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/assets/emitted/+page.svelte",
    "content": "<script>\n\tconst { data } = $props();\n</script>\n\n<p>{data.message}</p>\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/assets/emitted/message.csv",
    "content": "hello from message.csv\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/dynamic/[slug]/+page.svelte",
    "content": "<script>\n\timport { page } from '$app/state';\n</script>\n\n<h1>{page.params.slug}</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/nested/+page.svelte",
    "content": "<h1>nested hello</h1>\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/src/routes/redirect/+page.js",
    "content": "import { redirect } from '@sveltejs/kit';\nimport { base } from '$app/paths';\n\nexport function load() {\n\tredirect(301, `${base}/dynamic/foo`);\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/svelte.config.js",
    "content": "import adapter from '../../../../adapter-static/index.js';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\tadapter: adapter(),\n\n\t\tpaths: {\n\t\t\tbase: '/path-base',\n\t\t\trelative: false\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/test/tests.spec.js",
    "content": "import * as fs from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { assert, test } from 'vitest';\n\nconst build = fileURLToPath(new URL('../build', import.meta.url));\n\n/** @param {string} file */\nconst read = (file) => fs.readFileSync(`${build}/${file}`, 'utf-8');\n\ntest('prerenders /path-base', () => {\n\tconst content = read('index.html');\n\tassert.ok(content.includes('favicon.png') && content.includes('nested'));\n});\n\ntest('prerenders /path-base/redirect', () => {\n\tconst content = read('redirect.html');\n\tassert.equal(\n\t\tcontent,\n\t\t'<script>location.href=\"/path-base/dynamic/foo\";</script><meta http-equiv=\"refresh\" content=\"0;url=/path-base/dynamic/foo\">'\n\t);\n});\n\ntest('prerenders /path-base/dynamic/foo', () => {\n\tconst content = read('dynamic/foo.html');\n\tassert.ok(content.includes('<h1>foo</h1>'));\n});\n\ntest('prerenders /path-base/assets', () => {\n\tconst content = read('assets.html');\n\tassert.match(content, /<img[^>]+src=\"\\/path-base\\//u);\n});\n\ntest('prerenders /path-base/assets/emitted', () => {\n\tconst content = read('assets/emitted.html');\n\tassert.ok(content.includes('<p>hello from message.csv'));\n});\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t},\n\t\"extends\": \"./.svelte-kit/tsconfig.json\"\n}\n"
  },
  {
    "path": "packages/kit/test/prerendering/paths-base/vite.config.js",
    "content": "import * as path from 'node:path';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\n/** @type {import('vite').UserConfig} */\nconst config = {\n\tbuild: {\n\t\tminify: false,\n\t\t// disable inlining to test asset base path\n\t\tassetsInlineLimit: 0\n\t},\n\n\tclearScreen: false,\n\n\tlogLevel: 'silent',\n\n\tplugins: [sveltekit()],\n\n\tserver: {\n\t\tfs: {\n\t\t\tallow: [path.resolve('../../../src')]\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "packages/kit/test/prerendering/test-utils.js",
    "content": "/**\n * For static content, Svelte v4 will add a data-svelte-h attribute.\n * Replace the hash with something predictable before comparing the output.\n *\n * @param {string} html\n */\nexport function replace_hydration_attrs(html) {\n\treturn html.replace(/(\\s+)data-svelte-h=\"svelte-\\w+\"/g, '');\n}\n"
  },
  {
    "path": "packages/kit/test/setup.js",
    "content": "import {\n\tgoto,\n\tinvalidate,\n\tpreloadCode,\n\tpreloadData,\n\tbeforeNavigate,\n\tafterNavigate\n} from '$app/navigation';\nimport { onMount, tick } from 'svelte';\n\nexport function setup() {\n\tonMount(() => {\n\t\t// give tests programmatic control over the app\n\t\tObject.assign(window, {\n\t\t\tgoto,\n\t\t\tinvalidate,\n\t\t\tpreloadCode,\n\t\t\tpreloadData,\n\t\t\tbeforeNavigate,\n\t\t\tafterNavigate,\n\t\t\tsvelte_tick: tick\n\t\t});\n\n\t\t// communicate that the app is ready\n\t\tdocument.body.classList.add('started');\n\t});\n}\n"
  },
  {
    "path": "packages/kit/test/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"esnext\",\n\t\t\"module\": \"esnext\",\n\t\t\"moduleResolution\": \"node\",\n\t\t\"allowSyntheticDefaultImports\": true\n\t},\n\t\"include\": [\"./*\", \"./mocks/**/*\", \"./prerendering/*\"]\n}\n"
  },
  {
    "path": "packages/kit/test/types/actions.test.ts",
    "content": "import * as Kit from '@sveltejs/kit';\n\n// Test: Action types inferred correctly and transformed into a union\ntype Actions = {\n\tfoo: () => Promise<void>;\n\tbar: () => Promise<{ success: boolean } | Kit.ActionFailure<{ message: string }>>;\n\tbaz: () => Kit.ActionFailure<{ foo: string }> | { status: number; data: string };\n};\n\nlet form: Kit.AwaitedActions<Actions> = null as any;\nform.message = '';\nform.success = true;\n// @ts-expect-error - cannot both be present at the same time\nform = { message: '', success: true };\n\n// Test: Actions with different return types are transformed into a union that has all types accessible\ntype Actions2 = {\n\tfoo: () => Promise<{ message: string }>;\n\tbar: () => Promise<{ success: boolean }>;\n};\n\nlet form2: Kit.AwaitedActions<Actions2> = null as any;\nform2.message = '';\nform2.success = true;\n// @ts-expect-error - cannot both be present at the same time\nform2 = { message: '', success: true };\n\n// Test: ActionFailure is correctly infered to be different from the normal return type even if they have the same shape\ntype Actions3 = {\n\tbar: () => Kit.ActionFailure<{ foo: string }> | { status: number; data: { bar: string } };\n};\nlet form3: Kit.AwaitedActions<Actions3> = null as any;\nform3.foo = '';\nform3.status = 200;\n// @ts-expect-error - cannot both be present at the same time\nform3 = { foo: '', status: 200 };\n\nconst foo: any = null;\n// @ts-expect-error ActionFailure is not a class and so you can't do instanceof\nfoo instanceof Kit.ActionFailure;\n"
  },
  {
    "path": "packages/kit/test/types/load.test.ts",
    "content": "import * as Kit from '@sveltejs/kit';\n\n// Test: Return types inferred correctly and transformed into a union\ntype LoadReturn1 =\n\t| { success: true; message?: undefined }\n\t| { success?: undefined; message: string };\n\nlet result1: Kit.LoadProperties<LoadReturn1> = null as any;\nresult1.message = '';\nresult1.success = true;\n// @ts-expect-error - cannot both be present at the same time\nresult1 = { message: '', success: true };\n"
  },
  {
    "path": "packages/kit/test/types/remote.test.ts",
    "content": "import { query, prerender, command, form } from '$app/server';\nimport { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n\tRemoteForm,\n\tRemoteFormInput,\n\tRemotePrerenderFunction,\n\tRemoteQueryFunction,\n\tinvalid\n} from '@sveltejs/kit';\n\nconst schema: StandardSchemaV1<string> = null as any;\nconst schema2: StandardSchemaV1<string, number> = null as any;\nconst schema3: StandardSchemaV1<string | undefined, number> = null as any;\n\nfunction query_tests() {\n\tconst no_args: RemoteQueryFunction<void, string> = query(() => 'Hello world');\n\tvoid no_args();\n\t// @ts-expect-error\n\tvoid no_args('');\n\n\tconst one_arg: RemoteQueryFunction<number, string> = query('unchecked', (a: number) =>\n\t\ta.toString()\n\t);\n\tvoid one_arg(1);\n\t// @ts-expect-error\n\tvoid one_arg('1');\n\t// @ts-expect-error\n\tvoid one_arg();\n\n\tasync function query_without_args() {\n\t\tconst q = query(() => 'Hello world');\n\t\tconst result: string = await q();\n\t\tresult;\n\t\t// @ts-expect-error\n\t\tconst wrong: number = await q();\n\t\twrong;\n\t\t// @ts-expect-error\n\t\tvoid q(1);\n\t\t// @ts-expect-error\n\t\tquery((_: string) => 'hi');\n\t}\n\tvoid query_without_args();\n\n\tasync function query_with_optional_arg() {\n\t\tconst q = query(schema3, () => 'Hello world');\n\t\tvoid q();\n\t\tvoid q('hi');\n\t\t// @ts-expect-error\n\t\tvoid q(1);\n\n\t\tconst q2 = query('unchecked', (a?: string) => a);\n\t\tvoid q2();\n\t\tvoid q2('hi');\n\t\t// @ts-expect-error\n\t\tvoid q2(1);\n\t}\n\tvoid query_with_optional_arg();\n\n\tasync function query_unsafe() {\n\t\tconst q = query('unchecked', (a: number) => a);\n\t\tconst result: number = await q(1);\n\t\tresult;\n\t\t// @ts-expect-error\n\t\tvoid q(1, 2, 3);\n\t\t// @ts-expect-error\n\t\tvoid q('1', '2');\n\t}\n\tvoid query_unsafe();\n\n\tasync function query_schema_input_only() {\n\t\tconst q = query(schema, (a) => a);\n\t\tconst result: string = await q('1');\n\t\tresult;\n\t}\n\tvoid query_schema_input_only();\n\n\tasync function query_schema_input_and_output() {\n\t\tconst q = query(schema2, (a) => a);\n\t\tconst result: number = await q('1');\n\t\tresult;\n\t}\n\tvoid query_schema_input_and_output();\n}\nquery_tests();\n\nfunction prerender_tests() {\n\tconst no_args: RemotePrerenderFunction<void, string> = prerender(() => 'Hello world');\n\tvoid no_args();\n\t// @ts-expect-error\n\tvoid no_args('');\n\tconst one_arg: RemotePrerenderFunction<number, string> = prerender('unchecked', (a: number) =>\n\t\ta.toString()\n\t);\n\tvoid one_arg(1);\n\t// @ts-expect-error\n\tvoid one_arg('1');\n\t// @ts-expect-error\n\tvoid one_arg();\n\n\tasync function prerender_without_args() {\n\t\tconst q = prerender(() => 'Hello world');\n\t\tconst result: string = await q();\n\t\tresult;\n\t\t// @ts-expect-error\n\t\tconst wrong: number = await q();\n\t\twrong;\n\t\t// @ts-expect-error\n\t\tvoid q(1);\n\t\t// @ts-expect-error\n\t\tquery((_: string) => 'hi');\n\t}\n\tvoid prerender_without_args();\n\n\tasync function prerender_unsafe() {\n\t\tconst q = prerender('unchecked', (a: number) => a);\n\t\tconst result: number = await q(1);\n\t\tresult;\n\t\t// @ts-expect-error\n\t\tvoid q(1, 2, 3);\n\t\t// @ts-expect-error\n\t\tvoid q('1', '2');\n\t}\n\tvoid prerender_unsafe();\n\n\tasync function prerender_with_optional_arg() {\n\t\tconst q = prerender(schema3, () => 'Hello world');\n\t\tvoid q();\n\t\tvoid q('hi');\n\t\t// @ts-expect-error\n\t\tvoid q(1);\n\n\t\tconst q2 = prerender('unchecked', (a?: string) => a);\n\t\tvoid q2();\n\t\tvoid q2('hi');\n\t\t// @ts-expect-error\n\t\tvoid q2(1);\n\t}\n\tvoid prerender_with_optional_arg();\n\n\tasync function prerender_schema() {\n\t\tconst q = prerender(schema, (a) => a);\n\t\tconst result: string = await q('1');\n\t\tresult;\n\t}\n\tvoid prerender_schema();\n\n\tfunction prerender_schema_entries() {\n\t\tconst q = prerender(schema, (a) => a, { inputs: () => ['1'] });\n\t\tq;\n\t\t// @ts-expect-error\n\t\tconst q2 = prerender(schema, (a) => a, { inputs: () => [1] });\n\t\tq2;\n\t}\n\tprerender_schema_entries();\n}\nprerender_tests();\n\nfunction command_tests() {\n\tasync function command_without_args() {\n\t\tconst q = query(() => '');\n\t\tconst cmd = command(() => 'Hello world');\n\t\tconst result: string = await cmd();\n\t\tresult;\n\t\tconst result2: string = await cmd().updates(\n\t\t\tq(),\n\t\t\tq().withOverride(() => '')\n\t\t);\n\t\tresult2;\n\t\t// @ts-expect-error\n\t\tconst wrong: number = await cmd();\n\t\twrong;\n\t}\n\tvoid command_without_args();\n\n\tasync function command_with_optional_arg() {\n\t\tconst q = command(schema3, () => 'Hello world');\n\t\tvoid q();\n\t\tvoid q('hi');\n\t\t// @ts-expect-error\n\t\tvoid q(1);\n\n\t\tconst q2 = command('unchecked', (a?: string) => a);\n\t\tvoid q2();\n\t\tvoid q2('hi');\n\t\t// @ts-expect-error\n\t\tvoid q2(1);\n\t}\n\tvoid command_with_optional_arg();\n\n\tasync function command_unsafe() {\n\t\tconst cmd = command('unchecked', (a: string) => a);\n\t\tconst result: string = await cmd('test');\n\t\tresult;\n\t\t// @ts-expect-error\n\t\tvoid cmd(1);\n\t\t// @ts-expect-error\n\t\tvoid cmd('1', 2);\n\t}\n\tvoid command_unsafe();\n\n\tasync function command_schema() {\n\t\tconst cmd = command(schema, (a) => a);\n\t\tconst result: string = await cmd('foo');\n\t\tresult;\n\t\t// @ts-expect-error\n\t\tvoid cmd(123);\n\t}\n\tvoid command_schema();\n}\ncommand_tests();\n\nfunction form_tests() {\n\tconst q = query(() => '');\n\tconst f = form('unchecked', (data: { input: string }, issue) => {\n\t\tdata.input;\n\t\tif (Math.random() > 0.5) {\n\t\t\tinvalid(\n\t\t\t\t'foo',\n\t\t\t\tissue.input('bar'),\n\t\t\t\t// @ts-expect-error\n\t\t\t\tissue.nonexistent.prop('baz')\n\t\t\t);\n\t\t}\n\t\treturn { success: true };\n\t});\n\n\tf.result?.success === true;\n\n\tf.enhance(async ({ submit }) => {\n\t\tconst x: void = await submit();\n\t\tx;\n\t\tconst y: void = await submit().updates(\n\t\t\tq(),\n\t\t\tq().withOverride(() => '')\n\t\t);\n\t\ty;\n\t});\n\n\tconst f2 = form(\n\t\tnull as any as StandardSchemaV1<{ a: string; nested: { prop: string } }>,\n\t\t(data, issue) => {\n\t\t\tdata.a === '';\n\t\t\tdata.nested.prop === '';\n\t\t\t// @ts-expect-error\n\t\t\tdata.nested.nonexistent;\n\t\t\t// @ts-expect-error\n\t\t\tdata.nonexistent;\n\t\t\t// @ts-expect-error\n\t\t\tdata.a === 123;\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tinvalid(\n\t\t\t\t\t'foo',\n\t\t\t\t\tissue.nested.prop('bar'),\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tissue.nonexistent.prop('baz')\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { success: true };\n\t\t}\n\t);\n\t// @ts-expect-error\n\tf2.fields.as('text');\n\tf2.fields.a.issues();\n\tf2.fields.nested.prop.issues();\n\t// @ts-expect-error\n\tf2.fields.nonexistent.issues();\n\tf2.fields.a.value();\n\tf2.fields.nested.prop.value();\n\t// @ts-expect-error\n\tf2.fields.nonexistent.value();\n\t// @ts-expect-error\n\tf2.fields.array[0].array.as('text');\n\n\t// all schema properties optional\n\tconst f3 = form(\n\t\tnull as any as StandardSchemaV1<{ a?: string; nested?: { prop?: string } }>,\n\t\t(data, issue) => {\n\t\t\tdata.a === '';\n\t\t\tdata.nested?.prop === '';\n\t\t\t// @ts-expect-error\n\t\t\tdata.nested.prop === '';\n\t\t\t// @ts-expect-error\n\t\t\tdata.nested.nonexistent;\n\t\t\t// @ts-expect-error\n\t\t\tdata.nonexistent;\n\t\t\t// @ts-expect-error\n\t\t\tdata.a === 123;\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tinvalid(\n\t\t\t\t\t'foo',\n\t\t\t\t\tissue.nested.prop('bar'),\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tissue.nonexistent.prop('baz')\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { success: true };\n\t\t}\n\t);\n\t// @ts-expect-error\n\tf3.fields.as('text');\n\tf3.fields.a.issues();\n\tf3.fields.a.value();\n\tf3.fields.nested.prop.issues();\n\tf3.fields.nested.prop.value();\n\t// @ts-expect-error\n\tf3.fields.nonexistent.as('text');\n\n\t// index signature schema\n\tconst f4 = form(null as any as StandardSchemaV1<Record<string, any>>, (data) => {\n\t\tdata.a === '';\n\t\tdata.nested?.prop === '';\n\t\treturn { success: true };\n\t});\n\t// @ts-expect-error\n\tf4.fields.as('text');\n\tf4.fields.a.issues();\n\tf4.fields.a.value();\n\tf4.fields.nested.prop.issues();\n\tf4.fields.nested.prop.value();\n\n\t// schema with union types\n\tconst f5 = form(\n\t\tnull as any as StandardSchemaV1<{ foo: 'a' | 'b'; bar: 'c' | 'd' }>,\n\t\t(data, issue) => {\n\t\t\tdata.foo === 'a';\n\t\t\tdata.bar === 'c';\n\t\t\t// @ts-expect-error\n\t\t\tdata.foo === 'e';\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tinvalid(\n\t\t\t\t\t'foo',\n\t\t\t\t\tissue.bar('bar'),\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tissue.nonexistent.prop('baz')\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { success: true };\n\t\t}\n\t);\n\t// @ts-expect-error\n\tf5.fields.as('text');\n\tf5.fields.foo.issues();\n\tf5.fields.bar.issues();\n\tf5.fields.foo.value();\n\tf5.fields.bar.value() === 'c';\n\t// @ts-expect-error\n\tf5.fields.foo.value() === 'e';\n\t// @ts-expect-error\n\tf5.fields.nonexistent.as('text');\n\n\t// schema with arrays\n\tconst f6 = form(\n\t\tnull as any as StandardSchemaV1<{ array: Array<{ array: string[]; prop: string }> }>,\n\t\t(data, issue) => {\n\t\t\tdata.array[0].prop === 'a';\n\t\t\tdata.array[0].array[0] === 'a';\n\t\t\t// @ts-expect-error\n\t\t\tdata.array[0].array[0] === 1;\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tinvalid(\n\t\t\t\t\t'foo',\n\t\t\t\t\tissue.array[0].prop('bar'),\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tissue.nonexistent.prop('baz')\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { success: true };\n\t\t}\n\t);\n\t// @ts-expect-error\n\tf6.fields.as('text');\n\t// @ts-expect-error\n\tf6.field('array[0].array');\n\tf6.fields.array.issues();\n\tf6.fields.array[0].prop.issues();\n\tf6.fields.array[0].array.issues();\n\t// @ts-expect-error\n\tf6.fields.nonexistent.issues();\n\tf6.fields.array[0].prop.value();\n\tf6.fields.array[0].array.value();\n\t// @ts-expect-error\n\tf6.fields.array[0].array.as('text');\n\n\t// any\n\tconst f7 = form(null as any, (data, issue) => {\n\t\tdata.a === '';\n\t\tdata.nested?.prop === '';\n\t\tif (Math.random() > 0.5) {\n\t\t\tinvalid('foo', issue.nested.prop('bar'));\n\t\t}\n\t\treturn { success: true };\n\t});\n\t// @ts-expect-error\n\tf7.fields.as('text');\n\tf7.fields.a.issues();\n\tf7.fields.a.value();\n\tf7.fields.nested.prop.issues();\n\tf7.fields.nested.prop.value();\n\n\t// no schema\n\tconst f8 = form(() => {\n\t\tinvalid('foo');\n\t});\n\tf8.fields.issues();\n\tf8.fields.allIssues();\n\t// @ts-expect-error\n\tf8.fields.x;\n\t// @ts-expect-error\n\tf6.input!['array[0].prop'] = 123;\n\n\t// doesn't use data\n\tconst f9 = form(() => Promise.resolve({ success: true }));\n\tf9.result?.success === true;\n\n\t// generic form\n\tfunction f10<\n\t\tSchema extends StandardSchemaV1<RemoteFormInput, unknown>,\n\t\tForm extends RemoteForm<StandardSchemaV1.InferInput<Schema>, unknown>\n\t>(data: StandardSchemaV1.InferInput<Schema>, form: Form) {\n\t\tform.fields.set(data);\n\t\tform.fields.allIssues();\n\t}\n\tvoid f10;\n}\nform_tests();\n\nfunction boolean_tests() {\n\tconst q = query(() => 'Hello world');\n\tconst result = q();\n\n\tif (!result.ready) {\n\t\tresult.current === undefined;\n\t\t// @ts-expect-error\n\t\tresult.current.length;\n\t\t// @ts-expect-error\n\t\tresult.current?.length;\n\t} else {\n\t\tresult.current === 'a';\n\t\tresult.current.length;\n\t\t// @ts-expect-error\n\t\tresult.current === true;\n\t}\n\n\tif (result.loading) {\n\t\tresult.current === undefined;\n\t\tresult.current?.length;\n\t\t// @ts-expect-error\n\t\tresult.current.length;\n\t\t// @ts-expect-error\n\t\tresult.current === true;\n\t}\n\n\tif (result.error) {\n\t\tresult.current === 'a';\n\t\tresult.current?.length;\n\t\t// @ts-expect-error\n\t\tresult.current.length;\n\t\t// @ts-expect-error\n\t\tresult.current === true;\n\t}\n}\nboolean_tests();\n"
  },
  {
    "path": "packages/kit/test/types/tsconfig.json",
    "content": "{\n\t\"extends\": \"../../tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"noEmit\": true\n\t},\n\t\"include\": [\"**/*.test.ts\", \"../../src/types/*.d.ts\"]\n}\n"
  },
  {
    "path": "packages/kit/test/types.d.ts",
    "content": "import {\n\tPlaywrightTestArgs,\n\tPlaywrightTestOptions,\n\tPlaywrightWorkerArgs,\n\tPlaywrightWorkerOptions,\n\tTestType,\n\tPage\n} from '@playwright/test';\nimport { IncomingMessage, ServerResponse } from 'node:http';\nimport '../types/index';\nimport { AfterNavigate, BeforeNavigate } from '@sveltejs/kit';\n\nexport const test: TestType<\n\tPlaywrightTestArgs &\n\t\tPlaywrightTestOptions & {\n\t\t\tapp: {\n\t\t\t\tgoto(url: string, opts?: { replaceState?: boolean }): Promise<void>;\n\t\t\t\tinvalidate(url: string): Promise<void>;\n\t\t\t\tbeforeNavigate(fn: (navigation: BeforeNavigate) => void | boolean): void;\n\t\t\t\tafterNavigate(fn: (navigation: AfterNavigate) => void): void;\n\t\t\t\tpreloadCode(pathname: string): Promise<void>;\n\t\t\t\tpreloadData(url: string): Promise<void>;\n\t\t\t};\n\t\t\tclicknav(\n\t\t\t\tselector: string,\n\t\t\t\toptions?: { timeout?: number; waitForURL?: string }\n\t\t\t): Promise<void>;\n\t\t\tscroll_to(x: number, y: number): Promise<void>;\n\t\t\tin_view(selector: string): Promise<boolean>;\n\t\t\tget_computed_style(selector: string, prop: string): Promise<string>;\n\t\t\t/**\n\t\t\t * `handleError` defines the shape\n\t\t\t */\n\t\t\tread_errors(href: string): Record<string, any>;\n\t\t\tread_traces(test_id: string): SpanTree[];\n\t\t\tstart_server(\n\t\t\t\thandler: (req: IncomingMessage, res: ServerResponse) => void\n\t\t\t): Promise<{ port: number }>;\n\t\t\tpage: Page & {\n\t\t\t\tgoto: (\n\t\t\t\t\turl: string,\n\t\t\t\t\topts?: Parameters<Page['goto']>[1] & { wait_for_started?: boolean }\n\t\t\t\t) => ReturnType<Page['goto']>;\n\t\t\t};\n\t\t\tbaseURL: string;\n\t\t},\n\tPlaywrightWorkerArgs & PlaywrightWorkerOptions\n>;\n\nexport interface SpanData {\n\tname: string;\n\tstatus: {\n\t\tcode: number;\n\t\tmessage?: string;\n\t};\n\tstart_time: [number, number]; // HrTime tuple: [seconds, nanoseconds]\n\tend_time: [number, number]; // HrTime tuple: [seconds, nanoseconds]\n\tattributes: Record<string, string | number | boolean | Array<string | number | boolean>>;\n\tlinks: Array<{\n\t\tcontext: any;\n\t\tattributes?: Record<string, string | number | boolean | Array<string | number | boolean>>;\n\t}>;\n\ttrace_id: string;\n\tspan_id: string;\n\tparent_span_id: string | undefined;\n}\n\nexport type SpanTree = Omit<SpanData, 'parent_span_id'> & {\n\tchildren: SpanTree[];\n};\n"
  },
  {
    "path": "packages/kit/test/utils.js",
    "content": "/** @import { SpanData, SpanTree } from './types' */\n// This helps `pnpm check` pass in the test apps without having to include\n// the ambient.d.ts file in each of their tsconfig.json files.\n/** @import {} from './ambient' */\n\nimport fs from 'node:fs';\nimport http from 'node:http';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\nimport { defineConfig, test as base, devices } from '@playwright/test';\nimport { number_from_env } from '../../../test-utils/index.js';\n\n/** @type {import('./types')['test']} */\nexport const test = base.extend({\n\tapp: ({ page }, use) => {\n\t\t// these are assumed to have been put in the global scope by the layout\n\t\tvoid use({\n\t\t\tgoto: (url, opts) => page.evaluate(({ url, opts }) => goto(url, opts), { url, opts }),\n\n\t\t\tinvalidate: (url) => page.evaluate((url) => invalidate(url), url),\n\n\t\t\tbeforeNavigate: (fn) => page.evaluate((fn) => beforeNavigate(fn), fn),\n\n\t\t\tafterNavigate: () => page.evaluate(() => afterNavigate(() => {})),\n\n\t\t\tpreloadCode: (pathname) => page.evaluate((pathname) => preloadCode(pathname), pathname),\n\n\t\t\tpreloadData: (url) => page.evaluate((url) => preloadData(url), url)\n\t\t});\n\t},\n\n\tclicknav: async ({ page, javaScriptEnabled }, use) => {\n\t\t/**\n\t\t * @param {string} selector\n\t\t * @param {{ timeout?: number, waitForURL?: string }} [options]\n\t\t */\n\t\tasync function clicknav(selector, { timeout, waitForURL } = {}) {\n\t\t\tconst element = page.locator(selector);\n\t\t\tif (javaScriptEnabled) {\n\t\t\t\tconst promises = [page.waitForNavigation({ timeout }), element.click()];\n\t\t\t\tif (waitForURL) {\n\t\t\t\t\tpromises.push(page.waitForURL(waitForURL, { timeout }));\n\t\t\t\t}\n\t\t\t\tawait Promise.all(promises);\n\t\t\t} else {\n\t\t\t\tawait element.click();\n\t\t\t}\n\t\t}\n\n\t\tawait use(clicknav);\n\t},\n\n\tscroll_to: async ({ page }, use) => {\n\t\t/**\n\t\t * @param {number} x\n\t\t * @param {number} y\n\t\t */\n\t\tasync function scroll_to(x, y) {\n\t\t\t// The browser will do this for us, but we need to do it pre-emptively\n\t\t\t// so that we can check the scroll location.\n\t\t\t// Otherwise, we'd be checking a decimal number against an integer.\n\t\t\tx = Math.trunc(x);\n\t\t\ty = Math.trunc(y);\n\t\t\tconst watcher = page.waitForFunction(\n\t\t\t\t/** @param {{ x: number, y: number }} opt */ (opt) =>\n\t\t\t\t\t// check if the scroll position reached the desired or maximum position\n\t\t\t\t\twindow.scrollX ===\n\t\t\t\t\t\tMath.min(opt.x, document.documentElement.offsetWidth - window.innerWidth) &&\n\t\t\t\t\twindow.scrollY ===\n\t\t\t\t\t\tMath.min(opt.y, document.documentElement.offsetHeight - window.innerHeight),\n\t\t\t\t{ x, y }\n\t\t\t);\n\t\t\tawait page.evaluate(\n\t\t\t\t/** @param {{ x: number, y: number }} opt */ (opt) => window.scrollTo(opt.x, opt.y),\n\t\t\t\t{ x, y }\n\t\t\t);\n\t\t\tawait watcher;\n\t\t}\n\n\t\tawait use(scroll_to);\n\t},\n\n\tin_view: async ({ page }, use) => {\n\t\t/** @param {string} selector */\n\t\tasync function in_view(selector) {\n\t\t\tconst box = await page.locator(selector).boundingBox();\n\t\t\tconst view = page.viewportSize();\n\t\t\treturn !!box && !!view && box.y < view.height && box.y + box.height > 0;\n\t\t}\n\n\t\tawait use(in_view);\n\t},\n\n\tget_computed_style: async ({ page }, use) => {\n\t\t/**\n\t\t * @param {string} selector\n\t\t * @param {string} prop\n\t\t */\n\t\tfunction get_computed_style(selector, prop) {\n\t\t\treturn page.$eval(\n\t\t\t\tselector,\n\t\t\t\t(node, prop) => window.getComputedStyle(node).getPropertyValue(prop),\n\t\t\t\tprop\n\t\t\t);\n\t\t}\n\n\t\tawait use(get_computed_style);\n\t},\n\n\tpage: async ({ page, javaScriptEnabled }, use) => {\n\t\t// automatically wait for kit started event after navigation functions if js is enabled\n\t\tconst page_navigation_functions = /** @type {const} */ (['goto', 'goBack', 'reload']);\n\t\tpage_navigation_functions.forEach((fn) => {\n\t\t\tconst original_page_fn = page[fn];\n\t\t\tif (!original_page_fn) {\n\t\t\t\tthrow new Error(`function does not exist on page: ${fn}`);\n\t\t\t}\n\n\t\t\t/** @param  {...any} args */\n\t\t\tasync function modified_fn(...args) {\n\t\t\t\ttry {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tconst res = await original_page_fn.apply(page, args);\n\t\t\t\t\tif (javaScriptEnabled && args[1]?.wait_for_started !== false) {\n\t\t\t\t\t\tawait page.waitForSelector('body.started', { timeout: 15000 });\n\t\t\t\t\t}\n\t\t\t\t\treturn res;\n\t\t\t\t} catch (e) {\n\t\t\t\t\t// Exclude this function from the stack trace so that it points to the failing test\n\t\t\t\t\t// instead of this file.\n\t\t\t\t\tError.captureStackTrace(/** @type {Error} */ (e), modified_fn);\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpage[fn] = modified_fn;\n\t\t});\n\n\t\tawait use(page);\n\t},\n\n\t// eslint-disable-next-line no-empty-pattern -- Playwright doesn't let us use `_` as a parameter name. It must be a destructured object\n\tread_errors: async ({}, use) => {\n\t\t/** @param {string} path */\n\t\tfunction read_errors(path) {\n\t\t\tconst errors =\n\t\t\t\tfs.existsSync('test/errors.json') &&\n\t\t\t\tJSON.parse(fs.readFileSync('test/errors.json', 'utf8'));\n\t\t\treturn errors[path];\n\t\t}\n\n\t\tawait use(read_errors);\n\t},\n\n\t// eslint-disable-next-line no-empty-pattern -- Playwright doesn't let us use `_` as a parameter name. It must be a destructured object\n\tread_traces: async ({}, use) => {\n\t\t/** @param {string} test_id */\n\t\tfunction read_traces(test_id) {\n\t\t\tconst raw = fs.readFileSync('test/spans.jsonl', 'utf8').split('\\n').filter(Boolean);\n\t\t\tconst traces = /** @type {SpanData[]} */ (raw.map((line) => JSON.parse(line)));\n\n\t\t\treturn traces\n\t\t\t\t.filter((t) => t.parent_span_id === undefined && t.attributes.test_id === test_id)\n\t\t\t\t.map((root_trace) => {\n\t\t\t\t\tconst child_traces = traces.filter((span) => span.trace_id === root_trace.trace_id);\n\t\t\t\t\treturn build_span_tree(root_trace, child_traces);\n\t\t\t\t});\n\t\t}\n\n\t\tawait use(read_traces);\n\t},\n\n\t// eslint-disable-next-line no-empty-pattern -- Playwright doesn't let us use `_` as a parameter name. It must be a destructured object\n\tstart_server: async ({}, use) => {\n\t\t/**\n\t\t * @type {http.Server | undefined}\n\t\t */\n\t\tlet server;\n\n\t\t/**\n\t\t * @type {Set<import('net').Socket> | undefined}\n\t\t */\n\t\tlet sockets;\n\n\t\t/**\n\t\t * @param {(req: http.IncomingMessage, res: http.ServerResponse) => void} handler\n\t\t */\n\t\tasync function start_server(handler) {\n\t\t\tif (server) {\n\t\t\t\tthrow new Error('server already started');\n\t\t\t}\n\t\t\tserver = http.createServer(handler);\n\n\t\t\tawait new Promise((fulfil) => {\n\t\t\t\t/** @type {http.Server} */ (server).listen(0, 'localhost', () => {\n\t\t\t\t\tfulfil(undefined);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tconst { port } = /** @type {import('net').AddressInfo} */ (server.address());\n\t\t\tif (!port) {\n\t\t\t\tthrow new Error(`Could not find port from server ${JSON.stringify(server.address())}`);\n\t\t\t}\n\t\t\tsockets = new Set();\n\t\t\tserver.on('connection', (socket) => {\n\t\t\t\t/** @type {Set<import('net').Socket>} */ (sockets).add(socket);\n\t\t\t\tsocket.on('close', () => {\n\t\t\t\t\t/** @type {Set<import('net').Socket>} */ (sockets).delete(socket);\n\t\t\t\t});\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tport\n\t\t\t};\n\t\t}\n\t\tawait use(start_server);\n\n\t\tif (server) {\n\t\t\tif (sockets) {\n\t\t\t\tsockets.forEach((socket) => {\n\t\t\t\t\tif (!socket.destroyed) {\n\t\t\t\t\t\tsocket.destroy();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tawait new Promise((fulfil, reject) => {\n\t\t\t\t/** @type {http.Server} */ (server).close((err) => {\n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfulfil(undefined);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t},\n\n\t// make sure context fixture depends on start server, so setup/teardown order is\n\t// setup start_server\n\t// setup context\n\t// teardown context\n\t// teardown start_server\n\tasync context({ context, start_server }, use) {\n\t\t// just here make sure start_server is referenced, don't call\n\t\tif (!start_server) {\n\t\t\tthrow new Error('start_server fixture not present');\n\t\t}\n\t\tawait use(context);\n\t\ttry {\n\t\t\tawait context.close();\n\t\t} catch (e) {\n\t\t\tconsole.error('failed to close context fixture', e);\n\t\t}\n\t}\n});\n\nconst known_devices = {\n\tchromium: devices['Desktop Chrome'],\n\tfirefox: devices['Desktop Firefox'],\n\twebkit: devices['Desktop Safari']\n};\nconst test_browser = /** @type {keyof typeof known_devices} */ (\n\tprocess.env.KIT_E2E_BROWSER ?? 'chromium'\n);\n\nconst test_browser_device = known_devices[test_browser]\n\t? {\n\t\t\t...known_devices[test_browser],\n\t\t\tchannel: test_browser === 'chromium' ? 'chromium' : undefined\n\t\t}\n\t: undefined;\n\nif (!test_browser_device) {\n\tthrow new Error(\n\t\t`invalid test browser specified: KIT_E2E_BROWSER=${\n\t\t\tprocess.env.KIT_E2E_BROWSER\n\t\t}. Allowed values: ${Object.keys(known_devices).join(', ')}`\n\t);\n}\n\nexport const config = defineConfig({\n\tforbidOnly: !!process.env.CI,\n\t// generous timeouts on CI\n\ttimeout: process.env.CI ? 45000 : 15000,\n\twebServer: {\n\t\tcommand: process.env.DEV ? 'pnpm dev --force' : 'pnpm build && pnpm preview',\n\t\tport: process.env.DEV ? 5173 : 4173\n\t},\n\tretries: process.env.CI ? 2 : number_from_env('KIT_E2E_RETRIES', 0),\n\tprojects: [\n\t\t{\n\t\t\tname: `${test_browser}-${process.env.DEV ? 'dev' : 'build'}`,\n\t\t\tuse: {\n\t\t\t\tjavaScriptEnabled: true\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: `${test_browser}-${process.env.DEV ? 'dev' : 'build'}-no-js`,\n\t\t\tuse: {\n\t\t\t\tjavaScriptEnabled: false\n\t\t\t}\n\t\t}\n\t],\n\tuse: {\n\t\t...test_browser_device,\n\t\tscreenshot: 'only-on-failure',\n\t\ttrace: 'retain-on-failure'\n\t},\n\tworkers: process.env.CI ? 2 : number_from_env('KIT_E2E_WORKERS', undefined),\n\treporter: process.env.CI\n\t\t? [\n\t\t\t\t['dot'],\n\t\t\t\t[path.resolve(fileURLToPath(import.meta.url), '../github-flaky-warning-reporter.js')]\n\t\t\t]\n\t\t: 'list',\n\ttestDir: 'test',\n\ttestMatch: /(.+\\.)?(test|spec)\\.[jt]s/\n});\n\n/**\n * @param {SpanData} current_span\n * @param {SpanData[]} child_spans\n * @returns {SpanTree}\n */\nfunction build_span_tree(current_span, child_spans) {\n\tconst children = child_spans.filter((span) => span.parent_span_id === current_span.span_id);\n\treturn {\n\t\t...current_span,\n\t\tchildren: children.map((child) => build_span_tree(child, child_spans))\n\t};\n}\n"
  },
  {
    "path": "packages/kit/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2023\",\n\t\t\"module\": \"node16\",\n\t\t\"moduleResolution\": \"node16\",\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t\"paths\": {\n\t\t\t\"@sveltejs/kit\": [\"./src/exports/public.d.ts\"],\n\t\t\t\"@sveltejs/kit/node\": [\"./src/exports/node/index.js\"],\n\t\t\t\"@sveltejs/kit/node/polyfills\": [\"./src/exports/node/polyfills.js\"],\n\t\t\t\"@sveltejs/kit/internal\": [\"./src/exports/internal/index.js\"],\n\t\t\t\"@sveltejs/kit/internal/server\": [\"./src/exports/internal/server.js\"],\n\t\t\t\"$app/paths\": [\"./src/runtime/app/paths/public.d.ts\"],\n\t\t\t\"$app/paths/internal/client\": [\"./src/runtime/app/paths/internal/client.js\"],\n\t\t\t\"$app/paths/internal/server\": [\"./src/runtime/app/paths/internal/server.js\"],\n\t\t\t\"$app/server\": [\"./src/runtime/app/server/index.js\"],\n\t\t\t// internal use only\n\t\t\t\"types\": [\"./src/types/internal.d.ts\"]\n\t\t},\n\t\t\"noUnusedLocals\": true,\n\t\t\"noUnusedParameters\": true\n\t},\n\t\"include\": [\"*.js\", \"scripts/**/*\", \"src/**/*\"],\n\t\"exclude\": [\"./**/write_types/test/**\"]\n}\n"
  },
  {
    "path": "packages/kit/types/index.d.ts",
    "content": "/// <reference types=\"svelte\" />\n/// <reference types=\"vite/client\" />\n\ndeclare module '@sveltejs/kit' {\n\timport type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';\n\timport type { StandardSchemaV1 } from '@standard-schema/spec';\n\timport type { RouteId as AppRouteId, LayoutParams as AppLayoutParams, ResolvedPathname } from '$app/types';\n\t// @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore\n\ttype Span = import('@opentelemetry/api').Span;\n\n\t/**\n\t * [Adapters](https://svelte.dev/docs/kit/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.\n\t */\n\texport interface Adapter {\n\t\t/**\n\t\t * The name of the adapter, using for logging. Will typically correspond to the package name.\n\t\t */\n\t\tname: string;\n\t\t/**\n\t\t * This function is called after SvelteKit has built your app.\n\t\t * @param builder An object provided by SvelteKit that contains methods for adapting the app\n\t\t */\n\t\tadapt: (builder: Builder) => MaybePromise<void>;\n\t\t/**\n\t\t * Checks called during dev and build to determine whether specific features will work in production with this adapter.\n\t\t */\n\t\tsupports?: {\n\t\t\t/**\n\t\t\t * Test support for `read` from `$app/server`.\n\t\t\t * @param details.config The merged route config\n\t\t\t */\n\t\t\tread?: (details: { config: any; route: { id: string } }) => boolean;\n\n\t\t\t/**\n\t\t\t * Test support for `instrumentation.server.js`. To pass, the adapter must support running `instrumentation.server.js` prior to the application code.\n\t\t\t * @since 2.31.0\n\t\t\t */\n\t\t\tinstrumentation?: () => boolean;\n\t\t};\n\t\t/**\n\t\t * Creates an `Emulator`, which allows the adapter to influence the environment\n\t\t * during dev, build and prerendering.\n\t\t */\n\t\temulate?: () => MaybePromise<Emulator>;\n\t}\n\n\texport type LoadProperties<input extends Record<string, any> | void> = input extends void\n\t\t? undefined // needs to be undefined, because void will break intellisense\n\t\t: input extends Record<string, any>\n\t\t\t? input\n\t\t\t: unknown;\n\n\texport type AwaitedActions<T extends Record<string, (...args: any) => any>> = OptionalUnion<\n\t\t{\n\t\t\t[Key in keyof T]: UnpackValidationError<Awaited<ReturnType<T[Key]>>>;\n\t\t}[keyof T]\n\t>;\n\n\t// Takes a union type and returns a union type where each type also has all properties\n\t// of all possible types (typed as undefined), making accessing them more ergonomic\n\ttype OptionalUnion<\n\t\tU extends Record<string, any>, // not unknown, else interfaces don't satisfy this constraint\n\t\tA extends keyof U = U extends U ? keyof U : never\n\t> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;\n\n\tconst uniqueSymbol: unique symbol;\n\n\texport interface ActionFailure<T = undefined> {\n\t\tstatus: number;\n\t\tdata: T;\n\t\t[uniqueSymbol]: true; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure\n\t}\n\n\ttype UnpackValidationError<T> =\n\t\tT extends ActionFailure<infer X>\n\t\t\t? X\n\t\t\t: T extends void\n\t\t\t\t? undefined // needs to be undefined, because void will corrupt union type\n\t\t\t\t: T;\n\n\t/**\n\t * This object is passed to the `adapt` function of adapters.\n\t * It contains various methods and properties that are useful for adapting the app.\n\t */\n\texport interface Builder {\n\t\t/** Print messages to the console. `log.info` and `log.minor` are silent unless Vite's `logLevel` is `info`. */\n\t\tlog: Logger;\n\t\t/** Remove `dir` and all its contents. */\n\t\trimraf: (dir: string) => void;\n\t\t/** Create `dir` and any required parent directories. */\n\t\tmkdirp: (dir: string) => void;\n\n\t\t/** The fully resolved Svelte config. */\n\t\tconfig: ValidatedConfig;\n\t\t/** Information about prerendered pages and assets, if any. */\n\t\tprerendered: Prerendered;\n\t\t/** An array of all routes (including prerendered) */\n\t\troutes: RouteDefinition[];\n\n\t\t// TODO 3.0 remove this method\n\t\t/**\n\t\t * Create separate functions that map to one or more routes of your app.\n\t\t * @param fn A function that groups a set of routes into an entry point\n\t\t * @deprecated Use `builder.routes` instead\n\t\t */\n\t\tcreateEntries: (fn: (route: RouteDefinition) => AdapterEntry) => Promise<void>;\n\n\t\t/**\n\t\t * Find all the assets imported by server files belonging to `routes`\n\t\t */\n\t\tfindServerAssets: (routes: RouteDefinition[]) => string[];\n\n\t\t/**\n\t\t * Generate a fallback page for a static webserver to use when no route is matched. Useful for single-page apps.\n\t\t */\n\t\tgenerateFallback: (dest: string) => Promise<void>;\n\n\t\t/**\n\t\t * Generate a module exposing build-time environment variables as `$env/dynamic/public`.\n\t\t */\n\t\tgenerateEnvModule: () => void;\n\n\t\t/**\n\t\t * Generate a server-side manifest to initialise the SvelteKit [server](https://svelte.dev/docs/kit/@sveltejs-kit#Server) with.\n\t\t * @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\n\t\t */\n\t\tgenerateManifest: (opts: { relativePath: string; routes?: RouteDefinition[] }) => string;\n\n\t\t/**\n\t\t * Resolve a path to the `name` directory inside `outDir`, e.g. `/path/to/.svelte-kit/my-adapter`.\n\t\t * @param name path to the file, relative to the build directory\n\t\t */\n\t\tgetBuildDirectory: (name: string) => string;\n\t\t/** Get the fully resolved path to the directory containing client-side assets, including the contents of your `static` directory. */\n\t\tgetClientDirectory: () => string;\n\t\t/** Get the fully resolved path to the directory containing server-side code. */\n\t\tgetServerDirectory: () => string;\n\t\t/** Get the application path including any configured `base` path, e.g. `my-base-path/_app`. */\n\t\tgetAppPath: () => string;\n\n\t\t/**\n\t\t * Write client assets to `dest`.\n\t\t * @param dest the destination folder\n\t\t * @returns an array of files written to `dest`\n\t\t */\n\t\twriteClient: (dest: string) => string[];\n\t\t/**\n\t\t * Write prerendered files to `dest`.\n\t\t * @param dest the destination folder\n\t\t * @returns an array of files written to `dest`\n\t\t */\n\t\twritePrerendered: (dest: string) => string[];\n\t\t/**\n\t\t * Write server-side code to `dest`.\n\t\t * @param dest the destination folder\n\t\t * @returns an array of files written to `dest`\n\t\t */\n\t\twriteServer: (dest: string) => string[];\n\t\t/**\n\t\t * Copy a file or directory.\n\t\t * @param from the source file or directory\n\t\t * @param to the destination file or directory\n\t\t * @param opts.filter a function to determine whether a file or directory should be copied\n\t\t * @param opts.replace a map of strings to replace\n\t\t * @returns an array of files that were copied\n\t\t */\n\t\tcopy: (\n\t\t\tfrom: string,\n\t\t\tto: string,\n\t\t\topts?: {\n\t\t\t\tfilter?(basename: string): boolean;\n\t\t\t\treplace?: Record<string, string>;\n\t\t\t}\n\t\t) => string[];\n\n\t\t/**\n\t\t * Check if the server instrumentation file exists.\n\t\t * @returns true if the server instrumentation file exists, false otherwise\n\t\t * @since 2.31.0\n\t\t */\n\t\thasServerInstrumentationFile: () => boolean;\n\n\t\t/**\n\t\t * Instrument `entrypoint` with `instrumentation`.\n\t\t *\n\t\t * Renames `entrypoint` to `start` and creates a new module at\n\t\t * `entrypoint` which imports `instrumentation` and then dynamically imports `start`. This allows\n\t\t * the module hooks necessary for instrumentation libraries to be loaded prior to any application code.\n\t\t *\n\t\t * Caveats:\n\t\t * - \"Live exports\" will not work. If your adapter uses live exports, your users will need to manually import the server instrumentation on startup.\n\t\t * - If `tla` is `false`, OTEL auto-instrumentation may not work properly. Use it if your environment supports it.\n\t\t * - Use `hasServerInstrumentationFile` to check if the user has a server instrumentation file; if they don't, you shouldn't do this.\n\t\t *\n\t\t * @param options an object containing the following properties:\n\t\t * @param options.entrypoint the path to the entrypoint to trace.\n\t\t * @param options.instrumentation the path to the instrumentation file.\n\t\t * @param options.start the name of the start file. This is what `entrypoint` will be renamed to.\n\t\t * @param options.module configuration for the resulting entrypoint module.\n\t\t * @param options.module.generateText a function that receives the relative paths to the instrumentation and start files, and generates the text of the module to be traced. If not provided, the default implementation will be used, which uses top-level await.\n\t\t * @since 2.31.0\n\t\t */\n\t\tinstrument: (args: {\n\t\t\tentrypoint: string;\n\t\t\tinstrumentation: string;\n\t\t\tstart?: string;\n\t\t\tmodule?:\n\t\t\t\t| {\n\t\t\t\t\t\texports: string[];\n\t\t\t\t  }\n\t\t\t\t| {\n\t\t\t\t\t\tgenerateText: (args: { instrumentation: string; start: string }) => string;\n\t\t\t\t  };\n\t\t}) => void;\n\n\t\t/**\n\t\t * Compress files in `directory` with gzip and brotli, where appropriate. Generates `.gz` and `.br` files alongside the originals.\n\t\t * @param directory The directory containing the files to be compressed\n\t\t */\n\t\tcompress: (directory: string) => Promise<void>;\n\t}\n\n\t/**\n\t * An extension of [`vite-plugin-svelte`'s options](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#svelte-options).\n\t */\n\texport interface Config extends SvelteConfig {\n\t\t/**\n\t\t * SvelteKit options.\n\t\t *\n\t\t * @see https://svelte.dev/docs/kit/configuration\n\t\t */\n\t\tkit?: KitConfig;\n\t\t/** Any additional options required by tooling that integrates with Svelte. */\n\t\t[key: string]: any;\n\t}\n\n\texport interface Cookies {\n\t\t/**\n\t\t * Gets a cookie that was previously set with `cookies.set`, or from the request headers.\n\t\t * @param name the name of the cookie\n\t\t * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options)\n\t\t */\n\t\tget: (name: string, opts?: import('cookie').CookieParseOptions) => string | undefined;\n\n\t\t/**\n\t\t * Gets all cookies that were previously set with `cookies.set`, or from the request headers.\n\t\t * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options)\n\t\t */\n\t\tgetAll: (opts?: import('cookie').CookieParseOptions) => Array<{ name: string; value: string }>;\n\n\t\t/**\n\t\t * 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.\n\t\t *\n\t\t * 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`.\n\t\t *\n\t\t * 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\n\t\t * @param name the name of the cookie\n\t\t * @param value the cookie value\n\t\t * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options)\n\t\t */\n\t\tset: (\n\t\t\tname: string,\n\t\t\tvalue: string,\n\t\t\topts: import('cookie').CookieSerializeOptions & { path: string }\n\t\t) => void;\n\n\t\t/**\n\t\t * Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.\n\t\t *\n\t\t * 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\n\t\t * @param name the name of the cookie\n\t\t * @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)\n\t\t */\n\t\tdelete: (name: string, opts: import('cookie').CookieSerializeOptions & { path: string }) => void;\n\n\t\t/**\n\t\t * Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.\n\t\t *\n\t\t * 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`.\n\t\t *\n\t\t * 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\n\t\t *\n\t\t * @param name the name of the cookie\n\t\t * @param value the cookie value\n\t\t * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options)\n\t\t */\n\t\tserialize: (\n\t\t\tname: string,\n\t\t\tvalue: string,\n\t\t\topts: import('cookie').CookieSerializeOptions & { path: string }\n\t\t) => string;\n\t}\n\n\t/**\n\t * A collection of functions that influence the environment during dev, build and prerendering\n\t */\n\texport interface Emulator {\n\t\t/**\n\t\t * A function that is called with the current route `config` and `prerender` option\n\t\t * and returns an `App.Platform` object\n\t\t */\n\t\tplatform?(details: { config: any; prerender: PrerenderOption }): MaybePromise<App.Platform>;\n\t}\n\n\texport interface KitConfig {\n\t\t/**\n\t\t * Your [adapter](https://svelte.dev/docs/kit/adapters) is run when executing `vite build`. It determines how the output is converted for different platforms.\n\t\t * @default undefined\n\t\t */\n\t\tadapter?: Adapter;\n\t\t/**\n\t\t * An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript.\n\t\t *\n\t\t * ```js\n\t\t * /// file: svelte.config.js\n\t\t * /// type: import('@sveltejs/kit').Config\n\t\t * const config = {\n\t\t *   kit: {\n\t\t *     alias: {\n\t\t *       // this will match a file\n\t\t *       'my-file': 'path/to/my-file.js',\n\t\t *\n\t\t *       // this will match a directory and its contents\n\t\t *       // (`my-directory/x` resolves to `path/to/my-directory/x`)\n\t\t *       'my-directory': 'path/to/my-directory',\n\t\t *\n\t\t *       // an alias ending /* will only match\n\t\t *       // the contents of a directory, not the directory itself\n\t\t *       'my-directory/*': 'path/to/my-directory/*'\n\t\t *     }\n\t\t *   }\n\t\t * };\n\t\t * ```\n\t\t *\n\t\t * > [!NOTE] You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.\n\t\t * @default {}\n\t\t */\n\t\talias?: Record<string, string>;\n\t\t/**\n\t\t * The directory where SvelteKit keeps its stuff, including static assets (such as JS and CSS) and internally-used routes.\n\t\t *\n\t\t * If `paths.assets` is specified, there will be two app directories — `${paths.assets}/${appDir}` and `${paths.base}/${appDir}`.\n\t\t * @default \"_app\"\n\t\t */\n\t\tappDir?: string;\n\t\t/**\n\t\t * [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...\n\t\t *\n\t\t * ```js\n\t\t * /// file: svelte.config.js\n\t\t * /// type: import('@sveltejs/kit').Config\n\t\t * const config = {\n\t\t *   kit: {\n\t\t *     csp: {\n\t\t *       directives: {\n\t\t *         'script-src': ['self']\n\t\t *       },\n\t\t *       // must be specified with either the `report-uri` or `report-to` directives, or both\n\t\t *       reportOnly: {\n\t\t *         'script-src': ['self'],\n\t\t *         'report-uri': ['/']\n\t\t *       }\n\t\t *     }\n\t\t *   }\n\t\t * };\n\t\t *\n\t\t * export default config;\n\t\t * ```\n\t\t *\n\t\t * ...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.\n\t\t *\n\t\t * To add a nonce for scripts and links manually included in `src/app.html`, you may use the placeholder `%sveltekit.nonce%` (for example `<script nonce=\"%sveltekit.nonce%\">`).\n\t\t *\n\t\t * When pages are prerendered, the CSP header is added via a `<meta http-equiv>` tag (note that in this case, `frame-ancestors`, `report-uri` and `sandbox` directives will be ignored).\n\t\t *\n\t\t * > [!NOTE] When `mode` is `'auto'`, SvelteKit will use nonces for dynamically rendered pages and hashes for prerendered pages. Using nonces with prerendered pages is insecure and therefore forbidden.\n\t\t *\n\t\t * > [!NOTE] Note that most [Svelte transitions](https://svelte.dev/tutorial/svelte/transition) work by creating an inline `<style>` element. If you use these in your app, you must either leave the `style-src` directive unspecified or add `unsafe-inline`.\n\t\t *\n\t\t * If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle) to roll your own CSP.\n\t\t */\n\t\tcsp?: {\n\t\t\t/**\n\t\t\t * Whether to use hashes or nonces to restrict `<script>` and `<style>` elements. `'auto'` will use hashes for prerendered pages, and nonces for dynamically rendered pages.\n\t\t\t */\n\t\t\tmode?: 'hash' | 'nonce' | 'auto';\n\t\t\t/**\n\t\t\t * Directives that will be added to `Content-Security-Policy` headers.\n\t\t\t */\n\t\t\tdirectives?: CspDirectives;\n\t\t\t/**\n\t\t\t * Directives that will be added to `Content-Security-Policy-Report-Only` headers.\n\t\t\t */\n\t\t\treportOnly?: CspDirectives;\n\t\t};\n\t\t/**\n\t\t * Protection against [cross-site request forgery (CSRF)](https://owasp.org/www-community/attacks/csrf) attacks.\n\t\t */\n\t\tcsrf?: {\n\t\t\t/**\n\t\t\t * Whether to check the incoming `origin` header for `POST`, `PUT`, `PATCH`, or `DELETE` form submissions and verify that it matches the server's origin.\n\t\t\t *\n\t\t\t * To allow people to make `POST`, `PUT`, `PATCH`, or `DELETE` requests with a `Content-Type` of `application/x-www-form-urlencoded`, `multipart/form-data`, or `text/plain` to your app from other origins, you will need to disable this option. Be careful!\n\t\t\t * @default true\n\t\t\t * @deprecated Use `trustedOrigins: ['*']` instead\n\t\t\t */\n\t\t\tcheckOrigin?: boolean;\n\t\t\t/**\n\t\t\t * An array of origins that are allowed to make cross-origin form submissions to your app.\n\t\t\t *\n\t\t\t * Each origin should be a complete origin including protocol (e.g., `https://payment-gateway.com`).\n\t\t\t * This is useful for allowing trusted third-party services like payment gateways or authentication providers to submit forms to your app.\n\t\t\t *\n\t\t\t * If the array contains `'*'`, all origins will be trusted. This is generally not recommended!\n\t\t\t *\n\t\t\t * > [!NOTE] Only add origins you completely trust, as this bypasses CSRF protection for those origins.\n\t\t\t *\n\t\t\t * CSRF checks only apply in production, not in local development.\n\t\t\t * @default []\n\t\t\t * @example ['https://checkout.stripe.com', 'https://accounts.google.com']\n\t\t\t */\n\t\t\ttrustedOrigins?: string[];\n\t\t};\n\t\t/**\n\t\t * Whether or not the app is embedded inside a larger app. If `true`, SvelteKit will add its event listeners related to navigation etc on the parent of `%sveltekit.body%` instead of `window`, and will pass `params` from the server rather than inferring them from `location.pathname`.\n\t\t * Note that it is generally not supported to embed multiple SvelteKit apps on the same page and use client-side SvelteKit features within them (things such as pushing to the history state assume a single instance).\n\t\t * @default false\n\t\t */\n\t\tembedded?: boolean;\n\t\t/**\n\t\t * Environment variable configuration\n\t\t */\n\t\tenv?: {\n\t\t\t/**\n\t\t\t * The directory to search for `.env` files.\n\t\t\t * @default \".\"\n\t\t\t */\n\t\t\tdir?: string;\n\t\t\t/**\n\t\t\t * A prefix that signals that an environment variable is safe to expose to client-side code. See [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) and [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public). Note that Vite's [`envPrefix`](https://vitejs.dev/config/shared-options.html#envprefix) must be set separately if you are using Vite's environment variable handling - though use of that feature should generally be unnecessary.\n\t\t\t * @default \"PUBLIC_\"\n\t\t\t */\n\t\t\tpublicPrefix?: string;\n\t\t\t/**\n\t\t\t * A prefix that signals that an environment variable is unsafe to expose to client-side code. Environment variables matching neither the public nor the private prefix will be discarded completely. See [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) and [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private).\n\t\t\t * @default \"\"\n\t\t\t * @since 1.21.0\n\t\t\t */\n\t\t\tprivatePrefix?: string;\n\t\t};\n\t\t/** Experimental features. Here be dragons. These are not subject to semantic versioning, so breaking changes or removal can happen in any release. */\n\t\texperimental?: {\n\t\t\t/**\n\t\t\t * Options for enabling server-side [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions).\n\t\t\t * @default { server: false, serverFile: false }\n\t\t\t * @since 2.31.0\n\t\t\t */\n\t\t\ttracing?: {\n\t\t\t\t/**\n\t\t\t\t * Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions).\n\t\t\t\t * @default false\n\t\t\t\t * @since 2.31.0\n\t\t\t\t */\n\t\t\t\tserver?: boolean;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * @since 2.31.0\n\t\t\t */\n\t\t\tinstrumentation?: {\n\t\t\t\t/**\n\t\t\t\t * Enables `instrumentation.server.js` for tracing and observability instrumentation.\n\t\t\t\t * @default false\n\t\t\t\t * @since 2.31.0\n\t\t\t\t */\n\t\t\t\tserver?: boolean;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Whether to enable the experimental remote functions feature. This feature is not yet stable and may be changed or removed at any time.\n\t\t\t * @default false\n\t\t\t */\n\t\t\tremoteFunctions?: boolean;\n\n\t\t\t/**\n\t\t\t * Whether to enable the experimental forked preloading feature using Svelte's fork API.\n\t\t\t * @default false\n\t\t\t */\n\t\t\tforkPreloads?: boolean;\n\n\t\t\t/**\n\t\t\t * Whether to enable the experimental handling of rendering errors.\n\t\t\t * When enabled, `<svelte:boundary>` is used to wrap components at each level\n\t\t\t * where there's an `+error.svelte`, rendering the error page if the component fails.\n\t\t\t * In addition, error boundaries also work on the server and the error object goes through `handleError`.\n\t\t\t * @default false\n\t\t\t */\n\t\t\thandleRenderingErrors?: boolean;\n\t\t};\n\t\t/**\n\t\t * Where to find various files within your project.\n\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t */\n\t\tfiles?: {\n\t\t\t/**\n\t\t\t * The location of your source code.\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"src\"\n\t\t\t * @since 2.28\n\t\t\t */\n\t\t\tsrc?: string;\n\t\t\t/**\n\t\t\t * A place to put static files that should have stable URLs and undergo no processing, such as `favicon.ico` or `manifest.json`.\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"static\"\n\t\t\t */\n\t\t\tassets?: string;\n\t\t\thooks?: {\n\t\t\t\t/**\n\t\t\t\t * The location of your client [hooks](https://svelte.dev/docs/kit/hooks).\n\t\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t\t * @default \"src/hooks.client\"\n\t\t\t\t */\n\t\t\t\tclient?: string;\n\t\t\t\t/**\n\t\t\t\t * The location of your server [hooks](https://svelte.dev/docs/kit/hooks).\n\t\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t\t * @default \"src/hooks.server\"\n\t\t\t\t */\n\t\t\t\tserver?: string;\n\t\t\t\t/**\n\t\t\t\t * The location of your universal [hooks](https://svelte.dev/docs/kit/hooks).\n\t\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t\t * @default \"src/hooks\"\n\t\t\t\t * @since 2.3.0\n\t\t\t\t */\n\t\t\t\tuniversal?: string;\n\t\t\t};\n\t\t\t/**\n\t\t\t * Your app's internal library, accessible throughout the codebase as `$lib`.\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"src/lib\"\n\t\t\t */\n\t\t\tlib?: string;\n\t\t\t/**\n\t\t\t * A directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching).\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"src/params\"\n\t\t\t */\n\t\t\tparams?: string;\n\t\t\t/**\n\t\t\t * The files that define the structure of your app (see [Routing](https://svelte.dev/docs/kit/routing)).\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"src/routes\"\n\t\t\t */\n\t\t\troutes?: string;\n\t\t\t/**\n\t\t\t * The location of your service worker's entry point (see [Service workers](https://svelte.dev/docs/kit/service-workers)).\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"src/service-worker\"\n\t\t\t */\n\t\t\tserviceWorker?: string;\n\t\t\t/**\n\t\t\t * The location of the template for HTML responses.\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"src/app.html\"\n\t\t\t */\n\t\t\tappTemplate?: string;\n\t\t\t/**\n\t\t\t * The location of the template for fallback error responses.\n\t\t\t * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead\n\t\t\t * @default \"src/error.html\"\n\t\t\t */\n\t\t\terrorTemplate?: string;\n\t\t};\n\t\t/**\n\t\t * Inline CSS inside a `<style>` block at the head of the HTML. This option is a number that specifies the maximum length of a CSS file in UTF-16 code units, as specified by the [String.length](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) property, to be inlined. All CSS files needed for the page that are smaller than this value are merged and inlined in a `<style>` block.\n\t\t *\n\t\t * > [!NOTE] This results in fewer initial requests and can improve your [First Contentful Paint](https://web.dev/first-contentful-paint) score. However, it generates larger HTML output and reduces the effectiveness of browser caches. Use it advisedly.\n\t\t * @default 0\n\t\t */\n\t\tinlineStyleThreshold?: number;\n\t\t/**\n\t\t * An array of file extensions that SvelteKit will treat as modules. Files with extensions that match neither `config.extensions` nor `config.kit.moduleExtensions` will be ignored by the router.\n\t\t * @default [\".js\", \".ts\"]\n\t\t */\n\t\tmoduleExtensions?: string[];\n\t\t/**\n\t\t * The directory that SvelteKit writes files to during `dev` and `build`. You should exclude this directory from version control.\n\t\t * @default \".svelte-kit\"\n\t\t */\n\t\toutDir?: string;\n\t\t/**\n\t\t * Options related to the build output format\n\t\t */\n\t\toutput?: {\n\t\t\t/**\n\t\t\t * SvelteKit will preload the JavaScript modules needed for the initial page to avoid import 'waterfalls', resulting in faster application startup. There\n\t\t\t * are three strategies with different trade-offs:\n\t\t\t * - `modulepreload` - uses `<link rel=\"modulepreload\">`. This delivers the best results in Chromium-based browsers, in Firefox 115+, and Safari 17+. It is ignored in older browsers.\n\t\t\t * - `preload-js` - uses `<link rel=\"preload\">`. Prevents waterfalls in Chromium and Safari, but Chromium will parse each module twice (once as a script, once as a module). Causes modules to be requested twice in Firefox. This is a good setting if you want to maximise performance for users on iOS devices at the cost of a very slight degradation for Chromium users.\n\t\t\t * - `preload-mjs` - uses `<link rel=\"preload\">` but with the `.mjs` extension which prevents double-parsing in Chromium. Some static webservers will fail to serve .mjs files with a `Content-Type: application/javascript` header, which will cause your application to break. If that doesn't apply to you, this is the option that will deliver the best performance for the largest number of users, until `modulepreload` is more widely supported.\n\t\t\t * @default \"modulepreload\"\n\t\t\t * @since 1.8.4\n\t\t\t */\n\t\t\tpreloadStrategy?: 'modulepreload' | 'preload-js' | 'preload-mjs';\n\t\t\t/**\n\t\t\t * The bundle strategy option affects how your app's JavaScript and CSS files are loaded.\n\t\t\t * - If `'split'`, splits the app up into multiple .js/.css files so that they are loaded lazily as the user navigates around the app. This is the default, and is recommended for most scenarios.\n\t\t\t * - If `'single'`, creates just one .js bundle and one .css file containing code for the entire app.\n\t\t\t * - If `'inline'`, inlines all JavaScript and CSS of the entire app into the HTML. The result is usable without a server (i.e. you can just open the file in your browser).\n\t\t\t *\n\t\t\t * When using `'split'`, you can also adjust the bundling behaviour by setting [`output.experimentalMinChunkSize`](https://rollupjs.org/configuration-options/#output-experimentalminchunksize) and [`output.manualChunks`](https://rollupjs.org/configuration-options/#output-manualchunks) inside your Vite config's [`build.rollupOptions`](https://vite.dev/config/build-options.html#build-rollupoptions).\n\t\t\t *\n\t\t\t * If you want to inline your assets, you'll need to set Vite's [`build.assetsInlineLimit`](https://vite.dev/config/build-options.html#build-assetsinlinelimit) option to an appropriate size then import your assets through Vite.\n\t\t\t *\n\t\t\t * ```js\n\t\t\t * /// file: vite.config.js\n\t\t\t * import { sveltekit } from '@sveltejs/kit/vite';\n\t\t\t * import { defineConfig } from 'vite';\n\t\t\t *\n\t\t\t * export default defineConfig({\n\t\t\t *   plugins: [sveltekit()],\n\t\t\t *   build: {\n\t\t\t *     // inline all imported assets\n\t\t\t *     assetsInlineLimit: Infinity\n\t\t\t *   }\n\t\t\t * });\n\t\t\t * ```\n\t\t\t *\n\t\t\t * ```svelte\n\t\t\t * /// file: src/routes/+layout.svelte\n\t\t\t * <script>\n\t\t\t *   // import the asset through Vite\n\t\t\t *   import favicon from './favicon.png';\n\t\t\t * </script>\n\t\t\t *\n\t\t\t * <svelte:head>\n\t\t\t *   <!-- this asset will be inlined as a base64 URL -->\n\t\t\t *   <link rel=\"icon\" href={favicon} />\n\t\t\t * </svelte:head>\n\t\t\t * ```\n\t\t\t * @default 'split'\n\t\t\t * @since 2.13.0\n\t\t\t */\n\t\t\tbundleStrategy?: 'split' | 'single' | 'inline';\n\t\t};\n\t\tpaths?: {\n\t\t\t/**\n\t\t\t * An absolute path that your app's files are served from. This is useful if your files are served from a storage bucket of some kind.\n\t\t\t * @default \"\"\n\t\t\t */\n\t\t\tassets?: '' | `http://${string}` | `https://${string}`;\n\t\t\t/**\n\t\t\t * A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`base` from `$app/paths`](https://svelte.dev/docs/kit/$app-paths#base) for that: `<a href=\"{base}/your-page\">Link</a>`. If you find yourself writing this often, it may make sense to extract this into a reusable component.\n\t\t\t * @default \"\"\n\t\t\t */\n\t\t\tbase?: '' | `/${string}`;\n\t\t\t/**\n\t\t\t * Whether to use relative asset paths.\n\t\t\t *\n\t\t\t * If `true`, `base` and `assets` imported from `$app/paths` will be replaced with relative asset paths during server-side rendering, resulting in more portable HTML.\n\t\t\t * If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL\n\t\t\t *\n\t\t\t * [Single-page app](https://svelte.dev/docs/kit/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.\n\t\t\t *\n\t\t\t * If your app uses a `<base>` element, you should set this to `false`, otherwise asset URLs will incorrectly be resolved against the `<base>` URL rather than the current page.\n\t\t\t *\n\t\t\t * In 1.0, `undefined` was a valid value, which was set by default. In that case, if `paths.assets` was not external, SvelteKit would replace `%sveltekit.assets%` with a relative path and use relative paths to reference build artifacts, but `base` and `assets` imported from `$app/paths` would be as specified in your config.\n\t\t\t *\n\t\t\t * @default true\n\t\t\t * @since 1.9.0\n\t\t\t */\n\t\t\trelative?: boolean;\n\t\t};\n\t\t/**\n\t\t * See [Prerendering](https://svelte.dev/docs/kit/page-options#prerender).\n\t\t */\n\t\tprerender?: {\n\t\t\t/**\n\t\t\t * How many pages can be prerendered simultaneously. JS is single-threaded, but in cases where prerendering performance is network-bound (for example loading content from a remote CMS) this can speed things up by processing other tasks while waiting on the network response.\n\t\t\t * @default 1\n\t\t\t */\n\t\t\tconcurrency?: number;\n\t\t\t/**\n\t\t\t * Whether SvelteKit should find pages to prerender by following links from `entries`.\n\t\t\t * @default true\n\t\t\t */\n\t\t\tcrawl?: boolean;\n\t\t\t/**\n\t\t\t * An array of pages to prerender, or start crawling from (if `crawl: true`). The `*` string includes all routes containing no required `[parameters]`  with optional parameters included as being empty (since SvelteKit doesn't know what value any parameters should have).\n\t\t\t * @default [\"*\"]\n\t\t\t */\n\t\t\tentries?: Array<'*' | `/${string}`>;\n\t\t\t/**\n\t\t\t * How to respond to HTTP errors encountered while prerendering the app.\n\t\t\t *\n\t\t\t * - `'fail'` — fail the build\n\t\t\t * - `'ignore'` - silently ignore the failure and continue\n\t\t\t * - `'warn'` — continue, but print a warning\n\t\t\t * - `(details) => void` — a custom error handler that takes a `details` object with `status`, `path`, `referrer`, `referenceType` and `message` properties. If you `throw` from this function, the build will fail\n\t\t\t *\n\t\t\t * ```js\n\t\t\t * /// file: svelte.config.js\n\t\t\t * /// type: import('@sveltejs/kit').Config\n\t\t\t * const config = {\n\t\t\t *   kit: {\n\t\t\t *     prerender: {\n\t\t\t *       handleHttpError: ({ path, referrer, message }) => {\n\t\t\t *         // ignore deliberate link to shiny 404 page\n\t\t\t *         if (path === '/not-found' && referrer === '/blog/how-we-built-our-404-page') {\n\t\t\t *           return;\n\t\t\t *         }\n\t\t\t *\n\t\t\t *         // otherwise fail the build\n\t\t\t *         throw new Error(message);\n\t\t\t *       }\n\t\t\t *     }\n\t\t\t *   }\n\t\t\t * };\n\t\t\t * ```\n\t\t\t *\n\t\t\t * @default \"fail\"\n\t\t\t * @since 1.15.7\n\t\t\t */\n\t\t\thandleHttpError?: PrerenderHttpErrorHandlerValue;\n\t\t\t/**\n\t\t\t * How to respond when hash links from one prerendered page to another don't correspond to an `id` on the destination page.\n\t\t\t *\n\t\t\t * - `'fail'` — fail the build\n\t\t\t * - `'ignore'` - silently ignore the failure and continue\n\t\t\t * - `'warn'` — continue, but print a warning\n\t\t\t * - `(details) => void` — a custom error handler that takes a `details` object with `path`, `id`, `referrers` and `message` properties. If you `throw` from this function, the build will fail\n\t\t\t *\n\t\t\t * @default \"fail\"\n\t\t\t * @since 1.15.7\n\t\t\t */\n\t\t\thandleMissingId?: PrerenderMissingIdHandlerValue;\n\t\t\t/**\n\t\t\t * How to respond when an entry generated by the `entries` export doesn't match the route it was generated from.\n\t\t\t *\n\t\t\t * - `'fail'` — fail the build\n\t\t\t * - `'ignore'` - silently ignore the failure and continue\n\t\t\t * - `'warn'` — continue, but print a warning\n\t\t\t * - `(details) => void` — a custom error handler that takes a `details` object with `generatedFromId`, `entry`, `matchedId` and `message` properties. If you `throw` from this function, the build will fail\n\t\t\t *\n\t\t\t * @default \"fail\"\n\t\t\t * @since 1.16.0\n\t\t\t */\n\t\t\thandleEntryGeneratorMismatch?: PrerenderEntryGeneratorMismatchHandlerValue;\n\t\t\t/**\n\t\t\t * How to respond when a route is marked as prerenderable but has not been prerendered.\n\t\t\t *\n\t\t\t * - `'fail'` — fail the build\n\t\t\t * - `'ignore'` - silently ignore the failure and continue\n\t\t\t * - `'warn'` — continue, but print a warning\n\t\t\t * - `(details) => void` — a custom error handler that takes a `details` object with a `routes` property which contains all routes that haven't been prerendered. If you `throw` from this function, the build will fail\n\t\t\t *\n\t\t\t * The default behavior is to fail the build. This may be undesirable when you know that some of your routes may never be reached under certain\n\t\t\t * circumstances such as a CMS not returning data for a specific area, resulting in certain routes never being reached.\n\t\t\t *\n\t\t\t * @default \"fail\"\n\t\t\t * @since 2.16.0\n\t\t\t */\n\t\t\thandleUnseenRoutes?: PrerenderUnseenRoutesHandlerValue;\n\t\t\t/**\n\t\t\t * The value of `url.origin` during prerendering; useful if it is included in rendered content.\n\t\t\t * @default \"http://sveltekit-prerender\"\n\t\t\t */\n\t\t\torigin?: string;\n\t\t};\n\t\trouter?: {\n\t\t\t/**\n\t\t\t * What type of client-side router to use.\n\t\t\t * - `'pathname'` is the default and means the current URL pathname determines the route\n\t\t\t * - `'hash'` means the route is determined by `location.hash`. In this case, SSR and prerendering are disabled. This is only recommended if `pathname` is not an option, for example because you don't control the webserver where your app is deployed.\n\t\t\t *   It comes with some caveats: you can't use server-side rendering (or indeed any server logic), and you have to make sure that the links in your app all start with #/, or they won't work. Beyond that, everything works exactly like a normal SvelteKit app.\n\t\t\t *\n\t\t\t * @default \"pathname\"\n\t\t\t * @since 2.14.0\n\t\t\t */\n\t\t\ttype?: 'pathname' | 'hash';\n\t\t\t/**\n\t\t\t * How to determine which route to load when navigating to a new page.\n\t\t\t *\n\t\t\t * By default, SvelteKit will serve a route manifest to the browser.\n\t\t\t * When navigating, this manifest is used (along with the `reroute` hook, if it exists) to determine which components to load and which `load` functions to run.\n\t\t\t * Because everything happens on the client, this decision can be made immediately. The drawback is that the manifest needs to be\n\t\t\t * loaded and parsed before the first navigation can happen, which may have an impact if your app contains many routes.\n\t\t\t *\n\t\t\t * Alternatively, SvelteKit can determine the route on the server. This means that for every navigation to a path that has not yet been visited, the server will be asked to determine the route.\n\t\t\t * This has several advantages:\n\t\t\t * - The client does not need to load the routing manifest upfront, which can lead to faster initial page loads\n\t\t\t * - The list of routes is hidden from public view\n\t\t\t * - The server has an opportunity to intercept each navigation (for example through a middleware), enabling (for example) A/B testing opaque to SvelteKit\n\n\t\t\t * The drawback is that for unvisited paths, resolution will take slightly longer (though this is mitigated by [preloading](https://svelte.dev/docs/kit/link-options#data-sveltekit-preload-data)).\n\t\t\t *\n\t\t\t * > [!NOTE] When using server-side route resolution and prerendering, the resolution is prerendered along with the route itself.\n\t\t\t *\n\t\t\t * @default \"client\"\n\t\t\t * @since 2.17.0\n\t\t\t */\n\t\t\tresolution?: 'client' | 'server';\n\t\t};\n\t\tserviceWorker?: {\n\t\t\t/**\n\t\t\t * Determine which files in your `static` directory will be available in `$service-worker.files`.\n\t\t\t * @default (filename) => !/\\.DS_Store/.test(filename)\n\t\t\t */\n\t\t\tfiles?: (file: string) => boolean;\n\t\t} & (\n\t\t\t| {\n\t\t\t\t\t/**\n\t\t\t\t\t * Whether to automatically register the service worker, if it exists.\n\t\t\t\t\t * @default true\n\t\t\t\t\t */\n\t\t\t\t\tregister: true;\n\t\t\t\t\t/**\n\t\t\t\t\t * Options for serviceWorker.register(\"...\", options);\n\t\t\t\t\t */\n\t\t\t\t\toptions?: RegistrationOptions;\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\t/**\n\t\t\t\t\t * Whether to automatically register the service worker, if it exists.\n\t\t\t\t\t * @default true\n\t\t\t\t\t */\n\t\t\t\t\tregister?: false;\n\t\t\t  }\n\t\t);\n\t\ttypescript?: {\n\t\t\t/**\n\t\t\t * A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.\n\t\t\t * This is useful for extending a shared `tsconfig.json` in a monorepo root, for example.\n\t\t\t *\n\t\t\t * Note that any paths configured here should be relative to the generated config file, which is written to `.svelte-kit/tsconfig.json`.\n\t\t\t *\n\t\t\t * @default (config) => config\n\t\t\t * @since 1.3.0\n\t\t\t */\n\t\t\tconfig?: (config: Record<string, any>) => Record<string, any> | void;\n\t\t};\n\t\t/**\n\t\t * Client-side navigation can be buggy if you deploy a new version of your app while people are using it. If the code for the new page is already loaded, it may have stale content; if it isn't, the app's route manifest may point to a JavaScript file that no longer exists.\n\t\t * SvelteKit helps you solve this problem through version management.\n\t\t * If SvelteKit encounters an error while loading the page and detects that a new version has been deployed (using the `name` specified here, which defaults to a timestamp of the build) it will fall back to traditional full-page navigation.\n\t\t * Not all navigations will result in an error though, for example if the JavaScript for the next page is already loaded. If you still want to force a full-page navigation in these cases, use techniques such as setting the `pollInterval` and then using `beforeNavigate`:\n\t\t * ```html\n\t\t * /// file: +layout.svelte\n\t\t * <script>\n\t\t *   import { beforeNavigate } from '$app/navigation';\n\t\t *   import { updated } from '$app/state';\n\t\t *\n\t\t *   beforeNavigate(({ willUnload, to }) => {\n\t\t *     if (updated.current && !willUnload && to?.url) {\n\t\t *       location.href = to.url.href;\n\t\t *     }\n\t\t *   });\n\t\t * </script>\n\t\t * ```\n\t\t *\n\t\t * If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of [`updated.current`](https://svelte.dev/docs/kit/$app-state#updated) `true` when it detects one.\n\t\t */\n\t\tversion?: {\n\t\t\t/**\n\t\t\t * 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.\n\t\t\t *\n\t\t\t * For example, to use the current commit hash, you could do use `git rev-parse HEAD`:\n\t\t\t *\n\t\t\t * ```js\n\t\t\t * /// file: svelte.config.js\n\t\t\t * import * as child_process from 'node:child_process';\n\t\t\t *\n\t\t\t * export default {\n\t\t\t *   kit: {\n\t\t\t *     version: {\n\t\t\t *       name: child_process.execSync('git rev-parse HEAD').toString().trim()\n\t\t\t *     }\n\t\t\t *   }\n\t\t\t * };\n\t\t\t * ```\n\t\t\t */\n\t\t\tname?: string;\n\t\t\t/**\n\t\t\t * The interval in milliseconds to poll for version changes. If this is `0`, no polling occurs.\n\t\t\t * @default 0\n\t\t\t */\n\t\t\tpollInterval?: number;\n\t\t};\n\t}\n\n\t/**\n\t * The [`handle`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle) hook runs every time the SvelteKit server receives a [request](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Request) and\n\t * determines the [response](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Response).\n\t * It receives an `event` object representing the request and a function called `resolve`, which renders the route and generates a `Response`.\n\t * This allows you to modify response headers or bodies, or bypass SvelteKit entirely (for implementing routes programmatically, for example).\n\t */\n\texport type Handle = (input: {\n\t\tevent: RequestEvent;\n\t\tresolve: (event: RequestEvent, opts?: ResolveOptions) => MaybePromise<Response>;\n\t}) => MaybePromise<Response>;\n\n\t/**\n\t * The server-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while responding to a request.\n\t *\n\t * If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event.\n\t * Make sure that this function _never_ throws an error.\n\t */\n\texport type HandleServerError = (input: {\n\t\terror: unknown;\n\t\tevent: RequestEvent;\n\t\tstatus: number;\n\t\tmessage: string;\n\t}) => MaybePromise<void | App.Error>;\n\n\t/**\n\t * The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleValidationError) hook runs when the argument to a remote function fails validation.\n\t *\n\t * It will be called with the validation issues and the event, and must return an object shape that matches `App.Error`.\n\t */\n\texport type HandleValidationError<Issue extends StandardSchemaV1.Issue = StandardSchemaV1.Issue> =\n\t\t(input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<App.Error>;\n\n\t/**\n\t * The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while navigating.\n\t *\n\t * If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event.\n\t * Make sure that this function _never_ throws an error.\n\t */\n\texport type HandleClientError = (input: {\n\t\terror: unknown;\n\t\tevent: NavigationEvent;\n\t\tstatus: number;\n\t\tmessage: string;\n\t}) => MaybePromise<void | App.Error>;\n\n\t/**\n\t * The [`handleFetch`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleFetch) hook allows you to modify (or replace) the result of an [`event.fetch`](https://svelte.dev/docs/kit/load#Making-fetch-requests) call that runs on the server (or during prerendering) inside an endpoint, `load`, `action`, `handle`, `handleError` or `reroute`.\n\t */\n\texport type HandleFetch = (input: {\n\t\tevent: RequestEvent;\n\t\trequest: Request;\n\t\tfetch: typeof fetch;\n\t}) => MaybePromise<Response>;\n\n\t/**\n\t * The [`init`](https://svelte.dev/docs/kit/hooks#Shared-hooks-init) will be invoked before the server responds to its first request\n\t * @since 2.10.0\n\t */\n\texport type ServerInit = () => MaybePromise<void>;\n\n\t/**\n\t * The [`init`](https://svelte.dev/docs/kit/hooks#Shared-hooks-init) will be invoked once the app starts in the browser\n\t * @since 2.10.0\n\t */\n\texport type ClientInit = () => MaybePromise<void>;\n\n\t/**\n\t * The [`reroute`](https://svelte.dev/docs/kit/hooks#Universal-hooks-reroute) hook allows you to modify the URL before it is used to determine which route to render.\n\t * @since 2.3.0\n\t */\n\texport type Reroute = (event: { url: URL; fetch: typeof fetch }) => MaybePromise<void | string>;\n\n\t/**\n\t * The [`transport`](https://svelte.dev/docs/kit/hooks#Universal-hooks-transport) hook allows you to transport custom types across the server/client boundary.\n\t *\n\t * Each transporter has a pair of `encode` and `decode` functions. On the server, `encode` determines whether a value is an instance of the custom type and, if so, returns a non-falsy encoding of the value which can be an object or an array (or `false` otherwise).\n\t *\n\t * In the browser, `decode` turns the encoding back into an instance of the custom type.\n\t *\n\t * ```ts\n\t * import type { Transport } from '@sveltejs/kit';\n\t *\n\t * declare class MyCustomType {\n\t * \tdata: any\n\t * }\n\t *\n\t * // hooks.js\n\t * export const transport: Transport = {\n\t * \tMyCustomType: {\n\t * \t\tencode: (value) => value instanceof MyCustomType && [value.data],\n\t * \t\tdecode: ([data]) => new MyCustomType(data)\n\t * \t}\n\t * };\n\t * ```\n\t * @since 2.11.0\n\t */\n\texport type Transport = Record<string, Transporter>;\n\n\t/**\n\t * A member of the [`transport`](https://svelte.dev/docs/kit/hooks#Universal-hooks-transport) hook.\n\t */\n\texport interface Transporter<\n\t\tT = any,\n\t\tU = Exclude<any, false | 0 | '' | null | undefined | typeof NaN>\n\t> {\n\t\tencode: (value: T) => false | U;\n\t\tdecode: (data: U) => T;\n\t}\n\n\t/**\n\t * The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://svelte.dev/docs/kit/types#Generated-types))\n\t * rather than using `Load` directly.\n\t */\n\texport type Load<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tInputData extends Record<string, unknown> | null = Record<string, any> | null,\n\t\tParentData extends Record<string, unknown> = Record<string, any>,\n\t\tOutputData extends Record<string, unknown> | void = Record<string, any> | void,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> = (event: LoadEvent<Params, InputData, ParentData, RouteId>) => MaybePromise<OutputData>;\n\n\t/**\n\t * The generic form of `PageLoadEvent` and `LayoutLoadEvent`. You should import those from `./$types` (see [generated types](https://svelte.dev/docs/kit/types#Generated-types))\n\t * rather than using `LoadEvent` directly.\n\t */\n\texport interface LoadEvent<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tData extends Record<string, unknown> | null = Record<string, any> | null,\n\t\tParentData extends Record<string, unknown> = Record<string, any>,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> extends NavigationEvent<Params, RouteId> {\n\t\t/**\n\t\t * `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features:\n\t\t *\n\t\t * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.\n\t\t * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).\n\t\t * - 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.\n\t\t * - 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://svelte.dev/docs/kit/hooks#Server-hooks-handle)\n\t\t * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.\n\t\t *\n\t\t * You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies)\n\t\t */\n\t\tfetch: typeof fetch;\n\t\t/**\n\t\t * Contains the data returned by the route's server `load` function (in `+layout.server.js` or `+page.server.js`), if any.\n\t\t */\n\t\tdata: Data;\n\t\t/**\n\t\t * 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:\n\t\t *\n\t\t *\t```js\n\t\t *\t/// file: src/routes/blog/+page.js\n\t\t *\texport async function load({ fetch, setHeaders }) {\n\t\t *\t\tconst url = `https://cms.example.com/articles.json`;\n\t\t *\t\tconst response = await fetch(url);\n\t\t *\n\t\t *\t\tsetHeaders({\n\t\t *\t\t\tage: response.headers.get('age'),\n\t\t *\t\t\t'cache-control': response.headers.get('cache-control')\n\t\t *\t\t});\n\t\t *\n\t\t *\t\treturn response.json();\n\t\t *\t}\n\t\t *\t```\n\t\t *\n\t\t * Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.\n\t\t *\n\t\t * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API in a server-only `load` function instead.\n\t\t *\n\t\t * `setHeaders` has no effect when a `load` function runs in the browser.\n\t\t */\n\t\tsetHeaders: (headers: Record<string, string>) => void;\n\t\t/**\n\t\t * `await parent()` returns data from parent `+layout.js` `load` functions.\n\t\t * 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.\n\t\t *\n\t\t * 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.\n\t\t */\n\t\tparent: () => Promise<ParentData>;\n\t\t/**\n\t\t * 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()`](https://svelte.dev/docs/kit/$app-navigation#invalidate) to cause `load` to rerun.\n\t\t *\n\t\t * 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`.\n\t\t *\n\t\t * 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).\n\t\t *\n\t\t * 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).\n\t\t *\n\t\t * 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.\n\t\t *\n\t\t * ```js\n\t\t * /// file: src/routes/+page.js\n\t\t * let count = 0;\n\t\t * export async function load({ depends }) {\n\t\t * \tdepends('increase:count');\n\t\t *\n\t\t * \treturn { count: count++ };\n\t\t * }\n\t\t * ```\n\t\t *\n\t\t * ```html\n\t\t * /// file: src/routes/+page.svelte\n\t\t * <script>\n\t\t * \timport { invalidate } from '$app/navigation';\n\t\t *\n\t\t * \tlet { data } = $props();\n\t\t *\n\t\t * \tconst increase = async () => {\n\t\t * \t\tawait invalidate('increase:count');\n\t\t * \t}\n\t\t * </script>\n\t\t *\n\t\t * <p>{data.count}<p>\n\t\t * <button on:click={increase}>Increase Count</button>\n\t\t * ```\n\t\t */\n\t\tdepends: (...deps: Array<`${string}:${string}`>) => void;\n\t\t/**\n\t\t * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example:\n\t\t *\n\t\t * ```js\n\t\t * /// file: src/routes/+page.server.js\n\t\t * export async function load({ untrack, url }) {\n\t\t * \t// Untrack url.pathname so that path changes don't trigger a rerun\n\t\t * \tif (untrack(() => url.pathname === '/')) {\n\t\t * \t\treturn { message: 'Welcome!' };\n\t\t * \t}\n\t\t * }\n\t\t * ```\n\t\t */\n\t\tuntrack: <T>(fn: () => T) => T;\n\n\t\t/**\n\t\t * Access to spans for tracing. If tracing is not enabled or the function is being run in the browser, these spans will do nothing.\n\t\t * @since 2.31.0\n\t\t */\n\t\ttracing: {\n\t\t\t/** Whether tracing is enabled. */\n\t\t\tenabled: boolean;\n\t\t\t/** The root span for the request. This span is named `sveltekit.handle.root`. */\n\t\t\troot: Span;\n\t\t\t/** The span associated with the current `load` function. */\n\t\t\tcurrent: Span;\n\t\t};\n\t}\n\n\texport interface NavigationEvent<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> {\n\t\t/**\n\t\t * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object\n\t\t */\n\t\tparams: Params;\n\t\t/**\n\t\t * Info about the current route\n\t\t */\n\t\troute: {\n\t\t\t/**\n\t\t\t * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.\n\t\t\t */\n\t\t\tid: RouteId;\n\t\t};\n\t\t/**\n\t\t * The URL of the current page\n\t\t */\n\t\turl: URL;\n\t}\n\n\t/**\n\t * Information about the target of a specific navigation.\n\t */\n\texport interface NavigationTarget<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> {\n\t\t/**\n\t\t * Parameters of the target page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.\n\t\t * Is `null` if the target is not part of the SvelteKit app (could not be resolved to a route).\n\t\t */\n\t\tparams: Params | null;\n\t\t/**\n\t\t * Info about the target route\n\t\t */\n\t\troute: {\n\t\t\t/**\n\t\t\t * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.\n\t\t\t */\n\t\t\tid: RouteId | null;\n\t\t};\n\t\t/**\n\t\t * The URL that is navigated to\n\t\t */\n\t\turl: URL;\n\t\t/**\n\t\t * The scroll position associated with this navigation.\n\t\t *\n\t\t * For the `from` target, this is the scroll position at the moment of navigation.\n\t\t *\n\t\t * For the `to` target, this represents the scroll position that will be or was restored:\n\t\t * - In `beforeNavigate` and `onNavigate`, this is only available for `popstate` navigations (back/forward button)\n\t\t *   and will be `null` for other navigation types, since the final scroll position isn't known\n\t\t *   ahead of time.\n\t\t * - In `afterNavigate`, this is always the scroll position that was applied after the navigation\n\t\t *   completed.\n\t\t */\n\t\tscroll: { x: number; y: number } | null;\n\t}\n\n\t/**\n\t * - `enter`: The app has hydrated/started\n\t * - `form`: The user submitted a `<form method=\"GET\">`\n\t * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring\n\t * - `link`: Navigation was triggered by a link click\n\t * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect\n\t * - `popstate`: Navigation was triggered by back/forward navigation\n\t */\n\texport type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';\n\n\texport interface NavigationBase {\n\t\t/**\n\t\t * Where navigation was triggered from\n\t\t */\n\t\tfrom: NavigationTarget | null;\n\t\t/**\n\t\t * Where navigation is going to/has gone to\n\t\t */\n\t\tto: NavigationTarget | null;\n\t\t/**\n\t\t * Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation).\n\t\t */\n\t\twillUnload: boolean;\n\t\t/**\n\t\t * A promise that resolves once the navigation is complete, and rejects if the navigation\n\t\t * fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve\n\t\t */\n\t\tcomplete: Promise<void>;\n\t}\n\n\texport interface NavigationEnter extends NavigationBase {\n\t\t/**\n\t\t * The type of navigation:\n\t\t * - `enter`: The app has hydrated/started\n\t\t */\n\t\ttype: 'enter';\n\n\t\t/**\n\t\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t\t */\n\t\tdelta?: undefined;\n\n\t\t/**\n\t\t * Dispatched `Event` object when navigation occurred by `popstate` or `link`.\n\t\t */\n\t\tevent?: undefined;\n\t}\n\n\texport type NavigationExternal = NavigationGoto | NavigationLeave;\n\n\texport interface NavigationGoto extends NavigationBase {\n\t\t/**\n\t\t * The type of navigation:\n\t\t * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect\n\t\t */\n\t\ttype: 'goto';\n\n\t\t// TODO 3.0 remove this property, so that it only exists when type is 'popstate'\n\t\t// (would possibly be a breaking change to do it prior to that)\n\t\t/**\n\t\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t\t */\n\t\tdelta?: undefined;\n\t}\n\n\texport interface NavigationLeave extends NavigationBase {\n\t\t/**\n\t\t * The type of navigation:\n\t\t * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring\n\t\t */\n\t\ttype: 'leave';\n\n\t\t// TODO 3.0 remove this property, so that it only exists when type is 'popstate'\n\t\t// (would possibly be a breaking change to do it prior to that)\n\t\t/**\n\t\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t\t */\n\t\tdelta?: undefined;\n\t}\n\n\texport interface NavigationFormSubmit extends NavigationBase {\n\t\t/**\n\t\t * The type of navigation:\n\t\t * - `form`: The user submitted a `<form method=\"GET\">`\n\t\t */\n\t\ttype: 'form';\n\n\t\t/**\n\t\t * The `SubmitEvent` that caused the navigation\n\t\t */\n\t\tevent: SubmitEvent;\n\n\t\t// TODO 3.0 remove this property, so that it only exists when type is 'popstate'\n\t\t// (would possibly be a breaking change to do it prior to that)\n\t\t/**\n\t\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t\t */\n\t\tdelta?: undefined;\n\t}\n\n\texport interface NavigationPopState extends NavigationBase {\n\t\t/**\n\t\t * The type of navigation:\n\t\t * - `popstate`: Navigation was triggered by back/forward navigation\n\t\t */\n\t\ttype: 'popstate';\n\n\t\t/**\n\t\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t\t */\n\t\tdelta: number;\n\n\t\t/**\n\t\t * The `PopStateEvent` that caused the navigation\n\t\t */\n\t\tevent: PopStateEvent;\n\t}\n\n\texport interface NavigationLink extends NavigationBase {\n\t\t/**\n\t\t * The type of navigation:\n\t\t * - `link`: Navigation was triggered by a link click\n\t\t */\n\t\ttype: 'link';\n\n\t\t/**\n\t\t * The `PointerEvent` that caused the navigation\n\t\t */\n\t\tevent: PointerEvent;\n\n\t\t// TODO 3.0 remove this property, so that it only exists when type is 'popstate'\n\t\t// (would possibly be a breaking change to do it prior to that)\n\t\t/**\n\t\t * In case of a history back/forward navigation, the number of steps to go back/forward\n\t\t */\n\t\tdelta?: undefined;\n\t}\n\n\texport type Navigation =\n\t\t| NavigationExternal\n\t\t| NavigationFormSubmit\n\t\t| NavigationPopState\n\t\t| NavigationLink;\n\n\t/**\n\t * The argument passed to [`beforeNavigate`](https://svelte.dev/docs/kit/$app-navigation#beforeNavigate) callbacks.\n\t */\n\texport type BeforeNavigate = Navigation & {\n\t\t/**\n\t\t * Call this to prevent the navigation from starting.\n\t\t */\n\t\tcancel: () => void;\n\t};\n\n\t/**\n\t * The argument passed to [`onNavigate`](https://svelte.dev/docs/kit/$app-navigation#onNavigate) callbacks.\n\t */\n\texport type OnNavigate = Navigation & {\n\t\ttype: Exclude<NavigationType, 'enter' | 'leave'>;\n\t\t/**\n\t\t * Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page.\n\t\t */\n\t\twillUnload: false;\n\t};\n\n\t/**\n\t * The argument passed to [`afterNavigate`](https://svelte.dev/docs/kit/$app-navigation#afterNavigate) callbacks.\n\t */\n\texport type AfterNavigate = (Navigation | NavigationEnter) & {\n\t\ttype: Exclude<NavigationType, 'leave'>;\n\t\t/**\n\t\t * Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page.\n\t\t */\n\t\twillUnload: false;\n\t};\n\n\t/**\n\t * The shape of the [`page`](https://svelte.dev/docs/kit/$app-state#page) reactive object and the [`$page`](https://svelte.dev/docs/kit/$app-stores) store.\n\t */\n\texport interface Page<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> {\n\t\t/**\n\t\t * The URL of the current page.\n\t\t */\n\t\turl: URL & { pathname: ResolvedPathname };\n\t\t/**\n\t\t * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.\n\t\t */\n\t\tparams: Params;\n\t\t/**\n\t\t * Info about the current route.\n\t\t */\n\t\troute: {\n\t\t\t/**\n\t\t\t * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.\n\t\t\t */\n\t\t\tid: RouteId;\n\t\t};\n\t\t/**\n\t\t * HTTP status code of the current page.\n\t\t */\n\t\tstatus: number;\n\t\t/**\n\t\t * The error object of the current page, if any. Filled from the `handleError` hooks.\n\t\t */\n\t\terror: App.Error | null;\n\t\t/**\n\t\t * The merged result of all data from all `load` functions on the current page. You can type a common denominator through `App.PageData`.\n\t\t */\n\t\tdata: App.PageData & Record<string, any>;\n\t\t/**\n\t\t * The page state, which can be manipulated using the [`pushState`](https://svelte.dev/docs/kit/$app-navigation#pushState) and [`replaceState`](https://svelte.dev/docs/kit/$app-navigation#replaceState) functions from `$app/navigation`.\n\t\t */\n\t\tstate: App.PageState;\n\t\t/**\n\t\t * Filled only after a form submission. See [form actions](https://svelte.dev/docs/kit/form-actions) for more info.\n\t\t */\n\t\tform: any;\n\t}\n\n\t/**\n\t * The shape of a param matcher. See [matching](https://svelte.dev/docs/kit/advanced-routing#Matching) for more info.\n\t */\n\texport type ParamMatcher = (param: string) => boolean;\n\n\texport interface RequestEvent<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> {\n\t\t/**\n\t\t * Get or set cookies related to the current request\n\t\t */\n\t\tcookies: Cookies;\n\t\t/**\n\t\t * `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features:\n\t\t *\n\t\t * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.\n\t\t * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).\n\t\t * - 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.\n\t\t * - 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://svelte.dev/docs/kit/hooks#Server-hooks-handle)\n\t\t * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.\n\t\t *\n\t\t * You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).\n\t\t */\n\t\tfetch: typeof fetch;\n\t\t/**\n\t\t * The client's IP address, set by the adapter.\n\t\t */\n\t\tgetClientAddress: () => string;\n\t\t/**\n\t\t * Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle).\n\t\t */\n\t\tlocals: App.Locals;\n\t\t/**\n\t\t * The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.\n\t\t */\n\t\tparams: Params;\n\t\t/**\n\t\t * Additional data made available through the adapter.\n\t\t */\n\t\tplatform: Readonly<App.Platform> | undefined;\n\t\t/**\n\t\t * The original request object.\n\t\t */\n\t\trequest: Request;\n\t\t/**\n\t\t * Info about the current route.\n\t\t */\n\t\troute: {\n\t\t\t/**\n\t\t\t * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.\n\t\t\t */\n\t\t\tid: RouteId;\n\t\t};\n\t\t/**\n\t\t * 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:\n\t\t *\n\t\t *\t```js\n\t\t *\t/// file: src/routes/blog/+page.js\n\t\t *\texport async function load({ fetch, setHeaders }) {\n\t\t *\t\tconst url = `https://cms.example.com/articles.json`;\n\t\t *\t\tconst response = await fetch(url);\n\t\t *\n\t\t *\t\tsetHeaders({\n\t\t *\t\t\tage: response.headers.get('age'),\n\t\t *\t\t\t'cache-control': response.headers.get('cache-control')\n\t\t *\t\t});\n\t\t *\n\t\t *\t\treturn response.json();\n\t\t *\t}\n\t\t *\t```\n\t\t *\n\t\t * Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.\n\t\t *\n\t\t * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API instead.\n\t\t */\n\t\tsetHeaders: (headers: Record<string, string>) => void;\n\t\t/**\n\t\t * The requested URL.\n\t\t */\n\t\turl: URL;\n\t\t/**\n\t\t * `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\n\t\t * related to the data request in this case. Use this property instead if the distinction is important to you.\n\t\t */\n\t\tisDataRequest: boolean;\n\t\t/**\n\t\t * `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.\n\t\t */\n\t\tisSubRequest: boolean;\n\n\t\t/**\n\t\t * Access to spans for tracing. If tracing is not enabled, these spans will do nothing.\n\t\t * @since 2.31.0\n\t\t */\n\t\ttracing: {\n\t\t\t/** Whether tracing is enabled. */\n\t\t\tenabled: boolean;\n\t\t\t/** The root span for the request. This span is named `sveltekit.handle.root`. */\n\t\t\troot: Span;\n\t\t\t/** The span associated with the current `handle` hook, `load` function, or form action. */\n\t\t\tcurrent: Span;\n\t\t};\n\n\t\t/**\n\t\t * `true` if the request comes from the client via a remote function. The `url` property will be stripped of the internal information\n\t\t * related to the data request in this case. Use this property instead if the distinction is important to you.\n\t\t */\n\t\tisRemoteRequest: boolean;\n\t}\n\n\t/**\n\t * 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.\n\t *\n\t * It receives `Params` as the first generic argument, which you can skip by using [generated types](https://svelte.dev/docs/kit/types#Generated-types) instead.\n\t */\n\texport type RequestHandler<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> = (event: RequestEvent<Params, RouteId>) => MaybePromise<Response>;\n\n\texport interface ResolveOptions {\n\t\t/**\n\t\t * Applies custom transforms to HTML. If `done` is true, it's the final chunk. Chunks are not guaranteed to be well-formed HTML\n\t\t * (they could include an element's opening tag but not its closing tag, for example)\n\t\t * but they will always be split at sensible boundaries such as `%sveltekit.head%` or layout/page components.\n\t\t * @param input the html chunk and the info if this is the last chunk\n\t\t */\n\t\ttransformPageChunk?: (input: { html: string; done: boolean }) => MaybePromise<string | undefined>;\n\t\t/**\n\t\t * Determines which headers should be included in serialized responses when a `load` function loads a resource with `fetch`.\n\t\t * By default, none will be included.\n\t\t * @param name header name\n\t\t * @param value header value\n\t\t */\n\t\tfilterSerializedResponseHeaders?: (name: string, value: string) => boolean;\n\t\t/**\n\t\t * Determines what should be added to the `<head>` tag to preload it.\n\t\t * By default, `js` and `css` files will be preloaded.\n\t\t * @param input the type of the file and its path\n\t\t */\n\t\tpreload?: (input: { type: 'font' | 'css' | 'js' | 'asset'; path: string }) => boolean;\n\t}\n\n\texport interface RouteDefinition<Config = any> {\n\t\tid: string;\n\t\tapi: {\n\t\t\tmethods: Array<HttpMethod | '*'>;\n\t\t};\n\t\tpage: {\n\t\t\tmethods: Array<Extract<HttpMethod, 'GET' | 'POST'>>;\n\t\t};\n\t\tpattern: RegExp;\n\t\tprerender: PrerenderOption;\n\t\tsegments: RouteSegment[];\n\t\tmethods: Array<HttpMethod | '*'>;\n\t\tconfig: Config;\n\t}\n\n\texport class Server {\n\t\tconstructor(manifest: SSRManifest);\n\t\tinit(options: ServerInitOptions): Promise<void>;\n\t\trespond(request: Request, options: RequestOptions): Promise<Response>;\n\t}\n\n\texport interface ServerInitOptions {\n\t\t/** A map of environment variables. */\n\t\tenv: Record<string, string>;\n\t\t/** A function that turns an asset filename into a `ReadableStream`. Required for the `read` export from `$app/server` to work. */\n\t\tread?: (file: string) => MaybePromise<ReadableStream | null>;\n\t}\n\n\texport interface SSRManifest {\n\t\tappDir: string;\n\t\tappPath: string;\n\t\t/** Static files from `kit.config.files.assets` and the service worker (if any). */\n\t\tassets: Set<string>;\n\t\tmimeTypes: Record<string, string>;\n\n\t\t/** private fields */\n\t\t_: {\n\t\t\tclient: NonNullable<BuildData['client']>;\n\t\t\tnodes: SSRNodeLoader[];\n\t\t\t/** hashed filename -> import to that file */\n\t\t\tremotes: Record<string, () => Promise<any>>;\n\t\t\troutes: SSRRoute[];\n\t\t\tprerendered_routes: Set<string>;\n\t\t\tmatchers: () => Promise<Record<string, ParamMatcher>>;\n\t\t\t/** A `[file]: size` map of all assets imported by server code. */\n\t\t\tserver_assets: Record<string, number>;\n\t\t};\n\t}\n\n\t/**\n\t * The generic form of `PageServerLoad` and `LayoutServerLoad`. You should import those from `./$types` (see [generated types](https://svelte.dev/docs/kit/types#Generated-types))\n\t * rather than using `ServerLoad` directly.\n\t */\n\texport type ServerLoad<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tParentData extends Record<string, any> = Record<string, any>,\n\t\tOutputData extends Record<string, any> | void = Record<string, any> | void,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> = (event: ServerLoadEvent<Params, ParentData, RouteId>) => MaybePromise<OutputData>;\n\n\texport interface ServerLoadEvent<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tParentData extends Record<string, any> = Record<string, any>,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> extends RequestEvent<Params, RouteId> {\n\t\t/**\n\t\t * `await parent()` returns data from parent `+layout.server.js` `load` functions.\n\t\t *\n\t\t * 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.\n\t\t */\n\t\tparent: () => Promise<ParentData>;\n\t\t/**\n\t\t * 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()`](https://svelte.dev/docs/kit/$app-navigation#invalidate) to cause `load` to rerun.\n\t\t *\n\t\t * 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`.\n\t\t *\n\t\t * 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).\n\t\t *\n\t\t * 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).\n\t\t *\n\t\t * 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.\n\t\t *\n\t\t * ```js\n\t\t * /// file: src/routes/+page.js\n\t\t * let count = 0;\n\t\t * export async function load({ depends }) {\n\t\t * \tdepends('increase:count');\n\t\t *\n\t\t * \treturn { count: count++ };\n\t\t * }\n\t\t * ```\n\t\t *\n\t\t * ```html\n\t\t * /// file: src/routes/+page.svelte\n\t\t * <script>\n\t\t * \timport { invalidate } from '$app/navigation';\n\t\t *\n\t\t * \tlet { data } = $props();\n\t\t *\n\t\t * \tconst increase = async () => {\n\t\t * \t\tawait invalidate('increase:count');\n\t\t * \t}\n\t\t * </script>\n\t\t *\n\t\t * <p>{data.count}<p>\n\t\t * <button on:click={increase}>Increase Count</button>\n\t\t * ```\n\t\t */\n\t\tdepends: (...deps: string[]) => void;\n\t\t/**\n\t\t * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example:\n\t\t *\n\t\t * ```js\n\t\t * /// file: src/routes/+page.js\n\t\t * export async function load({ untrack, url }) {\n\t\t * \t// Untrack url.pathname so that path changes don't trigger a rerun\n\t\t * \tif (untrack(() => url.pathname === '/')) {\n\t\t * \t\treturn { message: 'Welcome!' };\n\t\t * \t}\n\t\t * }\n\t\t * ```\n\t\t */\n\t\tuntrack: <T>(fn: () => T) => T;\n\n\t\t/**\n\t\t * Access to spans for tracing. If tracing is not enabled, these spans will do nothing.\n\t\t * @since 2.31.0\n\t\t */\n\t\ttracing: {\n\t\t\t/** Whether tracing is enabled. */\n\t\t\tenabled: boolean;\n\t\t\t/** The root span for the request. This span is named `sveltekit.handle.root`. */\n\t\t\troot: Span;\n\t\t\t/** The span associated with the current server `load` function. */\n\t\t\tcurrent: Span;\n\t\t};\n\t}\n\n\t/**\n\t * Shape of a form action method that is part of `export const actions = {...}` in `+page.server.js`.\n\t * See [form actions](https://svelte.dev/docs/kit/form-actions) for more information.\n\t */\n\texport type Action<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tOutputData extends Record<string, any> | void = Record<string, any> | void,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> = (event: RequestEvent<Params, RouteId>) => MaybePromise<OutputData>;\n\n\t/**\n\t * Shape of the `export const actions = {...}` object in `+page.server.js`.\n\t * See [form actions](https://svelte.dev/docs/kit/form-actions) for more information.\n\t */\n\texport type Actions<\n\t\tParams extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,\n\t\tOutputData extends Record<string, any> | void = Record<string, any> | void,\n\t\tRouteId extends AppRouteId | null = AppRouteId | null\n\t> = Record<string, Action<Params, OutputData, RouteId>>;\n\n\t/**\n\t * When calling a form action via fetch, the response will be one of these shapes.\n\t * ```svelte\n\t * <form method=\"post\" use:enhance={() => {\n\t *   return ({ result }) => {\n\t * \t\t// result is of type ActionResult\n\t *   };\n\t * }}\n\t * ```\n\t */\n\texport type ActionResult<\n\t\tSuccess extends Record<string, unknown> | undefined = Record<string, any>,\n\t\tFailure extends Record<string, unknown> | undefined = Record<string, any>\n\t> =\n\t\t| { type: 'success'; status: number; data?: Success }\n\t\t| { type: 'failure'; status: number; data?: Failure }\n\t\t| { type: 'redirect'; status: number; location: string }\n\t\t| { type: 'error'; status?: number; error: any };\n\n\t/**\n\t * The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.\n\t */\n\texport interface HttpError {\n\t\t/** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses), in the range 400-599. */\n\t\tstatus: number;\n\t\t/** The content of the error. */\n\t\tbody: App.Error;\n\t}\n\n\t/**\n\t * The object returned by the [`redirect`](https://svelte.dev/docs/kit/@sveltejs-kit#redirect) function.\n\t */\n\texport interface Redirect {\n\t\t/** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages), in the range 300-308. */\n\t\tstatus: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308;\n\t\t/** The location to redirect to. */\n\t\tlocation: string;\n\t}\n\n\texport type SubmitFunction<\n\t\tSuccess extends Record<string, unknown> | undefined = Record<string, any>,\n\t\tFailure extends Record<string, unknown> | undefined = Record<string, any>\n\t> = (input: {\n\t\taction: URL;\n\t\tformData: FormData;\n\t\tformElement: HTMLFormElement;\n\t\tcontroller: AbortController;\n\t\tsubmitter: HTMLElement | null;\n\t\tcancel: () => void;\n\t}) => MaybePromise<\n\t\t| void\n\t\t| ((opts: {\n\t\t\t\tformData: FormData;\n\t\t\t\tformElement: HTMLFormElement;\n\t\t\t\taction: URL;\n\t\t\t\tresult: ActionResult<Success, Failure>;\n\t\t\t\t/**\n\t\t\t\t * Call this to get the default behavior of a form submission response.\n\t\t\t\t * @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission.\n\t\t\t\t * @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission.\n\t\t\t\t */\n\t\t\t\tupdate: (options?: { reset?: boolean; invalidateAll?: boolean }) => Promise<void>;\n\t\t  }) => MaybePromise<void>)\n\t>;\n\n\t/**\n\t * The type of `export const snapshot` exported from a page or layout component.\n\t */\n\texport interface Snapshot<T = any> {\n\t\tcapture: () => T;\n\t\trestore: (snapshot: T) => void;\n\t}\n\n\t// If T is unknown or has an index signature, the types below will recurse indefinitely and create giant unions that TS can't handle\n\ttype WillRecurseIndefinitely<T> = unknown extends T ? true : string extends keyof T ? true : false;\n\n\t// Input type mappings for form fields\n\ttype InputTypeMap = {\n\t\ttext: string;\n\t\temail: string;\n\t\tpassword: string;\n\t\turl: string;\n\t\ttel: string;\n\t\tsearch: string;\n\t\tnumber: number;\n\t\trange: number;\n\t\tdate: string;\n\t\t'datetime-local': string;\n\t\ttime: string;\n\t\tmonth: string;\n\t\tweek: string;\n\t\tcolor: string;\n\t\tcheckbox: boolean | string[];\n\t\tradio: string;\n\t\tfile: File;\n\t\thidden: string;\n\t\tsubmit: string;\n\t\tbutton: string;\n\t\treset: string;\n\t\timage: string;\n\t\tselect: string;\n\t\t'select multiple': string[];\n\t\t'file multiple': File[];\n\t};\n\n\t// Valid input types for a given value type\n\texport type RemoteFormFieldType<T> = {\n\t\t[K in keyof InputTypeMap]: T extends InputTypeMap[K] ? K : never;\n\t}[keyof InputTypeMap];\n\n\t// Input element properties based on type\n\ttype InputElementProps<T extends keyof InputTypeMap> = T extends 'checkbox' | 'radio'\n\t\t? {\n\t\t\t\tname: string;\n\t\t\t\ttype: T;\n\t\t\t\tvalue?: string;\n\t\t\t\t'aria-invalid': boolean | 'false' | 'true' | undefined;\n\t\t\t\tget checked(): boolean;\n\t\t\t\tset checked(value: boolean);\n\t\t\t}\n\t\t: T extends 'file'\n\t\t\t? {\n\t\t\t\t\tname: string;\n\t\t\t\t\ttype: 'file';\n\t\t\t\t\t'aria-invalid': boolean | 'false' | 'true' | undefined;\n\t\t\t\t\tget files(): FileList | null;\n\t\t\t\t\tset files(v: FileList | null);\n\t\t\t\t}\n\t\t\t: T extends 'select' | 'select multiple'\n\t\t\t\t? {\n\t\t\t\t\t\tname: string;\n\t\t\t\t\t\tmultiple: T extends 'select' ? false : true;\n\t\t\t\t\t\t'aria-invalid': boolean | 'false' | 'true' | undefined;\n\t\t\t\t\t\tget value(): string | number;\n\t\t\t\t\t\tset value(v: string | number);\n\t\t\t\t\t}\n\t\t\t\t: T extends 'text'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tname: string;\n\t\t\t\t\t\t\t'aria-invalid': boolean | 'false' | 'true' | undefined;\n\t\t\t\t\t\t\tget value(): string | number;\n\t\t\t\t\t\t\tset value(v: string | number);\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tname: string;\n\t\t\t\t\t\t\ttype: T;\n\t\t\t\t\t\t\t'aria-invalid': boolean | 'false' | 'true' | undefined;\n\t\t\t\t\t\t\tget value(): string | number;\n\t\t\t\t\t\t\tset value(v: string | number);\n\t\t\t\t\t\t};\n\n\ttype RemoteFormFieldMethods<T> = {\n\t\t/** The values that will be submitted */\n\t\tvalue(): DeepPartial<T>;\n\t\t/** Set the values that will be submitted */\n\t\tset(input: DeepPartial<T>): DeepPartial<T>;\n\t\t/** Validation issues, if any */\n\t\tissues(): RemoteFormIssue[] | undefined;\n\t};\n\n\texport type RemoteFormFieldValue = string | string[] | number | boolean | File | File[];\n\n\ttype AsArgs<Type extends keyof InputTypeMap, Value> = Type extends 'checkbox'\n\t\t? Value extends string[]\n\t\t\t? [type: Type, value: Value[number] | (string & {})]\n\t\t\t: [type: Type]\n\t\t: Type extends 'radio' | 'submit' | 'hidden'\n\t\t\t? [type: Type, value: Value | (string & {})]\n\t\t\t: [type: Type];\n\n\t/**\n\t * Form field accessor type that provides name(), value(), and issues() methods\n\t */\n\texport type RemoteFormField<Value extends RemoteFormFieldValue> = RemoteFormFieldMethods<Value> & {\n\t\t/**\n\t\t * Returns an object that can be spread onto an input element with the correct type attribute,\n\t\t * aria-invalid attribute if the field is invalid, and appropriate value/checked property getters/setters.\n\t\t * @example\n\t\t * ```svelte\n\t\t * <input {...myForm.fields.myString.as('text')} />\n\t\t * <input {...myForm.fields.myNumber.as('number')} />\n\t\t * <input {...myForm.fields.myBoolean.as('checkbox')} />\n\t\t * ```\n\t\t */\n\t\tas<T extends RemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;\n\t};\n\n\ttype RemoteFormFieldContainer<Value> = RemoteFormFieldMethods<Value> & {\n\t\t/** Validation issues belonging to this or any of the fields that belong to it, if any */\n\t\tallIssues(): RemoteFormIssue[] | undefined;\n\t};\n\n\ttype UnknownField<Value> = RemoteFormFieldMethods<Value> & {\n\t\t/** Validation issues belonging to this or any of the fields that belong to it, if any */\n\t\tallIssues(): RemoteFormIssue[] | undefined;\n\t\t/**\n\t\t * Returns an object that can be spread onto an input element with the correct type attribute,\n\t\t * aria-invalid attribute if the field is invalid, and appropriate value/checked property getters/setters.\n\t\t * @example\n\t\t * ```svelte\n\t\t * <input {...myForm.fields.myString.as('text')} />\n\t\t * <input {...myForm.fields.myNumber.as('number')} />\n\t\t * <input {...myForm.fields.myBoolean.as('checkbox')} />\n\t\t * ```\n\t\t */\n\t\tas<T extends RemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;\n\t} & {\n\t\t[key: string | number]: UnknownField<any>;\n\t};\n\n\ttype RemoteFormFieldsRoot<Input extends RemoteFormInput | void> =\n\t\tIsAny<Input> extends true\n\t\t\t? RecursiveFormFields\n\t\t\t: Input extends void\n\t\t\t\t? {\n\t\t\t\t\t\t/** Validation issues, if any */\n\t\t\t\t\t\tissues(): RemoteFormIssue[] | undefined;\n\t\t\t\t\t\t/** Validation issues belonging to this or any of the fields that belong to it, if any */\n\t\t\t\t\t\tallIssues(): RemoteFormIssue[] | undefined;\n\t\t\t\t\t}\n\t\t\t\t: RemoteFormFields<Input>;\n\n\t/**\n\t * Recursive type to build form fields structure with proxy access\n\t */\n\texport type RemoteFormFields<T> =\n\t\tWillRecurseIndefinitely<T> extends true\n\t\t\t? RecursiveFormFields\n\t\t\t: NonNullable<T> extends string | number | boolean | File\n\t\t\t\t? RemoteFormField<NonNullable<T>>\n\t\t\t\t: T extends string[] | File[]\n\t\t\t\t\t? RemoteFormField<T> & { [K in number]: RemoteFormField<T[number]> }\n\t\t\t\t\t: T extends Array<infer U>\n\t\t\t\t\t\t? RemoteFormFieldContainer<T> & {\n\t\t\t\t\t\t\t\t[K in number]: RemoteFormFields<U>;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: RemoteFormFieldContainer<T> & {\n\t\t\t\t\t\t\t\t[K in keyof T]-?: RemoteFormFields<T[K]>;\n\t\t\t\t\t\t\t};\n\n\t// By breaking this out into its own type, we avoid the TS recursion depth limit\n\ttype RecursiveFormFields = RemoteFormFieldContainer<any> & {\n\t\t[key: string | number]: UnknownField<any>;\n\t};\n\n\ttype MaybeArray<T> = T | T[];\n\n\texport interface RemoteFormInput {\n\t\t[key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput>;\n\t}\n\n\texport interface RemoteFormIssue {\n\t\tmessage: string;\n\t\tpath: Array<string | number>;\n\t}\n\n\t// If the schema specifies `id` as a string or number, ensure that `for(...)`\n\t// only accepts that type. Otherwise, accept `string | number`\n\ttype ExtractId<Input> = Input extends { id: infer Id }\n\t\t? Id extends string | number\n\t\t\t? Id\n\t\t\t: string | number\n\t\t: string | number;\n\n\t/**\n\t * A function and proxy object used to imperatively create validation errors in form handlers.\n\t *\n\t * Access properties to create field-specific issues: `issue.fieldName('message')`.\n\t * The type structure mirrors the input data structure for type-safe field access.\n\t * Call `invalid(issue.foo(...), issue.nested.bar(...))` to throw a validation error.\n\t */\n\texport type InvalidField<T> =\n\t\tWillRecurseIndefinitely<T> extends true\n\t\t\t? Record<string | number, any>\n\t\t\t: NonNullable<T> extends string | number | boolean | File\n\t\t\t\t? (message: string) => StandardSchemaV1.Issue\n\t\t\t\t: NonNullable<T> extends Array<infer U>\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t[K in number]: InvalidField<U>;\n\t\t\t\t\t\t} & ((message: string) => StandardSchemaV1.Issue)\n\t\t\t\t\t: NonNullable<T> extends RemoteFormInput\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t[K in keyof T]-?: InvalidField<T[K]>;\n\t\t\t\t\t\t\t} & ((message: string) => StandardSchemaV1.Issue)\n\t\t\t\t\t\t: Record<string, never>;\n\n\t/**\n\t * A validation error thrown by `invalid`.\n\t */\n\texport interface ValidationError {\n\t\t/** The validation issues */\n\t\tissues: StandardSchemaV1.Issue[];\n\t}\n\n\t/**\n\t * The return value of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.\n\t */\n\texport type RemoteForm<Input extends RemoteFormInput | void, Output> = {\n\t\t/** Attachment that sets up an event handler that intercepts the form submission on the client to prevent a full page reload */\n\t\t[attachment: symbol]: (node: HTMLFormElement) => void;\n\t\tmethod: 'POST';\n\t\t/** The URL to send the form to. */\n\t\taction: string;\n\t\t/** Use the `enhance` method to influence what happens when the form is submitted. */\n\t\tenhance(\n\t\t\tcallback: (opts: {\n\t\t\t\tform: HTMLFormElement;\n\t\t\t\tdata: Input;\n\t\t\t\tsubmit: () => Promise<void> & {\n\t\t\t\t\tupdates: (...queries: Array<RemoteQuery<any> | RemoteQueryOverride>) => Promise<void>;\n\t\t\t\t};\n\t\t\t}) => void | Promise<void>\n\t\t): {\n\t\t\tmethod: 'POST';\n\t\t\taction: string;\n\t\t\t[attachment: symbol]: (node: HTMLFormElement) => void;\n\t\t};\n\t\t/**\n\t\t * Create an instance of the form for the given `id`.\n\t\t * The `id` is stringified and used for deduplication to potentially reuse existing instances.\n\t\t * Useful when you have multiple forms that use the same remote form action, for example in a loop.\n\t\t * ```svelte\n\t\t * {#each todos as todo}\n\t\t *\t{@const todoForm = updateTodo.for(todo.id)}\n\t\t *\t<form {...todoForm}>\n\t\t *\t\t{#if todoForm.result?.invalid}<p>Invalid data</p>{/if}\n\t\t *\t\t...\n\t\t *\t</form>\n\t\t *\t{/each}\n\t\t * ```\n\t\t */\n\t\tfor(id: ExtractId<Input>): Omit<RemoteForm<Input, Output>, 'for'>;\n\t\t/** Preflight checks */\n\t\tpreflight(schema: StandardSchemaV1<Input, any>): RemoteForm<Input, Output>;\n\t\t/** Validate the form contents programmatically */\n\t\tvalidate(options?: {\n\t\t\t/** Set this to `true` to also show validation issues of fields that haven't been touched yet. */\n\t\t\tincludeUntouched?: boolean;\n\t\t\t/** Set this to `true` to only run the `preflight` validation. */\n\t\t\tpreflightOnly?: boolean;\n\t\t}): Promise<void>;\n\t\t/** The result of the form submission */\n\t\tget result(): Output | undefined;\n\t\t/** The number of pending submissions */\n\t\tget pending(): number;\n\t\t/** Access form fields using object notation */\n\t\tfields: RemoteFormFieldsRoot<Input>;\n\t};\n\n\t/**\n\t * The return value of a remote `command` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.\n\t */\n\texport type RemoteCommand<Input, Output> = {\n\t\t(arg: undefined extends Input ? Input | void : Input): Promise<Output> & {\n\t\t\tupdates(...queries: Array<RemoteQuery<any> | RemoteQueryOverride>): Promise<Output>;\n\t\t};\n\t\t/** The number of pending command executions */\n\t\tget pending(): number;\n\t};\n\n\texport type RemoteResource<T> = Promise<T> & {\n\t\t/** The error in case the query fails. Most often this is a [`HttpError`](https://svelte.dev/docs/kit/@sveltejs-kit#HttpError) but it isn't guaranteed to be. */\n\t\tget error(): any;\n\t\t/** `true` before the first result is available and during refreshes */\n\t\tget loading(): boolean;\n\t} & (\n\t\t\t| {\n\t\t\t\t\t/** The current value of the query. Undefined until `ready` is `true` */\n\t\t\t\t\tget current(): undefined;\n\t\t\t\t\tready: false;\n\t\t\t  }\n\t\t\t| {\n\t\t\t\t\t/** The current value of the query. Undefined until `ready` is `true` */\n\t\t\t\t\tget current(): T;\n\t\t\t\t\tready: true;\n\t\t\t  }\n\t\t);\n\n\texport type RemoteQuery<T> = RemoteResource<T> & {\n\t\t/**\n\t\t * Returns a plain promise with the result.\n\t\t * Unlike awaiting the resource directly, this can only be used _outside_ render\n\t\t * (i.e. in load functions, event handlers and so on)\n\t\t */\n\t\trun(): Promise<T>;\n\t\t/**\n\t\t * On the client, this function will update the value of the query without re-fetching it.\n\t\t *\n\t\t * On the server, this can be called in the context of a `command` or `form` and the specified data will accompany the action response back to the client.\n\t\t * This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.\n\t\t */\n\t\tset(value: T): void;\n\t\t/**\n\t\t * On the client, this function will re-fetch the query from the server.\n\t\t *\n\t\t * On the server, this can be called in the context of a `command` or `form` and the refreshed data will accompany the action response back to the client.\n\t\t * This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.\n\t\t */\n\t\trefresh(): Promise<void>;\n\t\t/**\n\t\t * Temporarily override the value of a query. This is used with the `updates` method of a [command](https://svelte.dev/docs/kit/remote-functions#command-Updating-queries) or [enhanced form submission](https://svelte.dev/docs/kit/remote-functions#form-enhance) to provide optimistic updates.\n\t\t *\n\t\t * ```svelte\n\t\t * <script>\n\t\t *   import { getTodos, addTodo } from './todos.remote.js';\n\t\t *   const todos = getTodos();\n\t\t * </script>\n\t\t *\n\t\t * <form {...addTodo.enhance(async ({ data, submit }) => {\n\t\t *   await submit().updates(\n\t\t *     todos.withOverride((todos) => [...todos, { text: data.get('text') }])\n\t\t *   );\n\t\t * })}>\n\t\t *   <input type=\"text\" name=\"text\" />\n\t\t *   <button type=\"submit\">Add Todo</button>\n\t\t * </form>\n\t\t * ```\n\t\t */\n\t\twithOverride(update: (current: T) => T): RemoteQueryOverride;\n\t};\n\n\texport interface RemoteQueryOverride {\n\t\t_key: string;\n\t\trelease(): void;\n\t}\n\n\t/**\n\t * The return value of a remote `prerender` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.\n\t */\n\texport type RemotePrerenderFunction<Input, Output> = (\n\t\targ: undefined extends Input ? Input | void : Input\n\t) => RemoteResource<Output>;\n\n\t/**\n\t * The return value of a remote `query` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.\n\t */\n\texport type RemoteQueryFunction<Input, Output> = (\n\t\targ: undefined extends Input ? Input | void : Input\n\t) => RemoteQuery<Output>;\n\tinterface AdapterEntry {\n\t\t/**\n\t\t * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.\n\t\t * For example, `/foo/a-[b]` and `/foo/[c]` are different routes, but would both\n\t\t * be represented in a Netlify _redirects file as `/foo/:param`, so they share an ID\n\t\t */\n\t\tid: string;\n\n\t\t/**\n\t\t * A function that compares the candidate route with the current route to determine\n\t\t * if it should be grouped with the current route.\n\t\t *\n\t\t * Use cases:\n\t\t * - Fallback pages: `/foo/[c]` is a fallback for `/foo/a-[b]`, and `/[...catchall]` is a fallback for all routes\n\t\t * - Grouping routes that share a common `config`: `/foo` should be deployed to the edge, `/bar` and `/baz` should be deployed to a serverless function\n\t\t */\n\t\tfilter(route: RouteDefinition): boolean;\n\n\t\t/**\n\t\t * A function that is invoked once the entry has been created. This is where you\n\t\t * should write the function to the filesystem and generate redirect manifests.\n\t\t */\n\t\tcomplete(entry: { generateManifest(opts: { relativePath: string }): string }): MaybePromise<void>;\n\t}\n\n\t// Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts\n\t//\n\t// MIT License\n\t//\n\t// Copyright (c) 2021-present, Joshua Hemphill\n\t// Copyright (c) 2021, Tecnico Corporation\n\t//\n\t// Permission is hereby granted, free of charge, to any person obtaining a copy\n\t// of this software and associated documentation files (the \"Software\"), to deal\n\t// in the Software without restriction, including without limitation the rights\n\t// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\t// copies of the Software, and to permit persons to whom the Software is\n\t// furnished to do so, subject to the following conditions:\n\t//\n\t// The above copyright notice and this permission notice shall be included in all\n\t// copies or substantial portions of the Software.\n\t//\n\t// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\t// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\t// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\t// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\t// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\t// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n\t// SOFTWARE.\n\n\tnamespace Csp {\n\t\ttype ActionSource = 'strict-dynamic' | 'report-sample';\n\t\ttype BaseSource =\n\t\t\t| 'self'\n\t\t\t| 'unsafe-eval'\n\t\t\t| 'unsafe-hashes'\n\t\t\t| 'unsafe-inline'\n\t\t\t| 'wasm-unsafe-eval'\n\t\t\t| 'none';\n\t\ttype CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;\n\t\ttype FrameSource = HostSource | SchemeSource | 'self' | 'none';\n\t\ttype HostNameScheme = `${string}.${string}` | 'localhost';\n\t\ttype HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`;\n\t\ttype HostProtocolSchemes = `${string}://` | '';\n\t\ttype HttpDelineator = '/' | '?' | '#' | '\\\\';\n\t\ttype PortScheme = `:${number}` | '' | ':*';\n\t\ttype SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:';\n\t\ttype Source = HostSource | SchemeSource | CryptoSource | BaseSource;\n\t\ttype Sources = Source[];\n\t}\n\n\tinterface CspDirectives {\n\t\t'child-src'?: Csp.Sources;\n\t\t'default-src'?: Array<Csp.Source | Csp.ActionSource>;\n\t\t'frame-src'?: Csp.Sources;\n\t\t'worker-src'?: Csp.Sources;\n\t\t'connect-src'?: Csp.Sources;\n\t\t'font-src'?: Csp.Sources;\n\t\t'img-src'?: Csp.Sources;\n\t\t'manifest-src'?: Csp.Sources;\n\t\t'media-src'?: Csp.Sources;\n\t\t'object-src'?: Csp.Sources;\n\t\t'prefetch-src'?: Csp.Sources;\n\t\t'script-src'?: Array<Csp.Source | Csp.ActionSource>;\n\t\t'script-src-elem'?: Csp.Sources;\n\t\t'script-src-attr'?: Csp.Sources;\n\t\t'style-src'?: Array<Csp.Source | Csp.ActionSource>;\n\t\t'style-src-elem'?: Csp.Sources;\n\t\t'style-src-attr'?: Csp.Sources;\n\t\t'base-uri'?: Array<Csp.Source | Csp.ActionSource>;\n\t\tsandbox?: Array<\n\t\t\t| 'allow-downloads-without-user-activation'\n\t\t\t| 'allow-forms'\n\t\t\t| 'allow-modals'\n\t\t\t| 'allow-orientation-lock'\n\t\t\t| 'allow-pointer-lock'\n\t\t\t| 'allow-popups'\n\t\t\t| 'allow-popups-to-escape-sandbox'\n\t\t\t| 'allow-presentation'\n\t\t\t| 'allow-same-origin'\n\t\t\t| 'allow-scripts'\n\t\t\t| 'allow-storage-access-by-user-activation'\n\t\t\t| 'allow-top-navigation'\n\t\t\t| 'allow-top-navigation-by-user-activation'\n\t\t>;\n\t\t'form-action'?: Array<Csp.Source | Csp.ActionSource>;\n\t\t'frame-ancestors'?: Array<Csp.HostSource | Csp.SchemeSource | Csp.FrameSource>;\n\t\t'navigate-to'?: Array<Csp.Source | Csp.ActionSource>;\n\t\t'report-uri'?: string[];\n\t\t'report-to'?: string[];\n\n\t\t'require-trusted-types-for'?: Array<'script'>;\n\t\t'trusted-types'?: Array<'none' | 'allow-duplicates' | '*' | string>;\n\t\t'upgrade-insecure-requests'?: boolean;\n\n\t\t/** @deprecated */\n\t\t'require-sri-for'?: Array<'script' | 'style' | 'script style'>;\n\n\t\t/** @deprecated */\n\t\t'block-all-mixed-content'?: boolean;\n\n\t\t/** @deprecated */\n\t\t'plugin-types'?: Array<`${string}/${string}` | 'none'>;\n\n\t\t/** @deprecated */\n\t\treferrer?: Array<\n\t\t\t| 'no-referrer'\n\t\t\t| 'no-referrer-when-downgrade'\n\t\t\t| 'origin'\n\t\t\t| 'origin-when-cross-origin'\n\t\t\t| 'same-origin'\n\t\t\t| 'strict-origin'\n\t\t\t| 'strict-origin-when-cross-origin'\n\t\t\t| 'unsafe-url'\n\t\t\t| 'none'\n\t\t>;\n\t}\n\n\ttype HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS';\n\n\tinterface Logger {\n\t\t(msg: string): void;\n\t\tsuccess(msg: string): void;\n\t\terror(msg: string): void;\n\t\twarn(msg: string): void;\n\t\tminor(msg: string): void;\n\t\tinfo(msg: string): void;\n\t}\n\n\ttype MaybePromise<T> = T | Promise<T>;\n\n\tinterface Prerendered {\n\t\t/**\n\t\t * 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`.\n\t\t */\n\t\tpages: Map<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\t/** The location of the .html file relative to the output directory */\n\t\t\t\tfile: string;\n\t\t\t}\n\t\t>;\n\t\t/**\n\t\t * A map of `path` to `{ type }` objects.\n\t\t */\n\t\tassets: Map<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\t/** The MIME type of the asset */\n\t\t\t\ttype: string;\n\t\t\t}\n\t\t>;\n\t\t/**\n\t\t * A map of redirects encountered during prerendering.\n\t\t */\n\t\tredirects: Map<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tstatus: number;\n\t\t\t\tlocation: string;\n\t\t\t}\n\t\t>;\n\t\t/** An array of prerendered paths (without trailing slashes, regardless of the trailingSlash config) */\n\t\tpaths: string[];\n\t}\n\n\tinterface PrerenderHttpErrorHandler {\n\t\t(details: {\n\t\t\tstatus: number;\n\t\t\tpath: string;\n\t\t\treferrer: string | null;\n\t\t\treferenceType: 'linked' | 'fetched';\n\t\t\tmessage: string;\n\t\t}): void;\n\t}\n\n\tinterface PrerenderMissingIdHandler {\n\t\t(details: { path: string; id: string; referrers: string[]; message: string }): void;\n\t}\n\n\tinterface PrerenderEntryGeneratorMismatchHandler {\n\t\t(details: { generatedFromId: string; entry: string; matchedId: string; message: string }): void;\n\t}\n\n\tinterface PrerenderUnseenRoutesHandler {\n\t\t(details: { routes: string[]; message: string }): void;\n\t}\n\n\ttype PrerenderHttpErrorHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderHttpErrorHandler;\n\ttype PrerenderMissingIdHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderMissingIdHandler;\n\ttype PrerenderUnseenRoutesHandlerValue =\n\t\t| 'fail'\n\t\t| 'warn'\n\t\t| 'ignore'\n\t\t| PrerenderUnseenRoutesHandler;\n\ttype PrerenderEntryGeneratorMismatchHandlerValue =\n\t\t| 'fail'\n\t\t| 'warn'\n\t\t| 'ignore'\n\t\t| PrerenderEntryGeneratorMismatchHandler;\n\n\texport type PrerenderOption = boolean | 'auto';\n\n\tinterface RequestOptions {\n\t\tgetClientAddress(): string;\n\t\tplatform?: App.Platform;\n\t}\n\n\tinterface RouteSegment {\n\t\tcontent: string;\n\t\tdynamic: boolean;\n\t\trest: boolean;\n\t}\n\n\t/** @default 'never' */\n\ttype TrailingSlash = 'never' | 'always' | 'ignore';\n\n\ttype DeepPartial<T> = T extends Record<PropertyKey, unknown> | unknown[]\n\t\t? {\n\t\t\t\t[K in keyof T]?: T[K] extends Record<PropertyKey, unknown> | unknown[]\n\t\t\t\t\t? DeepPartial<T[K]>\n\t\t\t\t\t: T[K];\n\t\t\t}\n\t\t: T | undefined;\n\n\ttype IsAny<T> = 0 extends 1 & T ? true : false;\n\tinterface Asset {\n\t\tfile: string;\n\t\tsize: number;\n\t\ttype: string | null;\n\t}\n\n\tinterface BuildData {\n\t\tapp_dir: string;\n\t\tapp_path: string;\n\t\tmanifest_data: ManifestData;\n\t\tout_dir: string;\n\t\tservice_worker: string | null;\n\t\tclient: {\n\t\t\t/** Path to the client entry point. */\n\t\t\tstart: string;\n\t\t\t/** Path to the generated `app.js` file that contains the client manifest. Only set in case of `bundleStrategy === 'split'`. */\n\t\t\tapp?: string;\n\t\t\t/** JS files that the client entry point relies on. */\n\t\t\timports: string[];\n\t\t\t/**\n\t\t\t * JS files that represent the entry points of the layouts/pages.\n\t\t\t * An entry is undefined if the layout/page has no component or universal file (i.e. only has a `.server.js` file).\n\t\t\t * Only set in case of `router.resolution === 'server'`.\n\t\t\t */\n\t\t\tnodes?: Array<string | undefined>;\n\t\t\t/**\n\t\t\t * CSS files referenced in the entry points of the layouts/pages.\n\t\t\t * An entry is undefined if the layout/page has no component or universal file (i.e. only has a `.server.js` file) or if has no CSS.\n\t\t\t * Only set in case of `router.resolution === 'server'`.\n\t\t\t */\n\t\t\tcss?: Array<string[] | undefined>;\n\t\t\t/**\n\t\t\t * Contains the client route manifest in a form suitable for the server which is used for server-side route resolution.\n\t\t\t * Notably, it contains all routes, regardless of whether they are prerendered or not (those are missing in the optimized server route manifest).\n\t\t\t * Only set in case of `router.resolution === 'server'`.\n\t\t\t */\n\t\t\troutes?: SSRClientRoute[];\n\t\t\tstylesheets: string[];\n\t\t\tfonts: string[];\n\t\t\tuses_env_dynamic_public: boolean;\n\t\t\t/** Only set in case of `bundleStrategy === 'inline'`. */\n\t\t\tinline?: {\n\t\t\t\tscript: string;\n\t\t\t\tstyle: string | undefined;\n\t\t\t};\n\t\t} | null;\n\t\tserver_manifest: import('vite').Manifest;\n\t}\n\n\tinterface ManifestData {\n\t\t/** Static files from `kit.config.files.assets`. */\n\t\tassets: Asset[];\n\t\thooks: {\n\t\t\tclient: string | null;\n\t\t\tserver: string | null;\n\t\t\tuniversal: string | null;\n\t\t};\n\t\tnodes: PageNode[];\n\t\troutes: RouteData[];\n\t\tmatchers: Record<string, string>;\n\t}\n\n\tinterface PageNode {\n\t\tdepth: number;\n\t\t/** The `+page/layout.svelte`. */\n\t\tcomponent?: string; // TODO supply default component if it's missing (bit of an edge case)\n\t\t/** The `+page/layout.js/.ts`. */\n\t\tuniversal?: string;\n\t\t/** The `+page/layout.server.js/ts`. */\n\t\tserver?: string;\n\t\tparent_id?: string;\n\t\tparent?: PageNode;\n\t\t/** Filled with the pages that reference this layout (if this is a layout). */\n\t\tchild_pages?: PageNode[];\n\t\t/** The final page options for a node if it was statically analysable */\n\t\tpage_options?: PageOptions | null;\n\t}\n\n\ttype RecursiveRequired<T> = {\n\t\t// Recursive implementation of TypeScript's Required utility type.\n\t\t// Will recursively continue until it reaches a primitive or Function\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n\t\t[K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type\n\t\t\t? RecursiveRequired<T[K]> // recursively continue through.\n\t\t\t: T[K]; // Use the exact type for everything else\n\t};\n\n\tinterface RouteParam {\n\t\tname: string;\n\t\tmatcher: string;\n\t\toptional: boolean;\n\t\trest: boolean;\n\t\tchained: boolean;\n\t}\n\n\t/**\n\t * Represents a route segment in the app. It can either be an intermediate node\n\t * with only layout/error pages, or a leaf, at which point either `page` and `leaf`\n\t * or `endpoint` is set.\n\t */\n\tinterface RouteData {\n\t\tid: string;\n\t\tparent: RouteData | null;\n\n\t\tsegment: string;\n\t\tpattern: RegExp;\n\t\tparams: RouteParam[];\n\n\t\tlayout: PageNode | null;\n\t\terror: PageNode | null;\n\t\tleaf: PageNode | null;\n\n\t\tpage: {\n\t\t\tlayouts: Array<number | undefined>;\n\t\t\terrors: Array<number | undefined>;\n\t\t\tleaf: number;\n\t\t} | null;\n\n\t\tendpoint: {\n\t\t\tfile: string;\n\t\t\t/** The final page options for the endpoint if it was statically analysable */\n\t\t\tpage_options: PageOptions | null;\n\t\t} | null;\n\t}\n\n\tinterface SSRComponent {\n\t\tdefault: {\n\t\t\trender(\n\t\t\t\tprops: Record<string, any>,\n\t\t\t\topts: { context: Map<any, any>; csp?: { nonce?: string; hash?: boolean } }\n\t\t\t): {\n\t\t\t\thtml: string;\n\t\t\t\thead: string;\n\t\t\t\tcss: {\n\t\t\t\t\tcode: string;\n\t\t\t\t\tmap: any; // TODO\n\t\t\t\t};\n\t\t\t\t/** Until we require all Svelte versions that support hashes, this might not be defined */\n\t\t\t\thashes?: {\n\t\t\t\t\tscript: Array<`sha256-${string}`>;\n\t\t\t\t};\n\t\t\t};\n\t\t};\n\t}\n\n\ttype SSRComponentLoader = () => Promise<SSRComponent>;\n\n\tinterface UniversalNode {\n\t\t/** Is `null` in case static analysis succeeds but the node is ssr=false */\n\t\tload?: Load;\n\t\tprerender?: PrerenderOption;\n\t\tssr?: boolean;\n\t\tcsr?: boolean;\n\t\ttrailingSlash?: TrailingSlash;\n\t\tconfig?: any;\n\t\tentries?: PrerenderEntryGenerator;\n\t}\n\n\tinterface ServerNode {\n\t\tload?: ServerLoad;\n\t\tprerender?: PrerenderOption;\n\t\tssr?: boolean;\n\t\tcsr?: boolean;\n\t\ttrailingSlash?: TrailingSlash;\n\t\tactions?: Actions;\n\t\tconfig?: any;\n\t\tentries?: PrerenderEntryGenerator;\n\t}\n\n\tinterface SSRNode {\n\t\t/** index into the `nodes` array in the generated `client/app.js`. */\n\t\tindex: number;\n\t\t/** external JS files that are loaded on the client. `imports[0]` is the entry point (e.g. `client/nodes/0.js`) */\n\t\timports: string[];\n\t\t/** external CSS files that are loaded on the client */\n\t\tstylesheets: string[];\n\t\t/** external font files that are loaded on the client */\n\t\tfonts: string[];\n\n\t\tuniversal_id?: string;\n\t\tserver_id?: string;\n\n\t\t/** inlined styles */\n\t\tinline_styles?(): MaybePromise<\n\t\t\tRecord<string, string | ((assets: string, base: string) => string)>\n\t\t>;\n\t\t/** Svelte component */\n\t\tcomponent?: SSRComponentLoader;\n\t\t/** +page.js or +layout.js */\n\t\tuniversal?: UniversalNode;\n\t\t/** +page.server.js, +layout.server.js, or +server.js */\n\t\tserver?: ServerNode;\n\t}\n\n\ttype SSRNodeLoader = () => Promise<SSRNode>;\n\n\tinterface PageNodeIndexes {\n\t\terrors: Array<number | undefined>;\n\t\tlayouts: Array<number | undefined>;\n\t\tleaf: number;\n\t}\n\n\ttype PrerenderEntryGenerator = () => MaybePromise<Array<Record<string, string>>>;\n\n\ttype SSREndpoint = Partial<Record<HttpMethod, RequestHandler>> & {\n\t\tprerender?: PrerenderOption;\n\t\ttrailingSlash?: TrailingSlash;\n\t\tconfig?: any;\n\t\tentries?: PrerenderEntryGenerator;\n\t\tfallback?: RequestHandler;\n\t};\n\n\tinterface SSRRoute {\n\t\tid: string;\n\t\tpattern: RegExp;\n\t\tparams: RouteParam[];\n\t\tpage: PageNodeIndexes | null;\n\t\tendpoint: (() => Promise<SSREndpoint>) | null;\n\t\tendpoint_id?: string;\n\t}\n\n\tinterface SSRClientRoute {\n\t\tid: string;\n\t\tpattern: RegExp;\n\t\tparams: RouteParam[];\n\t\terrors: Array<number | undefined>;\n\t\tlayouts: Array<[has_server_load: boolean, node_id: number] | undefined>;\n\t\tleaf: [has_server_load: boolean, node_id: number];\n\t}\n\n\ttype ValidatedConfig = Config & {\n\t\tkit: ValidatedKitConfig;\n\t\textensions: string[];\n\t};\n\n\ttype ValidatedKitConfig = Omit<RecursiveRequired<KitConfig>, 'adapter'> & {\n\t\tadapter?: Adapter;\n\t};\n\t/**\n\t * Throws an error with a HTTP status code and an optional message.\n\t * When called during request handling, this will cause SvelteKit to\n\t * return an error response without invoking `handleError`.\n\t * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.\n\t * @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.\n\t * @param body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.\n\t * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling.\n\t * @throws {Error} If the provided status is invalid (not between 400 and 599).\n\t */\n\texport function error(status: number, body: App.Error): never;\n\t/**\n\t * Throws an error with a HTTP status code and an optional message.\n\t * When called during request handling, this will cause SvelteKit to\n\t * return an error response without invoking `handleError`.\n\t * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.\n\t * @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.\n\t * @param body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.\n\t * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling.\n\t * @throws {Error} If the provided status is invalid (not between 400 and 599).\n\t */\n\texport function error(status: number, body?: {\n\t\tmessage: string;\n\t} extends App.Error ? App.Error | string | undefined : never): never;\n\t/**\n\t * Checks whether this is an error thrown by {@link error}.\n\t * @param status The status to filter for.\n\t * */\n\texport function isHttpError<T extends number>(e: unknown, status?: T): e is (HttpError_1 & {\n\t\tstatus: T extends undefined ? never : T;\n\t});\n\t/**\n\t * Redirect a request. When called during request handling, SvelteKit will return a redirect response.\n\t * Make sure you're not catching the thrown redirect, which would prevent SvelteKit from handling it.\n\t *\n\t * Most common status codes:\n\t *  * `303 See Other`: redirect as a GET request (often used after a form POST request)\n\t *  * `307 Temporary Redirect`: redirect will keep the request method\n\t *  * `308 Permanent Redirect`: redirect will keep the request method, SEO will be transferred to the new page\n\t *\n\t * [See all redirect status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages)\n\t *\n\t * @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.\n\t * @param location The location to redirect to.\n\t * @throws {Redirect} This error instructs SvelteKit to redirect to the specified location.\n\t * @throws {Error} If the provided status is invalid.\n\t * */\n\texport function redirect(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number), location: string | URL): never;\n\t/**\n\t * Checks whether this is a redirect thrown by {@link redirect}.\n\t * @param e The object to check.\n\t * */\n\texport function isRedirect(e: unknown): e is Redirect_1;\n\t/**\n\t * Create a JSON `Response` object from the supplied data.\n\t * @param data The value that will be serialized as JSON.\n\t * @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.\n\t */\n\texport function json(data: any, init?: ResponseInit): Response;\n\t/**\n\t * Create a `Response` object from the supplied body.\n\t * @param body The value that will be used as-is.\n\t * @param init Options such as `status` and `headers` that will be added to the response. A `Content-Length` header will be added automatically.\n\t */\n\texport function text(body: string, init?: ResponseInit): Response;\n\t/**\n\t * Create an `ActionFailure` object. Call when form submission fails.\n\t * @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.\n\t * */\n\texport function fail(status: number): ActionFailure<undefined>;\n\t/**\n\t * Create an `ActionFailure` object. Call when form submission fails.\n\t * @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.\n\t * @param data Data associated with the failure (e.g. validation errors)\n\t * */\n\texport function fail<T = undefined>(status: number, data: T): ActionFailure<T>;\n\t/**\n\t * Checks whether this is an action failure thrown by {@link fail}.\n\t * @param e The object to check.\n\t * */\n\texport function isActionFailure(e: unknown): e is ActionFailure;\n\t/**\n\t * Use this to throw a validation error to imperatively fail form validation.\n\t * Can be used in combination with `issue` passed to form actions to create field-specific issues.\n\t *\n\t * @example\n\t * ```ts\n\t * import { invalid } from '@sveltejs/kit';\n\t * import { form } from '$app/server';\n\t * import { tryLogin } from '$lib/server/auth';\n\t * import * as v from 'valibot';\n\t *\n\t * export const login = form(\n\t *   v.object({ name: v.string(), _password: v.string() }),\n\t *   async ({ name, _password }) => {\n\t *     const success = tryLogin(name, _password);\n\t *     if (!success) {\n\t *       invalid('Incorrect username or password');\n\t *     }\n\t *\n\t *     // ...\n\t *   }\n\t * );\n\t * ```\n\t * @since 2.47.3\n\t */\n\texport function invalid(...issues: (StandardSchemaV1.Issue | string)[]): never;\n\t/**\n\t * Checks whether this is an validation error thrown by {@link invalid}.\n\t * @param e The object to check.\n\t * @since 2.47.3\n\t */\n\texport function isValidationError(e: unknown): e is ActionFailure;\n\t/**\n\t * Strips possible SvelteKit-internal suffixes and trailing slashes from the URL pathname.\n\t * Returns the normalized URL as well as a method for adding the potential suffix back\n\t * based on a new pathname (possibly including search) or URL.\n\t * ```js\n\t * import { normalizeUrl } from '@sveltejs/kit';\n\t *\n\t * const { url, denormalize } = normalizeUrl('/blog/post/__data.json');\n\t * console.log(url.pathname); // /blog/post\n\t * console.log(denormalize('/blog/post/a')); // /blog/post/a/__data.json\n\t * ```\n\t * @since 2.18.0\n\t */\n\texport function normalizeUrl(url: URL | string): {\n\t\turl: URL;\n\t\twasNormalized: boolean;\n\t\tdenormalize: (url?: string | URL) => URL;\n\t};\n\texport type LessThan<TNumber extends number, TArray extends any[] = []> = TNumber extends TArray[\"length\"] ? TArray[number] : LessThan<TNumber, [...TArray, TArray[\"length\"]]>;\n\texport type NumericRange<TStart extends number, TEnd extends number> = Exclude<TEnd | LessThan<TEnd>, LessThan<TStart>>;\n\ttype ValidPageOption = (typeof valid_page_options_array)[number];\n\ttype PageOptions = Partial<Record<ValidPageOption, any>>;\n\tconst valid_page_options_array: readonly [\"ssr\", \"prerender\", \"csr\", \"trailingSlash\", \"config\", \"entries\", \"load\"];\n\texport const VERSION: string;\n\tclass HttpError_1 {\n\t\t\n\t\tconstructor(status: number, body: {\n\t\t\tmessage: string;\n\t\t} extends App.Error ? (App.Error | string | undefined) : App.Error);\n\t\tstatus: number;\n\t\tbody: App.Error;\n\t\ttoString(): string;\n\t}\n\tclass Redirect_1 {\n\t\t\n\t\tconstructor(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308, location: string);\n\t\tstatus: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308;\n\t\tlocation: string;\n\t}\n\n\texport {};\n}\n\ndeclare module '@sveltejs/kit/hooks' {\n\timport type { Handle } from '@sveltejs/kit';\n\t/**\n\t * A helper function for sequencing multiple `handle` calls in a middleware-like manner.\n\t * The behavior for the `handle` options is as follows:\n\t * - `transformPageChunk` is applied in reverse order and merged\n\t * - `preload` is applied in forward order, the first option \"wins\" and no `preload` options after it are called\n\t * - `filterSerializedResponseHeaders` behaves the same as `preload`\n\t *\n\t * ```js\n\t * /// file: src/hooks.server.js\n\t * import { sequence } from '@sveltejs/kit/hooks';\n\t *\n\t * /// type: import('@sveltejs/kit').Handle\n\t * async function first({ event, resolve }) {\n\t * \tconsole.log('first pre-processing');\n\t * \tconst result = await resolve(event, {\n\t * \t\ttransformPageChunk: ({ html }) => {\n\t * \t\t\t// transforms are applied in reverse order\n\t * \t\t\tconsole.log('first transform');\n\t * \t\t\treturn html;\n\t * \t\t},\n\t * \t\tpreload: () => {\n\t * \t\t\t// this one wins as it's the first defined in the chain\n\t * \t\t\tconsole.log('first preload');\n\t * \t\t\treturn true;\n\t * \t\t}\n\t * \t});\n\t * \tconsole.log('first post-processing');\n\t * \treturn result;\n\t * }\n\t *\n\t * /// type: import('@sveltejs/kit').Handle\n\t * async function second({ event, resolve }) {\n\t * \tconsole.log('second pre-processing');\n\t * \tconst result = await resolve(event, {\n\t * \t\ttransformPageChunk: ({ html }) => {\n\t * \t\t\tconsole.log('second transform');\n\t * \t\t\treturn html;\n\t * \t\t},\n\t * \t\tpreload: () => {\n\t * \t\t\tconsole.log('second preload');\n\t * \t\t\treturn true;\n\t * \t\t},\n\t * \t\tfilterSerializedResponseHeaders: () => {\n\t * \t\t\t// this one wins as it's the first defined in the chain\n\t * \t\t\tconsole.log('second filterSerializedResponseHeaders');\n\t * \t\t\treturn true;\n\t * \t\t}\n\t * \t});\n\t * \tconsole.log('second post-processing');\n\t * \treturn result;\n\t * }\n\t *\n\t * export const handle = sequence(first, second);\n\t * ```\n\t *\n\t * The example above would print:\n\t *\n\t * ```\n\t * first pre-processing\n\t * first preload\n\t * second pre-processing\n\t * second filterSerializedResponseHeaders\n\t * second transform\n\t * first transform\n\t * second post-processing\n\t * first post-processing\n\t * ```\n\t *\n\t * @param handlers The chain of `handle` functions\n\t * */\n\texport function sequence(...handlers: Handle[]): Handle;\n\n\texport {};\n}\n\ndeclare module '@sveltejs/kit/node' {\n\texport function getRequest({ request, base, bodySizeLimit }: {\n\t\trequest: import(\"http\").IncomingMessage;\n\t\tbase: string;\n\t\tbodySizeLimit?: number;\n\t}): Promise<Request>;\n\n\texport function setResponse(res: import(\"http\").ServerResponse, response: Response): Promise<void>;\n\t/**\n\t * Converts a file on disk to a readable stream\n\t * @since 2.4.0\n\t */\n\texport function createReadableStream(file: string): ReadableStream;\n\n\texport {};\n}\n\ndeclare module '@sveltejs/kit/node/polyfills' {\n\t/**\n\t * Make various web APIs available as globals:\n\t * - `crypto`\n\t * - `File`\n\t */\n\texport function installPolyfills(): void;\n\n\texport {};\n}\n\ndeclare module '@sveltejs/kit/vite' {\n\t/**\n\t * Returns the SvelteKit Vite plugins.\n\t * */\n\texport function sveltekit(): Promise<import(\"vite\").Plugin[]>;\n\n\texport {};\n}\n\ndeclare module '$app/environment' {\n\t/**\n\t * `true` if the app is running in the browser.\n\t */\n\texport const browser: boolean;\n\n\t/**\n\t * Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`.\n\t */\n\texport const dev: boolean;\n\n\t/**\n\t * SvelteKit analyses your app during the `build` step by running it. During this process, `building` is `true`. This also applies during prerendering.\n\t */\n\texport const building: boolean;\n\n\t/**\n\t * The value of `config.kit.version.name`.\n\t */\n\texport const version: string;\n\n\texport {};\n}\n\ndeclare module '$app/forms' {\n\t/**\n\t * Use this function to deserialize the response from a form submission.\n\t * Usage:\n\t *\n\t * ```js\n\t * import { deserialize } from '$app/forms';\n\t *\n\t * async function handleSubmit(event) {\n\t *   const response = await fetch('/form?/action', {\n\t *     method: 'POST',\n\t *     body: new FormData(event.target)\n\t *   });\n\t *\n\t *   const result = deserialize(await response.text());\n\t *   // ...\n\t * }\n\t * ```\n\t * */\n\texport function deserialize<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: string): import(\"@sveltejs/kit\").ActionResult<Success, Failure>;\n\t/**\n\t * This action enhances a `<form>` element that otherwise would work without JavaScript.\n\t *\n\t * The `submit` function is called upon submission with the given FormData and the `action` that should be triggered.\n\t * If `cancel` is called, the form will not be submitted.\n\t * You can use the abort `controller` to cancel the submission in case another one starts.\n\t * If a function is returned, that function is called with the response from the server.\n\t * If nothing is returned, the fallback will be used.\n\t *\n\t * If this function or its return value isn't set, it\n\t * - falls back to updating the `form` prop with the returned data if the action is on the same page as the form\n\t * - updates `page.status`\n\t * - resets the `<form>` element and invalidates all data in case of successful submission with no redirect response\n\t * - redirects in case of a redirect response\n\t * - redirects to the nearest error page in case of an unexpected error\n\t *\n\t * If you provide a custom function with a callback and want to use the default behavior, invoke `update` in your callback.\n\t * It accepts an options object\n\t * - `reset: false` if you don't want the `<form>` values to be reset after a successful submission\n\t * - `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission\n\t * @param form_element The form element\n\t * @param submit Submit callback\n\t */\n\texport function enhance<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(form_element: HTMLFormElement, submit?: import(\"@sveltejs/kit\").SubmitFunction<Success, Failure>): {\n\t\tdestroy(): void;\n\t};\n\t/**\n\t * This action updates the `form` property of the current page with the given data and updates `page.status`.\n\t * In case of an error, it redirects to the nearest error page.\n\t * */\n\texport function applyAction<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: import(\"@sveltejs/kit\").ActionResult<Success, Failure>): Promise<void>;\n\n\texport {};\n}\n\ndeclare module '$app/navigation' {\n\t/**\n\t * A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a URL.\n\t *\n\t * `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted.\n\t * */\n\texport function afterNavigate(callback: (navigation: import(\"@sveltejs/kit\").AfterNavigate) => void): void;\n\t/**\n\t * A navigation interceptor that triggers before we navigate to a URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls.\n\t *\n\t * 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.\n\t *\n\t * 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`.\n\t *\n\t * 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`.\n\t *\n\t * `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted.\n\t * */\n\texport function beforeNavigate(callback: (navigation: import(\"@sveltejs/kit\").BeforeNavigate) => void): void;\n\t/**\n\t * A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL except during full-page navigations.\n\t *\n\t * 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.\n\t *\n\t * 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.\n\t *\n\t * `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted.\n\t * */\n\texport function onNavigate(callback: (navigation: import(\"@sveltejs/kit\").OnNavigate) => MaybePromise<(() => void) | void>): void;\n\t/**\n\t * 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.\n\t * This is generally discouraged, since it breaks user expectations.\n\t * */\n\texport function disableScrollHandling(): void;\n\t/**\n\t * Allows you to navigate programmatically to a given route, with options such as keeping the current element focused.\n\t * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.\n\t *\n\t * For external URLs, use `window.location = url` instead of calling `goto(url)`.\n\t *\n\t * @param url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app.\n\t * @param {Object} opts Options related to the navigation\n\t * */\n\texport function goto(url: string | URL, opts?: {\n\t\treplaceState?: boolean | undefined;\n\t\tnoScroll?: boolean | undefined;\n\t\tkeepFocus?: boolean | undefined;\n\t\tinvalidateAll?: boolean | undefined;\n\t\tinvalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;\n\t\tstate?: App.PageState | undefined;\n\t}): Promise<void>;\n\t/**\n\t * 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.\n\t *\n\t * 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).\n\t * To create a custom identifier, use a string beginning with `[a-z]+:` (e.g. `custom:state`) — this is a valid URL.\n\t *\n\t * The `function` argument can be used define a custom predicate. It receives the full `URL` and causes `load` to rerun if `true` is returned.\n\t * This can be useful if you want to invalidate based on a pattern instead of a exact match.\n\t *\n\t * ```ts\n\t * // Example: Match '/path' regardless of the query parameters\n\t * import { invalidate } from '$app/navigation';\n\t *\n\t * invalidate((url) => url.pathname === '/path');\n\t * ```\n\t * @param resource The invalidated URL\n\t * */\n\texport function invalidate(resource: string | URL | ((url: URL) => boolean)): Promise<void>;\n\t/**\n\t * Causes all `load` and `query` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated.\n\t * */\n\texport function invalidateAll(): Promise<void>;\n\t/**\n\t * Causes all currently active remote functions to refresh, and all `load` functions belonging to the currently active page to re-run (unless disabled via the option argument).\n\t * Returns a `Promise` that resolves when the page is subsequently updated.\n\t * */\n\texport function refreshAll({ includeLoadFunctions }?: {\n\t\tincludeLoadFunctions?: boolean;\n\t}): Promise<void>;\n\t/**\n\t * Programmatically preloads the given page, which means\n\t *  1. ensuring that the code for the page is loaded, and\n\t *  2. calling the page's load function with the appropriate options.\n\t *\n\t * This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `data-sveltekit-preload-data`.\n\t * If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.\n\t * Returns a Promise that resolves with the result of running the new route's `load` functions once the preload is complete.\n\t *\n\t * @param href Page to preload\n\t * */\n\texport function preloadData(href: string): Promise<{\n\t\ttype: \"loaded\";\n\t\tstatus: number;\n\t\tdata: Record<string, any>;\n\t} | {\n\t\ttype: \"redirect\";\n\t\tlocation: string;\n\t}>;\n\t/**\n\t * Programmatically imports the code for routes that haven't yet been fetched.\n\t * Typically, you might call this to speed up subsequent navigation.\n\t *\n\t * 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`).\n\t *\n\t * Unlike `preloadData`, this won't call `load` functions.\n\t * Returns a Promise that resolves when the modules have been imported.\n\t *\n\t * */\n\texport function preloadCode(pathname: string): Promise<void>;\n\t/**\n\t * 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://svelte.dev/docs/kit/shallow-routing).\n\t *\n\t * */\n\texport function pushState(url: string | URL, state: App.PageState): void;\n\t/**\n\t * 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://svelte.dev/docs/kit/shallow-routing).\n\t *\n\t * */\n\texport function replaceState(url: string | URL, state: App.PageState): void;\n\ttype MaybePromise<T> = T | Promise<T>;\n\n\texport {};\n}\n\ndeclare module '$app/paths' {\n\timport type { RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname, RouteId, RouteParams, Asset, Pathname as Pathname_1 } from '$app/types';\n\t/**\n\t * A string that matches [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths).\n\t *\n\t * Example usage: `<a href=\"{base}/your-page\">Link</a>`\n\t *\n\t * @deprecated Use [`resolve(...)`](https://svelte.dev/docs/kit/$app-paths#resolve) instead\n\t */\n\texport let base: '' | `/${string}`;\n\n\t/**\n\t * An absolute path that matches [`config.kit.paths.assets`](https://svelte.dev/docs/kit/configuration#paths).\n\t *\n\t * > [!NOTE] 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.\n\t *\n\t * @deprecated Use [`asset(...)`](https://svelte.dev/docs/kit/$app-paths#asset) instead\n\t */\n\texport let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit_assets';\n\n\t/**\n\t * @deprecated Use [`resolve(...)`](https://svelte.dev/docs/kit/$app-paths#resolve) instead\n\t */\n\texport function resolveRoute<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash>(\n\t\t...args: ResolveArgs<T>\n\t): ResolvedPathname;\n\ttype StripSearchOrHash<T extends string> = T extends `${infer Pathname}?${string}`\n\t\t? Pathname\n\t\t: T extends `${infer Pathname}#${string}`\n\t\t\t? Pathname\n\t\t\t: T;\n\n\ttype ResolveArgs<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash> =\n\t\tT extends RouteId\n\t\t\t? RouteParams<T> extends Record<string, never>\n\t\t\t\t? [route: T]\n\t\t\t\t: [route: T, params: RouteParams<T>]\n\t\t\t: StripSearchOrHash<T> extends infer U extends RouteId\n\t\t\t\t? RouteParams<U> extends Record<string, never>\n\t\t\t\t\t? [route: T]\n\t\t\t\t\t: [route: T, params: RouteParams<U>]\n\t\t\t\t: [route: T];\n\t/**\n\t * Resolve the URL of an asset in your `static` directory, by prefixing it with [`config.kit.paths.assets`](https://svelte.dev/docs/kit/configuration#paths) if configured, or otherwise by prefixing it with the base path.\n\t *\n\t * During server rendering, the base path is relative and depends on the page currently being rendered.\n\t *\n\t * @example\n\t * ```svelte\n\t * <script>\n\t * \timport { asset } from '$app/paths';\n\t * </script>\n\t *\n\t * <img alt=\"a potato\" src={asset('/potato.jpg')} />\n\t * ```\n\t * @since 2.26\n\t *\n\t * */\n\texport function asset(file: Asset): string;\n\t/**\n\t * Resolve a pathname by prefixing it with the base path, if any, or resolve a route ID by populating dynamic segments with parameters.\n\t *\n\t * During server rendering, the base path is relative and depends on the page currently being rendered.\n\t *\n\t * @example\n\t * ```js\n\t * import { resolve } from '$app/paths';\n\t *\n\t * // using a pathname\n\t * const resolved = resolve(`/blog/hello-world`);\n\t *\n\t * // using a route ID plus parameters\n\t * const resolved = resolve('/blog/[slug]', {\n\t * \tslug: 'hello-world'\n\t * });\n\t * ```\n\t * @since 2.26\n\t *\n\t * */\n\texport function resolve<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash>(...args: ResolveArgs<T>): ResolvedPathname;\n\t/**\n\t * Match a path or URL to a route ID and extracts any parameters.\n\t *\n\t * @example\n\t * ```js\n\t * import { match } from '$app/paths';\n\t *\n\t * const route = await match('/blog/hello-world');\n\t *\n\t * if (route?.id === '/blog/[slug]') {\n\t * \tconst slug = route.params.slug;\n\t * \tconst response = await fetch(`/api/posts/${slug}`);\n\t * \tconst post = await response.json();\n\t * }\n\t * ```\n\t * @since 2.52.0\n\t *\n\t * */\n\texport function match(url: Pathname_1 | URL | (string & {})): Promise<{\n\t\tid: RouteId;\n\t\tparams: Record<string, string>;\n\t} | null>;\n\n\texport {};\n}\n\ndeclare module '$app/server' {\n\timport type { RequestEvent, RemoteCommand, RemoteForm, RemoteFormInput, InvalidField, RemotePrerenderFunction, RemoteQueryFunction } from '@sveltejs/kit';\n\timport type { StandardSchemaV1 } from '@standard-schema/spec';\n\t/**\n\t * Read the contents of an imported asset from the filesystem\n\t * @example\n\t * ```js\n\t * import { read } from '$app/server';\n\t * import somefile from './somefile.txt';\n\t *\n\t * const asset = read(somefile);\n\t * const text = await asset.text();\n\t * ```\n\t * @since 2.4.0\n\t */\n\texport function read(asset: string): Response;\n\t/**\n\t * Returns the current `RequestEvent`. Can be used inside server hooks, server `load` functions, actions, and endpoints (and functions called by them).\n\t *\n\t * In environments without [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).\n\t * @since 2.20.0\n\t *\n\t * */\n\texport function getRequestEvent(): RequestEvent;\n\t/**\n\t * Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function command<Output>(fn: () => Output): RemoteCommand<void, Output>;\n\t/**\n\t * Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function command<Input, Output>(validate: \"unchecked\", fn: (arg: Input) => Output): RemoteCommand<Input, Output>;\n\t/**\n\t * Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function command<Schema extends StandardSchemaV1, Output>(validate: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => Output): RemoteCommand<StandardSchemaV1.InferInput<Schema>, Output>;\n\t/**\n\t * Creates a form object that can be spread onto a `<form>` element.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function form<Output>(fn: () => MaybePromise<Output>): RemoteForm<void, Output>;\n\t/**\n\t * Creates a form object that can be spread onto a `<form>` element.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function form<Input extends RemoteFormInput, Output>(validate: \"unchecked\", fn: (data: Input, issue: InvalidField<Input>) => MaybePromise<Output>): RemoteForm<Input, Output>;\n\t/**\n\t * Creates a form object that can be spread onto a `<form>` element.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function form<Schema extends StandardSchemaV1<RemoteFormInput, Record<string, any>>, Output>(validate: Schema, fn: (data: StandardSchemaV1.InferOutput<Schema>, issue: InvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>): RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>;\n\t/**\n\t * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function prerender<Output>(fn: () => MaybePromise<Output>, options?: {\n\t\tinputs?: RemotePrerenderInputsGenerator<void>;\n\t\tdynamic?: boolean;\n\t} | undefined): RemotePrerenderFunction<void, Output>;\n\t/**\n\t * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function prerender<Input, Output>(validate: \"unchecked\", fn: (arg: Input) => MaybePromise<Output>, options?: {\n\t\tinputs?: RemotePrerenderInputsGenerator<Input>;\n\t\tdynamic?: boolean;\n\t} | undefined): RemotePrerenderFunction<Input, Output>;\n\t/**\n\t * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function prerender<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>, options?: {\n\t\tinputs?: RemotePrerenderInputsGenerator<StandardSchemaV1.InferInput<Schema>>;\n\t\tdynamic?: boolean;\n\t} | undefined): RemotePrerenderFunction<StandardSchemaV1.InferInput<Schema>, Output>;\n\t/**\n\t * Creates a remote query. When called from the browser, the function will be invoked on the server via a `fetch` call.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function query<Output>(fn: () => MaybePromise<Output>): RemoteQueryFunction<void, Output>;\n\t/**\n\t * Creates a remote query. When called from the browser, the function will be invoked on the server via a `fetch` call.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function query<Input, Output>(validate: \"unchecked\", fn: (arg: Input) => MaybePromise<Output>): RemoteQueryFunction<Input, Output>;\n\t/**\n\t * Creates a remote query. When called from the browser, the function will be invoked on the server via a `fetch` call.\n\t *\n\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.\n\t *\n\t * @since 2.27\n\t */\n\texport function query<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>): RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output>;\n\texport namespace query {\n\t\t/**\n\t\t * Creates a batch query function that collects multiple calls and executes them in a single request\n\t\t *\n\t\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.batch) for full documentation.\n\t\t *\n\t\t * @since 2.35\n\t\t */\n\t\tfunction batch<Input, Output>(validate: \"unchecked\", fn: (args: Input[]) => MaybePromise<(arg: Input, idx: number) => Output>): RemoteQueryFunction<Input, Output>;\n\t\t/**\n\t\t * Creates a batch query function that collects multiple calls and executes them in a single request\n\t\t *\n\t\t * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.batch) for full documentation.\n\t\t *\n\t\t * @since 2.35\n\t\t */\n\t\tfunction batch<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (args: StandardSchemaV1.InferOutput<Schema>[]) => MaybePromise<(arg: StandardSchemaV1.InferOutput<Schema>, idx: number) => Output>): RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output>;\n\t}\n\ttype RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Input[]>;\n\ttype MaybePromise<T> = T | Promise<T>;\n\n\texport {};\n}\n\ndeclare module '$app/state' {\n\t/**\n\t * A read-only reactive object with information about the current page, serving several use cases:\n\t * - retrieving the combined `data` of all pages/layouts anywhere in your component tree (also see [loading data](https://svelte.dev/docs/kit/load))\n\t * - retrieving the current value of the `form` prop anywhere in your component tree (also see [form actions](https://svelte.dev/docs/kit/form-actions))\n\t * - retrieving the page state that was set through `goto`, `pushState` or `replaceState` (also see [goto](https://svelte.dev/docs/kit/$app-navigation#goto) and [shallow routing](https://svelte.dev/docs/kit/shallow-routing))\n\t * - retrieving metadata such as the URL you're on, the current route and its parameters, and whether or not there was an error\n\t *\n\t * ```svelte\n\t * <!--- file: +layout.svelte --->\n\t * <script>\n\t * \timport { page } from '$app/state';\n\t * </script>\n\t *\n\t * <p>Currently at {page.url.pathname}</p>\n\t *\n\t * {#if page.error}\n\t * \t<span class=\"red\">Problem detected</span>\n\t * {:else}\n\t * \t<span class=\"small\">All systems operational</span>\n\t * {/if}\n\t * ```\n\t *\n\t * Changes to `page` are available exclusively with runes. (The legacy reactivity syntax will not reflect any changes)\n\t *\n\t * ```svelte\n\t * <!--- file: +page.svelte --->\n\t * <script>\n\t * \timport { page } from '$app/state';\n\t * \tconst id = $derived(page.params.id); // This will correctly update id for usage on this page\n\t * \t$: badId = page.params.id; // Do not use; will never update after initial load\n\t * </script>\n\t * ```\n\t *\n\t * On the server, values can only be read during rendering (in other words _not_ in e.g. `load` functions). In the browser, the values can be read at any time.\n\t *\n\t * */\n\texport const page: import(\"@sveltejs/kit\").Page;\n\t/**\n\t * A read-only object representing an in-progress navigation, with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties.\n\t * Values are `null` when no navigation is occurring, or during server rendering.\n\t * */\n\texport const navigating: import(\"@sveltejs/kit\").Navigation | {\n\t\tfrom: null;\n\t\tto: null;\n\t\ttype: null;\n\t\twillUnload: null;\n\t\tdelta: null;\n\t\tcomplete: null;\n\t};\n\t/**\n\t * A read-only reactive value that's initially `false`. If [`version.pollInterval`](https://svelte.dev/docs/kit/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update `current` to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.\n\t * */\n\texport const updated: {\n\t\tget current(): boolean;\n\t\tcheck(): Promise<boolean>;\n\t};\n\n\texport {};\n}\n\ndeclare module '$app/stores' {\n\texport function getStores(): {\n\t\t\n\t\tpage: typeof page;\n\t\t\n\t\tnavigating: typeof navigating;\n\t\t\n\t\tupdated: typeof updated;\n\t};\n\t/**\n\t * A readable store whose value contains page data.\n\t *\n\t * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.\n\t *\n\t * @deprecated Use `page` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))\n\t * */\n\texport const page: import(\"svelte/store\").Readable<import(\"@sveltejs/kit\").Page>;\n\t/**\n\t * A readable store.\n\t * When navigating starts, its value is a `Navigation` object with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties.\n\t * When navigating finishes, its value reverts to `null`.\n\t *\n\t * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.\n\t *\n\t * @deprecated Use `navigating` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))\n\t * */\n\texport const navigating: import(\"svelte/store\").Readable<import(\"@sveltejs/kit\").Navigation | null>;\n\t/**\n\t * A readable store whose initial value is `false`. If [`version.pollInterval`](https://svelte.dev/docs/kit/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.\n\t *\n\t * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.\n\t *\n\t * @deprecated Use `updated` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))\n\t * */\n\texport const updated: import(\"svelte/store\").Readable<boolean> & {\n\t\tcheck(): Promise<boolean>;\n\t};\n\n\texport {};\n}/**\n * 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:\n *\n * ```ts\n * declare global {\n * \tnamespace App {\n * \t\t// interface Error {}\n * \t\t// interface Locals {}\n * \t\t// interface PageData {}\n * \t\t// interface PageState {}\n * \t\t// interface Platform {}\n * \t}\n * }\n *\n * export {};\n * ```\n *\n * The `export {}` line exists because without it, the file would be treated as an _ambient module_ which prevents you from adding `import` declarations.\n * If you need to add ambient `declare module` declarations, do so in a separate file like `src/ambient.d.ts`.\n *\n * By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions.\n */\ndeclare namespace App {\n\t/**\n\t * 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.\n\t */\n\texport interface Error {\n\t\tmessage: string;\n\t}\n\n\t/**\n\t * The interface that defines `event.locals`, which can be accessed in server [hooks](https://svelte.dev/docs/kit/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files.\n\t */\n\texport interface Locals {}\n\n\t/**\n\t * Defines the common shape of the [page.data state](https://svelte.dev/docs/kit/$app-state#page) and [$page.data store](https://svelte.dev/docs/kit/$app-stores#page) - that is, the data that is shared between all pages.\n\t * The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.\n\t * Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).\n\t */\n\texport interface PageData {}\n\n\t/**\n\t * The shape of the `page.state` object, which can be manipulated using the [`pushState`](https://svelte.dev/docs/kit/$app-navigation#pushState) and [`replaceState`](https://svelte.dev/docs/kit/$app-navigation#replaceState) functions from `$app/navigation`.\n\t */\n\texport interface PageState {}\n\n\t/**\n\t * If your adapter provides [platform-specific context](https://svelte.dev/docs/kit/adapters#Platform-specific-context) via `event.platform`, you can specify it here.\n\t */\n\texport interface Platform {}\n}\n\n/**\n * This module is only available to [service workers](https://svelte.dev/docs/kit/service-workers).\n */\ndeclare module '$service-worker' {\n\t/**\n\t * 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.\n\t * Note that there is a `base` but no `assets`, since service workers cannot be used if `config.kit.paths.assets` is specified.\n\t */\n\texport const base: string;\n\t/**\n\t * An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`.\n\t * During development, this is an empty array.\n\t */\n\texport const build: string[];\n\t/**\n\t * 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://svelte.dev/docs/kit/configuration#serviceWorker)\n\t */\n\texport const files: string[];\n\t/**\n\t * An array of pathnames corresponding to prerendered pages and endpoints.\n\t * During development, this is an empty array.\n\t */\n\texport const prerendered: string[];\n\t/**\n\t * See [`config.kit.version`](https://svelte.dev/docs/kit/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.\n\t */\n\texport const version: string;\n}\n\n/**\n * This module contains generated types for the routes in your app.\n */\ndeclare module '$app/types' {\n\t/**\n\t * Interface for all generated app types. This gets extended via declaration merging. DO NOT USE THIS INTERFACE DIRECTLY.\n\t */\n\texport interface AppTypes {\n\t\t// These are all functions so that we can leverage function overloads to get the correct type.\n\t\t// Using the return types directly would error with a \"not the same type\" error.\n\t\t// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces\n\t\tRouteId(): string;\n\t\tRouteParams(): Record<string, Record<string, string>>;\n\t\tLayoutParams(): Record<string, Record<string, string>>;\n\t\tPathname(): string;\n\t\tResolvedPathname(): string;\n\t\tAsset(): string;\n\t}\n\n\t/**\n\t * A union of all the route IDs in your app. Used for `page.route.id` and `event.route.id`.\n\t */\n\texport type RouteId = ReturnType<AppTypes['RouteId']>;\n\n\t/**\n\t * `RouteId`, but possibly suffixed with a search string and/or hash.\n\t */\n\texport type RouteIdWithSearchOrHash = RouteId | `${RouteId}?${string}` | `${RouteId}#${string}`;\n\n\t/**\n\t * A utility for getting the parameters associated with a given route.\n\t */\n\texport type RouteParams<T extends RouteId> = T extends keyof ReturnType<AppTypes['RouteParams']>\n\t\t? ReturnType<AppTypes['RouteParams']>[T]\n\t\t: Record<string, never>;\n\n\t/**\n\t * A utility for getting the parameters associated with a given layout, which is similar to `RouteParams` but also includes optional parameters for any child route.\n\t */\n\texport type LayoutParams<T extends RouteId> = T extends keyof ReturnType<AppTypes['LayoutParams']>\n\t\t? ReturnType<AppTypes['LayoutParams']>[T]\n\t\t: Record<string, never>;\n\n\t/**\n\t * A union of all valid pathnames in your app.\n\t */\n\texport type Pathname = ReturnType<AppTypes['Pathname']>;\n\n\t/**\n\t * `Pathname`, but possibly suffixed with a search string and/or hash.\n\t */\n\texport type PathnameWithSearchOrHash =\n\t\t| Pathname\n\t\t| `${Pathname}?${string}`\n\t\t| `${Pathname}#${string}`;\n\n\t/**\n\t * `Pathname`, but possibly prefixed with a base path. Used for `page.url.pathname`.\n\t */\n\texport type ResolvedPathname = ReturnType<AppTypes['ResolvedPathname']>;\n\n\t/**\n\t * A union of all the filenames of assets contained in your `static` directory.\n\t */\n\texport type Asset = ReturnType<AppTypes['Asset']>;\n}\n\n//# sourceMappingURL=index.d.ts.map"
  },
  {
    "path": "packages/package/.gitignore",
    "content": ".DS_Store\n/node_modules/\n/test/**/build/\n!/src/core/adapt/fixtures/*/.svelte-kit/\n!/test/node_modules/\n/test/apps/basics/test/errors.json\n.custom-out-dir/\n/test/watch/src/lib/*\n!/test/watch/src/lib/index.js\n\n# these are already ignored by the top level .gitignore\n# repeating them here as a faux prettier ignore\n.svelte-kit/\ndist/\n"
  },
  {
    "path": "packages/package/CHANGELOG.md",
    "content": "# @sveltejs/package\n\n## 2.5.7\n### Patch Changes\n\n\n- chore(deps): update dependency chokidar to v5 ([#14986](https://github.com/sveltejs/kit/pull/14986))\n\n## 2.5.6\n### Patch Changes\n\n\n- fix: transform `.ts` extensions to `.js` in import/export statements of Svelte files when using `rewriteRelativeImportExtensions` ([#14936](https://github.com/sveltejs/kit/pull/14936))\n\n## 2.5.5\n### Patch Changes\n\n\n- fix: resolve aliases before transpiling for `rewriteRelativeImportExtensions` ([#14673](https://github.com/sveltejs/kit/pull/14673))\n\n## 2.5.4\n### Patch Changes\n\n\n- fix: resolve more alias issues ([#14514](https://github.com/sveltejs/kit/pull/14514))\n\n## 2.5.3\n### Patch Changes\n\n\n- fix: handle `import/export name, { ... }` when resolving aliases ([#14462](https://github.com/sveltejs/kit/pull/14462))\n\n## 2.5.2\n### Patch Changes\n\n\n- fix: handle `import/export * (as ...)` when resolving aliases ([#14433](https://github.com/sveltejs/kit/pull/14433))\n\n\n- fix: prevent false-positive alias replacement ([#14433](https://github.com/sveltejs/kit/pull/14433))\n\n## 2.5.1\n### Patch Changes\n\n\n- fix: better alias resolution ([#14413](https://github.com/sveltejs/kit/pull/14413))\n\n## 2.5.0\n### Minor Changes\n\n\n- feat: add `--preserve-output` flag to prevent deletion of the output directory before packaging ([#13055](https://github.com/sveltejs/kit/pull/13055))\n\n## 2.4.1\n### Patch Changes\n\n\n- chore: add `.git` to the end of `package.json` repository url ([#14134](https://github.com/sveltejs/kit/pull/14134))\n\n## 2.4.0\n### Minor Changes\n\n\n- feat: support svelte.config.ts ([#13935](https://github.com/sveltejs/kit/pull/13935))\n  \n  > **NOTE**\n  >\n  > Your runtime has to support importing TypeScript files for `svelte.config.ts` to work.\n  > In Node.js, the feature is supported with the `--experimental-strip-types` flag starting in Node 22.6.0 and supported without a flag starting in Node 23.6.0.\n\n## 2.3.12\n### Patch Changes\n\n\n- fix: handle non-semver-style dependency versions ([#13925](https://github.com/sveltejs/kit/pull/13925))\n\n## 2.3.11\n### Patch Changes\n\n\n- fix: handle missing package.json gracefully ([#13691](https://github.com/sveltejs/kit/pull/13691))\n\n## 2.3.10\n### Patch Changes\n\n\n- chore: update to chokidar 4.0.3 ([#13381](https://github.com/sveltejs/kit/pull/13381))\n\n## 2.3.9\n### Patch Changes\n\n\n- chore: bump `svelte2tsx` dependency for more up-to-date `d.ts` output ([#8843](https://github.com/sveltejs/kit/pull/8843))\n\n\n- fix: adjust declaration map paths ([#8843](https://github.com/sveltejs/kit/pull/8843))\n\n## 2.3.8\n### Patch Changes\n\n\n- fix: resolve aliases more robustly ([#13351](https://github.com/sveltejs/kit/pull/13351))\n\n## 2.3.7\n### Patch Changes\n\n\n- docs: update URLs for new svelte.dev site ([#12857](https://github.com/sveltejs/kit/pull/12857))\n\n## 2.3.6\n### Patch Changes\n\n\n- docs: demonstrate sv migrate over prior commands ([#12840](https://github.com/sveltejs/kit/pull/12840))\n\n## 2.3.5\n### Patch Changes\n\n\n- fix: use input tsconfig when calling emitDts ([#12612](https://github.com/sveltejs/kit/pull/12612))\n\n\n- chore(deps): update dependency chokidar to v4 ([#12671](https://github.com/sveltejs/kit/pull/12671))\n\n## 2.3.4\n### Patch Changes\n\n\n- chore: configure provenance in a simpler manner ([#12570](https://github.com/sveltejs/kit/pull/12570))\n\n## 2.3.3\n### Patch Changes\n\n\n- chore: package provenance ([#12567](https://github.com/sveltejs/kit/pull/12567))\n\n## 2.3.2\n\n### Patch Changes\n\n- chore: add keywords for discovery in npm search ([#12330](https://github.com/sveltejs/kit/pull/12330))\n\n## 2.3.1\n\n### Patch Changes\n\n- fix: don't strip `lang=\"ts\"` tag in Svelte 5 ([#12080](https://github.com/sveltejs/kit/pull/12080))\n\n## 2.3.0\n\n### Minor Changes\n\n- feat: add option to specify the tsconfig/jsconfig ([#11698](https://github.com/sveltejs/kit/pull/11698))\n\n## 2.2.7\n\n### Patch Changes\n\n- chore: update chokidar to 3.6.0 ([#11811](https://github.com/sveltejs/kit/pull/11811))\n\n## 2.2.6\n\n### Patch Changes\n\n- chore: bump svelte2tsx dependency to support generating types for `.svelte.js/ts` files ([#11619](https://github.com/sveltejs/kit/pull/11619))\n\n## 2.2.5\n\n### Patch Changes\n\n- fix: improve warning when encountering import.meta.env ([#11440](https://github.com/sveltejs/kit/pull/11440))\n\n## 2.2.4\n\n### Patch Changes\n\n- chore: update primary branch from master to main ([`47779436c5f6c4d50011d0ef8b2709a07c0fec5d`](https://github.com/sveltejs/kit/commit/47779436c5f6c4d50011d0ef8b2709a07c0fec5d))\n\n## 2.2.3\n\n### Patch Changes\n\n- fix: overwrite nodenext option when transpiling ([#11092](https://github.com/sveltejs/kit/pull/11092))\n\n## 2.2.2\n\n### Patch Changes\n\n- fix: prevent crash on errors in watch mode ([#10628](https://github.com/sveltejs/kit/pull/10628))\n\n## 2.2.1\n\n### Patch Changes\n\n- fix: delay emptying `dist/` folder ([#10514](https://github.com/sveltejs/kit/pull/10514))\n\n## 2.2.0\n\n### Minor Changes\n\n- feat: use Svelte 4 typings when packaging if dependencies allow it ([#10328](https://github.com/sveltejs/kit/pull/10328))\n\n## 2.1.0\n\n### Minor Changes\n\n- feat: support Svelte 4 ([#10225](https://github.com/sveltejs/kit/pull/10225))\n\n## 2.0.2\n\n### Patch Changes\n\n- fix: don't emit false positive export condition warning ([#9109](https://github.com/sveltejs/kit/pull/9109))\n\n## 2.0.1\n\n### Patch Changes\n\n- fix: print version when running `svelte-package --version` ([#9078](https://github.com/sveltejs/kit/pull/9078))\n\n## 2.0.0\n\n### Major Changes\n\n- breaking: remove `package.json` generation and package options from `svelte.config.js`. New default output directory is `dist`. Read the migration guide at https://github.com/sveltejs/kit/pull/8922 to learn how to update ([#8922](https://github.com/sveltejs/kit/pull/8922))\n\n## 1.0.2\n\n### Patch Changes\n\n- chore: update svelte2tsx ([`50a3c5a6`](https://github.com/sveltejs/kit/commit/50a3c5a6d1282c64422e80fe19b352c14e41c853))\n\n## 1.0.1\n\n### Patch Changes\n\n- fix: explicitly mark Node 17.x as not supported ([#8174](https://github.com/sveltejs/kit/pull/8174))\n\n## 1.0.0\n\n### Major Changes\n\nFirst major release, see below for the history of changes that lead up to this.\nStarting from now all releases follow semver and changes will be listed as Major/Minor/Patch\n\n## 1.0.0-next.6\n\n### Patch Changes\n\n- feat: warn if svelte not found in dependencies or peerDependencies ([#7685](https://github.com/sveltejs/kit/pull/7685))\n\n## 1.0.0-next.5\n\n### Patch Changes\n\n- fix check for undefined on application/ strip ([#6932](https://github.com/sveltejs/kit/pull/6932))\n\n## 1.0.0-next.4\n\n### Patch Changes\n\n- fix: don't strip `type=\"application/..\"` tags ([#6887](https://github.com/sveltejs/kit/pull/6887))\n\n## 1.0.0-next.3\n\n### Patch Changes\n\n- feat: Support aliases set through `kit.alias` ([#6350](https://github.com/sveltejs/kit/pull/6350))\n\n## 1.0.0-next.2\n\n### Patch Changes\n\n- breaking: require Node 16.14 ([#6388](https://github.com/sveltejs/kit/pull/6388))\n"
  },
  {
    "path": "packages/package/README.md",
    "content": "# The fastest way to build Svelte packages\n\n[Build Svelte packages](https://svelte.dev/docs/kit/packaging) in correctly packaged format.\n\nThe quickest way to get started is via the [sv](https://npmjs.com/package/sv) package:\n\n```sh\nnpx sv create my-app\ncd my-app\nnpm install\nnpm run dev\n```\n\nSee the [documentation](https://svelte.dev/docs/kit/packaging) to learn more.\n\n## Changelog\n\n[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/package/CHANGELOG.md).\n"
  },
  {
    "path": "packages/package/package.json",
    "content": "{\n\t\"name\": \"@sveltejs/package\",\n\t\"version\": \"2.5.7\",\n\t\"description\": \"The fastest way to build Svelte packages\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/sveltejs/kit.git\",\n\t\t\"directory\": \"packages/package\"\n\t},\n\t\"keywords\": [\n\t\t\"build\",\n\t\t\"bundle\",\n\t\t\"component\",\n\t\t\"library\",\n\t\t\"packaging\",\n\t\t\"svelte\",\n\t\t\"tool\"\n\t],\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://svelte.dev\",\n\t\"type\": \"module\",\n\t\"dependencies\": {\n\t\t\"chokidar\": \"^5.0.0\",\n\t\t\"kleur\": \"^4.1.5\",\n\t\t\"sade\": \"^1.8.1\",\n\t\t\"semver\": \"^7.5.4\",\n\t\t\"svelte2tsx\": \"~0.7.33\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"@types/node\": \"catalog:\",\n\t\t\"@types/semver\": \"catalog:\",\n\t\t\"prettier\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-preprocess\": \"catalog:\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^3.44.0 || ^4.0.0 || ^5.0.0-next.1\"\n\t},\n\t\"bin\": {\n\t\t\"svelte-package\": \"svelte-package.js\"\n\t},\n\t\"files\": [\n\t\t\"src\"\n\t],\n\t\"scripts\": {\n\t\t\"lint\": \"prettier --check .\",\n\t\t\"check\": \"tsc\",\n\t\t\"check:all\": \"tsc && pnpm -r --filter=\\\"./**\\\" check\",\n\t\t\"format\": \"pnpm lint --write\",\n\t\t\"test\": \"vitest run\"\n\t},\n\t\"exports\": {\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \"^16.14 || >=18\"\n\t}\n}\n"
  },
  {
    "path": "packages/package/src/cli.js",
    "content": "import fs from 'node:fs';\nimport process from 'node:process';\nimport colors from 'kleur';\nimport sade from 'sade';\nimport { load_config } from './config.js';\n\n/** @param {Error} error */\nfunction handle_error(error) {\n\tif (error.name === 'SyntaxError') throw error;\n\n\tconsole.error(colors.bold().red(`> ${error.message}`));\n\tif (error.stack) {\n\t\tconsole.error(colors.gray(error.stack.split('\\n').slice(1).join('\\n')));\n\t}\n\n\tprocess.exit(1);\n}\n\nconst pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));\nconst prog = sade('svelte-package', true).version(pkg.version);\n\nprog\n\t.describe('Create a package')\n\t.option('-i, --input', 'Input directory')\n\t.option('-o, --output', 'Output directory', 'dist')\n\t.option('-p, --preserve-output', 'Do not delete the output directory before packaging', false)\n\t.option('-t, --types', 'Emit type declarations', true)\n\t.option('-w, --watch', 'Rerun when files change', false)\n\t.option(\n\t\t'--tsconfig',\n\t\t'A path to a tsconfig or jsconfig file. When not provided, searches for the next upper tsconfig/jsconfig in the workspace path.'\n\t)\n\t.action(async (args) => {\n\t\ttry {\n\t\t\tconst config = await load_config();\n\n\t\t\t// @ts-expect-error\n\t\t\tif (config.package) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'config.package is no longer supported. See https://github.com/sveltejs/kit/pull/8922 for more information and how to migrate.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst packaging = await import('./index.js');\n\n\t\t\t/** @type {import('./types.js').Options} */\n\t\t\tconst options = {\n\t\t\t\tcwd: process.cwd(),\n\t\t\t\tinput: args.input ?? config.kit?.files?.lib ?? 'src/lib',\n\t\t\t\toutput: args.output,\n\t\t\t\tpreserve_output: args['preserve-output'],\n\t\t\t\ttsconfig: args.tsconfig,\n\t\t\t\ttypes: args.types,\n\t\t\t\tconfig\n\t\t\t};\n\n\t\t\tawait (args.watch ? packaging.watch(options) : packaging.build(options));\n\t\t} catch (error) {\n\t\t\thandle_error(/** @type {Error} */ (error));\n\t\t}\n\t});\n\nprog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` });\n"
  },
  {
    "path": "packages/package/src/config.js",
    "content": "import path from 'node:path';\nimport process from 'node:process';\nimport fs from 'node:fs';\nimport url from 'node:url';\n\n/**\n * Loads and validates Svelte config file\n * @param {{ cwd?: string }} options\n * @returns {Promise<import('./types.js').Options['config']>}\n */\nexport async function load_config({ cwd = process.cwd() } = {}) {\n\tconst config_files = ['js', 'ts']\n\t\t.map((ext) => path.join(cwd, `svelte.config.${ext}`))\n\t\t.filter((f) => fs.existsSync(f));\n\n\tif (config_files.length === 0) {\n\t\treturn {};\n\t}\n\tconst config_file = config_files[0];\n\tif (config_files.length > 1) {\n\t\tconsole.log(\n\t\t\t`Found multiple Svelte config files in ${cwd}: ${config_files.map((f) => path.basename(f)).join(', ')}. Using ${path.basename(config_file)}`\n\t\t);\n\t}\n\tconst config = (await import(`${url.pathToFileURL(config_file).href}?ts=${Date.now()}`)).default;\n\n\tif (config.package) {\n\t\tthrow new Error(\n\t\t\t'config.package is no longer supported. See https://github.com/sveltejs/kit/discussions/8825 for more information.'\n\t\t);\n\t}\n\n\treturn config;\n}\n\n/**\n * @param {string} cwd\n * @returns {Record<string, any>}\n */\nexport function load_pkg_json(cwd = process.cwd()) {\n\tconst pkg_json_file = path.join(cwd, 'package.json');\n\n\tif (!fs.existsSync(pkg_json_file)) {\n\t\treturn {};\n\t}\n\n\treturn JSON.parse(fs.readFileSync(pkg_json_file, 'utf-8'));\n}\n"
  },
  {
    "path": "packages/package/src/filesystem.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\n\n/** @param {string} dir */\nexport function mkdirp(dir) {\n\ttry {\n\t\tfs.mkdirSync(dir, { recursive: true });\n\t} catch (/** @type {any} */ e) {\n\t\tif (e.code === 'EEXIST') return;\n\t\tthrow e;\n\t}\n}\n\n/** @param {string} path */\nexport function rimraf(path) {\n\tfs.rmSync(path, { force: true, recursive: true });\n}\n\n/** @param {string} str */\nexport function posixify(str) {\n\treturn str.replace(/\\\\/g, '/');\n}\n\n/**\n * Get a list of all files in a directory\n * @param {string} cwd - the directory to walk\n * @param {boolean} [dirs] - whether to include directories in the result\n */\nexport function walk(cwd, dirs = false) {\n\t/** @type {string[]} */\n\tconst all_files = [];\n\n\t/** @param {string} dir */\n\tfunction walk_dir(dir) {\n\t\tconst files = fs.readdirSync(path.join(cwd, dir));\n\n\t\tfor (const file of files) {\n\t\t\tconst joined = path.join(dir, file);\n\t\t\tconst stats = fs.statSync(path.join(cwd, joined));\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\tif (dirs) all_files.push(joined);\n\t\t\t\twalk_dir(joined);\n\t\t\t} else {\n\t\t\t\tall_files.push(joined);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (walk_dir(''), all_files);\n}\n\n/**\n * @param {string} source\n * @param {string} target\n * @param {{\n *   filter?: (basename: string) => boolean;\n *   replace?: Record<string, string>;\n * }} opts\n */\nexport function copy(source, target, opts = {}) {\n\tif (!fs.existsSync(source)) return [];\n\n\t/** @type {string[]} */\n\tconst files = [];\n\n\tconst prefix = posixify(target) + '/';\n\n\tconst regex = opts.replace\n\t\t? new RegExp(`\\\\b(${Object.keys(opts.replace).join('|')})\\\\b`, 'g')\n\t\t: null;\n\n\t/**\n\t * @param {string} from\n\t * @param {string} to\n\t */\n\tfunction go(from, to) {\n\t\tif (opts.filter && !opts.filter(path.basename(from))) return;\n\n\t\tconst stats = fs.statSync(from);\n\n\t\tif (stats.isDirectory()) {\n\t\t\tfs.readdirSync(from).forEach((file) => {\n\t\t\t\tgo(path.join(from, file), path.join(to, file));\n\t\t\t});\n\t\t} else {\n\t\t\tmkdirp(path.dirname(to));\n\n\t\t\tif (opts.replace) {\n\t\t\t\tconst data = fs.readFileSync(from, 'utf-8');\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tto,\n\t\t\t\t\tdata.replace(\n\t\t\t\t\t\t/** @type {RegExp} */ (regex),\n\t\t\t\t\t\t(_match, key) => /** @type {Record<string, string>} */ (opts.replace)[key]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tfs.copyFileSync(from, to);\n\t\t\t}\n\n\t\t\tfiles.push(to === target ? posixify(path.basename(to)) : posixify(to).replace(prefix, ''));\n\t\t}\n\t}\n\n\tgo(source, target);\n\n\treturn files;\n}\n"
  },
  {
    "path": "packages/package/src/index.js",
    "content": "import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport colors from 'kleur';\nimport chokidar from 'chokidar';\nimport { preprocess } from 'svelte/compiler';\nimport { copy, mkdirp, posixify, rimraf } from './filesystem.js';\nimport {\n\tanalyze,\n\tresolve_aliases,\n\tresolve_ts_endings,\n\tscan,\n\tstrip_lang_tags,\n\twrite\n} from './utils.js';\nimport { emit_dts, load_tsconfig, transpile_ts } from './typescript.js';\nimport { create_validator } from './validate.js';\n\n/**\n * @param {import('./types.js').Options} options\n */\nexport async function build(options) {\n\tconst { analyse_code, validate } = create_validator(options);\n\tawait do_build(options, analyse_code);\n\tvalidate();\n}\n\n/**\n * @param {import('./types.js').Options} options\n * @param {(name: string, code: string) => void} analyse_code\n */\nasync function do_build(options, analyse_code) {\n\tconst { input, output, temp, extensions, alias, tsconfig } = normalize_options(options);\n\n\tif (!fs.existsSync(input)) {\n\t\tthrow new Error(`${path.relative('.', input)} does not exist`);\n\t}\n\n\trimraf(temp);\n\tmkdirp(temp);\n\n\tconst files = scan(input, extensions);\n\n\tif (options.types) {\n\t\tawait emit_dts(input, temp, output, options.cwd, alias, files, tsconfig);\n\t}\n\n\t/** @type {Map<string, import('typescript').CompilerOptions>} */\n\tconst tsconfig_cache = new Map();\n\n\tfor (const file of files) {\n\t\tawait process_file(\n\t\t\tinput,\n\t\t\ttemp,\n\t\t\tfile,\n\t\t\toptions.config.preprocess,\n\t\t\talias,\n\t\t\ttsconfig,\n\t\t\tanalyse_code,\n\t\t\ttsconfig_cache\n\t\t);\n\t}\n\n\tif (!options.preserve_output) {\n\t\trimraf(output);\n\t}\n\n\tmkdirp(output);\n\tcopy(temp, output);\n\n\tconsole.log(\n\t\tcolors\n\t\t\t.bold()\n\t\t\t.green(`${path.relative(options.cwd, input)} -> ${path.relative(options.cwd, output)}`)\n\t);\n}\n\n/**\n * @param {import('./types.js').Options} options\n */\nexport async function watch(options) {\n\tconst { analyse_code, validate } = create_validator(options);\n\n\tawait do_build(options, analyse_code);\n\n\tvalidate();\n\n\tconst { input, output, extensions, alias, tsconfig } = normalize_options(options);\n\n\tconst message = `\\nWatching ${path.relative(options.cwd, input)} for changes...\\n`;\n\n\tconsole.log(message);\n\n\t/** @type {Array<{ file: import('./types.js').File, type: string }>} */\n\tconst pending = [];\n\n\t/** @type {Array<(value?: any) => void>} */\n\tconst fulfillers = [];\n\n\t/** @type {NodeJS.Timeout} */\n\tlet timeout;\n\n\t/** @type {Map<string, import('typescript').CompilerOptions>} */\n\tconst tsconfig_cache = new Map();\n\n\tconst watcher = chokidar.watch(input, { ignoreInitial: true });\n\t/** @type {Promise<void>} */\n\tconst ready = new Promise((resolve) => watcher.on('ready', resolve));\n\n\twatcher.on('all', (type, filepath) => {\n\t\tconst file = analyze(path.relative(input, filepath), extensions);\n\n\t\tpending.push({ file, type });\n\n\t\tif (\n\t\t\tfile.name.endsWith('tsconfig.json') ||\n\t\t\tfile.name.endsWith('jsconfig.json') ||\n\t\t\t(options.tsconfig && posixify(filepath) === posixify(options.tsconfig))\n\t\t) {\n\t\t\ttsconfig_cache.clear();\n\t\t}\n\n\t\tclearTimeout(timeout);\n\t\ttimeout = setTimeout(async () => {\n\t\t\tconst files = scan(input, extensions);\n\n\t\t\tconst events = pending.slice();\n\t\t\tpending.length = 0;\n\n\t\t\tlet errored = false;\n\n\t\t\tfor (const { file, type } of events) {\n\t\t\t\tif (type === 'unlink') {\n\t\t\t\t\tfor (const candidate of [\n\t\t\t\t\t\tfile.name,\n\t\t\t\t\t\t`${file.base}.d.ts`,\n\t\t\t\t\t\t`${file.base}.d.mts`,\n\t\t\t\t\t\t`${file.base}.d.cts`\n\t\t\t\t\t]) {\n\t\t\t\t\t\tconst resolved = path.join(output, candidate);\n\n\t\t\t\t\t\tif (fs.existsSync(resolved)) {\n\t\t\t\t\t\t\tfs.unlinkSync(resolved);\n\n\t\t\t\t\t\t\tconst parent = path.dirname(resolved);\n\t\t\t\t\t\t\tif (parent !== output && fs.readdirSync(parent).length === 0) {\n\t\t\t\t\t\t\t\tfs.rmdirSync(parent);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconsole.log(`Removed ${file.dest}`);\n\t\t\t\t}\n\n\t\t\t\tif (type === 'add' || type === 'change') {\n\t\t\t\t\tconsole.log(`Processing ${file.name}`);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait process_file(\n\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\toptions.config.preprocess,\n\t\t\t\t\t\t\talias,\n\t\t\t\t\t\t\ttsconfig,\n\t\t\t\t\t\t\tanalyse_code,\n\t\t\t\t\t\t\ttsconfig_cache\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\terrored = true;\n\t\t\t\t\t\tconsole.error(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!errored && options.types) {\n\t\t\t\ttry {\n\t\t\t\t\tawait emit_dts(input, output, output, options.cwd, alias, files, tsconfig);\n\t\t\t\t\tconsole.log('Updated .d.ts files');\n\t\t\t\t} catch (e) {\n\t\t\t\t\terrored = true;\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!errored) {\n\t\t\t\tvalidate();\n\t\t\t}\n\n\t\t\tconsole.log(message);\n\n\t\t\tfulfillers.forEach((fn) => fn());\n\t\t}, 100);\n\t});\n\n\treturn {\n\t\twatcher,\n\t\tready,\n\t\tsettled: () =>\n\t\t\tnew Promise((fulfil, reject) => {\n\t\t\t\tfulfillers.push(fulfil);\n\t\t\t\tsetTimeout(() => reject(new Error('Timed out')), 1000);\n\t\t\t})\n\t};\n}\n\n/**\n * @param {import('./types.js').Options} options\n */\nfunction normalize_options(options) {\n\tconst input = path.resolve(options.cwd, options.input);\n\tconst output = path.resolve(options.cwd, options.output);\n\tconst preserve_output = options.preserve_output;\n\tconst temp = path.resolve(\n\t\toptions.cwd,\n\t\toptions.config.kit?.outDir ?? '.svelte-kit',\n\t\t'__package__'\n\t);\n\tconst extensions = options.config.extensions ?? ['.svelte'];\n\tconst tsconfig = options.tsconfig ? path.resolve(options.cwd, options.tsconfig) : undefined;\n\n\tconst alias = {\n\t\t$lib: path.resolve(options.cwd, options.config.kit?.files?.lib ?? 'src/lib'),\n\t\t...(options.config.kit?.alias ?? {})\n\t};\n\n\treturn {\n\t\tinput,\n\t\toutput,\n\t\tpreserve_output,\n\t\ttemp,\n\t\textensions,\n\t\talias,\n\t\ttsconfig\n\t};\n}\n\n/**\n * @param {string} input\n * @param {string} output\n * @param {import('./types.js').File} file\n * @param {import('svelte/types/compiler/preprocess').PreprocessorGroup | undefined} preprocessor\n * @param {Record<string, string>} aliases\n * @param {string | undefined} tsconfig\n * @param {(name: string, code: string) => void} analyse_code\n * @param {Map<string, import('typescript').CompilerOptions>} tsconfig_cache\n */\nasync function process_file(\n\tinput,\n\toutput,\n\tfile,\n\tpreprocessor,\n\taliases,\n\ttsconfig,\n\tanalyse_code,\n\ttsconfig_cache\n) {\n\tconst filename = path.join(input, file.name);\n\tconst dest = path.join(output, file.dest);\n\n\tif (file.is_svelte || file.name.endsWith('.ts') || file.name.endsWith('.js')) {\n\t\tlet contents = fs.readFileSync(filename, 'utf-8');\n\n\t\tif (file.is_svelte) {\n\t\t\tif (preprocessor) {\n\t\t\t\tconst preprocessed = (await preprocess(contents, preprocessor, { filename })).code;\n\t\t\t\tcontents = strip_lang_tags(preprocessed);\n\t\t\t}\n\t\t}\n\n\t\t// _before_ transpilining TS, that way TS will apply rewriteRelativeImportExtensions\n\t\t// to these now-resolved path aliases, too\n\t\tcontents = resolve_aliases(input, file.name, contents, aliases);\n\n\t\tif (file.name.endsWith('.ts') && !file.name.endsWith('.d.ts')) {\n\t\t\tcontents = await transpile_ts(tsconfig, filename, contents, tsconfig_cache);\n\t\t} else if (file.is_svelte) {\n\t\t\tconst options = await load_tsconfig(tsconfig, filename, tsconfig_cache);\n\t\t\t// Mimic TypeScript's transpileModule behavior for Svelte files\n\t\t\tif (options.rewriteRelativeImportExtensions) {\n\t\t\t\tcontents = resolve_ts_endings(contents);\n\t\t\t}\n\t\t}\n\n\t\tanalyse_code(file.name, contents);\n\t\twrite(dest, contents);\n\t} else {\n\t\tcopy(filename, dest);\n\t}\n}\n"
  },
  {
    "path": "packages/package/src/types.d.ts",
    "content": "import { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\nexport interface Options {\n\tcwd: string;\n\tinput: string;\n\toutput: string;\n\tpreserve_output: boolean;\n\ttypes: boolean;\n\ttsconfig?: string;\n\tconfig: {\n\t\textensions?: string[];\n\t\tkit?: {\n\t\t\talias?: Record<string, string>;\n\t\t\tfiles?: {\n\t\t\t\tlib?: string;\n\t\t\t};\n\t\t\toutDir?: string;\n\t\t};\n\t\tpreprocess?: PreprocessorGroup;\n\t};\n}\n\nexport interface File {\n\tname: string;\n\tdest: string;\n\tbase: string;\n\tis_svelte: boolean;\n}\n\nexport type RecursiveRequired<T> = {\n\t// Recursive implementation of TypeScript's Required utility type.\n\t// Will recursively continue until it reaches a primitive or Function\n\t[K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type\n\t\t? RecursiveRequired<T[K]> // recursively continue through.\n\t\t: T[K]; // Use the exact type for everything else\n};\n\nexport interface ValidatedConfig {\n\textensions: string[];\n\tkit?: any;\n\tpreprocess?: any;\n}\n\nexport type Validator<T = any> = (input: T, keypath: string) => T;\n"
  },
  {
    "path": "packages/package/src/typescript.js",
    "content": "import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport semver from 'semver';\nimport { posixify, mkdirp, rimraf, walk } from './filesystem.js';\nimport { resolve_aliases, write } from './utils.js';\nimport { emitDts } from 'svelte2tsx';\nimport { load_pkg_json } from './config.js';\n\n/**\n * Generates d.ts files by invoking TypeScript's \"emit d.ts files from input files\".\n * The files are written to a temporary location and those which should be kept\n * are sanitized ($lib alias resolved) and copied over to the destination folder.\n *\n * @param {string} input\n * @param {string} output\n * @param {string} final_output\n * @param {string} cwd\n * @param {Record<string, string>} alias\n * @param {import('./types.js').File[]} files\n * @param {string | undefined} tsconfig\n */\nexport async function emit_dts(input, output, final_output, cwd, alias, files, tsconfig) {\n\tconst tmp = `${output}/__package_types_tmp__`;\n\trimraf(tmp);\n\tmkdirp(tmp);\n\n\tconst require = createRequire(import.meta.url);\n\tconst pkg = load_pkg_json(cwd);\n\tconst svelte_dep = pkg.peerDependencies?.svelte || pkg.dependencies?.svelte || '3.0';\n\tlet no_svelte_3;\n\ttry {\n\t\tno_svelte_3 = !semver.intersects(svelte_dep, '^3.0.0');\n\t} catch {\n\t\t// Not all version specs are valid semver, e.g. \"latest\" or \"next\" or catalog references\n\t\tno_svelte_3 = true;\n\t}\n\tawait emitDts({\n\t\tlibRoot: input,\n\t\tsvelteShimsPath: no_svelte_3\n\t\t\t? require.resolve('svelte2tsx/svelte-shims-v4.d.ts')\n\t\t\t: require.resolve('svelte2tsx/svelte-shims.d.ts'),\n\t\tdeclarationDir: path.relative(cwd, tmp),\n\t\ttsconfig\n\t});\n\n\tconst handwritten = new Set();\n\n\t// skip files that conflict with hand-written .d.ts\n\tfor (const file of files) {\n\t\tif (file.name.endsWith('.d.ts')) {\n\t\t\thandwritten.add(file.name);\n\t\t}\n\t}\n\n\t// resolve $lib alias (TODO others), copy into package dir\n\tfor (const file of walk(tmp)) {\n\t\tconst normalized = posixify(file);\n\n\t\tif (handwritten.has(normalized)) {\n\t\t\tconsole.warn(`Using $lib/${normalized} instead of generated .d.ts file`);\n\t\t}\n\n\t\tlet source = fs.readFileSync(path.join(tmp, normalized), 'utf8');\n\t\tif (file.endsWith('.d.ts.map')) {\n\t\t\t// Because we put the .d.ts files in a temporary directory, the relative path needs to be adjusted\n\t\t\tconst parsed = JSON.parse(source);\n\t\t\tif (parsed.sources) {\n\t\t\t\tparsed.sources = /** @type {string[]} */ (parsed.sources).map((source) =>\n\t\t\t\t\tposixify(\n\t\t\t\t\t\tpath.join(\n\t\t\t\t\t\t\tpath.relative(\n\t\t\t\t\t\t\t\tpath.dirname(path.join(final_output, normalized)),\n\t\t\t\t\t\t\t\tpath.dirname(path.join(input, normalized))\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpath.basename(source)\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tsource = JSON.stringify(parsed);\n\t\t\t}\n\t\t} else {\n\t\t\tsource = resolve_aliases(input, normalized, source, alias);\n\t\t}\n\t\twrite(path.join(output, normalized), source);\n\t}\n\n\trimraf(tmp);\n}\n\n/**\n * TS -> JS\n *\n * @param {string | undefined} tsconfig\n * @param {string} filename\n * @param {string} source\n * @param {Map<string, import('typescript').CompilerOptions>} cache\n */\nexport async function transpile_ts(tsconfig, filename, source, cache) {\n\tconst ts = await try_load_ts();\n\tconst options = await load_tsconfig(tsconfig, filename, cache, ts);\n\t// transpileModule treats NodeNext as CommonJS because it doesn't read the package.json. Therefore we need to override it.\n\t// Also see https://github.com/microsoft/TypeScript/issues/53022 (the filename workaround doesn't work).\n\treturn ts.transpileModule(source, {\n\t\tcompilerOptions: {\n\t\t\t...options,\n\t\t\tmodule: ts.ModuleKind.ESNext,\n\t\t\tmoduleResolution: ts.ModuleResolutionKind.NodeNext\n\t\t},\n\t\tfileName: filename\n\t}).outputText;\n}\n\nasync function try_load_ts() {\n\ttry {\n\t\treturn (await import('typescript')).default;\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'You need to install TypeScript if you want to transpile TypeScript files and/or generate type definitions'\n\t\t);\n\t}\n}\n\n/**\n * @param {string | undefined} tsconfig\n * @param {string} filename\n * @param {Map<string, import('typescript').CompilerOptions>} cache\n * @param {import('typescript')} [ts]\n */\nexport async function load_tsconfig(tsconfig, filename, cache, ts) {\n\tif (!ts) {\n\t\tts = await try_load_ts();\n\t}\n\n\tlet config_filename;\n\t/** @type {string[]} */\n\tconst traversed_dirs = [];\n\n\tif (tsconfig) {\n\t\tif (fs.existsSync(tsconfig)) {\n\t\t\tconfig_filename = tsconfig;\n\n\t\t\tconst cached = cache.get(config_filename);\n\t\t\tif (cached) {\n\t\t\t\treturn cached;\n\t\t\t} else {\n\t\t\t\t// This isn't really a dir, but it simplifies the caching logic\n\t\t\t\ttraversed_dirs.push(config_filename);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error('Failed to locate provided tsconfig or jsconfig');\n\t\t}\n\t} else {\n\t\t// ts.findConfigFile is broken (it will favour a distant tsconfig\n\t\t// over a near jsconfig, and then only when you call it twice)\n\t\t// so we implement it ourselves\n\t\tlet dir = filename;\n\t\twhile (dir !== (dir = path.dirname(dir))) {\n\t\t\tconst cached = cache.get(dir);\n\t\t\tif (cached) {\n\t\t\t\tfor (const traversed of traversed_dirs) {\n\t\t\t\t\tcache.set(traversed, cached);\n\t\t\t\t}\n\t\t\t\treturn cached;\n\t\t\t}\n\n\t\t\ttraversed_dirs.push(dir);\n\n\t\t\tconst tsconfig = path.join(dir, 'tsconfig.json');\n\t\t\tconst jsconfig = path.join(dir, 'jsconfig.json');\n\n\t\t\tif (fs.existsSync(tsconfig)) {\n\t\t\t\tconfig_filename = tsconfig;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (fs.existsSync(jsconfig)) {\n\t\t\t\tconfig_filename = jsconfig;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!config_filename) {\n\t\tthrow new Error('Failed to locate tsconfig or jsconfig');\n\t}\n\n\tconst { error, config } = ts.readConfigFile(config_filename, ts.sys.readFile);\n\n\tif (error) {\n\t\tthrow new Error('Malformed tsconfig\\n' + JSON.stringify(error, null, 2));\n\t}\n\n\t// Do this so TS will not search for initial files which might take a while\n\tconfig.include = [];\n\tconfig.files = [];\n\tconst { options } = ts.parseJsonConfigFileContent(\n\t\tconfig,\n\t\tts.sys,\n\t\tpath.dirname(config_filename),\n\t\t{ sourceMap: false },\n\t\tconfig_filename\n\t);\n\n\tfor (const dir of traversed_dirs) {\n\t\tcache.set(dir, options);\n\t}\n\n\treturn options;\n}\n"
  },
  {
    "path": "packages/package/src/utils.js",
    "content": "import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { VERSION } from 'svelte/compiler';\nimport { posixify, mkdirp, walk } from './filesystem.js';\n\nconst is_svelte_5_plus = Number(VERSION.split('.')[0]) >= 5;\n\n/**\n * Resolves aliases\n *\n * @param {string} input\n * @param {string} file Relative to the input\n * @param {string} content\n * @param {Record<string, string>} aliases\n * @returns {string}\n */\nexport function resolve_aliases(input, file, content, aliases) {\n\treturn adjust_imports(content, (import_path) => {\n\t\tfor (const [alias, value] of Object.entries(aliases)) {\n\t\t\tif (\n\t\t\t\timport_path !== alias &&\n\t\t\t\t!import_path.startsWith(alias + (alias.endsWith('/') ? '' : '/'))\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst full_path = path.join(input, file);\n\t\t\tconst full_import_path = path.join(value, import_path.slice(alias.length));\n\t\t\tlet resolved = posixify(path.relative(path.dirname(full_path), full_import_path));\n\t\t\tresolved = resolved.startsWith('.') ? resolved : './' + resolved;\n\t\t\treturn resolved;\n\t\t}\n\t\treturn import_path;\n\t});\n}\n\n/**\n * Replace .ts extensions with .js in relative import/export statements\n *\n * @param {string} content\n * @returns {string}\n */\nexport function resolve_ts_endings(content) {\n\treturn adjust_imports(content, (import_path) => {\n\t\tif (\n\t\t\timport_path[0] === '.' &&\n\t\t\t((import_path[1] === '.' && import_path[2] === '/') || import_path[1] === '/') &&\n\t\t\timport_path.endsWith('.ts')\n\t\t) {\n\t\t\treturn import_path.slice(0, -3) + '.js';\n\t\t}\n\t\treturn import_path;\n\t});\n}\n\n/**\n * Adjust import paths\n *\n * @param {string} content\n * @param {(import_path: string) => string} adjust\n * @returns {string}\n */\nexport function adjust_imports(content, adjust) {\n\t/**\n\t * @param {string} match\n\t * @param {string} quote\n\t * @param {string} import_path\n\t */\n\tconst replace_import_path = (match, quote, import_path) => {\n\t\tconst adjusted = adjust(import_path);\n\t\tif (adjusted !== import_path) {\n\t\t\treturn match.replace(quote + import_path + quote, quote + adjusted + quote);\n\t\t}\n\t\treturn match;\n\t};\n\n\t// import/export (type) (xxx | xxx,) { ... } from ...\n\tcontent = content.replace(\n\t\t/\\b(?:import|export)(?:\\s+type)?(?:(?:\\s+\\p{L}[\\p{L}0-9]*\\s+)|(?:(?:\\s+\\p{L}[\\p{L}0-9]*\\s*,\\s*)?\\s*\\{[^}]*\\}\\s*))from\\s*(['\"])([^'\";]+)\\1/gmu,\n\t\t(match, quote, import_path) => replace_import_path(match, quote, import_path)\n\t);\n\n\t// import/export (type) * as xxx from ...\n\tcontent = content.replace(\n\t\t/\\b(?:import|export)(?:\\s+type)?\\s*\\*\\s*as\\s+\\p{L}[\\p{L}0-9]*\\s+from\\s*(['\"])([^'\";]+)\\1/gmu,\n\t\t(match, quote, import_path) => replace_import_path(match, quote, import_path)\n\t);\n\n\t// export (type) * from ...\n\tcontent = content.replace(\n\t\t/\\b(?:export)(?:\\s+type)?\\s*\\*\\s*from\\s*(['\"])([^'\";]+)\\1/gmu,\n\t\t(match, quote, import_path) => replace_import_path(match, quote, import_path)\n\t);\n\n\t// import(...)\n\tcontent = content.replace(\n\t\t/\\bimport\\s*\\(\\s*(['\"])([^'\";]+)\\1\\s*\\)/g,\n\t\t(match, quote, import_path) => replace_import_path(match, quote, import_path)\n\t);\n\n\t// import '...'\n\tcontent = content.replace(/\\bimport\\s+(['\"])([^'\";]+)\\1/g, (match, quote, import_path) =>\n\t\treplace_import_path(match, quote, import_path)\n\t);\n\n\treturn content;\n}\n\n/**\n * Strip out lang=\"X\" or type=\"text/X\" tags. Doing it here is only a temporary solution.\n * See https://github.com/sveltejs/kit/issues/2450 for ideas for places where it's handled better.\n *\n * @param {string} content\n */\nexport function strip_lang_tags(content) {\n\treturn content\n\t\t.replace(\n\t\t\t/(<!--[^]*?-->)|(<script[^>]*?)\\s(?:type|lang)=([\"'])(.*?)\\3/g,\n\t\t\t// Things like application/ld+json should be kept as-is. Preprocessed languages are \"ts\" etc.\n\t\t\t// Svelte 5 deals with TypeScript natively, and in the template, too, therefore keep it in.\n\t\t\t// Not removing it would mean Svelte parses without its TS plugin and then runs into errors.\n\t\t\t(match, comment, tag_open, _, type) =>\n\t\t\t\ttype?.startsWith('application/') || (is_svelte_5_plus && type === 'ts')\n\t\t\t\t\t? match\n\t\t\t\t\t: (comment ?? '') + (tag_open ?? '')\n\t\t)\n\t\t.replace(/(<!--[^]*?-->)|(<style[^>]*?)\\s(?:type|lang)=([\"']).*?\\3/g, '$1$2');\n}\n\n/**\n * @param {string} file\n * @param {Parameters<typeof fs.writeFileSync>[1]} contents\n */\nexport function write(file, contents) {\n\tmkdirp(path.dirname(file));\n\tfs.writeFileSync(file, contents);\n}\n\n/**\n * @param {string} input\n * @param {string[]} extensions\n * @returns {import('./types.js').File[]}\n */\nexport function scan(input, extensions) {\n\treturn walk(input).map((file) => analyze(file, extensions));\n}\n\n/**\n * @param {string} file\n * @param {string[]} extensions\n * @returns {import('./types.js').File}\n */\nexport function analyze(file, extensions) {\n\tconst name = posixify(file);\n\n\tconst svelte_extension = extensions.find((ext) => name.endsWith(ext));\n\n\tconst base = svelte_extension ? name : name.slice(0, -path.extname(name).length);\n\n\tconst dest = svelte_extension\n\t\t? name.slice(0, -svelte_extension.length) + '.svelte'\n\t\t: name.endsWith('.d.ts')\n\t\t\t? name\n\t\t\t: name.endsWith('.ts')\n\t\t\t\t? name.slice(0, -3) + '.js'\n\t\t\t\t: name;\n\n\treturn {\n\t\tname,\n\t\tdest,\n\t\tbase,\n\t\tis_svelte: !!svelte_extension\n\t};\n}\n"
  },
  {
    "path": "packages/package/src/validate.js",
    "content": "import colors from 'kleur';\nimport { load_pkg_json } from './config.js';\n\n/**\n * @param {import(\"./types.js\").Options} options\n */\nexport function create_validator(options) {\n\tconst { analyse_code, validate } = _create_validator(options);\n\n\treturn {\n\t\t/**\n\t\t * Checks a file content for problematic imports and things like `import.meta`\n\t\t * @param {string} name\n\t\t * @param {string} content\n\t\t */\n\t\tanalyse_code(name, content) {\n\t\t\tanalyse_code(name, content);\n\t\t},\n\t\tvalidate() {\n\t\t\t/** @type {Record<string, any>} */\n\t\t\tconst pkg = load_pkg_json(options.cwd);\n\t\t\tconst warnings = validate(pkg);\n\t\t\tif (Object.keys(pkg).length === 0) {\n\t\t\t\twarnings.push(\n\t\t\t\t\t'No package.json found in the current directory. Please create one or run this command in a directory containing one.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Just warnings, not errors, because\n\t\t\t// - would be annoying in watch mode (would have to restart the server)\n\t\t\t// - maybe there's a custom post-build script that fixes some of these\n\t\t\tif (warnings.length) {\n\t\t\t\tconsole.log(\n\t\t\t\t\tcolors\n\t\t\t\t\t\t.bold()\n\t\t\t\t\t\t.yellow('@sveltejs/package found the following issues while packaging your library:')\n\t\t\t\t);\n\t\t\t\tfor (const warning of warnings) {\n\t\t\t\t\tconsole.log(colors.yellow(`${warning}\\n`));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n}\n/**\n * @param {import(\"./types.js\").Options} options\n */\nexport function _create_validator(options) {\n\t/** @type {Set<string>} */\n\tconst imports = new Set();\n\tlet uses_import_meta = false;\n\tlet has_svelte_files = false;\n\n\t/**\n\t * Checks a file content for problematic imports and things like `import.meta`\n\t * @param {string} name\n\t * @param {string} content\n\t */\n\tfunction analyse_code(name, content) {\n\t\thas_svelte_files =\n\t\t\thas_svelte_files ||\n\t\t\t(options.config.extensions ?? ['.svelte']).some((ext) => name.endsWith(ext));\n\t\tuses_import_meta = uses_import_meta || content.includes('import.meta.env');\n\n\t\tconst file_imports = [\n\t\t\t...content.matchAll(/from\\s+('|\")([^\"';,]+?)\\1/g),\n\t\t\t...content.matchAll(/import\\s*\\(\\s*('|\")([^\"';,]+?)\\1\\s*\\)/g)\n\t\t];\n\t\tfor (const [, , import_path] of file_imports) {\n\t\t\tif (import_path.startsWith('$app/')) {\n\t\t\t\timports.add(import_path);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {Record<string, any>} pkg\n\t */\n\tfunction validate(pkg) {\n\t\t/** @type {string[]} */\n\t\tconst warnings = [];\n\n\t\tif (\n\t\t\timports.has('$app/environment') &&\n\t\t\t[...imports].filter((i) => i.startsWith('$app/')).length === 1\n\t\t) {\n\t\t\twarnings.push(\n\t\t\t\t'Avoid usage of `$app/environment` in your code, if you want the library to work for people not using SvelteKit (only regular Svelte, for example). ' +\n\t\t\t\t\t'Consider using packages like `esm-env` instead which provide cross-bundler-compatible environment variables.'\n\t\t\t);\n\t\t}\n\n\t\tif (uses_import_meta) {\n\t\t\twarnings.push(\n\t\t\t\t'Avoid usage of `import.meta.env` in your code. It only works in apps bundled with Vite. ' +\n\t\t\t\t\t'Consider using packages like `esm-env` instead which works with all bundlers or without bundling.'\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\t!(pkg.dependencies?.['@sveltejs/kit'] || pkg.peerDependencies?.['@sveltejs/kit']) &&\n\t\t\t([...imports].some((i) => i.startsWith('$app/')) || imports.has('@sveltejs/kit'))\n\t\t) {\n\t\t\twarnings.push(\n\t\t\t\t'You are using SvelteKit-specific imports in your code, but you have not declared a dependency on `@sveltejs/kit` in your `package.json`. ' +\n\t\t\t\t\t'Add it to your `dependencies` or `peerDependencies`.'\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\t!(pkg.dependencies?.svelte || pkg.peerDependencies?.svelte) &&\n\t\t\t(has_svelte_files ||\n\t\t\t\t[...imports].some((i) => i.startsWith('svelte/') || imports.has('svelte')))\n\t\t) {\n\t\t\twarnings.push(\n\t\t\t\t'You are using Svelte components or Svelte-specific imports in your code, but you have not declared a dependency on `svelte` in your `package.json`. ' +\n\t\t\t\t\t'Add it to your `dependencies` or `peerDependencies`.'\n\t\t\t);\n\t\t}\n\n\t\tif (pkg.exports) {\n\t\t\tconst { conditions } = traverse_exports(pkg.exports);\n\t\t\tif (has_svelte_files && !pkg.svelte && !conditions.has('svelte')) {\n\t\t\t\twarnings.push(\n\t\t\t\t\t'You are using Svelte files, but did not declare a `svelte` condition in one of your `exports` in your `package.json`. ' +\n\t\t\t\t\t\t'Add a `svelte` condition to your `exports` to ensure that your package is recognized as Svelte package by tooling. ' +\n\t\t\t\t\t\t'See https://svelte.dev/docs/kit/packaging#anatomy-of-a-package-json-exports for more info'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (pkg.svelte) {\n\t\t\t\tconst root_export = pkg.exports['.'];\n\t\t\t\tif (!root_export) {\n\t\t\t\t\twarnings.push(\n\t\t\t\t\t\t'You have a `svelte` field in your `package.json`, but no root export in your `exports`. Please align them so that bundlers will resolve consistently to the same file.'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tconst { exports } = traverse_exports({ '.': root_export });\n\t\t\t\t\tif (![...exports].map(export_to_regex).some((_export) => _export.test(pkg.svelte))) {\n\t\t\t\t\t\twarnings.push(\n\t\t\t\t\t\t\t'The `svelte` field in your `package.json` does not match any export in your root `exports`. Please align them so that bundlers will resolve consistently to the same file.'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tObject.keys(pkg.exports).map(export_to_regex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\twarnings.push(\n\t\t\t\t'No `exports` field found in `package.json`, please provide one. ' +\n\t\t\t\t\t'See https://svelte.dev/docs/kit/packaging#anatomy-of-a-package-json-exports for more info'\n\t\t\t);\n\t\t}\n\n\t\treturn warnings;\n\t}\n\n\treturn {\n\t\tanalyse_code,\n\t\tvalidate\n\t};\n}\n\n/**\n * @param {Record<string, any>} exports_map\n * @returns {{ exports: Set<string>; conditions: Set<string> }}\n */\nfunction traverse_exports(exports_map) {\n\t/** @type {Set<string>} */\n\tconst exports = new Set();\n\t/** @type {Set<string>} */\n\tconst conditions = new Set();\n\n\t/**\n\t * @param {Record<string, any>} exports_map\n\t * @param {boolean} is_first_level\n\t */\n\tfunction traverse(exports_map, is_first_level) {\n\t\tfor (const key of Object.keys(exports_map ?? {})) {\n\t\t\tif (!is_first_level) {\n\t\t\t\tconditions.add(key);\n\t\t\t}\n\n\t\t\tconst _export = exports_map[key];\n\n\t\t\tif (typeof _export === 'string') {\n\t\t\t\texports.add(_export);\n\t\t\t} else {\n\t\t\t\ttraverse(_export, false);\n\t\t\t}\n\t\t}\n\t}\n\n\ttraverse(exports_map, true);\n\n\treturn { exports, conditions };\n}\n\n/** @param {string} _export */\nfunction export_to_regex(_export) {\n\t// $& means the whole matched string\n\tconst regex_str = _export.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '.*');\n\treturn new RegExp(`^${regex_str}$`);\n}\n"
  },
  {
    "path": "packages/package/svelte-package.js",
    "content": "#!/usr/bin/env node\nimport './src/cli.js';\n"
  },
  {
    "path": "packages/package/test/errors/no-lib-folder/package.json",
    "content": "{\n\t\"name\": \"error-no-lib-folder\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"validate no lib folder error output\"\n}\n"
  },
  {
    "path": "packages/package/test/errors/no-lib-folder/svelte.config.js",
    "content": "export default {};\n"
  },
  {
    "path": "packages/package/test/errors/no-lib-folder/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"checkJs\": true,\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"$lib/*\": [\"./src/lib/*\"]\n\t\t}\n\t},\n\t\"include\": [\"src/**/*.d.ts\", \"src/**/*.js\", \"src/**/*.svelte\"]\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/assets/jsconfig.json",
    "content": "{}\n"
  },
  {
    "path": "packages/package/test/fixtures/assets/package.json",
    "content": "{\n\t\"name\": \"assets\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"no tampering assets\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/assets/svelte.config.js",
    "content": "export default {};\n"
  },
  {
    "path": "packages/package/test/fixtures/emitTypes-false/expected/Test.svelte",
    "content": "<script>\n\timport { createEventDispatcher } from 'svelte';\n\t/**\n\t * @type {string}\n\t */\n\texport const astring = 'potato';\n\n\tconst dispatch = createEventDispatcher();\n\tdispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/emitTypes-false/expected/Test2.svelte",
    "content": "<script>\n\t/**\n\t * @type {import('./foo').Foo}\n\t */\n\texport let foo;\n</script>\n"
  },
  {
    "path": "packages/package/test/fixtures/emitTypes-false/expected/foo.d.ts",
    "content": "export type Foo = boolean;\n"
  },
  {
    "path": "packages/package/test/fixtures/emitTypes-false/expected/index.js",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/emitTypes-false/package.json",
    "content": "{\n\t\"name\": \"emit-types\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"emitTypes settings disabled\",\n\t\"type\": \"module\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/emitTypes-false/src/lib/Test.svelte",
    "content": "<script>\n\timport { createEventDispatcher } from 'svelte';\n\t/**\n\t * @type {string}\n\t */\n\texport const astring = 'potato';\n\n\tconst dispatch = createEventDispatcher();\n\tdispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/emitTypes-false/src/lib/Test2.svelte",
    "content": "<script>\n\t/**\n\t * @type {import('./foo').Foo}\n\t */\n\texport let foo;\n</script>\n"
  },
  {
    "path": "packages/package/test/fixtures/emitTypes-false/src/lib/foo.d.ts",
    "content": "export type Foo = boolean;\n"
  },
  {
    "path": "packages/package/test/fixtures/emitTypes-false/src/lib/index.js",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/emitTypes-false/svelte.config.js",
    "content": "const config = {};\n\nexport default config;\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/ReadMe.md",
    "content": "Hello\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/Test.svelte",
    "content": "<script>\n\timport { createEventDispatcher } from 'svelte';\n\t/**\n\t * @type {string}\n\t */\n\texport const astring = 'potato';\n\n\tconst dispatch = createEventDispatcher();\n\tdispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/Test.svelte.d.ts",
    "content": "export default Test;\ntype Test = SvelteComponent<$$__sveltets_2_PropsWithChildren<{\n    astring?: string;\n}, {\n    default: {\n        astring: string;\n    };\n}>, {\n    event: CustomEvent<any>;\n} & {\n    [evt: string]: CustomEvent<any>;\n}, {\n    default: {\n        astring: string;\n    };\n}> & {\n    $$bindings?: string;\n} & {\n    astring: string;\n};\ndeclare const Test: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{\n    astring?: string;\n}, {\n    default: {\n        astring: string;\n    };\n}>, {\n    event: CustomEvent<any>;\n} & {\n    [evt: string]: CustomEvent<any>;\n}, {\n    default: {\n        astring: string;\n    };\n}, {\n    astring: string;\n}, string>;\ntype $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {\n    default: any;\n} ? Props extends Record<string, never> ? any : {\n    children?: any;\n} : {});\ninterface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n    new (options: import(\"svelte\").ComponentConstructorOptions<Props>): import(\"svelte\").SvelteComponent<Props, Events, Slots> & {\n        $$bindings?: Bindings;\n    } & Exports;\n    (internal: unknown, props: Props & {\n        $$events?: Events;\n        $$slots?: Slots;\n    }): Exports & {\n        $set?: any;\n        $on?: any;\n    };\n    z_$$bindings?: Bindings;\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/Test2.svelte",
    "content": "<script>\n\t/**\n\t * @type {import('./foo').Foo}\n\t */\n\texport let foo;\n</script>\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/Test2.svelte.d.ts",
    "content": "export default Test2;\ntype Test2 = SvelteComponent<{\n    foo: boolean;\n}, {\n    [evt: string]: CustomEvent<any>;\n}, {}> & {\n    $$bindings?: string;\n};\ndeclare const Test2: $$__sveltets_2_IsomorphicComponent<{\n    foo: import(\"./foo\").Foo;\n}, {\n    [evt: string]: CustomEvent<any>;\n}, {}, {}, string>;\ninterface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n    new (options: import(\"svelte\").ComponentConstructorOptions<Props>): import(\"svelte\").SvelteComponent<Props, Events, Slots> & {\n        $$bindings?: Bindings;\n    } & Exports;\n    (internal: unknown, props: Props & {\n        $$events?: Events;\n        $$slots?: Slots;\n    }): Exports & {\n        $set?: any;\n        $on?: any;\n    };\n    z_$$bindings?: Bindings;\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/foo.d.ts",
    "content": "export type Foo = boolean;\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/index.d.ts",
    "content": "export { default as Test } from './Test.svelte';\nexport { default as Internal } from './internal/Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/index.js",
    "content": "export { default as Test } from './Test.svelte';\nexport { default as Internal } from './internal/Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/internal/Test.svelte",
    "content": "<script>\n\t/**\n\t * @type {import('./foo').Foo}\n\t */\n\texport let foo;\n</script>\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/internal/Test.svelte.d.ts",
    "content": "export default Test;\ntype Test = SvelteComponent<{\n    foo: boolean;\n}, {\n    [evt: string]: CustomEvent<any>;\n}, {}> & {\n    $$bindings?: string;\n};\ndeclare const Test: $$__sveltets_2_IsomorphicComponent<{\n    foo: import(\"./foo\").Foo;\n}, {\n    [evt: string]: CustomEvent<any>;\n}, {}, {}, string>;\ninterface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n    new (options: import(\"svelte\").ComponentConstructorOptions<Props>): import(\"svelte\").SvelteComponent<Props, Events, Slots> & {\n        $$bindings?: Bindings;\n    } & Exports;\n    (internal: unknown, props: Props & {\n        $$events?: Events;\n        $$slots?: Slots;\n    }): Exports & {\n        $set?: any;\n        $on?: any;\n    };\n    z_$$bindings?: Bindings;\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/internal/foo.d.ts",
    "content": "export type Foo = boolean;\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/internal/index.d.ts",
    "content": "export const foo: 'bar';\nexport { x } from \"./runes.svelte.js\";\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/internal/index.js",
    "content": "export const foo = 'bar';\nexport { x } from './runes.svelte.js';\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/internal/runes.svelte.d.ts",
    "content": "export const x: true;\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/internal/runes.svelte.js",
    "content": "export const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/utils.d.ts",
    "content": ""
  },
  {
    "path": "packages/package/test/fixtures/javascript/expected/utils.js",
    "content": ""
  },
  {
    "path": "packages/package/test/fixtures/javascript/jsconfig.json",
    "content": "{}\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/package.json",
    "content": "{\n\t\"name\": \"javascript\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"standard javascript package\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/src/lib/Test.svelte",
    "content": "<script>\n\timport { createEventDispatcher } from 'svelte';\n\t/**\n\t * @type {string}\n\t */\n\texport const astring = 'potato';\n\n\tconst dispatch = createEventDispatcher();\n\tdispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/src/lib/Test2.svelte",
    "content": "<script>\n\t/**\n\t * @type {import('./foo').Foo}\n\t */\n\texport let foo;\n</script>\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/src/lib/foo.d.ts",
    "content": "export type Foo = boolean;\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/src/lib/index.js",
    "content": "export { default as Test } from './Test.svelte';\nexport { default as Internal } from './internal/Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/src/lib/internal/Test.svelte",
    "content": "<script>\n\t/**\n\t * @type {import('./foo').Foo}\n\t */\n\texport let foo;\n</script>\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/src/lib/internal/foo.d.ts",
    "content": "export type Foo = boolean;\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/src/lib/internal/index.js",
    "content": "export const foo = 'bar';\nexport { x } from './runes.svelte.js';\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/src/lib/internal/runes.svelte.js",
    "content": "export const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/javascript/src/lib/utils.js",
    "content": ""
  },
  {
    "path": "packages/package/test/fixtures/javascript/svelte.config.js",
    "content": "export default {};\n"
  },
  {
    "path": "packages/package/test/fixtures/preserve-output/expected/assets/theme.css",
    "content": ":root { color: red }"
  },
  {
    "path": "packages/package/test/fixtures/preserve-output/expected/index.d.ts",
    "content": "export declare const foo = 'bar';\n"
  },
  {
    "path": "packages/package/test/fixtures/preserve-output/expected/index.js",
    "content": "export const foo = 'bar';\n"
  },
  {
    "path": "packages/package/test/fixtures/preserve-output/package.json",
    "content": "{\n\t\"name\": \"preserve-output\",\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"description\": \"with additional things running before svelte-package\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t},\n\t\t\"./theme.css\": \"./dist/assets/theme.css\"\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/preserve-output/src/lib/index.ts",
    "content": "export const foo = 'bar';\n"
  },
  {
    "path": "packages/package/test/fixtures/preserve-output/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ESNext\"\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-3-types/expected/Test.svelte",
    "content": "<script lang=\"ts\">\nimport { createEventDispatcher } from 'svelte';\nexport const astring = 'potato';\nconst dispatch = createEventDispatcher();\ndispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-3-types/expected/Test.svelte.d.ts",
    "content": "import { SvelteComponentTyped } from 'svelte';\ndeclare const __propDef: {\n\tprops: {\n\t\tastring?: string;\n\t};\n\tevents: {\n\t\tevent: CustomEvent<boolean>;\n\t} & {\n\t\t[evt: string]: CustomEvent<any>;\n\t};\n\tslots: {\n\t\tdefault: {\n\t\t\tastring: string;\n\t\t};\n\t};\n};\nexport type TestProps = typeof __propDef.props;\nexport type TestEvents = typeof __propDef.events;\nexport type TestSlots = typeof __propDef.slots;\nexport default class Test extends SvelteComponentTyped<TestProps, TestEvents, TestSlots> {\n\tget astring(): string;\n}\nexport {};\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-3-types/expected/index.d.ts",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-3-types/expected/index.js",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-3-types/package.json",
    "content": "{\n\t\"name\": \"svelte-3-types\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"creates Svelte 3 backwards compatible types\",\n\t\"type\": \"module\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^3.0.0 || ^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-3-types/src/lib/Test.svelte",
    "content": "<script lang=\"ts\">\n\timport { createEventDispatcher } from 'svelte';\n\texport const astring: string = 'potato';\n\n\tconst dispatch = createEventDispatcher<{ event: boolean }>();\n\tdispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-3-types/src/lib/index.ts",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-3-types/svelte.config.js",
    "content": "import preprocess from 'svelte-preprocess';\n\nexport default {\n\tpreprocess: preprocess()\n};\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-3-types/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ESNext\",\n\t\t\"module\": \"ESNext\",\n\t\t\"verbatimModuleSyntax\": true\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/expected/Test.svelte",
    "content": "<script>\n\timport { createEventDispatcher } from 'svelte';\n\t/**\n\t * @type {string}\n\t */\n\texport const astring = 'potato';\n\n\tconst dispatch = createEventDispatcher();\n\tdispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/expected/Test.svelte.d.ts",
    "content": "export default Test;\ntype Test = SvelteComponent<$$__sveltets_2_PropsWithChildren<{\n    astring?: string;\n}, {\n    default: {\n        astring: string;\n    };\n}>, {\n    event: CustomEvent<any>;\n} & {\n    [evt: string]: CustomEvent<any>;\n}, {\n    default: {\n        astring: string;\n    };\n}> & {\n    $$bindings?: string;\n} & {\n    astring: string;\n};\ndeclare const Test: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{\n    astring?: string;\n}, {\n    default: {\n        astring: string;\n    };\n}>, {\n    event: CustomEvent<any>;\n} & {\n    [evt: string]: CustomEvent<any>;\n}, {\n    default: {\n        astring: string;\n    };\n}, {\n    astring: string;\n}, string>;\ntype $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {\n    default: any;\n} ? Props extends Record<string, never> ? any : {\n    children?: any;\n} : {});\ninterface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n    new (options: import(\"svelte\").ComponentConstructorOptions<Props>): import(\"svelte\").SvelteComponent<Props, Events, Slots> & {\n        $$bindings?: Bindings;\n    } & Exports;\n    (internal: unknown, props: Props & {\n        $$events?: Events;\n        $$slots?: Slots;\n    }): Exports & {\n        $set?: any;\n        $on?: any;\n    };\n    z_$$bindings?: Bindings;\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/expected/foo.d.ts",
    "content": "export type Foo = boolean;\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/expected/index.d.ts",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/expected/index.js",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/jsconfig.json",
    "content": "{}\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/package.json",
    "content": "{\n\t\"name\": \"svelte-kit\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"type\": \"module\",\n\t\"description\": \"SvelteKit library project\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/src/kitlib/Test.svelte",
    "content": "<script>\n\timport { createEventDispatcher } from 'svelte';\n\t/**\n\t * @type {string}\n\t */\n\texport const astring = 'potato';\n\n\tconst dispatch = createEventDispatcher();\n\tdispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/src/kitlib/foo.d.ts",
    "content": "export type Foo = boolean;\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/src/kitlib/index.js",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/svelte-kit/svelte.config.js",
    "content": "export default {\n\tkit: {\n\t\tfiles: {\n\t\t\tlib: 'src/kitlib'\n\t\t}\n\t}\n};\n"
  },
  {
    "path": "packages/package/test/fixtures/tsconfig-specified/expected/runes.svelte.d.ts",
    "content": "export declare const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/tsconfig-specified/expected/runes.svelte.js",
    "content": "export const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/tsconfig-specified/package.json",
    "content": "{\n\t\"name\": \"typescript\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"typescript package using esnext\",\n\t\"type\": \"module\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/tsconfig-specified/src/lib/runes.svelte.ts",
    "content": "// a comment to delete\nexport const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/tsconfig-specified/svelte.config.js",
    "content": "import preprocess from 'svelte-preprocess';\n\nexport default {\n\tpreprocess: preprocess()\n};\n"
  },
  {
    "path": "packages/package/test/fixtures/tsconfig-specified/tsconfig.build.json",
    "content": "{\n\t\"extends\": \"./tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"removeComments\": true\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/tsconfig-specified/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ESNext\",\n\t\t\"module\": \"ESNext\",\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-declaration-map/expected/Test.svelte",
    "content": "<script lang=\"ts\">\n\tlet { foo } = $props();\n</script>\n\n{foo}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-declaration-map/expected/Test.svelte.d.ts",
    "content": "type $$ComponentProps = {\n  foo: string;\n};\ndeclare const Test: import(\"svelte\").Component<$$ComponentProps, {}, \"\">;\ntype Test = ReturnType<typeof Test>;\nexport default Test\n//# sourceMappingURL=Test.svelte.d.ts.map"
  },
  {
    "path": "packages/package/test/fixtures/typescript-declaration-map/expected/index.d.ts",
    "content": "export { default as Test } from './Test.svelte';\n//# sourceMappingURL=index.d.ts.map"
  },
  {
    "path": "packages/package/test/fixtures/typescript-declaration-map/expected/index.js",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-declaration-map/package.json",
    "content": "{\n\t\"name\": \"typescript-declaration-map\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"standard typescript package with declarationMap:true\",\n\t\"type\": \"module\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^5.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-declaration-map/src/lib/Test.svelte",
    "content": "<script lang=\"ts\">\n\tlet { foo }: { foo: string } = $props();\n</script>\n\n{foo}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-declaration-map/src/lib/index.ts",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-declaration-map/svelte.config.js",
    "content": "import preprocess from 'svelte-preprocess';\n\nexport default {\n\tpreprocess: preprocess()\n};\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-declaration-map/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ESNext\",\n\t\t\"module\": \"ESNext\",\n\t\t\"declaration\": true,\n\t\t\"declarationMap\": true\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/Plain.svelte",
    "content": "<script>\n\t/** @type {import('./foo').Foo} */\n\texport let foo;\n</script>\n\n<svelte:head>\n  <script type=\"application/ld+json\">\n\t\t{\n\t\t\t\"@context\": \"http://schema.org\",\n\t\t\t\"@type\": \"Corporation\",\n\t\t\t\"name\": \"Svelte Corp\",\n\t\t\t\"description\": \"Svelte will cybernetically enhance you\",\n\t\t\t\"naics\": \"523910\",\n\t\t\t\"url\": \"https://svelte.dev\"\n\t\t}\n\t</script>\n</svelte:head>\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/Plain.svelte.d.ts",
    "content": "export default Plain;\ntype Plain = SvelteComponent<{\n    foo: boolean;\n}, {\n    [evt: string]: CustomEvent<any>;\n}, {}> & {\n    $$bindings?: string;\n};\ndeclare const Plain: $$__sveltets_2_IsomorphicComponent<{\n    foo: import(\"./foo\").Foo;\n}, {\n    [evt: string]: CustomEvent<any>;\n}, {}, {}, string>;\ninterface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n    new (options: import(\"svelte\").ComponentConstructorOptions<Props>): import(\"svelte\").SvelteComponent<Props, Events, Slots> & {\n        $$bindings?: Bindings;\n    } & Exports;\n    (internal: unknown, props: Props & {\n        $$events?: Events;\n        $$slots?: Slots;\n    }): Exports & {\n        $set?: any;\n        $on?: any;\n    };\n    z_$$bindings?: Bindings;\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/Test.svelte",
    "content": "<script lang=\"ts\">\nimport { createEventDispatcher } from 'svelte';\nexport const astring = 'potato';\nconst dispatch = createEventDispatcher();\ndispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/Test.svelte.d.ts",
    "content": "interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n\tnew (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {\n\t\t\t$$bindings?: Bindings;\n\t} & Exports;\n\t(internal: unknown, props: Props & {\n\t\t\t$$events?: Events;\n\t\t\t$$slots?: Slots;\n\t}): Exports & {\n\t\t\t$set?: any;\n\t\t\t$on?: any;\n\t};\n\tz_$$bindings?: Bindings;\n}\ntype $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {\n\tdefault: any;\n} ? Props extends Record<string, never> ? any : {\n\tchildren?: any;\n} : {});\ndeclare const Test: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{\n\tastring?: string;\n}, {\n\tdefault: {\n\t\t\tastring: string;\n\t};\n}>, {\n\tevent: CustomEvent<boolean>;\n} & {\n\t[evt: string]: CustomEvent<any>;\n}, {\n\tdefault: {\n\t\t\tastring: string;\n\t};\n}, {\n\tastring: string;\n}, string>;\ntype Test = InstanceType<typeof Test>;\nexport default Test;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/Test2.svelte",
    "content": "<script lang=\"ts\">\n\texport let foo;\n</script>\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/Test2.svelte.d.ts",
    "content": "import type { Foo } from './foo';\ninterface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n    new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {\n        $$bindings?: Bindings;\n    } & Exports;\n    (internal: unknown, props: Props & {\n        $$events?: Events;\n        $$slots?: Slots;\n    }): Exports & {\n        $set?: any;\n        $on?: any;\n    };\n    z_$$bindings?: Bindings;\n}\ndeclare const Test2: $$__sveltets_2_IsomorphicComponent<{\n    foo: Foo;\n}, {\n    [evt: string]: CustomEvent<any>;\n}, {}, {}, string>;\ntype Test2 = InstanceType<typeof Test2>;\nexport default Test2;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/foo.d.ts",
    "content": "export type Foo = boolean;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/index.d.ts",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/index.js",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/runes.svelte.d.ts",
    "content": "export declare const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/runes.svelte.js",
    "content": "export const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/utils.d.ts",
    "content": ""
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/expected/utils.js",
    "content": ""
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/package.json",
    "content": "{\n\t\"name\": \"typescript\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"typescript package using esnext\",\n\t\"type\": \"module\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/src/lib/Plain.svelte",
    "content": "<script>\n\t/** @type {import('./foo').Foo} */\n\texport let foo;\n</script>\n\n<svelte:head>\n\t<script type=\"application/ld+json\">\n\t\t{\n\t\t\t\"@context\": \"http://schema.org\",\n\t\t\t\"@type\": \"Corporation\",\n\t\t\t\"name\": \"Svelte Corp\",\n\t\t\t\"description\": \"Svelte will cybernetically enhance you\",\n\t\t\t\"naics\": \"523910\",\n\t\t\t\"url\": \"https://svelte.dev\"\n\t\t}\n\t</script>\n</svelte:head>\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/src/lib/Test.svelte",
    "content": "<script lang=\"ts\">\n\timport { createEventDispatcher } from 'svelte';\n\texport const astring: string = 'potato';\n\n\tconst dispatch = createEventDispatcher<{ event: boolean }>();\n\tdispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/src/lib/Test2.svelte",
    "content": "<script lang=\"ts\">\n\timport type { Foo } from './foo';\n\texport let foo: Foo;\n</script>\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/src/lib/foo.d.ts",
    "content": "export type Foo = boolean;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/src/lib/index.ts",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/src/lib/runes.svelte.ts",
    "content": "export const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/src/lib/utils.ts",
    "content": ""
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/svelte.config.js",
    "content": "import preprocess from 'svelte-preprocess';\n\nexport default {\n\tpreprocess: preprocess()\n};\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-esnext/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ESNext\",\n\t\t\"module\": \"ESNext\",\n\t\t\"verbatimModuleSyntax\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/expected/Test.svelte",
    "content": "<script lang=\"ts\">\nimport { createEventDispatcher } from 'svelte';\nexport const astring = 'potato';\nconst dispatch = createEventDispatcher();\ndispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/expected/Test.svelte.d.ts",
    "content": "interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n\tnew (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {\n\t\t\t$$bindings?: Bindings;\n\t} & Exports;\n\t(internal: unknown, props: Props & {\n\t\t\t$$events?: Events;\n\t\t\t$$slots?: Slots;\n\t}): Exports & {\n\t\t\t$set?: any;\n\t\t\t$on?: any;\n\t};\n\tz_$$bindings?: Bindings;\n}\ntype $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {\n\tdefault: any;\n} ? Props extends Record<string, never> ? any : {\n\tchildren?: any;\n} : {});\ndeclare const Test: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{\n\tastring?: string;\n}, {\n\tdefault: {\n\t\t\tastring: string;\n\t};\n}>, {\n\tevent: CustomEvent<boolean>;\n} & {\n\t[evt: string]: CustomEvent<any>;\n}, {\n\tdefault: {\n\t\t\tastring: string;\n\t};\n}, {\n\tastring: string;\n}, string>;\ntype Test = InstanceType<typeof Test>;\nexport default Test;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/expected/index.d.ts",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/expected/index.js",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/expected/runes.svelte.d.ts",
    "content": "export declare const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/expected/runes.svelte.js",
    "content": "export const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/package.json",
    "content": "{\n\t\"name\": \"typescript-nodenext\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"typescript package using nodenext\",\n\t\"type\": \"module\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/src/lib/Test.svelte",
    "content": "<script lang=\"ts\">\n\timport { createEventDispatcher } from 'svelte';\n\texport const astring: string = 'potato';\n\n\tconst dispatch = createEventDispatcher<{ event: boolean }>();\n\tdispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/src/lib/index.ts",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/src/lib/runes.svelte.ts",
    "content": "export const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/svelte.config.js",
    "content": "import preprocess from 'svelte-preprocess';\n\nexport default {\n\tpreprocess: preprocess({})\n};\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-nodenext/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ESNext\",\n\t\t\"module\": \"NodeNext\",\n\t\t\"verbatimModuleSyntax\": true,\n\t\t\"moduleResolution\": \"NodeNext\",\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/expected/Test.svelte",
    "content": "<script lang=\"ts\">\nimport { createEventDispatcher } from 'svelte';\nexport const astring = 'potato';\nconst dispatch = createEventDispatcher();\ndispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/expected/Test.svelte.d.ts",
    "content": "interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n\tnew (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {\n\t\t\t$$bindings?: Bindings;\n\t} & Exports;\n\t(internal: unknown, props: Props & {\n\t\t\t$$events?: Events;\n\t\t\t$$slots?: Slots;\n\t}): Exports & {\n\t\t\t$set?: any;\n\t\t\t$on?: any;\n\t};\n\tz_$$bindings?: Bindings;\n}\ntype $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {\n\tdefault: any;\n} ? Props extends Record<string, never> ? any : {\n\tchildren?: any;\n} : {});\ndeclare const Test: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{\n\tastring?: string;\n}, {\n\tdefault: {\n\t\t\tastring: string;\n\t};\n}>, {\n\tevent: CustomEvent<boolean>;\n} & {\n\t[evt: string]: CustomEvent<any>;\n}, {\n\tdefault: {\n\t\t\tastring: string;\n\t};\n}, {\n\tastring: string;\n}, string>;\ntype Test = InstanceType<typeof Test>;\nexport default Test;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/expected/index.d.ts",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/expected/index.js",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/expected/runes.svelte.d.ts",
    "content": "export declare const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/expected/runes.svelte.js",
    "content": "export const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/package.json",
    "content": "{\n\t\"name\": \"typescript-nodenext\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"typescript package using nodenext\",\n\t\"type\": \"module\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/src/lib/Test.svelte",
    "content": "<script lang=\"ts\">\n\timport { createEventDispatcher } from 'svelte';\n\texport const astring: string = 'potato';\n\n\tconst dispatch = createEventDispatcher<{ event: boolean }>();\n\tdispatch('event', true);\n</script>\n\n<slot {astring} />\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/src/lib/index.ts",
    "content": "export { default as Test } from './Test.svelte';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/src/lib/runes.svelte.ts",
    "content": "export const x = true;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/svelte.config.ts",
    "content": "import preprocess from 'svelte-preprocess';\n\nexport default {\n\t// @ts-ignore\n\tpreprocess: preprocess({})\n};\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-svelte-config/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ESNext\",\n\t\t\"module\": \"NodeNext\",\n\t\t\"verbatimModuleSyntax\": true,\n\t\t\"moduleResolution\": \"NodeNext\"\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/expected/Demo.svelte",
    "content": "<script lang=\"ts\">import { helper } from './helper.js';\n\timport { helper2 } from './helper2.js';\n</script>\n\n{helper()}{helper2()}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/expected/Demo.svelte.d.ts",
    "content": "interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n    new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {\n        $$bindings?: Bindings;\n    } & Exports;\n    (internal: unknown, props: {\n        $$events?: Events;\n        $$slots?: Slots;\n    }): Exports & {\n        $set?: any;\n        $on?: any;\n    };\n    z_$$bindings?: Bindings;\n}\ndeclare const Demo: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {\n    [evt: string]: CustomEvent<any>;\n}, {}, {}, string>;\ntype Demo = InstanceType<typeof Demo>;\nexport default Demo;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/expected/helper.d.ts",
    "content": "export declare const helper: () => string;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/expected/helper.js",
    "content": "export const helper = () => '';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/expected/helper2.d.ts",
    "content": "export declare const helper2: () => string;\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/expected/helper2.js",
    "content": "export const helper2 = () => '';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/expected/index.d.ts",
    "content": "import { helper } from \"./helper.ts\";\nimport { helper2 } from \"./helper2.ts\";\nexport { helper, helper2 };\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/expected/index.js",
    "content": "import { helper } from \"./helper.js\";\nimport { helper2 } from \"./helper2.js\";\nexport { helper, helper2 };\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/package.json",
    "content": "{\n\t\"name\": \"typescript-ts-extension-rewrites\",\n\t\"private\": true,\n\t\"version\": \"1.0.0\",\n\t\"description\": \"typescript package with extension rewrites, including to aliased import paths\",\n\t\"type\": \"module\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^5.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/src/lib/Demo.svelte",
    "content": "<script lang=\"ts\">\n\timport { helper } from '$lib/helper.ts';\n\timport { helper2 } from './helper2.ts';\n</script>\n\n{helper()}{helper2()}\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/src/lib/helper.ts",
    "content": "export const helper = () => '';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/src/lib/helper2.ts",
    "content": "export const helper2 = () => '';\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/src/lib/index.ts",
    "content": "import { helper } from '$lib/helper.ts';\nimport { helper2 } from './helper2.ts';\nexport { helper, helper2 };\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/svelte.config.js",
    "content": "export default {};\n"
  },
  {
    "path": "packages/package/test/fixtures/typescript-ts-extension-rewrites/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ESNext\",\n\t\t\"module\": \"ESNext\",\n\t\t\"allowImportingTsExtensions\": true,\n\t\t\"rewriteRelativeImportExtensions\": true\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/index.spec.js",
    "content": "import fs from 'node:fs';\nimport process from 'node:process';\nimport { join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport prettier from 'prettier';\nimport { test, expect } from 'vitest';\n\nimport { build, watch } from '../src/index.js';\nimport { load_config } from '../src/config.js';\nimport { rimraf, walk } from '../src/filesystem.js';\nimport { _create_validator } from '../src/validate.js';\nimport { resolve_aliases } from '../src/utils.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = join(__filename, '..');\n\n/**\n * @param {string} path\n * @param {Partial<import('../src/types.js').Options>} [options]\n */\nasync function test_make_package(path, options) {\n\tconst cwd = join(__dirname, 'fixtures', path);\n\tconst ewd = join(cwd, 'expected');\n\tconst output = join(cwd, 'dist');\n\n\tconst config = await load_config({ cwd });\n\n\tconst input = resolve(cwd, config.kit?.files?.lib ?? 'src/lib');\n\n\tawait build({\n\t\tcwd,\n\t\tinput,\n\t\toutput,\n\t\tpreserve_output: false,\n\t\ttypes: true,\n\t\tconfig,\n\t\t...options\n\t});\n\n\tconst expected_files = walk(ewd, true);\n\tconst actual_files = walk(output, true);\n\n\texpect(actual_files).toEqual(expected_files);\n\n\tconst extensions = ['.json', '.svelte', '.ts', 'js', '.map'];\n\tfor (const file of actual_files) {\n\t\tconst pathname = join(output, file);\n\t\tif (fs.statSync(pathname).isDirectory()) continue;\n\t\texpect(expected_files.includes(file), `Did not expect ${file} in ${path}`).toBeTruthy();\n\n\t\tconst expected = fs.readFileSync(join(ewd, file));\n\t\tconst actual = fs.readFileSync(join(output, file));\n\t\tconst err_msg = `Expected equal file contents for ${file} in ${path}`;\n\n\t\tif (extensions.some((ext) => pathname.endsWith(ext))) {\n\t\t\tconst expected_content = await format(file, expected.toString('utf-8'));\n\t\t\tconst actual_content = await format(file, actual.toString('utf-8'));\n\t\t\texpect(actual_content, err_msg).toBe(expected_content);\n\t\t} else {\n\t\t\texpect(expected.equals(actual)).toBeTruthy();\n\t\t}\n\t}\n}\n\n/**\n * Format with Prettier in order to get expected and actual content aligned\n * @param {string} file\n * @param {string} content\n */\nasync function format(file, content) {\n\tif (file.endsWith('.map')) {\n\t\treturn content;\n\t}\n\n\tif (file.endsWith('package.json')) {\n\t\t// For some reason these are ordered differently in different test environments\n\t\tconst json = JSON.parse(content);\n\t\tjson.exports = Object.entries(json.exports).sort(([ak], [bk]) => ak.localeCompare(bk));\n\t\tcontent = JSON.stringify(json);\n\t}\n\treturn await prettier.format(content, {\n\t\tparser: file.endsWith('.svelte') ? 'svelte' : file.endsWith('.json') ? 'json' : 'typescript',\n\t\tplugins: ['prettier-plugin-svelte']\n\t});\n}\n\nfor (const dir of fs.readdirSync(join(__dirname, 'errors'))) {\n\ttest(`package error [${dir}]`, async () => {\n\t\tconst cwd = join(__dirname, 'errors', dir);\n\t\tconst output = join(cwd, 'dist');\n\n\t\tconst config = await load_config({ cwd });\n\n\t\tconst input = resolve(cwd, config.kit?.files?.lib ?? 'src/lib');\n\n\t\ttry {\n\t\t\tawait build({ cwd, input, output, types: true, config, preserve_output: false });\n\t\t\tthrow new Error('Must not pass build');\n\t\t} catch (/** @type {any} */ error) {\n\t\t\texpect(error).toBeInstanceOf(Error);\n\t\t\tswitch (dir) {\n\t\t\t\tcase 'no-lib-folder':\n\t\t\t\t\texpect(error.message.replace(/\\\\/g, '/')).toMatch(\n\t\t\t\t\t\t'test/errors/no-lib-folder/src/lib does not exist'\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t// TODO: non-existent tsconfig passes without error\n\t\t\t\t// \tit detects tsconfig in packages/kit instead and creates package folder\n\t\t\t\t// \tin packages/kit/package, not sure how to handle and test this yet\n\t\t\t\t// case 'no-tsconfig':\n\t\t\t\t// \texpect(error.message).toMatch('Failed to locate tsconfig or jsconfig');\n\t\t\t\t// \tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error('All error test must be handled', { cause: error });\n\t\t\t}\n\t\t} finally {\n\t\t\trimraf(output);\n\t\t}\n\t});\n}\n\ntest('create package with javascript', async () => {\n\t// should also preserve filename casing\n\t// should also correctly handle nested folders\n\tawait test_make_package('javascript');\n});\n\ntest('create package with typescript using esnext', async () => {\n\tawait test_make_package('typescript-esnext');\n});\n\ntest('create package with typescript using nodenext', async () => {\n\tawait test_make_package('typescript-nodenext');\n});\n\ntest('create package with .ts extension rewrites, including for aliases', async () => {\n\tawait test_make_package('typescript-ts-extension-rewrites');\n});\n\n// only run this test in newer Node versions\n// TODO: remove after dropping support for Node < 22.18\nconst [major, minor] = process.versions.node.split('.', 2).map((str) => +str);\nconst has_ts_support = major > 22 || (major === 22 && minor >= 18);\n\nif (has_ts_support) {\n\ttest('create package with typescript using nodenext and svelte.config.ts', async () => {\n\t\tawait test_make_package('typescript-svelte-config');\n\t});\n}\n\ntest('create package and assets are not tampered', async () => {\n\tawait test_make_package('assets');\n});\n\ntest('create package with emitTypes settings disabled', async () => {\n\tawait test_make_package('emitTypes-false', { types: false });\n});\n\ntest('create package with SvelteComponentTyped for backwards compatibility', async () => {\n\tawait test_make_package('svelte-3-types');\n});\n\ntest('SvelteKit interop', async () => {\n\tawait test_make_package('svelte-kit');\n});\n\ntest('create package with declaration map', async () => {\n\tawait test_make_package('typescript-declaration-map');\n});\n\ntest('create package with tsconfig specified', async () => {\n\tawait test_make_package('tsconfig-specified', { tsconfig: 'tsconfig.build.json' });\n});\n\n// chokidar doesn't fire events in github actions :shrug:\nif (!process.env.CI) {\n\ttest('watches for changes', async () => {\n\t\tconst cwd = join(__dirname, 'watch');\n\n\t\tconst config = await load_config({ cwd });\n\n\t\tconst { watcher, ready, settled } = await watch({\n\t\t\tcwd,\n\t\t\tinput: 'src/lib',\n\t\t\toutput: 'package',\n\t\t\tpreserve_output: false,\n\t\t\ttypes: true,\n\t\t\tconfig\n\t\t});\n\n\t\t/** @param {string} file */\n\t\tfunction compare(file) {\n\t\t\texpect(read(`package/${file}`)).toEqual(read(`expected/${file}`));\n\t\t}\n\n\t\t/** @param {string} file */\n\t\tfunction read(file) {\n\t\t\treturn fs.readFileSync(join(__dirname, 'watch', file), 'utf-8');\n\t\t}\n\n\t\t/**\n\t\t * @param {string} file\n\t\t * @param {string} data\n\t\t */\n\t\tfunction write(file, data) {\n\t\t\treturn fs.writeFileSync(join(__dirname, 'watch', file), data);\n\t\t}\n\n\t\t/** @param {string} file */\n\t\tfunction remove(file) {\n\t\t\tconst filepath = join(__dirname, 'watch', file);\n\t\t\tif (fs.existsSync(filepath)) fs.unlinkSync(filepath);\n\t\t}\n\n\t\ttry {\n\t\t\tawait ready;\n\n\t\t\t// completes initial build\n\t\t\tcompare('index.js');\n\n\t\t\t// processes a .js file\n\t\t\twrite('src/lib/a.js', \"export const a = 'a';\");\n\t\t\tawait settled();\n\t\t\tcompare('a.js');\n\t\t\tcompare('a.d.ts');\n\n\t\t\t// processes a .ts file\n\t\t\twrite('src/lib/b.ts', \"export const b = 'b';\");\n\t\t\tawait settled();\n\t\t\tcompare('b.js');\n\t\t\tcompare('b.d.ts');\n\n\t\t\t// processes a Svelte file\n\t\t\twrite('src/lib/Test.svelte', '<script lang=\"ts\">export let answer: number</script>');\n\t\t\tawait settled();\n\t\t\tcompare('Test.svelte');\n\t\t\tcompare('Test.svelte.d.ts');\n\n\t\t\t// doesn't crash on an error\n\t\t\twrite('src/lib/post-error.svelte', '<button on:={foo}>click me</button>');\n\t\t\tawait settled();\n\n\t\t\t// recovers on subsequent change\n\t\t\twrite('src/lib/post-error.svelte', '<button on:click={foo}>click me</button>');\n\t\t\tawait settled();\n\t\t\tcompare('post-error.svelte');\n\t\t} finally {\n\t\t\tawait watcher.close();\n\n\t\t\tremove('src/lib/Test.svelte');\n\t\t\tremove('src/lib/a.js');\n\t\t\tremove('src/lib/b.ts');\n\t\t\tremove('src/lib/post-error.svelte');\n\t\t}\n\t}, 30_000);\n}\n\n/**\n * @param {string[]} actual\n * @param {string[]} expected\n */\nfunction has_warnings(actual, expected) {\n\texpect(actual.length).toEqual(expected.length);\n\texpect(\n\t\tactual.filter((warning) => expected.some((str) => warning.startsWith(str))).length\n\t).toEqual(expected.length);\n}\n\ntest('validates package (1)', () => {\n\tconst { analyse_code, validate } = _create_validator({\n\t\tconfig: {},\n\t\tcwd: '',\n\t\tinput: '',\n\t\toutput: '',\n\t\tpreserve_output: false,\n\t\ttypes: true\n\t});\n\tanalyse_code('src/lib/index.js', 'export const a = 1;import.meta.env;');\n\tanalyse_code('src/lib/C.svelte', '');\n\tconst warnings = validate({});\n\n\thas_warnings(warnings, [\n\t\t'No `exports` field found in `package.json`, please provide one.',\n\t\t'Avoid usage of `import.meta.env` in your code',\n\t\t'You are using Svelte components or Svelte-specific imports in your code, but you have not declared a dependency on `svelte` in your `package.json`. '\n\t]);\n});\n\ntest('validates package (2)', () => {\n\tconst { analyse_code, validate } = _create_validator({\n\t\tconfig: {},\n\t\tcwd: '',\n\t\tinput: '',\n\t\toutput: '',\n\t\tpreserve_output: false,\n\t\ttypes: true\n\t});\n\tanalyse_code('src/lib/C.svelte', '');\n\tconst warnings = validate({\n\t\texports: { '.': './dist/C.svelte' },\n\t\tpeerDependencies: { svelte: '^3.55.0' }\n\t});\n\n\thas_warnings(warnings, [\n\t\t'You are using Svelte files, but did not declare a `svelte` condition in one of your `exports` in your `package.json`. '\n\t]);\n});\n\ntest('validates package (all ok 1)', () => {\n\tconst { analyse_code, validate } = _create_validator({\n\t\tconfig: {},\n\t\tcwd: '',\n\t\tinput: '',\n\t\toutput: '',\n\t\tpreserve_output: false,\n\t\ttypes: true\n\t});\n\tanalyse_code('src/lib/C.svelte', '');\n\tconst warnings = validate({\n\t\texports: { '.': { svelte: './dist/C.svelte' } },\n\t\tpeerDependencies: { svelte: '^3.55.0' }\n\t});\n\n\texpect(warnings.length).toEqual(0);\n});\n\ntest('validates package (all ok 2)', () => {\n\tconst { analyse_code, validate } = _create_validator({\n\t\tconfig: {},\n\t\tcwd: '',\n\t\tinput: '',\n\t\toutput: '',\n\t\tpreserve_output: false,\n\t\ttypes: true\n\t});\n\tanalyse_code('src/lib/C.svelte', '');\n\tconst warnings = validate({\n\t\texports: { '.': { svelte: './dist/C.svelte' } },\n\t\tpeerDependencies: { svelte: '^3.55.0' },\n\t\tsvelte: './dist/C.svelte'\n\t});\n\n\texpect(warnings.length).toEqual(0);\n});\n\ntest('create package with preserved output', async () => {\n\tconst output = join(__dirname, 'fixtures', 'preserve-output', 'dist');\n\trimraf(output);\n\tfs.mkdirSync(join(output, 'assets'), { recursive: true });\n\tfs.writeFileSync(join(output, 'assets', 'theme.css'), ':root { color: red }');\n\tawait test_make_package('preserve-output', { preserve_output: true });\n});\n\ntest('resolves aliases correctly', () => {\n\tconst input = '/project/src/lib';\n\tconst file = 'components/Button.svelte';\n\tconst alias = { $lib: '/project/src/lib/components', '@/': '/project/src/' };\n\n\t// Test all static import variants\n\tconst source = `\n// Static imports\nimport Button from '$lib/Button.svelte';\nimport { named } from '$lib/utils.js';\nimport { named1, named2 } from '$lib/utils.js';\nimport defaultExport, { named } from '$lib/utils.js';\nimport * as All from '$lib/utils.js';\nimport { foo } from '@/foo.js';\n\n// Import types\nimport type { TypedInterface } from '$lib/types.js';\nimport type DefaultType from '$lib/types.js';\nimport type DefaultType, { TypedInterface } from '$lib/types.js';\nimport { type TypedInterface } from '$lib/types.js';\nimport defaultExport, { type TypedInterface } from '$lib/types.js';\n\n// Export re-exports\nexport { reexported } from '$lib/utils.js';\nexport { reexported1, reexported2 } from '$lib/utils.js';\nexport * from '$lib/utils.js';\nexport * as NamedExport from '$lib/utils.js';\nexport type { TypeExport } from '$lib/types.js';\n\n// Side-effect imports\nimport '$lib/styles.css';\nimport '$lib/polyfill.js';\n\n// Dynamic imports\nconst dynamicImport = import('$lib/dynamic.js');\nconst dynamicWithAwait = await import('$lib/async.js');\nconst dynamicInFunction = () => import('$lib/function.js');\n\n// False positives that should NOT be replaced\nconst notAnImport = \"This string contains $lib/fake.js but is not an import\";\nconst inString = 'The path $lib/fake.js should not be changed';\nconst invalidSyntax = 'import $lib/invalid without quotes';\nconst partialMatch = '$library/notmatching.js';\nimport * as AllWithDefault, { named } from '$lib/utils.js';\n\n// Edge cases with whitespace and formatting\nimport  Button2  from  '$lib/Button2.svelte';\nimport{named3}from'$lib/utils2.js';\nimport(  '$lib/dynamic2.js'  );\n`;\n\n\tconst expectedResolved = `\n// Static imports\nimport Button from './Button.svelte';\nimport { named } from './utils.js';\nimport { named1, named2 } from './utils.js';\nimport defaultExport, { named } from './utils.js';\nimport * as All from './utils.js';\nimport { foo } from '../../foo.js';\n\n// Import types\nimport type { TypedInterface } from './types.js';\nimport type DefaultType from './types.js';\nimport type DefaultType, { TypedInterface } from './types.js';\nimport { type TypedInterface } from './types.js';\nimport defaultExport, { type TypedInterface } from './types.js';\n\n// Export re-exports\nexport { reexported } from './utils.js';\nexport { reexported1, reexported2 } from './utils.js';\nexport * from './utils.js';\nexport * as NamedExport from './utils.js';\nexport type { TypeExport } from './types.js';\n\n// Side-effect imports\nimport './styles.css';\nimport './polyfill.js';\n\n// Dynamic imports\nconst dynamicImport = import('./dynamic.js');\nconst dynamicWithAwait = await import('./async.js');\nconst dynamicInFunction = () => import('./function.js');\n\n// False positives that should NOT be replaced\nconst notAnImport = \"This string contains $lib/fake.js but is not an import\";\nconst inString = 'The path $lib/fake.js should not be changed';\nconst invalidSyntax = 'import $lib/invalid without quotes';\nconst partialMatch = '$library/notmatching.js';\nimport * as AllWithDefault, { named } from '$lib/utils.js';\n\n// Edge cases with whitespace and formatting\nimport  Button2  from  './Button2.svelte';\nimport{named3}from'./utils2.js';\nimport(  './dynamic2.js'  );\n`;\n\n\tconst resolved = resolve_aliases(input, file, source, alias);\n\texpect(resolved.trim()).toBe(expectedResolved.trim());\n});\n"
  },
  {
    "path": "packages/package/test/watch/expected/Test.svelte",
    "content": "<script lang=\"ts\">export let answer: number</script>"
  },
  {
    "path": "packages/package/test/watch/expected/Test.svelte.d.ts",
    "content": "interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {\n    new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {\n        $$bindings?: Bindings;\n    } & Exports;\n    (internal: unknown, props: Props & {\n        $$events?: Events;\n        $$slots?: Slots;\n    }): Exports & {\n        $set?: any;\n        $on?: any;\n    };\n    z_$$bindings?: Bindings;\n}\ndeclare const Test: $$__sveltets_2_IsomorphicComponent<{\n    answer: number;\n}, {\n    [evt: string]: CustomEvent<any>;\n}, {}, {}, string>;\ntype Test = InstanceType<typeof Test>;\nexport default Test;\n"
  },
  {
    "path": "packages/package/test/watch/expected/a.d.ts",
    "content": "export const a: \"a\";\n"
  },
  {
    "path": "packages/package/test/watch/expected/a.js",
    "content": "export const a = 'a';"
  },
  {
    "path": "packages/package/test/watch/expected/b.d.ts",
    "content": "export declare const b = \"b\";\n"
  },
  {
    "path": "packages/package/test/watch/expected/b.js",
    "content": "export const b = 'b';\n"
  },
  {
    "path": "packages/package/test/watch/expected/index.js",
    "content": "console.log('index.js');\n"
  },
  {
    "path": "packages/package/test/watch/expected/package.json",
    "content": "{\n  \"type\": \"module\",\n  \"exports\": {\n    \"./package.json\": \"./package.json\",\n    \"./Test.svelte\": \"./Test.svelte\",\n    \".\": \"./index.js\"\n  },\n  \"svelte\": \"./index.js\"\n}"
  },
  {
    "path": "packages/package/test/watch/expected/post-error.svelte",
    "content": "<button on:click={foo}>click me</button>"
  },
  {
    "path": "packages/package/test/watch/package.json",
    "content": "{\n\t\"name\": \"watch\",\n\t\"type\": \"module\",\n\t\"peerDependencies\": {\n\t\t\"svelte\": \"^4.0.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "packages/package/test/watch/src/lib/index.js",
    "content": "console.log('index.js');\n"
  },
  {
    "path": "packages/package/test/watch/svelte.config.js",
    "content": "export default {};\n"
  },
  {
    "path": "packages/package/test/watch/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"target\": \"ESNext\",\n\t\t\"module\": \"ESNext\",\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"newLine\": \"lf\"\n\t}\n}\n"
  },
  {
    "path": "packages/package/tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"strict\": true,\n\t\t\"target\": \"es2022\",\n\t\t\"module\": \"node16\",\n\t\t\"moduleResolution\": \"node16\",\n\t\t\"allowSyntheticDefaultImports\": true\n\t},\n\t\"include\": [\"*.js\", \"src/**/*\", \"test/index.spec.js\"]\n}\n"
  },
  {
    "path": "packages/test-redirect-importer/index.js",
    "content": "import { redirect } from '@sveltejs/kit';\n\n// This exists to check that an external package importing `redirect`\n// will get something that satisfies the relevant `instanceof` checks\n\n/**\n * @param {string} redirectUrl\n * @returns {never}\n */\nexport function authenticate(redirectUrl) {\n\tredirect(302, redirectUrl);\n}\n"
  },
  {
    "path": "packages/test-redirect-importer/package.json",
    "content": "{\n\t\"name\": \"test-redirect-importer\",\n\t\"version\": \"0.0.1\",\n\t\"private\": true,\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": \"./index.js\"\n\t},\n\t\"dependencies\": {\n\t\t\"@sveltejs/kit\": \"workspace:*\"\n\t}\n}\n"
  },
  {
    "path": "playgrounds/README.md",
    "content": "You may use these playgrounds to experiment with your changes to SvelteKit. Make sure you don't check in any changes to the files in `src` that aren't already gitignored. The easiest way to do this is to run the following from the root of the project:\n\n```bash\ngit update-index --skip-worktree playgrounds/basic/src/routes/+layout.svelte\ngit update-index --skip-worktree playgrounds/basic/src/routes/+page.svelte\n```\n\nAlternatively, clone the [kit-sandbox](https://github.com/sveltejs/kit-sandbox) repo next to the `kit` repo, and use `pnpm link` to link your dependencies. This way you can have multiple different sandbox projects in different branches, and you never need to worry about accidentally committing throwaway code.\n"
  },
  {
    "path": "playgrounds/basic/.gitignore",
    "content": "# these are already ignored by the top level .gitignore\n# repeating them here as a faux .prettierignore\n/.svelte-kit/\n/dist/\n/build\n/src/lib\n/src/routes\n"
  },
  {
    "path": "playgrounds/basic/package.json",
    "content": "{\n\t\"name\": \"playground-basic\",\n\t\"version\": \"0.0.0\",\n\t\"private\": true,\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"build\": \"vite build\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"package\": \"svelte-kit sync && svelte-package && publint\",\n\t\t\"prepare\": \"svelte-kit sync\",\n\t\t\"prepublishOnly\": \"npm run package\",\n\t\t\"check\": \"svelte-kit sync && svelte-check\",\n\t\t\"check:watch\": \"svelte-kit sync && svelte-check --watch\",\n\t\t\"format\": \"prettier --config ../../.prettierrc --write .\",\n\t\t\"lint\": \"prettier --config ../../.prettierrc --check .\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@sveltejs/adapter-auto\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-cloudflare\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-netlify\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-node\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-static\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-vercel\": \"workspace:*\",\n\t\t\"@sveltejs/amp\": \"workspace:*\",\n\t\t\"@sveltejs/enhanced-img\": \"workspace:*\",\n\t\t\"@sveltejs/kit\": \"workspace:*\",\n\t\t\"@sveltejs/package\": \"workspace:*\",\n\t\t\"@sveltejs/vite-plugin-svelte\": \"catalog:\",\n\t\t\"prettier\": \"catalog:\",\n\t\t\"prettier-plugin-svelte\": \"catalog:\",\n\t\t\"publint\": \"catalog:\",\n\t\t\"svelte\": \"catalog:\",\n\t\t\"svelte-check\": \"catalog:\",\n\t\t\"typescript\": \"^5.5.0\",\n\t\t\"valibot\": \"catalog:\",\n\t\t\"vite\": \"catalog:\"\n\t},\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"svelte\": \"./dist/index.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"!dist/**/*.test.*\",\n\t\t\"!dist/**/*.spec.*\"\n\t],\n\t\"svelte\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.ts\"\n}\n"
  },
  {
    "path": "playgrounds/basic/src/app.d.ts",
    "content": "// See https://svelte.dev/docs/kit/types#app.d.ts\n// for information about these interfaces\ndeclare global {\n\tnamespace App {\n\t\t// interface Error {}\n\t\t// interface Locals {}\n\t\t// interface PageData {}\n\t\t// interface Platform {}\n\t}\n}\n\nexport {};\n"
  },
  {
    "path": "playgrounds/basic/src/app.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<link rel=\"icon\" href=\"%sveltekit.assets%/favicon.png\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t%sveltekit.head%\n\t</head>\n\t<body data-sveltekit-preload-data=\"hover\">\n\t\t<div style=\"display: contents\">%sveltekit.body%</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "playgrounds/basic/src/lib/index.js",
    "content": "// place files you want to import through the `$lib` alias in this folder.\n"
  },
  {
    "path": "playgrounds/basic/src/routes/+layout.svelte",
    "content": "<script>\n\tlet { children } = $props();\n</script>\n\n{@render children()}\n"
  },
  {
    "path": "playgrounds/basic/src/routes/+page.svelte",
    "content": "<script lang=\"ts\">\n</script>\n\n<h1>hello!</h1>\n"
  },
  {
    "path": "playgrounds/basic/svelte.config.js",
    "content": "import adapter from '@sveltejs/adapter-node';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tcompilerOptions: {\n\t\texperimental: {\n\t\t\tasync: true\n\t\t}\n\t},\n\n\tkit: {\n\t\tadapter: adapter(),\n\t\texperimental: {\n\t\t\tremoteFunctions: true\n\t\t}\n\t}\n};\n\nexport default config;\n"
  },
  {
    "path": "playgrounds/basic/tsconfig.json",
    "content": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true\n\t}\n\t// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias and https://svelte.dev/docs/kit/configuration#files\n\t//\n\t// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes\n\t// from the referenced tsconfig.json - TypeScript does not merge them in\n}\n"
  },
  {
    "path": "playgrounds/basic/vite.config.js",
    "content": "import { enhancedImages } from '@sveltejs/enhanced-img';\nimport { sveltekit } from '@sveltejs/kit/vite';\n\nexport default {\n\tplugins: [enhancedImages(), sveltekit()],\n\tserver: {\n\t\tfs: {\n\t\t\tallow: ['../../packages/kit']\n\t\t}\n\t}\n};\n"
  },
  {
    "path": "pnpm-workspace.yaml",
    "content": "packages:\n  - packages/*\n  - packages/adapter-cloudflare/test/apps/*\n  - packages/adapter-netlify/test/apps/*\n  - packages/adapter-vercel/test/apps/*\n  - packages/adapter-static/test/apps/*\n  - packages/enhanced-img/test/apps/*\n  - packages/kit/test/apps/*\n  - packages/kit/test/prerendering/*\n  - packages/kit/test/build-errors/**\n  - packages/kit/test/build-errors/apps/*\n  - '!.test-tmp/**'\n  - playgrounds/*\n# pnpm catalogs are currently only suitable for dependencies that\n# wouldn't require publishing a new package version\n# see https://github.com/changesets/changesets/issues/1707\ncatalog:\n  '@changesets/cli': ^2.29.6\n  '@fontsource/libre-barcode-128-text': ^5.1.0\n  '@netlify/dev': ^4.11.2\n  '@netlify/edge-functions': ^3.0.0\n  '@netlify/functions': ^5.0.0\n  '@opentelemetry/sdk-node': ^0.213.0\n  '@opentelemetry/sdk-trace-node': ^2.0.1\n  '@playwright/test': 1.58.2\n  '@polka/url': ^1.0.0-next.28\n  '@rollup/plugin-commonjs': ^29.0.0\n  '@rollup/plugin-json': ^6.1.0\n  '@rollup/plugin-node-resolve': ^16.0.0\n  '@sveltejs/eslint-config': ^9.0.0\n  '@sveltejs/vite-plugin-svelte': ^6.0.0-next.3\n  '@svitejs/changesets-changelog-github-compact': ^1.2.0\n  '@types/connect': ^3.4.38\n  '@types/estree': ^1.0.5\n  '@types/node': ^18.19.119\n  '@types/semver': ^7.5.6\n  '@types/set-cookie-parser': ^2.4.7\n  '@vitest/browser-playwright': ^4.0.0\n  dropcss: ^1.0.16\n  dts-buddy: ^0.7.0\n  esbuild: ^0.25.4\n  eslint: ^10.0.0\n  polka: ^1.0.0-next.28\n  publint: ^0.3.0\n  prettier: ^3.8.1\n  prettier-plugin-svelte: ^3.5.1\n  semver: ^7.5.4\n  sirv-cli: ^3.0.0\n  svelte: ^5.53.12\n  svelte-check: ^4.4.1\n  svelte-preprocess: ^6.0.0\n  valibot: ^1.1.0\n  vite: ^6.3.5\n  vitest: ^4.0.0\n  wrangler: ^4.14.3\ncatalogs:\n  vite-baseline:\n    vite: ^5.4.21 # should be 5.0.3 but older versions cause errors in some tests\n    '@sveltejs/vite-plugin-svelte': ^4.0.0\n    'vitest>vite': ^6.0.0 # vitest@4 doesn't work with vite@5, vite@7 doesn't work on node18\n  vite-beta:\n    vite: ^8.0.0-beta.18\n    '@sveltejs/vite-plugin-svelte': ^7.0.0-next.0\n  node-18:\n    vite: ^6.0.0 # vite7 requires node20\n    '@sveltejs/vite-plugin-svelte': ^5.0.0 #vps6 requires node20\noverrides:\n# ci script replaces all overrides with the vite-xxx or node-xx catalogs above.\n# if you want to introduce an override, make sure to add it to all of them too\n"
  },
  {
    "path": "renovate.json",
    "content": "{\n\t\"extends\": [\n\t\t\"config:recommended\",\n\t\t\":preserveSemverRanges\",\n\t\t\"group:allNonMajor\",\n\t\t\":semanticCommitTypeAll(chore)\"\n\t],\n\t\"pin\": {\n\t\t\"enabled\": false\n\t},\n\t\"ignoreDeps\": [\"@types/node\", \"cookie\", \"esbuild\", \"rollup\", \"typescript\"],\n\t\"packageRules\": [\n\t\t{\n\t\t\t\"matchPackageNames\": [\"vite\"],\n\t\t\t\"matchUpdateTypes\": [\"major\"],\n\t\t\t\"enabled\": false\n\t\t}\n\t]\n}\n"
  },
  {
    "path": "scripts/check-dependencies.js",
    "content": "import { execSync } from 'node:child_process';\n\nconst output = execSync('pnpm list --recursive --depth Infinity --json', {\n\tencoding: 'utf8',\n\tmaxBuffer: 100 * 1024 * 1024\n});\n\nconst packages = JSON.parse(output);\n\nconst deps = new Map();\n\nfunction get_or_default(map, key, constructor) {\n\tlet current = map.get(key);\n\tif (!current) {\n\t\tmap.set(key, (current = new constructor()));\n\t}\n\treturn current;\n}\n\nfunction add_deps(parent, dependencies, is_dev) {\n\tfor (const [name, { version }] of Object.entries(dependencies)) {\n\t\tif (version.startsWith('link:')) continue;\n\t\tconst versions = get_or_default(deps, name, Map);\n\t\tconst parents = get_or_default(versions, version, Set);\n\t\tparents.add(parent + (is_dev ? ':dev' : ''));\n\t}\n}\n\nfor (const pkg of packages) {\n\tif (pkg.dependencies) add_deps(pkg.name, pkg.dependencies);\n\tif (pkg.devDependencies) add_deps(pkg.name, pkg.devDependencies, 'dev');\n}\n\nconst duplicates = new Map([...deps].filter(([, versions]) => versions.size > 1));\nconsole.log(duplicates);\n"
  },
  {
    "path": "scripts/print-flaky-test-report.js",
    "content": "// pnpm captures stdout and prefixes it with the package name which breaks the annotations\n// so save it in a file and print it out at the end\n// ideally we'd just use cat, but that doesn't work on Windows hence this script\n\nimport { existsSync, createReadStream, unlinkSync } from 'node:fs';\nconst filename = '_tmp_flaky_test_output.txt';\n\nif (existsSync(filename)) {\n\tcreateReadStream(filename)\n\t\t.on('end', () => {\n\t\t\tprocess.stdout.write('\\n');\n\t\t\tunlinkSync(filename);\n\t\t})\n\t\t.pipe(process.stdout);\n}\n"
  },
  {
    "path": "scripts/sync-all.js",
    "content": "import fs from 'node:fs';\nimport path from 'node:path';\nimport { load_config } from '../packages/kit/src/core/config/index.js';\n\n// This isn't strictly necessary, but it eliminates some annoying warnings in CI\n\nfor (const directories of [\n\t'packages/kit/test/apps',\n\t'packages/kit/test/build-errors/apps',\n\t'packages/kit/test/prerendering'\n].map((dir) => path.resolve(dir))) {\n\tfor (const dir of fs.readdirSync(directories)) {\n\t\tconst cwd = path.join(directories, dir);\n\n\t\tif (!fs.existsSync(path.join(cwd,'svelte.config.js'))) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tprocess.chdir(cwd);\n\n\t\t// we defer this import so that we don't try and resolve `svelte` from\n\t\t// the root via `isSvelte5Plus`, which would blow up\n\t\tconst sync = await import('../packages/kit/src/core/sync/sync.js');\n\t\tawait sync.all(await load_config({ cwd }), 'development');\n\t}\n}\n"
  },
  {
    "path": "test-utils/index.js",
    "content": "/**\n * read process.env[name] and convert to number\n *\n * @param {string} name of process.env value to read\n * @param {number|undefined} default_value\n * @return {number|undefined} number or default_value if process.env[name] isn't set\n * @throws {Error} when value cannot be parsed to number\n */\nexport function number_from_env(name, default_value) {\n\tconst val = process.env[name];\n\tif(val!= null) {\n\t\tconst num = Number(val);\n\t\tif(isNaN(num)){\n\t\t\tthrow new Error(`process.env.${name} must be parsable to a number but is \"${val}\"`);\n\t\t}\n\t\treturn num;\n\t}\n\treturn default_value\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"checkJs\": true,\n\t\t\"noEmit\": true,\n\t\t\"module\": \"ESNext\",\n\t\t\"target\": \"ESNext\",\n\t\t\"moduleResolution\": \"bundler\"\n\t},\n\t\"include\": [\"eslint.config.js\", \".eslint/*.js\"]\n}\n"
  }
]