Skip to content

Commit c6fb6c8

Browse files
committed
Merge branch 'dev' of https://github.com/Flow-Launcher/Flow.Launcher into remove_sharpvectors
2 parents 0098c16 + ca5ce61 commit c6fb6c8

File tree

341 files changed

+17368
-10992
lines changed

Some content is hidden

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

341 files changed

+17368
-10992
lines changed

.cm/gitstream.cm

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# -*- mode: yaml -*-
2+
# This example configuration for provides basic automations to get started with gitStream.
3+
# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/
4+
manifest:
5+
version: 1.0
6+
7+
8+
automations:
9+
# Add a label that indicates how many minutes it will take to review the PR.
10+
estimated_time_to_review:
11+
if:
12+
- true
13+
run:
14+
- action: add-label@v1
15+
args:
16+
label: "{{ calc.etr }} min review"
17+
color: {{ colors.red if (calc.etr >= 20) else ( colors.yellow if (calc.etr >= 5) else colors.green ) }}
18+
# Post a comment that lists the best experts for the files that were modified.
19+
explain_code_experts:
20+
if:
21+
- true
22+
run:
23+
- action: explain-code-experts@v1
24+
args:
25+
gt: 10
26+
# Post a comment that indicates what percentage of the PR is new code.
27+
percent_new_code:
28+
if:
29+
- true
30+
run:
31+
- action: add-comment@v1
32+
args:
33+
comment: |
34+
This PR is {{ changes.ratio }}% new code.
35+
# Post a comment that request changes for a PR that contains a TODO statement.
36+
review_todo_comments:
37+
if:
38+
- {{ source.diff.files | matchDiffLines(regex=r/^[+].*(TODO)|(todo)/) | some }}
39+
run:
40+
- action: request-changes@v1
41+
args:
42+
comment: |
43+
This PR contains a TODO statement. Please check to see if they should be removed.
44+
# Post a comment that request a before and after screenshot
45+
request_screenshot:
46+
# Triggered for PRs that lack an image file or link to an image in the PR description
47+
if:
48+
- {{ not (has.screenshot_link or has.image_uploaded) }}
49+
run:
50+
- action: add-comment@v1
51+
args:
52+
comment: |
53+
Be a legend :trophy: by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.
54+
55+
56+
# +----------------------------------------------------------------------------+
57+
# | Custom Expressions |
58+
# | https://docs.gitstream.cm/how-it-works/#custom-expressions |
59+
# +----------------------------------------------------------------------------+
60+
61+
calc:
62+
etr: {{ branch | estimatedReviewTime }}
63+
64+
colors:
65+
red: 'b60205'
66+
yellow: 'fbca04'
67+
green: '0e8a16'
68+
69+
changes:
70+
# Sum all the lines added/edited in the PR
71+
additions: {{ branch.diff.files_metadata | map(attr='additions') | sum }}
72+
# Sum all the line removed in the PR
73+
deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}
74+
# Calculate the ratio of new code
75+
ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}
76+
77+
has:
78+
screenshot_link: {{ pr.description | includes(regex=r/!\[.*\]\(.*(jpg|svg|png|gif|psd).*\)/) }}
79+
image_uploaded: {{ pr.description | includes(regex=r/<img.*src.*(jpg|svg|png|gif|psd).*>/) }}

.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,8 @@ Português
9798
Português (Brasil)
9899
Italiano
99100
Slovenský
101+
quicklook
102+
Tiếng Việt
100103
Droplex
101104
Preinstalled
102105
errormetadatafile

.github/workflows/gitstream.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Code generated by gitStream GitHub app - DO NOT EDIT
2+
3+
name: gitStream workflow automation
4+
run-name: |
5+
/:\ gitStream: PR #${{ fromJSON(fromJSON(github.event.inputs.client_payload)).pullRequestNumber }} from ${{ github.event.inputs.full_repository }}
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
client_payload:
11+
description: The Client payload
12+
required: true
13+
full_repository:
14+
description: the repository name include the owner in `owner/repo_name` format
15+
required: true
16+
head_ref:
17+
description: the head sha
18+
required: true
19+
base_ref:
20+
description: the base ref
21+
required: true
22+
installation_id:
23+
description: the installation id
24+
required: false
25+
resolver_url:
26+
description: the resolver url to pass results to
27+
required: true
28+
resolver_token:
29+
description: Optional resolver token for resolver service
30+
required: false
31+
default: ''
32+
33+
jobs:
34+
gitStream:
35+
timeout-minutes: 5
36+
runs-on: ubuntu-latest
37+
name: gitStream workflow automation
38+
steps:
39+
- name: Evaluate Rules
40+
uses: linear-b/gitstream-github-action@v2
41+
id: rules-engine
42+
with:
43+
full_repository: ${{ github.event.inputs.full_repository }}
44+
head_ref: ${{ github.event.inputs.head_ref }}
45+
base_ref: ${{ github.event.inputs.base_ref }}
46+
client_payload: ${{ github.event.inputs.client_payload }}
47+
installation_id: ${{ github.event.inputs.installation_id }}
48+
resolver_url: ${{ github.event.inputs.resolver_url }}
49+
resolver_token: ${{ github.event.inputs.resolver_token }}

