@lvce-editor/explorer-view 7.23.1 → 7.23.3

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.
@@ -54,6 +54,67 @@ class VError extends Error {
54
54
  }
55
55
  }
56
56
 
57
+ class AssertionError extends Error {
58
+ constructor(message) {
59
+ super(message);
60
+ this.name = 'AssertionError';
61
+ }
62
+ }
63
+ const Object$1 = 1;
64
+ const Number$1 = 2;
65
+ const Array$1 = 3;
66
+ const String$1 = 4;
67
+ const Boolean$1 = 5;
68
+ const Function = 6;
69
+ const Null = 7;
70
+ const Unknown$1 = 8;
71
+ const getType = value => {
72
+ switch (typeof value) {
73
+ case 'number':
74
+ return Number$1;
75
+ case 'function':
76
+ return Function;
77
+ case 'string':
78
+ return String$1;
79
+ case 'object':
80
+ if (value === null) {
81
+ return Null;
82
+ }
83
+ if (Array.isArray(value)) {
84
+ return Array$1;
85
+ }
86
+ return Object$1;
87
+ case 'boolean':
88
+ return Boolean$1;
89
+ default:
90
+ return Unknown$1;
91
+ }
92
+ };
93
+ const object = value => {
94
+ const type = getType(value);
95
+ if (type !== Object$1) {
96
+ throw new AssertionError('expected value to be of type object');
97
+ }
98
+ };
99
+ const number = value => {
100
+ const type = getType(value);
101
+ if (type !== Number$1) {
102
+ throw new AssertionError('expected value to be of type number');
103
+ }
104
+ };
105
+ const array = value => {
106
+ const type = getType(value);
107
+ if (type !== Array$1) {
108
+ throw new AssertionError('expected value to be of type array');
109
+ }
110
+ };
111
+ const string = value => {
112
+ const type = getType(value);
113
+ if (type !== String$1) {
114
+ throw new AssertionError('expected value to be of type string');
115
+ }
116
+ };
117
+
57
118
  const isMessagePort = value => {
58
119
  return value && value instanceof MessagePort;
59
120
  };
@@ -1379,67 +1440,6 @@ const {
1379
1440
  set: set$6
1380
1441
  } = create$2(RendererProcess);
1381
1442
 
1382
- class AssertionError extends Error {
1383
- constructor(message) {
1384
- super(message);
1385
- this.name = 'AssertionError';
1386
- }
1387
- }
1388
- const Object$1 = 1;
1389
- const Number$1 = 2;
1390
- const Array$1 = 3;
1391
- const String$1 = 4;
1392
- const Boolean$1 = 5;
1393
- const Function = 6;
1394
- const Null = 7;
1395
- const Unknown$1 = 8;
1396
- const getType = value => {
1397
- switch (typeof value) {
1398
- case 'number':
1399
- return Number$1;
1400
- case 'function':
1401
- return Function;
1402
- case 'string':
1403
- return String$1;
1404
- case 'object':
1405
- if (value === null) {
1406
- return Null;
1407
- }
1408
- if (Array.isArray(value)) {
1409
- return Array$1;
1410
- }
1411
- return Object$1;
1412
- case 'boolean':
1413
- return Boolean$1;
1414
- default:
1415
- return Unknown$1;
1416
- }
1417
- };
1418
- const object = value => {
1419
- const type = getType(value);
1420
- if (type !== Object$1) {
1421
- throw new AssertionError('expected value to be of type object');
1422
- }
1423
- };
1424
- const number = value => {
1425
- const type = getType(value);
1426
- if (type !== Number$1) {
1427
- throw new AssertionError('expected value to be of type number');
1428
- }
1429
- };
1430
- const array = value => {
1431
- const type = getType(value);
1432
- if (type !== Array$1) {
1433
- throw new AssertionError('expected value to be of type array');
1434
- }
1435
- };
1436
- const string = value => {
1437
- const type = getType(value);
1438
- if (type !== String$1) {
1439
- throw new AssertionError('expected value to be of type string');
1440
- }
1441
- };
1442
-
1443
1443
  const {
1444
1444
  invoke: invoke$3,
1445
1445
  invokeAndTransfer,
@@ -3030,7 +3030,7 @@ const getFileIcons = async (dirents, fileIconCache) => {
3030
3030
  };
3031
3031
  };
