@lvce-editor/status-bar-worker 3.35.1 → 3.35.3

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.
@@ -2454,7 +2454,7 @@ const fontSize$1 = 12;
2454
2454
  const fontFamily$1 = 'system-ui, Ubuntu, Droid Sans, sans-serif';
2455
2455
  const getCacheKey = text => {
2456
2456
  const parameters = [text, 400, fontSize$1, fontFamily$1, 0, false, 0];
2457
- return `/status-bar-measurements/v1/${encodeURIComponent(JSON.stringify(parameters))}`;
2457
+ return `https://cache.invalid/status-bar-measurements/v1/${encodeURIComponent(JSON.stringify(parameters))}`;
2458
2458
  };
2459
2459
  const isValidWidth = value => {
2460
2460
  return typeof value === 'number' && Number.isFinite(value) && value >= 0;
@@ -2483,31 +2483,35 @@ const progressWidth = 69;
2483
2483
  const horizontalGroupPadding = 14;
2484
2484
  const measuredWidths = new WeakMap();
2485
2485
  const fallbackTextWidth = 150;
2486
- const measureTextWidths = async values => {
2487
- if (values.length === 0) {
2486
+ const measureTextWidths = async requests => {
2487
+ if (requests.length === 0) {
2488
2488
  return [];
2489
2489
  }
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) {
2490
+ const cachedWidths = await Promise.all(requests.map(({
2491
+ persist,
2492
+ value
2493
+ }) => persist ? getWidth(value) : Promise.resolve(undefined)));
2494
+ const missing = requests.filter((_, index) => cachedWidths[index] === undefined);
2495
+ if (missing.length === 0) {
2493
2496
  return cachedWidths;
2494
2497
  }
2495
2498
  let measuredWidths;
2496
2499
  let measurementSucceeded = true;
2497
2500
  try {
2498
- measuredWidths = await measureTextWidths$1(missingValues, 400, fontSize, fontFamily, 0, false, 0);
2501
+ measuredWidths = await measureTextWidths$1(missing.map(request => request.value), 400, fontSize, fontFamily, 0, false, 0);
2499
2502
  } catch {
2500
2503
  measurementSucceeded = false;
2501
- measuredWidths = missingValues.map(() => fallbackTextWidth);
2504
+ measuredWidths = missing.map(() => fallbackTextWidth);
2502
2505
  }
2503
2506
  let measuredIndex = 0;
2504
2507
  const widths = cachedWidths.map(width => {
2505
2508
  if (width !== undefined) {
2506
2509
  return width;
2507
2510
  }
2511
+ const request = missing[measuredIndex];
2508
2512
  const measuredWidth = measuredWidths[measuredIndex++];
2509
- if (measurementSucceeded) {
2510
- void setWidth(missingValues[measuredIndex - 1], measuredWidth);
2513
+ if (measurementSucceeded && request.persist) {
2514
+ void setWidth(request.value, measuredWidth);
2511
2515
  }
2512
2516
  return measuredWidth;
2513
2517
  });
@@ -2525,8 +2529,11 @@ const getElementWidth = (element, textWidths, textIndex) => {
2525
2529
  };
2526
2530
  const getItemWidths = async items => {
2527
2531
  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));
2532
+ const textRequests = unmeasuredItems.flatMap(item => item.elements.filter(element => element.type === 'text').map(element => ({
2533
+ persist: item.name !== EditorPosition$1,
2534
+ value: element.value
2535
+ })));
2536
+ const textWidths = await measureTextWidths(textRequests);
2530
2537
  let textIndex = 0;
2531
2538
  for (const item of unmeasuredItems) {
2532
2539
  let itemWidth = itemPaddingAndMargin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "3.35.1",
3
+ "version": "3.35.3",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",