@lvce-editor/main-area-worker 9.12.0 → 9.13.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.
@@ -1928,6 +1928,99 @@ const diff2 = uid => {
1928
1928
  return result;
1929
1929
  };
1930
1930
 
1931
+ const getActiveTabId$1 = state => {
1932
+ const {
1933
+ layout
1934
+ } = state;
1935
+ const {
1936
+ activeGroupId,
1937
+ groups
1938
+ } = layout;
1939
+ const activeGroup = groups.find(group => group.id === activeGroupId);
1940
+ return activeGroup?.activeTabId;
1941
+ };
1942
+
1943
+ const getSelectedTabBounds = state => {
1944
+ return {
1945
+ height: state.height - state.tabHeight,
1946
+ width: state.width,
1947
+ x: state.x,
1948
+ y: state.y + state.tabHeight
1949
+ };
1950
+ };
1951
+
1952
+ const getSelectedTabData = (state, groupIndex, index) => {
1953
+ const group = state.layout.groups[groupIndex];
1954
+ if (!group || index < 0 || index >= group.tabs.length) {
1955
+ return undefined;
1956
+ }
1957
+ const tab = group.tabs[index];
1958
+ return {
1959
+ group,
1960
+ groupId: group.id,
1961
+ tab,
1962
+ tabId: tab.id
1963
+ };
1964
+ };
1965
+
1966
+ const getUpdatedGroups = (groups, groupIndex, needsLoading, tabId) => {
1967
+ return groups.map((group, index) => {
1968
+ if (index !== groupIndex) {
1969
+ return {
1970
+ ...group,
1971
+ focused: false
1972
+ };
1973
+ }
1974
+ const tabs = needsLoading ? group.tabs.map(tab => {
1975
+ if (tab.id !== tabId) {
1976
+ return tab;
1977
+ }
1978
+ return {
1979
+ ...tab,
1980
+ errorMessage: '',
1981
+ loadingState: 'loading'
1982
+ };
1983
+ }) : group.tabs;
1984
+ return {
1985
+ ...group,
1986
+ activeTabId: tabId,
1987
+ focused: true,
1988
+ tabs
1989
+ };
1990
+ });
1991
+ };
1992
+
1993
+ const getViewletModuleId$1 = async uri => {
1994
+ // Query RendererWorker for viewlet module ID (optional, may fail in tests)
1995
+ let viewletModuleId;
1996
+ try {
1997
+ viewletModuleId = await invoke('Layout.getModuleId', uri);
1998
+ } catch {
1999
+ // Viewlet creation is optional - silently ignore if RendererWorker isn't available
2000
+ }
2001
+ return viewletModuleId;
2002
+ };
2003
+
2004
+ const DiffEditor = 'DiffEditor';
2005
+ const EditorText = 'Editor';
2006
+ const ExtensionDetail = 'ExtensionDetail';
2007
+ const QuickPick = 'QuickPick';
2008
+
2009
+ const getViewletModuleIdForEditorInput = async editorInput => {
2010
+ switch (editorInput.type) {
2011
+ case 'diff-editor':
2012
+ return DiffEditor;
2013
+ case 'editor':
2014
+ return getViewletModuleId$1(editorInput.uri);
2015
+ case 'extension-detail-view':
2016
+ return ExtensionDetail;
2017
+ }
2018
+ };
2019
+
2020
+ const getViewletModuleId = async tab => {
2021
+ return tab.editorInput ? getViewletModuleIdForEditorInput(tab.editorInput) : invoke('Layout.getModuleId', tab.uri);
2022
+ };
2023
+
1931
2024
  const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) => {
1932
2025
  await invoke('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
1933
2026
  };
@@ -2207,55 +2300,6 @@ const findTabById = (state, tabId) => {
2207
2300
  return undefined;
2208
2301
  };
2209
2302
 
2210
- // Counter for request IDs to handle race conditions
2211
- let requestIdCounter = 0;
2212
- const getNextRequestId = () => {
2213
- return ++requestIdCounter;
2214
- };
2215
-
2216
- const getViewletModuleId$1 = async uri => {
2217
- // Query RendererWorker for viewlet module ID (optional, may fail in tests)
2218
- let viewletModuleId;
2219
- try {
2220
- viewletModuleId = await invoke('Layout.getModuleId', uri);
2221
- } catch {
2222
- // Viewlet creation is optional - silently ignore if RendererWorker isn't available
2223
- }
2224
- return viewletModuleId;
2225
- };
2226
-
2227
- const DiffEditor = 'DiffEditor';
2228
- const EditorText = 'Editor';
2229
- const ExtensionDetail = 'ExtensionDetail';
2230
- const QuickPick = 'QuickPick';
2231
-
2232
- const getViewletModuleIdForEditorInput = async editorInput => {
2233
- switch (editorInput.type) {
2234
- case 'diff-editor':
2235
- return DiffEditor;
2236
- case 'editor':
2237
- return getViewletModuleId$1(editorInput.uri);
2238
- case 'extension-detail-view':
2239
- return ExtensionDetail;
2240
- }
2241
- };
2242
-
2243
- const shouldLoadContentForTab = tab => {
2244
- if (tab.editorInput && tab.editorInput.type !== 'editor') {
2245
- return false;
2246
- }
2247
- if (!tab.uri) {
2248
- return false;
2249
- }
2250
- if (tab.loadingState === 'loading') {
2251
- return false;
2252
- }
2253
- if (tab.loadingState === 'loaded' && tab.editorUid !== -1) {
2254
- return false;
2255
- }
2256
- return true;
2257
- };
2258
-
2259
2303
  const startContentLoading = async (oldState, state, tabId, path, requestId) => {
2260
2304
  try {
2261
2305
  const getLatestState = () => {
@@ -2270,76 +2314,17 @@ const startContentLoading = async (oldState, state, tabId, path, requestId) => {
2270
2314
  return state;
2271
2315
  };
2272
2316
 
2273
- const getActiveTabId$1 = state => {
2274
- const {
2275
- layout
2276
- } = state;
2277
- const {
2278
- activeGroupId,
2279
- groups
2280
- } = layout;
2281
- const activeGroup = groups.find(g => g.id === activeGroupId);
2282
- return activeGroup?.activeTabId;
2283
- };
2284
- const getSelectedTabData = (state, groupIndex, index) => {
2285
- const group = state.layout.groups[groupIndex];
2286
- if (!group || index < 0 || index >= group.tabs.length) {
2287
- return undefined;
2288
- }
2289
- const tab = group.tabs[index];
2290
- return {
2291
- group,
2292
- groupId: group.id,
2293
- tab,
2294
- tabId: tab.id
2295
- };
2296
- };
2297
- const getUpdatedGroups = (groups, groupIndex, needsLoading, tabId) => {
2298
- return groups.map((group, index) => {
2299
- if (index !== groupIndex) {
2300
- return {
2301
- ...group,
2302
- focused: false
2303
- };
2304
- }
2305
- const tabs = needsLoading ? group.tabs.map(tab => {
2306
- if (tab.id !== tabId) {
2307
- return tab;
2308
- }
2309
- return {
2310
- ...tab,
2311
- errorMessage: '',
2312
- loadingState: 'loading'
2313
- };
2314
- }) : group.tabs;
2315
- return {
2316
- ...group,
2317
- activeTabId: tabId,
2318
- focused: true,
2319
- tabs
2320
- };
2321
- });
2322
- };
2323
- const shouldCreateViewletForSelectedTab = tab => {
2324
- return Boolean(tab.uri) && (tab.editorUid === -1 || !tab.loadingState || tab.loadingState === 'loading');
2325
- };
2326
- const getSelectedTabBounds = state => {
2327
- return {
2328
- height: state.height - state.tabHeight,
2329
- width: state.width,
2330
- x: state.x,
2331
- y: state.y + state.tabHeight
2332
- };
2333
- };
2334
- const getViewletModuleId = async tab => {
2335
- return tab.editorInput ? getViewletModuleIdForEditorInput(tab.editorInput) : invoke('Layout.getModuleId', tab.uri);
2336
- };
2337
2317
  const maybeStartLoading = async (state, newState, tabId, tab, needsLoading, requestId) => {
2338
2318
  if (needsLoading && tab.uri) {
2339
2319
  return startContentLoading(state, newState, tabId, tab.uri, requestId);
2340
2320
  }
2341
2321
  return newState;
2342
2322
  };
2323
+
2324
+ const shouldCreateViewletForSelectedTab = tab => {
2325
+ return Boolean(tab.uri) && (tab.editorUid === -1 || !tab.loadingState || tab.loadingState === 'loading');
2326
+ };
2327
+
2343
2328
  const maybeCreateViewletForSelectedTab = async (state, newState, groupIndex, index, tabId, tab, uid, needsLoading, requestId, switchCommands) => {
2344
2329
  const selectedTab = newState.layout.groups[groupIndex].tabs[index];
2345
2330
  if (!shouldCreateViewletForSelectedTab(selectedTab)) {
@@ -2368,6 +2353,29 @@ const maybeCreateViewletForSelectedTab = async (state, newState, groupIndex, ind
2368
2353
  }
2369
2354
  return maybeStartLoading(state, stateWithViewlet, tabId, tab, needsLoading, requestId);
2370
2355
  };
2356
+
2357
+ // Counter for request IDs to handle race conditions
2358
+ let requestIdCounter = 0;
2359
+ const getNextRequestId = () => {
2360
+ return ++requestIdCounter;
2361
+ };
2362
+
2363
+ const shouldLoadContentForTab = tab => {
2364
+ if (tab.editorInput && tab.editorInput.type !== 'editor') {
2365
+ return false;
2366
+ }
2367
+ if (!tab.uri) {
2368
+ return false;
2369
+ }
2370
+ if (tab.loadingState === 'loading') {
2371
+ return false;
2372
+ }
2373
+ if (tab.loadingState === 'loaded' && tab.editorUid !== -1) {
2374
+ return false;
2375
+ }
2376
+ return true;
2377
+ };
2378
+
2371
2379
  const selectTab = async (state, groupIndex, index) => {
2372
2380
  const {
2373
2381
  layout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.12.0",
3
+ "version": "9.13.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",