@lvce-editor/explorer-view 2.44.0 → 2.46.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 +57 -31
- package/package.json +1 -1
|
@@ -523,6 +523,16 @@ const constructError = (message, type, name) => {
|
|
|
523
523
|
}
|
|
524
524
|
return new ErrorConstructor(message);
|
|
525
525
|
};
|
|
526
|
+
const joinLines = lines => {
|
|
527
|
+
return lines.join(NewLine);
|
|
528
|
+
};
|
|
529
|
+
const splitLines = lines => {
|
|
530
|
+
return lines.split(NewLine);
|
|
531
|
+
};
|
|
532
|
+
const getCurrentStack = () => {
|
|
533
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
|
|
534
|
+
return currentStack;
|
|
535
|
+
};
|
|
526
536
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
527
537
|
return string.indexOf(NewLine, startIndex);
|
|
528
538
|
};
|
|
@@ -533,19 +543,16 @@ const getParentStack = error => {
|
|
|
533
543
|
}
|
|
534
544
|
return parentStack;
|
|
535
545
|
};
|
|
536
|
-
const joinLines = lines => {
|
|
537
|
-
return lines.join(NewLine);
|
|
538
|
-
};
|
|
539
546
|
const MethodNotFound = -32601;
|
|
540
547
|
const Custom = -32001;
|
|
541
|
-
const splitLines = lines => {
|
|
542
|
-
return lines.split(NewLine);
|
|
543
|
-
};
|
|
544
548
|
const restoreJsonRpcError = error => {
|
|
549
|
+
const currentStack = getCurrentStack();
|
|
545
550
|
if (error && error instanceof Error) {
|
|
551
|
+
if (typeof error.stack === 'string') {
|
|
552
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
553
|
+
}
|
|
546
554
|
return error;
|
|
547
555
|
}
|
|
548
|
-
const currentStack = joinLines(splitLines(new Error().stack || '').slice(1));
|
|
549
556
|
if (error && error.code && error.code === MethodNotFound) {
|
|
550
557
|
const restoredError = new JsonRpcError(error.message);
|
|
551
558
|
const parentStack = getParentStack(error);
|
|
@@ -626,6 +633,17 @@ const getErrorType = prettyError => {
|
|
|
626
633
|
}
|
|
627
634
|
return undefined;
|
|
628
635
|
};
|
|
636
|
+
const isAlreadyStack = line => {
|
|
637
|
+
return line.trim().startsWith('at ');
|
|
638
|
+
};
|
|
639
|
+
const getStack = prettyError => {
|
|
640
|
+
const stackString = prettyError.stack || '';
|
|
641
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
642
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
643
|
+
return stackString.slice(newLineIndex + 1);
|
|
644
|
+
}
|
|
645
|
+
return stackString;
|
|
646
|
+
};
|
|
629
647
|
const getErrorProperty = (error, prettyError) => {
|
|
630
648
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
631
649
|
return {
|
|
@@ -638,7 +656,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
638
656
|
code: Custom,
|
|
639
657
|
message: prettyError.message,
|
|
640
658
|
data: {
|
|
641
|
-
stack: prettyError
|
|
659
|
+
stack: getStack(prettyError),
|
|
642
660
|
codeFrame: prettyError.codeFrame,
|
|
643
661
|
type: getErrorType(prettyError),
|
|
644
662
|
code: prettyError.code,
|
|
@@ -851,7 +869,7 @@ const WebWorkerRpcClient = {
|
|
|
851
869
|
};
|
|
852
870
|
|
|
853
871
|
const rpcs = Object.create(null);
|
|
854
|
-
const set$
|
|
872
|
+
const set$a = (id, rpc) => {
|
|
855
873
|
rpcs[id] = rpc;
|
|
856
874
|
};
|
|
857
875
|
const get$1 = id => {
|
|
@@ -875,19 +893,19 @@ const create$2 = rpcId => {
|
|
|
875
893
|
return rpc.invokeAndTransfer(method, ...params);
|
|
876
894
|
},
|
|
877
895
|
set(rpc) {
|
|
878
|
-
set$
|
|
896
|
+
set$a(rpcId, rpc);
|
|
879
897
|
}
|
|
880
898
|
};
|
|
881
899
|
};
|
|
882
900
|
const RendererWorker$1 = 1;
|
|
883
901
|
const {
|
|
884
|
-
invoke: invoke$
|
|
885
|
-
set: set$
|
|
902
|
+
invoke: invoke$5,
|
|
903
|
+
set: set$5
|
|
886
904
|
} = create$2(RendererWorker$1);
|
|
887
905
|
const RendererWorker = {
|
|
888
906
|
__proto__: null,
|
|
889
|
-
invoke: invoke$
|
|
890
|
-
set: set$
|
|
907
|
+
invoke: invoke$5,
|
|
908
|
+
set: set$5
|
|
891
909
|
};
|
|
892
910
|
|
|
893
911
|
const {
|
|
@@ -978,10 +996,10 @@ const createNewDirentsAccept = async (newFileName, pathSeparator, absolutePath,
|
|
|
978
996
|
await createNestedPath(root, parentPath, pathSeparator);
|
|
979
997
|
}
|
|
980
998
|
await createFn(absolutePath);
|
|
981
|
-
return
|
|
999
|
+
return '';
|
|
982
1000
|
} catch (error) {
|
|
983
1001
|
console.error(new VError(error, `Failed to create file`));
|
|
984
|
-
return
|
|
1002
|
+
return `${error}`;
|
|
985
1003
|
}
|
|
986
1004
|
};
|
|
987
1005
|
|
|
@@ -1481,9 +1499,12 @@ const acceptCreate = async (state, newDirentType, createFn) => {
|
|
|
1481
1499
|
}
|
|
1482
1500
|
const parentFolder = getParentFolder(items, focusedIndex, root);
|
|
1483
1501
|
const absolutePath = join2(parentFolder, newFileName);
|
|
1484
|
-
const
|
|
1485
|
-
if (
|
|
1486
|
-
return
|
|
1502
|
+
const createErrorMessage = await createNewDirentsAccept(newFileName, pathSeparator, absolutePath, root, createFn);
|
|
1503
|
+
if (createErrorMessage) {
|
|
1504
|
+
return {
|
|
1505
|
+
...state,
|
|
1506
|
+
editingErrorMessage: createErrorMessage
|
|
1507
|
+
};
|
|
1487
1508
|
}
|
|
1488
1509
|
const pathPaths = getPathParts(root, absolutePath, pathSeparator);
|
|
1489
1510
|
const children = await getPathPartsChildren(pathPaths);
|
|
@@ -4297,6 +4318,11 @@ const getErrorMessagePosition = (itemHeight, focusedIndex, minLineY, depth, inde
|
|
|
4297
4318
|
};
|
|
4298
4319
|
};
|
|
4299
4320
|
|
|
4321
|
+
const None$2 = 'none';
|
|
4322
|
+
const ToolBar = 'toolbar';
|
|
4323
|
+
const Tree = 'tree';
|
|
4324
|
+
const TreeItem$1 = 'treeitem';
|
|
4325
|
+
|
|
4300
4326
|
const Actions = 'Actions';
|
|
4301
4327
|
const Button$2 = 'Button';
|
|
4302
4328
|
const ButtonNarrow = 'ButtonNarrow';
|
|
@@ -4319,7 +4345,7 @@ const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
|
4319
4345
|
const ScrollBar = 'ScrollBar';
|
|
4320
4346
|
const ScrollBarSmall = 'ScrollBarSmall';
|
|
4321
4347
|
const ScrollBarThumb = 'ScrollBarThumb';
|
|
4322
|
-
const TreeItem
|
|
4348
|
+
const TreeItem = 'TreeItem';
|
|
4323
4349
|
const TreeItemActive = 'TreeItemActive';
|
|
4324
4350
|
const Viewlet = 'Viewlet';
|
|
4325
4351
|
const Welcome = 'Welcome';
|
|
@@ -4410,11 +4436,6 @@ const getExplorerWelcomeVirtualDom = isWide => {
|
|
|
4410
4436
|
}, text(openFolder$1())];
|
|
4411
4437
|
};
|
|
4412
4438
|
|
|
4413
|
-
const None$2 = 'none';
|
|
4414
|
-
const ToolBar = 'toolbar';
|
|
4415
|
-
const Tree = 'tree';
|
|
4416
|
-
const TreeItem = 'treeitem';
|
|
4417
|
-
|
|
4418
4439
|
const chevronDownVirtualDom = {
|
|
4419
4440
|
type: Div,
|
|
4420
4441
|
className: mergeClassNames(Chevron, MaskIconChevronDown),
|
|
@@ -4502,7 +4523,7 @@ const getExplorerItemVirtualDom = item => {
|
|
|
4502
4523
|
const chevronDom = getChevronVirtualDom(chevron);
|
|
4503
4524
|
return [{
|
|
4504
4525
|
type: Div,
|
|
4505
|
-
role: TreeItem,
|
|
4526
|
+
role: TreeItem$1,
|
|
4506
4527
|
className,
|
|
4507
4528
|
draggable: true,
|
|
4508
4529
|
title: path,
|
|
@@ -4560,6 +4581,11 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
|
4560
4581
|
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
4561
4582
|
};
|
|
4562
4583
|
|
|
4584
|
+
const getScrollBarTop = (height, contentHeight, scrollTop) => {
|
|
4585
|
+
const scrollBarTop = Math.round(scrollTop / contentHeight * height);
|
|
4586
|
+
return scrollBarTop;
|
|
4587
|
+
};
|
|
4588
|
+
|
|
4563
4589
|
const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
4564
4590
|
const shouldShowScrollbar = scrollBarHeight > 0;
|
|
4565
4591
|
if (!shouldShowScrollbar) {
|
|
@@ -4595,7 +4621,7 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
|
|
|
4595
4621
|
return getExplorerWelcomeVirtualDom(isWide);
|
|
4596
4622
|
}
|
|
4597
4623
|
const scrollBarHeight = getScrollBarSize(height, contentHeight, 20);
|
|
4598
|
-
const scrollBarTop =
|
|
4624
|
+
const scrollBarTop = getScrollBarTop(height, contentHeight, scrollTop);
|
|
4599
4625
|
const scrollBarDom = getScrollBarVirtualDom(scrollBarHeight, scrollBarTop);
|
|
4600
4626
|
const errorDom = getErrorMessageDom(errorMessage, errorMessageLeft, errorMessageTop);
|
|
4601
4627
|
const childCount = getChildCount(scrollBarDom.length, errorDom.length);
|
|
@@ -4603,7 +4629,7 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
|
|
|
4603
4629
|
type: Div,
|
|
4604
4630
|
childCount,
|
|
4605
4631
|
className: mergeClassNames(Viewlet, Explorer),
|
|
4606
|
-
role:
|
|
4632
|
+
role: None$2
|
|
4607
4633
|
};
|
|
4608
4634
|
const dom = [parentNode, ...getListItemsVirtualDom(visibleItems, focusedIndex, focused, dropTargets), ...scrollBarDom, ...errorDom];
|
|
4609
4635
|
return dom;
|
|
@@ -4644,8 +4670,8 @@ const getExpandedType = type => {
|
|
|
4644
4670
|
}
|
|
4645
4671
|
};
|
|
4646
4672
|
|
|
4647
|
-
const focused = mergeClassNames(TreeItem
|
|
4648
|
-
const selected = mergeClassNames(TreeItem
|
|
4673
|
+
const focused = mergeClassNames(TreeItem, TreeItemActive);
|
|
4674
|
+
const selected = mergeClassNames(TreeItem, TreeItemActive);
|
|
4649
4675
|
const getTreeItemClassName = (isSelected, isFocused) => {
|
|
4650
4676
|
if (isFocused) {
|
|
4651
4677
|
return focused;
|
|
@@ -4653,7 +4679,7 @@ const getTreeItemClassName = (isSelected, isFocused) => {
|
|
|
4653
4679
|
if (isSelected) {
|
|
4654
4680
|
return selected;
|
|
4655
4681
|
}
|
|
4656
|
-
return TreeItem
|
|
4682
|
+
return TreeItem;
|
|
4657
4683
|
};
|
|
4658
4684
|
|
|
4659
4685
|
const defaultIndent$1 = 1;
|