Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.
This commit is contained in:
1
node_modules/hast-util-parse-selector/index.d.ts
generated
vendored
Normal file
1
node_modules/hast-util-parse-selector/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export { parseSelector } from "./lib/index.js";
|
1
node_modules/hast-util-parse-selector/index.js
generated
vendored
Normal file
1
node_modules/hast-util-parse-selector/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {parseSelector} from './lib/index.js'
|
27
node_modules/hast-util-parse-selector/lib/index.d.ts
generated
vendored
Normal file
27
node_modules/hast-util-parse-selector/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Create a hast element from a simple CSS selector.
|
||||
*
|
||||
* @template {string} Selector
|
||||
* Type of selector.
|
||||
* @template {string} [DefaultTagName='div']
|
||||
* Type of default tag name (default: `'div'`).
|
||||
* @param {Selector | null | undefined} [selector]
|
||||
* Simple CSS selector (optional).
|
||||
*
|
||||
* Can contain a tag name (`foo`), classes (`.bar`), and an ID (`#baz`).
|
||||
* Multiple classes are allowed.
|
||||
* Uses the last ID if multiple IDs are found.
|
||||
* @param {DefaultTagName | null | undefined} [defaultTagName='div']
|
||||
* Tag name to use if `selector` does not specify one (default: `'div'`).
|
||||
* @returns {Element & {tagName: ExtractTagName<Selector, DefaultTagName>}}
|
||||
* Built element.
|
||||
*/
|
||||
export function parseSelector<Selector extends string, DefaultTagName extends string = "div">(selector?: Selector | null | undefined, defaultTagName?: DefaultTagName | null | undefined): import("hast").Element & {
|
||||
tagName: ExtractTagName<Selector, DefaultTagName>;
|
||||
};
|
||||
export type Element = import('hast').Element;
|
||||
export type Properties = import('hast').Properties;
|
||||
/**
|
||||
* Extract tag name from a simple selector.
|
||||
*/
|
||||
export type ExtractTagName<SimpleSelector extends string, DefaultTagName extends string> = SimpleSelector extends "" ? DefaultTagName : SimpleSelector extends `${infer TagName}.${infer Rest}` ? ExtractTagName<TagName, DefaultTagName> : SimpleSelector extends `${infer TagName_1}#${infer Rest_1}` ? ExtractTagName<TagName_1, DefaultTagName> : SimpleSelector extends string ? SimpleSelector : DefaultTagName;
|
87
node_modules/hast-util-parse-selector/lib/index.js
generated
vendored
Normal file
87
node_modules/hast-util-parse-selector/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @typedef {import('hast').Element} Element
|
||||
* @typedef {import('hast').Properties} Properties
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template {string} SimpleSelector
|
||||
* Selector type.
|
||||
* @template {string} DefaultTagName
|
||||
* Default tag name.
|
||||
* @typedef {(
|
||||
* SimpleSelector extends ''
|
||||
* ? DefaultTagName
|
||||
* : SimpleSelector extends `${infer TagName}.${infer Rest}`
|
||||
* ? ExtractTagName<TagName, DefaultTagName>
|
||||
* : SimpleSelector extends `${infer TagName}#${infer Rest}`
|
||||
* ? ExtractTagName<TagName, DefaultTagName>
|
||||
* : SimpleSelector extends string
|
||||
* ? SimpleSelector
|
||||
* : DefaultTagName
|
||||
* )} ExtractTagName
|
||||
* Extract tag name from a simple selector.
|
||||
*/
|
||||
|
||||
const search = /[#.]/g
|
||||
|
||||
/**
|
||||
* Create a hast element from a simple CSS selector.
|
||||
*
|
||||
* @template {string} Selector
|
||||
* Type of selector.
|
||||
* @template {string} [DefaultTagName='div']
|
||||
* Type of default tag name (default: `'div'`).
|
||||
* @param {Selector | null | undefined} [selector]
|
||||
* Simple CSS selector (optional).
|
||||
*
|
||||
* Can contain a tag name (`foo`), classes (`.bar`), and an ID (`#baz`).
|
||||
* Multiple classes are allowed.
|
||||
* Uses the last ID if multiple IDs are found.
|
||||
* @param {DefaultTagName | null | undefined} [defaultTagName='div']
|
||||
* Tag name to use if `selector` does not specify one (default: `'div'`).
|
||||
* @returns {Element & {tagName: ExtractTagName<Selector, DefaultTagName>}}
|
||||
* Built element.
|
||||
*/
|
||||
export function parseSelector(selector, defaultTagName) {
|
||||
const value = selector || ''
|
||||
/** @type {Properties} */
|
||||
const props = {}
|
||||
let start = 0
|
||||
/** @type {string | undefined} */
|
||||
let previous
|
||||
/** @type {string | undefined} */
|
||||
let tagName
|
||||
|
||||
while (start < value.length) {
|
||||
search.lastIndex = start
|
||||
const match = search.exec(value)
|
||||
const subvalue = value.slice(start, match ? match.index : value.length)
|
||||
|
||||
if (subvalue) {
|
||||
if (!previous) {
|
||||
tagName = subvalue
|
||||
} else if (previous === '#') {
|
||||
props.id = subvalue
|
||||
} else if (Array.isArray(props.className)) {
|
||||
props.className.push(subvalue)
|
||||
} else {
|
||||
props.className = [subvalue]
|
||||
}
|
||||
|
||||
start += subvalue.length
|
||||
}
|
||||
|
||||
if (match) {
|
||||
previous = match[0]
|
||||
start++
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'element',
|
||||
// @ts-expect-error: tag name is parsed.
|
||||
tagName: tagName || defaultTagName || 'div',
|
||||
properties: props,
|
||||
children: []
|
||||
}
|
||||
}
|
22
node_modules/hast-util-parse-selector/license
generated
vendored
Normal file
22
node_modules/hast-util-parse-selector/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
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.
|
79
node_modules/hast-util-parse-selector/package.json
generated
vendored
Normal file
79
node_modules/hast-util-parse-selector/package.json
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"name": "hast-util-parse-selector",
|
||||
"version": "4.0.0",
|
||||
"description": "hast utility to create an element from a simple CSS selector",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"unist",
|
||||
"hast",
|
||||
"hast-util",
|
||||
"util",
|
||||
"utility",
|
||||
"html",
|
||||
"css",
|
||||
"selector",
|
||||
"parse"
|
||||
],
|
||||
"repository": "syntax-tree/hast-util-parse-selector",
|
||||
"bugs": "https://github.com/syntax-tree/hast-util-parse-selector/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"files": [
|
||||
"lib/",
|
||||
"index.d.ts",
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/hast": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.0.0",
|
||||
"c8": "^8.0.0",
|
||||
"prettier": "^3.0.0",
|
||||
"remark-cli": "^11.0.0",
|
||||
"remark-preset-wooorm": "^9.0.0",
|
||||
"tsd": "^0.28.0",
|
||||
"type-coverage": "^2.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"xo": "^0.55.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepack": "npm run build && npm run format",
|
||||
"build": "tsc --build --clean && tsc --build && type-coverage && tsd",
|
||||
"format": "remark . -qfo && prettier . -w --log-level warn && xo --fix",
|
||||
"test-api": "node --conditions development test.js",
|
||||
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
|
||||
"test": "npm run build && npm run format && npm run test-coverage"
|
||||
},
|
||||
"prettier": {
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"useTabs": false
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"remark-preset-wooorm"
|
||||
]
|
||||
},
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"detail": true,
|
||||
"ignoreCatch": true,
|
||||
"strict": true
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true
|
||||
}
|
||||
}
|
203
node_modules/hast-util-parse-selector/readme.md
generated
vendored
Normal file
203
node_modules/hast-util-parse-selector/readme.md
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
# hast-util-parse-selector
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
[hast][] utility to create an element from a simple CSS selector.
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [When should I use this?](#when-should-i-use-this)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`parseSelector(selector?[, defaultTagName])`](#parseselectorselector-defaulttagname)
|
||||
* [Types](#types)
|
||||
* [Compatibility](#compatibility)
|
||||
* [Security](#security)
|
||||
* [Related](#related)
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a tiny utility that helps create elements.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
This utility is super niche.
|
||||
You probably want the more powerful [`hastscript`][hastscript] or
|
||||
[`hast-util-from-selector`][hast-util-from-selector]
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 16+), install with [npm][]:
|
||||
|
||||
```sh
|
||||
npm install hast-util-parse-selector
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
|
||||
```js
|
||||
import {parseSelector} from 'https://esm.sh/hast-util-parse-selector@4'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import {parseSelector} from 'https://esm.sh/hast-util-parse-selector@4?bundle'
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
```js
|
||||
import {parseSelector} from 'hast-util-parse-selector'
|
||||
|
||||
console.log(parseSelector('.quux#bar.baz.qux'))
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```js
|
||||
{ type: 'element',
|
||||
tagName: 'div',
|
||||
properties: { id: 'bar', className: [ 'quux', 'baz', 'qux' ] },
|
||||
children: [] }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This package exports the identifier [`parseSelector`][api-parse-selector].
|
||||
There is no default export.
|
||||
|
||||
### `parseSelector(selector?[, defaultTagName])`
|
||||
|
||||
Create a hast element from a simple CSS selector.
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `selector` (`string`, optional)
|
||||
— simple CSS selector, can contain a tag name (`foo`), classes (`.bar`),
|
||||
and an ID (`#baz`), multiple classes are allowed, uses the last ID if
|
||||
multiple IDs are found
|
||||
* `defaultTagName` (`string`, default: `'div'`)
|
||||
— tag name to use if `selector` does not specify one
|
||||
|
||||
###### Returns
|
||||
|
||||
Built element ([`Element`][element]).
|
||||
|
||||
## Types
|
||||
|
||||
This package is fully typed with [TypeScript][].
|
||||
It exports no additional types.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
|
||||
When we cut a new major release, we drop support for unmaintained versions of
|
||||
Node.
|
||||
This means we try to keep the current release line,
|
||||
`hast-util-parse-selector@^4`, compatible with Node.js 16.
|
||||
|
||||
## Security
|
||||
|
||||
Improper use of the `selector` or `defaultTagName` can open you up to a
|
||||
[cross-site scripting (XSS)][xss] attack as the value of `tagName`, when
|
||||
resolving to `script`, injects a `script` element into the syntax tree.
|
||||
|
||||
Do not use user input in `selector` or use
|
||||
[`hast-util-santize`][hast-util-sanitize].
|
||||
|
||||
## Related
|
||||
|
||||
* [`hast-util-from-selector`](https://github.com/syntax-tree/hast-util-from-selector)
|
||||
— parse complex CSS selectors to nodes
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
|
||||
ways to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://github.com/syntax-tree/hast-util-parse-selector/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/syntax-tree/hast-util-parse-selector/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-parse-selector.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/hast-util-parse-selector
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/hast-util-parse-selector.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/hast-util-parse-selector
|
||||
|
||||
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=hast-util-parse-selector
|
||||
|
||||
[size]: https://bundlejs.com/?q=hast-util-parse-selector
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/syntax-tree/unist/discussions
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[health]: https://github.com/syntax-tree/.github
|
||||
|
||||
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[hast]: https://github.com/syntax-tree/hast
|
||||
|
||||
[hast-util-sanitize]: https://github.com/syntax-tree/hast-util-sanitize
|
||||
|
||||
[hastscript]: https://github.com/syntax-tree/hastscript
|
||||
|
||||
[hast-util-from-selector]: https://github.com/syntax-tree/hast-util-from-selector
|
||||
|
||||
[element]: https://github.com/syntax-tree/hast#element
|
||||
|
||||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
|
||||
|
||||
[api-parse-selector]: #parseselectorselector-defaulttagname
|
Reference in New Issue
Block a user