Skip to content

Commit 865c478

Browse files
authored
Merge branch 'dev' into sys_cmd
2 parents 570b202 + 2c965b1 commit 865c478

File tree

27 files changed

+990
-946
lines changed

27 files changed

+990
-946
lines changed

.github/actions/spelling/expect.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
crowdin
22
DWM
33
workflows
4-
Wpf
54
wpf
65
actionkeyword
76
stackoverflow
@@ -20,9 +19,7 @@ Prioritise
2019
Segoe
2120
Google
2221
Customise
23-
UWP
2422
uwp
25-
Uwp
2623
Bokmal
2724
Bokm
2825
uninstallation
@@ -61,7 +58,6 @@ popup
6158
ptr
6259
pluginindicator
6360
TobiasSekan
64-
Img
6561
img
6662
resx
6763
bak
@@ -78,7 +74,6 @@ WCA_ACCENT_POLICY
7874
HGlobal
7975
dopusrt
8076
firefox
81-
Firefox
8277
msedge
8378
svgc
8479
ime
@@ -87,7 +82,6 @@ txb
8782
btn
8883
otf
8984
searchplugin
90-
Noresult
9185
wpftk
9286
mkv
9387
flac
@@ -108,4 +102,7 @@ Preinstalled
108102
errormetadatafile
109103
noresult
110104
pluginsmanager
111-
alreadyexists
105+
alreadyexists
106+
JsonRPC
107+
JsonRPCV2
108+
Softpedia

.github/actions/spelling/patterns.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,6 @@
118118

119119
# UWP
120120
[Uu][Ww][Pp]
121+
122+
# version suffix <word>v#
123+
(?:(?<=[A-Z]{2})V|(?<=[a-z]{2}|[A-Z]{2})v)\d+(?:\b|(?=[a-zA-Z_]))

.github/workflows/default_plugins.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515
- name: Setup .NET
16-
uses: actions/setup-dotnet@v3
16+
uses: actions/setup-dotnet@v4
1717
with:
1818
dotnet-version: 7.0.x
1919

.github/workflows/spelling.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
steps:
7474
- name: check-spelling
7575
id: spelling
76-
uses: check-spelling/check-spelling@v0.0.22
76+
uses: check-spelling/check-spelling@prerelease
7777
with:
7878
suppress_push_for_open_pull_request: 1
7979
checkout: true
@@ -91,10 +91,9 @@ jobs:
9191
extra_dictionaries:
9292
cspell:software-terms/dict/softwareTerms.txt
9393
cspell:win32/src/win32.txt
94-
cspell:php/src/php.txt
9594
cspell:filetypes/filetypes.txt
9695
cspell:csharp/csharp.txt
97-
cspell:dotnet/src/dotnet.txt
96+
cspell:dotnet/dict/dotnet.txt
9897
cspell:python/src/common/extra.txt
9998
cspell:python/src/python/python-lib.txt
10099
cspell:aws/aws.txt
@@ -130,7 +129,7 @@ jobs:
130129
if: (success() || failure()) && needs.spelling.outputs.followup && contains(github.event_name, 'pull_request')
131130
steps:
132131
- name: comment
133-
uses: check-spelling/check-spelling@v0.0.22
132+
uses: check-spelling/check-spelling@prerelease
134133
with:
135134
checkout: true
136135
spell_check_this: check-spelling/spell-check-this@main

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
issues: write
1414
pull-requests: write
1515
steps:
16-
- uses: actions/stale@v8
16+
- uses: actions/stale@v9
1717
with:
1818
stale-issue-message: 'This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
1919
days-before-stale: 45

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<PackageReference Include="FSharp.Core" Version="7.0.401" />
5858
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
5959
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
60-
<PackageReference Include="StreamJsonRpc" Version="2.16.36" />
60+
<PackageReference Include="StreamJsonRpc" Version="2.17.8" />
6161
</ItemGroup>
6262

6363
<ItemGroup>

Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,15 @@ protected void ExecuteFlowLauncherAPI(string method, object[] parameters)
126126

