@lvce-editor/file-system-process 3.8.0 → 4.0.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/index.js +194 -174
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -218,18 +218,22 @@ const isEnoentError = error => {
|
|
|
218
218
|
|
|
219
219
|
const FileSystemProcess = 210;
|
|
220
220
|
const MainProcess = -5;
|
|
221
|
-
const SharedProcess$1 =
|
|
221
|
+
const SharedProcess$1 = 1492;
|
|
222
222
|
|
|
223
223
|
const rpcs = Object.create(null);
|
|
224
|
-
const set$
|
|
224
|
+
const set$1 = (id, rpc) => {
|
|
225
225
|
rpcs[id] = rpc;
|
|
226
226
|
};
|
|
227
227
|
const get$1 = id => {
|
|
228
228
|
return rpcs[id];
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
-
const create$
|
|
231
|
+
const create$3 = rpcId => {
|
|
232
232
|
return {
|
|
233
|
+
async dispose() {
|
|
234
|
+
const rpc = get$1(rpcId);
|
|
235
|
+
await rpc.dispose();
|
|
236
|
+
},
|
|
233
237
|
// @ts-ignore
|
|
234
238
|
invoke(method, ...params) {
|
|
235
239
|
const rpc = get$1(rpcId);
|
|
@@ -243,11 +247,7 @@ const create$6 = rpcId => {
|
|
|
243
247
|
return rpc.invokeAndTransfer(method, ...params);
|
|
244
248
|
},
|
|
245
249
|
set(rpc) {
|
|
246
|
-
set$
|
|
247
|
-
},
|
|
248
|
-
async dispose() {
|
|
249
|
-
const rpc = get$1(rpcId);
|
|
250
|
-
await rpc.dispose();
|
|
250
|
+
set$1(rpcId, rpc);
|
|
251
251
|
}
|
|
252
252
|
};
|
|
253
253
|
};
|
|
@@ -429,8 +429,8 @@ const getModuleNotFoundError = stderr => {
|
|
|
429
429
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
430
430
|
const message = lines[messageIndex];
|
|
431
431
|
return {
|
|
432
|
-
|
|
433
|
-
|
|
432
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
433
|
+
message
|
|
434
434
|
};
|
|
435
435
|
};
|
|
436
436
|
const isModuleNotFoundError = stderr => {
|
|
@@ -453,14 +453,14 @@ const isUnhelpfulNativeModuleError = stderr => {
|
|
|
453
453
|
const getNativeModuleErrorMessage = stderr => {
|
|
454
454
|
const message = getMessageCodeBlock(stderr);
|
|
455
455
|
return {
|
|
456
|
-
|
|
457
|
-
|
|
456
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
457
|
+
message: `Incompatible native node module: ${message}`
|
|
458
458
|
};
|
|
459
459
|
};
|
|
460
460
|
const getModuleSyntaxError = () => {
|
|
461
461
|
return {
|
|
462
|
-
|
|
463
|
-
|
|
462
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
463
|
+
message: `ES Modules are not supported in electron`
|
|
464
464
|
};
|
|
465
465
|
};
|
|
466
466
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -479,8 +479,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
479
479
|
rest
|
|
480
480
|
} = getDetails(lines);
|
|
481
481
|
return {
|
|
482
|
-
message: actualMessage,
|
|
483
482
|
code: '',
|
|
483
|
+
message: actualMessage,
|
|
484
484
|
stack: rest
|
|
485
485
|
};
|
|
486
486
|
};
|
|
@@ -490,8 +490,8 @@ class IpcError extends VError {
|
|
|
490
490
|
if (stdout || stderr) {
|
|
491
491
|
// @ts-ignore
|
|
492
492
|
const {
|
|
493
|
-
message,
|
|
494
493
|
code,
|
|
494
|
+
message,
|
|
495
495
|
stack
|
|
496
496
|
} = getHelpfulChildProcessError(stdout, stderr);
|
|
497
497
|
const cause = new Error(message);
|
|
@@ -729,8 +729,8 @@ const removeListener = (emitter, type, callback) => {
|
|
|
729
729
|
};
|
|
730
730
|
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
731
731
|
const {
|
|
732
|
-
|
|
733
|
-
|
|
732
|
+
promise,
|
|
733
|
+
resolve
|
|
734
734
|
} = Promise.withResolvers();
|
|
735
735
|
const listenerMap = Object.create(null);
|
|
736
736
|
const cleanup = value => {
|
|
@@ -742,8 +742,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
742
742
|
for (const [event, type] of Object.entries(eventMap)) {
|
|
743
743
|
const listener = event => {
|
|
744
744
|
cleanup({
|
|
745
|
-
|
|
746
|
-
|
|
745
|
+
event,
|
|
746
|
+
type
|
|
747
747
|
});
|
|
748
748
|
};
|
|
749
749
|
addListener(eventEmitter, event, listener);
|
|
@@ -759,28 +759,28 @@ const getFirstWebSocketEvent = async webSocket => {
|
|
|
759
759
|
WebSocket
|
|
760
760
|
} = await import('ws');
|
|
761
761
|
switch (webSocket.readyState) {
|
|
762
|
-
case WebSocket.
|
|
762
|
+
case WebSocket.CLOSED:
|
|
763
763
|
return {
|
|
764
|
-
|
|
765
|
-
|
|
764
|
+
event: undefined,
|
|
765
|
+
type: Close
|
|
766
766
|
};
|
|
767
|
-
case WebSocket.
|
|
767
|
+
case WebSocket.OPEN:
|
|
768
768
|
return {
|
|
769
|
-
|
|
770
|
-
|
|
769
|
+
event: undefined,
|
|
770
|
+
type: Open
|
|
771
771
|
};
|
|
772
772
|
}
|
|
773
773
|
// @ts-ignore
|
|
774
774
|
const {
|
|
775
|
-
|
|
776
|
-
|
|
775
|
+
event,
|
|
776
|
+
type
|
|
777
777
|
} = await getFirstEvent(webSocket, {
|
|
778
|
-
|
|
779
|
-
|
|
778
|
+
close: Close,
|
|
779
|
+
open: Open
|
|
780
780
|
});
|
|
781
781
|
return {
|
|
782
|
-
|
|
783
|
-
|
|
782
|
+
event,
|
|
783
|
+
type
|
|
784
784
|
};
|
|
785
785
|
};
|
|
786
786
|
|
|
@@ -810,8 +810,8 @@ const handleUpgrade$1 = async (...args) => {
|
|
|
810
810
|
return module.handleUpgrade(...args);
|
|
811
811
|
};
|
|
812
812
|
const listen$1$1 = async ({
|
|
813
|
-
|
|
814
|
-
|
|
813
|
+
handle,
|
|
814
|
+
request
|
|
815
815
|
}) => {
|
|
816
816
|
if (!request) {
|
|
817
817
|
throw new IpcError('request must be defined');
|
|
@@ -831,14 +831,19 @@ const signal$4 = webSocket => {
|
|
|
831
831
|
};
|
|
832
832
|
const wrap$9 = webSocket => {
|
|
833
833
|
return {
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
834
|
+
dispose() {
|
|
835
|
+
this.webSocket.close();
|
|
836
|
+
},
|
|
837
|
+
// @ts-ignore
|
|
838
|
+
off(event, listener) {
|
|
839
|
+
this.webSocket.off(event, listener);
|
|
840
|
+
},
|
|
839
841
|
// @ts-ignore
|
|
840
842
|
on(event, listener) {
|
|
841
843
|
switch (event) {
|
|
844
|
+
case 'close':
|
|
845
|
+
webSocket.on('close', listener);
|
|
846
|
+
break;
|
|
842
847
|
case 'message':
|
|
843
848
|
// @ts-ignore
|
|
844
849
|
const wrappedListener = message => {
|
|
@@ -851,28 +856,23 @@ const wrap$9 = webSocket => {
|
|
|
851
856
|
};
|
|
852
857
|
webSocket.on('message', wrappedListener);
|
|
853
858
|
break;
|
|
854
|
-
case 'close':
|
|
855
|
-
webSocket.on('close', listener);
|
|
856
|
-
break;
|
|
857
859
|
default:
|
|
858
860
|
throw new Error('unknown event listener type');
|
|
859
861
|
}
|
|
860
862
|
},
|
|
861
863
|
// @ts-ignore
|
|
862
|
-
off(event, listener) {
|
|
863
|
-
this.webSocket.off(event, listener);
|
|
864
|
-
},
|
|
865
|
-
// @ts-ignore
|
|
866
864
|
send(message) {
|
|
867
865
|
const stringifiedMessage = serialize(message);
|
|
868
866
|
this.webSocket.send(stringifiedMessage);
|
|
869
867
|
},
|
|
870
|
-
dispose() {
|
|
871
|
-
this.webSocket.close();
|
|
872
|
-
},
|
|
873
868
|
start() {
|
|
874
869
|
throw new Error('start method is deprecated');
|
|
875
|
-
}
|
|
870
|
+
},
|
|
871
|
+
webSocket,
|
|
872
|
+
/**
|
|
873
|
+
* @type {any}
|
|
874
|
+
*/
|
|
875
|
+
wrappedListener: undefined
|
|
876
876
|
};
|
|
877
877
|
};
|
|
878
878
|
const IpcChildWithWebSocket = {
|
|
@@ -882,56 +882,14 @@ const IpcChildWithWebSocket = {
|
|
|
882
882
|
wrap: wrap$9
|
|
883
883
|
};
|
|
884
884
|
|
|
885
|
-
const Two = '2.0';
|
|
886
|
-
const create$4 = (method, params) => {
|
|
887
|
-
return {
|
|
888
|
-
jsonrpc: Two,
|
|
889
|
-
method,
|
|
890
|
-
params
|
|
891
|
-
};
|
|
892
|
-
};
|
|
885
|
+
const Two$1 = '2.0';
|
|
893
886
|
const callbacks = Object.create(null);
|
|
894
|
-
const set$1 = (id, fn) => {
|
|
895
|
-
callbacks[id] = fn;
|
|
896
|
-
};
|
|
897
887
|
const get = id => {
|
|
898
888
|
return callbacks[id];
|
|
899
889
|
};
|
|
900
890
|
const remove$1 = id => {
|
|
901
891
|
delete callbacks[id];
|
|
902
892
|
};
|
|
903
|
-
let id = 0;
|
|
904
|
-
const create$3 = () => {
|
|
905
|
-
return ++id;
|
|
906
|
-
};
|
|
907
|
-
const registerPromise = () => {
|
|
908
|
-
const id = create$3();
|
|
909
|
-
const {
|
|
910
|
-
resolve,
|
|
911
|
-
promise
|
|
912
|
-
} = Promise.withResolvers();
|
|
913
|
-
set$1(id, resolve);
|
|
914
|
-
return {
|
|
915
|
-
id,
|
|
916
|
-
promise
|
|
917
|
-
};
|
|
918
|
-
};
|
|
919
|
-
const create$2 = (method, params) => {
|
|
920
|
-
const {
|
|
921
|
-
id,
|
|
922
|
-
promise
|
|
923
|
-
} = registerPromise();
|
|
924
|
-
const message = {
|
|
925
|
-
jsonrpc: Two,
|
|
926
|
-
method,
|
|
927
|
-
params,
|
|
928
|
-
id
|
|
929
|
-
};
|
|
930
|
-
return {
|
|
931
|
-
message,
|
|
932
|
-
promise
|
|
933
|
-
};
|
|
934
|
-
};
|
|
935
893
|
class JsonRpcError extends Error {
|
|
936
894
|
constructor(message) {
|
|
937
895
|
super(message);
|
|
@@ -1127,7 +1085,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
1127
1085
|
};
|
|
1128
1086
|
const create$1 = (id, error) => {
|
|
1129
1087
|
return {
|
|
1130
|
-
jsonrpc: Two,
|
|
1088
|
+
jsonrpc: Two$1,
|
|
1131
1089
|
id,
|
|
1132
1090
|
error
|
|
1133
1091
|
};
|
|
@@ -1138,20 +1096,20 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
1138
1096
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1139
1097
|
return create$1(id, errorProperty);
|
|
1140
1098
|
};
|
|
1141
|
-
const create$
|
|
1099
|
+
const create$2 = (message, result) => {
|
|
1142
1100
|
return {
|
|
1143
|
-
jsonrpc: Two,
|
|
1101
|
+
jsonrpc: Two$1,
|
|
1144
1102
|
id: message.id,
|
|
1145
1103
|
result: result ?? null
|
|
1146
1104
|
};
|
|
1147
1105
|
};
|
|
1148
1106
|
const getSuccessResponse = (message, result) => {
|
|
1149
1107
|
const resultProperty = result ?? null;
|
|
1150
|
-
return create$
|
|
1108
|
+
return create$2(message, resultProperty);
|
|
1151
1109
|
};
|
|
1152
1110
|
const getErrorResponseSimple = (id, error) => {
|
|
1153
1111
|
return {
|
|
1154
|
-
jsonrpc: Two,
|
|
1112
|
+
jsonrpc: Two$1,
|
|
1155
1113
|
id,
|
|
1156
1114
|
error: {
|
|
1157
1115
|
code: Custom,
|
|
@@ -1238,29 +1196,6 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
1238
1196
|
}
|
|
1239
1197
|
throw new JsonRpcError('unexpected message');
|
|
1240
1198
|
};
|
|
1241
|
-
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
1242
|
-
const {
|
|
1243
|
-
message,
|
|
1244
|
-
promise
|
|
1245
|
-
} = create$2(method, params);
|
|
1246
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1247
|
-
ipc.sendAndTransfer(message);
|
|
1248
|
-
} else {
|
|
1249
|
-
ipc.send(message);
|
|
1250
|
-
}
|
|
1251
|
-
const responseMessage = await promise;
|
|
1252
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
1253
|
-
};
|
|
1254
|
-
const send = (transport, method, ...params) => {
|
|
1255
|
-
const message = create$4(method, params);
|
|
1256
|
-
transport.send(message);
|
|
1257
|
-
};
|
|
1258
|
-
const invoke$3 = (ipc, method, ...params) => {
|
|
1259
|
-
return invokeHelper(ipc, method, params, false);
|
|
1260
|
-
};
|
|
1261
|
-
const invokeAndTransfer$2 = (ipc, method, ...params) => {
|
|
1262
|
-
return invokeHelper(ipc, method, params, true);
|
|
1263
|
-
};
|
|
1264
1199
|
|
|
1265
1200
|
class CommandNotFoundError extends Error {
|
|
1266
1201
|
constructor(command) {
|
|
@@ -1283,24 +1218,87 @@ const execute = (command, ...args) => {
|
|
|
1283
1218
|
return fn(...args);
|
|
1284
1219
|
};
|
|
1285
1220
|
|
|
1221
|
+
const Two = '2.0';
|
|
1222
|
+
const create$s = (method, params) => {
|
|
1223
|
+
return {
|
|
1224
|
+
jsonrpc: Two,
|
|
1225
|
+
method,
|
|
1226
|
+
params
|
|
1227
|
+
};
|
|
1228
|
+
};
|
|
1229
|
+
const create$r = (id, method, params) => {
|
|
1230
|
+
const message = {
|
|
1231
|
+
id,
|
|
1232
|
+
jsonrpc: Two,
|
|
1233
|
+
method,
|
|
1234
|
+
params
|
|
1235
|
+
};
|
|
1236
|
+
return message;
|
|
1237
|
+
};
|
|
1238
|
+
let id = 0;
|
|
1239
|
+
const create$q = () => {
|
|
1240
|
+
return ++id;
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
1244
|
+
|
|
1245
|
+
const registerPromise = map => {
|
|
1246
|
+
const id = create$q();
|
|
1247
|
+
const {
|
|
1248
|
+
promise,
|
|
1249
|
+
resolve
|
|
1250
|
+
} = Promise.withResolvers();
|
|
1251
|
+
map[id] = resolve;
|
|
1252
|
+
return {
|
|
1253
|
+
id,
|
|
1254
|
+
promise
|
|
1255
|
+
};
|
|
1256
|
+
};
|
|
1257
|
+
|
|
1258
|
+
// @ts-ignore
|
|
1259
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
1260
|
+
const {
|
|
1261
|
+
id,
|
|
1262
|
+
promise
|
|
1263
|
+
} = registerPromise(callbacks);
|
|
1264
|
+
const message = create$r(id, method, params);
|
|
1265
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1266
|
+
ipc.sendAndTransfer(message);
|
|
1267
|
+
} else {
|
|
1268
|
+
ipc.send(message);
|
|
1269
|
+
}
|
|
1270
|
+
const responseMessage = await promise;
|
|
1271
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
1272
|
+
};
|
|
1286
1273
|
const createRpc = ipc => {
|
|
1274
|
+
const callbacks = Object.create(null);
|
|
1275
|
+
ipc._resolve = (id, response) => {
|
|
1276
|
+
const fn = callbacks[id];
|
|
1277
|
+
if (!fn) {
|
|
1278
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1281
|
+
fn(response);
|
|
1282
|
+
delete callbacks[id];
|
|
1283
|
+
};
|
|
1287
1284
|
const rpc = {
|
|
1285
|
+
async dispose() {
|
|
1286
|
+
await ipc?.dispose();
|
|
1287
|
+
},
|
|
1288
|
+
invoke(method, ...params) {
|
|
1289
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
1290
|
+
},
|
|
1291
|
+
invokeAndTransfer(method, ...params) {
|
|
1292
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
1293
|
+
},
|
|
1288
1294
|
// @ts-ignore
|
|
1289
1295
|
ipc,
|
|
1290
1296
|
/**
|
|
1291
1297
|
* @deprecated
|
|
1292
1298
|
*/
|
|
1293
1299
|
send(method, ...params) {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
invoke(method, ...params) {
|
|
1297
|
-
return invoke$3(ipc, method, ...params);
|
|
1298
|
-
},
|
|
1299
|
-
invokeAndTransfer(method, ...params) {
|
|
1300
|
-
return invokeAndTransfer$2(ipc, method, ...params);
|
|
1301
|
-
},
|
|
1302
|
-
async dispose() {
|
|
1303
|
-
await ipc?.dispose();
|
|
1300
|
+
const message = create$s(method, params);
|
|
1301
|
+
ipc.send(message);
|
|
1304
1302
|
}
|
|
1305
1303
|
};
|
|
1306
1304
|
return rpc;
|
|
@@ -1317,7 +1315,7 @@ const logError = () => {
|
|
|
1317
1315
|
const handleMessage = event => {
|
|
1318
1316
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket$1;
|
|
1319
1317
|
const actualExecute = event?.target?.execute || execute;
|
|
1320
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute,
|
|
1318
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1321
1319
|
};
|
|
1322
1320
|
const handleIpc = ipc => {
|
|
1323
1321
|
if ('addEventListener' in ipc) {
|
|
@@ -1335,7 +1333,7 @@ const listen$2 = async (module, options) => {
|
|
|
1335
1333
|
const ipc = module.wrap(rawIpc);
|
|
1336
1334
|
return ipc;
|
|
1337
1335
|
};
|
|
1338
|
-
const create$
|
|
1336
|
+
const create$p = async ({
|
|
1339
1337
|
commandMap,
|
|
1340
1338
|
messagePort,
|
|
1341
1339
|
requiresSocket
|
|
@@ -1354,9 +1352,9 @@ const create$k = async ({
|
|
|
1354
1352
|
};
|
|
1355
1353
|
const ElectronMessagePortRpcClient = {
|
|
1356
1354
|
__proto__: null,
|
|
1357
|
-
create: create$
|
|
1355
|
+
create: create$p
|
|
1358
1356
|
};
|
|
1359
|
-
const create$
|
|
1357
|
+
const create$o = async ({
|
|
1360
1358
|
commandMap
|
|
1361
1359
|
}) => {
|
|
1362
1360
|
// TODO create a commandMap per rpc instance
|
|
@@ -1368,9 +1366,29 @@ const create$j = async ({
|
|
|
1368
1366
|
};
|
|
1369
1367
|
const ElectronUtilityProcessRpcClient = {
|
|
1370
1368
|
__proto__: null,
|
|
1371
|
-
create: create$
|
|
1369
|
+
create: create$o
|
|
1370
|
+
};
|
|
1371
|
+
const create$k = async ({
|
|
1372
|
+
commandMap,
|
|
1373
|
+
getPortTuple,
|
|
1374
|
+
send
|
|
1375
|
+
}) => {
|
|
1376
|
+
const {
|
|
1377
|
+
port1,
|
|
1378
|
+
port2
|
|
1379
|
+
} = await getPortTuple();
|
|
1380
|
+
await send(port1);
|
|
1381
|
+
const rpc = create$p({
|
|
1382
|
+
commandMap,
|
|
1383
|
+
messagePort: port2
|
|
1384
|
+
});
|
|
1385
|
+
return rpc;
|
|
1372
1386
|
};
|
|
1373
|
-
const
|
|
1387
|
+
const TransferElectronMessagePortRpc = {
|
|
1388
|
+
__proto__: null,
|
|
1389
|
+
create: create$k
|
|
1390
|
+
};
|
|
1391
|
+
const create$9 = async ({
|
|
1374
1392
|
commandMap
|
|
1375
1393
|
}) => {
|
|
1376
1394
|
// TODO create a commandMap per rpc instance
|
|
@@ -1382,19 +1400,19 @@ const create$a = async ({
|
|
|
1382
1400
|
};
|
|
1383
1401
|
const NodeForkedProcessRpcClient = {
|
|
1384
1402
|
__proto__: null,
|
|
1385
|
-
create: create$
|
|
1403
|
+
create: create$9
|
|
1386
1404
|
};
|
|
1387
|
-
const create$
|
|
1405
|
+
const create$7 = async ({
|
|
1388
1406
|
commandMap,
|
|
1389
|
-
request,
|
|
1390
1407
|
handle,
|
|
1408
|
+
request,
|
|
1391
1409
|
requiresSocket
|
|
1392
1410
|
}) => {
|
|
1393
1411
|
// TODO create a commandMap per rpc instance
|
|
1394
1412
|
register(commandMap);
|
|
1395
1413
|
const ipc = await listen$2(IpcChildWithWebSocket, {
|
|
1396
|
-
|
|
1397
|
-
|
|
1414
|
+
handle,
|
|
1415
|
+
request
|
|
1398
1416
|
});
|
|
1399
1417
|
if (requiresSocket) {
|
|
1400
1418
|
ipc.requiresSocket = requiresSocket;
|
|
@@ -1405,9 +1423,9 @@ const create$8 = async ({
|
|
|
1405
1423
|
};
|
|
1406
1424
|
const NodeWebSocketRpcClient = {
|
|
1407
1425
|
__proto__: null,
|
|
1408
|
-
create: create$
|
|
1426
|
+
create: create$7
|
|
1409
1427
|
};
|
|
1410
|
-
const create$
|
|
1428
|
+
const create$6 = async ({
|
|
1411
1429
|
commandMap
|
|
1412
1430
|
}) => {
|
|
1413
1431
|
// TODO create a commandMap per rpc instance
|
|
@@ -1419,15 +1437,15 @@ const create$7 = async ({
|
|
|
1419
1437
|
};
|
|
1420
1438
|
const NodeWorkerRpcClient = {
|
|
1421
1439
|
__proto__: null,
|
|
1422
|
-
create: create$
|
|
1440
|
+
create: create$6
|
|
1423
1441
|
};
|
|
1424
1442
|
|
|
1425
1443
|
const {
|
|
1444
|
+
dispose,
|
|
1426
1445
|
invoke: invoke$2,
|
|
1427
1446
|
invokeAndTransfer: invokeAndTransfer$1,
|
|
1428
|
-
set
|
|
1429
|
-
|
|
1430
|
-
} = create$6(SharedProcess$1);
|
|
1447
|
+
set
|
|
1448
|
+
} = create$3(SharedProcess$1);
|
|
1431
1449
|
|
|
1432
1450
|
const SharedProcess = {
|
|
1433
1451
|
__proto__: null,
|
|
@@ -1442,7 +1460,7 @@ const createLazyRpc = rpcId => {
|
|
|
1442
1460
|
let factory;
|
|
1443
1461
|
const createRpc = async () => {
|
|
1444
1462
|
const rpc = await factory();
|
|
1445
|
-
set$
|
|
1463
|
+
set$1(rpcId, rpc);
|
|
1446
1464
|
};
|
|
1447
1465
|
const ensureRpc = async () => {
|
|
1448
1466
|
if (!rpcPromise) {
|
|
@@ -1451,13 +1469,18 @@ const createLazyRpc = rpcId => {
|
|
|
1451
1469
|
await rpcPromise;
|
|
1452
1470
|
};
|
|
1453
1471
|
return {
|
|
1454
|
-
setFactory(value) {
|
|
1455
|
-
factory = value;
|
|
1456
|
-
},
|
|
1457
1472
|
async invoke(method, ...params) {
|
|
1458
1473
|
await ensureRpc();
|
|
1459
1474
|
const rpc = get$1(rpcId);
|
|
1460
1475
|
return rpc.invoke(method, ...params);
|
|
1476
|
+
},
|
|
1477
|
+
async invokeAndTransfer(method, ...params) {
|
|
1478
|
+
await ensureRpc();
|
|
1479
|
+
const rpc = get$1(rpcId);
|
|
1480
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1481
|
+
},
|
|
1482
|
+
setFactory(value) {
|
|
1483
|
+
factory = value;
|
|
1461
1484
|
}
|
|
1462
1485
|
};
|
|
1463
1486
|
};
|
|
@@ -1762,14 +1785,14 @@ const Auto = argv => {
|
|
|
1762
1785
|
|
|
1763
1786
|
const getModule = method => {
|
|
1764
1787
|
switch (method) {
|
|
1788
|
+
case ElectronMessagePort:
|
|
1789
|
+
return ElectronMessagePortRpcClient.create;
|
|
1790
|
+
case ElectronUtilityProcess:
|
|
1791
|
+
return ElectronUtilityProcessRpcClient.create;
|
|
1765
1792
|
case NodeForkedProcess:
|
|
1766
1793
|
return NodeForkedProcessRpcClient.create;
|
|
1767
1794
|
case NodeWorker:
|
|
1768
1795
|
return NodeWorkerRpcClient.create;
|
|
1769
|
-
case ElectronUtilityProcess:
|
|
1770
|
-
return ElectronUtilityProcessRpcClient.create;
|
|
1771
|
-
case ElectronMessagePort:
|
|
1772
|
-
return ElectronMessagePortRpcClient.create;
|
|
1773
1796
|
case WebSocket:
|
|
1774
1797
|
return NodeWebSocketRpcClient.create;
|
|
1775
1798
|
default:
|
|
@@ -1789,11 +1812,11 @@ const listen$1 = async ({
|
|
|
1789
1812
|
const handleElectronMessagePort = async (messagePort, rpcId) => {
|
|
1790
1813
|
object(messagePort);
|
|
1791
1814
|
const rpc = await listen$1({
|
|
1792
|
-
|
|
1793
|
-
|
|
1815
|
+
messagePort,
|
|
1816
|
+
method: ElectronMessagePort
|
|
1794
1817
|
});
|
|
1795
1818
|
if (rpcId) {
|
|
1796
|
-
set$
|
|
1819
|
+
set$1(rpcId, rpc);
|
|
1797
1820
|
}
|
|
1798
1821
|
};
|
|
1799
1822
|
|
|
@@ -1804,9 +1827,9 @@ const handleWebSocket = async (handle, request) => {
|
|
|
1804
1827
|
object(handle);
|
|
1805
1828
|
object(request);
|
|
1806
1829
|
await listen$1({
|
|
1830
|
+
handle,
|
|
1807
1831
|
method: WebSocket,
|
|
1808
1832
|
request,
|
|
1809
|
-
handle,
|
|
1810
1833
|
requiresSocket
|
|
1811
1834
|
});
|
|
1812
1835
|
};
|
|
@@ -1820,8 +1843,7 @@ const create = () => {
|
|
|
1820
1843
|
|
|
1821
1844
|
const {
|
|
1822
1845
|
invoke,
|
|
1823
|
-
invokeAndTransfer
|
|
1824
|
-
} = SharedProcess;
|
|
1846
|
+
invokeAndTransfer} = SharedProcess;
|
|
1825
1847
|
|
|
1826
1848
|
const ports = Object.create(null);
|
|
1827
1849
|
const getPortTuple$1 = async () => {
|
|
@@ -1860,16 +1882,14 @@ const getPortTuple = async () => {
|
|
|
1860
1882
|
|
|
1861
1883
|
const createMainProcessRpc = async () => {
|
|
1862
1884
|
try {
|
|
1863
|
-
const {
|
|
1864
|
-
port1,
|
|
1865
|
-
port2
|
|
1866
|
-
} = await getPortTuple();
|
|
1867
|
-
await invokeAndTransfer(
|
|
1868
|
-
// @ts-ignore
|
|
1869
|
-
'TemporaryMessagePort.sendToElectron', port1, MainProcess, FileSystemProcess);
|
|
1870
|
-
const rpc = await ElectronMessagePortRpcClient.create({
|
|
1885
|
+
const rpc = TransferElectronMessagePortRpc.create({
|
|
1871
1886
|
commandMap: {},
|
|
1872
|
-
|
|
1887
|
+
getPortTuple,
|
|
1888
|
+
async send(port) {
|
|
1889
|
+
await invokeAndTransfer(
|
|
1890
|
+
// @ts-ignore
|
|
1891
|
+
'TemporaryMessagePort.sendToElectron', port, MainProcess, FileSystemProcess);
|
|
1892
|
+
}
|
|
1873
1893
|
});
|
|
1874
1894
|
return rpc;
|
|
1875
1895
|
} catch (error) {
|
|
@@ -1897,8 +1917,8 @@ const commandMap = {
|
|
|
1897
1917
|
'FileSystem.stat': stat,
|
|
1898
1918
|
'FileSystem.unwatchFile': unwatchFile,
|
|
1899
1919
|
'FileSystem.watchFile': watchFile,
|
|
1900
|
-
'FileSystem.writeFile': writeFile,
|
|
1901
1920
|
'FileSystem.writeBuffer': writeBuffer,
|
|
1921
|
+
'FileSystem.writeFile': writeFile,
|
|
1902
1922
|
'HandleElectronMessagePort.handleElectronMessagePort': handleElectronMessagePort,
|
|
1903
1923
|
'HandleWebSocket.handleWebSocket': handleWebSocket,
|
|
1904
1924
|
'Initialize.initialize': initialize,
|
|
@@ -1907,8 +1927,8 @@ const commandMap = {
|
|
|
1907
1927
|
|
|
1908
1928
|
const listen = async argv => {
|
|
1909
1929
|
await listen$1({
|
|
1910
|
-
|
|
1911
|
-
|
|
1930
|
+
commandMap: commandMap,
|
|
1931
|
+
method: Auto(argv)
|
|
1912
1932
|
});
|
|
1913
1933
|
};
|
|
1914
1934
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/file-system-process",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "File System Process",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lvce Editor",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"file-system-process": "bin/fileSystemProcess.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"trash": "^10.0.
|
|
22
|
-
"ws": "^8.
|
|
21
|
+
"trash": "^10.0.1",
|
|
22
|
+
"ws": "^8.19.0"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=22"
|