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:
199
node_modules/neotraverse/dist/index.d.ts
generated
vendored
Normal file
199
node_modules/neotraverse/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
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 `this.keys` here to traverse in a custom order.
|
||||
*/
|
||||
before(callback: (this: TraverseContext, value: any) => void): void;
|
||||
/**
|
||||
* Call this function after all of the children are traversed.
|
||||
*/
|
||||
after(callback: (this: TraverseContext, value: any) => void): void;
|
||||
/**
|
||||
* Call this function before each of the children are traversed.
|
||||
*/
|
||||
pre(callback: (this: TraverseContext, child: any, key: any) => void): void;
|
||||
/**
|
||||
* Call this function after each of the children are traversed.
|
||||
*/
|
||||
post(callback: (this: TraverseContext, child: any) => void): void;
|
||||
/**
|
||||
* Stops traversal entirely.
|
||||
*/
|
||||
stop(): void;
|
||||
/**
|
||||
* Prevents traversing descendents of the current node.
|
||||
*/
|
||||
block(): void;
|
||||
}
|
||||
/** @deprecated Import `Traverse` from `neotraverse/modern` instead */
|
||||
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: (this: 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: (this: 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: (this: 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;
|
||||
}
|
||||
declare const traverse: {
|
||||
(obj: any, options?: TraverseOptions): Traverse;
|
||||
/**
|
||||
* Get the element at the array `path`.
|
||||
*/
|
||||
get(obj: any, paths: PropertyKey[], options?: TraverseOptions): any;
|
||||
/**
|
||||
* Set the element at the array `path` to `value`.
|
||||
*/
|
||||
set(obj: any, path: PropertyKey[], value: any, options?: TraverseOptions): any;
|
||||
/**
|
||||
* Return whether the element at the array `path` exists.
|
||||
*/
|
||||
has(obj: any, paths: PropertyKey[], options?: TraverseOptions): boolean;
|
||||
/**
|
||||
* 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(obj: any, cb: (this: TraverseContext, v: any) => void, options?: TraverseOptions): any;
|
||||
/**
|
||||
* Execute `fn` for each node in the object but unlike `.map()`, when `this.update()` is called it updates the object in-place.
|
||||
*/
|
||||
forEach(obj: any, cb: (this: TraverseContext, v: any) => void, options?: TraverseOptions): 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(obj: any, cb: (this: TraverseContext, acc: any, v: any) => void, init?: any, options?: TraverseOptions): any;
|
||||
/**
|
||||
* Return an `Array` of every possible non-cyclic path in the object.
|
||||
* Paths are `Array`s of string keys.
|
||||
*/
|
||||
paths(obj: any, options?: TraverseOptions): PropertyKey[][];
|
||||
/**
|
||||
* Return an `Array` of every node in the object.
|
||||
*/
|
||||
nodes(obj: any, options?: TraverseOptions): any[];
|
||||
/**
|
||||
* Create a deep clone of the object.
|
||||
*/
|
||||
clone(obj: any, options?: TraverseOptions): any;
|
||||
};
|
||||
|
||||
export { Traverse, type TraverseContext, type TraverseOptions, traverse as default };
|
358
node_modules/neotraverse/dist/index.js
generated
vendored
Normal file
358
node_modules/neotraverse/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,358 @@
|
||||
// src/index.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;
|
||||
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.call(state, state.node);
|
||||
if (ret !== void 0 && state.update) {
|
||||
state.update(ret);
|
||||
}
|
||||
if (modifiers.before) {
|
||||
modifiers.before.call(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.call(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.call(state, child);
|
||||
}
|
||||
path.pop();
|
||||
}
|
||||
parents.pop();
|
||||
}
|
||||
if (modifiers.after) {
|
||||
modifiers.after.call(state, state.node);
|
||||
}
|
||||
return state;
|
||||
}(root).node;
|
||||
}
|
||||
var Traverse = class {
|
||||
// ! Have to keep these public as legacy mode requires them
|
||||
#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(function(x) {
|
||||
if (!this.isRoot || !skip) {
|
||||
acc = cb.call(this, 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(function() {
|
||||
acc.push(this.path);
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
/**
|
||||
* Return an `Array` of every node in the object.
|
||||
*/
|
||||
nodes() {
|
||||
const acc = [];
|
||||
this.forEach(function() {
|
||||
acc.push(this.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);
|
||||
}
|
||||
};
|
||||
var traverse = (obj, options) => {
|
||||
return new Traverse(obj, options);
|
||||
};
|
||||
traverse.get = (obj, paths, options) => {
|
||||
return new Traverse(obj, options).get(paths);
|
||||
};
|
||||
traverse.set = (obj, path, value, options) => {
|
||||
return new Traverse(obj, options).set(path, value);
|
||||
};
|
||||
traverse.has = (obj, paths, options) => {
|
||||
return new Traverse(obj, options).has(paths);
|
||||
};
|
||||
traverse.map = (obj, cb, options) => {
|
||||
return new Traverse(obj, options).map(cb);
|
||||
};
|
||||
traverse.forEach = (obj, cb, options) => {
|
||||
return new Traverse(obj, options).forEach(cb);
|
||||
};
|
||||
traverse.reduce = (obj, cb, init, options) => {
|
||||
return new Traverse(obj, options).reduce(cb, init);
|
||||
};
|
||||
traverse.paths = (obj, options) => {
|
||||
return new Traverse(obj, options).paths();
|
||||
};
|
||||
traverse.nodes = (obj, options) => {
|
||||
return new Traverse(obj, options).nodes();
|
||||
};
|
||||
traverse.clone = (obj, options) => {
|
||||
return new Traverse(obj, options).clone();
|
||||
};
|
||||
var src_default = traverse;
|
||||
export {
|
||||
Traverse,
|
||||
src_default as default
|
||||
};
|
602
node_modules/neotraverse/dist/legacy/legacy.cjs
generated
vendored
Normal file
602
node_modules/neotraverse/dist/legacy/legacy.cjs
generated
vendored
Normal file
@@ -0,0 +1,602 @@
|
||||
"use strict";
|
||||
function _array_like_to_array(arr, len) {
|
||||
if (len == null || len > arr.length) len = arr.length;
|
||||
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
||||
return arr2;
|
||||
}
|
||||
function _array_with_holes(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
function _class_call_check(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
function _defineProperties(target, props) {
|
||||
for(var i = 0; i < props.length; i++){
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
function _create_class(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
}
|
||||
function _instanceof(left, right) {
|
||||
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
||||
return !!right[Symbol.hasInstance](left);
|
||||
} else {
|
||||
return left instanceof right;
|
||||
}
|
||||
}
|
||||
function _iterable_to_array_limit(arr, i) {
|
||||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
||||
if (_i == null) return;
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _s, _e;
|
||||
try {
|
||||
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
||||
_arr.push(_s.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_n && _i["return"] != null) _i["return"]();
|
||||
} finally{
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
}
|
||||
function _non_iterable_rest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
function _sliced_to_array(arr, i) {
|
||||
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
||||
}
|
||||
function _type_of(obj) {
|
||||
"@swc/helpers - typeof";
|
||||
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
||||
}
|
||||
function _unsupported_iterable_to_array(o, minLen) {
|
||||
if (!o) return;
|
||||
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
||||
var n = Object.prototype.toString.call(o).slice(8, -1);
|
||||
if (n === "Object" && o.constructor) n = o.constructor.name;
|
||||
if (n === "Map" || n === "Set") return Array.from(n);
|
||||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
||||
}
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __typeError = function(msg) {
|
||||
throw TypeError(msg);
|
||||
};
|
||||
var __export = function(target, all) {
|
||||
for(var name in all)__defProp(target, name, {
|
||||
get: all[name],
|
||||
enumerable: true
|
||||
});
|
||||
};
|
||||
var __copyProps = function(to, from, except, desc) {
|
||||
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
||||
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
||||
try {
|
||||
var _loop = function() {
|
||||
var key = _step.value;
|
||||
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
||||
get: function() {
|
||||
return from[key];
|
||||
},
|
||||
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
||||
});
|
||||
};
|
||||
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = function(mod) {
|
||||
return __copyProps(__defProp({}, "__esModule", {
|
||||
value: true
|
||||
}), mod);
|
||||
};
|
||||
var __accessCheck = function(obj, member, msg) {
|
||||
return member.has(obj) || __typeError("Cannot " + msg);
|
||||
};
|
||||
var __privateGet = function(obj, member, getter) {
|
||||
return __accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj);
|
||||
};
|
||||
var __privateAdd = function(obj, member, value) {
|
||||
return member.has(obj) ? __typeError("Cannot add the same private member more than once") : _instanceof(member, WeakSet) ? member.add(obj) : member.set(obj, value);
|
||||
};
|
||||
var __privateSet = function(obj, member, value, setter) {
|
||||
return __accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value;
|
||||
};
|
||||
// src/legacy.cts
|
||||
var legacy_exports = {};
|
||||
__export(legacy_exports, {
|
||||
default: function() {
|
||||
return src_default;
|
||||
}
|
||||
});
|
||||
module.exports = __toCommonJS(legacy_exports);
|
||||
// src/index.ts
|
||||
var to_string = function(obj) {
|
||||
return Object.prototype.toString.call(obj);
|
||||
};
|
||||
var is_typed_array = function(value) {
|
||||
return ArrayBuffer.isView(value) && !_instanceof(value, DataView);
|
||||
};
|
||||
var is_date = function(obj) {
|
||||
return to_string(obj) === "[object Date]";
|
||||
};
|
||||
var is_regexp = function(obj) {
|
||||
return to_string(obj) === "[object RegExp]";
|
||||
};
|
||||
var is_error = function(obj) {
|
||||
return to_string(obj) === "[object Error]";
|
||||
};
|
||||
var is_boolean = function(obj) {
|
||||
return to_string(obj) === "[object Boolean]";
|
||||
};
|
||||
var is_number = function(obj) {
|
||||
return to_string(obj) === "[object Number]";
|
||||
};
|
||||
var is_string = function(obj) {
|
||||
return 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;
|
||||
function own_enumerable_keys(obj) {
|
||||
var res = Object.keys(obj);
|
||||
var symbols = get_own_property_symbols(obj);
|
||||
for(var 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) {
|
||||
var _gopd;
|
||||
return !((_gopd = gopd(object, key)) === null || _gopd === void 0 ? void 0 : _gopd.writable);
|
||||
}
|
||||
function copy(src, options) {
|
||||
if ((typeof src === "undefined" ? "undefined" : _type_of(src)) === "object" && src !== null) {
|
||||
var 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));
|
||||
}
|
||||
var iterator_function = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
||||
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
||||
try {
|
||||
for(var _iterator = iterator_function(src)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
||||
var key = _step.value;
|
||||
dst[key] = src[key];
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
return src;
|
||||
}
|
||||
var empty_null = {
|
||||
includeSymbols: false,
|
||||
immutable: false
|
||||
};
|
||||
function walk(root, cb) {
|
||||
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : empty_null;
|
||||
var path = [];
|
||||
var parents = [];
|
||||
var alive = true;
|
||||
var iterator_function = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
||||
var immutable = !!options.immutable;
|
||||
return function walker(node_) {
|
||||
var node = immutable ? copy(node_, options) : node_;
|
||||
var modifiers = {};
|
||||
var keep_going = true;
|
||||
var state = {
|
||||
node: node,
|
||||
node_: node_,
|
||||
path: [].concat(path),
|
||||
parent: parents[parents.length - 1],
|
||||
parents: 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 update(x) {
|
||||
var stopHere = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
||||
if (!state.isRoot) {
|
||||
state.parent.node[state.key] = x;
|
||||
}
|
||||
state.node = x;
|
||||
if (stopHere) {
|
||||
keep_going = false;
|
||||
}
|
||||
},
|
||||
delete: function _delete(stopHere) {
|
||||
delete state.parent.node[state.key];
|
||||
if (stopHere) {
|
||||
keep_going = false;
|
||||
}
|
||||
},
|
||||
remove: function remove(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 before(f) {
|
||||
modifiers.before = f;
|
||||
},
|
||||
after: function after(f) {
|
||||
modifiers.after = f;
|
||||
},
|
||||
pre: function pre(f) {
|
||||
modifiers.pre = f;
|
||||
},
|
||||
post: function post(f) {
|
||||
modifiers.post = f;
|
||||
},
|
||||
stop: function stop() {
|
||||
alive = false;
|
||||
},
|
||||
block: function block() {
|
||||
keep_going = false;
|
||||
}
|
||||
};
|
||||
if (!alive) {
|
||||
return state;
|
||||
}
|
||||
function update_state() {
|
||||
if (_type_of(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(var 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();
|
||||
var ret = cb.call(state, state.node);
|
||||
if (ret !== void 0 && state.update) {
|
||||
state.update(ret);
|
||||
}
|
||||
if (modifiers.before) {
|
||||
modifiers.before.call(state, state.node);
|
||||
}
|
||||
if (!keep_going) {
|
||||
return state;
|
||||
}
|
||||
if (_type_of(state.node) === "object" && state.node !== null && !state.circular) {
|
||||
parents.push(state);
|
||||
update_state();
|
||||
var _state_keys;
|
||||
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
||||
try {
|
||||
for(var _iterator = Object.entries((_state_keys = state.keys) !== null && _state_keys !== void 0 ? _state_keys : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
||||
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], key = _step_value[1];
|
||||
var _state_keys1;
|
||||
path.push(key);
|
||||
if (modifiers.pre) {
|
||||
modifiers.pre.call(state, state.node[key], key);
|
||||
}
|
||||
var 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_keys1 = state.keys) === null || _state_keys1 === void 0 ? void 0 : _state_keys1.length) ? +index === state.keys.length - 1 : false;
|
||||
child.isFirst = +index === 0;
|
||||
if (modifiers.post) {
|
||||
modifiers.post.call(state, child);
|
||||
}
|
||||
path.pop();
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
parents.pop();
|
||||
}
|
||||
if (modifiers.after) {
|
||||
modifiers.after.call(state, state.node);
|
||||
}
|
||||
return state;
|
||||
}(root).node;
|
||||
}
|
||||
var _value, _options;
|
||||
var Traverse = /*#__PURE__*/ function() {
|
||||
function Traverse(obj) {
|
||||
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : empty_null;
|
||||
_class_call_check(this, Traverse);
|
||||
// ! Have to keep these public as legacy mode requires them
|
||||
__privateAdd(this, _value);
|
||||
__privateAdd(this, _options);
|
||||
__privateSet(this, _value, obj);
|
||||
__privateSet(this, _options, options);
|
||||
}
|
||||
_create_class(Traverse, [
|
||||
{
|
||||
/**
|
||||
* Get the element at the array `path`.
|
||||
*/ key: "get",
|
||||
value: function get(paths) {
|
||||
var node = __privateGet(this, _value);
|
||||
for(var i = 0; node && i < paths.length; i++){
|
||||
var key = paths[i];
|
||||
if (!has_own_property.call(node, key) || !__privateGet(this, _options).includeSymbols && (typeof key === "undefined" ? "undefined" : _type_of(key)) === "symbol") {
|
||||
return void 0;
|
||||
}
|
||||
node = node[key];
|
||||
}
|
||||
return node;
|
||||
}
|
||||
},
|
||||
{
|
||||
/**
|
||||
* Return whether the element at the array `path` exists.
|
||||
*/ key: "has",
|
||||
value: function has(paths) {
|
||||
var node = __privateGet(this, _value);
|
||||
for(var i = 0; node && i < paths.length; i++){
|
||||
var key = paths[i];
|
||||
if (!has_own_property.call(node, key) || !__privateGet(this, _options).includeSymbols && (typeof key === "undefined" ? "undefined" : _type_of(key)) === "symbol") {
|
||||
return false;
|
||||
}
|
||||
node = node[key];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
/**
|
||||
* Set the element at the array `path` to `value`.
|
||||
*/ key: "set",
|
||||
value: function set(path, value) {
|
||||
var node = __privateGet(this, _value);
|
||||
var i = 0;
|
||||
for(i = 0; i < path.length - 1; i++){
|
||||
var 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)`.
|
||||
*/ key: "map",
|
||||
value: function map(cb) {
|
||||
return walk(__privateGet(this, _value), cb, {
|
||||
immutable: true,
|
||||
includeSymbols: !!__privateGet(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.
|
||||
*/ key: "forEach",
|
||||
value: function forEach(cb) {
|
||||
__privateSet(this, _value, walk(__privateGet(this, _value), cb, __privateGet(this, _options)));
|
||||
return __privateGet(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.
|
||||
*/ key: "reduce",
|
||||
value: function reduce(cb, init) {
|
||||
var skip = arguments.length === 1;
|
||||
var acc = skip ? __privateGet(this, _value) : init;
|
||||
this.forEach(function(x) {
|
||||
if (!this.isRoot || !skip) {
|
||||
acc = cb.call(this, acc, x);
|
||||
}
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
},
|
||||
{
|
||||
/**
|
||||
* Return an `Array` of every possible non-cyclic path in the object.
|
||||
* Paths are `Array`s of string keys.
|
||||
*/ key: "paths",
|
||||
value: function paths() {
|
||||
var acc = [];
|
||||
this.forEach(function() {
|
||||
acc.push(this.path);
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
},
|
||||
{
|
||||
/**
|
||||
* Return an `Array` of every node in the object.
|
||||
*/ key: "nodes",
|
||||
value: function nodes() {
|
||||
var acc = [];
|
||||
this.forEach(function() {
|
||||
acc.push(this.node);
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
},
|
||||
{
|
||||
/**
|
||||
* Create a deep clone of the object.
|
||||
*/ key: "clone",
|
||||
value: function clone() {
|
||||
var parents = [];
|
||||
var nodes = [];
|
||||
var options = __privateGet(this, _options);
|
||||
if (is_typed_array(__privateGet(this, _value))) {
|
||||
return __privateGet(this, _value).slice();
|
||||
}
|
||||
return function clone(src) {
|
||||
for(var i = 0; i < parents.length; i++){
|
||||
if (parents[i] === src) {
|
||||
return nodes[i];
|
||||
}
|
||||
}
|
||||
if ((typeof src === "undefined" ? "undefined" : _type_of(src)) === "object" && src !== null) {
|
||||
var dst = copy(src, options);
|
||||
parents.push(src);
|
||||
nodes.push(dst);
|
||||
var iteratorFunction = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
||||
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
||||
try {
|
||||
for(var _iterator = iteratorFunction(src)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
||||
var key = _step.value;
|
||||
dst[key] = clone(src[key]);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
parents.pop();
|
||||
nodes.pop();
|
||||
return dst;
|
||||
}
|
||||
return src;
|
||||
}(__privateGet(this, _value));
|
||||
}
|
||||
}
|
||||
]);
|
||||
return Traverse;
|
||||
}();
|
||||
_value = new WeakMap();
|
||||
_options = new WeakMap();
|
||||
var traverse = function(obj, options) {
|
||||
return new Traverse(obj, options);
|
||||
};
|
||||
traverse.get = function(obj, paths, options) {
|
||||
return new Traverse(obj, options).get(paths);
|
||||
};
|
||||
traverse.set = function(obj, path, value, options) {
|
||||
return new Traverse(obj, options).set(path, value);
|
||||
};
|
||||
traverse.has = function(obj, paths, options) {
|
||||
return new Traverse(obj, options).has(paths);
|
||||
};
|
||||
traverse.map = function(obj, cb, options) {
|
||||
return new Traverse(obj, options).map(cb);
|
||||
};
|
||||
traverse.forEach = function(obj, cb, options) {
|
||||
return new Traverse(obj, options).forEach(cb);
|
||||
};
|
||||
traverse.reduce = function(obj, cb, init, options) {
|
||||
return new Traverse(obj, options).reduce(cb, init);
|
||||
};
|
||||
traverse.paths = function(obj, options) {
|
||||
return new Traverse(obj, options).paths();
|
||||
};
|
||||
traverse.nodes = function(obj, options) {
|
||||
return new Traverse(obj, options).nodes();
|
||||
};
|
||||
traverse.clone = function(obj, options) {
|
||||
return new Traverse(obj, options).clone();
|
||||
};
|
||||
var src_default = traverse;
|
||||
// src/legacy.cts
|
||||
module.exports = src_default;
|
199
node_modules/neotraverse/dist/legacy/legacy.d.cts
generated
vendored
Normal file
199
node_modules/neotraverse/dist/legacy/legacy.d.cts
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
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 `this.keys` here to traverse in a custom order.
|
||||
*/
|
||||
before(callback: (this: TraverseContext, value: any) => void): void;
|
||||
/**
|
||||
* Call this function after all of the children are traversed.
|
||||
*/
|
||||
after(callback: (this: TraverseContext, value: any) => void): void;
|
||||
/**
|
||||
* Call this function before each of the children are traversed.
|
||||
*/
|
||||
pre(callback: (this: TraverseContext, child: any, key: any) => void): void;
|
||||
/**
|
||||
* Call this function after each of the children are traversed.
|
||||
*/
|
||||
post(callback: (this: TraverseContext, child: any) => void): void;
|
||||
/**
|
||||
* Stops traversal entirely.
|
||||
*/
|
||||
stop(): void;
|
||||
/**
|
||||
* Prevents traversing descendents of the current node.
|
||||
*/
|
||||
block(): void;
|
||||
}
|
||||
/** @deprecated Import `Traverse` from `neotraverse/modern` instead */
|
||||
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: (this: 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: (this: 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: (this: 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;
|
||||
}
|
||||
declare const traverse: {
|
||||
(obj: any, options?: TraverseOptions): Traverse;
|
||||
/**
|
||||
* Get the element at the array `path`.
|
||||
*/
|
||||
get(obj: any, paths: PropertyKey[], options?: TraverseOptions): any;
|
||||
/**
|
||||
* Set the element at the array `path` to `value`.
|
||||
*/
|
||||
set(obj: any, path: PropertyKey[], value: any, options?: TraverseOptions): any;
|
||||
/**
|
||||
* Return whether the element at the array `path` exists.
|
||||
*/
|
||||
has(obj: any, paths: PropertyKey[], options?: TraverseOptions): boolean;
|
||||
/**
|
||||
* 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(obj: any, cb: (this: TraverseContext, v: any) => void, options?: TraverseOptions): any;
|
||||
/**
|
||||
* Execute `fn` for each node in the object but unlike `.map()`, when `this.update()` is called it updates the object in-place.
|
||||
*/
|
||||
forEach(obj: any, cb: (this: TraverseContext, v: any) => void, options?: TraverseOptions): 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(obj: any, cb: (this: TraverseContext, acc: any, v: any) => void, init?: any, options?: TraverseOptions): any;
|
||||
/**
|
||||
* Return an `Array` of every possible non-cyclic path in the object.
|
||||
* Paths are `Array`s of string keys.
|
||||
*/
|
||||
paths(obj: any, options?: TraverseOptions): PropertyKey[][];
|
||||
/**
|
||||
* Return an `Array` of every node in the object.
|
||||
*/
|
||||
nodes(obj: any, options?: TraverseOptions): any[];
|
||||
/**
|
||||
* Create a deep clone of the object.
|
||||
*/
|
||||
clone(obj: any, options?: TraverseOptions): any;
|
||||
};
|
||||
|
||||
export { type TraverseContext, type TraverseOptions, traverse as default };
|
199
node_modules/neotraverse/dist/legacy/legacy.d.ts
generated
vendored
Normal file
199
node_modules/neotraverse/dist/legacy/legacy.d.ts
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
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 `this.keys` here to traverse in a custom order.
|
||||
*/
|
||||
before(callback: (this: TraverseContext, value: any) => void): void;
|
||||
/**
|
||||
* Call this function after all of the children are traversed.
|
||||
*/
|
||||
after(callback: (this: TraverseContext, value: any) => void): void;
|
||||
/**
|
||||
* Call this function before each of the children are traversed.
|
||||
*/
|
||||
pre(callback: (this: TraverseContext, child: any, key: any) => void): void;
|
||||
/**
|
||||
* Call this function after each of the children are traversed.
|
||||
*/
|
||||
post(callback: (this: TraverseContext, child: any) => void): void;
|
||||
/**
|
||||
* Stops traversal entirely.
|
||||
*/
|
||||
stop(): void;
|
||||
/**
|
||||
* Prevents traversing descendents of the current node.
|
||||
*/
|
||||
block(): void;
|
||||
}
|
||||
/** @deprecated Import `Traverse` from `neotraverse/modern` instead */
|
||||
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: (this: 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: (this: 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: (this: 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;
|
||||
}
|
||||
declare const traverse: {
|
||||
(obj: any, options?: TraverseOptions): Traverse;
|
||||
/**
|
||||
* Get the element at the array `path`.
|
||||
*/
|
||||
get(obj: any, paths: PropertyKey[], options?: TraverseOptions): any;
|
||||
/**
|
||||
* Set the element at the array `path` to `value`.
|
||||
*/
|
||||
set(obj: any, path: PropertyKey[], value: any, options?: TraverseOptions): any;
|
||||
/**
|
||||
* Return whether the element at the array `path` exists.
|
||||
*/
|
||||
has(obj: any, paths: PropertyKey[], options?: TraverseOptions): boolean;
|
||||
/**
|
||||
* 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(obj: any, cb: (this: TraverseContext, v: any) => void, options?: TraverseOptions): any;
|
||||
/**
|
||||
* Execute `fn` for each node in the object but unlike `.map()`, when `this.update()` is called it updates the object in-place.
|
||||
*/
|
||||
forEach(obj: any, cb: (this: TraverseContext, v: any) => void, options?: TraverseOptions): 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(obj: any, cb: (this: TraverseContext, acc: any, v: any) => void, init?: any, options?: TraverseOptions): any;
|
||||
/**
|
||||
* Return an `Array` of every possible non-cyclic path in the object.
|
||||
* Paths are `Array`s of string keys.
|
||||
*/
|
||||
paths(obj: any, options?: TraverseOptions): PropertyKey[][];
|
||||
/**
|
||||
* Return an `Array` of every node in the object.
|
||||
*/
|
||||
nodes(obj: any, options?: TraverseOptions): any[];
|
||||
/**
|
||||
* Create a deep clone of the object.
|
||||
*/
|
||||
clone(obj: any, options?: TraverseOptions): any;
|
||||
};
|
||||
|
||||
export { type TraverseContext, type TraverseOptions, traverse as default };
|
549
node_modules/neotraverse/dist/legacy/legacy.mjs
generated
vendored
Normal file
549
node_modules/neotraverse/dist/legacy/legacy.mjs
generated
vendored
Normal file
@@ -0,0 +1,549 @@
|
||||
function _array_like_to_array(arr, len) {
|
||||
if (len == null || len > arr.length) len = arr.length;
|
||||
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
||||
return arr2;
|
||||
}
|
||||
function _array_with_holes(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
function _class_call_check(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
function _defineProperties(target, props) {
|
||||
for(var i = 0; i < props.length; i++){
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
function _create_class(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
}
|
||||
function _instanceof(left, right) {
|
||||
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
||||
return !!right[Symbol.hasInstance](left);
|
||||
} else {
|
||||
return left instanceof right;
|
||||
}
|
||||
}
|
||||
function _iterable_to_array_limit(arr, i) {
|
||||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
||||
if (_i == null) return;
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _s, _e;
|
||||
try {
|
||||
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
||||
_arr.push(_s.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_n && _i["return"] != null) _i["return"]();
|
||||
} finally{
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
}
|
||||
function _non_iterable_rest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
function _sliced_to_array(arr, i) {
|
||||
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
||||
}
|
||||
function _type_of(obj) {
|
||||
"@swc/helpers - typeof";
|
||||
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
||||
}
|
||||
function _unsupported_iterable_to_array(o, minLen) {
|
||||
if (!o) return;
|
||||
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
||||
var n = Object.prototype.toString.call(o).slice(8, -1);
|
||||
if (n === "Object" && o.constructor) n = o.constructor.name;
|
||||
if (n === "Map" || n === "Set") return Array.from(n);
|
||||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
||||
}
|
||||
var __typeError = function(msg) {
|
||||
throw TypeError(msg);
|
||||
};
|
||||
var __accessCheck = function(obj, member, msg) {
|
||||
return member.has(obj) || __typeError("Cannot " + msg);
|
||||
};
|
||||
var __privateGet = function(obj, member, getter) {
|
||||
return __accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj);
|
||||
};
|
||||
var __privateAdd = function(obj, member, value) {
|
||||
return member.has(obj) ? __typeError("Cannot add the same private member more than once") : _instanceof(member, WeakSet) ? member.add(obj) : member.set(obj, value);
|
||||
};
|
||||
var __privateSet = function(obj, member, value, setter) {
|
||||
return __accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value;
|
||||
};
|
||||
// src/index.ts
|
||||
var to_string = function(obj) {
|
||||
return Object.prototype.toString.call(obj);
|
||||
};
|
||||
var is_typed_array = function(value) {
|
||||
return ArrayBuffer.isView(value) && !_instanceof(value, DataView);
|
||||
};
|
||||
var is_date = function(obj) {
|
||||
return to_string(obj) === "[object Date]";
|
||||
};
|
||||
var is_regexp = function(obj) {
|
||||
return to_string(obj) === "[object RegExp]";
|
||||
};
|
||||
var is_error = function(obj) {
|
||||
return to_string(obj) === "[object Error]";
|
||||
};
|
||||
var is_boolean = function(obj) {
|
||||
return to_string(obj) === "[object Boolean]";
|
||||
};
|
||||
var is_number = function(obj) {
|
||||
return to_string(obj) === "[object Number]";
|
||||
};
|
||||
var is_string = function(obj) {
|
||||
return 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;
|
||||
function own_enumerable_keys(obj) {
|
||||
var res = Object.keys(obj);
|
||||
var symbols = get_own_property_symbols(obj);
|
||||
for(var 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) {
|
||||
var _gopd;
|
||||
return !((_gopd = gopd(object, key)) === null || _gopd === void 0 ? void 0 : _gopd.writable);
|
||||
}
|
||||
function copy(src, options) {
|
||||
if ((typeof src === "undefined" ? "undefined" : _type_of(src)) === "object" && src !== null) {
|
||||
var 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));
|
||||
}
|
||||
var iterator_function = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
||||
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
||||
try {
|
||||
for(var _iterator = iterator_function(src)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
||||
var key = _step.value;
|
||||
dst[key] = src[key];
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
return src;
|
||||
}
|
||||
var empty_null = {
|
||||
includeSymbols: false,
|
||||
immutable: false
|
||||
};
|
||||
function walk(root, cb) {
|
||||
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : empty_null;
|
||||
var path = [];
|
||||
var parents = [];
|
||||
var alive = true;
|
||||
var iterator_function = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
||||
var immutable = !!options.immutable;
|
||||
return function walker(node_) {
|
||||
var node = immutable ? copy(node_, options) : node_;
|
||||
var modifiers = {};
|
||||
var keep_going = true;
|
||||
var state = {
|
||||
node: node,
|
||||
node_: node_,
|
||||
path: [].concat(path),
|
||||
parent: parents[parents.length - 1],
|
||||
parents: 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 update(x) {
|
||||
var stopHere = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
||||
if (!state.isRoot) {
|
||||
state.parent.node[state.key] = x;
|
||||
}
|
||||
state.node = x;
|
||||
if (stopHere) {
|
||||
keep_going = false;
|
||||
}
|
||||
},
|
||||
delete: function _delete(stopHere) {
|
||||
delete state.parent.node[state.key];
|
||||
if (stopHere) {
|
||||
keep_going = false;
|
||||
}
|
||||
},
|
||||
remove: function remove(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 before(f) {
|
||||
modifiers.before = f;
|
||||
},
|
||||
after: function after(f) {
|
||||
modifiers.after = f;
|
||||
},
|
||||
pre: function pre(f) {
|
||||
modifiers.pre = f;
|
||||
},
|
||||
post: function post(f) {
|
||||
modifiers.post = f;
|
||||
},
|
||||
stop: function stop() {
|
||||
alive = false;
|
||||
},
|
||||
block: function block() {
|
||||
keep_going = false;
|
||||
}
|
||||
};
|
||||
if (!alive) {
|
||||
return state;
|
||||
}
|
||||
function update_state() {
|
||||
if (_type_of(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(var 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();
|
||||
var ret = cb.call(state, state.node);
|
||||
if (ret !== void 0 && state.update) {
|
||||
state.update(ret);
|
||||
}
|
||||
if (modifiers.before) {
|
||||
modifiers.before.call(state, state.node);
|
||||
}
|
||||
if (!keep_going) {
|
||||
return state;
|
||||
}
|
||||
if (_type_of(state.node) === "object" && state.node !== null && !state.circular) {
|
||||
parents.push(state);
|
||||
update_state();
|
||||
var _state_keys;
|
||||
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
||||
try {
|
||||
for(var _iterator = Object.entries((_state_keys = state.keys) !== null && _state_keys !== void 0 ? _state_keys : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
||||
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], key = _step_value[1];
|
||||
var _state_keys1;
|
||||
path.push(key);
|
||||
if (modifiers.pre) {
|
||||
modifiers.pre.call(state, state.node[key], key);
|
||||
}
|
||||
var 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_keys1 = state.keys) === null || _state_keys1 === void 0 ? void 0 : _state_keys1.length) ? +index === state.keys.length - 1 : false;
|
||||
child.isFirst = +index === 0;
|
||||
if (modifiers.post) {
|
||||
modifiers.post.call(state, child);
|
||||
}
|
||||
path.pop();
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
parents.pop();
|
||||
}
|
||||
if (modifiers.after) {
|
||||
modifiers.after.call(state, state.node);
|
||||
}
|
||||
return state;
|
||||
}(root).node;
|
||||
}
|
||||
var _value, _options;
|
||||
var Traverse = /*#__PURE__*/ function() {
|
||||
"use strict";
|
||||
function Traverse(obj) {
|
||||
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : empty_null;
|
||||
_class_call_check(this, Traverse);
|
||||
// ! Have to keep these public as legacy mode requires them
|
||||
__privateAdd(this, _value);
|
||||
__privateAdd(this, _options);
|
||||
__privateSet(this, _value, obj);
|
||||
__privateSet(this, _options, options);
|
||||
}
|
||||
_create_class(Traverse, [
|
||||
{
|
||||
/**
|
||||
* Get the element at the array `path`.
|
||||
*/ key: "get",
|
||||
value: function get(paths) {
|
||||
var node = __privateGet(this, _value);
|
||||
for(var i = 0; node && i < paths.length; i++){
|
||||
var key = paths[i];
|
||||
if (!has_own_property.call(node, key) || !__privateGet(this, _options).includeSymbols && (typeof key === "undefined" ? "undefined" : _type_of(key)) === "symbol") {
|
||||
return void 0;
|
||||
}
|
||||
node = node[key];
|
||||
}
|
||||
return node;
|
||||
}
|
||||
},
|
||||
{
|
||||
/**
|
||||
* Return whether the element at the array `path` exists.
|
||||
*/ key: "has",
|
||||
value: function has(paths) {
|
||||
var node = __privateGet(this, _value);
|
||||
for(var i = 0; node && i < paths.length; i++){
|
||||
var key = paths[i];
|
||||
if (!has_own_property.call(node, key) || !__privateGet(this, _options).includeSymbols && (typeof key === "undefined" ? "undefined" : _type_of(key)) === "symbol") {
|
||||
return false;
|
||||
}
|
||||
node = node[key];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
/**
|
||||
* Set the element at the array `path` to `value`.
|
||||
*/ key: "set",
|
||||
value: function set(path, value) {
|
||||
var node = __privateGet(this, _value);
|
||||
var i = 0;
|
||||
for(i = 0; i < path.length - 1; i++){
|
||||
var 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)`.
|
||||
*/ key: "map",
|
||||
value: function map(cb) {
|
||||
return walk(__privateGet(this, _value), cb, {
|
||||
immutable: true,
|
||||
includeSymbols: !!__privateGet(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.
|
||||
*/ key: "forEach",
|
||||
value: function forEach(cb) {
|
||||
__privateSet(this, _value, walk(__privateGet(this, _value), cb, __privateGet(this, _options)));
|
||||
return __privateGet(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.
|
||||
*/ key: "reduce",
|
||||
value: function reduce(cb, init) {
|
||||
var skip = arguments.length === 1;
|
||||
var acc = skip ? __privateGet(this, _value) : init;
|
||||
this.forEach(function(x) {
|
||||
if (!this.isRoot || !skip) {
|
||||
acc = cb.call(this, acc, x);
|
||||
}
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
},
|
||||
{
|
||||
/**
|
||||
* Return an `Array` of every possible non-cyclic path in the object.
|
||||
* Paths are `Array`s of string keys.
|
||||
*/ key: "paths",
|
||||
value: function paths() {
|
||||
var acc = [];
|
||||
this.forEach(function() {
|
||||
acc.push(this.path);
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
},
|
||||
{
|
||||
/**
|
||||
* Return an `Array` of every node in the object.
|
||||
*/ key: "nodes",
|
||||
value: function nodes() {
|
||||
var acc = [];
|
||||
this.forEach(function() {
|
||||
acc.push(this.node);
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
},
|
||||
{
|
||||
/**
|
||||
* Create a deep clone of the object.
|
||||
*/ key: "clone",
|
||||
value: function clone() {
|
||||
var parents = [];
|
||||
var nodes = [];
|
||||
var options = __privateGet(this, _options);
|
||||
if (is_typed_array(__privateGet(this, _value))) {
|
||||
return __privateGet(this, _value).slice();
|
||||
}
|
||||
return function clone(src) {
|
||||
for(var i = 0; i < parents.length; i++){
|
||||
if (parents[i] === src) {
|
||||
return nodes[i];
|
||||
}
|
||||
}
|
||||
if ((typeof src === "undefined" ? "undefined" : _type_of(src)) === "object" && src !== null) {
|
||||
var dst = copy(src, options);
|
||||
parents.push(src);
|
||||
nodes.push(dst);
|
||||
var iteratorFunction = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
||||
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
||||
try {
|
||||
for(var _iterator = iteratorFunction(src)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
||||
var key = _step.value;
|
||||
dst[key] = clone(src[key]);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
parents.pop();
|
||||
nodes.pop();
|
||||
return dst;
|
||||
}
|
||||
return src;
|
||||
}(__privateGet(this, _value));
|
||||
}
|
||||
}
|
||||
]);
|
||||
return Traverse;
|
||||
}();
|
||||
_value = new WeakMap();
|
||||
_options = new WeakMap();
|
||||
var traverse = function(obj, options) {
|
||||
return new Traverse(obj, options);
|
||||
};
|
||||
traverse.get = function(obj, paths, options) {
|
||||
return new Traverse(obj, options).get(paths);
|
||||
};
|
||||
traverse.set = function(obj, path, value, options) {
|
||||
return new Traverse(obj, options).set(path, value);
|
||||
};
|
||||
traverse.has = function(obj, paths, options) {
|
||||
return new Traverse(obj, options).has(paths);
|
||||
};
|
||||
traverse.map = function(obj, cb, options) {
|
||||
return new Traverse(obj, options).map(cb);
|
||||
};
|
||||
traverse.forEach = function(obj, cb, options) {
|
||||
return new Traverse(obj, options).forEach(cb);
|
||||
};
|
||||
traverse.reduce = function(obj, cb, init, options) {
|
||||
return new Traverse(obj, options).reduce(cb, init);
|
||||
};
|
||||
traverse.paths = function(obj, options) {
|
||||
return new Traverse(obj, options).paths();
|
||||
};
|
||||
traverse.nodes = function(obj, options) {
|
||||
return new Traverse(obj, options).nodes();
|
||||
};
|
||||
traverse.clone = function(obj, options) {
|
||||
return new Traverse(obj, options).clone();
|
||||
};
|
||||
var src_default = traverse;
|
||||
// src/legacy.cts
|
||||
|
||||
export { src_default as default };
|
1
node_modules/neotraverse/dist/min/index.js
generated
vendored
Normal file
1
node_modules/neotraverse/dist/min/index.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),s=t=>"[object Error]"===e(t),r=t=>"[object Boolean]"===e(t),l=t=>"[object Number]"===e(t),c=t=>"[object String]"===e(t),i=Array.isArray,a=Object.getOwnPropertyDescriptor,u=Object.prototype.propertyIsEnumerable,f=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty;function h(e){const t=Object.keys(e),o=f(e);for(let n=0;n<o.length;n++)u.call(e,o[n])&&t.push(o[n]);return t}function d(e,t){return!a(e,t)?.writable}function b(e,a){if("object"==typeof e&&null!==e){let u;if(i(e))u=[];else if(o(e))u=new Date(e.getTime?e.getTime():e);else if(n(e))u=new RegExp(e);else if(s(e))u={message:e.message};else if(r(e)||l(e)||c(e))u=Object(e);else{if(t(e))return e.slice();u=Object.create(Object.getPrototypeOf(e))}const f=a.includeSymbols?h:Object.keys;for(const t of f(e))u[t]=e[t];return u}return e}var y={includeSymbols:!1,immutable:!1};function g(e,t,o=y){const n=[],s=[];let r=!0;const l=o.includeSymbols?h:Object.keys,c=!!o.immutable;return function e(a){const u=c?b(a,o):a,f={};let h=!0;const y={node:u,node_:a,path:[].concat(n),parent:s[s.length-1],parents:s,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){y.isRoot||(y.parent.node[y.key]=e),y.node=e,t&&(h=!1)},delete:function(e){delete y.parent.node[y.key],e&&(h=!1)},remove:function(e){i(y.parent.node)?y.parent.node.splice(y.key,1):delete y.parent.node[y.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(){r=!1},block:function(){h=!1}};if(!r)return y;function g(){if("object"==typeof y.node&&null!==y.node){y.keys&&y.node_===y.node||(y.keys=l(y.node)),y.isLeaf=0===y.keys.length;for(let e=0;e<s.length;e++)if(s[e].node_===a){y.circular=s[e];break}}else y.isLeaf=!0,y.keys=null;y.notLeaf=!y.isLeaf,y.notRoot=!y.isRoot}g();const m=t.call(y,y.node);if(void 0!==m&&y.update&&y.update(m),f.before&&f.before.call(y,y.node),!h)return y;if("object"==typeof y.node&&null!==y.node&&!y.circular){s.push(y),g();for(const[t,o]of Object.entries(y.keys??[])){n.push(o),f.pre&&f.pre.call(y,y.node[o],o);const s=e(y.node[o]);c&&p.call(y.node,o)&&!d(y.node,o)&&(y.node[o]=s.node),s.isLast=!!y.keys?.length&&+t==y.keys.length-1,s.isFirst=0==+t,f.post&&f.post.call(y,s),n.pop()}s.pop()}return f.after&&f.after.call(y,y.node),y}(e).node}var m=class{#e;#t;constructor(e,t=y){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 g(this.#e,e,{immutable:!0,includeSymbols:!!this.#t.includeSymbols})}forEach(e){return this.#e=g(this.#e,e,this.#t),this.#e}reduce(e,t){const o=1===arguments.length;let n=o?this.#e:t;return this.forEach((function(t){this.isRoot&&o||(n=e.call(this,n,t))})),n}paths(){const e=[];return this.forEach((function(){e.push(this.path)})),e}nodes(){const e=[];return this.forEach((function(){e.push(this.node)})),e}clone(){const e=[],o=[],n=this.#t;return t(this.#e)?this.#e.slice():function t(s){for(let t=0;t<e.length;t++)if(e[t]===s)return o[t];if("object"==typeof s&&null!==s){const r=b(s,n);e.push(s),o.push(r);const l=n.includeSymbols?h:Object.keys;for(const e of l(s))r[e]=t(s[e]);return e.pop(),o.pop(),r}return s}(this.#e)}},j=(e,t)=>new m(e,t);j.get=(e,t,o)=>new m(e,o).get(t),j.set=(e,t,o,n)=>new m(e,n).set(t,o),j.has=(e,t,o)=>new m(e,o).has(t),j.map=(e,t,o)=>new m(e,o).map(t),j.forEach=(e,t,o)=>new m(e,o).forEach(t),j.reduce=(e,t,o,n)=>new m(e,n).reduce(t,o),j.paths=(e,t)=>new m(e,t).paths(),j.nodes=(e,t)=>new m(e,t).nodes(),j.clone=(e,t)=>new m(e,t).clone();var v=j;export{m as Traverse,v as default};
|
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