mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-04 05:34:51 +00:00
Compare commits
153 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
022221307c | ||
|
|
ffc6353bf2 | ||
|
|
f4d8144a8b | ||
|
|
30d49ff6e8 | ||
|
|
db9d3b1484 | ||
|
|
a788d71530 | ||
|
|
f5e2abfdb4 | ||
|
|
42f09de7b5 | ||
|
|
72d1f4b2b9 | ||
|
|
d2b3c28f91 | ||
|
|
94c4cd82b0 | ||
|
|
600bc1a41b | ||
|
|
4e8e771293 | ||
|
|
4014ef7a4d | ||
|
|
364db7dc25 | ||
|
|
3dda18ac9a | ||
|
|
7f92ffa20e | ||
|
|
b69d4d23bf | ||
|
|
eb4144053d | ||
|
|
239d914747 | ||
|
|
5af8e489b9 | ||
|
|
b6fb1cb0bf | ||
|
|
aa98b85f18 | ||
|
|
af74d24f50 | ||
|
|
2240ffca82 | ||
|
|
f64b780a27 | ||
|
|
fbc5b93513 | ||
|
|
14d02706c0 | ||
|
|
2c14693430 | ||
|
|
54ff11acf5 | ||
|
|
b7e7ace6f3 | ||
|
|
1f7908a0f1 | ||
|
|
cafffde339 | ||
|
|
6fbba52edd | ||
|
|
8dd5d1561a | ||
|
|
25f35e34fe | ||
|
|
f1eaffb203 | ||
|
|
69ca5d6f9e | ||
|
|
5cd11a8110 | ||
|
|
c343b19a60 | ||
|
|
b3bb3ceb97 | ||
|
|
e25b89ff6a | ||
|
|
28be0dd209 | ||
|
|
8bf10c370c | ||
|
|
a32b50f86f | ||
|
|
a781234d05 | ||
|
|
8b66bdd7cb | ||
|
|
ba64639c1d | ||
|
|
5157561dc6 | ||
|
|
bbecd86cce | ||
|
|
bd99da560b | ||
|
|
9278402d65 | ||
|
|
9bc1b46810 | ||
|
|
d2956e6f2f | ||
|
|
da4e930478 | ||
|
|
8e9f7b016a | ||
|
|
10e95afa5c | ||
|
|
68505f8feb | ||
|
|
c91884a520 | ||
|
|
ccf0a4c73b | ||
|
|
660663d9c1 | ||
|
|
36ee9c4dd7 | ||
|
|
9f7c99db53 | ||
|
|
b9ba162a88 | ||
|
|
ad399f50ee | ||
|
|
428e53e265 | ||
|
|
0a02b7140b | ||
|
|
f6ea0dd8dc | ||
|
|
dc8987de5a | ||
|
|
dc73be0c81 | ||
|
|
4dc8f189f9 | ||
|
|
5ec179af5d | ||
|
|
802b1acf68 | ||
|
|
07a0bc9c7d | ||
|
|
43028afc02 | ||
|
|
d3d73611b7 | ||
|
|
6d31c41479 | ||
|
|
98a549560f | ||
|
|
8a3b9951fa | ||
|
|
552b4331b2 | ||
|
|
38785f9b18 | ||
|
|
886b4b81a5 | ||
|
|
e6b6f990d7 | ||
|
|
a2ada57292 | ||
|
|
0cede6131e | ||
|
|
ce52988aac | ||
|
|
3a52680a54 | ||
|
|
6d28e57f04 | ||
|
|
a2cdabf8cb | ||
|
|
25ab81ca8f | ||
|
|
5ba54ab40b | ||
|
|
cca8110c38 | ||
|
|
06f43032b4 | ||
|
|
0709d61120 | ||
|
|
aa09af8ad6 | ||
|
|
e90ef9e48d | ||
|
|
6d076fb99a | ||
|
|
131d1d9dd1 | ||
|
|
e5132e8198 | ||
|
|
6a7c60fdb5 | ||
|
|
8605fab9a7 | ||
|
|
c03d6e8976 | ||
|
|
5e0ef7edb5 | ||
|
|
5300609360 | ||
|
|
ed6ebe90b1 | ||
|
|
4e95322468 | ||
|
|
412f628422 | ||
|
|
3cb92169dd | ||
|
|
aea2c7aff5 | ||
|
|
ba16c4e032 | ||
|
|
8b5bb636f3 | ||
|
|
0fac6ae1cd | ||
|
|
24d1f6f844 | ||
|
|
73f7e5a7b2 | ||
|
|
01d1397a60 | ||
|
|
77e7280b1f | ||
|
|
8d6a5a757e | ||
|
|
f2e0808ede | ||
|
|
aa7efbad4b | ||
|
|
d0c52a1364 | ||
|
|
4235aa4677 | ||
|
|
8a3c86abc0 | ||
|
|
eda9b08cac | ||
|
|
a5cee6e6d5 | ||
|
|
4db0ac0ebb | ||
|
|
2a9c0e1d60 | ||
|
|
7dc3072b5f | ||
|
|
6642f9d505 | ||
|
|
078ac99098 | ||
|
|
f7cc2a995f | ||
|
|
c0ee3b8859 | ||
|
|
597df77508 | ||
|
|
f709f65f9e | ||
|
|
71d2b88b02 | ||
|
|
f4631c99f7 | ||
|
|
04968d088b | ||
|
|
5d446b23fa | ||
|
|
2b3eabf75a | ||
|
|
27a5057bb0 | ||
|
|
28f0ffaf62 | ||
|
|
0f085fdb1d | ||
|
|
7d8301af54 | ||
|
|
132b20b4ae | ||
|
|
cca5f7f40d | ||
|
|
63c2bcdf7c | ||
|
|
cad371c221 | ||
|
|
f4efad299a | ||
|
|
17e4646d11 | ||
|
|
977f389e2f | ||
|
|
b6ec73cb84 | ||
|
|
15499e38bf | ||
|
|
538bc02b54 | ||
|
|
2fb3062d4b |
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: https://donorbox.org/electron-net
|
||||
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Please search existing issues to avoid creating duplicates. -->
|
||||
|
||||
<!-- Which version of Electron.NET CLI and API are you using? -->
|
||||
<!-- Please always try to use latest version before report. -->
|
||||
* **Version**:
|
||||
|
||||
<!-- Which version of .NET Core and Node.js are you using (if applicable)? -->
|
||||
|
||||
<!-- What target are you building for? -->
|
||||
* **Target**:
|
||||
|
||||
<!-- Enter your issue details below this comment. -->
|
||||
<!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) -->
|
||||
|
||||
Steps to Reproduce:
|
||||
|
||||
1.
|
||||
2.
|
||||
13
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
13
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: Feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Please search existing feature request to avoid creating duplicates. -->
|
||||
|
||||
<!-- If you want, you can donate to increase feature request priority (https://donorbox.org/electron-net) -->
|
||||
<!-- Describe the feature you'd like. -->
|
||||
13
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
13
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
name: Question
|
||||
about: The issue tracker is not for questions. Please ask questions on https://stackoverflow.com/questions/tagged/electron.net
|
||||
or via chat in https://gitter.im/ElectronNET/community.
|
||||
title: ''
|
||||
labels: question
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
🚨 The issue tracker is not for questions 🚨
|
||||
|
||||
The issue tracker is not for questions. Please ask questions on https://stackoverflow.com/questions/tagged/electron.net or via chat in https://gitter.im/ElectronNET/community.
|
||||
@@ -1,8 +1,8 @@
|
||||
language: csharp
|
||||
mono: none
|
||||
dotnet: 2.1.300
|
||||
dist: xenial
|
||||
dotnet: 3.0
|
||||
before_script:
|
||||
- export PATH="$PATH:/home/travis/.dotnet/tools"
|
||||
- npm install electron-packager --global
|
||||
script:
|
||||
- ./buildAll.sh
|
||||
|
||||
104
Changelog.md
104
Changelog.md
@@ -1,5 +1,101 @@
|
||||
# not release
|
||||
# Not released
|
||||
|
||||
# 7.30.3
|
||||
|
||||
# Released
|
||||
|
||||
# 7.30.2
|
||||
|
||||
ElectronNET.CLI:
|
||||
|
||||
* Different manifest file support [\#340](https://github.com/ElectronNET/Electron.NET/issues/340)
|
||||
* Create a additional manifest file: `electronize init /manifest test`
|
||||
* Start the app with your additional manifest file: `electronize start /manifest electron.manifest.test.json`
|
||||
* Build the app with your additional manifest file: `electronize build /target win /manifest electron.manifest.test.json`.
|
||||
|
||||
* Command Line support [\#337](https://github.com/ElectronNET/Electron.NET/issues/337)
|
||||
* You can start the app with: `electronize start /args --dog=woof --test=true`
|
||||
* Or as binary: `myapp.exe /args --dog=woof --test=true`
|
||||
* Fixed bug: Start process with listen port 8000 error. [\#308](https://github.com/ElectronNET/Electron.NET/issues/308) (thanks [thecodejedi](https://github.com/thecodejedi))
|
||||
* Fixed bug: `electronize build` with no arguments would throw a `KeyNotFoundException`. (thanks [jamiebrynes7](https://github.com/jamiebrynes7))
|
||||
|
||||
ElectronNET.API:
|
||||
|
||||
* New Feature: Electron 7.1.2 support, but not all new features (we search contributors) [\#341](https://github.com/ElectronNET/Electron.NET/issues/341)
|
||||
* New Feature: Electron.App.CommandLine API [\#337](https://github.com/ElectronNET/Electron.NET/issues/337)
|
||||
* New Feature: Support of BrowserWindow.AddExtension, BrowserWindow.RemoveExtension, BrowserWindow.GetExtensions (thanks [Daddoon](https://github.com/Daddoon))
|
||||
|
||||
Thank you for donation [robertmclaws](https://github.com/robertmclaws) ❤
|
||||
|
||||
# 5.30.1
|
||||
|
||||
ElectronNET.CLI:
|
||||
|
||||
* Move to .NET Core 3.0
|
||||
* Use npm npx instead of global installations (thanks [jimbuck](https://github.com/jimbuck))
|
||||
|
||||
ElectronNET.API:
|
||||
|
||||
* Move to .NET Core 3.0
|
||||
* New Feature: Add BrowserWindow.RemoveMenu() (thanks [hack2root](https://github.com/hack2root))
|
||||
|
||||
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!
|
||||
# 5.22.14
|
||||
|
||||
ElectronNET.CLI:
|
||||
|
||||
* Fixed bug: Build fails with latest electron-builder version [\#288](https://github.com/ElectronNET/Electron.NET/issues/288)
|
||||
|
||||
ElectronNET.API:
|
||||
|
||||
* New Feature: Full support for Auto Updater [(Based on electron-updater - Version 4.0.6)](https://www.electron.build/auto-update)
|
||||
* New Feature: Support for set a custom static Port to ASP.NET Backend [\#155](https://github.com/ElectronNET/Electron.NET/issues/155)
|
||||
* Fixed bug: Electron tray icon TypeError ([Electron original issue](https://github.com/electron/electron/issues/7657)) (thanks [Tum4ik](https://github.com/Tum4ik))
|
||||
* Fixed bug: Wrong tray icon path in the application built via `electronize build` command (thanks [Tum4ik](https://github.com/Tum4ik))
|
||||
* Fixed bug: fix async issue where same port is considered open [\#261](https://github.com/ElectronNET/Electron.NET/issues/261) (thanks [netpoetica](https://github.com/netpoetica))
|
||||
|
||||
ElectronNET.WebApp:
|
||||
|
||||
* Fixed usage of the `Electron.Tray.Show` according fixed bugs in the ElectronNET.CLI (thanks [Tum4ik](https://github.com/Tum4ik))
|
||||
|
||||
# 5.22.13
|
||||
|
||||
ElectronNET.API:
|
||||
|
||||
* Fixed bug: Menu Item visibility [\#257](https://github.com/ElectronNET/Electron.NET/issues/257)
|
||||
* Fixed bug: electron.manifest.json - singleInstance not working [\#258](https://github.com/ElectronNET/Electron.NET/issues/258)
|
||||
* Fixed security issue: ASP.NET Core process is now bound to 127.0.0.1 instead of the broader localhost [\#258](https://github.com/ElectronNET/Electron.NET/pull/266)
|
||||
|
||||
# 5.22.12
|
||||
|
||||
ElectronNET.CLI:
|
||||
|
||||
* New Feature: Changed from **electron packager** to [**electron builder**](https://www.electron.build/)
|
||||
* New Feature: 'add hosthook' command for add a ElectronHostHook-Directory
|
||||
* Fixed bug: 'Unexpected firewall warnings' [\#181](https://github.com/ElectronNET/Electron.NET/issues/181)
|
||||
* Fixed bug: 'found 8 vulnerabilities (1 low, 5 moderate, 2 high)' [\#199](https://github.com/ElectronNET/Electron.NET/pull/199)
|
||||
* Merged pull request: Call electronize from the Path instead of via dotnet in launchSettings.json [\#243](https://github.com/ElectronNET/Electron.NET/pull/243) (thanks [grbd](https://github.com/grbd))
|
||||
|
||||
ElectronNET.API:
|
||||
|
||||
* New Feature: Electron 5.0.1 support, but not all new features
|
||||
* New Feature: Auto Updater [(Based on electron-updater)](https://www.electron.build/auto-update)
|
||||
* New Feature: Splashscreen-Support
|
||||
* New Feature: HostHook-API for execute own TypeScript/JavaScript code on native Electron Main-Process
|
||||
* New Feature: Session-API functions
|
||||
* Fixed bug: Node process running after stopping app [\#96](https://github.com/ElectronNET/Electron.NET/issues/96)
|
||||
* Fixed bug: 'X and Y options to not work on Windows 10' [\#193](https://github.com/ElectronNET/Electron.NET/issues/193)
|
||||
* Fixed bug: Unable to clear cache [\#66](https://github.com/ElectronNET/Electron.NET/issues/66)
|
||||
* Merged pull request: Fix BrowserWindow::SetMenu [\#231](https://github.com/ElectronNET/Electron.NET/pull/231) thanks (thanks [CodeKenpachi](https://github.com/CodeKenpachi))
|
||||
* Merged pull request: FIX application hangs after socket reconnect [\#233](https://github.com/ElectronNET/Electron.NET/pull/233) (thanks [pedromrpinto](https://github.com/pedromrpinto))
|
||||
* Merged pull request: Reduce chance of detecting false positives when scanning subprocesses for errors. [\#236](https://github.com/ElectronNET/Electron.NET/pull/236) (thanks [BorisTheBrave](https://github.com/BorisTheBrave))
|
||||
* Merged pull request: Updates the C# API to accept floating point as in JS. [\#240](https://github.com/ElectronNET/Electron.NET/pull/240) (thanks [BorisTheBrave](https://github.com/BorisTheBrave))
|
||||
* Merged pull request: buildReleaseNuGetPackages should leave you in the same directory you … [\#241](https://github.com/ElectronNET/Electron.NET/pull/241) (thanks [BorisTheBrave](https://github.com/BorisTheBrave))
|
||||
|
||||
ElectronNET.WebApp:
|
||||
|
||||
* Implemented a sample for the new HostHook-API
|
||||
* Fixed bug: 'Electron.NET API Demo: unable to copy code?' [\#247](https://github.com/ElectronNET/Electron.NET/issues/247)
|
||||
|
||||
# 0.0.11
|
||||
|
||||
@@ -39,12 +135,12 @@ ElectronNET.API:
|
||||
ElectronNET.CLI:
|
||||
|
||||
* More options on the 'build' command, e.g. for a 32bit debug build with electron prune: build /target custom win7-x86;win32 /dotnet-configuration Debug /electron-arch ia32 /electron-params "--prune=true "
|
||||
* .NET Core project is now build with Release configuration, but can be adjusted with the new params.
|
||||
* .NET Core project is now built with Release configuration but can be adjusted with the new params.
|
||||
* Be aware: "Breaking" (but because of the alpha status of this project, we won't use SemVer)
|
||||
|
||||
# 0.0.8
|
||||
|
||||
This version was skipped because we unfortunatly released a pre version of this on NuGet.
|
||||
This version was skipped because we unfortunately released a pre-version of this on NuGet.
|
||||
|
||||
# 0.0.7
|
||||
|
||||
@@ -57,7 +153,7 @@ ElectronNET.CLI:
|
||||
|
||||
ElectronNET.CLI:
|
||||
|
||||
* nuget packages are now release bits and have the correct assembly verion
|
||||
* nuget packages are now release bits and have the correct assembly version
|
||||
* Version command
|
||||
* better devCleanup.cmd
|
||||
* Better Platform Support Issue - thanks to @Petermarcu
|
||||
|
||||
@@ -3,7 +3,6 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -352,7 +351,10 @@ namespace ElectronNET.API
|
||||
|
||||
private event Action<bool> _accessibilitySupportChanged;
|
||||
|
||||
internal App() { }
|
||||
internal App()
|
||||
{
|
||||
CommandLine = new CommandLine();
|
||||
}
|
||||
|
||||
internal static App Instance
|
||||
{
|
||||
@@ -374,7 +376,7 @@ namespace ElectronNET.API
|
||||
}
|
||||
|
||||
private static App _app;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
@@ -1225,7 +1227,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appSetBadgeCount");
|
||||
BridgeConnector.Socket.Emit("appSetBadgeCount", count);
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
@@ -1256,6 +1258,11 @@ namespace ElectronNET.API
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manipulate the command line arguments for your app that Chromium reads.
|
||||
/// </summary>
|
||||
public CommandLine CommandLine { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the current desktop environment is Unity launcher.
|
||||
/// </summary>
|
||||
@@ -1381,47 +1388,6 @@ namespace ElectronNET.API
|
||||
BridgeConnector.Socket.Emit("appSetAboutPanelOptions", JObject.FromObject(options, _jsonSerializer));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a switch (with optional value) to Chromium's command line. Note: This
|
||||
/// will not affect process.argv, and is mainly used by developers to control some
|
||||
/// low-level Chromium behaviors.
|
||||
/// </summary>
|
||||
/// <param name="theSwtich">A command-line switch.</param>
|
||||
public void CommandLineAppendSwitch(string theSwtich)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appCommandLineAppendSwitch", theSwtich);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a switch (with optional value) to Chromium's command line. Note: This
|
||||
/// will not affect process.argv, and is mainly used by developers to control some
|
||||
/// low-level Chromium behaviors.
|
||||
/// </summary>
|
||||
/// <param name="theSwtich">A command-line switch.</param>
|
||||
/// <param name="value">A value for the given switch.</param>
|
||||
public void CommandLineAppendSwitch(string theSwtich, string value)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appCommandLineAppendSwitch", theSwtich, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append an argument to Chromium's command line. The argument will be quoted
|
||||
/// correctly.Note: This will not affect process.argv.
|
||||
/// </summary>
|
||||
/// <param name="value">The argument to append to the command line.</param>
|
||||
public void CommandLineAppendArgument(string value)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appCommandLineAppendArgument", value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables mixed sandbox mode on the app. This method can only be called before app is ready.
|
||||
/// </summary>
|
||||
public void EnableMixedSandbox()
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appEnableMixedSandbox");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When critical is passed, the dock icon will bounce until either the application
|
||||
/// becomes active or the request is canceled.When informational is passed, the
|
||||
|
||||
505
ElectronNET.API/AutoUpdater.cs
Normal file
505
ElectronNET.API/AutoUpdater.cs
Normal file
@@ -0,0 +1,505 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
/// Enable apps to automatically update themselves. Based on electron-updater.
|
||||
/// </summary>
|
||||
public sealed class AutoUpdater
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether to automatically download an update when it is found. (Default is true)
|
||||
/// </summary>
|
||||
public bool AutoDownload
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-autoDownload-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-autoDownload-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-set", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether to automatically install a downloaded update on app quit (if `QuitAndInstall` was not called before).
|
||||
///
|
||||
/// Applicable only on Windows and Linux.
|
||||
/// </summary>
|
||||
public bool AutoInstallOnAppQuit
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-autoInstallOnAppQuit-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-autoInstallOnAppQuit-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-set", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// *GitHub provider only.* Whether to allow update to pre-release versions.
|
||||
/// Defaults to "true" if application version contains prerelease components (e.g. "0.12.1-alpha.1", here "alpha" is a prerelease component), otherwise "false".
|
||||
///
|
||||
/// If "true", downgrade will be allowed("allowDowngrade" will be set to "true").
|
||||
/// </summary>
|
||||
public bool AllowPrerelease
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-allowPrerelease-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-allowPrerelease-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-set", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// *GitHub provider only.*
|
||||
/// Get all release notes (from current version to latest), not just the latest (Default is false).
|
||||
/// </summary>
|
||||
public bool FullChangelog
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-fullChangelog-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-fullChangelog-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-set", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel).
|
||||
/// Taken in account only if channel differs (pre-release version component in terms of semantic versioning).
|
||||
/// Default is false.
|
||||
/// </summary>
|
||||
public bool AllowDowngrade
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-allowDowngrade-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-allowDowngrade-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-set", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For test only.
|
||||
/// </summary>
|
||||
public string UpdateConfigPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<string>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-updateConfigPath-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-updateConfigPath-get-reply");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-updateConfigPath-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the update channel. Not applicable for GitHub.
|
||||
/// Doesn’t return channel from the update configuration, only if was previously set.
|
||||
/// </summary>
|
||||
public string Channel
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<string>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-channel-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-channel-get-reply");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-channel-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when there is an error while updating.
|
||||
/// </summary>
|
||||
public event Action<string> OnError
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_error == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-error" + GetHashCode(), (message) =>
|
||||
{
|
||||
_error(message.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-error-event", GetHashCode());
|
||||
}
|
||||
_error += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_error -= value;
|
||||
|
||||
if (_error == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-error" + GetHashCode());
|
||||
}
|
||||
}
|
||||
|
||||
private event Action<string> _error;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when checking if an update has started.
|
||||
/// </summary>
|
||||
public event Action OnCheckingForUpdate
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_checkingForUpdate == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-checking-for-update" + GetHashCode(), () =>
|
||||
{
|
||||
_checkingForUpdate();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-checking-for-update-event", GetHashCode());
|
||||
}
|
||||
_checkingForUpdate += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_checkingForUpdate -= value;
|
||||
|
||||
if (_checkingForUpdate == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-checking-for-update" + GetHashCode());
|
||||
}
|
||||
}
|
||||
|
||||
private event Action _checkingForUpdate;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when there is an available update.
|
||||
/// The update is downloaded automatically if AutoDownload is true.
|
||||
/// </summary>
|
||||
public event Action<UpdateInfo> OnUpdateAvailable
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_updateAvailable == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-update-available" + GetHashCode(), (updateInfo) =>
|
||||
{
|
||||
_updateAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-update-available-event", GetHashCode());
|
||||
}
|
||||
_updateAvailable += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_updateAvailable -= value;
|
||||
|
||||
if (_updateAvailable == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-update-available" + GetHashCode());
|
||||
}
|
||||
}
|
||||
|
||||
private event Action<UpdateInfo> _updateAvailable;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when there is no available update.
|
||||
/// </summary>
|
||||
public event Action<UpdateInfo> OnUpdateNotAvailable
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_updateNotAvailable == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-update-not-available" + GetHashCode(), (updateInfo) =>
|
||||
{
|
||||
_updateNotAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-update-not-available-event", GetHashCode());
|
||||
}
|
||||
_updateNotAvailable += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_updateNotAvailable -= value;
|
||||
|
||||
if (_updateNotAvailable == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-update-not-available" + GetHashCode());
|
||||
}
|
||||
}
|
||||
|
||||
private event Action<UpdateInfo> _updateNotAvailable;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted on download progress.
|
||||
/// </summary>
|
||||
public event Action<ProgressInfo> OnDownloadProgress
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_downloadProgress == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-download-progress" + GetHashCode(), (progressInfo) =>
|
||||
{
|
||||
_downloadProgress(JObject.Parse(progressInfo.ToString()).ToObject<ProgressInfo>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-download-progress-event", GetHashCode());
|
||||
}
|
||||
_downloadProgress += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_downloadProgress -= value;
|
||||
|
||||
if (_downloadProgress == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-download-progress" + GetHashCode());
|
||||
}
|
||||
}
|
||||
|
||||
private event Action<ProgressInfo> _downloadProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted on download complete.
|
||||
/// </summary>
|
||||
public event Action<UpdateInfo> OnUpdateDownloaded
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_updateDownloaded == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-update-downloaded" + GetHashCode(), (updateInfo) =>
|
||||
{
|
||||
_updateDownloaded(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-update-downloaded-event", GetHashCode());
|
||||
}
|
||||
_updateDownloaded += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_updateDownloaded -= value;
|
||||
|
||||
if (_updateDownloaded == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-update-downloaded" + GetHashCode());
|
||||
}
|
||||
}
|
||||
|
||||
private event Action<UpdateInfo> _updateDownloaded;
|
||||
|
||||
private static AutoUpdater _autoUpdater;
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal AutoUpdater() { }
|
||||
|
||||
internal static AutoUpdater Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_autoUpdater == null)
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if (_autoUpdater == null)
|
||||
{
|
||||
_autoUpdater = new AutoUpdater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _autoUpdater;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asks the server whether there is an update.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<UpdateCheckResult> CheckForUpdatesAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<UpdateCheckResult>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesComplete" + guid, (updateCheckResult) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
|
||||
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdates", guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asks the server whether there is an update.
|
||||
///
|
||||
/// This will immediately download an update, then install when the app quits.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<UpdateCheckResult> CheckForUpdatesAndNotifyAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<UpdateCheckResult>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid, (updateCheckResult) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
|
||||
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdatesAndNotify", guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restarts the app and installs the update after it has been downloaded.
|
||||
/// It should only be called after `update-downloaded` has been emitted.
|
||||
///
|
||||
/// Note: QuitAndInstall() will close all application windows first and only emit `before-quit` event on `app` after that.
|
||||
/// This is different from the normal quit event sequence.
|
||||
/// </summary>
|
||||
/// <param name="isSilent">*windows-only* Runs the installer in silent mode. Defaults to `false`.</param>
|
||||
/// <param name="isForceRunAfter">Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.</param>
|
||||
public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start downloading update manually. You can use this method if "AutoDownload" option is set to "false".
|
||||
/// </summary>
|
||||
/// <returns>Path to downloaded file.</returns>
|
||||
public Task<string> DownloadUpdateAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPath) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterDownloadUpdateComplete" + guid);
|
||||
taskCompletionSource.SetResult(downloadedPath.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdaterDownloadUpdate", guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Feed URL.
|
||||
/// </summary>
|
||||
/// <returns>Feed URL.</returns>
|
||||
public Task<string> GetFeedURLAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterGetFeedURLComplete" + guid, (downloadedPath) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterGetFeedURLComplete" + guid);
|
||||
taskCompletionSource.SetResult(downloadedPath.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdaterGetFeedURL", guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace ElectronNET.API
|
||||
internal static class BridgeConnector
|
||||
{
|
||||
private static Socket _socket;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
public static Socket Socket
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -1657,6 +1658,13 @@ namespace ElectronNET.API
|
||||
/// <param name="y"></param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
// Workaround Windows 10 / Electron Bug
|
||||
// https://github.com/electron/electron/issues/4045
|
||||
if (isWindows10())
|
||||
{
|
||||
x = x - 7;
|
||||
}
|
||||
|
||||
BridgeConnector.Socket.Emit("browserWindowSetPosition", Id, x, y);
|
||||
}
|
||||
|
||||
@@ -1668,9 +1676,21 @@ namespace ElectronNET.API
|
||||
/// <param name="animate"></param>
|
||||
public void SetPosition(int x, int y, bool animate)
|
||||
{
|
||||
// Workaround Windows 10 / Electron Bug
|
||||
// https://github.com/electron/electron/issues/4045
|
||||
if (isWindows10())
|
||||
{
|
||||
x = x - 7;
|
||||
}
|
||||
|
||||
BridgeConnector.Socket.Emit("browserWindowSetPosition", Id, x, y, animate);
|
||||
}
|
||||
|
||||
private bool isWindows10()
|
||||
{
|
||||
return RuntimeInformation.OSDescription.Contains("Windows 10");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains the window’s current position.
|
||||
/// </summary>
|
||||
@@ -1909,7 +1929,7 @@ namespace ElectronNET.API
|
||||
public void SetMenu(MenuItem[] menuItems)
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
BridgeConnector.Socket.Emit("browserWindowSetMenu", JArray.FromObject(menuItems, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("browserWindowSetMenu", Id, JArray.FromObject(menuItems, _jsonSerializer));
|
||||
_items.AddRange(menuItems);
|
||||
|
||||
BridgeConnector.Socket.Off("windowMenuItemClicked");
|
||||
@@ -1919,6 +1939,14 @@ namespace ElectronNET.API
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the window's menu bar.
|
||||
/// </summary>
|
||||
public void RemoveMenu()
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserWindowRemoveMenu", Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets progress value in progress bar. Valid range is [0, 1.0]. Remove progress
|
||||
/// bar when progress smaler as 0; Change to indeterminate mode when progress bigger as 1. On Linux
|
||||
@@ -1930,7 +1958,7 @@ namespace ElectronNET.API
|
||||
/// assumed.
|
||||
/// </summary>
|
||||
/// <param name="progress"></param>
|
||||
public void SetProgressBar(int progress)
|
||||
public void SetProgressBar(double progress)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserWindowSetProgressBar", Id, progress);
|
||||
}
|
||||
@@ -1947,7 +1975,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="progress"></param>
|
||||
/// <param name="progressBarOptions"></param>
|
||||
public void SetProgressBar(int progress, ProgressBarOptions progressBarOptions)
|
||||
public void SetProgressBar(double progress, ProgressBarOptions progressBarOptions)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserWindowSetProgressBar", Id, progress, JObject.FromObject(progressBarOptions, _jsonSerializer));
|
||||
}
|
||||
@@ -2282,5 +2310,58 @@ namespace ElectronNET.API
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Adds Chrome extension located at path, and returns extension's name.
|
||||
/// The method will also not return if the extension's manifest is missing or incomplete.
|
||||
/// Note: This API cannot be called before the ready event of the app module is emitted.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to the Chrome extension</param>
|
||||
/// <returns></returns>
|
||||
public static Task<string> AddExtensionAsync(string path)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("browserWindow-addExtension-completed", (extensionname) => {
|
||||
BridgeConnector.Socket.Off("browserWindow-addExtension-completed");
|
||||
|
||||
taskCompletionSource.SetResult(extensionname.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("browserWindowAddExtension", path);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Chrome extension with the specified name.
|
||||
/// Note: This API cannot be called before the ready event of the app module is emitted.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the Chrome extension to remove</param>
|
||||
public static void RemoveExtension(string name)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserWindowRemoveExtension", name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The keys are the extension names and each value is an object containing name and version properties.
|
||||
/// Note: This API cannot be called before the ready event of the app module is emitted.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Task<ChromeExtensionInfo[]> GetExtensionsAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<ChromeExtensionInfo[]>();
|
||||
|
||||
BridgeConnector.Socket.On("browserWindow-getExtensions-completed", (extensionslist) => {
|
||||
BridgeConnector.Socket.Off("browserWindow-getExtensions-completed");
|
||||
var chromeExtensionInfos = ((JArray)extensionslist).ToObject<ChromeExtensionInfo[]>();
|
||||
|
||||
taskCompletionSource.SetResult(chromeExtensionInfos);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("browserWindowGetExtensions");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -13,7 +12,7 @@ namespace ElectronNET.API
|
||||
public sealed class Clipboard
|
||||
{
|
||||
private static Clipboard _clipboard;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal Clipboard() { }
|
||||
|
||||
|
||||
116
ElectronNET.API/CommandLine.cs
Normal file
116
ElectronNET.API/CommandLine.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
/// Manipulate the command line arguments for your app that Chromium reads.
|
||||
/// </summary>
|
||||
public sealed class CommandLine
|
||||
{
|
||||
internal CommandLine() { }
|
||||
|
||||
internal static CommandLine Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_commandLine == null)
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if (_commandLine == null)
|
||||
{
|
||||
_commandLine = new CommandLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _commandLine;
|
||||
}
|
||||
}
|
||||
|
||||
private static CommandLine _commandLine;
|
||||
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Append a switch (with optional value) to Chromium's command line.
|
||||
/// </summary>
|
||||
/// <param name="the_switch">A command-line switch, without the leading --</param>
|
||||
/// <param name="value">(optional) - A value for the given switch</param>
|
||||
/// <remarks>
|
||||
/// Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.
|
||||
/// </remarks>
|
||||
public void AppendSwitch(string the_switch, string value = "")
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appCommandLineAppendSwitch", the_switch, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append an argument to Chromium's command line. The argument will be quoted correctly. Switches will precede arguments regardless of appending order.
|
||||
///
|
||||
/// If you're appending an argument like <code>--switch=value</code>, consider using <code>appendSwitch('switch', 'value')</code> instead.
|
||||
/// </summary>
|
||||
/// <param name="value">The argument to append to the command line</param>
|
||||
/// <remarks>
|
||||
/// Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.
|
||||
/// </remarks>
|
||||
public void AppendArgument(string value)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appCommandLineAppendArgument", value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the command-line switch is present.
|
||||
/// </summary>
|
||||
/// <param name="switchName">A command-line switch</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>Whether the command-line switch is present.</returns>
|
||||
public async Task<bool> HasSwitchAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appCommandLineHasSwitchCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appCommandLineHasSwitchCompleted");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appCommandLineHasSwitch", switchName);
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The command-line switch value.
|
||||
/// </summary>
|
||||
/// <param name="switchName">A command-line switch</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>The command-line switch value.</returns>
|
||||
/// <remarks>
|
||||
/// Note: When the switch is not present or has no value, it returns empty string.
|
||||
/// </remarks>
|
||||
public async Task<string> GetSwitchValueAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appCommandLineGetSwitchValueCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appCommandLineGetSwitchValueCompleted");
|
||||
taskCompletionSource.SetResult((string)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appCommandLineGetSwitchValue", switchName);
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace ElectronNET.API
|
||||
public sealed class Dialog
|
||||
{
|
||||
private static Dialog _dialog;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal Dialog() { }
|
||||
|
||||
@@ -67,8 +67,7 @@ namespace ElectronNET.API
|
||||
|
||||
BridgeConnector.Socket.Emit("showOpenDialog",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(options, _jsonSerializer),
|
||||
guid);
|
||||
JObject.FromObject(options, _jsonSerializer), guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
/// </summary>
|
||||
public static App App { get { return App.Instance; } }
|
||||
|
||||
/// <summary>
|
||||
/// Enable apps to automatically update themselves. Based on electron-updater.
|
||||
/// </summary>
|
||||
public static AutoUpdater AutoUpdater { get { return AutoUpdater.Instance; } }
|
||||
|
||||
/// <summary>
|
||||
/// Control your windows.
|
||||
/// </summary>
|
||||
@@ -59,5 +64,14 @@
|
||||
/// Perform copy and paste operations on the system clipboard.
|
||||
/// </summary>
|
||||
public static Clipboard Clipboard { get { return Clipboard.Instance; } }
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to execute native JavaScript/TypeScript code from the host process.
|
||||
///
|
||||
/// It is only possible if the Electron.NET CLI has previously added an
|
||||
/// ElectronHostHook directory:
|
||||
/// <c>electronize add HostHook</c>
|
||||
/// </summary>
|
||||
public static HostHook HostHook { get { return HostHook.Instance; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageOutputPath>..\artifacts</PackageOutputPath>
|
||||
<PackageId>ElectronNET.API</PackageId>
|
||||
@@ -10,29 +10,21 @@
|
||||
<Product>Electron.NET</Product>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageProjectUrl>https://github.com/ElectronNET/Electron.NET/</PackageProjectUrl>
|
||||
<Description>Building cross platform electron based desktop apps with .NET Core and ASP.NET NET Core.
|
||||
<Description>Building cross platform electron based desktop apps with .NET Core and ASP.NET Core.
|
||||
This package contains the API to access the "native" electron API.</Description>
|
||||
<RepositoryUrl>https://github.com/ElectronNET/Electron.NET/</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<PackageTags>electron aspnetcore</PackageTags>
|
||||
<PackageReleaseNotes>Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md</PackageReleaseNotes>
|
||||
<PackageIconUrl>https://raw.githubusercontent.com/ElectronNET/Electron.NET/master/assets/images/electron.net-logo-square.png</PackageIconUrl>
|
||||
<Version>1.0.0.0</Version>
|
||||
<PackageIcon>PackageIcon.png</PackageIcon>
|
||||
<Version>99.0.0.0</Version>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>bin\Debug\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DocumentationFile>bin\Release\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>bin\Debug\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="PackageIcon.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
|
||||
<Exec Command="$(ProjectDir)devCleanup.cmd" IgnoreExitCode="true" />
|
||||
@@ -41,8 +33,10 @@ This package contains the API to access the "native" electron API.</Description>
|
||||
<Exec Command="$(ProjectDir)devCleanup.sh" IgnoreExitCode="true" />
|
||||
</Target>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05">
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
35
ElectronNET.API/Entities/BlockMapDataHolder.cs
Normal file
35
ElectronNET.API/Entities/BlockMapDataHolder.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class BlockMapDataHolder
|
||||
{
|
||||
/// <summary>
|
||||
/// The file size. Used to verify downloaded size (save one HTTP request to get length).
|
||||
/// Also used when block map data is embedded into the file(appimage, windows web installer package).
|
||||
/// </summary>
|
||||
public double Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The block map file size. Used when block map data is embedded into the file (appimage, windows web installer package).
|
||||
/// This information can be obtained from the file itself, but it requires additional HTTP request,
|
||||
/// so, to reduce request count, block map size is specified in the update metadata too.
|
||||
/// </summary>
|
||||
public double BlockMapSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The file checksum.
|
||||
/// </summary>
|
||||
public string Sha512 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool IsAdminRightsRequired { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -12,24 +12,24 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// Window's width in pixels. Default is 800.
|
||||
/// </summary>
|
||||
public int Width { get; set; }
|
||||
public int Width { get; set; } = 800;
|
||||
|
||||
/// <summary>
|
||||
/// Window's height in pixels. Default is 600.
|
||||
/// </summary>
|
||||
public int Height { get; set; }
|
||||
public int Height { get; set; } = 600;
|
||||
|
||||
/// <summary>
|
||||
/// ( if y is used) Window's left offset from screen. Default is to center the
|
||||
/// window.
|
||||
/// </summary>
|
||||
public int X { get; set; }
|
||||
public int X { get; set; } = -1;
|
||||
|
||||
/// <summary>
|
||||
/// ( if x is used) Window's top offset from screen. Default is to center the
|
||||
/// window.
|
||||
/// </summary>
|
||||
public int Y { get; set; }
|
||||
public int Y { get; set; } = -1;
|
||||
|
||||
/// <summary>
|
||||
/// The width and height would be used as web page's size, which means the actual
|
||||
|
||||
33
ElectronNET.API/Entities/ChromeExtensionInfo.cs
Normal file
33
ElectronNET.API/Entities/ChromeExtensionInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Provide metadata about the current loaded Chrome extension
|
||||
/// </summary>
|
||||
public class ChromeExtensionInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChromeExtensionInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the Chrome extension.</param>
|
||||
/// <param name="version">The version of the Chrome extension.</param>
|
||||
public ChromeExtensionInfo(string name, string version)
|
||||
{
|
||||
Name = name;
|
||||
Version = version;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the Chrome extension
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Version of the Chrome extension
|
||||
/// </summary>
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
||||
24
ElectronNET.API/Entities/ClearStorageDataOptions.cs
Normal file
24
ElectronNET.API/Entities/ClearStorageDataOptions.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ClearStorageDataOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Should follow window.location.origin’s representation scheme://host:port.
|
||||
/// </summary>
|
||||
public string Origin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The types of storages to clear, can contain: appcache, cookies, filesystem,
|
||||
/// indexdb, localstorage, shadercache, websql, serviceworkers, cachestorage.
|
||||
/// </summary>
|
||||
public string[] Storages { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The types of quotas to clear, can contain: temporary, persistent, syncable.
|
||||
/// </summary>
|
||||
public string[] Quotas { get; set; }
|
||||
}
|
||||
}
|
||||
67
ElectronNET.API/Entities/CreateInterruptedDownloadOptions.cs
Normal file
67
ElectronNET.API/Entities/CreateInterruptedDownloadOptions.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CreateInterruptedDownloadOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Absolute path of the download.
|
||||
/// </summary>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Complete URL chain for the download.
|
||||
/// </summary>
|
||||
public string[] UrlChain { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string MimeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Start range for the download.
|
||||
/// </summary>
|
||||
public int Offset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total length of the download.
|
||||
/// </summary>
|
||||
public int Length { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Last-Modified header value.
|
||||
/// </summary>
|
||||
public string LastModified { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ETag header value.
|
||||
/// </summary>
|
||||
public string ETag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time when download was started in number of seconds since UNIX epoch.
|
||||
/// </summary>
|
||||
public int StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="path">Absolute path of the download.</param>
|
||||
/// <param name="urlChain">Complete URL chain for the download.</param>
|
||||
/// <param name="offset">Start range for the download.</param>
|
||||
/// <param name="length">Total length of the download.</param>
|
||||
/// <param name="lastModified">Last-Modified header value.</param>
|
||||
/// <param name="eTag">ETag header value.</param>
|
||||
public CreateInterruptedDownloadOptions(string path, string[] urlChain, int offset, int length, string lastModified, string eTag)
|
||||
{
|
||||
Path = path;
|
||||
UrlChain = urlChain;
|
||||
Offset = offset;
|
||||
Length = length;
|
||||
LastModified = lastModified;
|
||||
ETag = eTag;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
ElectronNET.API/Entities/EnableNetworkEmulationOptions.cs
Normal file
28
ElectronNET.API/Entities/EnableNetworkEmulationOptions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class EnableNetworkEmulationOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether to emulate network outage. Defaults to false.
|
||||
/// </summary>
|
||||
public bool Offline { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// RTT in ms. Defaults to 0 which will disable latency throttling.
|
||||
/// </summary>
|
||||
public int Latency { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Download rate in Bps. Defaults to 0 which will disable download throttling.
|
||||
/// </summary>
|
||||
public int DownloadThroughput { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Upload rate in Bps. Defaults to 0 which will disable upload throttling.
|
||||
/// </summary>
|
||||
public int UploadThroughput { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public enum HighlightMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Highlight the tray icon when it is clicked and also when its context menu is open. This is the default.
|
||||
/// </summary>
|
||||
selection,
|
||||
|
||||
/// <summary>
|
||||
/// Always highlight the tray icon.
|
||||
/// </summary>
|
||||
always,
|
||||
|
||||
/// <summary>
|
||||
/// Never highlight the tray icon.
|
||||
/// </summary>
|
||||
never,
|
||||
|
||||
/// <summary>
|
||||
/// Activate highlight the tray icon.
|
||||
/// </summary>
|
||||
on,
|
||||
|
||||
/// <summary>
|
||||
/// Deactivate highlight the tray icon.
|
||||
/// </summary>
|
||||
off
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -68,12 +69,14 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// If false, the menu item will be greyed out and unclickable.
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; }
|
||||
[DefaultValue(true)]
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// If false, the menu item will be entirely hidden.
|
||||
/// </summary>
|
||||
public bool Visible { get; set; }
|
||||
[DefaultValue(true)]
|
||||
public bool Visible { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Should only be specified for checkbox or radio type menu items.
|
||||
|
||||
37
ElectronNET.API/Entities/ProgressInfo.cs
Normal file
37
ElectronNET.API/Entities/ProgressInfo.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ProgressInfo
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Progress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string BytesPerSecond { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Percent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Total { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Transferred { get; set; }
|
||||
}
|
||||
}
|
||||
36
ElectronNET.API/Entities/ProxyConfig.cs
Normal file
36
ElectronNET.API/Entities/ProxyConfig.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ProxyConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// The URL associated with the PAC file.
|
||||
/// </summary>
|
||||
public string PacScript { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Rules indicating which proxies to use.
|
||||
/// </summary>
|
||||
public string ProxyRules { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Rules indicating which URLs should bypass the proxy settings.
|
||||
/// </summary>
|
||||
public string ProxyBypassRules { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="pacScript">The URL associated with the PAC file.</param>
|
||||
/// <param name="proxyRules">Rules indicating which proxies to use.</param>
|
||||
/// <param name="proxyBypassRules">Rules indicating which URLs should bypass the proxy settings.</param>
|
||||
public ProxyConfig(string pacScript, string proxyRules, string proxyBypassRules)
|
||||
{
|
||||
PacScript = pacScript;
|
||||
ProxyRules = proxyRules;
|
||||
ProxyBypassRules = proxyBypassRules;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
ElectronNET.API/Entities/ReleaseNoteInfo.cs
Normal file
18
ElectronNET.API/Entities/ReleaseNoteInfo.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReleaseNoteInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The version.
|
||||
/// </summary>
|
||||
public string Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The note.
|
||||
/// </summary>
|
||||
public string Note { get; set; }
|
||||
}
|
||||
}
|
||||
31
ElectronNET.API/Entities/RemoveClientCertificate.cs
Normal file
31
ElectronNET.API/Entities/RemoveClientCertificate.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class RemoveClientCertificate
|
||||
{
|
||||
/// <summary>
|
||||
/// Origin of the server whose associated client certificate must be removed from
|
||||
/// the cache.
|
||||
/// </summary>
|
||||
public string Origin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// clientCertificate.
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="origin">Origin of the server whose associated client certificate
|
||||
/// must be removed from the cache.</param>
|
||||
/// <param name="type">clientCertificate.</param>
|
||||
public RemoveClientCertificate(string origin, string type)
|
||||
{
|
||||
Origin = origin;
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
ElectronNET.API/Entities/RemovePassword.cs
Normal file
53
ElectronNET.API/Entities/RemovePassword.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class RemovePassword
|
||||
{
|
||||
/// <summary>
|
||||
/// When provided, the authentication info related to the origin will only be
|
||||
/// removed otherwise the entire cache will be cleared.
|
||||
/// </summary>
|
||||
public string Origin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Credentials of the authentication. Must be provided if removing by origin.
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Realm of the authentication. Must be provided if removing by origin.
|
||||
/// </summary>
|
||||
public string Realm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Scheme of the authentication. Can be basic, digest, ntlm, negotiate.
|
||||
/// Must be provided if removing by origin.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public Scheme Scheme { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// password.
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Credentials of the authentication. Must be provided if removing by origin.
|
||||
/// </summary>
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type">password.</param>
|
||||
public RemovePassword(string type)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
ElectronNET.API/Entities/Scheme.cs
Normal file
28
ElectronNET.API/Entities/Scheme.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public enum Scheme
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
basic,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
digest,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
ntlm,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
negotiate
|
||||
}
|
||||
}
|
||||
29
ElectronNET.API/Entities/UpdateCancellationToken.cs
Normal file
29
ElectronNET.API/Entities/UpdateCancellationToken.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class UpdateCancellationToken
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool Cancelled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
23
ElectronNET.API/Entities/UpdateCheckResult.cs
Normal file
23
ElectronNET.API/Entities/UpdateCheckResult.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class UpdateCheckResult
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public UpdateInfo UpdateInfo { get; set; } = new UpdateInfo();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string[] Download { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public UpdateCancellationToken CancellationToken { get; set; }
|
||||
}
|
||||
}
|
||||
13
ElectronNET.API/Entities/UpdateFileInfo.cs
Normal file
13
ElectronNET.API/Entities/UpdateFileInfo.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class UpdateFileInfo : BlockMapDataHolder
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
}
|
||||
}
|
||||
38
ElectronNET.API/Entities/UpdateInfo.cs
Normal file
38
ElectronNET.API/Entities/UpdateInfo.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class UpdateInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The version.
|
||||
/// </summary>
|
||||
public string Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public UpdateFileInfo[] Files { get; set; } = new UpdateFileInfo[0];
|
||||
|
||||
/// <summary>
|
||||
/// The release name.
|
||||
/// </summary>
|
||||
public string ReleaseName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The release notes.
|
||||
/// </summary>
|
||||
public ReleaseNoteInfo[] ReleaseNotes { get; set; } = new ReleaseNoteInfo[0];
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ReleaseDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The staged rollout percentage, 0-100.
|
||||
/// </summary>
|
||||
public int StagingPercentage { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace ElectronNET.API.Entities
|
||||
public bool DevTools { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether node integration is enabled. Default is true.
|
||||
/// Whether node integration is enabled. Required to enable IPC. Default is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true)]
|
||||
public bool NodeIntegration { get; set; } = true;
|
||||
@@ -185,7 +185,8 @@ namespace ElectronNET.API.Entities
|
||||
/// Context' entry in the combo box at the top of the Console tab. This option is
|
||||
/// currently experimental and may change or be removed in future Electron releases.
|
||||
/// </summary>
|
||||
public bool ContextIsolation { get; set; }
|
||||
[DefaultValue(true)]
|
||||
public bool ContextIsolation { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use native window.open(). Defaults to false. This option is currently experimental.
|
||||
@@ -203,6 +204,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <value>
|
||||
/// <c>true</c> if [webview tag]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool WebviewTag { get; set; }
|
||||
[DefaultValue(false)]
|
||||
public bool WebviewTag { get; set; } = false;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace ElectronNET.API
|
||||
public sealed class GlobalShortcut
|
||||
{
|
||||
private static GlobalShortcut _globalShortcut;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal GlobalShortcut() { }
|
||||
|
||||
|
||||
126
ElectronNET.API/HostHook.cs
Normal file
126
ElectronNET.API/HostHook.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows you to execute native JavaScript/TypeScript code from the host process.
|
||||
///
|
||||
/// It is only possible if the Electron.NET CLI has previously added an
|
||||
/// ElectronHostHook directory:
|
||||
/// <c>electronize add HostHook</c>
|
||||
/// </summary>
|
||||
public sealed class HostHook
|
||||
{
|
||||
private static HostHook _electronHostHook;
|
||||
private static object _syncRoot = new object();
|
||||
string oneCallguid = Guid.NewGuid().ToString();
|
||||
|
||||
internal HostHook() { }
|
||||
|
||||
internal static HostHook Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_electronHostHook == null)
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if (_electronHostHook == null)
|
||||
{
|
||||
_electronHostHook = new HostHook();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _electronHostHook;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute native JavaScript/TypeScript code.
|
||||
/// </summary>
|
||||
/// <param name="socketEventName">Socket name registered on the host.</param>
|
||||
/// <param name="arguments">Optional parameters.</param>
|
||||
public void Call(string socketEventName, params dynamic[] arguments)
|
||||
{
|
||||
BridgeConnector.Socket.On(socketEventName + "Error" + oneCallguid, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off(socketEventName + "Error" + oneCallguid);
|
||||
Electron.Dialog.ShowErrorBox("Host Hook Exception", result.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit(socketEventName, arguments, oneCallguid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute native JavaScript/TypeScript code.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Results from the executed host code.</typeparam>
|
||||
/// <param name="socketEventName">Socket name registered on the host.</param>
|
||||
/// <param name="arguments">Optional parameters.</param>
|
||||
/// <returns></returns>
|
||||
public Task<T> CallAsync<T>(string socketEventName, params dynamic[] arguments)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<T>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On(socketEventName + "Error" + guid, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off(socketEventName + "Error" + guid);
|
||||
Electron.Dialog.ShowErrorBox("Host Hook Exception", result.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.On(socketEventName + "Complete" + guid, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off(socketEventName + "Error" + guid);
|
||||
BridgeConnector.Socket.Off(socketEventName + "Complete" + guid);
|
||||
T data;
|
||||
|
||||
try
|
||||
{
|
||||
if (result.GetType().IsValueType || result is string)
|
||||
{
|
||||
data = (T)result;
|
||||
}
|
||||
else
|
||||
{
|
||||
var token = JToken.Parse(result.ToString());
|
||||
if (token is JArray)
|
||||
{
|
||||
data = token.ToObject<T>();
|
||||
}
|
||||
else if (token is JObject)
|
||||
{
|
||||
data = token.ToObject<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
data = (T)result;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new InvalidCastException("Return value does not match with the generic type.", exception);
|
||||
}
|
||||
|
||||
taskCompletionSource.SetResult(data);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit(socketEventName, arguments, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace ElectronNET.API
|
||||
public sealed class IpcMain
|
||||
{
|
||||
private static IpcMain _ipcMain;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal IpcMain() { }
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
List<JObject> jobjects = new List<JObject>();
|
||||
List<JArray> jarrays = new List<JArray>();
|
||||
List<Object> objects = new List<Object>();
|
||||
List<object> objects = new List<object>();
|
||||
|
||||
foreach (var parameterObject in data)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||
using ElectronNET.API.Extensions;
|
||||
using System.Linq;
|
||||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -16,7 +15,7 @@ namespace ElectronNET.API
|
||||
public sealed class Menu
|
||||
{
|
||||
private static Menu _menu;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal Menu() { }
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ElectronNET.API
|
||||
public sealed class Notification
|
||||
{
|
||||
private static Notification _notification;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal Notification() { }
|
||||
|
||||
|
||||
BIN
ElectronNET.API/PackageIcon.png
Normal file
BIN
ElectronNET.API/PackageIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
@@ -105,7 +105,7 @@ namespace ElectronNET.API
|
||||
private event Action<Display, string[]> _onDisplayMetricsChanged;
|
||||
|
||||
private static Screen _screen;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal Screen() { }
|
||||
|
||||
|
||||
380
ElectronNET.API/Session.cs
Normal file
380
ElectronNET.API/Session.cs
Normal file
@@ -0,0 +1,380 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
/// Manage browser sessions, cookies, cache, proxy settings, etc.
|
||||
/// </summary>
|
||||
public class Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the identifier.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The identifier.
|
||||
/// </value>
|
||||
public int Id { get; private set; }
|
||||
|
||||
internal Session(int id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication.
|
||||
/// </summary>
|
||||
/// <param name="domains">A comma-separated list of servers for which integrated authentication is enabled.</param>
|
||||
public void AllowNTLMCredentialsForDomains(string domains)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-allowNTLMCredentialsForDomains", Id, domains);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the session’s HTTP authentication cache.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public Task ClearAuthCacheAsync(RemovePassword options)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<object>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-clearAuthCache-completed" + guid, () =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-clearAuthCache-completed" + guid);
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, JObject.FromObject(options, _jsonSerializer), guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the session’s HTTP authentication cache.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
public Task ClearAuthCacheAsync(RemoveClientCertificate options)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<object>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-clearAuthCache-completed" + guid, () =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-clearAuthCache-completed" + guid);
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, JObject.FromObject(options, _jsonSerializer), guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the session’s HTTP cache.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task ClearCacheAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<object>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-clearCache-completed" + guid, () =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-clearCache-completed" + guid);
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearCache", Id, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the host resolver cache.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task ClearHostResolverCacheAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<object>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-clearHostResolverCache-completed" + guid, () =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-clearHostResolverCache-completed" + guid);
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearHostResolverCache", Id, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the data of web storages.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task ClearStorageDataAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<object>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-clearStorageData-completed" + guid, () =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-clearStorageData-completed" + guid);
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearStorageData", Id, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the data of web storages.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public Task ClearStorageDataAsync(ClearStorageDataOptions options)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<object>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-clearStorageData-options-completed" + guid, () =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-clearStorageData-options-completed" + guid);
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-clearStorageData-options", Id, JObject.FromObject(options, _jsonSerializer), guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows resuming cancelled or interrupted downloads from previous Session. The
|
||||
/// API will generate a DownloadItem that can be accessed with the will-download
|
||||
/// event. The DownloadItem will not have any WebContents associated with it and the
|
||||
/// initial state will be interrupted. The download will start only when the resume
|
||||
/// API is called on the DownloadItem.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
public void CreateInterruptedDownload(CreateInterruptedDownloadOptions options)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-createInterruptedDownload", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables any network emulation already active for the session. Resets to the
|
||||
/// original network configuration.
|
||||
/// </summary>
|
||||
public void DisableNetworkEmulation()
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-disableNetworkEmulation", Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Emulates network with the given configuration for the session.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
public void EnableNetworkEmulation(EnableNetworkEmulationOptions options)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-enableNetworkEmulation", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes any unwritten DOMStorage data to disk.
|
||||
/// </summary>
|
||||
public void FlushStorageData()
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-flushStorageData", Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetBlobDataAsync(string identifier)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<int[]>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-getBlobData-completed" + guid, (buffer) =>
|
||||
{
|
||||
var result = ((JArray)buffer).ToObject<int[]>();
|
||||
|
||||
BridgeConnector.Socket.Off("webContents-session-getBlobData-completed" + guid);
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-getBlobData", Id, identifier, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get session's current cache size.
|
||||
/// </summary>
|
||||
/// <returns>Callback is invoked with the session's current cache size.</returns>
|
||||
public Task<int> GetCacheSizeAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<int>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-getCacheSize-completed" + guid, (size) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-getCacheSize-completed" + guid);
|
||||
taskCompletionSource.SetResult((int)size);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-getCacheSize", Id, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<string[]> GetPreloadsAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string[]>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-getPreloads-completed" + guid, (preloads) =>
|
||||
{
|
||||
var result = ((JArray)preloads).ToObject<string[]>();
|
||||
BridgeConnector.Socket.Off("webContents-session-getPreloads-completed" + guid);
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-getPreloads", Id, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<string> GetUserAgent()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-getUserAgent-completed" + guid, (userAgent) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-getUserAgent-completed" + guid);
|
||||
taskCompletionSource.SetResult(userAgent.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-getUserAgent", Id, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the proxy information for url. The callback will be called with
|
||||
/// callback(proxy) when the request is performed.
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> ResolveProxyAsync(string url)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-resolveProxy-completed" + guid, (proxy) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-resolveProxy-completed" + guid);
|
||||
taskCompletionSource.SetResult(proxy.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-resolveProxy", Id, url, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets download saving directory. By default, the download directory will be the
|
||||
/// Downloads under the respective app folder.
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
public void SetDownloadPath(string path)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-setDownloadPath", Id, path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds scripts that will be executed on ALL web contents that are associated with
|
||||
/// this session just before normal preload scripts run.
|
||||
/// </summary>
|
||||
/// <param name="preloads"></param>
|
||||
public void SetPreloads(string[] preloads)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-setPreloads", Id, preloads);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the proxy settings. When pacScript and proxyRules are provided together,
|
||||
/// the proxyRules option is ignored and pacScript configuration is applied.
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public Task SetProxyAsync(ProxyConfig config)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<object>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-session-setProxy-completed" + guid, () =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-session-setProxy-completed" + guid);
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-session-setProxy", Id, JObject.FromObject(config, _jsonSerializer), guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the userAgent for this session. This doesn't affect existing WebContents, and
|
||||
/// each WebContents can use webContents.setUserAgent to override the session-wide
|
||||
/// user agent.
|
||||
/// </summary>
|
||||
/// <param name="userAgent"></param>
|
||||
public void SetUserAgent(string userAgent)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-setUserAgent", Id, userAgent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the userAgent and acceptLanguages for this session. The
|
||||
/// acceptLanguages must a comma separated ordered list of language codes, for
|
||||
/// example "en-US,fr,de,ko,zh-CN,ja". This doesn't affect existing WebContents, and
|
||||
/// each WebContents can use webContents.setUserAgent to override the session-wide
|
||||
/// user agent.
|
||||
/// </summary>
|
||||
/// <param name="userAgent"></param>
|
||||
/// <param name="acceptLanguages">The
|
||||
/// acceptLanguages must a comma separated ordered list of language codes, for
|
||||
/// example "en-US,fr,de,ko,zh-CN,ja".</param>
|
||||
public void SetUserAgent(string userAgent, string acceptLanguages)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-session-setUserAgent", Id, userAgent, acceptLanguages);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace ElectronNET.API
|
||||
public sealed class Shell
|
||||
{
|
||||
private static Shell _shell;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal Shell() { }
|
||||
|
||||
@@ -132,10 +132,10 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="options">macOS only</param>
|
||||
/// <param name="action">macOS only</param>
|
||||
/// <param name="errorAction">Action to get the error message.</param>
|
||||
/// <returns>Whether an application was available to open the URL.
|
||||
/// If callback is specified, always returns true.</returns>
|
||||
public Task<bool> OpenExternalAsync(string url, OpenExternalOptions options, Action<Error> action)
|
||||
public Task<bool> OpenExternalAsync(string url, OpenExternalOptions options, Action<Error> errorAction)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace ElectronNET.API
|
||||
}
|
||||
});
|
||||
|
||||
_openExternalCallbacks.Add(url, action);
|
||||
_openExternalCallbacks.Add(url, errorAction);
|
||||
|
||||
BridgeConnector.Socket.Emit("shell-openExternal", url, JObject.FromObject(options, _jsonSerializer), true);
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace ElectronNET.API
|
||||
// TODO: Implement macOS Events
|
||||
|
||||
private static Tray _tray;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal Tray() { }
|
||||
|
||||
@@ -307,18 +307,6 @@ namespace ElectronNET.API
|
||||
BridgeConnector.Socket.Emit("tray-setTitle", title);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// macOS: Sets when the tray’s icon background becomes highlighted (in blue).
|
||||
///
|
||||
/// Note: You can use highlightMode with a BrowserWindow by toggling between
|
||||
/// 'never' and 'always' modes when the window visibility changes.
|
||||
/// </summary>
|
||||
/// <param name="highlightMode"></param>
|
||||
public void SetHighlightMode(HighlightMode highlightMode)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("tray-setHighlightMode", highlightMode.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Windows: Displays a tray balloon.
|
||||
/// </summary>
|
||||
|
||||
@@ -20,6 +20,11 @@ namespace ElectronNET.API
|
||||
/// </value>
|
||||
public int Id { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Manage browser sessions, cookies, cache, proxy settings, etc.
|
||||
/// </summary>
|
||||
public Session Session { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when the renderer process crashes or is killed.
|
||||
/// </summary>
|
||||
@@ -82,6 +87,7 @@ namespace ElectronNET.API
|
||||
internal WebContents(int id)
|
||||
{
|
||||
Id = id;
|
||||
Session = new Session(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ElectronNET.API
|
||||
if(HybridSupport.IsElectronActive)
|
||||
{
|
||||
builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory)
|
||||
.UseUrls("http://0.0.0.0:" + BridgeSettings.WebPort);
|
||||
.UseUrls("http://127.0.0.1:" + BridgeSettings.WebPort);
|
||||
}
|
||||
|
||||
return builder;
|
||||
|
||||
@@ -5,6 +5,7 @@ using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -15,7 +16,7 @@ namespace ElectronNET.API
|
||||
public sealed class WindowManager
|
||||
{
|
||||
private static WindowManager _windowManager;
|
||||
private static object _syncRoot = new Object();
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal WindowManager() { }
|
||||
|
||||
@@ -114,11 +115,46 @@ namespace ElectronNET.API
|
||||
loadUrl = $"{loadUrl}:{BridgeSettings.WebPort}";
|
||||
}
|
||||
|
||||
BridgeConnector.Socket.Emit("createBrowserWindow", JObject.FromObject(options, _jsonSerializer), loadUrl);
|
||||
// Workaround Windows 10 / Electron Bug
|
||||
// https://github.com/electron/electron/issues/4045
|
||||
if (isWindows10())
|
||||
{
|
||||
options.Width = options.Width + 14;
|
||||
options.Height = options.Height + 7;
|
||||
}
|
||||
|
||||
if (options.X == -1 && options.Y == -1)
|
||||
{
|
||||
options.X = 0;
|
||||
options.Y = 0;
|
||||
|
||||
BridgeConnector.Socket.Emit("createBrowserWindow", JObject.FromObject(options, _jsonSerializer), loadUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Workaround Windows 10 / Electron Bug
|
||||
// https://github.com/electron/electron/issues/4045
|
||||
if (isWindows10())
|
||||
{
|
||||
options.X = options.X - 7;
|
||||
}
|
||||
|
||||
var ownjsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
BridgeConnector.Socket.Emit("createBrowserWindow", JObject.FromObject(options, ownjsonSerializer), loadUrl);
|
||||
}
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private bool isWindows10()
|
||||
{
|
||||
return RuntimeInformation.OSDescription.Contains("Windows 10");
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace ElectronNET.CLI.Commands.Actions
|
||||
{
|
||||
@@ -11,7 +8,7 @@ namespace ElectronNET.CLI.Commands.Actions
|
||||
{
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(tempPath, "main.js");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(tempPath, "package.json");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(tempPath, "package-lock.json");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(tempPath, "build-helper.js");
|
||||
|
||||
string hostApiFolder = Path.Combine(tempPath, "api");
|
||||
if (Directory.Exists(hostApiFolder) == false)
|
||||
@@ -21,6 +18,7 @@ namespace ElectronNET.CLI.Commands.Actions
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "ipc.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "app.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "browserWindows.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "commandLine.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "dialog.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "menu.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "notification.js", "api.");
|
||||
@@ -30,6 +28,14 @@ namespace ElectronNET.CLI.Commands.Actions
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "shell.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "screen.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "clipboard.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "autoUpdater.js", "api.");
|
||||
|
||||
string splashscreenFolder = Path.Combine(tempPath, "splashscreen");
|
||||
if (Directory.Exists(splashscreenFolder) == false)
|
||||
{
|
||||
Directory.CreateDirectory(splashscreenFolder);
|
||||
}
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(splashscreenFolder, "index.html", "splashscreen.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
ElectronNET.CLI/Commands/Actions/DirectoryCopy.cs
Normal file
67
ElectronNET.CLI/Commands/Actions/DirectoryCopy.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace ElectronNET.CLI.Commands.Actions
|
||||
{
|
||||
public static class DirectoryCopy
|
||||
{
|
||||
public static void Do(string sourceDirName, string destDirName, bool copySubDirs, List<string> ignoredSubDirs)
|
||||
{
|
||||
// Get the subdirectories for the specified directory.
|
||||
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
|
||||
|
||||
if (!dir.Exists)
|
||||
{
|
||||
throw new DirectoryNotFoundException(
|
||||
"Source directory does not exist or could not be found: "
|
||||
+ sourceDirName);
|
||||
}
|
||||
|
||||
DirectoryInfo[] dirs = dir.GetDirectories();
|
||||
// If the destination directory doesn't exist, create it.
|
||||
if (!Directory.Exists(destDirName))
|
||||
{
|
||||
Directory.CreateDirectory(destDirName);
|
||||
}
|
||||
else
|
||||
{
|
||||
DirectoryInfo targetDir = new DirectoryInfo(destDirName);
|
||||
|
||||
foreach (FileInfo fileDel in targetDir.EnumerateFiles())
|
||||
{
|
||||
fileDel.Delete();
|
||||
}
|
||||
foreach (DirectoryInfo dirDel in targetDir.EnumerateDirectories())
|
||||
{
|
||||
dirDel.Delete(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Get the files in the directory and copy them to the new location.
|
||||
FileInfo[] files = dir.GetFiles();
|
||||
foreach (FileInfo file in files)
|
||||
{
|
||||
string temppath = Path.Combine(destDirName, file.Name);
|
||||
file.CopyTo(temppath, false);
|
||||
}
|
||||
|
||||
// If copying subdirectories, copy them and their contents to new location.
|
||||
if (copySubDirs)
|
||||
{
|
||||
foreach (DirectoryInfo subdir in dirs)
|
||||
{
|
||||
if (ignoredSubDirs.Contains(subdir.Name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string temppath = Path.Combine(destDirName, subdir.Name);
|
||||
Do(subdir.FullName, temppath, copySubDirs, ignoredSubDirs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.CLI.Commands.Actions
|
||||
{
|
||||
@@ -23,11 +21,11 @@ namespace ElectronNET.CLI.Commands.Actions
|
||||
{
|
||||
case "win":
|
||||
netCorePublishRid = "win-x64";
|
||||
electronPackerPlatform = "win32";
|
||||
electronPackerPlatform = "win";
|
||||
break;
|
||||
case "osx":
|
||||
netCorePublishRid = "osx-x64";
|
||||
electronPackerPlatform = "darwin";
|
||||
electronPackerPlatform = "mac";
|
||||
break;
|
||||
case "linux":
|
||||
netCorePublishRid = "linux-x64";
|
||||
@@ -45,13 +43,13 @@ namespace ElectronNET.CLI.Commands.Actions
|
||||
default:
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
netCorePublishRid = "win-x64";
|
||||
electronPackerPlatform = "win32";
|
||||
netCorePublishRid = $"win-x{(Environment.Is64BitOperatingSystem ? "64" : "86")}";
|
||||
electronPackerPlatform = "win";
|
||||
}
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
netCorePublishRid = "osx-x64";
|
||||
electronPackerPlatform = "darwin";
|
||||
electronPackerPlatform = "mac";
|
||||
}
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
|
||||
136
ElectronNET.CLI/Commands/AddCommand.cs
Normal file
136
ElectronNET.CLI/Commands/AddCommand.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ElectronNET.CLI.Commands
|
||||
{
|
||||
public class AddCommand : ICommand
|
||||
{
|
||||
public const string COMMAND_NAME = "add";
|
||||
public const string COMMAND_DESCRIPTION = "The add command needs to be invoked via 'add hosthook'. This creates a special folder for your custom npm package installation.";
|
||||
public const string COMMAND_ARGUMENTS = "hosthook";
|
||||
public static IList<CommandOption> CommandOptions { get; set; } = new List<CommandOption>();
|
||||
|
||||
|
||||
private string[] _args;
|
||||
|
||||
public AddCommand(string[] args)
|
||||
{
|
||||
_args = args;
|
||||
}
|
||||
|
||||
private static string ElectronHostHookFolderName = "ElectronHostHook";
|
||||
|
||||
public Task<bool> ExecuteAsync()
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
if(_args.Length == 0)
|
||||
{
|
||||
Console.WriteLine("Specify 'hosthook' to add custom npm packages.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_args[0].ToLowerInvariant() != "hosthook")
|
||||
{
|
||||
Console.WriteLine("Specify 'hosthook' to add custom npm packages.");
|
||||
return false;
|
||||
}
|
||||
|
||||
string aspCoreProjectPath = "";
|
||||
|
||||
// Maybe ToDo: Adding the possiblity to specify a path (like we did in the InitCommand, but this would require a better command args parser)
|
||||
aspCoreProjectPath = Directory.GetCurrentDirectory();
|
||||
|
||||
var currentDirectory = aspCoreProjectPath;
|
||||
|
||||
var targetFilePath = Path.Combine(currentDirectory, ElectronHostHookFolderName);
|
||||
|
||||
if(Directory.Exists(targetFilePath))
|
||||
{
|
||||
Console.WriteLine("ElectronHostHook directory already in place. If you want to start over, delete the folder and invoke this command again.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine("Adding the ElectronHostHook folder to your project...");
|
||||
|
||||
Directory.CreateDirectory(targetFilePath);
|
||||
|
||||
// Deploy related files
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(targetFilePath, "index.ts", "ElectronHostHook.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(targetFilePath, "connector.ts", "ElectronHostHook.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(targetFilePath, "package.json", "ElectronHostHook.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(targetFilePath, "tsconfig.json", "ElectronHostHook.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(targetFilePath, ".gitignore", "ElectronHostHook.");
|
||||
|
||||
// npm for typescript compiler etc.
|
||||
Console.WriteLine("Start npm install...");
|
||||
ProcessHelper.CmdExecute("npm install", targetFilePath);
|
||||
|
||||
// run typescript compiler
|
||||
// ToDo: Not sure if this runs under linux/macos
|
||||
ProcessHelper.CmdExecute(@"npx tsc -p ../../", targetFilePath);
|
||||
|
||||
// search .csproj
|
||||
Console.WriteLine($"Search your .csproj to add configure CopyToPublishDirectory to 'Never'");
|
||||
var projectFile = Directory.EnumerateFiles(currentDirectory, "*.csproj", SearchOption.TopDirectoryOnly).FirstOrDefault();
|
||||
|
||||
Console.WriteLine($"Found your .csproj: {projectFile} - check for existing CopyToPublishDirectory setting or update it.");
|
||||
|
||||
if (!EditCsProj(projectFile)) return false;
|
||||
|
||||
Console.WriteLine($"Everything done - happy electronizing with your custom npm packages!");
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
// ToDo: Cleanup this copy/past code.
|
||||
private static bool EditCsProj(string projectFile)
|
||||
{
|
||||
using (var stream = File.Open(projectFile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
{
|
||||
var xmlDocument = XDocument.Load(stream);
|
||||
|
||||
var projectElement = xmlDocument.Descendants("Project").FirstOrDefault();
|
||||
if (projectElement == null || projectElement.Attribute("Sdk")?.Value != "Microsoft.NET.Sdk.Web")
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"Project file is not a compatible type of 'Microsoft.NET.Sdk.Web'. Your project: {projectElement?.Attribute("Sdk")?.Value}");
|
||||
return false;
|
||||
}
|
||||
|
||||
string itemGroupXmlString = "<ItemGroup>" +
|
||||
"<Content Update=\"ElectronHostHook\\**\\*.*\">" +
|
||||
"<CopyToPublishDirectory>Never</CopyToPublishDirectory>" +
|
||||
"</Content>" +
|
||||
"</ItemGroup>";
|
||||
|
||||
var newItemGroupForConfig = XElement.Parse(itemGroupXmlString);
|
||||
xmlDocument.Root.Add(newItemGroupForConfig);
|
||||
|
||||
stream.SetLength(0);
|
||||
stream.Position = 0;
|
||||
|
||||
var xws = new XmlWriterSettings
|
||||
{
|
||||
OmitXmlDeclaration = true,
|
||||
Indent = true
|
||||
};
|
||||
using (XmlWriter xw = XmlWriter.Create(stream, xws))
|
||||
{
|
||||
xmlDocument.Save(xw);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Console.WriteLine($"Publish setting added in csproj!");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.CLI.Commands.Actions;
|
||||
|
||||
@@ -16,9 +15,13 @@ namespace ElectronNET.CLI.Commands
|
||||
public static string COMMAND_ARGUMENTS = "Needed: '/target' with params 'win/osx/linux' to build for a typical app or use 'custom' and specify .NET Core build config & electron build config" + Environment.NewLine +
|
||||
" for custom target, check .NET Core RID Catalog and Electron build target/" + Environment.NewLine +
|
||||
" e.g. '/target win' or '/target custom \"win7-x86;win32\"'" + Environment.NewLine +
|
||||
"Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release" + Environment.NewLine +
|
||||
"Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release" + Environment.NewLine +
|
||||
"Optional: '/electron-arch' to specify the resulting electron processor architecture (e.g. ia86 for x86 builds). Be aware to use the '/target custom' param as well!" + Environment.NewLine +
|
||||
"Optional: '/electron-params' specify any other valid parameter, which will be routed to the electron-packager." + Environment.NewLine +
|
||||
"Optional: '/relative-path' to specify output a subdirectory for output." + Environment.NewLine +
|
||||
"Optional: '/absolute-path to specify and absolute path for output." + Environment.NewLine +
|
||||
"Optional: '/package-json' to specify a custom package.json file." + Environment.NewLine +
|
||||
"Optional: '/install-modules' to force node module install. Implied by '/package-json'" + Environment.NewLine +
|
||||
"Full example for a 32bit debug build with electron prune: build /target custom win7-x86;win32 /dotnet-configuration Debug /electron-arch ia32 /electron-params \"--prune=true \"";
|
||||
|
||||
public static IList<CommandOption> CommandOptions { get; set; } = new List<CommandOption>();
|
||||
@@ -34,6 +37,11 @@ namespace ElectronNET.CLI.Commands
|
||||
private string _paramDotNetConfig = "dotnet-configuration";
|
||||
private string _paramElectronArch = "electron-arch";
|
||||
private string _paramElectronParams = "electron-params";
|
||||
private string _paramOutputDirectory = "relative-path";
|
||||
private string _paramAbsoluteOutput = "absolute-path";
|
||||
private string _paramPackageJson = "package-json";
|
||||
private string _paramForceNodeInstall = "install-modules";
|
||||
private string _manifest = "manifest";
|
||||
|
||||
public Task<bool> ExecuteAsync()
|
||||
{
|
||||
@@ -44,6 +52,13 @@ namespace ElectronNET.CLI.Commands
|
||||
SimpleCommandLineParser parser = new SimpleCommandLineParser();
|
||||
parser.Parse(_args);
|
||||
|
||||
if (!parser.Arguments.ContainsKey(_paramTarget))
|
||||
{
|
||||
Console.WriteLine($"Error: missing '{_paramTarget}' argument.");
|
||||
Console.WriteLine(COMMAND_ARGUMENTS);
|
||||
return false;
|
||||
}
|
||||
|
||||
var desiredPlatform = parser.Arguments[_paramTarget][0];
|
||||
string specifiedFromCustom = string.Empty;
|
||||
if (desiredPlatform == "custom" && parser.Arguments[_paramTarget].Length > 1)
|
||||
@@ -61,12 +76,18 @@ namespace ElectronNET.CLI.Commands
|
||||
|
||||
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}...");
|
||||
|
||||
|
||||
string tempPath = Path.Combine(Directory.GetCurrentDirectory(), "obj", "desktop", desiredPlatform);
|
||||
|
||||
if (Directory.Exists(tempPath) == false)
|
||||
{
|
||||
Directory.CreateDirectory(tempPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.Delete(tempPath, true);
|
||||
Directory.CreateDirectory(tempPath);
|
||||
}
|
||||
|
||||
|
||||
Console.WriteLine("Executing dotnet publish in this directory: " + tempPath);
|
||||
|
||||
@@ -83,42 +104,53 @@ namespace ElectronNET.CLI.Commands
|
||||
}
|
||||
|
||||
DeployEmbeddedElectronFiles.Do(tempPath);
|
||||
var nodeModulesDirPath = Path.Combine(tempPath, "node_modules");
|
||||
|
||||
if (parser.Arguments.ContainsKey(_paramPackageJson))
|
||||
{
|
||||
Console.WriteLine("Copying custom package.json.");
|
||||
|
||||
File.Copy(parser.Arguments[_paramPackageJson][0], Path.Combine(tempPath, "package.json"), true);
|
||||
}
|
||||
|
||||
var checkForNodeModulesDirPath = Path.Combine(tempPath, "node_modules");
|
||||
|
||||
if (Directory.Exists(checkForNodeModulesDirPath) == false)
|
||||
if (Directory.Exists(checkForNodeModulesDirPath) == false || parser.Contains(_paramForceNodeInstall) || parser.Contains(_paramPackageJson))
|
||||
|
||||
Console.WriteLine("Start npm install...");
|
||||
ProcessHelper.CmdExecute("npm install --production", tempPath);
|
||||
|
||||
Console.WriteLine("ElectronHostHook handling started...");
|
||||
|
||||
string electronhosthookDir = Path.Combine(Directory.GetCurrentDirectory(), "ElectronHostHook");
|
||||
|
||||
if (Directory.Exists(electronhosthookDir))
|
||||
{
|
||||
Console.WriteLine("node_modules missing in: " + checkForNodeModulesDirPath);
|
||||
string hosthookDir = Path.Combine(tempPath, "ElectronHostHook");
|
||||
DirectoryCopy.Do(electronhosthookDir, hosthookDir, true, new List<string>() { "node_modules" });
|
||||
|
||||
Console.WriteLine("Start npm install...");
|
||||
ProcessHelper.CmdExecute("npm install", tempPath);
|
||||
Console.WriteLine("Start npm install for hosthooks...");
|
||||
ProcessHelper.CmdExecute("npm install", hosthookDir);
|
||||
|
||||
Console.WriteLine("Start npm install electron-packager...");
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// Works proper on Windows...
|
||||
ProcessHelper.CmdExecute("npm install electron-packager --global", tempPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ToDo: find another solution or document it proper
|
||||
// GH Issue https://github.com/electron-userland/electron-prebuilt/issues/48
|
||||
Console.WriteLine("Electron Packager - make sure you invoke 'sudo npm install electron-packager --global' at " + tempPath + " manually. Sry.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Skip npm install, because node_modules directory exists in: " + checkForNodeModulesDirPath);
|
||||
// ToDo: Not sure if this runs under linux/macos
|
||||
ProcessHelper.CmdExecute(@"npx tsc -p . --sourceMap false", hosthookDir);
|
||||
}
|
||||
|
||||
Console.WriteLine("Build Electron Desktop Application...");
|
||||
|
||||
// Specifying an absolute path supercedes a relative path
|
||||
string buildPath = Path.Combine(Directory.GetCurrentDirectory(), "bin", "desktop");
|
||||
if (parser.Arguments.ContainsKey(_paramAbsoluteOutput))
|
||||
{
|
||||
buildPath = parser.Arguments[_paramAbsoluteOutput][0];
|
||||
}
|
||||
else if (parser.Arguments.ContainsKey(_paramOutputDirectory))
|
||||
{
|
||||
buildPath = Path.Combine(Directory.GetCurrentDirectory(),parser.Arguments[_paramOutputDirectory][0]);
|
||||
}
|
||||
|
||||
Console.WriteLine("Executing electron magic in this directory: " + buildPath);
|
||||
|
||||
// ToDo: Need a solution for --asar support
|
||||
|
||||
string electronArch = "x64";
|
||||
if (parser.Arguments.ContainsKey(_paramElectronArch))
|
||||
{
|
||||
@@ -131,15 +163,25 @@ namespace ElectronNET.CLI.Commands
|
||||
electronParams = parser.Arguments[_paramElectronParams][0];
|
||||
}
|
||||
|
||||
// ToDo: Make the same thing easer with native c# - we can save a tmp file in production code :)
|
||||
Console.WriteLine("Create electron-builder configuration file...");
|
||||
|
||||
string manifestFileName = "electron.manifest.json";
|
||||
|
||||
if(parser.Arguments.ContainsKey(_manifest))
|
||||
{
|
||||
manifestFileName = parser.Arguments[_manifest].First();
|
||||
}
|
||||
|
||||
ProcessHelper.CmdExecute($"node build-helper.js " + manifestFileName, tempPath);
|
||||
|
||||
Console.WriteLine($"Package Electron App for Platform {platformInfo.ElectronPackerPlatform}...");
|
||||
ProcessHelper.CmdExecute($"electron-packager . --platform={platformInfo.ElectronPackerPlatform} --arch={electronArch} {electronParams} --out=\"{buildPath}\" --overwrite", tempPath);
|
||||
ProcessHelper.CmdExecute($"npx electron-builder . --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=7.1.2 {electronParams}", tempPath);
|
||||
|
||||
Console.WriteLine("... done");
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
@@ -17,26 +16,30 @@ namespace ElectronNET.CLI.Commands
|
||||
public const string COMMAND_ARGUMENTS = "<Path> from ASP.NET Core Project.";
|
||||
public static IList<CommandOption> CommandOptions { get; set; } = new List<CommandOption>();
|
||||
|
||||
private const string ConfigName = "electron.manifest.json";
|
||||
|
||||
private string[] _args;
|
||||
private static SimpleCommandLineParser _parser = new SimpleCommandLineParser();
|
||||
private static string ConfigName = "electron.manifest.json";
|
||||
private const string DefaultConfigFileName = "electron.manifest.json";
|
||||
|
||||
public InitCommand(string[] args)
|
||||
{
|
||||
_args = args;
|
||||
_parser.Parse(args);
|
||||
}
|
||||
|
||||
private static string _aspCoreProjectPath = "project-path";
|
||||
private static string _manifest = "manifest";
|
||||
|
||||
public Task<bool> ExecuteAsync()
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
string aspCoreProjectPath = "";
|
||||
|
||||
if (_args.Length > 0)
|
||||
if (_parser.Arguments.ContainsKey(_aspCoreProjectPath))
|
||||
{
|
||||
if (Directory.Exists(_args[0]))
|
||||
string projectPath = _parser.Arguments[_aspCoreProjectPath].First();
|
||||
if (Directory.Exists(projectPath))
|
||||
{
|
||||
aspCoreProjectPath = _args[0];
|
||||
aspCoreProjectPath = projectPath;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -46,7 +49,15 @@ namespace ElectronNET.CLI.Commands
|
||||
|
||||
var currentDirectory = aspCoreProjectPath;
|
||||
|
||||
Console.WriteLine("Adding our config file to your project...");
|
||||
if(_parser.Arguments.ContainsKey(_manifest))
|
||||
{
|
||||
ConfigName = "electron.manifest." + _parser.Arguments[_manifest].First() + ".json";
|
||||
Console.WriteLine($"Adding your custom {ConfigName} config file to your project...");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Adding our config file to your project...");
|
||||
}
|
||||
|
||||
var targetFilePath = Path.Combine(currentDirectory, ConfigName);
|
||||
|
||||
@@ -57,7 +68,7 @@ namespace ElectronNET.CLI.Commands
|
||||
}
|
||||
|
||||
// Deploy config file
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(currentDirectory, ConfigName);
|
||||
EmbeddedFileHelper.DeployEmbeddedFileToTargetFile(currentDirectory, DefaultConfigFileName, ConfigName);
|
||||
|
||||
// search .csproj
|
||||
Console.WriteLine($"Search your .csproj to add the needed {ConfigName}...");
|
||||
@@ -100,15 +111,41 @@ namespace ElectronNET.CLI.Commands
|
||||
|
||||
string launchSettingText = File.ReadAllText(launchSettingFile);
|
||||
|
||||
if (launchSettingText.Contains("electronize start") == false)
|
||||
if(_parser.Arguments.ContainsKey(_manifest))
|
||||
{
|
||||
string manifestName = _parser.Arguments[_manifest].First();
|
||||
|
||||
if(launchSettingText.Contains("start /manifest " + ConfigName) == false)
|
||||
{
|
||||
StringBuilder debugProfileBuilder = new StringBuilder();
|
||||
debugProfileBuilder.AppendLine("profiles\": {");
|
||||
debugProfileBuilder.AppendLine(" \"Electron.NET App - " + manifestName + "\": {");
|
||||
debugProfileBuilder.AppendLine(" \"commandName\": \"Executable\",");
|
||||
debugProfileBuilder.AppendLine(" \"executablePath\": \"electronize\",");
|
||||
debugProfileBuilder.AppendLine(" \"commandLineArgs\": \"start /manifest " + ConfigName + "\",");
|
||||
debugProfileBuilder.AppendLine(" \"workingDirectory\": \".\"");
|
||||
debugProfileBuilder.AppendLine(" },");
|
||||
|
||||
launchSettingText = launchSettingText.Replace("profiles\": {", debugProfileBuilder.ToString());
|
||||
File.WriteAllText(launchSettingFile, launchSettingText);
|
||||
|
||||
Console.WriteLine($"Debug profile added!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Debug profile already existing");
|
||||
}
|
||||
}
|
||||
else if (launchSettingText.Contains("\"executablePath\": \"electronize\"") == false)
|
||||
{
|
||||
StringBuilder debugProfileBuilder = new StringBuilder();
|
||||
debugProfileBuilder.AppendLine("profiles\": {");
|
||||
debugProfileBuilder.AppendLine("\"Electron.NET App\": {");
|
||||
debugProfileBuilder.AppendLine("\"commandName\": \"Executable\",");
|
||||
debugProfileBuilder.AppendLine("\"executablePath\": \"C:\\\\Program Files\\\\dotnet\\\\dotnet.exe\",");
|
||||
debugProfileBuilder.AppendLine("\"commandLineArgs\": \"electronize start\"");
|
||||
debugProfileBuilder.AppendLine("},");
|
||||
debugProfileBuilder.AppendLine(" \"Electron.NET App\": {");
|
||||
debugProfileBuilder.AppendLine(" \"commandName\": \"Executable\",");
|
||||
debugProfileBuilder.AppendLine(" \"executablePath\": \"electronize\",");
|
||||
debugProfileBuilder.AppendLine(" \"commandLineArgs\": \"start\",");
|
||||
debugProfileBuilder.AppendLine(" \"workingDirectory\": \".\"");
|
||||
debugProfileBuilder.AppendLine(" },");
|
||||
|
||||
launchSettingText = launchSettingText.Replace("profiles\": {", debugProfileBuilder.ToString());
|
||||
File.WriteAllText(launchSettingFile, launchSettingText);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.CLI.Commands.Actions;
|
||||
@@ -22,19 +22,27 @@ namespace ElectronNET.CLI.Commands
|
||||
_args = args;
|
||||
}
|
||||
|
||||
private string _aspCoreProjectPath = "project-path";
|
||||
private string _arguments = "args";
|
||||
private string _manifest = "manifest";
|
||||
|
||||
public Task<bool> ExecuteAsync()
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
Console.WriteLine("Start Electron Desktop Application...");
|
||||
|
||||
SimpleCommandLineParser parser = new SimpleCommandLineParser();
|
||||
parser.Parse(_args);
|
||||
|
||||
string aspCoreProjectPath = "";
|
||||
|
||||
if (_args.Length > 0)
|
||||
if (parser.Arguments.ContainsKey(_aspCoreProjectPath))
|
||||
{
|
||||
if (Directory.Exists(_args[0]))
|
||||
string projectPath = parser.Arguments[_aspCoreProjectPath].First();
|
||||
if (Directory.Exists(projectPath))
|
||||
{
|
||||
aspCoreProjectPath = _args[0];
|
||||
aspCoreProjectPath = projectPath;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -48,7 +56,7 @@ namespace ElectronNET.CLI.Commands
|
||||
Directory.CreateDirectory(tempPath);
|
||||
}
|
||||
|
||||
var platformInfo = GetTargetPlatformInformation.Do(String.Empty, String.Empty);
|
||||
var platformInfo = GetTargetPlatformInformation.Do(string.Empty, string.Empty);
|
||||
|
||||
string tempBinPath = Path.Combine(tempPath, "bin");
|
||||
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", aspCoreProjectPath);
|
||||
@@ -61,36 +69,59 @@ namespace ElectronNET.CLI.Commands
|
||||
|
||||
DeployEmbeddedElectronFiles.Do(tempPath);
|
||||
|
||||
var checkForNodeModulesDirPath = Path.Combine(tempPath, "node_modules");
|
||||
var nodeModulesDirPath = Path.Combine(tempPath, "node_modules");
|
||||
|
||||
if (Directory.Exists(checkForNodeModulesDirPath) == false)
|
||||
Console.WriteLine("node_modules missing in: " + nodeModulesDirPath);
|
||||
|
||||
Console.WriteLine("Start npm install...");
|
||||
ProcessHelper.CmdExecute("npm install", tempPath);
|
||||
|
||||
Console.WriteLine("ElectronHostHook handling started...");
|
||||
|
||||
string electronhosthookDir = Path.Combine(Directory.GetCurrentDirectory(), "ElectronHostHook");
|
||||
|
||||
if (Directory.Exists(electronhosthookDir))
|
||||
{
|
||||
Console.WriteLine("node_modules missing in: " + checkForNodeModulesDirPath);
|
||||
string hosthookDir = Path.Combine(tempPath, "ElectronHostHook");
|
||||
DirectoryCopy.Do(electronhosthookDir, hosthookDir, true, new List<string>() { "node_modules" });
|
||||
|
||||
Console.WriteLine("Start npm install...");
|
||||
ProcessHelper.CmdExecute("npm install", tempPath);
|
||||
Console.WriteLine("Start npm install for typescript & hosthooks...");
|
||||
ProcessHelper.CmdExecute("npm install", hosthookDir);
|
||||
|
||||
// ToDo: Not sure if this runs under linux/macos
|
||||
ProcessHelper.CmdExecute(@"npx tsc -p ../../ElectronHostHook", tempPath);
|
||||
}
|
||||
else
|
||||
|
||||
string arguments = "";
|
||||
|
||||
if (parser.Arguments.ContainsKey(_arguments))
|
||||
{
|
||||
Console.WriteLine("Skip npm install, because node_modules directory exists in: " + checkForNodeModulesDirPath);
|
||||
arguments = string.Join(' ', parser.Arguments[_arguments]);
|
||||
}
|
||||
|
||||
if (parser.Arguments.ContainsKey(_manifest))
|
||||
{
|
||||
arguments += " --manifest=" + parser.Arguments[_manifest].First();
|
||||
}
|
||||
|
||||
string path = Path.Combine(tempPath, "node_modules", ".bin");
|
||||
|
||||
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
|
||||
if (isWindows)
|
||||
{
|
||||
Console.WriteLine("Invoke electron.cmd - in dir: " + path);
|
||||
ProcessHelper.CmdExecute(@"electron.cmd ""..\..\main.js""", path);
|
||||
ProcessHelper.CmdExecute(@"electron.cmd ""..\..\main.js"" " + arguments, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Invoke electron - in dir: " + path);
|
||||
ProcessHelper.CmdExecute(@"./electron ""../../main.js""", path);
|
||||
ProcessHelper.CmdExecute(@"./electron ""../../main.js"" " + arguments, path);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,24 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<AssemblyName>electronize</AssemblyName>
|
||||
|
||||
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<AssemblyName>dotnet-electronize</AssemblyName>
|
||||
<ToolCommandName>electronize</ToolCommandName>
|
||||
|
||||
<PackageType>DotnetCliTool</PackageType>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageOutputPath>..\artifacts</PackageOutputPath>
|
||||
<PackageId>ElectronNET.CLI</PackageId>
|
||||
<Version>1.0.0.0</Version>
|
||||
<!-- Version 99 is just set for local development stuff to avoid a conflict with "real" packages on NuGet.org -->
|
||||
<Version>99.0.0.0</Version>
|
||||
<Authors>Gregor Biswanger, Robert Muehsig</Authors>
|
||||
<Product>Electron.NET</Product>
|
||||
<Company />
|
||||
<Description>Building cross platform electron based desktop apps with .NET Core and ASP.NET NET Core.
|
||||
This package contains the dotnet tooling to electronize your application.</Description>
|
||||
<Description>
|
||||
Building cross platform electron based desktop apps with .NET Core and ASP.NET Core.
|
||||
This package contains the dotnet tooling to electronize your application.
|
||||
</Description>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageProjectUrl>https://github.com/ElectronNET/Electron.NET/</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/ElectronNET/Electron.NET/</RepositoryUrl>
|
||||
@@ -22,7 +27,7 @@ This package contains the dotnet tooling to electronize your application.</Descr
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<PackageTags>electron aspnetcore</PackageTags>
|
||||
<PackageReleaseNotes>Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md</PackageReleaseNotes>
|
||||
<PackageIconUrl>https://raw.githubusercontent.com/ElectronNET/Electron.NET/master/assets/images/electron.net-logo-square.png</PackageIconUrl>
|
||||
<PackageIcon>PackageIcon.png</PackageIcon>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -31,56 +36,39 @@ This package contains the dotnet tooling to electronize your application.</Descr
|
||||
<None Remove="ElectronHost\package.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile></DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="PackageIcon.png" Pack="true" PackagePath="\"/>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DocumentationFile></DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\electron.manifest.json" Link="ElectronHost\electron.manifest.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\package-lock.json" Link="ElectronHost\package-lock.json" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\package.json" Link="ElectronHost\package.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\main.js" Link="ElectronHost\main.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\build-helper.js" Link="ElectronHost\build-helper.js" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\ipc.js" Link="ElectronHost\api\ipc.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\ElectronHostHook\index.ts" Link="ElectronHost\ElectronHostHook\index.ts" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\ElectronHostHook\connector.ts" Link="ElectronHost\ElectronHostHook\connector.ts" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\ElectronHostHook\tsconfig.json" Link="ElectronHost\ElectronHostHook\tsconfig.json" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\ElectronHostHook\package.json" Link="ElectronHost\ElectronHostHook\package.json" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\ElectronHostHook\.gitignore" Link="ElectronHost\ElectronHostHook\.gitignore" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\splashscreen\index.html" Link="ElectronHost\splashscreen\index.html" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\app.js" Link="ElectronHost\api\app.js" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\browserWindows.js" Link="ElectronHost\api\browserWindows.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\commandLine.js" Link="ElectronHost\api\commandLine.js" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\dialog.js" Link="ElectronHost\api\dialog.js" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\menu.js" Link="ElectronHost\api\menu.js" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\notification.js" Link="ElectronHost\api\notification.js" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\tray.js" Link="ElectronHost\api\tray.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\globalShortcut.js" Link="ElectronHost\api\globalShortcut.js" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\screen.js" Link="ElectronHost\api\screen.js" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\shell.js" Link="ElectronHost\api\shell.js" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\webContents.js" Link="ElectronHost\api\webContents.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\clipboard.js" Link="ElectronHost\api\clipboard.js" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\autoUpdater.js" Link="ElectronHost\api\autoUpdater.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05">
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -29,5 +29,19 @@ namespace ElectronNET.CLI
|
||||
streamFromEmbeddedFile.CopyTo(fileStream);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeployEmbeddedFileToTargetFile(string targetPath, string embeddedFile, string targetFile, string namespacePath = "")
|
||||
{
|
||||
using (var fileStream = File.Create(Path.Combine(targetPath, targetFile)))
|
||||
{
|
||||
var streamFromEmbeddedFile = GetTestResourceFileStream("ElectronHost." + namespacePath + embeddedFile);
|
||||
if (streamFromEmbeddedFile == null)
|
||||
{
|
||||
Console.WriteLine("Error: Couldn't find embedded file: " + embeddedFile);
|
||||
}
|
||||
|
||||
streamFromEmbeddedFile.CopyTo(fileStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
ElectronNET.CLI/PackageIcon.png
Normal file
BIN
ElectronNET.CLI/PackageIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
@@ -1,11 +1,14 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ElectronNET.CLI
|
||||
{
|
||||
public class ProcessHelper
|
||||
{
|
||||
private readonly static Regex ErrorRegex = new Regex(@"\berror\b", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
public static int CmdExecute(string command, string workingDirectoryPath, bool output = true, bool waitForExit = true)
|
||||
{
|
||||
using (Process cmd = new Process())
|
||||
@@ -44,7 +47,7 @@ namespace ElectronNET.CLI
|
||||
// 1 if something fails
|
||||
if (e != null && string.IsNullOrWhiteSpace(e.Data) == false)
|
||||
{
|
||||
if (e.Data.ToLowerInvariant().Contains("error"))
|
||||
if (ErrorRegex.IsMatch(e.Data))
|
||||
{
|
||||
returnCode = 1;
|
||||
}
|
||||
@@ -63,7 +66,7 @@ namespace ElectronNET.CLI
|
||||
// 1 if something fails
|
||||
if (e != null && string.IsNullOrWhiteSpace(e.Data) == false)
|
||||
{
|
||||
if (e.Data.ToLowerInvariant().Contains("error"))
|
||||
if (ErrorRegex.IsMatch(e.Data))
|
||||
{
|
||||
returnCode = 1;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ namespace ElectronNET.CLI
|
||||
case InitCommand.COMMAND_NAME:
|
||||
command = new InitCommand(args.Skip(1).ToArray());
|
||||
break;
|
||||
case AddCommand.COMMAND_NAME:
|
||||
command = new AddCommand(args.Skip(1).ToArray());
|
||||
break;
|
||||
case VersionCommand.COMMAND_NAME:
|
||||
command = new VersionCommand(args.Skip(1).ToArray());
|
||||
break;
|
||||
@@ -83,15 +86,20 @@ namespace ElectronNET.CLI
|
||||
Console.WriteLine($"\t{StartElectronCommand.COMMAND_NAME.PadRight(NAME_WIDTH)} {StartElectronCommand.COMMAND_DESCRIPTION}");
|
||||
|
||||
Console.WriteLine("\t");
|
||||
Console.WriteLine("Commands to build the Electron Application:");
|
||||
Console.WriteLine("Command to build the Electron Application:");
|
||||
Console.WriteLine("\t");
|
||||
Console.WriteLine($"\t{BuildCommand.COMMAND_NAME.PadRight(NAME_WIDTH)} {BuildCommand.COMMAND_DESCRIPTION}");
|
||||
|
||||
Console.WriteLine("\t");
|
||||
Console.WriteLine("Commands to init the Electron Application:");
|
||||
Console.WriteLine("Command to init the Electron Application:");
|
||||
Console.WriteLine("\t");
|
||||
Console.WriteLine($"\t{InitCommand.COMMAND_NAME.PadRight(NAME_WIDTH)} {InitCommand.COMMAND_DESCRIPTION}");
|
||||
|
||||
Console.WriteLine("\t");
|
||||
Console.WriteLine("Command to add a custom npm packages to the Electron Application:");
|
||||
Console.WriteLine("\t");
|
||||
Console.WriteLine($"\t{AddCommand.COMMAND_NAME.PadRight(NAME_WIDTH)} {AddCommand.COMMAND_DESCRIPTION}");
|
||||
|
||||
Console.WriteLine("\t");
|
||||
Console.WriteLine("Commands to see the current ElectronNET version number:");
|
||||
Console.WriteLine("\t");
|
||||
@@ -116,6 +124,9 @@ namespace ElectronNET.CLI
|
||||
case InitCommand.COMMAND_NAME:
|
||||
PrintUsage(InitCommand.COMMAND_NAME, InitCommand.COMMAND_DESCRIPTION, InitCommand.CommandOptions, InitCommand.COMMAND_ARGUMENTS);
|
||||
break;
|
||||
case AddCommand.COMMAND_NAME:
|
||||
PrintUsage(AddCommand.COMMAND_NAME, AddCommand.COMMAND_DESCRIPTION, AddCommand.CommandOptions, AddCommand.COMMAND_ARGUMENTS);
|
||||
break;
|
||||
case VersionCommand.COMMAND_NAME:
|
||||
PrintUsage(VersionCommand.COMMAND_NAME, VersionCommand.COMMAND_DESCRIPTION, VersionCommand.CommandOptions, VersionCommand.COMMAND_ARGUMENTS);
|
||||
break;
|
||||
|
||||
2
ElectronNET.Host/.gitignore
vendored
Normal file
2
ElectronNET.Host/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
bin
|
||||
22
ElectronNET.Host/.vscode/launch.json
vendored
22
ElectronNET.Host/.vscode/launch.json
vendored
@@ -8,9 +8,25 @@
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Electron App",
|
||||
"program": "${workspaceFolder}\\main.js",
|
||||
"runtimeExecutable": "${workspaceFolder}\\node_modules\\.bin\\electron",
|
||||
"sourceMaps": true
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
||||
"program": "${workspaceFolder}/main.js",
|
||||
"sourceMaps": true,
|
||||
"args": [
|
||||
"--test=true",
|
||||
"--blub=wuhuu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch build-helper",
|
||||
"program": "${workspaceFolder}/build-helper.js",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"args": [
|
||||
"electron.manifest.json"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
91
ElectronNET.Host/ElectronHostHook/.gitignore
vendored
Normal file
91
ElectronNET.Host/ElectronHostHook/.gitignore
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/node
|
||||
# Edit at https://www.gitignore.io/?templates=node
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# End of https://www.gitignore.io/api/node
|
||||
27
ElectronNET.Host/ElectronHostHook/connector.js
Normal file
27
ElectronNET.Host/ElectronHostHook/connector.js
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class Connector {
|
||||
constructor(socket,
|
||||
// @ts-ignore
|
||||
app) {
|
||||
this.socket = socket;
|
||||
this.app = app;
|
||||
}
|
||||
on(key, javaScriptCode) {
|
||||
this.socket.on(key, (...args) => {
|
||||
const id = args.pop();
|
||||
try {
|
||||
javaScriptCode(...args, (data) => {
|
||||
if (data) {
|
||||
this.socket.emit(`${key}Complete${id}`, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
this.socket.emit(`${key}Error${id}`, `Host Hook Exception`, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.Connector = Connector;
|
||||
//# sourceMappingURL=connector.js.map
|
||||
1
ElectronNET.Host/ElectronHostHook/connector.js.map
Normal file
1
ElectronNET.Host/ElectronHostHook/connector.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"connector.js","sourceRoot":"","sources":["connector.ts"],"names":[],"mappings":";;AAAA,MAAa,SAAS;IAClB,YAAoB,MAAuB;IACvC,aAAa;IACN,GAAiB;QAFR,WAAM,GAAN,MAAM,CAAiB;QAEhC,QAAG,GAAH,GAAG,CAAc;IAAI,CAAC;IAEjC,EAAE,CAAC,GAAW,EAAE,cAAwB;QACpC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;YACnC,MAAM,EAAE,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;YAE9B,IAAI;gBACA,cAAc,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;oBAC7B,IAAI,IAAI,EAAE;wBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,WAAW,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;qBACjD;gBACL,CAAC,CAAC,CAAC;aACN;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,QAAQ,EAAE,EAAE,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;aACtE;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AApBD,8BAoBC"}
|
||||
21
ElectronNET.Host/ElectronHostHook/connector.ts
Normal file
21
ElectronNET.Host/ElectronHostHook/connector.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export class Connector {
|
||||
constructor(private socket: SocketIO.Socket,
|
||||
// @ts-ignore
|
||||
public app: Electron.App) { }
|
||||
|
||||
on(key: string, javaScriptCode: Function): void {
|
||||
this.socket.on(key, (...args: any[]) => {
|
||||
const id: string = args.pop();
|
||||
|
||||
try {
|
||||
javaScriptCode(...args, (data) => {
|
||||
if (data) {
|
||||
this.socket.emit(`${key}Complete${id}`, data);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
this.socket.emit(`${key}Error${id}`, `Host Hook Exception`, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
14
ElectronNET.Host/ElectronHostHook/index.js
Normal file
14
ElectronNET.Host/ElectronHostHook/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const connector_1 = require("./connector");
|
||||
class HookService extends connector_1.Connector {
|
||||
constructor(socket, app) {
|
||||
super(socket, app);
|
||||
this.app = app;
|
||||
}
|
||||
onHostReady() {
|
||||
// execute your own JavaScript Host logic here
|
||||
}
|
||||
}
|
||||
exports.HookService = HookService;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
ElectronNET.Host/ElectronHostHook/index.js.map
Normal file
1
ElectronNET.Host/ElectronHostHook/index.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAEA,2CAAwC;AAExC,MAAa,WAAY,SAAQ,qBAAS;IACtC,YAAY,MAAuB,EAAS,GAAiB;QACzD,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QADqB,QAAG,GAAH,GAAG,CAAc;IAE7D,CAAC;IAED,WAAW;QACP,8CAA8C;IAClD,CAAC;CACJ;AARD,kCAQC"}
|
||||
14
ElectronNET.Host/ElectronHostHook/index.ts
Normal file
14
ElectronNET.Host/ElectronHostHook/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
// @ts-ignore
|
||||
import * as Electron from "electron";
|
||||
import { Connector } from "./connector";
|
||||
|
||||
export class HookService extends Connector {
|
||||
constructor(socket: SocketIO.Socket, public app: Electron.App) {
|
||||
super(socket, app);
|
||||
}
|
||||
|
||||
onHostReady(): void {
|
||||
// execute your own JavaScript Host logic here
|
||||
}
|
||||
}
|
||||
|
||||
19
ElectronNET.Host/ElectronHostHook/package.json
Normal file
19
ElectronNET.Host/ElectronHostHook/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "electron-host-hook",
|
||||
"version": "1.0.0",
|
||||
"description": "Connector for Electron.NET projects.",
|
||||
"repository": {
|
||||
"url": "https://github.com/ElectronNET/Electron.NET"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Gregor Biswanger",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/socket.io": "^2.1.2",
|
||||
"typescript": "^3.4.5"
|
||||
}
|
||||
}
|
||||
11
ElectronNET.Host/ElectronHostHook/tsconfig.json
Normal file
11
ElectronNET.Host/ElectronHostHook/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"sourceMap": true,
|
||||
"skipLibCheck": true,
|
||||
"target": "es2015"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
@@ -1,8 +1,18 @@
|
||||
"use strict";
|
||||
var isQuitWindowAllClosed = true;
|
||||
module.exports = function (socket, app) {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
let isQuitWindowAllClosed = true, electronSocket;
|
||||
module.exports = (socket, app) => {
|
||||
electronSocket = socket;
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', function () {
|
||||
app.on('window-all-closed', () => {
|
||||
// On macOS it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (process.platform !== 'darwin' &&
|
||||
@@ -10,77 +20,76 @@ module.exports = function (socket, app) {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
socket.on('quit-app-window-all-closed-event', function (quit) {
|
||||
socket.on('quit-app-window-all-closed-event', (quit) => {
|
||||
isQuitWindowAllClosed = quit;
|
||||
});
|
||||
socket.on('register-app-window-all-closed-event', function (id) {
|
||||
app.on('window-all-closed', function () {
|
||||
socket.emit('app-window-all-closed' + id);
|
||||
socket.on('register-app-window-all-closed-event', (id) => {
|
||||
app.on('window-all-closed', () => {
|
||||
electronSocket.emit('app-window-all-closed' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-app-before-quit-event', function (id) {
|
||||
app.on('before-quit', function (event) {
|
||||
socket.on('register-app-before-quit-event', (id) => {
|
||||
app.on('before-quit', (event) => {
|
||||
event.preventDefault();
|
||||
socket.emit('app-before-quit' + id);
|
||||
electronSocket.emit('app-before-quit' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-app-will-quit-event', function (id) {
|
||||
app.on('will-quit', function (event) {
|
||||
socket.on('register-app-will-quit-event', (id) => {
|
||||
app.on('will-quit', (event) => {
|
||||
event.preventDefault();
|
||||
socket.emit('app-will-quit' + id);
|
||||
electronSocket.emit('app-will-quit' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-app-browser-window-blur-event', function (id) {
|
||||
app.on('browser-window-blur', function () {
|
||||
socket.emit('app-browser-window-blur' + id);
|
||||
socket.on('register-app-browser-window-blur-event', (id) => {
|
||||
app.on('browser-window-blur', () => {
|
||||
electronSocket.emit('app-browser-window-blur' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-app-browser-window-focus-event', function (id) {
|
||||
app.on('browser-window-focus', function () {
|
||||
socket.emit('app-browser-window-focus' + id);
|
||||
socket.on('register-app-browser-window-focus-event', (id) => {
|
||||
app.on('browser-window-focus', () => {
|
||||
electronSocket.emit('app-browser-window-focus' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-app-browser-window-created-event', function (id) {
|
||||
app.on('browser-window-created', function () {
|
||||
socket.emit('app-browser-window-created' + id);
|
||||
socket.on('register-app-browser-window-created-event', (id) => {
|
||||
app.on('browser-window-created', () => {
|
||||
electronSocket.emit('app-browser-window-created' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-app-web-contents-created-event', function (id) {
|
||||
app.on('web-contents-created', function () {
|
||||
socket.emit('app-web-contents-created' + id);
|
||||
socket.on('register-app-web-contents-created-event', (id) => {
|
||||
app.on('web-contents-created', () => {
|
||||
electronSocket.emit('app-web-contents-created' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-app-accessibility-support-changed-event', function (id) {
|
||||
app.on('accessibility-support-changed', function (event, accessibilitySupportEnabled) {
|
||||
socket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled);
|
||||
socket.on('register-app-accessibility-support-changed-event', (id) => {
|
||||
app.on('accessibility-support-changed', (event, accessibilitySupportEnabled) => {
|
||||
electronSocket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled);
|
||||
});
|
||||
});
|
||||
socket.on('appQuit', function () {
|
||||
socket.on('appQuit', () => {
|
||||
app.quit();
|
||||
});
|
||||
socket.on('appExit', function (exitCode) {
|
||||
if (exitCode === void 0) { exitCode = 0; }
|
||||
socket.on('appExit', (exitCode = 0) => {
|
||||
app.exit(exitCode);
|
||||
});
|
||||
socket.on('appRelaunch', function (options) {
|
||||
socket.on('appRelaunch', (options) => {
|
||||
app.relaunch(options);
|
||||
});
|
||||
socket.on('appFocus', function () {
|
||||
socket.on('appFocus', () => {
|
||||
app.focus();
|
||||
});
|
||||
socket.on('appHide', function () {
|
||||
socket.on('appHide', () => {
|
||||
app.hide();
|
||||
});
|
||||
socket.on('appShow', function () {
|
||||
socket.on('appShow', () => {
|
||||
app.show();
|
||||
});
|
||||
socket.on('appGetAppPath', function () {
|
||||
var path = app.getAppPath();
|
||||
socket.emit('appGetAppPathCompleted', path);
|
||||
socket.on('appGetAppPath', () => {
|
||||
const path = app.getAppPath();
|
||||
electronSocket.emit('appGetAppPathCompleted', path);
|
||||
});
|
||||
socket.on('appGetPath', function (name) {
|
||||
var path = app.getPath(name);
|
||||
socket.emit('appGetPathCompleted', path);
|
||||
socket.on('appGetPath', (name) => {
|
||||
const path = app.getPath(name);
|
||||
electronSocket.emit('appGetPathCompleted', path);
|
||||
});
|
||||
// const nativeImages = {};
|
||||
// function addNativeImage(nativeImage: Electron.NativeImage) {
|
||||
@@ -91,165 +100,155 @@ module.exports = function (socket, app) {
|
||||
// nativeImage[indexCount] = nativeImage;
|
||||
// }
|
||||
// }
|
||||
socket.on('appGetFileIcon', function (path, options) {
|
||||
socket.on('appGetFileIcon', (path, options) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
let error = {};
|
||||
if (options) {
|
||||
app.getFileIcon(path, options, function (error, nativeImage) {
|
||||
socket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
});
|
||||
const nativeImage = yield app.getFileIcon(path, options).catch((errorFileIcon) => error = errorFileIcon);
|
||||
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
}
|
||||
else {
|
||||
app.getFileIcon(path, function (error, nativeImage) {
|
||||
socket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
});
|
||||
const nativeImage = yield app.getFileIcon(path).catch((errorFileIcon) => error = errorFileIcon);
|
||||
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
}
|
||||
});
|
||||
socket.on('appSetPath', function (name, path) {
|
||||
}));
|
||||
socket.on('appSetPath', (name, path) => {
|
||||
app.setPath(name, path);
|
||||
});
|
||||
socket.on('appGetVersion', function () {
|
||||
var version = app.getVersion();
|
||||
socket.emit('appGetVersionCompleted', version);
|
||||
socket.on('appGetVersion', () => {
|
||||
const version = app.getVersion();
|
||||
electronSocket.emit('appGetVersionCompleted', version);
|
||||
});
|
||||
socket.on('appGetName', function () {
|
||||
var name = app.getName();
|
||||
socket.emit('appGetNameCompleted', name);
|
||||
socket.on('appGetName', () => {
|
||||
const name = app.getName();
|
||||
electronSocket.emit('appGetNameCompleted', name);
|
||||
});
|
||||
socket.on('appSetName', function (name) {
|
||||
socket.on('appSetName', (name) => {
|
||||
app.setName(name);
|
||||
});
|
||||
socket.on('appGetLocale', function () {
|
||||
var locale = app.getLocale();
|
||||
socket.emit('appGetLocaleCompleted', locale);
|
||||
socket.on('appGetLocale', () => {
|
||||
const locale = app.getLocale();
|
||||
electronSocket.emit('appGetLocaleCompleted', locale);
|
||||
});
|
||||
socket.on('appAddRecentDocument', function (path) {
|
||||
socket.on('appAddRecentDocument', (path) => {
|
||||
app.addRecentDocument(path);
|
||||
});
|
||||
socket.on('appClearRecentDocuments', function () {
|
||||
socket.on('appClearRecentDocuments', () => {
|
||||
app.clearRecentDocuments();
|
||||
});
|
||||
socket.on('appSetAsDefaultProtocolClient', function (protocol, path, args) {
|
||||
var success = app.setAsDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appSetAsDefaultProtocolClientCompleted', success);
|
||||
socket.on('appSetAsDefaultProtocolClient', (protocol, path, args) => {
|
||||
const success = app.setAsDefaultProtocolClient(protocol, path, args);
|
||||
electronSocket.emit('appSetAsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
socket.on('appRemoveAsDefaultProtocolClient', function (protocol, path, args) {
|
||||
var success = app.removeAsDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appRemoveAsDefaultProtocolClientCompleted', success);
|
||||
socket.on('appRemoveAsDefaultProtocolClient', (protocol, path, args) => {
|
||||
const success = app.removeAsDefaultProtocolClient(protocol, path, args);
|
||||
electronSocket.emit('appRemoveAsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
socket.on('appIsDefaultProtocolClient', function (protocol, path, args) {
|
||||
var success = app.isDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appIsDefaultProtocolClientCompleted', success);
|
||||
socket.on('appIsDefaultProtocolClient', (protocol, path, args) => {
|
||||
const success = app.isDefaultProtocolClient(protocol, path, args);
|
||||
electronSocket.emit('appIsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
socket.on('appSetUserTasks', function (tasks) {
|
||||
var success = app.setUserTasks(tasks);
|
||||
socket.emit('appSetUserTasksCompleted', success);
|
||||
socket.on('appSetUserTasks', (tasks) => {
|
||||
const success = app.setUserTasks(tasks);
|
||||
electronSocket.emit('appSetUserTasksCompleted', success);
|
||||
});
|
||||
socket.on('appGetJumpListSettings', function () {
|
||||
var jumpListSettings = app.getJumpListSettings();
|
||||
socket.emit('appGetJumpListSettingsCompleted', jumpListSettings);
|
||||
socket.on('appGetJumpListSettings', () => {
|
||||
const jumpListSettings = app.getJumpListSettings();
|
||||
electronSocket.emit('appGetJumpListSettingsCompleted', jumpListSettings);
|
||||
});
|
||||
socket.on('appSetJumpList', function (categories) {
|
||||
socket.on('appSetJumpList', (categories) => {
|
||||
app.setJumpList(categories);
|
||||
});
|
||||
socket.on('appRequestSingleInstanceLock', function () {
|
||||
app.on('second-instance', function (args, workingDirectory) {
|
||||
socket.emit('secondInstance', [args, workingDirectory]);
|
||||
socket.on('appRequestSingleInstanceLock', () => {
|
||||
app.on('second-instance', (args, workingDirectory) => {
|
||||
electronSocket.emit('secondInstance', [args, workingDirectory]);
|
||||
});
|
||||
var success = app.requestSingleInstanceLock();
|
||||
socket.emit('appRequestSingleInstanceLockCompleted', success);
|
||||
const success = app.requestSingleInstanceLock();
|
||||
electronSocket.emit('appRequestSingleInstanceLockCompleted', success);
|
||||
});
|
||||
socket.on('appReleaseSingleInstanceLock', function () {
|
||||
socket.on('appReleaseSingleInstanceLock', () => {
|
||||
app.releaseSingleInstanceLock();
|
||||
});
|
||||
socket.on('appSetUserActivity', function (type, userInfo, webpageURL) {
|
||||
socket.on('appSetUserActivity', (type, userInfo, webpageURL) => {
|
||||
app.setUserActivity(type, userInfo, webpageURL);
|
||||
});
|
||||
socket.on('appGetCurrentActivityType', function () {
|
||||
var activityType = app.getCurrentActivityType();
|
||||
socket.emit('appGetCurrentActivityTypeCompleted', activityType);
|
||||
socket.on('appGetCurrentActivityType', () => {
|
||||
const activityType = app.getCurrentActivityType();
|
||||
electronSocket.emit('appGetCurrentActivityTypeCompleted', activityType);
|
||||
});
|
||||
socket.on('appSetAppUserModelId', function (id) {
|
||||
socket.on('appSetAppUserModelId', (id) => {
|
||||
app.setAppUserModelId(id);
|
||||
});
|
||||
socket.on('appImportCertificate', function (options) {
|
||||
app.importCertificate(options, function (result) {
|
||||
socket.emit('appImportCertificateCompleted', result);
|
||||
socket.on('appImportCertificate', (options) => {
|
||||
app.importCertificate(options, (result) => {
|
||||
electronSocket.emit('appImportCertificateCompleted', result);
|
||||
});
|
||||
});
|
||||
socket.on('appGetAppMetrics', function () {
|
||||
var processMetrics = app.getAppMetrics();
|
||||
socket.emit('appGetAppMetricsCompleted', processMetrics);
|
||||
socket.on('appGetAppMetrics', () => {
|
||||
const processMetrics = app.getAppMetrics();
|
||||
electronSocket.emit('appGetAppMetricsCompleted', processMetrics);
|
||||
});
|
||||
socket.on('appGetGpuFeatureStatus', function () {
|
||||
var gpuFeatureStatus = app.getGPUFeatureStatus();
|
||||
socket.emit('appGetGpuFeatureStatusCompleted', gpuFeatureStatus);
|
||||
socket.on('appGetGpuFeatureStatus', () => {
|
||||
const gpuFeatureStatus = app.getGPUFeatureStatus();
|
||||
electronSocket.emit('appGetGpuFeatureStatusCompleted', gpuFeatureStatus);
|
||||
});
|
||||
socket.on('appSetBadgeCount', function (count) {
|
||||
var success = app.setBadgeCount(count);
|
||||
socket.emit('appSetBadgeCountCompleted', success);
|
||||
socket.on('appSetBadgeCount', (count) => {
|
||||
const success = app.setBadgeCount(count);
|
||||
electronSocket.emit('appSetBadgeCountCompleted', success);
|
||||
});
|
||||
socket.on('appGetBadgeCount', function () {
|
||||
var count = app.getBadgeCount();
|
||||
socket.emit('appGetBadgeCountCompleted', count);
|
||||
socket.on('appGetBadgeCount', () => {
|
||||
const count = app.getBadgeCount();
|
||||
electronSocket.emit('appGetBadgeCountCompleted', count);
|
||||
});
|
||||
socket.on('appIsUnityRunning', function () {
|
||||
var isUnityRunning = app.isUnityRunning();
|
||||
socket.emit('appIsUnityRunningCompleted', isUnityRunning);
|
||||
socket.on('appIsUnityRunning', () => {
|
||||
const isUnityRunning = app.isUnityRunning();
|
||||
electronSocket.emit('appIsUnityRunningCompleted', isUnityRunning);
|
||||
});
|
||||
socket.on('appGetLoginItemSettings', function (options) {
|
||||
var loginItemSettings = app.getLoginItemSettings(options);
|
||||
socket.emit('appGetLoginItemSettingsCompleted', loginItemSettings);
|
||||
socket.on('appGetLoginItemSettings', (options) => {
|
||||
const loginItemSettings = app.getLoginItemSettings(options);
|
||||
electronSocket.emit('appGetLoginItemSettingsCompleted', loginItemSettings);
|
||||
});
|
||||
socket.on('appSetLoginItemSettings', function (settings) {
|
||||
socket.on('appSetLoginItemSettings', (settings) => {
|
||||
app.setLoginItemSettings(settings);
|
||||
});
|
||||
socket.on('appIsAccessibilitySupportEnabled', function () {
|
||||
var isAccessibilitySupportEnabled = app.isAccessibilitySupportEnabled();
|
||||
socket.emit('appIsAccessibilitySupportEnabledCompleted', isAccessibilitySupportEnabled);
|
||||
socket.on('appIsAccessibilitySupportEnabled', () => {
|
||||
const isAccessibilitySupportEnabled = app.isAccessibilitySupportEnabled();
|
||||
electronSocket.emit('appIsAccessibilitySupportEnabledCompleted', isAccessibilitySupportEnabled);
|
||||
});
|
||||
socket.on('appSetAboutPanelOptions', function (options) {
|
||||
socket.on('appSetAboutPanelOptions', (options) => {
|
||||
app.setAboutPanelOptions(options);
|
||||
});
|
||||
socket.on('appCommandLineAppendSwitch', function (theSwitch, value) {
|
||||
app.commandLine.appendSwitch(theSwitch, value);
|
||||
socket.on('appDockBounce', (type) => {
|
||||
const id = app.dock.bounce(type);
|
||||
electronSocket.emit('appDockBounceCompleted', id);
|
||||
});
|
||||
socket.on('appCommandLineAppendArgument', function (value) {
|
||||
app.commandLine.appendArgument(value);
|
||||
});
|
||||
socket.on('appEnableMixedSandbox', function () {
|
||||
app.enableMixedSandbox();
|
||||
});
|
||||
socket.on('appDockBounce', function (type) {
|
||||
var id = app.dock.bounce(type);
|
||||
socket.emit('appDockBounceCompleted', id);
|
||||
});
|
||||
socket.on('appDockCancelBounce', function (id) {
|
||||
socket.on('appDockCancelBounce', (id) => {
|
||||
app.dock.cancelBounce(id);
|
||||
});
|
||||
socket.on('appDockDownloadFinished', function (filePath) {
|
||||
socket.on('appDockDownloadFinished', (filePath) => {
|
||||
app.dock.downloadFinished(filePath);
|
||||
});
|
||||
socket.on('appDockSetBadge', function (text) {
|
||||
socket.on('appDockSetBadge', (text) => {
|
||||
app.dock.setBadge(text);
|
||||
});
|
||||
socket.on('appDockGetBadge', function () {
|
||||
var text = app.dock.getBadge();
|
||||
socket.emit('appDockGetBadgeCompleted', text);
|
||||
socket.on('appDockGetBadge', () => {
|
||||
const text = app.dock.getBadge();
|
||||
electronSocket.emit('appDockGetBadgeCompleted', text);
|
||||
});
|
||||
socket.on('appDockHide', function () {
|
||||
socket.on('appDockHide', () => {
|
||||
app.dock.hide();
|
||||
});
|
||||
socket.on('appDockShow', function () {
|
||||
socket.on('appDockShow', () => {
|
||||
app.dock.show();
|
||||
});
|
||||
socket.on('appDockIsVisible', function () {
|
||||
var isVisible = app.dock.isVisible();
|
||||
socket.emit('appDockIsVisibleCompleted', isVisible);
|
||||
socket.on('appDockIsVisible', () => {
|
||||
const isVisible = app.dock.isVisible();
|
||||
electronSocket.emit('appDockIsVisibleCompleted', isVisible);
|
||||
});
|
||||
// TODO: Menü Lösung muss noch implementiert werden
|
||||
socket.on('appDockSetMenu', function (menu) {
|
||||
socket.on('appDockSetMenu', (menu) => {
|
||||
app.dock.setMenu(menu);
|
||||
});
|
||||
socket.on('appDockSetIcon', function (image) {
|
||||
socket.on('appDockSetIcon', (image) => {
|
||||
app.dock.setIcon(image);
|
||||
});
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +1,6 @@
|
||||
import { nativeImage as NativeImage } from 'electron';
|
||||
let isQuitWindowAllClosed = true;
|
||||
|
||||
let isQuitWindowAllClosed = true, electronSocket;
|
||||
export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
electronSocket = socket;
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', () => {
|
||||
// On macOS it is common for applications and their menu bar
|
||||
@@ -19,7 +17,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('register-app-window-all-closed-event', (id) => {
|
||||
app.on('window-all-closed', () => {
|
||||
socket.emit('app-window-all-closed' + id);
|
||||
electronSocket.emit('app-window-all-closed' + id);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,7 +25,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
app.on('before-quit', (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
socket.emit('app-before-quit' + id);
|
||||
electronSocket.emit('app-before-quit' + id);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,37 +33,37 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
app.on('will-quit', (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
socket.emit('app-will-quit' + id);
|
||||
electronSocket.emit('app-will-quit' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-app-browser-window-blur-event', (id) => {
|
||||
app.on('browser-window-blur', () => {
|
||||
socket.emit('app-browser-window-blur' + id);
|
||||
electronSocket.emit('app-browser-window-blur' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-app-browser-window-focus-event', (id) => {
|
||||
app.on('browser-window-focus', () => {
|
||||
socket.emit('app-browser-window-focus' + id);
|
||||
electronSocket.emit('app-browser-window-focus' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-app-browser-window-created-event', (id) => {
|
||||
app.on('browser-window-created', () => {
|
||||
socket.emit('app-browser-window-created' + id);
|
||||
electronSocket.emit('app-browser-window-created' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-app-web-contents-created-event', (id) => {
|
||||
app.on('web-contents-created', () => {
|
||||
socket.emit('app-web-contents-created' + id);
|
||||
electronSocket.emit('app-web-contents-created' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-app-accessibility-support-changed-event', (id) => {
|
||||
app.on('accessibility-support-changed', (event, accessibilitySupportEnabled) => {
|
||||
socket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled);
|
||||
electronSocket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -95,12 +93,12 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('appGetAppPath', () => {
|
||||
const path = app.getAppPath();
|
||||
socket.emit('appGetAppPathCompleted', path);
|
||||
electronSocket.emit('appGetAppPathCompleted', path);
|
||||
});
|
||||
|
||||
socket.on('appGetPath', (name) => {
|
||||
const path = app.getPath(name);
|
||||
socket.emit('appGetPathCompleted', path);
|
||||
electronSocket.emit('appGetPathCompleted', path);
|
||||
});
|
||||
|
||||
// const nativeImages = {};
|
||||
@@ -115,15 +113,17 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
// }
|
||||
// }
|
||||
|
||||
socket.on('appGetFileIcon', (path, options) => {
|
||||
socket.on('appGetFileIcon', async (path, options) => {
|
||||
let error = {};
|
||||
|
||||
if (options) {
|
||||
app.getFileIcon(path, options, (error, nativeImage) => {
|
||||
socket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
});
|
||||
const nativeImage = await app.getFileIcon(path, options).catch((errorFileIcon) => error = errorFileIcon);
|
||||
|
||||
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
} else {
|
||||
app.getFileIcon(path, (error, nativeImage) => {
|
||||
socket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
});
|
||||
const nativeImage = await app.getFileIcon(path).catch((errorFileIcon) => error = errorFileIcon);
|
||||
|
||||
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -133,12 +133,12 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('appGetVersion', () => {
|
||||
const version = app.getVersion();
|
||||
socket.emit('appGetVersionCompleted', version);
|
||||
electronSocket.emit('appGetVersionCompleted', version);
|
||||
});
|
||||
|
||||
socket.on('appGetName', () => {
|
||||
const name = app.getName();
|
||||
socket.emit('appGetNameCompleted', name);
|
||||
electronSocket.emit('appGetNameCompleted', name);
|
||||
});
|
||||
|
||||
socket.on('appSetName', (name) => {
|
||||
@@ -147,7 +147,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('appGetLocale', () => {
|
||||
const locale = app.getLocale();
|
||||
socket.emit('appGetLocaleCompleted', locale);
|
||||
electronSocket.emit('appGetLocaleCompleted', locale);
|
||||
});
|
||||
|
||||
socket.on('appAddRecentDocument', (path) => {
|
||||
@@ -160,27 +160,27 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('appSetAsDefaultProtocolClient', (protocol, path, args) => {
|
||||
const success = app.setAsDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appSetAsDefaultProtocolClientCompleted', success);
|
||||
electronSocket.emit('appSetAsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appRemoveAsDefaultProtocolClient', (protocol, path, args) => {
|
||||
const success = app.removeAsDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appRemoveAsDefaultProtocolClientCompleted', success);
|
||||
electronSocket.emit('appRemoveAsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appIsDefaultProtocolClient', (protocol, path, args) => {
|
||||
const success = app.isDefaultProtocolClient(protocol, path, args);
|
||||
socket.emit('appIsDefaultProtocolClientCompleted', success);
|
||||
electronSocket.emit('appIsDefaultProtocolClientCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appSetUserTasks', (tasks) => {
|
||||
const success = app.setUserTasks(tasks);
|
||||
socket.emit('appSetUserTasksCompleted', success);
|
||||
electronSocket.emit('appSetUserTasksCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appGetJumpListSettings', () => {
|
||||
const jumpListSettings = app.getJumpListSettings();
|
||||
socket.emit('appGetJumpListSettingsCompleted', jumpListSettings);
|
||||
electronSocket.emit('appGetJumpListSettingsCompleted', jumpListSettings);
|
||||
});
|
||||
|
||||
socket.on('appSetJumpList', (categories) => {
|
||||
@@ -189,11 +189,11 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('appRequestSingleInstanceLock', () => {
|
||||
app.on('second-instance', (args, workingDirectory) => {
|
||||
socket.emit('secondInstance', [args, workingDirectory]);
|
||||
electronSocket.emit('secondInstance', [args, workingDirectory]);
|
||||
});
|
||||
|
||||
const success = app.requestSingleInstanceLock();
|
||||
socket.emit('appRequestSingleInstanceLockCompleted', success);
|
||||
electronSocket.emit('appRequestSingleInstanceLockCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appReleaseSingleInstanceLock', () => {
|
||||
@@ -206,7 +206,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('appGetCurrentActivityType', () => {
|
||||
const activityType = app.getCurrentActivityType();
|
||||
socket.emit('appGetCurrentActivityTypeCompleted', activityType);
|
||||
electronSocket.emit('appGetCurrentActivityTypeCompleted', activityType);
|
||||
});
|
||||
|
||||
socket.on('appSetAppUserModelId', (id) => {
|
||||
@@ -215,38 +215,38 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('appImportCertificate', (options) => {
|
||||
app.importCertificate(options, (result) => {
|
||||
socket.emit('appImportCertificateCompleted', result);
|
||||
electronSocket.emit('appImportCertificateCompleted', result);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('appGetAppMetrics', () => {
|
||||
const processMetrics = app.getAppMetrics();
|
||||
socket.emit('appGetAppMetricsCompleted', processMetrics);
|
||||
electronSocket.emit('appGetAppMetricsCompleted', processMetrics);
|
||||
});
|
||||
|
||||
socket.on('appGetGpuFeatureStatus', () => {
|
||||
const gpuFeatureStatus = app.getGPUFeatureStatus();
|
||||
socket.emit('appGetGpuFeatureStatusCompleted', gpuFeatureStatus);
|
||||
electronSocket.emit('appGetGpuFeatureStatusCompleted', gpuFeatureStatus);
|
||||
});
|
||||
|
||||
socket.on('appSetBadgeCount', (count) => {
|
||||
const success = app.setBadgeCount(count);
|
||||
socket.emit('appSetBadgeCountCompleted', success);
|
||||
electronSocket.emit('appSetBadgeCountCompleted', success);
|
||||
});
|
||||
|
||||
socket.on('appGetBadgeCount', () => {
|
||||
const count = app.getBadgeCount();
|
||||
socket.emit('appGetBadgeCountCompleted', count);
|
||||
electronSocket.emit('appGetBadgeCountCompleted', count);
|
||||
});
|
||||
|
||||
socket.on('appIsUnityRunning', () => {
|
||||
const isUnityRunning = app.isUnityRunning();
|
||||
socket.emit('appIsUnityRunningCompleted', isUnityRunning);
|
||||
electronSocket.emit('appIsUnityRunningCompleted', isUnityRunning);
|
||||
});
|
||||
|
||||
socket.on('appGetLoginItemSettings', (options) => {
|
||||
const loginItemSettings = app.getLoginItemSettings(options);
|
||||
socket.emit('appGetLoginItemSettingsCompleted', loginItemSettings);
|
||||
electronSocket.emit('appGetLoginItemSettingsCompleted', loginItemSettings);
|
||||
});
|
||||
|
||||
socket.on('appSetLoginItemSettings', (settings) => {
|
||||
@@ -255,28 +255,16 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('appIsAccessibilitySupportEnabled', () => {
|
||||
const isAccessibilitySupportEnabled = app.isAccessibilitySupportEnabled();
|
||||
socket.emit('appIsAccessibilitySupportEnabledCompleted', isAccessibilitySupportEnabled);
|
||||
electronSocket.emit('appIsAccessibilitySupportEnabledCompleted', isAccessibilitySupportEnabled);
|
||||
});
|
||||
|
||||
socket.on('appSetAboutPanelOptions', (options) => {
|
||||
app.setAboutPanelOptions(options);
|
||||
});
|
||||
|
||||
socket.on('appCommandLineAppendSwitch', (theSwitch, value) => {
|
||||
app.commandLine.appendSwitch(theSwitch, value);
|
||||
});
|
||||
|
||||
socket.on('appCommandLineAppendArgument', (value) => {
|
||||
app.commandLine.appendArgument(value);
|
||||
});
|
||||
|
||||
socket.on('appEnableMixedSandbox', () => {
|
||||
app.enableMixedSandbox();
|
||||
});
|
||||
|
||||
socket.on('appDockBounce', (type) => {
|
||||
const id = app.dock.bounce(type);
|
||||
socket.emit('appDockBounceCompleted', id);
|
||||
electronSocket.emit('appDockBounceCompleted', id);
|
||||
});
|
||||
|
||||
socket.on('appDockCancelBounce', (id) => {
|
||||
@@ -293,7 +281,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('appDockGetBadge', () => {
|
||||
const text = app.dock.getBadge();
|
||||
socket.emit('appDockGetBadgeCompleted', text);
|
||||
electronSocket.emit('appDockGetBadgeCompleted', text);
|
||||
});
|
||||
|
||||
socket.on('appDockHide', () => {
|
||||
@@ -306,7 +294,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
socket.on('appDockIsVisible', () => {
|
||||
const isVisible = app.dock.isVisible();
|
||||
socket.emit('appDockIsVisibleCompleted', isVisible);
|
||||
electronSocket.emit('appDockIsVisibleCompleted', isVisible);
|
||||
});
|
||||
|
||||
// TODO: Menü Lösung muss noch implementiert werden
|
||||
|
||||
112
ElectronNET.Host/api/autoUpdater.js
Normal file
112
ElectronNET.Host/api/autoUpdater.js
Normal file
@@ -0,0 +1,112 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
const electron_updater_1 = require("electron-updater");
|
||||
const path = require('path');
|
||||
let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
electronSocket = socket;
|
||||
// Events ********
|
||||
socket.on('register-autoUpdater-error-event', (id) => {
|
||||
electron_updater_1.autoUpdater.on('error', (error) => {
|
||||
electronSocket.emit('autoUpdater-error' + id, error.message);
|
||||
});
|
||||
});
|
||||
socket.on('register-autoUpdater-checking-for-update-event', (id) => {
|
||||
electron_updater_1.autoUpdater.on('checking-for-update', () => {
|
||||
electronSocket.emit('autoUpdater-checking-for-update' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-autoUpdater-update-available-event', (id) => {
|
||||
electron_updater_1.autoUpdater.on('update-available', (updateInfo) => {
|
||||
electronSocket.emit('autoUpdater-update-available' + id, updateInfo);
|
||||
});
|
||||
});
|
||||
socket.on('register-autoUpdater-update-not-available-event', (id) => {
|
||||
electron_updater_1.autoUpdater.on('update-not-available', (updateInfo) => {
|
||||
electronSocket.emit('autoUpdater-update-not-available' + id, updateInfo);
|
||||
});
|
||||
});
|
||||
socket.on('register-autoUpdater-download-progress-event', (id) => {
|
||||
electron_updater_1.autoUpdater.on('download-progress', (progressInfo) => {
|
||||
electronSocket.emit('autoUpdater-download-progress' + id, progressInfo);
|
||||
});
|
||||
});
|
||||
socket.on('register-autoUpdater-update-downloaded-event', (id) => {
|
||||
electron_updater_1.autoUpdater.on('update-downloaded', (updateInfo) => {
|
||||
electronSocket.emit('autoUpdater-update-downloaded' + id, updateInfo);
|
||||
});
|
||||
});
|
||||
// Properties *****
|
||||
socket.on('autoUpdater-autoDownload-get', () => {
|
||||
electronSocket.emit('autoUpdater-autoDownload-get-reply', electron_updater_1.autoUpdater.autoDownload);
|
||||
});
|
||||
socket.on('autoUpdater-autoDownload-set', (value) => {
|
||||
electron_updater_1.autoUpdater.autoDownload = value;
|
||||
});
|
||||
socket.on('autoUpdater-autoInstallOnAppQuit-get', () => {
|
||||
electronSocket.emit('autoUpdater-autoInstallOnAppQuit-get-reply', electron_updater_1.autoUpdater.autoInstallOnAppQuit);
|
||||
});
|
||||
socket.on('autoUpdater-autoInstallOnAppQuit-set', (value) => {
|
||||
electron_updater_1.autoUpdater.autoInstallOnAppQuit = value;
|
||||
});
|
||||
socket.on('autoUpdater-allowPrerelease-get', () => {
|
||||
electronSocket.emit('autoUpdater-allowPrerelease-get-reply', electron_updater_1.autoUpdater.allowPrerelease);
|
||||
});
|
||||
socket.on('autoUpdater-allowPrerelease-set', (value) => {
|
||||
electron_updater_1.autoUpdater.allowPrerelease = value;
|
||||
});
|
||||
socket.on('autoUpdater-fullChangelog-get', () => {
|
||||
electronSocket.emit('autoUpdater-fullChangelog-get-reply', electron_updater_1.autoUpdater.fullChangelog);
|
||||
});
|
||||
socket.on('autoUpdater-fullChangelog-set', (value) => {
|
||||
electron_updater_1.autoUpdater.fullChangelog = value;
|
||||
});
|
||||
socket.on('autoUpdater-allowDowngrade-get', () => {
|
||||
electronSocket.emit('autoUpdater-allowDowngrade-get-reply', electron_updater_1.autoUpdater.allowDowngrade);
|
||||
});
|
||||
socket.on('autoUpdater-allowDowngrade-set', (value) => {
|
||||
electron_updater_1.autoUpdater.allowDowngrade = value;
|
||||
});
|
||||
socket.on('autoUpdater-updateConfigPath-get', () => {
|
||||
electronSocket.emit('autoUpdater-updateConfigPath-get-reply', electron_updater_1.autoUpdater.updateConfigPath || '');
|
||||
});
|
||||
socket.on('autoUpdater-updateConfigPath-set', (value) => {
|
||||
electron_updater_1.autoUpdater.updateConfigPath = value;
|
||||
});
|
||||
socket.on('autoUpdater-channel-get', () => {
|
||||
electronSocket.emit('autoUpdater-channel-get-reply', electron_updater_1.autoUpdater.channel || '');
|
||||
});
|
||||
socket.on('autoUpdater-channel-set', (value) => {
|
||||
electron_updater_1.autoUpdater.channel = value;
|
||||
});
|
||||
// Methods ********
|
||||
socket.on('autoUpdaterCheckForUpdatesAndNotify', (guid) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const updateCheckResult = yield electron_updater_1.autoUpdater.checkForUpdatesAndNotify();
|
||||
electronSocket.emit('autoUpdaterCheckForUpdatesAndNotifyComplete' + guid, updateCheckResult);
|
||||
}));
|
||||
socket.on('autoUpdaterCheckForUpdates', (guid) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
// autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml');
|
||||
const updateCheckResult = yield electron_updater_1.autoUpdater.checkForUpdates();
|
||||
electronSocket.emit('autoUpdaterCheckForUpdatesComplete' + guid, updateCheckResult);
|
||||
}));
|
||||
socket.on('autoUpdaterQuitAndInstall', (isSilent, isForceRunAfter) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
|
||||
}));
|
||||
socket.on('autoUpdaterDownloadUpdate', (guid) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const downloadedPath = yield electron_updater_1.autoUpdater.downloadUpdate();
|
||||
electronSocket.emit('autoUpdaterDownloadUpdateComplete' + guid, downloadedPath);
|
||||
}));
|
||||
socket.on('autoUpdaterGetFeedURL', (guid) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const feedUrl = yield electron_updater_1.autoUpdater.getFeedURL();
|
||||
electronSocket.emit('autoUpdaterGetFeedURLComplete' + guid, feedUrl || '');
|
||||
}));
|
||||
};
|
||||
//# sourceMappingURL=autoUpdater.js.map
|
||||
1
ElectronNET.Host/api/autoUpdater.js.map
Normal file
1
ElectronNET.Host/api/autoUpdater.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"autoUpdater.js","sourceRoot":"","sources":["autoUpdater.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uDAA+C;AAC/C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;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autoUpdater.ts
Normal file
130
ElectronNET.Host/api/autoUpdater.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
const path = require('path');
|
||||
let electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket) => {
|
||||
electronSocket = socket;
|
||||
|
||||
// Events ********
|
||||
|
||||
socket.on('register-autoUpdater-error-event', (id) => {
|
||||
autoUpdater.on('error', (error) => {
|
||||
electronSocket.emit('autoUpdater-error' + id, error.message);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-autoUpdater-checking-for-update-event', (id) => {
|
||||
autoUpdater.on('checking-for-update', () => {
|
||||
electronSocket.emit('autoUpdater-checking-for-update' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-autoUpdater-update-available-event', (id) => {
|
||||
autoUpdater.on('update-available', (updateInfo) => {
|
||||
electronSocket.emit('autoUpdater-update-available' + id, updateInfo);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-autoUpdater-update-not-available-event', (id) => {
|
||||
autoUpdater.on('update-not-available', (updateInfo) => {
|
||||
electronSocket.emit('autoUpdater-update-not-available' + id, updateInfo);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-autoUpdater-download-progress-event', (id) => {
|
||||
autoUpdater.on('download-progress', (progressInfo) => {
|
||||
electronSocket.emit('autoUpdater-download-progress' + id, progressInfo);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-autoUpdater-update-downloaded-event', (id) => {
|
||||
autoUpdater.on('update-downloaded', (updateInfo) => {
|
||||
electronSocket.emit('autoUpdater-update-downloaded' + id, updateInfo);
|
||||
});
|
||||
});
|
||||
|
||||
// Properties *****
|
||||
|
||||
socket.on('autoUpdater-autoDownload-get', () => {
|
||||
electronSocket.emit('autoUpdater-autoDownload-get-reply', autoUpdater.autoDownload);
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-autoDownload-set', (value) => {
|
||||
autoUpdater.autoDownload = value;
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-autoInstallOnAppQuit-get', () => {
|
||||
electronSocket.emit('autoUpdater-autoInstallOnAppQuit-get-reply', autoUpdater.autoInstallOnAppQuit);
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-autoInstallOnAppQuit-set', (value) => {
|
||||
autoUpdater.autoInstallOnAppQuit = value;
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-allowPrerelease-get', () => {
|
||||
electronSocket.emit('autoUpdater-allowPrerelease-get-reply', autoUpdater.allowPrerelease);
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-allowPrerelease-set', (value) => {
|
||||
autoUpdater.allowPrerelease = value;
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-fullChangelog-get', () => {
|
||||
electronSocket.emit('autoUpdater-fullChangelog-get-reply', autoUpdater.fullChangelog);
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-fullChangelog-set', (value) => {
|
||||
autoUpdater.fullChangelog = value;
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-allowDowngrade-get', () => {
|
||||
electronSocket.emit('autoUpdater-allowDowngrade-get-reply', autoUpdater.allowDowngrade);
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-allowDowngrade-set', (value) => {
|
||||
autoUpdater.allowDowngrade = value;
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-updateConfigPath-get', () => {
|
||||
electronSocket.emit('autoUpdater-updateConfigPath-get-reply', autoUpdater.updateConfigPath || '');
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-updateConfigPath-set', (value) => {
|
||||
autoUpdater.updateConfigPath = value;
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-channel-get', () => {
|
||||
electronSocket.emit('autoUpdater-channel-get-reply', autoUpdater.channel || '');
|
||||
});
|
||||
|
||||
socket.on('autoUpdater-channel-set', (value) => {
|
||||
autoUpdater.channel = value;
|
||||
});
|
||||
|
||||
// Methods ********
|
||||
|
||||
socket.on('autoUpdaterCheckForUpdatesAndNotify', async (guid) => {
|
||||
const updateCheckResult = await autoUpdater.checkForUpdatesAndNotify();
|
||||
electronSocket.emit('autoUpdaterCheckForUpdatesAndNotifyComplete' + guid, updateCheckResult);
|
||||
});
|
||||
|
||||
socket.on('autoUpdaterCheckForUpdates', async (guid) => {
|
||||
// autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml');
|
||||
const updateCheckResult = await autoUpdater.checkForUpdates();
|
||||
electronSocket.emit('autoUpdaterCheckForUpdatesComplete' + guid, updateCheckResult);
|
||||
});
|
||||
|
||||
socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => {
|
||||
autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
|
||||
});
|
||||
|
||||
socket.on('autoUpdaterDownloadUpdate', async (guid) => {
|
||||
const downloadedPath = await autoUpdater.downloadUpdate();
|
||||
electronSocket.emit('autoUpdaterDownloadUpdateComplete' + guid, downloadedPath);
|
||||
});
|
||||
|
||||
socket.on('autoUpdaterGetFeedURL', async (guid) => {
|
||||
const feedUrl = await autoUpdater.getFeedURL();
|
||||
electronSocket.emit('autoUpdaterGetFeedURLComplete' + guid, feedUrl || '');
|
||||
});
|
||||
};
|
||||
@@ -1,183 +1,192 @@
|
||||
"use strict";
|
||||
var electron_1 = require("electron");
|
||||
var path = require('path');
|
||||
var windows = [];
|
||||
var window, lastOptions;
|
||||
module.exports = function (socket, app) {
|
||||
socket.on('register-browserWindow-ready-to-show', function (id) {
|
||||
getWindowById(id).on('ready-to-show', function () {
|
||||
socket.emit('browserWindow-ready-to-show' + id);
|
||||
const electron_1 = require("electron");
|
||||
const path = require('path');
|
||||
const windows = [];
|
||||
let window, lastOptions, electronSocket;
|
||||
module.exports = (socket, app) => {
|
||||
electronSocket = socket;
|
||||
socket.on('register-browserWindow-ready-to-show', (id) => {
|
||||
getWindowById(id).on('ready-to-show', () => {
|
||||
electronSocket.emit('browserWindow-ready-to-show' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-page-title-updated', function (id) {
|
||||
getWindowById(id).on('page-title-updated', function (event, title) {
|
||||
socket.emit('browserWindow-page-title-updated' + id, title);
|
||||
socket.on('register-browserWindow-page-title-updated', (id) => {
|
||||
getWindowById(id).on('page-title-updated', (event, title) => {
|
||||
electronSocket.emit('browserWindow-page-title-updated' + id, title);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-close', function (id) {
|
||||
getWindowById(id).on('close', function () {
|
||||
socket.emit('browserWindow-close' + id);
|
||||
socket.on('register-browserWindow-close', (id) => {
|
||||
getWindowById(id).on('close', () => {
|
||||
electronSocket.emit('browserWindow-close' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-closed', function (id) {
|
||||
getWindowById(id).on('closed', function () {
|
||||
socket.emit('browserWindow-closed' + id);
|
||||
socket.on('register-browserWindow-closed', (id) => {
|
||||
getWindowById(id).on('closed', () => {
|
||||
electronSocket.emit('browserWindow-closed' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-session-end', function (id) {
|
||||
getWindowById(id).on('session-end', function () {
|
||||
socket.emit('browserWindow-session-end' + id);
|
||||
socket.on('register-browserWindow-session-end', (id) => {
|
||||
getWindowById(id).on('session-end', () => {
|
||||
electronSocket.emit('browserWindow-session-end' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-unresponsive', function (id) {
|
||||
getWindowById(id).on('unresponsive', function () {
|
||||
socket.emit('browserWindow-unresponsive' + id);
|
||||
socket.on('register-browserWindow-unresponsive', (id) => {
|
||||
getWindowById(id).on('unresponsive', () => {
|
||||
electronSocket.emit('browserWindow-unresponsive' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-responsive', function (id) {
|
||||
getWindowById(id).on('responsive', function () {
|
||||
socket.emit('browserWindow-responsive' + id);
|
||||
socket.on('register-browserWindow-responsive', (id) => {
|
||||
getWindowById(id).on('responsive', () => {
|
||||
electronSocket.emit('browserWindow-responsive' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-blur', function (id) {
|
||||
getWindowById(id).on('blur', function () {
|
||||
socket.emit('browserWindow-blur' + id);
|
||||
socket.on('register-browserWindow-blur', (id) => {
|
||||
getWindowById(id).on('blur', () => {
|
||||
electronSocket.emit('browserWindow-blur' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-focus', function (id) {
|
||||
getWindowById(id).on('focus', function () {
|
||||
socket.emit('browserWindow-focus' + id);
|
||||
socket.on('register-browserWindow-focus', (id) => {
|
||||
getWindowById(id).on('focus', () => {
|
||||
electronSocket.emit('browserWindow-focus' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-show', function (id) {
|
||||
getWindowById(id).on('show', function () {
|
||||
socket.emit('browserWindow-show' + id);
|
||||
socket.on('register-browserWindow-show', (id) => {
|
||||
getWindowById(id).on('show', () => {
|
||||
electronSocket.emit('browserWindow-show' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-hide', function (id) {
|
||||
getWindowById(id).on('hide', function () {
|
||||
socket.emit('browserWindow-hide' + id);
|
||||
socket.on('register-browserWindow-hide', (id) => {
|
||||
getWindowById(id).on('hide', () => {
|
||||
electronSocket.emit('browserWindow-hide' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-maximize', function (id) {
|
||||
getWindowById(id).on('maximize', function () {
|
||||
socket.emit('browserWindow-maximize' + id);
|
||||
socket.on('register-browserWindow-maximize', (id) => {
|
||||
getWindowById(id).on('maximize', () => {
|
||||
electronSocket.emit('browserWindow-maximize' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-unmaximize', function (id) {
|
||||
getWindowById(id).on('unmaximize', function () {
|
||||
socket.emit('browserWindow-unmaximize' + id);
|
||||
socket.on('register-browserWindow-unmaximize', (id) => {
|
||||
getWindowById(id).on('unmaximize', () => {
|
||||
electronSocket.emit('browserWindow-unmaximize' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-minimize', function (id) {
|
||||
getWindowById(id).on('minimize', function () {
|
||||
socket.emit('browserWindow-minimize' + id);
|
||||
socket.on('register-browserWindow-minimize', (id) => {
|
||||
getWindowById(id).on('minimize', () => {
|
||||
electronSocket.emit('browserWindow-minimize' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-restore', function (id) {
|
||||
getWindowById(id).on('restore', function () {
|
||||
socket.emit('browserWindow-restore' + id);
|
||||
socket.on('register-browserWindow-restore', (id) => {
|
||||
getWindowById(id).on('restore', () => {
|
||||
electronSocket.emit('browserWindow-restore' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-resize', function (id) {
|
||||
getWindowById(id).on('resize', function () {
|
||||
socket.emit('browserWindow-resize' + id);
|
||||
socket.on('register-browserWindow-resize', (id) => {
|
||||
getWindowById(id).on('resize', () => {
|
||||
electronSocket.emit('browserWindow-resize' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-move', function (id) {
|
||||
getWindowById(id).on('move', function () {
|
||||
socket.emit('browserWindow-move' + id);
|
||||
socket.on('register-browserWindow-move', (id) => {
|
||||
getWindowById(id).on('move', () => {
|
||||
electronSocket.emit('browserWindow-move' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-moved', function (id) {
|
||||
getWindowById(id).on('moved', function () {
|
||||
socket.emit('browserWindow-moved' + id);
|
||||
socket.on('register-browserWindow-moved', (id) => {
|
||||
getWindowById(id).on('moved', () => {
|
||||
electronSocket.emit('browserWindow-moved' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-enter-full-screen', function (id) {
|
||||
getWindowById(id).on('enter-full-screen', function () {
|
||||
socket.emit('browserWindow-enter-full-screen' + id);
|
||||
socket.on('register-browserWindow-enter-full-screen', (id) => {
|
||||
getWindowById(id).on('enter-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-enter-full-screen' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-leave-full-screen', function (id) {
|
||||
getWindowById(id).on('leave-full-screen', function () {
|
||||
socket.emit('browserWindow-leave-full-screen' + id);
|
||||
socket.on('register-browserWindow-leave-full-screen', (id) => {
|
||||
getWindowById(id).on('leave-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-leave-full-screen' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-enter-html-full-screen', function (id) {
|
||||
getWindowById(id).on('enter-html-full-screen', function () {
|
||||
socket.emit('browserWindow-enter-html-full-screen' + id);
|
||||
socket.on('register-browserWindow-enter-html-full-screen', (id) => {
|
||||
getWindowById(id).on('enter-html-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-enter-html-full-screen' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-leave-html-full-screen', function (id) {
|
||||
getWindowById(id).on('leave-html-full-screen', function () {
|
||||
socket.emit('browserWindow-leave-html-full-screen' + id);
|
||||
socket.on('register-browserWindow-leave-html-full-screen', (id) => {
|
||||
getWindowById(id).on('leave-html-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-leave-html-full-screen' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-app-command', function (id) {
|
||||
getWindowById(id).on('app-command', function (event, command) {
|
||||
socket.emit('browserWindow-app-command' + id, command);
|
||||
socket.on('register-browserWindow-app-command', (id) => {
|
||||
getWindowById(id).on('app-command', (event, command) => {
|
||||
electronSocket.emit('browserWindow-app-command' + id, command);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-scroll-touch-begin', function (id) {
|
||||
getWindowById(id).on('scroll-touch-begin', function () {
|
||||
socket.emit('browserWindow-scroll-touch-begin' + id);
|
||||
socket.on('register-browserWindow-scroll-touch-begin', (id) => {
|
||||
getWindowById(id).on('scroll-touch-begin', () => {
|
||||
electronSocket.emit('browserWindow-scroll-touch-begin' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-scroll-touch-end', function (id) {
|
||||
getWindowById(id).on('scroll-touch-end', function () {
|
||||
socket.emit('browserWindow-scroll-touch-end' + id);
|
||||
socket.on('register-browserWindow-scroll-touch-end', (id) => {
|
||||
getWindowById(id).on('scroll-touch-end', () => {
|
||||
electronSocket.emit('browserWindow-scroll-touch-end' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-scroll-touch-edge', function (id) {
|
||||
getWindowById(id).on('scroll-touch-edge', function () {
|
||||
socket.emit('browserWindow-scroll-touch-edge' + id);
|
||||
socket.on('register-browserWindow-scroll-touch-edge', (id) => {
|
||||
getWindowById(id).on('scroll-touch-edge', () => {
|
||||
electronSocket.emit('browserWindow-scroll-touch-edge' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-swipe', function (id) {
|
||||
getWindowById(id).on('swipe', function (event, direction) {
|
||||
socket.emit('browserWindow-swipe' + id, direction);
|
||||
socket.on('register-browserWindow-swipe', (id) => {
|
||||
getWindowById(id).on('swipe', (event, direction) => {
|
||||
electronSocket.emit('browserWindow-swipe' + id, direction);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-sheet-begin', function (id) {
|
||||
getWindowById(id).on('sheet-begin', function () {
|
||||
socket.emit('browserWindow-sheet-begin' + id);
|
||||
socket.on('register-browserWindow-sheet-begin', (id) => {
|
||||
getWindowById(id).on('sheet-begin', () => {
|
||||
electronSocket.emit('browserWindow-sheet-begin' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-sheet-end', function (id) {
|
||||
getWindowById(id).on('sheet-end', function () {
|
||||
socket.emit('browserWindow-sheet-end' + id);
|
||||
socket.on('register-browserWindow-sheet-end', (id) => {
|
||||
getWindowById(id).on('sheet-end', () => {
|
||||
electronSocket.emit('browserWindow-sheet-end' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-new-window-for-tab', function (id) {
|
||||
getWindowById(id).on('new-window-for-tab', function () {
|
||||
socket.emit('browserWindow-new-window-for-tab' + id);
|
||||
socket.on('register-browserWindow-new-window-for-tab', (id) => {
|
||||
getWindowById(id).on('new-window-for-tab', () => {
|
||||
electronSocket.emit('browserWindow-new-window-for-tab' + id);
|
||||
});
|
||||
});
|
||||
socket.on('createBrowserWindow', function (options, loadUrl) {
|
||||
function hasOwnChildreen(obj, ...childNames) {
|
||||
for (let i = 0; i < childNames.length; i++) {
|
||||
if (!obj || !obj.hasOwnProperty(childNames[i])) {
|
||||
return false;
|
||||
}
|
||||
obj = obj[childNames[i]];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
socket.on('createBrowserWindow', (options, loadUrl) => {
|
||||
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
|
||||
options = Object.assign(Object.assign({}, options), { webPreferences: { nodeIntegration: true } });
|
||||
}
|
||||
window = new electron_1.BrowserWindow(options);
|
||||
lastOptions = options;
|
||||
window.on('closed', function (sender) {
|
||||
var _loop_1 = function () {
|
||||
windowItem = windows[index];
|
||||
window.on('closed', (sender) => {
|
||||
for (let index = 0; index < windows.length; index++) {
|
||||
const windowItem = windows[index];
|
||||
try {
|
||||
windowItem.id;
|
||||
}
|
||||
catch (error) {
|
||||
if (error.message === 'Object has been destroyed') {
|
||||
windows.splice(index, 1);
|
||||
var ids_1 = [];
|
||||
windows.forEach(function (x) { return ids_1.push(x.id); });
|
||||
socket.emit('BrowserWindowClosed', ids_1);
|
||||
const ids = [];
|
||||
windows.forEach(x => ids.push(x.id));
|
||||
electronSocket.emit('BrowserWindowClosed', ids);
|
||||
}
|
||||
}
|
||||
};
|
||||
var windowItem;
|
||||
for (var index = 0; index < windows.length; index++) {
|
||||
_loop_1();
|
||||
}
|
||||
});
|
||||
app.on('activate', function () {
|
||||
app.on('activate', () => {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (window === null && lastOptions) {
|
||||
@@ -188,193 +197,193 @@ module.exports = function (socket, app) {
|
||||
window.loadURL(loadUrl);
|
||||
}
|
||||
windows.push(window);
|
||||
socket.emit('BrowserWindowCreated', window.id);
|
||||
electronSocket.emit('BrowserWindowCreated', window.id);
|
||||
});
|
||||
socket.on('browserWindowDestroy', function (id) {
|
||||
socket.on('browserWindowDestroy', (id) => {
|
||||
getWindowById(id).destroy();
|
||||
});
|
||||
socket.on('browserWindowClose', function (id) {
|
||||
socket.on('browserWindowClose', (id) => {
|
||||
getWindowById(id).close();
|
||||
});
|
||||
socket.on('browserWindowFocus', function (id) {
|
||||
socket.on('browserWindowFocus', (id) => {
|
||||
getWindowById(id).focus();
|
||||
});
|
||||
socket.on('browserWindowBlur', function (id) {
|
||||
socket.on('browserWindowBlur', (id) => {
|
||||
getWindowById(id).blur();
|
||||
});
|
||||
socket.on('browserWindowIsFocused', function (id) {
|
||||
var isFocused = getWindowById(id).isFocused();
|
||||
socket.emit('browserWindow-isFocused-completed', isFocused);
|
||||
socket.on('browserWindowIsFocused', (id) => {
|
||||
const isFocused = getWindowById(id).isFocused();
|
||||
electronSocket.emit('browserWindow-isFocused-completed', isFocused);
|
||||
});
|
||||
socket.on('browserWindowIsDestroyed', function (id) {
|
||||
var isDestroyed = getWindowById(id).isDestroyed();
|
||||
socket.emit('browserWindow-isDestroyed-completed', isDestroyed);
|
||||
socket.on('browserWindowIsDestroyed', (id) => {
|
||||
const isDestroyed = getWindowById(id).isDestroyed();
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed', isDestroyed);
|
||||
});
|
||||
socket.on('browserWindowShow', function (id) {
|
||||
socket.on('browserWindowShow', (id) => {
|
||||
getWindowById(id).show();
|
||||
});
|
||||
socket.on('browserWindowShowInactive', function (id) {
|
||||
socket.on('browserWindowShowInactive', (id) => {
|
||||
getWindowById(id).showInactive();
|
||||
});
|
||||
socket.on('browserWindowHide', function (id) {
|
||||
socket.on('browserWindowHide', (id) => {
|
||||
getWindowById(id).hide();
|
||||
});
|
||||
socket.on('browserWindowIsVisible', function (id) {
|
||||
var isVisible = getWindowById(id).isVisible();
|
||||
socket.emit('browserWindow-isVisible-completed', isVisible);
|
||||
socket.on('browserWindowIsVisible', (id) => {
|
||||
const isVisible = getWindowById(id).isVisible();
|
||||
electronSocket.emit('browserWindow-isVisible-completed', isVisible);
|
||||
});
|
||||
socket.on('browserWindowIsModal', function (id) {
|
||||
var isModal = getWindowById(id).isModal();
|
||||
socket.emit('browserWindow-isModal-completed', isModal);
|
||||
socket.on('browserWindowIsModal', (id) => {
|
||||
const isModal = getWindowById(id).isModal();
|
||||
electronSocket.emit('browserWindow-isModal-completed', isModal);
|
||||
});
|
||||
socket.on('browserWindowMaximize', function (id) {
|
||||
socket.on('browserWindowMaximize', (id) => {
|
||||
getWindowById(id).maximize();
|
||||
});
|
||||
socket.on('browserWindowUnmaximize', function (id) {
|
||||
socket.on('browserWindowUnmaximize', (id) => {
|
||||
getWindowById(id).unmaximize();
|
||||
});
|
||||
socket.on('browserWindowIsMaximized', function (id) {
|
||||
var isMaximized = getWindowById(id).isMaximized();
|
||||
socket.emit('browserWindow-isMaximized-completed', isMaximized);
|
||||
socket.on('browserWindowIsMaximized', (id) => {
|
||||
const isMaximized = getWindowById(id).isMaximized();
|
||||
electronSocket.emit('browserWindow-isMaximized-completed', isMaximized);
|
||||
});
|
||||
socket.on('browserWindowMinimize', function (id) {
|
||||
socket.on('browserWindowMinimize', (id) => {
|
||||
getWindowById(id).minimize();
|
||||
});
|
||||
socket.on('browserWindowRestore', function (id) {
|
||||
socket.on('browserWindowRestore', (id) => {
|
||||
getWindowById(id).restore();
|
||||
});
|
||||
socket.on('browserWindowIsMinimized', function (id) {
|
||||
var isMinimized = getWindowById(id).isMinimized();
|
||||
socket.emit('browserWindow-isMinimized-completed', isMinimized);
|
||||
socket.on('browserWindowIsMinimized', (id) => {
|
||||
const isMinimized = getWindowById(id).isMinimized();
|
||||
electronSocket.emit('browserWindow-isMinimized-completed', isMinimized);
|
||||
});
|
||||
socket.on('browserWindowSetFullScreen', function (id, fullscreen) {
|
||||
socket.on('browserWindowSetFullScreen', (id, fullscreen) => {
|
||||
getWindowById(id).setFullScreen(fullscreen);
|
||||
});
|
||||
socket.on('browserWindowIsFullScreen', function (id) {
|
||||
var isFullScreen = getWindowById(id).isFullScreen();
|
||||
socket.emit('browserWindow-isFullScreen-completed', isFullScreen);
|
||||
socket.on('browserWindowIsFullScreen', (id) => {
|
||||
const isFullScreen = getWindowById(id).isFullScreen();
|
||||
electronSocket.emit('browserWindow-isFullScreen-completed', isFullScreen);
|
||||
});
|
||||
socket.on('browserWindowSetAspectRatio', function (id, aspectRatio, extraSize) {
|
||||
socket.on('browserWindowSetAspectRatio', (id, aspectRatio, extraSize) => {
|
||||
getWindowById(id).setAspectRatio(aspectRatio, extraSize);
|
||||
});
|
||||
socket.on('browserWindowPreviewFile', function (id, path, displayname) {
|
||||
socket.on('browserWindowPreviewFile', (id, path, displayname) => {
|
||||
getWindowById(id).previewFile(path, displayname);
|
||||
});
|
||||
socket.on('browserWindowCloseFilePreview', function (id) {
|
||||
socket.on('browserWindowCloseFilePreview', (id) => {
|
||||
getWindowById(id).closeFilePreview();
|
||||
});
|
||||
socket.on('browserWindowSetBounds', function (id, bounds, animate) {
|
||||
socket.on('browserWindowSetBounds', (id, bounds, animate) => {
|
||||
getWindowById(id).setBounds(bounds, animate);
|
||||
});
|
||||
socket.on('browserWindowGetBounds', function (id) {
|
||||
var rectangle = getWindowById(id).getBounds();
|
||||
socket.emit('browserWindow-getBounds-completed', rectangle);
|
||||
socket.on('browserWindowGetBounds', (id) => {
|
||||
const rectangle = getWindowById(id).getBounds();
|
||||
electronSocket.emit('browserWindow-getBounds-completed', rectangle);
|
||||
});
|
||||
socket.on('browserWindowSetContentBounds', function (id, bounds, animate) {
|
||||
socket.on('browserWindowSetContentBounds', (id, bounds, animate) => {
|
||||
getWindowById(id).setContentBounds(bounds, animate);
|
||||
});
|
||||
socket.on('browserWindowGetContentBounds', function (id) {
|
||||
var rectangle = getWindowById(id).getContentBounds();
|
||||
socket.emit('browserWindow-getContentBounds-completed', rectangle);
|
||||
socket.on('browserWindowGetContentBounds', (id) => {
|
||||
const rectangle = getWindowById(id).getContentBounds();
|
||||
electronSocket.emit('browserWindow-getContentBounds-completed', rectangle);
|
||||
});
|
||||
socket.on('browserWindowSetSize', function (id, width, height, animate) {
|
||||
socket.on('browserWindowSetSize', (id, width, height, animate) => {
|
||||
getWindowById(id).setSize(width, height, animate);
|
||||
});
|
||||
socket.on('browserWindowGetSize', function (id) {
|
||||
var size = getWindowById(id).getSize();
|
||||
socket.emit('browserWindow-getSize-completed', size);
|
||||
socket.on('browserWindowGetSize', (id) => {
|
||||
const size = getWindowById(id).getSize();
|
||||
electronSocket.emit('browserWindow-getSize-completed', size);
|
||||
});
|
||||
socket.on('browserWindowSetContentSize', function (id, width, height, animate) {
|
||||
socket.on('browserWindowSetContentSize', (id, width, height, animate) => {
|
||||
getWindowById(id).setContentSize(width, height, animate);
|
||||
});
|
||||
socket.on('browserWindowGetContentSize', function (id) {
|
||||
var size = getWindowById(id).getContentSize();
|
||||
socket.emit('browserWindow-getContentSize-completed', size);
|
||||
socket.on('browserWindowGetContentSize', (id) => {
|
||||
const size = getWindowById(id).getContentSize();
|
||||
electronSocket.emit('browserWindow-getContentSize-completed', size);
|
||||
});
|
||||
socket.on('browserWindowSetMinimumSize', function (id, width, height) {
|
||||
socket.on('browserWindowSetMinimumSize', (id, width, height) => {
|
||||
getWindowById(id).setMinimumSize(width, height);
|
||||
});
|
||||
socket.on('browserWindowGetMinimumSize', function (id) {
|
||||
var size = getWindowById(id).getMinimumSize();
|
||||
socket.emit('browserWindow-getMinimumSize-completed', size);
|
||||
socket.on('browserWindowGetMinimumSize', (id) => {
|
||||
const size = getWindowById(id).getMinimumSize();
|
||||
electronSocket.emit('browserWindow-getMinimumSize-completed', size);
|
||||
});
|
||||
socket.on('browserWindowSetMaximumSize', function (id, width, height) {
|
||||
socket.on('browserWindowSetMaximumSize', (id, width, height) => {
|
||||
getWindowById(id).setMaximumSize(width, height);
|
||||
});
|
||||
socket.on('browserWindowGetMaximumSize', function (id) {
|
||||
var size = getWindowById(id).getMaximumSize();
|
||||
socket.emit('browserWindow-getMaximumSize-completed', size);
|
||||
socket.on('browserWindowGetMaximumSize', (id) => {
|
||||
const size = getWindowById(id).getMaximumSize();
|
||||
electronSocket.emit('browserWindow-getMaximumSize-completed', size);
|
||||
});
|
||||
socket.on('browserWindowSetResizable', function (id, resizable) {
|
||||
socket.on('browserWindowSetResizable', (id, resizable) => {
|
||||
getWindowById(id).setResizable(resizable);
|
||||
});
|
||||
socket.on('browserWindowIsResizable', function (id) {
|
||||
var resizable = getWindowById(id).isResizable();
|
||||
socket.emit('browserWindow-isResizable-completed', resizable);
|
||||
socket.on('browserWindowIsResizable', (id) => {
|
||||
const resizable = getWindowById(id).isResizable();
|
||||
electronSocket.emit('browserWindow-isResizable-completed', resizable);
|
||||
});
|
||||
socket.on('browserWindowSetMovable', function (id, movable) {
|
||||
socket.on('browserWindowSetMovable', (id, movable) => {
|
||||
getWindowById(id).setMovable(movable);
|
||||
});
|
||||
socket.on('browserWindowIsMovable', function (id) {
|
||||
var movable = getWindowById(id).isMovable();
|
||||
socket.emit('browserWindow-isMovable-completed', movable);
|
||||
socket.on('browserWindowIsMovable', (id) => {
|
||||
const movable = getWindowById(id).isMovable();
|
||||
electronSocket.emit('browserWindow-isMovable-completed', movable);
|
||||
});
|
||||
socket.on('browserWindowSetMinimizable', function (id, minimizable) {
|
||||
socket.on('browserWindowSetMinimizable', (id, minimizable) => {
|
||||
getWindowById(id).setMinimizable(minimizable);
|
||||
});
|
||||
socket.on('browserWindowIsMinimizable', function (id) {
|
||||
var minimizable = getWindowById(id).isMinimizable();
|
||||
socket.emit('browserWindow-isMinimizable-completed', minimizable);
|
||||
socket.on('browserWindowIsMinimizable', (id) => {
|
||||
const minimizable = getWindowById(id).isMinimizable();
|
||||
electronSocket.emit('browserWindow-isMinimizable-completed', minimizable);
|
||||
});
|
||||
socket.on('browserWindowSetMaximizable', function (id, maximizable) {
|
||||
socket.on('browserWindowSetMaximizable', (id, maximizable) => {
|
||||
getWindowById(id).setMaximizable(maximizable);
|
||||
});
|
||||
socket.on('browserWindowIsMaximizable', function (id) {
|
||||
var maximizable = getWindowById(id).isMaximizable();
|
||||
socket.emit('browserWindow-isMaximizable-completed', maximizable);
|
||||
socket.on('browserWindowIsMaximizable', (id) => {
|
||||
const maximizable = getWindowById(id).isMaximizable();
|
||||
electronSocket.emit('browserWindow-isMaximizable-completed', maximizable);
|
||||
});
|
||||
socket.on('browserWindowSetFullScreenable', function (id, fullscreenable) {
|
||||
socket.on('browserWindowSetFullScreenable', (id, fullscreenable) => {
|
||||
getWindowById(id).setFullScreenable(fullscreenable);
|
||||
});
|
||||
socket.on('browserWindowIsFullScreenable', function (id) {
|
||||
var fullscreenable = getWindowById(id).isFullScreenable();
|
||||
socket.emit('browserWindow-isFullScreenable-completed', fullscreenable);
|
||||
socket.on('browserWindowIsFullScreenable', (id) => {
|
||||
const fullscreenable = getWindowById(id).isFullScreenable();
|
||||
electronSocket.emit('browserWindow-isFullScreenable-completed', fullscreenable);
|
||||
});
|
||||
socket.on('browserWindowSetClosable', function (id, closable) {
|
||||
socket.on('browserWindowSetClosable', (id, closable) => {
|
||||
getWindowById(id).setClosable(closable);
|
||||
});
|
||||
socket.on('browserWindowIsClosable', function (id) {
|
||||
var closable = getWindowById(id).isClosable();
|
||||
socket.emit('browserWindow-isClosable-completed', closable);
|
||||
socket.on('browserWindowIsClosable', (id) => {
|
||||
const closable = getWindowById(id).isClosable();
|
||||
electronSocket.emit('browserWindow-isClosable-completed', closable);
|
||||
});
|
||||
socket.on('browserWindowSetAlwaysOnTop', function (id, flag, level, relativeLevel) {
|
||||
socket.on('browserWindowSetAlwaysOnTop', (id, flag, level, relativeLevel) => {
|
||||
getWindowById(id).setAlwaysOnTop(flag, level, relativeLevel);
|
||||
});
|
||||
socket.on('browserWindowIsAlwaysOnTop', function (id) {
|
||||
var isAlwaysOnTop = getWindowById(id).isAlwaysOnTop();
|
||||
socket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop);
|
||||
socket.on('browserWindowIsAlwaysOnTop', (id) => {
|
||||
const isAlwaysOnTop = getWindowById(id).isAlwaysOnTop();
|
||||
electronSocket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop);
|
||||
});
|
||||
socket.on('browserWindowCenter', function (id) {
|
||||
socket.on('browserWindowCenter', (id) => {
|
||||
getWindowById(id).center();
|
||||
});
|
||||
socket.on('browserWindowSetPosition', function (id, x, y, animate) {
|
||||
socket.on('browserWindowSetPosition', (id, x, y, animate) => {
|
||||
getWindowById(id).setPosition(x, y, animate);
|
||||
});
|
||||
socket.on('browserWindowGetPosition', function (id) {
|
||||
var position = getWindowById(id).getPosition();
|
||||
socket.emit('browserWindow-getPosition-completed', position);
|
||||
socket.on('browserWindowGetPosition', (id) => {
|
||||
const position = getWindowById(id).getPosition();
|
||||
electronSocket.emit('browserWindow-getPosition-completed', position);
|
||||
});
|
||||
socket.on('browserWindowSetTitle', function (id, title) {
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
getWindowById(id).setTitle(title);
|
||||
});
|
||||
socket.on('browserWindowGetTitle', function (id) {
|
||||
var title = getWindowById(id).getTitle();
|
||||
socket.emit('browserWindow-getTitle-completed', title);
|
||||
socket.on('browserWindowGetTitle', (id) => {
|
||||
const title = getWindowById(id).getTitle();
|
||||
electronSocket.emit('browserWindow-getTitle-completed', title);
|
||||
});
|
||||
socket.on('browserWindowSetTitle', function (id, title) {
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
getWindowById(id).setTitle(title);
|
||||
});
|
||||
socket.on('browserWindowSetSheetOffset', function (id, offsetY, offsetX) {
|
||||
socket.on('browserWindowSetSheetOffset', (id, offsetY, offsetX) => {
|
||||
if (offsetX) {
|
||||
getWindowById(id).setSheetOffset(offsetY, offsetX);
|
||||
}
|
||||
@@ -382,153 +391,171 @@ module.exports = function (socket, app) {
|
||||
getWindowById(id).setSheetOffset(offsetY);
|
||||
}
|
||||
});
|
||||
socket.on('browserWindowFlashFrame', function (id, flag) {
|
||||
socket.on('browserWindowFlashFrame', (id, flag) => {
|
||||
getWindowById(id).flashFrame(flag);
|
||||
});
|
||||
socket.on('browserWindowSetSkipTaskbar', function (id, skip) {
|
||||
socket.on('browserWindowSetSkipTaskbar', (id, skip) => {
|
||||
getWindowById(id).setSkipTaskbar(skip);
|
||||
});
|
||||
socket.on('browserWindowSetKiosk', function (id, flag) {
|
||||
socket.on('browserWindowSetKiosk', (id, flag) => {
|
||||
getWindowById(id).setKiosk(flag);
|
||||
});
|
||||
socket.on('browserWindowIsKiosk', function (id) {
|
||||
var isKiosk = getWindowById(id).isKiosk();
|
||||
socket.emit('browserWindow-isKiosk-completed', isKiosk);
|
||||
socket.on('browserWindowIsKiosk', (id) => {
|
||||
const isKiosk = getWindowById(id).isKiosk();
|
||||
electronSocket.emit('browserWindow-isKiosk-completed', isKiosk);
|
||||
});
|
||||
socket.on('browserWindowSetRepresentedFilename', function (id, filename) {
|
||||
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
|
||||
getWindowById(id).setRepresentedFilename(filename);
|
||||
});
|
||||
socket.on('browserWindowGetRepresentedFilename', function (id) {
|
||||
var pathname = getWindowById(id).getRepresentedFilename();
|
||||
socket.emit('browserWindow-getRepresentedFilename-completed', pathname);
|
||||
socket.on('browserWindowGetRepresentedFilename', (id) => {
|
||||
const pathname = getWindowById(id).getRepresentedFilename();
|
||||
electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname);
|
||||
});
|
||||
socket.on('browserWindowSetDocumentEdited', function (id, edited) {
|
||||
socket.on('browserWindowSetDocumentEdited', (id, edited) => {
|
||||
getWindowById(id).setDocumentEdited(edited);
|
||||
});
|
||||
socket.on('browserWindowIsDocumentEdited', function (id) {
|
||||
var edited = getWindowById(id).isDocumentEdited();
|
||||
socket.emit('browserWindow-isDocumentEdited-completed', edited);
|
||||
socket.on('browserWindowIsDocumentEdited', (id) => {
|
||||
const edited = getWindowById(id).isDocumentEdited();
|
||||
electronSocket.emit('browserWindow-isDocumentEdited-completed', edited);
|
||||
});
|
||||
socket.on('browserWindowFocusOnWebView', function (id) {
|
||||
socket.on('browserWindowFocusOnWebView', (id) => {
|
||||
getWindowById(id).focusOnWebView();
|
||||
});
|
||||
socket.on('browserWindowBlurWebView', function (id) {
|
||||
socket.on('browserWindowBlurWebView', (id) => {
|
||||
getWindowById(id).blurWebView();
|
||||
});
|
||||
socket.on('browserWindowLoadURL', function (id, url, options) {
|
||||
socket.on('browserWindowLoadURL', (id, url, options) => {
|
||||
getWindowById(id).loadURL(url, options);
|
||||
});
|
||||
socket.on('browserWindowReload', function (id) {
|
||||
socket.on('browserWindowReload', (id) => {
|
||||
getWindowById(id).reload();
|
||||
});
|
||||
socket.on('browserWindowSetMenu', function (id, menuItems) {
|
||||
var menu = null;
|
||||
socket.on('browserWindowSetMenu', (id, menuItems) => {
|
||||
let menu = null;
|
||||
if (menuItems) {
|
||||
menu = electron_1.Menu.buildFromTemplate(menuItems);
|
||||
addMenuItemClickConnector(menu.items, function (id) {
|
||||
socket.emit("windowMenuItemClicked", id);
|
||||
addMenuItemClickConnector(menu.items, (id) => {
|
||||
electronSocket.emit('windowMenuItemClicked', id);
|
||||
});
|
||||
}
|
||||
getWindowById(id).setMenu(menu);
|
||||
});
|
||||
socket.on('browserWindowRemoveMenu', (id) => {
|
||||
getWindowById(id).removeMenu();
|
||||
});
|
||||
function addMenuItemClickConnector(menuItems, callback) {
|
||||
menuItems.forEach(function (item) {
|
||||
menuItems.forEach((item) => {
|
||||
if (item.submenu && item.submenu.items.length > 0) {
|
||||
addMenuItemClickConnector(item.submenu.items, callback);
|
||||
}
|
||||
if ("id" in item && item.id) {
|
||||
item.click = function () { callback(item.id); };
|
||||
if ('id' in item && item.id) {
|
||||
item.click = () => { callback(item.id); };
|
||||
}
|
||||
});
|
||||
}
|
||||
socket.on('browserWindowSetProgressBar', function (id, progress) {
|
||||
socket.on('browserWindowSetProgressBar', (id, progress) => {
|
||||
getWindowById(id).setProgressBar(progress);
|
||||
});
|
||||
socket.on('browserWindowSetHasShadow', function (id, hasShadow) {
|
||||
socket.on('browserWindowSetHasShadow', (id, hasShadow) => {
|
||||
getWindowById(id).setHasShadow(hasShadow);
|
||||
});
|
||||
socket.on('browserWindowHasShadow', function (id) {
|
||||
var hasShadow = getWindowById(id).hasShadow();
|
||||
socket.emit('browserWindow-hasShadow-completed', hasShadow);
|
||||
socket.on('browserWindowHasShadow', (id) => {
|
||||
const hasShadow = getWindowById(id).hasShadow();
|
||||
electronSocket.emit('browserWindow-hasShadow-completed', hasShadow);
|
||||
});
|
||||
socket.on('browserWindowSetThumbarButtons', function (id, thumbarButtons) {
|
||||
thumbarButtons.forEach(function (thumbarButton) {
|
||||
var imagePath = path.join(__dirname.replace('api', ''), 'bin', thumbarButton.icon.toString());
|
||||
socket.on('browserWindowSetThumbarButtons', (id, thumbarButtons) => {
|
||||
thumbarButtons.forEach(thumbarButton => {
|
||||
const imagePath = path.join(__dirname.replace('api', ''), 'bin', thumbarButton.icon.toString());
|
||||
thumbarButton.icon = electron_1.nativeImage.createFromPath(imagePath);
|
||||
thumbarButton.click = function () {
|
||||
socket.emit("thumbarButtonClicked", thumbarButton["id"]);
|
||||
thumbarButton.click = () => {
|
||||
electronSocket.emit('thumbarButtonClicked', thumbarButton['id']);
|
||||
};
|
||||
});
|
||||
var success = getWindowById(id).setThumbarButtons(thumbarButtons);
|
||||
socket.emit('browserWindowSetThumbarButtons-completed', success);
|
||||
const success = getWindowById(id).setThumbarButtons(thumbarButtons);
|
||||
electronSocket.emit('browserWindowSetThumbarButtons-completed', success);
|
||||
});
|
||||
socket.on('browserWindowSetThumbnailClip', function (id, rectangle) {
|
||||
socket.on('browserWindowSetThumbnailClip', (id, rectangle) => {
|
||||
getWindowById(id).setThumbnailClip(rectangle);
|
||||
});
|
||||
socket.on('browserWindowSetThumbnailToolTip', function (id, toolTip) {
|
||||
socket.on('browserWindowSetThumbnailToolTip', (id, toolTip) => {
|
||||
getWindowById(id).setThumbnailToolTip(toolTip);
|
||||
});
|
||||
socket.on('browserWindowSetAppDetails', function (id, options) {
|
||||
socket.on('browserWindowSetAppDetails', (id, options) => {
|
||||
getWindowById(id).setAppDetails(options);
|
||||
});
|
||||
socket.on('browserWindowShowDefinitionForSelection', function (id) {
|
||||
socket.on('browserWindowShowDefinitionForSelection', (id) => {
|
||||
getWindowById(id).showDefinitionForSelection();
|
||||
});
|
||||
socket.on('browserWindowSetAutoHideMenuBar', function (id, hide) {
|
||||
socket.on('browserWindowSetAutoHideMenuBar', (id, hide) => {
|
||||
getWindowById(id).setAutoHideMenuBar(hide);
|
||||
});
|
||||
socket.on('browserWindowIsMenuBarAutoHide', function (id) {
|
||||
var isMenuBarAutoHide = getWindowById(id).isMenuBarAutoHide();
|
||||
socket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide);
|
||||
socket.on('browserWindowIsMenuBarAutoHide', (id) => {
|
||||
const isMenuBarAutoHide = getWindowById(id).isMenuBarAutoHide();
|
||||
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide);
|
||||
});
|
||||
socket.on('browserWindowSetMenuBarVisibility', function (id, visible) {
|
||||
socket.on('browserWindowSetMenuBarVisibility', (id, visible) => {
|
||||
getWindowById(id).setMenuBarVisibility(visible);
|
||||
});
|
||||
socket.on('browserWindowIsMenuBarVisible', function (id) {
|
||||
var isMenuBarVisible = getWindowById(id).isMenuBarVisible();
|
||||
socket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible);
|
||||
socket.on('browserWindowIsMenuBarVisible', (id) => {
|
||||
const isMenuBarVisible = getWindowById(id).isMenuBarVisible();
|
||||
electronSocket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible);
|
||||
});
|
||||
socket.on('browserWindowSetVisibleOnAllWorkspaces', function (id, visible) {
|
||||
socket.on('browserWindowSetVisibleOnAllWorkspaces', (id, visible) => {
|
||||
getWindowById(id).setVisibleOnAllWorkspaces(visible);
|
||||
});
|
||||
socket.on('browserWindowIsVisibleOnAllWorkspaces', function (id) {
|
||||
var isVisibleOnAllWorkspaces = getWindowById(id).isVisibleOnAllWorkspaces();
|
||||
socket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces);
|
||||
socket.on('browserWindowIsVisibleOnAllWorkspaces', (id) => {
|
||||
const isVisibleOnAllWorkspaces = getWindowById(id).isVisibleOnAllWorkspaces();
|
||||
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces);
|
||||
});
|
||||
socket.on('browserWindowSetIgnoreMouseEvents', function (id, ignore) {
|
||||
socket.on('browserWindowSetIgnoreMouseEvents', (id, ignore) => {
|
||||
getWindowById(id).setIgnoreMouseEvents(ignore);
|
||||
});
|
||||
socket.on('browserWindowSetContentProtection', function (id, enable) {
|
||||
socket.on('browserWindowSetContentProtection', (id, enable) => {
|
||||
getWindowById(id).setContentProtection(enable);
|
||||
});
|
||||
socket.on('browserWindowSetFocusable', function (id, focusable) {
|
||||
socket.on('browserWindowSetFocusable', (id, focusable) => {
|
||||
getWindowById(id).setFocusable(focusable);
|
||||
});
|
||||
socket.on('browserWindowSetParentWindow', function (id, parent) {
|
||||
var browserWindow = electron_1.BrowserWindow.fromId(parent.id);
|
||||
socket.on('browserWindowSetParentWindow', (id, parent) => {
|
||||
const browserWindow = electron_1.BrowserWindow.fromId(parent.id);
|
||||
getWindowById(id).setParentWindow(browserWindow);
|
||||
});
|
||||
socket.on('browserWindowGetParentWindow', function (id) {
|
||||
var browserWindow = getWindowById(id).getParentWindow();
|
||||
socket.emit('browserWindow-getParentWindow-completed', browserWindow.id);
|
||||
socket.on('browserWindowGetParentWindow', (id) => {
|
||||
const browserWindow = getWindowById(id).getParentWindow();
|
||||
electronSocket.emit('browserWindow-getParentWindow-completed', browserWindow.id);
|
||||
});
|
||||
socket.on('browserWindowGetChildWindows', function (id) {
|
||||
var browserWindows = getWindowById(id).getChildWindows();
|
||||
var ids = [];
|
||||
browserWindows.forEach(function (x) {
|
||||
socket.on('browserWindowGetChildWindows', (id) => {
|
||||
const browserWindows = getWindowById(id).getChildWindows();
|
||||
const ids = [];
|
||||
browserWindows.forEach(x => {
|
||||
ids.push(x.id);
|
||||
});
|
||||
socket.emit('browserWindow-getChildWindows-completed', ids);
|
||||
electronSocket.emit('browserWindow-getChildWindows-completed', ids);
|
||||
});
|
||||
socket.on('browserWindowSetAutoHideCursor', function (id, autoHide) {
|
||||
socket.on('browserWindowSetAutoHideCursor', (id, autoHide) => {
|
||||
getWindowById(id).setAutoHideCursor(autoHide);
|
||||
});
|
||||
socket.on('browserWindowSetVibrancy', function (id, type) {
|
||||
socket.on('browserWindowSetVibrancy', (id, type) => {
|
||||
getWindowById(id).setVibrancy(type);
|
||||
});
|
||||
socket.on('browserWindowAddExtension', (path) => {
|
||||
const extensionName = electron_1.BrowserWindow.addExtension(path);
|
||||
electronSocket.emit('browserWindow-addExtension-completed', extensionName);
|
||||
});
|
||||
socket.on('browserWindowRemoveExtension', (name) => {
|
||||
electron_1.BrowserWindow.removeExtension(name);
|
||||
});
|
||||
socket.on('browserWindowGetExtensions', () => {
|
||||
const extensionsList = electron_1.BrowserWindow.getExtensions();
|
||||
const chromeExtensionInfo = [];
|
||||
Object.keys(extensionsList).forEach(key => {
|
||||
chromeExtensionInfo.push(extensionsList[key]);
|
||||
});
|
||||
electronSocket.emit('browserWindow-getExtensions-completed', chromeExtensionInfo);
|
||||
});
|
||||
function getWindowById(id) {
|
||||
for (var index = 0; index < windows.length; index++) {
|
||||
var element = windows[index];
|
||||
for (let index = 0; index < windows.length; index++) {
|
||||
const element = windows[index];
|
||||
if (element.id == id) {
|
||||
return element;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,197 +1,212 @@
|
||||
import { BrowserWindow, Menu, nativeImage } from "electron";
|
||||
import { BrowserWindow, Menu, nativeImage } from 'electron';
|
||||
const path = require('path');
|
||||
const windows: Electron.BrowserWindow[] = []
|
||||
let window, lastOptions;
|
||||
const windows: Electron.BrowserWindow[] = [];
|
||||
let window, lastOptions, electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
electronSocket = socket;
|
||||
socket.on('register-browserWindow-ready-to-show', (id) => {
|
||||
getWindowById(id).on('ready-to-show', () => {
|
||||
socket.emit('browserWindow-ready-to-show' + id);
|
||||
electronSocket.emit('browserWindow-ready-to-show' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-page-title-updated', (id) => {
|
||||
getWindowById(id).on('page-title-updated', (event, title) => {
|
||||
socket.emit('browserWindow-page-title-updated' + id, title);
|
||||
electronSocket.emit('browserWindow-page-title-updated' + id, title);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-close', (id) => {
|
||||
getWindowById(id).on('close', () => {
|
||||
socket.emit('browserWindow-close' + id);
|
||||
electronSocket.emit('browserWindow-close' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-closed', (id) => {
|
||||
getWindowById(id).on('closed', () => {
|
||||
socket.emit('browserWindow-closed' + id);
|
||||
electronSocket.emit('browserWindow-closed' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-session-end', (id) => {
|
||||
getWindowById(id).on('session-end', () => {
|
||||
socket.emit('browserWindow-session-end' + id);
|
||||
electronSocket.emit('browserWindow-session-end' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-unresponsive', (id) => {
|
||||
getWindowById(id).on('unresponsive', () => {
|
||||
socket.emit('browserWindow-unresponsive' + id);
|
||||
electronSocket.emit('browserWindow-unresponsive' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-responsive', (id) => {
|
||||
getWindowById(id).on('responsive', () => {
|
||||
socket.emit('browserWindow-responsive' + id);
|
||||
electronSocket.emit('browserWindow-responsive' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-blur', (id) => {
|
||||
getWindowById(id).on('blur', () => {
|
||||
socket.emit('browserWindow-blur' + id);
|
||||
electronSocket.emit('browserWindow-blur' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-focus', (id) => {
|
||||
getWindowById(id).on('focus', () => {
|
||||
socket.emit('browserWindow-focus' + id);
|
||||
electronSocket.emit('browserWindow-focus' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-show', (id) => {
|
||||
getWindowById(id).on('show', () => {
|
||||
socket.emit('browserWindow-show' + id);
|
||||
electronSocket.emit('browserWindow-show' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-hide', (id) => {
|
||||
getWindowById(id).on('hide', () => {
|
||||
socket.emit('browserWindow-hide' + id);
|
||||
electronSocket.emit('browserWindow-hide' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-maximize', (id) => {
|
||||
getWindowById(id).on('maximize', () => {
|
||||
socket.emit('browserWindow-maximize' + id);
|
||||
electronSocket.emit('browserWindow-maximize' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-unmaximize', (id) => {
|
||||
getWindowById(id).on('unmaximize', () => {
|
||||
socket.emit('browserWindow-unmaximize' + id);
|
||||
electronSocket.emit('browserWindow-unmaximize' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-minimize', (id) => {
|
||||
getWindowById(id).on('minimize', () => {
|
||||
socket.emit('browserWindow-minimize' + id);
|
||||
electronSocket.emit('browserWindow-minimize' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-restore', (id) => {
|
||||
getWindowById(id).on('restore', () => {
|
||||
socket.emit('browserWindow-restore' + id);
|
||||
electronSocket.emit('browserWindow-restore' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-resize', (id) => {
|
||||
getWindowById(id).on('resize', () => {
|
||||
socket.emit('browserWindow-resize' + id);
|
||||
electronSocket.emit('browserWindow-resize' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-move', (id) => {
|
||||
getWindowById(id).on('move', () => {
|
||||
socket.emit('browserWindow-move' + id);
|
||||
electronSocket.emit('browserWindow-move' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-moved', (id) => {
|
||||
getWindowById(id).on('moved', () => {
|
||||
socket.emit('browserWindow-moved' + id);
|
||||
electronSocket.emit('browserWindow-moved' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-enter-full-screen', (id) => {
|
||||
getWindowById(id).on('enter-full-screen', () => {
|
||||
socket.emit('browserWindow-enter-full-screen' + id);
|
||||
electronSocket.emit('browserWindow-enter-full-screen' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-leave-full-screen', (id) => {
|
||||
getWindowById(id).on('leave-full-screen', () => {
|
||||
socket.emit('browserWindow-leave-full-screen' + id);
|
||||
electronSocket.emit('browserWindow-leave-full-screen' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-enter-html-full-screen', (id) => {
|
||||
getWindowById(id).on('enter-html-full-screen', () => {
|
||||
socket.emit('browserWindow-enter-html-full-screen' + id);
|
||||
electronSocket.emit('browserWindow-enter-html-full-screen' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-leave-html-full-screen', (id) => {
|
||||
getWindowById(id).on('leave-html-full-screen', () => {
|
||||
socket.emit('browserWindow-leave-html-full-screen' + id);
|
||||
electronSocket.emit('browserWindow-leave-html-full-screen' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-app-command', (id) => {
|
||||
getWindowById(id).on('app-command', (event, command) => {
|
||||
socket.emit('browserWindow-app-command' + id, command);
|
||||
electronSocket.emit('browserWindow-app-command' + id, command);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-scroll-touch-begin', (id) => {
|
||||
getWindowById(id).on('scroll-touch-begin', () => {
|
||||
socket.emit('browserWindow-scroll-touch-begin' + id);
|
||||
electronSocket.emit('browserWindow-scroll-touch-begin' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-scroll-touch-end', (id) => {
|
||||
getWindowById(id).on('scroll-touch-end', () => {
|
||||
socket.emit('browserWindow-scroll-touch-end' + id);
|
||||
electronSocket.emit('browserWindow-scroll-touch-end' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-scroll-touch-edge', (id) => {
|
||||
getWindowById(id).on('scroll-touch-edge', () => {
|
||||
socket.emit('browserWindow-scroll-touch-edge' + id);
|
||||
electronSocket.emit('browserWindow-scroll-touch-edge' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-swipe', (id) => {
|
||||
getWindowById(id).on('swipe', (event, direction) => {
|
||||
socket.emit('browserWindow-swipe' + id, direction);
|
||||
electronSocket.emit('browserWindow-swipe' + id, direction);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-sheet-begin', (id) => {
|
||||
getWindowById(id).on('sheet-begin', () => {
|
||||
socket.emit('browserWindow-sheet-begin' + id);
|
||||
electronSocket.emit('browserWindow-sheet-begin' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-sheet-end', (id) => {
|
||||
getWindowById(id).on('sheet-end', () => {
|
||||
socket.emit('browserWindow-sheet-end' + id);
|
||||
electronSocket.emit('browserWindow-sheet-end' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-new-window-for-tab', (id) => {
|
||||
getWindowById(id).on('new-window-for-tab', () => {
|
||||
socket.emit('browserWindow-new-window-for-tab' + id);
|
||||
electronSocket.emit('browserWindow-new-window-for-tab' + id);
|
||||
});
|
||||
});
|
||||
|
||||
function hasOwnChildreen(obj, ...childNames) {
|
||||
for (let i = 0; i < childNames.length; i++) {
|
||||
if (!obj || !obj.hasOwnProperty(childNames[i])) {
|
||||
return false;
|
||||
}
|
||||
obj = obj[childNames[i]];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
socket.on('createBrowserWindow', (options, loadUrl) => {
|
||||
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
|
||||
options = { ...options, webPreferences: { nodeIntegration: true } };
|
||||
}
|
||||
|
||||
window = new BrowserWindow(options);
|
||||
lastOptions = options;
|
||||
|
||||
window.on('closed', (sender) => {
|
||||
for (var index = 0; index < windows.length; index++) {
|
||||
var windowItem = windows[index];
|
||||
for (let index = 0; index < windows.length; index++) {
|
||||
const windowItem = windows[index];
|
||||
try {
|
||||
windowItem.id;
|
||||
} catch (error) {
|
||||
@@ -200,7 +215,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
const ids = [];
|
||||
windows.forEach(x => ids.push(x.id));
|
||||
socket.emit('BrowserWindowClosed', ids);
|
||||
electronSocket.emit('BrowserWindowClosed', ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,7 +234,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
}
|
||||
|
||||
windows.push(window);
|
||||
socket.emit('BrowserWindowCreated', window.id);
|
||||
electronSocket.emit('BrowserWindowCreated', window.id);
|
||||
});
|
||||
|
||||
socket.on('browserWindowDestroy', (id) => {
|
||||
@@ -241,13 +256,13 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsFocused', (id) => {
|
||||
const isFocused = getWindowById(id).isFocused();
|
||||
|
||||
socket.emit('browserWindow-isFocused-completed', isFocused);
|
||||
electronSocket.emit('browserWindow-isFocused-completed', isFocused);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsDestroyed', (id) => {
|
||||
const isDestroyed = getWindowById(id).isDestroyed();
|
||||
|
||||
socket.emit('browserWindow-isDestroyed-completed', isDestroyed);
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed', isDestroyed);
|
||||
});
|
||||
|
||||
socket.on('browserWindowShow', (id) => {
|
||||
@@ -265,13 +280,13 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsVisible', (id) => {
|
||||
const isVisible = getWindowById(id).isVisible();
|
||||
|
||||
socket.emit('browserWindow-isVisible-completed', isVisible);
|
||||
electronSocket.emit('browserWindow-isVisible-completed', isVisible);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsModal', (id) => {
|
||||
const isModal = getWindowById(id).isModal();
|
||||
|
||||
socket.emit('browserWindow-isModal-completed', isModal);
|
||||
electronSocket.emit('browserWindow-isModal-completed', isModal);
|
||||
});
|
||||
|
||||
socket.on('browserWindowMaximize', (id) => {
|
||||
@@ -285,7 +300,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMaximized', (id) => {
|
||||
const isMaximized = getWindowById(id).isMaximized();
|
||||
|
||||
socket.emit('browserWindow-isMaximized-completed', isMaximized);
|
||||
electronSocket.emit('browserWindow-isMaximized-completed', isMaximized);
|
||||
});
|
||||
|
||||
socket.on('browserWindowMinimize', (id) => {
|
||||
@@ -299,7 +314,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMinimized', (id) => {
|
||||
const isMinimized = getWindowById(id).isMinimized();
|
||||
|
||||
socket.emit('browserWindow-isMinimized-completed', isMinimized);
|
||||
electronSocket.emit('browserWindow-isMinimized-completed', isMinimized);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetFullScreen', (id, fullscreen) => {
|
||||
@@ -309,7 +324,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsFullScreen', (id) => {
|
||||
const isFullScreen = getWindowById(id).isFullScreen();
|
||||
|
||||
socket.emit('browserWindow-isFullScreen-completed', isFullScreen);
|
||||
electronSocket.emit('browserWindow-isFullScreen-completed', isFullScreen);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAspectRatio', (id, aspectRatio, extraSize) => {
|
||||
@@ -331,7 +346,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetBounds', (id) => {
|
||||
const rectangle = getWindowById(id).getBounds();
|
||||
|
||||
socket.emit('browserWindow-getBounds-completed', rectangle);
|
||||
electronSocket.emit('browserWindow-getBounds-completed', rectangle);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetContentBounds', (id, bounds, animate) => {
|
||||
@@ -341,7 +356,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetContentBounds', (id) => {
|
||||
const rectangle = getWindowById(id).getContentBounds();
|
||||
|
||||
socket.emit('browserWindow-getContentBounds-completed', rectangle);
|
||||
electronSocket.emit('browserWindow-getContentBounds-completed', rectangle);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetSize', (id, width, height, animate) => {
|
||||
@@ -351,7 +366,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetSize', (id) => {
|
||||
const size = getWindowById(id).getSize();
|
||||
|
||||
socket.emit('browserWindow-getSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getSize-completed', size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetContentSize', (id, width, height, animate) => {
|
||||
@@ -361,7 +376,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetContentSize', (id) => {
|
||||
const size = getWindowById(id).getContentSize();
|
||||
|
||||
socket.emit('browserWindow-getContentSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getContentSize-completed', size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMinimumSize', (id, width, height) => {
|
||||
@@ -371,7 +386,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetMinimumSize', (id) => {
|
||||
const size = getWindowById(id).getMinimumSize();
|
||||
|
||||
socket.emit('browserWindow-getMinimumSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getMinimumSize-completed', size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMaximumSize', (id, width, height) => {
|
||||
@@ -381,7 +396,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetMaximumSize', (id) => {
|
||||
const size = getWindowById(id).getMaximumSize();
|
||||
|
||||
socket.emit('browserWindow-getMaximumSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getMaximumSize-completed', size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetResizable', (id, resizable) => {
|
||||
@@ -391,7 +406,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsResizable', (id) => {
|
||||
const resizable = getWindowById(id).isResizable();
|
||||
|
||||
socket.emit('browserWindow-isResizable-completed', resizable);
|
||||
electronSocket.emit('browserWindow-isResizable-completed', resizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMovable', (id, movable) => {
|
||||
@@ -401,7 +416,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMovable', (id) => {
|
||||
const movable = getWindowById(id).isMovable();
|
||||
|
||||
socket.emit('browserWindow-isMovable-completed', movable);
|
||||
electronSocket.emit('browserWindow-isMovable-completed', movable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMinimizable', (id, minimizable) => {
|
||||
@@ -411,7 +426,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMinimizable', (id) => {
|
||||
const minimizable = getWindowById(id).isMinimizable();
|
||||
|
||||
socket.emit('browserWindow-isMinimizable-completed', minimizable);
|
||||
electronSocket.emit('browserWindow-isMinimizable-completed', minimizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMaximizable', (id, maximizable) => {
|
||||
@@ -421,7 +436,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMaximizable', (id) => {
|
||||
const maximizable = getWindowById(id).isMaximizable();
|
||||
|
||||
socket.emit('browserWindow-isMaximizable-completed', maximizable);
|
||||
electronSocket.emit('browserWindow-isMaximizable-completed', maximizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetFullScreenable', (id, fullscreenable) => {
|
||||
@@ -431,7 +446,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsFullScreenable', (id) => {
|
||||
const fullscreenable = getWindowById(id).isFullScreenable();
|
||||
|
||||
socket.emit('browserWindow-isFullScreenable-completed', fullscreenable);
|
||||
electronSocket.emit('browserWindow-isFullScreenable-completed', fullscreenable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetClosable', (id, closable) => {
|
||||
@@ -441,7 +456,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsClosable', (id) => {
|
||||
const closable = getWindowById(id).isClosable();
|
||||
|
||||
socket.emit('browserWindow-isClosable-completed', closable);
|
||||
electronSocket.emit('browserWindow-isClosable-completed', closable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAlwaysOnTop', (id, flag, level, relativeLevel) => {
|
||||
@@ -451,7 +466,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsAlwaysOnTop', (id) => {
|
||||
const isAlwaysOnTop = getWindowById(id).isAlwaysOnTop();
|
||||
|
||||
socket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop);
|
||||
electronSocket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop);
|
||||
});
|
||||
|
||||
socket.on('browserWindowCenter', (id) => {
|
||||
@@ -465,7 +480,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetPosition', (id) => {
|
||||
const position = getWindowById(id).getPosition();
|
||||
|
||||
socket.emit('browserWindow-getPosition-completed', position);
|
||||
electronSocket.emit('browserWindow-getPosition-completed', position);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
@@ -475,7 +490,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetTitle', (id) => {
|
||||
const title = getWindowById(id).getTitle();
|
||||
|
||||
socket.emit('browserWindow-getTitle-completed', title);
|
||||
electronSocket.emit('browserWindow-getTitle-completed', title);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
@@ -505,7 +520,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsKiosk', (id) => {
|
||||
const isKiosk = getWindowById(id).isKiosk();
|
||||
|
||||
socket.emit('browserWindow-isKiosk-completed', isKiosk);
|
||||
electronSocket.emit('browserWindow-isKiosk-completed', isKiosk);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
|
||||
@@ -515,7 +530,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetRepresentedFilename', (id) => {
|
||||
const pathname = getWindowById(id).getRepresentedFilename();
|
||||
|
||||
socket.emit('browserWindow-getRepresentedFilename-completed', pathname);
|
||||
electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetDocumentEdited', (id, edited) => {
|
||||
@@ -525,7 +540,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsDocumentEdited', (id) => {
|
||||
const edited = getWindowById(id).isDocumentEdited();
|
||||
|
||||
socket.emit('browserWindow-isDocumentEdited-completed', edited);
|
||||
electronSocket.emit('browserWindow-isDocumentEdited-completed', edited);
|
||||
});
|
||||
|
||||
socket.on('browserWindowFocusOnWebView', (id) => {
|
||||
@@ -551,20 +566,24 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
menu = Menu.buildFromTemplate(menuItems);
|
||||
|
||||
addMenuItemClickConnector(menu.items, (id) => {
|
||||
socket.emit("windowMenuItemClicked", id);
|
||||
electronSocket.emit('windowMenuItemClicked', id);
|
||||
});
|
||||
}
|
||||
|
||||
getWindowById(id).setMenu(menu);
|
||||
});
|
||||
|
||||
socket.on('browserWindowRemoveMenu', (id) => {
|
||||
getWindowById(id).removeMenu();
|
||||
});
|
||||
|
||||
function addMenuItemClickConnector(menuItems, callback) {
|
||||
menuItems.forEach((item) => {
|
||||
if (item.submenu && item.submenu.items.length > 0) {
|
||||
addMenuItemClickConnector(item.submenu.items, callback);
|
||||
}
|
||||
|
||||
if ("id" in item && item.id) {
|
||||
if ('id' in item && item.id) {
|
||||
item.click = () => { callback(item.id); };
|
||||
}
|
||||
});
|
||||
@@ -581,7 +600,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowHasShadow', (id) => {
|
||||
const hasShadow = getWindowById(id).hasShadow();
|
||||
|
||||
socket.emit('browserWindow-hasShadow-completed', hasShadow);
|
||||
electronSocket.emit('browserWindow-hasShadow-completed', hasShadow);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetThumbarButtons', (id, thumbarButtons: Electron.ThumbarButton[]) => {
|
||||
@@ -589,12 +608,12 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
const imagePath = path.join(__dirname.replace('api', ''), 'bin', thumbarButton.icon.toString());
|
||||
thumbarButton.icon = nativeImage.createFromPath(imagePath);
|
||||
thumbarButton.click = () => {
|
||||
socket.emit("thumbarButtonClicked", thumbarButton["id"]);
|
||||
electronSocket.emit('thumbarButtonClicked', thumbarButton['id']);
|
||||
};
|
||||
});
|
||||
|
||||
const success = getWindowById(id).setThumbarButtons(thumbarButtons);
|
||||
socket.emit('browserWindowSetThumbarButtons-completed', success);
|
||||
electronSocket.emit('browserWindowSetThumbarButtons-completed', success);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetThumbnailClip', (id, rectangle) => {
|
||||
@@ -620,7 +639,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMenuBarAutoHide', (id) => {
|
||||
const isMenuBarAutoHide = getWindowById(id).isMenuBarAutoHide();
|
||||
|
||||
socket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide);
|
||||
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMenuBarVisibility', (id, visible) => {
|
||||
@@ -630,7 +649,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsMenuBarVisible', (id) => {
|
||||
const isMenuBarVisible = getWindowById(id).isMenuBarVisible();
|
||||
|
||||
socket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible);
|
||||
electronSocket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetVisibleOnAllWorkspaces', (id, visible) => {
|
||||
@@ -640,7 +659,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowIsVisibleOnAllWorkspaces', (id) => {
|
||||
const isVisibleOnAllWorkspaces = getWindowById(id).isVisibleOnAllWorkspaces();
|
||||
|
||||
socket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces);
|
||||
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetIgnoreMouseEvents', (id, ignore) => {
|
||||
@@ -664,7 +683,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
socket.on('browserWindowGetParentWindow', (id) => {
|
||||
const browserWindow = getWindowById(id).getParentWindow();
|
||||
|
||||
socket.emit('browserWindow-getParentWindow-completed', browserWindow.id);
|
||||
electronSocket.emit('browserWindow-getParentWindow-completed', browserWindow.id);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetChildWindows', (id) => {
|
||||
@@ -674,9 +693,9 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
|
||||
browserWindows.forEach(x => {
|
||||
ids.push(x.id);
|
||||
})
|
||||
});
|
||||
|
||||
socket.emit('browserWindow-getChildWindows-completed', ids);
|
||||
electronSocket.emit('browserWindow-getChildWindows-completed', ids);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAutoHideCursor', (id, autoHide) => {
|
||||
@@ -687,12 +706,33 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
getWindowById(id).setVibrancy(type);
|
||||
});
|
||||
|
||||
socket.on('browserWindowAddExtension', (path) => {
|
||||
const extensionName = BrowserWindow.addExtension(path);
|
||||
|
||||
electronSocket.emit('browserWindow-addExtension-completed', extensionName);
|
||||
});
|
||||
|
||||
socket.on('browserWindowRemoveExtension', (name) => {
|
||||
BrowserWindow.removeExtension(name);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetExtensions', () => {
|
||||
const extensionsList = BrowserWindow.getExtensions();
|
||||
const chromeExtensionInfo = [];
|
||||
|
||||
Object.keys(extensionsList).forEach(key => {
|
||||
chromeExtensionInfo.push(extensionsList[key]);
|
||||
});
|
||||
|
||||
electronSocket.emit('browserWindow-getExtensions-completed', chromeExtensionInfo);
|
||||
});
|
||||
|
||||
function getWindowById(id: number): Electron.BrowserWindow {
|
||||
for (var index = 0; index < windows.length; index++) {
|
||||
var element = windows[index];
|
||||
for (let index = 0; index < windows.length; index++) {
|
||||
const element = windows[index];
|
||||
if (element.id == id) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,49 +1,51 @@
|
||||
"use strict";
|
||||
var electron_1 = require("electron");
|
||||
module.exports = function (socket) {
|
||||
socket.on('clipboard-readText', function (type) {
|
||||
var text = electron_1.clipboard.readText(type);
|
||||
socket.emit('clipboard-readText-Completed', text);
|
||||
const electron_1 = require("electron");
|
||||
let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('clipboard-readText', (type) => {
|
||||
const text = electron_1.clipboard.readText(type);
|
||||
electronSocket.emit('clipboard-readText-Completed', text);
|
||||
});
|
||||
socket.on('clipboard-writeText', function (text, type) {
|
||||
socket.on('clipboard-writeText', (text, type) => {
|
||||
electron_1.clipboard.writeText(text, type);
|
||||
});
|
||||
socket.on('clipboard-readHTML', function (type) {
|
||||
var content = electron_1.clipboard.readHTML(type);
|
||||
socket.emit('clipboard-readHTML-Completed', content);
|
||||
socket.on('clipboard-readHTML', (type) => {
|
||||
const content = electron_1.clipboard.readHTML(type);
|
||||
electronSocket.emit('clipboard-readHTML-Completed', content);
|
||||
});
|
||||
socket.on('clipboard-writeHTML', function (markup, type) {
|
||||
socket.on('clipboard-writeHTML', (markup, type) => {
|
||||
electron_1.clipboard.writeHTML(markup, type);
|
||||
});
|
||||
socket.on('clipboard-readRTF', function (type) {
|
||||
var content = electron_1.clipboard.readRTF(type);
|
||||
socket.emit('clipboard-readRTF-Completed', content);
|
||||
socket.on('clipboard-readRTF', (type) => {
|
||||
const content = electron_1.clipboard.readRTF(type);
|
||||
electronSocket.emit('clipboard-readRTF-Completed', content);
|
||||
});
|
||||
socket.on('clipboard-writeRTF', function (text, type) {
|
||||
socket.on('clipboard-writeRTF', (text, type) => {
|
||||
electron_1.clipboard.writeHTML(text, type);
|
||||
});
|
||||
socket.on('clipboard-readBookmark', function () {
|
||||
var bookmark = electron_1.clipboard.readBookmark();
|
||||
socket.emit('clipboard-readBookmark-Completed', bookmark);
|
||||
socket.on('clipboard-readBookmark', () => {
|
||||
const bookmark = electron_1.clipboard.readBookmark();
|
||||
electronSocket.emit('clipboard-readBookmark-Completed', bookmark);
|
||||
});
|
||||
socket.on('clipboard-writeBookmark', function (title, url, type) {
|
||||
socket.on('clipboard-writeBookmark', (title, url, type) => {
|
||||
electron_1.clipboard.writeBookmark(title, url, type);
|
||||
});
|
||||
socket.on('clipboard-readFindText', function () {
|
||||
var content = electron_1.clipboard.readFindText();
|
||||
socket.emit('clipboard-readFindText-Completed', content);
|
||||
socket.on('clipboard-readFindText', () => {
|
||||
const content = electron_1.clipboard.readFindText();
|
||||
electronSocket.emit('clipboard-readFindText-Completed', content);
|
||||
});
|
||||
socket.on('clipboard-writeFindText', function (text) {
|
||||
socket.on('clipboard-writeFindText', (text) => {
|
||||
electron_1.clipboard.writeFindText(text);
|
||||
});
|
||||
socket.on('clipboard-clear', function (type) {
|
||||
socket.on('clipboard-clear', (type) => {
|
||||
electron_1.clipboard.clear(type);
|
||||
});
|
||||
socket.on('clipboard-availableFormats', function (type) {
|
||||
var formats = electron_1.clipboard.availableFormats(type);
|
||||
socket.emit('clipboard-availableFormats-Completed', formats);
|
||||
socket.on('clipboard-availableFormats', (type) => {
|
||||
const formats = electron_1.clipboard.availableFormats(type);
|
||||
electronSocket.emit('clipboard-availableFormats-Completed', formats);
|
||||
});
|
||||
socket.on('clipboard-write', function (data, type) {
|
||||
socket.on('clipboard-write', (data, type) => {
|
||||
electron_1.clipboard.write(data, type);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"clipboard.js","sourceRoot":"","sources":["clipboard.ts"],"names":[],"mappings":";AAAA,qCAAqC;AAErC,iBAAS,UAAC,MAAuB;IAE7B,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAC,IAAI;QACjC,IAAM,IAAI,GAAG,oBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,qBAAqB,EAAE,UAAC,IAAI,EAAE,IAAI;QACxC,oBAAS,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAC,IAAI;QACjC,IAAM,OAAO,GAAG,oBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,8B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IACrE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,EAAE;QAC1C,oBAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE;QAClC,oBAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,CAAC,IAAI,EAAE,EAAE;QAC7C,MAAM,OAAO,GAAG,oBAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACjD,cAAc,CAAC,IAAI,CAAC,sCAAsC,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACxC,oBAAS,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
||||
@@ -1,10 +1,11 @@
|
||||
import { clipboard } from "electron";
|
||||
import { clipboard } from 'electron';
|
||||
let electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket) => {
|
||||
|
||||
electronSocket = socket;
|
||||
socket.on('clipboard-readText', (type) => {
|
||||
const text = clipboard.readText(type);
|
||||
socket.emit('clipboard-readText-Completed', text);
|
||||
electronSocket.emit('clipboard-readText-Completed', text);
|
||||
});
|
||||
|
||||
socket.on('clipboard-writeText', (text, type) => {
|
||||
@@ -13,7 +14,7 @@ export = (socket: SocketIO.Socket) => {
|
||||
|
||||
socket.on('clipboard-readHTML', (type) => {
|
||||
const content = clipboard.readHTML(type);
|
||||
socket.emit('clipboard-readHTML-Completed', content);
|
||||
electronSocket.emit('clipboard-readHTML-Completed', content);
|
||||
});
|
||||
|
||||
socket.on('clipboard-writeHTML', (markup, type) => {
|
||||
@@ -22,7 +23,7 @@ export = (socket: SocketIO.Socket) => {
|
||||
|
||||
socket.on('clipboard-readRTF', (type) => {
|
||||
const content = clipboard.readRTF(type);
|
||||
socket.emit('clipboard-readRTF-Completed', content);
|
||||
electronSocket.emit('clipboard-readRTF-Completed', content);
|
||||
});
|
||||
|
||||
socket.on('clipboard-writeRTF', (text, type) => {
|
||||
@@ -31,7 +32,7 @@ export = (socket: SocketIO.Socket) => {
|
||||
|
||||
socket.on('clipboard-readBookmark', () => {
|
||||
const bookmark = clipboard.readBookmark();
|
||||
socket.emit('clipboard-readBookmark-Completed', bookmark);
|
||||
electronSocket.emit('clipboard-readBookmark-Completed', bookmark);
|
||||
});
|
||||
|
||||
socket.on('clipboard-writeBookmark', (title, url, type) => {
|
||||
@@ -40,7 +41,7 @@ export = (socket: SocketIO.Socket) => {
|
||||
|
||||
socket.on('clipboard-readFindText', () => {
|
||||
const content = clipboard.readFindText();
|
||||
socket.emit('clipboard-readFindText-Completed', content);
|
||||
electronSocket.emit('clipboard-readFindText-Completed', content);
|
||||
});
|
||||
|
||||
socket.on('clipboard-writeFindText', (text) => {
|
||||
@@ -53,10 +54,10 @@ export = (socket: SocketIO.Socket) => {
|
||||
|
||||
socket.on('clipboard-availableFormats', (type) => {
|
||||
const formats = clipboard.availableFormats(type);
|
||||
socket.emit('clipboard-availableFormats-Completed', formats);
|
||||
electronSocket.emit('clipboard-availableFormats-Completed', formats);
|
||||
});
|
||||
|
||||
socket.on('clipboard-write', (data, type) => {
|
||||
clipboard.write(data, type);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
20
ElectronNET.Host/api/commandLine.js
Normal file
20
ElectronNET.Host/api/commandLine.js
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
let electronSocket;
|
||||
module.exports = (socket, app) => {
|
||||
electronSocket = socket;
|
||||
socket.on('appCommandLineAppendSwitch', (the_switch, value) => {
|
||||
app.commandLine.appendSwitch(the_switch, value);
|
||||
});
|
||||
socket.on('appCommandLineAppendArgument', (value) => {
|
||||
app.commandLine.appendArgument(value);
|
||||
});
|
||||
socket.on('appCommandLineHasSwitch', (value) => {
|
||||
const hasSwitch = app.commandLine.hasSwitch(value);
|
||||
electronSocket.emit('appCommandLineHasSwitchCompleted', hasSwitch);
|
||||
});
|
||||
socket.on('appCommandLineGetSwitchValue', (the_switch) => {
|
||||
const value = app.commandLine.getSwitchValue(the_switch);
|
||||
electronSocket.emit('appCommandLineGetSwitchValueCompleted', value);
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=commandLine.js.map
|
||||
1
ElectronNET.Host/api/commandLine.js.map
Normal file
1
ElectronNET.Host/api/commandLine.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"commandLine.js","sourceRoot":"","sources":["commandLine.ts"],"names":[],"mappings":";AAAA,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,GAAiB,EAAE,EAAE;IACpD,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,CAAC,UAAkB,EAAE,KAAa,EAAE,EAAE;QAC1E,GAAG,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,CAAC,KAAa,EAAE,EAAE;QACxD,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,KAAa,EAAE,EAAE;QACnD,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnD,cAAc,CAAC,IAAI,CAAC,kCAAkC,EAAE,SAAS,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,CAAC,UAAkB,EAAE,EAAE;QAC7D,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACzD,cAAc,CAAC,IAAI,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
||||
23
ElectronNET.Host/api/commandLine.ts
Normal file
23
ElectronNET.Host/api/commandLine.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
let electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
electronSocket = socket;
|
||||
|
||||
socket.on('appCommandLineAppendSwitch', (the_switch: string, value: string) => {
|
||||
app.commandLine.appendSwitch(the_switch, value);
|
||||
});
|
||||
|
||||
socket.on('appCommandLineAppendArgument', (value: string) => {
|
||||
app.commandLine.appendArgument(value);
|
||||
});
|
||||
|
||||
socket.on('appCommandLineHasSwitch', (value: string) => {
|
||||
const hasSwitch = app.commandLine.hasSwitch(value);
|
||||
electronSocket.emit('appCommandLineHasSwitchCompleted', hasSwitch);
|
||||
});
|
||||
|
||||
socket.on('appCommandLineGetSwitchValue', (the_switch: string) => {
|
||||
const value = app.commandLine.getSwitchValue(the_switch);
|
||||
electronSocket.emit('appCommandLineGetSwitchValueCompleted', value);
|
||||
});
|
||||
};
|
||||
@@ -1,41 +1,46 @@
|
||||
"use strict";
|
||||
var electron_1 = require("electron");
|
||||
module.exports = function (socket) {
|
||||
socket.on('showMessageBox', function (browserWindow, options, guid) {
|
||||
if ("id" in browserWindow) {
|
||||
var window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
electron_1.dialog.showMessageBox(window, options, function (response, checkboxChecked) {
|
||||
socket.emit('showMessageBoxComplete' + guid, [response, checkboxChecked]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
var message = browserWindow;
|
||||
var id_1 = guid || options;
|
||||
electron_1.dialog.showMessageBox(browserWindow, function (response, checkboxChecked) {
|
||||
socket.emit('showMessageBoxComplete' + id_1, [response, checkboxChecked]);
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.on('showOpenDialog', function (browserWindow, options, guid) {
|
||||
var window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
electron_1.dialog.showOpenDialog(window, options, function (filePaths) {
|
||||
socket.emit('showOpenDialogComplete' + guid, filePaths || []);
|
||||
});
|
||||
});
|
||||
socket.on('showSaveDialog', function (browserWindow, options, guid) {
|
||||
var window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
electron_1.dialog.showSaveDialog(window, options, function (filename) {
|
||||
socket.emit('showSaveDialogComplete' + guid, filename || '');
|
||||
});
|
||||
});
|
||||
socket.on('showErrorBox', function (title, content) {
|
||||
electron_1.dialog.showErrorBox(title, content);
|
||||
});
|
||||
socket.on('showCertificateTrustDialog', function (browserWindow, options, guid) {
|
||||
var window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
electron_1.dialog.showCertificateTrustDialog(window, options, function () {
|
||||
socket.emit('showCertificateTrustDialogComplete' + guid);
|
||||
});
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
const electron_1 = require("electron");
|
||||
let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('showMessageBox', (browserWindow, options, guid) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
if ('id' in browserWindow) {
|
||||
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
const messageBoxReturnValue = yield electron_1.dialog.showMessageBox(window, options);
|
||||
electronSocket.emit('showMessageBoxComplete' + guid, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
|
||||
}
|
||||
else {
|
||||
const id = guid || options;
|
||||
const messageBoxReturnValue = yield electron_1.dialog.showMessageBox(browserWindow);
|
||||
electronSocket.emit('showMessageBoxComplete' + id, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
|
||||
}
|
||||
}));
|
||||
socket.on('showOpenDialog', (browserWindow, options, guid) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
const openDialogReturnValue = yield electron_1.dialog.showOpenDialog(window, options);
|
||||
electronSocket.emit('showOpenDialogComplete' + guid, openDialogReturnValue.filePaths || []);
|
||||
}));
|
||||
socket.on('showSaveDialog', (browserWindow, options, guid) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
const saveDialogReturnValue = yield electron_1.dialog.showSaveDialog(window, options);
|
||||
electronSocket.emit('showSaveDialogComplete' + guid, saveDialogReturnValue.filePath || '');
|
||||
}));
|
||||
socket.on('showErrorBox', (title, content) => {
|
||||
electron_1.dialog.showErrorBox(title, content);
|
||||
});
|
||||
socket.on('showCertificateTrustDialog', (browserWindow, options, guid) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
yield electron_1.dialog.showCertificateTrustDialog(window, options);
|
||||
electronSocket.emit('showCertificateTrustDialogComplete' + guid);
|
||||
}));
|
||||
};
|
||||
//# sourceMappingURL=dialog.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["dialog.ts"],"names":[],"mappings":";AAAA,qCAAiD;AAEjD,iBAAS,UAAC,MAAuB;IAC7B,MAAM,CAAC,EAAE,CAAC,gBAAgB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ACzC,iBAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,CAAO,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAC3E,MAAM,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACtD,MAAM,iBAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAEzD,cAAc,CAAC,IAAI,CAAC,oCAAoC,GAAG,IAAI,CAAC,CAAC;IACrE,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CAAC"}
|
||||
@@ -1,44 +1,44 @@
|
||||
import { BrowserWindow, dialog } from "electron";
|
||||
import { BrowserWindow, dialog } from 'electron';
|
||||
let electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket) => {
|
||||
socket.on('showMessageBox', (browserWindow, options, guid) => {
|
||||
if ("id" in browserWindow) {
|
||||
var window = BrowserWindow.fromId(browserWindow.id);
|
||||
electronSocket = socket;
|
||||
socket.on('showMessageBox', async (browserWindow, options, guid) => {
|
||||
if ('id' in browserWindow) {
|
||||
const window = BrowserWindow.fromId(browserWindow.id);
|
||||
|
||||
dialog.showMessageBox(window, options, (response, checkboxChecked) => {
|
||||
socket.emit('showMessageBoxComplete' + guid, [response, checkboxChecked]);
|
||||
});
|
||||
const messageBoxReturnValue = await dialog.showMessageBox(window, options);
|
||||
electronSocket.emit('showMessageBoxComplete' + guid, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
|
||||
} else {
|
||||
var message = browserWindow;
|
||||
let id = guid || options;
|
||||
dialog.showMessageBox(browserWindow, (response, checkboxChecked) => {
|
||||
socket.emit('showMessageBoxComplete' + id, [response, checkboxChecked]);
|
||||
});
|
||||
const id = guid || options;
|
||||
const messageBoxReturnValue = await dialog.showMessageBox(browserWindow);
|
||||
|
||||
electronSocket.emit('showMessageBoxComplete' + id, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('showOpenDialog', (browserWindow, options, guid) => {
|
||||
var window = BrowserWindow.fromId(browserWindow.id);
|
||||
dialog.showOpenDialog(window, options, (filePaths) => {
|
||||
socket.emit('showOpenDialogComplete' + guid, filePaths || []);
|
||||
});
|
||||
socket.on('showOpenDialog', async (browserWindow, options, guid) => {
|
||||
const window = BrowserWindow.fromId(browserWindow.id);
|
||||
const openDialogReturnValue = await dialog.showOpenDialog(window, options);
|
||||
|
||||
electronSocket.emit('showOpenDialogComplete' + guid, openDialogReturnValue.filePaths || []);
|
||||
});
|
||||
|
||||
socket.on('showSaveDialog', (browserWindow, options, guid) => {
|
||||
var window = BrowserWindow.fromId(browserWindow.id);
|
||||
dialog.showSaveDialog(window, options, (filename) => {
|
||||
socket.emit('showSaveDialogComplete' + guid, filename || '');
|
||||
});
|
||||
socket.on('showSaveDialog', async (browserWindow, options, guid) => {
|
||||
const window = BrowserWindow.fromId(browserWindow.id);
|
||||
const saveDialogReturnValue = await dialog.showSaveDialog(window, options);
|
||||
|
||||
electronSocket.emit('showSaveDialogComplete' + guid, saveDialogReturnValue.filePath || '');
|
||||
});
|
||||
|
||||
socket.on('showErrorBox', (title, content) => {
|
||||
dialog.showErrorBox(title, content);
|
||||
});
|
||||
|
||||
socket.on('showCertificateTrustDialog', (browserWindow, options, guid) => {
|
||||
var window = BrowserWindow.fromId(browserWindow.id);
|
||||
dialog.showCertificateTrustDialog(window, options, () => {
|
||||
socket.emit('showCertificateTrustDialogComplete' + guid);
|
||||
});
|
||||
socket.on('showCertificateTrustDialog', async (browserWindow, options, guid) => {
|
||||
const window = BrowserWindow.fromId(browserWindow.id);
|
||||
await dialog.showCertificateTrustDialog(window, options);
|
||||
|
||||
electronSocket.emit('showCertificateTrustDialogComplete' + guid);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
"use strict";
|
||||
var electron_1 = require("electron");
|
||||
module.exports = function (socket) {
|
||||
socket.on('globalShortcut-register', function (accelerator) {
|
||||
electron_1.globalShortcut.register(accelerator, function () {
|
||||
socket.emit('globalShortcut-pressed', accelerator);
|
||||
const electron_1 = require("electron");
|
||||
let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('globalShortcut-register', (accelerator) => {
|
||||
electron_1.globalShortcut.register(accelerator, () => {
|
||||
electronSocket.emit('globalShortcut-pressed', accelerator);
|
||||
});
|
||||
});
|
||||
socket.on('globalShortcut-isRegistered', function (accelerator) {
|
||||
var isRegistered = electron_1.globalShortcut.isRegistered(accelerator);
|
||||
socket.emit('globalShortcut-isRegisteredCompleted', isRegistered);
|
||||
socket.on('globalShortcut-isRegistered', (accelerator) => {
|
||||
const isRegistered = electron_1.globalShortcut.isRegistered(accelerator);
|
||||
electronSocket.emit('globalShortcut-isRegisteredCompleted', isRegistered);
|
||||
});
|
||||
socket.on('globalShortcut-unregister', function (accelerator) {
|
||||
socket.on('globalShortcut-unregister', (accelerator) => {
|
||||
electron_1.globalShortcut.unregister(accelerator);
|
||||
});
|
||||
socket.on('globalShortcut-unregisterAll', function () {
|
||||
socket.on('globalShortcut-unregisterAll', () => {
|
||||
try {
|
||||
electron_1.globalShortcut.unregisterAll();
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"globalShortcut.js","sourceRoot":"","sources":["globalShortcut.ts"],"names":[],"mappings":";AAAA,qCAA0C;AAE1C,iBAAS,UAAC,MAAuB;IAC7B,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,UAAC,WAAW;QAC7C,yBAAc,CAAC,QAAQ,CAAC,WAAW,EAAE;YACjC,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,6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CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QAC3C,IAAI;YACA,yBAAc,CAAC,aAAa,EAAE,CAAC;SAClC;QAAC,OAAO,KAAK,EAAE,GAAG;IACvB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
||||
@@ -1,16 +1,18 @@
|
||||
import { globalShortcut } from "electron";
|
||||
import { globalShortcut } from 'electron';
|
||||
let electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('globalShortcut-register', (accelerator) => {
|
||||
globalShortcut.register(accelerator, () => {
|
||||
socket.emit('globalShortcut-pressed', accelerator);
|
||||
electronSocket.emit('globalShortcut-pressed', accelerator);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('globalShortcut-isRegistered', (accelerator) => {
|
||||
const isRegistered = globalShortcut.isRegistered(accelerator);
|
||||
|
||||
socket.emit('globalShortcut-isRegisteredCompleted', isRegistered);
|
||||
electronSocket.emit('globalShortcut-isRegisteredCompleted', isRegistered);
|
||||
});
|
||||
|
||||
socket.on('globalShortcut-unregister', (accelerator) => {
|
||||
@@ -19,7 +21,7 @@ export = (socket: SocketIO.Socket) => {
|
||||
|
||||
socket.on('globalShortcut-unregisterAll', () => {
|
||||
try {
|
||||
globalShortcut.unregisterAll();
|
||||
globalShortcut.unregisterAll();
|
||||
} catch (error) { }
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,38 +1,35 @@
|
||||
"use strict";
|
||||
var electron_1 = require("electron");
|
||||
module.exports = function (socket) {
|
||||
socket.on('registerIpcMainChannel', function (channel) {
|
||||
electron_1.ipcMain.on(channel, function (event, args) {
|
||||
socket.emit(channel, [event.preventDefault(), args]);
|
||||
const electron_1 = require("electron");
|
||||
let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('registerIpcMainChannel', (channel) => {
|
||||
electron_1.ipcMain.on(channel, (event, args) => {
|
||||
electronSocket.emit(channel, [event.preventDefault(), args]);
|
||||
});
|
||||
});
|
||||
socket.on('registerSyncIpcMainChannel', function (channel) {
|
||||
electron_1.ipcMain.on(channel, function (event, args) {
|
||||
var x = socket;
|
||||
socket.on('registerSyncIpcMainChannel', (channel) => {
|
||||
electron_1.ipcMain.on(channel, (event, args) => {
|
||||
const x = socket;
|
||||
x.removeAllListeners(channel + 'Sync');
|
||||
socket.on(channel + 'Sync', function (result) {
|
||||
socket.on(channel + 'Sync', (result) => {
|
||||
event.returnValue = result;
|
||||
});
|
||||
socket.emit(channel, [event.preventDefault(), args]);
|
||||
electronSocket.emit(channel, [event.preventDefault(), args]);
|
||||
});
|
||||
});
|
||||
socket.on('registerOnceIpcMainChannel', function (channel) {
|
||||
electron_1.ipcMain.once(channel, function (event, args) {
|
||||
socket.emit(channel, [event.preventDefault(), args]);
|
||||
socket.on('registerOnceIpcMainChannel', (channel) => {
|
||||
electron_1.ipcMain.once(channel, (event, args) => {
|
||||
electronSocket.emit(channel, [event.preventDefault(), args]);
|
||||
});
|
||||
});
|
||||
socket.on('removeAllListenersIpcMainChannel', function (channel) {
|
||||
socket.on('removeAllListenersIpcMainChannel', (channel) => {
|
||||
electron_1.ipcMain.removeAllListeners(channel);
|
||||
});
|
||||
socket.on('sendToIpcRenderer', function (browserWindow, channel) {
|
||||
var data = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
data[_i - 2] = arguments[_i];
|
||||
}
|
||||
var _a;
|
||||
var window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
socket.on('sendToIpcRenderer', (browserWindow, channel, ...data) => {
|
||||
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
if (window) {
|
||||
(_a = window.webContents).send.apply(_a, [channel].concat(data));
|
||||
window.webContents.send(channel, ...data);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"ip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C,WAAW,GAAG,MAAM,CAAC;YAC/B,CAAC,CAAC,CAAC;YAEH,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,CAAC,OAAO,EAAE,EAAE;QAChD,kBAAO,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAClC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,kCAAkC,EAAE,CAAC,OAAO,EAAE,EAAE;QACtD,kBAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE;QAC/D,MAAM,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QAEtD,IAAI,MAAM,EAAE;YACR,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;SAC7C;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
||||
@@ -1,27 +1,29 @@
|
||||
import { ipcMain, BrowserWindow } from 'electron';
|
||||
let electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('registerIpcMainChannel', (channel) => {
|
||||
ipcMain.on(channel, (event, args) => {
|
||||
socket.emit(channel, [event.preventDefault(), args]);
|
||||
electronSocket.emit(channel, [event.preventDefault(), args]);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('registerSyncIpcMainChannel', (channel) => {
|
||||
ipcMain.on(channel, (event, args) => {
|
||||
let x = <any>socket;
|
||||
const x = <any>socket;
|
||||
x.removeAllListeners(channel + 'Sync');
|
||||
socket.on(channel + 'Sync', (result) => {
|
||||
event.returnValue = result;
|
||||
});
|
||||
|
||||
socket.emit(channel, [event.preventDefault(), args]);
|
||||
electronSocket.emit(channel, [event.preventDefault(), args]);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('registerOnceIpcMainChannel', (channel) => {
|
||||
ipcMain.once(channel, (event, args) => {
|
||||
socket.emit(channel, [event.preventDefault(), args]);
|
||||
electronSocket.emit(channel, [event.preventDefault(), args]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,9 +33,9 @@ export = (socket: SocketIO.Socket) => {
|
||||
|
||||
socket.on('sendToIpcRenderer', (browserWindow, channel, ...data) => {
|
||||
const window = BrowserWindow.fromId(browserWindow.id);
|
||||
|
||||
|
||||
if (window) {
|
||||
window.webContents.send(channel, ...data);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
"use strict";
|
||||
var electron_1 = require("electron");
|
||||
var contextMenuItems = [];
|
||||
module.exports = function (socket) {
|
||||
socket.on('menu-setContextMenu', function (browserWindowId, menuItems) {
|
||||
var menu = electron_1.Menu.buildFromTemplate(menuItems);
|
||||
addContextMenuItemClickConnector(menu.items, browserWindowId, function (id, browserWindowId) {
|
||||
socket.emit("contextMenuItemClicked", [id, browserWindowId]);
|
||||
const electron_1 = require("electron");
|
||||
const contextMenuItems = [];
|
||||
let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('menu-setContextMenu', (browserWindowId, menuItems) => {
|
||||
const menu = electron_1.Menu.buildFromTemplate(menuItems);
|
||||
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, browserWindowId) => {
|
||||
electronSocket.emit('contextMenuItemClicked', [id, browserWindowId]);
|
||||
});
|
||||
contextMenuItems.push({
|
||||
menu: menu,
|
||||
@@ -13,37 +15,37 @@ module.exports = function (socket) {
|
||||
});
|
||||
});
|
||||
function addContextMenuItemClickConnector(menuItems, browserWindowId, callback) {
|
||||
menuItems.forEach(function (item) {
|
||||
menuItems.forEach((item) => {
|
||||
if (item.submenu && item.submenu.items.length > 0) {
|
||||
addContextMenuItemClickConnector(item.submenu.items, browserWindowId, callback);
|
||||
}
|
||||
if ("id" in item && item.id) {
|
||||
item.click = function () { callback(item.id, browserWindowId); };
|
||||
if ('id' in item && item.id) {
|
||||
item.click = () => { callback(item.id, browserWindowId); };
|
||||
}
|
||||
});
|
||||
}
|
||||
socket.on('menu-contextMenuPopup', function (browserWindowId) {
|
||||
contextMenuItems.forEach(function (x) {
|
||||
socket.on('menu-contextMenuPopup', (browserWindowId) => {
|
||||
contextMenuItems.forEach(x => {
|
||||
if (x.browserWindowId === browserWindowId) {
|
||||
var browserWindow = electron_1.BrowserWindow.fromId(browserWindowId);
|
||||
const browserWindow = electron_1.BrowserWindow.fromId(browserWindowId);
|
||||
x.menu.popup(browserWindow);
|
||||
}
|
||||
});
|
||||
});
|
||||
socket.on('menu-setApplicationMenu', function (menuItems) {
|
||||
var menu = electron_1.Menu.buildFromTemplate(menuItems);
|
||||
addMenuItemClickConnector(menu.items, function (id) {
|
||||
socket.emit("menuItemClicked", id);
|
||||
socket.on('menu-setApplicationMenu', (menuItems) => {
|
||||
const menu = electron_1.Menu.buildFromTemplate(menuItems);
|
||||
addMenuItemClickConnector(menu.items, (id) => {
|
||||
electronSocket.emit('menuItemClicked', id);
|
||||
});
|
||||
electron_1.Menu.setApplicationMenu(menu);
|
||||
});
|
||||
function addMenuItemClickConnector(menuItems, callback) {
|
||||
menuItems.forEach(function (item) {
|
||||
menuItems.forEach((item) => {
|
||||
if (item.submenu && item.submenu.items.length > 0) {
|
||||
addMenuItemClickConnector(item.submenu.items, callback);
|
||||
}
|
||||
if ("id" in item && item.id) {
|
||||
item.click = function () { callback(item.id); };
|
||||
if ('id' in item && item.id) {
|
||||
item.click = () => { callback(item.id); };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":";AAAA,qCAA+C;AAC/C,IAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,iBAAS,UAAC,MAAuB;IAC7B,MAAM,CAAC,EAAE,CAAC,qBAAqB,EAAE,UAAC,eAAe,EAAE,SAAS;QACxD,IAAM,IAAI,GAAG,eAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAE/C,gCAAgC,CAAC,IAAI,CAAC,KAAK,EAAE,eAAe,EAAE,UAAC,EAAE,EAAE,eAAe;YAC9E,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;QAEH,gBAAgB,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,IAAI;YACV,eAAe,EAAE,eAAe;SACnC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,SAAS,gCAAgC,CAAC,SAAS,EAAE,eAAe,EAAE,QAAQ;QAC1E,SAAS,CAAC,OAAO,CAAC,UAAC,IAAI;YACnB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC/C,gCAAgC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;aACnF;YAED,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE;gBACzB,IAAI,CAAC,KAAK,GAAG,cAAQ,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9D;QACL,CAAC,CAAC,CAAC;IAC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indow } from 'electron';
|
||||
const contextMenuItems = [];
|
||||
let electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('menu-setContextMenu', (browserWindowId, menuItems) => {
|
||||
const menu = Menu.buildFromTemplate(menuItems);
|
||||
|
||||
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, browserWindowId) => {
|
||||
socket.emit("contextMenuItemClicked", [id, browserWindowId]);
|
||||
electronSocket.emit('contextMenuItemClicked', [id, browserWindowId]);
|
||||
});
|
||||
|
||||
contextMenuItems.push({
|
||||
@@ -21,7 +23,7 @@ export = (socket: SocketIO.Socket) => {
|
||||
addContextMenuItemClickConnector(item.submenu.items, browserWindowId, callback);
|
||||
}
|
||||
|
||||
if ("id" in item && item.id) {
|
||||
if ('id' in item && item.id) {
|
||||
item.click = () => { callback(item.id, browserWindowId); };
|
||||
}
|
||||
});
|
||||
@@ -29,8 +31,8 @@ export = (socket: SocketIO.Socket) => {
|
||||
|
||||
socket.on('menu-contextMenuPopup', (browserWindowId) => {
|
||||
contextMenuItems.forEach(x => {
|
||||
if(x.browserWindowId === browserWindowId) {
|
||||
let browserWindow = BrowserWindow.fromId(browserWindowId);
|
||||
if (x.browserWindowId === browserWindowId) {
|
||||
const browserWindow = BrowserWindow.fromId(browserWindowId);
|
||||
x.menu.popup(browserWindow);
|
||||
}
|
||||
});
|
||||
@@ -40,7 +42,7 @@ export = (socket: SocketIO.Socket) => {
|
||||
const menu = Menu.buildFromTemplate(menuItems);
|
||||
|
||||
addMenuItemClickConnector(menu.items, (id) => {
|
||||
socket.emit("menuItemClicked", id);
|
||||
electronSocket.emit('menuItemClicked', id);
|
||||
});
|
||||
|
||||
Menu.setApplicationMenu(menu);
|
||||
@@ -52,9 +54,9 @@ export = (socket: SocketIO.Socket) => {
|
||||
addMenuItemClickConnector(item.submenu.items, callback);
|
||||
}
|
||||
|
||||
if ("id" in item && item.id) {
|
||||
if ('id' in item && item.id) {
|
||||
item.click = () => { callback(item.id); };
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,38 +1,40 @@
|
||||
"use strict";
|
||||
var electron_1 = require("electron");
|
||||
var notifications = [];
|
||||
module.exports = function (socket) {
|
||||
socket.on('createNotification', function (options) {
|
||||
var notification = new electron_1.Notification(options);
|
||||
var haveEvent = false;
|
||||
const electron_1 = require("electron");
|
||||
const notifications = [];
|
||||
let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('createNotification', (options) => {
|
||||
const notification = new electron_1.Notification(options);
|
||||
let haveEvent = false;
|
||||
if (options.showID) {
|
||||
haveEvent = true;
|
||||
notification.on('show', function () {
|
||||
socket.emit('NotificationEventShow', options.showID);
|
||||
notification.on('show', () => {
|
||||
electronSocket.emit('NotificationEventShow', options.showID);
|
||||
});
|
||||
}
|
||||
if (options.clickID) {
|
||||
haveEvent = true;
|
||||
notification.on('click', function () {
|
||||
socket.emit('NotificationEventClick', options.clickID);
|
||||
notification.on('click', () => {
|
||||
electronSocket.emit('NotificationEventClick', options.clickID);
|
||||
});
|
||||
}
|
||||
if (options.closeID) {
|
||||
haveEvent = true;
|
||||
notification.on('close', function () {
|
||||
socket.emit('NotificationEventClose', options.closeID);
|
||||
notification.on('close', () => {
|
||||
electronSocket.emit('NotificationEventClose', options.closeID);
|
||||
});
|
||||
}
|
||||
if (options.replyID) {
|
||||
haveEvent = true;
|
||||
notification.on('reply', function (event, value) {
|
||||
socket.emit('NotificationEventReply', [options.replyID, value]);
|
||||
notification.on('reply', (event, value) => {
|
||||
electronSocket.emit('NotificationEventReply', [options.replyID, value]);
|
||||
});
|
||||
}
|
||||
if (options.actionID) {
|
||||
haveEvent = true;
|
||||
notification.on('action', function (event, value) {
|
||||
socket.emit('NotificationEventAction', [options.actionID, value]);
|
||||
notification.on('action', (event, value) => {
|
||||
electronSocket.emit('NotificationEventAction', [options.actionID, value]);
|
||||
});
|
||||
}
|
||||
if (haveEvent) {
|
||||
@@ -40,9 +42,9 @@ module.exports = function (socket) {
|
||||
}
|
||||
notification.show();
|
||||
});
|
||||
socket.on('notificationIsSupported', function (options) {
|
||||
var isSupported = electron_1.Notification.isSupported;
|
||||
socket.emit('notificationIsSupportedComplete', isSupported);
|
||||
socket.on('notificationIsSupported', () => {
|
||||
const isSupported = electron_1.Notification.isSupported;
|
||||
electronSocket.emit('notificationIsSupportedComplete', isSupported);
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=notification.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"notification.js","sourceRoot":"","sources":["notification.ts"],"names":[],"mappings":";AAAA,qCAAwC;AACxC,IAAM,aAAa,GAA4B,EAAE,CAAC;AAElD,iBAAS,UAAC,MAAuB;IAC7B,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAC,OAAO;QACpC,IAAM,YAAY,GAAG,IAAI,uBAAY,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,IAAG,OAAO,CAAC,MAAM,EAAE;YACf,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE;gBACpB,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;SACN;QAED,IAAG,OAAO,CAAC,OAAO,EAAE;YAChB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE;gBACrB,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;SACN;QAED,IAAG,OAAO,CAAC,OAAO,EAAE;YAChB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE;gBACrB,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,OAAO,CA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AAC,CAAC,CAAC;YAC9E,CAAC,CAAC,CAAC;SACN;QAED,IAAI,SAAS,EAAE;YACX,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACpC;QAED,YAAY,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACtC,MAAM,WAAW,GAAG,uBAAY,CAAC,WAAW,CAAC;QAC7C,cAAc,CAAC,IAAI,CAAC,iCAAiC,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user