@lvce-editor/explorer-view 4.11.0 → 5.0.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.
@@ -1227,8 +1227,13 @@ const {
1227
1227
  invoke: invoke$1,
1228
1228
  invokeAndTransfer,
1229
1229
  set: set$2} = create$2(RendererWorker);
1230
- const showContextMenu = async (x, y, id, ...args) => {
1231
- return invoke$1('ContextMenu.show', x, y, id, ...args);
1230
+ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1231
+ number(uid);
1232
+ number(menuId);
1233
+ number(x);
1234
+ number(y);
1235
+ // @ts-ignore
1236
+ await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1232
1237
  };
1233
1238
  const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1234
1239
  const command = 'IconTheme.handleMessagePort';
@@ -2605,7 +2610,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
2605
2610
  maxIndent: 0,
2606
2611
  errorMessageLeft: 0,
2607
2612
  errorMessageTop: 0,
2608
- visibleExplorerItems: []
2613
+ visibleExplorerItems: [],
2614
+ errorMessageWidth: 0
2609
2615
  };
2610
2616
  set(state.uid, state, state);
2611
2617
  return state;
@@ -2620,7 +2626,7 @@ const isEqual$6 = (oldState, newState) => {
2620
2626
  // TODO compute css more optimized
2621
2627
  // maybe only when items change, and even then not
2622
2628
  // always, but only when it affects the css
2623
- return oldState.errorMessageLeft === newState.errorMessageLeft && oldState.errorMessageTop === newState.errorMessageTop && oldState.maxIndent === newState.maxIndent && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.visibleExplorerItems === newState.visibleExplorerItems;
2629
+ return oldState.errorMessageLeft === newState.errorMessageLeft && oldState.errorMessageTop === newState.errorMessageTop && oldState.maxIndent === newState.maxIndent && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.visibleExplorerItems === newState.visibleExplorerItems && oldState.editingErrorMessage === newState.editingErrorMessage;
2624
2630
  };
2625
2631
 
