Repository: mateothegreat/svelte5-router Branch: main Commit: 371538eb962e Files: 159 Total size: 815.7 KB Directory structure: gitextract_rt2wkk2r/ ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.md │ │ └── feature_request.md │ ├── dependabot.yml │ └── workflows/ │ ├── demo.yaml │ ├── docs.yaml │ ├── release.yaml │ ├── setup.yaml │ └── test.yaml ├── LICENSE ├── demo/ │ ├── cypress/ │ │ ├── e2e/ │ │ │ └── route-activation.cy.ts │ │ ├── fixtures/ │ │ │ └── routes.json │ │ └── support/ │ │ ├── commands.ts │ │ └── e2e.ts │ ├── cypress.config.ts │ ├── index.html │ ├── package.json │ ├── src/ │ │ ├── app.css │ │ ├── app.svelte │ │ ├── lib/ │ │ │ ├── components/ │ │ │ │ ├── badge.svelte │ │ │ │ ├── code.svelte │ │ │ │ ├── container.svelte │ │ │ │ ├── default.svelte │ │ │ │ ├── file-link.svelte │ │ │ │ ├── inline-code.svelte │ │ │ │ └── routes/ │ │ │ │ ├── route-link.svelte │ │ │ │ ├── route-title.svelte │ │ │ │ └── route-wrapper.svelte │ │ │ ├── default-route-config.ts │ │ │ ├── router-history.ts │ │ │ └── session.svelte.ts │ │ ├── main.ts │ │ ├── routes/ │ │ │ ├── delayed.svelte │ │ │ ├── extras/ │ │ │ │ ├── dump.svelte │ │ │ │ ├── extras.svelte │ │ │ │ └── passing-down-props.svelte │ │ │ ├── hash/ │ │ │ │ └── hash.svelte │ │ │ ├── home.svelte │ │ │ ├── nested/ │ │ │ │ ├── level-1/ │ │ │ │ │ ├── level-1.svelte │ │ │ │ │ └── level-2/ │ │ │ │ │ ├── level-2.svelte │ │ │ │ │ └── level-3/ │ │ │ │ │ └── level-3.svelte │ │ │ │ └── nested.svelte │ │ │ ├── not-found.svelte │ │ │ ├── paths-and-params/ │ │ │ │ ├── custom-not-found.svelte │ │ │ │ ├── display-params.svelte │ │ │ │ ├── paths-and-params.svelte │ │ │ │ └── querystring-matching.svelte │ │ │ ├── patterns/ │ │ │ │ ├── dump.svelte │ │ │ │ ├── output.svelte │ │ │ │ ├── parameter-extraction.svelte │ │ │ │ └── patterns.svelte │ │ │ ├── protected/ │ │ │ │ ├── account-state.svelte.ts │ │ │ │ ├── denied.svelte │ │ │ │ ├── login.svelte │ │ │ │ ├── main.svelte │ │ │ │ └── manage-account/ │ │ │ │ ├── auth-guard-fast.ts │ │ │ │ ├── auth-guard-slow.ts │ │ │ │ ├── balance.svelte │ │ │ │ ├── home.svelte │ │ │ │ ├── manage-account.svelte │ │ │ │ └── worker-client.svelte.ts │ │ │ └── transitions/ │ │ │ ├── fade.svelte │ │ │ ├── slide.svelte │ │ │ └── transitions.svelte │ │ └── vite-env.d.ts │ ├── svelte.config.js │ ├── tailwind.config.ts │ ├── tsconfig.deployed.json │ ├── tsconfig.json │ ├── vercel.json │ └── vite.config.ts ├── docs/ │ ├── CNAME │ ├── actions.md │ ├── assets/ │ │ └── coverage.json │ ├── changelog.md │ ├── cliff.toml │ ├── debugging.md │ ├── diagrams/ │ │ ├── component-hierarchy.mmd │ │ ├── route-evaluations.mmd │ │ ├── router-architecture.mmd │ │ └── routing-lifecycle.mmd │ ├── diagrams.md │ ├── getting-started.md │ ├── helpers.md │ ├── hooks.md │ ├── llms.txt │ ├── makefile │ ├── package.json │ ├── props.md │ ├── puppeteer.config.cjs │ ├── readme.md │ ├── registry.md │ ├── routing-patterns.md │ ├── routing.md │ ├── statuses.md │ ├── styling.md │ ├── tsconfig.json │ └── typedoc.json ├── llms.txt ├── makefile ├── package.json ├── src/ │ ├── lib/ │ │ ├── actions/ │ │ │ ├── active.svelte.ts │ │ │ ├── apply-classes.ts │ │ │ ├── index.ts │ │ │ ├── options.ts │ │ │ └── route.svelte.ts │ │ ├── hash.test.ts │ │ ├── hash.ts │ │ ├── helpers/ │ │ │ ├── evaluators.test.ts │ │ │ ├── evaluators.ts │ │ │ ├── goto.ts │ │ │ ├── identify.ts │ │ │ ├── index.ts │ │ │ ├── logging.ts │ │ │ ├── marshal.test.ts │ │ │ ├── marshal.ts │ │ │ ├── normalize.ts │ │ │ ├── objects.ts │ │ │ ├── pop.ts │ │ │ ├── query.ts │ │ │ ├── regexp.ts │ │ │ ├── replace.ts │ │ │ ├── runtime.ts │ │ │ ├── tracing.svelte.ts │ │ │ ├── urls.test.ts │ │ │ └── urls.ts │ │ ├── hooks.ts │ │ ├── index.ts │ │ ├── path.ts │ │ ├── query.svelte.ts │ │ ├── query.test.ts │ │ ├── registry.svelte.ts │ │ ├── route.svelte.ts │ │ ├── router-instance-config.ts │ │ ├── router-instance.svelte.ts │ │ ├── router-integration.test.ts │ │ ├── router-patterns-demo.test.ts │ │ ├── router-remount.test.ts │ │ ├── router.svelte │ │ ├── statuses.ts │ │ └── utilities.svelte.ts │ └── vite-env.d.ts ├── svelte.config.js ├── test/ │ └── app/ │ ├── LICENSE │ ├── index.html │ ├── package.json │ ├── readme.md │ ├── src/ │ │ ├── app.css │ │ ├── app.svelte │ │ ├── main.ts │ │ └── routes/ │ │ ├── test-a/ │ │ │ └── test-a.svelte │ │ └── test-b/ │ │ └── test-b.svelte │ ├── svelte.config.ts │ ├── tsconfig.json │ └── vite.config.ts ├── tsconfig.build.json ├── tsconfig.json ├── vite.config.ts ├── vitest.config.ts └── vitest.setup.ts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: Bug report about: Create a report to help us improve title: '' labels: bug assignees: mateothegreat --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. See error **Expected behavior** A clear and concise description of what you expected to happen. **Logs** If available please provide any available logs, screenshots, etc. **Additional context** Add any other context about the problem here. ================================================ FILE: .github/ISSUE_TEMPLATE/feature_request.md ================================================ --- name: Feature request about: Suggest an idea for this project title: '' labels: enhancement assignees: mateothegreat --- **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd like** A clear and concise description of what you want to happen. **Additional context** Add any other context or screenshots about the feature request here. ================================================ FILE: .github/dependabot.yml ================================================ # To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file version: 2 updates: - package-ecosystem: "npm" # See documentation for possible values directory: "/" # Location of package manifests schedule: interval: "daily" ================================================ FILE: .github/workflows/demo.yaml ================================================ name: 📱 Demo on: workflow_dispatch: workflow_call: secrets: VERCEL_TOKEN: required: true concurrency: group: demo cancel-in-progress: true jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: install vercel run: npm install --global vercel@latest - name: vercel pull run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} - name: vercel build run: vercel build --local-config demo/vercel.json --prod --token=${{ secrets.VERCEL_TOKEN }} - name: vercel deploy run: vercel deploy --local-config demo/vercel.json --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} ================================================ FILE: .github/workflows/docs.yaml ================================================ name: 📚 Docs on: workflow_dispatch: workflow_call: permissions: id-token: write pages: write defaults: run: shell: bash working-directory: ./docs jobs: setup: name: 🔧 Request uses: ./.github/workflows/setup.yaml build: name: "📚 Build Docs" needs: setup environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: # [setup] checkout the repo. - uses: actions/checkout@v5.0.0 with: fetch-depth: 0 persist-credentials: false # [setup] setup node.js. - name: Setup Node.js uses: actions/setup-node@v4.4.0 with: node-version: 20.x - name: 📊 Generate diagrams run: make diagrams - name: 📚 Build documentation run: npm run docs:build - name: 📤 Upload Pages artifact uses: actions/upload-pages-artifact@v3.0.1 with: path: tmp/build - id: deployment name: 📤 Deploy documentation to GitHub Pages uses: actions/deploy-pages@v4.0.5 # [setup] authenticate with the cicd app to get proper credentials for pushing to the repo later. - name: cicd app auth id: app uses: actions/create-github-app-token@v2.1.1 with: app-id: ${{ secrets.CICD_APP_ID }} private-key: ${{ secrets.CICD_APP_PRIVATE_KEY }} # [setup] configure git for later changelog generation, commit, and the finalpush. - name: 🔧 Commit and push diagrams run: | git config --global user.name "mateothegreat[bot]" git config --global user.email "mateothegreat[bot]@users.noreply.github.com" git remote set-url origin https://x-access-token:${{ steps.app.outputs.token }}@github.com/${{ github.repository }}.git git add . git commit -am "chore(docs): update diagrams" git push origin HEAD:main ================================================ FILE: .github/workflows/release.yaml ================================================ name: 🚀 Release run-name: 🚀 Release (${{ github.event.inputs.label }}) on: workflow_dispatch: inputs: label: description: "The label to add to the release" required: false default: "standard release" type: string build_docs: description: "Release the docs?" required: false default: false type: boolean build_demo: description: "Release the demo?" required: false default: false type: boolean concurrency: group: release cancel-in-progress: true jobs: release: name: 🚀 Release ${{ github.event.inputs.label }} runs-on: ubuntu-latest permissions: contents: write packages: write steps: # [setup] authenticate with the cicd app to get proper credentials for pushing to the repo later. - name: cicd app auth id: app uses: actions/create-github-app-token@v2.1.1 with: app-id: ${{ secrets.CICD_APP_ID }} private-key: ${{ secrets.CICD_APP_PRIVATE_KEY }} # [setup] checkout the repo. - uses: actions/checkout@v5.0.0 with: fetch-depth: 0 persist-credentials: false # [setup] setup node.js. - name: Setup Node.js uses: actions/setup-node@v4.4.0 with: node-version: 20.x # [setup] configure git for later changelog generation, commit, and the finalpush. - name: configure git run: | git config --global user.name "mateothegreat[bot]" git config --global user.email "mateothegreat[bot]@users.noreply.github.com" git remote set-url origin https://x-access-token:${{ steps.app.outputs.token }}@github.com/${{ github.repository }}.git # [build] install dependencies first. - name: install run: npm install # [build] build the package which outputs to the dist/ directory. - name: build run: npm run build # [version] bump the version - name: npm version id: version run: | version=$(npm version patch --no-git-tag-version --json | sed 's/^v//' || { echo "npm version patch failed, git is dirty" exit 1 }) echo "version=$version" >> "$GITHUB_OUTPUT" echo "version is now: $version" # [version] generate the new changelog. - name: generate changelog uses: orhun/git-cliff-action@98c93442bb05a455a77bee982867857ae748eeea id: git-cliff with: config: ./docs/cliff.toml args: --tag ${{ steps.version.outputs.version }} env: OUTPUT: docs/changelog.md # [version] commit the changelog and package.json. - name: commit run: | git add docs/changelog.md package.json git commit -am "chore(release): update of changelog and bumping package.json for ${{ steps.version.outputs.version }}" git push origin HEAD:main git tag -a ${{ steps.version.outputs.version }} -m "release: ${{ steps.version.outputs.version }}" git push origin ${{ steps.version.outputs.version }} # [publish] prepare to publish by setting up credentials. - name: write to .npmrc run: echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" > ~/.npmrc # [publish] release publicly only if the build was successful above. - name: publish working-directory: dist run: | cp ../package.json . npm publish --access public # [publish] create a github release. - name: create github release uses: softprops/action-gh-release@v2.3.2 with: body: ${{ steps.git-cliff.outputs.content }} tag_name: ${{ steps.version.outputs.version }} docs: if: ${{ github.event.inputs.build_docs == true }} needs: release permissions: id-token: write pages: write uses: ./.github/workflows/docs.yaml demo: if: ${{ github.event.inputs.build_demo == true }} needs: release uses: ./.github/workflows/demo.yaml secrets: inherit notify: if: always() continue-on-error: true needs: release runs-on: ubuntu-latest steps: - uses: Ilshidur/action-discord@ad5235de713df3ef38022185499b02ffe93b7efe with: status: ${{ needs.build.result }} webhook: ${{ secrets.DISCORD_WEBHOOK }} env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} ================================================ FILE: .github/workflows/setup.yaml ================================================ name: 🔧 Setup on: workflow_call: jobs: node: name: "Runtime" environment: name: dev runs-on: ubuntu-latest steps: - name: ⬇️ Check out repo uses: actions/checkout@v4 - name: ⎔ Setup node uses: actions/setup-node@v4 with: node-version-file: "package.json" cache: "npm" - name: 📦 Cache node_modules uses: actions/cache@v3 id: cache-node-modules with: path: node_modules key: ${{ hashFiles('package-lock.json') }} - name: 📦 Install dependencies if: steps.cache-node-modules.outputs.cache-hit != 'true' run: | npm ci --legacy-peer-deps ================================================ FILE: .github/workflows/test.yaml ================================================ name: ⚡ Test Runner on: workflow_dispatch: workflow_call: permissions: contents: write jobs: setup: name: "🔧 Setup" environment: name: dev runs-on: ubuntu-latest steps: - name: ⬇️ Check out repo uses: actions/checkout@v4 - name: ⎔ Setup node uses: actions/setup-node@v4 with: node-version-file: "package.json" cache: "npm" # cache-dependency-path: "package-lock.json" - name: 🧹 Clean install for cross-platform compatibility run: | npm ci --legacy-peer-deps test: name: 🏃 Test needs: setup environment: name: dev runs-on: ubuntu-latest steps: - name: ⬇️ Check out repo uses: actions/checkout@v4 - name: ⎔ Setup node (reuse cache from setup) uses: actions/setup-node@v4 with: node-version-file: "package.json" cache: "npm" - name: Hydrate npm module cache uses: actions/cache@v3 id: hydrate with: path: node_modules key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - name: Install dependencies if: steps.hydrate.outputs.cache-hit != 'true' run: npm ci --legacy-peer-deps - name: 🧪 Run Tests run: npm run test:ci - name: ⚙️ Generating coverage badges run: | npx --yes coverage-badges-cli \ --source tmp/coverage/coverage-summary.json \ --style plastic \ --type statements \ --iconWidth 190 \ --label "Test Coverage" \ --output docs/assets/coverage-badge.svg - name: ⬆️ Push badges branch run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" git add docs/assets/coverage-badge.svg git commit -m "chore: update coverage badge" git push ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2025 Matthew Davis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: demo/cypress/e2e/route-activation.cy.ts ================================================ /// const routes = require("../fixtures/routes.json"); describe.only("route activation", () => { beforeEach(() => { cy.viewport(1500, 1500); cy.visit("http://localhost:8173"); }); routes.forEach((route) => { it(`should activate ${route.id} when visiting ${route.path}`, () => { cy.clickAndValidateActiveClasses(`a[href='${route.path}']`, "active", route.active); }); }); // it.only("displays two todo items by default", () => { // // cy.get("a[href='/props']").should("have.length", 1).click(); // // cy.contains("props.svelte").should("exist"); // // cy.get("a[href='/props/foo']").should("have.length", 1).click(); // // cy.contains("display-params.svelte").should("exist"); // // cy.contains(`"child": "foo"`).should("exist"); // // cy.get("a").filter('[href^="/props/bar?"]').should("have.length", 1).click(); // // cy.contains("display-params.svelte").should("exist"); // // cy.contains(`"child": "bar"`).should("exist"); // // cy.get("a").filter('[href="/props/foo"]').should("not.have.class", "active"); // // cy.get("a").filter('[href^="/props/bar"]').should("have.class", "active"); // cy.clickAndValidateActiveClasses("a[href='/props']", "active"); // }); // it("can add new todo items", () => { // // We'll store our item text in a variable so we can reuse it // const newItem = "Feed the cat"; // // Let's get the input element and use the `type` command to // // input our new list item. After typing the content of our item, // // we need to type the enter key as well in order to submit the input. // // This input has a data-test attribute so we'll use that to select the // // element in accordance with best practices: // // https://on.cypress.io/selecting-elements // cy.get("[data-test=new-todo]").type(`${newItem}{enter}`); // // Now that we've typed our new item, let's check that it actually was added to the list. // // Since it's the newest item, it should exist as the last element in the list. // // In addition, with the two default items, we should have a total of 3 elements in the list. // // Since assertions yield the element that was asserted on, // // we can chain both of these assertions together into a single statement. // cy.get(".todo-list li") // .should("have.length", 3) // .last() // .should("have.text", newItem); // }); // it("can check off an item as completed", () => { // // In addition to using the `get` command to get an element by selector, // // we can also use the `contains` command to get an element by its contents. // // However, this will yield the