.github/workflows/pr_assignee.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Assign PR to creator
2+
3+
# Due to GitHub token limitation, only able to assign org members not authors from forks.
4+
# https://github.com/thomaseizinger/assign-pr-creator-action/issues/3
5+
6+
on:
7+
pull_request:
8+
types: [opened]
9+
branches-ignore:
10+
- l10n_dev
11+
12+
jobs:
13+
automation:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Assign PR to creator
17+
uses: thomaseizinger/[email protected]
18+
with:
19+
repo-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr_milestone.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Set Milestone
2+
3+
# Assigns the earliest created milestone that matches the below glob pattern.
4+
5+
on:
6+
pull_request:
7+
types: [opened]
8+
9+
jobs:
10+
automation:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: set-milestone
15+
uses: andrefcdias/[email protected]
16+
with:
17+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
18+
milestone: "+([0-9]).+([0-9]).+([0-9])"
19+
use-expression: true

Flow.Launcher.Core/ExternalPlugins/UserPlugin.cs

Lines changed: 3 additions & 1 deletion
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; }
1718
public DateTime? LatestReleaseDate { get; set; }
1819
public DateTime? DateAdded { get; set; }
1920

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

Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,20 @@ public virtual Task ReloadDataAsync()
139139
return Task.CompletedTask;
140140
}
141141

142-
public virtual ValueTask DisposeAsync()
142+
public virtual async ValueTask DisposeAsync()
143143
{
144-
RPC?.Dispose();
145-
ErrorStream?.Dispose();
146-
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+
}
147156
}
148157
}
149158
}

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Core.ExternalPlugins;
1+
using Flow.Launcher.Core.ExternalPlugins;
22
using System;
33
using System.Collections.Concurrent;
44
using System.Collections.Generic;
@@ -90,6 +90,48 @@ public static async Task ReloadDataAsync()
9090
}).ToArray());
9191
}
9292

93+
public static async Task OpenExternalPreviewAsync(string path, bool sendFailToast = true)
94+
{
95+
await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch
96+
{
97+
IAsyncExternalPreview p => p.OpenPreviewAsync(path, sendFailToast),
98+
_ => Task.CompletedTask,
99+
}).ToArray());
100+
}
101+
102+
public static async Task CloseExternalPreviewAsync()
103+
{
104+
await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch
105+
{
106+
IAsyncExternalPreview p => p.ClosePreviewAsync(),
107+
_ => Task.CompletedTask,
108+
}).ToArray());
109+
}
110+
111+
public static async Task SwitchExternalPreviewAsync(string path, bool sendFailToast = true)
112+
{
113+
await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch
114+
{
115+
IAsyncExternalPreview p => p.SwitchPreviewAsync(path, sendFailToast),
116+
_ => Task.CompletedTask,
117+
}).ToArray());
118+
}
119+
120+
public static bool UseExternalPreview()
121+
{
122+
return GetPluginsForInterface<IAsyncExternalPreview>().Any(x => !x.Metadata.Disabled);
123+
}
124+
125+
public static bool AllowAlwaysPreview()
126+
{
127+
var plugin = GetPluginsForInterface<IAsyncExternalPreview>().FirstOrDefault(x => !x.Metadata.Disabled);
128+
129+
if (plugin is null)
130+
return false;
131+
132+
return ((IAsyncExternalPreview)plugin.Plugin).AllowAlwaysPreview();
133+
}
134+
93135
static PluginManager()
94136
{
95137
// validate user directory
@@ -380,7 +422,8 @@ public static bool PluginModified(string uuid)
380422

381423

382424
/// <summary>
383-
/// Update a plugin to new version, from a zip file. Will Delete zip after updating.
425+
/// Update a plugin to new version, from a zip file. By default will remove the zip file if update is via url,
426+
/// unless it's a local path installation
384427
/// </summary>
385428
public static void UpdatePlugin(PluginMetadata existingVersion, UserPlugin newVersion, string zipFilePath)
386429
{
@@ -390,11 +433,11 @@ public static void UpdatePlugin(PluginMetadata existingVersion, UserPlugin newVe
390433
}
391434

392435
/// <summary>
393-
/// Install a plugin. Will Delete zip after updating.
436+
/// Install a plugin. By default will remove the zip file if installation is from url, unless it's a local path installation
394437
/// </summary>
395438
public static void InstallPlugin(UserPlugin plugin, string zipFilePath)
396439
{
397-
InstallPlugin(plugin, zipFilePath, true);
440+
InstallPlugin(plugin, zipFilePath, checkModified: true);
398441
}
399442

400443
/// <summary>
@@ -420,7 +463,9 @@ internal static void InstallPlugin(UserPlugin plugin, string zipFilePath, bool c
420463
// Unzip plugin files to temp folder
421464
var tempFolderPluginPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
422465
System.IO.Compression.ZipFile.ExtractToDirectory(zipFilePath, tempFolderPluginPath);
423-
File.Delete(zipFilePath);
466+
467+
if(!plugin.IsFromLocalInstallPath)
468+
File.Delete(zipFilePath);
424469

425470
var pluginFolderPath = GetContainingFolderPathAfterUnzip(tempFolderPluginPath);
426471

Flow.Launcher.Core/Plugin/ProcessStreamPluginV2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ public override async Task ReloadDataAsync()
8282

8383
public override async ValueTask DisposeAsync()
8484
{
85+
await base.DisposeAsync();
8586
ClientProcess.Kill(true);
8687
await ClientProcess.WaitForExitAsync();
8788
ClientProcess.Dispose();
88-
await base.DisposeAsync();
8989
}
9090
}
9191
}

0 commit comments

Comments
 (0)