@lvce-editor/editor-worker 1.1.0 → 1.3.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.
@@ -1283,7 +1283,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
1283
1283
  const errorProperty = getErrorProperty(error, prettyError);
1284
1284
  return create$1$1(message, errorProperty);
1285
1285
  };
1286
- const create$4 = (message, result) => {
1286
+ const create$5 = (message, result) => {
1287
1287
  return {
1288
1288
  jsonrpc: Two,
1289
1289
  id: message.id,
@@ -1292,7 +1292,7 @@ const create$4 = (message, result) => {
1292
1292
  };
1293
1293
  const getSuccessResponse = (message, result) => {
1294
1294
  const resultProperty = result ?? null;
1295
- return create$4(message, resultProperty);
1295
+ return create$5(message, resultProperty);
1296
1296
  };
1297
1297
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
1298
1298
  try {
@@ -1323,7 +1323,7 @@ const handleJsonRpcMessage = async (ipc, message, execute, resolve, preparePrett
1323
1323
  }
1324
1324
  throw new JsonRpcError('unexpected message');
1325
1325
  };
1326
- const invoke$4 = async (ipc, method, ...params) => {
1326
+ const invoke$5 = async (ipc, method, ...params) => {
1327
1327
  const {
1328
1328
  message,
1329
1329
  promise
@@ -1383,7 +1383,7 @@ const preparePrettyError = error => {
1383
1383
  return error;
1384
1384
  };
1385
1385
  const logError$1 = error => {
1386
- console.error(error);
1386
+ // handled in renderer worker
1387
1387
  };
1388
1388
  const handleMessage = event => {
1389
1389
  return handleJsonRpcMessage(event.target, event.data, execute$1, resolve, preparePrettyError, logError$1, requiresSocket);
@@ -1400,6 +1400,7 @@ const handleIpc = ipc => {
1400
1400
 
1401
1401
  const RendererProcess = 9;
1402
1402
  const ExtensionHostWorker = 10;
1403
+ const SyntaxHighlightingWorker = 11;
1403
1404
 
1404
1405
  // @ts-ignore
1405
1406
  const getData = event => {
@@ -1437,20 +1438,20 @@ const set$3 = ipc => {
1437
1438
  state$8.ipc = ipc;
1438
1439
  };
1439
1440
 
1440
- const invoke$3 = (method, ...params) => {
1441
+ const invoke$4 = (method, ...params) => {
1441
1442
  const ipc = get$3();
1442
- return invoke$4(ipc, method, ...params);
1443
+ return invoke$5(ipc, method, ...params);
1443
1444
  };
1444
1445
  const invokeAndTransfer$1 = async (transfer, method, ...params) => {
1445
1446
  const ipc = get$3();
1446
1447
  return invokeAndTransfer$2(ipc, transfer, method, ...params);
1447
1448
  };
1448
- const listen$7 = ipc => {
1449
+ const listen$8 = ipc => {
1449
1450
  set$3(ipc);
1450
1451
  };
1451
1452
 
1452
- const invoke$2 = async (method, ...params) => {
1453
- return invoke$3(method, ...params);
1453
+ const invoke$3 = async (method, ...params) => {
1454
+ return invoke$4(method, ...params);
1454
1455
  };
1455
1456
  const invokeAndTransfer = async (transfer, method, ...params) => {
1456
1457
  return invokeAndTransfer$1(transfer, method, ...params);
@@ -1488,7 +1489,7 @@ const waitForFirstMessage$1 = async port => {
1488
1489
  return event;
1489
1490
  };
1490
1491
 
1491
- const create$3 = async () => {
1492
+ const create$4 = async () => {
1492
1493
  const {
1493
1494
  port1,
1494
1495
  port2
@@ -1500,7 +1501,7 @@ const create$3 = async () => {
1500
1501
  }
1501
1502
  return port2;
1502
1503
  };
1503
- const wrap$1 = port => {
1504
+ const wrap$3 = port => {
1504
1505
  return {
1505
1506
  port,
1506
1507
  /**
@@ -1532,6 +1533,59 @@ const wrap$1 = port => {
1532
1533
  };
1533
1534
 
1534
1535
  const IpcParentWithExtensionHostWorker = {
1536
+ __proto__: null,
1537
+ create: create$4,
1538
+ wrap: wrap$3
1539
+ };
1540
+
1541
+ const sendMessagePortToSyntaxHighlightingWorker = async port => {
1542
+ await invokeAndTransfer([port], 'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
1543
+ };
1544
+
1545
+ const create$3 = async () => {
1546
+ const {
1547
+ port1,
1548
+ port2
1549
+ } = getPortTuple();
1550
+ await sendMessagePortToSyntaxHighlightingWorker(port1);
1551
+ const event = await waitForFirstMessage$1(port2);
1552
+ if (event.data !== 'ready') {
1553
+ throw new IpcError$1('unexpected first message');
1554
+ }
1555
+ return port2;
1556
+ };
1557
+ const wrap$1 = port => {
1558
+ return {
1559
+ port,
1560
+ /**
1561
+ * @type {any}
1562
+ */
1563
+ listener: undefined,
1564
+ get onmessage() {
1565
+ return this.listener;
1566
+ },
1567
+ set onmessage(listener) {
1568
+ this.listener = listener;
1569
+ const wrappedListener = event => {
1570
+ const data = getData(event);
1571
+ // @ts-ignore
1572
+ listener({
1573
+ target: this,
1574
+ data
1575
+ });
1576
+ };
1577
+ this.port.onmessage = wrappedListener;
1578
+ },
1579
+ send(message) {
1580
+ this.port.postMessage(message);
1581
+ },
1582
+ sendAndTransfer(message, transfer) {
1583
+ this.port.postMessage(message, transfer);
1584
+ }
1585
+ };
1586
+ };
1587
+
1588
+ const IpcParentWithSyntaxHighlightingWorker = {
1535
1589
  __proto__: null,
1536
1590
  create: create$3,
1537
1591
  wrap: wrap$1
@@ -1596,6 +1650,8 @@ const getModule$1 = method => {
1596
1650
  return IpcParentWithRendererProcess;
1597
1651
  case ExtensionHostWorker:
1598
1652
  return IpcParentWithExtensionHostWorker;
1653
+ case SyntaxHighlightingWorker:
1654
+ return IpcParentWithSyntaxHighlightingWorker;
1599
1655
  default:
1600
1656
  throw new Error('unexpected ipc type');
1601
1657
  }
@@ -1616,18 +1672,29 @@ const create$1 = async ({
1616
1672
  return ipc;
1617
1673
  };
1618
1674
 
1619
- let _ipc$1;
1620
- const listen$6 = async () => {
1621
- const ipc = await create$1({
1622
- method: ExtensionHostWorker
1623
- });
1624
- handleIpc(ipc);
1625
- _ipc$1 = ipc;
1626
- };
1627
- const invoke$1 = (method, ...params) => {
1628
- return invoke$4(_ipc$1, method, ...params);
1675
+ const createRpc = method => {
1676
+ let _ipc;
1677
+ const listen = async () => {
1678
+ const ipc = await create$1({
1679
+ method
1680
+ });
1681
+ handleIpc(ipc);
1682
+ _ipc = ipc;
1683
+ };
1684
+ const invoke = (method, ...params) => {
1685
+ return invoke$5(_ipc, method, ...params);
1686
+ };
1687
+ return {
1688
+ listen,
1689
+ invoke
1690
+ };
1629
1691
  };
1630
1692
 
1693
+ const {
1694
+ listen: listen$7,
1695
+ invoke: invoke$2
1696
+ } = createRpc(ExtensionHostWorker);
1697
+
1631
1698
  const HoverExecute = 'ExtensionHostHover.execute';
1632
1699
  const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
1633
1700
 
@@ -1755,7 +1822,7 @@ const createEditor = async ({
1755
1822
  };
1756
1823
  // console.log({ newEditor })
1757
1824
  set$5(id, emptyEditor, newEditor4);
1758
- await invoke$1(TextDocumentSyncFull, uri, id, languageId, content);
1825
+ await invoke$2(TextDocumentSyncFull, uri, id, languageId, content);
1759
1826
  };
1760
1827
 
1761
1828
  // @ts-ignore
@@ -2093,7 +2160,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
2093
2160
  const x$1 = x(editor, rowIndex, columnIndex);
2094
2161
  const y$1 = y(editor, rowIndex);
2095
2162
  const displayErrorMessage = message;
2096
- await invoke$2('Editor.showOverlayMessage', editor, 'Viewlet.send', editor.uid, 'showOverlayMessage', x$1, y$1, displayErrorMessage);
2163
+ await invoke$3('Editor.showOverlayMessage', editor, 'Viewlet.send', editor.uid, 'showOverlayMessage', x$1, y$1, displayErrorMessage);
2097
2164
  if (!isError) {
2098
2165
  const handleTimeout = () => {
2099
2166
  editorHideMessage(editor);
@@ -2149,7 +2216,7 @@ const braceCompletion = async (editor, text) => {
2149
2216
  try {
2150
2217
  // @ts-ignore
2151
2218
  const offset = offsetAt(editor, editor.cursor);
2152
- const result = await invoke$2('ExtensionHostBraceCompletion.executeBraceCompletionProvider', editor, offset, text);
2219
+ const result = await invoke$3('ExtensionHostBraceCompletion.executeBraceCompletionProvider', editor, offset, text);
2153
2220
  if (result) {
2154
2221
  const closingBrace = getMatchingClosingBrace$1(text);
2155
2222
  const insertText = text + closingBrace;
@@ -2183,7 +2250,7 @@ const cancelSelection = editor => {
2183
2250
  const closeCompletion = async editor => {
2184
2251
  // TODO
2185
2252
  const completionUid = editor.completionUid;
2186
- await invoke$2('Viewlet.dispose', completionUid);
2253
+ await invoke$3('Viewlet.dispose', completionUid);
2187
2254
  editor.completionUid = 0;
2188
2255
  return editor;
2189
2256
  };
@@ -2321,7 +2388,7 @@ let VError$1 = class VError extends Error {
2321
2388
  const writeText = async text => {
2322
2389
  try {
2323
2390
  string(text);
2324
- await invoke$2('ClipBoard.writeText', /* text */text);
2391
+ await invoke$3('ClipBoard.writeText', /* text */text);
2325
2392
  } catch (error) {
2326
2393
  throw new VError$1(error, 'Failed to write text to clipboard');
2327
2394
  }
@@ -3005,7 +3072,7 @@ const deleteWordRight = editor => {
3005
3072
  };
3006
3073
 
3007
3074
  const findAllReferences = async editor => {
3008
- await invoke$2('SideBar.show', 'References', /* focus */true);
3075
+ await invoke$3('SideBar.show', 'References', /* focus */true);
3009
3076
  return editor;
3010
3077
  };
3011
3078
 
@@ -3019,7 +3086,7 @@ const findAllReferences = async editor => {
3019
3086
  // TODO should be in editor folder
3020
3087
 
3021
3088
  const format$1 = async editor => {
3022
- const edits = await invoke$2('Format.format', editor);
3089
+ const edits = await invoke$3('Format.format', editor);
3023
3090
  return edits;
3024
3091
  };
3025
3092
 
@@ -3129,7 +3196,7 @@ const getWordBefore = (editor, rowIndex, columnIndex) => {
3129
3196
 
3130
3197
  // @ts-ignore
3131
3198
  const getDefinition = async (editor, offset) => {
3132
- const definition = await invoke$2('ExtensionHostDefinition.executeDefinitionProvider', editor, offset);
3199
+ const definition = await invoke$3('ExtensionHostDefinition.executeDefinitionProvider', editor, offset);
3133
3200
  return definition;
3134
3201
  };
3135
3202
 
@@ -3268,7 +3335,7 @@ const goTo = async ({
3268
3335
  endRowIndex: definition.endRowIndex,
3269
3336
  endColumnIndex: definition.endColumnIndex
3270
3337
  };
3271
- await invoke$2( /* Main.openUri */'Main.openUri', /* uri */uri, /* focus */true, context);
3338
+ await invoke$3( /* Main.openUri */'Main.openUri', /* uri */uri, /* focus */true, context);
3272
3339
  return editor;
3273
3340
  } catch (error) {
3274
3341
  // TODO if editor is already disposed at this point, do nothing
@@ -3349,7 +3416,7 @@ const getNoLocationFoundMessage = info => {
3349
3416
  };
3350
3417
 
3351
3418
  const getTypeDefinition = async (editor, offset) => {
3352
- const definition = await invoke$2('ExtensionHostTypeDefinition.executeTypeDefinitionProvider', editor, offset);
3419
+ const definition = await invoke$3('ExtensionHostTypeDefinition.executeTypeDefinitionProvider', editor, offset);
3353
3420
  return definition;
3354
3421
  };
3355
3422
 
@@ -3393,7 +3460,7 @@ const goToTypeDefinition = (editor, explicit = true) => {
3393
3460
  const Editor = 3;
3394
3461
 
3395
3462
  const handleContextMenu = async (editor, button, x, y) => {
3396
- await invoke$2( /* ContextMenu.show */'ContextMenu.show', /* x */x, /* y */y, /* id */Editor);
3463
+ await invoke$3( /* ContextMenu.show */'ContextMenu.show', /* x */x, /* y */y, /* id */Editor);
3397
3464
  return editor;
3398
3465
  };
3399
3466
 
@@ -3431,7 +3498,7 @@ const WhenExpressionEditorText = 12;
3431
3498
  const handleFocus = editor => {
3432
3499
  // TODO make change events functional,
3433
3500
  // when rendering, send focus changes to renderer worker
3434
- invoke$2('Focus.setFocus', WhenExpressionEditorText);
3501
+ invoke$3('Focus.setFocus', WhenExpressionEditorText);
3435
3502
  return editor;
3436
3503
  };
3437
3504
 
@@ -4174,7 +4241,7 @@ const indentMore = editor => {
4174
4241
  };
4175
4242
 
4176
4243
  const getLanguageConfiguration = editor => {
4177
- return invoke$2('Languages.getLanguageConfiguration', {
4244
+ return invoke$3('Languages.getLanguageConfiguration', {
4178
4245
  uri: editor.uri,
4179
4246
  languageId: editor.languageId
4180
4247
  });
@@ -4391,13 +4458,13 @@ const moveSelectionPx = (editor, x, y) => {
4391
4458
 
4392
4459
  const FindWidget = 'FindWidget';
4393
4460
  const openFind = async state => {
4394
- await invoke$2('Viewlet.openWidget', FindWidget);
4461
+ await invoke$3('Viewlet.openWidget', FindWidget);
4395
4462
  return state;
4396
4463
  };
4397
4464
 
4398
4465
  const organizeImports = async editor => {
4399
4466
  // TODO ask extension host worker directly
4400
- const edits = await invoke$2('ExtensionHostOrganizeImports.organizeImports', editor);
4467
+ const edits = await invoke$3('ExtensionHostOrganizeImports.organizeImports', editor);
4401
4468
  console.log({
4402
4469
  edits
4403
4470
  });
@@ -4414,7 +4481,7 @@ const pasteText = (editor, text) => {
4414
4481
  };
4415
4482
 
4416
4483
  const paste = async editor => {
4417
- const text = await invoke$2('ClipBoard.readText');
4484
+ const text = await invoke$3('ClipBoard.readText');
4418
4485
  string(text);
4419
4486
  return pasteText(editor, text);
4420
4487
  };
@@ -4552,7 +4619,7 @@ const save = async editor => {
4552
4619
  const uri = editor.uri;
4553
4620
  const newEditor = await getNewEditor(editor);
4554
4621
  const content = getText(newEditor);
4555
- await invoke$2('FileSystem.writeFile', uri, content);
4622
+ await invoke$3('FileSystem.writeFile', uri, content);
4556
4623
  return newEditor;
4557
4624
  } catch (error) {
4558
4625
  // @ts-ignore
@@ -5083,7 +5150,7 @@ const selectWordRight = editor => {
5083
5150
  // import * as ExtensionHostSelection from '../ExtensionHost/ExtensionHostSelection.ts'
5084
5151
 
5085
5152
  const getNewSelections = async (editor, selections) => {
5086
- const newSelections = await invoke$2('ExtensionHostSelection.executeGrowSelection', editor, selections);
5153
+ const newSelections = await invoke$3('ExtensionHostSelection.executeGrowSelection', editor, selections);
5087
5154
  if (newSelections.length === 0) {
5088
5155
  return selections;
5089
5156
  }
@@ -5287,7 +5354,7 @@ const setSelections = (editor, selections) => {
5287
5354
 
5288
5355
  const EditorHover = 'EditorHover';
5289
5356
  const showHover = async state => {
5290
- await invoke$2('Viewlet.openWidget', EditorHover);
5357
+ await invoke$3('Viewlet.openWidget', EditorHover);
5291
5358
  return state;
5292
5359
  };
5293
5360
 
@@ -5298,7 +5365,7 @@ const showSourceActions = async editor => {
5298
5365
  // 2. query source actions from extension host
5299
5366
  // 3. show source actions menu
5300
5367
 
5301
- await invoke$2('Viewlet.openWidget', EditorSourceActions);
5368
+ await invoke$3('Viewlet.openWidget', EditorSourceActions);
5302
5369
  return editor;
5303
5370
  };
5304
5371
 
@@ -5369,7 +5436,7 @@ const getTabCompletion = async editor => {
5369
5436
  const rowIndex = selections[0];
5370
5437
  const columnIndex = selections[1];
5371
5438
  const offset = offsetAt(editor, rowIndex, columnIndex);
5372
- const tabCompletion = await invoke$2('ExtensionHostTabCompletion.executeTabCompletionProvider', editor, offset);
5439
+ const tabCompletion = await invoke$3('ExtensionHostTabCompletion.executeTabCompletionProvider', editor, offset);
5373
5440
  return tabCompletion;
5374
5441
  };
5375
5442
 
@@ -5866,7 +5933,7 @@ const typeWithAutoClosingQuote = (editor, text) => {
5866
5933
 
5867
5934
  const typeWithAutoClosingTag = async (editor, text) => {
5868
5935
  const offset = offsetAt(editor, editor.selections[0], editor.selections[1]);
5869
- const result = await invoke$2('ExtensionHostClosingTagCompletion.executeClosingTagProvider', editor, offset, text);
5936
+ const result = await invoke$3('ExtensionHostClosingTagCompletion.executeClosingTagProvider', editor, offset, text);
5870
5937
  if (!result) {
5871
5938
  const changes = editorReplaceSelections(editor, [text], EditorType);
5872
5939
  return scheduleDocumentAndCursorsSelections(editor, changes);
@@ -6286,7 +6353,7 @@ const OnHover = 'onHover';
6286
6353
 
6287
6354
  // TODO add tests for this
6288
6355
  const activateByEvent = async event => {
6289
- await invoke$2('ExtensionHostManagement.activateByEvent', event);
6356
+ await invoke$3('ExtensionHostManagement.activateByEvent', event);
6290
6357
  };
6291
6358
 
6292
6359
  const execute = async ({
@@ -6299,7 +6366,7 @@ const execute = async ({
6299
6366
  }) => {
6300
6367
  const fullEvent = `${event}:${editor.languageId}`;
6301
6368
  await activateByEvent(fullEvent);
6302
- const result = await invoke$1(method, editor.uid, ...args);
6369
+ const result = await invoke$2(method, editor.uid, ...args);
6303
6370
  return result;
6304
6371
  };
6305
6372
 
@@ -6324,19 +6391,19 @@ const getHover = async (editor, offset) => {
6324
6391
  };
6325
6392
 
6326
6393
  let _ipc;
6327
- const listen$5 = async () => {
6394
+ const listen$6 = async () => {
6328
6395
  const ipc = await create$1({
6329
6396
  method: RendererProcess
6330
6397
  });
6331
6398
  handleIpc(ipc);
6332
6399
  _ipc = ipc;
6333
6400
  };
6334
- const invoke = async (method, ...args) => {
6335
- return invoke$4(_ipc, method, ...args);
6401
+ const invoke$1 = async (method, ...args) => {
6402
+ return invoke$5(_ipc, method, ...args);
6336
6403
  };
6337
6404
 
6338
6405
  const measureTextBlockHeight = (text, fontFamily, fontSize, lineHeight, width) => {
6339
- return invoke('MeasureTextBlockHeight.measureTextBlockHeight', text, fontSize, fontFamily, lineHeight, width);
6406
+ return invoke$1('MeasureTextBlockHeight.measureTextBlockHeight', text, fontSize, fontFamily, lineHeight, width);
6340
6407
  };
6341
6408
 
6342
6409
  const deepCopy = value => {
@@ -6524,9 +6591,26 @@ const handleBeforeInput = (editor, inputType, data) => {
6524
6591
  }
6525
6592
  };
6526
6593
 
6527
- const intialize = async () => {
6528
- await listen$5();
6594
+ const {
6595
+ listen: listen$5,
6596
+ invoke
6597
+ } = createRpc(SyntaxHighlightingWorker);
6598
+
6599
+ let enabled = false;
6600
+ const setEnabled = value => {
6601
+ enabled = value;
6602
+ };
6603
+ const getEnabled = () => {
6604
+ return enabled;
6605
+ };
6606
+
6607
+ const intialize = async syntaxHighlightingEnabled => {
6529
6608
  await listen$6();
6609
+ if (syntaxHighlightingEnabled) {
6610
+ setEnabled(true);
6611
+ await listen$5();
6612
+ }
6613
+ await listen$7();
6530
6614
  };
6531
6615
 
6532
6616
  // TODO move cursor
@@ -6785,6 +6869,15 @@ const getTokensViewport = (editor, startLineIndex, endLineIndex) => {
6785
6869
  };
6786
6870
  };
6787
6871
 
6872
+ // TODO only send changed lines to renderer process instead of all lines in viewport
6873
+ const getTokensViewport2 = (editor, startLineIndex, endLineIndex) => {
6874
+ if (getEnabled()) {
6875
+ // TODO only send needed lines of text
6876
+ return invoke('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex);
6877
+ }
6878
+ return getTokensViewport(editor, startLineIndex, endLineIndex);
6879
+ };
6880
+
6788
6881
  const loadTokenizers = async languageIds => {
6789
6882
  for (const languageId of languageIds) {
6790
6883
  // @ts-ignore
@@ -6995,7 +7088,7 @@ const getLineInfosViewport = (editor, tokens, embeddedResults, minLineY, maxLine
6995
7088
  differences
6996
7089
  };
6997
7090
  };
6998
- const getVisible = editor => {
7091
+ const getVisible = async editor => {
6999
7092
  // console.log({ editor })
7000
7093
  // TODO should separate rendering from business logic somehow
7001
7094
  // currently hard to test because need to mock editor height, top, left,
@@ -7019,7 +7112,7 @@ const getVisible = editor => {
7019
7112
  tokens,
7020
7113
  tokenizersToLoad,
7021
7114
  embeddedResults
7022
- } = getTokensViewport(editor, minLineY, maxLineY);
7115
+ } = await getTokensViewport2(editor, minLineY, maxLineY);
7023
7116
  const minLineOffset = offsetAtSync(editor, minLineY, 0);
7024
7117
  const averageCharWidth = charWidth;
7025
7118
  const {
@@ -7214,7 +7307,7 @@ const renderLines = {
7214
7307
  isEqual(oldState, newState) {
7215
7308
  return oldState.lines === newState.lines && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width;
7216
7309
  },
7217
- apply(oldState, newState) {
7310
+ async apply(oldState, newState) {
7218
7311
  const incrementalEdits = getIncrementalEdits(oldState, newState);
7219
7312
  if (incrementalEdits) {
7220
7313
  return [/* method */'setIncrementalEdits', /* incrementalEdits */incrementalEdits];
@@ -7222,7 +7315,7 @@ const renderLines = {
7222
7315
  const {
7223
7316
  textInfos,
7224
7317
  differences
7225
- } = getVisible(newState);
7318
+ } = await getVisible(newState);
7226
7319
  newState.differences = differences;
7227
7320
  const dom = getEditorRowsVirtualDom(textInfos, differences);
7228
7321
  return [/* method */'setText', dom];
@@ -7301,7 +7394,7 @@ const renderGutterInfo = {
7301
7394
  }
7302
7395
  };
7303
7396
  const render = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus, renderDecorations, renderGutterInfo];
7304
- const renderEditor = id => {
7397
+ const renderEditor = async id => {
7305
7398
  const instance = get$5(id);
7306
7399
  if (!instance) {
7307
7400
  return [];
@@ -7313,7 +7406,7 @@ const renderEditor = id => {
7313
7406
  const commands = [];
7314
7407
  for (const item of render) {
7315
7408
  if (!item.isEqual(oldState, newState)) {
7316
- commands.push(item.apply(oldState, newState));
7409
+ commands.push(await item.apply(oldState, newState));
7317
7410
  }
7318
7411
  }
7319
7412
  set$5(id, newState, newState);
@@ -7328,7 +7421,8 @@ const wrapCommand = fn => async (editorUid, ...args) => {
7328
7421
  const oldInstance = get$5(editorUid);
7329
7422
  const newEditor = await fn(oldInstance.newState, ...args);
7330
7423
  set$5(editorUid, oldInstance.newState, newEditor);
7331
- const commands = renderEditor(editorUid);
7424
+ // TODO if possible, rendering should be sync
7425
+ const commands = await renderEditor(editorUid);
7332
7426
  newEditor.commands = commands;
7333
7427
  return newEditor;
7334
7428
  };
@@ -7899,7 +7993,7 @@ const listen = async () => {
7899
7993
  method: Auto()
7900
7994
  });
7901
7995
  handleIpc(ipc);
7902
- listen$7(ipc);
7996
+ listen$8(ipc);
7903
7997
  };
7904
7998
 
7905
7999
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "",
5
5
  "main": "dist/testWorkerMain.js",
6
6
  "type": "module",
@@ -49,5 +49,12 @@
49
49
  "ignores": [
50
50
  "distmin"
51
51
  ]
52
+ },
53
+ "nodemonConfig": {
54
+ "watch": [
55
+ "src"
56
+ ],
57
+ "ext": "ts,js",
58
+ "exec": "node scripts/build.js"
52
59
  }
53
60
  }