@lvce-editor/editor-worker 13.2.0 → 13.4.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.
@@ -899,7 +899,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
899
899
  const responseMessage = await promise;
900
900
  return unwrapJsonRpcResult(responseMessage);
901
901
  };
902
- const send = (transport, method, ...params) => {
902
+ const send$1 = (transport, method, ...params) => {
903
903
  const message = create$4$2(method, params);
904
904
  transport.send(message);
905
905
  };
@@ -939,7 +939,7 @@ const createRpc = ipc => {
939
939
  * @deprecated
940
940
  */
941
941
  send(method, ...params) {
942
- send(ipc, method, ...params);
942
+ send$1(ipc, method, ...params);
943
943
  },
944
944
  invoke(method, ...params) {
945
945
  return invoke$c(ipc, method, ...params);
@@ -1136,6 +1136,7 @@ const EditorWorker = 99;
1136
1136
  const ExtensionHostWorker = 44;
1137
1137
  const MarkdownWorker = 300;
1138
1138
  const RendererWorker = 1;
1139
+ const TextMeasurementWorker = 7011;
1139
1140
 
1140
1141
  const FocusEditorText$1 = 12;
1141
1142
 
@@ -1216,6 +1217,11 @@ const {
1216
1217
  invoke: invoke$a,
1217
1218
  invokeAndTransfer: invokeAndTransfer$1,
1218
1219
  set: set$9} = create$9(RendererWorker);
1220
+ const sendMessagePortToTextMeasurementWorker = async port => {
1221
+ const command = 'TextMeasurement.handleMessagePort';
1222
+ // @ts-ignore
1223
+ await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
1224
+ };
1219
1225
 
1220
1226
  const {
1221
1227
  invoke: invoke$9,
@@ -2435,6 +2441,11 @@ const getTabCount = string => {
2435
2441
  return count;
2436
2442
  };
2437
2443
 
2444
+ const RE_ASCII = /^[\p{ASCII}]*$/u;
2445
+ const isAscii = line => {
2446
+ return RE_ASCII.test(line);
2447
+ };
2448
+
2438
2449
  const measureTextWidthFast = async (text, charWidth) => {
2439
2450
  return text.length * charWidth;
2440
2451
  };
@@ -2497,7 +2508,11 @@ const measureTextWidthSlow = async (text, fontWeight, fontSize, fontFamily, lett
2497
2508
  };
2498
2509
 
2499
2510
  const measureTextWidth = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
2500
- if (isMonoSpaceFont) {
2511
+ // TODO maybe have a property for the whole text document
2512
+ // whether the document is ascii or not
2513
+ // so that it doesn't need to be checked on every cursor change
2514
+ // or scroll position change
2515
+ if (isMonoSpaceFont && isAscii(text)) {
2501
2516
  return await measureTextWidthFast(text, charWidth);
2502
2517
  }
2503
2518
  return await measureTextWidthSlow(text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
@@ -3646,11 +3661,6 @@ const getAccurateColumnIndexUnicode = async (line, guess, averageCharWidth, even
3646
3661
  return line.length;
3647
3662
  };
3648
3663
 
3649
- const RE_ASCII = /^[\p{ASCII}]*$/u;
3650
- const isAscii = line => {
3651
- return RE_ASCII.test(line);
3652
- };
3653
-
3654
3664
  const guessOffset = (eventX, averageCharWidth) => {
3655
3665
  const guess = Math.round(eventX / averageCharWidth);
3656
3666
  return guess;
@@ -6186,7 +6196,7 @@ const create$4 = () => {
6186
6196
  };
6187
6197
 
6188
6198
  const {
6189
- setFactory,
6199
+ setFactory: setFactory$1,
6190
6200
  invoke: invoke$4
6191
6201
  } = createLazyRpc(CompletionWorker);
6192
6202
 
@@ -9844,7 +9854,7 @@ const launchCompletionWorker = async () => {
9844
9854
  };
9845
9855
 
9846
9856
  const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
9847
- setFactory(launchCompletionWorker);
9857
+ setFactory$1(launchCompletionWorker);
9848
9858
  await Promise.all([initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental), initializeExtensionHost()]);
9849
9859
  };
9850
9860
 
@@ -10612,7 +10622,28 @@ const commandMap = {
10612
10622
  };
10613
10623
  wrapCommands(commandMap);
10614
10624
 
10625
+ const send = port => {
10626
+ // @ts-ignore
10627
+ return sendMessagePortToTextMeasurementWorker(port);
10628
+ };
10629
+ const createTextMeasurementWorkerRpc = async () => {
10630
+ try {
10631
+ const rpc = await TransferMessagePortRpcParent.create({
10632
+ commandMap: {},
10633
+ send
10634
+ });
10635
+ return rpc;
10636
+ } catch (error) {
10637
+ throw new VError(error, `Failed to create text measurement worker rpc`);
10638
+ }
10639
+ };
10640
+
10641
+ const {
10642
+ setFactory
10643
+ } = createLazyRpc(TextMeasurementWorker);
10644
+
10615
10645
  const listen = async () => {
10646
+ setFactory(createTextMeasurementWorkerRpc);
10616
10647
  const rpc = await WebWorkerRpcClient.create({
10617
10648
  commandMap: commandMap
10618
10649
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "13.2.0",
3
+ "version": "13.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"