@lvce-editor/editor-worker 18.4.0 → 18.6.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.
@@ -575,12 +575,12 @@ const getErrorConstructor = (message, type) => {
575
575
  switch (type) {
576
576
  case DomException:
577
577
  return DOMException;
578
- case TypeError$1:
579
- return TypeError;
580
- case SyntaxError$1:
581
- return SyntaxError;
582
578
  case ReferenceError$1:
583
579
  return ReferenceError;
580
+ case SyntaxError$1:
581
+ return SyntaxError;
582
+ case TypeError$1:
583
+ return TypeError;
584
584
  default:
585
585
  return Error;
586
586
  }
@@ -736,27 +736,27 @@ const getErrorProperty = (error, prettyError) => {
736
736
  if (error && error.code === E_COMMAND_NOT_FOUND) {
737
737
  return {
738
738
  code: MethodNotFound,
739
- message: error.message,
740
- data: error.stack
739
+ data: error.stack,
740
+ message: error.message
741
741
  };
742
742
  }
743
743
  return {
744
744
  code: Custom,
745
- message: prettyError.message,
746
745
  data: {
747
- stack: getStack(prettyError),
748
- codeFrame: prettyError.codeFrame,
749
- type: getErrorType(prettyError),
750
746
  code: prettyError.code,
751
- name: prettyError.name
752
- }
747
+ codeFrame: prettyError.codeFrame,
748
+ name: prettyError.name,
749
+ stack: getStack(prettyError),
750
+ type: getErrorType(prettyError)
751
+ },
752
+ message: prettyError.message
753
753
  };
754
754
  };
755
755
  const create$1$1 = (id, error) => {
756
756
  return {
757
- jsonrpc: Two$1,
757
+ error,
758
758
  id,
759
- error
759
+ jsonrpc: Two$1
760
760
  };
761
761
  };
762
762
  const getErrorResponse = (id, error, preparePrettyError, logError) => {
@@ -767,8 +767,8 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
767
767
  };
768
768
  const create$j = (message, result) => {
769
769
  return {
770
- jsonrpc: Two$1,
771
770
  id: message.id,
771
+ jsonrpc: Two$1,
772
772
  result: result ?? null
773
773
  };
774
774
  };
@@ -778,14 +778,14 @@ const getSuccessResponse = (message, result) => {
778
778
  };
779
779
  const getErrorResponseSimple = (id, error) => {
780
780
  return {
781
- jsonrpc: Two$1,
782
- id,
783
781
  error: {
784
782
  code: Custom,
783
+ data: error,
785
784
  // @ts-ignore
786
- message: error.message,
787
- data: error
788
- }
785
+ message: error.message
786
+ },
787
+ id,
788
+ jsonrpc: Two$1
789
789
  };
790
790
  };
791
791
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
@@ -815,35 +815,35 @@ const normalizeParams = args => {
815
815
  if (args.length === 1) {
816
816
  const options = args[0];
817
817
  return {
818
+ execute: options.execute,
818
819
  ipc: options.ipc,
820
+ logError: options.logError || defaultLogError,
819
821
  message: options.message,
820
- execute: options.execute,
821
- resolve: options.resolve || defaultResolve,
822
822
  preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
823
- logError: options.logError || defaultLogError,
824
- requiresSocket: options.requiresSocket || defaultRequiresSocket
823
+ requiresSocket: options.requiresSocket || defaultRequiresSocket,
824
+ resolve: options.resolve || defaultResolve
825
825
  };
826
826
  }
827
827
  return {
828
+ execute: args[2],
828
829
  ipc: args[0],
830
+ logError: args[5],
829
831
  message: args[1],
830
- execute: args[2],
831
- resolve: args[3],
832
832
  preparePrettyError: args[4],
833
- logError: args[5],
834
- requiresSocket: args[6]
833
+ requiresSocket: args[6],
834
+ resolve: args[3]
835
835
  };
836
836
  };
