The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | diff --git a/lib/state.js b/lib/state.js |
| 2 | index 0d9c9df..1279783 100644 |
| 3 | --- a/lib/state.js |
| 4 | +++ b/lib/state.js |
| 5 | @@ -176,7 +176,6 @@ |
| 6 | */ |
| 7 | |
| 8 | import structuredClone from '@ungap/structured-clone' |
| 9 | -import {visit} from 'unist-util-visit' |
| 10 | import {position} from 'unist-util-position' |
| 11 | import {handlers as defaultHandlers} from './handlers/index.js' |
| 12 | |
| 13 | @@ -223,7 +222,16 @@ export function createState(tree, options) { |
| 14 | wrap |
| 15 | } |
| 16 | |
| 17 | - visit(tree, function (node) { |
| 18 | + // A plain walk in the same order: `visit` costs more than the rest of this setup. |
| 19 | + collectDefinitions(tree) |
| 20 | + |
| 21 | + return state |
| 22 | + |
| 23 | + /** |
| 24 | + * @param {MdastNodes} node |
| 25 | + * @returns {undefined} |
| 26 | + */ |
| 27 | + function collectDefinitions(node) { |
| 28 | if (node.type === 'definition' || node.type === 'footnoteDefinition') { |
| 29 | const map = node.type === 'definition' ? definitionById : footnoteById |
| 30 | const id = String(node.identifier).toUpperCase() |
| 31 | @@ -235,9 +243,11 @@ export function createState(tree, options) { |
| 32 | map.set(id, node) |
| 33 | } |
| 34 | } |
| 35 | - }) |
| 36 | |
| 37 | - return state |
| 38 | + if ('children' in node) { |
| 39 | + for (const child of node.children) collectDefinitions(child) |
| 40 | + } |
| 41 | + } |
| 42 | |
| 43 | /** |
| 44 | * Transform an mdast node into a hast node. |