@lvce-editor/explorer-view 6.8.0 → 6.10.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.
@@ -2781,7 +2781,6 @@ const diffChildren = (oldChildren, newChildren, patches) => {
2781
2781
  patches.push({
2782
2782
  type: NavigateParent
2783
2783
  });
2784
- currentChildIndex = -1;
2785
2784
  }
2786
2785
  // Add remove patches in reverse order (highest index first)
2787
2786
  // This ensures indices remain valid as we remove
@@ -4534,6 +4533,34 @@ const isDirectoryHandle = fileHandle => {
4534
4533
  return fileHandle.kind === 'directory';
4535
4534
  };
4536
4535
 
4536
+ const getErrorCode = error => {
4537
+ if (error && typeof error === 'object' && 'code' in error && typeof error.code === 'string') {
4538
+ return error.code;
4539
+ }
4540
+ return '';
4541
+ };
4542
+
4543
+ const getErrorMessage = error => {
4544
+ if (error instanceof Error) {
4545
+ return error.message;
4546
+ }
4547
+ if (typeof error === 'string') {
4548
+ return error;
4549
+ }
4550
+ return 'Unknown error';
4551
+ };
4552
+
4553
+ const getExcluded = () => {
4554
+ const excludedObject = {};
4555
+ const excluded = [];
4556
+ for (const [key, value] of Object.entries(excludedObject)) {
4557
+ if (value) {
4558
+ excluded.push(key);
4559
+ }
4560
+ }
4561
+ return excluded;
4562
+ };
4563
+
4537
4564
  const isValid = decoration => {
4538
4565
  return decoration && typeof decoration.decoration === 'string' && typeof decoration.uri === 'string';
4539
4566
  };
@@ -4565,6 +4592,37 @@ const getFileDecorations = async (scheme, root, maybeUris, decorationsEnabled, a
4565
4592
  }
4566
4593
  };
4567
4594
 
4595
+ const getFriendlyErrorMessage = (errorMessage, errorCode) => {
4596
+ switch (errorCode) {
4597
+ case 'EACCES':
4598
+ case 'EPERM':
4599
+ return 'permission was denied';
4600
+ case 'EBUSY':
4601
+ return 'the folder is currently in use';
4602
+ case 'ENOENT':
4603
+ return 'the folder does not exist';
4604
+ case 'ENOTDIR':
4605
+ return 'the path is not a folder';
4606
+ default:
4607
+ return errorMessage || 'an unexpected error occurred';
4608
+ }
4609
+ };
4610
+
4611
+ const getPathSeparator = async root => {
4612
+ return getPathSeparator$1(root);
4613
+ };
4614
+
4615
+ const getRestoredDeltaY = savedState => {
4616
+ if (savedState && typeof savedState.deltaY === 'number') {
4617
+ return savedState.deltaY;
4618
+ }
4619
+ return 0;
4620
+ };
4621
+
4622
+ const getSavedRoot = (savedState, workspacePath) => {
4623
+ return workspacePath;
4624
+ };
4625
+
4568
4626
  const RE_PROTOCOL = /^[a-z+]:\/\//;
4569
4627
  const getScheme = uri => {
4570
4628
  const match = uri.match(RE_PROTOCOL);
@@ -4690,55 +4748,11 @@ const restoreExpandedState = async (savedState, root, pathSeparator, excluded) =
4690
4748
  return dirents;
4691
4749
  };
4692
4750
 
