@lvce-editor/main-process 4.6.0 → 4.8.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 +85 -88
- package/package.json +2 -2
package/dist/mainProcessMain.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
import { inspect } from 'node:util';
|
|
6
6
|
import { spawn } from 'node:child_process';
|
|
7
7
|
import { Console } from 'node:console';
|
|
8
|
-
import { createWriteStream, readFileSync, existsSync } from 'node:fs';
|
|
8
|
+
import { createWriteStream, readFileSync, openAsBlob, existsSync } from 'node:fs';
|
|
9
9
|
import { tmpdir, homedir } from 'node:os';
|
|
10
10
|
import * as NodePath from 'node:path';
|
|
11
11
|
import { dirname, join as join$1 } from 'node:path';
|
|
@@ -1215,7 +1215,7 @@ function requireLib () {
|
|
|
1215
1215
|
}
|
|
1216
1216
|
let deprecationWarningShown = false;
|
|
1217
1217
|
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
1218
|
-
function getMarkerLines(loc, source, opts) {
|
|
1218
|
+
function getMarkerLines(loc, source, opts, startLineBaseZero) {
|
|
1219
1219
|
const startLoc = Object.assign({
|
|
1220
1220
|
column: 0,
|
|
1221
1221
|
line: -1
|
|
@@ -1225,9 +1225,9 @@ function requireLib () {
|
|
|
1225
1225
|
linesAbove = 2,
|
|
1226
1226
|
linesBelow = 3
|
|
1227
1227
|
} = opts || {};
|
|
1228
|
-
const startLine = startLoc.line;
|
|
1228
|
+
const startLine = startLoc.line - startLineBaseZero;
|
|
1229
1229
|
const startColumn = startLoc.column;
|
|
1230
|
-
const endLine = endLoc.line;
|
|
1230
|
+
const endLine = endLoc.line - startLineBaseZero;
|
|
1231
1231
|
const endColumn = endLoc.column;
|
|
1232
1232
|
let start = Math.max(startLine - (linesAbove + 1), 0);
|
|
1233
1233
|
let end = Math.min(source.length, endLine + linesBelow);
|
|
@@ -1273,19 +1273,20 @@ function requireLib () {
|
|
|
1273
1273
|
}
|
|
1274
1274
|
function codeFrameColumns(rawLines, loc, opts = {}) {
|
|
1275
1275
|
const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;
|
|
1276
|
+
const startLineBaseZero = (opts.startLine || 1) - 1;
|
|
1276
1277
|
const defs = getDefs(shouldHighlight);
|
|
1277
1278
|
const lines = rawLines.split(NEWLINE);
|
|
1278
1279
|
const {
|
|
1279
1280
|
start,
|
|
1280
1281
|
end,
|
|
1281
1282
|
markerLines
|
|
1282
|
-
} = getMarkerLines(loc, lines, opts);
|
|
1283
|
+
} = getMarkerLines(loc, lines, opts, startLineBaseZero);
|
|
1283
1284
|
const hasColumns = loc.start && typeof loc.start.column === "number";
|
|
1284
|
-
const numberMaxWidth = String(end).length;
|
|
1285
|
+
const numberMaxWidth = String(end + startLineBaseZero).length;
|
|
1285
1286
|
const highlightedLines = shouldHighlight ? highlight(rawLines) : rawLines;
|
|
1286
1287
|
let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
|
|
1287
1288
|
const number = start + 1 + index;
|
|
1288
|
-
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
|
1289
|
+
const paddedNumber = ` ${number + startLineBaseZero}`.slice(-numberMaxWidth);
|
|
1289
1290
|
const gutter = ` ${paddedNumber} |`;
|
|
1290
1291
|
const hasMarker = markerLines[number];
|
|
1291
1292
|
const lastMarkerLine = !markerLines[number + 1];
|
|
@@ -1437,7 +1438,7 @@ const cleanStack = stack => {
|
|
|
1437
1438
|
};
|
|
1438
1439
|
const Utf8 = 'utf8';
|
|
1439
1440
|
const ERR_MODULE_NOT_FOUND$1 = 'ERR_MODULE_NOT_FOUND';
|
|
1440
|
-
const getActualPath = fileUri => {
|
|
1441
|
+
const getActualPath$1 = fileUri => {
|
|
1441
1442
|
if (fileUri.startsWith('file://')) {
|
|
1442
1443
|
return fileURLToPath(fileUri);
|
|
1443
1444
|
}
|
|
@@ -1519,7 +1520,7 @@ const prepare = error => {
|
|
|
1519
1520
|
}
|
|
1520
1521
|
if (match) {
|
|
1521
1522
|
const [_, path, line, column] = match;
|
|
1522
|
-
const actualPath = getActualPath(path);
|
|
1523
|
+
const actualPath = getActualPath$1(path);
|
|
1523
1524
|
const rawLines = readFileSync(actualPath, Utf8);
|
|
1524
1525
|
const location = {
|
|
1525
1526
|
start: {
|
|
@@ -3121,14 +3122,14 @@ const execute$1 = (command, ...args) => {
|
|
|
3121
3122
|
};
|
|
3122
3123
|
|
|
3123
3124
|
const Two = '2.0';
|
|
3124
|
-
const create$
|
|
3125
|
+
const create$t = (method, params) => {
|
|
3125
3126
|
return {
|
|
3126
3127
|
jsonrpc: Two,
|
|
3127
3128
|
method,
|
|
3128
3129
|
params
|
|
3129
3130
|
};
|
|
3130
3131
|
};
|
|
3131
|
-
const create$
|
|
3132
|
+
const create$s = (id, method, params) => {
|
|
3132
3133
|
const message = {
|
|
3133
3134
|
id,
|
|
3134
3135
|
jsonrpc: Two,
|
|
@@ -3138,14 +3139,14 @@ const create$r = (id, method, params) => {
|
|
|
3138
3139
|
return message;
|
|
3139
3140
|
};
|
|
3140
3141
|
let id = 0;
|
|
3141
|
-
const create$
|
|
3142
|
+
const create$r = () => {
|
|
3142
3143
|
return ++id;
|
|
3143
3144
|
};
|
|
3144
3145
|
|
|
3145
3146
|
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
3146
3147
|
|
|
3147
3148
|
const registerPromise = map => {
|
|
3148
|
-
const id = create$
|
|
3149
|
+
const id = create$r();
|
|
3149
3150
|
const {
|
|
3150
3151
|
promise,
|
|
3151
3152
|
resolve
|
|
@@ -3163,7 +3164,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
3163
3164
|
id,
|
|
3164
3165
|
promise
|
|
3165
3166
|
} = registerPromise(callbacks);
|
|
3166
|
-
const message = create$
|
|
3167
|
+
const message = create$s(id, method, params);
|
|
3167
3168
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
3168
3169
|
ipc.sendAndTransfer(message);
|
|
3169
3170
|
} else {
|
|
@@ -3199,7 +3200,7 @@ const createRpc = ipc => {
|
|
|
3199
3200
|
* @deprecated
|
|
3200
3201
|
*/
|
|
3201
3202
|
send(method, ...params) {
|
|
3202
|
-
const message = create$
|
|
3203
|
+
const message = create$t(method, params);
|
|
3203
3204
|
ipc.send(message);
|
|
3204
3205
|
}
|
|
3205
3206
|
};
|
|
@@ -3235,7 +3236,7 @@ const listen$1 = async (module, options) => {
|
|
|
3235
3236
|
const ipc = module.wrap(rawIpc);
|
|
3236
3237
|
return ipc;
|
|
3237
3238
|
};
|
|
3238
|
-
const create$
|
|
3239
|
+
const create$q = async ({
|
|
3239
3240
|
commandMap,
|
|
3240
3241
|
messagePort,
|
|
3241
3242
|
requiresSocket
|
|
@@ -3254,9 +3255,9 @@ const create$p = async ({
|
|
|
3254
3255
|
};
|
|
3255
3256
|
const ElectronMessagePortRpcClient = {
|
|
3256
3257
|
__proto__: null,
|
|
3257
|
-
create: create$
|
|
3258
|
+
create: create$q
|
|
3258
3259
|
};
|
|
3259
|
-
const create$
|
|
3260
|
+
const create$o = async ({
|
|
3260
3261
|
argv,
|
|
3261
3262
|
commandMap,
|
|
3262
3263
|
env,
|
|
@@ -3285,9 +3286,9 @@ const create$n = async ({
|
|
|
3285
3286
|
};
|
|
3286
3287
|
const ElectronUtilityProcessRpcParent = {
|
|
3287
3288
|
__proto__: null,
|
|
3288
|
-
create: create$
|
|
3289
|
+
create: create$o
|
|
3289
3290
|
};
|
|
3290
|
-
const create$
|
|
3291
|
+
const create$n = async ({
|
|
3291
3292
|
commandMap,
|
|
3292
3293
|
requiresSocket,
|
|
3293
3294
|
webContents
|
|
@@ -3305,7 +3306,7 @@ const create$m = async ({
|
|
|
3305
3306
|
};
|
|
3306
3307
|
const ElectronWebContentsRpcClient = {
|
|
3307
3308
|
__proto__: null,
|
|
3308
|
-
create: create$
|
|
3309
|
+
create: create$n
|
|
3309
3310
|
};
|
|
3310
3311
|
|
|
3311
3312
|
const commandMapRef = Object.create(null);
|
|
@@ -3345,16 +3346,12 @@ const getEntries = () => {
|
|
|
3345
3346
|
const uiEntries = entries.map(toUiEntry);
|
|
3346
3347
|
return uiEntries;
|
|
3347
3348
|
};
|
|
3348
|
-
const clearMarks = () => {
|
|
3349
|
-
performance.clearMarks();
|
|
3350
|
-
};
|
|
3351
3349
|
const {
|
|
3352
3350
|
timeOrigin
|
|
3353
3351
|
} = performance;
|
|
3354
3352
|
|
|
3355
3353
|
const Performance = {
|
|
3356
3354
|
__proto__: null,
|
|
3357
|
-
clearMarks,
|
|
3358
3355
|
getEntries,
|
|
3359
3356
|
mark,
|
|
3360
3357
|
timeOrigin
|
|
@@ -3922,25 +3919,6 @@ const handleSecondInstance = async (event, commandLine, workingDirectory, additi
|
|
|
3922
3919
|
await handleReady(parsedArgs, workingDirectory);
|
|
3923
3920
|
};
|
|
3924
3921
|
|
|
3925
|
-
const normalizePath = fullPath => {
|
|
3926
|
-
if (fullPath.startsWith('file://')) {
|
|
3927
|
-
return fileURLToPath(fullPath);
|
|
3928
|
-
}
|
|
3929
|
-
return fullPath;
|
|
3930
|
-
};
|
|
3931
|
-
|
|
3932
|
-
const showItemInFolder = fullPath => {
|
|
3933
|
-
const normalized = normalizePath(fullPath);
|
|
3934
|
-
shell.showItemInFolder(normalized);
|
|
3935
|
-
};
|
|
3936
|
-
const openPath = async path => {
|
|
3937
|
-
// TODO handle error
|
|
3938
|
-
await shell.openPath(path);
|
|
3939
|
-
};
|
|
3940
|
-
const openExternal$1 = async url => {
|
|
3941
|
-
await shell.openExternal(url);
|
|
3942
|
-
};
|
|
3943
|
-
|
|
3944
3922
|
const ContextMenu = 'context-menu';
|
|
3945
3923
|
const WillNavigate = 'will-navigate';
|
|
3946
3924
|
const DidNavigate = 'did-navigate';
|
|
@@ -3951,6 +3929,21 @@ const BeforeInputEvent = 'before-input-event';
|
|
|
3951
3929
|
const Allow = 'allow';
|
|
3952
3930
|
const Deny = 'deny';
|
|
3953
3931
|
|
|
3932
|
+
const shouldOpenExternal = url => {
|
|
3933
|
+
if (url.startsWith('http:') || url.startsWith('https:')) {
|
|
3934
|
+
return true;
|
|
3935
|
+
}
|
|
3936
|
+
return false;
|
|
3937
|
+
};
|
|
3938
|
+
|
|
3939
|
+
const openExternal = async url => {
|
|
3940
|
+
string(url);
|
|
3941
|
+
if (!shouldOpenExternal(url)) {
|
|
3942
|
+
throw new VError(`only http or https urls are allowed`);
|
|
3943
|
+
}
|
|
3944
|
+
await shell.openExternal(url);
|
|
3945
|
+
};
|
|
3946
|
+
|
|
3954
3947
|
const state$3 = {
|
|
3955
3948
|
canceled: Object.create(null),
|
|
3956
3949
|
fallThroughKeyBindings: [],
|
|
@@ -3998,8 +3991,7 @@ const shouldAllowNavigation = webContentsId => {
|
|
|
3998
3991
|
const handleWebContentsWindowOpen = ({
|
|
3999
3992
|
url
|
|
4000
3993
|
}) => {
|
|
4001
|
-
|
|
4002
|
-
void openExternal$1(url);
|
|
3994
|
+
void openExternal(url);
|
|
4003
3995
|
return {
|
|
4004
3996
|
action: Deny
|
|
4005
3997
|
};
|
|
@@ -4187,6 +4179,23 @@ const getElectronFileResponseIpc = async (url, request) => {
|
|
|
4187
4179
|
return response;
|
|
4188
4180
|
};
|
|
4189
4181
|
|
|
4182
|
+
/* eslint-disable n/no-unsupported-features/node-builtins */
|
|
4183
|
+
const getFileResponse = async (absolutePath, headers) => {
|
|
4184
|
+
// TODO support request method head
|
|
4185
|
+
const blob = await openAsBlob(absolutePath);
|
|
4186
|
+
const response = new Response(blob, {
|
|
4187
|
+
headers,
|
|
4188
|
+
status: 200
|
|
4189
|
+
});
|
|
4190
|
+
return response;
|
|
4191
|
+
};
|
|
4192
|
+
|
|
4193
|
+
const getNotFoundResponse = () => {
|
|
4194
|
+
return new Response('Not Found', {
|
|
4195
|
+
status: 404
|
|
4196
|
+
});
|
|
4197
|
+
};
|
|
4198
|
+
|
|
4190
4199
|
let config;
|
|
4191
4200
|
const createConfig = () => {
|
|
4192
4201
|
const configPath = join$1(root, 'config.json');
|
|
@@ -4205,6 +4214,15 @@ const getRelativePath = url => {
|
|
|
4205
4214
|
const relative = url.slice(scheme.length + 4);
|
|
4206
4215
|
return relative;
|
|
4207
4216
|
};
|
|
4217
|
+
const getActualPath = relative => {
|
|
4218
|
+
const actual = relative === '/' ? '/index.html' : relative;
|
|
4219
|
+
return actual;
|
|
4220
|
+
};
|
|
4221
|
+
const getAbsolutePath = relative => {
|
|
4222
|
+
const actual = getActualPath(relative);
|
|
4223
|
+
const absolutePath = join$1(root, 'static', actual);
|
|
4224
|
+
return absolutePath;
|
|
4225
|
+
};
|
|
4208
4226
|
const getElectronFileResponseConfig = async (url, request) => {
|
|
4209
4227
|
const parsedConfig = getOrCreateConfig();
|
|
4210
4228
|
const {
|
|
@@ -4215,26 +4233,17 @@ const getElectronFileResponseConfig = async (url, request) => {
|
|
|
4215
4233
|
if (relative.startsWith('/remote')) {
|
|
4216
4234
|
return getElectronFileResponseIpc(url, request);
|
|
4217
4235
|
}
|
|
4218
|
-
const actual = relative
|
|
4236
|
+
const actual = getActualPath(relative);
|
|
4219
4237
|
const match = files[actual];
|
|
4220
4238
|
if (match === undefined) {
|
|
4221
|
-
return
|
|
4222
|
-
status: 404
|
|
4223
|
-
});
|
|
4239
|
+
return getNotFoundResponse();
|
|
4224
4240
|
}
|
|
4225
4241
|
const responseHeaders = headers[match];
|
|
4226
|
-
const absolutePath =
|
|
4242
|
+
const absolutePath = getAbsolutePath(match);
|
|
4227
4243
|
if (!existsSync(absolutePath)) {
|
|
4228
|
-
return
|
|
4229
|
-
status: 404
|
|
4230
|
-
});
|
|
4244
|
+
return getNotFoundResponse();
|
|
4231
4245
|
}
|
|
4232
|
-
|
|
4233
|
-
const response = new Response(content, {
|
|
4234
|
-
headers: responseHeaders,
|
|
4235
|
-
status: 200
|
|
4236
|
-
});
|
|
4237
|
-
return response;
|
|
4246
|
+
return getFileResponse(absolutePath, responseHeaders);
|
|
4238
4247
|
};
|
|
4239
4248
|
|
|
4240
4249
|
const getElectronFileResponse = async (url, request) => {
|
|
@@ -4244,18 +4253,9 @@ const getElectronFileResponse = async (url, request) => {
|
|
|
4244
4253
|
return getElectronFileResponseConfig(url, request);
|
|
4245
4254
|
};
|
|
4246
4255
|
|
|
4247
|
-
/**
|
|
4248
|
-
*
|
|
4249
|
-
* @param {Headers} headers
|
|
4250
|
-
*/
|
|
4251
4256
|
const serializeRequestHeaders = headers => {
|
|
4252
4257
|
return Object.fromEntries(headers);
|
|
4253
4258
|
};
|
|
4254
|
-
|
|
4255
|
-
/**
|
|
4256
|
-
*
|
|
4257
|
-
* @param {Request} request
|
|
4258
|
-
*/
|
|
4259
4259
|
const serializeRequest = request => {
|
|
4260
4260
|
return {
|
|
4261
4261
|
headers: serializeRequestHeaders(request.headers),
|
|
@@ -4263,10 +4263,6 @@ const serializeRequest = request => {
|
|
|
4263
4263
|
};
|
|
4264
4264
|
};
|
|
4265
4265
|
|
|
4266
|
-
/**
|
|
4267
|
-
*
|
|
4268
|
-
* @param {GlobalRequest} request
|
|
4269
|
-
*/
|
|
4270
4266
|
const handleRequest = request => {
|
|
4271
4267
|
const serialized = serializeRequest(request);
|
|
4272
4268
|
return getElectronFileResponse(request.url, serialized);
|
|
@@ -4950,6 +4946,22 @@ const getBounds = () => {
|
|
|
4950
4946
|
};
|
|
4951
4947
|
};
|
|
4952
4948
|
|
|
4949
|
+
const normalizePath = fullPath => {
|
|
4950
|
+
if (fullPath.startsWith('file://')) {
|
|
4951
|
+
return fileURLToPath(fullPath);
|
|
4952
|
+
}
|
|
4953
|
+
return fullPath;
|
|
4954
|
+
};
|
|
4955
|
+
|
|
4956
|
+
const showItemInFolder = fullPath => {
|
|
4957
|
+
const normalized = normalizePath(fullPath);
|
|
4958
|
+
shell.showItemInFolder(normalized);
|
|
4959
|
+
};
|
|
4960
|
+
const openPath = async path => {
|
|
4961
|
+
// TODO handle error
|
|
4962
|
+
await shell.openPath(path);
|
|
4963
|
+
};
|
|
4964
|
+
|
|
4953
4965
|
const disposeWebContents = webContents => {
|
|
4954
4966
|
if (webContents.close) {
|
|
4955
4967
|
// electron v22
|
|
@@ -6205,21 +6217,6 @@ const create$1 = async ({
|
|
|
6205
6217
|
return ipc;
|
|
6206
6218
|
};
|
|
6207
6219
|
|
|
6208
|
-
const shouldOpenExternal = url => {
|
|
6209
|
-
if (url.startsWith('http:') || url.startsWith('https:')) {
|
|
6210
|
-
return true;
|
|
6211
|
-
}
|
|
6212
|
-
return false;
|
|
6213
|
-
};
|
|
6214
|
-
|
|
6215
|
-
const openExternal = async url => {
|
|
6216
|
-
string(url);
|
|
6217
|
-
if (!shouldOpenExternal(url)) {
|
|
6218
|
-
throw new VError(`only http or https urls are allowed`);
|
|
6219
|
-
}
|
|
6220
|
-
await shell.openExternal(url);
|
|
6221
|
-
};
|
|
6222
|
-
|
|
6223
6220
|
const Dash = '-';
|
|
6224
6221
|
const Space = ' ';
|
|
6225
6222
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/main-process",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"lvce-editor",
|
|
6
6
|
"electron"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "dist/mainProcessMain.js",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"electron": "40.
|
|
17
|
+
"electron": "40.1.0"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=22"
|