@opencode/ui 0.0.0-dev-837 → 0.0.0-dev-845

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.
@@ -1,5 +1,4 @@
1
1
  import type { Component, JSX } from "solid-js";
2
- import type { IconName } from "./file-icons/types";
3
2
  export type FileIconProps = JSX.GSVGAttributes<SVGSVGElement> & {
4
3
  node: {
5
4
  path: string;
@@ -9,4 +8,3 @@ export type FileIconProps = JSX.GSVGAttributes<SVGSVGElement> & {
9
8
  mono?: boolean;
10
9
  };
11
10
  export declare const FileIcon: Component<FileIconProps>;
12
- export declare function chooseIconName(path: string, type: "directory" | "file", expanded: boolean): IconName;
@@ -0,0 +1,2 @@
1
+ import type { IconName } from "./types";
2
+ export declare function chooseIconName(path: string, type: "directory" | "file", expanded: boolean): IconName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencode/ui",
3
- "version": "0.0.0-dev-837",
3
+ "version": "0.0.0-dev-845",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -267,6 +267,10 @@
267
267
  "import": "./src/components/file-icons/types.ts",
268
268
  "types": "./dist/components/file-icons/types.d.ts"
269
269
  },
270
+ "./icons/file-type-name": {
271
+ "import": "./src/components/file-icons/choose-icon-name.ts",
272
+ "types": "./dist/components/file-icons/choose-icon-name.d.ts"
273
+ },
270
274
  "./icons/app": {
271
275
  "import": "./src/components/app-icons/types.ts",
272
276
  "types": "./dist/components/app-icons/types.d.ts"
@@ -300,7 +304,7 @@
300
304
  "dependencies": {
301
305
  "@kitlangton/solid-motion": "0.2.2",
302
306
  "@kobalte/core": "0.13.13",
303
- "@opencode/util": "0.0.0-dev-837",
307
+ "@opencode/util": "0.0.0-dev-845",
304
308
  "@pierre/diffs": "1.6.1",
305
309
  "@pierre/highlights": "0.2.0",
306
310
  "@solid-primitives/event-listener": "2.4.6",
@@ -12,6 +12,7 @@ import {
12
12
  type FileIconSymbolEvent,
13
13
  type FileIconSymbolState,
14
14
  } from "./file-icon-machine"
15
+ import { chooseIconName } from "./file-icons/choose-icon-name"
15
16
  import type { IconName } from "./file-icons/types"
16
17
 
17
18
  export type FileIconProps = JSX.GSVGAttributes<SVGSVGElement> & {
@@ -183,573 +184,3 @@ function sprite() {
183
184
 
184
185
  return svg
185
186
  }
186
-
187
- type IconMaps = {
188
- fileNames: Record<string, IconName>
189
- fileExtensions: Record<string, IconName>
190
- folderNames: Record<string, IconName>
191
- defaults: {
192
- file: IconName
193
- folder: IconName
194
- folderOpen: IconName
195
- }
196
- }
197
-
198
- const ICON_MAPS: IconMaps = {
199
- fileNames: {
200
- // Documentation files
201
- "readme.md": "Readme",
202
- "changelog.md": "Changelog",
203
- "contributing.md": "Contributing",
204
- "conduct.md": "Conduct",
205
- license: "Certificate",
206
- authors: "Authors",
207
- credits: "Credits",
208
- install: "Installation",
209
-
210
- // Node.js files
211
- "package.json": "Nodejs",
212
- "package-lock.json": "Nodejs",
213
- "yarn.lock": "Yarn",
214
- "pnpm-lock.yaml": "Pnpm",
215
- "bun.lock": "Bun",
216
- "bun.lockb": "Bun",
217
- "bunfig.toml": "Bun",
218
- ".nvmrc": "Nodejs",
219
- ".node-version": "Nodejs",
220
-
221
- // Docker files
222
- dockerfile: "Docker",
223
- "docker-compose.yml": "Docker",
224
- "docker-compose.yaml": "Docker",
225
- ".dockerignore": "Docker",
226
-
227
- // Config files
228
- "jest.config.js": "Jest",
229
- "jest.config.ts": "Jest",
230
- "jest.config.mjs": "Jest",
231
- "vitest.config.js": "Vitest",
232
- "vitest.config.ts": "Vitest",
233
- "tailwind.config.js": "Tailwindcss",
234
- "tailwind.config.ts": "Tailwindcss",
235
- "turbo.json": "Turborepo",
236
- "tsconfig.json": "Tsconfig",
237
- "jsconfig.json": "Jsconfig",
238
- ".eslintrc": "Eslint",
239
- ".eslintrc.js": "Eslint",
240
- ".eslintrc.json": "Eslint",
241
- ".prettierrc": "Prettier",
242
- ".prettierrc.js": "Prettier",
243
- ".prettierrc.json": "Prettier",
244
- "vite.config.js": "Vite",
245
- "vite.config.ts": "Vite",
246
- "webpack.config.js": "Webpack",
247
- "rollup.config.js": "Rollup",
248
- "astro.config.mjs": "AstroConfig",
249
- "astro.config.js": "AstroConfig",
250
- "next.config.js": "Next",
251
- "next.config.mjs": "Next",
252
- "nuxt.config.js": "Nuxt",
253
- "nuxt.config.ts": "Nuxt",
254
- "svelte.config.js": "Svelte",
255
- "gatsby-config.js": "Gatsby",
256
- "remix.config.js": "Remix",
257
- "prisma.schema": "Prisma",
258
- ".gitignore": "Git",
259
- ".gitattributes": "Git",
260
- makefile: "Makefile",
261
- cmake: "Cmake",
262
- "cargo.toml": "Rust",
263
- "go.mod": "GoMod",
264
- "go.sum": "GoMod",
265
- "requirements.txt": "Python",
266
- "pyproject.toml": "Python",
267
- pipfile: "Python",
268
- "poetry.lock": "Poetry",
269
- gemfile: "Gemfile",
270
- rakefile: "Ruby",
271
- "composer.json": "Php",
272
- "build.gradle": "Gradle",
273
- "pom.xml": "Maven",
274
- "deno.json": "Deno",
275
- "deno.jsonc": "Deno",
276
- "vercel.json": "Vercel",
277
- "netlify.toml": "Netlify",
278
- ".env": "Tune",
279
- ".env.local": "Tune",
280
- ".env.development": "Tune",
281
- ".env.production": "Tune",
282
- ".env.example": "Tune",
283
- ".editorconfig": "Editorconfig",
284
- "robots.txt": "Robots",
285
- "favicon.ico": "Favicon",
286
- browserlist: "Browserlist",
287
- ".babelrc": "Babel",
288
- "babel.config.js": "Babel",
289
- "gulpfile.js": "Gulp",
290
- "gruntfile.js": "Grunt",
291
- "capacitor.config.json": "Capacitor",
292
- "ionic.config.json": "Ionic",
293
- "angular.json": "Angular",
294
- ".storybook": "Storybook",
295
- "storybook.config.js": "Storybook",
296
- "cypress.config.js": "Cypress",
297
- "playwright.config.js": "Playwright",
298
- "puppeteer.config.js": "Puppeteer",
299
- "wrangler.toml": "Wrangler",
300
- "firebase.json": "Firebase",
301
- supabase: "Supabase",
302
- terraform: "Terraform",
303
- kubernetes: "Kubernetes",
304
- ".gitpod.yml": "Gitpod",
305
- ".devcontainer": "Vscode",
306
- "travis.yml": "Travis",
307
- "appveyor.yml": "Appveyor",
308
- ".circleci": "Circleci",
309
- "renovate.json": "Renovate",
310
- "dependabot.yml": "Dependabot",
311
- "lerna.json": "Lerna",
312
- "nx.json": "Nx",
313
- },
314
- fileExtensions: {
315
- // Test files
316
- "spec.ts": "TestTs",
317
- "test.ts": "TestTs",
318
- "spec.tsx": "TestJsx",
319
- "test.tsx": "TestJsx",
320
- "spec.js": "TestJs",
321
- "test.js": "TestJs",
322
- "spec.jsx": "TestJsx",
323
- "test.jsx": "TestJsx",
324
-
325
- // JavaScript/TypeScript
326
- "js.map": "JavascriptMap",
327
- "d.ts": "TypescriptDef",
328
- ts: "Typescript",
329
- tsx: "React_ts",
330
- js: "Javascript",
331
- jsx: "React",
332
- mjs: "Javascript",
333
- cjs: "Javascript",
334
-
335
- // Web languages
336
- html: "Html",
337
- htm: "Html",
338
- css: "Css",
339
- scss: "Sass",
340
- sass: "Sass",
341
- less: "Less",
342
- styl: "Stylus",
343
-
344
- // Data formats
345
- json: "Json",
346
- xml: "Xml",
347
- yml: "Yaml",
348
- yaml: "Yaml",
349
- toml: "Toml",
350
- hjson: "Hjson",
351
-
352
- // Documentation
353
- md: "Markdown",
354
- mdx: "Mdx",
355
- tex: "Tex",
356
-
357
- // Programming languages
358
- py: "Python",
359
- pyx: "Python",
360
- pyw: "Python",
361
- rs: "Rust",
362
- go: "Go",
363
- java: "Java",
364
- kt: "Kotlin",
365
- scala: "Scala",
366
- php: "Php",
367
- rb: "Ruby",
368
- cs: "Csharp",
369
- vb: "Visualstudio",
370
- cpp: "Cpp",
371
- cc: "Cpp",
372
- cxx: "Cpp",
373
- c: "C",
374
- h: "H",
375
- hpp: "Hpp",
376
- swift: "Swift",
377
- m: "ObjectiveC",
378
- mm: "ObjectiveCpp",
379
- dart: "Dart",
380
- lua: "Lua",
381
- pl: "Perl",
382
- r: "R",
383
- jl: "Julia",
384
- hs: "Haskell",
385
- elm: "Elm",
386
- ml: "Ocaml",
387
- clj: "Clojure",
388
- cljs: "Clojure",
389
- erl: "Erlang",
390
- ex: "Elixir",
391
- exs: "Elixir",
392
- nim: "Nim",
393
- zig: "Zig",
394
- v: "Vlang",
395
- odin: "Odin",
396
- gleam: "Gleam",
397
- grain: "Grain",
398
- roc: "Rocket",
399
- fs: "Fsharp",
400
-
401
- // Shell scripts
402
- sh: "Console",
403
- bash: "Console",
404
- zsh: "Console",
405
- fish: "Console",
406
- ps1: "Powershell",
407
-
408
- // Config/build files
409
- cfg: "Settings",
410
- ini: "Settings",
411
- conf: "Settings",
412
- properties: "Settings",
413
-
414
- // Media files
415
- svg: "Svg",
416
- png: "Image",
417
- jpg: "Image",
418
- jpeg: "Image",
419
- gif: "Image",
420
- webp: "Image",
421
- bmp: "Image",
422
- ico: "Favicon",
423
- mp4: "Video",
424
- mov: "Video",
425
- avi: "Video",
426
- webm: "Video",
427
- mp3: "Audio",
428
- wav: "Audio",
429
- flac: "Audio",
430
-
431
- // Archive files
432
- zip: "Zip",
433
- tar: "Zip",
434
- gz: "Zip",
435
- rar: "Zip",
436
- "7z": "Zip",
437
-
438
- // Document files
439
- pdf: "Pdf",
440
- doc: "Word",
441
- docx: "Word",
442
- ppt: "Powerpoint",
443
- pptx: "Powerpoint",
444
- xls: "Document",
445
- xlsx: "Document",
446
-
447
- // Database files
448
- sql: "Database",
449
- db: "Database",
450
- sqlite: "Database",
451
-
452
- // Other
453
- env: "Tune",
454
- log: "Log",
455
- lock: "Lock",
456
- key: "Key",
457
- pem: "Certificate",
458
- crt: "Certificate",
459
- proto: "Proto",
460
- graphql: "Graphql",
461
- gql: "Graphql",
462
- wasm: "Webassembly",
463
- dockerfile: "Docker",
464
- },
465
- folderNames: {
466
- // Source code
467
- src: "FolderSrc",
468
- source: "FolderSrc",
469
- lib: "FolderLib",
470
- libs: "FolderLib",
471
-
472
- // Testing
473
- test: "FolderTest",
474
- tests: "FolderTest",
475
- testing: "FolderTest",
476
- spec: "FolderTest",
477
- specs: "FolderTest",
478
- __tests__: "FolderTest",
479
- e2e: "FolderTest",
480
- integration: "FolderTest",
481
- unit: "FolderTest",
482
- cypress: "FolderCypress",
483
-
484
- // Dependencies
485
- node_modules: "FolderNode",
486
- vendor: "FolderPackages",
487
- packages: "FolderPackages",
488
- deps: "FolderPackages",
489
-
490
- // Build/dist
491
- build: "FolderBuildkite",
492
- dist: "FolderDist",
493
- out: "FolderDist",
494
- output: "FolderDist",
495
- target: "FolderTarget",
496
-
497
- // Configuration
498
- config: "FolderConfig",
499
- configs: "FolderConfig",
500
- configuration: "FolderConfig",
501
- settings: "FolderConfig",
502
- env: "FolderEnvironment",
503
- environments: "FolderEnvironment",
504
-
505
- // Docker
506
- docker: "FolderDocker",
507
- dockerfiles: "FolderDocker",
508
- containers: "FolderDocker",
509
-
510
- // Documentation
511
- docs: "FolderDocs",
512
- doc: "FolderDocs",
513
- documentation: "FolderDocs",
514
- readme: "FolderDocs",
515
-
516
- // Public/assets
517
- public: "FolderPublic",
518
- static: "FolderPublic",
519
- assets: "FolderImages",
520
- images: "FolderImages",
521
- img: "FolderImages",
522
- icons: "FolderImages",
523
- media: "FolderImages",
524
- fonts: "FolderFont",
525
- styles: "FolderCss",
526
- stylesheets: "FolderCss",
527
- css: "FolderCss",
528
- sass: "FolderSass",
529
- scss: "FolderSass",
530
- less: "FolderLess",
531
-
532
- // Scripts
533
- scripts: "FolderScripts",
534
- script: "FolderScripts",
535
- tools: "FolderTools",
536
- utils: "FolderUtils",
537
- utilities: "FolderUtils",
538
- helpers: "FolderHelper",
539
-
540
- // Framework specific
541
- components: "FolderComponents",
542
- component: "FolderComponents",
543
- views: "FolderViews",
544
- view: "FolderViews",
545
- layouts: "FolderLayout",
546
- layout: "FolderLayout",
547
- templates: "FolderTemplate",
548
- template: "FolderTemplate",
549
- hooks: "FolderHook",
550
- hook: "FolderHook",
551
- store: "FolderStore",
552
- stores: "FolderStore",
553
- state: "FolderNgrxStore",
554
- reducers: "FolderReduxReducer",
555
- reducer: "FolderReduxReducer",
556
- services: "FolderApi",
557
- service: "FolderApi",
558
- api: "FolderApi",
559
- apis: "FolderApi",
560
- routes: "FolderRoutes",
561
- route: "FolderRoutes",
562
- routing: "FolderRoutes",
563
- middleware: "FolderMiddleware",
564
- middlewares: "FolderMiddleware",
565
- controllers: "FolderController",
566
- controller: "FolderController",
567
- models: "FolderDatabase",
568
- model: "FolderDatabase",
569
- schemas: "FolderDatabase",
570
- schema: "FolderDatabase",
571
- migrations: "FolderDatabase",
572
- migration: "FolderDatabase",
573
- seeders: "FolderSeeders",
574
- seeder: "FolderSeeders",
575
-
576
- // TypeScript
577
- types: "FolderTypescript",
578
- typing: "FolderTypescript",
579
- typings: "FolderTypescript",
580
- "@types": "FolderTypescript",
581
- interfaces: "FolderInterface",
582
- interface: "FolderInterface",
583
-
584
- // Mobile
585
- android: "FolderAndroid",
586
- ios: "FolderIos",
587
- mobile: "FolderMobile",
588
- flutter: "FolderFlutter",
589
-
590
- // Infrastructure
591
- kubernetes: "FolderKubernetes",
592
- k8s: "FolderKubernetes",
593
- terraform: "FolderTerraform",
594
- aws: "FolderAws",
595
- azure: "FolderAzurePipelines",
596
- firebase: "FolderFirebase",
597
- supabase: "FolderSupabase",
598
- vercel: "FolderVercel",
599
- netlify: "FolderNetlify",
600
-
601
- // CI/CD
602
- ".github": "FolderGithub",
603
- ".gitlab": "FolderGitlab",
604
- ".circleci": "FolderCircleci",
605
- ci: "FolderCi",
606
- ".ci": "FolderCi",
607
- workflows: "FolderGhWorkflows",
608
-
609
- // Git
610
- ".git": "FolderGit",
611
-
612
- // Development tools
613
- ".vscode": "FolderVscode",
614
- ".idea": "FolderIntellij",
615
- ".cursor": "FolderCursor",
616
- ".devcontainer": "FolderContainer",
617
- ".storybook": "FolderStorybook",
618
-
619
- // Localization
620
- i18n: "FolderI18n",
621
- locales: "FolderI18n",
622
- locale: "FolderI18n",
623
- lang: "FolderI18n",
624
- languages: "FolderI18n",
625
-
626
- // Other common patterns
627
- temp: "FolderTemp",
628
- tmp: "FolderTemp",
629
- logs: "FolderLog",
630
- log: "FolderLog",
631
- backup: "FolderBackup",
632
- backups: "FolderBackup",
633
- examples: "FolderExamples",
634
- example: "FolderExamples",
635
- demo: "FolderExamples",
636
- demos: "FolderExamples",
637
- samples: "FolderExamples",
638
- sample: "FolderExamples",
639
- fixtures: "FolderTest",
640
- mocks: "FolderMock",
641
- mock: "FolderMock",
642
- data: "FolderDatabase",
643
- database: "FolderDatabase",
644
- db: "FolderDatabase",
645
- sql: "FolderDatabase",
646
- prisma: "FolderPrisma",
647
- drizzle: "FolderDrizzle",
648
-
649
- // Security
650
- security: "FolderSecure",
651
- auth: "FolderSecure",
652
- authentication: "FolderSecure",
653
- authorization: "FolderSecure",
654
- keys: "FolderKeys",
655
- certs: "FolderKeys",
656
- certificates: "FolderKeys",
657
-
658
- // Content
659
- content: "FolderContent",
660
- posts: "FolderContent",
661
- articles: "FolderContent",
662
- blog: "FolderContent",
663
-
664
- // Functions
665
- functions: "FolderFunctions",
666
- function: "FolderFunctions",
667
- lambda: "FolderFunctions",
668
- lambdas: "FolderFunctions",
669
- serverless: "FolderServerless",
670
-
671
- // Jobs/tasks
672
- jobs: "FolderJob",
673
- job: "FolderJob",
674
- tasks: "FolderTasks",
675
- task: "FolderTasks",
676
- cron: "FolderTasks",
677
- queue: "FolderQueue",
678
- queues: "FolderQueue",
679
-
680
- // Desktop platforms
681
- desktop: "FolderDesktop",
682
- windows: "FolderWindows",
683
- macos: "FolderMacos",
684
- linux: "FolderLinux",
685
- },
686
- defaults: {
687
- file: "Document",
688
- folder: "Folder",
689
- folderOpen: "FolderOpen",
690
- },
691
- }
692
-
693
- const toOpenVariant = (icon: IconName): IconName => {
694
- if (!icon.startsWith("Folder")) return icon
695
-
696
- if (icon.endsWith("_light")) {
697
- // SAFETY: the icon generator writes an `Open` variant for every folder icon, light ones included.
698
- return icon.replace("_light", "Open_light") as IconName
699
- }
700
-
701
- if (!icon.endsWith("Open")) {
702
- // SAFETY: the icon generator writes an `Open` variant for every folder icon.
703
- return (icon + "Open") as IconName
704
- }
705
-
706
- return icon
707
- }
708
-
709
- const basenameOf = (p: string) => p.split("\\").join("/").split("/").filter(Boolean).pop() ?? ""
710
-
711
- const folderNameVariants = (name: string) => {
712
- const n = name.toLowerCase()
713
-
714
- return [n, `.${n}`, `_${n}`, `__${n}__`]
715
- }
716
-
717
- const dottedSuffixesDesc = (name: string) => {
718
- const n = name.toLowerCase()
719
- const idxs: number[] = []
720
-
721
- for (let i = 0; i < n.length; i++) if (n[i] === ".") idxs.push(i)
722
- const out = new Set<string>()
723
- out.add(n) // allow exact whole-name "extensions" like "dockerfile"
724
-
725
- for (const i of idxs) if (i + 1 < n.length) out.add(n.slice(i + 1))
726
-
727
- return Array.from(out).sort((a, b) => b.length - a.length) // longest first
728
- }
729
-
730
- export function chooseIconName(path: string, type: "directory" | "file", expanded: boolean): IconName {
731
- const base = basenameOf(path)
732
- const baseLower = base.toLowerCase()
733
-
734
- if (type === "directory") {
735
- for (const cand of folderNameVariants(baseLower)) {
736
- const icon = ICON_MAPS.folderNames[cand]
737
-
738
- if (icon) return expanded ? toOpenVariant(icon) : icon
739
- }
740
-
741
- return expanded ? ICON_MAPS.defaults.folderOpen : ICON_MAPS.defaults.folder
742
- }
743
-
744
- const byName = ICON_MAPS.fileNames[baseLower]
745
-
746
- if (byName) return byName
747
-
748
- for (const ext of dottedSuffixesDesc(baseLower)) {
749
- const icon = ICON_MAPS.fileExtensions[ext]
750
-
751
- if (icon) return icon
752
- }
753
-
754
- return ICON_MAPS.defaults.file
755
- }
@@ -0,0 +1,574 @@
1
+ // Which file-type icon a path gets (FileIcon in file-icon.tsx, and the docs code blocks on the
2
+ // website). Kept apart from FileIcon so a caller can map names without bundling the sprite.
3
+ import type { IconName } from "./types"
4
+
5
+ type IconMaps = {
6
+ fileNames: Record<string, IconName>
7
+ fileExtensions: Record<string, IconName>
8
+ folderNames: Record<string, IconName>
9
+ defaults: {
10
+ file: IconName
11
+ folder: IconName
12
+ folderOpen: IconName
13
+ }
14
+ }
15
+
16
+ const ICON_MAPS: IconMaps = {
17
+ fileNames: {
18
+ // Documentation files
19
+ "readme.md": "Readme",
20
+ "changelog.md": "Changelog",
21
+ "contributing.md": "Contributing",
22
+ "conduct.md": "Conduct",
23
+ license: "Certificate",
24
+ authors: "Authors",
25
+ credits: "Credits",
26
+ install: "Installation",
27
+
28
+ // Node.js files
29
+ "package.json": "Nodejs",
30
+ "package-lock.json": "Nodejs",
31
+ "yarn.lock": "Yarn",
32
+ "pnpm-lock.yaml": "Pnpm",
33
+ "bun.lock": "Bun",
34
+ "bun.lockb": "Bun",
35
+ "bunfig.toml": "Bun",
36
+ ".nvmrc": "Nodejs",
37
+ ".node-version": "Nodejs",
38
+
39
+ // Docker files
40
+ dockerfile: "Docker",
41
+ "docker-compose.yml": "Docker",
42
+ "docker-compose.yaml": "Docker",
43
+ ".dockerignore": "Docker",
44
+
45
+ // Config files
46
+ "jest.config.js": "Jest",
47
+ "jest.config.ts": "Jest",
48
+ "jest.config.mjs": "Jest",
49
+ "vitest.config.js": "Vitest",
50
+ "vitest.config.ts": "Vitest",
51
+ "tailwind.config.js": "Tailwindcss",
52
+ "tailwind.config.ts": "Tailwindcss",
53
+ "turbo.json": "Turborepo",
54
+ "tsconfig.json": "Tsconfig",
55
+ "jsconfig.json": "Jsconfig",
56
+ ".eslintrc": "Eslint",
57
+ ".eslintrc.js": "Eslint",
58
+ ".eslintrc.json": "Eslint",
59
+ ".prettierrc": "Prettier",
60
+ ".prettierrc.js": "Prettier",
61
+ ".prettierrc.json": "Prettier",
62
+ "vite.config.js": "Vite",
63
+ "vite.config.ts": "Vite",
64
+ "webpack.config.js": "Webpack",
65
+ "rollup.config.js": "Rollup",
66
+ "astro.config.mjs": "AstroConfig",
67
+ "astro.config.js": "AstroConfig",
68
+ "next.config.js": "Next",
69
+ "next.config.mjs": "Next",
70
+ "nuxt.config.js": "Nuxt",
71
+ "nuxt.config.ts": "Nuxt",
72
+ "svelte.config.js": "Svelte",
73
+ "gatsby-config.js": "Gatsby",
74
+ "remix.config.js": "Remix",
75
+ "prisma.schema": "Prisma",
76
+ ".gitignore": "Git",
77
+ ".gitattributes": "Git",
78
+ makefile: "Makefile",
79
+ cmake: "Cmake",
80
+ "cargo.toml": "Rust",
81
+ "go.mod": "GoMod",
82
+ "go.sum": "GoMod",
83
+ "requirements.txt": "Python",
84
+ "pyproject.toml": "Python",
85
+ pipfile: "Python",
86
+ "poetry.lock": "Poetry",
87
+ gemfile: "Gemfile",
88
+ rakefile: "Ruby",
89
+ "composer.json": "Php",
90
+ "build.gradle": "Gradle",
91
+ "pom.xml": "Maven",
92
+ "deno.json": "Deno",
93
+ "deno.jsonc": "Deno",
94
+ "vercel.json": "Vercel",
95
+ "netlify.toml": "Netlify",
96
+ ".env": "Tune",
97
+ ".env.local": "Tune",
98
+ ".env.development": "Tune",
99
+ ".env.production": "Tune",
100
+ ".env.example": "Tune",
101
+ ".editorconfig": "Editorconfig",
102
+ "robots.txt": "Robots",
103
+ "favicon.ico": "Favicon",
104
+ browserlist: "Browserlist",
105
+ ".babelrc": "Babel",
106
+ "babel.config.js": "Babel",
107
+ "gulpfile.js": "Gulp",
108
+ "gruntfile.js": "Grunt",
109
+ "capacitor.config.json": "Capacitor",
110
+ "ionic.config.json": "Ionic",
111
+ "angular.json": "Angular",
112
+ ".storybook": "Storybook",
113
+ "storybook.config.js": "Storybook",
114
+ "cypress.config.js": "Cypress",
115
+ "playwright.config.js": "Playwright",
116
+ "puppeteer.config.js": "Puppeteer",
117
+ "wrangler.toml": "Wrangler",
118
+ "firebase.json": "Firebase",
119
+ supabase: "Supabase",
120
+ terraform: "Terraform",
121
+ kubernetes: "Kubernetes",
122
+ ".gitpod.yml": "Gitpod",
123
+ ".devcontainer": "Vscode",
124
+ "travis.yml": "Travis",
125
+ "appveyor.yml": "Appveyor",
126
+ ".circleci": "Circleci",
127
+ "renovate.json": "Renovate",
128
+ "dependabot.yml": "Dependabot",
129
+ "lerna.json": "Lerna",
130
+ "nx.json": "Nx",
131
+ },
132
+ fileExtensions: {
133
+ // Test files
134
+ "spec.ts": "TestTs",
135
+ "test.ts": "TestTs",
136
+ "spec.tsx": "TestJsx",
137
+ "test.tsx": "TestJsx",
138
+ "spec.js": "TestJs",
139
+ "test.js": "TestJs",
140
+ "spec.jsx": "TestJsx",
141
+ "test.jsx": "TestJsx",
142
+
143
+ // JavaScript/TypeScript
144
+ "js.map": "JavascriptMap",
145
+ "d.ts": "TypescriptDef",
146
+ ts: "Typescript",
147
+ tsx: "React_ts",
148
+ js: "Javascript",
149
+ jsx: "React",
150
+ mjs: "Javascript",
151
+ cjs: "Javascript",
152
+
153
+ // Web languages
154
+ html: "Html",
155
+ htm: "Html",
156
+ css: "Css",
157
+ scss: "Sass",
158
+ sass: "Sass",
159
+ less: "Less",
160
+ styl: "Stylus",
161
+
162
+ // Data formats
163
+ json: "Json",
164
+ jsonc: "Json",
165
+ xml: "Xml",
166
+ yml: "Yaml",
167
+ yaml: "Yaml",
168
+ toml: "Toml",
169
+ hjson: "Hjson",
170
+
171
+ // Documentation
172
+ md: "Markdown",
173
+ mdx: "Mdx",
174
+ tex: "Tex",
175
+
176
+ // Programming languages
177
+ py: "Python",
178
+ pyx: "Python",
179
+ pyw: "Python",
180
+ rs: "Rust",
181
+ go: "Go",
182
+ java: "Java",
183
+ kt: "Kotlin",
184
+ scala: "Scala",
185
+ php: "Php",
186
+ rb: "Ruby",
187
+ cs: "Csharp",
188
+ vb: "Visualstudio",
189
+ cpp: "Cpp",
190
+ cc: "Cpp",
191
+ cxx: "Cpp",
192
+ c: "C",
193
+ h: "H",
194
+ hpp: "Hpp",
195
+ swift: "Swift",
196
+ m: "ObjectiveC",
197
+ mm: "ObjectiveCpp",
198
+ dart: "Dart",
199
+ lua: "Lua",
200
+ pl: "Perl",
201
+ r: "R",
202
+ jl: "Julia",
203
+ hs: "Haskell",
204
+ elm: "Elm",
205
+ ml: "Ocaml",
206
+ clj: "Clojure",
207
+ cljs: "Clojure",
208
+ erl: "Erlang",
209
+ ex: "Elixir",
210
+ exs: "Elixir",
211
+ nim: "Nim",
212
+ zig: "Zig",
213
+ v: "Vlang",
214
+ odin: "Odin",
215
+ gleam: "Gleam",
216
+ grain: "Grain",
217
+ roc: "Rocket",
218
+ fs: "Fsharp",
219
+
220
+ // Shell scripts
221
+ sh: "Console",
222
+ bash: "Console",
223
+ zsh: "Console",
224
+ fish: "Console",
225
+ ps1: "Powershell",
226
+
227
+ // Config/build files
228
+ cfg: "Settings",
229
+ ini: "Settings",
230
+ conf: "Settings",
231
+ properties: "Settings",
232
+
233
+ // Media files
234
+ svg: "Svg",
235
+ png: "Image",
236
+ jpg: "Image",
237
+ jpeg: "Image",
238
+ gif: "Image",
239
+ webp: "Image",
240
+ bmp: "Image",
241
+ ico: "Favicon",
242
+ mp4: "Video",
243
+ mov: "Video",
244
+ avi: "Video",
245
+ webm: "Video",
246
+ mp3: "Audio",
247
+ wav: "Audio",
248
+ flac: "Audio",
249
+
250
+ // Archive files
251
+ zip: "Zip",
252
+ tar: "Zip",
253
+ gz: "Zip",
254
+ rar: "Zip",
255
+ "7z": "Zip",
256
+
257
+ // Document files
258
+ pdf: "Pdf",
259
+ doc: "Word",
260
+ docx: "Word",
261
+ ppt: "Powerpoint",
262
+ pptx: "Powerpoint",
263
+ xls: "Document",
264
+ xlsx: "Document",
265
+
266
+ // Database files
267
+ sql: "Database",
268
+ db: "Database",
269
+ sqlite: "Database",
270
+
271
+ // Other
272
+ env: "Tune",
273
+ log: "Log",
274
+ lock: "Lock",
275
+ key: "Key",
276
+ pem: "Certificate",
277
+ crt: "Certificate",
278
+ proto: "Proto",
279
+ graphql: "Graphql",
280
+ gql: "Graphql",
281
+ wasm: "Webassembly",
282
+ dockerfile: "Docker",
283
+ },
284
+ folderNames: {
285
+ // Source code
286
+ src: "FolderSrc",
287
+ source: "FolderSrc",
288
+ lib: "FolderLib",
289
+ libs: "FolderLib",
290
+
291
+ // Testing
292
+ test: "FolderTest",
293
+ tests: "FolderTest",
294
+ testing: "FolderTest",
295
+ spec: "FolderTest",
296
+ specs: "FolderTest",
297
+ __tests__: "FolderTest",
298
+ e2e: "FolderTest",
299
+ integration: "FolderTest",
300
+ unit: "FolderTest",
301
+ cypress: "FolderCypress",
302
+
303
+ // Dependencies
304
+ node_modules: "FolderNode",
305
+ vendor: "FolderPackages",
306
+ packages: "FolderPackages",
307
+ deps: "FolderPackages",
308
+
309
+ // Build/dist
310
+ build: "FolderBuildkite",
311
+ dist: "FolderDist",
312
+ out: "FolderDist",
313
+ output: "FolderDist",
314
+ target: "FolderTarget",
315
+
316
+ // Configuration
317
+ config: "FolderConfig",
318
+ configs: "FolderConfig",
319
+ configuration: "FolderConfig",
320
+ settings: "FolderConfig",
321
+ env: "FolderEnvironment",
322
+ environments: "FolderEnvironment",
323
+
324
+ // Docker
325
+ docker: "FolderDocker",
326
+ dockerfiles: "FolderDocker",
327
+ containers: "FolderDocker",
328
+
329
+ // Documentation
330
+ docs: "FolderDocs",
331
+ doc: "FolderDocs",
332
+ documentation: "FolderDocs",
333
+ readme: "FolderDocs",
334
+
335
+ // Public/assets
336
+ public: "FolderPublic",
337
+ static: "FolderPublic",
338
+ assets: "FolderImages",
339
+ images: "FolderImages",
340
+ img: "FolderImages",
341
+ icons: "FolderImages",
342
+ media: "FolderImages",
343
+ fonts: "FolderFont",
344
+ styles: "FolderCss",
345
+ stylesheets: "FolderCss",
346
+ css: "FolderCss",
347
+ sass: "FolderSass",
348
+ scss: "FolderSass",
349
+ less: "FolderLess",
350
+
351
+ // Scripts
352
+ scripts: "FolderScripts",
353
+ script: "FolderScripts",
354
+ tools: "FolderTools",
355
+ utils: "FolderUtils",
356
+ utilities: "FolderUtils",
357
+ helpers: "FolderHelper",
358
+
359
+ // Framework specific
360
+ components: "FolderComponents",
361
+ component: "FolderComponents",
362
+ views: "FolderViews",
363
+ view: "FolderViews",
364
+ layouts: "FolderLayout",
365
+ layout: "FolderLayout",
366
+ templates: "FolderTemplate",
367
+ template: "FolderTemplate",
368
+ hooks: "FolderHook",
369
+ hook: "FolderHook",
370
+ store: "FolderStore",
371
+ stores: "FolderStore",
372
+ state: "FolderNgrxStore",
373
+ reducers: "FolderReduxReducer",
374
+ reducer: "FolderReduxReducer",
375
+ services: "FolderApi",
376
+ service: "FolderApi",
377
+ api: "FolderApi",
378
+ apis: "FolderApi",
379
+ routes: "FolderRoutes",
380
+ route: "FolderRoutes",
381
+ routing: "FolderRoutes",
382
+ middleware: "FolderMiddleware",
383
+ middlewares: "FolderMiddleware",
384
+ controllers: "FolderController",
385
+ controller: "FolderController",
386
+ models: "FolderDatabase",
387
+ model: "FolderDatabase",
388
+ schemas: "FolderDatabase",
389
+ schema: "FolderDatabase",
390
+ migrations: "FolderDatabase",
391
+ migration: "FolderDatabase",
392
+ seeders: "FolderSeeders",
393
+ seeder: "FolderSeeders",
394
+
395
+ // TypeScript
396
+ types: "FolderTypescript",
397
+ typing: "FolderTypescript",
398
+ typings: "FolderTypescript",
399
+ "@types": "FolderTypescript",
400
+ interfaces: "FolderInterface",
401
+ interface: "FolderInterface",
402
+
403
+ // Mobile
404
+ android: "FolderAndroid",
405
+ ios: "FolderIos",
406
+ mobile: "FolderMobile",
407
+ flutter: "FolderFlutter",
408
+
409
+ // Infrastructure
410
+ kubernetes: "FolderKubernetes",
411
+ k8s: "FolderKubernetes",
412
+ terraform: "FolderTerraform",
413
+ aws: "FolderAws",
414
+ azure: "FolderAzurePipelines",
415
+ firebase: "FolderFirebase",
416
+ supabase: "FolderSupabase",
417
+ vercel: "FolderVercel",
418
+ netlify: "FolderNetlify",
419
+
420
+ // CI/CD
421
+ ".github": "FolderGithub",
422
+ ".gitlab": "FolderGitlab",
423
+ ".circleci": "FolderCircleci",
424
+ ci: "FolderCi",
425
+ ".ci": "FolderCi",
426
+ workflows: "FolderGhWorkflows",
427
+
428
+ // Git
429
+ ".git": "FolderGit",
430
+
431
+ // Development tools
432
+ ".vscode": "FolderVscode",
433
+ ".idea": "FolderIntellij",
434
+ ".cursor": "FolderCursor",
435
+ ".devcontainer": "FolderContainer",
436
+ ".storybook": "FolderStorybook",
437
+
438
+ // Localization
439
+ i18n: "FolderI18n",
440
+ locales: "FolderI18n",
441
+ locale: "FolderI18n",
442
+ lang: "FolderI18n",
443
+ languages: "FolderI18n",
444
+
445
+ // Other common patterns
446
+ temp: "FolderTemp",
447
+ tmp: "FolderTemp",
448
+ logs: "FolderLog",
449
+ log: "FolderLog",
450
+ backup: "FolderBackup",
451
+ backups: "FolderBackup",
452
+ examples: "FolderExamples",
453
+ example: "FolderExamples",
454
+ demo: "FolderExamples",
455
+ demos: "FolderExamples",
456
+ samples: "FolderExamples",
457
+ sample: "FolderExamples",
458
+ fixtures: "FolderTest",
459
+ mocks: "FolderMock",
460
+ mock: "FolderMock",
461
+ data: "FolderDatabase",
462
+ database: "FolderDatabase",
463
+ db: "FolderDatabase",
464
+ sql: "FolderDatabase",
465
+ prisma: "FolderPrisma",
466
+ drizzle: "FolderDrizzle",
467
+
468
+ // Security
469
+ security: "FolderSecure",
470
+ auth: "FolderSecure",
471
+ authentication: "FolderSecure",
472
+ authorization: "FolderSecure",
473
+ keys: "FolderKeys",
474
+ certs: "FolderKeys",
475
+ certificates: "FolderKeys",
476
+
477
+ // Content
478
+ content: "FolderContent",
479
+ posts: "FolderContent",
480
+ articles: "FolderContent",
481
+ blog: "FolderContent",
482
+
483
+ // Functions
484
+ functions: "FolderFunctions",
485
+ function: "FolderFunctions",
486
+ lambda: "FolderFunctions",
487
+ lambdas: "FolderFunctions",
488
+ serverless: "FolderServerless",
489
+
490
+ // Jobs/tasks
491
+ jobs: "FolderJob",
492
+ job: "FolderJob",
493
+ tasks: "FolderTasks",
494
+ task: "FolderTasks",
495
+ cron: "FolderTasks",
496
+ queue: "FolderQueue",
497
+ queues: "FolderQueue",
498
+
499
+ // Desktop platforms
500
+ desktop: "FolderDesktop",
501
+ windows: "FolderWindows",
502
+ macos: "FolderMacos",
503
+ linux: "FolderLinux",
504
+ },
505
+ defaults: {
506
+ file: "Document",
507
+ folder: "Folder",
508
+ folderOpen: "FolderOpen",
509
+ },
510
+ }
511
+
512
+ const toOpenVariant = (icon: IconName): IconName => {
513
+ if (!icon.startsWith("Folder")) return icon
514
+
515
+ if (icon.endsWith("_light")) {
516
+ // SAFETY: the icon generator writes an `Open` variant for every folder icon, light ones included.
517
+ return icon.replace("_light", "Open_light") as IconName
518
+ }
519
+
520
+ if (!icon.endsWith("Open")) {
521
+ // SAFETY: the icon generator writes an `Open` variant for every folder icon.
522
+ return (icon + "Open") as IconName
523
+ }
524
+
525
+ return icon
526
+ }
527
+
528
+ const basenameOf = (p: string) => p.split("\\").join("/").split("/").filter(Boolean).pop() ?? ""
529
+
530
+ const folderNameVariants = (name: string) => {
531
+ const n = name.toLowerCase()
532
+
533
+ return [n, `.${n}`, `_${n}`, `__${n}__`]
534
+ }
535
+
536
+ const dottedSuffixesDesc = (name: string) => {
537
+ const n = name.toLowerCase()
538
+ const idxs: number[] = []
539
+
540
+ for (let i = 0; i < n.length; i++) if (n[i] === ".") idxs.push(i)
541
+ const out = new Set<string>()
542
+ out.add(n) // allow exact whole-name "extensions" like "dockerfile"
543
+
544
+ for (const i of idxs) if (i + 1 < n.length) out.add(n.slice(i + 1))
545
+
546
+ return Array.from(out).sort((a, b) => b.length - a.length) // longest first
547
+ }
548
+
549
+ export function chooseIconName(path: string, type: "directory" | "file", expanded: boolean): IconName {
550
+ const base = basenameOf(path)
551
+ const baseLower = base.toLowerCase()
552
+
553
+ if (type === "directory") {
554
+ for (const cand of folderNameVariants(baseLower)) {
555
+ const icon = ICON_MAPS.folderNames[cand]
556
+
557
+ if (icon) return expanded ? toOpenVariant(icon) : icon
558
+ }
559
+
560
+ return expanded ? ICON_MAPS.defaults.folderOpen : ICON_MAPS.defaults.folder
561
+ }
562
+
563
+ const byName = ICON_MAPS.fileNames[baseLower]
564
+
565
+ if (byName) return byName
566
+
567
+ for (const ext of dottedSuffixesDesc(baseLower)) {
568
+ const icon = ICON_MAPS.fileExtensions[ext]
569
+
570
+ if (icon) return icon
571
+ }
572
+
573
+ return ICON_MAPS.defaults.file
574
+ }