fix(web): dynamically import wasm module ()

* 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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 77 additions and 77 deletions
web/src/lib/utils

View file

@ -0,0 +1,14 @@
import { getAssetRatio } from '$lib/utils/asset-utils';
// note: it's important that this is not imported in more than one file due to https://github.com/sveltejs/kit/issues/7805
import { JustifiedLayout, type LayoutOptions } from '@immich/justified-layout-wasm';
import type { AssetResponseDto } from '@immich/sdk';
export function getJustifiedLayoutFromAssets(assets: AssetResponseDto[], options: LayoutOptions) {
const aspectRatios = new Float32Array(assets.length);
// eslint-disable-next-line unicorn/no-for-loop
for (let i = 0; i < assets.length; i++) {
const { width, height } = getAssetRatio(assets[i]);
aspectRatios[i] = width / height;
}
return new JustifiedLayout(aspectRatios, options);
}