@simon_he/vue-tui 0.0.3 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -74
- package/dist/index.cjs +14464 -3607
- package/dist/index.d.ts +689 -77
- package/dist/index.js +13874 -4979
- package/dist/path-suggest-CZQYJIIg.js +473 -0
- package/dist/path-suggest-DIMby3r0.js +3 -0
- package/package.json +22 -17
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/path.ts
|
|
4
|
+
function normalizeSeparators(input) {
|
|
5
|
+
return input.replace(/\\/g, "/");
|
|
6
|
+
}
|
|
7
|
+
function isAbsolutePath(path) {
|
|
8
|
+
const p = normalizeSeparators(path);
|
|
9
|
+
if (p.startsWith("/")) return true;
|
|
10
|
+
return /^[A-Z]:\//i.test(p);
|
|
11
|
+
}
|
|
12
|
+
function stripTrailingSlash(path) {
|
|
13
|
+
const p = normalizeSeparators(path);
|
|
14
|
+
if (p === "/") return p;
|
|
15
|
+
return p.replace(/\/+$/g, "");
|
|
16
|
+
}
|
|
17
|
+
function joinPath(base, next) {
|
|
18
|
+
const a = normalizeSeparators(base);
|
|
19
|
+
const b = normalizeSeparators(next);
|
|
20
|
+
if (!a) return b;
|
|
21
|
+
if (!b) return a;
|
|
22
|
+
if (a.endsWith("/")) return `${a}${b.startsWith("/") ? b.slice(1) : b}`;
|
|
23
|
+
return `${a}/${b.startsWith("/") ? b.slice(1) : b}`;
|
|
24
|
+
}
|
|
25
|
+
function normalizePath(path) {
|
|
26
|
+
var _raw$match;
|
|
27
|
+
const raw = normalizeSeparators(path);
|
|
28
|
+
if (!raw) return "";
|
|
29
|
+
const drive = ((_raw$match = raw.match(/^([A-Z]:)(\/|$)/i)) === null || _raw$match === void 0 ? void 0 : _raw$match[1]) ?? null;
|
|
30
|
+
const rest = drive ? raw.slice(drive.length) : raw;
|
|
31
|
+
const absolute = rest.startsWith("/");
|
|
32
|
+
const parts = rest.split("/").filter(Boolean);
|
|
33
|
+
const stack = [];
|
|
34
|
+
for (const part of parts) {
|
|
35
|
+
if (part === ".") continue;
|
|
36
|
+
if (part === "..") {
|
|
37
|
+
if (stack.length > 0 && stack[stack.length - 1] !== "..") {
|
|
38
|
+
stack.pop();
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!absolute) stack.push("..");
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
stack.push(part);
|
|
45
|
+
}
|
|
46
|
+
const prefix = drive ? `${drive}${absolute ? "/" : ""}` : absolute ? "/" : "";
|
|
47
|
+
const joined = stack.join("/");
|
|
48
|
+
const out = `${prefix}${joined}`;
|
|
49
|
+
return out || (absolute ? drive ? `${drive}/` : "/" : "");
|
|
50
|
+
}
|
|
51
|
+
function resolvePath(baseAbs, input) {
|
|
52
|
+
const b = normalizePath(baseAbs);
|
|
53
|
+
const i = normalizePath(input);
|
|
54
|
+
if (!b) return i;
|
|
55
|
+
if (isAbsolutePath(i)) return i;
|
|
56
|
+
return normalizePath(joinPath(b, i));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/cli/path-suggest-core.ts
|
|
61
|
+
function lower(s) {
|
|
62
|
+
return s.toLowerCase();
|
|
63
|
+
}
|
|
64
|
+
function fuzzyScore(name, query) {
|
|
65
|
+
const n = lower(name);
|
|
66
|
+
const q = lower(query);
|
|
67
|
+
if (!q) return 0;
|
|
68
|
+
if (n === q) return 2e3;
|
|
69
|
+
if (n.startsWith(q)) return 1500 - (n.length - q.length);
|
|
70
|
+
const idx = n.indexOf(q);
|
|
71
|
+
if (idx >= 0) return 1200 - idx;
|
|
72
|
+
let ni = 0;
|
|
73
|
+
let qi = 0;
|
|
74
|
+
let gaps = 0;
|
|
75
|
+
let lastMatch = -1;
|
|
76
|
+
while (ni < n.length && qi < q.length) {
|
|
77
|
+
if (n[ni] === q[qi]) {
|
|
78
|
+
if (lastMatch >= 0) gaps += ni - lastMatch - 1;
|
|
79
|
+
lastMatch = ni;
|
|
80
|
+
qi++;
|
|
81
|
+
}
|
|
82
|
+
ni++;
|
|
83
|
+
}
|
|
84
|
+
if (qi !== q.length) return null;
|
|
85
|
+
const maxGaps = Math.max(4, q.length * 2);
|
|
86
|
+
if (gaps > maxGaps) return null;
|
|
87
|
+
return 800 - gaps;
|
|
88
|
+
}
|
|
89
|
+
function parsePathQuery(rawInput) {
|
|
90
|
+
const input = rawInput.replace(/\\/g, "/");
|
|
91
|
+
const lastSlash = input.lastIndexOf("/");
|
|
92
|
+
if (lastSlash < 0) return {
|
|
93
|
+
dirPrefix: "",
|
|
94
|
+
query: input
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
dirPrefix: input.slice(0, lastSlash + 1),
|
|
98
|
+
query: input.slice(lastSlash + 1)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async function suggestPaths$1(options) {
|
|
102
|
+
const rawWorkspace = String(options.workspaceAbs ?? "");
|
|
103
|
+
const rawInput = String(options.input ?? "");
|
|
104
|
+
if (!rawWorkspace || rawWorkspace.includes("\0") || rawInput.includes("\0")) {
|
|
105
|
+
const safeWorkspaceAbs = normalizePath(rawWorkspace || ".");
|
|
106
|
+
return {
|
|
107
|
+
baseDirAbs: resolvePath(safeWorkspaceAbs, "."),
|
|
108
|
+
dirPrefix: "",
|
|
109
|
+
query: "",
|
|
110
|
+
suggestions: []
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const workspaceAbs = normalizePath(rawWorkspace);
|
|
114
|
+
const input = rawInput.replace(/\r/g, "").replace(/\\/g, "/");
|
|
115
|
+
const parsed = parsePathQuery(input);
|
|
116
|
+
let dirPrefix = parsed.dirPrefix;
|
|
117
|
+
let query = parsed.query;
|
|
118
|
+
let baseDirAbs = resolvePath(workspaceAbs, dirPrefix || ".");
|
|
119
|
+
let maxDepth = options.maxDepth ?? 0;
|
|
120
|
+
if (!query) maxDepth = 0;
|
|
121
|
+
const allowHidden = Boolean(options.showHidden);
|
|
122
|
+
const allowDir = options.mode === "directory" || options.mode === "any" || options.mode === "file";
|
|
123
|
+
const allowFile = options.mode === "file" || options.mode === "any";
|
|
124
|
+
const max = Math.max(0, Math.floor(options.max));
|
|
125
|
+
if (max <= 0) return {
|
|
126
|
+
baseDirAbs,
|
|
127
|
+
dirPrefix,
|
|
128
|
+
query,
|
|
129
|
+
suggestions: []
|
|
130
|
+
};
|
|
131
|
+
const maxDepthClamped = Math.max(0, Math.floor(maxDepth || 0));
|
|
132
|
+
const keepCapacity = Math.max(500, Math.min(8e3, max * 40));
|
|
133
|
+
const maxScannedDirs = Math.max(200, Math.min(6e3, 800 + maxDepthClamped * 600));
|
|
134
|
+
const maxScannedEntries = Math.max(2e3, Math.min(8e4, max * 2e3));
|
|
135
|
+
const scored = [];
|
|
136
|
+
let scannedDirs = 0;
|
|
137
|
+
let scannedEntries = 0;
|
|
138
|
+
let scanAborted = false;
|
|
139
|
+
function cmpScored(a, b) {
|
|
140
|
+
if (a.score !== b.score) return b.score - a.score;
|
|
141
|
+
if (a.depth !== b.depth) return a.depth - b.depth;
|
|
142
|
+
return a.name.localeCompare(b.name);
|
|
143
|
+
}
|
|
144
|
+
function pruneScored() {
|
|
145
|
+
if (scored.length <= keepCapacity) return;
|
|
146
|
+
scored.sort(cmpScored);
|
|
147
|
+
scored.length = keepCapacity;
|
|
148
|
+
}
|
|
149
|
+
function scoreItem(name, relPath, q) {
|
|
150
|
+
const byName = fuzzyScore(name, q);
|
|
151
|
+
const byPath = fuzzyScore(relPath, q);
|
|
152
|
+
if (byName == null && byPath == null) return null;
|
|
153
|
+
if (byName != null && byPath != null) return Math.max(byName + 50, byPath);
|
|
154
|
+
return byName ?? byPath;
|
|
155
|
+
}
|
|
156
|
+
async function searchDir(dirAbs, currentDepth, currentRelPath, preloadedEntries) {
|
|
157
|
+
if (scanAborted) return;
|
|
158
|
+
if (currentDepth > maxDepth) return;
|
|
159
|
+
if (dirAbs.includes("\0")) {
|
|
160
|
+
scanAborted = true;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
scannedDirs++;
|
|
164
|
+
if (scannedDirs > maxScannedDirs) {
|
|
165
|
+
scanAborted = true;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
let entries = [];
|
|
169
|
+
try {
|
|
170
|
+
entries = preloadedEntries ?? await options.listDir(dirAbs);
|
|
171
|
+
} catch {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
for (const e of entries) {
|
|
175
|
+
var _options$shouldIgnore;
|
|
176
|
+
if (scanAborted) return;
|
|
177
|
+
scannedEntries++;
|
|
178
|
+
if (scannedEntries > maxScannedEntries) {
|
|
179
|
+
scanAborted = true;
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (!allowHidden && !query && e.name.startsWith(".")) continue;
|
|
183
|
+
const itemRelPath = currentRelPath ? `${currentRelPath}/${e.name}` : e.name;
|
|
184
|
+
const normalizedRelPath = String(`${dirPrefix}${itemRelPath}`).replace(/\r/g, "").replace(/\\/g, "/").replace(/^(?:\.\/)+/g, "").replace(/^\/+/g, "").replace(/\/+/g, "/").replace(/\/+$/g, "");
|
|
185
|
+
const isDir = e.kind === "directory";
|
|
186
|
+
if ((_options$shouldIgnore = options.shouldIgnore) === null || _options$shouldIgnore === void 0 ? void 0 : _options$shouldIgnore.call(options, {
|
|
187
|
+
normalizedRelPath,
|
|
188
|
+
isDir
|
|
189
|
+
})) continue;
|
|
190
|
+
if (e.kind === "directory") {
|
|
191
|
+
if (!allowDir) continue;
|
|
192
|
+
const score = scoreItem(e.name, itemRelPath, query);
|
|
193
|
+
if (score != null) {
|
|
194
|
+
scored.push({
|
|
195
|
+
score,
|
|
196
|
+
name: e.name,
|
|
197
|
+
kind: "directory",
|
|
198
|
+
depth: currentDepth,
|
|
199
|
+
relPath: itemRelPath
|
|
200
|
+
});
|
|
201
|
+
if (scored.length > keepCapacity * 2) pruneScored();
|
|
202
|
+
}
|
|
203
|
+
await searchDir(`${dirAbs}/${e.name}`, currentDepth + 1, itemRelPath);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (e.kind === "file") {
|
|
207
|
+
if (!allowFile) continue;
|
|
208
|
+
const score = scoreItem(e.name, itemRelPath, query);
|
|
209
|
+
if (score != null) {
|
|
210
|
+
scored.push({
|
|
211
|
+
score,
|
|
212
|
+
name: e.name,
|
|
213
|
+
kind: "file",
|
|
214
|
+
depth: currentDepth,
|
|
215
|
+
relPath: itemRelPath
|
|
216
|
+
});
|
|
217
|
+
if (scored.length > keepCapacity * 2) pruneScored();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
let ok = true;
|
|
223
|
+
let baseEntries = null;
|
|
224
|
+
try {
|
|
225
|
+
baseEntries = await options.listDir(baseDirAbs);
|
|
226
|
+
} catch {
|
|
227
|
+
ok = false;
|
|
228
|
+
}
|
|
229
|
+
if (!ok && dirPrefix) {
|
|
230
|
+
const fallbackQuery = input.replace(/\/+$/g, "");
|
|
231
|
+
dirPrefix = "";
|
|
232
|
+
query = fallbackQuery;
|
|
233
|
+
baseDirAbs = workspaceAbs;
|
|
234
|
+
maxDepth = options.maxDepth ?? 0;
|
|
235
|
+
if (!query) maxDepth = 0;
|
|
236
|
+
baseEntries = null;
|
|
237
|
+
}
|
|
238
|
+
await searchDir(baseDirAbs, 0, "", baseEntries ?? void 0);
|
|
239
|
+
pruneScored();
|
|
240
|
+
scored.sort(cmpScored);
|
|
241
|
+
const list = max ? scored.slice(0, max) : [];
|
|
242
|
+
const suggestions = list.map((s) => {
|
|
243
|
+
const suffix = s.kind === "directory" ? "/" : "";
|
|
244
|
+
const completion = `${dirPrefix}${s.relPath}${suffix}`;
|
|
245
|
+
const absPath = resolvePath(workspaceAbs, `${dirPrefix}${s.relPath}`);
|
|
246
|
+
return {
|
|
247
|
+
kind: s.kind,
|
|
248
|
+
display: completion,
|
|
249
|
+
completion,
|
|
250
|
+
absPath
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
return {
|
|
254
|
+
baseDirAbs,
|
|
255
|
+
dirPrefix,
|
|
256
|
+
query,
|
|
257
|
+
suggestions
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function resolveUserPath$1(workspaceAbs, input, options) {
|
|
261
|
+
const raw = (input ?? "").replace(/\r/g, "").trim();
|
|
262
|
+
if (!raw) return resolvePath(normalizePath(workspaceAbs), ".");
|
|
263
|
+
if (raw === "~" || raw.startsWith("~/")) {
|
|
264
|
+
const home = String((options === null || options === void 0 ? void 0 : options.homeDir) ?? "").trim();
|
|
265
|
+
if (home) {
|
|
266
|
+
const rest = raw === "~" ? "" : raw.slice(2);
|
|
267
|
+
return resolvePath(normalizePath(home), rest);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const normalized = raw.replace(/\\/g, "/");
|
|
271
|
+
if (isAbsolutePath(normalized)) return normalizePath(normalized);
|
|
272
|
+
return resolvePath(normalizePath(workspaceAbs), normalized);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/cli/path-suggest.ts
|
|
277
|
+
const DEFAULT_IGNORED_SEGMENTS = new Set([
|
|
278
|
+
".git",
|
|
279
|
+
"node_modules",
|
|
280
|
+
"dist",
|
|
281
|
+
"cache",
|
|
282
|
+
".cache"
|
|
283
|
+
]);
|
|
284
|
+
const EMPTY_GITIGNORE_RULES = [];
|
|
285
|
+
const gitignoreRulesCache = new Map();
|
|
286
|
+
const gitignoreRulesLoading = new Map();
|
|
287
|
+
function isNodeLike() {
|
|
288
|
+
var _proc$versions;
|
|
289
|
+
const proc = process;
|
|
290
|
+
return typeof (proc === null || proc === void 0 || (_proc$versions = proc.versions) === null || _proc$versions === void 0 ? void 0 : _proc$versions.node) === "string";
|
|
291
|
+
}
|
|
292
|
+
function loadGitignoreRulesAsync(workspaceAbs) {
|
|
293
|
+
const key = normalizePath(workspaceAbs);
|
|
294
|
+
return (async () => {
|
|
295
|
+
if (!isNodeLike()) return EMPTY_GITIGNORE_RULES;
|
|
296
|
+
try {
|
|
297
|
+
const fs = await import("node:fs/promises");
|
|
298
|
+
const gitignoreAbs = resolvePath(key, ".gitignore");
|
|
299
|
+
const content = await fs.readFile(gitignoreAbs, "utf8");
|
|
300
|
+
return compileGitignoreRules(content);
|
|
301
|
+
} catch {
|
|
302
|
+
return EMPTY_GITIGNORE_RULES;
|
|
303
|
+
}
|
|
304
|
+
})();
|
|
305
|
+
}
|
|
306
|
+
function startGitignoreLoad(workspaceAbs) {
|
|
307
|
+
const key = normalizePath(workspaceAbs);
|
|
308
|
+
const existing = gitignoreRulesLoading.get(key);
|
|
309
|
+
if (existing) return existing;
|
|
310
|
+
const promise = loadGitignoreRulesAsync(key);
|
|
311
|
+
gitignoreRulesLoading.set(key, promise);
|
|
312
|
+
promise.then((rules) => {
|
|
313
|
+
gitignoreRulesCache.set(key, rules);
|
|
314
|
+
gitignoreRulesLoading.delete(key);
|
|
315
|
+
}).catch(() => {
|
|
316
|
+
gitignoreRulesCache.set(key, EMPTY_GITIGNORE_RULES);
|
|
317
|
+
gitignoreRulesLoading.delete(key);
|
|
318
|
+
});
|
|
319
|
+
return promise;
|
|
320
|
+
}
|
|
321
|
+
async function loadGitignoreRules(workspaceAbs) {
|
|
322
|
+
const key = normalizePath(workspaceAbs);
|
|
323
|
+
const cached = gitignoreRulesCache.get(key);
|
|
324
|
+
if (cached) return cached;
|
|
325
|
+
const pending = gitignoreRulesLoading.get(key) ?? startGitignoreLoad(key);
|
|
326
|
+
return pending;
|
|
327
|
+
}
|
|
328
|
+
function peekGitignoreRules(workspaceAbs) {
|
|
329
|
+
const key = normalizePath(workspaceAbs);
|
|
330
|
+
const cached = gitignoreRulesCache.get(key);
|
|
331
|
+
if (cached) return cached;
|
|
332
|
+
startGitignoreLoad(key);
|
|
333
|
+
return EMPTY_GITIGNORE_RULES;
|
|
334
|
+
}
|
|
335
|
+
function escapeRegexLiteral(ch) {
|
|
336
|
+
return /[\\^$.*+?()[\]{}|]/.test(ch) ? `\\${ch}` : ch;
|
|
337
|
+
}
|
|
338
|
+
function globToRegexSource(pattern, opts) {
|
|
339
|
+
const allowSlash = opts.allowSlash;
|
|
340
|
+
let out = "";
|
|
341
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
342
|
+
const ch = pattern[i];
|
|
343
|
+
if (ch === "*") {
|
|
344
|
+
if (pattern[i + 1] === "*") {
|
|
345
|
+
while (pattern[i + 1] === "*") i++;
|
|
346
|
+
out += ".*";
|
|
347
|
+
} else out += allowSlash ? "[^/]*" : ".*";
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (ch === "?") {
|
|
351
|
+
out += allowSlash ? "[^/]" : ".";
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
out += escapeRegexLiteral(ch);
|
|
355
|
+
}
|
|
356
|
+
return out;
|
|
357
|
+
}
|
|
358
|
+
function compileSegmentRule(rawPattern, opts) {
|
|
359
|
+
const pattern = rawPattern.trim();
|
|
360
|
+
if (!pattern) return null;
|
|
361
|
+
const source = globToRegexSource(pattern, { allowSlash: false });
|
|
362
|
+
return {
|
|
363
|
+
kind: "segment",
|
|
364
|
+
negative: opts.negative,
|
|
365
|
+
directoryOnly: opts.directoryOnly,
|
|
366
|
+
regex: new RegExp(`^${source}$`)
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
function compilePathRule(rawPattern, opts) {
|
|
370
|
+
let pattern = rawPattern.trim().replace(/\\/g, "/");
|
|
371
|
+
if (!pattern) return null;
|
|
372
|
+
if (pattern.startsWith("/")) pattern = pattern.slice(1);
|
|
373
|
+
if (!pattern) return null;
|
|
374
|
+
let prefix = "^";
|
|
375
|
+
if (pattern.startsWith("**/")) {
|
|
376
|
+
prefix += "(?:.*\\/)?";
|
|
377
|
+
pattern = pattern.slice(3);
|
|
378
|
+
}
|
|
379
|
+
const body = globToRegexSource(pattern, { allowSlash: true });
|
|
380
|
+
const suffix = opts.directoryOnly ? "(?:\\/.*)?$" : "$";
|
|
381
|
+
return {
|
|
382
|
+
kind: "path",
|
|
383
|
+
negative: opts.negative,
|
|
384
|
+
directoryOnly: opts.directoryOnly,
|
|
385
|
+
regex: new RegExp(`${prefix}${body}${suffix}`)
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function compileGitignoreRules(content) {
|
|
389
|
+
const lines = content.split(/\r?\n/);
|
|
390
|
+
const rules = [];
|
|
391
|
+
for (const rawLine of lines) {
|
|
392
|
+
const trimmed = rawLine.trim();
|
|
393
|
+
if (!trimmed) continue;
|
|
394
|
+
if (trimmed.startsWith("#")) continue;
|
|
395
|
+
let negative = false;
|
|
396
|
+
let line = trimmed;
|
|
397
|
+
if (line.startsWith("!")) {
|
|
398
|
+
negative = true;
|
|
399
|
+
line = line.slice(1).trim();
|
|
400
|
+
if (!line) continue;
|
|
401
|
+
}
|
|
402
|
+
let directoryOnly = false;
|
|
403
|
+
if (line.endsWith("/")) {
|
|
404
|
+
directoryOnly = true;
|
|
405
|
+
line = line.replace(/\/+$/g, "");
|
|
406
|
+
if (!line) continue;
|
|
407
|
+
}
|
|
408
|
+
line = line.replace(/\\/g, "/");
|
|
409
|
+
if (line.startsWith("./")) line = line.slice(2);
|
|
410
|
+
if (!line) continue;
|
|
411
|
+
const hasSlash = line.includes("/");
|
|
412
|
+
const rule = hasSlash ? compilePathRule(line, {
|
|
413
|
+
negative,
|
|
414
|
+
directoryOnly
|
|
415
|
+
}) : compileSegmentRule(line, {
|
|
416
|
+
negative,
|
|
417
|
+
directoryOnly
|
|
418
|
+
});
|
|
419
|
+
if (rule) rules.push(rule);
|
|
420
|
+
}
|
|
421
|
+
return rules;
|
|
422
|
+
}
|
|
423
|
+
function shouldIgnoreByDefault(normalizedRelPath) {
|
|
424
|
+
if (!normalizedRelPath) return false;
|
|
425
|
+
const segments = normalizedRelPath.split("/").filter(Boolean);
|
|
426
|
+
for (const seg of segments) if (DEFAULT_IGNORED_SEGMENTS.has(seg)) return true;
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
function isGitignored(normalizedRelPath, opts) {
|
|
430
|
+
const rel = normalizedRelPath;
|
|
431
|
+
if (!rel) return false;
|
|
432
|
+
const rules = opts.rules;
|
|
433
|
+
if (!rules.length) return false;
|
|
434
|
+
const segments = rel.split("/").filter(Boolean);
|
|
435
|
+
if (!segments.length) return false;
|
|
436
|
+
const prefixes = [];
|
|
437
|
+
let acc = "";
|
|
438
|
+
for (const seg of segments) {
|
|
439
|
+
acc = acc ? `${acc}/${seg}` : seg;
|
|
440
|
+
prefixes.push(acc);
|
|
441
|
+
}
|
|
442
|
+
let ignored = false;
|
|
443
|
+
for (const rule of rules) {
|
|
444
|
+
if (rule.kind === "segment") {
|
|
445
|
+
const pool$1 = rule.directoryOnly ? opts.isDir ? segments : segments.slice(0, -1) : segments;
|
|
446
|
+
if (pool$1.some((s) => rule.regex.test(s))) ignored = !rule.negative;
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
const pool = rule.directoryOnly ? opts.isDir ? prefixes : prefixes.slice(0, -1) : prefixes;
|
|
450
|
+
if (pool.some((p) => rule.regex.test(p))) ignored = !rule.negative;
|
|
451
|
+
}
|
|
452
|
+
return ignored;
|
|
453
|
+
}
|
|
454
|
+
async function suggestPaths(options) {
|
|
455
|
+
const workspaceAbs = normalizePath(String(options.workspaceAbs ?? ""));
|
|
456
|
+
const gitignoreMode = options.gitignore ?? "blocking";
|
|
457
|
+
const gitignoreRules = gitignoreMode === "nonBlocking" ? peekGitignoreRules(workspaceAbs) : await loadGitignoreRules(workspaceAbs);
|
|
458
|
+
return suggestPaths$1({
|
|
459
|
+
...options,
|
|
460
|
+
workspaceAbs,
|
|
461
|
+
shouldIgnore: ({ normalizedRelPath, isDir }) => shouldIgnoreByDefault(normalizedRelPath) || isGitignored(normalizedRelPath, {
|
|
462
|
+
isDir,
|
|
463
|
+
rules: gitignoreRules
|
|
464
|
+
})
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function resolveUserPath(workspaceAbs, input) {
|
|
468
|
+
const env = (process === null || process === void 0 ? void 0 : process.env) ?? {};
|
|
469
|
+
return resolveUserPath$1(workspaceAbs, input, { homeDir: String(env.HOME || env.USERPROFILE || "") });
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
//#endregion
|
|
473
|
+
export { isAbsolutePath, normalizePath, parsePathQuery, resolvePath, resolveUserPath, resolveUserPath$1, stripTrailingSlash, suggestPaths, suggestPaths$1 };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simon_he/vue-tui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"description": "A Vue 3 terminal UI component library",
|
|
6
6
|
"author": "Simon He",
|
|
7
7
|
"license": "MIT",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
+
"bun": "./src/index.ts",
|
|
22
23
|
"import": "./dist/index.js",
|
|
23
24
|
"require": "./dist/index.cjs"
|
|
24
25
|
}
|
|
@@ -38,30 +39,29 @@
|
|
|
38
39
|
"dist"
|
|
39
40
|
],
|
|
40
41
|
"peerDependencies": {
|
|
41
|
-
"vue": "^3.
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"ansi-styles": "^6.2.1"
|
|
42
|
+
"vue": "^3.5.27"
|
|
45
43
|
},
|
|
44
|
+
"dependencies": {},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"@antfu/eslint-config": "^4.
|
|
48
|
-
"@playwright/test": "^1.
|
|
49
|
-
"@sxzz/prettier-config": "^2.
|
|
50
|
-
"@types/node": "^18.19.
|
|
46
|
+
"@antfu/eslint-config": "^4.19.0",
|
|
47
|
+
"@playwright/test": "^1.58.2",
|
|
48
|
+
"@sxzz/prettier-config": "^2.3.1",
|
|
49
|
+
"@types/node": "^18.19.130",
|
|
51
50
|
"bumpp": "^8.2.1",
|
|
52
51
|
"esbuild": "^0.20.2",
|
|
53
|
-
"eslint": "^9.
|
|
54
|
-
"happy-dom": "^17.
|
|
52
|
+
"eslint": "^9.39.4",
|
|
53
|
+
"happy-dom": "^17.6.3",
|
|
55
54
|
"lint-staged": "^13.3.0",
|
|
56
55
|
"picocolors": "^1.1.1",
|
|
57
56
|
"pinia": "^3.0.4",
|
|
58
|
-
"prettier": "^3.
|
|
57
|
+
"prettier": "^3.8.1",
|
|
59
58
|
"rimraf": "^3.0.2",
|
|
60
59
|
"tsdown": "^0.9.9",
|
|
61
60
|
"tsx": "^3.14.0",
|
|
62
|
-
"typescript": "5.
|
|
63
|
-
"
|
|
64
|
-
"
|
|
61
|
+
"typescript": "^5.9.3",
|
|
62
|
+
"vitepress": "^1.6.4",
|
|
63
|
+
"vitest": "^4.1.0",
|
|
64
|
+
"vue": "^3.5.30"
|
|
65
65
|
},
|
|
66
66
|
"lint-staged": {
|
|
67
67
|
"*": [
|
|
@@ -79,8 +79,13 @@
|
|
|
79
79
|
"run:basic:terminal": "pnpm run build && pnpm -C examples/basic terminal",
|
|
80
80
|
"run:basic:multi-select:terminal": "pnpm run build && pnpm -C examples/basic build:terminal:multi-select && pnpm -C examples/basic terminal:multi-select",
|
|
81
81
|
"run:goatchain:terminal": "pnpm run build:goatchain && pnpm -C examples/goatchain terminal",
|
|
82
|
-
"
|
|
83
|
-
"
|
|
82
|
+
"docs:gen": "bunx tsx scripts/generate-component-api-docs.ts",
|
|
83
|
+
"docs:dev": "bun run docs:gen && vitepress dev docs",
|
|
84
|
+
"docs:build": "bun run docs:gen && vitepress build docs",
|
|
85
|
+
"docs:preview": "vitepress preview docs",
|
|
86
|
+
"format": "bunx --bun prettier --cache --write .",
|
|
87
|
+
"format:check": "bunx --bun prettier --check .",
|
|
88
|
+
"lint": "bunx --bun eslint . --cache",
|
|
84
89
|
"lint:fix": "pnpm run lint --fix",
|
|
85
90
|
"release": "bumpp && pnpm publish --no-git-checks --access public",
|
|
86
91
|
"start": "esno src/index.ts",
|