mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-04 05:34:51 +00:00
Compare commits
69 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68ee626d07 | ||
|
|
fd5801ffdc | ||
|
|
b6417d0718 | ||
|
|
6f1f7cbc5e | ||
|
|
aec0da6075 | ||
|
|
c9f0c43bc9 | ||
|
|
b87d7f9899 | ||
|
|
fa51cdd72c | ||
|
|
9b270755d0 | ||
|
|
c5db735773 | ||
|
|
88f5995f40 | ||
|
|
042cd7e6cb | ||
|
|
cb096212f9 | ||
|
|
0363dc8924 | ||
|
|
8cf5053512 | ||
|
|
32046adfb5 | ||
|
|
003a9d0d35 | ||
|
|
db6bed43dc | ||
|
|
80d160a71c | ||
|
|
01d938fb1a | ||
|
|
00eb9869dc | ||
|
|
2987e3143d | ||
|
|
20ca72b794 | ||
|
|
a0e0cc3bbc | ||
|
|
e295558258 | ||
|
|
e67f6c500b | ||
|
|
23015a9f3d | ||
|
|
7daac2d04e | ||
|
|
71955b9181 | ||
|
|
a619b6e5c9 | ||
|
|
3ba3fa6414 | ||
|
|
11fbd6b259 | ||
|
|
073eb0e00d | ||
|
|
c0bf257b55 | ||
|
|
62b37d059f | ||
|
|
ca8f4c454c | ||
|
|
d660dff871 | ||
|
|
c17720a4d7 | ||
|
|
274552f52b | ||
|
|
1e3fe6183c | ||
|
|
88b04377a7 | ||
|
|
92356d3587 | ||
|
|
a3c452eea5 | ||
|
|
68288d9d73 | ||
|
|
022221307c | ||
|
|
ffc6353bf2 | ||
|
|
f4d8144a8b | ||
|
|
30d49ff6e8 | ||
|
|
db9d3b1484 | ||
|
|
a788d71530 | ||
|
|
f5e2abfdb4 | ||
|
|
42f09de7b5 | ||
|
|
72d1f4b2b9 | ||
|
|
d2b3c28f91 | ||
|
|
94c4cd82b0 | ||
|
|
600bc1a41b | ||
|
|
4e8e771293 | ||
|
|
4014ef7a4d | ||
|
|
364db7dc25 | ||
|
|
3dda18ac9a | ||
|
|
7f92ffa20e | ||
|
|
eb4144053d | ||
|
|
cafffde339 | ||
|
|
28be0dd209 | ||
|
|
8bf10c370c | ||
|
|
a32b50f86f | ||
|
|
a781234d05 | ||
|
|
8b66bdd7cb | ||
|
|
ba64639c1d |
@@ -1,7 +1,7 @@
|
||||
language: csharp
|
||||
mono: none
|
||||
dist: xenial
|
||||
dotnet: 3.0
|
||||
dotnet: 3.1
|
||||
before_script:
|
||||
- export PATH="$PATH:/home/travis/.dotnet/tools"
|
||||
script:
|
||||
|
||||
75
Changelog.md
75
Changelog.md
@@ -1,13 +1,84 @@
|
||||
# Not released
|
||||
|
||||
# 5.22.15
|
||||
# 8.31.2
|
||||
|
||||
ElectronNET.CLI:
|
||||
* New Feature: Deactivate PublishReadyToRun for build or start [\#395](https://github.com/ElectronNET/Electron.NET/issues/395)
|
||||
|
||||
`electronize build /target win /PublishReadyToRun false`
|
||||
`electronize start /PublishReadyToRun false`
|
||||
* Fixed bug: Application window doesn't open after packaging [\#387](https://github.com/ElectronNET/Electron.NET/issues/387)
|
||||
|
||||
ElectronNET.API:
|
||||
|
||||
* New Feature: Add BrowserWindow.RemoveMenu() (thanks [hack2root](https://github.com/hack2root))
|
||||
* New Feature: NativeImage Support (thanks [ThrDev](https://github.com/ThrDev)) [\#394](https://github.com/ElectronNET/Electron.NET/pull/394)
|
||||
* New Feature: Update menu items for context menu and system tray on-the-fly. [\#270](https://github.com/ElectronNET/Electron.NET/pull/270)
|
||||
|
||||
|
||||
# Released
|
||||
|
||||
# 8.31.1
|
||||
|
||||
ElectronNET.CLI:
|
||||
* New Feature: Set a name and author of the app in `electron.manifest.json` [\#348](https://github.com/ElectronNET/Electron.NET/issues/348#issuecomment-615977950) [\#310](https://github.com/ElectronNET/Electron.NET/issues/310#issuecomment-617361086)
|
||||
* New Feature: Live reload (thanks [syedadeel2](https://github.com/syedadeel2)) [\#390](https://github.com/ElectronNET/Electron.NET/pull/390)
|
||||
`electronize start /watch`
|
||||
* New Feature: Every new window will created with an clear cache [\#273](https://github.com/ElectronNET/Electron.NET/issues/273)
|
||||
`electronize start /clear-cache`
|
||||
|
||||
ElectronNET.API:
|
||||
|
||||
* New Feature: Native Electron 8.2.3 support, but not all new features (we search contributors)
|
||||
* New Feature: We incease the startup time for ~25-36% [\#356](https://github.com/ElectronNET/Electron.NET/issues/356)
|
||||
* New Feature: Added print capability (thanks [x-xx-o](https://github.com/x-xx-o)) [\#355](https://github.com/ElectronNET/Electron.NET/pull/355)
|
||||
* New Feature: BrowserView API [\#371](https://github.com/ElectronNET/Electron.NET/issues/371)
|
||||
* Changed App.GetNameAsync and App.SetNameAsync to the App.Name Property [\#350](https://github.com/ElectronNET/Electron.NET/issues/350)
|
||||
* Fixed bug: Splash Screen disappearing on click [\#357](https://github.com/ElectronNET/Electron.NET/issues/357)
|
||||
* Fixed bug: Start MenuRole enum at 1 (thanks [jjuback](https://github.com/jjuback)) [\#369](https://github.com/ElectronNET/Electron.NET/pull/369)
|
||||
* Fixed bug: BridgeConnector not connected (spam console) [\#347](https://github.com/ElectronNET/Electron.NET/issues/347)
|
||||
* Fixed bug: BrowserWindowOptions is not setting Width and Height properly [\#373](https://github.com/ElectronNET/Electron.NET/issues/373)
|
||||
* Fixed bug: IpcMain.Once(string) is not one time use, is not removing listener [\#366](https://github.com/ElectronNET/Electron.NET/issues/366)
|
||||
* Fixed bug: IpcMain.RemoveAllListeners(string) is not removing the listeners [\#365](https://github.com/ElectronNET/Electron.NET/issues/365)
|
||||
* Fixed bug: GetLoginItemSettingsAsync does not work [\#352](https://github.com/ElectronNET/Electron.NET/issues/352)
|
||||
* Fixed bug: Using OnReadyToShow to display the main window in Blazor does not seem to work with Show set to false [\#361](https://github.com/ElectronNET/Electron.NET/issues/361)
|
||||
* Fixed bug: Unable to disable WebSecurity along with NodeIntegration enabled [\#389](https://github.com/ElectronNET/Electron.NET/issues/389)
|
||||
|
||||
# 7.30.2
|
||||
|
||||
ElectronNET.CLI:
|
||||
|
||||
* New Feature: 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`.
|
||||
|
||||
* New Feature: 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:
|
||||
|
||||
@@ -351,7 +351,44 @@ namespace ElectronNET.API
|
||||
|
||||
private event Action<bool> _accessibilitySupportChanged;
|
||||
|
||||
internal App() { }
|
||||
/// <summary>
|
||||
/// A property that indicates the current application's name, which is the
|
||||
/// name in the application's `package.json` file.
|
||||
///
|
||||
/// Usually the `name` field of `package.json` is a short lowercase name, according
|
||||
/// to the npm modules spec.You should usually also specify a `productName` field,
|
||||
/// which is your application's full capitalized name, and which will be preferred
|
||||
/// over `name` by Electron.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<string>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("appGetNameCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appGetNameCompleted");
|
||||
taskCompletionSource.SetResult((string)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appGetName");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appSetName", value);
|
||||
}
|
||||
}
|
||||
|
||||
internal App()
|
||||
{
|
||||
CommandLine = new CommandLine();
|
||||
}
|
||||
|
||||
internal static App Instance
|
||||
{
|
||||
@@ -548,42 +585,6 @@ namespace ElectronNET.API
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Usually the name field of package.json is a short lowercased name, according to
|
||||
/// the npm modules spec. You should usually also specify a productName field, which
|
||||
/// is your application's full capitalized name, and which will be preferred over
|
||||
/// name by Electron.
|
||||
/// </summary>
|
||||
/// <returns>The current application’s name, which is the name in the application’s package.json file.</returns>
|
||||
public async Task<string> GetNameAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
using(cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appGetNameCompleted", (name) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appGetNameCompleted");
|
||||
taskCompletionSource.SetResult(name.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appGetName");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current application's name.
|
||||
/// </summary>
|
||||
/// <param name="name">Application's name</param>
|
||||
public void SetName(string name)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("appSetName", name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current application locale.
|
||||
/// Note: When distributing your packaged app, you have to also ship the locales
|
||||
@@ -1224,7 +1225,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appSetBadgeCount");
|
||||
BridgeConnector.Socket.Emit("appSetBadgeCount", count);
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
@@ -1255,6 +1256,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>
|
||||
@@ -1295,7 +1301,9 @@ namespace ElectronNET.API
|
||||
BridgeConnector.Socket.On("appGetLoginItemSettingsCompleted", (loginItemSettings) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appGetLoginItemSettingsCompleted");
|
||||
taskCompletionSource.SetResult((LoginItemSettings)loginItemSettings);
|
||||
|
||||
string jsonResult = ((JObject)loginItemSettings).ToString();
|
||||
taskCompletionSource.SetResult(JsonConvert.DeserializeObject<LoginItemSettings>(jsonResult));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("appGetLoginItemSettings");
|
||||
@@ -1380,39 +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>
|
||||
/// 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
|
||||
|
||||
138
ElectronNET.API/BrowserView.cs
Normal file
138
ElectronNET.API/BrowserView.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
|
||||
/// It is like a child window, except that it is positioned relative to its owning window.
|
||||
/// It is meant to be an alternative to the webview tag.
|
||||
/// </summary>
|
||||
public class BrowserView
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the identifier.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The identifier.
|
||||
/// </value>
|
||||
public int Id { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Render and control web pages.
|
||||
/// </summary>
|
||||
public WebContents WebContents { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the view is destroyed.
|
||||
/// </summary>
|
||||
public Task<bool> IsDestroyedAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("browserView-isDestroyed-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserView-isDestroyed-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("browserView-isDestroyed", Id);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resizes and moves the view to the supplied bounds relative to the window.
|
||||
///
|
||||
/// (experimental)
|
||||
/// </summary>
|
||||
public Rectangle Bounds
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<Rectangle>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Rectangle>();
|
||||
|
||||
BridgeConnector.Socket.On("browserView-getBounds-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserView-getBounds-reply");
|
||||
taskCompletionSource.SetResult((Rectangle)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("browserView-getBounds", Id);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
|
||||
}
|
||||
}
|
||||
|
||||
internal Action<BrowserView> Destroyed;
|
||||
|
||||
/// <summary>
|
||||
/// BrowserView
|
||||
/// </summary>
|
||||
internal BrowserView(int id)
|
||||
{
|
||||
Id = id;
|
||||
|
||||
// Workaround: increase the Id so as not to conflict with BrowserWindow id
|
||||
// the backend detect about the value an BrowserView
|
||||
WebContents = new WebContents(id + 1000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Force closing the view, the `unload` and `beforeunload` events won't be emitted
|
||||
/// for the web page.After you're done with a view, call this function in order to
|
||||
/// free memory and other resources as soon as possible.
|
||||
/// </summary>
|
||||
public void Destroy()
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserView-destroy", Id);
|
||||
|
||||
Destroyed?.Invoke(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// (experimental)
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
public void SetAutoResize(AutoResizeOptions options)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color in #aarrggbb or #argb form. The alpha channel is optional.
|
||||
///
|
||||
/// (experimental)
|
||||
/// </summary>
|
||||
/// <param name="color">Color in #aarrggbb or #argb form. The alpha channel is optional.</param>
|
||||
public void SetBackgroundColor(string color)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserView-setBackgroundColor", Id, color);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2305,10 +2305,74 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public WebContents WebContents { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
|
||||
/// It is like a child window, except that it is positioned relative to its owning window.
|
||||
/// It is meant to be an alternative to the webview tag.
|
||||
/// </summary>
|
||||
/// <param name="browserView"></param>
|
||||
public void SetBrowserView(BrowserView browserView)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserWindow-setBrowserView", Id, browserView.Id);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +237,40 @@ namespace ElectronNET.API
|
||||
BridgeConnector.Socket.Emit("clipboard-write", JObject.FromObject(data, _jsonSerializer), type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an image from the clipboard.
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<NativeImage> ReadImageAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<NativeImage>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readImage-Completed", (image) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readImage-Completed");
|
||||
|
||||
var nativeImage = ((JObject)image).ToObject<NativeImage>();
|
||||
|
||||
taskCompletionSource.SetResult(nativeImage);
|
||||
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readImage", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an image to the clipboard.
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="type"></param>
|
||||
public void WriteImage(NativeImage image, string type = "")
|
||||
{
|
||||
BridgeConnector.Socket.Emit("clipboard-writeImage", JsonConvert.SerializeObject(image), type);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageOutputPath>..\artifacts</PackageOutputPath>
|
||||
<PackageId>ElectronNET.API</PackageId>
|
||||
@@ -19,19 +19,7 @@ This package contains the API to access the "native" electron API.</Description>
|
||||
<PackageReleaseNotes>Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md</PackageReleaseNotes>
|
||||
<PackageIcon>PackageIcon.png</PackageIcon>
|
||||
<Version>99.0.0.0</Version>
|
||||
</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\netcoreapp3.0\ElectronNET.API.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>bin\Debug\netcoreapp3.0\ElectronNET.API.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -53,6 +41,7 @@ This package contains the API to access the "native" electron API.</Description>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="SocketIoClientDotNet" Version="1.0.5" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
33
ElectronNET.API/Entities/AddRepresentationOptions.cs
Normal file
33
ElectronNET.API/Entities/AddRepresentationOptions.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class AddRepresentationOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the width
|
||||
/// </summary>
|
||||
public int? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height
|
||||
/// </summary>
|
||||
public int? Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the scalefactor
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the buffer
|
||||
/// </summary>
|
||||
public byte[] Buffer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the dataURL
|
||||
/// </summary>
|
||||
public string DataUrl { get; set; }
|
||||
}
|
||||
}
|
||||
38
ElectronNET.API/Entities/AutoResizeOptions.cs
Normal file
38
ElectronNET.API/Entities/AutoResizeOptions.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class AutoResizeOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// If `true`, the view's width will grow and shrink together with the window.
|
||||
/// `false` by default.
|
||||
/// </summary>
|
||||
[DefaultValue(false)]
|
||||
public bool Width { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// If `true`, the view's height will grow and shrink together with the window.
|
||||
/// `false` by default.
|
||||
/// </summary>
|
||||
[DefaultValue(false)]
|
||||
public bool Height { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// If `true`, the view's x position and width will grow and shrink proportionally
|
||||
/// with the window. `false` by default.
|
||||
/// </summary>
|
||||
[DefaultValue(false)]
|
||||
public bool Horizontal { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// If `true`, the view's y position and height will grow and shrink proportionally
|
||||
/// with the window. `false` by default.
|
||||
/// </summary>
|
||||
[DefaultValue(false)]
|
||||
public bool Vertical { get; set; } = false;
|
||||
}
|
||||
}
|
||||
13
ElectronNET.API/Entities/BitmapOptions.cs
Normal file
13
ElectronNET.API/Entities/BitmapOptions.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class BitmapOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the scale factor
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
}
|
||||
}
|
||||
13
ElectronNET.API/Entities/BrowserViewConstructorOptions.cs
Normal file
13
ElectronNET.API/Entities/BrowserViewConstructorOptions.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class BrowserViewConstructorOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// See BrowserWindow.
|
||||
/// </summary>
|
||||
public WebPreferences WebPreferences { get; set; }
|
||||
}
|
||||
}
|
||||
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; }
|
||||
}
|
||||
}
|
||||
23
ElectronNET.API/Entities/CreateFromBitmapOptions.cs
Normal file
23
ElectronNET.API/Entities/CreateFromBitmapOptions.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CreateFromBitmapOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the width
|
||||
/// </summary>
|
||||
public int? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height
|
||||
/// </summary>
|
||||
public int? Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the scalefactor
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
}
|
||||
}
|
||||
23
ElectronNET.API/Entities/CreateFromBufferOptions.cs
Normal file
23
ElectronNET.API/Entities/CreateFromBufferOptions.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CreateFromBufferOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the width
|
||||
/// </summary>
|
||||
public int? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height
|
||||
/// </summary>
|
||||
public int? Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the scalefactor
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -69,13 +69,11 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// If false, the menu item will be greyed out and unclickable.
|
||||
/// </summary>
|
||||
[DefaultValue(true)]
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// If false, the menu item will be entirely hidden.
|
||||
/// </summary>
|
||||
[DefaultValue(true)]
|
||||
public bool Visible { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// <summary>
|
||||
/// The undo
|
||||
/// </summary>
|
||||
undo,
|
||||
undo = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The redo
|
||||
|
||||
@@ -1,109 +1,453 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
// TODO: Need some of real code :)
|
||||
/// <summary>
|
||||
///
|
||||
/// Native Image handler for Electron.NET
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(NativeImageJsonConverter))]
|
||||
public class NativeImage
|
||||
{
|
||||
// public static NativeImage CreateEmpty()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
private readonly Dictionary<float, Image> _images = new Dictionary<float, Image>();
|
||||
private bool _isTemplateImage;
|
||||
|
||||
// public static NativeImage CreateFromBuffer(byte[] buffer)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
private static readonly Dictionary<string, float> ScaleFactorPairs = new Dictionary<string, float>
|
||||
{
|
||||
{"@2x", 2.0f}, {"@3x", 3.0f}, {"@1x", 1.0f}, {"@4x", 4.0f},
|
||||
{"@5x", 5.0f}, {"@1.25x", 1.25f}, {"@1.33x", 1.33f}, {"@1.4x", 1.4f},
|
||||
{"@1.5x", 1.5f}, {"@1.8x", 1.8f}, {"@2.5x", 2.5f}
|
||||
};
|
||||
|
||||
// public static NativeImage CreateFromBuffer(byte[] buffer, CreateFromBufferOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
private static float? ExtractDpiFromFilePath(string filePath)
|
||||
{
|
||||
var withoutExtension = Path.GetFileNameWithoutExtension(filePath);
|
||||
return ScaleFactorPairs
|
||||
.Where(p => withoutExtension.EndsWith(p.Key))
|
||||
.Select(p => p.Value)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
private static Image BytesToImage(byte[] bytes)
|
||||
{
|
||||
var ms = new MemoryStream(bytes);
|
||||
return Image.FromStream(ms);
|
||||
}
|
||||
|
||||
// public static NativeImage CreateFromDataURL(string dataURL)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
/// <summary>
|
||||
/// Creates an empty NativeImage
|
||||
/// </summary>
|
||||
public static NativeImage CreateEmpty()
|
||||
{
|
||||
return new NativeImage();
|
||||
}
|
||||
|
||||
// public static NativeImage CreateFromPath(string path)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static NativeImage CreateFromBitmap(Bitmap bitmap, CreateFromBitmapOptions options = null)
|
||||
{
|
||||
if (options is null)
|
||||
{
|
||||
options = new CreateFromBitmapOptions();
|
||||
}
|
||||
|
||||
// public void AddRepresentation(AddRepresentationOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
return new NativeImage(bitmap, options.ScaleFactor);
|
||||
}
|
||||
|
||||
// public NativeImage Crop(Rectangle rect)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
/// <summary>
|
||||
/// Creates a NativeImage from a byte array.
|
||||
/// </summary>
|
||||
public static NativeImage CreateFromBuffer(byte[] buffer, CreateFromBufferOptions options = null)
|
||||
{
|
||||
if (options is null)
|
||||
{
|
||||
options = new CreateFromBufferOptions();
|
||||
}
|
||||
|
||||
// public int GetAspectRatio()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
var ms = new MemoryStream(buffer);
|
||||
var image = Image.FromStream(ms);
|
||||
|
||||
// public byte[] GetBitmap()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
return new NativeImage(image, options.ScaleFactor);
|
||||
}
|
||||
|
||||
// public byte[] GetBitmap(BitmapOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
/// <summary>
|
||||
/// Creates a NativeImage from a base64 encoded data URL.
|
||||
/// </summary>
|
||||
/// <param name="dataUrl">A data URL with a base64 encoded image.</param>
|
||||
public static NativeImage CreateFromDataURL(string dataUrl)
|
||||
{
|
||||
var images = new Dictionary<float,Image>();
|
||||
var parsedDataUrl = Regex.Match(dataUrl, @"data:image/(?<type>.+?),(?<data>.+)");
|
||||
var actualData = parsedDataUrl.Groups["data"].Value;
|
||||
var binData = Convert.FromBase64String(actualData);
|
||||
|
||||
// public byte[] GetNativeHandle()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
var image = BytesToImage(binData);
|
||||
|
||||
// public Size GetSize()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
images.Add(1.0f, image);
|
||||
|
||||
// public bool IsEmpty()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
return new NativeImage(images);
|
||||
}
|
||||
|
||||
// public bool IsTemplateImage()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
/// <summary>
|
||||
/// Creates a NativeImage from an image on the disk.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the image</param>
|
||||
public static NativeImage CreateFromPath(string path)
|
||||
{
|
||||
var images = new Dictionary<float,Image>();
|
||||
if (Regex.IsMatch(path, "(@.+?x)"))
|
||||
{
|
||||
var dpi = ExtractDpiFromFilePath(path);
|
||||
if (dpi == null)
|
||||
{
|
||||
throw new Exception($"Invalid scaling factor for '{path}'.");
|
||||
}
|
||||
|
||||
// public NativeImage Resize(ResizeOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
images[dpi.Value] = Image.FromFile(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
|
||||
var extension = Path.GetExtension(path);
|
||||
// Load as 1x dpi
|
||||
images[1.0f] = Image.FromFile(path);
|
||||
|
||||
// public void SetTemplateImage(bool option)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
foreach (var scale in ScaleFactorPairs)
|
||||
{
|
||||
var fileName = $"{fileNameWithoutExtension}{scale}.{extension}";
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
var dpi = ExtractDpiFromFilePath(fileName);
|
||||
if (dpi != null)
|
||||
{
|
||||
images[dpi.Value] = Image.FromFile(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public byte[] ToBitmap(ToBitmapOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
return new NativeImage(images);
|
||||
}
|
||||
|
||||
// public string ToDataURL(ToDataURLOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
/// <summary>
|
||||
/// Creates an empty NativeImage
|
||||
/// </summary>
|
||||
public NativeImage()
|
||||
{
|
||||
}
|
||||
|
||||
// public byte[] ToJPEG(int quality)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
/// <summary>
|
||||
/// Creates a NativeImage from a bitmap and scale factor
|
||||
/// </summary>
|
||||
public NativeImage(Image bitmap, float scaleFactor = 1.0f)
|
||||
{
|
||||
_images.Add(scaleFactor, bitmap);
|
||||
}
|
||||
|
||||
// public byte[] ToPNG(ToPNGOptions options)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
/// <summary>
|
||||
/// Creates a NativeImage from a dictionary of scales and images.
|
||||
/// </summary>
|
||||
public NativeImage(Dictionary<float, Image> imageDictionary)
|
||||
{
|
||||
_images = imageDictionary;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Crops the image specified by the input rectangle and computes scale factor
|
||||
/// </summary>
|
||||
public NativeImage Crop(Rectangle rect)
|
||||
{
|
||||
var images = new Dictionary<float,Image>();
|
||||
foreach (var image in _images)
|
||||
{
|
||||
images.Add(image.Key, Crop(rect.X, rect.Y, rect.Width, rect.Height, image.Key));
|
||||
}
|
||||
|
||||
return new NativeImage(images);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resizes the image and computes scale factor
|
||||
/// </summary>
|
||||
public NativeImage Resize(ResizeOptions options)
|
||||
{
|
||||
var images = new Dictionary<float, Image>();
|
||||
foreach (var image in _images)
|
||||
{
|
||||
images.Add(image.Key, Resize(options.Width, options.Height, image.Key));
|
||||
}
|
||||
|
||||
return new NativeImage(images);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an image representation for a specific scale factor.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
public void AddRepresentation(AddRepresentationOptions options)
|
||||
{
|
||||
if (options.Buffer.Length > 0)
|
||||
{
|
||||
_images[options.ScaleFactor] =
|
||||
CreateFromBuffer(options.Buffer, new CreateFromBufferOptions {ScaleFactor = options.ScaleFactor})
|
||||
.GetScale(options.ScaleFactor);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(options.DataUrl))
|
||||
{
|
||||
_images[options.ScaleFactor] = CreateFromDataURL(options.DataUrl).GetScale(options.ScaleFactor);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the aspect ratio for the image based on scale factor
|
||||
/// </summary>
|
||||
/// <param name="scaleFactor">Optional</param>
|
||||
public float GetAspectRatio(float scaleFactor = 1.0f)
|
||||
{
|
||||
var image = GetScale(scaleFactor);
|
||||
if (image != null)
|
||||
{
|
||||
return image.Width / image.Height;
|
||||
}
|
||||
|
||||
return 0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a byte array that contains the image's raw bitmap pixel data.
|
||||
/// </summary>
|
||||
public byte[] GetBitmap(BitmapOptions options)
|
||||
{
|
||||
return ToBitmap(new ToBitmapOptions{ ScaleFactor = options.ScaleFactor });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a byte array that contains the image's raw bitmap pixel data.
|
||||
/// </summary>
|
||||
public byte[] GetNativeHandle()
|
||||
{
|
||||
return ToBitmap(new ToBitmapOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the specified image based on scale factor
|
||||
/// </summary>
|
||||
public Size GetSize(float scaleFactor = 1.0f)
|
||||
{
|
||||
if (_images.ContainsKey(scaleFactor))
|
||||
{
|
||||
var image = _images[scaleFactor];
|
||||
return new Size
|
||||
{
|
||||
Width = image.Width,
|
||||
Height = image.Height
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if the NativeImage instance is empty.
|
||||
/// </summary>
|
||||
public bool IsEmpty()
|
||||
{
|
||||
return _images.Count <= 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deprecated. Whether the image is a template image.
|
||||
/// </summary>
|
||||
public bool IsTemplateImage => _isTemplateImage;
|
||||
|
||||
/// <summary>
|
||||
/// Deprecated. Marks the image as a template image.
|
||||
/// </summary>
|
||||
public void SetTemplateImage(bool option)
|
||||
{
|
||||
_isTemplateImage = option;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Outputs a bitmap based on the scale factor
|
||||
/// </summary>
|
||||
public byte[] ToBitmap(ToBitmapOptions options)
|
||||
{
|
||||
return ImageToBytes(ImageFormat.Bmp, options.ScaleFactor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Outputs a data URL based on the scale factor
|
||||
/// </summary>
|
||||
public string ToDataURL(ToDataUrlOptions options)
|
||||
{
|
||||
if (!_images.ContainsKey(options.ScaleFactor))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var image = _images[options.ScaleFactor];
|
||||
var mimeType = ImageCodecInfo.GetImageEncoders().FirstOrDefault(x => x.FormatID == image.RawFormat.Guid)?.MimeType;
|
||||
if (mimeType is null)
|
||||
{
|
||||
mimeType = "image/png";
|
||||
}
|
||||
|
||||
var bytes = ImageToBytes(image.RawFormat, options.ScaleFactor);
|
||||
var base64 = Convert.ToBase64String(bytes);
|
||||
|
||||
return $"data:{mimeType};base64,{base64}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Outputs a JPEG for the default scale factor
|
||||
/// </summary>
|
||||
public byte[] ToJPEG(int quality)
|
||||
{
|
||||
return ImageToBytes(ImageFormat.Jpeg, 1.0f, quality);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Outputs a PNG for the specified scale factor
|
||||
/// </summary>
|
||||
public byte[] ToPNG(ToPNGOptions options)
|
||||
{
|
||||
return ImageToBytes(ImageFormat.Png, options.ScaleFactor);
|
||||
}
|
||||
|
||||
private byte[] ImageToBytes(ImageFormat imageFormat = null, float scaleFactor = 1.0f, int quality = 100)
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
|
||||
if (_images.ContainsKey(scaleFactor))
|
||||
{
|
||||
var image = _images[scaleFactor];
|
||||
var encoderCodecInfo = GetEncoder(imageFormat ?? image.RawFormat);
|
||||
var encoder = Encoder.Quality;
|
||||
|
||||
var encoderParameters = new EncoderParameters(1)
|
||||
{
|
||||
Param = new[]
|
||||
{
|
||||
new EncoderParameter(encoder, quality)
|
||||
}
|
||||
};
|
||||
|
||||
image.Save(ms, encoderCodecInfo, encoderParameters);
|
||||
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Image Resize(int? width, int? height, float scaleFactor = 1.0f)
|
||||
{
|
||||
if (!_images.ContainsKey(scaleFactor) || (width is null && height is null))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var image = _images[scaleFactor];
|
||||
using (var g = Graphics.FromImage(image))
|
||||
{
|
||||
g.CompositingQuality = CompositingQuality.HighQuality;
|
||||
|
||||
var aspect = GetAspectRatio(scaleFactor);
|
||||
|
||||
width ??= Convert.ToInt32(image.Width * aspect);
|
||||
height ??= Convert.ToInt32(image.Height * aspect);
|
||||
|
||||
width = Convert.ToInt32(width * scaleFactor);
|
||||
height = Convert.ToInt32(height * scaleFactor);
|
||||
|
||||
var bmp = new Bitmap(width.Value, height.Value);
|
||||
g.DrawImage(bmp,
|
||||
new System.Drawing.Rectangle(0, 0, image.Width, image.Height),
|
||||
new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
|
||||
GraphicsUnit.Pixel);
|
||||
|
||||
return bmp;
|
||||
}
|
||||
}
|
||||
|
||||
private Image Crop(int? x, int? y, int? width, int? height, float scaleFactor = 1.0f)
|
||||
{
|
||||
if (!_images.ContainsKey(scaleFactor))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var image = _images[scaleFactor];
|
||||
using (var g = Graphics.FromImage(image))
|
||||
{
|
||||
g.CompositingQuality = CompositingQuality.HighQuality;
|
||||
|
||||
x ??= 0;
|
||||
y ??= 0;
|
||||
|
||||
x = Convert.ToInt32(x * scaleFactor);
|
||||
y = Convert.ToInt32(y * scaleFactor);
|
||||
|
||||
width ??= image.Width;
|
||||
height ??= image.Height;
|
||||
|
||||
width = Convert.ToInt32(width * scaleFactor);
|
||||
height = Convert.ToInt32(height * scaleFactor);
|
||||
|
||||
var bmp = new Bitmap(width.Value, height.Value);
|
||||
g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, image.Width, image.Height), new System.Drawing.Rectangle(x.Value, y.Value, width.Value, height.Value), GraphicsUnit.Pixel);
|
||||
|
||||
return bmp;
|
||||
}
|
||||
}
|
||||
|
||||
private ImageCodecInfo GetEncoder(ImageFormat format)
|
||||
{
|
||||
var codecs = ImageCodecInfo.GetImageDecoders();
|
||||
foreach (ImageCodecInfo codec in codecs)
|
||||
{
|
||||
if (codec.FormatID == format.Guid)
|
||||
{
|
||||
return codec;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal Dictionary<float,string> GetAllScaledImages()
|
||||
{
|
||||
var dict = new Dictionary<float,string>();
|
||||
try
|
||||
{
|
||||
foreach (var (scale, image) in _images)
|
||||
{
|
||||
dict.Add(scale, Convert.ToBase64String(ImageToBytes(null, scale)));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
internal Image GetScale(float scaleFactor)
|
||||
{
|
||||
if (_images.ContainsKey(scaleFactor))
|
||||
{
|
||||
return _images[scaleFactor];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
34
ElectronNET.API/Entities/NativeImageJsonConverter.cs
Normal file
34
ElectronNET.API/Entities/NativeImageJsonConverter.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
internal class NativeImageJsonConverter : JsonConverter
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
if (value is NativeImage nativeImage)
|
||||
{
|
||||
var scaledImages = nativeImage.GetAllScaledImages();
|
||||
serializer.Serialize(writer, scaledImages);
|
||||
}
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
var dict = serializer.Deserialize<Dictionary<float, string>>(reader);
|
||||
var newDictionary = new Dictionary<float, Image>();
|
||||
foreach (var item in dict)
|
||||
{
|
||||
var bytes = Convert.FromBase64String(item.Value);
|
||||
newDictionary.Add(item.Key, Image.FromStream(new MemoryStream(bytes)));
|
||||
}
|
||||
return new NativeImage(newDictionary);
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(NativeImage);
|
||||
}
|
||||
}
|
||||
107
ElectronNET.API/Entities/PrintOptions.cs
Normal file
107
ElectronNET.API/Entities/PrintOptions.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Print dpi
|
||||
/// </summary>
|
||||
public class PrintDpi
|
||||
{
|
||||
/// <summary>
|
||||
/// The horizontal dpi
|
||||
/// </summary>
|
||||
public float Horizontal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The vertical dpi
|
||||
/// </summary>
|
||||
public float Vertical { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The page range to print
|
||||
/// </summary>
|
||||
public class PrintPageRange
|
||||
{
|
||||
/// <summary>
|
||||
/// From
|
||||
/// </summary>
|
||||
public int From { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// To
|
||||
/// </summary>
|
||||
public int To { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print options
|
||||
/// </summary>
|
||||
public class PrintOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Don't ask user for print settings
|
||||
/// </summary>
|
||||
public bool Silent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Prints the background color and image of the web page
|
||||
/// </summary>
|
||||
public bool PrintBackground { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set the printer device name to use
|
||||
/// </summary>
|
||||
public string DeviceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the printed web page will be in color or grayscale
|
||||
/// </summary>
|
||||
public bool Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the type of margins to use. Uses 0 for default margin, 1 for no
|
||||
/// margin, and 2 for minimum margin.
|
||||
/// </summary>
|
||||
public int MarginsType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// true for landscape, false for portrait.
|
||||
/// </summary>
|
||||
public bool Landscape { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The scale factor of the web page
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of pages to print per page sheet
|
||||
/// </summary>
|
||||
public int PagesPerSheet { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of copies of the web page to print
|
||||
/// </summary>
|
||||
public bool Copies { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the web page should be collated
|
||||
/// </summary>
|
||||
public bool Collate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The page range to print
|
||||
/// </summary>
|
||||
public PrintPageRange PageRanges { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set the duplex mode of the printed web page. Can be simplex, shortEdge, or longEdge.
|
||||
/// </summary>
|
||||
public string DuplexMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Dpi
|
||||
/// </summary>
|
||||
public PrintDpi Dpi { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
29
ElectronNET.API/Entities/PrinterInfo.cs
Normal file
29
ElectronNET.API/Entities/PrinterInfo.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Printer info
|
||||
/// </summary>
|
||||
public class PrinterInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Name
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Status
|
||||
/// </summary>
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is default
|
||||
/// </summary>
|
||||
public bool IsDefault { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
23
ElectronNET.API/Entities/ResizeOptions.cs
Normal file
23
ElectronNET.API/Entities/ResizeOptions.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ResizeOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the width
|
||||
/// </summary>
|
||||
public int? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height
|
||||
/// </summary>
|
||||
public int? Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// good, better, or best. Default is "best";
|
||||
/// </summary>
|
||||
public string Quality { get; set; } = "best";
|
||||
}
|
||||
}
|
||||
13
ElectronNET.API/Entities/ToBitmapOptions.cs
Normal file
13
ElectronNET.API/Entities/ToBitmapOptions.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ToBitmapOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the scalefactor
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
}
|
||||
}
|
||||
13
ElectronNET.API/Entities/ToDataUrlOptions.cs
Normal file
13
ElectronNET.API/Entities/ToDataUrlOptions.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ToDataUrlOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the scalefactor
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
}
|
||||
}
|
||||
13
ElectronNET.API/Entities/ToPNGOptions.cs
Normal file
13
ElectronNET.API/Entities/ToPNGOptions.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ToPNGOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the scalefactor
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
}
|
||||
}
|
||||
@@ -82,25 +82,25 @@ namespace ElectronNET.API
|
||||
/// <param name="menuItems">The menu items.</param>
|
||||
public void SetContextMenu(BrowserWindow browserWindow, MenuItem[] menuItems)
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
BridgeConnector.Socket.Emit("menu-setContextMenu", browserWindow.Id, JArray.FromObject(menuItems, _jsonSerializer));
|
||||
|
||||
if (!_contextMenuItems.ContainsKey(browserWindow.Id))
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
BridgeConnector.Socket.Emit("menu-setContextMenu", browserWindow.Id, JArray.FromObject(menuItems, _jsonSerializer));
|
||||
_contextMenuItems.Add(browserWindow.Id, menuItems.ToList());
|
||||
|
||||
var x = _contextMenuItems.ToDictionary(kv => kv.Key, kv => kv.Value.AsReadOnly());
|
||||
ContextMenuItems = new ReadOnlyDictionary<int, ReadOnlyCollection<MenuItem>>(x);
|
||||
|
||||
BridgeConnector.Socket.Off("contextMenuItemClicked");
|
||||
BridgeConnector.Socket.On("contextMenuItemClicked", (results) =>
|
||||
{
|
||||
var id = ((JArray)results).First.ToString();
|
||||
var browserWindowId = (int)((JArray)results).Last;
|
||||
|
||||
MenuItem menuItem = _contextMenuItems[browserWindowId].GetMenuItem(id);
|
||||
menuItem.Click?.Invoke();
|
||||
});
|
||||
}
|
||||
|
||||
BridgeConnector.Socket.Off("contextMenuItemClicked");
|
||||
BridgeConnector.Socket.On("contextMenuItemClicked", (results) =>
|
||||
{
|
||||
var id = ((JArray)results).First.ToString();
|
||||
var browserWindowId = (int)((JArray)results).Last;
|
||||
|
||||
MenuItem menuItem = _contextMenuItems[browserWindowId].GetMenuItem(id);
|
||||
menuItem.Click?.Invoke();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -115,8 +115,7 @@ namespace ElectronNET.API
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,6 +252,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
BridgeConnector.Socket.Emit("create-tray", image, JArray.FromObject(menuItems, _jsonSerializer));
|
||||
_items.Clear();
|
||||
_items.AddRange(menuItems);
|
||||
|
||||
BridgeConnector.Socket.Off("trayMenuItemClicked");
|
||||
@@ -307,18 +308,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>
|
||||
@@ -351,8 +340,7 @@ namespace ElectronNET.API
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,53 @@ namespace ElectronNET.API
|
||||
BridgeConnector.Socket.Emit("webContentsOpenDevTools", Id, JObject.FromObject(openDevToolsOptions, _jsonSerializer));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get system printers.
|
||||
/// </summary>
|
||||
/// <returns>printers</returns>
|
||||
public Task<PrinterInfo[]> GetPrintersAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<PrinterInfo[]>();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-getPrinters-completed", (printers) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-getPrinters-completed");
|
||||
|
||||
taskCompletionSource.SetResult(((Newtonsoft.Json.Linq.JArray)printers).ToObject<PrinterInfo[]>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-getPrinters", Id);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prints window's web page.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns>success</returns>
|
||||
public Task<bool> PrintAsync(PrintOptions options = null)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-print-completed", (success) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-print-completed");
|
||||
taskCompletionSource.SetResult((bool)success);
|
||||
});
|
||||
|
||||
if(options == null)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-print", Id, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("webContents-print", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
}
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prints window's web page as PDF with Chromium's preview printing custom
|
||||
/// settings.The landscape will be ignored if @page CSS at-rule is used in the web page.
|
||||
@@ -158,7 +205,59 @@ namespace ElectronNET.API
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The async method will resolve when the page has finished loading,
|
||||
/// and rejects if the page fails to load.
|
||||
///
|
||||
/// A noop rejection handler is already attached, which avoids unhandled rejection
|
||||
/// errors.
|
||||
///
|
||||
/// Loads the `url` in the window. The `url` must contain the protocol prefix, e.g.
|
||||
/// the `http://` or `file://`. If the load should bypass http cache then use the
|
||||
/// `pragma` header to achieve it.
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
public Task LoadURLAsync(string url)
|
||||
{
|
||||
return LoadURLAsync(url, new LoadURLOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The async method will resolve when the page has finished loading,
|
||||
/// and rejects if the page fails to load.
|
||||
///
|
||||
/// A noop rejection handler is already attached, which avoids unhandled rejection
|
||||
/// errors.
|
||||
///
|
||||
/// Loads the `url` in the window. The `url` must contain the protocol prefix, e.g.
|
||||
/// the `http://` or `file://`. If the load should bypass http cache then use the
|
||||
/// `pragma` header to achieve it.
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="options"></param>
|
||||
public Task LoadURLAsync(string url, LoadURLOptions options)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<object>();
|
||||
|
||||
BridgeConnector.Socket.On("webContents-loadURL-complete" + Id, () =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-loadURL-complete" + Id);
|
||||
BridgeConnector.Socket.Off("webContents-loadURL-error" + Id);
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.On("webContents-loadURL-error" + Id, (error) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("webContents-loadURL-error" + Id);
|
||||
taskCompletionSource.SetException(new InvalidOperationException(error.ToString()));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("webContents-loadURL", Id, url, JObject.FromObject(options, _jsonSerializer));
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -22,16 +23,27 @@ namespace ElectronNET.API
|
||||
{
|
||||
BridgeSettings.SocketPort = argument.ToUpper().Replace("/ELECTRONPORT=", "");
|
||||
Console.WriteLine("Use Electron Port: " + BridgeSettings.SocketPort);
|
||||
} else if(argument.ToUpper().Contains("ELECTRONWEBPORT"))
|
||||
}
|
||||
else if (argument.ToUpper().Contains("ELECTRONWEBPORT"))
|
||||
{
|
||||
BridgeSettings.WebPort = argument.ToUpper().Replace("/ELECTRONWEBPORT=", "");
|
||||
}
|
||||
}
|
||||
|
||||
if(HybridSupport.IsElectronActive)
|
||||
if (HybridSupport.IsElectronActive)
|
||||
{
|
||||
builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory)
|
||||
.UseUrls("http://127.0.0.1:" + BridgeSettings.WebPort);
|
||||
// check for the content folder if its exists in base director otherwise no need to include
|
||||
// It was used before because we are publishing the project which copies everything to bin folder and contentroot wwwroot was folder there.
|
||||
// now we have implemented the live reload if app is run using /watch then we need to use the default project path.
|
||||
if (Directory.Exists($"{AppDomain.CurrentDomain.BaseDirectory}\\wwwroot"))
|
||||
{
|
||||
builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory)
|
||||
.UseUrls("http://localhost:" + BridgeSettings.WebPort);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.UseUrls("http://localhost:" + BridgeSettings.WebPort);
|
||||
}
|
||||
}
|
||||
|
||||
return builder;
|
||||
|
||||
@@ -65,6 +65,15 @@ namespace ElectronNET.API
|
||||
public IReadOnlyCollection<BrowserWindow> BrowserWindows { get { return _browserWindows.AsReadOnly(); } }
|
||||
private List<BrowserWindow> _browserWindows = new List<BrowserWindow>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the browser views.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The browser view.
|
||||
/// </value>
|
||||
public IReadOnlyCollection<BrowserView> BrowserViews { get { return _browserViews.AsReadOnly(); } }
|
||||
private List<BrowserView> _browserViews = new List<BrowserView>();
|
||||
|
||||
/// <summary>
|
||||
/// Creates the window asynchronous.
|
||||
/// </summary>
|
||||
@@ -155,6 +164,51 @@ namespace ElectronNET.API
|
||||
return RuntimeInformation.OSDescription.Contains("Windows 10");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
|
||||
/// It is like a child window, except that it is positioned relative to its owning window.
|
||||
/// It is meant to be an alternative to the webview tag.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<BrowserView> CreateBrowserViewAsync()
|
||||
{
|
||||
return CreateBrowserViewAsync(new BrowserViewConstructorOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
|
||||
/// It is like a child window, except that it is positioned relative to its owning window.
|
||||
/// It is meant to be an alternative to the webview tag.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public Task<BrowserView> CreateBrowserViewAsync(BrowserViewConstructorOptions options)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<BrowserView>();
|
||||
|
||||
BridgeConnector.Socket.On("BrowserViewCreated", (id) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("BrowserViewCreated");
|
||||
|
||||
string browserViewId = id.ToString();
|
||||
BrowserView browserView = new BrowserView(int.Parse(browserViewId));
|
||||
browserView.Destroyed += (b) => _browserViews.Remove(b);
|
||||
|
||||
_browserViews.Add(browserView);
|
||||
|
||||
taskCompletionSource.SetResult(browserView);
|
||||
});
|
||||
|
||||
var ownjsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
BridgeConnector.Socket.Emit("createBrowserView", JObject.FromObject(options, ownjsonSerializer));
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
|
||||
@@ -18,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.");
|
||||
@@ -28,6 +29,7 @@ namespace ElectronNET.CLI.Commands.Actions
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "screen.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "clipboard.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "autoUpdater.js", "api.");
|
||||
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "browserView.js", "api.");
|
||||
|
||||
string splashscreenFolder = Path.Combine(tempPath, "splashscreen");
|
||||
if (Directory.Exists(splashscreenFolder) == false)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.CLI.Commands.Actions;
|
||||
@@ -40,6 +41,8 @@ namespace ElectronNET.CLI.Commands
|
||||
private string _paramAbsoluteOutput = "absolute-path";
|
||||
private string _paramPackageJson = "package-json";
|
||||
private string _paramForceNodeInstall = "install-modules";
|
||||
private string _manifest = "manifest";
|
||||
private string _paramPublishReadyToRun = "PublishReadyToRun";
|
||||
|
||||
public Task<bool> ExecuteAsync()
|
||||
{
|
||||
@@ -50,6 +53,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)
|
||||
@@ -72,7 +82,13 @@ namespace ElectronNET.CLI.Commands
|
||||
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);
|
||||
|
||||
@@ -80,7 +96,17 @@ namespace ElectronNET.CLI.Commands
|
||||
|
||||
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid} under {configuration}-Configuration...");
|
||||
|
||||
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c {configuration} --output \"{tempBinPath}\"", Directory.GetCurrentDirectory());
|
||||
string publishReadyToRun = "/p:PublishReadyToRun=";
|
||||
if (parser.Arguments.ContainsKey(_paramPublishReadyToRun))
|
||||
{
|
||||
publishReadyToRun += parser.Arguments[_paramPublishReadyToRun][0];
|
||||
}
|
||||
else
|
||||
{
|
||||
publishReadyToRun += "true";
|
||||
}
|
||||
|
||||
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c {configuration} --output \"{tempBinPath}\" {publishReadyToRun} --self-contained", Directory.GetCurrentDirectory());
|
||||
|
||||
if (resultCode != 0)
|
||||
{
|
||||
@@ -150,10 +176,18 @@ namespace ElectronNET.CLI.Commands
|
||||
|
||||
// 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...");
|
||||
ProcessHelper.CmdExecute($"node build-helper.js", tempPath);
|
||||
|
||||
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($"npx electron-builder . --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=5.0.8 {electronParams}", tempPath);
|
||||
ProcessHelper.CmdExecute($"npx electron-builder . --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=8.2.3 {electronParams}", tempPath);
|
||||
|
||||
Console.WriteLine("... done");
|
||||
|
||||
|
||||
@@ -16,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
|
||||
@@ -45,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);
|
||||
|
||||
@@ -56,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}...");
|
||||
@@ -99,7 +111,32 @@ namespace ElectronNET.CLI.Commands
|
||||
|
||||
string launchSettingText = File.ReadAllText(launchSettingFile);
|
||||
|
||||
if (launchSettingText.Contains("\"executablePath\": \"electronize\"") == 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\": {");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.CLI.Commands.Actions;
|
||||
@@ -21,19 +22,29 @@ namespace ElectronNET.CLI.Commands
|
||||
_args = args;
|
||||
}
|
||||
|
||||
private string _aspCoreProjectPath = "project-path";
|
||||
private string _arguments = "args";
|
||||
private string _manifest = "manifest";
|
||||
private string _clearCache = "clear-cache";
|
||||
private string _paramPublishReadyToRun = "PublishReadyToRun";
|
||||
|
||||
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
|
||||
@@ -50,7 +61,22 @@ namespace ElectronNET.CLI.Commands
|
||||
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);
|
||||
var resultCode = 0;
|
||||
|
||||
string publishReadyToRun = "/p:PublishReadyToRun=";
|
||||
if (parser.Arguments.ContainsKey(_paramPublishReadyToRun))
|
||||
{
|
||||
publishReadyToRun += parser.Arguments[_paramPublishReadyToRun][0];
|
||||
}
|
||||
else
|
||||
{
|
||||
publishReadyToRun += "true";
|
||||
}
|
||||
|
||||
if (parser != null && !parser.Arguments.ContainsKey("watch"))
|
||||
{
|
||||
resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\" {publishReadyToRun} --no-self-contained", aspCoreProjectPath);
|
||||
}
|
||||
|
||||
if (resultCode != 0)
|
||||
{
|
||||
@@ -83,19 +109,41 @@ namespace ElectronNET.CLI.Commands
|
||||
ProcessHelper.CmdExecute(@"npx tsc -p ../../ElectronHostHook", tempPath);
|
||||
}
|
||||
|
||||
string arguments = "";
|
||||
|
||||
if (parser.Arguments.ContainsKey(_arguments))
|
||||
{
|
||||
arguments = string.Join(' ', parser.Arguments[_arguments]);
|
||||
}
|
||||
|
||||
if (parser.Arguments.ContainsKey(_manifest))
|
||||
{
|
||||
arguments += " --manifest=" + parser.Arguments[_manifest].First();
|
||||
}
|
||||
|
||||
if (parser.Arguments.ContainsKey(_clearCache))
|
||||
{
|
||||
arguments += " --clear-cache=true";
|
||||
}
|
||||
|
||||
if (parser.Arguments.ContainsKey("watch"))
|
||||
{
|
||||
arguments += " --watch=true";
|
||||
}
|
||||
|
||||
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,9 +2,11 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<AssemblyName>electronize</AssemblyName>
|
||||
|
||||
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<AssemblyName>dotnet-electronize</AssemblyName>
|
||||
<ToolCommandName>electronize</ToolCommandName>
|
||||
|
||||
<PackageType>DotnetCliTool</PackageType>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageOutputPath>..\artifacts</PackageOutputPath>
|
||||
@@ -14,8 +16,10 @@
|
||||
<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 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>
|
||||
@@ -25,6 +29,11 @@ This package contains the dotnet tooling to electronize your application.</Descr
|
||||
<PackageReleaseNotes>Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md</PackageReleaseNotes>
|
||||
<PackageIcon>PackageIcon.png</PackageIcon>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
<StartupObject></StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -32,72 +41,36 @@ 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>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DocumentationFile></DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="PackageIcon.png" Pack="true" PackagePath="\"/>
|
||||
<None Include="PackageIcon.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\electron.manifest.json" Link="ElectronHost\electron.manifest.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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" />
|
||||
<EmbeddedResource Include="..\ElectronNET.Host\api\browserView.js" Link="ElectronHost\api\browserView.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"profiles": {
|
||||
"ElectronNET.CLI": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "build \"C:\\Users\\Gregor\\Documents\\Visual Studio 2017\\Projects\\ElectronNET\\ElectronNET.WebApp\""
|
||||
"commandLineArgs": "start /project-path \"C:\\Users\\Rizvi\\source\\repos\\Electron.NET\\ElectronNET.WebApp\" /watch"
|
||||
}
|
||||
}
|
||||
}
|
||||
18
ElectronNET.Host/.vscode/launch.json
vendored
18
ElectronNET.Host/.vscode/launch.json
vendored
@@ -10,7 +10,23 @@
|
||||
"name": "Launch Electron App",
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
||||
"program": "${workspaceFolder}/main.js",
|
||||
"sourceMaps": true
|
||||
"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,16 +91,15 @@ module.exports = (socket, app) => {
|
||||
// nativeImage[indexCount] = nativeImage;
|
||||
// }
|
||||
// }
|
||||
socket.on('appGetFileIcon', (path, options) => {
|
||||
socket.on('appGetFileIcon', async (path, options) => {
|
||||
let error = {};
|
||||
if (options) {
|
||||
app.getFileIcon(path, options, (error, nativeImage) => {
|
||||
electronSocket.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) => {
|
||||
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
});
|
||||
const nativeImage = await app.getFileIcon(path).catch((errorFileIcon) => error = errorFileIcon);
|
||||
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
}
|
||||
});
|
||||
socket.on('appSetPath', (name, path) => {
|
||||
@@ -111,11 +110,10 @@ module.exports = (socket, app) => {
|
||||
electronSocket.emit('appGetVersionCompleted', version);
|
||||
});
|
||||
socket.on('appGetName', () => {
|
||||
const name = app.getName();
|
||||
electronSocket.emit('appGetNameCompleted', name);
|
||||
electronSocket.emit('appGetNameCompleted', app.name);
|
||||
});
|
||||
socket.on('appSetName', (name) => {
|
||||
app.setName(name);
|
||||
app.name = name;
|
||||
});
|
||||
socket.on('appGetLocale', () => {
|
||||
const locale = app.getLocale();
|
||||
@@ -209,12 +207,6 @@ module.exports = (socket, app) => {
|
||||
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('appDockBounce', (type) => {
|
||||
const id = app.dock.bounce(type);
|
||||
electronSocket.emit('appDockBounceCompleted', id);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -113,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) => {
|
||||
electronSocket.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) => {
|
||||
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
});
|
||||
const nativeImage = await app.getFileIcon(path).catch((errorFileIcon) => error = errorFileIcon);
|
||||
|
||||
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -135,12 +137,11 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
});
|
||||
|
||||
socket.on('appGetName', () => {
|
||||
const name = app.getName();
|
||||
electronSocket.emit('appGetNameCompleted', name);
|
||||
electronSocket.emit('appGetNameCompleted', app.name);
|
||||
});
|
||||
|
||||
socket.on('appSetName', (name) => {
|
||||
app.setName(name);
|
||||
app.name = name;
|
||||
});
|
||||
|
||||
socket.on('appGetLocale', () => {
|
||||
@@ -260,14 +261,6 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
app.setAboutPanelOptions(options);
|
||||
});
|
||||
|
||||
socket.on('appCommandLineAppendSwitch', (theSwitch, value) => {
|
||||
app.commandLine.appendSwitch(theSwitch, value);
|
||||
});
|
||||
|
||||
socket.on('appCommandLineAppendArgument', (value) => {
|
||||
app.commandLine.appendArgument(value);
|
||||
});
|
||||
|
||||
socket.on('appDockBounce', (type) => {
|
||||
const id = app.dock.bounce(type);
|
||||
electronSocket.emit('appDockBounceCompleted', id);
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
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) : new P(function (resolve) { resolve(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;
|
||||
@@ -87,25 +79,25 @@ module.exports = (socket) => {
|
||||
electron_updater_1.autoUpdater.channel = value;
|
||||
});
|
||||
// Methods ********
|
||||
socket.on('autoUpdaterCheckForUpdatesAndNotify', (guid) => __awaiter(this, void 0, void 0, function* () {
|
||||
const updateCheckResult = yield electron_updater_1.autoUpdater.checkForUpdatesAndNotify();
|
||||
socket.on('autoUpdaterCheckForUpdatesAndNotify', async (guid) => {
|
||||
const updateCheckResult = await electron_updater_1.autoUpdater.checkForUpdatesAndNotify();
|
||||
electronSocket.emit('autoUpdaterCheckForUpdatesAndNotifyComplete' + guid, updateCheckResult);
|
||||
}));
|
||||
socket.on('autoUpdaterCheckForUpdates', (guid) => __awaiter(this, void 0, void 0, function* () {
|
||||
});
|
||||
socket.on('autoUpdaterCheckForUpdates', async (guid) => {
|
||||
// autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml');
|
||||
const updateCheckResult = yield electron_updater_1.autoUpdater.checkForUpdates();
|
||||
const updateCheckResult = await electron_updater_1.autoUpdater.checkForUpdates();
|
||||
electronSocket.emit('autoUpdaterCheckForUpdatesComplete' + guid, updateCheckResult);
|
||||
}));
|
||||
socket.on('autoUpdaterQuitAndInstall', (isSilent, isForceRunAfter) => __awaiter(this, void 0, void 0, function* () {
|
||||
});
|
||||
socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => {
|
||||
electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
|
||||
}));
|
||||
socket.on('autoUpdaterDownloadUpdate', (guid) => __awaiter(this, void 0, void 0, function* () {
|
||||
const downloadedPath = yield electron_updater_1.autoUpdater.downloadUpdate();
|
||||
});
|
||||
socket.on('autoUpdaterDownloadUpdate', async (guid) => {
|
||||
const downloadedPath = await electron_updater_1.autoUpdater.downloadUpdate();
|
||||
electronSocket.emit('autoUpdaterDownloadUpdateComplete' + guid, downloadedPath);
|
||||
}));
|
||||
socket.on('autoUpdaterGetFeedURL', (guid) => __awaiter(this, void 0, void 0, function* () {
|
||||
const feedUrl = yield electron_updater_1.autoUpdater.getFeedURL();
|
||||
});
|
||||
socket.on('autoUpdaterGetFeedURL', async (guid) => {
|
||||
const feedUrl = await electron_updater_1.autoUpdater.getFeedURL();
|
||||
electronSocket.emit('autoUpdaterGetFeedURLComplete' + guid, feedUrl || '');
|
||||
}));
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=autoUpdater.js.map
|
||||
@@ -1 +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;IACjC,cAAc,GAAG,MAAM,CAAC;IAExB,kBAAkB;IAElB,MAAM,CAAC,EAAE,CAAC,kCAAkC,EAAE,CAAC,EAAE,EAAE,EAAE;QACjD,8BAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC9B,cAAc,CAAC,IAAI,CAAC,mBAAmB,GAAG,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,gDAAgD,EAAE,CAAC,EAAE,EAAE,EAAE;QAC/D,8BAAW,CAAC,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;YACvC,cAAc,CAAC,IAAI,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,6CAA6C,EAAE,CAAC,EAAE,EAAE,EAAE;QAC5D,8BAAW,CAAC,EAAE,CAAC,kBAAkB,EAAE,CAAC,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,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2BAA2B,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE;QACvE,8BAAW,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2BAA2B,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAClD,MAAM,cAAc,GAAG,MAAM,8BAAW,CAAC,cAAc,EAAE,CAAC;QAC1D,cAAc,CAAC,IAAI,CAAC,mCAAmC,GAAG,IAAI,EAAE,cAAc,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,uBAAuB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC9C,MAAM,OAAO,GAAG,MAAM,8BAAW,CAAC,UAAU,EAAE,CAAC;QAC/C,cAAc,CAAC,IAAI,CAAC,+BAA+B,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
||||
55
ElectronNET.Host/api/browserView.js
Normal file
55
ElectronNET.Host/api/browserView.js
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
const electron_1 = require("electron");
|
||||
let browserViews = [];
|
||||
let browserView, electronSocket;
|
||||
module.exports = (socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('createBrowserView', (options) => {
|
||||
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
|
||||
options = { ...options, webPreferences: { nodeIntegration: true } };
|
||||
}
|
||||
browserView = new electron_1.BrowserView(options);
|
||||
browserViews.push(browserView);
|
||||
electronSocket.emit('BrowserViewCreated', browserView.id);
|
||||
});
|
||||
socket.on('browserView-isDestroyed', (id) => {
|
||||
const isDestroyed = getBrowserViewById(id).isDestroyed();
|
||||
electronSocket.emit('browserView-isDestroyed-reply', isDestroyed);
|
||||
});
|
||||
socket.on('browserView-getBounds', (id) => {
|
||||
const bounds = getBrowserViewById(id).getBounds();
|
||||
electronSocket.emit('browserView-getBounds-reply', bounds);
|
||||
});
|
||||
socket.on('browserView-setBounds', (id, bounds) => {
|
||||
getBrowserViewById(id).setBounds(bounds);
|
||||
});
|
||||
socket.on('browserView-destroy', (id) => {
|
||||
const browserViewIndex = browserViews.findIndex(b => b.id === id);
|
||||
getBrowserViewById(id).destroy();
|
||||
browserViews.splice(browserViewIndex, 1);
|
||||
});
|
||||
socket.on('browserView-setAutoResize', (id, options) => {
|
||||
getBrowserViewById(id).setAutoResize(options);
|
||||
});
|
||||
socket.on('browserView-setBackgroundColor', (id, color) => {
|
||||
getBrowserViewById(id).setBackgroundColor(color);
|
||||
});
|
||||
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;
|
||||
}
|
||||
function getBrowserViewById(id) {
|
||||
for (let index = 0; index < browserViews.length; index++) {
|
||||
const browserViewItem = browserViews[index];
|
||||
if (browserViewItem.id === id) {
|
||||
return browserViewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=browserView.js.map
|
||||
1
ElectronNET.Host/api/browserView.js.map
Normal file
1
ElectronNET.Host/api/browserView.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"browserView.js","sourceRoot":"","sources":["browserView.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,IAAI,YAAY,GAA2B,EAAE,CAAC;AAC9C,IAAI,WAAwB,EAAE,cAAc,CAAC;AAE7C,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,OAAO,EAAE,EAAE;QAC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
|
||||
import { BrowserView } from 'electron';
|
||||
let browserViews: Electron.BrowserView[] = [];
|
||||
let browserView: BrowserView, electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket) => {
|
||||
electronSocket = socket;
|
||||
|
||||
socket.on('createBrowserView', (options) => {
|
||||
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
|
||||
options = { ...options, webPreferences: { nodeIntegration: true } };
|
||||
}
|
||||
|
||||
browserView = new BrowserView(options);
|
||||
browserViews.push(browserView);
|
||||
|
||||
electronSocket.emit('BrowserViewCreated', browserView.id);
|
||||
});
|
||||
|
||||
socket.on('browserView-isDestroyed', (id) => {
|
||||
const isDestroyed = getBrowserViewById(id).isDestroyed();
|
||||
|
||||
electronSocket.emit('browserView-isDestroyed-reply', isDestroyed);
|
||||
});
|
||||
|
||||
socket.on('browserView-getBounds', (id) => {
|
||||
const bounds = getBrowserViewById(id).getBounds();
|
||||
|
||||
electronSocket.emit('browserView-getBounds-reply', bounds);
|
||||
});
|
||||
|
||||
socket.on('browserView-setBounds', (id, bounds) => {
|
||||
getBrowserViewById(id).setBounds(bounds);
|
||||
});
|
||||
|
||||
socket.on('browserView-destroy', (id) => {
|
||||
const browserViewIndex = browserViews.findIndex(b => b.id === id);
|
||||
getBrowserViewById(id).destroy();
|
||||
browserViews.splice(browserViewIndex, 1);
|
||||
});
|
||||
|
||||
socket.on('browserView-setAutoResize', (id, options) => {
|
||||
getBrowserViewById(id).setAutoResize(options);
|
||||
});
|
||||
|
||||
socket.on('browserView-setBackgroundColor', (id, color) => {
|
||||
getBrowserViewById(id).setBackgroundColor(color);
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function getBrowserViewById(id: number) {
|
||||
for (let index = 0; index < browserViews.length; index++) {
|
||||
const browserViewItem = browserViews[index];
|
||||
if (browserViewItem.id === id) {
|
||||
return browserViewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -2,11 +2,18 @@
|
||||
const electron_1 = require("electron");
|
||||
const path = require('path');
|
||||
const windows = [];
|
||||
let readyToShowWindowsIds = [];
|
||||
let window, lastOptions, electronSocket;
|
||||
let mainWindowURL;
|
||||
module.exports = (socket, app) => {
|
||||
electronSocket = socket;
|
||||
socket.on('register-browserWindow-ready-to-show', (id) => {
|
||||
if (readyToShowWindowsIds.includes(id)) {
|
||||
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== id);
|
||||
electronSocket.emit('browserWindow-ready-to-show' + id);
|
||||
}
|
||||
getWindowById(id).on('ready-to-show', () => {
|
||||
readyToShowWindowsIds.push(id);
|
||||
electronSocket.emit('browserWindow-ready-to-show' + id);
|
||||
});
|
||||
});
|
||||
@@ -155,20 +162,34 @@ module.exports = (socket, app) => {
|
||||
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 = Object.assign({}, options, { webPreferences: { nodeIntegration: true } });
|
||||
if (options.webPreferences && !('nodeIntegration' in options.webPreferences)) {
|
||||
options = { ...options, webPreferences: { ...options.webPreferences, nodeIntegration: true } };
|
||||
}
|
||||
window = new electron_1.BrowserWindow(options);
|
||||
else if (!options.webPreferences) {
|
||||
options = { ...options, webPreferences: { nodeIntegration: true } };
|
||||
}
|
||||
// we dont want to recreate the window when watch is ready.
|
||||
if (app.commandLine.hasSwitch('watch') && app['mainWindowURL'] === loadUrl) {
|
||||
window = app['mainWindow'];
|
||||
if (window) {
|
||||
window.reload();
|
||||
windows.push(window);
|
||||
electronSocket.emit('BrowserWindowCreated', window.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
window = new electron_1.BrowserWindow(options);
|
||||
}
|
||||
window.on('ready-to-show', () => {
|
||||
if (readyToShowWindowsIds.includes(window.id)) {
|
||||
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== window.id);
|
||||
}
|
||||
else {
|
||||
readyToShowWindowsIds.push(window.id);
|
||||
}
|
||||
});
|
||||
lastOptions = options;
|
||||
window.on('closed', (sender) => {
|
||||
for (let index = 0; index < windows.length; index++) {
|
||||
@@ -196,6 +217,16 @@ module.exports = (socket, app) => {
|
||||
if (loadUrl) {
|
||||
window.loadURL(loadUrl);
|
||||
}
|
||||
if (app.commandLine.hasSwitch('clear-cache') &&
|
||||
app.commandLine.getSwitchValue('clear-cache')) {
|
||||
window.webContents.session.clearCache();
|
||||
console.log('auto clear-cache active for new window.');
|
||||
}
|
||||
// set main window url
|
||||
if (app['mainWindowURL'] == undefined || app['mainWindowURL'] == "") {
|
||||
app['mainWindowURL'] = loadUrl;
|
||||
app['mainWindow'] = window;
|
||||
}
|
||||
windows.push(window);
|
||||
electronSocket.emit('BrowserWindowCreated', window.id);
|
||||
});
|
||||
@@ -538,6 +569,25 @@ module.exports = (socket, app) => {
|
||||
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);
|
||||
});
|
||||
socket.on('browserWindow-setBrowserView', (id, browserViewId) => {
|
||||
const browserView = electron_1.BrowserView.fromId(browserViewId);
|
||||
getWindowById(id).setBrowserView(browserView);
|
||||
});
|
||||
function getWindowById(id) {
|
||||
for (let index = 0; index < windows.length; index++) {
|
||||
const element = windows[index];
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,12 +1,19 @@
|
||||
import { BrowserWindow, Menu, nativeImage } from 'electron';
|
||||
import { BrowserWindow, Menu, nativeImage, BrowserView } from 'electron';
|
||||
const path = require('path');
|
||||
const windows: Electron.BrowserWindow[] = [];
|
||||
let readyToShowWindowsIds: number[] = [];
|
||||
let window, lastOptions, electronSocket;
|
||||
|
||||
let mainWindowURL;
|
||||
export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
electronSocket = socket;
|
||||
socket.on('register-browserWindow-ready-to-show', (id) => {
|
||||
if (readyToShowWindowsIds.includes(id)) {
|
||||
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== id);
|
||||
electronSocket.emit('browserWindow-ready-to-show' + id);
|
||||
}
|
||||
|
||||
getWindowById(id).on('ready-to-show', () => {
|
||||
readyToShowWindowsIds.push(id);
|
||||
electronSocket.emit('browserWindow-ready-to-show' + id);
|
||||
});
|
||||
});
|
||||
@@ -185,23 +192,34 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
});
|
||||
});
|
||||
|
||||
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')) {
|
||||
if (options.webPreferences && !('nodeIntegration' in options.webPreferences)) {
|
||||
options = { ...options, webPreferences: { ...options.webPreferences, nodeIntegration: true } };
|
||||
} else if (!options.webPreferences) {
|
||||
options = { ...options, webPreferences: { nodeIntegration: true } };
|
||||
}
|
||||
|
||||
window = new BrowserWindow(options);
|
||||
// we dont want to recreate the window when watch is ready.
|
||||
if (app.commandLine.hasSwitch('watch') && app['mainWindowURL'] === loadUrl) {
|
||||
window = app['mainWindow'];
|
||||
if (window) {
|
||||
window.reload();
|
||||
windows.push(window);
|
||||
electronSocket.emit('BrowserWindowCreated', window.id);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
window = new BrowserWindow(options);
|
||||
}
|
||||
|
||||
window.on('ready-to-show', () => {
|
||||
if (readyToShowWindowsIds.includes(window.id)) {
|
||||
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== window.id);
|
||||
} else {
|
||||
readyToShowWindowsIds.push(window.id);
|
||||
}
|
||||
});
|
||||
|
||||
lastOptions = options;
|
||||
|
||||
window.on('closed', (sender) => {
|
||||
@@ -233,6 +251,18 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
|
||||
window.loadURL(loadUrl);
|
||||
}
|
||||
|
||||
if (app.commandLine.hasSwitch('clear-cache') &&
|
||||
app.commandLine.getSwitchValue('clear-cache')) {
|
||||
window.webContents.session.clearCache();
|
||||
console.log('auto clear-cache active for new window.');
|
||||
}
|
||||
|
||||
// set main window url
|
||||
if (app['mainWindowURL'] == undefined || app['mainWindowURL'] == "") {
|
||||
app['mainWindowURL'] = loadUrl;
|
||||
app['mainWindow'] = window;
|
||||
}
|
||||
|
||||
windows.push(window);
|
||||
electronSocket.emit('BrowserWindowCreated', window.id);
|
||||
});
|
||||
@@ -706,6 +736,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);
|
||||
});
|
||||
|
||||
socket.on('browserWindow-setBrowserView', (id, browserViewId) => {
|
||||
const browserView = BrowserView.fromId(browserViewId);
|
||||
getWindowById(id).setBrowserView(browserView);
|
||||
});
|
||||
|
||||
|
||||
function getWindowById(id: number): Electron.BrowserWindow {
|
||||
for (let index = 0; index < windows.length; index++) {
|
||||
const element = windows[index];
|
||||
|
||||
@@ -48,5 +48,20 @@ module.exports = (socket) => {
|
||||
socket.on('clipboard-write', (data, type) => {
|
||||
electron_1.clipboard.write(data, type);
|
||||
});
|
||||
socket.on('clipboard-readImage', (type) => {
|
||||
var image = electron_1.clipboard.readImage(type);
|
||||
electronSocket.emit('clipboard-readImage-Completed', { 1: image.toPNG().toString('base64') });
|
||||
});
|
||||
socket.on('clipboard-writeImage', (data, type) => {
|
||||
var data = JSON.parse(data);
|
||||
const ni = electron_1.nativeImage.createEmpty();
|
||||
for (var i in data) {
|
||||
var scaleFactor = i;
|
||||
var bytes = data[i];
|
||||
var buff = Buffer.from(bytes, 'base64');
|
||||
ni.addRepresentation({ scaleFactor: +scaleFactor, buffer: buff });
|
||||
}
|
||||
electron_1.clipboard.writeImage(ni, type);
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=clipboard.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"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C"}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { clipboard } from 'electron';
|
||||
import { clipboard, nativeImage } from 'electron';
|
||||
let electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket) => {
|
||||
@@ -60,4 +60,22 @@ export = (socket: SocketIO.Socket) => {
|
||||
socket.on('clipboard-write', (data, type) => {
|
||||
clipboard.write(data, type);
|
||||
});
|
||||
|
||||
socket.on('clipboard-readImage', (type) => {
|
||||
var image = clipboard.readImage(type);
|
||||
electronSocket.emit('clipboard-readImage-Completed', { 1: image.toPNG().toString('base64') });
|
||||
});
|
||||
|
||||
socket.on('clipboard-writeImage', (data, type) => {
|
||||
var data = JSON.parse(data);
|
||||
const ni = nativeImage.createEmpty();
|
||||
for (var i in data) {
|
||||
var scaleFactor = i;
|
||||
var bytes = data[i];
|
||||
var buff = Buffer.from(bytes, 'base64');
|
||||
ni.addRepresentation({ scaleFactor: +scaleFactor, buffer: buff });
|
||||
}
|
||||
|
||||
clipboard.writeImage(ni, 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);
|
||||
});
|
||||
};
|
||||
@@ -3,40 +3,35 @@ const electron_1 = require("electron");
|
||||
let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('showMessageBox', (browserWindow, options, guid) => {
|
||||
socket.on('showMessageBox', async (browserWindow, options, guid) => {
|
||||
if ('id' in browserWindow) {
|
||||
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
electron_1.dialog.showMessageBox(window, options, (response, checkboxChecked) => {
|
||||
electronSocket.emit('showMessageBoxComplete' + guid, [response, checkboxChecked]);
|
||||
});
|
||||
const messageBoxReturnValue = await electron_1.dialog.showMessageBox(window, options);
|
||||
electronSocket.emit('showMessageBoxComplete' + guid, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
|
||||
}
|
||||
else {
|
||||
const id = guid || options;
|
||||
electron_1.dialog.showMessageBox(browserWindow, (response, checkboxChecked) => {
|
||||
electronSocket.emit('showMessageBoxComplete' + id, [response, checkboxChecked]);
|
||||
});
|
||||
const messageBoxReturnValue = await electron_1.dialog.showMessageBox(browserWindow);
|
||||
electronSocket.emit('showMessageBoxComplete' + id, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
|
||||
}
|
||||
});
|
||||
socket.on('showOpenDialog', (browserWindow, options, guid) => {
|
||||
socket.on('showOpenDialog', async (browserWindow, options, guid) => {
|
||||
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
electron_1.dialog.showOpenDialog(window, options, (filePaths) => {
|
||||
electronSocket.emit('showOpenDialogComplete' + guid, filePaths || []);
|
||||
});
|
||||
const openDialogReturnValue = await electron_1.dialog.showOpenDialog(window, options);
|
||||
electronSocket.emit('showOpenDialogComplete' + guid, openDialogReturnValue.filePaths || []);
|
||||
});
|
||||
socket.on('showSaveDialog', (browserWindow, options, guid) => {
|
||||
socket.on('showSaveDialog', async (browserWindow, options, guid) => {
|
||||
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
electron_1.dialog.showSaveDialog(window, options, (filename) => {
|
||||
electronSocket.emit('showSaveDialogComplete' + guid, filename || '');
|
||||
});
|
||||
const saveDialogReturnValue = await 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) => {
|
||||
socket.on('showCertificateTrustDialog', async (browserWindow, options, guid) => {
|
||||
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
|
||||
electron_1.dialog.showCertificateTrustDialog(window, options, () => {
|
||||
electronSocket.emit('showCertificateTrustDialogComplete' + guid);
|
||||
});
|
||||
await 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,uCAAiD;AACjD,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE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AAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACzC,iBAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,KAAK,EAAE,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,CAAC,CAAC;AACP,CAAC,CAAC"}
|
||||
@@ -3,43 +3,42 @@ let electronSocket;
|
||||
|
||||
export = (socket: SocketIO.Socket) => {
|
||||
electronSocket = socket;
|
||||
socket.on('showMessageBox', (browserWindow, options, guid) => {
|
||||
socket.on('showMessageBox', async (browserWindow, options, guid) => {
|
||||
if ('id' in browserWindow) {
|
||||
const window = BrowserWindow.fromId(browserWindow.id);
|
||||
|
||||
dialog.showMessageBox(window, options, (response, checkboxChecked) => {
|
||||
electronSocket.emit('showMessageBoxComplete' + guid, [response, checkboxChecked]);
|
||||
});
|
||||
const messageBoxReturnValue = await dialog.showMessageBox(window, options);
|
||||
electronSocket.emit('showMessageBoxComplete' + guid, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
|
||||
} else {
|
||||
const id = guid || options;
|
||||
dialog.showMessageBox(browserWindow, (response, checkboxChecked) => {
|
||||
electronSocket.emit('showMessageBoxComplete' + id, [response, checkboxChecked]);
|
||||
});
|
||||
const messageBoxReturnValue = await dialog.showMessageBox(browserWindow);
|
||||
|
||||
electronSocket.emit('showMessageBoxComplete' + id, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('showOpenDialog', (browserWindow, options, guid) => {
|
||||
socket.on('showOpenDialog', async (browserWindow, options, guid) => {
|
||||
const window = BrowserWindow.fromId(browserWindow.id);
|
||||
dialog.showOpenDialog(window, options, (filePaths) => {
|
||||
electronSocket.emit('showOpenDialogComplete' + guid, filePaths || []);
|
||||
});
|
||||
const openDialogReturnValue = await dialog.showOpenDialog(window, options);
|
||||
|
||||
electronSocket.emit('showOpenDialogComplete' + guid, openDialogReturnValue.filePaths || []);
|
||||
});
|
||||
|
||||
socket.on('showSaveDialog', (browserWindow, options, guid) => {
|
||||
socket.on('showSaveDialog', async (browserWindow, options, guid) => {
|
||||
const window = BrowserWindow.fromId(browserWindow.id);
|
||||
dialog.showSaveDialog(window, options, (filename) => {
|
||||
electronSocket.emit('showSaveDialogComplete' + guid, filename || '');
|
||||
});
|
||||
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) => {
|
||||
socket.on('showCertificateTrustDialog', async (browserWindow, options, guid) => {
|
||||
const window = BrowserWindow.fromId(browserWindow.id);
|
||||
dialog.showCertificateTrustDialog(window, options, () => {
|
||||
electronSocket.emit('showCertificateTrustDialogComplete' + guid);
|
||||
});
|
||||
await dialog.showCertificateTrustDialog(window, options);
|
||||
|
||||
electronSocket.emit('showCertificateTrustDialogComplete' + guid);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -9,10 +9,17 @@ module.exports = (socket) => {
|
||||
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, browserWindowId) => {
|
||||
electronSocket.emit('contextMenuItemClicked', [id, browserWindowId]);
|
||||
});
|
||||
contextMenuItems.push({
|
||||
const index = contextMenuItems.findIndex(contextMenu => contextMenu.browserWindowId === browserWindowId);
|
||||
const contextMenuItem = {
|
||||
menu: menu,
|
||||
browserWindowId: browserWindowId
|
||||
});
|
||||
};
|
||||
if (index === -1) {
|
||||
contextMenuItems.push(contextMenuItem);
|
||||
}
|
||||
else {
|
||||
contextMenuItems[index] = contextMenuItem;
|
||||
}
|
||||
});
|
||||
function addContextMenuItemClickConnector(menuItems, browserWindowId, callback) {
|
||||
menuItems.forEach((item) => {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":";AAAA,uCAA+C;AAC/C,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,qBAAqB,EAAE,CAAC,eAAe,EAAE,SAAS,EAAE,EAAE;QAC5D,MAAM,IAAI,GAAG,eAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAE/C,gCAAgC,CAAC,IAAI,CAAC,KAAK,EAAE,eAAe,EAAE,CAAC,EAAE,EAAE,eAAe,EAAE,EAAE;YAClF,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;QACzE,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,CAAC,IAAI,EAAE,EAAE;YACvB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CA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,CAAC;QAEH,eAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,SAAS,yBAAyB,CAAC,SAAS,EAAE,QAAQ;QAClD,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACvB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC/C,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;aAC3D;YAED,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE;gBACzB,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;aAC7C;QACL,CAAC,CAAC,CAAC;IACP,CAAC;AACL,CAAC,CAAC"}
|
||||
@@ -11,10 +11,18 @@ export = (socket: SocketIO.Socket) => {
|
||||
electronSocket.emit('contextMenuItemClicked', [id, browserWindowId]);
|
||||
});
|
||||
|
||||
contextMenuItems.push({
|
||||
const index = contextMenuItems.findIndex(contextMenu => contextMenu.browserWindowId === browserWindowId);
|
||||
|
||||
const contextMenuItem = {
|
||||
menu: menu,
|
||||
browserWindowId: browserWindowId
|
||||
});
|
||||
};
|
||||
|
||||
if (index === -1) {
|
||||
contextMenuItems.push(contextMenuItem);
|
||||
} else {
|
||||
contextMenuItems[index] = contextMenuItem;
|
||||
}
|
||||
});
|
||||
|
||||
function addContextMenuItemClickConnector(menuItems, browserWindowId, callback) {
|
||||
|
||||
@@ -42,7 +42,7 @@ module.exports = (socket) => {
|
||||
}
|
||||
notification.show();
|
||||
});
|
||||
socket.on('notificationIsSupported', (options) => {
|
||||
socket.on('notificationIsSupported', () => {
|
||||
const isSupported = electron_1.Notification.isSupported;
|
||||
electronSocket.emit('notificationIsSupportedComplete', isSupported);
|
||||
});
|
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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"}
|
||||
@@ -50,7 +50,7 @@ export = (socket: SocketIO.Socket) => {
|
||||
notification.show();
|
||||
});
|
||||
|
||||
socket.on('notificationIsSupported', (options) => {
|
||||
socket.on('notificationIsSupported', () => {
|
||||
const isSupported = Notification.isSupported;
|
||||
electronSocket.emit('notificationIsSupportedComplete', isSupported);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
const electron_1 = require("electron");
|
||||
const path = require('path');
|
||||
let tray;
|
||||
let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
@@ -82,11 +81,6 @@ module.exports = (socket) => {
|
||||
tray.setTitle(title);
|
||||
}
|
||||
});
|
||||
socket.on('tray-setHighlightMode', (mode) => {
|
||||
if (tray) {
|
||||
tray.setHighlightMode(mode);
|
||||
}
|
||||
});
|
||||
socket.on('tray-displayBalloon', (options) => {
|
||||
if (tray) {
|
||||
tray.displayBalloon(options);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"tray.js","sourceRoot":"","sources":["tray.ts"],"names":[],"mappings":";AAAA,uCAAmD;AACnD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,IAAI,IAAmB,CAAC;AACxB,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,qBAAqB,EAAE,CAAC,EAAE,EAAE,EAAE;QACpC,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAA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AAE;QACjC,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SACxB;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE;QACzC,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;SAChC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC/B,IAAI,IAAI,EAAE;YACN,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YACvC,cAAc,CAAC,IAAI,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAC;SACjE;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,yBAAyB,CAAC,SAAS,EAAE,QAAQ;QAClD,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACvB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC/C,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;aAC3D;YAED,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE;gBACzB,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;aAC7C;QACL,CAAC,CAAC,CAAC;IACP,CAAC;AACL,CAAC,CAAC"}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Menu, Tray, nativeImage } from 'electron';
|
||||
const path = require('path');
|
||||
let tray: Electron.Tray;
|
||||
let electronSocket;
|
||||
|
||||
@@ -97,12 +96,6 @@ export = (socket: SocketIO.Socket) => {
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('tray-setHighlightMode', (mode) => {
|
||||
if (tray) {
|
||||
tray.setHighlightMode(mode);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('tray-displayBalloon', (options) => {
|
||||
if (tray) {
|
||||
tray.displayBalloon(options);
|
||||
|
||||
@@ -26,19 +26,23 @@ module.exports = (socket) => {
|
||||
getWindowById(id).webContents.openDevTools();
|
||||
}
|
||||
});
|
||||
socket.on('webContents-printToPDF', (id, options, path) => {
|
||||
getWindowById(id).webContents.printToPDF(options || {}, (error, data) => {
|
||||
socket.on('webContents-getPrinters', async (id) => {
|
||||
const printers = await getWindowById(id).webContents.getPrinters();
|
||||
electronSocket.emit('webContents-getPrinters-completed', printers);
|
||||
});
|
||||
socket.on('webContents-print', async (id, options = {}) => {
|
||||
await getWindowById(id).webContents.print(options);
|
||||
electronSocket.emit('webContents-print-completed', true);
|
||||
});
|
||||
socket.on('webContents-printToPDF', async (id, options = {}, path) => {
|
||||
const buffer = await getWindowById(id).webContents.printToPDF(options);
|
||||
fs.writeFile(path, buffer, (error) => {
|
||||
if (error) {
|
||||
throw error;
|
||||
electronSocket.emit('webContents-printToPDF-completed', false);
|
||||
}
|
||||
else {
|
||||
electronSocket.emit('webContents-printToPDF-completed', true);
|
||||
}
|
||||
fs.writeFile(path, data, (error) => {
|
||||
if (error) {
|
||||
electronSocket.emit('webContents-printToPDF-completed', false);
|
||||
}
|
||||
else {
|
||||
electronSocket.emit('webContents-printToPDF-completed', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
socket.on('webContents-getUrl', function (id) {
|
||||
@@ -49,35 +53,30 @@ module.exports = (socket) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.allowNTLMCredentialsForDomains(domains);
|
||||
});
|
||||
socket.on('webContents-session-clearAuthCache', (id, options, guid) => {
|
||||
socket.on('webContents-session-clearAuthCache', async (id, options, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.clearAuthCache(options, () => {
|
||||
electronSocket.emit('webContents-session-clearAuthCache-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.clearAuthCache(options);
|
||||
electronSocket.emit('webContents-session-clearAuthCache-completed' + guid);
|
||||
});
|
||||
socket.on('webContents-session-clearCache', (id, guid) => {
|
||||
socket.on('webContents-session-clearCache', async (id, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.clearCache(() => {
|
||||
electronSocket.emit('webContents-session-clearCache-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.clearCache();
|
||||
electronSocket.emit('webContents-session-clearCache-completed' + guid);
|
||||
});
|
||||
socket.on('webContents-session-clearHostResolverCache', (id, guid) => {
|
||||
socket.on('webContents-session-clearHostResolverCache', async (id, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.clearHostResolverCache(() => {
|
||||
electronSocket.emit('webContents-session-clearHostResolverCache-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.clearHostResolverCache();
|
||||
electronSocket.emit('webContents-session-clearHostResolverCache-completed' + guid);
|
||||
});
|
||||
socket.on('webContents-session-clearStorageData', (id, guid) => {
|
||||
socket.on('webContents-session-clearStorageData', async (id, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.clearStorageData({}, () => {
|
||||
electronSocket.emit('webContents-session-clearStorageData-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.clearStorageData({});
|
||||
electronSocket.emit('webContents-session-clearStorageData-completed' + guid);
|
||||
});
|
||||
socket.on('webContents-session-clearStorageData-options', (id, options, guid) => {
|
||||
socket.on('webContents-session-clearStorageData-options', async (id, options, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.clearStorageData(options, () => {
|
||||
electronSocket.emit('webContents-session-clearStorageData-options-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.clearStorageData(options);
|
||||
electronSocket.emit('webContents-session-clearStorageData-options-completed' + guid);
|
||||
});
|
||||
socket.on('webContents-session-createInterruptedDownload', (id, options) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
@@ -95,17 +94,15 @@ module.exports = (socket) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.flushStorageData();
|
||||
});
|
||||
socket.on('webContents-session-getBlobData', (id, identifier, guid) => {
|
||||
socket.on('webContents-session-getBlobData', async (id, identifier, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.getBlobData(identifier, (buffer) => {
|
||||
electronSocket.emit('webContents-session-getBlobData-completed' + guid, buffer.buffer);
|
||||
});
|
||||
const buffer = await browserWindow.webContents.session.getBlobData(identifier);
|
||||
electronSocket.emit('webContents-session-getBlobData-completed' + guid, buffer.buffer);
|
||||
});
|
||||
socket.on('webContents-session-getCacheSize', (id, guid) => {
|
||||
socket.on('webContents-session-getCacheSize', async (id, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.getCacheSize((size) => {
|
||||
electronSocket.emit('webContents-session-getCacheSize-completed' + guid, size);
|
||||
});
|
||||
const size = await browserWindow.webContents.session.getCacheSize();
|
||||
electronSocket.emit('webContents-session-getCacheSize-completed' + guid, size);
|
||||
});
|
||||
socket.on('webContents-session-getPreloads', (id, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
@@ -117,11 +114,10 @@ module.exports = (socket) => {
|
||||
const userAgent = browserWindow.webContents.session.getUserAgent();
|
||||
electronSocket.emit('webContents-session-getUserAgent-completed' + guid, userAgent);
|
||||
});
|
||||
socket.on('webContents-session-resolveProxy', (id, url, guid) => {
|
||||
socket.on('webContents-session-resolveProxy', async (id, url, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.resolveProxy(url, (proxy) => {
|
||||
electronSocket.emit('webContents-session-resolveProxy-completed' + guid, proxy);
|
||||
});
|
||||
const proxy = await browserWindow.webContents.session.resolveProxy(url);
|
||||
electronSocket.emit('webContents-session-resolveProxy-completed' + guid, proxy);
|
||||
});
|
||||
socket.on('webContents-session-setDownloadPath', (id, path) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
@@ -131,17 +127,28 @@ module.exports = (socket) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.setPreloads(preloads);
|
||||
});
|
||||
socket.on('webContents-session-setProxy', (id, configuration, guid) => {
|
||||
socket.on('webContents-session-setProxy', async (id, configuration, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.setProxy(configuration, () => {
|
||||
electronSocket.emit('webContents-session-setProxy-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.setProxy(configuration);
|
||||
electronSocket.emit('webContents-session-setProxy-completed' + guid);
|
||||
});
|
||||
socket.on('webContents-session-setUserAgent', (id, userAgent, acceptLanguages) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.setUserAgent(userAgent, acceptLanguages);
|
||||
});
|
||||
socket.on('webContents-loadURL', (id, url, options) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.loadURL(url, options).then(() => {
|
||||
electronSocket.emit('webContents-loadURL-complete' + id);
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
electronSocket.emit('webContents-loadURL-error' + id, error);
|
||||
});
|
||||
});
|
||||
function getWindowById(id) {
|
||||
if (id >= 1000) {
|
||||
return electron_1.BrowserView.fromId(id - 1000);
|
||||
}
|
||||
return electron_1.BrowserWindow.fromId(id);
|
||||
}
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
import { BrowserWindow } from 'electron';
|
||||
import { BrowserWindow, BrowserView } from 'electron';
|
||||
const fs = require('fs');
|
||||
let electronSocket;
|
||||
|
||||
@@ -30,19 +30,25 @@ export = (socket: SocketIO.Socket) => {
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('webContents-printToPDF', (id, options, path) => {
|
||||
getWindowById(id).webContents.printToPDF(options || {}, (error, data) => {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
socket.on('webContents-getPrinters', async (id) => {
|
||||
const printers = await getWindowById(id).webContents.getPrinters();
|
||||
electronSocket.emit('webContents-getPrinters-completed', printers);
|
||||
});
|
||||
|
||||
fs.writeFile(path, data, (error) => {
|
||||
if (error) {
|
||||
electronSocket.emit('webContents-printToPDF-completed', false);
|
||||
} else {
|
||||
electronSocket.emit('webContents-printToPDF-completed', true);
|
||||
}
|
||||
});
|
||||
socket.on('webContents-print', async (id, options = {}) => {
|
||||
await getWindowById(id).webContents.print(options);
|
||||
electronSocket.emit('webContents-print-completed', true);
|
||||
});
|
||||
|
||||
socket.on('webContents-printToPDF', async (id, options = {}, path) => {
|
||||
const buffer = await getWindowById(id).webContents.printToPDF(options);
|
||||
|
||||
fs.writeFile(path, buffer, (error) => {
|
||||
if (error) {
|
||||
electronSocket.emit('webContents-printToPDF-completed', false);
|
||||
} else {
|
||||
electronSocket.emit('webContents-printToPDF-completed', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,39 +62,39 @@ export = (socket: SocketIO.Socket) => {
|
||||
browserWindow.webContents.session.allowNTLMCredentialsForDomains(domains);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-clearAuthCache', (id, options, guid) => {
|
||||
socket.on('webContents-session-clearAuthCache', async (id, options, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.clearAuthCache(options, () => {
|
||||
electronSocket.emit('webContents-session-clearAuthCache-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.clearAuthCache(options);
|
||||
|
||||
electronSocket.emit('webContents-session-clearAuthCache-completed' + guid);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-clearCache', (id, guid) => {
|
||||
socket.on('webContents-session-clearCache', async (id, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.clearCache(() => {
|
||||
electronSocket.emit('webContents-session-clearCache-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.clearCache();
|
||||
|
||||
electronSocket.emit('webContents-session-clearCache-completed' + guid);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-clearHostResolverCache', (id, guid) => {
|
||||
socket.on('webContents-session-clearHostResolverCache', async (id, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.clearHostResolverCache(() => {
|
||||
electronSocket.emit('webContents-session-clearHostResolverCache-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.clearHostResolverCache();
|
||||
|
||||
electronSocket.emit('webContents-session-clearHostResolverCache-completed' + guid);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-clearStorageData', (id, guid) => {
|
||||
socket.on('webContents-session-clearStorageData', async (id, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.clearStorageData({}, () => {
|
||||
electronSocket.emit('webContents-session-clearStorageData-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.clearStorageData({});
|
||||
|
||||
electronSocket.emit('webContents-session-clearStorageData-completed' + guid);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-clearStorageData-options', (id, options, guid) => {
|
||||
socket.on('webContents-session-clearStorageData-options', async (id, options, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.clearStorageData(options, () => {
|
||||
electronSocket.emit('webContents-session-clearStorageData-options-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.clearStorageData(options);
|
||||
|
||||
electronSocket.emit('webContents-session-clearStorageData-options-completed' + guid);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-createInterruptedDownload', (id, options) => {
|
||||
@@ -111,18 +117,18 @@ export = (socket: SocketIO.Socket) => {
|
||||
browserWindow.webContents.session.flushStorageData();
|
||||
});
|
||||
|
||||
socket.on('webContents-session-getBlobData', (id, identifier, guid) => {
|
||||
socket.on('webContents-session-getBlobData', async (id, identifier, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.getBlobData(identifier, (buffer) => {
|
||||
electronSocket.emit('webContents-session-getBlobData-completed' + guid, buffer.buffer);
|
||||
});
|
||||
const buffer = await browserWindow.webContents.session.getBlobData(identifier);
|
||||
|
||||
electronSocket.emit('webContents-session-getBlobData-completed' + guid, buffer.buffer);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-getCacheSize', (id, guid) => {
|
||||
socket.on('webContents-session-getCacheSize', async (id, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.getCacheSize((size) => {
|
||||
electronSocket.emit('webContents-session-getCacheSize-completed' + guid, size);
|
||||
});
|
||||
const size = await browserWindow.webContents.session.getCacheSize();
|
||||
|
||||
electronSocket.emit('webContents-session-getCacheSize-completed' + guid, size);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-getPreloads', (id, guid) => {
|
||||
@@ -139,11 +145,11 @@ export = (socket: SocketIO.Socket) => {
|
||||
electronSocket.emit('webContents-session-getUserAgent-completed' + guid, userAgent);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-resolveProxy', (id, url, guid) => {
|
||||
socket.on('webContents-session-resolveProxy', async (id, url, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.resolveProxy(url, (proxy) => {
|
||||
electronSocket.emit('webContents-session-resolveProxy-completed' + guid, proxy);
|
||||
});
|
||||
const proxy = await browserWindow.webContents.session.resolveProxy(url);
|
||||
|
||||
electronSocket.emit('webContents-session-resolveProxy-completed' + guid, proxy);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-setDownloadPath', (id, path) => {
|
||||
@@ -156,11 +162,11 @@ export = (socket: SocketIO.Socket) => {
|
||||
browserWindow.webContents.session.setPreloads(preloads);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-setProxy', (id, configuration, guid) => {
|
||||
socket.on('webContents-session-setProxy', async (id, configuration, guid) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.session.setProxy(configuration, () => {
|
||||
electronSocket.emit('webContents-session-setProxy-completed' + guid);
|
||||
});
|
||||
await browserWindow.webContents.session.setProxy(configuration);
|
||||
|
||||
electronSocket.emit('webContents-session-setProxy-completed' + guid);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-setUserAgent', (id, userAgent, acceptLanguages) => {
|
||||
@@ -168,7 +174,22 @@ export = (socket: SocketIO.Socket) => {
|
||||
browserWindow.webContents.session.setUserAgent(userAgent, acceptLanguages);
|
||||
});
|
||||
|
||||
function getWindowById(id: number): Electron.BrowserWindow {
|
||||
socket.on('webContents-loadURL', (id, url, options) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.loadURL(url, options).then(() => {
|
||||
electronSocket.emit('webContents-loadURL-complete' + id);
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
electronSocket.emit('webContents-loadURL-error' + id, error);
|
||||
});
|
||||
});
|
||||
|
||||
function getWindowById(id: number): Electron.BrowserWindow | Electron.BrowserView {
|
||||
|
||||
if (id >= 1000) {
|
||||
return BrowserView.fromId(id - 1000);
|
||||
}
|
||||
|
||||
return BrowserWindow.fromId(id);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
const manifestFileName = process.argv[2];
|
||||
// @ts-ignore
|
||||
const manifestFile = require('./bin/electron.manifest');
|
||||
const manifestFile = require('./bin/' + manifestFileName);
|
||||
const dasherize = require('dasherize');
|
||||
const fs = require('fs');
|
||||
|
||||
const builderConfiguration = { ...manifestFile.build };
|
||||
if(builderConfiguration.hasOwnProperty('buildVersion')) {
|
||||
// @ts-ignore
|
||||
const packageJson = require('./package');
|
||||
packageJson.name = dasherize(manifestFile.name || 'electron-net');
|
||||
packageJson.author = manifestFile.author || '';
|
||||
packageJson.version = builderConfiguration.buildVersion;
|
||||
|
||||
fs.writeFile('./package.json', JSON.stringify(packageJson), (error) => {
|
||||
@@ -17,6 +21,8 @@ if(builderConfiguration.hasOwnProperty('buildVersion')) {
|
||||
try {
|
||||
// @ts-ignore
|
||||
const packageLockJson = require('./package-lock');
|
||||
packageLockJson.name = dasherize(manifestFile.name || 'electron-net');
|
||||
packageLockJson.author = manifestFile.author || '';
|
||||
packageLockJson.version = builderConfiguration.buildVersion;
|
||||
fs.writeFile('./package-lock.json', JSON.stringify(packageLockJson), (error) => {
|
||||
if(error) {
|
||||
@@ -33,4 +39,11 @@ fs.writeFile('./bin/electron-builder.json', builderConfigurationString, (error)
|
||||
if(error) {
|
||||
console.log(error.message);
|
||||
}
|
||||
});
|
||||
|
||||
const manifestContent = JSON.stringify(manifestFile);
|
||||
fs.writeFile('./bin/electron.manifest.json', manifestContent, (error) => {
|
||||
if(error) {
|
||||
console.log(error.message);
|
||||
}
|
||||
});
|
||||
@@ -3,11 +3,13 @@
|
||||
"splashscreen": {
|
||||
"imageFile": ""
|
||||
},
|
||||
"name": "{{executable}}",
|
||||
"author": "",
|
||||
"singleInstance": false,
|
||||
"build": {
|
||||
"appId": "com.{{executable}}.app",
|
||||
"productName": "{{executable}}",
|
||||
"copyright": "Copyright © 2019",
|
||||
"copyright": "Copyright © 2020",
|
||||
"buildVersion": "1.0.0",
|
||||
"compression": "maximum",
|
||||
"directories": {
|
||||
|
||||
@@ -1,16 +1,35 @@
|
||||
const { app } = require('electron');
|
||||
const { BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const process = require('child_process').spawn;
|
||||
const cProcess = require('child_process').spawn;
|
||||
const portscanner = require('portscanner');
|
||||
const imageSize = require('image-size');
|
||||
let io, server, browserWindows, ipc, apiProcess, loadURL;
|
||||
let appApi, menu, dialogApi, notification, tray, webContents;
|
||||
let globalShortcut, shellApi, screen, clipboard, autoUpdater;
|
||||
let commandLine, browserView;
|
||||
let splashScreen, hostHook;
|
||||
let mainWindowId;
|
||||
|
||||
let manifestJsonFileName = 'electron.manifest.json';
|
||||
let watchable = false;
|
||||
if (app.commandLine.hasSwitch('manifest')) {
|
||||
manifestJsonFileName = app.commandLine.getSwitchValue('manifest');
|
||||
};
|
||||
|
||||
if (app.commandLine.hasSwitch('watch')) {
|
||||
watchable = true;
|
||||
};
|
||||
|
||||
let currentBinPath = path.join(__dirname.replace('app.asar', ''), 'bin');
|
||||
let manifestJsonFilePath = path.join(currentBinPath, manifestJsonFileName);
|
||||
|
||||
// if watch is enabled lets change the path
|
||||
if (watchable) {
|
||||
currentBinPath = path.join(__dirname, '../../'); // go to project directory
|
||||
manifestJsonFilePath = path.join(currentBinPath, manifestJsonFileName);
|
||||
}
|
||||
|
||||
const currentBinPath = path.join(__dirname.replace('app.asar', ''), 'bin');
|
||||
const manifestJsonFilePath = path.join(currentBinPath, 'electron.manifest.json');
|
||||
const manifestJsonFile = require(manifestJsonFilePath);
|
||||
if (manifestJsonFile.singleInstance || manifestJsonFile.aspCoreBackendPort) {
|
||||
const mainInstance = app.requestSingleInstanceLock();
|
||||
@@ -57,7 +76,7 @@ function startSplashScreen() {
|
||||
imageSize(imageFile, (error, dimensions) => {
|
||||
if (error) {
|
||||
console.log(`load splashscreen error:`);
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
|
||||
throw new Error(error.message);
|
||||
}
|
||||
@@ -68,7 +87,7 @@ function startSplashScreen() {
|
||||
transparent: true,
|
||||
center: true,
|
||||
frame: false,
|
||||
alwaysOnTop: true,
|
||||
closable: false,
|
||||
skipTaskbar: true,
|
||||
show: true
|
||||
});
|
||||
@@ -100,16 +119,48 @@ function startSocketApiBridge(port) {
|
||||
server.on('listening', function () {
|
||||
console.log('Electron Socket started on port %s at %s', server.address().port, server.address().address);
|
||||
// Now that socket connection is established, we can guarantee port will not be open for portscanner
|
||||
startAspCoreBackend(port);
|
||||
if (watchable) {
|
||||
startAspCoreBackendWithWatch(port);
|
||||
} else {
|
||||
startAspCoreBackend(port);
|
||||
}
|
||||
});
|
||||
|
||||
// prototype
|
||||
app['mainWindowURL'] = "";
|
||||
app['mainWindow'] = null;
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
|
||||
// we need to remove previously cache instances
|
||||
// otherwise it will fire the same event multiple depends how many time
|
||||
// live reload watch happen.
|
||||
socket.on('disconnect', function () {
|
||||
console.log('Got disconnect!');
|
||||
delete require.cache[require.resolve('./api/app')];
|
||||
delete require.cache[require.resolve('./api/browserWindows')];
|
||||
delete require.cache[require.resolve('./api/commandLine')];
|
||||
delete require.cache[require.resolve('./api/autoUpdater')];
|
||||
delete require.cache[require.resolve('./api/ipc')];
|
||||
delete require.cache[require.resolve('./api/menu')];
|
||||
delete require.cache[require.resolve('./api/dialog')];
|
||||
delete require.cache[require.resolve('./api/notification')];
|
||||
delete require.cache[require.resolve('./api/tray')];
|
||||
delete require.cache[require.resolve('./api/webContents')];
|
||||
delete require.cache[require.resolve('./api/globalShortcut')];
|
||||
delete require.cache[require.resolve('./api/shell')];
|
||||
delete require.cache[require.resolve('./api/screen')];
|
||||
delete require.cache[require.resolve('./api/clipboard')];
|
||||
delete require.cache[require.resolve('./api/browserView')];
|
||||
});
|
||||
|
||||
global['electronsocket'] = socket;
|
||||
global['electronsocket'].setMaxListeners(0);
|
||||
console.log('ASP.NET Core Application connected...', 'global.electronsocket', global['electronsocket'].id, new Date());
|
||||
|
||||
appApi = require('./api/app')(socket, app);
|
||||
browserWindows = require('./api/browserWindows')(socket, app);
|
||||
commandLine = require('./api/commandLine')(socket, app);
|
||||
autoUpdater = require('./api/autoUpdater')(socket);
|
||||
ipc = require('./api/ipc')(socket);
|
||||
menu = require('./api/menu')(socket);
|
||||
@@ -121,6 +172,9 @@ function startSocketApiBridge(port) {
|
||||
shellApi = require('./api/shell')(socket);
|
||||
screen = require('./api/screen')(socket);
|
||||
clipboard = require('./api/clipboard')(socket);
|
||||
browserView = require('./api/browserView')(socket);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
const hostHookScriptFilePath = path.join(__dirname, 'ElectronHostHook', 'index.js');
|
||||
@@ -131,7 +185,7 @@ function startSocketApiBridge(port) {
|
||||
hostHook.onHostReady();
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error.message);
|
||||
console.error(error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -145,11 +199,11 @@ function isModuleAvailable(name) {
|
||||
}
|
||||
|
||||
function startAspCoreBackend(electronPort) {
|
||||
if(manifestJsonFile.aspCoreBackendPort) {
|
||||
if (manifestJsonFile.aspCoreBackendPort) {
|
||||
startBackend(manifestJsonFile.aspCoreBackendPort)
|
||||
} else {
|
||||
// hostname needs to be localhost, otherwise Windows Firewall will be triggered.
|
||||
portscanner.findAPortNotInUse(8000, 65535, 'localhost', function (error, electronWebPort) {
|
||||
portscanner.findAPortNotInUse(electronPort + 1, 65535, 'localhost', function (error, electronWebPort) {
|
||||
startBackend(electronWebPort);
|
||||
});
|
||||
}
|
||||
@@ -167,10 +221,37 @@ function startAspCoreBackend(electronPort) {
|
||||
|
||||
let binFilePath = path.join(currentBinPath, binaryFile);
|
||||
var options = { cwd: currentBinPath };
|
||||
apiProcess = process(binFilePath, parameters, options);
|
||||
apiProcess = cProcess(binFilePath, parameters, options);
|
||||
|
||||
apiProcess.stdout.on('data', (data) => {
|
||||
console.log(`stdout: ${data.toString()}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function startAspCoreBackendWithWatch(electronPort) {
|
||||
if (manifestJsonFile.aspCoreBackendPort) {
|
||||
startBackend(manifestJsonFile.aspCoreBackendPort)
|
||||
} else {
|
||||
// hostname needs to be localhost, otherwise Windows Firewall will be triggered.
|
||||
portscanner.findAPortNotInUse(electronPort + 1, 65535, 'localhost', function (error, electronWebPort) {
|
||||
startBackend(electronWebPort);
|
||||
});
|
||||
}
|
||||
|
||||
function startBackend(aspCoreBackendPort) {
|
||||
console.log('ASP.NET Core Watch Port: ' + aspCoreBackendPort);
|
||||
loadURL = `http://localhost:${aspCoreBackendPort}`;
|
||||
const parameters = ['watch', 'run', `/electronPort=${electronPort}`, `/electronWebPort=${aspCoreBackendPort}`];
|
||||
|
||||
var options = {
|
||||
cwd: currentBinPath,
|
||||
env: process.env,
|
||||
};
|
||||
apiProcess = cProcess('dotnet', parameters, options);
|
||||
|
||||
apiProcess.stdout.on('data', (data) => {
|
||||
console.log(`stdout: ${data.toString()}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
3389
ElectronNET.Host/package-lock.json
generated
3389
ElectronNET.Host/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,28 @@
|
||||
{
|
||||
"name": "electron.net.host",
|
||||
"version": "1.0.2",
|
||||
"description": "Electron-Host for Electron.NET.",
|
||||
"repository": {
|
||||
"url": "https://github.com/ElectronNET/Electron.NET"
|
||||
},
|
||||
"main": "main.js",
|
||||
"author": "Gregor Biswanger",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "tsc -p ."
|
||||
},
|
||||
"dependencies": {
|
||||
"electron-updater": "^4.0.6",
|
||||
"image-size": "^0.7.4",
|
||||
"portscanner": "^2.2.0",
|
||||
"socket.io": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^10.14.4",
|
||||
"@types/socket.io": "^2.1.2",
|
||||
"tslint": "^5.12.0",
|
||||
"typescript": "^3.2.2",
|
||||
"electron": "^5.0.8"
|
||||
}
|
||||
"name": "electron.net.host",
|
||||
"version": "1.0.0",
|
||||
"description": "Electron-Host for Electron.NET.",
|
||||
"repository": {
|
||||
"url": "https://github.com/ElectronNET/Electron.NET"
|
||||
},
|
||||
"main": "main.js",
|
||||
"author": "Gregor Biswanger",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "tsc -p ."
|
||||
},
|
||||
"dependencies": {
|
||||
"dasherize": "^2.0.0",
|
||||
"electron-updater": "^4.2.5",
|
||||
"image-size": "^0.7.4",
|
||||
"portscanner": "^2.2.0",
|
||||
"socket.io": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^10.14.4",
|
||||
"@types/socket.io": "^2.1.2",
|
||||
"electron": "^8.2.3",
|
||||
"tslint": "^6.1.1",
|
||||
"typescript": "^3.8.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2015",
|
||||
"target": "ES2019",
|
||||
"sourceMap": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ElectronNET.API;
|
||||
using System.Linq;
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ElectronNET.WebApp.Controllers
|
||||
{
|
||||
@@ -23,6 +28,19 @@ namespace ElectronNET.WebApp.Controllers
|
||||
var mainWindow = Electron.WindowManager.BrowserWindows.First();
|
||||
Electron.IpcMain.Send(mainWindow, "paste-from", pasteText);
|
||||
});
|
||||
|
||||
Electron.IpcMain.On("copy-image-to", (test) =>
|
||||
{
|
||||
var nativeImage = NativeImage.CreateFromDataURL(test.ToString());
|
||||
Electron.Clipboard.WriteImage(nativeImage);
|
||||
});
|
||||
|
||||
Electron.IpcMain.On("paste-image-to", async test =>
|
||||
{
|
||||
var nativeImage = await Electron.Clipboard.ReadImageAsync();
|
||||
var mainWindow = Electron.WindowManager.BrowserWindows.First();
|
||||
Electron.IpcMain.Send(mainWindow, "paste-image-from", JsonConvert.SerializeObject(nativeImage));
|
||||
});
|
||||
}
|
||||
|
||||
return View();
|
||||
|
||||
@@ -112,7 +112,9 @@ namespace ElectronNET.WebApp.Controllers
|
||||
new MenuItem { Label = "Electron.NET", Type = MenuType.checkbox, Checked = true }
|
||||
};
|
||||
|
||||
var mainWindow = Electron.WindowManager.BrowserWindows.First();
|
||||
var mainWindow = Electron.WindowManager.BrowserWindows.FirstOrDefault();
|
||||
if (mainWindow == null) return;
|
||||
|
||||
Electron.Menu.SetContextMenu(mainWindow, menu);
|
||||
|
||||
Electron.IpcMain.On("show-context-menu", (args) =>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
|
||||
<AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
|
||||
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
|
||||
<TypeScriptToolsVersion>3.6</TypeScriptToolsVersion>
|
||||
<TypeScriptToolsVersion>3.8</TypeScriptToolsVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="Controllers\ManageWindowsController.cs" />
|
||||
|
||||
@@ -9,16 +9,15 @@ namespace ElectronNET.WebApp
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BuildWebHost(args).Run();
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IWebHost BuildWebHost(string[] args)
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
|
||||
{
|
||||
return WebHost.CreateDefaultBuilder(args)
|
||||
.ConfigureLogging((hostingContext, logging) => { logging.AddConsole(); })
|
||||
.UseElectron(args)
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
.UseStartup<Startup>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</h1>
|
||||
<h3>The <code>Electron.Clipboard</code> provides methods to perform copy and paste operations.</h3>
|
||||
<p>This module also has methods for copying text as markup (HTML) to the clipboard.</p>
|
||||
|
||||
|
||||
<p>You find the sample source code in <code>Controllers\ClipboardController.cs</code>.</p>
|
||||
</div>
|
||||
</header>
|
||||
@@ -90,24 +90,206 @@ pasteBtn.addEventListener('click', () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
const { ipcRenderer } = require("electron");
|
||||
|
||||
<div class="demo">
|
||||
<div class="demo-wrapper">
|
||||
<button id="copy-to-demo-toggle" class="js-container-target demo-toggle-button">
|
||||
Copy Image
|
||||
<div class="demo-meta u-avoid-clicks">Supports: Win, macOS, Linux <span class="demo-meta-divider">|</span> Process: Both</div>
|
||||
</button>
|
||||
<div class="demo-box">
|
||||
<div class="demo-controls">
|
||||
<button class="demo-button" id="copy-image-to">Copy</button>
|
||||
<textarea id="paste-image-div" onpaste="console.log('onpastefromhtml')"></textarea>
|
||||
<div class="demo-image-box" id="image-paste-div"></div>
|
||||
</div>
|
||||
<p>In this example we copy an image to the Clipboard. After clicking 'Copy' use the text area to paste (CMD + V or CTRL + V) the image from the clipboard.</p>
|
||||
<h5>Main Process (C#)</h5>
|
||||
<pre><code class="csharp">Electron.IpcMain.On("copy-image-to", async (test) =>
|
||||
{
|
||||
var nativeImage = NativeImage.CreateFromDataURL(test.ToString());
|
||||
Electron.Clipboard.WriteImage(nativeImage);
|
||||
});</code></pre>
|
||||
<div class="demo-protip">
|
||||
<h2>ProTip</h2>
|
||||
<strong>Electron.js Support in Electron.NET.</strong>
|
||||
<p>The <code>clipboard</code> module is built into Electron.js (therefore you can use this in the renderer processes).</p>
|
||||
<pre><code class="language-js">const { nativeImage, clipboard } = require('electron');
|
||||
|
||||
const copyBtn = document.getElementById('copy-to-image');
|
||||
const imageDataUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACmklEQVR42oVTX0hTURj/zr2b07utMR0st2m30UxZJRHpWNDjRkUPvgUZQdGD4Esq6yWf9EVx9iL4EAiBVNDDHqxs9RBI+ZcorLVSkemcNdmct827Oe92Ot1b270i9MHHOfc73/f7fvd3zofggGU/OD1k8RJ3E2/6Gw4TnyYerDoXei3PR/82uwtOliydlJbtoA1OhtY7AFVZxDOc3YRiegkELsRjPjKKMYxoz3+NlAAyc00sBuhTm9ztavNFoBizhIqVbYrZOOzHp0DYmhkHhHt1reGIePTrfeOQ2tzaranzAqI1cmJlw1IYF3KwF30F+a0Fv8Ed7kHbU40elc4SYOxXGJoxibmDl++D70W/AkeMvewX94VsEvjV57yQjrWhxNuTfsbW0lVlaynxHbw6AL4Jn9QSkdb4QIzQ4TfmIbsxP4zibxpmjE6vS33EfCjzEn+MFHrkuTikQsFZFJt07BxtvWSgVBXwX8MyQYU8xOcmObQ+cWLH6rpAANQy2RU3LKssX0tR2IfY7DsOrQbsM7VnHK5Kg04S69o8+J62HEpAfpbjMvBjcXkWrTw77jeyxq7qeqOUdH0J2u7pwNFsUbyF5cVNCAxkwPe4QfxORVKQXNsZRt+esJ5KvSpQ26hnKrQ0JBI5GLvLSSCntFLxl12x+NYDA5hqNJDnC/Dze4bPpgtt4o+Gxo8NGS10t9lOA6VCkEhViCByE4ur96C4j2BrVYDtWMHvvLHWIwJ8flTPEqp91dZie40Ng0ZbFIVKxCT+JqsEsscjSEYpUkyRpwy9p2+uR0pSfxqrYxFGnYxB6NDXCIzOKEDlHyCSkctQkEmpIJ1U8TxHj5L0kebb0fIwye3jQ5uH9PUiQIpxxoCnSSx49k5UMc6/ARiuBRgyrEC3AAAAAElFTkSuQmCC';
|
||||
|
||||
copyBtn.addEventListener('click', () => {
|
||||
var image = nativeImage.CreateFromDataURL(imageDataUrl);
|
||||
clipboard.WriteImage(image);
|
||||
})
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="demo">
|
||||
<div class="demo-wrapper">
|
||||
<button id="copy-to-demo-toggle" class="js-container-target demo-toggle-button">
|
||||
Paste Image
|
||||
<div class="demo-meta u-avoid-clicks">Supports: Win, macOS, Linux <span class="demo-meta-divider">|</span> Process: Both</div>
|
||||
</button>
|
||||
<div class="demo-box">
|
||||
<div class="demo-controls">
|
||||
<button class="demo-button" id="paste-image-from">Paste</button>
|
||||
<img class="demo-image-box" id="paste-image-from-div"></img>
|
||||
</div>
|
||||
<p>In this example we paste an image from the Clipboard. After clicking 'Paste', if your clipboard contained an image, the image will show up next to the paste button.</p>
|
||||
<h5>Main Process (C#)</h5>
|
||||
<pre><code class="csharp">Electron.IpcMain.On("paste-image-to", async test =>
|
||||
{
|
||||
var nativeImage = await Electron.Clipboard.ReadImageAsync();
|
||||
var mainWindow = Electron.WindowManager.BrowserWindows.First();
|
||||
Electron.IpcMain.Send(mainWindow, "paste-image-from", JsonConvert.SerializeObject(nativeImage));
|
||||
});</code></pre>
|
||||
<div class="demo-protip">
|
||||
<h2>ProTip</h2>
|
||||
<strong>Electron.js Support in Electron.NET.</strong>
|
||||
<p>The <code>clipboard</code> module is built into Electron.js (therefore you can use this in the renderer processes).</p>
|
||||
<pre><code class="language-js">const { nativeImage, clipboard } = require('electron');
|
||||
|
||||
const pasteBtn = document.getElementById('paste-to-image');
|
||||
|
||||
copyBtn.addEventListener('click', () => {
|
||||
const image = clipboard.readImage();
|
||||
document.getElementById('image-holder').src = image.toDataURL();
|
||||
})</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
const { ipcRenderer, nativeImage } = require("electron");
|
||||
|
||||
document.getElementById("copy-to").addEventListener("click", () => {
|
||||
document.getElementById('copy-to-input').placeholder = 'Copied! Paste here to see.';
|
||||
ipcRenderer.send("copy-to", "Electron.NET Demo!");
|
||||
});
|
||||
|
||||
|
||||
document.getElementById("paste-to").addEventListener("click", () => {
|
||||
ipcRenderer.send("paste-to", "What a demo!");
|
||||
});
|
||||
|
||||
document.getElementById("copy-image-to").addEventListener("click", () => {
|
||||
ipcRenderer.send("copy-image-to", 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACmklEQVR42oVTX0hTURj/zr2b07utMR0st2m30UxZJRHpWNDjRkUPvgUZQdGD4Esq6yWf9EVx9iL4EAiBVNDDHqxs9RBI+ZcorLVSkemcNdmct827Oe92Ot1b270i9MHHOfc73/f7fvd3zofggGU/OD1k8RJ3E2/6Gw4TnyYerDoXei3PR/82uwtOliydlJbtoA1OhtY7AFVZxDOc3YRiegkELsRjPjKKMYxoz3+NlAAyc00sBuhTm9ztavNFoBizhIqVbYrZOOzHp0DYmhkHhHt1reGIePTrfeOQ2tzaranzAqI1cmJlw1IYF3KwF30F+a0Fv8Ed7kHbU40elc4SYOxXGJoxibmDl++D70W/AkeMvewX94VsEvjV57yQjrWhxNuTfsbW0lVlaynxHbw6AL4Jn9QSkdb4QIzQ4TfmIbsxP4zibxpmjE6vS33EfCjzEn+MFHrkuTikQsFZFJt07BxtvWSgVBXwX8MyQYU8xOcmObQ+cWLH6rpAANQy2RU3LKssX0tR2IfY7DsOrQbsM7VnHK5Kg04S69o8+J62HEpAfpbjMvBjcXkWrTw77jeyxq7qeqOUdH0J2u7pwNFsUbyF5cVNCAxkwPe4QfxORVKQXNsZRt+esJ5KvSpQ26hnKrQ0JBI5GLvLSSCntFLxl12x+NYDA5hqNJDnC/Dze4bPpgtt4o+Gxo8NGS10t9lOA6VCkEhViCByE4ur96C4j2BrVYDtWMHvvLHWIwJ8flTPEqp91dZie40Ng0ZbFIVKxCT+JqsEsscjSEYpUkyRpwy9p2+uR0pSfxqrYxFGnYxB6NDXCIzOKEDlHyCSkctQkEmpIJ1U8TxHj5L0kebb0fIwye3jQ5uH9PUiQIpxxoCnSSx49k5UMc6/ARiuBRgyrEC3AAAAAElFTkSuQmCC');
|
||||
});
|
||||
|
||||
document.getElementById("paste-image-from").addEventListener("click", () => {
|
||||
ipcRenderer.send("paste-image-to");
|
||||
});
|
||||
|
||||
ipcRenderer.on("paste-from", (sender, text) => {
|
||||
const message = `Clipboard contents: ${text}`;
|
||||
document.getElementById("paste-from").innerText = message;
|
||||
});
|
||||
|
||||
ipcRenderer.on("paste-image-from", (sender, data) => {
|
||||
console.log(data);
|
||||
var data = JSON.parse(data);
|
||||
const ni = nativeImage.createEmpty();
|
||||
for (var i in data) {
|
||||
var scaleFactor = i;
|
||||
var bytes = data[i];
|
||||
var buff = Buffer.from(bytes, 'base64');
|
||||
ni.addRepresentation({ scaleFactor: scaleFactor, buffer: buff });
|
||||
}
|
||||
|
||||
document.getElementById("paste-image-from-div").src = ni.toDataURL();
|
||||
});
|
||||
|
||||
|
||||
var PasteImage = function (el) {
|
||||
this._el = el;
|
||||
this._listenForPaste();
|
||||
};
|
||||
|
||||
PasteImage.prototype._getURLObj = function () {
|
||||
return window.URL || window.webkitURL;
|
||||
};
|
||||
|
||||
PasteImage.prototype._pasteImage = function (image) {
|
||||
this.emit('paste-image', image);
|
||||
};
|
||||
|
||||
PasteImage.prototype._pasteImageSource = function (src) {
|
||||
var self = this,
|
||||
image = new Image();
|
||||
|
||||
image.onload = function () {
|
||||
self._pasteImage(image);
|
||||
};
|
||||
|
||||
image.src = src;
|
||||
};
|
||||
|
||||
PasteImage.prototype._onPaste = function (e) {
|
||||
|
||||
// We need to check if event.clipboardData is supported (Chrome & IE)
|
||||
if (e.clipboardData && e.clipboardData.items) {
|
||||
|
||||
// Get the items from the clipboard
|
||||
var items = e.clipboardData.items;
|
||||
|
||||
// Loop through all items, looking for any kind of image
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].type.indexOf('image') !== -1) {
|
||||
// We need to represent the image as a file
|
||||
var blob = items[i].getAsFile();
|
||||
|
||||
// Use a URL or webkitURL (whichever is available to the browser) to create a
|
||||
// temporary URL to the object
|
||||
var URLObj = this._getURLObj();
|
||||
var source = URLObj.createObjectURL(blob);
|
||||
|
||||
// The URL can then be used as the source of an image
|
||||
this._pasteImageSource(source);
|
||||
|
||||
// Prevent the image (or URL) from being pasted into the contenteditable element
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PasteImage.prototype._listenForPaste = function () {
|
||||
var self = this;
|
||||
|
||||
self._origOnPaste = self._el.onpaste;
|
||||
|
||||
self._el.addEventListener('paste', function (e) {
|
||||
|
||||
self._onPaste(e);
|
||||
|
||||
// Preserve an existing onpaste event handler
|
||||
if (self._origOnPaste) {
|
||||
self._origOnPaste.apply(this, arguments);
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
PasteImage.prototype.on = function (event, callback) {
|
||||
this._callback = callback;
|
||||
};
|
||||
|
||||
PasteImage.prototype.emit = function (event, arg) {
|
||||
this._callback(arg);
|
||||
};
|
||||
|
||||
var pasteImage = new PasteImage(document.getElementById('paste-image-div'));
|
||||
|
||||
pasteImage.on('paste-image', function (image) {
|
||||
document.getElementById('image-paste-div').appendChild(image);
|
||||
});
|
||||
|
||||
|
||||
}());
|
||||
</script>
|
||||
|
||||
|
||||
@@ -203,3 +203,7 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Clipboard paste image ------------------ */
|
||||
.demo-image-box {
|
||||
padding-left: 15px;
|
||||
}
|
||||
144
README.md
144
README.md
@@ -9,7 +9,7 @@ AppVeyor (Win/Linux): [: [](https://travis-ci.org/ElectronNET/Electron.NET)
|
||||
|
||||
Build cross platform desktop apps with .NET Core 2.2 and ASP.NET NET Core.
|
||||
Build cross platform desktop apps with .NET Core 3.1 and ASP.NET NET Core (Razor Pages, MVC), Blazor.
|
||||
|
||||
Electron.NET is a __wrapper__ around a "normal" Electron application with an embedded ASP.NET Core application. Via our Electron.NET IPC bridge we can invoke Electron APIs from .NET.
|
||||
|
||||
@@ -19,87 +19,65 @@ The CLI extensions hosts our toolset to build and start Electron.NET application
|
||||
|
||||
Well... there are lots of different approaches how to get a X-plat desktop app running. We thought it would be nice for .NET devs to use the ASP.NET Core environment and just embed it inside a pretty robust X-plat enviroment called Electron. Porting Electron to .NET is not a goal of this project, at least we don't have any clue how to do it. We just combine ASP.NET Core & Electron.
|
||||
|
||||
# NuGet:
|
||||
## 📦 NuGet:
|
||||
|
||||
* API [](https://www.nuget.org/packages/ElectronNET.API/)
|
||||
* CLI [](https://www.nuget.org/packages/ElectronNET.CLI/)
|
||||
|
||||
# Requirements to run:
|
||||
## 🛠 Requirements to run:
|
||||
|
||||
The current Electron.NET CLI builds Windows/macOS/Linux binaries. Our API uses .NET Core 3.0, so our minimum base OS is the same as [.NET Core 3.0](https://github.com/dotnet/core/blob/master/release-notes/3.0/3.0-supported-os.md).
|
||||
The current Electron.NET CLI builds Windows/macOS/Linux binaries. Our API uses .NET Core 3.1, so our minimum base OS is the same as [.NET Core 3.1](https://github.com/dotnet/core/blob/master/release-notes/3.1/3.1-supported-os.md).
|
||||
|
||||
Also you should have installed:
|
||||
|
||||
* npm
|
||||
* npm [contained in nodejs](https://nodejs.org)
|
||||
|
||||
# Community
|
||||
## 💬 Community
|
||||
|
||||
[](https://gitter.im/ElectronNET/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
|
||||
# Usage:
|
||||
## 🙏 Donate
|
||||
|
||||
We do this open source work in our free time. If you'd like us to invest more time on it, please [donate](https://donorbox.org/electron-net). Donation can be used to increase some issue priority. Thank you!
|
||||
|
||||
[](https://donorbox.org/electron-net)
|
||||
|
||||
## 👩🏫 Usage
|
||||
|
||||
To activate and communicate with the "native" (sort of native...) Electron API include the [ElectronNET.API NuGet package](https://www.nuget.org/packages/ElectronNET.API/) in your ASP.NET Core app.
|
||||
|
||||
````
|
||||
PM> Install-Package ElectronNET.API
|
||||
````
|
||||
## Program.cs
|
||||
### Program.cs
|
||||
|
||||
You start Electron.NET up with an `UseElectron` WebHostBuilder-Extension.
|
||||
|
||||
```csharp
|
||||
public static IWebHost BuildWebHost(string[] args)
|
||||
{
|
||||
return WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>()
|
||||
.UseElectron(args)
|
||||
.Build();
|
||||
}
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseElectron(args);
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
```
|
||||
|
||||
## Startup.cs
|
||||
### Startup.cs
|
||||
|
||||
Open the Electron Window in the Startup.cs file:
|
||||
|
||||
```csharp
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddMvc(option => option.EnableEndpointRouting = false);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseBrowserLink();
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
name: "default",
|
||||
template: "{controller=Home}/{action=Index}/{id?}");
|
||||
});
|
||||
...
|
||||
|
||||
// Open the Electron-Window here
|
||||
Task.Run(async () => await Electron.WindowManager.CreateWindowAsync());
|
||||
}
|
||||
```
|
||||
|
||||
__Please note:__ Currently it is important to use ASP.NET Core with MVC. If you are working with the dotnet CLI, use
|
||||
|
||||
```
|
||||
dotnet new mvc
|
||||
```
|
||||
|
||||
## Start the Application
|
||||
## 🚀 Start the Application
|
||||
|
||||
To start the application make sure you have installed the "[ElectronNET.CLI](https://www.nuget.org/packages/ElectronNET.CLI/)" packages as global tool:
|
||||
|
||||
@@ -119,21 +97,34 @@ electronize init
|
||||
```
|
||||
electronize start
|
||||
```
|
||||
|
||||
### Note
|
||||
> Only the first electronize start is slow. The next will go on faster.
|
||||
|
||||
## Debug
|
||||
## 🔭 Develop Electron.NET apps using a file watcher
|
||||
|
||||
The file watcher is included with version 8.31.1 of Electron.NET. For example, a file change can trigger compilation, test execution, or deployment. The Electron.NET window will automatically refresh and new code changes will be visible more quickly. The following Electron.NET CLI command is required:
|
||||
|
||||
```
|
||||
electronize start /watch
|
||||
```
|
||||
|
||||
### Note
|
||||
> Only the first electronize start is slow. The next will go on faster.
|
||||
|
||||
## 🐞 Debug
|
||||
|
||||
Start your Electron.NET application with the Electron.NET CLI command. In Visual Studio attach to your running application instance. Go in the __Debug__ Menu and click on __Attach to Process...__. Sort by your projectname on the right and select it on the list.
|
||||
|
||||
## Usage of the Electron-API
|
||||
|
||||
## 📔 Usage of the Electron-API
|
||||
|
||||
A complete documentation will follow. Until then take a look in the source code of the sample application:
|
||||
[Electron.NET API Demos](https://github.com/ElectronNET/electron.net-api-demos)
|
||||
|
||||
In this YouTube video, we show you how you can create a new project, use the Electron.NET API, debug a application and build an executable desktop app for Windows: [Electron.NET - Getting Started](https://www.youtube.com/watch?v=nuM6AojRFHk)
|
||||
|
||||
## Build
|
||||
## ⛏ Build
|
||||
|
||||
Here you need the Electron.NET CLI as well. Type the following command in your ASP.NET Core folder:
|
||||
|
||||
@@ -162,7 +153,19 @@ The end result should be an electron app under your __/bin/desktop__ folder.
|
||||
### Note
|
||||
> macOS builds can't be created on Windows machines because they require symlinks that aren't supported on Windows (per [this Electron issue](https://github.com/electron-userland/electron-packager/issues/71)). macOS builds can be produced on either Linux or macOS machines.
|
||||
|
||||
# Working with this Repo
|
||||
## 👨💻 Authors
|
||||
|
||||
* **Gregor Biswanger** - (Microsoft MVP, Intel Black Belt and Intel Software Innovator) is a freelance lecturer, consultant, trainer, author and speaker. He is a consultant for large and medium-sized companies, organizations and agencies for software architecture, web- and cross-platform development. You can find Gregor often on the road attending or speaking at international conferences. - [Cross-Platform-Blog](http://www.cross-platform-blog.com) - Twitter [@BFreakout](https://www.twitter.com/BFreakout)
|
||||
* **Robert Muehsig** - Software Developer - from Dresden, Germany, now living & working in Switzerland. Microsoft MVP & Web Geek. - [codeinside Blog](https://blog.codeinside.eu) - Twitter [@robert0muehsig](https://twitter.com/robert0muehsig)
|
||||
|
||||
See also the list of [contributors](https://github.com/ElectronNET/Electron.NET/graphs/contributors) who participated in this project.
|
||||
|
||||
|
||||
## 🙋♀️🙋♂ Contributing
|
||||
Feel free to submit a pull request if you find any bugs (to see a list of active issues, visit the [Issues section](https://github.com/ElectronNET/Electron.NET/issues).
|
||||
Please make sure all commits are properly documented.
|
||||
|
||||
## 🧪 Working with this Repo
|
||||
|
||||
This repository consists of the main parts (API & CLI) and it's own "playground" ASP.NET Core application. Both main parts produce local NuGet packages, that are versioned with 99.0.0. The first thing you will need is to run one of the buildAll scripts (.cmd for Windows, the other for macOS/Linux).
|
||||
|
||||
@@ -170,31 +173,28 @@ If you look for pure __[demo projects](https://github.com/ElectronNET)__ checkou
|
||||
|
||||
The problem working with this repository is, that NuGet has a pretty aggressive cache, see [here for further information](https://github.com/ElectronNET/Electron.NET/wiki).
|
||||
|
||||
# Contributing
|
||||
Feel free to submit a pull request if you find any bugs (to see a list of active issues, visit the [Issues section](https://github.com/ElectronNET/Electron.NET/issues).
|
||||
Please make sure all commits are properly documented.
|
||||
|
||||
# Authors
|
||||
|
||||
* **Gregor Biswanger** - (Microsoft MVP, Intel Black Belt and Intel Software Innovator) is a freelance lecturer, consultant, trainer, author and speaker. He is a consultant for large and medium-sized companies, organizations and agencies for software architecture, web- and cross-platform development. You can find Gregor often on the road attending or speaking at international conferences. - [Cross-Platform-Blog](http://www.cross-platform-blog.com) - Twitter [@BFreakout](https://www.twitter.com/BFreakout)
|
||||
* **Robert Muehsig** - Software Developer - from Dresden, Germany, now living & working in Switzerland. Microsoft MVP & Web Geek. - [codeinside Blog](https://blog.codeinside.eu) - Twitter [@robert0muehsig](https://twitter.com/robert0muehsig)
|
||||
|
||||
See also the list of [contributors](https://github.com/ElectronNET/Electron.NET/graphs/contributors) who participated in this project.
|
||||
|
||||
## Donate
|
||||
## 🙏 Donate
|
||||
|
||||
We do this open source work in our free time. If you'd like us to invest more time on it, please [donate](https://donorbox.org/electron-net). Donation can be used to increase some issue priority. Thank you!
|
||||
|
||||
# License
|
||||
[](https://donorbox.org/electron-net)
|
||||
|
||||
## 🎉 License
|
||||
MIT-licensed
|
||||
|
||||
**Enjoy!**
|
||||
|
||||
# Important notes
|
||||
## 📝 Important notes
|
||||
|
||||
## ElectronNET.API & ElectronNET.CLI Version 5.22.12
|
||||
### ElectronNET.API & ElectronNET.CLI Version 8.31.1
|
||||
|
||||
Make sure you also have the new Electron.NET CLI 5.22.12 version. This now uses [electron-builder](https://www.electron.build/configuration/configuration) and the necessary configuration to build is made in the **electron.manifest.json** file. In addition, own Electron.NET configurations are stored. Please make sure that your **electron.manifest.json** file has the following new structure:
|
||||
Make sure you also have the new Electron.NET API & CLI 8.31.1 version.
|
||||
|
||||
```
|
||||
dotnet tool update ElectronNET.CLI -g
|
||||
```
|
||||
|
||||
This now uses [electron-builder](https://www.electron.build/configuration/configuration) and the necessary configuration to build is made in the **electron.manifest.json** file (on the build part). In addition, own Electron.NET configurations are stored (on the root). Please make sure that your **electron.manifest.json** file has the following new structure:
|
||||
|
||||
```
|
||||
{
|
||||
@@ -202,11 +202,13 @@ Make sure you also have the new Electron.NET CLI 5.22.12 version. This now uses
|
||||
"splashscreen": {
|
||||
"imageFile": ""
|
||||
},
|
||||
"name": "{{executable}}",
|
||||
"author": "",
|
||||
"singleInstance": false,
|
||||
"build": {
|
||||
"appId": "com.{{executable}}.app",
|
||||
"productName": "{{executable}}",
|
||||
"copyright": "Copyright © 2019",
|
||||
"copyright": "Copyright © 2020",
|
||||
"buildVersion": "1.0.0",
|
||||
"compression": "maximum",
|
||||
"directories": {
|
||||
@@ -231,7 +233,7 @@ Make sure you also have the new Electron.NET CLI 5.22.12 version. This now uses
|
||||
}
|
||||
```
|
||||
|
||||
## ElectronNET.CLI Version 0.0.9
|
||||
### ElectronNET.CLI Version 0.0.9
|
||||
|
||||
In the Version 0.0.9 the CLI was not a global tool and needed to be registred like this in the .csproj:
|
||||
|
||||
@@ -251,10 +253,10 @@ dotnet restore
|
||||
If you still use this version you will need to invoke it like this:
|
||||
|
||||
```
|
||||
dotnet electronize ...
|
||||
electronize ...
|
||||
```
|
||||
|
||||
## Node Integration
|
||||
### Node Integration
|
||||
Electron.NET requires Node Integration to be enabled for IPC to function. If you are not using the IPC functionality you can disable Node Integration like so:
|
||||
|
||||
```csharp
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
set ENETVER=5.30.0-beta
|
||||
set ENETVER=8.31.1
|
||||
echo "Start building Electron.NET dev stack..."
|
||||
echo "Restore & Build API"
|
||||
cd ElectronNet.API
|
||||
|
||||
Reference in New Issue
Block a user