Compare commits

...

129 Commits

Author SHA1 Message Date
Florian Rappl
b6e496b2c6 Merge pull request #1082 from ElectronNET/dependabot/npm_and_yarn/src/ElectronNET.WebApp/ElectronHostHook/js-yaml-4.3.0
Bump js-yaml from 4.1.1 to 4.3.0 in /src/ElectronNET.WebApp/ElectronHostHook
2026-07-09 15:33:25 +02:00
Florian Rappl
5974cb9e43 Merge branch 'develop' into dependabot/npm_and_yarn/src/ElectronNET.WebApp/ElectronHostHook/js-yaml-4.3.0 2026-07-09 10:42:03 +02:00
dependabot[bot]
d4d4e9dddd Bump js-yaml in /src/ElectronNET.WebApp/ElectronHostHook
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.1.1 to 4.3.0.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.1.1...4.3.0)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.3.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-08 23:02:16 +00:00
Florian Rappl
3b5f21c724 Merge pull request #1081 from epsitec-sa/bug/default-runtime
chore: use default sdk runtime identifier
2026-07-06 15:17:02 +02:00
Samuel Nussbaum
5aebe807c3 change to less brittle solution 2026-07-06 11:02:48 +02:00
Samuel Nussbaum
bdee008cc8 use default sdk runtime identifier 2026-07-06 10:44:05 +02:00
Florian Rappl
7fc5c9b611 Merge pull request #1080 from epsitec-sa/bug/#1058
fix(shore): bloated asar and corrupted packaged directory
2026-07-05 11:08:43 +02:00
Samuel Nussbaum
86e5d74c03 dump to latest version 2026-07-03 15:24:49 +02:00
Samuel Nussbaum
e79b029e16 Fix scoped css naming issue 2026-07-03 15:09:49 +02:00
Samuel Nussbaum
5bdf6230b9 fix examples build and publish 2026-07-03 15:08:57 +02:00
Samuel Nussbaum
8c2382a05c Split packaging to avoid duplication in .asar archive 2026-07-03 11:28:52 +02:00
Florian Rappl
10b1b686cb Merge pull request #1079 from ElectronNET/dependabot/npm_and_yarn/src/ElectronNET.WebApp/ElectronHostHook/js-yaml-4.2.0
Bump js-yaml from 4.1.1 to 4.2.0 in /src/ElectronNET.WebApp/ElectronHostHook
2026-06-24 14:51:00 +02:00
Florian Rappl
d7d2521d0c Merge pull request #1078 from ElectronNET/dependabot/npm_and_yarn/src/ElectronNET.Host/multi-5f1280885e
Bump ws, engine.io and socket.io-adapter in /src/ElectronNET.Host
2026-06-24 14:50:35 +02:00
Florian Rappl
392419e5a7 Merge branch 'develop' into dependabot/npm_and_yarn/src/ElectronNET.Host/multi-5f1280885e 2026-06-24 14:50:10 +02:00
dependabot[bot]
f92f07a378 Bump js-yaml in /src/ElectronNET.WebApp/ElectronHostHook
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.1.1 to 4.2.0.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.1.1...4.2.0)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.2.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-24 07:11:36 +00:00
dependabot[bot]
9b045cbf01 Bump ws, engine.io and socket.io-adapter in /src/ElectronNET.Host
Bumps [ws](https://github.com/websockets/ws), [engine.io](https://github.com/socketio/socket.io) and [socket.io-adapter](https://github.com/socketio/socket.io). These dependencies needed to be updated together.

Updates `ws` from 8.20.1 to 8.21.0
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.20.1...8.21.0)

Updates `engine.io` from 6.6.8 to 6.6.9
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/engine.io@6.6.8...engine.io@6.6.9)

Updates `socket.io-adapter` from 2.5.7 to 2.5.8
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/socket.io-adapter@2.5.7...socket.io-adapter@2.5.8)

---
updated-dependencies:
- dependency-name: ws
  dependency-version: 8.21.0
  dependency-type: indirect
- dependency-name: engine.io
  dependency-version: 6.6.9
  dependency-type: indirect
- dependency-name: socket.io-adapter
  dependency-version: 2.5.8
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-24 03:30:33 +00:00
Florian Rappl
94ff3c1c4d Updated token usage 2026-06-22 23:23:44 +02:00
Florian Rappl
773937448d Updated version 2026-06-22 23:23:34 +02:00
Florian Rappl
b094051dcb Merge pull request #1077 from AeonSake/1076-add-overloads-for-useelectron
Add Overloads for `UseElectron`
2026-06-21 21:46:56 +02:00
Aeon
3a10e7e98d Add missing null-check 2026-06-20 01:38:58 +02:00
Aeon
056661028b Remove unused property 2026-06-20 01:26:55 +02:00
Aeon
27a8c69a9a Add missing extension method overloads 2026-06-20 01:26:25 +02:00
Aeon
8e900655b9 Replace static property with resolver service 2026-06-20 01:26:00 +02:00
Aeon
066efa80e2 Add service for resolving on-app-ready callback 2026-06-20 01:24:30 +02:00
Florian Rappl
18944fe222 Release 0.5.1 (#1074)
* Bump ws, engine.io and socket.io-adapter

Bumps [ws](https://github.com/websockets/ws), [engine.io](https://github.com/socketio/socket.io) and [socket.io-adapter](https://github.com/socketio/socket.io). These dependencies needed to be updated together.

Updates `ws` from 8.17.1 to 8.20.1
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.17.1...8.20.1)

Updates `engine.io` from 6.6.4 to 6.6.8
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/engine.io@6.6.4...engine.io@6.6.8)

Updates `socket.io-adapter` from 2.5.5 to 2.5.7
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/socket.io-adapter@2.5.5...socket.io-adapter@2.5.7)

---
updated-dependencies:
- dependency-name: ws
  dependency-version: 8.20.1
  dependency-type: indirect
- dependency-name: engine.io
  dependency-version: 6.6.8
  dependency-type: indirect
- dependency-name: socket.io-adapter
  dependency-version: 2.5.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump tmp and exceljs in /src/ElectronNET.WebApp/ElectronHostHook

Bumps [tmp](https://github.com/raszi/node-tmp) to 0.2.7 and updates ancestor dependency [exceljs](https://github.com/exceljs/exceljs). These dependencies need to be updated together.


Updates `tmp` from 0.1.0 to 0.2.7
- [Changelog](https://github.com/raszi/node-tmp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/raszi/node-tmp/compare/v0.1.0...v0.2.7)

Updates `exceljs` from 1.15.0 to 4.4.0
- [Release notes](https://github.com/exceljs/exceljs/releases)
- [Commits](https://github.com/exceljs/exceljs/compare/v1.15.0...v4.4.0)

---
updated-dependencies:
- dependency-name: tmp
  dependency-version: 0.2.7
  dependency-type: indirect
- dependency-name: exceljs
  dependency-version: 4.4.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump ws, engine.io and socket.io-adapter in /src/ElectronNET.Host

Bumps [ws](https://github.com/websockets/ws), [engine.io](https://github.com/socketio/socket.io) and [socket.io-adapter](https://github.com/socketio/socket.io). These dependencies needed to be updated together.

Updates `ws` from 8.18.3 to 8.20.1
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.18.3...8.20.1)

Updates `engine.io` from 6.6.5 to 6.6.8
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/engine.io@6.6.5...engine.io@6.6.8)

Updates `socket.io-adapter` from 2.5.6 to 2.5.7
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/socket.io-adapter@2.5.6...socket.io-adapter@2.5.7)

---
updated-dependencies:
- dependency-name: ws
  dependency-version: 8.20.1
  dependency-type: indirect
- dependency-name: engine.io
  dependency-version: 6.6.8
  dependency-type: indirect
- dependency-name: socket.io-adapter
  dependency-version: 2.5.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump ws, engine.io and socket.io-adapter

Bumps [ws](https://github.com/websockets/ws), [engine.io](https://github.com/socketio/socket.io) and [socket.io-adapter](https://github.com/socketio/socket.io). These dependencies needed to be updated together.

Updates `ws` from 8.18.3 to 8.20.1
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.18.3...8.20.1)

Updates `engine.io` from 6.6.5 to 6.6.8
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/engine.io@6.6.5...engine.io@6.6.8)

Updates `socket.io-adapter` from 2.5.6 to 2.5.7
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/socket.io-adapter@2.5.6...socket.io-adapter@2.5.7)

---
updated-dependencies:
- dependency-name: ws
  dependency-version: 8.20.1
  dependency-type: indirect
- dependency-name: engine.io
  dependency-version: 6.6.8
  dependency-type: indirect
- dependency-name: socket.io-adapter
  dependency-version: 2.5.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Improved argument forwarding

* Added support for Electron 42+

* Removed wrongly placed line

* Use path directly

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-08 21:28:22 +02:00
Florian Rappl
0e83af032c Merge branch 'develop' of https://github.com/ElectronNET/Electron.NET into develop 2026-06-07 14:48:15 +02:00
Florian Rappl
1ec84cfef0 Use path directly 2026-06-07 14:48:07 +02:00
Florian Rappl
1620c50627 Merge pull request #1071 from ElectronNET/dependabot/npm_and_yarn/src/ElectronNET.WebApp/ElectronHostHook/multi-8c9a216550
Bump ws, engine.io and socket.io-adapter in /src/ElectronNET.WebApp/ElectronHostHook
2026-06-07 13:44:13 +02:00
Florian Rappl
295b250e58 Merge pull request #1070 from ElectronNET/dependabot/npm_and_yarn/src/ElectronNET.Host/multi-8c9a216550
Bump ws, engine.io and socket.io-adapter in /src/ElectronNET.Host
2026-06-07 13:44:04 +02:00
Florian Rappl
644628c803 Merge pull request #1069 from ElectronNET/dependabot/npm_and_yarn/src/ElectronNET.WebApp/ElectronHostHook/multi-19724e71a7
Bump tmp and exceljs in /src/ElectronNET.WebApp/ElectronHostHook
2026-06-07 13:43:45 +02:00
Florian Rappl
a18944d4a4 Removed wrongly placed line 2026-06-07 13:41:21 +02:00
Florian Rappl
b5858a697a Added support for Electron 42+ 2026-06-07 13:22:25 +02:00
Florian Rappl
58b9ad0125 Improved argument forwarding 2026-06-06 21:10:19 +02:00
dependabot[bot]
e44927a655 Bump ws, engine.io and socket.io-adapter
Bumps [ws](https://github.com/websockets/ws), [engine.io](https://github.com/socketio/socket.io) and [socket.io-adapter](https://github.com/socketio/socket.io). These dependencies needed to be updated together.

Updates `ws` from 8.18.3 to 8.20.1
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.18.3...8.20.1)

Updates `engine.io` from 6.6.5 to 6.6.8
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/engine.io@6.6.5...engine.io@6.6.8)

Updates `socket.io-adapter` from 2.5.6 to 2.5.7
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/socket.io-adapter@2.5.6...socket.io-adapter@2.5.7)

---
updated-dependencies:
- dependency-name: ws
  dependency-version: 8.20.1
  dependency-type: indirect
- dependency-name: engine.io
  dependency-version: 6.6.8
  dependency-type: indirect
- dependency-name: socket.io-adapter
  dependency-version: 2.5.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-29 21:29:26 +00:00
dependabot[bot]
ed9a24bb5e Bump ws, engine.io and socket.io-adapter in /src/ElectronNET.Host
Bumps [ws](https://github.com/websockets/ws), [engine.io](https://github.com/socketio/socket.io) and [socket.io-adapter](https://github.com/socketio/socket.io). These dependencies needed to be updated together.

Updates `ws` from 8.18.3 to 8.20.1
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.18.3...8.20.1)

Updates `engine.io` from 6.6.5 to 6.6.8
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/engine.io@6.6.5...engine.io@6.6.8)

Updates `socket.io-adapter` from 2.5.6 to 2.5.7
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/socket.io-adapter@2.5.6...socket.io-adapter@2.5.7)

---
updated-dependencies:
- dependency-name: ws
  dependency-version: 8.20.1
  dependency-type: indirect
- dependency-name: engine.io
  dependency-version: 6.6.8
  dependency-type: indirect
- dependency-name: socket.io-adapter
  dependency-version: 2.5.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-28 03:59:46 +00:00
