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

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
 
@@ -1961,7 +1962,7 @@ const handleAttach = async command => {
1961
1962
  await invoke('Layout.attachViewlet', parentNodeSelector, command.instanceId);
1962
1963
  };
1963
1964
 
1964
- const getTitle$1 = async editorUid => {
1965
+ const getViewletTitle = async editorUid => {
1965
1966
  try {
1966
1967
  const title = await invoke('Viewlet.getTitle', editorUid);
1967
1968
  return typeof title === 'string' && title ? title : undefined;
@@ -1969,9 +1970,16 @@ 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);
1974
- return getTitle$1(editorUid);
1973
+ const createViewletContent = 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
+ }
1979
+ };
1980
+ const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri, args) => {
1981
+ await createViewletContent(viewletModuleId, editorUid, tabId, bounds, uri, args);
1982
+ return getViewletTitle(editorUid);
1975
1983
  };
1976
1984
 
1977
1985
  const getActiveFileUri = state => {
@@ -2460,6 +2468,9 @@ const closeTabAndSave = async (state, groupId, tabId) => {
2460
2468
  return closeTabWithViewlet(state, groupId, tabId);
2461
2469
  };
2462
2470
 
2471
+ const isFocused$1 = group => {
2472
+ return group.focused;
2473
+ };
2463
2474
  const getFocusedGroup = state => {
2464
2475
  const {
2465
2476
  layout
@@ -2467,7 +2478,7 @@ const getFocusedGroup = state => {
2467
2478
  const {
2468
2479
  groups
2469
2480
  } = layout;
2470
- return groups.find(group => group.focused);
2481
+ return groups.find(isFocused$1);
2471
2482
  };
2472
2483
 
2473
2484
  const closeActiveEditor = async state => {
@@ -2478,7 +2489,7 @@ const closeActiveEditor = async state => {
2478
2489
  const {
2479
2490
  activeTabId
2480
2491
  } = focusedGroup;
2481
- if (activeTabId === undefined) {
2492
+ if (activeTabId === -1) {
2482
2493
  return state;
2483
2494
  }
2484
2495
  return closeTabAndSave(state, focusedGroup.id, activeTabId);
@@ -2563,7 +2574,7 @@ const closeFocusedTab = async state => {
2563
2574
  const {
2564
2575
  activeTabId
2565
2576
  } = focusedGroup;
2566
- if (activeTabId === undefined) {
2577
+ if (activeTabId === -1) {
2567
2578
  return state;
2568
2579
  }
2569
2580
  return closeTabAndSave(state, focusedGroup.id, activeTabId);
@@ -2578,7 +2589,7 @@ const closeOtherTabs = (state, groupId) => {
2578
2589
  groups
2579
2590
  } = layout;
2580
2591
  const targetGroupId = groupId ?? activeGroupId;
2581
- if (targetGroupId === undefined) {
2592
+ if (targetGroupId === -1) {
2582
2593
  return state;
2583
2594
  }
2584
2595
  const group = groups.find(g => g.id === targetGroupId);
@@ -2588,7 +2599,7 @@ const closeOtherTabs = (state, groupId) => {
2588
2599
  const {
2589
2600
  activeTabId
2590
2601
  } = group;
2591
- if (activeTabId === undefined) {
2602
+ if (activeTabId === -1) {
2592
2603
  return state;
2593
2604
  }
2594
2605
  const closedTabs = group.tabs.map((tab, tabIndex) => ({
@@ -2619,15 +2630,15 @@ const closeOtherTabs = (state, groupId) => {
2619
2630
  };
2620
2631
 
2621
2632
  const getNextActiveTabId = (tabs, newTabs, activeTabId) => {
2622
- if (activeTabId === undefined) {
2623
- return undefined;
2633
+ if (activeTabId === -1) {
2634
+ return -1;
2624
2635
  }
2625
2636
  if (newTabs.some(tab => tab.id === activeTabId)) {
2626
2637
  return activeTabId;
2627
2638
  }
2628
2639
  const activeTabIndex = tabs.findIndex(tab => tab.id === activeTabId);
2629
2640
  if (activeTabIndex === -1 || newTabs.length === 0) {
2630
- return undefined;
2641
+ return -1;
2631
2642
  }
2632
2643
  return newTabs[Math.min(activeTabIndex, newTabs.length - 1)].id;
2633
2644
  };
@@ -2720,7 +2731,7 @@ const closeTabsRight = (state, groupId) => {
2720
2731
  activeTabId,
2721
2732
  tabs
2722
2733
  } = group;
2723
- if (activeTabId === undefined) {
2734
+ if (activeTabId === -1) {
2724
2735
  return state;
2725
2736
  }
2726
2737
  const activeTabIndex = tabs.findIndex(tab => tab.id === activeTabId);
@@ -2768,14 +2779,14 @@ const copyIntoNewWindow$1 = async state => {
2768
2779
  const {
2769
2780
  activeGroupId
2770
2781
  } = layout;
2771
- const group = findGroupById(state, activeGroupId ?? 0);
2782
+ const group = findGroupById(state, activeGroupId);
2772
2783
  if (!group) {
2773
2784
  return state;
2774
2785
  }
2775
2786
  const {
2776
2787
  activeTabId
2777
2788
  } = group;
2778
- if (activeTabId === undefined) {
2789
+ if (activeTabId === -1) {
2779
2790
  return state;
2780
2791
  }
2781
2792
  const tab = group.tabs.find(tab => tab.id === activeTabId);
@@ -2788,15 +2799,14 @@ const copyIntoNewWindow$1 = async state => {
2788
2799
 
2789
2800
  const copyPath$1 = async (state, path) => {
2790
2801
  string(path);
2791
- await writeClipBoardText(path);
2802
+ await writeText(path);
2792
2803
  return state;
2793
2804
  };
2794
2805
 
2795
2806
  const copyRelativePath$1 = async (state, path) => {
2796
2807
  string(path);
2797
- // TODO use clipboard worker
2798
2808
  const relativePath = await invoke('Workspace.pathBaseName', path);
2799
- await invoke('ClipBoard.writeText', relativePath);
2809
+ await writeText(relativePath);
2800
2810
  return state;
2801
2811
  };
2802
2812
 
@@ -2828,7 +2838,7 @@ const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
2828
2838
  iframes: [],
2829
2839
  initial: true,
2830
2840
  layout: {
2831
- activeGroupId: undefined,
2841
+ activeGroupId: -1,
2832
2842
  direction: Horizontal,
2833
2843
  groups: []
2834
2844
  },
@@ -3926,7 +3936,7 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
3926
3936
  activeGroupId,
3927
3937
  groups
3928
3938
  } = layout;
3929
- const activeGroup = activeGroupId === undefined ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
3939
+ const activeGroup = activeGroupId === -1 ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
3930
3940
 
3931
3941
  // Generate a request ID for content loading
3932
3942
  const requestId = getNextRequestId();
@@ -4201,6 +4211,13 @@ const updateTabIcon = async (context, readyState, tabId) => {
4201
4211
  }
4202
4212
  };
4203
4213
 
4214
+ const renderMainAreaPending = async uid => {
4215
+ try {
4216
+ await invoke('Layout.renderMainAreaPending', uid);
4217
+ } catch {
4218
+ // Older renderer workers render the final state when openInput completes.
4219
+ }
4220
+ };
4204
4221
  const getExistingTabState = (state, existingTab, preview) => {
4205
4222
  const focusedState = focusEditorGroup(state, existingTab.groupId);
4206
4223
  const pinnedState = !preview && existingTab.tab.isPreview ? updateTab(focusedState, existingTab.tab.id, {
@@ -4216,7 +4233,7 @@ const getActivePreviewEditorUid = state => {
4216
4233
  activeGroupId,
4217
4234
  groups
4218
4235
  } = layout;
4219
- const activeGroup = activeGroupId === undefined ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
4236
+ const activeGroup = activeGroupId === -1 ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
4220
4237
  const activeTab = activeGroup?.tabs.find(tab => tab.id === activeGroup.activeTabId);
4221
4238
  return activeTab?.isPreview ? activeTab.editorUid : -1;
4222
4239
  };
@@ -4292,10 +4309,16 @@ const openInputWithContext = async (context, options) => {
4292
4309
  if (editorUid === -1) {
4293
4310
  throw new Error('invalid editorUid');
4294
4311
  }
4295
- const renderedTitle = await createViewlet(viewletModuleId, editorUid, tabId, bounds, uri);
4312
+ await createViewletContent(viewletModuleId, editorUid, tabId, bounds, uri, options.args);
4296
4313
  const latestState = context.getState();
4297
- const readyState = handleViewletReady(latestState, editorUid, renderedTitle);
4314
+ let readyState = handleViewletReady(latestState, editorUid);
4298
4315
  await context.updateState(() => readyState);
4316
+ await renderMainAreaPending(state.uid);
4317
+ const renderedTitle = await getViewletTitle(editorUid);
4318
+ if (renderedTitle) {
4319
+ readyState = handleViewletReady(context.getState(), editorUid, renderedTitle);
4320
+ await context.updateState(() => readyState);
4321
+ }
4299
4322
  const stateWithIcon = await updateTabIcon(context, readyState, tabId);
4300
4323
  if (stateWithIcon) {
4301
4324
  return;
@@ -4336,20 +4359,31 @@ const getOptionUriOptions = options => {
4336
4359
  return options.uri;
4337
4360
  };
4338
4361
 
4339
- const getOpenInputOptions = options => {
4362
+ const getViewletContext = (options, viewletContext) => {
4363
+ if (viewletContext !== undefined || typeof options === 'string') {
4364
+ return viewletContext;
4365
+ }
4366
+ const context = Object.fromEntries(Object.entries(options).filter(([key]) => key !== 'focus' && key !== 'preview' && key !== 'uri'));
4367
+ return Object.keys(context).length === 0 ? undefined : context;
4368
+ };
4369
+ const getOpenInputOptions = (options, focus = true, viewletContext) => {
4340
4370
  const uri = getOptionUriOptions(options);
4341
4371
  const preview = typeof options === 'string' ? false : options.preview ?? false;
4372
+ const context = getViewletContext(options, viewletContext);
4342
4373
  return {
4374
+ ...(context !== undefined && {
4375
+ args: [context]
4376
+ }),
4343
4377
  editorInput: getNormalizedOpenEditorInput(uri),
4344
- focus: typeof options === 'string' ? false : options.focus,
4378
+ focus: typeof options === 'string' ? focus : options.focus,
4345
4379
  preview
4346
4380
  };
4347
4381
  };
4348
- const openUri = async (state, options) => {
4349
- return openInput(state, getOpenInputOptions(options));
4382
+ const openUri = async (state, options, focus = true, viewletContext) => {
4383
+ return openInput(state, getOpenInputOptions(options, focus, viewletContext));
4350
4384
  };
4351
- const openUriWithContext = async (context, options) => {
4352
- await openInputWithContext(context, getOpenInputOptions(options));
4385
+ const openUriWithContext = async (context, options, focus = true, viewletContext) => {
4386
+ await openInputWithContext(context, getOpenInputOptions(options, focus, viewletContext));
4353
4387
  };
4354
4388
 
4355
4389
  const retryOpen = async state => {
@@ -4552,7 +4586,7 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
4552
4586
  const newGroupId = create$2();
4553
4587
  const splitLayoutDirection = getSplitLayoutDirection(direction);
4554
4588
  const baseNewGroup = {
4555
- activeTabId: undefined,
4589
+ activeTabId: -1,
4556
4590
  direction: sourceGroup.direction,
4557
4591
  focused: true,
4558
4592
  id: newGroupId,
@@ -4591,7 +4625,7 @@ const handleClickAction = async (state, action, rawGroupId) => {
4591
4625
  if (action === RestoreClosedTab) {
4592
4626
  return restoreClosedTab(state);
4593
4627
  }
4594
- if (activeGroupId === undefined) {
4628
+ if (activeGroupId === -1) {
4595
4629
  return state;
4596
4630
  }
4597
4631
  const activeGroup = getActiveGroup(groups, activeGroupId);
@@ -4854,36 +4888,10 @@ const parseUriList = value => {
4854
4888
  return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
4855
4889
  };
4856
4890
 
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
4891
  const suffixByHandleKind = {
4873
4892
  directory: '/',
4874
4893
  file: ''
4875
4894
  };
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
4895
  const getDroppedBrowserUris = async itemIds => {
4888
4896
  if (itemIds.length === 0) {
4889
4897
  return [];
@@ -4924,6 +4932,34 @@ const getDroppedBrowserUris = async itemIds => {
4924
4932
  }
4925
4933
  return uris;
4926
4934
  };
4935
+
4936
+ const windowsDriveLetterRegex = /^[a-zA-Z]:\\/;
4937
+ const encodeFilePath = path => {
4938
+ return encodeURI(path).replaceAll('#', '%23').replaceAll('?', '%3F');
4939
+ };
4940
+ const toFileUri$1 = path => {
4941
+ if (path.startsWith('file://')) {
4942
+ return path;
4943
+ }
4944
+ if (windowsDriveLetterRegex.test(path)) {
4945
+ const normalizedPath = path.replaceAll('\\', '/');
4946
+ return `file:///${encodeFilePath(normalizedPath)}`;
4947
+ }
4948
+ return `file://${encodeFilePath(path)}`;
4949
+ };
4950
+
4951
+ const getDroppedElectronUris = async (itemIds, files) => {
4952
+ if (itemIds.length > 0) {
4953
+ await getFileHandles(itemIds);
4954
+ }
4955
+ const uris = [];
4956
+ for (const file of files) {
4957
+ const path = await invoke('FileSystemHandle.getFilePathElectron', file);
4958
+ uris.push(toFileUri$1(path));
4959
+ }
4960
+ return uris;
4961
+ };
4962
+
4927
4963
  const getDroppedUris = async (itemIds, files = [], platform = Web) => {
4928
4964
  if (platform === Electron && files.length > 0) {
4929
4965
  return getDroppedElectronUris(itemIds, files);
@@ -5006,7 +5042,7 @@ const newFile = async state => {
5006
5042
  } = layout;
5007
5043
 
5008
5044
  // Find the active group
5009
- const activeGroup = activeGroupId === undefined ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
5045
+ const activeGroup = activeGroupId === -1 ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
5010
5046
 
5011
5047
  // Prepare initial state
5012
5048
  let newState = state;
@@ -5031,7 +5067,7 @@ const newFile = async state => {
5031
5067
  if (group.id === targetGroupId) {
5032
5068
  return {
5033
5069
  ...group,
5034
- activeTabId: undefined,
5070
+ activeTabId: -1,
5035
5071
  tabs: []
5036
5072
  };
5037
5073
  }
@@ -5640,7 +5676,7 @@ const isValidTab = tab => {
5640
5676
  };
5641
5677
 
5642
5678
  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';
5679
+ 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
5680
  };
5645
5681
 
5646
5682
  const isValidMainAreaLayout = layout => {
@@ -5648,7 +5684,7 @@ const isValidMainAreaLayout = layout => {
5648
5684
  return false;
5649
5685
  }
5650
5686
  const layoutObj = layout;
5651
- if (layoutObj.activeGroupId !== undefined && typeof layoutObj.activeGroupId !== 'number') {
5687
+ if (typeof layoutObj.activeGroupId !== 'number') {
5652
5688
  return false;
5653
5689
  }
5654
5690
  if (!isLayoutDirection(layoutObj.direction)) {
@@ -5709,11 +5745,13 @@ const tryRestoreLayout = savedState => {
5709
5745
  // Mark all restored tabs as not dirty
5710
5746
  const normalizedLayout = {
5711
5747
  ...rawLayout,
5748
+ activeGroupId: rawLayout.activeGroupId === undefined ? -1 : rawLayout.activeGroupId,
5712
5749
  direction: layoutDirection,
5713
5750
  groups: rawLayout.groups.map(group => {
5714
5751
  const groupDirection = normalizeGroupDirection(group, layoutDirection);
5715
5752
  return {
5716
5753
  ...group,
5754
+ activeTabId: group?.activeTabId === undefined ? -1 : group.activeTabId,
5717
5755
  direction: groupDirection,
5718
5756
  tabs: Array.isArray(group?.tabs) ? group.tabs.map(normalizeRestoredTab) : []
5719
5757
  };
@@ -5878,7 +5916,7 @@ const loadContent$1 = async (state, savedState) => {
5878
5916
  ...stateWithHomeDir,
5879
5917
  initial: false,
5880
5918
  layout: {
5881
- activeGroupId: undefined,
5919
+ activeGroupId: -1,
5882
5920
  direction: Horizontal,
5883
5921
  groups: []
5884
5922
  }
@@ -6286,14 +6324,14 @@ const moveIntoNewWindow = async state => {
6286
6324
  const {
6287
6325
  activeGroupId
6288
6326
  } = layout;
6289
- const group = findGroupById(state, activeGroupId ?? 0);
6327
+ const group = findGroupById(state, activeGroupId);
6290
6328
  if (!group) {
6291
6329
  return state;
6292
6330
  }
6293
6331
  const {
6294
6332
  activeTabId
6295
6333
  } = group;
6296
- if (activeTabId === undefined) {
6334
+ if (activeTabId === -1) {
6297
6335
  return state;
6298
6336
  }
6299
6337
  const tab = group.tabs.find(tab => tab.id === activeTabId);
@@ -6437,16 +6475,19 @@ const getSashCss = (layout, width = 0) => {
6437
6475
  return getProtoSashCss(layout, width).map(renderSashCss);
6438
6476
  };
6439
6477
 
6478
+ const getSashCornerCss = (left, top) => {
6479
+ return `.SashCorner {
6480
+ left: ${left}%;
6481
+ top: ${top}%;
6482
+ }`;
6483
+ };
6440
6484
  const getCss = (layout, width = 0, dragOverlay) => {
6441
6485
  const rules = [];
6442
6486
  if (layout) {
6443
6487
  rules.push(...getEditorGroupCss(layout), ...getDragOverlayCss(dragOverlay), ...getSashCss(layout, width));
6444
6488
  const sashCorner = getSashCorner(layout);
6445
6489
  if (sashCorner) {
6446
- rules.push(`.SashCorner {
6447
- left: ${sashCorner.leftOffset}%;
6448
- top: ${sashCorner.topOffset}%;
6449
- }`);
6490
+ rules.push(getSashCornerCss(sashCorner.leftOffset, sashCorner.topOffset));
6450
6491
  }
6451
6492
  }
6452
6493
  const css = rules.join('\n');
@@ -7594,7 +7635,7 @@ const getSavedTab = tab => {
7594
7635
  const getFilteredGroups = groups => {
7595
7636
  return groups.map(group => {
7596
7637
  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;
7638
+ const activeTabId = tabs.some(tab => tab.id === group.activeTabId) ? group.activeTabId : tabs[0]?.id ?? -1;
7598
7639
  return {
7599
7640
  ...group,
7600
7641
  activeTabId,
@@ -7617,7 +7658,7 @@ const saveState = state => {
7617
7658
  const {
7618
7659
  activeGroupId: originalActiveGroupId
7619
7660
  } = layout;
7620
- const activeGroupId = originalActiveGroupId !== undefined && filteredGroups.every(g => g.id !== originalActiveGroupId) ? undefined : originalActiveGroupId;
7661
+ const activeGroupId = originalActiveGroupId !== -1 && filteredGroups.every(g => g.id !== originalActiveGroupId) ? -1 : originalActiveGroupId;
7621
7662
  return {
7622
7663
  layout: {
7623
7664
  ...layout,
@@ -7632,7 +7673,7 @@ const flipDirection = direction => {
7632
7673
  };
7633
7674
  const createEmptyGroup = direction => {
7634
7675
  return {
7635
- activeTabId: undefined,
7676
+ activeTabId: -1,
7636
7677
  direction,
7637
7678
  focused: false,
7638
7679
  id: create$2(),
@@ -7655,8 +7696,8 @@ const getActiveGroupIndex = (groups, activeGroupId) => {
7655
7696
  const mergeGroups = (target, groups, activeGroupId) => {
7656
7697
  const allGroups = [target, ...groups];
7657
7698
  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;
7699
+ const activeGroup = allGroups.find(group => group.id === activeGroupId) ?? groups.findLast(group => group.activeTabId !== -1) ?? target;
7700
+ const activeTabId = activeGroup.activeTabId === -1 ? tabs[0]?.id ?? -1 : activeGroup.activeTabId;
7660
7701
  return {
7661
7702
  ...target,
7662
7703
  activeTabId,
@@ -7711,7 +7752,7 @@ const setEditorLayout = (state, direction, slots) => {
7711
7752
  return {
7712
7753
  ...state,
7713
7754
  layout: {
7714
- activeGroupId: nextGroups[activeIndex]?.id,
7755
+ activeGroupId: nextGroups[activeIndex]?.id ?? -1,
7715
7756
  direction,
7716
7757
  groups: nextGroups
7717
7758
  }
@@ -7851,7 +7892,7 @@ const splitDown = (state, groupId) => {
7851
7892
  if (groups.length === 0) {
7852
7893
  const initialGroupId = create$2();
7853
7894
  const initialGroup = {
7854
- activeTabId: undefined,
7895
+ activeTabId: -1,
7855
7896
  direction,
7856
7897
  focused: true,
7857
7898
  id: initialGroupId,
@@ -7888,7 +7929,7 @@ const splitLeft = (state, groupId) => {
7888
7929
  if (groups.length === 0) {
7889
7930
  const initialGroupId = create$2();
7890
7931
  const initialGroup = {
7891
- activeTabId: undefined,
7932
+ activeTabId: -1,
7892
7933
  direction,
7893
7934
  focused: true,
7894
7935
  id: initialGroupId,
@@ -7906,7 +7947,7 @@ const splitLeft = (state, groupId) => {
7906
7947
  };
7907
7948
  return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, Left$1);
7908
7949
  }
7909
- const targetGroupId = groupId ?? activeGroupId ?? groups[0]?.id ?? 0;
7950
+ const targetGroupId = groupId ?? (activeGroupId === -1 ? groups[0]?.id : activeGroupId) ?? 0;
7910
7951
  return splitEditorGroup$1(state, targetGroupId, Left$1);
7911
7952
  };
7912
7953
 
@@ -7924,7 +7965,7 @@ const splitRight = (state, groupId) => {
7924
7965
  if (groups.length === 0) {
7925
7966
  const initialGroupId = create$2();
7926
7967
  const initialGroup = {
7927
- activeTabId: undefined,
7968
+ activeTabId: -1,
7928
7969
  direction,
7929
7970
  focused: true,
7930
7971
  id: initialGroupId,
@@ -7942,7 +7983,7 @@ const splitRight = (state, groupId) => {
7942
7983
  };
7943
7984
  return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, Right$1);
7944
7985
  }
7945
- const targetGroupId = groupId ?? activeGroupId ?? groups[0]?.id ?? 0;
7986
+ const targetGroupId = groupId ?? (activeGroupId === -1 ? groups[0]?.id : activeGroupId) ?? 0;
7946
7987
  return splitEditorGroup$1(state, targetGroupId, Right$1);
7947
7988
  };
7948
7989
 
@@ -7958,7 +7999,7 @@ const splitUp = (state, groupId) => {
7958
7999
  if (groups.length === 0) {
7959
8000
  const initialGroupId = create$2();
7960
8001
  const initialGroup = {
7961
- activeTabId: undefined,
8002
+ activeTabId: -1,
7962
8003
  direction,
7963
8004
  focused: true,
7964
8005
  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.5",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",