@lvce-editor/explorer-view 4.9.0 → 4.11.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.
@@ -1051,8 +1051,14 @@ const Button$3 = 'event.button';
1051
1051
  const ClientX = 'event.clientX';
1052
1052
  const ClientY = 'event.clientY';
1053
1053
  const CtrlKey = 'event.ctrlKey';
1054
+ const DataTransferFiles = 'event.dataTransfer.files';
1055
+ const DataTransferFiles2 = 'event.dataTransfer.files2';
1056
+ const DefaultPrevented = 'event.defaultPrevented';
1054
1057
  const DeltaMode = 'event.deltaMode';
1055
1058
  const DeltaY = 'event.deltaY';
1059
+ const EventTargetClassName = 'event.target.className';
1060
+ const IsTrusted = 'event.isTrusted';
1061
+ const ShiftKey = 'event.shiftKey';
1056
1062
  const TargetValue = 'event.target.value';
1057
1063
 
1058
1064
  const Enter = 3;
@@ -1805,7 +1811,7 @@ const CopyRelativePath = 'Copy Relative Path';
1805
1811
  const Cut = 'Cut';
1806
1812
  const Delete = 'Delete';
1807
1813
  const FileNameCannotStartWithSlash = 'A file or folder name cannot start with a slash.';
1808
- const FileOrFolderAlreadyExists = 'A file or folder **{0}** already exists at this location. Please choose a different name.';
1814
+ const FileOrFolderAlreadyExists = 'A file or folder **{PH1}** already exists at this location. Please choose a different name.';
1809
1815
  const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
1810
1816
  const FileCannotStartWithDot = 'A file or folder name cannot start with a dot.';
1811
1817
  const FileCannotStartWithBackSlash = 'A file or folder name cannot start with a backslash.';
