@lvce-editor/file-system-worker 5.21.0 → 5.22.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 +142 -36
- package/package.json +1 -1
|
@@ -534,7 +534,7 @@ const waitForWebSocketToBeOpen = webSocket => {
|
|
|
534
534
|
open: Open
|
|
535
535
|
});
|
|
536
536
|
};
|
|
537
|
-
const create$
|
|
537
|
+
const create$c = async ({
|
|
538
538
|
webSocket
|
|
539
539
|
}) => {
|
|
540
540
|
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
@@ -571,7 +571,7 @@ const wrap = webSocket => {
|
|
|
571
571
|
};
|
|
572
572
|
const IpcParentWithWebSocket$1 = {
|
|
573
573
|
__proto__: null,
|
|
574
|
-
create: create$
|
|
574
|
+
create: create$c,
|
|
575
575
|
wrap
|
|
576
576
|
};
|
|
577
577
|
|
|
@@ -882,7 +882,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
882
882
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
883
883
|
return create$1$1(id, errorProperty);
|
|
884
884
|
};
|
|
885
|
-
const create$
|
|
885
|
+
const create$b = (message, result) => {
|
|
886
886
|
return {
|
|
887
887
|
id: message.id,
|
|
888
888
|
jsonrpc: Two$1,
|
|
@@ -891,7 +891,7 @@ const create$a = (message, result) => {
|
|
|
891
891
|
};
|
|
892
892
|
const getSuccessResponse = (message, result) => {
|
|
893
893
|
const resultProperty = result ?? null;
|
|
894
|
-
return create$
|
|
894
|
+
return create$b(message, resultProperty);
|
|
895
895
|
};
|
|
896
896
|
const getErrorResponseSimple = (id, error) => {
|
|
897
897
|
return {
|
|
@@ -990,7 +990,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
990
990
|
|
|
991
991
|
const Two = '2.0';
|
|
992
992
|
|
|
993
|
-
const create$
|
|
993
|
+
const create$a = (method, params) => {
|
|
994
994
|
return {
|
|
995
995
|
jsonrpc: Two,
|
|
996
996
|
method,
|
|
@@ -998,7 +998,7 @@ const create$9 = (method, params) => {
|
|
|
998
998
|
};
|
|
999
999
|
};
|
|
1000
1000
|
|
|
1001
|
-
const create$
|
|
1001
|
+
const create$9 = (id, method, params) => {
|
|
1002
1002
|
const message = {
|
|
1003
1003
|
id,
|
|
1004
1004
|
jsonrpc: Two,
|
|
@@ -1009,12 +1009,12 @@ const create$8 = (id, method, params) => {
|
|
|
1009
1009
|
};
|
|
1010
1010
|
|
|
1011
1011
|
let id = 0;
|
|
1012
|
-
const create$
|
|
1012
|
+
const create$8 = () => {
|
|
1013
1013
|
return ++id;
|
|
1014
1014
|
};
|
|
1015
1015
|
|
|
1016
1016
|
const registerPromise = map => {
|
|
1017
|
-
const id = create$
|
|
1017
|
+
const id = create$8();
|
|
1018
1018
|
const {
|
|
1019
1019
|
promise,
|
|
1020
1020
|
resolve
|
|
@@ -1031,7 +1031,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
1031
1031
|
id,
|
|
1032
1032
|
promise
|
|
1033
1033
|
} = registerPromise(callbacks);
|
|
1034
|
-
const message = create$
|
|
1034
|
+
const message = create$9(id, method, params);
|
|
1035
1035
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1036
1036
|
ipc.sendAndTransfer(message);
|
|
1037
1037
|
} else {
|
|
@@ -1067,7 +1067,7 @@ const createRpc = ipc => {
|
|
|
1067
1067
|
* @deprecated
|
|
1068
1068
|
*/
|
|
1069
1069
|
send(method, ...params) {
|
|
1070
|
-
const message = create$
|
|
1070
|
+
const message = create$a(method, params);
|
|
1071
1071
|
ipc.send(message);
|
|
1072
1072
|
}
|
|
1073
1073
|
};
|
|
@@ -1135,7 +1135,7 @@ const createSharedLazyRpc = factory => {
|
|
|
1135
1135
|
};
|
|
1136
1136
|
};
|
|
1137
1137
|
|
|
1138
|
-
const create$
|
|
1138
|
+
const create$7 = async ({
|
|
1139
1139
|
commandMap,
|
|
1140
1140
|
isMessagePortOpen = true,
|
|
1141
1141
|
messagePort
|
|
@@ -1153,7 +1153,7 @@ const create$6 = async ({
|
|
|
1153
1153
|
return rpc;
|
|
1154
1154
|
};
|
|
1155
1155
|
|
|
1156
|
-
const create$
|
|
1156
|
+
const create$6 = async ({
|
|
1157
1157
|
commandMap,
|
|
1158
1158
|
isMessagePortOpen,
|
|
1159
1159
|
send
|
|
@@ -1163,20 +1163,20 @@ const create$5 = async ({
|
|
|
1163
1163
|
port2
|
|
1164
1164
|
} = new MessageChannel();
|
|
1165
1165
|
await send(port1);
|
|
1166
|
-
return create$
|
|
1166
|
+
return create$7({
|
|
1167
1167
|
commandMap,
|
|
1168
1168
|
isMessagePortOpen,
|
|
1169
1169
|
messagePort: port2
|
|
1170
1170
|
});
|
|
1171
1171
|
};
|
|
1172
1172
|
|
|
1173
|
-
const create$
|
|
1173
|
+
const create$5 = async ({
|
|
1174
1174
|
commandMap,
|
|
1175
1175
|
isMessagePortOpen,
|
|
1176
1176
|
send
|
|
1177
1177
|
}) => {
|
|
1178
1178
|
return createSharedLazyRpc(() => {
|
|
1179
|
-
return create$
|
|
1179
|
+
return create$6({
|
|
1180
1180
|
commandMap,
|
|
1181
1181
|
isMessagePortOpen,
|
|
1182
1182
|
send
|
|
@@ -1204,7 +1204,7 @@ const getProtocol = () => {
|
|
|
1204
1204
|
return location.protocol;
|
|
1205
1205
|
};
|
|
1206
1206
|
|
|
1207
|
-
const create$
|
|
1207
|
+
const create$4 = async ({
|
|
1208
1208
|
commandMap,
|
|
1209
1209
|
webSocket
|
|
1210
1210
|
}) => {
|
|
@@ -1236,7 +1236,7 @@ const connect$1 = async ({
|
|
|
1236
1236
|
}) => {
|
|
1237
1237
|
const webSocket = new WebSocket(wsUrl);
|
|
1238
1238
|
try {
|
|
1239
|
-
const rpc = await create$
|
|
1239
|
+
const rpc = await create$4({
|
|
1240
1240
|
commandMap,
|
|
1241
1241
|
webSocket
|
|
1242
1242
|
});
|
|
@@ -1249,7 +1249,7 @@ const connect$1 = async ({
|
|
|
1249
1249
|
throw error;
|
|
1250
1250
|
}
|
|
1251
1251
|
};
|
|
1252
|
-
const create$
|
|
1252
|
+
const create$3 = async ({
|
|
1253
1253
|
commandMap,
|
|
1254
1254
|
onClose,
|
|
1255
1255
|
type
|
|
@@ -1278,7 +1278,7 @@ const create$2 = async ({
|
|
|
1278
1278
|
return connection.rpc;
|
|
1279
1279
|
};
|
|
1280
1280
|
|
|
1281
|
-
const create$
|
|
1281
|
+
const create$2 = async ({
|
|
1282
1282
|
commandMap
|
|
1283
1283
|
}) => {
|
|
1284
1284
|
// TODO create a commandMap per rpc instance
|
|
@@ -1321,7 +1321,7 @@ const remove$6 = id => {
|
|
|
1321
1321
|
};
|
|
1322
1322
|
|
|
1323
1323
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1324
|
-
const create = rpcId => {
|
|
1324
|
+
const create$1 = rpcId => {
|
|
1325
1325
|
return {
|
|
1326
1326
|
async dispose() {
|
|
1327
1327
|
const rpc = get(rpcId);
|
|
@@ -1370,12 +1370,12 @@ const RendererWorker = 1;
|
|
|
1370
1370
|
|
|
1371
1371
|
const {
|
|
1372
1372
|
set: set$4
|
|
1373
|
-
} = create(ExtensionHostWorker);
|
|
1373
|
+
} = create$1(ExtensionHostWorker);
|
|
1374
1374
|
|
|
1375
1375
|
const {
|
|
1376
1376
|
invoke: invoke$3,
|
|
1377
1377
|
set: set$3
|
|
1378
|
-
} = create(FileSystemProcess$1);
|
|
1378
|
+
} = create$1(FileSystemProcess$1);
|
|
1379
1379
|
const remove$5 = async uri => {
|
|
1380
1380
|
return invoke$3('FileSystem.remove', uri);
|
|
1381
1381
|
};
|
|
@@ -1520,13 +1520,13 @@ const createLazyRpc = rpcId => {
|
|
|
1520
1520
|
|
|
1521
1521
|
const {
|
|
1522
1522
|
set: set$2
|
|
1523
|
-
} = create(RendererProcess);
|
|
1523
|
+
} = create$1(RendererProcess);
|
|
1524
1524
|
|
|
1525
1525
|
const {
|
|
1526
1526
|
invoke: invoke$2,
|
|
1527
1527
|
invokeAndTransfer,
|
|
1528
1528
|
set: set$1
|
|
1529
|
-
} = create(RendererWorker);
|
|
1529
|
+
} = create$1(RendererWorker);
|
|
1530
1530
|
const sendMessagePortToRendererProcess = async (port, rpcId = DebugWorker) => {
|
|
1531
1531
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1532
1532
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, rpcId);
|
|
@@ -1833,7 +1833,7 @@ const connect = async port => {
|
|
|
1833
1833
|
const {
|
|
1834
1834
|
commandMap
|
|
1835
1835
|
} = await Promise.resolve().then(function () { return CommandMap; });
|
|
1836
|
-
await create$
|
|
1836
|
+
await create$7({
|
|
1837
1837
|
commandMap,
|
|
1838
1838
|
messagePort: port
|
|
1839
1839
|
});
|
|
@@ -2823,6 +2823,100 @@ const glob = async (root, pattern) => {
|
|
|
2823
2823
|
return globWithFileSystem(FileSystemDisk, root, pattern);
|
|
2824
2824
|
};
|
|
2825
2825
|
|
|
2826
|
+
const escapeRegExp = character => /[|\\{}()[\]^$+?.]/.test(character) ? `\\${character}` : character;
|
|
2827
|
+
const globToken = (pattern, index) => {
|
|
2828
|
+
const character = pattern[index];
|
|
2829
|
+
switch (character) {
|
|
2830
|
+
case '?':
|
|
2831
|
+
return ['[^/]', 1];
|
|
2832
|
+
case '[':
|
|
2833
|
+
{
|
|
2834
|
+
const end = pattern.indexOf(']', index + 1);
|
|
2835
|
+
if (end === -1) return ['\\[', 1];
|
|
2836
|
+
const range = pattern.slice(index + 1, end);
|
|
2837
|
+
const normalizedRange = range.startsWith('!') ? `^${range.slice(1)}` : range;
|
|
2838
|
+
return [`[${normalizedRange}]`, end - index + 1];
|
|
2839
|
+
}
|
|
2840
|
+
case '*':
|
|
2841
|
+
if (pattern[index + 1] !== '*') return ['[^/]*', 1];
|
|
2842
|
+
return pattern[index + 2] === '/' ? ['(?:.*/)?', 3] : ['.*', 2];
|
|
2843
|
+
default:
|
|
2844
|
+
return [escapeRegExp(character), 1];
|
|
2845
|
+
}
|
|
2846
|
+
};
|
|
2847
|
+
const globToRegExp = pattern => {
|
|
2848
|
+
let source = '^';
|
|
2849
|
+
let index = 0;
|
|
2850
|
+
while (index < pattern.length) {
|
|
2851
|
+
const [token, length] = globToken(pattern, index);
|
|
2852
|
+
source += token;
|
|
2853
|
+
index += length;
|
|
2854
|
+
}
|
|
2855
|
+
return new RegExp(`${source}$`);
|
|
2856
|
+
};
|
|
2857
|
+
const parseRule = line => {
|
|
2858
|
+
let pattern = line.trimEnd();
|
|
2859
|
+
if (!pattern || pattern.startsWith('#')) {
|
|
2860
|
+
return undefined;
|
|
2861
|
+
}
|
|
2862
|
+
let negated = false;
|
|
2863
|
+
if (pattern.startsWith('!')) {
|
|
2864
|
+
negated = true;
|
|
2865
|
+
pattern = pattern.slice(1);
|
|
2866
|
+
} else if (pattern.startsWith('\\!') || pattern.startsWith('\\#')) {
|
|
2867
|
+
pattern = pattern.slice(1);
|
|
2868
|
+
}
|
|
2869
|
+
const rooted = pattern.startsWith('/');
|
|
2870
|
+
pattern = pattern.replace(/^\//, '');
|
|
2871
|
+
const directoryOnly = pattern.endsWith('/');
|
|
2872
|
+
if (directoryOnly) {
|
|
2873
|
+
pattern = pattern.slice(0, -1);
|
|
2874
|
+
}
|
|
2875
|
+
if (!pattern) {
|
|
2876
|
+
return undefined;
|
|
2877
|
+
}
|
|
2878
|
+
const hasSlash = rooted || pattern.includes('/');
|
|
2879
|
+
return {
|
|
2880
|
+
directoryOnly,
|
|
2881
|
+
negated,
|
|
2882
|
+
pattern: globToRegExp(pattern),
|
|
2883
|
+
segmentOnly: !hasSlash
|
|
2884
|
+
};
|
|
2885
|
+
};
|
|
2886
|
+
const ruleMatches = (rule, path, isDirectory) => {
|
|
2887
|
+
if (rule.directoryOnly && !isDirectory) {
|
|
2888
|
+
return false;
|
|
2889
|
+
}
|
|
2890
|
+
if (rule.segmentOnly) {
|
|
2891
|
+
const name = path.slice(path.lastIndexOf('/') + 1);
|
|
2892
|
+
return rule.pattern.test(name);
|
|
2893
|
+
}
|
|
2894
|
+
return rule.pattern.test(path);
|
|
2895
|
+
};
|
|
2896
|
+
const create = (contents = '') => {
|
|
2897
|
+
const rules = contents.split(/\r?\n/).map(parseRule).filter(rule => rule !== undefined);
|
|
2898
|
+
return {
|
|
2899
|
+
hasNegation: rules.some(rule => rule.negated),
|
|
2900
|
+
isIgnored(path, isDirectory = false) {
|
|
2901
|
+
const parts = path.split('/').filter(Boolean);
|
|
2902
|
+
let ignored = false;
|
|
2903
|
+
for (let index = 0; index < parts.length; index++) {
|
|
2904
|
+
if (ignored) {
|
|
2905
|
+
return true;
|
|
2906
|
+
}
|
|
2907
|
+
const relativePath = parts.slice(0, index + 1).join('/');
|
|
2908
|
+
const currentIsDirectory = index < parts.length - 1 || isDirectory;
|
|
2909
|
+
for (const rule of rules) {
|
|
2910
|
+
if (ruleMatches(rule, relativePath, currentIsDirectory)) {
|
|
2911
|
+
ignored = !rule.negated;
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
return ignored;
|
|
2916
|
+
}
|
|
2917
|
+
};
|
|
2918
|
+
};
|
|
2919
|
+
|
|
2826
2920
|
const FILE_RESULT = 1;
|
|
2827
2921
|
const MATCH_RESULT = 2;
|
|
2828
2922
|
const USE_REGULAR_EXPRESSION = 1 << 1;
|
|
@@ -2889,23 +2983,35 @@ const searchHtmlDirectory = async (uri, relativePath, query, flags) => {
|
|
|
2889
2983
|
const textSearch = async (root, query, options = {}) => {
|
|
2890
2984
|
return searchHtmlDirectory(root, '', query, options.flags || 0);
|
|
2891
2985
|
};
|
|
2892
|
-
const searchDirectory = async (uri, prefix
|
|
2986
|
+
const searchDirectory = async (uri, prefix, matcher) => {
|
|
2893
2987
|
const entries = await readDirWithFileTypes$1(uri);
|
|
2894
2988
|
const results = [];
|
|
2895
2989
|
for (const entry of entries) {
|
|
2896
2990
|
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
2897
2991
|
if (entry.type === Directory$1) {
|
|
2898
|
-
|
|
2899
|
-
|
|
2992
|
+
if (matcher.hasNegation || !matcher.isIgnored(relativePath, true)) {
|
|
2993
|
+
results.push(...(await searchDirectory(`${uri}/${entry.name}`, relativePath, matcher)));
|
|
2994
|
+
}
|
|
2995
|
+
} else if (!matcher.isIgnored(relativePath)) {
|
|
2900
2996
|
results.push(relativePath);
|
|
2901
2997
|
}
|
|
2902
2998
|
}
|
|
2903
2999
|
return results;
|
|
2904
3000
|
};
|
|
2905
|
-
const fileSearch = uri =>
|
|
3001
|
+
const fileSearch = async uri => {
|
|
3002
|
+
let contents = '';
|
|
3003
|
+
try {
|
|
3004
|
+
contents = await readFile$1(`${uri}/.gitignore`);
|
|
3005
|
+
} catch (error) {
|
|
3006
|
+
if (!(error instanceof FileNotFoundError)) {
|
|
3007
|
+
throw error;
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
return searchDirectory(uri, '', create(contents));
|
|
3011
|
+
};
|
|
2906
3012
|
|
|
2907
3013
|
const handleMessagePort = async (port, rpcId) => {
|
|
2908
|
-
const rpc = await create$
|
|
3014
|
+
const rpc = await create$7({
|
|
2909
3015
|
commandMap: {},
|
|
2910
3016
|
messagePort: port
|
|
2911
3017
|
});
|
|
@@ -2920,7 +3026,7 @@ const sendMessagePortToFileSystemProcess = async port => {
|
|
|
2920
3026
|
|
|
2921
3027
|
const createFileSystemProcessRpcElectron = async () => {
|
|
2922
3028
|
try {
|
|
2923
|
-
const rpc = await create$
|
|
3029
|
+
const rpc = await create$6({
|
|
2924
3030
|
commandMap: {},
|
|
2925
3031
|
send: sendMessagePortToFileSystemProcess
|
|
2926
3032
|
});
|
|
@@ -2939,7 +3045,7 @@ const createFileSystemProcessRpcNode = async () => {
|
|
|
2939
3045
|
protocols,
|
|
2940
3046
|
url
|
|
2941
3047
|
} = await invoke$2('WebSocketCapability.create', 'file-system-process');
|
|
2942
|
-
return await create$
|
|
3048
|
+
return await create$4({
|
|
2943
3049
|
commandMap: commandMapRef,
|
|
2944
3050
|
webSocket: new WebSocket(url, protocols)
|
|
2945
3051
|
});
|
|
@@ -2948,7 +3054,7 @@ const createFileSystemProcessRpcNode = async () => {
|
|
|
2948
3054
|
throw error;
|
|
2949
3055
|
}
|
|
2950
3056
|
}
|
|
2951
|
-
const rpc = await create$
|
|
3057
|
+
const rpc = await create$3({
|
|
2952
3058
|
commandMap: commandMapRef,
|
|
2953
3059
|
type: 'file-system-process'
|
|
2954
3060
|
});
|
|
@@ -3121,7 +3227,7 @@ const fileSystemModules = {
|
|
|
3121
3227
|
|
|
3122
3228
|
const initializeExtensionHostWorker = async () => {
|
|
3123
3229
|
try {
|
|
3124
|
-
const rpc = await create$
|
|
3230
|
+
const rpc = await create$5({
|
|
3125
3231
|
commandMap: {},
|
|
3126
3232
|
send: port => sendMessagePortToExtensionManagementWorker(port, 0)
|
|
3127
3233
|
});
|
|
@@ -3133,7 +3239,7 @@ const initializeExtensionHostWorker = async () => {
|
|
|
3133
3239
|
|
|
3134
3240
|
const initializeRendererProcess = async () => {
|
|
3135
3241
|
try {
|
|
3136
|
-
const rpc = await create$
|
|
3242
|
+
const rpc = await create$5({
|
|
3137
3243
|
commandMap: {},
|
|
3138
3244
|
send: sendMessagePortToRendererProcess
|
|
3139
3245
|
});
|
|
@@ -3144,7 +3250,7 @@ const initializeRendererProcess = async () => {
|
|
|
3144
3250
|
};
|
|
3145
3251
|
|
|
3146
3252
|
const initializeRendererWorker = async () => {
|
|
3147
|
-
const rpc = await create$
|
|
3253
|
+
const rpc = await create$2({
|
|
3148
3254
|
commandMap: commandMap
|
|
3149
3255
|
});
|
|
3150
3256
|
set$1(rpc);
|