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/neotraverse/dist/modern/min/modern.js
generated
vendored
Normal file
1
node_modules/neotraverse/dist/modern/min/modern.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var e=e=>Object.prototype.toString.call(e),t=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),o=t=>"[object Date]"===e(t),n=t=>"[object RegExp]"===e(t),r=t=>"[object Error]"===e(t),s=t=>"[object Boolean]"===e(t),l=t=>"[object Number]"===e(t),i=t=>"[object String]"===e(t),c=Array.isArray,u=Object.getOwnPropertyDescriptor,a=Object.prototype.propertyIsEnumerable,f=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,h=Object.keys;function d(e){const t=h(e),o=f(e);for(let n=0;n<o.length;n++)a.call(e,o[n])&&t.push(o[n]);return t}function b(e,t){return!u(e,t)?.writable}function y(e,u){if("object"==typeof e&&null!==e){let a;if(c(e))a=[];else if(o(e))a=new Date(e.getTime?e.getTime():e);else if(n(e))a=new RegExp(e);else if(r(e))a={message:e.message};else if(s(e)||l(e)||i(e))a=Object(e);else{if(t(e))return e.slice();a=Object.create(Object.getPrototypeOf(e))}const f=u.includeSymbols?d:h;for(const t of f(e))a[t]=e[t];return a}return e}var g={includeSymbols:!1,immutable:!1};function m(e,t,o=g){const n=[],r=[];let s=!0;const l=o.includeSymbols?d:h,i=!!o.immutable;return function e(u){const a=i?y(u,o):u,f={};let h=!0;const d={node:a,node_:u,path:[].concat(n),parent:r[r.length-1],parents:r,key:n[n.length-1],isRoot:0===n.length,level:n.length,circular:void 0,isLeaf:!1,notLeaf:!0,notRoot:!0,isFirst:!1,isLast:!1,update:function(e,t=!1){d.isRoot||(d.parent.node[d.key]=e),d.node=e,t&&(h=!1)},delete:function(e){delete d.parent.node[d.key],e&&(h=!1)},remove:function(e){c(d.parent.node)?d.parent.node.splice(d.key,1):delete d.parent.node[d.key],e&&(h=!1)},keys:null,before:function(e){f.before=e},after:function(e){f.after=e},pre:function(e){f.pre=e},post:function(e){f.post=e},stop:function(){s=!1},block:function(){h=!1}};if(!s)return d;function g(){if("object"==typeof d.node&&null!==d.node){d.keys&&d.node_===d.node||(d.keys=l(d.node)),d.isLeaf=0===d.keys.length;for(let e=0;e<r.length;e++)if(r[e].node_===u){d.circular=r[e];break}}else d.isLeaf=!0,d.keys=null;d.notLeaf=!d.isLeaf,d.notRoot=!d.isRoot}g();const m=t(d,d.node);if(void 0!==m&&d.update&&d.update(m),f.before&&f.before(d,d.node),!h)return d;if("object"==typeof d.node&&null!==d.node&&!d.circular){r.push(d),g();for(const[t,o]of Object.entries(d.keys??[])){n.push(o),f.pre&&f.pre(d,d.node[o],o);const r=e(d.node[o]);i&&p.call(d.node,o)&&!b(d.node,o)&&(d.node[o]=r.node),r.isLast=!!d.keys?.length&&+t==d.keys.length-1,r.isFirst=0==+t,f.post&&f.post(d,r),n.pop()}r.pop()}return f.after&&f.after(d,d.node),d}(e).node}var j=class{#e;#t;constructor(e,t=g){this.#e=e,this.#t=t}get(e){let t=this.#e;for(let o=0;t&&o<e.length;o++){const n=e[o];if(!p.call(t,n)||!this.#t.includeSymbols&&"symbol"==typeof n)return;t=t[n]}return t}has(e){let t=this.#e;for(let o=0;t&&o<e.length;o++){const n=e[o];if(!p.call(t,n)||!this.#t.includeSymbols&&"symbol"==typeof n)return!1;t=t[n]}return!0}set(e,t){let o=this.#e,n=0;for(n=0;n<e.length-1;n++){const t=e[n];p.call(o,t)||(o[t]={}),o=o[t]}return o[e[n]]=t,t}map(e){return m(this.#e,e,{immutable:!0,includeSymbols:!!this.#t.includeSymbols})}forEach(e){return this.#e=m(this.#e,e,this.#t),this.#e}reduce(e,t){const o=1===arguments.length;let n=o?this.#e:t;return this.forEach(((t,r)=>{t.isRoot&&o||(n=e(t,n,r))})),n}paths(){const e=[];return this.forEach((t=>{e.push(t.path)})),e}nodes(){const e=[];return this.forEach((t=>{e.push(t.node)})),e}clone(){const e=[],o=[],n=this.#t;return t(this.#e)?this.#e.slice():function t(r){for(let t=0;t<e.length;t++)if(e[t]===r)return o[t];if("object"==typeof r&&null!==r){const s=y(r,n);e.push(r),o.push(s);const l=n.includeSymbols?d:h;for(const e of l(r))s[e]=t(r[e]);return e.pop(),o.pop(),s}return r}(this.#e)}};export{j as Traverse};
|
156
node_modules/neotraverse/dist/modern/modern.d.ts
generated
vendored
Normal file
156
node_modules/neotraverse/dist/modern/modern.d.ts
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
interface TraverseOptions {
|
||||
/**
|
||||
* If true, does not alter the original object
|
||||
*/
|
||||
immutable?: boolean;
|
||||
/**
|
||||
* If false, removes all symbols from traversed objects
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
includeSymbols?: boolean;
|
||||
}
|
||||
interface TraverseContext {
|
||||
/**
|
||||
* The present node on the recursive walk
|
||||
*/
|
||||
node: any;
|
||||
/**
|
||||
* An array of string keys from the root to the present node
|
||||
*/
|
||||
path: PropertyKey[];
|
||||
/**
|
||||
* The context of the node's parent.
|
||||
* This is `undefined` for the root node.
|
||||
*/
|
||||
parent: TraverseContext | undefined;
|
||||
/**
|
||||
* The contexts of the node's parents.
|
||||
*/
|
||||
parents: TraverseContext[];
|
||||
/**
|
||||
* The name of the key of the present node in its parent.
|
||||
* This is `undefined` for the root node.
|
||||
*/
|
||||
key: PropertyKey | undefined;
|
||||
/**
|
||||
* Whether the present node is the root node
|
||||
*/
|
||||
isRoot: boolean;
|
||||
/**
|
||||
* Whether the present node is not the root node
|
||||
*/
|
||||
notRoot: boolean;
|
||||
/**
|
||||
* Whether the present node is the last node
|
||||
*/
|
||||
isLast: boolean;
|
||||
/**
|
||||
* Whether the present node is the first node
|
||||
*/
|
||||
isFirst: boolean;
|
||||
/**
|
||||
* Whether or not the present node is a leaf node (has no children)
|
||||
*/
|
||||
isLeaf: boolean;
|
||||
/**
|
||||
* Whether or not the present node is not a leaf node (has children)
|
||||
*/
|
||||
notLeaf: boolean;
|
||||
/**
|
||||
* Depth of the node within the traversal
|
||||
*/
|
||||
level: number;
|
||||
/**
|
||||
* If the node equals one of its parents, the `circular` attribute is set to the context of that parent and the traversal progresses no deeper.
|
||||
*/
|
||||
circular: TraverseContext | undefined;
|
||||
/**
|
||||
* Set a new value for the present node.
|
||||
*
|
||||
* All the elements in `value` will be recursively traversed unless `stopHere` is true (false by default).
|
||||
*/
|
||||
update(value: any, stopHere?: boolean): void;
|
||||
/**
|
||||
* Remove the current element from the output. If the node is in an Array it will be spliced off. Otherwise it will be deleted from its parent.
|
||||
*/
|
||||
remove(stopHere?: boolean): void;
|
||||
/**
|
||||
* Delete the current element from its parent in the output. Calls `delete` even on Arrays.
|
||||
*/
|
||||
delete(stopHere?: boolean): void;
|
||||
/**
|
||||
* Object keys of the node.
|
||||
*/
|
||||
keys: PropertyKey[] | null;
|
||||
/**
|
||||
* Call this function before all of the children are traversed.
|
||||
* You can assign into `ctx.keys` here to traverse in a custom order.
|
||||
*/
|
||||
before(callback: (ctx: TraverseContext, value: any) => void): void;
|
||||
/**
|
||||
* Call this function after all of the children are traversed.
|
||||
*/
|
||||
after(callback: (ctx: TraverseContext, value: any) => void): void;
|
||||
/**
|
||||
* Call this function before each of the children are traversed.
|
||||
*/
|
||||
pre(callback: (ctx: TraverseContext, child: any, key: any) => void): void;
|
||||
/**
|
||||
* Call this function after each of the children are traversed.
|
||||
*/
|
||||
post(callback: (ctx: TraverseContext, child: any) => void): void;
|
||||
/**
|
||||
* Stops traversal entirely.
|
||||
*/
|
||||
stop(): void;
|
||||
/**
|
||||
* Prevents traversing descendents of the current node.
|
||||
*/
|
||||
block(): void;
|
||||
}
|
||||
declare class Traverse {
|
||||
#private;
|
||||
constructor(obj: any, options?: TraverseOptions);
|
||||
/**
|
||||
* Get the element at the array `path`.
|
||||
*/
|
||||
get(paths: PropertyKey[]): any;
|
||||
/**
|
||||
* Return whether the element at the array `path` exists.
|
||||
*/
|
||||
has(paths: PropertyKey[]): boolean;
|
||||
/**
|
||||
* Set the element at the array `path` to `value`.
|
||||
*/
|
||||
set(path: PropertyKey[], value: any): any;
|
||||
/**
|
||||
* Execute `fn` for each node in the object and return a new object with the results of the walk. To update nodes in the result use `this.update(value)`.
|
||||
*/
|
||||
map(cb: (ctx: TraverseContext, v: any) => void): any;
|
||||
/**
|
||||
* Execute `fn` for each node in the object but unlike `.map()`, when `this.update()` is called it updates the object in-place.
|
||||
*/
|
||||
forEach(cb: (ctx: TraverseContext, v: any) => void): any;
|
||||
/**
|
||||
* For each node in the object, perform a [left-fold](http://en.wikipedia.org/wiki/Fold_(higher-order_function)) with the return value of `fn(acc, node)`.
|
||||
*
|
||||
* If `init` isn't specified, `init` is set to the root object for the first step and the root element is skipped.
|
||||
*/
|
||||
reduce(cb: (ctx: TraverseContext, acc: any, v: any) => void, init?: any): any;
|
||||
/**
|
||||
* Return an `Array` of every possible non-cyclic path in the object.
|
||||
* Paths are `Array`s of string keys.
|
||||
*/
|
||||
paths(): PropertyKey[][];
|
||||
/**
|
||||
* Return an `Array` of every node in the object.
|
||||
*/
|
||||
nodes(): any[];
|
||||
/**
|
||||
* Create a deep clone of the object.
|
||||
*/
|
||||
clone(): any;
|
||||
}
|
||||
|
||||
export { Traverse, type TraverseContext, type TraverseOptions };
|
326
node_modules/neotraverse/dist/modern/modern.js
generated
vendored
Normal file
326
node_modules/neotraverse/dist/modern/modern.js
generated
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
// src/modern.ts
|
||||
var to_string = (obj) => Object.prototype.toString.call(obj);
|
||||
var is_typed_array = (value) => ArrayBuffer.isView(value) && !(value instanceof DataView);
|
||||
var is_date = (obj) => to_string(obj) === "[object Date]";
|
||||
var is_regexp = (obj) => to_string(obj) === "[object RegExp]";
|
||||
var is_error = (obj) => to_string(obj) === "[object Error]";
|
||||
var is_boolean = (obj) => to_string(obj) === "[object Boolean]";
|
||||
var is_number = (obj) => to_string(obj) === "[object Number]";
|
||||
var is_string = (obj) => to_string(obj) === "[object String]";
|
||||
var is_array = Array.isArray;
|
||||
var gopd = Object.getOwnPropertyDescriptor;
|
||||
var is_property_enumerable = Object.prototype.propertyIsEnumerable;
|
||||
var get_own_property_symbols = Object.getOwnPropertySymbols;
|
||||
var has_own_property = Object.prototype.hasOwnProperty;
|
||||
var object_keys = Object.keys;
|
||||
function own_enumerable_keys(obj) {
|
||||
const res = object_keys(obj);
|
||||
const symbols = get_own_property_symbols(obj);
|
||||
for (let i = 0; i < symbols.length; i++) {
|
||||
if (is_property_enumerable.call(obj, symbols[i])) {
|
||||
res.push(symbols[i]);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function is_writable(object, key) {
|
||||
return !gopd(object, key)?.writable;
|
||||
}
|
||||
function copy(src, options) {
|
||||
if (typeof src === "object" && src !== null) {
|
||||
let dst;
|
||||
if (is_array(src)) {
|
||||
dst = [];
|
||||
} else if (is_date(src)) {
|
||||
dst = new Date(src.getTime ? src.getTime() : src);
|
||||
} else if (is_regexp(src)) {
|
||||
dst = new RegExp(src);
|
||||
} else if (is_error(src)) {
|
||||
dst = { message: src.message };
|
||||
} else if (is_boolean(src) || is_number(src) || is_string(src)) {
|
||||
dst = Object(src);
|
||||
} else if (is_typed_array(src)) {
|
||||
return src.slice();
|
||||
} else {
|
||||
dst = Object.create(Object.getPrototypeOf(src));
|
||||
}
|
||||
const iterator_function = options.includeSymbols ? own_enumerable_keys : object_keys;
|
||||
for (const key of iterator_function(src)) {
|
||||
dst[key] = src[key];
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
return src;
|
||||
}
|
||||
var empty_null = {
|
||||
includeSymbols: false,
|
||||
immutable: false
|
||||
};
|
||||
function walk(root, cb, options = empty_null) {
|
||||
const path = [];
|
||||
const parents = [];
|
||||
let alive = true;
|
||||
const iterator_function = options.includeSymbols ? own_enumerable_keys : object_keys;
|
||||
const immutable = !!options.immutable;
|
||||
return function walker(node_) {
|
||||
const node = immutable ? copy(node_, options) : node_;
|
||||
const modifiers = {};
|
||||
let keep_going = true;
|
||||
const state = {
|
||||
node,
|
||||
node_,
|
||||
path: [].concat(path),
|
||||
parent: parents[parents.length - 1],
|
||||
parents,
|
||||
key: path[path.length - 1],
|
||||
isRoot: path.length === 0,
|
||||
level: path.length,
|
||||
circular: void 0,
|
||||
isLeaf: false,
|
||||
notLeaf: true,
|
||||
notRoot: true,
|
||||
isFirst: false,
|
||||
isLast: false,
|
||||
update: function(x, stopHere = false) {
|
||||
if (!state.isRoot) {
|
||||
state.parent.node[state.key] = x;
|
||||
}
|
||||
state.node = x;
|
||||
if (stopHere) {
|
||||
keep_going = false;
|
||||
}
|
||||
},
|
||||
delete: function(stopHere) {
|
||||
delete state.parent.node[state.key];
|
||||
if (stopHere) {
|
||||
keep_going = false;
|
||||
}
|
||||
},
|
||||
remove: function(stopHere) {
|
||||
if (is_array(state.parent.node)) {
|
||||
state.parent.node.splice(state.key, 1);
|
||||
} else {
|
||||
delete state.parent.node[state.key];
|
||||
}
|
||||
if (stopHere) {
|
||||
keep_going = false;
|
||||
}
|
||||
},
|
||||
keys: null,
|
||||
before: function(f) {
|
||||
modifiers.before = f;
|
||||
},
|
||||
after: function(f) {
|
||||
modifiers.after = f;
|
||||
},
|
||||
pre: function(f) {
|
||||
modifiers.pre = f;
|
||||
},
|
||||
post: function(f) {
|
||||
modifiers.post = f;
|
||||
},
|
||||
stop: function() {
|
||||
alive = false;
|
||||
},
|
||||
block: function() {
|
||||
keep_going = false;
|
||||
}
|
||||
};
|
||||
if (!alive) {
|
||||
return state;
|
||||
}
|
||||
function update_state() {
|
||||
if (typeof state.node === "object" && state.node !== null) {
|
||||
if (!state.keys || state.node_ !== state.node) {
|
||||
state.keys = iterator_function(state.node);
|
||||
}
|
||||
state.isLeaf = state.keys.length === 0;
|
||||
for (let i = 0; i < parents.length; i++) {
|
||||
if (parents[i].node_ === node_) {
|
||||
state.circular = parents[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
state.isLeaf = true;
|
||||
state.keys = null;
|
||||
}
|
||||
state.notLeaf = !state.isLeaf;
|
||||
state.notRoot = !state.isRoot;
|
||||
}
|
||||
update_state();
|
||||
const ret = cb(state, state.node);
|
||||
if (ret !== void 0 && state.update) {
|
||||
state.update(ret);
|
||||
}
|
||||
if (modifiers.before) {
|
||||
modifiers.before(state, state.node);
|
||||
}
|
||||
if (!keep_going) {
|
||||
return state;
|
||||
}
|
||||
if (typeof state.node === "object" && state.node !== null && !state.circular) {
|
||||
parents.push(state);
|
||||
update_state();
|
||||
for (const [index, key] of Object.entries(state.keys ?? [])) {
|
||||
path.push(key);
|
||||
if (modifiers.pre) {
|
||||
modifiers.pre(state, state.node[key], key);
|
||||
}
|
||||
const child = walker(state.node[key]);
|
||||
if (immutable && has_own_property.call(state.node, key) && !is_writable(state.node, key)) {
|
||||
state.node[key] = child.node;
|
||||
}
|
||||
child.isLast = state.keys?.length ? +index === state.keys.length - 1 : false;
|
||||
child.isFirst = +index === 0;
|
||||
if (modifiers.post) {
|
||||
modifiers.post(state, child);
|
||||
}
|
||||
path.pop();
|
||||
}
|
||||
parents.pop();
|
||||
}
|
||||
if (modifiers.after) {
|
||||
modifiers.after(state, state.node);
|
||||
}
|
||||
return state;
|
||||
}(root).node;
|
||||
}
|
||||
var Traverse = class {
|
||||
#value;
|
||||
#options;
|
||||
constructor(obj, options = empty_null) {
|
||||
this.#value = obj;
|
||||
this.#options = options;
|
||||
}
|
||||
/**
|
||||
* Get the element at the array `path`.
|
||||
*/
|
||||
get(paths) {
|
||||
let node = this.#value;
|
||||
for (let i = 0; node && i < paths.length; i++) {
|
||||
const key = paths[i];
|
||||
if (!has_own_property.call(node, key) || !this.#options.includeSymbols && typeof key === "symbol") {
|
||||
return void 0;
|
||||
}
|
||||
node = node[key];
|
||||
}
|
||||
return node;
|
||||
}
|
||||
/**
|
||||
* Return whether the element at the array `path` exists.
|
||||
*/
|
||||
has(paths) {
|
||||
let node = this.#value;
|
||||
for (let i = 0; node && i < paths.length; i++) {
|
||||
const key = paths[i];
|
||||
if (!has_own_property.call(node, key) || !this.#options.includeSymbols && typeof key === "symbol") {
|
||||
return false;
|
||||
}
|
||||
node = node[key];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Set the element at the array `path` to `value`.
|
||||
*/
|
||||
set(path, value) {
|
||||
let node = this.#value;
|
||||
let i = 0;
|
||||
for (i = 0; i < path.length - 1; i++) {
|
||||
const key = path[i];
|
||||
if (!has_own_property.call(node, key)) {
|
||||
node[key] = {};
|
||||
}
|
||||
node = node[key];
|
||||
}
|
||||
node[path[i]] = value;
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* Execute `fn` for each node in the object and return a new object with the results of the walk. To update nodes in the result use `this.update(value)`.
|
||||
*/
|
||||
map(cb) {
|
||||
return walk(this.#value, cb, {
|
||||
immutable: true,
|
||||
includeSymbols: !!this.#options.includeSymbols
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Execute `fn` for each node in the object but unlike `.map()`, when `this.update()` is called it updates the object in-place.
|
||||
*/
|
||||
forEach(cb) {
|
||||
this.#value = walk(this.#value, cb, this.#options);
|
||||
return this.#value;
|
||||
}
|
||||
/**
|
||||
* For each node in the object, perform a [left-fold](http://en.wikipedia.org/wiki/Fold_(higher-order_function)) with the return value of `fn(acc, node)`.
|
||||
*
|
||||
* If `init` isn't specified, `init` is set to the root object for the first step and the root element is skipped.
|
||||
*/
|
||||
reduce(cb, init) {
|
||||
const skip = arguments.length === 1;
|
||||
let acc = skip ? this.#value : init;
|
||||
this.forEach((ctx, x) => {
|
||||
if (!ctx.isRoot || !skip) {
|
||||
acc = cb(ctx, acc, x);
|
||||
}
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
/**
|
||||
* Return an `Array` of every possible non-cyclic path in the object.
|
||||
* Paths are `Array`s of string keys.
|
||||
*/
|
||||
paths() {
|
||||
const acc = [];
|
||||
this.forEach((ctx) => {
|
||||
acc.push(ctx.path);
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
/**
|
||||
* Return an `Array` of every node in the object.
|
||||
*/
|
||||
nodes() {
|
||||
const acc = [];
|
||||
this.forEach((ctx) => {
|
||||
acc.push(ctx.node);
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
/**
|
||||
* Create a deep clone of the object.
|
||||
*/
|
||||
clone() {
|
||||
const parents = [];
|
||||
const nodes = [];
|
||||
const options = this.#options;
|
||||
if (is_typed_array(this.#value)) {
|
||||
return this.#value.slice();
|
||||
}
|
||||
return function clone(src) {
|
||||
for (let i = 0; i < parents.length; i++) {
|
||||
if (parents[i] === src) {
|
||||
return nodes[i];
|
||||
}
|
||||
}
|
||||
if (typeof src === "object" && src !== null) {
|
||||
const dst = copy(src, options);
|
||||
parents.push(src);
|
||||
nodes.push(dst);
|
||||
const iteratorFunction = options.includeSymbols ? own_enumerable_keys : object_keys;
|
||||
for (const key of iteratorFunction(src)) {
|
||||
dst[key] = clone(src[key]);
|
||||
}
|
||||
parents.pop();
|
||||
nodes.pop();
|
||||
return dst;
|
||||
}
|
||||
return src;
|
||||
}(this.#value);
|
||||
}
|
||||
};
|
||||
export {
|
||||
Traverse
|
||||
};
|
Reference in New Issue
Block a user