dependabot[bot]
94df47efa6 Bump tmp and exceljs in /src/ElectronNET.WebApp/ElectronHostHook
Bumps [tmp](https://github.com/raszi/node-tmp) to 0.2.7 and updates ancestor dependency [exceljs](https://github.com/exceljs/exceljs). These dependencies need to be updated together.


Updates `tmp` from 0.1.0 to 0.2.7
- [Changelog](https://github.com/raszi/node-tmp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/raszi/node-tmp/compare/v0.1.0...v0.2.7)

Updates `exceljs` from 1.15.0 to 4.4.0
- [Release notes](https://github.com/exceljs/exceljs/releases)
- [Commits](https://github.com/exceljs/exceljs/compare/v1.15.0...v4.4.0)

---
updated-dependencies:
- dependency-name: tmp
  dependency-version: 0.2.7
  dependency-type: indirect
- dependency-name: exceljs
  dependency-version: 4.4.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-28 00:35:30 +00:00
Florian Rappl
d9f3da87a8 Merge pull request #1068 from ElectronNET/dependabot/npm_and_yarn/src/ElectronNET.Host/ElectronHostHook/multi-8c9a216550
Bump ws, engine.io and socket.io-adapter in /src/ElectronNET.Host/ElectronHostHook
2026-05-25 22:22:22 +02:00
dependabot[bot]
a33d76ae2f Bump ws, engine.io and socket.io-adapter
Bumps [ws](https://github.com/websockets/ws), [engine.io](https://github.com/socketio/socket.io) and [socket.io-adapter](https://github.com/socketio/socket.io). These dependencies needed to be updated together.

Updates `ws` from 8.17.1 to 8.20.1
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.17.1...8.20.1)

Updates `engine.io` from 6.6.4 to 6.6.8
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/engine.io@6.6.4...engine.io@6.6.8)

Updates `socket.io-adapter` from 2.5.5 to 2.5.7
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/socket.io-adapter@2.5.5...socket.io-adapter@2.5.7)

---
updated-dependencies:
- dependency-name: ws
  dependency-version: 8.20.1
  dependency-type: indirect
- dependency-name: engine.io
  dependency-version: 6.6.8
  dependency-type: indirect
- dependency-name: socket.io-adapter
  dependency-version: 2.5.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-25 20:11:16 +00:00
Florian Rappl
15d6a23016 Merge pull request #1067 from ElectronNET/develop
Release 0.5.0
2026-05-25 22:10:07 +02:00
Florian Rappl
c76ce9702d Merge pull request #1066 from ElectronNET/feature/auth-sample-docs
Added Auth Sample Docs
2026-05-25 21:56:35 +02:00
Florian Rappl
279a823eb7 Improved demo and updated docs 2026-05-25 21:44:07 +02:00
Florian Rappl
fdab81a3a6 Merge branch 'develop' of https://github.com/ElectronNET/Electron.NET into feature/auth-sample-docs 2026-05-25 21:27:52 +02:00
Florian Rappl
558e582789 Updated available lists 2026-05-25 21:18:00 +02:00
Florian Rappl
c4251955d9 Updated changelog 2026-05-25 20:56:21 +02:00
Florian Rappl
af5e70c000 Fixed missing namespace reference 2026-05-25 20:40:18 +02:00
Florian Rappl
fee3806953 Removed flag 2026-05-25 20:37:42 +02:00
Florian Rappl
979b25ffe7 Exclude file-system based transfer from #1038 (#1064) 2026-05-10 19:09:51 +02:00
Florian Rappl
07be82cca6 WIP 2026-05-10 18:21:30 +02:00
Gregor Biswanger
fe939e0fda ci: stop hanging PR workflows and remove duplicate runs (#1063)
- Build and Publish now only triggers on push to main/develop (was: every push), so feature-branch pushes no longer run a second full matrix in parallel to PR Validation.

- integration-tests concurrency group is now scoped per calling workflow (github.workflow + github.ref), preventing PR Validation and Build and Publish from canceling each other's reusable test runs.

- Added timeout-minutes (25 per matrix job, 15 per dotnet test step, 10 for summary job) so a hung Electron process no longer keeps a runner busy until the 6h default timeout, which previously required manual cancel.

- Added --blame-hang --blame-hang-timeout 5min to dotnet test so hung tests produce a dump and fail fast instead of stalling.

- Removed pointless 0-20s random sleep step at the start of every matrix job.
2026-05-09 22:26:43 +02:00
Gregor Biswanger
50c9076af6 fix: replace ReadAllLines with ReadAllText in MigrationChecks.targets… (#1062)
* fix: replace ReadAllLines with ReadAllText in MigrationChecks.targets (fixes #1035)

System.IO.File::ReadAllLines is not available as an MSBuild property function on
all platforms (e.g. macOS GitHub Actions), causing MSB4185.

ReadAllText is universally supported by MSBuild and sufficient for the regex check
that detects 'electron' references in a root package.json (ELECTRON008).
The intermediate ItemGroup for line accumulation is no longer needed.

* test: strengthen migration checks test with exit code assertion and remove reserved MSBuildProjectDirectory override

* test: locate MigrationChecks.targets via directory walk for path robustness

* test: replace em-dashes with ASCII hyphens to avoid bidi/hidden Unicode warning

* test: split build test into clean and electron-containing package.json scenarios
2026-05-09 22:08:36 +02:00
Gregor Biswanger
d7e1a09880 fix: correct ReleaseNotes deserialization for AutoUpdater (fixes #1039) (#1061)
* fix: correct ReleaseNotes deserialization for AutoUpdater (fixes #1039)

- TypeScript normalize() now maps string releaseNotes to { note } objects
  and also handles arrays of strings (both cases were broken in PR #1041)
- Added ReleaseNotesConverter (JsonConverter<ReleaseNoteInfo[]>) as defensive
  C# layer that handles all shapes: null, string, string[], object[]
- Added [JsonConverter] attribute on UpdateInfo.ReleaseNotes
- Added unit tests (no Electron required) covering all four input shapes

* chore: sync generated autoUpdater.js and .map with updated TypeScript source

* refactor: address Copilot PR review comments

- Fix namespace: ElectronNET.Converter -> ElectronNET.API.Converter
- Replace JsonDocument.ParseValue() with JsonSerializer.Deserialize<ReleaseNoteInfo>()
  for cleaner, allocation-free object array parsing
- Fix Write(): empty ReleaseNoteInfo[] now serializes as [] instead of null
- Use Array.Empty<ReleaseNoteInfo>() in UpdateInfo default initializer
- Add tests: Serialize_WithEmptyReleaseNotes and Serialize_WithNullReleaseNotes
2026-05-09 18:17:59 +02:00
dependabot[bot]
30b7b1d251 Bump socket.io-parser in /src/ElectronNET.Host/ElectronHostHook (#1043)
Bumps [socket.io-parser](https://github.com/socketio/socket.io) from 4.2.4 to 4.2.6.
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/socket.io-parser@4.2.4...socket.io-parser@4.2.6)

---
updated-dependencies:
- dependency-name: socket.io-parser
  dependency-version: 4.2.6
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Florian Rappl <mail@florian-rappl.de>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-09 17:30:45 +02:00
dependabot[bot]
e9b3ba0add Bump socket.io-parser in /src/ElectronNET.WebApp/ElectronHostHook (#1044)
Bumps [socket.io-parser](https://github.com/socketio/socket.io) from 4.2.5 to 4.2.6.
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/socket.io-parser@4.2.5...socket.io-parser@4.2.6)

---
updated-dependencies:
- dependency-name: socket.io-parser
  dependency-version: 4.2.6
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Florian Rappl <mail@florian-rappl.de>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-09 17:30:27 +02:00
dependabot[bot]
89f721d1b3 Bump brace-expansion from 1.1.12 to 1.1.14 in /src/ElectronNET.WebApp/ElectronHostHook (#1060)
* Bump lodash in /src/ElectronNET.WebApp/ElectronHostHook (#1056)

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump brace-expansion in /src/ElectronNET.WebApp/ElectronHostHook

Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 1.1.12 to 1.1.14.
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v1.1.12...v1.1.14)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 1.1.14
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-09 17:26:55 +02:00
dependabot[bot]
833d288891 Bump lodash from 4.17.23 to 4.18.1 in /src/ElectronNET.Host (#1059)
* Bump lodash in /src/ElectronNET.WebApp/ElectronHostHook (#1056)

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump lodash from 4.17.23 to 4.18.1 in /src/ElectronNET.Host

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1)

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

Signed-off-by: dependabot[bot] <support@github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-09 17:24:25 +02:00
dependabot[bot]
e529d092c3 Bump lodash in /src/ElectronNET.WebApp/ElectronHostHook (#1056)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-09 17:11:36 +02:00
Florian Rappl
11f71feeb8 Automatic Port Selection and Secured Communication (#1038)
Adds dynamic OS-selected socket port handling and secured Electron/.NET communication.

The dotnet-first startup flow now generates the auth token on the .NET side and passes it to Electron through an environment variable. Electron reports the selected socket port through a temporary startup-info file, avoiding any dependency on parsing Electron console output.

Also avoids logging backend startup parameters because they include the auth token.
2026-05-09 17:03:32 +02:00
Florian Rappl
1e8b02648a Merge pull request #1041 from ElectronNET/hotfix/autoupdater-checkforchanges
Fixed Serialization of Release Notes
2026-03-26 10:27:43 +01:00
Florian Rappl
2a14840c6b Merge pull request #1017 from ElectronNET/dependabot/npm_and_yarn/src/ElectronNET.WebApp/ElectronHostHook/lodash-4.17.23
Bump lodash from 4.17.21 to 4.17.23 in /src/ElectronNET.WebApp/ElectronHostHook
2026-03-26 10:27:18 +01:00
Florian Rappl
005feddcc5 Merge pull request #1049 from AeonSake/1048-hasshadow-true-by-default
Fix `HasShadow` Not Being `true` by Default
2026-03-25 23:31:08 +01:00
Florian Rappl
3f14f9ae7e Merge branch 'develop' into dependabot/npm_and_yarn/src/ElectronNET.WebApp/ElectronHostHook/lodash-4.17.23 2026-03-25 23:30:11 +01:00
Florian Rappl
ce271fd30a Merge pull request #1046 from ElectronNET/dependabot/npm_and_yarn/src/ElectronNET.Host/flatted-3.4.2
Bump flatted from 3.3.3 to 3.4.2 in /src/ElectronNET.Host
2026-03-25 23:26:37 +01:00
Florian Rappl
1d1b9537b5 Merge pull request #1016 from ElectronNET/dependabot/npm_and_yarn/src/ElectronNET.Host/lodash-4.17.23
Bump lodash from 4.17.21 to 4.17.23 in /src/ElectronNET.Host
2026-03-25 23:25:44 +01:00
Aeon
4c48588ce2 Fix HasShadow not being true by default 2026-03-25 02:37:20 +01:00
dependabot[bot]
c9945a87a9 Bump flatted from 3.3.3 to 3.4.2 in /src/ElectronNET.Host
Bumps [flatted](https://github.com/WebReflection/flatted) from 3.3.3 to 3.4.2.
- [Commits](https://github.com/WebReflection/flatted/compare/v3.3.3...v3.4.2)

---
updated-dependencies:
- dependency-name: flatted
  dependency-version: 3.4.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-21 10:29:48 +00:00
Florian Rappl
8fc197b32a Proposed fix for releaseNotes serialization #1039 2026-03-18 20:12:06 +01:00
Florian Rappl
7930831b6d Added sample for auth 2026-03-18 19:49:48 +01:00
Florian Rappl
201046164c Merge pull request #1037 from ElectronNET/feature/socket-interface
Changed facade to socket connection
2026-03-05 23:18:24 +01:00
Florian Rappl
b8151a2fad Changed facade to socket connection 2026-03-05 11:25:22 +01:00
Florian Rappl
c1bf6d9423 Updated version 2026-03-05 11:13:07 +01:00
Florian Rappl
c8268fae0e Merge pull request #1034 from ElectronNET/develop
Release 0.4.1
2026-02-26 07:00:49 +01:00
Florian Rappl
8eead56cbc removed trailing whitespace 2026-02-25 16:02:34 +01:00
Florian Rappl
e28eadc32d Merge branch 'develop' of https://github.com/ElectronNET/Electron.NET into develop 2026-02-25 15:57:42 +01:00
Florian Rappl
9a935c009e Updated changelog for release 2026-02-25 15:57:26 +01:00
Florian Rappl
c22c248f0b Merge pull request #1031 from AeonSake/1028-preload-override
Add Documentation for Preload Script
2026-02-25 14:55:48 +01:00
softworkz
842e8700ef Add overload for GetAllDisplaysAsync() with timout parameter 2026-02-25 04:11:13 +01:00
Aeon
3850a71579 Revert "Add check for existing preload script path before overriding"
This reverts commit 497e6aa423.
2026-02-17 23:33:13 +01:00
Aeon
d5df30718b Update documentation to reflect current approach 2026-02-17 23:32:55 +01:00
Florian Rappl
77ca79acc9 Merge pull request #1027 from softworkz/submit_housekeeping
Fix global.json link in solution, add missing json file
2026-02-17 23:25:13 +01:00
Florian Rappl
05fb9e5a29 Merge pull request #1026 from softworkz/submit_disposed_exceptions
SocketIoFacade: Improve disposal, avoid exception on tear-down
2026-02-17 23:23:57 +01:00
Aeon
850d8f6902 Add documentation for preload script and warning for Blazor 2026-02-17 19:48:12 +01:00
Aeon
497e6aa423 Add check for existing preload script path before overriding 2026-02-17 19:31:06 +01:00
softworkz
41c5b5af62 Relax test timings 2026-02-14 21:54:45 +01:00
softworkz
10679029e8 Add missing electron-builder.json in sample project 2026-02-14 21:26:46 +01:00
softworkz
a451e3a599 Fix global.json link in solution 2026-02-14 21:26:31 +01:00
softworkz
09c735a10f SocketIoFacade: Improve disposal, avoid exception on tear-down 2026-02-14 21:25:25 +01:00
Florian Rappl
8009348941 Update transformed files 2026-02-04 11:26:06 +01:00
Florian Rappl
b3b124bde1 Updated TS formatting to match prettier 2026-02-04 11:25:30 +01:00
Florian Rappl
21226e1ef0 Updated deps 2026-02-04 11:18:55 +01:00
Florian Rappl
7174118a3e Merge pull request #1019 from DYH1319/feat/submit_new_event_for_ipc
feat: submit new events for ipcMain
2026-02-03 00:32:04 +01:00
DYH1319
092789a5ec feat: Add overloaded methods in IpcMain that supports listeners with a return type of Task<object>. 2026-01-25 00:47:35 +08:00
DYH1319
bff3fffcbd feat: Add the Handle, HandleOnce, and RemoveHandler events to IpcMain 2026-01-24 23:18:16 +08:00
dependabot[bot]
f4da9588c9 Bump lodash in /src/ElectronNET.WebApp/ElectronHostHook
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.21...4.17.23)

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

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-21 23:55:31 +00:00
dependabot[bot]
04c1415f6d Bump lodash from 4.17.21 to 4.17.23 in /src/ElectronNET.Host
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.21...4.17.23)

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

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-21 23:29:29 +00:00
Florian Rappl
456135a562 Merge pull request #1015 from hillin/main
Update Migration Guide
2026-01-21 12:18:25 +01:00
lucas
300f52510c Update Migration Guide with details on electron-builder.json location and launch settings 2026-01-21 15:30:44 +08:00
Florian Rappl
d85a64f515 Merge pull request #1014 from softworkz/submit_new_event
BrowserWindow: Add OnBoundsChanged event
2026-01-21 08:19:16 +01:00
Florian Rappl
53698d1d44 Merge pull request #1013 from softworkz/submit_timeout
Double-up timeout for electron-builder and other fixes
2026-01-21 08:07:50 +01:00
Florian Rappl
04a224aa4f Merge pull request #1012 from softworkz/submit_migcheck_updates
Relax Migration check for package.json in root
2026-01-21 08:06:55 +01:00
softworkz
891da140b7 Relax Migration check for package.json in root 2026-01-21 06:50:07 +01:00
softworkz
17f761d184 Fix FormatException 2026-01-21 06:48:28 +01:00
softworkz
9f6489891e ElectronNET.Host: Revert JS SDK to default value from VS 2026 2026-01-21 06:48:28 +01:00
softworkz
c8f1cdf59f Add tests for BrowserWindow.OnBoundsChanged event 2026-01-21 06:47:28 +01:00
softworkz
6c95dfd476 BrowserWindow: Add OnBoundsChanged event
While not being an original Electron event, this one includes the bounds values,
saving the additional roundtrip for calling GetBoundsAsync
2026-01-21 06:47:28 +01:00
softworkz
b180fc2ea8 Double-up timeout for electron-builder 2026-01-21 05:10:24 +01:00
Florian Rappl
682a1c38ed Optional 2025-12-23 21:10:57 +01:00
Florian Rappl
809b0a6be7 Added missing methods 2025-12-23 00:38:37 +01:00
Florian Rappl
ae3f755648 Fixed center handling 2025-12-22 12:32:52 +01:00
Florian Rappl
7e6760a428 Merge pull request #998 from ElectronNET/develop
Release 0.4.0
2025-12-19 00:09:34 +01:00
Florian Rappl
29fdbb5315 Updated changelog 2025-12-18 23:58:04 +01:00
Florian Rappl
36bba6a49f Merge pull request #995 from softworkz/submit_packageid
Set PackageId from ElectronPackageId
2025-12-18 21:57:28 +01:00
Florian Rappl
44a010e0ed Merge pull request #996 from softworkz/submit_singleinstance
Fix ElectronSingleInstance handling
2025-12-18 21:56:59 +01:00
softworkz
25770db138 Update src/ElectronNET/build/ElectronNET.Core.targets
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-18 17:25:52 +01:00
Florian Rappl
1c99ab02cc Merge pull request #997 from softworkz/submit_rerun
Try fix retry-test-jobs
2025-12-18 16:56:29 +01:00
softworkz
73c56e2450 Try fix retry-test-jobs 2025-12-18 16:13:04 +01:00
softworkz
30037fce69 Fix ElectronSingleInstance handling 2025-12-18 15:52:56 +01:00
softworkz
69048d5565 Set PackageId from ElectronPackageId 2025-12-18 15:12:21 +01:00
Florian Rappl
d9c8e04b5c Meta for 0.4.0 2025-12-17 16:40:46 +01:00
Florian Rappl
368ef412bb Merge pull request #988 from softworkz/submit_crossdebug
Core: Introduce cross-platform npm restore and check mismatch on publish
2025-12-17 15:29:48 +01:00
Florian Rappl
cb20fbad25 Merge pull request #991 from ElectronNET/develop
Release 0.3.1
2025-12-16 19:00:07 +01:00
Florian Rappl
89cdf2f55b Merge pull request #992 from softworkz/submit_rerun
Try fix job re-run
2025-12-16 18:53:23 +01:00
softworkz
1c62c1f132 Try fix job re-run 2025-12-16 16:02:43 +01:00
Florian Rappl
d3e3188681 Prepare for 0.3.1 2025-12-16 15:51:39 +01:00
Florian Rappl
4f95043309 Merge pull request #990 from softworkz/submit_packageid
Use ElectronPackageId instead of PackageId
2025-12-16 15:48:43 +01:00
softworkz
13f1203ccc Use ElectronPackageId instead of PackageId 2025-12-16 14:54:20 +01:00
softworkz
9d0378798b ElectronProcessActive: Add check for platform mismatch 2025-12-15 13:22:53 +01:00
softworkz
1d6ef7a250 ElectronProcessActive: Mark binaries as executable when debugging 2025-12-15 12:18:42 +01:00
softworkz
2d6d4e2320 Fix up incorrect symlinks created by npm on Windows 2025-12-15 12:18:42 +01:00
softworkz
df8e269d5c Core: Introduce cross-platform npm restore and check mismatch on publish 2025-12-15 12:18:42 +01:00
196 changed files with 65857 additions and 4344 deletions

View File

@@ -134,4 +134,16 @@ TL;DR: Unless there is a technical reason (e.g., a crucial new API not being ava
We pretty much release whenever we have something new (i.e., do fixes such as a 0.1.1, or add new features, such as a 0.2.0) quite quickly. We pretty much release whenever we have something new (i.e., do fixes such as a 0.1.1, or add new features, such as a 0.2.0) quite quickly.
We will go for a 1.0.0 release of this as early as ~mid of January 2026 (unless we find some critical things or want to extend the beta phase for ElectronNET.Core). This should be sufficient time to get some user input and have enough experience to call it stable. We will go for a 1.0.0 release of this as early as ~mid of June 2026 (unless we find some critical things or want to extend the beta phase for ElectronNET.Core). This should be sufficient time to get some user input and have enough experience to call it stable.
## Updating Electron Versions
The releases of Electron are found on the [releases.electronjs.org](https://releases.electronjs.org/release?page=1) website.
You can update the `src\ElectronNET\build\ElectronNETRules.Project.xaml` file with new entries using the following script (run it in the browser's console when being on the Electron Releases website):
```js
[...new Set([...document.querySelectorAll('tbody tr a[href^="/release/v"]')].map(m => m.getAttribute('href').replace('/release/v', '')))].map(m => `<EnumValue Name="${m}" DisplayName="${m}" />`).sort().join('\n')
```
Alternatively, use the website's information to feed into an AI agent of your choice.

View File

@@ -1,6 +1,8 @@
name: Build and Publish name: Build and Publish
on: [push] on:
push:
branches: [main, develop]
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -4,13 +4,14 @@ on:
workflow_call: workflow_call:
concurrency: concurrency:
group: integration-tests-${{ github.ref }} group: integration-tests-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
tests: tests:
name: ${{ matrix.os }} API-${{ matrix.electronVersion }} name: ${{ matrix.os }} API-${{ matrix.electronVersion }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
timeout-minutes: 25
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@@ -42,13 +43,6 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Random delay (0-20 seconds)
shell: bash
run: |
DELAY=$((RANDOM % 21))
echo "Waiting for $DELAY seconds..."
sleep $DELAY
- name: Setup .NET - name: Setup .NET
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4
with: with:
@@ -79,27 +73,31 @@ jobs:
- name: Run tests (Linux) - name: Run tests (Linux)
if: runner.os == 'Linux' if: runner.os == 'Linux'
continue-on-error: true continue-on-error: true
timeout-minutes: 15
run: | run: |
mkdir -p test-results mkdir -p test-results
xvfb-run -a dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj \ xvfb-run -a dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj \
-c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} \ -c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} \
--logger "trx;LogFileName=${{ matrix.os }}-electron-${{ matrix.electronVersion }}.trx" \ --logger "trx;LogFileName=${{ matrix.os }}-electron-${{ matrix.electronVersion }}.trx" \
--logger "console;verbosity=detailed" \ --logger "console;verbosity=detailed" \
--blame-hang --blame-hang-timeout 5min \
--results-directory test-results --results-directory test-results
- name: Run tests (Windows) - name: Run tests (Windows)
if: runner.os == 'Windows' if: runner.os == 'Windows'
continue-on-error: true continue-on-error: true
timeout-minutes: 15
run: | run: |
New-Item -ItemType Directory -Force -Path test-results | Out-Null New-Item -ItemType Directory -Force -Path test-results | Out-Null
dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj -c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} --logger "trx;LogFileName=${{ matrix.os }}-electron-${{ matrix.electronVersion }}.trx" --logger "console;verbosity=detailed" --results-directory test-results dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj -c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} --logger "trx;LogFileName=${{ matrix.os }}-electron-${{ matrix.electronVersion }}.trx" --logger "console;verbosity=detailed" --blame-hang --blame-hang-timeout 5min --results-directory test-results
- name: Run tests (macOS) - name: Run tests (macOS)
if: runner.os == 'macOS' if: runner.os == 'macOS'
continue-on-error: true continue-on-error: true
timeout-minutes: 15
run: | run: |
mkdir -p test-results mkdir -p test-results
dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj -c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} --logger "trx;LogFileName=${{ matrix.os }}-electron-${{ matrix.electronVersion }}.trx" --logger "console;verbosity=detailed" --results-directory test-results dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj -c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} --logger "trx;LogFileName=${{ matrix.os }}-electron-${{ matrix.electronVersion }}.trx" --logger "console;verbosity=detailed" --blame-hang --blame-hang-timeout 5min --results-directory test-results
- name: Upload raw test results - name: Upload raw test results
if: always() if: always()
@@ -114,6 +112,7 @@ jobs:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
if: always() if: always()
needs: [tests] needs: [tests]
timeout-minutes: 10
permissions: permissions:
actions: read actions: read

View File

@@ -32,19 +32,18 @@ jobs:
echo "Jobs and conclusions:" echo "Jobs and conclusions:"
echo "$jobs_json" | jq '.jobs[] | {name: .name, conclusion: .conclusion}' echo "$jobs_json" | jq '.jobs[] | {name: .name, conclusion: .conclusion}'
failed_matrix_jobs=$(echo "$jobs_json" | jq ' failed_matrix_jobs=$(echo "$jobs_json" | jq -r '
[ .jobs[] [ .jobs[]
| select(.conclusion == "failure" | select(.conclusion == "failure"
and (.name | contains(" API-"))) and (.name | contains(" API-")))
] ]
| length | length // 0
') ')
failed_matrix_jobs=${failed_matrix_jobs:-0}
echo "Failed Integration Tests matrix jobs: $failed_matrix_jobs" if [ "${failed_matrix_jobs}" -gt 0 ]; then
if [ "$failed_matrix_jobs" -gt 0 ]; then
echo "Detected failing Integration Tests jobs re-running failed jobs for this run." echo "Detected failing Integration Tests jobs re-running failed jobs for this run."
gh run rerun "$RUN_ID" --failed gh run rerun -R "$REPO" "$RUN_ID" --failed
else else
echo "Only non-matrix jobs (like Test Results) failed not auto-rerunning." echo "Only non-matrix jobs (like Test Results) failed not auto-rerunning."
fi fi

View File

@@ -1,3 +1,56 @@
# 0.5.2
## ElectronNET.Core
- Fixed token param being appended to external URLs (#1075)
- Added more variants for `UseElectron` (#1076) @AeonSake
# 0.5.1
## ElectronNET.Core
- Fixed slicing of arguments for packaged applications (#1072)
- Added support for Electron 42+ (#1073)
# 0.5.0
## ElectronNET.Core
- Updated internal facade from `SocketIoFacade` to `ISocketConnection` (#1037)
- Fixed `HasShadow` is not `true` by default (#1049) @AeonSake
- Fixed missing `ReadAllLines` in MSBuild execution (#1035)
- Fixed serialization of release notes for the updater (#1041)
- Added automatic port selection and secured IPC communication (#1038)
# 0.4.1
## ElectronNET.Core
- Updated documentation for preload scripts (#1031) @AeonSake
- Updated timeout for electron-builder (#1013) @softworkz
- Updated disposal avoiding exceptions on teardown (#1026) @softworkz
- Updated migration guide (#1015) @hilin
- Fixed handling of `Center` property for windows (#1001)
- Fixed false alarm for `ELECTRON001`, `ELECTRON008`, and `ELECTRON009` (#1012) @softworkz
- Added missing methods on `Cookies` (#1000)
- Added overload for `GetAllDisplaysAsync` with timeout (#1033) @softworkz
- Added `OnBoundsChanged` event (#1014) @softworkz
- Added new events for `ipcMain` (#1019) @DYH1319
# 0.4.0
## ElectronNET.Core
- Fixed ElectronSingleInstance handling (#996) @softworkz
- Fixed `PackageId` handling (#993) @softworkz
- Added cross-platform npm restore and check mismatch on publish (#988) @softworkz
# 0.3.1
## ElectronNET.Core
- Fixed issue transforming the project ID (#989, #990) @softworkz
# 0.3.0 # 0.3.0
## ElectronNET.Core ## ElectronNET.Core

View File

@@ -8,7 +8,9 @@ When you build an Electron.NET project, the following validation checks are perf
| Code | Check | Description | | Code | Check | Description |
|------|-------|-------------| |------|-------|-------------|
| [ELECTRON001](#1-packagejson-not-allowed) | package.json not allowed | Ensures no package.json exists outside ElectronHostHook | | [ELECTRON001](#1-packagejson-rules) | package.json location rules | Ensures `package.json`/`package-lock.json` arent present in unsupported locations (root `package.json` handled separately) |
| [ELECTRON008](#1-packagejson-rules) | root package.json contains electron | Warns when root `package.json` contains the word `electron` (case-insensitive) |
| [ELECTRON009](#1-packagejson-rules) | root package.json copied to output | Warns when root `package.json` is configured to be copied to output/publish |
| [ELECTRON002](#2-electron-manifestjson-not-allowed) | electron-manifest.json not allowed | Detects deprecated manifest files | | [ELECTRON002](#2-electron-manifestjson-not-allowed) | electron-manifest.json not allowed | Detects deprecated manifest files |
| [ELECTRON003](#3-electron-builderjson-location) | electron-builder.json location | Verifies electron-builder.json exists in Properties folder | | [ELECTRON003](#3-electron-builderjson-location) | electron-builder.json location | Verifies electron-builder.json exists in Properties folder |
| [ELECTRON004](#3-electron-builderjson-location) | electron-builder.json wrong location | Warns if electron-builder.json is found in incorrect locations | | [ELECTRON004](#3-electron-builderjson-location) | electron-builder.json wrong location | Warns if electron-builder.json is found in incorrect locations |
@@ -18,30 +20,44 @@ When you build an Electron.NET project, the following validation checks are perf
--- ---
## 1. package.json not allowed ## 1. package.json rules
**Warning Code:** `ELECTRON001` **Warning Codes:** `ELECTRON001`, `ELECTRON008`, `ELECTRON009`
### What is checked ### What is checked
The build system scans for `package.json` and `package-lock.json` files in your project directory. These files should not exist in the project root or subdirectories (with one exception). The build system scans for `package.json` and `package-lock.json` files in your project directory.
Rules:
- **ELECTRON001**: `package.json` / `package-lock.json` must not exist in the project directory or subdirectories
- Exception: `ElectronHostHook` folder is allowed
- Note: a **root** `package.json` is **excluded** from `ELECTRON001` and validated by `ELECTRON008` / `ELECTRON009`
- **ELECTRON008**: If a root `package.json` exists, it must **not** contain electron-related dependencies or configuration.
- **ELECTRON009**: If a root `package.json` exists, it must **not** be configured to be copied to output/publish (for example via `CopyToOutputDirectory` / `CopyToPublishDirectory` metadata)
### Why this matters ### Why this matters
In previous versions of Electron.NET, a `package.json` file was required in the project. The new version generates this file automatically from MSBuild properties defined in your `.csproj` file. Electron.NET generates its Electron-related `package.json` during publishing based on MSBuild properties. A user-maintained Electron-related `package.json` can conflict with that process.
Also, ensuring the root `package.json` is not copied prevents accidentally shipping it with the published app.
### Exception ### Exception
A `package.json` file **is allowed** in the `ElectronHostHook` folder if you're using custom host hooks. This is the only valid location for a manually maintained package.json. A `package.json` / `package-lock.json` file **is allowed** in the `ElectronHostHook` folder if you're using custom host hooks.
### How to fix ### How to fix
If you have an Electron-related `package.json` from older Electron.NET versions:
1. **Open your project's `.csproj` file** 1. **Open your project's `.csproj` file**
2. **Add the required properties** to a PropertyGroup with the label `ElectronNetCommon`: 2. **Add the required properties** to a PropertyGroup with the label `ElectronNetCommon`:
```xml ```xml
<PropertyGroup Label="ElectronNetCommon"> <PropertyGroup Label="ElectronNetCommon">
<PackageId>my-electron-app</PackageId> <ElectronPackageId>my-electron-app</ElectronPackageId>
<Title>My Electron App</Title> <Title>My Electron App</Title>
<Version>1.0.0</Version> <Version>1.0.0</Version>
<Description>My awesome Electron.NET application</Description> <Description>My awesome Electron.NET application</Description>
@@ -51,7 +67,12 @@ A `package.json` file **is allowed** in the `ElectronHostHook` folder if you're
</PropertyGroup> </PropertyGroup>
``` ```
3. **Delete the old `package.json`** file from your project root 3. **Delete** Electron-related `package.json` / `package-lock.json` files (except those under `ElectronHostHook` if applicable)
If you keep a root `package.json` for non-Electron reasons:
- Ensure it does **not** contain electron dependencies or configuration (fixes `ELECTRON008`)
- Ensure it is **not** copied to output/publish (fixes `ELECTRON009`)
> **See also:** [Migration Guide](Migration-Guide.md) for complete migration instructions. > **See also:** [Migration Guide](Migration-Guide.md) for complete migration instructions.

View File

@@ -31,7 +31,7 @@ dotnet add package ElectronNET.Core.AspNet # For ASP.NET projects
### Step 2: Configure Project Settings ### Step 2: Configure Project Settings
**Auto-generated Configuration:** **Auto-generated Configuration:**
ElectronNET.Core automatically creates `electron-builder.json` during the first build or NuGet restore. No manual configuration is needed for basic setups. ElectronNET.Core automatically creates `electron-builder.json` in the `Properties` folder of your project during the first build or NuGet restore. No manual configuration is needed for basic setups.
**Migrate Existing Configuration:** **Migrate Existing Configuration:**
If you have an existing `electron.manifest.json` file: If you have an existing `electron.manifest.json` file:
@@ -63,6 +63,9 @@ You can also manually edit `electron-builder.json`:
} }
``` ```
**Modify Launch Settings:**
ElectronNET.Core no longer needs a separate CLI tool (electronize.exe) for launching. You should update your launch settings to use either the ASP.NET-first or Electron-first approach. See [Debugging](../Using/Debugging.md) for details.
## 🎯 Testing Migration ## 🎯 Testing Migration
After completing the migration steps: After completing the migration steps:

View File

@@ -54,7 +54,7 @@ Add the Electron.NET configuration to your `.csproj` file:
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ElectronNET.Core" Version="0.3.0" /> <PackageReference Include="ElectronNET.Core" Version="0.5.1" />
</ItemGroup> </ItemGroup>
``` ```

View File

@@ -25,7 +25,7 @@ These are the current default values when you don't make any changes:
<ElectronSingleInstance>true</ElectronSingleInstance> <ElectronSingleInstance>true</ElectronSingleInstance>
<ElectronSplashScreen></ElectronSplashScreen> <ElectronSplashScreen></ElectronSplashScreen>
<ElectronIcon></ElectronIcon> <ElectronIcon></ElectronIcon>
<PackageId>$(MSBuildProjectName.Replace(".", "-").ToLower())</PackageId> <ElectronPackageId>$(MSBuildProjectName.Replace(".", "-").ToLower())</ElectronPackageId>
<ElectronBuilderJson>electron-builder.json</ElectronBuilderJson> <ElectronBuilderJson>electron-builder.json</ElectronBuilderJson>
<Title>$(MSBuildProjectName)</Title> <Title>$(MSBuildProjectName)</Title>
</PropertyGroup> </PropertyGroup>
@@ -38,15 +38,15 @@ Since electron builder still expects a `package.json` file to exist, ElectronNET
```json ```json
{ {
"name": "$(PackageId)", "name": "$(ElectronPackageId)",
"productName": "$(ElectronTitle)", "productName": "$(ElectronTitle)",
"build": { "build": {
"appId": "$(PackageId)", "appId": "$(ElectronPackageId)",
"linux": { "linux": {
"desktop": { "desktop": {
"entry": { "Name": "$(Title)" } "entry": { "Name": "$(Title)" }
}, },
"executableName": "$(PackageId)" "executableName": "$(ElectronPackageId)"
}, },
"deb": { "deb": {
"desktop": { "desktop": {
@@ -85,6 +85,26 @@ BrowserWindowOptions browserWindowOptions = new BrowserWindowOptions
``` ```
### Preload Script
If you require the use of a [preload script](https://www.electronjs.org/docs/latest/tutorial/tutorial-preload), you can specify the file path of the script when creating a new window like so:
```csharp
WebPreferences wp = new WebPreferences();
wp.Preload = "path/to/preload.js";
BrowserWindowOptions browserWindowOptions = new BrowserWindowOptions
{
WebPreferences = wp
};
```
> [!IMPORTANT]
> When using a preload script _AND_ running a Blazor app, `IsRunningBlazor` must be set to `false` (or removed) and the following lines must be added to the preload script:
> ```js
> global.process = undefined;
> global.module = undefined;
> ```
## 🚀 Next Steps ## 🚀 Next Steps

View File

@@ -0,0 +1,32 @@
# Secure Communication
By default, the IPC communication between .NET and Node.js is secured on startup. Consequently, multiple instances running on different user accounts (but shared on the same machine) can safely co-exist. However, this protection is not enough to secure the web application behind - or make any security statement w.r.t. a malicious root user.
## Securing the Web Application
You can opt-in to also guard your ASP.NET Core application using the same mechanism that is already used to protected the IPC broker that deals with the .NET to Node.js communication.
The key to opt-in is to provide another service *before* calling `AddElectron` on the service collection.
The following two namespaces are used in the next instructions:
```cs
using ElectronNET.AspNet.Middleware;
using ElectronNET.AspNet.Services;
```
You'll need the following line:
```cs
builder.Services.AddSingleton<IElectronAuthenticationService, ElectronAuthenticationService>();
```
This way, Electron.NET is notified that you want to store and re-use the authentication token that has been negotiated between the .NET and Node.js processes at startup.
With this being set up you can register a middleware to actually deny requests that have originated outside of your Electron.NET application:
```cs
app.UseMiddleware<ElectronAuthenticationMiddleware>();
```
This must be placed above any routing (e.g., before calling `UseRouting` on the web application) in order to properly take effect.

View File

@@ -24,6 +24,7 @@
- [Startup-Methods](Using/Startup-Methods.md) - [Startup-Methods](Using/Startup-Methods.md)
- [Debugging](Using/Debugging.md) - [Debugging](Using/Debugging.md)
- [Package Building](Using/Package-Building.md) - [Package Building](Using/Package-Building.md)
- [Secure Communication](Using/Secure-Communication.md)
- [Adding a `custom_main.js`](Using/Custom_main.md) - [Adding a `custom_main.js`](Using/Custom_main.md)
# API Reference # API Reference

View File

@@ -314,7 +314,9 @@ namespace ElectronNET.API
{ {
if (this.tcs != null) if (this.tcs != null)
{ {
var ex = new TimeoutException($"No response after {timeout:D}ms trying to retrieve value {apiBase.objectName}.{callerName}()"); var ex = new TimeoutException(
$"No response after {(long)timeout.TotalMilliseconds}ms trying to retrieve value {apiBase.objectName}.{callerName}()"
);
this.tcs.TrySetException(ex); this.tcs.TrySetException(ex);
this.tcs = null; this.tcs = null;
} }

View File

@@ -427,7 +427,7 @@ namespace ElectronNET.API
public void DisposeSocket() public void DisposeSocket()
{ {
BridgeConnector.Socket.DisposeSocket(); BridgeConnector.Socket.Dispose();
} }
/// <summary> /// <summary>

View File

@@ -186,6 +186,19 @@ public class BrowserWindow : ApiBase
remove => RemoveEvent(value, Id); remove => RemoveEvent(value, Id);
} }
/// <summary>
/// Emitted when the window is moved or resized.
/// </summary>
/// <remarks>
/// While not being an original Electron event, this one includes the bounds values,
/// saving the additional roundtrip for calling <see cref="GetBoundsAsync"/>.
/// </remarks>
public event Action<Rectangle> OnBoundsChanged
{
add => AddEvent(value, Id);
remove => RemoveEvent(value, Id);
}
/// <summary> /// <summary>
/// macOS: Emitted once when the window is moved to a new position. /// macOS: Emitted once when the window is moved to a new position.
/// </summary> /// </summary>

View File

@@ -2,6 +2,7 @@ using ElectronNET.API.Entities;
using ElectronNET.API.Serialization; using ElectronNET.API.Serialization;
using System; using System;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks;
namespace ElectronNET.API namespace ElectronNET.API
{ {
@@ -54,10 +55,79 @@ namespace ElectronNET.API
_changed -= value; _changed -= value;
if (_changed == null) if (_changed == null)
{
BridgeConnector.Socket.Off("webContents-session-cookies-changed" + Id); BridgeConnector.Socket.Off("webContents-session-cookies-changed" + Id);
}
} }
} }
private event Action<Cookie, CookieChangedCause, bool> _changed; private event Action<Cookie, CookieChangedCause, bool> _changed;
/// <summary>
/// Sends a request to get all cookies matching filter, and resolves a callack with the response.
/// </summary>
/// <param name="filter">
/// </param>
/// <returns>A task which resolves an array of cookie objects.</returns>
public Task<Cookie[]> GetAsync(CookieFilter filter)
{
var tcs = new TaskCompletionSource<Cookie[]>();
var guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.Once<Cookie[]>("webContents-session-cookies-get-completed" + guid, tcs.SetResult);
BridgeConnector.Socket.Emit("webContents-session-cookies-get", Id, filter, guid);
return tcs.Task;
}
/// <summary>
///
/// </summary>
/// <param name="details"></param>
/// <returns></returns>
public Task SetAsync(CookieDetails details)
{
var tcs = new TaskCompletionSource<object>();
var guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.Once<object>("webContents-session-cookies-set-completed" + guid, tcs.SetResult);
BridgeConnector.Socket.Emit("webContents-session-cookies-set", Id, details, guid);
return tcs.Task;
}
/// <summary>
/// Removes the cookies matching url and name
/// </summary>
/// <param name="url">The URL associated with the cookie.</param>
/// <param name="name">The name of cookie to remove.</param>
/// <returns>A task which resolves when the cookie has been removed</returns>
public Task RemoveAsync(string url, string name)
{
var tcs = new TaskCompletionSource<object>();
var guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.Once<object>("webContents-session-cookies-remove-completed" + guid, tcs.SetResult);
BridgeConnector.Socket.Emit("webContents-session-cookies-remove", Id, url, name, guid);
return tcs.Task;
}
/// <summary>
/// Writes any unwritten cookies data to disk.
/// </summary>
/// <returns>A task which resolves when the cookie store has been flushed</returns>
public Task FlushStoreAsync()
{
var tcs = new TaskCompletionSource<object>();
var guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.Once<object>("webContents-session-cookies-flushStore-completed" + guid, tcs.SetResult);
BridgeConnector.Socket.Emit("webContents-session-cookies-flushStore", Id, guid);
return tcs.Task;
}
} }
} }

View File

@@ -24,13 +24,13 @@ namespace ElectronNET.API.Entities
/// ( if y is used) Window's left offset from screen. Default is to center the /// ( if y is used) Window's left offset from screen. Default is to center the
/// window. /// window.
/// </summary> /// </summary>
public int X { get; set; } = -1; public int? X { get; set; }
/// <summary> /// <summary>
/// ( if x is used) Window's top offset from screen. Default is to center the /// ( if x is used) Window's top offset from screen. Default is to center the
/// window. /// window.
/// </summary> /// </summary>
public int Y { get; set; } = -1; public int? Y { get; set; }
/// <summary> /// <summary>
/// The width and height would be used as web page's size, which means the actual /// The width and height would be used as web page's size, which means the actual
@@ -215,7 +215,8 @@ namespace ElectronNET.API.Entities
/// <summary> /// <summary>
/// Whether window should have a shadow. Default is true. /// Whether window should have a shadow. Default is true.
/// </summary> /// </summary>
public bool HasShadow { get; set; } [DefaultValue(true)]
public bool HasShadow { get; set; } = true;
/// <summary> /// <summary>
/// Forces using dark theme for the window, only works on some GTK+3 desktop environments. Default is false. /// Forces using dark theme for the window, only works on some GTK+3 desktop environments. Default is false.

View File

@@ -24,7 +24,7 @@
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the cookie is a host-only cookie; this will only be true if no domain was passed. /// Gets or sets a value indicating whether the cookie is a host-only cookie; this will only be true if no domain was passed.
/// </summary> /// </summary>
public bool HostOnly { get; set; } public bool? HostOnly { get; set; }
/// <summary> /// <summary>
/// Gets or sets the path of the cookie. /// Gets or sets the path of the cookie.
@@ -34,22 +34,22 @@
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the cookie is marked as secure. /// Gets or sets a value indicating whether the cookie is marked as secure.
/// </summary> /// </summary>
public bool Secure { get; set; } public bool? Secure { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the cookie is marked as HTTP only. /// Gets or sets a value indicating whether the cookie is marked as HTTP only.
/// </summary> /// </summary>
public bool HttpOnly { get; set; } public bool? HttpOnly { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the cookie is a session cookie or a persistent cookie with an expiration date. /// Gets or sets a value indicating whether the cookie is a session cookie or a persistent cookie with an expiration date.
/// </summary> /// </summary>
public bool Session { get; set; } public bool? Session { get; set; }
/// <summary> /// <summary>
/// Gets or sets the expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. /// Gets or sets the expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies.
/// </summary> /// </summary>
public double ExpirationDate { get; set; } public double? ExpirationDate { get; set; }
/// <summary> /// <summary>
/// Gets or sets the SameSite policy applied to this cookie. Can be "unspecified", "no_restriction", "lax" or "strict". /// Gets or sets the SameSite policy applied to this cookie. Can be "unspecified", "no_restriction", "lax" or "strict".

View File

@@ -29,16 +29,16 @@
/// <summary> /// <summary>
/// (optional) - Filters cookies by their Secure property. /// (optional) - Filters cookies by their Secure property.
/// </summary> /// </summary>
public bool Secure { get; set; } public bool? Secure { get; set; }
/// <summary> /// <summary>
/// (optional) - Filters out session or persistent cookies. /// (optional) - Filters out session or persistent cookies.
/// </summary> /// </summary>
public bool Session { get; set; } public bool? Session { get; set; }
/// <summary> /// <summary>
/// (optional) - Filters cookies by httpOnly. /// (optional) - Filters cookies by httpOnly.
/// </summary> /// </summary>
public bool HttpOnly { get; set; } public bool? HttpOnly { get; set; }
} }
} }

View File

@@ -1,4 +1,8 @@
namespace ElectronNET.API.Entities using System;
using System.Text.Json.Serialization;
using ElectronNET.API.Converter;
namespace ElectronNET.API.Entities
{ {
/// <summary> /// <summary>
/// ///
@@ -24,7 +28,8 @@
/// <summary> /// <summary>
/// Gets or sets the release notes. /// Gets or sets the release notes.
/// </summary> /// </summary>
public ReleaseNoteInfo[] ReleaseNotes { get; set; } = new ReleaseNoteInfo[0]; [JsonConverter(typeof(ReleaseNotesConverter))]
public ReleaseNoteInfo[] ReleaseNotes { get; set; } = Array.Empty<ReleaseNoteInfo>();
/// <summary> /// <summary>
/// Gets or sets the release date. /// Gets or sets the release date.

View File

@@ -102,6 +102,29 @@ namespace ElectronNET.API
}); });
} }
/// <summary>
/// Send a message to the renderer process synchronously via channel,
/// you can also send arbitrary arguments.
///
/// Note: Sending a synchronous message will block the whole renderer process,
/// unless you know what you are doing you should never use it.
/// </summary>
/// <param name="channel"></param>
/// <param name="listener"></param>
public void OnSync(string channel, Func<object, Task<object>> listener)
{
BridgeConnector.Socket.Emit("registerSyncIpcMainChannel", channel);
BridgeConnector.Socket.On<JsonElement>(channel, (args) =>
{
Task.Run(async () =>
{
var arg = FormatArguments(args);
var result = await listener(arg);
BridgeConnector.Socket.Emit(channel + "Sync", result);
});
});
}
/// <summary> /// <summary>
/// Adds a one time listener method for the event. This listener is invoked only /// Adds a one time listener method for the event. This listener is invoked only
/// the next time a message is sent to channel, after which it is removed. /// the next time a message is sent to channel, after which it is removed.
@@ -154,5 +177,88 @@ namespace ElectronNET.API
{ {
BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, data); BridgeConnector.Socket.Emit("sendToIpcRendererBrowserView", browserView.Id, channel, data);
} }
/// <summary>
/// Adds a handler for an invokeable IPC. This handler will be called
/// whenever a renderer calls ipcRenderer.invoke(channel, ...args).
/// </summary>
/// <param name="channel">Channelname.</param>
/// <param name="listener">Callback Method.</param>
public void Handle(string channel, Func<object, object> listener)
{
BridgeConnector.Socket.Emit("registerHandleIpcMainChannel", channel);
BridgeConnector.Socket.On<JsonElement>(channel, (args) =>
{
var arg = FormatArguments(args);
var result = listener(arg);
BridgeConnector.Socket.Emit(channel + "Handle", result);
});
}
/// <summary>
/// Adds a handler for an invokeable IPC. This handler will be called
/// whenever a renderer calls ipcRenderer.invoke(channel, ...args).
/// </summary>
/// <param name="channel">Channelname.</param>
/// <param name="listener">Callback Method.</param>
public void Handle(string channel, Func<object, Task<object>> listener)
{
BridgeConnector.Socket.Emit("registerHandleIpcMainChannel", channel);
BridgeConnector.Socket.On<JsonElement>(channel, (args) =>
{
Task.Run(async () =>
{
var arg = FormatArguments(args);
var result = await listener(arg);
BridgeConnector.Socket.Emit(channel + "Handle", result);
});
});
}
/// <summary>
/// Handles a single invokeable IPC message, then removes the listener.
/// See ipcMain.handle(channel, listener).
/// </summary>
/// <param name="channel">Channelname.</param>
/// <param name="listener">Callback Method.</param>
public void HandleOnce(string channel, Func<object, object> listener)
{
BridgeConnector.Socket.Emit("registerHandleOnceIpcMainChannel", channel);
BridgeConnector.Socket.Once<JsonElement>(channel, (args) =>
{
var arg = FormatArguments(args);
var result = listener(arg);
BridgeConnector.Socket.Emit(channel + "HandleOnce", result);
});
}
/// <summary>
/// Handles a single invokeable IPC message, then removes the listener.
/// See ipcMain.handle(channel, listener).
/// </summary>
/// <param name="channel">Channelname.</param>
/// <param name="listener">Callback Method.</param>
public void HandleOnce(string channel, Func<object, Task<object>> listener)
{
BridgeConnector.Socket.Emit("registerHandleOnceIpcMainChannel", channel);
BridgeConnector.Socket.Once<JsonElement>(channel, (args) =>
{
Task.Run(async () =>
{
var arg = FormatArguments(args);
var result = await listener(arg);
BridgeConnector.Socket.Emit(channel + "HandleOnce", result);
});
});
}
/// <summary>
/// Removes any handler for channel, if present.
/// </summary>
/// <param name="channel">Channelname.</param>
public void RemoveHandler(string channel)
{
BridgeConnector.Socket.Emit("removeHandlerIpcMainChannel", channel);
}
} }
} }

View File

@@ -124,6 +124,15 @@ namespace ElectronNET.API
/// <returns>An array of displays that are currently available.</returns> /// <returns>An array of displays that are currently available.</returns>
public Task<Display[]> GetAllDisplaysAsync() => this.InvokeAsync<Display[]>(); public Task<Display[]> GetAllDisplaysAsync() => this.InvokeAsync<Display[]>();
/// <summary>
/// An array of displays that are currently available.
/// </summary>
/// <param name="invocationTimeout">The invocation timeout.</param>
/// <returns>
/// An array of displays that are currently available.
/// </returns>
public Task<Display[]> GetAllDisplaysAsync(TimeSpan invocationTimeout) => this.InvokeAsyncWithTimeout<Display[]>(invocationTimeout);
/// <summary> /// <summary>
/// The display nearest the specified point. /// The display nearest the specified point.
/// </summary> /// </summary>

View File

@@ -130,11 +130,8 @@ namespace ElectronNET.API
options.Height += 7; options.Height += 7;
} }
if (options.X == -1 && options.Y == -1) if (!options.X.HasValue && !options.Y.HasValue)
{ {
options.X = 0;
options.Y = 0;
await BridgeConnector.Socket.Emit("createBrowserWindow", options, loadUrl).ConfigureAwait(false); await BridgeConnector.Socket.Emit("createBrowserWindow", options, loadUrl).ConfigureAwait(false);
} }
else else

View File

@@ -4,7 +4,7 @@ namespace ElectronNET.API
{ {
internal static class BridgeConnector internal static class BridgeConnector
{ {
public static SocketIoFacade Socket public static ISocketConnection Socket
{ {
get get
{ {

View File

@@ -0,0 +1,56 @@
namespace ElectronNET.API;
using System;
using System.Threading.Tasks;
/// <summary>
/// Common interface for communication facades.
/// Provides methods for bidirectional communication between .NET and Electron.
/// </summary>
internal interface ISocketConnection : IDisposable
{
/// <summary>
/// Raised when the bridge connection is established.
/// </summary>
event EventHandler BridgeConnected;
/// <summary>
/// Raised when the bridge connection is lost.
/// </summary>
event EventHandler BridgeDisconnected;
/// <summary>
/// Establishes the connection to Electron.
/// </summary>
void Connect();
/// <summary>
/// Registers a persistent event handler.
/// </summary>
void On(string eventName, Action action);
/// <summary>
/// Registers a persistent event handler with a typed parameter.
/// </summary>
void On<T>(string eventName, Action<T> action);
/// <summary>
/// Registers a one-time event handler.
/// </summary>
void Once(string eventName, Action action);
/// <summary>
/// Registers a one-time event handler with a typed parameter.
/// </summary>
void Once<T>(string eventName, Action<T> action);
/// <summary>
/// Removes an event handler.
/// </summary>
void Off(string eventName);
/// <summary>
/// Sends a message to Electron.
/// </summary>
Task Emit(string eventName, params object[] args);
}

View File

@@ -3,19 +3,29 @@
namespace ElectronNET.API; namespace ElectronNET.API;
using System; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using ElectronNET.API.Serialization; using ElectronNET.API.Serialization;
using SocketIO.Serializer.SystemTextJson; using SocketIO.Serializer.SystemTextJson;
using SocketIO = SocketIOClient.SocketIO; using SocketIO = SocketIOClient.SocketIO;
using SocketIOOptions = SocketIOClient.SocketIOOptions;
internal class SocketIoFacade internal class SocketIOConnection : ISocketConnection
{ {
private readonly SocketIO _socket; private readonly SocketIO _socket;
private readonly object _lockObj = new object(); private readonly object _lockObj = new object();
private bool _isDisposed;
public SocketIoFacade(string uri) public SocketIOConnection(string uri, string authorization)
{ {
_socket = new SocketIO(uri); var opts = string.IsNullOrEmpty(authorization) ? new SocketIOOptions() : new SocketIOOptions
{
ExtraHeaders = new Dictionary<string, string>
{
["authorization"] = authorization
},
};
_socket = new SocketIO(uri, opts);
_socket.Serializer = new SystemTextJsonSerializer(ElectronJson.Options); _socket.Serializer = new SystemTextJsonSerializer(ElectronJson.Options);
// Use default System.Text.Json serializer from SocketIOClient. // Use default System.Text.Json serializer from SocketIOClient.
// Outgoing args are normalized to camelCase via SerializeArg in Emit. // Outgoing args are normalized to camelCase via SerializeArg in Emit.
@@ -27,6 +37,8 @@ internal class SocketIoFacade
public void Connect() public void Connect()
{ {
this.CheckDisposed();
_socket.OnError += (sender, e) => { Console.WriteLine($"BridgeConnector Error: {sender} {e}"); }; _socket.OnError += (sender, e) => { Console.WriteLine($"BridgeConnector Error: {sender} {e}"); };
_socket.OnConnected += (_, _) => _socket.OnConnected += (_, _) =>
@@ -46,6 +58,8 @@ internal class SocketIoFacade
public void On(string eventName, Action action) public void On(string eventName, Action action)
{ {
this.CheckDisposed();
lock (_lockObj) lock (_lockObj)
{ {
_socket.On(eventName, _ => { Task.Run(action); }); _socket.On(eventName, _ => { Task.Run(action); });
@@ -54,6 +68,8 @@ internal class SocketIoFacade
public void On<T>(string eventName, Action<T> action) public void On<T>(string eventName, Action<T> action)
{ {
this.CheckDisposed();
lock (_lockObj) lock (_lockObj)
{ {
_socket.On(eventName, response => _socket.On(eventName, response =>
@@ -66,6 +82,8 @@ internal class SocketIoFacade
public void Once(string eventName, Action action) public void Once(string eventName, Action action)
{ {
this.CheckDisposed();
lock (_lockObj) lock (_lockObj)
{ {
_socket.On(eventName, _ => _socket.On(eventName, _ =>
@@ -78,6 +96,8 @@ internal class SocketIoFacade
public void Once<T>(string eventName, Action<T> action) public void Once<T>(string eventName, Action<T> action)
{ {
this.CheckDisposed();
lock (_lockObj) lock (_lockObj)
{ {
_socket.On(eventName, (socketIoResponse) => _socket.On(eventName, (socketIoResponse) =>
@@ -90,6 +110,11 @@ internal class SocketIoFacade
public void Off(string eventName) public void Off(string eventName)
{ {
if (_isDisposed)
{
return;
}
lock (_lockObj) lock (_lockObj)
{ {
_socket.Off(eventName); _socket.Off(eventName);
@@ -98,11 +123,33 @@ internal class SocketIoFacade
public async Task Emit(string eventName, params object[] args) public async Task Emit(string eventName, params object[] args)
{ {
await _socket.EmitAsync(eventName, args).ConfigureAwait(false); if (!_isDisposed)
{
await _socket.EmitAsync(eventName, args).ConfigureAwait(false);
}
} }
public void DisposeSocket() /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
public void Dispose()
{ {
_socket.Dispose(); Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_isDisposed = true;
_socket.Dispose();
}
}
private void CheckDisposed()
{
if (this._isDisposed)
{
throw new ObjectDisposedException(nameof(SocketIOConnection));
}
} }
} }

View File

@@ -26,6 +26,8 @@
private readonly StringBuilder stdOut = new StringBuilder(4 * 1024); private readonly StringBuilder stdOut = new StringBuilder(4 * 1024);
private readonly StringBuilder stdErr = new StringBuilder(4 * 1024); private readonly StringBuilder stdErr = new StringBuilder(4 * 1024);
public event EventHandler<string> LineReceived;
private volatile ManualResetEvent stdOutEvent; private volatile ManualResetEvent stdOutEvent;
private volatile ManualResetEvent stdErrEvent; private volatile ManualResetEvent stdErrEvent;
private volatile Stopwatch stopwatch; private volatile Stopwatch stopwatch;
@@ -571,6 +573,7 @@
if (e.Data != null) if (e.Data != null)
{ {
Console.WriteLine("|| " + e.Data); Console.WriteLine("|| " + e.Data);
LineReceived?.Invoke(this, e.Data);
} }
else else
{ {

View File

@@ -0,0 +1,91 @@
using ElectronNET.API.Entities;
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace ElectronNET.API.Converter;
/// <summary>
/// Handles the polymorphic shape of releaseNotes coming from electron-builder.
/// Depending on the updater.fullChangelog setting, electron-builder sends:
/// - null → when there are no notes
/// - "some string" → plain string (FullChangelog = false, default)
/// - ["note A", "note B"] → array of strings (after broken normalize in older TS)
/// - [{ version, note }, ...] → array of objects (FullChangelog = true)
/// All forms are normalised to ReleaseNoteInfo[] so the C# model stays clean.
/// See: https://github.com/ElectronNET/Electron.NET/issues/1039
/// </summary>
public class ReleaseNotesConverter : JsonConverter<ReleaseNoteInfo[]>
{
// Ensure the converter is called even when the JSON token is null,
// so we can return an empty array instead of null.
public override bool HandleNull => true;
public override ReleaseNoteInfo[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case JsonTokenType.Null:
return Array.Empty<ReleaseNoteInfo>();
case JsonTokenType.String:
// Plain string: "Some release notes"
return new[] { new ReleaseNoteInfo { Note = reader.GetString() } };
case JsonTokenType.StartArray:
var list = new List<ReleaseNoteInfo>();
while (reader.Read() && reader.TokenType != JsonTokenType.EndArray)
{
if (reader.TokenType == JsonTokenType.String)
{
// Array of strings: ["Note A", "Note B"]
list.Add(new ReleaseNoteInfo { Note = reader.GetString() });
}
else if (reader.TokenType == JsonTokenType.StartObject)
{
// Array of objects: [{ "version": "1.0", "note": "..." }]
var entry = JsonSerializer.Deserialize<ReleaseNoteInfo>(ref reader, options) ?? new ReleaseNoteInfo();
list.Add(entry);
}
else
{
reader.Skip();
}
}
return list.ToArray();
default:
throw new JsonException($"Unexpected token {reader.TokenType} when reading releaseNotes.");
}
}
public override void Write(Utf8JsonWriter writer, ReleaseNoteInfo[] value, JsonSerializerOptions options)
{
if (value is null)
{
writer.WriteNullValue();
return;
}
if (value.Length == 0)
{
writer.WriteStartArray();
writer.WriteEndArray();
return;
}
writer.WriteStartArray();
foreach (var item in value)
{
writer.WriteStartObject();
if (item.Version is not null)
{
writer.WriteString("version", item.Version);
}
writer.WriteString("note", item.Note);
writer.WriteEndObject();
}
writer.WriteEndArray();
}
}

View File

@@ -16,6 +16,7 @@
internal const int DefaultWebPort = 8001; internal const int DefaultWebPort = 8001;
internal const string ElectronPortArgumentName = "electronPort"; internal const string ElectronPortArgumentName = "electronPort";
internal const string ElectronPidArgumentName = "electronPID"; internal const string ElectronPidArgumentName = "electronPID";
internal const string ElectronAuthTokenArgumentName = "electronAuthToken";
/// <summary>Initializes the <see cref="ElectronNetRuntime"/> class.</summary> /// <summary>Initializes the <see cref="ElectronNetRuntime"/> class.</summary>
static ElectronNetRuntime() static ElectronNetRuntime()
@@ -26,6 +27,8 @@
public static string ElectronExtraArguments { get; set; } public static string ElectronExtraArguments { get; set; }
public static string ElectronAuthToken { get; internal set; }
public static int? ElectronSocketPort { get; internal set; } public static int? ElectronSocketPort { get; internal set; }
public static int? AspNetWebPort { get; internal set; } public static int? AspNetWebPort { get; internal set; }
@@ -47,9 +50,7 @@
internal static int? ElectronProcessId { get; set; } internal static int? ElectronProcessId { get; set; }
internal static Func<Task> OnAppReadyCallback { get; set; } internal static ISocketConnection GetSocket()
internal static SocketIoFacade GetSocket()
{ {
return RuntimeControllerCore?.Socket; return RuntimeControllerCore?.Socket;
} }

View File

@@ -12,7 +12,7 @@
{ {
} }
internal abstract SocketIoFacade Socket { get; } internal abstract ISocketConnection Socket { get; }
internal abstract ElectronProcessBase ElectronProcess { get; } internal abstract ElectronProcessBase ElectronProcess { get; }

View File

@@ -13,13 +13,12 @@
{ {
private ElectronProcessBase electronProcess; private ElectronProcessBase electronProcess;
private SocketBridgeService socketBridge; private SocketBridgeService socketBridge;
private int? port;
public RuntimeControllerDotNetFirst() public RuntimeControllerDotNetFirst()
{ {
} }
internal override SocketIoFacade Socket internal override ISocketConnection Socket
{ {
get get
{ {
@@ -41,19 +40,13 @@
var isUnPacked = ElectronNetRuntime.StartupMethod.IsUnpackaged(); var isUnPacked = ElectronNetRuntime.StartupMethod.IsUnpackaged();
var electronBinaryName = ElectronNetRuntime.ElectronExecutable; var electronBinaryName = ElectronNetRuntime.ElectronExecutable;
var args = string.Format("{0} {1}", ElectronNetRuntime.ElectronExtraArguments, Environment.CommandLine).Trim(); var args = string.Format("{0} {1}", ElectronNetRuntime.ElectronExtraArguments, Environment.CommandLine).Trim();
this.port = ElectronNetRuntime.ElectronSocketPort; var port = ElectronNetRuntime.ElectronSocketPort ?? 0;
if (!this.port.HasValue)
{
this.port = PortHelper.GetFreePort(ElectronNetRuntime.DefaultSocketPort);
ElectronNetRuntime.ElectronSocketPort = this.port;
}
Console.Error.WriteLine("[StartCore]: isUnPacked: {0}", isUnPacked); Console.Error.WriteLine("[StartCore]: isUnPacked: {0}", isUnPacked);
Console.Error.WriteLine("[StartCore]: electronBinaryName: {0}", electronBinaryName); Console.Error.WriteLine("[StartCore]: electronBinaryName: {0}", electronBinaryName);
Console.Error.WriteLine("[StartCore]: args: {0}", args); Console.Error.WriteLine("[StartCore]: args: {0}", args);
this.electronProcess = new ElectronProcessActive(isUnPacked, electronBinaryName, args, this.port.Value); this.electronProcess = new ElectronProcessActive(isUnPacked, electronBinaryName, args, port);
this.electronProcess.Ready += this.ElectronProcess_Ready; this.electronProcess.Ready += this.ElectronProcess_Ready;
this.electronProcess.Stopped += this.ElectronProcess_Stopped; this.electronProcess.Stopped += this.ElectronProcess_Stopped;
@@ -63,8 +56,10 @@
private void ElectronProcess_Ready(object sender, EventArgs e) private void ElectronProcess_Ready(object sender, EventArgs e)
{ {
var port = ElectronNetRuntime.ElectronSocketPort.Value;
var token = ElectronNetRuntime.ElectronAuthToken;
this.TransitionState(LifetimeState.Started); this.TransitionState(LifetimeState.Started);
this.socketBridge = new SocketBridgeService(this.port!.Value); this.socketBridge = new SocketBridgeService(port, token);
this.socketBridge.Ready += this.SocketBridge_Ready; this.socketBridge.Ready += this.SocketBridge_Ready;
this.socketBridge.Stopped += this.SocketBridge_Stopped; this.socketBridge.Stopped += this.SocketBridge_Stopped;
this.socketBridge.Start(); this.socketBridge.Start();

View File

@@ -11,13 +11,12 @@
{ {
private ElectronProcessBase electronProcess; private ElectronProcessBase electronProcess;
private SocketBridgeService socketBridge; private SocketBridgeService socketBridge;
private int? port;
public RuntimeControllerElectronFirst() public RuntimeControllerElectronFirst()
{ {
} }
internal override SocketIoFacade Socket internal override ISocketConnection Socket
{ {
get get
{ {
@@ -36,12 +35,8 @@
protected override Task StartCore() protected override Task StartCore()
{ {
this.port = ElectronNetRuntime.ElectronSocketPort; var port = ElectronNetRuntime.ElectronSocketPort.Value;
var token = ElectronNetRuntime.ElectronAuthToken;
if (!this.port.HasValue)
{
throw new Exception("No port has been specified by Electron!");
}
if (!ElectronNetRuntime.ElectronProcessId.HasValue) if (!ElectronNetRuntime.ElectronProcessId.HasValue)
{ {
@@ -49,7 +44,7 @@
} }
this.TransitionState(LifetimeState.Starting); this.TransitionState(LifetimeState.Starting);
this.socketBridge = new SocketBridgeService(this.port!.Value); this.socketBridge = new SocketBridgeService(port, token);
this.socketBridge.Ready += this.SocketBridge_Ready; this.socketBridge.Ready += this.SocketBridge_Ready;
this.socketBridge.Stopped += this.SocketBridge_Stopped; this.socketBridge.Stopped += this.SocketBridge_Stopped;
this.socketBridge.Start(); this.socketBridge.Start();

View File

@@ -8,7 +8,7 @@
public string RuntimeIdentifier { get; internal set; } public string RuntimeIdentifier { get; internal set; }
public string ElectronSingleInstance { get; internal set; } public bool ElectronSingleInstance { get; internal set; }
public string Title { get; internal set; } public string Title { get; internal set; }

View File

@@ -1,12 +1,16 @@
namespace ElectronNET.Runtime.Services.ElectronProcess namespace ElectronNET.Runtime.Services.ElectronProcess
{ {
using ElectronNET.Common;
using ElectronNET.Runtime.Data;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using ElectronNET.Common;
using ElectronNET.Runtime.Data;
/// <summary> /// <summary>
/// Launches and manages the Electron app process. /// Launches and manages the Electron app process.
@@ -14,6 +18,8 @@
[Localizable(false)] [Localizable(false)]
internal class ElectronProcessActive : ElectronProcessBase internal class ElectronProcessActive : ElectronProcessBase
{ {
private readonly Regex extractor = new Regex("^Electron Socket: listening on port (\\d+) at .* using ([a-f0-9]+)$");
private readonly bool isUnpackaged; private readonly bool isUnpackaged;
private readonly string electronBinaryName; private readonly string electronBinaryName;
private readonly string extraArguments; private readonly string extraArguments;
@@ -33,14 +39,42 @@
this.socketPort = socketPort; this.socketPort = socketPort;
} }
protected override Task StartCore() protected override async Task StartCore()
{ {
var dir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); var dir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
string startCmd, args, workingDir; string startCmd, args, workingDir;
if (this.isUnpackaged) if (this.isUnpackaged)
{ {
this.CheckRuntimeIdentifier();
var electrondir = Path.Combine(dir.FullName, ".electron"); var electrondir = Path.Combine(dir.FullName, ".electron");
ProcessRunner chmodRunner = null;
try
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var distFolder = Path.Combine(electrondir, "node_modules", "electron", "dist");
chmodRunner = new ProcessRunner("ElectronRunner-Chmod");
chmodRunner.Run("chmod", "-R +x " + distFolder, electrondir);
await chmodRunner.WaitForExitAsync().ConfigureAwait(true);
if (chmodRunner.LastExitCode != 0)
{
throw new Exception("Failed to set executable permissions on Electron dist folder.");
}
}
}
catch (Exception ex)
{
Console.Error.WriteLine("[StartCore]: Exception: " + chmodRunner?.StandardError);
Console.Error.WriteLine("[StartCore]: Exception: " + chmodRunner?.StandardOutput);
Console.Error.WriteLine("[StartCore]: Exception: " + ex);
}
startCmd = Path.Combine(electrondir, "node_modules", "electron", "dist", "electron"); startCmd = Path.Combine(electrondir, "node_modules", "electron", "dist", "electron");
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
@@ -53,17 +87,70 @@
} }
else else
{ {
dir = dir.Parent?.Parent; dir = dir.Parent!.Parent!;
startCmd = Path.Combine(dir.FullName, this.electronBinaryName); startCmd = Path.Combine(dir.FullName, this.electronBinaryName);
args = $"-dotnetpacked -electronforcedport={this.socketPort:D} " + this.extraArguments; args = $"-dotnetpacked -electronforcedport={this.socketPort:D} " + this.extraArguments;
workingDir = dir.FullName; workingDir = dir.FullName;
} }
// We don't await this in order to let the state transition to "Starting" // We don't await this in order to let the state transition to "Starting"
Task.Run(async () => await this.StartInternal(startCmd, args, workingDir).ConfigureAwait(false)); Task.Run(async () => await this.StartInternal(startCmd, args, workingDir).ConfigureAwait(false));
}
return Task.CompletedTask; private void CheckRuntimeIdentifier()
{
var buildInfoRid = ElectronNetRuntime.BuildInfo.RuntimeIdentifier;
if (string.IsNullOrEmpty(buildInfoRid))
{
return;
}
var osPart = buildInfoRid.Split('-').First();
var mismatch = false;
switch (osPart)
{
case "win":
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
mismatch = true;
}
break;
case "linux":
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
mismatch = true;
}
break;
case "osx":
if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
mismatch = true;
}
break;
case "freebsd":
if (!RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
{
mismatch = true;
}
break;
}
if (mismatch)
{
throw new PlatformNotSupportedException($"This Electron.NET application was built for '{buildInfoRid}'. It cannot run on this platform.");
}
} }
protected override Task StopCore() protected override Task StopCore()
@@ -72,20 +159,59 @@
return Task.CompletedTask; return Task.CompletedTask;
} }
private async Task StartInternal(string startCmd, string args, string directoriy) private async Task StartInternal(string startCmd, string args, string directory)
{ {
var tcs = new TaskCompletionSource();
using var cts = new CancellationTokenSource(2 * 60_000); // cancel after 2 minutes
using var _ = cts.Token.Register(() =>
{
// Time is over - let's kill the process and move on
this.process.Cancel();
// We don't want to raise exceptions here - just pass the barrier
tcs.TrySetResult();
});
void Read_SocketIO_Parameters(object sender, string line)
{
// Look for "Electron Socket: listening on port %s at ..."
var match = extractor.Match(line);
if (match?.Success ?? false)
{
var port = int.Parse(match.Groups[1].Value);
var token = match.Groups[2].Value;
this.process.LineReceived -= Read_SocketIO_Parameters;
ElectronNetRuntime.ElectronAuthToken = token;
ElectronNetRuntime.ElectronSocketPort = port;
tcs.SetResult();
}
}
void Monitor_SocketIO_Failure(object sender, EventArgs e)
{
// We don't want to raise exceptions here - just pass the barrier
if (tcs.Task.IsCompleted)
{
this.Process_Exited(sender, e);
}
else
{
tcs.TrySetResult();
}
}
try try
{ {
await Task.Delay(10.ms()).ConfigureAwait(false);
Console.Error.WriteLine("[StartInternal]: startCmd: {0}", startCmd); Console.Error.WriteLine("[StartInternal]: startCmd: {0}", startCmd);
Console.Error.WriteLine("[StartInternal]: args: {0}", args); Console.Error.WriteLine("[StartInternal]: args: {0}", args);
this.process = new ProcessRunner("ElectronRunner"); this.process = new ProcessRunner("ElectronRunner");
this.process.ProcessExited += this.Process_Exited; this.process.ProcessExited += Monitor_SocketIO_Failure;
this.process.Run(startCmd, args, directoriy); this.process.LineReceived += Read_SocketIO_Parameters;
this.process.Run(startCmd, args, directory);
await Task.Delay(500.ms()).ConfigureAwait(false); await tcs.Task.ConfigureAwait(false);
Console.Error.WriteLine("[StartInternal]: after run:"); Console.Error.WriteLine("[StartInternal]: after run:");
@@ -95,11 +221,11 @@
Console.Error.WriteLine("[StartInternal]: Process is not running: " + this.process.StandardOutput); Console.Error.WriteLine("[StartInternal]: Process is not running: " + this.process.StandardOutput);
Task.Run(() => this.TransitionState(LifetimeState.Stopped)); Task.Run(() => this.TransitionState(LifetimeState.Stopped));
throw new Exception("Failed to launch the Electron process.");
} }
else
this.TransitionState(LifetimeState.Ready); {
this.TransitionState(LifetimeState.Ready);
}
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -8,22 +8,24 @@
internal class SocketBridgeService : LifetimeServiceBase internal class SocketBridgeService : LifetimeServiceBase
{ {
private readonly int socketPort; private readonly int socketPort;
private readonly string authorization;
private readonly string socketUrl; private readonly string socketUrl;
private SocketIoFacade socket; private SocketIOConnection socket;
public SocketBridgeService(int socketPort) public SocketBridgeService(int socketPort, string authorization)
{ {
this.socketPort = socketPort; this.socketPort = socketPort;
this.authorization = authorization;
this.socketUrl = $"http://localhost:{this.socketPort}"; this.socketUrl = $"http://localhost:{this.socketPort}";
} }
public int SocketPort => this.socketPort; public int SocketPort => this.socketPort;
internal SocketIoFacade Socket => this.socket; internal SocketIOConnection Socket => this.socket;
protected override Task StartCore() protected override Task StartCore()
{ {
this.socket = new SocketIoFacade(this.socketUrl); this.socket = new SocketIOConnection(this.socketUrl, this.authorization);
this.socket.BridgeConnected += this.Socket_BridgeConnected; this.socket.BridgeConnected += this.Socket_BridgeConnected;
this.socket.BridgeDisconnected += this.Socket_BridgeDisconnected; this.socket.BridgeDisconnected += this.Socket_BridgeDisconnected;
Task.Run(this.Connect); Task.Run(this.Connect);
@@ -33,7 +35,7 @@
protected override Task StopCore() protected override Task StopCore()
{ {
this.socket.DisposeSocket(); this.socket.Dispose();
return Task.CompletedTask; return Task.CompletedTask;
} }

View File

@@ -106,6 +106,20 @@
Console.WriteLine("Electron Process ID: " + result); Console.WriteLine("Electron Process ID: " + result);
} }
} }
var authTokenArg = argsList.FirstOrDefault(e => e.Contains(ElectronNetRuntime.ElectronAuthTokenArgumentName, StringComparison.OrdinalIgnoreCase));
if (authTokenArg != null)
{
var parts = authTokenArg.Split('=', StringSplitOptions.TrimEntries);
if (parts.Length > 1 && !string.IsNullOrWhiteSpace(parts[1]))
{
var result = parts[1];
ElectronNetRuntime.ElectronAuthToken = result;
Console.WriteLine("Use Auth Token: " + result);
}
}
} }
private void SetElectronExecutable() private void SetElectronExecutable()
@@ -165,13 +179,9 @@
ElectronNetRuntime.DotnetAppType = DotnetAppType.AspNetCoreApp; ElectronNetRuntime.DotnetAppType = DotnetAppType.AspNetCoreApp;
} }
if (isSingleInstance?.Length > 0 && bool.TryParse(isSingleInstance, out var isSingleInstanceActive) && isSingleInstanceActive) if (bool.TryParse(isSingleInstance, out var parsedBool))
{ {
buildInfo.ElectronSingleInstance = "yes"; buildInfo.ElectronSingleInstance = parsedBool;
}
else
{
buildInfo.ElectronSingleInstance = "no";
} }
if (httpPort?.Length > 0 && int.TryParse(httpPort, out var port)) if (httpPort?.Length > 0 && int.TryParse(httpPort, out var port))

View File

@@ -44,5 +44,98 @@
return builder; return builder;
} }
/// <summary>
/// Adds Electron.NET support to the current ASP.NET Core application and registers an application-ready callback.
/// </summary>
/// <param name="builder">The <see cref="WebApplicationBuilder"/> to extend.</param>
/// <param name="args">The command-line arguments passed to the process, forwarded to Electron.</param>
/// <param name="onAppReadyCallback">
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
/// </param>
/// <returns>
/// The same <see cref="WebApplicationBuilder"/> instance to enable fluent configuration.
/// </returns>
/// <example>
/// <code language="csharp">
/// var builder = WebApplication.CreateBuilder(args)
/// .UseElectron(args, async (processArgs) =>
/// {
/// // Create the main browser window or perform other startup tasks.
/// });
///
/// var app = builder.Build();
/// app.MapRazorPages();
/// app.Run();
/// </code>
/// </example>
public static WebApplicationBuilder UseElectron(this WebApplicationBuilder builder, string[] args, Func<string[], Task> onAppReadyCallback)
{
builder.WebHost.UseElectron(args, onAppReadyCallback);
return builder;
}
/// <summary>
/// Adds Electron.NET support to the current ASP.NET Core application and registers an application-ready callback.
/// </summary>
/// <param name="builder">The <see cref="WebApplicationBuilder"/> to extend.</param>
/// <param name="args">The command-line arguments passed to the process, forwarded to Electron.</param>
/// <param name="onAppReadyCallback">
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
/// </param>
/// <returns>
/// The same <see cref="WebApplicationBuilder"/> instance to enable fluent configuration.
/// </returns>
/// <example>
/// <code language="csharp">
/// var builder = WebApplication.CreateBuilder(args)
/// .UseElectron(args, async (serviceProvider) =>
/// {
/// // Create the main browser window or perform other startup tasks.
/// });
///
/// var app = builder.Build();
/// app.MapRazorPages();
/// app.Run();
/// </code>
/// </example>
public static WebApplicationBuilder UseElectron(this WebApplicationBuilder builder, string[] args, Func<IServiceProvider, Task> onAppReadyCallback)
{
builder.WebHost.UseElectron(args, onAppReadyCallback);
return builder;
}
/// <summary>
/// Adds Electron.NET support to the current ASP.NET Core application and registers an application-ready callback.
/// </summary>
/// <param name="builder">The <see cref="WebApplicationBuilder"/> to extend.</param>
/// <param name="args">The command-line arguments passed to the process, forwarded to Electron.</param>
/// <param name="onAppReadyCallback">
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
/// </param>
/// <returns>
/// The same <see cref="WebApplicationBuilder"/> instance to enable fluent configuration.
/// </returns>
/// <example>
/// <code language="csharp">
/// var builder = WebApplication.CreateBuilder(args)
/// .UseElectron(args, async (serviceProvider, processArgs) =>
/// {
/// // Create the main browser window or perform other startup tasks.
/// });
///
/// var app = builder.Build();
/// app.MapRazorPages();
/// app.Run();
/// </code>
/// </example>
public static WebApplicationBuilder UseElectron(this WebApplicationBuilder builder, string[] args, Func<IServiceProvider, string[], Task> onAppReadyCallback)
{
builder.WebHost.UseElectron(args, onAppReadyCallback);
return builder;
}
} }
} }

View File

@@ -1,6 +1,7 @@
namespace ElectronNET.API namespace ElectronNET.API
{ {
using System; using System;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using ElectronNET.AspNet; using ElectronNET.AspNet;
@@ -10,6 +11,7 @@
using ElectronNET.Runtime.Helpers; using ElectronNET.Runtime.Helpers;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
/// <summary> /// <summary>
/// Provides extension methods for <see cref="IWebHostBuilder"/> to enable Electron.NET /// Provides extension methods for <see cref="IWebHostBuilder"/> to enable Electron.NET
@@ -59,30 +61,179 @@
/// </example> /// </example>
public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func<Task> onAppReadyCallback) public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func<Task> onAppReadyCallback)
{ {
ElectronNetRuntime.OnAppReadyCallback = onAppReadyCallback; builder.ConfigureServices(services =>
{
services.AddSingleton<IAppReadyCallbackResolver>(_ => new AppReadyCallbackResolver(onAppReadyCallback));
});
return UseElectronCore(builder, args);
}
/// <summary>
/// Adds Electron.NET support to the current ASP.NET Core web host and registers an application-ready callback.
/// </summary>
/// <param name="builder">The <see cref="IWebHostBuilder"/> to extend.</param>
/// <param name="args">The command-line arguments passed to the process.</param>
/// <param name="onAppReadyCallback">
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
/// </param>
/// <returns>
/// The same <see cref="IWebHostBuilder"/> instance to enable fluent configuration.
/// </returns>
/// <example>
/// <code language="csharp">
/// using Microsoft.AspNetCore.Hosting;
/// using Microsoft.Extensions.Hosting;
/// using ElectronNET.API;
///
/// public class Program
/// {
/// public static void Main(string[] args)
/// {
/// Host.CreateDefaultBuilder(args)
/// .ConfigureWebHostDefaults(webBuilder =>
/// {
/// webBuilder.UseStartup&lt;Startup&gt;();
/// webBuilder.UseElectron(args, async (processArgs) =>
/// {
/// // Create the main browser window or perform other startup tasks.
/// });
/// })
/// .Build()
/// .Run();
/// }
/// }
/// </code>
/// </example>
public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func<string[], Task> onAppReadyCallback)
{
builder.ConfigureServices(services =>
{
services.AddSingleton<IAppReadyCallbackResolver>(_ => new AppReadyCallbackResolver(args, onAppReadyCallback));
});
return UseElectronCore(builder, args);
}
/// <summary>
/// Adds Electron.NET support to the current ASP.NET Core web host and registers an application-ready callback.
/// </summary>
/// <param name="builder">The <see cref="IWebHostBuilder"/> to extend.</param>
/// <param name="args">The command-line arguments passed to the process.</param>
/// <param name="onAppReadyCallback">
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
/// </param>
/// <returns>
/// The same <see cref="IWebHostBuilder"/> instance to enable fluent configuration.
/// </returns>
/// <example>
/// <code language="csharp">
/// using Microsoft.AspNetCore.Hosting;
/// using Microsoft.Extensions.Hosting;
/// using ElectronNET.API;
///
/// public class Program
/// {
/// public static void Main(string[] args)
/// {
/// Host.CreateDefaultBuilder(args)
/// .ConfigureWebHostDefaults(webBuilder =>
/// {
/// webBuilder.UseStartup&lt;Startup&gt;();
/// webBuilder.UseElectron(args, async (serviceProvider) =>
/// {
/// // Create the main browser window or perform other startup tasks.
/// });
/// })
/// .Build()
/// .Run();
/// }
/// }
/// </code>
/// </example>
public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func<IServiceProvider, Task> onAppReadyCallback)
{
builder.ConfigureServices(services =>
{
services.AddSingleton<IAppReadyCallbackResolver>(provider => new AppReadyCallbackResolver(provider, onAppReadyCallback));
});
return UseElectronCore(builder, args);
}
/// <summary>
/// Adds Electron.NET support to the current ASP.NET Core web host and registers an application-ready callback.
/// </summary>
/// <param name="builder">The <see cref="IWebHostBuilder"/> to extend.</param>
/// <param name="args">The command-line arguments passed to the process.</param>
/// <param name="onAppReadyCallback">
/// An asynchronous callback invoked when the Electron app is ready. Use this to create windows or perform initialization.
/// </param>
/// <returns>
/// The same <see cref="IWebHostBuilder"/> instance to enable fluent configuration.
/// </returns>
/// <example>
/// <code language="csharp">
/// using Microsoft.AspNetCore.Hosting;
/// using Microsoft.Extensions.Hosting;
/// using ElectronNET.API;
///
/// public class Program
/// {
/// public static void Main(string[] args)
/// {
/// Host.CreateDefaultBuilder(args)
/// .ConfigureWebHostDefaults(webBuilder =>
/// {
/// webBuilder.UseStartup&lt;Startup&gt;();
/// webBuilder.UseElectron(args, async (serviceProvider, processArgs) =>
/// {
/// // Create the main browser window or perform other startup tasks.
/// });
/// })
/// .Build()
/// .Run();
/// }
/// }
/// </code>
/// </example>
public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func<IServiceProvider, string[], Task> onAppReadyCallback)
{
builder.ConfigureServices(services =>
{
services.AddSingleton<IAppReadyCallbackResolver>(provider => new AppReadyCallbackResolver(provider, args, onAppReadyCallback));
});
return UseElectronCore(builder, args);
}
private static IWebHostBuilder UseElectronCore(IWebHostBuilder builder, string[] args)
{
// no matter how this is set - let's unset to prevent Electron not starting as expected // no matter how this is set - let's unset to prevent Electron not starting as expected
// e.g., VS Code sets this env variable, but this will cause `require("electron")` to not // e.g., VS Code sets this env variable, but this will cause `require("electron")` to not
// work as expected, see issue #952 // work as expected, see issue #952
Environment.SetEnvironmentVariable("ELECTRON_RUN_AS_NODE", null); Environment.SetEnvironmentVariable("ELECTRON_RUN_AS_NODE", null);
var webPort = PortHelper.GetFreePort(ElectronNetRuntime.AspNetWebPort ?? ElectronNetRuntime.DefaultWebPort); var webPort = ElectronNetRuntime.AspNetWebPort ?? 0;
ElectronNetRuntime.AspNetWebPort = webPort;
// check for the content folder if its exists in base director otherwise no need to include // check for the content folder if its exists in base director otherwise no need to include
// It was used before because we are publishing the project which copies everything to bin folder and contentroot wwwroot was folder there. // It was used before because we are publishing the project which copies everything to bin folder and contentroot wwwroot was folder there.
// now we have implemented the live reload if app is run using /watch then we need to use the default project path. // now we have implemented the live reload if app is run using /watch then we need to use the default project path.
// For port 0 (dynamic port assignment), Kestrel requires binding to specific IP (127.0.0.1) not localhost
var host = webPort == 0 ? "127.0.0.1" : "localhost";
if (Directory.Exists($"{AppDomain.CurrentDomain.BaseDirectory}\\wwwroot")) if (Directory.Exists($"{AppDomain.CurrentDomain.BaseDirectory}\\wwwroot"))
{ {
builder = builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) builder = builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory)
.UseUrls("http://localhost:" + webPort); .UseUrls($"http://{host}:{webPort}");
} }
else else
{ {
builder = builder.UseUrls("http://localhost:" + webPort); builder = builder.UseUrls($"http://{host}:{webPort}");
} }
builder = builder.ConfigureServices(services => builder = builder.ConfigureServices((context, services) =>
{ {
services.AddTransient<IStartupFilter, ServerReadyStartupFilter>(); services.AddTransient<IStartupFilter, ServerReadyStartupFilter>();
services.AddSingleton<AspNetLifetimeAdapter>(); services.AddSingleton<AspNetLifetimeAdapter>();

View File

@@ -0,0 +1,100 @@
namespace ElectronNET.AspNet.Middleware
{
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using ElectronNET.AspNet.Services;
/// <summary>
/// Middleware that validates authentication for all Electron requests.
/// Checks for authentication cookie or token query parameter on first request.
/// Sets HttpOnly cookie for subsequent requests.
///
/// Security Model:
/// - First request includes token as query parameter (?token=guid)
/// - Middleware validates token and sets secure HttpOnly cookie
/// - Subsequent requests use cookie (no token in URL)
/// - HTTP endpoints protected
/// </summary>
public class ElectronAuthenticationMiddleware
{
private readonly RequestDelegate _next;
private readonly IElectronAuthenticationService _authService;
private readonly ILogger<ElectronAuthenticationMiddleware> _logger;
private const string AuthCookieName = "ElectronAuth";
public ElectronAuthenticationMiddleware(
RequestDelegate next,
IElectronAuthenticationService authService,
ILogger<ElectronAuthenticationMiddleware> logger)
{
_next = next;
_authService = authService;
_logger = logger;
}
public async Task InvokeAsync(HttpContext context)
{
var path = context.Request.Path.Value;
// Check if authentication cookie exists
var authCookie = context.Request.Cookies[AuthCookieName];
if (!string.IsNullOrEmpty(authCookie))
{
// Cookie present - validate it
if (_authService.ValidateToken(authCookie))
{
await _next(context);
return;
}
else
{
// Invalid cookie - reject
_logger.LogWarning("Authentication failed: Invalid cookie for path {Path} from {RemoteIp}", path, context.Connection.RemoteIpAddress);
context.Response.StatusCode = 401;
await context.Response.WriteAsync("Unauthorized: Invalid authentication");
return;
}
}
// No cookie - check for token in query string (first-time authentication)
var token = context.Request.Query["token"].ToString();
if (!string.IsNullOrEmpty(token))
{
if (_authService.ValidateToken(token))
{
// Valid token - set cookie for future requests
_logger.LogInformation("Authentication successful: Setting cookie for path {Path}", path);
context.Response.Cookies.Append(AuthCookieName, token, new CookieOptions
{
HttpOnly = true, // Prevent JavaScript access (XSS protection)
SameSite = SameSiteMode.Strict, // CSRF protection
Path = "/", // Valid for all routes
Secure = false, // False because localhost is HTTP
IsEssential = true // Required for app to function
});
await _next(context);
return;
}
else
{
// Invalid token - reject
_logger.LogWarning("Authentication failed: Invalid token (prefix: {TokenPrefix}...) for path {Path} from {RemoteIp}", token.Length > 8 ? token.Substring(0, 8) : token, path, context.Connection.RemoteIpAddress);
context.Response.StatusCode = 401;
await context.Response.WriteAsync("Unauthorized: Invalid authentication");
return;
}
}
// Neither cookie nor valid token present - reject
_logger.LogWarning("Authentication failed: No cookie or token provided for path {Path} from {RemoteIp}", path, context.Connection.RemoteIpAddress);
context.Response.StatusCode = 401;
await context.Response.WriteAsync("Unauthorized: Authentication required");
}
}
}

View File

@@ -1,8 +1,13 @@
namespace ElectronNET.AspNet.Runtime namespace ElectronNET.AspNet.Runtime
{ {
using System; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.Extensions.DependencyInjection;
using ElectronNET.API; using ElectronNET.API;
using ElectronNET.AspNet.Services;
using ElectronNET.Common; using ElectronNET.Common;
using ElectronNET.Runtime.Controllers; using ElectronNET.Runtime.Controllers;
using ElectronNET.Runtime.Data; using ElectronNET.Runtime.Data;
@@ -10,12 +15,18 @@
internal abstract class RuntimeControllerAspNetBase : RuntimeControllerBase internal abstract class RuntimeControllerAspNetBase : RuntimeControllerBase
{ {
private readonly IServer server;
private readonly AspNetLifetimeAdapter aspNetLifetimeAdapter; private readonly AspNetLifetimeAdapter aspNetLifetimeAdapter;
private readonly IAppReadyCallbackResolver callbackResolver;
private readonly IElectronAuthenticationService authenticationService;
private SocketBridgeService socketBridge; private SocketBridgeService socketBridge;
protected RuntimeControllerAspNetBase(AspNetLifetimeAdapter aspNetLifetimeAdapter) protected RuntimeControllerAspNetBase(IServer server, AspNetLifetimeAdapter aspNetLifetimeAdapter, IAppReadyCallbackResolver callbackResolver, IElectronAuthenticationService authenticationService = null)
{ {
this.server = server;
this.aspNetLifetimeAdapter = aspNetLifetimeAdapter; this.aspNetLifetimeAdapter = aspNetLifetimeAdapter;
this.callbackResolver = callbackResolver;
this.authenticationService = authenticationService;
this.aspNetLifetimeAdapter.Ready += this.AspNetLifetimeAdapter_Ready; this.aspNetLifetimeAdapter.Ready += this.AspNetLifetimeAdapter_Ready;
this.aspNetLifetimeAdapter.Stopping += this.AspNetLifetimeAdapter_Stopping; this.aspNetLifetimeAdapter.Stopping += this.AspNetLifetimeAdapter_Stopping;
this.aspNetLifetimeAdapter.Stopped += this.AspNetLifetimeAdapter_Stopped; this.aspNetLifetimeAdapter.Stopped += this.AspNetLifetimeAdapter_Stopped;
@@ -25,7 +36,7 @@
internal override SocketBridgeService SocketBridge => this.socketBridge; internal override SocketBridgeService SocketBridge => this.socketBridge;
internal override SocketIoFacade Socket internal override ISocketConnection Socket
{ {
get get
{ {
@@ -38,9 +49,9 @@
} }
} }
protected void CreateSocketBridge(int port) protected void CreateSocketBridge(int port, string authorization)
{ {
this.socketBridge = new SocketBridgeService(port); this.socketBridge = new SocketBridgeService(port, authorization);
this.socketBridge.Ready += this.SocketBridge_Ready; this.socketBridge.Ready += this.SocketBridge_Ready;
this.socketBridge.Stopped += this.SocketBridge_Stopped; this.socketBridge.Stopped += this.SocketBridge_Stopped;
this.socketBridge.Start(); this.socketBridge.Start();
@@ -52,6 +63,15 @@
this.ElectronProcess.IsReady() && this.ElectronProcess.IsReady() &&
this.aspNetLifetimeAdapter.IsReady()) this.aspNetLifetimeAdapter.IsReady())
{ {
var token = ElectronNetRuntime.ElectronAuthToken;
var serverAddressesFeature = this.server.Features.Get<IServerAddressesFeature>();
var address = serverAddressesFeature.Addresses.First();
var uri = new Uri(address);
// Only if somebody registered an IElectronAuthenticationService service - otherwise we do not care
this.authenticationService?.SetExpectedToken(token);
ElectronNetRuntime.AspNetWebPort = uri.Port;
this.TransitionState(LifetimeState.Ready); this.TransitionState(LifetimeState.Ready);
Task.Run(this.RunReadyCallback); Task.Run(this.RunReadyCallback);
} }
@@ -112,15 +132,15 @@
private async Task RunReadyCallback() private async Task RunReadyCallback()
{ {
if (ElectronNetRuntime.OnAppReadyCallback == null) if (!callbackResolver.HasCallback)
{ {
Console.WriteLine("Warning: Non OnReadyCallback provided in UseElectron() setup."); Console.WriteLine("Warning: No OnReadyCallback provided in UseElectron() setup.");
return; return;
} }
try try
{ {
await ElectronNetRuntime.OnAppReadyCallback().ConfigureAwait(false); await callbackResolver.Invoke().ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -2,6 +2,9 @@
{ {
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Security.Principal;
using Microsoft.AspNetCore.Hosting.Server;
using ElectronNET.AspNet.Services;
using ElectronNET.Common; using ElectronNET.Common;
using ElectronNET.Runtime.Data; using ElectronNET.Runtime.Data;
using ElectronNET.Runtime.Helpers; using ElectronNET.Runtime.Helpers;
@@ -10,9 +13,8 @@
internal class RuntimeControllerAspNetDotnetFirst : RuntimeControllerAspNetBase internal class RuntimeControllerAspNetDotnetFirst : RuntimeControllerAspNetBase
{ {
private ElectronProcessBase electronProcess; private ElectronProcessBase electronProcess;
private int? port;
public RuntimeControllerAspNetDotnetFirst(AspNetLifetimeAdapter aspNetLifetimeAdapter) : base(aspNetLifetimeAdapter) public RuntimeControllerAspNetDotnetFirst(IServer server, AspNetLifetimeAdapter aspNetLifetimeAdapter, IAppReadyCallbackResolver callbackResolver, IElectronAuthenticationService authenticationService = null) : base(server, aspNetLifetimeAdapter, callbackResolver, authenticationService)
{ {
} }
@@ -23,15 +25,9 @@
var isUnPacked = ElectronNetRuntime.StartupMethod.IsUnpackaged(); var isUnPacked = ElectronNetRuntime.StartupMethod.IsUnpackaged();
var electronBinaryName = ElectronNetRuntime.ElectronExecutable; var electronBinaryName = ElectronNetRuntime.ElectronExecutable;
var args = Environment.CommandLine; var args = Environment.CommandLine;
this.port = ElectronNetRuntime.ElectronSocketPort; var port = ElectronNetRuntime.ElectronSocketPort ?? 0;
if (!this.port.HasValue) this.electronProcess = new ElectronProcessActive(isUnPacked, electronBinaryName, args, port);
{
this.port = PortHelper.GetFreePort(ElectronNetRuntime.DefaultSocketPort);
ElectronNetRuntime.ElectronSocketPort = this.port;
}
this.electronProcess = new ElectronProcessActive(isUnPacked, electronBinaryName, args, this.port.Value);
this.electronProcess.Ready += this.ElectronProcess_Ready; this.electronProcess.Ready += this.ElectronProcess_Ready;
this.electronProcess.Stopped += this.ElectronProcess_Stopped; this.electronProcess.Stopped += this.ElectronProcess_Stopped;
@@ -46,8 +42,10 @@
private void ElectronProcess_Ready(object sender, EventArgs e) private void ElectronProcess_Ready(object sender, EventArgs e)
{ {
var port = ElectronNetRuntime.ElectronSocketPort.Value;
var token = ElectronNetRuntime.ElectronAuthToken;
this.TransitionState(LifetimeState.Started); this.TransitionState(LifetimeState.Started);
this.CreateSocketBridge(this.port!.Value); this.CreateSocketBridge(port, token);
} }
private void ElectronProcess_Stopped(object sender, EventArgs e) private void ElectronProcess_Stopped(object sender, EventArgs e)

View File

@@ -2,15 +2,16 @@
{ {
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting.Server;
using ElectronNET.AspNet.Services;
using ElectronNET.Runtime.Data; using ElectronNET.Runtime.Data;
using ElectronNET.Runtime.Services.ElectronProcess; using ElectronNET.Runtime.Services.ElectronProcess;
internal class RuntimeControllerAspNetElectronFirst : RuntimeControllerAspNetBase internal class RuntimeControllerAspNetElectronFirst : RuntimeControllerAspNetBase
{ {
private ElectronProcessBase electronProcess; private ElectronProcessBase electronProcess;
private int? port;
public RuntimeControllerAspNetElectronFirst(AspNetLifetimeAdapter aspNetLifetimeAdapter) : base(aspNetLifetimeAdapter) public RuntimeControllerAspNetElectronFirst(IServer server, AspNetLifetimeAdapter aspNetLifetimeAdapter, IAppReadyCallbackResolver callbackResolver, IElectronAuthenticationService authenticationService = null) : base(server, aspNetLifetimeAdapter, callbackResolver, authenticationService)
{ {
} }
@@ -18,19 +19,15 @@
protected override Task StartCore() protected override Task StartCore()
{ {
this.port = ElectronNetRuntime.ElectronSocketPort; var port = ElectronNetRuntime.ElectronSocketPort.Value;
var token = ElectronNetRuntime.ElectronAuthToken;
if (!this.port.HasValue)
{
throw new Exception("No port has been specified by Electron!");
}
if (!ElectronNetRuntime.ElectronProcessId.HasValue) if (!ElectronNetRuntime.ElectronProcessId.HasValue)
{ {
throw new Exception("No electronPID has been specified by Electron!"); throw new Exception("No electronPID has been specified by Electron!");
} }
this.CreateSocketBridge(this.port!.Value); this.CreateSocketBridge(port, token);
this.electronProcess = new ElectronProcessPassive(ElectronNetRuntime.ElectronProcessId.Value); this.electronProcess = new ElectronProcessPassive(ElectronNetRuntime.ElectronProcessId.Value);
this.electronProcess.Stopped += this.ElectronProcess_Stopped; this.electronProcess.Stopped += this.ElectronProcess_Stopped;

View File

@@ -0,0 +1,46 @@
using System;
using System.Threading.Tasks;
namespace ElectronNET.AspNet.Runtime
{
internal class AppReadyCallbackResolver : IAppReadyCallbackResolver
{
private readonly Func<Task> _callback;
public AppReadyCallbackResolver()
{ }
public AppReadyCallbackResolver(Func<Task> callback)
{
_callback = callback;
}
public AppReadyCallbackResolver(string[] args, Func<string[], Task> callback)
{
if (callback != null)
{
_callback = () => callback.Invoke(args);
}
}
public AppReadyCallbackResolver(IServiceProvider serviceProvider, Func<IServiceProvider, Task> callback)
{
if (callback != null)
{
_callback = () => callback.Invoke(serviceProvider);
}
}
public AppReadyCallbackResolver(IServiceProvider serviceProvider, string[] args, Func<IServiceProvider, string[], Task> callback)
{
if (callback != null)
{
_callback = () => callback.Invoke(serviceProvider, args);
}
}
public bool HasCallback => _callback != null;
public Task Invoke() => _callback?.Invoke() ?? Task.CompletedTask;
}
}

View File

@@ -0,0 +1,11 @@
using System.Threading.Tasks;
namespace ElectronNET.AspNet.Runtime
{
internal interface IAppReadyCallbackResolver
{
public bool HasCallback { get; }
public Task Invoke();
}
}

View File

@@ -0,0 +1,53 @@
namespace ElectronNET.AspNet.Services
{
/// <summary>
/// Implementation of authentication service for Electron clients.
/// Stores and validates the authentication token to ensure only the spawned Electron process can connect.
/// </summary>
public class ElectronAuthenticationService : IElectronAuthenticationService
{
private string _expectedToken;
private readonly object _lock = new object();
/// <inheritdoc />
public void SetExpectedToken(string token)
{
lock (_lock)
{
_expectedToken = token;
}
}
/// <inheritdoc />
public bool ValidateToken(string token)
{
if (string.IsNullOrEmpty(token))
return false;
lock (_lock)
{
if (string.IsNullOrEmpty(_expectedToken))
return false;
// Constant-time comparison to prevent timing attacks
return ConstantTimeEquals(token, _expectedToken);
}
}
/// <summary>
/// Performs constant-time string comparison to prevent timing attacks.
/// </summary>
private static bool ConstantTimeEquals(string a, string b)
{
if (a == null || b == null || a.Length != b.Length)
return false;
var result = 0;
for (int i = 0; i < a.Length; i++)
{
result |= a[i] ^ b[i];
}
return result == 0;
}
}
}

View File

@@ -0,0 +1,24 @@
namespace ElectronNET.AspNet.Services
{
/// <summary>
/// Service for validating authentication tokens from Electron clients.
/// Used to ensure only the Electron process spawned by this .NET instance can connect.
/// </summary>
public interface IElectronAuthenticationService
{
/// <summary>
/// Sets the expected authentication token for this instance.
/// Should be called when launching Electron with the generated token.
/// </summary>
/// <param name="token">The authentication token</param>
void SetExpectedToken(string token);
/// <summary>
/// Validates an incoming token against the expected token.
/// Uses constant-time comparison to prevent timing attacks.
/// </summary>
/// <param name="token">The token to validate</param>
/// <returns>True if token is valid, false otherwise</returns>
bool ValidateToken(string token);
}
}

View File

@@ -70,7 +70,7 @@
<ProjectReference Include="..\ElectronNET.API\ElectronNET.API.csproj" Condition="$(ElectronNetDevMode)" /> <ProjectReference Include="..\ElectronNET.API\ElectronNET.API.csproj" Condition="$(ElectronNetDevMode)" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ElectronNET.Core" Version="0.3.0" Condition="'$(ElectronNetDevMode)' != 'true'" /> <PackageReference Include="ElectronNET.Core" Version="0.5.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
</ItemGroup> </ItemGroup>
<Import Project="..\ElectronNET\build\ElectronNET.Core.targets" Condition="$(ElectronNetDevMode)" /> <Import Project="..\ElectronNET\build\ElectronNET.Core.targets" Condition="$(ElectronNetDevMode)" />

View File

@@ -39,6 +39,15 @@
"undici-types": "~7.14.0" "undici-types": "~7.14.0"
} }
}, },
"node_modules/@types/ws": {
"version": "8.18.1",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz",
"integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/accepts": { "node_modules/accepts": {
"version": "1.3.8", "version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
@@ -101,20 +110,21 @@
} }
}, },
"node_modules/engine.io": { "node_modules/engine.io": {
"version": "6.6.4", "version": "6.6.8",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.4.tgz", "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.8.tgz",
"integrity": "sha512-ZCkIjSYNDyGn0R6ewHDtXgns/Zre/NT6Agvq1/WobF7JXgFff4SeDroKiCO3fNJreU9YG429Sc81o4w5ok/W5g==", "integrity": "sha512-2agL3ueZhqxoVrfmntO8yuVj+uNSlIOnhykYHk3Cq0ShYPdUjjUiSJrQvXjq01I9jAuI0Zl2YO8Evv5Mqytm5g==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/cors": "^2.8.12", "@types/cors": "^2.8.12",
"@types/node": ">=10.0.0", "@types/node": ">=10.0.0",
"@types/ws": "^8.5.12",
"accepts": "~1.3.4", "accepts": "~1.3.4",
"base64id": "2.0.0", "base64id": "2.0.0",
"cookie": "~0.7.2", "cookie": "~0.7.2",
"cors": "~2.8.5", "cors": "~2.8.5",
"debug": "~4.3.1", "debug": "~4.4.1",
"engine.io-parser": "~5.2.1", "engine.io-parser": "~5.2.1",
"ws": "~8.17.1" "ws": "~8.20.1"
}, },
"engines": { "engines": {
"node": ">=10.2.0" "node": ">=10.2.0"
@@ -129,6 +139,23 @@
"node": ">=10.0.0" "node": ">=10.0.0"
} }
}, },
"node_modules/engine.io/node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/mime-db": { "node_modules/mime-db": {
"version": "1.52.0", "version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
@@ -193,28 +220,62 @@
} }
}, },
"node_modules/socket.io-adapter": { "node_modules/socket.io-adapter": {
"version": "2.5.5", "version": "2.5.7",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.5.tgz", "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.7.tgz",
"integrity": "sha512-eLDQas5dzPgOWCk9GuuJC2lBqItuhKI4uxGgo9aIV7MYbk2h9Q6uULEh8WBzThoI7l+qU9Ast9fVUmkqPP9wYg==", "integrity": "sha512-e0LyK91f3cUxTmv95/KzoLg47+zF+s/sbxRGDNsyG4dmIP8ZSX8ax6byOxfJXeNNtS/8AZlfD+uP7gBeR7DLlg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"debug": "~4.3.4", "debug": "~4.4.1",
"ws": "~8.17.1" "ws": "~8.20.1"
}
},
"node_modules/socket.io-adapter/node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
} }
}, },
"node_modules/socket.io-parser": { "node_modules/socket.io-parser": {
"version": "4.2.4", "version": "4.2.6",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.6.tgz",
"integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", "integrity": "sha512-asJqbVBDsBCJx0pTqw3WfesSY0iRX+2xzWEWzrpcH7L6fLzrhyF8WPI8UaeM4YCuDfpwA/cgsdugMsmtz8EJeg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@socket.io/component-emitter": "~3.1.0", "@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.1" "debug": "~4.4.1"
}, },
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"
} }
}, },
"node_modules/socket.io-parser/node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.9.3", "version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
@@ -245,9 +306,9 @@
} }
}, },
"node_modules/ws": { "node_modules/ws": {
"version": "8.17.1", "version": "8.20.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.20.1.tgz",
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "integrity": "sha512-It4dO0K5v//JtTXuPkfEOaI3uUN87iYPnqo/ZzqCoG3g8uhA66QUMs/SrM0YK7/NAu+r4LMh/9dq2A7k+rHs+w==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.VisualStudio.JavaScript.Sdk/1.0.4110890"> <Project Sdk="Microsoft.VisualStudio.JavaScript.Sdk/1.0.3864779">
<ItemGroup> <ItemGroup>
<None Include=".vscode\tasks.json" /> <None Include=".vscode\tasks.json" />
</ItemGroup> </ItemGroup>

View File

@@ -1,13 +1,14 @@
"use strict"; "use strict";
let isQuitWindowAllClosed = true, electronSocket; let isQuitWindowAllClosed = true;
let electronSocket;
let appWindowAllClosedEventId; let appWindowAllClosedEventId;
module.exports = (socket, app) => { module.exports = (socket, app) => {
electronSocket = socket; electronSocket = socket;
// By default, quit when all windows are closed // By default, quit when all windows are closed
app.on('window-all-closed', () => { app.on("window-all-closed", () => {
// On macOS it is common for applications and their menu bar // On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q // to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin' && isQuitWindowAllClosed) { if (process.platform !== "darwin" && isQuitWindowAllClosed) {
app.quit(); app.quit();
} }
else if (appWindowAllClosedEventId) { else if (appWindowAllClosedEventId) {
@@ -15,220 +16,224 @@ module.exports = (socket, app) => {
// - OR - // - OR -
// If the user has indicated NOT to quit when all windows are closed, // If the user has indicated NOT to quit when all windows are closed,
// emit the event. // emit the event.
electronSocket.emit('app-window-all-closed' + appWindowAllClosedEventId); electronSocket.emit("app-window-all-closed" + appWindowAllClosedEventId);
} }
}); });
socket.on('quit-app-window-all-closed', (quit) => { socket.on("quit-app-window-all-closed", (quit) => {
isQuitWindowAllClosed = quit; isQuitWindowAllClosed = quit;
}); });
socket.on('register-app-window-all-closed', (id) => { socket.on("register-app-window-all-closed", (id) => {
appWindowAllClosedEventId = id; appWindowAllClosedEventId = id;
}); });
socket.on('register-app-before-quit', (id) => { socket.on("register-app-before-quit", (id) => {
app.on('before-quit', (event) => { app.on("before-quit", (event) => {
event.preventDefault(); event.preventDefault();
electronSocket.emit('app-before-quit' + id); electronSocket.emit("app-before-quit" + id);
}); });
}); });
socket.on('register-app-will-quit', (id) => { socket.on("register-app-will-quit", (id) => {
app.on('will-quit', (event) => { app.on("will-quit", (event) => {
event.preventDefault(); event.preventDefault();
electronSocket.emit('app-will-quit' + id); electronSocket.emit("app-will-quit" + id);
}); });
}); });
socket.on('register-app-browser-window-blur', (id) => { socket.on("register-app-browser-window-blur", (id) => {
app.on('browser-window-blur', () => { app.on("browser-window-blur", () => {
electronSocket.emit('app-browser-window-blur' + id); electronSocket.emit("app-browser-window-blur" + id);
}); });
}); });
socket.on('register-app-browser-window-focus', (id) => { socket.on("register-app-browser-window-focus", (id) => {
app.on('browser-window-focus', () => { app.on("browser-window-focus", () => {
electronSocket.emit('app-browser-window-focus' + id); electronSocket.emit("app-browser-window-focus" + id);
}); });
}); });
socket.on('register-app-browser-window-created', (id) => { socket.on("register-app-browser-window-created", (id) => {
app.on('browser-window-created', () => { app.on("browser-window-created", () => {
electronSocket.emit('app-browser-window-created' + id); electronSocket.emit("app-browser-window-created" + id);
}); });
}); });
socket.on('register-app-web-contents-created', (id) => { socket.on("register-app-web-contents-created", (id) => {
app.on('web-contents-created', () => { app.on("web-contents-created", () => {
electronSocket.emit('app-web-contents-created' + id); electronSocket.emit("app-web-contents-created" + id);
}); });
}); });
socket.on('register-app-accessibility-support-changed', (id) => { socket.on("register-app-accessibility-support-changed", (id) => {
app.on('accessibility-support-changed', (event, accessibilitySupportEnabled) => { app.on("accessibility-support-changed", (event, accessibilitySupportEnabled) => {
electronSocket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled); electronSocket.emit("app-accessibility-support-changed" + id, accessibilitySupportEnabled);
}); });
}); });
socket.on('appQuit', () => { socket.on("appQuit", () => {
app.quit(); app.quit();
}); });
socket.on('appExit', (exitCode = 0) => { socket.on("appExit", (exitCode = 0) => {
app.exit(exitCode); app.exit(exitCode);
}); });
socket.on('appRelaunch', (options) => { socket.on("appRelaunch", (options) => {
app.relaunch(options); app.relaunch(options);
}); });
socket.on('appFocus', (options) => { socket.on("appFocus", (options) => {
app.focus(options); app.focus(options);
}); });
socket.on('appHide', () => { socket.on("appHide", () => {
app.hide(); app.hide();
}); });
socket.on('appShow', () => { socket.on("appShow", () => {
app.show(); app.show();
}); });
socket.on('appGetAppPath', () => { socket.on("appGetAppPath", () => {
const path = app.getAppPath(); const path = app.getAppPath();
electronSocket.emit('appGetAppPathCompleted', path); electronSocket.emit("appGetAppPathCompleted", path);
}); });
socket.on('appSetAppLogsPath', (path) => { socket.on("appSetAppLogsPath", (path) => {
app.setAppLogsPath(path); app.setAppLogsPath(path);
}); });
socket.on('appGetPath', (name) => { socket.on("appGetPath", (name) => {
const path = app.getPath(name); const path = app.getPath(name);
electronSocket.emit('appGetPathCompleted', path); electronSocket.emit("appGetPathCompleted", path);
}); });
socket.on('appGetFileIcon', async (path, options) => { socket.on("appGetFileIcon", async (path, options) => {
let error = {}; let error = {};
if (options) { if (options) {
const nativeImage = await app.getFileIcon(path, options).catch((errorFileIcon) => error = errorFileIcon); const nativeImage = await app
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]); .getFileIcon(path, options)
.catch((errorFileIcon) => (error = errorFileIcon));
electronSocket.emit("appGetFileIconCompleted", [error, nativeImage]);
} }
else { else {
const nativeImage = await app.getFileIcon(path).catch((errorFileIcon) => error = errorFileIcon); const nativeImage = await app
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]); .getFileIcon(path)
.catch((errorFileIcon) => (error = errorFileIcon));
electronSocket.emit("appGetFileIconCompleted", [error, nativeImage]);
} }
}); });
socket.on('appSetPath', (name, path) => { socket.on("appSetPath", (name, path) => {
app.setPath(name, path); app.setPath(name, path);
}); });
socket.on('appGetVersion', () => { socket.on("appGetVersion", () => {
const version = app.getVersion(); const version = app.getVersion();
electronSocket.emit('appGetVersionCompleted', version); electronSocket.emit("appGetVersionCompleted", version);
}); });
socket.on('appGetName', () => { socket.on("appGetName", () => {
electronSocket.emit('appGetNameCompleted', app.name); electronSocket.emit("appGetNameCompleted", app.name);
}); });
socket.on('appSetName', (name) => { socket.on("appSetName", (name) => {
app.name = name; app.name = name;
}); });
socket.on('appGetLocale', () => { socket.on("appGetLocale", () => {
const locale = app.getLocale(); const locale = app.getLocale();
electronSocket.emit('appGetLocaleCompleted', locale); electronSocket.emit("appGetLocaleCompleted", locale);
}); });
socket.on('appAddRecentDocument', (path) => { socket.on("appAddRecentDocument", (path) => {
app.addRecentDocument(path); app.addRecentDocument(path);
}); });
socket.on('appClearRecentDocuments', () => { socket.on("appClearRecentDocuments", () => {
app.clearRecentDocuments(); app.clearRecentDocuments();
}); });
socket.on('appSetAsDefaultProtocolClient', (protocol, path, args) => { socket.on("appSetAsDefaultProtocolClient", (protocol, path, args) => {
const success = app.setAsDefaultProtocolClient(protocol, path, args); const success = app.setAsDefaultProtocolClient(protocol, path, args);
electronSocket.emit('appSetAsDefaultProtocolClientCompleted', success); electronSocket.emit("appSetAsDefaultProtocolClientCompleted", success);
}); });
socket.on('appRemoveAsDefaultProtocolClient', (protocol, path, args) => { socket.on("appRemoveAsDefaultProtocolClient", (protocol, path, args) => {
const success = app.removeAsDefaultProtocolClient(protocol, path, args); const success = app.removeAsDefaultProtocolClient(protocol, path, args);
electronSocket.emit('appRemoveAsDefaultProtocolClientCompleted', success); electronSocket.emit("appRemoveAsDefaultProtocolClientCompleted", success);
}); });
socket.on('appIsDefaultProtocolClient', (protocol, path, args) => { socket.on("appIsDefaultProtocolClient", (protocol, path, args) => {
const success = app.isDefaultProtocolClient(protocol, path, args); const success = app.isDefaultProtocolClient(protocol, path, args);
electronSocket.emit('appIsDefaultProtocolClientCompleted', success); electronSocket.emit("appIsDefaultProtocolClientCompleted", success);
}); });
socket.on('appSetUserTasks', (tasks) => { socket.on("appSetUserTasks", (tasks) => {
const success = app.setUserTasks(tasks); const success = app.setUserTasks(tasks);
electronSocket.emit('appSetUserTasksCompleted', success); electronSocket.emit("appSetUserTasksCompleted", success);
}); });
socket.on('appGetJumpListSettings', () => { socket.on("appGetJumpListSettings", () => {
const jumpListSettings = app.getJumpListSettings(); const jumpListSettings = app.getJumpListSettings();
electronSocket.emit('appGetJumpListSettingsCompleted', jumpListSettings); electronSocket.emit("appGetJumpListSettingsCompleted", jumpListSettings);
}); });
socket.on('appSetJumpList', (categories) => { socket.on("appSetJumpList", (categories) => {
app.setJumpList(categories); app.setJumpList(categories);
}); });
socket.on('appRequestSingleInstanceLock', () => { socket.on("appRequestSingleInstanceLock", () => {
const success = app.requestSingleInstanceLock(); const success = app.requestSingleInstanceLock();
electronSocket.emit('appRequestSingleInstanceLockCompleted', success); electronSocket.emit("appRequestSingleInstanceLockCompleted", success);
app.on('second-instance', (event, args = [], workingDirectory = '') => { app.on("second-instance", (event, args = [], workingDirectory = "") => {
electronSocket.emit('secondInstance', [args, workingDirectory]); electronSocket.emit("secondInstance", [args, workingDirectory]);
}); });
}); });
socket.on('appHasSingleInstanceLock', () => { socket.on("appHasSingleInstanceLock", () => {
const hasLock = app.hasSingleInstanceLock(); const hasLock = app.hasSingleInstanceLock();
electronSocket.emit('appHasSingleInstanceLockCompleted', hasLock); electronSocket.emit("appHasSingleInstanceLockCompleted", hasLock);
}); });
socket.on('appReleaseSingleInstanceLock', () => { socket.on("appReleaseSingleInstanceLock", () => {
app.releaseSingleInstanceLock(); app.releaseSingleInstanceLock();
}); });
socket.on('appSetUserActivity', (type, userInfo, webpageUrl) => { socket.on("appSetUserActivity", (type, userInfo, webpageUrl) => {
app.setUserActivity(type, userInfo, webpageUrl); app.setUserActivity(type, userInfo, webpageUrl);
}); });
socket.on('appGetCurrentActivityType', () => { socket.on("appGetCurrentActivityType", () => {
const activityType = app.getCurrentActivityType(); const activityType = app.getCurrentActivityType();
electronSocket.emit('appGetCurrentActivityTypeCompleted', activityType); electronSocket.emit("appGetCurrentActivityTypeCompleted", activityType);
}); });
socket.on('appInvalidateCurrentActivity', () => { socket.on("appInvalidateCurrentActivity", () => {
app.invalidateCurrentActivity(); app.invalidateCurrentActivity();
}); });
socket.on('appResignCurrentActivity', () => { socket.on("appResignCurrentActivity", () => {
app.resignCurrentActivity(); app.resignCurrentActivity();
}); });
socket.on('appSetAppUserModelId', (id) => { socket.on("appSetAppUserModelId", (id) => {
app.setAppUserModelId(id); app.setAppUserModelId(id);
}); });
socket.on('appImportCertificate', (options) => { socket.on("appImportCertificate", (options) => {
app.importCertificate(options, (result) => { app.importCertificate(options, (result) => {
electronSocket.emit('appImportCertificateCompleted', result); electronSocket.emit("appImportCertificateCompleted", result);
}); });
}); });
socket.on('appGetAppMetrics', () => { socket.on("appGetAppMetrics", () => {
const processMetrics = app.getAppMetrics(); const processMetrics = app.getAppMetrics();
electronSocket.emit('appGetAppMetricsCompleted', processMetrics); electronSocket.emit("appGetAppMetricsCompleted", processMetrics);
}); });
socket.on('appGetGpuFeatureStatus', () => { socket.on("appGetGpuFeatureStatus", () => {
const gpuFeatureStatus = app.getGPUFeatureStatus(); const gpuFeatureStatus = app.getGPUFeatureStatus();
electronSocket.emit('appGetGpuFeatureStatusCompleted', gpuFeatureStatus); electronSocket.emit("appGetGpuFeatureStatusCompleted", gpuFeatureStatus);
}); });
socket.on('appSetBadgeCount', (count) => { socket.on("appSetBadgeCount", (count) => {
const success = app.setBadgeCount(count); const success = app.setBadgeCount(count);
electronSocket.emit('appSetBadgeCountCompleted', success); electronSocket.emit("appSetBadgeCountCompleted", success);
}); });
socket.on('appGetBadgeCount', () => { socket.on("appGetBadgeCount", () => {
const count = app.getBadgeCount(); const count = app.getBadgeCount();
electronSocket.emit('appGetBadgeCountCompleted', count); electronSocket.emit("appGetBadgeCountCompleted", count);
}); });
socket.on('appIsUnityRunning', () => { socket.on("appIsUnityRunning", () => {
const isUnityRunning = app.isUnityRunning(); const isUnityRunning = app.isUnityRunning();
electronSocket.emit('appIsUnityRunningCompleted', isUnityRunning); electronSocket.emit("appIsUnityRunningCompleted", isUnityRunning);
}); });
socket.on('appGetLoginItemSettings', (options) => { socket.on("appGetLoginItemSettings", (options) => {
const loginItemSettings = app.getLoginItemSettings(options); const loginItemSettings = app.getLoginItemSettings(options);
electronSocket.emit('appGetLoginItemSettingsCompleted', loginItemSettings); electronSocket.emit("appGetLoginItemSettingsCompleted", loginItemSettings);
}); });
socket.on('appSetLoginItemSettings', (settings) => { socket.on("appSetLoginItemSettings", (settings) => {
app.setLoginItemSettings(settings); app.setLoginItemSettings(settings);
}); });
socket.on('appIsAccessibilitySupportEnabled', () => { socket.on("appIsAccessibilitySupportEnabled", () => {
const isAccessibilitySupportEnabled = app.isAccessibilitySupportEnabled(); const isAccessibilitySupportEnabled = app.isAccessibilitySupportEnabled();
electronSocket.emit('appIsAccessibilitySupportEnabledCompleted', isAccessibilitySupportEnabled); electronSocket.emit("appIsAccessibilitySupportEnabledCompleted", isAccessibilitySupportEnabled);
}); });
socket.on('appSetAccessibilitySupportEnabled', (enabled) => { socket.on("appSetAccessibilitySupportEnabled", (enabled) => {
app.setAccessibilitySupportEnabled(enabled); app.setAccessibilitySupportEnabled(enabled);
}); });
socket.on('appShowAboutPanel', () => { socket.on("appShowAboutPanel", () => {
app.showAboutPanel(); app.showAboutPanel();
}); });
socket.on('appSetAboutPanelOptions', (options) => { socket.on("appSetAboutPanelOptions", (options) => {
app.setAboutPanelOptions(options); app.setAboutPanelOptions(options);
}); });
socket.on('appGetUserAgentFallback', () => { socket.on("appGetUserAgentFallback", () => {
electronSocket.emit('appGetUserAgentFallbackCompleted', app.userAgentFallback); electronSocket.emit("appGetUserAgentFallbackCompleted", app.userAgentFallback);
}); });
socket.on('appSetUserAgentFallback', (userAgent) => { socket.on("appSetUserAgentFallback", (userAgent) => {
app.userAgentFallback = userAgent; app.userAgentFallback = userAgent;
}); });
socket.on('register-app-on-event', (eventName, listenerName) => { socket.on("register-app-on-event", (eventName, listenerName) => {
app.on(eventName, (...args) => { app.on(eventName, (...args) => {
if (args.length > 1) { if (args.length > 1) {
electronSocket.emit(listenerName, args[1]); electronSocket.emit(listenerName, args[1]);
@@ -238,7 +243,7 @@ module.exports = (socket, app) => {
} }
}); });
}); });
socket.on('register-app-once-event', (eventName, listenerName) => { socket.on("register-app-once-event", (eventName, listenerName) => {
app.once(eventName, (...args) => { app.once(eventName, (...args) => {
if (args.length > 1) { if (args.length > 1) {
electronSocket.emit(listenerName, args[1]); electronSocket.emit(listenerName, args[1]);

File diff suppressed because one or more lines are too long

View File

@@ -1,313 +1,338 @@
import { RelaunchOptions, LoginItemSettingsOptions, Settings, AboutPanelOptionsOptions } from "electron"; import type { Socket } from "net";
import { Socket } from "net"; import {
RelaunchOptions,
LoginItemSettingsOptions,
Settings,
AboutPanelOptionsOptions,
} from "electron";
let isQuitWindowAllClosed = true;
let electronSocket: Socket;
let appWindowAllClosedEventId: string;
let isQuitWindowAllClosed = true, electronSocket;
let appWindowAllClosedEventId;
export = (socket: Socket, app: Electron.App) => { export = (socket: Socket, app: Electron.App) => {
electronSocket = socket; electronSocket = socket;
// By default, quit when all windows are closed // By default, quit when all windows are closed
app.on('window-all-closed', () => { app.on("window-all-closed", () => {
// On macOS it is common for applications and their menu bar // On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q // to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin' && isQuitWindowAllClosed) { if (process.platform !== "darwin" && isQuitWindowAllClosed) {
app.quit(); app.quit();
} else if (appWindowAllClosedEventId) { } else if (appWindowAllClosedEventId) {
// If the user is on macOS // If the user is on macOS
// - OR - // - OR -
// If the user has indicated NOT to quit when all windows are closed, // If the user has indicated NOT to quit when all windows are closed,
// emit the event. // emit the event.
electronSocket.emit('app-window-all-closed' + appWindowAllClosedEventId); electronSocket.emit("app-window-all-closed" + appWindowAllClosedEventId);
} }
});
socket.on("quit-app-window-all-closed", (quit) => {
isQuitWindowAllClosed = quit;
});
socket.on("register-app-window-all-closed", (id) => {
appWindowAllClosedEventId = id;
});
socket.on("register-app-before-quit", (id) => {
app.on("before-quit", (event) => {
event.preventDefault();
electronSocket.emit("app-before-quit" + id);
}); });
});
socket.on('quit-app-window-all-closed', (quit) => { socket.on("register-app-will-quit", (id) => {
isQuitWindowAllClosed = quit; app.on("will-quit", (event) => {
event.preventDefault();
electronSocket.emit("app-will-quit" + id);
}); });
});
socket.on('register-app-window-all-closed', (id) => { socket.on("register-app-browser-window-blur", (id) => {
appWindowAllClosedEventId = id; app.on("browser-window-blur", () => {
electronSocket.emit("app-browser-window-blur" + id);
}); });
});
socket.on('register-app-before-quit', (id) => { socket.on("register-app-browser-window-focus", (id) => {
app.on('before-quit', (event) => { app.on("browser-window-focus", () => {
event.preventDefault(); electronSocket.emit("app-browser-window-focus" + id);
electronSocket.emit('app-before-quit' + id);
});
}); });
});
socket.on('register-app-will-quit', (id) => { socket.on("register-app-browser-window-created", (id) => {
app.on('will-quit', (event) => { app.on("browser-window-created", () => {
event.preventDefault(); electronSocket.emit("app-browser-window-created" + id);
electronSocket.emit('app-will-quit' + id);
});
}); });
});
socket.on('register-app-browser-window-blur', (id) => { socket.on("register-app-web-contents-created", (id) => {
app.on('browser-window-blur', () => { app.on("web-contents-created", () => {
electronSocket.emit('app-browser-window-blur' + id); electronSocket.emit("app-web-contents-created" + id);
});
}); });
});
socket.on('register-app-browser-window-focus', (id) => { socket.on("register-app-accessibility-support-changed", (id) => {
app.on('browser-window-focus', () => { app.on(
electronSocket.emit('app-browser-window-focus' + id); "accessibility-support-changed",
}); (event, accessibilitySupportEnabled) => {
electronSocket.emit(
"app-accessibility-support-changed" + id,
accessibilitySupportEnabled,
);
},
);
});
socket.on("appQuit", () => {
app.quit();
});
socket.on("appExit", (exitCode = 0) => {
app.exit(exitCode);
});
socket.on("appRelaunch", (options) => {
app.relaunch(options as RelaunchOptions);
});
socket.on("appFocus", (options) => {
app.focus(options);
});
socket.on("appHide", () => {
app.hide();
});
socket.on("appShow", () => {
app.show();
});
socket.on("appGetAppPath", () => {
const path = app.getAppPath();
electronSocket.emit("appGetAppPathCompleted", path);
});
socket.on("appSetAppLogsPath", (path) => {
app.setAppLogsPath(path);
});
socket.on("appGetPath", (name) => {
const path = app.getPath(name);
electronSocket.emit("appGetPathCompleted", path);
});
socket.on("appGetFileIcon", async (path, options) => {
let error = {};
if (options) {
const nativeImage = await app
.getFileIcon(path, options)
.catch((errorFileIcon) => (error = errorFileIcon));
electronSocket.emit("appGetFileIconCompleted", [error, nativeImage]);
} else {
const nativeImage = await app
.getFileIcon(path)
.catch((errorFileIcon) => (error = errorFileIcon));
electronSocket.emit("appGetFileIconCompleted", [error, nativeImage]);
}
});
socket.on("appSetPath", (name, path) => {
app.setPath(name, path);
});
socket.on("appGetVersion", () => {
const version = app.getVersion();
electronSocket.emit("appGetVersionCompleted", version);
});
socket.on("appGetName", () => {
electronSocket.emit("appGetNameCompleted", app.name);
});
socket.on("appSetName", (name) => {
app.name = name;
});
socket.on("appGetLocale", () => {
const locale = app.getLocale();
electronSocket.emit("appGetLocaleCompleted", locale);
});
socket.on("appAddRecentDocument", (path) => {
app.addRecentDocument(path);
});
socket.on("appClearRecentDocuments", () => {
app.clearRecentDocuments();
});
socket.on("appSetAsDefaultProtocolClient", (protocol, path, args) => {
const success = app.setAsDefaultProtocolClient(protocol, path, args);
electronSocket.emit("appSetAsDefaultProtocolClientCompleted", success);
});
socket.on("appRemoveAsDefaultProtocolClient", (protocol, path, args) => {
const success = app.removeAsDefaultProtocolClient(protocol, path, args);
electronSocket.emit("appRemoveAsDefaultProtocolClientCompleted", success);
});
socket.on("appIsDefaultProtocolClient", (protocol, path, args) => {
const success = app.isDefaultProtocolClient(protocol, path, args);
electronSocket.emit("appIsDefaultProtocolClientCompleted", success);
});
socket.on("appSetUserTasks", (tasks) => {
const success = app.setUserTasks(tasks);
electronSocket.emit("appSetUserTasksCompleted", success);
});
socket.on("appGetJumpListSettings", () => {
const jumpListSettings = app.getJumpListSettings();
electronSocket.emit("appGetJumpListSettingsCompleted", jumpListSettings);
});
socket.on("appSetJumpList", (categories) => {
app.setJumpList(categories);
});
socket.on("appRequestSingleInstanceLock", () => {
const success = app.requestSingleInstanceLock();
electronSocket.emit("appRequestSingleInstanceLockCompleted", success);
app.on("second-instance", (event, args = [], workingDirectory = "") => {
electronSocket.emit("secondInstance", [args, workingDirectory]);
}); });
});
socket.on('register-app-browser-window-created', (id) => { socket.on("appHasSingleInstanceLock", () => {
app.on('browser-window-created', () => { const hasLock = app.hasSingleInstanceLock();
electronSocket.emit('app-browser-window-created' + id);
}); electronSocket.emit("appHasSingleInstanceLockCompleted", hasLock);
});
socket.on("appReleaseSingleInstanceLock", () => {
app.releaseSingleInstanceLock();
});
socket.on("appSetUserActivity", (type, userInfo, webpageUrl) => {
app.setUserActivity(type, userInfo, webpageUrl);
});
socket.on("appGetCurrentActivityType", () => {
const activityType = app.getCurrentActivityType();
electronSocket.emit("appGetCurrentActivityTypeCompleted", activityType);
});
socket.on("appInvalidateCurrentActivity", () => {
app.invalidateCurrentActivity();
});
socket.on("appResignCurrentActivity", () => {
app.resignCurrentActivity();
});
socket.on("appSetAppUserModelId", (id) => {
app.setAppUserModelId(id);
});
socket.on("appImportCertificate", (options) => {
app.importCertificate(options, (result) => {
electronSocket.emit("appImportCertificateCompleted", result);
}); });
});
socket.on('register-app-web-contents-created', (id) => { socket.on("appGetAppMetrics", () => {
app.on('web-contents-created', () => { const processMetrics = app.getAppMetrics();
electronSocket.emit('app-web-contents-created' + id); electronSocket.emit("appGetAppMetricsCompleted", processMetrics);
}); });
socket.on("appGetGpuFeatureStatus", () => {
const gpuFeatureStatus = app.getGPUFeatureStatus();
electronSocket.emit("appGetGpuFeatureStatusCompleted", gpuFeatureStatus);
});
socket.on("appSetBadgeCount", (count) => {
const success = app.setBadgeCount(count);
electronSocket.emit("appSetBadgeCountCompleted", success);
});
socket.on("appGetBadgeCount", () => {
const count = app.getBadgeCount();
electronSocket.emit("appGetBadgeCountCompleted", count);
});
socket.on("appIsUnityRunning", () => {
const isUnityRunning = app.isUnityRunning();
electronSocket.emit("appIsUnityRunningCompleted", isUnityRunning);
});
socket.on("appGetLoginItemSettings", (options) => {
const loginItemSettings = app.getLoginItemSettings(
options as LoginItemSettingsOptions,
);
electronSocket.emit("appGetLoginItemSettingsCompleted", loginItemSettings);
});
socket.on("appSetLoginItemSettings", (settings) => {
app.setLoginItemSettings(settings as Settings);
});
socket.on("appIsAccessibilitySupportEnabled", () => {
const isAccessibilitySupportEnabled = app.isAccessibilitySupportEnabled();
electronSocket.emit(
"appIsAccessibilitySupportEnabledCompleted",
isAccessibilitySupportEnabled,
);
});
socket.on("appSetAccessibilitySupportEnabled", (enabled) => {
app.setAccessibilitySupportEnabled(enabled);
});
socket.on("appShowAboutPanel", () => {
app.showAboutPanel();
});
socket.on("appSetAboutPanelOptions", (options) => {
app.setAboutPanelOptions(options as AboutPanelOptionsOptions);
});
socket.on("appGetUserAgentFallback", () => {
electronSocket.emit(
"appGetUserAgentFallbackCompleted",
app.userAgentFallback,
);
});
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-accessibility-support-changed', (id) => { socket.on("register-app-once-event", (eventName, listenerName) => {
app.on('accessibility-support-changed', (event, accessibilitySupportEnabled) => { app.once(eventName, (...args) => {
electronSocket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled); if (args.length > 1) {
}); electronSocket.emit(listenerName, args[1]);
}); } else {
electronSocket.emit(listenerName);
socket.on('appQuit', () => { }
app.quit();
});
socket.on('appExit', (exitCode = 0) => {
app.exit(exitCode);
});
socket.on('appRelaunch', (options) => {
app.relaunch(options as RelaunchOptions);
});
socket.on('appFocus', (options) => {
app.focus(options);
});
socket.on('appHide', () => {
app.hide();
});
socket.on('appShow', () => {
app.show();
});
socket.on('appGetAppPath', () => {
const path = app.getAppPath();
electronSocket.emit('appGetAppPathCompleted', path);
});
socket.on('appSetAppLogsPath', (path) => {
app.setAppLogsPath(path);
});
socket.on('appGetPath', (name) => {
const path = app.getPath(name);
electronSocket.emit('appGetPathCompleted', path);
});
socket.on('appGetFileIcon', async (path, options) => {
let error = {};
if (options) {
const nativeImage = await app.getFileIcon(path, options).catch((errorFileIcon) => error = errorFileIcon);
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]);
} else {
const nativeImage = await app.getFileIcon(path).catch((errorFileIcon) => error = errorFileIcon);
electronSocket.emit('appGetFileIconCompleted', [error, nativeImage]);
}
});
socket.on('appSetPath', (name, path) => {
app.setPath(name, path);
});
socket.on('appGetVersion', () => {
const version = app.getVersion();
electronSocket.emit('appGetVersionCompleted', version);
});
socket.on('appGetName', () => {
electronSocket.emit('appGetNameCompleted', app.name);
});
socket.on('appSetName', (name) => {
app.name = name;
});
socket.on('appGetLocale', () => {
const locale = app.getLocale();
electronSocket.emit('appGetLocaleCompleted', locale);
});
socket.on('appAddRecentDocument', (path) => {
app.addRecentDocument(path);
});
socket.on('appClearRecentDocuments', () => {
app.clearRecentDocuments();
});
socket.on('appSetAsDefaultProtocolClient', (protocol, path, args) => {
const success = app.setAsDefaultProtocolClient(protocol, path, args);
electronSocket.emit('appSetAsDefaultProtocolClientCompleted', success);
});
socket.on('appRemoveAsDefaultProtocolClient', (protocol, path, args) => {
const success = app.removeAsDefaultProtocolClient(protocol, path, args);
electronSocket.emit('appRemoveAsDefaultProtocolClientCompleted', success);
});
socket.on('appIsDefaultProtocolClient', (protocol, path, args) => {
const success = app.isDefaultProtocolClient(protocol, path, args);
electronSocket.emit('appIsDefaultProtocolClientCompleted', success);
});
socket.on('appSetUserTasks', (tasks) => {
const success = app.setUserTasks(tasks);
electronSocket.emit('appSetUserTasksCompleted', success);
});
socket.on('appGetJumpListSettings', () => {
const jumpListSettings = app.getJumpListSettings();
electronSocket.emit('appGetJumpListSettingsCompleted', jumpListSettings);
});
socket.on('appSetJumpList', (categories) => {
app.setJumpList(categories);
});
socket.on('appRequestSingleInstanceLock', () => {
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();
electronSocket.emit('appHasSingleInstanceLockCompleted', hasLock);
});
socket.on('appReleaseSingleInstanceLock', () => {
app.releaseSingleInstanceLock();
});
socket.on('appSetUserActivity', (type, userInfo, webpageUrl) => {
app.setUserActivity(type, userInfo, webpageUrl);
});
socket.on('appGetCurrentActivityType', () => {
const activityType = app.getCurrentActivityType();
electronSocket.emit('appGetCurrentActivityTypeCompleted', activityType);
});
socket.on('appInvalidateCurrentActivity', () => {
app.invalidateCurrentActivity();
});
socket.on('appResignCurrentActivity', () => {
app.resignCurrentActivity();
});
socket.on('appSetAppUserModelId', (id) => {
app.setAppUserModelId(id);
});
socket.on('appImportCertificate', (options) => {
app.importCertificate(options, (result) => {
electronSocket.emit('appImportCertificateCompleted', result);
});
});
socket.on('appGetAppMetrics', () => {
const processMetrics = app.getAppMetrics();
electronSocket.emit('appGetAppMetricsCompleted', processMetrics);
});
socket.on('appGetGpuFeatureStatus', () => {
const gpuFeatureStatus = app.getGPUFeatureStatus();
electronSocket.emit('appGetGpuFeatureStatusCompleted', gpuFeatureStatus);
});
socket.on('appSetBadgeCount', (count) => {
const success = app.setBadgeCount(count);
electronSocket.emit('appSetBadgeCountCompleted', success);
});
socket.on('appGetBadgeCount', () => {
const count = app.getBadgeCount();
electronSocket.emit('appGetBadgeCountCompleted', count);
});
socket.on('appIsUnityRunning', () => {
const isUnityRunning = app.isUnityRunning();
electronSocket.emit('appIsUnityRunningCompleted', isUnityRunning);
});
socket.on('appGetLoginItemSettings', (options) => {
const loginItemSettings = app.getLoginItemSettings(options as LoginItemSettingsOptions);
electronSocket.emit('appGetLoginItemSettingsCompleted', loginItemSettings);
});
socket.on('appSetLoginItemSettings', (settings) => {
app.setLoginItemSettings(settings as Settings);
});
socket.on('appIsAccessibilitySupportEnabled', () => {
const isAccessibilitySupportEnabled = app.isAccessibilitySupportEnabled();
electronSocket.emit('appIsAccessibilitySupportEnabledCompleted', isAccessibilitySupportEnabled);
});
socket.on('appSetAccessibilitySupportEnabled', (enabled) => {
app.setAccessibilitySupportEnabled(enabled);
});
socket.on('appShowAboutPanel', () => {
app.showAboutPanel();
});
socket.on('appSetAboutPanelOptions', (options) => {
app.setAboutPanelOptions(options as AboutPanelOptionsOptions);
});
socket.on('appGetUserAgentFallback', () => {
electronSocket.emit('appGetUserAgentFallbackCompleted', app.userAgentFallback);
});
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,114 +1,133 @@
"use strict"; "use strict";
const electron_updater_1 = require("electron-updater"); const electron_updater_1 = require("electron-updater");
let electronSocket; let electronSocket;
function normalize(updateInfo) {
if (typeof updateInfo?.releaseNotes === "string") {
updateInfo.releaseNotes = [{ note: updateInfo.releaseNotes }];
}
else if (Array.isArray(updateInfo?.releaseNotes)) {
updateInfo.releaseNotes = updateInfo.releaseNotes.map((entry) => typeof entry === "string" ? { note: entry } : entry);
}
}
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('register-autoUpdater-error', (id) => { socket.on("register-autoUpdater-error", (id) => {
electron_updater_1.autoUpdater.on('error', (error) => { electron_updater_1.autoUpdater.on("error", (error) => {
electronSocket.emit('autoUpdater-error' + id, error.message); electronSocket.emit("autoUpdater-error" + id, error.message);
}); });
}); });
socket.on('register-autoUpdater-checking-for-update', (id) => { socket.on("register-autoUpdater-checking-for-update", (id) => {
electron_updater_1.autoUpdater.on('checking-for-update', () => { electron_updater_1.autoUpdater.on("checking-for-update", () => {
electronSocket.emit('autoUpdater-checking-for-update' + id); electronSocket.emit("autoUpdater-checking-for-update" + id);
}); });
}); });
socket.on('register-autoUpdater-update-available', (id) => { socket.on("register-autoUpdater-update-available", (id) => {
electron_updater_1.autoUpdater.on('update-available', (updateInfo) => { electron_updater_1.autoUpdater.on("update-available", (updateInfo) => {
electronSocket.emit('autoUpdater-update-available' + id, updateInfo); normalize(updateInfo);
electronSocket.emit("autoUpdater-update-available" + id, updateInfo);
}); });
}); });
socket.on('register-autoUpdater-update-not-available', (id) => { socket.on("register-autoUpdater-update-not-available", (id) => {
electron_updater_1.autoUpdater.on('update-not-available', (updateInfo) => { electron_updater_1.autoUpdater.on("update-not-available", (updateInfo) => {
electronSocket.emit('autoUpdater-update-not-available' + id, updateInfo); normalize(updateInfo);
electronSocket.emit("autoUpdater-update-not-available" + id, updateInfo);
}); });
}); });
socket.on('register-autoUpdater-download-progress', (id) => { socket.on("register-autoUpdater-download-progress", (id) => {
electron_updater_1.autoUpdater.on('download-progress', (progressInfo) => { electron_updater_1.autoUpdater.on("download-progress", (progressInfo) => {
electronSocket.emit('autoUpdater-download-progress' + id, progressInfo); electronSocket.emit("autoUpdater-download-progress" + id, progressInfo);
}); });
}); });
socket.on('register-autoUpdater-update-downloaded', (id) => { socket.on("register-autoUpdater-update-downloaded", (id) => {
electron_updater_1.autoUpdater.on('update-downloaded', (updateInfo) => { electron_updater_1.autoUpdater.on("update-downloaded", (updateInfo) => {
electronSocket.emit('autoUpdater-update-downloaded' + id, updateInfo); normalize(updateInfo);
electronSocket.emit("autoUpdater-update-downloaded" + id, updateInfo);
}); });
}); });
// Properties ***** // Properties *****
socket.on('autoUpdater-autoDownload', () => { socket.on("autoUpdater-autoDownload", () => {
electronSocket.emit('autoUpdater-autoDownload-completed', electron_updater_1.autoUpdater.autoDownload); electronSocket.emit("autoUpdater-autoDownload-completed", electron_updater_1.autoUpdater.autoDownload);
}); });
socket.on('autoUpdater-autoDownload-set', (value) => { socket.on("autoUpdater-autoDownload-set", (value) => {
electron_updater_1.autoUpdater.autoDownload = value; electron_updater_1.autoUpdater.autoDownload = value;
}); });
socket.on('autoUpdater-autoInstallOnAppQuit', () => { socket.on("autoUpdater-autoInstallOnAppQuit", () => {
electronSocket.emit('autoUpdater-autoInstallOnAppQuit-completed', electron_updater_1.autoUpdater.autoInstallOnAppQuit); electronSocket.emit("autoUpdater-autoInstallOnAppQuit-completed", electron_updater_1.autoUpdater.autoInstallOnAppQuit);
}); });
socket.on('autoUpdater-autoInstallOnAppQuit-set', (value) => { socket.on("autoUpdater-autoInstallOnAppQuit-set", (value) => {
electron_updater_1.autoUpdater.autoInstallOnAppQuit = value; electron_updater_1.autoUpdater.autoInstallOnAppQuit = value;
}); });
socket.on('autoUpdater-allowPrerelease', () => { socket.on("autoUpdater-allowPrerelease", () => {
electronSocket.emit('autoUpdater-allowPrerelease-completed', electron_updater_1.autoUpdater.allowPrerelease); electronSocket.emit("autoUpdater-allowPrerelease-completed", electron_updater_1.autoUpdater.allowPrerelease);
}); });
socket.on('autoUpdater-allowPrerelease-set', (value) => { socket.on("autoUpdater-allowPrerelease-set", (value) => {
electron_updater_1.autoUpdater.allowPrerelease = value; electron_updater_1.autoUpdater.allowPrerelease = value;
}); });
socket.on('autoUpdater-fullChangelog', () => { socket.on("autoUpdater-fullChangelog", () => {
electronSocket.emit('autoUpdater-fullChangelog-completed', electron_updater_1.autoUpdater.fullChangelog); electronSocket.emit("autoUpdater-fullChangelog-completed", electron_updater_1.autoUpdater.fullChangelog);
}); });
socket.on('autoUpdater-fullChangelog-set', (value) => { socket.on("autoUpdater-fullChangelog-set", (value) => {
electron_updater_1.autoUpdater.fullChangelog = value; electron_updater_1.autoUpdater.fullChangelog = value;
}); });
socket.on('autoUpdater-allowDowngrade', () => { socket.on("autoUpdater-allowDowngrade", () => {
electronSocket.emit('autoUpdater-allowDowngrade-completed', electron_updater_1.autoUpdater.allowDowngrade); electronSocket.emit("autoUpdater-allowDowngrade-completed", electron_updater_1.autoUpdater.allowDowngrade);
}); });
socket.on('autoUpdater-allowDowngrade-set', (value) => { socket.on("autoUpdater-allowDowngrade-set", (value) => {
electron_updater_1.autoUpdater.allowDowngrade = value; electron_updater_1.autoUpdater.allowDowngrade = value;
}); });
socket.on('autoUpdater-updateConfigPath', () => { socket.on("autoUpdater-updateConfigPath", () => {
electronSocket.emit('autoUpdater-updateConfigPath-completed', electron_updater_1.autoUpdater.updateConfigPath || ''); electronSocket.emit("autoUpdater-updateConfigPath-completed", electron_updater_1.autoUpdater.updateConfigPath || "");
}); });
socket.on('autoUpdater-updateConfigPath-set', (value) => { socket.on("autoUpdater-updateConfigPath-set", (value) => {
electron_updater_1.autoUpdater.updateConfigPath = value; electron_updater_1.autoUpdater.updateConfigPath = value;
}); });
socket.on('autoUpdater-currentVersion', () => { socket.on("autoUpdater-currentVersion", () => {
electronSocket.emit('autoUpdater-currentVersion-completed', electron_updater_1.autoUpdater.currentVersion); electronSocket.emit("autoUpdater-currentVersion-completed", electron_updater_1.autoUpdater.currentVersion);
}); });
socket.on('autoUpdater-channel', () => { socket.on("autoUpdater-channel", () => {
electronSocket.emit('autoUpdater-channel-completed', electron_updater_1.autoUpdater.channel || ''); electronSocket.emit("autoUpdater-channel-completed", electron_updater_1.autoUpdater.channel || "");
}); });
socket.on('autoUpdater-channel-set', (value) => { socket.on("autoUpdater-channel-set", (value) => {
electron_updater_1.autoUpdater.channel = value; electron_updater_1.autoUpdater.channel = value;
}); });
socket.on('autoUpdater-requestHeaders', () => { socket.on("autoUpdater-requestHeaders", () => {
electronSocket.emit('autoUpdater-requestHeaders-completed', electron_updater_1.autoUpdater.requestHeaders); electronSocket.emit("autoUpdater-requestHeaders-completed", electron_updater_1.autoUpdater.requestHeaders);
}); });
socket.on('autoUpdater-requestHeaders-set', (value) => { socket.on("autoUpdater-requestHeaders-set", (value) => {
electron_updater_1.autoUpdater.requestHeaders = value; electron_updater_1.autoUpdater.requestHeaders = value;
}); });
socket.on('autoUpdater-checkForUpdatesAndNotify', async (guid) => { socket.on("autoUpdater-checkForUpdatesAndNotify", async (guid) => {
electron_updater_1.autoUpdater.checkForUpdatesAndNotify().then((updateCheckResult) => { electron_updater_1.autoUpdater
electronSocket.emit('autoUpdater-checkForUpdatesAndNotify-completed' + guid, updateCheckResult); .checkForUpdatesAndNotify()
}).catch((error) => { .then((updateCheckResult) => {
electronSocket.emit('autoUpdater-checkForUpdatesAndNotifyError' + guid, error); normalize(updateCheckResult?.updateInfo);
electronSocket.emit("autoUpdater-checkForUpdatesAndNotify-completed" + guid, updateCheckResult);
})
.catch((error) => {
electronSocket.emit("autoUpdater-checkForUpdatesAndNotifyError" + guid, error);
}); });
}); });
socket.on('autoUpdater-checkForUpdates', async (guid) => { socket.on("autoUpdater-checkForUpdates", async (guid) => {
electron_updater_1.autoUpdater.checkForUpdates().then((updateCheckResult) => { electron_updater_1.autoUpdater
electronSocket.emit('autoUpdater-checkForUpdates-completed' + guid, updateCheckResult); .checkForUpdates()
}).catch((error) => { .then((updateCheckResult) => {
electronSocket.emit('autoUpdater-checkForUpdatesError' + guid, error); normalize(updateCheckResult?.updateInfo);
electronSocket.emit("autoUpdater-checkForUpdates-completed" + guid, updateCheckResult);
})
.catch((error) => {
electronSocket.emit("autoUpdater-checkForUpdatesError" + guid, error);
}); });
}); });
socket.on('autoUpdater-quitAndInstall', async (isSilent, isForceRunAfter) => { socket.on("autoUpdater-quitAndInstall", async (isSilent, isForceRunAfter) => {
electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter); electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
}); });
socket.on('autoUpdater-downloadUpdate', async (guid) => { socket.on("autoUpdater-downloadUpdate", async (guid) => {
const downloadedPath = await electron_updater_1.autoUpdater.downloadUpdate(); const downloadedPath = await electron_updater_1.autoUpdater.downloadUpdate();
electronSocket.emit('autoUpdater-downloadUpdate-completed' + guid, downloadedPath); electronSocket.emit("autoUpdater-downloadUpdate-completed" + guid, downloadedPath);
}); });
socket.on('autoUpdater-getFeedURL', async (guid) => { socket.on("autoUpdater-getFeedURL", async (guid) => {
const feedUrl = await electron_updater_1.autoUpdater.getFeedURL(); const feedUrl = await electron_updater_1.autoUpdater.getFeedURL();
electronSocket.emit('autoUpdater-getFeedURL-completed' + guid, feedUrl || ''); electronSocket.emit("autoUpdater-getFeedURL-completed" + guid, feedUrl || "");
}); });
}; };
//# sourceMappingURL=autoUpdater.js.map //# sourceMappingURL=autoUpdater.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,143 +1,207 @@
import { Socket } from 'net'; import type { Socket } from "net";
import { autoUpdater } from 'electron-updater'; import { autoUpdater } from "electron-updater";
let electronSocket;
let electronSocket: Socket;
function normalize(updateInfo) {
if (typeof updateInfo?.releaseNotes === "string") {
updateInfo.releaseNotes = [{ note: updateInfo.releaseNotes }];
} else if (Array.isArray(updateInfo?.releaseNotes)) {
updateInfo.releaseNotes = updateInfo.releaseNotes.map((entry) =>
typeof entry === "string" ? { note: entry } : entry,
);
}
}
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('register-autoUpdater-error', (id) => { socket.on("register-autoUpdater-error", (id) => {
autoUpdater.on('error', (error) => { autoUpdater.on("error", (error) => {
electronSocket.emit('autoUpdater-error' + id, error.message); electronSocket.emit("autoUpdater-error" + id, error.message);
});
}); });
});
socket.on('register-autoUpdater-checking-for-update', (id) => { socket.on("register-autoUpdater-checking-for-update", (id) => {
autoUpdater.on('checking-for-update', () => { autoUpdater.on("checking-for-update", () => {
electronSocket.emit('autoUpdater-checking-for-update' + id); electronSocket.emit("autoUpdater-checking-for-update" + id);
});
}); });
});
socket.on('register-autoUpdater-update-available', (id) => { socket.on("register-autoUpdater-update-available", (id) => {
autoUpdater.on('update-available', (updateInfo) => { autoUpdater.on("update-available", (updateInfo) => {
electronSocket.emit('autoUpdater-update-available' + id, updateInfo); normalize(updateInfo);
}); electronSocket.emit("autoUpdater-update-available" + id, updateInfo);
}); });
});
socket.on('register-autoUpdater-update-not-available', (id) => { socket.on("register-autoUpdater-update-not-available", (id) => {
autoUpdater.on('update-not-available', (updateInfo) => { autoUpdater.on("update-not-available", (updateInfo) => {
electronSocket.emit('autoUpdater-update-not-available' + id, updateInfo); normalize(updateInfo);
}); electronSocket.emit("autoUpdater-update-not-available" + id, updateInfo);
}); });
});
socket.on('register-autoUpdater-download-progress', (id) => { socket.on("register-autoUpdater-download-progress", (id) => {
autoUpdater.on('download-progress', (progressInfo) => { autoUpdater.on("download-progress", (progressInfo) => {
electronSocket.emit('autoUpdater-download-progress' + id, progressInfo); electronSocket.emit("autoUpdater-download-progress" + id, progressInfo);
});
}); });
});
socket.on('register-autoUpdater-update-downloaded', (id) => { socket.on("register-autoUpdater-update-downloaded", (id) => {
autoUpdater.on('update-downloaded', (updateInfo) => { autoUpdater.on("update-downloaded", (updateInfo) => {
electronSocket.emit('autoUpdater-update-downloaded' + id, updateInfo); normalize(updateInfo);
}); electronSocket.emit("autoUpdater-update-downloaded" + id, updateInfo);
}); });
});
// Properties ***** // Properties *****
socket.on('autoUpdater-autoDownload', () => { socket.on("autoUpdater-autoDownload", () => {
electronSocket.emit('autoUpdater-autoDownload-completed', autoUpdater.autoDownload); electronSocket.emit(
}); "autoUpdater-autoDownload-completed",
autoUpdater.autoDownload,
);
});
socket.on('autoUpdater-autoDownload-set', (value) => { socket.on("autoUpdater-autoDownload-set", (value) => {
autoUpdater.autoDownload = value; autoUpdater.autoDownload = value;
}); });
socket.on('autoUpdater-autoInstallOnAppQuit', () => { socket.on("autoUpdater-autoInstallOnAppQuit", () => {
electronSocket.emit('autoUpdater-autoInstallOnAppQuit-completed', autoUpdater.autoInstallOnAppQuit); electronSocket.emit(
}); "autoUpdater-autoInstallOnAppQuit-completed",
autoUpdater.autoInstallOnAppQuit,
);
});
socket.on('autoUpdater-autoInstallOnAppQuit-set', (value) => { socket.on("autoUpdater-autoInstallOnAppQuit-set", (value) => {
autoUpdater.autoInstallOnAppQuit = value; autoUpdater.autoInstallOnAppQuit = value;
}); });
socket.on('autoUpdater-allowPrerelease', () => { socket.on("autoUpdater-allowPrerelease", () => {
electronSocket.emit('autoUpdater-allowPrerelease-completed', autoUpdater.allowPrerelease); electronSocket.emit(
}); "autoUpdater-allowPrerelease-completed",
autoUpdater.allowPrerelease,
);
});
socket.on('autoUpdater-allowPrerelease-set', (value) => { socket.on("autoUpdater-allowPrerelease-set", (value) => {
autoUpdater.allowPrerelease = value; autoUpdater.allowPrerelease = value;
}); });
socket.on('autoUpdater-fullChangelog', () => { socket.on("autoUpdater-fullChangelog", () => {
electronSocket.emit('autoUpdater-fullChangelog-completed', autoUpdater.fullChangelog); electronSocket.emit(
}); "autoUpdater-fullChangelog-completed",
autoUpdater.fullChangelog,
);
});
socket.on('autoUpdater-fullChangelog-set', (value) => { socket.on("autoUpdater-fullChangelog-set", (value) => {
autoUpdater.fullChangelog = value; autoUpdater.fullChangelog = value;
}); });
socket.on('autoUpdater-allowDowngrade', () => { socket.on("autoUpdater-allowDowngrade", () => {
electronSocket.emit('autoUpdater-allowDowngrade-completed', autoUpdater.allowDowngrade); electronSocket.emit(
}); "autoUpdater-allowDowngrade-completed",
autoUpdater.allowDowngrade,
);
});
socket.on('autoUpdater-allowDowngrade-set', (value) => { socket.on("autoUpdater-allowDowngrade-set", (value) => {
autoUpdater.allowDowngrade = value; autoUpdater.allowDowngrade = value;
}); });
socket.on('autoUpdater-updateConfigPath', () => { socket.on("autoUpdater-updateConfigPath", () => {
electronSocket.emit('autoUpdater-updateConfigPath-completed', autoUpdater.updateConfigPath || ''); electronSocket.emit(
}); "autoUpdater-updateConfigPath-completed",
autoUpdater.updateConfigPath || "",
);
});
socket.on('autoUpdater-updateConfigPath-set', (value) => { socket.on("autoUpdater-updateConfigPath-set", (value) => {
autoUpdater.updateConfigPath = value; autoUpdater.updateConfigPath = value;
}); });
socket.on('autoUpdater-currentVersion', () => { socket.on("autoUpdater-currentVersion", () => {
electronSocket.emit('autoUpdater-currentVersion-completed', autoUpdater.currentVersion); electronSocket.emit(
}); "autoUpdater-currentVersion-completed",
autoUpdater.currentVersion,
);
});
socket.on('autoUpdater-channel', () => { socket.on("autoUpdater-channel", () => {
electronSocket.emit('autoUpdater-channel-completed', autoUpdater.channel || ''); electronSocket.emit(
}); "autoUpdater-channel-completed",
autoUpdater.channel || "",
);
});
socket.on('autoUpdater-channel-set', (value) => { socket.on("autoUpdater-channel-set", (value) => {
autoUpdater.channel = value; autoUpdater.channel = value;
}); });
socket.on('autoUpdater-requestHeaders', () => { socket.on("autoUpdater-requestHeaders", () => {
electronSocket.emit('autoUpdater-requestHeaders-completed', autoUpdater.requestHeaders); electronSocket.emit(
}); "autoUpdater-requestHeaders-completed",
autoUpdater.requestHeaders,
);
});
socket.on('autoUpdater-requestHeaders-set', (value) => { socket.on("autoUpdater-requestHeaders-set", (value) => {
autoUpdater.requestHeaders = value; autoUpdater.requestHeaders = value;
}); });
socket.on('autoUpdater-checkForUpdatesAndNotify', async (guid) => { socket.on("autoUpdater-checkForUpdatesAndNotify", async (guid) => {
autoUpdater.checkForUpdatesAndNotify().then((updateCheckResult) => { autoUpdater
electronSocket.emit('autoUpdater-checkForUpdatesAndNotify-completed' + guid, updateCheckResult); .checkForUpdatesAndNotify()
}).catch((error) => { .then((updateCheckResult) => {
electronSocket.emit('autoUpdater-checkForUpdatesAndNotifyError' + guid, error); normalize(updateCheckResult?.updateInfo);
}); electronSocket.emit(
}); "autoUpdater-checkForUpdatesAndNotify-completed" + guid,
updateCheckResult,
);
})
.catch((error) => {
electronSocket.emit(
"autoUpdater-checkForUpdatesAndNotifyError" + guid,
error,
);
});
});
socket.on('autoUpdater-checkForUpdates', async (guid) => { socket.on("autoUpdater-checkForUpdates", async (guid) => {
autoUpdater.checkForUpdates().then((updateCheckResult) => { autoUpdater
electronSocket.emit('autoUpdater-checkForUpdates-completed' + guid, updateCheckResult); .checkForUpdates()
}).catch((error) => { .then((updateCheckResult) => {
electronSocket.emit('autoUpdater-checkForUpdatesError' + guid, error); normalize(updateCheckResult?.updateInfo);
}); electronSocket.emit(
}); "autoUpdater-checkForUpdates-completed" + guid,
updateCheckResult,
);
})
.catch((error) => {
electronSocket.emit("autoUpdater-checkForUpdatesError" + guid, error);
});
});
socket.on('autoUpdater-quitAndInstall', async (isSilent, isForceRunAfter) => { socket.on("autoUpdater-quitAndInstall", async (isSilent, isForceRunAfter) => {
autoUpdater.quitAndInstall(isSilent, isForceRunAfter); autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
}); });
socket.on('autoUpdater-downloadUpdate', async (guid) => { socket.on("autoUpdater-downloadUpdate", async (guid) => {
const downloadedPath = await autoUpdater.downloadUpdate(); const downloadedPath = await autoUpdater.downloadUpdate();
electronSocket.emit('autoUpdater-downloadUpdate-completed' + guid, downloadedPath); electronSocket.emit(
}); "autoUpdater-downloadUpdate-completed" + guid,
downloadedPath,
);
});
socket.on('autoUpdater-getFeedURL', async (guid) => { socket.on("autoUpdater-getFeedURL", async (guid) => {
const feedUrl = await autoUpdater.getFeedURL(); const feedUrl = await autoUpdater.getFeedURL();
electronSocket.emit('autoUpdater-getFeedURL-completed' + guid, feedUrl || ''); electronSocket.emit(
}); "autoUpdater-getFeedURL-completed" + guid,
feedUrl || "",
);
});
}; };

View File

@@ -2,17 +2,22 @@
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.browserViewMediateService = exports.browserViewApi = void 0; exports.browserViewMediateService = exports.browserViewApi = void 0;
const electron_1 = require("electron"); const electron_1 = require("electron");
const browserViews = (global['browserViews'] = global['browserViews'] || []); const browserViews = (global["browserViews"] =
let browserView, electronSocket; global["browserViews"] || []);
const proxyToCredentialsMap = (global['proxyToCredentialsMap'] = global['proxyToCredentialsMap'] || []); const proxyToCredentialsMap = (global["proxyToCredentialsMap"] = global["proxyToCredentialsMap"] || []);
let browserView;
let electronSocket;
const browserViewApi = (socket) => { const browserViewApi = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('createBrowserView', (options) => { socket.on("createBrowserView", (options) => {
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) { if (!hasOwnChildreen(options, "webPreferences", "nodeIntegration")) {
options = { ...options, webPreferences: { nodeIntegration: true, contextIsolation: false } }; options = {
...options,
webPreferences: { nodeIntegration: true, contextIsolation: false },
};
} }
browserView = new electron_1.BrowserView(options); browserView = new electron_1.BrowserView(options);
browserView['id'] = browserViews.length + 1; browserView["id"] = browserViews.length + 1;
if (options.proxy) { if (options.proxy) {
browserView.webContents.session.setProxy({ proxyRules: options.proxy }); browserView.webContents.session.setProxy({ proxyRules: options.proxy });
} }
@@ -20,19 +25,19 @@ const browserViewApi = (socket) => {
proxyToCredentialsMap[options.proxy] = options.proxyCredentials; proxyToCredentialsMap[options.proxy] = options.proxyCredentials;
} }
browserViews.push(browserView); browserViews.push(browserView);
electronSocket.emit('BrowserViewCreated', browserView['id']); electronSocket.emit("BrowserViewCreated", browserView["id"]);
}); });
socket.on('browserView-bounds', (id) => { socket.on("browserView-bounds", (id) => {
const bounds = getBrowserViewById(id).getBounds(); const bounds = getBrowserViewById(id).getBounds();
electronSocket.emit('browserView-bounds-completed', bounds); electronSocket.emit("browserView-bounds-completed", bounds);
}); });
socket.on('browserView-bounds-set', (id, bounds) => { socket.on("browserView-bounds-set", (id, bounds) => {
getBrowserViewById(id).setBounds(bounds); getBrowserViewById(id).setBounds(bounds);
}); });
socket.on('browserView-setAutoResize', (id, options) => { socket.on("browserView-setAutoResize", (id, options) => {
getBrowserViewById(id).setAutoResize(options); getBrowserViewById(id).setAutoResize(options);
}); });
socket.on('browserView-setBackgroundColor', (id, color) => { socket.on("browserView-setBackgroundColor", (id, color) => {
getBrowserViewById(id).setBackgroundColor(color); getBrowserViewById(id).setBackgroundColor(color);
}); });
function hasOwnChildreen(obj, ...childNames) { function hasOwnChildreen(obj, ...childNames) {
@@ -53,7 +58,7 @@ exports.browserViewMediateService = browserViewMediateService;
function getBrowserViewById(id) { function getBrowserViewById(id) {
for (let index = 0; index < browserViews.length; index++) { for (let index = 0; index < browserViews.length; index++) {
const browserViewItem = browserViews[index]; const browserViewItem = browserViews[index];
if (browserViewItem['id'] === id) { if (browserViewItem["id"] === id) {
return browserViewItem; return browserViewItem;
} }
} }

View File

@@ -1 +1 @@
{"version":3,"file":"browserView.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AC,EAAE,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,UAAU;QACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3C,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/C,OAAO,KAAK,CAAC;YACf,CAAC;YACD,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAeO,wCAAc;AAbvB,MAAM,yBAAyB,GAAG,CAAC,aAAqB,EAAe,EAAE;IACvE,OAAO,kBAAkB,CAAC,aAAa,CAAC,CAAC;AAC3C,CAAC,CAAC;AAWuB,8DAAyB;AATlD,SAAS,kBAAkB,CAAC,EAAU;IACpC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,MAAM,eAAe,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YACjC,OAAO,eAAe,CAAC;QACzB,CAAC;IACH,CAAC;AACH,CAAC"}

View File

@@ -1,74 +1,83 @@
import { Socket } from 'net'; import type { Socket } from "net";
import { BrowserView } from 'electron'; import { BrowserView } from "electron";
const browserViews: BrowserView[] = (global['browserViews'] = global['browserViews'] || []) as BrowserView[];
let browserView: BrowserView, electronSocket; const browserViews: BrowserView[] = (global["browserViews"] =
const proxyToCredentialsMap: { [proxy: string]: string } = (global['proxyToCredentialsMap'] = global['proxyToCredentialsMap'] || []) as { [proxy: string]: string }; global["browserViews"] || []) as BrowserView[];
const proxyToCredentialsMap: { [proxy: string]: string } = (global[
"proxyToCredentialsMap"
] = global["proxyToCredentialsMap"] || []) as { [proxy: string]: string };
let browserView: BrowserView;
let electronSocket: Socket;
const browserViewApi = (socket: Socket) => { const browserViewApi = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('createBrowserView', (options) => { socket.on("createBrowserView", (options) => {
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) { if (!hasOwnChildreen(options, "webPreferences", "nodeIntegration")) {
options = { ...options, webPreferences: { nodeIntegration: true, contextIsolation: false } }; 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-bounds', (id) => {
const bounds = getBrowserViewById(id).getBounds();
electronSocket.emit('browserView-bounds-completed', bounds);
});
socket.on('browserView-bounds-set', (id, bounds) => {
getBrowserViewById(id).setBounds(bounds);
});
socket.on('browserView-setAutoResize', (id, options) => {
getBrowserViewById(id).setAutoResize(options);
});
socket.on('browserView-setBackgroundColor', (id, color) => {
getBrowserViewById(id).setBackgroundColor(color);
});
function hasOwnChildreen(obj, ...childNames) {
for (let i = 0; i < childNames.length; i++) {
if (!obj || !obj.hasOwnProperty(childNames[i])) {
return false;
}
obj = obj[childNames[i]];
}
return true;
} }
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-bounds", (id) => {
const bounds = getBrowserViewById(id).getBounds();
electronSocket.emit("browserView-bounds-completed", bounds);
});
socket.on("browserView-bounds-set", (id, bounds) => {
getBrowserViewById(id).setBounds(bounds);
});
socket.on("browserView-setAutoResize", (id, options) => {
getBrowserViewById(id).setAutoResize(options);
});
socket.on("browserView-setBackgroundColor", (id, color) => {
getBrowserViewById(id).setBackgroundColor(color);
});
function hasOwnChildreen(obj, ...childNames) {
for (let i = 0; i < childNames.length; i++) {
if (!obj || !obj.hasOwnProperty(childNames[i])) {
return false;
}
obj = obj[childNames[i]];
}
return true;
}
}; };
const browserViewMediateService = (browserViewId: number): BrowserView => { const browserViewMediateService = (browserViewId: number): BrowserView => {
return getBrowserViewById(browserViewId); return getBrowserViewById(browserViewId);
}; };
function getBrowserViewById(id: number) { function getBrowserViewById(id: number) {
for (let index = 0; index < browserViews.length; index++) { for (let index = 0; index < browserViews.length; index++) {
const browserViewItem = browserViews[index]; const browserViewItem = browserViews[index];
if (browserViewItem['id'] === id) { if (browserViewItem["id"] === id) {
return browserViewItem; return browserViewItem;
}
} }
}
} }
export { browserViewApi, browserViewMediateService }; export { browserViewApi, browserViewMediateService };

View File

@@ -1,12 +1,46 @@
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
const path = __importStar(require("path"));
const electron_1 = require("electron"); const electron_1 = require("electron");
const browserView_1 = require("./browserView"); const browserView_1 = require("./browserView");
const path = require("path");
const windows = (global["browserWindows"] = const windows = (global["browserWindows"] =
global["browserWindows"] || []); global["browserWindows"] || []);
let readyToShowWindowsIds = []; let readyToShowWindowsIds = [];
let window, lastOptions, electronSocket; let window;
let mainWindowURL; let lastOptions;
let electronSocket;
const proxyToCredentialsMap = (global["proxyToCredentialsMap"] = global["proxyToCredentialsMap"] || []); const proxyToCredentialsMap = (global["proxyToCredentialsMap"] = global["proxyToCredentialsMap"] || []);
module.exports = (socket, app) => { module.exports = (socket, app) => {
electronSocket = socket; electronSocket = socket;
@@ -112,6 +146,12 @@ module.exports = (socket, app) => {
electronSocket.emit("browserWindow-move" + id); electronSocket.emit("browserWindow-move" + id);
}); });
}); });
socket.on("register-browserWindow-bounds-changed", (id) => {
const window = getWindowById(id);
const cb = () => electronSocket.emit("browserWindow-bounds-changed" + id, window.getBounds());
window.on("resize", cb);
window.on("move", cb);
});
socket.on("register-browserWindow-moved", (id) => { socket.on("register-browserWindow-moved", (id) => {
getWindowById(id).on("moved", () => { getWindowById(id).on("moved", () => {
electronSocket.emit("browserWindow-moved" + id); electronSocket.emit("browserWindow-moved" + id);
@@ -237,7 +277,27 @@ module.exports = (socket, app) => {
} }
}); });
if (loadUrl) { if (loadUrl) {
window.loadURL(loadUrl); // Append authentication token to initial URL if available
const token = global["authToken"];
if (token) {
try {
const url = new URL(loadUrl);
const isLocal = url.hostname === "localhost" ||
url.hostname === "127.0.0.1" ||
url.hostname === "::1";
if (isLocal) {
url.searchParams.set("token", token);
}
window.loadURL(url.toString());
}
catch {
// Handle invalid URLs or file:// URLs if needed
window.loadURL(loadUrl);
}
}
else {
window.loadURL(loadUrl);
}
} }
if (app.commandLine.hasSwitch("clear-cache") && if (app.commandLine.hasSwitch("clear-cache") &&
app.commandLine.getSwitchValue("clear-cache")) { app.commandLine.getSwitchValue("clear-cache")) {

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,18 @@
import { Socket } from "net"; import * as path from "path";
import { BrowserWindow, Menu, nativeImage } from "electron"; import type { Socket } from "net";
import { BrowserWindow, Menu } from "electron";
import { browserViewMediateService } from "./browserView"; import { browserViewMediateService } from "./browserView";
const path = require("path");
const windows: Electron.BrowserWindow[] = (global["browserWindows"] = const windows: Electron.BrowserWindow[] = (global["browserWindows"] =
global["browserWindows"] || []) as Electron.BrowserWindow[]; global["browserWindows"] || []) as Electron.BrowserWindow[];
let readyToShowWindowsIds: number[] = []; let readyToShowWindowsIds: number[] = [];
let window, lastOptions, electronSocket;
let mainWindowURL; let window;
let lastOptions;
let electronSocket;
const proxyToCredentialsMap: { [proxy: string]: string } = (global[ const proxyToCredentialsMap: { [proxy: string]: string } = (global[
"proxyToCredentialsMap" "proxyToCredentialsMap"
] = global["proxyToCredentialsMap"] || []) as { [proxy: string]: string }; ] = global["proxyToCredentialsMap"] || []) as { [proxy: string]: string };
@@ -32,7 +38,7 @@ export = (socket: Socket, app: Electron.App) => {
socket.on("register-browserWindow-ready-to-show", (id) => { socket.on("register-browserWindow-ready-to-show", (id) => {
if (readyToShowWindowsIds.includes(id)) { if (readyToShowWindowsIds.includes(id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter( readyToShowWindowsIds = readyToShowWindowsIds.filter(
(value) => value !== id (value) => value !== id,
); );
electronSocket.emit("browserWindow-ready-to-show" + id); electronSocket.emit("browserWindow-ready-to-show" + id);
} }
@@ -139,6 +145,17 @@ export = (socket: Socket, app: Electron.App) => {
}); });
}); });
socket.on("register-browserWindow-bounds-changed", (id) => {
const window = getWindowById(id);
const cb = () =>
electronSocket.emit(
"browserWindow-bounds-changed" + id,
window.getBounds(),
);
window.on("resize", cb);
window.on("move", cb);
});
socket.on("register-browserWindow-moved", (id) => { socket.on("register-browserWindow-moved", (id) => {
getWindowById(id).on("moved", () => { getWindowById(id).on("moved", () => {
electronSocket.emit("browserWindow-moved" + id); electronSocket.emit("browserWindow-moved" + id);
@@ -224,7 +241,7 @@ export = (socket: Socket, app: Electron.App) => {
__dirname, __dirname,
"..", "..",
"scripts", "scripts",
"blazor-preload.js" "blazor-preload.js",
); );
} }
@@ -257,7 +274,7 @@ export = (socket: Socket, app: Electron.App) => {
window.on("ready-to-show", () => { window.on("ready-to-show", () => {
if (readyToShowWindowsIds.includes(window.id)) { if (readyToShowWindowsIds.includes(window.id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter( readyToShowWindowsIds = readyToShowWindowsIds.filter(
(value) => value !== window.id (value) => value !== window.id,
); );
} else { } else {
readyToShowWindowsIds.push(window.id); readyToShowWindowsIds.push(window.id);
@@ -292,7 +309,30 @@ export = (socket: Socket, app: Electron.App) => {
}); });
if (loadUrl) { if (loadUrl) {
window.loadURL(loadUrl); // Append authentication token to initial URL if available
const token = global["authToken"];
if (token) {
try {
const url = new URL(loadUrl);
const isLocal =
url.hostname === "localhost" ||
url.hostname === "127.0.0.1" ||
url.hostname === "::1";
if (isLocal) {
url.searchParams.set("token", token);
}
window.loadURL(url.toString());
} catch {
// Handle invalid URLs or file:// URLs if needed
window.loadURL(loadUrl);
}
} else {
window.loadURL(loadUrl);
}
} }
if ( if (
@@ -524,7 +564,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit( electronSocket.emit(
"browserWindow-isFullScreenable-completed", "browserWindow-isFullScreenable-completed",
fullscreenable fullscreenable,
); );
}); });
@@ -609,7 +649,7 @@ export = (socket: Socket, app: Electron.App) => {
.toString(16); .toString(16);
electronSocket.emit( electronSocket.emit(
"browserWindow-getNativeWindowHandle-completed", "browserWindow-getNativeWindowHandle-completed",
nativeWindowHandle nativeWindowHandle,
); );
}); });
@@ -622,7 +662,7 @@ export = (socket: Socket, app: Electron.App) => {
} catch (e) { } catch (e) {
console.warn( console.warn(
"setRepresentedFilename failed (likely unsupported platform):", "setRepresentedFilename failed (likely unsupported platform):",
e e,
); );
} }
}); });
@@ -637,12 +677,12 @@ export = (socket: Socket, app: Electron.App) => {
} catch (e) { } catch (e) {
console.warn( console.warn(
"getRepresentedFilename failed (likely unsupported platform):", "getRepresentedFilename failed (likely unsupported platform):",
e e,
); );
} }
electronSocket.emit( electronSocket.emit(
"browserWindow-getRepresentedFilename-completed", "browserWindow-getRepresentedFilename-completed",
pathname pathname,
); );
}); });
@@ -734,7 +774,7 @@ export = (socket: Socket, app: Electron.App) => {
imagePath = path.join( imagePath = path.join(
__dirname.replace("api", ""), __dirname.replace("api", ""),
"bin", "bin",
originalIconPath originalIconPath,
); );
} }
const { nativeImage } = require("electron"); const { nativeImage } = require("electron");
@@ -751,7 +791,7 @@ export = (socket: Socket, app: Electron.App) => {
const success = getWindowById(id).setThumbarButtons(thumbarButtons); const success = getWindowById(id).setThumbarButtons(thumbarButtons);
electronSocket.emit("browserWindowSetThumbarButtons-completed", success); electronSocket.emit("browserWindowSetThumbarButtons-completed", success);
} },
); );
socket.on("browserWindowSetThumbnailClip", (id, rectangle) => { socket.on("browserWindowSetThumbnailClip", (id, rectangle) => {
@@ -779,7 +819,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit( electronSocket.emit(
"browserWindow-isMenuBarAutoHide-completed", "browserWindow-isMenuBarAutoHide-completed",
isMenuBarAutoHide isMenuBarAutoHide,
); );
}); });
@@ -792,7 +832,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit( electronSocket.emit(
"browserWindow-isMenuBarVisible-completed", "browserWindow-isMenuBarVisible-completed",
isMenuBarVisible isMenuBarVisible,
); );
}); });
@@ -806,7 +846,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit( electronSocket.emit(
"browserWindow-isVisibleOnAllWorkspaces-completed", "browserWindow-isVisibleOnAllWorkspaces-completed",
isVisibleOnAllWorkspaces isVisibleOnAllWorkspaces,
); );
}); });
@@ -838,7 +878,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit( electronSocket.emit(
"browserWindow-getParentWindow-completed", "browserWindow-getParentWindow-completed",
browserWindow.id browserWindow.id,
); );
}); });

View File

@@ -3,63 +3,65 @@ const electron_1 = require("electron");
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('clipboard-readText', (type) => { socket.on("clipboard-readText", (type) => {
const text = electron_1.clipboard.readText(type); const text = electron_1.clipboard.readText(type);
electronSocket.emit('clipboard-readText-completed', text); electronSocket.emit("clipboard-readText-completed", text);
}); });
socket.on('clipboard-writeText', (text, type) => { socket.on("clipboard-writeText", (text, type) => {
electron_1.clipboard.writeText(text, type); electron_1.clipboard.writeText(text, type);
}); });
socket.on('clipboard-readHTML', (type) => { socket.on("clipboard-readHTML", (type) => {
const content = electron_1.clipboard.readHTML(type); const content = electron_1.clipboard.readHTML(type);
electronSocket.emit('clipboard-readHTML-completed', content); electronSocket.emit("clipboard-readHTML-completed", content);
}); });
socket.on('clipboard-writeHTML', (markup, type) => { socket.on("clipboard-writeHTML", (markup, type) => {
electron_1.clipboard.writeHTML(markup, type); electron_1.clipboard.writeHTML(markup, type);
}); });
socket.on('clipboard-readRTF', (type) => { socket.on("clipboard-readRTF", (type) => {
const content = electron_1.clipboard.readRTF(type); const content = electron_1.clipboard.readRTF(type);
electronSocket.emit('clipboard-readRTF-completed', content); electronSocket.emit("clipboard-readRTF-completed", content);
}); });
socket.on('clipboard-writeRTF', (text, type) => { socket.on("clipboard-writeRTF", (text, type) => {
electron_1.clipboard.writeHTML(text, type); electron_1.clipboard.writeHTML(text, type);
}); });
socket.on('clipboard-readBookmark', () => { socket.on("clipboard-readBookmark", () => {
const bookmark = electron_1.clipboard.readBookmark(); const bookmark = electron_1.clipboard.readBookmark();
electronSocket.emit('clipboard-readBookmark-completed', bookmark); electronSocket.emit("clipboard-readBookmark-completed", bookmark);
}); });
socket.on('clipboard-writeBookmark', (title, url, type) => { socket.on("clipboard-writeBookmark", (title, url, type) => {
electron_1.clipboard.writeBookmark(title, url, type); electron_1.clipboard.writeBookmark(title, url, type);
}); });
socket.on('clipboard-readFindText', () => { socket.on("clipboard-readFindText", () => {
const content = electron_1.clipboard.readFindText(); const content = electron_1.clipboard.readFindText();
electronSocket.emit('clipboard-readFindText-completed', content); electronSocket.emit("clipboard-readFindText-completed", content);
}); });
socket.on('clipboard-writeFindText', (text) => { socket.on("clipboard-writeFindText", (text) => {
electron_1.clipboard.writeFindText(text); electron_1.clipboard.writeFindText(text);
}); });
socket.on('clipboard-clear', (type) => { socket.on("clipboard-clear", (type) => {
electron_1.clipboard.clear(type); electron_1.clipboard.clear(type);
}); });
socket.on('clipboard-availableFormats', (type) => { socket.on("clipboard-availableFormats", (type) => {
const formats = electron_1.clipboard.availableFormats(type); const formats = electron_1.clipboard.availableFormats(type);
electronSocket.emit('clipboard-availableFormats-completed', formats); electronSocket.emit("clipboard-availableFormats-completed", formats);
}); });
socket.on('clipboard-write', (data, type) => { socket.on("clipboard-write", (data, type) => {
electron_1.clipboard.write(data, type); electron_1.clipboard.write(data, type);
}); });
socket.on('clipboard-readImage', (type) => { socket.on("clipboard-readImage", (type) => {
const image = electron_1.clipboard.readImage(type); const image = electron_1.clipboard.readImage(type);
electronSocket.emit('clipboard-readImage-completed', { 1: image.toPNG().toString('base64') }); electronSocket.emit("clipboard-readImage-completed", {
1: image.toPNG().toString("base64"),
});
}); });
socket.on('clipboard-writeImage', (data, type) => { socket.on("clipboard-writeImage", (data, type) => {
const dataContent = JSON.parse(data); const dataContent = JSON.parse(data);
const image = electron_1.nativeImage.createEmpty(); const image = electron_1.nativeImage.createEmpty();
// tslint:disable-next-line: forin // tslint:disable-next-line: forin
for (const key in dataContent) { for (const key in dataContent) {
const scaleFactor = key; const scaleFactor = key;
const bytes = data[key]; const bytes = data[key];
const buffer = Buffer.from(bytes, 'base64'); const buffer = Buffer.from(bytes, "base64");
image.addRepresentation({ scaleFactor: +scaleFactor, buffer: buffer }); image.addRepresentation({ scaleFactor: +scaleFactor, buffer: buffer });
} }
electron_1.clipboard.writeImage(image, type); electron_1.clipboard.writeImage(image, type);

View File

@@ -1 +1 @@
{"version":3,"file":"clipboard.js","sourceRoot":"","sources":["clipboard.ts"],"names":[],"mappings":";AACA,uCAAkD;AAClD,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,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;IACjE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,qBAAqB,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;QAC9C,oBAAS,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,IAAI,EAAE,E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{ Socket } from "net";
import { clipboard, nativeImage } from 'electron'; import { clipboard, nativeImage } from "electron";
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('clipboard-readText', (type) => { socket.on("clipboard-readText", (type) => {
const text = clipboard.readText(type); const text = clipboard.readText(type);
electronSocket.emit('clipboard-readText-completed', text); electronSocket.emit("clipboard-readText-completed", text);
});
socket.on("clipboard-writeText", (text, type) => {
clipboard.writeText(text, type);
});
socket.on("clipboard-readHTML", (type) => {
const content = clipboard.readHTML(type);
electronSocket.emit("clipboard-readHTML-completed", content);
});
socket.on("clipboard-writeHTML", (markup, type) => {
clipboard.writeHTML(markup, type);
});
socket.on("clipboard-readRTF", (type) => {
const content = clipboard.readRTF(type);
electronSocket.emit("clipboard-readRTF-completed", content);
});
socket.on("clipboard-writeRTF", (text, type) => {
clipboard.writeHTML(text, type);
});
socket.on("clipboard-readBookmark", () => {
const bookmark = clipboard.readBookmark();
electronSocket.emit("clipboard-readBookmark-completed", bookmark);
});
socket.on("clipboard-writeBookmark", (title, url, type) => {
clipboard.writeBookmark(title, url, type);
});
socket.on("clipboard-readFindText", () => {
const content = clipboard.readFindText();
electronSocket.emit("clipboard-readFindText-completed", content);
});
socket.on("clipboard-writeFindText", (text) => {
clipboard.writeFindText(text);
});
socket.on("clipboard-clear", (type) => {
clipboard.clear(type);
});
socket.on("clipboard-availableFormats", (type) => {
const formats = clipboard.availableFormats(type);
electronSocket.emit("clipboard-availableFormats-completed", formats);
});
socket.on("clipboard-write", (data, type) => {
clipboard.write(data, type);
});
socket.on("clipboard-readImage", (type) => {
const image = clipboard.readImage(type);
electronSocket.emit("clipboard-readImage-completed", {
1: image.toPNG().toString("base64"),
}); });
});
socket.on('clipboard-writeText', (text, type) => { socket.on("clipboard-writeImage", (data, type) => {
clipboard.writeText(text, type); const dataContent = JSON.parse(data);
}); const image = nativeImage.createEmpty();
socket.on('clipboard-readHTML', (type) => { // tslint:disable-next-line: forin
const content = clipboard.readHTML(type); for (const key in dataContent) {
electronSocket.emit('clipboard-readHTML-completed', content); const scaleFactor = key;
}); const bytes = data[key];
const buffer = Buffer.from(bytes, "base64");
image.addRepresentation({ scaleFactor: +scaleFactor, buffer: buffer });
}
socket.on('clipboard-writeHTML', (markup, type) => { clipboard.writeImage(image, type);
clipboard.writeHTML(markup, type); });
});
socket.on('clipboard-readRTF', (type) => {
const content = clipboard.readRTF(type);
electronSocket.emit('clipboard-readRTF-completed', content);
});
socket.on('clipboard-writeRTF', (text, type) => {
clipboard.writeHTML(text, type);
});
socket.on('clipboard-readBookmark', () => {
const bookmark = clipboard.readBookmark();
electronSocket.emit('clipboard-readBookmark-completed', bookmark);
});
socket.on('clipboard-writeBookmark', (title, url, type) => {
clipboard.writeBookmark(title, url, type);
});
socket.on('clipboard-readFindText', () => {
const content = clipboard.readFindText();
electronSocket.emit('clipboard-readFindText-completed', content);
});
socket.on('clipboard-writeFindText', (text) => {
clipboard.writeFindText(text);
});
socket.on('clipboard-clear', (type) => {
clipboard.clear(type);
});
socket.on('clipboard-availableFormats', (type) => {
const formats = clipboard.availableFormats(type);
electronSocket.emit('clipboard-availableFormats-completed', formats);
});
socket.on('clipboard-write', (data, type) => {
clipboard.write(data, type);
});
socket.on('clipboard-readImage', (type) => {
const image = clipboard.readImage(type);
electronSocket.emit('clipboard-readImage-completed', { 1: image.toPNG().toString('base64') });
});
socket.on('clipboard-writeImage', (data, type) => {
const dataContent = JSON.parse(data);
const image = nativeImage.createEmpty();
// tslint:disable-next-line: forin
for (const key in dataContent) {
const scaleFactor = key;
const bytes = data[key];
const buffer = Buffer.from(bytes, 'base64');
image.addRepresentation({ scaleFactor: +scaleFactor, buffer: buffer });
}
clipboard.writeImage(image, type);
});
}; };

View File

@@ -2,19 +2,19 @@
let electronSocket; let electronSocket;
module.exports = (socket, app) => { module.exports = (socket, app) => {
electronSocket = socket; electronSocket = socket;
socket.on('appCommandLineAppendSwitch', (the_switch, value) => { socket.on("appCommandLineAppendSwitch", (the_switch, value) => {
app.commandLine.appendSwitch(the_switch, value); app.commandLine.appendSwitch(the_switch, value);
}); });
socket.on('appCommandLineAppendArgument', (value) => { socket.on("appCommandLineAppendArgument", (value) => {
app.commandLine.appendArgument(value); app.commandLine.appendArgument(value);
}); });
socket.on('appCommandLineHasSwitch', (value) => { socket.on("appCommandLineHasSwitch", (value) => {
const hasSwitch = app.commandLine.hasSwitch(value); const hasSwitch = app.commandLine.hasSwitch(value);
electronSocket.emit('appCommandLineHasSwitchCompleted', hasSwitch); electronSocket.emit("appCommandLineHasSwitchCompleted", hasSwitch);
}); });
socket.on('appCommandLineGetSwitchValue', (the_switch) => { socket.on("appCommandLineGetSwitchValue", (the_switch) => {
const value = app.commandLine.getSwitchValue(the_switch); const value = app.commandLine.getSwitchValue(the_switch);
electronSocket.emit('appCommandLineGetSwitchValueCompleted', value); electronSocket.emit("appCommandLineGetSwitchValueCompleted", value);
}); });
}; };
//# sourceMappingURL=commandLine.js.map //# sourceMappingURL=commandLine.js.map

View File

@@ -1 +1 @@
{"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;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M,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACzD,cAAc,CAAC,IAAI,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

@@ -1,24 +1,28 @@
import { Socket } from 'net'; import type { Socket } from "net";
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket, app: Electron.App) => { export = (socket: Socket, app: Electron.App) => {
electronSocket = socket; electronSocket = socket;
socket.on('appCommandLineAppendSwitch', (the_switch: string, value: string) => { socket.on(
app.commandLine.appendSwitch(the_switch, value); "appCommandLineAppendSwitch",
}); (the_switch: string, value: string) => {
app.commandLine.appendSwitch(the_switch, value);
},
);
socket.on('appCommandLineAppendArgument', (value: string) => { socket.on("appCommandLineAppendArgument", (value: string) => {
app.commandLine.appendArgument(value); app.commandLine.appendArgument(value);
}); });
socket.on('appCommandLineHasSwitch', (value: string) => { socket.on("appCommandLineHasSwitch", (value: string) => {
const hasSwitch = app.commandLine.hasSwitch(value); const hasSwitch = app.commandLine.hasSwitch(value);
electronSocket.emit('appCommandLineHasSwitchCompleted', hasSwitch); electronSocket.emit("appCommandLineHasSwitchCompleted", hasSwitch);
}); });
socket.on('appCommandLineGetSwitchValue', (the_switch: string) => { socket.on("appCommandLineGetSwitchValue", (the_switch: string) => {
const value = app.commandLine.getSwitchValue(the_switch); const value = app.commandLine.getSwitchValue(the_switch);
electronSocket.emit('appCommandLineGetSwitchValueCompleted', value); electronSocket.emit("appCommandLineGetSwitchValueCompleted", value);
}); });
}; };

View File

@@ -3,35 +3,41 @@ const electron_1 = require("electron");
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('showMessageBox', async (browserWindow, options, guid) => { socket.on("showMessageBox", async (browserWindow, options, guid) => {
if ('id' in browserWindow) { if ("id" in browserWindow) {
const window = electron_1.BrowserWindow.fromId(browserWindow.id); const window = electron_1.BrowserWindow.fromId(browserWindow.id);
const messageBoxReturnValue = await electron_1.dialog.showMessageBox(window, options); const messageBoxReturnValue = await electron_1.dialog.showMessageBox(window, options);
electronSocket.emit('showMessageBoxComplete' + guid, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]); electronSocket.emit("showMessageBoxComplete" + guid, [
messageBoxReturnValue.response,
messageBoxReturnValue.checkboxChecked,
]);
} }
else { else {
const id = guid || options; const id = guid || options;
const messageBoxReturnValue = await electron_1.dialog.showMessageBox(browserWindow); const messageBoxReturnValue = await electron_1.dialog.showMessageBox(browserWindow);
electronSocket.emit('showMessageBoxComplete' + id, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]); electronSocket.emit("showMessageBoxComplete" + id, [
messageBoxReturnValue.response,
messageBoxReturnValue.checkboxChecked,
]);
} }
}); });
socket.on('showOpenDialog', async (browserWindow, options, guid) => { socket.on("showOpenDialog", async (browserWindow, options, guid) => {
const window = electron_1.BrowserWindow.fromId(browserWindow.id); const window = electron_1.BrowserWindow.fromId(browserWindow.id);
const openDialogReturnValue = await electron_1.dialog.showOpenDialog(window, options); const openDialogReturnValue = await electron_1.dialog.showOpenDialog(window, options);
electronSocket.emit('showOpenDialogComplete' + guid, openDialogReturnValue.filePaths || []); electronSocket.emit("showOpenDialogComplete" + guid, openDialogReturnValue.filePaths || []);
}); });
socket.on('showSaveDialog', async (browserWindow, options, guid) => { socket.on("showSaveDialog", async (browserWindow, options, guid) => {
const window = electron_1.BrowserWindow.fromId(browserWindow.id); const window = electron_1.BrowserWindow.fromId(browserWindow.id);
const saveDialogReturnValue = await electron_1.dialog.showSaveDialog(window, options); const saveDialogReturnValue = await electron_1.dialog.showSaveDialog(window, options);
electronSocket.emit('showSaveDialogComplete' + guid, saveDialogReturnValue.filePath || ''); electronSocket.emit("showSaveDialogComplete" + guid, saveDialogReturnValue.filePath || "");
}); });
socket.on('showErrorBox', (title, content) => { socket.on("showErrorBox", (title, content) => {
electron_1.dialog.showErrorBox(title, content); electron_1.dialog.showErrorBox(title, content);
}); });
socket.on('showCertificateTrustDialog', async (browserWindow, options, guid) => { socket.on("showCertificateTrustDialog", async (browserWindow, options, guid) => {
const window = electron_1.BrowserWindow.fromId(browserWindow.id); const window = electron_1.BrowserWindow.fromId(browserWindow.id);
await electron_1.dialog.showCertificateTrustDialog(window, options); await electron_1.dialog.showCertificateTrustDialog(window, options);
electronSocket.emit('showCertificateTrustDialogComplete' + guid); electronSocket.emit("showCertificateTrustDialogComplete" + guid);
}); });
}; };
//# sourceMappingURL=dialog.js.map //# sourceMappingURL=dialog.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["dialog.ts"],"names":[],"mappings":";AACA,uCAAiD;AACjD,IAAI,cAAsB,CAAC;AAE3B,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,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,CAAC;YACxB,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;QAClI,CAAC;aAAM,CAAC;YACJ,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,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rowserWindow, dialog } from "electron";
let electronSocket: Socket; let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('showMessageBox', async (browserWindow, options, guid) => { socket.on("showMessageBox", async (browserWindow, options, guid) => {
if ('id' in browserWindow) { if ("id" in browserWindow) {
const window = BrowserWindow.fromId(browserWindow.id); const window = BrowserWindow.fromId(browserWindow.id);
const messageBoxReturnValue = await dialog.showMessageBox(window, options); const messageBoxReturnValue = await dialog.showMessageBox(
electronSocket.emit('showMessageBoxComplete' + guid, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]); window,
} else { options,
const id = guid || options; );
const messageBoxReturnValue = await dialog.showMessageBox(browserWindow); electronSocket.emit("showMessageBoxComplete" + guid, [
messageBoxReturnValue.response,
messageBoxReturnValue.checkboxChecked,
]);
} else {
const id = guid || options;
const messageBoxReturnValue = await dialog.showMessageBox(browserWindow);
electronSocket.emit('showMessageBoxComplete' + id, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]); electronSocket.emit("showMessageBoxComplete" + id, [
} messageBoxReturnValue.response,
}); messageBoxReturnValue.checkboxChecked,
]);
}
});
socket.on('showOpenDialog', async (browserWindow, options, guid) => { socket.on("showOpenDialog", async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id); const window = BrowserWindow.fromId(browserWindow.id);
const openDialogReturnValue = await dialog.showOpenDialog(window, options); const openDialogReturnValue = await dialog.showOpenDialog(window, options);
electronSocket.emit('showOpenDialogComplete' + guid, openDialogReturnValue.filePaths || []); electronSocket.emit(
}); "showOpenDialogComplete" + guid,
openDialogReturnValue.filePaths || [],
);
});
socket.on('showSaveDialog', async (browserWindow, options, guid) => { socket.on("showSaveDialog", async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id); const window = BrowserWindow.fromId(browserWindow.id);
const saveDialogReturnValue = await dialog.showSaveDialog(window, options); const saveDialogReturnValue = await dialog.showSaveDialog(window, options);
electronSocket.emit('showSaveDialogComplete' + guid, saveDialogReturnValue.filePath || ''); electronSocket.emit(
}); "showSaveDialogComplete" + guid,
saveDialogReturnValue.filePath || "",
);
});
socket.on('showErrorBox', (title, content) => { socket.on("showErrorBox", (title, content) => {
dialog.showErrorBox(title, content); dialog.showErrorBox(title, content);
}); });
socket.on('showCertificateTrustDialog', async (browserWindow, options, guid) => { socket.on(
const window = BrowserWindow.fromId(browserWindow.id); "showCertificateTrustDialog",
await dialog.showCertificateTrustDialog(window, options); async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
await dialog.showCertificateTrustDialog(window, options);
electronSocket.emit('showCertificateTrustDialogComplete' + guid); electronSocket.emit("showCertificateTrustDialogComplete" + guid);
}); },
);
}; };

View File

@@ -3,49 +3,49 @@ const electron_1 = require("electron");
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('dock-bounce', (type) => { socket.on("dock-bounce", (type) => {
const id = electron_1.app.dock.bounce(type); const id = electron_1.app.dock.bounce(type);
electronSocket.emit('dock-bounce-completed', id); electronSocket.emit("dock-bounce-completed", id);
}); });
socket.on('dock-cancelBounce', (id) => { socket.on("dock-cancelBounce", (id) => {
electron_1.app.dock.cancelBounce(id); electron_1.app.dock.cancelBounce(id);
}); });
socket.on('dock-downloadFinished', (filePath) => { socket.on("dock-downloadFinished", (filePath) => {
electron_1.app.dock.downloadFinished(filePath); electron_1.app.dock.downloadFinished(filePath);
}); });
socket.on('dock-setBadge', (text) => { socket.on("dock-setBadge", (text) => {
electron_1.app.dock.setBadge(text); electron_1.app.dock.setBadge(text);
}); });
socket.on('dock-getBadge', () => { socket.on("dock-getBadge", () => {
const text = electron_1.app.dock.getBadge(); const text = electron_1.app.dock.getBadge();
electronSocket.emit('dock-getBadge-completed', text); electronSocket.emit("dock-getBadge-completed", text);
}); });
socket.on('dock-hide', () => { socket.on("dock-hide", () => {
electron_1.app.dock.hide(); electron_1.app.dock.hide();
}); });
socket.on('dock-show', () => { socket.on("dock-show", () => {
electron_1.app.dock.show(); electron_1.app.dock.show();
}); });
socket.on('dock-isVisible', () => { socket.on("dock-isVisible", () => {
const isVisible = electron_1.app.dock.isVisible(); const isVisible = electron_1.app.dock.isVisible();
electronSocket.emit('dock-isVisible-completed', isVisible); electronSocket.emit("dock-isVisible-completed", isVisible);
}); });
socket.on('dock-setMenu', (menuItems) => { socket.on("dock-setMenu", (menuItems) => {
let menu = null; let menu = null;
if (menuItems) { if (menuItems) {
menu = electron_1.Menu.buildFromTemplate(menuItems); menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => { addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('dockMenuItemClicked', id); electronSocket.emit("dockMenuItemClicked", id);
}); });
} }
electron_1.app.dock.setMenu(menu); electron_1.app.dock.setMenu(menu);
}); });
// TODO: Menu (macOS) still to be implemented // TODO: Menu (macOS) still to be implemented
socket.on('dock-getMenu', () => { socket.on("dock-getMenu", () => {
const menu = electron_1.app.dock.getMenu(); const menu = electron_1.app.dock.getMenu();
electronSocket.emit('dock-getMenu-completed', menu); electronSocket.emit("dock-getMenu-completed", menu);
}); });
socket.on('dock-setIcon', (image) => { socket.on("dock-setIcon", (image) => {
electron_1.app.dock.setIcon(image); electron_1.app.dock.setIcon(image);
}); });
function addMenuItemClickConnector(menuItems, callback) { function addMenuItemClickConnector(menuItems, callback) {
@@ -53,8 +53,10 @@ module.exports = (socket) => {
if (item.submenu && item.submenu.items.length > 0) { if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback); addMenuItemClickConnector(item.submenu.items, callback);
} }
if ('id' in item && item.id) { if ("id" in item && item.id) {
item.click = () => { callback(item.id); }; item.click = () => {
callback(item.id);
};
} }
}); });
} }

View File

@@ -1 +1 @@
{"version":3,"file":"dock.js","sourceRoot":"","sources":["dock.ts"],"names":[],"mappings":";AACA,uCAAqC;AACrC,IAAI,cA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;QAChC,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE;QAClC,cAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,SAAS,yBAAyB,CAAC,SAAS,EAAE,QAAQ;QACpD,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClD,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC1D,CAAC;YAED,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;gBAC5B,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE;oBAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACpB,CAAC,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}

View File

@@ -1,78 +1,81 @@
import { Socket } from 'net'; import type { Socket } from "net";
import { app, Menu } from 'electron'; import { app, Menu } from "electron";
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('dock-bounce', (type) => { socket.on("dock-bounce", (type) => {
const id = app.dock.bounce(type); const id = app.dock.bounce(type);
electronSocket.emit('dock-bounce-completed', id); electronSocket.emit("dock-bounce-completed", id);
}); });
socket.on('dock-cancelBounce', (id) => { socket.on("dock-cancelBounce", (id) => {
app.dock.cancelBounce(id); app.dock.cancelBounce(id);
}); });
socket.on('dock-downloadFinished', (filePath) => { socket.on("dock-downloadFinished", (filePath) => {
app.dock.downloadFinished(filePath); app.dock.downloadFinished(filePath);
}); });
socket.on('dock-setBadge', (text) => { socket.on("dock-setBadge", (text) => {
app.dock.setBadge(text); app.dock.setBadge(text);
}); });
socket.on('dock-getBadge', () => { socket.on("dock-getBadge", () => {
const text = app.dock.getBadge(); const text = app.dock.getBadge();
electronSocket.emit('dock-getBadge-completed', text); electronSocket.emit("dock-getBadge-completed", text);
}); });
socket.on('dock-hide', () => { socket.on("dock-hide", () => {
app.dock.hide(); app.dock.hide();
}); });
socket.on('dock-show', () => { socket.on("dock-show", () => {
app.dock.show(); app.dock.show();
}); });
socket.on('dock-isVisible', () => { socket.on("dock-isVisible", () => {
const isVisible = app.dock.isVisible(); const isVisible = app.dock.isVisible();
electronSocket.emit('dock-isVisible-completed', isVisible); electronSocket.emit("dock-isVisible-completed", isVisible);
}); });
socket.on('dock-setMenu', (menuItems) => { socket.on("dock-setMenu", (menuItems) => {
let menu = null; let menu = null;
if (menuItems) { if (menuItems) {
menu = Menu.buildFromTemplate(menuItems); menu = Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => { addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('dockMenuItemClicked', id); electronSocket.emit("dockMenuItemClicked", id);
}); });
}
app.dock.setMenu(menu);
});
// TODO: Menu (macOS) still to be implemented
socket.on('dock-getMenu', () => {
const menu = app.dock.getMenu();
electronSocket.emit('dock-getMenu-completed', menu);
});
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); };
}
});
} }
app.dock.setMenu(menu);
});
// TODO: Menu (macOS) still to be implemented
socket.on("dock-getMenu", () => {
const menu = app.dock.getMenu();
electronSocket.emit("dock-getMenu-completed", menu);
});
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

@@ -3,19 +3,19 @@ const electron_1 = require("electron");
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('globalShortcut-register', (accelerator) => { socket.on("globalShortcut-register", (accelerator) => {
electron_1.globalShortcut.register(accelerator, () => { electron_1.globalShortcut.register(accelerator, () => {
electronSocket.emit('globalShortcut-pressed', accelerator); electronSocket.emit("globalShortcut-pressed", accelerator);
}); });
}); });
socket.on('globalShortcut-isRegistered', (accelerator) => { socket.on("globalShortcut-isRegistered", (accelerator) => {
const isRegistered = electron_1.globalShortcut.isRegistered(accelerator); const isRegistered = electron_1.globalShortcut.isRegistered(accelerator);
electronSocket.emit('globalShortcut-isRegisteredCompleted', isRegistered); electronSocket.emit("globalShortcut-isRegisteredCompleted", isRegistered);
}); });
socket.on('globalShortcut-unregister', (accelerator) => { socket.on("globalShortcut-unregister", (accelerator) => {
electron_1.globalShortcut.unregister(accelerator); electron_1.globalShortcut.unregister(accelerator);
}); });
socket.on('globalShortcut-unregisterAll', () => { socket.on("globalShortcut-unregisterAll", () => {
try { try {
electron_1.globalShortcut.unregisterAll(); electron_1.globalShortcut.unregisterAll();
} }

View File

@@ -1 +1 @@
{"version":3,"file":"globalShortcut.js","sourceRoot":"","sources":["globalShortcut.ts"],"names":[],"mappings":";AAAA,uCAA0C;AAE1C,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,WAAW,EAAE,EAAE;QACjD,yBAAc,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;YACtC,cAAc,CAAC,IAAI,CAAC,wBAAwB,EA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EAAE,YAAY,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2BAA2B,EAAE,CAAC,WAAW,EAAE,EAAE;QACrD,yBAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QAC7C,IAAI,CAAC;YACH,yBAAc,CAAC,aAAa,EAAE,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC,CAAA,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

@@ -1,28 +1,29 @@
import { globalShortcut } from 'electron'; import type { Socket } from "net";
import { Socket } from 'net'; import { globalShortcut } from "electron";
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('globalShortcut-register', (accelerator) => { socket.on("globalShortcut-register", (accelerator) => {
globalShortcut.register(accelerator, () => { globalShortcut.register(accelerator, () => {
electronSocket.emit('globalShortcut-pressed', accelerator); electronSocket.emit("globalShortcut-pressed", accelerator);
});
}); });
});
socket.on('globalShortcut-isRegistered', (accelerator) => { socket.on("globalShortcut-isRegistered", (accelerator) => {
const isRegistered = globalShortcut.isRegistered(accelerator); const isRegistered = globalShortcut.isRegistered(accelerator);
electronSocket.emit('globalShortcut-isRegisteredCompleted', isRegistered); electronSocket.emit("globalShortcut-isRegisteredCompleted", isRegistered);
}); });
socket.on('globalShortcut-unregister', (accelerator) => { socket.on("globalShortcut-unregister", (accelerator) => {
globalShortcut.unregister(accelerator); globalShortcut.unregister(accelerator);
}); });
socket.on('globalShortcut-unregisterAll', () => { socket.on("globalShortcut-unregisterAll", () => {
try { try {
globalShortcut.unregisterAll(); globalShortcut.unregisterAll();
} catch (error) { } } catch (error) {}
}); });
}; };

View File

@@ -3,40 +3,41 @@ const electron_1 = require("electron");
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('registerIpcMainChannel', (channel) => { socket.on("registerIpcMainChannel", (channel) => {
electron_1.ipcMain.on(channel, (event, args) => { electron_1.ipcMain.on(channel, (event, args) => {
electronSocket.emit(channel, [event.preventDefault(), args]); electronSocket.emit(channel, [event.preventDefault(), args]);
}); });
}); });
socket.on('registerSyncIpcMainChannel', (channel) => { socket.on("registerSyncIpcMainChannel", (channel) => {
electron_1.ipcMain.on(channel, (event, args) => { electron_1.ipcMain.on(channel, (event, args) => {
const x = socket; const x = socket;
x.removeAllListeners(channel + 'Sync'); x.removeAllListeners(channel + "Sync");
socket.on(channel + 'Sync', (result) => { socket.on(channel + "Sync", (result) => {
event.returnValue = result; event.returnValue = result;
}); });
electronSocket.emit(channel, [event.preventDefault(), args]); electronSocket.emit(channel, [event.preventDefault(), args]);
}); });
}); });
socket.on('registerOnceIpcMainChannel', (channel) => { socket.on("registerOnceIpcMainChannel", (channel) => {
electron_1.ipcMain.once(channel, (event, args) => { electron_1.ipcMain.once(channel, (event, args) => {
electronSocket.emit(channel, [event.preventDefault(), args]); electronSocket.emit(channel, [event.preventDefault(), args]);
}); });
}); });
socket.on('removeAllListenersIpcMainChannel', (channel) => { socket.on("removeAllListenersIpcMainChannel", (channel) => {
electron_1.ipcMain.removeAllListeners(channel); electron_1.ipcMain.removeAllListeners(channel);
}); });
socket.on('sendToIpcRenderer', (browserWindow, channel, data) => { socket.on("sendToIpcRenderer", (browserWindow, channel, data) => {
const window = electron_1.BrowserWindow.fromId(browserWindow.id); const window = electron_1.BrowserWindow.fromId(browserWindow.id);
if (window) { if (window) {
window.webContents.send(channel, ...data); window.webContents.send(channel, ...data);
} }
}); });
socket.on('sendToIpcRendererBrowserView', (id, channel, data) => { socket.on("sendToIpcRendererBrowserView", (id, channel, data) => {
const browserViews = (global['browserViews'] = global['browserViews'] || []); const browserViews = (global["browserViews"] =
global["browserViews"] || []);
let view = null; let view = null;
for (let i = 0; i < browserViews.length; i++) { for (let i = 0; i < browserViews.length; i++) {
if (browserViews[i]['id'] === id) { if (browserViews[i]["id"] === id) {
view = browserViews[i]; view = browserViews[i];
break; break;
} }
@@ -45,29 +46,58 @@ module.exports = (socket) => {
view.webContents.send(channel, ...data); view.webContents.send(channel, ...data);
} }
}); });
socket.on("registerHandleIpcMainChannel", (channel) => {
electron_1.ipcMain.handle(channel, (event, args) => {
return new Promise((resolve, _reject) => {
socket.removeAllListeners(channel + "Handle");
socket.on(channel + "Handle", (result) => {
resolve(result);
});
electronSocket.emit(channel, [event.preventDefault(), args]);
});
});
});
socket.on("registerHandleOnceIpcMainChannel", (channel) => {
electron_1.ipcMain.handleOnce(channel, (event, args) => {
return new Promise((resolve, _reject) => {
socket.removeAllListeners(channel + "HandleOnce");
socket.once(channel + "HandleOnce", (result) => {
resolve(result);
});
electronSocket.emit(channel, [event.preventDefault(), args]);
});
});
});
socket.on("removeHandlerIpcMainChannel", (channel) => {
electron_1.ipcMain.removeHandler(channel);
});
// Integration helpers: programmatically click menu items from renderer tests // Integration helpers: programmatically click menu items from renderer tests
electron_1.ipcMain.on('integration-click-application-menu', (event, id) => { electron_1.ipcMain.on("integration-click-application-menu", (event, id) => {
try { try {
const menu = electron_1.Menu.getApplicationMenu(); const menu = electron_1.Menu.getApplicationMenu();
const mi = menu ? menu.getMenuItemById(id) : null; const mi = menu ? menu.getMenuItemById(id) : null;
if (mi && typeof mi.click === 'function') { if (mi && typeof mi.click === "function") {
const bw = electron_1.BrowserWindow.fromWebContents(event.sender); const bw = electron_1.BrowserWindow.fromWebContents(event.sender);
mi.click(undefined, bw, undefined); mi.click(undefined, bw, undefined);
} }
} }
catch { /* ignore */ } catch {
/* ignore */
}
}); });
electron_1.ipcMain.on('integration-click-context-menu', (event, windowId, id) => { electron_1.ipcMain.on("integration-click-context-menu", (event, windowId, id) => {
try { try {
const entries = global['contextMenuItems'] || []; const entries = global["contextMenuItems"] || [];
const entry = entries.find((x) => x.browserWindowId === windowId); const entry = entries.find((x) => x.browserWindowId === windowId);
const mi = entry?.menu?.items?.find((i) => i.id === id); const mi = entry?.menu?.items?.find((i) => i.id === id);
if (mi && typeof mi.click === 'function') { if (mi && typeof mi.click === "function") {
const bw = electron_1.BrowserWindow.fromId(windowId); const bw = electron_1.BrowserWindow.fromId(windowId);
mi.click(undefined, bw, undefined); mi.click(undefined, bw, undefined);
} }
} }
catch { /* ignore */ } catch {
/* ignore */
}
}); });
}; };
//# sourceMappingURL=ipc.js.map //# sourceMappingURL=ipc.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"ipc.js","sourceRoot":"","sources":["ipc.ts"],"names":[],"mappings":";AAAA,uCAAqE;AAErE,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC,OAAO,EAAE,EAAE;QAC5C,kBAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,CAAC,OAAO,EAAE,EAAE;QAChD,kBAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChC,MAAM,CAAC,GAAQ,MAAM,CAAC;YACtB,CAAC,CAAC,kBAAkB,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;YACvC,MAAM,CAAC,EAAE,CAAC,OAAO,GAAG,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;gBACnC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC;YAC/B,CAAC,CAAC,CAAC;YAEH,cAAc,CAAC,IAA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M,OAAO,GAAI,MAAc,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,KAAK,QAAQ,CAAC,CAAC;YACvE,MAAM,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7D,IAAI,EAAE,IAAI,OAAQ,EAAU,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;gBAClD,MAAM,EAAE,GAAG,wBAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACzC,EAAU,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}

View File

@@ -1,81 +1,118 @@
import { ipcMain, BrowserWindow, BrowserView, Menu } from 'electron'; import type { Socket } from "net";
import { Socket } from 'net'; import { ipcMain, BrowserWindow, BrowserView, Menu } from "electron";
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('registerIpcMainChannel', (channel) => { socket.on("registerIpcMainChannel", (channel) => {
ipcMain.on(channel, (event, args) => { ipcMain.on(channel, (event, args) => {
electronSocket.emit(channel, [event.preventDefault(), args]); electronSocket.emit(channel, [event.preventDefault(), args]);
});
});
socket.on("registerSyncIpcMainChannel", (channel) => {
ipcMain.on(channel, (event, args) => {
const x = <any>socket;
x.removeAllListeners(channel + "Sync");
socket.on(channel + "Sync", (result) => {
event.returnValue = result;
});
electronSocket.emit(channel, [event.preventDefault(), args]);
});
});
socket.on("registerOnceIpcMainChannel", (channel) => {
ipcMain.once(channel, (event, args) => {
electronSocket.emit(channel, [event.preventDefault(), args]);
});
});
socket.on("removeAllListenersIpcMainChannel", (channel) => {
ipcMain.removeAllListeners(channel);
});
socket.on("sendToIpcRenderer", (browserWindow, channel, data) => {
const window = BrowserWindow.fromId(browserWindow.id);
if (window) {
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);
}
});
socket.on("registerHandleIpcMainChannel", (channel) => {
ipcMain.handle(channel, (event, args) => {
return new Promise((resolve, _reject) => {
socket.removeAllListeners(channel + "Handle");
socket.on(channel + "Handle", (result) => {
resolve(result);
}); });
electronSocket.emit(channel, [event.preventDefault(), args]);
});
}); });
});
socket.on('registerSyncIpcMainChannel', (channel) => { socket.on("registerHandleOnceIpcMainChannel", (channel) => {
ipcMain.on(channel, (event, args) => { ipcMain.handleOnce(channel, (event, args) => {
const x = <any>socket; return new Promise((resolve, _reject) => {
x.removeAllListeners(channel + 'Sync'); socket.removeAllListeners(channel + "HandleOnce");
socket.on(channel + 'Sync', (result) => { socket.once(channel + "HandleOnce", (result) => {
event.returnValue = result; resolve(result);
});
electronSocket.emit(channel, [event.preventDefault(), args]);
}); });
electronSocket.emit(channel, [event.preventDefault(), args]);
});
}); });
});
socket.on('registerOnceIpcMainChannel', (channel) => { socket.on("removeHandlerIpcMainChannel", (channel) => {
ipcMain.once(channel, (event, args) => { ipcMain.removeHandler(channel);
electronSocket.emit(channel, [event.preventDefault(), args]); });
});
});
socket.on('removeAllListenersIpcMainChannel', (channel) => { // Integration helpers: programmatically click menu items from renderer tests
ipcMain.removeAllListeners(channel); ipcMain.on("integration-click-application-menu", (event, id: string) => {
}); try {
const menu = Menu.getApplicationMenu();
const mi = menu ? menu.getMenuItemById(id) : null;
if (mi && typeof (mi as any).click === "function") {
const bw = BrowserWindow.fromWebContents(event.sender);
(mi as any).click(undefined, bw, undefined);
}
} catch {
/* ignore */
}
});
socket.on('sendToIpcRenderer', (browserWindow, channel, data) => { ipcMain.on(
const window = BrowserWindow.fromId(browserWindow.id); "integration-click-context-menu",
(event, windowId: number, id: string) => {
if (window) { try {
window.webContents.send(channel, ...data); const entries = (global as any)["contextMenuItems"] || [];
const entry = entries.find((x: any) => x.browserWindowId === windowId);
const mi = entry?.menu?.items?.find((i: any) => i.id === id);
if (mi && typeof (mi as any).click === "function") {
const bw = BrowserWindow.fromId(windowId);
(mi as any).click(undefined, bw, undefined);
} }
}); } catch {
/* ignore */
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);
}
});
// Integration helpers: programmatically click menu items from renderer tests
ipcMain.on('integration-click-application-menu', (event, id: string) => {
try {
const menu = Menu.getApplicationMenu();
const mi = menu ? menu.getMenuItemById(id) : null;
if (mi && typeof (mi as any).click === 'function') {
const bw = BrowserWindow.fromWebContents(event.sender);
(mi as any).click(undefined, bw, undefined);
}
} catch { /* ignore */ }
});
ipcMain.on('integration-click-context-menu', (event, windowId: number, id: string) => {
try {
const entries = (global as any)['contextMenuItems'] || [];
const entry = entries.find((x: any) => x.browserWindowId === windowId);
const mi = entry?.menu?.items?.find((i: any) => i.id === id);
if (mi && typeof (mi as any).click === 'function') {
const bw = BrowserWindow.fromId(windowId);
(mi as any).click(undefined, bw, undefined);
}
} catch { /* ignore */ }
});
}; };

View File

@@ -1,18 +1,19 @@
"use strict"; "use strict";
const electron_1 = require("electron"); const electron_1 = require("electron");
const contextMenuItems = (global['contextMenuItems'] = global['contextMenuItems'] || []); const contextMenuItems = (global["contextMenuItems"] =
global["contextMenuItems"] || []);
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('menu-setContextMenu', (browserWindowId, menuItems) => { socket.on("menu-setContextMenu", (browserWindowId, menuItems) => {
const menu = electron_1.Menu.buildFromTemplate(menuItems); const menu = electron_1.Menu.buildFromTemplate(menuItems);
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, windowId) => { addContextMenuItemClickConnector(menu.items, browserWindowId, (id, windowId) => {
electronSocket.emit('contextMenuItemClicked', [id, windowId]); electronSocket.emit("contextMenuItemClicked", [id, windowId]);
}); });
const index = contextMenuItems.findIndex(contextMenu => contextMenu.browserWindowId === browserWindowId); const index = contextMenuItems.findIndex((contextMenu) => contextMenu.browserWindowId === browserWindowId);
const contextMenuItem = { const contextMenuItem = {
menu: menu, menu: menu,
browserWindowId: browserWindowId browserWindowId: browserWindowId,
}; };
if (index === -1) { if (index === -1) {
contextMenuItems.push(contextMenuItem); contextMenuItems.push(contextMenuItem);
@@ -26,23 +27,25 @@ module.exports = (socket) => {
if (item.submenu && item.submenu.items.length > 0) { if (item.submenu && item.submenu.items.length > 0) {
addContextMenuItemClickConnector(item.submenu.items, browserWindowId, callback); addContextMenuItemClickConnector(item.submenu.items, browserWindowId, callback);
} }
if ('id' in item && item.id) { if ("id" in item && item.id) {
item.click = () => { callback(item.id, browserWindowId); }; item.click = () => {
callback(item.id, browserWindowId);
};
} }
}); });
} }
socket.on('menu-contextMenuPopup', (browserWindowId) => { socket.on("menu-contextMenuPopup", (browserWindowId) => {
contextMenuItems.forEach(x => { contextMenuItems.forEach((x) => {
if (x.browserWindowId === browserWindowId) { if (x.browserWindowId === browserWindowId) {
const browserWindow = electron_1.BrowserWindow.fromId(browserWindowId); const browserWindow = electron_1.BrowserWindow.fromId(browserWindowId);
x.menu.popup(browserWindow); x.menu.popup(browserWindow);
} }
}); });
}); });
socket.on('menu-setApplicationMenu', (menuItems) => { socket.on("menu-setApplicationMenu", (menuItems) => {
const menu = electron_1.Menu.buildFromTemplate(menuItems); const menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => { addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('menuItemClicked', id); electronSocket.emit("menuItemClicked", id);
}); });
electron_1.Menu.setApplicationMenu(menu); electron_1.Menu.setApplicationMenu(menu);
}); });
@@ -51,8 +54,10 @@ module.exports = (socket) => {
if (item.submenu && item.submenu.items.length > 0) { if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback); addMenuItemClickConnector(item.submenu.items, callback);
} }
if ('id' in item && item.id) { if ("id" in item && item.id) {
item.click = () => { callback(item.id); }; item.click = () => {
callback(item.id);
};
} }
}); });
} }

View File

@@ -1 +1 @@
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":";AACA,uCAA+C;AAC/C,MAAM,gBAAgB,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC;AACzF,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,qBAAqB,EAAE,CAAC,eAAe,EAAE,SAAS,EAAE,EAAE;QAC5D,MAAM,IAAI,GAAG,eAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAE/C,gCAAgC,CAAC,IAAI,CAAC,KAAK,EAAE,eAAe,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE;YAC3E,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,gBAAgB,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,eAAe,KA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B,CAAC,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}

View File

@@ -1,71 +1,92 @@
import { Socket } from 'net'; import type { Socket } from "net";
import { Menu, BrowserWindow } from 'electron'; import { Menu, BrowserWindow } from "electron";
const contextMenuItems = (global['contextMenuItems'] = global['contextMenuItems'] || []);
let electronSocket; const contextMenuItems = (global["contextMenuItems"] =
global["contextMenuItems"] || []);
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('menu-setContextMenu', (browserWindowId, menuItems) => { socket.on("menu-setContextMenu", (browserWindowId, menuItems) => {
const menu = Menu.buildFromTemplate(menuItems); const menu = Menu.buildFromTemplate(menuItems);
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, windowId) => { addContextMenuItemClickConnector(
electronSocket.emit('contextMenuItemClicked', [id, windowId]); menu.items,
}); browserWindowId,
(id, windowId) => {
electronSocket.emit("contextMenuItemClicked", [id, windowId]);
},
);
const index = contextMenuItems.findIndex(contextMenu => contextMenu.browserWindowId === browserWindowId); const index = contextMenuItems.findIndex(
(contextMenu) => contextMenu.browserWindowId === browserWindowId,
);
const contextMenuItem = { const contextMenuItem = {
menu: menu, menu: menu,
browserWindowId: browserWindowId browserWindowId: browserWindowId,
};
if (index === -1) {
contextMenuItems.push(contextMenuItem);
} else {
contextMenuItems[index] = contextMenuItem;
}
});
function addContextMenuItemClickConnector(
menuItems,
browserWindowId,
callback,
) {
menuItems.forEach((item) => {
if (item.submenu && item.submenu.items.length > 0) {
addContextMenuItemClickConnector(
item.submenu.items,
browserWindowId,
callback,
);
}
if ("id" in item && item.id) {
item.click = () => {
callback(item.id, browserWindowId);
}; };
}
});
}
if (index === -1) { socket.on("menu-contextMenuPopup", (browserWindowId) => {
contextMenuItems.push(contextMenuItem); contextMenuItems.forEach((x) => {
} else { if (x.browserWindowId === browserWindowId) {
contextMenuItems[index] = contextMenuItem; const browserWindow = BrowserWindow.fromId(browserWindowId);
} x.menu.popup(browserWindow);
}
});
});
socket.on("menu-setApplicationMenu", (menuItems) => {
const menu = Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit("menuItemClicked", id);
}); });
function addContextMenuItemClickConnector(menuItems, browserWindowId, callback) { Menu.setApplicationMenu(menu);
menuItems.forEach((item) => { });
if (item.submenu && item.submenu.items.length > 0) {
addContextMenuItemClickConnector(item.submenu.items, browserWindowId, callback);
}
if ('id' in item && item.id) { function addMenuItemClickConnector(menuItems, callback) {
item.click = () => { callback(item.id, browserWindowId); }; menuItems.forEach((item) => {
} if (item.submenu && item.submenu.items.length > 0) {
}); addMenuItemClickConnector(item.submenu.items, callback);
} }
socket.on('menu-contextMenuPopup', (browserWindowId) => { if ("id" in item && item.id) {
contextMenuItems.forEach(x => { item.click = () => {
if (x.browserWindowId === browserWindowId) { callback(item.id);
const browserWindow = BrowserWindow.fromId(browserWindowId); };
x.menu.popup(browserWindow); }
}
});
}); });
}
socket.on('menu-setApplicationMenu', (menuItems) => {
const menu = Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('menuItemClicked', id);
});
Menu.setApplicationMenu(menu);
});
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

@@ -3,28 +3,28 @@ const electron_1 = require("electron");
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('nativeTheme-shouldUseDarkColors', () => { socket.on("nativeTheme-shouldUseDarkColors", () => {
const shouldUseDarkColors = electron_1.nativeTheme.shouldUseDarkColors; const shouldUseDarkColors = electron_1.nativeTheme.shouldUseDarkColors;
electronSocket.emit('nativeTheme-shouldUseDarkColors-completed', shouldUseDarkColors); electronSocket.emit("nativeTheme-shouldUseDarkColors-completed", shouldUseDarkColors);
}); });
socket.on('nativeTheme-shouldUseHighContrastColors', () => { socket.on("nativeTheme-shouldUseHighContrastColors", () => {
const shouldUseHighContrastColors = electron_1.nativeTheme.shouldUseHighContrastColors; const shouldUseHighContrastColors = electron_1.nativeTheme.shouldUseHighContrastColors;
electronSocket.emit('nativeTheme-shouldUseHighContrastColors-completed', shouldUseHighContrastColors); electronSocket.emit("nativeTheme-shouldUseHighContrastColors-completed", shouldUseHighContrastColors);
}); });
socket.on('nativeTheme-shouldUseInvertedColorScheme', () => { socket.on("nativeTheme-shouldUseInvertedColorScheme", () => {
const shouldUseInvertedColorScheme = electron_1.nativeTheme.shouldUseInvertedColorScheme; const shouldUseInvertedColorScheme = electron_1.nativeTheme.shouldUseInvertedColorScheme;
electronSocket.emit('nativeTheme-shouldUseInvertedColorScheme-completed', shouldUseInvertedColorScheme); electronSocket.emit("nativeTheme-shouldUseInvertedColorScheme-completed", shouldUseInvertedColorScheme);
}); });
socket.on('nativeTheme-getThemeSource', () => { socket.on("nativeTheme-getThemeSource", () => {
const themeSource = electron_1.nativeTheme.themeSource; const themeSource = electron_1.nativeTheme.themeSource;
electronSocket.emit('nativeTheme-getThemeSource-completed', themeSource); electronSocket.emit("nativeTheme-getThemeSource-completed", themeSource);
}); });
socket.on('nativeTheme-themeSource', (themeSource) => { socket.on("nativeTheme-themeSource", (themeSource) => {
electron_1.nativeTheme.themeSource = themeSource; electron_1.nativeTheme.themeSource = themeSource;
}); });
socket.on('register-nativeTheme-updated', (id) => { socket.on("register-nativeTheme-updated", (id) => {
electron_1.nativeTheme.on('updated', () => { electron_1.nativeTheme.on("updated", () => {
electronSocket.emit('nativeTheme-updated' + id); electronSocket.emit("nativeTheme-updated" + id);
}); });
}); });
}; };

View File

@@ -1 +1 @@
{"version":3,"file":"nativeTheme.js","sourceRoot":"","sources":["nativeTheme.ts"],"names":[],"mappings":";AACA,uCAAuC;AACvC,IAAI,cAAc,CA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AC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YAC7B,cAAc,CAAC,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

@@ -1,41 +1,52 @@
import { Socket } from 'net'; import type { Socket } from "net";
import { nativeTheme } from 'electron'; import { nativeTheme } from "electron";
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('nativeTheme-shouldUseDarkColors', () => { socket.on("nativeTheme-shouldUseDarkColors", () => {
const shouldUseDarkColors = nativeTheme.shouldUseDarkColors; const shouldUseDarkColors = nativeTheme.shouldUseDarkColors;
electronSocket.emit('nativeTheme-shouldUseDarkColors-completed', shouldUseDarkColors); electronSocket.emit(
}); "nativeTheme-shouldUseDarkColors-completed",
shouldUseDarkColors,
socket.on('nativeTheme-shouldUseHighContrastColors', () => { );
const shouldUseHighContrastColors = nativeTheme.shouldUseHighContrastColors; });
electronSocket.emit('nativeTheme-shouldUseHighContrastColors-completed', shouldUseHighContrastColors); socket.on("nativeTheme-shouldUseHighContrastColors", () => {
}); const shouldUseHighContrastColors = nativeTheme.shouldUseHighContrastColors;
socket.on('nativeTheme-shouldUseInvertedColorScheme', () => { electronSocket.emit(
const shouldUseInvertedColorScheme = nativeTheme.shouldUseInvertedColorScheme; "nativeTheme-shouldUseHighContrastColors-completed",
shouldUseHighContrastColors,
electronSocket.emit('nativeTheme-shouldUseInvertedColorScheme-completed', shouldUseInvertedColorScheme); );
}); });
socket.on('nativeTheme-getThemeSource', () => { socket.on("nativeTheme-shouldUseInvertedColorScheme", () => {
const themeSource = nativeTheme.themeSource; const shouldUseInvertedColorScheme =
nativeTheme.shouldUseInvertedColorScheme;
electronSocket.emit('nativeTheme-getThemeSource-completed', themeSource);
}); electronSocket.emit(
"nativeTheme-shouldUseInvertedColorScheme-completed",
socket.on('nativeTheme-themeSource', (themeSource) => { shouldUseInvertedColorScheme,
nativeTheme.themeSource = themeSource; );
}); });
socket.on('register-nativeTheme-updated', (id) => { socket.on("nativeTheme-getThemeSource", () => {
nativeTheme.on('updated', () => { const themeSource = nativeTheme.themeSource;
electronSocket.emit('nativeTheme-updated' + id);
}); electronSocket.emit("nativeTheme-getThemeSource-completed", themeSource);
});
socket.on("nativeTheme-themeSource", (themeSource) => {
nativeTheme.themeSource = themeSource;
});
socket.on("register-nativeTheme-updated", (id) => {
nativeTheme.on("updated", () => {
electronSocket.emit("nativeTheme-updated" + id);
}); });
});
}; };

View File

@@ -1,40 +1,44 @@
"use strict"; "use strict";
const electron_1 = require("electron"); const electron_1 = require("electron");
const notifications = (global['notifications'] = global['notifications'] || []); const notifications = (global["notifications"] =
global["notifications"] || []);
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('createNotification', (options) => { socket.on("createNotification", (options) => {
const notification = new electron_1.Notification(options); const notification = new electron_1.Notification(options);
let haveEvent = false; let haveEvent = false;
if (options.showID) { if (options.showID) {
haveEvent = true; haveEvent = true;
notification.on('show', () => { notification.on("show", () => {
electronSocket.emit('NotificationEventShow', options.showID); electronSocket.emit("NotificationEventShow", options.showID);
}); });
} }
if (options.clickID) { if (options.clickID) {
haveEvent = true; haveEvent = true;
notification.on('click', () => { notification.on("click", () => {
electronSocket.emit('NotificationEventClick', options.clickID); electronSocket.emit("NotificationEventClick", options.clickID);
}); });
} }
if (options.closeID) { if (options.closeID) {
haveEvent = true; haveEvent = true;
notification.on('close', () => { notification.on("close", () => {
electronSocket.emit('NotificationEventClose', options.closeID); electronSocket.emit("NotificationEventClose", options.closeID);
}); });
} }
if (options.replyID) { if (options.replyID) {
haveEvent = true; haveEvent = true;
notification.on('reply', (event, value) => { notification.on("reply", (event, value) => {
electronSocket.emit('NotificationEventReply', [options.replyID, value]); electronSocket.emit("NotificationEventReply", [options.replyID, value]);
}); });
} }
if (options.actionID) { if (options.actionID) {
haveEvent = true; haveEvent = true;
notification.on('action', (event, value) => { notification.on("action", (event, value) => {
electronSocket.emit('NotificationEventAction', [options.actionID, value]); electronSocket.emit("NotificationEventAction", [
options.actionID,
value,
]);
}); });
} }
if (haveEvent) { if (haveEvent) {
@@ -42,9 +46,9 @@ module.exports = (socket) => {
} }
notification.show(); notification.show();
}); });
socket.on('notificationIsSupported', () => { socket.on("notificationIsSupported", () => {
const isSupported = electron_1.Notification.isSupported(); const isSupported = electron_1.Notification.isSupported();
electronSocket.emit('notificationIsSupportedCompleted', isSupported); electronSocket.emit("notificationIsSupportedCompleted", isSupported);
}); });
}; };
//# sourceMappingURL=notification.js.map //# sourceMappingURL=notification.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"notification.js","sourceRoot":"","sources":["notification.ts"],"names":[],"mappings":";AACA,uCAAwC;AACxC,MAAM,aAAa,GAA4B,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,CAA4B,CAAC;AACpI,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,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,CAAC;YACjB,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;QACP,CAAC;QAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC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AC,CAAC;QACL,CAAC;QAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBACxC,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YAC1E,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBACzC,cAAc,CAAC,IAAI,CAAC,yBAAyB,EAAE;oBAC7C,OAAO,CAAC,QAAQ;oBAChB,KAAK;iBACN,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACd,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC;QAED,YAAY,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACxC,MAAM,WAAW,GAAG,uBAAY,CAAC,WAAW,EAAE,CAAC;QAC/C,cAAc,CAAC,IAAI,CAAC,kCAAkC,EAAE,WAAW,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

@@ -1,58 +1,64 @@
import { Socket } from 'net'; import type { Socket } from "net";
import { Notification } from 'electron'; import { Notification } from "electron";
const notifications: Electron.Notification[] = (global['notifications'] = global['notifications'] || []) as Electron.Notification[];
let electronSocket; const notifications: Electron.Notification[] = (global["notifications"] =
global["notifications"] || []) as Electron.Notification[];
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('createNotification', (options) => { socket.on("createNotification", (options) => {
const notification = new Notification(options); const notification = new Notification(options);
let haveEvent = false; let haveEvent = false;
if (options.showID) { if (options.showID) {
haveEvent = true; haveEvent = true;
notification.on('show', () => { notification.on("show", () => {
electronSocket.emit('NotificationEventShow', options.showID); electronSocket.emit("NotificationEventShow", options.showID);
}); });
} }
if (options.clickID) { if (options.clickID) {
haveEvent = true; haveEvent = true;
notification.on('click', () => { notification.on("click", () => {
electronSocket.emit('NotificationEventClick', options.clickID); electronSocket.emit("NotificationEventClick", options.clickID);
}); });
} }
if (options.closeID) { if (options.closeID) {
haveEvent = true; haveEvent = true;
notification.on('close', () => { notification.on("close", () => {
electronSocket.emit('NotificationEventClose', options.closeID); electronSocket.emit("NotificationEventClose", options.closeID);
}); });
} }
if (options.replyID) { if (options.replyID) {
haveEvent = true; haveEvent = true;
notification.on('reply', (event, value) => { notification.on("reply", (event, value) => {
electronSocket.emit('NotificationEventReply', [options.replyID, value]); electronSocket.emit("NotificationEventReply", [options.replyID, value]);
}); });
} }
if (options.actionID) { if (options.actionID) {
haveEvent = true; haveEvent = true;
notification.on('action', (event, value) => { notification.on("action", (event, value) => {
electronSocket.emit('NotificationEventAction', [options.actionID, value]); electronSocket.emit("NotificationEventAction", [
}); options.actionID,
} value,
]);
});
}
if (haveEvent) { if (haveEvent) {
notifications.push(notification); notifications.push(notification);
} }
notification.show(); notification.show();
}); });
socket.on('notificationIsSupported', () => { socket.on("notificationIsSupported", () => {
const isSupported = Notification.isSupported(); const isSupported = Notification.isSupported();
electronSocket.emit('notificationIsSupportedCompleted', isSupported); electronSocket.emit("notificationIsSupportedCompleted", isSupported);
}); });
}; };

View File

@@ -3,39 +3,39 @@ const electron_1 = require("electron");
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('register-powerMonitor-lock-screen', () => { socket.on("register-powerMonitor-lock-screen", () => {
electron_1.powerMonitor.on('lock-screen', () => { electron_1.powerMonitor.on("lock-screen", () => {
electronSocket.emit('powerMonitor-lock-screen'); electronSocket.emit("powerMonitor-lock-screen");
}); });
}); });
socket.on('register-powerMonitor-unlock-screen', () => { socket.on("register-powerMonitor-unlock-screen", () => {
electron_1.powerMonitor.on('unlock-screen', () => { electron_1.powerMonitor.on("unlock-screen", () => {
electronSocket.emit('powerMonitor-unlock-screen'); electronSocket.emit("powerMonitor-unlock-screen");
}); });
}); });
socket.on('register-powerMonitor-suspend', () => { socket.on("register-powerMonitor-suspend", () => {
electron_1.powerMonitor.on('suspend', () => { electron_1.powerMonitor.on("suspend", () => {
electronSocket.emit('powerMonitor-suspend'); electronSocket.emit("powerMonitor-suspend");
}); });
}); });
socket.on('register-powerMonitor-resume', () => { socket.on("register-powerMonitor-resume", () => {
electron_1.powerMonitor.on('resume', () => { electron_1.powerMonitor.on("resume", () => {
electronSocket.emit('powerMonitor-resume'); electronSocket.emit("powerMonitor-resume");
}); });
}); });
socket.on('register-powerMonitor-ac', () => { socket.on("register-powerMonitor-ac", () => {
electron_1.powerMonitor.on('on-ac', () => { electron_1.powerMonitor.on("on-ac", () => {
electronSocket.emit('powerMonitor-ac'); electronSocket.emit("powerMonitor-ac");
}); });
}); });
socket.on('register-powerMonitor-battery', () => { socket.on("register-powerMonitor-battery", () => {
electron_1.powerMonitor.on('on-battery', () => { electron_1.powerMonitor.on("on-battery", () => {
electronSocket.emit('powerMonitor-battery'); electronSocket.emit("powerMonitor-battery");
}); });
}); });
socket.on('register-powerMonitor-shutdown', () => { socket.on("register-powerMonitor-shutdown", () => {
electron_1.powerMonitor.on('shutdown', () => { electron_1.powerMonitor.on("shutdown", () => {
electronSocket.emit('powerMonitor-shutdown'); electronSocket.emit("powerMonitor-shutdown");
}); });
}); });
}; };

