@lvce-editor/main-area-worker 9.32.4 → 9.32.5

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.
@@ -935,7 +935,10 @@ const constructError = (message, type, name) => {
935
935
  if (ErrorConstructor === Error) {
936
936
  const error = new Error(message);
937
937
  if (name && name !== 'VError') {
938
- error.name = name;
938
+ Object.defineProperty(error, 'name', {
939
+ configurable: true,
940
+ value: name
941
+ });
939
942
  }
940
943
  return error;
941
944
  }
@@ -966,31 +969,45 @@ const getParentStack = error => {
966
969
  };
967
970
  const MethodNotFound = -32601;
968
971
  const Custom = -32001;
972
+ const setStack = (error, stack) => {
973
+ const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
974
+ if (descriptor) {
975
+ if (!descriptor.configurable && !descriptor.writable) {
976
+ return;
977
+ }
978
+ if (!descriptor.configurable && descriptor.writable) {
979
+ error.stack = stack;
980
+ return;
981
+ }
982
+ }
983
+ Object.defineProperty(error, 'stack', {
984
+ configurable: true,
985
+ value: stack,
986
+ writable: true
987
+ });
988
+ };
969
989
  const restoreExistingError = (error, currentStack) => {
970
990
  if (typeof error.stack === 'string') {
971
- error.stack = error.stack + NewLine + currentStack;
991
+ setStack(error, `${error.stack}${NewLine}${currentStack}`);
972
992
  }
973
993
  return error;
974
994
  };
975
995
  const restoreMethodNotFoundError = (error, currentStack) => {
976
996
  const restoredError = new JsonRpcError(error.message);
977
997
  const parentStack = getParentStack(error);
978
- restoredError.stack = parentStack + NewLine + currentStack;
998
+ setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
979
999
  return restoredError;
980
1000
  };
981
1001
  const restoreStackFromData = (restoredError, error, currentStack) => {
982
1002
  if (error.data.stack && error.data.type && error.message) {
983
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
1003
+ setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
984
1004
  return;
985
1005
  }
986
1006
  if (error.data.stack) {
987
- restoredError.stack = error.data.stack;
1007
+ setStack(restoredError, error.data.stack);
988
1008
  }
989
1009
  };
990
1010
  const applyDataProperties = (restoredError, error) => {
991
- if (!error.data) {
992
- return;
993
- }
994
1011
  restoreStackFromData(restoredError, error, getCurrentStack());
995
1012
  if (error.data.codeFrame) {
996
1013
  // @ts-ignore
@@ -1011,7 +1028,7 @@ const applyDirectProperties = (restoredError, error) => {
1011
1028
  const indexNewLine = getNewLineIndex(lowerStack);
1012
1029
  const parentStack = getParentStack(error);
1013
1030
  // @ts-ignore
1014
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
1031
+ setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
1015
1032
  }
1016
1033
  if (error.codeFrame) {
1017
1034
  // @ts-ignore
@@ -4504,6 +4521,7 @@ const EditorGroupHeader = 'EditorGroupHeader';
4504
4521
  const EmptyGroupHeader = 'EmptyGroupHeader';
4505
4522
  const EmptyGroupCloseButton = 'EmptyGroupCloseButton';
4506
4523
  const EditorGroup = 'EditorGroup';
4524
+ const EditorGroupEmpty = 'EditorGroup EditorGroupEmpty';
4507
4525
  const EditorGroupsHorizontal = 'EditorGroupsHorizontal';
4508
4526
  const EditorGroupsVertical = 'EditorGroupsVertical';
4509
4527
  const EditorContainer = 'EditorContainer';
@@ -5341,7 +5359,7 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
5341
5359
  return newState;
5342
5360
  };
5343
5361
 
5344
- const loadContent = async (state, savedState) => {
5362
+ const loadContent$1 = async (state, savedState) => {
5345
5363
  const homeDirUri = await loadHomeDirUri();
5346
5364
  const stateWithHomeDir = {
5347
5365
  ...state,
@@ -5379,7 +5397,7 @@ const loadContent = async (state, savedState) => {
5379
5397
  };
5380
5398
 
5381
5399
  const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
5382
- return loadContent(state, savedState);
5400
+ return loadContent$1(state, savedState);
5383
5401
  };
5384
5402
 
5385
5403
  const handleWorkspaceRefresh = async (state, refresh = {}) => {
@@ -6274,31 +6292,36 @@ const HandleSashCornerPointerDown = 20;
6274
6292
  const HandleSashCornerPointerMove = 21;
6275
6293
  const HandleSashCornerPointerUp = 22;
6276
6294
 
6295
+ const textEditorNode = {
6296
+ childCount: 1,
6297
+ className: TextEditor,
6298
+ type: Div
6299
+ };
6300
+ const editorContentNode = {
6301
+ childCount: 1,
6302
+ className: EditorContent,
6303
+ type: Pre
6304
+ };
6277
6305
  const renderContent = content => {
6278
- return [{
6279
- childCount: 1,
6280
- className: TextEditor,
6281
- type: Div
6282
- }, {
6283
- childCount: 1,
6284
- className: EditorContent,
6285
- type: Pre
6286
- }, text(content)];
6306
+ return [textEditorNode, editorContentNode, text(content)];
6287
6307
  };
6288
6308
 
6309
+ const textEditorErrorNode = {
6310
+ childCount: 1,
6311
+ className: TextEditorError,
6312
+ type: Div
6313
+ };
6314
+ const editorContentErrorNode = {
6315
+ childCount: 2,
6316
+ className: EditorContentError,
6317
+ type: Div
6318
+ };
6319
+ const paragraphNode = {
6320
+ childCount: 1,
6321
+ type: P
6322
+ };
6289
6323
  const renderError = errorMessage => {
6290
- return [{
6291
- childCount: 1,
6292
- className: TextEditorError,
6293
- type: Div
6294
- }, {
6295
- childCount: 2,
6296
- className: EditorContentError,
6297
- type: Div
6298
- }, {
6299
- childCount: 1,
6300
- type: P
6301
- }, text(`Error: ${errorMessage}`), {
6324
+ return [textEditorErrorNode, editorContentErrorNode, paragraphNode, text(`Error: ${errorMessage}`), {
6302
6325
  childCount: 1,
6303
6326
  className: mergeClassNames(Button, ButtonSecondary),
6304
6327
  'data-action': RetryOpen,
@@ -6308,16 +6331,18 @@ const renderError = errorMessage => {
6308
6331
  }, text(retry())];
6309
6332
  };
6310
6333
 
6334
+ const textEditorLoadingNode = {
6335
+ childCount: 1,
6336
+ className: TextEditorLoading,
6337
+ type: Div
6338
+ };
6339
+ const editorContentLoadingNode = {
6340
+ childCount: 1,
6341
+ className: EditorContentLoading,
6342
+ type: Div
6343
+ };
6311
6344
  const renderLoading = () => {
6312
- return [{
6313
- childCount: 1,
6314
- className: TextEditorLoading,
6315
- type: Div
6316
- }, {
6317
- childCount: 1,
6318
- className: EditorContentLoading,
6319
- type: Div
6320
- }, text('Loading...')];
6345
+ return [textEditorLoadingNode, editorContentLoadingNode, text('Loading...')];
6321
6346
  };
6322
6347
 
6323
6348
  const renderViewletReference = tab => {
@@ -6356,6 +6381,16 @@ const renderEditor = tab => {
6356
6381
  return renderContent('');
6357
6382
  };
6358
6383
 
6384
+ const dirtyIconNode = {
6385
+ childCount: 0,
6386
+ className: MaskIconCircleFilled,
6387
+ type: Div
6388
+ };
6389
+ const closeIconNode$1 = {
6390
+ childCount: 0,
6391
+ className: MaskIconClose,
6392
+ type: Div
6393
+ };
6359
6394
  const renderTabActions = (isDirty, tabIndex, groupIndex) => {
6360
6395
  if (isDirty) {
6361
6396
  return [{
@@ -6366,11 +6401,7 @@ const renderTabActions = (isDirty, tabIndex, groupIndex) => {
6366
6401
  'data-index': tabIndex,
6367
6402
  onClick: HandleClickClose,
6368
6403
  type: Button$2
6369
- }, {
6370
- childCount: 0,
6371
- className: MaskIconCircleFilled,
6372
- type: Div
6373
- }];
6404
+ }, dirtyIconNode];
6374
6405
  }
6375
6406
  return [{
6376
6407
  'aria-label': 'Close',
@@ -6380,24 +6411,26 @@ const renderTabActions = (isDirty, tabIndex, groupIndex) => {
6380
6411
  'data-index': tabIndex,
6381
6412
  onClick: HandleClickClose,
6382
6413
  type: Button$2
6383
- }, {
6384
- childCount: 0,
6385
- className: MaskIconClose,
6386
- type: Div
6387
- }];
6414
+ }, closeIconNode$1];
6388
6415
  };
6389
6416
 
6390
6417
  const ExtensionDetailScheme = 'extension-detail://';
6391
6418
  const KeyBindingsUri = 'app://keybindings';
6392
6419
  const RunningExtensionsScheme = 'running-extensions://';
6393
6420
  const SearchEditorScheme = 'search-editor://';
6421
+ const tabIconNode = {
6422
+ childCount: 1,
6423
+ className: TabIcon,
6424
+ role: None$1,
6425
+ type: Div
6426
+ };
6427
+ const tabTitleNode = {
6428
+ childCount: 1,
6429
+ className: TabTitle,
6430
+ type: Span
6431
+ };
6394
6432
  const renderMaskIcon = className => {
6395
- return [{
6396
- childCount: 1,
6397
- className: TabIcon,
6398
- role: None$1,
6399
- type: Div
6400
- }, {
6433
+ return [tabIconNode, {
6401
6434
  childCount: 0,
6402
6435
  className,
6403
6436
  type: Div
@@ -6428,13 +6461,13 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
6428
6461
  const closeButtonNodes = renderTabActions(tab.isDirty, tabIndex, groupIndex);
6429
6462
  let className = MainTab;
6430
6463
  if (isActive) {
6431
- className += ' ' + MainTabSelected;
6464
+ className = mergeClassNames(className, MainTabSelected);
6432
6465
  }
6433
6466
  if (tab.isDirty) {
6434
- className += ' ' + MainTabModified;
6467
+ className = mergeClassNames(className, MainTabModified);
6435
6468
  }
6436
6469
  if (tab.isPreview) {
6437
- className += ' ' + MainTabPreview;
6470
+ className = mergeClassNames(className, MainTabPreview);
6438
6471
  }
6439
6472
  return [{
6440
6473
  'aria-selected': isActive,
@@ -6448,11 +6481,7 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
6448
6481
  role: Tab$1,
6449
6482
  title: tab.uriTitle || tab.uri || tab.title,
6450
6483
  type: Div
6451
- }, ...renderTabIcon(tab), {
6452
- childCount: 1,
6453
- className: TabTitle,
6454
- type: Span
6455
- }, text(tab.title), ...closeButtonNodes];
6484
+ }, ...renderTabIcon(tab), tabTitleNode, text(tab.title), ...closeButtonNodes];
6456
6485
  };
6457
6486
 
6458
6487
  const getTabsVirtualDom = (group, groupIndex, tabsChildCount) => {
@@ -6471,6 +6500,11 @@ const isHtmlFile = tab => {
6471
6500
  return tab.uri.endsWith('.html');
6472
6501
  };
6473
6502
 
6503
+ const previewIconNode = {
6504
+ childCount: 0,
6505
+ className: MaskIconPreview,
6506
+ type: Div
6507
+ };
6474
6508
  const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
6475
6509
  const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
6476
6510
  const showTogglePreview = isHtmlFile(activeTab);
@@ -6489,11 +6523,7 @@ const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
6489
6523
  onClick: HandleClickAction,
6490
6524
  title: togglePreview(),
6491
6525
  type: Button$2
6492
- }, {
6493
- childCount: 0,
6494
- className: MaskIconPreview,
6495
- type: Div
6496
- });
6526
+ }, previewIconNode);
6497
6527
  }
6498
6528
  if (splitButtonEnabled) {
6499
6529
  buttons.push({
@@ -6534,6 +6564,11 @@ const emptyHeader = {
6534
6564
  className: EmptyGroupHeader,
6535
6565
  type: Div
6536
6566
  };
6567
+ const closeIconNode = {
6568
+ childCount: 0,
6569
+ className: MaskIconClose,
6570
+ type: Div
6571
+ };
6537
6572
  const renderEmptyGroupCloseButton = (group, groupIndex) => {
6538
6573
  return [emptyHeader, {
6539
6574
  childCount: 1,
@@ -6543,11 +6578,7 @@ const renderEmptyGroupCloseButton = (group, groupIndex) => {
6543
6578
  onClick: HandleClickAction,
6544
6579
  title: closeEditorGroup(),
6545
6580
  type: Button$2
6546
- }, {
6547
- childCount: 0,
6548
- className: MaskIconClose,
6549
- type: Div
6550
- }];
6581
+ }, closeIconNode];
6551
6582
  };
6552
6583
 
6553
6584
  const renderWaterMark = groupId => {
@@ -6570,7 +6601,7 @@ const renderEmptyEditorGroup = (group, groupIndex, style, closeButtonEnabled = t
6570
6601
  const closeButtonDom = closeButtonEnabled ? renderEmptyGroupCloseButton(group) : [];
6571
6602
  return [{
6572
6603
  childCount: closeButtonEnabled ? 2 : 1,
6573
- className: EditorGroup,
6604
+ className: EditorGroupEmpty,
6574
6605
  'data-groupId': String(group.id),
6575
6606
  onContextMenu: HandleContextMenu,
6576
6607
  style,
@@ -6579,6 +6610,11 @@ const renderEmptyEditorGroup = (group, groupIndex, style, closeButtonEnabled = t
6579
6610
  }, ...closeButtonDom, ...renderWaterMark(group.id)];
6580
6611
  };
6581
6612
 
6613
+ const editorContainerNode = {
6614
+ childCount: 1,
6615
+ className: EditorContainer,
6616
+ type: Div
6617
+ };
6582
6618
  const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width', closeButtonEnabled = true) => {
6583
6619
  const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
6584
6620
  const style = `${sizeProperty}:${group.size}%;`;
@@ -6593,11 +6629,7 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
6593
6629
  'data-groupId': String(group.id),
6594
6630
  style,
6595
6631
  type: Div
6596
- }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled), {
6597
- childCount: 1,
6598
- className: EditorContainer,
6599
- type: Div
6600
- }, ...renderEditor(activeTab)];
6632
+ }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled), editorContainerNode, ...renderEditor(activeTab)];
6601
6633
  };
6602
6634
 
6603
6635
  const getSashClassName = direction => {
@@ -6622,22 +6654,24 @@ const renderSash = (direction, sashId) => {
6622
6654
  }];
6623
6655
  };
6624
6656
 
6657
+ const sashCornerNode = {
6658
+ childCount: 0,
6659
+ className: 'SashCorner',
6660
+ onPointerDown: HandleSashCornerPointerDown,
6661
+ role: None$1,
6662
+ type: Button$2
6663
+ };
6625
6664
  const renderSashCorner = () => {
6626
- return {
6627
- childCount: 0,
6628
- className: 'SashCorner',
6629
- onPointerDown: HandleSashCornerPointerDown,
6630
- role: None$1,
6631
- type: Button$2
6632
- };
6665
+ return sashCornerNode;
6633
6666
  };
6634
6667
 
6668
+ const mainNode$1 = {
6669
+ childCount: 1,
6670
+ className: Main,
6671
+ type: Div
6672
+ };
6635
6673
  const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width') => {
6636
- return [{
6637
- childCount: 1,
6638
- className: Main,
6639
- type: Div
6640
- }, ...renderEditorGroup(layout.groups[0], 0, splitButtonEnabled, sizeProperty, false)];
6674
+ return [mainNode$1, ...renderEditorGroup(layout.groups[0], 0, splitButtonEnabled, sizeProperty, false)];
6641
6675
  };
6642
6676
 
6643
6677
  const getDirectionClassName = (direction, isSplit) => {
@@ -6648,7 +6682,12 @@ const getDirectionClassName = (direction, isSplit) => {
6648
6682
  };
6649
6683
  const getContainerClassName = (direction, childCount) => {
6650
6684
  const directionClassName = getDirectionClassName(direction, childCount > 1);
6651
- return directionClassName ? `${EDITOR_GROUPS_CONTAINER} ${directionClassName}` : EDITOR_GROUPS_CONTAINER;
6685
+ return directionClassName ? mergeClassNames(EDITOR_GROUPS_CONTAINER, directionClassName) : EDITOR_GROUPS_CONTAINER;
6686
+ };
6687
+ const mainNode = {
6688
+ childCount: 1,
6689
+ className: Main,
6690
+ type: Div
6652
6691
  };
6653
6692
  const getSizeProperty = direction => {
6654
6693
  return direction === Vertical ? 'height' : 'width';
@@ -6722,11 +6761,7 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
6722
6761
  }
6723
6762
  const editorGroupsContainerClassName = getContainerClassName(direction, groups.length);
6724
6763
  if (groups.length === 0) {
6725
- return [{
6726
- childCount: 1,
6727
- className: Main,
6728
- type: Div
6729
- }, {
6764
+ return [mainNode, {
6730
6765
  childCount: 0,
6731
6766
  className: editorGroupsContainerClassName,
6732
6767
  'data-groupId': '',
@@ -6741,11 +6776,7 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
6741
6776
  } = renderSegmentChildren(direction, groups, splitButtonEnabled);
6742
6777
  const sashCorner = getSashCorner(layout);
6743
6778
  const sashCornerChildren = sashCorner ? [renderSashCorner()] : [];
6744
- return [{
6745
- childCount: 1,
6746
- className: Main,
6747
- type: Div
6748
- }, {
6779
+ return [mainNode, {
6749
6780
  childCount: childCount + sashCornerChildren.length,
6750
6781
  className: editorGroupsContainerClassName,
6751
6782
  role: None$1,
@@ -6967,6 +6998,13 @@ const reopenEditorWith = async context => {
6967
6998
  }
6968
6999
  };
6969
7000
 
7001
+ const resize$1 = (state, dimensions) => {
7002
+ return {
7003
+ ...state,
7004
+ ...dimensions
7005
+ };
7006
+ };
7007
+
6970
7008
  const settingsUri = 'app://settings.json';
6971
7009
  const saveEditorAndHandleSettingsChange = async tab => {
6972
7010
  const editorState = await saveEditor(tab.editorUid);
@@ -7393,6 +7431,32 @@ const splitUp = (state, groupId) => {
7393
7431
  return splitEditorGroup$1(state, resolvedGroupId, 'up');
7394
7432
  };
7395
7433
 
7434
+ const pendingLoads = new Map();
7435
+ const loadContent = wrapSerialCommand(loadContent$1);
7436
+ const loadContentTracked = async (uid, ...args) => {
7437
+ const loading = loadContent(uid, ...args);
7438
+ pendingLoads.set(uid, loading);
7439
+ try {
7440
+ await loading;
7441
+ } finally {
7442
+ if (pendingLoads.get(uid) === loading) {
7443
+ pendingLoads.delete(uid);
7444
+ }
7445
+ }
7446
+ };
7447
+ const resize = async (uid, dimensions) => {
7448
+ const loading = pendingLoads.get(uid);
7449
+ if (loading) {
7450
+ await loading;
7451
+ }
7452
+ const instance = get(uid);
7453
+ if (!instance) {
7454
+ return [];
7455
+ }
7456
+ const resizedState = resize$1(instance.newState, dimensions);
7457
+ set(uid, instance.oldState, resizedState);
7458
+ return handleResize(resizedState, dimensions);
7459
+ };
7396
7460
  const commandMap = {
7397
7461
  'Main.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
7398
7462
  'Main.closeAll': wrapSerialCommand(closeAll$1),
@@ -7450,8 +7514,7 @@ const commandMap = {
7450
7514
  'MainArea.handleHeaderDoubleClick': wrapSerialCommand(handleHeaderDoubleClick),
7451
7515
  'MainArea.handleIconThemeChange': wrapSerialCommand(handleIconThemeChange),
7452
7516
  'MainArea.handleModifiedStatusChange': wrapAsyncCommand(handleModifiedStatusChangeWithContext),
7453
- 'MainArea.handleResize': wrapGetter(handleResize),
7454
- // TODO would need to have a function that returns newstate as well as commands
7517
+ 'MainArea.handleResize': resize,
7455
7518
  'MainArea.handleSashCornerPointerDown': wrapSerialCommand(handleSashCornerPointerDown),
7456
7519
  'MainArea.handleSashCornerPointerMove': wrapSerialCommand(handleSashCornerPointerMove),
7457
7520
  'MainArea.handleSashCornerPointerUp': wrapSerialCommand(handleSashCornerPointerUp),
@@ -7464,7 +7527,7 @@ const commandMap = {
7464
7527
  'MainArea.handleWorkspaceRefresh': wrapAsyncCommand(handleWorkspaceRefreshWithContext),
7465
7528
  'MainArea.hasActiveTextEditor': wrapGetter(hasActiveTextEditor),
7466
7529
  'MainArea.initialize': initialize,
7467
- 'MainArea.loadContent': wrapSerialCommand(loadContent),
7530
+ 'MainArea.loadContent': loadContentTracked,
7468
7531
  'MainArea.moveIntoNewWindow': wrapSerialCommand(moveIntoNewWindow),
7469
7532
  'MainArea.newFile': wrapSerialCommand(newFile),
7470
7533
  'MainArea.newWindow': wrapSerialCommand(newWindow),
@@ -7475,7 +7538,7 @@ const commandMap = {
7475
7538
  'MainArea.render2': render2,
7476
7539
  'MainArea.renderEventListeners': renderEventListeners,
7477
7540
  'MainArea.reopenEditorWith': wrapSerialAsyncCommand(reopenEditorWith),
7478
- 'MainArea.resize': wrapGetter(handleResize),
7541
+ 'MainArea.resize': resize,
7479
7542
  'MainArea.restoreClosedTab': wrapSerialCommand(restoreClosedTab),
7480
7543
  'MainArea.save': wrapSerialCommand(save),
7481
7544
  'MainArea.saveState': wrapGetter(saveState),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.32.4",
3
+ "version": "9.32.5",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",