@xyd-js/cli 0.1.0-xyd.4 → 0.1.0-xyd.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cli/bin.js +3 -0
- package/.cli/{host/node_modules/.vite/deps/gray-matter.js → index.js} +2714 -533
- package/.cli/package.json +37 -0
- package/package.json +11 -20
- package/.cli/dist/index.d.ts +0 -1
- package/.cli/dist/index.js +0 -12418
- package/.cli/host/.react-router/types/app/+types/root.ts +0 -40
- package/.cli/host/node_modules/.vite/deps/@mdx-js_mdx.js +0 -81
- package/.cli/host/node_modules/.vite/deps/@mdx-js_mdx.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/@mdx-js_rollup.js +0 -4003
- package/.cli/host/node_modules/.vite/deps/@mdx-js_rollup.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/@radix-ui_react-icons.js +0 -7531
- package/.cli/host/node_modules/.vite/deps/@radix-ui_react-icons.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/@radix-ui_react-tabs.js +0 -917
- package/.cli/host/node_modules/.vite/deps/@radix-ui_react-tabs.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/_metadata.json +0 -157
- package/.cli/host/node_modules/.vite/deps/chunk-2TUXWMP5.js +0 -46
- package/.cli/host/node_modules/.vite/deps/chunk-2TUXWMP5.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-A76PLWFF.js +0 -23875
- package/.cli/host/node_modules/.vite/deps/chunk-A76PLWFF.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-B2TCFXA3.js +0 -27
- package/.cli/host/node_modules/.vite/deps/chunk-B2TCFXA3.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-CZACBYAQ.js +0 -3461
- package/.cli/host/node_modules/.vite/deps/chunk-CZACBYAQ.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-DNIFH2K7.js +0 -3461
- package/.cli/host/node_modules/.vite/deps/chunk-DNIFH2K7.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-ERHH4CDL.js +0 -23875
- package/.cli/host/node_modules/.vite/deps/chunk-ERHH4CDL.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-ETJV5QNK.js +0 -27
- package/.cli/host/node_modules/.vite/deps/chunk-ETJV5QNK.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-GPEJJ3KZ.js +0 -1906
- package/.cli/host/node_modules/.vite/deps/chunk-GPEJJ3KZ.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-IVP26VTC.js +0 -21
- package/.cli/host/node_modules/.vite/deps/chunk-IVP26VTC.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-MJUUSK53.js +0 -894
- package/.cli/host/node_modules/.vite/deps/chunk-MJUUSK53.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-NHN7DW4J.js +0 -928
- package/.cli/host/node_modules/.vite/deps/chunk-NHN7DW4J.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-NSHFRFAV.js +0 -894
- package/.cli/host/node_modules/.vite/deps/chunk-NSHFRFAV.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-O6QCC74R.js +0 -205
- package/.cli/host/node_modules/.vite/deps/chunk-O6QCC74R.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-OO6QDGMA.js +0 -10609
- package/.cli/host/node_modules/.vite/deps/chunk-OO6QDGMA.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-OUN4SSIE.js +0 -205
- package/.cli/host/node_modules/.vite/deps/chunk-OUN4SSIE.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-SBIFJFEH.js +0 -894
- package/.cli/host/node_modules/.vite/deps/chunk-SBIFJFEH.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-SURLKOJ2.js +0 -12
- package/.cli/host/node_modules/.vite/deps/chunk-SURLKOJ2.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-TKNG6GUJ.js +0 -894
- package/.cli/host/node_modules/.vite/deps/chunk-TKNG6GUJ.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-TM4FKLNO.js +0 -21628
- package/.cli/host/node_modules/.vite/deps/chunk-TM4FKLNO.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-V2IF7L2E.js +0 -12
- package/.cli/host/node_modules/.vite/deps/chunk-V2IF7L2E.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-VENRSTQF.js +0 -21628
- package/.cli/host/node_modules/.vite/deps/chunk-VENRSTQF.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-XCGROZNW.js +0 -10609
- package/.cli/host/node_modules/.vite/deps/chunk-XCGROZNW.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-ZFDQJWTH.js +0 -928
- package/.cli/host/node_modules/.vite/deps/chunk-ZFDQJWTH.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/chunk-ZFOARUJI.js +0 -1906
- package/.cli/host/node_modules/.vite/deps/chunk-ZFOARUJI.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/gray-matter.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/lucide-react.js +0 -34742
- package/.cli/host/node_modules/.vite/deps/lucide-react.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/package.json +0 -3
- package/.cli/host/node_modules/.vite/deps/react-dom.js +0 -7
- package/.cli/host/node_modules/.vite/deps/react-dom.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/react-dom_client.js +0 -39
- package/.cli/host/node_modules/.vite/deps/react-dom_client.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/react-router.js +0 -243
- package/.cli/host/node_modules/.vite/deps/react-router.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/react-router_dom.js +0 -212
- package/.cli/host/node_modules/.vite/deps/react-router_dom.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/react.js +0 -6
- package/.cli/host/node_modules/.vite/deps/react.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/react_jsx-dev-runtime.js +0 -913
- package/.cli/host/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/react_jsx-runtime.js +0 -7
- package/.cli/host/node_modules/.vite/deps/react_jsx-runtime.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/remark-frontmatter.js +0 -428
- package/.cli/host/node_modules/.vite/deps/remark-frontmatter.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/remark-gfm.js +0 -3122
- package/.cli/host/node_modules/.vite/deps/remark-gfm.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/remark-mdx-frontmatter.js +0 -10482
- package/.cli/host/node_modules/.vite/deps/remark-mdx-frontmatter.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/unist-util-visit.js +0 -14
- package/.cli/host/node_modules/.vite/deps/unist-util-visit.js.map +0 -7
- package/.cli/host/node_modules/.vite/deps/vfile.js +0 -8
- package/.cli/host/node_modules/.vite/deps/vfile.js.map +0 -7
- package/.cli/host/package.json +0 -43
- package/bin.js +0 -3
- /package/.cli/{host/app → app}/root.tsx +0 -0
- /package/.cli/{host/app → app}/routes.ts +0 -0
- /package/.cli/{host/postcss.config.cjs → postcss.config.cjs} +0 -0
- /package/.cli/{host/react-router.config.ts → react-router.config.ts} +0 -0
- /package/.cli/{host/tsconfig.json → tsconfig.json} +0 -0
- /package/.cli/{host/vite.config.ts → vite.config.ts} +0 -0
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
// ../node_modules/.pnpm/unist-util-is@6.0.0/node_modules/unist-util-is/lib/index.js
|
|
2
|
-
var convert = (
|
|
3
|
-
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
4
|
-
/**
|
|
5
|
-
* @type {(
|
|
6
|
-
* (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
|
|
7
|
-
* (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
|
|
8
|
-
* (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
|
|
9
|
-
* ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
|
|
10
|
-
* ((test?: Test) => Check)
|
|
11
|
-
* )}
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* @param {Test} [test]
|
|
15
|
-
* @returns {Check}
|
|
16
|
-
*/
|
|
17
|
-
function(test) {
|
|
18
|
-
if (test === null || test === void 0) {
|
|
19
|
-
return ok;
|
|
20
|
-
}
|
|
21
|
-
if (typeof test === "function") {
|
|
22
|
-
return castFactory(test);
|
|
23
|
-
}
|
|
24
|
-
if (typeof test === "object") {
|
|
25
|
-
return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
|
|
26
|
-
}
|
|
27
|
-
if (typeof test === "string") {
|
|
28
|
-
return typeFactory(test);
|
|
29
|
-
}
|
|
30
|
-
throw new Error("Expected function, string, or object as test");
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
function anyFactory(tests) {
|
|
34
|
-
const checks = [];
|
|
35
|
-
let index = -1;
|
|
36
|
-
while (++index < tests.length) {
|
|
37
|
-
checks[index] = convert(tests[index]);
|
|
38
|
-
}
|
|
39
|
-
return castFactory(any);
|
|
40
|
-
function any(...parameters) {
|
|
41
|
-
let index2 = -1;
|
|
42
|
-
while (++index2 < checks.length) {
|
|
43
|
-
if (checks[index2].apply(this, parameters)) return true;
|
|
44
|
-
}
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function propsFactory(check) {
|
|
49
|
-
const checkAsRecord = (
|
|
50
|
-
/** @type {Record<string, unknown>} */
|
|
51
|
-
check
|
|
52
|
-
);
|
|
53
|
-
return castFactory(all);
|
|
54
|
-
function all(node) {
|
|
55
|
-
const nodeAsRecord = (
|
|
56
|
-
/** @type {Record<string, unknown>} */
|
|
57
|
-
/** @type {unknown} */
|
|
58
|
-
node
|
|
59
|
-
);
|
|
60
|
-
let key;
|
|
61
|
-
for (key in check) {
|
|
62
|
-
if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function typeFactory(check) {
|
|
68
|
-
return castFactory(type);
|
|
69
|
-
function type(node) {
|
|
70
|
-
return node && node.type === check;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function castFactory(testFunction) {
|
|
74
|
-
return check;
|
|
75
|
-
function check(value, index, parent) {
|
|
76
|
-
return Boolean(
|
|
77
|
-
looksLikeANode(value) && testFunction.call(
|
|
78
|
-
this,
|
|
79
|
-
value,
|
|
80
|
-
typeof index === "number" ? index : void 0,
|
|
81
|
-
parent || void 0
|
|
82
|
-
)
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function ok() {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
function looksLikeANode(value) {
|
|
90
|
-
return value !== null && typeof value === "object" && "type" in value;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ../node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/color.js
|
|
94
|
-
function color(d) {
|
|
95
|
-
return d;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// ../node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/index.js
|
|
99
|
-
var empty = [];
|
|
100
|
-
var CONTINUE = true;
|
|
101
|
-
var EXIT = false;
|
|
102
|
-
var SKIP = "skip";
|
|
103
|
-
function visitParents(tree, test, visitor, reverse) {
|
|
104
|
-
let check;
|
|
105
|
-
if (typeof test === "function" && typeof visitor !== "function") {
|
|
106
|
-
reverse = visitor;
|
|
107
|
-
visitor = test;
|
|
108
|
-
} else {
|
|
109
|
-
check = test;
|
|
110
|
-
}
|
|
111
|
-
const is2 = convert(check);
|
|
112
|
-
const step = reverse ? -1 : 1;
|
|
113
|
-
factory(tree, void 0, [])();
|
|
114
|
-
function factory(node, index, parents) {
|
|
115
|
-
const value = (
|
|
116
|
-
/** @type {Record<string, unknown>} */
|
|
117
|
-
node && typeof node === "object" ? node : {}
|
|
118
|
-
);
|
|
119
|
-
if (typeof value.type === "string") {
|
|
120
|
-
const name = (
|
|
121
|
-
// `hast`
|
|
122
|
-
typeof value.tagName === "string" ? value.tagName : (
|
|
123
|
-
// `xast`
|
|
124
|
-
typeof value.name === "string" ? value.name : void 0
|
|
125
|
-
)
|
|
126
|
-
);
|
|
127
|
-
Object.defineProperty(visit2, "name", {
|
|
128
|
-
value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")"
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
return visit2;
|
|
132
|
-
function visit2() {
|
|
133
|
-
let result = empty;
|
|
134
|
-
let subresult;
|
|
135
|
-
let offset;
|
|
136
|
-
let grandparents;
|
|
137
|
-
if (!test || is2(node, index, parents[parents.length - 1] || void 0)) {
|
|
138
|
-
result = toResult(visitor(node, parents));
|
|
139
|
-
if (result[0] === EXIT) {
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if ("children" in node && node.children) {
|
|
144
|
-
const nodeAsParent = (
|
|
145
|
-
/** @type {UnistParent} */
|
|
146
|
-
node
|
|
147
|
-
);
|
|
148
|
-
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
149
|
-
offset = (reverse ? nodeAsParent.children.length : -1) + step;
|
|
150
|
-
grandparents = parents.concat(nodeAsParent);
|
|
151
|
-
while (offset > -1 && offset < nodeAsParent.children.length) {
|
|
152
|
-
const child = nodeAsParent.children[offset];
|
|
153
|
-
subresult = factory(child, offset, grandparents)();
|
|
154
|
-
if (subresult[0] === EXIT) {
|
|
155
|
-
return subresult;
|
|
156
|
-
}
|
|
157
|
-
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return result;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function toResult(value) {
|
|
166
|
-
if (Array.isArray(value)) {
|
|
167
|
-
return value;
|
|
168
|
-
}
|
|
169
|
-
if (typeof value === "number") {
|
|
170
|
-
return [CONTINUE, value];
|
|
171
|
-
}
|
|
172
|
-
return value === null || value === void 0 ? empty : [value];
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// ../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js
|
|
176
|
-
function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
177
|
-
let reverse;
|
|
178
|
-
let test;
|
|
179
|
-
let visitor;
|
|
180
|
-
if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
|
|
181
|
-
test = void 0;
|
|
182
|
-
visitor = testOrVisitor;
|
|
183
|
-
reverse = visitorOrReverse;
|
|
184
|
-
} else {
|
|
185
|
-
test = testOrVisitor;
|
|
186
|
-
visitor = visitorOrReverse;
|
|
187
|
-
reverse = maybeReverse;
|
|
188
|
-
}
|
|
189
|
-
visitParents(tree, test, overload, reverse);
|
|
190
|
-
function overload(node, parents) {
|
|
191
|
-
const parent = parents[parents.length - 1];
|
|
192
|
-
const index = parent ? parent.children.indexOf(node) : void 0;
|
|
193
|
-
return visitor(node, index, parent);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export {
|
|
198
|
-
convert,
|
|
199
|
-
CONTINUE,
|
|
200
|
-
EXIT,
|
|
201
|
-
SKIP,
|
|
202
|
-
visitParents,
|
|
203
|
-
visit
|
|
204
|
-
};
|
|
205
|
-
//# sourceMappingURL=chunk-OUN4SSIE.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../../node_modules/.pnpm/unist-util-is@6.0.0/node_modules/unist-util-is/lib/index.js", "../../../../../../../node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/color.js", "../../../../../../../node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/index.js", "../../../../../../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n */\n\n/**\n * @template Fn\n * @template Fallback\n * @typedef {Fn extends (value: any) => value is infer Thing ? Thing : Fallback} Predicate\n */\n\n/**\n * @callback Check\n * Check that an arbitrary value is a node.\n * @param {unknown} this\n * The given context.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean}\n * Whether this is a node and passes a test.\n *\n * @typedef {Record<string, unknown> | Node} Props\n * Object to check for equivalence.\n *\n * Note: `Node` is included as it is common but is not indexable.\n *\n * @typedef {Array<Props | TestFunction | string> | Props | TestFunction | string | null | undefined} Test\n * Check for an arbitrary node.\n *\n * @callback TestFunction\n * Check if a node passes a test.\n * @param {unknown} this\n * The given context.\n * @param {Node} node\n * A node.\n * @param {number | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | undefined} [parent]\n * The node’s parent.\n * @returns {boolean | undefined | void}\n * Whether this node passes the test.\n *\n * Note: `void` is included until TS sees no return as `undefined`.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param {unknown} node\n * Thing to check, typically `Node`.\n * @param {Test} test\n * A check for a specific node.\n * @param {number | null | undefined} index\n * The node’s position in its parent.\n * @param {Parent | null | undefined} parent\n * The node’s parent.\n * @param {unknown} context\n * Context object (`this`) to pass to `test` functions.\n * @returns {boolean}\n * Whether `node` is a node and passes a test.\n */\nexport const is =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * (<Condition extends string>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * (<Condition extends Props>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * (<Condition extends TestFunction>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n * ((node?: null | undefined) => false) &\n * ((node: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((node: unknown, test?: Test, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => boolean)\n * )}\n */\n (\n /**\n * @param {unknown} [node]\n * @param {Test} [test]\n * @param {number | null | undefined} [index]\n * @param {Parent | null | undefined} [parent]\n * @param {unknown} [context]\n * @returns {boolean}\n */\n // eslint-disable-next-line max-params\n function (node, test, index, parent, context) {\n const check = convert(test)\n\n if (\n index !== undefined &&\n index !== null &&\n (typeof index !== 'number' ||\n index < 0 ||\n index === Number.POSITIVE_INFINITY)\n ) {\n throw new Error('Expected positive finite index')\n }\n\n if (\n parent !== undefined &&\n parent !== null &&\n (!is(parent) || !parent.children)\n ) {\n throw new Error('Expected parent node')\n }\n\n if (\n (parent === undefined || parent === null) !==\n (index === undefined || index === null)\n ) {\n throw new Error('Expected both parent and index')\n }\n\n return looksLikeANode(node)\n ? check.call(context, node, index, parent)\n : false\n }\n )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param {Test} test\n * * when nullish, checks if `node` is a `Node`.\n * * when `string`, works like passing `(node) => node.type === test`.\n * * when `function` checks if function passed the node is true.\n * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n * * when `array`, checks if any one of the subtests pass.\n * @returns {Check}\n * An assertion.\n */\nexport const convert =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((test?: Test) => Check)\n * )}\n */\n (\n /**\n * @param {Test} [test]\n * @returns {Check}\n */\n function (test) {\n if (test === null || test === undefined) {\n return ok\n }\n\n if (typeof test === 'function') {\n return castFactory(test)\n }\n\n if (typeof test === 'object') {\n return Array.isArray(test) ? anyFactory(test) : propsFactory(test)\n }\n\n if (typeof test === 'string') {\n return typeFactory(test)\n }\n\n throw new Error('Expected function, string, or object as test')\n }\n )\n\n/**\n * @param {Array<Props | TestFunction | string>} tests\n * @returns {Check}\n */\nfunction anyFactory(tests) {\n /** @type {Array<Check>} */\n const checks = []\n let index = -1\n\n while (++index < tests.length) {\n checks[index] = convert(tests[index])\n }\n\n return castFactory(any)\n\n /**\n * @this {unknown}\n * @type {TestFunction}\n */\n function any(...parameters) {\n let index = -1\n\n while (++index < checks.length) {\n if (checks[index].apply(this, parameters)) return true\n }\n\n return false\n }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {Check}\n */\nfunction propsFactory(check) {\n const checkAsRecord = /** @type {Record<string, unknown>} */ (check)\n\n return castFactory(all)\n\n /**\n * @param {Node} node\n * @returns {boolean}\n */\n function all(node) {\n const nodeAsRecord = /** @type {Record<string, unknown>} */ (\n /** @type {unknown} */ (node)\n )\n\n /** @type {string} */\n let key\n\n for (key in check) {\n if (nodeAsRecord[key] !== checkAsRecord[key]) return false\n }\n\n return true\n }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {Check}\n */\nfunction typeFactory(check) {\n return castFactory(type)\n\n /**\n * @param {Node} node\n */\n function type(node) {\n return node && node.type === check\n }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunction} testFunction\n * @returns {Check}\n */\nfunction castFactory(testFunction) {\n return check\n\n /**\n * @this {unknown}\n * @type {Check}\n */\n function check(value, index, parent) {\n return Boolean(\n looksLikeANode(value) &&\n testFunction.call(\n this,\n value,\n typeof index === 'number' ? index : undefined,\n parent || undefined\n )\n )\n }\n}\n\nfunction ok() {\n return true\n}\n\n/**\n * @param {unknown} value\n * @returns {value is Node}\n */\nfunction looksLikeANode(value) {\n return value !== null && typeof value === 'object' && 'type' in value\n}\n", "/**\n * @param {string} d\n * @returns {string}\n */\nexport function color(d) {\n return d\n}\n", "/**\n * @typedef {import('unist').Node} UnistNode\n * @typedef {import('unist').Parent} UnistParent\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends Array<any>\n * ? MatchesOne<Value, Check[keyof Check]>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {InternalAncestor<InclusiveDescendant<Tree>, Child>} Ancestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {'skip' | boolean} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<VisitedParents>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [VisitedParents=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n * @template {UnistNode} [Tree=UnistNode]\n * Tree type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from 'unist-util-visit-parents/do-not-use-color'\n\n/** @type {Readonly<ActionTuple>} */\nconst empty = []\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} test\n * `unist-util-is`-compatible test\n * @param {Visitor | boolean | null | undefined} [visitor]\n * Handle each node.\n * @param {boolean | null | undefined} [reverse]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visitParents(tree, test, visitor, reverse) {\n /** @type {Test} */\n let check\n\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n } else {\n // @ts-expect-error visitor given, so `test` isn’t a visitor.\n check = test\n }\n\n const is = convert(check)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {UnistNode} node\n * @param {number | undefined} index\n * @param {Array<UnistParent>} parents\n */\n function factory(node, index, parents) {\n const value = /** @type {Record<string, unknown>} */ (\n node && typeof node === 'object' ? node : {}\n )\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {Readonly<ActionTuple>} */\n let result = empty\n /** @type {Readonly<ActionTuple>} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<UnistParent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || undefined)) {\n // @ts-expect-error: `visitor` is now a visitor.\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n if ('children' in node && node.children) {\n const nodeAsParent = /** @type {UnistParent} */ (node)\n\n if (nodeAsParent.children && result[0] !== SKIP) {\n offset = (reverse ? nodeAsParent.children.length : -1) + step\n grandparents = parents.concat(nodeAsParent)\n\n while (offset > -1 && offset < nodeAsParent.children.length) {\n const child = nodeAsParent.children[offset]\n\n subresult = factory(child, offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n }\n\n return result\n }\n }\n}\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {Readonly<ActionTuple>}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return value === null || value === undefined ? empty : [value]\n}\n", "/**\n * @typedef {import('unist').Node} UnistNode\n * @typedef {import('unist').Parent} UnistParent\n * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n// To do: use types from `unist-util-visit-parents` when it’s released.\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends Array<any>\n * ? MatchesOne<Value, Check[keyof Check]>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform `parent`.\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of `parent` still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Visited\n * Node type.\n * @template {UnistParent} Ancestor\n * Parent type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromMatch<\n * Matches<Descendant, Check>,\n * Extract<Descendant, UnistParent>\n * >\n * )} BuildVisitorFromDescendants\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromDescendants<\n * InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} testOrVisitor\n * `unist-util-is`-compatible test (optional, omit to pass a visitor).\n * @param {Visitor | boolean | null | undefined} [visitorOrReverse]\n * Handle each node (when test is omitted, pass `reverse`).\n * @param {boolean | null | undefined} [maybeReverse=false]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {\n /** @type {boolean | null | undefined} */\n let reverse\n /** @type {Test} */\n let test\n /** @type {Visitor} */\n let visitor\n\n if (\n typeof testOrVisitor === 'function' &&\n typeof visitorOrReverse !== 'function'\n ) {\n test = undefined\n visitor = testOrVisitor\n reverse = visitorOrReverse\n } else {\n // @ts-expect-error: assume the overload with test was given.\n test = testOrVisitor\n // @ts-expect-error: assume the overload with test was given.\n visitor = visitorOrReverse\n reverse = maybeReverse\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {UnistNode} node\n * @param {Array<UnistParent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n const index = parent ? parent.children.indexOf(node) : undefined\n return visitor(node, index, parent)\n }\n}\n"],
|
|
5
|
-
"mappings": ";AA2IO,IAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBT,SAAU,MAAM;AACd,QAAI,SAAS,QAAQ,SAAS,QAAW;AACvC,aAAO;AAAA,IACT;AAEA,QAAI,OAAO,SAAS,YAAY;AAC9B,aAAO,YAAY,IAAI;AAAA,IACzB;AAEA,QAAI,OAAO,SAAS,UAAU;AAC5B,aAAO,MAAM,QAAQ,IAAI,IAAI,WAAW,IAAI,IAAI,aAAa,IAAI;AAAA,IACnE;AAEA,QAAI,OAAO,SAAS,UAAU;AAC5B,aAAO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