@anymux/ui-kit 0.1.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.
Files changed (244) hide show
  1. package/dist/ExplorerLayout-CSIJd7N4.js +105 -0
  2. package/dist/ExplorerLayout-CSIJd7N4.js.map +1 -0
  3. package/dist/FileBrowserContext-B6jixa2j.js +11 -0
  4. package/dist/FileBrowserContext-B6jixa2j.js.map +1 -0
  5. package/dist/calendar-DSlrbHoj.js +761 -0
  6. package/dist/calendar-DSlrbHoj.js.map +1 -0
  7. package/dist/calendar.d.ts +3 -0
  8. package/dist/calendar.js +3 -0
  9. package/dist/contacts-DQXTZzHc.js +539 -0
  10. package/dist/contacts-DQXTZzHc.js.map +1 -0
  11. package/dist/contacts.d.ts +3 -0
  12. package/dist/contacts.js +3 -0
  13. package/dist/file-browser-m5atC3kF.js +6755 -0
  14. package/dist/file-browser-m5atC3kF.js.map +1 -0
  15. package/dist/file-browser.d.ts +11 -0
  16. package/dist/file-browser.js +9 -0
  17. package/dist/git-B55e6LL-.js +561 -0
  18. package/dist/git-B55e6LL-.js.map +1 -0
  19. package/dist/git.d.ts +2 -0
  20. package/dist/git.js +3 -0
  21. package/dist/iconMap-V4B8P-Uh.js +206 -0
  22. package/dist/iconMap-V4B8P-Uh.js.map +1 -0
  23. package/dist/icons-CIsIOZXR.js +0 -0
  24. package/dist/icons.d.ts +2 -0
  25. package/dist/icons.js +4 -0
  26. package/dist/index-BNmNIWBL.d.ts +71 -0
  27. package/dist/index-BNmNIWBL.d.ts.map +1 -0
  28. package/dist/index-Bryv_GCG.d.ts +1481 -0
  29. package/dist/index-Bryv_GCG.d.ts.map +1 -0
  30. package/dist/index-CuQIjSXs.d.ts +134 -0
  31. package/dist/index-CuQIjSXs.d.ts.map +1 -0
  32. package/dist/index-DSu19mq0.d.ts +153 -0
  33. package/dist/index-DSu19mq0.d.ts.map +1 -0
  34. package/dist/index-DmsyeHFr.d.ts +149 -0
  35. package/dist/index-DmsyeHFr.d.ts.map +1 -0
  36. package/dist/index-DxnJ8FYM.d.ts +17 -0
  37. package/dist/index-DxnJ8FYM.d.ts.map +1 -0
  38. package/dist/index-DzfY1Tok.d.ts +32 -0
  39. package/dist/index-DzfY1Tok.d.ts.map +1 -0
  40. package/dist/index-Ml_SgiKa.d.ts +1847 -0
  41. package/dist/index-Ml_SgiKa.d.ts.map +1 -0
  42. package/dist/index-kHr9udZD.d.ts +1025 -0
  43. package/dist/index-kHr9udZD.d.ts.map +1 -0
  44. package/dist/index.d.ts +11 -0
  45. package/dist/index.js +15 -0
  46. package/dist/layout-Ca_4r8ka.js +89 -0
  47. package/dist/layout-Ca_4r8ka.js.map +1 -0
  48. package/dist/layout.d.ts +2 -0
  49. package/dist/layout.js +5 -0
  50. package/dist/list-CxfT6hix.js +6831 -0
  51. package/dist/list-CxfT6hix.js.map +1 -0
  52. package/dist/list.d.ts +2 -0
  53. package/dist/list.js +5 -0
  54. package/dist/media-DZ292aKK.js +557 -0
  55. package/dist/media-DZ292aKK.js.map +1 -0
  56. package/dist/media.d.ts +3 -0
  57. package/dist/media.js +3 -0
  58. package/dist/tree-Dd9Z0Aso.js +3351 -0
  59. package/dist/tree-Dd9Z0Aso.js.map +1 -0
  60. package/dist/tree.d.ts +2 -0
  61. package/dist/tree.js +6 -0
  62. package/dist/types-common-CB3kRek8.d.ts +26 -0
  63. package/dist/types-common-CB3kRek8.d.ts.map +1 -0
  64. package/dist/utils-B4fdKKsy.js +3 -0
  65. package/package.json +109 -0
  66. package/src/calendar/AgendaView.tsx +37 -0
  67. package/src/calendar/CalendarBrowser.tsx +90 -0
  68. package/src/calendar/CalendarModel.ts +142 -0
  69. package/src/calendar/CalendarSidebar.tsx +81 -0
  70. package/src/calendar/DayView.tsx +76 -0
  71. package/src/calendar/EventCard.tsx +51 -0
  72. package/src/calendar/MockCalendarProvider.ts +98 -0
  73. package/src/calendar/MonthView.tsx +77 -0
  74. package/src/calendar/WeekView.tsx +129 -0
  75. package/src/calendar/index.ts +18 -0
  76. package/src/calendar/types.ts +25 -0
  77. package/src/contacts/ContactAvatar.tsx +35 -0
  78. package/src/contacts/ContactBrowser.tsx +56 -0
  79. package/src/contacts/ContactCard.tsx +37 -0
  80. package/src/contacts/ContactDetail.tsx +63 -0
  81. package/src/contacts/ContactGroupSidebar.tsx +40 -0
  82. package/src/contacts/ContactList.tsx +32 -0
  83. package/src/contacts/ContactListModel.ts +120 -0
  84. package/src/contacts/MockContactProvider.ts +77 -0
  85. package/src/contacts/index.ts +17 -0
  86. package/src/contacts/types.ts +26 -0
  87. package/src/demos/CalendarBrowserDemo.tsx +15 -0
  88. package/src/demos/ContactBrowserDemo.tsx +15 -0
  89. package/src/demos/MediaBrowserDemo.tsx +15 -0
  90. package/src/file-browser/adapters/DocumentViewerAdapter.ts +371 -0
  91. package/src/file-browser/adapters/FileSystemBridge.ts +168 -0
  92. package/src/file-browser/adapters/GitBrowserAdapter.ts +546 -0
  93. package/src/file-browser/adapters/README.md +504 -0
  94. package/src/file-browser/adapters/index.ts +27 -0
  95. package/src/file-browser/adapters/types.ts +70 -0
  96. package/src/file-browser/architecture.md +645 -0
  97. package/src/file-browser/components/CreateItemDialog.tsx +71 -0
  98. package/src/file-browser/components/DeleteConfirmDialog.tsx +58 -0
  99. package/src/file-browser/components/FileBrowser.tsx +473 -0
  100. package/src/file-browser/components/FileBrowserContent.tsx +209 -0
  101. package/src/file-browser/components/FileBrowserHeader.tsx +151 -0
  102. package/src/file-browser/components/FileBrowserToolbar.tsx +145 -0
  103. package/src/file-browser/components/LeftPanel/LeftPanel.tsx +103 -0
  104. package/src/file-browser/components/LeftPanel/LeftPanelTabs.tsx +70 -0
  105. package/src/file-browser/components/LeftPanel/TreeNavigationView.tsx +256 -0
  106. package/src/file-browser/components/PreviewPane.tsx +146 -0
  107. package/src/file-browser/components/RightPanel/FilePreview.tsx +219 -0
  108. package/src/file-browser/components/RightPanel/RightPanel.tsx +186 -0
  109. package/src/file-browser/components/RightPanel/RightPanelToolbar.tsx +113 -0
  110. package/src/file-browser/components/UploadProgress.tsx +123 -0
  111. package/src/file-browser/components/ViewerHost.tsx +208 -0
  112. package/src/file-browser/components/mobile/MobileNavigation.tsx +227 -0
  113. package/src/file-browser/components/navigation/NavigationButtons.tsx +171 -0
  114. package/src/file-browser/components/shared/ErrorBoundary.tsx +116 -0
  115. package/src/file-browser/components/shared/FileBrowserItem.tsx +195 -0
  116. package/src/file-browser/components/shared/FileIcon.tsx +169 -0
  117. package/src/file-browser/components/toolbar/ViewModeToggle.tsx +200 -0
  118. package/src/file-browser/components/views/ListView/ListView.tsx +484 -0
  119. package/src/file-browser/components/views/ThumbnailView/ThumbnailView.tsx +323 -0
  120. package/src/file-browser/components/views/TreeView/TreeNode.tsx +186 -0
  121. package/src/file-browser/components/views/TreeView/TreeNodeList.tsx +191 -0
  122. package/src/file-browser/components/views/TreeView/TreeView.tsx +200 -0
  123. package/src/file-browser/components/views/TreemapView/TreemapView.tsx +339 -0
  124. package/src/file-browser/context/FileBrowserContext.tsx +13 -0
  125. package/src/file-browser/examples/BasicUsage.tsx +20 -0
  126. package/src/file-browser/index.ts +98 -0
  127. package/src/file-browser/models/FileBrowserModel.ts +623 -0
  128. package/src/file-browser/models/LeftPanelManagerModel.ts +105 -0
  129. package/src/file-browser/models/NavigationManagerModel.ts +312 -0
  130. package/src/file-browser/models/ResponsiveLayoutManagerModel.ts +437 -0
  131. package/src/file-browser/models/RightPanelManagerModel.ts +190 -0
  132. package/src/file-browser/models/SelectionManagerModel.ts +252 -0
  133. package/src/file-browser/models/ToolbarManagerModel.ts +144 -0
  134. package/src/file-browser/models/UploadModel.ts +147 -0
  135. package/src/file-browser/models/ViewModeManagerModel.ts +185 -0
  136. package/src/file-browser/models/ViewerHostModel.ts +44 -0
  137. package/src/file-browser/models/ui/ListViewUIModel.ts +265 -0
  138. package/src/file-browser/models/ui/PreviewUIModel.ts +297 -0
  139. package/src/file-browser/models/ui/ThumbnailViewUIModel.ts +254 -0
  140. package/src/file-browser/models/ui/TreeViewUIModel.ts +128 -0
  141. package/src/file-browser/models/ui/TreemapViewUIModel.ts +350 -0
  142. package/src/file-browser/providers/FileSystemListProvider.ts +552 -0
  143. package/src/file-browser/providers/FileSystemProvider.ts +401 -0
  144. package/src/file-browser/providers/FileSystemTreeProvider.ts +231 -0
  145. package/src/file-browser/providers/GitProvider.ts +337 -0
  146. package/src/file-browser/providers/GitRepositoryProvider.ts +376 -0
  147. package/src/file-browser/providers/IFileBrowserProvider.ts +56 -0
  148. package/src/file-browser/providers/MemoryProvider.ts +303 -0
  149. package/src/file-browser/providers/index.ts +4 -0
  150. package/src/file-browser/registry/ViewerRegistry.ts +551 -0
  151. package/src/file-browser/registry/types.ts +144 -0
  152. package/src/file-browser/scripts/performanceBenchmark.ts +553 -0
  153. package/src/file-browser/services/ThumbnailCacheService.ts +128 -0
  154. package/src/file-browser/tasks.md +537 -0
  155. package/src/file-browser/types/FileBrowserTypes.ts +126 -0
  156. package/src/file-browser/types/ProviderTypes.ts +155 -0
  157. package/src/file-browser/types/UITypes.ts +235 -0
  158. package/src/file-browser/types/ViewModeTypes.ts +150 -0
  159. package/src/file-browser/utils/gestures.ts +327 -0
  160. package/src/file-browser/utils/performance.ts +563 -0
  161. package/src/file-browser/viewers/ImageViewer.tsx +163 -0
  162. package/src/file-browser/viewers/ImageViewerModel.ts +79 -0
  163. package/src/file-browser/viewers/TextViewer.tsx +95 -0
  164. package/src/file-browser/viewers/UnsupportedFileViewer.tsx +57 -0
  165. package/src/file-browser/viewers/index.ts +61 -0
  166. package/src/git/BranchList.tsx +128 -0
  167. package/src/git/CommitGraph.tsx +239 -0
  168. package/src/git/CommitList.tsx +258 -0
  169. package/src/git/DiffViewer.tsx +219 -0
  170. package/src/git/index.ts +4 -0
  171. package/src/icons/iconMap.ts +146 -0
  172. package/src/icons/index.ts +9 -0
  173. package/src/index.ts +13 -0
  174. package/src/layout/README.md +307 -0
  175. package/src/layout/components/ExplorerLayout/ExplorerLayout.tsx +178 -0
  176. package/src/layout/examples/SimpleExample.tsx +60 -0
  177. package/src/layout/index.ts +6 -0
  178. package/src/lib/utils.ts +1 -0
  179. package/src/list/README.md +303 -0
  180. package/src/list/architecture.md +807 -0
  181. package/src/list/components/CalculatedGridView.tsx +252 -0
  182. package/src/list/components/DragPreview.tsx +102 -0
  183. package/src/list/components/ListContextMenu.tsx +274 -0
  184. package/src/list/components/ListItem.tsx +761 -0
  185. package/src/list/components/ListItems.tsx +919 -0
  186. package/src/list/components/MasonryView.tsx +241 -0
  187. package/src/list/components/SearchFilter.tsx +44 -0
  188. package/src/list/components/TreemapView.tsx +709 -0
  189. package/src/list/components/ViewSizeControls.tsx +205 -0
  190. package/src/list/components/ViewTypeSelector.tsx +312 -0
  191. package/src/list/components/VirtualizedDetailsView.tsx +231 -0
  192. package/src/list/components/VirtualizedGrid.tsx +164 -0
  193. package/src/list/components/VirtualizedList.tsx +154 -0
  194. package/src/list/components/VirtualizedMasonryView.tsx +344 -0
  195. package/src/list/components/shared/EmptyState.tsx +103 -0
  196. package/src/list/components/shared/ErrorBoundary.tsx +123 -0
  197. package/src/list/components/shared/ErrorDisplay.tsx +100 -0
  198. package/src/list/components/shared/ListLoader.tsx +146 -0
  199. package/src/list/components/shared/LoadingIndicator.tsx +80 -0
  200. package/src/list/index.ts +92 -0
  201. package/src/list/models/ListItemsModel.ts +1301 -0
  202. package/src/list/models/TreemapModel.ts +204 -0
  203. package/src/list/providers/ListItemsProvider.ts +313 -0
  204. package/src/list/providers/TestListProvider.ts +604 -0
  205. package/src/list/tasks.md +937 -0
  206. package/src/list/types/ListTypes.ts +178 -0
  207. package/src/list/utils/BenchmarkLogger.ts +243 -0
  208. package/src/list/utils/DragDropManager.ts +320 -0
  209. package/src/list/utils/GridLayoutCalculator.ts +290 -0
  210. package/src/list/utils/ListAccessibility.ts +367 -0
  211. package/src/list/utils/ListKeyboard.ts +414 -0
  212. package/src/list/utils/MasonryLayoutCalculator.ts +302 -0
  213. package/src/list/utils/MasonryLayoutEngine.ts +401 -0
  214. package/src/list/utils/__tests__/MasonryLayoutEngine.test.ts +157 -0
  215. package/src/list/utils/__tests__/VirtualizedMasonryView.test.tsx +251 -0
  216. package/src/media/AlbumSidebar.tsx +48 -0
  217. package/src/media/MediaBrowser.tsx +92 -0
  218. package/src/media/MediaBrowserModel.ts +138 -0
  219. package/src/media/MediaGrid.tsx +50 -0
  220. package/src/media/MediaList.tsx +49 -0
  221. package/src/media/MediaPreview.tsx +63 -0
  222. package/src/media/MediaTimeline.tsx +38 -0
  223. package/src/media/MockMediaProvider.ts +70 -0
  224. package/src/media/index.ts +18 -0
  225. package/src/media/types.ts +21 -0
  226. package/src/styles/variables.css +60 -0
  227. package/src/tree/DEVELOPMENT_SUMMARY.md +170 -0
  228. package/src/tree/__tests__/TreeModel.test.ts +16 -0
  229. package/src/tree/architecture.md +530 -0
  230. package/src/tree/components/Tree.tsx +283 -0
  231. package/src/tree/components/TreeCheckbox.tsx +147 -0
  232. package/src/tree/components/TreeContextMenu.tsx +139 -0
  233. package/src/tree/components/TreeNodeList.tsx +329 -0
  234. package/src/tree/components/TreeTable.tsx +382 -0
  235. package/src/tree/index.ts +58 -0
  236. package/src/tree/models/TreeModel.ts +839 -0
  237. package/src/tree/providers/SimpleTreeProvider.ts +463 -0
  238. package/src/tree/providers/TestTreeProvider.ts +946 -0
  239. package/src/tree/providers/TreeProvider.ts +308 -0
  240. package/src/tree/tasks.md +2046 -0
  241. package/src/tree/types/TreeTypes.ts +279 -0
  242. package/src/tree/utils/SelectionTheme.ts +150 -0
  243. package/src/tree/utils/logger.ts +203 -0
  244. package/src/types-common.ts +21 -0
