Skip to content

Commit

Permalink
Merge pull request #2617 from Flow-Launcher/dev
Browse files Browse the repository at this point in the history
Release 1.18.0 | Plugin 4.3.0
  • Loading branch information
jjw24 authored Apr 21, 2024
2 parents 2f679e9 + a9b4187 commit 7ea5c68
Show file tree
Hide file tree
Showing 133 changed files with 1,386 additions and 1,239 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ dotnet_style_prefer_conditional_expression_over_return = true:silent
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
Expand Down Expand Up @@ -134,7 +134,7 @@ csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
Expand Down
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,4 @@ alreadyexists
JsonRPC
JsonRPCV2
Softpedia
img
26 changes: 13 additions & 13 deletions .github/workflows/default_plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
dotnet-version: 7.0.x

- name: Determine New Plugin Updates
uses: dorny/paths-filter@v2
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Publish BrowserBookmark
if: steps.changes.outputs.browserbookmark == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.BrowserBookmark"
files: "Flow.Launcher.Plugin.BrowserBookmark.zip"
Expand All @@ -92,7 +92,7 @@ jobs:
- name: Publish Calculator
if: steps.changes.outputs.calculator == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.Calculator"
files: "Flow.Launcher.Plugin.Calculator.zip"
Expand All @@ -119,7 +119,7 @@ jobs:
- name: Publish Explorer
if: steps.changes.outputs.explorer == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.Explorer"
files: "Flow.Launcher.Plugin.Explorer.zip"
Expand All @@ -146,7 +146,7 @@ jobs:
- name: Publish PluginIndicator
if: steps.changes.outputs.pluginindicator == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.PluginIndicator"
files: "Flow.Launcher.Plugin.PluginIndicator.zip"
Expand All @@ -173,7 +173,7 @@ jobs:
- name: Publish PluginsManager
if: steps.changes.outputs.pluginsmanager == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.PluginsManager"
files: "Flow.Launcher.Plugin.PluginsManager.zip"
Expand All @@ -200,7 +200,7 @@ jobs:
- name: Publish ProcessKiller
if: steps.changes.outputs.processkiller == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.ProcessKiller"
files: "Flow.Launcher.Plugin.ProcessKiller.zip"
Expand All @@ -227,7 +227,7 @@ jobs:
- name: Publish Program
if: steps.changes.outputs.program == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.Program"
files: "Flow.Launcher.Plugin.Program.zip"
Expand All @@ -254,7 +254,7 @@ jobs:
- name: Publish Shell
if: steps.changes.outputs.shell == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.Shell"
files: "Flow.Launcher.Plugin.Shell.zip"
Expand All @@ -281,7 +281,7 @@ jobs:
- name: Publish Sys
if: steps.changes.outputs.sys == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.Sys"
files: "Flow.Launcher.Plugin.Sys.zip"
Expand All @@ -308,7 +308,7 @@ jobs:
- name: Publish Url
if: steps.changes.outputs.url == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.Url"
files: "Flow.Launcher.Plugin.Url.zip"
Expand All @@ -335,7 +335,7 @@ jobs:
- name: Publish WebSearch
if: steps.changes.outputs.websearch == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.WebSearch"
files: "Flow.Launcher.Plugin.WebSearch.zip"
Expand All @@ -362,7 +362,7 @@ jobs:
- name: Publish WindowsSettings
if: steps.changes.outputs.windowssettings == 'true'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
repository: "Flow-Launcher/Flow.Launcher.Plugin.WindowsSettings"
files: "Flow.Launcher.Plugin.WindowsSettings.zip"
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher.Core/Flow.Launcher.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
<PackageReference Include="Droplex" Version="1.7.0" />
<PackageReference Include="FSharp.Core" Version="7.0.401" />
<PackageReference Include="Meziantou.Framework.Win32.Jobs" Version="3.2.1" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
<PackageReference Include="StreamJsonRpc" Version="2.17.8" />
<PackageReference Include="StreamJsonRpc" Version="2.17.11" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 2 additions & 8 deletions Flow.Launcher.Core/Plugin/ExecutablePluginV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@ internal sealed class ExecutablePluginV2 : ProcessStreamPluginV2

