Skip to content

Commit b02c139

Browse files
committed
Merge branch 'refs/heads/dev' into new-image-cache
2 parents fd05912 + c4310f0 commit b02c139

File tree

390 files changed

+19818
-12442
lines changed

Some content is hidden

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

390 files changed

+19818
-12442
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ dotnet_style_prefer_conditional_expression_over_return = true:silent
5858
###############################
5959
# Style Definitions
6060
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
61-
# Use PascalCase for constant fields
61+
# Use PascalCase for constant fields
6262
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
6363
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
6464
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
@@ -134,7 +134,7 @@ csharp_preserve_single_line_statements = true
134134
csharp_preserve_single_line_blocks = true
135135
csharp_using_directive_placement = outside_namespace:silent
136136
csharp_prefer_simple_using_statement = true:suggestion
137-
csharp_style_namespace_declarations = block_scoped:silent
137+
csharp_style_namespace_declarations = file_scoped:silent
138138
csharp_style_prefer_method_group_conversion = true:silent
139139
csharp_style_expression_bodied_lambdas = true:silent
140140
csharp_style_expression_bodied_local_functions = false:silent

.github/actions/spelling/allow.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ https
33
ssh
44
ubuntu
55
runcount
6+
Firefox
7+
Português
8+
Português (Brasil)

.github/actions/spelling/expect.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ WCA_ACCENT_POLICY
7474
HGlobal
7575
dopusrt
7676
firefox
77+
Firefox
7778
msedge
7879
svgc
7980
ime
@@ -97,6 +98,7 @@ Português
9798
Português (Brasil)
9899
Italiano
99100
Slovenský
101+
Tiếng Việt
100102
Droplex
101103
Preinstalled
102104
errormetadatafile
@@ -106,3 +108,4 @@ alreadyexists
106108
JsonRPC
107109
JsonRPCV2
108110
Softpedia
111+
img

.github/workflows/default_plugins.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
dotnet-version: 7.0.x
1919