@@ -0,0 +1,376 @@
1
+ import type { IFileBrowserProvider } from './IFileBrowserProvider';
2
+ import type { FileBrowserItem, IconDefinition, PreviewData } from '../types/FileBrowserTypes';
3
+ import type { IFileSystem, IGitRepo } from '@anymux/file-system';
4
+
5
+ interface GitRepositoryOptions {
6
+ repositoryPath: string;
7
+ branch?: string;
8
+ enableLogging?: boolean;
9
+ fileSystem?: IFileSystem;
10
+ gitRepo?: IGitRepo;
11
+ }
12
+
13
+ interface GitFileInfo {
14
+ path: string;
15
+ type: 'file' | 'directory' | 'symlink';
16
+ size?: number;
17
+ lastModified?: Date;
18
+ sha?: string;
19
+ staged?: boolean;
20
+ modified?: boolean;
21
+ }
22
+
23
+ export class GitRepositoryProvider implements IFileBrowserProvider {
24
+ readonly id = 'git-repository';
25
+ readonly name = 'Git Repository Provider';
26
+ readonly version = '1.0.0';
27
+
28
+ private options: GitRepositoryOptions;
29
+ private fileSystem: IFileSystem | undefined;
30
+ private gitRepo: IGitRepo | undefined;
31
+
32
+ constructor(options: GitRepositoryOptions) {
33
+ this.options = {
34
+ branch: 'main',
35
+ enableLogging: false,
36
+ ...options
37
+ };
38
+ this.fileSystem = options.fileSystem;
39
+ this.gitRepo = options.gitRepo;
40
+ }
41
+
42
+ async loadItems(path: string): Promise<FileBrowserItem[]> {
43
+ try {
44
+ const normalizedPath = this.normalizePath(path);
45
+ this.log(`Loading git items for path: ${normalizedPath}`);
46
+
47
+ // Delegate to real file system if provided
48
+ if (this.fileSystem) {
49
+ return this.loadItemsFromFileSystem(normalizedPath);
50
+ }
51
+
52
+ // Fallback to mock data
53
+ const mockGitFiles = await this.getMockGitFiles(normalizedPath);
54
+
55
+ return mockGitFiles.map(file => {
56
+ const item: FileBrowserItem = {
57
+ id: file.path,
58
+ name: this.getFileName(file.path),
59
+ path: file.path,
60
+ type: file.type === 'directory' ? 'directory' as const : 'file' as const,
61
+ hasChildren: file.type === 'directory',
62
+ metadata: {
63
+ sha: file.sha,
64
+ staged: file.staged,
65
+ modified: file.modified,
66
+ gitStatus: this.getGitStatus(file)
67
+ }
68
+ };
69
+ if (file.size != null) item.size = file.size;
70
+ if (file.lastModified != null) item.lastModified = file.lastModified;
71
+ return item;
72
+ });
73
+ } catch (error) {
74
+ this.log(`Error loading git items: ${error}`);
75
+ throw new Error(`Failed to load git repository items: ${error}`);
76
+ }
77
+ }
78
+
79
+ private async loadItemsFromFileSystem(path: string): Promise<FileBrowserItem[]> {
80
+ if (!this.fileSystem) return [];
81
+
82
+ const entries = await this.fileSystem.readdir(path);
83
+ const items: FileBrowserItem[] = [];
84
+
85
+ for (const entry of entries) {
86
+ const entryPath = path === '/' ? `/${entry}` : `${path}/${entry}`;
87
+ try {
88
+ const stat = await this.fileSystem.stat(entryPath);
89
+ const isDir = stat.isDirectory();
90
+ const item: FileBrowserItem = {
91
+ id: entryPath,
92
+ name: String(entry),
93
+ path: entryPath,
94
+ type: isDir ? 'directory' as const : 'file' as const,
95
+ hasChildren: isDir,
96
+ lastModified: stat.mtime,
97
+ };
98
+ if (!isDir) item.size = stat.size;
99
+ items.push(item);
100
+ } catch (err) {
101
+ console.warn(`[GitRepositoryProvider] stat failed for ${entryPath}, skipping:`, err instanceof Error ? err.message : err);
102
+ }
103
+ }
104
+
105
+ return items;
106
+ }
107
+
108
+ normalizePath(path: string): string {
109
+ if (!path || path === '') return '/';
110
+
111
+ let normalized = path.replace(/\\/g, '/');
112
+ normalized = normalized.replace(/\/+/g, '/');
113
+
114
+ if (normalized.length > 1 && normalized.endsWith('/')) {
115
+ normalized = normalized.slice(0, -1);
116
+ }
117
+
118
+ if (!normalized.startsWith('/')) {
119
+ normalized = '/' + normalized;
120
+ }
121
+
122
+ return normalized;
123
+ }
124
+
125
+ getParentPath(path: string): string | null {
126
+ const normalized = this.normalizePath(path);
127
+ if (normalized === '/') return null;
128
+
129
+ const parts = normalized.split('/').filter(Boolean);
130
+ parts.pop();
131
+
132
+ return parts.length === 0 ? '/' : '/' + parts.join('/');
133
+ }
134
+
135
+ resolvePath(basePath: string, relativePath: string): string {
136
+ if (relativePath.startsWith('/')) {
137
+ return this.normalizePath(relativePath);
138
+ }
139
+
140
+ const base = this.normalizePath(basePath);
141
+ const resolved = base === '/' ? `/${relativePath}` : `${base}/${relativePath}`;
142
+ return this.normalizePath(resolved);
143
+ }
144
+
145
+ getItemIcon(item: FileBrowserItem): IconDefinition {
146
+ const gitStatus = item.metadata?.gitStatus;
147
+
148
+ if (item.type === 'directory') {
149
+ if (gitStatus === 'modified') {
150
+ return { type: 'lucide', name: 'folder-edit', color: '#f59e0b' };
151
+ }
152
+ if (gitStatus === 'staged') {
153
+ return { type: 'lucide', name: 'folder-check', color: '#10b981' };
154
+ }
155
+ return { type: 'lucide', name: 'folder-git-2', color: '#3b82f6' };
156
+ }
157
+
158
+ const ext = item.name.split('.').pop()?.toLowerCase();
159
+ const baseIcon = this.getBaseFileIcon(ext);
160
+
161
+ let color = baseIcon.color;
162
+ if (gitStatus === 'modified') {
163
+ color = '#f59e0b';
164
+ } else if (gitStatus === 'staged') {
165
+ color = '#10b981';
166
+ } else if (gitStatus === 'untracked') {
167
+ color = '#ef4444';
168
+ }
169
+
170
+ const result: IconDefinition = { type: baseIcon.type };
171
+ if (baseIcon.name) result.name = baseIcon.name;
172
+ if (color) result.color = color;
173
+ return result;
174
+ }
175
+
176
+ private getBaseFileIcon(ext?: string): IconDefinition {
177
+ const iconMap: Record<string, string> = {
178
+ 'gitignore': 'git-branch',
179
+ 'gitattributes': 'git-branch',
180
+ 'gitmodules': 'git-branch',
181
+ 'js': 'file-code',
182
+ 'ts': 'file-code',
183
+ 'jsx': 'file-code',
184
+ 'tsx': 'file-code',
185
+ 'vue': 'file-code',
186
+ 'html': 'file-code',
187
+ 'css': 'file-code',
188
+ 'scss': 'file-code',
189
+ 'json': 'file-code',
190
+ 'yaml': 'file-code',
191
+ 'yml': 'file-code',
192
+ 'md': 'file-text',
193
+ 'txt': 'file-text',
194
+ 'rst': 'file-text',
195
+ 'png': 'image',
196
+ 'jpg': 'image',
197
+ 'jpeg': 'image',
198
+ 'gif': 'image',
199
+ 'svg': 'image',
200
+ 'webp': 'image',
201
+ 'toml': 'settings',
202
+ 'ini': 'settings',
203
+ 'conf': 'settings',
204
+ 'zip': 'file-archive',
205
+ 'tar': 'file-archive',
206
+ 'gz': 'file-archive',
207
+ 'pdf': 'file-text',
208
+ 'lock': 'lock',
209
+ };
210
+
211
+ return {
212
+ type: 'lucide',
213
+ name: iconMap[ext || ''] || 'file',
214
+ color: '#6b7280'
215
+ };
216
+ }
217
+
218
+ getItemDisplayName(item: FileBrowserItem): string {
219
+ const gitStatus = item.metadata?.gitStatus;
220
+
221
+ const statusIndicators: Record<string, string> = {
222
+ 'modified': ' ●',
223
+ 'staged': ' ✓',
224
+ 'untracked': ' ?',
225
+ 'deleted': ' ✗',
226
+ };
227
+
228
+ const indicator = gitStatus ? statusIndicators[gitStatus] || '' : '';
229
+ return item.name + indicator;
230
+ }
231
+
232
+ async getItemPreview(item: FileBrowserItem): Promise<PreviewData | null> {
233
+ if (item.type === 'file') {
234
+ const ext = item.name.split('.').pop()?.toLowerCase();
235
+
236
+ if (['gitignore', 'gitattributes', 'gitmodules'].includes(ext || '')) {
237
+ return {
238
+ type: 'text',
239
+ content: `Git configuration file: ${item.name}`
240
+ };
241
+ }
242
+
243
+ if (['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'].includes(ext || '')) {
244
+ return {
245
+ type: 'image',
246
+ url: `git-blob://${this.options.repositoryPath}/${item.path}`
247
+ };
248
+ }
249
+
250
+ // Read file content from real file system if available
251
+ if (this.fileSystem && ['txt', 'md', 'json', 'js', 'ts', 'css', 'html', 'yaml', 'yml'].includes(ext || '')) {
252
+ try {
253
+ const content = await this.fileSystem.readFile(item.path, 'utf-8');
254
+ return {
255
+ type: 'text',
256
+ content: typeof content === 'string' ? content.slice(0, 4096) : 'Binary file'
257
+ };
258
+ } catch {
259
+ return { type: 'text', content: 'Unable to read file' };
260
+ }
261
+ }
262
+ }
263
+
264
+ return null;
265
+ }
266
+
267
+ canPerformAction(action: string, items: FileBrowserItem[]): boolean {
268
+ const gitActions = ['stage', 'unstage', 'commit', 'revert', 'diff', 'blame'];
269
+ const basicActions = ['view', 'copy'];
270
+
271
+ const supportedActions = [...gitActions, ...basicActions];
272
+ return supportedActions.includes(action) && items.length > 0;
273
+ }
274
+
275
+ async performAction(action: string, items: FileBrowserItem[]): Promise<any> {
276
+ this.log(`Performing git action ${action} on items:`, items);
277
+
278
+ switch (action) {
279
+ case 'stage':
280
+ return { success: true, message: `Staged ${items.length} files` };
281
+ case 'unstage':
282
+ return { success: true, message: `Unstaged ${items.length} files` };
283
+ case 'commit':
284
+ return { success: true, message: 'Commit created' };
285
+ case 'revert':
286
+ return { success: true, message: `Reverted ${items.length} files` };
287
+ case 'diff':
288
+ return { success: true, data: 'Diff content would go here' };
289
+ case 'blame':
290
+ return { success: true, data: 'Blame information would go here' };
291
+ default:
292
+ return { success: true, message: `${action} completed` };
293
+ }
294
+ }
295
+
296
+ async initialize(): Promise<void> {
297
+ this.log(`Initializing git repository provider for ${this.options.repositoryPath}`);
298
+ }
299
+
300
+ dispose(): void {
301
+ this.log('Disposing git repository provider');
302
+ }
303
+
304
+ // Git-specific methods
305
+ async getCurrentBranch(): Promise<string> {
306
+ if (this.gitRepo) {
307
+ const branches = await this.gitRepo.listBranches();
308
+ const defaultBranch = branches.find(b => b.isDefault);
309
+ return defaultBranch?.name || this.options.branch || 'main';
310
+ }
311
+ return this.options.branch || 'main';
312
+ }
313
+
314
+ async getBranches(): Promise<string[]> {
315
+ if (this.gitRepo) {
316
+ const branches = await this.gitRepo.listBranches();
317
+ return branches.map(b => b.name);
318
+ }
319
+ return ['main', 'develop', 'feature/new-feature'];
320
+ }
321
+
322
+ async switchBranch(branch: string): Promise<void> {
323
+ this.log(`Switching to branch: ${branch}`);
324
+ this.options.branch = branch;
325
+ }
326
+
327
+ async getCommitHistory(path?: string, limit = 50): Promise<any[]> {
328
+ if (this.gitRepo) {
329
+ const options: { path?: string; maxCount?: number } = { maxCount: limit };
330
+ if (path != null) options.path = path;
331
+ return this.gitRepo.listCommits(options);
332
+ }
333
+ return [];
334
+ }
335
+
336
+ // Private helper methods
337
+ private async getMockGitFiles(path: string): Promise<GitFileInfo[]> {
338
+ const mockFiles: Record<string, GitFileInfo[]> = {
339
+ '/': [
340
+ { path: '/src', type: 'directory', lastModified: new Date() },
341
+ { path: '/docs', type: 'directory', lastModified: new Date() },
342
+ { path: '/package.json', type: 'file', size: 1024, lastModified: new Date(), sha: 'abc123', modified: true },
343
+ { path: '/README.md', type: 'file', size: 2048, lastModified: new Date(), sha: 'def456' },
344
+ { path: '/.gitignore', type: 'file', size: 512, lastModified: new Date(), sha: 'ghi789' },
345
+ ],
346
+ '/src': [
347
+ { path: '/src/index.ts', type: 'file', size: 4096, lastModified: new Date(), sha: 'jkl012', staged: true },
348
+ { path: '/src/components', type: 'directory', lastModified: new Date() },
349
+ { path: '/src/utils.ts', type: 'file', size: 1536, lastModified: new Date(), sha: 'mno345', modified: true },
350
+ ],
351
+ '/docs': [
352
+ { path: '/docs/guide.md', type: 'file', size: 8192, lastModified: new Date(), sha: 'pqr678' },
353
+ { path: '/docs/api.md', type: 'file', size: 6144, lastModified: new Date(), sha: 'stu901' },
354
+ ]
355
+ };
356
+
357
+ return mockFiles[path] || [];
358
+ }
359
+
360
+ private getFileName(path: string): string {
361
+ const parts = path.split('/');
362
+ return parts[parts.length - 1] || path;
363
+ }
364
+
365
+ private getGitStatus(file: GitFileInfo): string {
366
+ if (file.staged) return 'staged';
367
+ if (file.modified) return 'modified';
368
+ return 'tracked';
369
+ }
370
+
371
+ private log(message: string, ...args: any[]): void {
372
+ if (this.options.enableLogging) {
373
+ console.log(`[GitRepositoryProvider] ${message}`, ...args);
374
+ }
375
+ }
376
+ }
@@ -0,0 +1,56 @@
1
+ import { FileBrowserItem, IconDefinition, PreviewData } from '../types/FileBrowserTypes';
2
+ import { LeftPanelMode } from '../models/LeftPanelManagerModel';
3
+ import { ViewModeDefinition } from '../models/RightPanelManagerModel';
4
+
5
+ export interface IFileBrowserProvider {
6
+ // Identification
7
+ readonly id: string;
8
+ readonly name: string;
9
+ readonly version: string;
10
+
11
+ // Core data operations
12
+ loadItems(path: string): Promise<FileBrowserItem[]>;
13
+
14
+ // Dual-panel support
15
+ getLeftPanelModes?(): LeftPanelMode[];
16
+ getRightPanelViewModes?(): ViewModeDefinition[];
17
+
18
+ // Path operations
19
+ normalizePath?(path: string): string;
20
+ getParentPath?(path: string): string | null;
21
+ resolvePath?(basePath: string, relativePath: string): string;
22
+
23
+ // Item customization
24
+ getItemIcon?(item: FileBrowserItem): IconDefinition;
25
+ getItemPreview?(item: FileBrowserItem): Promise<PreviewData | null>;
26
+ getItemDisplayName?(item: FileBrowserItem): string;
27
+
28
+ // File preview capabilities
29
+ canPreviewFile?(item: FileBrowserItem): boolean;
30
+ getFilePreview?(item: FileBrowserItem): Promise<PreviewData>;
31
+
32
+ // Optional capabilities
33
+ canPerformAction?(action: string, items: FileBrowserItem[]): boolean;
34
+ performAction?(action: string, items: FileBrowserItem[]): Promise<any>;
35
+
36
+ // Lifecycle
37
+ initialize?(): Promise<void>;
38
+ dispose?(): void;
39
+ }
40
+
41
+ export interface ProviderCapabilities {
42
+ canCreate: boolean;
43
+ canRead: boolean;
44
+ canUpdate: boolean;
45
+ canDelete: boolean;
46
+ canMove: boolean;
47
+ canCopy: boolean;
48
+ canRename: boolean;
49
+ supportsNavigation: boolean;
50
+ supportsSelection: boolean;
51
+ supportsHierarchy: boolean;
52
+ // Panel capabilities
53
+ supportsLeftPanelModes: boolean;
54
+ supportsRightPanelViewModes: boolean;
55
+ supportsFilePreview: boolean;
56
+ }