@opencode/ui 2.2.5 → 2.2.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/dist/actions/button/button.d.ts +2 -2
- package/dist/actions/icon-button/icon-button.d.ts +1 -1
- package/dist/components/animated-number-machine.d.ts +95 -0
- package/dist/components/file-icon-machine.d.ts +40 -0
- package/dist/components/file-icon.d.ts +0 -2
- package/dist/components/file-icons/choose-icon-name.d.ts +2 -0
- package/dist/components/image-flight-machine.d.ts +135 -0
- package/dist/components/image-zoom-machine.d.ts +95 -0
- package/dist/components/image-zoom.d.ts +6 -3
- package/dist/components/list.d.ts +2 -6
- package/dist/components/menu-scroll.d.ts +9 -3
- package/dist/components/popover-machine.d.ts +96 -0
- package/dist/components/popover.d.ts +2 -2
- package/dist/components/resize-handle-machine.d.ts +71 -0
- package/dist/components/resize-handle.d.ts +2 -0
- package/dist/components/scroll-view-machine.d.ts +68 -0
- package/dist/components/scroll-view.d.ts +2 -2
- package/dist/components/spinner.d.ts +11 -3
- package/dist/components/text-field-machine.d.ts +62 -0
- package/dist/components/text-reveal-machine.d.ts +90 -0
- package/dist/components/typewriter-machine.d.ts +62 -0
- package/dist/context/dialog-machine.d.ts +125 -0
- package/dist/context/dialog.d.ts +17 -16
- package/dist/data-display/line-comment/machine.d.ts +157 -0
- package/dist/data-display/project-avatar/animation-machine.d.ts +62 -0
- package/dist/data-display/project-avatar/animation.d.ts +1 -1
- package/dist/feedback/activity-ring/activity-ring.d.ts +2 -1
- package/dist/feedback/toast/machine.d.ts +57 -0
- package/dist/feedback/toast/toast.d.ts +1 -1
- package/dist/forms/checkbox/checkbox.d.ts +6 -1
- package/dist/forms/select/machine.d.ts +45 -0
- package/dist/forms/select/select.d.ts +4 -0
- package/dist/forms/typeahead/machine.d.ts +85 -0
- package/dist/hooks/auto-scroll-machine.d.ts +89 -0
- package/dist/hooks/create-auto-scroll.d.ts +1 -1
- package/dist/hooks/list-machine.d.ts +150 -0
- package/dist/hooks/use-filtered-list.d.ts +21 -35
- package/dist/i18n/en.d.ts +5 -0
- package/dist/icons/catalog.d.ts +8 -0
- package/dist/navigation/menu/machine.d.ts +49 -0
- package/dist/navigation/menu/menu.d.ts +5 -3
- package/dist/navigation/segmented-control/machine.d.ts +46 -0
- package/dist/overlays/mcp-sign-in/machine.d.ts +184 -0
- package/dist/overlays/mcp-sign-in/mcp-sign-in.d.ts +40 -0
- package/dist/overlays/tooltip/machine.d.ts +146 -0
- package/dist/theme/context.d.ts +38 -14
- package/dist/theme/machine.d.ts +174 -0
- package/dist/typography/text-shimmer/machine.d.ts +48 -0
- package/package.json +19 -3
- package/src/actions/button/button.tsx +11 -6
- package/src/actions/icon-button/icon-button.tsx +17 -4
- package/src/components/animated-number-machine.ts +214 -0
- package/src/components/animated-number.tsx +134 -83
- package/src/components/file-icon-machine.ts +78 -0
- package/src/components/file-icon.tsx +96 -579
- package/src/components/file-icons/choose-icon-name.ts +574 -0
- package/src/components/image-flight-machine.ts +247 -0
- package/src/components/image-preview.css +5 -2
- package/src/components/image-preview.tsx +390 -252
- package/src/components/image-zoom-machine.ts +191 -0
- package/src/components/image-zoom.ts +22 -14
- package/src/components/list.tsx +46 -137
- package/src/components/menu-scroll.css +19 -8
- package/src/components/menu-scroll.tsx +111 -34
- package/src/components/popover-machine.ts +198 -0
- package/src/components/popover.tsx +157 -89
- package/src/components/resize-handle-machine.ts +174 -0
- package/src/components/resize-handle.tsx +116 -67
- package/src/components/scroll-view-machine.ts +244 -0
- package/src/components/scroll-view.tsx +163 -116
- package/src/components/spinner.css +18 -5
- package/src/components/spinner.tsx +28 -14
- package/src/components/text-field-machine.ts +102 -0
- package/src/components/text-field.tsx +78 -24
- package/src/components/text-reveal-machine.ts +184 -0
- package/src/components/text-reveal.tsx +96 -93
- package/src/components/typewriter-machine.ts +134 -0
- package/src/components/typewriter.tsx +50 -39
- package/src/context/dialog-machine.ts +280 -0
- package/src/context/dialog.tsx +168 -177
- package/src/data-display/line-comment/line-comment.tsx +157 -178
- package/src/data-display/line-comment/machine.ts +391 -0
- package/src/data-display/project-avatar/animation-machine.ts +182 -0
- package/src/data-display/project-avatar/animation.ts +67 -38
- package/src/feedback/activity-ring/activity-ring.tsx +1 -1
- package/src/feedback/toast/machine.ts +115 -0
- package/src/feedback/toast/toast.tsx +55 -59
- package/src/forms/checkbox/checkbox-compact.css +169 -0
- package/src/forms/checkbox/checkbox.tsx +93 -31
- package/src/forms/search-list/search-list.css +5 -1
- package/src/forms/search-list/search-list.tsx +4 -4
- package/src/forms/select/machine.ts +81 -0
- package/src/forms/select/select.css +59 -17
- package/src/forms/select/select.tsx +67 -31
- package/src/forms/typeahead/machine.ts +253 -0
- package/src/forms/typeahead/typeahead.tsx +70 -62
- package/src/hooks/auto-scroll-machine.ts +261 -0
- package/src/hooks/create-auto-scroll.tsx +110 -205
- package/src/hooks/list-machine.ts +359 -0
- package/src/hooks/use-filtered-list.tsx +101 -112
- package/src/i18n/en.ts +6 -1
- package/src/icons/catalog.ts +8 -0
- package/src/navigation/menu/machine.ts +109 -0
- package/src/navigation/menu/menu.tsx +130 -22
- package/src/navigation/segmented-control/machine.ts +72 -0
- package/src/navigation/segmented-control/segmented-control.tsx +46 -46
- package/src/overlays/dialog/dialog.tsx +7 -1
- package/src/overlays/mcp-sign-in/machine.ts +343 -0
- package/src/overlays/mcp-sign-in/mcp-sign-in.ts +159 -0
- package/src/overlays/tooltip/machine.ts +303 -0
- package/src/overlays/tooltip/tooltip.tsx +157 -92
- package/src/styles/theme.css +10 -2
- package/src/theme/context.tsx +192 -269
- package/src/theme/machine.ts +508 -0
- package/src/typography/text-shimmer/machine.ts +90 -0
- package/src/typography/text-shimmer/text-shimmer.css +71 -39
- package/src/typography/text-shimmer/text-shimmer.tsx +41 -24
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import type { Component, JSX } from "solid-js"
|
|
2
|
-
import { createEffect, createMemo, createUniqueId, splitProps, Show } from "solid-js"
|
|
1
|
+
import type { Accessor, Component, JSX, Setter } from "solid-js"
|
|
2
|
+
import { createEffect, createMemo, createSignal, createUniqueId, splitProps, Show, untrack } from "solid-js"
|
|
3
|
+
import {
|
|
4
|
+
chooseFallbackIconName,
|
|
5
|
+
FILE_ICON_LOAD_TIMEOUT_MS,
|
|
6
|
+
FILE_ICON_REQUESTED,
|
|
7
|
+
INITIAL_FILE_ICON_SYMBOL_STATE,
|
|
8
|
+
READY_FILE_ICON_SYMBOL_STATE,
|
|
9
|
+
selectFileIconSymbol,
|
|
10
|
+
transitionFileIconSymbol,
|
|
11
|
+
type FileIconSymbolEffect,
|
|
12
|
+
type FileIconSymbolEvent,
|
|
13
|
+
type FileIconSymbolState,
|
|
14
|
+
} from "./file-icon-machine"
|
|
15
|
+
import { chooseIconName } from "./file-icons/choose-icon-name"
|
|
3
16
|
import type { IconName } from "./file-icons/types"
|
|
4
17
|
|
|
5
18
|
export type FileIconProps = JSX.GSVGAttributes<SVGSVGElement> & {
|
|
@@ -11,8 +24,13 @@ export type FileIconProps = JSX.GSVGAttributes<SVGSVGElement> & {
|
|
|
11
24
|
export const FileIcon: Component<FileIconProps> = (props) => {
|
|
12
25
|
const [local, rest] = splitProps(props, ["node", "class", "classList", "expanded", "mono"])
|
|
13
26
|
const name = createMemo(() => chooseIconName(local.node.path, local.node.type, local.expanded || false))
|
|
27
|
+
const fallback = createMemo(() => chooseFallbackIconName(local.node.type, local.expanded || false))
|
|
28
|
+
const shown = createMemo(() => selectFileIconSymbol(symbol(name()).state(), name(), fallback()))
|
|
14
29
|
const id = `file-icon-mono-${createUniqueId()}`
|
|
15
|
-
createEffect(() =>
|
|
30
|
+
createEffect(() => {
|
|
31
|
+
sprite()
|
|
32
|
+
dispatchSymbol(name(), FILE_ICON_REQUESTED)
|
|
33
|
+
})
|
|
16
34
|
|
|
17
35
|
return (
|
|
18
36
|
<svg
|
|
@@ -23,10 +41,10 @@ export const FileIcon: Component<FileIconProps> = (props) => {
|
|
|
23
41
|
[local.class ?? ""]: !!local.class,
|
|
24
42
|
}}
|
|
25
43
|
>
|
|
26
|
-
<Show when={local.mono} fallback={<use href={`#${symbolID(
|
|
44
|
+
<Show when={local.mono} fallback={<use href={`#${symbolID(shown())}`} />}>
|
|
27
45
|
<defs>
|
|
28
46
|
<mask id={id} mask-type="alpha">
|
|
29
|
-
<use href={`#${symbolID(
|
|
47
|
+
<use href={`#${symbolID(shown())}`} />
|
|
30
48
|
</mask>
|
|
31
49
|
</defs>
|
|
32
50
|
<rect width="100%" height="100%" fill="currentColor" mask={`url(#${id})`} />
|
|
@@ -39,23 +57,73 @@ export const FileIcon: Component<FileIconProps> = (props) => {
|
|
|
39
57
|
// sprite cost several MB per copy. Each icon is instead a lazy chunk, copied once into a hidden in-document sprite.
|
|
40
58
|
const spriteID = "file-icon-sprite"
|
|
41
59
|
|
|
42
|
-
const symbolID = (name:
|
|
60
|
+
const symbolID = (name: string) => `file-icon-${name}`
|
|
43
61
|
|
|
44
|
-
const
|
|
62
|
+
const FALLBACK_ICONS = new Set<IconName>(["Document", "Folder", "FolderOpen"])
|
|
63
|
+
|
|
64
|
+
type SymbolEntry = {
|
|
65
|
+
state: Accessor<FileIconSymbolState>
|
|
66
|
+
setState: Setter<FileIconSymbolState>
|
|
67
|
+
timer?: ReturnType<typeof setTimeout>
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const symbols = new Map<IconName, SymbolEntry>()
|
|
45
71
|
|
|
46
72
|
let sources: Partial<Record<IconName, () => Promise<string>>> | undefined
|
|
47
73
|
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
74
|
+
function symbol(name: IconName) {
|
|
75
|
+
const existing = symbols.get(name)
|
|
76
|
+
|
|
77
|
+
if (existing) return existing
|
|
78
|
+
|
|
79
|
+
const [state, setState] = createSignal(
|
|
80
|
+
FALLBACK_ICONS.has(name) ? READY_FILE_ICON_SYMBOL_STATE : INITIAL_FILE_ICON_SYMBOL_STATE,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
const entry: SymbolEntry = { state, setState }
|
|
84
|
+
symbols.set(name, entry)
|
|
85
|
+
|
|
86
|
+
return entry
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function dispatchSymbol(name: IconName, event: FileIconSymbolEvent) {
|
|
90
|
+
const entry = symbol(name)
|
|
91
|
+
const prev = untrack(entry.state)
|
|
92
|
+
const next = transitionFileIconSymbol(prev, event)
|
|
93
|
+
|
|
94
|
+
if (next.state !== prev) entry.setState(next.state)
|
|
95
|
+
// A `<use>` follows its target once the symbol appears, so mounted icons may switch before the insert.
|
|
96
|
+
next.effects.forEach((effect) => runSymbolEffect(name, entry, effect))
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function runSymbolEffect(name: IconName, entry: SymbolEntry, effect: FileIconSymbolEffect) {
|
|
100
|
+
if (effect.type === "insert-symbol") return insertSymbol(name, effect.svg)
|
|
101
|
+
|
|
102
|
+
if (effect.type === "cancel-timeout") return clearTimeout(entry.timer)
|
|
103
|
+
|
|
104
|
+
// The fallbacks are bundled, so they never load lazily.
|
|
51
105
|
sources ??= Object.fromEntries(
|
|
52
106
|
Object.entries(
|
|
53
|
-
import.meta.glob<string>(
|
|
107
|
+
import.meta.glob<string>(
|
|
108
|
+
[
|
|
109
|
+
"../assets/icons/file-types/*.svg",
|
|
110
|
+
"!../assets/icons/file-types/document.svg",
|
|
111
|
+
"!../assets/icons/file-types/folder.svg",
|
|
112
|
+
"!../assets/icons/file-types/folder-open.svg",
|
|
113
|
+
],
|
|
114
|
+
{ query: "?raw", import: "default" },
|
|
115
|
+
),
|
|
54
116
|
).map(([path, load]) => [toIconName(path), load]),
|
|
55
117
|
)
|
|
56
|
-
sources[name]
|
|
57
|
-
|
|
58
|
-
|
|
118
|
+
const load = sources[name]
|
|
119
|
+
|
|
120
|
+
if (!load) return dispatchSymbol(name, { type: "load.failed" })
|
|
121
|
+
// A dynamic import has no timeout of its own and can stall on a slow or dropped connection.
|
|
122
|
+
entry.timer = setTimeout(() => dispatchSymbol(name, { type: "load.timed-out" }), FILE_ICON_LOAD_TIMEOUT_MS)
|
|
123
|
+
load().then(
|
|
124
|
+
(svg) => dispatchSymbol(name, { type: "load.succeeded", svg }),
|
|
125
|
+
() => dispatchSymbol(name, { type: "load.failed" }),
|
|
126
|
+
)
|
|
59
127
|
}
|
|
60
128
|
|
|
61
129
|
// Mirrors the file name to icon name rule of the spritesheet generator that writes `file-icons/types.ts`.
|
|
@@ -67,8 +135,9 @@ function toIconName(path: string) {
|
|
|
67
135
|
.join("")
|
|
68
136
|
}
|
|
69
137
|
|
|
70
|
-
function insertSymbol(name:
|
|
138
|
+
function insertSymbol(name: string, text: string) {
|
|
71
139
|
const id = symbolID(name)
|
|
140
|
+
|
|
72
141
|
// Icons share the document now, so scope their internal ids (gradients, clip paths) and drop their unstyled
|
|
73
142
|
// classes, which app CSS such as Tailwind utilities would otherwise match.
|
|
74
143
|
const scoped = text
|
|
@@ -76,6 +145,7 @@ function insertSymbol(name: IconName, text: string) {
|
|
|
76
145
|
.replace(/\sid="([^"]*)"/g, ` id="${id}-$1"`)
|
|
77
146
|
.replace(/url\(#([^)]*)\)/g, `url(#${id}-$1)`)
|
|
78
147
|
.replace(/href="#([^"]*)"/g, `href="#${id}-$1"`)
|
|
148
|
+
|
|
79
149
|
const svg = new DOMParser().parseFromString(scoped, "image/svg+xml").documentElement
|
|
80
150
|
const symbol = document.createElementNS("http://www.w3.org/2000/svg", "symbol")
|
|
81
151
|
Array.from(svg.attributes)
|
|
@@ -100,570 +170,17 @@ function sprite() {
|
|
|
100
170
|
svg.style.position = "absolute"
|
|
101
171
|
svg.style.overflow = "hidden"
|
|
102
172
|
document.body.insertBefore(svg, document.body.firstChild)
|
|
173
|
+
// The fallbacks ship with the component, so an icon whose own symbol fails to load always has one to show.
|
|
174
|
+
Object.entries(
|
|
175
|
+
import.meta.glob<string>(
|
|
176
|
+
[
|
|
177
|
+
"../assets/icons/file-types/document.svg",
|
|
178
|
+
"../assets/icons/file-types/folder.svg",
|
|
179
|
+
"../assets/icons/file-types/folder-open.svg",
|
|
180
|
+
],
|
|
181
|
+
{ query: "?raw", import: "default", eager: true },
|
|
182
|
+
),
|
|
183
|
+
).forEach(([path, text]) => insertSymbol(toIconName(path), text))
|
|
103
184
|
|
|
104
185
|
return svg
|
|
105
186
|
}
|
|
106
|
-
|
|
107
|
-
type IconMaps = {
|
|
108
|
-
fileNames: Record<string, IconName>
|
|
109
|
-
fileExtensions: Record<string, IconName>
|
|
110
|
-
folderNames: Record<string, IconName>
|
|
111
|
-
defaults: {
|
|
112
|
-
file: IconName
|
|
113
|
-
folder: IconName
|
|
114
|
-
folderOpen: IconName
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const ICON_MAPS: IconMaps = {
|
|
119
|
-
fileNames: {
|
|
120
|
-
// Documentation files
|
|
121
|
-
"readme.md": "Readme",
|
|
122
|
-
"changelog.md": "Changelog",
|
|
123
|
-
"contributing.md": "Contributing",
|
|
124
|
-
"conduct.md": "Conduct",
|
|
125
|
-
license: "Certificate",
|
|
126
|
-
authors: "Authors",
|
|
127
|
-
credits: "Credits",
|
|
128
|
-
install: "Installation",
|
|
129
|
-
|
|
130
|
-
// Node.js files
|
|
131
|
-
"package.json": "Nodejs",
|
|
132
|
-
"package-lock.json": "Nodejs",
|
|
133
|
-
"yarn.lock": "Yarn",
|
|
134
|
-
"pnpm-lock.yaml": "Pnpm",
|
|
135
|
-
"bun.lock": "Bun",
|
|
136
|
-
"bun.lockb": "Bun",
|
|
137
|
-
"bunfig.toml": "Bun",
|
|
138
|
-
".nvmrc": "Nodejs",
|
|
139
|
-
".node-version": "Nodejs",
|
|
140
|
-
|
|
141
|
-
// Docker files
|
|
142
|
-
dockerfile: "Docker",
|
|
143
|
-
"docker-compose.yml": "Docker",
|
|
144
|
-
"docker-compose.yaml": "Docker",
|
|
145
|
-
".dockerignore": "Docker",
|
|
146
|
-
|
|
147
|
-
// Config files
|
|
148
|
-
"jest.config.js": "Jest",
|
|
149
|
-
"jest.config.ts": "Jest",
|
|
150
|
-
"jest.config.mjs": "Jest",
|
|
151
|
-
"vitest.config.js": "Vitest",
|
|
152
|
-
"vitest.config.ts": "Vitest",
|
|
153
|
-
"tailwind.config.js": "Tailwindcss",
|
|
154
|
-
"tailwind.config.ts": "Tailwindcss",
|
|
155
|
-
"turbo.json": "Turborepo",
|
|
156
|
-
"tsconfig.json": "Tsconfig",
|
|
157
|
-
"jsconfig.json": "Jsconfig",
|
|
158
|
-
".eslintrc": "Eslint",
|
|
159
|
-
".eslintrc.js": "Eslint",
|
|
160
|
-
".eslintrc.json": "Eslint",
|
|
161
|
-
".prettierrc": "Prettier",
|
|
162
|
-
".prettierrc.js": "Prettier",
|
|
163
|
-
".prettierrc.json": "Prettier",
|
|
164
|
-
"vite.config.js": "Vite",
|
|
165
|
-
"vite.config.ts": "Vite",
|
|
166
|
-
"webpack.config.js": "Webpack",
|
|
167
|
-
"rollup.config.js": "Rollup",
|
|
168
|
-
"astro.config.mjs": "AstroConfig",
|
|
169
|
-
"astro.config.js": "AstroConfig",
|
|
170
|
-
"next.config.js": "Next",
|
|
171
|
-
"next.config.mjs": "Next",
|
|
172
|
-
"nuxt.config.js": "Nuxt",
|
|
173
|
-
"nuxt.config.ts": "Nuxt",
|
|
174
|
-
"svelte.config.js": "Svelte",
|
|
175
|
-
"gatsby-config.js": "Gatsby",
|
|
176
|
-
"remix.config.js": "Remix",
|
|
177
|
-
"prisma.schema": "Prisma",
|
|
178
|
-
".gitignore": "Git",
|
|
179
|
-
".gitattributes": "Git",
|
|
180
|
-
makefile: "Makefile",
|
|
181
|
-
cmake: "Cmake",
|
|
182
|
-
"cargo.toml": "Rust",
|
|
183
|
-
"go.mod": "GoMod",
|
|
184
|
-
"go.sum": "GoMod",
|
|
185
|
-
"requirements.txt": "Python",
|
|
186
|
-
"pyproject.toml": "Python",
|
|
187
|
-
pipfile: "Python",
|
|
188
|
-
"poetry.lock": "Poetry",
|
|
189
|
-
gemfile: "Gemfile",
|
|
190
|
-
rakefile: "Ruby",
|
|
191
|
-
"composer.json": "Php",
|
|
192
|
-
"build.gradle": "Gradle",
|
|
193
|
-
"pom.xml": "Maven",
|
|
194
|
-
"deno.json": "Deno",
|
|
195
|
-
"deno.jsonc": "Deno",
|
|
196
|
-
"vercel.json": "Vercel",
|
|
197
|
-
"netlify.toml": "Netlify",
|
|
198
|
-
".env": "Tune",
|
|
199
|
-
".env.local": "Tune",
|
|
200
|
-
".env.development": "Tune",
|
|
201
|
-
".env.production": "Tune",
|
|
202
|
-
".env.example": "Tune",
|
|
203
|
-
".editorconfig": "Editorconfig",
|
|
204
|
-
"robots.txt": "Robots",
|
|
205
|
-
"favicon.ico": "Favicon",
|
|
206
|
-
browserlist: "Browserlist",
|
|
207
|
-
".babelrc": "Babel",
|
|
208
|
-
"babel.config.js": "Babel",
|
|
209
|
-
"gulpfile.js": "Gulp",
|
|
210
|
-
"gruntfile.js": "Grunt",
|
|
211
|
-
"capacitor.config.json": "Capacitor",
|
|
212
|
-
"ionic.config.json": "Ionic",
|
|
213
|
-
"angular.json": "Angular",
|
|
214
|
-
".storybook": "Storybook",
|
|
215
|
-
"storybook.config.js": "Storybook",
|
|
216
|
-
"cypress.config.js": "Cypress",
|
|
217
|
-
"playwright.config.js": "Playwright",
|
|
218
|
-
"puppeteer.config.js": "Puppeteer",
|
|
219
|
-
"wrangler.toml": "Wrangler",
|
|
220
|
-
"firebase.json": "Firebase",
|
|
221
|
-
supabase: "Supabase",
|
|
222
|
-
terraform: "Terraform",
|
|
223
|
-
kubernetes: "Kubernetes",
|
|
224
|
-
".gitpod.yml": "Gitpod",
|
|
225
|
-
".devcontainer": "Vscode",
|
|
226
|
-
"travis.yml": "Travis",
|
|
227
|
-
"appveyor.yml": "Appveyor",
|
|
228
|
-
".circleci": "Circleci",
|
|
229
|
-
"renovate.json": "Renovate",
|
|
230
|
-
"dependabot.yml": "Dependabot",
|
|
231
|
-
"lerna.json": "Lerna",
|
|
232
|
-
"nx.json": "Nx",
|
|
233
|
-
},
|
|
234
|
-
fileExtensions: {
|
|
235
|
-
// Test files
|
|
236
|
-
"spec.ts": "TestTs",
|
|
237
|
-
"test.ts": "TestTs",
|
|
238
|
-
"spec.tsx": "TestJsx",
|
|
239
|
-
"test.tsx": "TestJsx",
|
|
240
|
-
"spec.js": "TestJs",
|
|
241
|
-
"test.js": "TestJs",
|
|
242
|
-
"spec.jsx": "TestJsx",
|
|
243
|
-
"test.jsx": "TestJsx",
|
|
244
|
-
|
|
245
|
-
// JavaScript/TypeScript
|
|
246
|
-
"js.map": "JavascriptMap",
|
|
247
|
-
"d.ts": "TypescriptDef",
|
|
248
|
-
ts: "Typescript",
|
|
249
|
-
tsx: "React_ts",
|
|
250
|
-
js: "Javascript",
|
|
251
|
-
jsx: "React",
|
|
252
|
-
mjs: "Javascript",
|
|
253
|
-
cjs: "Javascript",
|
|
254
|
-
|
|
255
|
-
// Web languages
|
|
256
|
-
html: "Html",
|
|
257
|
-
htm: "Html",
|
|
258
|
-
css: "Css",
|
|
259
|
-
scss: "Sass",
|
|
260
|
-
sass: "Sass",
|
|
261
|
-
less: "Less",
|
|
262
|
-
styl: "Stylus",
|
|
263
|
-
|
|
264
|
-
// Data formats
|
|
265
|
-
json: "Json",
|
|
266
|
-
xml: "Xml",
|
|
267
|
-
yml: "Yaml",
|
|
268
|
-
yaml: "Yaml",
|
|
269
|
-
toml: "Toml",
|
|
270
|
-
hjson: "Hjson",
|
|
271
|
-
|
|
272
|
-
// Documentation
|
|
273
|
-
md: "Markdown",
|
|
274
|
-
mdx: "Mdx",
|
|
275
|
-
tex: "Tex",
|
|
276
|
-
|
|
277
|
-
// Programming languages
|
|
278
|
-
py: "Python",
|
|
279
|
-
pyx: "Python",
|
|
280
|
-
pyw: "Python",
|
|
281
|
-
rs: "Rust",
|
|
282
|
-
go: "Go",
|
|
283
|
-
java: "Java",
|
|
284
|
-
kt: "Kotlin",
|
|
285
|
-
scala: "Scala",
|
|
286
|
-
php: "Php",
|
|
287
|
-
rb: "Ruby",
|
|
288
|
-
cs: "Csharp",
|
|
289
|
-
vb: "Visualstudio",
|
|
290
|
-
cpp: "Cpp",
|
|
291
|
-
cc: "Cpp",
|
|
292
|
-
cxx: "Cpp",
|
|
293
|
-
c: "C",
|
|
294
|
-
h: "H",
|
|
295
|
-
hpp: "Hpp",
|
|
296
|
-
swift: "Swift",
|
|
297
|
-
m: "ObjectiveC",
|
|
298
|
-
mm: "ObjectiveCpp",
|
|
299
|
-
dart: "Dart",
|
|
300
|
-
lua: "Lua",
|
|
301
|
-
pl: "Perl",
|
|
302
|
-
r: "R",
|
|
303
|
-
jl: "Julia",
|
|
304
|
-
hs: "Haskell",
|
|
305
|
-
elm: "Elm",
|
|
306
|
-
ml: "Ocaml",
|
|
307
|
-
clj: "Clojure",
|
|
308
|
-
cljs: "Clojure",
|
|
309
|
-
erl: "Erlang",
|
|
310
|
-
ex: "Elixir",
|
|
311
|
-
exs: "Elixir",
|
|
312
|
-
nim: "Nim",
|
|
313
|
-
zig: "Zig",
|
|
314
|
-
v: "Vlang",
|
|
315
|
-
odin: "Odin",
|
|
316
|
-
gleam: "Gleam",
|
|
317
|
-
grain: "Grain",
|
|
318
|
-
roc: "Rocket",
|
|
319
|
-
fs: "Fsharp",
|
|
320
|
-
|
|
321
|
-
// Shell scripts
|
|
322
|
-
sh: "Console",
|
|
323
|
-
bash: "Console",
|
|
324
|
-
zsh: "Console",
|
|
325
|
-
fish: "Console",
|
|
326
|
-
ps1: "Powershell",
|
|
327
|
-
|
|
328
|
-
// Config/build files
|
|
329
|
-
cfg: "Settings",
|
|
330
|
-
ini: "Settings",
|
|
331
|
-
conf: "Settings",
|
|
332
|
-
properties: "Settings",
|
|
333
|
-
|
|
334
|
-
// Media files
|
|
335
|
-
svg: "Svg",
|
|
336
|
-
png: "Image",
|
|
337
|
-
jpg: "Image",
|
|
338
|
-
jpeg: "Image",
|
|
339
|
-
gif: "Image",
|
|
340
|
-
webp: "Image",
|
|
341
|
-
bmp: "Image",
|
|
342
|
-
ico: "Favicon",
|
|
343
|
-
mp4: "Video",
|
|
344
|
-
mov: "Video",
|
|
345
|
-
avi: "Video",
|
|
346
|
-
webm: "Video",
|
|
347
|
-
mp3: "Audio",
|
|
348
|
-
wav: "Audio",
|
|
349
|
-
flac: "Audio",
|
|
350
|
-
|
|
351
|
-
// Archive files
|
|
352
|
-
zip: "Zip",
|
|
353
|
-
tar: "Zip",
|
|
354
|
-
gz: "Zip",
|
|
355
|
-
rar: "Zip",
|
|
356
|
-
"7z": "Zip",
|
|
357
|
-
|
|
358
|
-
// Document files
|
|
359
|
-
pdf: "Pdf",
|
|
360
|
-
doc: "Word",
|
|
361
|
-
docx: "Word",
|
|
362
|
-
ppt: "Powerpoint",
|
|
363
|
-
pptx: "Powerpoint",
|
|
364
|
-
xls: "Document",
|
|
365
|
-
xlsx: "Document",
|
|
366
|
-
|
|
367
|
-
// Database files
|
|
368
|
-
sql: "Database",
|
|
369
|
-
db: "Database",
|
|
370
|
-
sqlite: "Database",
|
|
371
|
-
|
|
372
|
-
// Other
|
|
373
|
-
env: "Tune",
|
|
374
|
-
log: "Log",
|
|
375
|
-
lock: "Lock",
|
|
376
|
-
key: "Key",
|
|
377
|
-
pem: "Certificate",
|
|
378
|
-
crt: "Certificate",
|
|
379
|
-
proto: "Proto",
|
|
380
|
-
graphql: "Graphql",
|
|
381
|
-
gql: "Graphql",
|
|
382
|
-
wasm: "Webassembly",
|
|
383
|
-
dockerfile: "Docker",
|
|
384
|
-
},
|
|
385
|
-
folderNames: {
|
|
386
|
-
// Source code
|
|
387
|
-
src: "FolderSrc",
|
|
388
|
-
source: "FolderSrc",
|
|
389
|
-
lib: "FolderLib",
|
|
390
|
-
libs: "FolderLib",
|
|
391
|
-
|
|
392
|
-
// Testing
|
|
393
|
-
test: "FolderTest",
|
|
394
|
-
tests: "FolderTest",
|
|
395
|
-
testing: "FolderTest",
|
|
396
|
-
spec: "FolderTest",
|
|
397
|
-
specs: "FolderTest",
|
|
398
|
-
__tests__: "FolderTest",
|
|
399
|
-
e2e: "FolderTest",
|
|
400
|
-
integration: "FolderTest",
|
|
401
|
-
unit: "FolderTest",
|
|
402
|
-
cypress: "FolderCypress",
|
|
403
|
-
|
|
404
|
-
// Dependencies
|
|
405
|
-
node_modules: "FolderNode",
|
|
406
|
-
vendor: "FolderPackages",
|
|
407
|
-
packages: "FolderPackages",
|
|
408
|
-
deps: "FolderPackages",
|
|
409
|
-
|
|
410
|
-
// Build/dist
|
|
411
|
-
build: "FolderBuildkite",
|
|
412
|
-
dist: "FolderDist",
|
|
413
|
-
out: "FolderDist",
|
|
414
|
-
output: "FolderDist",
|
|
415
|
-
target: "FolderTarget",
|
|
416
|
-
|
|
417
|
-
// Configuration
|
|
418
|
-
config: "FolderConfig",
|
|
419
|
-
configs: "FolderConfig",
|
|
420
|
-
configuration: "FolderConfig",
|
|
421
|
-
settings: "FolderConfig",
|
|
422
|
-
env: "FolderEnvironment",
|
|
423
|
-
environments: "FolderEnvironment",
|
|
424
|
-
|
|
425
|
-
// Docker
|
|
426
|
-
docker: "FolderDocker",
|
|
427
|
-
dockerfiles: "FolderDocker",
|
|
428
|
-
containers: "FolderDocker",
|
|
429
|
-
|
|
430
|
-
// Documentation
|
|
431
|
-
docs: "FolderDocs",
|
|
432
|
-
doc: "FolderDocs",
|
|
433
|
-
documentation: "FolderDocs",
|
|
434
|
-
readme: "FolderDocs",
|
|
435
|
-
|
|
436
|
-
// Public/assets
|
|
437
|
-
public: "FolderPublic",
|
|
438
|
-
static: "FolderPublic",
|
|
439
|
-
assets: "FolderImages",
|
|
440
|
-
images: "FolderImages",
|
|
441
|
-
img: "FolderImages",
|
|
442
|
-
icons: "FolderImages",
|
|
443
|
-
media: "FolderImages",
|
|
444
|
-
fonts: "FolderFont",
|
|
445
|
-
styles: "FolderCss",
|
|
446
|
-
stylesheets: "FolderCss",
|
|
447
|
-
css: "FolderCss",
|
|
448
|
-
sass: "FolderSass",
|
|
449
|
-
scss: "FolderSass",
|
|
450
|
-
less: "FolderLess",
|
|
451
|
-
|
|
452
|
-
// Scripts
|
|
453
|
-
scripts: "FolderScripts",
|
|
454
|
-
script: "FolderScripts",
|
|
455
|
-
tools: "FolderTools",
|
|
456
|
-
utils: "FolderUtils",
|
|
457
|
-
utilities: "FolderUtils",
|
|
458
|
-
helpers: "FolderHelper",
|
|
459
|
-
|
|
460
|
-
// Framework specific
|
|
461
|
-
components: "FolderComponents",
|
|
462
|
-
component: "FolderComponents",
|
|
463
|
-
views: "FolderViews",
|
|
464
|
-
view: "FolderViews",
|
|
465
|
-
layouts: "FolderLayout",
|
|
466
|
-
layout: "FolderLayout",
|
|
467
|
-
templates: "FolderTemplate",
|
|
468
|
-
template: "FolderTemplate",
|
|
469
|
-
hooks: "FolderHook",
|
|
470
|
-
hook: "FolderHook",
|
|
471
|
-
store: "FolderStore",
|
|
472
|
-
stores: "FolderStore",
|
|
473
|
-
state: "FolderNgrxStore",
|
|
474
|
-
reducers: "FolderReduxReducer",
|
|
475
|
-
reducer: "FolderReduxReducer",
|
|
476
|
-
services: "FolderApi",
|
|
477
|
-
service: "FolderApi",
|
|
478
|
-
api: "FolderApi",
|
|
479
|
-
apis: "FolderApi",
|
|
480
|
-
routes: "FolderRoutes",
|
|
481
|
-
route: "FolderRoutes",
|
|
482
|
-
routing: "FolderRoutes",
|
|
483
|
-
middleware: "FolderMiddleware",
|
|
484
|
-
middlewares: "FolderMiddleware",
|
|
485
|
-
controllers: "FolderController",
|
|
486
|
-
controller: "FolderController",
|
|
487
|
-
models: "FolderDatabase",
|
|
488
|
-
model: "FolderDatabase",
|
|
489
|
-
schemas: "FolderDatabase",
|
|
490
|
-
schema: "FolderDatabase",
|
|
491
|
-
migrations: "FolderDatabase",
|
|
492
|
-
migration: "FolderDatabase",
|
|
493
|
-
seeders: "FolderSeeders",
|
|
494
|
-
seeder: "FolderSeeders",
|
|
495
|
-
|
|
496
|
-
// TypeScript
|
|
497
|
-
types: "FolderTypescript",
|
|
498
|
-
typing: "FolderTypescript",
|
|
499
|
-
typings: "FolderTypescript",
|
|
500
|
-
"@types": "FolderTypescript",
|
|
501
|
-
interfaces: "FolderInterface",
|
|
502
|
-
interface: "FolderInterface",
|
|
503
|
-
|
|
504
|
-
// Mobile
|
|
505
|
-
android: "FolderAndroid",
|
|
506
|
-
ios: "FolderIos",
|
|
507
|
-
mobile: "FolderMobile",
|
|
508
|
-
flutter: "FolderFlutter",
|
|
509
|
-
|
|
510
|
-
// Infrastructure
|
|
511
|
-
kubernetes: "FolderKubernetes",
|
|
512
|
-
k8s: "FolderKubernetes",
|
|
513
|
-
terraform: "FolderTerraform",
|
|
514
|
-
aws: "FolderAws",
|
|
515
|
-
azure: "FolderAzurePipelines",
|
|
516
|
-
firebase: "FolderFirebase",
|
|
517
|
-
supabase: "FolderSupabase",
|
|
518
|
-
vercel: "FolderVercel",
|
|
519
|
-
netlify: "FolderNetlify",
|
|
520
|
-
|
|
521
|
-
// CI/CD
|
|
522
|
-
".github": "FolderGithub",
|
|
523
|
-
".gitlab": "FolderGitlab",
|
|
524
|
-
".circleci": "FolderCircleci",
|
|
525
|
-
ci: "FolderCi",
|
|
526
|
-
".ci": "FolderCi",
|
|
527
|
-
workflows: "FolderGhWorkflows",
|
|
528
|
-
|
|
529
|
-
// Git
|
|
530
|
-
".git": "FolderGit",
|
|
531
|
-
|
|
532
|
-
// Development tools
|
|
533
|
-
".vscode": "FolderVscode",
|
|
534
|
-
".idea": "FolderIntellij",
|
|
535
|
-
".cursor": "FolderCursor",
|
|
536
|
-
".devcontainer": "FolderContainer",
|
|
537
|
-
".storybook": "FolderStorybook",
|
|
538
|
-
|
|
539
|
-
// Localization
|
|
540
|
-
i18n: "FolderI18n",
|
|
541
|
-
locales: "FolderI18n",
|
|
542
|
-
locale: "FolderI18n",
|
|
543
|
-
lang: "FolderI18n",
|
|
544
|
-
languages: "FolderI18n",
|
|
545
|
-
|
|
546
|
-
// Other common patterns
|
|
547
|
-
temp: "FolderTemp",
|
|
548
|
-
tmp: "FolderTemp",
|
|
549
|
-
logs: "FolderLog",
|
|
550
|
-
log: "FolderLog",
|
|
551
|
-
backup: "FolderBackup",
|
|
552
|
-
backups: "FolderBackup",
|
|
553
|
-
examples: "FolderExamples",
|
|
554
|
-
example: "FolderExamples",
|
|
555
|
-
demo: "FolderExamples",
|
|
556
|
-
demos: "FolderExamples",
|
|
557
|
-
samples: "FolderExamples",
|
|
558
|
-
sample: "FolderExamples",
|
|
559
|
-
fixtures: "FolderTest",
|
|
560
|
-
mocks: "FolderMock",
|
|
561
|
-
mock: "FolderMock",
|
|
562
|
-
data: "FolderDatabase",
|
|
563
|
-
database: "FolderDatabase",
|
|
564
|
-
db: "FolderDatabase",
|
|
565
|
-
sql: "FolderDatabase",
|
|
566
|
-
prisma: "FolderPrisma",
|
|
567
|
-
drizzle: "FolderDrizzle",
|
|
568
|
-
|
|
569
|
-
// Security
|
|
570
|
-
security: "FolderSecure",
|
|
571
|
-
auth: "FolderSecure",
|
|
572
|
-
authentication: "FolderSecure",
|
|
573
|
-
authorization: "FolderSecure",
|
|
574
|
-
keys: "FolderKeys",
|
|
575
|
-
certs: "FolderKeys",
|
|
576
|
-
certificates: "FolderKeys",
|
|
577
|
-
|
|
578
|
-
// Content
|
|
579
|
-
content: "FolderContent",
|
|
580
|
-
posts: "FolderContent",
|
|
581
|
-
articles: "FolderContent",
|
|
582
|
-
blog: "FolderContent",
|
|
583
|
-
|
|
584
|
-
// Functions
|
|
585
|
-
functions: "FolderFunctions",
|
|
586
|
-
function: "FolderFunctions",
|
|
587
|
-
lambda: "FolderFunctions",
|
|
588
|
-
lambdas: "FolderFunctions",
|
|
589
|
-
serverless: "FolderServerless",
|
|
590
|
-
|
|
591
|
-
// Jobs/tasks
|
|
592
|
-
jobs: "FolderJob",
|
|
593
|
-
job: "FolderJob",
|
|
594
|
-
tasks: "FolderTasks",
|
|
595
|
-
task: "FolderTasks",
|
|
596
|
-
cron: "FolderTasks",
|
|
597
|
-
queue: "FolderQueue",
|
|
598
|
-
queues: "FolderQueue",
|
|
599
|
-
|
|
600
|
-
// Desktop platforms
|
|
601
|
-
desktop: "FolderDesktop",
|
|
602
|
-
windows: "FolderWindows",
|
|
603
|
-
macos: "FolderMacos",
|
|
604
|
-
linux: "FolderLinux",
|
|
605
|
-
},
|
|
606
|
-
defaults: {
|
|
607
|
-
file: "Document",
|
|
608
|
-
folder: "Folder",
|
|
609
|
-
folderOpen: "FolderOpen",
|
|
610
|
-
},
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
const toOpenVariant = (icon: IconName): IconName => {
|
|
614
|
-
if (!icon.startsWith("Folder")) return icon
|
|
615
|
-
|
|
616
|
-
if (icon.endsWith("_light")) return icon.replace("_light", "Open_light") as IconName
|
|
617
|
-
|
|
618
|
-
if (!icon.endsWith("Open")) return (icon + "Open") as IconName
|
|
619
|
-
|
|
620
|
-
return icon
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
const basenameOf = (p: string) => p.split("\\").join("/").split("/").filter(Boolean).pop() ?? ""
|
|
624
|
-
|
|
625
|
-
const folderNameVariants = (name: string) => {
|
|
626
|
-
const n = name.toLowerCase()
|
|
627
|
-
|
|
628
|
-
return [n, `.${n}`, `_${n}`, `__${n}__`]
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
const dottedSuffixesDesc = (name: string) => {
|
|
632
|
-
const n = name.toLowerCase()
|
|
633
|
-
const idxs: number[] = []
|
|
634
|
-
|
|
635
|
-
for (let i = 0; i < n.length; i++) if (n[i] === ".") idxs.push(i)
|
|
636
|
-
const out = new Set<string>()
|
|
637
|
-
out.add(n) // allow exact whole-name "extensions" like "dockerfile"
|
|
638
|
-
|
|
639
|
-
for (const i of idxs) if (i + 1 < n.length) out.add(n.slice(i + 1))
|
|
640
|
-
|
|
641
|
-
return Array.from(out).sort((a, b) => b.length - a.length) // longest first
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
export function chooseIconName(path: string, type: "directory" | "file", expanded: boolean): IconName {
|
|
645
|
-
const base = basenameOf(path)
|
|
646
|
-
const baseLower = base.toLowerCase()
|
|
647
|
-
|
|
648
|
-
if (type === "directory") {
|
|
649
|
-
for (const cand of folderNameVariants(baseLower)) {
|
|
650
|
-
const icon = ICON_MAPS.folderNames[cand]
|
|
651
|
-
|
|
652
|
-
if (icon) return expanded ? toOpenVariant(icon) : icon
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
return expanded ? ICON_MAPS.defaults.folderOpen : ICON_MAPS.defaults.folder
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
const byName = ICON_MAPS.fileNames[baseLower]
|
|
659
|
-
|
|
660
|
-
if (byName) return byName
|
|
661
|
-
|
|
662
|
-
for (const ext of dottedSuffixesDesc(baseLower)) {
|
|
663
|
-
const icon = ICON_MAPS.fileExtensions[ext]
|
|
664
|
-
|
|
665
|
-
if (icon) return icon
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
return ICON_MAPS.defaults.file
|
|
669
|
-
}
|