@lvce-editor/status-bar-worker 3.35.2 → 3.36.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.
@@ -1219,6 +1219,12 @@ const {
1219
1219
  invokeAndTransfer,
1220
1220
  set: set$5
1221
1221
  } = create$2(RendererWorker);
1222
+ const initializeRendererWorkerForWorker = async commandMap => {
1223
+ const rpc = await create$3({
1224
+ commandMap
1225
+ });
1226
+ set$5(rpc);
1227
+ };
1222
1228
  const sendMessagePortToTextMeasurementWorker = async port => {
1223
1229
  const command = 'TextMeasurement.handleMessagePort';
1224
1230
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
@@ -1230,6 +1236,16 @@ const sendMessagePortToCacheWorker = async port => {
1230
1236
  const getPreference = async key => {
1231
1237
  return await invoke$3('Preferences.get', key);
1232
1238
  };
1239
+ const send3 = port => {
1240
+ return sendMessagePortToTextMeasurementWorker(port);
1241
+ };
1242
+ const initializeTextMeasurementWorker = async () => {
1243
+ const rpc = await create$4({
1244
+ commandMap: {},
1245
+ send: send3
1246
+ });
1247
+ set$6(rpc);
1248
+ };
1233
1249
 
1234
1250
  const toCommandId = key => {
1235
1251
  const dotIndex = key.indexOf('.');
@@ -2483,31 +2499,35 @@ const progressWidth = 69;
2483
2499
  const horizontalGroupPadding = 14;
2484
2500
  const measuredWidths = new WeakMap();
2485
2501
  const fallbackTextWidth = 150;
2486
- const measureTextWidths = async values => {
2487
- if (values.length === 0) {
2502
+ const measureTextWidths = async requests => {
2503
+ if (requests.length === 0) {
2488
2504
  return [];
2489
2505
  }
2490
- const cachedWidths = await Promise.all(values.map(value => getWidth(value)));
2491
- const missingValues = values.filter((_, index) => cachedWidths[index] === undefined);
2492
- if (missingValues.length === 0) {
2506
+ const cachedWidths = await Promise.all(requests.map(({
2507
+ persist,
2508
+ value
2509
+ }) => persist ? getWidth(value) : Promise.resolve(undefined)));
2510
+ const missing = requests.filter((_, index) => cachedWidths[index] === undefined);
2511
+ if (missing.length === 0) {
2493
2512
  return cachedWidths;
2494
2513
  }
2495
2514
  let measuredWidths;
2496
2515
  let measurementSucceeded = true;
2497
2516
  try {
2498
- measuredWidths = await measureTextWidths$1(missingValues, 400, fontSize, fontFamily, 0, false, 0);
2517
+ measuredWidths = await measureTextWidths$1(missing.map(request => request.value), 400, fontSize, fontFamily, 0, false, 0);
2499
2518
  } catch {
2500
2519
  measurementSucceeded = false;
2501
- measuredWidths = missingValues.map(() => fallbackTextWidth);
2520
+ measuredWidths = missing.map(() => fallbackTextWidth);
2502
2521
  }
2503
2522
  let measuredIndex = 0;
2504
2523
  const widths = cachedWidths.map(width => {
2505
2524
  if (width !== undefined) {
2506
2525
  return width;
2507
2526
  }
2527
+ const request = missing[measuredIndex];
2508
2528
  const measuredWidth = measuredWidths[measuredIndex++];
2509
- if (measurementSucceeded) {
2510
- void setWidth(missingValues[measuredIndex - 1], measuredWidth);
2529
+ if (measurementSucceeded && request.persist) {
2530
+ void setWidth(request.value, measuredWidth);
2511
2531
  }
2512
2532
  return measuredWidth;
2513
2533
  });
@@ -2525,8 +2545,11 @@ const getElementWidth = (element, textWidths, textIndex) => {
2525
2545
  };
2526
2546
  const getItemWidths = async items => {
2527
2547
  const unmeasuredItems = [...new Set(items.filter(item => !measuredWidths.has(item)))];
2528
- const textElements = unmeasuredItems.flatMap(item => item.elements.filter(element => element.type === 'text'));
2529
- const textWidths = await measureTextWidths(textElements.map(element => element.value));
2548
+ const textRequests = unmeasuredItems.flatMap(item => item.elements.filter(element => element.type === 'text').map(element => ({
2549
+ persist: item.name !== EditorPosition$1,
2550
+ value: element.value
2551
+ })));
2552
+ const textWidths = await measureTextWidths(textRequests);
2530
2553
  let textIndex = 0;
2531
2554
  for (const item of unmeasuredItems) {
2532
2555
  let itemWidth = itemPaddingAndMargin;
@@ -3368,25 +3391,6 @@ const initializeQuickPickWorker = async () => {
3368
3391
  set$3(rpc);
3369
3392
  };
3370
3393
 
3371
- const initializeRenderWorker = async () => {
3372
- const rpc = await create$3({
3373
- commandMap: commandMap
3374
- });
3375
- set$5(rpc);
3376
- };
3377
-
3378
- const send = port => {
3379
- // @ts-ignore
3380
- return sendMessagePortToTextMeasurementWorker(port);
3381
- };
3382
- const initializeTextMeasurementWorkerRpc = async () => {
3383
- const rpc = await create$4({
3384
- commandMap: {},
3385
- send
3386
- });
3387
- set$6(rpc);
3388
- };
3389
-
3390
3394
  const registerCacheWorker = async () => {
3391
3395
  const lazyRpc = await create$4({
3392
3396
  commandMap: {},
@@ -3403,7 +3407,7 @@ const registerCacheWorker = async () => {
3403
3407
  };
3404
3408
  const listen = async () => {
3405
3409
  registerCommands(commandMap);
3406
- await Promise.all([initializeRenderWorker(), initializeQuickPickWorker(), initializeMenuWorker(), initializeTextMeasurementWorkerRpc(), registerCacheWorker()]);
3410
+ await Promise.all([initializeRendererWorkerForWorker(commandMap), initializeQuickPickWorker(), initializeMenuWorker(), initializeTextMeasurementWorker(), registerCacheWorker()]);
3407
3411
  };
3408
3412
 
3409
3413
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "3.35.2",
3
+ "version": "3.36.0",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",