@lvce-editor/editor-worker 19.62.3 → 19.63.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.
@@ -5247,6 +5247,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir, _langua
5247
5247
  height,
5248
5248
  highlightActiveLineNumber: true,
5249
5249
  highlightedLine: -1,
5250
+ hoverDelay: 200,
5250
5251
  hoverEnabled: false,
5251
5252
  id,
5252
5253
  incrementalEdits: emptyIncrementalEdits,
@@ -5498,6 +5499,7 @@ const createEditor = async ({
5498
5499
  formatOnSave,
5499
5500
  height,
5500
5501
  highlightActiveLineNumber = true,
5502
+ hoverDelay = 200,
5501
5503
  hoverEnabled,
5502
5504
  id,
5503
5505
  isAutoClosingBracketsEnabled,
@@ -5566,6 +5568,7 @@ const createEditor = async ({
5566
5568
  hasListener: false,
5567
5569
  height,
5568
5570
  highlightActiveLineNumber,
5571
+ hoverDelay,
5569
5572
  id,
5570
5573
  incrementalEdits: emptyIncrementalEdits,
5571
5574
  insertSpaces: true,
@@ -5852,6 +5855,39 @@ const dispose$3 = uid => {
5852
5855
  pendingSaves.delete(uid);
5853
5856
  };
5854
5857
 
5858
+ const state$6 = {
5859
+ editor: undefined,
5860
+ timeout: -1,
5861
+ token: 0,
5862
+ x: 0,
5863
+ y: 0
5864
+ };
5865
+ const get$2 = () => {
5866
+ return state$6;
5867
+ };
5868
+ const set$2 = (editor, timeout, x, y, token) => {
5869
+ state$6.editor = editor;
5870
+ state$6.timeout = timeout;
5871
+ state$6.token = token;
5872
+ state$6.x = x;
5873
+ state$6.y = y;
5874
+ };
5875
+ const clear$1 = editorUid => {
5876
+ const {
5877
+ editor,
5878
+ timeout
5879
+ } = state$6;
5880
+ if (editorUid !== undefined && editor?.uid !== editorUid) {
5881
+ return;
5882
+ }
5883
+ if (timeout !== -1) {
5884
+ clearTimeout(timeout);
5885
+ }
5886
+ state$6.editor = undefined;
5887
+ state$6.timeout = -1;
5888
+ state$6.token++;
5889
+ };
5890
+
5855
5891
  const getOffset = (lines, rowIndex, columnIndex) => {
5856
5892
  let offset = columnIndex;
5857
5893
  for (let i = 0; i < rowIndex; i++) {
@@ -5967,11 +6003,11 @@ const next = editorUid => {
5967
6003
  revisions.set(editorUid, revision);
5968
6004
  return revision;
5969
6005
  };
5970
- const get$2 = editorUid => {
6006
+ const get$1 = editorUid => {
5971
6007
  return revisions.get(editorUid) || 0;
5972
6008
  };
5973
6009
  const record = (editorUid, revision) => {
5974
- revisions.set(editorUid, Math.max(get$2(editorUid), revision));
6010
+ revisions.set(editorUid, Math.max(get$1(editorUid), revision));
5975
6011
  };
5976
6012
  const dispose$1 = editorUid => {
5977
6013
  revisions.delete(editorUid);
@@ -6027,6 +6063,7 @@ const disposeEditor = async editorUid => {
6027
6063
  if (!editor) {
6028
6064
  return [];
6029
6065
  }
6066
+ clear$1(editorUid);
6030
6067
  for (const widget of editor.widgets) {
6031
6068
  if (widget.id === ColorPicker$2) {
6032
6069
  await invoke$7('ColorPicker.dispose', widget.newState.uid);
@@ -6316,7 +6353,7 @@ const isFormattingError = error => {
6316
6353
  return error && error instanceof Error && error.message.startsWith(expectedErrorMessage$1);
6317
6354
  };
6318
6355
 
6319
- const state$6 = {
6356
+ const state$5 = {
6320
6357
  configured: false,
6321
6358
  lastId: -1,
6322
6359
  nextId: 0
@@ -6324,23 +6361,23 @@ const state$6 = {
6324
6361
  const configure = (start, end) => {
6325
6362
  const {
6326
6363
  configured
6327
- } = state$6;
6364
+ } = state$5;
6328
6365
  if (configured) {
6329
6366
  throw new Error('Component id range is already configured');
6330
6367
  }
6331
6368
  if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start <= 0 || end < start) {
6332
6369
  throw new Error('Invalid component id range');
6333
6370
  }
6334
- state$6.nextId = start;
6335
- state$6.lastId = end;
6336
- state$6.configured = true;
6371
+ state$5.nextId = start;
6372
+ state$5.lastId = end;
6373
+ state$5.configured = true;
6337
6374
  };
6338
6375
  const create$8 = () => {
6339
6376
  const {
6340
6377
  configured,
6341
6378
  lastId,
6342
6379
  nextId
6343
- } = state$6;
6380
+ } = state$5;
6344
6381
  if (!configured) {
6345
6382
  // Compatibility with renderer versions that do not assign worker id ranges.
6346
6383
  return Math.random();
@@ -6348,7 +6385,7 @@ const create$8 = () => {
6348
6385
  if (nextId > lastId) {
6349
6386
  throw new Error('Component id range exhausted');
6350
6387
  }
6351
- return state$6.nextId++;
6388
+ return state$5.nextId++;
6352
6389
  };
6353
6390
 
6354
6391
  const Message = 9;
@@ -7262,7 +7299,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
7262
7299
  if (!newState) {
7263
7300
  return editor;
7264
7301
  }
7265
- if (get$2(editor.uid) !== widgetRevision) {
7302
+ if (get$1(editor.uid) !== widgetRevision) {
7266
7303
  return get$8(editor.uid)?.newState || editor;
7267
7304
  }
7268
7305
  // @ts-ignore
@@ -7369,12 +7406,12 @@ const closeColorPicker = editor => {
7369
7406
  };
7370
7407
  };
7371
7408
 
7372
- const state$5 = {
7409
+ const state$4 = {
7373
7410
  compositionText: '',
7374
7411
  isComposing: false
7375
7412
  };
7376
7413
  const compositionStart = (editor, event) => {
7377
- state$5.isComposing = true;
7414
+ state$4.isComposing = true;
7378
7415
  return editor;
7379
7416
  };
7380
7417
  const getCompositionChanges = (selections, data) => {
@@ -7384,9 +7421,9 @@ const getCompositionChanges = (selections, data) => {
7384
7421
  const selectionStartColumn = selections[i + 1];
7385
7422
  const selectionEndRow = selections[i + 2];
7386
7423
  const selectionEndColumn = selections[i + 3];
7387
- const startColumnIndex = selectionStartColumn - state$5.compositionText.length;
7424
+ const startColumnIndex = selectionStartColumn - state$4.compositionText.length;
7388
7425
  changes.push({
7389
- deleted: [state$5.compositionText],
7426
+ deleted: [state$4.compositionText],
7390
7427
  end: {
7391
7428
  columnIndex: selectionEndColumn,
7392
7429
  rowIndex: selectionEndRow
@@ -7406,7 +7443,7 @@ const compositionUpdate = (editor, data) => {
7406
7443
  selections
7407
7444
  } = editor;
7408
7445
  const changes = getCompositionChanges(selections, data);
7409
- state$5.compositionText = data;
7446
+ state$4.compositionText = data;
7410
7447
  return scheduleDocumentAndCursorsSelections(editor, changes);
7411
7448
  };
7412
7449
  const compositionEnd = (editor, data) => {
@@ -7414,8 +7451,8 @@ const compositionEnd = (editor, data) => {
7414
7451
  selections
7415
7452
  } = editor;
7416
7453
  const changes = getCompositionChanges(selections, data);
7417
- state$5.isComposing = false;
7418
- state$5.compositionText = '';
7454
+ state$4.isComposing = false;
7455
+ state$4.compositionText = '';
7419
7456
  return scheduleDocumentAndCursorsSelections(editor, changes);
7420
7457
  };
7421
7458
 
@@ -9029,7 +9066,7 @@ const clear = editor => {
9029
9066
  decorations: filtered
9030
9067
  };
9031
9068
  };
9032
- const set$2 = (editor, offset, length) => {
9069
+ const set$1 = (editor, offset, length) => {
9033
9070
  if (matches(editor, offset, length)) {
9034
9071
  return editor;
9035
9072
  }
@@ -9185,24 +9222,6 @@ const handleMouseDown = async (state, button, altKey, ctrlKey, x, y, detail, shi
9185
9222
  };
9186
9223
  };
9187
9224
 
9188
- const state$4 = {
9189
- editor: undefined,
9190
- timeout: -1,
9191
- token: 0,
9192
- x: 0,
9193
- y: 0
9194
- };
9195
- const get$1 = () => {
9196
- return state$4;
9197
- };
9198
- const set$1 = (editor, timeout, x, y, token) => {
9199
- state$4.editor = editor;
9200
- state$4.timeout = timeout;
9201
- state$4.token = token;
9202
- state$4.x = x;
9203
- state$4.y = y;
9204
- };
9205
-
9206
9225
  const RE_ALPHA_NUMERIC = /[a-zA-Z\d]/;
9207
9226
  const isAlphaNumeric = char => {
9208
9227
  return RE_ALPHA_NUMERIC.test(char);
@@ -9264,7 +9283,7 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
9264
9283
  if (!definition) {
9265
9284
  return clear(editor);
9266
9285
  }
9267
- return set$2(editor, wordOffset, wordLength);
9286
+ return set$1(editor, wordOffset, wordLength);
9268
9287
  } catch (error) {
9269
9288
  if (isNoDefinitionProviderFoundError(error)) {
9270
9289
  return clear(editor);
@@ -9560,7 +9579,7 @@ const applyHoverContent = async (editor, getNewState) => {
9560
9579
  const widgetRevision = next(editor.uid);
9561
9580
  const widget = widgets[widgetIndex];
9562
9581
  const newState = await getNewState(widget.newState);
9563
- if (get$2(editor.uid) !== widgetRevision) {
9582
+ if (get$1(editor.uid) !== widgetRevision) {
9564
9583
  return editor;
9565
9584
  }
9566
9585
  if (!newState) {
@@ -9600,9 +9619,12 @@ const showHover = async (editor, position, token) => {
9600
9619
  return;
9601
9620
  }
9602
9621
  const latestEditor = instance.newState;
9622
+ if (!latestEditor.hoverEnabled) {
9623
+ return;
9624
+ }
9603
9625
  const newEditor = await showHover$1(latestEditor, position);
9604
9626
  const latestInstance = get$8(editor.uid);
9605
- if (latestEditor === newEditor || !latestInstance || latestInstance.newState !== latestEditor || get$1().token !== token) {
9627
+ if (latestEditor === newEditor || !latestInstance || latestInstance.newState !== latestEditor || get$2().token !== token) {
9606
9628
  return;
9607
9629
  }
9608
9630
  set$8(editor.uid, latestInstance.oldState, newEditor);
@@ -9624,8 +9646,12 @@ const onHoverIdle = async token => {
9624
9646
  token: latestToken,
9625
9647
  x,
9626
9648
  y
9627
- } = get$1();
9628
- if (latestToken !== token) {
9649
+ } = get$2();
9650
+ if (latestToken !== token || !editor) {
9651
+ return;
9652
+ }
9653
+ const instance = get$8(editor.uid);
9654
+ if (!instance || !instance.newState.hoverEnabled) {
9629
9655
  return;
9630
9656
  }
9631
9657
  const position = await at(editor, x, y);
@@ -9634,8 +9660,8 @@ const onHoverIdle = async token => {
9634
9660
  // Hover providers are optional and should not surface errors from an idle mouse event.
9635
9661
  }
9636
9662
  };
9637
- const hoverDelay = 200;
9638
9663
  const handleMouseMove = async (editor, x, y, altKey) => {
9664
+ clear$1();
9639
9665
  if (altKey) {
9640
9666
  return handleMouseMoveWithAltKey(editor, x, y);
9641
9667
  }
@@ -9643,13 +9669,9 @@ const handleMouseMove = async (editor, x, y, altKey) => {
9643
9669
  if (!editorWithoutDefinitionLink.hoverEnabled) {
9644
9670
  return editorWithoutDefinitionLink;
9645
9671
  }
9646
- const oldState = get$1();
9647
- if (oldState.timeout !== -1) {
9648
- clearTimeout(oldState.timeout);
9649
- }
9650
9672
  const token = create$8();
9651
- const timeout = setTimeout(onHoverIdle, hoverDelay, token);
9652
- set$1(editorWithoutDefinitionLink, timeout, x, y, token);
9673
+ const timeout = setTimeout(onHoverIdle, editorWithoutDefinitionLink.hoverDelay ?? 200, token);
9674
+ set$2(editorWithoutDefinitionLink, timeout, x, y, token);
9653
9675
  return editorWithoutDefinitionLink;
9654
9676
  };
9655
9677
 
@@ -14474,8 +14496,16 @@ const getMergeConflictActionsEnabled = async () => {
14474
14496
  return (await get$3(kMergeConflictActions)) ?? false;
14475
14497
  };
14476
14498
 
14499
+ const DEFAULT_HOVER_DELAY = 200;
14500
+ const getHoverDelay = value => {
14501
+ const delay = typeof value === 'number' ? value : Number(value);
14502
+ if (!Number.isFinite(delay) || delay < 0) {
14503
+ return DEFAULT_HOVER_DELAY;
14504
+ }
14505
+ return delay;
14506
+ };
14477
14507
  const getEditorPreferences = async () => {
14478
- const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, roundedSelection, combineWhitespaceTokens] = await Promise.all([get$3('editor.diagnostics'), getFontFamily(), getFontSize(), getFontWeight(), get$3('editor.formatOnSave'), get$3('editor.hover'), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getHighlightActiveLineNumber(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getMergeConflictActionsEnabled(), get$3('breadcrumbs.enabled'), get$3('editor.insertSpaces'), get$3('editor.dragAndDrop'), get$3('editor.roundedSelection'), get$3('editor.combineWhitespaceTokens')]);
14508
+ const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, hoverEnabled, hoverDelay, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, roundedSelection, combineWhitespaceTokens] = await Promise.all([get$3('editor.diagnostics'), getFontFamily(), getFontSize(), getFontWeight(), get$3('editor.formatOnSave'), get$3('editor.hover'), get$3('editor.hoverDelay'), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getHighlightActiveLineNumber(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getMergeConflictActionsEnabled(), get$3('breadcrumbs.enabled'), get$3('editor.insertSpaces'), get$3('editor.dragAndDrop'), get$3('editor.roundedSelection'), get$3('editor.combineWhitespaceTokens')]);
14479
14509
  return {
14480
14510
  breadcrumbsEnabled: breadcrumbsEnabled ?? false,
14481
14511
  combineWhitespaceTokens: combineWhitespaceTokens ?? true,
@@ -14487,7 +14517,8 @@ const getEditorPreferences = async () => {
14487
14517
  fontWeight,
14488
14518
  formatOnSave: formatOnSave ?? false,
14489
14519
  highlightActiveLineNumber,
14490
- hoverEnabled: hoverEnabled ?? true,
14520
+ hoverDelay: getHoverDelay(hoverDelay),
14521
+ hoverEnabled: hoverEnabled ?? false,
14491
14522
  insertSpaces: insertSpaces ?? true,
14492
14523
  isAutoClosingBracketsEnabled: isAutoClosingBracketsEnabled$1,
14493
14524
  isAutoClosingQuotesEnabled: isAutoClosingQuotesEnabled$1,
@@ -14553,6 +14584,9 @@ const handleSettingsChanged = async state => {
14553
14584
  minimapRevision: (state.minimapRevision || 0) + (minimapEnabled ? 1 : 0),
14554
14585
  visualDecorations: diagnosticsEnabled ? state.visualDecorations : []
14555
14586
  };
14587
+ if (!editorWithUpdatedSettings.hoverEnabled) {
14588
+ clear$1(state.uid);
14589
+ }
14556
14590
  let documentSymbols = state.documentSymbols || [];
14557
14591
  let workspaceUri = state.workspaceUri || '';
14558
14592
  if (!breadcrumbsEnabled) {
@@ -14850,6 +14884,7 @@ const loadContent = async (state, savedState, largeFile = false) => {
14850
14884
  fontWeight,
14851
14885
  formatOnSave,
14852
14886
  highlightActiveLineNumber,
14887
+ hoverDelay,
14853
14888
  hoverEnabled,
14854
14889
  insertSpaces,
14855
14890
  isAutoClosingBracketsEnabled,
@@ -14882,6 +14917,7 @@ const loadContent = async (state, savedState, largeFile = false) => {
14882
14917
  fontWeight,
14883
14918
  formatOnSave,
14884
14919
  highlightActiveLineNumber,
14920
+ hoverDelay,
14885
14921
  hoverEnabled,
14886
14922
  insertSpaces,
14887
14923
  isAutoClosingBracketsEnabled,
@@ -759,7 +759,17 @@
759
759
  "heading": "Hover",
760
760
  "id": "editor.hover",
761
761
  "type": "boolean",
762
- "value": "true"
762
+ "value": false
763
+ },
764
+ {
765
+ "category": "text-editor",
766
+ "description": "Controls the delay in milliseconds after which hover information will show up",
767
+ "heading": "Hover Delay",
768
+ "id": "editor.hoverDelay",
769
+ "type": "number",
770
+ "value": 200,
771
+ "minimum": 0,
772
+ "maximum": 10000
763
773
  },
764
774
  {
765
775
  "category": "text-editor",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.62.3",
3
+ "version": "19.63.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"