@opensumi/ide-components 2.21.13-rc-1673328992.0 → 2.21.13
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.
- package/dist/index.css +1 -1
- package/dist/index.js +10029 -2352
- package/lib/button/index.d.ts +4 -4
- package/lib/button/index.d.ts.map +1 -1
- package/lib/checkbox/style.less +1 -1
- package/lib/dialog/index.d.ts +1 -1
- package/lib/dialog/index.d.ts.map +1 -1
- package/lib/dropdown/dropdown.d.ts +2 -2
- package/lib/dropdown/dropdown.d.ts.map +1 -1
- package/lib/icon/icon.d.ts +2 -3
- package/lib/icon/icon.d.ts.map +1 -1
- package/lib/icon/icon.js +2 -5
- package/lib/icon/icon.js.map +1 -1
- package/lib/icon/iconfont/iconManager.d.ts +0 -2
- package/lib/icon/iconfont/iconManager.d.ts.map +1 -1
- package/lib/icon/iconfont/iconMap.d.ts +0 -2
- package/lib/icon/iconfont/iconMap.d.ts.map +1 -1
- package/lib/icon/iconfont/iconMap.js +0 -2
- package/lib/icon/iconfont/iconMap.js.map +1 -1
- package/lib/icon/iconfont/iconfont.css +7 -27
- package/lib/icon/iconfont/iconfont.eot +0 -0
- package/lib/icon/iconfont/iconfont.html +3 -3
- package/lib/icon/iconfont/iconfont.js +1 -1
- package/lib/icon/iconfont/iconfont.json +21 -56
- package/lib/icon/iconfont/iconfont.svg +0 -4
- package/lib/icon/iconfont/iconfont.ttf +0 -0
- package/lib/icon/iconfont/iconfont.woff +0 -0
- package/lib/icon/iconfont/iconfont.woff2 +0 -0
- package/lib/icon/iconfont-cn.d.ts +1 -1
- package/lib/icon/iconfont-cn.d.ts.map +1 -1
- package/lib/icon/styles.less +2 -2
- package/lib/locale-context-provider.d.ts +2 -2
- package/lib/locale-context-provider.d.ts.map +1 -1
- package/lib/menu/MenuContext.d.ts +1 -1
- package/lib/menu/MenuContext.d.ts.map +1 -1
- package/lib/menu/index.d.ts +2 -2
- package/lib/menu/index.d.ts.map +1 -1
- package/lib/menu/index.js +26 -26
- package/lib/menu/index.js.map +1 -1
- package/lib/menu/style.less +5 -0
- package/lib/message/index.d.ts +5 -5
- package/lib/message/index.d.ts.map +1 -1
- package/lib/message/message.d.ts +6 -6
- package/lib/message/message.d.ts.map +1 -1
- package/lib/modal/Modal.d.ts +3 -3
- package/lib/modal/Modal.d.ts.map +1 -1
- package/lib/notification/notification.d.ts +2 -2
- package/lib/notification/notification.d.ts.map +1 -1
- package/lib/popover/index.d.ts.map +1 -1
- package/lib/popover/index.js +1 -3
- package/lib/popover/index.js.map +1 -1
- package/lib/popover/styles.less +1 -1
- package/lib/recycle-list/RecycleList.js +1 -1
- package/lib/recycle-list/RecycleList.js.map +1 -1
- package/lib/recycle-tree/RecycleTree.d.ts +2 -2
- package/lib/recycle-tree/RecycleTree.d.ts.map +1 -1
- package/lib/recycle-tree/TreeNodeRendererWrap.d.ts +2 -2
- package/lib/recycle-tree/TreeNodeRendererWrap.d.ts.map +1 -1
- package/lib/recycle-tree/basic/index.d.ts.map +1 -1
- package/lib/recycle-tree/basic/index.js +21 -45
- package/lib/recycle-tree/basic/index.js.map +1 -1
- package/lib/recycle-tree/basic/styles.less +0 -3
- package/lib/recycle-tree/basic/tree-node.define.d.ts +4 -8
- package/lib/recycle-tree/basic/tree-node.define.d.ts.map +1 -1
- package/lib/recycle-tree/basic/tree-node.define.js +9 -12
- package/lib/recycle-tree/basic/tree-node.define.js.map +1 -1
- package/lib/recycle-tree/basic/tree-node.js +2 -4
- package/lib/recycle-tree/basic/tree-node.js.map +1 -1
- package/lib/recycle-tree/basic/tree-service.d.ts +1 -9
- package/lib/recycle-tree/basic/tree-service.d.ts.map +1 -1
- package/lib/recycle-tree/basic/tree-service.js +7 -28
- package/lib/recycle-tree/basic/tree-service.js.map +1 -1
- package/lib/recycle-tree/basic/types.d.ts +8 -28
- package/lib/recycle-tree/basic/types.d.ts.map +1 -1
- package/lib/recycle-tree/basic/types.js.map +1 -1
- package/lib/recycle-tree/decorators/Adaptive/index.d.ts +1 -1
- package/lib/recycle-tree/decorators/Adaptive/index.d.ts.map +1 -1
- package/lib/recycle-tree/decorators/Filter/index.d.ts +1 -1
- package/lib/recycle-tree/decorators/Filter/index.d.ts.map +1 -1
- package/lib/recycle-tree/tree/TreeNode.d.ts +5 -18
- package/lib/recycle-tree/tree/TreeNode.d.ts.map +1 -1
- package/lib/recycle-tree/tree/TreeNode.js +159 -236
- package/lib/recycle-tree/tree/TreeNode.js.map +1 -1
- package/lib/recycle-tree/types/tree-node.d.ts +1 -5
- package/lib/recycle-tree/types/tree-node.d.ts.map +1 -1
- package/lib/recycle-tree/types/tree-node.js.map +1 -1
- package/lib/recycle-tree/types/tree.d.ts +1 -2
- package/lib/recycle-tree/types/tree.d.ts.map +1 -1
- package/lib/recycle-tree/types/watcher.d.ts +4 -4
- package/lib/recycle-tree/types/watcher.d.ts.map +1 -1
- package/lib/scrollbars/index.d.ts +1 -4
- package/lib/scrollbars/index.d.ts.map +1 -1
- package/lib/scrollbars/index.js +4 -21
- package/lib/scrollbars/index.js.map +1 -1
- package/lib/scrollbars/styles.less +0 -5
- package/lib/utils/deprecated.d.ts +1 -1
- package/lib/utils/deprecated.d.ts.map +1 -1
- package/lib/utils/deprecated.js.map +1 -1
- package/lib/utils/marked.d.ts +2 -3
- package/lib/utils/marked.d.ts.map +1 -1
- package/lib/utils/marked.js.map +1 -1
- package/lib/utils/motion.d.ts +1 -1
- package/lib/utils/motion.d.ts.map +1 -1
- package/lib/utils/type.d.ts +1 -1
- package/lib/utils/type.d.ts.map +1 -1
- package/package.json +8 -10
- package/dist/1.index.js +0 -7994
- package/lib/icon/iconfont/index.html +0 -15
- package/lib/markdown/index.d.ts +0 -15
- package/lib/markdown/index.d.ts.map +0 -1
- package/lib/markdown/index.js +0 -25
- package/lib/markdown/index.js.map +0 -1
- package/lib/markdown/render.d.ts +0 -11
- package/lib/markdown/render.d.ts.map +0 -1
- package/lib/markdown/render.js +0 -35
- package/lib/markdown/render.js.map +0 -1
- package/lib/virtual-list/index.d.ts +0 -4
- package/lib/virtual-list/index.d.ts.map +0 -1
- package/lib/virtual-list/index.js +0 -23
- package/lib/virtual-list/index.js.map +0 -1
- package/lib/virtual-list/types.d.ts +0 -30
- package/lib/virtual-list/types.d.ts.map +0 -1
- package/lib/virtual-list/types.js +0 -3
- package/lib/virtual-list/types.js.map +0 -1
|
@@ -25,6 +25,21 @@ var BranchOperatorStatus;
|
|
|
25
25
|
BranchOperatorStatus[BranchOperatorStatus["SHRINKED"] = 2] = "SHRINKED";
|
|
26
26
|
})(BranchOperatorStatus = exports.BranchOperatorStatus || (exports.BranchOperatorStatus = {}));
|
|
27
27
|
class TreeNode {
|
|
28
|
+
constructor(tree, parent, watcher, optionalMetadata) {
|
|
29
|
+
this._uid = TreeNode.nextId();
|
|
30
|
+
this._parent = parent;
|
|
31
|
+
this._tree = tree;
|
|
32
|
+
this._disposed = false;
|
|
33
|
+
this._visible = true;
|
|
34
|
+
this._metadata = Object.assign({}, (optionalMetadata || {}));
|
|
35
|
+
this._depth = parent ? parent.depth + 1 : 0;
|
|
36
|
+
if (watcher) {
|
|
37
|
+
this._watcher = watcher;
|
|
38
|
+
}
|
|
39
|
+
else if (parent) {
|
|
40
|
+
this._watcher = parent.watcher;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
28
43
|
static is(node) {
|
|
29
44
|
return !!node && 'depth' in node && 'name' in node && 'path' in node && 'id' in node;
|
|
30
45
|
}
|
|
@@ -49,7 +64,8 @@ class TreeNode {
|
|
|
49
64
|
return TreeNode.pathToId.set(path, id);
|
|
50
65
|
}
|
|
51
66
|
static getGlobalTreeState(path) {
|
|
52
|
-
|
|
67
|
+
const root = path.split(Path.separator).slice(0, 2).join(Path.separator);
|
|
68
|
+
let state = TreeNode.pathToGlobalTreeState.get(root);
|
|
53
69
|
if (!state) {
|
|
54
70
|
state = {
|
|
55
71
|
isExpanding: false,
|
|
@@ -62,7 +78,8 @@ class TreeNode {
|
|
|
62
78
|
return state;
|
|
63
79
|
}
|
|
64
80
|
static setGlobalTreeState(path, updateState) {
|
|
65
|
-
|
|
81
|
+
const root = path.split(Path.separator).slice(0, 2).join(Path.separator);
|
|
82
|
+
let state = TreeNode.pathToGlobalTreeState.get(root);
|
|
66
83
|
if (!state) {
|
|
67
84
|
state = {
|
|
68
85
|
isExpanding: false,
|
|
@@ -73,24 +90,9 @@ class TreeNode {
|
|
|
73
90
|
};
|
|
74
91
|
}
|
|
75
92
|
state = Object.assign(Object.assign({}, state), updateState);
|
|
76
|
-
TreeNode.pathToGlobalTreeState.set(
|
|
93
|
+
TreeNode.pathToGlobalTreeState.set(root, state);
|
|
77
94
|
return state;
|
|
78
95
|
}
|
|
79
|
-
constructor(tree, parent, watcher, optionalMetadata) {
|
|
80
|
-
this._uid = TreeNode.nextId();
|
|
81
|
-
this._parent = parent;
|
|
82
|
-
this._tree = tree;
|
|
83
|
-
this._disposed = false;
|
|
84
|
-
this._visible = true;
|
|
85
|
-
this._metadata = Object.assign({}, (optionalMetadata || {}));
|
|
86
|
-
this._depth = parent ? parent.depth + 1 : 0;
|
|
87
|
-
if (watcher) {
|
|
88
|
-
this._watcher = watcher;
|
|
89
|
-
}
|
|
90
|
-
else if (parent) {
|
|
91
|
-
this._watcher = parent.watcher;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
96
|
get disposed() {
|
|
95
97
|
return this._disposed;
|
|
96
98
|
}
|
|
@@ -242,6 +244,80 @@ TreeNode.pathToId = new Map();
|
|
|
242
244
|
// 每颗树都只会在根节点上绑定一个可取消的对象,即同个时间点只能存在一个改变树数据结构的事情
|
|
243
245
|
TreeNode.pathToGlobalTreeState = new Map();
|
|
244
246
|
class CompositeTreeNode extends TreeNode {
|
|
247
|
+
// parent 为undefined即表示该节点为根节点
|
|
248
|
+
constructor(tree, parent, watcher, optionalMetadata) {
|
|
249
|
+
super(tree, parent, watcher, optionalMetadata);
|
|
250
|
+
this._children = null;
|
|
251
|
+
this.refreshThrottler = new ide_utils_1.Throttler();
|
|
252
|
+
this._lock = false;
|
|
253
|
+
/**
|
|
254
|
+
* 处理Watch事件,同时可通过外部手动调 g用节点更新函数进行节点替换,这里为通用的事件管理
|
|
255
|
+
* 如: transferItem,insertItem, unlinkItem等
|
|
256
|
+
* @private
|
|
257
|
+
* @memberof CompositeTreeNode
|
|
258
|
+
*/
|
|
259
|
+
this.handleWatchEvent = async (event) => {
|
|
260
|
+
this.watcher.notifyWillProcessWatchEvent(this, event);
|
|
261
|
+
if (event.type === types_1.WatchEvent.Moved) {
|
|
262
|
+
const { oldPath, newPath } = event;
|
|
263
|
+
if (typeof oldPath !== 'string') {
|
|
264
|
+
throw new TypeError('Expected oldPath to be a string');
|
|
265
|
+
}
|
|
266
|
+
if (typeof newPath !== 'string') {
|
|
267
|
+
throw new TypeError('Expected newPath to be a string');
|
|
268
|
+
}
|
|
269
|
+
if (Path.isRelative(oldPath)) {
|
|
270
|
+
throw new TypeError('oldPath must be absolute');
|
|
271
|
+
}
|
|
272
|
+
if (Path.isRelative(newPath)) {
|
|
273
|
+
throw new TypeError('newPath must be absolute');
|
|
274
|
+
}
|
|
275
|
+
this.transferItem(oldPath, newPath);
|
|
276
|
+
}
|
|
277
|
+
else if (event.type === types_1.WatchEvent.Added) {
|
|
278
|
+
const { node } = event;
|
|
279
|
+
if (!TreeNode.is(node)) {
|
|
280
|
+
throw new TypeError('Expected node to be a TreeNode');
|
|
281
|
+
}
|
|
282
|
+
this.insertItem(node);
|
|
283
|
+
}
|
|
284
|
+
else if (event.type === types_1.WatchEvent.Removed) {
|
|
285
|
+
const { path } = event;
|
|
286
|
+
const pathObject = new Path(path);
|
|
287
|
+
const dirName = pathObject.dir.toString();
|
|
288
|
+
const name = pathObject.base.toString();
|
|
289
|
+
if (dirName === this.path && !!this.children) {
|
|
290
|
+
const item = this.children.find((c) => c.name === name);
|
|
291
|
+
if (item) {
|
|
292
|
+
this.unlinkItem(item);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
// 如果当前变化的节点已在数据视图(并非滚动到不可见区域)中不可见,则将该节点折叠,待下次更新即可,
|
|
298
|
+
if (!this.isItemVisibleAtRootSurface(this)) {
|
|
299
|
+
this.isExpanded = false;
|
|
300
|
+
this._children = null;
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
// needReload --- 判断根目录是否需要进行一次刷新,部分情况,如压缩目录下的文件创建后不应该刷新
|
|
304
|
+
await this.refresh();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
this.watcher.notifyDidProcessWatchEvent(this, event);
|
|
308
|
+
};
|
|
309
|
+
this.isExpanded = parent ? false : true;
|
|
310
|
+
this._branchSize = 0;
|
|
311
|
+
if (!parent) {
|
|
312
|
+
this.watchEvents = new Map();
|
|
313
|
+
// 为根节点创建监听器
|
|
314
|
+
this._watcher = this.generatorWatcher();
|
|
315
|
+
TreeNode.setTreeNode(this.id, this.path, this);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
this._watcher = parent.watcher;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
245
321
|
static defaultSortComparator(a, b) {
|
|
246
322
|
if (a.constructor === b.constructor) {
|
|
247
323
|
return a.name > b.name ? 1 : a.name < b.name ? -1 : 0;
|
|
@@ -320,81 +396,6 @@ class CompositeTreeNode extends TreeNode {
|
|
|
320
396
|
};
|
|
321
397
|
return watcher;
|
|
322
398
|
}
|
|
323
|
-
// parent 为undefined即表示该节点为根节点
|
|
324
|
-
constructor(tree, parent, watcher, optionalMetadata) {
|
|
325
|
-
super(tree, parent, watcher, optionalMetadata);
|
|
326
|
-
this._children = null;
|
|
327
|
-
this._lock = false;
|
|
328
|
-
this.refreshThrottler = new ide_utils_1.ThrottledDelayer(CompositeTreeNode.REFRESH_DELAY);
|
|
329
|
-
this.toRefreshPathQueue = new Set();
|
|
330
|
-
/**
|
|
331
|
-
* 处理 Watch 事件,同时可通过外部手动调 g用节点更新函数进行节点替换,这里为通用的事件管理
|
|
332
|
-
* 如: transferItem,insertItem, unlinkItem等
|
|
333
|
-
* @private
|
|
334
|
-
* @memberof CompositeTreeNode
|
|
335
|
-
*/
|
|
336
|
-
this.handleWatchEvent = async (event) => {
|
|
337
|
-
this.watcher.notifyWillProcessWatchEvent(this, event);
|
|
338
|
-
if (event.type === types_1.WatchEvent.Moved) {
|
|
339
|
-
const { oldPath, newPath } = event;
|
|
340
|
-
if (typeof oldPath !== 'string') {
|
|
341
|
-
throw new TypeError('Expected oldPath to be a string');
|
|
342
|
-
}
|
|
343
|
-
if (typeof newPath !== 'string') {
|
|
344
|
-
throw new TypeError('Expected newPath to be a string');
|
|
345
|
-
}
|
|
346
|
-
if (Path.isRelative(oldPath)) {
|
|
347
|
-
throw new TypeError('oldPath must be absolute');
|
|
348
|
-
}
|
|
349
|
-
if (Path.isRelative(newPath)) {
|
|
350
|
-
throw new TypeError('newPath must be absolute');
|
|
351
|
-
}
|
|
352
|
-
this.transferItem(oldPath, newPath);
|
|
353
|
-
}
|
|
354
|
-
else if (event.type === types_1.WatchEvent.Added) {
|
|
355
|
-
const { node } = event;
|
|
356
|
-
if (!TreeNode.is(node)) {
|
|
357
|
-
throw new TypeError('Expected node to be a TreeNode');
|
|
358
|
-
}
|
|
359
|
-
this.insertItem(node);
|
|
360
|
-
}
|
|
361
|
-
else if (event.type === types_1.WatchEvent.Removed) {
|
|
362
|
-
const { path } = event;
|
|
363
|
-
const pathObject = new Path(path);
|
|
364
|
-
const dirName = pathObject.dir.toString();
|
|
365
|
-
const name = pathObject.base.toString();
|
|
366
|
-
if (dirName === this.path && !!this.children) {
|
|
367
|
-
const item = this.children.find((c) => c.name === name);
|
|
368
|
-
if (item) {
|
|
369
|
-
this.unlinkItem(item);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
else {
|
|
374
|
-
// 如果当前变化的节点已在数据视图(并非滚动到不可见区域)中不可见,则将该节点折叠,待下次更新即可,
|
|
375
|
-
if (!this.isItemVisibleAtRootSurface(this)) {
|
|
376
|
-
this.isExpanded = false;
|
|
377
|
-
this._children = null;
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
await this.refresh();
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
this.watcher.notifyDidProcessWatchEvent(this, event);
|
|
384
|
-
};
|
|
385
|
-
this.isExpanded = parent ? false : true;
|
|
386
|
-
this._branchSize = 0;
|
|
387
|
-
if (!parent) {
|
|
388
|
-
this.watchEvents = new Map();
|
|
389
|
-
// 为根节点创建监听器
|
|
390
|
-
this._watcher = this.generatorWatcher();
|
|
391
|
-
this._root = this;
|
|
392
|
-
TreeNode.setTreeNode(this.id, this.path, this);
|
|
393
|
-
}
|
|
394
|
-
else {
|
|
395
|
-
this._watcher = parent.watcher;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
399
|
// 重载 name 的 getter/setter,路径改变时需要重新监听文件节点变化
|
|
399
400
|
set name(name) {
|
|
400
401
|
const prevPath = this.path;
|
|
@@ -451,19 +452,6 @@ class CompositeTreeNode extends TreeNode {
|
|
|
451
452
|
get lock() {
|
|
452
453
|
return this._lock;
|
|
453
454
|
}
|
|
454
|
-
get root() {
|
|
455
|
-
if ((0, ide_utils_1.isUndefined)(this._root)) {
|
|
456
|
-
this._root = this.getRoot() || null;
|
|
457
|
-
}
|
|
458
|
-
return this._root;
|
|
459
|
-
}
|
|
460
|
-
getRoot() {
|
|
461
|
-
let root = this.parent;
|
|
462
|
-
while (root && root.parent) {
|
|
463
|
-
root = root.parent;
|
|
464
|
-
}
|
|
465
|
-
return root;
|
|
466
|
-
}
|
|
467
455
|
/**
|
|
468
456
|
* 确保此“目录”的子级已加载(不影响“展开”状态)
|
|
469
457
|
* 如果子级已经加载,则返回的Promise将立即解决
|
|
@@ -540,24 +528,14 @@ class CompositeTreeNode extends TreeNode {
|
|
|
540
528
|
TreeNode.setTreeNode(this.id, this.path, this);
|
|
541
529
|
}
|
|
542
530
|
}
|
|
543
|
-
isCompactNode(node) {
|
|
544
|
-
return CompositeTreeNode.is(node) && node.name.includes(Path.separator);
|
|
545
|
-
}
|
|
546
531
|
// 获取当前节点下所有展开的节点路径
|
|
547
532
|
getAllExpandedNodePath() {
|
|
548
|
-
var _a;
|
|
549
533
|
let paths = [];
|
|
550
534
|
if (this.children) {
|
|
551
535
|
for (let i = 0; i < this.children.length; i++) {
|
|
552
536
|
const child = this.children[i];
|
|
553
537
|
if (CompositeTreeNode.is(child) && child.expanded) {
|
|
554
|
-
|
|
555
|
-
// 当获取到的节点为压缩节点时,仅需要存储其根路径,便于后续展开更新节点状态
|
|
556
|
-
paths.push(new Path(child.parent.path).join(child.name.split(Path.separator)[0]).toString());
|
|
557
|
-
}
|
|
558
|
-
else {
|
|
559
|
-
paths.push(child.path);
|
|
560
|
-
}
|
|
538
|
+
paths.push(child.path);
|
|
561
539
|
paths = paths.concat(child.getAllExpandedNodePath());
|
|
562
540
|
}
|
|
563
541
|
}
|
|
@@ -594,7 +572,7 @@ class CompositeTreeNode extends TreeNode {
|
|
|
594
572
|
* @param token CancellationToken
|
|
595
573
|
*/
|
|
596
574
|
async resolveChildrens(token) {
|
|
597
|
-
var _a
|
|
575
|
+
var _a;
|
|
598
576
|
let childrens = this.children;
|
|
599
577
|
let expandedPaths = [];
|
|
600
578
|
try {
|
|
@@ -620,8 +598,8 @@ class CompositeTreeNode extends TreeNode {
|
|
|
620
598
|
flatTree[i] = this._children[i].id;
|
|
621
599
|
}
|
|
622
600
|
const expandedChilds = [];
|
|
623
|
-
for (let i = 0
|
|
624
|
-
const subChild =
|
|
601
|
+
for (let i = 0; i < (this.children || []).length; i++) {
|
|
602
|
+
const subChild = this.children[i];
|
|
625
603
|
if (CompositeTreeNode.is(subChild) && subChild.expanded) {
|
|
626
604
|
const paths = await subChild.resolveChildrens(token);
|
|
627
605
|
if (paths) {
|
|
@@ -651,22 +629,16 @@ class CompositeTreeNode extends TreeNode {
|
|
|
651
629
|
}
|
|
652
630
|
}
|
|
653
631
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
* @param toExpandPaths 待展开的路径
|
|
657
|
-
* @param token CancellationToken
|
|
658
|
-
* @param origin 当 this === origin 时,说明此节点为调用的源头节点
|
|
659
|
-
*/
|
|
660
|
-
async refreshTreeNodeByPaths(toExpandPaths = this.getAllExpandedNodePath(), token, origin) {
|
|
632
|
+
// 静默刷新子节点, 即不触发分支更新事件
|
|
633
|
+
async refreshTreeNodeByPaths(expandedPaths = this.getAllExpandedNodePath(), needReload = true, token, root) {
|
|
661
634
|
if (!CompositeTreeNode.is(this)) {
|
|
662
635
|
return;
|
|
663
636
|
}
|
|
664
637
|
// 如果某次刷新操作被取消,则下次刷新依旧使用上一次刷新的展开目录进行刷新
|
|
665
|
-
let
|
|
666
|
-
const originChildren = this.children;
|
|
638
|
+
let forceLoadPath;
|
|
667
639
|
let childrens = this.children || [];
|
|
668
640
|
if (this.expanded) {
|
|
669
|
-
if (
|
|
641
|
+
if (needReload) {
|
|
670
642
|
try {
|
|
671
643
|
childrens = (await this._tree.resolveChildren(this)) || [];
|
|
672
644
|
}
|
|
@@ -692,15 +664,12 @@ class CompositeTreeNode extends TreeNode {
|
|
|
692
664
|
return;
|
|
693
665
|
}
|
|
694
666
|
}
|
|
695
|
-
while ((
|
|
696
|
-
const isRelative =
|
|
667
|
+
while ((forceLoadPath = expandedPaths.shift())) {
|
|
668
|
+
const isRelative = forceLoadPath.indexOf(`${this.path}${Path.separator}`) > -1;
|
|
697
669
|
if (!isRelative) {
|
|
698
|
-
if (toExpandPath === this.path) {
|
|
699
|
-
toExpandPath = undefined;
|
|
700
|
-
}
|
|
701
670
|
break;
|
|
702
671
|
}
|
|
703
|
-
const child = childrens === null || childrens === void 0 ? void 0 : childrens.find((child) => child.path ===
|
|
672
|
+
const child = childrens === null || childrens === void 0 ? void 0 : childrens.find((child) => child.path === forceLoadPath);
|
|
704
673
|
// 对于压缩情况的路径需要额外处理一下
|
|
705
674
|
// 如果这里加载的路径是 a/b/c, 有可能目前只加载到 a/b
|
|
706
675
|
if (!child) {
|
|
@@ -709,32 +678,33 @@ class CompositeTreeNode extends TreeNode {
|
|
|
709
678
|
}
|
|
710
679
|
for (let i = 0; i < childrens.length; i++) {
|
|
711
680
|
const child = childrens[i];
|
|
712
|
-
if (
|
|
681
|
+
if (forceLoadPath.indexOf(`${child.path}${Path.separator}`) === 0 && CompositeTreeNode.is(child)) {
|
|
713
682
|
// 包含压缩节点的情况
|
|
714
|
-
if (!CompositeTreeNode.is(child)) {
|
|
715
|
-
//
|
|
683
|
+
if (!CompositeTreeNode.is(child) || child.expanded) {
|
|
684
|
+
// 说明此时节点初始化时已默认展开或被裁切,不需要进一步处理
|
|
716
685
|
continue;
|
|
717
686
|
}
|
|
718
687
|
child.isExpanded = true;
|
|
719
688
|
// 加载路径包含当前判断路径,尝试加载该节点再匹配
|
|
720
689
|
const extraExpandedPaths = await child.resolveChildrens(token);
|
|
721
|
-
if (token === null || token === void 0 ? void 0 : token.isCancellationRequested) {
|
|
722
|
-
return;
|
|
723
|
-
}
|
|
724
690
|
if (extraExpandedPaths) {
|
|
725
|
-
|
|
691
|
+
expandedPaths = expandedPaths.filter((path) => !extraExpandedPaths.find((a) => a === path));
|
|
726
692
|
}
|
|
727
|
-
if (
|
|
728
|
-
|
|
693
|
+
if (token === null || token === void 0 ? void 0 : token.isCancellationRequested) {
|
|
694
|
+
return;
|
|
729
695
|
}
|
|
730
|
-
if (
|
|
696
|
+
if (expandedPaths.length > 0) {
|
|
731
697
|
// 不需要重新reload压缩节点的子节点内容
|
|
732
|
-
|
|
733
|
-
(await child.refreshTreeNodeByPaths([...toExpandPaths], token, origin)) || [];
|
|
698
|
+
await child.refreshTreeNodeByPaths(expandedPaths, false, token, root);
|
|
734
699
|
if (token === null || token === void 0 ? void 0 : token.isCancellationRequested) {
|
|
735
700
|
return;
|
|
736
701
|
}
|
|
737
702
|
}
|
|
703
|
+
else {
|
|
704
|
+
if (child.parent !== root) {
|
|
705
|
+
child.expandBranch(child, true);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
738
708
|
break;
|
|
739
709
|
}
|
|
740
710
|
}
|
|
@@ -745,31 +715,27 @@ class CompositeTreeNode extends TreeNode {
|
|
|
745
715
|
child.isExpanded = true;
|
|
746
716
|
}
|
|
747
717
|
const extraExpandedPaths = await child.resolveChildrens(token);
|
|
718
|
+
if (extraExpandedPaths) {
|
|
719
|
+
expandedPaths = expandedPaths.filter((path) => !extraExpandedPaths.find((a) => a === path));
|
|
720
|
+
}
|
|
748
721
|
if (token === null || token === void 0 ? void 0 : token.isCancellationRequested) {
|
|
749
722
|
return;
|
|
750
723
|
}
|
|
751
|
-
if (
|
|
752
|
-
|
|
753
|
-
}
|
|
754
|
-
if (toExpandPaths.length > 0 && !(token === null || token === void 0 ? void 0 : token.isCancellationRequested)) {
|
|
755
|
-
toExpandPaths =
|
|
756
|
-
(await child.refreshTreeNodeByPaths([...toExpandPaths], token, origin)) || [];
|
|
724
|
+
if (expandedPaths.length > 0 && !(token === null || token === void 0 ? void 0 : token.isCancellationRequested)) {
|
|
725
|
+
await child.refreshTreeNodeByPaths(expandedPaths, false, token, root);
|
|
757
726
|
if (token === null || token === void 0 ? void 0 : token.isCancellationRequested) {
|
|
758
727
|
return;
|
|
759
728
|
}
|
|
760
729
|
}
|
|
761
730
|
}
|
|
762
731
|
}
|
|
763
|
-
if (
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
for (let i = 0; i < originChildren.length; i++) {
|
|
771
|
-
const child = originChildren[i];
|
|
772
|
-
child === null || child === void 0 ? void 0 : child.dispose();
|
|
732
|
+
if (forceLoadPath) {
|
|
733
|
+
expandedPaths.unshift(forceLoadPath);
|
|
734
|
+
if (needReload) {
|
|
735
|
+
if (this.children) {
|
|
736
|
+
for (let i = 0; i < this.children.length; i++) {
|
|
737
|
+
const child = this.children[i];
|
|
738
|
+
child.dispose();
|
|
773
739
|
}
|
|
774
740
|
}
|
|
775
741
|
const expandedChilds = [];
|
|
@@ -790,20 +756,24 @@ class CompositeTreeNode extends TreeNode {
|
|
|
790
756
|
}
|
|
791
757
|
this._branchSize = flatTree.length;
|
|
792
758
|
this.setFlattenedBranch(flatTree, true);
|
|
793
|
-
this.watcher.notifyDidUpdateBranch();
|
|
794
759
|
}
|
|
795
|
-
if (this.parent !==
|
|
796
|
-
//
|
|
760
|
+
if (this.parent !== root) {
|
|
761
|
+
// 第二层节点不处理
|
|
797
762
|
this.expandBranch(this, true);
|
|
798
763
|
}
|
|
799
|
-
return toExpandPaths;
|
|
800
764
|
}
|
|
801
765
|
else if (CompositeTreeNode.isRoot(this)) {
|
|
766
|
+
if (token === null || token === void 0 ? void 0 : token.isCancellationRequested) {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
802
769
|
if (this.children) {
|
|
770
|
+
// 重置旧的节点分支
|
|
803
771
|
this.shrinkBranch(this, true);
|
|
772
|
+
}
|
|
773
|
+
if (this.children) {
|
|
804
774
|
for (let i = 0; i < this.children.length; i++) {
|
|
805
775
|
const child = this.children[i];
|
|
806
|
-
child
|
|
776
|
+
child.dispose();
|
|
807
777
|
}
|
|
808
778
|
}
|
|
809
779
|
const expandedChilds = [];
|
|
@@ -852,23 +822,26 @@ class CompositeTreeNode extends TreeNode {
|
|
|
852
822
|
this.watcher.notifyDidUpdateBranch();
|
|
853
823
|
}
|
|
854
824
|
else {
|
|
855
|
-
|
|
825
|
+
if (token === null || token === void 0 ? void 0 : token.isCancellationRequested) {
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
856
828
|
const expandedChilds = [];
|
|
857
|
-
if (
|
|
829
|
+
if (needReload) {
|
|
830
|
+
// 非根节点刷新的情况
|
|
858
831
|
// 通知节点更新
|
|
859
832
|
if (this.children) {
|
|
860
833
|
// 重置旧的节点分支
|
|
861
834
|
this.shrinkBranch(this, true);
|
|
862
835
|
}
|
|
863
836
|
if (this.children) {
|
|
864
|
-
for (let i = 0
|
|
837
|
+
for (let i = 0; i < this.children.length; i++) {
|
|
865
838
|
const child = this.children[i];
|
|
866
839
|
child.dispose();
|
|
867
840
|
}
|
|
868
841
|
}
|
|
869
842
|
const flatTree = new Array(childrens.length);
|
|
870
843
|
this._children = Array(childrens.length);
|
|
871
|
-
for (let i = 0
|
|
844
|
+
for (let i = 0; i < childrens.length; i++) {
|
|
872
845
|
const child = childrens[i];
|
|
873
846
|
child.id = TreeNode.getIdByPath(child.path) || child.id;
|
|
874
847
|
this._children[i] = child;
|
|
@@ -901,11 +874,12 @@ class CompositeTreeNode extends TreeNode {
|
|
|
901
874
|
const child = expandedChilds[i];
|
|
902
875
|
child.expandBranch(child, true);
|
|
903
876
|
}
|
|
877
|
+
// 清理上一次监听函数
|
|
904
878
|
if (typeof this.watchTerminator === 'function') {
|
|
905
879
|
this.watchTerminator(this.path);
|
|
906
880
|
}
|
|
907
881
|
this.watchTerminator = this.watcher.onWatchEvent(this.path, this.handleWatchEvent);
|
|
908
|
-
if (
|
|
882
|
+
if (needReload) {
|
|
909
883
|
this.expandBranch(this);
|
|
910
884
|
}
|
|
911
885
|
}
|
|
@@ -916,7 +890,7 @@ class CompositeTreeNode extends TreeNode {
|
|
|
916
890
|
// 清理子节点,等待下次展开时更新
|
|
917
891
|
if (!!this.children && this.parent) {
|
|
918
892
|
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
919
|
-
for (let i = 0
|
|
893
|
+
for (let i = 0; i < this.children.length; i++) {
|
|
920
894
|
const child = this.children[i];
|
|
921
895
|
child.dispose();
|
|
922
896
|
}
|
|
@@ -1075,7 +1049,6 @@ class CompositeTreeNode extends TreeNode {
|
|
|
1075
1049
|
* 直接调用此方法将不会触发onWillHandleWatchEvent和onDidHandleWatchEvent事件
|
|
1076
1050
|
*/
|
|
1077
1051
|
unlinkItem(item, reparenting) {
|
|
1078
|
-
var _a;
|
|
1079
1052
|
if (!this._children) {
|
|
1080
1053
|
return;
|
|
1081
1054
|
}
|
|
@@ -1087,7 +1060,7 @@ class CompositeTreeNode extends TreeNode {
|
|
|
1087
1060
|
if (!this.isItemVisibleAtRootSurface(this)) {
|
|
1088
1061
|
return;
|
|
1089
1062
|
}
|
|
1090
|
-
|
|
1063
|
+
this._children.splice(idx, 1);
|
|
1091
1064
|
const branchSizeDecrease = 1 + (item instanceof CompositeTreeNode && item.expanded ? item._branchSize : 0);
|
|
1092
1065
|
this._branchSize -= branchSizeDecrease;
|
|
1093
1066
|
// 逐级往上查找节点的父节点,并沿途裁剪分支数
|
|
@@ -1114,14 +1087,13 @@ class CompositeTreeNode extends TreeNode {
|
|
|
1114
1087
|
* 转换节点路径
|
|
1115
1088
|
*/
|
|
1116
1089
|
transferItem(oldPath, newPath) {
|
|
1117
|
-
var _a;
|
|
1118
1090
|
const oldP = new Path(oldPath);
|
|
1119
1091
|
const from = oldP.dir.toString();
|
|
1120
1092
|
if (from !== this.path) {
|
|
1121
1093
|
return;
|
|
1122
1094
|
}
|
|
1123
1095
|
const name = oldP.base.toString();
|
|
1124
|
-
const item =
|
|
1096
|
+
const item = this._children.find((c) => c.name === name);
|
|
1125
1097
|
if (!item) {
|
|
1126
1098
|
return;
|
|
1127
1099
|
}
|
|
@@ -1244,6 +1216,7 @@ class CompositeTreeNode extends TreeNode {
|
|
|
1244
1216
|
const tempChildren = new Array(rawItems.length);
|
|
1245
1217
|
for (let i = 0; i < rawItems.length; i++) {
|
|
1246
1218
|
const child = rawItems[i];
|
|
1219
|
+
// 如果存在上一次缓存的节点,则使用缓存节点的 ID
|
|
1247
1220
|
child.id = TreeNode.getIdByPath(child.path) || child.id;
|
|
1248
1221
|
tempChildren[i] = child;
|
|
1249
1222
|
TreeNode.setIdByPath(child.path, child.id);
|
|
@@ -1262,13 +1235,13 @@ class CompositeTreeNode extends TreeNode {
|
|
|
1262
1235
|
flatTree[i] = tempChildren[i].id;
|
|
1263
1236
|
}
|
|
1264
1237
|
if (this.children) {
|
|
1238
|
+
// 重置节点分支
|
|
1265
1239
|
this.shrinkBranch(this);
|
|
1266
1240
|
}
|
|
1267
1241
|
if (this.children) {
|
|
1268
1242
|
for (let i = 0; i < this.children.length; i++) {
|
|
1269
1243
|
const child = this.children[i];
|
|
1270
|
-
|
|
1271
|
-
child === null || child === void 0 ? void 0 : child.dispose();
|
|
1244
|
+
child.dispose();
|
|
1272
1245
|
}
|
|
1273
1246
|
}
|
|
1274
1247
|
for (let i = 0; i < tempChildren.length; i++) {
|
|
@@ -1321,11 +1294,7 @@ class CompositeTreeNode extends TreeNode {
|
|
|
1321
1294
|
}
|
|
1322
1295
|
}
|
|
1323
1296
|
// 当没有传入具体路径时,使用当前展开目录作为刷新路径
|
|
1324
|
-
async refresh(tokenSource
|
|
1325
|
-
if (!CompositeTreeNode.isRoot(this)) {
|
|
1326
|
-
// 刷新操作只能从根节点进行,便于对重复的刷新操作进行合并
|
|
1327
|
-
return await this.root.refresh(tokenSource, this);
|
|
1328
|
-
}
|
|
1297
|
+
async refresh(tokenSource) {
|
|
1329
1298
|
const state = TreeNode.getGlobalTreeState(this.path);
|
|
1330
1299
|
if (state.isLoadingPath || state.isExpanding) {
|
|
1331
1300
|
return;
|
|
@@ -1351,55 +1320,14 @@ class CompositeTreeNode extends TreeNode {
|
|
|
1351
1320
|
token = state.refreshCancelToken.token;
|
|
1352
1321
|
}
|
|
1353
1322
|
}
|
|
1354
|
-
this.
|
|
1355
|
-
await this.refreshThrottler.trigger(() => this.doRefresh(token));
|
|
1323
|
+
await this.refreshThrottler.queue(async () => this.doRefresh(token));
|
|
1356
1324
|
TreeNode.setGlobalTreeState(this.path, {
|
|
1357
1325
|
isRefreshing: false,
|
|
1358
1326
|
});
|
|
1359
1327
|
}
|
|
1360
1328
|
async doRefresh(token) {
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1363
|
-
return;
|
|
1364
|
-
}
|
|
1365
|
-
const paths = target.getAllExpandedNodePath();
|
|
1366
|
-
await target.refreshTreeNodeByPaths(paths, token, target);
|
|
1367
|
-
}
|
|
1368
|
-
getRefreshNode() {
|
|
1369
|
-
let paths = Array.from(this.toRefreshPathQueue);
|
|
1370
|
-
this.toRefreshPathQueue.clear();
|
|
1371
|
-
if (!paths.length) {
|
|
1372
|
-
return this.root;
|
|
1373
|
-
}
|
|
1374
|
-
// 根据路径层级深度进行排序
|
|
1375
|
-
paths = paths.sort((a, b) => {
|
|
1376
|
-
const depthA = Path.pathDepth(a);
|
|
1377
|
-
const depthB = Path.pathDepth(b);
|
|
1378
|
-
return depthA - depthB;
|
|
1379
|
-
});
|
|
1380
|
-
if (paths.length === 1 || Path.pathDepth(paths[0]) === 1) {
|
|
1381
|
-
// 说明刷新队列中包含根节点,直接返回根节点进行刷新
|
|
1382
|
-
return TreeNode.getTreeNodeByPath(paths[0]);
|
|
1383
|
-
}
|
|
1384
|
-
const sortedPaths = paths.map((p) => new Path(p));
|
|
1385
|
-
let rootPath = sortedPaths[0];
|
|
1386
|
-
for (let i = 1, len = sortedPaths.length; i < len; i++) {
|
|
1387
|
-
if (rootPath.isEqualOrParent(sortedPaths[i])) {
|
|
1388
|
-
continue;
|
|
1389
|
-
}
|
|
1390
|
-
else {
|
|
1391
|
-
while (!rootPath.isRoot) {
|
|
1392
|
-
rootPath = rootPath.dir;
|
|
1393
|
-
if (!rootPath || rootPath.isEqualOrParent(sortedPaths[i])) {
|
|
1394
|
-
break;
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
if (rootPath) {
|
|
1400
|
-
return TreeNode.getTreeNodeByPath(rootPath.toString());
|
|
1401
|
-
}
|
|
1402
|
-
return this.root;
|
|
1329
|
+
const paths = this.getAllExpandedNodePath();
|
|
1330
|
+
await this.refreshTreeNodeByPaths(paths, true, token, this);
|
|
1403
1331
|
}
|
|
1404
1332
|
isItemVisibleAtRootSurface(node) {
|
|
1405
1333
|
let parent = node;
|
|
@@ -1643,11 +1571,7 @@ class CompositeTreeNode extends TreeNode {
|
|
|
1643
1571
|
* @memberof CompositeTreeNode
|
|
1644
1572
|
*/
|
|
1645
1573
|
getTreeNodeAtIndex(index) {
|
|
1646
|
-
|
|
1647
|
-
const id = (_a = this._flattenedBranch) === null || _a === void 0 ? void 0 : _a[index];
|
|
1648
|
-
if (!id) {
|
|
1649
|
-
return undefined;
|
|
1650
|
-
}
|
|
1574
|
+
const id = this._flattenedBranch[index];
|
|
1651
1575
|
return TreeNode.getTreeNodeById(id);
|
|
1652
1576
|
}
|
|
1653
1577
|
/**
|
|
@@ -1670,5 +1594,4 @@ class CompositeTreeNode extends TreeNode {
|
|
|
1670
1594
|
}
|
|
1671
1595
|
}
|
|
1672
1596
|
exports.CompositeTreeNode = CompositeTreeNode;
|
|
1673
|
-
CompositeTreeNode.REFRESH_DELAY = 200;
|
|
1674
1597
|
//# sourceMappingURL=TreeNode.js.map
|