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:
becarta
2025-05-23 12:43:00 +02:00
parent f40db0f5c9
commit a544759a3b
11127 changed files with 1647032 additions and 0 deletions

9
node_modules/unist-util-visit/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export type {Test} from 'unist-util-is'
export type {
Action,
ActionTuple,
Index,
VisitorResult
} from 'unist-util-visit-parents'
export type {Visitor, BuildVisitor} from './lib/index.js'
export {CONTINUE, EXIT, SKIP, visit} from './lib/index.js'

2
node_modules/unist-util-visit/index.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
// Note: types exported from `index.d.ts`
export {CONTINUE, EXIT, SKIP, visit} from './lib/index.js'

198
node_modules/unist-util-visit/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,198 @@
export function visit<Tree extends import('unist').Node, Check extends Test>(
tree: Tree,
check: Check,
visitor: BuildVisitor<Tree, Check>,
reverse?: boolean | null | undefined
): undefined
export function visit<Tree extends import('unist').Node, Check extends Test>(
tree: Tree,
visitor: BuildVisitor<Tree, Test>,
reverse?: boolean | null | undefined
): undefined
export type UnistNode = import('unist').Node
export type UnistParent = import('unist').Parent
export type VisitorResult = import('unist-util-visit-parents').VisitorResult
/**
* Test from `unist-util-is`.
*
* Note: we have remove and add `undefined`, because otherwise when generating
* automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
* which doesnt work when publishing on npm.
*/
export type Test = Exclude<import('unist-util-is').Test, undefined> | undefined
/**
* Get the value of a type guard `Fn`.
*/
export type Predicate<Fn, Fallback> = Fn extends (
value: any
) => value is infer Thing
? Thing
: Fallback
/**
* Check whether a node matches a primitive check in the type system.
*/
export type MatchesOne<Value, Check> = Check extends null | undefined
? Value
: Value extends {
type: Check
}
? Value
: Value extends Check
? Value
: Check extends Function
? Predicate<Check, Value> extends Value
? Predicate<Check, Value>
: never
: never
/**
* Check whether a node matches a check in the type system.
*/
export type Matches<Value, Check> = Check extends Array<any>
? MatchesOne<Value, Check[keyof Check]>
: MatchesOne<Value, Check>
/**
* Number; capped reasonably.
*/
export type Uint = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
/**
* Increment a number in the type system.
*/
export type Increment<I extends Uint = 0> = I extends 0
? 1
: I extends 1
? 2
: I extends 2
? 3
: I extends 3
? 4
: I extends 4
? 5
: I extends 5
? 6
: I extends 6
? 7
: I extends 7
? 8
: I extends 8
? 9
: 10
/**
* Collect nodes that can be parents of `Child`.
*/
export type InternalParent<
Node extends import('unist').Node,
Child extends import('unist').Node
> = Node extends import('unist').Parent
? Node extends {
children: (infer Children)[]
}
? Child extends Children
? Node
: never
: never
: never
/**
* Collect nodes in `Tree` that can be parents of `Child`.
*/
export type Parent<
Tree extends import('unist').Node,
Child extends import('unist').Node
> = InternalParent<InclusiveDescendant<Tree>, Child>
/**
* Collect nodes in `Tree` that can be ancestors of `Child`.
*/
export type InternalAncestor<
Node extends import('unist').Node,
Child extends import('unist').Node,
Max extends Uint = 10,
Depth extends Uint = 0
> = Depth extends Max
? never
:
| InternalParent<Node, Child>
| InternalAncestor<
Node,
InternalParent<Node, Child>,
Max,
Increment<Depth>
>
/**
* Collect all (inclusive) descendants of `Tree`.
*
* > 👉 **Note**: for performance reasons, this seems to be the fastest way to
* > recurse without actually running into an infinite loop, which the
* > previous version did.
* >
* > Practically, a max of `2` is typically enough assuming a `Root` is
* > passed, but it doesnt improve performance.
* > It gets higher with `List > ListItem > Table > TableRow > TableCell`.
* > Using up to `10` doesnt hurt or help either.
*/
export type InclusiveDescendant<
Tree extends import('unist').Node,
Max extends Uint = 10,
Depth extends Uint = 0
> = Tree extends UnistParent
? Depth extends Max
? Tree
:
| Tree
| InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>
: Tree
/**
* Handle a node (matching `test`, if given).
*
* Visitors are free to transform `node`.
* They can also transform `parent`.
*
* Replacing `node` itself, if `SKIP` is not returned, still causes its
* descendants to be walked (which is a bug).
*
* When adding or removing previous siblings of `node` (or next siblings, in
* case of reverse), the `Visitor` should return a new `Index` to specify the
* sibling to traverse after `node` is traversed.
* Adding or removing next siblings of `node` (or previous siblings, in case
* of reverse) is handled as expected without needing to return a new `Index`.
*
* Removing the children property of `parent` still results in them being
* traversed.
*/
export type Visitor<
Visited extends import('unist').Node = import('unist').Node,
Ancestor extends import('unist').Parent = import('unist').Parent
> = (
node: Visited,
index: Visited extends UnistNode ? number | undefined : never,
parent: Ancestor extends UnistParent ? Ancestor | undefined : never
) => VisitorResult
/**
* Build a typed `Visitor` function from a node and all possible parents.
*
* It will infer which values are passed as `node` and which as `parent`.
*/
export type BuildVisitorFromMatch<
Visited extends import('unist').Node,
Ancestor extends import('unist').Parent
> = Visitor<Visited, Parent<Ancestor, Visited>>
/**
* Build a typed `Visitor` function from a list of descendants and a test.
*
* It will infer which values are passed as `node` and which as `parent`.
*/
export type BuildVisitorFromDescendants<
Descendant extends import('unist').Node,
Check extends Test
> = BuildVisitorFromMatch<
Matches<Descendant, Check>,
Extract<Descendant, UnistParent>
>
/**
* Build a typed `Visitor` function from a tree and a test.
*
* It will infer which values are passed as `node` and which as `parent`.
*/
export type BuildVisitor<
Tree extends import('unist').Node = import('unist').Node,
Check extends Test = Test
> = BuildVisitorFromDescendants<InclusiveDescendant<Tree>, Check>
export {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'

313
node_modules/unist-util-visit/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,313 @@
/**
* @typedef {import('unist').Node} UnistNode
* @typedef {import('unist').Parent} UnistParent
* @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult
*/
/**
* @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test
* Test from `unist-util-is`.
*
* Note: we have remove and add `undefined`, because otherwise when generating
* automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
* which doesnt work when publishing on npm.
*/
// To do: use types from `unist-util-visit-parents` when its released.
/**
* @typedef {(
* Fn extends (value: any) => value is infer Thing
* ? Thing
* : Fallback
* )} Predicate
* Get the value of a type guard `Fn`.
* @template Fn
* Value; typically function that is a type guard (such as `(x): x is Y`).
* @template Fallback
* Value to yield if `Fn` is not a type guard.
*/
/**
* @typedef {(
* Check extends null | undefined // No test.
* ? Value
* : Value extends {type: Check} // String (type) test.
* ? Value
* : Value extends Check // Partial test.
* ? Value
* : Check extends Function // Function test.
* ? Predicate<Check, Value> extends Value
* ? Predicate<Check, Value>
* : never
* : never // Some other test?
* )} MatchesOne
* Check whether a node matches a primitive check in the type system.
* @template Value
* Value; typically unist `Node`.
* @template Check
* Value; typically `unist-util-is`-compatible test, but not arrays.
*/
/**
* @typedef {(
* Check extends Array<any>
* ? MatchesOne<Value, Check[keyof Check]>
* : MatchesOne<Value, Check>
* )} Matches
* Check whether a node matches a check in the type system.
* @template Value
* Value; typically unist `Node`.
* @template Check
* Value; typically `unist-util-is`-compatible test.
*/
/**
* @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint
* Number; capped reasonably.
*/
/**
* @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment
* Increment a number in the type system.
* @template {Uint} [I=0]
* Index.
*/
/**
* @typedef {(
* Node extends UnistParent
* ? Node extends {children: Array<infer Children>}
* ? Child extends Children ? Node : never
* : never
* : never
* )} InternalParent
* Collect nodes that can be parents of `Child`.
* @template {UnistNode} Node
* All node types in a tree.
* @template {UnistNode} Child
* Node to search for.
*/
/**
* @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent
* Collect nodes in `Tree` that can be parents of `Child`.
* @template {UnistNode} Tree
* All node types in a tree.
* @template {UnistNode} Child
* Node to search for.
*/
/**
* @typedef {(
* Depth extends Max
* ? never
* :
* | InternalParent<Node, Child>
* | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>
* )} InternalAncestor
* Collect nodes in `Tree` that can be ancestors of `Child`.
* @template {UnistNode} Node
* All node types in a tree.
* @template {UnistNode} Child
* Node to search for.
* @template {Uint} [Max=10]
* Max; searches up to this depth.
* @template {Uint} [Depth=0]
* Current depth.
*/
/**
* @typedef {(
* Tree extends UnistParent
* ? Depth extends Max
* ? Tree
* : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>
* : Tree
* )} InclusiveDescendant
* Collect all (inclusive) descendants of `Tree`.
*
* > 👉 **Note**: for performance reasons, this seems to be the fastest way to
* > recurse without actually running into an infinite loop, which the
* > previous version did.
* >
* > Practically, a max of `2` is typically enough assuming a `Root` is
* > passed, but it doesnt improve performance.
* > It gets higher with `List > ListItem > Table > TableRow > TableCell`.
* > Using up to `10` doesnt hurt or help either.
* @template {UnistNode} Tree
* Tree type.
* @template {Uint} [Max=10]
* Max; searches up to this depth.
* @template {Uint} [Depth=0]
* Current depth.
*/
/**
* @callback Visitor
* Handle a node (matching `test`, if given).
*
* Visitors are free to transform `node`.
* They can also transform `parent`.
*
* Replacing `node` itself, if `SKIP` is not returned, still causes its
* descendants to be walked (which is a bug).
*
* When adding or removing previous siblings of `node` (or next siblings, in
* case of reverse), the `Visitor` should return a new `Index` to specify the
* sibling to traverse after `node` is traversed.
* Adding or removing next siblings of `node` (or previous siblings, in case
* of reverse) is handled as expected without needing to return a new `Index`.
*
* Removing the children property of `parent` still results in them being
* traversed.
* @param {Visited} node
* Found node.
* @param {Visited extends UnistNode ? number | undefined : never} index
* Index of `node` in `parent`.
* @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
* Parent of `node`.
* @returns {VisitorResult}
* What to do next.
*
* An `Index` is treated as a tuple of `[CONTINUE, Index]`.
* An `Action` is treated as a tuple of `[Action]`.
*
* Passing a tuple back only makes sense if the `Action` is `SKIP`.
* When the `Action` is `EXIT`, that action can be returned.
* When the `Action` is `CONTINUE`, `Index` can be returned.
* @template {UnistNode} [Visited=UnistNode]
* Visited node type.
* @template {UnistParent} [Ancestor=UnistParent]
* Ancestor type.
*/
/**
* @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch
* Build a typed `Visitor` function from a node and all possible parents.
*
* It will infer which values are passed as `node` and which as `parent`.
* @template {UnistNode} Visited
* Node type.
* @template {UnistParent} Ancestor
* Parent type.
*/
/**
* @typedef {(
* BuildVisitorFromMatch<
* Matches<Descendant, Check>,
* Extract<Descendant, UnistParent>
* >
* )} BuildVisitorFromDescendants
* Build a typed `Visitor` function from a list of descendants and a test.
*
* It will infer which values are passed as `node` and which as `parent`.
* @template {UnistNode} Descendant
* Node type.
* @template {Test} Check
* Test type.
*/
/**
* @typedef {(
* BuildVisitorFromDescendants<
* InclusiveDescendant<Tree>,
* Check
* >
* )} BuildVisitor
* Build a typed `Visitor` function from a tree and a test.
*
* It will infer which values are passed as `node` and which as `parent`.
* @template {UnistNode} [Tree=UnistNode]
* Node type.
* @template {Test} [Check=Test]
* Test type.
*/
import {visitParents} from 'unist-util-visit-parents'
export {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'
/**
* Visit nodes.
*
* This algorithm performs *depth-first* *tree traversal* in *preorder*
* (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
*
* You can choose for which nodes `visitor` is called by passing a `test`.
* For complex tests, you should test yourself in `visitor`, as it will be
* faster and will have improved type information.
*
* Walking the tree is an intensive task.
* Make use of the return values of the visitor when possible.
* Instead of walking a tree multiple times, walk it once, use `unist-util-is`
* to check if a node matches, and then perform different operations.
*
* You can change the tree.
* See `Visitor` for more info.
*
* @overload
* @param {Tree} tree
* @param {Check} check
* @param {BuildVisitor<Tree, Check>} visitor
* @param {boolean | null | undefined} [reverse]
* @returns {undefined}
*
* @overload
* @param {Tree} tree
* @param {BuildVisitor<Tree>} visitor
* @param {boolean | null | undefined} [reverse]
* @returns {undefined}
*
* @param {UnistNode} tree
* Tree to traverse.
* @param {Visitor | Test} testOrVisitor
* `unist-util-is`-compatible test (optional, omit to pass a visitor).
* @param {Visitor | boolean | null | undefined} [visitorOrReverse]
* Handle each node (when test is omitted, pass `reverse`).
* @param {boolean | null | undefined} [maybeReverse=false]
* Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
* @returns {undefined}
* Nothing.
*
* @template {UnistNode} Tree
* Node type.
* @template {Test} Check
* `unist-util-is`-compatible test.
*/
export function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
/** @type {boolean | null | undefined} */
let reverse
/** @type {Test} */
let test
/** @type {Visitor} */
let visitor
if (
typeof testOrVisitor === 'function' &&
typeof visitorOrReverse !== 'function'
) {
test = undefined
visitor = testOrVisitor
reverse = visitorOrReverse
} else {
// @ts-expect-error: assume the overload with test was given.
test = testOrVisitor
// @ts-expect-error: assume the overload with test was given.
visitor = visitorOrReverse
reverse = maybeReverse
}
visitParents(tree, test, overload, reverse)
/**
* @param {UnistNode} node
* @param {Array<UnistParent>} parents
*/
function overload(node, parents) {
const parent = parents[parents.length - 1]
const index = parent ? parent.children.indexOf(node) : undefined
return visitor(node, index, parent)
}
}

22
node_modules/unist-util-visit/license generated vendored Normal file
View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2015 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.

113
node_modules/unist-util-visit/package.json generated vendored Normal file
View File

@@ -0,0 +1,113 @@
{
"name": "unist-util-visit",
"version": "5.0.0",
"description": "unist utility to visit nodes",
"license": "MIT",
"keywords": [
"unist",
"unist-util",
"util",
"utility",
"remark",
"retext",
"rehype",
"mdast",
"hast",
"xast",
"nlcst",
"natural",
"language",
"markdown",
"html",
"xml",
"tree",
"ast",
"node",
"visit",
"walk"
],
"repository": "syntax-tree/unist-util-visit",
"bugs": "https://github.com/syntax-tree/unist-util-visit/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)",
"Eugene Sharygin <eush77@gmail.com>",
"Richard Gibson <richard.gibson@gmail.com>"
],
"sideEffects": false,
"type": "module",
"exports": "./index.js",
"files": [
"lib/",
"index.d.ts",
"index.js"
],
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
},
"devDependencies": {
"@types/mdast": "^4.0.0",
"@types/node": "^20.0.0",
"c8": "^8.0.0",
"mdast-util-from-markdown": "^1.0.0",
"mdast-util-gfm": "^2.0.0",
"micromark-extension-gfm": "^2.0.0",
"prettier": "^2.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.54.0"
},
"scripts": {
"prepack": "npm run build && npm run format",
"build": "tsc --build --clean && tsc --build && tsd && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel 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,
"#": "needed `any`s",
"ignoreFiles": [
"lib/index.d.ts"
],
"ignoreCatch": true,
"strict": true
},
"xo": {
"overrides": [
{
"files": [
"**/*.ts"
],
"rules": {
"import/no-extraneous-dependencies": "off"
}
}
],
"prettier": true
}
}

