Skip to content

Commit 0f0387a

Browse files
authored
Merge pull request #1054 from ionite34/dev
2.14.0
2 parents 078453c + f7b3b0d commit 0f0387a

File tree

337 files changed

+18209
-3479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+18209
-3479
lines changed

.aiexclude

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Docs
2+
LICENSE
3+
CHANGELOG.md
4+
5+
# Legacy
6+
StabilityMatrix/
7+
8+
# Tests
9+
*.verified.*
10+
11+
# Misc projects
12+
StabilityMatrix.Native/
13+
StabilityMatrix.Native.*/
14+
StabilityMatrix.Avalonia.Diagnostics/
15+
StabilityMatrix.Avalonia.Diagnostics/
16+
StabilityMatrix.UITests/
17+
18+
# Vendored
19+
Avalonia.Gif/
20+
21+
# Configs
22+
*.editorconfig
23+
*.DotSettings
24+
25+
# Assets
26+
*.svg
27+
StabilityMatrix.Avalonia/Assets/Fonts/
28+
StabilityMatrix.Avalonia/Assets/linux-x64/
29+
StabilityMatrix.Avalonia/Assets/macos-arm64/
30+
StabilityMatrix.Avalonia/Assets/win-x64/

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"husky": {
6-
"version": "0.6.0",
6+
"version": "0.7.2",
77
"commands": [
88
"husky"
99
],

.husky/task-runner.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
"group": "generate-openapi",
2020
"command": "dotnet",
2121
"args": ["refitter", "--settings-file", "./StabilityMatrix.Core/Api/LykosAuthApi/.refitter"]
22+
},
23+
{
24+
"name": "Run refitter for PromptGenApi",
25+
"group": "generate-promptgen-openapi",
26+
"command": "dotnet",
27+
"args": ["refitter", "--settings-file", "./StabilityMatrix.Core/Api/PromptGen/.refitter"]
2228
}
2329
]
2430
}

Avalonia.Gif/GifImage.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,28 @@ public class GifImage : Control
1818
string
1919
>("SourceUriRaw");
2020

21-
public static readonly StyledProperty<Uri> SourceUriProperty = AvaloniaProperty.Register<GifImage, Uri>(
22-
"SourceUri"
23-
);
21+
public static readonly StyledProperty<Uri> SourceUriProperty = AvaloniaProperty.Register<
22+
GifImage,
23+
Uri
24+
>("SourceUri");
2425

2526
public static readonly StyledProperty<Stream> SourceStreamProperty = AvaloniaProperty.Register<
2627
GifImage,
2728
Stream
2829
>("SourceStream");
2930

30-
public static readonly StyledProperty<IterationCount> IterationCountProperty = AvaloniaProperty.Register<
31-
GifImage,
32-
IterationCount
33-
>("IterationCount", IterationCount.Infinite);
31+
public static readonly StyledProperty<IterationCount> IterationCountProperty =
32+
AvaloniaProperty.Register<GifImage, IterationCount>("IterationCount", IterationCount.Infinite);
3433

3534
private IGifInstance? _gifInstance;
3635

37-
public static readonly StyledProperty<StretchDirection> StretchDirectionProperty = AvaloniaProperty.Register<
38-
GifImage,
39-
StretchDirection
40-
>("StretchDirection");
36+
public static readonly StyledProperty<StretchDirection> StretchDirectionProperty =
37+
AvaloniaProperty.Register<GifImage, StretchDirection>("StretchDirection");
4138

42-
public static readonly StyledProperty<Stretch> StretchProperty = AvaloniaProperty.Register<GifImage, Stretch>(
43-
"Stretch"
44-
);
39+
public static readonly StyledProperty<Stretch> StretchProperty = AvaloniaProperty.Register<
40+
GifImage,
41+
Stretch
42+
>("Stretch");
4543

4644
private CompositionCustomVisual? _customVisual;
4745

