@lvce-editor/editor-worker 5.0.0 → 5.2.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.
@@ -18,6 +18,11 @@ const execute$1 = (command, ...args) => {
18
18
  return fn(...args);
19
19
  };
20
20
 
21
+ const codeGeneratorAccept = state => {
22
+ // TODO close code generator widget
23
+ return state;
24
+ };
25
+
21
26
  let AssertionError$1 = class AssertionError extends Error {
22
27
  constructor(message) {
23
28
  super(message);
@@ -273,6 +278,17 @@ const joinLines$2 = lines => {
273
278
  return lines.join('\n');
274
279
  };
275
280
 
281
+ const RE_WHITESPACE = /^\s+/;
282
+
283
+ // TODO this doesn't belong here
284
+ const getIndent = line => {
285
+ const whitespaceMatch = line.match(RE_WHITESPACE);
286
+ if (!whitespaceMatch) {
287
+ return '';
288
+ }
289
+ return whitespaceMatch[0];
290
+ };
291
+
276
292
  // TODO have function for single edit (most common, avoid one array)
277
293
  const applyEdits = (textDocument, changes) => {
278
294
  object(textDocument);
@@ -330,7 +346,7 @@ const applyEdits = (textDocument, changes) => {
330
346
  // TODO only do this once after all edits, not inside loop
331
347
  textDocument.maxLineY = Math.min(textDocument.numberOfVisibleLines, textDocument.lines.length);
332
348
  }
333
- linesDelta += Math.max(inserted.length - deleted.length, 0);
349
+ linesDelta += inserted.length - deleted.length;
334
350
  }
335
351
  return newLines;
336
352
  };
@@ -340,16 +356,6 @@ const getLine = (textDocument, index) => {
340
356
  const getText$1 = state => {
341
357
  return joinLines$2(state.lines);
342
358
  };
343
- const RE_WHITESPACE = /^\s+/;
344
-
345
- // TODO this doesn't belong here
346
- const getIndent = line => {
347
- const whitespaceMatch = line.match(RE_WHITESPACE);
348
- if (!whitespaceMatch) {
349
- return '';
350
- }
351
- return whitespaceMatch[0];
352
- };
353
359
 
354
360
  // TDOO this doesn;t belong here
355
361
  const getSelectionText = (textDocument, range) => {
@@ -416,11 +422,6 @@ const positionAt = (textDocument, offset) => {
416
422
  } else {
417
423
  columnIndex = currentOffset - offset;
418
424
  }
419
- console.log({
420
- rowIndex,
421
- columnIndex
422
- });
423
- // TODO
424
425
  return {
425
426
  rowIndex,
426
427
  columnIndex
@@ -1038,6 +1039,13 @@ const set$6 = (id, oldEditor, newEditor) => {
1038
1039
  };
1039
1040
  };
1040
1041
 
1042
+ const CompletionExecute = 'ExtensionHostCompletion.execute';
1043
+ const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
1044
+ const HoverExecute = 'ExtensionHostHover.execute';
1045
+ const RenameExecuteRename = 'ExtensionHostRename.executeRenameProvider';
1046
+ const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
1047
+ const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
1048
+
1041
1049
  const Two = '2.0';
1042
1050
  class AssertionError extends Error {
1043
1051
  constructor(message) {
@@ -1722,13 +1730,6 @@ const {
1722
1730
  invoke: invoke$2
1723
1731
  } = createRpc(ExtensionHostWorker);
1724
1732
 
1725
- const CompletionExecute = 'ExtensionHostCompletion.execute';
1726
- const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
1727
- const HoverExecute = 'ExtensionHostHover.execute';
1728
- const RenameExecuteRename = 'ExtensionHostRename.executeRenameProvider';
1729
- const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
1730
- const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
1731
-
1732
1733
  const ColorPicker$2 = 41;
1733
1734
  const CompletionDetail$1 = 999;
1734
1735
  const EditorCompletion = 9;
@@ -1750,6 +1751,90 @@ const measureCharacterWidth = (fontWeight, fontSize, fontFamily, letterSpacing)
1750
1751
  return measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
1751
1752
  };
1752
1753
 
1754
+ const OnRename = 'onRename';
1755
+ const OnCompletion = 'onCompletion';
1756
+ const OnDiagnostic = 'onDiagnostic';
1757
+ const OnHover = 'onHover';
1758
+ const OnTabCompletion = 'onTabCompletion';
1759
+
1760
+ // TODO add tests for this
1761
+ const activateByEvent = async event => {
1762
+ await invoke$3('ExtensionHostManagement.activateByEvent', event);
1763
+ };
1764
+
1765
+ const execute = async ({
1766
+ editor,
1767
+ args,
1768
+ event,
1769
+ method,
1770
+ noProviderFoundMessage,
1771
+ noProviderFoundResult = undefined
1772
+ }) => {
1773
+ const fullEvent = `${event}:${editor.languageId}`;
1774
+ await activateByEvent(fullEvent);
1775
+ const result = await invoke$2(method, editor.uid, ...args);
1776
+ return result;
1777
+ };
1778
+
1779
+ const combineResults$3 = results => {
1780
+ return results[0];
1781
+ };
1782
+ const executeDiagnosticProvider = editor => {
1783
+ return execute({
1784
+ editor,
1785
+ event: OnDiagnostic,
1786
+ method: 'ExtensionHost.executeDiagnosticProvider',
1787
+ args: [],
1788
+ noProviderFoundMessage: 'no diagnostic provider found',
1789
+ noProviderResult: [],
1790
+ combineResults: combineResults$3
1791
+ });
1792
+ };
1793
+
1794
+ const getDiagnosticType = diagnostic => {
1795
+ return diagnostic.type;
1796
+ };
1797
+
1798
+ const getVisibleDiagnostics = (editor, diagnostics) => {
1799
+ const visibleDiagnostics = [];
1800
+ for (const diagnostic of diagnostics) {
1801
+ visibleDiagnostics.push({
1802
+ x: diagnostic.columnIndex * editor.columnWidth,
1803
+ y: (diagnostic.rowIndex - editor.minLineY) * editor.rowHeight,
1804
+ width: 20,
1805
+ height: editor.rowHeight,
1806
+ type: getDiagnosticType(diagnostic)
1807
+ });
1808
+ }
1809
+ return visibleDiagnostics;
1810
+ };
1811
+
1812
+ const updateDiagnostics = async uid => {
1813
+ try {
1814
+ // TODO handle error
1815
+ // TODO handle race condition
1816
+ const {
1817
+ newState
1818
+ } = get$6(uid);
1819
+ // TODO request diagnostics from extension host
1820
+ const diagnostics = await executeDiagnosticProvider(newState);
1821
+ const latest = get$6(uid);
1822
+ if (!latest) {
1823
+ return;
1824
+ }
1825
+ const decorations = getVisibleDiagnostics(latest.newState, diagnostics);
1826
+ const newEditor = {
1827
+ ...latest.newState,
1828
+ diagnostics,
1829
+ decorations
1830
+ };
1831
+ set$6(uid, latest.oldState, newEditor);
1832
+ await invoke$3('Editor.rerender', uid);
1833
+ } catch (error) {
1834
+ console.error(`Failed to update diagnostics: ${error}`);
1835
+ }
1836
+ };
1837
+
1753
1838
  const emptyEditor = {
1754
1839
  uri: '',
1755
1840
  languageId: '',
@@ -1800,7 +1885,8 @@ const createEditor = async ({
1800
1885
  fontWeight,
1801
1886
  fontFamily,
1802
1887
  isMonospaceFont,
1803
- uri
1888
+ uri,
1889
+ diagnosticsEnabled
1804
1890
  }) => {
1805
1891
  number$1(id);
1806
1892
  string(content);
@@ -1860,7 +1946,8 @@ const createEditor = async ({
1860
1946
  uid: id,
1861
1947
  id,
1862
1948
  widgets: [],
1863
- focusKey: Empty
1949
+ focusKey: Empty,
1950
+ diagnosticsEnabled
1864
1951
  };
1865
1952
  // TODO avoid creating intermediate editors here
1866
1953
  const newEditor1 = setBounds(editor, x, y, width, height, 9);
@@ -1872,6 +1959,9 @@ const createEditor = async ({
1872
1959
  };
1873
1960
  set$6(id, emptyEditor, newEditor4);
1874
1961
  await invoke$2(TextDocumentSyncFull, uri, id, languageId, content);
1962
+ if (diagnosticsEnabled) {
1963
+ updateDiagnostics(editor.uid);
1964
+ }
1875
1965
  };
1876
1966
 
1877
1967
  // @ts-ignore
@@ -2264,6 +2354,16 @@ const cancelSelection = editor => {
2264
2354
  return scheduleSelections(editor, newSelections);
2265
2355
  };
2266
2356
 
2357
+ // TODO use numeric widget id
2358
+ const CodeGenerator = 1;
2359
+ const ColorPicker$1 = 2;
2360
+ const Completion = 3;
2361
+ const CompletionDetail = 4;
2362
+ const Find = 5;
2363
+ const Hover = 6;
2364
+ const Rename = 7;
2365
+ const SourceAction = 8;
2366
+
2267
2367
  const getIndex = (widgets, id) => {
2268
2368
  for (const [i, widget] of widgets.entries()) {
2269
2369
  if (widget.id === id) {
@@ -2278,15 +2378,24 @@ const removeEditorWidget = (widgets, id) => {
2278
2378
  return newWidgets;
2279
2379
  };
2280
2380
 
2281
- // TODO use numeric widget id
2282
- const CodeGenerator = 1;
2283
- const ColorPicker$1 = 2;
2284
- const Completion = 3;
2285
- const CompletionDetail = 4;
2286
- const Find = 5;
2287
- const Hover = 6;
2288
- const Rename = 7;
2289
- const SourceAction = 8;
2381
+ const isMatchingWidget$2 = widget => {
2382
+ return widget.id === CodeGenerator;
2383
+ };
2384
+ const closeCodeGenerator = editor => {
2385
+ const {
2386
+ widgets
2387
+ } = editor;
2388
+ const index = widgets.findIndex(isMatchingWidget$2);
2389
+ if (index === -1) {
2390
+ return editor;
2391
+ }
2392
+ const newWidgets = removeEditorWidget(widgets, CodeGenerator);
2393
+ return {
2394
+ ...editor,
2395
+ widgets: newWidgets,
2396
+ focused: true
2397
+ };
2398
+ };
2290
2399
 
2291
2400
  const isCompletionWidget = widget => {
2292
2401
  return widget.id === Completion;
@@ -2306,14 +2415,14 @@ const closeCompletion = editor => {
2306
2415
  };
2307
2416
  };
2308
2417
 
2309
- const isMatchingWidget$2 = widget => {
2418
+ const isMatchingWidget$1 = widget => {
2310
2419
  return widget.id === Find;
2311
2420
  };
2312
2421
  const closeFind = editor => {
2313
2422
  const {
2314
2423
  widgets
2315
2424
  } = editor;
2316
- const index = widgets.findIndex(isMatchingWidget$2);
2425
+ const index = widgets.findIndex(isMatchingWidget$1);
2317
2426
  if (index === -1) {
2318
2427
  return editor;
2319
2428
  }
@@ -2345,14 +2454,14 @@ const closeRename = editor => {
2345
2454
  };
2346
2455
  };
2347
2456
 
2348
- const isMatchingWidget$1 = widget => {
2457
+ const isMatchingWidget = widget => {
2349
2458
  return widget.id === SourceAction;
2350
2459
  };
2351
2460
  const closeSourceAction = editor => {
2352
2461
  const {
2353
2462
  widgets
2354
2463
  } = editor;
2355
- const index = widgets.findIndex(isMatchingWidget$1);
2464
+ const index = widgets.findIndex(isMatchingWidget);
2356
2465
  if (index === -1) {
2357
2466
  return editor;
2358
2467
  }
@@ -2845,7 +2954,6 @@ const wordPartRight = (line, columnIndex) => {
2845
2954
  return tryRegexArray(partialLine, ARRAY_PARTIAL_WORD_RIGHT_2);
2846
2955
  };
2847
2956
 
2848
- // @ts-ignore
2849
2957
  const cursorCharacterLeft = editor => {
2850
2958
  return editorCursorHorizontalLeft(editor, characterLeft);
2851
2959
  };
@@ -3190,28 +3298,22 @@ const findAllReferences = async editor => {
3190
3298
  return editor;
3191
3299
  };
3192
3300
 
3193
- // TODO format should be executed in parallel with saving
3194
- // -> fast save, no need to wait for formatting
3195
- // -> fast formatting, no need to wait for save
3196
-
3197
- // TODO should format on save when closing/switching editor?
3198
-
3199
- // TODO format with cursor
3200
- // TODO should be in editor folder
3201
-
3202
- const format$1 = async editor => {
3203
- const edits = await invoke$3('Format.format', editor);
3301
+ const getFormattingEdits = async editor => {
3302
+ const edits = await execute({
3303
+ editor,
3304
+ event: 'onFormatting',
3305
+ method: 'ExtensionHostFormatting.executeFormattingProvider',
3306
+ args: []
3307
+ });
3204
3308
  return edits;
3205
3309
  };
3206
3310
 
3207
- const warn = (...args) => {
3208
- console.warn(...args);
3209
- };
3210
- const error = (...args) => {
3211
- console.error(...args);
3311
+ const expectedErrorMessage$1 = 'Failed to execute formatting provider: FormattingError:';
3312
+ const isFormattingError = error => {
3313
+ // @ts-ignore
3314
+ return error && error instanceof Error && error.message.startsWith(expectedErrorMessage$1);
3212
3315
  };
3213
3316
 
3214
- // @ts-ignore
3215
3317
  const getDocumentEdits = (editor, edits) => {
3216
3318
  const documentEdits = [];
3217
3319
  for (const edit of edits) {
@@ -3236,7 +3338,13 @@ const getDocumentEdits = (editor, edits) => {
3236
3338
  return documentEdits;
3237
3339
  };
3238
3340
 
3239
- // @ts-ignore
3341
+ const warn = (...args) => {
3342
+ console.warn(...args);
3343
+ };
3344
+ const error = (...args) => {
3345
+ console.error(...args);
3346
+ };
3347
+
3240
3348
  const applyDocumentEdits = (editor, edits) => {
3241
3349
  if (!Array.isArray(edits)) {
3242
3350
  warn('something is wrong with format on save', edits);
@@ -3250,14 +3358,11 @@ const applyDocumentEdits = (editor, edits) => {
3250
3358
  };
3251
3359
 
3252
3360
  const expectedErrorMessage = 'Failed to execute formatting provider: FormattingError:';
3253
- const isFormattingError = error => {
3254
- return error && error instanceof Error && error.message.startsWith(expectedErrorMessage);
3255
- };
3256
3361
 
3257
3362
  // TODO also format with cursor
3258
3363
  const format = async editor => {
3259
3364
  try {
3260
- const edits = await format$1(editor);
3365
+ const edits = await getFormattingEdits(editor);
3261
3366
  return applyDocumentEdits(editor, edits);
3262
3367
  } catch (error) {
3263
3368
  if (isFormattingError(error)) {
@@ -3267,6 +3372,8 @@ const format = async editor => {
3267
3372
  return editor;
3268
3373
  }
3269
3374
  console.error(error);
3375
+
3376
+ // TODO configure editor message as widget
3270
3377
  const displayErrorMessage = `${error}`;
3271
3378
  await editorShowMessage(editor, 0, 0, displayErrorMessage, true);
3272
3379
  return editor;
@@ -4507,7 +4614,54 @@ const moveSelectionPx = (editor, x, y) => {
4507
4614
  return editorMoveSelection(editor, position);
4508
4615
  };
4509
4616
 
4617
+ const User = 1;
4618
+ const Script = 2;
4619
+ const Unknown$1 = 0;
4620
+
4510
4621
  const create$6 = () => {
4622
+ const completionUid = create$8();
4623
+ const widget = {
4624
+ id: CodeGenerator,
4625
+ oldState: {
4626
+ uid: completionUid,
4627
+ questions: [],
4628
+ x: 0,
4629
+ y: 0,
4630
+ width: 0,
4631
+ height: 0,
4632
+ focused: false,
4633
+ focusSource: Unknown$1
4634
+ },
4635
+ newState: {
4636
+ uid: completionUid,
4637
+ questions: [],
4638
+ x: 0,
4639
+ y: 0,
4640
+ width: 0,
4641
+ height: 0,
4642
+ focused: true,
4643
+ focusSource: Script
4644
+ }
4645
+ };
4646
+ return widget;
4647
+ };
4648
+
4649
+ const newStateGenerator$1 = async state => {
4650
+ const latestState = {
4651
+ ...state,
4652
+ x: 100,
4653
+ y: 100,
4654
+ width: 150,
4655
+ height: 45
4656
+ };
4657
+ return latestState;
4658
+ };
4659
+ const openCodeGenerator = async editor => {
4660
+ const fullFocus = true;
4661
+ return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$6, newStateGenerator$1, fullFocus);
4662
+ };
4663
+
4664
+ const create$5 = () => {
4511
4665
  const completionUid = create$8();
4512
4666
  const completionWidget = {
4513
4667
  id: Completion,
@@ -4549,30 +4703,6 @@ const create$6 = () => {
4549
4703
  return completionWidget;
4550
4704
  };
4551
4705
 
4552
- const OnRename = 'onRename';
4553
- const OnCompletion = 'onCompletion';
4554
- const OnHover = 'onHover';
4555
- const OnTabCompletion = 'onTabCompletion';
4556
-
4557
- // TODO add tests for this
4558
- const activateByEvent = async event => {
4559
- await invoke$3('ExtensionHostManagement.activateByEvent', event);
4560
- };
4561
-
4562
- const execute = async ({
4563
- editor,
4564
- args,
4565
- event,
4566
- method,
4567
- noProviderFoundMessage,
4568
- noProviderFoundResult = undefined
4569
- }) => {
4570
- const fullEvent = `${event}:${editor.languageId}`;
4571
- await activateByEvent(fullEvent);
4572
- const result = await invoke$2(method, editor.uid, ...args);
4573
- return result;
4574
- };
4575
-
4576
4706
  const combineResults$2 = results => {
4577
4707
  return results[0] ?? [];
4578
4708
  };
@@ -5023,7 +5153,7 @@ const openCompletion = async editor => {
5023
5153
  if (hasWidget(widgets, Completion)) {
5024
5154
  return editor;
5025
5155
  }
5026
- const completionWidget = create$6();
5156
+ const completionWidget = create$5();
5027
5157
  const newWidgets = [...widgets, completionWidget];
5028
5158
  const newEditor = {
5029
5159
  ...editor,
@@ -5048,11 +5178,7 @@ const openCompletion = async editor => {
5048
5178
  };
5049
5179
  };
5050
5180
 
5051
- const User = 1;
5052
- const Script = 2;
5053
- const Unknown$1 = 0;
5054
-
5055
- const create$5 = () => {
5181
+ const create$4 = () => {
5056
5182
  const uid = create$8();
5057
5183
  const widget = {
5058
5184
  id: Find,
@@ -5458,7 +5584,7 @@ const openFind2 = async editor => {
5458
5584
  return latestState;
5459
5585
  };
5460
5586
  const fullFocus = true;
5461
- return addWidgetToEditor(Find, FindWidget, editor, create$5, newStateGenerator, fullFocus);
5587
+ return addWidgetToEditor(Find, FindWidget, editor, create$4, newStateGenerator, fullFocus);
5462
5588
  };
5463
5589
 
5464
5590
  const openFind = async state => {
@@ -5480,7 +5606,7 @@ const getRenamePosition = editor => {
5480
5606
  };
5481
5607
  };
5482
5608
 
5483
- const create$4 = () => {
5609
+ const create$3 = () => {
5484
5610
  const completionUid = create$8();
5485
5611
  const renameWidget = {
5486
5612
  id: Rename,
@@ -5541,12 +5667,21 @@ const openRename = async editor => {
5541
5667
  return latestState;
5542
5668
  };
5543
5669
  const fullFocus = true;
5544
- return addWidgetToEditor(Rename, FocusEditorRename, editor, create$4, newStateGenerator, fullFocus);
5670
+ return addWidgetToEditor(Rename, FocusEditorRename, editor, create$3, newStateGenerator, fullFocus);
5671
+ };
5672
+
5673
+ const getOrganizeImportEdits = async editor => {
5674
+ const edits = await execute({
5675
+ editor,
5676
+ event: 'onLanguage',
5677
+ method: 'ExtensionHostOrganizeImports.execute',
5678
+ args: []
5679
+ });
5680
+ return edits;
5545
5681
  };
5546
5682
 
5547
5683
  const organizeImports = async editor => {
5548
- // TODO ask extension host worker directly
5549
- const edits = await invoke$3('ExtensionHostOrganizeImports.organizeImports', editor);
5684
+ const edits = await getOrganizeImportEdits(editor);
5550
5685
  return applyDocumentEdits(editor, edits);
5551
5686
  };
5552
5687
 
@@ -6428,7 +6563,7 @@ const showHover = async state => {
6428
6563
  return state;
6429
6564
  };
6430
6565
 
6431
- const create$3 = () => {
6566
+ const create$2 = () => {
6432
6567
  const uid = create$8();
6433
6568
  const widget = {
6434
6569
  id: Hover,
@@ -6694,11 +6829,11 @@ const loadHoverContent = async state => {
6694
6829
  };
6695
6830
  };
6696
6831
 
6697
- const newStateGenerator$1 = async state => {
6832
+ const newStateGenerator = async state => {
6698
6833
  return loadHoverContent(state);
6699
6834
  };
6700
6835
  const showHover2 = async editor => {
6701
- return addWidgetToEditor(Hover, FocusEditorHover, editor, create$3, newStateGenerator$1);
6836
+ return addWidgetToEditor(Hover, FocusEditorHover, editor, create$2, newStateGenerator);
6702
6837
  };
6703
6838
 
6704
6839
  // TODO ask extension host worker instead
@@ -6751,7 +6886,7 @@ const loadSourceActions = async (editor, state) => {
6751
6886
  };
6752
6887
  };
6753
6888
 
6754
- const create$2 = () => {
6889
+ const create$1 = () => {
6755
6890
  const completionUid = create$8();
6756
6891
  const widget = {
6757
6892
  id: SourceAction,
@@ -6783,7 +6918,7 @@ const showSourceActions = async editor => {
6783
6918
  const newStateGenerator = async state => {
6784
6919
  return loadSourceActions(editor, state);
6785
6920
  };
6786
- return addWidgetToEditor(SourceAction, SourceActions, editor, create$2, newStateGenerator);
6921
+ return addWidgetToEditor(SourceAction, SourceActions, editor, create$1, newStateGenerator);
6787
6922
  };
6788
6923
 
6789
6924
  const compareString = (a, b) => {
@@ -7662,7 +7797,7 @@ const handelWheel = (state, deltaMode, deltaY) => {
7662
7797
  return newState;
7663
7798
  };
7664
7799
 
7665
- const create$1 = () => {
7800
+ const create = () => {
7666
7801
  const completionUid = create$8();
7667
7802
  const completionWidget = {
7668
7803
  id: CompletionDetail,
@@ -7716,7 +7851,7 @@ const openDetails = editor => {
7716
7851
  };
7717
7852
  return newestState;
7718
7853
  };
7719
- return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create$1, newStateGenerator);
7854
+ return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create, newStateGenerator);
7720
7855
  };
7721
7856
 
7722
7857
  const getEdits = async (editor, completionItem) => {
@@ -7855,6 +7990,8 @@ const ColorPickerDark = 'ColorPickerDark';
7855
7990
  const ColorPickerLight = 'ColorPickerLight';
7856
7991
  const ColorPickerRectangle = 'ColorPickerRectangle';
7857
7992
  const ColorPickerSlider = 'ColorPickerSlider';
7993
+ const DiagnosticError = 'DiagnosticError';
7994
+ const DiagnosticWarning = 'DiagnosticWarning';
7858
7995
  const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
7859
7996
  const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
7860
7997
  const CompletionDetailContent = 'CompletionDetailContent';
@@ -7889,6 +8026,8 @@ const MaskIcon = 'MaskIcon';
7889
8026
  const MaskIconSymbolFile = 'MaskIconSymbolFile';
7890
8027
  const MultilineInputBox = 'MultilineInputBox';
7891
8028
  const SearchField = 'SearchField';
8029
+ const SearchFieldButton = 'SearchFieldButton';
8030
+ const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
7892
8031
  const SearchFieldButtons = 'SearchFieldButtons';
7893
8032
  const SourceActionHeading = 'SourceActionHeading';
7894
8033
  const SourceActionIcon = 'SourceActionIcon';
@@ -8127,6 +8266,11 @@ const handleBlur = editor => {
8127
8266
  return closeRename(editor);
8128
8267
  };
8129
8268
 
8269
+ const rerender = editor => {
8270
+ // TODO avoid slow clone
8271
+ return structuredClone(editor);
8272
+ };
8273
+
8130
8274
  const focusIndex = (state, index) => {
8131
8275
  const newState = {
8132
8276
  ...state,
@@ -8338,49 +8482,6 @@ const moveLineDown = editor => {
8338
8482
  return editor;
8339
8483
  };
8340
8484
 
8341
- const create = () => {
8342
- const completionUid = create$8();
8343
- const widget = {
8344
- id: CodeGenerator,
8345
- oldState: {
8346
- uid: completionUid,
8347
- questions: [],
8348
- x: 0,
8349
- y: 0,
8350
- width: 0,
8351
- height: 0,
8352
- focused: false,
8353
- focusSource: Unknown$1
8354
- },
8355
- newState: {
8356
- uid: completionUid,
8357
- questions: [],
8358
- x: 0,
8359
- y: 0,
8360
- width: 0,
8361
- height: 0,
8362
- focused: true,
8363
- focusSource: Script
8364
- }
8365
- };
8366
- return widget;
8367
- };
8368
-
8369
- const newStateGenerator = async state => {
8370
- const latestState = {
8371
- ...state,
8372
- x: 100,
8373
- y: 100,
8374
- width: 150,
8375
- height: 45
8376
- };
8377
- return latestState;
8378
- };
8379
- const openCodeGenerator = async editor => {
8380
- const fullFocus = true;
8381
- return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create, newStateGenerator, fullFocus);
8382
- };
8383
-
8384
8485
  // TODO handle multiple cursors
8385
8486
  const moveLineUp = editor => {
8386
8487
  // const rowIndex = editor.cursor.rowIndex
@@ -8905,20 +9006,25 @@ const getCursorsVirtualDom = cursors => {
8905
9006
  return dom;
8906
9007
  };
8907
9008
 
9009
+ // TODO use numeric value
8908
9010
  const Error$1 = 'error';
8909
9011
  const Warning = 'warning';
8910
9012
 
8911
9013
  const getDiagnosticClassName = type => {
8912
- // TODO use classnames enum
8913
9014
  switch (type) {
8914
9015
  case Error$1:
8915
- return 'DiagnosticError';
9016
+ return DiagnosticError;
8916
9017
  case Warning:
8917
- return 'DiagnosticWarning';
9018
+ return DiagnosticWarning;
8918
9019
  default:
8919
- return 'DiagnosticError';
9020
+ return DiagnosticError;
8920
9021
  }
8921
9022
  };
9023
+
9024
+ const mergeClassNames = (...classNames) => {
9025
+ return classNames.filter(Boolean).join(' ');
9026
+ };
9027
+
8922
9028
  const getDiagnosticVirtualDom = diagnostic => {
8923
9029
  const {
8924
9030
  x,
@@ -8930,7 +9036,7 @@ const getDiagnosticVirtualDom = diagnostic => {
8930
9036
  const extraClassName = getDiagnosticClassName(type);
8931
9037
  return [{
8932
9038
  type: Div,
8933
- className: `${Diagnostic} ${extraClassName}`,
9039
+ className: mergeClassNames(Diagnostic, extraClassName),
8934
9040
  width,
8935
9041
  height,
8936
9042
  top: y,
@@ -9220,25 +9326,6 @@ const renderEditor = async id => {
9220
9326
  return commands;
9221
9327
  };
9222
9328
 
9223
- const isMatchingWidget = widget => {
9224
- return widget.id === CodeGenerator;
9225
- };
9226
- const closeCodeGenerator = editor => {
9227
- const {
9228
- widgets
9229
- } = editor;
9230
- const index = widgets.findIndex(isMatchingWidget);
9231
- if (index === -1) {
9232
- return editor;
9233
- }
9234
- const newWidgets = removeEditorWidget(widgets, CodeGenerator);
9235
- return {
9236
- ...editor,
9237
- widgets: newWidgets,
9238
- focused: true
9239
- };
9240
- };
9241
-
9242
9329
  const keep = [
9243
9330
  // 'ColorPicker.handleSliderPointerDown',
9244
9331
  // 'ColorPicker.handleSliderPointerMove',
@@ -9317,11 +9404,6 @@ const wrapCommands = commands => {
9317
9404
  }
9318
9405
  };
9319
9406
 
9320
- const codeGeneratorAccept = state => {
9321
- // TODO close code generator widget
9322
- return state;
9323
- };
9324
-
9325
9407
  const commandMap = {
9326
9408
  'CodeGenerator.accept': codeGeneratorAccept,
9327
9409
  'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
@@ -9424,6 +9506,7 @@ const commandMap = {
9424
9506
  'Editor.pasteText': pasteText,
9425
9507
  'Editor.render': renderEditor,
9426
9508
  'Editor.replaceRange': replaceRange,
9509
+ 'Editor.rerender': rerender,
9427
9510
  'Editor.save': save,
9428
9511
  'Editor.selectAll': selectAll,
9429
9512
  'Editor.selectAllLeft': editorSelectAllLeft,
@@ -10028,10 +10111,6 @@ const removeWidget = widget => {
10028
10111
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
10029
10112
  };
10030
10113
 
10031
- const mergeClassNames = (...classNames) => {
10032
- return classNames.filter(Boolean).join(' ');
10033
- };
10034
-
10035
10114
  const getCodeGeneratorVirtualDom = state => {
10036
10115
  const escapeToClose$1 = escapeToClose();
10037
10116
  const enterCode$1 = enterCode();
@@ -10892,7 +10971,7 @@ const getSearchFieldButtonVirtualDom = button => {
10892
10971
  } = button;
10893
10972
  return [{
10894
10973
  type: Div,
10895
- className: `SearchFieldButton ${checked ? 'SearchFieldButtonChecked' : ''}`,
10974
+ className: mergeClassNames(SearchFieldButton, checked ? SearchFieldButtonChecked : ''),
10896
10975
  title,
10897
10976
  role: CheckBox,
10898
10977
  ariaChecked: checked,
@@ -10900,7 +10979,7 @@ const getSearchFieldButtonVirtualDom = button => {
10900
10979
  childCount: 1
10901
10980
  }, {
10902
10981
  type: Div,
10903
- className: `MaskIcon ${icon}`,
10982
+ className: mergeClassNames(MaskIcon, icon),
10904
10983
  childCount: 0
10905
10984
  }];
10906
10985
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "5.0.0",
3
+ "version": "5.2.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",