@lvce-editor/file-system-worker 5.19.1 → 5.20.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/fileSystemWorkerMain.js +307 -191
- package/package.json +1 -1
|
@@ -155,17 +155,6 @@ function binaryStringToArrayBuffer(binary) {
|
|
|
155
155
|
return buf;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
const normalizeBlobError = error => {
|
|
159
|
-
const ProgressEventConstructor = ProgressEvent;
|
|
160
|
-
if (error && ProgressEventConstructor && error instanceof ProgressEventConstructor && error.target &&
|
|
161
|
-
// @ts-expect-error - target.error may not be in the type definition
|
|
162
|
-
error.target.error) {
|
|
163
|
-
// @ts-expect-error - target.error may not be in the type definition
|
|
164
|
-
return error.target.error;
|
|
165
|
-
}
|
|
166
|
-
return error;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
158
|
const normalizeLine = line => {
|
|
170
159
|
if (line.startsWith('Error: ')) {
|
|
171
160
|
return line.slice('Error: '.length);
|
|
@@ -222,23 +211,6 @@ class VError extends Error {
|
|
|
222
211
|
}
|
|
223
212
|
}
|
|
224
213
|
|
|
225
|
-
const binaryStringToBlob = async (string, type) => {
|
|
226
|
-
try {
|
|
227
|
-
return binaryStringToBlob$1(string, type);
|
|
228
|
-
} catch (error) {
|
|
229
|
-
const normalizedError = normalizeBlobError(error);
|
|
230
|
-
throw new VError(normalizedError, 'Failed to convert binary string to blob');
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
const blobToBinaryString = async blob => {
|
|
234
|
-
try {
|
|
235
|
-
return await blobToBinaryString$1(blob);
|
|
236
|
-
} catch (error) {
|
|
237
|
-
const normalizedError = normalizeBlobError(error);
|
|
238
|
-
throw new VError(normalizedError, 'Failed to convert blob to binary string');
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
|
|
242
214
|
class AssertionError extends Error {
|
|
243
215
|
constructor(message) {
|
|
244
216
|
super(message);
|
|
@@ -773,7 +745,7 @@ const register$1 = commandMap => {
|
|
|
773
745
|
const getCommand = key => {
|
|
774
746
|
return commands[key];
|
|
775
747
|
};
|
|
776
|
-
const execute = (command, ...args) => {
|
|
748
|
+
const execute$1 = (command, ...args) => {
|
|
777
749
|
const fn = getCommand(command);
|
|
778
750
|
if (!fn) {
|
|
779
751
|
throw new CommandNotFoundError(command);
|
|
@@ -1234,7 +1206,7 @@ const logError = () => {
|
|
|
1234
1206
|
};
|
|
1235
1207
|
const handleMessage = event => {
|
|
1236
1208
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1237
|
-
const actualExecute = event?.target?.execute || execute;
|
|
1209
|
+
const actualExecute = event?.target?.execute || execute$1;
|
|
1238
1210
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1239
1211
|
};
|
|
1240
1212
|
|
|
@@ -1379,7 +1351,7 @@ const waitForReconnect = async () => {
|
|
|
1379
1351
|
setTimeout(resolve, reconnectDelay);
|
|
1380
1352
|
});
|
|
1381
1353
|
};
|
|
1382
|
-
const connect = async ({
|
|
1354
|
+
const connect$1 = async ({
|
|
1383
1355
|
commandMap,
|
|
1384
1356
|
wsUrl
|
|
1385
1357
|
}) => {
|
|
@@ -1408,13 +1380,13 @@ const create$2 = async ({
|
|
|
1408
1380
|
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1409
1381
|
let connection;
|
|
1410
1382
|
try {
|
|
1411
|
-
connection = await connect({
|
|
1383
|
+
connection = await connect$1({
|
|
1412
1384
|
commandMap,
|
|
1413
1385
|
wsUrl
|
|
1414
1386
|
});
|
|
1415
1387
|
} catch {
|
|
1416
1388
|
await waitForReconnect();
|
|
1417
|
-
connection = await connect({
|
|
1389
|
+
connection = await connect$1({
|
|
1418
1390
|
commandMap,
|
|
1419
1391
|
wsUrl
|
|
1420
1392
|
});
|
|
@@ -1517,7 +1489,6 @@ const RendererProcess = 1670;
|
|
|
1517
1489
|
const RendererWorker = 1;
|
|
1518
1490
|
|
|
1519
1491
|
const {
|
|
1520
|
-
invoke: invoke$4,
|
|
1521
1492
|
set: set$4
|
|
1522
1493
|
} = create(ExtensionHostWorker);
|
|
1523
1494
|
|
|
@@ -1689,83 +1660,6 @@ const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
|
1689
1660
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1690
1661
|
};
|
|
1691
1662
|
|
|
1692
|
-
const remove$3 = async dirent => {
|
|
1693
|
-
throw new Error('not implemented');
|
|
1694
|
-
};
|
|
1695
|
-
const readFile$3 = async uri => {
|
|
1696
|
-
const response = await fetch(uri);
|
|
1697
|
-
if (!response.ok) {
|
|
1698
|
-
throw new Error(response.statusText);
|
|
1699
|
-
}
|
|
1700
|
-
const result = await response.text();
|
|
1701
|
-
return result;
|
|
1702
|
-
};
|
|
1703
|
-
const readFileAsBlob$2 = async uri => {
|
|
1704
|
-
const response = await fetch(uri);
|
|
1705
|
-
if (!response.ok) {
|
|
1706
|
-
throw new Error(response.statusText);
|
|
1707
|
-
}
|
|
1708
|
-
const result = await response.blob();
|
|
1709
|
-
return result;
|
|
1710
|
-
};
|
|
1711
|
-
const exists$3 = async uri => {
|
|
1712
|
-
const response = await fetch(uri);
|
|
1713
|
-
return response.ok;
|
|
1714
|
-
};
|
|
1715
|
-
const readDirWithFileTypes$3 = async uri => {
|
|
1716
|
-
throw new Error('not implemented');
|
|
1717
|
-
};
|
|
1718
|
-
const readJson$3 = async uri => {
|
|
1719
|
-
const response = await fetch(uri);
|
|
1720
|
-
if (!response.ok) {
|
|
1721
|
-
throw new Error(response.statusText);
|
|
1722
|
-
}
|
|
1723
|
-
const json = await response.json();
|
|
1724
|
-
return json;
|
|
1725
|
-
};
|
|
1726
|
-
const getRealPath$3 = async path => {
|
|
1727
|
-
throw new Error('not implemented');
|
|
1728
|
-
};
|
|
1729
|
-
const stat$3 = async dirent => {
|
|
1730
|
-
throw new Error('not implemented');
|
|
1731
|
-
};
|
|
1732
|
-
const createFile$2 = async uri => {
|
|
1733
|
-
throw new Error('not implemented');
|
|
1734
|
-
};
|
|
1735
|
-
const writeFile$3 = async (uri, content) => {
|
|
1736
|
-
throw new Error('not implemented');
|
|
1737
|
-
};
|
|
1738
|
-
const mkdir$3 = async uri => {
|
|
1739
|
-
throw new Error('not implemented');
|
|
1740
|
-
};
|
|
1741
|
-
const rename$3 = async (oldUri, newUri) => {
|
|
1742
|
-
throw new Error('not implemented');
|
|
1743
|
-
};
|
|
1744
|
-
const copy$3 = async (oldUri, newUri) => {
|
|
1745
|
-
throw new Error('not implemented');
|
|
1746
|
-
};
|
|
1747
|
-
const getFolderSize$3 = async uri => {
|
|
1748
|
-
throw new Error('not implemented');
|
|
1749
|
-
};
|
|
1750
|
-
|
|
1751
|
-
const FileSystemFetch = {
|
|
1752
|
-
__proto__: null,
|
|
1753
|
-
copy: copy$3,
|
|
1754
|
-
createFile: createFile$2,
|
|
1755
|
-
exists: exists$3,
|
|
1756
|
-
getFolderSize: getFolderSize$3,
|
|
1757
|
-
getRealPath: getRealPath$3,
|
|
1758
|
-
mkdir: mkdir$3,
|
|
1759
|
-
readDirWithFileTypes: readDirWithFileTypes$3,
|
|
1760
|
-
readFile: readFile$3,
|
|
1761
|
-
readFileAsBlob: readFileAsBlob$2,
|
|
1762
|
-
readJson: readJson$3,
|
|
1763
|
-
remove: remove$3,
|
|
1764
|
-
rename: rename$3,
|
|
1765
|
-
stat: stat$3,
|
|
1766
|
-
writeFile: writeFile$3
|
|
1767
|
-
};
|
|
1768
|
-
|
|
1769
1663
|
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1770
1664
|
const assertUri = uri => {
|
|
1771
1665
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
@@ -1782,20 +1676,20 @@ const getFileHashes$1 = async uris => {
|
|
|
1782
1676
|
};
|
|
1783
1677
|
const {
|
|
1784
1678
|
appendFile: appendFile$1,
|
|
1785
|
-
copy: copy$
|
|
1786
|
-
exists: exists$
|
|
1787
|
-
getFolderSize: getFolderSize$
|
|
1788
|
-
getRealPath: getRealPath$
|
|
1679
|
+
copy: copy$3,
|
|
1680
|
+
exists: exists$3,
|
|
1681
|
+
getFolderSize: getFolderSize$3,
|
|
1682
|
+
getRealPath: getRealPath$3,
|
|
1789
1683
|
invoke: invoke$1,
|
|
1790
|
-
mkdir: mkdir$
|
|
1791
|
-
readDirWithFileTypes: readDirWithFileTypes$
|
|
1792
|
-
readFile: readFile$
|
|
1793
|
-
readJson: readJson$
|
|
1794
|
-
remove: remove$
|
|
1795
|
-
rename: rename$
|
|
1684
|
+
mkdir: mkdir$3,
|
|
1685
|
+
readDirWithFileTypes: readDirWithFileTypes$3,
|
|
1686
|
+
readFile: readFile$3,
|
|
1687
|
+
readJson: readJson$3,
|
|
1688
|
+
remove: remove$3,
|
|
1689
|
+
rename: rename$3,
|
|
1796
1690
|
set,
|
|
1797
|
-
stat: stat$
|
|
1798
|
-
writeFile: writeFile$
|
|
1691
|
+
stat: stat$3,
|
|
1692
|
+
writeFile: writeFile$3
|
|
1799
1693
|
} = FileSystemProcess;
|
|
1800
1694
|
|
|
1801
1695
|
const Http = 'http:';
|
|
@@ -1881,53 +1775,251 @@ const getFileExtension = uri => {
|
|
|
1881
1775
|
return uri.slice(lastDot + 1);
|
|
1882
1776
|
};
|
|
1883
1777
|
|
|
1778
|
+
// These numeric types are the filesystem wire protocol consumed by explorer.
|
|
1779
|
+
const directory = 3;
|
|
1780
|
+
const file = 7;
|
|
1781
|
+
const files = new Map();
|
|
1782
|
+
const getPath = uri => (uri.startsWith('memfs://') ? uri.slice('memfs://'.length) : uri).replace(/\/$/, '');
|
|
1783
|
+
const getEntry = uri => files.get(getPath(uri));
|
|
1784
|
+
const ensureParentDirs = path => {
|
|
1785
|
+
let end = path.indexOf('/');
|
|
1786
|
+
while (end >= 0) {
|
|
1787
|
+
const parent = path.slice(0, end);
|
|
1788
|
+
if (!files.has(parent)) files.set(parent, {
|
|
1789
|
+
content: new Blob(),
|
|
1790
|
+
type: directory
|
|
1791
|
+
});
|
|
1792
|
+
end = path.indexOf('/', end + 1);
|
|
1793
|
+
}
|
|
1794
|
+
};
|
|
1884
1795
|
const getBlobType = uri => {
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1796
|
+
const types = {
|
|
1797
|
+
css: 'text/css',
|
|
1798
|
+
html: 'text/html',
|
|
1799
|
+
js: 'text/javascript',
|
|
1800
|
+
json: 'application/json',
|
|
1801
|
+
svg: 'image/svg+xml',
|
|
1802
|
+
txt: 'text/plain',
|
|
1803
|
+
xml: 'application/xml'
|
|
1804
|
+
};
|
|
1805
|
+
return types[getFileExtension(uri).toLowerCase()] || '';
|
|
1806
|
+
};
|
|
1807
|
+
const readFileAsBlob$2 = async uri => {
|
|
1808
|
+
const entry = getEntry(uri);
|
|
1809
|
+
if (!entry) throw new Error(`File not found: ${uri}`);
|
|
1810
|
+
if (entry.type !== file) throw new Error(`File is a directory: ${uri}`);
|
|
1811
|
+
return entry.content;
|
|
1812
|
+
};
|
|
1813
|
+
const readFile$2 = async uri => {
|
|
1814
|
+
const blob = await readFileAsBlob$2(uri);
|
|
1815
|
+
return blob.text();
|
|
1816
|
+
};
|
|
1817
|
+
const writeFile$2 = async (uri, content) => {
|
|
1818
|
+
const path = getPath(uri);
|
|
1819
|
+
ensureParentDirs(path);
|
|
1820
|
+
files.set(path, {
|
|
1821
|
+
content: new Blob([content], {
|
|
1822
|
+
type: getBlobType(uri)
|
|
1823
|
+
}),
|
|
1824
|
+
type: file
|
|
1825
|
+
});
|
|
1826
|
+
await triggerMemfsFileWatcher(uri);
|
|
1827
|
+
};
|
|
1828
|
+
const exists$2 = async uri => !!getEntry(uri);
|
|
1829
|
+
const createFile$2 = async uri => writeFile$2(uri, '');
|
|
1830
|
+
const mkdir$2 = async uri => {
|
|
1831
|
+
const path = getPath(uri);
|
|
1832
|
+
ensureParentDirs(path);
|
|
1833
|
+
files.set(path, {
|
|
1834
|
+
content: new Blob(),
|
|
1835
|
+
type: directory
|
|
1836
|
+
});
|
|
1837
|
+
await triggerMemfsFileWatcher(uri);
|
|
1838
|
+
};
|
|
1839
|
+
const remove$2 = async uri => {
|
|
1840
|
+
const path = getPath(uri);
|
|
1841
|
+
for (const key of files.keys()) {
|
|
1842
|
+
if (key === path || key.startsWith(`${path}/`)) files.delete(key);
|
|
1903
1843
|
}
|
|
1844
|
+
await triggerMemfsFileWatcher(uri);
|
|
1904
1845
|
};
|
|
1846
|
+
const readDirWithFileTypes$2 = async uri => {
|
|
1847
|
+
const path = `${getPath(uri)}/`;
|
|
1848
|
+
const entries = new Map();
|
|
1849
|
+
for (const [key, value] of files) {
|
|
1850
|
+
if (!key.startsWith(path) || key === path) continue;
|
|
1851
|
+
const rest = key.slice(path.length);
|
|
1852
|
+
const slash = rest.indexOf('/');
|
|
1853
|
+
entries.set(slash === -1 ? rest : rest.slice(0, slash), slash === -1 ? value.type : directory);
|
|
1854
|
+
}
|
|
1855
|
+
return Array.from(entries, ([name, type]) => ({
|
|
1856
|
+
name,
|
|
1857
|
+
type
|
|
1858
|
+
}));
|
|
1859
|
+
};
|
|
1860
|
+
const rename$2 = async (oldUri, newUri) => {
|
|
1861
|
+
const oldPath = getPath(oldUri);
|
|
1862
|
+
const newPath = getPath(newUri);
|
|
1863
|
+
const entry = getEntry(oldUri);
|
|
1864
|
+
if (!entry) throw new Error(`File not found: ${oldUri}`);
|
|
1865
|
+
if (oldPath === newPath) return;
|
|
1866
|
+
if (newPath.startsWith(`${oldPath}/`)) throw new Error('Cannot move a directory into itself');
|
|
1867
|
+
ensureParentDirs(newPath);
|
|
1868
|
+
// Snapshot before mutating the map so newly inserted keys are not visited.
|
|
1869
|
+
const entries = [...files];
|
|
1870
|
+
for (const [key, value] of entries) {
|
|
1871
|
+
if (!(key === oldPath || key.startsWith(`${oldPath}/`))) {
|
|
1872
|
+
continue;
|
|
1873
|
+
}
|
|
1874
|
+
files.set(`${newPath}${key.slice(oldPath.length)}`, value);
|
|
1875
|
+
files.delete(key);
|
|
1876
|
+
}
|
|
1877
|
+
await triggerMemfsFileWatcher(oldUri);
|
|
1878
|
+
await triggerMemfsFileWatcher(newUri);
|
|
1879
|
+
};
|
|
1880
|
+
const copy$2 = async (oldUri, newUri) => writeFile$2(newUri, await readFile$2(oldUri));
|
|
1881
|
+
const stat$2 = async uri => {
|
|
1882
|
+
const entry = getEntry(uri);
|
|
1883
|
+
return entry ? {
|
|
1884
|
+
exists: true,
|
|
1885
|
+
size: entry.content.size,
|
|
1886
|
+
type: entry.type
|
|
1887
|
+
} : {
|
|
1888
|
+
exists: false,
|
|
1889
|
+
size: 0
|
|
1890
|
+
};
|
|
1891
|
+
};
|
|
1892
|
+
const readJson$2 = async uri => JSON.parse(await readFile$2(uri));
|
|
1893
|
+
const getPathSeparator$1 = async _root => '/';
|
|
1894
|
+
const getRealPath$2 = async uri => uri;
|
|
1895
|
+
const getFolderSize$2 = async uri => {
|
|
1896
|
+
const path = `${getPath(uri)}/`;
|
|
1897
|
+
let size = 0;
|
|
1898
|
+
for (const [key, entry] of files) if (key.startsWith(path)) size += entry.content.size;
|
|
1899
|
+
return size;
|
|
1900
|
+
};
|
|
1901
|
+
const getFiles = async () => {
|
|
1902
|
+
const entries = await Promise.all(Array.from(files, async ([path, entry]) => [path, {
|
|
1903
|
+
content: await entry.content.text(),
|
|
1904
|
+
type: entry.type
|
|
1905
|
+
}]));
|
|
1906
|
+
return Object.fromEntries(entries);
|
|
1907
|
+
};
|
|
1908
|
+
|
|
1909
|
+
const FileSystemMemory = {
|
|
1910
|
+
__proto__: null,
|
|
1911
|
+
copy: copy$2,
|
|
1912
|
+
createFile: createFile$2,
|
|
1913
|
+
exists: exists$2,
|
|
1914
|
+
getFiles,
|
|
1915
|
+
getFolderSize: getFolderSize$2,
|
|
1916
|
+
getPathSeparator: getPathSeparator$1,
|
|
1917
|
+
getRealPath: getRealPath$2,
|
|
1918
|
+
mkdir: mkdir$2,
|
|
1919
|
+
readDirWithFileTypes: readDirWithFileTypes$2,
|
|
1920
|
+
readFile: readFile$2,
|
|
1921
|
+
readFileAsBlob: readFileAsBlob$2,
|
|
1922
|
+
readJson: readJson$2,
|
|
1923
|
+
remove: remove$2,
|
|
1924
|
+
rename: rename$2,
|
|
1925
|
+
stat: stat$2,
|
|
1926
|
+
writeFile: writeFile$2
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1929
|
+
const memoryRoot = id => `memfs:///applications/${encodeURIComponent(id)}`;
|
|
1930
|
+
const memoryUri = (id, uri) => `${memoryRoot(id)}/${uri.slice('memfs://'.length).replace(/^\/+/, '')}`;
|
|
1931
|
+
const execute = async (id, method, ...args) => {
|
|
1932
|
+
const [uri] = args;
|
|
1933
|
+
if (typeof uri !== 'string') throw new TypeError('Application filesystem requires a URI');
|
|
1934
|
+
if (uri.startsWith('memfs://')) {
|
|
1935
|
+
if (method === 'isReadonly') return false;
|
|
1936
|
+
const fn = FileSystemMemory[method === 'getBlob' ? 'readFileAsBlob' : method];
|
|
1937
|
+
if (typeof fn !== 'function') throw new Error(`Unsupported application memory operation: ${method}`);
|
|
1938
|
+
const mapped = [...args];
|
|
1939
|
+
mapped[0] = memoryUri(id, uri);
|
|
1940
|
+
if (method === 'rename' || method === 'copy') {
|
|
1941
|
+
if (typeof args[1] !== 'string' || !args[1].startsWith('memfs://')) throw new Error('Cross-filesystem operation is not supported');
|
|
1942
|
+
mapped[1] = memoryUri(id, args[1]);
|
|
1943
|
+
}
|
|
1944
|
+
return fn(...mapped);
|
|
1945
|
+
}
|
|
1946
|
+
// Provider activation and component-state access need application context.
|
|
1947
|
+
// This callback handles only non-memory URIs, never file contents storage.
|
|
1948
|
+
return invoke$2('Application.execute', id, `FileSystem.${method}`, ...args);
|
|
1949
|
+
};
|
|
1950
|
+
const dispose = async id => remove$2(memoryRoot(id));
|
|
1951
|
+
|
|
1952
|
+
const normalizeBlobError = error => {
|
|
1953
|
+
const ProgressEventConstructor = ProgressEvent;
|
|
1954
|
+
if (error && ProgressEventConstructor && error instanceof ProgressEventConstructor && error.target &&
|
|
1955
|
+
// @ts-expect-error - target.error may not be in the type definition
|
|
1956
|
+
error.target.error) {
|
|
1957
|
+
// @ts-expect-error - target.error may not be in the type definition
|
|
1958
|
+
return error.target.error;
|
|
1959
|
+
}
|
|
1960
|
+
return error;
|
|
1961
|
+
};
|
|
1962
|
+
|
|
1963
|
+
const binaryStringToBlob = async (string, type) => {
|
|
1964
|
+
try {
|
|
1965
|
+
return binaryStringToBlob$1(string, type);
|
|
1966
|
+
} catch (error) {
|
|
1967
|
+
const normalizedError = normalizeBlobError(error);
|
|
1968
|
+
throw new VError(normalizedError, 'Failed to convert binary string to blob');
|
|
1969
|
+
}
|
|
1970
|
+
};
|
|
1971
|
+
const blobToBinaryString = async blob => {
|
|
1972
|
+
try {
|
|
1973
|
+
return await blobToBinaryString$1(blob);
|
|
1974
|
+
} catch (error) {
|
|
1975
|
+
const normalizedError = normalizeBlobError(error);
|
|
1976
|
+
throw new VError(normalizedError, 'Failed to convert blob to binary string');
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
|
|
1980
|
+
const connect = async port => {
|
|
1981
|
+
const {
|
|
1982
|
+
commandMap
|
|
1983
|
+
} = await Promise.resolve().then(function () { return CommandMap; });
|
|
1984
|
+
await create$6({
|
|
1985
|
+
commandMap,
|
|
1986
|
+
messagePort: port
|
|
1987
|
+
});
|
|
1988
|
+
};
|
|
1989
|
+
|
|
1905
1990
|
const remove$1 = async dirent => {
|
|
1906
|
-
|
|
1907
|
-
// Trigger file watchers for memfs files
|
|
1908
|
-
await triggerMemfsFileWatcher(dirent);
|
|
1991
|
+
throw new Error('not implemented');
|
|
1909
1992
|
};
|
|
1910
1993
|
const readFile$1 = async uri => {
|
|
1911
|
-
|
|
1994
|
+
const response = await fetch(uri);
|
|
1995
|
+
if (!response.ok) {
|
|
1996
|
+
throw new Error(response.statusText);
|
|
1997
|
+
}
|
|
1998
|
+
const result = await response.text();
|
|
1999
|
+
return result;
|
|
1912
2000
|
};
|
|
1913
2001
|
const readFileAsBlob$1 = async uri => {
|
|
1914
|
-
const
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
return new Blob([content], {
|
|
1918
|
-
type
|
|
1919
|
-
});
|
|
2002
|
+
const response = await fetch(uri);
|
|
2003
|
+
if (!response.ok) {
|
|
2004
|
+
throw new Error(response.statusText);
|
|
1920
2005
|
}
|
|
1921
|
-
|
|
2006
|
+
const result = await response.blob();
|
|
2007
|
+
return result;
|
|
1922
2008
|
};
|
|
1923
2009
|
const exists$1 = async uri => {
|
|
1924
|
-
|
|
2010
|
+
const response = await fetch(uri);
|
|
2011
|
+
return response.ok;
|
|
1925
2012
|
};
|
|
1926
2013
|
const readDirWithFileTypes$1 = async uri => {
|
|
1927
2014
|
throw new Error('not implemented');
|
|
1928
2015
|
};
|
|
1929
2016
|
const readJson$1 = async uri => {
|
|
1930
|
-
|
|
2017
|
+
const response = await fetch(uri);
|
|
2018
|
+
if (!response.ok) {
|
|
2019
|
+
throw new Error(response.statusText);
|
|
2020
|
+
}
|
|
2021
|
+
const json = await response.json();
|
|
2022
|
+
return json;
|
|
1931
2023
|
};
|
|
1932
2024
|
const getRealPath$1 = async path => {
|
|
1933
2025
|
throw new Error('not implemented');
|
|
@@ -1936,23 +2028,16 @@ const stat$1 = async dirent => {
|
|
|
1936
2028
|
throw new Error('not implemented');
|
|
1937
2029
|
};
|
|
1938
2030
|
const createFile$1 = async uri => {
|
|
1939
|
-
|
|
1940
|
-
// Trigger file watchers for memfs files
|
|
1941
|
-
await triggerMemfsFileWatcher(uri);
|
|
2031
|
+
throw new Error('not implemented');
|
|
1942
2032
|
};
|
|
1943
2033
|
const writeFile$1 = async (uri, content) => {
|
|
1944
|
-
|
|
1945
|
-
// Trigger file watchers for memfs files
|
|
1946
|
-
await triggerMemfsFileWatcher(uri);
|
|
2034
|
+
throw new Error('not implemented');
|
|
1947
2035
|
};
|
|
1948
2036
|
const mkdir$1 = async uri => {
|
|
1949
2037
|
throw new Error('not implemented');
|
|
1950
2038
|
};
|
|
1951
2039
|
const rename$1 = async (oldUri, newUri) => {
|
|
1952
|
-
|
|
1953
|
-
// Trigger file watchers for both old and new URIs
|
|
1954
|
-
await triggerMemfsFileWatcher(oldUri);
|
|
1955
|
-
await triggerMemfsFileWatcher(newUri);
|
|
2040
|
+
throw new Error('not implemented');
|
|
1956
2041
|
};
|
|
1957
2042
|
const copy$1 = async (oldUri, newUri) => {
|
|
1958
2043
|
throw new Error('not implemented');
|
|
@@ -1961,7 +2046,7 @@ const getFolderSize$1 = async uri => {
|
|
|
1961
2046
|
throw new Error('not implemented');
|
|
1962
2047
|
};
|
|
1963
2048
|
|
|
1964
|
-
const
|
|
2049
|
+
const FileSystemFetch = {
|
|
1965
2050
|
__proto__: null,
|
|
1966
2051
|
copy: copy$1,
|
|
1967
2052
|
createFile: createFile$1,
|
|
@@ -2003,21 +2088,28 @@ const isProviderUri = uri => {
|
|
|
2003
2088
|
|
|
2004
2089
|
const remove = async dirent => {
|
|
2005
2090
|
if (isMemory(dirent)) {
|
|
2006
|
-
return remove$
|
|
2091
|
+
return remove$2(dirent);
|
|
2007
2092
|
}
|
|
2008
|
-
|
|
2093
|
+
if (isProviderUri(dirent)) {
|
|
2094
|
+
return invoke$2('FileSystem.remove', dirent);
|
|
2095
|
+
}
|
|
2096
|
+
return remove$3(dirent);
|
|
2009
2097
|
};
|
|
2010
2098
|
const readFile = async uri => {
|
|
2099
|
+
if (uri.startsWith('untitled:')) return '';
|
|
2011
2100
|
if (isFetch(uri) || isHtml(uri)) {
|
|
2012
2101
|
return invoke$2('FileSystem.readFile', uri);
|
|
2013
2102
|
}
|
|
2014
2103
|
if (isHttp(uri)) {
|
|
2015
|
-
return readFile$
|
|
2104
|
+
return readFile$1(uri);
|
|
2105
|
+
}
|
|
2106
|
+
if (isMemory(uri)) {
|
|
2107
|
+
return readFile$2(uri);
|
|
2016
2108
|
}
|
|
2017
|
-
if (
|
|
2109
|
+
if (isProviderUri(uri)) {
|
|
2018
2110
|
return invoke$2('FileSystem.readFile', uri);
|
|
2019
2111
|
}
|
|
2020
|
-
return readFile$
|
|
2112
|
+
return readFile$3(uri);
|
|
2021
2113
|
};
|
|
2022
2114
|
const getFileHash = async uri => {
|
|
2023
2115
|
return getFileHash$1(uri);
|
|
@@ -2032,25 +2124,29 @@ const readDirWithFileTypes = async uri => {
|
|
|
2032
2124
|
if (isFetch(uri) || isHtml(uri)) {
|
|
2033
2125
|
return invoke$2('FileSystem.readDirWithFileTypes', uri);
|
|
2034
2126
|
}
|
|
2035
|
-
if (isMemory(uri)
|
|
2127
|
+
if (isMemory(uri)) {
|
|
2128
|
+
return readDirWithFileTypes$2(uri);
|
|
2129
|
+
}
|
|
2130
|
+
if (isProviderUri(uri)) {
|
|
2036
2131
|
return invoke$2('FileSystem.readDirWithFileTypes', uri);
|
|
2037
2132
|
}
|
|
2038
|
-
return readDirWithFileTypes$
|
|
2133
|
+
return readDirWithFileTypes$3(uri);
|
|
2039
2134
|
};
|
|
2040
2135
|
const isReadonly = async uri => {
|
|
2041
2136
|
return invoke$1('FileSystem.isReadonly', uri);
|
|
2042
2137
|
};
|
|
2043
2138
|
const readJson = async uri => {
|
|
2044
2139
|
if (isHttp(uri)) {
|
|
2045
|
-
return readJson$
|
|
2140
|
+
return readJson$1(uri);
|
|
2046
2141
|
}
|
|
2047
2142
|
if (isMemory(uri)) {
|
|
2048
|
-
return readJson$
|
|
2143
|
+
return readJson$2(uri);
|
|
2049
2144
|
}
|
|
2050
|
-
return readJson$
|
|
2145
|
+
return readJson$3(uri);
|
|
2051
2146
|
};
|
|
2052
2147
|
const getRealPath = async path => {
|
|
2053
|
-
return getRealPath$2(path);
|
|
2148
|
+
if (isMemory(path)) return getRealPath$2(path);
|
|
2149
|
+
return getRealPath$3(path);
|
|
2054
2150
|
};
|
|
2055
2151
|
const getFileSize = async uri => {
|
|
2056
2152
|
if (isHttp(uri) || isMemory(uri)) {
|
|
@@ -2060,10 +2156,10 @@ const getFileSize = async uri => {
|
|
|
2060
2156
|
};
|
|
2061
2157
|
const readFileAsBlob = async uri => {
|
|
2062
2158
|
if (isHttp(uri)) {
|
|
2063
|
-
return readFileAsBlob$
|
|
2159
|
+
return readFileAsBlob$1(uri);
|
|
2064
2160
|
}
|
|
2065
2161
|
if (isMemory(uri)) {
|
|
2066
|
-
return readFileAsBlob$
|
|
2162
|
+
return readFileAsBlob$2(uri);
|
|
2067
2163
|
}
|
|
2068
2164
|
if (uri.startsWith('file:///')) {
|
|
2069
2165
|
const rest = uri.slice('file:///'.length);
|
|
@@ -2078,31 +2174,35 @@ const readFileAsBlob = async uri => {
|
|
|
2078
2174
|
throw new Error('uri not supported');
|
|
2079
2175
|
};
|
|
2080
2176
|
const stat = async dirent => {
|
|
2081
|
-
return stat$2(dirent);
|
|
2177
|
+
if (isMemory(dirent)) return stat$2(dirent);
|
|
2178
|
+
return stat$3(dirent);
|
|
2082
2179
|
};
|
|
2083
2180
|
const exists = async uri => {
|
|
2084
2181
|
if (isFetch(uri) || isHtml(uri)) {
|
|
2085
2182
|
return invoke$2('FileSystem.exists', uri);
|
|
2086
2183
|
}
|
|
2087
2184
|
if (isHttp(uri)) {
|
|
2088
|
-
return exists$
|
|
2185
|
+
return exists$1(uri);
|
|
2089
2186
|
}
|
|
2090
2187
|
if (isMemory(uri)) {
|
|
2091
|
-
return
|
|
2188
|
+
return exists$2(uri);
|
|
2092
2189
|
}
|
|
2093
|
-
return exists$
|
|
2190
|
+
return exists$3(uri);
|
|
2094
2191
|
};
|
|
2095
2192
|
const createFile = async uri => {
|
|
2096
2193
|
if (isMemory(uri)) {
|
|
2097
|
-
return createFile$
|
|
2194
|
+
return createFile$2(uri);
|
|
2098
2195
|
}
|
|
2099
|
-
return writeFile$
|
|
2196
|
+
return writeFile$3(uri, '');
|
|
2100
2197
|
};
|
|
2101
2198
|
const writeFile = async (uri, content) => {
|
|
2102
2199
|
if (isMemory(uri)) {
|
|
2200
|
+
return writeFile$2(uri, content);
|
|
2201
|
+
}
|
|
2202
|
+
if (isProviderUri(uri)) {
|
|
2103
2203
|
return invoke$2('FileSystem.writeFile', uri, content);
|
|
2104
2204
|
}
|
|
2105
|
-
return writeFile$
|
|
2205
|
+
return writeFile$3(uri, content);
|
|
2106
2206
|
};
|
|
2107
2207
|
const getBytes = async blob => {
|
|
2108
2208
|
if (blob.bytes) {
|
|
@@ -2119,22 +2219,27 @@ const writeBlob = async (uri, blob) => {
|
|
|
2119
2219
|
};
|
|
2120
2220
|
const mkdir = async uri => {
|
|
2121
2221
|
if (isMemory(uri)) {
|
|
2122
|
-
await
|
|
2222
|
+
await mkdir$2(uri);
|
|
2123
2223
|
return;
|
|
2124
2224
|
}
|
|
2125
|
-
return mkdir$
|
|
2225
|
+
return mkdir$3(uri);
|
|
2126
2226
|
};
|
|
2127
2227
|
const rename = async (oldUri, newUri) => {
|
|
2128
2228
|
if (isMemory(oldUri) || isMemory(newUri)) {
|
|
2129
|
-
return rename$
|
|
2229
|
+
return rename$2(oldUri, newUri);
|
|
2130
2230
|
}
|
|
2131
|
-
return rename$
|
|
2231
|
+
return rename$3(oldUri, newUri);
|
|
2132
2232
|
};
|
|
2133
2233
|
const copy = async (oldUri, newUri) => {
|
|
2134
|
-
return copy$2(oldUri, newUri);
|
|
2234
|
+
if (isMemory(oldUri) && isMemory(newUri)) return copy$2(oldUri, newUri);
|
|
2235
|
+
return copy$3(oldUri, newUri);
|
|
2135
2236
|
};
|
|
2136
2237
|
const getFolderSize = async uri => {
|
|
2137
|
-
return getFolderSize$
|
|
2238
|
+
return getFolderSize$3(uri);
|
|
2239
|
+
};
|
|
2240
|
+
const getPathSeparator = async uri => {
|
|
2241
|
+
if (isMemory(uri)) return getPathSeparator$1();
|
|
2242
|
+
return invoke$1('FileSystem.getPathSeparator', uri);
|
|
2138
2243
|
};
|
|
2139
2244
|
|
|
2140
2245
|
const FileSystemDisk = {
|
|
@@ -2147,6 +2252,7 @@ const FileSystemDisk = {
|
|
|
2147
2252
|
getFileHashes,
|
|
2148
2253
|
getFileSize,
|
|
2149
2254
|
getFolderSize,
|
|
2255
|
+
getPathSeparator,
|
|
2150
2256
|
getRealPath,
|
|
2151
2257
|
isReadonly,
|
|
2152
2258
|
mkdir,
|
|
@@ -2593,10 +2699,13 @@ const uploadFileSystemHandles = async (root, pathSeparator, fileSystemHandles) =
|
|
|
2593
2699
|
};
|
|
2594
2700
|
|
|
2595
2701
|
const commandMap = {
|
|
2702
|
+
'ApplicationFileSystem.dispose': dispose,
|
|
2703
|
+
'ApplicationFileSystem.execute': execute,
|
|
2596
2704
|
'Blob.base64StringToBlob': base64StringToBlob,
|
|
2597
2705
|
'Blob.binaryStringToBlob': binaryStringToBlob,
|
|
2598
2706
|
'Blob.blobToBinaryString': blobToBinaryString,
|
|
2599
2707
|
'FileSystem.appendFile': appendFile,
|
|
2708
|
+
'FileSystem.connect': connect,
|
|
2600
2709
|
'FileSystem.copy': copy,
|
|
2601
2710
|
'FileSystem.createFile': createFile,
|
|
2602
2711
|
'FileSystem.executeWatchCallback': executeWatchCallback,
|
|
@@ -2605,6 +2714,7 @@ const commandMap = {
|
|
|
2605
2714
|
'FileSystem.getFileHashes': getFileHashes,
|
|
2606
2715
|
'FileSystem.getFileSize': getFileSize,
|
|
2607
2716
|
'FileSystem.getFolderSize': getFolderSize,
|
|
2717
|
+
'FileSystem.getPathSeparator': getPathSeparator,
|
|
2608
2718
|
'FileSystem.getRealPath': getRealPath,
|
|
2609
2719
|
'FileSystem.glob': glob,
|
|
2610
2720
|
'FileSystem.handleMessagePort': handleMessagePort,
|
|
@@ -2622,9 +2732,15 @@ const commandMap = {
|
|
|
2622
2732
|
'FileSystem.watchFile': watchFile,
|
|
2623
2733
|
'FileSystem.writeBlob': writeBlob,
|
|
2624
2734
|
'FileSystem.writeFile': writeFile,
|
|
2735
|
+
'FileSystemMemory.getFiles': getFiles,
|
|
2625
2736
|
'Initialize.initialize': initialize
|
|
2626
2737
|
};
|
|
2627
2738
|
|
|
2739
|
+
const CommandMap = {
|
|
2740
|
+
__proto__: null,
|
|
2741
|
+
commandMap
|
|
2742
|
+
};
|
|
2743
|
+
|
|
2628
2744
|
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
2629
2745
|
|
|
2630
2746
|
const state = Object.create(null);
|