Skip to content

Commit f8675ed

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into imageOptimize
2 parents 734a0cb + d8eaf88 commit f8675ed

File tree

94 files changed

+1719
-975
lines changed

Some content is hidden

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

94 files changed

+1719
-975
lines changed

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

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

5555
<ItemGroup>
56-
<PackageReference Include="Droplex" Version="1.2.0" />
56+
<PackageReference Include="Droplex" Version="1.3.1" />
5757
<PackageReference Include="FSharp.Core" Version="4.7.1" />
58+
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.1.3" />
5859
<PackageReference Include="squirrel.windows" Version="1.5.2" />
5960
</ItemGroup>
6061

61-
<ItemGroup>
62-
<Folder Include="Properties\" />
63-
</ItemGroup>
64-
6562
<ItemGroup>
6663
<ProjectReference Include="..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
6764
<ProjectReference Include="..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Flow Launcher and other plugins,
1+
/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Flow Launcher and other plugins,
32
* like python or other self-execute program. But, we added addtional infos (proxy and so on) into rpc request. Also, we didn't use the
43
* "id" and "jsonrpc" in the request, since it's not so useful in our request model.
54
*
@@ -13,10 +12,12 @@
1312
*
1413
*/
1514

15+
using Flow.Launcher.Core.Resource;
1616
using System.Collections.Generic;
1717
using System.Linq;
1818
using System.Text.Json.Serialization;
1919
using Flow.Launcher.Plugin;
20+
using System.Text.Json;
2021

2122
namespace Flow.Launcher.Core.Plugin
2223
{
@@ -29,12 +30,8 @@ public class JsonRPCErrorModel
2930
public string Data { get; set; }
3031
}
3132

32-
public class JsonRPCModelBase
33-
{
34-
public int Id { get; set; }
35-
}
3633

37-
public class JsonRPCResponseModel : JsonRPCModelBase
34+
public class JsonRPCResponseModel
3835
{
3936
public string Result { get; set; }
4037

@@ -48,45 +45,20 @@ public class JsonRPCQueryResponseModel : JsonRPCResponseModel
4845

4946
public string DebugMessage { get; set; }
5047
}
51-
52-
public class JsonRPCRequestModel : JsonRPCModelBase
48+
49+
public class JsonRPCRequestModel
5350
{
5451
public string Method { get; set; }
5552

5653
public object[] Parameters { get; set; }
5754

58-
public override string ToString()
59-
{
60-
string rpc = string.Empty;
61-
if (Parameters != null && Parameters.Length > 0)
62-
{
63-
string parameters = $"[{string.Join(',', Parameters.Select(GetParameterByType))}]";
64-
rpc = $@"{{\""method\"":\""{Method}\"",\""parameters\"":{parameters}";
65-
}
66-
else
67-
{
68-
rpc = $@"{{\""method\"":\""{Method}\"",\""parameters\"":[]";
69-
}
70-
71-
return rpc;
72-
73-
}
74-
75-
private string GetParameterByType(object parameter)
76-
=> parameter switch
55+
private static readonly JsonSerializerOptions options = new()
7756
{
78-
null => "null",
79-
string _ => $@"\""{ReplaceEscapes(parameter.ToString())}\""",
80-
bool _ => $@"{parameter.ToString().ToLower()}",
81-
_ => parameter.ToString()
57+
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
8258
};
83-
84-
85-
private string ReplaceEscapes(string str)
59+
public override string ToString()
8660
{
87-
return str.Replace(@"\", @"\\") //Escapes in ProcessStartInfo
88-
.Replace(@"\", @"\\") //Escapes itself when passed to client
89-
.Replace(@"""", @"\\""""");
61+
return JsonSerializer.Serialize(this, options);
9062
}
9163
}
9264

@@ -95,11 +67,7 @@ private string ReplaceEscapes(string str)
9567
/// </summary>
9668
public class JsonRPCServerRequestModel : JsonRPCRequestModel
9769
{
98-
public override string ToString()
99-
{
100-
string rpc = base.ToString();
101-
return rpc + "}";
102-
}
70+
10371
}
10472

10573
/// <summary>
@@ -108,12 +76,6 @@ public override string ToString()
10876
public class JsonRPCClientRequestModel : JsonRPCRequestModel
10977
{
11078
public bool DontHideAfterAction { get; set; }
111-
112-
public override string ToString()
113-
{
114-
string rpc = base.ToString();
115-
return rpc + "}";
116-
}
11779
}
11880

11981
/// <summary>
@@ -125,4 +87,4 @@ public class JsonRPCResult : Result
12587
{
12688
public JsonRPCClientRequestModel JsonRPCAction { get; set; }
12789
}
128-
}
90+
}

0 commit comments

Comments
 (0)