View File

@@ -1 +1 @@
{"version":3,"file":"powerMonitor.js","sourceRoot":"","sources":["powerMonitor.ts"],"names":[],"mappings":";AACA,uCAAwC;AACxC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MA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,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACzC,uBAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAC5B,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAC9C,uBAAY,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;YACjC,cAAc,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QAC/C,uBAAY,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE;YAC/B,cAAc,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

@@ -1,42 +1,43 @@
import { Socket } from 'net'; import type { Socket } from "net";
import { powerMonitor } from 'electron'; import { powerMonitor } from "electron";
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('register-powerMonitor-lock-screen', () => { socket.on("register-powerMonitor-lock-screen", () => {
powerMonitor.on('lock-screen', () => { powerMonitor.on("lock-screen", () => {
electronSocket.emit('powerMonitor-lock-screen'); electronSocket.emit("powerMonitor-lock-screen");
});
}); });
socket.on('register-powerMonitor-unlock-screen', () => { });
powerMonitor.on('unlock-screen', () => { socket.on("register-powerMonitor-unlock-screen", () => {
electronSocket.emit('powerMonitor-unlock-screen'); powerMonitor.on("unlock-screen", () => {
}); electronSocket.emit("powerMonitor-unlock-screen");
}); });
socket.on('register-powerMonitor-suspend', () => { });
powerMonitor.on('suspend', () => { socket.on("register-powerMonitor-suspend", () => {
electronSocket.emit('powerMonitor-suspend'); powerMonitor.on("suspend", () => {
}); electronSocket.emit("powerMonitor-suspend");
}); });
socket.on('register-powerMonitor-resume', () => { });
powerMonitor.on('resume', () => { socket.on("register-powerMonitor-resume", () => {
electronSocket.emit('powerMonitor-resume'); powerMonitor.on("resume", () => {
}); electronSocket.emit("powerMonitor-resume");
}); });
socket.on('register-powerMonitor-ac', () => { });
powerMonitor.on('on-ac', () => { socket.on("register-powerMonitor-ac", () => {
electronSocket.emit('powerMonitor-ac'); powerMonitor.on("on-ac", () => {
}); electronSocket.emit("powerMonitor-ac");
}); });
socket.on('register-powerMonitor-battery', () => { });
powerMonitor.on('on-battery', () => { socket.on("register-powerMonitor-battery", () => {
electronSocket.emit('powerMonitor-battery'); powerMonitor.on("on-battery", () => {
}); electronSocket.emit("powerMonitor-battery");
}); });
socket.on('register-powerMonitor-shutdown', () => { });
powerMonitor.on('shutdown', () => { socket.on("register-powerMonitor-shutdown", () => {
electronSocket.emit('powerMonitor-shutdown'); powerMonitor.on("shutdown", () => {
}); electronSocket.emit("powerMonitor-shutdown");
}); });
});
}; };

