Skip to content

Commit 65fcbbc

Browse files
committed
Merge remote-tracking branch 'origin/dev' into PluginSearchTextBox
# Conflicts: # Flow.Launcher/Languages/en.xaml
2 parents d87ee11 + 472fff8 commit 65fcbbc

File tree

450 files changed

+34251
-5849
lines changed

Some content is hidden

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

450 files changed

+34251
-5849
lines changed

.github/workflows/stale.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# For more information, see:
2+
# https://github.com/actions/stale
3+
name: Mark stale issues and pull requests
4+
5+
on:
6+
schedule:
7+
- cron: '30 1 * * *'
8+
9+
jobs:
10+
stale:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
issues: write
14+
pull-requests: write
15+
steps:
16+
- uses: actions/stale@v4
17+
with:
18+
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
19+
days-before-stale: 30
20+
days-before-close: 5
21+
days-before-pr-close: -1
22+
exempt-all-milestones: true
23+
close-issue-message: 'This issue was closed because it has been stale for 5 days with no activity. If you feel this issue still needs attention please feel free to reopen.'

Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using Flow.Launcher.Infrastructure.Logger;
33
using System;
44
using System.Collections.Generic;
5+
using System.Net;
6+
using System.Net.Http;
57
using System.Text.Json;
68
using System.Threading;
79
using System.Threading.Tasks;
@@ -10,43 +12,43 @@ namespace Flow.Launcher.Core.ExternalPlugins
1012
{
1113
public static class PluginsManifest
1214
{
13-
static PluginsManifest()
14-
{
15-
UpdateTask = UpdateManifestAsync();
16-
}
17-
18-
public static List<UserPlugin> UserPlugins { get; private set; } = new List<UserPlugin>();
19-
20-
public static Task UpdateTask { get; private set; }
15+
private const string manifestFileUrl = "https://cdn.jsdelivr.net/gh/Flow-Launcher/Flow.Launcher.PluginsManifest@plugin_api_v2/plugins.json";
2116

2217
private static readonly SemaphoreSlim manifestUpdateLock = new(1);
2318

24-
public static Task UpdateManifestAsync()
25-
{
26-
if (manifestUpdateLock.CurrentCount == 0)
27-
{
28-
return UpdateTask;
29-
}
19+
private static string latestEtag = "";
3020

31-
return UpdateTask = DownloadManifestAsync();
32-
}
21+
public static List<UserPlugin> UserPlugins { get; private set; } = new List<UserPlugin>();
3322

34-
private async static Task DownloadManifestAsync()
23+
public static async Task UpdateManifestAsync(CancellationToken token = default)
3524
{
3625
try
3726
{
38-
await manifestUpdateLock.WaitAsync().ConfigureAwait(false);
27+
await manifestUpdateLock.WaitAsync(token).ConfigureAwait(false);
28+
29+
var request = new HttpRequestMessage(HttpMethod.Get, manifestFileUrl);
30+
request.Headers.Add("If-None-Match", latestEtag);
31+
32+
var response = await Http.SendAsync(request, token).ConfigureAwait(false);
3933

40-
await using var jsonStream = await Http.GetStreamAsync("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/plugin_api_v2/plugins.json")
41-
.ConfigureAwait(false);
34+
if (response.StatusCode == HttpStatusCode.OK)
35+
{
36+
Log.Info($"|PluginsManifest.{nameof(UpdateManifestAsync)}|Fetched plugins from manifest repo");
4237

43-
UserPlugins = await JsonSerializer.DeserializeAsync<List<UserPlugin>>(jsonStream).ConfigureAwait(false);
38+
var json = await response.Content.ReadAsStreamAsync(token).ConfigureAwait(false);
39+
40+
UserPlugins = await JsonSerializer.DeserializeAsync<List<UserPlugin>>(json, cancellationToken: token).ConfigureAwait(false);
41+
42+
latestEtag = response.Headers.ETag.Tag;
43+
}
44+
else if (response.StatusCode != HttpStatusCode.NotModified)
45+
{
46+
Log.Warn($"|PluginsManifest.{nameof(UpdateManifestAsync)}|Http response for manifest file was {response.StatusCode}");
47+
}
4448
}
4549
catch (Exception e)
4650
{
47-
Log.Exception("|PluginManagement.GetManifest|Encountered error trying to download plugins manifest", e);
48-
49-
UserPlugins = new List<UserPlugin>();
51+
Log.Exception($"|PluginsManifest.{nameof(UpdateManifestAsync)}|Http request failed", e);
5052
}
5153
finally
5254
{

Flow.Launcher.Core/Flow.Launcher.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0-windows</TargetFramework>
4+
<TargetFramework>net6.0-windows</TargetFramework>
55
<UseWpf>true</UseWpf>
66
<UseWindowsForms>true</UseWindowsForms>
77
<OutputType>Library</OutputType>
@@ -53,7 +53,7 @@
5353
</ItemGroup>
5454

5555
<ItemGroup>
56-
<PackageReference Include="Droplex" Version="1.4.0" />
56+
<PackageReference Include="Droplex" Version="1.4.1" />
5757
<PackageReference Include="FSharp.Core" Version="5.0.2" />
5858
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.1.3" />
5959
<PackageReference Include="squirrel.windows" Version="1.5.2" />

Flow.Launcher.Core/Plugin/ExecutablePlugin.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Diagnostics;
1+
using System.Diagnostics;
32
using System.IO;
43
using System.Threading;
54
using System.Threading.Tasks;
@@ -22,18 +21,23 @@ public ExecutablePlugin(string filename)
2221
RedirectStandardOutput = true,
2322
RedirectStandardError = true
2423
};
24+
25+
// required initialisation for below request calls
26+
_startInfo.ArgumentList.Add(string.Empty);
2527
}
2628

2729
protected override Task<Stream> RequestAsync(JsonRPCRequestModel request, CancellationToken token = default)
2830
{
29-
_startInfo.Arguments = $"\"{request}\"";
31+
// since this is not static, request strings will build up in ArgumentList if index is not specified
32+
_startInfo.ArgumentList[0] = request.ToString();
3033
return ExecuteAsync(_startInfo, token);
3134
}
3235

3336
protected override string Request(JsonRPCRequestModel rpcRequest, CancellationToken token = default)
3437
{
35-
_startInfo.Arguments = $"\"{rpcRequest}\"";
38+
// since this is not static, request strings will build up in ArgumentList if index is not specified
39+
_startInfo.ArgumentList[0] = rpcRequest.ToString();
3640
return Execute(_startInfo);
3741
}
3842
}
39-
}
43+
}

Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ public virtual async Task InitAsync(PluginInitContext context)
354354
this.context = context;
355355
await InitSettingAsync();
356356
}
357-
private static readonly Thickness settingControlMargin = new(10);
357+
private static readonly Thickness settingControlMargin = new(10, 4, 10, 4);
358+
private static readonly Thickness settingPanelMargin = new(15, 20, 15, 20);
359+
private static readonly Thickness settingTextBlockMargin = new(10, 4, 10, 4);
358360
private JsonRpcConfigurationModel _settingsTemplate;
359361
public Control CreateSettingPanel()
360362
{
@@ -363,7 +365,7 @@ public Control CreateSettingPanel()
363365
var settingWindow = new UserControl();
364366
var mainPanel = new StackPanel
365367
{
366-
Margin = settingControlMargin,
368+
Margin = settingPanelMargin,
367369
Orientation = Orientation.Vertical
368370
};
369371
settingWindow.Content = mainPanel;
@@ -375,10 +377,13 @@ public Control CreateSettingPanel()
375377
Orientation = Orientation.Horizontal,
376378
Margin = settingControlMargin
377379
};
378-
var name = new Label()
380+
var name = new TextBlock()
379381
{
380-
Content = attribute.Label,
381-
Margin = settingControlMargin
382+
Text = attribute.Label,
383+
Width = 120,
384+
VerticalAlignment = VerticalAlignment.Center,
385+
Margin = settingControlMargin,
386+
TextWrapping = TextWrapping.WrapWithOverflow
382387
};
383388