2020
- name: Determine New Plugin Updates
21-
uses: dorny/paths-filter@v2
21+
uses: dorny/paths-filter@v3
2222
id: changes
2323
with:
2424
filters: |
@@ -65,7 +65,7 @@ jobs:
6565
6666
- name: Publish BrowserBookmark
6767
if: steps.changes.outputs.browserbookmark == 'true'
68-
uses: softprops/action-gh-release@v1
68+
uses: softprops/action-gh-release@v2
6969
with:
7070
repository: "Flow-Launcher/Flow.Launcher.Plugin.BrowserBookmark"
7171
files: "Flow.Launcher.Plugin.BrowserBookmark.zip"
@@ -92,7 +92,7 @@ jobs:
9292
9393
- name: Publish Calculator
9494
if: steps.changes.outputs.calculator == 'true'
95-
uses: softprops/action-gh-release@v1
95+
uses: softprops/action-gh-release@v2
9696
with:
9797
repository: "Flow-Launcher/Flow.Launcher.Plugin.Calculator"
9898
files: "Flow.Launcher.Plugin.Calculator.zip"
@@ -119,7 +119,7 @@ jobs:
119119
120120
- name: Publish Explorer
121121
if: steps.changes.outputs.explorer == 'true'
122-
uses: softprops/action-gh-release@v1
122+
uses: softprops/action-gh-release@v2
123123
with:
124124
repository: "Flow-Launcher/Flow.Launcher.Plugin.Explorer"
125125
files: "Flow.Launcher.Plugin.Explorer.zip"
@@ -146,7 +146,7 @@ jobs:
146146
147147
- name: Publish PluginIndicator
148148
if: steps.changes.outputs.pluginindicator == 'true'
149-
uses: softprops/action-gh-release@v1
149+
uses: softprops/action-gh-release@v2
150150
with:
151151
repository: "Flow-Launcher/Flow.Launcher.Plugin.PluginIndicator"
152152
files: "Flow.Launcher.Plugin.PluginIndicator.zip"
@@ -173,7 +173,7 @@ jobs:
173173
174174
- name: Publish PluginsManager
175175
if: steps.changes.outputs.pluginsmanager == 'true'
176-
uses: softprops/action-gh-release@v1
176+
uses: softprops/action-gh-release@v2
177177
with:
178178
repository: "Flow-Launcher/Flow.Launcher.Plugin.PluginsManager"
179179
files: "Flow.Launcher.Plugin.PluginsManager.zip"
@@ -200,7 +200,7 @@ jobs:
200200
201201
- name: Publish ProcessKiller
202202
if: steps.changes.outputs.processkiller == 'true'
203-
uses: softprops/action-gh-release@v1
203+
uses: softprops/action-gh-release@v2
204204
with:
205205
repository: "Flow-Launcher/Flow.Launcher.Plugin.ProcessKiller"
206206
files: "Flow.Launcher.Plugin.ProcessKiller.zip"
@@ -227,7 +227,7 @@ jobs:
227227
228228
- name: Publish Program
229229
if: steps.changes.outputs.program == 'true'
230-
uses: softprops/action-gh-release@v1
230+
uses: softprops/action-gh-release@v2
231231
with:
232232
repository: "Flow-Launcher/Flow.Launcher.Plugin.Program"
233233
files: "Flow.Launcher.Plugin.Program.zip"
@@ -254,7 +254,7 @@ jobs:
254254
255255
- name: Publish Shell
256256
if: steps.changes.outputs.shell == 'true'
257-
uses: softprops/action-gh-release@v1
257+
uses: softprops/action-gh-release@v2
258258
with:
259259
repository: "Flow-Launcher/Flow.Launcher.Plugin.Shell"
260260
files: "Flow.Launcher.Plugin.Shell.zip"
@@ -281,7 +281,7 @@ jobs:
281281
282282
- name: Publish Sys
283283
if: steps.changes.outputs.sys == 'true'
284-
uses: softprops/action-gh-release@v1
284+
uses: softprops/action-gh-release@v2
285285
with:
286286
repository: "Flow-Launcher/Flow.Launcher.Plugin.Sys"
287287
files: "Flow.Launcher.Plugin.Sys.zip"
@@ -308,7 +308,7 @@ jobs:
308308
309309
- name: Publish Url
310310
if: steps.changes.outputs.url == 'true'
311-
uses: softprops/action-gh-release@v1
311+
uses: softprops/action-gh-release@v2
312312
with:
313313
repository: "Flow-Launcher/Flow.Launcher.Plugin.Url"
314314
files: "Flow.Launcher.Plugin.Url.zip"
@@ -335,7 +335,7 @@ jobs:
335335
336336
- name: Publish WebSearch
337337
if: steps.changes.outputs.websearch == 'true'
338-
uses: softprops/action-gh-release@v1
338+
uses: softprops/action-gh-release@v2
339339
with:
340340
repository: "Flow-Launcher/Flow.Launcher.Plugin.WebSearch"
341341
files: "Flow.Launcher.Plugin.WebSearch.zip"
@@ -362,7 +362,7 @@ jobs:
362362
363363
- name: Publish WindowsSettings
364364
if: steps.changes.outputs.windowssettings == 'true'
365-
uses: softprops/action-gh-release@v1
365+
uses: softprops/action-gh-release@v2
366366
with:
367367
repository: "Flow-Launcher/Flow.Launcher.Plugin.WindowsSettings"
368368
files: "Flow.Launcher.Plugin.WindowsSettings.zip"

Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using System.Net;
66
using System.Net.Http;
77
using System.Net.Http.Json;
8+
using System.Text.Json;
9+
using System.Text.Json.Serialization;
810
using System.Threading;
911
using System.Threading.Tasks;
1012

@@ -16,6 +18,11 @@ public record CommunityPluginSource(string ManifestFileUrl)
1618

