@lvce-editor/main-process 6.27.1 → 6.27.2
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 +56 -50
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -7,7 +7,7 @@ import { spawn } from 'node:child_process';
|
|
|
7
7
|
import { Console } from 'node:console';
|
|
8
8
|
import { mkdirSync, createWriteStream, readFileSync, openAsBlob, existsSync, writeFileSync, rmSync, openSync, writeSync, closeSync } from 'node:fs';
|
|
9
9
|
import * as NodePath from 'node:path';
|
|
10
|
-
import { dirname, join as join$1, isAbsolute } from 'node:path';
|
|
10
|
+
import { dirname as dirname$1, join as join$1, isAbsolute } from 'node:path';
|
|
11
11
|
import { homedir, tmpdir } from 'node:os';
|
|
12
12
|
import { readFile } from 'node:fs/promises';
|
|
13
13
|
import { pbkdf2Sync, createDecipheriv, createHash } from 'node:crypto';
|
|
@@ -784,8 +784,11 @@ const getNewLineIndex$2 = (string, startIndex = undefined) => {
|
|
|
784
784
|
const join = (...paths) => {
|
|
785
785
|
return NodePath.join(...paths);
|
|
786
786
|
};
|
|
787
|
+
const dirname = path => {
|
|
788
|
+
return NodePath.dirname(path);
|
|
789
|
+
};
|
|
787
790
|
|
|
788
|
-
const __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
791
|
+
const __dirname$1 = dirname$1(fileURLToPath(import.meta.url));
|
|
789
792
|
const root = process.env.LVCE_ROOT || join(__dirname$1, '../../../../..');
|
|
790
793
|
|
|
791
794
|
const {
|
|
@@ -819,58 +822,62 @@ const getSharedProcessPath = () => {
|
|
|
819
822
|
};
|
|
820
823
|
|
|
821
824
|
const createFileLogger = fileName => {
|
|
822
|
-
|
|
825
|
+
const logFile = join(logsDir, fileName);
|
|
826
|
+
mkdirSync(dirname(logFile), {
|
|
823
827
|
recursive: true
|
|
824
828
|
});
|
|
825
|
-
const logFile = join(logsDir, fileName);
|
|
826
829
|
const writeStream = createWriteStream(logFile);
|
|
827
|
-
|
|
830
|
+
const logger = new Console(writeStream);
|
|
831
|
+
logger.dispose = () => {
|
|
832
|
+
writeStream.end();
|
|
833
|
+
};
|
|
834
|
+
return logger;
|
|
828
835
|
};
|
|
829
836
|
|
|
830
837
|
// TODO disable logging via environment variable, don't enable logging during tests
|
|
831
838
|
|
|
832
|
-
const state$
|
|
839
|
+
const state$6 = {
|
|
833
840
|
console: undefined
|
|
834
841
|
};
|
|
835
842
|
const createConsole = () => {
|
|
836
843
|
return createFileLogger('log-main-process.txt');
|
|
837
844
|
};
|
|
838
|
-
const getOrCreateLogger
|
|
839
|
-
state$
|
|
840
|
-
return state$
|
|
845
|
+
const getOrCreateLogger = () => {
|
|
846
|
+
state$6.console ||= createConsole();
|
|
847
|
+
return state$6.console;
|
|
841
848
|
};
|
|
842
849
|
const info = (...args) => {
|
|
843
|
-
const logger = getOrCreateLogger
|
|
850
|
+
const logger = getOrCreateLogger();
|
|
844
851
|
logger.info(...args);
|
|
845
852
|
console.info(...args);
|
|
846
853
|
};
|
|
847
854
|
const error = (...args) => {
|
|
848
|
-
const logger = getOrCreateLogger
|
|
855
|
+
const logger = getOrCreateLogger();
|
|
849
856
|
logger.error(...args);
|
|
850
857
|
console.error(...args);
|
|
851
858
|
};
|
|
852
859
|
process.stdout.on('close', () => {
|
|
853
|
-
const logger = getOrCreateLogger
|
|
860
|
+
const logger = getOrCreateLogger();
|
|
854
861
|
logger.info('stdout closed');
|
|
855
862
|
});
|
|
856
863
|
process.stdout.on('exit', () => {
|
|
857
|
-
const logger = getOrCreateLogger
|
|
864
|
+
const logger = getOrCreateLogger();
|
|
858
865
|
logger.info('stdout exited');
|
|
859
866
|
});
|
|
860
867
|
process.stderr.on('close', () => {
|
|
861
|
-
const logger = getOrCreateLogger
|
|
868
|
+
const logger = getOrCreateLogger();
|
|
862
869
|
logger.info('stderr closed');
|
|
863
870
|
});
|
|
864
871
|
process.stderr.on('exit', () => {
|
|
865
|
-
const logger = getOrCreateLogger
|
|
872
|
+
const logger = getOrCreateLogger();
|
|
866
873
|
logger.info('stderr exited');
|
|
867
874
|
});
|
|
868
875
|
process.stdout.on('error', error => {
|
|
869
|
-
const logger = getOrCreateLogger
|
|
876
|
+
const logger = getOrCreateLogger();
|
|
870
877
|
logger.error(`[main-process] stdout error: ${error.stack}`);
|
|
871
878
|
});
|
|
872
879
|
process.stderr.on('error', error => {
|
|
873
|
-
const logger = getOrCreateLogger
|
|
880
|
+
const logger = getOrCreateLogger();
|
|
874
881
|
logger.error(`[main-process] stderr error: ${error.stack}`);
|
|
875
882
|
});
|
|
876
883
|
|
|
@@ -3428,27 +3435,27 @@ const formatUtilityProcessName = name => {
|
|
|
3428
3435
|
return camelCase(name);
|
|
3429
3436
|
};
|
|
3430
3437
|
|
|
3431
|
-
const state$
|
|
3438
|
+
const state$5 = {
|
|
3432
3439
|
all: Object.create(null)
|
|
3433
3440
|
};
|
|
3434
3441
|
const add$2 = (pid, process, name) => {
|
|
3435
3442
|
number(pid);
|
|
3436
3443
|
object(process);
|
|
3437
3444
|
string(name);
|
|
3438
|
-
state$
|
|
3445
|
+
state$5.all[pid] = {
|
|
3439
3446
|
name,
|
|
3440
3447
|
process
|
|
3441
3448
|
};
|
|
3442
3449
|
};
|
|
3443
3450
|
const remove$1 = pid => {
|
|
3444
3451
|
number(pid);
|
|
3445
|
-
delete state$
|
|
3452
|
+
delete state$5.all[pid];
|
|
3446
3453
|
};
|
|
3447
3454
|
const getAll = () => {
|
|
3448
|
-
return Object.entries(state$
|
|
3455
|
+
return Object.entries(state$5.all);
|
|
3449
3456
|
};
|
|
3450
3457
|
const getByName = name => {
|
|
3451
|
-
for (const value of Object.values(state$
|
|
3458
|
+
for (const value of Object.values(state$5.all)) {
|
|
3452
3459
|
// @ts-ignore
|
|
3453
3460
|
if (value.name === name) {
|
|
3454
3461
|
// @ts-ignore
|
|
@@ -3605,7 +3612,7 @@ const launchSharedProcess = async ({
|
|
|
3605
3612
|
return sharedProcessRpc;
|
|
3606
3613
|
};
|
|
3607
3614
|
|
|
3608
|
-
const state$
|
|
3615
|
+
const state$4 = {
|
|
3609
3616
|
/**
|
|
3610
3617
|
* @type {any}
|
|
3611
3618
|
*/
|
|
@@ -3616,14 +3623,14 @@ const getOrCreate = async ({
|
|
|
3616
3623
|
env = {},
|
|
3617
3624
|
method
|
|
3618
3625
|
}) => {
|
|
3619
|
-
if (!state$
|
|
3626
|
+
if (!state$4.promise) {
|
|
3620
3627
|
// @ts-ignore
|
|
3621
|
-
state$
|
|
3628
|
+
state$4.promise = launchSharedProcess({
|
|
3622
3629
|
env,
|
|
3623
3630
|
method
|
|
3624
3631
|
});
|
|
3625
3632
|
}
|
|
3626
|
-
return state$
|
|
3633
|
+
return state$4.promise;
|
|
3627
3634
|
};
|
|
3628
3635
|
const send$1 = async (method, ...params) => {
|
|
3629
3636
|
const rpc = await getOrCreate({
|
|
@@ -3788,14 +3795,14 @@ const createTitleBar = items => {
|
|
|
3788
3795
|
|
|
3789
3796
|
const PHASE_DEFAULT = 0;
|
|
3790
3797
|
const PHASE_SHUTDOWN = -1;
|
|
3791
|
-
const state$
|
|
3798
|
+
const state$3 = {
|
|
3792
3799
|
phase: PHASE_DEFAULT
|
|
3793
3800
|
};
|
|
3794
3801
|
const isShutDown = () => {
|
|
3795
|
-
return state$
|
|
3802
|
+
return state$3.phase === PHASE_SHUTDOWN;
|
|
3796
3803
|
};
|
|
3797
3804
|
const setShutDown = () => {
|
|
3798
|
-
state$
|
|
3805
|
+
state$3.phase = PHASE_SHUTDOWN;
|
|
3799
3806
|
};
|
|
3800
3807
|
|
|
3801
3808
|
// TODO move this function to shared process
|
|
@@ -4094,21 +4101,21 @@ const openExternal = async url => {
|
|
|
4094
4101
|
await shell.openExternal(url);
|
|
4095
4102
|
};
|
|
4096
4103
|
|
|
4097
|
-
const state$
|
|
4104
|
+
const state$2 = {
|
|
4098
4105
|
canceled: Object.create(null),
|
|
4099
4106
|
fallThroughKeyBindings: [],
|
|
4100
4107
|
views: Object.create(null)
|
|
4101
4108
|
};
|
|
4102
4109
|
const add$1 = (id, browserWindow, view) => {
|
|
4103
4110
|
// state
|
|
4104
|
-
state$
|
|
4111
|
+
state$2.views[id] = {
|
|
4105
4112
|
browserWindow,
|
|
4106
4113
|
view
|
|
4107
4114
|
};
|
|
4108
4115
|
};
|
|
4109
4116
|
const hasWebContents = id => {
|
|
4110
4117
|
number(id);
|
|
4111
|
-
return id in state$
|
|
4118
|
+
return id in state$2.views;
|
|
4112
4119
|
};
|
|
4113
4120
|
/**
|
|
4114
4121
|
*
|
|
@@ -4116,19 +4123,19 @@ const hasWebContents = id => {
|
|
|
4116
4123
|
* @returns {{browserWindow: Electron.BrowserWindow, view: Electron.WebContentsView}}
|
|
4117
4124
|
*/
|
|
4118
4125
|
const get$3 = id => {
|
|
4119
|
-
return state$
|
|
4126
|
+
return state$2.views[id];
|
|
4120
4127
|
};
|
|
4121
4128
|
const remove = id => {
|
|
4122
|
-
delete state$
|
|
4129
|
+
delete state$2.views[id];
|
|
4123
4130
|
};
|
|
4124
4131
|
const setFallthroughKeyBindings = fallthroughKeyBindings => {
|
|
4125
|
-
state$
|
|
4132
|
+
state$2.fallThroughKeyBindings = fallthroughKeyBindings;
|
|
4126
4133
|
};
|
|
4127
4134
|
const getFallthroughKeyBindings = () => {
|
|
4128
|
-
return state$
|
|
4135
|
+
return state$2.fallThroughKeyBindings;
|
|
4129
4136
|
};
|
|
4130
4137
|
const setCanceled = id => {
|
|
4131
|
-
state$
|
|
4138
|
+
state$2.canceled[id] = true;
|
|
4132
4139
|
};
|
|
4133
4140
|
|
|
4134
4141
|
const shouldAllowNavigation = webContentsId => {
|
|
@@ -4831,20 +4838,20 @@ const createElectronSession = () => {
|
|
|
4831
4838
|
return session;
|
|
4832
4839
|
};
|
|
4833
4840
|
|
|
4834
|
-
const state$
|
|
4841
|
+
const state$1 = {
|
|
4835
4842
|
session: undefined
|
|
4836
4843
|
};
|
|
4837
4844
|
const has = () => {
|
|
4838
|
-
return Boolean(state$
|
|
4845
|
+
return Boolean(state$1.session);
|
|
4839
4846
|
};
|
|
4840
4847
|
const get$2 = () => {
|
|
4841
|
-
if (!state$
|
|
4848
|
+
if (!state$1.session) {
|
|
4842
4849
|
throw new Error('session is not defined');
|
|
4843
4850
|
}
|
|
4844
|
-
return state$
|
|
4851
|
+
return state$1.session;
|
|
4845
4852
|
};
|
|
4846
4853
|
const set$1 = value => {
|
|
4847
|
-
state$
|
|
4854
|
+
state$1.session = value;
|
|
4848
4855
|
};
|
|
4849
4856
|
|
|
4850
4857
|
const create$2 = rpc => {
|
|
@@ -4902,12 +4909,8 @@ class WindowLoadError extends VError {
|
|
|
4902
4909
|
}
|
|
4903
4910
|
}
|
|
4904
4911
|
|
|
4905
|
-
const
|
|
4906
|
-
|
|
4907
|
-
};
|
|
4908
|
-
const getOrCreateLogger = () => {
|
|
4909
|
-
state$1.console ||= createFileLogger('log-window.txt');
|
|
4910
|
-
return state$1.console;
|
|
4912
|
+
const getLogFileName = (windowId, now = Date.now()) => {
|
|
4913
|
+
return `${windowId}/${now}.txt`;
|
|
4911
4914
|
};
|
|
4912
4915
|
const formatMessage = ({
|
|
4913
4916
|
level,
|
|
@@ -4924,10 +4927,13 @@ const formatMessage = ({
|
|
|
4924
4927
|
timestamp: new Date().toISOString()
|
|
4925
4928
|
});
|
|
4926
4929
|
};
|
|
4927
|
-
const addListener = (webContents, logger =
|
|
4930
|
+
const addListener = (windowId, webContents, logger = createFileLogger(getLogFileName(windowId))) => {
|
|
4928
4931
|
webContents.on('console-message', event => {
|
|
4929
4932
|
logger.log(formatMessage(event));
|
|
4930
4933
|
});
|
|
4934
|
+
webContents.on('destroyed', () => {
|
|
4935
|
+
logger.dispose?.();
|
|
4936
|
+
});
|
|
4931
4937
|
};
|
|
4932
4938
|
|
|
4933
4939
|
// TODO impossible to test these methods
|
|
@@ -4973,7 +4979,7 @@ const createAppWindow = async (windowOptions, parsedArgs, workingDirectory, titl
|
|
|
4973
4979
|
}
|
|
4974
4980
|
});
|
|
4975
4981
|
mark(DidCreateCodeWindow);
|
|
4976
|
-
addListener(window.webContents);
|
|
4982
|
+
addListener(window.id, window.webContents);
|
|
4977
4983
|
addDevDiagnostics(window);
|
|
4978
4984
|
const handleReadyToShow = () => {
|
|
4979
4985
|
// due to electron bug, zoom level needs to be set here,
|