384389
FrameworkElement contentControl;
@@ -390,8 +395,8 @@ public Control CreateSettingPanel()
390395
contentControl = new TextBlock
391396
{
392397
Text = attribute.Description.Replace("\\r\\n", "\r\n"),
393-
Margin = settingControlMargin,
394-
MaxWidth = 400,
398+
Margin = settingTextBlockMargin,
399+
MaxWidth = 500,
395400
TextWrapping = TextWrapping.WrapWithOverflow
396401
};
397402
break;

Flow.Launcher.Core/Plugin/PluginAssemblyLoader.cs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@ internal class PluginAssemblyLoader : AssemblyLoadContext
1515

1616
private readonly AssemblyName assemblyName;
1717

18-
private static readonly ConcurrentDictionary<string, byte> loadedAssembly;
19-
20-
static PluginAssemblyLoader()
21-
{
22-
var currentAssemblies = AppDomain.CurrentDomain.GetAssemblies();
23-
loadedAssembly = new ConcurrentDictionary<string, byte>(
24-
currentAssemblies.Select(x => new KeyValuePair<string, byte>(x.FullName, default)));
25-
26-
AppDomain.CurrentDomain.AssemblyLoad += (sender, args) =>
27-
{
28-
loadedAssembly[args.LoadedAssembly.FullName] = default;
29-
};
30-
}
31-
3218
internal PluginAssemblyLoader(string assemblyFilePath)
3319
{
3420
dependencyResolver = new AssemblyDependencyResolver(assemblyFilePath);
@@ -47,21 +33,15 @@ protected override Assembly Load(AssemblyName assemblyName)
4733
// When resolving dependencies, ignore assembly depenedencies that already exits with Flow.Launcher
4834
// Otherwise duplicate assembly will be loaded and some weird behavior will occur, such as WinRT.Runtime.dll
4935
// will fail due to loading multiple versions in process, each with their own static instance of registration state
50-
if (assemblyPath == null || ExistsInReferencedPackage(assemblyName))
51-
return null;
36+
var existAssembly = Default.Assemblies.FirstOrDefault(x => x.FullName == assemblyName.FullName);
5237

53-
return LoadFromAssemblyPath(assemblyPath);
38+
return existAssembly ?? (assemblyPath == null ? null : LoadFromAssemblyPath(assemblyPath));
5439
}
5540

