dsh-remote-vs 0.19.1 → 0.20.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.
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Coloured file-type / folder icons for the remote DIRECTORY TREE
3
+ * (`RemoteExplorer`), so a remote folder looks like the local sidebar's folder.
4
+ *
5
+ * Scope: the tree only. Search hits, SCM rows, commit panes and download rows
6
+ * keep the neutral outline glyphs from `kit.tsx` — this set is deliberately not
7
+ * the fallback of `FileIcon` / `FolderIcon`.
8
+ *
9
+ * Provenance
10
+ * ----------
11
+ * These are a straight port of the local sidebar plugin's artwork (`FileTypeIcon`
12
+ * and its amber `FolderIcon` in dsh-sidebar's `src/client/icons.tsx`, package
13
+ * name `dsh-sidebar`): one paper sheet whose colour and bottom-right mark carry
14
+ * the type — TS blue + `<>`, JS yellow + `<>`, Python blue with a yellow mark,
15
+ * Markdown blue + lines, images purple + a mountain, archives yellow + a zip,
16
+ * `.gitignore` orange + a commit graph.
17
+ *
18
+ * The copy exists on purpose: the client bundle may not import another plugin's
19
+ * values (tsdown's purity gate rejects cross-plugin imports), and dsh-sidebar
20
+ * publishes no `fileIcon` / `folderIcon` service that `kit.tsx` could call.
21
+ * `kit.tsx` still prefers such a service if a host ever provides one (the
22
+ * better-sidebar lineage is where that contract would come from); this set is
23
+ * the fallback that paints a real, typed tree in a dsh-sidebar profile.
24
+ *
25
+ * One deliberate difference from the source: the image mark used
26
+ * `fill="currentColor"`, which in a tree inherits the row's dim text colour —
27
+ * `.rvs-node-icon` sets `color: var(--rvs-fg3)` — so the mountain would render
28
+ * grey on the purple sheet. Here the mark group pins `color` to the type colour
29
+ * and the artwork stays the colour the palette intends.
30
+ */
31
+ import type { ReactNode } from 'react';
32
+ /** The bottom-right mark that carries the category (drawn in the type colour). */
33
+ type FileMark = 'code' | 'markup' | 'style' | 'data' | 'doc' | 'image' | 'archive' | 'shell' | 'config' | 'git' | 'lock' | 'box' | 'table';
34
+ /** How one file type looks: sheet colour + category mark + optional mark colour. */
35
+ export interface FileLook {
36
+ color: string;
37
+ mark: FileMark;
38
+ /** Mark colour; defaults to the sheet colour (Python = blue sheet + yellow mark). */
39
+ markColor?: string;
40
+ }
41
+ /**
42
+ * The extension / exact-name tables, exposed read-only for the gate's full-table
43
+ * snapshot: one changed hex or mark must turn `scripts/check-file-icons.mjs`
44
+ * red, instead of shipping a silently different palette.
45
+ *
46
+ * `baseName` stays private on purpose — `kit.tsx` already exports a `baseName`
47
+ * with different semantics (POSIX only, strips a trailing slash), and exporting
48
+ * both invites the wrong import.
49
+ */
50
+ export declare const FILE_TYPE_LOOKS: Readonly<Record<string, FileLook>>;
51
+ export declare const FILE_NAME_LOOKS: Readonly<Record<string, FileLook>>;
52
+ /** Resolve a path's look from its name / extension. */
53
+ export declare function lookOf(path: string): FileLook;
54
+ /** Props for {@link FileTypeIcon} / {@link FolderGlyph}. */
55
+ export interface FileIconProps {
56
+ /** Workspace-relative path (any separator); only the basename is read. */
57
+ path: string;
58
+ /** Edge length in px, default 16. */
59
+ size?: number;
60
+ className?: string;
61
+ }
62
+ /**
63
+ * Coloured file-type icon: sheet + top-right fold + bottom-right category mark.
64
+ *
65
+ * At 16 px this reads better than two-letter badges and does not depend on font
66
+ * rendering.
67
+ */
68
+ export declare function FileTypeIcon(props: FileIconProps): ReactNode;
69
+ /** Every extension the file-type icon recognises (reporting / gate). */
70
+ export declare const FILE_TYPE_EXTENSIONS: readonly string[];
71
+ /** Props for the amber folder glyph. */
72
+ export interface FolderGlyphProps {
73
+ /** Expanded: the front flap drops down and reveals the inner sheet (VSCode-like). */
74
+ open?: boolean;
75
+ /** Edge length in px, default 16. */
76
+ size?: number;
77
+ className?: string;
78
+ }
79
+ /**
80
+ * Amber folder icon. The folder colour is content colour, in the same scheme as
81
+ * the file types — it does not follow the skin.
82
+ */
83
+ export declare function FolderGlyph(props: FolderGlyphProps): ReactNode;
84
+ export {};
@@ -5,11 +5,17 @@
5
5
  * ships the same split, and the confirm dialogs are what guard destructive
6
6
  * remote git verbs).
