@lvce-editor/main-area-worker 9.37.3 → 9.37.4

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.
@@ -1468,8 +1468,12 @@ const SetPatches = 'Viewlet.setPatches';
1468
1468
  const FocusEditorText = 12;
1469
1469
 
1470
1470
  const {
1471
+ invoke: invoke$3,
1471
1472
  set: set$4
1472
1473
  } = create$4(ClipBoardWorker);
1474
+ const writeText = async text => {
1475
+ return invoke$3('ClipBoard.writeText', text);
1476
+ };
1473
1477
 
1474
1478
  const {
1475
1479
  invoke: invoke$2,
@@ -1578,9 +1582,6 @@ const confirm$1 = async (message, options) => {
1578
1582
  const result = await invoke('ConfirmPrompt.prompt', message, options);
1579
1583
  return result;
1580
1584
  };
1581
- const writeClipBoardText = async text => {
1582
- await invoke('ClipBoard.writeText', /* text */text);
1583
- };
1584
1585
 
1585
1586
  const toCommandId = key => {
1586
1587
  const dotIndex = key.indexOf('.');
@@ -1873,7 +1874,7 @@ const withGroupsAndActiveGroup = (state, groups, activeGroupId) => {
1873
1874
  };
1874
1875
 
1875
1876
  const withEmptyGroups = state => {
1876
- return withGroupsAndActiveGroup(state, [], undefined);
1877
+ return withGroupsAndActiveGroup(state, [], -1);
1877
1878
  };
1878
1879
 
1879
1880
  const withGroups = (state, groups) => {
@@ -1924,7 +1925,7 @@ const closeTab = (state, groupId, tabId) => {
1924
1925
  if (newTabs.length > 0) {
1925
1926
  newActiveTabId = newTabs[Math.min(tabIndex, newTabs.length - 1)].id;
1926
1927
  } else {
1927
- newActiveTabId = undefined;
1928
+ newActiveTabId = -1;
1928
1929
  }
1929
1930
  }
1930
1931
  return {
@@ -1945,7 +1946,7 @@ const closeTab = (state, groupId, tabId) => {
1945
1946
  // If there are remaining groups, redistribute sizes
1946
1947
  if (remainingGroups.length > 0) {
1947
1948
  const redistributedGroups = redistributeSizesWithRounding(remainingGroups);
1948
- const newActiveGroupId = activeGroupId === groupId ? remainingGroups[0]?.id : activeGroupId;
1949
+ const newActiveGroupId = activeGroupId === groupId ? remainingGroups[0]?.id ?? -1 : activeGroupId;
1949
1950
  return withGroupsAndActiveGroup(stateWithClosedTab, redistributedGroups, newActiveGroupId);
1950
1951
  }
1951
1952
 
@@ -1969,8 +1970,12 @@ const getTitle$1 = async editorUid => {
1969
1970
  return undefined;
1970
1971
  }
1971
1972
  };
1972
- const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) => {
1973
- await invoke('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
1973
+ const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri, args) => {
1974
+ if (args === undefined) {
1975
+ await invoke('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
1976
+ } else {
1977
+ await invoke('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri, args);
1978
+ }
1974
1979
  return getTitle$1(editorUid);
1975
1980
  };
1976
1981
 
@@ -2460,6 +2465,9 @@ const closeTabAndSave = async (state, groupId, tabId) => {
2460
2465
  return closeTabWithViewlet(state, groupId, tabId);
2461
2466
  };
2462
2467
 
2468
+ const isFocused$1 = group => {
2469
+ return group.focused;
2470
+ };
2463
2471
  const getFocusedGroup = state => {
2464
2472
  const {
2465
2473
  layout
@@ -2467,7 +2475,7 @@ const getFocusedGroup = state => {
2467
2475
  const {
2468
2476
  groups
2469
2477
  } = layout;
2470
- return groups.find(group => group.focused);
2478
+ return groups.find(isFocused$1);
2471
2479
  };
2472
2480
 
2473
2481
  const closeActiveEditor = async state => {
@@ -2478,7 +2486,7 @@ const closeActiveEditor = async state => {
2478
2486
  const {
2479
2487
  activeTabId
2480
2488
  } = focusedGroup;
2481
- if (activeTabId === undefined) {
2489
+ if (activeTabId === -1) {
2482
2490
  return state;
2483
2491
  }
2484
2492
  return closeTabAndSave(state, focusedGroup.id, activeTabId);
@@ -2563,7 +2571,7 @@ const closeFocusedTab = async state => {
2563
2571
  const {
2564
2572
  activeTabId
2565
2573
  } = focusedGroup;
2566
- if (activeTabId === undefined) {
2574
+ if (activeTabId === -1) {
2567
2575
  return state;
2568
2576
  }
2569
2577
  return closeTabAndSave(state, focusedGroup.id, activeTabId);
@@ -2578,7 +2586,7 @@ const closeOtherTabs = (state, groupId) => {
2578
2586
  groups
2579
2587
  } = layout;
2580
2588
  const targetGroupId = groupId ?? activeGroupId;
2581
- if (targetGroupId === undefined) {
2589
+ if (targetGroupId === -1) {
2582
2590
  return state;
2583
2591
  }
2584
2592
  const group = groups.find(g => g.id === targetGroupId);
@@ -2588,7 +2596,7 @@ const closeOtherTabs = (state, groupId) => {
2588
2596
  const {
2589
2597
  activeTabId
2590
2598
  } = group;
2591
- if (activeTabId === undefined) {
2599
+ if (activeTabId === -1) {
2592
2600
  return state;
2593
2601
  }
2594
2602
  const closedTabs = group.tabs.map((tab, tabIndex) => ({
@@ -2619,15 +2627,15 @@ const closeOtherTabs = (state, groupId) => {
2619
2627
  };
2620
2628
 
2621
2629
  const getNextActiveTabId = (tabs, newTabs, activeTabId) => {
2622
- if (activeTabId === undefined) {
2623
- return undefined;
2630
+ if (activeTabId === -1) {
2631
+ return -1;
2624
2632
  }
2625
2633
  if (newTabs.some(tab => tab.id === activeTabId)) {
2626
2634
  return activeTabId;
2627
2635
  }
2628
2636
  const activeTabIndex = tabs.findIndex(tab => tab.id === activeTabId);
2629
2637
  if (activeTabIndex === -1 || newTabs.length === 0) {
2630
- return undefined;
2638
+ return -1;
2631
2639
  }
2632
2640
  return newTabs[Math.min(activeTabIndex, newTabs.length - 1)].id;
2633
2641
  };
@@ -2720,7 +2728,7 @@ const closeTabsRight = (state, groupId) => {
2720
2728
  activeTabId,
2721
2729
  tabs
2722
2730
  } = group;
2723
- if (activeTabId === undefined) {
2731
+ if (activeTabId === -1) {
2724
2732
  return state;
2725
2733
  }
2726
2734
  const activeTabIndex = tabs.findIndex(tab => tab.id === activeTabId);
@@ -2768,14 +2776,14 @@ const copyIntoNewWindow$1 = async state => {
2768
2776
  const {
2769
2777
  activeGroupId
2770
2778
  } = layout;
2771
- const group = findGroupById(state, activeGroupId ?? 0);
2779
+ const group = findGroupById(state, activeGroupId);
2772
2780
  if (!group) {
2773
2781
  return state;
2774
2782
  }
2775
2783
  const {
2776
2784
  activeTabId
2777
2785
  } = group;
2778
- if (activeTabId === undefined) {
2786
+ if (activeTabId === -1) {
2779
2787
  return state;
2780
2788
  }
2781
2789
  const tab = group.tabs.find(tab => tab.id === activeTabId);
@@ -2788,15 +2796,14 @@ const copyIntoNewWindow$1 = async state => {
2788
2796
 
2789
2797
  const copyPath$1 = async (state, path) => {
2790
2798
  string(path);
2791
- await writeClipBoardText(path);
2799
+ await writeText(path);
2792
2800
  return state;
2793
2801
  };
2794
2802
 
2795
2803
  const copyRelativePath$1 = async (state, path) => {
2796
2804
  string(path);
2797
- // TODO use clipboard worker
2798
2805
  const relativePath = await invoke('Workspace.pathBaseName', path);
2799
- await invoke('ClipBoard.writeText', relativePath);
2806
+ await writeText(relativePath);
2800
2807
  return state;
2801
2808
  };
2802
2809
 
@@ -2828,7 +2835,7 @@ const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
2828
2835
  iframes: [],
2829
2836
  initial: true,
2830
2837
  layout: {
2831
- activeGroupId: undefined,
2838
+ activeGroupId: -1,
2832
2839
  direction: Horizontal,
2833
2840
  groups: []
2834
2841
  },
@@ -3926,7 +3933,7 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
3926
3933
  activeGroupId,
3927
3934
  groups
3928
3935
  } = layout;
3929
- const activeGroup = activeGroupId === undefined ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
3936
+ const activeGroup = activeGroupId === -1 ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
3930
3937
 
3931
3938
  // Generate a request ID for content loading
3932
3939
  const requestId = getNextRequestId();
@@ -4216,7 +4223,7 @@ const getActivePreviewEditorUid = state => {
4216
4223
  activeGroupId,
4217
4224
  groups
4218
4225
  } = layout;
4219
- const activeGroup = activeGroupId === undefined ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
4226
+ const activeGroup = activeGroupId === -1 ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
4220
4227
  const activeTab = activeGroup?.tabs.find(tab => tab.id === activeGroup.activeTabId);
4221
4228
  return activeTab?.isPreview ? activeTab.editorUid : -1;
4222
4229
  };
@@ -4292,7 +4299,7 @@ const openInputWithContext = async (context, options) => {
4292
4299
  if (editorUid === -1) {
4293
4300
  throw new Error('invalid editorUid');
4294
4301
  }
4295
- const renderedTitle = await createViewlet(viewletModuleId, editorUid, tabId, bounds, uri);
4302
+ const renderedTitle = await createViewlet(viewletModuleId, editorUid, tabId, bounds, uri, options.args);
4296
4303
  const latestState = context.getState();
4297
4304
  const readyState = handleViewletReady(latestState, editorUid, renderedTitle);
4298
4305
  await context.updateState(() => readyState);
@@ -4336,20 +4343,31 @@ const getOptionUriOptions = options => {
4336
4343
  return options.uri;
4337
4344
  };
4338
4345
 
4339
- const getOpenInputOptions = options => {
4346
+ const getViewletContext = (options, viewletContext) => {
4347
+ if (viewletContext !== undefined || typeof options === 'string') {
4348
+ return viewletContext;
4349
+ }
4350
+ const context = Object.fromEntries(Object.entries(options).filter(([key]) => key !== 'focus' && key !== 'preview' && key !== 'uri'));
4351
+ return Object.keys(context).length === 0 ? undefined : context;
4352
+ };
4353
+ const getOpenInputOptions = (options, focus = true, viewletContext) => {
4340
4354
  const uri = getOptionUriOptions(options);
4341
4355
  const preview = typeof options === 'string' ? false : options.preview ?? false;
4356
+ const context = getViewletContext(options, viewletContext);
4342
4357
  return {
4358
+ ...(context !== undefined && {
4359
+ args: [context]
4360
+ }),
4343
4361
  editorInput: getNormalizedOpenEditorInput(uri),
4344
- focus: typeof options === 'string' ? false : options.focus,
4362
+ focus: typeof options === 'string' ? focus : options.focus,
4345
4363
  preview
4346
4364
  };
4347
4365
  };
4348
- const openUri = async (state, options) => {
4349
- return openInput(state, getOpenInputOptions(options));
4366
+ const openUri = async (state, options, focus = true, viewletContext) => {
4367
+ return openInput(state, getOpenInputOptions(options, focus, viewletContext));
4350
4368
  };
4351
- const openUriWithContext = async (context, options) => {
4352
- await openInputWithContext(context, getOpenInputOptions(options));
4369
+ const openUriWithContext = async (context, options, focus = true, viewletContext) => {
4370
+ await openInputWithContext(context, getOpenInputOptions(options, focus, viewletContext));
4353
4371
  };
4354
4372
 
4355
4373
  const retryOpen = async state => {
@@ -4552,7 +4570,7 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
4552
4570
  const newGroupId = create$2();
4553
4571
  const splitLayoutDirection = getSplitLayoutDirection(direction);
4554
4572
  const baseNewGroup = {
4555
- activeTabId: undefined,
4573
+ activeTabId: -1,
4556
4574
  direction: sourceGroup.direction,
4557
4575
  focused: true,
4558
4576
  id: newGroupId,
@@ -4591,7 +4609,7 @@ const handleClickAction = async (state, action, rawGroupId) => {
4591
4609
  if (action === RestoreClosedTab) {
4592
4610
  return restoreClosedTab(state);
4593
4611
  }
4594
- if (activeGroupId === undefined) {
4612
+ if (activeGroupId === -1) {
4595
4613
  return state;
4596
4614
  }
4597
4615
  const activeGroup = getActiveGroup(groups, activeGroupId);
@@ -4854,36 +4872,10 @@ const parseUriList = value => {
4854
4872
  return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
4855
4873
  };
4856
4874
 
4857
- const windowsDriveLetterRegex = /^[a-zA-Z]:\\/;
4858
- const encodeFilePath = path => {
4859
- return encodeURI(path).replaceAll('#', '%23').replaceAll('?', '%3F');
4860
- };
4861
- const toFileUri$1 = path => {
4862
- if (path.startsWith('file://')) {
4863
- return path;
4864
- }
4865
- if (windowsDriveLetterRegex.test(path)) {
4866
- const normalizedPath = path.replaceAll('\\', '/');
4867
- return `file:///${encodeFilePath(normalizedPath)}`;
4868
- }
4869
- return `file://${encodeFilePath(path)}`;
4870
- };
4871
-
4872
4875
  const suffixByHandleKind = {
4873
4876
  directory: '/',
4874
4877
  file: ''
4875
4878
  };
4876
- const getDroppedElectronUris = async (itemIds, files) => {
4877
- if (itemIds.length > 0) {
4878
- await getFileHandles(itemIds);
4879
- }
4880
- const uris = [];
4881
- for (const file of files) {
4882
- const path = await invoke('FileSystemHandle.getFilePathElectron', file);
4883
- uris.push(toFileUri$1(path));
4884
- }
4885
- return uris;
4886
- };
4887
4879
  const getDroppedBrowserUris = async itemIds => {
4888
4880
  if (itemIds.length === 0) {
4889
4881
  return [];
@@ -4924,6 +4916,34 @@ const getDroppedBrowserUris = async itemIds => {
4924
4916
  }
4925
4917
  return uris;
4926
4918
  };
4919
+
4920
+ const windowsDriveLetterRegex = /^[a-zA-Z]:\\/;
4921
+ const encodeFilePath = path => {
4922
+ return encodeURI(path).replaceAll('#', '%23').replaceAll('?', '%3F');
4923
+ };
4924
+ const toFileUri$1 = path => {
4925
+ if (path.startsWith('file://')) {
4926
+ return path;
4927
+ }
4928
+ if (windowsDriveLetterRegex.test(path)) {
4929
+ const normalizedPath = path.replaceAll('\\', '/');
4930
+ return `file:///${encodeFilePath(normalizedPath)}`;
4931
+ }
4932
+ return `file://${encodeFilePath(path)}`;
4933
+ };
4934
+
4935
+ const getDroppedElectronUris = async (itemIds, files) => {
4936
+ if (itemIds.length > 0) {
4937
+ await getFileHandles(itemIds);
4938
+ }
4939
+ const uris = [];
4940
+ for (const file of files) {
4941
+ const path = await invoke('FileSystemHandle.getFilePathElectron', file);
4942
+ uris.push(toFileUri$1(path));
4943
+ }
4944
+ return uris;
4945
+ };
4946
+
4927
4947
  const getDroppedUris = async (itemIds, files = [], platform = Web) => {
4928
4948
  if (platform === Electron && files.length > 0) {
4929
4949
  return getDroppedElectronUris(itemIds, files);
@@ -5006,7 +5026,7 @@ const newFile = async state => {
5006
5026
  } = layout;
5007
5027
 
5008
5028
  // Find the active group
5009
- const activeGroup = activeGroupId === undefined ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
5029
+ const activeGroup = activeGroupId === -1 ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
5010
5030
 
5011
5031
  // Prepare initial state
5012
5032
  let newState = state;
@@ -5031,7 +5051,7 @@ const newFile = async state => {
5031
5051
  if (group.id === targetGroupId) {
5032
5052
  return {
5033
5053
  ...group,
5034
- activeTabId: undefined,
5054
+ activeTabId: -1,
5035
5055
  tabs: []
5036
5056
  };
5037
5057
  }
@@ -5640,7 +5660,7 @@ const isValidTab = tab => {
5640
5660
  };
5641
5661
 
5642
5662
  const isValidEditorGroup = group => {
5643
- return group && typeof group.id === 'number' && Array.isArray(group.tabs) && group.tabs.every(isValidTab) && (group.activeTabId === undefined || typeof group.activeTabId === 'number') && isLayoutDirection(group.direction) && typeof group.focused === 'boolean' && (group.segmentId === undefined || typeof group.segmentId === 'number') && typeof group.size === 'number' && group.size > 0 && typeof group.isEmpty === 'boolean';
5663
+ return group && typeof group.id === 'number' && Array.isArray(group.tabs) && group.tabs.every(isValidTab) && typeof group.activeTabId === 'number' && isLayoutDirection(group.direction) && typeof group.focused === 'boolean' && (group.segmentId === undefined || typeof group.segmentId === 'number') && typeof group.size === 'number' && group.size > 0 && typeof group.isEmpty === 'boolean';
5644
5664
  };
5645
5665
 
5646
5666
  const isValidMainAreaLayout = layout => {
@@ -5648,7 +5668,7 @@ const isValidMainAreaLayout = layout => {
5648
5668
  return false;
5649
5669
  }
5650
5670
  const layoutObj = layout;
5651
- if (layoutObj.activeGroupId !== undefined && typeof layoutObj.activeGroupId !== 'number') {
5671
+ if (typeof layoutObj.activeGroupId !== 'number') {
5652
5672
  return false;
5653
5673
  }
5654
5674
  if (!isLayoutDirection(layoutObj.direction)) {
@@ -5709,11 +5729,13 @@ const tryRestoreLayout = savedState => {
5709
5729
  // Mark all restored tabs as not dirty
5710
5730
  const normalizedLayout = {
5711
5731
  ...rawLayout,
5732
+ activeGroupId: rawLayout.activeGroupId === undefined ? -1 : rawLayout.activeGroupId,
5712
5733
  direction: layoutDirection,
5713
5734
  groups: rawLayout.groups.map(group => {
5714
5735
  const groupDirection = normalizeGroupDirection(group, layoutDirection);
5715
5736
  return {
5716
5737
  ...group,
5738
+ activeTabId: group?.activeTabId === undefined ? -1 : group.activeTabId,
5717
5739
  direction: groupDirection,
5718
5740
  tabs: Array.isArray(group?.tabs) ? group.tabs.map(normalizeRestoredTab) : []
5719
5741
  };
@@ -5878,7 +5900,7 @@ const loadContent$1 = async (state, savedState) => {
5878
5900
  ...stateWithHomeDir,
5879
5901
  initial: false,
5880
5902
  layout: {
5881
- activeGroupId: undefined,
5903
+ activeGroupId: -1,
5882
5904
  direction: Horizontal,
5883
5905
  groups: []
5884
5906
  }
@@ -6286,14 +6308,14 @@ const moveIntoNewWindow = async state => {
6286
6308
  const {
6287
6309
  activeGroupId
6288
6310
  } = layout;
6289
- const group = findGroupById(state, activeGroupId ?? 0);
6311
+ const group = findGroupById(state, activeGroupId);
6290
6312
  if (!group) {
6291
6313
  return state;
6292
6314
  }
6293
6315
  const {
6294
6316
  activeTabId
6295
6317
  } = group;
6296
- if (activeTabId === undefined) {
6318
+ if (activeTabId === -1) {
6297
6319
  return state;
6298
6320
  }
6299
6321
  const tab = group.tabs.find(tab => tab.id === activeTabId);
@@ -6437,16 +6459,19 @@ const getSashCss = (layout, width = 0) => {
6437
6459
  return getProtoSashCss(layout, width).map(renderSashCss);
6438
6460
  };
6439
6461
 
6462
+ const getSashCornerCss = (left, top) => {
6463
+ return `.SashCorner {
6464
+ left: ${left}%;
6465
+ top: ${top}%;
6466
+ }`;
6467
+ };
6440
6468
  const getCss = (layout, width = 0, dragOverlay) => {
6441
6469
  const rules = [];
6442
6470
  if (layout) {
6443
6471
  rules.push(...getEditorGroupCss(layout), ...getDragOverlayCss(dragOverlay), ...getSashCss(layout, width));
6444
6472
  const sashCorner = getSashCorner(layout);
6445
6473
  if (sashCorner) {
6446
- rules.push(`.SashCorner {
6447
- left: ${sashCorner.leftOffset}%;
6448
- top: ${sashCorner.topOffset}%;
6449
- }`);
6474
+ rules.push(getSashCornerCss(sashCorner.leftOffset, sashCorner.topOffset));
6450
6475
  }
6451
6476
  }
6452
6477
  const css = rules.join('\n');
@@ -7594,7 +7619,7 @@ const getSavedTab = tab => {
7594
7619
  const getFilteredGroups = groups => {
7595
7620
  return groups.map(group => {
7596
7621
  const tabs = group.tabs.filter(tab => !tab.uri?.startsWith('untitled://')).map(getSavedTab);
7597
- const activeTabId = tabs.some(tab => tab.id === group.activeTabId) ? group.activeTabId : tabs[0]?.id;
7622
+ const activeTabId = tabs.some(tab => tab.id === group.activeTabId) ? group.activeTabId : tabs[0]?.id ?? -1;
7598
7623
  return {
7599
7624
  ...group,
7600
7625
  activeTabId,
@@ -7617,7 +7642,7 @@ const saveState = state => {
7617
7642
  const {
7618
7643
  activeGroupId: originalActiveGroupId
7619
7644
  } = layout;
7620
- const activeGroupId = originalActiveGroupId !== undefined && filteredGroups.every(g => g.id !== originalActiveGroupId) ? undefined : originalActiveGroupId;
7645
+ const activeGroupId = originalActiveGroupId !== -1 && filteredGroups.every(g => g.id !== originalActiveGroupId) ? -1 : originalActiveGroupId;
7621
7646
  return {
7622
7647
  layout: {
7623
7648
  ...layout,
@@ -7632,7 +7657,7 @@ const flipDirection = direction => {
7632
7657
  };
7633
7658
  const createEmptyGroup = direction => {
7634
7659
  return {
7635
- activeTabId: undefined,
7660
+ activeTabId: -1,
7636
7661
  direction,
7637
7662
  focused: false,
7638
7663
  id: create$2(),
@@ -7655,8 +7680,8 @@ const getActiveGroupIndex = (groups, activeGroupId) => {
7655
7680
  const mergeGroups = (target, groups, activeGroupId) => {
7656
7681
  const allGroups = [target, ...groups];
7657
7682
  const tabs = allGroups.flatMap(group => group.tabs);
7658
- const activeGroup = allGroups.find(group => group.id === activeGroupId) ?? groups.findLast(group => group.activeTabId !== undefined) ?? target;
7659
- const activeTabId = activeGroup.activeTabId ?? tabs[0]?.id;
7683
+ const activeGroup = allGroups.find(group => group.id === activeGroupId) ?? groups.findLast(group => group.activeTabId !== -1) ?? target;
7684
+ const activeTabId = activeGroup.activeTabId === -1 ? tabs[0]?.id ?? -1 : activeGroup.activeTabId;
7660
7685
  return {
7661
7686
  ...target,
7662
7687
  activeTabId,
@@ -7711,7 +7736,7 @@ const setEditorLayout = (state, direction, slots) => {
7711
7736
  return {
7712
7737
  ...state,
7713
7738
  layout: {
7714
- activeGroupId: nextGroups[activeIndex]?.id,
7739
+ activeGroupId: nextGroups[activeIndex]?.id ?? -1,
7715
7740
  direction,
7716
7741
  groups: nextGroups
7717
7742
  }
@@ -7851,7 +7876,7 @@ const splitDown = (state, groupId) => {
7851
7876
  if (groups.length === 0) {
7852
7877
  const initialGroupId = create$2();
7853
7878
  const initialGroup = {
7854
- activeTabId: undefined,
7879
+ activeTabId: -1,
7855
7880
  direction,
7856
7881
  focused: true,
7857
7882
  id: initialGroupId,
@@ -7888,7 +7913,7 @@ const splitLeft = (state, groupId) => {
7888
7913
  if (groups.length === 0) {
7889
7914
  const initialGroupId = create$2();
7890
7915
  const initialGroup = {
7891
- activeTabId: undefined,
7916
+ activeTabId: -1,
7892
7917
  direction,
7893
7918
  focused: true,
7894
7919
  id: initialGroupId,
@@ -7906,7 +7931,7 @@ const splitLeft = (state, groupId) => {
7906
7931
  };
7907
7932
  return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, Left$1);
7908
7933
  }
7909
- const targetGroupId = groupId ?? activeGroupId ?? groups[0]?.id ?? 0;
7934
+ const targetGroupId = groupId ?? (activeGroupId === -1 ? groups[0]?.id : activeGroupId) ?? 0;
7910
7935
  return splitEditorGroup$1(state, targetGroupId, Left$1);
7911
7936
  };
7912
7937
 
@@ -7924,7 +7949,7 @@ const splitRight = (state, groupId) => {
7924
7949
  if (groups.length === 0) {
7925
7950
  const initialGroupId = create$2();
7926
7951
  const initialGroup = {
7927
- activeTabId: undefined,
7952
+ activeTabId: -1,
7928
7953
  direction,
7929
7954
  focused: true,
7930
7955
  id: initialGroupId,
@@ -7942,7 +7967,7 @@ const splitRight = (state, groupId) => {
7942
7967
  };
7943
7968
  return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, Right$1);
7944
7969
  }
7945
- const targetGroupId = groupId ?? activeGroupId ?? groups[0]?.id ?? 0;
7970
+ const targetGroupId = groupId ?? (activeGroupId === -1 ? groups[0]?.id : activeGroupId) ?? 0;
7946
7971
  return splitEditorGroup$1(state, targetGroupId, Right$1);
7947
7972
  };
7948
7973
 
@@ -7958,7 +7983,7 @@ const splitUp = (state, groupId) => {
7958
7983
  if (groups.length === 0) {
7959
7984
  const initialGroupId = create$2();
7960
7985
  const initialGroup = {
7961
- activeTabId: undefined,
7986
+ activeTabId: -1,
7962
7987
  direction,
7963
7988
  focused: true,
7964
7989
  id: initialGroupId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.37.3",
3
+ "version": "9.37.4",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",