2626
2632
  const isEqual$5 = (oldState, newState) => {
@@ -3599,8 +3605,8 @@ const handleClickOpenFolder = async state => {
3599
3605
  return state;
3600
3606
  };
3601
3607
 
3602
- const show = async (x, y, id, ...args) => {
3603
- return showContextMenu(x, y, id, ...args);
3608
+ const show2 = async (uid, menuId, x, y, args) => {
3609
+ await showContextMenu2(uid, menuId, x, y, args);
3604
3610
  };
3605
3611
 
3606
3612
  const Explorer = 4;
@@ -3617,7 +3623,9 @@ const handleContextMenuAtIndex = async (state, index, x, y) => {
3617
3623
  focused: false
3618
3624
  };
3619
3625
  set(uid, state, newState);
3620
- await show(x, y, Explorer);
3626
+ await show2(uid, Explorer, x, y, {
3627
+ menuId: Explorer
3628
+ });
3621
3629
  return newState;
3622
3630
  };
3623
3631
 
@@ -4955,6 +4963,10 @@ const confirmDelete = async paths => {
4955
4963
  return result === true;
4956
4964
  };
4957
4965
 
4966
+ const showErrorAlert = async errorMessage => {
4967
+ await confirm(errorMessage);
4968
+ };
4969
+
4958
4970
  const removeDirent = async state => {
4959
4971
  const {
4960
4972
  items,
@@ -4981,7 +4993,7 @@ const removeDirent = async state => {
4981
4993
  // TODO use bulk edit and explorer refresh
4982
4994
  const errorMessage = await applyFileOperations(fileOperations);
4983
4995
  if (errorMessage) {
4984
- await confirm(errorMessage);
4996
+ await showErrorAlert(errorMessage);
4985
4997
  return state;
4986
4998
  }
4987
4999
  const newState = await refresh(state);
@@ -5063,16 +5075,28 @@ const getIndentRule = indent => {
5063
5075
  padding-left: ${indent}px;
5064
5076
  }`;
5065
5077
  };
5066
- const getCss = (scrollBarHeight, uniqueIndents, errorMessageLeft, errorMessageTop) => {
5078
+ const getCss = (scrollBarHeight, uniqueIndents, errorMessageLeft, errorMessageTop, errorMessageWidth) => {
5067
5079
  const rules = [`.Explorer {
5068
5080
  --ScrollBarThumbHeight: ${scrollBarHeight}px;
5069
5081
  --ErrorMessageTop: ${errorMessageTop}px;
5070
5082
  --ErrorMessageLeft: ${errorMessageLeft}px;
5083
+ --ErrorMessageWidth: ${errorMessageWidth}px;
5071
5084
  }`, ...uniqueIndents.map(getIndentRule)];
5072
5085
  const css = rules.join('\n');
5073
5086
  return css;
5074
5087
  };
5075
5088
 
5089
+ const getErrorMessagePosition = (itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding, width) => {
5090
+ const top = itemHeight * (focusedIndex - minLineY + 1);
5091
+ const left = depth * indent + fileIconWidth + padding;
5092
+ const errorMessageWidth = width - left;
5093
+ return {
5094
+ top,
5095
+ left,
5096
+ errorMessageWidth
5097
+ };
5098
+ };
5099
+
5076
5100
  const getUnique = items => {
5077
5101
  const seens = [];
5078
5102
  for (const item of items) {
@@ -5085,15 +5109,29 @@ const getUnique = items => {
5085
5109
 
5086
5110
  const renderCss = (oldState, newState) => {
5087
5111
  const {
5112
+ width,
5113
+ items,
5088
5114
  scrollBarHeight,
5089
5115
  uid,
5090
5116
  visibleExplorerItems,
5091
- errorMessageLeft,
5092
- errorMessageTop
5117
+ itemHeight,
5118
+ focusedIndex,
5119
+ minLineY
5093
5120
  } = newState;
5094
5121
  const indents = visibleExplorerItems.map(item => item.indent);
5095
5122
  const uniqueIndents = getUnique(indents);
5096
- const css = getCss(scrollBarHeight, uniqueIndents, errorMessageLeft, errorMessageTop);
5123
+ const indent = 8;
5124
+ const padding = 10;
5125
+ const fileIconWidth = 16;
5126
+ const defaultPaddingLeft = 0;
5127
+ const chevronSpace = 22;
5128
+ const depth = items[focusedIndex]?.depth || 0;
5129
+ const {
5130
+ top,
5131
+ left,
5132
+ errorMessageWidth
5133
+ } = getErrorMessagePosition(itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding + defaultPaddingLeft + chevronSpace, width);
5134
+ const css = getCss(scrollBarHeight, uniqueIndents, left, top, errorMessageWidth);
5097
5135
  return [SetCss, uid, css];
5098
5136
  };
5099
5137
 
@@ -5173,15 +5211,6 @@ const renderFocusContext = (oldState, newState) => {
5173
5211
  return [];
5174
5212
  };
5175
5213
 
5176
- const getErrorMessagePosition = (itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding) => {
5177
- const top = itemHeight * (focusedIndex - minLineY + 1);
5178
- const left = depth * indent + fileIconWidth + padding;
5179
- return {
5180
- top,
5181
- left
5182
- };
5183
- };
5184
-
5185
5214
  const None = 'none';
5186
5215
  const ToolBar = 'toolbar';
5187
5216
  const Tree = 'tree';
@@ -5193,16 +5222,14 @@ const Input = 6;
5193
5222
  const Img = 17;
5194
5223
  const P = 50;
5195
5224
 
5196
- const getErrorMessageDom = (errorMessage, errorMessageLeft, errorMessageTop) => {
5225
+ const getErrorMessageDom = errorMessage => {
5197
5226
  if (!errorMessage) {
5198
5227
  return [];
5199
5228
  }
5200
- const translateString = position(errorMessageLeft, errorMessageTop);
5201
5229
  return [{
5202
5230
  type: Div,
5203
5231
  className: mergeClassNames(ExplorerErrorMessage),
5204
- childCount: 1,
5205
- translate: translateString
5232
+ childCount: 1
5206
5233
  }, text(errorMessage)];
5207
5234
  };
5208
5235
 
@@ -5433,14 +5460,14 @@ const getChildCount = (scrollBarDomLength, errorDomLength) => {
5433
5460
  }
5434
5461
  return childCount;
5435
5462
  };
5436
- const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, scrollTop, errorMessage, errorMessageTop, errorMessageLeft) => {
5463
+ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, scrollTop, errorMessage) => {
5437
5464
  if (!root) {
5438
5465
  return getExplorerWelcomeVirtualDom(isWide);
5439
5466
  }
5440
5467
  const scrollBarHeight = getScrollBarSize(height, contentHeight, 20);
5441
5468
  const scrollBarTop = getScrollBarTop(height, contentHeight, scrollTop);
5442
5469
  const scrollBarDom = getScrollBarVirtualDom(scrollBarHeight, scrollBarTop);
5443
- const errorDom = getErrorMessageDom(errorMessage, errorMessageLeft, errorMessageTop);
5470
+ const errorDom = getErrorMessageDom(errorMessage);
5444
5471
  const childCount = getChildCount(scrollBarDom.length, errorDom.length);
5445
5472
  const parentNode = {
5446
5473
  type: Div,
@@ -5462,24 +5489,13 @@ const renderItems = (oldState, newState) => {
5462
5489
  height,
5463
5490
  itemHeight,
5464
5491
  items,
5465
- minLineY,
5466
5492
  root,
5467
5493
  width
5468
5494
  } = newState;
5469
5495
  const visibleDirents = newState.visibleExplorerItems;
5470
5496
  const isWide = width > 450;
5471
5497
  const contentHeight = items.length * itemHeight;
5472
- const depth = items[focusedIndex]?.depth || 0;
5473
- const indent = 8;
5474
- const padding = 10;
5475
- const fileIconWidth = 16;
5476
- const defaultPaddingLeft = 0;
5477
- const chevronSpace = 22;
5478
- const {
5479
- top,
5480
- left
5481
- } = getErrorMessagePosition(itemHeight, focusedIndex, minLineY, depth, indent, fileIconWidth, padding + defaultPaddingLeft + chevronSpace);
5482
- const dom = getExplorerVirtualDom(visibleDirents, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, deltaY, editingErrorMessage, top, left);
5498
+ const dom = getExplorerVirtualDom(visibleDirents, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, deltaY, editingErrorMessage);
5483
5499
  return [SetDom2, dom];
5484
5500
  };
5485
5501
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "4.11.0",
3
+ "version": "5.0.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",