ftreeview 0.1.1
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/LICENSE +21 -0
- package/README.md +235 -0
- package/dist/cli.js +1619 -0
- package/package.json +58 -0
- package/src/App.jsx +243 -0
- package/src/cli.js +228 -0
- package/src/components/StatusBar.jsx +270 -0
- package/src/components/TreeLine.jsx +190 -0
- package/src/components/TreeView.jsx +129 -0
- package/src/hooks/useChangedFiles.js +82 -0
- package/src/hooks/useGitStatus.js +347 -0
- package/src/hooks/useIgnore.js +182 -0
- package/src/hooks/useNavigation.js +247 -0
- package/src/hooks/useTree.js +508 -0
- package/src/hooks/useWatcher.js +129 -0
- package/src/index.js +22 -0
- package/src/lib/changeStatus.js +79 -0
- package/src/lib/connectors.js +233 -0
- package/src/lib/constants.js +64 -0
- package/src/lib/icons.js +658 -0
- package/src/lib/theme.js +102 -0
package/src/lib/theme.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme + UI tokens for ftree.
|
|
3
|
+
*
|
|
4
|
+
* Ink is cross-terminal, so we keep tokens simple (named colors, dim/bold).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const ICON_SET = {
|
|
8
|
+
AUTO: 'auto',
|
|
9
|
+
EMOJI: 'emoji',
|
|
10
|
+
NERD: 'nerd',
|
|
11
|
+
ASCII: 'ascii',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const THEME = {
|
|
15
|
+
VSCODE: 'vscode',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const VSCODE_THEME = {
|
|
19
|
+
name: THEME.VSCODE,
|
|
20
|
+
colors: {
|
|
21
|
+
fg: 'white',
|
|
22
|
+
muted: 'gray',
|
|
23
|
+
accent: 'cyan',
|
|
24
|
+
success: 'green',
|
|
25
|
+
warning: 'yellow',
|
|
26
|
+
danger: 'red',
|
|
27
|
+
},
|
|
28
|
+
tree: {
|
|
29
|
+
connector: { color: 'gray', dimColor: true },
|
|
30
|
+
cursor: { backgroundColor: 'blue', color: 'white' },
|
|
31
|
+
dirName: { color: 'cyan', bold: true },
|
|
32
|
+
fileName: { color: 'white' },
|
|
33
|
+
hidden: { color: 'gray', dimColor: true },
|
|
34
|
+
symlink: { color: 'magenta' },
|
|
35
|
+
error: { color: 'red' },
|
|
36
|
+
},
|
|
37
|
+
statusBar: {
|
|
38
|
+
separator: '•',
|
|
39
|
+
separatorStyle: { color: 'gray', dimColor: true },
|
|
40
|
+
hintStyle: { color: 'gray', dimColor: true },
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Resolve icon set selection deterministically.
|
|
46
|
+
*
|
|
47
|
+
* Precedence:
|
|
48
|
+
* 1) CLI flag (--icon-set)
|
|
49
|
+
* 2) Env var (FTREE_ICON_SET)
|
|
50
|
+
* 3) Fallback to emoji
|
|
51
|
+
*
|
|
52
|
+
* @param {object} options
|
|
53
|
+
* @param {string|undefined} options.cliIconSet
|
|
54
|
+
* @param {boolean} [options.noIcons]
|
|
55
|
+
* @param {NodeJS.ProcessEnv} [options.env]
|
|
56
|
+
* @returns {'emoji'|'nerd'|'ascii'}
|
|
57
|
+
*/
|
|
58
|
+
export function resolveIconSet({ cliIconSet, noIcons = false, env = process.env } = {}) {
|
|
59
|
+
const fromCli = (cliIconSet || '').toLowerCase();
|
|
60
|
+
const fromEnv = (env.FTREE_ICON_SET || '').toLowerCase();
|
|
61
|
+
|
|
62
|
+
// Back-compat: --no-icons acts like "ascii"
|
|
63
|
+
if (noIcons && !fromCli) {
|
|
64
|
+
return ICON_SET.ASCII;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const requested = fromCli || fromEnv || ICON_SET.EMOJI;
|
|
68
|
+
|
|
69
|
+
if (requested === ICON_SET.NERD) return ICON_SET.NERD;
|
|
70
|
+
if (requested === ICON_SET.ASCII) return ICON_SET.ASCII;
|
|
71
|
+
return ICON_SET.EMOJI;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Resolve theme name deterministically (currently single theme).
|
|
76
|
+
*
|
|
77
|
+
* @param {object} options
|
|
78
|
+
* @param {string|undefined} options.cliTheme
|
|
79
|
+
* @param {NodeJS.ProcessEnv} [options.env]
|
|
80
|
+
* @returns {string} theme name
|
|
81
|
+
*/
|
|
82
|
+
export function resolveThemeName({ cliTheme, env = process.env } = {}) {
|
|
83
|
+
const requested = (cliTheme || env.FTREE_THEME || THEME.VSCODE).toLowerCase();
|
|
84
|
+
if (requested === THEME.VSCODE) {
|
|
85
|
+
return THEME.VSCODE;
|
|
86
|
+
}
|
|
87
|
+
return THEME.VSCODE;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get theme tokens.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} [themeName]
|
|
94
|
+
* @returns {typeof VSCODE_THEME}
|
|
95
|
+
*/
|
|
96
|
+
export function getTheme(themeName = THEME.VSCODE) {
|
|
97
|
+
if (themeName === THEME.VSCODE) {
|
|
98
|
+
return VSCODE_THEME;
|
|
99
|
+
}
|
|
100
|
+
return VSCODE_THEME;
|
|
101
|
+
}
|
|
102
|
+
|