@lvce-editor/file-system-worker 5.19.2 → 5.20.1

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.
@@ -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$2,
1786
- exists: exists$2,
1787
- getFolderSize: getFolderSize$2,
1788
- getRealPath: getRealPath$2,
1679
+ copy: copy$3,
1680
+ exists: exists$3,
1681
+ getFolderSize: getFolderSize$3,
1682
+ getRealPath: getRealPath$3,
1789
1683
  invoke: invoke$1,
1790
- mkdir: mkdir$2,
1791
- readDirWithFileTypes: readDirWithFileTypes$2,
1792
- readFile: readFile$2,
1793
- readJson: readJson$2,
1794
- remove: remove$2,
1795
- rename: rename$2,
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$2,
1798
- writeFile: writeFile$2
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 extension = getFileExtension(uri).toLowerCase();
1886
- switch (extension) {
1887
- case 'css':
1888
- return 'text/css';
1889
- case 'html':
1890
- return 'text/html';
1891
- case 'js':
1892
- return 'text/javascript';
1893
- case 'json':
1894
- return 'application/json';
1895
- case 'svg':
1896
- return 'image/svg+xml';
1897
- case 'txt':
1898
- return 'text/plain';
1899
- case 'xml':
1900
- return 'application/xml';
1901
- default:
1902
- return '';
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);
1843
+ }
1844
+ await triggerMemfsFileWatcher(uri);
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);
1903
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;
1904
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
- await invoke$4('FileSystemMemory.remove', dirent);
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
- return invoke$4('FileSystemMemory.readFile', uri);
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 content = await readFile$1(uri);
1915
- const type = getBlobType(uri);
1916
- if (type) {
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
- return new Blob([content]);
2006
+ const result = await response.blob();
2007
+ return result;
1922
2008
  };
