@lvce-editor/main-process 4.7.0 → 4.9.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.
@@ -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$s = (method, params) => {
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$r = (id, method, params) => {
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$q = () => {
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$q();
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$r(id, method, params);
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$s(method, params);
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$p = async ({
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$p
3258
+ create: create$q
3258
3259
  };
3259
- const create$n = async ({
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$n
3289
+ create: create$o
3289
3290
  };
3290
- const create$m = async ({
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$m
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
- // @ts-ignore
4002
- void openExternal$1(url);
3994
+ void openExternal(url);
4003
3995
  return {
4004
3996
  action: Deny
4005
3997
  };
@@ -4222,6 +4214,15 @@ const getRelativePath = url => {
4222
4214
  const relative = url.slice(scheme.length + 4);
4223
4215
  return relative;
4224
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
+ };
4225
4226
  const getElectronFileResponseConfig = async (url, request) => {
4226
4227
  const parsedConfig = getOrCreateConfig();
4227
4228
  const {
@@ -4232,13 +4233,13 @@ const getElectronFileResponseConfig = async (url, request) => {
4232
4233
  if (relative.startsWith('/remote')) {
4233
4234
  return getElectronFileResponseIpc(url, request);
4234
4235
  }
4235
- const actual = relative === '/' ? '/index.html' : relative;
4236
+ const actual = getActualPath(relative);
4236
4237
  const match = files[actual];
4237
4238
  if (match === undefined) {
4238
4239
  return getNotFoundResponse();
4239
4240
  }
4240
4241
  const responseHeaders = headers[match];
4241
- const absolutePath = join$1(root, 'static', actual);
4242
+ const absolutePath = getAbsolutePath(match);
4242
4243
  if (!existsSync(absolutePath)) {
4243
4244
  return getNotFoundResponse();
4244
4245
  }
@@ -4252,18 +4253,9 @@ const getElectronFileResponse = async (url, request) => {
4252
4253
  return getElectronFileResponseConfig(url, request);
4253
4254
  };
4254
4255
 
4255
- /**
4256
- *
4257
- * @param {Headers} headers
4258
- */
4259
4256
  const serializeRequestHeaders = headers => {
4260
4257
  return Object.fromEntries(headers);
4261
4258
  };
4262
-
4263
- /**
4264
- *
4265
- * @param {Request} request
4266
- */
4267
4259
  const serializeRequest = request => {
4268
4260
  return {
4269
4261
  headers: serializeRequestHeaders(request.headers),
@@ -4271,10 +4263,6 @@ const serializeRequest = request => {
4271
4263
  };
4272
4264
  };
4273
4265
 
4274
- /**
4275
- *
4276
- * @param {GlobalRequest} request
4277
- */
4278
4266
  const handleRequest = request => {
4279
4267
  const serialized = serializeRequest(request);
4280
4268
  return getElectronFileResponse(request.url, serialized);
@@ -4841,6 +4829,25 @@ const showOpenDialog = async (title, properties) => {
4841
4829
  // TODO maybe return whole result (including canceled or not)
4842
4830
  return result.filePaths;
4843
4831
  };
4832
+ const showSaveDialog = async (title, properties) => {
4833
+ string(title);
4834
+ array(properties);
4835
+ const focusedWindow = getFocusedWindow();
4836
+ if (!focusedWindow) {
4837
+ return {
4838
+ canceled: true,
4839
+ filePath: ''
4840
+ };
4841
+ }
4842
+ const result = await Electron.dialog.showSaveDialog(focusedWindow, {
4843
+ properties,
4844
+ title
4845
+ });
4846
+ return {
4847
+ canceled: result.canceled,
4848
+ filePath: result.filePath
4849
+ };
4850
+ };
4844
4851
 
4845
4852
  /**
4846
4853
  *
@@ -4958,6 +4965,22 @@ const getBounds = () => {
4958
4965
  };
4959
4966
  };
4960
4967
 
4968
+ const normalizePath = fullPath => {
4969
+ if (fullPath.startsWith('file://')) {
4970
+ return fileURLToPath(fullPath);
4971
+ }
4972
+ return fullPath;
4973
+ };
4974
+
4975
+ const showItemInFolder = fullPath => {
4976
+ const normalized = normalizePath(fullPath);
4977
+ shell.showItemInFolder(normalized);
4978
+ };
4979
+ const openPath = async path => {
4980
+ // TODO handle error
4981
+ await shell.openPath(path);
4982
+ };
4983
+
4961
4984
  const disposeWebContents = webContents => {
4962
4985
  if (webContents.close) {
4963
4986
  // electron v22
@@ -6213,21 +6236,6 @@ const create$1 = async ({
6213
6236
  return ipc;
6214
6237
  };
6215
6238
 
6216
- const shouldOpenExternal = url => {
6217
- if (url.startsWith('http:') || url.startsWith('https:')) {
6218
- return true;
6219
- }
6220
- return false;
6221
- };
6222
-
6223
- const openExternal = async url => {
6224
- string(url);
6225
- if (!shouldOpenExternal(url)) {
6226
- throw new VError(`only http or https urls are allowed`);
6227
- }
6228
- await shell.openExternal(url);
6229
- };
6230
-
6231
6239
  const Dash = '-';
6232
6240
  const Space = ' ';
6233
6241
 
@@ -6357,6 +6365,7 @@ const commandMap = {
6357
6365
  'ElectronDeveloper.getPerformanceEntries': getPerformanceEntries,
6358
6366
  'ElectronDialog.showMessageBox': showMessageBox,
6359
6367
  'ElectronDialog.showOpenDialog': showOpenDialog,
6368
+ 'ElectronDialog.showSaveDialog': showSaveDialog,
6360
6369
  'ElectronNet.getJson': getJson,
6361
6370
  'ElectronNetLog.startLogging': startLogging,
6362
6371
  'ElectronNetLog.stopLogging': stopLogging,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "4.7.0",
3
+ "version": "4.9.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.0.0"
17
+ "electron": "40.1.0"
18
18
  },
19
19
  "engines": {
20
20
  "node": ">=22"