3032
3032
 
3033
- const directoryTypes$2 = new Set([DirectoryExpanded, DirectoryExpanding, EditingDirectoryExpanded]);
3033
+ const directoryTypes$3 = new Set([DirectoryExpanded, DirectoryExpanding, EditingDirectoryExpanded]);
3034
3034
  const getParentPath = (path, pathSeparator) => {
3035
3035
  const index = path.lastIndexOf(pathSeparator);
3036
3036
  if (index === -1) {
@@ -3041,7 +3041,7 @@ const getParentPath = (path, pathSeparator) => {
3041
3041
  const getGitIgnoreCandidateDirs = (root, items, pathSeparator) => {
3042
3042
  const dirs = new Set([root]);
3043
3043
  for (const item of items) {
3044
- if (directoryTypes$2.has(item.type)) {
3044
+ if (directoryTypes$3.has(item.type)) {
3045
3045
  dirs.add(item.path);
3046
3046
  }
3047
3047
  const parent = getParentPath(item.path, pathSeparator);
@@ -3719,6 +3719,8 @@ const {
3719
3719
  wrapGetter
3720
3720
  } = create$1();
3721
3721
  const commandQueues = new Map();
3722
+ const gitIgnoreApplyDelay = 100;
3723
+ const pendingGitIgnoreUpdates = new Map();
3722
3724
  const runQueuedCommand = async (previousCommand, command) => {
3723
3725
  await previousCommand;
3724
3726
  return command();
@@ -3747,21 +3749,66 @@ const enqueueCommand = async (id, command) => {
3747
3749
  const hasSameVisibleExplorerItemInputs = (oldState, newState) => {
3748
3750
  return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.height === newState.height && oldState.itemHeight === newState.itemHeight && oldState.focusedIndex === newState.focusedIndex && oldState.editingIndex === newState.editingIndex && oldState.editingSessionId === newState.editingSessionId && oldState.editingIcon === newState.editingIcon && oldState.cutItems === newState.cutItems && oldState.editingErrorMessage === newState.editingErrorMessage && oldState.dropTargets === newState.dropTargets && oldState.fileIconCache === newState.fileIconCache && oldState.decorations === newState.decorations && oldState.useChevrons === newState.useChevrons && oldState.sourceControlIgnoredUris === newState.sourceControlIgnoredUris;
3749
3751
  };
3750
- const maybeUpdateGitIgnoredUris = async (oldState, newState) => {
3751
- if (oldState.items === newState.items || oldState.sourceControlIgnoredUris !== newState.sourceControlIgnoredUris) {
3752
- return newState;
3752
+ const updateGitIgnoredUris = (state, generation, sourceControlIgnoredUris) => {
3753
+ const {
3754
+ gitIgnoreGeneration
3755
+ } = state;
3756
+ if (gitIgnoreGeneration !== generation) {
3757
+ return state;
3758
+ }
3759
+ return {
3760
+ ...state,
3761
+ sourceControlIgnoredUris
3762
+ };
3763
+ };
3764
+ const scheduleGitIgnoredUrisUpdate = (uid, generation, sourceControlIgnoredUris) => {
3765
+ const previous = pendingGitIgnoreUpdates.get(uid);
3766
+ if (previous) {
3767
+ clearTimeout(previous.timer);
3768
+ }
3769
+ const run = () => {
3770
+ pendingGitIgnoreUpdates.delete(uid);
3771
+ void invoke$3('Viewlet.executeViewletCommand', uid, 'updateGitIgnoredUris', generation, sourceControlIgnoredUris).catch(() => {
3772
+ // Ignored decorations are optional and must not block explorer interaction.
3773
+ });
3774
+ };
3775
+ const timer = setTimeout(run, gitIgnoreApplyDelay);
3776
+ pendingGitIgnoreUpdates.set(uid, {
3777
+ run,
3778
+ timer
3779
+ });
3780
+ };
3781
+ const postponeGitIgnoredUrisUpdate = uid => {
3782
+ const pending = pendingGitIgnoreUpdates.get(uid);
3783
+ if (!pending) {
3784
+ return;
3785
+ }
3786
+ clearTimeout(pending.timer);
3787
+ const timer = setTimeout(pending.run, gitIgnoreApplyDelay);
3788
+ pendingGitIgnoreUpdates.set(uid, {
3789
+ run: pending.run,
3790
+ timer
3791
+ });
3792
+ };
3793
+ const maybeScheduleGitIgnoredUrisUpdate = (oldState, newState) => {
3794
+ if (!newState.gitIgnoreDecorations || oldState.items === newState.items || oldState.sourceControlIgnoredUris !== newState.sourceControlIgnoredUris) {
3795
+ return;
3753
3796
  }
3754
3797
  const {
3755
3798
  gitIgnoreDecorations,
3799
+ gitIgnoreGeneration,
3756
3800
  items,
3757
3801
  pathSeparator,
3758
- root
3802
+ root,
3803
+ uid
3759
3804
  } = newState;
3760
- const sourceControlIgnoredUris = await getGitIgnoredUris(root, items, pathSeparator, gitIgnoreDecorations);
3761
- return {
3762
- ...newState,
3763
- sourceControlIgnoredUris
3764
- };
3805
+ setTimeout(() => {
3806
+ void getGitIgnoredUris(root, items, pathSeparator, gitIgnoreDecorations).then(sourceControlIgnoredUris => {
3807
+ scheduleGitIgnoredUrisUpdate(uid, gitIgnoreGeneration, sourceControlIgnoredUris);
3808
+ }).catch(() => {
3809
+ // Ignored decorations are optional and must not block explorer interaction.
3810
+ });
3811
+ }, 0);
3765
3812
  };
3766
3813
  const wrapListItemCommandInternal = (fn, queued) => {
3767
3814
  const runCommand = async (id, ...args) => {
@@ -3775,7 +3822,11 @@ const wrapListItemCommandInternal = (fn, queued) => {
3775
3822
  completion
3776
3823
  };
3777
3824
  }
3778
- const updatedState = await maybeUpdateGitIgnoredUris(newState, rawUpdatedState);
3825
+ const gitIgnoreInputsChanged = newState.items !== rawUpdatedState.items || newState.root !== rawUpdatedState.root || newState.pathSeparator !== rawUpdatedState.pathSeparator || newState.gitIgnoreDecorations !== rawUpdatedState.gitIgnoreDecorations;
3826
+ const updatedState = gitIgnoreInputsChanged ? {
3827
+ ...rawUpdatedState,
3828
+ gitIgnoreGeneration: newState.gitIgnoreGeneration + 1
3829
+ } : rawUpdatedState;
3779
3830
  const {
3780
3831
  cutItems,
3781
3832
  decorations,
@@ -3818,18 +3869,27 @@ const wrapListItemCommandInternal = (fn, queued) => {
3818
3869
  };
3819
3870
  const intermediate2 = get(id);
3820
3871
  set$1(id, intermediate2.oldState, finalState);
3872
+ maybeScheduleGitIgnoredUrisUpdate(newState, finalState);
3821
3873
  return {
3822
3874
  completion
3823
3875
  };
3824
3876
  };
3825
3877
  if (!queued) {
3826
3878
  return async (id, ...args) => {
3827
- const result = await runCommand(id, ...args);
3828
- await result.completion;
3879
+ try {
3880
+ const result = await runCommand(id, ...args);
3881
+ await result.completion;
3882
+ } finally {
3883
+ postponeGitIgnoredUrisUpdate(id);
3884
+ }
3829
3885
  };
3830
3886
  }
3831
3887
  const wrappedCommand = async (id, ...args) => {
3832
- await enqueueCommand(id, () => runCommand(id, ...args));
3888
+ try {
3889
+ await enqueueCommand(id, () => runCommand(id, ...args));
3890
+ } finally {
3891
+ postponeGitIgnoredUrisUpdate(id);
3892
+ }
3833
3893
  };
3834
3894
  return wrappedCommand;
3835
3895
  };
@@ -3881,6 +3941,7 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, ass
3881
3941
  focusWord: '',
3882
3942
  focusWordTimeout: 800,
3883
3943
  gitIgnoreDecorations: false,
3944
+ gitIgnoreGeneration: 0,
3884
3945
  handleOffset: 0,
3885
3946
  hasError: false,
3886
3947
  height,
@@ -6037,9 +6098,9 @@ const handleDrop$1 = async (state, fileHandles, files, paths) => {
6037
6098
  };
6038
6099
  };
6039
6100
 
6040
- const directoryTypes$1 = [Directory, DirectoryExpanded, DirectoryExpanding];
6101
+ const directoryTypes$2 = [Directory, DirectoryExpanded, DirectoryExpanding];
6041
6102
  const isDirectory = item => {
6042
- return directoryTypes$1.includes(item.type);
6103
+ return directoryTypes$2.includes(item.type);
6043
6104
  };
6044
6105
  const isDescendant = (path, parentPath, pathSeparator) => {
6045
6106
  const prefix = parentPath.endsWith(pathSeparator) ? parentPath : `${parentPath}${pathSeparator}`;
@@ -6265,11 +6326,20 @@ const getDroppedItems = async (itemIds, isElectron) => {
6265
6326
  };
6266
6327
  };
6267
6328
 
6329
+ const directoryTypes$1 = new Set([Directory, DirectoryExpanded, DirectoryExpanding, EditingDirectoryExpanded, EditingFolder, SymLinkFolder]);
6330
+ const getDragUri = item => {
6331
+ const uri = ensureUri(item.path);
6332
+ if (directoryTypes$1.has(item.type) && !uri.endsWith('/')) {
6333
+ return `${uri}/`;
6334
+ }
6335
+ return uri;
6336
+ };
6337
+
6268
6338
  const getInternalDragPaths = (items, uris) => {
6269
6339
  if (uris.length === 0) {
6270
6340
  return [];
6271
6341
  }
6272
- const pathByUri = new Map(items.map(item => [ensureUri(item.path), item.path]));
6342
+ const pathByUri = new Map(items.map(item => [getDragUri(item), item.path]));
6273
6343
  const paths = [];
6274
6344
  for (const uri of uris) {
6275
6345
  const path = pathByUri.get(uri);
@@ -7241,8 +7311,8 @@ const getDragLabel = urls => {
7241
7311
  return String(urls.length);
7242
7312
  };
7243
7313
 
7244
- const getDragData = urls => {
7245
- const data = urls.map(ensureUri).join('\n');
7314
+ const getDragData = items => {
7315
+ const data = items.map(getDragUri).join('\n');
7246
7316
  const dragData = [{
7247
7317
  data,
7248
7318
  type: 'text/uri-list'
@@ -7252,7 +7322,7 @@ const getDragData = urls => {
7252
7322
  }];
7253
7323
  return {
7254
7324
  items: dragData,
7255
- label: getDragLabel(urls)
7325
+ label: getDragLabel(items.map(item => item.path))
7256
7326
  };
7257
7327
  };
7258
7328
 
@@ -7276,7 +7346,7 @@ const renderDragData = (oldState, newState) => {
7276
7346
  } else {
7277
7347
  draggedItems = [];
7278
7348
  }
7279
- const dragData = getDragData(draggedItems.map(item => item.path));
7349
+ const dragData = getDragData(draggedItems);
7280
7350
  return ['Viewlet.setDragData', uid, dragData];
7281
7351
  };
7282
7352
 
@@ -8345,6 +8415,7 @@ const commandMap = {
8345
8415
  'Explorer.terminate': terminate,
8346
8416
  'Explorer.toggleIndividualSelection': wrapListItemCommand(toggleIndividualSelection),
8347
8417
  'Explorer.updateEditingValue': wrapListItemCommand(updateEditingValue),
8418
+ 'Explorer.updateGitIgnoredUris': wrapListItemCommand(updateGitIgnoredUris),
8348
8419
  'Explorer.updateIcons': wrapListItemCommand(updateIcons)
8349
8420
  };
8350
8421
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "7.23.1",
3
+ "version": "7.23.3",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",