837
837
  const handleJsonRpcMessage = async (...args) => {
838
838
  const options = normalizeParams(args);
839
839
  const {
840
- message,
841
- ipc,
842
840
  execute,
843
- resolve,
844
- preparePrettyError,
841
+ ipc,
845
842
  logError,
846
- requiresSocket
843
+ message,
844
+ preparePrettyError,
845
+ requiresSocket,
846
+ resolve
847
847
  } = options;
848
848
  if ('id' in message) {
849
849
  if ('method' in message) {
@@ -904,7 +904,6 @@ const registerPromise = map => {
904
904
  };
905
905
  };
906
906
 
907
- // @ts-ignore
908
907
  const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
909
908
  const {
910
909
  id,
@@ -986,6 +985,41 @@ const listen$1 = async (module, options) => {
986
985
  return ipc;
987
986
  };
988
987
 
988
+ const create$f = async ({
989
+ commandMap,
990
+ isMessagePortOpen = true,
991
+ messagePort
992
+ }) => {
993
+ // TODO create a commandMap per rpc instance
994
+ register(commandMap);
995
+ const rawIpc = await IpcParentWithMessagePort$1.create({
996
+ isMessagePortOpen,
997
+ messagePort
998
+ });
999
+ const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1000
+ handleIpc(ipc);
1001
+ const rpc = createRpc(ipc);
1002
+ messagePort.start();
1003
+ return rpc;
1004
+ };
1005
+
1006
+ const create$e = async ({
1007
+ commandMap,
1008
+ isMessagePortOpen,
1009
+ send
1010
+ }) => {
1011
+ const {
1012
+ port1,
1013
+ port2
1014
+ } = new MessageChannel();
1015
+ await send(port1);
1016
+ return create$f({
1017
+ commandMap,
1018
+ isMessagePortOpen,
1019
+ messagePort: port2
1020
+ });
1021
+ };
1022
+
989
1023
  const createSharedLazyRpc = factory => {
990
1024
  let rpcPromise;
991
1025
  const getOrCreate = () => {
@@ -1014,13 +1048,13 @@ const createSharedLazyRpc = factory => {
1014
1048
  };
1015
1049
  };
1016
1050
 
1017
- const create$f = async ({
1051
+ const create$d = async ({
1018
1052
  commandMap,
1019
1053
  isMessagePortOpen,
1020
1054
  send
1021
1055
  }) => {
1022
1056
  return createSharedLazyRpc(() => {
1023
- return create$c({
1057
+ return create$e({
1024
1058
  commandMap,
1025
1059
  isMessagePortOpen,
1026
1060
  send
@@ -1028,51 +1062,16 @@ const create$f = async ({
1028
1062
  });
1029
1063
  };
1030
1064
 
1031
- const create$e = async ({
1032
- commandMap,
1033
- isMessagePortOpen = true,
1034
- messagePort
1035
- }) => {
1036
- // TODO create a commandMap per rpc instance
1037
- register(commandMap);
1038
- const rawIpc = await IpcParentWithMessagePort$1.create({
1039
- isMessagePortOpen,
1040
- messagePort
1041
- });
1042
- const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1043
- handleIpc(ipc);
1044
- const rpc = createRpc(ipc);
1045
- messagePort.start();
1046
- return rpc;
1047
- };
1048
-
1049
- const create$d = async ({
1065
+ const create$c = async ({
1050
1066
  commandMap,
1051
1067
  messagePort
1052
1068
  }) => {
1053
- return create$e({
1069
+ return create$f({
1054
1070
  commandMap,
1055
1071
  messagePort
1056
1072
  });
1057
1073
  };
1058
1074
 
1059
- const create$c = async ({
1060
- commandMap,
1061
- isMessagePortOpen,
1062
- send
1063
- }) => {
1064
- const {
1065
- port1,
1066
- port2
1067
- } = new MessageChannel();
1068
- await send(port1);
1069
- return create$e({
1070
- commandMap,
1071
- isMessagePortOpen,
1072
- messagePort: port2
1073
- });
1074
- };
1075
-
1076
1075
  const create$b = async ({
1077
1076
  commandMap
1078
1077
  }) => {
@@ -1084,63 +1083,8 @@ const create$b = async ({
1084
1083
  return rpc;
1085
1084
  };
1086
1085
 
1087
- const Text$1 = 12;
1088
- const Reference = 100;
1089
-
1090
- const Backspace = 1;
1091
- const Tab$1 = 2;
1092
- const Enter = 3;
1093
- const Escape = 8;
1094
- const Space$1 = 9;
1095
- const End = 255;
1096
- const Home = 12;
1097
- const LeftArrow = 13;
1098
- const UpArrow = 14;
1099
- const RightArrow = 15;
1100
- const DownArrow = 16;
1101
- const Delete$1 = 18;
1102
- const KeyA = 29;
1103
- const KeyC = 31;
1104
- const KeyD = 32;
1105
- const KeyF = 34;
1106
- const KeyH = 36;
1107
- const KeyJ = 38;
1108
- const KeyK = 39;
1109
- const KeyL = 40;
1110
- const KeyO = 43;
1111
- const KeyV = 50;
1112
- const KeyX = 52;
1113
- const KeyZ = 54;
1114
- const F2 = 58;
1115
- const F3 = 59;
1116
- const F4 = 60;
1117
- const F12 = 68;
1118
- const Period = 87;
1119
- const Slash$1 = 88;
1120
- const BracketLeft = 90;
1121
- const BracketRight = 92;
1122
-
1123
- const CodeGenerator = 1;
1124
- const ColorPicker$1 = 2;
1125
- const Completion = 3;
1126
- const CompletionDetail = 4;
1127
- const Find = 5;
1128
- const Hover = 6;
1129
- const Rename$1 = 7;
1130
- const SourceAction$1 = 8;
1131
-
1132
1086
  const Script$1 = 2;
1133
1087
 
1134
- const CtrlCmd = 1 << 11 >>> 0;
1135
- const Shift = 1 << 10 >>> 0;
1136
- const Alt$1 = 1 << 9 >>> 0;
1137
-
1138
- const Editor$1 = 3;
1139
- const SourceControl = 22;
1140
-
1141
- const Separator = 1;
1142
- const None = 0;
1143
-
1144
1088
  const CompletionWorker = 301;
1145
1089
  const DebugWorker = 55;
1146
1090
  const EditorWorker = 99;
@@ -1150,15 +1094,6 @@ const IconThemeWorker = 7009;
1150
1094
  const MarkdownWorker = 300;
1151
1095
  const OpenerWorker = 4561;
1152
1096
  const RendererWorker$1 = 1;
1153
- const TextMeasurementWorker = 7011;
1154
-
1155
- const FocusSelector = 'Viewlet.focusSelector';
1156
- const SetCss$1 = 'Viewlet.setCss';
1157
- const SetFocusContext$1 = 'Viewlet.setFocusContext';
1158
- const SetPatches = 'Viewlet.setPatches';
1159
-
1160
- const FocusEditorText$1 = 12;
1161
- const FocusExplorer = 13;
1162
1097
 
1163
1098
  const createMockRpc = ({
1164
1099
  commandMap
@@ -1269,6 +1204,9 @@ const {
1269
1204
  invoke: invoke$e,
1270
1205
  set: set$d
1271
1206
  } = create$a(ExtensionManagementWorker);
1207
+ const getLanguages$1 = (platform, assetDir) => {
1208
+ return invoke$e('Extensions.getLanguages', platform, assetDir);
1209
+ };
1272
1210
 
1273
1211
  const {
1274
1212
  dispose: dispose$2,
@@ -1283,6 +1221,9 @@ const searchFileHtml = async uri => {
1283
1221
  const getFilePathElectron = async file => {
1284
1222
  return invoke$d('FileSystemHandle.getFilePathElectron', file);
1285
1223
  };
1224
+ const handleModifiedStatusChange = async (uri, modified) => {
1225
+ return invoke$d('Main.handleModifiedStatusChange', uri, modified);
1226
+ };
1286
1227
  /**
1287
1228
  * @deprecated
1288
1229
  */
@@ -1386,6 +1327,9 @@ const disableExtension = async id => {
1386
1327
  const enableExtension = async id => {
1387
1328
  return invoke$d('ExtensionManagement.enable', id);
1388
1329
  };
1330
+ const disposeEditor = async uid => {
1331
+ return invoke$d('Viewlet.dispose', uid);
1332
+ };
1389
1333
  const handleDebugChange = async params => {
1390
1334
  return invoke$d('Run And Debug.handleChange', params);
1391
1335
  };
@@ -1398,10 +1342,31 @@ const handleWorkspaceRefresh = async () => {
1398
1342
  const closeWidget = async widgetId => {
1399
1343
  return invoke$d('Viewlet.closeWidget', widgetId);
1400
1344
  };
1345
+ const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) => {
1346
+ return invoke$d('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
1347
+ };
1401
1348
  const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1402
1349
  const command = 'HandleMessagePort.handleMessagePort2';
1403
1350
  await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1404
1351
  };
1352
+ const getViewletModuleId = async uri => {
1353
+ return invoke$d('Layout.getModuleId', uri);
1354
+ };
1355
+ const showPanel = async () => {
1356
+ return invoke$d('Layout.showPanel');
1357
+ };
1358
+ const showPreview = async () => {
1359
+ return invoke$d('Layout.showPreview');
1360
+ };
1361
+ const saveEditor = async () => {
1362
+ return invoke$d('Editor.save');
1363
+ };
1364
+ const togglePanelView = async id => {
1365
+ return invoke$d('Panel.toggleView', id);
1366
+ };
1367
+ const resizeViewlet = async (uid, dimensions) => {
1368
+ return invoke$d('Viewlet.resize', uid, dimensions);
1369
+ };
1405
1370
  const sendMessagePortToFileSearchWorker = async (port, rpcId = 0) => {
1406
1371
  const command = 'QuickPick.handleMessagePort';
1407
1372
  await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSearchWorker', port, command, rpcId);
@@ -1422,6 +1387,12 @@ const getKeyBindings$1 = async () => {
1422
1387
  const writeClipBoardText = async text => {
1423
1388
  await invoke$d('ClipBoard.writeText', /* text */text);
1424
1389
  };
1390
+ const writeFile = async (uri, text) => {
1391
+ await invoke$d('FileSystem.writeFile', uri, text);
1392
+ };
1393
+ const handleUriChange = async (uri, newUri) => {
1394
+ await invoke$d('Main.handleUriChange', uri, newUri);
1395
+ };
1425
1396
  const readClipBoardText = async () => {
1426
1397
  return invoke$d('ClipBoard.readText');
1427
1398
  };
@@ -1550,6 +1521,9 @@ const unmaximizeWindow = async () => {
1550
1521
  const maximizeWindow = async () => {
1551
1522
  return invoke$d('ElectronWindow.maximize');
1552
1523
  };
1524
+ const showSideBar = async (id, focus) => {
1525
+ return invoke$d('SideBar.show', id, focus);
1526
+ };
1553
1527
  const closeWindow = async () => {
1554
1528
  return invoke$d('ElectronWindow.close');
1555
1529
  };
@@ -1562,7 +1536,7 @@ const setExtensionsSearchValue = async searchValue => {
1562
1536
  const openExternal$1 = async uri => {
1563
1537
  await invoke$d('Open.openExternal', uri);
1564
1538
  };
1565
- const openUrl = async uri => {
1539
+ const openUrl$1 = async uri => {
1566
1540
  await invoke$d('Open.openUrl', uri);
1567
1541
  };
1568
1542
  const getAllPreferences = async () => {
@@ -1588,8 +1562,10 @@ const RendererWorker = {
1588
1562
  closeWidget,
1589
1563
  closeWindow,
1590
1564
  confirm,
1565
+ createViewlet,
1591
1566
  disableExtension,
1592
1567
  dispose: dispose$2,
1568
+ disposeEditor,
1593
1569
  enableExtension,
1594
1570
  getActiveEditorId,
1595
1571
  getAllExtensions,
@@ -1614,6 +1590,7 @@ const RendererWorker = {
1614
1590
  getPreference,
1615
1591
  getRecentlyOpened,
1616
1592
  getV8Version,
1593
+ getViewletModuleId,
1617
1594
  getWebViewSecret,
1618
1595
  getWindowId,
1619
1596
  getWorkspacePath,
@@ -1621,6 +1598,8 @@ const RendererWorker = {
1621
1598
  handleDebugPaused,
1622
1599
  handleDebugResumed,
1623
1600
  handleDebugScriptParsed,
1601
+ handleModifiedStatusChange,
1602
+ handleUriChange,
1624
1603
  handleWorkspaceRefresh,
1625
1604
  installExtension,
1626
1605
  invoke: invoke$d,
@@ -1632,7 +1611,7 @@ const RendererWorker = {
1632
1611
  openExternal: openExternal$1,
1633
1612
  openNativeFolder,
1634
1613
  openUri,
1635
- openUrl,
1614
+ openUrl: openUrl$1,
1636
1615
  openWidget,
1637
1616
  readClipBoardText,
1638
1617
  readFile,
@@ -1641,6 +1620,8 @@ const RendererWorker = {
1641
1620
  registerWebViewInterceptor,
1642
1621
  renderMarkdown,
1643
1622
  rerenderEditor,
1623
+ resizeViewlet,
1624
+ saveEditor,
1644
1625
  searchFileFetch,
1645
1626
  searchFileHtml,
1646
1627
  searchFileMemory,
@@ -1674,36 +1655,57 @@ const RendererWorker = {
1674
1655
  showContextMenu2,
1675
1656
  showErrorDialog,
1676
1657
  showMessageBox,
1658
+ showPanel,
1659
+ showPreview,
1677
1660
  showSaveFilePicker,
1661
+ showSideBar,
1662
+ togglePanelView,
1678
1663
  uninstallExtension,
1679
1664
  unmaximizeWindow,
1680
1665
  unregisterWebViewInterceptor,
1681
1666
  writeClipBoardImage,
1682
- writeClipBoardText
1667
+ writeClipBoardText,
1668
+ writeFile
1683
1669
  };
1684
1670
 
1685
1671
  const {
1686
1672
  invoke: invoke$c,
1687
1673
  set: set$b
1688
1674
  } = create$a(OpenerWorker);
1675
+ const openUrl = async (url, platform) => {
1676
+ return invoke$c('Open.openUrl', url, platform);
1677
+ };
1689
1678
 
1690
1679
  const {
1680
+ invoke: invoke$b,
1691
1681
  set: set$a
1692
1682
  } = create$a(IconThemeWorker);
1693
1683
 
1694
1684
  const {
1695
1685
  dispose: dispose$1,
1696
- invoke: invoke$b,
1686
+ invoke: invoke$a,
1697
1687
  invokeAndTransfer,
1698
1688
  set: set$9
1699
1689
  } = create$a(MarkdownWorker);
1690
+ const tokenizeIncremental = (uid, languageId, oldLine, newLine, rowIndex, minLineY) => {
1691
+ return invoke$a('TokenizeIncremental.tokenizeIncremental', uid, languageId, oldLine, newLine, rowIndex, minLineY);
1692
+ };
1693
+ const getTokensViewPort = (slimEditor, startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend) => {
1694
+ return invoke$a('GetTokensViewport.getTokensViewport', slimEditor, startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
1695
+ };
1696
+ const loadTokenizer$1 = (languageId, tokenizerPath) => {
1697
+ return invoke$a('Tokenizer.load', languageId, tokenizerPath);
1698
+ };
1700
1699
 
1701
1700
  const SyntaxHighlightingWorker = {
1702
1701
  __proto__: null,
1703
1702
  dispose: dispose$1,
1704
- invoke: invoke$b,
1703
+ getTokensViewPort,
1704
+ invoke: invoke$a,
1705
1705
  invokeAndTransfer,
1706
- set: set$9
1706
+ loadTokenizer: loadTokenizer$1,
1707
+ set: set$9,
1708
+ tokenizeIncremental
1707
1709
  };
1708
1710
 
1709
1711
  const createLazyRpc = rpcId => {
@@ -1776,7 +1778,7 @@ const create$9 = () => {
1776
1778
  },
1777
1779
  getKeys() {
1778
1780
  return Object.keys(states).map(key => {
1779
- return Number.parseInt(key);
1781
+ return Number.parseFloat(key);
1780
1782
  });
1781
1783
  },
1782
1784
  registerCommands(commandMap) {
@@ -1818,6 +1820,37 @@ const create$9 = () => {
1818
1820
  return fn(newState, ...args);
1819
1821
  };
1820
1822
  return wrapped;
1823
+ },
1824
+ wrapLoadContent(fn) {
1825
+ const wrapped = async (uid, ...args) => {
1826
+ const {
1827
+ newState,
1828
+ oldState
1829
+ } = states[uid];
1830
+ const result = await fn(newState, ...args);
1831
+ const {
1832
+ error,
1833
+ state
1834
+ } = result;
1835
+ if (oldState === state || newState === state) {
1836
+ return {
1837
+ error
1838
+ };
1839
+ }
1840
+ const latestOld = states[uid];
1841
+ const latestNew = {
1842
+ ...latestOld.newState,
1843
+ ...state
1844
+ };
1845
+ states[uid] = {
1846
+ newState: latestNew,
1847
+ oldState: latestOld.oldState
1848
+ };
1849
+ return {
1850
+ error
1851
+ };
1852
+ };
1853
+ return wrapped;
1821
1854
  }
1822
1855
  };
1823
1856
  };
@@ -1830,7 +1863,7 @@ const activateByEvent = async (event, assetDir, platform) => {
1830
1863
  string(event);
1831
1864
  // Assert.string(assetDir)
1832
1865
  // Assert.number(platform)
1833
- await invoke$d('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
1866
+ await activateByEvent$1(event, assetDir, platform);
1834
1867
  };
1835
1868
 
1836
1869
  const codeGeneratorAccept = state => {
@@ -1841,7 +1874,7 @@ const codeGeneratorAccept = state => {
1841
1874
  const ModuleWorkerAndWorkaroundForChromeDevtoolsBug = 6;
1842
1875
 
1843
1876
  const launchWorker = async (name, url, intializeCommand) => {
1844
- const rpc = await create$c({
1877
+ const rpc = await create$e({
1845
1878
  commandMap: {},
1846
1879
  isMessagePortOpen: true,
1847
1880
  async send(port) {
@@ -1873,7 +1906,7 @@ const getOrCreate$3 = () => {
1873
1906
  }
1874
1907
  return workerPromise$3;
1875
1908
  };
1876
- const invoke$a = async (method, ...params) => {
1909
+ const invoke$9 = async (method, ...params) => {
1877
1910
  const worker = await getOrCreate$3();
1878
1911
  return await worker.invoke(method, ...params);
1879
1912
  };
@@ -1886,10 +1919,10 @@ const loadContent$3 = async (state, parentUid) => {
1886
1919
  x,
1887
1920
  y
1888
1921
  } = state;
1889
- await invoke$a('ColorPicker.create', uid, x, y, width, height, parentUid);
1890
- await invoke$a('ColorPicker.loadContent', uid);
1891
- const diff = await invoke$a('ColorPicker.diff2', uid);
1892
- const commands = await invoke$a('ColorPicker.render2', uid, diff);
1922
+ await invoke$9('ColorPicker.create', uid, x, y, width, height, parentUid);
1923
+ await invoke$9('ColorPicker.loadContent', uid);
1924
+ const diff = await invoke$9('ColorPicker.diff2', uid);
1925
+ const commands = await invoke$9('ColorPicker.render2', uid, diff);
1893
1926
  return {
1894
1927
  ...state,
1895
1928
  commands
@@ -1899,6 +1932,7 @@ const loadContent$3 = async (state, parentUid) => {
1899
1932
  const {
1900
1933
  get: get$7,
1901
1934
  getCommandIds,
1935
+ registerCommands,
1902
1936
  set: set$8,
1903
1937
  wrapCommand: wrapCommand$1,
1904
1938
  wrapGetter
@@ -1906,7 +1940,7 @@ const {
1906
1940
 
1907
1941
  const emptyIncrementalEdits = [];
1908
1942
 
1909
- const ColorPicker = 41;
1943
+ const ColorPicker$1 = 41;
1910
1944
  const EditorCompletion = 9;
1911
1945
  const Empty = 0;
1912
1946
  const FindWidget = 16;
@@ -1990,6 +2024,73 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
1990
2024
  set$8(id, editor, editor);
1991
2025
  };
1992
2026
 
2027
+ const AltKey = 'event.altKey';
2028
+ const Button = 'event.button';
2029
+ const ClientX = 'event.clientX';
2030
+ const ClientY = 'event.clientY';
2031
+ const DeltaMode = 'event.deltaMode';
2032
+ const DeltaY = 'event.deltaY';
2033
+
2034
+ const Backspace = 1;
2035
+ const Tab$1 = 2;
2036
+ const Enter = 3;
2037
+ const Escape = 8;
2038
+ const Space$1 = 9;
2039
+ const End = 255;
2040
+ const Home = 12;
2041
+ const LeftArrow = 13;
2042
+ const UpArrow = 14;
2043
+ const RightArrow = 15;
2044
+ const DownArrow = 16;
2045
+ const Delete$1 = 18;
2046
+ const KeyA = 29;
2047
+ const KeyC = 31;
2048
+ const KeyD = 32;
2049
+ const KeyF = 34;
2050
+ const KeyH = 36;
2051
+ const KeyJ = 38;
2052
+ const KeyK = 39;
2053
+ const KeyL = 40;
2054
+ const KeyO = 43;
2055
+ const KeyV = 50;
2056
+ const KeyX = 52;
2057
+ const KeyZ = 54;
2058
+ const F2 = 58;
2059
+ const F3 = 59;
2060
+ const F4 = 60;
2061
+ const F12 = 68;
2062
+ const Period = 87;
2063
+ const Slash$1 = 88;
2064
+ const BracketLeft = 90;
2065
+ const BracketRight = 92;
2066
+
2067
+ const CodeGenerator = 1;
2068
+ const ColorPicker = 2;
2069
+ const Completion = 3;
2070
+ const CompletionDetail = 4;
2071
+ const Find = 5;
2072
+ const Hover = 6;
2073
+ const Rename$1 = 7;
2074
+ const SourceAction$1 = 8;
2075
+
2076
+ const CtrlCmd = 1 << 11 >>> 0;
2077
+ const Shift = 1 << 10 >>> 0;
2078
+ const Alt$1 = 1 << 9 >>> 0;
2079
+
2080
+ const Editor$1 = 3;
2081
+ const SourceControl = 22;
2082
+
2083
+ const Separator = 1;
2084
+ const None = 0;
2085
+
2086
+ const FocusSelector = 'Viewlet.focusSelector';
2087
+ const SetCss$1 = 'Viewlet.setCss';
2088
+ const SetFocusContext$1 = 'Viewlet.setFocusContext';
2089
+ const SetPatches = 'Viewlet.setPatches';
2090
+
2091
+ const FocusEditorText$1 = 12;
2092
+ const FocusExplorer = 13;
2093
+
1993
2094
  // TODO use numeric enum
1994
2095
  const CompositionUpdate = 'compositionUpdate';
1995
2096
  const ContentEditableInput = 'contentEditableInput';
@@ -2264,7 +2365,7 @@ const getEnabled$1 = () => {
2264
2365
  };
2265
2366
 
2266
2367
  const {
2267
- invoke: invoke$9,
2368
+ invoke: invoke$8,
2268
2369
  set: set$5
2269
2370
  } = SyntaxHighlightingWorker;
2270
2371
 
@@ -2300,7 +2401,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
2300
2401
  }
2301
2402
  if (getEnabled$1()) {
2302
2403
  // @ts-ignore
2303
- const tokenMap = await invoke$9('Tokenizer.load', languageId, tokenizePath);
2404
+ const tokenMap = await invoke$8('Tokenizer.load', languageId, tokenizePath);
2304
2405
  set$3(languageId, tokenMap);
2305
2406
  return;
2306
2407
  }
@@ -2476,13 +2577,13 @@ const getTokensViewport2 = async (editor, startLineIndex, endLineIndex, syncIncr
2476
2577
  invalidStartIndex,
2477
2578
  languageId
2478
2579
  };
2479
- return invoke$9('GetTokensViewport.getTokensViewport', slimEditor,
2580
+ return invoke$8('GetTokensViewport.getTokensViewport', slimEditor,
2480
2581
  // @ts-ignore
2481
2582
  startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
2482
2583
  }
2483
2584
  // TODO only send needed lines of text
2484
2585
  // @ts-ignore
2485
- return invoke$9('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
2586
+ return invoke$8('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
2486
2587
  }
2487
2588
  return getTokensViewport(editor, startLineIndex, endLineIndex);
2488
2589
  };
@@ -3186,7 +3287,7 @@ const getIncrementalEdits = async (oldState, newState) => {
3186
3287
  const oldLine = oldState.lines[rowIndex];
3187
3288
  const newLine = lines[rowIndex];
3188
3289
  // @ts-ignore
3189
- const incrementalEdits = await invoke$9(
3290
+ const incrementalEdits = await invoke$8(
3190
3291
  // @ts-ignore
3191
3292
  'TokenizeIncremental.tokenizeIncremental', newState.uid,
3192
3293
  // @ts-ignore
@@ -3385,11 +3486,11 @@ const splitLines = lines => {
3385
3486
  };
3386
3487
 
3387
3488
  const {
3388
- invoke: invoke$8} = RendererWorker;
3489
+ invoke: invoke$7} = RendererWorker;
3389
3490
 
3390
3491
  const notifyTabModifiedStatusChange = async uri => {
3391
3492
  try {
3392
- await invoke$8('Main.handleModifiedStatusChange', uri, true);
3493
+ await invoke$7('Main.handleModifiedStatusChange', uri, true);
3393
3494
  } catch {
3394
3495
  // ignore
3395
3496
  }
@@ -3425,13 +3526,8 @@ const measureTextWidthFast = async (text, charWidth) => {
3425
3526
  return text.length * charWidth;
3426
3527
  };
3427
3528
 
3428
- const {
3429
- invoke: invoke$7,
3430
- setFactory: setFactory$1
3431
- } = createLazyRpc(TextMeasurementWorker);
3432
-
3433
3529
  const measureTextWidthSlow = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
3434
- const width = await invoke$7('TextMeasurement.measureTextWidth', text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
3530
+ const width = await invoke$b('TextMeasurement.measureTextWidth', text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
3435
3531
  return width;
3436
3532
  };
3437
3533
 
@@ -4082,7 +4178,7 @@ const getLanguageId$1 = (uri, languages) => {
4082
4178
  const getLanguages = async (platform, assetDir) => {
4083
4179
  number(platform);
4084
4180
  string(assetDir);
4085
- const languages = await invoke$e('Extensions.getLanguages', platform, assetDir);
4181
+ const languages = await getLanguages$1(platform, assetDir);
4086
4182
  return languages;
4087
4183
  };
4088
4184
 
@@ -4091,7 +4187,7 @@ const measureCharacterWidth = async (fontWeight, fontSize, fontFamily, letterSpa
4091
4187
  };
4092
4188
 
4093
4189
  const get$1 = async key => {
4094
- const value = await invoke$d('Preferences.get', key);
4190
+ const value = await getPreference(key);
4095
4191
  return value;
4096
4192
  };
4097
4193
 
@@ -5064,7 +5160,7 @@ const create$7 = () => {
5064
5160
  const create$6 = () => {
5065
5161
  const completionUid = create$7();
5066
5162
  const widget = {
5067
- id: ColorPicker$1,
5163
+ id: ColorPicker,
5068
5164
  newState: {
5069
5165
  commands: [],
5070
5166
  height: 0,
@@ -5089,7 +5185,7 @@ const newStateGenerator$6 = (state, parentUid) => {
5089
5185
  return loadContent$3(state, parentUid);
5090
5186
  };
5091
5187
  const openColorPicker = async editor => {
5092
- return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$6);
5188
+ return addWidgetToEditor(ColorPicker, ColorPicker$1, editor, create$6, newStateGenerator$6);
5093
5189
  };
5094
5190
 
5095
5191
  const state$4 = {
@@ -5145,7 +5241,7 @@ const compositionEnd = (editor, data) => {
5145
5241
  const writeText = async text => {
5146
5242
  try {
5147
5243
  string(text);
5148
- await invoke$d('ClipBoard.writeText', /* text */text);
5244
+ await writeClipBoardText(text);
5149
5245
  } catch (error) {
5150
5246
  throw new VError(error, 'Failed to write text to clipboard');
5151
5247
  }
@@ -6105,7 +6201,7 @@ const goTo = async ({
6105
6201
  startColumnIndex: definition.startColumnIndex,
6106
6202
  startRowIndex: definition.startRowIndex
6107
6203
  };
6108
- await invoke$d(/* Main.openUri */'Main.openUri', /* uri */uri, /* focus */true, context);
6204
+ await openUri(uri, true, context);
6109
6205
  return editor;
6110
6206
  } catch (error) {
6111
6207
  // TODO if editor is already disposed at this point, do nothing
@@ -6255,8 +6351,7 @@ const setPosition$1 = position => {
6255
6351
  };
6256
6352
 
6257
6353
  const openExternal = async (url, platform) => {
6258
- // @ts-ignore
6259
- await invoke$c('Open.openUrl', url, platform);
6354
+ await openUrl(url, platform);
6260
6355
  };
6261
6356
 
6262
6357
  // TODO first change cursor position, then run go to definition
@@ -7545,8 +7640,7 @@ const pasteText = (editor, text) => {
7545
7640
  };
7546
7641
 
7547
7642
  const paste = async editor => {
7548
- // @ts-ignore
7549
- const text = await invoke$d('ClipBoard.readText');
7643
+ const text = await readClipBoardText();
7550
7644
  string(text);
7551
7645
  return pasteText(editor, text);
7552
7646
  };
@@ -7706,7 +7800,7 @@ const saveUntitledFile = async (uri, content, platform) => {
7706
7800
  return;
7707
7801
  }
7708
7802
  await invoke$d('FileSystem.writeFile', filePath, content);
7709
- await invoke$d('Layout.handleWorkspaceRefresh');
7803
+ await handleWorkspaceRefresh();
7710
7804
  await invoke$d('Main.handleUriChange', uri, filePath);
7711
7805
  return filePath;
7712
7806
  };
@@ -9376,7 +9470,7 @@ const editorUnindent = editor => {
9376
9470
 
9377
9471
  const isFunctional = widgetId => {
9378
9472
  switch (widgetId) {
9379
- case ColorPicker$1:
9473
+ case ColorPicker:
9380
9474
  case Completion:
9381
9475
  case Find:
9382
9476
  case Hover:
@@ -9421,8 +9515,8 @@ const addWidget$1 = (widget, id, render) => {
9421
9515
 
9422
9516
  const getWidgetInvoke = widgetId => {
9423
9517
  switch (widgetId) {
9424
- case ColorPicker$1:
9425
- return invoke$a;
9518
+ case ColorPicker:
9519
+ return invoke$9;
9426
9520
  case Completion:
9427
9521
  return invoke$4;
9428
9522
  case Find:
@@ -9898,13 +9992,13 @@ const HandleWheel = 'handleWheel';
9898
9992
  const Div = 4;
9899
9993
  const Input = 6;
9900
9994
  const Span = 8;
9901
- const Text = 12;
9995
+ const Text$1 = 12;
9902
9996
 
9903
9997
  const text = data => {
9904
9998
  return {
9905
9999
  childCount: 0,
9906
10000
  text: data,
9907
- type: Text
10001
+ type: Text$1
9908
10002
  };
9909
10003
  };
9910
10004
 
@@ -10328,7 +10422,7 @@ const getDiagnostics$1 = async editorUid => {
10328
10422
  };
10329
10423
 
10330
10424
  const ensure = async (fontName, fontUrl) => {
10331
- await invoke$7('TextMeasurement.ensureFont', fontName, fontUrl);
10425
+ await invoke$b('TextMeasurement.ensureFont', fontName, fontUrl);
10332
10426
  };
10333
10427
 
10334
10428
  const getKeyBindings = () => {
@@ -10886,7 +10980,7 @@ const handleBeforeInput = (editor, inputType, data) => {
10886
10980
  };
10887
10981
 
10888
10982
  const handleMessagePort = async (port, rpcId) => {
10889
- const rpc = await create$d({
10983
+ const rpc = await create$c({
10890
10984
  commandMap: {},
10891
10985
  messagePort: port
10892
10986
  });
@@ -11000,13 +11094,13 @@ const hotReload = async () => {
11000
11094
  };
11001
11095
 
11002
11096
  const sendMessagePortToExtensionHostWorker2 = async (port, initialCommand, rpcId) => {
11003
- await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, initialCommand, rpcId);
11097
+ await sendMessagePortToExtensionHostWorker(port, rpcId);
11004
11098
  };
11005
11099
 
11006
11100
  const createExtensionHostRpc = async () => {
11007
11101
  try {
11008
11102
  const initialCommand = 'HandleMessagePort.handleMessagePort2';
11009
- const rpc = await create$c({
11103
+ const rpc = await create$e({
11010
11104
  commandMap: {},
11011
11105
  async send(port) {
11012
11106
  await sendMessagePortToExtensionHostWorker2(port, initialCommand, EditorWorker);
@@ -11025,7 +11119,7 @@ const initializeExtensionHost = async () => {
11025
11119
 
11026
11120
  const createExtensionManagementWorkerRpc = async () => {
11027
11121
  try {
11028
- const rpc = await create$c({
11122
+ const rpc = await create$e({
11029
11123
  commandMap: {},
11030
11124
  async send(port) {
11031
11125
  await sendMessagePortToExtensionManagementWorker(port, EditorWorker);
@@ -11046,15 +11140,15 @@ const initializeExtensionManagementWorker = async () => {
11046
11140
  }
11047
11141
  };
11048
11142
 
11049
- const send$2 = port => {
11143
+ const send$1 = port => {
11050
11144
  // @ts-ignore
11051
11145
  return sendMessagePortToOpenerWorker(port);
11052
11146
  };
11053
11147
  const initializeOpenerWorker = async () => {
11054
11148
  try {
11055
- const rpc = await create$f({
11149
+ const rpc = await create$d({
11056
11150
  commandMap: {},
11057
- send: send$2
11151
+ send: send$1
11058
11152
  });
11059
11153
  set$b(rpc);
11060
11154
  } catch {
@@ -11064,10 +11158,9 @@ const initializeOpenerWorker = async () => {
11064
11158
 
11065
11159
  const sendMessagePortToSyntaxHighlightingWorker = async port => {
11066
11160
  try {
11067
- await invokeAndTransfer$1(
11068
- // @ts-ignore
11069
- 'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
11161
+ await sendMessagePortToSyntaxHighlightingWorker$1(port);
11070
11162
  } catch {
11163
+ // deprecated
11071
11164
  await invokeAndTransfer$1(
11072
11165
  // @ts-ignore
11073
11166
  'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
@@ -11076,7 +11169,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
11076
11169
 
11077
11170
  const createSyntaxHighlightingWorkerRpc = async () => {
11078
11171
  try {
11079
- const rpc = await create$c({
11172
+ const rpc = await create$e({
11080
11173
  commandMap: {},
11081
11174
  send: sendMessagePortToSyntaxHighlightingWorker
11082
11175
  });
@@ -11097,19 +11190,15 @@ const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncre
11097
11190
  }
11098
11191
  };
11099
11192
 
11100
- const send$1 = port => {
11193
+ const send = port => {
11101
11194
  return sendMessagePortToTextMeasurementWorker(port);
11102
11195
  };
11103
11196
  const initializeTextMeasurementWorker = async () => {
11104
- try {
11105
- const rpc = await create$f({
11106
- commandMap: {},
11107
- send: send$1
11108
- });
11109
- set$a(rpc);
11110
- } catch {
11111
- // ignore
11112
- }
11197
+ const rpc = await create$d({
11198
+ commandMap: {},
11199
+ send
11200
+ });
11201
+ set$a(rpc);
11113
11202
  };
11114
11203
 
11115
11204
  const launchCompletionWorker = async () => {
@@ -11196,6 +11285,14 @@ const getEditorPreferences = async () => {
11196
11285
  };
11197
11286
  };
11198
11287
 
11288
+ const getTokenizePath = (languages, languageId) => {
11289
+ for (const language of languages) {
11290
+ if (language?.id === languageId) {
11291
+ return language.tokenize || '';
11292
+ }
11293
+ }
11294
+ return '';
11295
+ };
11199
11296
  const loadContent = async (state, savedState) => {
11200
11297
  const {
11201
11298
  assetDir,
@@ -11225,7 +11322,12 @@ const loadContent = async (state, savedState) => {
11225
11322
  // TODO support overwriting language id by setting it explicitly or via settings
11226
11323
  const charWidth = await measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing);
11227
11324
  const languages = await getLanguages(platform, assetDir);
11228
- const computedlanguageId = getLanguageId$1(uri, languages);
11325
+ const computedLanguageId = getLanguageId$1(uri, languages);
11326
+ const tokenizePath = getTokenizePath(languages, computedLanguageId);
11327
+ await loadTokenizer(computedLanguageId, tokenizePath);
11328
+ const tokenizer = getTokenizer(computedLanguageId);
11329
+ const newTokenizerId = state.tokenizerId + 1;
11330
+ set$2(newTokenizerId, tokenizer);
11229
11331
  const newEditor0 = {
11230
11332
  ...state,
11231
11333
  charWidth,
@@ -11238,11 +11340,12 @@ const loadContent = async (state, savedState) => {
11238
11340
  isAutoClosingQuotesEnabled,
11239
11341
  isAutoClosingTagsEnabled,
11240
11342
  isQuickSuggestionsEnabled,
11241
- languageId: computedlanguageId,
11343
+ languageId: computedLanguageId,
11242
11344
  letterSpacing,
11243
11345
  lineNumbers,
11244
11346
  rowHeight,
11245
- tabSize
11347
+ tabSize,
11348
+ tokenizerId: newTokenizerId
11246
11349
  };
11247
11350
  const content = await readFile(uri);
11248
11351
 
@@ -11273,7 +11376,7 @@ const loadContent = async (state, savedState) => {
11273
11376
  // TODO only sync when needed
11274
11377
  // e.g. it might not always be necessary to send text to extension host worker
11275
11378
  // @ts-ignore
11276
- await invoke$6(TextDocumentSyncFull, uri, id, computedlanguageId, content);
11379
+ await invoke$6(TextDocumentSyncFull, uri, id, computedLanguageId, content);
11277
11380
 
11278
11381
  // TODO await promise
11279
11382
  if (diagnosticsEnabled) {
@@ -11380,6 +11483,9 @@ const renderFocusContext$1 = (oldState, newState) => {
11380
11483
  return [SetFocusContext$1, newState.uid, FocusExplorer];
11381
11484
  };
11382
11485
 
11486
+ const Text = 12;
11487
+ const Reference = 100;
11488
+
11383
11489
  const SetText = 1;
11384
11490
  const Replace = 2;
11385
11491
  const SetAttribute = 3;
@@ -11468,7 +11574,7 @@ const compareNodes = (oldNode, newNode) => {
11468
11574
  return patches;
11469
11575
  }
11470
11576
  // Handle text nodes
11471
- if (oldNode.type === Text$1 && newNode.type === Text$1) {
11577
+ if (oldNode.type === Text && newNode.type === Text) {
11472
11578
  if (oldNode.text !== newNode.text) {
11473
11579
  patches.push({
11474
11580
  type: SetText,
@@ -11861,7 +11967,7 @@ const getEditorVirtualDom = ({
11861
11967
  };
11862
11968
 
11863
11969
  const getDom = state => {
11864
- if (state.initial) {
11970
+ if (state.initial && state.textInfos.length === 0) {
11865
11971
  return [];
11866
11972
  }
11867
11973
  return getEditorVirtualDom(state);
@@ -12137,7 +12243,7 @@ const renderEventListeners = () => {
12137
12243
  params: ['handleFocus']
12138
12244
  }, {
12139
12245
  name: HandleMouseMove,
12140
- params: ['handleInput', 'event.clientX', 'event.clientY', 'event.altKey']
12246
+ params: ['handleInput', ClientX, ClientY, AltKey]
12141
12247
  }, {
12142
12248
  name: HandleBlur,
12143
12249
  params: ['handleBlur']
@@ -12159,11 +12265,11 @@ const renderEventListeners = () => {
12159
12265
  preventDefault: true
12160
12266
  }, {
12161
12267
  name: HandleWheel,
12162
- params: ['setDelta', 'event.deltaMode', 'event.deltaY'],
12163
- preventDefault: true
12268
+ params: ['setDelta', DeltaMode, DeltaY],
12269
+ passive: true
12164
12270
  }, {
12165
12271
  name: HandleContextMenu,
12166
- params: ['handleContextMenu', 'event.button', 'event.clientX', 'event.clientY'],
12272
+ params: ['handleContextMenu', Button, ClientX, ClientY],
12167
12273
  preventDefault: true
12168
12274
  }];
12169
12275
  };
@@ -12499,25 +12605,15 @@ const commandMap = {
12499
12605
  'Listener.unregister': unregisterListener,
12500
12606
  'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker': sendMessagePortToExtensionHostWorker2
12501
12607
  };
12502
-
12503
- const send = port => {
12504
- // @ts-ignore
12505
- return sendMessagePortToTextMeasurementWorker(port);
12506
- };
12507
- const createTextMeasurementWorkerRpc = async () => {
12508
- try {
12509
- const rpc = await create$c({
12510
- commandMap: {},
12511
- send
12512
- });
12513
- return rpc;
12514
- } catch (error) {
12515
- throw new VError(error, `Failed to create text measurement worker rpc`);
12608
+ for (const [key, value] of Object.entries(commandMap)) {
12609
+ if (key.startsWith('Editor.')) {
12610
+ // @ts-ignore
12611
+ commandMap['EditorText' + key.slice('Editor'.length)] = value;
12516
12612
  }
12517
- };
12613
+ }
12518
12614
 
12519
12615
  const listen = async () => {
12520
- setFactory$1(createTextMeasurementWorkerRpc);
12616
+ registerCommands(commandMap);
12521
12617
  const rpc = await create$b({
12522
12618
  commandMap: commandMap
12523
12619
  });
@@ -12819,7 +12915,7 @@ const EditorHoverWidget = {
12819
12915
  };
12820
12916
 
12821
12917
  const registerWidgets = () => {
12822
- set$7(ColorPicker$1, EditorColorPickerWidget);
12918
+ set$7(ColorPicker, EditorColorPickerWidget);
12823
12919
  set$7(Completion, EditorCompletionWidget);
12824
12920
  set$7(CompletionDetail, EditorCompletionDetailWidget);
12825
12921
  set$7(Find, EditorFindWidget);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "18.4.0",
3
+ "version": "18.6.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"