127127
private async Task InitSettingAsync()
128128
{
129-
if (!File.Exists(SettingConfigurationPath))
130-
return;
129+
JsonRpcConfigurationModel configuration = null;
130+
if (File.Exists(SettingConfigurationPath))
131+
{
132+
var deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build();
133+
configuration =
134+
deserializer.Deserialize<JsonRpcConfigurationModel>(
135+
await File.ReadAllTextAsync(SettingConfigurationPath));
136+
}
131137

132-
var deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance)
133-
.Build();
134-
var configuration =
135-
deserializer.Deserialize<JsonRpcConfigurationModel>(
136-
await File.ReadAllTextAsync(SettingConfigurationPath));
137138

138139
Settings ??= new JsonRPCPluginSettings
139140
{

Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ namespace Flow.Launcher.Core.Plugin
1111
{
1212
public class JsonRPCPluginSettings
1313
{
14-
public required JsonRpcConfigurationModel Configuration { get; init; }
14+
public required JsonRpcConfigurationModel? Configuration { get; init; }
1515

1616
public required string SettingPath { get; init; }
1717
public Dictionary<string, FrameworkElement> SettingControls { get; } = new();
18-
18+
1919
public IReadOnlyDictionary<string, object> Inner => Settings;
2020
protected ConcurrentDictionary<string, object> Settings { get; set; }
2121
public required IPublicAPI API { get; init; }
22-
22+
2323
private JsonStorage<ConcurrentDictionary<string, object>> _storage;
2424

2525
// maybe move to resource?
@@ -37,32 +37,34 @@ public async Task InitializeAsync()
3737
_storage = new JsonStorage<ConcurrentDictionary<string, object>>(SettingPath);
3838
Settings = await _storage.LoadAsync();
3939

40-
foreach (var (type, attributes) in Configuration.Body)
40+
if (Settings != null || Configuration == null)
41+
{
42+
return;
43+
}
44+
45+
foreach (var (type, attributes) in Configuration.Body)
4146
{
4247
if (attributes.Name == null)
4348
{
4449
continue;
4550
}
46-
51+
4752
if (!Settings.ContainsKey(attributes.Name))
4853
{
4954
Settings[attributes.Name] = attributes.DefaultValue;
5055
}
5156
}
5257
}
5358

54-
59+
5560
public void UpdateSettings(IReadOnlyDictionary<string, object> settings)
5661
{
5762
if (settings == null || settings.Count == 0)
5863
return;
5964

6065
foreach (var (key, value) in settings)
6166
{
62-
if (Settings.ContainsKey(key))
63-
{
64-
Settings[key] = value;
65-
}
67+
Settings[key] = value;
6668

6769
if (SettingControls.TryGetValue(key, out var control))
6870
{
@@ -78,33 +80,35 @@ public void UpdateSettings(IReadOnlyDictionary<string, object> settings)
7880
comboBox.Dispatcher.Invoke(() => comboBox.SelectedItem = value);
7981
break;
8082
case CheckBox checkBox:
81-
checkBox.Dispatcher.Invoke(() => checkBox.IsChecked = value is bool isChecked ? isChecked : bool.Parse(value as string ?? string.Empty));
83+
checkBox.Dispatcher.Invoke(() =>
84+
checkBox.IsChecked = value is bool isChecked
85+
? isChecked
86+
: bool.Parse(value as string ?? string.Empty));
8287
break;
8388
}
8489
}
8590
}
91+
92+
Save();
8693
}
87-
94+
8895
public async Task SaveAsync()
8996
{
9097
await _storage.SaveAsync();
9198
}
92-
99+
93100
public void Save()
94101
{
95102
_storage.Save();
96103
}
97-
104+
98105
public Control CreateSettingPanel()
99106
{
100-
if (Settings == null)
107+
if (Settings == null || Settings.Count == 0)
101108
return new();
102109

103110
var settingWindow = new UserControl();
104-
var mainPanel = new Grid
105-
{
106-
Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center
107-
};
111+
var mainPanel = new Grid { Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center };
108112

109113
ColumnDefinition gridCol1 = new ColumnDefinition();
110114
ColumnDefinition gridCol2 = new ColumnDefinition();
@@ -239,10 +243,7 @@ public Control CreateSettingPanel()
239243
Margin = new Thickness(10, 0, 0, 0), Content = "Browse"
240244
};
241245

242-
var dockPanel = new DockPanel()
243-
{
244-
Margin = settingControlMargin
245-
};
246+
var dockPanel = new DockPanel() { Margin = settingControlMargin };
246247

247248
DockPanel.SetDock(Btn, Dock.Right);
248249
dockPanel.Children.Add(Btn);
@@ -349,7 +350,10 @@ public Control CreateSettingPanel()
349350
case "checkbox":
350351
var checkBox = new CheckBox
351352
{
352-
IsChecked = Settings[attribute.Name] is bool isChecked ? isChecked : bool.Parse(attribute.DefaultValue),
353+
IsChecked =
354+
Settings[attribute.Name] is bool isChecked
355+
? isChecked
356+
: bool.Parse(attribute.DefaultValue),
353357
Margin = settingCheckboxMargin,
354358
HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
355359
ToolTip = attribute.Description
@@ -372,14 +376,12 @@ public Control CreateSettingPanel()
372376

373377
break;
374378
case "hyperlink":
375-
var hyperlink = new Hyperlink
376-
{
377-
ToolTip = attribute.Description, NavigateUri = attribute.url
378-
};
379+
var hyperlink = new Hyperlink { ToolTip = attribute.Description, NavigateUri = attribute.url };
379380

380381
var linkbtn = new System.Windows.Controls.Button
381382
{
382-
HorizontalAlignment = System.Windows.HorizontalAlignment.Right, Margin = settingControlMargin
383+
HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
384+
Margin = settingControlMargin
383385
};
384386

385387
linkbtn.Content = attribute.urlLabel;
@@ -405,12 +407,9 @@ public Control CreateSettingPanel()
405407
mainPanel.Children.Add(panel);
406408
mainPanel.Children.Add(contentControl);
407409
rowCount++;
408-
409410
}
410411

411412
return settingWindow;
412413
}
413-
414-
415414
}
416415
}

Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async Task ReadErrorAsync()
9191

