update tsconfig

This commit is contained in:
Philipp Kunz 2024-04-14 18:14:02 +02:00
parent f4e17f7c74
commit c68bb206a2
4 changed files with 152 additions and 32 deletions

View File

@ -5,17 +5,26 @@
"githost": "code.foss.global", "githost": "code.foss.global",
"gitscope": "push.rocks", "gitscope": "push.rocks",
"gitrepo": "smartrouter", "gitrepo": "smartrouter",
"description": "a router for routing on websites", "description": "A JavaScript library providing routing capabilities for web applications.",
"npmPackagename": "@push.rocks/smartrouter", "npmPackagename": "@push.rocks/smartrouter",
"license": "MIT", "license": "MIT",
"projectDomain": "push.rocks" "projectDomain": "push.rocks",
"keywords": [
"web development",
"routing",
"single page application",
"URL management",
"path matching",
"query parameters",
"browser history"
]
} }
}, },
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public"
}, },
"tsdocs": { "tsdoc": {
"legal": "\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" "legal": "\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"
} }
} }

View File

@ -2,7 +2,7 @@
"name": "@push.rocks/smartrouter", "name": "@push.rocks/smartrouter",
"version": "1.0.17", "version": "1.0.17",
"private": false, "private": false,
"description": "a router for routing on websites", "description": "A JavaScript library providing routing capabilities for web applications.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH", "author": "Lossless GmbH",
@ -21,6 +21,8 @@
"@types/node": "^20.6.0" "@types/node": "^20.6.0"
}, },
"dependencies": { "dependencies": {
"@push.rocks/lik": "^6.0.5",
"@push.rocks/smartrx": "^3.0.6",
"path-to-regexp": "^6.2.0" "path-to-regexp": "^6.2.0"
}, },
"files": [ "files": [
@ -38,5 +40,14 @@
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
], ],
"type": "module" "type": "module",
"keywords": [
"web development",
"routing",
"single page application",
"URL management",
"path matching",
"query parameters",
"browser history"
]
} }

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

151
readme.md
View File

@ -1,37 +1,136 @@
# @push.rocks/smartrouter # @push.rocks/smartrouter
a router for routing on websites a router for routing on websites
## Availabililty and Links ## Install
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartrouter) To install `@push.rocks/smartrouter`, run the following command in your project directory:
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartrouter) ```sh
* [github.com (source mirror)](https://github.com/push.rocks/smartrouter) npm install @push.rocks/smartrouter --save
* [docs (typedoc)](https://push.rocks.gitlab.io/smartrouter/) ```
## Status for master This will add `@push.rocks/smartrouter` to your project's dependencies and enable you to use it within your application.
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartrouter/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartrouter/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartrouter)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartrouter)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartrouter)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartrouter)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartrouter)](https://lossless.cloud)
## Usage ## Usage
`@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.
Use TypeScript for best in class intellisense ### Basic Setup
First, 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.
## Contribution ```typescript
import { SmartRouter } from '@push.rocks/smartrouter';
```
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) ### Initialize the Router
Create an instance of `SmartRouter` and optionally provide configuration options. If your application requires debugging information, `debug` can be set to `true`.
For further information read the linked docs at the top of this readme. ```typescript
const router = new SmartRouter({
debug: true, // Enables debugging. Optional and false by default.
});
```
## Legal ### Define Routes
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc) Define 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.
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
```typescript
router.on('/home', async (routeInfo) => {
console.log('Home route accessed', routeInfo);
// Handle the home route
// You can load a page component, change document title, etc.
});
router.on('/about', async (routeInfo) => {
console.log('About route accessed', routeInfo);
// Handle the about route
});
```
### Path Parameters
`@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.
```typescript
router.on('/user/:userId', async (routeInfo) => {
console.log(`User Profile for ID: ${routeInfo.params.userId}`, routeInfo);
// Load and display user profile based on userId
});
```
### Query Parameters
Query parameters can be accessed through the `routeInfo.queryParams` object, making it easy to handle complex routing scenarios with optional parameters.
```typescript
router.on('/search', async (routeInfo) => {
console.log('Search Query:', routeInfo.queryParams.query);
// Perform a search operation using the provided query parameter
});
```
### Programmatic Navigation
Navigate programmatically using the `pushUrl` method. This method allows you to change the URL without reloading the page, and optionally pass state information.
```typescript
// Navigate to the about page
router.pushUrl('/about');
// Navigate to a user profile with URL parameters
router.pushUrl('/user/12345');
```
### Managing Query Parameters
`@push.rocks/smartrouter` provides methods for managing URL query parameters, enabling dynamic URL manipulation for filter settings, pagination, and other use cases.
```typescript
// Set a query parameter
router.queryParams.setQueryParam('key', 'value');
// Get a query parameter
const value = router.queryParams.getQueryParam('key');
// Delete a query parameter
router.queryParams.deleteQueryParam('key');
```
### Selection Dimensions
`@push.rocks/smartrouter` introduces the concept of selection dimensions, allowing you to manage stateful selections across routes. This is especially useful for complex navigation flows that depend on prior selections.
```typescript
await router.createSelectionDimension({
routeArg: '/select/:option',
keyArg: 'mySelection',
options: [
{
key: 'option1',
detail: { /* some data */ },
action: async () => { /* action for option1 */ }
},
{
key: 'option2',
detail: { /* some data */ },
action: async () => { /* action for option2 */ }
}
]
});
// Navigate to a selection option
router.pushUrl('/select/option1');
```
This 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.
## License and Legal Information
This 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.
**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.
### Trademarks
This 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.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By 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.