@@ -1884,8 +1890,10 @@ const fileCannotStartWithBackSlash = () => {
1884
1890
  const typeAFileName = () => {
1885
1891
  return i18nString(TypeAFileName);
1886
1892
  };
1887
- const fileOrFolderAlreadyExists = () => {
1888
- return i18nString(FileOrFolderAlreadyExists);
1893
+ const fileOrFolderAlreadyExists = name => {
1894
+ return i18nString(FileOrFolderAlreadyExists, {
1895
+ PH1: name
1896
+ });
1889
1897
  };
1890
1898
 
1891
1899
  const validateFileName2 = (name, siblingFileNames = []) => {
@@ -1905,7 +1913,7 @@ const validateFileName2 = (name, siblingFileNames = []) => {
1905
1913
 
1906
1914
  // Check if file already exists
1907
1915
  if (siblingFileNames.includes(name)) {
1908
- return fileOrFolderAlreadyExists();
1916
+ return fileOrFolderAlreadyExists(name);
1909
1917
  }
1910
1918
  return '';
1911
1919
  };
@@ -2546,62 +2554,6 @@ const ListItem = 22;
2546
2554
 
2547
2555
  const Slash = '/';
2548
2556
 
2549
- // TODO parentUid might ot be needed
2550
- const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) => {
2551
- const state = {
2552
- uid,
2553
- parentUid,
2554
- root: '',
2555
- items: [],
2556
- focusedIndex: -1,
2557
- focused: false,
2558
- hoverIndex: -1,
2559
- x,
2560
- y,
2561
- width,
2562
- height,
2563
- deltaY: 0,
2564
- minLineY: 0,
2565
- maxLineY: 0,
2566
- pathSeparator: Slash,
2567
- version: 0,
2568
- editingIndex: -1,
2569
- itemHeight: ListItem,
2570
- dropTargets: [],
2571
- excluded: [],
2572
- editingValue: '',
2573
- editingType: None$5,
2574
- editingIcon: '',
2575
- fileIconCache: Object.create(null),
2576
- useChevrons: false,
2577
- confirmDelete: false,
2578
- icons: [],
2579
- platform,
2580
- focus: 0,
2581
- editingErrorMessage: '',
2582
- inputSource: 0,
2583
- editingSelectionEnd: 0,
2584
- editingSelectionStart: 0,
2585
- focusWord: '',
2586
- focusWordTimeout: 800,
2587
- finalDeltaY: 0,
2588
- handleOffset: 0,
2589
- scrollBarActive: false,
2590
- scrollBarHeight: 0,
2591
- confirmPaste: false,
2592
- pasteShouldMove: false,
2593
- cutItems: [],
2594
- isPointerDown: false,
2595
- pointerDownIndex: -1,
2596
- sourceControlIgnoredUris: [],
2597
- maxIndent: 0,
2598
- errorMessageLeft: 0,
2599
- errorMessageTop: 0,
2600
- visibleExplorerItems: []
2601
- };
2602
- set(uid, state, state);
2603
- };
2604
-
2605
2557
  // TODO parentUid might ot be needed
2606
2558
  const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) => {
2607
2559
  const state = {
@@ -2659,6 +2611,11 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
2659
2611
  return state;
2660
2612
  };
2661
2613
 
2614
+ // TODO parentUid might ot be needed
2615
+ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) => {
2616
+ return create(uid, uri, x, y, width, height, args, parentUid, platform);
2617
+ };
2618
+
2662
2619
  const isEqual$6 = (oldState, newState) => {
2663
2620
  // TODO compute css more optimized
2664
2621
  // maybe only when items change, and even then not
@@ -3181,11 +3138,8 @@ const getMenuEntries = state => {
3181
3138
  }
3182
3139
  };
3183
3140
 
3184
- const getMenuEntries2 = uid => {
3185
- const {
3186
- newState
3187
- } = get(uid);
3188
- return getMenuEntries(newState);
3141
+ const getMenuEntries2 = state => {
3142
+ return getMenuEntries(state);
3189
3143
  };
3190
3144
 
3191
3145
  const Keyboard = -1;
@@ -5104,18 +5058,17 @@ const renameDirent = async state => {
5104
5058
  };
5105
5059
  };
5106
5060
 
5061
+ const getIndentRule = indent => {
5062
+ return `.Indent-${indent} {
5063
+ padding-left: ${indent}px;
5064
+ }`;
5065
+ };
5107
5066
  const getCss = (scrollBarHeight, uniqueIndents, errorMessageLeft, errorMessageTop) => {
5108
- // TODO each visible item should have an indent property
5109
5067
  const rules = [`.Explorer {
5110
5068
  --ScrollBarThumbHeight: ${scrollBarHeight}px;
5111
5069
  --ErrorMessageTop: ${errorMessageTop}px;
5112
5070
  --ErrorMessageLeft: ${errorMessageLeft}px;
5113
- }`];
5114
- for (const item of uniqueIndents) {
5115
- rules.push(`.Indent-${item} {
5116
- padding-left: ${item}px;
5117
- }`);
5118
- }
5071
+ }`, ...uniqueIndents.map(getIndentRule)];
5119
5072
  const css = rules.join('\n');
5120
5073
  return css;
5121
5074
  };
@@ -5672,26 +5625,15 @@ const renderEventListeners = () => {
5672
5625
  return [{
5673
5626
  name: HandleInputBlur,
5674
5627
  params: ['handleInputBlur']
5675
- },
5676
- // {
5677
- // name: DomEventListenersFunctions.HandleInputKeyDown,
5678
- // params: ['handleInputKeyDown'],
5679
- // stopPropagation: true, // TODO find a way to do this without stopPropagation
5680
- // },
5681
- // {
5682
- // name: DomEventListenersFunctions.HandleListKeyDown,
5683
- // params: ['handleKeyDown', 'event.key'],
5684
- // preventDefault: true,
5685
- // },
5686
- {
5628
+ }, {
5687
5629
  name: HandleListFocus,
5688
- params: ['handleFocus', 'event.isTrusted', 'event.target.className']
5630
+ params: ['handleFocus', IsTrusted, EventTargetClassName]
5689
5631
  }, {
5690
5632
  name: HandleListBlur,
5691
5633
  params: ['handleBlur']
5692
5634
  }, {
5693
5635
  name: HandleClick,
5694
- params: ['handleClickAt', 'event.defaultPrevented', Button$3, CtrlKey, 'event.shiftKey', ClientX, ClientY],
5636
+ params: ['handleClickAt', DefaultPrevented, Button$3, CtrlKey, ShiftKey, ClientX, ClientY],
5695
5637
  preventDefault: true
5696
5638
  }, {
5697
5639
  name: HandleInputClick,
@@ -5704,7 +5646,6 @@ const renderEventListeners = () => {
5704
5646
  }, {
5705
5647
  name: HandlePointerDown,
5706
5648
  params: ['handlePointerDown', Button$3, ClientX, ClientY]
5707
- // preventDefault: true,
5708
5649
  }, {
5709
5650
  name: HandleEditingInput,
5710
5651
  params: ['updateEditingValue', TargetValue]
@@ -5722,7 +5663,7 @@ const renderEventListeners = () => {
5722
5663
  preventDefault: true
5723
5664
  }, {
5724
5665
  name: HandleDrop,
5725
- params: ['handleDrop', ClientX, ClientY, 'event.dataTransfer.files2', 'event.dataTransfer.files'],
5666
+ params: ['handleDrop', ClientX, ClientY, DataTransferFiles2, DataTransferFiles],
5726
5667
  preventDefault: true
5727
5668
  }, {
5728
5669
  name: HandleDragLeave,
@@ -5735,20 +5676,27 @@ const renderEventListeners = () => {
5735
5676
  }];
5736
5677
  };
5737
5678
 
5679
+ const hasProperty = (object, key) => {
5680
+ if (!object || typeof object !== 'object' || !(key in object)) {
5681
+ return false;
5682
+ }
5683
+ return true;
5684
+ };
5685
+
5738
5686
  const getSavedMinLineY = savedState => {
5739
- if (savedState && typeof savedState === 'object' && 'minLineY' in savedState && typeof savedState.minLineY === 'number') {
5687
+ if (hasProperty(savedState, 'minLineY') && typeof savedState.minLineY === 'number') {
5740
5688
  return savedState.minLineY;
5741
5689
  }
5742
5690
  return 0;
5743
5691
  };
5744
5692
  const getSavedDeltaY = savedState => {
5745
- if (savedState && typeof savedState === 'object' && 'deltaY' in savedState && typeof savedState.deltaY === 'number') {
5693
+ if (hasProperty(savedState, 'deltaY') && typeof savedState.deltaY === 'number') {
5746
5694
  return savedState.deltaY;
5747
5695
  }
5748
5696
  return 0;
5749
5697
  };
5750
5698
  const getSavedWorkspacePath = savedState => {
5751
- if (savedState && typeof savedState === 'object' && 'workspacePath' in savedState && typeof savedState.workspacePath === 'string') {
5699
+ if (hasProperty(savedState, 'workspacePath') && typeof savedState.workspacePath === 'string') {
5752
5700
  return savedState.workspacePath;
5753
5701
  }
5754
5702
  return '';
@@ -6030,7 +5978,7 @@ const commandMap = {
6030
5978
  'Explorer.focusNone': wrapListItemCommand(focusNone),
6031
5979
  'Explorer.focusPrevious': wrapListItemCommand(focusPrevious),
6032
5980
  'Explorer.getCommandIds': getCommandIds,
6033
- 'Explorer.getMenuEntries2': getMenuEntries2,
5981
+ 'Explorer.getMenuEntries2': wrapGetter(getMenuEntries2),
6034
5982
  'Explorer.getMouseActions': getMouseActions,
6035
5983
  'Explorer.handleArrowLeft': wrapListItemCommand(handleArrowLeft),
6036
5984
  'Explorer.handleArrowRight': wrapListItemCommand(handleArrowRight),
@@ -6090,7 +6038,6 @@ const commandMap = {
6090
6038
  'Explorer.saveState': wrapGetter(saveState),
6091
6039
  'Explorer.terminate': terminate,
6092
6040
  'Explorer.initialize': initialize,
6093
- // deprecated
6094
6041
  'Explorer.create': create
6095
6042
  };
6096
6043
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "4.9.0",
3
+ "version": "4.11.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",