@lvce-editor/editor-worker 19.27.2 → 19.28.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.
@@ -1620,7 +1620,11 @@ const getPreference = async key => {
1620
1620
  return await invoke$b('Preferences.get', key);
1621
1621
  };
1622
1622
  const openUri = async (uri, focus, options) => {
1623
- await invoke$b('Main.openUri', uri, focus, options);
1623
+ await invoke$b('Main.openUri', {
1624
+ ...options,
1625
+ focus,
1626
+ uri
1627
+ });
1624
1628
  };
1625
1629
  const sendMessagePortToSyntaxHighlightingWorker$1 = async port => {
1626
1630
  await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
@@ -7531,7 +7535,7 @@ const execute = async ({
7531
7535
  return result;
7532
7536
  };
7533
7537
 
7534
- const getTextDocument$1 = editor => {
7538
+ const getTextDocument$2 = editor => {
7535
7539
  return {
7536
7540
  documentId: editor.id || editor.uid,
7537
7541
  languageId: editor.languageId,
@@ -7540,7 +7544,7 @@ const getTextDocument$1 = editor => {
7540
7544
  };
7541
7545
  };
7542
7546
  const executeIsolatedHoverProvider = async (editor, offset) => {
7543
- const textDocument = getTextDocument$1(editor);
7547
+ const textDocument = getTextDocument$2(editor);
7544
7548
  return invoke$e('Extensions.executeHoverProvider', textDocument, offset);
7545
7549
  };
7546
7550
  const executeHoverProvider = async (editor, offset) => {
@@ -9726,6 +9730,129 @@ const showHover = async state => {
9726
9730
  return state;
9727
9731
  };
9728
9732
 
9733
+ const clampIndex = (index, length) => {
9734
+ return Math.max(0, Math.min(index, length - 1));
9735
+ };
9736
+ const getDocumentation = (signature, parameter, activeParameter) => {
9737
+ const documentation = [];
9738
+ if (parameter) {
9739
+ documentation.push(`Parameter ${activeParameter + 1} of ${signature.parameters.length}: ${parameter.label}`);
9740
+ if (parameter.documentation) {
9741
+ documentation.push(parameter.documentation);
9742
+ }
9743
+ }
9744
+ if (signature.documentation) {
9745
+ documentation.push(signature.documentation);
9746
+ }
9747
+ return documentation.join('\n');
9748
+ };
9749
+ const getSignatureHelpContent = signatureHelp => {
9750
+ if (signatureHelp.signatures.length === 0) {
9751
+ return undefined;
9752
+ }
9753
+ const activeSignature = clampIndex(signatureHelp.activeSignature, signatureHelp.signatures.length);
9754
+ const signature = signatureHelp.signatures[activeSignature];
9755
+ const activeParameter = clampIndex(signatureHelp.activeParameter, signature.parameters.length);
9756
+ const parameter = signature.parameters[activeParameter];
9757
+ return {
9758
+ displayString: signature.label,
9759
+ documentation: getDocumentation(signature, parameter, activeParameter)
9760
+ };
9761
+ };
9762
+
9763
+ const getTextDocument$1 = editor => {
9764
+ return {
9765
+ documentId: editor.id || editor.uid,
9766
+ languageId: editor.languageId,
9767
+ text: getText$1(editor),
9768
+ uri: editor.uri
9769
+ };
9770
+ };
9771
+ const executeSignatureHelpProvider = async (editor, offset) => {
9772
+ object(editor);
9773
+ number(offset);
9774
+ const textDocument = getTextDocument$1(editor);
9775
+ return invoke$e('Extensions.executeSignatureHelpProvider', textDocument, offset);
9776
+ };
9777
+
9778
+ const getSignatureHelp = async (editor, offset) => {
9779
+ return executeSignatureHelpProvider(editor, offset);
9780
+ };
9781
+
9782
+ const getSignatureHelpInfo = async editorUid => {
9783
+ number(editorUid);
9784
+ const instance = get$7(editorUid);
9785
+ const editor = instance.newState;
9786
+ const {
9787
+ selections
9788
+ } = editor;
9789
+ const rowIndex = selections[0];
9790
+ const columnIndex = selections[1];
9791
+ const offset = offsetAt(editor, rowIndex, columnIndex);
9792
+ const signatureHelp = await getSignatureHelp(editor, offset);
9793
+ if (!signatureHelp) {
9794
+ return undefined;
9795
+ }
9796
+ const content = getSignatureHelpContent(signatureHelp);
9797
+ if (!content) {
9798
+ return undefined;
9799
+ }
9800
+ const {
9801
+ displayString,
9802
+ documentation
9803
+ } = content;
9804
+ const lineInfos = await tokenizeCodeBlock(displayString, editor.languageId || 'typescript', '');
9805
+ const documentationHeight = await measureTextBlockHeight();
9806
+ const x$1 = x(editor, rowIndex, columnIndex);
9807
+ const y$1 = editor.height - y(editor, rowIndex) + editor.y + 40;
9808
+ return {
9809
+ documentation,
9810
+ documentationHeight,
9811
+ lineInfos,
9812
+ x: x$1,
9813
+ y: y$1
9814
+ };
9815
+ };
9816
+
9817
+ const loadSignatureHelpContent = async state => {
9818
+ const {
9819
+ editorUid
9820
+ } = state;
9821
+ const signatureHelpInfo = await getSignatureHelpInfo(editorUid);
9822
+ if (!signatureHelpInfo) {
9823
+ return undefined;
9824
+ }
9825
+ const {
9826
+ documentation,
9827
+ lineInfos,
9828
+ x,
9829
+ y
9830
+ } = signatureHelpInfo;
9831
+ return {
9832
+ ...state,
9833
+ diagnostics: [],
9834
+ documentation,
9835
+ lineInfos,
9836
+ width: 600,
9837
+ x,
9838
+ y
9839
+ };
9840
+ };
9841
+
9842
+ const showSignatureHelp = async editor => {
9843
+ const {
9844
+ widgets = []
9845
+ } = editor;
9846
+ const editorWithoutHover = hasWidget(widgets, Hover) ? {
9847
+ ...editor,
9848
+ widgets: removeEditorWidget(widgets, Hover)
9849
+ } : editor;
9850
+ const newStateGenerator = async state => {
9851
+ return loadSignatureHelpContent(state);
9852
+ };
9853
+ return addWidgetToEditor(Hover, FocusEditorHover, editorWithoutHover, create$5, newStateGenerator);
9854
+ };
9855
+
9729
9856
  const create = () => {
9730
9857
  const completionUid = create$8();
9731
9858
  const widget = {
@@ -11582,8 +11709,12 @@ const getKeyBindings = () => {
11582
11709
  when: FocusEditorText
11583
11710
  }, {
11584
11711
  command: 'Editor.selectionGrow',
11585
- key: CtrlCmd | Shift | Space$1,
11712
+ key: Alt$1 | Shift | RightArrow,
11586
11713
  when: FocusEditor
11714
+ }, {
11715
+ command: 'Editor.showSignatureHelp',
11716
+ key: CtrlCmd | Shift | Space$1,
11717
+ when: FocusEditorText
11587
11718
  }];
11588
11719
  };
11589
11720
 
@@ -13731,6 +13862,7 @@ const commandMap = {
13731
13862
  'Editor.setText': wrapCommand(setText),
13732
13863
  'Editor.showHover': showHover,
13733
13864
  'Editor.showHover2': wrapCommand(showHover2),
13865
+ 'Editor.showSignatureHelp': wrapCommand(showSignatureHelp),
13734
13866
  'Editor.showSourceActions': wrapCommand(showSourceActions),
13735
13867
  'Editor.showSourceActions2': wrapCommand(showSourceActions),
13736
13868
  'Editor.showSourceActions3': wrapCommand(showSourceActions),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.27.2",
3
+ "version": "19.28.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"