@lvce-editor/editor-worker 3.0.0 → 3.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.
package/dist/api/api.d.ts CHANGED
@@ -9,6 +9,9 @@ interface EventMap {
9
9
  'EditorCompletion.loadContent': (editorUid: number, state: any) => Promise<any>
10
10
  'EditorCompletion.selectCurrent': (editorUid: number, state: any) => Promise<any>
11
11
  'EditorCompletion.selectIndex': (editorUid: number, state: any, index: number) => Promise<any>
12
+ 'EditorCompletion.openDetails': (editorUid: number, state: any) => Promise<any>
13
+ 'EditorCompletion.closeDetails': (editorUid: number, state: any) => Promise<any>
14
+ 'EditorCompletion.toggleDetails': (editorUid: number, state: any) => Promise<any>
12
15
  'FindWidget.focusFirst': (state: any) => Promise<any>
13
16
  'FindWidget.focusIndex': (state: any, index: number) => Promise<any>
14
17
  'FindWidget.focusLast': (state: any) => Promise<any>
@@ -4,7 +4,7 @@ let AssertionError$1 = class AssertionError extends Error {
4
4
  this.name = 'AssertionError';
5
5
  }
6
6
  };
7
- const getType$1 = value => {
7
+ const getType$2 = value => {
8
8
  switch (typeof value) {
9
9
  case 'number':
10
10
  return 'number';
@@ -27,31 +27,31 @@ const getType$1 = value => {
27
27
  }
28
28
  };
29
29
  const object = value => {
30
- const type = getType$1(value);
30
+ const type = getType$2(value);
31
31
  if (type !== 'object') {
32
32
  throw new AssertionError$1('expected value to be of type object');
33
33
  }
34
34
  };
35
35
  const number$1 = value => {
36
- const type = getType$1(value);
36
+ const type = getType$2(value);
37
37
  if (type !== 'number') {
38
38
  throw new AssertionError$1('expected value to be of type number');
39
39
  }
40
40
  };
41
41
  const array = value => {
42
- const type = getType$1(value);
42
+ const type = getType$2(value);
43
43
  if (type !== 'array') {
44
44
  throw new AssertionError$1('expected value to be of type array');
45
45
  }
46
46
  };
47
47
  const string = value => {
48
- const type = getType$1(value);
48
+ const type = getType$2(value);
49
49
  if (type !== 'string') {
50
50
  throw new AssertionError$1('expected value to be of type string');
51
51
  }
52
52
  };
53
53
  const boolean = value => {
54
- const type = getType$1(value);
54
+ const type = getType$2(value);
55
55
  if (type !== 'boolean') {
56
56
  throw new AssertionError$1('expected value to be of type boolean');
57
57
  }
@@ -211,10 +211,10 @@ const renderColorPickerDom = {
211
211
  return ['Viewlet.setDom2', dom];
212
212
  }
213
213
  };
214
- const render$4 = [renderColorPickerDom, renderColor, renderOffsetX];
214
+ const render$6 = [renderColorPickerDom, renderColor, renderOffsetX];
215
215
  const renderColorPicker = async (oldState, newState) => {
216
216
  const commands = [];
217
- for (const item of render$4) {
217
+ for (const item of render$6) {
218
218
  if (!item.isEqual(oldState, newState)) {
219
219
  commands.push(item.apply(oldState, newState));
220
220
  }
@@ -1140,7 +1140,7 @@ class AssertionError extends Error {
1140
1140
  this.name = 'AssertionError';
1141
1141
  }
1142
1142
  }
1143
- const getType = value => {
1143
+ const getType$1 = value => {
1144
1144
  switch (typeof value) {
1145
1145
  case 'number':
1146
1146
  return 'number';
@@ -1163,7 +1163,7 @@ const getType = value => {
1163
1163
  }
1164
1164
  };
1165
1165
  const number = value => {
1166
- const type = getType(value);
1166
+ const type = getType$1(value);
1167
1167
  if (type !== 'number') {
1168
1168
  throw new AssertionError('expected value to be of type number');
1169
1169
  }
@@ -1177,7 +1177,7 @@ const set$5 = (id, fn) => {
1177
1177
  const get$5 = id => {
1178
1178
  return state$1$1.callbacks[id];
1179
1179
  };
1180
- const remove$1 = id => {
1180
+ const remove$2 = id => {
1181
1181
  delete state$1$1.callbacks[id];
1182
1182
  };
1183
1183
  const state$a = {
@@ -1223,7 +1223,7 @@ const resolve = (id, args) => {
1223
1223
  return;
1224
1224
  }
1225
1225
  fn(args);
1226
- remove$1(id);
1226
+ remove$2(id);
1227
1227
  };
1228
1228
  const create$2$1 = (method, params) => {
1229
1229
  const {
@@ -1372,14 +1372,16 @@ const unwrapJsonRpcResult = responseMessage => {
1372
1372
  }
1373
1373
  throw new JsonRpcError('unexpected response message');
1374
1374
  };
1375
- const create$1$1 = (message, error) => {
1376
- return {
1377
- jsonrpc: Two,
1378
- id: message.id,
1379
- error
1380
- };
1381
- };
1382
1375
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
1376
+ const getType = prettyError => {
1377
+ if (prettyError && prettyError.type) {
1378
+ return prettyError.type;
1379
+ }
1380
+ if (prettyError && prettyError.constructor && prettyError.constructor.name) {
1381
+ return prettyError.constructor.name;
1382
+ }
1383
+ return undefined;
1384
+ };
1383
1385
  const getErrorProperty = (error, prettyError) => {
1384
1386
  if (error && error.code === E_COMMAND_NOT_FOUND) {
1385
1387
  return {
@@ -1394,18 +1396,26 @@ const getErrorProperty = (error, prettyError) => {
1394
1396
  data: {
1395
1397
  stack: prettyError.stack,
1396
1398
  codeFrame: prettyError.codeFrame,
1397
- type: prettyError.type,
1398
- code: prettyError.code
1399
+ type: getType(prettyError),
1400
+ code: prettyError.code,
1401
+ name: prettyError.name
1399
1402
  }
1400
1403
  };
1401
1404
  };
1405
+ const create$1$1 = (message, error) => {
1406
+ return {
1407
+ jsonrpc: Two,
1408
+ id: message.id,
1409
+ error
1410
+ };
1411
+ };
1402
1412
  const getErrorResponse = (message, error, preparePrettyError, logError) => {
1403
1413
  const prettyError = preparePrettyError(error);
1404
1414
  logError(error, prettyError);
1405
1415
  const errorProperty = getErrorProperty(error, prettyError);
1406
1416
  return create$1$1(message, errorProperty);
1407
1417
  };
1408
- const create$5 = (message, result) => {
1418
+ const create$8 = (message, result) => {
1409
1419
  return {
1410
1420
  jsonrpc: Two,
1411
1421
  id: message.id,
@@ -1414,7 +1424,7 @@ const create$5 = (message, result) => {
1414
1424
  };
1415
1425
  const getSuccessResponse = (message, result) => {
1416
1426
  const resultProperty = result ?? null;
1417
- return create$5(message, resultProperty);
1427
+ return create$8(message, resultProperty);
1418
1428
  };
1419
1429
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
1420
1430
  try {
@@ -1490,14 +1500,7 @@ const invoke$5 = async (ipc, method, ...params) => {
1490
1500
  const result = unwrapJsonRpcResult(responseMessage);
1491
1501
  return result;
1492
1502
  };
1493
-
1494
- // TODO deprecated old typings,
1495
- // always use automatic transferrable detection
1496
- const invokeAndTransfer$2 = async (ipc, handle, method, ...params) => {
1497
- if (typeof handle === 'string') {
1498
- params = [method, ...params];
1499
- method = handle;
1500
- }
1503
+ const invokeAndTransfer$2 = async (ipc, method, ...params) => {
1501
1504
  const {
1502
1505
  message,
1503
1506
  promise
@@ -1653,7 +1656,7 @@ const waitForFirstMessage$1 = async port => {
1653
1656
  return event;
1654
1657
  };
1655
1658
 
1656
- const create$4 = async () => {
1659
+ const create$7 = async () => {
1657
1660
  const {
1658
1661
  port1,
1659
1662
  port2
@@ -1698,7 +1701,7 @@ const wrap$3 = port => {
1698
1701
 
1699
1702
  const IpcParentWithExtensionHostWorker = {
1700
1703
  __proto__: null,
1701
- create: create$4,
1704
+ create: create$7,
1702
1705
  wrap: wrap$3
1703
1706
  };
1704
1707
 
@@ -1706,7 +1709,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
1706
1709
  await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
1707
1710
  };
1708
1711
 
1709
- const create$3 = async () => {
1712
+ const create$6 = async () => {
1710
1713
  const {
1711
1714
  port1,
1712
1715
  port2
@@ -1751,7 +1754,7 @@ const wrap$1 = port => {
1751
1754
 
1752
1755
  const IpcParentWithSyntaxHighlightingWorker = {
1753
1756
  __proto__: null,
1754
- create: create$3,
1757
+ create: create$6,
1755
1758
  wrap: wrap$1
1756
1759
  };
1757
1760
 
@@ -1759,7 +1762,7 @@ const sendMessagePortToRendererProcess = async port => {
1759
1762
  await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
1760
1763
  };
1761
1764
 
1762
- const create$2 = async () => {
1765
+ const create$5 = async () => {
1763
1766
  const {
1764
1767
  port1,
1765
1768
  port2
@@ -1804,7 +1807,7 @@ const wrap = port => {
1804
1807
 
1805
1808
  const IpcParentWithRendererProcess = {
1806
1809
  __proto__: null,
1807
- create: create$2,
1810
+ create: create$5,
1808
1811
  wrap
1809
1812
  };
1810
1813
 
@@ -1821,7 +1824,7 @@ const getModule$1 = method => {
1821
1824
  }
1822
1825
  };
1823
1826
 
1824
- const create$1 = async ({
1827
+ const create$4 = async ({
1825
1828
  method,
1826
1829
  ...options
1827
1830
  }) => {
@@ -1839,7 +1842,7 @@ const create$1 = async ({
1839
1842
  const createRpc = method => {
1840
1843
  let _ipc;
1841
1844
  const listen = async () => {
1842
- const ipc = await create$1({
1845
+ const ipc = await create$4({
1843
1846
  method
1844
1847
  });
1845
1848
  handleIpc(ipc);
@@ -2116,7 +2119,7 @@ const getAccurateColumnIndexAscii = (line, guess, averageCharWidth, eventX, font
2116
2119
  const supported = () => {
2117
2120
  return 'Segmenter' in Intl;
2118
2121
  };
2119
- const create = () => {
2122
+ const create$3 = () => {
2120
2123
  // @ts-ignore
2121
2124
  const segmenter = new Intl.Segmenter();
2122
2125
  return {
@@ -2154,7 +2157,7 @@ const create = () => {
2154
2157
 
2155
2158
  // @ts-ignore
2156
2159
  const getAccurateColumnIndexUnicode = (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
2157
- const segmenter = create();
2160
+ const segmenter = create$3();
2158
2161
  const segments = segmenter.getSegments(line);
2159
2162
  const isMonospaceFont = false;
2160
2163
  const charWidth = 0;
@@ -2383,7 +2386,9 @@ const cancelSelection = editor => {
2383
2386
  return scheduleSelections(editor, newSelections);
2384
2387
  };
2385
2388
 
2389
+ // TODO use numeric widget id
2386
2390
  const Completion = 'completion';
2391
+ const CompletionDetail = 'completionDetail';
2387
2392
 
2388
2393
  const isCompletionWidget = widget => {
2389
2394
  return widget.id === Completion;
@@ -2697,7 +2702,7 @@ const characterLeft = (line, columnIndex) => {
2697
2702
  if (!supported()) {
2698
2703
  return 1;
2699
2704
  }
2700
- const segmenter = create();
2705
+ const segmenter = create$3();
2701
2706
  const last = segmenter.at(line, columnIndex - 1);
2702
2707
  return columnIndex - last.index;
2703
2708
  };
@@ -2708,7 +2713,7 @@ const characterRight = (line, columnIndex) => {
2708
2713
  if (!supported()) {
2709
2714
  return 1;
2710
2715
  }
2711
- const segmenter = create();
2716
+ const segmenter = create$3();
2712
2717
  const next = segmenter.at(line, columnIndex);
2713
2718
  return next.segment.length;
2714
2719
  };
@@ -4465,6 +4470,44 @@ const moveSelectionPx = (editor, x, y) => {
4465
4470
  return editorMoveSelection(editor, position);
4466
4471
  };
4467
4472
 
4473
+ const create$2 = () => {
4474
+ return Math.random();
4475
+ };
4476
+
4477
+ const create$1 = () => {
4478
+ const completionUid = create$2();
4479
+ const completionWidget = {
4480
+ id: Completion,
4481
+ oldState: {
4482
+ items: [],
4483
+ itemHeight: 20,
4484
+ maxHeight: 150,
4485
+ minLineY: 0,
4486
+ maxLineY: 0,
4487
+ uid: completionUid,
4488
+ focusedIndex: -1,
4489
+ x: 0,
4490
+ y: 0,
4491
+ width: 0,
4492
+ height: 0
4493
+ },
4494
+ newState: {
4495
+ items: [],
4496
+ itemHeight: 20,
4497
+ maxHeight: 150,
4498
+ minLineY: 0,
4499
+ maxLineY: 10,
4500
+ uid: completionUid,
4501
+ focusedIndex: -1,
4502
+ x: 0,
4503
+ y: 0,
4504
+ width: 0,
4505
+ height: 0
4506
+ }
4507
+ };
4508
+ return completionWidget;
4509
+ };
4510
+
4468
4511
  const OnCompletion = 'onCompletion';
4469
4512
  const OnHover = 'onHover';
4470
4513
 
@@ -4922,26 +4965,7 @@ const openCompletion = async editor => {
4922
4965
  if (hasWidget(widgets, Completion)) {
4923
4966
  return editor;
4924
4967
  }
4925
- const completionUid = Math.random();
4926
- const completionWidget = {
4927
- id: Completion,
4928
- oldState: {
4929
- items: [],
4930
- itemHeight: 20,
4931
- maxHeight: 150,
4932
- minLineY: 0,
4933
- maxLineY: 0,
4934
- uid: completionUid
4935
- },
4936
- newState: {
4937
- items: [],
4938
- itemHeight: 20,
4939
- maxHeight: 150,
4940
- minLineY: 0,
4941
- maxLineY: 10,
4942
- uid: completionUid
4943
- }
4944
- };
4968
+ const completionWidget = create$1();
4945
4969
  const newWidgets = [...widgets, completionWidget];
4946
4970
  const newEditor = {
4947
4971
  ...editor,
@@ -6652,15 +6676,32 @@ const editorUnindent = editor => {
6652
6676
 
6653
6677
  // editor.lines //?
6654
6678
 
6655
- const isCompletion$2 = widget => {
6656
- return widget.id === Completion;
6657
- };
6658
- const getCompletionState = editor => {
6679
+ const getWidgetState = (editor, id) => {
6659
6680
  const {
6660
6681
  widgets
6661
6682
  } = editor;
6662
- const child = widgets.find(isCompletion$2);
6663
- return child.newState;
6683
+ for (const widget of widgets) {
6684
+ if (widget.id === id) {
6685
+ return widget.newState;
6686
+ }
6687
+ }
6688
+ return undefined;
6689
+ };
6690
+
6691
+ const getCompletionState = editor => {
6692
+ return getWidgetState(editor, Completion);
6693
+ };
6694
+
6695
+ const closeDetails = editor => {
6696
+ const child = getCompletionState(editor);
6697
+ if (!child) {
6698
+ return editor;
6699
+ }
6700
+ console.log('open details');
6701
+ // TODO when completion details are open, close them
6702
+ // TODO when completion details are opening, close them
6703
+ // TODO when completion details are closed, open them
6704
+ return editor;
6664
6705
  };
6665
6706
 
6666
6707
  const isCompletion$1 = widget => {
@@ -6696,16 +6737,81 @@ const focusFirst$1 = editor => {
6696
6737
 
6697
6738
  const focusNext$1 = editor => {
6698
6739
  const child = getCompletionState(editor);
6740
+ if (!child) {
6741
+ return editor;
6742
+ }
6699
6743
  const nextIndex = child.focusedIndex + 1;
6700
6744
  return focusIndex$1(editor, nextIndex);
6701
6745
  };
6702
6746
 
6703
6747
  const focusPrevious$1 = editor => {
6704
6748
  const child = getCompletionState(editor);
6749
+ if (!child) {
6750
+ return editor;
6751
+ }
6705
6752
  const previousIndex = child.focusedIndex - 1;
6706
6753
  return focusIndex$1(editor, previousIndex);
6707
6754
  };
6708
6755
 
6756
+ const create = () => {
6757
+ const completionUid = create$2();
6758
+ const completionWidget = {
6759
+ id: CompletionDetail,
6760
+ oldState: {
6761
+ content: '',
6762
+ uid: completionUid,
6763
+ x: 0,
6764
+ y: 0,
6765
+ width: 0,
6766
+ height: 0
6767
+ },
6768
+ newState: {
6769
+ content: '',
6770
+ uid: completionUid,
6771
+ x: 0,
6772
+ y: 0,
6773
+ width: 0,
6774
+ height: 0
6775
+ }
6776
+ };
6777
+ return completionWidget;
6778
+ };
6779
+
6780
+ const getCompletionDetailState = editor => {
6781
+ return getWidgetState(editor, CompletionDetail);
6782
+ };
6783
+
6784
+ const openDetails = editor => {
6785
+ const child = getCompletionState(editor);
6786
+ if (!child) {
6787
+ return editor;
6788
+ }
6789
+ const detailState = getCompletionDetailState(editor);
6790
+ if (detailState) {
6791
+ return editor;
6792
+ }
6793
+ const widget = create();
6794
+ console.log({
6795
+ child
6796
+ });
6797
+ const newestState = {
6798
+ ...widget.newState,
6799
+ content: 'abc',
6800
+ x: child.x + child.width,
6801
+ y: child.y,
6802
+ width: 100,
6803
+ height: 100
6804
+ };
6805
+ const latestWidgets = [...editor.widgets, {
6806
+ ...widget,
6807
+ newState: newestState
6808
+ }];
6809
+ return {
6810
+ ...editor,
6811
+ widgets: latestWidgets
6812
+ };
6813
+ };
6814
+
6709
6815
  const getEdits = async (editor, completionItem) => {
6710
6816
  const child = getCompletionState(editor);
6711
6817
  // @ts-ignore
@@ -6755,6 +6861,9 @@ const select = async (editor, completionItem) => {
6755
6861
  };
6756
6862
  const selectIndex = (editor, index) => {
6757
6863
  const child = getCompletionState(editor);
6864
+ if (!child) {
6865
+ return editor;
6866
+ }
6758
6867
  const {
6759
6868
  items
6760
6869
  } = child;
@@ -6771,12 +6880,26 @@ const selectIndex = (editor, index) => {
6771
6880
 
6772
6881
  const selectCurrent = editor => {
6773
6882
  const child = getCompletionState(editor);
6883
+ if (!child) {
6884
+ return editor;
6885
+ }
6774
6886
  const {
6775
6887
  focusedIndex
6776
6888
  } = child;
6777
6889
  return selectIndex(editor, focusedIndex);
6778
6890
  };
6779
6891
 
6892
+ const toggleDetails = editor => {
6893
+ const child = getCompletionState(editor);
6894
+ if (!child) {
6895
+ return editor;
6896
+ }
6897
+ // TODO when completion details are open, close them
6898
+ // TODO when completion details are opening, close them
6899
+ // TODO when completion details are closed, open them
6900
+ return editor;
6901
+ };
6902
+
6780
6903
  const executeHoverProvider = (editor, offset) => {
6781
6904
  object(editor);
6782
6905
  number$1(offset);
@@ -6799,7 +6922,7 @@ const getHover = async (editor, offset) => {
6799
6922
 
6800
6923
  let _ipc;
6801
6924
  const listen$5 = async () => {
6802
- const ipc = await create$1({
6925
+ const ipc = await create$4({
6803
6926
  method: RendererProcess
6804
6927
  });
6805
6928
  handleIpc(ipc);
@@ -7123,7 +7246,7 @@ const renderHoverDom = {
7123
7246
  return [/* method */'Viewlet.setDom2', dom];
7124
7247
  }
7125
7248
  };
7126
- const renderBounds$1 = {
7249
+ const renderBounds$2 = {
7127
7250
  isEqual(oldState, newState) {
7128
7251
  return oldState.x === newState.x && oldState.y === newState.y && oldState.resizedWidth === newState.resizedWidth;
7129
7252
  },
@@ -7141,10 +7264,10 @@ const renderBounds$1 = {
7141
7264
  return [SetBounds, x, y, resizedWidth, height];
7142
7265
  }
7143
7266
  };
7144
- const render$3 = [renderHoverDom, renderBounds$1];
7267
+ const render$5 = [renderHoverDom, renderBounds$2];
7145
7268
  const renderHover = async (oldState, newState) => {
7146
7269
  const commands = [];
7147
- for (const item of render$3) {
7270
+ for (const item of render$5) {
7148
7271
  if (!item.isEqual(oldState, newState)) {
7149
7272
  commands.push(item.apply(oldState, newState));
7150
7273
  }
@@ -8262,7 +8385,7 @@ const renderItems = {
8262
8385
  return ['setDom', dom];
8263
8386
  }
8264
8387
  };
8265
- const renderBounds = {
8388
+ const renderBounds$1 = {
8266
8389
  isEqual(oldState, newState) {
8267
8390
  return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
8268
8391
  },
@@ -8308,10 +8431,10 @@ const renderScrollBar = {
8308
8431
  return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
8309
8432
  }
8310
8433
  };
8311
- const render$2 = [renderItems, renderBounds, renderHeight, renderNegativeMargin, renderScrollBar];
8434
+ const render$4 = [renderItems, renderBounds$1, renderHeight, renderNegativeMargin, renderScrollBar];
8312
8435
  const renderCompletion = (oldState, newState) => {
8313
8436
  const commands = [];
8314
- for (const item of render$2) {
8437
+ for (const item of render$4) {
8315
8438
  if (!item.isEqual(oldState, newState)) {
8316
8439
  commands.push(item.apply(oldState, newState));
8317
8440
  }
@@ -8319,7 +8442,7 @@ const renderCompletion = (oldState, newState) => {
8319
8442
  return commands;
8320
8443
  };
8321
8444
 
8322
- const render$1 = (oldState, newState) => {
8445
+ const render$3 = (oldState, newState) => {
8323
8446
  const commands = renderCompletion(oldState, newState);
8324
8447
  const wrappedCommands = [];
8325
8448
  const uid = newState.uid;
@@ -8328,8 +8451,8 @@ const render$1 = (oldState, newState) => {
8328
8451
  }
8329
8452
  return wrappedCommands;
8330
8453
  };
8331
- const add = widget => {
8332
- const commands = render$1(widget.oldState, widget.newState);
8454
+ const add$1 = widget => {
8455
+ const commands = render$3(widget.oldState, widget.newState);
8333
8456
  const id = 'EditorCompletion';
8334
8457
  // TODO how to generate a unique integer id
8335
8458
  // that doesn't collide with ids created in renderer worker?
@@ -8339,7 +8462,7 @@ const add = widget => {
8339
8462
  allCommands.push(...commands);
8340
8463
  return allCommands;
8341
8464
  };
8342
- const remove = widget => {
8465
+ const remove$1 = widget => {
8343
8466
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
8344
8467
  };
8345
8468
  const handleEditorType = (editor, state) => {
@@ -8406,11 +8529,85 @@ const handleEditorDeleteLeft = (editor, state) => {
8406
8529
 
8407
8530
  const EditorCompletionWidget = {
8408
8531
  __proto__: null,
8409
- add,
8532
+ add: add$1,
8410
8533
  handleEditorDeleteLeft,
8411
8534
  handleEditorType,
8412
- remove,
8413
- render: render$1
8535
+ remove: remove$1,
8536
+ render: render$3
8537
+ };
8538
+
8539
+ const getCompletionDetailVirtualDom = content => {
8540
+ const dom = [{
8541
+ type: Div,
8542
+ childCount: 2
8543
+ }, {
8544
+ type: Div,
8545
+ className: 'CompletionDetailContent',
8546
+ childCount: 1
8547
+ }, text(content), {
8548
+ type: Div,
8549
+ className: 'CompletionDetailCloseButton',
8550
+ childCount: 0
8551
+ }];
8552
+ return dom;
8553
+ };
8554
+
8555
+ const renderContent = {
8556
+ isEqual(oldState, newState) {
8557
+ return oldState.content === newState.content;
8558
+ },
8559
+ apply(oldState, newState) {
8560
+ const dom = getCompletionDetailVirtualDom(newState.content);
8561
+ return ['setDom', dom];
8562
+ }
8563
+ };
8564
+ const renderBounds = {
8565
+ isEqual(oldState, newState) {
8566
+ return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
8567
+ },
8568
+ apply(oldState, newState) {
8569
+ const {
8570
+ x,
8571
+ y,
8572
+ width,
8573
+ height
8574
+ } = newState;
8575
+ return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
8576
+ }
8577
+ };
8578
+ const render$2 = [renderContent, renderBounds];
8579
+ const renderFull = (oldState, newState) => {
8580
+ const commands = [];
8581
+ for (const item of render$2) {
8582
+ if (!item.isEqual(oldState, newState)) {
8583
+ commands.push(item.apply(oldState, newState));
8584
+ }
8585
+ }
8586
+ return commands;
8587
+ };
8588
+
8589
+ const render$1 = (oldState, newState) => {
8590
+ const commands = renderFull(oldState, newState);
8591
+ const wrappedCommands = [];
8592
+ const uid = newState.uid;
8593
+ for (const command of commands) {
8594
+ wrappedCommands.push(['Viewlet.send', uid, ...command]);
8595
+ }
8596
+ return wrappedCommands;
8597
+ };
8598
+ const add = widget => {
8599
+ const commands = render$1(widget.oldState, widget.newState);
8600
+ const id = 'EditorCompletionDetails';
8601
+ // TODO how to generate a unique integer id
8602
+ // that doesn't collide with ids created in renderer worker?
8603
+ const uid = widget.newState.uid;
8604
+ const allCommands = [];
8605
+ allCommands.push(['Viewlet.create', id, uid]);
8606
+ allCommands.push(...commands);
8607
+ return allCommands;
8608
+ };
8609
+ const remove = widget => {
8610
+ return [['Viewlet.send', widget.newState.uid, 'dispose']];
8414
8611
  };
8415
8612
 
8416
8613
  const addWidget = widget => {
@@ -8419,6 +8616,8 @@ const addWidget = widget => {
8419
8616
  } = widget;
8420
8617
  switch (id) {
8421
8618
  case Completion:
8619
+ return add$1(widget);
8620
+ case CompletionDetail:
8422
8621
  return add(widget);
8423
8622
  default:
8424
8623
  throw new Error('unsupported widget');
@@ -8430,6 +8629,8 @@ const renderWidget = widget => {
8430
8629
  } = widget;
8431
8630
  switch (id) {
8432
8631
  case Completion:
8632
+ return render$3(widget.oldState, widget.newState);
8633
+ case CompletionDetail:
8433
8634
  return render$1(widget.oldState, widget.newState);
8434
8635
  default:
8435
8636
  throw new Error(`unsupported widget`);
@@ -8441,6 +8642,8 @@ const removeWidget = widget => {
8441
8642
  } = widget;
8442
8643
  switch (id) {
8443
8644
  case Completion:
8645
+ return remove$1(widget);
8646
+ case CompletionDetail:
8444
8647
  return remove(widget);
8445
8648
  default:
8446
8649
  throw new Error('unsupported widget');
@@ -8783,6 +8986,7 @@ const commandMap = {
8783
8986
  'Editor.undo': undo,
8784
8987
  'Editor.unIndent': editorUnindent,
8785
8988
  'EditorCompletion.advance': advance,
8989
+ 'EditorCompletion.closeDetails': closeDetails,
8786
8990
  'EditorCompletion.focusFirst': focusFirst$1,
8787
8991
  'EditorCompletion.focusIndex': focusIndex$1,
8788
8992
  'EditorCompletion.focusNext': focusNext$1,
@@ -8792,8 +8996,10 @@ const commandMap = {
8792
8996
  'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
8793
8997
  'EditorCompletion.handleEditorType': handleEditorType$1,
8794
8998
  'EditorCompletion.loadContent': loadContent$2,
8999
+ 'EditorCompletion.openDetails': openDetails,
8795
9000
  'EditorCompletion.selectCurrent': selectCurrent,
8796
9001
  'EditorCompletion.selectIndex': selectIndex,
9002
+ 'EditorCompletion.toggleDetails': toggleDetails,
8797
9003
  'FindWidget.focusFirst': focusFirst,
8798
9004
  'FindWidget.focusIndex': focusIndex,
8799
9005
  'FindWidget.focusLast': focusLast,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "",
5
5
  "main": "dist/testWorkerMain.js",
6
6
  "type": "module",