@lvce-editor/title-bar-worker 4.28.1 → 4.28.3

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.
@@ -1165,7 +1165,7 @@ const createMockRpc = ({
1165
1165
  };
1166
1166
 
1167
1167
  const rpcs = Object.create(null);
1168
- const set$5 = (id, rpc) => {
1168
+ const set$6 = (id, rpc) => {
1169
1169
  rpcs[id] = rpc;
1170
1170
  };
1171
1171
  const get$1 = id => {
@@ -1198,7 +1198,7 @@ const create$2 = rpcId => {
1198
1198
  const mockRpc = createMockRpc({
1199
1199
  commandMap
1200
1200
  });
1201
- set$5(rpcId, mockRpc);
1201
+ set$6(rpcId, mockRpc);
1202
1202
  // @ts-ignore
1203
1203
  mockRpc[Symbol.dispose] = () => {
1204
1204
  remove(rpcId);
@@ -1207,7 +1207,7 @@ const create$2 = rpcId => {
1207
1207
  return mockRpc;
1208
1208
  },
1209
1209
  set(rpc) {
1210
- set$5(rpcId, rpc);
1210
+ set$6(rpcId, rpc);
1211
1211
  }
1212
1212
  };
1213
1213
  };
@@ -1640,18 +1640,18 @@ const FocusTitleBarMenuBar = 26;
1640
1640
 
1641
1641
  const {
1642
1642
  invoke: invoke$3,
1643
- set: set$4
1643
+ set: set$5
1644
1644
  } = create$2(MainProcess);
1645
1645
 
1646
1646
  const {
1647
1647
  invoke: invoke$2,
1648
- set: set$3
1648
+ set: set$4
1649
1649
  } = create$2(RendererProcess);
1650
1650
 
1651
1651
  const {
1652
1652
  invoke: invoke$1,
1653
1653
  invokeAndTransfer,
1654
- set: set$2
1654
+ set: set$3
1655
1655
  } = create$2(RendererWorker);
1656
1656
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1657
1657
  number(uid);
@@ -1945,6 +1945,7 @@ const createDefaultState = (uid = DEFAULT_UID) => ({
1945
1945
  mainAreaUid: DEFAULT_MAIN_AREA_UID,
1946
1946
  menus: [],
1947
1947
  platform: Electron,
1948
+ showSideBarThings: true,
1948
1949
  title: '',
1949
1950
  titleBarButtons: [],
1950
1951
  titleBarButtonsEnabled: true,
@@ -2193,7 +2194,7 @@ const {
2193
2194
  get,
2194
2195
  getCommandIds,
2195
2196
  registerCommands,
2196
- set: set$1,
2197
+ set: set$2,
2197
2198
  wrapCommand: wrapNotification,
2198
2199
  wrapGetter,
2199
2200
  wrapSerialCommand: wrapCommand
@@ -2230,11 +2231,11 @@ const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled,
2230
2231
  x,
2231
2232
  y
2232
2233
  };
2233
- set$1(id, state, state);
2234
+ set$2(id, state, state);
2234
2235
  };
2235
2236
 
2236
2237
  const isEqual$3 = (oldState, newState) => {
2237
- return oldState.commandCenterEnabled === newState.commandCenterEnabled && oldState.titleBarEntries === newState.titleBarEntries && oldState.titleBarMenuBarEnabled === newState.titleBarMenuBarEnabled && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.title === newState.title && oldState.workspaceUri === newState.workspaceUri;
2238
+ return oldState.commandCenterEnabled === newState.commandCenterEnabled && oldState.titleBarEntries === newState.titleBarEntries && oldState.titleBarMenuBarEnabled === newState.titleBarMenuBarEnabled && oldState.showSideBarThings === newState.showSideBarThings && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.title === newState.title && oldState.workspaceUri === newState.workspaceUri;
2238
2239
  };
2239
2240
 
2240
2241
  const isEqual$2 = (oldState, newState) => {
@@ -3316,7 +3317,7 @@ const initializeMainProcess = async () => {
3316
3317
  commandMap: {},
3317
3318
  send
3318
3319
  });
3319
- set$4(rpc);
3320
+ set$5(rpc);
3320
3321
  };
3321
3322
 
3322
3323
  // based on https://www.electronjs.org/docs/latest/api/menu-item#new-menuitemoptions
@@ -3745,6 +3746,7 @@ const getTitleBarVirtualDom = state => {
3745
3746
  focusedIndex,
3746
3747
  isMenuOpen,
3747
3748
  platform,
3749
+ showSideBarThings,
3748
3750
  title,
3749
3751
  titleBarButtons,
3750
3752
  titleBarButtonsEnabled,
@@ -3761,7 +3763,8 @@ const getTitleBarVirtualDom = state => {
3761
3763
  const iconSrc = getIcon(assetDir);
3762
3764
  const visibleEntries = getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
3763
3765
  const titleEnabled = titleBarTitleEnabled && !commandCenterEnabled;
3764
- const childCount = Number(titleBarIconEnabled) + Number(titleBarMenuBarEnabled) + Number(commandCenterEnabled) + Number(titleEnabled) + Number(titleBarButtonsEnabled);
3766
+ const showSideBar = showSideBarThings !== false;
3767
+ const childCount = Number(showSideBar && titleBarIconEnabled) + Number(showSideBar && titleBarMenuBarEnabled) + Number(showSideBar && commandCenterEnabled) + Number(showSideBar && titleEnabled) + Number(titleBarButtonsEnabled);
3765
3768
  return [{
3766
3769
  ariaLabel: titleBar(),
3767
3770
  childCount,
@@ -3770,7 +3773,7 @@ const getTitleBarVirtualDom = state => {
3770
3773
  onContextMenu: HandleTitleBarContextMenu,
3771
3774
  role: ContentInfo,
3772
3775
  type: Div
3773
- }, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getCommandCenterVirtualDom(commandCenterEnabled), ...getTitleVirtualDom(titleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
3776
+ }, ...getTitleBarIconVirtualDom(showSideBar && titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(showSideBar && titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getCommandCenterVirtualDom(showSideBar && commandCenterEnabled), ...getTitleVirtualDom(showSideBar && titleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
3774
3777
  };
3775
3778
 
3776
3779
  const renderTitleBar = (oldState, newState) => {
@@ -4199,8 +4202,8 @@ const isConnected = () => {
4199
4202
  const invoke = (method, ...params) => {
4200
4203
  return invoke$2(method, ...params);
4201
4204
  };
4202
- const set = rpc => {
4203
- set$3(rpc);
4205
+ const set$1 = rpc => {
4206
+ set$4(rpc);
4204
4207
  state.connected = true;
4205
4208
  };
4206
4209
 
@@ -4237,7 +4240,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
4237
4240
  messagePort: port
4238
4241
  });
4239
4242
  if (setAsRendererProcess) {
4240
- set(rpc);
4243
+ set$1(rpc);
4241
4244
  }
4242
4245
  };
4243
4246
 
@@ -4376,10 +4379,38 @@ const getRemoteSshWorkspace = workspaceUri => {
4376
4379
  return undefined;
4377
4380
  }
4378
4381
  };
4379
- const getWorkspaceTitle = (workspacePath, titleTemplate, appName) => {
4382
+ const getDevContainerWorkspace = workspaceUri => {
4383
+ // Workspace title-change events currently carry the resolved path, where
4384
+ // devcontainer paths end in a marker instead of retaining their URI scheme.
4385
+ if (workspaceUri.endsWith('!')) {
4386
+ return {
4387
+ path: workspaceUri
4388
+ };
4389
+ }
4390
+ try {
4391
+ const url = new URL(workspaceUri);
4392
+ if (url.protocol !== 'devcontainers:') {
4393
+ return undefined;
4394
+ }
4395
+ return {
4396
+ path: url.pathname
4397
+ };
4398
+ } catch {
4399
+ return undefined;
4400
+ }
4401
+ };
4402
+ const getWorkspaceTitle = (workspacePath, titleTemplate, appName, decodeFolderName = false) => {
4380
4403
  const endIndex = getEndIndex(workspacePath);
4381
4404
  const slashIndex = Math.max(workspacePath.lastIndexOf('/', endIndex - 1), workspacePath.lastIndexOf('\\', endIndex - 1));
4382
- const folderName = workspacePath.slice(slashIndex + 1, endIndex);
4405
+ const encodedFolderName = workspacePath.slice(slashIndex + 1, endIndex);
4406
+ let folderName = encodedFolderName;
4407
+ if (decodeFolderName) {
4408
+ try {
4409
+ folderName = decodeURIComponent(encodedFolderName);
4410
+ } catch {
4411
+ // Keep malformed URI segments visible rather than failing title rendering.
4412
+ }
4413
+ }
4383
4414
 
4384
4415
  // If titleTemplate is empty, return folderName directly
4385
4416
  if (!titleTemplate) {
@@ -4397,14 +4428,26 @@ const getTitle = (workspaceUri, titleTemplate, appName) => {
4397
4428
  return appName;
4398
4429
  }
4399
4430
  const remoteSshWorkspace = getRemoteSshWorkspace(workspaceUri);
4400
- const workspacePath = remoteSshWorkspace?.path ?? getPath(workspaceUri);
4401
- const title = getWorkspaceTitle(workspacePath, titleTemplate, appName);
4431
+ const devContainerWorkspace = getDevContainerWorkspace(workspaceUri);
4432
+ const workspacePath = remoteSshWorkspace?.path ?? devContainerWorkspace?.path ?? getPath(workspaceUri);
4433
+ const displayWorkspacePath = getDevContainerDisplayPath(devContainerWorkspace, workspacePath);
4434
+ const title = getWorkspaceTitle(displayWorkspacePath, titleTemplate, appName, Boolean(devContainerWorkspace));
4435
+ if (devContainerWorkspace) {
4436
+ const devContainerSuffix = '[devcontainer]';
4437
+ return title ? `${title} ${devContainerSuffix}` : devContainerSuffix;
4438
+ }
4402
4439
  if (!remoteSshWorkspace) {
4403
4440
  return title || appName;
4404
4441
  }
4405
4442
  const remoteSuffix = `[SSH: ${remoteSshWorkspace.host}]`;
4406
4443
  return title ? `${title} ${remoteSuffix}` : remoteSuffix;
4407
4444
  };
4445
+ const getDevContainerDisplayPath = (devContainerWorkspace, workspacePath) => {
4446
+ if (!devContainerWorkspace || !workspacePath.endsWith('!')) {
4447
+ return workspacePath;
4448
+ }
4449
+ return workspacePath.slice(0, -1);
4450
+ };
4408
4451
 
4409
4452
  const launchTextMeasurementWorker = async () => {
4410
4453
  const rpc = await create$5({
@@ -4565,7 +4608,7 @@ const loadContent2Command = async uid => {
4565
4608
  titleWidth: latest.newState.titleWidth,
4566
4609
  workspaceUri: latest.newState.workspaceUri
4567
4610
  };
4568
- set$1(uid, latest.oldState, nextState, nextState);
4611
+ set$2(uid, latest.oldState, nextState, nextState);
4569
4612
  };
4570
4613
 
4571
4614
  const renderFocusContext = (oldState, newState) => {
@@ -4891,7 +4934,7 @@ const render3 = async (uid, diffResult) => {
4891
4934
  newState,
4892
4935
  oldState
4893
4936
  } = get(uid);
4894
- set$1(uid, newState, newState);
4937
+ set$2(uid, newState, newState);
4895
4938
  const commands = [];
4896
4939
  for (const item of numbers) {
4897
4940
  if (!pendingDiffs.has(item)) {
@@ -5009,6 +5052,28 @@ const setPlatform = (state, platform) => {
5009
5052
  };
5010
5053
  };
5011
5054
 
5055
+ const setShowSideBarThings = (state, showSideBarThings) => {
5056
+ const {
5057
+ focused,
5058
+ focusedIndex,
5059
+ isMenuOpen,
5060
+ menus,
5061
+ showSideBarThings: currentShowSideBarThings
5062
+ } = state;
5063
+ if (showSideBarThings === currentShowSideBarThings) {
5064
+ return state;
5065
+ }
5066
+ return {
5067
+ ...state,
5068
+ focused: showSideBarThings && focused,
5069
+ focusedIndex: showSideBarThings ? focusedIndex : -1,
5070
+ isMenuOpen: showSideBarThings && isMenuOpen,
5071
+ menus: showSideBarThings ? menus : [],
5072
+ showSideBarThings
5073
+ };
5074
+ };
5075
+ const set = wrapCommand(setShowSideBarThings);
5076
+
5012
5077
  const setTitleTemplate = async (state, titleTemplate) => {
5013
5078
  const {
5014
5079
  applicationName,
@@ -5085,7 +5150,7 @@ const create = (id, uri, x, y, width, height) => {
5085
5150
  x,
5086
5151
  y
5087
5152
  };
5088
- set$1(id, state, state);
5153
+ set$2(id, state, state);
5089
5154
  return state;
5090
5155
  };
5091
5156
 
@@ -5405,7 +5470,7 @@ const selectIndexNone = async (state, item) => {
5405
5470
  menus: []
5406
5471
  };
5407
5472
  if (storedState) {
5408
- set$1(uid, storedState.oldState, closedState, closedState);
5473
+ set$2(uid, storedState.oldState, closedState, closedState);
5409
5474
  if (latestState.menus.length > 0) {
5410
5475
  const [command, ...args] = renderMenus(latestState, closedState);
5411
5476
  await invoke$2(command, ...args);
@@ -5420,7 +5485,7 @@ const selectIndexNone = async (state, item) => {
5420
5485
  menus: []
5421
5486
  };
5422
5487
  if (storedState) {
5423
- set$1(uid, finalState, finalState, finalState);
5488
+ set$2(uid, finalState, finalState, finalState);
5424
5489
  }
5425
5490
  return finalState;
5426
5491
  };
@@ -5690,7 +5755,7 @@ const toggleMenu = async state => {
5690
5755
  };
5691
5756
 
5692
5757
  const wakeUp = sleepState => {
5693
- set$1(sleepState.uid, sleepState, sleepState);
5758
+ set$2(sleepState.uid, sleepState, sleepState);
5694
5759
  };
5695
5760
 
5696
5761
  const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
@@ -5756,6 +5821,7 @@ const commandMap = {
5756
5821
  'TitleBar.saveState': wrapGetter(saveState),
5757
5822
  'TitleBar.setComponentState': setComponentState,
5758
5823
  'TitleBar.setPlatform': wrapCommand(setPlatform),
5824
+ 'TitleBar.setShowSideBarThings': set,
5759
5825
  'TitleBar.setTitleTemplate': wrapCommand(setTitleTemplate),
5760
5826
  'TitleBar.setWidth': wrapCommand(setWidth),
5761
5827
  'TitleBar.showCommandCenter': wrapCommand(showCommandCenter),
@@ -5772,7 +5838,7 @@ const listen = async () => {
5772
5838
  const rpc = await create$3({
5773
5839
  commandMap: commandMap
5774
5840
  });
5775
- set$2(rpc);
5841
+ set$3(rpc);
5776
5842
  };
5777
5843
 
5778
5844
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "4.28.1",
3
+ "version": "4.28.3",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",