@lvce-editor/main-process 1.1.0 → 1.2.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/mainProcessMain.js +13 -194
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -3,8 +3,6 @@ import Electron__default, { dialog, app, clipboard, BrowserWindow, MessageChanne
|
|
|
3
3
|
import process$1 from 'node:process';
|
|
4
4
|
import { inspect } from 'node:util';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
|
-
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
7
|
-
import * as _ws from 'ws';
|
|
8
6
|
import { createWriteStream, readFileSync } from 'node:fs';
|
|
9
7
|
import * as NodePath from 'node:path';
|
|
10
8
|
import { dirname, join as join$1 } from 'node:path';
|
|
@@ -648,7 +646,7 @@ let options = {
|
|
|
648
646
|
// eslint-disable-line unicorn/prefer-top-level-await
|
|
649
647
|
const {
|
|
650
648
|
default: isDevelopment
|
|
651
|
-
} = await Promise.resolve().then(function () { return index
|
|
649
|
+
} = await Promise.resolve().then(function () { return index; });
|
|
652
650
|
return isDevelopment;
|
|
653
651
|
})()
|
|
654
652
|
};
|
|
@@ -3398,7 +3396,6 @@ const NodeWorker$1 = 1;
|
|
|
3398
3396
|
const NodeForkedProcess$1 = 2;
|
|
3399
3397
|
const ElectronUtilityProcess$1 = 3;
|
|
3400
3398
|
const ElectronMessagePort$1 = 4;
|
|
3401
|
-
const WebSocket = 6;
|
|
3402
3399
|
const RendererProcess2 = 8;
|
|
3403
3400
|
|
|
3404
3401
|
const Two = '2.0';
|
|
@@ -3759,7 +3756,7 @@ const getPortTuple = () => {
|
|
|
3759
3756
|
};
|
|
3760
3757
|
|
|
3761
3758
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
3762
|
-
const root = join$1(__dirname, '../../../../..');
|
|
3759
|
+
const root = process.env.LVCE_ROOT || join$1(__dirname, '../../../../..');
|
|
3763
3760
|
|
|
3764
3761
|
const {
|
|
3765
3762
|
env: env$1,
|
|
@@ -3778,6 +3775,9 @@ const getSessionId = () => {
|
|
|
3778
3775
|
return process.env.SESSION_ID || `persist:${scheme}`;
|
|
3779
3776
|
};
|
|
3780
3777
|
const getSharedProcessPath = () => {
|
|
3778
|
+
if (process.env.LVCE_SHARED_PROCESS_PATH) {
|
|
3779
|
+
return process.env.LVCE_SHARED_PROCESS_PATH;
|
|
3780
|
+
}
|
|
3781
3781
|
return join$1(root, 'packages', 'shared-process', 'src', 'sharedProcessMain.ts');
|
|
3782
3782
|
};
|
|
3783
3783
|
|
|
@@ -4427,7 +4427,7 @@ const IpcChildWithElectronUtilityProcess$1 = {
|
|
|
4427
4427
|
signal: signal$b,
|
|
4428
4428
|
wrap: wrap$i
|
|
4429
4429
|
};
|
|
4430
|
-
const withResolvers$
|
|
4430
|
+
const withResolvers$1 = () => {
|
|
4431
4431
|
let _resolve;
|
|
4432
4432
|
const promise = new Promise(resolve => {
|
|
4433
4433
|
_resolve = resolve;
|
|
@@ -4581,8 +4581,6 @@ const IpcChildWithRendererProcess2$1 = {
|
|
|
4581
4581
|
listen: listen$2,
|
|
4582
4582
|
wrap: wrap$a
|
|
4583
4583
|
};
|
|
4584
|
-
const Open = 2;
|
|
4585
|
-
const Close = 3;
|
|
4586
4584
|
const addListener = (emitter, type, callback) => {
|
|
4587
4585
|
if ('addEventListener' in emitter) {
|
|
4588
4586
|
emitter.addEventListener(type, callback);
|
|
@@ -4601,7 +4599,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
4601
4599
|
const {
|
|
4602
4600
|
resolve,
|
|
4603
4601
|
promise
|
|
4604
|
-
} = withResolvers$
|
|
4602
|
+
} = withResolvers$1();
|
|
4605
4603
|
const listenerMap = Object.create(null);
|
|
4606
4604
|
const cleanup = value => {
|
|
4607
4605
|
for (const event of Object.keys(eventMap)) {
|
|
@@ -4621,140 +4619,6 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
4621
4619
|
}
|
|
4622
4620
|
return promise;
|
|
4623
4621
|
};
|
|
4624
|
-
|
|
4625
|
-
// @ts-ignore
|
|
4626
|
-
const getFirstWebSocketEvent = async webSocket => {
|
|
4627
|
-
// @ts-ignore
|
|
4628
|
-
const {
|
|
4629
|
-
WebSocket
|
|
4630
|
-
} = await import('ws');
|
|
4631
|
-
switch (webSocket.readyState) {
|
|
4632
|
-
case WebSocket.OPEN:
|
|
4633
|
-
return {
|
|
4634
|
-
type: Open,
|
|
4635
|
-
event: undefined
|
|
4636
|
-
};
|
|
4637
|
-
case WebSocket.CLOSED:
|
|
4638
|
-
return {
|
|
4639
|
-
type: Close,
|
|
4640
|
-
event: undefined
|
|
4641
|
-
};
|
|
4642
|
-
}
|
|
4643
|
-
// @ts-ignore
|
|
4644
|
-
const {
|
|
4645
|
-
type,
|
|
4646
|
-
event
|
|
4647
|
-
} = await getFirstEvent(webSocket, {
|
|
4648
|
-
open: Open,
|
|
4649
|
-
close: Close
|
|
4650
|
-
});
|
|
4651
|
-
return {
|
|
4652
|
-
type,
|
|
4653
|
-
event
|
|
4654
|
-
};
|
|
4655
|
-
};
|
|
4656
|
-
|
|
4657
|
-
// @ts-ignore
|
|
4658
|
-
const isWebSocketOpen = async webSocket => {
|
|
4659
|
-
// @ts-ignore
|
|
4660
|
-
const {
|
|
4661
|
-
WebSocket
|
|
4662
|
-
} = await import('ws');
|
|
4663
|
-
return webSocket.readyState === WebSocket.OPEN;
|
|
4664
|
-
};
|
|
4665
|
-
|
|
4666
|
-
// @ts-ignore
|
|
4667
|
-
const serialize = message => {
|
|
4668
|
-
return JSON.stringify(message);
|
|
4669
|
-
};
|
|
4670
|
-
|
|
4671
|
-
// @ts-ignore
|
|
4672
|
-
const deserialize = message => {
|
|
4673
|
-
return JSON.parse(message.toString());
|
|
4674
|
-
};
|
|
4675
|
-
|
|
4676
|
-
// @ts-ignore
|
|
4677
|
-
const handleUpgrade$1 = async (...args) => {
|
|
4678
|
-
const module = await Promise.resolve().then(function () { return index; });
|
|
4679
|
-
// @ts-ignore
|
|
4680
|
-
return module.handleUpgrade(...args);
|
|
4681
|
-
};
|
|
4682
|
-
|
|
4683
|
-
// @ts-ignore
|
|
4684
|
-
const listen$1 = async ({
|
|
4685
|
-
request,
|
|
4686
|
-
handle
|
|
4687
|
-
}) => {
|
|
4688
|
-
if (!request) {
|
|
4689
|
-
throw new IpcError('request must be defined');
|
|
4690
|
-
}
|
|
4691
|
-
if (!handle) {
|
|
4692
|
-
throw new IpcError('handle must be defined');
|
|
4693
|
-
}
|
|
4694
|
-
const webSocket = await handleUpgrade$1(request, handle);
|
|
4695
|
-
webSocket.pause();
|
|
4696
|
-
if (!(await isWebSocketOpen(webSocket))) {
|
|
4697
|
-
await getFirstWebSocketEvent(webSocket);
|
|
4698
|
-
}
|
|
4699
|
-
return webSocket;
|
|
4700
|
-
};
|
|
4701
|
-
const signal$4 = webSocket => {
|
|
4702
|
-
webSocket.resume();
|
|
4703
|
-
};
|
|
4704
|
-
|
|
4705
|
-
// @ts-ignore
|
|
4706
|
-
const wrap$9 = webSocket => {
|
|
4707
|
-
return {
|
|
4708
|
-
webSocket,
|
|
4709
|
-
/**
|
|
4710
|
-
* @type {any}
|
|
4711
|
-
*/
|
|
4712
|
-
wrappedListener: undefined,
|
|
4713
|
-
// @ts-ignore
|
|
4714
|
-
on(event, listener) {
|
|
4715
|
-
switch (event) {
|
|
4716
|
-
case 'message':
|
|
4717
|
-
// @ts-ignore
|
|
4718
|
-
const wrappedListener = message => {
|
|
4719
|
-
const data = deserialize(message);
|
|
4720
|
-
const event = {
|
|
4721
|
-
data,
|
|
4722
|
-
target: this
|
|
4723
|
-
};
|
|
4724
|
-
listener(event);
|
|
4725
|
-
};
|
|
4726
|
-
webSocket.on('message', wrappedListener);
|
|
4727
|
-
break;
|
|
4728
|
-
case 'close':
|
|
4729
|
-
webSocket.on('close', listener);
|
|
4730
|
-
break;
|
|
4731
|
-
default:
|
|
4732
|
-
throw new Error('unknown event listener type');
|
|
4733
|
-
}
|
|
4734
|
-
},
|
|
4735
|
-
// @ts-ignore
|
|
4736
|
-
off(event, listener) {
|
|
4737
|
-
this.webSocket.off(event, listener);
|
|
4738
|
-
},
|
|
4739
|
-
// @ts-ignore
|
|
4740
|
-
send(message) {
|
|
4741
|
-
const stringifiedMessage = serialize(message);
|
|
4742
|
-
this.webSocket.send(stringifiedMessage);
|
|
4743
|
-
},
|
|
4744
|
-
dispose() {
|
|
4745
|
-
this.webSocket.close();
|
|
4746
|
-
},
|
|
4747
|
-
start() {
|
|
4748
|
-
throw new Error('start method is deprecated');
|
|
4749
|
-
}
|
|
4750
|
-
};
|
|
4751
|
-
};
|
|
4752
|
-
const IpcChildWithWebSocket = {
|
|
4753
|
-
__proto__: null,
|
|
4754
|
-
listen: listen$1,
|
|
4755
|
-
signal: signal$4,
|
|
4756
|
-
wrap: wrap$9
|
|
4757
|
-
};
|
|
4758
4622
|
const create$7 = ({
|
|
4759
4623
|
messagePort
|
|
4760
4624
|
}) => {
|
|
@@ -4804,7 +4668,7 @@ const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
|
4804
4668
|
const {
|
|
4805
4669
|
resolve,
|
|
4806
4670
|
promise
|
|
4807
|
-
} = withResolvers$
|
|
4671
|
+
} = withResolvers$1();
|
|
4808
4672
|
let stdout = '';
|
|
4809
4673
|
let stderr = '';
|
|
4810
4674
|
const cleanup = value => {
|
|
@@ -5200,8 +5064,6 @@ const getModule$3 = method => {
|
|
|
5200
5064
|
return IpcChildWithNodeForkedProcess$1;
|
|
5201
5065
|
case NodeWorker$1:
|
|
5202
5066
|
return IpcChildWithNodeWorker$1;
|
|
5203
|
-
case WebSocket:
|
|
5204
|
-
return IpcChildWithWebSocket;
|
|
5205
5067
|
case ElectronUtilityProcess$1:
|
|
5206
5068
|
return IpcChildWithElectronUtilityProcess$1;
|
|
5207
5069
|
case ElectronMessagePort$1:
|
|
@@ -7157,55 +7019,9 @@ const isEnvSet = 'ELECTRON_IS_DEV' in env;
|
|
|
7157
7019
|
const getFromEnv = Number.parseInt(env.ELECTRON_IS_DEV, 10) === 1;
|
|
7158
7020
|
const isDev = isEnvSet ? getFromEnv : !Electron__default.app.isPackaged;
|
|
7159
7021
|
|
|
7160
|
-
const index$1 = {
|
|
7161
|
-
__proto__: null,
|
|
7162
|
-
default: isDev
|
|
7163
|
-
};
|
|
7164
|
-
|
|
7165
|
-
// workaround for jest or node bug
|
|
7166
|
-
const WebSocketServer = _ws.WebSocketServer ? _ws.WebSocketServer :
|
|
7167
|
-
// @ts-ignore
|
|
7168
|
-
_ws.default.WebSocketServer;
|
|
7169
|
-
const webSocketServer = new WebSocketServer({
|
|
7170
|
-
noServer: true
|
|
7171
|
-
|
|
7172
|
-
// TODO not sure if ws compress is working at all
|
|
7173
|
-
// perMessageDeflate: true
|
|
7174
|
-
});
|
|
7175
|
-
const withResolvers$1 = () => {
|
|
7176
|
-
/**
|
|
7177
|
-
* @type {any}
|
|
7178
|
-
*/
|
|
7179
|
-
let _resolve;
|
|
7180
|
-
/**
|
|
7181
|
-
* @type {any}
|
|
7182
|
-
*/
|
|
7183
|
-
let _reject;
|
|
7184
|
-
const promise = new Promise((resolve, reject) => {
|
|
7185
|
-
_resolve = resolve;
|
|
7186
|
-
_reject = reject;
|
|
7187
|
-
});
|
|
7188
|
-
return {
|
|
7189
|
-
resolve: _resolve,
|
|
7190
|
-
reject: _reject,
|
|
7191
|
-
promise
|
|
7192
|
-
};
|
|
7193
|
-
};
|
|
7194
|
-
const handleUpgrade = (request, socket) => {
|
|
7195
|
-
const {
|
|
7196
|
-
promise,
|
|
7197
|
-
resolve
|
|
7198
|
-
} = withResolvers$1();
|
|
7199
|
-
const upgradeCallback = ws => {
|
|
7200
|
-
resolve(ws);
|
|
7201
|
-
};
|
|
7202
|
-
webSocketServer.handleUpgrade(request, socket, Buffer$1.alloc(0), upgradeCallback);
|
|
7203
|
-
return promise;
|
|
7204
|
-
};
|
|
7205
|
-
|
|
7206
7022
|
const index = {
|
|
7207
7023
|
__proto__: null,
|
|
7208
|
-
|
|
7024
|
+
default: isDev
|
|
7209
7025
|
};
|
|
7210
7026
|
|
|
7211
7027
|
const Dash = '-';
|
|
@@ -7399,6 +7215,9 @@ const createElectronSession = () => {
|
|
|
7399
7215
|
const state$2 = {
|
|
7400
7216
|
session: undefined
|
|
7401
7217
|
};
|
|
7218
|
+
const has = () => {
|
|
7219
|
+
return Boolean(state$2.session);
|
|
7220
|
+
};
|
|
7402
7221
|
const get$1 = () => {
|
|
7403
7222
|
if (!state$2.session) {
|
|
7404
7223
|
throw new Error('session is not defined');
|
|
@@ -7426,7 +7245,7 @@ const create = ipc => {
|
|
|
7426
7245
|
};
|
|
7427
7246
|
|
|
7428
7247
|
const get = () => {
|
|
7429
|
-
if (!
|
|
7248
|
+
if (!has()) {
|
|
7430
7249
|
set$1(createElectronSession());
|
|
7431
7250
|
}
|
|
7432
7251
|
return get$1();
|