fix(web): dynamically import wasm module (#16261)

* dynamically import wasm module

* remove unused import
This commit is contained in:
Mert
2025-02-22 21:16:06 +03:00
committed by GitHub
parent e4b6efc1f5
commit 4376fd72b7
7 changed files with 77 additions and 77 deletions

View File

@@ -1,7 +1,6 @@
import { locale } from '$lib/stores/preferences.store';
import { getKey } from '$lib/utils';
import { AssetGridTaskManager } from '$lib/utils/asset-store-task-manager';
import { getJustifiedLayoutFromAssets } from '$lib/utils/asset-utils';
import { generateId } from '$lib/utils/generate-id';
import type { AssetGridRouteSearchParams } from '$lib/utils/navigation';
import { fromLocalDateTime, splitBucketIntoDateGroups, type DateGroup } from '$lib/utils/timeline-util';
@@ -436,7 +435,7 @@ export class AssetStore {
private async initialLayout(changedWidth: boolean) {
for (const bucket of this.buckets) {
this.updateGeometry(bucket, changedWidth);
await this.updateGeometry(bucket, changedWidth);
}
this.timelineHeight = this.buckets.reduce((accumulator, b) => accumulator + b.bucketHeight, 0);
@@ -454,7 +453,7 @@ export class AssetStore {
this.emit(false);
}
private updateGeometry(bucket: AssetBucket, invalidateHeight: boolean) {
private async updateGeometry(bucket: AssetBucket, invalidateHeight: boolean) {
if (invalidateHeight) {
bucket.isBucketHeightActual = false;
bucket.measured = false;
@@ -477,6 +476,8 @@ export class AssetStore {
rowHeight: 235,
rowWidth: Math.floor(viewportWidth),
};
// TODO: move this import and make this method sync after https://github.com/sveltejs/kit/issues/7805 is fixed
const { getJustifiedLayoutFromAssets } = await import('$lib/utils/layout-utils');
for (const assetGroup of bucket.dateGroups) {
if (!assetGroup.heightActual) {
const unwrappedWidth = (3 / 2) * assetGroup.assets.length * THUMBNAIL_HEIGHT * (7 / 10);
@@ -552,7 +553,7 @@ export class AssetStore {
bucket.assets = assets;
bucket.dateGroups = splitBucketIntoDateGroups(bucket, get(locale));
this.maxBucketAssets = Math.max(this.maxBucketAssets, assets.length);
this.updateGeometry(bucket, true);
await this.updateGeometry(bucket, true);
this.timelineHeight = this.buckets.reduce((accumulator, b) => accumulator + b.bucketHeight, 0);
bucket.loaded();
this.notifyListeners({ type: 'loaded', bucket });
@@ -679,7 +680,7 @@ export class AssetStore {
return bDate.diff(aDate).milliseconds;
});
bucket.dateGroups = splitBucketIntoDateGroups(bucket, get(locale));
this.updateGeometry(bucket, true);
void this.updateGeometry(bucket, true);
}
this.emit(true);
@@ -821,7 +822,7 @@ export class AssetStore {
}
if (changed) {
bucket.dateGroups = splitBucketIntoDateGroups(bucket, get(locale));
this.updateGeometry(bucket, true);
void this.updateGeometry(bucket, true);
}
}