@lvce-editor/main-process 3.0.0 → 3.1.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.
@@ -4,15 +4,15 @@ import process$1 from 'node:process';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { inspect } from 'node:util';
6
6
  import { spawn } from 'node:child_process';
7
- import { MessageChannel } from 'node:worker_threads';
7
+ import { Console } from 'node:console';
8
8
  import { createWriteStream, readFileSync } from 'node:fs';
9
+ import { tmpdir, homedir } from 'node:os';
9
10
  import * as NodePath from 'node:path';
10
11
  import { dirname } from 'node:path';
11
12
  import require$$1 from 'tty';
12
13
  import require$$1$1 from 'util';
13
14
  import require$$0 from 'os';
14
- import { tmpdir, homedir } from 'node:os';
15
- import { Console } from 'node:console';
15
+ import { MessageChannel } from 'node:worker_threads';
16
16
 
17
17
  function escapeStringRegexp(string) {
18
18
  if (typeof string !== 'string') {
@@ -779,7 +779,7 @@ const getNewLineIndex$2 = (string, startIndex = undefined) => {
779
779
 
780
780
  // TODO disable logging via environment variable, don't enable logging during tests
781
781
 
782
- const state$7 = {
782
+ const state$6 = {
783
783
  console: undefined
784
784
  };
785
785
  const createConsole = () => {
@@ -789,8 +789,8 @@ const createConsole = () => {
789
789
  return logger;
790
790
  };
791
791
  const getOrCreateLogger = () => {
792
- state$7.console ||= createConsole();
793
- return state$7.console;
792
+ state$6.console ||= createConsole();
793
+ return state$6.console;
794
794
  };
795
795
  const info = (...args) => {
796
796
  const logger = getOrCreateLogger();
@@ -2331,7 +2331,7 @@ const IpcParentWithElectronMessagePort$1 = {
2331
2331
  signal: signal$2,
2332
2332
  wrap: wrap$7
2333
2333
  };
2334
- const Exit$1 = 1;
2334
+ const Exit = 1;
2335
2335
  const Error$2 = 2;
2336
2336
  const Message$1 = 3;
2337
2337
  const getFirstUtilityProcessEvent = async utilityProcess => {
@@ -2366,7 +2366,7 @@ const getFirstUtilityProcessEvent = async utilityProcess => {
2366
2366
  };
2367
2367
  const handleExit = event => {
2368
2368
  cleanup({
2369
- type: Exit$1,
2369
+ type: Exit,
2370
2370
  event,
2371
2371
  stdout,
2372
2372
  stderr
@@ -2421,7 +2421,7 @@ const create$6 = async ({
2421
2421
  stdout,
2422
2422
  stderr
2423
2423
  } = await getFirstUtilityProcessEvent(childProcess);
2424
- if (type === Exit$1) {
2424
+ if (type === Exit) {
2425
2425
  throw new IpcError(`Utility process exited before ipc connection was established`, stdout, stderr);
2426
2426
  }
2427
2427
  // @ts-ignore
@@ -2535,7 +2535,7 @@ const getFirstNodeChildProcessEvent = async childProcess => {
2535
2535
  };
2536
2536
  const handleExit = event => {
2537
2537
  cleanup({
2538
- type: Exit$1,
2538
+ type: Exit,
2539
2539
  event,
2540
2540
  stdout,
2541
2541
  stderr
@@ -2590,7 +2590,7 @@ const create$2$2 = async ({
2590
2590
  event,
2591
2591
  stderr
2592
2592
  } = await getFirstNodeChildProcessEvent(childProcess);
2593
- if (type === Exit$1) {
2593
+ if (type === Exit) {
2594
2594
  throw new ChildProcessError(stderr);
2595
2595
  }
2596
2596
  if (type === Error$2) {
@@ -2654,7 +2654,7 @@ const fixNodeWorkerParameters = value => {
2654
2654
  const getFirstNodeWorkerEvent = worker => {
2655
2655
  return getFirstEvent(worker, {
2656
2656
  message: Message$1,
2657
- exit: Exit$1,
2657
+ exit: Exit,
2658
2658
  error: Error$2
2659
2659
  });
2660
2660
  };
@@ -2688,7 +2688,7 @@ const create$1$2 = async ({
2688
2688
  type,
2689
2689
  event
2690
2690
  } = await getFirstNodeWorkerEvent(worker);
2691
- if (type === Exit$1) {
2691
+ if (type === Exit) {
2692
2692
  throw new IpcError(`Worker exited before ipc connection was established`);
2693
2693
  }
2694
2694
  if (type === Error$2) {
@@ -2934,7 +2934,7 @@ const resolve = (id, response) => {
2934
2934
  fn(response);
2935
2935
  remove$2(id);
2936
2936
  };
2937
- const E_COMMAND_NOT_FOUND$1 = 'E_COMMAND_NOT_FOUND';
2937
+ const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
2938
2938
  const getErrorType = prettyError => {
2939
2939
  if (prettyError && prettyError.type) {
2940
2940
  return prettyError.type;
@@ -2956,7 +2956,7 @@ const getStack = prettyError => {
2956
2956
  return stackString;
2957
2957
  };
2958
2958
  const getErrorProperty = (error, prettyError) => {
2959
- if (error && error.code === E_COMMAND_NOT_FOUND$1) {
2959
+ if (error && error.code === E_COMMAND_NOT_FOUND) {
2960
2960
  return {
2961
2961
  code: MethodNotFound,
2962
2962
  message: error.message,
@@ -3112,14 +3112,14 @@ const invokeAndTransfer$1 = (ipc, method, ...params) => {
3112
3112
  return invokeHelper(ipc, method, params, true);
3113
3113
  };
3114
3114
 
3115
- let CommandNotFoundError$1 = class CommandNotFoundError extends Error {
3115
+ class CommandNotFoundError extends Error {
3116
3116
  constructor(command) {
3117
3117
  super(`Command not found ${command}`);
3118
3118
  this.name = 'CommandNotFoundError';
3119
3119
  }
3120
- };
3120
+ }
3121
3121
  const commands = Object.create(null);
3122
- const register$1 = commandMap => {
3122
+ const register = commandMap => {
3123
3123
  Object.assign(commands, commandMap);
3124
3124
  };
3125
3125
  const getCommand = key => {
@@ -3128,7 +3128,7 @@ const getCommand = key => {
3128
3128
  const execute$1 = (command, ...args) => {
3129
3129
  const fn = getCommand(command);
3130
3130
  if (!fn) {
3131
- throw new CommandNotFoundError$1(command);
3131
+ throw new CommandNotFoundError(command);
3132
3132
  }
3133
3133
  return fn(...args);
3134
3134
  };
@@ -3191,7 +3191,7 @@ const create$k = async ({
3191
3191
  requiresSocket
3192
3192
  }) => {
3193
3193
  // TODO create a commandMap per rpc instance
3194
- register$1(commandMap);
3194
+ register(commandMap);
3195
3195
  const ipc = await listen$1(IpcChildWithElectronMessagePort$1, {
3196
3196
  messagePort
3197
3197
  });
@@ -3216,7 +3216,7 @@ const create$i = async ({
3216
3216
  requiresSocket
3217
3217
  }) => {
3218
3218
  // TODO create a commandMap per rpc instance
3219
- register$1(commandMap);
3219
+ register(commandMap);
3220
3220
  const rawIpc = await IpcParentWithElectronUtilityProcess$1$1.create({
3221
3221
  env,
3222
3222
  argv,
@@ -3243,7 +3243,7 @@ const create$h = async ({
3243
3243
  requiresSocket
3244
3244
  }) => {
3245
3245
  // TODO create a commandMap per rpc instance
3246
- register$1(commandMap);
3246
+ register(commandMap);
3247
3247
  const ipc = IpcChildWithRendererProcess2$1.wrap(webContents);
3248
3248
  if (requiresSocket) {
3249
3249
  // @ts-ignore
@@ -3411,7 +3411,7 @@ const launchSharedProcess = async ({
3411
3411
  return sharedProcessRpc;
3412
3412
  };
3413
3413
 
3414
- const state$6 = {
3414
+ const state$5 = {
3415
3415
  /**
3416
3416
  * @type {any}
3417
3417
  */
@@ -3422,14 +3422,14 @@ const getOrCreate = async ({
3422
3422
  env = {},
3423
3423
  method
3424
3424
  }) => {
3425
- if (!state$6.promise) {
3425
+ if (!state$5.promise) {
3426
3426
  // @ts-ignore
3427
- state$6.promise = launchSharedProcess({
3427
+ state$5.promise = launchSharedProcess({
3428
3428
  env,
3429
3429
  method
3430
3430
  });
3431
3431
  }
3432
- return state$6.promise;
3432
+ return state$5.promise;
3433
3433
  };
3434
3434
  const send$1 = async (method, ...params) => {
3435
3435
  const rpc = await getOrCreate({
@@ -4557,14 +4557,14 @@ const createTitleBar = items => {
4557
4557
 
4558
4558
  const PHASE_DEFAULT = 0;
4559
4559
  const PHASE_SHUTDOWN = -1;
4560
- const state$5 = {
4560
+ const state$4 = {
4561
4561
  phase: PHASE_DEFAULT
4562
4562
  };
4563
4563
  const isShutDown = () => {
4564
- return state$5.phase === PHASE_SHUTDOWN;
4564
+ return state$4.phase === PHASE_SHUTDOWN;
4565
4565
  };
4566
4566
  const setShutDown = () => {
4567
- state$5.phase = PHASE_SHUTDOWN;
4567
+ state$4.phase = PHASE_SHUTDOWN;
4568
4568
  };
4569
4569
 
4570
4570
  // TODO move this function to shared process
@@ -4869,21 +4869,21 @@ const BeforeInputEvent = 'before-input-event';
4869
4869
  const Allow = 'allow';
4870
4870
  const Deny = 'deny';
4871
4871
 
4872
- const state$4 = {
4872
+ const state$3 = {
4873
4873
  canceled: Object.create(null),
4874
4874
  fallThroughKeyBindings: [],
4875
4875
  views: Object.create(null)
4876
4876
  };
4877
4877
  const add$1 = (id, browserWindow, view) => {
4878
4878
  // state
4879
- state$4.views[id] = {
4879
+ state$3.views[id] = {
4880
4880
  browserWindow,
4881
4881
  view
4882
4882
  };
4883
4883
  };
4884
4884
  const hasWebContents = id => {
4885
4885
  number(id);
4886
- return id in state$4.views;
4886
+ return id in state$3.views;
4887
4887
  };
4888
4888
  /**
4889
4889
  *
@@ -4891,19 +4891,19 @@ const hasWebContents = id => {
4891
4891
  * @returns {{browserWindow: Electron.BrowserWindow, view: Electron.WebContentsView}}
4892
4892
  */
4893
4893
  const get$3 = id => {
4894
- return state$4.views[id];
4894
+ return state$3.views[id];
4895
4895
  };
4896
4896
  const remove$1 = id => {
4897
- delete state$4.views[id];
4897
+ delete state$3.views[id];
4898
4898
  };
4899
4899
  const setFallthroughKeyBindings = fallthroughKeyBindings => {
4900
- state$4.fallThroughKeyBindings = fallthroughKeyBindings;
4900
+ state$3.fallThroughKeyBindings = fallthroughKeyBindings;
4901
4901
  };
4902
4902
  const getFallthroughKeyBindings = () => {
4903
- return state$4.fallThroughKeyBindings;
4903
+ return state$3.fallThroughKeyBindings;
4904
4904
  };
4905
4905
  const setCanceled = id => {
4906
- state$4.canceled[id] = true;
4906
+ state$3.canceled[id] = true;
4907
4907
  };
4908
4908
 
4909
4909
  const shouldAllowNavigation = webContentsId => {
@@ -5065,197 +5065,6 @@ const {
5065
5065
  argv
5066
5066
  } = process;
5067
5067
 
5068
- const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
5069
- const E_MODULE_NOT_FOUND = 'E_MODULE_NOT_FOUND';
5070
-
5071
- class CommandNotFoundError extends Error {
5072
- constructor(id) {
5073
- super(`command ${id} not found`);
5074
- this.name = 'CommandNotFoundError';
5075
- // @ts-ignore
5076
- this.code = E_COMMAND_NOT_FOUND;
5077
- }
5078
- }
5079
-
5080
- const App = 1;
5081
- const AppWindow = 2;
5082
- const Beep = 3;
5083
- const Developer = 4;
5084
- const Dialog = 5;
5085
- const ElectronWindowProcessExplorer = 6;
5086
- const Window = 7;
5087
- const ElectronShell = 8;
5088
- const ElectronPowerSaveBlocker = 9;
5089
- const ElectronSafeStorage = 10;
5090
- const ElectronContentTracing = 11;
5091
- const ElectronNetLog = 12;
5092
- const ElectronBrowserView = 13;
5093
- const ElectronBrowserViewQuickPick = 14;
5094
- const ElectronContextMenu = 16;
5095
- const ElectronClipBoard = 17;
5096
- const ElectronApplicationMenu = 18;
5097
- const Process = 19;
5098
- const ElectronNet = 20;
5099
- const ElectronBrowserViewSuggestions = 21;
5100
- const CreatePidMap = 22;
5101
- const OpenExternal$1 = 23;
5102
- const Platform = 25;
5103
- const GetWindowId = 26;
5104
- const DesktopCapturer = 27;
5105
- const Trash = 28;
5106
- const IpcParent = 29;
5107
- const Crash = 30;
5108
- const Exit = 31;
5109
- const ElectronScreen = 32;
5110
- const TemporaryMessagePort = 34;
5111
- const ElectronWebContents = 35;
5112
- const ElectronWebContentsView = 36;
5113
- const ElectronWebContentsViewFunctions = 37;
5114
- const CreateMessagePort = 38;
5115
- const HandleElectronMessagePort = 39;
5116
- const ElectronSession = 40;
5117
-
5118
- const getPrefix = commandId => {
5119
- return commandId.slice(0, commandId.indexOf('.'));
5120
- };
5121
- const getModuleId = commandId => {
5122
- const prefix = getPrefix(commandId);
5123
- switch (prefix) {
5124
- case 'App':
5125
- case 'ElectronApp':
5126
- return App;
5127
- case 'AppWindow':
5128
- return AppWindow;
5129
- case 'Beep':
5130
- return Beep;
5131
- case 'Crash':
5132
- return Crash;
5133
- case 'CreateMessagePort':
5134
- return CreateMessagePort;
5135
- case 'CreatePidMap':
5136
- return CreatePidMap;
5137
- case 'DesktopCapturer':
5138
- return DesktopCapturer;
5139
- case 'ElectronApplicationMenu':
5140
- return ElectronApplicationMenu;
5141
- case 'ElectronBeep':
5142
- return Beep;
5143
- case 'ElectronBrowserView':
5144
- return ElectronBrowserView;
5145
- case 'ElectronBrowserViewQuickPick':
5146
- return ElectronBrowserViewQuickPick;
5147
- case 'ElectronBrowserViewSuggestions':
5148
- return ElectronBrowserViewSuggestions;
5149
- case 'ElectronClipBoard':
5150
- return ElectronClipBoard;
5151
- case 'ElectronContentTracing':
5152
- return ElectronContentTracing;
5153
- case 'ElectronContextMenu':
5154
- return ElectronContextMenu;
5155
- case 'ElectronDeveloper':
5156
- return Developer;
5157
- case 'ElectronDialog':
5158
- return Dialog;
5159
- case 'ElectronNet':
5160
- return ElectronNet;
5161
- case 'ElectronNetLog':
5162
- return ElectronNetLog;
5163
- case 'ElectronPowerSaveBlocker':
5164
- return ElectronPowerSaveBlocker;
5165
- case 'ElectronSafeStorage':
5166
- return ElectronSafeStorage;
5167
- case 'ElectronScreen':
5168
- return ElectronScreen;
5169
- case 'ElectronSession':
5170
- return ElectronSession;
5171
- case 'ElectronShell':
5172
- return ElectronShell;
5173
- case 'ElectronWebContents':
5174
- return ElectronWebContents;
5175
- case 'ElectronWebContentsView':
5176
- return ElectronWebContentsView;
5177
- case 'ElectronWebContentsViewFunctions':
5178
- return ElectronWebContentsViewFunctions;
5179
- case 'ElectronWindow':
5180
- return Window;
5181
- case 'ElectronWindowProcessExplorer':
5182
- return ElectronWindowProcessExplorer;
5183
- case 'Exit':
5184
- return Exit;
5185
- case 'GetWindowId':
5186
- return GetWindowId;
5187
- case 'HandleElectronMessagePort':
5188
- return HandleElectronMessagePort;
5189
- case 'IpcParent':
5190
- return IpcParent;
5191
- case 'OpenExternal':
5192
- return OpenExternal$1;
5193
- case 'Platform':
5194
- return Platform;
5195
- case 'Process':
5196
- return Process;
5197
- case 'TemporaryMessagePort':
5198
- return TemporaryMessagePort;
5199
- case 'Trash':
5200
- return Trash;
5201
- default:
5202
- throw new CommandNotFoundError(commandId);
5203
- }
5204
- };
5205
-
5206
- const state$3 = {
5207
- commands: Object.create(null),
5208
- async load(moduleId) {},
5209
- pendingModules: Object.create(null)
5210
- };
5211
- const initializeModule = module => {
5212
- if (module.Commands) {
5213
- for (const [key, value] of Object.entries(module.Commands)) {
5214
- if (module.name) {
5215
- const actualKey = `${module.name}.${key}`;
5216
- register(actualKey, value);
5217
- } else {
5218
- register(key, value);
5219
- }
5220
- }
5221
- return;
5222
- }
5223
- throw new Error(`module ${module.name || '<unnamed module>'} is missing commands`);
5224
- };
5225
- const getOrLoadModule = moduleId => {
5226
- if (!state$3.pendingModules[moduleId]) {
5227
- const importPromise = state$3.load(moduleId);
5228
- state$3.pendingModules[moduleId] = importPromise.then(initializeModule);
5229
- }
5230
- return state$3.pendingModules[moduleId];
5231
- };
5232
- const loadCommand = command => getOrLoadModule(getModuleId(command));
5233
- const register = (commandId, listener) => {
5234
- state$3.commands[commandId] = listener;
5235
- };
5236
- const hasThrown = new Set();
5237
- const loadThenExecute = async (command, ...args) => {
5238
- await loadCommand(command);
5239
- // TODO can skip then block in prod (only to prevent endless loop in dev)
5240
- if (!(command in state$3.commands)) {
5241
- if (hasThrown.has(command)) {
5242
- return;
5243
- }
5244
- hasThrown.add(command);
5245
- throw new Error(`Command did not register "${command}"`);
5246
- }
5247
- return execute(command, ...args);
5248
- };
5249
- const execute = (command, ...args) => {
5250
- if (command in state$3.commands) {
5251
- return state$3.commands[command](...args);
5252
- }
5253
- return loadThenExecute(command, ...args);
5254
- };
5255
- const setLoad = load => {
5256
- state$3.load = load;
5257
- };
5258
-
5259
5068
  const ClipBoardRead = 'clipboard-read';
5260
5069
  const ClipBoardSanitizedWrite = 'clipboard-sanitized-write';
5261
5070
  const FullScreen = 'fullscreen';
@@ -5704,6 +5513,105 @@ const stopRecording = () => {
5704
5513
  return contentTracing.stopRecording();
5705
5514
  };
5706
5515
 
5516
+ const withResolvers = () => {
5517
+ /**
5518
+ * @type {any}
5519
+ */
5520
+ let _resolve;
5521
+ /**
5522
+ * @type {any}
5523
+ */
5524
+ let _reject;
5525
+ const promise = new Promise((resolve, reject) => {
5526
+ _resolve = resolve;
5527
+ _reject = reject;
5528
+ });
5529
+ return {
5530
+ promise,
5531
+ reject: _reject,
5532
+ resolve: _resolve
5533
+ };
5534
+ };
5535
+
5536
+ const getElectronCallbacks = () => {
5537
+ const {
5538
+ promise,
5539
+ resolve
5540
+ } = withResolvers();
5541
+ const handleClick = menuItem => {
5542
+ resolve({
5543
+ data: menuItem,
5544
+ type: 'click'
5545
+ });
5546
+ };
5547
+ const handleClose = () => {
5548
+ resolve({
5549
+ data: undefined,
5550
+ type: 'close'
5551
+ });
5552
+ };
5553
+ return {
5554
+ handleClick,
5555
+ handleClose,
5556
+ promise
5557
+ };
5558
+ };
5559
+
5560
+ const getElectronMenuItems = (menuItems, click) => {
5561
+ const template = [];
5562
+ for (const menuItem of menuItems) {
5563
+ // @ts-ignore
5564
+ template.push({
5565
+ ...menuItem,
5566
+ click
5567
+ });
5568
+ }
5569
+ return template;
5570
+ };
5571
+
5572
+ const openContextMenu = async (menuItems, x, y) => {
5573
+ array(menuItems);
5574
+ number(x);
5575
+ number(y);
5576
+ const {
5577
+ handleClick,
5578
+ handleClose,
5579
+ promise
5580
+ } = getElectronCallbacks();
5581
+ const template = getElectronMenuItems(menuItems, handleClick);
5582
+ const menu = Menu.buildFromTemplate(template);
5583
+ // TODO pass window id
5584
+ const window = BrowserWindow.getFocusedWindow();
5585
+ if (!window) {
5586
+ return {
5587
+ data: undefined,
5588
+ type: 'close'
5589
+ };
5590
+ }
5591
+ menu.popup({
5592
+ callback: handleClose,
5593
+ window,
5594
+ x,
5595
+ y
5596
+ });
5597
+ const event = await promise;
5598
+ // @ts-ignore
5599
+ if (event.type === 'click') {
5600
+ return {
5601
+ // @ts-ignore
5602
+ data: event.data.label,
5603
+ type: 'click'
5604
+ };
5605
+ }
5606
+ // @ts-ignore
5607
+ if (event.type === 'close') {
5608
+ return {
5609
+ data: undefined,
5610
+ type: 'close'
5611
+ };
5612
+ }
5613
+ };
5614
+
5707
5615
  const getPerformanceEntries = () => {
5708
5616
  const entries = getEntries();
5709
5617
  const {
@@ -6992,6 +6900,13 @@ const printPrettyError = (prettyError, prefix = '') => {
6992
6900
  error(`${prefix}${prettyError.type}: ${prettyError.message}\n\n${prettyError.codeFrame}\n\n${prettyError.stack}\n`);
6993
6901
  };
6994
6902
 
6903
+ const execute = (method, ...params) => {
6904
+ const fn = commandMapRef[method];
6905
+ if (!fn) {
6906
+ throw new Error(`command not found: ${method}`);
6907
+ }
6908
+ return fn(...params);
6909
+ };
6995
6910
  const logError = (error, prettyError) => {
6996
6911
  printPrettyError(prettyError, '[main-process] ');
6997
6912
  };
@@ -7299,6 +7214,7 @@ const commandMap = {
7299
7214
  'ElectronBeep.beep': beep,
7300
7215
  'ElectronContentTracing.startRecording': startRecording,
7301
7216
  'ElectronContentTracing.stopRecording': stopRecording,
7217
+ 'ElectronContextMenu.openContextMenu': openContextMenu,
7302
7218
  'ElectronDeveloper.crashMainProcess': crashMainProcess,
7303
7219
  'ElectronDeveloper.getPerformanceEntries': getPerformanceEntries,
7304
7220
  'ElectronDialog.showMessageBox': showMessageBox,
@@ -7369,88 +7285,6 @@ const commandMap = {
7369
7285
  'Trash.trash': trash
7370
7286
  };
7371
7287
 
7372
- class ModuleNotFoundError extends Error {
7373
- constructor(id) {
7374
- super(`Module ${id} not found`);
7375
- this.name = 'ModuleNotFoundError';
7376
- // @ts-ignore
7377
- this.code = E_MODULE_NOT_FOUND;
7378
- }
7379
- }
7380
-
7381
- const load = async moduleId => {
7382
- switch (moduleId) {
7383
- case App:
7384
- return Promise.resolve().then(function () { return App_ipc; });
7385
- case AppWindow:
7386
- return Promise.resolve().then(function () { return AppWindow_ipc; });
7387
- case Beep:
7388
- return Promise.resolve().then(function () { return Beep_ipc; });
7389
- case Crash:
7390
- return Promise.resolve().then(function () { return Crash_ipc; });
7391
- case CreateMessagePort:
7392
- return Promise.resolve().then(function () { return CreateMessagePort_ipc; });
7393
- case CreatePidMap:
7394
- return Promise.resolve().then(function () { return CreatePidMap_ipc; });
7395
- case DesktopCapturer:
7396
- return Promise.resolve().then(function () { return DesktopCapturer_ipc; });
7397
- case Developer:
7398
- return Promise.resolve().then(function () { return ElectronDeveloper_ipc; });
7399
- case Dialog:
7400
- return Promise.resolve().then(function () { return ElectronDialog_ipc; });
7401
- case ElectronApplicationMenu:
7402
- return Promise.resolve().then(function () { return ElectronApplicationMenu_ipc; });
7403
- case ElectronClipBoard:
7404
- return Promise.resolve().then(function () { return ElectronClipBoard_ipc; });
7405
- case ElectronContentTracing:
7406
- return Promise.resolve().then(function () { return ElectronContentTracing_ipc; });
7407
- case ElectronContextMenu:
7408
- return Promise.resolve().then(function () { return ElectronContextMenu_ipc; });
7409
- case ElectronNet:
7410
- return Promise.resolve().then(function () { return ElectronNet_ipc; });
7411
- case ElectronNetLog:
7412
- return Promise.resolve().then(function () { return ElectronNetLog_ipc; });
7413
- case ElectronPowerSaveBlocker:
7414
- return Promise.resolve().then(function () { return ElectronPowerSaveBlocker_ipc; });
7415
- case ElectronSafeStorage:
7416
- return Promise.resolve().then(function () { return ElectronSafeStorage_ipc; });
7417
- case ElectronScreen:
7418
- return Promise.resolve().then(function () { return ElectronScreen_ipc; });
7419
- case ElectronSession:
7420
- return Promise.resolve().then(function () { return ElectronSession_ipc; });
7421
- case ElectronShell:
7422
- return Promise.resolve().then(function () { return ElectronShell_ipc; });
7423
- case ElectronWebContents:
7424
- return Promise.resolve().then(function () { return ElectronWebContents_ipc; });
7425
- case ElectronWebContentsView:
7426
- return Promise.resolve().then(function () { return ElectronWebContentsView_ipc; });
7427
- case ElectronWebContentsViewFunctions:
7428
- return Promise.resolve().then(function () { return ElectronWebContentsViewFunctions_ipc; });
7429
- case ElectronWindowProcessExplorer:
7430
- return Promise.resolve().then(function () { return ElectronWindowProcessExplorer_ipc; });
7431
- case Exit:
7432
- return Promise.resolve().then(function () { return Exit_ipc; });
7433
- case GetWindowId:
7434
- return Promise.resolve().then(function () { return GetWindowId_ipc; });
7435
- case HandleElectronMessagePort:
7436
- return Promise.resolve().then(function () { return HandleElectronMessagePort_ipc; });
7437
- case IpcParent:
7438
- return Promise.resolve().then(function () { return IpcParent_ipc; });
7439
- case OpenExternal$1:
7440
- return Promise.resolve().then(function () { return OpenExternal_ipc; });
7441
- case Process:
7442
- return Promise.resolve().then(function () { return Process_ipc; });
7443
- case TemporaryMessagePort:
7444
- return Promise.resolve().then(function () { return TemporaryMessagePort_ipc; });
7445
- case Trash:
7446
- return Promise.resolve().then(function () { return Trash_ipc; });
7447
- case Window:
7448
- return Promise.resolve().then(function () { return ElectronWindow_ipc; });
7449
- default:
7450
- throw new ModuleNotFoundError(moduleId);
7451
- }
7452
- };
7453
-
7454
7288
  const setStackTraceLimit = value => {
7455
7289
  if (Error.stackTraceLimit && Error.stackTraceLimit < value) {
7456
7290
  Error.stackTraceLimit = value;
@@ -7465,518 +7299,7 @@ const main = async () => {
7465
7299
  on$1('uncaughtExceptionMonitor', handleUncaughtExceptionMonitor);
7466
7300
  // workaround for https://github.com/electron/electron/issues/36526
7467
7301
  on$1('unhandledRejection', handleUnhandledRejection);
7468
- setLoad(load);
7469
7302
  await hydrate(isLinux, chromeUserDataPath, argv);
7470
7303
  };
7471
7304
 
7472
7305
  main();
7473
-
7474
- const name$w = 'App';
7475
- const Commands$w = {};
7476
-
7477
- const App_ipc = {
7478
- __proto__: null,
7479
- Commands: Commands$w,
7480
- name: name$w
7481
- };
7482
-
7483
- const name$v = 'AppWindow';
7484
- const Commands$v = {
7485
- createAppWindow: createAppWindow
7486
- };
7487
-
7488
- const AppWindow_ipc = {
7489
- __proto__: null,
7490
- Commands: Commands$v,
7491
- name: name$v
7492
- };
7493
-
7494
- const name$u = 'Beep';
7495
- const Commands$u = {
7496
- beep: beep$1
7497
- };
7498
-
7499
- const Beep_ipc = {
7500
- __proto__: null,
7501
- Commands: Commands$u,
7502
- name: name$u
7503
- };
7504
-
7505
- const name$t = 'Crash';
7506
- const Commands$t = {
7507
- crashMainProcess: crashMainProcess$1
7508
- };
7509
-
7510
- const Crash_ipc = {
7511
- __proto__: null,
7512
- Commands: Commands$t,
7513
- name: name$t
7514
- };
7515
-
7516
- const name$s = 'CreateMessagePort';
7517
- const Commands$s = {
7518
- createMessagePort: createMessagePort
7519
- };
7520
-
7521
- const CreateMessagePort_ipc = {
7522
- __proto__: null,
7523
- Commands: Commands$s,
7524
- name: name$s
7525
- };
7526
-
7527
- const name$r = 'CreatePidMap';
7528
- const Commands$r = {
7529
- createPidMap: createPidMap
7530
- };
7531
-
7532
- const CreatePidMap_ipc = {
7533
- __proto__: null,
7534
- Commands: Commands$r,
7535
- name: name$r
7536
- };
7537
-
7538
- const name$q = 'DesktopCapturer';
7539
- const Commands$q = {
7540
- getSources: getSources
7541
- };
7542
-
7543
- const DesktopCapturer_ipc = {
7544
- __proto__: null,
7545
- Commands: Commands$q,
7546
- name: name$q
7547
- };
7548
-
7549
- const name$p = 'ElectronDeveloper';
7550
- const Commands$p = {
7551
- crashMainProcess: crashMainProcess,
7552
- getPerformanceEntries: getPerformanceEntries
7553
- };
7554
-
7555
- const ElectronDeveloper_ipc = {
7556
- __proto__: null,
7557
- Commands: Commands$p,
7558
- name: name$p
7559
- };
7560
-
7561
- const name$o = 'ElectronDialog';
7562
- const Commands$o = {
7563
- showMessageBox: showMessageBox,
7564
- showOpenDialog: showOpenDialog
7565
- };
7566
-
7567
- const ElectronDialog_ipc = {
7568
- __proto__: null,
7569
- Commands: Commands$o,
7570
- name: name$o
7571
- };
7572
-
7573
- const name$n = 'ElectronApplicationMenu';
7574
- const Commands$n = {
7575
- setItems: setItems
7576
- };
7577
-
7578
- const ElectronApplicationMenu_ipc = {
7579
- __proto__: null,
7580
- Commands: Commands$n,
7581
- name: name$n
7582
- };
7583
-
7584
- const writeText = text => {
7585
- clipboard.writeText(text);
7586
- };
7587
-
7588
- const name$m = 'ElectronClipBoard';
7589
- const Commands$m = {
7590
- writeText: writeText
7591
- };
7592
-
7593
- const ElectronClipBoard_ipc = {
7594
- __proto__: null,
7595
- Commands: Commands$m,
7596
- name: name$m
7597
- };
7598
-
7599
- const name$l = 'ElectronContentTracing';
7600
- const Commands$l = {
7601
- startRecording: startRecording,
7602
- stopRecording: stopRecording
7603
- };
7604
-
7605
- const ElectronContentTracing_ipc = {
7606
- __proto__: null,
7607
- Commands: Commands$l,
7608
- name: name$l
7609
- };
7610
-
7611
- const withResolvers = () => {
7612
- /**
7613
- * @type {any}
7614
- */
7615
- let _resolve;
7616
- /**
7617
- * @type {any}
7618
- */
7619
- let _reject;
7620
- const promise = new Promise((resolve, reject) => {
7621
- _resolve = resolve;
7622
- _reject = reject;
7623
- });
7624
- return {
7625
- promise,
7626
- reject: _reject,
7627
- resolve: _resolve
7628
- };
7629
- };
7630
-
7631
- const getElectronCallbacks = () => {
7632
- const {
7633
- promise,
7634
- resolve
7635
- } = withResolvers();
7636
- const handleClick = menuItem => {
7637
- resolve({
7638
- data: menuItem,
7639
- type: 'click'
7640
- });
7641
- };
7642
- const handleClose = () => {
7643
- resolve({
7644
- data: undefined,
7645
- type: 'close'
7646
- });
7647
- };
7648
- return {
7649
- handleClick,
7650
- handleClose,
7651
- promise
7652
- };
7653
- };
7654
-
7655
- const getElectronMenuItems = (menuItems, click) => {
7656
- const template = [];
7657
- for (const menuItem of menuItems) {
7658
- // @ts-ignore
7659
- template.push({
7660
- ...menuItem,
7661
- click
7662
- });
7663
- }
7664
- return template;
7665
- };
7666
-
7667
- // @ts-ignore
7668
- const openContextMenu = async (menuItems, x, y) => {
7669
- array(menuItems);
7670
- number(x);
7671
- number(y);
7672
- const {
7673
- handleClick,
7674
- handleClose,
7675
- promise
7676
- } = getElectronCallbacks();
7677
- const template = getElectronMenuItems(menuItems, handleClick);
7678
- const menu = Menu.buildFromTemplate(template);
7679
- const window = BrowserWindow.getFocusedWindow();
7680
- if (!window) {
7681
- return {
7682
- data: undefined,
7683
- type: 'close'
7684
- };
7685
- }
7686
- menu.popup({
7687
- callback: handleClose,
7688
- window,
7689
- x,
7690
- y
7691
- });
7692
- const event = await promise;
7693
- // @ts-ignore
7694
- if (event.type === 'click') {
7695
- return {
7696
- // @ts-ignore
7697
- data: event.data.label,
7698
- type: 'click'
7699
- };
7700
- }
7701
- // @ts-ignore
7702
- if (event.type === 'close') {
7703
- return {
7704
- data: undefined,
7705
- type: 'close'
7706
- };
7707
- }
7708
- };
7709
-
7710
- const name$k = 'ElectronContextMenu';
7711
- const Commands$k = {
7712
- openContextMenu: openContextMenu
7713
- };
7714
-
7715
- const ElectronContextMenu_ipc = {
7716
- __proto__: null,
7717
- Commands: Commands$k,
7718
- name: name$k
7719
- };
7720
-
7721
- const name$j = 'ElectronNet';
7722
- const Commands$j = {
7723
- getJson: getJson
7724
- };
7725
-
7726
- const ElectronNet_ipc = {
7727
- __proto__: null,
7728
- Commands: Commands$j,
7729
- name: name$j
7730
- };
7731
-
7732
- const name$i = 'ElectronNetLog';
7733
- const Commands$i = {
7734
- startLogging: startLogging,
7735
- stopLogging: stopLogging
7736
- };
7737
-
7738
- const ElectronNetLog_ipc = {
7739
- __proto__: null,
7740
- Commands: Commands$i,
7741
- name: name$i
7742
- };
7743
-
7744
- const name$h = 'ElectronPowerSaveBlocker';
7745
- const Commands$h = {
7746
- start: start,
7747
- stop: stop
7748
- };
7749
-
7750
- const ElectronPowerSaveBlocker_ipc = {
7751
- __proto__: null,
7752
- Commands: Commands$h,
7753
- name: name$h
7754
- };
7755
-
7756
- const name$g = 'ElectronSafeStorage';
7757
- const Commands$g = {
7758
- decrypt: decrypt,
7759
- encrypt: encrypt,
7760
- isEncryptionAvailable: isEncryptionAvailable
7761
- };
7762
-
7763
- const ElectronSafeStorage_ipc = {
7764
- __proto__: null,
7765
- Commands: Commands$g,
7766
- name: name$g
7767
- };
7768
-
7769
- const name$f = 'ElectronScreen';
7770
- const Commands$f = {
7771
- getBounds: getBounds,
7772
- getHeight: getHeight,
7773
- getWidth: getWidth
7774
- };
7775
-
7776
- const ElectronScreen_ipc = {
7777
- __proto__: null,
7778
- Commands: Commands$f,
7779
- name: name$f
7780
- };
7781
-
7782
- const name$e = 'ElectronSession';
7783
- const Commands$e = {
7784
- registerWebviewProtocol: registerWebviewProtocol
7785
- };
7786
-
7787
- const ElectronSession_ipc = {
7788
- __proto__: null,
7789
- Commands: Commands$e,
7790
- name: name$e
7791
- };
7792
-
7793
- const name$d = 'ElectronShell';
7794
- const Commands$d = {
7795
- beep: beep$1,
7796
- openExternal: openExternal,
7797
- openPath: showItemInFolder,
7798
- showItemInFolder: showItemInFolder
7799
- };
7800
-
7801
- const ElectronShell_ipc = {
7802
- __proto__: null,
7803
- Commands: Commands$d,
7804
- name: name$d
7805
- };
7806
-
7807
- const name$c = 'ElectronWebContents';
7808
- const Commands$c = {
7809
- callFunction: callFunction,
7810
- dispose: dispose$1,
7811
- getStats: getStats$1
7812
- };
7813
-
7814
- const ElectronWebContents_ipc = {
7815
- __proto__: null,
7816
- Commands: Commands$c,
7817
- name: name$c
7818
- };
7819
-
7820
- const name$b = 'ElectronWebContentsView';
7821
- const Commands$b = {
7822
- attachEventListeners: attachEventListeners,
7823
- createWebContentsView: createWebContentsView,
7824
- disposeWebContentsView: disposeWebContentsView
7825
- };
7826
-
7827
- const ElectronWebContentsView_ipc = {
7828
- __proto__: null,
7829
- Commands: Commands$b,
7830
- name: name$b
7831
- };
7832
-
7833
- const name$a = 'ElectronWebContentsViewFunctions';
7834
- const Commands$a = {
7835
- addToWindow: addToWindow,
7836
- backward: wrapBrowserViewCommand(backward),
7837
- cancelNavigation: wrapBrowserViewCommand(cancelNavigation),
7838
- copyImageAt: wrapBrowserViewCommand(copyImageAt),
7839
- executeJavaScript: wrapBrowserViewCommand(executeJavaScript),
7840
- focus: wrapBrowserViewCommand(focus),
7841
- forward: wrapBrowserViewCommand(forward),
7842
- getDomTree: wrapBrowserViewCommand(getDomTree),
7843
- getStats: wrapBrowserViewCommand(getStats),
7844
- hide: hide,
7845
- insertCss: wrapBrowserViewCommand(insertCss),
7846
- insertJavaScript: wrapBrowserViewCommand(executeJavaScript),
7847
- inspectElement: wrapBrowserViewCommand(inspectElement),
7848
- openDevtools: wrapBrowserViewCommand(openDevtools),
7849
- reload: wrapBrowserViewCommand(reload),
7850
- resizeBrowserView: wrapBrowserViewCommand(resizeBrowserView),
7851
- setBackgroundColor: wrapBrowserViewCommand(setBackgroundColor),
7852
- setFallthroughKeyBindings: setFallThroughKeyBindings,
7853
- setIframeSrc: wrapBrowserViewCommand(setIframeSrc),
7854
- setIframeSrcFallback: wrapBrowserViewCommand(setIframeSrcFallback),
7855
- show: show
7856
- };
7857
-
7858
- const ElectronWebContentsViewFunctions_ipc = {
7859
- __proto__: null,
7860
- Commands: Commands$a,
7861
- name: name$a
7862
- };
7863
-
7864
- const name$9 = 'ElectronWindowProcessExplorer';
7865
- const Commands$9 = {
7866
- open2: open2
7867
- };
7868
-
7869
- const ElectronWindowProcessExplorer_ipc = {
7870
- __proto__: null,
7871
- Commands: Commands$9,
7872
- name: name$9
7873
- };
7874
-
7875
- const name$8 = 'Exit';
7876
- const Commands$8 = {
7877
- exit: exit
7878
- };
7879
-
7880
- const Exit_ipc = {
7881
- __proto__: null,
7882
- Commands: Commands$8,
7883
- name: name$8
7884
- };
7885
-
7886
- const name$7 = 'GetWindowId';
7887
- const Commands$7 = {
7888
- getWindowId: getWindowId
7889
- };
7890
-
7891
- const GetWindowId_ipc = {
7892
- __proto__: null,
7893
- Commands: Commands$7,
7894
- name: name$7
7895
- };
7896
-
7897
- const name$6 = 'HandleElectronMessagePort';
7898
- const Commands$6 = {
7899
- handleElectronMessagePort: handleElectronMessagePort
7900
- };
7901
-
7902
- const HandleElectronMessagePort_ipc = {
7903
- __proto__: null,
7904
- Commands: Commands$6,
7905
- name: name$6
7906
- };
7907
-
7908
- const name$5 = 'IpcParent';
7909
- const Commands$5 = {
7910
- create: create$1
7911
- };
7912
-
7913
- const IpcParent_ipc = {
7914
- __proto__: null,
7915
- Commands: Commands$5,
7916
- name: name$5
7917
- };
7918
-
7919
- const name$4 = 'OpenExternal';
7920
- const Commands$4 = {
7921
- openExternal: openExternal
7922
- };
7923
-
7924
- const OpenExternal_ipc = {
7925
- __proto__: null,
7926
- Commands: Commands$4,
7927
- name: name$4
7928
- };
7929
-
7930
- const name$3 = 'Process';
7931
- const Commands$3 = {
7932
- getArgv: getArgv,
7933
- getChromeVersion: getChromeVersion,
7934
- getElectronVersion: getElectronVersion,
7935
- getNodeVersion: getNodeVersion,
7936
- getPid: getPid,
7937
- getV8Version: getV8Version
7938
- };
7939
-
7940
- const Process_ipc = {
7941
- __proto__: null,
7942
- Commands: Commands$3,
7943
- name: name$3
7944
- };
7945
-
7946
- const name$2 = 'TemporaryMessagePort';
7947
- const Commands$2 = {
7948
- createPortTuple: createPortTuple,
7949
- dispose: dispose,
7950
- sendTo: sendTo
7951
- };
7952
-
7953
- const TemporaryMessagePort_ipc = {
7954
- __proto__: null,
7955
- Commands: Commands$2,
7956
- name: name$2
7957
- };
7958
-
7959
- const name$1 = 'Trash';
7960
- const Commands$1 = {
7961
- trash: trash
7962
- };
7963
-
7964
- const Trash_ipc = {
7965
- __proto__: null,
7966
- Commands: Commands$1,
7967
- name: name$1
7968
- };
7969
-
7970
- const name = 'ElectronWindow';
7971
- const Commands = {
7972
- executeWebContentsFunction: executeWebContentsFunction,
7973
- executeWindowFunction: executeWindowFunction,
7974
- getFocusedWindowId: getFocusedWindowId,
7975
- getZoom: getZoom
7976
- };
7977
-
7978
- const ElectronWindow_ipc = {
7979
- __proto__: null,
7980
- Commands,
7981
- name
7982
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"