Compare commits

...

52 Commits

Author SHA1 Message Date
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
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
Florian Rappl
bdfbcd5b77 Merge pull request #986 from ElectronNET/develop
Release 0.3.0
2025-12-14 22:13:10 +01:00
Florian Rappl
19e785f53f Fixed whitespace 2025-12-14 15:30:21 +01:00
Florian Rappl
0b453177b5 Added contributing guide 2025-12-14 15:20:15 +01:00
Florian Rappl
8ed7f27722 Make sure the electron-host-hook strays unobtrusive 2025-12-14 00:49:34 +01:00
Florian Rappl
321b8cd9e5 Merge branch 'develop' of https://github.com/ElectronNET/Electron.NET into develop 2025-12-14 00:36:59 +01:00
Florian Rappl
b326f863d8 Updated changelog 2025-12-14 00:36:53 +01:00
Florian Rappl
f148fe6a14 Merge pull request #983 from markatosi/develop
Wiki Package building macOS sections added
2025-12-14 00:32:37 +01:00
Florian Rappl
515d325731 Fixed startup in VS Code 2025-12-13 23:43:12 +01:00
markatosi
f32a40fe17 Add macOS profiles for ASP.NET and Console apps
Added profiles for ASP.NET and Console applications on macOS.
2025-12-13 12:18:38 -10:00
Florian Rappl
c53a5a9163 Merge pull request #982 from markatosi/develop
Change Example code for AutoMenuHide
2025-12-13 12:28:41 +01:00
markatosi
8d4cdddc46 Conditionally set AutoHideMenuBar for Windows/Linux 2025-12-12 13:45:56 -10:00
92 changed files with 3071 additions and 1991 deletions

137
.github/CONTRIBUTING.md vendored Normal file
View File

