@simon_he/vue-tui 0.0.8 → 1.0.0
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/README.md +142 -30
- package/dist/TSelect-BwJJbuTt.js +6089 -0
- package/dist/TTree-DK_DQBYm.js +6480 -0
- package/dist/agent.cjs +39416 -0
- package/dist/agent.d.cts +44 -0
- package/dist/agent.d.ts +44 -0
- package/dist/agent.js +828 -0
- package/dist/ansi-palette-CNXqFciC.js +57 -0
- package/dist/ansi-styles.d.ts +200 -0
- package/dist/block-source-CKUOnkgT.js +1663 -0
- package/dist/cli/headless-renderer.d.ts +29 -0
- package/dist/cli/input.d.ts +49 -0
- package/dist/cli/node-file-writers.d.ts +13 -0
- package/dist/cli/node-module.d.ts +2 -0
- package/dist/cli/parse-kitty.d.ts +2 -0
- package/dist/cli/parse-mouse.d.ts +2 -0
- package/dist/cli/parse-utils.d.ts +14 -0
- package/dist/cli/parse-xterm.d.ts +2 -0
- package/dist/cli/path-provider-types.d.ts +1 -0
- package/dist/cli/path-provider.d.ts +4 -0
- package/dist/cli/path-suggest-core.d.ts +1 -0
- package/dist/cli/path-suggest.d.ts +15 -0
- package/dist/cli/recording.d.ts +4 -0
- package/dist/cli/stdin-buffer.d.ts +33 -0
- package/dist/cli.cjs +11061 -0
- package/dist/cli.d.cts +23 -0
- package/dist/cli.d.ts +23 -0
- package/dist/cli.js +9875 -0
- package/dist/core/ansi/capability.d.ts +20 -0
- package/dist/core/ansi/colors.d.ts +41 -0
- package/dist/core/ansi/sgr.d.ts +7 -0
- package/dist/core/ansi/theme.d.ts +6 -0
- package/dist/core/ansi-palette.d.ts +14 -0
- package/dist/core/buffer/buffer.d.ts +54 -0
- package/dist/core/buffer/width.d.ts +4 -0
- package/dist/core/debug-logger.d.ts +18 -0
- package/dist/core/hyperlink.d.ts +9 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/path-provider-types.d.ts +24 -0
- package/dist/core/path-suggest.d.ts +35 -0
- package/dist/core/render-plane.d.ts +3 -0
- package/dist/core/terminal/create-terminal.d.ts +8 -0
- package/dist/core/terminal/emitter.d.ts +7 -0
- package/dist/core/types.d.ts +107 -0
- package/dist/core.cjs +3153 -0
- package/dist/core.d.cts +14 -0
- package/dist/core.d.ts +14 -0
- package/dist/core.js +424 -0
- package/dist/create-terminal-C2oiWFJU.js +1434 -0
- package/dist/create-terminal-app.d.ts +36 -0
- package/dist/dom-renderer-BqGijQID.js +1173 -0
- package/dist/env-Cl8qmNFN.js +19 -0
- package/dist/events/index.d.ts +6 -0
- package/dist/events/manager/cli-event-manager.d.ts +22 -0
- package/dist/events/manager/event-manager.d.ts +30 -0
- package/dist/events/manager/selection-suppression.d.ts +3 -0
- package/dist/events/manager/types.d.ts +108 -0
- package/dist/events/recording.d.ts +44 -0
- package/dist/experimental.cjs +4412 -1641
- package/dist/experimental.d.cts +42 -0
- package/dist/experimental.d.ts +42 -825
- package/dist/experimental.js +31 -7392
- package/dist/frame-perf-C6Xfg85O.js +24 -0
- package/dist/hyperlink-Bn02UXJb.js +419 -0
- package/dist/index.cjs +14765 -17582
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +35 -1528
- package/dist/index.js +17 -20026
- package/dist/linkify-D_gzn9Xq.js +562 -0
- package/dist/markdown.cjs +9321 -7623
- package/dist/markdown.d.cts +11 -0
- package/dist/markdown.d.ts +11 -112
- package/dist/markdown.js +36 -1427
- package/dist/observability/cli-latency-node.d.ts +3 -0
- package/dist/observability/cli-latency-types.d.ts +41 -0
- package/dist/observability/cli-latency.d.ts +3 -0
- package/dist/observability/frame-perf-store.d.ts +18 -0
- package/dist/observability/frame-perf.d.ts +40 -0
- package/dist/observability/perf-sink.d.ts +56 -0
- package/dist/observability/trace.d.ts +40 -0
- package/dist/observability/tui-profiler.d.ts +33 -0
- package/dist/observability.cjs +221 -0
- package/dist/observability.d.cts +8 -0
- package/dist/observability.d.ts +8 -0
- package/dist/observability.js +4 -0
- package/dist/path-mnSgEpCm.js +81 -0
- package/dist/path-suggest-BNqcuE3-.js +274 -0
- package/dist/path-suggest-Dk9TRLh5.js +3 -0
- package/dist/{path-suggest-DmrmeueH.js → path-suggest-bvR9SY6Q.js} +86 -18
- package/dist/renderer/capabilities.d.ts +13 -0
- package/dist/renderer/cli/index.d.ts +2 -0
- package/dist/renderer/cli/stdout-metrics.d.ts +18 -0
- package/dist/renderer/cli/stdout-renderer.d.ts +48 -0
- package/dist/renderer/dom/dom-renderer.d.ts +157 -0
- package/dist/renderer/dom/index.d.ts +2 -0
- package/dist/renderer/index.d.ts +2 -0
- package/dist/renderer-dom.cjs +1505 -0
- package/dist/renderer-dom.d.cts +4 -0
- package/dist/renderer-dom.d.ts +4 -0
- package/dist/renderer-dom.js +7 -0
- package/dist/runtime/index.d.ts +36 -0
- package/dist/runtime/osc52.d.ts +9 -0
- package/dist/runtime-rfcZCyJq.js +1197 -0
- package/dist/runtime.cjs +1698 -0
- package/dist/runtime.d.cts +9 -0
- package/dist/runtime.d.ts +9 -0
- package/dist/runtime.js +4 -0
- package/dist/selection/terminal-selection.d.ts +123 -0
- package/dist/sgr-BmzxEjAO.js +304 -0
- package/dist/terminal-selection-DBinO6p5.js +330 -0
- package/dist/tlog-theme-qPBt5rge.js +9254 -0
- package/dist/trace-CjzYeIxN.js +182 -0
- package/dist/utils/env.d.ts +3 -0
- package/dist/utils/grapheme.d.ts +5 -0
- package/dist/utils/newlines.d.ts +1 -0
- package/dist/utils/path.d.ts +7 -0
- package/dist/utils/url-safety.d.ts +2 -0
- package/dist/vue/agent/view-models.d.ts +98 -0
- package/dist/vue/components/TAnchor.d.ts +108 -0
- package/dist/vue/components/TBox.d.ts +144 -0
- package/dist/vue/components/TCommandPalette.d.ts +587 -0
- package/dist/vue/components/TDataTable.d.ts +367 -0
- package/dist/vue/components/TDebugOverlay.d.ts +43 -0
- package/dist/vue/components/TDialog.d.ts +255 -0
- package/dist/vue/components/TFeedback.d.ts +635 -0
- package/dist/vue/components/TFlow.d.ts +85 -0
- package/dist/vue/components/TForm.d.ts +1230 -0
- package/dist/vue/components/TInput.d.ts +545 -0
- package/dist/vue/components/TInputBox.d.ts +158 -0
- package/dist/vue/components/TJsonEditor.d.ts +165 -0
- package/dist/vue/components/TLink.d.ts +239 -0
- package/dist/vue/components/TLinkifyText.d.ts +141 -0
- package/dist/vue/components/TList.d.ts +119 -0
- package/dist/vue/components/TLogLinksPanel.d.ts +238 -0
- package/dist/vue/components/TLogMinimap.d.ts +263 -0
- package/dist/vue/components/TLogScrollbar.d.ts +236 -0
- package/dist/vue/components/TLogSearchBar.d.ts +267 -0
- package/dist/vue/components/TLogSearchPager.d.ts +162 -0
- package/dist/vue/components/TLogSearchResults.d.ts +200 -0
- package/dist/vue/components/TLogView.d.ts +536 -0
- package/dist/vue/components/TLogVirtualLinksPanel.d.ts +141 -0
- package/dist/vue/components/TLogVirtualSearchResults.d.ts +146 -0
- package/dist/vue/components/TMarkdownText.d.ts +134 -0
- package/dist/vue/components/TMultilineModal.d.ts +62 -0
- package/dist/vue/components/TNavigation.d.ts +324 -0
- package/dist/vue/components/TOverlay.d.ts +366 -0
- package/dist/vue/components/TPanels.d.ts +244 -0
- package/dist/vue/components/TPathPicker.d.ts +213 -0
- package/dist/vue/components/TRenderLayer.d.ts +16 -0
- package/dist/vue/components/TRenderPlane.d.ts +17 -0
- package/dist/vue/components/TSelect.d.ts +335 -0
- package/dist/vue/components/TTable.d.ts +317 -0
- package/dist/vue/components/TText.d.ts +116 -0
- package/dist/vue/components/TThinkingView.d.ts +233 -0
- package/dist/vue/components/TToolCallView.d.ts +384 -0
- package/dist/vue/components/TTranscriptView.d.ts +221 -0
- package/dist/vue/components/TTransition.d.ts +83 -0
- package/dist/vue/components/TTree.d.ts +200 -0
- package/dist/vue/components/TUserMessageView.d.ts +344 -0
- package/dist/vue/components/TView.d.ts +127 -0
- package/dist/vue/components/TVirtualList.d.ts +182 -0
- package/dist/vue/components/TVirtualMarkdown.d.ts +168 -0
- package/dist/vue/components/TVirtualRows.d.ts +247 -0
- package/dist/vue/components/TerminalProvider.d.ts +218 -0
- package/dist/vue/components/input/host.d.ts +17 -0
- package/dist/vue/components/input/plugins/hostPlugin.d.ts +7 -0
- package/dist/vue/components/input/plugins/hostPlugin.node.d.ts +15 -0
- package/dist/vue/components/input/plugins/mentionUtils.d.ts +17 -0
- package/dist/vue/components/input/plugins/nodeMentionPathProvider.d.ts +2 -0
- package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +8 -0
- package/dist/vue/components/input/plugins/promptMentionState.d.ts +98 -0
- package/dist/vue/components/input/plugins/restrictText.d.ts +27 -0
- package/dist/vue/components/input/plugins/types.d.ts +90 -0
- package/dist/vue/components/input/utils/inlineText.d.ts +57 -0
- package/dist/vue/components/input/utils/inlineTextTokens.d.ts +34 -0
- package/dist/vue/components/input/utils/primitives.d.ts +3 -0
- package/dist/vue/components/input/utils/wordNavigation.d.ts +6 -0
- package/dist/vue/components/link/host.d.ts +15 -0
- package/dist/vue/components/list/list-geometry.d.ts +16 -0
- package/dist/vue/components/list/list-paint.d.ts +1 -0
- package/dist/vue/components/list/scroll-state.d.ts +25 -0
- package/dist/vue/components/list/selection-state.d.ts +6 -0
- package/dist/vue/components/simple-utils.d.ts +5 -0
- package/dist/vue/components/terminal-provider/copy-toast.d.ts +6 -0
- package/dist/vue/components/terminal-provider/portals.d.ts +17 -0
- package/dist/vue/components/terminal-provider/scheduler.d.ts +29 -0
- package/dist/vue/components/terminal-provider/selection-config.d.ts +15 -0
- package/dist/vue/components/terminal-provider/utils.d.ts +5 -0
- package/dist/vue/composables/use-layout.d.ts +2 -0
- package/dist/vue/composables/use-render-node.d.ts +19 -0
- package/dist/vue/composables/use-render-stack.d.ts +3 -0
- package/dist/vue/composables/use-runtime.d.ts +5 -0
- package/dist/vue/composables/use-terminal-node.d.ts +14 -0
- package/dist/vue/composables/use-terminal.d.ts +2 -0
- package/dist/vue/composables/use-visibility.d.ts +12 -0
- package/dist/vue/context.d.ts +153 -0
- package/dist/vue/index.d.ts +69 -0
- package/dist/vue/injection-key.d.ts +2 -0
- package/dist/vue/linkify.d.ts +11 -0
- package/dist/vue/log/append-only-log-store.d.ts +2 -0
- package/dist/vue/log/tlog-keymap.d.ts +28 -0
- package/dist/vue/log/tlog-plugins.d.ts +144 -0
- package/dist/vue/log/tlog-session.d.ts +81 -0
- package/dist/vue/log/tlog-theme.d.ts +68 -0
- package/dist/vue/log/types.d.ts +43 -0
- package/dist/vue/log/use-tlog-link-controller.d.ts +31 -0
- package/dist/vue/log/use-tlog-retained-index.d.ts +26 -0
- package/dist/vue/log/use-tlog-search-controller.d.ts +51 -0
- package/dist/vue/log/use-tlog-search-results-page.d.ts +31 -0
- package/dist/vue/log/use-tlog-virtual-search-results.d.ts +22 -0
- package/dist/vue/markdown/ast.d.ts +3 -0
- package/dist/vue/markdown/block-source.d.ts +22 -0
- package/dist/vue/markdown/document.d.ts +20 -0
- package/dist/vue/markdown/layout.d.ts +21 -0
- package/dist/vue/markdown/parser.d.ts +11 -0
- package/dist/vue/markdown/render.d.ts +10 -0
- package/dist/vue/markdown/theme.d.ts +186 -0
- package/dist/vue/markdown/types.d.ts +59 -0
- package/dist/vue/overlay.d.ts +27 -0
- package/dist/vue/render/context.d.ts +3 -0
- package/dist/vue/render/render-manager.d.ts +94 -0
- package/dist/vue/router/RouterView.d.ts +25 -0
- package/dist/vue/router/composables.d.ts +4 -0
- package/dist/vue/router/context.d.ts +4 -0
- package/dist/vue/router/router.d.ts +7 -0
- package/dist/vue/router/types.d.ts +29 -0
- package/dist/vue/scheduler/frame-mailbox.d.ts +55 -0
- package/dist/vue/scheduler/frame-scheduler.d.ts +51 -0
- package/dist/vue/theme.d.ts +48 -0
- package/dist/vue/transcript/hit-regions.d.ts +2 -0
- package/dist/vue/transcript/layout.d.ts +20 -0
- package/dist/vue/transcript/plain-text.d.ts +2 -0
- package/dist/vue/transcript/types.d.ts +122 -0
- package/dist/vue/utils/frame-task.d.ts +6 -0
- package/dist/vue/utils/rect.d.ts +4 -0
- package/dist/vue/utils/row-scroll.d.ts +25 -0
- package/dist/vue/utils/style-cache.d.ts +3 -0
- package/dist/vue/utils/text.d.ts +27 -0
- package/dist/vue/utils/wheel-scroll.d.ts +18 -0
- package/dist/vue.cjs +23668 -0
- package/dist/vue.d.cts +1 -0
- package/dist/vue.d.ts +1 -0
- package/dist/vue.js +3957 -0
- package/dist/{wheel-scroll-CiNsasLf.js → wheel-scroll-vBRaQ7p-.js} +404 -405
- package/package.json +185 -35
- package/dist/path-suggest-BeV6n7m-.js +0 -3
- package/dist/sgr-Tko2EQ0U.js +0 -484
- package/dist/theme-Bsm65g8k.d.ts +0 -32
- package/dist/types-ClIV2h1o.d.ts +0 -103
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { dirname, isAbsolutePath, joinPath, normalizePath, resolvePath } from "./path-mnSgEpCm.js";
|
|
2
|
+
|
|
3
|
+
//#region src/core/path-suggest.ts
|
|
4
|
+
function lower(s) {
|
|
5
|
+
return s.toLowerCase();
|
|
6
|
+
}
|
|
7
|
+
function normalizePathInputSeparators(input) {
|
|
8
|
+
let out = "";
|
|
9
|
+
for (let i = 0; i < input.length; i++) {
|
|
10
|
+
const ch = input[i];
|
|
11
|
+
if (ch === "\r") continue;
|
|
12
|
+
out += ch === "\\" ? "/" : ch;
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
}
|
|
16
|
+
function stripCarriageReturns(input) {
|
|
17
|
+
let out = "";
|
|
18
|
+
for (let i = 0; i < input.length; i++) {
|
|
19
|
+
const ch = input[i];
|
|
20
|
+
if (ch !== "\r") out += ch;
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
function stripLeadingDotSlash(input) {
|
|
25
|
+
let i = 0;
|
|
26
|
+
while (i + 1 < input.length && input.charCodeAt(i) === 46 && input.charCodeAt(i + 1) === 47) i += 2;
|
|
27
|
+
return i === 0 ? input : input.slice(i);
|
|
28
|
+
}
|
|
29
|
+
function stripLeadingSlashes(input) {
|
|
30
|
+
let i = 0;
|
|
31
|
+
while (i < input.length && input.charCodeAt(i) === 47) i++;
|
|
32
|
+
return i === 0 ? input : input.slice(i);
|
|
33
|
+
}
|
|
34
|
+
function stripTrailingSlashes(input) {
|
|
35
|
+
let end = input.length;
|
|
36
|
+
while (end > 0 && input.charCodeAt(end - 1) === 47) end--;
|
|
37
|
+
return end === input.length ? input : input.slice(0, end);
|
|
38
|
+
}
|
|
39
|
+
function collapseSlashes(input) {
|
|
40
|
+
let out = "";
|
|
41
|
+
let previousWasSlash = false;
|
|
42
|
+
for (let i = 0; i < input.length; i++) {
|
|
43
|
+
const ch = input[i];
|
|
44
|
+
const isSlash = ch === "/";
|
|
45
|
+
if (isSlash) {
|
|
46
|
+
if (!previousWasSlash) out += "/";
|
|
47
|
+
previousWasSlash = true;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
out += ch;
|
|
51
|
+
previousWasSlash = false;
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
function normalizeRelativePathForIgnore(input) {
|
|
56
|
+
return stripTrailingSlashes(collapseSlashes(stripLeadingSlashes(stripLeadingDotSlash(normalizePathInputSeparators(input)))));
|
|
57
|
+
}
|
|
58
|
+
function fuzzyScore(name, query) {
|
|
59
|
+
const n = lower(name);
|
|
60
|
+
const q = lower(query);
|
|
61
|
+
if (!q) return 0;
|
|
62
|
+
if (n === q) return 2e3;
|
|
63
|
+
if (n.startsWith(q)) return 1500 - (n.length - q.length);
|
|
64
|
+
const idx = n.indexOf(q);
|
|
65
|
+
if (idx >= 0) return 1200 - idx;
|
|
66
|
+
let ni = 0;
|
|
67
|
+
let qi = 0;
|
|
68
|
+
let gaps = 0;
|
|
69
|
+
let lastMatch = -1;
|
|
70
|
+
while (ni < n.length && qi < q.length) {
|
|
71
|
+
if (n[ni] === q[qi]) {
|
|
72
|
+
if (lastMatch >= 0) gaps += ni - lastMatch - 1;
|
|
73
|
+
lastMatch = ni;
|
|
74
|
+
qi++;
|
|
75
|
+
}
|
|
76
|
+
ni++;
|
|
77
|
+
}
|
|
78
|
+
if (qi !== q.length) return null;
|
|
79
|
+
const maxGaps = Math.max(4, q.length * 2);
|
|
80
|
+
if (gaps > maxGaps) return null;
|
|
81
|
+
return 800 - gaps;
|
|
82
|
+
}
|
|
83
|
+
function parsePathQuery(rawInput) {
|
|
84
|
+
const input = normalizePathInputSeparators(rawInput);
|
|
85
|
+
const lastSlash = input.lastIndexOf("/");
|
|
86
|
+
if (lastSlash < 0) return {
|
|
87
|
+
dirPrefix: "",
|
|
88
|
+
query: input
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
dirPrefix: input.slice(0, lastSlash + 1),
|
|
92
|
+
query: input.slice(lastSlash + 1)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async function suggestPaths(options) {
|
|
96
|
+
const rawWorkspace = String(options.workspaceAbs ?? "");
|
|
97
|
+
const rawInput = String(options.input ?? "");
|
|
98
|
+
if (!rawWorkspace || rawWorkspace.includes("\0") || rawInput.includes("\0")) {
|
|
99
|
+
const safeWorkspaceAbs = normalizePath(rawWorkspace || ".");
|
|
100
|
+
return {
|
|
101
|
+
baseDirAbs: resolvePath(safeWorkspaceAbs, "."),
|
|
102
|
+
dirPrefix: "",
|
|
103
|
+
query: "",
|
|
104
|
+
suggestions: []
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const workspaceAbs = normalizePath(rawWorkspace);
|
|
108
|
+
const input = normalizePathInputSeparators(rawInput);
|
|
109
|
+
const parsed = parsePathQuery(input);
|
|
110
|
+
let dirPrefix = parsed.dirPrefix;
|
|
111
|
+
let query = parsed.query;
|
|
112
|
+
let baseDirAbs = resolvePath(workspaceAbs, dirPrefix || ".");
|
|
113
|
+
let maxDepth = options.maxDepth ?? 0;
|
|
114
|
+
if (!query) maxDepth = 0;
|
|
115
|
+
const allowHidden = Boolean(options.showHidden);
|
|
116
|
+
const allowDir = options.mode === "directory" || options.mode === "any" || options.mode === "file";
|
|
117
|
+
const allowFile = options.mode === "file" || options.mode === "any";
|
|
118
|
+
const max = Math.max(0, Math.floor(options.max));
|
|
119
|
+
if (max <= 0) return {
|
|
120
|
+
baseDirAbs,
|
|
121
|
+
dirPrefix,
|
|
122
|
+
query,
|
|
123
|
+
suggestions: []
|
|
124
|
+
};
|
|
125
|
+
const maxDepthClamped = Math.max(0, Math.floor(maxDepth || 0));
|
|
126
|
+
const keepCapacity = Math.max(500, Math.min(8e3, max * 40));
|
|
127
|
+
const maxScannedDirs = Math.max(200, Math.min(6e3, 800 + maxDepthClamped * 600));
|
|
128
|
+
const maxScannedEntries = Math.max(2e3, Math.min(8e4, max * 2e3));
|
|
129
|
+
const scored = [];
|
|
130
|
+
let scannedDirs = 0;
|
|
131
|
+
let scannedEntries = 0;
|
|
132
|
+
let scanAborted = false;
|
|
133
|
+
function cmpScored(a, b) {
|
|
134
|
+
if (a.score !== b.score) return b.score - a.score;
|
|
135
|
+
if (a.depth !== b.depth) return a.depth - b.depth;
|
|
136
|
+
return a.name.localeCompare(b.name);
|
|
137
|
+
}
|
|
138
|
+
function pruneScored() {
|
|
139
|
+
if (scored.length <= keepCapacity) return;
|
|
140
|
+
scored.sort(cmpScored);
|
|
141
|
+
scored.length = keepCapacity;
|
|
142
|
+
}
|
|
143
|
+
function scoreItem(name, relPath, q) {
|
|
144
|
+
const byName = fuzzyScore(name, q);
|
|
145
|
+
const byPath = fuzzyScore(relPath, q);
|
|
146
|
+
if (byName == null && byPath == null) return null;
|
|
147
|
+
if (byName != null && byPath != null) return Math.max(byName + 50, byPath);
|
|
148
|
+
return byName ?? byPath;
|
|
149
|
+
}
|
|
150
|
+
async function searchDir(dirAbs, currentDepth, currentRelPath, preloadedEntries) {
|
|
151
|
+
if (scanAborted) return;
|
|
152
|
+
if (currentDepth > maxDepth) return;
|
|
153
|
+
if (dirAbs.includes("\0")) {
|
|
154
|
+
scanAborted = true;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
scannedDirs++;
|
|
158
|
+
if (scannedDirs > maxScannedDirs) {
|
|
159
|
+
scanAborted = true;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
let entries = [];
|
|
163
|
+
try {
|
|
164
|
+
entries = preloadedEntries ?? await options.listDir(dirAbs);
|
|
165
|
+
} catch {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
for (const e of entries) {
|
|
169
|
+
if (scanAborted) return;
|
|
170
|
+
scannedEntries++;
|
|
171
|
+
if (scannedEntries > maxScannedEntries) {
|
|
172
|
+
scanAborted = true;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (!allowHidden && !query && e.name.startsWith(".")) continue;
|
|
176
|
+
const itemRelPath = currentRelPath ? `${currentRelPath}/${e.name}` : e.name;
|
|
177
|
+
const normalizedRelPath = normalizeRelativePathForIgnore(`${dirPrefix}${itemRelPath}`);
|
|
178
|
+
const isDir = e.kind === "directory";
|
|
179
|
+
if (options.shouldIgnore?.({
|
|
180
|
+
normalizedRelPath,
|
|
181
|
+
isDir
|
|
182
|
+
})) continue;
|
|
183
|
+
if (e.kind === "directory") {
|
|
184
|
+
if (!allowDir) continue;
|
|
185
|
+
const score = scoreItem(e.name, itemRelPath, query);
|
|
186
|
+
if (score != null) {
|
|
187
|
+
scored.push({
|
|
188
|
+
score,
|
|
189
|
+
name: e.name,
|
|
190
|
+
kind: "directory",
|
|
191
|
+
depth: currentDepth,
|
|
192
|
+
relPath: itemRelPath
|
|
193
|
+
});
|
|
194
|
+
if (scored.length > keepCapacity * 2) pruneScored();
|
|
195
|
+
}
|
|
196
|
+
await searchDir(`${dirAbs}/${e.name}`, currentDepth + 1, itemRelPath);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (e.kind === "file") {
|
|
200
|
+
if (!allowFile) continue;
|
|
201
|
+
const score = scoreItem(e.name, itemRelPath, query);
|
|
202
|
+
if (score != null) {
|
|
203
|
+
scored.push({
|
|
204
|
+
score,
|
|
205
|
+
name: e.name,
|
|
206
|
+
kind: "file",
|
|
207
|
+
depth: currentDepth,
|
|
208
|
+
relPath: itemRelPath
|
|
209
|
+
});
|
|
210
|
+
if (scored.length > keepCapacity * 2) pruneScored();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
let ok = true;
|
|
216
|
+
let baseEntries = null;
|
|
217
|
+
try {
|
|
218
|
+
baseEntries = await options.listDir(baseDirAbs);
|
|
219
|
+
} catch {
|
|
220
|
+
ok = false;
|
|
221
|
+
}
|
|
222
|
+
if (!ok && dirPrefix) {
|
|
223
|
+
const fallbackQuery = stripTrailingSlashes(input);
|
|
224
|
+
dirPrefix = "";
|
|
225
|
+
query = fallbackQuery;
|
|
226
|
+
baseDirAbs = workspaceAbs;
|
|
227
|
+
maxDepth = options.maxDepth ?? 0;
|
|
228
|
+
if (!query) maxDepth = 0;
|
|
229
|
+
baseEntries = null;
|
|
230
|
+
}
|
|
231
|
+
await searchDir(baseDirAbs, 0, "", baseEntries ?? void 0);
|
|
232
|
+
pruneScored();
|
|
233
|
+
scored.sort(cmpScored);
|
|
234
|
+
const list = max ? scored.slice(0, max) : [];
|
|
235
|
+
const suggestions = list.map((s) => {
|
|
236
|
+
const suffix = s.kind === "directory" ? "/" : "";
|
|
237
|
+
const completion = `${dirPrefix}${s.relPath}${suffix}`;
|
|
238
|
+
const absPath = resolvePath(workspaceAbs, `${dirPrefix}${s.relPath}`);
|
|
239
|
+
return {
|
|
240
|
+
kind: s.kind,
|
|
241
|
+
display: completion,
|
|
242
|
+
completion,
|
|
243
|
+
absPath
|
|
244
|
+
};
|
|
245
|
+
});
|
|
246
|
+
return {
|
|
247
|
+
baseDirAbs,
|
|
248
|
+
dirPrefix,
|
|
249
|
+
query,
|
|
250
|
+
suggestions
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function resolveUserPath(workspaceAbs, input, options) {
|
|
254
|
+
const raw = stripCarriageReturns(input ?? "").trim();
|
|
255
|
+
if (!raw) return resolvePath(normalizePath(workspaceAbs), ".");
|
|
256
|
+
if (raw === "~" || raw.startsWith("~/")) {
|
|
257
|
+
const home = String(options?.homeDir ?? "").trim();
|
|
258
|
+
if (home) {
|
|
259
|
+
const rest = raw === "~" ? "" : raw.slice(2);
|
|
260
|
+
return resolvePath(normalizePath(home), rest);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const normalized = normalizePathInputSeparators(raw);
|
|
264
|
+
if (isAbsolutePath(normalized)) return normalizePath(normalized);
|
|
265
|
+
return resolvePath(normalizePath(workspaceAbs), normalized);
|
|
266
|
+
}
|
|
267
|
+
function suggestParentHint(path) {
|
|
268
|
+
const p = normalizePath(path);
|
|
269
|
+
const d = dirname(p);
|
|
270
|
+
return d ? joinPath(d, "..") : "..";
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
export { parsePathQuery, resolveUserPath, suggestParentHint, suggestPaths };
|
|
@@ -1,19 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/cli/node-module.ts
|
|
2
|
+
function isNodeRuntime() {
|
|
3
|
+
var _proc$versions;
|
|
4
|
+
const proc = globalThis.process;
|
|
5
|
+
return typeof (proc === null || proc === void 0 || (_proc$versions = proc.versions) === null || _proc$versions === void 0 ? void 0 : _proc$versions.node) === "string";
|
|
6
|
+
}
|
|
7
|
+
function importNodeModule(specifier) {
|
|
8
|
+
if (!isNodeRuntime()) return Promise.resolve(null);
|
|
9
|
+
try {
|
|
10
|
+
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
11
|
+
return dynamicImport(specifier).catch(() => null);
|
|
12
|
+
} catch {
|
|
13
|
+
return Promise.resolve(null);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
2
16
|
|
|
17
|
+
//#endregion
|
|
3
18
|
//#region src/utils/path.ts
|
|
4
19
|
function normalizeSeparators(input) {
|
|
5
|
-
|
|
20
|
+
let out = "";
|
|
21
|
+
for (let i = 0; i < input.length; i++) {
|
|
22
|
+
const ch = input[i];
|
|
23
|
+
out += ch === "\\" ? "/" : ch;
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
6
26
|
}
|
|
7
27
|
function isAbsolutePath(path) {
|
|
8
28
|
const p = normalizeSeparators(path);
|
|
9
29
|
if (p.startsWith("/")) return true;
|
|
10
30
|
return /^[A-Z]:\//i.test(p);
|
|
11
31
|
}
|
|
12
|
-
function stripTrailingSlash(path) {
|
|
13
|
-
const p = normalizeSeparators(path);
|
|
14
|
-
if (p === "/") return p;
|
|
15
|
-
return p.replace(/\/+$/g, "");
|
|
16
|
-
}
|
|
17
32
|
function joinPath(base, next) {
|
|
18
33
|
const a = normalizeSeparators(base);
|
|
19
34
|
const b = normalizeSeparators(next);
|
|
@@ -57,10 +72,61 @@ function resolvePath(baseAbs, input) {
|
|
|
57
72
|
}
|
|
58
73
|
|
|
59
74
|
//#endregion
|
|
60
|
-
//#region src/
|
|
75
|
+
//#region src/core/path-suggest.ts
|
|
61
76
|
function lower(s) {
|
|
62
77
|
return s.toLowerCase();
|
|
63
78
|
}
|
|
79
|
+
function normalizePathInputSeparators(input) {
|
|
80
|
+
let out = "";
|
|
81
|
+
for (let i = 0; i < input.length; i++) {
|
|
82
|
+
const ch = input[i];
|
|
83
|
+
if (ch === "\r") continue;
|
|
84
|
+
out += ch === "\\" ? "/" : ch;
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
function stripCarriageReturns(input) {
|
|
89
|
+
let out = "";
|
|
90
|
+
for (let i = 0; i < input.length; i++) {
|
|
91
|
+
const ch = input[i];
|
|
92
|
+
if (ch !== "\r") out += ch;
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
function stripLeadingDotSlash(input) {
|
|
97
|
+
let i = 0;
|
|
98
|
+
while (i + 1 < input.length && input.charCodeAt(i) === 46 && input.charCodeAt(i + 1) === 47) i += 2;
|
|
99
|
+
return i === 0 ? input : input.slice(i);
|
|
100
|
+
}
|
|
101
|
+
function stripLeadingSlashes(input) {
|
|
102
|
+
let i = 0;
|
|
103
|
+
while (i < input.length && input.charCodeAt(i) === 47) i++;
|
|
104
|
+
return i === 0 ? input : input.slice(i);
|
|
105
|
+
}
|
|
106
|
+
function stripTrailingSlashes(input) {
|
|
107
|
+
let end = input.length;
|
|
108
|
+
while (end > 0 && input.charCodeAt(end - 1) === 47) end--;
|
|
109
|
+
return end === input.length ? input : input.slice(0, end);
|
|
110
|
+
}
|
|
111
|
+
function collapseSlashes(input) {
|
|
112
|
+
let out = "";
|
|
113
|
+
let previousWasSlash = false;
|
|
114
|
+
for (let i = 0; i < input.length; i++) {
|
|
115
|
+
const ch = input[i];
|
|
116
|
+
const isSlash = ch === "/";
|
|
117
|
+
if (isSlash) {
|
|
118
|
+
if (!previousWasSlash) out += "/";
|
|
119
|
+
previousWasSlash = true;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
out += ch;
|
|
123
|
+
previousWasSlash = false;
|
|
124
|
+
}
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
function normalizeRelativePathForIgnore(input) {
|
|
128
|
+
return stripTrailingSlashes(collapseSlashes(stripLeadingSlashes(stripLeadingDotSlash(normalizePathInputSeparators(input)))));
|
|
129
|
+
}
|
|
64
130
|
function fuzzyScore(name, query) {
|
|
65
131
|
const n = lower(name);
|
|
66
132
|
const q = lower(query);
|
|
@@ -87,7 +153,7 @@ function fuzzyScore(name, query) {
|
|
|
87
153
|
return 800 - gaps;
|
|
88
154
|
}
|
|
89
155
|
function parsePathQuery(rawInput) {
|
|
90
|
-
const input = rawInput
|
|
156
|
+
const input = normalizePathInputSeparators(rawInput);
|
|
91
157
|
const lastSlash = input.lastIndexOf("/");
|
|
92
158
|
if (lastSlash < 0) return {
|
|
93
159
|
dirPrefix: "",
|
|
@@ -111,7 +177,7 @@ async function suggestPaths$1(options) {
|
|
|
111
177
|
};
|
|
112
178
|
}
|
|
113
179
|
const workspaceAbs = normalizePath(rawWorkspace);
|
|
114
|
-
const input = rawInput
|
|
180
|
+
const input = normalizePathInputSeparators(rawInput);
|
|
115
181
|
const parsed = parsePathQuery(input);
|
|
116
182
|
let dirPrefix = parsed.dirPrefix;
|
|
117
183
|
let query = parsed.query;
|
|
@@ -181,7 +247,7 @@ async function suggestPaths$1(options) {
|
|
|
181
247
|
}
|
|
182
248
|
if (!allowHidden && !query && e.name.startsWith(".")) continue;
|
|
183
249
|
const itemRelPath = currentRelPath ? `${currentRelPath}/${e.name}` : e.name;
|
|
184
|
-
const normalizedRelPath =
|
|
250
|
+
const normalizedRelPath = normalizeRelativePathForIgnore(`${dirPrefix}${itemRelPath}`);
|
|
185
251
|
const isDir = e.kind === "directory";
|
|
186
252
|
if ((_options$shouldIgnore = options.shouldIgnore) === null || _options$shouldIgnore === void 0 ? void 0 : _options$shouldIgnore.call(options, {
|
|
187
253
|
normalizedRelPath,
|
|
@@ -227,7 +293,7 @@ async function suggestPaths$1(options) {
|
|
|
227
293
|
ok = false;
|
|
228
294
|
}
|
|
229
295
|
if (!ok && dirPrefix) {
|
|
230
|
-
const fallbackQuery = input
|
|
296
|
+
const fallbackQuery = stripTrailingSlashes(input);
|
|
231
297
|
dirPrefix = "";
|
|
232
298
|
query = fallbackQuery;
|
|
233
299
|
baseDirAbs = workspaceAbs;
|
|
@@ -258,7 +324,7 @@ async function suggestPaths$1(options) {
|
|
|
258
324
|
};
|
|
259
325
|
}
|
|
260
326
|
function resolveUserPath$1(workspaceAbs, input, options) {
|
|
261
|
-
const raw = (input ?? "").
|
|
327
|
+
const raw = stripCarriageReturns(input ?? "").trim();
|
|
262
328
|
if (!raw) return resolvePath(normalizePath(workspaceAbs), ".");
|
|
263
329
|
if (raw === "~" || raw.startsWith("~/")) {
|
|
264
330
|
const home = String((options === null || options === void 0 ? void 0 : options.homeDir) ?? "").trim();
|
|
@@ -267,7 +333,7 @@ function resolveUserPath$1(workspaceAbs, input, options) {
|
|
|
267
333
|
return resolvePath(normalizePath(home), rest);
|
|
268
334
|
}
|
|
269
335
|
}
|
|
270
|
-
const normalized = raw
|
|
336
|
+
const normalized = normalizePathInputSeparators(raw);
|
|
271
337
|
if (isAbsolutePath(normalized)) return normalizePath(normalized);
|
|
272
338
|
return resolvePath(normalizePath(workspaceAbs), normalized);
|
|
273
339
|
}
|
|
@@ -286,7 +352,7 @@ const gitignoreRulesCache = new Map();
|
|
|
286
352
|
const gitignoreRulesLoading = new Map();
|
|
287
353
|
function isNodeLike() {
|
|
288
354
|
var _proc$versions;
|
|
289
|
-
const proc = process;
|
|
355
|
+
const proc = globalThis.process;
|
|
290
356
|
return typeof (proc === null || proc === void 0 || (_proc$versions = proc.versions) === null || _proc$versions === void 0 ? void 0 : _proc$versions.node) === "string";
|
|
291
357
|
}
|
|
292
358
|
function loadGitignoreRulesAsync(workspaceAbs) {
|
|
@@ -294,7 +360,8 @@ function loadGitignoreRulesAsync(workspaceAbs) {
|
|
|
294
360
|
return (async () => {
|
|
295
361
|
if (!isNodeLike()) return EMPTY_GITIGNORE_RULES;
|
|
296
362
|
try {
|
|
297
|
-
const fs = await
|
|
363
|
+
const fs = await importNodeModule("node:fs/promises");
|
|
364
|
+
if (!fs) return EMPTY_GITIGNORE_RULES;
|
|
298
365
|
const gitignoreAbs = resolvePath(key, ".gitignore");
|
|
299
366
|
const content = await fs.readFile(gitignoreAbs, "utf8");
|
|
300
367
|
return compileGitignoreRules(content);
|
|
@@ -465,9 +532,10 @@ async function suggestPaths(options) {
|
|
|
465
532
|
});
|
|
466
533
|
}
|
|
467
534
|
function resolveUserPath(workspaceAbs, input) {
|
|
468
|
-
|
|
535
|
+
var _process;
|
|
536
|
+
const env = ((_process = globalThis.process) === null || _process === void 0 ? void 0 : _process.env) ?? {};
|
|
469
537
|
return resolveUserPath$1(workspaceAbs, input, { homeDir: String(env.HOME || env.USERPROFILE || "") });
|
|
470
538
|
}
|
|
471
539
|
|
|
472
540
|
//#endregion
|
|
473
|
-
export { isAbsolutePath, normalizePath, parsePathQuery, resolvePath, resolveUserPath,
|
|
541
|
+
export { importNodeModule, isAbsolutePath, normalizePath, parsePathQuery, resolvePath, resolveUserPath, suggestPaths };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type RendererCapabilities = Readonly<{
|
|
2
|
+
syncFlush: boolean;
|
|
3
|
+
scrollOperations: boolean;
|
|
4
|
+
domRows: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
export type TerminalRendererLike = Readonly<{
|
|
7
|
+
capabilities: RendererCapabilities;
|
|
8
|
+
container?: HTMLElement;
|
|
9
|
+
debugStats?: unknown;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const DOM_RENDERER_CAPABILITIES: RendererCapabilities;
|
|
12
|
+
export declare const HEADLESS_RENDERER_CAPABILITIES: RendererCapabilities;
|
|
13
|
+
export declare const STDOUT_RENDERER_CAPABILITIES: RendererCapabilities;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type StdoutRendererWriteMode = "stream" | "sync" | "chunked";
|
|
2
|
+
export interface StdoutRendererMetrics {
|
|
3
|
+
lastFrameAt: number;
|
|
4
|
+
lastFrameBytes: number;
|
|
5
|
+
lastWriteMs: number;
|
|
6
|
+
writeEmaMs: number;
|
|
7
|
+
writeMode: StdoutRendererWriteMode;
|
|
8
|
+
fps: number;
|
|
9
|
+
bytesPerSec: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function getStdoutRendererMetrics(): StdoutRendererMetrics;
|
|
12
|
+
export declare function recordStdoutFrame(info: Readonly<{
|
|
13
|
+
at: number;
|
|
14
|
+
bytes: number;
|
|
15
|
+
writeMs: number;
|
|
16
|
+
writeEmaMs: number;
|
|
17
|
+
writeMode: StdoutRendererWriteMode;
|
|
18
|
+
}>): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Terminal } from "../../core/types.js";
|
|
2
|
+
import type { RendererCapabilities } from "../capabilities.js";
|
|
3
|
+
import type { ThemePalette } from "../../core/ansi-palette.js";
|
|
4
|
+
export type CliOutput = Readonly<{
|
|
5
|
+
write: (chunk: string) => unknown;
|
|
6
|
+
isTTY?: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
export type StdoutRenderer = Readonly<{
|
|
9
|
+
capabilities: RendererCapabilities;
|
|
10
|
+
render: () => void;
|
|
11
|
+
dispose: () => void;
|
|
12
|
+
/** Move terminal cursor to specified cell position for IME input */
|
|
13
|
+
setCursor: (x: number, y: number) => void;
|
|
14
|
+
/** Show or hide the terminal cursor */
|
|
15
|
+
showCursor: (visible: boolean) => void;
|
|
16
|
+
/** Update default background without recreating the renderer. */
|
|
17
|
+
updateTheme?: (next: Readonly<{
|
|
18
|
+
defaultBg?: string | null;
|
|
19
|
+
palette?: ThemePalette | null;
|
|
20
|
+
}>) => void;
|
|
21
|
+
}>;
|
|
22
|
+
export type StdoutColorMode = "auto" | "truecolor" | "ansi256" | "ansi16" | "ansi8";
|
|
23
|
+
export type { ThemePalette } from "../../core/ansi-palette.js";
|
|
24
|
+
export declare function createStdoutRenderer(terminal: Terminal, options?: Readonly<{
|
|
25
|
+
output?: CliOutput;
|
|
26
|
+
clear?: boolean;
|
|
27
|
+
hideCursor?: boolean;
|
|
28
|
+
altScreen?: boolean;
|
|
29
|
+
/** Fallback background color when a cell has no explicit bg. `null` = transparent (terminal default). */
|
|
30
|
+
defaultBg?: string | null;
|
|
31
|
+
/** Optional ANSI-name palette used when emitting ansi256/truecolor sequences. */
|
|
32
|
+
palette?: ThemePalette | null;
|
|
33
|
+
/** Track TTY resize events (process.stdout 'resize') and call terminal.resize(). */
|
|
34
|
+
trackResize?: boolean;
|
|
35
|
+
/** Color mode for ANSI output (auto detects truecolor via env). */
|
|
36
|
+
colorMode?: StdoutColorMode;
|
|
37
|
+
/** Optional function to get IME cursor position, included in render output for atomic write */
|
|
38
|
+
getImeAnchor?: () => {
|
|
39
|
+
cellX: number;
|
|
40
|
+
cellY: number;
|
|
41
|
+
} | null;
|
|
42
|
+
/** Use DEC 2026 synchronized output mode (default: false for compatibility) */
|
|
43
|
+
useSyncOutput?: boolean;
|
|
44
|
+
allowFileUrls?: boolean;
|
|
45
|
+
profileFileWriter?: {
|
|
46
|
+
appendFileSync?: (path: string, data: string) => void;
|
|
47
|
+
};
|
|
48
|
+
}>): StdoutRenderer;
|