@lvce-editor/main-area-worker 9.54.0 → 9.54.2

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.
@@ -3770,6 +3770,33 @@ const getLabel = uri => {
3770
3770
  return getBasename$1(uri);
3771
3771
  };
3772
3772
 
3773
+ /**
3774
+ *
3775
+ * @param {string} uri
3776
+ * @returns
3777
+ */
3778
+ const getFileIcon = uri => {
3779
+ if (uri === 'app://keybindings') {
3780
+ return `MaskIconRecordKey`;
3781
+ }
3782
+ if (uri.startsWith('extension-detail://')) {
3783
+ return `MaskIconExtensions`;
3784
+ }
3785
+ if (uri.startsWith('process-explorer://')) {
3786
+ return `MaskIconDebugAlt2`;
3787
+ }
3788
+ if (uri.startsWith('running-extensions://')) {
3789
+ return `MaskIconExtensions`;
3790
+ }
3791
+ if (uri.startsWith('cookie-import-view://')) {
3792
+ return `MaskIconRecordKey`;
3793
+ }
3794
+ if (uri.startsWith('search-editor://')) {
3795
+ return `MaskIconSearch`;
3796
+ }
3797
+ return '';
3798
+ };
3799
+
3773
3800
  const getEditorInputTitle = editorInput => {
3774
3801
  switch (editorInput.type) {
3775
3802
  case 'binary':
@@ -4080,8 +4107,6 @@ const getIconsCached = (dirents, fileIconCache) => {
4080
4107
  return dirents.map(dirent => fileIconCache[dirent]);
4081
4108
  };
4082
4109
 
4083
- const ExtensionDetailScheme$1 = 'extension-detail://';
4084
- const RunningExtensionsScheme$1 = 'running-extensions://';
4085
4110
  const getBasename = uri => {
4086
4111
  const lastSlashIndex = uri.lastIndexOf('/');
4087
4112
  if (lastSlashIndex === -1) {
@@ -4092,7 +4117,7 @@ const getBasename = uri => {
4092
4117
  const getMissingTabs = (tabs, fileIconCache) => {
4093
4118
  const missingTabs = [];
4094
4119
  for (const tab of tabs) {
4095
- if (tab.uri && !tab.uri.startsWith(ExtensionDetailScheme$1) && !tab.uri.startsWith(RunningExtensionsScheme$1) && !(tab.uri in fileIconCache)) {
4120
+ if (tab.uri && !getFileIcon(tab.uri) && !(tab.uri in fileIconCache)) {
4096
4121
  missingTabs.push(tab);
4097
4122
  }
4098
4123
  }
@@ -4165,31 +4190,40 @@ const getFileIconsForTabs = async (tabs, fileIconCache) => {
4165
4190
  };
4166
4191
  };
4167
4192
 
4193
+ const updateIcon = (state, tabId, icon) => {
4194
+ return {
4195
+ ...state,
4196
+ layout: {
4197
+ ...state.layout,
4198
+ groups: state.layout.groups.map(group => ({
4199
+ ...group,
4200
+ tabs: group.tabs.map(tab => tab.id === tabId ? {
4201
+ ...tab,
4202
+ icon
4203
+ } : tab)
4204
+ }))
4205
+ }
4206
+ };
4207
+ };
4168
4208
  const updateTabIcon = async (context, readyState, tabId) => {
4169
4209
  const newTab = findTabById(readyState, tabId);
4170
4210
  if (!newTab || !newTab.tab.uri) {
4171
4211
  return undefined;
4172
4212
  }
4213
+ const builtInIcon = getFileIcon(newTab.tab.uri);
4214
+ if (builtInIcon) {
4215
+ return context.updateState(state => updateIcon(state, tabId, builtInIcon));
4216
+ }
4173
4217
  try {
4174
4218
  const {
4175
4219
  newFileIconCache
4176
4220
  } = await getFileIconsForTabs([newTab.tab], readyState.fileIconCache);
4177
4221
  const stateBeforeIconUpdate = context.getState();
4178
4222
  const icon = newFileIconCache[newTab.tab.uri] || '';
4179
- const stateWithIcon = {
4223
+ const stateWithIcon = updateIcon({
4180
4224
  ...stateBeforeIconUpdate,
4181
- fileIconCache: newFileIconCache,
4182
- layout: {
4183
- ...stateBeforeIconUpdate.layout,
4184
- groups: stateBeforeIconUpdate.layout.groups.map(group => ({
4185
- ...group,
4186
- tabs: group.tabs.map(tab => tab.id === tabId ? {
4187
- ...tab,
4188
- icon
4189
- } : tab)
4190
- }))
4191
- }
4192
- };
4225
+ fileIconCache: newFileIconCache
4226
+ }, tabId, icon);
4193
4227
  return context.updateState(() => stateWithIcon);
4194
4228
  } catch {
4195
4229
  return undefined;
@@ -5573,40 +5607,53 @@ const getAllTabs$1 = layout => {
5573
5607
  return allTabs;
5574
5608
  };
5575
5609
 
5610
+ const updateLayoutIcons = (layout, fileIconCache, preserveExisting) => {
5611
+ const {
5612
+ groups
5613
+ } = layout;
5614
+ return {
5615
+ ...layout,
5616
+ groups: groups.map(group => ({
5617
+ ...group,
5618
+ tabs: group.tabs.map(tab => {
5619
+ const {
5620
+ icon: existingIcon
5621
+ } = tab;
5622
+ const uri = tab.uri || '';
5623
+ const builtInIcon = getFileIcon(uri);
5624
+ let icon = fileIconCache[uri];
5625
+ if (preserveExisting && !(uri in fileIconCache)) {
5626
+ icon = existingIcon;
5627
+ }
5628
+ if (builtInIcon) {
5629
+ icon = builtInIcon;
5630
+ }
5631
+ return {
5632
+ ...tab,
5633
+ icon
5634
+ };
5635
+ })
5636
+ }))
5637
+ };
5638
+ };
5576
5639
  const loadFileIcons = async state => {
5577
5640
  const {
5578
5641
  fileIconCache,
5579
5642
  layout
5580
5643
  } = state;
5581
- const {
5582
- groups
5583
- } = layout;
5584
5644
  try {
5585
5645
  const allTabs = getAllTabs$1(layout);
5586
5646
  const {
5587
5647
  newFileIconCache
5588
5648
  } = await getFileIconsForTabs(allTabs, fileIconCache);
5589
-
5590
- // Update tabs with their icons
5591
- const updatedLayout = {
5592
- ...layout,
5593
- groups: groups.map(group => ({
5594
- ...group,
5595
- tabs: group.tabs.map(tab => ({
5596
- ...tab,
5597
- icon: newFileIconCache[tab.uri || '']
5598
- }))
5599
- }))
5600
- };
5601
5649
  return {
5602
5650
  fileIconCache: newFileIconCache,
5603
- updatedLayout
5651
+ updatedLayout: updateLayoutIcons(layout, newFileIconCache, false)
5604
5652
  };
5605
5653
  } catch {
5606
- // If icon request fails, continue without icons
5607
5654
  return {
5608
5655
  fileIconCache,
5609
- updatedLayout: layout
5656
+ updatedLayout: updateLayoutIcons(layout, fileIconCache, true)
5610
5657
  };
5611
5658
  }
5612
5659
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.54.0",
3
+ "version": "9.54.2",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",