9292
private void SetupJsonRPC()
9393
{
94-
var formatter = new JsonMessageFormatter();
94+
var formatter = new SystemTextJsonFormatter { JsonSerializerOptions = RequestSerializeOption };
9595
var handler = new NewLineDelimitedMessageHandler(ClientPipe,
9696
formatter);
9797

@@ -100,10 +100,8 @@ private void SetupJsonRPC()
100100
RPC.AddLocalRpcMethod("UpdateResults", new Action<string, JsonRPCQueryResponseModel>((rawQuery, response) =>
101101
{
102102
var results = ParseResults(response);
103-
ResultsUpdated?.Invoke(this, new ResultUpdatedEventArgs { Query = new Query()
104-
{
105-
RawQuery = rawQuery
106-
}, Results = results });
103+
ResultsUpdated?.Invoke(this,
104+
new ResultUpdatedEventArgs { Query = new Query() { RawQuery = rawQuery }, Results = results });
107105
}));
108106
RPC.SynchronizationContext = null;
109107
RPC.StartListening();

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,19 @@ public static async Task<List<Result>> QueryForPluginAsync(PluginPair pair, Quer
212212
}
213213
catch (Exception e)
214214
{
215-
throw new FlowPluginException(metadata, e);
215+
Result r = new()
216+
{
217+
Title = $"{metadata.Name}: Failed to respond!",
218+
SubTitle = "Select this result for more info",
219+
IcoPath = Flow.Launcher.Infrastructure.Constant.ErrorIcon,
220+
PluginDirectory = metadata.PluginDirectory,
221+
ActionKeywordAssigned = query.ActionKeyword,
222+
PluginID = metadata.ID,
223+
OriginQuery = query,
224+
Action = _ => { throw new FlowPluginException(metadata, e);},
225+
Score = -100
226+
};
227+
results.Add(r);
216228
}
217229
return results;
218230
}

0 commit comments

Comments
 (0)