1923
2009
  const exists$1 = async uri => {
1924
- throw new Error('not implemented');
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
- throw new Error('not implemented');
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
- await invoke$4('FileSystemMemory.createFile', uri);
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
- await invoke$4('FileSystemMemory.writeFile', uri, content);
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
- await invoke$4('FileSystemMemory.rename', oldUri, newUri);
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 FileSystemMemory = {
2049
+ const FileSystemFetch = {
1965
2050
  __proto__: null,
1966
2051
  copy: copy$1,
1967
2052
  createFile: createFile$1,
@@ -2003,24 +2088,28 @@ const isProviderUri = uri => {
2003
2088
 
2004
2089
  const remove = async dirent => {
2005
2090
  if (isMemory(dirent)) {
2006
- return remove$1(dirent);
2091
+ return remove$2(dirent);
2007
2092
  }
2008
2093
  if (isProviderUri(dirent)) {
2009
2094
  return invoke$2('FileSystem.remove', dirent);
2010
2095
  }
2011
- return remove$2(dirent);
2096
+ return remove$3(dirent);
2012
2097
  };
2013
2098
  const readFile = async uri => {
2099
+ if (uri.startsWith('untitled:')) return '';
2014
2100
  if (isFetch(uri) || isHtml(uri)) {
2015
2101
  return invoke$2('FileSystem.readFile', uri);
2016
2102
  }
2017
2103
  if (isHttp(uri)) {
2018
- return readFile$3(uri);
2104
+ return readFile$1(uri);
2105
+ }
2106
+ if (isMemory(uri)) {
2107
+ return readFile$2(uri);
2019
2108
  }
2020
- if (isMemory(uri) || isProviderUri(uri)) {
2109
+ if (isProviderUri(uri)) {
2021
2110
  return invoke$2('FileSystem.readFile', uri);
2022
2111
  }
2023
- return readFile$2(uri);
2112
+ return readFile$3(uri);
2024
2113
  };
2025
2114
  const getFileHash = async uri => {
2026
2115
  return getFileHash$1(uri);
@@ -2035,25 +2124,29 @@ const readDirWithFileTypes = async uri => {
2035
2124
  if (isFetch(uri) || isHtml(uri)) {
2036
2125
  return invoke$2('FileSystem.readDirWithFileTypes', uri);
2037
2126
  }
2038
- if (isMemory(uri) || isProviderUri(uri)) {
2127
+ if (isMemory(uri)) {
2128
+ return readDirWithFileTypes$2(uri);
2129
+ }
2130
+ if (isProviderUri(uri)) {
2039
2131
  return invoke$2('FileSystem.readDirWithFileTypes', uri);
2040
2132
  }
2041
- return readDirWithFileTypes$2(uri);
2133
+ return readDirWithFileTypes$3(uri);
2042
2134
  };
2043
2135
  const isReadonly = async uri => {
2044
2136
  return invoke$1('FileSystem.isReadonly', uri);
2045
2137
  };
2046
2138
  const readJson = async uri => {
2047
2139
  if (isHttp(uri)) {
2048
- return readJson$3(uri);
2140
+ return readJson$1(uri);
2049
2141
  }
2050
2142
  if (isMemory(uri)) {
2051
- return readJson$1();
2143
+ return readJson$2(uri);
2052
2144
  }
2053
- return readJson$2(uri);
2145
+ return readJson$3(uri);
2054
2146
  };
2055
2147
  const getRealPath = async path => {
2056
- return getRealPath$2(path);
2148
+ if (isMemory(path)) return getRealPath$2(path);
2149
+ return getRealPath$3(path);
2057
2150
  };
2058
2151
  const getFileSize = async uri => {
2059
2152
  if (isHttp(uri) || isMemory(uri)) {
@@ -2063,10 +2156,10 @@ const getFileSize = async uri => {
2063
2156
  };
2064
2157
  const readFileAsBlob = async uri => {
2065
2158
  if (isHttp(uri)) {
2066
- return readFileAsBlob$2(uri);
2159
+ return readFileAsBlob$1(uri);
2067
2160
  }
2068
2161
  if (isMemory(uri)) {
2069
- return readFileAsBlob$1(uri);
2162
+ return readFileAsBlob$2(uri);
2070
2163
  }
2071
2164
  if (uri.startsWith('file:///')) {
2072
2165
  const rest = uri.slice('file:///'.length);
@@ -2078,34 +2171,41 @@ const readFileAsBlob = async uri => {
2078
2171
  const blob = await response.blob();
2079
2172
  return blob;
2080
2173
  }
2174
+ if (isProviderUri(uri)) {
2175
+ return invoke$2('FileSystem.getBlob', uri);
2176
+ }
2081
2177
  throw new Error('uri not supported');
2082
2178
  };
2083
2179
  const stat = async dirent => {
2084
- return stat$2(dirent);
2180
+ if (isMemory(dirent)) return stat$2(dirent);
2181
+ return stat$3(dirent);
2085
2182
  };
2086
2183
  const exists = async uri => {
2087
2184
  if (isFetch(uri) || isHtml(uri)) {
2088
2185
  return invoke$2('FileSystem.exists', uri);
2089
2186
  }
2090
2187
  if (isHttp(uri)) {
2091
- return exists$3(uri);
2188
+ return exists$1(uri);
2092
2189
  }
2093
2190
  if (isMemory(uri)) {
2094
- return invoke$2('FileSystem.exists', uri);
2191
+ return exists$2(uri);
2095
2192
  }
2096
- return exists$2(uri);
2193
+ return exists$3(uri);
2097
2194
  };
2098
2195
  const createFile = async uri => {
2099
2196
  if (isMemory(uri)) {
2100
- return createFile$1(uri);
2197
+ return createFile$2(uri);
2101
2198
  }
2102
- return writeFile$2(uri, '');
2199
+ return writeFile$3(uri, '');
2103
2200
  };
2104
2201
  const writeFile = async (uri, content) => {
2105
- if (isMemory(uri) || isProviderUri(uri)) {
2202
+ if (isMemory(uri)) {
2203
+ return writeFile$2(uri, content);
2204
+ }
2205
+ if (isProviderUri(uri)) {
2106
2206
  return invoke$2('FileSystem.writeFile', uri, content);
2107
2207
  }
2108
- return writeFile$2(uri, content);
2208
+ return writeFile$3(uri, content);
2109
2209
  };
2110
2210
  const getBytes = async blob => {
2111
2211
  if (blob.bytes) {
@@ -2122,22 +2222,27 @@ const writeBlob = async (uri, blob) => {
2122
2222
  };
2123
2223
  const mkdir = async uri => {
2124
2224
  if (isMemory(uri)) {
2125
- await invoke$2('FileSystem.mkdir', uri);
2225
+ await mkdir$2(uri);
2126
2226
  return;
2127
2227
  }
2128
- return mkdir$2(uri);
2228
+ return mkdir$3(uri);
2129
2229
  };
2130
2230
  const rename = async (oldUri, newUri) => {
2131
2231
  if (isMemory(oldUri) || isMemory(newUri)) {
2132
- return rename$1(oldUri, newUri);
2232
+ return rename$2(oldUri, newUri);
2133
2233
  }
2134
- return rename$2(oldUri, newUri);
2234
+ return rename$3(oldUri, newUri);
2135
2235
  };
2136
2236
  const copy = async (oldUri, newUri) => {
2137
- return copy$2(oldUri, newUri);
2237
+ if (isMemory(oldUri) && isMemory(newUri)) return copy$2(oldUri, newUri);
2238
+ return copy$3(oldUri, newUri);
2138
2239
  };
2139
2240
  const getFolderSize = async uri => {
2140
- return getFolderSize$2(uri);
2241
+ return getFolderSize$3(uri);
2242
+ };
2243
+ const getPathSeparator = async uri => {
2244
+ if (isMemory(uri)) return getPathSeparator$1();
2245
+ return invoke$1('FileSystem.getPathSeparator', uri);
2141
2246
  };
2142
2247
 
2143
2248
  const FileSystemDisk = {
@@ -2150,6 +2255,7 @@ const FileSystemDisk = {
2150
2255
  getFileHashes,
2151
2256
  getFileSize,
2152
2257
  getFolderSize,
2258
+ getPathSeparator,
2153
2259
  getRealPath,
2154
2260
  isReadonly,
2155
2261
  mkdir,
@@ -2596,10 +2702,13 @@ const uploadFileSystemHandles = async (root, pathSeparator, fileSystemHandles) =
2596
2702
  };
2597
2703
 
2598
2704
  const commandMap = {
2705
+ 'ApplicationFileSystem.dispose': dispose,
2706
+ 'ApplicationFileSystem.execute': execute,
2599
2707
  'Blob.base64StringToBlob': base64StringToBlob,
2600
2708
  'Blob.binaryStringToBlob': binaryStringToBlob,
2601
2709
  'Blob.blobToBinaryString': blobToBinaryString,
2602
2710
  'FileSystem.appendFile': appendFile,
2711
+ 'FileSystem.connect': connect,
2603
2712
  'FileSystem.copy': copy,
2604
2713
  'FileSystem.createFile': createFile,
2605
2714
  'FileSystem.executeWatchCallback': executeWatchCallback,
@@ -2608,6 +2717,7 @@ const commandMap = {
2608
2717
  'FileSystem.getFileHashes': getFileHashes,
2609
2718
  'FileSystem.getFileSize': getFileSize,
2610
2719
  'FileSystem.getFolderSize': getFolderSize,
2720
+ 'FileSystem.getPathSeparator': getPathSeparator,
2611
2721
  'FileSystem.getRealPath': getRealPath,
2612
2722
  'FileSystem.glob': glob,
2613
2723
  'FileSystem.handleMessagePort': handleMessagePort,
@@ -2625,9 +2735,15 @@ const commandMap = {
2625
2735
  'FileSystem.watchFile': watchFile,
2626
2736
  'FileSystem.writeBlob': writeBlob,
2627
2737
  'FileSystem.writeFile': writeFile,
2738
+ 'FileSystemMemory.getFiles': getFiles,
2628
2739
  'Initialize.initialize': initialize
2629
2740
  };
2630
2741
 
2742
+ const CommandMap = {
2743
+ __proto__: null,
2744
+ commandMap
2745
+ };
2746
+
2631
2747
  /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
2632
2748
 
2633
2749
  const state = Object.create(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-system-worker",
3
- "version": "5.19.2",
3
+ "version": "5.20.1",
4
4
  "description": "File System Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"