@tutti-os/workspace-file-manager 0.0.23 → 0.0.24
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/{chunk-VCW64U6E.js → chunk-6X2KFAFG.js} +317 -11
- package/dist/chunk-6X2KFAFG.js.map +1 -0
- package/dist/{chunk-V2LNXNYT.js → chunk-HIYT2WOT.js} +3 -1
- package/dist/chunk-HIYT2WOT.js.map +1 -0
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/{index-BWspwoUn.d.ts → index-D23bxzS8.d.ts} +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +425 -72
- package/dist/index.js.map +1 -1
- package/dist/services/index.d.ts +4 -4
- package/dist/services/index.js +12 -2
- package/dist/{fileKinds-Bu-8Dp5v.d.ts → workspaceFileManagerLocations-VT6VDqTL.d.ts} +49 -3
- package/package.json +4 -4
- package/dist/chunk-V2LNXNYT.js.map +0 -1
- package/dist/chunk-VCW64U6E.js.map +0 -1
|
@@ -3,7 +3,8 @@ import { proxy } from "valtio";
|
|
|
3
3
|
|
|
4
4
|
// src/services/workspaceFileManagerTypes.ts
|
|
5
5
|
var workspaceFileManagerLogicalRoot = "/";
|
|
6
|
-
var workspaceFileManagerPersistedStateSchemaVersion =
|
|
6
|
+
var workspaceFileManagerPersistedStateSchemaVersion = 3;
|
|
7
|
+
var workspaceFileManagerPreviousPersistedStateSchemaVersion = 2;
|
|
7
8
|
|
|
8
9
|
// src/services/internal/model/fileKinds.ts
|
|
9
10
|
import {
|
|
@@ -188,6 +189,18 @@ function isWorkspaceFilePathWithinRoot(path, rootPath) {
|
|
|
188
189
|
return root === workspaceFileManagerLogicalRoot || normalized === root || normalized.startsWith(`${root}/`);
|
|
189
190
|
}
|
|
190
191
|
|
|
192
|
+
// src/services/internal/model/searchEntries.ts
|
|
193
|
+
function workspaceFileSearchEntryToEntry(entry) {
|
|
194
|
+
return {
|
|
195
|
+
hasChildren: entry.kind === "directory",
|
|
196
|
+
kind: entry.kind,
|
|
197
|
+
mtimeMs: null,
|
|
198
|
+
name: entry.name,
|
|
199
|
+
path: entry.path,
|
|
200
|
+
sizeBytes: null
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
191
204
|
// src/services/internal/model/validation.ts
|
|
192
205
|
function validateWorkspaceFileEntryName(name) {
|
|
193
206
|
const trimmed = name.trim();
|
|
@@ -200,6 +213,43 @@ function validateWorkspaceFileEntryName(name) {
|
|
|
200
213
|
return null;
|
|
201
214
|
}
|
|
202
215
|
|
|
216
|
+
// src/services/workspaceFileManagerLocations.ts
|
|
217
|
+
function flattenWorkspaceFileLocations(sections) {
|
|
218
|
+
return sections.flatMap((section) => section.locations);
|
|
219
|
+
}
|
|
220
|
+
function findWorkspaceFileLocationById(sections, locationId) {
|
|
221
|
+
if (!locationId) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
return flattenWorkspaceFileLocations(sections).find(
|
|
225
|
+
(location) => location.id === locationId
|
|
226
|
+
) ?? null;
|
|
227
|
+
}
|
|
228
|
+
function resolveWorkspaceFileLocationDefaultId(input) {
|
|
229
|
+
const { sections } = input;
|
|
230
|
+
const persisted = findWorkspaceFileLocationById(
|
|
231
|
+
sections,
|
|
232
|
+
input.persistedLocationId
|
|
233
|
+
);
|
|
234
|
+
if (persisted) {
|
|
235
|
+
return persisted.id;
|
|
236
|
+
}
|
|
237
|
+
const preferred = findWorkspaceFileLocationById(
|
|
238
|
+
sections,
|
|
239
|
+
input.defaultLocationId
|
|
240
|
+
);
|
|
241
|
+
if (preferred) {
|
|
242
|
+
return preferred.id;
|
|
243
|
+
}
|
|
244
|
+
if (input.fallbackToFirst === false) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
return flattenWorkspaceFileLocations(sections)[0]?.id ?? null;
|
|
248
|
+
}
|
|
249
|
+
function isWorkspaceFileRecentLocation(location) {
|
|
250
|
+
return location?.kind === "recent";
|
|
251
|
+
}
|
|
252
|
+
|
|
203
253
|
// src/services/internal/workspaceFileManagerStore.ts
|
|
204
254
|
function createWorkspaceFileManagerStore(input) {
|
|
205
255
|
const persistedState = normalizeWorkspaceFileManagerPersistedState(
|
|
@@ -208,6 +258,12 @@ function createWorkspaceFileManagerStore(input) {
|
|
|
208
258
|
const initialDirectoryPath = normalizeWorkspaceFilePath(
|
|
209
259
|
input.initialDirectoryPath
|
|
210
260
|
);
|
|
261
|
+
const locationSections = input.locationSections ?? [];
|
|
262
|
+
const selectedLocationId = resolveWorkspaceFileLocationDefaultId({
|
|
263
|
+
defaultLocationId: input.defaultLocationId,
|
|
264
|
+
persistedLocationId: persistedState?.selectedLocationId,
|
|
265
|
+
sections: locationSections
|
|
266
|
+
});
|
|
211
267
|
return proxy({
|
|
212
268
|
busyAction: null,
|
|
213
269
|
capabilities: input.capabilities,
|
|
@@ -226,6 +282,7 @@ function createWorkspaceFileManagerStore(input) {
|
|
|
226
282
|
isLoading: false,
|
|
227
283
|
isMutating: false,
|
|
228
284
|
isSearching: false,
|
|
285
|
+
locationSections,
|
|
229
286
|
navigationBackStack: persistedState?.navigationBackStack ?? [],
|
|
230
287
|
navigationForwardStack: persistedState?.navigationForwardStack ?? [],
|
|
231
288
|
pendingDirectoryPath: null,
|
|
@@ -234,6 +291,7 @@ function createWorkspaceFileManagerStore(input) {
|
|
|
234
291
|
searchEntries: [],
|
|
235
292
|
searchError: null,
|
|
236
293
|
searchQuery: "",
|
|
294
|
+
selectedLocationId,
|
|
237
295
|
selectedPath: null,
|
|
238
296
|
unsupportedDialog: null,
|
|
239
297
|
importConflictDialog: null,
|
|
@@ -254,13 +312,18 @@ function getWorkspaceFileManagerPersistedState(state) {
|
|
|
254
312
|
state.navigationForwardStack,
|
|
255
313
|
state.root
|
|
256
314
|
),
|
|
315
|
+
selectedLocationId: state.selectedLocationId ?? null,
|
|
257
316
|
schemaVersion: workspaceFileManagerPersistedStateSchemaVersion
|
|
258
317
|
};
|
|
259
318
|
}
|
|
260
319
|
function normalizeWorkspaceFileManagerPersistedState(value) {
|
|
261
|
-
if (!isPersistedStateRecord(value) ||
|
|
320
|
+
if (!isPersistedStateRecord(value) || typeof value.currentDirectoryPath !== "string" || !isStringArray(value.navigationBackStack) || !isStringArray(value.navigationForwardStack)) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
if (value.schemaVersion !== workspaceFileManagerPersistedStateSchemaVersion && value.schemaVersion !== workspaceFileManagerPreviousPersistedStateSchemaVersion) {
|
|
262
324
|
return null;
|
|
263
325
|
}
|
|
326
|
+
const selectedLocationId = value.schemaVersion === workspaceFileManagerPersistedStateSchemaVersion ? readOptionalString(value.selectedLocationId) : null;
|
|
264
327
|
return {
|
|
265
328
|
currentDirectoryPath: normalizeWorkspaceFilePath(
|
|
266
329
|
value.currentDirectoryPath
|
|
@@ -269,6 +332,7 @@ function normalizeWorkspaceFileManagerPersistedState(value) {
|
|
|
269
332
|
navigationForwardStack: normalizePersistedStack(
|
|
270
333
|
value.navigationForwardStack
|
|
271
334
|
),
|
|
335
|
+
selectedLocationId,
|
|
272
336
|
schemaVersion: workspaceFileManagerPersistedStateSchemaVersion
|
|
273
337
|
};
|
|
274
338
|
}
|
|
@@ -278,6 +342,9 @@ function isPersistedStateRecord(value) {
|
|
|
278
342
|
function isStringArray(value) {
|
|
279
343
|
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
280
344
|
}
|
|
345
|
+
function readOptionalString(value) {
|
|
346
|
+
return typeof value === "string" && value.trim() ? value : null;
|
|
347
|
+
}
|
|
281
348
|
function normalizePersistedStack(values, root) {
|
|
282
349
|
if (!Array.isArray(values)) {
|
|
283
350
|
return [];
|
|
@@ -505,6 +572,12 @@ function findWorkspaceFileEntry(state, entryPath) {
|
|
|
505
572
|
return nestedEntry;
|
|
506
573
|
}
|
|
507
574
|
}
|
|
575
|
+
const searchEntry = state.searchEntries.find(
|
|
576
|
+
(entry) => entry.path === entryPath
|
|
577
|
+
);
|
|
578
|
+
if (searchEntry) {
|
|
579
|
+
return workspaceFileSearchEntryToEntry(searchEntry);
|
|
580
|
+
}
|
|
508
581
|
return null;
|
|
509
582
|
}
|
|
510
583
|
|
|
@@ -1254,7 +1327,7 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1254
1327
|
this.activationController = new WorkspaceFileManagerActivationController({
|
|
1255
1328
|
copy: () => this.copy,
|
|
1256
1329
|
host: input.host,
|
|
1257
|
-
loadDirectory: (path) => this.
|
|
1330
|
+
loadDirectory: (path) => this.loadDirectory(path),
|
|
1258
1331
|
resolveErrorMessage: (error, overrides) => this.resolveErrorMessage(error, overrides),
|
|
1259
1332
|
resolveFileDefaultOpener: input.resolveFileDefaultOpener,
|
|
1260
1333
|
store: this.store
|
|
@@ -1353,6 +1426,9 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1353
1426
|
this.store.importConflictDialog = null;
|
|
1354
1427
|
}
|
|
1355
1428
|
async confirmCreateDialog() {
|
|
1429
|
+
if (this.isRecentLocationSelected()) {
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1356
1432
|
const createDialog = this.store.createDialog;
|
|
1357
1433
|
if (!createDialog) {
|
|
1358
1434
|
return;
|
|
@@ -1431,12 +1507,21 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1431
1507
|
await this.importController.confirmImportConflict();
|
|
1432
1508
|
}
|
|
1433
1509
|
async createDirectory(path) {
|
|
1510
|
+
if (this.isRecentLocationSelected()) {
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1434
1513
|
await this.mutationController.createDirectory(path);
|
|
1435
1514
|
}
|
|
1436
1515
|
async createFile(path) {
|
|
1516
|
+
if (this.isRecentLocationSelected()) {
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1437
1519
|
await this.mutationController.createFile(path);
|
|
1438
1520
|
}
|
|
1439
1521
|
async deleteSelected() {
|
|
1522
|
+
if (this.isRecentLocationSelected()) {
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1440
1525
|
await this.mutationController.deleteSelected();
|
|
1441
1526
|
}
|
|
1442
1527
|
decrementDragDepth() {
|
|
@@ -1455,9 +1540,11 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1455
1540
|
}
|
|
1456
1541
|
async goBack() {
|
|
1457
1542
|
await this.navigationController.goBack();
|
|
1543
|
+
this.syncSelectedDirectoryLocation();
|
|
1458
1544
|
}
|
|
1459
1545
|
async goForward() {
|
|
1460
1546
|
await this.navigationController.goForward();
|
|
1547
|
+
this.syncSelectedDirectoryLocation();
|
|
1461
1548
|
}
|
|
1462
1549
|
getPersistedState() {
|
|
1463
1550
|
return getWorkspaceFileManagerPersistedState(this.store);
|
|
@@ -1516,7 +1603,7 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1516
1603
|
this.initializePromise = (async () => {
|
|
1517
1604
|
this.observeStore();
|
|
1518
1605
|
if (!this.hasLoadedDirectoryState()) {
|
|
1519
|
-
await this.
|
|
1606
|
+
await this.loadSelectedLocationOrDirectory();
|
|
1520
1607
|
}
|
|
1521
1608
|
await this.previewController.syncPreviewState();
|
|
1522
1609
|
this.hasInitialized = true;
|
|
@@ -1528,13 +1615,18 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1528
1615
|
}
|
|
1529
1616
|
}
|
|
1530
1617
|
async loadDirectory(path = this.store.currentDirectoryPath) {
|
|
1618
|
+
this.clearSearchState();
|
|
1531
1619
|
await this.navigationController.loadDirectory(path);
|
|
1620
|
+
this.syncSelectedDirectoryLocation();
|
|
1532
1621
|
}
|
|
1533
1622
|
openContextMenu(input) {
|
|
1534
1623
|
this.store.contextMenuEntryPath = input.entryPath;
|
|
1535
1624
|
this.store.contextMenu = input;
|
|
1536
1625
|
}
|
|
1537
1626
|
openCreateDirectoryDialog() {
|
|
1627
|
+
if (this.isRecentLocationSelected()) {
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1538
1630
|
this.store.contextMenu = null;
|
|
1539
1631
|
this.store.contextMenuEntryPath = null;
|
|
1540
1632
|
this.store.createDialog = {
|
|
@@ -1544,6 +1636,9 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1544
1636
|
};
|
|
1545
1637
|
}
|
|
1546
1638
|
openCreateFileDialog() {
|
|
1639
|
+
if (this.isRecentLocationSelected()) {
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1547
1642
|
this.store.contextMenu = null;
|
|
1548
1643
|
this.store.contextMenuEntryPath = null;
|
|
1549
1644
|
this.store.createDialog = {
|
|
@@ -1553,6 +1648,9 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1553
1648
|
};
|
|
1554
1649
|
}
|
|
1555
1650
|
openDeleteDialog(entry) {
|
|
1651
|
+
if (this.isRecentLocationSelected()) {
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1556
1654
|
this.store.contextMenu = null;
|
|
1557
1655
|
this.store.contextMenuEntryPath = null;
|
|
1558
1656
|
this.store.deleteDialog = {
|
|
@@ -1560,6 +1658,9 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1560
1658
|
};
|
|
1561
1659
|
}
|
|
1562
1660
|
startInlineRename(entry) {
|
|
1661
|
+
if (this.isRecentLocationSelected()) {
|
|
1662
|
+
return;
|
|
1663
|
+
}
|
|
1563
1664
|
this.store.contextMenu = null;
|
|
1564
1665
|
this.store.contextMenuEntryPath = null;
|
|
1565
1666
|
this.store.inlineRenameEntryPath = entry.path;
|
|
@@ -1673,6 +1774,9 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1673
1774
|
});
|
|
1674
1775
|
}
|
|
1675
1776
|
async moveEntry(entry, targetDirectoryPath) {
|
|
1777
|
+
if (this.isRecentLocationSelected()) {
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1676
1780
|
this.store.busyAction = "move";
|
|
1677
1781
|
try {
|
|
1678
1782
|
await this.mutationController.moveEntry(entry, targetDirectoryPath);
|
|
@@ -1681,10 +1785,16 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1681
1785
|
}
|
|
1682
1786
|
}
|
|
1683
1787
|
async refresh() {
|
|
1788
|
+
const selectedLocation = this.selectedLocation();
|
|
1789
|
+
if (selectedLocation?.kind === "recent") {
|
|
1790
|
+
await this.loadRecentLocation(selectedLocation);
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1684
1793
|
await this.navigationController.refresh();
|
|
1685
1794
|
}
|
|
1686
1795
|
async revealPath(path) {
|
|
1687
1796
|
await this.navigationController.revealPath(path);
|
|
1797
|
+
this.syncSelectedDirectoryLocation();
|
|
1688
1798
|
}
|
|
1689
1799
|
resetDragDepth() {
|
|
1690
1800
|
this.store.dragDepth = 0;
|
|
@@ -1693,21 +1803,20 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1693
1803
|
const requestID = ++this.searchRequestSeq;
|
|
1694
1804
|
this.store.searchQuery = query;
|
|
1695
1805
|
this.store.searchError = null;
|
|
1696
|
-
|
|
1806
|
+
const trimmedQuery = query.trim();
|
|
1807
|
+
if (trimmedQuery === "") {
|
|
1697
1808
|
this.store.searchEntries = [];
|
|
1698
1809
|
this.store.isSearching = false;
|
|
1699
1810
|
return;
|
|
1700
1811
|
}
|
|
1701
1812
|
this.store.isSearching = true;
|
|
1702
1813
|
try {
|
|
1703
|
-
const
|
|
1704
|
-
|
|
1705
|
-
workspaceID: this.store.workspaceID
|
|
1706
|
-
});
|
|
1814
|
+
const selectedLocation = this.selectedLocation();
|
|
1815
|
+
const entries = isWorkspaceFileRecentLocation(selectedLocation) ? await this.searchRecentEntries(trimmedQuery) : await this.searchDirectoryEntries(query, selectedLocation);
|
|
1707
1816
|
if (this.isDisposed || requestID !== this.searchRequestSeq) {
|
|
1708
1817
|
return;
|
|
1709
1818
|
}
|
|
1710
|
-
this.store.searchEntries =
|
|
1819
|
+
this.store.searchEntries = entries;
|
|
1711
1820
|
} catch (error) {
|
|
1712
1821
|
if (!this.isDisposed && requestID === this.searchRequestSeq) {
|
|
1713
1822
|
this.store.searchError = this.resolveErrorMessage(error);
|
|
@@ -1725,6 +1834,28 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1725
1834
|
}
|
|
1726
1835
|
this.store.selectedPath = nextSelectedPath;
|
|
1727
1836
|
}
|
|
1837
|
+
async selectLocation(locationId) {
|
|
1838
|
+
const location = findWorkspaceFileLocationById(
|
|
1839
|
+
this.store.locationSections,
|
|
1840
|
+
locationId
|
|
1841
|
+
);
|
|
1842
|
+
if (!location) {
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
this.store.selectedLocationId = location.id;
|
|
1846
|
+
this.store.contextMenu = null;
|
|
1847
|
+
this.store.contextMenuEntryPath = null;
|
|
1848
|
+
this.store.createDialog = null;
|
|
1849
|
+
this.store.deleteDialog = null;
|
|
1850
|
+
this.store.inlineRenameEntryPath = null;
|
|
1851
|
+
this.store.inlineRenameValidation = null;
|
|
1852
|
+
this.clearSearchState();
|
|
1853
|
+
if (location.kind === "recent") {
|
|
1854
|
+
await this.loadRecentLocation(location);
|
|
1855
|
+
return;
|
|
1856
|
+
}
|
|
1857
|
+
await this.navigationController.loadDirectory(location.path);
|
|
1858
|
+
}
|
|
1728
1859
|
setActive(active) {
|
|
1729
1860
|
if (this.isActive === active) {
|
|
1730
1861
|
return;
|
|
@@ -1744,6 +1875,31 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1744
1875
|
this.copy = copy;
|
|
1745
1876
|
void this.previewController.syncPreviewState();
|
|
1746
1877
|
}
|
|
1878
|
+
async setLocations(input) {
|
|
1879
|
+
const previousLocationId = this.store.selectedLocationId;
|
|
1880
|
+
const previousLocation = findWorkspaceFileLocationById(
|
|
1881
|
+
this.store.locationSections,
|
|
1882
|
+
previousLocationId
|
|
1883
|
+
);
|
|
1884
|
+
this.store.locationSections = input.sections;
|
|
1885
|
+
const nextLocationId = resolveWorkspaceFileLocationDefaultId({
|
|
1886
|
+
defaultLocationId: input.defaultLocationId,
|
|
1887
|
+
persistedLocationId: previousLocationId,
|
|
1888
|
+
sections: input.sections
|
|
1889
|
+
});
|
|
1890
|
+
const nextLocation = findWorkspaceFileLocationById(
|
|
1891
|
+
input.sections,
|
|
1892
|
+
nextLocationId
|
|
1893
|
+
);
|
|
1894
|
+
this.store.selectedLocationId = nextLocationId;
|
|
1895
|
+
if (!this.hasInitialized || !nextLocationId) {
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1898
|
+
const selectedLocationChanged = previousLocationId !== nextLocationId || previousLocation?.kind !== nextLocation?.kind || previousLocation?.kind === "directory" && nextLocation?.kind === "directory" && !areWorkspaceFilePathsEqual(previousLocation.path, nextLocation.path);
|
|
1899
|
+
if (selectedLocationChanged) {
|
|
1900
|
+
await this.selectLocation(nextLocationId);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1747
1903
|
updateCreateDialogName(name) {
|
|
1748
1904
|
if (!this.store.createDialog) {
|
|
1749
1905
|
return;
|
|
@@ -1758,12 +1914,18 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1758
1914
|
this.store.inlineRenameValidation = null;
|
|
1759
1915
|
}
|
|
1760
1916
|
async importDroppedFiles(dataTransfer, targetDirectoryPath) {
|
|
1917
|
+
if (this.isRecentLocationSelected()) {
|
|
1918
|
+
return { supported: false };
|
|
1919
|
+
}
|
|
1761
1920
|
return this.importController.importDroppedFiles(
|
|
1762
1921
|
dataTransfer,
|
|
1763
1922
|
targetDirectoryPath
|
|
1764
1923
|
);
|
|
1765
1924
|
}
|
|
1766
1925
|
async importFiles(targetDirectoryPath) {
|
|
1926
|
+
if (this.isRecentLocationSelected()) {
|
|
1927
|
+
return { supported: false };
|
|
1928
|
+
}
|
|
1767
1929
|
return this.importController.importFiles(targetDirectoryPath);
|
|
1768
1930
|
}
|
|
1769
1931
|
applyHostActionResult(result, fallback) {
|
|
@@ -1792,6 +1954,134 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1792
1954
|
hasLoadedDirectoryState() {
|
|
1793
1955
|
return this.store.error !== null || this.store.entries.length > 0 || this.store.selectedPath !== null;
|
|
1794
1956
|
}
|
|
1957
|
+
async loadSelectedLocationOrDirectory() {
|
|
1958
|
+
const selectedLocation = this.selectedLocation();
|
|
1959
|
+
if (selectedLocation?.kind === "recent") {
|
|
1960
|
+
await this.loadRecentLocation(selectedLocation);
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
await this.navigationController.loadDirectory(
|
|
1964
|
+
this.resolveInitialDirectoryPath(selectedLocation)
|
|
1965
|
+
);
|
|
1966
|
+
}
|
|
1967
|
+
async loadRecentLocation(location) {
|
|
1968
|
+
this.store.isLoading = true;
|
|
1969
|
+
this.store.error = null;
|
|
1970
|
+
try {
|
|
1971
|
+
const listing = await this.host.listRecentEntries?.({
|
|
1972
|
+
workspaceID: this.store.workspaceID
|
|
1973
|
+
});
|
|
1974
|
+
this.store.root = normalizeWorkspaceFilePath(
|
|
1975
|
+
listing?.root ?? this.store.root
|
|
1976
|
+
);
|
|
1977
|
+
this.store.currentDirectoryPath = listing?.directoryPath ?? this.store.root;
|
|
1978
|
+
this.store.entries = listing?.entries ?? [];
|
|
1979
|
+
this.store.directoryExpansionByPath = {};
|
|
1980
|
+
this.store.expandedDirectoryPaths = {};
|
|
1981
|
+
this.store.navigationBackStack = [];
|
|
1982
|
+
this.store.navigationForwardStack = [];
|
|
1983
|
+
this.store.selectedLocationId = location.id;
|
|
1984
|
+
this.store.selectedPath = null;
|
|
1985
|
+
} catch (error) {
|
|
1986
|
+
this.store.error = this.resolveErrorMessage(error);
|
|
1987
|
+
} finally {
|
|
1988
|
+
this.store.isLoading = false;
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
selectedLocation() {
|
|
1992
|
+
return findWorkspaceFileLocationById(
|
|
1993
|
+
this.store.locationSections,
|
|
1994
|
+
this.store.selectedLocationId
|
|
1995
|
+
);
|
|
1996
|
+
}
|
|
1997
|
+
isRecentLocationSelected() {
|
|
1998
|
+
return isWorkspaceFileRecentLocation(this.selectedLocation());
|
|
1999
|
+
}
|
|
2000
|
+
resolveInitialDirectoryPath(selectedLocation) {
|
|
2001
|
+
if (selectedLocation?.kind !== "directory") {
|
|
2002
|
+
return this.store.currentDirectoryPath;
|
|
2003
|
+
}
|
|
2004
|
+
return isWorkspaceFilePathWithinDirectory(
|
|
2005
|
+
this.store.currentDirectoryPath,
|
|
2006
|
+
selectedLocation.path
|
|
2007
|
+
) ? this.store.currentDirectoryPath : selectedLocation.path;
|
|
2008
|
+
}
|
|
2009
|
+
syncSelectedDirectoryLocation() {
|
|
2010
|
+
if (this.store.error) {
|
|
2011
|
+
return;
|
|
2012
|
+
}
|
|
2013
|
+
this.store.selectedLocationId = this.resolveDirectoryLocationIdForPath(
|
|
2014
|
+
this.store.currentDirectoryPath
|
|
2015
|
+
);
|
|
2016
|
+
}
|
|
2017
|
+
resolveDirectoryLocationIdForPath(path) {
|
|
2018
|
+
let bestLocation = null;
|
|
2019
|
+
for (const section of this.store.locationSections) {
|
|
2020
|
+
for (const location of section.locations) {
|
|
2021
|
+
if (location.kind !== "directory") {
|
|
2022
|
+
continue;
|
|
2023
|
+
}
|
|
2024
|
+
const normalizedLocationPath = normalizeWorkspaceFilePath(
|
|
2025
|
+
location.path,
|
|
2026
|
+
this.store.root
|
|
2027
|
+
);
|
|
2028
|
+
if (!isWorkspaceFilePathWithinDirectory(path, normalizedLocationPath)) {
|
|
2029
|
+
continue;
|
|
2030
|
+
}
|
|
2031
|
+
if (!bestLocation || normalizedLocationPath.length > bestLocation.path.length) {
|
|
2032
|
+
bestLocation = {
|
|
2033
|
+
id: location.id,
|
|
2034
|
+
path: normalizedLocationPath
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
return bestLocation?.id ?? null;
|
|
2040
|
+
}
|
|
2041
|
+
clearSearchState() {
|
|
2042
|
+
if (this.store.searchQuery === "" && this.store.searchEntries.length === 0 && this.store.searchError === null && !this.store.isSearching) {
|
|
2043
|
+
return;
|
|
2044
|
+
}
|
|
2045
|
+
this.searchRequestSeq += 1;
|
|
2046
|
+
this.store.searchEntries = [];
|
|
2047
|
+
this.store.searchError = null;
|
|
2048
|
+
this.store.searchQuery = "";
|
|
2049
|
+
this.store.isSearching = false;
|
|
2050
|
+
}
|
|
2051
|
+
async searchDirectoryEntries(query, selectedLocation) {
|
|
2052
|
+
if (!this.host.search) {
|
|
2053
|
+
return [];
|
|
2054
|
+
}
|
|
2055
|
+
const result = await this.host.search({
|
|
2056
|
+
query,
|
|
2057
|
+
workspaceID: this.store.workspaceID,
|
|
2058
|
+
...selectedLocation?.kind === "directory" ? { within: selectedLocation.path } : {}
|
|
2059
|
+
});
|
|
2060
|
+
return result.entries;
|
|
2061
|
+
}
|
|
2062
|
+
async searchRecentEntries(query) {
|
|
2063
|
+
if (!this.host.listRecentEntries) {
|
|
2064
|
+
return [];
|
|
2065
|
+
}
|
|
2066
|
+
const listing = await this.host.listRecentEntries({
|
|
2067
|
+
limit: 100,
|
|
2068
|
+
workspaceID: this.store.workspaceID
|
|
2069
|
+
});
|
|
2070
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
2071
|
+
return listing.entries.filter((entry) => {
|
|
2072
|
+
const name = entry.name.toLowerCase();
|
|
2073
|
+
const path = entry.path.toLowerCase();
|
|
2074
|
+
return name.includes(normalizedQuery) || path.includes(normalizedQuery);
|
|
2075
|
+
}).map((entry, index) => ({
|
|
2076
|
+
directoryPath: workspaceFileDirectory(entry.path, listing.root),
|
|
2077
|
+
kind: entry.kind,
|
|
2078
|
+
matchIndices: [],
|
|
2079
|
+
matchTarget: entry.name.toLowerCase().includes(normalizedQuery) ? "basename" : "path",
|
|
2080
|
+
name: entry.name,
|
|
2081
|
+
path: entry.path,
|
|
2082
|
+
score: listing.entries.length - index
|
|
2083
|
+
}));
|
|
2084
|
+
}
|
|
1795
2085
|
notifyHostActionMessages(result, fallback) {
|
|
1796
2086
|
if (!this.onHostActionMessage) {
|
|
1797
2087
|
return;
|
|
@@ -1889,6 +2179,14 @@ var DefaultWorkspaceFileManagerSession = class {
|
|
|
1889
2179
|
function serializePersistedState(state) {
|
|
1890
2180
|
return JSON.stringify(state);
|
|
1891
2181
|
}
|
|
2182
|
+
function areWorkspaceFilePathsEqual(left, right) {
|
|
2183
|
+
return normalizeWorkspaceFilePath(left) === normalizeWorkspaceFilePath(right);
|
|
2184
|
+
}
|
|
2185
|
+
function isWorkspaceFilePathWithinDirectory(path, directoryPath) {
|
|
2186
|
+
const normalizedPath = normalizeWorkspaceFilePath(path);
|
|
2187
|
+
const normalizedDirectoryPath = normalizeWorkspaceFilePath(directoryPath);
|
|
2188
|
+
return normalizedPath === normalizedDirectoryPath || normalizedDirectoryPath === "/" || normalizedPath.startsWith(`${normalizedDirectoryPath}/`);
|
|
2189
|
+
}
|
|
1892
2190
|
|
|
1893
2191
|
// src/services/internal/workspaceFileManagerService.ts
|
|
1894
2192
|
var DefaultWorkspaceFileManagerService = class {
|
|
@@ -1896,7 +2194,9 @@ var DefaultWorkspaceFileManagerService = class {
|
|
|
1896
2194
|
const capabilities = capabilitiesFromHost(input);
|
|
1897
2195
|
const store = createWorkspaceFileManagerStore({
|
|
1898
2196
|
capabilities,
|
|
2197
|
+
defaultLocationId: input.defaultLocationId,
|
|
1899
2198
|
initialDirectoryPath: input.initialDirectoryPath,
|
|
2199
|
+
locationSections: input.locationSections,
|
|
1900
2200
|
persistedState: normalizeWorkspaceFileManagerPersistedState(
|
|
1901
2201
|
input.persistedState ?? input.persistence?.load?.()
|
|
1902
2202
|
),
|
|
@@ -2141,6 +2441,7 @@ export {
|
|
|
2141
2441
|
resolveWorkspaceFileExtension,
|
|
2142
2442
|
resolveWorkspaceFileVisualKind,
|
|
2143
2443
|
resolveWorkspaceImageMimeType,
|
|
2444
|
+
resolveWorkspaceVideoMimeType,
|
|
2144
2445
|
workspaceFilePreviewMaxBytes,
|
|
2145
2446
|
workspaceFileTextMaxBytes,
|
|
2146
2447
|
formatWorkspaceFileBytes,
|
|
@@ -2149,6 +2450,11 @@ export {
|
|
|
2149
2450
|
normalizeWorkspaceFilePath,
|
|
2150
2451
|
workspaceFileName,
|
|
2151
2452
|
buildWorkspaceFileBreadcrumbs,
|
|
2453
|
+
workspaceFileSearchEntryToEntry,
|
|
2454
|
+
flattenWorkspaceFileLocations,
|
|
2455
|
+
findWorkspaceFileLocationById,
|
|
2456
|
+
resolveWorkspaceFileLocationDefaultId,
|
|
2457
|
+
isWorkspaceFileRecentLocation,
|
|
2152
2458
|
findWorkspaceFileEntry,
|
|
2153
2459
|
createWorkspaceFileManagerService,
|
|
2154
2460
|
shouldResolveWorkspaceFileEntryIcon,
|
|
@@ -2162,4 +2468,4 @@ export {
|
|
|
2162
2468
|
sortWorkspaceFileEntriesForArrangeMode,
|
|
2163
2469
|
resolveWorkspaceFileEntryArrangeDateMs
|
|
2164
2470
|
};
|
|
2165
|
-
//# sourceMappingURL=chunk-
|
|
2471
|
+
//# sourceMappingURL=chunk-6X2KFAFG.js.map
|