7
7
  *
8
- * Icon sourcing: when dsh-better-sidebar is installed its service answers
9
- * `fileIcon` / `folderIcon`, which run the host's own classifier and any
10
- * user-registered icon theme — the remote tree then matches the user's local
11
- * sidebar glyph for glyph. Without that service the built-in SVG set below
12
- * takes over, so the native fallback surface still renders a real tree.
8
+ * Icon sourcing has two tiers. `FileIcon` / `FolderIcon` paint the plain glyphs
9
+ * below (search hits, SCM rows, commit panes, download rows — list chrome where
10
+ * one neutral outline reads best). `ExplorerFileIcon` / `ExplorerFolderIcon`
11
+ * paint the COLOURED type set ported from dsh-sidebar in `./file-icons.tsx`, so
12
+ * the remote directory tree looks like the local sidebar's tree: one sheet
13
+ * whose colour and mark carry the file type, and an amber folder that opens.
14
+ *
15
+ * Every tier still prefers the host service when one is published (the
16
+ * better-sidebar lineage's `fileIcon` / `folderIcon`: host classifier plus any
17
+ * registered icon theme). dsh-sidebar itself publishes none today, so in a
18
+ * dsh-sidebar profile the SVG sets above are what actually render.
13
19
  */
14
20
  import { type ReactNode } from 'react';
