{"_id":"@push.rocks/smartrouter","_rev":"5-c81a71f6616d726412b8f770b68e8221","name":"@push.rocks/smartrouter","dist-tags":{"latest":"1.3.3"},"versions":{"1.0.16":{"name":"@push.rocks/smartrouter","version":"1.0.16","author":{"name":"Lossless GmbH"},"license":"MIT","_id":"@push.rocks/smartrouter@1.0.16","maintainers":[{"name":"lossless","email":"hello@lossless.com"}],"dist":{"shasum":"9e90112876380499abb730bac1e551d597861320","tarball":"https://registry.npmjs.org/@push.rocks/smartrouter/-/smartrouter-1.0.16.tgz","fileCount":21,"integrity":"sha512-GsEv6paOuIbC3vkIS5LxNroK68mNygB+oSDJRaUOE8/OCJLk0aPfI579nEiuXP/DkGjC1SjQ2bUWc3BTaUM3GQ==","signatures":[{"sig":"MEUCIBLinEh8JZWIKE0Dxn18YKg+OJbhPI8U1t+DfB0RILoXAiEAzDPjguHLSSlEg6GTVtL6uVsgIFQnUNC47A1+VlNV/eM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":64238},"main":"dist_ts/index.js","type":"module","private":false,"scripts":{"test":"(tstest test/)","build":"(tsbuild --web && tsbundle npm --web)","format":"(gitzone format)","buildDocs":"tsdoc"},"typings":"dist_ts/index.d.ts","_npmUser":{"name":"lossless","email":"hello@lossless.com"},"_npmVersion":"9.5.0","description":"a router for routing on websites","directories":{},"_nodeVersion":"18.14.2","browserslist":["last 1 chrome versions"],"dependencies":{"path-to-regexp":"^6.2.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"^18.15.3","@gitzone/tstest":"^1.0.60","@gitzone/tsbuild":"^2.1.29","@gitzone/tsbundle":"^2.0.7","@pushrocks/tapbundle":"^5.0.4"},"_npmOperationalInternal":{"tmp":"tmp/smartrouter_1.0.16_1689123706566_0.6565167290917187","host":"s3://npm-registry-packages"}},"1.2.1":{"name":"@push.rocks/smartrouter","version":"1.2.1","keywords":["web development","routing","single page application","URL management","path matching","query parameters","browser history"],"author":{"name":"Lossless GmbH"},"license":"MIT","_id":"@push.rocks/smartrouter@1.2.1","maintainers":[{"name":"lossless","email":"hello@lossless.com"}],"homepage":"https://code.foss.global/push.rocks/smartrouter","dist":{"shasum":"98f42399244143b63adfceff3e8b0f018f3ac2df","tarball":"https://registry.npmjs.org/@push.rocks/smartrouter/-/smartrouter-1.2.1.tgz","fileCount":22,"integrity":"sha512-noDMqDr3aa2ASqbZwdKQFvpeaBkGuCJjzFTVoW8duRehO2x6t6zfLw7syLBeFIeOKdjunXlM2Y9e6e8mgQGJCw==","signatures":[{"sig":"MEYCIQCvtpYwZVm5M0mLtMxzBYqt1RsAnQUYaeJkg/t07tzhcwIhAL1gvQ+zju718RH1HRV90s7koApvurhfxId3zkiwD2JY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":245985},"main":"dist_ts/index.js","type":"module","_from":"file:push.rocks-smartrouter-1.2.1.tgz","private":false,"scripts":{"test":"(tstest test/)","build":"(tsbuild --web && tsbundle npm --web)","format":"(gitzone format)","buildDocs":"tsdoc"},"typings":"dist_ts/index.d.ts","_npmUser":{"name":"lossless","email":"hello@lossless.com"},"_resolved":"/tmp/a8c8b1436291dfc7d34e01a02e20dab8/push.rocks-smartrouter-1.2.1.tgz","_integrity":"sha512-noDMqDr3aa2ASqbZwdKQFvpeaBkGuCJjzFTVoW8duRehO2x6t6zfLw7syLBeFIeOKdjunXlM2Y9e6e8mgQGJCw==","repository":{"url":"https://code.foss.global/push.rocks/smartrouter.git","type":"git"},"_npmVersion":"10.2.3","description":"A JavaScript library providing routing capabilities for web applications.","directories":{},"_nodeVersion":"21.2.0","browserslist":["last 1 chrome versions"],"dependencies":{"path-to-regexp":"^6.2.0","@push.rocks/lik":"^6.0.5","@push.rocks/smartrx":"^3.0.6"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"^20.6.0","@git.zone/tstest":"^1.0.81","@git.zone/tsbuild":"^2.1.70","@git.zone/tsbundle":"^2.0.7","@push.rocks/tapbundle":"^5.0.15"},"_npmOperationalInternal":{"tmp":"tmp/smartrouter_1.2.1_1728238708156_0.2921013897593645","host":"s3://npm-registry-packages"}},"1.3.0":{"name":"@push.rocks/smartrouter","version":"1.3.0","keywords":["web development","routing","single page application","URL management","path matching","query parameters","browser history"],"author":{"name":"Lossless GmbH"},"license":"MIT","_id":"@push.rocks/smartrouter@1.3.0","maintainers":[{"name":"lossless","email":"hello@lossless.com"}],"homepage":"https://code.foss.global/push.rocks/smartrouter","dist":{"shasum":"428c39421e56c3e27b18506b30085b98b323c210","tarball":"https://registry.npmjs.org/@push.rocks/smartrouter/-/smartrouter-1.3.0.tgz","fileCount":22,"integrity":"sha512-zKXcP3ij/n4sGrEQ1GGL7loC44D94AWWhKq4kzspVJtbw2VTjNnEAW3El7CRVClYeKgcV5Zdy9XzHGIxful6vQ==","signatures":[{"sig":"MEUCIQC5WLUVDAh85rCr5HDm/ahJwBXZIoCCffvPBo7m2u8VywIgYFDU74BB+ZXZa+koEwQcXipWpMXTL7GLWlCAHx+qUDw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":248081},"main":"dist_ts/index.js","type":"module","_from":"file:push.rocks-smartrouter-1.3.0.tgz","private":false,"scripts":{"test":"(tstest test/)","build":"(tsbuild --web && tsbundle npm --web)","format":"(gitzone format)","buildDocs":"tsdoc"},"typings":"dist_ts/index.d.ts","_npmUser":{"name":"lossless","email":"hello@lossless.com"},"_resolved":"/tmp/b54cc4fb8e46794bc85813f8336acf08/push.rocks-smartrouter-1.3.0.tgz","_integrity":"sha512-zKXcP3ij/n4sGrEQ1GGL7loC44D94AWWhKq4kzspVJtbw2VTjNnEAW3El7CRVClYeKgcV5Zdy9XzHGIxful6vQ==","repository":{"url":"https://code.foss.global/push.rocks/smartrouter.git","type":"git"},"_npmVersion":"10.2.3","description":"A JavaScript library providing routing capabilities for web applications.","directories":{},"_nodeVersion":"21.2.0","browserslist":["last 1 chrome versions"],"dependencies":{"path-to-regexp":"^6.2.0","@push.rocks/lik":"^6.0.5","@push.rocks/smartrx":"^3.0.6"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"^20.6.0","@git.zone/tstest":"^1.0.81","@git.zone/tsbuild":"^2.1.70","@git.zone/tsbundle":"^2.0.7","@push.rocks/tapbundle":"^5.0.15"},"_npmOperationalInternal":{"tmp":"tmp/smartrouter_1.3.0_1728246485228_0.2899810366438609","host":"s3://npm-registry-packages"}},"1.3.2":{"name":"@push.rocks/smartrouter","version":"1.3.2","keywords":["web development","routing","single page application","URL management","path matching","query parameters","browser history"],"author":{"name":"Lossless GmbH"},"license":"MIT","_id":"@push.rocks/smartrouter@1.3.2","maintainers":[{"name":"lossless","email":"hello@lossless.com"}],"homepage":"https://code.foss.global/push.rocks/smartrouter","dist":{"shasum":"e9700df2a8cd848ca36c9f368c7ff5b8775fd95e","tarball":"https://registry.npmjs.org/@push.rocks/smartrouter/-/smartrouter-1.3.2.tgz","fileCount":22,"integrity":"sha512-JtkxClN4CaHXMSeLDNvfWPwiVEPdEoQVSX2ee3gLgbXNO9dt9hvXdIhFrnFeLwyeA6M8nJdb9SqjrjZroYJsxw==","signatures":[{"sig":"MEYCIQCM1SAbUbXCCGkcCTpbBXD9t5ZBbSwB4jx90GlbHanmBwIhANR8IXC9Vv5zaCvo3HyBfi+bpipa2CDDzemso5BOWitI","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":258279},"main":"dist_ts/index.js","type":"module","_from":"file:push.rocks-smartrouter-1.3.2.tgz","private":false,"scripts":{"test":"(tstest test/)","build":"(tsbuild --web && tsbundle npm --web)","format":"(gitzone format)","buildDocs":"tsdoc"},"typings":"dist_ts/index.d.ts","_npmUser":{"name":"lossless","email":"hello@lossless.com"},"_resolved":"/tmp/d7977199db54d8fd7658420934812431/push.rocks-smartrouter-1.3.2.tgz","_integrity":"sha512-JtkxClN4CaHXMSeLDNvfWPwiVEPdEoQVSX2ee3gLgbXNO9dt9hvXdIhFrnFeLwyeA6M8nJdb9SqjrjZroYJsxw==","repository":{"url":"https://code.foss.global/push.rocks/smartrouter.git","type":"git"},"_npmVersion":"10.2.3","description":"A JavaScript library providing routing capabilities for web applications.","directories":{},"_nodeVersion":"21.2.0","browserslist":["last 1 chrome versions"],"dependencies":{"path-to-regexp":"^8.2.0","@push.rocks/lik":"^6.0.15","@push.rocks/smartrx":"^3.0.7"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"^22.7.4","@git.zone/tstest":"^1.0.90","@git.zone/tsbuild":"^2.1.84","@git.zone/tsbundle":"^2.0.15","@push.rocks/tapbundle":"^5.3.0"},"_npmOperationalInternal":{"tmp":"tmp/smartrouter_1.3.2_1728247157212_0.6084118952228181","host":"s3://npm-registry-packages"}},"1.3.3":{"name":"@push.rocks/smartrouter","version":"1.3.3","private":false,"description":"A JavaScript library providing routing capabilities for web applications.","main":"dist_ts/index.js","typings":"dist_ts/index.d.ts","author":{"name":"Lossless GmbH"},"license":"MIT","scripts":{"test":"(tstest test/ --verbose)","build":"(tsbuild --web && tsbundle npm --web)","format":"(gitzone format)","buildDocs":"tsdoc"},"devDependencies":{"@git.zone/tsbuild":"^2.6.4","@git.zone/tsbundle":"^2.5.1","@git.zone/tstest":"^2.3.2","@types/node":"^22.7.4"},"dependencies":{"@push.rocks/lik":"^6.2.2","@push.rocks/smartrx":"^3.0.10","path-to-regexp":"^8.2.0"},"browserslist":["last 1 chrome versions"],"type":"module","keywords":["web development","routing","single page application","URL management","path matching","query parameters","browser history"],"homepage":"https://code.foss.global/push.rocks/smartrouter","repository":{"type":"git","url":"https://code.foss.global/push.rocks/smartrouter.git"},"packageManager":"pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977","_id":"@push.rocks/smartrouter@1.3.3","gitHead":"2f8247b3d5beda5703bb73fd0f4414e29a1d4650","_nodeVersion":"23.8.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-1+xZEnWlhzqLWAaJ1zFNhQ0zgbfCWQl1DBT72LygLxTs+P0K8AwJKgqo/IX6CT55kGCFnPAZIYSbVJlGsgrB0w==","shasum":"d1a1006300187c1aa5faf1a8d6ea7b212fc6d522","tarball":"https://registry.npmjs.org/@push.rocks/smartrouter/-/smartrouter-1.3.3.tgz","fileCount":22,"unpackedSize":1700627,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHcQj8Eq+aSnDPP1xSMxz6BAxUrb/84mH5iXIdYQhiasAiEAmWDN0KN5DIwPzRtaGv3xCp9KTyM3B33W95ewjWNY/ao="}]},"_npmUser":{"name":"lossless","email":"hello@lossless.com"},"directories":{},"maintainers":[{"name":"lossless","email":"hello@lossless.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/smartrouter_1.3.3_1753465294177_0.6366640903991099"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-12T01:01:46.428Z","modified":"2025-07-25T17:41:34.660Z","1.0.16":"2023-07-12T01:01:46.754Z","1.2.1":"2024-10-06T18:18:28.363Z","1.3.0":"2024-10-06T20:28:05.513Z","1.3.2":"2024-10-06T20:39:17.432Z","1.3.3":"2025-07-25T17:41:34.475Z"},"author":{"name":"Lossless GmbH"},"license":"MIT","homepage":"https://code.foss.global/push.rocks/smartrouter","keywords":["web development","routing","single page application","URL management","path matching","query parameters","browser history"],"repository":{"type":"git","url":"https://code.foss.global/push.rocks/smartrouter.git"},"description":"A JavaScript library providing routing capabilities for web applications.","maintainers":[{"name":"lossless","email":"hello@lossless.com"}],"readme":"# @push.rocks/smartrouter\nA JavaScript library providing routing capabilities for web applications with support for path parameters, query parameters, and programmatic navigation\n\n## Install\nTo install `@push.rocks/smartrouter`, run the following command in your project directory:\n```sh\npnpm install @push.rocks/smartrouter --save\n```\n\nThis will add `@push.rocks/smartrouter` to your project's dependencies and enable you to use it within your application.\n\n## Usage\n`@push.rocks/smartrouter` provides a versatile routing solution for websites, leveraging modern Web APIs to manipulate browser history and handle URL paths intelligently. Below are examples demonstrating how to use `@push.rocks/smartrouter` effectively in a TypeScript project, taking advantage of ESM syntax.\n\n### Basic Setup\nFirst, ensure you've installed the package as described in the Install section above. Next, import `SmartRouter` from `@push.rocks/smartrouter` in your application's entry point or any module where routing is required.\n\n```typescript\nimport { SmartRouter } from '@push.rocks/smartrouter';\n```\n\n### Initialize the Router\nCreate an instance of `SmartRouter` and optionally provide configuration options. If your application requires debugging information, `debug` can be set to `true`.\n\n```typescript\nconst router = new SmartRouter({\n  debug: true, // Enables debugging. Optional and false by default.\n});\n```\n\n### Define Routes\nDefine your application routes using the `on` method, which takes a URL pattern and a handler function. The handler function will be called when the application navigates to a URL that matches the pattern.\n\n```typescript\nrouter.on('/home', async (routeInfo) => {\n  console.log('Home route accessed', routeInfo);\n  // Handle the home route\n  // You can load a page component, change document title, etc.\n});\n\nrouter.on('/about', async (routeInfo) => {\n  console.log('About route accessed', routeInfo);\n  // Handle the about route\n});\n```\n\n### Path Parameters\n`@push.rocks/smartrouter` supports dynamic path parameters. Define path parameters within your route strings using the `:` prefix, and access their values from the `routeInfo.params` object in your handler function.\n\n```typescript\nrouter.on('/user/:userId', async (routeInfo) => {\n  console.log(`User Profile for ID: ${routeInfo.params.userId}`, routeInfo);\n  // Load and display user profile based on userId\n});\n```\n\n### Query Parameters\nQuery parameters can be accessed through the `routeInfo.queryParams` object, making it easy to handle complex routing scenarios with optional parameters.\n\n```typescript\nrouter.on('/search', async (routeInfo) => {\n  console.log('Search Query:', routeInfo.queryParams.query);\n  // Perform a search operation using the provided query parameter\n});\n```\n\n### Programmatic Navigation\nNavigate programmatically using the `pushUrl` method. This method allows you to change the URL without reloading the page, and optionally pass state information.\n\n```typescript\n// Navigate to the about page\nrouter.pushUrl('/about');\n\n// Navigate to a user profile with URL parameters\nrouter.pushUrl('/user/12345');\n\n// Navigate with state data\nrouter.pushUrl('/dashboard', { previousPage: 'home' });\n```\n\n### Managing Query Parameters\n`@push.rocks/smartrouter` provides methods for managing URL query parameters, enabling dynamic URL manipulation for filter settings, pagination, and other use cases.\n\n```typescript\n// Set a query parameter (replace by default)\nrouter.queryParams.setQueryParam('key', 'value');\n\n// Set a query parameter with push (adds to history)\nrouter.queryParams.setQueryParam('key', 'value', 'push');\n\n// Get a query parameter\nconst value = router.queryParams.getQueryParam('key');\n\n// Get all query parameters as an object\nconst allParams = router.queryParams.getAllAsObject();\n\n// Delete a query parameter\nrouter.queryParams.deleteQueryParam('key');\n\n// Delete with push to history\nrouter.queryParams.deleteQueryParam('key', 'push');\n```\n\n### Sub-Routers\nCreate sub-routers with a specific base path for modular routing:\n\n```typescript\n// Create a sub-router for admin routes\nconst adminRouter = router.createSubRouter('/admin');\n\n// Routes will be prefixed with /admin\nadminRouter.on('/dashboard', async (routeInfo) => {\n  // This handles /admin/dashboard\n});\n\nadminRouter.on('/users', async (routeInfo) => {\n  // This handles /admin/users\n});\n```\n\n### Route Management\nThe `on` method returns a function that can be used to remove the route:\n\n```typescript\n// Add a route\nconst removeRoute = router.on('/temporary', async (routeInfo) => {\n  console.log('Temporary route accessed');\n});\n\n// Later, remove the route\nremoveRoute();\n```\n\n### Cleanup\nWhen you're done with a router instance, clean it up properly:\n\n```typescript\n// Destroy the router, removing all event listeners and routes\nrouter.destroy();\n```\n\nThis module enables complex routing scenarios, simplifying the handling of navigational logic in modern web applications. By leveraging `@push.rocks/smartrouter`, developers can implement detailed routing mechanisms, manipulate browser history thoughtfully, and maintain cleaner URL structures, enhancing the user experience and making web apps more accessible.\n\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH  \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n","readmeFilename":"readme.md"}