@lvce-editor/editor-worker 19.23.0 → 19.24.1

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.
@@ -1445,7 +1445,7 @@ const create$9 = rpcId => {
1445
1445
  };
1446
1446
 
1447
1447
  const Audio = 0;
1448
- const Button$1 = 1;
1448
+ const Button$2 = 1;
1449
1449
  const Col = 2;
1450
1450
  const ColGroup = 3;
1451
1451
  const Div$1 = 4;
@@ -1498,7 +1498,7 @@ const Video = 61;
1498
1498
  const TextArea$1 = 62;
1499
1499
  const Select = 63;
1500
1500
  const Option = 64;
1501
- const Code = 65;
1501
+ const Code$1 = 65;
1502
1502
  const Label = 66;
1503
1503
  const Dt = 67;
1504
1504
  const Iframe = 68;
@@ -1536,11 +1536,11 @@ const VirtualDomElements = {
1536
1536
  Audio,
1537
1537
  BlockQuote,
1538
1538
  Br,
1539
- Button: Button$1,
1539
+ Button: Button$2,
1540
1540
  Canvas,
1541
1541
  Circle,
1542
1542
  Cite,
1543
- Code,
1543
+ Code: Code$1,
1544
1544
  Col,
1545
1545
  ColGroup,
1546
1546
  Data,
@@ -1614,7 +1614,7 @@ const VirtualDomElements = {
1614
1614
  };
1615
1615
 
1616
1616
  const AltKey = 'event.altKey';
1617
- const Button = 'event.button';
1617
+ const Button$1 = 'event.button';
1618
1618
  const ClientX = 'event.clientX';
1619
1619
  const ClientY = 'event.clientY';
1620
1620
  const DeltaMode = 'event.deltaMode';
@@ -4473,207 +4473,6 @@ const get$2 = async key => {
4473
4473
  return value;
4474
4474
  };
4475
4475
 
4476
- const logError = async (error, prefix) => {
4477
- const prettyError = await invoke$g('Errors.prepare', error);
4478
- await invoke$g('Errors.print', prettyError, prefix);
4479
- };
4480
- const logFallback = (error, prefix) => {
4481
- if (prefix) {
4482
- console.error(prefix, error);
4483
- return;
4484
- }
4485
- console.error(error);
4486
- };
4487
- const handleError$1 = async (error, prefix = '') => {
4488
- try {
4489
- await logError(error, prefix);
4490
- } catch (otherError) {
4491
- console.warn('ErrorHandling error', otherError);
4492
- logFallback(error, prefix);
4493
- }
4494
- };
4495
-
4496
- const OnDiagnostic = 'onDiagnostic';
4497
- const OnHover = 'onHover';
4498
- const OnTabCompletion = 'onTabCompletion';
4499
-
4500
- const execute = async ({
4501
- args,
4502
- assetDir,
4503
- editor,
4504
- event,
4505
- method,
4506
- noProviderFoundMessage,
4507
- noProviderFoundResult = undefined,
4508
- platform
4509
- }) => {
4510
- const fullEvent = `${event}:${editor.languageId}`;
4511
- await activateByEvent(fullEvent, assetDir, platform);
4512
- const result = await invoke$6(method, editor.uid, ...args);
4513
- return result;
4514
- };
4515
-
4516
- const getTextDocument$1 = editor => {
4517
- return {
4518
- documentId: editor.id || editor.uid,
4519
- languageId: editor.languageId,
4520
- text: getText$1(editor),
4521
- uri: editor.uri
4522
- };
4523
- };
4524
- const executeIsolatedDiagnosticProvider = async editor => {
4525
- const textDocument = getTextDocument$1(editor);
4526
- return invoke$e('Extensions.executeDiagnosticProvider', textDocument);
4527
- };
4528
- const executeDiagnosticProvider = async editor => {
4529
- const isolatedDiagnostics = await executeIsolatedDiagnosticProvider(editor);
4530
- if (isolatedDiagnostics.length > 0) {
4531
- return isolatedDiagnostics;
4532
- }
4533
- const {
4534
- assetDir,
4535
- platform
4536
- } = editor;
4537
- return execute({
4538
- args: [],
4539
- assetDir,
4540
- editor,
4541
- event: OnDiagnostic,
4542
- method: 'ExtensionHost.executeDiagnosticProvider',
4543
- noProviderFoundMessage: 'no diagnostic provider found',
4544
- platform
4545
- });
4546
- };
4547
-
4548
- const getDiagnosticType = diagnostic => {
4549
- return diagnostic.type;
4550
- };
4551
-
4552
- const getY = (row, minLineY, rowHeight) => {
4553
- return (row - minLineY) * rowHeight;
4554
- };
4555
-
4556
- const getVisibleDiagnostics = async (editor, diagnostics) => {
4557
- const visibleDiagnostics = [];
4558
- const {
4559
- charWidth,
4560
- fontFamily,
4561
- fontSize,
4562
- fontWeight,
4563
- isMonospaceFont,
4564
- letterSpacing,
4565
- lines,
4566
- minLineY,
4567
- rowHeight,
4568
- tabSize,
4569
- width
4570
- } = editor;
4571
- for (const diagnostic of diagnostics) {
4572
- const {
4573
- columnIndex,
4574
- endColumnIndex,
4575
- rowIndex
4576
- } = diagnostic;
4577
- const columnDelta = endColumnIndex - columnIndex;
4578
- const diagnosticWidth = columnDelta * charWidth;
4579
- const endLineDifference = 0;
4580
- const halfCursorWidth = 0;
4581
- const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
4582
- const y = getY(rowIndex, minLineY, rowHeight) - rowHeight;
4583
- visibleDiagnostics.push({
4584
- height: rowHeight,
4585
- type: getDiagnosticType(diagnostic),
4586
- width: diagnosticWidth,
4587
- x,
4588
- y
4589
- });
4590
- }
4591
- return visibleDiagnostics;
4592
- };
4593
-
4594
- /**
4595
- * Merges link decorations with diagnostic decorations
4596
- * Links should always be present, but we also need to include any diagnostic decorations
4597
- */
4598
- const mergeLinksWithDiagnosticDecorations = (editor, diagnosticDecorations) => {
4599
- // Get link decorations
4600
- const linkDecorations = detectAllLinksAsDecorations(editor);
4601
-
4602
- // Merge with diagnostic decorations
4603
- const allDecorations = [...linkDecorations, ...diagnosticDecorations];
4604
-
4605
- // Sort by offset to maintain proper order
4606
- const sortedDecorations = [];
4607
- for (let i = 0; i < allDecorations.length; i += 4) {
4608
- sortedDecorations.push({
4609
- length: allDecorations[i + 1],
4610
- modifiers: allDecorations[i + 3],
4611
- offset: allDecorations[i],
4612
- type: allDecorations[i + 2]
4613
- });
4614
- }
4615
- sortedDecorations.sort((a, b) => a.offset - b.offset);
4616
-
4617
- // Flatten back to array format
4618
- const result = [];
4619
- for (const dec of sortedDecorations) {
4620
- result.push(dec.offset, dec.length, dec.type, dec.modifiers);
4621
- }
4622
- return result;
4623
- };
4624
-
4625
- const getDiagnostics$2 = async editor => {
4626
- const content = getText$1(editor);
4627
- // @ts-ignore
4628
- await invoke$6(TextDocumentSyncFull, editor.uri, editor.id, editor.languageId, content);
4629
- return executeDiagnosticProvider(editor);
4630
- };
4631
- const addDiagnostics = async (editor, diagnostics) => {
4632
- const visualDecorations = await getVisibleDiagnostics(editor, diagnostics);
4633
- const diagnosticDecorations = visualDecorations.flatMap(decoration => [decoration.offset, decoration.length, decoration.type, decoration.modifiers || 0]);
4634
- const decorations = mergeLinksWithDiagnosticDecorations(editor, diagnosticDecorations);
4635
- return {
4636
- ...editor,
4637
- decorations,
4638
- diagnostics,
4639
- visualDecorations
4640
- };
4641
- };
4642
- const handleError = async (error, editor) => {
4643
- if (error instanceof Error && error.message.includes('No diagnostic provider found')) {
4644
- return editor;
4645
- }
4646
- await handleError$1(error, 'Failed to update diagnostics: ');
4647
- return editor;
4648
- };
4649
- const getEditorWithDiagnostics = async editor => {
4650
- try {
4651
- const diagnostics = await getDiagnostics$2(editor);
4652
- if (!get$7(editor.id)) {
4653
- return editor;
4654
- }
4655
- return addDiagnostics(editor, diagnostics);
4656
- } catch (error) {
4657
- return handleError(error, editor);
4658
- }
4659
- };
4660
- const updateDiagnostics = async editor => {
4661
- try {
4662
- const diagnostics = await getDiagnostics$2(editor);
4663
- const latest = get$7(editor.id);
4664
- if (!latest) {
4665
- return editor;
4666
- }
4667
- const newEditor = await addDiagnostics(latest.newState, diagnostics);
4668
- set$9(editor.id, latest.oldState, newEditor);
4669
- // @ts-ignore
4670
- await invoke$b('Editor.rerender', editor.id);
4671
- return newEditor;
4672
- } catch (error) {
4673
- return handleError(error, editor);
4674
- }
4675
- };
4676
-
4677
4476
  const createEditor = async ({
4678
4477
  assetDir,
4679
4478
  columnToReveal,
@@ -4832,11 +4631,10 @@ const createEditor = async ({
4832
4631
  // e.g. it might not always be necessary to send text to extension host worker
4833
4632
  // @ts-ignore
4834
4633
  await invoke$6(TextDocumentSyncFull, uri, id, languageId, content);
4835
- const editorWithDiagnostics = diagnosticsEnabled ? await updateDiagnostics(newEditor4) : newEditor4;
4836
4634
  const completionsOnTypeRaw = await get$2('editor.completionsOnType');
4837
4635
  const completionsOnType = Boolean(completionsOnTypeRaw);
4838
4636
  set$9(id, emptyEditor, {
4839
- ...editorWithDiagnostics,
4637
+ ...newEditor4,
4840
4638
  completionsOnType
4841
4639
  });
4842
4640
  };
@@ -5157,6 +4955,26 @@ const closeWidgetsMaybe = widgets => {
5157
4955
  return widgets.filter(widget => isPersistentWidget(widget.id));
5158
4956
  };
5159
4957
 
4958
+ const logError = async (error, prefix) => {
4959
+ const prettyError = await invoke$g('Errors.prepare', error);
4960
+ await invoke$g('Errors.print', prettyError, prefix);
4961
+ };
4962
+ const logFallback = (error, prefix) => {
4963
+ if (prefix) {
4964
+ console.error(prefix, error);
4965
+ return;
4966
+ }
4967
+ console.error(error);
4968
+ };
4969
+ const handleError$1 = async (error, prefix = '') => {
4970
+ try {
4971
+ await logError(error, prefix);
4972
+ } catch (otherError) {
4973
+ console.warn('ErrorHandling error', otherError);
4974
+ logFallback(error, prefix);
4975
+ }
4976
+ };
4977
+
5160
4978
  const getFormattingEdits = async editor => {
5161
4979
  const textDocument = {
5162
4980
  documentId: editor.id || editor.uid,
@@ -8914,6 +8732,22 @@ const openRename = async editor => {
8914
8732
  };
8915
8733
  };
8916
8734
 
8735
+ const execute = async ({
8736
+ args,
8737
+ assetDir,
8738
+ editor,
8739
+ event,
8740
+ method,
8741
+ noProviderFoundMessage,
8742
+ noProviderFoundResult = undefined,
8743
+ platform
8744
+ }) => {
8745
+ const fullEvent = `${event}:${editor.languageId}`;
8746
+ await activateByEvent(fullEvent, assetDir, platform);
8747
+ const result = await invoke$6(method, editor.uid, ...args);
8748
+ return result;
8749
+ };
8750
+
8917
8751
  const getOrganizeImportEdits = async editor => {
8918
8752
  const edits = await execute({
8919
8753
  args: [],
@@ -9692,6 +9526,10 @@ const sortLinesAscending = editor => {
9692
9526
  return scheduleDocumentAndCursorsSelections(editor, changes);
9693
9527
  };
9694
9528
 
9529
+ const OnDiagnostic = 'onDiagnostic';
9530
+ const OnHover = 'onHover';
9531
+ const OnTabCompletion = 'onTabCompletion';
9532
+
9695
9533
  const executeTabCompletionProvider = async (editor, offset) => {
9696
9534
  return execute({
9697
9535
  args: [offset],
@@ -10504,7 +10342,7 @@ const EditorCompletionWidget = {
10504
10342
  toggleDetails: toggleDetails$1
10505
10343
  };
10506
10344
 
10507
- const getTextDocument = editor => {
10345
+ const getTextDocument$1 = editor => {
10508
10346
  return {
10509
10347
  documentId: editor.id || editor.uid,
10510
10348
  languageId: editor.languageId,
@@ -10513,7 +10351,7 @@ const getTextDocument = editor => {
10513
10351
  };
10514
10352
  };
10515
10353
  const executeIsolatedHoverProvider = async (editor, offset) => {
10516
- const textDocument = getTextDocument(editor);
10354
+ const textDocument = getTextDocument$1(editor);
10517
10355
  return invoke$e('Extensions.executeHoverProvider', textDocument, offset);
10518
10356
  };
10519
10357
  const executeHoverProvider = async (editor, offset) => {
@@ -10790,6 +10628,10 @@ const getLineInfosVirtualDom = lineInfos => {
10790
10628
  return dom;
10791
10629
  };
10792
10630
 
10631
+ const mergeClassNames = (...classNames) => {
10632
+ return classNames.filter(Boolean).join(' ');
10633
+ };
10634
+
10793
10635
  const hoverProblemMessage = {
10794
10636
  childCount: 1,
10795
10637
  className: HoverProblemMessage,
@@ -10800,6 +10642,11 @@ const hoverProblemDetail = {
10800
10642
  className: HoverProblemDetail,
10801
10643
  type: Span
10802
10644
  };
10645
+ const hoverDocumentationNode = {
10646
+ childCount: 1,
10647
+ className: HoverDocumentation,
10648
+ type: Div
10649
+ };
10803
10650
  const getChildCount = (lineInfos, documentation, diagnostics) => {
10804
10651
  const documentationCount = documentation ? 1 : 0;
10805
10652
  const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
@@ -10809,13 +10656,13 @@ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
10809
10656
  const dom = [];
10810
10657
  dom.push({
10811
10658
  childCount: getChildCount(lineInfos, documentation, diagnostics) + 1,
10812
- className: 'Viewlet EditorHover',
10659
+ className: mergeClassNames('Viewlet', 'EditorHover'),
10813
10660
  type: Div
10814
10661
  });
10815
10662
  if (diagnostics && diagnostics.length > 0) {
10816
10663
  dom.push({
10817
10664
  childCount: diagnostics.length * 2,
10818
- className: `${HoverDisplayString} ${HoverProblem}`,
10665
+ className: mergeClassNames(HoverDisplayString, HoverProblem),
10819
10666
  type: Div
10820
10667
  });
10821
10668
  for (const diagnostic of diagnostics) {
@@ -10831,15 +10678,11 @@ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
10831
10678
  }, ...lineInfosDom);
10832
10679
  }
10833
10680
  if (documentation) {
10834
- dom.push({
10835
- childCount: 1,
10836
- className: HoverDocumentation,
10837
- type: Div
10838
- }, text(documentation));
10681
+ dom.push(hoverDocumentationNode, text(documentation));
10839
10682
  }
10840
10683
  dom.push({
10841
10684
  childCount: 0,
10842
- className: 'Sash SashVertical SashResize',
10685
+ className: mergeClassNames('Sash', 'SashVertical', 'SashResize'),
10843
10686
  onPointerDown: HandleSashPointerDown,
10844
10687
  type: Div
10845
10688
  });
@@ -11181,7 +11024,7 @@ const getSourceActions = async editorUid => {
11181
11024
  const actions = await getEditorSourceActions(editorUid);
11182
11025
  return actions;
11183
11026
  };
11184
- const getDiagnostics$1 = async editorUid => {
11027
+ const getDiagnostics$2 = async editorUid => {
11185
11028
  const editor = getEditor(editorUid);
11186
11029
  const {
11187
11030
  diagnostics
@@ -11669,7 +11512,39 @@ const getMenuIds = () => {
11669
11512
  return [Editor$1];
11670
11513
  };
11671
11514
 
11672
- const getDiagnostics = editor => {
11515
+ const getTextDocument = editor => {
11516
+ return {
11517
+ documentId: editor.id || editor.uid,
11518
+ languageId: editor.languageId,
11519
+ text: getText$1(editor),
11520
+ uri: editor.uri
11521
+ };
11522
+ };
11523
+ const executeIsolatedDiagnosticProvider = async editor => {
11524
+ const textDocument = getTextDocument(editor);
11525
+ return invoke$e('Extensions.executeDiagnosticProvider', textDocument);
11526
+ };
11527
+ const executeDiagnosticProvider = async editor => {
11528
+ const isolatedDiagnostics = await executeIsolatedDiagnosticProvider(editor);
11529
+ if (isolatedDiagnostics.length > 0) {
11530
+ return isolatedDiagnostics;
11531
+ }
11532
+ const {
11533
+ assetDir,
11534
+ platform
11535
+ } = editor;
11536
+ return execute({
11537
+ args: [],
11538
+ assetDir,
11539
+ editor,
11540
+ event: OnDiagnostic,
11541
+ method: 'ExtensionHost.executeDiagnosticProvider',
11542
+ noProviderFoundMessage: 'no diagnostic provider found',
11543
+ platform
11544
+ });
11545
+ };
11546
+
11547
+ const getDiagnostics$1 = editor => {
11673
11548
  return executeDiagnosticProvider(editor);
11674
11549
  };
11675
11550
  const getProblems = async () => {
@@ -11682,7 +11557,7 @@ const getProblems = async () => {
11682
11557
  return editor;
11683
11558
  });
11684
11559
  const newEditors = editors.map(editor => editor.newState);
11685
- const diagnostics = await Promise.all(newEditors.map(getDiagnostics));
11560
+ const diagnostics = await Promise.all(newEditors.map(getDiagnostics$1));
11686
11561
  const flatDiagnostics = diagnostics.flat();
11687
11562
  return flatDiagnostics;
11688
11563
  };
@@ -12226,11 +12101,10 @@ const loadContent = async (state, savedState) => {
12226
12101
  // e.g. it might not always be necessary to send text to extension host worker
12227
12102
  // @ts-ignore
12228
12103
  await invoke$6(TextDocumentSyncFull, uri, id, computedLanguageId, content);
12229
- const editorWithDiagnostics = diagnosticsEnabled ? await getEditorWithDiagnostics(newEditor4) : newEditor4;
12230
12104
  const completionsOnTypeRaw = await get$2('editor.completionsOnType');
12231
12105
  const completionsOnType = Boolean(completionsOnTypeRaw);
12232
12106
  const newEditor5 = {
12233
- ...editorWithDiagnostics,
12107
+ ...newEditor4,
12234
12108
  completionsOnType,
12235
12109
  initial: false
12236
12110
  };
@@ -12634,33 +12508,41 @@ const diffTree = (oldNodes, newNodes) => {
12634
12508
  return removeTrailingNavigationPatches(patches);
12635
12509
  };
12636
12510
 
12511
+ const Button = 'button';
12512
+ const Code = 'code';
12513
+ const TextBox = 'textbox';
12514
+
12515
+ const True = 'true';
12516
+
12517
+ const editorInputNode = {
12518
+ childCount: 1,
12519
+ className: 'EditorInput',
12520
+ type: Div
12521
+ };
12522
+ const editorTextAreaNode = {
12523
+ ariaAutoComplete: 'list',
12524
+ ariaMultiLine: True,
12525
+ ariaRoleDescription: 'editor',
12526
+ autocapitalize: 'off',
12527
+ autocomplete: 'off',
12528
+ autocorrect: 'off',
12529
+ childCount: 0,
12530
+ name: 'editor',
12531
+ onBeforeInput: HandleBeforeInput,
12532
+ onBlur: HandleBlur,
12533
+ onCompositionEnd: HandleCompositionEnd,
12534
+ onCompositionStart: HandleCompositionStart,
12535
+ onCompositionUpdate: HandleCompositionUpdate,
12536
+ onCut: HandleCut,
12537
+ onFocus: HandleFocus,
12538
+ onPaste: HandlePaste,
12539
+ role: TextBox,
12540
+ spellcheck: false,
12541
+ type: TextArea,
12542
+ wrap: 'off'
12543
+ };
12637
12544
  const getEditorInputVirtualDom = () => {
12638
- return [{
12639
- childCount: 1,
12640
- className: 'EditorInput',
12641
- type: Div
12642
- }, {
12643
- ariaAutoComplete: 'list',
12644
- ariaMultiLine: 'true',
12645
- ariaRoleDescription: 'editor',
12646
- autocapitalize: 'off',
12647
- autocomplete: 'off',
12648
- autocorrect: 'off',
12649
- childCount: 0,
12650
- name: 'editor',
12651
- onBeforeInput: HandleBeforeInput,
12652
- onBlur: HandleBlur,
12653
- onCompositionEnd: HandleCompositionEnd,
12654
- onCompositionStart: HandleCompositionStart,
12655
- onCompositionUpdate: HandleCompositionUpdate,
12656
- onCut: HandleCut,
12657
- onFocus: HandleFocus,
12658
- onPaste: HandlePaste,
12659
- role: 'textbox',
12660
- spellcheck: false,
12661
- type: TextArea,
12662
- wrap: 'off'
12663
- }];
12545
+ return [editorInputNode, editorTextAreaNode];
12664
12546
  };
12665
12547
 
12666
12548
  const getCursorsVirtualDom = cursors => {
@@ -12697,10 +12579,6 @@ const getDiagnosticClassName = type => {
12697
12579
  }
12698
12580
  };
12699
12581
 
12700
- const mergeClassNames = (...classNames) => {
12701
- return classNames.filter(Boolean).join(' ');
12702
- };
12703
-
12704
12582
  const getDiagnosticVirtualDom = diagnostic => {
12705
12583
  const {
12706
12584
  height,
@@ -12742,7 +12620,7 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
12742
12620
  const difference = differences[i];
12743
12621
  let className = EditorRow;
12744
12622
  if (i === highlightedLine) {
12745
- className += ' ' + EditorRowHighlighted;
12623
+ className = mergeClassNames(className, EditorRowHighlighted);
12746
12624
  }
12747
12625
  dom.push({
12748
12626
  childCount: textInfo.length / 2,
@@ -12803,12 +12681,13 @@ const getEditorSelectionsVirtualDom = selectionInfos => {
12803
12681
  }, ...selectionsDom];
12804
12682
  };
12805
12683
 
12684
+ const editorLayersNode = {
12685
+ childCount: 4,
12686
+ className: 'EditorLayers',
12687
+ type: Div
12688
+ };
12806
12689
  const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = []) => {
12807
- return [{
12808
- childCount: 4,
12809
- className: 'EditorLayers',
12810
- type: Div
12811
- }, ...getEditorSelectionsVirtualDom(selectionInfos), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine), ...getEditorCursorsVirtualDom(cursorInfos), ...getEditorDiagnosticsVirtualDom(diagnostics)];
12690
+ return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine), ...getEditorCursorsVirtualDom(cursorInfos), ...getEditorDiagnosticsVirtualDom(diagnostics)];
12812
12691
  };
12813
12692
 
12814
12693
  const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
@@ -12822,26 +12701,34 @@ const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
12822
12701
  const getScrollBarVirtualDom = () => {
12823
12702
  return [{
12824
12703
  childCount: 1,
12825
- className: 'ScrollBar ScrollBarVertical',
12704
+ className: mergeClassNames('ScrollBar', 'ScrollBarVertical'),
12826
12705
  onContextMenu: HandleContextMenu,
12827
12706
  onPointerDown: HandleScrollBarVerticalPointerDown,
12828
12707
  type: Div
12829
12708
  }, {
12830
12709
  childCount: 0,
12831
- className: 'ScrollBarThumb ScrollBarThumbVertical',
12710
+ className: mergeClassNames('ScrollBarThumb', 'ScrollBarThumbVertical'),
12832
12711
  type: Div
12833
12712
  }, {
12834
12713
  childCount: 1,
12835
- className: 'ScrollBar ScrollBarHorizontal',
12714
+ className: mergeClassNames('ScrollBar', 'ScrollBarHorizontal'),
12836
12715
  onPointerDown: HandleScrollBarHorizontalPointerDown,
12837
12716
  type: Div
12838
12717
  }, {
12839
12718
  childCount: 0,
12840
- className: 'ScrollBarThumb ScrollBarThumbHorizontal',
12719
+ className: mergeClassNames('ScrollBarThumb', 'ScrollBarThumbHorizontal'),
12841
12720
  type: Div
12842
12721
  }];
12843
12722
  };
12844
12723
 
12724
+ const editorContentNode = {
12725
+ childCount: 5,
12726
+ className: 'EditorContent',
12727
+ onKeyUp: HandleKeyUp,
12728
+ onMouseMove: HandleMouseMove,
12729
+ onWheel: HandleWheel,
12730
+ type: Div
12731
+ };
12845
12732
  const getEditorContentVirtualDom = ({
12846
12733
  cursorInfos = [],
12847
12734
  diagnostics = [],
@@ -12852,14 +12739,7 @@ const getEditorContentVirtualDom = ({
12852
12739
  selectionInfos = [],
12853
12740
  textInfos
12854
12741
  }) => {
12855
- return [{
12856
- childCount: 5,
12857
- className: 'EditorContent',
12858
- onKeyUp: HandleKeyUp,
12859
- onMouseMove: HandleMouseMove,
12860
- onWheel: HandleWheel,
12861
- type: Div
12862
- }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
12742
+ return [editorContentNode, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
12863
12743
  };
12864
12744
 
12865
12745
  const getGutterInfoVirtualDom = gutterInfo => {
@@ -12906,6 +12786,11 @@ const getGutterInfos = (minLineY, maxLineY, breakPoints, showLineNumbers = true,
12906
12786
  return gutterInfos;
12907
12787
  };
12908
12788
 
12789
+ const textEditorErrorMessageNode = {
12790
+ childCount: 1,
12791
+ className: 'TextEditorErrorMessage',
12792
+ type: Div
12793
+ };
12909
12794
  const getEditorVirtualDom = ({
12910
12795
  breakPoints = [],
12911
12796
  cursorInfos = [],
@@ -12926,29 +12811,25 @@ const getEditorVirtualDom = ({
12926
12811
  if (loadError) {
12927
12812
  return [{
12928
12813
  childCount: 2,
12929
- className: 'Viewlet TextEditorError',
12814
+ className: mergeClassNames('Viewlet', 'TextEditorError'),
12930
12815
  'data-uid': uid,
12931
- role: 'code',
12816
+ role: Code,
12932
12817
  type: Div
12933
12818
  }, {
12934
12819
  childCount: 0,
12935
- className: 'EditorTextIcon EditorTextIconError MaskIcon MaskIconError',
12936
- type: Div
12937
- }, {
12938
- childCount: 1,
12939
- className: 'TextEditorErrorMessage',
12820
+ className: mergeClassNames('EditorTextIcon', 'EditorTextIconError', 'MaskIcon', 'MaskIconError'),
12940
12821
  type: Div
12941
- }, text(loadError)];
12822
+ }, textEditorErrorMessageNode, text(loadError)];
12942
12823
  }
12943
12824
  const visibleGutterInfos = breakPoints.length > 0 || visibleLineIndices ? getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices) : gutterInfos;
12944
12825
  const showGutter = lineNumbers || breakPoints.length > 0;
12945
12826
  const gutterDom = showGutter ? getEditorGutterVirtualDom(visibleGutterInfos) : [];
12946
12827
  return [{
12947
12828
  childCount: showGutter ? 2 : 1,
12948
- className: 'Viewlet Editor',
12829
+ className: mergeClassNames('Viewlet', 'Editor'),
12949
12830
  'data-uid': uid,
12950
12831
  onContextMenu: HandleContextMenu,
12951
- role: 'code',
12832
+ role: Code,
12952
12833
  type: Div
12953
12834
  }, ...gutterDom, ...getEditorContentVirtualDom({
12954
12835
  cursorInfos,
@@ -13201,7 +13082,7 @@ const renderEventListeners = () => {
13201
13082
  passive: true
13202
13083
  }, {
13203
13084
  name: HandleContextMenu,
13204
- params: ['handleContextMenu', Button, ClientX, ClientY],
13085
+ params: ['handleContextMenu', Button$1, ClientX, ClientY],
13205
13086
  preventDefault: true
13206
13087
  }, {
13207
13088
  name: HandleScrollBarVerticalPointerDown,
@@ -13293,6 +13174,125 @@ const updateDebugInfo = async debugId => {
13293
13174
  await invoke$b('Editor.rerender', key);
13294
13175
  };
13295
13176
 
13177
+ const getDiagnosticType = diagnostic => {
13178
+ return diagnostic.type;
13179
+ };
13180
+
13181
+ const getY = (row, minLineY, rowHeight) => {
13182
+ return (row - minLineY) * rowHeight;
13183
+ };
13184
+
13185
+ const getVisibleDiagnostics = async (editor, diagnostics) => {
13186
+ const visibleDiagnostics = [];
13187
+ const {
13188
+ charWidth,
13189
+ fontFamily,
13190
+ fontSize,
13191
+ fontWeight,
13192
+ isMonospaceFont,
13193
+ letterSpacing,
13194
+ lines,
13195
+ minLineY,
13196
+ rowHeight,
13197
+ tabSize,
13198
+ width
13199
+ } = editor;
13200
+ for (const diagnostic of diagnostics) {
13201
+ const {
13202
+ columnIndex,
13203
+ endColumnIndex,
13204
+ rowIndex
13205
+ } = diagnostic;
13206
+ const columnDelta = endColumnIndex - columnIndex;
13207
+ const diagnosticWidth = columnDelta * charWidth;
13208
+ const endLineDifference = 0;
13209
+ const halfCursorWidth = 0;
13210
+ const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
13211
+ const y = getY(rowIndex, minLineY, rowHeight);
13212
+ visibleDiagnostics.push({
13213
+ height: rowHeight,
13214
+ type: getDiagnosticType(diagnostic),
13215
+ width: diagnosticWidth,
13216
+ x,
13217
+ y
13218
+ });
13219
+ }
13220
+ return visibleDiagnostics;
13221
+ };
13222
+
13223
+ /**
13224
+ * Merges link decorations with diagnostic decorations
13225
+ * Links should always be present, but we also need to include any diagnostic decorations
13226
+ */
13227
+ const mergeLinksWithDiagnosticDecorations = (editor, diagnosticDecorations) => {
13228
+ // Get link decorations
13229
+ const linkDecorations = detectAllLinksAsDecorations(editor);
13230
+
13231
+ // Merge with diagnostic decorations
13232
+ const allDecorations = [...linkDecorations, ...diagnosticDecorations];
13233
+
13234
+ // Sort by offset to maintain proper order
13235
+ const sortedDecorations = [];
13236
+ for (let i = 0; i < allDecorations.length; i += 4) {
13237
+ sortedDecorations.push({
13238
+ length: allDecorations[i + 1],
13239
+ modifiers: allDecorations[i + 3],
13240
+ offset: allDecorations[i],
13241
+ type: allDecorations[i + 2]
13242
+ });
13243
+ }
13244
+ sortedDecorations.sort((a, b) => a.offset - b.offset);
13245
+
13246
+ // Flatten back to array format
13247
+ const result = [];
13248
+ for (const dec of sortedDecorations) {
13249
+ result.push(dec.offset, dec.length, dec.type, dec.modifiers);
13250
+ }
13251
+ return result;
13252
+ };
13253
+
13254
+ const getDiagnostics = async editor => {
13255
+ const content = getText$1(editor);
13256
+ // @ts-ignore
13257
+ await invoke$6(TextDocumentSyncFull, editor.uri, editor.id, editor.languageId, content);
13258
+ return executeDiagnosticProvider(editor);
13259
+ };
13260
+ const addDiagnostics = async (editor, diagnostics) => {
13261
+ const visualDecorations = await getVisibleDiagnostics(editor, diagnostics);
13262
+ const diagnosticDecorations = visualDecorations.flatMap(decoration => [decoration.offset, decoration.length, decoration.type, decoration.modifiers || 0]);
13263
+ const decorations = mergeLinksWithDiagnosticDecorations(editor, diagnosticDecorations);
13264
+ return {
13265
+ ...editor,
13266
+ decorations,
13267
+ diagnostics,
13268
+ visualDecorations
13269
+ };
13270
+ };
13271
+ const handleError = async (error, editor) => {
13272
+ if (error instanceof Error && error.message.includes('No diagnostic provider found')) {
13273
+ return editor;
13274
+ }
13275
+ await handleError$1(error, 'Failed to update diagnostics: ');
13276
+ return editor;
13277
+ };
13278
+ const updateDiagnostics = async editor => {
13279
+ if (!editor.diagnosticsEnabled) {
13280
+ return editor;
13281
+ }
13282
+ try {
13283
+ const diagnostics = await getDiagnostics(editor);
13284
+ const latest = get$7(editor.id);
13285
+ if (!latest) {
13286
+ return editor;
13287
+ }
13288
+ const newEditor = await addDiagnostics(latest.newState, diagnostics);
13289
+ set$9(editor.id, latest.oldState, newEditor);
13290
+ return newEditor;
13291
+ } catch (error) {
13292
+ return handleError(error, editor);
13293
+ }
13294
+ };
13295
+
13296
13296
  const queues = [];
13297
13297
 
13298
13298
  // TODO wrap commands globally, not per editor
@@ -13392,7 +13392,7 @@ const commandMap = {
13392
13392
  'Editor.fold': wrapCommand(fold$1),
13393
13393
  'Editor.format': wrapCommand(format),
13394
13394
  'Editor.getCommandIds': getCommandIds,
13395
- 'Editor.getDiagnostics': getDiagnostics$1,
13395
+ 'Editor.getDiagnostics': getDiagnostics$2,
13396
13396
  'Editor.getKeyBindings': getKeyBindings,
13397
13397
  'Editor.getKeys': getKeys$1,
13398
13398
  'Editor.getLanguageId': getLanguageId,
@@ -13499,6 +13499,7 @@ const commandMap = {
13499
13499
  'Editor.setDecorations': wrapCommand(setDecorations),
13500
13500
  'Editor.setDelta': wrapCommand(setDelta),
13501
13501
  'Editor.setDeltaY': wrapCommand(setDeltaY),
13502
+ 'Editor.setDiagnostics': wrapCommand(addDiagnostics),
13502
13503
  'Editor.setLanguageId': wrapCommand(setLanguageId),
13503
13504
  'Editor.setSelections': wrapCommand(setSelections),
13504
13505
  'Editor.setSelections2': setSelections2,
@@ -13686,6 +13687,11 @@ const listen = async () => {
13686
13687
 
13687
13688
  const CodeGeneratorInput = 'CodeGeneratorInput';
13688
13689
 
13690
+ const codeGeneratorMessageNode = {
13691
+ childCount: 1,
13692
+ className: CodeGeneratorMessage,
13693
+ type: Div
13694
+ };
13689
13695
  const getCodeGeneratorVirtualDom = state => {
13690
13696
  const escapeToClose$1 = escapeToClose();
13691
13697
  const enterCode$1 = enterCode();
@@ -13699,11 +13705,7 @@ const getCodeGeneratorVirtualDom = state => {
13699
13705
  name: CodeGeneratorInput,
13700
13706
  placeholder: enterCode$1,
13701
13707
  type: Input
13702
- }, {
13703
- childCount: 1,
13704
- className: CodeGeneratorMessage,
13705
- type: Div
13706
- }, text(escapeToClose$1)];
13708
+ }, codeGeneratorMessageNode, text(escapeToClose$1)];
13707
13709
  };
13708
13710
 
13709
13711
  const renderContent$1 = {
@@ -13805,23 +13807,29 @@ const EditorColorPickerWidget = {
13805
13807
  render: render$4
13806
13808
  };
13807
13809
 
13810
+ const Focusable = 0;
13811
+
13812
+ const completionDetailContentNode = {
13813
+ childCount: 1,
13814
+ className: CompletionDetailContent,
13815
+ type: Div
13816
+ };
13817
+ const completionDetailCloseButtonNode = {
13818
+ childCount: 1,
13819
+ className: CompletionDetailCloseButton,
13820
+ onClick: HandleClose,
13821
+ role: Button,
13822
+ tabIndex: Focusable,
13823
+ type: Div
13824
+ };
13808
13825
  const getCompletionDetailVirtualDom = content => {
13809
13826
  const dom = [{
13810
13827
  childCount: 2,
13811
- className: 'Viewlet EditorCompletionDetails',
13828
+ className: mergeClassNames('Viewlet', 'EditorCompletionDetails'),
13812
13829
  type: Div
13813
- }, {
13814
- childCount: 1,
13815
- className: CompletionDetailContent,
13816
- type: Div
13817
- }, text(content), {
13818
- childCount: 1,
13819
- className: CompletionDetailCloseButton,
13820
- onClick: HandleClose,
13821
- type: Div
13822
- }, {
13830
+ }, completionDetailContentNode, text(content), completionDetailCloseButtonNode, {
13823
13831
  childCount: 0,
13824
- className: `${MaskIcon} ${IconClose}`,
13832
+ className: mergeClassNames(MaskIcon, IconClose),
13825
13833
  type: Div
13826
13834
  }];
13827
13835
  return dom;
@@ -13969,7 +13977,7 @@ const render = widget => {
13969
13977
  } = widget.newState;
13970
13978
  const dom = [{
13971
13979
  childCount: 1,
13972
- className: 'Viewlet EditorMessage EditorMessageText EditorOverlayMessage',
13980
+ className: mergeClassNames('Viewlet', 'EditorMessage', 'EditorMessageText', 'EditorOverlayMessage'),
13973
13981
  style: `left:${x}px;top:${y}px;`,
13974
13982
  type: Div
13975
13983
  }, text(message)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.23.0",
3
+ "version": "19.24.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"