15
21
  type IconProps = {
@@ -101,6 +107,19 @@ export declare function FolderIcon(props: {
101
107
  size?: number;
102
108
  className?: string;
103
109
  }): ReactNode;
110
+ /** Explorer file row: host glyph when available, else the coloured type icon. */
111
+ export declare function ExplorerFileIcon(props: {
112
+ path: string;
113
+ size?: number;
114
+ className?: string;
115
+ }): ReactNode;
116
+ /** Explorer directory row: host glyph when available, else the amber folder. */
117
+ export declare function ExplorerFolderIcon(props: {
118
+ path: string;
119
+ open: boolean;
120
+ size?: number;
121
+ className?: string;
122
+ }): ReactNode;
104
123
  export declare function isImageFile(path: string): boolean;
105
124
  export declare function isMarkdownFile(path: string): boolean;
106
125
  export declare function isHtmlFile(path: string): boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-remote-vs",
3
3
  "description": "VSCode-style remote development for DSH: SSH host manager (key/password), helper deploy pipeline with version check, remote file explorer + editor + terminal in dsh-better-sidebar.",
4
- "version": "0.19.1",
4
+ "version": "0.20.0",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
7
7
  "dsh",
@@ -32,8 +32,8 @@ import {
32
32
  IconRefresh,
33
33
  IconUpload,
34
34
  ContextMenu,
35
- FileIcon,
36
- FolderIcon,
35
+ ExplorerFileIcon,
36
+ ExplorerFolderIcon,
37
37
  baseName,
38
38
  confirmDialog,
39
39
  copyText,
@@ -566,8 +566,8 @@ export const ExplorerRowView = memo(function ExplorerRowView(props: ExplorerRowP
566
566
  >
567
567
  <span className="rvs-node-icon">
568
568
  {entry.isDir
569
- ? <FolderIcon path={entry.path} open={isOpen} size={15} />
570
- : <FileIcon path={entry.path} size={15} />}
569
+ ? <ExplorerFolderIcon path={entry.path} open={isOpen} size={16} />
570
+ : <ExplorerFileIcon path={entry.path} size={16} />}
571
571
  </span>
572
572
  {isRenaming
573
573
  ? (
@@ -2229,8 +2229,12 @@ export function RemoteExplorer(props: { showHidden: boolean; onToggleHidden: ()
2229
2229
  kind={row.createKind}
2230
2230
  onCommit={(value) => { void doCreate(value) }}
2231
2231
  onCancel={() => setCreating(undefined)}
2232
- fileIcon={<FileIcon path="name.ts" size={15} />}
2233
- folderIcon={<FolderIcon path="name" open={false} size={15} />}
2232
+ // 16 px to match the tree rows and the local sidebar's tree, and
2233
+ // a nameless sheet for the file: the row has no path yet, so
2234
+ // claiming a type (the old hard-coded `name.ts`) would paint
2235
+ // every "new file" row TS-blue.
2236
+ fileIcon={<ExplorerFileIcon path="untitled" size={16} />}
2237
+ folderIcon={<ExplorerFolderIcon path="name" open={false} size={16} />}
2234
2238
  t={t}
2235
2239
  />
2236
2240
  )
@@ -73,7 +73,7 @@ const zh: Record<string, string> = {
73
73
  'tab.terminal': '终端',
74
74
  'tab.ports': '端口',
75
75
  'tab.monitor': '监控',
76
- 'tab.remote': '远程',
76
+ 'tab.remote': '远程工作台',
77
77
  'tab.remoteDesc': '远端文件、终端与 Git',
78
78
  'hosts.title': '远程主机',
79
79
  'hosts.empty': '尚未配置主机。点击「新增主机」,或从现有配置导入。',
@@ -240,8 +240,8 @@ const zh: Record<string, string> = {
240
240
  'settings.hosts': '远程主机',
241
241
  'settings.workspaces': '远程工作区',
242
242
  'plugin.version': '插件版本',
243
- 'native.tab': '远程',
244
- 'native.guide.title': '远程',
243
+ 'native.tab': '远程工作台',
244
+ 'native.guide.title': '远程工作台',
245
245
  'native.guide.desc': '远端文件、终端与 Git',
246
246
  // ---- VS Code-style explorer (rail, tree, SCM, diff, history, editor)
247
247
  'tab.search': '搜索',
@@ -688,7 +688,7 @@ const en: Record<string, string> = {
688
688
  'tab.terminal': 'Terminal',
689
689
  'tab.ports': 'Ports',
690
690
  'tab.monitor': 'Monitor',
691
- 'tab.remote': 'Remote',
691
+ 'tab.remote': 'Remote Workspace',
692
692
  'tab.remoteDesc': 'Remote files, terminal and Git',
693
693
  'hosts.title': 'Remote hosts',
694
694
  'hosts.empty': 'No hosts yet. Add one, or import from existing configs.',
@@ -855,8 +855,8 @@ const en: Record<string, string> = {
855
855
  'settings.hosts': 'Remote hosts',
856
856
  'settings.workspaces': 'Remote workspaces',
857
857
  'plugin.version': 'Plugin version',
858
- 'native.tab': 'Remote',
859
- 'native.guide.title': 'Remote',
858
+ 'native.tab': 'Remote Workspace',
859
+ 'native.guide.title': 'Remote Workspace',
860
860
  'native.guide.desc': 'Remote files, terminal and Git',
861
861
  // ---- VS Code-style explorer
862
862
  'tab.search': 'Search',
@@ -83,9 +83,11 @@ export function apply(ctx: Context): void {
83
83
  return false
84
84
  }
85
85
  if (sidebar === undefined) return false
86
- // The host icon classifier paints the remote tree with the same glyphs
87
- // the local sidebar uses (and honours any registered icon theme). It is
88
- // optional: without it the built-in SVG set takes over.
86
+ // Optional host icon classifier: a better-sidebar release may publish
87
+ // `fileIcon` / `folderIcon` alongside `registerTab`, and then the remote
88
+ // tree follows the user's registered icon theme. dsh-sidebar (the local
89
+ // sidebar this plugin usually runs next to) publishes none, so in practice
90
+ // the built-in colour set in `vsc/file-icons.tsx` is what paints the tree.
89
91
  try {
90
92
  const candidate = sidebar as unknown as Partial<IconServiceLike>
91
93
  if (typeof candidate.fileIcon === 'function' && typeof candidate.folderIcon === 'function') {
@@ -0,0 +1,380 @@
1
+ /**
2
+ * Coloured file-type / folder icons for the remote DIRECTORY TREE
3
+ * (`RemoteExplorer`), so a remote folder looks like the local sidebar's folder.
4
+ *
5
+ * Scope: the tree only. Search hits, SCM rows, commit panes and download rows
6
+ * keep the neutral outline glyphs from `kit.tsx` — this set is deliberately not
7
+ * the fallback of `FileIcon` / `FolderIcon`.
8
+ *
9
+ * Provenance
10
+ * ----------
11
+ * These are a straight port of the local sidebar plugin's artwork (`FileTypeIcon`
12
+ * and its amber `FolderIcon` in dsh-sidebar's `src/client/icons.tsx`, package
13
+ * name `dsh-sidebar`): one paper sheet whose colour and bottom-right mark carry
14
+ * the type — TS blue + `<>`, JS yellow + `<>`, Python blue with a yellow mark,
15
+ * Markdown blue + lines, images purple + a mountain, archives yellow + a zip,
16
+ * `.gitignore` orange + a commit graph.
17
+ *
18
+ * The copy exists on purpose: the client bundle may not import another plugin's
19
+ * values (tsdown's purity gate rejects cross-plugin imports), and dsh-sidebar
20
+ * publishes no `fileIcon` / `folderIcon` service that `kit.tsx` could call.
21
+ * `kit.tsx` still prefers such a service if a host ever provides one (the
22
+ * better-sidebar lineage is where that contract would come from); this set is
23
+ * the fallback that paints a real, typed tree in a dsh-sidebar profile.
24
+ *
25
+ * One deliberate difference from the source: the image mark used
26
+ * `fill="currentColor"`, which in a tree inherits the row's dim text colour —
27
+ * `.rvs-node-icon` sets `color: var(--rvs-fg3)` — so the mountain would render
28
+ * grey on the purple sheet. Here the mark group pins `color` to the type colour
29
+ * and the artwork stays the colour the palette intends.
30
+ */
31
+ import type { ReactNode } from 'react'
32
+
33
+ /** File paper outline (shared by every file-type icon). */
34
+ const SHEET = 'M4 1.4h5.4l3.6 3.6v9.4c0 .5-.4.9-.9.9H3.1a.9.9 0 0 1-.9-.9V2.3c0-.5.4-.9.9-.9Z'
35
+ /** Top-right fold. */
36
+ const SHEET_FOLD = 'M9.4 1.4v3.6h3.6'
37
+
38
+ /** The bottom-right mark that carries the category (drawn in the type colour). */
39
+ type FileMark =
40
+ | 'code' | 'markup' | 'style' | 'data' | 'doc' | 'image'
41
+ | 'archive' | 'shell' | 'config' | 'git' | 'lock' | 'box' | 'table'
42
+
43
+ /** How one file type looks: sheet colour + category mark + optional mark colour. */
44
+ export interface FileLook {
45
+ color: string
46
+ mark: FileMark
47
+ /** Mark colour; defaults to the sheet colour (Python = blue sheet + yellow mark). */
48
+ markColor?: string
49
+ }
50
+
51
+ /** Extension → look. Brand colours are tuned for readability on dark and light. */
52
+ const BY_EXT: Readonly<Record<string, FileLook>> = { ts: { color: '#519aba', mark: 'code' },
53
+ mts: { color: '#519aba', mark: 'code' },
54
+ cts: { color: '#519aba', mark: 'code' },
55
+ tsx: { color: '#4fc3f7', mark: 'code' },
56
+ js: { color: '#d5c93f', mark: 'code' },
57
+ mjs: { color: '#d5c93f', mark: 'code' },
58
+ cjs: { color: '#d5c93f', mark: 'code' },
59
+ jsx: { color: '#4fc3f7', mark: 'code' },
60
+ json: { color: '#d2b13a', mark: 'data' },
61
+ jsonc: { color: '#d2b13a', mark: 'data' },
62
+ json5: { color: '#d2b13a', mark: 'data' },
63
+ md: { color: '#4b9fe3', mark: 'doc' },
64
+ markdown: { color: '#4b9fe3', mark: 'doc' },
65
+ mdx: { color: '#4b9fe3', mark: 'doc' },
66
+ py: { color: '#3572a5', mark: 'code', markColor: '#ffd75e' },
67
+ pyi: { color: '#3572a5', mark: 'code', markColor: '#ffd75e' },
68
+ java: { color: '#e05a4f', mark: 'code' },
69
+ kt: { color: '#a97bff', mark: 'code' },
70
+ c: { color: '#7f9bd6', mark: 'code' },
71
+ h: { color: '#a074c4', mark: 'code' },
72
+ cpp: { color: '#6295cb', mark: 'code' },
73
+ cc: { color: '#6295cb', mark: 'code' },
74
+ cxx: { color: '#6295cb', mark: 'code' },
75
+ hpp: { color: '#6295cb', mark: 'code' },
76
+ hh: { color: '#6295cb', mark: 'code' },
77
+ cs: { color: '#b878d8', mark: 'code' },
78
+ go: { color: '#00add8', mark: 'code' },
79
+ rs: { color: '#dea584', mark: 'code' },
80
+ php: { color: '#8b9be8', mark: 'code' },
81
+ rb: { color: '#e05a4f', mark: 'code' },
82
+ swift: { color: '#e8743b', mark: 'code' },
83
+ lua: { color: '#5a8fe0', mark: 'code' },
84
+ html: { color: '#e8743b', mark: 'markup' },
85
+ htm: { color: '#e8743b', mark: 'markup' },
86
+ vue: { color: '#41b883', mark: 'markup' },
87
+ svelte: { color: '#ff5c33', mark: 'markup' },
88
+ xml: { color: '#f19a38', mark: 'markup' },
89
+ xsl: { color: '#f19a38', mark: 'markup' },
90
+ css: { color: '#42a5f5', mark: 'style' },
91
+ scss: { color: '#e05a8f', mark: 'style' },
92
+ sass: { color: '#e05a8f', mark: 'style' },
93
+ less: { color: '#42a5f5', mark: 'style' },
94
+ yaml: { color: '#a074c4', mark: 'data' },
95
+ yml: { color: '#a074c4', mark: 'data' },
96
+ toml: { color: '#b08b6a', mark: 'config' },
97
+ ini: { color: '#b08b6a', mark: 'config' },
98
+ conf: { color: '#b08b6a', mark: 'config' },
99
+ cfg: { color: '#b08b6a', mark: 'config' },
100
+ env: { color: '#b08b6a', mark: 'config' },
101
+ sh: { color: '#4ec9b0', mark: 'shell' },
102
+ bash: { color: '#4ec9b0', mark: 'shell' },
103
+ zsh: { color: '#4ec9b0', mark: 'shell' },
104
+ fish: { color: '#4ec9b0', mark: 'shell' },
105
+ ps1: { color: '#4ec9b0', mark: 'shell' },
106
+ psm1: { color: '#4ec9b0', mark: 'shell' },
107
+ bat: { color: '#4ec9b0', mark: 'shell' },
108
+ cmd: { color: '#4ec9b0', mark: 'shell' },
109
+ txt: { color: '#9aa0a6', mark: 'doc' },
110
+ log: { color: '#9aa0a6', mark: 'doc' },
111
+ csv: { color: '#7fb36b', mark: 'table' },
112
+ tsv: { color: '#7fb36b', mark: 'table' },
113
+ xlsx: { color: '#7fb36b', mark: 'table' },
114
+ png: { color: '#b18adf', mark: 'image' },
115
+ jpg: { color: '#b18adf', mark: 'image' },
116
+ jpeg: { color: '#b18adf', mark: 'image' },
117
+ gif: { color: '#b18adf', mark: 'image' },
118
+ webp: { color: '#b18adf', mark: 'image' },
119
+ bmp: { color: '#b18adf', mark: 'image' },
120
+ ico: { color: '#b18adf', mark: 'image' },
121
+ avif: { color: '#b18adf', mark: 'image' },
122
+ svg: { color: '#b18adf', mark: 'image' },
123
+ pdf: { color: '#d94f4f', mark: 'doc' },
124
+ zip: { color: '#d9b64a', mark: 'archive' },
125
+ rar: { color: '#d9b64a', mark: 'archive' },
126
+ '7z': { color: '#d9b64a', mark: 'archive' },
127
+ tar: { color: '#d9b64a', mark: 'archive' },
128
+ gz: { color: '#d9b64a', mark: 'archive' },
129
+ tgz: { color: '#d9b64a', mark: 'archive' },
130
+ bz2: { color: '#d9b64a', mark: 'archive' },
131
+ xz: { color: '#d9b64a', mark: 'archive' },
132
+ lock: { color: '#8b949e', mark: 'lock' },
133
+ dockerfile: { color: '#2496ed', mark: 'box' },
134
+ docker: { color: '#2496ed', mark: 'box' },
135
+ // `demo.gitignore` / `x.gitattributes` derive from the dot-file convention and
136
+ // take the orange branch mark here; the plain names are in BY_NAME.
137
+ gitignore: { color: '#e8703a', mark: 'git' },
138
+ gitattributes: { color: '#e8703a', mark: 'git' },
139
+ gitmodules: { color: '#e8703a', mark: 'git' },
140
+ exe: { color: '#8b949e', mark: 'box' },
141
+ dll: { color: '#8b949e', mark: 'box' },
142
+ so: { color: '#8b949e', mark: 'box' },
143
+ dylib: { color: '#8b949e', mark: 'box' },
144
+ }
145
+
146
+ /** Exact file name → look (extension-less files and conventional names hit here first). */
147
+ const BY_NAME: Readonly<Record<string, FileLook>> = {
148
+ dockerfile: { color: '#2496ed', mark: 'box' },
149
+ 'docker-compose.yml': { color: '#2496ed', mark: 'box' },
150
+ 'docker-compose.yaml': { color: '#2496ed', mark: 'box' },
151
+ makefile: { color: '#b08b6a', mark: 'config' },
152
+ gnumakefile: { color: '#b08b6a', mark: 'config' },
153
+ 'cmakelists.txt': { color: '#b08b6a', mark: 'config' },
154
+ '.gitignore': { color: '#e8703a', mark: 'git' },
155
+ '.gitattributes': { color: '#e8703a', mark: 'git' },
156
+ '.gitmodules': { color: '#e8703a', mark: 'git' },
157
+ '.npmrc': { color: '#b08b6a', mark: 'config' },
158
+ '.editorconfig': { color: '#b08b6a', mark: 'config' },
159
+ '.prettierrc': { color: '#b08b6a', mark: 'config' },
160
+ 'package-lock.json': { color: '#8b949e', mark: 'lock' },
161
+ 'pnpm-lock.yaml': { color: '#8b949e', mark: 'lock' },
162
+ 'yarn.lock': { color: '#8b949e', mark: 'lock' },
163
+ license: { color: '#9aa0a6', mark: 'doc' },
164
+ readme: { color: '#4b9fe3', mark: 'doc' },
165
+ }
166
+
167
+ /** Unrecognised file: grey document. */
168
+ const FALLBACK: FileLook = { color: '#8b949e', mark: 'doc' }
169
+
170
+ /**
171
+ * The extension / exact-name tables, exposed read-only for the gate's full-table
172
+ * snapshot: one changed hex or mark must turn `scripts/check-file-icons.mjs`
173
+ * red, instead of shipping a silently different palette.
174
+ *
175
+ * `baseName` stays private on purpose — `kit.tsx` already exports a `baseName`
176
+ * with different semantics (POSIX only, strips a trailing slash), and exporting
177
+ * both invites the wrong import.
178
+ */
179
+ export const FILE_TYPE_LOOKS: Readonly<Record<string, FileLook>> = BY_EXT
180
+ export const FILE_NAME_LOOKS: Readonly<Record<string, FileLook>> = BY_NAME
181
+
182
+ /** Drawing commands for a category mark (coordinates sit on the sheet's lower half). */
183
+ const MARKS: Readonly<Record<FileMark, ReactNode>> = {
184
+ code: (
185
+ <>
186
+ <path d="M6.4 7.8 5 9.6l1.4 1.8" />
187
+ <path d="M9.6 7.8 11 9.6l-1.4 1.8" />
188
+ </>
189
+ ),
190
+ markup: (
191
+ <>
192
+ <path d="M5.8 7.9 4.4 9.8l1.4 1.9" />
193
+ <path d="M8.6 7.5l-1.6 4.6" />
194
+ <path d="M10.2 7.9l1.4 1.9-1.4 1.9" />
195
+ </>
196
+ ),
197
+ style: (
198
+ <>
199
+ <path d="M7.1 7.6 6.3 12M9.7 7.6l-.8 4.4" />
200
+ <path d="M5.5 9h4.9M5.3 10.6h4.9" />
201
+ </>
202
+ ),
203
+ data: (
204
+ <>
205
+ <path d="M7.1 7.4c-.9 0-.9.7-.9 1.3s0 1.2-.9 1.2c.9 0 .9.6.9 1.2s0 1.3.9 1.3" />
206
+ <path d="M8.9 7.4c.9 0 .9.7.9 1.3s0 1.2.9 1.2c-.9 0-.9.6-.9 1.2s0 1.3-.9 1.3" />
207
+ </>
208
+ ),
209
+ doc: <path d="M5.2 7.8h5.6M5.2 9.7h5.6M5.2 11.6h3.6" />,
210
+ image: (
211
+ <>
212
+ <circle cx="6.4" cy="8.1" r=".85" fill="currentColor" stroke="none" />
213
+ <path d="M4.8 12.2l2.1-2.6 1.5 1.7 1.2-1.3 1.8 2.2Z" fill="currentColor" stroke="none" />
214
+ </>
215
+ ),
216
+ archive: (
217
+ <>
218
+ <path d="M4.8 7.6h6.4v4.6H4.8z" />
219
+ <path d="M4.8 9h6.4" />
220
+ <path d="M7.2 7.6v1.4M7.2 10.4h1.6" />
221
+ </>
222
+ ),
223
+ shell: (
224
+ <>
225
+ <path d="M5.2 8.2 6.9 9.8l-1.7 1.6" />
226
+ <path d="M8.3 11.4h2.7" />
227
+ </>
228
+ ),
229
+ config: (
230
+ <>
231
+ <path d="M5 8.2h6M5 11h6" />
232
+ <circle cx="7" cy="8.2" r="1.05" />
233
+ <circle cx="9.4" cy="11" r="1.05" />
234
+ </>
235
+ ),
236
+ git: (
237
+ <>
238
+ <circle cx="6" cy="7.7" r="1" />
239
+ <circle cx="9.8" cy="10.9" r="1" />
240
+ <path d="M6 8.7v1.3M9.8 8.6c0 1.4-3.8 1.3-3.8 2.3" />
241
+ </>
242
+ ),
243
+ lock: (
244
+ <>
245
+ <rect x="5.4" y="8.6" width="5.2" height="3.8" rx="1" />
246
+ <path d="M6.6 8.6V7.4a1.4 1.4 0 0 1 2.8 0v1.2" />
247
+ </>
248
+ ),
249
+ box: (
250
+ <>
251
+ <path d="M4.6 8.4h2v1.8h-2zM6.9 8.4h2v1.8h-2zM6.9 10.5h2v1.8h-2zM4.6 12.6h6.8" />
252
+ </>
253
+ ),
254
+ table: (
255
+ <>
256
+ <path d="M4.8 7.6h6.4v4.6H4.8z" />
257
+ <path d="M4.8 9.1h6.4M4.8 10.7h6.4M7.5 7.6v4.6" />
258
+ </>
259
+ ),
260
+ }
261
+
262
+ /** Basename of a path that may use either separator. */
263
+ function baseName(path: string): string {
264
+ const normalized = path.replace(/\\/g, '/')
265
+ return normalized.slice(normalized.lastIndexOf('/') + 1)
266
+ }
267
+
268
+ /** Resolve a path's look from its name / extension. */
269
+ export function lookOf(path: string): FileLook {
270
+ const name = baseName(path).toLowerCase()
271
+ const named = BY_NAME[name]
272
+ if (named !== undefined) return named
273
+ if (name.startsWith('.env')) return { color: '#b08b6a', mark: 'config' }
274
+ const dot = name.lastIndexOf('.')
275
+ // dot === 0 is a dot-file such as `.bashrc` with no extension: fall through.
276
+ if (dot <= 0) return FALLBACK
277
+ return BY_EXT[name.slice(dot + 1)] ?? FALLBACK
278
+ }
279
+
280
+ /** Props for {@link FileTypeIcon} / {@link FolderGlyph}. */
281
+ export interface FileIconProps {
282
+ /** Workspace-relative path (any separator); only the basename is read. */
283
+ path: string
284
+ /** Edge length in px, default 16. */
285
+ size?: number
286
+ className?: string
287
+ }
288
+
289
+ /**
290
+ * Coloured file-type icon: sheet + top-right fold + bottom-right category mark.
291
+ *
292
+ * At 16 px this reads better than two-letter badges and does not depend on font
293
+ * rendering.
294
+ */
295
+ export function FileTypeIcon(props: FileIconProps): ReactNode {
296
+ const size = props.size ?? 16
297
+ const look = lookOf(props.path)
298
+ return (
299
+ <svg
300
+ width={size}
301
+ height={size}
302
+ viewBox="0 0 16 16"
303
+ fill="none"
304
+ className={props.className}
305
+ aria-hidden="true"
306
+ >
307
+ <path
308
+ d={SHEET}
309
+ fill={look.color}
310
+ fillOpacity={0.14}
311
+ stroke={look.color}
312
+ strokeWidth={1}
313
+ strokeLinejoin="round"
314
+ />
315
+ <path d={SHEET_FOLD} stroke={look.color} strokeWidth={1} strokeLinejoin="round" />
316
+ <g
317
+ stroke={look.markColor ?? look.color}
318
+ strokeWidth={1.15}
319
+ strokeLinecap="round"
320
+ strokeLinejoin="round"
321
+ // Pins currentColor for the image mark to the type colour: the tree row
322
+ // sets a dim text colour that would otherwise grey the mountain out.
323
+ style={{ color: look.markColor ?? look.color }}
324
+ >
325
+ {MARKS[look.mark]}
326
+ </g>
327
+ </svg>
328
+ )
329
+ }
330
+
331
+ /** Every extension the file-type icon recognises (reporting / gate). */
332
+ export const FILE_TYPE_EXTENSIONS: readonly string[] = Object.keys(BY_EXT).sort()
333
+
334
+ /** Props for the amber folder glyph. */
335
+ export interface FolderGlyphProps {
336
+ /** Expanded: the front flap drops down and reveals the inner sheet (VSCode-like). */
337
+ open?: boolean
338
+ /** Edge length in px, default 16. */
339
+ size?: number
340
+ className?: string
341
+ }
342
+
343
+ /**
344
+ * Amber folder icon. The folder colour is content colour, in the same scheme as
345
+ * the file types — it does not follow the skin.
346
+ */
347
+ export function FolderGlyph(props: FolderGlyphProps): ReactNode {
348
+ const size = props.size ?? 16
349
+ return props.open === true
350
+ ? (
351
+ <svg width={size} height={size} viewBox="0 0 16 16" fill="none" className={props.className} aria-hidden="true">
352
+ <path
353
+ d="M1.9 12V4.3c0-.6.4-1 1-1h3.2l1.5 1.7h5.6c.6 0 1 .4 1 1v5.4"
354
+ fill="#c69a3f"
355
+ stroke="#a8781c"
356
+ strokeWidth=".9"
357
+ strokeLinejoin="round"
358
+ />
359
+ <path
360
+ d="M2 12.6 3.5 8c.1-.4.5-.7.9-.7h9.5c.7 0 1.2.7 1 1.4l-1.3 3.8c-.1.4-.5.7-.9.7H2.9c-.6 0-1-.5-.9-1.1Z"
361
+ fill="#e7b95d"
362
+ stroke="#a8781c"
363
+ strokeWidth=".9"
364
+ strokeLinejoin="round"
365
+ />
366
+ </svg>
367
+ )
368
+ : (
369
+ <svg width={size} height={size} viewBox="0 0 16 16" fill="none" className={props.className} aria-hidden="true">
370
+ <path
371
+ d="M1.9 12.3V4.2c0-.6.4-1 1-1h3.2l1.5 1.7h5.6c.6 0 1 .4 1 1v6.4c0 .6-.4 1-1 1H2.9c-.6 0-1-.4-1-1Z"
372
+ fill="#d9ab4e"
373
+ stroke="#a8781c"
374
+ strokeWidth=".9"
375
+ strokeLinejoin="round"
376
+ />
377
+ <path d="M2.6 5.3h10.8" stroke="#a8781c" strokeWidth=".9" opacity=".45" />
378
+ </svg>
379
+ )
380
+ }