@lvce-editor/file-system-worker 1.8.0 → 1.10.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 +34 -3
- package/package.json +1 -1
|
@@ -988,6 +988,10 @@ const create$5 = async ({
|
|
|
988
988
|
messagePort.start();
|
|
989
989
|
return rpc;
|
|
990
990
|
};
|
|
991
|
+
const PlainMessagePortRpc = {
|
|
992
|
+
__proto__: null,
|
|
993
|
+
create: create$5
|
|
994
|
+
};
|
|
991
995
|
const create$4 = async ({
|
|
992
996
|
commandMap,
|
|
993
997
|
messagePort
|
|
@@ -1072,6 +1076,13 @@ const readFile$2 = async uri => {
|
|
|
1072
1076
|
const result = await response.text();
|
|
1073
1077
|
return result;
|
|
1074
1078
|
};
|
|
1079
|
+
const exists$2 = async uri => {
|
|
1080
|
+
const response = await fetch(uri);
|
|
1081
|
+
if (response.ok) {
|
|
1082
|
+
return true;
|
|
1083
|
+
}
|
|
1084
|
+
return false;
|
|
1085
|
+
};
|
|
1075
1086
|
|
|
1076
1087
|
const rpcs = Object.create(null);
|
|
1077
1088
|
const set$g = (id, rpc) => {
|
|
@@ -1184,6 +1195,7 @@ const RendererWorker = {
|
|
|
1184
1195
|
invokeAndTransfer: invokeAndTransfer$3,
|
|
1185
1196
|
set: set$3};
|
|
1186
1197
|
|
|
1198
|
+
// @ts-ignore
|
|
1187
1199
|
const {
|
|
1188
1200
|
set: set$1,
|
|
1189
1201
|
rename: rename$1,
|
|
@@ -1197,7 +1209,8 @@ const {
|
|
|
1197
1209
|
getRealPath: getRealPath$1,
|
|
1198
1210
|
readDirWithFileTypes: readDirWithFileTypes$1,
|
|
1199
1211
|
readFile: readFile$1,
|
|
1200
|
-
remove: remove$1
|
|
1212
|
+
remove: remove$1,
|
|
1213
|
+
exists: exists$1
|
|
1201
1214
|
} = FileSystemProcess;
|
|
1202
1215
|
|
|
1203
1216
|
const Http = 'http:';
|
|
@@ -1206,8 +1219,11 @@ const Https = 'https:';
|
|
|
1206
1219
|
const remove = async dirent => {
|
|
1207
1220
|
return remove$1(dirent);
|
|
1208
1221
|
};
|
|
1222
|
+
const isHttp = uri => {
|
|
1223
|
+
return uri.startsWith(Http) || uri.startsWith(Https);
|
|
1224
|
+
};
|
|
1209
1225
|
const readFile = async uri => {
|
|
1210
|
-
if (
|
|
1226
|
+
if (isHttp(uri)) {
|
|
1211
1227
|
return readFile$2(uri);
|
|
1212
1228
|
}
|
|
1213
1229
|
return readFile$1(uri);
|
|
@@ -1227,6 +1243,12 @@ const getRealPath = async path => {
|
|
|
1227
1243
|
const stat = async dirent => {
|
|
1228
1244
|
return stat$1(dirent);
|
|
1229
1245
|
};
|
|
1246
|
+
const exists = async uri => {
|
|
1247
|
+
if (isHttp(uri)) {
|
|
1248
|
+
return exists$2(uri);
|
|
1249
|
+
}
|
|
1250
|
+
return exists$1(uri);
|
|
1251
|
+
};
|
|
1230
1252
|
const createFile = async uri => {
|
|
1231
1253
|
return writeFile$1(uri, '');
|
|
1232
1254
|
};
|
|
@@ -1246,6 +1268,13 @@ const getFolderSize = async uri => {
|
|
|
1246
1268
|
return getFolderSize$1(uri);
|
|
1247
1269
|
};
|
|
1248
1270
|
|
|
1271
|
+
const handleMessagePort = async (port, rpcId) => {
|
|
1272
|
+
await PlainMessagePortRpc.create({
|
|
1273
|
+
commandMap: {},
|
|
1274
|
+
messagePort: port
|
|
1275
|
+
});
|
|
1276
|
+
};
|
|
1277
|
+
|
|
1249
1278
|
const getPortTuple = () => {
|
|
1250
1279
|
const {
|
|
1251
1280
|
port1,
|
|
@@ -1322,6 +1351,8 @@ const initialize = async platform => {
|
|
|
1322
1351
|
const commandMap = {
|
|
1323
1352
|
'FileSystem.copy': copy,
|
|
1324
1353
|
'FileSystem.createFile': createFile,
|
|
1354
|
+
'FileSystem.exists': exists,
|
|
1355
|
+
'FileSystem.getFolderSize': getFolderSize,
|
|
1325
1356
|
'FileSystem.getPathSeparator': getPathSeparator,
|
|
1326
1357
|
'FileSystem.getRealPath': getRealPath,
|
|
1327
1358
|
'FileSystem.mkdir': mkdir,
|
|
@@ -1332,7 +1363,7 @@ const commandMap = {
|
|
|
1332
1363
|
'FileSystem.rename': rename,
|
|
1333
1364
|
'FileSystem.stat': stat,
|
|
1334
1365
|
'FileSystem.writeFile': writeFile,
|
|
1335
|
-
'FileSystem.
|
|
1366
|
+
'FileSystem.handleMessagePort': handleMessagePort,
|
|
1336
1367
|
'Initialize.initialize': initialize
|
|
1337
1368
|
};
|
|
1338
1369
|
|