@@ -0,0 +1,137 @@
# Contributing
## Project Scope
The Electron.NET project ultimately tries to provide a framework for developing cross-platform client applications on the basis of .NET and Electron. Anything that is related to this goal will be considered. The project aims to be as close to Electron with .NET as a basis as possible. If your contribution does not reflect that goal, the chances of accepting it are limited.
## Code License
This is an open source project falling under the [MIT License](../LICENSE). By using, distributing, or contributing to this project, you accept and agree that all code within the Electron.NET project and its libraries are licensed under MIT license.
## Becoming a Contributor
Usually appointing someone as a contributor follows this process:
1. An individual contributes actively via discussions (reporting bugs, giving feedback to existing or opening new issues) and / or pull requests
2. The individual is either directly asked, invited or asks for contributor rights on the project
3. The individual uses the contribution rights to sustain or increase the active contributions
Every contributor might have to sign the contributor's license agreement (CLA) to establish a legal trust between the project and its contributors.
## Working on Electron.NET
### Issue Discussion
Discussion of issues should be placed transparently in the issue tracker here on GitHub.
* [General issues, bugs, new features](https://github.com/ElectronNET/Electron.NET/issues)
* [General discussions, help, exchange of ideas](https://github.com/ElectronNET/Electron.NET/discussions)
### Modifying the code
Electron.NET and its libraries uses features from the latest versions of C# (e.g., C# 10). You will therefore need a C# compiler that is up for the job.
1. Fork and clone the repo.
2. First try to build the ElectronNET.Core library and see if you get the tests running.
3. You will be required to resolve some dependencies via NuGet.
The build system of Electron.NET uses NUKE.
### Code Conventions
Most parts in the Electron.NET project are fairly straight forward. Among these are:
* Always use statement blocks for control statements, e.g., in a for-loop, if-condition, ...
* You may use a simple (throw) statement in case of enforcing contracts on argument
* Be explicit about modifiers (some files follow an older convention of the code base, but we settled on the explicit style)
### Development Workflow
1. If no issue already exists for the work you'll be doing, create one to document the problem(s) being solved and self-assign.
2. Otherwise please let us know that you are working on the problem. Regular status updates (e.g. "still in progress", "no time anymore", "practically done", "pull request issued") are highly welcome.
3. Create a new branch—please don't work in the `main` branch directly. It is reserved for releases. We recommend naming the branch to match the issue being addressed (`feature/#777` or `issue-777`).
4. Add failing tests for the change you want to make. Tests are crucial and should be taken from W3C (or other specification).
5. Fix stuff. Always go from edge case to edge case.
6. All tests should pass now. Also your new implementation should not break existing tests.
7. Update the documentation to reflect any changes. (or document such changes in the original issue)
8. Push to your fork or push your issue-specific branch to the main repository, then submit a pull request against `develop`.
Just to illustrate the git workflow for Electron.NET a little bit more we've added the following graphs.
Initially, Electron.NET starts at the `main` branch. This branch should contain the latest stable (or released) version.
Here we now created a new branch called `develop`. This is the development branch.
Now active work is supposed to be done. Therefore a new branch should be created. Let's create one:
```sh
git checkout -b feature/#777
```
There may be many of these feature branches. Most of them are also pushed to the server for discussion or synchronization.
```sh
git push -u origin feature/#777
```
Now feature branches may be closed when they are done. Here we simply merge with the feature branch(es). For instance the following command takes the `feature/#777` branch from the server and merges it with the `develop` branch.
```sh
git checkout develop
git pull
git pull origin feature/#777
git push
```
Finally, we may have all the features that are needed to release a new version of Electron.NET. Here we tag the release. For instance for the 1.0 release we use `v1.0`.
```sh
git checkout main
git merge develop
git tag v1.0
```
(The last part is automatically performed by our CI system. Don't tag manually.)
### Versioning
The rules of [semver](http://semver.org/) don't necessarily apply here, but we will try to stay quite close to them.
Prior to version 1.0.0 we use the following scheme:
1. MINOR versions for reaching a feature milestone potentially combined with dramatic API changes
2. PATCH versions for refinements (e.g. performance improvements, bug fixes)
After releasing version 1.0.0 the scheme changes to become:
1. MAJOR versions at maintainers' discretion following significant changes to the codebase (e.g., API changes)
2. MINOR versions for backwards-compatible enhancements (e.g., performance improvements)
3. PATCH versions for backwards-compatible bug fixes (e.g., spec compliance bugs, support issues)
#### Code style
Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.** In general most of the [C# coding guidelines from Microsoft](https://msdn.microsoft.com/en-us/library/ff926074.aspx) are followed. This project prefers type inference with `var` to explicitly stating (redundant) information.
It is also important to keep a certain `async`-flow and to always use `ConfigureAwait(false)` in conjunction with an `await` expression.
## Backwards Compatibility
We always try to remain backwards compatible beyond the currently supported versions of .NET.
For instance, in December 2025 there have been activity to remove .NET 6 support from the codebase. We rejected this. Key points:
1. We have absolutely no need to drop `.net6` support. It doesn't hurt us in any way.
2. Many are still using `.net6`, including Electron.NET (non-Core) users. It doesn't make sense to force them to update two things at the same time (.NET + Electron.NET).
3. We MUST NOT and NEVER update `Microsoft.Build.Utilities.Core`. This will make Electron.NET stop working on older Visual Studio and MSBuild versions. There's are also no reasons to update it in the first place.
It's important to note that the Microsoft label of "Out of support" on .NET has almost no practical meaning. We've rarely (if ever) seen any bugs fixed in the same .NET version which mattered. The bugs that all new .NET versions have are much worse than mature .NET versions which are declared as "out of support". Keep in mind that the LTS matters most for active development / ongoing supported projects. If, e.g., a TV has been released a decade ago it most likely won't be patched. Still, you might want to deploy applications to it, which then naturally would involve being based on "out of support" versions of the framework.
TL;DR: Unless there is a technical reason (e.g., a crucial new API not being available) we should not drop "out of support" .NET versions. At the time of writing (December 2025) the minimum supported .NET version remains at `.net6`.
## Timeline
**All of this information is related to ElectronNET.Core pre-v1!**
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.

View File

@@ -27,24 +27,23 @@ jobs:
run: |
echo "Inspecting jobs of workflow run $RUN_ID in $REPO"
jobs_json="$(gh api repos/$REPO/actions/runs/$RUN_ID/jobs)"
jobs_json="$(gh api -R $REPO repos/$REPO/actions/runs/$RUN_ID/jobs)"
echo "Jobs and conclusions:"
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[]
| select(.conclusion == "failure"
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."
gh run rerun "$RUN_ID" --failed
gh run rerun -R "$REPO" "$RUN_ID" --failed
else
echo "Only non-matrix jobs (like Test Results) failed not auto-rerunning."
fi

View File

@@ -1,3 +1,24 @@
# 0.4.1
## ElectronNET.Core
- Fixed handling of `Center` property for windows (#1001)
- Added missing methods on `Cookies` (#1000)
# 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
## ElectronNET.Core
@@ -6,13 +27,19 @@
- Updated all model classes to Electron API 39.2 (#949) @softworkz
- Fixed output path for `electron-builder` (#942) @softworkz
- Fixed floating point display resolution (#944) @softworkz
- Fixed error in case of missing electron-host-hook (#978)
- Fixed previous API break using exposed `JsonElement` objects (#938) @softworkz
- Fixed and improved several test cases (#962) @softworkz
- Fixed startup of Electron.NET from VS Code Debug Adapter (#952)
- Fixed the `BrowserWindowOptions` (#945) @softworkz
- Fixed example for `AutoMenuHide` to reflect platform capabilities (#982) @markatosi
- Added several migration checks for publishing (#966) @softworkz
- Added more test runners for E2E tests (#950, #951) @agracio
- Added dynamic updates for tray menu (#973) @davidroth
- Added matrix tests with 6 runners and 2 electron version (#948) @softworkz
- Added additional APIs for WebContents (#958) @agracio
- Added documentation for MacOS package publish (#983) @markatosi
- Added sample application for `ElectronHostHook` (#967) @adityashirsatrao007
# 0.2.0

View File

@@ -133,9 +133,10 @@ builder.UseElectron(args, async () =>
{
var options = new BrowserWindowOptions {
Show = false,
AutoHideMenuBar = true,
IsRunningBlazor = true, // <-- crucial
};
if (OperatingSystem.IsWindows() || OperatingSystem.IsLinux())
options.AutoHideMenuBar = true;
var browserWindow = await Electron.WindowManager.CreateWindowAsync(options);
browserWindow.OnReadyToShow += () => browserWindow.Show();
});

View File

@@ -8,7 +8,9 @@ When you build an Electron.NET project, the following validation checks are perf
| 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 |
| [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 |
@@ -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
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
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
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
If you have an Electron-related `package.json` from older Electron.NET versions:
1. **Open your project's `.csproj` file**
2. **Add the required properties** to a PropertyGroup with the label `ElectronNetCommon`:
```xml
<PropertyGroup Label="ElectronNetCommon">
<PackageId>my-electron-app</PackageId>
<ElectronPackageId>my-electron-app</ElectronPackageId>
<Title>My Electron App</Title>
<Version>1.0.0</Version>
<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>
```
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.

View File

@@ -31,7 +31,7 @@ dotnet add package ElectronNET.Core.AspNet # For ASP.NET projects
### Step 2: Configure Project Settings
**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:**
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
After completing the migration steps:

View File

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

View File

@@ -25,7 +25,7 @@ These are the current default values when you don't make any changes:
<ElectronSingleInstance>true</ElectronSingleInstance>
<ElectronSplashScreen></ElectronSplashScreen>
<ElectronIcon></ElectronIcon>
<PackageId>$(MSBuildProjectName.Replace(".", "-").ToLower())</PackageId>
<ElectronPackageId>$(MSBuildProjectName.Replace(".", "-").ToLower())</ElectronPackageId>
<ElectronBuilderJson>electron-builder.json</ElectronBuilderJson>
<Title>$(MSBuildProjectName)</Title>
</PropertyGroup>
@@ -38,15 +38,15 @@ Since electron builder still expects a `package.json` file to exist, ElectronNET
```json
{
"name": "$(PackageId)",
"name": "$(ElectronPackageId)",
"productName": "$(ElectronTitle)",
"build": {
"appId": "$(PackageId)",
"appId": "$(ElectronPackageId)",
"linux": {
"desktop": {
"entry": { "Name": "$(Title)" }
},
"executableName": "$(PackageId)"
"executableName": "$(ElectronPackageId)"
},
"deb": {
"desktop": {

View File

@@ -62,6 +62,52 @@ Add publish profiles to `Properties/PublishProfiles/`:
</Project>
```
#### ASP.NET Application Profile (macOS Apple Silicon ARM64)
**osx-arm64.pubxml:**
```xml
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<DeleteExistingFiles>true</DeleteExistingFiles>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<TargetFramework>net10.0</TargetFramework>
<RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
<ProjectGuid>48eff821-2f4d-60cc-aa44-be0f1d6e5f35</ProjectGuid>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
```
#### ASP.NET Application Profile (macOS Intel x64)
**osx-x64.pubxml:**
```xml
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<DeleteExistingFiles>true</DeleteExistingFiles>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<TargetFramework>net10.0</TargetFramework>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<ProjectGuid>48eff821-2f4d-60cc-aa44-be0f1d6e5f35</ProjectGuid>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
```
#### Console Application Profile (Windows)
**win-x64.pubxml:**
@@ -103,6 +149,46 @@ Add publish profiles to `Properties/PublishProfiles/`:
</Project>
```
#### Console Application Profile (macOS Apple Silicon ARM64)
**osx-arm64.pubxml:**
```xml
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net10.0</TargetFramework>
<RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
</PropertyGroup>
</Project>
```
#### Console Application Profile (macOS Intel x64)
**osx-x64.pubxml:**
```xml
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net10.0</TargetFramework>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
</PropertyGroup>
</Project>
```
### Step 2: Configure Electron Builder
ElectronNET.Core automatically adds a default `electron-builder.json` file under `Properties\electron-builder.json`.

View File

@@ -314,7 +314,9 @@ namespace ElectronNET.API
{
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 = null;
}

View File

@@ -186,6 +186,19 @@ public class BrowserWindow : ApiBase
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>
/// macOS: Emitted once when the window is moved to a new position.
/// </summary>

View File

@@ -2,6 +2,7 @@ using ElectronNET.API.Entities;
using ElectronNET.API.Serialization;
using System;
using System.Text.Json;
using System.Threading.Tasks;
namespace ElectronNET.API
{
@@ -54,10 +55,79 @@ namespace ElectronNET.API
_changed -= value;
if (_changed == null)
{
BridgeConnector.Socket.Off("webContents-session-cookies-changed" + Id);
}
}
}
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
/// window.
/// </summary>
public int X { get; set; } = -1;
public int? X { get; set; }
/// <summary>
/// ( if x is used) Window's top offset from screen. Default is to center the
/// window.
/// </summary>
public int Y { get; set; } = -1;
public int? Y { get; set; }
/// <summary>
/// The width and height would be used as web page's size, which means the actual

View File

@@ -24,7 +24,7 @@
/// <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.
/// </summary>
public bool HostOnly { get; set; }
public bool? HostOnly { get; set; }
/// <summary>
/// Gets or sets the path of the cookie.
@@ -34,22 +34,22 @@
/// <summary>
/// Gets or sets a value indicating whether the cookie is marked as secure.
/// </summary>
public bool Secure { get; set; }
public bool? Secure { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the cookie is marked as HTTP only.
/// </summary>
public bool HttpOnly { get; set; }
public bool? HttpOnly { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the cookie is a session cookie or a persistent cookie with an expiration date.
/// </summary>
public bool Session { get; set; }
public bool? Session { get; set; }
/// <summary>
/// Gets or sets the expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies.
/// </summary>
public double ExpirationDate { get; set; }
public double? ExpirationDate { get; set; }
/// <summary>
/// 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>
/// (optional) - Filters cookies by their Secure property.
/// </summary>
public bool Secure { get; set; }
public bool? Secure { get; set; }
/// <summary>
/// (optional) - Filters out session or persistent cookies.
/// </summary>
public bool Session { get; set; }
public bool? Session { get; set; }
/// <summary>
/// (optional) - Filters cookies by httpOnly.
/// </summary>
public bool HttpOnly { get; set; }
public bool? HttpOnly { get; set; }
}
}

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>
/// 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.
@@ -154,5 +177,88 @@ namespace ElectronNET.API
{
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

@@ -130,11 +130,8 @@ namespace ElectronNET.API
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);
}
else

View File

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

View File

@@ -1,12 +1,13 @@
namespace ElectronNET.Runtime.Services.ElectronProcess
{
using ElectronNET.Common;
using ElectronNET.Runtime.Data;
using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using ElectronNET.Common;
using ElectronNET.Runtime.Data;
/// <summary>
/// Launches and manages the Electron app process.
@@ -33,14 +34,42 @@
this.socketPort = socketPort;
}
protected override Task StartCore()
protected override async Task StartCore()
{
var dir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
string startCmd, args, workingDir;
if (this.isUnpackaged)
{
this.CheckRuntimeIdentifier();
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");
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
@@ -53,17 +82,71 @@
}
else
{
dir = dir.Parent?.Parent;
dir = dir.Parent!.Parent!;
startCmd = Path.Combine(dir.FullName, this.electronBinaryName);
args = $"-dotnetpacked -electronforcedport={this.socketPort:D} " + this.extraArguments;
workingDir = dir.FullName;
}
// 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));
}
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()

View File

@@ -165,13 +165,9 @@
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";
}
else
{
buildInfo.ElectronSingleInstance = "no";
buildInfo.ElectronSingleInstance = parsedBool;
}
if (httpPort?.Length > 0 && int.TryParse(httpPort, out var port))

View File

@@ -61,6 +61,11 @@
{
ElectronNetRuntime.OnAppReadyCallback = onAppReadyCallback;
// 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
// work as expected, see issue #952
Environment.SetEnvironmentVariable("ELECTRON_RUN_AS_NODE", null);
var webPort = PortHelper.GetFreePort(ElectronNetRuntime.AspNetWebPort ?? ElectronNetRuntime.DefaultWebPort);
ElectronNetRuntime.AspNetWebPort = webPort;

View File

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

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>
<None Include=".vscode\tasks.json" />
</ItemGroup>

View File

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

@@ -3,112 +3,118 @@ const electron_updater_1 = require("electron-updater");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('register-autoUpdater-error', (id) => {
electron_updater_1.autoUpdater.on('error', (error) => {
electronSocket.emit('autoUpdater-error' + id, error.message);
socket.on("register-autoUpdater-error", (id) => {
electron_updater_1.autoUpdater.on("error", (error) => {
electronSocket.emit("autoUpdater-error" + id, error.message);
});
});
socket.on('register-autoUpdater-checking-for-update', (id) => {
electron_updater_1.autoUpdater.on('checking-for-update', () => {
electronSocket.emit('autoUpdater-checking-for-update' + id);
socket.on("register-autoUpdater-checking-for-update", (id) => {
electron_updater_1.autoUpdater.on("checking-for-update", () => {
electronSocket.emit("autoUpdater-checking-for-update" + id);
});
});
socket.on('register-autoUpdater-update-available', (id) => {
electron_updater_1.autoUpdater.on('update-available', (updateInfo) => {
electronSocket.emit('autoUpdater-update-available' + id, updateInfo);
socket.on("register-autoUpdater-update-available", (id) => {
electron_updater_1.autoUpdater.on("update-available", (updateInfo) => {
electronSocket.emit("autoUpdater-update-available" + id, updateInfo);
});
});
socket.on('register-autoUpdater-update-not-available', (id) => {
electron_updater_1.autoUpdater.on('update-not-available', (updateInfo) => {
electronSocket.emit('autoUpdater-update-not-available' + id, updateInfo);
socket.on("register-autoUpdater-update-not-available", (id) => {
electron_updater_1.autoUpdater.on("update-not-available", (updateInfo) => {
electronSocket.emit("autoUpdater-update-not-available" + id, updateInfo);
});
});
socket.on('register-autoUpdater-download-progress', (id) => {
electron_updater_1.autoUpdater.on('download-progress', (progressInfo) => {
electronSocket.emit('autoUpdater-download-progress' + id, progressInfo);
socket.on("register-autoUpdater-download-progress", (id) => {
electron_updater_1.autoUpdater.on("download-progress", (progressInfo) => {
electronSocket.emit("autoUpdater-download-progress" + id, progressInfo);
});
});
socket.on('register-autoUpdater-update-downloaded', (id) => {
electron_updater_1.autoUpdater.on('update-downloaded', (updateInfo) => {
electronSocket.emit('autoUpdater-update-downloaded' + id, updateInfo);
socket.on("register-autoUpdater-update-downloaded", (id) => {
electron_updater_1.autoUpdater.on("update-downloaded", (updateInfo) => {
electronSocket.emit("autoUpdater-update-downloaded" + id, updateInfo);
});
});
// Properties *****
socket.on('autoUpdater-autoDownload', () => {
electronSocket.emit('autoUpdater-autoDownload-completed', electron_updater_1.autoUpdater.autoDownload);
socket.on("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;
});
socket.on('autoUpdater-autoInstallOnAppQuit', () => {
electronSocket.emit('autoUpdater-autoInstallOnAppQuit-completed', electron_updater_1.autoUpdater.autoInstallOnAppQuit);
socket.on("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;
});
socket.on('autoUpdater-allowPrerelease', () => {
electronSocket.emit('autoUpdater-allowPrerelease-completed', electron_updater_1.autoUpdater.allowPrerelease);
socket.on("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;
});
socket.on('autoUpdater-fullChangelog', () => {
electronSocket.emit('autoUpdater-fullChangelog-completed', electron_updater_1.autoUpdater.fullChangelog);
socket.on("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;
});
socket.on('autoUpdater-allowDowngrade', () => {
electronSocket.emit('autoUpdater-allowDowngrade-completed', electron_updater_1.autoUpdater.allowDowngrade);
socket.on("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;
});
socket.on('autoUpdater-updateConfigPath', () => {
electronSocket.emit('autoUpdater-updateConfigPath-completed', electron_updater_1.autoUpdater.updateConfigPath || '');
socket.on("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;
});
socket.on('autoUpdater-currentVersion', () => {
electronSocket.emit('autoUpdater-currentVersion-completed', electron_updater_1.autoUpdater.currentVersion);
socket.on("autoUpdater-currentVersion", () => {
electronSocket.emit("autoUpdater-currentVersion-completed", electron_updater_1.autoUpdater.currentVersion);
});
socket.on('autoUpdater-channel', () => {
electronSocket.emit('autoUpdater-channel-completed', electron_updater_1.autoUpdater.channel || '');
socket.on("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;
});
socket.on('autoUpdater-requestHeaders', () => {
electronSocket.emit('autoUpdater-requestHeaders-completed', electron_updater_1.autoUpdater.requestHeaders);
socket.on("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;
});
socket.on('autoUpdater-checkForUpdatesAndNotify', async (guid) => {
electron_updater_1.autoUpdater.checkForUpdatesAndNotify().then((updateCheckResult) => {
electronSocket.emit('autoUpdater-checkForUpdatesAndNotify-completed' + guid, updateCheckResult);
}).catch((error) => {
electronSocket.emit('autoUpdater-checkForUpdatesAndNotifyError' + guid, error);
socket.on("autoUpdater-checkForUpdatesAndNotify", async (guid) => {
electron_updater_1.autoUpdater
.checkForUpdatesAndNotify()
.then((updateCheckResult) => {
electronSocket.emit("autoUpdater-checkForUpdatesAndNotify-completed" + guid, updateCheckResult);
})
.catch((error) => {
electronSocket.emit("autoUpdater-checkForUpdatesAndNotifyError" + guid, error);
});
});
socket.on('autoUpdater-checkForUpdates', async (guid) => {
electron_updater_1.autoUpdater.checkForUpdates().then((updateCheckResult) => {
electronSocket.emit('autoUpdater-checkForUpdates-completed' + guid, updateCheckResult);
}).catch((error) => {
electronSocket.emit('autoUpdater-checkForUpdatesError' + guid, error);
socket.on("autoUpdater-checkForUpdates", async (guid) => {
electron_updater_1.autoUpdater
.checkForUpdates()
.then((updateCheckResult) => {
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);
});
socket.on('autoUpdater-downloadUpdate', async (guid) => {
socket.on("autoUpdater-downloadUpdate", async (guid) => {
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();
electronSocket.emit('autoUpdater-getFeedURL-completed' + guid, feedUrl || '');
electronSocket.emit("autoUpdater-getFeedURL-completed" + guid, feedUrl || "");
});
};
//# sourceMappingURL=autoUpdater.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"autoUpdater.js","sourceRoot":"","sources":["autoUpdater.ts"],"names":[],"mappings":";AACA,uDAA+C;AAC/C,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,CAAC,EAAE,EAAE,EAAE;QAC3C,8BAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC9B,cAAc,CAAC,IAAI,CAAC,mBAAmB,GAAG,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,0CAA0C,EAAE,CAAC,EAAE,EAAE,EAAE;QACzD,8BAAW,CAAC,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;YACvC,cAAc,CAAC,IAAI,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,uCAAuC,EAAE,CAAC,EAAE,EAAE,EAAE;QACtD,8BAAW,CAAC,EAAE,CAAC,kBAAkB,EAAE,CAAC,UAAU,EAAE,EAAE;YAC9C,cAAc,CAAC,IAAI,CAAC,8BAA8B,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2CAA2C,EAAE,CAAC,EAAE,EAAE,EAAE;QAC1D,8BAAW,CAAC,EAAE,CAAC,sBAAsB,EAAE,CAAC,UAAU,EAAE,EAAE;YAClD,cAAc,CAAC,IAAI,CAAC,kCAAkC,GAAG,EAAE,E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C1E,8BAAW,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACrD,MAAM,cAAc,GAAG,MAAM,8BAAW,CAAC,cAAc,EAAE,CAAC;QAC1D,cAAc,CAAC,IAAI,CACjB,sCAAsC,GAAG,IAAI,EAC7C,cAAc,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,wBAAwB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACjD,MAAM,OAAO,GAAG,MAAM,8BAAW,CAAC,UAAU,EAAE,CAAC;QAC/C,cAAc,CAAC,IAAI,CACjB,kCAAkC,GAAG,IAAI,EACzC,OAAO,IAAI,EAAE,CACd,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

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

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"browserView.js","sourceRoot":"","sources":["browserView.ts"],"names":[],"mappings":";;;AACA,uCAAuC;AACvC,MAAM,YAAY,GAAkB,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,CAAkB,CAAC;AAC7G,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,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 { BrowserView } from 'electron';
const browserViews: BrowserView[] = (global['browserViews'] = global['browserViews'] || []) as BrowserView[];
let browserView: BrowserView, electronSocket;
const proxyToCredentialsMap: { [proxy: string]: string } = (global['proxyToCredentialsMap'] = global['proxyToCredentialsMap'] || []) as { [proxy: string]: string };
import type { Socket } from "net";
import { BrowserView } from "electron";
const browserViews: BrowserView[] = (global["browserViews"] =
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) => {
electronSocket = socket;
electronSocket = socket;
socket.on('createBrowserView', (options) => {
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
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;
socket.on("createBrowserView", (options) => {
if (!hasOwnChildreen(options, "webPreferences", "nodeIntegration")) {
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;
}
};
const browserViewMediateService = (browserViewId: number): BrowserView => {
return getBrowserViewById(browserViewId);
return getBrowserViewById(browserViewId);
};
function getBrowserViewById(id: number) {
for (let index = 0; index < browserViews.length; index++) {
const browserViewItem = browserViews[index];
if (browserViewItem['id'] === id) {
return browserViewItem;
}
for (let index = 0; index < browserViews.length; index++) {
const browserViewItem = browserViews[index];
if (browserViewItem["id"] === id) {
return browserViewItem;
}
}
}
export { browserViewApi, browserViewMediateService };

View File

@@ -1,12 +1,46 @@
"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 browserView_1 = require("./browserView");
const path = require("path");
const windows = (global["browserWindows"] =
global["browserWindows"] || []);
let readyToShowWindowsIds = [];
let window, lastOptions, electronSocket;
let mainWindowURL;
let window;
let lastOptions;
let electronSocket;
const proxyToCredentialsMap = (global["proxyToCredentialsMap"] = global["proxyToCredentialsMap"] || []);
module.exports = (socket, app) => {
electronSocket = socket;
@@ -112,6 +146,12 @@ module.exports = (socket, app) => {
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) => {
getWindowById(id).on("moved", () => {
electronSocket.emit("browserWindow-moved" + id);

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,17 @@
import { Socket } from "net";
import { BrowserWindow, Menu, nativeImage } from "electron";
import * as path from "path";
import type { Socket } from "net";
import { BrowserWindow, Menu } from "electron";
import { browserViewMediateService } from "./browserView";
const path = require("path");
const windows: Electron.BrowserWindow[] = (global["browserWindows"] =
global["browserWindows"] || []) as Electron.BrowserWindow[];
let readyToShowWindowsIds: number[] = [];
let window, lastOptions, electronSocket;
let mainWindowURL;
let window;
let lastOptions;
let electronSocket;
const proxyToCredentialsMap: { [proxy: string]: string } = (global[
"proxyToCredentialsMap"
] = global["proxyToCredentialsMap"] || []) as { [proxy: string]: string };
@@ -32,7 +37,7 @@ export = (socket: Socket, app: Electron.App) => {
socket.on("register-browserWindow-ready-to-show", (id) => {
if (readyToShowWindowsIds.includes(id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(
(value) => value !== id
(value) => value !== id,
);
electronSocket.emit("browserWindow-ready-to-show" + id);
}
@@ -139,6 +144,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) => {
getWindowById(id).on("moved", () => {
electronSocket.emit("browserWindow-moved" + id);
@@ -224,7 +240,7 @@ export = (socket: Socket, app: Electron.App) => {
__dirname,
"..",
"scripts",
"blazor-preload.js"
"blazor-preload.js",
);
}
@@ -257,7 +273,7 @@ export = (socket: Socket, app: Electron.App) => {
window.on("ready-to-show", () => {
if (readyToShowWindowsIds.includes(window.id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(
(value) => value !== window.id
(value) => value !== window.id,
);
} else {
readyToShowWindowsIds.push(window.id);
@@ -524,7 +540,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit(
"browserWindow-isFullScreenable-completed",
fullscreenable
fullscreenable,
);
});
@@ -609,7 +625,7 @@ export = (socket: Socket, app: Electron.App) => {
.toString(16);
electronSocket.emit(
"browserWindow-getNativeWindowHandle-completed",
nativeWindowHandle
nativeWindowHandle,
);
});
@@ -622,7 +638,7 @@ export = (socket: Socket, app: Electron.App) => {
} catch (e) {
console.warn(
"setRepresentedFilename failed (likely unsupported platform):",
e
e,
);
}
});
@@ -637,12 +653,12 @@ export = (socket: Socket, app: Electron.App) => {
} catch (e) {
console.warn(
"getRepresentedFilename failed (likely unsupported platform):",
e
e,
);
}
electronSocket.emit(
"browserWindow-getRepresentedFilename-completed",
pathname
pathname,
);
});
@@ -734,7 +750,7 @@ export = (socket: Socket, app: Electron.App) => {
imagePath = path.join(
__dirname.replace("api", ""),
"bin",
originalIconPath
originalIconPath,
);
}
const { nativeImage } = require("electron");
@@ -751,7 +767,7 @@ export = (socket: Socket, app: Electron.App) => {
const success = getWindowById(id).setThumbarButtons(thumbarButtons);
electronSocket.emit("browserWindowSetThumbarButtons-completed", success);
}
},
);
socket.on("browserWindowSetThumbnailClip", (id, rectangle) => {
@@ -779,7 +795,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit(
"browserWindow-isMenuBarAutoHide-completed",
isMenuBarAutoHide
isMenuBarAutoHide,
);
});
@@ -792,7 +808,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit(
"browserWindow-isMenuBarVisible-completed",
isMenuBarVisible
isMenuBarVisible,
);
});
@@ -806,7 +822,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit(
"browserWindow-isVisibleOnAllWorkspaces-completed",
isVisibleOnAllWorkspaces
isVisibleOnAllWorkspaces,
);
});
@@ -838,7 +854,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit(
"browserWindow-getParentWindow-completed",
browserWindow.id
browserWindow.id,
);
});

View File

@@ -3,63 +3,65 @@ const electron_1 = require("electron");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('clipboard-readText', (type) => {
socket.on("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);
});
socket.on('clipboard-readHTML', (type) => {
socket.on("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);
});
socket.on('clipboard-readRTF', (type) => {
socket.on("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);
});
socket.on('clipboard-readBookmark', () => {
socket.on("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);
});
socket.on('clipboard-readFindText', () => {
socket.on("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);
});
socket.on('clipboard-clear', (type) => {
socket.on("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);
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);
});
socket.on('clipboard-readImage', (type) => {
socket.on("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 image = electron_1.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');
const buffer = Buffer.from(bytes, "base64");
image.addRepresentation({ scaleFactor: +scaleFactor, buffer: buffer });
}
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,oB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E;YACnD,CAAC,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;SACpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,sBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,KAAK,GAAG,sBAAW,CAAC,WAAW,EAAE,CAAC;QAExC,kCAAkC;QAClC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,MAAM,WAAW,GAAG,GAAG,CAAC;YACxB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACxB,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC5C,KAAK,CAAC,iBAAiB,CAAC,EAAE,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,oBAAS,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

@@ -1,84 +1,87 @@
import { Socket } from 'net';
import { clipboard, nativeImage } from 'electron';
let electronSocket;
import type { Socket } from "net";
import { clipboard, nativeImage } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
socket.on('clipboard-readText', (type) => {
const text = clipboard.readText(type);
electronSocket.emit('clipboard-readText-completed', text);
electronSocket = socket;
socket.on("clipboard-readText", (type) => {
const text = clipboard.readText(type);
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) => {
clipboard.writeText(text, type);
});
socket.on("clipboard-writeImage", (data, type) => {
const dataContent = JSON.parse(data);
const image = nativeImage.createEmpty();
socket.on('clipboard-readHTML', (type) => {
const content = clipboard.readHTML(type);
electronSocket.emit('clipboard-readHTML-completed', content);
});
// 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 });
}
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-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);
});
clipboard.writeImage(image, type);
});
};

View File

@@ -2,19 +2,19 @@
let electronSocket;
module.exports = (socket, app) => {
electronSocket = socket;
socket.on('appCommandLineAppendSwitch', (the_switch, value) => {
socket.on("appCommandLineAppendSwitch", (the_switch, value) => {
app.commandLine.appendSwitch(the_switch, value);
});
socket.on('appCommandLineAppendArgument', (value) => {
socket.on("appCommandLineAppendArgument", (value) => {
app.commandLine.appendArgument(value);
});
socket.on('appCommandLineHasSwitch', (value) => {
socket.on("appCommandLineHasSwitch", (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);
electronSocket.emit('appCommandLineGetSwitchValueCompleted', value);
electronSocket.emit("appCommandLineGetSwitchValueCompleted", value);
});
};
//# 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;QACnD,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnD,cAAc,CAAC,IAAI,CAAC,kCAAkC,EAAE,SAAS,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,CAAC,UAAkB,EAAE,EAAE;QAC7D,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACzD,cAAc,CAAC,IAAI,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
{"version":3,"file":"commandLine.js","sourceRoot":"","sources":["commandLine.ts"],"names":[],"mappings":";AAEA,IAAI,cAAsB,CAAC;AAE3B,iBAAS,CAAC,MAAc,EAAE,GAAiB,EAAE,EAAE;IAC7C,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CACP,4BAA4B,EAC5B,CAAC,UAAkB,EAAE,KAAa,EAAE,EAAE;QACpC,GAAG,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,CAAC,KAAa,EAAE,EAAE;QAC1D,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,KAAa,EAAE,EAAE;QACrD,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnD,cAAc,CAAC,IAAI,CAAC,kCAAkC,EAAE,SAAS,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,CAAC,UAAkB,EAAE,EAAE;QAC/D,MAAM,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';
let electronSocket;
import type { Socket } from "net";
let electronSocket: Socket;
export = (socket: Socket, app: Electron.App) => {
electronSocket = socket;
electronSocket = socket;
socket.on('appCommandLineAppendSwitch', (the_switch: string, value: string) => {
app.commandLine.appendSwitch(the_switch, value);
});
socket.on(
"appCommandLineAppendSwitch",
(the_switch: string, value: string) => {
app.commandLine.appendSwitch(the_switch, value);
},
);
socket.on('appCommandLineAppendArgument', (value: string) => {
app.commandLine.appendArgument(value);
});
socket.on("appCommandLineAppendArgument", (value: string) => {
app.commandLine.appendArgument(value);
});
socket.on('appCommandLineHasSwitch', (value: string) => {
const hasSwitch = app.commandLine.hasSwitch(value);
electronSocket.emit('appCommandLineHasSwitchCompleted', hasSwitch);
});
socket.on("appCommandLineHasSwitch", (value: string) => {
const hasSwitch = app.commandLine.hasSwitch(value);
electronSocket.emit("appCommandLineHasSwitchCompleted", hasSwitch);
});
socket.on('appCommandLineGetSwitchValue', (the_switch: string) => {
const value = app.commandLine.getSwitchValue(the_switch);
electronSocket.emit('appCommandLineGetSwitchValueCompleted', value);
});
socket.on("appCommandLineGetSwitchValue", (the_switch: string) => {
const value = app.commandLine.getSwitchValue(the_switch);
electronSocket.emit("appCommandLineGetSwitchValueCompleted", value);
});
};

View File

@@ -3,35 +3,41 @@ const electron_1 = require("electron");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('showMessageBox', async (browserWindow, options, guid) => {
if ('id' in browserWindow) {
socket.on("showMessageBox", async (browserWindow, options, guid) => {
if ("id" in browserWindow) {
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
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 {
const id = guid || options;
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 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 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);
});
socket.on('showCertificateTrustDialog', async (browserWindow, options, guid) => {
socket.on("showCertificateTrustDialog", async (browserWindow, options, guid) => {
const window = electron_1.BrowserWindow.fromId(browserWindow.id);
await electron_1.dialog.showCertificateTrustDialog(window, options);
electronSocket.emit('showCertificateTrustDialogComplete' + guid);
electronSocket.emit("showCertificateTrustDialogComplete" + guid);
});
};
//# 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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,EAAE,OAAO,CAAC,CAAC;QAEzD,cAAc,CAAC,IAAI,CAAC,oCAAoC,GAAG,IAAI,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}

View File

@@ -1,45 +1,64 @@
import { Socket } from 'net';
import { BrowserWindow, dialog } from 'electron';
import type { Socket } from "net";
import { BrowserWindow, dialog } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
socket.on('showMessageBox', async (browserWindow, options, guid) => {
if ('id' in browserWindow) {
const window = BrowserWindow.fromId(browserWindow.id);
electronSocket = socket;
socket.on("showMessageBox", async (browserWindow, options, guid) => {
if ("id" in browserWindow) {
const window = BrowserWindow.fromId(browserWindow.id);
const messageBoxReturnValue = await dialog.showMessageBox(window, options);
electronSocket.emit('showMessageBoxComplete' + guid, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
} else {
const id = guid || options;
const messageBoxReturnValue = await dialog.showMessageBox(browserWindow);
const messageBoxReturnValue = await dialog.showMessageBox(
window,
options,
);
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) => {
const window = BrowserWindow.fromId(browserWindow.id);
const openDialogReturnValue = await dialog.showOpenDialog(window, options);
socket.on("showOpenDialog", async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
const openDialogReturnValue = await dialog.showOpenDialog(window, options);
electronSocket.emit('showOpenDialogComplete' + guid, openDialogReturnValue.filePaths || []);
});
electronSocket.emit(
"showOpenDialogComplete" + guid,
openDialogReturnValue.filePaths || [],
);
});
socket.on('showSaveDialog', async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
const saveDialogReturnValue = await dialog.showSaveDialog(window, options);
socket.on("showSaveDialog", async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
const saveDialogReturnValue = await dialog.showSaveDialog(window, options);
electronSocket.emit('showSaveDialogComplete' + guid, saveDialogReturnValue.filePath || '');
});
electronSocket.emit(
"showSaveDialogComplete" + guid,
saveDialogReturnValue.filePath || "",
);
});
socket.on('showErrorBox', (title, content) => {
dialog.showErrorBox(title, content);
});
socket.on("showErrorBox", (title, content) => {
dialog.showErrorBox(title, content);
});
socket.on('showCertificateTrustDialog', async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
await dialog.showCertificateTrustDialog(window, options);
socket.on(
"showCertificateTrustDialog",
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;
module.exports = (socket) => {
electronSocket = socket;
socket.on('dock-bounce', (type) => {
socket.on("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);
});
socket.on('dock-downloadFinished', (filePath) => {
socket.on("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);
});
socket.on('dock-getBadge', () => {
socket.on("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();
});
socket.on('dock-show', () => {
socket.on("dock-show", () => {
electron_1.app.dock.show();
});
socket.on('dock-isVisible', () => {
socket.on("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;
if (menuItems) {
menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('dockMenuItemClicked', id);
electronSocket.emit("dockMenuItemClicked", id);
});
}
electron_1.app.dock.setMenu(menu);
});
// TODO: Menu (macOS) still to be implemented
socket.on('dock-getMenu', () => {
socket.on("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);
});
function addMenuItemClickConnector(menuItems, callback) {
@@ -53,8 +53,10 @@ module.exports = (socket) => {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
if ('id' in item && item.id) {
item.click = () => { callback(item.id); };
if ("id" in item && 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,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE;QAC9B,MAAM,EAAE,GAAG,cAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,cAAc,CAAC,IAAI,CAAC,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BAAyB,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 { app, Menu } from 'electron';
let electronSocket;
import type { Socket } from "net";
import { app, Menu } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
electronSocket = socket;
socket.on('dock-bounce', (type) => {
const id = app.dock.bounce(type);
electronSocket.emit('dock-bounce-completed', id);
});
socket.on("dock-bounce", (type) => {
const id = app.dock.bounce(type);
electronSocket.emit("dock-bounce-completed", id);
});
socket.on('dock-cancelBounce', (id) => {
app.dock.cancelBounce(id);
});
socket.on("dock-cancelBounce", (id) => {
app.dock.cancelBounce(id);
});
socket.on('dock-downloadFinished', (filePath) => {
app.dock.downloadFinished(filePath);
});
socket.on("dock-downloadFinished", (filePath) => {
app.dock.downloadFinished(filePath);
});
socket.on('dock-setBadge', (text) => {
app.dock.setBadge(text);
});
socket.on("dock-setBadge", (text) => {
app.dock.setBadge(text);
});
socket.on('dock-getBadge', () => {
const text = app.dock.getBadge();
electronSocket.emit('dock-getBadge-completed', text);
});
socket.on("dock-getBadge", () => {
const text = app.dock.getBadge();
electronSocket.emit("dock-getBadge-completed", text);
});
socket.on('dock-hide', () => {
app.dock.hide();
});
socket.on("dock-hide", () => {
app.dock.hide();
});
socket.on('dock-show', () => {
app.dock.show();
});
socket.on("dock-show", () => {
app.dock.show();
});
socket.on('dock-isVisible', () => {
const isVisible = app.dock.isVisible();
electronSocket.emit('dock-isVisible-completed', isVisible);
});
socket.on("dock-isVisible", () => {
const isVisible = app.dock.isVisible();
electronSocket.emit("dock-isVisible-completed", isVisible);
});
socket.on('dock-setMenu', (menuItems) => {
let menu = null;
socket.on("dock-setMenu", (menuItems) => {
let menu = null;
if (menuItems) {
menu = Menu.buildFromTemplate(menuItems);
if (menuItems) {
menu = Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (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); };
}
});
addMenuItemClickConnector(menu.items, (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);
};
}
});
}
};

View File

@@ -3,19 +3,19 @@ const electron_1 = require("electron");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('globalShortcut-register', (accelerator) => {
socket.on("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);
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);
});
socket.on('globalShortcut-unregisterAll', () => {
socket.on("globalShortcut-unregisterAll", () => {
try {
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,EAAE,WAAW,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,6BAA6B,EAAE,CAAC,WAAW,EAAE,EAAE;QACrD,MAAM,YAAY,GAAG,yBAAc,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QAE9D,cAAc,CAAC,IAAI,CAAC,sCAAsC,EAAE,YAAY,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2BAA2B,EAAE,CAAC,WAAW,EAAE,EAAE;QACnD,yBAAc,CAAC,UAAU,CAAC,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AAC"}

View File

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

View File

@@ -3,40 +3,41 @@ const electron_1 = require("electron");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('registerIpcMainChannel', (channel) => {
socket.on("registerIpcMainChannel", (channel) => {
electron_1.ipcMain.on(channel, (event, args) => {
electronSocket.emit(channel, [event.preventDefault(), args]);
});
});
socket.on('registerSyncIpcMainChannel', (channel) => {
socket.on("registerSyncIpcMainChannel", (channel) => {
electron_1.ipcMain.on(channel, (event, args) => {
const x = socket;
x.removeAllListeners(channel + 'Sync');
socket.on(channel + 'Sync', (result) => {
x.removeAllListeners(channel + "Sync");
socket.on(channel + "Sync", (result) => {
event.returnValue = result;
});
electronSocket.emit(channel, [event.preventDefault(), args]);
});
});
socket.on('registerOnceIpcMainChannel', (channel) => {
socket.on("registerOnceIpcMainChannel", (channel) => {
electron_1.ipcMain.once(channel, (event, args) => {
electronSocket.emit(channel, [event.preventDefault(), args]);
});
});
socket.on('removeAllListenersIpcMainChannel', (channel) => {
socket.on("removeAllListenersIpcMainChannel", (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);
if (window) {
window.webContents.send(channel, ...data);
}
});
socket.on('sendToIpcRendererBrowserView', (id, channel, data) => {
const browserViews = (global['browserViews'] = global['browserViews'] || []);
socket.on("sendToIpcRendererBrowserView", (id, channel, data) => {
const browserViews = (global["browserViews"] =
global["browserViews"] || []);
let view = null;
for (let i = 0; i < browserViews.length; i++) {
if (browserViews[i]['id'] === id) {
if (browserViews[i]["id"] === id) {
view = browserViews[i];
break;
}
@@ -45,29 +46,58 @@ module.exports = (socket) => {
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
electron_1.ipcMain.on('integration-click-application-menu', (event, id) => {
electron_1.ipcMain.on("integration-click-application-menu", (event, id) => {
try {
const menu = electron_1.Menu.getApplicationMenu();
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);
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 {
const entries = global['contextMenuItems'] || [];
const entries = global["contextMenuItems"] || [];
const entry = entries.find((x) => x.browserWindowId === windowId);
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);
mi.click(undefined, bw, undefined);
}
}
catch { /* ignore */ }
catch {
/* ignore */
}
});
};
//# 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;Y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AC;YACP,YAAY;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,kBAAO,CAAC,EAAE,CACR,gCAAgC,EAChC,CAAC,KAAK,EAAE,QAAgB,EAAE,EAAU,EAAE,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,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 { Socket } from 'net';
let electronSocket;
import type { Socket } from "net";
import { ipcMain, BrowserWindow, BrowserView, Menu } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
socket.on('registerIpcMainChannel', (channel) => {
ipcMain.on(channel, (event, args) => {
electronSocket.emit(channel, [event.preventDefault(), args]);
electronSocket = socket;
socket.on("registerIpcMainChannel", (channel) => {
ipcMain.on(channel, (event, 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) => {
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("registerHandleOnceIpcMainChannel", (channel) => {
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('registerOnceIpcMainChannel', (channel) => {
ipcMain.once(channel, (event, args) => {
electronSocket.emit(channel, [event.preventDefault(), args]);
});
});
socket.on("removeHandlerIpcMainChannel", (channel) => {
ipcMain.removeHandler(channel);
});
socket.on('removeAllListenersIpcMainChannel', (channel) => {
ipcMain.removeAllListeners(channel);
});
// 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 */
}
});
socket.on('sendToIpcRenderer', (browserWindow, channel, data) => {
const window = BrowserWindow.fromId(browserWindow.id);
if (window) {
window.webContents.send(channel, ...data);
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);
}
});
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 */ }
});
} catch {
/* ignore */
}
},
);
};

View File

@@ -1,18 +1,19 @@
"use strict";
const electron_1 = require("electron");
const contextMenuItems = (global['contextMenuItems'] = global['contextMenuItems'] || []);
const contextMenuItems = (global["contextMenuItems"] =
global["contextMenuItems"] || []);
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('menu-setContextMenu', (browserWindowId, menuItems) => {
socket.on("menu-setContextMenu", (browserWindowId, menuItems) => {
const menu = electron_1.Menu.buildFromTemplate(menuItems);
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 = {
menu: menu,
browserWindowId: browserWindowId
browserWindowId: browserWindowId,
};
if (index === -1) {
contextMenuItems.push(contextMenuItem);
@@ -26,23 +27,25 @@ module.exports = (socket) => {
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 ("id" in item && item.id) {
item.click = () => {
callback(item.id, browserWindowId);
};
}
});
}
socket.on('menu-contextMenuPopup', (browserWindowId) => {
contextMenuItems.forEach(x => {
socket.on("menu-contextMenuPopup", (browserWindowId) => {
contextMenuItems.forEach((x) => {
if (x.browserWindowId === browserWindowId) {
const browserWindow = electron_1.BrowserWindow.fromId(browserWindowId);
x.menu.popup(browserWindow);
}
});
});
socket.on('menu-setApplicationMenu', (menuItems) => {
socket.on("menu-setApplicationMenu", (menuItems) => {
const menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('menuItemClicked', id);
electronSocket.emit("menuItemClicked", id);
});
electron_1.Menu.setApplicationMenu(menu);
});
@@ -51,8 +54,10 @@ module.exports = (socket) => {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
if ('id' in item && item.id) {
item.click = () => { callback(item.id); };
if ("id" in item && 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,KAAK,eAAe,CAAC,CAAC;QAEzG,MAAM,eAAe,GAAG;YACpB,IAAI,EAAE,IAAI;YACV,eAAe,EAAE,eAAe;SACnC,CAAC;QAEF,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACJ,gBAAgB,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC;QAC9C,CAAC;IACL,CAAC,CAAC,C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CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,SAAS,EAAE,EAAE;QACjD,MAAM,IAAI,GAAG,eAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAE/C,yBAAyB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE;YAC3C,cAAc,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,eAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAChC,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,71 +1,92 @@
import { Socket } from 'net';
import { Menu, BrowserWindow } from 'electron';
const contextMenuItems = (global['contextMenuItems'] = global['contextMenuItems'] || []);
let electronSocket;
import type { Socket } from "net";
import { Menu, BrowserWindow } from "electron";
const contextMenuItems = (global["contextMenuItems"] =
global["contextMenuItems"] || []);
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
socket.on('menu-setContextMenu', (browserWindowId, menuItems) => {
const menu = Menu.buildFromTemplate(menuItems);
electronSocket = socket;
socket.on("menu-setContextMenu", (browserWindowId, menuItems) => {
const menu = Menu.buildFromTemplate(menuItems);
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, windowId) => {
electronSocket.emit('contextMenuItemClicked', [id, windowId]);
});
addContextMenuItemClickConnector(
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 = {
menu: menu,
browserWindowId: browserWindowId
const contextMenuItem = {
menu: menu,
browserWindowId: browserWindowId,
};
if (index === -1) {
contextMenuItems.push(contextMenuItem);
} else {
contextMenuItems[index] = contextMenuItem;
}
});
function addContextMenuItemClickConnector(
menuItems,
browserWindowId,
callback,
) {
menuItems.forEach((item) => {
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) {
contextMenuItems.push(contextMenuItem);
} else {
contextMenuItems[index] = contextMenuItem;
}
socket.on("menu-contextMenuPopup", (browserWindowId) => {
contextMenuItems.forEach((x) => {
if (x.browserWindowId === browserWindowId) {
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) {
menuItems.forEach((item) => {
if (item.submenu && item.submenu.items.length > 0) {
addContextMenuItemClickConnector(item.submenu.items, browserWindowId, callback);
}
Menu.setApplicationMenu(menu);
});
if ('id' in item && item.id) {
item.click = () => { callback(item.id, browserWindowId); };
}
});
}
function addMenuItemClickConnector(menuItems, callback) {
menuItems.forEach((item) => {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
socket.on('menu-contextMenuPopup', (browserWindowId) => {
contextMenuItems.forEach(x => {
if (x.browserWindowId === browserWindowId) {
const browserWindow = BrowserWindow.fromId(browserWindowId);
x.menu.popup(browserWindow);
}
});
if ("id" in item && item.id) {
item.click = () => {
callback(item.id);
};
}
});
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;
module.exports = (socket) => {
electronSocket = socket;
socket.on('nativeTheme-shouldUseDarkColors', () => {
socket.on("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;
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;
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;
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;
});
socket.on('register-nativeTheme-updated', (id) => {
electron_1.nativeTheme.on('updated', () => {
electronSocket.emit('nativeTheme-updated' + id);
socket.on("register-nativeTheme-updated", (id) => {
electron_1.nativeTheme.on("updated", () => {
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,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QAC9C,MAAM,mBAAmB,GAAG,sBAAW,CAAC,mBAAmB,CAAC;QAE5D,cAAc,CAAC,IAAI,CAAC,2CAA2C,EAAE,mBAAmB,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACtD,MAAM,2BAA2B,GAAG,sBAAW,CAAC,2BAA2B,CAAC;QAE5E,cAAc,CAAC,IAAI,CAAC,mDAAmD,EAAE,2BAA2B,CAAC,CAAC;IAC1G,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;Q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CAAC,IAAI,CACjB,mDAAmD,EACnD,2BAA2B,CAC5B,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QACzD,MAAM,4BAA4B,GAChC,sBAAW,CAAC,4BAA4B,CAAC;QAE3C,cAAc,CAAC,IAAI,CACjB,oDAAoD,EACpD,4BAA4B,CAC7B,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC3C,MAAM,WAAW,GAAG,sBAAW,CAAC,WAAW,CAAC;QAE5C,cAAc,CAAC,IAAI,CAAC,sCAAsC,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,WAAW,EAAE,EAAE;QACnD,sBAAW,CAAC,WAAW,GAAG,WAAW,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,CAAC,EAAE,EAAE,EAAE;QAC/C,sBAAW,CAAC,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 { nativeTheme } from 'electron';
let electronSocket;
import type { Socket } from "net";
import { nativeTheme } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
electronSocket = socket;
socket.on('nativeTheme-shouldUseDarkColors', () => {
const shouldUseDarkColors = nativeTheme.shouldUseDarkColors;
socket.on("nativeTheme-shouldUseDarkColors", () => {
const shouldUseDarkColors = nativeTheme.shouldUseDarkColors;
electronSocket.emit('nativeTheme-shouldUseDarkColors-completed', shouldUseDarkColors);
});
socket.on('nativeTheme-shouldUseHighContrastColors', () => {
const shouldUseHighContrastColors = nativeTheme.shouldUseHighContrastColors;
electronSocket.emit('nativeTheme-shouldUseHighContrastColors-completed', shouldUseHighContrastColors);
});
socket.on('nativeTheme-shouldUseInvertedColorScheme', () => {
const shouldUseInvertedColorScheme = nativeTheme.shouldUseInvertedColorScheme;
electronSocket.emit('nativeTheme-shouldUseInvertedColorScheme-completed', shouldUseInvertedColorScheme);
});
socket.on('nativeTheme-getThemeSource', () => {
const themeSource = nativeTheme.themeSource;
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);
});
electronSocket.emit(
"nativeTheme-shouldUseDarkColors-completed",
shouldUseDarkColors,
);
});
socket.on("nativeTheme-shouldUseHighContrastColors", () => {
const shouldUseHighContrastColors = nativeTheme.shouldUseHighContrastColors;
electronSocket.emit(
"nativeTheme-shouldUseHighContrastColors-completed",
shouldUseHighContrastColors,
);
});
socket.on("nativeTheme-shouldUseInvertedColorScheme", () => {
const shouldUseInvertedColorScheme =
nativeTheme.shouldUseInvertedColorScheme;
electronSocket.emit(
"nativeTheme-shouldUseInvertedColorScheme-completed",
shouldUseInvertedColorScheme,
);
});
socket.on("nativeTheme-getThemeSource", () => {
const themeSource = nativeTheme.themeSource;
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";
const electron_1 = require("electron");
const notifications = (global['notifications'] = global['notifications'] || []);
const notifications = (global["notifications"] =
global["notifications"] || []);
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('createNotification', (options) => {
socket.on("createNotification", (options) => {
const notification = new electron_1.Notification(options);
let haveEvent = false;
if (options.showID) {
haveEvent = true;
notification.on('show', () => {
electronSocket.emit('NotificationEventShow', options.showID);
notification.on("show", () => {
electronSocket.emit("NotificationEventShow", options.showID);
});
}
if (options.clickID) {
haveEvent = true;
notification.on('click', () => {
electronSocket.emit('NotificationEventClick', options.clickID);
notification.on("click", () => {
electronSocket.emit("NotificationEventClick", options.clickID);
});
}
if (options.closeID) {
haveEvent = true;
notification.on('close', () => {
electronSocket.emit('NotificationEventClose', options.closeID);
notification.on("close", () => {
electronSocket.emit("NotificationEventClose", options.closeID);
});
}
if (options.replyID) {
haveEvent = true;
notification.on('reply', (event, value) => {
electronSocket.emit('NotificationEventReply', [options.replyID, value]);
notification.on("reply", (event, value) => {
electronSocket.emit("NotificationEventReply", [options.replyID, value]);
});
}
if (options.actionID) {
haveEvent = true;
notification.on('action', (event, value) => {
electronSocket.emit('NotificationEventAction', [options.actionID, value]);
notification.on("action", (event, value) => {
electronSocket.emit("NotificationEventAction", [
options.actionID,
value,
]);
});
}
if (haveEvent) {
@@ -42,9 +46,9 @@ module.exports = (socket) => {
}
notification.show();
});
socket.on('notificationIsSupported', () => {
socket.on("notificationIsSupported", () => {
const isSupported = electron_1.Notification.isSupported();
electronSocket.emit('notificationIsSupportedCompleted', isSupported);
electronSocket.emit("notificationIsSupportedCompleted", isSupported);
});
};
//# 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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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 { Notification } from 'electron';
const notifications: Electron.Notification[] = (global['notifications'] = global['notifications'] || []) as Electron.Notification[];
let electronSocket;
import type { Socket } from "net";
import { Notification } from "electron";
const notifications: Electron.Notification[] = (global["notifications"] =
global["notifications"] || []) as Electron.Notification[];
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
socket.on('createNotification', (options) => {
const notification = new Notification(options);
let haveEvent = false;
electronSocket = socket;
socket.on("createNotification", (options) => {
const notification = new Notification(options);
let haveEvent = false;
if (options.showID) {
haveEvent = true;
notification.on('show', () => {
electronSocket.emit('NotificationEventShow', options.showID);
});
}
if (options.showID) {
haveEvent = true;
notification.on("show", () => {
electronSocket.emit("NotificationEventShow", options.showID);
});
}
if (options.clickID) {
haveEvent = true;
notification.on('click', () => {
electronSocket.emit('NotificationEventClick', options.clickID);
});
}
if (options.clickID) {
haveEvent = true;
notification.on("click", () => {
electronSocket.emit("NotificationEventClick", options.clickID);
});
}
if (options.closeID) {
haveEvent = true;
notification.on('close', () => {
electronSocket.emit('NotificationEventClose', options.closeID);
});
}
if (options.closeID) {
haveEvent = true;
notification.on("close", () => {
electronSocket.emit("NotificationEventClose", options.closeID);
});
}
if (options.replyID) {
haveEvent = true;
notification.on('reply', (event, value) => {
electronSocket.emit('NotificationEventReply', [options.replyID, value]);
});
}
if (options.replyID) {
haveEvent = true;
notification.on("reply", (event, value) => {
electronSocket.emit("NotificationEventReply", [options.replyID, value]);
});
}
if (options.actionID) {
haveEvent = true;
notification.on('action', (event, value) => {
electronSocket.emit('NotificationEventAction', [options.actionID, value]);
});
}
if (options.actionID) {
haveEvent = true;
notification.on("action", (event, value) => {
electronSocket.emit("NotificationEventAction", [
options.actionID,
value,
]);
});
}
if (haveEvent) {
notifications.push(notification);
}
if (haveEvent) {
notifications.push(notification);
}
notification.show();
});
notification.show();
});
socket.on('notificationIsSupported', () => {
const isSupported = Notification.isSupported();
electronSocket.emit('notificationIsSupportedCompleted', isSupported);
});
socket.on("notificationIsSupported", () => {
const isSupported = Notification.isSupported();
electronSocket.emit("notificationIsSupportedCompleted", isSupported);
});
};

View File

@@ -3,39 +3,39 @@ const electron_1 = require("electron");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('register-powerMonitor-lock-screen', () => {
electron_1.powerMonitor.on('lock-screen', () => {
electronSocket.emit('powerMonitor-lock-screen');
socket.on("register-powerMonitor-lock-screen", () => {
electron_1.powerMonitor.on("lock-screen", () => {
electronSocket.emit("powerMonitor-lock-screen");
});
});
socket.on('register-powerMonitor-unlock-screen', () => {
electron_1.powerMonitor.on('unlock-screen', () => {
electronSocket.emit('powerMonitor-unlock-screen');
socket.on("register-powerMonitor-unlock-screen", () => {
electron_1.powerMonitor.on("unlock-screen", () => {
electronSocket.emit("powerMonitor-unlock-screen");
});
});
socket.on('register-powerMonitor-suspend', () => {
electron_1.powerMonitor.on('suspend', () => {
electronSocket.emit('powerMonitor-suspend');
socket.on("register-powerMonitor-suspend", () => {
electron_1.powerMonitor.on("suspend", () => {
electronSocket.emit("powerMonitor-suspend");
});
});
socket.on('register-powerMonitor-resume', () => {
electron_1.powerMonitor.on('resume', () => {
electronSocket.emit('powerMonitor-resume');
socket.on("register-powerMonitor-resume", () => {
electron_1.powerMonitor.on("resume", () => {
electronSocket.emit("powerMonitor-resume");
});
});
socket.on('register-powerMonitor-ac', () => {
electron_1.powerMonitor.on('on-ac', () => {
electronSocket.emit('powerMonitor-ac');
socket.on("register-powerMonitor-ac", () => {
electron_1.powerMonitor.on("on-ac", () => {
electronSocket.emit("powerMonitor-ac");
});
});
socket.on('register-powerMonitor-battery', () => {
electron_1.powerMonitor.on('on-battery', () => {
electronSocket.emit('powerMonitor-battery');
socket.on("register-powerMonitor-battery", () => {
electron_1.powerMonitor.on("on-battery", () => {
electronSocket.emit("powerMonitor-battery");
});
});
socket.on('register-powerMonitor-shutdown', () => {
electron_1.powerMonitor.on('shutdown', () => {
electronSocket.emit('powerMonitor-shutdown');
socket.on("register-powerMonitor-shutdown", () => {
electron_1.powerMonitor.on("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,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAChD,uBAAY,CAAC,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE;YAChC,cAAc,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAClD,uBAAY,CAAC,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAC5C,uBAAY,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YAC5B,cAAc,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QAC3C,uBAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YAC3B,cAAc,CAAC,IAAI,CAAC,q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AI,CAAC,4BAA4B,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAC9C,uBAAY,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YAC9B,cAAc,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QAC7C,uBAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YAC7B,cAAc,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 { powerMonitor } from 'electron';
let electronSocket;
import type { Socket } from "net";
import { powerMonitor } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
socket.on('register-powerMonitor-lock-screen', () => {
powerMonitor.on('lock-screen', () => {
electronSocket.emit('powerMonitor-lock-screen');
});
electronSocket = socket;
socket.on("register-powerMonitor-lock-screen", () => {
powerMonitor.on("lock-screen", () => {
electronSocket.emit("powerMonitor-lock-screen");
});
socket.on('register-powerMonitor-unlock-screen', () => {
powerMonitor.on('unlock-screen', () => {
electronSocket.emit('powerMonitor-unlock-screen');
});
});
socket.on("register-powerMonitor-unlock-screen", () => {
powerMonitor.on("unlock-screen", () => {
electronSocket.emit("powerMonitor-unlock-screen");
});
socket.on('register-powerMonitor-suspend', () => {
powerMonitor.on('suspend', () => {
electronSocket.emit('powerMonitor-suspend');
});
});
socket.on("register-powerMonitor-suspend", () => {
powerMonitor.on("suspend", () => {
electronSocket.emit("powerMonitor-suspend");
});
socket.on('register-powerMonitor-resume', () => {
powerMonitor.on('resume', () => {
electronSocket.emit('powerMonitor-resume');
});
});
socket.on("register-powerMonitor-resume", () => {
powerMonitor.on("resume", () => {
electronSocket.emit("powerMonitor-resume");
});
socket.on('register-powerMonitor-ac', () => {
powerMonitor.on('on-ac', () => {
electronSocket.emit('powerMonitor-ac');
});
});
socket.on("register-powerMonitor-ac", () => {
powerMonitor.on("on-ac", () => {
electronSocket.emit("powerMonitor-ac");
});
socket.on('register-powerMonitor-battery', () => {
powerMonitor.on('on-battery', () => {
electronSocket.emit('powerMonitor-battery');
});
});
socket.on("register-powerMonitor-battery", () => {
powerMonitor.on("on-battery", () => {
electronSocket.emit("powerMonitor-battery");
});
socket.on('register-powerMonitor-shutdown', () => {
powerMonitor.on('shutdown', () => {
electronSocket.emit('powerMonitor-shutdown');
});
});
socket.on("register-powerMonitor-shutdown", () => {
powerMonitor.on("shutdown", () => {
electronSocket.emit("powerMonitor-shutdown");
});
});
};

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"process.js","sourceRoot":"","sources":["process.ts"],"names":[],"mappings":";AACA,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC;QAC/B,cAAc,CAAC,IAAI,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QAC3B,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QAC3B,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC;QAC/B,cAAc,CAAC,IAAI,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;QACjC,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACnC,cAAc,CAAC,IAAI,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,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YAC9B,cAAc,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC,CAAC;YACjD,OAAO;QACT,CAAC;QACD,cAAc,CAAC,IAAI,CAAC,uBAAuB,EAAE,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';
let electronSocket;
import type { Socket } from "net";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
electronSocket = socket;
socket.on('process-execPath', () => {
const value = process.execPath;
electronSocket.emit('process-execPath-completed', value);
});
socket.on("process-execPath", () => {
const value = process.execPath;
electronSocket.emit("process-execPath-completed", value);
});
socket.on('process-argv', () => {
const value = process.argv;
electronSocket.emit('process-argv-completed', value);
});
socket.on("process-argv", () => {
const value = process.argv;
electronSocket.emit("process-argv-completed", value);
});
socket.on('process-type', () => {
const value = process.type;
electronSocket.emit('process-type-completed', value);
});
socket.on("process-type", () => {
const value = process.type;
electronSocket.emit("process-type-completed", value);
});
socket.on('process-versions', () => {
const value = process.versions;
electronSocket.emit('process-versions-completed', value);
});
socket.on("process-versions", () => {
const value = process.versions;
electronSocket.emit("process-versions-completed", value);
});
socket.on('process-defaultApp', () => {
if (process.defaultApp === undefined) {
electronSocket.emit('process-defaultApp-completed', false);
return;
}
electronSocket.emit('process-defaultApp-completed', process.defaultApp);
});
socket.on("process-defaultApp", () => {
if (process.defaultApp === undefined) {
electronSocket.emit("process-defaultApp-completed", false);
return;
}
electronSocket.emit("process-defaultApp-completed", process.defaultApp);
});
socket.on('process-isMainFrame', () => {
if (process.isMainFrame === undefined) {
electronSocket.emit('process-isMainFrame-completed', false);
return;
}
electronSocket.emit('process-isMainFrame-completed', process.isMainFrame);
});
socket.on("process-isMainFrame", () => {
if (process.isMainFrame === undefined) {
electronSocket.emit("process-isMainFrame-completed", false);
return;
}
electronSocket.emit("process-isMainFrame-completed", process.isMainFrame);
});
socket.on('process-resourcesPath', () => {
const value = process.resourcesPath;
electronSocket.emit('process-resourcesPath-completed', value);
});
socket.on("process-resourcesPath", () => {
const value = process.resourcesPath;
electronSocket.emit("process-resourcesPath-completed", value);
});
socket.on('process-upTime', () => {
let value = process.uptime();
if (value === undefined) {
value = -1;
}
electronSocket.emit('process-upTime-completed', value);
});
socket.on("process-upTime", () => {
let value = process.uptime();
if (value === undefined) {
value = -1;
}
electronSocket.emit("process-upTime-completed", value);
});
socket.on('process-pid', () => {
if (process.pid === undefined) {
electronSocket.emit('process-pid-completed', -1);
return;
}
electronSocket.emit('process-pid-completed', process.pid);
});
socket.on("process-pid", () => {
if (process.pid === undefined) {
electronSocket.emit("process-pid-completed", -1);
return;
}
electronSocket.emit("process-pid-completed", process.pid);
});
socket.on('process-arch', () => {
const value = process.arch;
electronSocket.emit('process-arch-completed', value);
});
socket.on("process-arch", () => {
const value = process.arch;
electronSocket.emit("process-arch-completed", value);
});
socket.on('process-platform', () => {
const value = process.platform;
electronSocket.emit('process-platform-completed', value);
})
socket.on("process-platform", () => {
const value = process.platform;
electronSocket.emit("process-platform-completed", value);
});
};

View File

@@ -3,44 +3,47 @@ const electron_1 = require("electron");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('register-screen-display-added', (id) => {
electron_1.screen.on('display-added', (event, display) => {
electronSocket.emit('screen-display-added' + id, display);
socket.on("register-screen-display-added", (id) => {
electron_1.screen.on("display-added", (event, display) => {
electronSocket.emit("screen-display-added" + id, display);
});
});
socket.on('register-screen-display-removed', (id) => {
electron_1.screen.on('display-removed', (event, display) => {
electronSocket.emit('screen-display-removed' + id, display);
socket.on("register-screen-display-removed", (id) => {
electron_1.screen.on("display-removed", (event, display) => {
electronSocket.emit("screen-display-removed" + id, display);
});
});
socket.on('register-screen-display-metrics-changed', (id) => {
electron_1.screen.on('display-metrics-changed', (event, display, changedMetrics) => {
electronSocket.emit('screen-display-metrics-changed' + id, [display, changedMetrics]);
socket.on("register-screen-display-metrics-changed", (id) => {
electron_1.screen.on("display-metrics-changed", (event, 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();
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;
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();
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();
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);
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);
electronSocket.emit('screen-getDisplayMatching-completed', display);
electronSocket.emit("screen-getDisplayMatching-completed", display);
});
};
//# 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,cAAc,CAA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import { screen } from 'electron';
let electronSocket;
import type { Socket } from "net";
import { screen } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
electronSocket = socket;
socket.on('register-screen-display-added', (id) => {
screen.on('display-added', (event, display) => {
electronSocket.emit('screen-display-added' + id, display);
});
socket.on("register-screen-display-added", (id) => {
screen.on("display-added", (event, display) => {
electronSocket.emit("screen-display-added" + id, display);
});
});
socket.on('register-screen-display-removed', (id) => {
screen.on('display-removed', (event, display) => {
electronSocket.emit('screen-display-removed' + id, display);
});
socket.on("register-screen-display-removed", (id) => {
screen.on("display-removed", (event, display) => {
electronSocket.emit("screen-display-removed" + id, display);
});
});
socket.on('register-screen-display-metrics-changed', (id) => {
screen.on('display-metrics-changed', (event, display, changedMetrics) => {
electronSocket.emit('screen-display-metrics-changed' + id, [display, changedMetrics]);
});
socket.on("register-screen-display-metrics-changed", (id) => {
screen.on("display-metrics-changed", (event, display, changedMetrics) => {
electronSocket.emit("screen-display-metrics-changed" + id, [
display,
changedMetrics,
]);
});
});
socket.on('screen-getCursorScreenPoint', () => {
const point = screen.getCursorScreenPoint();
electronSocket.emit('screen-getCursorScreenPoint-completed', point);
});
socket.on("screen-getCursorScreenPoint", () => {
const point = screen.getCursorScreenPoint();
electronSocket.emit("screen-getCursorScreenPoint-completed", point);
});
socket.on('screen-getMenuBarWorkArea', () => {
const height = screen.getPrimaryDisplay().workArea;
electronSocket.emit('screen-getMenuBarWorkArea-completed', height);
});
socket.on("screen-getMenuBarWorkArea", () => {
const height = screen.getPrimaryDisplay().workArea;
electronSocket.emit("screen-getMenuBarWorkArea-completed", height);
});
socket.on('screen-getPrimaryDisplay', () => {
const display = screen.getPrimaryDisplay();
electronSocket.emit('screen-getPrimaryDisplay-completed', display);
});
socket.on("screen-getPrimaryDisplay", () => {
const display = screen.getPrimaryDisplay();
electronSocket.emit("screen-getPrimaryDisplay-completed", display);
});
socket.on('screen-getAllDisplays', () => {
const display = screen.getAllDisplays();
electronSocket.emit('screen-getAllDisplays-completed', display);
});
socket.on("screen-getAllDisplays", () => {
const display = screen.getAllDisplays();
electronSocket.emit("screen-getAllDisplays-completed", display);
});
socket.on('screen-getDisplayNearestPoint', (point) => {
const display = screen.getDisplayNearestPoint(point);
electronSocket.emit('screen-getDisplayNearestPoint-completed', display);
});
socket.on("screen-getDisplayNearestPoint", (point) => {
const display = screen.getDisplayNearestPoint(point);
electronSocket.emit("screen-getDisplayNearestPoint-completed", display);
});
socket.on('screen-getDisplayMatching', (rectangle) => {
const display = screen.getDisplayMatching(rectangle);
electronSocket.emit('screen-getDisplayMatching-completed', display);
});
socket.on("screen-getDisplayMatching", (rectangle) => {
const display = screen.getDisplayMatching(rectangle);
electronSocket.emit("screen-getDisplayMatching-completed", display);
});
};

View File

@@ -3,18 +3,18 @@ const electron_1 = require("electron");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('shell-showItemInFolder', (fullPath) => {
socket.on("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);
electronSocket.emit('shell-openPathCompleted', errorMessage);
electronSocket.emit("shell-openPathCompleted", errorMessage);
});
socket.on('shell-openExternal', async (url, options) => {
let result = '';
socket.on("shell-openExternal", async (url, options) => {
let result = "";
if (options) {
await electron_1.shell.openExternal(url, options).catch(e => {
await electron_1.shell.openExternal(url, options).catch((e) => {
result = e.message;
});
}
@@ -23,9 +23,9 @@ module.exports = (socket) => {
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;
try {
await electron_1.shell.trashItem(fullPath);
@@ -34,18 +34,18 @@ module.exports = (socket) => {
catch (error) {
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();
});
socket.on('shell-writeShortcutLink', (shortcutPath, operation, options) => {
socket.on("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);
electronSocket.emit('shell-readShortcutLinkCompleted', shortcutDetails);
electronSocket.emit("shell-readShortcutLinkCompleted", shortcutDetails);
});
};
//# 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,KAAK,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,YAAY,GAAG,MAAM,gBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEhD,cAAc,CAAC,IAAI,CAAC,yBAAyB,EAAE,YAAY,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,E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c,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 { shell } from 'electron';
let electronSocket;
import type { Socket } from "net";
import { shell } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
socket.on('shell-showItemInFolder', (fullPath) => {
shell.showItemInFolder(fullPath);
electronSocket = socket;
socket.on("shell-showItemInFolder", (fullPath) => {
shell.showItemInFolder(fullPath);
electronSocket.emit('shell-showItemInFolderCompleted');
});
electronSocket.emit("shell-showItemInFolderCompleted");
});
socket.on('shell-openPath', async (path) => {
const errorMessage = await shell.openPath(path);
socket.on("shell-openPath", async (path) => {
const errorMessage = await shell.openPath(path);
electronSocket.emit('shell-openPathCompleted', errorMessage);
});
electronSocket.emit("shell-openPathCompleted", errorMessage);
});
socket.on('shell-openExternal', async (url, options) => {
let result = '';
socket.on("shell-openExternal", async (url, options) => {
let result = "";
if (options) {
await shell.openExternal(url, options).catch(e => {
result = e.message;
});
} else {
await shell.openExternal(url).catch((e) => {
result = e.message;
});
}
if (options) {
await shell.openExternal(url, options).catch((e) => {
result = e.message;
});
} else {
await shell.openExternal(url).catch((e) => {
result = e.message;
});
}
electronSocket.emit('shell-openExternalCompleted', result);
});
electronSocket.emit("shell-openExternalCompleted", result);
});
socket.on('shell-trashItem', async (fullPath, deleteOnFail) => {
let success = false;
socket.on("shell-trashItem", async (fullPath, deleteOnFail) => {
let success = false;
try {
await shell.trashItem(fullPath);
success = true;
} catch (error) {
success = false;
}
try {
await shell.trashItem(fullPath);
success = true;
} catch (error) {
success = false;
}
electronSocket.emit('shell-trashItem-completed', success);
});
electronSocket.emit("shell-trashItem-completed", success);
});
socket.on('shell-beep', () => {
shell.beep();
});
socket.on("shell-beep", () => {
shell.beep();
});
socket.on('shell-writeShortcutLink', (shortcutPath, operation, options) => {
const success = shell.writeShortcutLink(shortcutPath, operation, options);
socket.on("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) => {
const shortcutDetails = shell.readShortcutLink(shortcutPath);
socket.on("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";
const electron_1 = require("electron");
let tray = (global['$tray'] = global['tray'] || { value: null });
let tray = (global["$tray"] = global["tray"] || {
value: null,
});
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('register-tray-click', (id) => {
socket.on("register-tray-click", (id) => {
if (tray.value) {
tray.value.on('click', (event, bounds) => {
electronSocket.emit('tray-click' + id, [event.__proto__, bounds]);
tray.value.on("click", (event, 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) {
tray.value.on('right-click', (event, bounds) => {
electronSocket.emit('tray-right-click' + id, [event.__proto__, bounds]);
tray.value.on("right-click", (event, 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) {
tray.value.on('double-click', (event, bounds) => {
electronSocket.emit('tray-double-click' + id, [event.__proto__, bounds]);
tray.value.on("double-click", (event, 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) {
tray.value.on('balloon-show', () => {
electronSocket.emit('tray-balloon-show' + id);
tray.value.on("balloon-show", () => {
electronSocket.emit("tray-balloon-show" + id);
});
}
});
socket.on('register-tray-balloon-click', (id) => {
socket.on("register-tray-balloon-click", (id) => {
if (tray.value) {
tray.value.on('balloon-click', () => {
electronSocket.emit('tray-balloon-click' + id);
tray.value.on("balloon-click", () => {
electronSocket.emit("tray-balloon-click" + id);
});
}
});
socket.on('register-tray-balloon-closed', (id) => {
socket.on("register-tray-balloon-closed", (id) => {
if (tray.value) {
tray.value.on('balloon-closed', () => {
electronSocket.emit('tray-balloon-closed' + id);
tray.value.on("balloon-closed", () => {
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);
tray.value = new electron_1.Tray(trayIcon);
if (menuItems) {
applyContextMenu(menuItems);
}
});
socket.on('tray-destroy', () => {
socket.on("tray-destroy", () => {
if (tray.value) {
tray.value.destroy();
}
});
socket.on('set-contextMenu', (menuItems) => {
socket.on("set-contextMenu", (menuItems) => {
if (menuItems && tray.value) {
applyContextMenu(menuItems);
}
});
socket.on('tray-setImage', (image) => {
socket.on("tray-setImage", (image) => {
if (tray.value) {
tray.value.setImage(image);
}
});
socket.on('tray-setPressedImage', (image) => {
socket.on("tray-setPressedImage", (image) => {
if (tray.value) {
const img = electron_1.nativeImage.createFromPath(image);
tray.value.setPressedImage(img);
}
});
socket.on('tray-setToolTip', (toolTip) => {
socket.on("tray-setToolTip", (toolTip) => {
if (tray.value) {
tray.value.setToolTip(toolTip);
}
});
socket.on('tray-setTitle', (title) => {
socket.on("tray-setTitle", (title) => {
if (tray.value) {
tray.value.setTitle(title);
}
});
socket.on('tray-displayBalloon', (options) => {
socket.on("tray-displayBalloon", (options) => {
if (tray.value) {
tray.value.displayBalloon(options);
}
});
socket.on('tray-isDestroyed', () => {
socket.on("tray-isDestroyed", () => {
if (tray.value) {
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) {
tray.value.on(eventName, (...args) => {
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) {
tray.value.once(eventName, (...args) => {
if (args.length > 1) {
@@ -122,7 +133,7 @@ module.exports = (socket) => {
function applyContextMenu(menuItems) {
const menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('trayMenuItemClicked', id);
electronSocket.emit("trayMenuItemClicked", id);
});
tray.value.setContextMenu(menu);
}
@@ -131,8 +142,10 @@ module.exports = (socket) => {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
if ('id' in item && item.id) {
item.click = () => { callback(item.id); };
if ("id" in item && item.id) {
item.click = () => {
callback(item.id);
};
}
});
}

File diff suppressed because one or more lines are too long

View File

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

@@ -1,7 +1,40 @@
"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 fs = __importStar(require("fs"));
const electron_1 = require("electron");
const browserView_1 = require("./browserView");
const fs = require("fs");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
@@ -315,28 +348,28 @@ module.exports = (socket) => {
const extension = await browserWindow.webContents.session.loadExtension(path, { allowFileAccess: allowFileAccess });
electronSocket.emit("webContents-session-loadExtension-completed", extension);
});
socket.on('webContents-getZoomFactor', (id) => {
socket.on("webContents-getZoomFactor", (id) => {
const browserWindow = getWindowById(id);
const text = browserWindow.webContents.getZoomFactor();
electronSocket.emit('webContents-getZoomFactor-completed', text);
electronSocket.emit("webContents-getZoomFactor-completed", text);
});
socket.on('webContents-setZoomFactor', (id, factor) => {
socket.on("webContents-setZoomFactor", (id, factor) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.setZoomFactor(factor);
});
socket.on('webContents-getZoomLevel', (id) => {
socket.on("webContents-getZoomLevel", (id) => {
const browserWindow = getWindowById(id);
const content = browserWindow.webContents.getZoomLevel();
electronSocket.emit('webContents-getZoomLevel-completed', content);
electronSocket.emit("webContents-getZoomLevel-completed", content);
});
socket.on('webContents-setZoomLevel', (id, level) => {
socket.on("webContents-setZoomLevel", (id, level) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.setZoomLevel(level);
});
socket.on('webContents-setVisualZoomLevelLimits', async (id, minimumLevel, maximumLevel) => {
socket.on("webContents-setVisualZoomLevelLimits", async (id, minimumLevel, maximumLevel) => {
const browserWindow = getWindowById(id);
await browserWindow.webContents.setVisualZoomLevelLimits(minimumLevel, maximumLevel);
electronSocket.emit('webContents-setVisualZoomLevelLimits-completed');
electronSocket.emit("webContents-setVisualZoomLevelLimits-completed");
});
socket.on("webContents-toggleDevTools", (id) => {
getWindowById(id).webContents.toggleDevTools();
@@ -346,26 +379,26 @@ module.exports = (socket) => {
});
socket.on("webContents-isDevToolsOpened", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isDevToolsOpened-completed', browserWindow.webContents.isDevToolsOpened());
electronSocket.emit("webContents-isDevToolsOpened-completed", browserWindow.webContents.isDevToolsOpened());
});
socket.on("webContents-isDevToolsFocused", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isDevToolsFocused-completed', browserWindow.webContents.isDevToolsFocused());
electronSocket.emit("webContents-isDevToolsFocused-completed", browserWindow.webContents.isDevToolsFocused());
});
socket.on("webContents-setAudioMuted", (id, muted) => {
getWindowById(id).webContents.setAudioMuted(muted);
});
socket.on("webContents-isAudioMuted", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isAudioMuted-completed', browserWindow.webContents.isAudioMuted());
electronSocket.emit("webContents-isAudioMuted-completed", browserWindow.webContents.isAudioMuted());
});
socket.on("webContents-isCurrentlyAudible", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isCurrentlyAudible-completed', browserWindow.webContents.isCurrentlyAudible());
electronSocket.emit("webContents-isCurrentlyAudible-completed", browserWindow.webContents.isCurrentlyAudible());
});
socket.on("webContents-getUserAgent", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-getUserAgent-completed', browserWindow.webContents.getUserAgent());
electronSocket.emit("webContents-getUserAgent-completed", browserWindow.webContents.getUserAgent());
});
socket.on("webContents-setUserAgent", (id, userAgent) => {
getWindowById(id).webContents.setUserAgent(userAgent);

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,10 @@
import { Socket } from "net";
import {BrowserWindow, BrowserView} from "electron";
import * as fs from "fs";
import type { Socket } from "net";
import { BrowserWindow, BrowserView } from "electron";
import { browserViewMediateService } from "./browserView";
const fs = require("fs");
let electronSocket;
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
@@ -68,7 +70,7 @@ export = (socket: Socket) => {
errorCode,
validatedUrl,
});
}
},
);
});
@@ -136,17 +138,17 @@ export = (socket: Socket) => {
async (id, code, userGesture = false) => {
const result = await getWindowById(id).webContents.executeJavaScript(
code,
userGesture
userGesture,
);
electronSocket.emit("webContents-executeJavaScript-completed", result);
}
},
);
socket.on("webContents-getUrl", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit(
"webContents-getUrl" + id,
browserWindow.webContents.getURL()
browserWindow.webContents.getURL(),
);
});
@@ -155,7 +157,7 @@ export = (socket: Socket) => {
(id, domains) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.session.allowNTLMCredentialsForDomains(domains);
}
},
);
socket.on("webContents-session-clearAuthCache", async (...args) => {
@@ -194,7 +196,7 @@ export = (socket: Socket) => {
await browserWindow.webContents.session.clearHostResolverCache();
electronSocket.emit(
"webContents-session-clearHostResolverCache-completed" + guid
"webContents-session-clearHostResolverCache-completed" + guid,
);
});
@@ -203,7 +205,7 @@ export = (socket: Socket) => {
await browserWindow.webContents.session.clearStorageData({});
electronSocket.emit(
"webContents-session-clearStorageData-completed" + guid
"webContents-session-clearStorageData-completed" + guid,
);
});
@@ -214,9 +216,9 @@ export = (socket: Socket) => {
await browserWindow.webContents.session.clearStorageData(options);
electronSocket.emit(
"webContents-session-clearStorageData-options-completed" + guid
"webContents-session-clearStorageData-options-completed" + guid,
);
}
},
);
socket.on("webContents-session-createInterruptedDownload", (id, options) => {
@@ -241,13 +243,12 @@ export = (socket: Socket) => {
socket.on("webContents-session-getBlobData", async (id, identifier, guid) => {
const browserWindow = getWindowById(id);
const buffer = await browserWindow.webContents.session.getBlobData(
identifier
);
const buffer =
await browserWindow.webContents.session.getBlobData(identifier);
electronSocket.emit(
"webContents-session-getBlobData-completed" + guid,
buffer.buffer
buffer.buffer,
);
});
@@ -257,7 +258,7 @@ export = (socket: Socket) => {
electronSocket.emit(
"webContents-session-getCacheSize-completed" + guid,
size
size,
);
});
@@ -267,7 +268,7 @@ export = (socket: Socket) => {
electronSocket.emit(
"webContents-session-getPreloads-completed" + guid,
preloads
preloads,
);
});
@@ -277,7 +278,7 @@ export = (socket: Socket) => {
electronSocket.emit(
"webContents-session-getUserAgent-completed" + guid,
userAgent
userAgent,
);
});
@@ -287,7 +288,7 @@ export = (socket: Socket) => {
electronSocket.emit(
"webContents-session-resolveProxy-completed" + guid,
proxy
proxy,
);
});
@@ -314,9 +315,9 @@ export = (socket: Socket) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.session.setUserAgent(
userAgent,
acceptLanguages
acceptLanguages,
);
}
},
);
socket.on(
@@ -328,17 +329,17 @@ export = (socket: Socket) => {
session.webRequest.onBeforeRequest(filter, (details, callback) => {
socket.emit(
`webContents-session-webRequest-onBeforeRequest${id}`,
details
details,
);
// Listen for a response from C# to continue the request
electronSocket.once(
`webContents-session-webRequest-onBeforeRequest-response${id}`,
(response) => {
callback(response);
}
},
);
});
}
},
);
socket.on("register-webContents-session-cookies-changed", (id) => {
@@ -353,7 +354,7 @@ export = (socket: Socket) => {
cause,
removed,
]);
}
},
);
});
@@ -363,7 +364,7 @@ export = (socket: Socket) => {
electronSocket.emit(
"webContents-session-cookies-get-completed" + guid,
cookies
cookies,
);
});
@@ -381,9 +382,9 @@ export = (socket: Socket) => {
await browserWindow.webContents.session.cookies.remove(url, name);
electronSocket.emit(
"webContents-session-cookies-remove-completed" + guid
"webContents-session-cookies-remove-completed" + guid,
);
}
},
);
socket.on("webContents-session-cookies-flushStore", async (id, guid) => {
@@ -391,7 +392,7 @@ export = (socket: Socket) => {
await browserWindow.webContents.session.cookies.flushStore();
electronSocket.emit(
"webContents-session-cookies-flushStore-completed" + guid
"webContents-session-cookies-flushStore-completed" + guid,
);
});
@@ -441,7 +442,7 @@ export = (socket: Socket) => {
electronSocket.emit(
"webContents-session-getAllExtensions-completed",
chromeExtensionInfo
chromeExtensionInfo,
);
});
@@ -456,87 +457,108 @@ export = (socket: Socket) => {
const browserWindow = getWindowById(id);
const extension = await browserWindow.webContents.session.loadExtension(
path,
{ allowFileAccess: allowFileAccess }
{ allowFileAccess: allowFileAccess },
);
electronSocket.emit(
"webContents-session-loadExtension-completed",
extension
extension,
);
}
},
);
socket.on('webContents-getZoomFactor', (id) => {
const browserWindow = getWindowById(id);
const text = browserWindow.webContents.getZoomFactor();
electronSocket.emit('webContents-getZoomFactor-completed', text);
});
socket.on("webContents-getZoomFactor", (id) => {
const browserWindow = getWindowById(id);
const text = browserWindow.webContents.getZoomFactor();
electronSocket.emit("webContents-getZoomFactor-completed", text);
});
socket.on('webContents-setZoomFactor', (id, factor) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.setZoomFactor(factor);
});
socket.on("webContents-setZoomFactor", (id, factor) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.setZoomFactor(factor);
});
socket.on('webContents-getZoomLevel', (id) => {
const browserWindow = getWindowById(id);
const content = browserWindow.webContents.getZoomLevel();
electronSocket.emit('webContents-getZoomLevel-completed', content);
});
socket.on("webContents-getZoomLevel", (id) => {
const browserWindow = getWindowById(id);
const content = browserWindow.webContents.getZoomLevel();
electronSocket.emit("webContents-getZoomLevel-completed", content);
});
socket.on('webContents-setZoomLevel', (id, level) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.setZoomLevel(level);
});
socket.on("webContents-setZoomLevel", (id, level) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.setZoomLevel(level);
});
socket.on('webContents-setVisualZoomLevelLimits', async (id, minimumLevel, maximumLevel) => {
const browserWindow = getWindowById(id);
await browserWindow.webContents.setVisualZoomLevelLimits(minimumLevel, maximumLevel);
electronSocket.emit('webContents-setVisualZoomLevelLimits-completed');
});
socket.on(
"webContents-setVisualZoomLevelLimits",
async (id, minimumLevel, maximumLevel) => {
const browserWindow = getWindowById(id);
await browserWindow.webContents.setVisualZoomLevelLimits(
minimumLevel,
maximumLevel,
);
electronSocket.emit("webContents-setVisualZoomLevelLimits-completed");
},
);
socket.on("webContents-toggleDevTools", (id) => {
getWindowById(id).webContents.toggleDevTools();
});
socket.on("webContents-toggleDevTools", (id) => {
getWindowById(id).webContents.toggleDevTools();
});
socket.on("webContents-closeDevTools", (id) => {
getWindowById(id).webContents.closeDevTools();
});
socket.on("webContents-closeDevTools", (id) => {
getWindowById(id).webContents.closeDevTools();
});
socket.on("webContents-isDevToolsOpened", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isDevToolsOpened-completed', browserWindow.webContents.isDevToolsOpened());
});
socket.on("webContents-isDevToolsOpened", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit(
"webContents-isDevToolsOpened-completed",
browserWindow.webContents.isDevToolsOpened(),
);
});
socket.on("webContents-isDevToolsFocused", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isDevToolsFocused-completed', browserWindow.webContents.isDevToolsFocused());
});
socket.on("webContents-isDevToolsFocused", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit(
"webContents-isDevToolsFocused-completed",
browserWindow.webContents.isDevToolsFocused(),
);
});
socket.on("webContents-setAudioMuted", (id, muted) => {
getWindowById(id).webContents.setAudioMuted(muted);
});
socket.on("webContents-setAudioMuted", (id, muted) => {
getWindowById(id).webContents.setAudioMuted(muted);
});
socket.on("webContents-isAudioMuted", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isAudioMuted-completed', browserWindow.webContents.isAudioMuted());
});
socket.on("webContents-isAudioMuted", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit(
"webContents-isAudioMuted-completed",
browserWindow.webContents.isAudioMuted(),
);
});
socket.on("webContents-isCurrentlyAudible", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isCurrentlyAudible-completed', browserWindow.webContents.isCurrentlyAudible());
});
socket.on("webContents-isCurrentlyAudible", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit(
"webContents-isCurrentlyAudible-completed",
browserWindow.webContents.isCurrentlyAudible(),
);
});
socket.on("webContents-getUserAgent", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-getUserAgent-completed', browserWindow.webContents.getUserAgent());
});
socket.on("webContents-getUserAgent", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit(
"webContents-getUserAgent-completed",
browserWindow.webContents.getUserAgent(),
);
});
socket.on("webContents-setUserAgent", (id, userAgent) => {
getWindowById(id).webContents.setUserAgent(userAgent);
});
socket.on("webContents-setUserAgent", (id, userAgent) => {
getWindowById(id).webContents.setUserAgent(userAgent);
});
function getWindowById(
id: number
function getWindowById(
id: number,
): Electron.BrowserWindow | Electron.BrowserView {
if (id >= 1000) {
return browserViewMediateService(id - 1000);

View File

@@ -5,14 +5,13 @@ const path = require('path');
const cProcess = require('child_process').spawn;
const portscanner = require('portscanner');
const { imageSize } = require('image-size');
const { HookService } = require('electron-host-hook');
let io, server, browserWindows, ipc, apiProcess, loadURL;
let appApi, menu, dialogApi, notification, tray, webContents;
let globalShortcut, shellApi, screen, clipboard, autoUpdater;
let commandLine, browserView;
let powerMonitor;
let processInfo;
let splashScreen, hostHook;
let splashScreen;
let nativeTheme;
let dock;
let launchFile;
@@ -94,7 +93,7 @@ app.on('will-finish-launching', () => {
const manifestJsonFile = require(manifestJsonFilePath);
if (manifestJsonFile.singleInstance === "yes") {
if (manifestJsonFile.singleInstance) {
const mainInstance = app.requestSingleInstanceLock();
app.on('second-instance', (events, args = []) => {
args.forEach((parameter) => {
@@ -263,6 +262,7 @@ function startSocketApiBridge(port) {
console.log('Electron Socket: starting...');
server = require('http').createServer();
const { Server } = require('socket.io');
let hostHook;
io = new Server({
pingTimeout: 60000, // in ms, default is 5000
pingInterval: 10000, // in ms, default is 25000
@@ -359,6 +359,8 @@ function startSocketApiBridge(port) {
});
try {
const { HookService } = require('electron-host-hook');
if (hostHook === undefined) {
hostHook = new HookService(socket, app);
hostHook.onHostReady();
@@ -366,6 +368,7 @@ function startSocketApiBridge(port) {
} catch (error) {
console.error(error.message);
}
console.log('Electron Socket: startup complete.');
});
}
@@ -373,7 +376,7 @@ function startSocketApiBridge(port) {
function startAspCoreBackend(electronPort) {
startBackend();
function startBackend() {
function startBackend() {
loadURL = `about:blank`;
const envParam = getEnvironmentParameter();
const parameters = [

View File

@@ -57,9 +57,9 @@
}
},
"node_modules/@eslint-community/eslint-utils": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz",
"integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==",
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz",
"integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -140,9 +140,9 @@
}
},
"node_modules/@eslint/eslintrc": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz",
"integrity": "sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==",
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.3.tgz",
"integrity": "sha512-Kr+LPIUVKz2qkx1HAMH8q1q6azbqBAsXJUxBl/ODDuVPX45Z9DfwB8tPjTi6nNZ8BuM3nbJxC5zCAg5elnBUTQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -152,7 +152,7 @@
"globals": "^14.0.0",
"ignore": "^5.2.0",
"import-fresh": "^3.2.1",
"js-yaml": "^4.1.0",
"js-yaml": "^4.1.1",
"minimatch": "^3.1.2",
"strip-json-comments": "^3.1.1"
},
@@ -164,9 +164,9 @@
}
},
"node_modules/@eslint/js": {
"version": "9.39.1",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.1.tgz",
"integrity": "sha512-S26Stp4zCy88tH94QbBv3XCuzRQiZ9yXofEILmglYTh/Ug/a9/umqvgFtYBAo3Lp0nsI/5/qH1CCrbdK3AP1Tw==",
"version": "9.39.2",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.2.tgz",
"integrity": "sha512-q1mjIoW1VX4IvSocvM/vbTiveKC4k9eLrajNEuSsmjymSDEbpGddtpfOoN7YGAqBK3NG+uqo8ia4PDTt8buCYA==",
"dev": true,
"license": "MIT",
"engines": {
@@ -314,9 +314,9 @@
"license": "MIT"
},
"node_modules/@types/http-cache-semantics": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz",
"integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz",
"integrity": "sha512-L3LgimLHXtGkWikKnsPg0/VFx9OGZaC+eN1u4r+OB1XRqH3meBIAVC2zr1WdMH+RHmnRkqliQAOHNJ/E0j/e0Q==",
"dev": true,
"license": "MIT"
},
@@ -338,9 +338,9 @@
}
},
"node_modules/@types/node": {
"version": "22.19.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.1.tgz",
"integrity": "sha512-LCCV0HdSZZZb34qifBsyWlUmok6W7ouER+oQIGBScS8EsZsQbrtFTUrDX4hOl+CS6p7cnNC4td+qrSVGSCTUfQ==",
"version": "22.19.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.8.tgz",
"integrity": "sha512-ebO/Yl+EAvVe8DnMfi+iaAyIqYdK0q/q0y0rw82INWEKJOBe6b/P3YWE8NW7oOlF/nXFNrHwhARrN/hdgDkraA==",
"license": "MIT",
"dependencies": {
"undici-types": "~6.21.0"
@@ -498,9 +498,9 @@
}
},
"node_modules/builder-util-runtime": {
"version": "9.3.1",
"resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.3.1.tgz",
"integrity": "sha512-2/egrNDDnRaxVwK3A+cJq6UOlqOdedGA7JPqCeJjN2Zjk1/QB/6QUi3b714ScIGS7HafFXTyzJEOr5b44I3kvQ==",
"version": "9.5.1",
"resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.5.1.tgz",
"integrity": "sha512-qt41tMfgHTllhResqM5DcnHyDIWNgzHvuY2jDcYP9iaGpkWxTUzV6GQjDeLnlR1/DtdlcsWQbA7sByMpmJFTLQ==",
"license": "MIT",
"dependencies": {
"debug": "^4.3.4",
@@ -616,9 +616,9 @@
}
},
"node_modules/cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"version": "2.8.6",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz",
"integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==",
"license": "MIT",
"dependencies": {
"object-assign": "^4",
@@ -626,6 +626,10 @@
},
"engines": {
"node": ">= 0.10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/cross-spawn": {
@@ -782,18 +786,18 @@
"link": true
},
"node_modules/electron-updater": {
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.6.2.tgz",
"integrity": "sha512-Cr4GDOkbAUqRHP5/oeOmH/L2Bn6+FQPxVLZtPbcmKZC63a1F3uu5EefYOssgZXG3u/zBlubbJ5PJdITdMVggbw==",
"version": "6.7.3",
"resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.7.3.tgz",
"integrity": "sha512-EgkT8Z9noqXKbwc3u5FkJA+r48jwZ5DTUiOkJMOTEEH//n5Am6wfQGz7nvSFEA2oIAMv9jRzn5JKTyWeSKOPgg==",
"license": "MIT",
"dependencies": {
"builder-util-runtime": "9.3.1",
"builder-util-runtime": "9.5.1",
"fs-extra": "^10.1.0",
"js-yaml": "^4.1.0",
"lazy-val": "^1.0.5",
"lodash.escaperegexp": "^4.1.2",
"lodash.isequal": "^4.5.0",
"semver": "^7.6.3",
"semver": "~7.7.3",
"tiny-typed-emitter": "^2.1.0"
}
},
@@ -845,9 +849,9 @@
}
},
"node_modules/electron/node_modules/@types/node": {
"version": "20.19.25",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.25.tgz",
"integrity": "sha512-ZsJzA5thDQMSQO788d7IocwwQbI8B5OPzmqNvpf3NY/+MHDAS759Wo0gd2WQeXYt5AAAQjzcrTVC6SKCuYgoCQ==",
"version": "20.19.31",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.31.tgz",
"integrity": "sha512-5jsi0wpncvTD33Sh1UCgacK37FFwDn+EG7wCmEvs62fCvBL+n8/76cAYDok21NF6+jaVWIqKwCZyX7Vbu8eB3A==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -865,9 +869,9 @@
}
},
"node_modules/engine.io": {
"version": "6.6.4",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.4.tgz",
"integrity": "sha512-ZCkIjSYNDyGn0R6ewHDtXgns/Zre/NT6Agvq1/WobF7JXgFff4SeDroKiCO3fNJreU9YG429Sc81o4w5ok/W5g==",
"version": "6.6.5",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.5.tgz",
"integrity": "sha512-2RZdgEbXmp5+dVbRm0P7HQUImZpICccJy7rN7Tv+SFa55pH+lxnuw6/K1ZxxBfHoYpSkHLAO92oa8O4SwFXA2A==",
"license": "MIT",
"dependencies": {
"@types/cors": "^2.8.12",
@@ -876,9 +880,9 @@
"base64id": "2.0.0",
"cookie": "~0.7.2",
"cors": "~2.8.5",
"debug": "~4.3.1",
"debug": "~4.4.1",
"engine.io-parser": "~5.2.1",
"ws": "~8.17.1"
"ws": "~8.18.3"
},
"engines": {
"node": ">=10.2.0"
@@ -893,23 +897,6 @@
"node": ">=10.0.0"
}
},
"node_modules/engine.io/node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/env-paths": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
@@ -964,9 +951,9 @@
}
},
"node_modules/eslint": {
"version": "9.39.1",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.1.tgz",
"integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==",
"version": "9.39.2",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.2.tgz",
"integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -976,7 +963,7 @@
"@eslint/config-helpers": "^0.4.2",
"@eslint/core": "^0.17.0",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "9.39.1",
"@eslint/js": "9.39.2",
"@eslint/plugin-kit": "^0.4.1",
"@humanfs/node": "^0.16.6",
"@humanwhocodes/module-importer": "^1.0.1",
@@ -1072,9 +1059,9 @@
}
},
"node_modules/esquery": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz",
"integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==",
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz",
"integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
@@ -1614,9 +1601,9 @@
}
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"version": "4.17.23",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
"license": "MIT"
},
"node_modules/lodash.escaperegexp": {
@@ -2005,10 +1992,13 @@
}
},
"node_modules/sax": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.4.3.tgz",
"integrity": "sha512-yqYn1JhPczigF94DMS+shiDMjDowYO6y9+wB/4WgO0Y19jWYk0lQ4tuG5KI7kj4FTp1wxPj5IFfcrz/s1c3jjQ==",
"license": "BlueOak-1.0.0"
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.4.4.tgz",
"integrity": "sha512-1n3r/tGXO6b6VXMdFT54SHzT9ytu9yr7TaELowdYpMqY/Ao7EnlQGmAQ1+RatX7Tkkdm6hONI2owqNx2aZj5Sw==",
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=11.0.0"
}
},
"node_modules/semver": {
"version": "6.3.1",
@@ -2069,15 +2059,15 @@
}
},
"node_modules/socket.io": {
"version": "4.8.1",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.1.tgz",
"integrity": "sha512-oZ7iUCxph8WYRHHcjBEc9unw3adt5CmSNlppj/5Q4k2RIrhl8Z5yY2Xr4j9zj0+wzVZ0bxmYoGSzKJnRl6A4yg==",
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.3.tgz",
"integrity": "sha512-2Dd78bqzzjE6KPkD5fHZmDAKRNe3J15q+YHDrIsy9WEkqttc7GY+kT9OBLSMaPbQaEd0x1BjcmtMtXkfpc+T5A==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.4",
"base64id": "~2.0.0",
"cors": "~2.8.5",
"debug": "~4.3.2",
"debug": "~4.4.1",
"engine.io": "~6.6.0",
"socket.io-adapter": "~2.5.2",
"socket.io-parser": "~4.2.4"
@@ -2087,79 +2077,28 @@
}
},
"node_modules/socket.io-adapter": {
"version": "2.5.5",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.5.tgz",
"integrity": "sha512-eLDQas5dzPgOWCk9GuuJC2lBqItuhKI4uxGgo9aIV7MYbk2h9Q6uULEh8WBzThoI7l+qU9Ast9fVUmkqPP9wYg==",
"version": "2.5.6",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.6.tgz",
"integrity": "sha512-DkkO/dz7MGln0dHn5bmN3pPy+JmywNICWrJqVWiVOyvXjWQFIv9c2h24JrQLLFJ2aQVQf/Cvl1vblnd4r2apLQ==",
"license": "MIT",
"dependencies": {
"debug": "~4.3.4",
"ws": "~8.17.1"
}
},
"node_modules/socket.io-adapter/node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
"debug": "~4.4.1",
"ws": "~8.18.3"
}
},
"node_modules/socket.io-parser": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz",
"integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==",
"version": "4.2.5",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.5.tgz",
"integrity": "sha512-bPMmpy/5WWKHea5Y/jYAP6k74A+hvmRCQaJuJB6I/ML5JZq/KfNieUVo/3Mh7SAqn7TyFdIo6wqYHInG1MU1bQ==",
"license": "MIT",
"dependencies": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.1"
"debug": "~4.4.1"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/socket.io-parser/node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/socket.io/node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/sprintf-js": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
@@ -2323,9 +2262,9 @@
"license": "ISC"
},
"node_modules/ws": {
"version": "8.17.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
"version": "8.18.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"

View File

@@ -257,5 +257,57 @@ namespace ElectronNET.IntegrationTests.Tests
win.SetDocumentEdited(false);
}
[IntegrationFact]
public async Task BoundsChanged_event_fires_with_updated_bounds()
{
BrowserWindow window = null;
try
{
window = await Electron.WindowManager.CreateWindowAsync(
new BrowserWindowOptions { Show = false, Width = 300, Height = 200 },
"about:blank");
var tcs = new TaskCompletionSource<Rectangle>(TaskCreationOptions.RunContinuationsAsynchronously);
window.OnBoundsChanged += bounds => tcs.TrySetResult(bounds);
await Task.Delay(500.ms());
var target = new Rectangle { X = 25, Y = 35, Width = 420, Height = 310 };
window.SetBounds(target);
var completed = await Task.WhenAny(tcs.Task, Task.Delay(3.seconds()));
completed.Should().Be(tcs.Task);
var observed = await tcs.Task;
observed.Width.Should().Be(target.Width);
observed.Height.Should().Be(target.Height);
}
finally
{
window?.Destroy();
}
}
[IntegrationFact]
public async Task BoundsChanged_event_can_fire_on_resize_of_existing_window()
{
var win = this.MainWindow;
var tcs = new TaskCompletionSource<Rectangle>(TaskCreationOptions.RunContinuationsAsynchronously);
win.OnBoundsChanged += bounds => tcs.TrySetResult(bounds);
await Task.Delay(500.ms());
win.SetBounds(new Rectangle { X = 10, Y = 10, Width = 560, Height = 440 });
var completed = await Task.WhenAny(tcs.Task, Task.Delay(3.seconds()));
completed.Should().Be(tcs.Task);
var boundsObserved = await tcs.Task;
boundsObserved.Width.Should().Be(560);
boundsObserved.Height.Should().Be(440);
}
}
}

View File

@@ -27,8 +27,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ElectronNET.Core" Version="0.2.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
<PackageReference Include="ElectronNET.Core.AspNet" Version="0.2.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
<PackageReference Include="ElectronNET.Core" Version="0.4.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
<PackageReference Include="ElectronNET.Core.AspNet" Version="0.4.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.9.3" />
</ItemGroup>

View File

@@ -76,8 +76,8 @@
<ProjectReference Include="..\ElectronNET.AspNet\ElectronNET.AspNet.csproj" Condition="$(ElectronNetDevMode)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ElectronNET.Core" Version="0.3.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
<PackageReference Include="ElectronNET.Core.AspNet" Version="0.3.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
<PackageReference Include="ElectronNET.Core" Version="0.4.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
<PackageReference Include="ElectronNET.Core.AspNet" Version="0.4.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.9.3" />
</ItemGroup>

View File

@@ -9,7 +9,7 @@
<ElectronSplashScreen></ElectronSplashScreen>
<ElectronIcon></ElectronIcon>
<PackageIcon></PackageIcon>
<PackageId>$(MSBuildProjectName.Replace(".", "-").ToLower())</PackageId>
<ElectronPackageId>$(MSBuildProjectName.Replace(".", "-").ToLower())</ElectronPackageId>
<ElectronBuilderJson>electron-builder.json</ElectronBuilderJson>
<Title>$(MSBuildProjectName)</Title>
</PropertyGroup>

View File

@@ -4,7 +4,7 @@
<PropertyGroup Condition="'$(ElectronExecutable)' == ''">
<WinPrefix>win</WinPrefix>
<ElectronExecutable Condition="'$(RuntimeIdentifier.StartsWith($(WinPrefix)))' == 'true'">$(Title)</ElectronExecutable>
<ElectronExecutable Condition="'$(RuntimeIdentifier.StartsWith($(WinPrefix)))' != 'true'">$(PackageId)</ElectronExecutable>
<ElectronExecutable Condition="'$(RuntimeIdentifier.StartsWith($(WinPrefix)))' != 'true'">$(ElectronPackageId)</ElectronExecutable>
</PropertyGroup>
<PropertyGroup>
@@ -12,6 +12,10 @@
<_IsMsAspNetProject Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true'">True</_IsMsAspNetProject>
</PropertyGroup>
<PropertyGroup>
<PackageId Condition="'$(PackageId)' == ''">$(ElectronPackageId)</PackageId>
</PropertyGroup>
<ItemGroup>
<AssemblyMetadata Include="ElectronExecutable" Value="$(ElectronExecutable)" />
<AssemblyMetadata Include="ElectronVersion" Value="$(ElectronVersion)" />

View File

@@ -124,7 +124,7 @@
</PropertyGroup>
<ItemGroup>
<TemplateProperty Include="PackageId" Value="$(PackageId)" />
<TemplateProperty Include="ElectronPackageId" Value="$(ElectronPackageId)" />
<TemplateProperty Include="Title" Value="$(Title)" />
<TemplateProperty Include="ElectronTitle" Value="$(ElectronTitle)" />
<TemplateProperty Include="Version" Value="$(Version)" />
@@ -135,7 +135,7 @@
<TemplateProperty Include="ElectronSplashScreen" Value="$(ElectronSplashScreenFileName)" />
<TemplateProperty Include="ElectronVersion" Value="$(ElectronVersion)" />
<TemplateProperty Include="TargetName" Value="$(ElectronTargetName)" />
<TemplateProperty Include="ElectronSingleInstance" Value="$(ElectronSingleInstance)" />
<TemplateProperty Include="ElectronSingleInstance" Value="$(ElectronSingleInstance.ToLower())" />
</ItemGroup>
<MakeDir Directories="$(ElectronIntermediateOutputPath)" />
@@ -297,12 +297,58 @@
<RemoveDir Directories="$(ElectronHookTargetModuleDir)" Condition="Exists($(ElectronHookTargetModuleDir))" />
</Target>
<Target Name="ElectronCheckVersionMismatch">
<PropertyGroup>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'win-x64'">x64</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'win-x86'">ia32</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'win-arm64'">arm64</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'linux-x64'">x64</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'linux-arm'">armv7l</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">arm64</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'osx-x64'">x64</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'osx-arm64'">arm64</ElectronArch>
<ElectronPlatform Condition="'$(RuntimeIdentifier)' == 'win-x64' OR '$(RuntimeIdentifier)' == 'win-x86' OR '$(RuntimeIdentifier)' == 'win-arm64'">win</ElectronPlatform>
<ElectronPlatform Condition="'$(RuntimeIdentifier)' == 'linux-x64' OR '$(RuntimeIdentifier)' == 'linux-arm' OR '$(RuntimeIdentifier)' == 'linux-arm64'">linux</ElectronPlatform>
<ElectronPlatform Condition="'$(RuntimeIdentifier)' == 'osx-x64' OR '$(RuntimeIdentifier)' == 'osx-arm64'">mac</ElectronPlatform>
<!-- npm uses different OS names than Electron -->
<NpmOs Condition="'$(ElectronPlatform)' == 'win'">win32</NpmOs>
<NpmOs Condition="'$(ElectronPlatform)' == 'linux'">linux</NpmOs>
<NpmOs Condition="'$(ElectronPlatform)' == 'mac'">darwin</NpmOs>
<!-- npm CPU is same as ElectronArch except for linux-arm -->
<NpmCpu>$(ElectronArch)</NpmCpu>
<NpmCpu Condition="'$(RuntimeIdentifier)' == 'linux-arm'">arm</NpmCpu>
<_CurrentOSPlatform Condition="$([MSBuild]::IsOSPlatform('Windows'))">win</_CurrentOSPlatform>
<_CurrentOSPlatform Condition="$([MSBuild]::IsOSPlatform('Linux'))">linux</_CurrentOSPlatform>
<_CurrentOSPlatform Condition="$([MSBuild]::IsOSPlatform('OSX'))">mac</_CurrentOSPlatform>
</PropertyGroup>
<!-- Validate that the target platform matches the current OS -->
<PropertyGroup>
<IsLinuxWsl>false</IsLinuxWsl>
<IsLinuxWsl Condition="'$(ElectronPlatform)' == 'linux' AND '$(_CurrentOSPlatform)' == 'win'">true</IsLinuxWsl>
<_IsCrossCompileAllowed>false</_IsCrossCompileAllowed>
<!-- Allow Linux builds on Windows via WSL -->
<_IsCrossCompileAllowed Condition="'$(_CurrentOSPlatform)' == 'win' AND '$(ElectronPlatform)' == 'linux' AND '$(IsLinuxWsl)' == 'true'">true</_IsCrossCompileAllowed>
<_IsPlatformMismatch>false</_IsPlatformMismatch>
<_IsPlatformMismatch Condition="'$(_CurrentOSPlatform)' != '$(ElectronPlatform)' AND '$(_IsCrossCompileAllowed)' != 'true'">true</_IsPlatformMismatch>
</PropertyGroup>
</Target>
<Target Name="ElectronConfigureApp"
Inputs="@(ElectronPackageJsonFiles)"
Outputs="@(ElectronPackageJsonFiles->'$(OutDir)%(TargetPath)')"
AfterTargets="CopyFilesToOutputDirectory"
DependsOnTargets="ElectronResetHostHook"
DependsOnTargets="ElectronResetHostHook;ElectronCheckVersionMismatch"
>
<Copy SourceFiles="@(ElectronPackageJsonFiles)" DestinationFiles="@(ElectronPackageJsonFiles->'$(OutDir)%(TargetPath)')" >
@@ -316,10 +362,9 @@
<PropertyGroup>
<ElectronOutputPath>$([System.IO.Path]::GetFullPath('$(ElectronOutDir)'))</ElectronOutputPath>
<LinuxPrefix>linux</LinuxPrefix>
<IsLinuxWsl>false</IsLinuxWsl>
<IsLinuxWsl Condition="'$(RuntimeIdentifier.StartsWith($(LinuxPrefix)))' == 'true'AND $([MSBuild]::IsOSPlatform('Windows'))">true</IsLinuxWsl>
<_NpmCmd>npm install --no-bin-links</_NpmCmd>
<!-- Add cross-platform parameters when there's a platform mismatch (for remote debugging preparation) -->
<_NpmCmd Condition="'$(_IsPlatformMismatch)' == 'true'">$(_NpmCmd) --os=$(NpmOs) --cpu=$(NpmCpu) --arch=$(NpmCpu) --platform=$(NpmOs)</_NpmCmd>
<_NpmCmd Condition="'$(IsLinuxWsl)' == 'true'">wsl bash -ic '$(_NpmCmd)'</_NpmCmd>
</PropertyGroup>
@@ -335,6 +380,23 @@
<Message Importance="High" Text="Electron setup failed!" Condition="'$(ExecExitCode)' != '0'" />
<!-- Fix up incorrect symlinks created by npm on Windows when targeting macOS -->
<PropertyGroup>
<_ElectronFrameworksDir>$(ElectronOutDir)node_modules\electron\dist\Electron.app\Contents\Frameworks</_ElectronFrameworksDir>
</PropertyGroup>
<ItemGroup>
<_ElectronFrameworkDirs Include="$(_ElectronFrameworksDir)\Electron Framework.framework" />
<_ElectronFrameworkDirs Include="$(_ElectronFrameworksDir)\Mantle.framework" />
<_ElectronFrameworkDirs Include="$(_ElectronFrameworksDir)\ReactiveObjC.framework" />
<_ElectronFrameworkDirs Include="$(_ElectronFrameworksDir)\Squirrel.framework" />
</ItemGroup>
<!-- Only execute on Windows host when targeting macOS -->
<Message Importance="High" Text="Fixing macOS framework Resources symlinks" Condition="'$(ElectronPlatform)' == 'mac' AND '$(_CurrentOSPlatform)' == 'win'" />
<Exec Command="cmd /c del Resources &amp;&amp; mklink /D Resources &quot;Versions\Current\Resources&quot;" WorkingDirectory="%(_ElectronFrameworkDirs.Identity)" Condition="'$(ElectronPlatform)' == 'mac' AND '$(_CurrentOSPlatform)' == 'win'" />
</Target>
<Target Name="BeforePublishElectronApp" BeforeTargets="PrepareForPublish">
@@ -367,7 +429,7 @@
<_ElectronPublishAppAfterTarget Condition="'$(UsingMicrosoftNETSdkWeb)' != 'true'">Publish</_ElectronPublishAppAfterTarget>
</PropertyGroup>
<Target Name="ElectronPublishApp" AfterTargets="$(_ElectronPublishAppAfterTarget)">
<Target Name="ElectronPublishApp" AfterTargets="$(_ElectronPublishAppAfterTarget)" DependsOnTargets="ElectronCheckVersionMismatch">
<PropertyGroup>
<PublishDir>$(_OriginalPublishDir)</PublishDir>
@@ -376,21 +438,18 @@
</PropertyGroup>
<PropertyGroup>
<!-- Default values -->
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'win-x64'">x64</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'win-x86'">ia32</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'win-arm64'">arm64</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'linux-x64'">x64</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'linux-arm'">armv7l</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">arm64</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'osx-x64'">x64</ElectronArch>
<ElectronArch Condition="'$(RuntimeIdentifier)' == 'osx-arm64'">arm64</ElectronArch>
<Error Condition="'$(_IsPlatformMismatch)' == 'true'"
Code="ELECTRON100"
Text="The target RuntimeIdentifier '$(RuntimeIdentifier)' (platform: $(ElectronPlatform)) does not match the current operating system ($(_CurrentOSPlatform)).
<ElectronPlatform Condition="'$(RuntimeIdentifier)' == 'win-x64' OR '$(RuntimeIdentifier)' == 'win-x86' OR '$(RuntimeIdentifier)' == 'win-arm64'">win</ElectronPlatform>
<ElectronPlatform Condition="'$(RuntimeIdentifier)' == 'linux-x64' OR '$(RuntimeIdentifier)' == 'linux-arm' OR '$(RuntimeIdentifier)' == 'linux-arm64'">linux</ElectronPlatform>
<ElectronPlatform Condition="'$(RuntimeIdentifier)' == 'osx-x64' OR '$(RuntimeIdentifier)' == 'osx-arm64'">mac</ElectronPlatform>
</PropertyGroup>
Electron applications must be built on the target operating system:
- Windows targets (win-x64, win-x86, win-arm64) must be built on Windows
- Linux targets (linux-x64, linux-arm, linux-arm64) must be built on Linux (or Windows with WSL)
- macOS targets (osx-x64, osx-arm64) must be built on macOS
EXCEPTION: Linux targets can be built on Windows using WSL (Windows Subsystem for Linux).
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#8-cross-platform-build-validation" />
<RemoveEnvironmentVariables Variables="BUILD_BUILDNUMBER;BUILD_NUMBER;TRAVIS_BUILD_NUMBER;APPVEYOR_BUILD_NUMBER;CIRCLE_BUILD_NUM;CI_PIPELINE_IID" />
@@ -452,7 +511,7 @@
<PropertyGroup>
<ElectronPaParams></ElectronPaParams>
<ElectronPaParams Condition="'$(PackageId)' != ''">$(ElectronPaParams) -c.appId &quot;$(PackageId)&quot;</ElectronPaParams>
<ElectronPaParams Condition="'$(ElectronPackageId)' != ''">$(ElectronPaParams) -c.appId &quot;$(ElectronPackageId)&quot;</ElectronPaParams>
<ElectronPaParams Condition="'$(Version)' != ''">$(ElectronPaParams) -c.buildVersion &quot;$(Version)&quot;</ElectronPaParams>
<ElectronPaParams Condition="'$(Copyright)' != ''">$(ElectronPaParams) -c.copyright &quot;$(Copyright)&quot;</ElectronPaParams>
<ElectronPaParams>$(ElectronPaParams) -c.extraResources &quot;bin/**/*&quot;</ElectronPaParams>
@@ -463,7 +522,7 @@
<_NpxCmd Condition="'$(IsLinuxWsl)' == 'true'">wsl bash -ic '$(_NpxCmd)'</_NpxCmd>
</PropertyGroup>
<Exec Command="$(_NpxCmd)" WorkingDirectory="$(ElectronPublishDirFullPath)" Timeout="900000" StandardOutputImportance="High" StandardErrorImportance="High" ContinueOnError="false" Condition="@(CopiedFiles->Count()) > 0">
<Exec Command="$(_NpxCmd)" WorkingDirectory="$(ElectronPublishDirFullPath)" Timeout="1800000" StandardOutputImportance="High" StandardErrorImportance="High" ContinueOnError="false" Condition="@(CopiedFiles->Count()) > 0">
<Output TaskParameter="ExitCode" PropertyName="ExecExitCode"/>
</Exec>

View File

@@ -4,6 +4,8 @@
<PropertyGroup>
<ElectronMigrationChecksDependsOn>
ElectronCheckNoPackageJson;
ElectronCheckRootPackageJsonNoElectron;
ElectronCheckRootPackageJsonNotCopied;
ElectronCheckNoManifestJson;
ElectronCheckElectronBuilderJson;
ElectronCheckNoParentPaths;
@@ -19,14 +21,17 @@
</Target>
<!--
Check 1: No package.json must be present in the project (except ElectronHostHook folder)
Check 1: No package.json/package-lock.json must be present in the project (except ElectronHostHook folder)
NOTE: Root package.json is excluded from ELECTRON001 and checked by separate targets.
-->
<Target Name="ElectronCheckNoPackageJson">
<!-- Find all package.json files, excluding ElectronHostHook folder and output directories -->
<!-- Find all package.json files, excluding ElectronHostHook folder, root, and output directories -->
<ItemGroup>
<_InvalidPackageJson Include="$(MSBuildProjectDirectory)\**\package.json"
Exclude="$(MSBuildProjectDirectory)\ElectronHostHook\**\package.json;
Exclude="$(MSBuildProjectDirectory)\package.json;
$(MSBuildProjectDirectory)\ElectronHostHook\**\package.json;
$(MSBuildProjectDirectory)\bin\**\package.json;
$(MSBuildProjectDirectory)\obj\**\package.json;
$(MSBuildProjectDirectory)\publish\**\package.json;
@@ -46,17 +51,87 @@
<Warning Condition="'$(_HasInvalidPackageJson)' == 'true'"
Code="ELECTRON001"
Text="Found package.json or package-lock.json file(s) in the project root or subdirectories. These files are no longer supported in this location.
Text="Found package.json or package-lock.json file(s) in unsupported location(s). These files are no longer supported in this location.
Files found:
@(_InvalidPackageJson, '%0A')@(_InvalidPackageLockJson, '%0A')
MIGRATION REQUIRED:
All properties from an existing package.json file must now be specified as MSBuild properties in the project file.
All Electron.NET-related properties from an existing package.json must now be specified as MSBuild properties in the project file.
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#1-packagejson-not-allowed
EXCEPTION: package.json and package-lock.json files ARE allowed in the 'ElectronHostHook' folder for custom host hook implementations." />
EXCEPTION:
- package.json and package-lock.json files ARE allowed in the 'ElectronHostHook' folder for custom host hook implementations.
- A package.json in the project root is handled by separate migration checks." />
</Target>
<!--
Check 1b: Root package.json must not contain Electron-related configuration
-->
<Target Name="ElectronCheckRootPackageJsonNoElectron"
Condition="Exists('$(MSBuildProjectDirectory)\package.json')">
<ItemGroup>
<_RootPackageJsonLines Include="$([System.IO.File]::ReadAllLines('$(MSBuildProjectDirectory)\package.json'))" />
</ItemGroup>
<PropertyGroup>
<_RootPackageJsonContent>@(_RootPackageJsonLines, ' ')</_RootPackageJsonContent>
<_RootPackageJsonHasElectron>false</_RootPackageJsonHasElectron>
<_RootPackageJsonHasElectron Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('$(_RootPackageJsonContent)', 'electron', System.Text.RegularExpressions.RegexOptions.IgnoreCase))">true</_RootPackageJsonHasElectron>
</PropertyGroup>
<Warning
Condition="'$(_RootPackageJsonHasElectron)' == 'true'"
Code="ELECTRON008"
Text="The project contains a root package.json that references 'electron' (case-insensitive).
File:
$(MSBuildProjectDirectory)\package.json
MIGRATION REQUIRED:
Electron.NET configuration must be defined via MSBuild properties and electron-builder.json (not via a user-provided package.json).
HOW TO FIX:
- Remove Electron-related entries from the root package.json, or delete the file if it's only used for Electron configuration.
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#1-packagejson-not-allowed" />
</Target>
<!--
Check 1c: Root package.json must not be copied to output/publish
-->
<Target Name="ElectronCheckRootPackageJsonNotCopied"
Condition="Exists('$(MSBuildProjectDirectory)\package.json')">
<ItemGroup>
<_RootPackageJsonFile Include="@(Content);@(None)"
Condition="'%(Identity)' == 'package.json' OR '%(Identity)' == '$(MSBuildProjectDirectory)\package.json'" />
</ItemGroup>
<PropertyGroup>
<_RootPackageJsonIsCopied>false</_RootPackageJsonIsCopied>
<_RootPackageJsonIsCopied Condition="'@(_RootPackageJsonFile)' != '' AND ( '%(_RootPackageJsonFile.CopyToOutputDirectory)' != '' OR '%(_RootPackageJsonFile.CopyToPublishDirectory)' != '' )">true</_RootPackageJsonIsCopied>
</PropertyGroup>
<Warning
Condition="'$(_RootPackageJsonIsCopied)' == 'true'"
Code="ELECTRON009"
Text="The project contains a root package.json that is configured to be copied to the output/publish directory.
File:
$(MSBuildProjectDirectory)\package.json
MIGRATION REQUIRED:
Root package.json must not be copied during build/publish.
HOW TO FIX:
- Remove CopyToOutputDirectory / CopyToPublishDirectory metadata for package.json in your project file.
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#1-packagejson-not-allowed" />
</Target>

View File

@@ -479,7 +479,7 @@
Description="The version of the app, following the major.minor.patch pattern. Version numbers may include a pre-release suffix."
Category="AppInfo" />
<StringProperty Name="PackageId"
<StringProperty Name="ElectronPackageId"
DisplayName="App Identifier"
Category="AppInfo">
</StringProperty>

View File

@@ -1,13 +1,13 @@
{
"name": "$(PackageId)",
"name": "$(ElectronPackageId)",
"productName": "$(ElectronTitle)",
"build": {
"appId": "$(PackageId)",
"appId": "$(ElectronPackageId)",
"linux": {
"desktop": {
"entry": { "Name": "$(Title)" }
},
"executableName": "$(PackageId)"
"executableName": "$(ElectronPackageId)"
},
"deb": {
"desktop": {
@@ -23,7 +23,7 @@
},
"license": "$(License)",
"executable": "$(TargetName)",
"singleInstance": "$(ElectronSingleInstance)",
"singleInstance": $(ElectronSingleInstance),
"homepage": "$(ProjectUrl)",
"splashscreen": {
"imageFile": "$(ElectronSplashScreen)"

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.3.0</Version>
<Version>0.4.1</Version>
<PackageNamePrefix>ElectronNET.Core</PackageNamePrefix>
<Authors>Gregor Biswanger, Florian Rappl, softworkz</Authors>
<Product>Electron.NET</Product>