5641
internal Type FromAssemblyGetTypeOfInterface(Assembly assembly, Type type)
5742
{
5843
var allTypes = assembly.ExportedTypes;
5944
return allTypes.First(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Any(t => t == type));
6045
}
61-
62-
internal bool ExistsInReferencedPackage(AssemblyName assemblyName)
63-
{
64-
return loadedAssembly.ContainsKey(assemblyName.FullName);
65-
}
6646
}
6747
}

Flow.Launcher.Core/Resource/AvailableLanguages.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ internal static class AvailableLanguages
1919
public static Language Serbian = new Language("sr", "Srpski");
2020
public static Language Portuguese_Portugal = new Language("pt-pt", "Português");
2121
public static Language Portuguese_Brazil = new Language("pt-br", "Português (Brasil)");
22+
public static Language Spanish = new Language("es", "Spanish");
23+
public static Language Spanish_LatinAmerica = new Language("es-419", "Spanish (Latin America)");
2224
public static Language Italian = new Language("it", "Italiano");
2325
public static Language Norwegian_Bokmal = new Language("nb-NO", "Norsk Bokmål");
2426
public static Language Slovak = new Language("sk", "Slovenský");
@@ -43,6 +45,8 @@ public static List<Language> GetAvailableLanguages()
4345
Serbian,
4446
Portuguese_Portugal,
4547
Portuguese_Brazil,
48+
Spanish,
49+
Spanish_LatinAmerica,
4650
Italian,
4751
Norwegian_Bokmal,
4852
Slovak,

Flow.Launcher.Core/Updater.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
9191
catch (Exception e) when (e is HttpRequestException or WebException or SocketException || e.InnerException is TimeoutException)
9292
{
9393
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
94-
api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),
95-
api.GetTranslation("update_flowlauncher_check_connection"));
94+
if (!silentUpdate)
95+
api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),
96+
api.GetTranslation("update_flowlauncher_check_connection"));
9697
}
9798
finally
9899
{
@@ -124,7 +125,7 @@ private async Task<UpdateManager> GitHubUpdateManager(string repository)
124125
var releases = await System.Text.Json.JsonSerializer.DeserializeAsync<List<GithubRelease>>(jsonStream).ConfigureAwait(false);
125126
var latest = releases.Where(r => !r.Prerelease).OrderByDescending(r => r.PublishedAt).First();
126127
var latestUrl = latest.HtmlUrl.Replace("/tag/", "/download/");
127-
128+
128129
var client = new WebClient
129130
{
130131
Proxy = Http.WebProxy

Flow.Launcher.Infrastructure/Constant.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static class Constant
2121
public static readonly string PreinstalledDirectory = Path.Combine(ProgramDirectory, Plugins);
2222
public const string Issue = "https://github.com/Flow-Launcher/Flow.Launcher/issues/new";
2323
public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location.NonNull()).ProductVersion;
24-
public const string Documentation = "https://flow-launcher.github.io/docs/#/usage-tips";
24+
public const string Documentation = "https://flowlauncher.com/docs/#/usage-tips";
2525

2626
public static readonly int ThumbnailSize = 64;
2727
private static readonly string ImagesDirectory = Path.Combine(ProgramDirectory, "Images");
@@ -43,8 +43,8 @@ public static class Constant
4343
public const string Settings = "Settings";
4444
public const string Logs = "Logs";
4545

46-
public const string Website = "https://flow-launcher.github.io";
46+
public const string Website = "https://flowlauncher.com";
4747
public const string GitHub = "https://github.com/Flow-Launcher/Flow.Launcher";
48-
public const string Docs = "https://flow-launcher.github.io/docs";
48+
public const string Docs = "https://flowlauncher.com/docs";
4949
}
5050
}

Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0-windows</TargetFramework>
4+
<TargetFramework>net6.0-windows</TargetFramework>
55
<ProjectGuid>{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}</ProjectGuid>
66
<OutputType>Library</OutputType>
77
<UseWpf>true</UseWpf>

0 commit comments

Comments
 (0)