View File

@@ -2,61 +2,61 @@
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('process-execPath', () => { socket.on("process-execPath", () => {
const value = process.execPath; const value = process.execPath;
electronSocket.emit('process-execPath-completed', value); electronSocket.emit("process-execPath-completed", value);
}); });
socket.on('process-argv', () => { socket.on("process-argv", () => {
const value = process.argv; const value = process.argv;
electronSocket.emit('process-argv-completed', value); electronSocket.emit("process-argv-completed", value);
}); });
socket.on('process-type', () => { socket.on("process-type", () => {
const value = process.type; const value = process.type;
electronSocket.emit('process-type-completed', value); electronSocket.emit("process-type-completed", value);
}); });
socket.on('process-versions', () => { socket.on("process-versions", () => {
const value = process.versions; const value = process.versions;
electronSocket.emit('process-versions-completed', value); electronSocket.emit("process-versions-completed", value);
}); });
socket.on('process-defaultApp', () => { socket.on("process-defaultApp", () => {
if (process.defaultApp === undefined) { if (process.defaultApp === undefined) {
electronSocket.emit('process-defaultApp-completed', false); electronSocket.emit("process-defaultApp-completed", false);
return; return;
} }
electronSocket.emit('process-defaultApp-completed', process.defaultApp); electronSocket.emit("process-defaultApp-completed", process.defaultApp);
}); });
socket.on('process-isMainFrame', () => { socket.on("process-isMainFrame", () => {
if (process.isMainFrame === undefined) { if (process.isMainFrame === undefined) {
electronSocket.emit('process-isMainFrame-completed', false); electronSocket.emit("process-isMainFrame-completed", false);
return; return;
} }
electronSocket.emit('process-isMainFrame-completed', process.isMainFrame); electronSocket.emit("process-isMainFrame-completed", process.isMainFrame);
}); });
socket.on('process-resourcesPath', () => { socket.on("process-resourcesPath", () => {
const value = process.resourcesPath; const value = process.resourcesPath;
electronSocket.emit('process-resourcesPath-completed', value); electronSocket.emit("process-resourcesPath-completed", value);
}); });
socket.on('process-upTime', () => { socket.on("process-upTime", () => {
let value = process.uptime(); let value = process.uptime();
if (value === undefined) { if (value === undefined) {
value = -1; value = -1;
} }
electronSocket.emit('process-upTime-completed', value); electronSocket.emit("process-upTime-completed", value);
}); });
socket.on('process-pid', () => { socket.on("process-pid", () => {
if (process.pid === undefined) { if (process.pid === undefined) {
electronSocket.emit('process-pid-completed', -1); electronSocket.emit("process-pid-completed", -1);
return; return;
} }
electronSocket.emit('process-pid-completed', process.pid); electronSocket.emit("process-pid-completed", process.pid);
}); });
socket.on('process-arch', () => { socket.on("process-arch", () => {
const value = process.arch; const value = process.arch;
electronSocket.emit('process-arch-completed', value); electronSocket.emit("process-arch-completed", value);
}); });
socket.on('process-platform', () => { socket.on("process-platform", () => {
const value = process.platform; const value = process.platform;
electronSocket.emit('process-platform-completed', value); electronSocket.emit("process-platform-completed", value);
}); });
}; };
//# sourceMappingURL=process.js.map //# sourceMappingURL=process.js.map

