@lousy-agents/cli 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.
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@biomejs/biome": "2.5.15",
|
|
21
|
-
"@lousy-agents/mcp": "5.22.
|
|
21
|
+
"@lousy-agents/mcp": "5.22.16",
|
|
22
22
|
"@modelcontextprotocol/server-sequential-thinking": "2026.8.31",
|
|
23
23
|
"@testcontainers/postgresql": "12.2.1",
|
|
24
24
|
"@types/node": "24.19.2",
|
|
@@ -958,9 +958,9 @@
|
|
|
958
958
|
}
|
|
959
959
|
},
|
|
960
960
|
"node_modules/@lousy-agents/mcp": {
|
|
961
|
-
"version": "5.22.
|
|
962
|
-
"resolved": "https://registry.npmjs.org/@lousy-agents/mcp/-/mcp-5.22.
|
|
963
|
-
"integrity": "sha512-
|
|
961
|
+
"version": "5.22.16",
|
|
962
|
+
"resolved": "https://registry.npmjs.org/@lousy-agents/mcp/-/mcp-5.22.16.tgz",
|
|
963
|
+
"integrity": "sha512-5tWj/Hcb1CIbaQ5+MMM1mQ6QQj+L12axG3Z5Curbta6vpOHFReEzrJjcyfeJh9uh1KkAaGcpjjnSGVxY/DCuxQ==",
|
|
964
964
|
"dev": true,
|
|
965
965
|
"license": "BSD-2-Clause-Patent",
|
|
966
966
|
"dependencies": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@biomejs/biome": "2.5.15",
|
|
32
|
-
"@lousy-agents/mcp": "5.22.
|
|
32
|
+
"@lousy-agents/mcp": "5.22.16",
|
|
33
33
|
"@modelcontextprotocol/server-sequential-thinking": "2026.8.31",
|
|
34
34
|
"@testcontainers/postgresql": "12.2.1",
|
|
35
35
|
"@types/node": "24.19.2",
|
package/dist/index.js
CHANGED
|
@@ -3053,7 +3053,7 @@ exports.basename = (path, { windows } = {}) => {
|
|
|
3053
3053
|
|
|
3054
3054
|
|
|
3055
3055
|
},
|
|
3056
|
-
|
|
3056
|
+
5217(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
|
|
3057
3057
|
// NAMESPACE OBJECT: ../../node_modules/micromark/lib/constructs.js
|
|
3058
3058
|
var constructs_namespaceObject = {};
|
|
3059
3059
|
__webpack_require__.r(constructs_namespaceObject);
|
|
@@ -18751,8 +18751,8 @@ function pinnedWriteModeAssertion(fd, mode, assertBeforeMutation, privateCreatio
|
|
|
18751
18751
|
|
|
18752
18752
|
|
|
18753
18753
|
// Node has no portable no-replace rename. Publish the completed stage by link,
|
|
18754
|
-
// then remove its verified temporary name
|
|
18755
|
-
function publishCopyStage(params) {
|
|
18754
|
+
// then remove its verified temporary name after any descriptor handoff.
|
|
18755
|
+
async function publishCopyStage(params) {
|
|
18756
18756
|
const { identity, temporaryPath, targetPath } = params;
|
|
18757
18757
|
const assertCurrent = () => {
|
|
18758
18758
|
directory_guard_assertSyncDirectoryGuard(params.parentGuard);
|
|
@@ -18806,13 +18806,23 @@ function publishCopyStage(params) {
|
|
|
18806
18806
|
}
|
|
18807
18807
|
}
|
|
18808
18808
|
else {
|
|
18809
|
-
const
|
|
18810
|
-
|
|
18811
|
-
|
|
18812
|
-
|
|
18813
|
-
|
|
18814
|
-
!
|
|
18815
|
-
|
|
18809
|
+
const verifyPair = () => {
|
|
18810
|
+
directory_guard_assertSyncDirectoryGuard(params.parentGuard);
|
|
18811
|
+
const parent = external_node_fs_.lstatSync(external_node_path_.dirname(temporaryPath), { bigint: true });
|
|
18812
|
+
const current = external_node_fs_.lstatSync(temporaryPath, { bigint: true });
|
|
18813
|
+
const target = external_node_fs_.lstatSync(targetPath, { bigint: true });
|
|
18814
|
+
if (parent.isSymbolicLink() || !parent.isDirectory() ||
|
|
18815
|
+
!file_identity_sameFileIdentityForCleanup(parent, params.parentGuard.stat) ||
|
|
18816
|
+
current.isSymbolicLink() || !current.isFile() || current.nlink !== 2n ||
|
|
18817
|
+
target.isSymbolicLink() || !target.isFile() || target.nlink !== 2n ||
|
|
18818
|
+
!file_identity_sameFileIdentityForCleanup(current, identity) || !file_identity_sameFileIdentityForCleanup(target, identity)) {
|
|
18819
|
+
throw new errors_FsSafeError("path-mismatch", "published copy temporary name changed before cleanup");
|
|
18820
|
+
}
|
|
18821
|
+
};
|
|
18822
|
+
verifyPair();
|
|
18823
|
+
if (params.beforeTemporaryUnlink) {
|
|
18824
|
+
await params.beforeTemporaryUnlink();
|
|
18825
|
+
verifyPair();
|
|
18816
18826
|
}
|
|
18817
18827
|
// This removes the stage's name, never the published destination or source.
|
|
18818
18828
|
external_node_fs_.unlinkSync(temporaryPath);
|
|
@@ -18885,6 +18895,40 @@ function publishThroughPlaceholder(params, assertCurrent) {
|
|
|
18885
18895
|
}
|
|
18886
18896
|
}
|
|
18887
18897
|
|
|
18898
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/publication-handle.js
|
|
18899
|
+
|
|
18900
|
+
|
|
18901
|
+
|
|
18902
|
+
|
|
18903
|
+
|
|
18904
|
+
|
|
18905
|
+
/** Pin the published name before releasing a descriptor opened through its stage. */
|
|
18906
|
+
async function openPublicationHandle(targetPath, identity) {
|
|
18907
|
+
const flags = read_open_flags_resolveReadOpenFlags();
|
|
18908
|
+
const handle = await promises_.open(targetPath, flags).catch(async (error) => {
|
|
18909
|
+
// Restrictive final modes must not be widened just to inspect publication.
|
|
18910
|
+
if (!hasErrorCode(error, "EACCES") || (process.arch !== "x64" && process.arch !== "arm64"))
|
|
18911
|
+
throw error;
|
|
18912
|
+
const metadataFlag = process.platform === "linux" ? 0x200000 : undefined; // O_PATH
|
|
18913
|
+
if (metadataFlag === undefined)
|
|
18914
|
+
throw error;
|
|
18915
|
+
return promises_.open(targetPath, metadataFlag | external_node_fs_.constants.O_NOFOLLOW);
|
|
18916
|
+
});
|
|
18917
|
+
try {
|
|
18918
|
+
const opened = external_node_fs_.fstatSync(handle.fd, { bigint: true });
|
|
18919
|
+
const named = external_node_fs_.lstatSync(targetPath, { bigint: true });
|
|
18920
|
+
if (!opened.isFile() || !named.isFile() || named.isSymbolicLink() ||
|
|
18921
|
+
!file_identity_sameFileIdentityForCleanup(opened, identity) || !file_identity_sameFileIdentityForCleanup(named, identity)) {
|
|
18922
|
+
throw new errors_FsSafeError("path-mismatch", "publication descriptor handoff identity changed");
|
|
18923
|
+
}
|
|
18924
|
+
return handle;
|
|
18925
|
+
}
|
|
18926
|
+
catch (error) {
|
|
18927
|
+
await handle.close().catch(() => undefined);
|
|
18928
|
+
throw error;
|
|
18929
|
+
}
|
|
18930
|
+
}
|
|
18931
|
+
|
|
18888
18932
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js
|
|
18889
18933
|
|
|
18890
18934
|
|
|
@@ -18906,6 +18950,7 @@ function publishThroughPlaceholder(params, assertCurrent) {
|
|
|
18906
18950
|
|
|
18907
18951
|
|
|
18908
18952
|
|
|
18953
|
+
|
|
18909
18954
|
|
|
18910
18955
|
|
|
18911
18956
|
async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
@@ -18923,6 +18968,7 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
|
18923
18968
|
let handle;
|
|
18924
18969
|
let tempIdentity;
|
|
18925
18970
|
let readHandle;
|
|
18971
|
+
let handoffCloseFailure;
|
|
18926
18972
|
let renamed = false;
|
|
18927
18973
|
const completeCreate = params.overwrite === false && params.input.kind !== "file" && params.input.stageBeforePublish === true;
|
|
18928
18974
|
let receipt;
|
|
@@ -18977,11 +19023,15 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
|
18977
19023
|
}), external_node_path_.basename(tempPath), external_node_fs_.fstatSync(handle.fd, { bigint: true }));
|
|
18978
19024
|
}
|
|
18979
19025
|
let verifiedIdentity = expectedTempStat;
|
|
19026
|
+
// Keep unreadable modes supported where Node has no read-free file open.
|
|
19027
|
+
const canHandoff = process.platform !== "win32" &&
|
|
19028
|
+
((params.mode & 0o400) !== 0 ||
|
|
19029
|
+
(process.platform === "linux" && (process.arch === "x64" || process.arch === "arm64")));
|
|
18980
19030
|
phase = "publish";
|
|
18981
19031
|
await withAsyncDirectoryGuards([parentGuard], async () => {
|
|
18982
19032
|
assertFinalSymlinkRejected(targetPath, params.rejectFinalSymlink);
|
|
18983
19033
|
if (params.overwrite === false) {
|
|
18984
|
-
publishCopyStage({
|
|
19034
|
+
await publishCopyStage({
|
|
18985
19035
|
temporaryPath: tempPath, targetPath, fd: handle.fd,
|
|
18986
19036
|
identity: tempIdentity, parentGuard,
|
|
18987
19037
|
assertBeforeMutation,
|
|
@@ -18995,6 +19045,18 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
|
18995
19045
|
publication = Object.freeze({ status: "published", staged: receipt, basename: params.basename, overwrite: false });
|
|
18996
19046
|
params.onPublished?.(identity);
|
|
18997
19047
|
},
|
|
19048
|
+
beforeTemporaryUnlink: !canHandoff ? undefined : async () => {
|
|
19049
|
+
readHandle = await openPublicationHandle(targetPath, expectedTempStat);
|
|
19050
|
+
// Keep the destination pinned while closing the stage's NFS dentry.
|
|
19051
|
+
const stagedHandle = handle;
|
|
19052
|
+
handle = undefined;
|
|
19053
|
+
try {
|
|
19054
|
+
await stagedHandle.close();
|
|
19055
|
+
}
|
|
19056
|
+
catch (error) {
|
|
19057
|
+
handoffCloseFailure = { error };
|
|
19058
|
+
}
|
|
19059
|
+
},
|
|
18998
19060
|
});
|
|
18999
19061
|
}
|
|
19000
19062
|
else {
|
|
@@ -19022,6 +19084,7 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
|
19022
19084
|
throw new errors_FsSafeError("path-mismatch", "fallback target changed during write");
|
|
19023
19085
|
}
|
|
19024
19086
|
const expectedHash = sha256Hex(params.input.data, params.input.encoding);
|
|
19087
|
+
await readHandle?.close();
|
|
19025
19088
|
readHandle = await promises_.open(targetPath, read_open_flags_resolveReadOpenFlags());
|
|
19026
19089
|
const readHandleStat = external_node_fs_.fstatSync(readHandle.fd, { bigint: true });
|
|
19027
19090
|
const actualHash = sha256Hex(await readFileHandleBounded(readHandle, Infinity));
|
|
@@ -19060,7 +19123,11 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
|
|
|
19060
19123
|
pathname: tempPath, handle, identity: tempIdentity, parentGuard, throwOnCleanupError: true,
|
|
19061
19124
|
}) : "not-needed";
|
|
19062
19125
|
},
|
|
19063
|
-
close: [async () => { await readHandle?.close(); }, async () => {
|
|
19126
|
+
close: [async () => { await readHandle?.close(); }, async () => {
|
|
19127
|
+
await handle?.close();
|
|
19128
|
+
if (handoffCloseFailure)
|
|
19129
|
+
throw handoffCloseFailure.error;
|
|
19130
|
+
}],
|
|
19064
19131
|
});
|
|
19065
19132
|
}
|
|
19066
19133
|
else
|
|
@@ -85125,8 +85192,12 @@ function encodeCharacterReference(code) {
|
|
|
85125
85192
|
|
|
85126
85193
|
;// CONCATENATED MODULE: ../../node_modules/unist-util-visit-parents/lib/color.node.js
|
|
85127
85194
|
/**
|
|
85195
|
+
* Color a string.
|
|
85196
|
+
*
|
|
85128
85197
|
* @param {string} d
|
|
85198
|
+
* Value.
|
|
85129
85199
|
* @returns {string}
|
|
85200
|
+
* Colored value.
|
|
85130
85201
|
*/
|
|
85131
85202
|
function color_node_color(d) {
|
|
85132
85203
|
return '\u001B[33m' + d + '\u001B[39m'
|
|
@@ -85302,46 +85373,98 @@ function color_node_color(d) {
|
|
|
85302
85373
|
* List with one or two values, the first an action, the second an index.
|
|
85303
85374
|
*
|
|
85304
85375
|
* @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult
|
|
85305
|
-
* Any value that can be returned from
|
|
85376
|
+
* Any value that can be returned from an enter visitor.
|
|
85377
|
+
*
|
|
85378
|
+
* Like `VisitorResultExit`,
|
|
85379
|
+
* but `SKIP` can also be returned,
|
|
85380
|
+
* to not walk the children of the node,
|
|
85381
|
+
* and `ActionTuple` can be used to combine an action with an index.
|
|
85382
|
+
*
|
|
85383
|
+
* @typedef {Index | boolean | null | undefined | void} VisitorResultExit
|
|
85384
|
+
* Any value that can be returned from an exit visitor.
|
|
85306
85385
|
*/
|
|
85307
85386
|
|
|
85308
85387
|
/**
|
|
85309
85388
|
* @callback Visitor
|
|
85310
|
-
* Handle a node (matching `test`, if given).
|
|
85311
|
-
*
|
|
85312
|
-
*
|
|
85313
|
-
*
|
|
85314
|
-
*
|
|
85315
|
-
*
|
|
85316
|
-
*
|
|
85317
|
-
*
|
|
85318
|
-
*
|
|
85319
|
-
*
|
|
85320
|
-
* sibling to traverse after `node` is traversed.
|
|
85321
|
-
* Adding or removing next siblings of `node` (or previous siblings, in case
|
|
85322
|
-
* of reverse) is handled as expected without needing to return a new `Index`.
|
|
85323
|
-
*
|
|
85324
|
-
* Removing the children property of an ancestor still results in them being
|
|
85325
|
-
* traversed.
|
|
85389
|
+
* Handle a node (matching `test`, if given) before its children.
|
|
85390
|
+
*
|
|
85391
|
+
* Changes inside `node` are walked next.
|
|
85392
|
+
* Replacing or removing it is easier in `exit`.
|
|
85393
|
+
* When replacing or removing it here,
|
|
85394
|
+
* return `SKIP` (as otherwise its old children are walked),
|
|
85395
|
+
* or `[SKIP, index]` to continue with the node now at `index`.
|
|
85396
|
+
* Changing next siblings (in walk order) is fine;
|
|
85397
|
+
* changing previous siblings needs a new `Index`.
|
|
85398
|
+
* Removing an ancestor or changing its previous siblings is not supported.
|
|
85326
85399
|
* @param {Visited} node
|
|
85327
85400
|
* Found node.
|
|
85328
85401
|
* @param {Array<VisitedParents>} ancestors
|
|
85329
85402
|
* Ancestors of `node`.
|
|
85403
|
+
* @param {number | undefined} index
|
|
85404
|
+
* Index of `node` in its parent (the last of `ancestors`),
|
|
85405
|
+
* or `undefined` for the tree itself.
|
|
85330
85406
|
* @returns {VisitorResult}
|
|
85331
85407
|
* What to do next.
|
|
85332
85408
|
*
|
|
85333
|
-
*
|
|
85334
|
-
*
|
|
85409
|
+
* Like `VisitorExit`,
|
|
85410
|
+
* but `SKIP` can also be returned,
|
|
85411
|
+
* to not walk the children of `node`.
|
|
85412
|
+
* Passing a tuple back (`ActionTuple`) only makes sense as `[SKIP, Index]`.
|
|
85413
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
85414
|
+
* Visited node type.
|
|
85415
|
+
* @template {UnistParent} [VisitedParents=UnistParent]
|
|
85416
|
+
* Ancestor type.
|
|
85417
|
+
*/
|
|
85418
|
+
|
|
85419
|
+
/**
|
|
85420
|
+
* @callback VisitorExit
|
|
85421
|
+
* Handle a node (matching `test`, if given) after its children.
|
|
85422
|
+
*
|
|
85423
|
+
* Changes inside `node` are not walked,
|
|
85424
|
+
* which makes this a good place to change `node` based on its children,
|
|
85425
|
+
* or to replace or remove it.
|
|
85426
|
+
* When removing `node` or changing previous siblings (in walk order),
|
|
85427
|
+
* return a new `Index`.
|
|
85428
|
+
* Removing an ancestor or changing its previous siblings is not supported.
|
|
85429
|
+
* @param {Visited} node
|
|
85430
|
+
* Found node.
|
|
85431
|
+
* @param {Array<VisitedParents>} ancestors
|
|
85432
|
+
* Ancestors of `node`.
|
|
85433
|
+
* @param {number | undefined} index
|
|
85434
|
+
* Index of `node` in its parent (the last of `ancestors`),
|
|
85435
|
+
* or `undefined` for the tree itself.
|
|
85436
|
+
* @returns {VisitorResultExit}
|
|
85437
|
+
* What to do next.
|
|
85335
85438
|
*
|
|
85336
|
-
*
|
|
85337
|
-
*
|
|
85338
|
-
*
|
|
85439
|
+
* `CONTINUE` (`true`, nothing) continues as normal,
|
|
85440
|
+
* `EXIT` (`false`) stops traversing,
|
|
85441
|
+
* and `Index` continues at that sibling.
|
|
85339
85442
|
* @template {UnistNode} [Visited=UnistNode]
|
|
85340
85443
|
* Visited node type.
|
|
85341
85444
|
* @template {UnistParent} [VisitedParents=UnistParent]
|
|
85342
85445
|
* Ancestor type.
|
|
85343
85446
|
*/
|
|
85344
85447
|
|
|
85448
|
+
/**
|
|
85449
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
85450
|
+
* Visited node type.
|
|
85451
|
+
* @template {UnistParent} [VisitedParents=UnistParent]
|
|
85452
|
+
* Ancestor type.
|
|
85453
|
+
* @typedef Visitors
|
|
85454
|
+
* Handle nodes when entering and exiting them.
|
|
85455
|
+
* The `enter` visitor is optional while `exit` is required.
|
|
85456
|
+
*
|
|
85457
|
+
* Pass an `enter` visitor directly to only handle nodes when entering them.
|
|
85458
|
+
*
|
|
85459
|
+
* `enter` is called before children (if any) are walked and `exit` after that.
|
|
85460
|
+
* `exit` is still called when `enter` returns `SKIP`.
|
|
85461
|
+
* Both `enter` and `exit` are only called for nodes that match an optional `test`.
|
|
85462
|
+
* @property {Visitor<Visited, VisitedParents> | null | undefined} [enter]
|
|
85463
|
+
* Handle a node before its children (optional).
|
|
85464
|
+
* @property {VisitorExit<Visited, VisitedParents>} exit
|
|
85465
|
+
* Handle a node after its children.
|
|
85466
|
+
*/
|
|
85467
|
+
|
|
85345
85468
|
/**
|
|
85346
85469
|
* @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor
|
|
85347
85470
|
* Build a typed `Visitor` function from a tree and a test.
|
|
@@ -85353,6 +85476,17 @@ function color_node_color(d) {
|
|
|
85353
85476
|
* Test type.
|
|
85354
85477
|
*/
|
|
85355
85478
|
|
|
85479
|
+
/**
|
|
85480
|
+
* @typedef {Visitors<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitors
|
|
85481
|
+
* Build typed `Visitors` from a tree and a test.
|
|
85482
|
+
*
|
|
85483
|
+
* It will infer which values are passed as `node` and which as `parents`.
|
|
85484
|
+
* @template {UnistNode} [Tree=UnistNode]
|
|
85485
|
+
* Tree type.
|
|
85486
|
+
* @template {Test} [Check=Test]
|
|
85487
|
+
* Test type.
|
|
85488
|
+
*/
|
|
85489
|
+
|
|
85356
85490
|
|
|
85357
85491
|
|
|
85358
85492
|
|
|
@@ -85371,6 +85505,7 @@ const EXIT = false
|
|
|
85371
85505
|
|
|
85372
85506
|
/**
|
|
85373
85507
|
* Do not traverse this node’s children.
|
|
85508
|
+
* Only works when entering a node.
|
|
85374
85509
|
*/
|
|
85375
85510
|
const SKIP = 'skip'
|
|
85376
85511
|
|
|
@@ -85378,10 +85513,13 @@ const SKIP = 'skip'
|
|
|
85378
85513
|
* Visit nodes, with ancestral information.
|
|
85379
85514
|
*
|
|
85380
85515
|
* This algorithm performs *depth-first* *tree traversal* in *preorder*
|
|
85381
|
-
* (**NLR**) or if `reverse` is given,
|
|
85516
|
+
* (**NLR**) or if `reverse` is given,
|
|
85517
|
+
* in *reverse preorder* (**NRL**).
|
|
85518
|
+
* An `exit` visitor is called in *postorder* (**LRN**)
|
|
85519
|
+
* or if `reverse` is given, in *reverse postorder* (**RLN**).
|
|
85382
85520
|
*
|
|
85383
|
-
* You can choose
|
|
85384
|
-
* For complex tests, you should test yourself in
|
|
85521
|
+
* You can choose which nodes are visited by passing a `test`.
|
|
85522
|
+
* For complex tests, you should test yourself in a visitor, as it will be
|
|
85385
85523
|
* faster and will have improved type information.
|
|
85386
85524
|
*
|
|
85387
85525
|
* Walking the tree is an intensive task.
|
|
@@ -85390,29 +85528,72 @@ const SKIP = 'skip'
|
|
|
85390
85528
|
* to check if a node matches, and then perform different operations.
|
|
85391
85529
|
*
|
|
85392
85530
|
* You can change the tree.
|
|
85393
|
-
*
|
|
85531
|
+
* Changes inside a node made when entering it are walked,
|
|
85532
|
+
* changes made when exiting it are not.
|
|
85533
|
+
* See `Visitor` and `VisitorExit` for more info.
|
|
85394
85534
|
*
|
|
85395
85535
|
* @overload
|
|
85396
85536
|
* @param {Tree} tree
|
|
85537
|
+
* Tree to traverse.
|
|
85397
85538
|
* @param {Check} check
|
|
85398
|
-
*
|
|
85539
|
+
* `unist-util-is`-compatible test.
|
|
85540
|
+
* @param {BuildVisitor<Tree, Check>} enter
|
|
85541
|
+
* Handle each node when entering it.
|
|
85399
85542
|
* @param {boolean | null | undefined} [reverse]
|
|
85543
|
+
* Walk children from last to first;
|
|
85544
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
85545
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
85400
85546
|
* @returns {undefined}
|
|
85547
|
+
* Nothing.
|
|
85401
85548
|
*
|
|
85402
85549
|
* @overload
|
|
85403
85550
|
* @param {Tree} tree
|
|
85404
|
-
*
|
|
85551
|
+
* Tree to traverse.
|
|
85552
|
+
* @param {Check} check
|
|
85553
|
+
* `unist-util-is`-compatible test.
|
|
85554
|
+
* @param {BuildVisitors<Tree, Check>} visitors
|
|
85555
|
+
* Handle each node when exiting it, and optionally when entering it.
|
|
85556
|
+
* @param {boolean | null | undefined} [reverse]
|
|
85557
|
+
* Walk children from last to first;
|
|
85558
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
85559
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
85560
|
+
* @returns {undefined}
|
|
85561
|
+
* Nothing.
|
|
85562
|
+
*
|
|
85563
|
+
* @overload
|
|
85564
|
+
* @param {Tree} tree
|
|
85565
|
+
* Tree to traverse.
|
|
85566
|
+
* @param {BuildVisitor<Tree>} enter
|
|
85567
|
+
* Handle each node when entering it.
|
|
85405
85568
|
* @param {boolean | null | undefined} [reverse]
|
|
85569
|
+
* Walk children from last to first;
|
|
85570
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
85571
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
85406
85572
|
* @returns {undefined}
|
|
85573
|
+
* Nothing.
|
|
85574
|
+
*
|
|
85575
|
+
* @overload
|
|
85576
|
+
* @param {Tree} tree
|
|
85577
|
+
* Tree to traverse.
|
|
85578
|
+
* @param {BuildVisitors<Tree>} visitors
|
|
85579
|
+
* Handle each node when exiting it, and optionally when entering it.
|
|
85580
|
+
* @param {boolean | null | undefined} [reverse]
|
|
85581
|
+
* Walk children from last to first;
|
|
85582
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
85583
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
85584
|
+
* @returns {undefined}
|
|
85585
|
+
* Nothing.
|
|
85407
85586
|
*
|
|
85408
85587
|
* @param {UnistNode} tree
|
|
85409
85588
|
* Tree to traverse.
|
|
85410
|
-
* @param {Visitor | Test}
|
|
85411
|
-
* `unist-util-is`-compatible test
|
|
85412
|
-
* @param {Visitor | boolean | null | undefined} [
|
|
85413
|
-
*
|
|
85589
|
+
* @param {Visitor | Visitors | Test} testOrEnterOrVisitors
|
|
85590
|
+
* `unist-util-is`-compatible test, `enter`, or `visitors`.
|
|
85591
|
+
* @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]
|
|
85592
|
+
* `enter`, `visitors`, or `reverse` after a test.
|
|
85414
85593
|
* @param {boolean | null | undefined} [reverse]
|
|
85415
|
-
*
|
|
85594
|
+
* Walk children from last to first;
|
|
85595
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
85596
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
85416
85597
|
* @returns {undefined}
|
|
85417
85598
|
* Nothing.
|
|
85418
85599
|
*
|
|
@@ -85421,28 +85602,89 @@ const SKIP = 'skip'
|
|
|
85421
85602
|
* @template {Test} Check
|
|
85422
85603
|
* `unist-util-is`-compatible test.
|
|
85423
85604
|
*/
|
|
85424
|
-
function visitParents(
|
|
85605
|
+
function visitParents(
|
|
85606
|
+
tree,
|
|
85607
|
+
testOrEnterOrVisitors,
|
|
85608
|
+
enterOrVisitorsOrReverse,
|
|
85609
|
+
reverse
|
|
85610
|
+
) {
|
|
85611
|
+
if (!tree || typeof tree !== 'object') {
|
|
85612
|
+
throw new Error('Unexpected value `' + tree + '` for `tree`, expected node')
|
|
85613
|
+
}
|
|
85614
|
+
|
|
85615
|
+
let preorder = true
|
|
85425
85616
|
/** @type {Test} */
|
|
85426
85617
|
let check
|
|
85618
|
+
/** @type {Visitors | Visitor} */
|
|
85619
|
+
let visitors
|
|
85620
|
+
/** @type {Visitor | null | undefined} */
|
|
85621
|
+
let enter
|
|
85622
|
+
/** @type {VisitorExit | null | undefined} */
|
|
85623
|
+
let exit
|
|
85624
|
+
|
|
85625
|
+
// Third parameter is an enter visitor or a visitors object, so expect a `test` too.
|
|
85626
|
+
if (
|
|
85627
|
+
typeof enterOrVisitorsOrReverse === 'function' ||
|
|
85628
|
+
(enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === 'object')
|
|
85629
|
+
) {
|
|
85630
|
+
check = /** @type {Test} */ (testOrEnterOrVisitors)
|
|
85631
|
+
visitors = enterOrVisitorsOrReverse
|
|
85632
|
+
if (reverse) preorder = false
|
|
85633
|
+
}
|
|
85634
|
+
// Assume no test.
|
|
85635
|
+
else {
|
|
85636
|
+
visitors = /** @type {Visitors | Visitor} */ (testOrEnterOrVisitors)
|
|
85637
|
+
if (enterOrVisitorsOrReverse) preorder = false
|
|
85638
|
+
}
|
|
85427
85639
|
|
|
85428
|
-
if (typeof
|
|
85429
|
-
|
|
85430
|
-
|
|
85431
|
-
|
|
85640
|
+
if (typeof visitors === 'function') {
|
|
85641
|
+
enter = visitors
|
|
85642
|
+
} else if (visitors && typeof visitors === 'object') {
|
|
85643
|
+
if (visitors.enter === null || visitors.enter === undefined) {
|
|
85644
|
+
// Empty.
|
|
85645
|
+
} else if (typeof visitors.enter === 'function') {
|
|
85646
|
+
enter = visitors.enter
|
|
85647
|
+
} else {
|
|
85648
|
+
throw new Error(
|
|
85649
|
+
'Unexpected value `' +
|
|
85650
|
+
visitors.enter +
|
|
85651
|
+
'` for `visitors.enter`, expected optional visitor'
|
|
85652
|
+
)
|
|
85653
|
+
}
|
|
85654
|
+
|
|
85655
|
+
if (typeof visitors.exit === 'function') {
|
|
85656
|
+
exit = visitors.exit
|
|
85657
|
+
} else {
|
|
85658
|
+
throw new Error(
|
|
85659
|
+
'Unexpected value `' +
|
|
85660
|
+
visitors.exit +
|
|
85661
|
+
'` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)'
|
|
85662
|
+
)
|
|
85663
|
+
}
|
|
85432
85664
|
} else {
|
|
85433
|
-
|
|
85434
|
-
|
|
85665
|
+
throw new Error(
|
|
85666
|
+
'Unexpected value `' +
|
|
85667
|
+
visitors +
|
|
85668
|
+
'` for `enter` or `visitors`, expected visitor or object with visitors'
|
|
85669
|
+
)
|
|
85435
85670
|
}
|
|
85436
85671
|
|
|
85437
85672
|
const is = convert(check)
|
|
85438
|
-
const step =
|
|
85673
|
+
const step = preorder ? 1 : -1
|
|
85439
85674
|
|
|
85440
85675
|
factory(tree, undefined, [])()
|
|
85441
85676
|
|
|
85442
85677
|
/**
|
|
85678
|
+
* Create a function to visit a node.
|
|
85679
|
+
*
|
|
85443
85680
|
* @param {UnistNode} node
|
|
85681
|
+
* Node to visit.
|
|
85444
85682
|
* @param {number | undefined} index
|
|
85683
|
+
* Index of `node` in its parent.
|
|
85445
85684
|
* @param {Array<UnistParent>} parents
|
|
85685
|
+
* Ancestors of `node`.
|
|
85686
|
+
* @returns {() => Readonly<ActionTuple>}
|
|
85687
|
+
* Visit `node`.
|
|
85446
85688
|
*/
|
|
85447
85689
|
function factory(node, index, parents) {
|
|
85448
85690
|
const value = /** @type {Record<string, unknown>} */ (
|
|
@@ -85468,18 +85710,13 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
85468
85710
|
return visit
|
|
85469
85711
|
|
|
85470
85712
|
function visit() {
|
|
85713
|
+
const matches =
|
|
85714
|
+
!check || is(node, index, parents[parents.length - 1] || undefined)
|
|
85471
85715
|
/** @type {Readonly<ActionTuple>} */
|
|
85472
85716
|
let result = lib_empty
|
|
85473
|
-
/** @type {Readonly<ActionTuple>} */
|
|
85474
|
-
let subresult
|
|
85475
|
-
/** @type {number} */
|
|
85476
|
-
let offset
|
|
85477
|
-
/** @type {Array<UnistParent>} */
|
|
85478
|
-
let grandparents
|
|
85479
85717
|
|
|
85480
|
-
if (
|
|
85481
|
-
|
|
85482
|
-
result = lib_toResult(visitor(node, parents))
|
|
85718
|
+
if (enter && matches) {
|
|
85719
|
+
result = lib_toResult(enter(node, parents, index))
|
|
85483
85720
|
|
|
85484
85721
|
if (result[0] === EXIT) {
|
|
85485
85722
|
return result
|
|
@@ -85490,13 +85727,13 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
85490
85727
|
const nodeAsParent = /** @type {UnistParent} */ (node)
|
|
85491
85728
|
|
|
85492
85729
|
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
85493
|
-
offset = (
|
|
85494
|
-
grandparents = parents
|
|
85730
|
+
let offset = (preorder ? -1 : nodeAsParent.children.length) + step
|
|
85731
|
+
const grandparents = [...parents, nodeAsParent]
|
|
85495
85732
|
|
|
85496
85733
|
while (offset > -1 && offset < nodeAsParent.children.length) {
|
|
85497
85734
|
const child = nodeAsParent.children[offset]
|
|
85498
85735
|
|
|
85499
|
-
subresult = factory(child, offset, grandparents)()
|
|
85736
|
+
const subresult = factory(child, offset, grandparents)()
|
|
85500
85737
|
|
|
85501
85738
|
if (subresult[0] === EXIT) {
|
|
85502
85739
|
return subresult
|
|
@@ -85508,6 +85745,23 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
85508
85745
|
}
|
|
85509
85746
|
}
|
|
85510
85747
|
|
|
85748
|
+
if (exit && matches) {
|
|
85749
|
+
const exitResult = lib_toResult(exit(node, parents, index))
|
|
85750
|
+
|
|
85751
|
+
if (exitResult[0] === SKIP) {
|
|
85752
|
+
throw new Error(
|
|
85753
|
+
'Unexpected value `' +
|
|
85754
|
+
exitResult[0] +
|
|
85755
|
+
'` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing'
|
|
85756
|
+
)
|
|
85757
|
+
}
|
|
85758
|
+
|
|
85759
|
+
// Prefer a result from `exit` over `enter`.
|
|
85760
|
+
if (exitResult[0] === EXIT || typeof exitResult[1] === 'number') {
|
|
85761
|
+
return exitResult
|
|
85762
|
+
}
|
|
85763
|
+
}
|
|
85764
|
+
|
|
85511
85765
|
return result
|
|
85512
85766
|
}
|
|
85513
85767
|
}
|
|
@@ -85536,7 +85790,13 @@ function lib_toResult(value) {
|
|
|
85536
85790
|
;// CONCATENATED MODULE: ../../node_modules/unist-util-visit/lib/index.js
|
|
85537
85791
|
/**
|
|
85538
85792
|
* @import {Node as UnistNode, Parent as UnistParent} from 'unist'
|
|
85539
|
-
* @import {
|
|
85793
|
+
* @import {
|
|
85794
|
+
* InclusiveDescendant,
|
|
85795
|
+
* Matches,
|
|
85796
|
+
* Visitors as ParentsVisitors,
|
|
85797
|
+
* VisitorResult,
|
|
85798
|
+
* VisitorResultExit
|
|
85799
|
+
* } from 'unist-util-visit-parents'
|
|
85540
85800
|
*/
|
|
85541
85801
|
|
|
85542
85802
|
/**
|
|
@@ -85548,67 +85808,6 @@ function lib_toResult(value) {
|
|
|
85548
85808
|
* which doesn’t work when publishing on npm.
|
|
85549
85809
|
*/
|
|
85550
85810
|
|
|
85551
|
-
// To do: use types from `unist-util-visit-parents` when it’s released.
|
|
85552
|
-
|
|
85553
|
-
/**
|
|
85554
|
-
* @typedef {(
|
|
85555
|
-
* Fn extends (value: any) => value is infer Thing
|
|
85556
|
-
* ? Thing
|
|
85557
|
-
* : Fallback
|
|
85558
|
-
* )} Predicate
|
|
85559
|
-
* Get the value of a type guard `Fn`.
|
|
85560
|
-
* @template Fn
|
|
85561
|
-
* Value; typically function that is a type guard (such as `(x): x is Y`).
|
|
85562
|
-
* @template Fallback
|
|
85563
|
-
* Value to yield if `Fn` is not a type guard.
|
|
85564
|
-
*/
|
|
85565
|
-
|
|
85566
|
-
/**
|
|
85567
|
-
* @typedef {(
|
|
85568
|
-
* Check extends null | undefined // No test.
|
|
85569
|
-
* ? Value
|
|
85570
|
-
* : Value extends {type: Check} // String (type) test.
|
|
85571
|
-
* ? Value
|
|
85572
|
-
* : Value extends Check // Partial test.
|
|
85573
|
-
* ? Value
|
|
85574
|
-
* : Check extends Function // Function test.
|
|
85575
|
-
* ? Predicate<Check, Value> extends Value
|
|
85576
|
-
* ? Predicate<Check, Value>
|
|
85577
|
-
* : never
|
|
85578
|
-
* : never // Some other test?
|
|
85579
|
-
* )} MatchesOne
|
|
85580
|
-
* Check whether a node matches a primitive check in the type system.
|
|
85581
|
-
* @template Value
|
|
85582
|
-
* Value; typically unist `Node`.
|
|
85583
|
-
* @template Check
|
|
85584
|
-
* Value; typically `unist-util-is`-compatible test, but not arrays.
|
|
85585
|
-
*/
|
|
85586
|
-
|
|
85587
|
-
/**
|
|
85588
|
-
* @typedef {(
|
|
85589
|
-
* Check extends ReadonlyArray<any>
|
|
85590
|
-
* ? MatchesOne<Value, Check[number]>
|
|
85591
|
-
* : MatchesOne<Value, Check>
|
|
85592
|
-
* )} Matches
|
|
85593
|
-
* Check whether a node matches a check in the type system.
|
|
85594
|
-
* @template Value
|
|
85595
|
-
* Value; typically unist `Node`.
|
|
85596
|
-
* @template Check
|
|
85597
|
-
* Value; typically `unist-util-is`-compatible test.
|
|
85598
|
-
*/
|
|
85599
|
-
|
|
85600
|
-
/**
|
|
85601
|
-
* @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint
|
|
85602
|
-
* Number; capped reasonably.
|
|
85603
|
-
*/
|
|
85604
|
-
|
|
85605
|
-
/**
|
|
85606
|
-
* @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
|
|
85607
|
-
* Increment a number in the type system.
|
|
85608
|
-
* @template {Uint} [I=0]
|
|
85609
|
-
* Index.
|
|
85610
|
-
*/
|
|
85611
|
-
|
|
85612
85811
|
/**
|
|
85613
85812
|
* @typedef {(
|
|
85614
85813
|
* Node extends UnistParent
|
|
@@ -85634,89 +85833,64 @@ function lib_toResult(value) {
|
|
|
85634
85833
|
*/
|
|
85635
85834
|
|
|
85636
85835
|
/**
|
|
85637
|
-
* @
|
|
85638
|
-
*
|
|
85639
|
-
* ? never
|
|
85640
|
-
* :
|
|
85641
|
-
* | InternalParent<Node, Child>
|
|
85642
|
-
* | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>
|
|
85643
|
-
* )} InternalAncestor
|
|
85644
|
-
* Collect nodes in `Tree` that can be ancestors of `Child`.
|
|
85645
|
-
* @template {UnistNode} Node
|
|
85646
|
-
* All node types in a tree.
|
|
85647
|
-
* @template {UnistNode} Child
|
|
85648
|
-
* Node to search for.
|
|
85649
|
-
* @template {Uint} [Max=10]
|
|
85650
|
-
* Max; searches up to this depth.
|
|
85651
|
-
* @template {Uint} [Depth=0]
|
|
85652
|
-
* Current depth.
|
|
85653
|
-
*/
|
|
85654
|
-
|
|
85655
|
-
/**
|
|
85656
|
-
* @typedef {(
|
|
85657
|
-
* Tree extends UnistParent
|
|
85658
|
-
* ? Depth extends Max
|
|
85659
|
-
* ? Tree
|
|
85660
|
-
* : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>
|
|
85661
|
-
* : Tree
|
|
85662
|
-
* )} InclusiveDescendant
|
|
85663
|
-
* Collect all (inclusive) descendants of `Tree`.
|
|
85836
|
+
* @callback Visitor
|
|
85837
|
+
* Handle a node (matching `test`, if given) before its children.
|
|
85664
85838
|
*
|
|
85665
|
-
*
|
|
85666
|
-
*
|
|
85667
|
-
*
|
|
85668
|
-
*
|
|
85669
|
-
*
|
|
85670
|
-
*
|
|
85671
|
-
*
|
|
85672
|
-
*
|
|
85673
|
-
*
|
|
85674
|
-
*
|
|
85675
|
-
* @
|
|
85676
|
-
*
|
|
85677
|
-
* @template {
|
|
85678
|
-
*
|
|
85839
|
+
* Like `Visitor` in `unist-util-visit-parents`,
|
|
85840
|
+
* but with `index` and `parent` instead of `parents`.
|
|
85841
|
+
* @param {Visited} node
|
|
85842
|
+
* Found node.
|
|
85843
|
+
* @param {Visited extends UnistNode ? number | undefined : never} index
|
|
85844
|
+
* Index of `node` in `parent`,
|
|
85845
|
+
* or `undefined` for the tree itself.
|
|
85846
|
+
* @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
|
|
85847
|
+
* Parent of `node`,
|
|
85848
|
+
* or `undefined` for the tree itself.
|
|
85849
|
+
* @returns {VisitorResult}
|
|
85850
|
+
* What to do next.
|
|
85851
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
85852
|
+
* Visited node type.
|
|
85853
|
+
* @template {UnistParent} [Ancestor=UnistParent]
|
|
85854
|
+
* Ancestor type.
|
|
85679
85855
|
*/
|
|
85680
85856
|
|
|
85681
85857
|
/**
|
|
85682
|
-
* @callback
|
|
85683
|
-
* Handle a node (matching `test`, if given).
|
|
85684
|
-
*
|
|
85685
|
-
* Visitors are free to transform `node`.
|
|
85686
|
-
* They can also transform `parent`.
|
|
85858
|
+
* @callback VisitorExit
|
|
85859
|
+
* Handle a node (matching `test`, if given) after its children.
|
|
85687
85860
|
*
|
|
85688
|
-
*
|
|
85689
|
-
*
|
|
85690
|
-
*
|
|
85691
|
-
* When adding or removing previous siblings of `node` (or next siblings, in
|
|
85692
|
-
* case of reverse), the `Visitor` should return a new `Index` to specify the
|
|
85693
|
-
* sibling to traverse after `node` is traversed.
|
|
85694
|
-
* Adding or removing next siblings of `node` (or previous siblings, in case
|
|
85695
|
-
* of reverse) is handled as expected without needing to return a new `Index`.
|
|
85696
|
-
*
|
|
85697
|
-
* Removing the children property of `parent` still results in them being
|
|
85698
|
-
* traversed.
|
|
85861
|
+
* Like `VisitorExit` in `unist-util-visit-parents`,
|
|
85862
|
+
* but with `index` and `parent` instead of `parents`.
|
|
85699
85863
|
* @param {Visited} node
|
|
85700
85864
|
* Found node.
|
|
85701
85865
|
* @param {Visited extends UnistNode ? number | undefined : never} index
|
|
85702
|
-
* Index of `node` in `parent
|
|
85866
|
+
* Index of `node` in `parent`,
|
|
85867
|
+
* or `undefined` for the tree itself.
|
|
85703
85868
|
* @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
|
|
85704
|
-
* Parent of `node
|
|
85705
|
-
*
|
|
85869
|
+
* Parent of `node`,
|
|
85870
|
+
* or `undefined` for the tree itself.
|
|
85871
|
+
* @returns {VisitorResultExit}
|
|
85706
85872
|
* What to do next.
|
|
85707
|
-
*
|
|
85708
|
-
* An `Index` is treated as a tuple of `[CONTINUE, Index]`.
|
|
85709
|
-
* An `Action` is treated as a tuple of `[Action]`.
|
|
85710
|
-
*
|
|
85711
|
-
* Passing a tuple back only makes sense if the `Action` is `SKIP`.
|
|
85712
|
-
* When the `Action` is `EXIT`, that action can be returned.
|
|
85713
|
-
* When the `Action` is `CONTINUE`, `Index` can be returned.
|
|
85714
85873
|
* @template {UnistNode} [Visited=UnistNode]
|
|
85715
85874
|
* Visited node type.
|
|
85716
85875
|
* @template {UnistParent} [Ancestor=UnistParent]
|
|
85717
85876
|
* Ancestor type.
|
|
85718
85877
|
*/
|
|
85719
85878
|
|
|
85879
|
+
/**
|
|
85880
|
+
* @template {UnistNode} [Visited=UnistNode]
|
|
85881
|
+
* Visited node type.
|
|
85882
|
+
* @template {UnistParent} [Ancestor=UnistParent]
|
|
85883
|
+
* Ancestor type.
|
|
85884
|
+
* @typedef Visitors
|
|
85885
|
+
* Handle nodes when entering and exiting them.
|
|
85886
|
+
*
|
|
85887
|
+
* Like `Visitors` in `unist-util-visit-parents`.
|
|
85888
|
+
* @property {Visitor<Visited, Ancestor> | null | undefined} [enter]
|
|
85889
|
+
* Handle a node before its children (optional).
|
|
85890
|
+
* @property {VisitorExit<Visited, Ancestor>} exit
|
|
85891
|
+
* Handle a node after its children.
|
|
85892
|
+
*/
|
|
85893
|
+
|
|
85720
85894
|
/**
|
|
85721
85895
|
* @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch
|
|
85722
85896
|
* Build a typed `Visitor` function from a node and all possible parents.
|
|
@@ -85760,6 +85934,25 @@ function lib_toResult(value) {
|
|
|
85760
85934
|
* Test type.
|
|
85761
85935
|
*/
|
|
85762
85936
|
|
|
85937
|
+
/**
|
|
85938
|
+
* @typedef {(
|
|
85939
|
+
* Visitors<
|
|
85940
|
+
* Matches<InclusiveDescendant<Tree>, Check>,
|
|
85941
|
+
* Parent<
|
|
85942
|
+
* Extract<InclusiveDescendant<Tree>, UnistParent>,
|
|
85943
|
+
* Matches<InclusiveDescendant<Tree>, Check>
|
|
85944
|
+
* >
|
|
85945
|
+
* >
|
|
85946
|
+
* )} BuildVisitors
|
|
85947
|
+
* Build typed `Visitors` from a tree and a test.
|
|
85948
|
+
*
|
|
85949
|
+
* It will infer which values are passed as `node` and which as `parent`.
|
|
85950
|
+
* @template {UnistNode} [Tree=UnistNode]
|
|
85951
|
+
* Node type.
|
|
85952
|
+
* @template {Test} [Check=Test]
|
|
85953
|
+
* Test type.
|
|
85954
|
+
*/
|
|
85955
|
+
|
|
85763
85956
|
|
|
85764
85957
|
|
|
85765
85958
|
|
|
@@ -85768,10 +85961,13 @@ function lib_toResult(value) {
|
|
|
85768
85961
|
* Visit nodes.
|
|
85769
85962
|
*
|
|
85770
85963
|
* This algorithm performs *depth-first* *tree traversal* in *preorder*
|
|
85771
|
-
* (**NLR**) or if `reverse` is given,
|
|
85964
|
+
* (**NLR**) or if `reverse` is given,
|
|
85965
|
+
* in *reverse preorder* (**NRL**).
|
|
85966
|
+
* An `exit` visitor is called in *postorder* (**LRN**)
|
|
85967
|
+
* or if `reverse` is given, in *reverse postorder* (**RLN**).
|
|
85772
85968
|
*
|
|
85773
|
-
* You can choose
|
|
85774
|
-
* For complex tests, you should test yourself in
|
|
85969
|
+
* You can choose which nodes are visited by passing a `test`.
|
|
85970
|
+
* For complex tests, you should test yourself in a visitor, as it will be
|
|
85775
85971
|
* faster and will have improved type information.
|
|
85776
85972
|
*
|
|
85777
85973
|
* Walking the tree is an intensive task.
|
|
@@ -85780,29 +85976,48 @@ function lib_toResult(value) {
|
|
|
85780
85976
|
* to check if a node matches, and then perform different operations.
|
|
85781
85977
|
*
|
|
85782
85978
|
* You can change the tree.
|
|
85783
|
-
*
|
|
85979
|
+
* Changes inside a node made when entering it are walked,
|
|
85980
|
+
* changes made when exiting it are not.
|
|
85981
|
+
* See `Visitor` and `VisitorExit` for more info.
|
|
85784
85982
|
*
|
|
85785
85983
|
* @overload
|
|
85786
85984
|
* @param {Tree} tree
|
|
85985
|
+
* Tree to traverse.
|
|
85787
85986
|
* @param {Check} check
|
|
85788
|
-
*
|
|
85987
|
+
* `unist-util-is`-compatible test.
|
|
85988
|
+
* @param {BuildVisitor<Tree, Check> | BuildVisitors<Tree, Check>} visitors
|
|
85989
|
+
* Handle each node when entering it,
|
|
85990
|
+
* or `{enter, exit}` to also handle it when exiting it.
|
|
85789
85991
|
* @param {boolean | null | undefined} [reverse]
|
|
85992
|
+
* Walk children from last to first;
|
|
85993
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
85994
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
85790
85995
|
* @returns {undefined}
|
|
85996
|
+
* Nothing.
|
|
85791
85997
|
*
|
|
85792
85998
|
* @overload
|
|
85793
85999
|
* @param {Tree} tree
|
|
85794
|
-
*
|
|
86000
|
+
* Tree to traverse.
|
|
86001
|
+
* @param {BuildVisitor<Tree> | BuildVisitors<Tree>} visitors
|
|
86002
|
+
* Handle each node when entering it,
|
|
86003
|
+
* or `{enter, exit}` to also handle it when exiting it.
|
|
85795
86004
|
* @param {boolean | null | undefined} [reverse]
|
|
86005
|
+
* Walk children from last to first;
|
|
86006
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
86007
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
85796
86008
|
* @returns {undefined}
|
|
86009
|
+
* Nothing.
|
|
85797
86010
|
*
|
|
85798
86011
|
* @param {UnistNode} tree
|
|
85799
86012
|
* Tree to traverse.
|
|
85800
|
-
* @param {Visitor | Test}
|
|
85801
|
-
* `unist-util-is`-compatible test
|
|
85802
|
-
* @param {Visitor | boolean | null | undefined} [
|
|
85803
|
-
*
|
|
85804
|
-
* @param {boolean | null | undefined} [maybeReverse
|
|
85805
|
-
*
|
|
86013
|
+
* @param {Visitor | Visitors | Test} testOrEnterOrVisitors
|
|
86014
|
+
* `unist-util-is`-compatible test, `enter`, or `visitors`.
|
|
86015
|
+
* @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]
|
|
86016
|
+
* `enter`, `visitors`, or `reverse` after a test.
|
|
86017
|
+
* @param {boolean | null | undefined} [maybeReverse]
|
|
86018
|
+
* Walk children from last to first;
|
|
86019
|
+
* for `enter`, reverse preorder (NRL) instead of preorder (NLR);
|
|
86020
|
+
* for `exit`, reverse postorder (RLN) instead of postorder (LRN).
|
|
85806
86021
|
* @returns {undefined}
|
|
85807
86022
|
* Nothing.
|
|
85808
86023
|
*
|
|
@@ -85811,39 +86026,90 @@ function lib_toResult(value) {
|
|
|
85811
86026
|
* @template {Test} Check
|
|
85812
86027
|
* `unist-util-is`-compatible test.
|
|
85813
86028
|
*/
|
|
85814
|
-
function lib_visit(
|
|
86029
|
+
function lib_visit(
|
|
86030
|
+
tree,
|
|
86031
|
+
testOrEnterOrVisitors,
|
|
86032
|
+
enterOrVisitorsOrReverse,
|
|
86033
|
+
maybeReverse
|
|
86034
|
+
) {
|
|
86035
|
+
/** @type {Test} */
|
|
86036
|
+
let check
|
|
86037
|
+
/** @type {Visitor | Visitors} */
|
|
86038
|
+
let visitors
|
|
85815
86039
|
/** @type {boolean | null | undefined} */
|
|
85816
86040
|
let reverse
|
|
85817
|
-
/** @type {Test} */
|
|
85818
|
-
let test
|
|
85819
|
-
/** @type {Visitor} */
|
|
85820
|
-
let visitor
|
|
85821
86041
|
|
|
86042
|
+
// Third parameter is an enter visitor or a visitors object, so expect a `test` too.
|
|
85822
86043
|
if (
|
|
85823
|
-
typeof
|
|
85824
|
-
typeof
|
|
86044
|
+
typeof enterOrVisitorsOrReverse === 'function' ||
|
|
86045
|
+
(enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === 'object')
|
|
85825
86046
|
) {
|
|
85826
|
-
|
|
85827
|
-
|
|
85828
|
-
reverse = visitorOrReverse
|
|
85829
|
-
} else {
|
|
85830
|
-
// @ts-expect-error: assume the overload with test was given.
|
|
85831
|
-
test = testOrVisitor
|
|
85832
|
-
// @ts-expect-error: assume the overload with test was given.
|
|
85833
|
-
visitor = visitorOrReverse
|
|
86047
|
+
check = /** @type {Test} */ (testOrEnterOrVisitors)
|
|
86048
|
+
visitors = enterOrVisitorsOrReverse
|
|
85834
86049
|
reverse = maybeReverse
|
|
85835
86050
|
}
|
|
86051
|
+
// Assume no test.
|
|
86052
|
+
else {
|
|
86053
|
+
visitors = /** @type {Visitor | Visitors} */ (testOrEnterOrVisitors)
|
|
86054
|
+
reverse = enterOrVisitorsOrReverse
|
|
86055
|
+
}
|
|
85836
86056
|
|
|
85837
|
-
|
|
86057
|
+
if (typeof visitors === 'function') {
|
|
86058
|
+
visitParents(tree, check, lib_wrap(visitors), reverse)
|
|
86059
|
+
} else {
|
|
86060
|
+
visitParents(tree, check, wrapVisitors(visitors), reverse)
|
|
86061
|
+
}
|
|
86062
|
+
}
|
|
86063
|
+
|
|
86064
|
+
/**
|
|
86065
|
+
* Turn `visit` visitors into `visitParents` visitors.
|
|
86066
|
+
*
|
|
86067
|
+
* @param {Visitors} visitors
|
|
86068
|
+
* Visitors for `visit`.
|
|
86069
|
+
* @returns {ParentsVisitors}
|
|
86070
|
+
* Visitors for `visitParents`.
|
|
86071
|
+
*/
|
|
86072
|
+
function wrapVisitors(visitors) {
|
|
86073
|
+
// Pass anything else straight to `visitParents` to get its errors.
|
|
86074
|
+
if (!visitors || typeof visitors !== 'object') return visitors
|
|
86075
|
+
|
|
86076
|
+
return {
|
|
86077
|
+
enter:
|
|
86078
|
+
typeof visitors.enter === 'function'
|
|
86079
|
+
? lib_wrap(visitors.enter)
|
|
86080
|
+
: visitors.enter,
|
|
86081
|
+
exit:
|
|
86082
|
+
typeof visitors.exit === 'function' ? lib_wrap(visitors.exit) : visitors.exit
|
|
86083
|
+
}
|
|
86084
|
+
}
|
|
86085
|
+
|
|
86086
|
+
/**
|
|
86087
|
+
* Turn a `visit` visitor into a `visitParents` one.
|
|
86088
|
+
*
|
|
86089
|
+
* @template {VisitorResult} Result
|
|
86090
|
+
* Result type.
|
|
86091
|
+
* @param {(node: UnistNode, index: number | undefined, parent: UnistParent | undefined) => Result} visitor
|
|
86092
|
+
* Visitor for `visit`.
|
|
86093
|
+
* @returns {(node: UnistNode, parents: Array<UnistParent>, index: number | undefined) => Result}
|
|
86094
|
+
* Visitor for `visitParents`.
|
|
86095
|
+
*/
|
|
86096
|
+
function lib_wrap(visitor) {
|
|
86097
|
+
return overload
|
|
85838
86098
|
|
|
85839
86099
|
/**
|
|
86100
|
+
* Call `visitor` with `index` and `parent` instead of `parents`.
|
|
86101
|
+
*
|
|
85840
86102
|
* @param {UnistNode} node
|
|
86103
|
+
* Visited node.
|
|
85841
86104
|
* @param {Array<UnistParent>} parents
|
|
86105
|
+
* Ancestors of `node`.
|
|
86106
|
+
* @param {number | undefined} index
|
|
86107
|
+
* Index of `node` in its parent.
|
|
86108
|
+
* @returns {Result}
|
|
86109
|
+
* What to do next.
|
|
85842
86110
|
*/
|
|
85843
|
-
function overload(node, parents) {
|
|
85844
|
-
|
|
85845
|
-
const index = parent ? parent.children.indexOf(node) : undefined
|
|
85846
|
-
return visitor(node, index, parent)
|
|
86111
|
+
function overload(node, parents, index) {
|
|
86112
|
+
return visitor(node, index, parents[parents.length - 1])
|
|
85847
86113
|
}
|
|
85848
86114
|
}
|
|
85849
86115
|
|
|
@@ -89166,7 +89432,7 @@ function trough() {
|
|
|
89166
89432
|
|
|
89167
89433
|
// Next or done.
|
|
89168
89434
|
if (fn) {
|
|
89169
|
-
|
|
89435
|
+
trough_lib_wrap(fn, next)(...output)
|
|
89170
89436
|
} else {
|
|
89171
89437
|
callback(null, ...output)
|
|
89172
89438
|
}
|
|
@@ -89218,7 +89484,7 @@ function trough() {
|
|
|
89218
89484
|
* @returns {Run}
|
|
89219
89485
|
* Wrapped middleware.
|
|
89220
89486
|
*/
|
|
89221
|
-
function
|
|
89487
|
+
function trough_lib_wrap(middleware, callback) {
|
|
89222
89488
|
/** @type {boolean} */
|
|
89223
89489
|
let called
|
|
89224
89490
|
|
|
@@ -112983,4 +113249,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
|
|
|
112983
113249
|
// module factories are used so entry inlining is disabled
|
|
112984
113250
|
// startup
|
|
112985
113251
|
// Load entry module and return exports
|
|
112986
|
-
var __webpack_exports__ = __webpack_require__(
|
|
113252
|
+
var __webpack_exports__ = __webpack_require__(5217);
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@biomejs/biome": "2.5.15",
|
|
25
25
|
"@eslint/eslintrc": "3.3.7",
|
|
26
|
-
"@lousy-agents/mcp": "5.22.
|
|
26
|
+
"@lousy-agents/mcp": "5.22.16",
|
|
27
27
|
"@modelcontextprotocol/server-sequential-thinking": "2026.8.31",
|
|
28
28
|
"@testing-library/jest-dom": "7.0.1",
|
|
29
29
|
"@testing-library/react": "16.3.3",
|