@lvce-editor/editor-worker 19.70.4 → 19.70.6

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.
@@ -1187,7 +1187,7 @@ const createMockRpc = ({
1187
1187
  };
1188
1188
 
1189
1189
  const rpcs = Object.create(null);
1190
- const set$i = (id, rpc) => {
1190
+ const set$j = (id, rpc) => {
1191
1191
  rpcs[id] = rpc;
1192
1192
  };
1193
1193
  const get$9 = id => {
@@ -1220,7 +1220,7 @@ const create$c = rpcId => {
1220
1220
  const mockRpc = createMockRpc({
1221
1221
  commandMap
1222
1222
  });
1223
- set$i(rpcId, mockRpc);
1223
+ set$j(rpcId, mockRpc);
1224
1224
  // @ts-ignore
1225
1225
  mockRpc[Symbol.dispose] = () => {
1226
1226
  remove$8(rpcId);
@@ -1229,7 +1229,7 @@ const create$c = rpcId => {
1229
1229
  return mockRpc;
1230
1230
  },
1231
1231
  set(rpc) {
1232
- set$i(rpcId, rpc);
1232
+ set$j(rpcId, rpc);
1233
1233
  }
1234
1234
  };
1235
1235
  };
@@ -1328,23 +1328,23 @@ const FocusEditorText$1 = 12;
1328
1328
 
1329
1329
  const {
1330
1330
  invoke: invoke$j,
1331
- set: set$h
1331
+ set: set$i
1332
1332
  } = create$c(DialogWorker);
1333
1333
 
1334
1334
  const {
1335
1335
  invoke: invoke$i,
1336
- set: set$g
1336
+ set: set$h
1337
1337
  } = create$c(DragAndDropWorker);
1338
1338
 
1339
1339
  const {
1340
1340
  invoke: invoke$h,
1341
- set: set$f
1341
+ set: set$g
1342
1342
  } = create$c(ErrorWorker);
1343
1343
 
1344
1344
  const {
1345
1345
  invoke: invoke$g,
1346
1346
  invokeAndTransfer: invokeAndTransfer$2,
1347
- set: set$e
1347
+ set: set$f
1348
1348
  } = create$c(ExtensionManagementWorker);
1349
1349
  const getLanguages$1 = (platform, assetDir) => {
1350
1350
  return invoke$g('Extensions.getLanguages', platform, assetDir);
@@ -1363,7 +1363,7 @@ const createLazyRpc = rpcId => {
1363
1363
  throw new Error('Lazy RPC launch was superseded');
1364
1364
  }
1365
1365
  activeRpc = rpc;
1366
- set$i(rpcId, rpc);
1366
+ set$j(rpcId, rpc);
1367
1367
  return rpc;
1368
1368
  };
1369
1369
  const ensureRpc = async () => {
@@ -1425,7 +1425,7 @@ const createLazyRpc = rpcId => {
1425
1425
 
1426
1426
  const {
1427
1427
  invoke: invoke$f,
1428
- set: set$d
1428
+ set: set$e
1429
1429
  } = create$c(OpenerWorker);
1430
1430
  const openUrl = async (url, platform) => {
1431
1431
  return invoke$f('Open.openUrl', url, platform);
@@ -1433,13 +1433,13 @@ const openUrl = async (url, platform) => {
1433
1433
 
1434
1434
  const {
1435
1435
  invoke: invoke$e,
1436
- set: set$c
1436
+ set: set$d
1437
1437
  } = create$c(TextMeasurementWorker);
1438
1438
 
1439
1439
  const {
1440
1440
  invoke: invoke$d,
1441
1441
  invokeAndTransfer: invokeAndTransfer$1,
1442
- set: set$b
1442
+ set: set$c
1443
1443
  } = create$c(RendererWorker);
1444
1444
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1445
1445
  number(uid);
@@ -1494,13 +1494,13 @@ const sendMessagePortToSyntaxHighlightingWorker$1 = async port => {
1494
1494
 
1495
1495
  const {
1496
1496
  invoke: invoke$c,
1497
- set: set$a
1497
+ set: set$b
1498
1498
  } = create$c(MarkdownWorker);
1499
1499
 
1500
1500
  const SyntaxHighlightingWorker = {
1501
1501
  __proto__: null,
1502
1502
  invoke: invoke$c,
1503
- set: set$a
1503
+ set: set$b
1504
1504
  };
1505
1505
 
1506
1506
  const toCommandId = key => {
@@ -1811,7 +1811,7 @@ const getKeys$2 = () => {
1811
1811
  const keys = editorStates.getKeys();
1812
1812
  return keys.map(String);
1813
1813
  };
1814
- const set$9 = (id, oldEditor, newEditor) => {
1814
+ const set$a = (id, oldEditor, newEditor) => {
1815
1815
  editorStates.set(id, oldEditor, newEditor);
1816
1816
  };
1817
1817
 
@@ -1862,7 +1862,7 @@ const ToggleBlockComment$1 = 'toggleBlockComment';
1862
1862
  const Unknown$2 = 'unknown';
1863
1863
 
1864
1864
  const map$1 = Object.create(null);
1865
- const set$8 = (id, widget) => {
1865
+ const set$9 = (id, widget) => {
1866
1866
  map$1[id] = widget;
1867
1867
  };
1868
1868
  const get$7 = id => {
@@ -2506,7 +2506,7 @@ const getEnabled$1 = () => {
2506
2506
 
2507
2507
  const {
2508
2508
  invoke: invoke$b,
2509
- set: set$7
2509
+ set: set$8
2510
2510
  } = SyntaxHighlightingWorker;
2511
2511
 
2512
2512
  const state$c = {
@@ -2517,7 +2517,7 @@ const state$c = {
2517
2517
  const has = languageId => {
2518
2518
  return Object.hasOwn(state$c.tokenizers, languageId);
2519
2519
  };
2520
- const set$6 = (languageId, tokenizer) => {
2520
+ const set$7 = (languageId, tokenizer) => {
2521
2521
  state$c.tokenizers[languageId] = tokenizer;
2522
2522
  };
2523
2523
  const get$6 = languageId => {
@@ -2541,7 +2541,7 @@ const isPending = languageId => {
2541
2541
  };
2542
2542
 
2543
2543
  const tokenMaps = Object.create(null);
2544
- const set$5 = (languageId, tokenMap) => {
2544
+ const set$6 = (languageId, tokenMap) => {
2545
2545
  tokenMaps[languageId] = tokenMap;
2546
2546
  };
2547
2547
  const get$5 = languageId => {
@@ -2557,7 +2557,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
2557
2557
  if (getEnabled$1()) {
2558
2558
  // @ts-ignore
2559
2559
  const tokenMap = await invoke$b('Tokenizer.load', languageId, tokenizePath);
2560
- set$5(languageId, tokenMap);
2560
+ set$6(languageId, tokenMap);
2561
2561
  return;
2562
2562
  }
2563
2563
  try {
@@ -2573,8 +2573,8 @@ const loadTokenizer = async (languageId, tokenizePath) => {
2573
2573
  console.warn(`tokenizer.TokenMap should be an object in "${tokenizePath}"`);
2574
2574
  return;
2575
2575
  }
2576
- set$5(languageId, tokenizer.TokenMap);
2577
- set$6(languageId, tokenizer);
2576
+ set$6(languageId, tokenizer.TokenMap);
2577
+ set$7(languageId, tokenizer);
2578
2578
  } catch (error) {
2579
2579
  // TODO better error handling
2580
2580
  console.error(error);
@@ -2591,7 +2591,7 @@ const getTokenizer = languageId => {
2591
2591
  };
2592
2592
 
2593
2593
  const tokenizers = Object.create(null);
2594
- const set$4 = (id, value) => {
2594
+ const set$5 = (id, value) => {
2595
2595
  tokenizers[id] = value;
2596
2596
  };
2597
2597
  const get$4 = id => {
@@ -3322,6 +3322,12 @@ const getLineInfosViewport = (editor, tokens, embeddedResults, minLineY, maxLine
3322
3322
  };
3323
3323
  };
3324
3324
  const getVisible$1 = async (editor, syncIncremental) => {
3325
+ if (editor.lifecycle?.disposed) {
3326
+ return {
3327
+ differences: [],
3328
+ textInfos: []
3329
+ };
3330
+ }
3325
3331
  if (editor.largeFile) {
3326
3332
  return getLargeFileVisible(editor);
3327
3333
  }
@@ -3355,6 +3361,12 @@ const getVisible$1 = async (editor, syncIncremental) => {
3355
3361
  } = await getTokensViewport2(editor, minLineY, maxLineY, syncIncremental);
3356
3362
  for (let i = 0; tokenizersToLoad.length > 0 && i < maxTokenizerLoadPasses$1; i++) {
3357
3363
  await loadTokenizers(tokenizersToLoad);
3364
+ if (editor.lifecycle?.disposed) {
3365
+ return {
3366
+ differences: [],
3367
+ textInfos: []
3368
+ };
3369
+ }
3358
3370
  // @ts-ignore
3359
3371
  const refreshed = await getTokensViewport2(editor, minLineY, maxLineY, syncIncremental);
3360
3372
  ({
@@ -3363,6 +3375,12 @@ const getVisible$1 = async (editor, syncIncremental) => {
3363
3375
  tokens
3364
3376
  } = refreshed);
3365
3377
  }
3378
+ if (editor.lifecycle?.disposed) {
3379
+ return {
3380
+ differences: [],
3381
+ textInfos: []
3382
+ };
3383
+ }
3366
3384
  const minLineOffset = await offsetAtSync(editor, minLineY, 0);
3367
3385
  const averageCharWidth = charWidth;
3368
3386
  const {
@@ -4372,7 +4390,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
4372
4390
  ...newEditor,
4373
4391
  decorations: linkDecorations
4374
4392
  };
4375
- set$9(editor.uid, editor, newEditorWithDecorations);
4393
+ set$a(editor.uid, editor, newEditorWithDecorations);
4376
4394
 
4377
4395
  // Notify main-area-worker about modified status change
4378
4396
  if (!editor.modified) {
@@ -5255,7 +5273,7 @@ const updateColorPickerValue = async (editorUid, value) => {
5255
5273
  return;
5256
5274
  }
5257
5275
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
5258
- set$9(editorUid, editor, newEditorWithDerivedState);
5276
+ set$a(editorUid, editor, newEditorWithDerivedState);
5259
5277
  };
5260
5278
 
5261
5279
  const getColorPickerWorkerCommandMap = () => ({
@@ -5466,7 +5484,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir, _langua
5466
5484
  x,
5467
5485
  y
5468
5486
  };
5469
- set$9(id, editor, editor);
5487
+ set$a(id, editor, editor);
5470
5488
  };
5471
5489
 
5472
5490
  const emptyEditor = {
@@ -5809,10 +5827,10 @@ const createEditor = async ({
5809
5827
  focused: true,
5810
5828
  textInfos
5811
5829
  };
5812
- set$9(id, emptyEditor, newEditor4);
5830
+ set$a(id, emptyEditor, newEditor4);
5813
5831
  const completionsOnTypeRaw = await get$3('editor.completionsOnType');
5814
5832
  const completionsOnType = Boolean(completionsOnTypeRaw);
5815
- set$9(id, emptyEditor, {
5833
+ set$a(id, emptyEditor, {
5816
5834
  ...newEditor4,
5817
5835
  completionsOnType
5818
5836
  });
@@ -5843,7 +5861,7 @@ const createStandaloneEditor = async ({
5843
5861
  const createdEditor = get$8(id).newState;
5844
5862
  await loadTokenizer(languageId, tokenizePath);
5845
5863
  const tokenizerId = createdEditor.tokenizerId + 1;
5846
- set$4(tokenizerId, getTokenizer(languageId));
5864
+ set$5(tokenizerId, getTokenizer(languageId));
5847
5865
  const configuredEditor = {
5848
5866
  ...createdEditor,
5849
5867
  charWidth,
@@ -5888,7 +5906,7 @@ const createStandaloneEditor = async ({
5888
5906
  selectionInfos
5889
5907
  };
5890
5908
  if (!createdEditor.lifecycle?.disposed) {
5891
- set$9(id, createdEditor, finalEditor);
5909
+ set$a(id, createdEditor, finalEditor);
5892
5910
  }
5893
5911
  };
5894
5912
 
@@ -6001,17 +6019,17 @@ const dispose$4 = uid => {
6001
6019
  pendingSaves.delete(uid);
6002
6020
  };
6003
6021
 
6004
- const dismissals = new Map();
6005
- const clear$2 = editorUid => {
6006
- const dismissal = dismissals.get(editorUid);
6022
+ const dismissals$1 = new Map();
6023
+ const clear$3 = editorUid => {
6024
+ const dismissal = dismissals$1.get(editorUid);
6007
6025
  if (dismissal) {
6008
6026
  clearTimeout(dismissal.timeout);
6009
- dismissals.delete(editorUid);
6027
+ dismissals$1.delete(editorUid);
6010
6028
  }
6011
6029
  };
6012
- const set$3 = (editorUid, dismissal) => {
6013
- clear$2(editorUid);
6014
- dismissals.set(editorUid, dismissal);
6030
+ const set$4 = (editorUid, dismissal) => {
6031
+ clear$3(editorUid);
6032
+ dismissals$1.set(editorUid, dismissal);
6015
6033
  };
6016
6034
 
6017
6035
  const state$6 = {
@@ -6024,14 +6042,14 @@ const state$6 = {
6024
6042
  const get$2 = () => {
6025
6043
  return state$6;
6026
6044
  };
6027
- const set$2 = (editor, timeout, x, y, token) => {
6045
+ const set$3 = (editor, timeout, x, y, token) => {
6028
6046
  state$6.editor = editor;
6029
6047
  state$6.timeout = timeout;
6030
6048
  state$6.token = token;
6031
6049
  state$6.x = x;
6032
6050
  state$6.y = y;
6033
6051
  };
6034
- const clear$1 = editorUid => {
6052
+ const clear$2 = editorUid => {
6035
6053
  const {
6036
6054
  editor,
6037
6055
  timeout
@@ -6047,6 +6065,20 @@ const clear$1 = editorUid => {
6047
6065
  state$6.token++;
6048
6066
  };
6049
6067
 
6068
+ const dismissals = new Map();
6069
+ const clear$1 = editorUid => {
6070
+ const dismissal = dismissals.get(editorUid);
6071
+ if (!dismissal) {
6072
+ return;
6073
+ }
6074
+ clearTimeout(dismissal.timeout);
6075
+ dismissals.delete(editorUid);
6076
+ };
6077
+ const set$2 = (editorUid, dismissal) => {
6078
+ clear$1(editorUid);
6079
+ dismissals.set(editorUid, dismissal);
6080
+ };
6081
+
6050
6082
  const getOffset = (lines, rowIndex, columnIndex) => {
6051
6083
  let offset = columnIndex;
6052
6084
  for (let i = 0; i < rowIndex; i++) {
@@ -6418,7 +6450,7 @@ const commitDiagnostics = async (editor, generation, diagnostics, onAccepted) =>
6418
6450
  return latest.newState;
6419
6451
  }
6420
6452
  const newEditor = mergeDiagnostics(latest.newState, editorWithDiagnostics);
6421
- set$9(editor.id, latest.oldState, newEditor);
6453
+ set$a(editor.id, latest.oldState, newEditor);
6422
6454
  requestDiagnosticSnapshots.set(editor.id, diagnostics);
6423
6455
  onAccepted?.();
6424
6456
  await invoke$5('Editor.renderPending', newEditor.id);
@@ -6631,8 +6663,9 @@ const disposeEditor = async editorUid => {
6631
6663
  }
6632
6664
  dispose$2(editorUid);
6633
6665
  dispose$4(editorUid);
6634
- clear$1(editorUid);
6635
6666
  clear$2(editorUid);
6667
+ clear$3(editorUid);
6668
+ clear$1(editorUid);
6636
6669
  dispose$1(editorUid);
6637
6670
  const pending = [];
6638
6671
  if (getEnabled$1()) {
@@ -7290,6 +7323,20 @@ const create$8 = () => {
7290
7323
  return state$5.nextId++;
7291
7324
  };
7292
7325
 
7326
+ const getIndex = (widgets, id) => {
7327
+ for (const [i, widget] of widgets.entries()) {
7328
+ if (widget.id === id) {
7329
+ return i;
7330
+ }
7331
+ }
7332
+ return -1;
7333
+ };
7334
+ const removeEditorWidget = (widgets, id) => {
7335
+ const index = getIndex(widgets, id);
7336
+ const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
7337
+ return newWidgets;
7338
+ };
7339
+
7293
7340
  const Message = 9;
7294
7341
 
7295
7342
  const getAccurateColumnIndexAscii = async (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth) => {
@@ -7434,21 +7481,32 @@ const at = async (editor, eventX, eventY) => {
7434
7481
  };
7435
7482
 
7436
7483
  /**
7437
- * @deprecated this doesn't work for variable width characters (Unicode/emoji).
7438
- * Use position computation in renderer process instead
7439
- *
7440
- * @param {object} editor
7441
- * @param {number} rowIndex
7442
- * @param {number} columnIndex
7443
- * @returns
7484
+ * @deprecated this doesn't account for variable-width characters, gutters, or horizontal scrolling.
7444
7485
  */
7445
7486
  const x = (editor, rowIndex, columnIndex) => {
7446
7487
  const {
7447
7488
  columnWidth,
7448
7489
  x
7449
7490
  } = editor;
7450
- const offsetX = columnIndex * columnWidth + x;
7451
- return offsetX;
7491
+ return columnIndex * columnWidth + x;
7492
+ };
7493
+ const getCursorX = async (editor, rowIndex, columnIndex) => {
7494
+ const {
7495
+ charWidth,
7496
+ deltaX,
7497
+ fontFamily,
7498
+ fontSize,
7499
+ fontWeight,
7500
+ gutterWidth = 0,
7501
+ isMonospaceFont,
7502
+ letterSpacing,
7503
+ lines,
7504
+ tabSize,
7505
+ width,
7506
+ x
7507
+ } = editor;
7508
+ const textX = await getX(lines[rowIndex] || '', columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, 0, width, charWidth);
7509
+ return x + gutterWidth + textX - deltaX;
7452
7510
  };
7453
7511
  const y = (editor, rowIndex) => {
7454
7512
  const {
@@ -7460,6 +7518,8 @@ const y = (editor, rowIndex) => {
7460
7518
  return offsetY;
7461
7519
  };
7462
7520
 
7521
+ const defaultMessageDelay = 3000;
7522
+
7463
7523
  /**
7464
7524
  *
7465
7525
  * @param {any} editor
@@ -7470,29 +7530,54 @@ const y = (editor, rowIndex) => {
7470
7530
  * @returns
7471
7531
  */
7472
7532
  // @ts-ignore
7473
- const editorShowMessage = (editor, rowIndex, columnIndex, message, _isError) => {
7533
+ const editorShowMessage = async (editor, rowIndex, columnIndex, message, _isError) => {
7474
7534
  object(editor);
7475
7535
  number(rowIndex);
7476
7536
  number(columnIndex);
7477
7537
  string(message);
7478
- const x$1 = x(editor, rowIndex, columnIndex);
7538
+ const x = await getCursorX(editor, rowIndex, columnIndex);
7479
7539
  const y$1 = y(editor, rowIndex);
7480
7540
  const existingWidget = editor.widgets.find(widget => widget.id === Message);
7481
7541
  const uid = existingWidget?.newState.uid ?? create$8();
7482
7542
  const newState = {
7483
7543
  message,
7484
7544
  uid,
7485
- x: x$1,
7545
+ x,
7486
7546
  y: y$1
7487
7547
  };
7488
7548
  const widget = {
7489
7549
  id: Message,
7490
7550
  newState
7491
7551
  };
7492
- return {
7552
+ const newEditor = {
7493
7553
  ...editor,
7494
7554
  widgets: [...editor.widgets.filter(item => item.id !== Message), widget]
7495
7555
  };
7556
+ if (typeof editor.uid === 'number') {
7557
+ const timeout = setTimeout(async () => {
7558
+ clear$1(editor.uid);
7559
+ const latestInstance = get$8(editor.uid);
7560
+ if (!latestInstance) {
7561
+ return;
7562
+ }
7563
+ const latestEditor = latestInstance.newState;
7564
+ const latestWidget = latestEditor.widgets.find(item => item.id === Message);
7565
+ if (latestWidget?.newState.uid !== uid) {
7566
+ return;
7567
+ }
7568
+ const editorWithoutMessage = {
7569
+ ...latestEditor,
7570
+ widgetRevision: next(editor.uid),
7571
+ widgets: removeEditorWidget(latestEditor.widgets, Message)
7572
+ };
7573
+ set$a(editor.uid, latestEditor, editorWithoutMessage);
7574
+ await invoke$d('Editor.renderPending', editor.uid);
7575
+ }, editor.messageDelay ?? defaultMessageDelay);
7576
+ set$2(editor.uid, {
7577
+ timeout
7578
+ });
7579
+ }
7580
+ return newEditor;
7496
7581
  };
7497
7582
 
7498
7583
  /**
@@ -7504,8 +7589,8 @@ const editorShowMessage = (editor, rowIndex, columnIndex, message, _isError) =>
7504
7589
  * @returns
7505
7590
  */
7506
7591
  // @ts-ignore
7507
- const showErrorMessage = (editor, rowIndex, columnIndex, message) => {
7508
- return editorShowMessage(editor, rowIndex, columnIndex, message);
7592
+ const showErrorMessage = async (editor, rowIndex, columnIndex, message) => {
7593
+ return await editorShowMessage(editor, rowIndex, columnIndex, message);
7509
7594
  };
7510
7595
 
7511
7596
  const expectedErrorMessage = 'Failed to execute formatting provider: FormattingError:';
@@ -7773,20 +7858,6 @@ const getCursorOffset = editor => {
7773
7858
  return offsetAt(editor, editor.selections[0], editor.selections[1]);
7774
7859
  };
7775
7860
 
7776
- const getIndex = (widgets, id) => {
7777
- for (const [i, widget] of widgets.entries()) {
7778
- if (widget.id === id) {
7779
- return i;
7780
- }
7781
- }
7782
- return -1;
7783
- };
7784
- const removeEditorWidget = (widgets, id) => {
7785
- const index = getIndex(widgets, id);
7786
- const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
7787
- return newWidgets;
7788
- };
7789
-
7790
7861
  const cancelSelection = editor => {
7791
7862
  const {
7792
7863
  selections,
@@ -10175,14 +10246,14 @@ const handleMouseLeave = (viewletUid, editorUidValue) => {
10175
10246
  const {
10176
10247
  widgets = []
10177
10248
  } = instance.newState;
10178
- clear$1(editorUid);
10179
10249
  clear$2(editorUid);
10250
+ clear$3(editorUid);
10180
10251
  const hoverWidget = widgets.find(widget => widget.id === Hover);
10181
10252
  if (!hoverWidget) {
10182
10253
  return;
10183
10254
  }
10184
10255
  const timeout = setTimeout(async () => {
10185
- clear$2(editorUid);
10256
+ clear$3(editorUid);
10186
10257
  const latestInstance = get$8(editorUid);
10187
10258
  if (!latestInstance) {
10188
10259
  return;
@@ -10200,16 +10271,16 @@ const handleMouseLeave = (viewletUid, editorUidValue) => {
10200
10271
  widgetRevision: next(editorUid),
10201
10272
  widgets: removeEditorWidget(latestEditor.widgets, Hover)
10202
10273
  };
10203
- set$9(editorUid, latestEditor, newEditor);
10274
+ set$a(editorUid, latestEditor, newEditor);
10204
10275
  await invoke$d('Editor.renderPending', editorUid);
10205
10276
  }, editorHoverDismissDelay);
10206
- set$3(editorUid, {
10277
+ set$4(editorUid, {
10207
10278
  timeout
10208
10279
  });
10209
10280
  };
10210
10281
  const handleMouseEnter = (viewletUid, editorUidValue) => {
10211
10282
  const targetEditorUid = editorUidValue ?? viewletUid;
10212
- clear$2(Number(targetEditorUid));
10283
+ clear$3(Number(targetEditorUid));
10213
10284
  };
10214
10285
 
10215
10286
  const RE_ALPHA_NUMERIC = /[a-zA-Z\d]/;
@@ -10633,7 +10704,7 @@ const showHover = async (editor, position, token) => {
10633
10704
  if (latestEditor === newEditor || !latestInstance || latestInstance.newState !== latestEditor || get$2().token !== token) {
10634
10705
  return;
10635
10706
  }
10636
- set$9(editor.uid, latestInstance.oldState, newEditor);
10707
+ set$a(editor.uid, latestInstance.oldState, newEditor);
10637
10708
  await invoke$d('Editor.renderPending', editor.uid);
10638
10709
  };
10639
10710
 
@@ -10667,7 +10738,7 @@ const onHoverIdle = async token => {
10667
10738
  }
10668
10739
  };
10669
10740
  const handleMouseMove = async (editor, x, y, altKey) => {
10670
- clear$1();
10741
+ clear$2();
10671
10742
  if (altKey) {
10672
10743
  return handleMouseMoveWithAltKey(editor, x, y);
10673
10744
  }
@@ -10677,7 +10748,7 @@ const handleMouseMove = async (editor, x, y, altKey) => {
10677
10748
  }
10678
10749
  const token = create$8();
10679
10750
  const timeout = setTimeout(onHoverIdle, editorWithoutDefinitionLink.hoverDelay ?? 200, token);
10680
- set$2(editorWithoutDefinitionLink, timeout, x, y, token);
10751
+ set$3(editorWithoutDefinitionLink, timeout, x, y, token);
10681
10752
  return editorWithoutDefinitionLink;
10682
10753
  };
10683
10754
 
@@ -10895,7 +10966,7 @@ const continueScrollingAndMovingSelection = async editorUid => {
10895
10966
  }
10896
10967
  return;
10897
10968
  }
10898
- set$9(editor.uid, editor, derivedEditor);
10969
+ set$a(editor.uid, editor, derivedEditor);
10899
10970
  if (derivedEditor.hasListener) {
10900
10971
  requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
10901
10972
  }
@@ -11684,7 +11755,7 @@ const updateEditor = async (editorUid, editor, newEditor) => {
11684
11755
  return;
11685
11756
  }
11686
11757
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
11687
- set$9(editorUid, editor, newEditorWithDerivedState);
11758
+ set$a(editorUid, editor, newEditorWithDerivedState);
11688
11759
  };
11689
11760
  const applyDocumentEdits = async (editorUid, edits) => {
11690
11761
  const editor = getEditor$1(editorUid);
@@ -11734,7 +11805,7 @@ const launch = async () => {
11734
11805
  return;
11735
11806
  }
11736
11807
  const rpc = await launchFindWidgetWorker();
11737
- set$i(rpcId, rpc);
11808
+ set$j(rpcId, rpc);
11738
11809
  };
11739
11810
  const invoke$3 = async (method, ...params) => {
11740
11811
  const rpc = get$9(rpcId);
@@ -11865,7 +11936,7 @@ const createFn = (key, name, widgetId) => {
11865
11936
  const latestAfterInvoke = get$8(editor.uid).newState;
11866
11937
  const latestChildIndex = latestAfterInvoke.widgets.findIndex(isWidget);
11867
11938
  if (latestChildIndex === -1) {
11868
- set$9(editor.uid, editor, latestAfterInvoke);
11939
+ set$a(editor.uid, editor, latestAfterInvoke);
11869
11940
  await dispose$3();
11870
11941
  return latestAfterInvoke;
11871
11942
  }
@@ -11879,7 +11950,7 @@ const createFn = (key, name, widgetId) => {
11879
11950
  widgetRevision,
11880
11951
  widgets: removeEditorWidget(latest.widgets, widgetId)
11881
11952
  };
11882
- set$9(editor.uid, latest, newEditor);
11953
+ set$a(editor.uid, latest, newEditor);
11883
11954
  return newEditor;
11884
11955
  }
11885
11956
  const newState = {
@@ -11887,7 +11958,7 @@ const createFn = (key, name, widgetId) => {
11887
11958
  commands
11888
11959
  };
11889
11960
  const newEditor = updateWidget(latest, widgetId, newState);
11890
- set$9(editor.uid, editor, newEditor);
11961
+ set$a(editor.uid, editor, newEditor);
11891
11962
  return newEditor;
11892
11963
  };
11893
11964
  return fn;
@@ -12917,7 +12988,7 @@ const setLanguageId = async (editor, languageId, tokenizePath, isExplicit = fals
12917
12988
  await loadTokenizer(languageId, tokenizePath);
12918
12989
  const tokenizer = getTokenizer(languageId);
12919
12990
  const newTokenizerId = tokenizerId + 1;
12920
- set$4(newTokenizerId, tokenizer);
12991
+ set$5(newTokenizerId, tokenizer);
12921
12992
  return {
12922
12993
  ...editor,
12923
12994
  explicitLanguageId: isExplicit ? languageId : editor.explicitLanguageId,
@@ -14922,7 +14993,7 @@ const setSelections2 = async (editorUid, selections) => {
14922
14993
  const editor = getEditor$1(editorUid);
14923
14994
  const newEditor = setSelections$2(editor, selections);
14924
14995
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
14925
- set$9(editorUid, editor, newEditorWithDerivedState);
14996
+ set$a(editorUid, editor, newEditorWithDerivedState);
14926
14997
  };
14927
14998
  const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
14928
14999
  const editor = getEditor$1(editorUid);
@@ -14946,7 +15017,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
14946
15017
  widgets: newWidgets
14947
15018
  };
14948
15019
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
14949
- set$9(editorUid, editor, newEditorWithDerivedState);
15020
+ set$a(editorUid, editor, newEditorWithDerivedState);
14950
15021
  await setFocus(FocusEditorText);
14951
15022
  if (unsetAdditionalFocus$1) {
14952
15023
  await unsetAdditionalFocus(unsetAdditionalFocus$1);
@@ -14959,7 +15030,7 @@ const applyEdits2 = async (editorUid, edits, selectionChanges) => {
14959
15030
  const editor = getEditor$1(editorUid);
14960
15031
  const newEditor = await applyEdit(editor, edits, selectionChanges);
14961
15032
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
14962
- set$9(editorUid, editor, newEditorWithDerivedState);
15033
+ set$a(editorUid, editor, newEditorWithDerivedState);
14963
15034
  };
14964
15035
  const getSourceActions = async editorUid => {
14965
15036
  const actions = await getEditorSourceActions(editorUid);
@@ -15633,7 +15704,7 @@ const handleMessagePort = async (port, rpcId) => {
15633
15704
  messagePort: port
15634
15705
  });
15635
15706
  if (rpcId) {
15636
- set$i(rpcId, rpc);
15707
+ set$j(rpcId, rpc);
15637
15708
  await initializeListener(rpcId);
15638
15709
  }
15639
15710
  };
@@ -15751,6 +15822,8 @@ const getMergeConflictActionsEnabled = async () => {
15751
15822
  };
15752
15823
 
15753
15824
  const DEFAULT_HOVER_DELAY = 200;
15825
+ const DEFAULT_MESSAGE_DELAY = 3000;
15826
+ const MAX_MESSAGE_DELAY = 10_000;
15754
15827
  const getHoverDelay = value => {
15755
15828
  const delay = typeof value === 'number' ? value : Number(value);
15756
15829
  if (!Number.isFinite(delay) || delay < 0) {
@@ -15758,8 +15831,15 @@ const getHoverDelay = value => {
15758
15831
  }
15759
15832
  return delay;
15760
15833
  };
15834
+ const getMessageDelay = value => {
15835
+ const delay = typeof value === 'number' ? value : Number(value);
15836
+ if (!Number.isFinite(delay) || delay < 0 || delay > MAX_MESSAGE_DELAY) {
15837
+ return DEFAULT_MESSAGE_DELAY;
15838
+ }
15839
+ return delay;
15840
+ };
15761
15841
  const getEditorPreferences = async () => {
15762
- 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')]);
15842
+ const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, hoverEnabled, hoverDelay, messageDelay, 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'), get$3('editor.messageDelay'), 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')]);
15763
15843
  return {
15764
15844
  breadcrumbsEnabled: breadcrumbsEnabled ?? false,
15765
15845
  combineWhitespaceTokens: combineWhitespaceTokens ?? true,
@@ -15781,6 +15861,7 @@ const getEditorPreferences = async () => {
15781
15861
  letterSpacing,
15782
15862
  lineNumbers,
15783
15863
  mergeConflictActionsEnabled,
15864
+ messageDelay: getMessageDelay(messageDelay),
15784
15865
  minimapEnabled,
15785
15866
  roundedSelection: roundedSelection === true,
15786
15867
  rowHeight,
@@ -15855,7 +15936,7 @@ const handleSettingsChanged = async state => {
15855
15936
  visualDecorations: diagnosticsEnabled ? state.visualDecorations : []
15856
15937
  };
15857
15938
  if (!editorWithUpdatedSettings.hoverEnabled) {
15858
- clear$1(state.uid);
15939
+ clear$2(state.uid);
15859
15940
  }
15860
15941
  let documentSymbols = state.documentSymbols || [];
15861
15942
  let workspaceUri = state.workspaceUri || '';
@@ -16040,7 +16121,7 @@ const hotReload = async () => {
16040
16121
  await relaunchWorkers();
16041
16122
  const newEditors = await restoreWidgetState(keys, savedStates);
16042
16123
  for (const editor of newEditors) {
16043
- set$9(editor.newState.uid, editor.oldState, editor.newState);
16124
+ set$a(editor.newState.uid, editor.oldState, editor.newState);
16044
16125
  }
16045
16126
 
16046
16127
  // TODO ask renderer worker to rerender all editors
@@ -16078,7 +16159,7 @@ const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncre
16078
16159
  if (syntaxHighlightingEnabled) {
16079
16160
  setEnabled$1(true);
16080
16161
  const syntaxRpc = await createSyntaxHighlightingWorkerRpc();
16081
- set$7(syntaxRpc);
16162
+ set$8(syntaxRpc);
16082
16163
  }
16083
16164
  if (syncIncremental) {
16084
16165
  setEnabled(true);
@@ -16275,7 +16356,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true) =
16275
16356
  await loadTokenizer(computedLanguageId, tokenizePath);
16276
16357
  const tokenizer = getTokenizer(computedLanguageId);
16277
16358
  const newTokenizerId = state.tokenizerId + 1;
16278
- set$4(newTokenizerId, tokenizer);
16359
+ set$5(newTokenizerId, tokenizer);
16279
16360
  effectiveEditor.tokenizerId = newTokenizerId;
16280
16361
  }
16281
16362
  const savedHistory = existingEditor ? undefined : getSavedHistory(savedState, content);
@@ -16419,7 +16500,7 @@ const refreshGutterDecorationsAll = async () => {
16419
16500
  if (!latest) {
16420
16501
  continue;
16421
16502
  }
16422
- set$9(editor.id, latest.oldState, {
16503
+ set$a(editor.id, latest.oldState, {
16423
16504
  ...latest.newState,
16424
16505
  gutterDecorations: refreshedEditor.gutterDecorations
16425
16506
  });
@@ -17730,7 +17811,7 @@ const render2 = (uid, _diffResult) => {
17730
17811
  } = editor;
17731
17812
  // Diagnostics can change after the caller calculated its diff in a separate RPC.
17732
17813
  const diffResult = diff(oldState, newState);
17733
- set$9(uid, newState, newState);
17814
+ set$a(uid, newState, newState);
17734
17815
  const commands = applyRender(oldState, newState, diffResult);
17735
17816
  return commands;
17736
17817
  };
@@ -17840,7 +17921,7 @@ const renderEditor = async id => {
17840
17921
  oldState
17841
17922
  } = instance;
17842
17923
  const commands = [];
17843
- set$9(id, newState, newState);
17924
+ set$a(id, newState, newState);
17844
17925
  for (const item of render$7) {
17845
17926
  if (item.isEqual(oldState, newState)) {
17846
17927
  continue;
@@ -18055,7 +18136,7 @@ const updateDebugInfo = async debugId => {
18055
18136
  ...newState,
18056
18137
  highlightedLine: newInfo.rowIndex
18057
18138
  };
18058
- set$9(key, oldState, newEditor);
18139
+ set$a(key, oldState, newEditor);
18059
18140
  // @ts-ignore
18060
18141
  await invoke$d('Editor.rerender', key);
18061
18142
  };
@@ -18152,7 +18233,7 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
18152
18233
  return returnState ? newEditor : undefined;
18153
18234
  }
18154
18235
  const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
18155
- set$9(uid, state, newEditorWithDerivedState);
18236
+ set$a(uid, state, newEditorWithDerivedState);
18156
18237
  await dispose$3();
18157
18238
  if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
18158
18239
  void editorDiagnosticEffect.apply(newEditorWithDerivedState);
@@ -18181,7 +18262,7 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
18181
18262
  undoStack: finalEditor.undoStack,
18182
18263
  visualDecorations: finalEditor.visualDecorations
18183
18264
  });
18184
- set$9(otherUid, instance.oldState, synchronizedEditor);
18265
+ set$a(otherUid, instance.oldState, synchronizedEditor);
18185
18266
  if (editorDiagnosticEffect.isActive(editor, synchronizedEditor)) {
18186
18267
  void editorDiagnosticEffect.apply(synchronizedEditor);
18187
18268
  }
@@ -18209,6 +18290,19 @@ const wrapFocusCommand$1 = (fn, returnState = true) => {
18209
18290
  };
18210
18291
  };
18211
18292
 
18293
+ // Optional provider work must not hold the editing queue while another worker responds.
18294
+ const wrapDeferredCommand$1 = (fn, returnState = true) => {
18295
+ const apply = wrapCommand$1((editor, snapshot, result) => editor === snapshot ? result : editor, false, returnState);
18296
+ return async (uid, ...args) => {
18297
+ const snapshot = await enqueue(uid, async () => get$8(uid)?.newState);
18298
+ if (!snapshot) {
18299
+ return undefined;
18300
+ }
18301
+ const result = await fn(snapshot, ...args);
18302
+ return apply(uid, snapshot, result);
18303
+ };
18304
+ };
18305
+
18212
18306
  // State and undo history belong in this worker. Rendering reads changes separately.
18213
18307
  const wrapCommand = (fn, preservesTypingCoalescing = false) => {
18214
18308
  return wrapCommand$1(fn, preservesTypingCoalescing, false);
@@ -18216,6 +18310,9 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => {
18216
18310
  const wrapFocusCommand = fn => {
18217
18311
  return wrapFocusCommand$1(fn, false);
18218
18312
  };
18313
+ const wrapDeferredCommand = fn => {
18314
+ return wrapDeferredCommand$1(fn, false);
18315
+ };
18219
18316
 
18220
18317
  const executeViewletCommand = (uid, commandId, ...args) => {
18221
18318
  return executeViewletCommand$1(commandMap, uid, commandId, ...args);
@@ -18425,8 +18522,8 @@ const commandMap = {
18425
18522
  'Editor.setSelections': wrapCommand(setSelections),
18426
18523
  'Editor.setSelections2': setSelections2,
18427
18524
  'Editor.setText': wrapCommand(setText),
18428
- 'Editor.showHover': wrapCommand(showHover$1),
18429
- 'Editor.showHover2': wrapCommand(showHover$1),
18525
+ 'Editor.showHover': wrapDeferredCommand(showHover$1),
18526
+ 'Editor.showHover2': wrapDeferredCommand(showHover$1),
18430
18527
  'Editor.showSignatureHelp': wrapCommand(showSignatureHelp),
18431
18528
  'Editor.showSourceActions': wrapCommand(showSourceActions),
18432
18529
  'Editor.showSourceActions2': wrapCommand(showSourceActions),
@@ -18544,7 +18641,7 @@ const initializeDragAndDropWorker = async () => {
18544
18641
  commandMap: {},
18545
18642
  send: sendMessagePortToDragAndDropWorker
18546
18643
  });
18547
- set$g(rpc);
18644
+ set$h(rpc);
18548
18645
  };
18549
18646
 
18550
18647
  const initializeErrorWorker = async () => {
@@ -18554,7 +18651,7 @@ const initializeErrorWorker = async () => {
18554
18651
  return sendMessagePortToErrorWorker(port, EditorWorker);
18555
18652
  }
18556
18653
  });
18557
- set$f(rpc);
18654
+ set$g(rpc);
18558
18655
  };
18559
18656
 
18560
18657
  const createExtensionManagementWorkerRpc = async () => {
@@ -18570,7 +18667,7 @@ const createExtensionManagementWorkerRpc = async () => {
18570
18667
  const initializeExtensionManagementWorker = async () => {
18571
18668
  try {
18572
18669
  const rpc = await createExtensionManagementWorkerRpc();
18573
- set$e(rpc);
18670
+ set$f(rpc);
18574
18671
  } catch {
18575
18672
  // ignore
18576
18673
  }
@@ -18585,14 +18682,14 @@ const initializeOpenerWorker = async () => {
18585
18682
  commandMap: {},
18586
18683
  send: send$1
18587
18684
  });
18588
- set$d(rpc);
18685
+ set$e(rpc);
18589
18686
  };
18590
18687
 
18591
18688
  const initializeRendererWorker = async () => {
18592
18689
  const rpc = await create$d({
18593
18690
  commandMap: commandMap
18594
18691
  });
18595
- set$b(rpc);
18692
+ set$c(rpc);
18596
18693
  };
18597
18694
 
18598
18695
  const send = port => {
@@ -18603,7 +18700,7 @@ const initializeTextMeasurementWorker = async () => {
18603
18700
  commandMap: {},
18604
18701
  send
18605
18702
  });
18606
- set$c(rpc);
18703
+ set$d(rpc);
18607
18704
  };
18608
18705
 
18609
18706
  const listen = async () => {
@@ -18613,7 +18710,7 @@ const listen = async () => {
18613
18710
  commandMap: {},
18614
18711
  send: sendMessagePortToDialogWorker
18615
18712
  });
18616
- set$h(dialogRpc);
18713
+ set$i(dialogRpc);
18617
18714
  };
18618
18715
 
18619
18716
  const CodeGeneratorInput = 'CodeGeneratorInput';
@@ -18935,15 +19032,15 @@ const EditorMessageWidget = {
18935
19032
  };
18936
19033
 
18937
19034
  const registerWidgets = () => {
18938
- set$8(ColorPicker$2, EditorColorPickerWidget);
18939
- set$8(Completion, EditorCompletionWidget);
18940
- set$8(CompletionDetail, EditorCompletionDetailWidget);
18941
- set$8(Find, EditorFindWidget);
18942
- set$8(Hover, EditorHoverWidget);
18943
- set$8(Message, EditorMessageWidget);
18944
- set$8(Rename$1, EditorRenameWidget);
18945
- set$8(SourceAction$1, EditorSourceActionWidget);
18946
- set$8(CodeGenerator, EditorCodeGeneratorWidget);
19035
+ set$9(ColorPicker$2, EditorColorPickerWidget);
19036
+ set$9(Completion, EditorCompletionWidget);
19037
+ set$9(CompletionDetail, EditorCompletionDetailWidget);
19038
+ set$9(Find, EditorFindWidget);
19039
+ set$9(Hover, EditorHoverWidget);
19040
+ set$9(Message, EditorMessageWidget);
19041
+ set$9(Rename$1, EditorRenameWidget);
19042
+ set$9(SourceAction$1, EditorSourceActionWidget);
19043
+ set$9(CodeGenerator, EditorCodeGeneratorWidget);
18947
19044
  };
18948
19045
 
18949
19046
  const handleUnhandledRejection = event => {
@@ -791,6 +791,16 @@
791
791
  "minimum": 0,
792
792
  "maximum": 10000
793
793
  },
794
+ {
795
+ "category": "text-editor",
796
+ "description": "Controls how long editor messages remain visible, in milliseconds",
797
+ "heading": "Message Display Duration",
798
+ "id": "editor.messageDelay",
799
+ "type": "number",
800
+ "value": 3000,
801
+ "minimum": 0,
802
+ "maximum": 10000
803
+ },
794
804
  {
795
805
  "category": "text-editor",
796
806
  "description": "Controls whether the editor should be in a diff editor",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.70.4",
3
+ "version": "19.70.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"