View File

@@ -1 +1 @@
{"version":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,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QAC3B,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC;QAC/B,cAAc,CAAC,IAAI,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

@@ -1,73 +1,74 @@
import { Socket } from 'net'; import type { Socket } from "net";
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('process-execPath', () => { socket.on("process-execPath", () => {
const value = process.execPath; const value = process.execPath;
electronSocket.emit('process-execPath-completed', value); electronSocket.emit("process-execPath-completed", value);
}); });
socket.on('process-argv', () => { socket.on("process-argv", () => {
const value = process.argv; const value = process.argv;
electronSocket.emit('process-argv-completed', value); electronSocket.emit("process-argv-completed", value);
}); });
socket.on('process-type', () => { socket.on("process-type", () => {
const value = process.type; const value = process.type;
electronSocket.emit('process-type-completed', value); electronSocket.emit("process-type-completed", value);
}); });
socket.on('process-versions', () => { socket.on("process-versions", () => {
const value = process.versions; const value = process.versions;
electronSocket.emit('process-versions-completed', value); electronSocket.emit("process-versions-completed", value);
}); });
socket.on('process-defaultApp', () => { socket.on("process-defaultApp", () => {
if (process.defaultApp === undefined) { if (process.defaultApp === undefined) {
electronSocket.emit('process-defaultApp-completed', false); electronSocket.emit("process-defaultApp-completed", false);
return; return;
} }
electronSocket.emit('process-defaultApp-completed', process.defaultApp); electronSocket.emit("process-defaultApp-completed", process.defaultApp);
}); });
socket.on('process-isMainFrame', () => { socket.on("process-isMainFrame", () => {
if (process.isMainFrame === undefined) { if (process.isMainFrame === undefined) {
electronSocket.emit('process-isMainFrame-completed', false); electronSocket.emit("process-isMainFrame-completed", false);
return; return;
} }
electronSocket.emit('process-isMainFrame-completed', process.isMainFrame); electronSocket.emit("process-isMainFrame-completed", process.isMainFrame);
}); });
socket.on('process-resourcesPath', () => { socket.on("process-resourcesPath", () => {
const value = process.resourcesPath; const value = process.resourcesPath;
electronSocket.emit('process-resourcesPath-completed', value); electronSocket.emit("process-resourcesPath-completed", value);
}); });
socket.on('process-upTime', () => { socket.on("process-upTime", () => {
let value = process.uptime(); let value = process.uptime();
if (value === undefined) { if (value === undefined) {
value = -1; value = -1;
} }
electronSocket.emit('process-upTime-completed', value); electronSocket.emit("process-upTime-completed", value);
}); });
socket.on('process-pid', () => { socket.on("process-pid", () => {
if (process.pid === undefined) { if (process.pid === undefined) {
electronSocket.emit('process-pid-completed', -1); electronSocket.emit("process-pid-completed", -1);
return; return;
} }
electronSocket.emit('process-pid-completed', process.pid); electronSocket.emit("process-pid-completed", process.pid);
}); });
socket.on('process-arch', () => { socket.on("process-arch", () => {
const value = process.arch; const value = process.arch;
electronSocket.emit('process-arch-completed', value); electronSocket.emit("process-arch-completed", value);
}); });
socket.on('process-platform', () => { socket.on("process-platform", () => {
const value = process.platform; const value = process.platform;
electronSocket.emit('process-platform-completed', value); electronSocket.emit("process-platform-completed", value);
}) });
}; };

