@lousy-agents/mcp 5.22.15 → 5.22.17
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/dist/mcp-server.js +495 -229
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -6559,7 +6559,7 @@ function escapeJsonPtr(str) {
|
|
|
6559
6559
|
|
|
6560
6560
|
|
|
6561
6561
|
},
|
|
6562
|
-
|
|
6562
|
+
9324(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
|
|
6563
6563
|
// NAMESPACE OBJECT: ../../node_modules/micromark/lib/constructs.js
|
|
6564
6564
|
var constructs_namespaceObject = {};
|
|
6565
6565
|
__webpack_require__.r(constructs_namespaceObject);
|
|
@@ -53723,8 +53723,8 @@ function pinnedWriteModeAssertion(fd, mode, assertBeforeMutation, privateCreatio
|
|
|
53723
53723
|
|
|
53724
53724
|
|
|
53725
53725
|
// Node has no portable no-replace rename. Publish the completed stage by link,
|
|
53726
|
-
// then remove its verified temporary name
|
|
53727
|
-
function publishCopyStage(params) {
|
|
53726
|
+
// then remove its verified temporary name after any descriptor handoff.
|
|
53727
|
+
async function publishCopyStage(params) {
|
|
53728
53728
|
const { identity, temporaryPath, targetPath } = params;
|
|
53729
53729
|
const assertCurrent = () => {
|
|
53730
53730
|
directory_guard_assertSyncDirectoryGuard(params.parentGuard);
|
|
@@ -53778,13 +53778,23 @@ function publishCopyStage(params) {
|
|
|
53778
53778
|
}
|
|
53779
53779
|
}
|
|
53780
53780
|
else {
|
|
53781
|
-
const
|
|
53782
|
-
|
|
53783
|
-
|
|
53784
|
-
|
|
53785
|
-
|
|
53786
|
-
!
|
|
53787
|
-
|
|
53781
|
+
const verifyPair = () => {
|
|
53782
|
+
directory_guard_assertSyncDirectoryGuard(params.parentGuard);
|
|
53783
|
+
const parent = external_node_fs_.lstatSync(external_node_path_.dirname(temporaryPath), { bigint: true });
|
|
53784
|
+
const current = external_node_fs_.lstatSync(temporaryPath, { bigint: true });
|
|
53785
|
+
const target = external_node_fs_.lstatSync(targetPath, { bigint: true });
|
|
53786
|
+
if (parent.isSymbolicLink() || !parent.isDirectory() ||
|
|
53787
|
+
!file_identity_sameFileIdentityForCleanup(parent, params.parentGuard.stat) ||
|
|
53788
|
+
current.isSymbolicLink() || !current.isFile() || current.nlink !== 2n ||
|
|
53789
|
+
target.isSymbolicLink() || !target.isFile() || target.nlink !== 2n ||
|
|
53790
|
+
!file_identity_sameFileIdentityForCleanup(current, identity) || !file_identity_sameFileIdentityForCleanup(target, identity)) {
|
|
53791
|
+
throw new errors_FsSafeError("path-mismatch", "published copy temporary name changed before cleanup");
|
|
53792
|
+
}
|
|
53793
|
+
};
|
|
53794
|
+
verifyPair();
|
|
53795
|
+
if (params.beforeTemporaryUnlink) {
|
|
53796
|
+
await params.beforeTemporaryUnlink();
|
|
53797
|
+
verifyPair();
|
|
53788
53798
|
}
|
|
53789
53799
|
// This removes the stage's name, never the published destination or source.
|
|
53790
53800
|
external_node_fs_.unlinkSync(temporaryPath);
|
|
@@ -53857,6 +53867,40 @@ function publishThroughPlaceholder(params, assertCurrent) {
|
|
|
53857
53867
|
}
|
|
53858
53868
|
}
|
|
53859
53869
|
|
|
53870
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/publication-handle.js
|
|
53871
|
+
|
|
53872
|
+
|
|
53873
|
+
|
|
53874
|
+
|
|
53875
|
+
|
|
53876
|
+
|
|
53877
|
+
/** Pin the published name before releasing a descriptor opened through its stage. */
|
|
53878
|
+
async function openPublicationHandle(targetPath, identity) {
|
|
53879
|
+
const flags = read_open_flags_resolveReadOpenFlags();
|
|
53880
|
+
const handle = await promises_.open(targetPath, flags).catch(async (error) => {
|
|
53881
|
+
// Restrictive final modes must not be widened just to inspect publication.
|
|
53882
|
+
if (!hasErrorCode(error, "EACCES") || (process.arch !== "x64" && process.arch !== "arm64"))
|
|
53883
|
+
throw error;
|
|
53884
|
+
const metadataFlag = process.platform === "linux" ? 0x200000 : undefined; // O_PATH
|
|
53885
|
+
if (metadataFlag === undefined)
|
|
53886
|
+
throw error;
|
|
53887
|
+
return promises_.open(targetPath, metadataFlag | external_node_fs_.constants.O_NOFOLLOW);
|
|
53888
|
+
});
|
|
53889
|
+
try {
|
|
53890
|
+
const opened = external_node_fs_.fstatSync(handle.fd, { bigint: true });
|
|
53891
|
+
const named = external_node_fs_.lstatSync(targetPath, { bigint: true });
|
|
53892
|
+
if (!opened.isFile() || !named.isFile() || named.isSymbolicLink() ||
|
|
53893
|
+
!file_identity_sameFileIdentityForCleanup(opened, identity) || !file_identity_sameFileIdentityForCleanup(named, identity)) {
|
|
53894
|
+
throw new errors_FsSafeError("path-mismatch", "publication descriptor handoff identity changed");
|
|
53895
|
+
}
|
|
53896
|
+
return handle;
|
|
53897
|
+
}
|
|
53898
|
+
catch (error) {
|
|
53899
|
+
await handle.close().catch(() => undefined);
|
|
53900
|
+
throw error;
|
|
53901
|
+
}
|
|
53902
|
+
}
|
|
53903
|
+
|
|
53860
53904
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js
|
|
53861
53905
|
|
|
53862
53906
|
|
|
@@ -53878,6 +53922,7 @@ function publishThroughPlaceholder(params, assertCurrent) {
|
|
|
53878
53922
|
|
|
53879
53923
|
|
|
53880
53924
|
|
|
53925
|
+
|
|
53881
53926
|
|
|
53882
53927
|
|
|
53883
53928
|
async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
@@ -53895,6 +53940,7 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
|
53895
53940
|
let handle;
|
|
53896
53941
|
let tempIdentity;
|
|
53897
53942
|
let readHandle;
|
|
53943
|
+
let handoffCloseFailure;
|
|
53898
53944
|
let renamed = false;
|
|
53899
53945
|
const completeCreate = params.overwrite === false && params.input.kind !== "file" && params.input.stageBeforePublish === true;
|
|
53900
53946
|
let receipt;
|
|
@@ -53949,11 +53995,15 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
|
53949
53995
|
}), external_node_path_.basename(tempPath), external_node_fs_.fstatSync(handle.fd, { bigint: true }));
|
|
53950
53996
|
}
|
|
53951
53997
|
let verifiedIdentity = expectedTempStat;
|
|
53998
|
+
// Keep unreadable modes supported where Node has no read-free file open.
|
|
53999
|
+
const canHandoff = process.platform !== "win32" &&
|
|
54000
|
+
((params.mode & 0o400) !== 0 ||
|
|
54001
|
+
(process.platform === "linux" && (process.arch === "x64" || process.arch === "arm64")));
|
|
53952
54002
|
phase = "publish";
|
|
53953
54003
|
await withAsyncDirectoryGuards([parentGuard], async () => {
|
|
53954
54004
|
assertFinalSymlinkRejected(targetPath, params.rejectFinalSymlink);
|
|
53955
54005
|
if (params.overwrite === false) {
|
|
53956
|
-
publishCopyStage({
|
|
54006
|
+
await publishCopyStage({
|
|
53957
54007
|
temporaryPath: tempPath, targetPath, fd: handle.fd,
|
|
53958
54008
|
identity: tempIdentity, parentGuard,
|
|
53959
54009
|
assertBeforeMutation,
|
|
@@ -53967,6 +54017,18 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
|
53967
54017
|
publication = Object.freeze({ status: "published", staged: receipt, basename: params.basename, overwrite: false });
|
|
53968
54018
|
params.onPublished?.(identity);
|
|
53969
54019
|
},
|
|
54020
|
+
beforeTemporaryUnlink: !canHandoff ? undefined : async () => {
|
|
54021
|
+
readHandle = await openPublicationHandle(targetPath, expectedTempStat);
|
|
54022
|
+
// Keep the destination pinned while closing the stage's NFS dentry.
|
|
54023
|
+
const stagedHandle = handle;
|
|
54024
|
+
handle = undefined;
|
|
54025
|
+
try {
|
|
54026
|
+
await stagedHandle.close();
|
|
54027
|
+
}
|
|
54028
|
+
catch (error) {
|
|
54029
|
+
handoffCloseFailure = { error };
|
|
54030
|
+
}
|
|
54031
|
+
},
|
|
53970
54032
|
});
|
|
53971
54033
|
}
|
|
53972
54034
|
else {
|
|
@@ -53994,6 +54056,7 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
|
53994
54056
|
throw new errors_FsSafeError("path-mismatch", "fallback target changed during write");
|
|
53995
54057
|
}
|
|
53996
54058
|
const expectedHash = sha256Hex(params.input.data, params.input.encoding);
|
|
54059
|
+
await readHandle?.close();
|
|
53997
54060
|
readHandle = await promises_.open(targetPath, read_open_flags_resolveReadOpenFlags());
|
|
53998
54061
|
const readHandleStat = external_node_fs_.fstatSync(readHandle.fd, { bigint: true });
|
|
53999
54062
|
const actualHash = sha256Hex(await readFileHandleBounded(readHandle, Infinity));
|
|
@@ -54032,7 +54095,11 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
|
54032
54095
|
pathname: tempPath, handle, identity: tempIdentity, parentGuard, throwOnCleanupError: true,
|
|
54033
54096
|
}) : "not-needed";
|
|
54034
54097
|
},
|
|
54035
|
-
close: [async () => { await readHandle?.close(); }, async () => {
|
|
54098
|
+
close: [async () => { await readHandle?.close(); }, async () => {
|
|
54099
|
+
await handle?.close();
|
|
54100
|
+
if (handoffCloseFailure)
|
|
54101
|
+
throw handoffCloseFailure.error;
|
|
54102
|
+
}],
|
|
54036
54103
|
});
|
|
54037
54104
|
}
|
|
54038
54105
|
else
|
|
@@ -90263,8 +90330,12 @@ function encodeCharacterReference(code) {
|
|
|
90263
90330
|
|
|
90264
90331
|
;// CONCATENATED MODULE: ../../node_modules/unist-util-visit-parents/lib/color.node.js
|
|
90265
90332
|
/**
|
|
90333
|
+
* Color a string.
|
|
90334
|
+
*
|
|
90266
90335
|
* @param {string} d
|
|
90336
|
+
* Value.
|
|
90267
90337
|
* @returns {string}
|
|
90338
|
+
* Colored value.
|
|
90268
90339
|
*/
|
|
90269
90340
|
function color_node_color(d) {
|
|
90270
90341
|
return '\u001B[33m' + d + '\u001B[39m'
|
|
@@ -90440,46 +90511,98 @@ function color_node_color(d) {
|
|
|
90440
90511
|
* List with one or two values, the first an action, the second an index.
|
|
90441
90512
|
*
|
|
90442
90513
|
* @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult
|
|
90443
|
-
* Any value that can be returned from
|
|
90514
|
+
* Any value that can be returned from an enter visitor.
|
|
90515
|
+
*
|
|
90516
|
+
* Like `VisitorResultExit`,
|
|
90517
|
+
* but `SKIP` can also be returned,
|
|
90518
|
+
* to not walk the children of the node,
|
|
90519
|
+
* and `ActionTuple` can be used to combine an action with an index.
|
|
90520
|
+
*
|
|
90521
|
+
* @typedef {Index | boolean | null | undefined | void} VisitorResultExit
|
|
90522
|
+
* Any value that can be returned from an exit visitor.
|
|
90444
90523
|
*/
|
|
90445
90524
|
|
|
90446
90525
|
/**
|
|
90447
90526
|
* @callback Visitor
|
|
90448
|
-
* Handle a node (matching `test`, if given).
|
|
90449
|
-
*
|
|
90450
|
-
*
|
|
90451
|
-
*
|
|
90452
|
-
*
|
|
90453
|
-
*
|
|
90454
|
-
*
|
|
90455
|
-
*
|
|
90456
|
-
*
|
|
90457
|
-
*
|
|
90458
|
-
* sibling to traverse after `node` is traversed.
|
|
90459
|
-
* Adding or removing next siblings of `node` (or previous siblings, in case
|
|
90460
|
-
* of reverse) is handled as expected without needing to return a new `Index`.
|
|
90461
|
-
*
|
|
90462
|
-
* Removing the children property of an ancestor still results in them being
|
|
90463
|
-
* traversed.
|
|
90527
|
+
* Handle a node (matching `test`, if given) before its children.
|
|
90528
|
+
*
|
|
90529
|
+
* Changes inside `node` are walked next.
|
|
90530
|
+
* Replacing or removing it is easier in `exit`.
|
|
90531
|
+
* When replacing or removing it here,
|
|
90532
|
+
* return `SKIP` (as otherwise its old children are walked),
|
|
90533
|
+
* or `[SKIP, index]` to continue with the node now at `index`.
|
|
90534
|
+
* Changing next siblings (in walk order) is fine;
|
|
90535
|
+
* changing previous siblings needs a new `Index`.
|
|
90536
|
+
* Removing an ancestor or changing its previous siblings is not supported.
|
|
90464
90537
|
* @param {Visited} node
|
|
90465
90538
|
* Found node.
|
|
90466
90539
|
* @param {Array<VisitedParents>} ancestors
|
|
90467
90540
|
* Ancestors of `node`.
|
|
90541
|
+
* @param {number | undefined} index
|
|
90542
|
+
* Index of `node` in its parent (the last of `ancestors`),
|
|
90543
|
+
* or `undefined` for the tree itself.
|
|
90468
90544
|
* @returns {VisitorResult}
|
|
90469
90545
|
* What to do next.
|
|
90470
90546
|
*
|
|
90471
|
-
*
|
|
90472
|
-
*
|
|
90547
|
+
* Like `VisitorExit`,
|
|
90548
|
+
* but `SKIP` can also be returned,
|
|
90549
|
+
* to not walk the children of `node`.
|
|
90550
|
+
* Passing a tuple back (`ActionTuple`) only makes sense as `[SKIP, Index]`.
|
|
90551
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
90552
|
+
* Visited node type.
|
|
90553
|
+
* @template {UnistParent} [VisitedParents=UnistParent]
|
|
90554
|
+
* Ancestor type.
|
|
90555
|
+
*/
|
|
90556
|
+
|
|
90557
|
+
/**
|
|
90558
|
+
* @callback VisitorExit
|
|
90559
|
+
* Handle a node (matching `test`, if given) after its children.
|
|
90560
|
+
*
|
|
90561
|
+
* Changes inside `node` are not walked,
|
|
90562
|
+
* which makes this a good place to change `node` based on its children,
|
|
90563
|
+
* or to replace or remove it.
|
|
90564
|
+
* When removing `node` or changing previous siblings (in walk order),
|
|
90565
|
+
* return a new `Index`.
|
|
90566
|
+
* Removing an ancestor or changing its previous siblings is not supported.
|
|
90567
|
+
* @param {Visited} node
|
|
90568
|
+
* Found node.
|
|
90569
|
+
* @param {Array<VisitedParents>} ancestors
|
|
90570
|
+
* Ancestors of `node`.
|
|
90571
|
+
* @param {number | undefined} index
|
|
90572
|
+
* Index of `node` in its parent (the last of `ancestors`),
|
|
90573
|
+
* or `undefined` for the tree itself.
|
|
90574
|
+
* @returns {VisitorResultExit}
|
|
90575
|
+
* What to do next.
|
|
90473
90576
|
*
|
|
90474
|
-
*
|
|
90475
|
-
*
|
|
90476
|
-
*
|
|
90577
|
+
* `CONTINUE` (`true`, nothing) continues as normal,
|
|
90578
|
+
* `EXIT` (`false`) stops traversing,
|
|
90579
|
+
* and `Index` continues at that sibling.
|
|
90477
90580
|
* @template {UnistNode} [Visited=UnistNode]
|
|
90478
90581
|
* Visited node type.
|
|
90479
90582
|
* @template {UnistParent} [VisitedParents=UnistParent]
|
|
90480
90583
|
* Ancestor type.
|
|
90481
90584
|
*/
|
|
90482
90585
|
|
|
90586
|
+
/**
|
|
90587
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
90588
|
+
* Visited node type.
|
|
90589
|
+
* @template {UnistParent} [VisitedParents=UnistParent]
|
|
90590
|
+
* Ancestor type.
|
|
90591
|
+
* @typedef Visitors
|
|
90592
|
+
* Handle nodes when entering and exiting them.
|
|
90593
|
+
* The `enter` visitor is optional while `exit` is required.
|
|
90594
|
+
*
|
|
90595
|
+
* Pass an `enter` visitor directly to only handle nodes when entering them.
|
|
90596
|
+
*
|
|
90597
|
+
* `enter` is called before children (if any) are walked and `exit` after that.
|
|
90598
|
+
* `exit` is still called when `enter` returns `SKIP`.
|
|
90599
|
+
* Both `enter` and `exit` are only called for nodes that match an optional `test`.
|
|
90600
|
+
* @property {Visitor<Visited, VisitedParents> | null | undefined} [enter]
|
|
90601
|
+
* Handle a node before its children (optional).
|
|
90602
|
+
* @property {VisitorExit<Visited, VisitedParents>} exit
|
|
90603
|
+
* Handle a node after its children.
|
|
90604
|
+
*/
|
|
90605
|
+
|
|
90483
90606
|
/**
|
|
90484
90607
|
* @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor
|
|
90485
90608
|
* Build a typed `Visitor` function from a tree and a test.
|
|
@@ -90491,6 +90614,17 @@ function color_node_color(d) {
|
|
|
90491
90614
|
* Test type.
|
|
90492
90615
|
*/
|
|
90493
90616
|
|
|
90617
|
+
/**
|
|
90618
|
+
* @typedef {Visitors<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitors
|
|
90619
|
+
* Build typed `Visitors` from a tree and a test.
|
|
90620
|
+
*
|
|
90621
|
+
* It will infer which values are passed as `node` and which as `parents`.
|
|
90622
|
+
* @template {UnistNode} [Tree=UnistNode]
|
|
90623
|
+
* Tree type.
|
|
90624
|
+
* @template {Test} [Check=Test]
|
|
90625
|
+
* Test type.
|
|
90626
|
+
*/
|
|
90627
|
+
|
|
90494
90628
|
|
|
90495
90629
|
|
|
90496
90630
|
|
|
@@ -90509,6 +90643,7 @@ const EXIT = false
|
|
|
90509
90643
|
|
|
90510
90644
|
/**
|
|
90511
90645
|
* Do not traverse this node’s children.
|
|
90646
|
+
* Only works when entering a node.
|
|
90512
90647
|
*/
|
|
90513
90648
|
const SKIP = 'skip'
|
|
90514
90649
|
|
|
@@ -90516,10 +90651,13 @@ const SKIP = 'skip'
|
|
|
90516
90651
|
* Visit nodes, with ancestral information.
|
|
90517
90652
|
*
|
|
90518
90653
|
* This algorithm performs *depth-first* *tree traversal* in *preorder*
|
|
90519
|
-
* (**NLR**) or if `reverse` is given,
|
|
90654
|
+
* (**NLR**) or if `reverse` is given,
|
|
90655
|
+
* in *reverse preorder* (**NRL**).
|
|
90656
|
+
* An `exit` visitor is called in *postorder* (**LRN**)
|
|
90657
|
+
* or if `reverse` is given, in *reverse postorder* (**RLN**).
|
|
90520
90658
|
*
|
|
90521
|
-
* You can choose
|
|
90522
|
-
* For complex tests, you should test yourself in
|
|
90659
|
+
* You can choose which nodes are visited by passing a `test`.
|
|
90660
|
+
* For complex tests, you should test yourself in a visitor, as it will be
|
|
90523
90661
|
* faster and will have improved type information.
|
|
90524
90662
|
*
|
|
90525
90663
|
* Walking the tree is an intensive task.
|
|
@@ -90528,29 +90666,72 @@ const SKIP = 'skip'
|
|
|
90528
90666
|
* to check if a node matches, and then perform different operations.
|
|
90529
90667
|
*
|
|
90530
90668
|
* You can change the tree.
|
|
90531
|
-
*
|
|
90669
|
+
* Changes inside a node made when entering it are walked,
|
|
90670
|
+
* changes made when exiting it are not.
|
|
90671
|
+
* See `Visitor` and `VisitorExit` for more info.
|
|
90532
90672
|
*
|
|
90533
90673
|
* @overload
|
|
90534
90674
|
* @param {Tree} tree
|
|
90675
|
+
* Tree to traverse.
|
|
90535
90676
|
* @param {Check} check
|
|
90536
|
-
*
|
|
90677
|
+
* `unist-util-is`-compatible test.
|
|
90678
|
+
* @param {BuildVisitor<Tree, Check>} enter
|
|
90679
|
+
* Handle each node when entering it.
|
|
90537
90680
|
* @param {boolean | null | undefined} [reverse]
|
|
90681
|
+
* Walk children from last to first;
|
|
90682
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
90683
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
90538
90684
|
* @returns {undefined}
|
|
90685
|
+
* Nothing.
|
|
90539
90686
|
*
|
|
90540
90687
|
* @overload
|
|
90541
90688
|
* @param {Tree} tree
|
|
90542
|
-
*
|
|
90689
|
+
* Tree to traverse.
|
|
90690
|
+
* @param {Check} check
|
|
90691
|
+
* `unist-util-is`-compatible test.
|
|
90692
|
+
* @param {BuildVisitors<Tree, Check>} visitors
|
|
90693
|
+
* Handle each node when exiting it, and optionally when entering it.
|
|
90694
|
+
* @param {boolean | null | undefined} [reverse]
|
|
90695
|
+
* Walk children from last to first;
|
|
90696
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
90697
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
90698
|
+
* @returns {undefined}
|
|
90699
|
+
* Nothing.
|
|
90700
|
+
*
|
|
90701
|
+
* @overload
|
|
90702
|
+
* @param {Tree} tree
|
|
90703
|
+
* Tree to traverse.
|
|
90704
|
+
* @param {BuildVisitor<Tree>} enter
|
|
90705
|
+
* Handle each node when entering it.
|
|
90543
90706
|
* @param {boolean | null | undefined} [reverse]
|
|
90707
|
+
* Walk children from last to first;
|
|
90708
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
90709
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
90544
90710
|
* @returns {undefined}
|
|
90711
|
+
* Nothing.
|
|
90712
|
+
*
|
|
90713
|
+
* @overload
|
|
90714
|
+
* @param {Tree} tree
|
|
90715
|
+
* Tree to traverse.
|
|
90716
|
+
* @param {BuildVisitors<Tree>} visitors
|
|
90717
|
+
* Handle each node when exiting it, and optionally when entering it.
|
|
90718
|
+
* @param {boolean | null | undefined} [reverse]
|
|
90719
|
+
* Walk children from last to first;
|
|
90720
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
90721
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
90722
|
+
* @returns {undefined}
|
|
90723
|
+
* Nothing.
|
|
90545
90724
|
*
|
|
90546
90725
|
* @param {UnistNode} tree
|
|
90547
90726
|
* Tree to traverse.
|
|
90548
|
-
* @param {Visitor | Test}
|
|
90549
|
-
* `unist-util-is`-compatible test
|
|
90550
|
-
* @param {Visitor | boolean | null | undefined} [
|
|
90551
|
-
*
|
|
90727
|
+
* @param {Visitor | Visitors | Test} testOrEnterOrVisitors
|
|
90728
|
+
* `unist-util-is`-compatible test, `enter`, or `visitors`.
|
|
90729
|
+
* @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]
|
|
90730
|
+
* `enter`, `visitors`, or `reverse` after a test.
|
|
90552
90731
|
* @param {boolean | null | undefined} [reverse]
|
|
90553
|
-
*
|
|
90732
|
+
* Walk children from last to first;
|
|
90733
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
90734
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
90554
90735
|
* @returns {undefined}
|
|
90555
90736
|
* Nothing.
|
|
90556
90737
|
*
|
|
@@ -90559,28 +90740,89 @@ const SKIP = 'skip'
|
|
|
90559
90740
|
* @template {Test} Check
|
|
90560
90741
|
* `unist-util-is`-compatible test.
|
|
90561
90742
|
*/
|
|
90562
|
-
function visitParents(
|
|
90743
|
+
function visitParents(
|
|
90744
|
+
tree,
|
|
90745
|
+
testOrEnterOrVisitors,
|
|
90746
|
+
enterOrVisitorsOrReverse,
|
|
90747
|
+
reverse
|
|
90748
|
+
) {
|
|
90749
|
+
if (!tree || typeof tree !== 'object') {
|
|
90750
|
+
throw new Error('Unexpected value `' + tree + '` for `tree`, expected node')
|
|
90751
|
+
}
|
|
90752
|
+
|
|
90753
|
+
let preorder = true
|
|
90563
90754
|
/** @type {Test} */
|
|
90564
90755
|
let check
|
|
90756
|
+
/** @type {Visitors | Visitor} */
|
|
90757
|
+
let visitors
|
|
90758
|
+
/** @type {Visitor | null | undefined} */
|
|
90759
|
+
let enter
|
|
90760
|
+
/** @type {VisitorExit | null | undefined} */
|
|
90761
|
+
let exit
|
|
90762
|
+
|
|
90763
|
+
// Third parameter is an enter visitor or a visitors object, so expect a `test` too.
|
|
90764
|
+
if (
|
|
90765
|
+
typeof enterOrVisitorsOrReverse === 'function' ||
|
|
90766
|
+
(enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === 'object')
|
|
90767
|
+
) {
|
|
90768
|
+
check = /** @type {Test} */ (testOrEnterOrVisitors)
|
|
90769
|
+
visitors = enterOrVisitorsOrReverse
|
|
90770
|
+
if (reverse) preorder = false
|
|
90771
|
+
}
|
|
90772
|
+
// Assume no test.
|
|
90773
|
+
else {
|
|
90774
|
+
visitors = /** @type {Visitors | Visitor} */ (testOrEnterOrVisitors)
|
|
90775
|
+
if (enterOrVisitorsOrReverse) preorder = false
|
|
90776
|
+
}
|
|
90565
90777
|
|
|
90566
|
-
if (typeof
|
|
90567
|
-
|
|
90568
|
-
|
|
90569
|
-
|
|
90778
|
+
if (typeof visitors === 'function') {
|
|
90779
|
+
enter = visitors
|
|
90780
|
+
} else if (visitors && typeof visitors === 'object') {
|
|
90781
|
+
if (visitors.enter === null || visitors.enter === undefined) {
|
|
90782
|
+
// Empty.
|
|
90783
|
+
} else if (typeof visitors.enter === 'function') {
|
|
90784
|
+
enter = visitors.enter
|
|
90785
|
+
} else {
|
|
90786
|
+
throw new Error(
|
|
90787
|
+
'Unexpected value `' +
|
|
90788
|
+
visitors.enter +
|
|
90789
|
+
'` for `visitors.enter`, expected optional visitor'
|
|
90790
|
+
)
|
|
90791
|
+
}
|
|
90792
|
+
|
|
90793
|
+
if (typeof visitors.exit === 'function') {
|
|
90794
|
+
exit = visitors.exit
|
|
90795
|
+
} else {
|
|
90796
|
+
throw new Error(
|
|
90797
|
+
'Unexpected value `' +
|
|
90798
|
+
visitors.exit +
|
|
90799
|
+
'` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)'
|
|
90800
|
+
)
|
|
90801
|
+
}
|
|
90570
90802
|
} else {
|
|
90571
|
-
|
|
90572
|
-
|
|
90803
|
+
throw new Error(
|
|
90804
|
+
'Unexpected value `' +
|
|
90805
|
+
visitors +
|
|
90806
|
+
'` for `enter` or `visitors`, expected visitor or object with visitors'
|
|
90807
|
+
)
|
|
90573
90808
|
}
|
|
90574
90809
|
|
|
90575
90810
|
const is = convert(check)
|
|
90576
|
-
const step =
|
|
90811
|
+
const step = preorder ? 1 : -1
|
|
90577
90812
|
|
|
90578
90813
|
factory(tree, undefined, [])()
|
|
90579
90814
|
|
|
90580
90815
|
/**
|
|
90816
|
+
* Create a function to visit a node.
|
|
90817
|
+
*
|
|
90581
90818
|
* @param {UnistNode} node
|
|
90819
|
+
* Node to visit.
|
|
90582
90820
|
* @param {number | undefined} index
|
|
90821
|
+
* Index of `node` in its parent.
|
|
90583
90822
|
* @param {Array<UnistParent>} parents
|
|
90823
|
+
* Ancestors of `node`.
|
|
90824
|
+
* @returns {() => Readonly<ActionTuple>}
|
|
90825
|
+
* Visit `node`.
|
|
90584
90826
|
*/
|
|
90585
90827
|
function factory(node, index, parents) {
|
|
90586
90828
|
const value = /** @type {Record<string, unknown>} */ (
|
|
@@ -90606,18 +90848,13 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
90606
90848
|
return visit
|
|
90607
90849
|
|
|
90608
90850
|
function visit() {
|
|
90851
|
+
const matches =
|
|
90852
|
+
!check || is(node, index, parents[parents.length - 1] || undefined)
|
|
90609
90853
|
/** @type {Readonly<ActionTuple>} */
|
|
90610
90854
|
let result = lib_empty
|
|
90611
|
-
/** @type {Readonly<ActionTuple>} */
|
|
90612
|
-
let subresult
|
|
90613
|
-
/** @type {number} */
|
|
90614
|
-
let offset
|
|
90615
|
-
/** @type {Array<UnistParent>} */
|
|
90616
|
-
let grandparents
|
|
90617
90855
|
|
|
90618
|
-
if (
|
|
90619
|
-
|
|
90620
|
-
result = toResult(visitor(node, parents))
|
|
90856
|
+
if (enter && matches) {
|
|
90857
|
+
result = toResult(enter(node, parents, index))
|
|
90621
90858
|
|
|
90622
90859
|
if (result[0] === EXIT) {
|
|
90623
90860
|
return result
|
|
@@ -90628,13 +90865,13 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
90628
90865
|
const nodeAsParent = /** @type {UnistParent} */ (node)
|
|
90629
90866
|
|
|
90630
90867
|
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
90631
|
-
offset = (
|
|
90632
|
-
grandparents = parents
|
|
90868
|
+
let offset = (preorder ? -1 : nodeAsParent.children.length) + step
|
|
90869
|
+
const grandparents = [...parents, nodeAsParent]
|
|
90633
90870
|
|
|
90634
90871
|
while (offset > -1 && offset < nodeAsParent.children.length) {
|
|
90635
90872
|
const child = nodeAsParent.children[offset]
|
|
90636
90873
|
|
|
90637
|
-
subresult = factory(child, offset, grandparents)()
|
|
90874
|
+
const subresult = factory(child, offset, grandparents)()
|
|
90638
90875
|
|
|
90639
90876
|
if (subresult[0] === EXIT) {
|
|
90640
90877
|
return subresult
|
|
@@ -90646,6 +90883,23 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
90646
90883
|
}
|
|
90647
90884
|
}
|
|
90648
90885
|
|
|
90886
|
+
if (exit && matches) {
|
|
90887
|
+
const exitResult = toResult(exit(node, parents, index))
|
|
90888
|
+
|
|
90889
|
+
if (exitResult[0] === SKIP) {
|
|
90890
|
+
throw new Error(
|
|
90891
|
+
'Unexpected value `' +
|
|
90892
|
+
exitResult[0] +
|
|
90893
|
+
'` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing'
|
|
90894
|
+
)
|
|
90895
|
+
}
|
|
90896
|
+
|
|
90897
|
+
// Prefer a result from `exit` over `enter`.
|
|
90898
|
+
if (exitResult[0] === EXIT || typeof exitResult[1] === 'number') {
|
|
90899
|
+
return exitResult
|
|
90900
|
+
}
|
|
90901
|
+
}
|
|
90902
|
+
|
|
90649
90903
|
return result
|
|
90650
90904
|
}
|
|
90651
90905
|
}
|
|
@@ -90674,7 +90928,13 @@ function toResult(value) {
|
|
|
90674
90928
|
;// CONCATENATED MODULE: ../../node_modules/unist-util-visit/lib/index.js
|
|
90675
90929
|
/**
|
|
90676
90930
|
* @import {Node as UnistNode, Parent as UnistParent} from 'unist'
|
|
90677
|
-
* @import {
|
|
90931
|
+
* @import {
|
|
90932
|
+
* InclusiveDescendant,
|
|
90933
|
+
* Matches,
|
|
90934
|
+
* Visitors as ParentsVisitors,
|
|
90935
|
+
* VisitorResult,
|
|
90936
|
+
* VisitorResultExit
|
|
90937
|
+
* } from 'unist-util-visit-parents'
|
|
90678
90938
|
*/
|
|
90679
90939
|
|
|
90680
90940
|
/**
|
|
@@ -90686,67 +90946,6 @@ function toResult(value) {
|
|
|
90686
90946
|
* which doesn’t work when publishing on npm.
|
|
90687
90947
|
*/
|
|
90688
90948
|
|
|
90689
|
-
// To do: use types from `unist-util-visit-parents` when it’s released.
|
|
90690
|
-
|
|
90691
|
-
/**
|
|
90692
|
-
* @typedef {(
|
|
90693
|
-
* Fn extends (value: any) => value is infer Thing
|
|
90694
|
-
* ? Thing
|
|
90695
|
-
* : Fallback
|
|
90696
|
-
* )} Predicate
|
|
90697
|
-
* Get the value of a type guard `Fn`.
|
|
90698
|
-
* @template Fn
|
|
90699
|
-
* Value; typically function that is a type guard (such as `(x): x is Y`).
|
|
90700
|
-
* @template Fallback
|
|
90701
|
-
* Value to yield if `Fn` is not a type guard.
|
|
90702
|
-
*/
|
|
90703
|
-
|
|
90704
|
-
/**
|
|
90705
|
-
* @typedef {(
|
|
90706
|
-
* Check extends null | undefined // No test.
|
|
90707
|
-
* ? Value
|
|
90708
|
-
* : Value extends {type: Check} // String (type) test.
|
|
90709
|
-
* ? Value
|
|
90710
|
-
* : Value extends Check // Partial test.
|
|
90711
|
-
* ? Value
|
|
90712
|
-
* : Check extends Function // Function test.
|
|
90713
|
-
* ? Predicate<Check, Value> extends Value
|
|
90714
|
-
* ? Predicate<Check, Value>
|
|
90715
|
-
* : never
|
|
90716
|
-
* : never // Some other test?
|
|
90717
|
-
* )} MatchesOne
|
|
90718
|
-
* Check whether a node matches a primitive check in the type system.
|
|
90719
|
-
* @template Value
|
|
90720
|
-
* Value; typically unist `Node`.
|
|
90721
|
-
* @template Check
|
|
90722
|
-
* Value; typically `unist-util-is`-compatible test, but not arrays.
|
|
90723
|
-
*/
|
|
90724
|
-
|
|
90725
|
-
/**
|
|
90726
|
-
* @typedef {(
|
|
90727
|
-
* Check extends ReadonlyArray<any>
|
|
90728
|
-
* ? MatchesOne<Value, Check[number]>
|
|
90729
|
-
* : MatchesOne<Value, Check>
|
|
90730
|
-
* )} Matches
|
|
90731
|
-
* Check whether a node matches a check in the type system.
|
|
90732
|
-
* @template Value
|
|
90733
|
-
* Value; typically unist `Node`.
|
|
90734
|
-
* @template Check
|
|
90735
|
-
* Value; typically `unist-util-is`-compatible test.
|
|
90736
|
-
*/
|
|
90737
|
-
|
|
90738
|
-
/**
|
|
90739
|
-
* @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint
|
|
90740
|
-
* Number; capped reasonably.
|
|
90741
|
-
*/
|
|
90742
|
-
|
|
90743
|
-
/**
|
|
90744
|
-
* @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
|
|
90745
|
-
* Increment a number in the type system.
|
|
90746
|
-
* @template {Uint} [I=0]
|
|
90747
|
-
* Index.
|
|
90748
|
-
*/
|
|
90749
|
-
|
|
90750
90949
|
/**
|
|
90751
90950
|
* @typedef {(
|
|
90752
90951
|
* Node extends UnistParent
|
|
@@ -90772,89 +90971,64 @@ function toResult(value) {
|
|
|
90772
90971
|
*/
|
|
90773
90972
|
|
|
90774
90973
|
/**
|
|
90775
|
-
* @
|
|
90776
|
-
*
|
|
90777
|
-
* ? never
|
|
90778
|
-
* :
|
|
90779
|
-
* | InternalParent<Node, Child>
|
|
90780
|
-
* | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>
|
|
90781
|
-
* )} InternalAncestor
|
|
90782
|
-
* Collect nodes in `Tree` that can be ancestors of `Child`.
|
|
90783
|
-
* @template {UnistNode} Node
|
|
90784
|
-
* All node types in a tree.
|
|
90785
|
-
* @template {UnistNode} Child
|
|
90786
|
-
* Node to search for.
|
|
90787
|
-
* @template {Uint} [Max=10]
|
|
90788
|
-
* Max; searches up to this depth.
|
|
90789
|
-
* @template {Uint} [Depth=0]
|
|
90790
|
-
* Current depth.
|
|
90791
|
-
*/
|
|
90792
|
-
|
|
90793
|
-
/**
|
|
90794
|
-
* @typedef {(
|
|
90795
|
-
* Tree extends UnistParent
|
|
90796
|
-
* ? Depth extends Max
|
|
90797
|
-
* ? Tree
|
|
90798
|
-
* : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>
|
|
90799
|
-
* : Tree
|
|
90800
|
-
* )} InclusiveDescendant
|
|
90801
|
-
* Collect all (inclusive) descendants of `Tree`.
|
|
90974
|
+
* @callback Visitor
|
|
90975
|
+
* Handle a node (matching `test`, if given) before its children.
|
|
90802
90976
|
*
|
|
90803
|
-
*
|
|
90804
|
-
*
|
|
90805
|
-
*
|
|
90806
|
-
*
|
|
90807
|
-
*
|
|
90808
|
-
*
|
|
90809
|
-
*
|
|
90810
|
-
*
|
|
90811
|
-
*
|
|
90812
|
-
*
|
|
90813
|
-
* @
|
|
90814
|
-
*
|
|
90815
|
-
* @template {
|
|
90816
|
-
*
|
|
90977
|
+
* Like `Visitor` in `unist-util-visit-parents`,
|
|
90978
|
+
* but with `index` and `parent` instead of `parents`.
|
|
90979
|
+
* @param {Visited} node
|
|
90980
|
+
* Found node.
|
|
90981
|
+
* @param {Visited extends UnistNode ? number | undefined : never} index
|
|
90982
|
+
* Index of `node` in `parent`,
|
|
90983
|
+
* or `undefined` for the tree itself.
|
|
90984
|
+
* @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
|
|
90985
|
+
* Parent of `node`,
|
|
90986
|
+
* or `undefined` for the tree itself.
|
|
90987
|
+
* @returns {VisitorResult}
|
|
90988
|
+
* What to do next.
|
|
90989
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
90990
|
+
* Visited node type.
|
|
90991
|
+
* @template {UnistParent} [Ancestor=UnistParent]
|
|
90992
|
+
* Ancestor type.
|
|
90817
90993
|
*/
|
|
90818
90994
|
|
|
90819
90995
|
/**
|
|
90820
|
-
* @callback
|
|
90821
|
-
* Handle a node (matching `test`, if given).
|
|
90822
|
-
*
|
|
90823
|
-
* Visitors are free to transform `node`.
|
|
90824
|
-
* They can also transform `parent`.
|
|
90996
|
+
* @callback VisitorExit
|
|
90997
|
+
* Handle a node (matching `test`, if given) after its children.
|
|
90825
90998
|
*
|
|
90826
|
-
*
|
|
90827
|
-
*
|
|
90828
|
-
*
|
|
90829
|
-
* When adding or removing previous siblings of `node` (or next siblings, in
|
|
90830
|
-
* case of reverse), the `Visitor` should return a new `Index` to specify the
|
|
90831
|
-
* sibling to traverse after `node` is traversed.
|
|
90832
|
-
* Adding or removing next siblings of `node` (or previous siblings, in case
|
|
90833
|
-
* of reverse) is handled as expected without needing to return a new `Index`.
|
|
90834
|
-
*
|
|
90835
|
-
* Removing the children property of `parent` still results in them being
|
|
90836
|
-
* traversed.
|
|
90999
|
+
* Like `VisitorExit` in `unist-util-visit-parents`,
|
|
91000
|
+
* but with `index` and `parent` instead of `parents`.
|
|
90837
91001
|
* @param {Visited} node
|
|
90838
91002
|
* Found node.
|
|
90839
91003
|
* @param {Visited extends UnistNode ? number | undefined : never} index
|
|
90840
|
-
* Index of `node` in `parent
|
|
91004
|
+
* Index of `node` in `parent`,
|
|
91005
|
+
* or `undefined` for the tree itself.
|
|
90841
91006
|
* @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
|
|
90842
|
-
* Parent of `node
|
|
90843
|
-
*
|
|
91007
|
+
* Parent of `node`,
|
|
91008
|
+
* or `undefined` for the tree itself.
|
|
91009
|
+
* @returns {VisitorResultExit}
|
|
90844
91010
|
* What to do next.
|
|
90845
|
-
*
|
|
90846
|
-
* An `Index` is treated as a tuple of `[CONTINUE, Index]`.
|
|
90847
|
-
* An `Action` is treated as a tuple of `[Action]`.
|
|
90848
|
-
*
|
|
90849
|
-
* Passing a tuple back only makes sense if the `Action` is `SKIP`.
|
|
90850
|
-
* When the `Action` is `EXIT`, that action can be returned.
|
|
90851
|
-
* When the `Action` is `CONTINUE`, `Index` can be returned.
|
|
90852
91011
|
* @template {UnistNode} [Visited=UnistNode]
|
|
90853
91012
|
* Visited node type.
|
|
90854
91013
|
* @template {UnistParent} [Ancestor=UnistParent]
|
|
90855
91014
|
* Ancestor type.
|
|
90856
91015
|
*/
|
|
90857
91016
|
|
|
91017
|
+
/**
|
|
91018
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
91019
|
+
* Visited node type.
|
|
91020
|
+
* @template {UnistParent} [Ancestor=UnistParent]
|
|
91021
|
+
* Ancestor type.
|
|
91022
|
+
* @typedef Visitors
|
|
91023
|
+
* Handle nodes when entering and exiting them.
|
|
91024
|
+
*
|
|
91025
|
+
* Like `Visitors` in `unist-util-visit-parents`.
|
|
91026
|
+
* @property {Visitor<Visited, Ancestor> | null | undefined} [enter]
|
|
91027
|
+
* Handle a node before its children (optional).
|
|
91028
|
+
* @property {VisitorExit<Visited, Ancestor>} exit
|
|
91029
|
+
* Handle a node after its children.
|
|
91030
|
+
*/
|
|
91031
|
+
|
|
90858
91032
|
/**
|
|
90859
91033
|
* @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch
|
|
90860
91034
|
* Build a typed `Visitor` function from a node and all possible parents.
|
|
@@ -90898,6 +91072,25 @@ function toResult(value) {
|
|
|
90898
91072
|
* Test type.
|
|
90899
91073
|
*/
|
|
90900
91074
|
|
|
91075
|
+
/**
|
|
91076
|
+
* @typedef {(
|
|
91077
|
+
* Visitors<
|
|
91078
|
+
* Matches<InclusiveDescendant<Tree>, Check>,
|
|
91079
|
+
* Parent<
|
|
91080
|
+
* Extract<InclusiveDescendant<Tree>, UnistParent>,
|
|
91081
|
+
* Matches<InclusiveDescendant<Tree>, Check>
|
|
91082
|
+
* >
|
|
91083
|
+
* >
|
|
91084
|
+
* )} BuildVisitors
|
|
91085
|
+
* Build typed `Visitors` from a tree and a test.
|
|
91086
|
+
*
|
|
91087
|
+
* It will infer which values are passed as `node` and which as `parent`.
|
|
91088
|
+
* @template {UnistNode} [Tree=UnistNode]
|
|
91089
|
+
* Node type.
|
|
91090
|
+
* @template {Test} [Check=Test]
|
|
91091
|
+
* Test type.
|
|
91092
|
+
*/
|
|
91093
|
+
|
|
90901
91094
|
|
|
90902
91095
|
|
|
90903
91096
|
|
|
@@ -90906,10 +91099,13 @@ function toResult(value) {
|
|
|
90906
91099
|
* Visit nodes.
|
|
90907
91100
|
*
|
|
90908
91101
|
* This algorithm performs *depth-first* *tree traversal* in *preorder*
|
|
90909
|
-
* (**NLR**) or if `reverse` is given,
|
|
91102
|
+
* (**NLR**) or if `reverse` is given,
|
|
91103
|
+
* in *reverse preorder* (**NRL**).
|
|
91104
|
+
* An `exit` visitor is called in *postorder* (**LRN**)
|
|
91105
|
+
* or if `reverse` is given, in *reverse postorder* (**RLN**).
|
|
90910
91106
|
*
|
|
90911
|
-
* You can choose
|
|
90912
|
-
* For complex tests, you should test yourself in
|
|
91107
|
+
* You can choose which nodes are visited by passing a `test`.
|
|
91108
|
+
* For complex tests, you should test yourself in a visitor, as it will be
|
|
90913
91109
|
* faster and will have improved type information.
|
|
90914
91110
|
*
|
|
90915
91111
|
* Walking the tree is an intensive task.
|
|
@@ -90918,29 +91114,48 @@ function toResult(value) {
|
|
|
90918
91114
|
* to check if a node matches, and then perform different operations.
|
|
90919
91115
|
*
|
|
90920
91116
|
* You can change the tree.
|
|
90921
|
-
*
|
|
91117
|
+
* Changes inside a node made when entering it are walked,
|
|
91118
|
+
* changes made when exiting it are not.
|
|
91119
|
+
* See `Visitor` and `VisitorExit` for more info.
|
|
90922
91120
|
*
|
|
90923
91121
|
* @overload
|
|
90924
91122
|
* @param {Tree} tree
|
|
91123
|
+
* Tree to traverse.
|
|
90925
91124
|
* @param {Check} check
|
|
90926
|
-
*
|
|
91125
|
+
* `unist-util-is`-compatible test.
|
|
91126
|
+
* @param {BuildVisitor<Tree, Check> | BuildVisitors<Tree, Check>} visitors
|
|
91127
|
+
* Handle each node when entering it,
|
|
91128
|
+
* or `{enter, exit}` to also handle it when exiting it.
|
|
90927
91129
|
* @param {boolean | null | undefined} [reverse]
|
|
91130
|
+
* Walk children from last to first;
|
|
91131
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
91132
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
90928
91133
|
* @returns {undefined}
|
|
91134
|
+
* Nothing.
|
|
90929
91135
|
*
|
|
90930
91136
|
* @overload
|
|
90931
91137
|
* @param {Tree} tree
|
|
90932
|
-
*
|
|
91138
|
+
* Tree to traverse.
|
|
91139
|
+
* @param {BuildVisitor<Tree> | BuildVisitors<Tree>} visitors
|
|
91140
|
+
* Handle each node when entering it,
|
|
91141
|
+
* or `{enter, exit}` to also handle it when exiting it.
|
|
90933
91142
|
* @param {boolean | null | undefined} [reverse]
|
|
91143
|
+
* Walk children from last to first;
|
|
91144
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
91145
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
90934
91146
|
* @returns {undefined}
|
|
91147
|
+
* Nothing.
|
|
90935
91148
|
*
|
|
90936
91149
|
* @param {UnistNode} tree
|
|
90937
91150
|
* Tree to traverse.
|
|
90938
|
-
* @param {Visitor | Test}
|
|
90939
|
-
* `unist-util-is`-compatible test
|
|
90940
|
-
* @param {Visitor | boolean | null | undefined} [
|
|
90941
|
-
*
|
|
90942
|
-
* @param {boolean | null | undefined} [maybeReverse
|
|
90943
|
-
*
|
|
91151
|
+
* @param {Visitor | Visitors | Test} testOrEnterOrVisitors
|
|
91152
|
+
* `unist-util-is`-compatible test, `enter`, or `visitors`.
|
|
91153
|
+
* @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]
|
|
91154
|
+
* `enter`, `visitors`, or `reverse` after a test.
|
|
91155
|
+
* @param {boolean | null | undefined} [maybeReverse]
|
|
91156
|
+
* Walk children from last to first;
|
|
91157
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
91158
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
90944
91159
|
* @returns {undefined}
|
|
90945
91160
|
* Nothing.
|
|
90946
91161
|
*
|
|
@@ -90949,39 +91164,90 @@ function toResult(value) {
|
|
|
90949
91164
|
* @template {Test} Check
|
|
90950
91165
|
* `unist-util-is`-compatible test.
|
|
90951
91166
|
*/
|
|
90952
|
-
function lib_visit(
|
|
91167
|
+
function lib_visit(
|
|
91168
|
+
tree,
|
|
91169
|
+
testOrEnterOrVisitors,
|
|
91170
|
+
enterOrVisitorsOrReverse,
|
|
91171
|
+
maybeReverse
|
|
91172
|
+
) {
|
|
91173
|
+
/** @type {Test} */
|
|
91174
|
+
let check
|
|
91175
|
+
/** @type {Visitor | Visitors} */
|
|
91176
|
+
let visitors
|
|
90953
91177
|
/** @type {boolean | null | undefined} */
|
|
90954
91178
|
let reverse
|
|
90955
|
-
/** @type {Test} */
|
|
90956
|
-
let test
|
|
90957
|
-
/** @type {Visitor} */
|
|
90958
|
-
let visitor
|
|
90959
91179
|
|
|
91180
|
+
// Third parameter is an enter visitor or a visitors object, so expect a `test` too.
|
|
90960
91181
|
if (
|
|
90961
|
-
typeof
|
|
90962
|
-
typeof
|
|
91182
|
+
typeof enterOrVisitorsOrReverse === 'function' ||
|
|
91183
|
+
(enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === 'object')
|
|
90963
91184
|
) {
|
|
90964
|
-
|
|
90965
|
-
|
|
90966
|
-
reverse = visitorOrReverse
|
|
90967
|
-
} else {
|
|
90968
|
-
// @ts-expect-error: assume the overload with test was given.
|
|
90969
|
-
test = testOrVisitor
|
|
90970
|
-
// @ts-expect-error: assume the overload with test was given.
|
|
90971
|
-
visitor = visitorOrReverse
|
|
91185
|
+
check = /** @type {Test} */ (testOrEnterOrVisitors)
|
|
91186
|
+
visitors = enterOrVisitorsOrReverse
|
|
90972
91187
|
reverse = maybeReverse
|
|
90973
91188
|
}
|
|
91189
|
+
// Assume no test.
|
|
91190
|
+
else {
|
|
91191
|
+
visitors = /** @type {Visitor | Visitors} */ (testOrEnterOrVisitors)
|
|
91192
|
+
reverse = enterOrVisitorsOrReverse
|
|
91193
|
+
}
|
|
90974
91194
|
|
|
90975
|
-
|
|
91195
|
+
if (typeof visitors === 'function') {
|
|
91196
|
+
visitParents(tree, check, lib_wrap(visitors), reverse)
|
|
91197
|
+
} else {
|
|
91198
|
+
visitParents(tree, check, wrapVisitors(visitors), reverse)
|
|
91199
|
+
}
|
|
91200
|
+
}
|
|
91201
|
+
|
|
91202
|
+
/**
|
|
91203
|
+
* Turn `visit` visitors into `visitParents` visitors.
|
|
91204
|
+
*
|
|
91205
|
+
* @param {Visitors} visitors
|
|
91206
|
+
* Visitors for `visit`.
|
|
91207
|
+
* @returns {ParentsVisitors}
|
|
91208
|
+
* Visitors for `visitParents`.
|
|
91209
|
+
*/
|
|
91210
|
+
function wrapVisitors(visitors) {
|
|
91211
|
+
// Pass anything else straight to `visitParents` to get its errors.
|
|
91212
|
+
if (!visitors || typeof visitors !== 'object') return visitors
|
|
91213
|
+
|
|
91214
|
+
return {
|
|
91215
|
+
enter:
|
|
91216
|
+
typeof visitors.enter === 'function'
|
|
91217
|
+
? lib_wrap(visitors.enter)
|
|
91218
|
+
: visitors.enter,
|
|
91219
|
+
exit:
|
|
91220
|
+
typeof visitors.exit === 'function' ? lib_wrap(visitors.exit) : visitors.exit
|
|
91221
|
+
}
|
|
91222
|
+
}
|
|
91223
|
+
|
|
91224
|
+
/**
|
|
91225
|
+
* Turn a `visit` visitor into a `visitParents` one.
|
|
91226
|
+
*
|
|
91227
|
+
* @template {VisitorResult} Result
|
|
91228
|
+
* Result type.
|
|
91229
|
+
* @param {(node: UnistNode, index: number | undefined, parent: UnistParent | undefined) => Result} visitor
|
|
91230
|
+
* Visitor for `visit`.
|
|
91231
|
+
* @returns {(node: UnistNode, parents: Array<UnistParent>, index: number | undefined) => Result}
|
|
91232
|
+
* Visitor for `visitParents`.
|
|
91233
|
+
*/
|
|
91234
|
+
function lib_wrap(visitor) {
|
|
91235
|
+
return overload
|
|
90976
91236
|
|
|
90977
91237
|
/**
|
|
91238
|
+
* Call `visitor` with `index` and `parent` instead of `parents`.
|
|
91239
|
+
*
|
|
90978
91240
|
* @param {UnistNode} node
|
|
91241
|
+
* Visited node.
|
|
90979
91242
|
* @param {Array<UnistParent>} parents
|
|
91243
|
+
* Ancestors of `node`.
|
|
91244
|
+
* @param {number | undefined} index
|
|
91245
|
+
* Index of `node` in its parent.
|
|
91246
|
+
* @returns {Result}
|
|
91247
|
+
* What to do next.
|
|
90980
91248
|
*/
|
|
90981
|
-
function overload(node, parents) {
|
|
90982
|
-
|
|
90983
|
-
const index = parent ? parent.children.indexOf(node) : undefined
|
|
90984
|
-
return visitor(node, index, parent)
|
|
91249
|
+
function overload(node, parents, index) {
|
|
91250
|
+
return visitor(node, index, parents[parents.length - 1])
|
|
90985
91251
|
}
|
|
90986
91252
|
}
|
|
90987
91253
|
|
|
@@ -94304,7 +94570,7 @@ function trough() {
|
|
|
94304
94570
|
|
|
94305
94571
|
// Next or done.
|
|
94306
94572
|
if (fn) {
|
|
94307
|
-
|
|
94573
|
+
trough_lib_wrap(fn, next)(...output)
|
|
94308
94574
|
} else {
|
|
94309
94575
|
callback(null, ...output)
|
|
94310
94576
|
}
|
|
@@ -94356,7 +94622,7 @@ function trough() {
|
|
|
94356
94622
|
* @returns {Run}
|
|
94357
94623
|
* Wrapped middleware.
|
|
94358
94624
|
*/
|
|
94359
|
-
function
|
|
94625
|
+
function trough_lib_wrap(middleware, callback) {
|
|
94360
94626
|
/** @type {boolean} */
|
|
94361
94627
|
let called
|
|
94362
94628
|
|
|
@@ -109911,4 +110177,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
|
|
|
109911
110177
|
// module factories are used so entry inlining is disabled
|
|
109912
110178
|
// startup
|
|
109913
110179
|
// Load entry module and return exports
|
|
109914
|
-
var __webpack_exports__ = __webpack_require__(
|
|
110180
|
+
var __webpack_exports__ = __webpack_require__(9324);
|