@lvce-editor/editor-worker 19.29.2 → 19.29.3

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.
@@ -1903,9 +1903,9 @@ const codeGeneratorAccept = state => {
1903
1903
 
1904
1904
  const ModuleWorkerAndWorkaroundForChromeDevtoolsBug = 6;
1905
1905
 
1906
- const launchWorker = async (name, url, intializeCommand) => {
1906
+ const launchWorker = async (name, url, intializeCommand, commandMap = {}) => {
1907
1907
  const rpc = await create$e({
1908
- commandMap: {},
1908
+ commandMap,
1909
1909
  isMessagePortOpen: true,
1910
1910
  async send(port) {
1911
1911
  await invokeAndTransfer('IpcParent.create', {
@@ -1985,6 +1985,14 @@ const Empty = 0;
1985
1985
  const FindWidget = 16;
1986
1986
  const FocusEditorHover = 51;
1987
1987
  const FocusEditorRename$1 = 11;
1988
+ const FocusFindWidgetCloseButton = 48;
1989
+ const FocusFindWidgetNextMatchButton = 49;
1990
+ const FocusFindWidgetOptions = 44;
1991
+ const FocusFindWidgetPreviousMatchButton = 50;
1992
+ const FocusFindWidgetReplace$1 = 43;
1993
+ const FocusFindWidgetReplaceAllButton = 47;
1994
+ const FocusFindWidgetReplaceButton = 46;
1995
+ const FocusFindWidgetToggleReplace = 42;
1988
1996
  const SourceActions = 38;
1989
1997
  const FocusCodeGenerator = 52;
1990
1998
 
@@ -4069,7 +4077,7 @@ const getSelectionFromChange = change => {
4069
4077
  start: newPosition
4070
4078
  };
4071
4079
  };
4072
- const setSelections$1 = (editor, selections) => {
4080
+ const setSelections$2 = (editor, selections) => {
4073
4081
  object(editor);
4074
4082
  const {
4075
4083
  foldingRanges = []
@@ -4187,7 +4195,7 @@ const applyAutoClosingRangesEdit = (editor, changes) => {
4187
4195
  return newAutoClosingRanges;
4188
4196
  };
4189
4197
  const scheduleSelections = (editor, selectionEdits) => {
4190
- return setSelections$1(editor, selectionEdits);
4198
+ return setSelections$2(editor, selectionEdits);
4191
4199
  };
4192
4200
  const updateLines = (editor, lines) => {
4193
4201
  const newEditor = {
@@ -4868,7 +4876,7 @@ const renderWidgets$1 = (oldState, newState) => {
4868
4876
  record(newState.uid, declaredRevision);
4869
4877
  const widgetUids = newWidgets.map(widget => widget.newState.uid);
4870
4878
  const allCommands = [...addCommands, ...changeCommands, ['Viewlet.setWidgets', newState.uid, declaredRevision, widgetUids]];
4871
- return allCommands.filter(item => item[0] !== 'Viewlet.setFocusContext' && item[0] !== 'Viewlet.appendToBody');
4879
+ return allCommands.filter(item => item[0] !== 'Viewlet.appendToBody' && (item[0] !== 'Viewlet.setFocusContext' || item.length >= 3));
4872
4880
  };
4873
4881
 
4874
4882
  const disposeEditor = async editorUid => {
@@ -4978,7 +4986,7 @@ const error = (...args) => {
4978
4986
  console.error(...args);
4979
4987
  };
4980
4988
 
4981
- const applyDocumentEdits = (editor, edits) => {
4989
+ const applyDocumentEdits$1 = (editor, edits) => {
4982
4990
  if (!Array.isArray(edits)) {
4983
4991
  warn('something is wrong with format on save', edits);
4984
4992
  return editor;
@@ -5354,7 +5362,7 @@ const expectedErrorMessage = 'Failed to execute formatting provider: FormattingE
5354
5362
  const format = async editor => {
5355
5363
  try {
5356
5364
  const edits = await getFormattingEdits(editor);
5357
- return applyDocumentEdits(editor, edits);
5365
+ return applyDocumentEdits$1(editor, edits);
5358
5366
  } catch (error) {
5359
5367
  if (isFormattingError(error)) {
5360
5368
  console.error('Formatting Error:',
@@ -5683,7 +5691,7 @@ const closeCompletion = editor => {
5683
5691
  const isMatchingWidget$1 = widget => {
5684
5692
  return widget.id === Find;
5685
5693
  };
5686
- const closeFind = editor => {
5694
+ const closeFind$1 = editor => {
5687
5695
  const {
5688
5696
  widgets
5689
5697
  } = editor;
@@ -8671,10 +8679,83 @@ const addWidget = (widget, id, render) => {
8671
8679
  return allCommands;
8672
8680
  };
8673
8681
 
8682
+ const getEditor$1 = editorUid => {
8683
+ const instance = get$8(editorUid);
8684
+ if (!instance) {
8685
+ throw new Error(`editor ${editorUid} not found`);
8686
+ }
8687
+ const {
8688
+ newState
8689
+ } = instance;
8690
+ return newState;
8691
+ };
8692
+
8693
+ const setFocus = async focusKey => {
8694
+ await invoke$a('Focus.setFocus', focusKey);
8695
+ };
8696
+ const unsetAdditionalFocus = async focusKey => {
8697
+ if (!focusKey) {
8698
+ return;
8699
+ }
8700
+ // @ts-ignore
8701
+ await invoke$a('Focus.removeAdditionalFocus', focusKey);
8702
+ };
8703
+
8704
+ const FocusEditor = 12;
8705
+ const FocusEditorCompletions = 9;
8706
+ const FocusEditorRename = 11;
8707
+ const FocusEditorText = 12;
8708
+ const FocusFindWidget = 16;
8709
+ const FocusSourceActions = 38;
8710
+ const FocusFindWidgetReplace = 43;
8711
+ const FocusEditorCodeGenerator = 52;
8712
+ const FocusColorPicker = 41;
8713
+
8714
+ const updateEditor = async (editorUid, editor, newEditor) => {
8715
+ if (newEditor === editor) {
8716
+ return;
8717
+ }
8718
+ const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
8719
+ set$8(editorUid, editor, newEditorWithDerivedState);
8720
+ };
8721
+ const applyDocumentEdits = async (editorUid, edits) => {
8722
+ const editor = getEditor$1(editorUid);
8723
+ const newEditor = await applyDocumentEdits$1(editor, edits);
8724
+ await updateEditor(editorUid, editor, newEditor);
8725
+ };
8726
+ const closeFind = async editorUid => {
8727
+ const editor = getEditor$1(editorUid);
8728
+ const newEditor = closeFind$1(editor);
8729
+ await updateEditor(editorUid, editor, newEditor);
8730
+ await setFocus(FocusEditorText);
8731
+ };
8732
+ const getLines = editorUid => {
8733
+ return getEditor$1(editorUid).lines;
8734
+ };
8735
+ const getSelections$1 = editorUid => {
8736
+ return getEditor$1(editorUid).selections;
8737
+ };
8738
+ const setSelections$1 = async (editorUid, selections) => {
8739
+ const editor = getEditor$1(editorUid);
8740
+ const newEditor = {
8741
+ ...editor,
8742
+ selections
8743
+ };
8744
+ await updateEditor(editorUid, editor, newEditor);
8745
+ };
8746
+
8747
+ const getFindWidgetWorkerCommandMap = () => ({
8748
+ 'Editor.applyDocumentEdits': applyDocumentEdits,
8749
+ 'Editor.closeFind2': closeFind,
8750
+ 'Editor.getLines2': getLines,
8751
+ 'Editor.getSelections2': getSelections$1,
8752
+ 'Editor.setSelections2': setSelections$1
8753
+ });
8754
+
8674
8755
  const launchFindWidgetWorker = async () => {
8675
8756
  const name = 'Find Widget Worker';
8676
8757
  const url = 'findWidgetWorkerMain.js';
8677
- return launchWorker(name, url);
8758
+ return launchWorker(name, url, undefined, getFindWidgetWorkerCommandMap());
8678
8759
  };
8679
8760
 
8680
8761
  const rpcId = 9002;
@@ -8799,7 +8880,7 @@ const getEditorByWidgetUid = (widgetUid, widgetId) => {
8799
8880
  }
8800
8881
  return undefined;
8801
8882
  };
8802
- const getEditor$1 = (editorOrUid, widgetId) => {
8883
+ const getEditor = (editorOrUid, widgetId) => {
8803
8884
  if (editorOrUid && editorOrUid.widgets) {
8804
8885
  return editorOrUid;
8805
8886
  }
@@ -8817,7 +8898,7 @@ const createFn = (key, name, widgetId) => {
8817
8898
  return key === 'close' || key === 'handleClickButton' && args.includes(Close);
8818
8899
  };
8819
8900
  const fn = async (editorOrUid, ...args) => {
8820
- const editor = getEditor$1(editorOrUid, widgetId);
8901
+ const editor = getEditor(editorOrUid, widgetId);
8821
8902
  if (!editor) {
8822
8903
  return editorOrUid;
8823
8904
  }
@@ -8858,7 +8939,7 @@ const createFn = (key, name, widgetId) => {
8858
8939
  commands
8859
8940
  };
8860
8941
  const newEditor = updateWidget(latest, widgetId, newState);
8861
- set$8(editor.uid, latest, newEditor);
8942
+ set$8(editor.uid, editor, newEditor);
8862
8943
  return newEditor;
8863
8944
  };
8864
8945
  return fn;
@@ -8895,10 +8976,13 @@ const render$c = widget => {
8895
8976
  const commands = renderFull$4(widget.oldState, widget.newState);
8896
8977
  const wrappedCommands = [];
8897
8978
  const {
8979
+ editorUid,
8898
8980
  uid
8899
8981
  } = widget.newState;
8900
8982
  for (const command of commands) {
8901
- if (commandsToForward$5.includes(command[0])) {
8983
+ if (command[0] === SetFocusContext) {
8984
+ wrappedCommands.push([command[0], editorUid, ...command.slice(1)]);
8985
+ } else if (commandsToForward$5.includes(command[0])) {
8902
8986
  wrappedCommands.push(command);
8903
8987
  } else {
8904
8988
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -9017,22 +9101,11 @@ const create$2 = () => {
9017
9101
  return widget;
9018
9102
  };
9019
9103
 
9020
- const getEditor = editorUid => {
9021
- const instance = get$8(editorUid);
9022
- if (!instance) {
9023
- throw new Error(`editor ${editorUid} not found`);
9024
- }
9025
- const {
9026
- newState
9027
- } = instance;
9028
- return newState;
9029
- };
9030
-
9031
9104
  const loadContent$2 = async (state, parentUid) => {
9032
9105
  const {
9033
9106
  uid
9034
9107
  } = state;
9035
- const editor = getEditor(parentUid);
9108
+ const editor = getEditor$1(parentUid);
9036
9109
  const {
9037
9110
  height,
9038
9111
  width,
@@ -9176,7 +9249,7 @@ const getOrganizeImportEdits = async editor => {
9176
9249
 
9177
9250
  const organizeImports = async editor => {
9178
9251
  const edits = await getOrganizeImportEdits(editor);
9179
- return applyDocumentEdits(editor, edits);
9252
+ return applyDocumentEdits$1(editor, edits);
9180
9253
  };
9181
9254
 
9182
9255
  // @ts-ignore
@@ -11185,7 +11258,7 @@ const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...par
11185
11258
  const isWidget = widget => {
11186
11259
  return widget.id === widgetId;
11187
11260
  };
11188
- const latestEditor = getEditor(editor.uid);
11261
+ const latestEditor = getEditor$1(editor.uid);
11189
11262
  const childIndex1 = latestEditor.widgets.findIndex(isWidget);
11190
11263
  if (childIndex1 === -1) {
11191
11264
  return latestEditor;
@@ -11235,81 +11308,55 @@ const getWordAtOffset = editor => {
11235
11308
  return '';
11236
11309
  };
11237
11310
 
11238
- const setFocus = async focusKey => {
11239
- await invoke$a('Focus.setFocus', focusKey);
11240
- };
11241
- const unsetAdditionalFocus = async focusKey => {
11242
- if (!focusKey) {
11243
- return;
11244
- }
11245
- // @ts-ignore
11246
- await invoke$a('Focus.removeAdditionalFocus', focusKey);
11247
- };
11248
-
11249
- const FocusEditor = 12;
11250
- const FocusEditorCompletions = 9;
11251
- const FocusEditorRename = 11;
11252
- const FocusEditorText = 12;
11253
- const FocusFindWidget = 16;
11254
- const FocusSourceActions = 38;
11255
- const FocusFindWidgetReplace = 43;
11256
- const FocusFindWidgetReplaceButton = 46;
11257
- const FocusFindWidgetReplaceAllButton = 47;
11258
- const FocusFindWidgetCloseButton = 48;
11259
- const FocusFindWidgetNextMatchButton = 49;
11260
- const FocusFindWidgetPreviousMatchButton = 50;
11261
- const FocusEditorCodeGenerator = 52;
11262
- const FocusColorPicker = 41;
11263
-
11264
11311
  const getPositionAtCursor = editorUid => {
11265
- const editor = getEditor(editorUid);
11312
+ const editor = getEditor$1(editorUid);
11266
11313
  return getPositionAtCursor$1(editor);
11267
11314
  };
11268
11315
  const getUri = editorUid => {
11269
- const editor = getEditor(editorUid);
11316
+ const editor = getEditor$1(editorUid);
11270
11317
  return editor.uri;
11271
11318
  };
11272
11319
  const getLanguageId = editorUid => {
11273
- const editor = getEditor(editorUid);
11320
+ const editor = getEditor$1(editorUid);
11274
11321
  return editor.languageId;
11275
11322
  };
11276
11323
  const getOffsetAtCursor = editorUid => {
11277
- const editor = getEditor(editorUid);
11324
+ const editor = getEditor$1(editorUid);
11278
11325
  return getOffsetAtCursor$1(editor);
11279
11326
  };
11280
11327
  const getWordAt = (editorUid, rowIndex, columnIndex) => {
11281
- const editor = getEditor(editorUid);
11328
+ const editor = getEditor$1(editorUid);
11282
11329
  const {
11283
11330
  word
11284
11331
  } = getWordAt$1(editor, rowIndex, columnIndex);
11285
11332
  return word;
11286
11333
  };
11287
11334
  const getWordAtOffset2 = editorUid => {
11288
- const editor = getEditor(editorUid);
11335
+ const editor = getEditor$1(editorUid);
11289
11336
  const word = getWordAtOffset(editor);
11290
11337
  return word;
11291
11338
  };
11292
11339
  const getWordBefore2 = (editorUid, rowIndex, columnIndex) => {
11293
- const editor = getEditor(editorUid);
11340
+ const editor = getEditor$1(editorUid);
11294
11341
  const word = getWordBefore(editor, rowIndex, columnIndex);
11295
11342
  return word;
11296
11343
  };
11297
11344
  const getLines2 = editorUid => {
11298
- const editor = getEditor(editorUid);
11345
+ const editor = getEditor$1(editorUid);
11299
11346
  const {
11300
11347
  lines
11301
11348
  } = editor;
11302
11349
  return lines;
11303
11350
  };
11304
11351
  const getSelections2 = editorUid => {
11305
- const editor = getEditor(editorUid);
11352
+ const editor = getEditor$1(editorUid);
11306
11353
  const {
11307
11354
  selections
11308
11355
  } = editor;
11309
11356
  return selections;
11310
11357
  };
11311
11358
  const setSelections2 = async (editorUid, selections) => {
11312
- const editor = getEditor(editorUid);
11359
+ const editor = getEditor$1(editorUid);
11313
11360
  const newEditor = {
11314
11361
  ...editor,
11315
11362
  selections
@@ -11318,7 +11365,7 @@ const setSelections2 = async (editorUid, selections) => {
11318
11365
  set$8(editorUid, editor, newEditorWithDerivedState);
11319
11366
  };
11320
11367
  const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
11321
- const editor = getEditor(editorUid);
11368
+ const editor = getEditor$1(editorUid);
11322
11369
  const widgetRevision = next(editorUid);
11323
11370
  const invoke = getWidgetInvoke(widgetId);
11324
11371
  const {
@@ -11348,7 +11395,7 @@ const closeFind2 = async editorUid => {
11348
11395
  await closeWidget2(editorUid, Find, 'FindWidget', 0);
11349
11396
  };
11350
11397
  const applyEdits2 = async (editorUid, edits) => {
11351
- const editor = getEditor(editorUid);
11398
+ const editor = getEditor$1(editorUid);
11352
11399
  const newEditor = await applyEdit(editor, edits);
11353
11400
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
11354
11401
  set$8(editorUid, editor, newEditorWithDerivedState);
@@ -11358,7 +11405,7 @@ const getSourceActions = async editorUid => {
11358
11405
  return actions;
11359
11406
  };
11360
11407
  const getDiagnostics$1 = async editorUid => {
11361
- const editor = getEditor(editorUid);
11408
+ const editor = getEditor$1(editorUid);
11362
11409
  const {
11363
11410
  diagnostics
11364
11411
  } = editor;
@@ -11369,6 +11416,18 @@ const ensure = async (fontName, fontUrl) => {
11369
11416
  await invoke$b('TextMeasurement.ensureFont', fontName, fontUrl);
11370
11417
  };
11371
11418
 
11419
+ const findWidgetFocusContexts = [FindWidget, FocusFindWidgetReplace$1, FocusFindWidgetOptions, FocusFindWidgetToggleReplace, FocusFindWidgetPreviousMatchButton, FocusFindWidgetNextMatchButton, FocusFindWidgetCloseButton, FocusFindWidgetReplaceButton, FocusFindWidgetReplaceAllButton];
11420
+ const getFindWidgetFocusKeyBindings = () => {
11421
+ return findWidgetFocusContexts.flatMap(focusContext => [{
11422
+ command: 'FindWidget.focusNextElement',
11423
+ key: Tab$1,
11424
+ when: focusContext
11425
+ }, {
11426
+ command: 'FindWidget.focusPreviousElement',
11427
+ key: Shift | Tab$1,
11428
+ when: focusContext
11429
+ }]);
11430
+ };
11372
11431
  const getKeyBindings = () => {
11373
11432
  return [{
11374
11433
  command: 'Editor.closeColorPicker',
@@ -11398,6 +11457,10 @@ const getKeyBindings = () => {
11398
11457
  command: 'EditorSourceActions.selectCurrent',
11399
11458
  key: Enter,
11400
11459
  when: FocusSourceActions
11460
+ }, {
11461
+ command: 'FindWidget.replace',
11462
+ key: Enter,
11463
+ when: FocusFindWidgetReplace
11401
11464
  }, {
11402
11465
  command: 'FindWidget.focusNext',
11403
11466
  key: Enter,
@@ -11418,62 +11481,10 @@ const getKeyBindings = () => {
11418
11481
  command: 'FindWidget.focusNext',
11419
11482
  key: F4,
11420
11483
  when: FocusFindWidget
11421
- }, {
11422
- command: 'FindWidget.focusToggleReplace',
11423
- key: Shift | Tab$1,
11424
- when: FocusFindWidget
11425
- }, {
11426
- command: 'FindWidget.focusReplace',
11427
- key: Tab$1,
11428
- when: FocusFindWidget
11429
- }, {
11430
- command: 'FindWidget.focusPreviousMatchButton',
11431
- key: Tab$1,
11432
- when: FocusFindWidgetReplace
11433
- }, {
11484
+ }, ...getFindWidgetFocusKeyBindings(), {
11434
11485
  command: 'FindWidget.replaceAll',
11435
11486
  key: Alt$1 | CtrlCmd | Enter,
11436
11487
  when: FocusFindWidgetReplace
11437
- }, {
11438
- command: 'FindWidget.focusNextMatchButton',
11439
- key: Tab$1,
11440
- when: FocusFindWidgetPreviousMatchButton
11441
- }, {
11442
- command: 'FindWidget.focusReplace',
11443
- key: Shift | Tab$1,
11444
- when: FocusFindWidgetPreviousMatchButton
11445
- }, {
11446
- command: 'FindWidget.focusPreviousMatchButton',
11447
- key: Shift | Tab$1,
11448
- when: FocusFindWidgetNextMatchButton
11449
- }, {
11450
- command: 'FindWidget.focusCloseButton',
11451
- key: Tab$1,
11452
- when: FocusFindWidgetNextMatchButton
11453
- }, {
11454
- command: 'FindWidget.focusNextMatchButton',
11455
- key: Shift | Tab$1,
11456
- when: FocusFindWidgetCloseButton
11457
- }, {
11458
- command: 'FindWidget.focusReplaceButton',
11459
- key: Tab$1,
11460
- when: FocusFindWidgetCloseButton
11461
- }, {
11462
- command: 'FindWidget.focusFind',
11463
- key: Shift | Tab$1,
11464
- when: FocusFindWidgetReplace
11465
- }, {
11466
- command: 'FindWidget.focusReplaceAllButton',
11467
- key: Tab$1,
11468
- when: FocusFindWidgetReplaceButton
11469
- }, {
11470
- command: 'FindWidget.focusCloseButton',
11471
- key: Shift | Tab$1,
11472
- when: FocusFindWidgetReplaceButton
11473
- }, {
11474
- command: 'FindWidget.focusReplaceButton',
11475
- key: Shift | Tab$1,
11476
- when: FocusFindWidgetReplaceAllButton
11477
11488
  }, {
11478
11489
  command: 'EditorCompletion.focusNext',
11479
11490
  key: DownArrow,
@@ -11951,7 +11962,7 @@ const getQuickPickMenuEntries = () => {
11951
11962
  };
11952
11963
 
11953
11964
  const getSelections = editorUid => {
11954
- const editor = getEditor(editorUid);
11965
+ const editor = getEditor$1(editorUid);
11955
11966
  const {
11956
11967
  selections
11957
11968
  } = editor;
@@ -11960,7 +11971,7 @@ const getSelections = editorUid => {
11960
11971
 
11961
11972
  const getText = editorUid => {
11962
11973
  number(editorUid);
11963
- const editor = getEditor(editorUid);
11974
+ const editor = getEditor$1(editorUid);
11964
11975
  const {
11965
11976
  lines
11966
11977
  } = editor;
@@ -13720,7 +13731,7 @@ const commandMap = {
13720
13731
  'ColorPicker.loadContent': loadContent$3,
13721
13732
  'Editor.addCursorAbove': wrapCommand(addCursorAbove),
13722
13733
  'Editor.addCursorBelow': wrapCommand(addCursorBelow),
13723
- 'Editor.applyDocumentEdits': wrapCommand(applyDocumentEdits),
13734
+ 'Editor.applyDocumentEdits': wrapCommand(applyDocumentEdits$1),
13724
13735
  'Editor.applyEdit': wrapCommand(applyEdit),
13725
13736
  'Editor.applyEdit2': applyEdits2,
13726
13737
  'Editor.applyWorkspaceEdit': wrapCommand(applyWorkspaceEdit),
@@ -13729,7 +13740,7 @@ const commandMap = {
13729
13740
  'Editor.closeCodeGenerator': wrapCommand(closeCodeGenerator),
13730
13741
  'Editor.closeColorPicker': wrapCommand(closeColorPicker),
13731
13742
  'Editor.closeCompletion': wrapCommand(closeCompletion),
13732
- 'Editor.closeFind': wrapCommand(closeFind),
13743
+ 'Editor.closeFind': wrapCommand(closeFind$1),
13733
13744
  'Editor.closeFind2': closeFind2,
13734
13745
  'Editor.closeRename': wrapCommand(closeRename),
13735
13746
  'Editor.closeSourceAction': wrapCommand(closeSourceAction),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.29.2",
3
+ "version": "19.29.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"