@lvce-editor/file-system-worker 5.16.0 → 5.18.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 +358 -59
- package/package.json +1 -1
|
@@ -1256,6 +1256,34 @@ const listen$1 = async (module, options) => {
|
|
|
1256
1256
|
return ipc;
|
|
1257
1257
|
};
|
|
1258
1258
|
|
|
1259
|
+
const createSharedLazyRpc = factory => {
|
|
1260
|
+
let rpcPromise;
|
|
1261
|
+
const getOrCreate = () => {
|
|
1262
|
+
if (!rpcPromise) {
|
|
1263
|
+
rpcPromise = factory();
|
|
1264
|
+
}
|
|
1265
|
+
return rpcPromise;
|
|
1266
|
+
};
|
|
1267
|
+
return {
|
|
1268
|
+
async dispose() {
|
|
1269
|
+
const rpc = await getOrCreate();
|
|
1270
|
+
await rpc.dispose();
|
|
1271
|
+
},
|
|
1272
|
+
async invoke(method, ...params) {
|
|
1273
|
+
const rpc = await getOrCreate();
|
|
1274
|
+
return rpc.invoke(method, ...params);
|
|
1275
|
+
},
|
|
1276
|
+
async invokeAndTransfer(method, ...params) {
|
|
1277
|
+
const rpc = await getOrCreate();
|
|
1278
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1279
|
+
},
|
|
1280
|
+
async send(method, ...params) {
|
|
1281
|
+
const rpc = await getOrCreate();
|
|
1282
|
+
rpc.send(method, ...params);
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
};
|
|
1286
|
+
|
|
1259
1287
|
const create$6 = async ({
|
|
1260
1288
|
commandMap,
|
|
1261
1289
|
isMessagePortOpen = true,
|
|
@@ -1291,34 +1319,6 @@ const create$5 = async ({
|
|
|
1291
1319
|
});
|
|
1292
1320
|
};
|
|
1293
1321
|
|
|
1294
|
-
const createSharedLazyRpc = factory => {
|
|
1295
|
-
let rpcPromise;
|
|
1296
|
-
const getOrCreate = () => {
|
|
1297
|
-
if (!rpcPromise) {
|
|
1298
|
-
rpcPromise = factory();
|
|
1299
|
-
}
|
|
1300
|
-
return rpcPromise;
|
|
1301
|
-
};
|
|
1302
|
-
return {
|
|
1303
|
-
async dispose() {
|
|
1304
|
-
const rpc = await getOrCreate();
|
|
1305
|
-
await rpc.dispose();
|
|
1306
|
-
},
|
|
1307
|
-
async invoke(method, ...params) {
|
|
1308
|
-
const rpc = await getOrCreate();
|
|
1309
|
-
return rpc.invoke(method, ...params);
|
|
1310
|
-
},
|
|
1311
|
-
async invokeAndTransfer(method, ...params) {
|
|
1312
|
-
const rpc = await getOrCreate();
|
|
1313
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1314
|
-
},
|
|
1315
|
-
async send(method, ...params) {
|
|
1316
|
-
const rpc = await getOrCreate();
|
|
1317
|
-
rpc.send(method, ...params);
|
|
1318
|
-
}
|
|
1319
|
-
};
|
|
1320
|
-
};
|
|
1321
|
-
|
|
1322
1322
|
const create$4 = async ({
|
|
1323
1323
|
commandMap,
|
|
1324
1324
|
isMessagePortOpen,
|
|
@@ -1506,6 +1506,9 @@ const create = rpcId => {
|
|
|
1506
1506
|
};
|
|
1507
1507
|
};
|
|
1508
1508
|
|
|
1509
|
+
const Directory$1 = 3;
|
|
1510
|
+
const File$3 = 7;
|
|
1511
|
+
|
|
1509
1512
|
const DebugWorker = 55;
|
|
1510
1513
|
const ExtensionHostWorker = 44;
|
|
1511
1514
|
const FileSystemProcess$1 = 210;
|
|
@@ -1596,58 +1599,101 @@ const FileSystemProcess = {
|
|
|
1596
1599
|
writeFile: writeFile$4
|
|
1597
1600
|
};
|
|
1598
1601
|
|
|
1599
|
-
const {
|
|
1600
|
-
set: set$2
|
|
1601
|
-
} = create(RendererProcess);
|
|
1602
|
-
|
|
1603
|
-
const {
|
|
1604
|
-
invoke: invoke$2,
|
|
1605
|
-
invokeAndTransfer,
|
|
1606
|
-
set: set$1
|
|
1607
|
-
} = create(RendererWorker);
|
|
1608
|
-
const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
|
|
1609
|
-
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1610
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
1611
|
-
};
|
|
1612
|
-
const sendMessagePortToRendererProcess = async port => {
|
|
1613
|
-
const command = 'HandleMessagePort.handleMessagePort';
|
|
1614
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
|
|
1615
|
-
};
|
|
1616
|
-
const sendMessagePortToFileSystemProcess$1 = async (port, rpcId) => {
|
|
1617
|
-
const command = 'HandleMessagePortForFileSystemProcess.handleMessagePortForFileSystemProcess';
|
|
1618
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, rpcId);
|
|
1619
|
-
};
|
|
1620
|
-
|
|
1621
1602
|
const createLazyRpc = rpcId => {
|
|
1622
|
-
let
|
|
1603
|
+
let activeRpc;
|
|
1623
1604
|
let factory;
|
|
1624
|
-
|
|
1605
|
+
let generation = 0;
|
|
1606
|
+
let rpcPromise;
|
|
1607
|
+
const resetListeners = new Set();
|
|
1608
|
+
const createRpc = async expectedGeneration => {
|
|
1625
1609
|
const rpc = await factory();
|
|
1610
|
+
if (generation !== expectedGeneration) {
|
|
1611
|
+
await rpc.dispose();
|
|
1612
|
+
throw new Error('Lazy RPC launch was superseded');
|
|
1613
|
+
}
|
|
1614
|
+
activeRpc = rpc;
|
|
1626
1615
|
set$5(rpcId, rpc);
|
|
1616
|
+
return rpc;
|
|
1627
1617
|
};
|
|
1628
1618
|
const ensureRpc = async () => {
|
|
1619
|
+
if (activeRpc) {
|
|
1620
|
+
return activeRpc;
|
|
1621
|
+
}
|
|
1629
1622
|
if (!rpcPromise) {
|
|
1630
|
-
|
|
1623
|
+
const pending = createRpc(generation);
|
|
1624
|
+
rpcPromise = pending;
|
|
1625
|
+
void pending.catch(() => {
|
|
1626
|
+
if (rpcPromise === pending) {
|
|
1627
|
+
rpcPromise = undefined;
|
|
1628
|
+
}
|
|
1629
|
+
});
|
|
1631
1630
|
}
|
|
1632
|
-
|
|
1631
|
+
return rpcPromise;
|
|
1632
|
+
};
|
|
1633
|
+
const clear = async (reason, notify) => {
|
|
1634
|
+
generation++;
|
|
1635
|
+
const rpc = activeRpc;
|
|
1636
|
+
activeRpc = undefined;
|
|
1637
|
+
rpcPromise = undefined;
|
|
1638
|
+
if (rpc && get(rpcId) === rpc) {
|
|
1639
|
+
remove$5(rpcId);
|
|
1640
|
+
}
|
|
1641
|
+
if (notify) {
|
|
1642
|
+
for (const listener of resetListeners) {
|
|
1643
|
+
listener(reason);
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
await rpc?.dispose();
|
|
1633
1647
|
};
|
|
1634
1648
|
return {
|
|
1649
|
+
dispose() {
|
|
1650
|
+
return clear(undefined, false);
|
|
1651
|
+
},
|
|
1635
1652
|
async invoke(method, ...params) {
|
|
1636
|
-
await ensureRpc();
|
|
1637
|
-
const rpc = get(rpcId);
|
|
1653
|
+
const rpc = await ensureRpc();
|
|
1638
1654
|
return rpc.invoke(method, ...params);
|
|
1639
1655
|
},
|
|
1640
1656
|
async invokeAndTransfer(method, ...params) {
|
|
1641
|
-
await ensureRpc();
|
|
1642
|
-
const rpc = get(rpcId);
|
|
1657
|
+
const rpc = await ensureRpc();
|
|
1643
1658
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1644
1659
|
},
|
|
1660
|
+
onDidReset(listener) {
|
|
1661
|
+
resetListeners.add(listener);
|
|
1662
|
+
return () => {
|
|
1663
|
+
resetListeners.delete(listener);
|
|
1664
|
+
};
|
|
1665
|
+
},
|
|
1666
|
+
reset(reason) {
|
|
1667
|
+
return clear(reason, true);
|
|
1668
|
+
},
|
|
1645
1669
|
setFactory(value) {
|
|
1646
1670
|
factory = value;
|
|
1647
1671
|
}
|
|
1648
1672
|
};
|
|
1649
1673
|
};
|
|
1650
1674
|
|
|
1675
|
+
const {
|
|
1676
|
+
set: set$2
|
|
1677
|
+
} = create(RendererProcess);
|
|
1678
|
+
|
|
1679
|
+
const {
|
|
1680
|
+
invoke: invoke$2,
|
|
1681
|
+
invokeAndTransfer,
|
|
1682
|
+
set: set$1
|
|
1683
|
+
} = create(RendererWorker);
|
|
1684
|
+
const sendMessagePortToRendererProcess = async port => {
|
|
1685
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1686
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
|
|
1687
|
+
};
|
|
1688
|
+
const sendMessagePortToFileSystemProcess$1 = async (port, rpcId) => {
|
|
1689
|
+
const command = 'HandleMessagePortForFileSystemProcess.handleMessagePortForFileSystemProcess';
|
|
1690
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, rpcId);
|
|
1691
|
+
};
|
|
1692
|
+
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
1693
|
+
const command = 'Extensions.handleMessagePort';
|
|
1694
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1695
|
+
};
|
|
1696
|
+
|
|
1651
1697
|
const remove$3 = async dirent => {
|
|
1652
1698
|
throw new Error('not implemented');
|
|
1653
1699
|
};
|
|
@@ -1740,6 +1786,9 @@ const assertUri = uri => {
|
|
|
1740
1786
|
const getFileHash$1 = async uri => {
|
|
1741
1787
|
return invoke$3('FileSystem.getFileHash', uri);
|
|
1742
1788
|
};
|
|
1789
|
+
const getFileHashes$1 = async uris => {
|
|
1790
|
+
return invoke$3('FileSystem.getFileHashes', uris);
|
|
1791
|
+
};
|
|
1743
1792
|
const {
|
|
1744
1793
|
appendFile: appendFile$1,
|
|
1745
1794
|
copy: copy$2,
|
|
@@ -1981,6 +2030,9 @@ const readFile = async uri => {
|
|
|
1981
2030
|
const getFileHash = async uri => {
|
|
1982
2031
|
return getFileHash$1(uri);
|
|
1983
2032
|
};
|
|
2033
|
+
const getFileHashes = async uris => {
|
|
2034
|
+
return getFileHashes$1(uris);
|
|
2035
|
+
};
|
|
1984
2036
|
const appendFile = async (uri, text) => {
|
|
1985
2037
|
return appendFile$1(uri, text);
|
|
1986
2038
|
};
|
|
@@ -2097,6 +2149,7 @@ const FileSystemDisk = {
|
|
|
2097
2149
|
createFile,
|
|
2098
2150
|
exists,
|
|
2099
2151
|
getFileHash,
|
|
2152
|
+
getFileHashes,
|
|
2100
2153
|
getFolderSize,
|
|
2101
2154
|
getPathSeparator,
|
|
2102
2155
|
getRealPath,
|
|
@@ -2113,6 +2166,250 @@ const FileSystemDisk = {
|
|
|
2113
2166
|
writeFile
|
|
2114
2167
|
};
|
|
2115
2168
|
|
|
2169
|
+
const createGlobImplementation = () => {
|
|
2170
|
+
const batchSize = 32;
|
|
2171
|
+
/* eslint-disable unicorn/consistent-function-scoping -- Keep implementation helpers lazy to stay within the worker memory budget. */
|
|
2172
|
+
|
|
2173
|
+
const joinPath = (base, name) => {
|
|
2174
|
+
return base ? `${base}/${name}` : name;
|
|
2175
|
+
};
|
|
2176
|
+
const joinUri = (base, name) => {
|
|
2177
|
+
return base.endsWith('/') ? `${base}${name}` : `${base}/${name}`;
|
|
2178
|
+
};
|
|
2179
|
+
const escapeRegexCharacter = character => {
|
|
2180
|
+
return /[\\^$.*+?()[\]|{}]/.test(character) ? `\\${character}` : character;
|
|
2181
|
+
};
|
|
2182
|
+
const getCharacterClass = (pattern, index) => {
|
|
2183
|
+
const endIndex = pattern.indexOf(']', index + 1);
|
|
2184
|
+
if (endIndex === -1) {
|
|
2185
|
+
return undefined;
|
|
2186
|
+
}
|
|
2187
|
+
let contents = pattern.slice(index + 1, endIndex).replaceAll('\\', '\\\\');
|
|
2188
|
+
if (contents.startsWith('!')) {
|
|
2189
|
+
contents = `^${contents.slice(1)}`;
|
|
2190
|
+
}
|
|
2191
|
+
return {
|
|
2192
|
+
endIndex,
|
|
2193
|
+
source: `[${contents}]`
|
|
2194
|
+
};
|
|
2195
|
+
};
|
|
2196
|
+
const getAsteriskToken = (pattern, index) => {
|
|
2197
|
+
if (pattern[index + 1] !== '*') {
|
|
2198
|
+
return {
|
|
2199
|
+
endIndex: index,
|
|
2200
|
+
source: '[^/]*'
|
|
2201
|
+
};
|
|
2202
|
+
}
|
|
2203
|
+
if (pattern[index + 2] === '/') {
|
|
2204
|
+
return {
|
|
2205
|
+
endIndex: index + 2,
|
|
2206
|
+
source: '(?:.*/)?'
|
|
2207
|
+
};
|
|
2208
|
+
}
|
|
2209
|
+
return {
|
|
2210
|
+
endIndex: index + 1,
|
|
2211
|
+
source: '.*'
|
|
2212
|
+
};
|
|
2213
|
+
};
|
|
2214
|
+
const getCharacterClassToken = (pattern, index) => {
|
|
2215
|
+
return getCharacterClass(pattern, index) || {
|
|
2216
|
+
endIndex: index,
|
|
2217
|
+
source: '\\['
|
|
2218
|
+
};
|
|
2219
|
+
};
|
|
2220
|
+
const getEscapeToken = (pattern, index) => {
|
|
2221
|
+
const nextCharacter = pattern[index + 1];
|
|
2222
|
+
if (!nextCharacter) {
|
|
2223
|
+
return {
|
|
2224
|
+
endIndex: index,
|
|
2225
|
+
source: '\\\\'
|
|
2226
|
+
};
|
|
2227
|
+
}
|
|
2228
|
+
return {
|
|
2229
|
+
endIndex: index + 1,
|
|
2230
|
+
source: escapeRegexCharacter(nextCharacter)
|
|
2231
|
+
};
|
|
2232
|
+
};
|
|
2233
|
+
const getGlobToken = (pattern, index) => {
|
|
2234
|
+
const character = pattern[index];
|
|
2235
|
+
switch (character) {
|
|
2236
|
+
case '?':
|
|
2237
|
+
return {
|
|
2238
|
+
endIndex: index,
|
|
2239
|
+
source: '[^/]'
|
|
2240
|
+
};
|
|
2241
|
+
case '[':
|
|
2242
|
+
return getCharacterClassToken(pattern, index);
|
|
2243
|
+
case '*':
|
|
2244
|
+
return getAsteriskToken(pattern, index);
|
|
2245
|
+
case '\\':
|
|
2246
|
+
return getEscapeToken(pattern, index);
|
|
2247
|
+
default:
|
|
2248
|
+
return {
|
|
2249
|
+
endIndex: index,
|
|
2250
|
+
source: escapeRegexCharacter(character)
|
|
2251
|
+
};
|
|
2252
|
+
}
|
|
2253
|
+
};
|
|
2254
|
+
const globToRegexSource = pattern => {
|
|
2255
|
+
let source = '';
|
|
2256
|
+
let index = 0;
|
|
2257
|
+
while (index < pattern.length) {
|
|
2258
|
+
const token = getGlobToken(pattern, index);
|
|
2259
|
+
source += token.source;
|
|
2260
|
+
index = token.endIndex + 1;
|
|
2261
|
+
}
|
|
2262
|
+
return source;
|
|
2263
|
+
};
|
|
2264
|
+
const compileGlob = pattern => {
|
|
2265
|
+
const regex = new RegExp(`^${globToRegexSource(pattern)}$`);
|
|
2266
|
+
return path => regex.test(path);
|
|
2267
|
+
};
|
|
2268
|
+
const compileIgnoreRule = line => {
|
|
2269
|
+
let pattern = line.trimEnd();
|
|
2270
|
+
if (!pattern || pattern.startsWith('#')) {
|
|
2271
|
+
return undefined;
|
|
2272
|
+
}
|
|
2273
|
+
let ignored = true;
|
|
2274
|
+
if (pattern.startsWith('!')) {
|
|
2275
|
+
ignored = false;
|
|
2276
|
+
pattern = pattern.slice(1);
|
|
2277
|
+
} else if (pattern.startsWith('\\!') || pattern.startsWith('\\#')) {
|
|
2278
|
+
pattern = pattern.slice(1);
|
|
2279
|
+
}
|
|
2280
|
+
const directoryOnly = pattern.endsWith('/');
|
|
2281
|
+
if (directoryOnly) {
|
|
2282
|
+
pattern = pattern.slice(0, -1);
|
|
2283
|
+
}
|
|
2284
|
+
const anchored = pattern.startsWith('/');
|
|
2285
|
+
if (anchored) {
|
|
2286
|
+
pattern = pattern.slice(1);
|
|
2287
|
+
}
|
|
2288
|
+
if (!pattern) {
|
|
2289
|
+
return undefined;
|
|
2290
|
+
}
|
|
2291
|
+
const prefix = anchored || pattern.includes('/') ? '^' : '(?:^|/)';
|
|
2292
|
+
return {
|
|
2293
|
+
directoryOnly,
|
|
2294
|
+
ignored,
|
|
2295
|
+
regex: new RegExp(`${prefix}${globToRegexSource(pattern)}$`)
|
|
2296
|
+
};
|
|
2297
|
+
};
|
|
2298
|
+
const parseGitIgnore = contents => {
|
|
2299
|
+
const rules = [];
|
|
2300
|
+
for (const line of contents.split(/\r?\n/)) {
|
|
2301
|
+
const rule = compileIgnoreRule(line);
|
|
2302
|
+
if (rule) {
|
|
2303
|
+
rules.push(rule);
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
return rules;
|
|
2307
|
+
};
|
|
2308
|
+
const getPathForLayer = (relativePath, layerBasePath) => {
|
|
2309
|
+
if (!layerBasePath) {
|
|
2310
|
+
return relativePath;
|
|
2311
|
+
}
|
|
2312
|
+
return relativePath.slice(layerBasePath.length + 1);
|
|
2313
|
+
};
|
|
2314
|
+
const isIgnored = (relativePath, isDirectory, ignoreLayers) => {
|
|
2315
|
+
let ignored = false;
|
|
2316
|
+
for (const layer of ignoreLayers) {
|
|
2317
|
+
if (layer.basePath && relativePath !== layer.basePath && !relativePath.startsWith(`${layer.basePath}/`)) {
|
|
2318
|
+
continue;
|
|
2319
|
+
}
|
|
2320
|
+
const pathForLayer = getPathForLayer(relativePath, layer.basePath);
|
|
2321
|
+
for (const rule of layer.rules) {
|
|
2322
|
+
const {
|
|
2323
|
+
directoryOnly,
|
|
2324
|
+
ignored: ruleIgnored,
|
|
2325
|
+
regex
|
|
2326
|
+
} = rule;
|
|
2327
|
+
if ((!directoryOnly || isDirectory) && regex.test(pathForLayer)) {
|
|
2328
|
+
ignored = ruleIgnored;
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
return ignored;
|
|
2333
|
+
};
|
|
2334
|
+
const readIgnoreLayer = async (fileSystem, uri, relativePath, entries) => {
|
|
2335
|
+
const gitIgnore = entries.find(entry => entry.name === '.gitignore' && entry.type === File$3);
|
|
2336
|
+
if (!gitIgnore) {
|
|
2337
|
+
return undefined;
|
|
2338
|
+
}
|
|
2339
|
+
try {
|
|
2340
|
+
const contents = await fileSystem.readFile(joinUri(uri, gitIgnore.name));
|
|
2341
|
+
return {
|
|
2342
|
+
basePath: relativePath,
|
|
2343
|
+
rules: parseGitIgnore(contents)
|
|
2344
|
+
};
|
|
2345
|
+
} catch {
|
|
2346
|
+
return undefined;
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
const scanDirectory = async (fileSystem, task, isMatch) => {
|
|
2350
|
+
const entries = await fileSystem.readDirWithFileTypes(task.uri);
|
|
2351
|
+
const ignoreLayer = await readIgnoreLayer(fileSystem, task.uri, task.relativePath, entries);
|
|
2352
|
+
const ignoreLayers = ignoreLayer ? [...task.ignoreLayers, ignoreLayer] : task.ignoreLayers;
|
|
2353
|
+
const directories = [];
|
|
2354
|
+
const matches = [];
|
|
2355
|
+
const sortedEntries = entries.toSorted((left, right) => left.name.localeCompare(right.name));
|
|
2356
|
+
for (const entry of sortedEntries) {
|
|
2357
|
+
const relativePath = joinPath(task.relativePath, entry.name);
|
|
2358
|
+
if (entry.type === Directory$1) {
|
|
2359
|
+
if (entry.name !== '.git' && !isIgnored(relativePath, true, ignoreLayers)) {
|
|
2360
|
+
directories.push({
|
|
2361
|
+
ignoreLayers,
|
|
2362
|
+
relativePath,
|
|
2363
|
+
uri: joinUri(task.uri, entry.name)
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
} else if (entry.type === File$3 && isMatch(relativePath) && !isIgnored(relativePath, false, ignoreLayers)) {
|
|
2367
|
+
matches.push(joinUri(task.uri, entry.name));
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
return {
|
|
2371
|
+
directories,
|
|
2372
|
+
matches
|
|
2373
|
+
};
|
|
2374
|
+
};
|
|
2375
|
+
const globWithFileSystemImplementation = async (fileSystem, root, pattern) => {
|
|
2376
|
+
const isMatch = compileGlob(pattern);
|
|
2377
|
+
const matches = [];
|
|
2378
|
+
let pending = [{
|
|
2379
|
+
ignoreLayers: [],
|
|
2380
|
+
relativePath: '',
|
|
2381
|
+
uri: root
|
|
2382
|
+
}];
|
|
2383
|
+
while (pending.length > 0) {
|
|
2384
|
+
const next = [];
|
|
2385
|
+
for (let index = 0; index < pending.length; index += batchSize) {
|
|
2386
|
+
const batch = pending.slice(index, index + batchSize);
|
|
2387
|
+
const results = await Promise.all(batch.map(task => scanDirectory(fileSystem, task, isMatch)));
|
|
2388
|
+
for (const result of results) {
|
|
2389
|
+
next.push(...result.directories);
|
|
2390
|
+
matches.push(...result.matches);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
pending = next;
|
|
2394
|
+
}
|
|
2395
|
+
return matches.toSorted((left, right) => left.localeCompare(right));
|
|
2396
|
+
};
|
|
2397
|
+
|
|
2398
|
+
/* eslint-enable unicorn/consistent-function-scoping */
|
|
2399
|
+
return globWithFileSystemImplementation;
|
|
2400
|
+
};
|
|
2401
|
+
const createLazyGlobImplementation = () => {
|
|
2402
|
+
let implementation;
|
|
2403
|
+
return async (fileSystem, root, pattern) => {
|
|
2404
|
+
implementation ||= createGlobImplementation();
|
|
2405
|
+
return implementation(fileSystem, root, pattern);
|
|
2406
|
+
};
|
|
2407
|
+
};
|
|
2408
|
+
const globWithFileSystem = createLazyGlobImplementation();
|
|
2409
|
+
const glob = async (root, pattern) => {
|
|
2410
|
+
return globWithFileSystem(FileSystemDisk, root, pattern);
|
|
2411
|
+
};
|
|
2412
|
+
|
|
2116
2413
|
const handleMessagePort = async (port, rpcId) => {
|
|
2117
2414
|
const rpc = await create$6({
|
|
2118
2415
|
commandMap: {},
|
|
@@ -2310,9 +2607,11 @@ const commandMap = {
|
|
|
2310
2607
|
'FileSystem.executeWatchCallback': executeWatchCallback,
|
|
2311
2608
|
'FileSystem.exists': exists,
|
|
2312
2609
|
'FileSystem.getFileHash': getFileHash,
|
|
2610
|
+
'FileSystem.getFileHashes': getFileHashes,
|
|
2313
2611
|
'FileSystem.getFolderSize': getFolderSize,
|
|
2314
2612
|
'FileSystem.getPathSeparator': getPathSeparator,
|
|
2315
2613
|
'FileSystem.getRealPath': getRealPath,
|
|
2614
|
+
'FileSystem.glob': glob,
|
|
2316
2615
|
'FileSystem.handleMessagePort': handleMessagePort,
|
|
2317
2616
|
'FileSystem.isReadonly': isReadonly,
|
|
2318
2617
|
'FileSystem.mkdir': mkdir,
|
|
@@ -2353,7 +2652,7 @@ const initializeExtensionHostWorker = async () => {
|
|
|
2353
2652
|
try {
|
|
2354
2653
|
const rpc = await create$4({
|
|
2355
2654
|
commandMap: {},
|
|
2356
|
-
send:
|
|
2655
|
+
send: port => sendMessagePortToExtensionManagementWorker(port, 0)
|
|
2357
2656
|
});
|
|
2358
2657
|
set$4(rpc);
|
|
2359
2658
|
} catch (error) {
|