feat: Enable native imaging for web

This commit is contained in:
Christian Kußowski 2025-10-24 13:32:59 +02:00
parent 55705942ef
commit 6e87353e08
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
5 changed files with 14 additions and 9 deletions

3
.gitignore vendored
View file

@ -13,7 +13,8 @@
prime
# libolm package
/assets/js/package
web/Imaging.js
web/Imaging.wasm
# IntelliJ related
*.iml

View file

@ -122,7 +122,8 @@ abstract class ClientManager {
AuthenticationTypes.sso,
},
nativeImplementations: nativeImplementations,
customImageResizer: PlatformInfos.isMobile ? customImageResizer : null,
customImageResizer:
PlatformInfos.isMobile || kIsWeb ? customImageResizer : null,
defaultNetworkRequestTimeout: const Duration(minutes: 30),
enableDehydratedDevices: true,
shareKeysWith: ShareKeysWith.values

View file

@ -18,12 +18,6 @@ import 'package:native_imaging/native_imaging.dart' as native;
Future<MatrixImageFileResizedResponse?> customImageResizer(
MatrixImageFileResizeArguments arguments,
) async {
if (kIsWeb) {
throw UnsupportedError(
'customImageResizer only supports non-web platforms.',
);
}
await native.init();
var imageBytes = arguments.bytes;

View file

@ -9,4 +9,12 @@ flutter_rust_bridge_codegen build-web --dart-root dart --rust-root $(readlink -f
cd ..
rm -f ./assets/vodozemac/vodozemac_bindings_dart*
mv .vodozemac/dart/web/pkg/vodozemac_bindings_dart* ./assets/vodozemac/
rm -rf .vodozemac
rm -rf .vodozemac
# Add native imaging:
cd web/
curl -L 'https://github.com/famedly/dart_native_imaging/releases/download/v0.2.1/native_imaging.zip' > native_imaging.zip # make sure to sync version with pubspec.yaml
unzip native_imaging.zip
mv js/* .
rmdir js
rm native_imaging.zip

View file

@ -33,6 +33,7 @@
<title>FluffyChat</title>
<link rel="manifest" href="manifest.json">
<link rel="stylesheet" type="text/css" href="splash/style.css">
<script src="Imaging.js"></script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>