@lvce-editor/main-process 6.40.0 → 6.41.1

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.
@@ -4748,14 +4748,39 @@ const create$3 = () => {
4748
4748
  let pressedAt = -1;
4749
4749
  let releasedAt = -1;
4750
4750
  let controlCode = '';
4751
- const reset = () => {
4751
+ const heldControls = new Set();
4752
+ let overlappingControls = false;
4753
+ const resetTaps = () => {
4752
4754
  pressedAt = -1;
4753
4755
  releasedAt = -1;
4754
4756
  controlCode = '';
4755
4757
  };
4758
+ const reset = () => {
4759
+ resetTaps();
4760
+ heldControls.clear();
4761
+ overlappingControls = false;
4762
+ };
4763
+ const hasOverlappingControls = (input, isControl) => {
4764
+ if (isControl && !input.isAutoRepeat) {
4765
+ if (input.type === 'keyDown') {
4766
+ if (heldControls.size > 0) overlappingControls = true;
4767
+ heldControls.add(input.code);
4768
+ } else if (input.type === 'keyUp') {
4769
+ heldControls.delete(input.code);
4770
+ }
4771
+ if (overlappingControls) {
4772
+ resetTaps();
4773
+ if (heldControls.size === 0) overlappingControls = false;
4774
+ return true;
4775
+ }
4776
+ }
4777
+ return false;
4778
+ };
4756
4779
  const accept = (input, now) => {
4757
- if (!['ControlLeft', 'ControlRight'].includes(input.code) || input.alt || input.meta || input.shift || input.isComposing) {
4758
- reset();
4780
+ const isControl = ['ControlLeft', 'ControlRight'].includes(input.code);
4781
+ if (hasOverlappingControls(input, isControl)) return false;
4782
+ if (!isControl || input.alt || input.meta || input.shift || input.isComposing) {
4783
+ resetTaps();
4759
4784
  return false;
4760
4785
  }
4761
4786
  if (input.isAutoRepeat) {
@@ -4763,19 +4788,19 @@ const create$3 = () => {
4763
4788
  }
4764
4789
  if (input.type === 'keyDown') {
4765
4790
  if (pressedAt !== -1 || controlCode !== input.code || now - releasedAt > 400) {
4766
- reset();
4791
+ resetTaps();
4767
4792
  }
4768
4793
  controlCode = input.code;
4769
4794
  pressedAt = now;
4770
4795
  return false;
4771
4796
  }
4772
4797
  if (input.type !== 'keyUp' || controlCode !== input.code || pressedAt === -1 || now - pressedAt > 250) {
4773
- reset();
4798
+ resetTaps();
4774
4799
  return false;
4775
4800
  }
4776
4801
  pressedAt = -1;
4777
4802
  if (releasedAt !== -1 && now - releasedAt <= 400) {
4778
- reset();
4803
+ resetTaps();
4779
4804
  return true;
4780
4805
  }
4781
4806
  releasedAt = now;
@@ -4791,7 +4816,7 @@ const windows = new Map();
4791
4816
  const setEnabled = (windowId, enabled) => {
4792
4817
  windows.get(windowId)?.setEnabled(enabled);
4793
4818
  };
4794
- const attach$d = (window, contents) => {
4819
+ const attach$e = (window, contents) => {
4795
4820
  windows.get(window.id)?.attach(contents);
4796
4821
  };
4797
4822
  const listen$2 = (window, rpc) => {
@@ -6442,7 +6467,7 @@ const handleWebContentsViewZoomKeyBinding = (webContentsId, input) => {
6442
6467
  };
6443
6468
 
6444
6469
  const key$a = 'before-input';
6445
- const attach$c = (webContents, listener) => {
6470
+ const attach$d = (webContents, listener) => {
6446
6471
  webContents.on(BeforeInputEvent, listener);
6447
6472
  };
6448
6473
  const detach$a = (webContents, listener) => {
@@ -6482,14 +6507,14 @@ const handler$a = (event, input, webContentsId) => {
6482
6507
 
6483
6508
  const ElectronBrowserViewEventListenerBeforeInput = {
6484
6509
  __proto__: null,
6485
- attach: attach$c,
6510
+ attach: attach$d,
6486
6511
  detach: detach$a,
6487
6512
  handler: handler$a,
6488
6513
  key: key$a
6489
6514
  };
6490
6515
 
6491
6516
  const key$9 = AudioStateChanged;
6492
- const attach$b = (webContents, listener) => {
6517
+ const attach$c = (webContents, listener) => {
6493
6518
  webContents.on(AudioStateChanged, listener);
6494
6519
  };
6495
6520
  const detach$9 = (webContents, listener) => {
@@ -6504,29 +6529,32 @@ const handler$9 = event => {
6504
6529
 
6505
6530
  const ElectronBrowserViewEventListenerAudioStateChanged = {
6506
6531
  __proto__: null,
6507
- attach: attach$b,
6532
+ attach: attach$c,
6508
6533
  detach: detach$9,
6509
6534
  handler: handler$9,
6510
6535
  key: key$9
6511
6536
  };
6512
6537
 
6513
6538
  const key$8 = 'context-menu';
6514
- const attach$a = (webContents, listener) => {
6539
+ const attach$b = (webContents, listener) => {
6515
6540
  webContents.on(ContextMenu, listener);
6516
6541
  };
6517
6542
  const detach$8 = (webContents, listener) => {
6518
6543
  webContents.off(ContextMenu, listener);
6519
6544
  };
6520
- const handler$8 = (event, params) => {
6545
+ const handler$8 = (event, params, browserViewId) => {
6521
6546
  return {
6522
- messages: [['handleContextMenu', params]],
6547
+ messages: [['handleContextMenu', {
6548
+ ...params,
6549
+ browserViewId
6550
+ }]],
6523
6551
  result: undefined
6524
6552
  };
6525
6553
  };
6526
6554
 
6527
6555
  const ElectronBrowserViewEventListenerContextMenu = {
6528
6556
  __proto__: null,
6529
- attach: attach$a,
6557
+ attach: attach$b,
6530
6558
  detach: detach$8,
6531
6559
  handler: handler$8,
6532
6560
  key: key$8
@@ -6566,7 +6594,7 @@ const cancelForWebContents = webContentsId => {
6566
6594
  };
6567
6595
 
6568
6596
  const key$7 = 'destroyed';
6569
- const attach$9 = (webContents, listener) => {
6597
+ const attach$a = (webContents, listener) => {
6570
6598
  webContents.on(Destroyed, listener);
6571
6599
  };
6572
6600
  const detach$7 = (webContents, listener) => {
@@ -6594,7 +6622,7 @@ const handler$7 = (_event, webContentsId) => {
6594
6622
 
6595
6623
  const ElectronBrowserViewEventListenerDestroyed = {
6596
6624
  __proto__: null,
6597
- attach: attach$9,
6625
+ attach: attach$a,
6598
6626
  detach: detach$7,
6599
6627
  handler: handler$7,
6600
6628
  key: key$7
@@ -6611,7 +6639,7 @@ const has = (webContents, url) => {
6611
6639
  const maxFaviconBytes = 1024 * 1024;
6612
6640
  const faviconFetchTimeout = 2000;
6613
6641
  const key$6 = PageFaviconUpdated;
6614
- const attach$8 = (webContents, listener) => {
6642
+ const attach$9 = (webContents, listener) => {
6615
6643
  webContents.on(PageFaviconUpdated, listener);
6616
6644
  };
6617
6645
  const detach$6 = (webContents, listener) => {
@@ -6701,7 +6729,7 @@ const handler$6 = async (_event, favicons, _webContentsId, webContents) => {
6701
6729
 
6702
6730
  const ElectronBrowserViewEventListenerPageFaviconUpdated = {
6703
6731
  __proto__: null,
6704
- attach: attach$8,
6732
+ attach: attach$9,
6705
6733
  detach: detach$6,
6706
6734
  handler: handler$6,
6707
6735
  key: key$6,
@@ -6709,7 +6737,7 @@ const ElectronBrowserViewEventListenerPageFaviconUpdated = {
6709
6737
  };
6710
6738
 
6711
6739
  const key$5 = 'did-navigate';
6712
- const attach$7 = (webContents, listener) => {
6740
+ const attach$8 = (webContents, listener) => {
6713
6741
  webContents.on(DidNavigate, listener);
6714
6742
  };
6715
6743
  const detach$5 = (webContents, listener) => {
@@ -6746,14 +6774,14 @@ const handler$5 = async (_event, url, _httpResponseCode, _httpStatusText, _webCo
6746
6774
 
6747
6775
  const ElectronBrowserViewEventListenerDidNavigate = {
6748
6776
  __proto__: null,
6749
- attach: attach$7,
6777
+ attach: attach$8,
6750
6778
  detach: detach$5,
6751
6779
  handler: handler$5,
6752
6780
  key: key$5
6753
6781
  };
6754
6782
 
6755
6783
  const key$4 = DidNavigateInPage;
6756
- const attach$6 = (webContents, listener) => {
6784
+ const attach$7 = (webContents, listener) => {
6757
6785
  webContents.on(DidNavigateInPage, listener);
6758
6786
  };
6759
6787
  const detach$4 = (webContents, listener) => {
@@ -6769,14 +6797,14 @@ const handler$4 = (_event, url, isMainFrame) => {
6769
6797
 
6770
6798
  const ElectronBrowserViewEventListenerDidNavigateInPage = {
6771
6799
  __proto__: null,
6772
- attach: attach$6,
6800
+ attach: attach$7,
6773
6801
  detach: detach$4,
6774
6802
  handler: handler$4,
6775
6803
  key: key$4
6776
6804
  };
6777
6805
 
6778
6806
  const key$3 = Login;
6779
- const attach$5 = (webContents, listener) => {
6807
+ const attach$6 = (webContents, listener) => {
6780
6808
  webContents.on(Login, listener);
6781
6809
  };
6782
6810
  const detach$3 = (webContents, listener) => {
@@ -6801,14 +6829,14 @@ const handler$3 = (event, authenticationResponseDetails, authInfo, callback, web
6801
6829
 
6802
6830
  const ElectronBrowserViewEventListenerLogin = {
6803
6831
  __proto__: null,
6804
- attach: attach$5,
6832
+ attach: attach$6,
6805
6833
  detach: detach$3,
6806
6834
  handler: handler$3,
6807
6835
  key: key$3
6808
6836
  };
6809
6837
 
6810
6838
  const key$2 = 'page-title-updated';
6811
- const attach$4 = (webContents, listener) => {
6839
+ const attach$5 = (webContents, listener) => {
6812
6840
  webContents.on(PageTitleUpdated, listener);
6813
6841
  };
6814
6842
  const detach$2 = (webContents, listener) => {
@@ -6823,14 +6851,14 @@ const handler$2 = (event, title) => {
6823
6851
 
6824
6852
  const ElectronBrowserViewEventListenerPageTitleUpdated = {
6825
6853
  __proto__: null,
6826
- attach: attach$4,
6854
+ attach: attach$5,
6827
6855
  detach: detach$2,
6828
6856
  handler: handler$2,
6829
6857
  key: key$2
6830
6858
  };
6831
6859
 
6832
6860
  const key$1 = 'will-navigate';
6833
- const attach$3 = (webContents, listener) => {
6861
+ const attach$4 = (webContents, listener) => {
6834
6862
  webContents.on(WillNavigate, listener);
6835
6863
  };
6836
6864
  const detach$1 = (webContents, listener) => {
@@ -6845,14 +6873,14 @@ const handler$1 = (event, url) => {
6845
6873
 
6846
6874
  const ElectronBrowserViewEventListenerWillNavigate = {
6847
6875
  __proto__: null,
6848
- attach: attach$3,
6876
+ attach: attach$4,
6849
6877
  detach: detach$1,
6850
6878
  handler: handler$1,
6851
6879
  key: key$1
6852
6880
  };
6853
6881
 
6854
6882
  const key = 'window-open';
6855
- const attach$2 = (webContents, listener) => {
6883
+ const attach$3 = (webContents, listener) => {
6856
6884
  webContents.setWindowOpenHandler(listener);
6857
6885
  };
6858
6886
  const detach = (webContents, listener) => {
@@ -6882,7 +6910,7 @@ const handler = ({
6882
6910
 
6883
6911
  const ElectronBrowserViewEventListenerWindowOpen = {
6884
6912
  __proto__: null,
6885
- attach: attach$2,
6913
+ attach: attach$3,
6886
6914
  detach,
6887
6915
  handler,
6888
6916
  key
@@ -7052,7 +7080,7 @@ const getSession = () => {
7052
7080
  return state.session;
7053
7081
  };
7054
7082
 
7055
- const attach$1 = (webContents, parentWebContents) => {
7083
+ const attach$2 = (webContents, parentWebContents) => {
7056
7084
  let shouldRestoreParentFocus = false;
7057
7085
  const cancel = () => {
7058
7086
  shouldRestoreParentFocus = false;
@@ -7106,7 +7134,7 @@ const isSoundCloudUrl = url => {
7106
7134
  return false;
7107
7135
  }
7108
7136
  };
7109
- const attach = webContents => {
7137
+ const attach$1 = webContents => {
7110
7138
  webContents.on(DidNavigate, (_event, url) => {
7111
7139
  if (!isSoundCloudUrl(url)) {
7112
7140
  return;
@@ -7123,14 +7151,23 @@ const send = (method, ...params) => {
7123
7151
  return rpc.send(method, ...params);
7124
7152
  };
7125
7153
 
7154
+ const focusTimes = new WeakMap();
7155
+ const attach = contents => {
7156
+ if (focusTimes.has(contents)) return;
7157
+ focusTimes.set(contents, 0);
7158
+ contents.on('focus', () => focusTimes.set(contents, Date.now()));
7159
+ };
7160
+ const getLastFocusedAt = contents => focusTimes.get(contents) || 0;
7161
+
7126
7162
  const webContentsWithEventListeners = new WeakSet();
7127
7163
  const attachEventListenersToWebContents = (webContentsId, webContents, browserWindow) => {
7128
7164
  if (webContentsWithEventListeners.has(webContents)) {
7129
7165
  return;
7130
7166
  }
7131
- attach$d(browserWindow, webContents);
7132
- attach$1(webContents, browserWindow.webContents);
7133
7167
  attach(webContents);
7168
+ attach$e(browserWindow, webContents);
7169
+ attach$2(webContents, browserWindow.webContents);
7170
+ attach$1(webContents);
7134
7171
  const values = Object.values(ElectronBrowserViewEventListeners);
7135
7172
  for (const value of values) {
7136
7173
  const handleResult = ({
@@ -7526,6 +7563,8 @@ const getStats = (view, includeMemory = false) => {
7526
7563
  canGoBack,
7527
7564
  canGoForward,
7528
7565
  isAudioMuted,
7566
+ isFocused: webContents.isFocused(),
7567
+ lastFocusedAt: getLastFocusedAt(webContents),
7529
7568
  title,
7530
7569
  url
7531
7570
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.40.0",
3
+ "version": "6.41.1",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"