@lvce-editor/main-process 1.1.0 → 1.3.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 +17 -198
- 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';
|
|
@@ -3758,8 +3755,12 @@ const getPortTuple = () => {
|
|
|
3758
3755
|
};
|
|
3759
3756
|
};
|
|
3760
3757
|
|
|
3758
|
+
const join = (...paths) => {
|
|
3759
|
+
return NodePath.join(...paths);
|
|
3760
|
+
};
|
|
3761
|
+
|
|
3761
3762
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
3762
|
-
const root = join
|
|
3763
|
+
const root = process.env.LVCE_ROOT || join(__dirname, '../../../../..');
|
|
3763
3764
|
|
|
3764
3765
|
const {
|
|
3765
3766
|
env: env$1,
|
|
@@ -3778,6 +3779,9 @@ const getSessionId = () => {
|
|
|
3778
3779
|
return process.env.SESSION_ID || `persist:${scheme}`;
|
|
3779
3780
|
};
|
|
3780
3781
|
const getSharedProcessPath = () => {
|
|
3782
|
+
if (process.env.LVCE_SHARED_PROCESS_PATH) {
|
|
3783
|
+
return process.env.LVCE_SHARED_PROCESS_PATH;
|
|
3784
|
+
}
|
|
3781
3785
|
return join$1(root, 'packages', 'shared-process', 'src', 'sharedProcessMain.ts');
|
|
3782
3786
|
};
|
|
3783
3787
|
|
|
@@ -4427,7 +4431,7 @@ const IpcChildWithElectronUtilityProcess$1 = {
|
|
|
4427
4431
|
signal: signal$b,
|
|
4428
4432
|
wrap: wrap$i
|
|
4429
4433
|
};
|
|
4430
|
-
const withResolvers$
|
|
4434
|
+
const withResolvers$1 = () => {
|
|
4431
4435
|
let _resolve;
|
|
4432
4436
|
const promise = new Promise(resolve => {
|
|
4433
4437
|
_resolve = resolve;
|
|
@@ -4581,8 +4585,6 @@ const IpcChildWithRendererProcess2$1 = {
|
|
|
4581
4585
|
listen: listen$2,
|
|
4582
4586
|
wrap: wrap$a
|
|
4583
4587
|
};
|
|
4584
|
-
const Open = 2;
|
|
4585
|
-
const Close = 3;
|
|
4586
4588
|
const addListener = (emitter, type, callback) => {
|
|
4587
4589
|
if ('addEventListener' in emitter) {
|
|
4588
4590
|
emitter.addEventListener(type, callback);
|
|
@@ -4601,7 +4603,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
4601
4603
|
const {
|
|
4602
4604
|
resolve,
|
|
4603
4605
|
promise
|
|
4604
|
-
} = withResolvers$
|
|
4606
|
+
} = withResolvers$1();
|
|
4605
4607
|
const listenerMap = Object.create(null);
|
|
4606
4608
|
const cleanup = value => {
|
|
4607
4609
|
for (const event of Object.keys(eventMap)) {
|
|
@@ -4621,140 +4623,6 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
4621
4623
|
}
|
|
4622
4624
|
return promise;
|
|
4623
4625
|
};
|
|
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
4626
|
const create$7 = ({
|
|
4759
4627
|
messagePort
|
|
4760
4628
|
}) => {
|
|
@@ -4804,7 +4672,7 @@ const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
|
4804
4672
|
const {
|
|
4805
4673
|
resolve,
|
|
4806
4674
|
promise
|
|
4807
|
-
} = withResolvers$
|
|
4675
|
+
} = withResolvers$1();
|
|
4808
4676
|
let stdout = '';
|
|
4809
4677
|
let stderr = '';
|
|
4810
4678
|
const cleanup = value => {
|
|
@@ -5200,8 +5068,6 @@ const getModule$3 = method => {
|
|
|
5200
5068
|
return IpcChildWithNodeForkedProcess$1;
|
|
5201
5069
|
case NodeWorker$1:
|
|
5202
5070
|
return IpcChildWithNodeWorker$1;
|
|
5203
|
-
case WebSocket:
|
|
5204
|
-
return IpcChildWithWebSocket;
|
|
5205
5071
|
case ElectronUtilityProcess$1:
|
|
5206
5072
|
return IpcChildWithElectronUtilityProcess$1;
|
|
5207
5073
|
case ElectronMessagePort$1:
|
|
@@ -7157,55 +7023,9 @@ const isEnvSet = 'ELECTRON_IS_DEV' in env;
|
|
|
7157
7023
|
const getFromEnv = Number.parseInt(env.ELECTRON_IS_DEV, 10) === 1;
|
|
7158
7024
|
const isDev = isEnvSet ? getFromEnv : !Electron__default.app.isPackaged;
|
|
7159
7025
|
|
|
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
7026
|
const index = {
|
|
7207
7027
|
__proto__: null,
|
|
7208
|
-
|
|
7028
|
+
default: isDev
|
|
7209
7029
|
};
|
|
7210
7030
|
|
|
7211
7031
|
const Dash = '-';
|
|
@@ -7399,6 +7219,9 @@ const createElectronSession = () => {
|
|
|
7399
7219
|
const state$2 = {
|
|
7400
7220
|
session: undefined
|
|
7401
7221
|
};
|
|
7222
|
+
const has = () => {
|
|
7223
|
+
return Boolean(state$2.session);
|
|
7224
|
+
};
|
|
7402
7225
|
const get$1 = () => {
|
|
7403
7226
|
if (!state$2.session) {
|
|
7404
7227
|
throw new Error('session is not defined');
|
|
@@ -7426,7 +7249,7 @@ const create = ipc => {
|
|
|
7426
7249
|
};
|
|
7427
7250
|
|
|
7428
7251
|
const get = () => {
|
|
7429
|
-
if (!
|
|
7252
|
+
if (!has()) {
|
|
7430
7253
|
set$1(createElectronSession());
|
|
7431
7254
|
}
|
|
7432
7255
|
return get$1();
|
|
@@ -9222,10 +9045,6 @@ const ElectronWebContentsView_ipc = {
|
|
|
9222
9045
|
name: name$5
|
|
9223
9046
|
};
|
|
9224
9047
|
|
|
9225
|
-
const join = (...paths) => {
|
|
9226
|
-
return NodePath.join(...paths);
|
|
9227
|
-
};
|
|
9228
|
-
|
|
9229
9048
|
const webContentsViewErrorPath = join(root, 'packages', 'main-process', 'pages', 'error', 'error.html');
|
|
9230
9049
|
|
|
9231
9050
|
// TODO create output channel for browser view debug logs
|