@lvce-editor/file-system-worker 1.5.0 → 1.7.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.
@@ -541,15 +541,15 @@ const set$2 = (id, fn) => {
541
541
  const get$1 = id => {
542
542
  return callbacks[id];
543
543
  };
544
- const remove$1 = id => {
544
+ 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
@@ -725,7 +725,7 @@ const resolve = (id, response) => {
725
725
  return;
726
726
  }
727
727
  fn(response);
728
- remove$1(id);
728
+ remove$2(id);
729
729
  };
730
730
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
731
731
  const getErrorType = prettyError => {
@@ -898,7 +898,7 @@ const send = (transport, method, ...params) => {
898
898
  const message = create$4$1(method, params);
899
899
  transport.send(message);
900
900
  };
901
- const invoke$1 = (ipc, method, ...params) => {
901
+ const invoke = (ipc, method, ...params) => {
902
902
  return invokeHelper(ipc, method, params, false);
903
903
  };
904
904
  const invokeAndTransfer$1 = (ipc, method, ...params) => {
@@ -931,7 +931,7 @@ const createRpc = ipc => {
931
931
  send(ipc, method, ...params);
932
932
  },
933
933
  invoke(method, ...params) {
934
- return invoke$1(ipc, method, ...params);
934
+ return invoke(ipc, method, ...params);
935
935
  },
936
936
  invokeAndTransfer(method, ...params) {
937
937
  return invokeAndTransfer$1(ipc, method, ...params);
@@ -1015,11 +1015,41 @@ const create$2 = async ({
1015
1015
  const rpc = createRpc(ipc);
1016
1016
  return rpc;
1017
1017
  };
1018
- const WebSocketRpcParent = {
1019
- __proto__: null,
1020
- create: create$2
1018
+ const Https = 'https:';
1019
+ const Ws = 'ws:';
1020
+ const Wss = 'wss:';
1021
+ const getWebSocketProtocol = locationProtocol => {
1022
+ return locationProtocol === Https ? 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,7 @@ const create$1 = async ({
1031
1061
  };
1032
1062
  const WebWorkerRpcClient = {
1033
1063
  __proto__: null,
1034
- create: create$1
1064
+ create: create$3
1035
1065
  };
1036
1066
 
1037
1067
  const rpcs = Object.create(null);
@@ -1076,10 +1106,66 @@ const RpcId = {
1076
1106
  const {
1077
1107
  invoke: invoke$8,
1078
1108
  set: set$8} = create(FileSystemProcess$1);
1109
+ const remove$1$1 = async uri => {
1110
+ return invoke$8('FileSystem.remove', uri);
1111
+ };
1112
+ const readFile$1$1 = async uri => {
1113
+ return invoke$8('FileSystem.readFile', uri);
1114
+ };
1115
+ const readDirWithFileTypes$1$1 = async uri => {
1116
+ return invoke$8('FileSystem.readDirWithFileTypes', uri);
1117
+ };
1118
+ const getPathSeparator$1$1 = async root => {
1119
+ // @ts-ignore
1120
+ return invoke$8('FileSystem.getPathSeparator', root);
1121
+ };
1122
+ const readJson$2 = async root => {
1123
+ // @ts-ignore
1124
+ return invoke$8('FileSystem.readJson', root);
1125
+ };
1126
+ const getRealPath$1$1 = async path => {
1127
+ // @ts-ignore
1128
+ return invoke$8('FileSystem.getRealPath', path);
1129
+ };
1130
+ const stat$1$1 = async path => {
1131
+ // @ts-ignore
1132
+ return invoke$8('FileSystem.stat', path);
1133
+ };
1134
+ const writeFile$1$1 = async (path, content) => {
1135
+ // @ts-ignore
1136
+ return invoke$8('FileSystem.writeFile', path, content);
1137
+ };
1138
+ const mkdir$1$1 = async path => {
1139
+ // @ts-ignore
1140
+ return invoke$8('FileSystem.mkdir', path);
1141
+ };
1142
+ const rename$1$1 = async (oldUri, newUri) => {
1143
+ // @ts-ignore
1144
+ return invoke$8('FileSystem.rename', oldUri, newUri);
1145
+ };
1146
+ const copy$1$1 = async (oldUri, newUri) => {
1147
+ // @ts-ignore
1148
+ return invoke$8('FileSystem.copy', oldUri, newUri);
1149
+ };
1150
+ const getFolderSize$1$1 = async uri => {
1151
+ // @ts-ignore
1152
+ return invoke$8('FileSystem.getFolderSize', uri);
1153
+ };
1079
1154
  const FileSystemProcess = {
1080
1155
  __proto__: null,
1081
- invoke: invoke$8,
1082
- set: set$8
1156
+ copy: copy$1$1,
1157
+ getFolderSize: getFolderSize$1$1,
1158
+ getPathSeparator: getPathSeparator$1$1,
1159
+ getRealPath: getRealPath$1$1,
1160
+ mkdir: mkdir$1$1,
1161
+ readDirWithFileTypes: readDirWithFileTypes$1$1,
1162
+ readFile: readFile$1$1,
1163
+ readJson: readJson$2,
1164
+ remove: remove$1$1,
1165
+ rename: rename$1$1,
1166
+ set: set$8,
1167
+ stat: stat$1$1,
1168
+ writeFile: writeFile$1$1
1083
1169
  };
1084
1170
  const {
1085
1171
  invokeAndTransfer: invokeAndTransfer$3,
@@ -1090,47 +1176,59 @@ const RendererWorker = {
1090
1176
  set: set$3};
1091
1177
 
1092
1178
  const {
1093
- invoke,
1094
- set: set$1
1179
+ set: set$1,
1180
+ rename: rename$1,
1181
+ copy: copy$1,
1182
+ mkdir: mkdir$1,
1183
+ getFolderSize: getFolderSize$1,
1184
+ writeFile: writeFile$1,
1185
+ stat: stat$1,
1186
+ readJson: readJson$1,
1187
+ getPathSeparator: getPathSeparator$1,
1188
+ getRealPath: getRealPath$1,
1189
+ readDirWithFileTypes: readDirWithFileTypes$1,
1190
+ readFile: readFile$1,
1191
+ remove: remove$1
1095
1192
  } = FileSystemProcess;
1096
1193
 
1097
1194
  const remove = async dirent => {
1098
- return invoke('FileSystem.remove', dirent);
1195
+ return remove$1(dirent);
1099
1196
  };
1100
1197
  const readFile = async uri => {
1101
- return invoke('FileSystem.readFile', uri);
1198
+ return readFile$1(uri);
1102
1199
  };
1103
1200
  const readDirWithFileTypes = async uri => {
1104
- return invoke('FileSystem.readDirWithFileTypes', uri);
1201
+ return readDirWithFileTypes$1(uri);
1105
1202
  };
1106
1203
  const getPathSeparator = async root => {
1107
- // @ts-ignore
1108
- return invoke('FileSystem.getPathSeparator', root);
1204
+ return getPathSeparator$1(root);
1109
1205
  };
1110
1206
  const readJson = async uri => {
1111
- // @ts-ignore
1112
- return invoke('FileSystem.readJson', uri);
1207
+ return readJson$1(uri);
1113
1208
  };
1114
1209
  const getRealPath = async path => {
1115
- return invoke('FileSystem.getRealPath', path);
1210
+ return getRealPath$1(path);
1116
1211
  };
1117
1212
  const stat = async dirent => {
1118
- return invoke('FileSystem.stat', dirent);
1213
+ return stat$1(dirent);
1119
1214
  };
1120
1215
  const createFile = async uri => {
1121
- return invoke('FileSystem.writeFile', uri, '');
1216
+ return writeFile$1(uri, '');
1122
1217
  };
1123
1218
  const writeFile = async (uri, content) => {
1124
- return invoke('FileSystem.writeFile', uri, content);
1219
+ return writeFile$1(uri, content);
1125
1220
  };
1126
1221
  const mkdir = async uri => {
1127
- return invoke('FileSystem.mkdir', uri);
1222
+ return mkdir$1(uri);
1128
1223
  };
1129
1224
  const rename = async (oldUri, newUri) => {
1130
- return invoke('FileSystem.rename', oldUri, newUri);
1225
+ return rename$1(oldUri, newUri);
1131
1226
  };
1132
1227
  const copy = async (oldUri, newUri) => {
1133
- return invoke('FileSystem.copy', oldUri, newUri);
1228
+ return copy$1(oldUri, newUri);
1229
+ };
1230
+ const getFolderSize = async uri => {
1231
+ return getFolderSize$1(uri);
1134
1232
  };
1135
1233
 
1136
1234
  const getPortTuple = () => {
@@ -1146,8 +1244,7 @@ const getPortTuple = () => {
1146
1244
 
1147
1245
  const {
1148
1246
  invokeAndTransfer,
1149
- set
1150
- } = RendererWorker;
1247
+ set} = RendererWorker;
1151
1248
 
1152
1249
  const sendMessagePortToFileSystemProcess = async port => {
1153
1250
  const command = 'HandleMessagePortForFileSystemProcess.handleMessagePortForFileSystemProcess';
@@ -1171,34 +1268,10 @@ const createFileSystemProcessRpcElectron = async () => {
1171
1268
  }
1172
1269
  };
1173
1270
 
1174
- const Https = 'https:';
1175
- const Ws = 'ws:';
1176
- const Wss = 'wss:';
1177
-
1178
- const getWebSocketProtocol = locationProtocol => {
1179
- return locationProtocol === Https ? Wss : Ws;
1180
- };
1181
-
1182
- const getWebSocketUrl = (type, host, locationProtocol) => {
1183
- const wsProtocol = getWebSocketProtocol(locationProtocol);
1184
- return `${wsProtocol}//${host}/websocket/${type}`;
1185
- };
1186
-
1187
- const getHost = () => {
1188
- return location.host;
1189
- };
1190
- const getProtocol = () => {
1191
- return location.protocol;
1192
- };
1193
-
1194
1271
  const createFileSystemProcessRpcNode = async () => {
1195
1272
  try {
1196
- const host = getHost();
1197
- const protocol = getProtocol();
1198
- const wsUrl = getWebSocketUrl('file-system-process', host, protocol);
1199
- const webSocket = new WebSocket(wsUrl);
1200
- const rpc = await WebSocketRpcParent.create({
1201
- webSocket,
1273
+ const rpc = await WebSocketRpcParent2.create({
1274
+ type: 'file-system-process',
1202
1275
  commandMap: {}
1203
1276
  });
1204
1277
  return rpc;
@@ -1244,6 +1317,7 @@ const commandMap = {
1244
1317
  'FileSystem.rename': rename,
1245
1318
  'FileSystem.stat': stat,
1246
1319
  'FileSystem.writeFile': writeFile,
1320
+ 'FileSystem.getFolderSize': getFolderSize,
1247
1321
  'Initialize.initialize': initialize
1248
1322
  };
1249
1323
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-system-worker",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "File System Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"