@@ -288,10 +286,19 @@ e.NewValue is null
288286
private void UpdateGifInstance(object source)
289287
{
290288
_gifInstance?.Dispose();
291-
_gifInstance = new WebpInstance(source);
292-
// _gifInstance = new GifInstance(source);
293-
_gifInstance.IterationCount = IterationCount;
294-
_customVisual?.SendHandlerMessage(_gifInstance);
289+
290+
try
291+
{
292+
_gifInstance = new WebpInstance(source);
293+
// _gifInstance = new GifInstance(source);
294+
295+
_gifInstance.IterationCount = IterationCount;
296+
_customVisual?.SendHandlerMessage(_gifInstance);
297+
}
298+
catch (Exception e)
299+
{
300+
Logger.Sink?.Log(LogEventLevel.Warning, "GifImage Update Source ", this, e.ToString());
301+
}
295302
}
296303
}
297304
}

Avalonia.Gif/GifInstance.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Avalonia.Gif.Decoding;
99
using Avalonia.Media.Imaging;
1010
using Avalonia.Platform;
11+
using SkiaSharp;
1112

1213
namespace Avalonia.Gif
1314
{
@@ -60,12 +61,20 @@ public GifInstance(Stream currentStream)
6061
_gifDecoder.Header.Dimensions.Height
6162
);
6263

63-
_targetBitmap = new WriteableBitmap(
64-
pixSize,
65-
new Vector(96, 96),
66-
PixelFormat.Bgra8888,
67-
AlphaFormat.Opaque
68-
);
64+
// Different on os: https://github.com/mono/SkiaSharp/issues/1492#issuecomment-689015409
65+
// ReSharper disable once SwitchExpressionHandlesSomeKnownEnumValuesWithExceptionInDefault
66+
var format = SKImageInfo.PlatformColorType switch
67+
{
68+
SKColorType.Bgra8888 => PixelFormat.Bgra8888,
69+
SKColorType.Rgba8888 => PixelFormat.Rgba8888,
70+
_
71+
=> throw new NotSupportedException(
72+
$"Unsupported color type: {SKImageInfo.PlatformColorType}"
73+
)
74+
};
75+
76+
_targetBitmap = new WriteableBitmap(pixSize, new Vector(96, 96), format, AlphaFormat.Opaque);
77+
6978
GifPixelSize = pixSize;
7079

7180
_totalTime = TimeSpan.Zero;

Avalonia.Gif/WebpInstance.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,17 @@ public WebpInstance(Stream currentStream)
5454

5555
var pixSize = new PixelSize(_codec.Info.Width, _codec.Info.Height);
5656

57-
_targetBitmap = new WriteableBitmap(
58-
pixSize,
59-
new Vector(96, 96),
60-
PixelFormat.Bgra8888,
61-
AlphaFormat.Opaque
62-
);
57+
// Different on os: https://github.com/mono/SkiaSharp/issues/1492#issuecomment-689015409
58+
// ReSharper disable once SwitchExpressionHandlesSomeKnownEnumValuesWithExceptionInDefault
59+
var format = SKImageInfo.PlatformColorType switch
60+
{
61+
SKColorType.Bgra8888 => PixelFormat.Bgra8888,
62+
SKColorType.Rgba8888 => PixelFormat.Rgba8888,
63+
_ => throw new NotSupportedException($"Unsupported color type: {SKImageInfo.PlatformColorType}")
64+
};
65+
66+
_targetBitmap = new WriteableBitmap(pixSize, new Vector(96, 96), format, AlphaFormat.Opaque);
67+
6368
GifPixelSize = pixSize;
6469

6570
_totalTime = TimeSpan.Zero;
@@ -121,9 +126,18 @@ private static Stream GetStreamFromUri(Uri uri)
121126

122127
if (!uriString.StartsWith("resm") && !uriString.StartsWith("avares"))
123128
{
124-
return new FileStream(uriString, FileMode.Open, FileAccess.Read);
129+
// Local file
130+
using var fs = new FileStream(uriString, FileMode.Open, FileAccess.Read);
131+
132+
// Copy to memory stream then return
133+
var memoryStream = new MemoryStream();
134+
fs.CopyTo(memoryStream);
135+
memoryStream.Seek(0, SeekOrigin.Begin);
136+
137+
return memoryStream;
125138
}
126139

140+
// Internal Avalonia resources
127141
return AssetLoader.Open(uri);
128142
}
129143

0 commit comments

Comments
 (0)