@lvce-editor/status-bar-worker 3.35.2 → 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.
- package/dist/statusBarWorkerMain.js +18 -11
- package/package.json +1 -1
|
@@ -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
|
|
2487
|
-
if (
|
|
2486
|
+
const measureTextWidths = async requests => {
|
|
2487
|
+
if (requests.length === 0) {
|
|
2488
2488
|
return [];
|
|
2489
2489
|
}
|
|
2490
|
-
const cachedWidths = await Promise.all(
|
|
2491
|
-
|
|
2492
|
-
|
|
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(
|
|
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 =
|
|
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(
|
|
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
|
|
2529
|
-
|
|
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;
|