Skip to content

Commit ffc6353

Browse files
Merge branch 'master' into bug/318-rename-clitool
2 parents eb41440 + f4d8144 commit ffc6353

Some content is hidden

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

58 files changed

+741
-2444
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
language: csharp
22
mono: none
33
dist: xenial
4-
dotnet: 2.2
4+
dotnet: 3.0
55
before_script:
66
- export PATH="$PATH:/home/travis/.dotnet/tools"
7-
- npm install electron-packager --global
87
script:
98
- ./buildAll.sh

Changelog.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
11
# Not released
22

3-
# 5.22.15
3+
# 7.30.3
4+
5+
# Released
6+
7+
# 7.30.2
8+
9+
ElectronNET.CLI:
10+
11+
* Different manifest file support [\#340](https://github.com/ElectronNET/Electron.NET/issues/340)
12+
* Create a additional manifest file: `electronize init /manifest test`
13+
* Start the app with your additional manifest file: `electronize start /manifest electron.manifest.test.json`
14+
* Build the app with your additional manifest file: `electronize build /target win /manifest electron.manifest.test.json`.
15+
16+
* Command Line support [\#337](https://github.com/ElectronNET/Electron.NET/issues/337)
17+
* You can start the app with: `electronize start /args --dog=woof --test=true`
18+
* Or as binary: `myapp.exe /args --dog=woof --test=true`
19+
* Fixed bug: Start process with listen port 8000 error. [\#308](https://github.com/ElectronNET/Electron.NET/issues/308) (thanks [thecodejedi](https://github.com/thecodejedi))
20+
* Fixed bug: `electronize build` with no arguments would throw a `KeyNotFoundException`. (thanks [jamiebrynes7](https://github.com/jamiebrynes7))
421

522
ElectronNET.API:
623

7-
* New Feature: Add BrowserWindow.RemoveMenu() (thanks [hack2root](https://github.com/hack2root))
24+
* New Feature: Electron 7.1.2 support, but not all new features (we search contributors) [\#341](https://github.com/ElectronNET/Electron.NET/issues/341)
25+
* New Feature: Electron.App.CommandLine API [\#337](https://github.com/ElectronNET/Electron.NET/issues/337)
26+
* New Feature: Support of BrowserWindow.AddExtension, BrowserWindow.RemoveExtension, BrowserWindow.GetExtensions (thanks [Daddoon](https://github.com/Daddoon))
827

9-
# Released
28+
Thank you for donation [robertmclaws](https://github.com/robertmclaws)
29+
30+
# 5.30.1
31+
32+
ElectronNET.CLI:
33+
34+
* Move to .NET Core 3.0
35+
* Use npm npx instead of global installations (thanks [jimbuck](https://github.com/jimbuck))
36+
37+
ElectronNET.API:
38+
39+
* Move to .NET Core 3.0
40+
* New Feature: Add BrowserWindow.RemoveMenu() (thanks [hack2root](https://github.com/hack2root))
1041

42+
Thanks to [MaherJendoubi](https://github.com/MaherJendoubi), [kant2002](https://github.com/kant2002), [raz-canva](https://github.com/raz-canva) and [Daddoon](https://github.com/Daddoon) to give .NET Core 3.0 feedback!
1143
# 5.22.14
1244

1345
ElectronNET.CLI:

ElectronNET.API/App.cs

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ public event Action<bool> AccessibilitySupportChanged
351351

352352
private event Action<bool> _accessibilitySupportChanged;
353353

354-
internal App() { }
354+
internal App()
355+
{
356+
CommandLine = new CommandLine();
357+
}
355358

356359
internal static App Instance
357360
{
@@ -1224,7 +1227,7 @@ public void SetAppUserModelId(string id)
12241227
taskCompletionSource.SetResult((bool)success);
12251228
});
12261229

1227-
BridgeConnector.Socket.Emit("appSetBadgeCount");
1230+
BridgeConnector.Socket.Emit("appSetBadgeCount", count);
12281231

12291232
return await taskCompletionSource.Task
12301233
.ConfigureAwait(false);
@@ -1255,6 +1258,11 @@ public void SetAppUserModelId(string id)
12551258
}
12561259
}
12571260

1261+
/// <summary>
1262+
/// Manipulate the command line arguments for your app that Chromium reads.
1263+
/// </summary>
1264+
public CommandLine CommandLine { get; internal set; }
1265+
12581266
/// <summary>
12591267
/// Whether the current desktop environment is Unity launcher.
12601268
/// </summary>
@@ -1380,39 +1388,6 @@ public void SetAboutPanelOptions(AboutPanelOptions options)
13801388
BridgeConnector.Socket.Emit("appSetAboutPanelOptions", JObject.FromObject(options, _jsonSerializer));
13811389
}
13821390

1383-
/// <summary>
1384-
/// Append a switch (with optional value) to Chromium's command line. Note: This
1385-
/// will not affect process.argv, and is mainly used by developers to control some
1386-
/// low-level Chromium behaviors.
1387-
/// </summary>
1388-
/// <param name="theSwtich">A command-line switch.</param>
1389-
public void CommandLineAppendSwitch(string theSwtich)
1390-
{
1391-
BridgeConnector.Socket.Emit("appCommandLineAppendSwitch", theSwtich);
1392-
}
1393-
1394-
/// <summary>
1395-
/// Append a switch (with optional value) to Chromium's command line. Note: This
1396-
/// will not affect process.argv, and is mainly used by developers to control some
1397-
/// low-level Chromium behaviors.
1398-
/// </summary>
1399-
/// <param name="theSwtich">A command-line switch.</param>
1400-
/// <param name="value">A value for the given switch.</param>
1401-
public void CommandLineAppendSwitch(string theSwtich, string value)
1402-
{
1403-
BridgeConnector.Socket.Emit("appCommandLineAppendSwitch", theSwtich, value);
1404-
}
1405-
1406-
/// <summary>
1407-
/// Append an argument to Chromium's command line. The argument will be quoted
1408-
/// correctly.Note: This will not affect process.argv.
1409-
/// </summary>
1410-
/// <param name="value">The argument to append to the command line.</param>
1411-
public void CommandLineAppendArgument(string value)
1412-
{
1413-
BridgeConnector.Socket.Emit("appCommandLineAppendArgument", value);
1414-
}
1415-
14161391
/// <summary>
14171392
/// When critical is passed, the dock icon will bounce until either the application
14181393
/// becomes active or the request is canceled.When informational is passed, the

ElectronNET.API/BrowserWindow.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,5 +2310,58 @@ public void SetVibrancy(Vibrancy type)
23102310
ContractResolver = new CamelCasePropertyNamesContractResolver(),
23112311
NullValueHandling = NullValueHandling.Ignore
23122312
};
2313+
2314+
/// <summary>
2315+
/// Adds Chrome extension located at path, and returns extension's name.
2316+
/// The method will also not return if the extension's manifest is missing or incomplete.
2317+
/// Note: This API cannot be called before the ready event of the app module is emitted.
2318+
/// </summary>
2319+
/// <param name="path">Path to the Chrome extension</param>
2320+
/// <returns></returns>
2321+
public static Task<string> AddExtensionAsync(string path)
2322+
{
2323+
var taskCompletionSource = new TaskCompletionSource<string>();
2324+
2325+
BridgeConnector.Socket.On("browserWindow-addExtension-completed", (extensionname) => {
2326+
BridgeConnector.Socket.Off("browserWindow-addExtension-completed");
2327+
2328+
taskCompletionSource.SetResult(extensionname.ToString());
2329+
});
2330+
2331+
BridgeConnector.Socket.Emit("browserWindowAddExtension", path);
2332+
2333+
return taskCompletionSource.Task;
2334+
}
2335+
2336+
/// <summary>
2337+
/// Remove Chrome extension with the specified name.
2338+
/// Note: This API cannot be called before the ready event of the app module is emitted.
2339+
/// </summary>
2340+
/// <param name="name">Name of the Chrome extension to remove</param>
2341+
public static void RemoveExtension(string name)
2342+
{
2343+
BridgeConnector.Socket.Emit("browserWindowRemoveExtension", name);
2344+
}
2345+
2346+
/// <summary>
2347+
/// The keys are the extension names and each value is an object containing name and version properties.
2348+
/// Note: This API cannot be called before the ready event of the app module is emitted.
2349+
/// </summary>
2350+
/// <returns></returns>
2351+
public static Task<ChromeExtensionInfo[]> GetExtensionsAsync()
2352+
{
2353+
var taskCompletionSource = new TaskCompletionSource<ChromeExtensionInfo[]>();
2354+
2355+
BridgeConnector.Socket.On("browserWindow-getExtensions-completed", (extensionslist) => {
2356+
BridgeConnector.Socket.Off("browserWindow-getExtensions-completed");
2357+
var chromeExtensionInfos = ((JArray)extensionslist).ToObject<ChromeExtensionInfo[]>();
2358+
2359+
taskCompletionSource.SetResult(chromeExtensionInfos);
2360+
});
2361+
2362+
BridgeConnector.Socket.Emit("browserWindowGetExtensions");
2363+
2364+
return taskCompletionSource.Task;
2365+
}
23132366
}
23142367
}

ElectronNET.API/CommandLine.cs

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
4+
namespace ElectronNET.API
5+
{
6+
/// <summary>
7+
/// Manipulate the command line arguments for your app that Chromium reads.
8+
/// </summary>
9+
public sealed class CommandLine
10+
{
11+
internal CommandLine() { }
12+
13+
internal static CommandLine Instance
14+
{
15+
get
16+
{
17+
if (_commandLine == null)
18+
{
19+
lock (_syncRoot)
20+
{
21+
if (_commandLine == null)
22+
{
23+
_commandLine = new CommandLine();
24+
}
25+
}
26+
}
27+
28+
return _commandLine;
29+
}
30+
}
31+
32+
private static CommandLine _commandLine;
33+
34+
private static object _syncRoot = new object();
35+
36+
/// <summary>
37+
/// Append a switch (with optional value) to Chromium's command line.
38+
/// </summary>
39+
/// <param name="the_switch">A command-line switch, without the leading --</param>
40+
/// <param name="value">(optional) - A value for the given switch</param>
41+
/// <remarks>
42+
/// Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.
43+
/// </remarks>
44+
public void AppendSwitch(string the_switch, string value = "")
45+
{
46+
BridgeConnector.Socket.Emit("appCommandLineAppendSwitch", the_switch, value);
47+
}
48+
49+
/// <summary>
50+
/// Append an argument to Chromium's command line. The argument will be quoted correctly. Switches will precede arguments regardless of appending order.
51+
///
52+
/// If you're appending an argument like <code>--switch=value</code>, consider using <code>appendSwitch('switch', 'value')</code> instead.
53+
/// </summary>
54+
/// <param name="value">The argument to append to the command line</param>
55+
/// <remarks>
56+
/// Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.
57+
/// </remarks>
58+
public void AppendArgument(string value)
59+
{
60+
BridgeConnector.Socket.Emit("appCommandLineAppendArgument", value);
61+
}
62+
63+
/// <summary>
64+
/// Whether the command-line switch is present.
65+
/// </summary>
66+
/// <param name="switchName">A command-line switch</param>
67+
/// <param name="cancellationToken"></param>
68+
/// <returns>Whether the command-line switch is present.</returns>
69+
public async Task<bool> HasSwitchAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
70+
{
71+
cancellationToken.ThrowIfCancellationRequested();
72+
73+
var taskCompletionSource = new TaskCompletionSource<bool>();
74+
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
75+
{
76+
BridgeConnector.Socket.On("appCommandLineHasSwitchCompleted", (result) =>
77+
{
78+
BridgeConnector.Socket.Off("appCommandLineHasSwitchCompleted");
79+
taskCompletionSource.SetResult((bool)result);
80+
});
81+
82+
BridgeConnector.Socket.Emit("appCommandLineHasSwitch", switchName);
83+
84+
return await taskCompletionSource.Task.ConfigureAwait(false);
85+
}
86+
}
87+
88+
/// <summary>
89+
/// The command-line switch value.
90+
/// </summary>
91+
/// <param name="switchName">A command-line switch</param>
92+
/// <param name="cancellationToken"></param>
93+
/// <returns>The command-line switch value.</returns>
94+
/// <remarks>
95+
/// Note: When the switch is not present or has no value, it returns empty string.
96+
/// </remarks>
97+
public async Task<string> GetSwitchValueAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
98+
{
99+
cancellationToken.ThrowIfCancellationRequested();
100+
101+
var taskCompletionSource = new TaskCompletionSource<string>();
102+
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
103+
{
104+
BridgeConnector.Socket.On("appCommandLineGetSwitchValueCompleted", (result) =>
105+
{
106+
BridgeConnector.Socket.Off("appCommandLineGetSwitchValueCompleted");
107+
taskCompletionSource.SetResult((string)result);
108+
});
109+
110+
BridgeConnector.Socket.Emit("appCommandLineGetSwitchValue", switchName);
111+
112+
return await taskCompletionSource.Task.ConfigureAwait(false);
113+
}
114+
}
115+
}
116+
}

ElectronNET.API/ElectronNET.API.csproj

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
66
<PackageOutputPath>..\artifacts</PackageOutputPath>
77
<PackageId>ElectronNET.API</PackageId>
@@ -17,22 +17,14 @@ This package contains the API to access the "native" electron API.</Description>
1717
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1818
<PackageTags>electron aspnetcore</PackageTags>
1919
<PackageReleaseNotes>Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md</PackageReleaseNotes>
20-
<PackageIconUrl>https://raw.githubusercontent.com/ElectronNET/Electron.NET/master/assets/images/electron.net-logo-square.png</PackageIconUrl>
21-
<Version>1.0.0.0</Version>
20+
<PackageIcon>PackageIcon.png</PackageIcon>
21+
<Version>99.0.0.0</Version>
22+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2223
</PropertyGroup>
2324

24-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
25-
<DocumentationFile>bin\Debug\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
26-
</PropertyGroup>
27-
28-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
29-
<DocumentationFile>bin\Release\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
30-
</PropertyGroup>
31-
32-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
33-
<DocumentationFile>bin\Debug\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
34-
<Optimize>true</Optimize>
35-
</PropertyGroup>
25+
<ItemGroup>
26+
<None Include="PackageIcon.png" Pack="true" PackagePath="\" />
27+
</ItemGroup>
3628

3729
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
3830
<Exec Command="$(ProjectDir)devCleanup.cmd" IgnoreExitCode="true" />
@@ -41,8 +33,10 @@ This package contains the API to access the "native" electron API.</Description>
4133
<Exec Command="$(ProjectDir)devCleanup.sh" IgnoreExitCode="true" />
4234
</Target>
4335
<ItemGroup>
44-
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.1" />
45-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05">
36+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
37+
</ItemGroup>
38+
<ItemGroup>
39+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01">
4640
<PrivateAssets>all</PrivateAssets>
4741
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4842
</PackageReference>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace ElectronNET.API.Entities
6+
{
7+
/// <summary>
8+
/// Provide metadata about the current loaded Chrome extension
9+
/// </summary>
10+
public class ChromeExtensionInfo
11+
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="ChromeExtensionInfo"/> class.
14+
/// </summary>
15+
/// <param name="name">The name of the Chrome extension.</param>
16+
/// <param name="version">The version of the Chrome extension.</param>
17+
public ChromeExtensionInfo(string name, string version)
18+
{
19+
Name = name;
20+
Version = version;
21+
}
22+
23+
/// <summary>
24+
/// Name of the Chrome extension
25+
/// </summary>
26+
public string Name { get; set; }
27+
28+
/// <summary>
29+
/// Version of the Chrome extension
30+
/// </summary>
31+
public string Version { get; set; }
32+
}
33+
}

0 commit comments

Comments
 (0)