1719
private List<UserPlugin> plugins = new();
1820

21+
private static JsonSerializerOptions PluginStoreItemSerializationOption = new JsonSerializerOptions()
22+
{
23+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
24+
};
25+
1926
/// <summary>
2027
/// Fetch and deserialize the contents of a plugins.json file found at <see cref="ManifestFileUrl"/>.
2128
/// We use conditional http requests to keep repeat requests fast.
@@ -32,12 +39,15 @@ public async Task<List<UserPlugin>> FetchAsync(CancellationToken token)
3239

3340
request.Headers.Add("If-None-Match", latestEtag);
3441

35-
using var response = await Http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false);
42+
using var response = await Http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token)
43+
.ConfigureAwait(false);
3644

3745
if (response.StatusCode == HttpStatusCode.OK)
3846
{
39-
this.plugins = await response.Content.ReadFromJsonAsync<List<UserPlugin>>(cancellationToken: token).ConfigureAwait(false);
40-
this.latestEtag = response.Headers.ETag.Tag;
47+
this.plugins = await response.Content
48+
.ReadFromJsonAsync<List<UserPlugin>>(PluginStoreItemSerializationOption, cancellationToken: token)
49+
.ConfigureAwait(false);
50+
this.latestEtag = response.Headers.ETag?.Tag;
4151

4252
Log.Info(nameof(CommunityPluginSource), $"Loaded {this.plugins.Count} plugins from {ManifestFileUrl}");
4353
return this.plugins;
@@ -49,7 +59,8 @@ public async Task<List<UserPlugin>> FetchAsync(CancellationToken token)
4959
}
5060
else
5161
{
52-
Log.Warn(nameof(CommunityPluginSource), $"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
62+
Log.Warn(nameof(CommunityPluginSource),
63+
$"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
5364
throw new Exception($"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
5465
}
5566
}

Flow.Launcher.Core/ExternalPlugins/UserPlugin.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22

33
namespace Flow.Launcher.Core.ExternalPlugins
44
{
@@ -13,9 +13,11 @@ public record UserPlugin
1313
public string Website { get; set; }
1414
public string UrlDownload { get; set; }
1515
public string UrlSourceCode { get; set; }
16+
public string LocalInstallPath { get; set; }
1617
public string IcoPath { get; set; }
17-
public DateTime LatestReleaseDate { get; set; }
18-
public DateTime DateAdded { get; set; }
18+
public DateTime? LatestReleaseDate { get; set; }
19+
public DateTime? DateAdded { get; set; }
1920

21+
public bool IsFromLocalInstallPath => !string.IsNullOrEmpty(LocalInstallPath);
2022
}
2123
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@
5555
<ItemGroup>
5656
<PackageReference Include="Droplex" Version="1.7.0" />
5757
<PackageReference Include="FSharp.Core" Version="7.0.401" />
58-
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
58+
<PackageReference Include="Meziantou.Framework.Win32.Jobs" Version="3.2.1" />
59+
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
5960
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
60-
<PackageReference Include="StreamJsonRpc" Version="2.17.8" />
61+
<PackageReference Include="StreamJsonRpc" Version="2.17.11" />
6162
</ItemGroup>
6263

6364
<ItemGroup>

Flow.Launcher.Core/Plugin/ExecutablePluginV2.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@ internal sealed class ExecutablePluginV2 : ProcessStreamPluginV2
1212

1313
public ExecutablePluginV2(string filename)
1414
{
15-
StartInfo = new ProcessStartInfo
16-
{
17-
FileName = filename,
18-
UseShellExecute = false,
19-
CreateNoWindow = true,
20-
RedirectStandardOutput = true,
21-
RedirectStandardError = true
22-
};
15+
StartInfo = new ProcessStartInfo { FileName = filename };
2316
}
2417

18+
protected override MessageHandlerType MessageHandler { get; } = MessageHandlerType.NewLineDelimited;
2519
}
2620
}

Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task InitializeAsync()
3737
_storage = new JsonStorage<ConcurrentDictionary<string, object>>(SettingPath);
3838
Settings = await _storage.LoadAsync();
3939

