@lvce-editor/file-system-worker 1.6.0 → 1.8.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 +64 -34
- package/package.json +1 -1
|
@@ -545,11 +545,11 @@ const remove$2 = id => {
|
|
|
545
545
|
delete callbacks[id];
|
|
546
546
|
};
|
|
547
547
|
let id = 0;
|
|
548
|
-
const create$3 = () => {
|
|
548
|
+
const create$3$1 = () => {
|
|
549
549
|
return ++id;
|
|
550
550
|
};
|
|
551
551
|
const registerPromise = () => {
|
|
552
|
-
const id = create$3();
|
|
552
|
+
const id = create$3$1();
|
|
553
553
|
const {
|
|
554
554
|
resolve,
|
|
555
555
|
promise
|
|
@@ -1015,11 +1015,41 @@ const create$2 = async ({
|
|
|
1015
1015
|
const rpc = createRpc(ipc);
|
|
1016
1016
|
return rpc;
|
|
1017
1017
|
};
|
|
1018
|
-
const
|
|
1019
|
-
|
|
1020
|
-
|
|
1018
|
+
const Https$1 = 'https:';
|
|
1019
|
+
const Ws = 'ws:';
|
|
1020
|
+
const Wss = 'wss:';
|
|
1021
|
+
const getWebSocketProtocol = locationProtocol => {
|
|
1022
|
+
return locationProtocol === Https$1 ? Wss : Ws;
|
|
1023
|
+
};
|
|
1024
|
+
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
1025
|
+
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
1026
|
+
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
1027
|
+
};
|
|
1028
|
+
const getHost = () => {
|
|
1029
|
+
return location.host;
|
|
1030
|
+
};
|
|
1031
|
+
const getProtocol = () => {
|
|
1032
|
+
return location.protocol;
|
|
1021
1033
|
};
|
|
1022
1034
|
const create$1 = async ({
|
|
1035
|
+
commandMap,
|
|
1036
|
+
type
|
|
1037
|
+
}) => {
|
|
1038
|
+
const host = getHost();
|
|
1039
|
+
const protocol = getProtocol();
|
|
1040
|
+
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1041
|
+
const webSocket = new WebSocket(wsUrl);
|
|
1042
|
+
const rpc = await create$2({
|
|
1043
|
+
webSocket,
|
|
1044
|
+
commandMap
|
|
1045
|
+
});
|
|
1046
|
+
return rpc;
|
|
1047
|
+
};
|
|
1048
|
+
const WebSocketRpcParent2 = {
|
|
1049
|
+
__proto__: null,
|
|
1050
|
+
create: create$1
|
|
1051
|
+
};
|
|
1052
|
+
const create$3 = async ({
|
|
1023
1053
|
commandMap
|
|
1024
1054
|
}) => {
|
|
1025
1055
|
// TODO create a commandMap per rpc instance
|
|
@@ -1031,7 +1061,16 @@ const create$1 = async ({
|
|
|
1031
1061
|
};
|
|
1032
1062
|
const WebWorkerRpcClient = {
|
|
1033
1063
|
__proto__: null,
|
|
1034
|
-
create: create$
|
|
1064
|
+
create: create$3
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
const readFile$2 = async uri => {
|
|
1068
|
+
const response = await fetch(uri);
|
|
1069
|
+
if (!response.ok) {
|
|
1070
|
+
throw new Error(response.statusText);
|
|
1071
|
+
}
|
|
1072
|
+
const result = await response.text();
|
|
1073
|
+
return result;
|
|
1035
1074
|
};
|
|
1036
1075
|
|
|
1037
1076
|
const rpcs = Object.create(null);
|
|
@@ -1117,9 +1156,14 @@ const copy$1$1 = async (oldUri, newUri) => {
|
|
|
1117
1156
|
// @ts-ignore
|
|
1118
1157
|
return invoke$8('FileSystem.copy', oldUri, newUri);
|
|
1119
1158
|
};
|
|
1159
|
+
const getFolderSize$1$1 = async uri => {
|
|
1160
|
+
// @ts-ignore
|
|
1161
|
+
return invoke$8('FileSystem.getFolderSize', uri);
|
|
1162
|
+
};
|
|
1120
1163
|
const FileSystemProcess = {
|
|
1121
1164
|
__proto__: null,
|
|
1122
1165
|
copy: copy$1$1,
|
|
1166
|
+
getFolderSize: getFolderSize$1$1,
|
|
1123
1167
|
getPathSeparator: getPathSeparator$1$1,
|
|
1124
1168
|
getRealPath: getRealPath$1$1,
|
|
1125
1169
|
mkdir: mkdir$1$1,
|
|
@@ -1145,6 +1189,7 @@ const {
|
|
|
1145
1189
|
rename: rename$1,
|
|
1146
1190
|
copy: copy$1,
|
|
1147
1191
|
mkdir: mkdir$1,
|
|
1192
|
+
getFolderSize: getFolderSize$1,
|
|
1148
1193
|
writeFile: writeFile$1,
|
|
1149
1194
|
stat: stat$1,
|
|
1150
1195
|
readJson: readJson$1,
|
|
@@ -1155,10 +1200,16 @@ const {
|
|
|
1155
1200
|
remove: remove$1
|
|
1156
1201
|
} = FileSystemProcess;
|
|
1157
1202
|
|
|
1203
|
+
const Http = 'http:';
|
|
1204
|
+
const Https = 'https:';
|
|
1205
|
+
|
|
1158
1206
|
const remove = async dirent => {
|
|
1159
1207
|
return remove$1(dirent);
|
|
1160
1208
|
};
|
|
1161
1209
|
const readFile = async uri => {
|
|
1210
|
+
if (uri.startsWith(Http) || uri.startsWith(Https)) {
|
|
1211
|
+
return readFile$2(uri);
|
|
1212
|
+
}
|
|
1162
1213
|
return readFile$1(uri);
|
|
1163
1214
|
};
|
|
1164
1215
|
const readDirWithFileTypes = async uri => {
|
|
@@ -1191,6 +1242,9 @@ const rename = async (oldUri, newUri) => {
|
|
|
1191
1242
|
const copy = async (oldUri, newUri) => {
|
|
1192
1243
|
return copy$1(oldUri, newUri);
|
|
1193
1244
|
};
|
|
1245
|
+
const getFolderSize = async uri => {
|
|
1246
|
+
return getFolderSize$1(uri);
|
|
1247
|
+
};
|
|
1194
1248
|
|
|
1195
1249
|
const getPortTuple = () => {
|
|
1196
1250
|
const {
|
|
@@ -1205,8 +1259,7 @@ const getPortTuple = () => {
|
|
|
1205
1259
|
|
|
1206
1260
|
const {
|
|
1207
1261
|
invokeAndTransfer,
|
|
1208
|
-
set
|
|
1209
|
-
} = RendererWorker;
|
|
1262
|
+
set} = RendererWorker;
|
|
1210
1263
|
|
|
1211
1264
|
const sendMessagePortToFileSystemProcess = async port => {
|
|
1212
1265
|
const command = 'HandleMessagePortForFileSystemProcess.handleMessagePortForFileSystemProcess';
|
|
@@ -1230,34 +1283,10 @@ const createFileSystemProcessRpcElectron = async () => {
|
|
|
1230
1283
|
}
|
|
1231
1284
|
};
|
|
1232
1285
|
|
|
1233
|
-
const Https = 'https:';
|
|
1234
|
-
const Ws = 'ws:';
|
|
1235
|
-
const Wss = 'wss:';
|
|
1236
|
-
|
|
1237
|
-
const getWebSocketProtocol = locationProtocol => {
|
|
1238
|
-
return locationProtocol === Https ? Wss : Ws;
|
|
1239
|
-
};
|
|
1240
|
-
|
|
1241
|
-
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
1242
|
-
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
1243
|
-
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
1244
|
-
};
|
|
1245
|
-
|
|
1246
|
-
const getHost = () => {
|
|
1247
|
-
return location.host;
|
|
1248
|
-
};
|
|
1249
|
-
const getProtocol = () => {
|
|
1250
|
-
return location.protocol;
|
|
1251
|
-
};
|
|
1252
|
-
|
|
1253
1286
|
const createFileSystemProcessRpcNode = async () => {
|
|
1254
1287
|
try {
|
|
1255
|
-
const
|
|
1256
|
-
|
|
1257
|
-
const wsUrl = getWebSocketUrl('file-system-process', host, protocol);
|
|
1258
|
-
const webSocket = new WebSocket(wsUrl);
|
|
1259
|
-
const rpc = await WebSocketRpcParent.create({
|
|
1260
|
-
webSocket,
|
|
1288
|
+
const rpc = await WebSocketRpcParent2.create({
|
|
1289
|
+
type: 'file-system-process',
|
|
1261
1290
|
commandMap: {}
|
|
1262
1291
|
});
|
|
1263
1292
|
return rpc;
|
|
@@ -1303,6 +1332,7 @@ const commandMap = {
|
|
|
1303
1332
|
'FileSystem.rename': rename,
|
|
1304
1333
|
'FileSystem.stat': stat,
|
|
1305
1334
|
'FileSystem.writeFile': writeFile,
|
|
1335
|
+
'FileSystem.getFolderSize': getFolderSize,
|
|
1306
1336
|
'Initialize.initialize': initialize
|
|
1307
1337
|
};
|
|
1308
1338
|
|