319
node_modules/unist-util-visit/readme.md generated vendored Normal file
View File

@@ -0,0 +1,319 @@
# unist-util-visit
[![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]
[unist][] utility to walk the tree.
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`visit(tree[, test], visitor[, reverse])`](#visittree-test-visitor-reverse)
* [`CONTINUE`](#continue)
* [`EXIT`](#exit)
* [`SKIP`](#skip)
* [`Action`](#action)
* [`ActionTuple`](#actiontuple)
* [`BuildVisitor`](#buildvisitor)
* [`Index`](#index)
* [`Test`](#test)
* [`Visitor`](#visitor)
* [`VisitorResult`](#visitorresult)
* [Types](#types)
* [Compatibility](#compatibility)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This is a very important utility for working with unist as it lets you walk the
tree.
## When should I use this?
You can use this utility when you want to walk the tree.
You can use [`unist-util-visit-parents`][vp] if you care about the entire stack
of parents.
## Install
This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:
```sh
npm install unist-util-visit
```
In Deno with [`esm.sh`][esmsh]:
```js
import {CONTINUE, EXIT, SKIP, visit} from 'https://esm.sh/unist-util-visit@5'
```
In browsers with [`esm.sh`][esmsh]:
```html
<script type="module">
import {CONTINUE, EXIT, SKIP, visit} from 'https://esm.sh/unist-util-visit@5?bundle'
</script>
```
## Use
```js
import {fromMarkdown} from 'mdast-util-from-markdown'
import {visit} from 'unist-util-visit'
const tree = fromMarkdown('Some *emphasis*, **strong**, and `code`.')
visit(tree, 'text', function (node, index, parent) {
console.log([node.value, parent ? parent.type : index])
})
```
Yields:
```js
[ 'Some ', 'paragraph' ]
[ 'emphasis', 'emphasis' ]
[ ', ', 'paragraph' ]
[ 'strong', 'strong' ]
[ ', and ', 'paragraph' ]
[ '.', 'paragraph' ]
```
## API
This package exports the identifiers [`CONTINUE`][api-continue],
[`EXIT`][api-exit], [`SKIP`][api-skip], and [`visit`][api-visit].
There is no default export.
### `visit(tree[, test], visitor[, reverse])`
This function works exactly the same as [`unist-util-visit-parents`][vp],
but [`Visitor`][api-visitor] has a different signature.
### `CONTINUE`
Continue traversing as normal (`true`).
### `EXIT`
Stop traversing immediately (`false`).
### `SKIP`
Do not traverse this nodes children (`'skip'`).
### `Action`
Union of the action types (TypeScript type).
See [`Action` in `unist-util-visit-parents`][vp-action].
### `ActionTuple`
List with an action and an index (TypeScript type).
See [`ActionTuple` in `unist-util-visit-parents`][vp-action-tuple].
### `BuildVisitor`
Build a typed `Visitor` function from a tree and a test (TypeScript type).
See [`BuildVisitor` in `unist-util-visit-parents`][vp-build-visitor].
### `Index`
Move to the sibling at `index` next (TypeScript type).
See [`Index` in `unist-util-visit-parents`][vp-index].
### `Test`
[`unist-util-is`][unist-util-is] compatible test (TypeScript type).
### `Visitor`
Handle a node (matching `test`, if given) (TypeScript type).
Visitors are free to transform `node`.
They can also transform `parent`.
Replacing `node` itself, if `SKIP` is not returned, still causes its
descendants to be walked (which is a bug).
When adding or removing previous siblings of `node` (or next siblings, in
case of reverse), the `Visitor` should return a new `Index` to specify the
sibling to traverse after `node` is traversed.
Adding or removing next siblings of `node` (or previous siblings, in case
of reverse) is handled as expected without needing to return a new `Index`.
Removing the children property of `parent` still results in them being
traversed.
###### Parameters
* `node` ([`Node`][node])
— found node
* `index` (`number` or `undefined`)
— index of `node` in `parent`
* `parent` ([`Node`][node] or `undefined`)
— parent of `node`
###### Returns
What to do next.
An `Index` is treated as a tuple of `[CONTINUE, Index]`.
An `Action` is treated as a tuple of `[Action]`.
Passing a tuple back only makes sense if the `Action` is `SKIP`.
When the `Action` is `EXIT`, that action can be returned.
When the `Action` is `CONTINUE`, `Index` can be returned.
### `VisitorResult`
Any value that can be returned from a visitor (TypeScript type).
See [`VisitorResult` in `unist-util-visit-parents`][vp-visitor-result].
## Types
This package is fully typed with [TypeScript][].
It exports the additional types [`Action`][api-action],
[`ActionTuple`][api-action-tuple], [`BuildVisitor`][api-build-visitor],
[`Index`][api-index], [`Test`][api-test], [`Visitor`][api-visitor], and
[`VisitorResult`][api-visitor-result].
## 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, `unist-util-visit@^5`,
compatible with Node.js 16.
## Related
* [`unist-util-visit-parents`][vp]
— walk the tree with a stack of parents
* [`unist-util-filter`](https://github.com/syntax-tree/unist-util-filter)
— create a new tree with all nodes that pass a test
* [`unist-util-map`](https://github.com/syntax-tree/unist-util-map)
— create a new tree with all nodes mapped by a given function
* [`unist-util-flatmap`](https://gitlab.com/staltz/unist-util-flatmap)
— create a new tree by mapping (to an array) with the given function
* [`unist-util-remove`](https://github.com/syntax-tree/unist-util-remove)
— remove nodes from a tree that pass a test
* [`unist-util-select`](https://github.com/syntax-tree/unist-util-select)
— select nodes with CSS-like selectors
## 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]
<!-- Definition -->
[build-badge]: https://github.com/syntax-tree/unist-util-visit/workflows/main/badge.svg
[build]: https://github.com/syntax-tree/unist-util-visit/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-visit.svg
[coverage]: https://codecov.io/github/syntax-tree/unist-util-visit
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-visit.svg
[downloads]: https://www.npmjs.com/package/unist-util-visit
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=unist-util-visit
[size]: https://bundlejs.com/?q=unist-util-visit
[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
[unist]: https://github.com/syntax-tree/unist
[node]: https://github.com/syntax-tree/unist#nodes
[unist-util-is]: https://github.com/syntax-tree/unist-util-is
[vp]: https://github.com/syntax-tree/unist-util-visit-parents
[vp-action]: https://github.com/syntax-tree/unist-util-visit-parents#action
[vp-action-tuple]: https://github.com/syntax-tree/unist-util-visit-parents#actiontuple
[vp-build-visitor]: https://github.com/syntax-tree/unist-util-visit-parents#buildvisitor
[vp-index]: https://github.com/syntax-tree/unist-util-visit-parents#index
[vp-visitor-result]: https://github.com/syntax-tree/unist-util-visit-parents#visitorresult
[api-visit]: #visittree-test-visitor-reverse
[api-continue]: #continue
[api-exit]: #exit
[api-skip]: #skip
[api-action]: #action
[api-action-tuple]: #actiontuple
[api-build-visitor]: #buildvisitor
[api-index]: #index
[api-test]: #test
[api-visitor]: #visitor
[api-visitor-result]: #visitorresult