public ExecutablePluginV2(string filename)
{
StartInfo = new ProcessStartInfo
{
FileName = filename,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true
};
StartInfo = new ProcessStartInfo { FileName = filename };
}

protected override MessageHandlerType MessageHandler { get; } = MessageHandlerType.NewLineDelimited;
}
}
38 changes: 32 additions & 6 deletions Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ namespace Flow.Launcher.Core.Plugin
{
internal abstract class JsonRPCPluginV2 : JsonRPCPluginBase, IAsyncDisposable, IAsyncReloadable, IResultUpdated
{
public abstract string SupportedLanguage { get; set; }

public const string JsonRpc = "JsonRPC";

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

private JoinableTaskFactory JTF { get; } = new JoinableTaskFactory(new JoinableTaskContext());

public override List<Result> LoadContextMenus(Result selectedResult)
{
throw new NotImplementedException();
try
{
var res = JTF.Run(() => RPC.InvokeWithCancellationAsync<JsonRPCQueryResponseModel>("context_menu",
new object[] { selectedResult.ContextData }));

var results = ParseResults(res);

return results;
}
catch
{
return new List<Result>();
}
}

public override async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
{
try
{
var res = await RPC.InvokeWithCancellationAsync<JsonRPCQueryResponseModel>("query",
new[] { query },
new object[] { query, Settings.Inner },
token);

var results = ParseResults(res);
Expand Down Expand Up @@ -88,12 +100,26 @@ async Task ReadErrorAsync()

public event ResultUpdatedEventHandler ResultsUpdated;

protected enum MessageHandlerType
{
HeaderDelimited,
LengthHeaderDelimited,
NewLineDelimited
}

protected abstract MessageHandlerType MessageHandler { get; }


private void SetupJsonRPC()
{
var formatter = new SystemTextJsonFormatter { JsonSerializerOptions = RequestSerializeOption };
var handler = new NewLineDelimitedMessageHandler(ClientPipe,
formatter);
IJsonRpcMessageHandler handler = MessageHandler switch
{
MessageHandlerType.HeaderDelimited => new HeaderDelimitedMessageHandler(ClientPipe, formatter),
MessageHandlerType.LengthHeaderDelimited => new LengthHeaderMessageHandler(ClientPipe, formatter),
MessageHandlerType.NewLineDelimited => new NewLineDelimitedMessageHandler(ClientPipe, formatter),
_ => throw new ArgumentOutOfRangeException()
};

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

Expand Down
16 changes: 4 additions & 12 deletions Flow.Launcher.Core/Plugin/NodePluginV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,21 @@ namespace Flow.Launcher.Core.Plugin
/// <summary>
/// Execution of JavaScript & TypeScript plugins
/// </summary>
internal class NodePluginV2 : ProcessStreamPluginV2
internal sealed class NodePluginV2 : ProcessStreamPluginV2
{
public NodePluginV2(string filename)
{
StartInfo = new ProcessStartInfo
{
FileName = filename,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true
};
StartInfo = new ProcessStartInfo { FileName = filename, };
}

public override string SupportedLanguage { get; set; }
protected override ProcessStartInfo StartInfo { get; set; }

public override async Task InitAsync(PluginInitContext context)
{
StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
StartInfo.ArgumentList.Add(string.Empty);
StartInfo.WorkingDirectory = context.CurrentPluginMetadata.PluginDirectory;
await base.InitAsync(context);
}

protected override MessageHandlerType MessageHandler { get; } = MessageHandlerType.HeaderDelimited;
}
}
29 changes: 19 additions & 10 deletions Flow.Launcher.Core/Plugin/ProcessStreamPluginV2.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using System;
#nullable enable

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipelines;
using System.Threading.Tasks;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Plugin;
using Meziantou.Framework.Win32;
using Microsoft.VisualBasic.ApplicationServices;
using Nerdbank.Streams;

namespace Flow.Launcher.Core.Plugin
Expand All @@ -18,31 +21,37 @@ static ProcessStreamPluginV2()
{
_jobObject.SetLimits(new JobObjectLimits()
{
Flags = JobObjectLimitFlags.KillOnJobClose | JobObjectLimitFlags.DieOnUnhandledException
Flags = JobObjectLimitFlags.KillOnJobClose | JobObjectLimitFlags.DieOnUnhandledException |
JobObjectLimitFlags.SilentBreakawayOk
});

_jobObject.AssignProcess(Process.GetCurrentProcess());
}

public override string SupportedLanguage { get; set; }
protected sealed override IDuplexPipe ClientPipe { get; set; }
protected sealed override IDuplexPipe ClientPipe { get; set; } = null!;

protected abstract ProcessStartInfo StartInfo { get; set; }

protected Process ClientProcess { get; set; }
protected Process ClientProcess { get; set; } = null!;

public override async Task InitAsync(PluginInitContext context)
{
StartInfo.EnvironmentVariables["FLOW_VERSION"] = Constant.Version;
StartInfo.EnvironmentVariables["FLOW_PROGRAM_DIRECTORY"] = Constant.ProgramDirectory;
StartInfo.EnvironmentVariables["FLOW_APPLICATION_DIRECTORY"] = Constant.ApplicationDirectory;

StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
StartInfo.RedirectStandardError = true;
StartInfo.RedirectStandardInput = true;
StartInfo.RedirectStandardOutput = true;
StartInfo.CreateNoWindow = true;
StartInfo.UseShellExecute = false;
StartInfo.WorkingDirectory = context.CurrentPluginMetadata.PluginDirectory;

ClientProcess = Process.Start(StartInfo);
ArgumentNullException.ThrowIfNull(ClientProcess);

var process = Process.Start(StartInfo);
ArgumentNullException.ThrowIfNull(process);
ClientProcess = process;
_jobObject.AssignProcess(ClientProcess);

SetupPipe(ClientProcess);

ErrorStream = ClientProcess.StandardError;
Expand Down
21 changes: 10 additions & 11 deletions Flow.Launcher.Core/Plugin/PythonPluginV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,25 @@ namespace Flow.Launcher.Core.Plugin
{
internal sealed class PythonPluginV2 : ProcessStreamPluginV2
{
public override string SupportedLanguage { get; set; } = AllowedLanguage.Python;
protected override ProcessStartInfo StartInfo { get; set; }

public PythonPluginV2(string filename)
{
StartInfo = new ProcessStartInfo
{
FileName = filename,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true
};
StartInfo = new ProcessStartInfo { FileName = filename, };

var path = Path.Combine(Constant.ProgramDirectory, JsonRpc);
StartInfo.EnvironmentVariables["PYTHONPATH"] = path;

//Add -B flag to tell python don't write .py[co] files. Because .pyc contains location infos which will prevent python portable
StartInfo.ArgumentList.Add("-B");
}

public override async Task InitAsync(PluginInitContext context)
{
StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
await base.InitAsync(context);
}

protected override MessageHandlerType MessageHandler { get; } = MessageHandlerType.NewLineDelimited;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@

<ItemGroup>
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
<PackageReference Include="FastCache.Cached" Version="1.8.2" />
<PackageReference Include="Fody" Version="6.5.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MemoryPack" Version="1.10.0" />
<PackageReference Include="MemoryPack" Version="1.21.1" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="17.7.30" />
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NLog.Schema" Version="4.7.10" />
Expand Down
Loading

0 comments on commit 7ea5c68

Please sign in to comment.