@lvce-editor/auth-worker 1.10.0 → 1.11.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/authWorkerMain.js +28 -135
- package/package.json +1 -1
package/dist/authWorkerMain.js
CHANGED
|
@@ -267,45 +267,6 @@ const readyMessage = 'ready';
|
|
|
267
267
|
const getData$2 = event => {
|
|
268
268
|
return event.data;
|
|
269
269
|
};
|
|
270
|
-
const listen$8 = ({
|
|
271
|
-
port
|
|
272
|
-
}) => {
|
|
273
|
-
return port;
|
|
274
|
-
};
|
|
275
|
-
const signal$9 = port => {
|
|
276
|
-
port.postMessage(readyMessage);
|
|
277
|
-
};
|
|
278
|
-
class IpcChildWithMessagePort extends Ipc {
|
|
279
|
-
getData(event) {
|
|
280
|
-
return getData$2(event);
|
|
281
|
-
}
|
|
282
|
-
send(message) {
|
|
283
|
-
this._rawIpc.postMessage(message);
|
|
284
|
-
}
|
|
285
|
-
sendAndTransfer(message) {
|
|
286
|
-
const transfer = getTransferrables(message);
|
|
287
|
-
this._rawIpc.postMessage(message, transfer);
|
|
288
|
-
}
|
|
289
|
-
dispose() {
|
|
290
|
-
// ignore
|
|
291
|
-
}
|
|
292
|
-
onClose(callback) {
|
|
293
|
-
// ignore
|
|
294
|
-
}
|
|
295
|
-
onMessage(callback) {
|
|
296
|
-
this._rawIpc.addEventListener('message', callback);
|
|
297
|
-
this._rawIpc.start();
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
const wrap$g = port => {
|
|
301
|
-
return new IpcChildWithMessagePort(port);
|
|
302
|
-
};
|
|
303
|
-
const IpcChildWithMessagePort$1 = {
|
|
304
|
-
__proto__: null,
|
|
305
|
-
listen: listen$8,
|
|
306
|
-
signal: signal$9,
|
|
307
|
-
wrap: wrap$g
|
|
308
|
-
};
|
|
309
270
|
const listen$7 = () => {
|
|
310
271
|
// @ts-ignore
|
|
311
272
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
@@ -342,70 +303,11 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
342
303
|
const wrap$f = global => {
|
|
343
304
|
return new IpcChildWithModuleWorker(global);
|
|
344
305
|
};
|
|
345
|
-
const
|
|
346
|
-
const {
|
|
347
|
-
promise,
|
|
348
|
-
resolve
|
|
349
|
-
} = Promise.withResolvers();
|
|
350
|
-
port.addEventListener('message', resolve, {
|
|
351
|
-
once: true
|
|
352
|
-
});
|
|
353
|
-
const event = await promise;
|
|
354
|
-
// @ts-ignore
|
|
355
|
-
return event.data;
|
|
356
|
-
};
|
|
357
|
-
const listen$6 = async () => {
|
|
358
|
-
const parentIpcRaw = listen$7();
|
|
359
|
-
signal$8(parentIpcRaw);
|
|
360
|
-
const parentIpc = wrap$f(parentIpcRaw);
|
|
361
|
-
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
362
|
-
if (firstMessage.method !== 'initialize') {
|
|
363
|
-
throw new IpcError('unexpected first message');
|
|
364
|
-
}
|
|
365
|
-
const type = firstMessage.params[0];
|
|
366
|
-
if (type === 'message-port') {
|
|
367
|
-
parentIpc.send({
|
|
368
|
-
id: firstMessage.id,
|
|
369
|
-
jsonrpc: '2.0',
|
|
370
|
-
result: null
|
|
371
|
-
});
|
|
372
|
-
parentIpc.dispose();
|
|
373
|
-
const port = firstMessage.params[1];
|
|
374
|
-
return port;
|
|
375
|
-
}
|
|
376
|
-
return globalThis;
|
|
377
|
-
};
|
|
378
|
-
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
379
|
-
getData(event) {
|
|
380
|
-
return getData$2(event);
|
|
381
|
-
}
|
|
382
|
-
send(message) {
|
|
383
|
-
this._rawIpc.postMessage(message);
|
|
384
|
-
}
|
|
385
|
-
sendAndTransfer(message) {
|
|
386
|
-
const transfer = getTransferrables(message);
|
|
387
|
-
this._rawIpc.postMessage(message, transfer);
|
|
388
|
-
}
|
|
389
|
-
dispose() {
|
|
390
|
-
if (this._rawIpc.close) {
|
|
391
|
-
this._rawIpc.close();
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
onClose(callback) {
|
|
395
|
-
// ignore
|
|
396
|
-
}
|
|
397
|
-
onMessage(callback) {
|
|
398
|
-
this._rawIpc.addEventListener('message', callback);
|
|
399
|
-
this._rawIpc.start();
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
const wrap$e = port => {
|
|
403
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
404
|
-
};
|
|
405
|
-
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
306
|
+
const IpcChildWithModuleWorker$1 = {
|
|
406
307
|
__proto__: null,
|
|
407
|
-
listen: listen$
|
|
408
|
-
|
|
308
|
+
listen: listen$7,
|
|
309
|
+
signal: signal$8,
|
|
310
|
+
wrap: wrap$f
|
|
409
311
|
};
|
|
410
312
|
const addListener = (emitter, type, callback) => {
|
|
411
313
|
if ('addEventListener' in emitter) {
|
|
@@ -737,7 +639,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
737
639
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
738
640
|
return create$1$1(id, errorProperty);
|
|
739
641
|
};
|
|
740
|
-
const create$
|
|
642
|
+
const create$8 = (message, result) => {
|
|
741
643
|
return {
|
|
742
644
|
id: message.id,
|
|
743
645
|
jsonrpc: Two$1,
|
|
@@ -746,7 +648,7 @@ const create$9 = (message, result) => {
|
|
|
746
648
|
};
|
|
747
649
|
const getSuccessResponse = (message, result) => {
|
|
748
650
|
const resultProperty = result ?? null;
|
|
749
|
-
return create$
|
|
651
|
+
return create$8(message, resultProperty);
|
|
750
652
|
};
|
|
751
653
|
const getErrorResponseSimple = (id, error) => {
|
|
752
654
|
return {
|
|
@@ -840,7 +742,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
840
742
|
|
|
841
743
|
const Two = '2.0';
|
|
842
744
|
|
|
843
|
-
const create$
|
|
745
|
+
const create$7 = (method, params) => {
|
|
844
746
|
return {
|
|
845
747
|
jsonrpc: Two,
|
|
846
748
|
method,
|
|
@@ -848,7 +750,7 @@ const create$8 = (method, params) => {
|
|
|
848
750
|
};
|
|
849
751
|
};
|
|
850
752
|
|
|
851
|
-
const create$
|
|
753
|
+
const create$6 = (id, method, params) => {
|
|
852
754
|
const message = {
|
|
853
755
|
id,
|
|
854
756
|
jsonrpc: Two,
|
|
@@ -859,12 +761,12 @@ const create$7 = (id, method, params) => {
|
|
|
859
761
|
};
|
|
860
762
|
|
|
861
763
|
let id = 0;
|
|
862
|
-
const create$
|
|
764
|
+
const create$5 = () => {
|
|
863
765
|
return ++id;
|
|
864
766
|
};
|
|
865
767
|
|
|
866
768
|
const registerPromise = map => {
|
|
867
|
-
const id = create$
|
|
769
|
+
const id = create$5();
|
|
868
770
|
const {
|
|
869
771
|
promise,
|
|
870
772
|
resolve
|
|
@@ -881,7 +783,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
881
783
|
id,
|
|
882
784
|
promise
|
|
883
785
|
} = registerPromise(callbacks);
|
|
884
|
-
const message = create$
|
|
786
|
+
const message = create$6(id, method, params);
|
|
885
787
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
886
788
|
ipc.sendAndTransfer(message);
|
|
887
789
|
} else {
|
|
@@ -917,7 +819,7 @@ const createRpc = ipc => {
|
|
|
917
819
|
* @deprecated
|
|
918
820
|
*/
|
|
919
821
|
send(method, ...params) {
|
|
920
|
-
const message = create$
|
|
822
|
+
const message = create$7(method, params);
|
|
921
823
|
ipc.send(message);
|
|
922
824
|
}
|
|
923
825
|
};
|
|
@@ -957,7 +859,7 @@ const listen$1 = async (module, options) => {
|
|
|
957
859
|
return ipc;
|
|
958
860
|
};
|
|
959
861
|
|
|
960
|
-
const create$
|
|
862
|
+
const create$4 = async ({
|
|
961
863
|
commandMap,
|
|
962
864
|
isMessagePortOpen = true,
|
|
963
865
|
messagePort
|
|
@@ -975,7 +877,7 @@ const create$5 = async ({
|
|
|
975
877
|
return rpc;
|
|
976
878
|
};
|
|
977
879
|
|
|
978
|
-
const create$
|
|
880
|
+
const create$3 = async ({
|
|
979
881
|
commandMap,
|
|
980
882
|
isMessagePortOpen,
|
|
981
883
|
send
|
|
@@ -985,7 +887,7 @@ const create$4 = async ({
|
|
|
985
887
|
port2
|
|
986
888
|
} = new MessageChannel();
|
|
987
889
|
await send(port1);
|
|
988
|
-
return create$
|
|
890
|
+
return create$4({
|
|
989
891
|
commandMap,
|
|
990
892
|
isMessagePortOpen,
|
|
991
893
|
messagePort: port2
|
|
@@ -1020,13 +922,13 @@ const createSharedLazyRpc = factory => {
|
|
|
1020
922
|
};
|
|
1021
923
|
};
|
|
1022
924
|
|
|
1023
|
-
const create$
|
|
925
|
+
const create$2 = async ({
|
|
1024
926
|
commandMap,
|
|
1025
927
|
isMessagePortOpen,
|
|
1026
928
|
send
|
|
1027
929
|
}) => {
|
|
1028
930
|
return createSharedLazyRpc(() => {
|
|
1029
|
-
return create$
|
|
931
|
+
return create$3({
|
|
1030
932
|
commandMap,
|
|
1031
933
|
isMessagePortOpen,
|
|
1032
934
|
send
|
|
@@ -1034,26 +936,12 @@ const create$3 = async ({
|
|
|
1034
936
|
});
|
|
1035
937
|
};
|
|
1036
938
|
|
|
1037
|
-
const create$2 = async ({
|
|
1038
|
-
commandMap,
|
|
1039
|
-
messagePort
|
|
1040
|
-
}) => {
|
|
1041
|
-
// TODO create a commandMap per rpc instance
|
|
1042
|
-
register(commandMap);
|
|
1043
|
-
const ipc = await listen$1(IpcChildWithMessagePort$1, {
|
|
1044
|
-
port: messagePort
|
|
1045
|
-
});
|
|
1046
|
-
handleIpc(ipc);
|
|
1047
|
-
const rpc = createRpc(ipc);
|
|
1048
|
-
return rpc;
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
939
|
const create$1 = async ({
|
|
1052
940
|
commandMap
|
|
1053
941
|
}) => {
|
|
1054
942
|
// TODO create a commandMap per rpc instance
|
|
1055
943
|
register(commandMap);
|
|
1056
|
-
const ipc = await listen$1(
|
|
944
|
+
const ipc = await listen$1(IpcChildWithModuleWorker$1);
|
|
1057
945
|
handleIpc(ipc);
|
|
1058
946
|
const rpc = createRpc(ipc);
|
|
1059
947
|
return rpc;
|
|
@@ -1160,7 +1048,7 @@ const sendMessagePortToAuthProcess = async port => {
|
|
|
1160
1048
|
await sendMessagePortToSharedProcess(port);
|
|
1161
1049
|
};
|
|
1162
1050
|
const initializeAuthProcess = async () => {
|
|
1163
|
-
const rpc = await create$
|
|
1051
|
+
const rpc = await create$2({
|
|
1164
1052
|
commandMap: {},
|
|
1165
1053
|
send: sendMessagePortToAuthProcess
|
|
1166
1054
|
});
|
|
@@ -1171,18 +1059,22 @@ const sendMessagePortToOpenerWorker = async port => {
|
|
|
1171
1059
|
await sendMessagePortToOpenerWorker$1(port, 0);
|
|
1172
1060
|
};
|
|
1173
1061
|
const initializeOpenerWorker = async () => {
|
|
1174
|
-
const rpc = await create$
|
|
1062
|
+
const rpc = await create$2({
|
|
1175
1063
|
commandMap: {},
|
|
1176
1064
|
send: sendMessagePortToOpenerWorker
|
|
1177
1065
|
});
|
|
1178
1066
|
set$1(rpc);
|
|
1179
1067
|
};
|
|
1180
1068
|
|
|
1181
|
-
const handleMessagePort = async port => {
|
|
1182
|
-
await create$
|
|
1069
|
+
const handleMessagePort = async (port, rpcId) => {
|
|
1070
|
+
const rpc = await create$4({
|
|
1183
1071
|
commandMap: commandMap,
|
|
1072
|
+
isMessagePortOpen: true,
|
|
1184
1073
|
messagePort: port
|
|
1185
1074
|
});
|
|
1075
|
+
if (rpcId) {
|
|
1076
|
+
set$3(rpcId, rpc);
|
|
1077
|
+
}
|
|
1186
1078
|
};
|
|
1187
1079
|
|
|
1188
1080
|
const initialize = async platform => {
|
|
@@ -1808,7 +1700,8 @@ const commandMap = {
|
|
|
1808
1700
|
'Auth.setNextLoginResponse': setNextLoginResponse,
|
|
1809
1701
|
'Auth.setNextRefreshResponse': setNextRefreshResponse,
|
|
1810
1702
|
'Auth.syncBackendAuth': syncBackendAuth,
|
|
1811
|
-
'HandleMessagePort.handleMessagePort': handleMessagePort
|
|
1703
|
+
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
1704
|
+
initialize: (_, port) => handleMessagePort(port)
|
|
1812
1705
|
};
|
|
1813
1706
|
|
|
1814
1707
|
const initializeRendererWorker = async () => {
|