@lvce-editor/title-bar-worker 4.16.0 → 4.17.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.
@@ -1032,7 +1032,7 @@ const createMockRpc = ({
1032
1032
  };
1033
1033
 
1034
1034
  const rpcs = Object.create(null);
1035
- const set$2 = (id, rpc) => {
1035
+ const set$4 = (id, rpc) => {
1036
1036
  rpcs[id] = rpc;
1037
1037
  };
1038
1038
  const get$1 = id => {
@@ -1065,7 +1065,7 @@ const create$2 = rpcId => {
1065
1065
  const mockRpc = createMockRpc({
1066
1066
  commandMap
1067
1067
  });
1068
- set$2(rpcId, mockRpc);
1068
+ set$4(rpcId, mockRpc);
1069
1069
  // @ts-ignore
1070
1070
  mockRpc[Symbol.dispose] = () => {
1071
1071
  remove(rpcId);
@@ -1074,7 +1074,7 @@ const create$2 = rpcId => {
1074
1074
  return mockRpc;
1075
1075
  },
1076
1076
  set(rpc) {
1077
- set$2(rpcId, rpc);
1077
+ set$4(rpcId, rpc);
1078
1078
  }
1079
1079
  };
1080
1080
  };
@@ -1495,6 +1495,7 @@ const parseKey = rawKey => {
1495
1495
 
1496
1496
  const Electron$1 = 2;
1497
1497
 
1498
+ const RendererProcess = 1670;
1498
1499
  const RendererWorker = 1;
1499
1500
 
1500
1501
  const FocusSelector = 'Viewlet.focusSelector';
@@ -1503,6 +1504,11 @@ const SetFocusContext = 'Viewlet.setFocusContext';
1503
1504
 
1504
1505
  const FocusTitleBarMenuBar = 26;
1505
1506
 
1507
+ const {
1508
+ invoke: invoke$2,
1509
+ set: set$3
1510
+ } = create$2(RendererProcess);
1511
+
1506
1512
  class AssertionError extends Error {
1507
1513
  constructor(message) {
1508
1514
  super(message);
@@ -1559,32 +1565,32 @@ const array = value => {
1559
1565
  };
1560
1566
 
1561
1567
  const {
1562
- invoke,
1568
+ invoke: invoke$1,
1563
1569
  invokeAndTransfer,
1564
- set: set$1
1570
+ set: set$2
1565
1571
  } = create$2(RendererWorker);
1566
1572
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1567
1573
  number(uid);
1568
1574
  number(menuId);
1569
1575
  number(x);
1570
1576
  number(y);
1571
- await invoke('ContextMenu.show2', uid, menuId, x, y, args);
1577
+ await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1572
1578
  };
1573
1579
  const sendMessagePortToTextMeasurementWorker = async port => {
1574
1580
  const command = 'TextMeasurement.handleMessagePort';
1575
1581
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
1576
1582
  };
1577
1583
  const getWindowId$1 = async () => {
1578
- return invoke('GetWindowId.getWindowId');
1584
+ return invoke$1('GetWindowId.getWindowId');
1579
1585
  };
1580
1586
  const minimizeWindow = async () => {
1581
- return invoke('ElectronWindow.minimize');
1587
+ return invoke$1('ElectronWindow.minimize');
1582
1588
  };
1583
1589
  const maximizeWindow = async () => {
1584
- return invoke('ElectronWindow.maximize');
1590
+ return invoke$1('ElectronWindow.maximize');
1585
1591
  };
1586
1592
  const closeWindow = async () => {
1587
- return invoke('ElectronWindow.close');
1593
+ return invoke$1('ElectronWindow.close');
1588
1594
  };
1589
1595
 
1590
1596
  const toCommandId = key => {
@@ -1839,7 +1845,7 @@ const Remote = 3;
1839
1845
 
1840
1846
  const DEFAULT_UID = 1;
1841
1847
  const DEFAULT_APP_NAME = 'Lvce Editor';
1842
- const DEFAULT_MAIN_AREA_UID$1 = 2;
1848
+ const DEFAULT_MAIN_AREA_UID = 2;
1843
1849
  const createDefaultState = (uid = DEFAULT_UID) => ({
1844
1850
  appName: DEFAULT_APP_NAME,
1845
1851
  assetDir: '',
@@ -1858,7 +1864,7 @@ const createDefaultState = (uid = DEFAULT_UID) => ({
1858
1864
  labelLetterSpacing: 0,
1859
1865
  labelPadding: 8,
1860
1866
  layoutControlsEnabled: false,
1861
- mainAreaUid: DEFAULT_MAIN_AREA_UID$1,
1867
+ mainAreaUid: DEFAULT_MAIN_AREA_UID,
1862
1868
  menus: [],
1863
1869
  platform: Electron,
1864
1870
  title: '',
@@ -2109,7 +2115,7 @@ const {
2109
2115
  get,
2110
2116
  getCommandIds,
2111
2117
  registerCommands,
2112
- set,
2118
+ set: set$1,
2113
2119
  wrapCommand,
2114
2120
  wrapGetter
2115
2121
  } = create$1();
@@ -2145,7 +2151,7 @@ const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled,
2145
2151
  x,
2146
2152
  y
2147
2153
  };
2148
- set(id, state, state);
2154
+ set$1(id, state, state);
2149
2155
  };
2150
2156
 
2151
2157
  const isEqual$3 = (oldState, newState) => {
@@ -2233,14 +2239,6 @@ const getMenuIds = () => {
2233
2239
  return [Edit$2, File$3, Go$2, Help$3, OpenRecent$1, Run$2, Selection$2, Terminal$2, TitleBar$3, View$2, MenuIdAppearance, MenuIdEditorLayout, MenuIdSwitchEditor, MenuIdSwitchGroup, MenuIdTitleBarContextMenu, TitleBarContextMenu];
2234
2240
  };
2235
2241
 
2236
- const hasActiveTextEditor$1 = async mainAreaUid => {
2237
- try {
2238
- return await invoke('Main.hasActiveTextEditor', mainAreaUid);
2239
- } catch {
2240
- return false;
2241
- }
2242
- };
2243
-
2244
2242
  const nonTextEditorExtensions = new Set(['.avif', '.avi', '.bmp', '.gif', '.ico', '.jpeg', '.jpg', '.m4v', '.mkv', '.mov', '.mp4', '.mpeg', '.mpg', '.ogv', '.png', '.svg', '.tif', '.tiff', '.webm', '.webp']);
2245
2243
  const nonTextEditorPrefixes = ['diff://?', 'extension-detail://', 'process-explorer://', 'running-extensions://'];
2246
2244
  const getPathEndIndex = uri => {
@@ -2267,7 +2265,7 @@ const isTextEditorUri = uri => {
2267
2265
  };
2268
2266
  const hasActiveTextEditor = async () => {
2269
2267
  try {
2270
- const activeEditorId = await invoke('GetActiveEditor.getActiveEditorId');
2268
+ const activeEditorId = await invoke$1('GetActiveEditor.getActiveEditorId');
2271
2269
  return typeof activeEditorId === 'number' && activeEditorId >= 0;
2272
2270
  } catch {
2273
2271
  return false;
@@ -2275,7 +2273,7 @@ const hasActiveTextEditor = async () => {
2275
2273
  };
2276
2274
  const hasOpenTextEditor = async () => {
2277
2275
  try {
2278
- const openEditorUris = await invoke('GetActiveEditor.getOpenEditorUris');
2276
+ const openEditorUris = await invoke$1('GetActiveEditor.getOpenEditorUris');
2279
2277
  if (Array.isArray(openEditorUris)) {
2280
2278
  return openEditorUris.some(isTextEditorUri);
2281
2279
  }
@@ -2299,7 +2297,7 @@ const sideBarLeft = 1;
2299
2297
  const sideBarRight = 2;
2300
2298
  const getSideBarPosition = async () => {
2301
2299
  try {
2302
- return await invoke('Layout.getSideBarPosition');
2300
+ return await invoke$1('Layout.getSideBarPosition');
2303
2301
  } catch {
2304
2302
  return sideBarRight;
2305
2303
  }
@@ -2589,7 +2587,7 @@ const View = 16;
2589
2587
 
2590
2588
  const getAutoSave = async () => {
2591
2589
  try {
2592
- return await invoke('Preferences.get', 'files.autoSave');
2590
+ return await invoke$1('Preferences.get', 'files.autoSave');
2593
2591
  } catch {
2594
2592
  return 'off';
2595
2593
  }
@@ -2638,7 +2636,7 @@ const getMenuEntries$b = async (platform, autoSave$1, hasActiveTextEditor = fals
2638
2636
  label: save()
2639
2637
  }, {
2640
2638
  command: 'Main.saveAll',
2641
- flags: saveFlags,
2639
+ flags: Disabled,
2642
2640
  id: 'saveAll',
2643
2641
  label: saveAll()
2644
2642
  }, menuEntrySeparator, {
@@ -2777,7 +2775,7 @@ const normalizeUri = value => {
2777
2775
  }
2778
2776
  };
2779
2777
  const getRecentlyOpened = async () => {
2780
- const recentlyOpened = await invoke(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
2778
+ const recentlyOpened = await invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
2781
2779
  if (!Array.isArray(recentlyOpened)) {
2782
2780
  return [];
2783
2781
  }
@@ -3144,13 +3142,12 @@ const getMenuEntries$1 = () => {
3144
3142
  }];
3145
3143
  };
3146
3144
 
3147
- const DEFAULT_MAIN_AREA_UID = 2;
3148
3145
  const getMenuEntries2 = async (state, props) => {
3149
3146
  switch (props.menuId) {
3150
3147
  case Edit$2:
3151
3148
  return getMenuEntries$d();
3152
3149
  case File$3:
3153
- return getMenuEntries$b(props.platform, undefined, await hasActiveTextEditor$1(state.mainAreaUid ?? DEFAULT_MAIN_AREA_UID));
3150
+ return getMenuEntries$b(props.platform, undefined, await hasOpenTextEditor());
3154
3151
  case Go$2:
3155
3152
  return getMenuEntries$a();
3156
3153
  case Help$3:
@@ -3347,7 +3344,7 @@ const toElectronMenu = (map, rootId) => {
3347
3344
 
3348
3345
  const setItems = async items => {
3349
3346
  const windowId = await getWindowId();
3350
- return invoke('WebView.compatSharedProcessInvoke', 'ElectronApplicationMenu.setItems', windowId, items);
3347
+ return invoke$1('WebView.compatSharedProcessInvoke', 'ElectronApplicationMenu.setItems', windowId, items);
3351
3348
  };
3352
3349
  const hydrate = async state => {
3353
3350
  const {
@@ -3488,7 +3485,7 @@ const commandCenterItems = [{
3488
3485
  label: 'More'
3489
3486
  }];
3490
3487
  const handleCommandCenterClick = async state => {
3491
- await invoke('QuickPick.show', 'custom', commandCenterItems, undefined, {
3488
+ await invoke$1('QuickPick.show', 'custom', commandCenterItems, undefined, {
3492
3489
  executeItemCommand: true,
3493
3490
  mode: 'quickPick',
3494
3491
  placeholder: 'Search files by name (append : to go to line or @ to go to symbol)',
@@ -3530,10 +3527,35 @@ const handleElectronMenuClick = async (state, label) => {
3530
3527
  args = [],
3531
3528
  command
3532
3529
  } = commandPair;
3533
- await invoke(command, ...args);
3530
+ await invoke$1(command, ...args);
3534
3531
  return state;
3535
3532
  };
3536
3533
 
3534
+ const state = {
3535
+ connected: false
3536
+ };
3537
+ const isConnected = () => {
3538
+ const {
3539
+ connected
3540
+ } = state;
3541
+ return connected;
3542
+ };
3543
+ const invoke = (method, ...params) => {
3544
+ return invoke$2(method, ...params);
3545
+ };
3546
+ const set = rpc => {
3547
+ set$3(rpc);
3548
+ state.connected = true;
3549
+ };
3550
+
3551
+ const handleMessagePort = async port => {
3552
+ const rpc = await create$5({
3553
+ commandMap: {},
3554
+ messagePort: port
3555
+ });
3556
+ set(rpc);
3557
+ };
3558
+
3537
3559
  const getMenuOffset = (x, clientX, iconWidth) => {
3538
3560
  return clientX - x - iconWidth;
3539
3561
  };
@@ -3629,7 +3651,7 @@ const toCommandInfo = entry => {
3629
3651
  const addMenuEntryKeyBindings = async entries => {
3630
3652
  try {
3631
3653
  const commands = entries.map(toCommandInfo);
3632
- const keys = await invoke('Layout.getKeyBindings', commands);
3654
+ const keys = await invoke$1('Layout.getKeyBindings', commands);
3633
3655
  if (!keys.some(Boolean)) {
3634
3656
  return entries;
3635
3657
  }
@@ -4050,7 +4072,7 @@ const getTitleBarMenuBarWidth = (windowWidth, menuBarX, iconWidth, titleWidth) =
4050
4072
  };
4051
4073
 
4052
4074
  const getWorkspaceUri = () => {
4053
- return invoke('Workspace.getUri');
4075
+ return invoke$1('Workspace.getUri');
4054
4076
  };
4055
4077
 
4056
4078
  const loadContent2 = async state => {
@@ -4106,7 +4128,7 @@ const loadContent2Command = async uid => {
4106
4128
  titleWidth: latest.newState.titleWidth,
4107
4129
  workspaceUri: latest.newState.workspaceUri
4108
4130
  };
4109
- set(uid, latest.oldState, nextState, nextState);
4131
+ set$1(uid, latest.oldState, nextState, nextState);
4110
4132
  };
4111
4133
 
4112
4134
  const renderFocusContext = (oldState, newState) => {
@@ -4639,12 +4661,18 @@ const getRenderer3 = diffType => {
4639
4661
  }
4640
4662
  };
4641
4663
 
4664
+ const renderDirect = async (uid, commands) => {
4665
+ const rendererWorkerCommands = commands.filter(command => command[0] === SetFocusContext);
4666
+ const rendererProcessCommands = commands.filter(command => command[0] !== SetFocusContext);
4667
+ const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
4668
+ return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
4669
+ };
4642
4670
  const render3 = async (uid, diffResult) => {
4643
4671
  const {
4644
4672
  newState,
4645
4673
  oldState
4646
4674
  } = get(uid);
4647
- set(uid, newState, newState);
4675
+ set$1(uid, newState, newState);
4648
4676
  const commands = [];
4649
4677
  for (const item of diffResult) {
4650
4678
  const fn = getRenderer3(item);
@@ -4653,6 +4681,9 @@ const render3 = async (uid, diffResult) => {
4653
4681
  commands.push(result);
4654
4682
  }
4655
4683
  }
4684
+ if (isConnected()) {
4685
+ return renderDirect(uid, commands);
4686
+ }
4656
4687
  return commands;
4657
4688
  };
4658
4689
 
@@ -4811,7 +4842,7 @@ const create = (id, uri, x, y, width, height) => {
4811
4842
  x,
4812
4843
  y
4813
4844
  };
4814
- set(id, state, state);
4845
+ set$1(id, state, state);
4815
4846
  return state;
4816
4847
  };
4817
4848
 
@@ -5139,7 +5170,7 @@ const handleKeyEnterMenuClosed = state => {
5139
5170
  };
5140
5171
 
5141
5172
  const executeMenuItemCommand = async item => {
5142
- await invoke(item.command, ...(item.args || []));
5173
+ await invoke$1(item.command, ...(item.args || []));
5143
5174
  };
5144
5175
 
5145
5176
  const selectIndexIgnore = async (state, item) => {
@@ -5161,7 +5192,7 @@ const selectIndexNone = async (state, item) => {
5161
5192
  menus: []
5162
5193
  };
5163
5194
  if (storedState) {
5164
- set(uid, storedState.oldState, newState, newState);
5195
+ set$1(uid, storedState.oldState, newState, newState);
5165
5196
  }
5166
5197
  return newState;
5167
5198
  };
@@ -5169,7 +5200,7 @@ const selectIndexNone = async (state, item) => {
5169
5200
  const selectIndexRestoreEditorFocus = async (state, item) => {
5170
5201
  await executeMenuItemCommand(item);
5171
5202
  try {
5172
- await invoke('Main.focus');
5203
+ await invoke$1('Main.focus');
5173
5204
  } catch {
5174
5205
  // Focus restoration is best effort and must not turn a successful command into a failure.
5175
5206
  }
@@ -5411,7 +5442,7 @@ const toggleMenu = async state => {
5411
5442
  };
5412
5443
 
5413
5444
  const wakeUp = sleepState => {
5414
- set(sleepState.uid, sleepState, sleepState);
5445
+ set$1(sleepState.uid, sleepState, sleepState);
5415
5446
  };
5416
5447
 
5417
5448
  const commandMap = {
@@ -5454,6 +5485,7 @@ const commandMap = {
5454
5485
  'TitleBar.handleKeySpace': wrapCommand(handleKeySpace),
5455
5486
  'TitleBar.handleMenuClick': wrapCommand(handleMenuClick),
5456
5487
  'TitleBar.handleMenuMouseOver': wrapCommand(handleMenuMouseOver),
5488
+ 'TitleBar.handleMessagePort': handleMessagePort,
5457
5489
  'TitleBar.handleMouseOut': wrapCommand(handleMouseOut),
5458
5490
  'TitleBar.handleMouseOver': wrapCommand(handleMouseOver),
5459
5491
  'TitleBar.handlePointerOut': wrapCommand(handlePointerOut),
@@ -5485,7 +5517,7 @@ const listen = async () => {
5485
5517
  const rpc = await create$3({
5486
5518
  commandMap: commandMap
5487
5519
  });
5488
- set$1(rpc);
5520
+ set$2(rpc);
5489
5521
  };
5490
5522
 
5491
5523
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "4.16.0",
3
+ "version": "4.17.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",