@lvce-editor/explorer-view 2.32.0 → 2.33.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.
- package/dist/explorerViewWorkerMain.js +137 -87
- package/package.json +1 -1
|
@@ -356,22 +356,11 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
356
356
|
const wrap$f = global => {
|
|
357
357
|
return new IpcChildWithModuleWorker(global);
|
|
358
358
|
};
|
|
359
|
-
const withResolvers = () => {
|
|
360
|
-
let _resolve;
|
|
361
|
-
const promise = new Promise(resolve => {
|
|
362
|
-
_resolve = resolve;
|
|
363
|
-
});
|
|
364
|
-
return {
|
|
365
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
366
|
-
resolve: _resolve,
|
|
367
|
-
promise
|
|
368
|
-
};
|
|
369
|
-
};
|
|
370
359
|
const waitForFirstMessage = async port => {
|
|
371
360
|
const {
|
|
372
361
|
resolve,
|
|
373
362
|
promise
|
|
374
|
-
} = withResolvers();
|
|
363
|
+
} = Promise.withResolvers();
|
|
375
364
|
port.addEventListener('message', resolve, {
|
|
376
365
|
once: true
|
|
377
366
|
});
|
|
@@ -442,7 +431,7 @@ const create$4 = (method, params) => {
|
|
|
442
431
|
};
|
|
443
432
|
};
|
|
444
433
|
const callbacks = Object.create(null);
|
|
445
|
-
const set$
|
|
434
|
+
const set$3 = (id, fn) => {
|
|
446
435
|
callbacks[id] = fn;
|
|
447
436
|
};
|
|
448
437
|
const get$2 = id => {
|
|
@@ -461,7 +450,7 @@ const registerPromise = () => {
|
|
|
461
450
|
resolve,
|
|
462
451
|
promise
|
|
463
452
|
} = Promise.withResolvers();
|
|
464
|
-
set$
|
|
453
|
+
set$3(id, resolve);
|
|
465
454
|
return {
|
|
466
455
|
id,
|
|
467
456
|
promise
|
|
@@ -993,6 +982,33 @@ const getPaths = items => {
|
|
|
993
982
|
return items.map(getPath);
|
|
994
983
|
};
|
|
995
984
|
|
|
985
|
+
const rpcs = Object.create(null);
|
|
986
|
+
const set$5 = (id, rpc) => {
|
|
987
|
+
rpcs[id] = rpc;
|
|
988
|
+
};
|
|
989
|
+
const get$1 = id => {
|
|
990
|
+
return rpcs[id];
|
|
991
|
+
};
|
|
992
|
+
const RendererWorker$1 = 1;
|
|
993
|
+
const invoke$2 = (method, ...params) => {
|
|
994
|
+
const rpc = get$1(RendererWorker$1);
|
|
995
|
+
// @ts-ignore
|
|
996
|
+
return rpc.invoke(method, ...params);
|
|
997
|
+
};
|
|
998
|
+
const set$2 = rpc => {
|
|
999
|
+
set$5(RendererWorker$1, rpc);
|
|
1000
|
+
};
|
|
1001
|
+
const RendererWorker = {
|
|
1002
|
+
__proto__: null,
|
|
1003
|
+
invoke: invoke$2,
|
|
1004
|
+
set: set$2
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
const {
|
|
1008
|
+
invoke,
|
|
1009
|
+
set: set$1
|
|
1010
|
+
} = RendererWorker;
|
|
1011
|
+
|
|
996
1012
|
const DELTA_EDITING = 100;
|
|
997
1013
|
|
|
998
1014
|
const BlockDevice = 1;
|
|
@@ -1010,37 +1026,26 @@ const EditingFile = File + DELTA_EDITING;
|
|
|
1010
1026
|
const EditingFolder = Directory + DELTA_EDITING;
|
|
1011
1027
|
const EditingDirectoryExpanded = DirectoryExpanded + DELTA_EDITING;
|
|
1012
1028
|
|
|
1013
|
-
const
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
};
|
|
1019
|
-
const get$1 = id => {
|
|
1020
|
-
return rpcs[id];
|
|
1021
|
-
};
|
|
1022
|
-
|
|
1023
|
-
const invoke = (method, ...params) => {
|
|
1024
|
-
const rpc = get$1(RendererWorker);
|
|
1025
|
-
// @ts-ignore
|
|
1026
|
-
return rpc.invoke(method, ...params);
|
|
1027
|
-
};
|
|
1028
|
-
|
|
1029
|
-
const getFileIcon = async name => {
|
|
1030
|
-
return invoke('IconTheme.getFileIcon', {
|
|
1031
|
-
name
|
|
1032
|
-
});
|
|
1029
|
+
const getSimpleType = direntType => {
|
|
1030
|
+
if (direntType === Directory || direntType === DirectoryExpanded || direntType === EditingDirectoryExpanded || direntType === EditingFolder) {
|
|
1031
|
+
return 2;
|
|
1032
|
+
}
|
|
1033
|
+
return 1;
|
|
1033
1034
|
};
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
}
|
|
1035
|
+
const toSimpleIconRequest = request => {
|
|
1036
|
+
return {
|
|
1037
|
+
name: request.name,
|
|
1038
|
+
type: getSimpleType(request.type)
|
|
1039
|
+
};
|
|
1039
1040
|
};
|
|
1040
1041
|
|
|
1041
1042
|
const requestFileIcons = async requests => {
|
|
1042
|
-
|
|
1043
|
-
|
|
1043
|
+
if (requests.length === 0) {
|
|
1044
|
+
return [];
|
|
1045
|
+
}
|
|
1046
|
+
const simpleRequests = requests.map(toSimpleIconRequest);
|
|
1047
|
+
const icons = await invoke('IconTheme.getIcons', simpleRequests);
|
|
1048
|
+
return icons;
|
|
1044
1049
|
};
|
|
1045
1050
|
|
|
1046
1051
|
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
@@ -4129,11 +4134,6 @@ const renderFocus = (oldState, newState) => {
|
|
|
4129
4134
|
return [];
|
|
4130
4135
|
};
|
|
4131
4136
|
|
|
4132
|
-
const None$2 = 'none';
|
|
4133
|
-
const ToolBar = 'toolbar';
|
|
4134
|
-
const Tree = 'tree';
|
|
4135
|
-
const TreeItem$1 = 'treeitem';
|
|
4136
|
-
|
|
4137
4137
|
const Actions = 'Actions';
|
|
4138
4138
|
const Button$2 = 'Button';
|
|
4139
4139
|
const ButtonNarrow = 'ButtonNarrow';
|
|
@@ -4153,7 +4153,10 @@ const Label = 'Label';
|
|
|
4153
4153
|
const ListItems = 'ListItems';
|
|
4154
4154
|
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
4155
4155
|
const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
4156
|
-
const
|
|
4156
|
+
const ScrollBar = 'ScrollBar';
|
|
4157
|
+
const ScrollBarSmall = 'ScrollBarSmall';
|
|
4158
|
+
const ScrollBarThumb = 'ScrollBarThumb';
|
|
4159
|
+
const TreeItem$1 = 'TreeItem';
|
|
4157
4160
|
const TreeItemActive = 'TreeItemActive';
|
|
4158
4161
|
const Viewlet = 'Viewlet';
|
|
4159
4162
|
const Welcome = 'Welcome';
|
|
@@ -4197,6 +4200,12 @@ const text = data => {
|
|
|
4197
4200
|
childCount: 0
|
|
4198
4201
|
};
|
|
4199
4202
|
};
|
|
4203
|
+
const px = value => {
|
|
4204
|
+
return `${value}px`;
|
|
4205
|
+
};
|
|
4206
|
+
const position = (x, y) => {
|
|
4207
|
+
return `${x}px ${y}px`;
|
|
4208
|
+
};
|
|
4200
4209
|
|
|
4201
4210
|
const Button$1 = 1;
|
|
4202
4211
|
const Div = 4;
|
|
@@ -4204,6 +4213,33 @@ const Input = 6;
|
|
|
4204
4213
|
const Img = 17;
|
|
4205
4214
|
const P = 50;
|
|
4206
4215
|
|
|
4216
|
+
const getExplorerWelcomeVirtualDom = isWide => {
|
|
4217
|
+
return [{
|
|
4218
|
+
type: Div,
|
|
4219
|
+
className: mergeClassNames(Viewlet, Explorer),
|
|
4220
|
+
tabIndex: 0,
|
|
4221
|
+
childCount: 1
|
|
4222
|
+
}, {
|
|
4223
|
+
type: Div,
|
|
4224
|
+
className: Welcome,
|
|
4225
|
+
childCount: 2
|
|
4226
|
+
}, {
|
|
4227
|
+
type: P,
|
|
4228
|
+
className: WelcomeMessage,
|
|
4229
|
+
childCount: 1
|
|
4230
|
+
}, text(youHaveNotYetOpenedAFolder()), {
|
|
4231
|
+
type: Button$1,
|
|
4232
|
+
className: mergeClassNames(Button$2, ButtonPrimary, isWide ? ButtonWide : ButtonNarrow),
|
|
4233
|
+
childCount: 1,
|
|
4234
|
+
onClick: HandleClickOpenFolder
|
|
4235
|
+
}, text(openFolder$1())];
|
|
4236
|
+
};
|
|
4237
|
+
|
|
4238
|
+
const None$2 = 'none';
|
|
4239
|
+
const ToolBar = 'toolbar';
|
|
4240
|
+
const Tree = 'tree';
|
|
4241
|
+
const TreeItem = 'treeitem';
|
|
4242
|
+
|
|
4207
4243
|
const chevronDownVirtualDom = {
|
|
4208
4244
|
type: Div,
|
|
4209
4245
|
className: mergeClassNames(Chevron, MaskIconChevronDown),
|
|
@@ -4291,7 +4327,7 @@ const getExplorerItemVirtualDom = item => {
|
|
|
4291
4327
|
const chevronDom = getChevronVirtualDom(chevron);
|
|
4292
4328
|
return [{
|
|
4293
4329
|
type: Div,
|
|
4294
|
-
role: TreeItem
|
|
4330
|
+
role: TreeItem,
|
|
4295
4331
|
className,
|
|
4296
4332
|
draggable: true,
|
|
4297
4333
|
title: path,
|
|
@@ -4307,28 +4343,6 @@ const getExplorerItemVirtualDom = item => {
|
|
|
4307
4343
|
}, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name)];
|
|
4308
4344
|
};
|
|
4309
4345
|
|
|
4310
|
-
const getExplorerWelcomeVirtualDom = isWide => {
|
|
4311
|
-
return [{
|
|
4312
|
-
type: Div,
|
|
4313
|
-
className: mergeClassNames(Viewlet, Explorer),
|
|
4314
|
-
tabIndex: 0,
|
|
4315
|
-
childCount: 1
|
|
4316
|
-
}, {
|
|
4317
|
-
type: Div,
|
|
4318
|
-
className: Welcome,
|
|
4319
|
-
childCount: 2
|
|
4320
|
-
}, {
|
|
4321
|
-
type: P,
|
|
4322
|
-
className: WelcomeMessage,
|
|
4323
|
-
childCount: 1
|
|
4324
|
-
}, text(youHaveNotYetOpenedAFolder()), {
|
|
4325
|
-
type: Button$1,
|
|
4326
|
-
className: mergeClassNames(Button$2, ButtonPrimary, isWide ? ButtonWide : ButtonNarrow),
|
|
4327
|
-
childCount: 1,
|
|
4328
|
-
onClick: HandleClickOpenFolder
|
|
4329
|
-
}, text(openFolder$1())];
|
|
4330
|
-
};
|
|
4331
|
-
|
|
4332
4346
|
const getActiveDescendant = focusedIndex => {
|
|
4333
4347
|
if (focusedIndex >= 0) {
|
|
4334
4348
|
return 'TreeItemActive';
|
|
@@ -4341,17 +4355,8 @@ const getClassName = (focused, focusedIndex, dropTarget) => {
|
|
|
4341
4355
|
const className = mergeClassNames(ListItems, extraClass1, extraClass2);
|
|
4342
4356
|
return className;
|
|
4343
4357
|
};
|
|
4344
|
-
const
|
|
4345
|
-
|
|
4346
|
-
childCount: 1,
|
|
4347
|
-
className: mergeClassNames(Viewlet, Explorer),
|
|
4348
|
-
role: 'none'
|
|
4349
|
-
};
|
|
4350
|
-
const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused, dropTargets) => {
|
|
4351
|
-
if (!root) {
|
|
4352
|
-
return getExplorerWelcomeVirtualDom(isWide);
|
|
4353
|
-
}
|
|
4354
|
-
const dom = [parentNode, {
|
|
4358
|
+
const getListItemsVirtualDom = (visibleItems, focusedIndex, focused, dropTargets) => {
|
|
4359
|
+
const dom = [{
|
|
4355
4360
|
type: Div,
|
|
4356
4361
|
className: getClassName(focused, focusedIndex, dropTargets),
|
|
4357
4362
|
tabIndex: 0,
|
|
@@ -4373,6 +4378,50 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
|
|
|
4373
4378
|
return dom;
|
|
4374
4379
|
};
|
|
4375
4380
|
|
|
4381
|
+
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
4382
|
+
if (size >= contentSize) {
|
|
4383
|
+
return 0;
|
|
4384
|
+
}
|
|
4385
|
+
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
4386
|
+
};
|
|
4387
|
+
|
|
4388
|
+
const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
4389
|
+
const shouldShowScrollbar = scrollBarHeight > 0;
|
|
4390
|
+
if (!shouldShowScrollbar) {
|
|
4391
|
+
return [];
|
|
4392
|
+
}
|
|
4393
|
+
const heightString = px(scrollBarHeight);
|
|
4394
|
+
const translateString = position(0, scrollBarTop);
|
|
4395
|
+
return [{
|
|
4396
|
+
type: Div,
|
|
4397
|
+
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
4398
|
+
childCount: 1
|
|
4399
|
+
}, {
|
|
4400
|
+
type: Div,
|
|
4401
|
+
className: ScrollBarThumb,
|
|
4402
|
+
childCount: 0,
|
|
4403
|
+
height: heightString,
|
|
4404
|
+
translate: translateString
|
|
4405
|
+
}];
|
|
4406
|
+
};
|
|
4407
|
+
|
|
4408
|
+
const parentNode = {
|
|
4409
|
+
type: Div,
|
|
4410
|
+
childCount: 2,
|
|
4411
|
+
className: mergeClassNames(Viewlet, Explorer),
|
|
4412
|
+
role: 'none'
|
|
4413
|
+
};
|
|
4414
|
+
const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused, dropTargets, height, contentHeight, scrollTop) => {
|
|
4415
|
+
if (!root) {
|
|
4416
|
+
return getExplorerWelcomeVirtualDom(isWide);
|
|
4417
|
+
}
|
|
4418
|
+
const scrollBarHeight = getScrollBarSize(height, contentHeight, 20);
|
|
4419
|
+
const scrollBarTop = Math.round(scrollTop / contentHeight * height);
|
|
4420
|
+
const scrollBarDom = getScrollBarVirtualDom(scrollBarHeight, scrollBarTop);
|
|
4421
|
+
const dom = [parentNode, ...getListItemsVirtualDom(visibleItems, focusedIndex, focused, dropTargets), ...scrollBarDom];
|
|
4422
|
+
return dom;
|
|
4423
|
+
};
|
|
4424
|
+
|
|
4376
4425
|
const None$1 = 0;
|
|
4377
4426
|
const Right = 1;
|
|
4378
4427
|
const Down = 2;
|
|
@@ -4408,8 +4457,8 @@ const getExpandedType = type => {
|
|
|
4408
4457
|
}
|
|
4409
4458
|
};
|
|
4410
4459
|
|
|
4411
|
-
const focused = mergeClassNames(TreeItem, TreeItemActive);
|
|
4412
|
-
const selected = mergeClassNames(TreeItem, TreeItemActive);
|
|
4460
|
+
const focused = mergeClassNames(TreeItem$1, TreeItemActive);
|
|
4461
|
+
const selected = mergeClassNames(TreeItem$1, TreeItemActive);
|
|
4413
4462
|
const getTreeItemClassName = (isSelected, isFocused) => {
|
|
4414
4463
|
if (isFocused) {
|
|
4415
4464
|
return focused;
|
|
@@ -4417,7 +4466,7 @@ const getTreeItemClassName = (isSelected, isFocused) => {
|
|
|
4417
4466
|
if (isSelected) {
|
|
4418
4467
|
return selected;
|
|
4419
4468
|
}
|
|
4420
|
-
return TreeItem;
|
|
4469
|
+
return TreeItem$1;
|
|
4421
4470
|
};
|
|
4422
4471
|
|
|
4423
4472
|
const defaultIndent$1 = 1;
|
|
@@ -4488,7 +4537,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
4488
4537
|
const renderItems = (oldState, newState) => {
|
|
4489
4538
|
const visibleDirents = getVisibleExplorerItems(newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.editingIndex, newState.editingType, newState.editingValue, newState.editingErrorMessage, newState.icons, newState.useChevrons, newState.dropTargets, newState.editingIcon);
|
|
4490
4539
|
const isWide = newState.width > 450;
|
|
4491
|
-
const
|
|
4540
|
+
const contentHeight = newState.items.length * newState.itemHeight;
|
|
4541
|
+
const dom = getExplorerVirtualDom(visibleDirents, newState.focusedIndex, newState.root, isWide, newState.focused, newState.dropTargets, newState.height, contentHeight, newState.deltaY);
|
|
4492
4542
|
return ['Viewlet.setDom2', dom];
|
|
4493
4543
|
};
|
|
4494
4544
|
|
|
@@ -4840,7 +4890,7 @@ const revealItemHidden = async (state, uri) => {
|
|
|
4840
4890
|
}
|
|
4841
4891
|
const pathPartsToReveal = getPathPartsToReveal(root, pathParts, items);
|
|
4842
4892
|
const pathPartsChildren = await Promise.all(pathPartsToReveal.map(getPathPartChildren));
|
|
4843
|
-
const pathPartsChildrenFlat = pathPartsChildren.flat(
|
|
4893
|
+
const pathPartsChildrenFlat = pathPartsChildren.flat();
|
|
4844
4894
|
const orderedPathParts = orderDirents(pathPartsChildrenFlat);
|
|
4845
4895
|
const mergedDirents = mergeVisibleWithHiddenItems(items, orderedPathParts);
|
|
4846
4896
|
const index = getIndex(mergedDirents, uri);
|
|
@@ -5112,7 +5162,7 @@ const listen = async () => {
|
|
|
5112
5162
|
const rpc = await WebWorkerRpcClient.create({
|
|
5113
5163
|
commandMap: commandMap
|
|
5114
5164
|
});
|
|
5115
|
-
set$
|
|
5165
|
+
set$1(rpc);
|
|
5116
5166
|
};
|
|
5117
5167
|
|
|
5118
5168
|
const main = async () => {
|