View File

@@ -3,44 +3,47 @@ const electron_1 = require("electron");
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('register-screen-display-added', (id) => { socket.on("register-screen-display-added", (id) => {
electron_1.screen.on('display-added', (event, display) => { electron_1.screen.on("display-added", (event, display) => {
electronSocket.emit('screen-display-added' + id, display); electronSocket.emit("screen-display-added" + id, display);
}); });
}); });
socket.on('register-screen-display-removed', (id) => { socket.on("register-screen-display-removed", (id) => {
electron_1.screen.on('display-removed', (event, display) => { electron_1.screen.on("display-removed", (event, display) => {
electronSocket.emit('screen-display-removed' + id, display); electronSocket.emit("screen-display-removed" + id, display);
}); });
}); });
socket.on('register-screen-display-metrics-changed', (id) => { socket.on("register-screen-display-metrics-changed", (id) => {
electron_1.screen.on('display-metrics-changed', (event, display, changedMetrics) => { electron_1.screen.on("display-metrics-changed", (event, display, changedMetrics) => {
electronSocket.emit('screen-display-metrics-changed' + id, [display, changedMetrics]); electronSocket.emit("screen-display-metrics-changed" + id, [
display,
changedMetrics,
]);
}); });
}); });
socket.on('screen-getCursorScreenPoint', () => { socket.on("screen-getCursorScreenPoint", () => {
const point = electron_1.screen.getCursorScreenPoint(); const point = electron_1.screen.getCursorScreenPoint();
electronSocket.emit('screen-getCursorScreenPoint-completed', point); electronSocket.emit("screen-getCursorScreenPoint-completed", point);
}); });
socket.on('screen-getMenuBarWorkArea', () => { socket.on("screen-getMenuBarWorkArea", () => {
const height = electron_1.screen.getPrimaryDisplay().workArea; const height = electron_1.screen.getPrimaryDisplay().workArea;
electronSocket.emit('screen-getMenuBarWorkArea-completed', height); electronSocket.emit("screen-getMenuBarWorkArea-completed", height);
}); });
socket.on('screen-getPrimaryDisplay', () => { socket.on("screen-getPrimaryDisplay", () => {
const display = electron_1.screen.getPrimaryDisplay(); const display = electron_1.screen.getPrimaryDisplay();
electronSocket.emit('screen-getPrimaryDisplay-completed', display); electronSocket.emit("screen-getPrimaryDisplay-completed", display);
}); });
socket.on('screen-getAllDisplays', () => { socket.on("screen-getAllDisplays", () => {
const display = electron_1.screen.getAllDisplays(); const display = electron_1.screen.getAllDisplays();
electronSocket.emit('screen-getAllDisplays-completed', display); electronSocket.emit("screen-getAllDisplays-completed", display);
}); });
socket.on('screen-getDisplayNearestPoint', (point) => { socket.on("screen-getDisplayNearestPoint", (point) => {
const display = electron_1.screen.getDisplayNearestPoint(point); const display = electron_1.screen.getDisplayNearestPoint(point);
electronSocket.emit('screen-getDisplayNearestPoint-completed', display); electronSocket.emit("screen-getDisplayNearestPoint-completed", display);
}); });
socket.on('screen-getDisplayMatching', (rectangle) => { socket.on("screen-getDisplayMatching", (rectangle) => {
const display = electron_1.screen.getDisplayMatching(rectangle); const display = electron_1.screen.getDisplayMatching(rectangle);
electronSocket.emit('screen-getDisplayMatching-completed', display); electronSocket.emit("screen-getDisplayMatching-completed", display);
}); });
}; };
//# sourceMappingURL=screen.js.map //# sourceMappingURL=screen.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"screen.js","sourceRoot":"","sources":["screen.ts"],"names":[],"mappings":";AACA,uCAAkC;AAClC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IAExB,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,sBAAsB,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;QAC9D,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,KAAK,EAAE,OAAO,EAAE,EAAE;YAC5C,cAAc,CAAC,IAAI,CAAC,wBAAwB,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yCAAyC,EAAE,CAAC,EAAE,EAAE,EAAE;QACxD,iBAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE;YACpE,cAAc,CAAC,IAAI,CAAC,gCAAgC,GAAG,EAAE,EAAE,CAAC,OAAO,EAAE,c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from 'net'; import type { Socket } from "net";
import { screen } from 'electron'; import { screen } from "electron";
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('register-screen-display-added', (id) => { socket.on("register-screen-display-added", (id) => {
screen.on('display-added', (event, display) => { screen.on("display-added", (event, display) => {
electronSocket.emit('screen-display-added' + id, display); electronSocket.emit("screen-display-added" + id, display);
});
}); });
});
socket.on('register-screen-display-removed', (id) => { socket.on("register-screen-display-removed", (id) => {
screen.on('display-removed', (event, display) => { screen.on("display-removed", (event, display) => {
electronSocket.emit('screen-display-removed' + id, display); electronSocket.emit("screen-display-removed" + id, display);
});
}); });
});
socket.on('register-screen-display-metrics-changed', (id) => { socket.on("register-screen-display-metrics-changed", (id) => {
screen.on('display-metrics-changed', (event, display, changedMetrics) => { screen.on("display-metrics-changed", (event, display, changedMetrics) => {
electronSocket.emit('screen-display-metrics-changed' + id, [display, changedMetrics]); electronSocket.emit("screen-display-metrics-changed" + id, [
}); display,
changedMetrics,
]);
}); });
});
socket.on('screen-getCursorScreenPoint', () => { socket.on("screen-getCursorScreenPoint", () => {
const point = screen.getCursorScreenPoint(); const point = screen.getCursorScreenPoint();
electronSocket.emit('screen-getCursorScreenPoint-completed', point); electronSocket.emit("screen-getCursorScreenPoint-completed", point);
}); });
socket.on('screen-getMenuBarWorkArea', () => { socket.on("screen-getMenuBarWorkArea", () => {
const height = screen.getPrimaryDisplay().workArea; const height = screen.getPrimaryDisplay().workArea;
electronSocket.emit('screen-getMenuBarWorkArea-completed', height); electronSocket.emit("screen-getMenuBarWorkArea-completed", height);
}); });
socket.on('screen-getPrimaryDisplay', () => { socket.on("screen-getPrimaryDisplay", () => {
const display = screen.getPrimaryDisplay(); const display = screen.getPrimaryDisplay();
electronSocket.emit('screen-getPrimaryDisplay-completed', display); electronSocket.emit("screen-getPrimaryDisplay-completed", display);
}); });
socket.on('screen-getAllDisplays', () => { socket.on("screen-getAllDisplays", () => {
const display = screen.getAllDisplays(); const display = screen.getAllDisplays();
electronSocket.emit('screen-getAllDisplays-completed', display); electronSocket.emit("screen-getAllDisplays-completed", display);
}); });
socket.on('screen-getDisplayNearestPoint', (point) => { socket.on("screen-getDisplayNearestPoint", (point) => {
const display = screen.getDisplayNearestPoint(point); const display = screen.getDisplayNearestPoint(point);
electronSocket.emit('screen-getDisplayNearestPoint-completed', display); electronSocket.emit("screen-getDisplayNearestPoint-completed", display);
}); });
socket.on('screen-getDisplayMatching', (rectangle) => { socket.on("screen-getDisplayMatching", (rectangle) => {
const display = screen.getDisplayMatching(rectangle); const display = screen.getDisplayMatching(rectangle);
electronSocket.emit('screen-getDisplayMatching-completed', display); electronSocket.emit("screen-getDisplayMatching-completed", display);
}); });
}; };

