@lvce-editor/main-area-worker 9.3.0 → 9.5.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.
@@ -1716,6 +1716,8 @@ const Main$1 = 24;
1716
1716
  const Separator = 1;
1717
1717
  const None = 0;
1718
1718
 
1719
+ const Electron = 2;
1720
+
1719
1721
  const ClipBoardWorker = 3400;
1720
1722
  const ExtensionHostWorker = 44;
1721
1723
  const IconThemeWorker = 7009;
@@ -3459,8 +3461,7 @@ const handleResize = async (state, dimensions) => {
3459
3461
  // Resize all editor children to their new bounds
3460
3462
  const {
3461
3463
  layout,
3462
- tabHeight,
3463
- uid
3464
+ tabHeight
3464
3465
  } = state;
3465
3466
  const {
3466
3467
  groups
@@ -3484,7 +3485,6 @@ const handleResize = async (state, dimensions) => {
3484
3485
  }
3485
3486
  }
3486
3487
  }
3487
- allResizeCommands.push(['Viewlet.setBounds', uid, x, y, width, height]);
3488
3488
  return allResizeCommands;
3489
3489
  };
3490
3490
 
@@ -3992,7 +3992,7 @@ const splitRight$1 = () => {
3992
3992
  const splitEditorGroup = () => {
3993
3993
  return i18nString(SplitEditorGroup);
3994
3994
  };
3995
- const newWindow = () => {
3995
+ const newWindow$1 = () => {
3996
3996
  return i18nString(NewWindow);
3997
3997
  };
3998
3998
  const close = () => {
@@ -4075,7 +4075,18 @@ const getArgs = groupId => {
4075
4075
  }
4076
4076
  return [groupId];
4077
4077
  };
4078
- const getMenuEntries$2 = groupId => {
4078
+ const getNewWindowMenuEntries = state => {
4079
+ if (state.platform !== Electron) {
4080
+ return [];
4081
+ }
4082
+ return [menuEntrySeparator, {
4083
+ command: 'MainArea.newWindow',
4084
+ flags: None,
4085
+ id: 'newWindow',
4086
+ label: newWindow$1()
4087
+ }];
4088
+ };
4089
+ const getMenuEntries$2 = (state, groupId) => {
4079
4090
  const groupArgs = getArgs(groupId);
4080
4091
  const entries = [{
4081
4092
  args: [QuickPick, 'file'],
@@ -4107,12 +4118,7 @@ const getMenuEntries$2 = groupId => {
4107
4118
  flags: None,
4108
4119
  id: 'splitRight',
4109
4120
  label: splitRight$1()
4110
- }, menuEntrySeparator, {
4111
- command: 'Main.newWindow',
4112
- flags: None,
4113
- id: 'newWindow',
4114
- label: newWindow()
4115
- }];
4121
+ }, ...getNewWindowMenuEntries(state)];
4116
4122
  if (!hasTargetGroup(groupId)) {
4117
4123
  return entries;
4118
4124
  }
@@ -4263,7 +4269,7 @@ const getMenuEntries$1 = state => {
4263
4269
  const getMenuEntries = async (state, props) => {
4264
4270
  switch (props.menuId) {
4265
4271
  case Main$1:
4266
- return getMenuEntries$2(props.groupId);
4272
+ return getMenuEntries$2(state, props.groupId);
4267
4273
  case Tab:
4268
4274
  return getMenuEntries$1(state);
4269
4275
  default:
@@ -4271,6 +4277,11 @@ const getMenuEntries = async (state, props) => {
4271
4277
  }
4272
4278
  };
4273
4279
 
4280
+ const newWindow = async state => {
4281
+ await invoke('Main.newWindow');
4282
+ return state;
4283
+ };
4284
+
4274
4285
  const openUris = async (state, uris) => {
4275
4286
  if (uris.length === 0) {
4276
4287
  return state;
@@ -4299,19 +4310,56 @@ const refresh = state => {
4299
4310
  };
4300
4311
  };
4301
4312
 
4302
- const getCss = () => {
4313
+ const getEditorGroupCss = layout => {
4314
+ const groupSizeVariable = layout.direction === Vertical ? '--EditorGroupHeight' : '--EditorGroupWidth';
4315
+ return layout.groups.map(group => {
4316
+ return `.EditorGroup[data-groupId="${group.id}"] {
4317
+ ${groupSizeVariable}: ${group.size}%;
4318
+ }`;
4319
+ });
4320
+ };
4321
+
4322
+ const getSashCss = layout => {
4323
+ if (layout.groups.length <= 1) {
4324
+ return [];
4325
+ }
4326
+ const sashPositionVariable = layout.direction === Horizontal ? '--SashLeft' : '--SashTop';
4327
+ const rules = [];
4328
+ let sashOffset = 0;
4329
+ for (let i = 1; i < layout.groups.length; i++) {
4330
+ sashOffset += layout.groups[i - 1].size;
4331
+ const beforeGroupId = layout.groups[i - 1].id;
4332
+ const afterGroupId = layout.groups[i].id;
4333
+ const sashId = create(beforeGroupId, afterGroupId);
4334
+ rules.push(`.Sash[data-sashId="${sashId}"] {
4335
+ ${sashPositionVariable}: ${sashOffset}%;
4336
+ }`);
4337
+ }
4338
+ return rules;
4339
+ };
4340
+
4341
+ const getCss = layout => {
4303
4342
  const rules = [`.MainArea {
4304
4343
  }`, `.editor-groups-container {
4305
4344
  overflow: auto;
4306
4345
  }`, `.EditorGroup {
4307
4346
  min-width: 250px;
4347
+ width: var(--EditorGroupWidth, auto);
4348
+ /*height: var(--EditorGroupHeight, auto);*/
4349
+ }`, `.MainArea .SashVertical {
4350
+ left: var(--SashLeft);
4351
+ }`, `.MainArea .SashHorizontal {
4352
+ top: var(--SashTop);
4308
4353
  }`];
4354
+ if (layout) {
4355
+ rules.push(...getEditorGroupCss(layout), ...getSashCss(layout));
4356
+ }
4309
4357
  const css = rules.join('\n');
4310
4358
  return css;
4311
4359
  };
4312
4360
 
4313
4361
  const renderCss = (oldState, newState) => {
4314
- const css = getCss();
4362
+ const css = getCss(newState.layout);
4315
4363
  return [SetCss, newState.uid, css];
4316
4364
  };
4317
4365
 
@@ -4625,6 +4673,25 @@ const HandleSashPointerDown = 16;
4625
4673
  const HandleSashPointerMove = 17;
4626
4674
  const HandleSashPointerUp = 18;
4627
4675
 
4676
+ const MIN_GROUP_WIDTH_PX = 250;
4677
+ const getSashOffset = (layout, groupIndex, width) => {
4678
+ const {
4679
+ direction,
4680
+ groups
4681
+ } = layout;
4682
+ const percentOffset = groups.slice(0, groupIndex).reduce((total, group) => total + group.size, 0);
4683
+ if (direction !== Horizontal || !width || !Number.isFinite(width)) {
4684
+ return `${percentOffset}%`;
4685
+ }
4686
+ const effectiveGroupSizes = groups.map(group => Math.max(group.size / 100 * width, MIN_GROUP_WIDTH_PX));
4687
+ const hasOverflowingGroups = effectiveGroupSizes.some((size, index) => size !== groups[index].size / 100 * width);
4688
+ if (!hasOverflowingGroups) {
4689
+ return `${percentOffset}%`;
4690
+ }
4691
+ const pixelOffset = effectiveGroupSizes.slice(0, groupIndex).reduce((total, size) => total + size, 0);
4692
+ return `${pixelOffset}px`;
4693
+ };
4694
+
4628
4695
  const renderContent = content => {
4629
4696
  return [{
4630
4697
  childCount: 1,
@@ -4899,6 +4966,7 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
4899
4966
  return [{
4900
4967
  childCount: 2,
4901
4968
  className: EditorGroup,
4969
+ 'data-groupId': String(group.id),
4902
4970
  style,
4903
4971
  type: Div
4904
4972
  }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled), {
@@ -4928,7 +4996,7 @@ const renderSash = (direction, sashId, style) => {
4928
4996
  }];
4929
4997
  };
4930
4998
 
4931
- const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty) => {
4999
+ const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width') => {
4932
5000
  return [{
4933
5001
  childCount: 1,
4934
5002
  className: Main,
@@ -4936,24 +5004,6 @@ const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty) => {
4936
5004
  }, ...renderEditorGroup(layout.groups[0], 0, splitButtonEnabled, sizeProperty)];
4937
5005
  };
4938
5006
 
4939
- const MIN_GROUP_WIDTH_PX = 250;
4940
- const getSashOffset = (layout, groupIndex, width) => {
4941
- const {
4942
- direction,
4943
- groups
4944
- } = layout;
4945
- const percentOffset = groups.slice(0, groupIndex).reduce((total, group) => total + group.size, 0);
4946
- if (direction !== Horizontal || !width || !Number.isFinite(width)) {
4947
- return `${percentOffset}%`;
4948
- }
4949
- const effectiveGroupSizes = groups.map(group => Math.max(group.size / 100 * width, MIN_GROUP_WIDTH_PX));
4950
- const hasOverflowingGroups = effectiveGroupSizes.some((size, index) => size !== groups[index].size / 100 * width);
4951
- if (!hasOverflowingGroups) {
4952
- return `${percentOffset}%`;
4953
- }
4954
- const pixelOffset = effectiveGroupSizes.slice(0, groupIndex).reduce((total, size) => total + size, 0);
4955
- return `${pixelOffset}px`;
4956
- };
4957
5007
  const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, width = 0) => {
4958
5008
  const {
4959
5009
  direction,
@@ -5128,18 +5178,18 @@ const save = async state => {
5128
5178
  });
5129
5179
  };
5130
5180
 
5181
+ const getFilteredGroups = groups => {
5182
+ return groups.map(group => ({
5183
+ ...group,
5184
+ tabs: group.tabs.filter(tab => !tab.uri?.startsWith('untitled://'))
5185
+ })).filter(group => group.tabs.length > 0);
5186
+ };
5187
+
5131
5188
  const saveState = state => {
5132
5189
  const {
5133
5190
  layout
5134
5191
  } = state;
5135
-
5136
- // Filter out untitled editors from tabs
5137
- const filteredGroups = layout.groups.map(group => ({
5138
- ...group,
5139
- tabs: group.tabs.filter(tab => !tab.uri?.startsWith('untitled://'))
5140
- }))
5141
- // Remove groups that become empty after filtering
5142
- .filter(group => group.tabs.length > 0);
5192
+ const filteredGroups = getFilteredGroups(layout.groups);
5143
5193
 
5144
5194
  // Update activeGroupId if it points to a removed group
5145
5195
  const {
@@ -5332,6 +5382,7 @@ const commandMap = {
5332
5382
  'MainArea.initialize': initialize,
5333
5383
  'MainArea.loadContent': wrapCommand(loadContent),
5334
5384
  'MainArea.newFile': wrapCommand(newFile),
5385
+ 'MainArea.newWindow': wrapCommand(newWindow),
5335
5386
  'MainArea.openInput': wrapCommand(openInput),
5336
5387
  'MainArea.openUri': wrapCommand(openUri),
5337
5388
  'MainArea.openUris': wrapCommand(openUris),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.3.0",
3
+ "version": "9.5.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",