@lvce-editor/editor-worker 19.74.7 → 19.75.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.
@@ -1187,7 +1187,7 @@ const createMockRpc = ({
1187
1187
  };
1188
1188
 
1189
1189
  const rpcs = Object.create(null);
1190
- const set$j = (id, rpc) => {
1190
+ const set$k = (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$j(rpcId, mockRpc);
1223
+ set$k(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$j(rpcId, rpc);
1232
+ set$k(rpcId, rpc);
1233
1233
  }
1234
1234
  };
1235
1235
  };
@@ -1327,27 +1327,27 @@ const SetPatches = 'Viewlet.setPatches';
1327
1327
  const FocusEditorText$1 = 12;
1328
1328
 
1329
1329
  const {
1330
- invoke: invoke$j,
1331
- set: set$i
1330
+ invoke: invoke$k,
1331
+ set: set$j
1332
1332
  } = create$c(DialogWorker);
1333
1333
 
1334
1334
  const {
1335
- invoke: invoke$i,
1336
- set: set$h
1335
+ invoke: invoke$j,
1336
+ set: set$i
1337
1337
  } = create$c(DragAndDropWorker);
1338
1338
 
1339
1339
  const {
1340
- invoke: invoke$h,
1341
- set: set$g
1340
+ invoke: invoke$i,
1341
+ set: set$h
1342
1342
  } = create$c(ErrorWorker);
1343
1343
 
1344
1344
  const {
1345
- invoke: invoke$g,
1345
+ invoke: invoke$h,
1346
1346
  invokeAndTransfer: invokeAndTransfer$2,
1347
- set: set$f
1347
+ set: set$g
1348
1348
  } = create$c(ExtensionManagementWorker);
1349
1349
  const getLanguages$1 = (platform, assetDir) => {
1350
- return invoke$g('Extensions.getLanguages', platform, assetDir);
1350
+ return invoke$h('Extensions.getLanguages', platform, assetDir);
1351
1351
  };
1352
1352
 
1353
1353
  const createLazyRpc = rpcId => {
@@ -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$j(rpcId, rpc);
1366
+ set$k(rpcId, rpc);
1367
1367
  return rpc;
1368
1368
  };
1369
1369
  const ensureRpc = async () => {
@@ -1424,29 +1424,29 @@ const createLazyRpc = rpcId => {
1424
1424
  };
1425
1425
 
1426
1426
  const {
1427
- invoke: invoke$f,
1428
- set: set$e
1427
+ invoke: invoke$g,
1428
+ set: set$f
1429
1429
  } = create$c(OpenerWorker);
1430
1430
  const openUrl = async (url, platform) => {
1431
- return invoke$f('Open.openUrl', url, platform);
1431
+ return invoke$g('Open.openUrl', url, platform);
1432
1432
  };
1433
1433
 
1434
1434
  const {
1435
- invoke: invoke$e,
1436
- set: set$d
1435
+ invoke: invoke$f,
1436
+ set: set$e
1437
1437
  } = create$c(TextMeasurementWorker);
1438
1438
 
1439
1439
  const {
1440
- invoke: invoke$d,
1440
+ invoke: invoke$e,
1441
1441
  invokeAndTransfer: invokeAndTransfer$1,
1442
- set: set$c
1442
+ set: set$d
1443
1443
  } = create$c(RendererWorker);
1444
1444
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1445
1445
  number(uid);
1446
1446
  number(menuId);
1447
1447
  number(x);
1448
1448
  number(y);
1449
- await invoke$d('ContextMenu.show2', uid, menuId, x, y, args);
1449
+ await invoke$e('ContextMenu.show2', uid, menuId, x, y, args);
1450
1450
  };
1451
1451
  const sendMessagePortToDragAndDropWorker = async port => {
1452
1452
  const command = 'DragAndDrop.handleMessagePort';
@@ -1465,10 +1465,10 @@ const sendMessagePortToErrorWorker = async (port, rpcId) => {
1465
1465
  await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
1466
1466
  };
1467
1467
  const writeClipBoardText = async text => {
1468
- await invoke$d('ClipBoard.writeText', /* text */text);
1468
+ await invoke$e('ClipBoard.writeText', /* text */text);
1469
1469
  };
1470
1470
  const readClipBoardText = async () => {
1471
- return invoke$d('ClipBoard.readText');
1471
+ return invoke$e('ClipBoard.readText');
1472
1472
  };
1473
1473
  const sendMessagePortToTextMeasurementWorker = async port => {
1474
1474
  const command = 'TextMeasurement.handleMessagePort';
@@ -1479,10 +1479,10 @@ const sendMessagePortToExtensionManagementWorker$1 = async (port, rpcId) => {
1479
1479
  await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
1480
1480
  };
1481
1481
  const getPreference$1 = async key => {
1482
- return await invoke$d('Preferences.get', key);
1482
+ return await invoke$e('Preferences.get', key);
1483
1483
  };
1484
1484
  const openUri = async (uri, focus, options) => {
1485
- await invoke$d('Main.openUri', {
1485
+ await invoke$e('Main.openUri', {
1486
1486
  ...options,
1487
1487
  focus,
1488
1488
  uri
@@ -1493,8 +1493,8 @@ const sendMessagePortToSyntaxHighlightingWorker$1 = async port => {
1493
1493
  };
1494
1494
 
1495
1495
  const {
1496
- invoke: invoke$c,
1497
- set: set$b
1496
+ invoke: invoke$d,
1497
+ set: set$c
1498
1498
  } = create$c(MarkdownWorker);
1499
1499
 
1500
1500
  const toCommandId = key => {
@@ -1764,7 +1764,7 @@ const activateByEvent = async (event, assetDir, platform) => {
1764
1764
  string(event);
1765
1765
  // Assert.string(assetDir)
1766
1766
  // Assert.number(platform)
1767
- await invoke$g('Extensions.activateByEvent', event);
1767
+ await invoke$h('Extensions.activateByEvent', event);
1768
1768
  };
1769
1769
 
1770
1770
  const codeGeneratorAccept = state => {
@@ -1805,7 +1805,7 @@ const getKeys$2 = () => {
1805
1805
  const keys = editorStates.getKeys();
1806
1806
  return keys.map(String);
1807
1807
  };
1808
- const set$a = (id, oldEditor, newEditor) => {
1808
+ const set$b = (id, oldEditor, newEditor) => {
1809
1809
  editorStates.set(id, oldEditor, newEditor);
1810
1810
  };
1811
1811
 
@@ -1856,7 +1856,7 @@ const ToggleBlockComment$1 = 'toggleBlockComment';
1856
1856
  const Unknown$2 = 'unknown';
1857
1857
 
1858
1858
  const map$1 = Object.create(null);
1859
- const set$9 = (id, widget) => {
1859
+ const set$a = (id, widget) => {
1860
1860
  map$1[id] = widget;
1861
1861
  };
1862
1862
  const get$7 = id => {
@@ -2641,7 +2641,7 @@ const getInitialLineState = initialLineState => {
2641
2641
  return deepCopy(initialLineState);
2642
2642
  };
2643
2643
 
2644
- const state$e = {
2644
+ const state$f = {
2645
2645
  warned: []
2646
2646
  };
2647
2647
  const flattenTokensArray = tokens => {
@@ -2653,10 +2653,10 @@ const flattenTokensArray = tokens => {
2653
2653
  return flattened;
2654
2654
  };
2655
2655
  const warnDeprecatedArrayReturn = (languageId, fn) => {
2656
- if (state$e.warned.includes(fn)) {
2656
+ if (state$f.warned.includes(fn)) {
2657
2657
  return;
2658
2658
  }
2659
- state$e.warned.push(fn);
2659
+ state$f.warned.push(fn);
2660
2660
  console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
2661
2661
  };
2662
2662
  const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
@@ -2717,38 +2717,38 @@ const TokenizePlainText = {
2717
2717
  tokenizeLine
2718
2718
  };
2719
2719
 
2720
- const state$d = {
2720
+ const state$e = {
2721
2721
  enabled: false
2722
2722
  };
2723
2723
  const setEnabled$1 = value => {
2724
- state$d.enabled = value;
2724
+ state$e.enabled = value;
2725
2725
  };
2726
2726
  const getEnabled$1 = () => {
2727
- return state$d.enabled;
2727
+ return state$e.enabled;
2728
2728
  };
2729
2729
 
2730
- const invoke$b = (...args) => invoke$c(...args);
2731
- const set$8 = (...args) => set$b(...args);
2730
+ const invoke$c = (...args) => invoke$d(...args);
2731
+ const set$9 = (...args) => set$c(...args);
2732
2732
 
2733
- const state$c = {
2733
+ const state$d = {
2734
2734
  pending: Object.create(null),
2735
2735
  tokenizePaths: Object.create(null),
2736
2736
  tokenizers: Object.create(null)
2737
2737
  };
2738
2738
  const has = languageId => {
2739
- return Object.hasOwn(state$c.tokenizers, languageId);
2739
+ return Object.hasOwn(state$d.tokenizers, languageId);
2740
2740
  };
2741
- const set$7 = (languageId, tokenizer) => {
2742
- state$c.tokenizers[languageId] = tokenizer;
2741
+ const set$8 = (languageId, tokenizer) => {
2742
+ state$d.tokenizers[languageId] = tokenizer;
2743
2743
  };
2744
2744
  const get$6 = languageId => {
2745
- return state$c.tokenizers[languageId];
2745
+ return state$d.tokenizers[languageId];
2746
2746
  };
2747
2747
  const setTokenizePath = (languageId, tokenizePath) => {
2748
- state$c.tokenizePaths[languageId] = tokenizePath;
2748
+ state$d.tokenizePaths[languageId] = tokenizePath;
2749
2749
  };
2750
2750
  const getTokenizePath$1 = languageId => {
2751
- return state$c.tokenizePaths[languageId] || '';
2751
+ return state$d.tokenizePaths[languageId] || '';
2752
2752
  };
2753
2753
  const setTokenizePaths = languages => {
2754
2754
  for (const language of languages) {
@@ -2758,11 +2758,11 @@ const setTokenizePaths = languages => {
2758
2758
  }
2759
2759
  };
2760
2760
  const isPending = languageId => {
2761
- return Object.hasOwn(state$c.pending, languageId);
2761
+ return Object.hasOwn(state$d.pending, languageId);
2762
2762
  };
2763
2763
 
2764
2764
  const tokenMaps = Object.create(null);
2765
- const set$6 = (languageId, tokenMap) => {
2765
+ const set$7 = (languageId, tokenMap) => {
2766
2766
  tokenMaps[languageId] = tokenMap;
2767
2767
  };
2768
2768
  const get$5 = languageId => {
@@ -2777,8 +2777,8 @@ const loadTokenizer = async (languageId, tokenizePath) => {
2777
2777
  setTokenizePath(languageId, tokenizePath);
2778
2778
  if (getEnabled$1()) {
2779
2779
  // @ts-ignore
2780
- const tokenMap = await invoke$b('Tokenizer.load', languageId, tokenizePath);
2781
- set$6(languageId, tokenMap);
2780
+ const tokenMap = await invoke$c('Tokenizer.load', languageId, tokenizePath);
2781
+ set$7(languageId, tokenMap);
2782
2782
  return;
2783
2783
  }
2784
2784
  try {
@@ -2794,8 +2794,8 @@ const loadTokenizer = async (languageId, tokenizePath) => {
2794
2794
  console.warn(`tokenizer.TokenMap should be an object in "${tokenizePath}"`);
2795
2795
  return;
2796
2796
  }
2797
- set$6(languageId, tokenizer.TokenMap);
2798
- set$7(languageId, tokenizer);
2797
+ set$7(languageId, tokenizer.TokenMap);
2798
+ set$8(languageId, tokenizer);
2799
2799
  } catch (error) {
2800
2800
  // TODO better error handling
2801
2801
  console.error(error);
@@ -2812,7 +2812,7 @@ const getTokenizer = languageId => {
2812
2812
  };
2813
2813
 
2814
2814
  const tokenizers = Object.create(null);
2815
- const set$5 = (id, value) => {
2815
+ const set$6 = (id, value) => {
2816
2816
  tokenizers[id] = value;
2817
2817
  };
2818
2818
  const get$4 = id => {
@@ -2973,13 +2973,13 @@ const getTokensViewport2 = async (editor, startLineIndex, endLineIndex, syncIncr
2973
2973
  invalidStartIndex,
2974
2974
  languageId
2975
2975
  };
2976
- return invoke$b('GetTokensViewport.getTokensViewport', slimEditor,
2976
+ return invoke$c('GetTokensViewport.getTokensViewport', slimEditor,
2977
2977
  // @ts-ignore
2978
2978
  startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
2979
2979
  }
2980
2980
  // TODO only send needed lines of text
2981
2981
  // @ts-ignore
2982
- return invoke$b('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
2982
+ return invoke$c('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
2983
2983
  }
2984
2984
  return getTokensViewport(editor, startLineIndex, endLineIndex);
2985
2985
  };
@@ -3001,12 +3001,12 @@ const measureTextWidthFast = async (text, charWidth) => {
3001
3001
  };
3002
3002
 
3003
3003
  const measureTextWidthSlow = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
3004
- const width = await invoke$e('TextMeasurement.measureTextWidth', text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
3004
+ const width = await invoke$f('TextMeasurement.measureTextWidth', text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
3005
3005
  return width;
3006
3006
  };
3007
3007
 
3008
3008
  const measureTextWidthsSlow = async (texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
3009
- return await invoke$e('TextMeasurement.measureTextWidths', texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
3009
+ return await invoke$f('TextMeasurement.measureTextWidths', texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
3010
3010
  };
3011
3011
 
3012
3012
  const measureTextWidth = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
@@ -3243,7 +3243,7 @@ const positionAt = (textDocument, offset) => {
3243
3243
  const maxTokenizerLoadPasses$1 = 10;
3244
3244
  const getGraphemeSegments = async lines => {
3245
3245
  try {
3246
- return await invoke$e('TextMeasurement.getGraphemeSegments', lines);
3246
+ return await invoke$f('TextMeasurement.getGraphemeSegments', lines);
3247
3247
  } catch {
3248
3248
  return undefined;
3249
3249
  }
@@ -3709,14 +3709,14 @@ const getVisible$1 = async (editor, syncIncremental) => {
3709
3709
  };
3710
3710
  };
3711
3711
 
3712
- const state$b = {
3712
+ const state$c = {
3713
3713
  enabled: false
3714
3714
  };
3715
3715
  const setEnabled = value => {
3716
- state$b.enabled = value;
3716
+ state$c.enabled = value;
3717
3717
  };
3718
3718
  const getEnabled = () => {
3719
- return state$b.enabled;
3719
+ return state$c.enabled;
3720
3720
  };
3721
3721
 
3722
3722
  // TODO this should be in a separate scrolling module
@@ -3796,7 +3796,7 @@ const getIncrementalEdits = async (oldState, newState) => {
3796
3796
  return emptyIncrementalEdits;
3797
3797
  }
3798
3798
  // @ts-ignore
3799
- const incrementalEdits = await invoke$b(
3799
+ const incrementalEdits = await invoke$c(
3800
3800
  // @ts-ignore
3801
3801
  'TokenizeIncremental.tokenizeIncremental', newState.uid,
3802
3802
  // @ts-ignore
@@ -4044,7 +4044,7 @@ const send$2 = (rpcId, rpc, status) => {
4044
4044
  return delivery.running || start(delivery);
4045
4045
  };
4046
4046
 
4047
- const state$a = Object.create(null);
4047
+ const state$b = Object.create(null);
4048
4048
 
4049
4049
  /**
4050
4050
  * Register a listener for a specific event type
@@ -4054,13 +4054,13 @@ const state$a = Object.create(null);
4054
4054
  const registerListener$1 = (listenerType, rpcId) => {
4055
4055
  number(listenerType);
4056
4056
  number(rpcId);
4057
- if (!Object.hasOwn(state$a, listenerType)) {
4058
- state$a[listenerType] = [];
4057
+ if (!Object.hasOwn(state$b, listenerType)) {
4058
+ state$b[listenerType] = [];
4059
4059
  }
4060
4060
 
4061
4061
  // Avoid duplicate registrations
4062
- if (!state$a[listenerType].includes(rpcId)) {
4063
- state$a[listenerType].push(rpcId);
4062
+ if (!state$b[listenerType].includes(rpcId)) {
4063
+ state$b[listenerType].push(rpcId);
4064
4064
  }
4065
4065
  };
4066
4066
 
@@ -4075,10 +4075,10 @@ const unregisterListener$1 = (listenerType, rpcId) => {
4075
4075
  if (listenerType === EditorSelection$1) {
4076
4076
  dispose$5(rpcId);
4077
4077
  }
4078
- if (Object.hasOwn(state$a, listenerType)) {
4079
- const index = state$a[listenerType].indexOf(rpcId);
4078
+ if (Object.hasOwn(state$b, listenerType)) {
4079
+ const index = state$b[listenerType].indexOf(rpcId);
4080
4080
  if (index !== -1) {
4081
- state$a[listenerType].splice(index, 1);
4081
+ state$b[listenerType].splice(index, 1);
4082
4082
  }
4083
4083
  }
4084
4084
  };
@@ -4090,7 +4090,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
4090
4090
  */
4091
4091
  const getListeners = listenerType => {
4092
4092
  number(listenerType);
4093
- return state$a[listenerType] || [];
4093
+ return state$b[listenerType] || [];
4094
4094
  };
4095
4095
 
4096
4096
  /**
@@ -4189,36 +4189,36 @@ const splitLines = lines => {
4189
4189
  return lines.split('\n');
4190
4190
  };
4191
4191
 
4192
- const state$9 = {};
4192
+ const state$a = {};
4193
4193
  const create$a = () => create$g({
4194
4194
  commandMap: {},
4195
4195
  send: port => invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, 'FileSystem.connect')
4196
4196
  });
4197
- const invoke$a = async (method, ...args) => {
4198
- state$9.rpcPromise ||= create$a();
4197
+ const invoke$b = async (method, ...args) => {
4198
+ state$a.rpcPromise ||= create$a();
4199
4199
  let rpc;
4200
4200
  try {
4201
4201
  const {
4202
4202
  rpcPromise
4203
- } = state$9;
4203
+ } = state$a;
4204
4204
  rpc = await rpcPromise;
4205
4205
  } catch (error) {
4206
- delete state$9.rpcPromise;
4206
+ delete state$a.rpcPromise;
4207
4207
  throw error;
4208
4208
  }
4209
4209
  return rpc.invoke(method, ...args);
4210
4210
  };
4211
4211
 
4212
- const invoke$9 = async (applicationId, method, ...args) => {
4213
- return applicationId === undefined ? invoke$d(method, ...args) : invoke$d('Application.execute', applicationId, method, ...args);
4212
+ const invoke$a = async (applicationId, method, ...args) => {
4213
+ return applicationId === undefined ? invoke$e(method, ...args) : invoke$e('Application.execute', applicationId, method, ...args);
4214
4214
  };
4215
4215
  const readFile$1 = async (applicationId, uri) => {
4216
- return applicationId === undefined ? invoke$a('FileSystem.readFile', uri) : invoke$a('ApplicationFileSystem.execute', applicationId, 'readFile', uri);
4216
+ return applicationId === undefined ? invoke$b('FileSystem.readFile', uri) : invoke$b('ApplicationFileSystem.execute', applicationId, 'readFile', uri);
4217
4217
  };
4218
4218
 
4219
4219
  const notifyTabModifiedStatusChange = async (uri, modified, applicationId) => {
4220
4220
  try {
4221
- await invoke$9(applicationId, 'Main.handleModifiedStatusChange', uri, modified);
4221
+ await invoke$a(applicationId, 'Main.handleModifiedStatusChange', uri, modified);
4222
4222
  } catch {
4223
4223
  // ignore
4224
4224
  }
@@ -4320,7 +4320,7 @@ const transformDiagnostics = (diagnostics, changes) => {
4320
4320
  });
4321
4321
  };
4322
4322
 
4323
- const queues = {};
4323
+ const queues$1 = {};
4324
4324
  const enqueue = async (uid, callback) => {
4325
4325
  const instance = get$8(uid);
4326
4326
  if (!instance) {
@@ -4331,12 +4331,12 @@ const enqueue = async (uid, callback) => {
4331
4331
  uri
4332
4332
  } = instance.newState;
4333
4333
  const key = JSON.stringify([applicationId ?? null, uri || uid]);
4334
- const previous = queues[key];
4334
+ const previous = queues$1[key];
4335
4335
  const {
4336
4336
  promise,
4337
4337
  resolve
4338
4338
  } = Promise.withResolvers();
4339
- queues[key] = promise;
4339
+ queues$1[key] = promise;
4340
4340
  if (previous) {
4341
4341
  await previous;
4342
4342
  }
@@ -4344,15 +4344,15 @@ const enqueue = async (uid, callback) => {
4344
4344
  return await callback();
4345
4345
  } finally {
4346
4346
  resolve();
4347
- if (queues[key] === promise) {
4348
- delete queues[key];
4347
+ if (queues$1[key] === promise) {
4348
+ delete queues$1[key];
4349
4349
  }
4350
4350
  }
4351
4351
  };
4352
4352
 
4353
4353
  const logError = async (error, prefix) => {
4354
- const prettyError = await invoke$h('Errors.prepare', error);
4355
- await invoke$h('Errors.print', prettyError, prefix);
4354
+ const prettyError = await invoke$i('Errors.prepare', error);
4355
+ await invoke$i('Errors.print', prettyError, prefix);
4356
4356
  };
4357
4357
  const logFallback = (error, prefix) => {
4358
4358
  if (prefix) {
@@ -4370,8 +4370,8 @@ const handleError$1 = async (error, prefix = '') => {
4370
4370
  }
4371
4371
  };
4372
4372
 
4373
- const invoke$8 = async (applicationId, method, ...args) => {
4374
- return applicationId === undefined ? invoke$g(method, ...args) : invoke$g('Extensions.invokeForApplication', applicationId, method, ...args);
4373
+ const invoke$9 = async (applicationId, method, ...args) => {
4374
+ return applicationId === undefined ? invoke$h(method, ...args) : invoke$h('Extensions.invokeForApplication', applicationId, method, ...args);
4375
4375
  };
4376
4376
  const invokeAndTransfer = async (applicationId, method, ...args) => {
4377
4377
  return applicationId === undefined ? invokeAndTransfer$2(method, ...args) : invokeAndTransfer$2('Extensions.invokeForApplication', applicationId, method, ...args);
@@ -4472,7 +4472,7 @@ const getVisibleDiagnostics = async (editor, diagnostics) => {
4472
4472
  return visibleDiagnostics;
4473
4473
  };
4474
4474
 
4475
- const invoke$7 = (...args) => invoke$d(...args);
4475
+ const invoke$8 = (...args) => invoke$e(...args);
4476
4476
 
4477
4477
  /**
4478
4478
  * Merges link decorations with diagnostic decorations
@@ -4532,7 +4532,7 @@ const handleError = async (error, editor) => {
4532
4532
  };
4533
4533
  const notifyDiagnosticsChange = async (uri, applicationId) => {
4534
4534
  try {
4535
- await invoke$9(applicationId, 'Layout.handleDiagnosticsChange', uri);
4535
+ await invoke$a(applicationId, 'Layout.handleDiagnosticsChange', uri);
4536
4536
  } catch {
4537
4537
  // Older renderer workers do not support diagnostics change listeners.
4538
4538
  }
@@ -4583,10 +4583,10 @@ const commitDiagnostics = async (editor, generation, diagnostics, onAccepted) =>
4583
4583
  return latest.newState;
4584
4584
  }
4585
4585
  const newEditor = mergeDiagnostics(latest.newState, editorWithDiagnostics);
4586
- set$a(editor.id, latest.oldState, newEditor);
4586
+ set$b(editor.id, latest.oldState, newEditor);
4587
4587
  requestDiagnosticSnapshots.set(editor.id, diagnostics);
4588
4588
  onAccepted?.();
4589
- await invoke$7('Editor.renderPending', newEditor.id);
4589
+ await invoke$8('Editor.renderPending', newEditor.id);
4590
4590
  await notifyDiagnosticsChange(newEditor.uri, newEditor.applicationId);
4591
4591
  return newEditor;
4592
4592
  })) ?? editor;
@@ -5230,7 +5230,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
5230
5230
  ...newEditor,
5231
5231
  decorations: linkDecorations
5232
5232
  };
5233
- set$a(editor.uid, editor, newEditorWithDecorations);
5233
+ set$b(editor.uid, editor, newEditorWithDecorations);
5234
5234
 
5235
5235
  // Notify main-area-worker about modified status change
5236
5236
  if (!editor.modified) {
@@ -5500,7 +5500,7 @@ const execute = async ({
5500
5500
  return noProviderFoundResult;
5501
5501
  }
5502
5502
  const textDocument = getTextDocument$2(editor);
5503
- const result = await invoke$8(editor.applicationId, 'Extensions.executeLanguageProvider', kind, method, textDocument, ...args);
5503
+ const result = await invoke$9(editor.applicationId, 'Extensions.executeLanguageProvider', kind, method, textDocument, ...args);
5504
5504
  if (!result.found) {
5505
5505
  return noProviderFoundResult;
5506
5506
  }
@@ -5556,7 +5556,7 @@ const getEditorGutterDecorations = async editor => {
5556
5556
  uri: editor.uri
5557
5557
  };
5558
5558
  try {
5559
- const results = await invoke$8(editor.applicationId, 'Extensions.executeProvidersByEvent', 'onEditorGutterDecoration', 'ExtensionApi.executeEditorGutterDecorationProvider', textDocument);
5559
+ const results = await invoke$9(editor.applicationId, 'Extensions.executeProvidersByEvent', 'onEditorGutterDecoration', 'ExtensionApi.executeEditorGutterDecorationProvider', textDocument);
5560
5560
  return getProviderDecorations$1(results);
5561
5561
  } catch {
5562
5562
  return [];
@@ -5592,7 +5592,7 @@ const getEditorTextDecorations = async editor => {
5592
5592
  });
5593
5593
  }
5594
5594
  try {
5595
- const results = await invoke$8(editor.applicationId, 'Extensions.executeProvidersByEvent', 'onEditorTextDecoration', 'ExtensionApi.executeEditorTextDecorationProvider', {
5595
+ const results = await invoke$9(editor.applicationId, 'Extensions.executeProvidersByEvent', 'onEditorTextDecoration', 'ExtensionApi.executeEditorTextDecorationProvider', {
5596
5596
  languageId: editor.languageId,
5597
5597
  selections,
5598
5598
  text: getText$1(editor),
@@ -5667,7 +5667,7 @@ const getLightBulbRowIndex = async editor => {
5667
5667
  };
5668
5668
  const offset = getOffsetAtCursor$1(editor);
5669
5669
  try {
5670
- const actions = await invoke$8(editor.applicationId, 'Extensions.executeCodeActionProviders', textDocument, offset);
5670
+ const actions = await invoke$9(editor.applicationId, 'Extensions.executeCodeActionProviders', textDocument, offset);
5671
5671
  return Array.isArray(actions) && actions.length > 0 ? rowIndex : -1;
5672
5672
  } catch {
5673
5673
  return -1;
@@ -6288,7 +6288,7 @@ const updateColorPickerValue = async (editorUid, value) => {
6288
6288
  return;
6289
6289
  }
6290
6290
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
6291
- set$a(editorUid, editor, newEditorWithDerivedState);
6291
+ set$b(editorUid, editor, newEditorWithDerivedState);
6292
6292
  };
6293
6293
 
6294
6294
  const getColorPickerWorkerCommandMap = () => ({
@@ -6323,14 +6323,14 @@ const launchColorPickerWorker = async () => {
6323
6323
  return launchWorker(name, url, undefined, getColorPickerWorkerCommandMap());
6324
6324
  };
6325
6325
 
6326
- const state$8 = {};
6326
+ const state$9 = {};
6327
6327
  const getOrCreate$2 = () => {
6328
- if (!state$8.workerPromise) {
6329
- state$8.workerPromise = launchColorPickerWorker();
6328
+ if (!state$9.workerPromise) {
6329
+ state$9.workerPromise = launchColorPickerWorker();
6330
6330
  }
6331
- return state$8.workerPromise;
6331
+ return state$9.workerPromise;
6332
6332
  };
6333
- const invoke$6 = async (method, ...params) => {
6333
+ const invoke$7 = async (method, ...params) => {
6334
6334
  const worker = await getOrCreate$2();
6335
6335
  return await worker.invoke(method, ...params);
6336
6336
  };
@@ -6344,10 +6344,10 @@ const loadContent$3 = async (state, parentUid) => {
6344
6344
  x,
6345
6345
  y
6346
6346
  } = state;
6347
- await invoke$6('ColorPicker.create', uid, x, y, width, height, parentUid);
6348
- await invoke$6('ColorPicker.loadContent', uid, toColorPickerValue(value));
6349
- const diff = await invoke$6('ColorPicker.diff2', uid);
6350
- const commands = await invoke$6('ColorPicker.render2', uid, diff);
6347
+ await invoke$7('ColorPicker.create', uid, x, y, width, height, parentUid);
6348
+ await invoke$7('ColorPicker.loadContent', uid, toColorPickerValue(value));
6349
+ const diff = await invoke$7('ColorPicker.diff2', uid);
6350
+ const commands = await invoke$7('ColorPicker.render2', uid, diff);
6351
6351
  return {
6352
6352
  ...state,
6353
6353
  commands
@@ -6500,7 +6500,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir, _langua
6500
6500
  x,
6501
6501
  y
6502
6502
  };
6503
- set$a(id, editor, editor);
6503
+ set$b(id, editor, editor);
6504
6504
  };
6505
6505
 
6506
6506
  const emptyEditor = {
@@ -6656,11 +6656,11 @@ const applyLineEndings = (content, endOfLine) => {
6656
6656
  };
6657
6657
 
6658
6658
  const get$3 = async (key, applicationId) => {
6659
- const value = applicationId === undefined ? await getPreference$1(key) : await invoke$9(applicationId, 'Preferences.get', key);
6659
+ const value = applicationId === undefined ? await getPreference$1(key) : await invoke$a(applicationId, 'Preferences.get', key);
6660
6660
  return value;
6661
6661
  };
6662
6662
  const update = async settings => {
6663
- await invoke$d('Preferences.update', settings);
6663
+ await invoke$e('Preferences.update', settings);
6664
6664
  };
6665
6665
 
6666
6666
  const createEditor = async ({
@@ -6843,10 +6843,10 @@ const createEditor = async ({
6843
6843
  focused: true,
6844
6844
  textInfos
6845
6845
  };
6846
- set$a(id, emptyEditor, newEditor4);
6846
+ set$b(id, emptyEditor, newEditor4);
6847
6847
  const completionsOnTypeRaw = await get$3('editor.completionsOnType');
6848
6848
  const completionsOnType = Boolean(completionsOnTypeRaw);
6849
- set$a(id, emptyEditor, {
6849
+ set$b(id, emptyEditor, {
6850
6850
  ...newEditor4,
6851
6851
  completionsOnType
6852
6852
  });
@@ -6877,7 +6877,7 @@ const createStandaloneEditor = async ({
6877
6877
  const createdEditor = get$8(id).newState;
6878
6878
  await loadTokenizer(languageId, tokenizePath);
6879
6879
  const tokenizerId = createdEditor.tokenizerId + 1;
6880
- set$5(tokenizerId, getTokenizer(languageId));
6880
+ set$6(tokenizerId, getTokenizer(languageId));
6881
6881
  const configuredEditor = {
6882
6882
  ...createdEditor,
6883
6883
  charWidth,
@@ -6922,7 +6922,7 @@ const createStandaloneEditor = async ({
6922
6922
  selectionInfos
6923
6923
  };
6924
6924
  if (!createdEditor.lifecycle?.disposed) {
6925
- set$a(id, createdEditor, finalEditor);
6925
+ set$b(id, createdEditor, finalEditor);
6926
6926
  }
6927
6927
  };
6928
6928
 
@@ -6999,7 +6999,7 @@ const diff2 = uid => {
6999
6999
 
7000
7000
  const autoSaveDelay = 1000;
7001
7001
  const pendingSaves = new Map();
7002
- const state$7 = {
7002
+ const state$8 = {
7003
7003
  nextToken: 0
7004
7004
  };
7005
7005
  const run = async (uid, token, save) => {
@@ -7010,7 +7010,7 @@ const run = async (uid, token, save) => {
7010
7010
  };
7011
7011
  const schedule$1 = (uid, save) => {
7012
7012
  dispose$4(uid);
7013
- const token = ++state$7.nextToken;
7013
+ const token = ++state$8.nextToken;
7014
7014
  const timeout = setTimeout(run, autoSaveDelay, uid, token, save);
7015
7015
  pendingSaves.set(uid, {
7016
7016
  timeout,
@@ -7043,12 +7043,12 @@ const clear$3 = editorUid => {
7043
7043
  dismissals$1.delete(editorUid);
7044
7044
  }
7045
7045
  };
7046
- const set$4 = (editorUid, dismissal) => {
7046
+ const set$5 = (editorUid, dismissal) => {
7047
7047
  clear$3(editorUid);
7048
7048
  dismissals$1.set(editorUid, dismissal);
7049
7049
  };
7050
7050
 
7051
- const state$6 = {
7051
+ const state$7 = {
7052
7052
  editor: undefined,
7053
7053
  timeout: -1,
7054
7054
  token: 0,
@@ -7056,29 +7056,29 @@ const state$6 = {
7056
7056
  y: 0
7057
7057
  };
7058
7058
  const get$2 = () => {
7059
- return state$6;
7059
+ return state$7;
7060
7060
  };
7061
- const set$3 = (editor, timeout, x, y, token) => {
7062
- state$6.editor = editor;
7063
- state$6.timeout = timeout;
7064
- state$6.token = token;
7065
- state$6.x = x;
7066
- state$6.y = y;
7061
+ const set$4 = (editor, timeout, x, y, token) => {
7062
+ state$7.editor = editor;
7063
+ state$7.timeout = timeout;
7064
+ state$7.token = token;
7065
+ state$7.x = x;
7066
+ state$7.y = y;
7067
7067
  };
7068
7068
  const clear$2 = editorUid => {
7069
7069
  const {
7070
7070
  editor,
7071
7071
  timeout
7072
- } = state$6;
7072
+ } = state$7;
7073
7073
  if (editorUid !== undefined && editor?.uid !== editorUid) {
7074
7074
  return;
7075
7075
  }
7076
7076
  if (timeout !== -1) {
7077
7077
  clearTimeout(timeout);
7078
7078
  }
7079
- state$6.editor = undefined;
7080
- state$6.timeout = -1;
7081
- state$6.token++;
7079
+ state$7.editor = undefined;
7080
+ state$7.timeout = -1;
7081
+ state$7.token++;
7082
7082
  };
7083
7083
 
7084
7084
  const dismissals = new Map();
@@ -7090,7 +7090,7 @@ const clear$1 = editorUid => {
7090
7090
  clearTimeout(dismissal.timeout);
7091
7091
  dismissals.delete(editorUid);
7092
7092
  };
7093
- const set$2 = (editorUid, dismissal) => {
7093
+ const set$3 = (editorUid, dismissal) => {
7094
7094
  clear$1(editorUid);
7095
7095
  dismissals.set(editorUid, dismissal);
7096
7096
  };
@@ -7170,7 +7170,7 @@ const launchRenameWorker = async () => {
7170
7170
  };
7171
7171
 
7172
7172
  let workerPromise;
7173
- const invoke$5 = async (method, ...params) => {
7173
+ const invoke$6 = async (method, ...params) => {
7174
7174
  // eslint-disable-next-line unicorn/no-top-level-assignment-in-function
7175
7175
  workerPromise ||= launchRenameWorker();
7176
7176
  const worker = await workerPromise;
@@ -7194,7 +7194,7 @@ const textAppendPaths = new Map();
7194
7194
  const get$1 = uid => {
7195
7195
  return renderedDoms.get(uid);
7196
7196
  };
7197
- const set$1 = (uid, dom, paths) => {
7197
+ const set$2 = (uid, dom, paths) => {
7198
7198
  renderedDoms.set(uid, dom);
7199
7199
  setTextAppendPaths(uid, paths);
7200
7200
  };
@@ -7302,7 +7302,7 @@ const disposeEditor = async editorUid => {
7302
7302
  clearDiagnosticRequestState(editorUid);
7303
7303
  dispose$6(editorUid);
7304
7304
  try {
7305
- await invoke$9(editor.applicationId, 'Layout.handleDiagnosticsChange', editor.uri);
7305
+ await invoke$a(editor.applicationId, 'Layout.handleDiagnosticsChange', editor.uri);
7306
7306
  } catch {
7307
7307
  // Older renderer workers do not support diagnostics change listeners.
7308
7308
  }
@@ -7314,11 +7314,11 @@ const disposeEditor = async editorUid => {
7314
7314
  dispose$1(editorUid);
7315
7315
  const pending = [];
7316
7316
  if (getEnabled$1()) {
7317
- pending.push(invoke$b('TextDocument.dispose', editor.id));
7317
+ pending.push(invoke$c('TextDocument.dispose', editor.id));
7318
7318
  }
7319
7319
  for (const widget of editor.widgets) {
7320
7320
  if (widget.id === ColorPicker$2) {
7321
- pending.push(invoke$6('ColorPicker.dispose', widget.newState.uid));
7321
+ pending.push(invoke$7('ColorPicker.dispose', widget.newState.uid));
7322
7322
  }
7323
7323
  }
7324
7324
  const commands = renderWidgets$1(editor, {
@@ -7373,6 +7373,29 @@ const hasWidget = (widgets, id) => {
7373
7373
  return false;
7374
7374
  };
7375
7375
 
7376
+ const getWidgetIndex = (widgets, widgetId, uid) => {
7377
+ return widgets.findIndex(widget => widget.id === widgetId && widget.newState.uid === uid);
7378
+ };
7379
+ const hydrateWidget = (editor, widgetId, uid, newState) => {
7380
+ const widgetIndex = getWidgetIndex(editor.widgets, widgetId, uid);
7381
+ if (widgetIndex === -1) {
7382
+ return editor;
7383
+ }
7384
+ const widget = editor.widgets[widgetIndex];
7385
+ const newWidget = {
7386
+ ...widget,
7387
+ newState,
7388
+ oldState: widget.newState
7389
+ };
7390
+ return {
7391
+ ...editor,
7392
+ widgets: [...editor.widgets.slice(0, widgetIndex), newWidget, ...editor.widgets.slice(widgetIndex + 1)]
7393
+ };
7394
+ };
7395
+ const getLatestEditor = (uid, fallback) => {
7396
+ const instance = get$8(uid);
7397
+ return instance?.newState || fallback;
7398
+ };
7376
7399
  const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGenerator, fullFocus) => {
7377
7400
  const {
7378
7401
  widgets = []
@@ -7382,35 +7405,75 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
7382
7405
  }
7383
7406
  const widgetRevision = next(editor.uid);
7384
7407
  const widget = factory();
7385
- // @ts-ignore
7386
- widget.newState.editorUid = editor.uid;
7387
- const newState = await newStateGenerator(widget.newState, editor.uid);
7408
+ const initialState = {
7409
+ ...widget.newState,
7410
+ editorUid: editor.uid
7411
+ };
7412
+ const widgetUid = initialState.uid;
7413
+ const stagedWidget = {
7414
+ ...widget,
7415
+ newState: initialState
7416
+ };
7417
+ const newWidgets = [...widgets, stagedWidget];
7418
+ const stagedEditor = {
7419
+ ...editor,
7420
+ additionalFocus: fullFocus ? 0 : focusKey,
7421
+ focus: fullFocus ? focusKey : FocusEditorText$1,
7422
+ focused: !fullFocus,
7423
+ widgetRevision,
7424
+ widgets: newWidgets
7425
+ };
7426
+ if (fullFocus) {
7427
+ // Staging changes pending state; only rendering may advance the mounted baseline.
7428
+ set$b(editor.uid, get$8(editor.uid)?.oldState || editor, stagedEditor);
7429
+ }
7430
+ const newState = await newStateGenerator(initialState, editor.uid);
7388
7431
  if (!newState) {
7432
+ if (get(editor.uid) !== widgetRevision) {
7433
+ return getLatestEditor(editor.uid, editor);
7434
+ }
7435
+ if (fullFocus) {
7436
+ const latestEditor = getLatestEditor(editor.uid, stagedEditor);
7437
+ if (latestEditor === stagedEditor) {
7438
+ set$b(editor.uid, get$8(editor.uid)?.oldState || editor, editor);
7439
+ }
7440
+ return latestEditor === stagedEditor ? editor : latestEditor;
7441
+ }
7389
7442
  return editor;
7390
7443
  }
7444
+ const latestState = {
7445
+ ...newState,
7446
+ editorUid: editor.uid
7447
+ };
7448
+ if (fullFocus) {
7449
+ const currentEditor = getLatestEditor(editor.uid, stagedEditor);
7450
+ // A concurrent editor update based on the pre-staging state can replace the
7451
+ // staged widget list. Restore it only when the original widget list is still
7452
+ // current; a changed list may represent an explicit close.
7453
+ const latestEditor = currentEditor.widgets === editor.widgets ? {
7454
+ ...currentEditor,
7455
+ widgets: newWidgets
7456
+ } : currentEditor;
7457
+ const hydratedEditor = hydrateWidget(latestEditor, widgetId, widgetUid, latestState);
7458
+ if (hydratedEditor !== latestEditor) {
7459
+ set$b(editor.uid, get$8(editor.uid)?.oldState || editor, hydratedEditor);
7460
+ }
7461
+ return hydratedEditor;
7462
+ }
7391
7463
  if (get(editor.uid) !== widgetRevision) {
7392
- return get$8(editor.uid)?.newState || editor;
7464
+ return getLatestEditor(editor.uid, editor);
7393
7465
  }
7394
- // @ts-ignore
7395
- newState.editorUid = editor.uid;
7396
7466
  const latestWidget = {
7397
7467
  ...widget,
7398
- newState
7468
+ newState: latestState
7399
7469
  };
7400
- const newWidgets = [...widgets, latestWidget];
7401
- const newFocus = !fullFocus;
7402
- const newEditor = {
7403
- ...editor,
7404
- additionalFocus: fullFocus ? 0 : focusKey,
7405
- focus: fullFocus ? focusKey : FocusEditorText$1,
7406
- focused: newFocus,
7407
- widgetRevision,
7408
- widgets: newWidgets
7470
+ return {
7471
+ ...stagedEditor,
7472
+ widgets: [...widgets, latestWidget]
7409
7473
  };
7410
- return newEditor;
7411
7474
  };
7412
7475
 
7413
- const state$5 = {
7476
+ const state$6 = {
7414
7477
  configured: false,
7415
7478
  lastId: -1,
7416
7479
  nextId: 0
@@ -7418,23 +7481,23 @@ const state$5 = {
7418
7481
  const configure = (start, end) => {
7419
7482
  const {
7420
7483
  configured
7421
- } = state$5;
7484
+ } = state$6;
7422
7485
  if (configured) {
7423
7486
  throw new Error('Component id range is already configured');
7424
7487
  }
7425
7488
  if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start <= 0 || end < start) {
7426
7489
  throw new Error('Invalid component id range');
7427
7490
  }
7428
- state$5.nextId = start;
7429
- state$5.lastId = end;
7430
- state$5.configured = true;
7491
+ state$6.nextId = start;
7492
+ state$6.lastId = end;
7493
+ state$6.configured = true;
7431
7494
  };
7432
7495
  const create$8 = () => {
7433
7496
  const {
7434
7497
  configured,
7435
7498
  lastId,
7436
7499
  nextId
7437
- } = state$5;
7500
+ } = state$6;
7438
7501
  if (!configured) {
7439
7502
  // Compatibility with renderer versions that do not assign worker id ranges.
7440
7503
  return Math.random();
@@ -7442,7 +7505,7 @@ const create$8 = () => {
7442
7505
  if (nextId > lastId) {
7443
7506
  throw new Error('Component id range exhausted');
7444
7507
  }
7445
- return state$5.nextId++;
7508
+ return state$6.nextId++;
7446
7509
  };
7447
7510
 
7448
7511
  const create$7 = () => {
@@ -7470,7 +7533,7 @@ const create$7 = () => {
7470
7533
  };
7471
7534
 
7472
7535
  const {
7473
- invoke: invoke$4,
7536
+ invoke: invoke$5,
7474
7537
  setFactory
7475
7538
  } = createLazyRpc(CompletionWorker);
7476
7539
 
@@ -7536,7 +7599,7 @@ const updateWidget = (editor, widgetId, newState) => {
7536
7599
 
7537
7600
  const disposeCompletion = async uid => {
7538
7601
  try {
7539
- await invoke$4('Completions.dispose', uid);
7602
+ await invoke$5('Completions.dispose', uid);
7540
7603
  } catch {
7541
7604
  // A completion worker may already have disposed this state during shutdown.
7542
7605
  }
@@ -7556,14 +7619,14 @@ const newStateGenerator$4 = async (state, parentUid, markCreated, automatic) =>
7556
7619
  applicationId,
7557
7620
  languageId
7558
7621
  } = newState;
7559
- await invoke$4('Completions.create', uid, x, y, width, height, parentUid, languageId, applicationId);
7622
+ await invoke$5('Completions.create', uid, x, y, width, height, parentUid, languageId, applicationId);
7560
7623
  markCreated();
7561
- await invoke$4('Completions.loadContent', uid, automatic);
7562
- if (automatic && !(await invoke$4('Completions.hasItems', uid))) {
7624
+ await invoke$5('Completions.loadContent', uid, automatic);
7625
+ if (automatic && !(await invoke$5('Completions.hasItems', uid))) {
7563
7626
  return undefined;
7564
7627
  }
7565
- const diff = await invoke$4('Completions.diff2', uid);
7566
- const commands = await invoke$4('Completions.render2', uid, diff);
7628
+ const diff = await invoke$5('Completions.diff2', uid);
7629
+ const commands = await invoke$5('Completions.render2', uid, diff);
7567
7630
  return {
7568
7631
  ...state,
7569
7632
  automatic,
@@ -7576,15 +7639,15 @@ const openCompletion = async (editor, automatic = false) => {
7576
7639
  const {
7577
7640
  uid
7578
7641
  } = widget.newState;
7579
- await invoke$4('Completions.loadContent', uid, automatic);
7642
+ await invoke$5('Completions.loadContent', uid, automatic);
7580
7643
  if (!isCurrent$1(editor, get$8(editor.uid)?.newState)) {
7581
7644
  return get$8(editor.uid)?.newState || editor;
7582
7645
  }
7583
- if (automatic && !(await invoke$4('Completions.hasItems', uid))) {
7646
+ if (automatic && !(await invoke$5('Completions.hasItems', uid))) {
7584
7647
  return closeCompletion(editor);
7585
7648
  }
7586
- const diff = await invoke$4('Completions.diff2', uid);
7587
- const commands = await invoke$4('Completions.render2', uid, diff);
7649
+ const diff = await invoke$5('Completions.diff2', uid);
7650
+ const commands = await invoke$5('Completions.render2', uid, diff);
7588
7651
  return updateWidget(editor, Completion, {
7589
7652
  ...widget.newState,
7590
7653
  automatic,
@@ -8257,7 +8320,7 @@ const getFormattingEdits = async editor => {
8257
8320
  text: getText$1(editor),
8258
8321
  uri: editor.uri
8259
8322
  };
8260
- return invoke$8(editor.applicationId, 'Extensions.executeFormattingProvider', textDocument);
8323
+ return invoke$9(editor.applicationId, 'Extensions.executeFormattingProvider', textDocument);
8261
8324
  };
8262
8325
 
8263
8326
  const expectedErrorMessage$1 = 'Failed to execute formatting provider: FormattingError:';
@@ -8499,10 +8562,10 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, _isErro
8499
8562
  widgetRevision: next(editor.uid),
8500
8563
  widgets: removeEditorWidget(latestEditor.widgets, Message)
8501
8564
  };
8502
- set$a(editor.uid, latestEditor, editorWithoutMessage);
8503
- await invoke$d('Editor.renderPending', editor.uid);
8565
+ set$b(editor.uid, latestEditor, editorWithoutMessage);
8566
+ await invoke$e('Editor.renderPending', editor.uid);
8504
8567
  }, editor.messageDelay ?? defaultMessageDelay);
8505
- set$2(editor.uid, {
8568
+ set$3(editor.uid, {
8506
8569
  timeout
8507
8570
  });
8508
8571
  }
@@ -8553,7 +8616,7 @@ const getNewEditor = async (editor, skipFormatting = false) => {
8553
8616
  };
8554
8617
 
8555
8618
  const isReadonlyFile = async (uri, applicationId) => {
8556
- return invoke$9(applicationId, 'FileSystem.isReadonly', uri);
8619
+ return invoke$a(applicationId, 'FileSystem.isReadonly', uri);
8557
8620
  };
8558
8621
 
8559
8622
  const isUntitledFile = uri => {
@@ -8561,7 +8624,7 @@ const isUntitledFile = uri => {
8561
8624
  };
8562
8625
 
8563
8626
  const saveNormalFile = async (uri, content, applicationId) => {
8564
- await invoke$9(applicationId, 'FileSystem.writeFile', uri, content, 'utf8', false);
8627
+ await invoke$a(applicationId, 'FileSystem.writeFile', uri, content, 'utf8', false);
8565
8628
  };
8566
8629
 
8567
8630
  const showFilePicker = async platform => {
@@ -8569,7 +8632,7 @@ const showFilePicker = async platform => {
8569
8632
  const {
8570
8633
  canceled,
8571
8634
  filePath
8572
- } = await invoke$f('Open.showSaveDialog', dialogTitle, [], platform);
8635
+ } = await invoke$g('Open.showSaveDialog', dialogTitle, [], platform);
8573
8636
  if (canceled) {
8574
8637
  return '';
8575
8638
  }
@@ -8581,8 +8644,8 @@ const saveUntitledFile = async (uri, content, platform, applicationId) => {
8581
8644
  if (!filePath) {
8582
8645
  return;
8583
8646
  }
8584
- await invoke$9(applicationId, 'FileSystem.writeFile', filePath, content);
8585
- await invoke$9(applicationId, 'Layout.handleWorkspaceRefresh');
8647
+ await invoke$a(applicationId, 'FileSystem.writeFile', filePath, content);
8648
+ await invoke$a(applicationId, 'Layout.handleWorkspaceRefresh');
8586
8649
  return filePath;
8587
8650
  };
8588
8651
 
@@ -8592,7 +8655,7 @@ const isPermissionDeniedError = error => {
8592
8655
  };
8593
8656
  const showSaveErrorDialog = async error => {
8594
8657
  if (isPermissionDeniedError(error)) {
8595
- await invoke$j('ElectronDialog.showMessageBox', {
8658
+ await invoke$k('ElectronDialog.showMessageBox', {
8596
8659
  buttons: ['OK'],
8597
8660
  defaultId: 0,
8598
8661
  message: "You don't have permission to save changes to this file.",
@@ -8601,7 +8664,7 @@ const showSaveErrorDialog = async error => {
8601
8664
  });
8602
8665
  return;
8603
8666
  }
8604
- await invoke$j('ElectronDialog.showMessageBox', {
8667
+ await invoke$k('ElectronDialog.showMessageBox', {
8605
8668
  buttons: ['OK'],
8606
8669
  defaultId: 0,
8607
8670
  detail: error.message,
@@ -8693,11 +8756,11 @@ const refresh = async request => {
8693
8756
  if (!isCurrent(latest?.newState, snapshot)) {
8694
8757
  return false;
8695
8758
  }
8696
- set$a(snapshot.uid, latest.oldState, next);
8759
+ set$b(snapshot.uid, latest.oldState, next);
8697
8760
  return true;
8698
8761
  });
8699
8762
  if (changed) {
8700
- await invoke$d('Editor.renderPending', snapshot.uid);
8763
+ await invoke$e('Editor.renderPending', snapshot.uid);
8701
8764
  }
8702
8765
  }
8703
8766
  } catch (error) {
@@ -8768,7 +8831,7 @@ const saveAfterDelay = async (uid, token) => {
8768
8831
  });
8769
8832
  await save(uid);
8770
8833
  if (didSave) {
8771
- await invoke$d('Editor.renderPending', uid);
8834
+ await invoke$e('Editor.renderPending', uid);
8772
8835
  }
8773
8836
  };
8774
8837
 
@@ -8824,7 +8887,7 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
8824
8887
  // Another command can commit before the renderer consumes this edit.
8825
8888
  // Keep its last rendered baseline, including renders completed while we awaited derived state.
8826
8889
  const renderedState = get$8(uid)?.oldState ?? oldInstance.oldState;
8827
- set$a(uid, renderedState, newEditorWithDerivedState);
8890
+ set$b(uid, renderedState, newEditorWithDerivedState);
8828
8891
  await dispose$3();
8829
8892
  if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
8830
8893
  void editorDiagnosticEffect.apply(newEditorWithDerivedState);
@@ -8860,7 +8923,7 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
8860
8923
  if (!latest || editor.lifecycle?.disposed || latest.newState.lifecycle !== editor.lifecycle) {
8861
8924
  continue;
8862
8925
  }
8863
- set$a(otherUid, latest.oldState, synchronizedEditor);
8926
+ set$b(otherUid, latest.oldState, synchronizedEditor);
8864
8927
  if (deferGutterDecorations) {
8865
8928
  schedule(synchronizedEditor);
8866
8929
  }
@@ -8994,13 +9057,13 @@ const applyWorkspaceEdit = async (editor, changes) => {
8994
9057
  currentEditor = await scheduleDocumentAndCursorsSelections(openEditor, textChanges);
8995
9058
  } else {
8996
9059
  await updateOpenEditor(openEditor.uid, textChanges);
8997
- await invoke$7('Editor.renderPending', openEditor.uid);
9060
+ await invoke$8('Editor.renderPending', openEditor.uid);
8998
9061
  }
8999
9062
  continue;
9000
9063
  }
9001
9064
  const text = await readFile$1(editor.applicationId, uri);
9002
9065
  const newText = applyEditsToText(text, edits);
9003
- await invoke$9(editor.applicationId, 'FileSystem.writeFile', uri, newText);
9066
+ await invoke$a(editor.applicationId, 'FileSystem.writeFile', uri, newText);
9004
9067
  }
9005
9068
  return currentEditor;
9006
9069
  };
@@ -9477,7 +9540,7 @@ const closeRename = async editor => {
9477
9540
  return editor;
9478
9541
  }
9479
9542
  const renameWidget = widgets[renameWidgetIndex];
9480
- await invoke$5('Rename.close', renameWidget.newState.uid);
9543
+ await invoke$6('Rename.close', renameWidget.newState.uid);
9481
9544
  const latest = get$8(uid);
9482
9545
  const {
9483
9546
  newState
@@ -9597,12 +9660,12 @@ const closeColorPicker = editor => {
9597
9660
  };
9598
9661
  };
9599
9662
 
9600
- const state$4 = {
9663
+ const state$5 = {
9601
9664
  compositionText: '',
9602
9665
  isComposing: false
9603
9666
  };
9604
9667
  const compositionStart = (editor, event) => {
9605
- state$4.isComposing = true;
9668
+ state$5.isComposing = true;
9606
9669
  return editor;
9607
9670
  };
9608
9671
  const getCompositionChanges = (selections, data) => {
@@ -9612,9 +9675,9 @@ const getCompositionChanges = (selections, data) => {
9612
9675
  const selectionStartColumn = selections[i + 1];
9613
9676
  const selectionEndRow = selections[i + 2];
9614
9677
  const selectionEndColumn = selections[i + 3];
9615
- const startColumnIndex = selectionStartColumn - state$4.compositionText.length;
9678
+ const startColumnIndex = selectionStartColumn - state$5.compositionText.length;
9616
9679
  changes.push({
9617
- deleted: [state$4.compositionText],
9680
+ deleted: [state$5.compositionText],
9618
9681
  end: {
9619
9682
  columnIndex: selectionEndColumn,
9620
9683
  rowIndex: selectionEndRow
@@ -9634,7 +9697,7 @@ const compositionUpdate = (editor, data) => {
9634
9697
  selections
9635
9698
  } = editor;
9636
9699
  const changes = getCompositionChanges(selections, data);
9637
- state$4.compositionText = data;
9700
+ state$5.compositionText = data;
9638
9701
  return scheduleDocumentAndCursorsSelections(editor, changes);
9639
9702
  };
9640
9703
  const compositionEnd = (editor, data) => {
@@ -9642,8 +9705,8 @@ const compositionEnd = (editor, data) => {
9642
9705
  selections
9643
9706
  } = editor;
9644
9707
  const changes = getCompositionChanges(selections, data);
9645
- state$4.isComposing = false;
9646
- state$4.compositionText = '';
9708
+ state$5.isComposing = false;
9709
+ state$5.compositionText = '';
9647
9710
  return scheduleDocumentAndCursorsSelections(editor, changes);
9648
9711
  };
9649
9712
 
@@ -10617,7 +10680,7 @@ const deleteWordRight = editor => {
10617
10680
 
10618
10681
  const findAllReferences$1 = async editor => {
10619
10682
  // @ts-ignore
10620
- await invoke$d('SideBar.show', 'References', /* focus */true);
10683
+ await invoke$e('SideBar.show', 'References', /* focus */true);
10621
10684
  return editor;
10622
10685
  };
10623
10686
 
@@ -11215,7 +11278,7 @@ const getEditorLineDecorations = async (editor, rowIndex) => {
11215
11278
  uri: editor.uri
11216
11279
  };
11217
11280
  try {
11218
- const results = await invoke$8(editor.applicationId, 'Extensions.executeProvidersByEvent', 'onEditorLineDecoration', 'ExtensionApi.executeEditorLineDecorationProvider', textDocument, rowIndex);
11281
+ const results = await invoke$9(editor.applicationId, 'Extensions.executeProvidersByEvent', 'onEditorLineDecoration', 'ExtensionApi.executeEditorLineDecorationProvider', textDocument, rowIndex);
11219
11282
  return getProviderDecorations(results, rowIndex);
11220
11283
  } catch {
11221
11284
  return [];
@@ -11329,7 +11392,7 @@ const clear = editor => {
11329
11392
  decorations: filtered
11330
11393
  };
11331
11394
  };
11332
- const set = (editor, offset, length) => {
11395
+ const set$1 = (editor, offset, length) => {
11333
11396
  if (matches(editor, offset, length)) {
11334
11397
  return editor;
11335
11398
  }
@@ -11432,10 +11495,10 @@ const startTextDrag = async (state, x, y) => {
11432
11495
  }
11433
11496
  try {
11434
11497
  if (state.textDragId) {
11435
- await invoke$i('DragAndDrop.discardTextDrag', state.textDragId);
11498
+ await invoke$j('DragAndDrop.discardTextDrag', state.textDragId);
11436
11499
  }
11437
11500
  const text = getText$1(state).slice(startOffset, endOffset);
11438
- const textDragId = await invoke$i('DragAndDrop.createTextDrag', {
11501
+ const textDragId = await invoke$j('DragAndDrop.createTextDrag', {
11439
11502
  endOffset,
11440
11503
  sourceUri: state.uri,
11441
11504
  startOffset,
@@ -11521,10 +11584,10 @@ const handleMouseLeave = (viewletUid, editorUidValue) => {
11521
11584
  widgetRevision: next(editorUid),
11522
11585
  widgets: removeEditorWidget(latestEditor.widgets, Hover)
11523
11586
  };
11524
- set$a(editorUid, latestEditor, newEditor);
11525
- await invoke$d('Editor.renderPending', editorUid);
11587
+ set$b(editorUid, latestEditor, newEditor);
11588
+ await invoke$e('Editor.renderPending', editorUid);
11526
11589
  }, editorHoverDismissDelay);
11527
- set$4(editorUid, {
11590
+ set$5(editorUid, {
11528
11591
  timeout
11529
11592
  });
11530
11593
  };
@@ -11594,7 +11657,7 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
11594
11657
  if (!definition) {
11595
11658
  return clear(editor);
11596
11659
  }
11597
- return set(editor, wordOffset, wordLength);
11660
+ return set$1(editor, wordOffset, wordLength);
11598
11661
  } catch (error) {
11599
11662
  if (isNoDefinitionProviderFoundError(error)) {
11600
11663
  return clear(editor);
@@ -11618,7 +11681,7 @@ const getDiagnosticHoverDetail = ({
11618
11681
 
11619
11682
  const measureTextBlockHeight = async (text, fontFamily, fontSize, lineHeight, width) => {
11620
11683
  // @ts-ignore
11621
- return invoke$d('MeasureTextHeight.measureTextBlockHeight', text, fontFamily, fontSize, lineHeight, width);
11684
+ return invoke$e('MeasureTextHeight.measureTextBlockHeight', text, fontFamily, fontSize, lineHeight, width);
11622
11685
  };
11623
11686
 
11624
11687
  const maximumWidth = 600;
@@ -11696,7 +11759,7 @@ const getTextDocument$1 = editor => {
11696
11759
  };
11697
11760
  const executeIsolatedHoverProvider = async (editor, offset) => {
11698
11761
  const textDocument = getTextDocument$1(editor);
11699
- return invoke$8(editor.applicationId, 'Extensions.executeHoverProvider', textDocument, offset);
11762
+ return invoke$9(editor.applicationId, 'Extensions.executeHoverProvider', textDocument, offset);
11700
11763
  };
11701
11764
  const executeHoverProvider = async (editor, offset) => {
11702
11765
  object(editor);
@@ -11713,10 +11776,10 @@ const getHover = async (editor, offset) => {
11713
11776
  };
11714
11777
 
11715
11778
  const getVirtualDomFromMarkdown = async markdown => {
11716
- const html = await invoke$7('Markdown.renderMarkdown', markdown, {
11779
+ const html = await invoke$8('Markdown.renderMarkdown', markdown, {
11717
11780
  linksExternal: true
11718
11781
  });
11719
- return invoke$7('Markdown.getVirtualDom', html);
11782
+ return invoke$8('Markdown.getVirtualDom', html);
11720
11783
  };
11721
11784
 
11722
11785
  const getLineInfo = (line, tokens, TokenMap) => {
@@ -11931,8 +11994,8 @@ const showHover = async (editor, position, token) => {
11931
11994
  if (latestEditor === newEditor || !latestInstance || latestInstance.newState !== latestEditor || get$2().token !== token) {
11932
11995
  return;
11933
11996
  }
11934
- set$a(editor.uid, latestInstance.oldState, newEditor);
11935
- await invoke$d('Editor.renderPending', editor.uid);
11997
+ set$b(editor.uid, latestInstance.oldState, newEditor);
11998
+ await invoke$e('Editor.renderPending', editor.uid);
11936
11999
  };
11937
12000
 
11938
12001
  // TODO several things can happen:
@@ -11975,7 +12038,7 @@ const handleMouseMove = async (editor, x, y, altKey) => {
11975
12038
  }
11976
12039
  const token = create$8();
11977
12040
  const timeout = setTimeout(onHoverIdle, editorWithoutDefinitionLink.hoverDelay ?? 200, token);
11978
- set$3(editorWithoutDefinitionLink, timeout, x, y, token);
12041
+ set$4(editorWithoutDefinitionLink, timeout, x, y, token);
11979
12042
  return editorWithoutDefinitionLink;
11980
12043
  };
11981
12044
 
@@ -12024,7 +12087,7 @@ const editorHandleNativeSelectionChange = (editor, range) => {
12024
12087
  const handlePointerCaptureLost = async editor => {
12025
12088
  if (editor.textDragId) {
12026
12089
  try {
12027
- await invoke$i('DragAndDrop.discardTextDrag', editor.textDragId);
12090
+ await invoke$j('DragAndDrop.discardTextDrag', editor.textDragId);
12028
12091
  } catch {
12029
12092
  // The pointer state still needs to be reset if the worker is unavailable.
12030
12093
  }
@@ -12193,8 +12256,8 @@ const continueScrollingAndMovingSelection = async editorUid => {
12193
12256
  }
12194
12257
  return;
12195
12258
  }
12196
- set$a(editor.uid, editor, derivedEditor);
12197
- await invoke$d('Editor.renderPending', editor.uid);
12259
+ set$b(editor.uid, editor, derivedEditor);
12260
+ await invoke$e('Editor.renderPending', editor.uid);
12198
12261
  if (derivedEditor.hasListener) {
12199
12262
  requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
12200
12263
  }
@@ -12319,7 +12382,7 @@ const handlePointerUp = async editor => {
12319
12382
  return resetEditor;
12320
12383
  }
12321
12384
  try {
12322
- const data = await invoke$i('DragAndDrop.takeTextDrag', editor.textDragId);
12385
+ const data = await invoke$j('DragAndDrop.takeTextDrag', editor.textDragId);
12323
12386
  if (!data) {
12324
12387
  return resetEditor;
12325
12388
  }
@@ -12472,7 +12535,7 @@ const handleTouchEnd = (editor, touchEvent) => {
12472
12535
  // }
12473
12536
  };
12474
12537
 
12475
- const state$3 = {
12538
+ const state$4 = {
12476
12539
  deltaY: 0,
12477
12540
  touchOffsetY: 0
12478
12541
  };
@@ -12483,8 +12546,8 @@ const handleTouchStart = (editor, touchEvent) => {
12483
12546
  return;
12484
12547
  }
12485
12548
  const firstTouch = touchEvent.touches[0];
12486
- state$3.touchOffsetY = firstTouch.y;
12487
- state$3.deltaY = editor.deltaY;
12549
+ state$4.touchOffsetY = firstTouch.y;
12550
+ state$4.deltaY = editor.deltaY;
12488
12551
  // const position = EditorPosition.at(editor, firstTouch.x, firstTouch.y)
12489
12552
  // EditorMoveSelection.state.position = position
12490
12553
  // state.date = Date.now()
@@ -12524,7 +12587,7 @@ const handleTouchMove = (editor, touchEvent) => {
12524
12587
  return;
12525
12588
  }
12526
12589
  const firstTouch = touchEvent.touches[0];
12527
- const offsetY = state$3.deltaY + (state$3.touchOffsetY - firstTouch.y);
12590
+ const offsetY = state$4.deltaY + (state$4.touchOffsetY - firstTouch.y);
12528
12591
  setDeltaYFixedValue(editor, offsetY);
12529
12592
  };
12530
12593
 
@@ -12628,7 +12691,7 @@ const indentMore = editor => {
12628
12691
 
12629
12692
  const getLanguageConfiguration = async editor => {
12630
12693
  // @ts-ignore
12631
- return invoke$d('Languages.getLanguageConfiguration', {
12694
+ return invoke$e('Languages.getLanguageConfiguration', {
12632
12695
  languageId: editor.languageId,
12633
12696
  uri: editor.uri
12634
12697
  });
@@ -12881,14 +12944,14 @@ const addWidget = (widget, id, render) => {
12881
12944
  };
12882
12945
 
12883
12946
  const setFocus = async focusKey => {
12884
- await invoke$d('Focus.setFocus', focusKey);
12947
+ await invoke$e('Focus.setFocus', focusKey);
12885
12948
  };
12886
12949
  const unsetAdditionalFocus = async focusKey => {
12887
12950
  if (!focusKey) {
12888
12951
  return;
12889
12952
  }
12890
12953
  // @ts-ignore
12891
- await invoke$d('Focus.removeAdditionalFocus', focusKey);
12954
+ await invoke$e('Focus.removeAdditionalFocus', focusKey);
12892
12955
  };
12893
12956
 
12894
12957
  const FocusEditor = 12;
@@ -12906,7 +12969,7 @@ const updateEditor = async (editorUid, editor, newEditor) => {
12906
12969
  return;
12907
12970
  }
12908
12971
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
12909
- set$a(editorUid, editor, newEditorWithDerivedState);
12972
+ set$b(editorUid, editor, newEditorWithDerivedState);
12910
12973
  };
12911
12974
  const applyDocumentEdits = async (editorUid, edits) => {
12912
12975
  const editor = getEditor$1(editorUid);
@@ -12956,9 +13019,9 @@ const launch = async () => {
12956
13019
  return;
12957
13020
  }
12958
13021
  const rpc = await launchFindWidgetWorker();
12959
- set$j(rpcId, rpc);
13022
+ set$k(rpcId, rpc);
12960
13023
  };
12961
- const invoke$3 = async (method, ...params) => {
13024
+ const invoke$4 = async (method, ...params) => {
12962
13025
  const rpc = get$9(rpcId);
12963
13026
  return await rpc.invoke(method, ...params);
12964
13027
  };
@@ -12982,14 +13045,14 @@ const launchHoverWorker = async () => {
12982
13045
  return rpc;
12983
13046
  };
12984
13047
 
12985
- const state$2 = {};
13048
+ const state$3 = {};
12986
13049
  const getOrCreate$1 = () => {
12987
- if (!state$2.workerPromise) {
12988
- state$2.workerPromise = launchHoverWorker();
13050
+ if (!state$3.workerPromise) {
13051
+ state$3.workerPromise = launchHoverWorker();
12989
13052
  }
12990
- return state$2.workerPromise;
13053
+ return state$3.workerPromise;
12991
13054
  };
12992
- const invoke$2 = async (method, ...params) => {
13055
+ const invoke$3 = async (method, ...params) => {
12993
13056
  const worker = await getOrCreate$1();
12994
13057
  return await worker.invoke(method, ...params);
12995
13058
  };
@@ -13002,14 +13065,14 @@ const launchSourceActionWorker = async () => {
13002
13065
  return rpc;
13003
13066
  };
13004
13067
 
13005
- const state$1 = {};
13068
+ const state$2 = {};
13006
13069
  const getOrCreate = () => {
13007
- if (!state$1.workerPromise) {
13008
- state$1.workerPromise = launchSourceActionWorker();
13070
+ if (!state$2.workerPromise) {
13071
+ state$2.workerPromise = launchSourceActionWorker();
13009
13072
  }
13010
- return state$1.workerPromise;
13073
+ return state$2.workerPromise;
13011
13074
  };
13012
- const invoke$1 = async (method, ...params) => {
13075
+ const invoke$2 = async (method, ...params) => {
13013
13076
  const worker = await getOrCreate();
13014
13077
  return await worker.invoke(method, ...params);
13015
13078
  };
@@ -13017,17 +13080,17 @@ const invoke$1 = async (method, ...params) => {
13017
13080
  const getWidgetInvoke = widgetId => {
13018
13081
  switch (widgetId) {
13019
13082
  case ColorPicker$2:
13020
- return invoke$6;
13083
+ return invoke$7;
13021
13084
  case Completion:
13022
- return invoke$4;
13085
+ return invoke$5;
13023
13086
  case Find:
13024
- return invoke$3;
13087
+ return invoke$4;
13025
13088
  case Hover:
13026
- return invoke$2;
13089
+ return invoke$3;
13027
13090
  case Rename$1:
13028
- return invoke$5;
13091
+ return invoke$6;
13029
13092
  case SourceAction$1:
13030
- return invoke$1;
13093
+ return invoke$2;
13031
13094
  default:
13032
13095
  return undefined;
13033
13096
  }
@@ -13087,7 +13150,7 @@ const createFn = (key, name, widgetId) => {
13087
13150
  const latestAfterInvoke = get$8(editor.uid).newState;
13088
13151
  const latestChildIndex = latestAfterInvoke.widgets.findIndex(isWidget);
13089
13152
  if (latestChildIndex === -1) {
13090
- set$a(editor.uid, editor, latestAfterInvoke);
13153
+ set$b(editor.uid, editor, latestAfterInvoke);
13091
13154
  await dispose$3();
13092
13155
  return latestAfterInvoke;
13093
13156
  }
@@ -13101,7 +13164,7 @@ const createFn = (key, name, widgetId) => {
13101
13164
  widgetRevision,
13102
13165
  widgets: removeEditorWidget(latest.widgets, widgetId)
13103
13166
  };
13104
- set$a(editor.uid, latest, newEditor);
13167
+ set$b(editor.uid, latest, newEditor);
13105
13168
  return newEditor;
13106
13169
  }
13107
13170
  const newState = {
@@ -13109,7 +13172,7 @@ const createFn = (key, name, widgetId) => {
13109
13172
  commands
13110
13173
  };
13111
13174
  const newEditor = updateWidget(latest, widgetId, newState);
13112
- set$a(editor.uid, editor, newEditor);
13175
+ set$b(editor.uid, editor, newEditor);
13113
13176
  return newEditor;
13114
13177
  };
13115
13178
  return fn;
@@ -13287,10 +13350,10 @@ const loadContent$2 = async (state, parentUid, savedState) => {
13287
13350
  y
13288
13351
  } = editor;
13289
13352
  await launch();
13290
- await invoke$3('FindWidget.create', uid, x, y, width, height, parentUid);
13291
- await invoke$3('FindWidget.loadContent', uid, savedState);
13292
- const diff = await invoke$3('FindWidget.diff2', uid);
13293
- const commands = await invoke$3('FindWidget.render2', uid, diff);
13353
+ await invoke$4('FindWidget.create', uid, x, y, width, height, parentUid);
13354
+ await invoke$4('FindWidget.loadContent', uid, savedState);
13355
+ const diff = await invoke$4('FindWidget.diff2', uid);
13356
+ const commands = await invoke$4('FindWidget.render2', uid, diff);
13294
13357
  return {
13295
13358
  ...state,
13296
13359
  commands
@@ -13370,10 +13433,10 @@ const newStateGenerator$1 = async (state, parentUid) => {
13370
13433
  applicationId,
13371
13434
  languageId
13372
13435
  } = newState;
13373
- await invoke$5('Rename.create', uid, x, y, width, height, parentUid, languageId, applicationId);
13374
- await invoke$5('Rename.loadContent', uid);
13375
- const diff = await invoke$5('Rename.diff2', uid);
13376
- const commands = await invoke$5('Rename.render2', uid, diff);
13436
+ await invoke$6('Rename.create', uid, x, y, width, height, parentUid, languageId, applicationId);
13437
+ await invoke$6('Rename.loadContent', uid);
13438
+ const diff = await invoke$6('Rename.diff2', uid);
13439
+ const commands = await invoke$6('Rename.render2', uid, diff);
13377
13440
  return {
13378
13441
  ...state,
13379
13442
  commands
@@ -13438,7 +13501,7 @@ const getOrganizeImportEdits = async editor => {
13438
13501
  text: getText$1(editor),
13439
13502
  uri: editor.uri
13440
13503
  };
13441
- const result = await invoke$8(editor.applicationId, 'Extensions.executeOrganizeImportsProvider', textDocument);
13504
+ const result = await invoke$9(editor.applicationId, 'Extensions.executeOrganizeImportsProvider', textDocument);
13442
13505
  return result.found ? result.result ?? [] : [];
13443
13506
  };
13444
13507
 
@@ -13497,11 +13560,11 @@ const writeClipboardImage = async (editor, blob) => {
13497
13560
  for (let index = 0; index < 1000; index++) {
13498
13561
  const fileName = index === 0 ? `image.${extension}` : `image-${index}.${extension}`;
13499
13562
  const uri = getImageUri(editor.uri, fileName);
13500
- if (await invoke$9(editor.applicationId, 'FileSystem.exists', uri)) {
13563
+ if (await invoke$a(editor.applicationId, 'FileSystem.exists', uri)) {
13501
13564
  continue;
13502
13565
  }
13503
13566
  try {
13504
- await invoke$9(editor.applicationId, 'FileSystem.createFile', uri);
13567
+ await invoke$a(editor.applicationId, 'FileSystem.createFile', uri);
13505
13568
  } catch (error) {
13506
13569
  if (isFileExistsError(error)) {
13507
13570
  continue;
@@ -13509,14 +13572,14 @@ const writeClipboardImage = async (editor, blob) => {
13509
13572
  throw error;
13510
13573
  }
13511
13574
  try {
13512
- await invoke$9(editor.applicationId, 'FileSystem.writeFile', uri, await toBinaryString(blob), 'binary');
13575
+ await invoke$a(editor.applicationId, 'FileSystem.writeFile', uri, await toBinaryString(blob), 'binary');
13513
13576
  return {
13514
13577
  fileName,
13515
13578
  uri
13516
13579
  };
13517
13580
  } catch (error) {
13518
13581
  try {
13519
- await invoke$9(editor.applicationId, 'FileSystem.remove', uri);
13582
+ await invoke$a(editor.applicationId, 'FileSystem.remove', uri);
13520
13583
  } catch {}
13521
13584
  throw error;
13522
13585
  }
@@ -13528,7 +13591,7 @@ const paste = async (editor, pastedText) => {
13528
13591
  if (editor.languageId === 'markdown') {
13529
13592
  let image;
13530
13593
  try {
13531
- image = await invoke$d('ClipBoard.readImage');
13594
+ image = await invoke$e('ClipBoard.readImage');
13532
13595
  } catch (error) {
13533
13596
  imageReadError = error;
13534
13597
  }
@@ -13544,7 +13607,7 @@ const paste = async (editor, pastedText) => {
13544
13607
  const currentEditor = get$8(editor.uid)?.newState;
13545
13608
  if (!currentEditor || currentEditor.uri !== editor.uri || currentEditor.languageId !== 'markdown') {
13546
13609
  try {
13547
- await invoke$9(editor.applicationId, 'FileSystem.remove', savedImage.uri);
13610
+ await invoke$a(editor.applicationId, 'FileSystem.remove', savedImage.uri);
13548
13611
  } catch {}
13549
13612
  throw new Error('The Markdown document changed while saving the clipboard image. Paste the image again.');
13550
13613
  }
@@ -14173,7 +14236,7 @@ const setLanguageId = async (editor, languageId, tokenizePath, isExplicit = fals
14173
14236
  await loadTokenizer(languageId, tokenizePath);
14174
14237
  const tokenizer = getTokenizer(languageId);
14175
14238
  const newTokenizerId = tokenizerId + 1;
14176
- set$5(newTokenizerId, tokenizer);
14239
+ set$6(newTokenizerId, tokenizer);
14177
14240
  return {
14178
14241
  ...editor,
14179
14242
  explicitLanguageId: isExplicit ? languageId : editor.explicitLanguageId,
@@ -14285,7 +14348,7 @@ const executeSignatureHelpProvider = async (editor, offset) => {
14285
14348
  object(editor);
14286
14349
  number(offset);
14287
14350
  const textDocument = getTextDocument(editor);
14288
- return invoke$8(editor.applicationId, 'Extensions.executeSignatureHelpProvider', textDocument, offset);
14351
+ return invoke$9(editor.applicationId, 'Extensions.executeSignatureHelpProvider', textDocument, offset);
14289
14352
  };
14290
14353
 
14291
14354
  const getSignatureHelp = async (editor, offset) => {
@@ -14423,10 +14486,10 @@ const newStateGenerator = async (state, parentUid) => {
14423
14486
  const {
14424
14487
  languageId
14425
14488
  } = newState;
14426
- await invoke$1('SourceActions.create', uid, x, y, width, height, parentUid, languageId);
14427
- await invoke$1('SourceActions.loadContent', uid);
14428
- const diff = await invoke$1('SourceActions.diff2', uid);
14429
- const commands = await invoke$1('SourceActions.render2', uid, diff);
14489
+ await invoke$2('SourceActions.create', uid, x, y, width, height, parentUid, languageId);
14490
+ await invoke$2('SourceActions.loadContent', uid);
14491
+ const diff = await invoke$2('SourceActions.diff2', uid);
14492
+ const commands = await invoke$2('SourceActions.render2', uid, diff);
14430
14493
  return {
14431
14494
  ...state,
14432
14495
  commands
@@ -16041,7 +16104,7 @@ const executeViewletCommand$1 = async (commandMap, uid, commandId, ...args) => {
16041
16104
  throw new TypeError(`Viewlet command not found: ${commandId}`);
16042
16105
  }
16043
16106
  await fn(uid, ...args);
16044
- await invoke$d('Viewlet.executeViewletCommand', uid, '__renderPending', false);
16107
+ await invoke$e('Viewlet.executeViewletCommand', uid, '__renderPending', false);
16045
16108
  };
16046
16109
 
16047
16110
  const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...params) => {
@@ -16086,7 +16149,7 @@ const getEditorSourceActions = async editorId => {
16086
16149
  const {
16087
16150
  newState
16088
16151
  } = get$8(editorId);
16089
- const extensions = await invoke$8(newState.applicationId, 'Extensions.getAllExtensions', newState.assetDir, newState.platform);
16152
+ const extensions = await invoke$9(newState.applicationId, 'Extensions.getAllExtensions', newState.assetDir, newState.platform);
16090
16153
  return extensions.filter(extension => !extension.disabled).flatMap(extension => extension.codeActions || []).filter(action => action.languageId === newState.languageId);
16091
16154
  };
16092
16155
 
@@ -16179,10 +16242,28 @@ const getSelections2 = editorUid => {
16179
16242
  return selections;
16180
16243
  };
16181
16244
  const setSelections2 = async (editorUid, selections) => {
16182
- const editor = getEditor$1(editorUid);
16183
- const newEditor = setSelections$2(editor, selections);
16184
- const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
16185
- set$a(editorUid, editor, newEditorWithDerivedState);
16245
+ const requested = get$8(editorUid);
16246
+ if (!requested || requested.newState.lifecycle?.disposed) {
16247
+ return;
16248
+ }
16249
+ const requestedLifecycle = requested.newState.lifecycle;
16250
+ await enqueue(editorUid, async () => {
16251
+ const instance = get$8(editorUid);
16252
+ if (!instance || instance.newState.lifecycle?.disposed || instance.newState.lifecycle !== requestedLifecycle) {
16253
+ return;
16254
+ }
16255
+ const editor = instance.newState;
16256
+ const {
16257
+ lifecycle
16258
+ } = editor;
16259
+ const newEditor = setSelections$2(editor, selections);
16260
+ const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
16261
+ const current = get$8(editorUid);
16262
+ if (!current || lifecycle?.disposed || current.newState.lifecycle !== lifecycle) {
16263
+ return;
16264
+ }
16265
+ set$b(editorUid, current.oldState, newEditorWithDerivedState);
16266
+ });
16186
16267
  };
16187
16268
  const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
16188
16269
  const editor = getEditor$1(editorUid);
@@ -16206,7 +16287,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
16206
16287
  widgets: newWidgets
16207
16288
  };
16208
16289
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
16209
- set$a(editorUid, editor, newEditorWithDerivedState);
16290
+ set$b(editorUid, editor, newEditorWithDerivedState);
16210
16291
  await setFocus(FocusEditorText);
16211
16292
  if (unsetAdditionalFocus$1) {
16212
16293
  await unsetAdditionalFocus(unsetAdditionalFocus$1);
@@ -16231,7 +16312,7 @@ const getDiagnostics = async editorUid => {
16231
16312
  };
16232
16313
 
16233
16314
  const ensure = async (fontName, fontUrl) => {
16234
- await invoke$e('TextMeasurement.ensureFont', fontName, fontUrl);
16315
+ await invoke$f('TextMeasurement.ensureFont', fontName, fontUrl);
16235
16316
  };
16236
16317
 
16237
16318
  const findWidgetFocusContexts = [FindWidget, FocusFindWidgetReplace$1, FocusFindWidgetOptions, FocusFindWidgetToggleReplace, FocusFindWidgetPreviousMatchButton, FocusFindWidgetNextMatchButton, FocusFindWidgetCloseButton, FocusFindWidgetReplaceButton, FocusFindWidgetReplaceAllButton];
@@ -16890,20 +16971,72 @@ const handleBeforeInput = (editor, inputType, data) => {
16890
16971
  }
16891
16972
  };
16892
16973
 
16974
+ // These commands have renderer-owned effects in addition to editor state updates.
16975
+ const rendererCommands = new Set(['ColorPicker.handleSliderKeyDown', 'handleFocus', 'handleUriChange', 'handleWorkspaceRefresh', 'hotReload', 'loadContent', 'loadContentLater', 'refreshGutterDecorationsAll', 'renderPending', 'setLanguageId', 'showOverlayMessage', 'updateDiagnostics']);
16976
+ const createCommandMap = commands => ({
16977
+ async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
16978
+ if (rendererCommands.has(command)) {
16979
+ await invoke$e('Viewlet.executeViewletCommand', uid, command, ...args);
16980
+ return;
16981
+ }
16982
+ const fn = commands[command.includes('.') ? command : `Editor.${command}`];
16983
+ if (typeof fn !== 'function') {
16984
+ throw new TypeError(`Editor event command not found: ${command}`);
16985
+ }
16986
+ const editor = get$8(uid)?.newState;
16987
+ if (!editor) return;
16988
+ await fn(uid, ...args);
16989
+ const current = get$8(uid)?.newState;
16990
+ if (!current || editor.lifecycle?.disposed || current.lifecycle !== editor.lifecycle) return;
16991
+ // The wrapped command has released the document queue before requesting a
16992
+ // render; a diff can now run without waiting on its own command.
16993
+ await invoke$e('Viewlet.requestRender', uid, false);
16994
+ }
16995
+ });
16996
+
16997
+ const state$1 = {
16998
+ rpc: undefined
16999
+ };
17000
+ const isConnected = () => {
17001
+ const {
17002
+ rpc
17003
+ } = state$1;
17004
+ return rpc !== undefined;
17005
+ };
17006
+ const set = value => {
17007
+ state$1.rpc = value;
17008
+ };
17009
+ const invoke$1 = (method, ...params) => {
17010
+ const {
17011
+ rpc
17012
+ } = state$1;
17013
+ if (!rpc) {
17014
+ throw new Error('Editor renderer process is not connected');
17015
+ }
17016
+ return rpc.invoke(method, ...params);
17017
+ };
17018
+
16893
17019
  const handleMessagePort = async (port, rpcId) => {
16894
17020
  const rpc = await create$e({
16895
17021
  commandMap: {},
16896
17022
  messagePort: port
16897
17023
  });
16898
17024
  if (rpcId) {
16899
- set$j(rpcId, rpc);
17025
+ set$k(rpcId, rpc);
16900
17026
  await initializeListener(rpcId);
16901
17027
  }
16902
17028
  };
17029
+ const handleDirectMessagePort = async (port, commands) => {
17030
+ const rpc = await create$h({
17031
+ commandMap: createCommandMap(commands),
17032
+ messagePort: port
17033
+ });
17034
+ set(rpc);
17035
+ };
16903
17036
 
16904
17037
  const getBreadcrumbFileIcon = async (uri, applicationId) => {
16905
17038
  try {
16906
- const icon = await invoke$9(applicationId, 'IconTheme.getFileIcon', {
17039
+ const icon = await invoke$a(applicationId, 'IconTheme.getFileIcon', {
16907
17040
  name: decodeURIComponent(uri.split('/').at(-1) || '')
16908
17041
  });
16909
17042
  return typeof icon === 'string' ? icon : '';
@@ -17093,7 +17226,7 @@ const getLargeFilePreferences = () => ({
17093
17226
 
17094
17227
  const getWorkspaceUri$1 = async applicationId => {
17095
17228
  try {
17096
- return await invoke$9(applicationId, 'Workspace.getPath');
17229
+ return await invoke$a(applicationId, 'Workspace.getPath');
17097
17230
  } catch {
17098
17231
  return '';
17099
17232
  }
@@ -17106,9 +17239,9 @@ const updateFindWidget = async state => {
17106
17239
  const {
17107
17240
  uid
17108
17241
  } = widget.newState;
17109
- await invoke$3('FindWidget.handleSettingsChanged', uid);
17110
- const diff = await invoke$3('FindWidget.diff2', uid);
17111
- const commands = await invoke$3('FindWidget.render2', uid, diff);
17242
+ await invoke$4('FindWidget.handleSettingsChanged', uid);
17243
+ const diff = await invoke$4('FindWidget.diff2', uid);
17244
+ const commands = await invoke$4('FindWidget.render2', uid, diff);
17112
17245
  return updateWidget(state, Find, {
17113
17246
  ...widget.newState,
17114
17247
  commands
@@ -17203,7 +17336,7 @@ const getWidgetHotReloadDescriptor = widgetId => {
17203
17336
  switch (widgetId) {
17204
17337
  case Find:
17205
17338
  return {
17206
- invoke: invoke$3,
17339
+ invoke: invoke$4,
17207
17340
  name: 'FindWidget'
17208
17341
  };
17209
17342
  default:
@@ -17328,12 +17461,12 @@ const hotReload = async () => {
17328
17461
  await relaunchWorkers();
17329
17462
  const newEditors = await restoreWidgetState(keys, savedStates);
17330
17463
  for (const editor of newEditors) {
17331
- set$a(editor.newState.uid, editor.oldState, editor.newState);
17464
+ set$b(editor.newState.uid, editor.oldState, editor.newState);
17332
17465
  }
17333
17466
 
17334
17467
  // TODO ask renderer worker to rerender all editors
17335
17468
  // @ts-ignore
17336
- await invoke$d(`Editor.rerender`);
17469
+ await invoke$e(`Editor.rerender`);
17337
17470
  } finally {
17338
17471
  state.isReloading = false;
17339
17472
  }
@@ -17366,7 +17499,7 @@ const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncre
17366
17499
  if (syntaxHighlightingEnabled) {
17367
17500
  setEnabled$1(true);
17368
17501
  const syntaxRpc = await createSyntaxHighlightingWorkerRpc();
17369
- set$8(syntaxRpc);
17502
+ set$9(syntaxRpc);
17370
17503
  }
17371
17504
  if (syncIncremental) {
17372
17505
  setEnabled(true);
@@ -17413,7 +17546,7 @@ const isExcludedFromFileCache = uri => {
17413
17546
  return fileName === '.env' || fileName.startsWith('.env.');
17414
17547
  };
17415
17548
  const removeCachedEditorFile = (applicationId, uri) => {
17416
- void invoke$9(undefined, 'CacheStorage.removeEditorFileCache', applicationId || '', uri).catch(() => {});
17549
+ void invoke$a(undefined, 'CacheStorage.removeEditorFileCache', applicationId || '', uri).catch(() => {});
17417
17550
  };
17418
17551
  const readFileWithCache = async (applicationId, uri, forceReload, useCache) => {
17419
17552
  if (!useCache) {
@@ -17429,7 +17562,7 @@ const readFileWithCache = async (applicationId, uri, forceReload, useCache) => {
17429
17562
  }
17430
17563
  let fingerprint = '';
17431
17564
  try {
17432
- const stat = await invoke$9(applicationId, 'FileSystem.statWithMetadata', uri);
17565
+ const stat = await invoke$a(applicationId, 'FileSystem.statWithMetadata', uri);
17433
17566
  if (stat?.size <= editorFileCacheMaxBytes) {
17434
17567
  fingerprint = getFileStatFingerprint(stat);
17435
17568
  }
@@ -17441,7 +17574,7 @@ const readFileWithCache = async (applicationId, uri, forceReload, useCache) => {
17441
17574
  }
17442
17575
  if (fingerprint) {
17443
17576
  try {
17444
- const cached = await invoke$9(undefined, 'CacheStorage.getEditorFileCache', applicationId || '', uri, fingerprint);
17577
+ const cached = await invoke$a(undefined, 'CacheStorage.getEditorFileCache', applicationId || '', uri, fingerprint);
17445
17578
  if (typeof cached === 'string') {
17446
17579
  return cached;
17447
17580
  }
@@ -17451,7 +17584,7 @@ const readFileWithCache = async (applicationId, uri, forceReload, useCache) => {
17451
17584
  }
17452
17585
  const content = await readFile$1(applicationId, uri);
17453
17586
  if (fingerprint && new TextEncoder().encode(content).byteLength <= editorFileCacheMaxBytes) {
17454
- void invoke$9(undefined, 'CacheStorage.setEditorFileCache', applicationId || '', uri, fingerprint, content).catch(() => {});
17587
+ void invoke$a(undefined, 'CacheStorage.setEditorFileCache', applicationId || '', uri, fingerprint, content).catch(() => {});
17455
17588
  }
17456
17589
  return content;
17457
17590
  };
@@ -17490,7 +17623,7 @@ const readFile = (applicationId, uri, forceReload, useCache) => {
17490
17623
  };
17491
17624
  const getWorkspaceUri = async applicationId => {
17492
17625
  try {
17493
- return await invoke$9(applicationId, 'Workspace.getPath');
17626
+ return await invoke$a(applicationId, 'Workspace.getPath');
17494
17627
  } catch {
17495
17628
  return '';
17496
17629
  }
@@ -17675,7 +17808,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
17675
17808
  await loadTokenizer(computedLanguageId, tokenizePath);
17676
17809
  const tokenizer = getTokenizer(computedLanguageId);
17677
17810
  const newTokenizerId = state.tokenizerId + 1;
17678
- set$5(newTokenizerId, tokenizer);
17811
+ set$6(newTokenizerId, tokenizer);
17679
17812
  effectiveEditor.tokenizerId = newTokenizerId;
17680
17813
  }
17681
17814
  const savedHistory = existingEditor ? undefined : getSavedHistory(savedState, content);
@@ -17821,11 +17954,11 @@ const refreshGutterDecorationsAll = async () => {
17821
17954
  if (!latest) {
17822
17955
  continue;
17823
17956
  }
17824
- set$a(editor.id, latest.oldState, {
17957
+ set$b(editor.id, latest.oldState, {
17825
17958
  ...latest.newState,
17826
17959
  gutterDecorations: refreshedEditor.gutterDecorations
17827
17960
  });
17828
- await invoke$d('Editor.renderPending', editor.id);
17961
+ await invoke$e('Editor.renderPending', editor.id);
17829
17962
  }
17830
17963
  }
17831
17964
  };
@@ -19020,7 +19153,7 @@ const renderIncremental = (oldState, newState) => {
19020
19153
  const textAppendPaths = getTextAppendPaths$1(newState.uid);
19021
19154
  if (renderedDom && textAppendPaths && canRenderPlainTextAppend(oldState, newState)) {
19022
19155
  const newDom = updateTextAppendDom(renderedDom, newState, textAppendPaths);
19023
- set$1(newState.uid, newDom, textAppendPaths);
19156
+ set$2(newState.uid, newDom, textAppendPaths);
19024
19157
  const patches = getTextAppendPatches(newState, textAppendPaths);
19025
19158
  return [SetPatches, newState.uid, patches];
19026
19159
  }
@@ -19028,7 +19161,7 @@ const renderIncremental = (oldState, newState) => {
19028
19161
  const newDom = getDom(newState);
19029
19162
  const patches = diffTree(oldDom, newDom);
19030
19163
  const newTextAppendPaths = newState.languageId === 'plaintext' && newState.lines.length === 1 ? getTextAppendPaths(newDom) : undefined;
19031
- set$1(newState.uid, newDom, newTextAppendPaths);
19164
+ set$2(newState.uid, newDom, newTextAppendPaths);
19032
19165
  if (patches.length === 0) {
19033
19166
  return [];
19034
19167
  }
@@ -19155,11 +19288,65 @@ const render2 = (uid, _diffResult) => {
19155
19288
  } = editor;
19156
19289
  // Diagnostics can change after the caller calculated its diff in a separate RPC.
19157
19290
  const diffResult = diff(oldState, newState);
19158
- set$a(uid, newState, newState);
19291
+ set$b(uid, newState, newState);
19159
19292
  const commands = applyRender(oldState, newState, diffResult);
19160
19293
  return commands;
19161
19294
  };
19162
19295
 
19296
+ const queues = new Map();
19297
+ const focusCommands = new Set(['Viewlet.focus', 'Viewlet.focusSelector', 'Viewlet.setFocusContext', 'Viewlet.setAdditionalFocus', 'Viewlet.unsetAdditionalFocus']);
19298
+ const renderDirect = async (uid, preserveFocus) => {
19299
+ const instance = get$8(uid);
19300
+ if (!instance) return [];
19301
+ const {
19302
+ newState,
19303
+ oldState
19304
+ } = instance;
19305
+ const oldDom = get$1(uid);
19306
+ const oldPaths = getTextAppendPaths$1(uid);
19307
+ try {
19308
+ const commands = render2(uid, []);
19309
+ const result = [];
19310
+ for (const command of commands) {
19311
+ if (preserveFocus && focusCommands.has(command[0])) continue;
19312
+ // Widget creation/declarations and focus contexts must still pass through
19313
+ // renderer-worker. Replace only DOM patches, preserving command order.
19314
+ if (isConnected() && command[0] === 'Viewlet.setPatches' && command[1] === uid) {
19315
+ const transactionId = await invoke$1('Viewlet.queueCommands', uid, [command]);
19316
+ result.push(['Viewlet.commitPending', uid, transactionId]);
19317
+ } else {
19318
+ result.push(command);
19319
+ }
19320
+ }
19321
+ return result;
19322
+ } catch (error) {
19323
+ const latest = get$8(uid);
19324
+ if (latest?.newState.lifecycle === newState.lifecycle && latest.oldState === newState) {
19325
+ // A rejected queue RPC must not acknowledge patches that never arrived.
19326
+ set$b(uid, oldState, latest.newState);
19327
+ if (oldDom) set$2(uid, oldDom, oldPaths);else dispose$2(uid);
19328
+ }
19329
+ throw error;
19330
+ }
19331
+ };
19332
+ const renderDirect2 = async (uid, preserveFocus = false) => {
19333
+ const lifecycle = get$8(uid)?.newState.lifecycle;
19334
+ const previous = queues.get(uid);
19335
+ const {
19336
+ promise,
19337
+ resolve
19338
+ } = Promise.withResolvers();
19339
+ queues.set(uid, promise);
19340
+ if (previous) await previous;
19341
+ try {
19342
+ if (get$8(uid)?.newState.lifecycle !== lifecycle) return [];
19343
+ return await renderDirect(uid, preserveFocus);
19344
+ } finally {
19345
+ resolve();
19346
+ if (queues.get(uid) === promise) queues.delete(uid);
19347
+ }
19348
+ };
19349
+
19163
19350
  const renderLines = {
19164
19351
  apply(oldState, newState) {
19165
19352
  const {
@@ -19266,7 +19453,7 @@ const renderEditor = async id => {
19266
19453
  oldState
19267
19454
  } = instance;
19268
19455
  const commands = [];
19269
- set$a(id, newState, newState);
19456
+ set$b(id, newState, newState);
19270
19457
  for (const item of render$7) {
19271
19458
  if (item.isEqual(oldState, newState)) {
19272
19459
  continue;
@@ -19420,7 +19607,7 @@ const save = async (uid, skipFormatting = false) => {
19420
19607
  const saved = await saveContent(uid);
19421
19608
  if (savedFrom && saved && savedFrom.uri !== saved.uri) {
19422
19609
  // Retargeting calls Editor.handleUriChange, so release the editing queue first.
19423
- await invoke$9(savedFrom.applicationId, 'Main.handleUriChange', savedFrom.uri, saved.uri);
19610
+ await invoke$a(savedFrom.applicationId, 'Main.handleUriChange', savedFrom.uri, saved.uri);
19424
19611
  }
19425
19612
  };
19426
19613
 
@@ -19543,9 +19730,9 @@ const updateDebugInfo = async debugId => {
19543
19730
  ...newState,
19544
19731
  highlightedLine: newInfo.rowIndex
19545
19732
  };
19546
- set$a(key, oldState, newEditor);
19733
+ set$b(key, oldState, newEditor);
19547
19734
  // @ts-ignore
19548
- await invoke$d('Editor.rerender', key);
19735
+ await invoke$e('Editor.rerender', key);
19549
19736
  };
19550
19737
 
19551
19738
  // State and undo history belong in this worker. Rendering reads changes separately.
@@ -19599,7 +19786,7 @@ const wrapTypingCommand = (fn, shouldOpenCompletion, shouldDismissHover, preserv
19599
19786
  await command(uid, ...args);
19600
19787
  const editor = get$8(uid)?.newState;
19601
19788
  if (editor && (shouldOpenCompletion(...args) && shouldOpenAutomaticCompletion(editor) || editor.widgets?.some(widget => widget.id === Completion && widget.newState.automatic))) {
19602
- void updateAutomaticCompletionDeferred(uid).then(() => invoke$d('Editor.renderPending', uid)).catch(error => handleError$1(error, 'Failed to open completion widget: '));
19789
+ void updateAutomaticCompletionDeferred(uid).then(() => invoke$e('Editor.renderPending', uid)).catch(error => handleError$1(error, 'Failed to open completion widget: '));
19603
19790
  }
19604
19791
  };
19605
19792
  };
@@ -19712,6 +19899,7 @@ const commandMap = {
19712
19899
  'Editor.handleBlur': wrapCommand(handleBlur$1),
19713
19900
  'Editor.handleClickAtPosition': wrapCommand(handleClickAtPosition),
19714
19901
  'Editor.handleContextMenu': wrapCommand(handleContextMenu),
19902
+ 'Editor.handleDirectMessagePort': port => handleDirectMessagePort(port, commandMap),
19715
19903
  'Editor.handleDoubleClick': wrapCommand(handleDoubleClick),
19716
19904
  'Editor.handleFocus': wrapFocusCommand(handleFocus$1),
19717
19905
  'Editor.handleKeyUp': wrapCommand(handleKeyUp, true),
@@ -19774,6 +19962,7 @@ const commandMap = {
19774
19962
  'Editor.refreshTextDecorations': wrapCommand(refreshTextDecorations),
19775
19963
  'Editor.render': renderEditor,
19776
19964
  'Editor.render2': render2,
19965
+ 'Editor.renderDirect2': renderDirect2,
19777
19966
  'Editor.renderEventListeners': renderEventListeners,
19778
19967
  'Editor.replaceRange': wrapCommand(replaceRange),
19779
19968
  'Editor.rerender': wrapCommand(rerender),
@@ -19931,7 +20120,7 @@ const initializeDragAndDropWorker = async () => {
19931
20120
  commandMap: {},
19932
20121
  send: sendMessagePortToDragAndDropWorker
19933
20122
  });
19934
- set$h(rpc);
20123
+ set$i(rpc);
19935
20124
  };
19936
20125
 
19937
20126
  const initializeErrorWorker = async () => {
@@ -19941,7 +20130,7 @@ const initializeErrorWorker = async () => {
19941
20130
  return sendMessagePortToErrorWorker(port, EditorWorker);
19942
20131
  }
19943
20132
  });
19944
- set$g(rpc);
20133
+ set$h(rpc);
19945
20134
  };
19946
20135
 
19947
20136
  const createExtensionManagementWorkerRpc = async () => {
@@ -19957,7 +20146,7 @@ const createExtensionManagementWorkerRpc = async () => {
19957
20146
  const initializeExtensionManagementWorker = async () => {
19958
20147
  try {
19959
20148
  const rpc = await createExtensionManagementWorkerRpc();
19960
- set$f(rpc);
20149
+ set$g(rpc);
19961
20150
  } catch {
19962
20151
  // ignore
19963
20152
  }
@@ -19972,14 +20161,14 @@ const initializeOpenerWorker = async () => {
19972
20161
  commandMap: {},
19973
20162
  send: send$1
19974
20163
  });
19975
- set$e(rpc);
20164
+ set$f(rpc);
19976
20165
  };
19977
20166
 
19978
20167
  const initializeRendererWorker = async () => {
19979
20168
  const rpc = await create$d({
19980
20169
  commandMap: commandMap
19981
20170
  });
19982
- set$c(rpc);
20171
+ set$d(rpc);
19983
20172
  };
19984
20173
 
19985
20174
  const send = port => {
@@ -19990,7 +20179,7 @@ const initializeTextMeasurementWorker = async () => {
19990
20179
  commandMap: {},
19991
20180
  send
19992
20181
  });
19993
- set$d(rpc);
20182
+ set$e(rpc);
19994
20183
  };
19995
20184
 
19996
20185
  const listen = async () => {
@@ -20000,7 +20189,7 @@ const listen = async () => {
20000
20189
  commandMap: {},
20001
20190
  send: sendMessagePortToDialogWorker
20002
20191
  });
20003
- set$i(dialogRpc);
20192
+ set$j(dialogRpc);
20004
20193
  };
20005
20194
 
20006
20195
  const CodeGeneratorInput = 'CodeGeneratorInput';
@@ -20322,15 +20511,15 @@ const EditorMessageWidget = {
20322
20511
  };
20323
20512
 
20324
20513
  const registerWidgets = () => {
20325
- set$9(ColorPicker$2, EditorColorPickerWidget);
20326
- set$9(Completion, EditorCompletionWidget);
20327
- set$9(CompletionDetail, EditorCompletionDetailWidget);
20328
- set$9(Find, EditorFindWidget);
20329
- set$9(Hover, EditorHoverWidget);
20330
- set$9(Message, EditorMessageWidget);
20331
- set$9(Rename$1, EditorRenameWidget);
20332
- set$9(SourceAction$1, EditorSourceActionWidget);
20333
- set$9(CodeGenerator, EditorCodeGeneratorWidget);
20514
+ set$a(ColorPicker$2, EditorColorPickerWidget);
20515
+ set$a(Completion, EditorCompletionWidget);
20516
+ set$a(CompletionDetail, EditorCompletionDetailWidget);
20517
+ set$a(Find, EditorFindWidget);
20518
+ set$a(Hover, EditorHoverWidget);
20519
+ set$a(Message, EditorMessageWidget);
20520
+ set$a(Rename$1, EditorRenameWidget);
20521
+ set$a(SourceAction$1, EditorSourceActionWidget);
20522
+ set$a(CodeGenerator, EditorCodeGeneratorWidget);
20334
20523
  };
20335
20524
 
20336
20525
  const handleUnhandledRejection = event => {