View File

@@ -3,18 +3,18 @@ const electron_1 = require("electron");
let electronSocket; let electronSocket;
module.exports = (socket) => { module.exports = (socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('shell-showItemInFolder', (fullPath) => { socket.on("shell-showItemInFolder", (fullPath) => {
electron_1.shell.showItemInFolder(fullPath); electron_1.shell.showItemInFolder(fullPath);
electronSocket.emit('shell-showItemInFolderCompleted'); electronSocket.emit("shell-showItemInFolderCompleted");
}); });
socket.on('shell-openPath', async (path) => { socket.on("shell-openPath", async (path) => {
const errorMessage = await electron_1.shell.openPath(path); const errorMessage = await electron_1.shell.openPath(path);
electronSocket.emit('shell-openPathCompleted', errorMessage); electronSocket.emit("shell-openPathCompleted", errorMessage);
}); });
socket.on('shell-openExternal', async (url, options) => { socket.on("shell-openExternal", async (url, options) => {
let result = ''; let result = "";
if (options) { if (options) {
await electron_1.shell.openExternal(url, options).catch(e => { await electron_1.shell.openExternal(url, options).catch((e) => {
result = e.message; result = e.message;
}); });
} }
@@ -23,9 +23,9 @@ module.exports = (socket) => {
result = e.message; result = e.message;
}); });
} }
electronSocket.emit('shell-openExternalCompleted', result); electronSocket.emit("shell-openExternalCompleted", result);
}); });
socket.on('shell-trashItem', async (fullPath, deleteOnFail) => { socket.on("shell-trashItem", async (fullPath, deleteOnFail) => {
let success = false; let success = false;
try { try {
await electron_1.shell.trashItem(fullPath); await electron_1.shell.trashItem(fullPath);
@@ -34,18 +34,18 @@ module.exports = (socket) => {
catch (error) { catch (error) {
success = false; success = false;
} }
electronSocket.emit('shell-trashItem-completed', success); electronSocket.emit("shell-trashItem-completed", success);
}); });
socket.on('shell-beep', () => { socket.on("shell-beep", () => {
electron_1.shell.beep(); electron_1.shell.beep();
}); });
socket.on('shell-writeShortcutLink', (shortcutPath, operation, options) => { socket.on("shell-writeShortcutLink", (shortcutPath, operation, options) => {
const success = electron_1.shell.writeShortcutLink(shortcutPath, operation, options); const success = electron_1.shell.writeShortcutLink(shortcutPath, operation, options);
electronSocket.emit('shell-writeShortcutLinkCompleted', success); electronSocket.emit("shell-writeShortcutLinkCompleted", success);
}); });
socket.on('shell-readShortcutLink', (shortcutPath) => { socket.on("shell-readShortcutLink", (shortcutPath) => {
const shortcutDetails = electron_1.shell.readShortcutLink(shortcutPath); const shortcutDetails = electron_1.shell.readShortcutLink(shortcutPath);
electronSocket.emit('shell-readShortcutLinkCompleted', shortcutDetails); electronSocket.emit("shell-readShortcutLinkCompleted", shortcutDetails);
}); });
}; };
//# sourceMappingURL=shell.js.map //# sourceMappingURL=shell.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"shell.js","sourceRoot":"","sources":["shell.ts"],"names":[],"mappings":";AACA,uCAAiC;AACjC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC,QAAQ,EAAE,EAAE;QAC7C,gBAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAEjC,cAAc,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,K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AAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAE1E,cAAc,CAAC,IAAI,CAAC,kCAAkC,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC,YAAY,EAAE,EAAE;QACnD,MAAM,eAAe,GAAG,gBAAK,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QAE7D,cAAc,CAAC,IAAI,CAAC,iCAAiC,EAAE,eAAe,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

@@ -1,63 +1,64 @@
import { Socket } from 'net'; import type { Socket } from "net";
import { shell } from 'electron'; import { shell } from "electron";
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket) => { export = (socket: Socket) => {
electronSocket = socket; electronSocket = socket;
socket.on('shell-showItemInFolder', (fullPath) => { socket.on("shell-showItemInFolder", (fullPath) => {
shell.showItemInFolder(fullPath); shell.showItemInFolder(fullPath);
electronSocket.emit('shell-showItemInFolderCompleted'); electronSocket.emit("shell-showItemInFolderCompleted");
}); });
socket.on('shell-openPath', async (path) => { socket.on("shell-openPath", async (path) => {
const errorMessage = await shell.openPath(path); const errorMessage = await shell.openPath(path);
electronSocket.emit('shell-openPathCompleted', errorMessage); electronSocket.emit("shell-openPathCompleted", errorMessage);
}); });
socket.on('shell-openExternal', async (url, options) => { socket.on("shell-openExternal", async (url, options) => {
let result = ''; let result = "";
if (options) { if (options) {
await shell.openExternal(url, options).catch(e => { await shell.openExternal(url, options).catch((e) => {
result = e.message; result = e.message;
}); });
} else { } else {
await shell.openExternal(url).catch((e) => { await shell.openExternal(url).catch((e) => {
result = e.message; result = e.message;
}); });
} }
electronSocket.emit('shell-openExternalCompleted', result); electronSocket.emit("shell-openExternalCompleted", result);
}); });
socket.on('shell-trashItem', async (fullPath, deleteOnFail) => { socket.on("shell-trashItem", async (fullPath, deleteOnFail) => {
let success = false; let success = false;
try { try {
await shell.trashItem(fullPath); await shell.trashItem(fullPath);
success = true; success = true;
} catch (error) { } catch (error) {
success = false; success = false;
} }
electronSocket.emit('shell-trashItem-completed', success); electronSocket.emit("shell-trashItem-completed", success);
}); });
socket.on('shell-beep', () => { socket.on("shell-beep", () => {
shell.beep(); shell.beep();
}); });
socket.on('shell-writeShortcutLink', (shortcutPath, operation, options) => { socket.on("shell-writeShortcutLink", (shortcutPath, operation, options) => {
const success = shell.writeShortcutLink(shortcutPath, operation, options); const success = shell.writeShortcutLink(shortcutPath, operation, options);
electronSocket.emit('shell-writeShortcutLinkCompleted', success); electronSocket.emit("shell-writeShortcutLinkCompleted", success);
}); });
socket.on('shell-readShortcutLink', (shortcutPath) => { socket.on("shell-readShortcutLink", (shortcutPath) => {
const shortcutDetails = shell.readShortcutLink(shortcutPath); const shortcutDetails = shell.readShortcutLink(shortcutPath);
electronSocket.emit('shell-readShortcutLinkCompleted', shortcutDetails); electronSocket.emit("shell-readShortcutLinkCompleted", shortcutDetails);
}); });
}; };

View File

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

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