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:
74
node_modules/unist-util-find-after/lib/index.d.ts
generated
vendored
Normal file
74
node_modules/unist-util-find-after/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Find the first node in `parent` after another `node` or after an index,
|
||||
* that passes `test`.
|
||||
*
|
||||
* @param parent
|
||||
* Parent node.
|
||||
* @param index
|
||||
* Child node or index.
|
||||
* @param [test=undefined]
|
||||
* Test for child to look for (optional).
|
||||
* @returns
|
||||
* A child (matching `test`, if given) or `undefined`.
|
||||
*/
|
||||
export const findAfter: (<
|
||||
Kind extends import('unist').Parent,
|
||||
Check extends Test
|
||||
>(
|
||||
parent: Kind,
|
||||
index: number | Child<Kind>,
|
||||
test: Check
|
||||
) => Matches<Child<Kind>, Check> | undefined) &
|
||||
(<Kind_1 extends import('unist').Parent>(
|
||||
parent: Kind_1,
|
||||
index: number | Child<Kind_1>,
|
||||
test?: null | undefined
|
||||
) => Child<Kind_1> | undefined)
|
||||
export type UnistNode = import('unist').Node
|
||||
export type UnistParent = import('unist').Parent
|
||||
/**
|
||||
* 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 doesn’t 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>
|
||||
/**
|
||||
* Collect nodes that can be parents of `Child`.
|
||||
*/
|
||||
export type Child<Kind extends import('unist').Node> = Kind extends {
|
||||
children: (infer Child_1)[]
|
||||
}
|
||||
? Child_1
|
||||
: never
|
130
node_modules/unist-util-find-after/lib/index.js
generated
vendored
Normal file
130
node_modules/unist-util-find-after/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* @typedef {import('unist').Node} UnistNode
|
||||
* @typedef {import('unist').Parent} UnistParent
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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 doesn’t work when publishing on npm.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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 {(
|
||||
* Kind extends {children: Array<infer Child>}
|
||||
* ? Child
|
||||
* : never
|
||||
* )} Child
|
||||
* Collect nodes that can be parents of `Child`.
|
||||
* @template {UnistNode} Kind
|
||||
* All node types.
|
||||
*/
|
||||
|
||||
import {convert} from 'unist-util-is'
|
||||
|
||||
/**
|
||||
* Find the first node in `parent` after another `node` or after an index,
|
||||
* that passes `test`.
|
||||
*
|
||||
* @param parent
|
||||
* Parent node.
|
||||
* @param index
|
||||
* Child node or index.
|
||||
* @param [test=undefined]
|
||||
* Test for child to look for (optional).
|
||||
* @returns
|
||||
* A child (matching `test`, if given) or `undefined`.
|
||||
*/
|
||||
export const findAfter =
|
||||
// Note: overloads like this are needed to support optional generics.
|
||||
/**
|
||||
* @type {(
|
||||
* (<Kind extends UnistParent, Check extends Test>(parent: Kind, index: Child<Kind> | number, test: Check) => Matches<Child<Kind>, Check> | undefined) &
|
||||
* (<Kind extends UnistParent>(parent: Kind, index: Child<Kind> | number, test?: null | undefined) => Child<Kind> | undefined)
|
||||
* )}
|
||||
*/
|
||||
(
|
||||
/**
|
||||
* @param {UnistParent} parent
|
||||
* @param {UnistNode | number} index
|
||||
* @param {Test} [test]
|
||||
* @returns {UnistNode | undefined}
|
||||
*/
|
||||
function (parent, index, test) {
|
||||
const is = convert(test)
|
||||
|
||||
if (!parent || !parent.type || !parent.children) {
|
||||
throw new Error('Expected parent node')
|
||||
}
|
||||
|
||||
if (typeof index === 'number') {
|
||||
if (index < 0 || index === Number.POSITIVE_INFINITY) {
|
||||
throw new Error('Expected positive finite number as index')
|
||||
}
|
||||
} else {
|
||||
index = parent.children.indexOf(index)
|
||||
|
||||
if (index < 0) {
|
||||
throw new Error('Expected child node or index')
|
||||
}
|
||||
}
|
||||
|
||||
while (++index < parent.children.length) {
|
||||
if (is(parent.children[index], index, parent)) {
|
||||
return parent.children[index]
|
||||
}
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
)
|
Reference in New Issue
Block a user