40-
if (Settings != null || Configuration == null)
40+
if (Configuration == null)
4141
{
4242
return;
4343
}

Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ namespace Flow.Launcher.Core.Plugin
1515
{
1616
internal abstract class JsonRPCPluginV2 : JsonRPCPluginBase, IAsyncDisposable, IAsyncReloadable, IResultUpdated
1717
{
18-
public abstract string SupportedLanguage { get; set; }
19-
2018
public const string JsonRpc = "JsonRPC";
2119

2220
protected abstract IDuplexPipe ClientPipe { get; set; }
@@ -41,17 +39,31 @@ protected override async Task<bool> ExecuteResultAsync(JsonRPCResult result)
4139
}
4240
}
4341

42+
private JoinableTaskFactory JTF { get; } = new JoinableTaskFactory(new JoinableTaskContext());
43+
4444
public override List<Result> LoadContextMenus(Result selectedResult)
4545
{
46-
throw new NotImplementedException();
46+
try
47+
{
48+
var res = JTF.Run(() => RPC.InvokeWithCancellationAsync<JsonRPCQueryResponseModel>("context_menu",
49+
new object[] { selectedResult.ContextData }));
50+
51+
var results = ParseResults(res);
52+
53+
return results;
54+
}
55+
catch
56+
{
57+
return new List<Result>();
58+
}
4759
}
4860

4961
public override async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
5062
{
5163
try
5264
{
5365
var res = await RPC.InvokeWithCancellationAsync<JsonRPCQueryResponseModel>("query",
54-
new[] { query },
66+
new object[] { query, Settings.Inner },
5567
token);
5668

5769
var results = ParseResults(res);
@@ -88,12 +100,26 @@ async Task ReadErrorAsync()
88100

89101
public event ResultUpdatedEventHandler ResultsUpdated;
90102

103+
protected enum MessageHandlerType
104+
{
105+
HeaderDelimited,
106+
LengthHeaderDelimited,
107+
NewLineDelimited
108+
}
109+
110+
protected abstract MessageHandlerType MessageHandler { get; }
111+
91112

92113
private void SetupJsonRPC()
93114
{
94115
var formatter = new SystemTextJsonFormatter { JsonSerializerOptions = RequestSerializeOption };
95-
var handler = new NewLineDelimitedMessageHandler(ClientPipe,
96-
formatter);
116+
IJsonRpcMessageHandler handler = MessageHandler switch
117+
{
118+
MessageHandlerType.HeaderDelimited => new HeaderDelimitedMessageHandler(ClientPipe, formatter),
119+
MessageHandlerType.LengthHeaderDelimited => new LengthHeaderMessageHandler(ClientPipe, formatter),
120+
MessageHandlerType.NewLineDelimited => new NewLineDelimitedMessageHandler(ClientPipe, formatter),
121+
_ => throw new ArgumentOutOfRangeException()
122+
};
97123

98124
RPC = new JsonRpc(handler, new JsonRPCPublicAPI(Context.API));
99125

@@ -113,11 +139,20 @@ public virtual Task ReloadDataAsync()
113139
return Task.CompletedTask;
114140
}
115141

116-
public virtual ValueTask DisposeAsync()
142+
public virtual async ValueTask DisposeAsync()
117143
{
118-
RPC?.Dispose();
119-
ErrorStream?.Dispose();
120-
return ValueTask.CompletedTask;
144+
try
145+
{
146+
await RPC.InvokeAsync("close");
147+
}
148+
catch (RemoteMethodNotFoundException e)
149+
{
150+
}
151+
finally
152+
{
153+
RPC?.Dispose();
154+
ErrorStream?.Dispose();
155+
}
121156
}
122157
}
123158
}

0 commit comments

Comments
 (0)