@lvce-editor/explorer-view 7.23.1 → 7.23.2

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,
@@ -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,
@@ -8345,6 +8406,7 @@ const commandMap = {
8345
8406
  'Explorer.terminate': terminate,
8346
8407
  'Explorer.toggleIndividualSelection': wrapListItemCommand(toggleIndividualSelection),
8347
8408
  'Explorer.updateEditingValue': wrapListItemCommand(updateEditingValue),
8409
+ 'Explorer.updateGitIgnoredUris': wrapListItemCommand(updateGitIgnoredUris),
8348
8410
  'Explorer.updateIcons': wrapListItemCommand(updateIcons)
8349
8411
  };
8350
8412
 
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.2",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",