@lvce-editor/editor-worker 10.2.0 → 11.1.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.
@@ -1118,6 +1118,8 @@ const ExtensionHostWorker = 44;
1118
1118
  const MarkdownWorker = 300;
1119
1119
  const RendererWorker$1 = 1;
1120
1120
 
1121
+ const FocusEditorText$1 = 12;
1122
+
1121
1123
  const rpcs = Object.create(null);
1122
1124
  const set$c = (id, rpc) => {
1123
1125
  rpcs[id] = rpc;
@@ -1348,7 +1350,7 @@ const getIcons = async requests => {
1348
1350
  const activateByEvent$1 = event => {
1349
1351
  return invoke$b('ExtensionHostManagement.activateByEvent', event);
1350
1352
  };
1351
- const setAdditionalFocus$1 = focusKey => {
1353
+ const setAdditionalFocus = focusKey => {
1352
1354
  // @ts-ignore
1353
1355
  return invoke$b('Focus.setAdditionalFocus', focusKey);
1354
1356
  };
@@ -1530,7 +1532,7 @@ const RendererWorker = {
1530
1532
  sendMessagePortToSearchProcess,
1531
1533
  sendMessagePortToSyntaxHighlightingWorker: sendMessagePortToSyntaxHighlightingWorker$1,
1532
1534
  set: set$a,
1533
- setAdditionalFocus: setAdditionalFocus$1,
1535
+ setAdditionalFocus,
1534
1536
  setColorTheme,
1535
1537
  setExtensionsSearchValue,
1536
1538
  setFocus: setFocus$1,
@@ -3599,6 +3601,7 @@ const createEditor = async ({
3599
3601
  const newEditor4 = {
3600
3602
  ...newEditor3,
3601
3603
  focused: true,
3604
+ focus: FocusEditorText$1,
3602
3605
  textInfos,
3603
3606
  differences
3604
3607
  };
@@ -3762,13 +3765,12 @@ const applyWorkspaceEdit = async (editor, changes) => {
3762
3765
  };
3763
3766
 
3764
3767
  const handleBlur$1 = editor => {
3765
- if (editor.focusKey !== Empty) {
3768
+ if (!editor.focused) {
3766
3769
  return editor;
3767
3770
  }
3768
3771
  const newEditor = {
3769
3772
  ...editor,
3770
- focused: false,
3771
- focusKey: Empty
3773
+ focused: false
3772
3774
  };
3773
3775
  return newEditor;
3774
3776
  };
@@ -4212,25 +4214,6 @@ const hasWidget = (widgets, id) => {
4212
4214
  return false;
4213
4215
  };
4214
4216
 
4215
- const setAdditionalFocus = async focusKey => {
4216
- // @ts-ignore
4217
- await invoke$9('Focus.setAdditionalFocus', focusKey);
4218
- };
4219
-
4220
- const setFocus = async focusKey => {
4221
- if (!focusKey) {
4222
- return;
4223
- }
4224
- await invoke$9('Focus.setFocus', focusKey);
4225
- };
4226
- const unsetAdditionalFocus = async focusKey => {
4227
- if (!focusKey) {
4228
- return;
4229
- }
4230
- // @ts-ignore
4231
- await invoke$9('Focus.removeAdditionalFocus', focusKey);
4232
- };
4233
-
4234
4217
  const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGenerator, fullFocus) => {
4235
4218
  const {
4236
4219
  widgets
@@ -4249,14 +4232,13 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
4249
4232
  newState
4250
4233
  };
4251
4234
  const newWidgets = [...widgets, latestWidget];
4252
- // TODO avoid side effect, apply focus shift during render
4253
- await (fullFocus ? setFocus(focusKey) : setAdditionalFocus(focusKey));
4254
4235
  const newFocus = !fullFocus;
4255
4236
  const newEditor = {
4256
4237
  ...editor,
4257
4238
  widgets: newWidgets,
4258
- focusKey,
4259
- focused: newFocus
4239
+ focused: newFocus,
4240
+ focus: fullFocus ? focusKey : FocusEditorText$1,
4241
+ additionalFocus: fullFocus ? 0 : focusKey
4260
4242
  };
4261
4243
  return newEditor;
4262
4244
  };
@@ -4925,7 +4907,7 @@ const getChanges$4 = (editor, getDelta) => {
4925
4907
  } = editor;
4926
4908
  for (let i = 0; i < selections.length; i += 4) {
4927
4909
  // @ts-ignore
4928
- const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
4910
+ const [selectionStartRow, selectionStartColumn] = getSelectionPairs(selections, i);
4929
4911
  const start = {
4930
4912
  rowIndex: selectionStartRow,
4931
4913
  columnIndex: selectionStartColumn
@@ -5520,12 +5502,16 @@ const handleDoubleClick = (editor, modifier, x, y) => {
5520
5502
  return selectWord(editor, position.rowIndex, position.columnIndex);
5521
5503
  };
5522
5504
 
5523
- const WhenExpressionEditorText = 12;
5524
5505
  const handleFocus$1 = editor => {
5525
- // TODO make change events functional,
5526
- // when rendering, send focus changes to renderer worker
5527
- invoke$9('Focus.setFocus', WhenExpressionEditorText);
5528
- return editor;
5506
+ if (editor.focused && editor.focus === FocusEditorText$1) {
5507
+ return editor;
5508
+ }
5509
+ return {
5510
+ ...editor,
5511
+ focused: true,
5512
+ focus: FocusEditorText$1,
5513
+ additionalFocus: 0
5514
+ };
5529
5515
  };
5530
5516
 
5531
5517
  const Single = 1;
@@ -6867,7 +6853,7 @@ const getNewSelections$4 = (selections, lines, getDelta) => {
6867
6853
  const newSelections = clone(selections);
6868
6854
  for (let i = 0; i < selections.length; i += 4) {
6869
6855
  // @ts-ignore
6870
- const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn, reversed] = getSelectionPairs(selections, i);
6856
+ const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
6871
6857
  if (selectionStartRow === selectionEndRow && selectionStartColumn === selectionEndColumn) {
6872
6858
  moveToPositionLeft(newSelections, i + 2, selectionStartRow, selectionStartColumn, lines, getDelta);
6873
6859
  moveToPositionEqual(newSelections, i, selectionEndRow, selectionEndColumn);
@@ -9235,6 +9221,17 @@ const getWordAtOffset = editor => {
9235
9221
  return '';
9236
9222
  };
9237
9223
 
9224
+ const setFocus = async focusKey => {
9225
+ await invoke$9('Focus.setFocus', focusKey);
9226
+ };
9227
+ const unsetAdditionalFocus = async focusKey => {
9228
+ if (!focusKey) {
9229
+ return;
9230
+ }
9231
+ // @ts-ignore
9232
+ await invoke$9('Focus.removeAdditionalFocus', focusKey);
9233
+ };
9234
+
9238
9235
  const FocusEditor = 12;
9239
9236
  const FocusEditorCompletions = 9;
9240
9237
  const FocusEditorRename = 11;
@@ -10324,14 +10321,28 @@ const renderFocus$1 = {
10324
10321
  return oldState.focused === newState.focused;
10325
10322
  },
10326
10323
  apply(oldState, newState) {
10327
- // TODO avoid side effect
10328
- if (newState.focused) {
10329
- const FocusEditorText = 12;
10330
- invoke$9('Focus.setFocus', FocusEditorText);
10331
- }
10332
10324
  return [/* method */'setFocused', newState.focused];
10333
10325
  }
10334
10326
  };
10327
+ const renderFocusContext = {
10328
+ isEqual(oldState, newState) {
10329
+ return oldState.focus === newState.focus;
10330
+ },
10331
+ apply(oldState, newState) {
10332
+ return ['Viewlet.setFocusContext', newState.uid, newState.focus];
10333
+ }
10334
+ };
10335
+ const renderAdditionalFocusContext = {
10336
+ isEqual(oldState, newState) {
10337
+ return newState.additionalFocus === newState.additionalFocus;
10338
+ },
10339
+ apply(oldState, newState) {
10340
+ if (newState.additionalFocus) {
10341
+ return ['Focus.setAdditionalFocus', newState.uid, newState.additionalFocus];
10342
+ }
10343
+ return ['Focus.unsetAdditionalFocus', newState.uid, newState.additionalFocus];
10344
+ }
10345
+ };
10335
10346
  const renderDecorations = {
10336
10347
  isEqual(oldState, newState) {
10337
10348
  return oldState.decorations === newState.decorations;
@@ -10413,11 +10424,12 @@ const renderWidgets = {
10413
10424
  }
10414
10425
  }
10415
10426
  const allCommands = [...addCommands, ...changeCommands, ...removeCommands];
10416
- return allCommands;
10427
+ const filteredCommands = allCommands.filter(item => item[0] !== 'Viewlet.setFocusContext');
10428
+ return filteredCommands;
10417
10429
  },
10418
10430
  multiple: true
10419
10431
  };
10420
- const render$6 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
10432
+ const render$6 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets, renderFocusContext, renderAdditionalFocusContext];
10421
10433
  const renderEditor = id => {
10422
10434
  const instance = get$4(id);
10423
10435
  if (!instance) {
@@ -10562,8 +10574,9 @@ const widgetCommands = {
10562
10574
  const effects = [editorDiagnosticEffect];
10563
10575
  const wrapCommand = fn => async (editorUid, ...args) => {
10564
10576
  const oldInstance = get$4(editorUid);
10565
- const newEditor = await fn(oldInstance.newState, ...args);
10566
- if (oldInstance.newState === newEditor) {
10577
+ const state = oldInstance.newState;
10578
+ const newEditor = await fn(state, ...args);
10579
+ if (state === newEditor) {
10567
10580
  return newEditor;
10568
10581
  }
10569
10582
  for (const effect of effects) {
@@ -10575,7 +10588,7 @@ const wrapCommand = fn => async (editorUid, ...args) => {
10575
10588
 
10576
10589
  // TODO combine neweditor with latest editor?
10577
10590
 
10578
- set$6(editorUid, oldInstance.newState, newEditor);
10591
+ set$6(editorUid, state, newEditor);
10579
10592
  const commands = renderEditor(editorUid);
10580
10593
  return {
10581
10594
  ...newEditor,
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "10.2.0",
3
+ "version": "11.1.0",
4
4
  "license": "MIT",
5
5
  "author": "Lvce Editor",
6
6
  "type": "module",
7
7
  "main": "dist/editorWorkerMain.js",
8
8
  "dependencies": {
9
- "@lvce-editor/constants": "^1.23.0"
9
+ "@lvce-editor/constants": "^1.24.0"
10
10
  }
11
11
  }