@lvce-editor/activity-bar-worker 7.19.1 → 7.21.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.
@@ -249,7 +249,7 @@ const {
249
249
  get: get$2,
250
250
  getCommandIds,
251
251
  registerCommands,
252
- set: set$3,
252
+ set: set$5,
253
253
  wrapAsyncCommand,
254
254
  wrapCommand,
255
255
  wrapGetter
@@ -284,7 +284,7 @@ const create$9 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
284
284
  x,
285
285
  y
286
286
  };
287
- set$3(id, state, state);
287
+ set$5(id, state, state);
288
288
  return state;
289
289
  };
290
290
 
@@ -594,6 +594,7 @@ const LeftClick = 0;
594
594
  const Electron = 2;
595
595
 
596
596
  const ExtensionManagementWorker = 9006;
597
+ const RendererProcess = 1670;
597
598
  const RendererWorker = 1;
598
599
 
599
600
  const Left = 1;
@@ -1966,7 +1967,7 @@ const createMockRpc = ({
1966
1967
  };
1967
1968
 
1968
1969
  const rpcs = Object.create(null);
1969
- const set$2 = (id, rpc) => {
1970
+ const set$4 = (id, rpc) => {
1970
1971
  rpcs[id] = rpc;
1971
1972
  };
1972
1973
  const get = id => {
@@ -1999,7 +2000,7 @@ const create = rpcId => {
1999
2000
  const mockRpc = createMockRpc({
2000
2001
  commandMap
2001
2002
  });
2002
- set$2(rpcId, mockRpc);
2003
+ set$4(rpcId, mockRpc);
2003
2004
  // @ts-ignore
2004
2005
  mockRpc[Symbol.dispose] = () => {
2005
2006
  remove(rpcId);
@@ -2008,27 +2009,32 @@ const create = rpcId => {
2008
2009
  return mockRpc;
2009
2010
  },
2010
2011
  set(rpc) {
2011
- set$2(rpcId, rpc);
2012
+ set$4(rpcId, rpc);
2012
2013
  }
2013
2014
  };
2014
2015
  };
2015
2016
 
2016
2017
  const {
2017
- invoke: invoke$1,
2018
- set: set$1
2018
+ invoke: invoke$3,
2019
+ set: set$3
2019
2020
  } = create(ExtensionManagementWorker);
2020
2021
 
2021
2022
  const {
2022
- invoke,
2023
+ invoke: invoke$2,
2024
+ set: set$2
2025
+ } = create(RendererProcess);
2026
+
2027
+ const {
2028
+ invoke: invoke$1,
2023
2029
  invokeAndTransfer,
2024
- set
2030
+ set: set$1
2025
2031
  } = create(RendererWorker);
2026
2032
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
2027
2033
  number(uid);
2028
2034
  number(menuId);
2029
2035
  number(x);
2030
2036
  number(y);
2031
- await invoke('ContextMenu.show2', uid, menuId, x, y, args);
2037
+ await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
2032
2038
  };
2033
2039
  const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
2034
2040
  const command = 'Extensions.handleMessagePort';
@@ -2046,7 +2052,7 @@ const handleClickAccount = async (state, eventX, eventY, viewletId) => {
2046
2052
  uid
2047
2053
  } = state;
2048
2054
  try {
2049
- await invoke('Layout.refreshAuthState');
2055
+ await invoke$1('Layout.refreshAuthState');
2050
2056
  } catch {
2051
2057
  // Keep the account menu available when auth is unavailable.
2052
2058
  }
@@ -2238,7 +2244,7 @@ const getBadgeText = badgeCount => {
2238
2244
 
2239
2245
  const updateItemsWithBadgeCount = async items => {
2240
2246
  try {
2241
- const badgeCounts = await invoke('Layout.getBadgeCounts');
2247
+ const badgeCounts = await invoke$1('Layout.getBadgeCounts');
2242
2248
  const newItems = items.map(item => {
2243
2249
  const badgeCount = badgeCounts[item.id] || 0;
2244
2250
  const badgeText = getBadgeText(badgeCount);
@@ -2389,7 +2395,7 @@ const getSideBarChange = (sideBarVisible, currentViewletId, viewletId) => {
2389
2395
  };
2390
2396
 
2391
2397
  const toggle = async id => {
2392
- await invoke('Layout.toggleSideBarView', id);
2398
+ await invoke$1('Layout.toggleSideBarView', id);
2393
2399
  };
2394
2400
 
2395
2401
  const handleClickOther = async (state, viewletId) => {
@@ -2502,18 +2508,18 @@ const handleClick = async (state, button, eventX, eventY, targetName = '') => {
2502
2508
  };
2503
2509
 
2504
2510
  const handleClickSignIn = async state => {
2505
- await invoke('Layout.signIn');
2511
+ await invoke$1('Layout.signIn');
2506
2512
  return state;
2507
2513
  };
2508
2514
 
2509
2515
  const handleClickSignOut = async state => {
2510
- await invoke('Layout.signOut');
2516
+ await invoke$1('Layout.signOut');
2511
2517
  return state;
2512
2518
  };
2513
2519
 
2514
2520
  const getSideBarPosition = async () => {
2515
2521
  try {
2516
- return await invoke('Layout.getSideBarPosition');
2522
+ return await invoke$1('Layout.getSideBarPosition');
2517
2523
  } catch {
2518
2524
  return Left;
2519
2525
  }
@@ -2542,7 +2548,7 @@ const handleExtensionManagementMessagePort = async port => {
2542
2548
  commandMap: commandMap$1,
2543
2549
  messagePort: port
2544
2550
  });
2545
- set$1(rpc);
2551
+ set$3(rpc);
2546
2552
  };
2547
2553
 
2548
2554
  const hashString = value => {
@@ -2661,7 +2667,7 @@ const getActivityBarItems = (state, contributedViews = []) => {
2661
2667
 
2662
2668
  const getContributedViews = async platform => {
2663
2669
  try {
2664
- const views = await invoke$1('Extensions.getViews', '', platform);
2670
+ const views = await invoke$3('Extensions.getViews', '', platform);
2665
2671
  if (!Array.isArray(views)) {
2666
2672
  return [];
2667
2673
  }
@@ -2725,6 +2731,41 @@ const handleFocus = state => {
2725
2731
  };
2726
2732
  };
2727
2733
 
2734
+ const state = {
2735
+ connected: false
2736
+ };
2737
+ const isConnected = () => {
2738
+ const {
2739
+ connected
2740
+ } = state;
2741
+ return connected;
2742
+ };
2743
+ const invoke = (method, ...params) => {
2744
+ return invoke$2(method, ...params);
2745
+ };
2746
+ const set = rpc => {
2747
+ set$2(rpc);
2748
+ state.connected = true;
2749
+ };
2750
+
2751
+ const handleMessagePort = async (port, viewletCommandMap) => {
2752
+ const executeViewletCommand = async (uid, command, ...args) => {
2753
+ const fn = viewletCommandMap[`ActivityBar.${command}`];
2754
+ if (typeof fn !== 'function') {
2755
+ throw new TypeError(`Viewlet command not found: ${command}`);
2756
+ }
2757
+ await fn(uid, ...args);
2758
+ await invoke$1('Viewlet.requestRender', uid);
2759
+ };
2760
+ const rpc = await create$4({
2761
+ commandMap: {
2762
+ 'Viewlet.executeViewletCommand': executeViewletCommand
2763
+ },
2764
+ messagePort: port
2765
+ });
2766
+ set(rpc);
2767
+ };
2768
+
2728
2769
  const handleResize = (state, dimensions) => {
2729
2770
  const {
2730
2771
  activityBarItems,
@@ -2749,7 +2790,7 @@ const handleResize = (state, dimensions) => {
2749
2790
 
2750
2791
  const getAccountEnabled = async defaultValue => {
2751
2792
  try {
2752
- const value = await invoke('Preferences.get', 'activityBar.accountEnabled');
2793
+ const value = await invoke$1('Preferences.get', 'activityBar.accountEnabled');
2753
2794
  return typeof value === 'boolean' ? value : defaultValue;
2754
2795
  } catch {
2755
2796
  return defaultValue;
@@ -2783,7 +2824,7 @@ const handleSettingsChanged = async state => {
2783
2824
 
2784
2825
  const getSideBarVisible = async () => {
2785
2826
  try {
2786
- const visible = await invoke('Layout.getSideBarVisible');
2827
+ const visible = await invoke$1('Layout.getSideBarVisible');
2787
2828
  return visible;
2788
2829
  } catch {
2789
2830
  return true;
@@ -2879,7 +2920,7 @@ const handleUpdateStateChange = async (state, config) => {
2879
2920
 
2880
2921
  const getActiveView = async () => {
2881
2922
  try {
2882
- const activeView = await invoke('Layout.getActiveSideBarView');
2923
+ const activeView = await invoke$1('Layout.getActiveSideBarView');
2883
2924
  return activeView;
2884
2925
  } catch {
2885
2926
  return Explorer;
@@ -3548,14 +3589,23 @@ const applyRender = (oldState, newState, diffResult) => {
3548
3589
  return commands;
3549
3590
  };
3550
3591
 
3592
+ const renderDirect = async (uid, commands) => {
3593
+ const rendererWorkerCommands = commands.filter(command => command[0] === SetFocusContext);
3594
+ const rendererProcessCommands = commands.filter(command => command[0] !== SetFocusContext);
3595
+ const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
3596
+ return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
3597
+ };
3551
3598
  const render2 = (uid, diffResult) => {
3552
3599
  const {
3553
3600
  newState,
3554
3601
  oldState
3555
3602
  } = get$2(uid);
3556
- set$3(uid, newState, newState);
3603
+ set$5(uid, newState, newState);
3557
3604
  const commands = applyRender(oldState, newState, diffResult);
3558
- return commands;
3605
+ if (!isConnected()) {
3606
+ return commands;
3607
+ }
3608
+ return renderDirect(uid, commands);
3559
3609
  };
3560
3610
 
3561
3611
  const renderEventListeners = () => {
@@ -3763,9 +3813,10 @@ const toggleActivityBarItem = async (state, itemId) => {
3763
3813
  };
3764
3814
 
3765
3815
  const wakeUp = sleepState => {
3766
- set$3(sleepState.uid, sleepState, sleepState);
3816
+ set$5(sleepState.uid, sleepState, sleepState);
3767
3817
  };
3768
3818
 
3819
+ const handleDirectMessagePort = port => handleMessagePort(port, commandMap);
3769
3820
  const commandMap = {
3770
3821
  'ActivityBar.create': create$9,
3771
3822
  'ActivityBar.diff2': diff2,
@@ -3795,6 +3846,7 @@ const commandMap = {
3795
3846
  'ActivityBar.handleExtensionManagementMessagePort': handleExtensionManagementMessagePort,
3796
3847
  'ActivityBar.handleExtensionsChanged': wrapCommand(handleExtensionsChanged),
3797
3848
  'ActivityBar.handleFocus': wrapCommand(handleFocus),
3849
+ 'ActivityBar.handleMessagePort': handleDirectMessagePort,
3798
3850
  'ActivityBar.handleSettingsChanged': wrapCommand(handleSettingsChanged),
3799
3851
  'ActivityBar.handleSideBarStateChange': wrapCommand(handleSideBarStateChange),
3800
3852
  'ActivityBar.handleUpdateStateChange': wrapCommand(handleUpdateStateChange),
@@ -3821,14 +3873,14 @@ const initializeExtensionManagementWorker = async () => {
3821
3873
  commandMap: {},
3822
3874
  send
3823
3875
  });
3824
- set$1(rpc);
3876
+ set$3(rpc);
3825
3877
  };
3826
3878
 
3827
3879
  const initializeRendererWorker = async () => {
3828
3880
  const rpc = await create$1({
3829
3881
  commandMap: commandMap
3830
3882
  });
3831
- set(rpc);
3883
+ set$1(rpc);
3832
3884
  };
3833
3885
 
3834
3886
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "7.19.1",
3
+ "version": "7.21.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",