@lvce-editor/file-search-worker 3.19.0 → 4.0.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.
- package/dist/fileSearchWorkerMain.js +101 -769
- package/package.json +1 -1
|
@@ -448,7 +448,7 @@ const set$2 = (id, fn) => {
|
|
|
448
448
|
const get$2 = id => {
|
|
449
449
|
return callbacks[id];
|
|
450
450
|
};
|
|
451
|
-
const remove
|
|
451
|
+
const remove = id => {
|
|
452
452
|
delete callbacks[id];
|
|
453
453
|
};
|
|
454
454
|
let id = 0;
|
|
@@ -625,7 +625,7 @@ const resolve = (id, response) => {
|
|
|
625
625
|
return;
|
|
626
626
|
}
|
|
627
627
|
fn(response);
|
|
628
|
-
remove
|
|
628
|
+
remove(id);
|
|
629
629
|
};
|
|
630
630
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
631
631
|
const getErrorType = prettyError => {
|
|
@@ -899,14 +899,14 @@ const warn = (...args) => {
|
|
|
899
899
|
console.warn(...args);
|
|
900
900
|
};
|
|
901
901
|
|
|
902
|
-
const state$
|
|
902
|
+
const state$9 = {
|
|
903
903
|
menuEntries: []
|
|
904
904
|
};
|
|
905
905
|
const getAll = () => {
|
|
906
|
-
return state$
|
|
906
|
+
return state$9.menuEntries;
|
|
907
907
|
};
|
|
908
908
|
const add = menuEntries => {
|
|
909
|
-
state$
|
|
909
|
+
state$9.menuEntries = [...state$9.menuEntries, ...menuEntries];
|
|
910
910
|
};
|
|
911
911
|
|
|
912
912
|
const Hide = 'hide';
|
|
@@ -1102,8 +1102,8 @@ const QuickPickEntriesCommand = {
|
|
|
1102
1102
|
selectPick: selectPick$b
|
|
1103
1103
|
};
|
|
1104
1104
|
|
|
1105
|
-
const Directory
|
|
1106
|
-
const File$
|
|
1105
|
+
const Directory = 3;
|
|
1106
|
+
const File$2 = 7;
|
|
1107
1107
|
|
|
1108
1108
|
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1109
1109
|
const getProtocol = uri => {
|
|
@@ -1118,12 +1118,12 @@ const openUri = async uri => {
|
|
|
1118
1118
|
await invoke$1(/* Main.openUri */'Main.openUri', /* uri */uri);
|
|
1119
1119
|
};
|
|
1120
1120
|
|
|
1121
|
-
const state$
|
|
1121
|
+
const state$8 = Object.create(null);
|
|
1122
1122
|
const register$1 = modules => {
|
|
1123
|
-
Object.assign(state$
|
|
1123
|
+
Object.assign(state$8, modules);
|
|
1124
1124
|
};
|
|
1125
1125
|
const getModule = protocol => {
|
|
1126
|
-
return state$
|
|
1126
|
+
return state$8[protocol];
|
|
1127
1127
|
};
|
|
1128
1128
|
|
|
1129
1129
|
const searchFile$5 = async (path, value, prepare, assetDir) => {
|
|
@@ -1231,7 +1231,7 @@ const getPickFileIcon$2 = pick => {
|
|
|
1231
1231
|
}
|
|
1232
1232
|
const baseName = pathBaseName(pick);
|
|
1233
1233
|
return {
|
|
1234
|
-
type: File$
|
|
1234
|
+
type: File$2,
|
|
1235
1235
|
name: baseName
|
|
1236
1236
|
};
|
|
1237
1237
|
};
|
|
@@ -1378,7 +1378,7 @@ const selectPick$7 = async item => {
|
|
|
1378
1378
|
const getFilterValue$7 = value => {
|
|
1379
1379
|
return value;
|
|
1380
1380
|
};
|
|
1381
|
-
const state$
|
|
1381
|
+
const state$7 = {};
|
|
1382
1382
|
const getPickDescription$7 = value => {
|
|
1383
1383
|
return '';
|
|
1384
1384
|
};
|
|
@@ -1409,7 +1409,7 @@ const QuickPickEntriesSymbol = {
|
|
|
1409
1409
|
isPrepared: isPrepared$6,
|
|
1410
1410
|
name: name$7,
|
|
1411
1411
|
selectPick: selectPick$7,
|
|
1412
|
-
state: state$
|
|
1412
|
+
state: state$7
|
|
1413
1413
|
};
|
|
1414
1414
|
|
|
1415
1415
|
// TODO probably not needed
|
|
@@ -1444,7 +1444,7 @@ const getPickLabel$5 = value => {
|
|
|
1444
1444
|
const getPickIcon$5 = value => {
|
|
1445
1445
|
return '';
|
|
1446
1446
|
};
|
|
1447
|
-
const state$
|
|
1447
|
+
const state$6 = {};
|
|
1448
1448
|
const getNoResults$6 = () => {
|
|
1449
1449
|
return '';
|
|
1450
1450
|
};
|
|
@@ -1470,7 +1470,7 @@ const QuickPickEntriesView = {
|
|
|
1470
1470
|
isPrepared: isPrepared$5,
|
|
1471
1471
|
name: name$6,
|
|
1472
1472
|
selectPick: selectPick$6,
|
|
1473
|
-
state: state$
|
|
1473
|
+
state: state$6
|
|
1474
1474
|
};
|
|
1475
1475
|
|
|
1476
1476
|
const name$5 = 'workspace-symbol';
|
|
@@ -1510,7 +1510,7 @@ const QuickPickEntriesWorkspaceSymbol = {
|
|
|
1510
1510
|
};
|
|
1511
1511
|
|
|
1512
1512
|
const Command = '>';
|
|
1513
|
-
const Symbol$
|
|
1513
|
+
const Symbol$1 = '@';
|
|
1514
1514
|
const WorkspaceSymbol$1 = '#';
|
|
1515
1515
|
const GoToLine = ':';
|
|
1516
1516
|
const View$1 = 'view ';
|
|
@@ -1518,7 +1518,7 @@ const None$2 = '';
|
|
|
1518
1518
|
|
|
1519
1519
|
// TODO avoid global variable
|
|
1520
1520
|
|
|
1521
|
-
const state$
|
|
1521
|
+
const state$5 = {
|
|
1522
1522
|
// providerId: PROVIDER_NOOP,
|
|
1523
1523
|
provider: QuickPickNoop,
|
|
1524
1524
|
prefix: 'string-that-should-never-match-another-string'
|
|
@@ -1529,23 +1529,23 @@ const state$7 = {
|
|
|
1529
1529
|
*/
|
|
1530
1530
|
const name$4 = 'everything';
|
|
1531
1531
|
const getPlaceholder$4 = () => {
|
|
1532
|
-
return state$
|
|
1532
|
+
return state$5.provider.getPlaceholder();
|
|
1533
1533
|
};
|
|
1534
1534
|
const getLabel$3 = () => {
|
|
1535
1535
|
return '';
|
|
1536
1536
|
};
|
|
1537
1537
|
const getHelpEntries$4 = () => {
|
|
1538
|
-
return state$
|
|
1538
|
+
return state$5.provider.getHelpEntries();
|
|
1539
1539
|
};
|
|
1540
1540
|
const getNoResults$4 = () => {
|
|
1541
|
-
return state$
|
|
1541
|
+
return state$5.provider.getNoResults();
|
|
1542
1542
|
};
|
|
1543
1543
|
const getPrefix = value => {
|
|
1544
1544
|
if (value.startsWith(Command)) {
|
|
1545
1545
|
return Command;
|
|
1546
1546
|
}
|
|
1547
|
-
if (value.startsWith(Symbol$
|
|
1548
|
-
return Symbol$
|
|
1547
|
+
if (value.startsWith(Symbol$1)) {
|
|
1548
|
+
return Symbol$1;
|
|
1549
1549
|
}
|
|
1550
1550
|
if (value.startsWith(WorkspaceSymbol$1)) {
|
|
1551
1551
|
return WorkspaceSymbol$1;
|
|
@@ -1565,7 +1565,7 @@ const getQuickPickProvider = prefix => {
|
|
|
1565
1565
|
switch (prefix) {
|
|
1566
1566
|
case Command:
|
|
1567
1567
|
return QuickPickEntriesCommand;
|
|
1568
|
-
case Symbol$
|
|
1568
|
+
case Symbol$1:
|
|
1569
1569
|
return QuickPickEntriesSymbol;
|
|
1570
1570
|
case WorkspaceSymbol$1:
|
|
1571
1571
|
return QuickPickEntriesWorkspaceSymbol;
|
|
@@ -1581,20 +1581,20 @@ const getPicks$4 = async value => {
|
|
|
1581
1581
|
const prefix = getPrefix(value);
|
|
1582
1582
|
|
|
1583
1583
|
// TODO race condition
|
|
1584
|
-
if (state$
|
|
1585
|
-
state$
|
|
1584
|
+
if (state$5.prefix !== prefix) {
|
|
1585
|
+
state$5.prefix = prefix;
|
|
1586
1586
|
// @ts-ignore
|
|
1587
|
-
state$
|
|
1587
|
+
state$5.provider = await getQuickPickProvider(prefix);
|
|
1588
1588
|
}
|
|
1589
1589
|
// TODO this line is a bit duplicated with getFilterValue
|
|
1590
1590
|
const slicedValue = value.slice(prefix.length).trimStart();
|
|
1591
|
-
const picks = await state$
|
|
1591
|
+
const picks = await state$5.provider.getPicks(slicedValue);
|
|
1592
1592
|
return picks;
|
|
1593
1593
|
};
|
|
1594
1594
|
const selectPick$4 = item => {
|
|
1595
1595
|
const {
|
|
1596
1596
|
provider
|
|
1597
|
-
} = state$
|
|
1597
|
+
} = state$5;
|
|
1598
1598
|
return provider.selectPick(item);
|
|
1599
1599
|
};
|
|
1600
1600
|
const openCommandPalette = () => {
|
|
@@ -1604,18 +1604,18 @@ const openView = () => {
|
|
|
1604
1604
|
// show('view ')
|
|
1605
1605
|
};
|
|
1606
1606
|
const getFilterValue$4 = value => {
|
|
1607
|
-
return value.slice(state$
|
|
1607
|
+
return value.slice(state$5.prefix.length);
|
|
1608
1608
|
};
|
|
1609
1609
|
const getPickFilterValue$4 = pick => {
|
|
1610
1610
|
const {
|
|
1611
1611
|
provider
|
|
1612
|
-
} = state$
|
|
1612
|
+
} = state$5;
|
|
1613
1613
|
return provider.getPickFilterValue(pick);
|
|
1614
1614
|
};
|
|
1615
1615
|
const getPickDescription$5 = pick => {
|
|
1616
1616
|
const {
|
|
1617
1617
|
provider
|
|
1618
|
-
} = state$
|
|
1618
|
+
} = state$5;
|
|
1619
1619
|
// @ts-ignore
|
|
1620
1620
|
if (provider.getPickDescription) {
|
|
1621
1621
|
// @ts-ignore
|
|
@@ -1626,21 +1626,21 @@ const getPickDescription$5 = pick => {
|
|
|
1626
1626
|
const getPickLabel$4 = pick => {
|
|
1627
1627
|
const {
|
|
1628
1628
|
provider
|
|
1629
|
-
} = state$
|
|
1629
|
+
} = state$5;
|
|
1630
1630
|
// @ts-ignore
|
|
1631
1631
|
return provider.getPickLabel(pick);
|
|
1632
1632
|
};
|
|
1633
1633
|
const getPickIcon$4 = pick => {
|
|
1634
1634
|
const {
|
|
1635
1635
|
provider
|
|
1636
|
-
} = state$
|
|
1636
|
+
} = state$5;
|
|
1637
1637
|
// @ts-ignore
|
|
1638
1638
|
return provider.getPickIcon(pick);
|
|
1639
1639
|
};
|
|
1640
1640
|
const getPickFileIcon$1 = pick => {
|
|
1641
1641
|
const {
|
|
1642
1642
|
provider
|
|
1643
|
-
} = state$
|
|
1643
|
+
} = state$5;
|
|
1644
1644
|
// @ts-ignore
|
|
1645
1645
|
if (provider.getPickFileIcon) {
|
|
1646
1646
|
// @ts-ignore
|
|
@@ -1651,7 +1651,7 @@ const getPickFileIcon$1 = pick => {
|
|
|
1651
1651
|
const isPrepared$4 = () => {
|
|
1652
1652
|
const {
|
|
1653
1653
|
provider
|
|
1654
|
-
} = state$
|
|
1654
|
+
} = state$5;
|
|
1655
1655
|
// @ts-ignore
|
|
1656
1656
|
if (provider.isPrepared) {
|
|
1657
1657
|
// @ts-ignore
|
|
@@ -1678,7 +1678,7 @@ const QuickPickEntriesEverything = {
|
|
|
1678
1678
|
openCommandPalette,
|
|
1679
1679
|
openView,
|
|
1680
1680
|
selectPick: selectPick$4,
|
|
1681
|
-
state: state$
|
|
1681
|
+
state: state$5
|
|
1682
1682
|
};
|
|
1683
1683
|
|
|
1684
1684
|
const Default$1 = 0;
|
|
@@ -1837,287 +1837,6 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) =
|
|
|
1837
1837
|
return state;
|
|
1838
1838
|
};
|
|
1839
1839
|
|
|
1840
|
-
const assetDir = '';
|
|
1841
|
-
|
|
1842
|
-
const fileMapUrl = `${assetDir}/config/fileMap.json`;
|
|
1843
|
-
|
|
1844
|
-
const getBlob$2 = async url => {
|
|
1845
|
-
try {
|
|
1846
|
-
const response = await fetch(url);
|
|
1847
|
-
if (!response.ok) {
|
|
1848
|
-
throw new Error(response.statusText);
|
|
1849
|
-
}
|
|
1850
|
-
const text = await response.blob();
|
|
1851
|
-
return text;
|
|
1852
|
-
} catch (error) {
|
|
1853
|
-
throw new VError(error, `Failed to request blob for ${url}`);
|
|
1854
|
-
}
|
|
1855
|
-
};
|
|
1856
|
-
|
|
1857
|
-
const getJson = async url => {
|
|
1858
|
-
try {
|
|
1859
|
-
const response = await fetch(url);
|
|
1860
|
-
if (!response.ok) {
|
|
1861
|
-
throw new Error(response.statusText);
|
|
1862
|
-
}
|
|
1863
|
-
const text = await response.json();
|
|
1864
|
-
return text;
|
|
1865
|
-
} catch (error) {
|
|
1866
|
-
throw new VError(error, `Failed to request json for ${url}`);
|
|
1867
|
-
}
|
|
1868
|
-
};
|
|
1869
|
-
|
|
1870
|
-
const getText = async url => {
|
|
1871
|
-
try {
|
|
1872
|
-
const response = await fetch(url);
|
|
1873
|
-
if (!response.ok) {
|
|
1874
|
-
throw new Error(response.statusText);
|
|
1875
|
-
}
|
|
1876
|
-
const text = await response.text();
|
|
1877
|
-
return text;
|
|
1878
|
-
} catch (error) {
|
|
1879
|
-
throw new VError(error, `Failed to request text for ${url}`);
|
|
1880
|
-
}
|
|
1881
|
-
};
|
|
1882
|
-
|
|
1883
|
-
const Slash$1 = '/';
|
|
1884
|
-
|
|
1885
|
-
const Slash = Slash$1;
|
|
1886
|
-
|
|
1887
|
-
// TODO move all of this to an extension
|
|
1888
|
-
|
|
1889
|
-
const readFile$1 = async uri => {
|
|
1890
|
-
const fetchUri = `${assetDir}${uri}`;
|
|
1891
|
-
const text = await getText(fetchUri);
|
|
1892
|
-
return text;
|
|
1893
|
-
};
|
|
1894
|
-
const writeFile$1 = () => {
|
|
1895
|
-
throw new Error('not implemented');
|
|
1896
|
-
};
|
|
1897
|
-
const mkdir$1 = () => {
|
|
1898
|
-
throw new Error('not implemented');
|
|
1899
|
-
};
|
|
1900
|
-
const remove$1 = () => {
|
|
1901
|
-
throw new Error('not implemented');
|
|
1902
|
-
};
|
|
1903
|
-
const readDirWithFileTypes$1 = async uri => {
|
|
1904
|
-
const fileList = await getJson(fileMapUrl);
|
|
1905
|
-
const dirents = [];
|
|
1906
|
-
for (const fileUri of fileList) {
|
|
1907
|
-
if (fileUri.startsWith(uri)) {
|
|
1908
|
-
const rest = fileUri.slice(uri.length + 1);
|
|
1909
|
-
if (rest.includes(Slash)) {
|
|
1910
|
-
const name = rest.slice(0, rest.indexOf(Slash));
|
|
1911
|
-
if (dirents.some(dirent => dirent.name === name)) {
|
|
1912
|
-
continue;
|
|
1913
|
-
}
|
|
1914
|
-
dirents.push({
|
|
1915
|
-
type: Directory$1,
|
|
1916
|
-
name
|
|
1917
|
-
});
|
|
1918
|
-
} else {
|
|
1919
|
-
dirents.push({
|
|
1920
|
-
type: File$3,
|
|
1921
|
-
name: rest
|
|
1922
|
-
});
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
return dirents;
|
|
1927
|
-
};
|
|
1928
|
-
const chmod$1 = () => {
|
|
1929
|
-
throw new Error('[memfs] chmod not implemented');
|
|
1930
|
-
};
|
|
1931
|
-
const getBlob$1 = async (uri, type) => {
|
|
1932
|
-
const fetchUri = `${assetDir}${uri}`;
|
|
1933
|
-
const blob = getBlob$2(fetchUri);
|
|
1934
|
-
return blob;
|
|
1935
|
-
};
|
|
1936
|
-
|
|
1937
|
-
class FileNotFoundError extends Error {
|
|
1938
|
-
constructor(uri) {
|
|
1939
|
-
super(`File not found: ${uri}`);
|
|
1940
|
-
this.code = 'ENOENT';
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
|
|
1944
|
-
const ApplicationJson = 'application/json';
|
|
1945
|
-
const AudioMpeg = 'audio/mpeg';
|
|
1946
|
-
const FontTtf = 'font/ttf';
|
|
1947
|
-
const ImagePng = 'image/png';
|
|
1948
|
-
const ImageSvgXml = 'image/svg+xml';
|
|
1949
|
-
const TextCss = 'text/css';
|
|
1950
|
-
const TextHtml = 'text/html';
|
|
1951
|
-
const TextJavaScript = 'text/javascript';
|
|
1952
|
-
const TextPlain = 'text/plain';
|
|
1953
|
-
const VideoWebm = 'video/webm';
|
|
1954
|
-
|
|
1955
|
-
const getMimeType = fileExtension => {
|
|
1956
|
-
switch (fileExtension) {
|
|
1957
|
-
case '.html':
|
|
1958
|
-
return TextHtml;
|
|
1959
|
-
case '.css':
|
|
1960
|
-
return TextCss;
|
|
1961
|
-
case '.ttf':
|
|
1962
|
-
return FontTtf;
|
|
1963
|
-
case '.js':
|
|
1964
|
-
case '.mjs':
|
|
1965
|
-
case '.ts':
|
|
1966
|
-
return TextJavaScript;
|
|
1967
|
-
case '.svg':
|
|
1968
|
-
return ImageSvgXml;
|
|
1969
|
-
case '.png':
|
|
1970
|
-
return ImagePng;
|
|
1971
|
-
case '.json':
|
|
1972
|
-
case '.map':
|
|
1973
|
-
return ApplicationJson;
|
|
1974
|
-
case '.mp3':
|
|
1975
|
-
return AudioMpeg;
|
|
1976
|
-
case '.webm':
|
|
1977
|
-
return VideoWebm;
|
|
1978
|
-
case '.txt':
|
|
1979
|
-
return TextPlain;
|
|
1980
|
-
default:
|
|
1981
|
-
return '';
|
|
1982
|
-
}
|
|
1983
|
-
};
|
|
1984
|
-
|
|
1985
|
-
const dirname = (pathSeparator, path) => {
|
|
1986
|
-
const index = path.lastIndexOf(pathSeparator);
|
|
1987
|
-
if (index === -1) {
|
|
1988
|
-
return path;
|
|
1989
|
-
}
|
|
1990
|
-
return path.slice(0, index);
|
|
1991
|
-
};
|
|
1992
|
-
const extname = path => {
|
|
1993
|
-
const index = path.lastIndexOf('.');
|
|
1994
|
-
if (index === -1) {
|
|
1995
|
-
return '';
|
|
1996
|
-
}
|
|
1997
|
-
return path.slice(index);
|
|
1998
|
-
};
|
|
1999
|
-
|
|
2000
|
-
const getContentType = uri => {
|
|
2001
|
-
const extension = extname(uri);
|
|
2002
|
-
const mime = getMimeType(extension);
|
|
2003
|
-
return mime;
|
|
2004
|
-
};
|
|
2005
|
-
|
|
2006
|
-
// TODO move this to an extension?
|
|
2007
|
-
|
|
2008
|
-
const state$6 = {
|
|
2009
|
-
files: Object.create(null)
|
|
2010
|
-
};
|
|
2011
|
-
const getDirent = uri => {
|
|
2012
|
-
return state$6.files[uri];
|
|
2013
|
-
};
|
|
2014
|
-
const readFile = uri => {
|
|
2015
|
-
const dirent = getDirent(uri);
|
|
2016
|
-
if (!dirent) {
|
|
2017
|
-
throw new FileNotFoundError(uri);
|
|
2018
|
-
}
|
|
2019
|
-
if (dirent.type !== File$3) {
|
|
2020
|
-
throw new Error('file is a directory');
|
|
2021
|
-
}
|
|
2022
|
-
return dirent.content;
|
|
2023
|
-
};
|
|
2024
|
-
const ensureParentDir = uri => {
|
|
2025
|
-
const startIndex = 0;
|
|
2026
|
-
let endIndex = uri.indexOf(Slash);
|
|
2027
|
-
while (endIndex >= 0) {
|
|
2028
|
-
const part = uri.slice(startIndex, endIndex + 1);
|
|
2029
|
-
state$6.files[part] = {
|
|
2030
|
-
type: Directory$1,
|
|
2031
|
-
content: ''
|
|
2032
|
-
};
|
|
2033
|
-
endIndex = uri.indexOf(Slash, endIndex + 1);
|
|
2034
|
-
}
|
|
2035
|
-
};
|
|
2036
|
-
const writeFile = (uri, content) => {
|
|
2037
|
-
const dirent = getDirent(uri);
|
|
2038
|
-
if (dirent) {
|
|
2039
|
-
dirent.content = content;
|
|
2040
|
-
} else {
|
|
2041
|
-
ensureParentDir(uri);
|
|
2042
|
-
state$6.files[uri] = {
|
|
2043
|
-
type: File$3,
|
|
2044
|
-
content
|
|
2045
|
-
};
|
|
2046
|
-
}
|
|
2047
|
-
};
|
|
2048
|
-
const mkdir = uri => {
|
|
2049
|
-
if (!uri.endsWith(Slash)) {
|
|
2050
|
-
uri += Slash;
|
|
2051
|
-
}
|
|
2052
|
-
ensureParentDir(uri);
|
|
2053
|
-
state$6.files[uri] = {
|
|
2054
|
-
type: Directory$1,
|
|
2055
|
-
content: ''
|
|
2056
|
-
};
|
|
2057
|
-
};
|
|
2058
|
-
const remove = uri => {
|
|
2059
|
-
const toDelete = [];
|
|
2060
|
-
for (const key of Object.keys(state$6.files)) {
|
|
2061
|
-
if (key.startsWith(uri)) {
|
|
2062
|
-
toDelete.push(key);
|
|
2063
|
-
}
|
|
2064
|
-
}
|
|
2065
|
-
for (const key of toDelete) {
|
|
2066
|
-
delete state$6.files[key];
|
|
2067
|
-
}
|
|
2068
|
-
};
|
|
2069
|
-
const readDirWithFileTypes = uri => {
|
|
2070
|
-
if (!uri.endsWith(Slash)) {
|
|
2071
|
-
uri += Slash;
|
|
2072
|
-
}
|
|
2073
|
-
const dirents = [];
|
|
2074
|
-
for (const [key, value] of Object.entries(state$6.files)) {
|
|
2075
|
-
if (key.startsWith(uri)) {
|
|
2076
|
-
// @ts-ignore
|
|
2077
|
-
switch (value.type) {
|
|
2078
|
-
case Directory$1:
|
|
2079
|
-
if (!key.slice(0, -1).includes(Slash, uri.length) && key !== `${uri}/` && key !== uri) {
|
|
2080
|
-
dirents.push({
|
|
2081
|
-
// @ts-ignore
|
|
2082
|
-
type: value.type,
|
|
2083
|
-
name: key.slice(uri.length, -1)
|
|
2084
|
-
});
|
|
2085
|
-
}
|
|
2086
|
-
break;
|
|
2087
|
-
case File$3:
|
|
2088
|
-
if (!key.includes(Slash, uri.length + 1)) {
|
|
2089
|
-
dirents.push({
|
|
2090
|
-
// @ts-ignore
|
|
2091
|
-
type: value.type,
|
|
2092
|
-
name: key.slice(uri.length)
|
|
2093
|
-
});
|
|
2094
|
-
}
|
|
2095
|
-
break;
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
return dirents;
|
|
2100
|
-
};
|
|
2101
|
-
const getBlob = (uri, type) => {
|
|
2102
|
-
const content = readFile(uri);
|
|
2103
|
-
const contentType = type || getContentType(uri);
|
|
2104
|
-
const blob = new Blob([content], {
|
|
2105
|
-
type: contentType
|
|
2106
|
-
});
|
|
2107
|
-
return blob;
|
|
2108
|
-
};
|
|
2109
|
-
const getBlobUrl = (uri, type) => {
|
|
2110
|
-
const blob = getBlob(uri, type);
|
|
2111
|
-
const url = URL.createObjectURL(blob);
|
|
2112
|
-
return url;
|
|
2113
|
-
};
|
|
2114
|
-
const chmod = () => {
|
|
2115
|
-
throw new Error('[memfs] chmod not implemented');
|
|
2116
|
-
};
|
|
2117
|
-
const getFiles = () => {
|
|
2118
|
-
return state$6.files;
|
|
2119
|
-
};
|
|
2120
|
-
|
|
2121
1840
|
const emptyMatches = [];
|
|
2122
1841
|
|
|
2123
1842
|
const convertToPick = item => {
|
|
@@ -2698,12 +2417,12 @@ const getDefaultValue = uri => {
|
|
|
2698
2417
|
}
|
|
2699
2418
|
};
|
|
2700
2419
|
|
|
2701
|
-
const state$
|
|
2420
|
+
const state$4 = Object.create(null);
|
|
2702
2421
|
const register = modules => {
|
|
2703
|
-
Object.assign(state$
|
|
2422
|
+
Object.assign(state$4, modules);
|
|
2704
2423
|
};
|
|
2705
2424
|
const load = moduleId => {
|
|
2706
|
-
const module = state$
|
|
2425
|
+
const module = state$4[moduleId];
|
|
2707
2426
|
if (!module) {
|
|
2708
2427
|
throw new Error(`unknown module "${moduleId}"`);
|
|
2709
2428
|
}
|
|
@@ -2809,11 +2528,11 @@ const getPickFileIcon = pick => {
|
|
|
2809
2528
|
pick = pick.pick;
|
|
2810
2529
|
}
|
|
2811
2530
|
return {
|
|
2812
|
-
type: Directory
|
|
2531
|
+
type: Directory,
|
|
2813
2532
|
name: pick
|
|
2814
2533
|
};
|
|
2815
2534
|
};
|
|
2816
|
-
const state$
|
|
2535
|
+
const state$3 = {};
|
|
2817
2536
|
const isPrepared$3 = () => {
|
|
2818
2537
|
return false;
|
|
2819
2538
|
};
|
|
@@ -2835,17 +2554,17 @@ const QuickPickEntriesOpenRecent = {
|
|
|
2835
2554
|
isPrepared: isPrepared$3,
|
|
2836
2555
|
name: name$3,
|
|
2837
2556
|
selectPick: selectPick$3,
|
|
2838
|
-
state: state$
|
|
2557
|
+
state: state$3
|
|
2839
2558
|
};
|
|
2840
2559
|
|
|
2841
2560
|
const CommandPalette = 'quickPick://commandPalette';
|
|
2842
2561
|
const Commands = 'quickPick://commands';
|
|
2843
|
-
const File$
|
|
2562
|
+
const File$1 = 'quickPick://file';
|
|
2844
2563
|
const EveryThing = 'quickPick://everything';
|
|
2845
2564
|
const Number$1 = 'quickPick://number';
|
|
2846
2565
|
const Recent = 'quickPick://recent';
|
|
2847
2566
|
const ColorTheme = 'quickPick://color-theme';
|
|
2848
|
-
const Symbol
|
|
2567
|
+
const Symbol = 'quickPick://symbol';
|
|
2849
2568
|
const View = 'quickPick://view';
|
|
2850
2569
|
const WorkspaceSymbol = 'quickPick://workspace-symbol';
|
|
2851
2570
|
const Custom = 'quickPick://custom';
|
|
@@ -2878,7 +2597,7 @@ const requestFileIcons = async requests => {
|
|
|
2878
2597
|
if (!request.name) {
|
|
2879
2598
|
return '';
|
|
2880
2599
|
}
|
|
2881
|
-
return request.type === File$
|
|
2600
|
+
return request.type === File$2 ? invoke$1('IconTheme.getFileIcon', {
|
|
2882
2601
|
name: request.name
|
|
2883
2602
|
}) : invoke$1('IconTheme.getFolderIcon', {
|
|
2884
2603
|
name: request.name
|
|
@@ -3190,417 +2909,6 @@ const doRender = async uid => {
|
|
|
3190
2909
|
return applyRender(oldState, newState, diffResult);
|
|
3191
2910
|
};
|
|
3192
2911
|
|
|
3193
|
-
const removeLeadingSlash = path => {
|
|
3194
|
-
if (path.startsWith('/')) {
|
|
3195
|
-
return path.slice(1);
|
|
3196
|
-
}
|
|
3197
|
-
return path;
|
|
3198
|
-
};
|
|
3199
|
-
|
|
3200
|
-
// TODO simplify code
|
|
3201
|
-
// 1. don't have playground prefix in fileMap json
|
|
3202
|
-
// 2. remove code here that removes the prefix
|
|
3203
|
-
const searchFile$3 = async path => {
|
|
3204
|
-
const fileList = await getJson(fileMapUrl);
|
|
3205
|
-
const result = fileList.map(removeLeadingSlash);
|
|
3206
|
-
const prefixLength = path.length - 'file:///'.length;
|
|
3207
|
-
const final = [];
|
|
3208
|
-
for (const item of result) {
|
|
3209
|
-
final.push(item.slice(prefixLength));
|
|
3210
|
-
}
|
|
3211
|
-
return final;
|
|
3212
|
-
};
|
|
3213
|
-
|
|
3214
|
-
const Directory = 'directory';
|
|
3215
|
-
const File$1 = 'file';
|
|
3216
|
-
|
|
3217
|
-
// based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
|
|
3218
|
-
|
|
3219
|
-
const fromAsync = async asyncIterable => {
|
|
3220
|
-
const children = [];
|
|
3221
|
-
for await (const value of asyncIterable) {
|
|
3222
|
-
children.push(value);
|
|
3223
|
-
}
|
|
3224
|
-
return children;
|
|
3225
|
-
};
|
|
3226
|
-
|
|
3227
|
-
/**
|
|
3228
|
-
* Do not use directly, use FileSystemHtml.getChildHandles
|
|
3229
|
-
* instead which prompts for the required permission to
|
|
3230
|
-
* retrieve the child handles
|
|
3231
|
-
*
|
|
3232
|
-
*/
|
|
3233
|
-
|
|
3234
|
-
const getChildHandles = async handle => {
|
|
3235
|
-
// @ts-ignore
|
|
3236
|
-
const handles = await fromAsync(handle.values());
|
|
3237
|
-
return handles;
|
|
3238
|
-
};
|
|
3239
|
-
|
|
3240
|
-
const instanceOfAny = (object, constructors) => constructors.some(c => object instanceof c);
|
|
3241
|
-
let idbProxyableTypes;
|
|
3242
|
-
let cursorAdvanceMethods;
|
|
3243
|
-
// This is a function to prevent it throwing up in node environments.
|
|
3244
|
-
function getIdbProxyableTypes() {
|
|
3245
|
-
return idbProxyableTypes || (idbProxyableTypes = [IDBDatabase, IDBObjectStore, IDBIndex, IDBCursor, IDBTransaction]);
|
|
3246
|
-
}
|
|
3247
|
-
// This is a function to prevent it throwing up in node environments.
|
|
3248
|
-
function getCursorAdvanceMethods() {
|
|
3249
|
-
return cursorAdvanceMethods || (cursorAdvanceMethods = [IDBCursor.prototype.advance, IDBCursor.prototype.continue, IDBCursor.prototype.continuePrimaryKey]);
|
|
3250
|
-
}
|
|
3251
|
-
const transactionDoneMap = new WeakMap();
|
|
3252
|
-
const transformCache = new WeakMap();
|
|
3253
|
-
const reverseTransformCache = new WeakMap();
|
|
3254
|
-
function promisifyRequest(request) {
|
|
3255
|
-
const promise = new Promise((resolve, reject) => {
|
|
3256
|
-
const unlisten = () => {
|
|
3257
|
-
request.removeEventListener('success', success);
|
|
3258
|
-
request.removeEventListener('error', error);
|
|
3259
|
-
};
|
|
3260
|
-
const success = () => {
|
|
3261
|
-
resolve(wrap(request.result));
|
|
3262
|
-
unlisten();
|
|
3263
|
-
};
|
|
3264
|
-
const error = () => {
|
|
3265
|
-
reject(request.error);
|
|
3266
|
-
unlisten();
|
|
3267
|
-
};
|
|
3268
|
-
request.addEventListener('success', success);
|
|
3269
|
-
request.addEventListener('error', error);
|
|
3270
|
-
});
|
|
3271
|
-
// This mapping exists in reverseTransformCache but doesn't exist in transformCache. This
|
|
3272
|
-
// is because we create many promises from a single IDBRequest.
|
|
3273
|
-
reverseTransformCache.set(promise, request);
|
|
3274
|
-
return promise;
|
|
3275
|
-
}
|
|
3276
|
-
function cacheDonePromiseForTransaction(tx) {
|
|
3277
|
-
// Early bail if we've already created a done promise for this transaction.
|
|
3278
|
-
if (transactionDoneMap.has(tx)) return;
|
|
3279
|
-
const done = new Promise((resolve, reject) => {
|
|
3280
|
-
const unlisten = () => {
|
|
3281
|
-
tx.removeEventListener('complete', complete);
|
|
3282
|
-
tx.removeEventListener('error', error);
|
|
3283
|
-
tx.removeEventListener('abort', error);
|
|
3284
|
-
};
|
|
3285
|
-
const complete = () => {
|
|
3286
|
-
resolve();
|
|
3287
|
-
unlisten();
|
|
3288
|
-
};
|
|
3289
|
-
const error = () => {
|
|
3290
|
-
reject(tx.error || new DOMException('AbortError', 'AbortError'));
|
|
3291
|
-
unlisten();
|
|
3292
|
-
};
|
|
3293
|
-
tx.addEventListener('complete', complete);
|
|
3294
|
-
tx.addEventListener('error', error);
|
|
3295
|
-
tx.addEventListener('abort', error);
|
|
3296
|
-
});
|
|
3297
|
-
// Cache it for later retrieval.
|
|
3298
|
-
transactionDoneMap.set(tx, done);
|
|
3299
|
-
}
|
|
3300
|
-
let idbProxyTraps = {
|
|
3301
|
-
get(target, prop, receiver) {
|
|
3302
|
-
if (target instanceof IDBTransaction) {
|
|
3303
|
-
// Special handling for transaction.done.
|
|
3304
|
-
if (prop === 'done') return transactionDoneMap.get(target);
|
|
3305
|
-
// Make tx.store return the only store in the transaction, or undefined if there are many.
|
|
3306
|
-
if (prop === 'store') {
|
|
3307
|
-
return receiver.objectStoreNames[1] ? undefined : receiver.objectStore(receiver.objectStoreNames[0]);
|
|
3308
|
-
}
|
|
3309
|
-
}
|
|
3310
|
-
// Else transform whatever we get back.
|
|
3311
|
-
return wrap(target[prop]);
|
|
3312
|
-
},
|
|
3313
|
-
set(target, prop, value) {
|
|
3314
|
-
target[prop] = value;
|
|
3315
|
-
return true;
|
|
3316
|
-
},
|
|
3317
|
-
has(target, prop) {
|
|
3318
|
-
if (target instanceof IDBTransaction && (prop === 'done' || prop === 'store')) {
|
|
3319
|
-
return true;
|
|
3320
|
-
}
|
|
3321
|
-
return prop in target;
|
|
3322
|
-
}
|
|
3323
|
-
};
|
|
3324
|
-
function replaceTraps(callback) {
|
|
3325
|
-
idbProxyTraps = callback(idbProxyTraps);
|
|
3326
|
-
}
|
|
3327
|
-
function wrapFunction(func) {
|
|
3328
|
-
// Due to expected object equality (which is enforced by the caching in `wrap`), we
|
|
3329
|
-
// only create one new func per func.
|
|
3330
|
-
// Cursor methods are special, as the behaviour is a little more different to standard IDB. In
|
|
3331
|
-
// IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
|
|
3332
|
-
// cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
|
|
3333
|
-
// with real promises, so each advance methods returns a new promise for the cursor object, or
|
|
3334
|
-
// undefined if the end of the cursor has been reached.
|
|
3335
|
-
if (getCursorAdvanceMethods().includes(func)) {
|
|
3336
|
-
return function (...args) {
|
|
3337
|
-
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
3338
|
-
// the original object.
|
|
3339
|
-
func.apply(unwrap(this), args);
|
|
3340
|
-
return wrap(this.request);
|
|
3341
|
-
};
|
|
3342
|
-
}
|
|
3343
|
-
return function (...args) {
|
|
3344
|
-
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
3345
|
-
// the original object.
|
|
3346
|
-
return wrap(func.apply(unwrap(this), args));
|
|
3347
|
-
};
|
|
3348
|
-
}
|
|
3349
|
-
function transformCachableValue(value) {
|
|
3350
|
-
if (typeof value === 'function') return wrapFunction(value);
|
|
3351
|
-
// This doesn't return, it just creates a 'done' promise for the transaction,
|
|
3352
|
-
// which is later returned for transaction.done (see idbObjectHandler).
|
|
3353
|
-
if (value instanceof IDBTransaction) cacheDonePromiseForTransaction(value);
|
|
3354
|
-
if (instanceOfAny(value, getIdbProxyableTypes())) return new Proxy(value, idbProxyTraps);
|
|
3355
|
-
// Return the same value back if we're not going to transform it.
|
|
3356
|
-
return value;
|
|
3357
|
-
}
|
|
3358
|
-
function wrap(value) {
|
|
3359
|
-
// We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
|
|
3360
|
-
// IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
|
|
3361
|
-
if (value instanceof IDBRequest) return promisifyRequest(value);
|
|
3362
|
-
// If we've already transformed this value before, reuse the transformed value.
|
|
3363
|
-
// This is faster, but it also provides object equality.
|
|
3364
|
-
if (transformCache.has(value)) return transformCache.get(value);
|
|
3365
|
-
const newValue = transformCachableValue(value);
|
|
3366
|
-
// Not all types are transformed.
|
|
3367
|
-
// These may be primitive types, so they can't be WeakMap keys.
|
|
3368
|
-
if (newValue !== value) {
|
|
3369
|
-
transformCache.set(value, newValue);
|
|
3370
|
-
reverseTransformCache.set(newValue, value);
|
|
3371
|
-
}
|
|
3372
|
-
return newValue;
|
|
3373
|
-
}
|
|
3374
|
-
const unwrap = value => reverseTransformCache.get(value);
|
|
3375
|
-
|
|
3376
|
-
/**
|
|
3377
|
-
* Open a database.
|
|
3378
|
-
*
|
|
3379
|
-
* @param name Name of the database.
|
|
3380
|
-
* @param version Schema version.
|
|
3381
|
-
* @param callbacks Additional callbacks.
|
|
3382
|
-
*/
|
|
3383
|
-
function openDB(name, version, {
|
|
3384
|
-
blocked,
|
|
3385
|
-
upgrade,
|
|
3386
|
-
blocking,
|
|
3387
|
-
terminated
|
|
3388
|
-
} = {}) {
|
|
3389
|
-
const request = indexedDB.open(name, version);
|
|
3390
|
-
const openPromise = wrap(request);
|
|
3391
|
-
if (upgrade) {
|
|
3392
|
-
request.addEventListener('upgradeneeded', event => {
|
|
3393
|
-
upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
|
|
3394
|
-
});
|
|
3395
|
-
}
|
|
3396
|
-
if (blocked) {
|
|
3397
|
-
request.addEventListener('blocked', event => blocked(
|
|
3398
|
-
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
3399
|
-
event.oldVersion, event.newVersion, event));
|
|
3400
|
-
}
|
|
3401
|
-
openPromise.then(db => {
|
|
3402
|
-
if (terminated) db.addEventListener('close', () => terminated());
|
|
3403
|
-
if (blocking) {
|
|
3404
|
-
db.addEventListener('versionchange', event => blocking(event.oldVersion, event.newVersion, event));
|
|
3405
|
-
}
|
|
3406
|
-
}).catch(() => {});
|
|
3407
|
-
return openPromise;
|
|
3408
|
-
}
|
|
3409
|
-
const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
|
|
3410
|
-
const writeMethods = ['put', 'add', 'delete', 'clear'];
|
|
3411
|
-
const cachedMethods = new Map();
|
|
3412
|
-
function getMethod(target, prop) {
|
|
3413
|
-
if (!(target instanceof IDBDatabase && !(prop in target) && typeof prop === 'string')) {
|
|
3414
|
-
return;
|
|
3415
|
-
}
|
|
3416
|
-
if (cachedMethods.get(prop)) return cachedMethods.get(prop);
|
|
3417
|
-
const targetFuncName = prop.replace(/FromIndex$/, '');
|
|
3418
|
-
const useIndex = prop !== targetFuncName;
|
|
3419
|
-
const isWrite = writeMethods.includes(targetFuncName);
|
|
3420
|
-
if (
|
|
3421
|
-
// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
|
|
3422
|
-
!(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) || !(isWrite || readMethods.includes(targetFuncName))) {
|
|
3423
|
-
return;
|
|
3424
|
-
}
|
|
3425
|
-
const method = async function (storeName, ...args) {
|
|
3426
|
-
// isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
|
|
3427
|
-
const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
|
|
3428
|
-
let target = tx.store;
|
|
3429
|
-
if (useIndex) target = target.index(args.shift());
|
|
3430
|
-
// Must reject if op rejects.
|
|
3431
|
-
// If it's a write operation, must reject if tx.done rejects.
|
|
3432
|
-
// Must reject with op rejection first.
|
|
3433
|
-
// Must resolve with op value.
|
|
3434
|
-
// Must handle both promises (no unhandled rejections)
|
|
3435
|
-
return (await Promise.all([target[targetFuncName](...args), isWrite && tx.done]))[0];
|
|
3436
|
-
};
|
|
3437
|
-
cachedMethods.set(prop, method);
|
|
3438
|
-
return method;
|
|
3439
|
-
}
|
|
3440
|
-
replaceTraps(oldTraps => ({
|
|
3441
|
-
...oldTraps,
|
|
3442
|
-
get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
|
|
3443
|
-
has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop)
|
|
3444
|
-
}));
|
|
3445
|
-
const advanceMethodProps = ['continue', 'continuePrimaryKey', 'advance'];
|
|
3446
|
-
const methodMap = {};
|
|
3447
|
-
const advanceResults = new WeakMap();
|
|
3448
|
-
const ittrProxiedCursorToOriginalProxy = new WeakMap();
|
|
3449
|
-
const cursorIteratorTraps = {
|
|
3450
|
-
get(target, prop) {
|
|
3451
|
-
if (!advanceMethodProps.includes(prop)) return target[prop];
|
|
3452
|
-
let cachedFunc = methodMap[prop];
|
|
3453
|
-
if (!cachedFunc) {
|
|
3454
|
-
cachedFunc = methodMap[prop] = function (...args) {
|
|
3455
|
-
advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args));
|
|
3456
|
-
};
|
|
3457
|
-
}
|
|
3458
|
-
return cachedFunc;
|
|
3459
|
-
}
|
|
3460
|
-
};
|
|
3461
|
-
async function* iterate(...args) {
|
|
3462
|
-
// tslint:disable-next-line:no-this-assignment
|
|
3463
|
-
let cursor = this;
|
|
3464
|
-
if (!(cursor instanceof IDBCursor)) {
|
|
3465
|
-
cursor = await cursor.openCursor(...args);
|
|
3466
|
-
}
|
|
3467
|
-
if (!cursor) return;
|
|
3468
|
-
cursor = cursor;
|
|
3469
|
-
const proxiedCursor = new Proxy(cursor, cursorIteratorTraps);
|
|
3470
|
-
ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor);
|
|
3471
|
-
// Map this double-proxy back to the original, so other cursor methods work.
|
|
3472
|
-
reverseTransformCache.set(proxiedCursor, unwrap(cursor));
|
|
3473
|
-
while (cursor) {
|
|
3474
|
-
yield proxiedCursor;
|
|
3475
|
-
// If one of the advancing methods was not called, call continue().
|
|
3476
|
-
cursor = await (advanceResults.get(proxiedCursor) || cursor.continue());
|
|
3477
|
-
advanceResults.delete(proxiedCursor);
|
|
3478
|
-
}
|
|
3479
|
-
}
|
|
3480
|
-
function isIteratorProp(target, prop) {
|
|
3481
|
-
return prop === Symbol.asyncIterator && instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor]) || prop === 'iterate' && instanceOfAny(target, [IDBIndex, IDBObjectStore]);
|
|
3482
|
-
}
|
|
3483
|
-
replaceTraps(oldTraps => ({
|
|
3484
|
-
...oldTraps,
|
|
3485
|
-
get(target, prop, receiver) {
|
|
3486
|
-
if (isIteratorProp(target, prop)) return iterate;
|
|
3487
|
-
return oldTraps.get(target, prop, receiver);
|
|
3488
|
-
},
|
|
3489
|
-
has(target, prop) {
|
|
3490
|
-
return isIteratorProp(target, prop) || oldTraps.has(target, prop);
|
|
3491
|
-
}
|
|
3492
|
-
}));
|
|
3493
|
-
|
|
3494
|
-
const state$3 = {
|
|
3495
|
-
dbVersion: 1};
|
|
3496
|
-
|
|
3497
|
-
// TODO high memory usage in idb because of transactionDoneMap
|
|
3498
|
-
|
|
3499
|
-
const getHandleDb = async () => {
|
|
3500
|
-
// @ts-ignore
|
|
3501
|
-
const db = await openDB('handle', state$3.dbVersion, {
|
|
3502
|
-
async upgrade(db) {
|
|
3503
|
-
if (!db.objectStoreNames.contains('file-handles-store')) {
|
|
3504
|
-
await db.createObjectStore('file-handles-store', {});
|
|
3505
|
-
}
|
|
3506
|
-
}
|
|
3507
|
-
});
|
|
3508
|
-
return db;
|
|
3509
|
-
};
|
|
3510
|
-
const getHandle$1 = async uri => {
|
|
3511
|
-
const handleDb = await getHandleDb();
|
|
3512
|
-
const handle = await handleDb.get('file-handles-store', uri);
|
|
3513
|
-
return handle;
|
|
3514
|
-
};
|
|
3515
|
-
|
|
3516
|
-
const getHandle = async uri => {
|
|
3517
|
-
try {
|
|
3518
|
-
// TODO retrieve handle from state or from indexeddb
|
|
3519
|
-
// TODO if not found, throw error
|
|
3520
|
-
const handle = await getHandle$1(uri);
|
|
3521
|
-
return handle;
|
|
3522
|
-
} catch (error) {
|
|
3523
|
-
throw new VError(error, 'Failed to get handle');
|
|
3524
|
-
}
|
|
3525
|
-
};
|
|
3526
|
-
|
|
3527
|
-
const getDirectoryHandle = async uri => {
|
|
3528
|
-
const handle = await getHandle(uri);
|
|
3529
|
-
if (handle) {
|
|
3530
|
-
return handle;
|
|
3531
|
-
}
|
|
3532
|
-
const dirname$1 = dirname('/', uri);
|
|
3533
|
-
if (uri === dirname$1) {
|
|
3534
|
-
return undefined;
|
|
3535
|
-
}
|
|
3536
|
-
return getDirectoryHandle(dirname$1);
|
|
3537
|
-
};
|
|
3538
|
-
const toIgnore = ['.git', 'node_modules', 'dist', 'dist2'];
|
|
3539
|
-
const searchFilesRecursively = async (all, parent, handle) => {
|
|
3540
|
-
const childHandles = await getChildHandles(handle);
|
|
3541
|
-
const promises = [];
|
|
3542
|
-
for (const childHandle of childHandles) {
|
|
3543
|
-
if (toIgnore.includes(childHandle.name)) {
|
|
3544
|
-
continue;
|
|
3545
|
-
}
|
|
3546
|
-
const absolutePath = parent + '/' + childHandle.name;
|
|
3547
|
-
switch (childHandle.kind) {
|
|
3548
|
-
case Directory:
|
|
3549
|
-
promises.push(searchFilesRecursively(all, absolutePath, childHandle));
|
|
3550
|
-
break;
|
|
3551
|
-
case File$1:
|
|
3552
|
-
all.push(absolutePath);
|
|
3553
|
-
break;
|
|
3554
|
-
}
|
|
3555
|
-
}
|
|
3556
|
-
await Promise.all(promises);
|
|
3557
|
-
};
|
|
3558
|
-
const searchFile$2 = async uri => {
|
|
3559
|
-
const path = uri.slice('html://'.length);
|
|
3560
|
-
const handle = await getDirectoryHandle(path);
|
|
3561
|
-
if (!handle) {
|
|
3562
|
-
// @ts-ignore
|
|
3563
|
-
throw new VError(`Folder not found ${uri}`);
|
|
3564
|
-
}
|
|
3565
|
-
const all = [];
|
|
3566
|
-
await searchFilesRecursively(all, '', handle);
|
|
3567
|
-
return all;
|
|
3568
|
-
};
|
|
3569
|
-
|
|
3570
|
-
const getFileSearchRipGrepArgs = () => {
|
|
3571
|
-
const ripGrepArgs = ['--files', '--sort-files'];
|
|
3572
|
-
return ripGrepArgs;
|
|
3573
|
-
};
|
|
3574
|
-
|
|
3575
|
-
const invoke = (method, ...params) => {
|
|
3576
|
-
return invoke$1('SearchProcess.invoke', method, ...params);
|
|
3577
|
-
};
|
|
3578
|
-
|
|
3579
|
-
const splitLines = lines => {
|
|
3580
|
-
if (!lines) {
|
|
3581
|
-
return [];
|
|
3582
|
-
}
|
|
3583
|
-
return lines.split('\n');
|
|
3584
|
-
};
|
|
3585
|
-
|
|
3586
|
-
// TODO create direct connection from electron to file search worker using message ports
|
|
3587
|
-
|
|
3588
|
-
const searchFile$1 = async (path, value, prepare) => {
|
|
3589
|
-
const ripGrepArgs = getFileSearchRipGrepArgs();
|
|
3590
|
-
const options = {
|
|
3591
|
-
ripGrepArgs,
|
|
3592
|
-
searchPath: path,
|
|
3593
|
-
limit: 9_999_999
|
|
3594
|
-
};
|
|
3595
|
-
const stdout = await invoke('SearchFile.searchFile', options);
|
|
3596
|
-
const lines = splitLines(stdout);
|
|
3597
|
-
if (!prepare) {
|
|
3598
|
-
return lines;
|
|
3599
|
-
}
|
|
3600
|
-
const filtered = filterQuickPickItems(lines, value);
|
|
3601
|
-
return filtered;
|
|
3602
|
-
};
|
|
3603
|
-
|
|
3604
2912
|
const selectCurrentIndex = state => {
|
|
3605
2913
|
return selectIndex(state, state.focusedIndex);
|
|
3606
2914
|
};
|
|
@@ -3657,30 +2965,11 @@ const commandMap = {
|
|
|
3657
2965
|
'QuickPick.selectItem': wrapCommand(selectItem),
|
|
3658
2966
|
'QuickPick.setDeltaY': wrapCommand(setDeltaY),
|
|
3659
2967
|
'QuickPick.setValue': wrapCommand(setValue),
|
|
2968
|
+
// deprecated
|
|
3660
2969
|
'SearchFile.filter': filterQuickPickItems,
|
|
3661
2970
|
'SearchFile.searchFile': searchFile$5,
|
|
3662
|
-
'SearchFile.searchFileWithFetch': searchFile$3,
|
|
3663
|
-
'SearchFile.searchFileWithHtml': searchFile$2,
|
|
3664
|
-
'SearchFile.searchFileWithRipGrep': searchFile$1,
|
|
3665
|
-
// deprecated
|
|
3666
2971
|
'QuickPick.create': create,
|
|
3667
|
-
'QuickPick.loadEntries': loadQuickPickEntries
|
|
3668
|
-
'FileSystemFetch.chmod': chmod$1,
|
|
3669
|
-
'FileSystemFetch.getBlob': getBlob$1,
|
|
3670
|
-
'FileSystemFetch.mkdir': mkdir$1,
|
|
3671
|
-
'FileSystemFetch.readDirWithFileTypes': readDirWithFileTypes$1,
|
|
3672
|
-
'FileSystemFetch.readFile': readFile$1,
|
|
3673
|
-
'FileSystemFetch.remove': remove$1,
|
|
3674
|
-
'FileSystemFetch.writeFile': writeFile$1,
|
|
3675
|
-
'FileSystemMemory.chmod': chmod,
|
|
3676
|
-
'FileSystemMemory.getBlob': getBlob,
|
|
3677
|
-
'FileSystemMemory.getBlobUrl': getBlobUrl,
|
|
3678
|
-
'FileSystemMemory.getFiles': getFiles,
|
|
3679
|
-
'FileSystemMemory.mkdir': mkdir,
|
|
3680
|
-
'FileSystemMemory.readDirWithFileTypes': readDirWithFileTypes,
|
|
3681
|
-
'FileSystemMemory.readFile': readFile,
|
|
3682
|
-
'FileSystemMemory.remove': remove,
|
|
3683
|
-
'FileSystemMemory.writeFile': writeFile
|
|
2972
|
+
'QuickPick.loadEntries': loadQuickPickEntries
|
|
3684
2973
|
};
|
|
3685
2974
|
|
|
3686
2975
|
const getColorThemeNames = async () => {
|
|
@@ -3935,13 +3224,13 @@ const QuickPickEntriesNumber = {
|
|
|
3935
3224
|
const quickPickEntriesModules = {
|
|
3936
3225
|
[CommandPalette]: QuickPickEntriesEverything,
|
|
3937
3226
|
[Commands]: QuickPickEntriesEverything,
|
|
3938
|
-
[File$
|
|
3227
|
+
[File$1]: QuickPickEntriesEverything,
|
|
3939
3228
|
[EveryThing]: QuickPickEntriesEverything,
|
|
3940
3229
|
[WorkspaceSymbol]: QuickPickEntriesEverything,
|
|
3941
3230
|
[Number$1]: QuickPickEntriesNumber,
|
|
3942
3231
|
[Recent]: QuickPickEntriesOpenRecent,
|
|
3943
3232
|
[ColorTheme]: QuickPickEntriesColorTheme,
|
|
3944
|
-
[Symbol
|
|
3233
|
+
[Symbol]: QuickPickEntriesSymbol,
|
|
3945
3234
|
[View]: QuickPickEntriesView,
|
|
3946
3235
|
[Custom]: QuickPickEntriesCustom
|
|
3947
3236
|
};
|
|
@@ -3952,18 +3241,61 @@ const Fetch = 'fetch';
|
|
|
3952
3241
|
const File = 'file';
|
|
3953
3242
|
const Default = '';
|
|
3954
3243
|
|
|
3955
|
-
const searchFile = async
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3244
|
+
const searchFile$3 = async uri => {
|
|
3245
|
+
return invoke$1('ExtensionHost.searchFileWithMemory', uri);
|
|
3246
|
+
};
|
|
3247
|
+
|
|
3248
|
+
// TODO simplify code
|
|
3249
|
+
// 1. don't have playground prefix in fileMap json
|
|
3250
|
+
// 2. remove code here that removes the prefix
|
|
3251
|
+
const searchFile$2 = async path => {
|
|
3252
|
+
return invoke$1('ExtensionHost.searchFileWithFetch', path);
|
|
3253
|
+
};
|
|
3254
|
+
|
|
3255
|
+
const searchFile$1 = async uri => {
|
|
3256
|
+
return invoke$1('ExtensionHost.searchFileWithHtml', uri);
|
|
3257
|
+
};
|
|
3258
|
+
|
|
3259
|
+
const getFileSearchRipGrepArgs = () => {
|
|
3260
|
+
const ripGrepArgs = ['--files', '--sort-files'];
|
|
3261
|
+
return ripGrepArgs;
|
|
3262
|
+
};
|
|
3263
|
+
|
|
3264
|
+
const invoke = (method, ...params) => {
|
|
3265
|
+
return invoke$1('SearchProcess.invoke', method, ...params);
|
|
3266
|
+
};
|
|
3267
|
+
|
|
3268
|
+
const splitLines = lines => {
|
|
3269
|
+
if (!lines) {
|
|
3270
|
+
return [];
|
|
3271
|
+
}
|
|
3272
|
+
return lines.split('\n');
|
|
3273
|
+
};
|
|
3274
|
+
|
|
3275
|
+
// TODO create direct connection from electron to file search worker using message ports
|
|
3276
|
+
|
|
3277
|
+
const searchFile = async (path, value, prepare) => {
|
|
3278
|
+
const ripGrepArgs = getFileSearchRipGrepArgs();
|
|
3279
|
+
const options = {
|
|
3280
|
+
ripGrepArgs,
|
|
3281
|
+
searchPath: path,
|
|
3282
|
+
limit: 9_999_999
|
|
3283
|
+
};
|
|
3284
|
+
const stdout = await invoke('SearchFile.searchFile', options);
|
|
3285
|
+
const lines = splitLines(stdout);
|
|
3286
|
+
if (!prepare) {
|
|
3287
|
+
return lines;
|
|
3288
|
+
}
|
|
3289
|
+
const filtered = filterQuickPickItems(lines, value);
|
|
3290
|
+
return filtered;
|
|
3959
3291
|
};
|
|
3960
3292
|
|
|
3961
3293
|
const searchModules = {
|
|
3962
|
-
[Memfs]: searchFile,
|
|
3963
|
-
[Fetch]: searchFile$
|
|
3964
|
-
[Html]: searchFile$
|
|
3965
|
-
[File]: searchFile
|
|
3966
|
-
[Default]: searchFile
|
|
3294
|
+
[Memfs]: searchFile$3,
|
|
3295
|
+
[Fetch]: searchFile$2,
|
|
3296
|
+
[Html]: searchFile$1,
|
|
3297
|
+
[File]: searchFile,
|
|
3298
|
+
[Default]: searchFile
|
|
3967
3299
|
};
|
|
3968
3300
|
|
|
3969
3301
|
const listen = async () => {
|