Compare commits

...

141 Commits

Author SHA1 Message Date
Robert Muehsig
a2514ed5bc build script updated 2023-03-27 20:04:37 +02:00
Gregor Biswanger
b453278803 Update to new Electron.NET 23.6.1 2023-03-24 14:16:14 +01:00
Gregor Biswanger
a244382383 Add workaround for web-socket communication 2023-03-24 14:15:55 +01:00
Gregor Biswanger
a82e714ef8 Update Changelog für Electron.NET 23.6.1 2023-03-24 13:27:21 +01:00
Gregor Biswanger
b339485fdc Change signature of PrintToPDFOptions 2023-03-24 13:26:15 +01:00
Gregor Biswanger
551635867d Replace deprecated scroll-touch-events with input-event 2023-03-24 01:50:13 +01:00
Gregor Biswanger
941b8cf5c2 Add vscode dev profiles 2023-03-24 01:47:11 +01:00
Gregor Biswanger
06b01f75da Update Demo App to 23.6.1 2023-03-23 20:53:58 +01:00
Gregor Biswanger
e4b1f6586e Update NPM packages 2023-03-23 20:42:42 +01:00
Gregor Biswanger
0657a274d4 Add socket.io client csharp package 2023-03-23 20:29:08 +01:00
Gregor Biswanger
e3acc79c4f Change to .NET 6 build 2023-03-15 23:26:09 +01:00
Gregor Biswanger
73c1d1cd46 Upgrade to .NET 7 2023-02-24 14:56:40 +01:00
Robert Muehsig
c2a8c627b9 13.5.1 2021-07-08 14:09:44 +02:00
Gregor Biswanger
1862094861 Merge pull request #585 from tub5/bug/584
If we provide the Version parameter and haven't included the version …
2021-07-02 17:18:41 +02:00
Gregor Biswanger
0ad89c7d22 RequestSingleInstanceLockAsync callback does work now - bug fix #519 2021-07-02 17:18:14 +02:00
tub5
0af664b8a6 If we provide the Version parameter and haven't included the version or product version dotnet flag then add them.
Fixes: #584
2021-07-02 16:07:31 +01:00
Gregor Biswanger
afcd113675 singleInstance handle command line arguments 2021-07-02 16:50:48 +02:00
Gregor Biswanger
0e22ee3fd3 Changed CLI help text 2021-07-02 12:47:51 +02:00
Gregor Biswanger
ce0cdf39c6 Update to native Electron 13.1.5, Update Changelog 2021-07-02 02:04:23 +02:00
Gregor Biswanger
305544ab42 Merge pull request #579 from tub5/bug/578
Upgrade to use Electron 12.0.12
2021-07-01 23:43:10 +02:00
Gregor Biswanger
78d9d601b1 Merge branch 'master' into bug/578 2021-07-01 23:42:09 +02:00
Gregor Biswanger
fdd643ba48 Merge pull request #573 from tantumalice/serialization-fix
Vibrancy serialization fix
2021-07-01 23:40:09 +02:00
Gregor Biswanger
29a257251f Merge pull request #570 from cristiangiagante/net5_compat
Changes PublishSingleFile default to false for NET5 compatibility
2021-07-01 23:38:27 +02:00
Gregor Biswanger
3676db89d3 Merge branch 'master' into net5_compat 2021-07-01 23:38:19 +02:00
Gregor Biswanger
29011189f8 Merge pull request #582 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/ws-7.4.6
Bump ws from 7.4.2 to 7.4.6 in /ElectronNET.Host
2021-07-01 23:25:54 +02:00
Gregor Biswanger
9d7d859764 Merge pull request #583 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/lodash-4.17.21
Bump lodash from 4.17.19 to 4.17.21 in /ElectronNET.Host
2021-07-01 23:25:24 +02:00
Gregor Biswanger
5cdda5595a Merge pull request #581 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/normalize-url-4.5.1
Bump normalize-url from 4.5.0 to 4.5.1 in /ElectronNET.Host
2021-07-01 23:25:01 +02:00
Gregor Biswanger
62fe944ae3 Merge pull request #565 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.WebApp/ElectronHostHook/lodash-4.17.21
Bump lodash from 4.17.19 to 4.17.21 in /ElectronNET.WebApp/ElectronHostHook
2021-07-01 23:24:25 +02:00
Gregor Biswanger
617eb15df8 Merge pull request #562 from TSrgy/using-exit-code
Using exit code instead of seek for the term 'error'
2021-07-01 23:24:10 +02:00
Gregor Biswanger
bff71dc86a Merge pull request #561 from nfichter/proxy-credentials
Add support for proxies that require basic username/password authentication
2021-07-01 23:20:36 +02:00
Gregor Biswanger
f0280f420a Merge pull request #560 from nfichter/ipc-to-browser-view
Allow IpcMain to send IPC messages to BrowserViews
2021-07-01 23:18:55 +02:00
Gregor Biswanger
9f7809810f Merge pull request #559 from nfichter/insert-css
Add WebContents insertCSS functionality
2021-07-01 23:16:53 +02:00
Gregor Biswanger
e610c96550 Merge pull request #547 from Funkrusha/feature/enable-post-requests
Add PostData to LoadURLOptions to allow http-posts in LoadURL calls
2021-07-01 23:13:19 +02:00
Gregor Biswanger
f3bd3d07d5 Merge pull request #546 from tub5/master
Fixes Add ability to pass an argument for "Version" for both the "dot…
2021-07-01 22:55:15 +02:00
Gregor Biswanger
0e8cfec689 Merge branch 'master' into master 2021-07-01 22:55:09 +02:00
Gregor Biswanger
c1b3d422d5 Merge pull request #540 from MiniguyBrendan/master
Resolve #539, #357 - Fix splash screen interaction causing crashes, ghost dragging, and resizable behavior
2021-07-01 22:41:00 +02:00
dependabot[bot]
fc12363e11 Bump lodash from 4.17.19 to 4.17.21 in /ElectronNET.Host
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

