Skip to content

Commit 54e6907

Browse files
authored
Merge pull request #697 from Flow-Launcher/dev
Release 1.9.0 | Plugin 2.1.0
2 parents 15db87c + fa206e9 commit 54e6907

File tree

286 files changed

+63387
-4052
lines changed

Some content is hidden

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

286 files changed

+63387
-4052
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using Flow.Launcher.Infrastructure.Http;
2+
using Flow.Launcher.Infrastructure.Logger;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text.Json;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
9+
namespace Flow.Launcher.Core.ExternalPlugins
10+
{
11+
public static class PluginsManifest
12+
{
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; }
21+
22+
private static readonly SemaphoreSlim manifestUpdateLock = new(1);
23+
24+
public static Task UpdateManifestAsync()
25+
{
26+
if (manifestUpdateLock.CurrentCount == 0)
27+
{
28+
return UpdateTask;
29+
}
30+
31+
return UpdateTask = DownloadManifestAsync();
32+
}
33+
34+
private async static Task DownloadManifestAsync()
35+
{
36+
try
37+
{
38+
await manifestUpdateLock.WaitAsync().ConfigureAwait(false);
39+
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);
42+
43+
UserPlugins = await JsonSerializer.DeserializeAsync<List<UserPlugin>>(jsonStream).ConfigureAwait(false);
44+
}
45+
catch (Exception e)
46+
{
47+
Log.Exception("|PluginManagement.GetManifest|Encountered error trying to download plugins manifest", e);
48+
49+
UserPlugins = new List<UserPlugin>();
50+
}
51+
finally
52+
{
53+
manifestUpdateLock.Release();
54+
}
55+
}
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-

2-
namespace Flow.Launcher.Plugin.PluginsManager.Models
1+
namespace Flow.Launcher.Core.ExternalPlugins
32
{
4-
public class UserPlugin
3+
public record UserPlugin
54
{
65
public string ID { get; set; }
76
public string Name { get; set; }
@@ -12,5 +11,6 @@ public class UserPlugin
1211
public string Website { get; set; }
1312
public string UrlDownload { get; set; }
1413
public string UrlSourceCode { get; set; }
14+
public string IcoPath { get; set; }
1515
}
1616
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
</ItemGroup>
5454

5555
<ItemGroup>
56-
<PackageReference Include="Droplex" Version="1.3.1" />
57-
<PackageReference Include="FSharp.Core" Version="4.7.1" />
56+
<PackageReference Include="Droplex" Version="1.4.0" />
57+
<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" />
6060
</ItemGroup>

Flow.Launcher.Core/Plugin/ExecutablePlugin.cs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,16 @@ public ExecutablePlugin(string filename)
2424
};
2525
}
2626

27-
protected override Task<Stream> ExecuteQueryAsync(Query query, CancellationToken token)
27+
protected override Task<Stream> RequestAsync(JsonRPCRequestModel request, CancellationToken token = default)
2828
{
29-
JsonRPCServerRequestModel request = new JsonRPCServerRequestModel
30-
{
31-
Method = "query",
32-
Parameters = new object[] {query.Search},
33-
};
34-
3529
_startInfo.Arguments = $"\"{request}\"";
36-
3730
return ExecuteAsync(_startInfo, token);
3831
}
3932

40-
protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest)
33+
protected override string Request(JsonRPCRequestModel rpcRequest, CancellationToken token = default)
4134
{
4235
_startInfo.Arguments = $"\"{rpcRequest}\"";
4336
return Execute(_startInfo);
4437
}
45-
46-
protected override string ExecuteContextMenu(Result selectedResult)
47-
{
48-
JsonRPCServerRequestModel request = new JsonRPCServerRequestModel
49-
{
50-
Method = "contextmenu",
51-
Parameters = new object[] {selectedResult.ContextData},
52-
};
53-
54-
_startInfo.Arguments = $"\"{request}\"";
55-
56-
return Execute(_startInfo);
57-
}
5838
}
5939
}

Flow.Launcher.Core/Plugin/JsonPRCModel.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ public class JsonRPCQueryResponseModel : JsonRPCResponseModel
4343
[JsonPropertyName("result")]
4444
public new List<JsonRPCResult> Result { get; set; }
4545

46+
public Dictionary<string, object> SettingsChange { get; set; }
47+
4648
public string DebugMessage { get; set; }
4749
}
48-
50+
4951
public class JsonRPCRequestModel
5052
{
5153
public string Method { get; set; }
5254

5355
public object[] Parameters { get; set; }
5456

57+
public Dictionary<string, object> Settings { get; set; }
58+
5559
private static readonly JsonSerializerOptions options = new()
5660
{
5761
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
@@ -86,5 +90,7 @@ public class JsonRPCClientRequestModel : JsonRPCRequestModel
8690
public class JsonRPCResult : Result
8791
{
8892
public JsonRPCClientRequestModel JsonRPCAction { get; set; }
93+
94+
public Dictionary<string, object> SettingsChange { get; set; }
8995
}
9096
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System.Collections.Generic;
2+
3+
namespace Flow.Launcher.Core.Plugin
4+
{
5+
public class JsonRpcConfigurationModel
6+
{
7+
public List<SettingField> Body { get; set; }
8+
public void Deconstruct(out List<SettingField> Body)
9+
{
10+
Body = this.Body;
11+
}
12+
}
13+
14+
public class SettingField
15+
{
16+
public string Type { get; set; }
17+
public FieldAttributes Attributes { get; set; }
18+
public void Deconstruct(out string Type, out FieldAttributes attributes)
19+
{
20+
Type = this.Type;
21+
attributes = this.Attributes;
22+
}
23+
}
24+
public class FieldAttributes
25+
{
26+
public string Name { get; set; }
27+
public string Label { get; set; }
28+
public string Description { get; set; }
29+
public bool Validation { get; set; }
30+
public List<string> Options { get; set; }
31+
public string DefaultValue { get; set; }
32+
public char passwordChar { get; set; }
33+
public void Deconstruct(out string Name, out string Label, out string Description, out bool Validation, out List<string> Options, out string DefaultValue)
34+
{
35+
Name = this.Name;
36+
Label = this.Label;
37+
Description = this.Description;
38+
Validation = this.Validation;
39+
Options = this.Options;
40+
DefaultValue = this.DefaultValue;
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)