4693
- const getPathSeparator = root => {
4694
- return getPathSeparator$1(root);
4695
- };
4696
- const getExcluded = () => {
4697
- const excludedObject = {};
4698
- const excluded = [];
4699
- for (const [key, value] of Object.entries(excludedObject)) {
4700
- if (value) {
4701
- excluded.push(key);
4702
- }
4703
- }
4704
- return excluded;
4705
- };
4706
- const getSavedRoot = (savedState, workspacePath) => {
4707
- return workspacePath;
4708
- };
4709
- const getErrorCode = error => {
4710
- if (error && typeof error === 'object' && 'code' in error && typeof error.code === 'string') {
4711
- return error.code;
4712
- }
4713
- return '';
4714
- };
4715
- const getErrorMessage = error => {
4716
- if (error instanceof Error) {
4717
- return error.message;
4718
- }
4719
- if (typeof error === 'string') {
4720
- return error;
4721
- }
4722
- return 'Unknown error';
4723
- };
4724
- const getFriendlyErrorMessage = (errorMessage, errorCode) => {
4725
- switch (errorCode) {
4726
- case 'EACCES':
4727
- case 'EPERM':
4728
- return 'permission was denied';
4729
- case 'EBUSY':
4730
- return 'the folder is currently in use';
4731
- case 'ENOENT':
4732
- return 'the folder does not exist';
4733
- case 'ENOTDIR':
4734
- return 'the path is not a folder';
4735
- default:
4736
- return errorMessage || 'an unexpected error occurred';
4737
- }
4738
- };
4739
4751
  const loadContent = async (state, savedState) => {
4740
4752
  const {
4741
4753
  assetDir,
4754
+ height,
4755
+ itemHeight,
4742
4756
  platform
4743
4757
  } = state;
4744
4758
  const {
@@ -4753,14 +4767,10 @@ const loadContent = async (state, savedState) => {
4753
4767
  const pathSeparator = await getPathSeparator(root); // TODO only load path separator once
4754
4768
  const excluded = getExcluded();
4755
4769
  const restoredDirents = await restoreExpandedState(savedState, root, pathSeparator, excluded);
4756
- let minLineY = 0;
4757
- if (savedState && typeof savedState.minLineY === 'number') {
4758
- minLineY = savedState.minLineY;
4759
- }
4760
- let deltaY = 0;
4761
- if (savedState && typeof savedState.deltaY === 'number') {
4762
- deltaY = savedState.deltaY;
4763
- }
4770
+ const rawDeltaY = getRestoredDeltaY(savedState);
4771
+ const maxDeltaY = Math.max(restoredDirents.length * itemHeight - height, 0);
4772
+ const deltaY = Math.min(Math.max(rawDeltaY, 0), maxDeltaY);
4773
+ const minLineY = Math.round(deltaY / itemHeight);
4764
4774
  const scheme = getScheme(root);
4765
4775
  const decorations = await getFileDecorations(scheme, root, restoredDirents.filter(item => item.depth === 1).map(item => item.path), sourceControlDecorations, assetDir, platform);
4766
4776
  return {
@@ -6539,10 +6549,7 @@ const renderEventListeners = () => {
6539
6549
  };
6540
6550
 
6541
6551
  const hasProperty = (object, key) => {
6542
- if (!object || typeof object !== 'object' || !(key in object)) {
6543
- return false;
6544
- }
6545
- return true;
6552
+ return !!object && typeof object === 'object' && key in object;
6546
6553
  };
6547
6554
 
6548
6555
  const getSavedMinLineY = savedState => {
@@ -6581,6 +6588,14 @@ const restoreState = savedState => {
6581
6588
  };
6582
6589
  };
6583
6590
 
6591
+ const isUriWithinRoot = (root, uri, pathSeparator) => {
6592
+ if (uri === root) {
6593
+ return true;
6594
+ }
6595
+ const rootWithSeparator = root.endsWith(pathSeparator) ? root : `${root}${pathSeparator}`;
6596
+ return uri.startsWith(rootWithSeparator);
6597
+ };
6598
+
6584
6599
  const getPathPartsToReveal = (root, pathParts, dirents) => {
6585
6600
  for (let i = 0; i < pathParts.length; i++) {
6586
6601
  const pathPart = pathParts[i];
@@ -6665,8 +6680,13 @@ const revealItem = async (state, uri) => {
6665
6680
  object(state);
6666
6681
  string(uri);
6667
6682
  const {
6668
- items
6683
+ items,
6684
+ pathSeparator,
6685
+ root
6669
6686
  } = state;
6687
+ if (!isUriWithinRoot(root, uri, pathSeparator)) {
6688
+ return state;
6689
+ }
6670
6690
  const index = getIndex(items, uri);
6671
6691
  if (index === -1) {
6672
6692
  return revealItemHidden(state, uri);
@@ -6907,6 +6927,7 @@ const commandMap = {
6907
6927
  'Explorer.renderActions2': renderActions,
6908
6928
  'Explorer.renderEventListeners': renderEventListeners,
6909
6929
  'Explorer.restoreState': restoreState,
6930
+ 'Explorer.reveal': wrapListItemCommand(revealItem),
6910
6931
  'Explorer.revealItem': wrapListItemCommand(revealItem),
6911
6932
  'Explorer.saveState': wrapGetter(saveState),
6912
6933
  'Explorer.selectAll': wrapListItemCommand(selectAll),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "6.8.0",
3
+ "version": "6.10.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",