---
updated-dependencies:
- dependency-name: lodash
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-01 18:17:06 +00:00
dependabot[bot]
02f2fd770c Bump ws from 7.4.2 to 7.4.6 in /ElectronNET.Host
Bumps [ws](https://github.com/websockets/ws) from 7.4.2 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.4.2...7.4.6)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-01 18:16:42 +00:00
dependabot[bot]
5ee1918bb4 Bump normalize-url from 4.5.0 to 4.5.1 in /ElectronNET.Host
Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/sindresorhus/normalize-url/releases)
- [Commits](https://github.com/sindresorhus/normalize-url/commits)

---
updated-dependencies:
- dependency-name: normalize-url
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-01 18:16:36 +00:00
dependabot[bot]
2213c61746 Bump lodash in /ElectronNET.WebApp/ElectronHostHook
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-01 18:16:36 +00:00
Gregor Biswanger
3cdff747fe Merge pull request #531 from stackify/issue/523
fixes #523 allow for property overrides to be passed in
2021-07-01 20:12:04 +02:00
tub5
476cc9e505 Updating ContextIsolation as per the comment from @danatcofo. "on electron v12 WebPreferences.contextIsolation defaults to true… this means that window.require() will no longer function" 2021-06-28 15:55:16 +01:00
tub5
fb8ca94e8e Upgrade to use Electron 12.0.12
Resolves #578
2021-06-28 12:46:17 +01:00
tub5
c94702fc60 Remove incorrect text at the top of the file 2021-06-28 12:10:05 +01:00
Alisa Semenova
cd9e06d5db Vibrancy serialization fix 2021-06-14 16:52:33 +03:00
Cristian Giagante
613f0a05b3 Changes PublishSingleFile default to false for NET5 compatibility 2021-06-02 22:39:28 -03:00
TSrgy
de2ce85a5c write command to console 2021-04-29 21:25:42 +05:00
TSrgy
e5d47e077b escape arguments for bash 2021-04-29 21:11:16 +05:00
TSrgy
ac77ccce9f Using exit code 2021-04-29 08:29:36 +05:00
Noah Fichter
504cc59760 Remove app argument from browserViewApi since it's no longer needed 2021-04-26 14:45:02 -04:00
Noah Fichter
0ee7097f31 Add support for proxies that require basic authentication 2021-04-26 14:38:41 -04:00
Noah Fichter
2d93d959f7 Allow IpcMain to send IPC messages to BrowserViews 2021-04-26 13:04:34 -04:00
Noah Fichter
a4d261a4e7 Add WebContents insertCSS functionality 2021-04-26 12:41:14 -04:00
Martin Schweizer
3838fe8971 Add PostData to LoadURLOptions to allow http-posts in LoadURL calls
Enable the possibility to post data to external Url's with the BrowserWindow.LoadURL function. The post data is provided through LoadURLOptions
2021-03-12 16:31:29 +01:00
tub5
b5e69f5dda Fixes Add ability to pass an argument for "Version" for both the "dotnet publish" and "electron-builder" commands #543 2021-03-04 14:45:52 +00:00
Brendan
55a3f10d37 Splash screen always renders on top 2021-02-18 13:32:45 -05:00
Brendan
7e494518f3 Fully ignore mouse events on splash screen (avoids drag + drop file into window) 2021-02-17 02:30:19 -05:00
Brendan
4596492cd9 Fix splash screen interaction causing crashes, fix splash screen content ghost drag, fix resizable splash screen. Resolves #539, #357
Using the browser-window-focus event would cause the splashScreen to be destroyed early (since regular mouse-focus events would cause the event to be fired).

Using the browser-window-created event produces the correct behavior.
2021-02-17 02:07:42 -05:00
Daniel Gidman
dd5bfd3961 Pass dotnet publsh /p: arguments to the publish command
use '/p:propertyName=value' or '/property:propertyName=value' to pass in dotnet build property overrides.

fixes #523
https://github.com/ElectronNET/Electron.NET/issues/523
2021-01-25 12:15:01 -06:00
dependabot[bot]
5d907864d8 Bump socket.io from 2.2.0 to 2.4.0 in /ElectronNET.Host
Bumps [socket.io](https://github.com/socketio/socket.io) from 2.2.0 to 2.4.0.
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/2.4.0/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/2.2.0...2.4.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-25 10:14:46 -06:00
Gregor Biswanger
30941df39c Update to .NET 5 infos 2021-01-22 00:16:04 +01:00
Gregor Biswanger
3588a8696d Update Changelog 2021-01-22 00:12:40 +01:00
Robert Muehsig
876bb98d92 11.5.1 2021-01-21 23:55:24 +01:00
Gregor Biswanger
427b57a002 Update Changelog 2021-01-21 22:06:08 +01:00
Gregor Biswanger
cc0b15c61e Merge pull request #528 from stackify/issue/527
Issue/527
2021-01-21 21:45:15 +01:00
Dan
8a0276daf9 Add ability to enable remote module in browser
The jump from Election 9x to 11x changed the default setting.  This exposes it so that user can re-enable it if needed.
2021-01-20 11:49:50 -06:00
Dan
e94196504e Support subscribing to unmapped events on App and Tray modules
`Electron.App.On("eventName", () => {});` or `Electron.App.On("eventName", obj => {});`

fix #527
2021-01-18 19:52:58 -06:00
Dan
6076c727d1 By blow fix of documentation
fix #500
2021-01-18 19:52:58 -06:00
Dan
300dc49dde Update the buildAll.sh so that you can run it successfully on a Mac 2021-01-18 19:52:58 -06:00
Dan
ce0f3fd61e Dock Menu support
fix #527
2021-01-18 19:52:58 -06:00
Dan
12f5eae65c Expose Electron members to the service provider
Used for class composition with IServiceProvider
2021-01-18 13:09:10 -06:00
Dan
3ef44cf878 Merge remote-tracking branch 'ElectronNET/master' 2021-01-18 10:30:57 -06:00
Gregor Biswanger
41fa8e9e74 Update WebApp to Electron 11.1.1 - Fix Chrome breaking changes with link ref=imports 2021-01-12 03:12:01 +01:00
Gregor Biswanger
49e21de465 Merge pull request #486 from stackify/bug/442
442: maintain references between socket.io connection events
2021-01-11 23:27:51 +01:00
Dan Gidman
d2f6308dd2 Merge remote-tracking branch 'upstream/master' into bug/442 2021-01-11 15:50:28 -06:00
Gregor Biswanger
f06b95803f Update to native Electron 11.1.1 - Fix breaking changes and refactoring. 2021-01-11 01:56:39 +01:00
Gregor Biswanger
b9feff3436 Merge pull request #522 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/ini-1.3.7
Bump ini from 1.3.5 to 1.3.7 in /ElectronNET.Host
2021-01-11 00:12:49 +01:00
Gregor Biswanger
335489d2d9 Merge pull request #509 from scottkuhl/issues/491-upgrade-to-net-5
Upgrade to .NET 5
2021-01-11 00:10:09 +01:00
Gregor Biswanger
6fe0c6f085 Merge pull request #506 from nathanwienand/add-publish-single-file
Added new build and start commandline options for single exe
2021-01-11 00:07:53 +01:00
Gregor Biswanger
f82d185865 Merge pull request #505 from aarong-av/aarong-av/donfigurable-default-port
Adding a configurable default electron port.
2021-01-11 00:05:14 +01:00
Gregor Biswanger
550e2c2625 Merge pull request #487 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/electron-9.3.1
Bump electron from 9.2.0 to 9.3.1 in /ElectronNET.Host
2021-01-11 00:03:05 +01:00
Gregor Biswanger
61f54ebd55 Merge pull request #480 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.WebApp/ElectronHostHook/bl-4.0.3
Bump bl from 4.0.2 to 4.0.3 in /ElectronNET.WebApp/ElectronHostHook
2021-01-10 23:56:54 +01:00
Gregor Biswanger
c8c818a77a Merge pull request #478 from dlitty/master
Added support for launching the application with a file on MacOS
2021-01-10 23:55:20 +01:00
Gregor Biswanger
fc590f55d8 Merge pull request #474 from freosc/PullRequest
Avoid Blocking Calls in App and AutoUpdater
2021-01-10 23:50:48 +01:00
dependabot[bot]
5fbe01df30 Bump ini from 1.3.5 to 1.3.7 in /ElectronNET.Host
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-11 17:11:37 +00:00
Scott Kuhl
dbf4d0f720 Upgraded NuGet packages to the latest versions:
- Microsoft.SourceLink.GitHub 1.0.0-beta2-19367-01 > 1.0.0
- System.Drawing.Common 4.7.0 > 5.0.0
- Microsoft.VisualStudio.Web.CodeGeneration.Design 3.0.0 > 5.0.0
2020-11-21 16:24:24 -06:00
Scott Kuhl
f996b3023e Updated TypeScript from 3.8 to 4.0. 2020-11-21 16:13:49 -06:00
Scott Kuhl
7f62e7299b Updated .NET Core 3.1 to .NET 5.0. 2020-11-21 16:13:06 -06:00
Aaron Gilliland
b803e42a73 Minor fix due to a copy paste issue. 2020-11-14 19:15:54 -06:00
Nathan Wienand
da1838db60 adding new build and start commandline options for single exe 2020-11-12 11:15:37 +00:00
Aaron Gilliland
8af1f50b88 Adding a configurable default electron port. Our environment does not allow for random port assignment. Port 8000 is not an option for our environment. 2020-11-11 07:48:42 -06:00
dependabot[bot]
c4f2188c62 Bump electron from 9.2.0 to 9.3.1 in /ElectronNET.Host
Bumps [electron](https://github.com/electron/electron) from 9.2.0 to 9.3.1.
- [Release notes](https://github.com/electron/electron/releases)
- [Changelog](https://github.com/electron/electron/blob/master/docs/breaking-changes.md)
- [Commits](https://github.com/electron/electron/compare/v9.2.0...v9.3.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-06 18:02:00 +00:00
Dan Gidman
e73655bd68 442: maintain references between socket.io connection events
https://github.com/ElectronNET/Electron.NET/issues/442

remove deletes of modules during disconnect
add delete of hostHook during disconnect
check if modules exist before importing them curring connect
move local caches of modules into global scope.
2020-10-06 11:29:53 -05:00
dependabot[bot]
758424d3ce Bump bl from 4.0.2 to 4.0.3 in /ElectronNET.WebApp/ElectronHostHook
Bumps [bl](https://github.com/rvagg/bl) from 4.0.2 to 4.0.3.
- [Release notes](https://github.com/rvagg/bl/releases)
- [Commits](https://github.com/rvagg/bl/compare/v4.0.2...v4.0.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-02 17:53:24 +00:00
Dan Litty
7518acb3c2 Added support for launching the application with a file on MacOS by listening for the open-file and open-url events from the operating system, and forwarding them to the Electron.NET app when listeners are added 2020-08-31 16:47:05 -04:00
Fre
5522addc0b PR 2020-08-21 12:35:31 +02:00
Fre
7f204c2a42 PR 2020-08-21 12:32:33 +02:00
Fre
de13f49bb6 PR 2020-08-21 12:27:31 +02:00
Fre
bca37228d9 del asynchelper 2020-08-21 12:22:28 +02:00
Fre
e17a36f7cb small changes 2020-08-21 12:13:38 +02:00
Fre
deccebb582 Merge branch 'master' into freosc
# Conflicts:
#	ElectronNET.Host/main.js
2020-08-21 11:13:06 +02:00
Fre
776ccc21e8 Merge remote-tracking branch 'upstream/master' 2020-08-21 10:36:24 +02:00
Fre
d0c92cac85 avoid memory leak when re-adding the eventlisteners 2020-08-21 10:32:02 +02:00
Gregor Biswanger
b525bf1a9a Update Changelog for 9.31.3 - Update to the native Electron 9.2.0 support 2020-08-14 13:25:27 +02:00
Gregor Biswanger
6337cac588 Merge pull request #468 from duncanawoods/fix_bad_fontsize_if_position_is_set
set default WebPreferences.DefaultFontSize
2020-08-14 12:55:17 +02:00
Gregor Biswanger
5d4509babe Merge pull request #467 from duncanawoods/fix_ERR_UNKNOWN_URL_SCHEME
fix ERR_UNKNOWN_URL_SCHEME by intercepting file:// protocol
2020-08-14 12:51:56 +02:00
Gregor Biswanger
3eef85cddf Merge pull request #465 from duncanawoods/buildsh_linux_errors
buildAll.sh linux errors
2020-08-14 12:48:40 +02:00
Gregor Biswanger
3f582d6c4e Merge pull request #457 from kojo12228/add-fsharp-support
Search for .csproj and .fsproj in init and add commands
2020-08-14 12:44:45 +02:00
Gregor Biswanger
18c5a65d6d Merge pull request #453 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.WebApp/ElectronHostHook/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19 in /ElectronNET.WebApp/ElectronHostHook
2020-08-14 12:42:02 +02:00
Gregor Biswanger
f8bbb138d8 Merge pull request #450 from ElectronNET/dependabot/npm_and_yarn/ElectronNET.Host/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19 in /ElectronNET.Host
2020-08-14 12:41:50 +02:00
Gregor Biswanger
7880d56e4c Merge pull request #445 from rbaker26/master
Update Documentation in the README.md
2020-08-14 12:41:06 +02:00
Gregor Biswanger
c16a888699 Merge pull request #463 from code-lever/master
Add target command line option found in 'build' to 'start' in CLI to …
2020-08-14 12:37:49 +02:00
Gregor Biswanger
814e046d5c Merge pull request #433 from BurtsevC/master
description added to package.json
2020-08-14 12:31:27 +02:00
duncan
d2457203bc Add build electron host to buildAll.sh 2020-08-14 10:19:11 +01:00
duncan
a70304948a set default WebPreferences.DefaultFontSize to fix tiny text when possition is set 2020-08-13 22:54:45 +01:00
duncan
a49b2ce278 fix ERR_UNKNOWN_URL_SCHEME by intercepting file:// protocol
fix whitespace

Revert "fix whitespace"

This reverts commit 608e364ebbabb19ffd6c3e3e0f357251c2e8e348.

fix whitespace
2020-08-13 20:46:10 +01:00
duncan
1577146187 buildall.sh disable win/osx builds on linux 2020-08-13 13:18:49 +01:00
duncan
d61f20dd67 buildall.sh restore original paths using pushd/pops 2020-08-13 13:15:47 +01:00
Gabe Cook
f7217b417f Add target command line option found in 'build' to 'start' in CLI to support custom targets in development. 2020-08-07 10:09:27 -05:00
Fre
e136ed4127 Merge branch 'master' of https://github.com/freosc/Electron.NET into freosc 2020-08-03 08:50:02 +02:00
Kojo Amoasi
7489543c75 search for .csproj and .fsproj in init and add 2020-07-22 13:42:00 +01:00
dependabot[bot]
cbf3032617 Bump lodash in /ElectronNET.WebApp/ElectronHostHook
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-20 23:26:19 +00:00
dependabot[bot]
68c54b9917 Bump lodash from 4.17.15 to 4.17.19 in /ElectronNET.Host
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-17 20:44:42 +00:00
Robert Muehsig
26d10fca38 9.31.2 2020-07-08 12:56:51 +02:00
Gregor Biswanger
bd15587079 Update to Electron 9.0.5 2020-07-08 12:56:50 +02:00
Gregor Biswanger
42613f5b56 Rollback to socket.io 2.2.0 2020-07-08 12:56:49 +02:00
Gregor Biswanger
62117df108 Update Changelog 2020-07-08 12:56:49 +02:00
Fre V
f68ea25cba Merge pull request #4 from ElectronNET/master
nieuwe versie
2020-07-08 11:25:37 +02:00
Fre
4e9de2abfa Aanpassingen autoupdate & async code 2020-07-08 11:16:00 +02:00
Bob Baker
a08d274dc1 Update README.md 2020-07-06 12:02:42 -07:00
Robert Muehsig
3dea16798b 9.31.2 2020-07-06 19:00:17 +02:00
Gregor Biswanger
bf8c7c8fa1 Update to Electron 9.0.5 2020-07-06 18:37:31 +02:00
Gregor Biswanger
06724f6eae Rollback to socket.io 2.2.0 2020-07-06 18:24:23 +02:00
Gregor Biswanger
83e579d44b Merge branch 'master' of https://github.com/ElectronNET/Electron.NET 2020-07-06 18:19:08 +02:00
Gregor Biswanger
ed67aa8072 Update Changelog 2020-07-06 18:19:02 +02:00
Fre V
f1ceaa208e Merge pull request #3 from ElectronNET/master
903
2020-07-06 15:59:12 +02:00
Gregor Biswanger
5e005499ef Merge pull request #435 from writzx/master
Enabled empty tray icon
2020-07-05 00:26:51 +02:00
Gregor Biswanger
975e4020dc Merge pull request #443 from rbaker26/master
Bug Fix, Fixed Publishing Issue ("Unknown argument: .")
2020-07-05 00:24:21 +02:00
Bob Baker
15ce35a7d9 removed extra . cause build failures 2020-07-03 23:19:19 -07:00
Writwick Das
de1637672a enabled empty tray icon
(fixes click event on macos)
2020-06-15 17:01:31 +02:00
BurtsevC
6b75f63135 description added to package.json 2020-06-13 15:53:52 +03:00
122 changed files with 10451 additions and 5449 deletions

3
.gitignore vendored
View File

@@ -260,3 +260,6 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Mac Only settings file
.DS_Store

32
.vscode/tasks.json vendored
View File

@@ -1,16 +1,18 @@
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}/ElectronNET.CLI/ElectronNET.CLI.csproj"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}
"version": "2.0.0",
"command": "dotnet",
"args": [],
"tasks": [
{
"label": "build",
"type": "shell",
"command": "dotnet",
"args": ["build", "${workspaceRoot}/ElectronNET.CLI/ElectronNET.CLI.csproj"],
"problemMatcher": "$msCompile",
"group": {
"_id": "build",
"isDefault": false
}
}
]
}

View File

@@ -1,7 +1,96 @@
# Not released
# 23.6.2
# Released
# 23.6.1
ElectronNET.CLI:
* New Feature: Upgrade to .NET 6 support
ElectronNET.API:
* New Feature: Native Electron 23.2.0 support, but not all new API features included (we search contributors)
* New Feature: Upgrade to .NET 6 support
* New Feature: Changed Web-Socket .NET Library to [SocketIOClient](https://github.com/doghappy/socket.io-client-csharp)
* Breaking Changes: We removed deprecated API events/methods from ElectronNET.API [(More Details)](https://www.electronjs.org/docs/latest/breaking-changes)
# 13.5.1
ElectronNET.CLI:
* New Feature: Using exit code instead of seek for the term 'error' (thanks [TSrgy](https://github.com/TSrgy)) [\#562](https://github.com/ElectronNET/Electron.NET/pull/562)
* Fixed bug: Allow for property overrides to be passed in (thanks [danatcofo](https://github.com/danatcofo)) [\#531](https://github.com/ElectronNET/Electron.NET/pull/531)
Use `/p:propertyName=value` or `/property:propertyName=value` to pass in property overrides. This is equivalent to the `-p:` option documented here: [https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish)
* Fixed bug: Add ability to pass an argument for "Version" for both the "dotnet publish" and "electron-builder" commands (thanks [tub5](https://github.com/tub5)) [\#546](https://github.com/ElectronNET/Electron.NET/pull/546)
* Fixed bug: Version flag not persisting with the referenced executable (thanks [tub5](https://github.com/tub5)) [\#585](https://github.com/ElectronNET/Electron.NET/pull/585)
* Fixed bug: Changes PublishSingleFile default to false for NET5 compatibility (thanks [cristiangiagante](https://github.com/cristiangiagante)) [\#570](https://github.com/ElectronNET/Electron.NET/pull/570)
ElectronNET.API:
* New Feature: Native Electron 13.1.5 support, but not all new features (we search contributors)
* Breaking API Changes (from native Electron 13.1.5):
- `Shell.MoveItemToTrashAsync` renamed with `Shell.TrashItemAsync`
- The deprecated extension APIs have been removed: `BrowserWindow.GetAllExtensionsAsync()`, `BrowserWindow.RemoveExtension()`, `BrowserWindow.AddExtensionAsync()`. Use the session APIs instead: `Session.GetAllExtensionsAsync()`, `Session.RemoveExtension()`, `Session.LoadExtensionAsync()`.
* New Feature: singleInstance handle command line arguments [\#520](https://github.com/ElectronNET/Electron.NET/issues/520)
* New Feature: Add WebContents [insertCSS](https://www.electronjs.org/docs/api/web-contents#contentsinsertcsscss-options) functionality (thanks [nfichter](https://github.com/nfichter)) [\#559](https://github.com/ElectronNET/Electron.NET/pull/559)
* New Feature: Allow IpcMain to send IPC messages to BrowserViews (thanks [nfichter](https://github.com/nfichter)) [\#560](https://github.com/ElectronNET/Electron.NET/pull/560)
* New Feature: Add support for proxies that require basic username/password authentication (thanks [nfichter](https://github.com/nfichter)) [\#561](https://github.com/ElectronNET/Electron.NET/pull/561)
* New Feature: Add PostData to LoadURLOptions to allow http-posts in LoadURL calls (thanks [Funkrusha](https://github.com/Funkrusha)) [\#547](https://github.com/ElectronNET/Electron.NET/pull/547)
* Fixed bug: Fix splash screen interaction causing crashes, ghost dragging, and resizable behavior #540 (thanks [MiniguyBrendan](https://github.com/MiniguyBrendan)) [\#540](https://github.com/ElectronNET/Electron.NET/pull/540)
* Fixed bug: Vibrancy serialization fix (thanks [tantumalice](https://github.com/tantumalice)) [\#573](https://github.com/ElectronNET/Electron.NET/pull/573)
# 11.5.1
ElectronNET.CLI:
* New Feature: Added new build and start commandline options for single exe (thanks [nathanwienand](https://github.com/nathanwienand)) [\#506](https://github.com/ElectronNET/Electron.NET/pull/506)
* New Feature: Set a description of the app in `electron.manifest.json` (thanks [BurtsevC](https://github.com/BurtsevC)) [\#433](https://github.com/ElectronNET/Electron.NET/pull/433)
* New Feature: Set a target for the start command (thanks [gabecook](https://github.com/gabecook)) [\#463](https://github.com/ElectronNET/Electron.NET/pull/463)
* New Feature: `electronize init` support for F# projects (thanks [kojo12228](https://github.com/kojo12228)) [\#457](https://github.com/ElectronNET/Electron.NET/pull/457)
* New Feature: Linux support for the buildAll.sh (thanks [duncanawoods](https://github.com/duncanawoods)) [\#465](https://github.com/ElectronNET/Electron.NET/pull/465)
* Fixed bug: ERR_UNKNOWN_URL_SCHEME by intercepting file:// protocol (thanks [duncanawoods](https://github.com/duncanawoods)) [\#467](https://github.com/ElectronNET/Electron.NET/pull/467)
ElectronNET.API:
* New Feature: Native Electron 11.1.1 support, but not all new features (we search contributors)
* Breaking API Changes (from native Electron 11.0): - Removed: BrowserView.{destroy, fromId, fromWebContents, getAllViews} and id property of BrowserView
* New Feature: Upgrade to .NET 5 (thanks [scottkuhl](https://github.com/scottkuhl)) [\#509](https://github.com/ElectronNET/Electron.NET/pull/509)
* New Feature: Extension Method for adding the Electron static class members to the standard MS DI Containers, this is a QOL issue only. `services.AddElectron()` (thanks [danatcofo](https://github.com/danatcofo )) [\#528](https://github.com/ElectronNET/Electron.NET/pull/528)
* New Feature: SetMenu completed for the Dock (MacOS) (thanks [danatcofo](https://github.com/danatcofo )) [\#528](https://github.com/ElectronNET/Electron.NET/pull/528)
Example for the Dock Menu
`Electron.Dock.SetMenu(new [] {
new MenuItem {
Label = "Dock Menu Item",
Click = () => {
// do something
}
},
});`
Example for consuming the activate event (MacOs only)
`Electron.App.On("activate", obj => {
var hasWindows = (bool)obj;
// do something
});`
* New Feature: On and Once implementations for the App and Tray to cover the plethora of events that are not mapped explicitly in those two modules. (thanks [danatcofo](https://github.com/danatcofo )) [\#528](https://github.com/ElectronNET/Electron.NET/pull/528)
* New Feature: Adding the `EnableRemoteModule` property to the WebPreferences object. As of Electron 10, this property defaulted to false and without it exposed you can't use the remote module within a window. (thanks [danatcofo](https://github.com/danatcofo )) [\#528](https://github.com/ElectronNET/Electron.NET/pull/528)
* New Feature: Adding a configurable default electron port. (thanks [aarong-av](https://github.com/aarong-av)) [\#505](https://github.com/ElectronNET/Electron.NET/pull/505)
* New Feature: Added support for launching the application with a file on MacOS (thanks [dlitty](https://github.com/dlitty)) [\#478](https://github.com/ElectronNET/Electron.NET/pull/478)
* Improved: Avoid Blocking Calls in App and AutoUpdater (thanks [freosc](https://github.com/freosc)) [\#474](https://github.com/ElectronNET/Electron.NET/pull/474)
* Fixed bug: Maintain references between socket.io connection events (thanks [danatcofo](https://github.com/danatcofo )) [\#468](https://github.com/ElectronNET/Electron.NET/pull/486)
* Fixed bug: Set default WebPreferences.DefaultFontSize (thanks [duncanawoods](https://github.com/duncanawoods)) [\#468](https://github.com/ElectronNET/Electron.NET/pull/468)
# 9.31.2
* Electron-Builder fixed for Windows builds.
# 9.31.1
ElectronNET.CLI:
@@ -25,6 +114,7 @@ ElectronNET.API:
* Notification-Api Enhancement: Added missing properties in Notifications (thanks [konstantingross](https://github.com/konstantingross)) [\#410](https://github.com/ElectronNET/Electron.NET/pull/410)
* BrowserWindows-Api Enhancement: Add missing API call for SetProgressBar options (thanks [konstantingross](https://github.com/konstantingross)) [\#416](https://github.com/ElectronNET/Electron.NET/pull/416)
* BrowserWindow Enhancement: Add BrowserWindow.GetNativeWindowHandle() (thanks [kdlslyv](https://github.com/kdlslyv)) [\#429](https://github.com/ElectronNET/Electron.NET/pull/429)
* HostHook-Api Enhancement: HostHook.CallAsync should use TaskCompletionSource.SetException instead of throwing exception (thanks [Fre V](https://github.com/freosc)) [\#430](https://github.com/ElectronNET/Electron.NET/pull/430)
* MacOS Enhancement: Application exit logic (thanks [dafergu2](https://github.com/dafergu2)) [\#405](https://github.com/ElectronNET/Electron.NET/pull/405)
* Fixed bug: ElectronNET.API.Entities.WebPreferences.ContextIsolation [DefaultValue(true)] [\#411](https://github.com/ElectronNET/Electron.NET/issues/411)

View File

@@ -7,6 +7,7 @@ using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using ElectronNET.API.Extensions;
using static System.Collections.Specialized.BitVector32;
namespace ElectronNET.API
{
@@ -398,6 +399,70 @@ namespace ElectronNET.API
}
private bool _isReady = false;
/// <summary>
/// Emitted when a MacOS user wants to open a file with the application. The open-file event is usually emitted
/// when the application is already open and the OS wants to reuse the application to open the file.
/// open-file is also emitted when a file is dropped onto the dock and the application is not yet running.
/// <para/>
/// On Windows, you have to parse the arguments using App.CommandLine to get the filepath.
/// </summary>
public event Action<string> OpenFile
{
add
{
if (_openFile == null)
{
BridgeConnector.Socket.On("app-open-file" + GetHashCode(), (file) =>
{
_openFile(file.ToString());
});
BridgeConnector.Socket.Emit("register-app-open-file-event", GetHashCode());
}
_openFile += value;
}
remove
{
_openFile -= value;
if (_openFile == null)
BridgeConnector.Socket.Off("app-open-file" + GetHashCode());
}
}
private event Action<string> _openFile;
/// <summary>
/// Emitted when a MacOS user wants to open a URL with the application. Your application's Info.plist file must
/// define the URL scheme within the CFBundleURLTypes key, and set NSPrincipalClass to AtomApplication.
/// </summary>
public event Action<string> OpenUrl
{
add
{
if (_openUrl == null)
{
BridgeConnector.Socket.On("app-open-url" + GetHashCode(), (url) =>
{
_openUrl(url.ToString());
});
BridgeConnector.Socket.Emit("register-app-open-url-event", GetHashCode());
}
_openUrl += value;
}
remove
{
_openUrl -= value;
if (_openUrl == null)
BridgeConnector.Socket.Off("app-open-url" + GetHashCode());
}
}
private event Action<string> _openUrl;
/// <summary>
/// A <see cref="string"/> property that indicates the current application's name, which is the name in the
/// application's package.json file.
@@ -407,6 +472,27 @@ namespace ElectronNET.API
/// which will be preferred over name by Electron.
/// </summary>
public string Name
{
[Obsolete("Use the asynchronous version NameAsync instead")]
get
{
return NameAsync.Result;
}
set
{
BridgeConnector.Socket.Emit("appSetName", value);
}
}
/// <summary>
/// A <see cref="string"/> 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 Task<string> NameAsync
{
get
{
@@ -423,14 +509,11 @@ namespace ElectronNET.API
BridgeConnector.Socket.Emit("appGetName");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("appSetName", value);
});
}
}
internal App()
{
CommandLine = new CommandLine();
@@ -1479,6 +1562,27 @@ namespace ElectronNET.API
/// is used.
/// </summary>
public string UserAgentFallback
{
[Obsolete("Use the asynchronous version UserAgentFallbackAsync instead")]
get
{
return UserAgentFallbackAsync.Result;
}
set
{
BridgeConnector.Socket.Emit("appSetUserAgentFallback", value);
}
}
/// <summary>
/// A <see cref="string"/> which is the user agent string Electron will use as a global fallback.
/// <para/>
/// This is the user agent that will be used when no user agent is set at the webContents or
/// session level. It is useful for ensuring that your entire app has the same user agent. Set to a
/// custom value as early as possible in your app's initialization to ensure that your overridden value
/// is used.
/// </summary>
public Task<string> UserAgentFallbackAsync
{
get
{
@@ -1495,11 +1599,7 @@ namespace ElectronNET.API
BridgeConnector.Socket.Emit("appGetUserAgentFallback");
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("appSetUserAgentFallback", value);
});
}
}
@@ -1509,5 +1609,35 @@ namespace ElectronNET.API
}
private bool _preventQuit = false;
private const string ModuleName = "app";
/// <summary>
/// Subscribe to an unmapped event on the <see cref="App"/> module.
/// </summary>
/// <param name="eventName">The event name</param>
/// <param name="action">The handler</param>
public void On(string eventName, Action action)
=> Events.Instance.On(ModuleName, eventName, action);
/// <summary>
/// Subscribe to an unmapped event on the <see cref="App"/> module.
/// </summary>
/// <param name="eventName">The event name</param>
/// <param name="action">The handler</param>
public async Task On(string eventName, Action<object> action)
=> await Events.Instance.On(ModuleName, eventName, action);
/// <summary>
/// Subscribe to an unmapped event on the <see cref="App"/> module once.
/// </summary>
/// <param name="eventName">The event name</param>
/// <param name="action">The handler</param>
public void Once(string eventName, Action action)
=> Events.Instance.Once(ModuleName, eventName, action);
/// <summary>
/// Subscribe to an unmapped event on the <see cref="App"/> module once.
/// </summary>
/// <param name="eventName">The event name</param>
/// <param name="action">The handler</param>
public async Task Once(string eventName, Action<object> action)
=> await Events.Instance.Once(ModuleName, eventName, action);
}
}

View File

@@ -1,6 +1,9 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace ElectronNET.API
@@ -182,11 +185,48 @@ namespace ElectronNET.API
}
}
/// <summary>
/// The current application version
/// </summary>
public Task<SemVer> CurrentVersionAsync
{
get
{
return Task.Run<SemVer>(() =>
{
var taskCompletionSource = new TaskCompletionSource<SemVer>();
BridgeConnector.Socket.On("autoUpdater-currentVersion-get-reply", (result) =>
{
BridgeConnector.Socket.Off("autoUpdater-currentVersion-get-reply");
SemVer version = ((JObject)result).ToObject<SemVer>();
taskCompletionSource.SetResult(version);
});
BridgeConnector.Socket.Emit("autoUpdater-currentVersion-get");
return taskCompletionSource.Task;
});
}
}
/// <summary>
/// Get the update channel. Not applicable for GitHub.
/// Doesnt return channel from the update configuration, only if was previously set.
/// </summary>
[Obsolete("Use the asynchronous version ChannelAsync instead")]
public string Channel
{
get
{
return ChannelAsync.Result;
}
}
/// <summary>
/// Get the update channel. Not applicable for GitHub.
/// Doesnt return channel from the update configuration, only if was previously set.
/// </summary>
public Task<string> ChannelAsync
{
get
{
@@ -199,11 +239,45 @@ namespace ElectronNET.API
BridgeConnector.Socket.Off("autoUpdater-channel-get-reply");
taskCompletionSource.SetResult(result.ToString());
});
BridgeConnector.Socket.Emit("autoUpdater-channel-get");
return taskCompletionSource.Task;
}).Result;
});
}
}
/// <summary>
/// The request headers.
/// </summary>
public Task<Dictionary<string, string>> RequestHeadersAsync
{
get
{
return Task.Run(() =>
{
var taskCompletionSource = new TaskCompletionSource<Dictionary<string, string>>();
BridgeConnector.Socket.On("autoUpdater-requestHeaders-get-reply", (headers) =>
{
BridgeConnector.Socket.Off("autoUpdater-requestHeaders-get-reply");
Dictionary<string, string> result = ((JObject)headers).ToObject<Dictionary<string, string>>();
taskCompletionSource.SetResult(result);
});
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-get");
return taskCompletionSource.Task;
});
}
}
/// <summary>
/// The request headers.
/// </summary>
public Dictionary<string, string> RequestHeaders
{
set
{
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", JObject.FromObject(value, _jsonSerializer));
}
}
@@ -416,9 +490,26 @@ namespace ElectronNET.API
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesComplete" + guid, (updateCheckResult) =>
{
try
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
}
catch (Exception ex)
{
taskCompletionSource.SetException(ex);
}
});
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesError" + guid, (error) =>
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
string message = "An error occurred in CheckForUpdatesAsync";
if (error != null && !string.IsNullOrEmpty(error.ToString()))
message = JsonConvert.SerializeObject(error);
taskCompletionSource.SetException(new Exception(message));
});
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdates", guid);
@@ -438,9 +529,29 @@ namespace ElectronNET.API
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid, (updateCheckResult) =>
{
try
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
if (updateCheckResult == null)
taskCompletionSource.SetResult(null);
else
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
}
catch (Exception ex)
{
taskCompletionSource.SetException(ex);
}
});
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyError" + guid, (error) =>
{
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
string message = "An error occurred in autoUpdaterCheckForUpdatesAndNotify";
if (error != null)
message = JsonConvert.SerializeObject(error);
taskCompletionSource.SetException(new Exception(message));
});
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdatesAndNotify", guid);
@@ -501,5 +612,10 @@ namespace ElectronNET.API
return taskCompletionSource.Task;
}
private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
}
}

View File

@@ -1,38 +1,27 @@
using Quobject.SocketIoClientDotNet.Client;
using System;
namespace ElectronNET.API
namespace ElectronNET.API
{
internal static class BridgeConnector
{
private static Socket _socket;
private static object _syncRoot = new object();
private static SocketIoFacade _socket;
private static readonly object SyncRoot = new();
public static Socket Socket
public static SocketIoFacade Socket
{
get
{
if(_socket == null && HybridSupport.IsElectronActive)
if (_socket == null)
{
lock (_syncRoot)
lock (SyncRoot)
{
if (_socket == null && HybridSupport.IsElectronActive)
if (_socket == null)
{
_socket = IO.Socket("http://localhost:" + BridgeSettings.SocketPort);
_socket.On(Socket.EVENT_CONNECT, () =>
{
Console.WriteLine("BridgeConnector connected!");
});
}
}
}
else if(_socket == null && !HybridSupport.IsElectronActive)
{
lock (_syncRoot)
{
if (_socket == null && !HybridSupport.IsElectronActive)
{
_socket = IO.Socket(new Uri("http://localhost"), new IO.Options { AutoConnect = false });
string socketUrl = HybridSupport.IsElectronActive
? $"http://localhost:{BridgeSettings.SocketPort}"
: "http://localhost";
_socket = new SocketIoFacade(socketUrl);
_socket.Connect();
}
}
}
@@ -41,4 +30,4 @@ namespace ElectronNET.API
}
}
}
}
}

View File

@@ -2,9 +2,6 @@
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
@@ -29,30 +26,6 @@ namespace ElectronNET.API
/// </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.
///
@@ -83,8 +56,6 @@ namespace ElectronNET.API
}
}
internal Action<BrowserView> Destroyed;
/// <summary>
/// BrowserView
/// </summary>
@@ -97,18 +68,6 @@ namespace ElectronNET.API
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>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ElectronNET.API.Converter;
/// <summary>
///
/// </summary>
public class ModifierTypeListConverter : JsonConverter<List<ModifierType>>
{
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="objectType"></param>
/// <param name="existingValue"></param>
/// <param name="hasExistingValue"></param>
/// <param name="serializer"></param>
/// <returns></returns>
public override List<ModifierType> ReadJson(JsonReader reader, Type objectType, List<ModifierType> existingValue, bool hasExistingValue, JsonSerializer serializer)
{
var token = JToken.Load(reader);
if (token.Type == JTokenType.Null)
{
return null;
}
return token.ToObject<List<string>>().Select(m => (ModifierType)Enum.Parse(typeof(ModifierType), m)).ToList();
}
/// <summary>
///
/// </summary>
/// <param name="writer"></param>
/// <param name="value"></param>
/// <param name="serializer"></param>
public override void WriteJson(JsonWriter writer, List<ModifierType> value, JsonSerializer serializer)
{
writer.WriteStartArray();
foreach (var modifier in value)
{
writer.WriteValue(modifier.ToString());
}
writer.WriteEndArray();
}
}

View File

@@ -5,7 +5,6 @@ using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Web;
namespace ElectronNET.API
{

View File

@@ -1,8 +1,11 @@
using System.Threading;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
using ElectronNET.API.Extensions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
namespace ElectronNET.API
{
@@ -162,12 +165,29 @@ namespace ElectronNET.API
}
/// <summary>
/// TODO: Menu (macOS) still to be implemented
/// Gets the dock menu items.
/// </summary>
/// <value>
/// The menu items.
/// </value>
public IReadOnlyCollection<MenuItem> MenuItems { get { return _items.AsReadOnly(); } }
private List<MenuItem> _items = new List<MenuItem>();
/// <summary>
/// Sets the application's dock menu.
/// </summary>
public void SetMenu()
public void SetMenu(MenuItem[] menuItems)
{
BridgeConnector.Socket.Emit("dock-setMenu");
menuItems.AddMenuItemsId();
BridgeConnector.Socket.Emit("dock-setMenu", JArray.FromObject(menuItems, _jsonSerializer));
_items.AddRange(menuItems);
BridgeConnector.Socket.Off("dockMenuItemClicked");
BridgeConnector.Socket.On("dockMenuItemClicked", (id) => {
MenuItem menuItem = _items.GetMenuItem(id.ToString());
menuItem?.Click();
});
}
/// <summary>
@@ -202,5 +222,11 @@ namespace ElectronNET.API
{
BridgeConnector.Socket.Emit("dock-setIcon", image);
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
}
}

View File

@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>..\artifacts</PackageOutputPath>
<PackageId>ElectronNET.API</PackageId>
<Authors>Gregor Biswanger, Robert Muehsig</Authors>
<Authors>Gregor Biswanger, Florian Rappl</Authors>
<Company />
<Product>Electron.NET</Product>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
@@ -21,11 +20,9 @@ This package contains the API to access the "native" electron API.</Description>
<Version>99.0.0.0</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Include="PackageIcon.png" Pack="true" PackagePath="\" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
<Exec Command="$(ProjectDir)devCleanup.cmd" IgnoreExitCode="true" />
</Target>
@@ -33,15 +30,19 @@ This package contains the API to access the "native" electron API.</Description>
<Exec Command="$(ProjectDir)devCleanup.sh" IgnoreExitCode="true" />
</Target>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="SocketIoClientDotNet" Version="1.0.5" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SocketIOClient" Version="3.0.8" />
<PackageReference Include="SocketIOClient.Newtonsoft.Json" Version="3.0.7" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.410601">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
</Project>

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class Blob : IPostData
{
/// <summary>
/// The object represents a Blob
/// </summary>
public string Type { get; } = "blob";
/// <summary>
/// The UUID of the Blob being uploaded
/// </summary>
public string BlobUUID { get; set; }
}
}

View File

@@ -9,5 +9,17 @@
/// See BrowserWindow.
/// </summary>
public WebPreferences WebPreferences { get; set; }
/// <summary>
/// A proxy to set on creation in the format host:port.
/// The proxy can be alternatively set using the BrowserView.WebContents.SetProxyAsync function.
/// </summary>
public string Proxy { get; set; }
/// <summary>
/// The credentials of the Proxy in the format username:password.
/// These will only be used if the Proxy field is also set.
/// </summary>
public string ProxyCredentials { get; set; }
}
}

View File

@@ -258,5 +258,17 @@ namespace ElectronNET.API.Entities
/// Settings of web page's features.
/// </summary>
public WebPreferences WebPreferences { get; set; }
/// <summary>
/// A proxy to set on creation in the format host:port.
/// The proxy can be alternatively set using the BrowserWindow.WebContents.SetProxyAsync function.
/// </summary>
public string Proxy { get; set; }
/// <summary>
/// The credentials of the Proxy in the format username:password.
/// These will only be used if the Proxy field is also set.
/// </summary>
public string ProxyCredentials { get; set; }
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronNET.API.Entities
{
/// <summary>
/// Docs: https://electronjs.org/docs/api/structures/extension
/// </summary>
public class Extension
{
/// <summary>
///
/// </summary>
public string Id { get; set; }
/// <summary>
/// Copy of the extension's manifest data.
/// </summary>
public dynamic Manifest { get; set; }
/// <summary>
///
/// </summary>
public string Name { get; set; }
/// <summary>
/// The extension's file path.
/// </summary>
public string Path { get; set; }
/// <summary>
/// The extension's `chrome-extension://` URL.
/// </summary>
public string Url { get; set; }
/// <summary>
///
/// </summary>
public string Version { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
namespace ElectronNET.API.Entities
{
/// <summary>
/// Interface to use Electrons PostData Object
/// </summary>
public interface IPostData
{
/// <summary>
/// One of the following:
/// rawData - <see cref="UploadRawData"/> The data is available as a Buffer, in the rawData field.
/// file - <see cref="UploadFile"/> The object represents a file. The filePath, offset, length and modificationTime fields will be used to describe the file.
/// blob - <see cref="Blob"/> The object represents a Blob. The blobUUID field will be used to describe the Blob.
/// </summary>
public string Type { get; }
}
}

View File

@@ -0,0 +1,81 @@
using Newtonsoft.Json.Converters;
using System.Collections.Generic;
using ElectronNET.API.Converter;
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class InputEvent
{
/// <summary>
/// Equivalent to KeyboardEvent.key.
/// </summary>
public string Key { get; set; } = "";
/// <summary>
/// Equivalent to KeyboardEvent.code.
/// </summary>
public string Code { get; set; } = "";
/// <summary>
/// Equivalent to KeyboardEvent.repeat.
/// </summary>
public bool IsAutoRepeat { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.isComposing.
/// </summary>
public bool IsComposing { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.shiftKey.
/// </summary>
public bool Shift { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.controlKey.
/// </summary>
public bool Control { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.altKey.
/// </summary>
public bool Alt { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.metaKey.
/// </summary>
public bool Meta { get; set; } = false;
/// <summary>
/// Equivalent to KeyboardEvent.location.
/// </summary>
public int Location { get; set; } = 0;
/// <summary>
/// An array of modifiers of the event, can be `shift`, `control`, `ctrl`, `alt`,
/// `meta`, `command`, `cmd`, `isKeypad`, `isAutoRepeat`, `leftButtonDown`,
/// `middleButtonDown`, `rightButtonDown`, `capsLock`, `numLock`, `left`, `right`
/// </summary>
[JsonConverter(typeof(ModifierTypeListConverter))]
public List<ModifierType> Modifiers { get; set; }
/// <summary>
/// Can be `undefined`, `mouseDown`, `mouseUp`, `mouseMove`, `mouseEnter`,
/// `mouseLeave`, `contextMenu`, `mouseWheel`, `rawKeyDown`, `keyDown`, `keyUp`,
/// `gestureScrollBegin`, `gestureScrollEnd`, `gestureScrollUpdate`,
/// `gestureFlingStart`, `gestureFlingCancel`, `gesturePinchBegin`,
/// `gesturePinchEnd`, `gesturePinchUpdate`, `gestureTapDown`, `gestureShowPress`,
/// `gestureTap`, `gestureTapCancel`, `gestureShortPress`, `gestureLongPress`,
/// `gestureLongTap`, `gestureTwoFingerTap`, `gestureTapUnconfirmed`,
/// `gestureDoubleTap`, `touchStart`, `touchMove`, `touchEnd`, `touchCancel`,
/// `touchScrollStarted`, `pointerDown`, `pointerUp`, `pointerMove`,
/// `pointerRawUpdate`, `pointerCancel` or `pointerCausedUaAction`.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public InputEventType Type { get; set; }
}
}

View File

@@ -0,0 +1,201 @@
namespace ElectronNET.API.Entities;
/// <summary>
///
/// </summary>
public enum InputEventType
{
/// <summary>
///
/// </summary>
undefined,
/// <summary>
///
/// </summary>
mouseDown,
/// <summary>
///
/// </summary>
mouseUp,
/// <summary>
///
/// </summary>
mouseMove,
/// <summary>
///
/// </summary>
mouseEnter,
/// <summary>
///
/// </summary>
mouseLeave,
/// <summary>
///
/// </summary>
contextMenu,
/// <summary>
///
/// </summary>
mouseWheel,
/// <summary>
///
/// </summary>
rawKeyDown,
/// <summary>
///
/// </summary>
keyDown,
/// <summary>
///
/// </summary>
keyUp,
/// <summary>
///
/// </summary>
gestureScrollBegin,
/// <summary>
///
/// </summary>
gestureScrollEnd,
/// <summary>
///
/// </summary>
gestureScrollUpdate,
/// <summary>
///
/// </summary>
gestureFlingStart,
/// <summary>
///
/// </summary>
gestureFlingCancel,
/// <summary>
///
/// </summary>
gesturePinchBegin,
/// <summary>
///
/// </summary>
gesturePinchEnd,
/// <summary>
///
/// </summary>
gesturePinchUpdate,
/// <summary>
///
/// </summary>
gestureTapDown,
/// <summary>
///
/// </summary>
gestureShowPress,
/// <summary>
///
/// </summary>
gestureTap,
/// <summary>
///
/// </summary>
gestureTapCancel,
/// <summary>
///
/// </summary>
gestureShortPress,
/// <summary>
///
/// </summary>
gestureLongPress,
/// <summary>
///
/// </summary>
gestureLongTap,
/// <summary>
///
/// </summary>
gestureTwoFingerTap,
/// <summary>
///
/// </summary>
gestureTapUnconfirmed,
/// <summary>
///
/// </summary>
gestureDoubleTap,
/// <summary>
///
/// </summary>
touchStart,
/// <summary>
///
/// </summary>
touchMove,
/// <summary>
///
/// </summary>
touchEnd,
/// <summary>
///
/// </summary>
touchCancel,
/// <summary>
///
/// </summary>
touchScrollStarted,
/// <summary>
///
/// </summary>
pointerDown,
/// <summary>
///
/// </summary>
pointerUp,
/// <summary>
///
/// </summary>
pointerMove,
/// <summary>
///
/// </summary>
pointerRawUpdate,
/// <summary>
///
/// </summary>
pointerCancel,
/// <summary>
///
/// </summary>
pointerCausedUaAction
}

View File

@@ -26,5 +26,11 @@
/// Extra headers for the request.
/// </summary>
public string ExtraHeaders { get; set; }
/// <summary>
/// PostData Object for the request.
/// Can be <see cref="UploadRawData"/>, <see cref="UploadFile"/> or <see cref="Blob"/>
/// </summary>
public IPostData[] PostData { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
namespace ElectronNET.API.Entities;
/// <summary>
///
/// </summary>
public class Margins
{
/// <summary>
/// Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen,
/// you will also need to specify `top`, `bottom`, `left`, and `right`.
/// </summary>
public string MarginType { get; set; }
/// <summary>
/// The top margin of the printed web page, in pixels.
/// </summary>
public int Top { get; set; }
/// <summary>
/// The bottom margin of the printed web page, in pixels.
/// </summary>
public int Bottom { get; set; }
/// <summary>
/// The left margin of the printed web page, in pixels.
/// </summary>
public int Left { get; set; }
/// <summary>
/// The right margin of the printed web page, in pixels.
/// </summary>
public int Right { get; set; }
}

View File

@@ -0,0 +1,87 @@
namespace ElectronNET.API.Entities;
/// <summary>
/// Specifies the possible modifier keys for a keyboard input.
/// </summary>
public enum ModifierType
{
/// <summary>
/// The Shift key.
/// </summary>
shift,
/// <summary>
/// The Control key.
/// </summary>
control,
/// <summary>
/// The Control key (alias for control).
/// </summary>
ctrl,
/// <summary>
/// The Alt key.
/// </summary>
alt,
/// <summary>
/// The Meta key.
/// </summary>
meta,
/// <summary>
/// The Command key.
/// </summary>
command,
/// <summary>
/// The Command key (alias for command).
/// </summary>
cmd,
/// <summary>
/// Indicates whether the keypad modifier key is pressed.
/// </summary>
isKeypad,
/// <summary>
/// Indicates whether the key is an auto-repeated key.
/// </summary>
isAutoRepeat,
/// <summary>
/// Indicates whether the left mouse button is pressed.
/// </summary>
leftButtonDown,
/// <summary>
/// Indicates whether the middle mouse button is pressed.
/// </summary>
middleButtonDown,
/// <summary>
/// Indicates whether the right mouse button is pressed.
/// </summary>
rightButtonDown,
/// <summary>
/// The Caps Lock key.
/// </summary>
capsLock,
/// <summary>
/// The Num Lock key.
/// </summary>
numlock,
/// <summary>
/// The Left key.
/// </summary>
left,
/// <summary>
/// The Right key.
/// </summary>
right
}

View File

@@ -1,35 +1,63 @@
namespace ElectronNET.API.Entities
namespace ElectronNET.API.Entities;
/// <summary>
///
/// </summary>
public class PrintToPDFOptions
{
/// <summary>
///
/// Paper orientation. `true` for landscape, `false` for portrait. Defaults to false.
/// </summary>
public class PrintToPDFOptions
{
/// <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; }
public bool Landscape { get; set; } = false;
/// <summary>
/// Specify page size of the generated PDF. Can be A3, A4, A5, Legal, Letter,
/// Tabloid or an Object containing height and width in microns.
/// </summary>
public string PageSize { get; set; }
/// <summary>
/// Whether to display header and footer. Defaults to false.
/// </summary>
public bool DisplayHeaderFooter { get; set; } = false;
/// <summary>
/// Whether to print CSS backgrounds.
/// </summary>
public bool PrintBackground { get; set; }
/// <summary>
/// Whether to print background graphics. Defaults to false.
/// </summary>
public bool PrintBackground { get; set; } = false;
/// <summary>
/// Whether to print selection only.
/// </summary>
public bool PrintSelectionOnly { get; set; }
/// <summary>
/// Scale of the webpage rendering. Defaults to 1.
/// </summary>
public double Scale { get; set; } = 1;
/// <summary>
/// true for landscape, false for portrait.
/// </summary>
public bool Landscape { get; set; }
}
/// <summary>
/// Specify page size of the generated PDF. Can be `A0`, `A1`, `A2`, `A3`, `A4`,
/// `A5`, `A6`, `Legal`, `Letter`, `Tabloid`, `Ledger`, or an Object containing
/// `height` and `width` in inches. Defaults to `Letter`.
/// </summary>
public string PageSize { get; set; } = "Letter";
/// <summary>
/// Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string,
/// which means print all pages.
/// </summary>
public string PageRanges { get; set; } = "";
/// <summary>
/// HTML template for the print header. Should be valid HTML markup with following
/// classes used to inject printing values into them: `date` (formatted print date),
/// `title` (document title), `url` (document location), `pageNumber` (current page
/// number) and `totalPages` (total pages in the document). For example, `<span class="title"></span>`
/// would generate span containing the title.
/// </summary>
public string HeaderTemplate { get; set; }
/// <summary>
/// HTML template for the print footer. Should use the same format as the
/// `headerTemplate`.
/// </summary>
public string FooterTemplate { get; set; }
/// <summary>
/// Whether or not to prefer page size as defined by css. Defaults to false, in
/// which case the content will be scaled to fit the paper size.
/// </summary>
public bool PreferCSSPageSize { get; set; } = false;
public Margins Margins { get; set; }
}

View File

@@ -1,31 +0,0 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class RemoveClientCertificate
{
/// <summary>
/// Origin of the server whose associated client certificate must be removed from
/// the cache.
/// </summary>
public string Origin { get; set; }
/// <summary>
/// clientCertificate.
/// </summary>
public string Type { get; set; }
/// <summary>
///
/// </summary>
/// <param name="origin">Origin of the server whose associated client certificate
/// must be removed from the cache.</param>
/// <param name="type">clientCertificate.</param>
public RemoveClientCertificate(string origin, string type)
{
Origin = origin;
Type = type;
}
}
}

View File

@@ -0,0 +1,59 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class SemVer
{
/// <summary>
///
/// </summary>
public string Raw { get; set; }
/// <summary>
///
/// </summary>
public bool Loose { get; set; }
/// <summary>
///
/// </summary>
public SemVerOptions Options { get; set; }
/// <summary>
///
/// </summary>
public int Major { get; set; }
/// <summary>
///
/// </summary>
public int Minor { get; set; }
/// <summary>
///
/// </summary>
public int Patch { get; set; }
/// <summary>
///
/// </summary>
public string Version { get; set; }
/// <summary>
///
/// </summary>
public string[] Build { get; set; }
/// <summary>
///
/// </summary>
public string[] Prerelease { get; set; }
}
/// <summary>
///
/// </summary>
public class SemVerOptions {
/// <summary>
///
/// </summary>
public bool? Loose { get; set; }
/// <summary>
///
/// </summary>
public bool? IncludePrerelease { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class UploadFile : IPostData
{
/// <summary>
/// The object represents a file.
/// </summary>
public string Type { get; } = "file";
/// <summary>
/// The path of the file being uploaded.
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// The offset from the beginning of the file being uploaded, in bytes. Defaults to 0.
/// </summary>
public long Offset { get; set; } = 0;
/// <summary>
/// The length of the file being uploaded, <see cref="Offset"/>. Defaults to 0.
/// If set to -1, the whole file will be uploaded.
/// </summary>
public long Length { get; set; } = 0;
/// <summary>
/// The modification time of the file represented by a double, which is the number of seconds since the UNIX Epoch (Jan 1, 1970)
/// </summary>
public double ModificationTime { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
public class UploadRawData : IPostData
{
/// <summary>
/// The data is available as a Buffer, in the rawData field.
/// </summary>
public string Type { get; } = "rawData";
/// <summary>
/// The raw bytes of the post data in a Buffer.
/// </summary>
public byte[] Bytes { get; set; }
}
}

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using System.Runtime.Serialization;
namespace ElectronNET.API.Entities
{
@@ -10,7 +10,7 @@ namespace ElectronNET.API.Entities
/// <summary>
/// The appearance based
/// </summary>
[JsonProperty("appearance-based")]
[EnumMember(Value = "appearance-based")]
appearanceBased,
/// <summary>
@@ -51,13 +51,13 @@ namespace ElectronNET.API.Entities
/// <summary>
/// The medium light
/// </summary>
[JsonProperty("medium-light")]
[EnumMember(Value = "medium-light")]
mediumLight,
/// <summary>
/// The ultra dark
/// </summary>
[JsonProperty("ultra-dark")]
[EnumMember(Value = "ultra-dark")]
ultraDark
}
}

View File

@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
@@ -142,7 +142,7 @@ namespace ElectronNET.API.Entities
/// <summary>
/// Defaults to 16.
/// </summary>
public int DefaultFontSize { get; set; }
public int DefaultFontSize { get; set; } = 16;
/// <summary>
/// Defaults to 13.
@@ -186,7 +186,7 @@ namespace ElectronNET.API.Entities
/// currently experimental and may change or be removed in future Electron releases.
/// </summary>
[DefaultValue(false)]
public bool ContextIsolation { get; set; }
public bool ContextIsolation { get; set; } = false;
/// <summary>
/// Whether to use native window.open(). Defaults to false. This option is currently experimental.
@@ -206,5 +206,11 @@ namespace ElectronNET.API.Entities
/// </value>
[DefaultValue(false)]
public bool WebviewTag { get; set; } = false;
/// <summary>
/// Whether to enable the remote module. Defaults to false.
/// </summary>
[DefaultValue(false)]
public bool EnableRemoteModule { get; set; } = false;
}
}

88
ElectronNET.API/Events.cs Normal file
View File

@@ -0,0 +1,88 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
namespace ElectronNET.API
{
/// <summary>
/// Generic Event Consumers for Electron Modules
/// </summary>
internal class Events
{
private static Events _events;
private static readonly object SyncRoot = new();
private readonly TextInfo _textInfo = new CultureInfo("en-US", false).TextInfo;
private Events()
{}
public static Events Instance
{
get
{
if (_events == null)
{
lock (SyncRoot)
{
if (_events == null)
{
_events = new Events();
}
}
}
return _events;
}
}
/// <summary>
/// Subscribe to an unmapped electron event.
/// </summary>
/// <param name="moduleName">The name of the module, e.g. app, dock, etc...</param>
/// <param name="eventName">The name of the event</param>
/// <param name="action">The event handler</param>
public void On(string moduleName, string eventName, Action action)
=> On(moduleName, eventName, action);
/// <summary>
/// Subscribe to an unmapped electron event.
/// </summary>
/// <param name="moduleName">The name of the module, e.g. app, dock, etc...</param>
/// <param name="eventName">The name of the event</param>
/// <param name="action">The event handler</param>
public async Task On<T>(string moduleName, string eventName, Action<T> action)
{
var listener = $"{moduleName}{_textInfo.ToTitleCase(eventName)}Completed";
var subscriber = $"register-{moduleName}-on-event";
BridgeConnector.Socket.On(listener, action);
await BridgeConnector.Socket.Emit(subscriber, eventName, listener);
}
/// <summary>
/// Subscribe to an unmapped electron event.
/// </summary>
/// <param name="moduleName">The name of the module, e.g. app, dock, etc...</param>
/// <param name="eventName">The name of the event</param>
/// <param name="fn">The event handler</param>
public void Once(string moduleName, string eventName, Action action)
=> Once(moduleName, eventName, action);
/// <summary>
/// Subscribe to an unmapped electron event.
/// </summary>
/// <param name="moduleName">The name of the module, e.g. app, dock, etc...</param>
/// <param name="eventName">The name of the event</param>
/// <param name="action">The event handler</param>
public async Task Once<T>(string moduleName, string eventName, Action<T> action)
{
var listener = $"{moduleName}{_textInfo.ToTitleCase(eventName)}Completed";
var subscriber = $"register-{moduleName}-once-event";
BridgeConnector.Socket.Once(listener, action);
await BridgeConnector.Socket.Emit(subscriber, eventName, listener);
}
}
}

View File

@@ -0,0 +1,3 @@
// Global using directives
global using System.Web;

View File

@@ -5,6 +5,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ElectronNET.API
{
@@ -43,9 +44,9 @@ namespace ElectronNET.API
/// </summary>
/// <param name="channel">Channelname.</param>
/// <param name="listener">Callback Method.</param>
public void On(string channel, Action<object> listener)
public async Task On(string channel, Action<object> listener)
{
BridgeConnector.Socket.Emit("registerIpcMainChannel", channel);
await BridgeConnector.Socket.Emit("registerIpcMainChannel", channel);
BridgeConnector.Socket.Off(channel);
BridgeConnector.Socket.On(channel, (args) =>
{
@@ -179,6 +180,45 @@ namespace ElectronNET.API
}
}
/// <summary>
/// Send a message to the BrowserView renderer process asynchronously via channel, you can also send
/// arbitrary arguments. Arguments will be serialized in JSON internally and hence
/// no functions or prototype chain will be included. The renderer process handles it by
/// listening for channel with ipcRenderer module.
/// </summary>
/// <param name="browserView">BrowserView with channel.</param>
/// <param name="channel">Channelname.</param>
/// <param name="data">Arguments data.</param>
public void Send(BrowserView browserView, string channel, params object[] data)
{
List<JObject> jobjects = new List<JObject>();
List<JArray> jarrays = new List<JArray>();
List<object> objects = new List<object>();
foreach (var parameterObject in data)
{
if(parameterObject.GetType().IsArray || parameterObject.GetType().IsGenericType && parameterObject is IEnumerable)
{
jarrays.Add(JArray.FromObject(parameterObject, _jsonSerializer));
} else if(parameterObject.GetType().IsClass && !parameterObject.GetType().IsPrimitive && !(parameterObject is string))
{
jobjects.Add(JObject.FromObject(parameterObject, _jsonSerializer));
} else if(parameterObject.GetType().IsPrimitive || (parameterObject is string))
{
objects.Add(parameterObject);
}
}
if(jobjects.Count > 0 || jarrays.Count > 0)
{
BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, jarrays.ToArray(), jobjects.ToArray(), objects.ToArray());
}
else
{
BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, data);
}
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),

View File

@@ -0,0 +1,33 @@
using Microsoft.Extensions.DependencyInjection;
namespace ElectronNET.API
{
/// <summary>
///
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// Adds the <see cref="Electron"/> Members to the Service Collection
/// </summary>
public static IServiceCollection AddElectron(this IServiceCollection services)
=> services
// adding in this manner to ensure late binding.
.AddSingleton(provider => IpcMain.Instance)
.AddSingleton(provider => App.Instance)
.AddSingleton(provider => AutoUpdater.Instance)
.AddSingleton(provider => WindowManager.Instance)
.AddSingleton(provider => Menu.Instance)
.AddSingleton(provider => Dialog.Instance)
.AddSingleton(provider => Notification.Instance)
.AddSingleton(provider => Tray.Instance)
.AddSingleton(provider => GlobalShortcut.Instance)
.AddSingleton(provider => Shell.Instance)
.AddSingleton(provider => Screen.Instance)
.AddSingleton(provider => Clipboard.Instance)
.AddSingleton(provider => HostHook.Instance)
.AddSingleton(provider => PowerMonitor.Instance)
.AddSingleton(provider => NativeTheme.Instance)
.AddSingleton(provider => Dock.Instance);
}
}

View File

@@ -64,8 +64,7 @@ namespace ElectronNET.API
/// <summary>
/// Clears the sessions HTTP authentication cache.
/// </summary>
/// <param name="options"></param>
public Task ClearAuthCacheAsync(RemoveClientCertificate options)
public Task ClearAuthCacheAsync()
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
@@ -76,7 +75,7 @@ namespace ElectronNET.API
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, JObject.FromObject(options, _jsonSerializer), guid);
BridgeConnector.Socket.Emit("webContents-session-clearAuthCache", Id, guid);
return taskCompletionSource.Task;
}
@@ -376,6 +375,81 @@ namespace ElectronNET.API
BridgeConnector.Socket.Emit("webContents-session-setUserAgent", Id, userAgent, acceptLanguages);
}
/// <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 Task<ChromeExtensionInfo[]> GetAllExtensionsAsync()
{
var taskCompletionSource = new TaskCompletionSource<ChromeExtensionInfo[]>();
BridgeConnector.Socket.On("webContents-session-getAllExtensions-completed", (extensionslist) =>
{
BridgeConnector.Socket.Off("webContents-session-getAllExtensions-completed");
var chromeExtensionInfos = ((JArray)extensionslist).ToObject<ChromeExtensionInfo[]>();
taskCompletionSource.SetResult(chromeExtensionInfos);
});
BridgeConnector.Socket.Emit("webContents-session-getAllExtensions", Id);
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 void RemoveExtension(string name)
{
BridgeConnector.Socket.Emit("webContents-session-removeExtension", Id, name);
}
/// <summary>
/// resolves when the extension is loaded.
///
/// This method will raise an exception if the extension could not be loaded.If
/// there are warnings when installing the extension (e.g. if the extension requests
/// an API that Electron does not support) then they will be logged to the console.
///
/// Note that Electron does not support the full range of Chrome extensions APIs.
/// See Supported Extensions APIs for more details on what is supported.
///
/// Note that in previous versions of Electron, extensions that were loaded would be
/// remembered for future runs of the application.This is no longer the case:
/// `loadExtension` must be called on every boot of your app if you want the
/// extension to be loaded.
///
/// This API does not support loading packed (.crx) extensions.
///
///** Note:** This API cannot be called before the `ready` event of the `app` module
/// is emitted.
///
///** Note:** Loading extensions into in-memory(non-persistent) sessions is not supported and will throw an error.
/// </summary>
/// <param name="path">Path to the Chrome extension</param>
/// <param name="allowFileAccess">Whether to allow the extension to read local files over `file://` protocol and
/// inject content scripts into `file://` pages. This is required e.g. for loading
/// devtools extensions on `file://` URLs. Defaults to false.</param>
/// <returns></returns>
public Task<Extension> LoadExtensionAsync(string path, bool allowFileAccess = false)
{
var taskCompletionSource = new TaskCompletionSource<Extension>();
BridgeConnector.Socket.On("webContents-session-loadExtension-completed", (extension) =>
{
BridgeConnector.Socket.Off("webContents-session-loadExtension-completed");
taskCompletionSource.SetResult(((JObject)extension).ToObject<Extension>());
});
BridgeConnector.Socket.Emit("webContents-session-loadExtension", Id, path, allowFileAccess);
return taskCompletionSource.Task;
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),

View File

@@ -120,20 +120,19 @@ namespace ElectronNET.API
/// Move the given file to trash and returns a <see cref="bool"/> status for the operation.
/// </summary>
/// <param name="fullPath">The full path to the directory / file.</param>
/// <param name="deleteOnFail">Whether or not to unilaterally remove the item if the Trash is disabled or unsupported on the volume.</param>
/// <returns> Whether the item was successfully moved to the trash.</returns>
public Task<bool> MoveItemToTrashAsync(string fullPath, bool deleteOnFail)
public Task<bool> TrashItemAsync(string fullPath)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("shell-moveItemToTrashCompleted", (success) =>
BridgeConnector.Socket.On("shell-trashItem-completed", (success) =>
{
BridgeConnector.Socket.Off("shell-moveItemToTrashCompleted");
BridgeConnector.Socket.Off("shell-trashItem-completed");
taskCompletionSource.SetResult((bool) success);
});
BridgeConnector.Socket.Emit("shell-moveItemToTrash", fullPath, deleteOnFail);
BridgeConnector.Socket.Emit("shell-trashItem", fullPath);
return taskCompletionSource.Task;
}

View File

@@ -0,0 +1,93 @@
using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using SocketIOClient;
using SocketIOClient.Newtonsoft.Json;
namespace ElectronNET.API;
internal class SocketIoFacade
{
private readonly SocketIO _socket;
public SocketIoFacade(string uri)
{
_socket = new SocketIO(uri);
var jsonSerializer = new NewtonsoftJsonSerializer(new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
});
_socket.JsonSerializer = jsonSerializer;
}
public void Connect()
{
_socket.OnError += (sender, e) =>
{
Console.WriteLine($"BridgeConnector Error: {sender} {e}");
};
_socket.OnConnected += (_, _) =>
{
Console.WriteLine("BridgeConnector connected!");
};
_socket.OnDisconnected += (_, _) =>
{
Console.WriteLine("BridgeConnector disconnected!");
};
_socket.ConnectAsync().GetAwaiter().GetResult();
}
public void On(string eventName, Action action)
{
_socket.On(eventName, response =>
{
Task.Run(action);
});
}
public void On<T>(string eventName, Action<T> action)
{
_socket.On(eventName, response =>
{
var value = response.GetValue<T>();
Task.Run(() => action(value));
});
}
// TODO: Remove this method when SocketIoClient supports object deserialization
public void On(string eventName, Action<object> action)
{
_socket.On(eventName, response =>
{
var value = response.GetValue<object>();
Console.WriteLine($"Called Event {eventName} - data {value}");
Task.Run(() => action(value));
});
}
public void Once<T>(string eventName, Action<T> action)
{
_socket.On(eventName, (socketIoResponse) =>
{
_socket.Off(eventName);
Task.Run(() => action(socketIoResponse.GetValue<T>()));
});
}
public void Off(string eventName)
{
_socket.Off(eventName);
}
public async Task Emit(string eventName, params object[] args)
{
await _socket.EmitAsync(eventName, args);
}
}

View File

@@ -23,7 +23,7 @@ namespace ElectronNET.API
{
if (_click == null)
{
BridgeConnector.Socket.On("tray-click-event" + GetHashCode(), (result) =>
BridgeConnector.Socket.On<dynamic>("tray-click-event" + GetHashCode(), (result) =>
{
var args = ((JArray)result).ToObject<object[]>();
var trayClickEventArgs = ((JObject)args[0]).ToObject<TrayClickEventArgs>();
@@ -55,7 +55,7 @@ namespace ElectronNET.API
{
if (_rightClick == null)
{
BridgeConnector.Socket.On("tray-right-click-event" + GetHashCode(), (result) =>
BridgeConnector.Socket.On<dynamic>("tray-right-click-event" + GetHashCode(), (result) =>
{
var args = ((JArray)result).ToObject<object[]>();
var trayClickEventArgs = ((JObject)args[0]).ToObject<TrayClickEventArgs>();
@@ -87,7 +87,7 @@ namespace ElectronNET.API
{
if (_doubleClick == null)
{
BridgeConnector.Socket.On("tray-double-click-event" + GetHashCode(), (result) =>
BridgeConnector.Socket.On<dynamic>("tray-double-click-event" + GetHashCode(), (result) =>
{
var args = ((JArray)result).ToObject<object[]>();
var trayClickEventArgs = ((JObject)args[0]).ToObject<TrayClickEventArgs>();
@@ -182,7 +182,7 @@ namespace ElectronNET.API
{
_balloonClosed();
});
BridgeConnector.Socket.Emit("register-tray-balloon-closed", GetHashCode());
}
_balloonClosed += value;
@@ -201,7 +201,7 @@ namespace ElectronNET.API
// TODO: Implement macOS Events
private static Tray _tray;
private static object _syncRoot = new object();
private static readonly object _syncRoot = new();
internal Tray() { }
@@ -230,17 +230,18 @@ namespace ElectronNET.API
/// <value>
/// The menu items.
/// </value>
public IReadOnlyCollection<MenuItem> MenuItems { get { return _items.AsReadOnly(); } }
private List<MenuItem> _items = new List<MenuItem>();
public IReadOnlyCollection<MenuItem> MenuItems => _items.AsReadOnly();
private readonly List<MenuItem> _items = new();
/// <summary>
/// Shows the Traybar.
/// </summary>
/// <param name="image">The image.</param>
/// <param name="menuItem">The menu item.</param>
public void Show(string image, MenuItem menuItem)
public async Task Show(string image, MenuItem menuItem)
{
Show(image, new MenuItem[] { menuItem });
await Show(image, new MenuItem[] { menuItem });
}
/// <summary>
@@ -248,27 +249,36 @@ namespace ElectronNET.API
/// </summary>
/// <param name="image">The image.</param>
/// <param name="menuItems">The menu items.</param>
public void Show(string image, MenuItem[] menuItems)
public async Task Show(string image, MenuItem[] menuItems)
{
menuItems.AddMenuItemsId();
BridgeConnector.Socket.Emit("create-tray", image, JArray.FromObject(menuItems, _jsonSerializer));
await BridgeConnector.Socket.Emit("create-tray", image, JArray.FromObject(menuItems, _jsonSerializer));
_items.Clear();
_items.AddRange(menuItems);
BridgeConnector.Socket.Off("trayMenuItemClicked");
BridgeConnector.Socket.On("trayMenuItemClicked", (id) =>
BridgeConnector.Socket.On<string>("trayMenuItemClicked", (id) =>
{
MenuItem menuItem = _items.GetMenuItem(id.ToString());
MenuItem menuItem = _items.GetMenuItem(id);
menuItem?.Click();
});
}
/// <summary>
/// Shows the Traybar (empty).
/// </summary>
/// <param name="image">The image.</param>
public async Task Show(string image)
{
await BridgeConnector.Socket.Emit("create-tray", image);
}
/// <summary>
/// Destroys the tray icon immediately.
/// </summary>
public void Destroy()
public async Task Destroy()
{
BridgeConnector.Socket.Emit("tray-destroy");
await BridgeConnector.Socket.Emit("tray-destroy");
_items.Clear();
}
@@ -276,71 +286,101 @@ namespace ElectronNET.API
/// Sets the image associated with this tray icon.
/// </summary>
/// <param name="image"></param>
public void SetImage(string image)
public async Task SetImage(string image)
{
BridgeConnector.Socket.Emit("tray-setImage", image);
await BridgeConnector.Socket.Emit("tray-setImage", image);
}
/// <summary>
/// Sets the image associated with this tray icon when pressed on macOS.
/// </summary>
/// <param name="image"></param>
public void SetPressedImage(string image)
public async Task SetPressedImage(string image)
{
BridgeConnector.Socket.Emit("tray-setPressedImage", image);
await BridgeConnector.Socket.Emit("tray-setPressedImage", image);
}
/// <summary>
/// Sets the hover text for this tray icon.
/// </summary>
/// <param name="toolTip"></param>
public void SetToolTip(string toolTip)
public async Task SetToolTip(string toolTip)
{
BridgeConnector.Socket.Emit("tray-setToolTip", toolTip);
await BridgeConnector.Socket.Emit("tray-setToolTip", toolTip);
}
/// <summary>
/// macOS: Sets the title displayed aside of the tray icon in the status bar.
/// </summary>
/// <param name="title"></param>
public void SetTitle(string title)
public async Task SetTitle(string title)
{
BridgeConnector.Socket.Emit("tray-setTitle", title);
await BridgeConnector.Socket.Emit("tray-setTitle", title);
}
/// <summary>
/// Windows: Displays a tray balloon.
/// </summary>
/// <param name="options"></param>
public void DisplayBalloon(DisplayBalloonOptions options)
public async Task DisplayBalloon(DisplayBalloonOptions options)
{
BridgeConnector.Socket.Emit("tray-displayBalloon", JObject.FromObject(options, _jsonSerializer));
await BridgeConnector.Socket.Emit("tray-displayBalloon", JObject.FromObject(options, _jsonSerializer));
}
/// <summary>
/// Whether the tray icon is destroyed.
/// </summary>
/// <returns></returns>
public Task<bool> IsDestroyedAsync()
public async Task<bool> IsDestroyedAsync()
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("tray-isDestroyedCompleted", (isDestroyed) =>
BridgeConnector.Socket.On<bool>("tray-isDestroyedCompleted", (isDestroyed) =>
{
BridgeConnector.Socket.Off("tray-isDestroyedCompleted");
taskCompletionSource.SetResult((bool)isDestroyed);
taskCompletionSource.SetResult(isDestroyed);
});
BridgeConnector.Socket.Emit("tray-isDestroyed");
await BridgeConnector.Socket.Emit("tray-isDestroyed");
return taskCompletionSource.Task;
return await taskCompletionSource.Task;
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
private readonly JsonSerializer _jsonSerializer = new()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
private const string ModuleName = "tray";
/// <summary>
/// Subscribe to an unmapped event on the <see cref="Tray"/> module.
/// </summary>
/// <param name="eventName">The event name</param>
/// <param name="action">The handler</param>
public void On(string eventName, Action action)
=> Events.Instance.On(ModuleName, eventName, action);
/// <summary>
/// Subscribe to an unmapped event on the <see cref="Tray"/> module.
/// </summary>
/// <param name="eventName">The event name</param>
/// <param name="action">The handler</param>
public async Task On<T>(string eventName, Action<T> action)
=> await Events.Instance.On(ModuleName, eventName, action);
/// <summary>
/// Subscribe to an unmapped event on the <see cref="Tray"/> module once.
/// </summary>
/// <param name="eventName">The event name</param>
/// <param name="action">The handler</param>
public void Once(string eventName, Action action)
=> Events.Instance.Once(ModuleName, eventName, action);
/// <summary>
/// Subscribe to an unmapped event on the <see cref="Tray"/> module once.
/// </summary>
/// <param name="eventName">The event name</param>
/// <param name="action">The handler</param>
public async Task Once<T>(string eventName, Action<T> action)
=> await Events.Instance.Once(ModuleName, eventName, action);
}
}

View File

@@ -5,264 +5,305 @@ using Newtonsoft.Json.Serialization;
using System;
using System.Threading.Tasks;
namespace ElectronNET.API
namespace ElectronNET.API;
/// <summary>
/// Render and control web pages.
/// </summary>
public class WebContents
{
/// <summary>
/// Render and control web pages.
/// Gets the identifier.
/// </summary>
public class WebContents
/// <value>
/// The identifier.
/// </value>
public int Id { get; private set; }
/// <summary>
/// Manage browser sessions, cookies, cache, proxy settings, etc.
/// </summary>
public Session Session { get; internal set; }
/// <summary>
/// Emitted when the renderer process crashes or is killed.
/// </summary>
public event Action<bool> OnCrashed
{
/// <summary>
/// Gets the identifier.
/// </summary>
/// <value>
/// The identifier.
/// </value>
public int Id { get; private set; }
/// <summary>
/// Manage browser sessions, cookies, cache, proxy settings, etc.
/// </summary>
public Session Session { get; internal set; }
/// <summary>
/// Emitted when the renderer process crashes or is killed.
/// </summary>
public event Action<bool> OnCrashed
add
{
add
if (_crashed == null)
{
if (_crashed == null)
BridgeConnector.Socket.On("webContents-crashed" + Id, (killed) =>
{
BridgeConnector.Socket.On("webContents-crashed" + Id, (killed) =>
{
_crashed((bool)killed);
});
_crashed((bool)killed);
});
BridgeConnector.Socket.Emit("register-webContents-crashed", Id);
}
_crashed += value;
}
remove
{
_crashed -= value;
if (_crashed == null)
BridgeConnector.Socket.Off("webContents-crashed" + Id);
BridgeConnector.Socket.Emit("register-webContents-crashed", Id);
}
_crashed += value;
}
private event Action<bool> _crashed;
/// <summary>
/// Emitted when the navigation is done, i.e. the spinner of the tab has
/// stopped spinning, and the onload event was dispatched.
/// </summary>
public event Action OnDidFinishLoad
remove
{
add
{
if (_didFinishLoad == null)
{
BridgeConnector.Socket.On("webContents-didFinishLoad" + Id, () =>
{
_didFinishLoad();
});
_crashed -= value;
BridgeConnector.Socket.Emit("register-webContents-didFinishLoad", Id);
}
_didFinishLoad += value;
}
remove
{
_didFinishLoad -= value;
if (_didFinishLoad == null)
BridgeConnector.Socket.Off("webContents-didFinishLoad" + Id);
}
if (_crashed == null)
BridgeConnector.Socket.Off("webContents-crashed" + Id);
}
private event Action _didFinishLoad;
internal WebContents(int id)
{
Id = id;
Session = new Session(id);
}
/// <summary>
/// Opens the devtools.
/// </summary>
public void OpenDevTools()
{
BridgeConnector.Socket.Emit("webContentsOpenDevTools", Id);
}
/// <summary>
/// Opens the devtools.
/// </summary>
/// <param name="openDevToolsOptions"></param>
public void OpenDevTools(OpenDevToolsOptions openDevToolsOptions)
{
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.
/// By default, an empty options will be regarded as: Use page-break-before: always;
/// CSS style to force to print to a new page.
/// </summary>
/// <param name="path"></param>
/// <param name="options"></param>
/// <returns>success</returns>
public Task<bool> PrintToPDFAsync(string path, PrintToPDFOptions options = null)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("webContents-printToPDF-completed", (success) =>
{
BridgeConnector.Socket.Off("webContents-printToPDF-completed");
taskCompletionSource.SetResult((bool)success);
});
if(options == null)
{
BridgeConnector.Socket.Emit("webContents-printToPDF", Id, "", path);
}
else
{
BridgeConnector.Socket.Emit("webContents-printToPDF", Id, JObject.FromObject(options, _jsonSerializer), path);
}
return taskCompletionSource.Task;
}
/// <summary>
/// Is used to get the Url of the loaded page.
/// It's usefull if a web-server redirects you and you need to know where it redirects. For instance, It's useful in case of Implicit Authorization.
/// </summary>
/// <returns>URL of the loaded page</returns>
public Task<string> GetUrl()
{
var taskCompletionSource = new TaskCompletionSource<string>();
var eventString = "webContents-getUrl" + Id;
BridgeConnector.Socket.On(eventString, (url) =>
{
BridgeConnector.Socket.Off(eventString);
taskCompletionSource.SetResult((string)url);
});
BridgeConnector.Socket.Emit("webContents-getUrl", Id);
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(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
}
private event Action<bool> _crashed;
/// <summary>
/// Emitted when the navigation is done, i.e. the spinner of the tab has
/// stopped spinning, and the onload event was dispatched.
/// </summary>
public event Action OnDidFinishLoad
{
add
{
if (_didFinishLoad == null)
{
BridgeConnector.Socket.On("webContents-didFinishLoad" + Id, () =>
{
_didFinishLoad();
});
BridgeConnector.Socket.Emit("register-webContents-didFinishLoad", Id);
}
_didFinishLoad += value;
}
remove
{
_didFinishLoad -= value;
if (_didFinishLoad == null)
BridgeConnector.Socket.Off("webContents-didFinishLoad" + Id);
}
}
private event Action _didFinishLoad;
/// <summary>
/// Emitted when an input event is sent to the WebContents.
/// </summary>
public event Action<InputEvent> InputEvent
{
add
{
if (_inputEvent == null)
{
BridgeConnector.Socket.On("webContents-input-event" + Id, (eventArgs) =>
{
var inputEvent = ((JObject)eventArgs).ToObject<InputEvent>();
_inputEvent(inputEvent);
});
BridgeConnector.Socket.Emit("register-webContents-input-event", Id);
}
_inputEvent += value;
}
remove
{
_inputEvent -= value;
if (_inputEvent == null)
BridgeConnector.Socket.Off("webContents-input-event" + Id);
}
}
private event Action<InputEvent> _inputEvent;
internal WebContents(int id)
{
Id = id;
Session = new Session(id);
}
/// <summary>
/// Opens the devtools.
/// </summary>
public void OpenDevTools()
{
BridgeConnector.Socket.Emit("webContentsOpenDevTools", Id);
}
/// <summary>
/// Opens the devtools.
/// </summary>
/// <param name="openDevToolsOptions"></param>
public void OpenDevTools(OpenDevToolsOptions openDevToolsOptions)
{
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.
/// By default, an empty options will be regarded as: Use page-break-before: always;
/// CSS style to force to print to a new page.
/// </summary>
/// <param name="path"></param>
/// <param name="options"></param>
/// <returns>success</returns>
public Task<bool> PrintToPDFAsync(string path, PrintToPDFOptions options = null)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
BridgeConnector.Socket.On("webContents-printToPDF-completed", (success) =>
{
BridgeConnector.Socket.Off("webContents-printToPDF-completed");
taskCompletionSource.SetResult((bool)success);
});
if(options == null)
{
BridgeConnector.Socket.Emit("webContents-printToPDF", Id, "", path);
}
else
{
BridgeConnector.Socket.Emit("webContents-printToPDF", Id, JObject.FromObject(options, _jsonSerializer), path);
}
return taskCompletionSource.Task;
}
/// <summary>
/// Is used to get the Url of the loaded page.
/// It's usefull if a web-server redirects you and you need to know where it redirects. For instance, It's useful in case of Implicit Authorization.
/// </summary>
/// <returns>URL of the loaded page</returns>
public Task<string> GetUrl()
{
var taskCompletionSource = new TaskCompletionSource<string>();
var eventString = "webContents-getUrl" + Id;
BridgeConnector.Socket.On(eventString, (url) =>
{
BridgeConnector.Socket.Off(eventString);
taskCompletionSource.SetResult((string)url);
});
BridgeConnector.Socket.Emit("webContents-getUrl", Id);
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;
}
/// <summary>
/// Inserts CSS into the web page.
/// See: https://www.electronjs.org/docs/api/web-contents#contentsinsertcsscss-options
/// Works for both BrowserWindows and BrowserViews.
/// </summary>
/// <param name="isBrowserWindow">Whether the webContents belong to a BrowserWindow or not (the other option is a BrowserView)</param>
/// <param name="path">Absolute path to the CSS file location</param>
public void InsertCSS(bool isBrowserWindow, string path)
{
BridgeConnector.Socket.Emit("webContents-insertCSS", Id, isBrowserWindow, path);
}
private readonly JsonSerializer _jsonSerializer = new()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
}

View File

@@ -5,6 +5,7 @@ using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
@@ -16,7 +17,7 @@ namespace ElectronNET.API
public sealed class WindowManager
{
private static WindowManager _windowManager;
private static object _syncRoot = new object();
private static readonly object SyncRoot = new();
internal WindowManager() { }
@@ -26,7 +27,7 @@ namespace ElectronNET.API
{
if (_windowManager == null)
{
lock (_syncRoot)
lock (SyncRoot)
{
if (_windowManager == null)
{
@@ -47,7 +48,7 @@ namespace ElectronNET.API
/// </value>
public bool IsQuitOnWindowAllClosed
{
get { return _isQuitOnWindowAllClosed; }
get => _isQuitOnWindowAllClosed;
set
{
BridgeConnector.Socket.Emit("quit-app-window-all-closed-event", value);
@@ -62,8 +63,9 @@ namespace ElectronNET.API
/// <value>
/// The browser windows.
/// </value>
public IReadOnlyCollection<BrowserWindow> BrowserWindows { get { return _browserWindows.AsReadOnly(); } }
private List<BrowserWindow> _browserWindows = new List<BrowserWindow>();
public IReadOnlyCollection<BrowserWindow> BrowserWindows => _browserWindows.AsReadOnly();
private readonly List<BrowserWindow> _browserWindows = new();
/// <summary>
/// Gets the browser views.
@@ -71,8 +73,9 @@ namespace ElectronNET.API
/// <value>
/// The browser view.
/// </value>
public IReadOnlyCollection<BrowserView> BrowserViews { get { return _browserViews.AsReadOnly(); } }
private List<BrowserView> _browserViews = new List<BrowserView>();
public IReadOnlyCollection<BrowserView> BrowserViews => _browserViews.AsReadOnly();
private readonly List<BrowserView> _browserViews = new();
/// <summary>
/// Creates the window asynchronous.
@@ -90,7 +93,7 @@ namespace ElectronNET.API
/// <param name="options">The options.</param>
/// <param name="loadUrl">The load URL.</param>
/// <returns></returns>
public Task<BrowserWindow> CreateWindowAsync(BrowserWindowOptions options, string loadUrl = "http://localhost")
public async Task<BrowserWindow> CreateWindowAsync(BrowserWindowOptions options, string loadUrl = "http://localhost")
{
var taskCompletionSource = new TaskCompletionSource<BrowserWindow>();
@@ -98,16 +101,18 @@ namespace ElectronNET.API
{
BridgeConnector.Socket.Off("BrowserWindowCreated");
string windowId = id.ToString();
BrowserWindow browserWindow = new BrowserWindow(int.Parse(windowId));
var browserWindowId = int.Parse(id.ToString()!);
var browserWindow = new BrowserWindow(browserWindowId);
_browserWindows.Add(browserWindow);
taskCompletionSource.SetResult(browserWindow);
});
BridgeConnector.Socket.Off("BrowserWindowClosed");
BridgeConnector.Socket.On("BrowserWindowClosed", (ids) =>
BridgeConnector.Socket.On<object>("BrowserWindowClosed", (ids) =>
{
BridgeConnector.Socket.Off("BrowserWindowClosed");
var browserWindowIds = ((JArray)ids).ToObject<int[]>();
for (int index = 0; index < _browserWindows.Count; index++)
@@ -126,10 +131,10 @@ namespace ElectronNET.API
// Workaround Windows 10 / Electron Bug
// https://github.com/electron/electron/issues/4045
if (isWindows10())
if (IsWindows10())
{
options.Width = options.Width + 14;
options.Height = options.Height + 7;
options.Width += 14;
options.Height += 7;
}
if (options.X == -1 && options.Y == -1)
@@ -137,15 +142,15 @@ namespace ElectronNET.API
options.X = 0;
options.Y = 0;
BridgeConnector.Socket.Emit("createBrowserWindow", JObject.FromObject(options, _jsonSerializer), loadUrl);
await BridgeConnector.Socket.Emit("createBrowserWindow", JObject.FromObject(options, _jsonSerializer), loadUrl);
}
else
{
// Workaround Windows 10 / Electron Bug
// https://github.com/electron/electron/issues/4045
if (isWindows10())
if (IsWindows10())
{
options.X = options.X - 7;
options.X -= 7;
}
var ownjsonSerializer = new JsonSerializer()
@@ -153,13 +158,13 @@ namespace ElectronNET.API
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
BridgeConnector.Socket.Emit("createBrowserWindow", JObject.FromObject(options, ownjsonSerializer), loadUrl);
await BridgeConnector.Socket.Emit("createBrowserWindow", JObject.FromObject(options, ownjsonSerializer), loadUrl);
}
return taskCompletionSource.Task;
return await taskCompletionSource.Task;
}
private bool isWindows10()
private bool IsWindows10()
{
return RuntimeInformation.OSDescription.Contains("Windows 10");
}
@@ -182,7 +187,7 @@ namespace ElectronNET.API
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public Task<BrowserView> CreateBrowserViewAsync(BrowserViewConstructorOptions options)
public async Task<BrowserView> CreateBrowserViewAsync(BrowserViewConstructorOptions options)
{
var taskCompletionSource = new TaskCompletionSource<BrowserView>();
@@ -192,7 +197,6 @@ namespace ElectronNET.API
string browserViewId = id.ToString();
BrowserView browserView = new BrowserView(int.Parse(browserViewId));
browserView.Destroyed += (b) => _browserViews.Remove(b);
_browserViews.Add(browserView);
@@ -204,12 +208,12 @@ namespace ElectronNET.API
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
BridgeConnector.Socket.Emit("createBrowserView", JObject.FromObject(options, ownjsonSerializer));
await BridgeConnector.Socket.Emit("createBrowserView", JObject.FromObject(options, ownjsonSerializer));
return taskCompletionSource.Task;
return await taskCompletionSource.Task;
}
private JsonSerializer _jsonSerializer = new JsonSerializer()
private readonly JsonSerializer _jsonSerializer = new()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,

View File

@@ -10,11 +10,20 @@ namespace ElectronNET.CLI.Commands.Actions
EmbeddedFileHelper.DeployEmbeddedFile(tempPath, "package.json");
EmbeddedFileHelper.DeployEmbeddedFile(tempPath, "build-helper.js");
string vscodeFolder = Path.Combine(tempPath, ".vscode");
if (Directory.Exists(vscodeFolder) == false)
{
Directory.CreateDirectory(vscodeFolder);
}
EmbeddedFileHelper.DeployEmbeddedFile(vscodeFolder, "launch.json", ".vscode.");
EmbeddedFileHelper.DeployEmbeddedFile(vscodeFolder, "tasks.json", ".vscode.");
string hostApiFolder = Path.Combine(tempPath, "api");
if (Directory.Exists(hostApiFolder) == false)
{
Directory.CreateDirectory(hostApiFolder);
}
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "ipc.js", "api.");
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "app.js", "api.");
EmbeddedFileHelper.DeployEmbeddedFile(hostApiFolder, "browserWindows.js", "api.");

View File

@@ -75,13 +75,16 @@ namespace ElectronNET.CLI.Commands
// ToDo: Not sure if this runs under linux/macos
ProcessHelper.CmdExecute(@"npx tsc -p ../../", targetFilePath);
// search .csproj
Console.WriteLine($"Search your .csproj to add configure CopyToPublishDirectory to 'Never'");
var projectFile = Directory.EnumerateFiles(currentDirectory, "*.csproj", SearchOption.TopDirectoryOnly).FirstOrDefault();
// search .csproj or .fsproj (.csproj has higher precedence)
Console.WriteLine($"Search your .csproj/.fsproj to add configure CopyToPublishDirectory to 'Never'");
var projectFile = Directory.EnumerateFiles(currentDirectory, "*.csproj", SearchOption.TopDirectoryOnly)
.Union(Directory.EnumerateFiles(currentDirectory, "*.fsproj", SearchOption.TopDirectoryOnly))
.FirstOrDefault();
Console.WriteLine($"Found your .csproj: {projectFile} - check for existing CopyToPublishDirectory setting or update it.");
var extension = Path.GetExtension(projectFile);
Console.WriteLine($"Found your {extension}: {projectFile} - check for existing CopyToPublishDirectory setting or update it.");
if (!EditCsProj(projectFile)) return false;
if (!EditProjectFile(projectFile)) return false;
Console.WriteLine($"Everything done - happy electronizing with your custom npm packages!");
@@ -90,7 +93,7 @@ namespace ElectronNET.CLI.Commands
}
// ToDo: Cleanup this copy/past code.
private static bool EditCsProj(string projectFile)
private static bool EditProjectFile(string projectFile)
{
using (var stream = File.Open(projectFile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
@@ -128,7 +131,7 @@ namespace ElectronNET.CLI.Commands
}
Console.WriteLine($"Publish setting added in csproj!");
Console.WriteLine($"Publish setting added in csproj/fsproj!");
return true;
}

View File

@@ -13,14 +13,16 @@ namespace ElectronNET.CLI.Commands
public const string COMMAND_DESCRIPTION = "Build your Electron Application.";
public static string COMMAND_ARGUMENTS = "Needed: '/target' with params 'win/osx/linux' to build for a typical app or use 'custom' and specify .NET Core build config & electron build config" + Environment.NewLine +
" for custom target, check .NET Core RID Catalog and Electron build target/" + Environment.NewLine +
" e.g. '/target win' or '/target custom \"win7-x86;win32\"'" + Environment.NewLine +
" e.g. '/target win' or '/target custom \"win7-x86;win\"'" + Environment.NewLine +
"Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release" + Environment.NewLine +
"Optional: '/electron-arch' to specify the resulting electron processor architecture (e.g. ia86 for x86 builds). Be aware to use the '/target custom' param as well!" + Environment.NewLine +
"Optional: '/electron-params' specify any other valid parameter, which will be routed to the electron-packager." + Environment.NewLine +
"Optional: '/relative-path' to specify output a subdirectory for output." + Environment.NewLine +
"Optional: '/absolute-path to specify and absolute path for output." + Environment.NewLine +
"Optional: '/package-json' to specify a custom package.json file." + Environment.NewLine +
"Optional: '/install-modules' to force node module install. Implied by '/package-json'" + Environment.NewLine +
"Optional: '/install-modules' to force node module install. Implied by '/package-json'" + Environment.NewLine +
"Optional: '/Version' to specify the version that should be applied to both the `dotnet publish` and `electron-builder` commands. Implied by '/Version'" + Environment.NewLine +
"Optional: '/p:[property]' or '/property:[property]' to pass in dotnet publish properties. Example: '/property:Version=1.0.0' to override the FileVersion" + Environment.NewLine +
"Full example for a 32bit debug build with electron prune: build /target custom win7-x86;win32 /dotnet-configuration Debug /electron-arch ia32 /electron-params \"--prune=true \"";
public static IList<CommandOption> CommandOptions { get; set; } = new List<CommandOption>();
@@ -42,6 +44,8 @@ namespace ElectronNET.CLI.Commands
private string _paramForceNodeInstall = "install-modules";
private string _manifest = "manifest";
private string _paramPublishReadyToRun = "PublishReadyToRun";
private string _paramPublishSingleFile = "PublishSingleFile";
private string _paramVersion = "Version";
public Task<bool> ExecuteAsync()
{
@@ -52,6 +56,11 @@ namespace ElectronNET.CLI.Commands
SimpleCommandLineParser parser = new SimpleCommandLineParser();
parser.Parse(_args);
//This version will be shared between the dotnet publish and electron-builder commands
string version = null;
if (parser.Arguments.ContainsKey(_paramVersion))
version = parser.Arguments[_paramVersion][0];
if (!parser.Arguments.ContainsKey(_paramTarget))
{
Console.WriteLine($"Error: missing '{_paramTarget}' argument.");
@@ -77,35 +86,35 @@ namespace ElectronNET.CLI.Commands
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}...");
string tempPath = Path.Combine(Directory.GetCurrentDirectory(), "obj", "desktop", desiredPlatform);
if (Directory.Exists(tempPath) == false)
{
Directory.CreateDirectory(tempPath);
}
}
else
{
Directory.Delete(tempPath, true);
Directory.CreateDirectory(tempPath);
}
Console.WriteLine("Executing dotnet publish in this directory: " + tempPath);
string tempBinPath = Path.Combine(tempPath, "bin");
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid} under {configuration}-Configuration...");
var dotNetPublishFlags = GetDotNetPublishFlags(parser);
string publishReadyToRun = "/p:PublishReadyToRun=";
if (parser.Arguments.ContainsKey(_paramPublishReadyToRun))
{
publishReadyToRun += parser.Arguments[_paramPublishReadyToRun][0];
}
else
{
publishReadyToRun += "true";
}
var command =
$"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {string.Join(' ', dotNetPublishFlags.Select(kvp => $"{kvp.Key}={kvp.Value}"))} --self-contained";
// output the command
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(command);
Console.ResetColor();
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {publishReadyToRun} --self-contained", Directory.GetCurrentDirectory());
var resultCode = ProcessHelper.CmdExecute(command, Directory.GetCurrentDirectory());
if (resultCode != 0)
{
@@ -127,7 +136,7 @@ namespace ElectronNET.CLI.Commands
if (Directory.Exists(checkForNodeModulesDirPath) == false || parser.Contains(_paramForceNodeInstall) || parser.Contains(_paramPackageJson))
Console.WriteLine("Start npm install...");
Console.WriteLine("Start npm install...");
ProcessHelper.CmdExecute("npm install --production", tempPath);
Console.WriteLine("ElectronHostHook handling started...");
@@ -156,7 +165,7 @@ namespace ElectronNET.CLI.Commands
}
else if (parser.Arguments.ContainsKey(_paramOutputDirectory))
{
buildPath = Path.Combine(Directory.GetCurrentDirectory(),parser.Arguments[_paramOutputDirectory][0]);
buildPath = Path.Combine(Directory.GetCurrentDirectory(), parser.Arguments[_paramOutputDirectory][0]);
}
Console.WriteLine("Executing electron magic in this directory: " + buildPath);
@@ -178,20 +187,69 @@ namespace ElectronNET.CLI.Commands
string manifestFileName = "electron.manifest.json";
if(parser.Arguments.ContainsKey(_manifest))
if (parser.Arguments.ContainsKey(_manifest))
{
manifestFileName = parser.Arguments[_manifest].First();
}
ProcessHelper.CmdExecute($"node build-helper.js " + manifestFileName, tempPath);
ProcessHelper.CmdExecute(
string.IsNullOrWhiteSpace(version)
? $"node build-helper.js {manifestFileName}"
: $"node build-helper.js {manifestFileName} {version}", 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=9.0.3 {electronParams}", tempPath);
ProcessHelper.CmdExecute($"npx electron-builder --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=23.2.0 {electronParams}", tempPath);
Console.WriteLine("... done");
return true;
});
}
private Dictionary<string, string> GetDotNetPublishFlags(SimpleCommandLineParser parser)
{
var dotNetPublishFlags = new Dictionary<string, string>
{
{"/p:PublishReadyToRun", parser.TryGet(_paramPublishReadyToRun, out var rtr) ? rtr[0] : "true"},
{"/p:PublishSingleFile", parser.TryGet(_paramPublishSingleFile, out var psf) ? psf[0] : "true"},
};
if (parser.Arguments.ContainsKey(_paramVersion))
{
if(parser.Arguments.Keys.All(key => !key.StartsWith("p:Version=") && !key.StartsWith("property:Version=")))
dotNetPublishFlags.Add("/p:Version", parser.Arguments[_paramVersion][0]);
if(parser.Arguments.Keys.All(key => !key.StartsWith("p:ProductVersion=") && !key.StartsWith("property:ProductVersion=")))
dotNetPublishFlags.Add("/p:ProductVersion", parser.Arguments[_paramVersion][0]);
}
foreach (var parm in parser.Arguments.Keys.Where(key => key.StartsWith("p:") || key.StartsWith("property:")))
{
var split = parm.IndexOf('=');
if (split < 0)
{
continue;
}
var key = $"/{parm.Substring(0, split)}";
// normalize the key
if (key.StartsWith("/property:"))
{
key = key.Replace("/property:", "/p:");
}
var value = parm.Substring(split + 1);
if (dotNetPublishFlags.ContainsKey(key))
{
dotNetPublishFlags[key] = value;
}
else
{
dotNetPublishFlags.Add(key, value);
}
}
return dotNetPublishFlags;
}
}
}
}

View File

@@ -70,19 +70,22 @@ namespace ElectronNET.CLI.Commands
// Deploy config file
EmbeddedFileHelper.DeployEmbeddedFileToTargetFile(currentDirectory, DefaultConfigFileName, ConfigName);
// search .csproj
Console.WriteLine($"Search your .csproj to add the needed {ConfigName}...");
var projectFile = Directory.EnumerateFiles(currentDirectory, "*.csproj", SearchOption.TopDirectoryOnly).FirstOrDefault();
// search .csproj/.fsproj (.csproj has higher precedence)
Console.WriteLine($"Search your .csproj/fsproj to add the needed {ConfigName}...");
var projectFile = Directory.EnumerateFiles(currentDirectory, "*.csproj", SearchOption.TopDirectoryOnly)
.Union(Directory.EnumerateFiles(currentDirectory, "*.fsproj", SearchOption.TopDirectoryOnly))
.FirstOrDefault();
// update config file with the name of the csproj
// ToDo: If the csproj name != application name, this will fail
// update config file with the name of the csproj/fsproj
// ToDo: If the csproj/fsproj name != application name, this will fail
string text = File.ReadAllText(targetFilePath);
text = text.Replace("{{executable}}", Path.GetFileNameWithoutExtension(projectFile));
File.WriteAllText(targetFilePath, text);
Console.WriteLine($"Found your .csproj: {projectFile} - check for existing config or update it.");
var extension = Path.GetExtension(projectFile);
Console.WriteLine($"Found your {extension}: {projectFile} - check for existing config or update it.");
if (!EditCsProj(projectFile)) return false;
if (!EditProjectFile(projectFile)) return false;
// search launchSettings.json
Console.WriteLine($"Search your .launchSettings to add our electron debug profile...");
@@ -158,7 +161,7 @@ namespace ElectronNET.CLI.Commands
}
}
private static bool EditCsProj(string projectFile)
private static bool EditProjectFile(string projectFile)
{
using (var stream = File.Open(projectFile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
@@ -174,11 +177,11 @@ namespace ElectronNET.CLI.Commands
if (xmlDocument.ToString().Contains($"Content Update=\"{ConfigName}\""))
{
Console.WriteLine($"{ConfigName} already in csproj.");
Console.WriteLine($"{ConfigName} already in csproj/fsproj.");
return false;
}
Console.WriteLine($"{ConfigName} will be added to csproj.");
Console.WriteLine($"{ConfigName} will be added to csproj/fsproj.");
string itemGroupXmlString = "<ItemGroup>" +
"<Content Update=\"" + ConfigName + "\">" +
@@ -204,7 +207,7 @@ namespace ElectronNET.CLI.Commands
}
Console.WriteLine($"{ConfigName} added in csproj!");
Console.WriteLine($"{ConfigName} added in csproj/fsproj!");
return true;
}
}

View File

@@ -27,7 +27,9 @@ namespace ElectronNET.CLI.Commands
private string _manifest = "manifest";
private string _clearCache = "clear-cache";
private string _paramPublishReadyToRun = "PublishReadyToRun";
private string _paramPublishSingleFile = "PublishSingleFile";
private string _paramDotNetConfig = "dotnet-configuration";
private string _paramTarget = "target";
public Task<bool> ExecuteAsync()
{
@@ -59,8 +61,6 @@ namespace ElectronNET.CLI.Commands
Directory.CreateDirectory(tempPath);
}
var platformInfo = GetTargetPlatformInformation.Do(string.Empty, string.Empty);
string tempBinPath = Path.Combine(tempPath, "bin");
var resultCode = 0;
@@ -74,6 +74,31 @@ namespace ElectronNET.CLI.Commands
publishReadyToRun += "true";
}
string publishSingleFile = "/p:PublishSingleFile=";
if (parser.Arguments.ContainsKey(_paramPublishSingleFile))
{
publishSingleFile += parser.Arguments[_paramPublishSingleFile][0];
}
else
{
publishSingleFile += "true";
}
// If target is specified as a command line argument, use it.
// Format is the same as the build command.
// If target is not specified, autodetect it.
var platformInfo = GetTargetPlatformInformation.Do(string.Empty, string.Empty);
if (parser.Arguments.ContainsKey(_paramTarget))
{
var desiredPlatform = parser.Arguments[_paramTarget][0];
string specifiedFromCustom = string.Empty;
if (desiredPlatform == "custom" && parser.Arguments[_paramTarget].Length > 1)
{
specifiedFromCustom = parser.Arguments[_paramTarget][1];
}
platformInfo = GetTargetPlatformInformation.Do(desiredPlatform, specifiedFromCustom);
}
string configuration = "Debug";
if (parser.Arguments.ContainsKey(_paramDotNetConfig))
{
@@ -82,7 +107,7 @@ namespace ElectronNET.CLI.Commands
if (parser != null && !parser.Arguments.ContainsKey("watch"))
{
resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {publishReadyToRun} --no-self-contained", aspCoreProjectPath);
resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {publishReadyToRun} {publishSingleFile} --no-self-contained", aspCoreProjectPath);
}
if (resultCode != 0)

View File

@@ -1,19 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>dotnet-electronize</AssemblyName>
<ToolCommandName>electronize</ToolCommandName>
<PackageType>DotnetCliTool</PackageType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>..\artifacts</PackageOutputPath>
<PackageId>ElectronNET.CLI</PackageId>
<!-- Version 99 is just set for local development stuff to avoid a conflict with "real" packages on NuGet.org -->
<Version>99.0.0.0</Version>
<Authors>Gregor Biswanger, Robert Muehsig</Authors>
<Authors>Gregor Biswanger, Florian Rappl</Authors>
<Product>Electron.NET</Product>
<Company />
<Description>
@@ -29,22 +26,19 @@
<PackageReleaseNotes>Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md</PackageReleaseNotes>
<PackageIcon>PackageIcon.png</PackageIcon>
<PackAsTool>true</PackAsTool>
<StartupObject></StartupObject>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<None Remove="ElectronHost\package-lock.json" />
<None Remove="ElectronHost\package.json" />
</ItemGroup>
<ItemGroup>
<None Include="PackageIcon.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\ElectronNET.Host\electron.manifest.json" Link="ElectronHost\electron.manifest.json" />
<EmbeddedResource Include="..\ElectronNET.Host\package.json" Link="ElectronHost\package.json" />
@@ -74,13 +68,17 @@
<EmbeddedResource Include="..\ElectronNET.Host\api\browserView.js" Link="ElectronHost\api\browserView.js" />
<EmbeddedResource Include="..\ElectronNET.Host\api\powerMonitor.js" Link="ElectronHost\api\powerMonitor.js" />
<EmbeddedResource Include="..\ElectronNET.Host\api\nativeTheme.js" Link="ElectronHost\api\nativeTheme.js" />
<EmbeddedResource Include="..\ElectronNET.Host\.vscode\launch.json" Link="ElectronHost\.vscode\launch.json" />
<EmbeddedResource Include="..\ElectronNET.Host\.vscode\tasks.json" Link="ElectronHost\.vscode\tasks.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.410601">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
<Exec Command="$(ProjectDir)devCleanup.cmd" IgnoreExitCode="true" />
@@ -88,4 +86,4 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' != 'Windows_NT'">
<Exec Command="$(ProjectDir)devCleanup.sh" IgnoreExitCode="true" />
</Target>
</Project>
</Project>

View File

@@ -1,14 +1,11 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
namespace ElectronNET.CLI
{
public class ProcessHelper
{
private readonly static Regex ErrorRegex = new Regex(@"\berror\b", RegexOptions.IgnoreCase | RegexOptions.Compiled);
public static int CmdExecute(string command, string workingDirectoryPath, bool output = true, bool waitForExit = true)
{
using (Process cmd = new Process())
@@ -17,12 +14,13 @@ namespace ElectronNET.CLI
if (isWindows)
{
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
}
else
{
// works for OSX and Linux (at least on Ubuntu)
cmd.StartInfo.FileName = "bash";
var escapedArgs = command.Replace("\"", "\\\"");
cmd.StartInfo = new ProcessStartInfo("bash", $"-c \"{escapedArgs}\"");
}
cmd.StartInfo.RedirectStandardInput = true;
@@ -32,65 +30,23 @@ namespace ElectronNET.CLI
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.WorkingDirectory = workingDirectoryPath;
int returnCode = 0;
if (output)
{
cmd.OutputDataReceived += (s, e) =>
{
// (sometimes error messages are only visbile here)
// poor mans solution, we just seek for the term 'error'
// we can't just use cmd.ExitCode, because
// we delegate it to cmd.exe, which runs fine
// but we can catch any error here and return
// 1 if something fails
if (e != null && string.IsNullOrWhiteSpace(e.Data) == false)
{
if (ErrorRegex.IsMatch(e.Data))
{
returnCode = 1;
}
Console.WriteLine(e.Data);
}
};
cmd.ErrorDataReceived += (s, e) =>
{
// poor mans solution, we just seek for the term 'error'
// we can't just use cmd.ExitCode, because
// we delegate it to cmd.exe, which runs fine
// but we can catch any error here and return
// 1 if something fails
if (e != null && string.IsNullOrWhiteSpace(e.Data) == false)
{
if (ErrorRegex.IsMatch(e.Data))
{
returnCode = 1;
}
Console.WriteLine(e.Data);
}
};
cmd.OutputDataReceived += (s, e) => Console.WriteLine(e.Data);
cmd.ErrorDataReceived += (s, e) => Console.WriteLine(e.Data);
}
Console.WriteLine(command);
cmd.Start();
cmd.BeginOutputReadLine();
cmd.BeginErrorReadLine();
cmd.StandardInput.WriteLine(command);
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
if (waitForExit)
{
cmd.WaitForExit();
}
return returnCode;
return cmd.ExitCode;
}
}
}

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
namespace ElectronNET.CLI
{
@@ -29,10 +31,24 @@ namespace ElectronNET.CLI
}
if (currentName != "")
Arguments[currentName] = values.ToArray();
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"Arguments: \n\t{string.Join("\n\t",Arguments.Keys.Select(i => $"{i} = {string.Join(" ", Arguments[i])}"))}");
Console.ResetColor();
}
public bool Contains(string name)
{
return Arguments.ContainsKey(name);
}
internal bool TryGet(string key, out string[] value)
{
value = null;
if (!Contains(key)) {
return false;
}
value = Arguments[key];
return true;
}
}
}

View File

@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Connector = void 0;
class Connector {
constructor(socket,
// @ts-ignore

View File

@@ -1 +1 @@
{"version":3,"file":"connector.js","sourceRoot":"","sources":["connector.ts"],"names":[],"mappings":";;AAAA,MAAa,SAAS;IAClB,YAAoB,MAAuB;IACvC,aAAa;IACN,GAAiB;QAFR,WAAM,GAAN,MAAM,CAAiB;QAEhC,QAAG,GAAH,GAAG,CAAc;IAAI,CAAC;IAEjC,EAAE,CAAC,GAAW,EAAE,cAAwB;QACpC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;YACnC,MAAM,EAAE,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;YAE9B,IAAI;gBACA,cAAc,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;oBAC7B,IAAI,IAAI,EAAE;wBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,WAAW,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;qBACjD;gBACL,CAAC,CAAC,CAAC;aACN;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,QAAQ,EAAE,EAAE,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;aACtE;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AApBD,8BAoBC"}
{"version":3,"file":"connector.js","sourceRoot":"","sources":["connector.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAS;IAClB,YAAoB,MAAuB;IACvC,aAAa;IACN,GAAiB;QAFR,WAAM,GAAN,MAAM,CAAiB;QAEhC,QAAG,GAAH,GAAG,CAAc;IAAI,CAAC;IAEjC,EAAE,CAAC,GAAW,EAAE,cAAwB;QACpC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;YACnC,MAAM,EAAE,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;YAE9B,IAAI;gBACA,cAAc,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;oBAC7B,IAAI,IAAI,EAAE;wBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,WAAW,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;qBACjD;gBACL,CAAC,CAAC,CAAC;aACN;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,QAAQ,EAAE,EAAE,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;aACtE;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AApBD,8BAoBC"}

View File

@@ -1,5 +1,7 @@
import { Socket } from 'socket.io';
export class Connector {
constructor(private socket: SocketIO.Socket,
constructor(private socket: Socket,
// @ts-ignore
public app: Electron.App) { }

View File

@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HookService = void 0;
const connector_1 = require("./connector");
class HookService extends connector_1.Connector {
constructor(socket, app) {

View File

@@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAEA,2CAAwC;AAExC,MAAa,WAAY,SAAQ,qBAAS;IACtC,YAAY,MAAuB,EAAS,GAAiB;QACzD,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QADqB,QAAG,GAAH,GAAG,CAAc;IAE7D,CAAC;IAED,WAAW;QACP,8CAA8C;IAClD,CAAC;CACJ;AARD,kCAQC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAEA,2CAAwC;AAExC,MAAa,WAAY,SAAQ,qBAAS;IACtC,YAAY,MAAuB,EAAS,GAAiB;QACzD,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QADqB,QAAG,GAAH,GAAG,CAAc;IAE7D,CAAC;IAED,WAAW;QACP,8CAA8C;IAClD,CAAC;CACJ;AARD,kCAQC"}

View File

@@ -1,9 +1,10 @@
// @ts-ignore
import * as Electron from "electron";
import { Socket } from "socket.io";
import { Connector } from "./connector";
export class HookService extends Connector {
constructor(socket: SocketIO.Socket, public app: Electron.App) {
constructor(socket: Socket, public app: Electron.App) {
super(socket, app);
}
@@ -11,4 +12,3 @@ export class HookService extends Connector {
// execute your own JavaScript Host logic here
}
}

View File

@@ -0,0 +1,441 @@
{
"name": "electron-host-hook",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "electron-host-hook",
"version": "1.0.0",
"license": "MIT",
"devDependencies": {
"socket.io": "^4.6.1",
"typescript": "^5.0.2"
}
},
"node_modules/@socket.io/component-emitter": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
"integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==",
"dev": true
},
"node_modules/@types/cookie": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz",
"integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==",
"dev": true
},
"node_modules/@types/cors": {
"version": "2.8.13",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.13.tgz",
"integrity": "sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/node": {
"version": "18.15.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.5.tgz",
"integrity": "sha512-Ark2WDjjZO7GmvsyFFf81MXuGTA/d6oP38anyxWOL6EREyBKAxKoFHwBhaZxCfLRLpO8JgVXwqOwSwa7jRcjew==",
"dev": true
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"dev": true,
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/base64id": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
"integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==",
"dev": true,
"engines": {
"node": "^4.5.0 || >= 5.9"
}
},
"node_modules/cookie": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
"integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==",
"dev": true,
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"dev": true,
"dependencies": {
"object-assign": "^4",
"vary": "^1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dev": true,
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/engine.io": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.4.1.tgz",
"integrity": "sha512-JFYQurD/nbsA5BSPmbaOSLa3tSVj8L6o4srSwXXY3NqE+gGUNmmPTbhn8tjzcCtSqhFgIeqef81ngny8JM25hw==",
"dev": true,
"dependencies": {
"@types/cookie": "^0.4.1",
"@types/cors": "^2.8.12",
"@types/node": ">=10.0.0",
"accepts": "~1.3.4",
"base64id": "2.0.0",
"cookie": "~0.4.1",
"cors": "~2.8.5",
"debug": "~4.3.1",
"engine.io-parser": "~5.0.3",
"ws": "~8.11.0"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/engine.io-parser": {
"version": "5.0.6",
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.6.tgz",
"integrity": "sha512-tjuoZDMAdEhVnSFleYPCtdL2GXwVTGtNjoeJd9IhIG3C1xs9uwxqRNEu5WpnDZCaozwVlK/nuQhpodhXSIMaxw==",
"dev": true,
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"dev": true,
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dev": true,
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"dev": true,
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/socket.io": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.6.1.tgz",
"integrity": "sha512-KMcaAi4l/8+xEjkRICl6ak8ySoxsYG+gG6/XfRCPJPQ/haCRIJBTL4wIl8YCsmtaBovcAXGLOShyVWQ/FG8GZA==",
"dev": true,
"dependencies": {
"accepts": "~1.3.4",
"base64id": "~2.0.0",
"debug": "~4.3.2",
"engine.io": "~6.4.1",
"socket.io-adapter": "~2.5.2",
"socket.io-parser": "~4.2.1"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/socket.io-adapter": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.2.tgz",
"integrity": "sha512-87C3LO/NOMc+eMcpcxUBebGjkpMDkNBS9tf7KJqcDsmL936EChtVva71Dw2q4tQcuVC+hAUy4an2NO/sYXmwRA==",
"dev": true,
"dependencies": {
"ws": "~8.11.0"
}
},
"node_modules/socket.io-parser": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.2.tgz",
"integrity": "sha512-DJtziuKypFkMMHCm2uIshOYC7QaylbtzQwiMYDuCKy3OPkjLzu4B2vAhTlqipRHHzrI0NJeBAizTK7X+6m1jVw==",
"dev": true,
"dependencies": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.1"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/typescript": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz",
"integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=12.20"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"dev": true,
"engines": {
"node": ">= 0.8"
}
},
"node_modules/ws": {
"version": "8.11.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
"integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
"dev": true,
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
}
},
"dependencies": {
"@socket.io/component-emitter": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
"integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==",
"dev": true
},
"@types/cookie": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz",
"integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==",
"dev": true
},
"@types/cors": {
"version": "2.8.13",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.13.tgz",
"integrity": "sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/node": {
"version": "18.15.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.5.tgz",
"integrity": "sha512-Ark2WDjjZO7GmvsyFFf81MXuGTA/d6oP38anyxWOL6EREyBKAxKoFHwBhaZxCfLRLpO8JgVXwqOwSwa7jRcjew==",
"dev": true
},
"accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"dev": true,
"requires": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
}
},
"base64id": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
"integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==",
"dev": true
},
"cookie": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
"integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==",
"dev": true
},
"cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"dev": true,
"requires": {
"object-assign": "^4",
"vary": "^1"
}
},
"debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dev": true,
"requires": {
"ms": "2.1.2"
}
},
"engine.io": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.4.1.tgz",
"integrity": "sha512-JFYQurD/nbsA5BSPmbaOSLa3tSVj8L6o4srSwXXY3NqE+gGUNmmPTbhn8tjzcCtSqhFgIeqef81ngny8JM25hw==",
"dev": true,
"requires": {
"@types/cookie": "^0.4.1",
"@types/cors": "^2.8.12",
"@types/node": ">=10.0.0",
"accepts": "~1.3.4",
"base64id": "2.0.0",
"cookie": "~0.4.1",
"cors": "~2.8.5",
"debug": "~4.3.1",
"engine.io-parser": "~5.0.3",
"ws": "~8.11.0"
}
},
"engine.io-parser": {
"version": "5.0.6",
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.6.tgz",
"integrity": "sha512-tjuoZDMAdEhVnSFleYPCtdL2GXwVTGtNjoeJd9IhIG3C1xs9uwxqRNEu5WpnDZCaozwVlK/nuQhpodhXSIMaxw==",
"dev": true
},
"mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"dev": true
},
"mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dev": true,
"requires": {
"mime-db": "1.52.0"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"dev": true
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"dev": true
},
"socket.io": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.6.1.tgz",
"integrity": "sha512-KMcaAi4l/8+xEjkRICl6ak8ySoxsYG+gG6/XfRCPJPQ/haCRIJBTL4wIl8YCsmtaBovcAXGLOShyVWQ/FG8GZA==",
"dev": true,
"requires": {
"accepts": "~1.3.4",
"base64id": "~2.0.0",
"debug": "~4.3.2",
"engine.io": "~6.4.1",
"socket.io-adapter": "~2.5.2",
"socket.io-parser": "~4.2.1"
}
},
"socket.io-adapter": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.2.tgz",
"integrity": "sha512-87C3LO/NOMc+eMcpcxUBebGjkpMDkNBS9tf7KJqcDsmL936EChtVva71Dw2q4tQcuVC+hAUy4an2NO/sYXmwRA==",
"dev": true,
"requires": {
"ws": "~8.11.0"
}
},
"socket.io-parser": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.2.tgz",
"integrity": "sha512-DJtziuKypFkMMHCm2uIshOYC7QaylbtzQwiMYDuCKy3OPkjLzu4B2vAhTlqipRHHzrI0NJeBAizTK7X+6m1jVw==",
"dev": true,
"requires": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.1"
}
},
"typescript": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz",
"integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==",
"dev": true
},
"vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"dev": true
},
"ws": {
"version": "8.11.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
"integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
"dev": true,
"requires": {}
}
}
}

View File

@@ -13,7 +13,7 @@
"author": "Gregor Biswanger",
"license": "MIT",
"devDependencies": {
"@types/socket.io": "^2.1.2",
"typescript": "^3.4.5"
"socket.io": "^4.6.1",
"typescript": "^5.0.2"
}
}

View File

@@ -90,15 +90,6 @@ module.exports = (socket, app) => {
const path = app.getPath(name);
electronSocket.emit('appGetPathCompleted', path);
});
// const nativeImages = {};
// function addNativeImage(nativeImage: Electron.NativeImage) {
// if(Object.keys(nativeImages).length === 0) {
// nativeImage['1'] = nativeImage;
// } else {
// let indexCount = Object.keys(nativeImages).length + 1;
// nativeImage[indexCount] = nativeImage;
// }
// }
socket.on('appGetFileIcon', async (path, options) => {
let error = {};
if (options) {
@@ -157,11 +148,11 @@ module.exports = (socket, app) => {
app.setJumpList(categories);
});
socket.on('appRequestSingleInstanceLock', () => {
app.on('second-instance', (args, workingDirectory) => {
electronSocket.emit('secondInstance', [args, workingDirectory]);
});
const success = app.requestSingleInstanceLock();
electronSocket.emit('appRequestSingleInstanceLockCompleted', success);
app.on('second-instance', (event, args = [], workingDirectory = '') => {
electronSocket.emit('secondInstance', [args, workingDirectory]);
});
});
socket.on('appHasSingleInstanceLock', () => {
const hasLock = app.hasSingleInstanceLock();
@@ -237,5 +228,25 @@ module.exports = (socket, app) => {
socket.on('appSetUserAgentFallback', (userAgent) => {
app.userAgentFallback = userAgent;
});
socket.on('register-app-on-event', (eventName, listenerName) => {
app.on(eventName, (...args) => {
if (args.length > 1) {
electronSocket.emit(listenerName, args[1]);
}
else {
electronSocket.emit(listenerName);
}
});
});
socket.on('register-app-once-event', (eventName, listenerName) => {
app.once(eventName, (...args) => {
if (args.length > 1) {
electronSocket.emit(listenerName, args[1]);
}
else {
electronSocket.emit(listenerName);
}
});
});
};
//# sourceMappingURL=app.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,8 @@
import { Socket } from "net";
let isQuitWindowAllClosed = true, electronSocket;
let appWindowAllClosedEventId;
export = (socket: SocketIO.Socket, app: Electron.App) => {
export = (socket: Socket, app: Electron.App) => {
electronSocket = socket;
// By default, quit when all windows are closed
@@ -103,25 +105,13 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
socket.on('appSetAppLogsPath', (path) => {
app.setAppLogsPath(path);
});
});
socket.on('appGetPath', (name) => {
const path = app.getPath(name);
electronSocket.emit('appGetPathCompleted', path);
});
// const nativeImages = {};
// function addNativeImage(nativeImage: Electron.NativeImage) {
// if(Object.keys(nativeImages).length === 0) {
// nativeImage['1'] = nativeImage;
// } else {
// let indexCount = Object.keys(nativeImages).length + 1;
// nativeImage[indexCount] = nativeImage;
// }
// }
socket.on('appGetFileIcon', async (path, options) => {
let error = {};
@@ -196,12 +186,12 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
});
socket.on('appRequestSingleInstanceLock', () => {
app.on('second-instance', (args, workingDirectory) => {
electronSocket.emit('secondInstance', [args, workingDirectory]);
});
const success = app.requestSingleInstanceLock();
electronSocket.emit('appRequestSingleInstanceLockCompleted', success);
app.on('second-instance', (event, args = [], workingDirectory = '') => {
electronSocket.emit('secondInstance', [args, workingDirectory]);
});
});
socket.on('appHasSingleInstanceLock', () => {
@@ -222,7 +212,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
const activityType = app.getCurrentActivityType();
electronSocket.emit('appGetCurrentActivityTypeCompleted', activityType);
});
socket.on('appInvalidateCurrentActivity', () => {
app.invalidateCurrentActivity();
});
@@ -290,7 +280,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
socket.on('appSetAboutPanelOptions', (options) => {
app.setAboutPanelOptions(options);
});
});
socket.on('appGetUserAgentFallback', () => {
electronSocket.emit('appGetUserAgentFallbackCompleted', app.userAgentFallback);
@@ -299,4 +289,24 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
socket.on('appSetUserAgentFallback', (userAgent) => {
app.userAgentFallback = userAgent;
});
socket.on('register-app-on-event', (eventName, listenerName) => {
app.on(eventName, (...args) => {
if (args.length > 1) {
electronSocket.emit(listenerName, args[1]);
} else {
electronSocket.emit(listenerName);
}
});
});
socket.on('register-app-once-event', (eventName, listenerName) => {
app.once(eventName, (...args) => {
if (args.length > 1) {
electronSocket.emit(listenerName, args[1]);
} else {
electronSocket.emit(listenerName);
}
});
});
};

View File

@@ -1,10 +1,8 @@
"use strict";
const electron_updater_1 = require("electron-updater");
const path = require('path');
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
// Events ********
socket.on('register-autoUpdater-error-event', (id) => {
electron_updater_1.autoUpdater.on('error', (error) => {
electronSocket.emit('autoUpdater-error' + id, error.message);
@@ -72,21 +70,34 @@ module.exports = (socket) => {
socket.on('autoUpdater-updateConfigPath-set', (value) => {
electron_updater_1.autoUpdater.updateConfigPath = value;
});
socket.on('autoUpdater-currentVersion-get', () => {
electronSocket.emit('autoUpdater-currentVersion-get-reply', electron_updater_1.autoUpdater.currentVersion);
});
socket.on('autoUpdater-channel-get', () => {
electronSocket.emit('autoUpdater-channel-get-reply', electron_updater_1.autoUpdater.channel || '');
});
socket.on('autoUpdater-channel-set', (value) => {
electron_updater_1.autoUpdater.channel = value;
});
// Methods ********
socket.on('autoUpdater-requestHeaders-get', () => {
electronSocket.emit('autoUpdater-requestHeaders-get-reply', electron_updater_1.autoUpdater.requestHeaders);
});
socket.on('autoUpdater-requestHeaders-set', (value) => {
electron_updater_1.autoUpdater.requestHeaders = value;
});
socket.on('autoUpdaterCheckForUpdatesAndNotify', async (guid) => {
const updateCheckResult = await electron_updater_1.autoUpdater.checkForUpdatesAndNotify();
electronSocket.emit('autoUpdaterCheckForUpdatesAndNotifyComplete' + guid, updateCheckResult);
electron_updater_1.autoUpdater.checkForUpdatesAndNotify().then((updateCheckResult) => {
electronSocket.emit('autoUpdaterCheckForUpdatesAndNotifyComplete' + guid, updateCheckResult);
}).catch((error) => {
electronSocket.emit('autoUpdaterCheckForUpdatesAndNotifyError' + guid, error);
});
});
socket.on('autoUpdaterCheckForUpdates', async (guid) => {
// autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml');
const updateCheckResult = await electron_updater_1.autoUpdater.checkForUpdates();
electronSocket.emit('autoUpdaterCheckForUpdatesComplete' + guid, updateCheckResult);
electron_updater_1.autoUpdater.checkForUpdates().then((updateCheckResult) => {
electronSocket.emit('autoUpdaterCheckForUpdatesComplete' + guid, updateCheckResult);
}).catch((error) => {
electronSocket.emit('autoUpdaterCheckForUpdatesError' + guid, error);
});
});
socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => {
electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter);

View File

@@ -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,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C;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"}

View File

@@ -1,12 +1,10 @@
import { Socket } from 'net';
import { autoUpdater } from 'electron-updater';
const path = require('path');
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
// Events ********
socket.on('register-autoUpdater-error-event', (id) => {
autoUpdater.on('error', (error) => {
electronSocket.emit('autoUpdater-error' + id, error.message);
@@ -93,6 +91,10 @@ export = (socket: SocketIO.Socket) => {
autoUpdater.updateConfigPath = value;
});
socket.on('autoUpdater-currentVersion-get', () => {
electronSocket.emit('autoUpdater-currentVersion-get-reply', autoUpdater.currentVersion);
});
socket.on('autoUpdater-channel-get', () => {
electronSocket.emit('autoUpdater-channel-get-reply', autoUpdater.channel || '');
});
@@ -101,17 +103,28 @@ export = (socket: SocketIO.Socket) => {
autoUpdater.channel = value;
});
// Methods ********
socket.on('autoUpdater-requestHeaders-get', () => {
electronSocket.emit('autoUpdater-requestHeaders-get-reply', autoUpdater.requestHeaders);
});
socket.on('autoUpdater-requestHeaders-set', (value) => {
autoUpdater.requestHeaders = value;
});
socket.on('autoUpdaterCheckForUpdatesAndNotify', async (guid) => {
const updateCheckResult = await autoUpdater.checkForUpdatesAndNotify();
electronSocket.emit('autoUpdaterCheckForUpdatesAndNotifyComplete' + guid, updateCheckResult);
autoUpdater.checkForUpdatesAndNotify().then((updateCheckResult) => {
electronSocket.emit('autoUpdaterCheckForUpdatesAndNotifyComplete' + guid, updateCheckResult);
}).catch((error) => {
electronSocket.emit('autoUpdaterCheckForUpdatesAndNotifyError' + guid, error);
});
});
socket.on('autoUpdaterCheckForUpdates', async (guid) => {
// autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml');
const updateCheckResult = await autoUpdater.checkForUpdates();
electronSocket.emit('autoUpdaterCheckForUpdatesComplete' + guid, updateCheckResult);
autoUpdater.checkForUpdates().then((updateCheckResult) => {
electronSocket.emit('autoUpdaterCheckForUpdatesComplete' + guid, updateCheckResult);
}).catch((error) => {
electronSocket.emit('autoUpdaterCheckForUpdatesError' + guid, error);
});
});
socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => {

View File

@@ -1,20 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.browserViewMediateService = exports.browserViewApi = void 0;
const electron_1 = require("electron");
let browserViews = [];
const browserViews = (global['browserViews'] = global['browserViews'] || []);
let browserView, electronSocket;
module.exports = (socket) => {
const proxyToCredentialsMap = (global['proxyToCredentialsMap'] = global['proxyToCredentialsMap'] || []);
const browserViewApi = (socket) => {
electronSocket = socket;
socket.on('createBrowserView', (options) => {
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
options = { ...options, webPreferences: { nodeIntegration: true } };
options = { ...options, webPreferences: { nodeIntegration: true, contextIsolation: false } };
}
browserView = new electron_1.BrowserView(options);
browserView['id'] = browserViews.length + 1;
if (options.proxy) {
browserView.webContents.session.setProxy({ proxyRules: options.proxy });
}
if (options.proxy && options.proxyCredentials) {
proxyToCredentialsMap[options.proxy] = options.proxyCredentials;
}
browserViews.push(browserView);
electronSocket.emit('BrowserViewCreated', browserView.id);
});
socket.on('browserView-isDestroyed', (id) => {
const isDestroyed = getBrowserViewById(id).isDestroyed();
electronSocket.emit('browserView-isDestroyed-reply', isDestroyed);
electronSocket.emit('BrowserViewCreated', browserView['id']);
});
socket.on('browserView-getBounds', (id) => {
const bounds = getBrowserViewById(id).getBounds();
@@ -23,11 +29,6 @@ module.exports = (socket) => {
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);
});
@@ -43,13 +44,18 @@ module.exports = (socket) => {
}
return true;
}
function getBrowserViewById(id) {
for (let index = 0; index < browserViews.length; index++) {
const browserViewItem = browserViews[index];
if (browserViewItem.id === id) {
return browserViewItem;
}
};
exports.browserViewApi = browserViewApi;
const browserViewMediateService = (browserViewId) => {
return getBrowserViewById(browserViewId);
};
exports.browserViewMediateService = browserViewMediateService;
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

View File

@@ -1 +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;QACvC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,EAAE;YAChE,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,CAAC;SACv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AY,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE;YAC9B,OAAO,eAAe,CAAC;SAC1B;KACJ;AACL,CAAC"}

View File

@@ -1,25 +1,31 @@
import { Socket } from 'net';
import { BrowserView } from 'electron';
let browserViews: Electron.BrowserView[] = [];
const browserViews: BrowserView[] = (global['browserViews'] = global['browserViews'] || []) as BrowserView[];
let browserView: BrowserView, electronSocket;
const proxyToCredentialsMap: { [proxy: string]: string } = (global['proxyToCredentialsMap'] = global['proxyToCredentialsMap'] || []) as { [proxy: string]: string };
export = (socket: SocketIO.Socket) => {
const browserViewApi = (socket: Socket) => {
electronSocket = socket;
socket.on('createBrowserView', (options) => {
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
options = { ...options, webPreferences: { nodeIntegration: true } };
options = { ...options, webPreferences: { nodeIntegration: true, contextIsolation: false } };
}
browserView = new BrowserView(options);
browserView['id'] = browserViews.length + 1;
if (options.proxy) {
browserView.webContents.session.setProxy({proxyRules: options.proxy});
}
if (options.proxy && options.proxyCredentials) {
proxyToCredentialsMap[options.proxy] = options.proxyCredentials;
}
browserViews.push(browserView);
electronSocket.emit('BrowserViewCreated', browserView.id);
});
socket.on('browserView-isDestroyed', (id) => {
const isDestroyed = getBrowserViewById(id).isDestroyed();
electronSocket.emit('browserView-isDestroyed-reply', isDestroyed);
electronSocket.emit('BrowserViewCreated', browserView['id']);
});
socket.on('browserView-getBounds', (id) => {
@@ -32,12 +38,6 @@ export = (socket: SocketIO.Socket) => {
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);
});
@@ -56,13 +56,19 @@ export = (socket: SocketIO.Socket) => {
return true;
}
};
function getBrowserViewById(id: number) {
for (let index = 0; index < browserViews.length; index++) {
const browserViewItem = browserViews[index];
if (browserViewItem.id === id) {
return browserViewItem;
}
const browserViewMediateService = (browserViewId: number): BrowserView => {
return getBrowserViewById(browserViewId);
};
function getBrowserViewById(id: number) {
for (let index = 0; index < browserViews.length; index++) {
const browserViewItem = browserViews[index];
if (browserViewItem['id'] === id) {
return browserViewItem;
}
}
};
}
export { browserViewApi, browserViewMediateService };

View File

@@ -1,12 +1,25 @@
"use strict";
const electron_1 = require("electron");
const browserView_1 = require("./browserView");
const path = require('path');
const windows = [];
const windows = (global['browserWindows'] = global['browserWindows'] || []);
let readyToShowWindowsIds = [];
let window, lastOptions, electronSocket;
let mainWindowURL;
const proxyToCredentialsMap = (global['proxyToCredentialsMap'] = global['proxyToCredentialsMap'] || []);
module.exports = (socket, app) => {
electronSocket = socket;
app.on('login', (event, webContents, request, authInfo, callback) => {
if (authInfo.isProxy) {
let proxy = `${authInfo.host}:${authInfo.port}`;
if (proxy in proxyToCredentialsMap && proxyToCredentialsMap[proxy].split(':').length === 2) {
event.preventDefault();
let user = proxyToCredentialsMap[proxy].split(':')[0];
let pass = proxyToCredentialsMap[proxy].split(':')[1];
callback(user, pass);
}
}
});
socket.on('register-browserWindow-ready-to-show', (id) => {
if (readyToShowWindowsIds.includes(id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== id);
@@ -127,21 +140,6 @@ module.exports = (socket, app) => {
electronSocket.emit('browserWindow-app-command' + id, command);
});
});
socket.on('register-browserWindow-scroll-touch-begin', (id) => {
getWindowById(id).on('scroll-touch-begin', () => {
electronSocket.emit('browserWindow-scroll-touch-begin' + id);
});
});
socket.on('register-browserWindow-scroll-touch-end', (id) => {
getWindowById(id).on('scroll-touch-end', () => {
electronSocket.emit('browserWindow-scroll-touch-end' + id);
});
});
socket.on('register-browserWindow-scroll-touch-edge', (id) => {
getWindowById(id).on('scroll-touch-edge', () => {
electronSocket.emit('browserWindow-scroll-touch-edge' + id);
});
});
socket.on('register-browserWindow-swipe', (id) => {
getWindowById(id).on('swipe', (event, direction) => {
electronSocket.emit('browserWindow-swipe' + id, direction);
@@ -164,10 +162,10 @@ module.exports = (socket, app) => {
});
socket.on('createBrowserWindow', (options, loadUrl) => {
if (options.webPreferences && !('nodeIntegration' in options.webPreferences)) {
options = { ...options, webPreferences: { ...options.webPreferences, nodeIntegration: true } };
options = { ...options, webPreferences: { ...options.webPreferences, nodeIntegration: true, contextIsolation: false } };
}
else if (!options.webPreferences) {
options = { ...options, webPreferences: { nodeIntegration: true } };
options = { ...options, webPreferences: { nodeIntegration: true, contextIsolation: false } };
}
// we dont want to recreate the window when watch is ready.
if (app.commandLine.hasSwitch('watch') && app['mainWindowURL'] === loadUrl) {
@@ -182,6 +180,12 @@ module.exports = (socket, app) => {
else {
window = new electron_1.BrowserWindow(options);
}
if (options.proxy) {
window.webContents.session.setProxy({ proxyRules: options.proxy });
}
if (options.proxy && options.proxyCredentials) {
proxyToCredentialsMap[options.proxy] = options.proxyCredentials;
}
window.on('ready-to-show', () => {
if (readyToShowWindowsIds.includes(window.id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== window.id);
@@ -576,29 +580,13 @@ 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);
getWindowById(id).setBrowserView((0, browserView_1.browserViewMediateService)(browserViewId));
});
function getWindowById(id) {
for (let index = 0; index < windows.length; index++) {
const element = windows[index];
if (element.id == id) {
if (element.id === id) {
return element;
}
}

File diff suppressed because one or more lines are too long

View File

@@ -1,11 +1,28 @@
import { BrowserWindow, Menu, nativeImage, BrowserView } from 'electron';
import { Socket } from 'net';
import { BrowserWindow, Menu, nativeImage } from 'electron';
import { browserViewMediateService } from './browserView';
const path = require('path');
const windows: Electron.BrowserWindow[] = [];
const windows: Electron.BrowserWindow[] = (global['browserWindows'] = global['browserWindows'] || []) as Electron.BrowserWindow[];
let readyToShowWindowsIds: number[] = [];
let window, lastOptions, electronSocket;
let mainWindowURL;
export = (socket: SocketIO.Socket, app: Electron.App) => {
const proxyToCredentialsMap: { [proxy: string]: string } = (global['proxyToCredentialsMap'] = global['proxyToCredentialsMap'] || []) as { [proxy: string]: string };
export = (socket: Socket, app: Electron.App) => {
electronSocket = socket;
app.on('login', (event, webContents, request, authInfo, callback) => {
if (authInfo.isProxy) {
let proxy = `${authInfo.host}:${authInfo.port}`
if (proxy in proxyToCredentialsMap && proxyToCredentialsMap[proxy].split(':').length === 2) {
event.preventDefault()
let user = proxyToCredentialsMap[proxy].split(':')[0]
let pass = proxyToCredentialsMap[proxy].split(':')[1]
callback(user, pass)
}
}
})
socket.on('register-browserWindow-ready-to-show', (id) => {
if (readyToShowWindowsIds.includes(id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== id);
@@ -150,24 +167,6 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
});
});
socket.on('register-browserWindow-scroll-touch-begin', (id) => {
getWindowById(id).on('scroll-touch-begin', () => {
electronSocket.emit('browserWindow-scroll-touch-begin' + id);
});
});
socket.on('register-browserWindow-scroll-touch-end', (id) => {
getWindowById(id).on('scroll-touch-end', () => {
electronSocket.emit('browserWindow-scroll-touch-end' + id);
});
});
socket.on('register-browserWindow-scroll-touch-edge', (id) => {
getWindowById(id).on('scroll-touch-edge', () => {
electronSocket.emit('browserWindow-scroll-touch-edge' + id);
});
});
socket.on('register-browserWindow-swipe', (id) => {
getWindowById(id).on('swipe', (event, direction) => {
electronSocket.emit('browserWindow-swipe' + id, direction);
@@ -194,9 +193,9 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
socket.on('createBrowserWindow', (options, loadUrl) => {
if (options.webPreferences && !('nodeIntegration' in options.webPreferences)) {
options = { ...options, webPreferences: { ...options.webPreferences, nodeIntegration: true } };
options = { ...options, webPreferences: { ...options.webPreferences, nodeIntegration: true, contextIsolation: false } };
} else if (!options.webPreferences) {
options = { ...options, webPreferences: { nodeIntegration: true } };
options = { ...options, webPreferences: { nodeIntegration: true, contextIsolation: false } };
}
// we dont want to recreate the window when watch is ready.
@@ -212,6 +211,14 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
window = new BrowserWindow(options);
}
if (options.proxy) {
window.webContents.session.setProxy({proxyRules: options.proxy});
}
if (options.proxy && options.proxyCredentials) {
proxyToCredentialsMap[options.proxy] = options.proxyCredentials;
}
window.on('ready-to-show', () => {
if (readyToShowWindowsIds.includes(window.id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== window.id);
@@ -554,8 +561,8 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
});
socket.on('browserWindowGetNativeWindowHandle', (id) => {
const nativeWindowHandle = getWindowById(id).getNativeWindowHandle().readInt32LE(0).toString(16);
electronSocket.emit('browserWindow-getNativeWindowHandle-completed', nativeWindowHandle);
const nativeWindowHandle = getWindowById(id).getNativeWindowHandle().readInt32LE(0).toString(16);
electronSocket.emit('browserWindow-getNativeWindowHandle-completed', nativeWindowHandle);
});
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
@@ -745,37 +752,14 @@ 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);
getWindowById(id).setBrowserView(browserViewMediateService(browserViewId));
});
function getWindowById(id: number): Electron.BrowserWindow {
for (let index = 0; index < windows.length; index++) {
const element = windows[index];
if (element.id == id) {
if (element.id === id) {
return element;
}
}

View File

@@ -1 +1 @@
{"version":3,"file":"clipboard.js","sourceRoot":"","sources":["clipboard.ts"],"names":[],"mappings":";AAAA,uCAAkD;AAClD,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,oBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtC,cAAc,CAAC,IAAI,CAAC,8BAA8B,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,qBAAqB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QAC5C,oBAAS,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,oBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzC,cAAc,CAAC,IAAI,CAAC,8BAA8B,EAAE,OAAO,CAAC,CAAC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B,CAAC,EAAE,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;SAC1E;QAED,oBAAS,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}

View File

@@ -1,7 +1,8 @@
import { Socket } from 'net';
import { clipboard, nativeImage } from 'electron';
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('clipboard-readText', (type) => {
const text = clipboard.readText(type);

View File

@@ -1 +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"}
{"version":3,"file":"commandLine.js","sourceRoot":"","sources":["commandLine.ts"],"names":[],"mappings":";AACA,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,GAAiB,EAAE,EAAE;IAC3C,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"}

View File

@@ -1,6 +1,7 @@
import { Socket } from 'net';
let electronSocket;
export = (socket: SocketIO.Socket, app: Electron.App) => {
export = (socket: Socket, app: Electron.App) => {
electronSocket = socket;
socket.on('appCommandLineAppendSwitch', (the_switch: string, value: string) => {

View File

@@ -1 +1 @@
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["dialog.ts"],"names":[],"mappings":";AAAA,uCAAiD;AACjD,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAC/D,IAAI,IAAI,IAAI,aAAa,EAAE;YACvB,MAAM,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAEtD,MAAM,qBAAqB,GAAG,MAAM,iBAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC3E,cAAc,CAAC,IAAI,CAAC,wBAAwB,GAAG,IAAI,EAAE,CAAC,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;SACjI;aAAM;YACH,MAAM,EAAE,GAAG,IAAI,IAAI,OAAO,CAAC;YAC3B,MAAM,qBAAqB,GAAG,MAAM,iBAAM,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YAEzE,cAAc,CAAC,IAAI,CAAC,wBAAwB,GAAG,EAAE,EAAE,CAAC,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;SAC/H;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAC/D,MAAM,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACtD,MAAM,qBAAqB,GAAG,MAAM,iBAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE3E,cA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CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACtD,MAAM,qBAAqB,GAAG,MAAM,iBAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE3E,cAAc,CAAC,IAAI,CAAC,wBAAwB,GAAG,IAAI,EAAE,qBAAqB,CAAC,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"}

View File

@@ -1,7 +1,8 @@
import { Socket } from 'net';
import { BrowserWindow, dialog } from 'electron';
let electronSocket;
let electronSocket: Socket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('showMessageBox', async (browserWindow, options, guid) => {
if ('id' in browserWindow) {

View File

@@ -30,8 +30,14 @@ module.exports = (socket) => {
const isVisible = electron_1.app.dock.isVisible();
electronSocket.emit('dock-isVisible-completed', isVisible);
});
// TODO: Menu (macOS) still to be implemented
socket.on('dock-setMenu', (menu) => {
socket.on('dock-setMenu', (menuItems) => {
let menu = null;
if (menuItems) {
menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('dockMenuItemClicked', id);
});
}
electron_1.app.dock.setMenu(menu);
});
// TODO: Menu (macOS) still to be implemented
@@ -42,5 +48,15 @@ module.exports = (socket) => {
socket.on('dock-setIcon', (image) => {
electron_1.app.dock.setIcon(image);
});
function addMenuItemClickConnector(menuItems, callback) {
menuItems.forEach((item) => {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
if ('id' in item && item.id) {
item.click = () => { callback(item.id); };
}
});
}
};
//# sourceMappingURL=dock.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"dock.js","sourceRoot":"","sources":["dock.ts"],"names":[],"mappings":";AAAA,uCAA+B;AAC/B,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE;QAC9B,MAAM,EAAE,GAAG,cAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,cAAc,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE,EAAE;QAClC,cAAG,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,EAAE;QAC5C,cAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;QAChC,cAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,eAAe,EA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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"}

View File

@@ -1,8 +1,9 @@
import { app } from 'electron';
import { Socket } from 'net';
import { app, Menu } from 'electron';
let electronSocket;
export = (socket: SocketIO.Socket) => {
electronSocket = socket;
export = (socket: Socket) => {
electronSocket = socket;
socket.on('dock-bounce', (type) => {
const id = app.dock.bounce(type);
@@ -39,8 +40,17 @@ export = (socket: SocketIO.Socket) => {
electronSocket.emit('dock-isVisible-completed', isVisible);
});
// TODO: Menu (macOS) still to be implemented
socket.on('dock-setMenu', (menu) => {
socket.on('dock-setMenu', (menuItems) => {
let menu = null;
if (menuItems) {
menu = Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('dockMenuItemClicked', id);
});
}
app.dock.setMenu(menu);
});
@@ -53,4 +63,16 @@ export = (socket: SocketIO.Socket) => {
socket.on('dock-setIcon', (image) => {
app.dock.setIcon(image);
});
};
function addMenuItemClickConnector(menuItems, callback) {
menuItems.forEach((item) => {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
if ('id' in item && item.id) {
item.click = () => { callback(item.id); };
}
});
}
};

View File

@@ -1 +1 @@
{"version":3,"file":"globalShortcut.js","sourceRoot":"","sources":["globalShortcut.ts"],"names":[],"mappings":";AAAA,uCAA0C;AAC1C,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAA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AAC,6BAA6B,EAAE,CAAC,WAAW,EAAE,EAAE;QACrD,MAAM,YAAY,GAAG,yBAAc,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QAE9D,cAAc,CAAC,IAAI,CAAC,sCAAsC,EAAE,YAAY,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2BAA2B,EAAE,CAAC,WAAW,EAAE,EAAE;QACnD,yBAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QAC3C,IAAI;YACA,yBAAc,CAAC,aAAa,EAAE,CAAC;SAClC;QAAC,OAAO,KAAK,EAAE,GAAG;IACvB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}

View File

@@ -1,7 +1,8 @@
import { globalShortcut } from 'electron';
import { Socket } from 'net';
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('globalShortcut-register', (accelerator) => {
globalShortcut.register(accelerator, () => {

View File

@@ -32,5 +32,18 @@ module.exports = (socket) => {
window.webContents.send(channel, ...data);
}
});
socket.on('sendToIpcRendererBrowserView', (id, channel, ...data) => {
const browserViews = (global['browserViews'] = global['browserViews'] || []);
let view = null;
for (let i = 0; i < browserViews.length; i++) {
if (browserViews[i]['id'] === id) {
view = browserViews[i];
break;
}
}
if (view) {
view.webContents.send(channel, ...data);
}
});
};
//# sourceMappingURL=ipc.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"ipc.js","sourceRoot":"","sources":["ipc.ts"],"names":[],"mappings":";AAAA,uCAAkD;AAClD,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC,OAAO,EAAE,EAAE;QAC5C,kBAAO,CAA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,EAAE,EAAE;gBAC9B,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;gBACvB,MAAM;aACT;SACJ;QAED,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;SAC3C;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}

View File

@@ -1,7 +1,8 @@
import { ipcMain, BrowserWindow } from 'electron';
import { ipcMain, BrowserWindow, BrowserView } from 'electron';
import { Socket } from 'net';
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('registerIpcMainChannel', (channel) => {
ipcMain.on(channel, (event, args) => {
@@ -38,4 +39,19 @@ export = (socket: SocketIO.Socket) => {
window.webContents.send(channel, ...data);
}
});
socket.on('sendToIpcRendererBrowserView', (id, channel, ...data) => {
const browserViews: BrowserView[] = (global['browserViews'] = global['browserViews'] || []) as BrowserView[];
let view: BrowserView = null;
for (let i = 0; i < browserViews.length; i++) {
if (browserViews[i]['id'] === id) {
view = browserViews[i];
break;
}
}
if (view) {
view.webContents.send(channel, ...data);
}
});
};

View File

@@ -1,13 +1,13 @@
"use strict";
const electron_1 = require("electron");
const contextMenuItems = [];
const contextMenuItems = (global['contextMenuItems'] = global['contextMenuItems'] || []);
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('menu-setContextMenu', (browserWindowId, menuItems) => {
const menu = electron_1.Menu.buildFromTemplate(menuItems);
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, browserWindowId) => {
electronSocket.emit('contextMenuItemClicked', [id, browserWindowId]);
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, windowId) => {
electronSocket.emit('contextMenuItemClicked', [id, windowId]);
});
const index = contextMenuItems.findIndex(contextMenu => contextMenu.browserWindowId === browserWindowId);
const contextMenuItem = {

View File

@@ -1 +1 @@
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.ts"],"names":[],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AEH,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"}

View File

@@ -1,14 +1,15 @@
import { Socket } from 'net';
import { Menu, BrowserWindow } from 'electron';
const contextMenuItems = [];
const contextMenuItems = (global['contextMenuItems'] = global['contextMenuItems'] || []);
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('menu-setContextMenu', (browserWindowId, menuItems) => {
const menu = Menu.buildFromTemplate(menuItems);
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, browserWindowId) => {
electronSocket.emit('contextMenuItemClicked', [id, browserWindowId]);
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, windowId) => {
electronSocket.emit('contextMenuItemClicked', [id, windowId]);
});
const index = contextMenuItems.findIndex(contextMenu => contextMenu.browserWindowId === browserWindowId);

View File

@@ -1 +1 @@
{"version":3,"file":"nativeTheme.js","sourceRoot":"","sources":["nativeTheme.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QAC9C,MA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AAC,CAAC;AACP,CAAC,CAAC"}

View File

@@ -1,7 +1,8 @@
import { Socket } from 'net';
import { nativeTheme } from 'electron';
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('nativeTheme-shouldUseDarkColors', () => {
@@ -37,4 +38,4 @@ export = (socket: SocketIO.Socket) => {
electronSocket.emit('nativeTheme-updated' + id);
});
});
};
};

View File

@@ -1,6 +1,6 @@
"use strict";
const electron_1 = require("electron");
const notifications = [];
const notifications = (global['notifications'] = global['notifications'] || []);
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;

View File

@@ -1 +1 @@
{"version":3,"file":"notification.js","sourceRoot":"","sources":["notification.ts"],"names":[],"mappings":";AAAA,uCAAwC;AACxC,MAAM,aAAa,GAA4B,EAAE,CAAC;AAClD,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE;QACxC,MAAM,YAAY,GAAG,IAAI,uBAAY,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,IAAI,OAAO,CAAC,MAAM,EAAE;YAChB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;gBACzB,cAAc,CAAC,IAAI,CAAC,uBAAuB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC;SACN;QAED,IAAI,OAAO,CAAC,OAAO,EAAE;YACjB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBAC1B,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YACnE,CAAC,CAAC,CAAC;SACN;QAED,IAAI,OAA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C;YAC5E,CAAC,CAAC,CAAC;SACN;QAED,IAAI,OAAO,CAAC,QAAQ,EAAE;YAClB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBACvC,cAAc,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAC9E,CAAC,CAAC,CAAC;SACN;QAED,IAAI,SAAS,EAAE;YACX,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACpC;QAED,YAAY,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACtC,MAAM,WAAW,GAAG,uBAAY,CAAC,WAAW,CAAC;QAC7C,cAAc,CAAC,IAAI,CAAC,iCAAiC,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}

View File

@@ -1,8 +1,9 @@
import { Socket } from 'net';
import { Notification } from 'electron';
const notifications: Electron.Notification[] = [];
const notifications: Electron.Notification[] = (global['notifications'] = global['notifications'] || []) as Electron.Notification[];
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('createNotification', (options) => {
const notification = new Notification(options);

View File

@@ -1 +1 @@
{"version":3,"file":"powerMonitor.js","sourceRoot":"","sources":["powerMonitor.ts"],"names":[],"mappings":";AAAA,uCAAwC;AACxC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACtC,uBAAY,CAAC,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE;YAChC,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC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AU,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACrC,uBAAY,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;YAC/B,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACnC,uBAAY,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE;YAC7B,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}

View File

@@ -1,7 +1,8 @@
import { Socket } from 'net';
import { powerMonitor } from 'electron';
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('register-pm-lock-screen', () => {
powerMonitor.on('lock-screen', () => {

View File

@@ -1 +1 @@
{"version":3,"file":"screen.js","sourceRoot":"","sources":["screen.ts"],"names":[],"mappings":";AAAA,uCAAkC;AAClC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,+BAA+B,EAAE,CAAC,EAAE,EAAE,EAAE;QAC9C,iBAAM,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC1C,cAAc,CAAC,IAAI,CAAC,4BAA4B,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,iCAAiC,EAAE,CAAC,EAAE,EAAE,EAAE;QAChD,iBAAM,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC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,CAAC,KAAK,CAAC,CAAC;QACrD,cAAc,CAAC,IAAI,CAAC,wCAAwC,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2BAA2B,EAAE,CAAC,SAAS,EAAE,EAAE;QACjD,MAAM,OAAO,GAAG,iBAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACrD,cAAc,CAAC,IAAI,CAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}

View File

@@ -1,7 +1,8 @@
import { Socket } from 'net';
import { screen } from 'electron';
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('register-screen-display-added', (id) => {
screen.on('display-added', (event, display) => {

View File

@@ -12,7 +12,7 @@ module.exports = (socket) => {
electronSocket.emit('shell-openPathCompleted', errorMessage);
});
socket.on('shell-openExternal', async (url, options) => {
let result = "";
let result = '';
if (options) {
await electron_1.shell.openExternal(url, options).catch(e => {
result = e.message;
@@ -25,9 +25,16 @@ module.exports = (socket) => {
}
electronSocket.emit('shell-openExternalCompleted', result);
});
socket.on('shell-moveItemToTrash', (fullPath, deleteOnFail) => {
const success = electron_1.shell.moveItemToTrash(fullPath, deleteOnFail);
electronSocket.emit('shell-moveItemToTrashCompleted', success);
socket.on('shell-trashItem', async (fullPath, deleteOnFail) => {
let success = false;
try {
await electron_1.shell.trashItem(fullPath);
success = true;
}
catch (error) {
success = false;
}
electronSocket.emit('shell-trashItem-completed', success);
});
socket.on('shell-beep', () => {
electron_1.shell.beep();

View File

@@ -1 +1 @@
{"version":3,"file":"shell.js","sourceRoot":"","sources":["shell.ts"],"names":[],"mappings":";AAAA,uCAAiC;AACjC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAuB,EAAE,EAAE;IACjC,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,wBAA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AAO,CAAC,CAAC;QAE1E,cAAc,CAAC,IAAI,CAAC,kCAAkC,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC,YAAY,EAAE,EAAE;QACjD,MAAM,eAAe,GAAG,gBAAK,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QAE7D,cAAc,CAAC,IAAI,CAAC,iCAAiC,EAAE,eAAe,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}

View File

@@ -1,7 +1,8 @@
import { Socket } from 'net';
import { shell } from 'electron';
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('shell-showItemInFolder', (fullPath) => {
shell.showItemInFolder(fullPath);
@@ -16,26 +17,32 @@ export = (socket: SocketIO.Socket) => {
});
socket.on('shell-openExternal', async (url, options) => {
let result = "";
let result = '';
if (options) {
await shell.openExternal(url, options).catch(e => {
result = e.message;
});
}
else {
});
} else {
await shell.openExternal(url).catch((e) => {
result = e.message;
result = e.message;
});
}
electronSocket.emit('shell-openExternalCompleted', result);
});
socket.on('shell-moveItemToTrash', (fullPath, deleteOnFail) => {
const success = shell.moveItemToTrash(fullPath, deleteOnFail);
socket.on('shell-trashItem', async (fullPath, deleteOnFail) => {
let success = false;
electronSocket.emit('shell-moveItemToTrashCompleted', success);
try {
await shell.trashItem(fullPath);
success = true;
} catch (error) {
success = false;
}
electronSocket.emit('shell-trashItem-completed', success);
});
socket.on('shell-beep', () => {
@@ -53,4 +60,4 @@ export = (socket: SocketIO.Socket) => {
electronSocket.emit('shell-readShortcutLinkCompleted', shortcutDetails);
});
};
};

View File

@@ -1,97 +1,123 @@
"use strict";
const electron_1 = require("electron");
let tray;
let tray = (global['$tray'] = global['tray'] || { value: null });
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('register-tray-click', (id) => {
if (tray) {
tray.on('click', (event, bounds) => {
if (tray.value) {
tray.value.on('click', (event, bounds) => {
electronSocket.emit('tray-click-event' + id, [event.__proto__, bounds]);
});
}
});
socket.on('register-tray-right-click', (id) => {
if (tray) {
tray.on('right-click', (event, bounds) => {
if (tray.value) {
tray.value.on('right-click', (event, bounds) => {
electronSocket.emit('tray-right-click-event' + id, [event.__proto__, bounds]);
});
}
});
socket.on('register-tray-double-click', (id) => {
if (tray) {
tray.on('double-click', (event, bounds) => {
if (tray.value) {
tray.value.on('double-click', (event, bounds) => {
electronSocket.emit('tray-double-click-event' + id, [event.__proto__, bounds]);
});
}
});
socket.on('register-tray-balloon-show', (id) => {
if (tray) {
tray.on('balloon-show', () => {
if (tray.value) {
tray.value.on('balloon-show', () => {
electronSocket.emit('tray-balloon-show-event' + id);
});
}
});
socket.on('register-tray-balloon-click', (id) => {
if (tray) {
tray.on('balloon-click', () => {
if (tray.value) {
tray.value.on('balloon-click', () => {
electronSocket.emit('tray-balloon-click-event' + id);
});
}
});
socket.on('register-tray-balloon-closed', (id) => {
if (tray) {
tray.on('balloon-closed', () => {
if (tray.value) {
tray.value.on('balloon-closed', () => {
electronSocket.emit('tray-balloon-closed-event' + id);
});
}
});
socket.on('create-tray', (image, menuItems) => {
const menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('trayMenuItemClicked', id);
});
const trayIcon = electron_1.nativeImage.createFromPath(image);
tray = new electron_1.Tray(trayIcon);
tray.setContextMenu(menu);
tray.value = new electron_1.Tray(trayIcon);
if (menuItems) {
const menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('trayMenuItemClicked', id);
});
tray.value.setContextMenu(menu);
}
});
socket.on('tray-destroy', () => {
if (tray) {
tray.destroy();
if (tray.value) {
tray.value.destroy();
}
});
socket.on('tray-setImage', (image) => {
if (tray) {
tray.setImage(image);
if (tray.value) {
tray.value.setImage(image);
}
});
socket.on('tray-setPressedImage', (image) => {
if (tray) {
if (tray.value) {
const img = electron_1.nativeImage.createFromPath(image);
tray.setPressedImage(img);
tray.value.setPressedImage(img);
}
});
socket.on('tray-setToolTip', (toolTip) => {
if (tray) {
tray.setToolTip(toolTip);
if (tray.value) {
tray.value.setToolTip(toolTip);
}
});
socket.on('tray-setTitle', (title) => {
if (tray) {
tray.setTitle(title);
if (tray.value) {
tray.value.setTitle(title);
}
});
socket.on('tray-displayBalloon', (options) => {
if (tray) {
tray.displayBalloon(options);
if (tray.value) {
tray.value.displayBalloon(options);
}
});
socket.on('tray-isDestroyed', () => {
if (tray) {
const isDestroyed = tray.isDestroyed();
if (tray.value) {
const isDestroyed = tray.value.isDestroyed();
electronSocket.emit('tray-isDestroyedCompleted', isDestroyed);
}
});
socket.on('register-tray-on-event', (eventName, listenerName) => {
if (tray.value) {
tray.value.on(eventName, (...args) => {
if (args.length > 1) {
electronSocket.emit(listenerName, args[1]);
}
else {
electronSocket.emit(listenerName);
}
});
}
});
socket.on('register-tray-once-event', (eventName, listenerName) => {
if (tray.value) {
tray.value.once(eventName, (...args) => {
if (args.length > 1) {
electronSocket.emit(listenerName, args[1]);
}
else {
electronSocket.emit(listenerName);
}
});
}
});
function addMenuItemClickConnector(menuItems, callback) {
menuItems.forEach((item) => {
if (item.submenu && item.submenu.items.length > 0) {

View File

@@ -1 +1 @@
{"version":3,"file":"tray.js","sourceRoot":"","sources":["tray.ts"],"names":[],"mappings":";AAAA,uCAAmD;AACnD,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,EAAE,MAAM,EAAE,EAAE;gBAC/B,cAAc,CAAC,IAAI,CAAC,kBAA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,0BAA0B,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE;QAC9D,IAAI,IAAI,CAAC,KAAK,EAAC;YACX,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE;gBACnC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;oBACjB,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC9C;qBAAM;oBACH,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBACrC;YACL,CAAC,CAAC,CAAC;SACN;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"}

View File

@@ -1,114 +1,141 @@
import { Socket } from 'net';
import { Menu, Tray, nativeImage } from 'electron';
let tray: Electron.Tray;
let tray: { value: Electron.Tray } = (global['$tray'] = global['tray'] || { value: null });
let electronSocket;
export = (socket: SocketIO.Socket) => {
export = (socket: Socket) => {
electronSocket = socket;
socket.on('register-tray-click', (id) => {
if (tray) {
tray.on('click', (event, bounds) => {
if (tray.value) {
tray.value.on('click', (event, bounds) => {
electronSocket.emit('tray-click-event' + id, [(<any>event).__proto__, bounds]);
});
}
});
socket.on('register-tray-right-click', (id) => {
if (tray) {
tray.on('right-click', (event, bounds) => {
if (tray.value) {
tray.value.on('right-click', (event, bounds) => {
electronSocket.emit('tray-right-click-event' + id, [(<any>event).__proto__, bounds]);
});
}
});
socket.on('register-tray-double-click', (id) => {
if (tray) {
tray.on('double-click', (event, bounds) => {
if (tray.value) {
tray.value.on('double-click', (event, bounds) => {
electronSocket.emit('tray-double-click-event' + id, [(<any>event).__proto__, bounds]);
});
}
});
socket.on('register-tray-balloon-show', (id) => {
if (tray) {
tray.on('balloon-show', () => {
if (tray.value) {
tray.value.on('balloon-show', () => {
electronSocket.emit('tray-balloon-show-event' + id);
});
}
});
socket.on('register-tray-balloon-click', (id) => {
if (tray) {
tray.on('balloon-click', () => {
if (tray.value) {
tray.value.on('balloon-click', () => {
electronSocket.emit('tray-balloon-click-event' + id);
});
}
});
socket.on('register-tray-balloon-closed', (id) => {
if (tray) {
tray.on('balloon-closed', () => {
if (tray.value) {
tray.value.on('balloon-closed', () => {
electronSocket.emit('tray-balloon-closed-event' + id);
});
}
});
socket.on('create-tray', (image, menuItems) => {
const menu = Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('trayMenuItemClicked', id);
});
const trayIcon = nativeImage.createFromPath(image);
tray = new Tray(trayIcon);
tray.setContextMenu(menu);
tray.value = new Tray(trayIcon);
if (menuItems) {
const menu = Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('trayMenuItemClicked', id);
});
tray.value.setContextMenu(menu);
}
});
socket.on('tray-destroy', () => {
if (tray) {
tray.destroy();
if (tray.value) {
tray.value.destroy();
}
});
socket.on('tray-setImage', (image) => {
if (tray) {
tray.setImage(image);
if (tray.value) {
tray.value.setImage(image);
}
});
socket.on('tray-setPressedImage', (image) => {
if (tray) {
if (tray.value) {
const img = nativeImage.createFromPath(image);
tray.setPressedImage(img);
tray.value.setPressedImage(img);
}
});
socket.on('tray-setToolTip', (toolTip) => {
if (tray) {
tray.setToolTip(toolTip);
if (tray.value) {
tray.value.setToolTip(toolTip);
}
});
socket.on('tray-setTitle', (title) => {
if (tray) {
tray.setTitle(title);
if (tray.value) {
tray.value.setTitle(title);
}
});
socket.on('tray-displayBalloon', (options) => {
if (tray) {
tray.displayBalloon(options);
if (tray.value) {
tray.value.displayBalloon(options);
}
});
socket.on('tray-isDestroyed', () => {
if (tray) {
const isDestroyed = tray.isDestroyed();
if (tray.value) {
const isDestroyed = tray.value.isDestroyed();
electronSocket.emit('tray-isDestroyedCompleted', isDestroyed);
}
});
socket.on('register-tray-on-event', (eventName, listenerName) => {
if (tray.value){
tray.value.on(eventName, (...args) => {
if (args.length > 1) {
electronSocket.emit(listenerName, args[1]);
} else {
electronSocket.emit(listenerName);
}
});
}
});
socket.on('register-tray-once-event', (eventName, listenerName) => {
if (tray.value){
tray.value.once(eventName, (...args) => {
if (args.length > 1) {
electronSocket.emit(listenerName, args[1]);
} else {
electronSocket.emit(listenerName);
}
});
}
});
function addMenuItemClickConnector(menuItems, callback) {
menuItems.forEach((item) => {
if (item.submenu && item.submenu.items.length > 0) {

View File

@@ -1,5 +1,6 @@
"use strict";
const electron_1 = require("electron");
const browserView_1 = require("./browserView");
const fs = require('fs');
let electronSocket;
module.exports = (socket) => {
@@ -18,6 +19,15 @@ module.exports = (socket) => {
electronSocket.emit('webContents-didFinishLoad' + id);
});
});
socket.on('register-webContents-input-event', (id) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.removeAllListeners('input-event');
browserWindow.webContents.on('input-event', (_, eventArgs) => {
if (eventArgs.type !== 'char') {
electronSocket.emit('webContents-input-event' + id, eventArgs);
}
});
});
socket.on('webContentsOpenDevTools', (id, options) => {
if (options) {
getWindowById(id).webContents.openDevTools(options);
@@ -27,7 +37,7 @@ module.exports = (socket) => {
}
});
socket.on('webContents-getPrinters', async (id) => {
const printers = await getWindowById(id).webContents.getPrinters();
const printers = await getWindowById(id).webContents.getPrintersAsync();
electronSocket.emit('webContents-getPrinters-completed', printers);
});
socket.on('webContents-print', async (id, options = {}) => {
@@ -53,9 +63,9 @@ module.exports = (socket) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.session.allowNTLMCredentialsForDomains(domains);
});
socket.on('webContents-session-clearAuthCache', async (id, options, guid) => {
socket.on('webContents-session-clearAuthCache', async (id, guid) => {
const browserWindow = getWindowById(id);
await browserWindow.webContents.session.clearAuthCache(options);
await browserWindow.webContents.session.clearAuthCache();
electronSocket.emit('webContents-session-clearAuthCache-completed' + guid);
});
socket.on('webContents-session-clearCache', async (id, guid) => {
@@ -165,16 +175,58 @@ module.exports = (socket) => {
});
socket.on('webContents-loadURL', (id, url, options) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.loadURL(url, options).then(() => {
browserWindow.webContents
.loadURL(url, options)
.then(() => {
electronSocket.emit('webContents-loadURL-complete' + id);
}).catch((error) => {
})
.catch((error) => {
console.error(error);
electronSocket.emit('webContents-loadURL-error' + id, error);
});
});
socket.on('webContents-insertCSS', (id, isBrowserWindow, path) => {
if (isBrowserWindow) {
const browserWindow = getWindowById(id);
if (browserWindow) {
browserWindow.webContents.insertCSS(fs.readFileSync(path, 'utf8'));
}
}
else {
const browserViews = (global['browserViews'] = global['browserViews'] || []);
let view = null;
for (let i = 0; i < browserViews.length; i++) {
if (browserViews[i]['id'] + 1000 === id) {
view = browserViews[i];
break;
}
}
if (view) {
view.webContents.insertCSS(fs.readFileSync(path, 'utf8'));
}
}
});
socket.on('webContents-session-getAllExtensions', (id) => {
const browserWindow = getWindowById(id);
const extensionsList = browserWindow.webContents.session.getAllExtensions();
const chromeExtensionInfo = [];
Object.keys(extensionsList).forEach((key) => {
chromeExtensionInfo.push(extensionsList[key]);
});
electronSocket.emit('webContents-session-getAllExtensions-completed', chromeExtensionInfo);
});
socket.on('webContents-session-removeExtension', (id, name) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.session.removeExtension(name);
});
socket.on('webContents-session-loadExtension', async (id, path, allowFileAccess = false) => {
const browserWindow = getWindowById(id);
const extension = await browserWindow.webContents.session.loadExtension(path, { allowFileAccess: allowFileAccess });
electronSocket.emit('webContents-session-loadExtension-completed', extension);
});
function getWindowById(id) {
if (id >= 1000) {
return electron_1.BrowserView.fromId(id - 1000);
return (0, browserView_1.browserViewMediateService)(id - 1000);
}
return electron_1.BrowserWindow.fromId(id);
}

Some files were not shown because too many files have changed in this diff Show More