mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-04 05:34:51 +00:00
Compare commits
220 Commits
0.0.18-pre
...
0.3.0-pre.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70e8f85123 | ||
|
|
5a7cbd972f | ||
|
|
33da428c45 | ||
|
|
f1b4766360 | ||
|
|
e070759645 | ||
|
|
49eaa5e129 | ||
|
|
b3f5a3c52b | ||
|
|
0d732ce99e | ||
|
|
218b99808b | ||
|
|
7f507a6d86 | ||
|
|
81b3793966 | ||
|
|
1baa5c6200 | ||
|
|
5f76804065 | ||
|
|
70ffebf39d | ||
|
|
0a54735f35 | ||
|
|
1ac371b3da | ||
|
|
e854451043 | ||
|
|
331c2f548c | ||
|
|
b00adcbd38 | ||
|
|
ed6d24dbb1 | ||
|
|
2c82206c62 | ||
|
|
d0eb0880b1 | ||
|
|
0321804128 | ||
|
|
f548ff08d4 | ||
|
|
bbc7c79d5a | ||
|
|
2389ae32bd | ||
|
|
42fecbdc98 | ||
|
|
95e02e2655 | ||
|
|
153625ba51 | ||
|
|
c97f914e7a | ||
|
|
d95b41fbae | ||
|
|
2b2b26e13b | ||
|
|
9bb2adca78 | ||
|
|
88d2daacb1 | ||
|
|
c90f003519 | ||
|
|
daa9f399e9 | ||
|
|
6246b44d68 | ||
|
|
347c1ef0e4 | ||
|
|
7c8eeef225 | ||
|
|
44a820e285 | ||
|
|
8ccc7bfdd0 | ||
|
|
cf185fd2fb | ||
|
|
4ee11aaeae | ||
|
|
f1063bbe98 | ||
|
|
7c39d28f81 | ||
|
|
e52bf69dee | ||
|
|
46d395ad12 | ||
|
|
c0e3a595c3 | ||
|
|
65db66b4e9 | ||
|
|
ce8a86baf5 | ||
|
|
7eaf84a021 | ||
|
|
90f5f5dbe2 | ||
|
|
e09ef35be4 | ||
|
|
dae521180f | ||
|
|
c81ed54fff | ||
|
|
276ce8f4dc | ||
|
|
20212cdca7 | ||
|
|
0acdc65271 | ||
|
|
c92a54fbda | ||
|
|
4de7760556 | ||
|
|
3821ca60ea | ||
|
|
59887cce5f | ||
|
|
77834d0f2e | ||
|
|
6761119241 | ||
|
|
41d9f0afc7 | ||
|
|
1d554fda60 | ||
|
|
2f4d37d823 | ||
|
|
1815951092 | ||
|
|
aa483ebaa4 | ||
|
|
9b4e0e4504 | ||
|
|
d05191d1e2 | ||
|
|
ef41329a91 | ||
|
|
edafa8ccdb | ||
|
|
55c035323b | ||
|
|
2e5c6200a6 | ||
|
|
be518a7a10 | ||
|
|
9e9558b837 | ||
|
|
5f6e4a9e9d | ||
|
|
b89c08ee96 | ||
|
|
8ff875435b | ||
|
|
bfad0cd45a | ||
|
|
91ed116cb1 | ||
|
|
54eac4b521 | ||
|
|
ac05ded844 | ||
|
|
5434b0ec8e | ||
|
|
20acd31f1a | ||
|
|
f53d071bd9 | ||
|
|
2cf3095450 | ||
|
|
0ec791da9d | ||
|
|
0580942a59 | ||
|
|
8e8d88c48f | ||
|
|
61476e3ca4 | ||
|
|
9488576d8f | ||
|
|
ff1b802838 | ||
|
|
c98ad58290 | ||
|
|
a30239e3a6 | ||
|
|
17f24749cd | ||
|
|
7558037b91 | ||
|
|
e4485fd483 | ||
|
|
1a964b405e | ||
|
|
dfcb2345f3 | ||
|
|
3f10d6b5dd | ||
|
|
90c3eb2c88 | ||
|
|
dbf76a1d6d | ||
|
|
8e7892ebd4 | ||
|
|
30b547b8d3 | ||
|
|
30b4d92291 | ||
|
|
6c9027faf3 | ||
|
|
c712027ea3 | ||
|
|
7889057022 | ||
|
|
68c50f1c1e | ||
|
|
1006355bb7 | ||
|
|
12c5391164 | ||
|
|
8ba24c0f2f | ||
|
|
bb7ae8d711 | ||
|
|
385dcfbf52 | ||
|
|
515430ff96 | ||
|
|
a6d67a4dfe | ||
|
|
946b2af81a | ||
|
|
1e483e9cc4 | ||
|
|
5305e17ba9 | ||
|
|
442084a3e5 | ||
|
|
cd205edabb | ||
|
|
10bf461b51 | ||
|
|
5b0ab76d38 | ||
|
|
349762bd5e | ||
|
|
0b49467186 | ||
|
|
6fa65aa149 | ||
|
|
816e9c0fe9 | ||
|
|
c81b0e537f | ||
|
|
b89e3caa17 | ||
|
|
e8c5de63c9 | ||
|
|
d7b9174853 | ||
|
|
5ba4ab24d5 | ||
|
|
c6ff957d9a | ||
|
|
c37f98dcd6 | ||
|
|
0188051d6c | ||
|
|
3eb8507985 | ||
|
|
546668a2c0 | ||
|
|
68feffba02 | ||
|
|
12d2fcb484 | ||
|
|
979cf72d4c | ||
|
|
14bf7fdcd8 | ||
|
|
f89f2e7591 | ||
|
|
9a0a494bc5 | ||
|
|
41a2b075c9 | ||
|
|
adc1e81743 | ||
|
|
d8062aae00 | ||
|
|
0522bc425b | ||
|
|
168eceac8c | ||
|
|
4736bc640c | ||
|
|
18b1317fc5 | ||
|
|
dfe04f14d0 | ||
|
|
9d6861ffcd | ||
|
|
d8b0d0443d | ||
|
|
71ced8db56 | ||
|
|
fc69598b09 | ||
|
|
60a278c41f | ||
|
|
9d25795b7a | ||
|
|
5b597cc12c | ||
|
|
707c0f5a7b | ||
|
|
bb59bc8365 | ||
|
|
423ea57af7 | ||
|
|
8dcc3721eb | ||
|
|
dc27511aa5 | ||
|
|
dd465baebf | ||
|
|
04210955a3 | ||
|
|
4129cc17a6 | ||
|
|
bc0f601dd8 | ||
|
|
95fd7aa665 | ||
|
|
402147b8ef | ||
|
|
ed7cc434ea | ||
|
|
c5fb5f62d9 | ||
|
|
84989cda25 | ||
|
|
84b3c59353 | ||
|
|
c1e7b84ec6 | ||
|
|
9bb7dcfa62 | ||
|
|
c0e711940d | ||
|
|
d03458094b | ||
|
|
14962e1983 | ||
|
|
d79b73e960 | ||
|
|
21ae89bc70 | ||
|
|
7927a95cb8 | ||
|
|
758e6a41e3 | ||
|
|
61421ddd66 | ||
|
|
98d085f112 | ||
|
|
cf0b12ed0a | ||
|
|
4c3065c64b | ||
|
|
2a6d2117e9 | ||
|
|
93f457dd0f | ||
|
|
6001a3c481 | ||
|
|
4671b9b32a | ||
|
|
de7f98136e | ||
|
|
87668f5606 | ||
|
|
ea688026d0 | ||
|
|
b6b9292478 | ||
|
|
408f83e401 | ||
|
|
689a002dc2 | ||
|
|
f919289628 | ||
|
|
2c544a83e9 | ||
|
|
2b393079ae | ||
|
|
79d3d3f0b1 | ||
|
|
688d6d83cc | ||
|
|
7bcc5c9878 | ||
|
|
0cfadb36f5 | ||
|
|
568c785412 | ||
|
|
2944e69b21 | ||
|
|
8df9eff3bc | ||
|
|
14f43f4574 | ||
|
|
d96eebd5ee | ||
|
|
23fac3263f | ||
|
|
935de8a1a5 | ||
|
|
c2ba55e333 | ||
|
|
9a615ca7e0 | ||
|
|
f9601a6e3e | ||
|
|
8daf4d1498 | ||
|
|
c01ef407af | ||
|
|
dc019adb10 | ||
|
|
f7de17f1ee | ||
|
|
ca748384cf |
@@ -1,30 +1,25 @@
|
||||
name: CI
|
||||
name: Build and Publish
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
|
||||
|
||||
concurrency:
|
||||
group: build-publish-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
runs-on: ubuntu-latest
|
||||
Integration-Tests:
|
||||
uses: ./.github/workflows/integration-tests.yml
|
||||
name: '1'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: |
|
||||
6.0.x
|
||||
8.0.x
|
||||
|
||||
- name: Build
|
||||
run: ./build.sh
|
||||
|
||||
windows:
|
||||
Publish:
|
||||
needs: [Integration-Tests]
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 10
|
||||
name: '2 / Publish'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -35,6 +30,7 @@ jobs:
|
||||
dotnet-version: |
|
||||
6.0.x
|
||||
8.0.x
|
||||
10.0.x
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
39
.github/workflows/PR Validation.yml
vendored
Normal file
39
.github/workflows/PR Validation.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
name: PR Validation
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
concurrency:
|
||||
group: pr-validation-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
Whitespace-Check:
|
||||
uses: ./.github/workflows/trailing-whitespace-check.yml
|
||||
secrets: inherit
|
||||
name: '1'
|
||||
|
||||
Tests:
|
||||
needs: Whitespace-Check
|
||||
uses: ./.github/workflows/integration-tests.yml
|
||||
secrets: inherit
|
||||
name: '2'
|
||||
|
||||
build:
|
||||
needs: [Whitespace-Check, Tests]
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 10
|
||||
name: '3 / Build'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: |
|
||||
6.0.x
|
||||
8.0.x
|
||||
10.0.x
|
||||
|
||||
- name: Build
|
||||
run: .\build.ps1
|
||||
220
.github/workflows/integration-tests.yml
vendored
Normal file
220
.github/workflows/integration-tests.yml
vendored
Normal file
@@ -0,0 +1,220 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
concurrency:
|
||||
group: integration-tests-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: ${{ matrix.os }} API-${{ matrix.electronVersion }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-22.04, ubuntu-24.04, windows-2022, windows-2025, macos-14, macos-15-intel, macos-26]
|
||||
electronVersion: ['30.4.0', '38.2.2']
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
rid: linux-x64
|
||||
- os: ubuntu-24.04
|
||||
rid: linux-x64
|
||||
- os: windows-2022
|
||||
rid: win-x64
|
||||
- os: windows-2025
|
||||
rid: win-x64
|
||||
- os: macos-14
|
||||
rid: osx-arm64
|
||||
- os: macos-15-intel
|
||||
rid: osx-x64
|
||||
- os: macos-26
|
||||
rid: osx-arm64
|
||||
|
||||
env:
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
|
||||
DOTNET_NOLOGO: 1
|
||||
CI: true
|
||||
ELECTRON_ENABLE_LOGGING: 1
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Random delay (0-20 seconds)
|
||||
shell: bash
|
||||
run: |
|
||||
DELAY=$((RANDOM % 21))
|
||||
echo "Waiting for $DELAY seconds..."
|
||||
sleep $DELAY
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '10.0.x'
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
|
||||
- name: Restore
|
||||
run: dotnet restore -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj
|
||||
|
||||
- name: Build
|
||||
run: dotnet build --no-restore -c Release -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj
|
||||
|
||||
- name: Install Linux GUI dependencies
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
set -e
|
||||
sudo apt-get update
|
||||
. /etc/os-release
|
||||
if [ "$VERSION_ID" = "24.04" ]; then ALSA_PKG=libasound2t64; else ALSA_PKG=libasound2; fi
|
||||
echo "Using ALSA package: $ALSA_PKG"
|
||||
sudo apt-get install -y xvfb \
|
||||
libgtk-3-0 libnss3 libgdk-pixbuf-2.0-0 libdrm2 libgbm1 libxss1 libxtst6 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libx11-xcb1 "$ALSA_PKG"
|
||||
|
||||
- name: Run tests (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
mkdir -p test-results
|
||||
xvfb-run -a dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj \
|
||||
-c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} \
|
||||
--logger "trx;LogFileName=${{ matrix.os }}-electron-${{ matrix.electronVersion }}.trx" \
|
||||
--logger "console;verbosity=detailed" \
|
||||
--results-directory test-results
|
||||
|
||||
- name: Run tests (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
New-Item -ItemType Directory -Force -Path test-results | Out-Null
|
||||
dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj -c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} --logger "trx;LogFileName=${{ matrix.os }}-electron-${{ matrix.electronVersion }}.trx" --logger "console;verbosity=detailed" --results-directory test-results
|
||||
|
||||
- name: Run tests (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
mkdir -p test-results
|
||||
dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj -c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} -p:ElectronVersion=${{ matrix.electronVersion }} --logger "trx;LogFileName=${{ matrix.os }}-electron-${{ matrix.electronVersion }}.trx" --logger "console;verbosity=detailed" --results-directory test-results
|
||||
|
||||
- name: Upload raw test results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-results-${{ matrix.os }}-electron-${{ matrix.electronVersion }}
|
||||
path: test-results/*.trx
|
||||
retention-days: 7
|
||||
|
||||
summary:
|
||||
name: Test Results
|
||||
runs-on: ubuntu-24.04
|
||||
if: always()
|
||||
needs: [tests]
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
checks: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Download all test results
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: test-results
|
||||
|
||||
- name: Setup .NET (for CTRF conversion)
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '10.0.x'
|
||||
|
||||
- name: Install CTRF TRX→CTRF converter (dotnet tool)
|
||||
run: |
|
||||
dotnet new tool-manifest
|
||||
dotnet tool install DotnetCtrfJsonReporter --local
|
||||
|
||||
- name: Convert TRX → CTRF and clean names (filePath=OS|Electron X.Y.Z)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ctrf
|
||||
shopt -s globstar nullglob
|
||||
conv=0
|
||||
for trx in test-results/**/*.trx; do
|
||||
base="$(basename "$trx" .trx)" # e.g. ubuntu-22.04-electron-30.4.0
|
||||
os="${base%%-electron-*}"
|
||||
electron="${base#*-electron-}"
|
||||
label="$os|Electron $electron"
|
||||
outdir="ctrf/${label}"
|
||||
mkdir -p "$outdir"
|
||||
out="${outdir}/ctrf-report.json"
|
||||
|
||||
dotnet tool run DotnetCtrfJsonReporter -p "$trx" -d "$outdir" -f "ctrf-report.json"
|
||||
|
||||
jq --arg fp "$label" '.results.tests |= map(.filePath = $fp)' "$out" > "${out}.tmp" && mv "${out}.tmp" "$out"
|
||||
|
||||
echo "Converted & normalized $trx -> $out"
|
||||
conv=$((conv+1))
|
||||
done
|
||||
echo "Processed $conv TRX file(s)"
|
||||
|
||||
- name: Publish Test Report
|
||||
if: always()
|
||||
uses: ctrf-io/github-test-reporter@v1
|
||||
with:
|
||||
report-path: 'ctrf/**/*.json'
|
||||
summary: true
|
||||
pull-request: false
|
||||
status-check: false
|
||||
status-check-name: 'Integration Tests'
|
||||
use-suite-name: true
|
||||
update-comment: true
|
||||
always-group-by: true
|
||||
overwrite-comment: true
|
||||
exit-on-fail: true
|
||||
group-by: 'suite'
|
||||
upload-artifact: true
|
||||
fetch-previous-results: true
|
||||
summary-report: false
|
||||
summary-delta-report: true
|
||||
github-report: true
|
||||
test-report: false
|
||||
test-list-report: false
|
||||
failed-report: true
|
||||
failed-folded-report: false
|
||||
skipped-report: true
|
||||
suite-folded-report: true
|
||||
suite-list-report: false
|
||||
file-report: true
|
||||
previous-results-report: true
|
||||
insights-report: true
|
||||
flaky-report: true
|
||||
flaky-rate-report: true
|
||||
fail-rate-report: false
|
||||
slowest-report: false
|
||||
report-order: 'summary-delta-report,failed-report,skipped-report,suite-folded-report,file-report,previous-results-report,github-report'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Save PR Number
|
||||
if: github.event_name == 'pull_request'
|
||||
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Write PR Number to File
|
||||
if: github.event_name == 'pull_request'
|
||||
run: echo "$PR_NUMBER" > pr_number.txt
|
||||
shell: bash
|
||||
|
||||
- name: Upload PR Number Artifact
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: pr_number
|
||||
path: pr_number.txt
|
||||
|
||||
- name: Summary
|
||||
run: echo "All matrix test jobs completed."
|
||||
81
.github/workflows/pr-comment.yml
vendored
Normal file
81
.github/workflows/pr-comment.yml
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
name: Create PR Comments
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [ "PR Validation" ]
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
pr-comment:
|
||||
name: Post Test Result as PR comment
|
||||
runs-on: ubuntu-24.04
|
||||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion != 'cancelled'
|
||||
|
||||
steps:
|
||||
- name: Download CTRF artifact
|
||||
uses: dawidd6/action-download-artifact@v8
|
||||
with:
|
||||
github_token: ${{ github.token }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: ctrf-report
|
||||
path: ctrf
|
||||
|
||||
- name: Download PR Number Artifact
|
||||
uses: dawidd6/action-download-artifact@v8
|
||||
with:
|
||||
github_token: ${{ github.token }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: pr_number
|
||||
path: pr_number
|
||||
|
||||
- name: Read PR Number
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
FILE='pr_number/pr_number.txt'
|
||||
|
||||
# Ensure file exists
|
||||
if [ ! -f "$FILE" ] || [ -L "$FILE" ]; then
|
||||
echo "Error: $FILE is missing or is not a regular file." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Chec file size
|
||||
if [ "$(wc -c < "$FILE" | tr -d ' ')" -gt 200 ]; then
|
||||
echo "Error: $FILE is too large." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read first line
|
||||
PR_NUMBER=""
|
||||
IFS= read -r PR_NUMBER < "$FILE" || true
|
||||
|
||||
# Validate whether it's a number
|
||||
if ! [[ "$PR_NUMBER" =~ ^[0-9]{1,10}$ ]]; then
|
||||
echo "Error: PR_NUMBER is not a valid integer on the first line." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf 'PR_NUMBER=%s\n' "$PR_NUMBER" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Post PR Comment
|
||||
uses: ctrf-io/github-test-reporter@v1
|
||||
with:
|
||||
report-path: 'ctrf/**/*.json'
|
||||
issue: ${{ env.PR_NUMBER }}
|
||||
|
||||
summary: true
|
||||
pull-request: true
|
||||
use-suite-name: true
|
||||
update-comment: true
|
||||
always-group-by: true
|
||||
overwrite-comment: true
|
||||
upload-artifact: false
|
||||
|
||||
pull-request-report: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
50
.github/workflows/retry-test-jobs.yml
vendored
Normal file
50
.github/workflows/retry-test-jobs.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Tests auto-rerun
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [ "PR Validation", "Build and Publish" ]
|
||||
types: [ completed ]
|
||||
|
||||
jobs:
|
||||
rerun-failed-matrix-jobs-once:
|
||||
if: >
|
||||
${{
|
||||
github.event.workflow_run.conclusion == 'failure' &&
|
||||
github.event.workflow_run.run_attempt == 1
|
||||
}}
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Decide whether to rerun (only if matrix jobs failed)
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
RUN_ID: ${{ github.event.workflow_run.id }}
|
||||
run: |
|
||||
echo "Inspecting jobs of workflow run $RUN_ID in $REPO"
|
||||
|
||||
jobs_json="$(gh api 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 '
|
||||
[ .jobs[]
|
||||
| select(.conclusion == "failure"
|
||||
and (.name | contains(" API-")))
|
||||
]
|
||||
| length
|
||||
')
|
||||
|
||||
echo "Failed Integration Tests matrix jobs: $failed_matrix_jobs"
|
||||
|
||||
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
|
||||
else
|
||||
echo "Only non-matrix jobs (like Test Results) failed – not auto-rerunning."
|
||||
fi
|
||||
84
.github/workflows/trailing-whitespace-check.yml
vendored
Normal file
84
.github/workflows/trailing-whitespace-check.yml
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
name: Whitespace Check
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
check-whitespace:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check for trailing whitespace
|
||||
run: |
|
||||
echo "Checking for trailing whitespace in changed files..."
|
||||
|
||||
# Get the base branch
|
||||
BASE_SHA="${{ github.event.pull_request.base.sha }}"
|
||||
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
|
||||
|
||||
# Get list of changed files (excluding deleted files)
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=d "$BASE_SHA" "$HEAD_SHA")
|
||||
|
||||
if [ -z "$CHANGED_FILES" ]; then
|
||||
echo "No files to check."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# File patterns to check (text files)
|
||||
PATTERNS="\.cs$|\.csproj$|\.sln$|\.ts$|\.html$|\.css$|\.scss$"
|
||||
|
||||
# Directories and file patterns to exclude
|
||||
EXCLUDE_PATTERNS="(^|\/)(\.|node_modules|bin|obj|artifacts|packages|\.vs|\.nuke\/temp)($|\/)"
|
||||
|
||||
ERRORS_FOUND=0
|
||||
TEMP_FILE=$(mktemp)
|
||||
|
||||
while IFS= read -r file; do
|
||||
# Skip if file doesn't exist (shouldn't happen with --diff-filter=d, but just in case)
|
||||
if [ ! -f "$file" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if file matches patterns to check
|
||||
if ! echo "$file" | grep -qE "$PATTERNS"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if file should be excluded
|
||||
if echo "$file" | grep -qE "$EXCLUDE_PATTERNS"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Find trailing whitespace lines, excluding XML doc placeholder lines that are exactly "/// " (one space)
|
||||
MATCHES=$(grep -n '[[:space:]]$' "$file" | grep -vE '^[0-9]+:[[:space:]]*/// $' || true)
|
||||
|
||||
if [ -n "$MATCHES" ]; then
|
||||
echo "❌ Trailing whitespace found in: $file"
|
||||
echo "$MATCHES" | head -10
|
||||
TOTAL=$(echo "$MATCHES" | wc -l)
|
||||
if [ "$TOTAL" -gt 10 ]; then
|
||||
echo " ... and $(($TOTAL - 10)) more lines"
|
||||
fi
|
||||
echo "1" >> "$TEMP_FILE"
|
||||
fi
|
||||
done <<< "$CHANGED_FILES"
|
||||
|
||||
ERRORS_FOUND=$(wc -l < "$TEMP_FILE" 2>/dev/null || echo "0")
|
||||
rm -f "$TEMP_FILE"
|
||||
|
||||
if [ "$ERRORS_FOUND" -gt 0 ]; then
|
||||
echo ""
|
||||
echo "❌ Found trailing whitespace in $ERRORS_FOUND file(s)."
|
||||
echo "Please remove trailing whitespace from the files listed above."
|
||||
exit 1
|
||||
else
|
||||
echo "✅ No trailing whitespace found in changed files."
|
||||
exit 0
|
||||
fi
|
||||
@@ -1,23 +1,54 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"$ref": "#/definitions/build",
|
||||
"title": "Build Schema",
|
||||
"definitions": {
|
||||
"build": {
|
||||
"type": "object",
|
||||
"Host": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"AppVeyor",
|
||||
"AzurePipelines",
|
||||
"Bamboo",
|
||||
"Bitbucket",
|
||||
"Bitrise",
|
||||
"GitHubActions",
|
||||
"GitLab",
|
||||
"Jenkins",
|
||||
"Rider",
|
||||
"SpaceAutomation",
|
||||
"TeamCity",
|
||||
"Terminal",
|
||||
"TravisCI",
|
||||
"VisualStudio",
|
||||
"VSCode"
|
||||
]
|
||||
},
|
||||
"ExecutableTarget": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Clean",
|
||||
"Compile",
|
||||
"Default",
|
||||
"Package",
|
||||
"PrePublish",
|
||||
"Publish",
|
||||
"PublishPackages",
|
||||
"PublishPreRelease",
|
||||
"PublishRelease",
|
||||
"Restore",
|
||||
"RunUnitTests"
|
||||
]
|
||||
},
|
||||
"Verbosity": {
|
||||
"type": "string",
|
||||
"description": "",
|
||||
"enum": [
|
||||
"Verbose",
|
||||
"Normal",
|
||||
"Minimal",
|
||||
"Quiet"
|
||||
]
|
||||
},
|
||||
"NukeBuild": {
|
||||
"properties": {
|
||||
"CommonPropsFilePath": {
|
||||
"type": "string",
|
||||
"description": "common.props file path - to determine the configured version"
|
||||
},
|
||||
"Configuration": {
|
||||
"type": "string",
|
||||
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
|
||||
"enum": [
|
||||
"Debug",
|
||||
"Release"
|
||||
]
|
||||
},
|
||||
"Continue": {
|
||||
"type": "boolean",
|
||||
"description": "Indicates to continue a previously failed build attempt"
|
||||
@@ -27,25 +58,8 @@
|
||||
"description": "Shows the help text for this build assembly"
|
||||
},
|
||||
"Host": {
|
||||
"type": "string",
|
||||
"description": "Host for execution. Default is 'automatic'",
|
||||
"enum": [
|
||||
"AppVeyor",
|
||||
"AzurePipelines",
|
||||
"Bamboo",
|
||||
"Bitbucket",
|
||||
"Bitrise",
|
||||
"GitHubActions",
|
||||
"GitLab",
|
||||
"Jenkins",
|
||||
"Rider",
|
||||
"SpaceAutomation",
|
||||
"TeamCity",
|
||||
"Terminal",
|
||||
"TravisCI",
|
||||
"VisualStudio",
|
||||
"VSCode"
|
||||
]
|
||||
"$ref": "#/definitions/Host"
|
||||
},
|
||||
"NoLogo": {
|
||||
"type": "boolean",
|
||||
@@ -66,10 +80,6 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"ReleaseNotesFilePath": {
|
||||
"type": "string",
|
||||
"description": "ReleaseNotesFilePath - To determine the lates changelog version"
|
||||
},
|
||||
"Root": {
|
||||
"type": "string",
|
||||
"description": "Root directory during build execution"
|
||||
@@ -78,59 +88,50 @@
|
||||
"type": "array",
|
||||
"description": "List of targets to be skipped. Empty list skips all dependencies",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Clean",
|
||||
"Compile",
|
||||
"CreatePackages",
|
||||
"Default",
|
||||
"Package",
|
||||
"PrePublish",
|
||||
"Publish",
|
||||
"PublishPackages",
|
||||
"PublishPreRelease",
|
||||
"PublishRelease",
|
||||
"Restore",
|
||||
"RunUnitTests"
|
||||
]
|
||||
"$ref": "#/definitions/ExecutableTarget"
|
||||
}
|
||||
},
|
||||
"Solution": {
|
||||
"type": "string",
|
||||
"description": "Path to a solution file that is automatically loaded"
|
||||
},
|
||||
"Target": {
|
||||
"type": "array",
|
||||
"description": "List of targets to be invoked. Default is '{default_target}'",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Clean",
|
||||
"Compile",
|
||||
"CreatePackages",
|
||||
"Default",
|
||||
"Package",
|
||||
"PrePublish",
|
||||
"Publish",
|
||||
"PublishPackages",
|
||||
"PublishPreRelease",
|
||||
"PublishRelease",
|
||||
"Restore",
|
||||
"RunUnitTests"
|
||||
]
|
||||
"$ref": "#/definitions/ExecutableTarget"
|
||||
}
|
||||
},
|
||||
"Verbosity": {
|
||||
"type": "string",
|
||||
"description": "Logging verbosity during build execution. Default is 'Normal'",
|
||||
"enum": [
|
||||
"Minimal",
|
||||
"Normal",
|
||||
"Quiet",
|
||||
"Verbose"
|
||||
]
|
||||
"$ref": "#/definitions/Verbosity"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"properties": {
|
||||
"CommonPropsFilePath": {
|
||||
"type": "string",
|
||||
"description": "common.props file path - to determine the configured version"
|
||||
},
|
||||
"Configuration": {
|
||||
"type": "string",
|
||||
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
|
||||
"enum": [
|
||||
"Debug",
|
||||
"Release"
|
||||
]
|
||||
},
|
||||
"ReleaseNotesFilePath": {
|
||||
"type": "string",
|
||||
"description": "ReleaseNotesFilePath - To determine the lates changelog version"
|
||||
},
|
||||
"Solution": {
|
||||
"type": "string",
|
||||
"description": "Path to a solution file that is automatically loaded"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/NukeBuild"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
59
Changelog.md
59
Changelog.md
@@ -1,8 +1,58 @@
|
||||
# 0.3.0
|
||||
|
||||
## ElectronNET.Core
|
||||
|
||||
- Updated infrastructure (#937, #939) @softworkz
|
||||
- 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 previous API break using exposed `JsonElement` objects (#938) @softworkz
|
||||
- Fixed and improved several test cases (#962) @softworkz
|
||||
- Fixed the `BrowserWindowOptions` (#945) @softworkz
|
||||
- Added several migration checks for publishing (#966) @softworkz
|
||||
- Added more test runners for E2E tests (#950, #951) @agracio
|
||||
- Added matrix tests with 6 runners and 2 electron version (#948) @softworkz
|
||||
- Added additional APIs for WebContents (#958) @agracio
|
||||
|
||||
# 0.2.0
|
||||
|
||||
## ElectronNET.Core
|
||||
|
||||
- Updated dependencies (#930) @softworkz
|
||||
- Updated integration tests (#931) @softworkz
|
||||
- Updated `ElectronNET.Host` (#935) @softworkz
|
||||
- Removed transition period specific build configuration (#928) @softworkz
|
||||
- Added `IsRunningBlazor` option to `BrowserWindowOptions` (#926)
|
||||
- Added platform support attributes (#929) @softworkz
|
||||
|
||||
# 0.1.0
|
||||
|
||||
## ElectronNET.Core
|
||||
|
||||
- Updated `PrintToPDFOptions` to also allow specifying the `PageSize` with an object (#769)
|
||||
- Updated splashscreen image to have 0 margin (#622)
|
||||
- Updated the IPC API w.r.t. naming and consistency (#905) @agracio
|
||||
- Updated the IPC bridge w.r.t. synchronization and thread-safety (#918) @agracio
|
||||
- Updated serialization to use `System.Text.Json` replacing `Newtonsoft.Json` (#917) @Denny09310
|
||||
- Fixed parameter handling for the `sendToIpcRenderer` function (#922) @softworkz
|
||||
- Fixed synchronization on removing event handlers (#921) @softworkz
|
||||
- Fixed creation of windows with `contextIsolation` enabled (#906) @NimbusFox
|
||||
- Fixed single instance behavior using the `ElectronSingleInstance` property (#901)
|
||||
- Fixed potential race conditions (#908) @softworkz
|
||||
- Added option to use `ElectronSplashScreen` with an HTML file (#799)
|
||||
- Added option to provide floating point value as aspect ratios with `SetAspectRatio` (#793)
|
||||
- Added option to provide `TitleBarOverlay` as an object (#911) @Denny09310
|
||||
- Added `TitleBarOverlay` property to `BrowserWindowOptions` (#909)
|
||||
- Added `RoundedCorners` property to `BrowserWindowOptions`
|
||||
- Added integration tests and robustness checks (#913) @softworkz
|
||||
- Added .NET 10 as an explicit target
|
||||
|
||||
# 0.0.18
|
||||
|
||||
## ElectronNET.Core
|
||||
|
||||
### Highlights
|
||||
|
||||
- **Complete MSBuild Integration**: Eliminated CLI tool dependency, moved all build processes to MSBuild with deep Visual Studio integration
|
||||
- **Modernized Architecture**: Restructured process lifecycle with .NET launching first and running Electron as child process for better control and reliability
|
||||
- **Cross-Platform Development**: Build and debug Linux applications directly from Windows Visual Studio via WSL integration
|
||||
@@ -11,6 +61,7 @@
|
||||
- **Console App Support**: No longer requires ASP.NET - now works with simple console applications for file system or remote server HTML/JS
|
||||
|
||||
### Build System & Project Structure
|
||||
|
||||
- Eliminated electron.manifest.json configuration file, replaced with MSBuild project properties
|
||||
- Introduced new package structure: ElectronNET.Core (main package), ElectronNET.Core.Api (API definitions), ElectronNET.Core.AspNet (ASP.NET integration)
|
||||
- Added Runtime Identifier (RID) selection as part of project configuration
|
||||
@@ -19,19 +70,22 @@
|
||||
- Added custom MSBuild tasks for Electron-specific build operations
|
||||
|
||||
### Development Experience
|
||||
|
||||
- Implemented unpackaged run-mode for development using regular .NET builds with unpackaged Electron configuration
|
||||
- Added support for building Linux packages on Windows via WSL integration
|
||||
- Enabled running and debugging Linux application outputs on Windows through WSL
|
||||
- Integrated TypeScript compilation with ASP.NET tooling for consistent builds
|
||||
- Added process orchestration supporting 8 different launch scenarios (packaged/unpackaged × console/ASP.NET × dotnet-first/electron-first)
|
||||
- Added process orchestration supporting 8 different launch scenarios (packaged/unpackaged × console/ASP.NET × dotnet-first/electron-first)
|
||||
|
||||
### Debugging & Runtime
|
||||
|
||||
- Dramatically improved debugging experience with ASP.NET-first launch mode
|
||||
- Added Hot Reload support for ASP.NET code during development
|
||||
- Implemented proper process termination handling for all exit scenarios
|
||||
- Minimized startup times through optimized build and launch procedures
|
||||
|
||||
### Technical Improvements
|
||||
|
||||
- Enhanced splash screen handling with automatic path resolution
|
||||
- Improved ElectronHostHook integration as proper npm package dependency
|
||||
- Updated to latest TypeScript version with ESLint configuration
|
||||
@@ -40,6 +94,7 @@
|
||||
- Added build-time Electron version compatibility validation
|
||||
|
||||
### Package & Distribution
|
||||
|
||||
- Integrated MSBuild publishing mechanisms for creating Electron packages
|
||||
- Added folder publishing support with improved parameter handling
|
||||
- Implemented automated package.json generation from MSBuild properties
|
||||
@@ -47,6 +102,7 @@
|
||||
- Reduced package sizes by eliminating unnecessary TypeScript dependencies
|
||||
|
||||
### Migration & Compatibility
|
||||
|
||||
- Maintained backward compatibility for existing ElectronHostHook implementations
|
||||
- Removed ASP.NET requirement: Now works with simple console applications for file system or remote server HTML/JS scenarios
|
||||
- Added support for both console and ASP.NET Core application types
|
||||
@@ -54,4 +110,3 @@
|
||||
- Added migration path for existing projects through updated package structure
|
||||
|
||||
This represents a comprehensive modernization of Electron.NET, addressing the major pain points around debugging, build complexity, and platform limitations while maintaining full API compatibility.
|
||||
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017-2024 Gregor Biswanger, Robert Mühsig
|
||||
Copyright (c) 2017-2025 Gregor Biswanger, Robert Mühsig, Florian Rappl
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
171
README.md
171
README.md
@@ -2,43 +2,40 @@
|
||||
|
||||
[](https://donorbox.org/electron-net) [](https://gitter.im/ElectronNET/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [](https://github.com/ElectronNET/Electron.NET/actions/workflows/ci.yml)
|
||||
|
||||
# Electron.Net Core is here!
|
||||
# Electron.NET Core is here!
|
||||
|
||||
## A Complete Transformation
|
||||
|
||||
ElectronNET.Core represents a fundamental modernization of Electron.NET, addressing years of accumulated pain points while preserving full API compatibility. This isn't just an update—it's a complete rethinking of how .NET developers build and debug cross-platform desktop applications with Electron.
|
||||
`ElectronNET.Core` represents a fundamental modernization of Electron.NET, addressing years of accumulated pain points while preserving full API compatibility. This isn't just an update — it's a complete rethinking of how .NET developers build and debug cross-platform desktop applications with Electron.
|
||||
|
||||
Read more: [**What's New in ElectronNET.Core**](wiki/What's-New)
|
||||
|
||||
|
||||
Build cross platform desktop applications with .NET 6/8 - from console apps to ASP.Net Core (Razor Pages, MVC) to Blazor
|
||||
Read more: [**What's New in `ElectronNET.Core`**](https://github.com/ElectronNET/Electron.NET/wiki/What's-New)
|
||||
|
||||
Build cross platform desktop applications with .NET 6/8/10 - from console apps to ASP.NET Core (Razor Pages, MVC) to Blazor.
|
||||
|
||||
## Wait - how does that work exactly?
|
||||
|
||||
Well... there are lots of different approaches how to get a X-plat desktop app running. Electron.NET provides a range of ways to build .NET based solutions using Electron at the side of presentation. While the classic Electron.Net setup, using an ASP.Net host ran by the Electron side is still the primary way, there's more flexibility now: both, dotnet and Electron are now able to launch the other for better lifetime management, and when you don't need a local web server - like when running content from files or remote servers, you can drop the ASP.Net stack altogether and got with a lightweight console app instead.
|
||||
Well... there are lots of different approaches how to get a X-plat desktop app running. Electron.NET provides a range of ways to build .NET-based solutions using Electron at the side of presentation.
|
||||
|
||||
While the classic Electron.NET setup (using an ASP.NET host run by the Electron side) is still the primary way, there's more flexibility now. Both .NET and Electron are now able to launch the other for better lifetime management, and when you don't need a local web server (like when running content from files or remote servers), you can drop the ASP.NET stack altogether and go with a lightweight console app instead.
|
||||
|
||||
## 📦 NuGet
|
||||
|
||||
[ ElectronNET.Core ](https://www.nuget.org/packages/ElectronNET.Core.API/) | [ ElectronNET.Core.API ](https://www.nuget.org/packages/ElectronNET.Core.API/) | [ ElectronNET.Core.AspNet ](https://www.nuget.org/packages/ElectronNET.Core.AspNet/)
|
||||
|
||||
* ElectronNET.Core: [](https://www.nuget.org/packages/ElectronNET.Core.API/)
|
||||
* ElectronNET.Core.API: [](https://www.nuget.org/packages/ElectronNET.Core.API/)
|
||||
* ElectronNET.Core.AspNet: [](https://www.nuget.org/packages/ElectronNET.Core.AspNet/)
|
||||
|
||||
## 🛠 Requirements to Run
|
||||
|
||||
Our API uses .NET 6/8, so our
|
||||
You should have installed:
|
||||
|
||||
Also you should have installed:
|
||||
* .NET 6/8 or later.
|
||||
* The minimum base OS is the same as [.NET 6](https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md) / [.NET 8](https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md).
|
||||
* Node.JS using at least [Version 22.x](https://nodejs.org).
|
||||
|
||||
* .NET 6/8 or later
|
||||
* OS
|
||||
minimum base OS is the same as [.NET 6](https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md) / [.NET 8](https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md).
|
||||
* NodeJS (at least [Version 22.x](https://nodejs.org))
|
||||
## 👩🏫 Usage with ASP.NET
|
||||
|
||||
|
||||
## 👩🏫 Usage with ASP.Net
|
||||
|
||||
- Create a new ASP.Net Core project
|
||||
- Install the following two nuget packages:
|
||||
- Create a new ASP.NET Core project
|
||||
- Install the following two NuGet packages:
|
||||
|
||||
```ps1
|
||||
dotnet add package ElectronNET.Core
|
||||
@@ -46,59 +43,144 @@ dotnet add package ElectronNET.Core
|
||||
dotnet add package ElectronNET.Core.AspNet
|
||||
```
|
||||
|
||||
### Enable Electron.NET on Startup
|
||||
### Classic ASP.NET Core
|
||||
|
||||
#### Enable Electron.NET on Startup
|
||||
|
||||
To do so, use the `UseElectron` extension method on a `WebApplicationBuilder`, an `IWebHostBuilder` or any descendants.
|
||||
|
||||
> [!NOTE]
|
||||
> New in Electron.NET Core is that you provide a callback method as an argument to `UseElectron()`, which ensures that you get to know the right moment to set up your application UI.
|
||||
|
||||
### Program.cs
|
||||
#### Program.cs
|
||||
|
||||
```csharp
|
||||
using ElectronNET.API;
|
||||
using ElectronNET.API.Entities;
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseElectron(args, ElectronAppReady)
|
||||
.UseStartup<Startup>()
|
||||
.Build()
|
||||
.Run();
|
||||
}
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseElectron(args, ElectronAppReady)
|
||||
.UseStartup<Startup>()
|
||||
.Build()
|
||||
.Run();
|
||||
}
|
||||
|
||||
public static async Task ElectronAppReady()
|
||||
{
|
||||
var browserWindow = await Electron.WindowManager.CreateWindowAsync(
|
||||
new BrowserWindowOptions { Show = false });
|
||||
public static async Task ElectronAppReady()
|
||||
{
|
||||
var browserWindow = await Electron.WindowManager.CreateWindowAsync(
|
||||
new BrowserWindowOptions { Show = false });
|
||||
|
||||
browserWindow.OnReadyToShow += () => browserWindow.Show();
|
||||
}
|
||||
browserWindow.OnReadyToShow += () => browserWindow.Show();
|
||||
}
|
||||
```
|
||||
|
||||
### Minimal API Example
|
||||
|
||||
For a minimal API you can use:
|
||||
|
||||
```csharp
|
||||
using ElectronNET;
|
||||
using ElectronNET.API;
|
||||
using ElectronNET.API.Entities;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddElectron(); // <- might be useful to set up DI
|
||||
|
||||
builder.UseElectron(args, async () =>
|
||||
{
|
||||
var browserWindow = await Electron.WindowManager.CreateWindowAsync(
|
||||
new BrowserWindowOptions { Show = false, AutoHideMenuBar = true });
|
||||
|
||||
browserWindow.OnReadyToShow += () => browserWindow.Show();
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
app.UseAuthorization();
|
||||
app.MapRazorPages();
|
||||
app.Run();
|
||||
```
|
||||
|
||||
### Blazor
|
||||
|
||||
For a project with Blazor you can use:
|
||||
|
||||
```cs
|
||||
using ElectronNET.API;
|
||||
using ElectronNET.API.Entities;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services
|
||||
.AddRazorComponents()
|
||||
.AddInteractiveWebAssemblyComponents();
|
||||
|
||||
builder.Services.AddElectron(); // <-- might be useful to set up DI
|
||||
|
||||
builder.UseElectron(args, async () =>
|
||||
{
|
||||
var options = new BrowserWindowOptions {
|
||||
Show = false,
|
||||
AutoHideMenuBar = true,
|
||||
IsRunningBlazor = true, // <-- crucial
|
||||
};
|
||||
var browserWindow = await Electron.WindowManager.CreateWindowAsync(options);
|
||||
browserWindow.OnReadyToShow += () => browserWindow.Show();
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseWebAssemblyDebugging();
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseAntiforgery();
|
||||
|
||||
app.MapRazorComponents<BlazorApp.Components.App>()
|
||||
.AddInteractiveWebAssemblyRenderMode();
|
||||
|
||||
app.Run();
|
||||
```
|
||||
|
||||
The `IsRunningBlazor` option makes sure to set up the renderer in a way that Blazor can just run without any interference. This includes things such as HMR for development.
|
||||
|
||||
## 🚀 Starting and Debugging the Application
|
||||
|
||||
Just press F5 in Visual Studio or use dotnet for debugging.
|
||||
|
||||
Just press `F5` in Visual Studio or use dotnet for debugging.
|
||||
|
||||
## 📔 Usage of the Electron API
|
||||
|
||||
A complete documentation is available on the Wiki.
|
||||
Complete documentation is available on the Wiki.
|
||||
|
||||
In this YouTube video, we show you how you can create a new project, use the Electron.NET API, debug a application and build an executable desktop app for Windows: [Electron.NET - Getting Started](https://www.youtube.com/watch?v=nuM6AojRFHk)
|
||||
|
||||
> [!NOTE]
|
||||
> The video hasn't been updated for the changes in ElectronNET.Core, so it is partially outdated.
|
||||
|
||||
|
||||
|
||||
## 👨💻 Authors
|
||||
|
||||
* **[Gregor Biswanger](https://github.com/GregorBiswanger)** - (Microsoft MVP, Intel Black Belt and Intel Software Innovator) is a freelance lecturer, consultant, trainer, author and speaker. He is a consultant for large and medium-sized companies, organizations and agencies for software architecture, web- and cross-platform development. You can find Gregor often on the road attending or speaking at international conferences. - [Cross-Platform-Blog](http://www.cross-platform-blog.com) - Twitter [@BFreakout](https://www.twitter.com/BFreakout)
|
||||
* **[Dr. Florian Rappl](https://github.com/FlorianRappl)** - Software Developer - from Munich, Germany. Microsoft MVP & Web Geek. - [The Art of Micro Frontends](https://microfrontends.art) - [Homepage](https://florian-rappl.de) - Twitter [@florianrappl](https://twitter.com/florianrappl)
|
||||
* [**softworkz**](https://github.com/softworkz) - full range developer - likes to start where others gave up - MS MVP alumni and Munich citizen as well
|
||||
* **[softworkz](https://github.com/softworkz)** - Full Range Developer - likes to start where others gave up. MS MVP alumni and Munich citizen as well.
|
||||
* **[Robert Muehsig](https://github.com/robertmuehsig)** - Software Developer - from Dresden, Germany, now living & working in Switzerland. Microsoft MVP & Web Geek. - [codeinside Blog](https://blog.codeinside.eu) - Twitter [@robert0muehsig](https://twitter.com/robert0muehsig)
|
||||
|
||||
See also the list of [contributors](https://github.com/ElectronNET/Electron.NET/graphs/contributors) who participated in this project.
|
||||
@@ -108,7 +190,6 @@ See also the list of [contributors](https://github.com/ElectronNET/Electron.NET/
|
||||
Feel free to submit a pull request if you find any bugs (to see a list of active issues, visit the [Issues section](https://github.com/ElectronNET/Electron.NET/issues).
|
||||
Please make sure all commits are properly documented.
|
||||
|
||||
|
||||
## 🙏 Donate
|
||||
|
||||
We do this open source work in our free time. If you'd like us to invest more time on it, please [donate](https://donorbox.org/electron-net). Donation can be used to increase some issue priority. Thank you!
|
||||
@@ -124,9 +205,7 @@ Any support appreciated! 🍻
|
||||
|
||||
## 🎉 License
|
||||
|
||||
MIT-licensed. See [LICENSE](./LICENSE) for details.
|
||||
MIT-licensed. See [LICENSE](https://github.com/ElectronNET/Electron.NET/blob/main/LICENSE) for details.
|
||||
|
||||
**Enjoy!**
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
235
docs/Core/Migration-Checks.md
Normal file
235
docs/Core/Migration-Checks.md
Normal file
@@ -0,0 +1,235 @@
|
||||
# Migration Checks
|
||||
|
||||
Electron.NET includes automatic build-time validation checks that help users migrating from previous versions avoid common configuration issues. These checks run automatically during the build process and provide helpful guidance when problems are detected.
|
||||
|
||||
## Overview
|
||||
|
||||
When you build an Electron.NET project, the following validation checks are performed:
|
||||
|
||||
| Code | Check | Description |
|
||||
|------|-------|-------------|
|
||||
| [ELECTRON001](#1-packagejson-not-allowed) | package.json not allowed | Ensures no package.json exists outside ElectronHostHook |
|
||||
| [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 |
|
||||
| [ELECTRON005](#4-parent-paths-not-allowed-in-electron-builderjson) | Parent paths not allowed | Checks for `..` references in config |
|
||||
| [ELECTRON006](#5-publish-profile-validation) | ASP.NET publish profile mismatch | Warns when ASP.NET projects have console-style profiles |
|
||||
| [ELECTRON007](#5-publish-profile-validation) | Console publish profile mismatch | Warns when console projects have ASP.NET-style profiles |
|
||||
|
||||
---
|
||||
|
||||
## 1. package.json not allowed
|
||||
|
||||
**Warning Code:** `ELECTRON001`
|
||||
|
||||
### 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).
|
||||
|
||||
### 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.
|
||||
|
||||
### 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.
|
||||
|
||||
### How to fix
|
||||
|
||||
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>
|
||||
<Title>My Electron App</Title>
|
||||
<Version>1.0.0</Version>
|
||||
<Description>My awesome Electron.NET application</Description>
|
||||
<Company>My Company</Company>
|
||||
<Copyright>Copyright © 2025</Copyright>
|
||||
<ElectronVersion>30.0.9</ElectronVersion>
|
||||
</PropertyGroup>
|
||||
```
|
||||
|
||||
3. **Delete the old `package.json`** file from your project root
|
||||
|
||||
> **See also:** [Migration Guide](Migration-Guide.md) for complete migration instructions.
|
||||
|
||||
---
|
||||
|
||||
## 2. electron-manifest.json not allowed
|
||||
|
||||
**Warning Code:** `ELECTRON002`
|
||||
|
||||
### What is checked
|
||||
|
||||
The build system checks for the presence of `electron.manifest.json` or `electron-manifest.json` files in your project.
|
||||
|
||||
### Why this matters
|
||||
|
||||
The `electron.manifest.json` file format is deprecated. All configuration should now be specified using:
|
||||
- MSBuild properties in your `.csproj` file (for application metadata)
|
||||
- The `electron-builder.json` file in the `Properties` folder (for build configuration)
|
||||
|
||||
### How to fix
|
||||
|
||||
1. **Migrate application properties** to your `.csproj` file (see [Migration Guide](Migration-Guide.md))
|
||||
2. **Move the `build` section** from `electron.manifest.json` to `Properties/electron-builder.json`
|
||||
3. **Delete the old `electron.manifest.json`** file
|
||||
|
||||
**Example electron-builder.json:**
|
||||
```json
|
||||
{
|
||||
"compression": "maximum",
|
||||
"win": {
|
||||
"icon": "Assets/app.ico",
|
||||
"target": ["nsis", "portable"]
|
||||
},
|
||||
"linux": {
|
||||
"icon": "Assets/app.png",
|
||||
"target": ["AppImage", "deb"]
|
||||
},
|
||||
"mac": {
|
||||
"icon": "Assets/app.icns",
|
||||
"target": ["dmg", "zip"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. electron-builder.json Location
|
||||
|
||||
**Warning Codes:** `ELECTRON003`, `ELECTRON004`
|
||||
|
||||
### What is checked
|
||||
|
||||
- `ELECTRON003`: Verifies that an `electron-builder.json` file exists in the `Properties` folder
|
||||
- `ELECTRON004`: Warns if `electron-builder.json` is found in incorrect locations
|
||||
|
||||
### Why this matters
|
||||
|
||||
The `electron-builder.json` file must be located in the `Properties` folder so it can be properly copied to the output directory during publishing.
|
||||
|
||||
### How to fix
|
||||
|
||||
1. **Create the Properties folder** if it doesn't exist
|
||||
2. **Move or create** `electron-builder.json` in `Properties/electron-builder.json`
|
||||
3. **Remove** any `electron-builder.json` files from other locations
|
||||
|
||||
**Expected structure:**
|
||||
```
|
||||
MyProject/
|
||||
├── Properties/
|
||||
│ ├── electron-builder.json ✅ Correct location
|
||||
│ ├── launchSettings.json
|
||||
│ └── PublishProfiles/
|
||||
├── MyProject.csproj
|
||||
└── Program.cs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Parent paths not allowed in electron-builder.json
|
||||
|
||||
**Warning Code:** `ELECTRON005`
|
||||
|
||||
### What is checked
|
||||
|
||||
The build system scans the `electron-builder.json` file for parent-path references (`..`).
|
||||
|
||||
### Why this matters
|
||||
|
||||
During the publish process, the `electron-builder.json` file is copied to the build output directory. Any relative paths in this file are resolved from that location, not from your project directory. Parent-path references (`../`) will not work correctly because they would point outside the published application.
|
||||
|
||||
### How to fix
|
||||
|
||||
1. **Move resource files** (icons, installers, etc.) inside your project folder structure
|
||||
2. **Configure the files** to be copied to the output directory in your `.csproj`:
|
||||
|
||||
```xml
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\**\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
3. **Update paths** in `electron-builder.json` to use relative paths without `..`:
|
||||
|
||||
**Before (incorrect):**
|
||||
```json
|
||||
{
|
||||
"win": {
|
||||
"icon": "../SharedAssets/app.ico"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**After (correct):**
|
||||
```json
|
||||
{
|
||||
"win": {
|
||||
"icon": "Assets/app.ico"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Publish Profile Validation
|
||||
|
||||
**Warning Codes:** `ELECTRON006`, `ELECTRON007`
|
||||
|
||||
### What is checked
|
||||
|
||||
The build system examines `.pubxml` files in the `Properties/PublishProfiles` folder and validates that they match the project type:
|
||||
|
||||
- **ELECTRON006**: For **ASP.NET projects** (using `Microsoft.NET.Sdk.Web`), checks that publish profiles include `WebPublishMethod`. This property is required for proper ASP.NET publishing.
|
||||
|
||||
- **ELECTRON007**: For **console/other projects** (not using the Web SDK), checks that publish profiles do NOT include the `WebPublishMethod` property. These ASP.NET-specific properties are incorrect for non-web applications.
|
||||
|
||||
### Why this matters
|
||||
|
||||
Electron.NET supports both ASP.NET and console application project types, each requiring different publish profile configurations:
|
||||
|
||||
| Project Type | SDK | Expected Properties |
|
||||
|--------------|-----|---------------------|
|
||||
| ASP.NET (Razor Pages, MVC, Blazor) | `Microsoft.NET.Sdk.Web` | `WebPublishMethod`, no `PublishProtocol` |
|
||||
| Console Application | `Microsoft.NET.Sdk` | `PublishProtocol`, no `WebPublishMethod` |
|
||||
|
||||
Using the wrong publish profile type can lead to incomplete or broken builds.
|
||||
|
||||
### How to fix
|
||||
|
||||
1. **Delete existing publish profiles** from `Properties/PublishProfiles/`
|
||||
2. **Create new publish profiles** using the Visual Studio Publishing Wizard:
|
||||
- Right-click on the project in Solution Explorer
|
||||
- Select **Publish...**
|
||||
- Follow the wizard to create a **Folder** publish profile
|
||||
|
||||
For correct publish profile examples for both ASP.NET and Console applications, see **[Package Building](../Using/Package-Building.md#step-1-create-publish-profiles)**.
|
||||
|
||||
---
|
||||
|
||||
## Disabling Migration Checks
|
||||
|
||||
If you need to disable specific migration checks (not recommended), you can set the following properties in your `.csproj` file:
|
||||
|
||||
```xml
|
||||
<PropertyGroup>
|
||||
<!-- Disable all migration checks -->
|
||||
<ElectronSkipMigrationChecks>true</ElectronSkipMigrationChecks>
|
||||
</PropertyGroup>
|
||||
```
|
||||
|
||||
> ⚠️ **Warning:** Disabling migration checks may result in build or runtime errors. Only disable checks if you fully understand the implications.
|
||||
|
||||
---
|
||||
|
||||
## See Also
|
||||
|
||||
- [Migration Guide](Migration-Guide.md) - Complete step-by-step migration instructions
|
||||
- [Advanced Migration Topics](Advanced-Migration-Topics.md) - Complex migration scenarios
|
||||
- [Configuration](../Using/Configuration.md) - Project configuration options
|
||||
- [Package Building](../Using/Package-Building.md) - Building distributable packages
|
||||
@@ -49,12 +49,12 @@ Add the Electron.NET configuration to your `.csproj` file:
|
||||
```xml
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ElectronNET.Core" Version="1.0.0" />
|
||||
<PackageReference Include="ElectronNET.Core" Version="0.3.0" />
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
|
||||
74
docs/Using/Custom_main.md
Normal file
74
docs/Using/Custom_main.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# Using custom_main.js
|
||||
|
||||
This guide explains how to include and use a `custom_main.js` file in your Electron.NET application for advanced Electron/Node.js customization.
|
||||
|
||||
## Why use custom_main.js?
|
||||
|
||||
- Register custom protocol handlers (e.g., `myapp://`) — protocols must be registered before the app is fully initialized
|
||||
- Integrate Node.js modules (e.g., telemetry, OS APIs)
|
||||
- Control startup logic (abort, environment checks)
|
||||
- Set up IPC messaging or preload scripts
|
||||
|
||||
## Step-by-Step Process
|
||||
|
||||
### 1. Create the custom_main.js file
|
||||
|
||||
Place your custom logic in `electron/custom_main.js`:
|
||||
|
||||
```javascript
|
||||
module.exports.onStartup = function(host) {
|
||||
// Example: Register a global shortcut for opening dev tools
|
||||
const { app, globalShortcut, BrowserWindow } = require('electron');
|
||||
app.on('ready', () => {
|
||||
const ret = globalShortcut.register('Control+Shift+I', () => {
|
||||
BrowserWindow.getAllWindows().forEach(win => win.webContents.openDevTools());
|
||||
console.log('Ctrl+Shift+I is pressed: DevTools opened!');
|
||||
});
|
||||
});
|
||||
app.on('will-quit', () => {
|
||||
globalShortcut.unregisterAll();
|
||||
});
|
||||
return true;
|
||||
};
|
||||
```
|
||||
|
||||
### 2. Configure your .csproj to copy custom_main.js to output
|
||||
|
||||
Add this to your `.csproj` file:
|
||||
|
||||
```xml
|
||||
<ItemGroup>
|
||||
<None Update="electron\custom_main.js">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<TargetPath>.electron\custom_main.js</TargetPath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
### 3. Build and run your app
|
||||
|
||||
Use the standard build/run commands:
|
||||
|
||||
```powershell
|
||||
dotnet build
|
||||
dotnet run
|
||||
```
|
||||
|
||||
Electron.NET will automatically load and execute your `custom_main.js` before initializing the .NET backend.
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
Use environment variables to control features:
|
||||
|
||||
```javascript
|
||||
const env = process.env.ASPNETCORE_ENVIRONMENT || 'Production';
|
||||
if (env === 'Development') { /* enable dev features */ }
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- `custom_main.js` must use CommonJS syntax (`module.exports.onStartup = ...`).
|
||||
- Place the file in your source directory and copy it to `.electron` using `.csproj`.
|
||||
- Electron.NET will abort startup if `onStartup` returns `false`.
|
||||
|
||||
### Complete example is available here [ElectronNetSampleApp](https://github.com/niteshsinghal85/ElectronNetSampleApp)
|
||||
@@ -26,12 +26,15 @@ Add publish profiles to `Properties/PublishProfiles/`:
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<ProjectGuid>48eff821-2f4d-60cc-aa44-be0f1d6e5f35</ProjectGuid>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
```
|
||||
@@ -46,12 +49,15 @@ Add publish profiles to `Properties/PublishProfiles/`:
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<ProjectGuid>48eff821-2f4d-60cc-aa44-be0f1d6e5f35</ProjectGuid>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
```
|
||||
@@ -68,7 +74,7 @@ Add publish profiles to `Properties/PublishProfiles/`:
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<SelfContained>false</SelfContained>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
@@ -89,7 +95,7 @@ Add publish profiles to `Properties/PublishProfiles/`:
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<SelfContained>false</SelfContained>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
- [What's new?](Core/What's-New.md)
|
||||
- [Migration Guide](Core/Migration-Guide.md)
|
||||
- [Migration Checks](Core/Migration-Checks.md)
|
||||
- [Advanced Migration](Core/Advanced-Migration-Topics.md)
|
||||
|
||||
# Getting Started
|
||||
@@ -23,6 +24,7 @@
|
||||
- [Startup-Methods](Using/Startup-Methods.md)
|
||||
- [Debugging](Using/Debugging.md)
|
||||
- [Package Building](Using/Package-Building.md)
|
||||
- [Adding a `custom_main.js`](Using/Custom_main.md)
|
||||
|
||||
# API Reference
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "8.0.305",
|
||||
"version": "10.0.100",
|
||||
"rollForward": "feature",
|
||||
"allowPrerelease": false
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Nuke.Common;
|
||||
using Nuke.Common.CI.GitHubActions;
|
||||
using Nuke.Common.IO;
|
||||
using Nuke.Common.ProjectModel;
|
||||
using Nuke.Common.Tooling;
|
||||
using Nuke.Common.Tools.DotNet;
|
||||
using Nuke.Common.Tools.GitHub;
|
||||
using Nuke.Common.Tools.NuGet;
|
||||
@@ -15,7 +16,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using static Nuke.Common.IO.FileSystemTasks;
|
||||
using static Nuke.Common.IO.PathConstruction;
|
||||
using static Nuke.Common.Tools.DotNet.DotNetTasks;
|
||||
// ReSharper disable ArrangeThisQualifier
|
||||
@@ -103,7 +103,7 @@ class Build : NukeBuild
|
||||
VersionPostFix = $"-pre";
|
||||
}
|
||||
|
||||
Log.Information("Building version: {Version}", Version);
|
||||
Log.Information("Building version {Version} with postfix {VersionPostFix}", Version, VersionPostFix);
|
||||
}
|
||||
|
||||
Target Clean => _ => _
|
||||
@@ -116,7 +116,7 @@ class Build : NukeBuild
|
||||
Target Restore => _ => _
|
||||
.Executes(() =>
|
||||
{
|
||||
DotNetRestore(s => s.SetProjectFile(Solution.Path));
|
||||
DotNetRestore(s => s.SetProjectFile(Solution));
|
||||
});
|
||||
|
||||
Target Compile => _ => _
|
||||
@@ -124,7 +124,7 @@ class Build : NukeBuild
|
||||
.Executes(() =>
|
||||
{
|
||||
DotNetBuild(s => s
|
||||
.SetProjectFile(Solution.Path)
|
||||
.SetProjectFile(Solution)
|
||||
.SetConfiguration(Configuration)
|
||||
.SetProperty("GeneratePackageOnBuild", "True")
|
||||
.SetProperty("VersionPostFix", VersionPostFix ?? string.Empty));
|
||||
@@ -134,18 +134,17 @@ class Build : NukeBuild
|
||||
.DependsOn(Compile)
|
||||
.Executes(() =>
|
||||
{
|
||||
// There aren't any yet
|
||||
});
|
||||
var TestProject = SourceDirectory / "ElectronNET.IntegrationTests" / "ElectronNET.IntegrationTests.csproj";
|
||||
|
||||
Target CreatePackages => _ => _
|
||||
.DependsOn(Compile)
|
||||
.Executes(() =>
|
||||
{
|
||||
// Packages are created on build
|
||||
DotNetTest(s => s
|
||||
.SetProjectFile(TestProject)
|
||||
.SetConfiguration(Configuration)
|
||||
.When(_ => GitHubActions.Instance is not null, x => x.SetLoggers("GitHubActions"))
|
||||
);
|
||||
});
|
||||
|
||||
Target PublishPackages => _ => _
|
||||
.DependsOn(CreatePackages)
|
||||
.DependsOn(Compile)
|
||||
.DependsOn(RunUnitTests)
|
||||
.Executes(() =>
|
||||
{
|
||||
@@ -240,7 +239,7 @@ class Build : NukeBuild
|
||||
|
||||
Target Package => _ => _
|
||||
.DependsOn(RunUnitTests)
|
||||
.DependsOn(CreatePackages);
|
||||
.DependsOn(Compile);
|
||||
|
||||
Target Default => _ => _
|
||||
.DependsOn(Package);
|
||||
|
||||
@@ -85,7 +85,7 @@ public sealed class ReleaseNotesParser
|
||||
|
||||
// Parse content.
|
||||
var notes = new List<string>();
|
||||
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Sanity checks.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace></RootNamespace>
|
||||
<NoWarn>CS0649;CS0169</NoWarn>
|
||||
<NukeRootDirectory>..</NukeRootDirectory>
|
||||
@@ -11,11 +11,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nuke.Common" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Build" Version="18.0.2" />
|
||||
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="18.0.2" />
|
||||
<PackageReference Include="Nuke.Common" Version="10.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageDownload Include="NuGet.CommandLine" Version="[6.3.1]" />
|
||||
<PackageDownload Include="NuGet.CommandLine" Version="[6.12.2]" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
4
src/.editorconfig
Normal file
4
src/.editorconfig
Normal file
@@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# CA1416: Validate platform compatibility
|
||||
dotnet_diagnostic.CA1416.severity = error
|
||||
380
src/ElectronNET.API/API/ApiBase.cs
Normal file
380
src/ElectronNET.API/API/ApiBase.cs
Normal file
@@ -0,0 +1,380 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
using Common;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public abstract class ApiBase
|
||||
{
|
||||
protected enum SocketTaskEventNameTypes
|
||||
{
|
||||
DashesLowerFirst,
|
||||
NoDashUpperFirst
|
||||
}
|
||||
|
||||
protected enum SocketTaskMessageNameTypes
|
||||
{
|
||||
DashesLowerFirst,
|
||||
NoDashUpperFirst
|
||||
}
|
||||
|
||||
protected enum SocketEventNameTypes
|
||||
{
|
||||
DashedLower,
|
||||
CamelCase,
|
||||
}
|
||||
|
||||
private static readonly TimeSpan InvocationTimeout = 1000.ms();
|
||||
|
||||
private readonly string objectName;
|
||||
private readonly ConcurrentDictionary<string, Invocator> invocators;
|
||||
private readonly ConcurrentDictionary<string, string> invocationEventNames = new();
|
||||
private readonly ConcurrentDictionary<string, string> invocationMessageNames = new();
|
||||
private readonly ConcurrentDictionary<string, string> methodMessageNames = new();
|
||||
private static readonly ConcurrentDictionary<string, EventContainer> eventContainers = new();
|
||||
private static readonly ConcurrentDictionary<string, ConcurrentDictionary<string, Invocator>> AllInvocators = new();
|
||||
|
||||
private readonly object objLock = new object();
|
||||
|
||||
public virtual int Id
|
||||
{
|
||||
get => -1;
|
||||
|
||||
// ReSharper disable once ValueParameterNotUsed
|
||||
protected set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract SocketTaskEventNameTypes SocketTaskEventNameType { get; }
|
||||
protected virtual SocketTaskMessageNameTypes SocketTaskMessageNameType => SocketTaskMessageNameTypes.NoDashUpperFirst;
|
||||
protected virtual SocketEventNameTypes SocketEventNameType => SocketEventNameTypes.DashedLower;
|
||||
|
||||
protected ApiBase()
|
||||
{
|
||||
this.objectName = this.GetType().Name.LowerFirst();
|
||||
this.invocators = AllInvocators.GetOrAdd(this.objectName, _ => new ConcurrentDictionary<string, Invocator>());
|
||||
}
|
||||
|
||||
protected void CallMethod0([CallerMemberName] string callerName = null)
|
||||
{
|
||||
var messageName = this.methodMessageNames.GetOrAdd(callerName, s => this.objectName + s);
|
||||
if (this.Id >= 0)
|
||||
{
|
||||
BridgeConnector.Socket.Emit(messageName, this.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit(messageName);
|
||||
}
|
||||
}
|
||||
|
||||
protected void CallMethod1(object val1, [CallerMemberName] string callerName = null)
|
||||
{
|
||||
var messageName = this.methodMessageNames.GetOrAdd(callerName, s => this.objectName + s);
|
||||
if (this.Id >= 0)
|
||||
{
|
||||
BridgeConnector.Socket.Emit(messageName, this.Id, val1);
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit(messageName, val1);
|
||||
}
|
||||
}
|
||||
|
||||
protected void CallMethod2(object val1, object val2, [CallerMemberName] string callerName = null)
|
||||
{
|
||||
var messageName = this.methodMessageNames.GetOrAdd(callerName, s => this.objectName + s);
|
||||
if (this.Id >= 0)
|
||||
{
|
||||
BridgeConnector.Socket.Emit(messageName, this.Id, val1, val2);
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit(messageName, val1, val2);
|
||||
}
|
||||
}
|
||||
|
||||
protected void CallMethod3(object val1, object val2, object val3, [CallerMemberName] string callerName = null)
|
||||
{
|
||||
var messageName = this.methodMessageNames.GetOrAdd(callerName, s => this.objectName + s);
|
||||
if (this.Id >= 0)
|
||||
{
|
||||
BridgeConnector.Socket.Emit(messageName, this.Id, val1, val2, val3);
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit(messageName, val1, val2, val3);
|
||||
}
|
||||
}
|
||||
|
||||
protected Task<T> InvokeAsync<T>(object arg = null, [CallerMemberName] string callerName = null)
|
||||
{
|
||||
return this.InvokeAsyncWithTimeout<T>(InvocationTimeout, arg, callerName);
|
||||
}
|
||||
|
||||
protected Task<T> InvokeAsyncWithTimeout<T>(TimeSpan invocationTimeout, object arg = null, [CallerMemberName] string callerName = null)
|
||||
{
|
||||
Debug.Assert(callerName != null, nameof(callerName) + " != null");
|
||||
|
||||
lock (this.objLock)
|
||||
{
|
||||
return this.invocators.GetOrAdd(callerName, _ =>
|
||||
{
|
||||
var getter = new Invocator<T>(this, callerName, invocationTimeout, arg);
|
||||
|
||||
getter.Task<T>().ContinueWith(_ =>
|
||||
{
|
||||
lock (this.objLock)
|
||||
{
|
||||
return this.invocators.TryRemove(callerName, out var _);
|
||||
}
|
||||
});
|
||||
|
||||
return getter;
|
||||
}).Task<T>();
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddEvent(Action value, int? id = null, [CallerMemberName] string callerName = null)
|
||||
{
|
||||
Debug.Assert(callerName != null, nameof(callerName) + " != null");
|
||||
var eventName = this.EventName(callerName);
|
||||
|
||||
var eventKey = this.EventKey(eventName, id);
|
||||
|
||||
lock (this.objLock)
|
||||
{
|
||||
var container = eventContainers.GetOrAdd(eventKey, _ =>
|
||||
{
|
||||
var container = new EventContainer();
|
||||
BridgeConnector.Socket.On(eventKey, container.OnEventAction);
|
||||
BridgeConnector.Socket.Emit($"register-{eventName}", id);
|
||||
return container;
|
||||
});
|
||||
|
||||
container.Register(value);
|
||||
}
|
||||
}
|
||||
|
||||
protected void RemoveEvent(Action value, int? id = null, [CallerMemberName] string callerName = null)
|
||||
{
|
||||
Debug.Assert(callerName != null, nameof(callerName) + " != null");
|
||||
var eventName = this.EventName(callerName);
|
||||
var eventKey = this.EventKey(eventName, id);
|
||||
|
||||
lock (this.objLock)
|
||||
{
|
||||
if (eventContainers.TryGetValue(eventKey, out var container) && !container.Unregister(value))
|
||||
{
|
||||
BridgeConnector.Socket.Off(eventKey);
|
||||
eventContainers.TryRemove(eventKey, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddEvent<T>(Action<T> value, int? id = null, [CallerMemberName] string callerName = null)
|
||||
{
|
||||
Debug.Assert(callerName != null, nameof(callerName) + " != null");
|
||||
|
||||
var eventName = this.EventName(callerName);
|
||||
var eventKey = this.EventKey(eventName, id);
|
||||
|
||||
lock (this.objLock)
|
||||
{
|
||||
var container = eventContainers.GetOrAdd(eventKey, _ =>
|
||||
{
|
||||
var container = new EventContainer();
|
||||
BridgeConnector.Socket.On<T>(eventKey, container.OnEventActionT);
|
||||
BridgeConnector.Socket.Emit($"register-{eventName}", id);
|
||||
return container;
|
||||
});
|
||||
|
||||
container.Register(value);
|
||||
}
|
||||
}
|
||||
|
||||
protected void RemoveEvent<T>(Action<T> value, int? id = null, [CallerMemberName] string callerName = null)
|
||||
{
|
||||
Debug.Assert(callerName != null, nameof(callerName) + " != null");
|
||||
var eventName = this.EventName(callerName);
|
||||
var eventKey = this.EventKey(eventName, id);
|
||||
|
||||
lock (this.objLock)
|
||||
{
|
||||
if (eventContainers.TryGetValue(eventKey, out var container) && !container.Unregister(value))
|
||||
{
|
||||
BridgeConnector.Socket.Off(eventKey);
|
||||
eventContainers.TryRemove(eventKey, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string EventName(string callerName)
|
||||
{
|
||||
switch (this.SocketEventNameType)
|
||||
{
|
||||
case SocketEventNameTypes.DashedLower:
|
||||
return $"{this.objectName}-{callerName.ToDashedEventName()}";
|
||||
case SocketEventNameTypes.CamelCase:
|
||||
return $"{this.objectName}-{callerName.ToCamelCaseEventName()}";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private string EventKey(string eventName, int? id)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}{1:D}", eventName, id);
|
||||
}
|
||||
|
||||
internal abstract class Invocator
|
||||
{
|
||||
public abstract Task<T> Task<T>();
|
||||
}
|
||||
|
||||
internal class Invocator<T> : Invocator
|
||||
{
|
||||
private readonly Task<T> tcsTask;
|
||||
private TaskCompletionSource<T> tcs;
|
||||
|
||||
public Invocator(ApiBase apiBase, string callerName, TimeSpan timeout, object arg = null)
|
||||
{
|
||||
this.tcs = new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
this.tcsTask = this.tcs.Task;
|
||||
|
||||
string eventName;
|
||||
string messageName;
|
||||
|
||||
switch (apiBase.SocketTaskEventNameType)
|
||||
{
|
||||
case SocketTaskEventNameTypes.DashesLowerFirst:
|
||||
eventName = apiBase.invocationEventNames.GetOrAdd(callerName, s => $"{apiBase.objectName}-{s.StripAsync().LowerFirst()}-completed");
|
||||
break;
|
||||
case SocketTaskEventNameTypes.NoDashUpperFirst:
|
||||
eventName = apiBase.invocationEventNames.GetOrAdd(callerName, s => $"{apiBase.objectName}{s.StripAsync()}Completed");
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
switch (apiBase.SocketTaskMessageNameType)
|
||||
{
|
||||
case SocketTaskMessageNameTypes.DashesLowerFirst:
|
||||
messageName = apiBase.invocationMessageNames.GetOrAdd(callerName, s => $"{apiBase.objectName}-{s.StripAsync().LowerFirst()}");
|
||||
break;
|
||||
case SocketTaskMessageNameTypes.NoDashUpperFirst:
|
||||
messageName = apiBase.invocationMessageNames.GetOrAdd(callerName, s => apiBase.objectName + s.StripAsync());
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
BridgeConnector.Socket.Once<T>(eventName, (result) =>
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
try
|
||||
{
|
||||
var value = result;
|
||||
this.tcs?.SetResult(value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.tcs?.TrySetException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.tcs = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (arg != null)
|
||||
{
|
||||
_ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id, arg) : BridgeConnector.Socket.Emit(messageName, arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id) : BridgeConnector.Socket.Emit(messageName);
|
||||
}
|
||||
|
||||
System.Threading.Tasks.Task.Delay(timeout).ContinueWith(_ =>
|
||||
{
|
||||
if (this.tcs != null)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (this.tcs != null)
|
||||
{
|
||||
var ex = new TimeoutException($"No response after {timeout:D}ms trying to retrieve value {apiBase.objectName}.{callerName}()");
|
||||
this.tcs.TrySetException(ex);
|
||||
this.tcs = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public override Task<T1> Task<T1>()
|
||||
{
|
||||
return this.tcsTask as Task<T1>;
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentlySynchronizedField")]
|
||||
private class EventContainer
|
||||
{
|
||||
private Action eventAction;
|
||||
private Delegate eventActionT;
|
||||
|
||||
private Action<T> GetEventActionT<T>()
|
||||
{
|
||||
return (Action<T>)this.eventActionT;
|
||||
}
|
||||
|
||||
private void SetEventActionT<T>(Action<T> actionT)
|
||||
{
|
||||
this.eventActionT = actionT;
|
||||
}
|
||||
|
||||
public void OnEventAction() => this.eventAction?.Invoke();
|
||||
|
||||
public void OnEventActionT<T>(T p) => this.GetEventActionT<T>()?.Invoke(p);
|
||||
|
||||
public void Register(Action receiver)
|
||||
{
|
||||
this.eventAction += receiver;
|
||||
}
|
||||
|
||||
public void Register<T>(Action<T> receiver)
|
||||
{
|
||||
var actionT = this.GetEventActionT<T>();
|
||||
actionT += receiver;
|
||||
this.SetEventActionT(actionT);
|
||||
}
|
||||
|
||||
public bool Unregister(Action receiver)
|
||||
{
|
||||
this.eventAction -= receiver;
|
||||
return this.eventAction != null;
|
||||
}
|
||||
|
||||
public bool Unregister<T>(Action<T> receiver)
|
||||
{
|
||||
var actionT = this.GetEventActionT<T>();
|
||||
actionT -= receiver;
|
||||
this.SetEventActionT(actionT);
|
||||
|
||||
return actionT != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,21 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
/// Enable apps to automatically update themselves. Based on electron-updater.
|
||||
/// </summary>
|
||||
public sealed class AutoUpdater
|
||||
public sealed class AutoUpdater : ApiBase
|
||||
{
|
||||
protected override SocketTaskEventNameTypes SocketTaskEventNameType => SocketTaskEventNameTypes.DashesLowerFirst;
|
||||
protected override SocketTaskMessageNameTypes SocketTaskMessageNameType => SocketTaskMessageNameTypes.DashesLowerFirst;
|
||||
protected override SocketEventNameTypes SocketEventNameType => SocketEventNameTypes.DashedLower;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to automatically download an update when it is found. (Default is true)
|
||||
/// </summary>
|
||||
@@ -20,20 +23,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-autoDownload-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-autoDownload-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
return Task.Run(() => this.InvokeAsync<bool>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -50,20 +40,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-autoInstallOnAppQuit-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-autoInstallOnAppQuit-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
return Task.Run(() => this.InvokeAsync<bool>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -72,7 +49,7 @@ namespace ElectronNET.API
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// *GitHub provider only.* Whether to allow update to pre-release versions.
|
||||
/// *GitHub provider only.* Whether to allow update to pre-release versions.
|
||||
/// Defaults to "true" if application version contains prerelease components (e.g. "0.12.1-alpha.1", here "alpha" is a prerelease component), otherwise "false".
|
||||
///
|
||||
/// If "true", downgrade will be allowed("allowDowngrade" will be set to "true").
|
||||
@@ -81,20 +58,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-allowPrerelease-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-allowPrerelease-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
return Task.Run(() => this.InvokeAsync<bool>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -103,27 +67,14 @@ namespace ElectronNET.API
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// *GitHub provider only.*
|
||||
/// *GitHub provider only.*
|
||||
/// Get all release notes (from current version to latest), not just the latest (Default is false).
|
||||
/// </summary>
|
||||
public bool FullChangelog
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-fullChangelog-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-fullChangelog-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
return Task.Run(() => this.InvokeAsync<bool>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -140,20 +91,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<bool>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-allowDowngrade-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-allowDowngrade-get-reply");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
return Task.Run(() => this.InvokeAsync<bool>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -168,20 +106,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<string>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-updateConfigPath-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-updateConfigPath-get-reply");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdater-updateConfigPath-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
return Task.Run(() => this.InvokeAsync<string>()).Result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,25 +117,12 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<SemVer>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<SemVer>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-currentVersion-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-currentVersion-get-reply");
|
||||
SemVer version = ((JObject)result).ToObject<SemVer>();
|
||||
taskCompletionSource.SetResult(version);
|
||||
});
|
||||
BridgeConnector.Socket.Emit("autoUpdater-currentVersion-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
});
|
||||
return Task.Run(() => this.InvokeAsync<SemVer>());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the update channel. Not applicable for GitHub.
|
||||
/// Get the update channel. Not applicable for GitHub.
|
||||
/// Doesn’t return channel from the update configuration, only if was previously set.
|
||||
/// </summary>
|
||||
[Obsolete("Use the asynchronous version ChannelAsync instead")]
|
||||
@@ -223,29 +135,27 @@ namespace ElectronNET.API
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the update channel. Not applicable for GitHub.
|
||||
/// Get the update channel. Not applicable for GitHub.
|
||||
/// Doesn’t return channel from the update configuration, only if was previously set.
|
||||
/// </summary>
|
||||
public Task<string> ChannelAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<string>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdater-channel-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-channel-get-reply");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
});
|
||||
BridgeConnector.Socket.Emit("autoUpdater-channel-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
});
|
||||
return Task.Run(() => this.InvokeAsync<string>());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the update channel. Not applicable for GitHub.
|
||||
/// </summary>
|
||||
public string SetChannel
|
||||
{
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("autoUpdater-channel-set", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -255,18 +165,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Dictionary<string, string>>();
|
||||
BridgeConnector.Socket.On("autoUpdater-requestHeaders-get-reply", (headers) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdater-requestHeaders-get-reply");
|
||||
Dictionary<string, string> result = ((JObject)headers).ToObject<Dictionary<string, string>>();
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-get");
|
||||
return taskCompletionSource.Task;
|
||||
});
|
||||
return Task.Run(() => this.InvokeAsync<Dictionary<string, string>>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +176,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", JObject.FromObject(value, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,180 +185,62 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public event Action<string> OnError
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_error == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-error" + GetHashCode(), (message) =>
|
||||
{
|
||||
_error(message.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-error-event", GetHashCode());
|
||||
}
|
||||
_error += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_error -= value;
|
||||
|
||||
if (_error == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-error" + GetHashCode());
|
||||
}
|
||||
add => AddEvent(value, GetHashCode());
|
||||
remove => RemoveEvent(value, GetHashCode());
|
||||
}
|
||||
|
||||
private event Action<string> _error;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when checking if an update has started.
|
||||
/// </summary>
|
||||
public event Action OnCheckingForUpdate
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_checkingForUpdate == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-checking-for-update" + GetHashCode(), () =>
|
||||
{
|
||||
_checkingForUpdate();
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-checking-for-update-event", GetHashCode());
|
||||
}
|
||||
_checkingForUpdate += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_checkingForUpdate -= value;
|
||||
|
||||
if (_checkingForUpdate == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-checking-for-update" + GetHashCode());
|
||||
}
|
||||
add => AddEvent(value, GetHashCode());
|
||||
remove => RemoveEvent(value, GetHashCode());
|
||||
}
|
||||
|
||||
private event Action _checkingForUpdate;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when there is an available update.
|
||||
/// Emitted when there is an available update.
|
||||
/// The update is downloaded automatically if AutoDownload is true.
|
||||
/// </summary>
|
||||
public event Action<UpdateInfo> OnUpdateAvailable
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_updateAvailable == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-update-available" + GetHashCode(), (updateInfo) =>
|
||||
{
|
||||
_updateAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-update-available-event", GetHashCode());
|
||||
}
|
||||
_updateAvailable += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_updateAvailable -= value;
|
||||
|
||||
if (_updateAvailable == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-update-available" + GetHashCode());
|
||||
}
|
||||
add => AddEvent(value, GetHashCode());
|
||||
remove => RemoveEvent(value, GetHashCode());
|
||||
}
|
||||
|
||||
private event Action<UpdateInfo> _updateAvailable;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when there is no available update.
|
||||
/// </summary>
|
||||
public event Action<UpdateInfo> OnUpdateNotAvailable
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_updateNotAvailable == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-update-not-available" + GetHashCode(), (updateInfo) =>
|
||||
{
|
||||
_updateNotAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-update-not-available-event", GetHashCode());
|
||||
}
|
||||
_updateNotAvailable += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_updateNotAvailable -= value;
|
||||
|
||||
if (_updateNotAvailable == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-update-not-available" + GetHashCode());
|
||||
}
|
||||
add => AddEvent(value, GetHashCode());
|
||||
remove => RemoveEvent(value, GetHashCode());
|
||||
}
|
||||
|
||||
private event Action<UpdateInfo> _updateNotAvailable;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted on download progress.
|
||||
/// </summary>
|
||||
public event Action<ProgressInfo> OnDownloadProgress
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_downloadProgress == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-download-progress" + GetHashCode(), (progressInfo) =>
|
||||
{
|
||||
_downloadProgress(JObject.Parse(progressInfo.ToString()).ToObject<ProgressInfo>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-download-progress-event", GetHashCode());
|
||||
}
|
||||
_downloadProgress += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_downloadProgress -= value;
|
||||
|
||||
if (_downloadProgress == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-download-progress" + GetHashCode());
|
||||
}
|
||||
add => AddEvent(value, GetHashCode());
|
||||
remove => RemoveEvent(value, GetHashCode());
|
||||
}
|
||||
|
||||
private event Action<ProgressInfo> _downloadProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Emitted on download complete.
|
||||
/// </summary>
|
||||
public event Action<UpdateInfo> OnUpdateDownloaded
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_updateDownloaded == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("autoUpdater-update-downloaded" + GetHashCode(), (updateInfo) =>
|
||||
{
|
||||
_updateDownloaded(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-autoUpdater-update-downloaded-event", GetHashCode());
|
||||
}
|
||||
_updateDownloaded += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_updateDownloaded -= value;
|
||||
|
||||
if (_updateDownloaded == null)
|
||||
BridgeConnector.Socket.Off("autoUpdater-update-downloaded" + GetHashCode());
|
||||
}
|
||||
add => AddEvent(value, GetHashCode());
|
||||
remove => RemoveEvent(value, GetHashCode());
|
||||
}
|
||||
|
||||
private event Action<UpdateInfo> _updateDownloaded;
|
||||
|
||||
private static AutoUpdater _autoUpdater;
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal AutoUpdater() { }
|
||||
internal AutoUpdater()
|
||||
{
|
||||
}
|
||||
|
||||
internal static AutoUpdater Instance
|
||||
{
|
||||
@@ -489,30 +270,27 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<UpdateCheckResult>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesComplete" + guid, (updateCheckResult) =>
|
||||
BridgeConnector.Socket.Once<UpdateCheckResult>("autoUpdater-checkForUpdates-completed" + guid, (result) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
|
||||
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
|
||||
BridgeConnector.Socket.Off("autoUpdater-checkForUpdatesError" + guid);
|
||||
taskCompletionSource.SetResult(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
taskCompletionSource.SetException(ex);
|
||||
}
|
||||
});
|
||||
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesError" + guid, (error) =>
|
||||
BridgeConnector.Socket.Once<string>("autoUpdater-checkForUpdatesError" + guid, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
|
||||
BridgeConnector.Socket.Off("autoUpdater-checkForUpdates-completed" + guid);
|
||||
string message = "An error occurred in CheckForUpdatesAsync";
|
||||
if (error != null && !string.IsNullOrEmpty(error.ToString()))
|
||||
message = JsonConvert.SerializeObject(error);
|
||||
if (!string.IsNullOrEmpty(result)) message = result;
|
||||
taskCompletionSource.SetException(new Exception(message));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdates", guid);
|
||||
BridgeConnector.Socket.Emit("autoUpdater-checkForUpdates", guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -528,49 +306,43 @@ namespace ElectronNET.API
|
||||
var taskCompletionSource = new TaskCompletionSource<UpdateCheckResult>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid, (updateCheckResult) =>
|
||||
BridgeConnector.Socket.Once<UpdateCheckResult>("autoUpdater-checkForUpdatesAndNotify-completed" + guid, (result) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
|
||||
if (updateCheckResult == null)
|
||||
taskCompletionSource.SetResult(null);
|
||||
else
|
||||
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
|
||||
BridgeConnector.Socket.Off("autoUpdater-checkForUpdatesAndNotifyError" + guid);
|
||||
taskCompletionSource.SetResult(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
taskCompletionSource.SetException(ex);
|
||||
}
|
||||
});
|
||||
BridgeConnector.Socket.On("autoUpdaterCheckForUpdatesAndNotifyError" + guid, (error) =>
|
||||
BridgeConnector.Socket.Once<string>("autoUpdater-checkForUpdatesAndNotifyError" + guid, (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
|
||||
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
|
||||
string message = "An error occurred in autoUpdaterCheckForUpdatesAndNotify";
|
||||
if (error != null)
|
||||
message = JsonConvert.SerializeObject(error);
|
||||
BridgeConnector.Socket.Off("autoUpdater-checkForUpdatesAndNotify-completed" + guid);
|
||||
string message = "An error occurred in CheckForUpdatesAndNotifyAsync";
|
||||
if (!string.IsNullOrEmpty(result)) message = result;
|
||||
taskCompletionSource.SetException(new Exception(message));
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdatesAndNotify", guid);
|
||||
BridgeConnector.Socket.Emit("autoUpdater-checkForUpdatesAndNotify", guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restarts the app and installs the update after it has been downloaded.
|
||||
/// It should only be called after `update-downloaded` has been emitted.
|
||||
///
|
||||
/// Note: QuitAndInstall() will close all application windows first and only emit `before-quit` event on `app` after that.
|
||||
/// This is different from the normal quit event sequence.
|
||||
/// Restarts the app and installs the update after it has been downloaded.
|
||||
/// It should only be called after `update-downloaded` has been emitted.
|
||||
///
|
||||
/// Note: QuitAndInstall() will close all application windows first and only emit `before-quit` event on `app` after that.
|
||||
/// This is different from the normal quit event sequence.
|
||||
/// </summary>
|
||||
/// <param name="isSilent">*windows-only* Runs the installer in silent mode. Defaults to `false`.</param>
|
||||
/// <param name="isForceRunAfter">Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.</param>
|
||||
public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
|
||||
BridgeConnector.Socket.Emit("autoUpdater-quitAndInstall", isSilent, isForceRunAfter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -579,18 +351,13 @@ namespace ElectronNET.API
|
||||
/// <returns>Path to downloaded file.</returns>
|
||||
public Task<string> DownloadUpdateAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPath) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterDownloadUpdateComplete" + guid);
|
||||
taskCompletionSource.SetResult(downloadedPath.ToString());
|
||||
});
|
||||
BridgeConnector.Socket.Once<string>("autoUpdater-downloadUpdate-completed" + guid, tcs.SetResult);
|
||||
BridgeConnector.Socket.Emit("autoUpdater-downloadUpdate", guid);
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdaterDownloadUpdate", guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -599,23 +366,13 @@ namespace ElectronNET.API
|
||||
/// <returns>Feed URL.</returns>
|
||||
public Task<string> GetFeedURLAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("autoUpdaterGetFeedURLComplete" + guid, (downloadedPath) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("autoUpdaterGetFeedURLComplete" + guid);
|
||||
taskCompletionSource.SetResult(downloadedPath.ToString());
|
||||
});
|
||||
BridgeConnector.Socket.Once<string>("autoUpdater-getFeedURL-completed" + guid, tcs.SetResult);
|
||||
BridgeConnector.Socket.Emit("autoUpdater-getFeedURL", guid);
|
||||
|
||||
BridgeConnector.Socket.Emit("autoUpdaterGetFeedURL", guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,22 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
|
||||
/// It is like a child window, except that it is positioned relative to its owning window.
|
||||
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
|
||||
/// It is like a child window, except that it is positioned relative to its owning window.
|
||||
/// It is meant to be an alternative to the webview tag.
|
||||
/// </summary>
|
||||
public class BrowserView
|
||||
public class BrowserView : ApiBase
|
||||
{
|
||||
protected override SocketTaskEventNameTypes SocketTaskEventNameType => SocketTaskEventNameTypes.DashesLowerFirst;
|
||||
protected override SocketTaskMessageNameTypes SocketTaskMessageNameType => SocketTaskMessageNameTypes.DashesLowerFirst;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identifier.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The identifier.
|
||||
/// </value>
|
||||
public int Id { get; internal set; }
|
||||
public override int Id { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Render and control web pages.
|
||||
@@ -28,38 +25,24 @@ namespace ElectronNET.API
|
||||
|
||||
/// <summary>
|
||||
/// Resizes and moves the view to the supplied bounds relative to the window.
|
||||
///
|
||||
/// (experimental)
|
||||
/// </summary>
|
||||
public Rectangle Bounds
|
||||
{
|
||||
get
|
||||
{
|
||||
return Task.Run<Rectangle>(() =>
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Rectangle>();
|
||||
|
||||
BridgeConnector.Socket.On("browserView-getBounds-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("browserView-getBounds-reply");
|
||||
taskCompletionSource.SetResult((Rectangle)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("browserView-getBounds", Id);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}).Result;
|
||||
return Task.Run(() => this.InvokeAsync<Rectangle>()).Result;
|
||||
}
|
||||
set
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("browserView-bounds-set", Id, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BrowserView
|
||||
/// </summary>
|
||||
internal BrowserView(int id)
|
||||
internal BrowserView(int id)
|
||||
{
|
||||
Id = id;
|
||||
|
||||
@@ -74,12 +57,11 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public void SetAutoResize(AutoResizeOptions options)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color in #aarrggbb or #argb form. The alpha channel is optional.
|
||||
///
|
||||
/// (experimental)
|
||||
/// </summary>
|
||||
/// <param name="color">Color in #aarrggbb or #argb form. The alpha channel is optional.</param>
|
||||
@@ -87,11 +69,5 @@ namespace ElectronNET.API
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserView-setBackgroundColor", Id, color);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,27 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Serialization;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
/// Perform copy and paste operations on the system clipboard.
|
||||
/// </summary>
|
||||
public sealed class Clipboard
|
||||
public sealed class Clipboard : ApiBase
|
||||
{
|
||||
protected override SocketTaskEventNameTypes SocketTaskEventNameType => SocketTaskEventNameTypes.DashesLowerFirst;
|
||||
protected override SocketTaskMessageNameTypes SocketTaskMessageNameType => SocketTaskMessageNameTypes.DashesLowerFirst;
|
||||
|
||||
private static Clipboard _clipboard;
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal Clipboard() { }
|
||||
internal Clipboard()
|
||||
{
|
||||
}
|
||||
|
||||
internal static Clipboard Instance
|
||||
{
|
||||
@@ -40,21 +47,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns>The content in the clipboard as plain text.</returns>
|
||||
public Task<string> ReadTextAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readText-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readText-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readText", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string> ReadTextAsync(string type = "") => this.InvokeAsync<string>(type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text into the clipboard as plain text.
|
||||
@@ -71,21 +64,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> ReadHTMLAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readHTML-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readHTML-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readHTML", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string> ReadHTMLAsync(string type = "") => this.InvokeAsync<string>(type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes markup to the clipboard.
|
||||
@@ -102,21 +81,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> ReadRTFAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readRTF-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readRTF-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readRTF", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string> ReadRTFAsync(string type = "") => this.InvokeAsync<string>(type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text into the clipboard in RTF.
|
||||
@@ -125,41 +90,31 @@ namespace ElectronNET.API
|
||||
/// <param name="type"></param>
|
||||
public void WriteRTF(string text, string type = "")
|
||||
{
|
||||
BridgeConnector.Socket.Emit("clipboard-writeHTML", text, type);
|
||||
BridgeConnector.Socket.Emit("clipboard-writeRTF", text, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an Object containing title and url keys representing
|
||||
/// the bookmark in the clipboard. The title and url values will
|
||||
/// Returns an Object containing title and url keys representing
|
||||
/// the bookmark in the clipboard. The title and url values will
|
||||
/// be empty strings when the bookmark is unavailable.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<ReadBookmark> ReadBookmarkAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<ReadBookmark>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readBookmark-Completed", (bookmark) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readBookmark-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(((JObject)bookmark).ToObject<ReadBookmark>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readBookmark");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
[SupportedOSPlatform("macOS")]
|
||||
[SupportedOSPlatform("Windows")]
|
||||
public Task<ReadBookmark> ReadBookmarkAsync() => this.InvokeAsync<ReadBookmark>();
|
||||
|
||||
/// <summary>
|
||||
/// Writes the title and url into the clipboard as a bookmark.
|
||||
///
|
||||
/// Note: Most apps on Windows don’t support pasting bookmarks
|
||||
/// into them so you can use clipboard.write to write both a
|
||||
/// into them so you can use clipboard.write to write both a
|
||||
/// bookmark and fallback text to the clipboard.
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="type"></param>
|
||||
[SupportedOSPlatform("macOS")]
|
||||
[SupportedOSPlatform("Windows")]
|
||||
public void WriteBookmark(string title, string url, string type = "")
|
||||
{
|
||||
BridgeConnector.Socket.Emit("clipboard-writeBookmark", title, url, type);
|
||||
@@ -171,27 +126,15 @@ namespace ElectronNET.API
|
||||
/// find pasteboard whenever the application is activated.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<string> ReadFindTextAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readFindText-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readFindText-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readFindText");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
[SupportedOSPlatform("macOS")]
|
||||
public Task<string> ReadFindTextAsync() => this.InvokeAsync<string>();
|
||||
|
||||
/// <summary>
|
||||
/// macOS: Writes the text into the find pasteboard as plain text. This method uses
|
||||
/// macOS: Writes the text into the find pasteboard as plain text. This method uses
|
||||
/// synchronous IPC when called from the renderer process.
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
[SupportedOSPlatform("macOS")]
|
||||
public void WriteFindText(string text)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("clipboard-writeFindText", text);
|
||||
@@ -211,21 +154,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string[]> AvailableFormatsAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string[]>();
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-availableFormats-Completed", (formats) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-availableFormats-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(((JArray)formats).ToObject<string[]>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-availableFormats", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string[]> AvailableFormatsAsync(string type = "") => this.InvokeAsync<string[]>(type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes data to the clipboard.
|
||||
@@ -234,7 +163,7 @@ namespace ElectronNET.API
|
||||
/// <param name="type"></param>
|
||||
public void Write(Data data, string type = "")
|
||||
{
|
||||
BridgeConnector.Socket.Emit("clipboard-write", JObject.FromObject(data, _jsonSerializer), type);
|
||||
BridgeConnector.Socket.Emit("clipboard-write", data, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -242,25 +171,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<NativeImage> ReadImageAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<NativeImage>();
|
||||
public Task<NativeImage> ReadImageAsync(string type = "") => this.InvokeAsync<NativeImage>(type);
|
||||
|
||||
BridgeConnector.Socket.On("clipboard-readImage-Completed", (image) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("clipboard-readImage-Completed");
|
||||
|
||||
var nativeImage = ((JObject)image).ToObject<NativeImage>();
|
||||
|
||||
taskCompletionSource.SetResult(nativeImage);
|
||||
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("clipboard-readImage", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an image to the clipboard.
|
||||
/// </summary>
|
||||
@@ -268,14 +180,7 @@ namespace ElectronNET.API
|
||||
/// <param name="type"></param>
|
||||
public void WriteImage(NativeImage image, string type = "")
|
||||
{
|
||||
BridgeConnector.Socket.Emit("clipboard-writeImage", JsonConvert.SerializeObject(image), type);
|
||||
BridgeConnector.Socket.Emit("clipboard-writeImage", JsonSerializer.Serialize(image, ElectronJson.Options), type);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,9 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public sealed class CommandLine
|
||||
{
|
||||
internal CommandLine() { }
|
||||
internal CommandLine()
|
||||
{
|
||||
}
|
||||
|
||||
internal static CommandLine Instance
|
||||
{
|
||||
@@ -66,22 +68,17 @@ namespace ElectronNET.API
|
||||
/// <param name="switchName">A command-line switch</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>Whether the command-line switch is present.</returns>
|
||||
public async Task<bool> HasSwitchAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> HasSwitchAsync(string switchName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => tcs.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appCommandLineHasSwitchCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appCommandLineHasSwitchCompleted");
|
||||
taskCompletionSource.SetResult((bool)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Once<bool>("appCommandLineHasSwitchCompleted", tcs.SetResult);
|
||||
BridgeConnector.Socket.Emit("appCommandLineHasSwitch", switchName);
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
return await tcs.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,23 +91,18 @@ namespace ElectronNET.API
|
||||
/// <remarks>
|
||||
/// Note: When the switch is not present or has no value, it returns empty string.
|
||||
/// </remarks>
|
||||
public async Task<string> GetSwitchValueAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<string> GetSwitchValueAsync(string switchName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
using (cancellationToken.Register(() => tcs.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("appCommandLineGetSwitchValueCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("appCommandLineGetSwitchValueCompleted");
|
||||
taskCompletionSource.SetResult((string)result);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Once<string>("appCommandLineGetSwitchValueCompleted", tcs.SetResult);
|
||||
BridgeConnector.Socket.Emit("appCommandLineGetSwitchValue", switchName);
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
return await tcs.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Serialization;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -34,16 +32,21 @@ namespace ElectronNET.API
|
||||
{
|
||||
if (_changed == null)
|
||||
{
|
||||
BridgeConnector.Socket.On("webContents-session-cookies-changed" + Id, (args) =>
|
||||
BridgeConnector.Socket.On<JsonElement>("webContents-session-cookies-changed" + Id, (args) =>
|
||||
{
|
||||
Cookie cookie = ((JArray)args)[0].ToObject<Cookie>();
|
||||
CookieChangedCause cause = ((JArray)args)[1].ToObject<CookieChangedCause>();
|
||||
bool removed = ((JArray)args)[2].ToObject<bool>();
|
||||
var e = args.EnumerateArray().GetEnumerator();
|
||||
e.MoveNext();
|
||||
var cookie = e.Current.Deserialize<Cookie>(ElectronJson.Options);
|
||||
e.MoveNext();
|
||||
var cause = e.Current.Deserialize<CookieChangedCause>(ElectronJson.Options);
|
||||
e.MoveNext();
|
||||
var removed = e.Current.GetBoolean();
|
||||
_changed(cookie, cause, removed);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Emit("register-webContents-session-cookies-changed", Id);
|
||||
}
|
||||
|
||||
_changed += value;
|
||||
}
|
||||
remove
|
||||
@@ -56,12 +59,5 @@ namespace ElectronNET.API
|
||||
}
|
||||
|
||||
private event Action<Cookie, CookieChangedCause, bool> _changed;
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
using ElectronNET.API.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ElectronNET.API.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -16,7 +14,9 @@ namespace ElectronNET.API
|
||||
private static Dialog _dialog;
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
internal Dialog() { }
|
||||
internal Dialog()
|
||||
{
|
||||
}
|
||||
|
||||
internal static Dialog Instance
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if(_dialog == null)
|
||||
if (_dialog == null)
|
||||
{
|
||||
_dialog = new Dialog();
|
||||
}
|
||||
@@ -38,8 +38,8 @@ namespace ElectronNET.API
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Note: On Windows and Linux an open dialog can not be both a file selector
|
||||
/// and a directory selector, so if you set properties to ['openFile', 'openDirectory']
|
||||
/// Note: On Windows and Linux an open dialog can not be both a file selector
|
||||
/// and a directory selector, so if you set properties to ['openFile', 'openDirectory']
|
||||
/// on these platforms, a directory selector will be shown.
|
||||
/// </summary>
|
||||
/// <param name="browserWindow">The browserWindow argument allows the dialog to attach itself to a parent window, making it modal.</param>
|
||||
@@ -47,23 +47,16 @@ namespace ElectronNET.API
|
||||
/// <returns>An array of file paths chosen by the user</returns>
|
||||
public Task<string[]> ShowOpenDialogAsync(BrowserWindow browserWindow, OpenDialogOptions options)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string[]>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("showOpenDialogComplete" + guid, (filePaths) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("showOpenDialogComplete" + guid);
|
||||
|
||||
var result = ((JArray)filePaths).ToObject<string[]>();
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
var tcs = new TaskCompletionSource<string[]>();
|
||||
var guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.Once<string[]>("showOpenDialogComplete" + guid, tcs.SetResult);
|
||||
BridgeConnector.Socket.Emit("showOpenDialog",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(options, _jsonSerializer), guid);
|
||||
browserWindow,
|
||||
options,
|
||||
guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -74,22 +67,16 @@ namespace ElectronNET.API
|
||||
/// <returns>Returns String, the path of the file chosen by the user, if a callback is provided it returns an empty string.</returns>
|
||||
public Task<string> ShowSaveDialogAsync(BrowserWindow browserWindow, SaveDialogOptions options)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("showSaveDialogComplete" + guid, (filename) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("showSaveDialogComplete" + guid);
|
||||
|
||||
taskCompletionSource.SetResult(filename.ToString());
|
||||
});
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
var guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.Once<string>("showSaveDialogComplete" + guid, tcs.SetResult);
|
||||
BridgeConnector.Socket.Emit("showSaveDialog",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(options, _jsonSerializer),
|
||||
guid);
|
||||
browserWindow,
|
||||
options,
|
||||
guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -143,43 +130,47 @@ namespace ElectronNET.API
|
||||
/// <returns>The API call will be asynchronous and the result will be passed via MessageBoxResult.</returns>
|
||||
public Task<MessageBoxResult> ShowMessageBoxAsync(BrowserWindow browserWindow, MessageBoxOptions messageBoxOptions)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<MessageBoxResult>();
|
||||
var tcs = new TaskCompletionSource<MessageBoxResult>();
|
||||
var guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("showMessageBoxComplete" + guid, (args) =>
|
||||
BridgeConnector.Socket.Once<JsonElement>("showMessageBoxComplete" + guid, (args) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("showMessageBoxComplete" + guid);
|
||||
// args is [response:int, checkboxChecked:boolean]
|
||||
var arr = args.EnumerateArray();
|
||||
var e = arr.GetEnumerator();
|
||||
e.MoveNext();
|
||||
var response = e.Current.GetInt32();
|
||||
e.MoveNext();
|
||||
var checkbox = e.Current.GetBoolean();
|
||||
|
||||
var result = ((JArray)args);
|
||||
|
||||
taskCompletionSource.SetResult(new MessageBoxResult
|
||||
tcs.SetResult(new MessageBoxResult
|
||||
{
|
||||
Response = (int)result.First,
|
||||
CheckboxChecked = (bool)result.Last
|
||||
Response = response,
|
||||
CheckboxChecked = checkbox
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
if (browserWindow == null)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("showMessageBox", JObject.FromObject(messageBoxOptions, _jsonSerializer), guid);
|
||||
} else
|
||||
BridgeConnector.Socket.Emit("showMessageBox", messageBoxOptions, guid);
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("showMessageBox",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(messageBoxOptions, _jsonSerializer),
|
||||
BridgeConnector.Socket.Emit("showMessageBox",
|
||||
browserWindow,
|
||||
messageBoxOptions,
|
||||
guid);
|
||||
}
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a modal dialog that shows an error message.
|
||||
///
|
||||
/// This API can be called safely before the ready event the app module emits,
|
||||
/// it is usually used to report errors in early stage of startup.If called
|
||||
/// before the app readyevent on Linux, the message will be emitted to stderr,
|
||||
/// This API can be called safely before the ready event the app module emits,
|
||||
/// it is usually used to report errors in early stage of startup.If called
|
||||
/// before the app readyevent on Linux, the message will be emitted to stderr,
|
||||
/// and no GUI dialog will appear.
|
||||
/// </summary>
|
||||
/// <param name="title">The title to display in the error box.</param>
|
||||
@@ -191,11 +182,13 @@ namespace ElectronNET.API
|
||||
|
||||
/// <summary>
|
||||
/// On macOS, this displays a modal dialog that shows a message and certificate information,
|
||||
/// and gives the user the option of trusting/importing the certificate. If you provide a
|
||||
/// and gives the user the option of trusting/importing the certificate. If you provide a
|
||||
/// browserWindow argument the dialog will be attached to the parent window, making it modal.
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
[SupportedOSPlatform("macOS")]
|
||||
[SupportedOSPlatform("Windows")]
|
||||
public Task ShowCertificateTrustDialogAsync(CertificateTrustDialogOptions options)
|
||||
{
|
||||
return ShowCertificateTrustDialogAsync(null, options);
|
||||
@@ -203,36 +196,26 @@ namespace ElectronNET.API
|
||||
|
||||
/// <summary>
|
||||
/// On macOS, this displays a modal dialog that shows a message and certificate information,
|
||||
/// and gives the user the option of trusting/importing the certificate. If you provide a
|
||||
/// and gives the user the option of trusting/importing the certificate. If you provide a
|
||||
/// browserWindow argument the dialog will be attached to the parent window, making it modal.
|
||||
/// </summary>
|
||||
/// <param name="browserWindow"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
[SupportedOSPlatform("macOS")]
|
||||
[SupportedOSPlatform("Windows")]
|
||||
public Task ShowCertificateTrustDialogAsync(BrowserWindow browserWindow, CertificateTrustDialogOptions options)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
BridgeConnector.Socket.On("showCertificateTrustDialogComplete" + guid, () =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("showCertificateTrustDialogComplete" + guid);
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Once("showCertificateTrustDialogComplete" + guid, () => tcs.SetResult());
|
||||
BridgeConnector.Socket.Emit("showCertificateTrustDialog",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(options, _jsonSerializer),
|
||||
browserWindow,
|
||||
options,
|
||||
guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.API.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
/// Control your app in the macOS dock.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macOS")]
|
||||
public sealed class Dock
|
||||
{
|
||||
private static Dock _dock;
|
||||
@@ -54,18 +53,13 @@ namespace ElectronNET.API
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<int>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
var tcs = new TaskCompletionSource<int>();
|
||||
using (cancellationToken.Register(() => tcs.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("dock-bounce-completed", (id) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("dock-bounce-completed");
|
||||
taskCompletionSource.SetResult((int) id);
|
||||
});
|
||||
BridgeConnector.Socket.Once<int>("dock-bounce-completed", tcs.SetResult);
|
||||
BridgeConnector.Socket.Emit("dock-bounce", type);
|
||||
|
||||
BridgeConnector.Socket.Emit("dock-bounce", type.GetDescription());
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
return await tcs.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -106,18 +100,13 @@ namespace ElectronNET.API
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
using (cancellationToken.Register(() => tcs.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("dock-getBadge-completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("dock-getBadge-completed");
|
||||
taskCompletionSource.SetResult((string) text);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Once<string>("dock-getBadge-completed", tcs.SetResult);
|
||||
BridgeConnector.Socket.Emit("dock-getBadge");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
return await tcs.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -148,18 +137,13 @@ namespace ElectronNET.API
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
using (cancellationToken.Register(() => tcs.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("dock-isVisible-completed", (isVisible) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("dock-isVisible-completed");
|
||||
taskCompletionSource.SetResult((bool) isVisible);
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Once<bool>("dock-isVisible-completed", tcs.SetResult);
|
||||
BridgeConnector.Socket.Emit("dock-isVisible");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
return await tcs.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -170,7 +154,14 @@ namespace ElectronNET.API
|
||||
/// <value>
|
||||
/// The menu items.
|
||||
/// </value>
|
||||
public IReadOnlyCollection<MenuItem> MenuItems { get { return _items.AsReadOnly(); } }
|
||||
public IReadOnlyCollection<MenuItem> MenuItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return _items.AsReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
private List<MenuItem> _items = new List<MenuItem>();
|
||||
|
||||
/// <summary>
|
||||
@@ -179,15 +170,15 @@ namespace ElectronNET.API
|
||||
public void SetMenu(MenuItem[] menuItems)
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
BridgeConnector.Socket.Emit("dock-setMenu", JArray.FromObject(menuItems, _jsonSerializer));
|
||||
BridgeConnector.Socket.Emit("dock-setMenu", new[] { menuItems });
|
||||
_items.AddRange(menuItems);
|
||||
|
||||
BridgeConnector.Socket.Off("dockMenuItemClicked");
|
||||
BridgeConnector.Socket.On("dockMenuItemClicked", (id) => {
|
||||
MenuItem menuItem = _items.GetMenuItem(id.ToString());
|
||||
BridgeConnector.Socket.On<string>("dockMenuItemClicked", (id) =>
|
||||
{
|
||||
MenuItem menuItem = _items.GetMenuItem(id);
|
||||
menuItem?.Click();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -198,18 +189,13 @@ namespace ElectronNET.API
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<Menu>();
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
var tcs = new TaskCompletionSource<Menu>();
|
||||
using (cancellationToken.Register(() => tcs.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.Socket.On("dock-getMenu-completed", (menu) =>
|
||||
{
|
||||
BridgeConnector.Socket.Off("dock-getMenu-completed");
|
||||
taskCompletionSource.SetResult(((JObject)menu).ToObject<Menu>());
|
||||
});
|
||||
|
||||
BridgeConnector.Socket.Once<Menu>("dock-getMenu-completed", tcs.SetResult);
|
||||
BridgeConnector.Socket.Emit("dock-getMenu");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
return await tcs.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -222,11 +208,5 @@ namespace ElectronNET.API
|
||||
{
|
||||
BridgeConnector.Socket.Emit("dock-setIcon", image);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -8,85 +8,192 @@
|
||||
/// <summary>
|
||||
/// Communicate asynchronously from the main process to renderer processes.
|
||||
/// </summary>
|
||||
public static IpcMain IpcMain { get { return IpcMain.Instance; } }
|
||||
public static IpcMain IpcMain
|
||||
{
|
||||
get
|
||||
{
|
||||
return IpcMain.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Control your application's event lifecycle.
|
||||
/// </summary>
|
||||
public static App App { get { return App.Instance; } }
|
||||
public static App App
|
||||
{
|
||||
get
|
||||
{
|
||||
return App.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable apps to automatically update themselves. Based on electron-updater.
|
||||
/// </summary>
|
||||
public static AutoUpdater AutoUpdater { get { return AutoUpdater.Instance; } }
|
||||
public static AutoUpdater AutoUpdater
|
||||
{
|
||||
get
|
||||
{
|
||||
return AutoUpdater.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Control your windows.
|
||||
/// </summary>
|
||||
public static WindowManager WindowManager { get { return WindowManager.Instance; } }
|
||||
public static WindowManager WindowManager
|
||||
{
|
||||
get
|
||||
{
|
||||
return WindowManager.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create native application menus and context menus.
|
||||
/// </summary>
|
||||
public static Menu Menu { get { return Menu.Instance; } }
|
||||
public static Menu Menu
|
||||
{
|
||||
get
|
||||
{
|
||||
return Menu.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Display native system dialogs for opening and saving files, alerting, etc.
|
||||
/// </summary>
|
||||
public static Dialog Dialog { get { return Dialog.Instance; } }
|
||||
public static Dialog Dialog
|
||||
{
|
||||
get
|
||||
{
|
||||
return Dialog.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create OS desktop notifications
|
||||
/// </summary>
|
||||
public static Notification Notification { get { return Notification.Instance; } }
|
||||
public static Notification Notification
|
||||
{
|
||||
get
|
||||
{
|
||||
return Notification.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add icons and context menus to the system’s notification area.
|
||||
/// </summary>
|
||||
public static Tray Tray { get { return Tray.Instance; } }
|
||||
public static Tray Tray
|
||||
{
|
||||
get
|
||||
{
|
||||
return Tray.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detect keyboard events when the application does not have keyboard focus.
|
||||
/// </summary>
|
||||
public static GlobalShortcut GlobalShortcut { get { return GlobalShortcut.Instance; } }
|
||||
public static GlobalShortcut GlobalShortcut
|
||||
{
|
||||
get
|
||||
{
|
||||
return GlobalShortcut.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manage files and URLs using their default applications.
|
||||
/// </summary>
|
||||
public static Shell Shell { get { return Shell.Instance; } }
|
||||
public static Shell Shell
|
||||
{
|
||||
get
|
||||
{
|
||||
return Shell.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve information about screen size, displays, cursor position, etc.
|
||||
/// </summary>
|
||||
public static Screen Screen { get { return Screen.Instance; } }
|
||||
public static Screen Screen
|
||||
{
|
||||
get
|
||||
{
|
||||
return Screen.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform copy and paste operations on the system clipboard.
|
||||
/// </summary>
|
||||
public static Clipboard Clipboard { get { return Clipboard.Instance; } }
|
||||
public static Clipboard Clipboard
|
||||
{
|
||||
get
|
||||
{
|
||||
return Clipboard.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to execute native JavaScript/TypeScript code from the host process.
|
||||
///
|
||||
/// It is only possible if the Electron.NET CLI has previously added an
|
||||
/// It is only possible if the Electron.NET CLI has previously added an
|
||||
/// ElectronHostHook directory:
|
||||
/// <c>electronize add HostHook</c>
|
||||
/// </summary>
|
||||
public static HostHook HostHook { get { return HostHook.Instance; } }
|
||||
public static HostHook HostHook
|
||||
{
|
||||
get
|
||||
{
|
||||
return HostHook.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to execute native Lock and Unlock process.
|
||||
/// Allows you to execute native Lock and Unlock process.
|
||||
/// </summary>
|
||||
public static PowerMonitor PowerMonitor { get { return PowerMonitor.Instance; } }
|
||||
public static PowerMonitor PowerMonitor
|
||||
{
|
||||
get
|
||||
{
|
||||
return PowerMonitor.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read and respond to changes in Chromium's native color theme.
|
||||
/// </summary>
|
||||
public static NativeTheme NativeTheme { get { return NativeTheme.Instance; } }
|
||||
public static NativeTheme NativeTheme
|
||||
{
|
||||
get
|
||||
{
|
||||
return NativeTheme.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Control your app in the macOS dock.
|
||||
/// </summary>
|
||||
public static Dock Dock { get { return Dock.Instance; } }
|
||||
public static Dock Dock
|
||||
{
|
||||
get
|
||||
{
|
||||
return Dock.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Electeon extensions to the Nodejs process object.
|
||||
/// </summary>
|
||||
public static Process Process
|
||||
{
|
||||
get
|
||||
{
|
||||
return Process.Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// About panel options.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class AboutPanelOptions
|
||||
{
|
||||
/// <summary>
|
||||
@@ -21,28 +24,35 @@
|
||||
public string Copyright { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The app's build version number.
|
||||
/// The app's build version number (macOS).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Credit information.
|
||||
/// Credit information (macOS, Windows).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string Credits { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of app authors.
|
||||
/// List of app authors (Linux).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("linux")]
|
||||
public string[] Authors { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The app's website.
|
||||
/// The app's website (Linux).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("linux")]
|
||||
public string Website { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Path to the app's icon. On Linux, will be shown as 64x64 pixels while retaining aspect ratio.
|
||||
/// Path to the app's icon in a JPEG or PNG file format. On Linux, will be shown as 64x64 pixels while retaining aspect ratio. On Windows, a 48x48 PNG will result in the best visual quality.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("linux")]
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string IconPath { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,36 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class AddRepresentationOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the width
|
||||
/// Gets or sets the width in pixels. Defaults to 0. Required if a bitmap buffer is specified as <see cref="Buffer"/>.
|
||||
/// </summary>
|
||||
public int? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height
|
||||
/// Gets or sets the height in pixels. Defaults to 0. Required if a bitmap buffer is specified as <see cref="Buffer"/>.
|
||||
/// </summary>
|
||||
public int? Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the scalefactor
|
||||
/// Gets or sets the image scale factor. Defaults to 1.0.
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the buffer
|
||||
/// Gets or sets the buffer containing the raw image data.
|
||||
/// </summary>
|
||||
public byte[] Buffer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the dataURL
|
||||
/// Gets or sets the data URL containing a base 64 encoded PNG or JPEG image.
|
||||
/// </summary>
|
||||
public string DataUrl { get; set; }
|
||||
public string DataUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,36 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class AppDetailsOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Window’s App User Model ID. It has to be set, otherwise the other options will have no effect.
|
||||
/// Window's App User Model ID. It has to be set, otherwise the other options will have no effect.
|
||||
/// </summary>
|
||||
public string AppId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Window’s Relaunch Icon.
|
||||
/// Window's relaunch icon resource path.
|
||||
/// </summary>
|
||||
public string AppIconPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Index of the icon in appIconPath. Ignored when appIconPath is not set. Default is 0.
|
||||
/// Index of the icon in <see cref="AppIconPath"/>. Ignored when <see cref="AppIconPath"/> is not set. Default is 0.
|
||||
/// </summary>
|
||||
public int AppIconIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Window’s Relaunch Command.
|
||||
/// Window's relaunch command.
|
||||
/// </summary>
|
||||
public string RelaunchCommand { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Window’s Relaunch Display Name.
|
||||
/// Window's relaunch display name.
|
||||
/// </summary>
|
||||
public string RelaunchDisplayName { get; set; }
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class AutoResizeOptions
|
||||
{
|
||||
/// <summary>
|
||||
@@ -35,4 +36,4 @@ namespace ElectronNET.API.Entities
|
||||
[DefaultValue(false)]
|
||||
public bool Vertical { get; set; } = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,12 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class BitmapOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the scale factor
|
||||
/// The image scale factor. Defaults to 1.0.
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class Blob : IPostData
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
@@ -32,4 +28,4 @@ namespace ElectronNET.API.Entities
|
||||
/// </summary>
|
||||
public bool IsAdminRightsRequired { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,23 +3,26 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class BrowserViewConstructorOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// See BrowserWindow.
|
||||
/// Gets or sets the web preferences for the view (see WebPreferences).
|
||||
/// </summary>
|
||||
public WebPreferences WebPreferences { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A proxy to set on creation in the format host:port.
|
||||
/// Gets or sets a proxy to use on creation in the format host:port.
|
||||
/// The proxy can be alternatively set using the BrowserView.WebContents.SetProxyAsync function.
|
||||
/// </summary>
|
||||
/// <remarks>This is custom shortcut. Not part of the Electron API.</remarks>
|
||||
public string Proxy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The credentials of the Proxy in the format username:password.
|
||||
/// Gets or sets the credentials of the proxy in the format username:password.
|
||||
/// These will only be used if the Proxy field is also set.
|
||||
/// </summary>
|
||||
/// <remarks>This is custom shortcut. Not part of the Electron API.</remarks>
|
||||
public string ProxyCredentials { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using ElectronNET.Converter;
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -72,24 +73,32 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// Whether window is movable. This is not implemented on Linux. Default is true.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DefaultValue(true)]
|
||||
public bool Movable { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether window is minimizable. This is not implemented on Linux. Default is true.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DefaultValue(true)]
|
||||
public bool Minimizable { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether window is maximizable. This is not implemented on Linux. Default is true.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DefaultValue(true)]
|
||||
public bool Maximizable { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether window is closable. This is not implemented on Linux. Default is true.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DefaultValue(true)]
|
||||
public bool Closable { get; set; } = true;
|
||||
|
||||
@@ -115,16 +124,24 @@ namespace ElectronNET.API.Entities
|
||||
|
||||
/// <summary>
|
||||
/// Whether the window can be put into fullscreen mode. On macOS, also whether the
|
||||
/// maximize/zoom button should toggle full screen mode or maximize window.Default
|
||||
/// is true.
|
||||
/// maximize/zoom button should toggle full screen mode or maximize window. Default
|
||||
/// is true (Electron default).
|
||||
/// </summary>
|
||||
public bool Fullscreenable { get; set; }
|
||||
[DefaultValue(true)]
|
||||
public bool Fullscreenable { get; set; } = true; // FIX: previously defaulted to false in C#
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the window in taskbar. Default is false.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
[SupportedOSPlatform("windows")]
|
||||
public bool SkipTaskbar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if Blazor is used. Will disable "module" and "process" globals. Default is false.
|
||||
/// </summary>
|
||||
public bool IsRunningBlazor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The kiosk mode. Default is false.
|
||||
/// </summary>
|
||||
@@ -136,8 +153,7 @@ namespace ElectronNET.API.Entities
|
||||
public string Title { get; set; } = "Electron.NET";
|
||||
|
||||
/// <summary>
|
||||
/// The window icon. On Windows it is recommended to use ICO icons to get best
|
||||
/// visual effects, you can also leave it undefined so the executable's icon will be used.
|
||||
/// The window icon. Can be a NativeImage or a string path. On Windows it is recommended to use ICO icons; when undefined, the executable's icon will be used.
|
||||
/// </summary>
|
||||
public string Icon { get; set; }
|
||||
|
||||
@@ -148,7 +164,7 @@ namespace ElectronNET.API.Entities
|
||||
public bool Show { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Specify false to create a . Default is true.
|
||||
/// Specify false to create a frameless window. Default is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true)]
|
||||
public bool Frame { get; set; } = true;
|
||||
@@ -163,6 +179,7 @@ namespace ElectronNET.API.Entities
|
||||
/// Whether the web view accepts a single mouse-down event that simultaneously
|
||||
/// activates the window.Default is false.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool AcceptFirstMouse { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -173,33 +190,40 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
/// Auto hide the menu bar unless the Alt key is pressed. Default is false.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
[SupportedOSPlatform("linux")]
|
||||
public bool AutoHideMenuBar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enable the window to be resized larger than screen. Default is false.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool EnableLargerThanScreen { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Window's background color as Hexadecimal value, like #66CD00 or #FFF or
|
||||
/// #80FFFFFF (alpha is supported). Default is #FFF (white).
|
||||
/// The window's background color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. Alpha in #AARRGGBB format is supported if transparent is set to true. Default is #FFF (white).
|
||||
/// </summary>
|
||||
public string BackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether window should have a shadow. This is only implemented on macOS. Default
|
||||
/// is true.
|
||||
/// Initial opacity of the window, between 0.0 (fully transparent) and 1.0 (fully opaque). Only implemented on Windows and macOS.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
[SupportedOSPlatform("macos")]
|
||||
public double? Opacity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether window should have a shadow. Default is true.
|
||||
/// </summary>
|
||||
public bool HasShadow { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Forces using dark theme for the window, only works on some GTK+3 desktop
|
||||
/// environments.Default is false.
|
||||
/// Forces using dark theme for the window, only works on some GTK+3 desktop environments. Default is false.
|
||||
/// </summary>
|
||||
public bool DarkTheme { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Makes the window . Default is false.
|
||||
/// Makes the window transparent. Default is false.
|
||||
/// </summary>
|
||||
public bool Transparent { get; set; }
|
||||
|
||||
@@ -212,13 +236,30 @@ namespace ElectronNET.API.Entities
|
||||
/// The style of window title bar. Default is default. Possible values are:
|
||||
/// 'default' | 'hidden' | 'hiddenInset' | 'customButtonsOnHover'
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public TitleBarStyle TitleBarStyle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Shows the title in the tile bar in full screen mode on macOS for all
|
||||
/// titleBarStyle options.Default is false.
|
||||
/// Set a custom position for the traffic light buttons in frameless windows (macOS).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public Point TrafficLightPosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Configures the window's title bar overlay when using a frameless window.
|
||||
/// Can be either:
|
||||
/// - false: No title bar overlay.
|
||||
/// - true: Enables the default title bar overlay.
|
||||
/// - An object defining custom overlay options (such as height, color, etc.).
|
||||
///
|
||||
/// Default is false.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(TitleBarOverlayConverter))]
|
||||
public TitleBarOverlay TitleBarOverlay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Shows the title in the title bar in full screen mode on macOS for all titleBarStyle options. Default is false.
|
||||
/// </summary>
|
||||
/// <remarks>Not documented by MCP base-window-options / browser-window-options.</remarks>
|
||||
public bool FullscreenWindowTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -226,15 +267,27 @@ namespace ElectronNET.API.Entities
|
||||
/// window frame.Setting it to false will remove window shadow and window
|
||||
/// animations. Default is true.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DefaultValue(true)]
|
||||
public bool ThickFrame { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Add a type of vibrancy effect to the window, only on macOS. Can be
|
||||
/// appearance-based, light, dark, titlebar, selection, menu, popover, sidebar,
|
||||
/// medium-light or ultra-dark.
|
||||
/// Whether frameless window should have rounded corners. Default is true. Setting this
|
||||
/// property to false will prevent the window from being fullscreenable on macOS. On
|
||||
/// Windows versions older than Windows 11 Build 22000 this property has no effect, and
|
||||
/// frameless windows will not have rounded corners.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[SupportedOSPlatform("macos")]
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DefaultValue(true)]
|
||||
public bool RoundedCorners { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Add a type of vibrancy effect to the window, only on macOS. Can be
|
||||
/// appearance-based, titlebar, selection, menu, popover, sidebar, header, sheet,
|
||||
/// window, hud, fullscreen-ui, tooltip, content, under-window, or under-page.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public Vibrancy Vibrancy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -244,6 +297,7 @@ namespace ElectronNET.API.Entities
|
||||
/// it to zoom to the width of the screen.This will also affect the behavior when
|
||||
/// calling maximize() directly.Default is false.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool ZoomToPageWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -252,6 +306,7 @@ namespace ElectronNET.API.Entities
|
||||
/// adds a native new tab button to your window's tab bar and allows your app and
|
||||
/// window to receive the new-window-for-tab event.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string TabbingIdentifier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -263,12 +318,39 @@ namespace ElectronNET.API.Entities
|
||||
/// A proxy to set on creation in the format host:port.
|
||||
/// The proxy can be alternatively set using the BrowserWindow.WebContents.SetProxyAsync function.
|
||||
/// </summary>
|
||||
/// <remarks>Not documented by MCP base-window-options / browser-window-options.</remarks>
|
||||
public string Proxy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The credentials of the Proxy in the format username:password.
|
||||
/// These will only be used if the Proxy field is also set.
|
||||
/// </summary>
|
||||
/// <remarks>Not documented by MCP base-window-options / browser-window-options.</remarks>
|
||||
public string ProxyCredentials { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether to use pre-Lion fullscreen on macOS. Default is false.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool SimpleFullscreen { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the window should be hidden when the user toggles into mission control (macOS).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool HiddenInMissionControl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets how the material appearance should reflect window activity state on macOS. Must be used with the vibrancy property.
|
||||
/// Possible values: 'followWindow' (default), 'active', 'inactive'.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string VisualEffectState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the system-drawn background material on Windows. Can be 'auto', 'none', 'mica', 'acrylic' or 'tabbed'.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string BackgroundMaterial { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,23 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class CPUUsage
|
||||
{
|
||||
/// <summary>
|
||||
/// Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
|
||||
/// </summary>
|
||||
public int PercentCPUUsage { get; set; }
|
||||
public double PercentCPUUsage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of average idle cpu wakeups per second since the last call to
|
||||
/// getCPUUsage.First call returns 0.
|
||||
/// Total seconds of CPU time used since process startup, if available.
|
||||
/// </summary>
|
||||
public int IdleWakeupsPerSecond { get; set; }
|
||||
public double? CumulativeCPUUsage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of average idle CPU wakeups per second since the last call to
|
||||
/// getCPUUsage. First call returns 0. Will always return 0 on Windows.
|
||||
/// </summary>
|
||||
public double IdleWakeupsPerSecond { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class Certificate
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class CertificatePrincipal
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class CertificateTrustDialogOptions
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Provide metadata about the current loaded Chrome extension
|
||||
/// </summary>
|
||||
/// <yremarks>Project-specific: no matching Electron structure found in MCP docs (electronjs).</yremarks>
|
||||
public class ChromeExtensionInfo
|
||||
{
|
||||
/// <summary>
|
||||
@@ -30,4 +27,4 @@ namespace ElectronNET.API.Entities
|
||||
/// </summary>
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class ClearStorageDataOptions
|
||||
{
|
||||
/// <summary>
|
||||
@@ -11,14 +12,17 @@
|
||||
public string Origin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The types of storages to clear, can contain: appcache, cookies, filesystem,
|
||||
/// indexdb, localstorage, shadercache, websql, serviceworkers, cachestorage.
|
||||
/// The types of storages to clear. Can contain: cookies, filesystem, indexdb,
|
||||
/// localstorage, shadercache, websql, serviceworkers, cachestorage.
|
||||
/// If not specified, all storage types are cleared.
|
||||
/// </summary>
|
||||
public string[] Storages { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The types of quotas to clear, can contain: temporary, persistent, syncable.
|
||||
/// The types of quotas to clear. Can contain: temporary. If not specified,
|
||||
/// all quotas are cleared. The <c>quotas</c> option is deprecated;
|
||||
/// "temporary" is the only remaining supported quota type.
|
||||
/// </summary>
|
||||
public string[] Quotas { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +1,59 @@
|
||||
namespace ElectronNET.API.Entities {
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Cookie structure as used by Electron session.cookies APIs.
|
||||
/// </summary>
|
||||
public class Cookie {
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class Cookie
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the cookie.
|
||||
/// Gets or sets the name of the cookie.
|
||||
/// </summary>
|
||||
public string Name { get; set;}
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The value of the cookie.
|
||||
/// Gets or sets the value of the cookie.
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains.
|
||||
/// Gets or sets the domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains.
|
||||
/// </summary>
|
||||
public string Domain { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - Whether the cookie is a host-only cookie; this will only be true if no domain was passed.
|
||||
/// Gets or sets a value indicating whether the cookie is a host-only cookie; this will only be true if no domain was passed.
|
||||
/// </summary>
|
||||
public bool HostOnly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - The path of the cookie.
|
||||
/// Gets or sets the path of the cookie.
|
||||
/// </summary>
|
||||
public string Path { get; set; }
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - Whether the cookie is marked as secure.
|
||||
/// Gets or sets a value indicating whether the cookie is marked as secure.
|
||||
/// </summary>
|
||||
public bool Secure { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - Whether the cookie is marked as HTTP only.
|
||||
/// 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>
|
||||
/// (optional) - Whether the cookie is a session cookie or a persistent cookie with an expiration date.
|
||||
/// Gets or sets a value indicating whether the cookie is a session cookie or a persistent cookie with an expiration date.
|
||||
/// </summary>
|
||||
public bool Session { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies.
|
||||
/// Gets or sets the expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies.
|
||||
/// </summary>
|
||||
public long 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".
|
||||
/// </summary>
|
||||
public string SameSite { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,15 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities {
|
||||
/// <summary>
|
||||
/// The cause of the change
|
||||
/// The cause of the cookie change (per Electron Cookies 'changed' event).
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum CookieChangedCause
|
||||
public enum CookieChangedCause
|
||||
{
|
||||
/// <summary>
|
||||
///The cookie was changed directly by a consumer's action.
|
||||
/// The cookie was changed directly by a consumer's action.
|
||||
/// </summary>
|
||||
[JsonProperty("explicit")]
|
||||
@explicit,
|
||||
|
||||
/// <summary>
|
||||
@@ -20,19 +18,19 @@ namespace ElectronNET.API.Entities {
|
||||
overwrite,
|
||||
|
||||
/// <summary>
|
||||
/// The cookie was automatically removed as it expired.
|
||||
/// The cookie was automatically removed as it expired.
|
||||
/// </summary>
|
||||
expired,
|
||||
|
||||
/// <summary>
|
||||
/// The cookie was automatically evicted during garbage collection.
|
||||
/// The cookie was automatically evicted during garbage collection.
|
||||
/// </summary>
|
||||
evicted,
|
||||
|
||||
/// <summary>
|
||||
/// The cookie was overwritten with an already-expired expiration date.
|
||||
/// The cookie was overwritten with an already-expired expiration date.
|
||||
/// </summary>
|
||||
[JsonProperty("expired_overwrite")]
|
||||
[JsonPropertyName("expired_overwrite")]
|
||||
expiredOverwrite
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,63 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ElectronNET.API.Entities {
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CookieDetails {
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class CookieDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// The URL to associate the cookie with. The callback will be rejected if the URL is invalid.
|
||||
/// Gets or sets the URL to associate the cookie with. The operation will be rejected if the URL is invalid.
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - The name of the cookie. Empty by default if omitted.
|
||||
/// Gets or sets the name of the cookie. Empty by default if omitted.
|
||||
/// </summary>
|
||||
[DefaultValue("")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - The value of the cookie. Empty by default if omitted.
|
||||
/// Gets or sets the value of the cookie. Empty by default if omitted.
|
||||
/// </summary>
|
||||
[DefaultValue("")]
|
||||
[DefaultValue("")]
|
||||
public string Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains. Empty by default if omitted.
|
||||
/// Gets or sets the domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains. Empty by default if omitted.
|
||||
/// </summary>
|
||||
[DefaultValue("")]
|
||||
public string Domain { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - The path of the cookie. Empty by default if omitted.
|
||||
/// Gets or sets the path of the cookie. Empty by default if omitted.
|
||||
/// </summary>
|
||||
[DefaultValue("")]
|
||||
[DefaultValue("")]
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - Whether the cookie is marked as secure. Defaults to false.
|
||||
/// Gets or sets a value indicating whether the cookie should be marked as secure. Defaults to false unless the SameSite policy is set to <c>no_restriction</c> (SameSite=None).
|
||||
/// </summary>
|
||||
[DefaultValue(false)]
|
||||
[DefaultValue(false)]
|
||||
public bool Secure { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - Whether the cookie is marked as HTTP only. Defaults to false.
|
||||
/// Gets or sets a value indicating whether the cookie should be marked as HTTP only. Defaults to false.
|
||||
/// </summary>
|
||||
[DefaultValue(false)]
|
||||
public bool HttpOnly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - The expiration date of the cookie as the number of seconds since the UNIX epoch.
|
||||
/// If omitted then the cookie becomes a session cookie and will not be retained between sessions.
|
||||
/// Gets or sets the expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie and will not be retained between sessions.
|
||||
/// </summary>
|
||||
[DefaultValue(0)]
|
||||
public long ExpirationDate { get; set; }
|
||||
public double ExpirationDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the SameSite policy to apply to this cookie. Can be "unspecified", "no_restriction", "lax" or "strict". Default is "lax".
|
||||
/// </summary>
|
||||
public string SameSite { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CookieFilter
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class CookieFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// (optional) - Retrieves cookies which are associated with url.Empty implies retrieving cookies of all URLs.
|
||||
/// (optional) - Retrieves cookies which are associated with url. Empty implies retrieving cookies of all URLs.
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
|
||||
@@ -39,5 +36,9 @@ namespace ElectronNET.API.Entities
|
||||
/// </summary>
|
||||
public bool Session { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - Filters cookies by httpOnly.
|
||||
/// </summary>
|
||||
public bool HttpOnly { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,21 +3,22 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class CreateFromBitmapOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the width
|
||||
/// Gets or sets the width in pixels. Required for nativeImage.createFromBitmap(buffer, options).
|
||||
/// </summary>
|
||||
public int? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height
|
||||
/// Gets or sets the height in pixels. Required for nativeImage.createFromBitmap(buffer, options).
|
||||
/// </summary>
|
||||
public int? Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the scalefactor
|
||||
/// Gets or sets the image scale factor. Optional, defaults to 1.0.
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,20 +3,21 @@ namespace ElectronNET.API.Entities
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class CreateFromBufferOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the width
|
||||
/// Gets or sets the width. Required for bitmap buffers passed to nativeImage.createFromBuffer.
|
||||
/// </summary>
|
||||
public int? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height
|
||||
/// Gets or sets the height. Required for bitmap buffers passed to nativeImage.createFromBuffer.
|
||||
/// </summary>
|
||||
public int? Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the scalefactor
|
||||
/// The image scale factor. Optional, defaults to 1.0.
|
||||
/// </summary>
|
||||
public float ScaleFactor { get; set; } = 1.0f;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class CreateInterruptedDownloadOptions
|
||||
{
|
||||
/// <summary>
|
||||
@@ -16,7 +17,7 @@
|
||||
public string[] UrlChain { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// (optional) - MIME type of the download.
|
||||
/// </summary>
|
||||
public string MimeType { get; set; }
|
||||
|
||||
@@ -41,9 +42,10 @@
|
||||
public string ETag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time when download was started in number of seconds since UNIX epoch.
|
||||
/// (optional) - Time when download was started in number of seconds since UNIX epoch.
|
||||
/// Electron documents this as a Number (Double).
|
||||
/// </summary>
|
||||
public int StartTime { get; set; }
|
||||
public double? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -64,4 +66,4 @@
|
||||
ETag = eTag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,12 @@
|
||||
/// </value>
|
||||
public string Html { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the image.
|
||||
/// Maps to clipboard.write({ image: NativeImage }).
|
||||
/// </summary>
|
||||
public NativeImage Image { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RTF.
|
||||
|
||||
@@ -34,5 +34,10 @@
|
||||
/// Defaults to Impact.
|
||||
/// </summary>
|
||||
public string Fantasy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defaults to Latin Modern Math.
|
||||
/// </summary>
|
||||
public string Math { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Opens the devtools with specified dock state, can be right, bottom, undocked,
|
||||
/// detach.Defaults to last used dock state.In undocked mode it's possible to dock
|
||||
/// back.In detach mode it's not.
|
||||
/// Opens the devtools with specified dock state, can be left, right, bottom, undocked,
|
||||
/// detach. Defaults to last used dock state. In undocked mode it's possible to dock
|
||||
/// back. In detach mode it's not.
|
||||
/// </summary>
|
||||
public enum DevToolsMode
|
||||
{
|
||||
@@ -25,6 +25,11 @@
|
||||
/// <summary>
|
||||
/// The detach
|
||||
/// </summary>
|
||||
detach
|
||||
detach,
|
||||
|
||||
/// <summary>
|
||||
/// The left
|
||||
/// </summary>
|
||||
left,
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,11 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class Display
|
||||
{
|
||||
/// <summary>
|
||||
/// Can be available, unavailable, unknown.
|
||||
/// Gets or sets the accelerometer support status; can be 'available', 'unavailable', or 'unknown'.
|
||||
/// </summary>
|
||||
public string AccelerometerSupport { get; set; }
|
||||
|
||||
@@ -19,57 +20,72 @@
|
||||
public Rectangle Bounds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of bits per pixel.
|
||||
/// Gets or sets the number of bits per pixel.
|
||||
/// </summary>
|
||||
public int ColorDepth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Represent a color space (three-dimensional object which contains all realizable color combinations) for the purpose of color conversions.
|
||||
/// Gets or sets the color space description used for color conversions.
|
||||
/// </summary>
|
||||
public string ColorSpace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of bits per color component.
|
||||
/// Gets or sets the number of bits per color component.
|
||||
/// </summary>
|
||||
public int DepthPerComponent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The display refresh rate.
|
||||
/// Gets or sets a value indicating whether the display is detected by the system.
|
||||
/// </summary>
|
||||
public int DisplayFrequency { get; set; }
|
||||
public bool Detected { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unique identifier associated with the display.
|
||||
/// Gets or sets the display refresh rate.
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
public double DisplayFrequency { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// true for an internal display and false for an external display.
|
||||
/// Gets or sets the unique identifier associated with the display. A value of -1 means the display is invalid or the correct id is not yet known, and a value of -10 means the display is a virtual display assigned to a unified desktop.
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the display is internal (true) or external (false).
|
||||
/// </summary>
|
||||
public bool Internal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User-friendly label, determined by the platform.
|
||||
/// Gets or sets the user-friendly label, determined by the platform.
|
||||
/// </summary>
|
||||
public string Label { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees.
|
||||
/// Gets or sets the maximum cursor size in native pixels.
|
||||
/// </summary>
|
||||
public Size MaximumCursorSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the display's origin in pixel coordinates. Only available on windowing systems that position displays in pixel coordinates (e.g., X11).
|
||||
/// </summary>
|
||||
public Point NativeOrigin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the screen rotation in clock-wise degrees. Can be 0, 90, 180, or 270.
|
||||
/// </summary>
|
||||
public int Rotation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Output device's pixel scale factor.
|
||||
/// Gets or sets the output device's pixel scale factor.
|
||||
/// </summary>
|
||||
public int ScaleFactor { get; set; }
|
||||
public double ScaleFactor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Can be available, unavailable, unknown.
|
||||
/// Gets or sets the touch support status; can be 'available', 'unavailable', or 'unknown'.
|
||||
/// </summary>
|
||||
public string TouchSupport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the display is a monochrome display.
|
||||
/// Gets or sets a value indicating whether the display is monochrome.
|
||||
/// </summary>
|
||||
public bool Monochrome { get; set; }
|
||||
|
||||
@@ -82,10 +98,10 @@
|
||||
public Size Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the work area.
|
||||
/// Gets or sets the work area of the display in DIP points.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The work area.
|
||||
/// The work area of the display in DIP points.
|
||||
/// </value>
|
||||
public Rectangle WorkArea { get; set; }
|
||||
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
namespace ElectronNET.API
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public enum DisplayBalloonIconType
|
||||
{
|
||||
none,
|
||||
info,
|
||||
warning,
|
||||
error,
|
||||
custom
|
||||
}
|
||||
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("Windows")]
|
||||
public class DisplayBalloonOptions
|
||||
{
|
||||
/// <summary>
|
||||
@@ -28,5 +41,29 @@
|
||||
/// The content.
|
||||
/// </value>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - Icon type for the balloon: none, info, warning, error or custom.
|
||||
/// Default is custom.
|
||||
/// </summary>
|
||||
public DisplayBalloonIconType IconType { get; set; } = DisplayBalloonIconType.custom;
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - Use the large version of the icon. Default is true.
|
||||
/// Maps to Windows NIIF_LARGE_ICON.
|
||||
/// </summary>
|
||||
public bool LargeIcon { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - Do not play the associated sound. Default is false.
|
||||
/// Maps to Windows NIIF_NOSOUND.
|
||||
/// </summary>
|
||||
public bool NoSound { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// (optional) - Do not display the balloon if the current user is in "quiet time".
|
||||
/// Default is false. Maps to Windows NIIF_RESPECT_QUIET_TIME.
|
||||
/// </summary>
|
||||
public bool RespectQuietTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the DockBounceType enumeration.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("macOS")]
|
||||
public enum DockBounceType
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class EnableNetworkEmulationOptions
|
||||
{
|
||||
/// <summary>
|
||||
@@ -12,17 +13,20 @@
|
||||
|
||||
/// <summary>
|
||||
/// RTT in ms. Defaults to 0 which will disable latency throttling.
|
||||
/// Electron documents this as a Number (Double).
|
||||
/// </summary>
|
||||
public int Latency { get; set; }
|
||||
public double Latency { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Download rate in Bps. Defaults to 0 which will disable download throttling.
|
||||
/// Electron documents this as a Number (Double).
|
||||
/// </summary>
|
||||
public int DownloadThroughput { get; set; }
|
||||
public double DownloadThroughput { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Upload rate in Bps. Defaults to 0 which will disable upload throttling.
|
||||
/// Electron documents this as a Number (Double).
|
||||
/// </summary>
|
||||
public int UploadThroughput { get; set; }
|
||||
public double UploadThroughput { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Docs: https://electronjs.org/docs/api/structures/extension
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class Extension
|
||||
{
|
||||
/// <summary>
|
||||
@@ -41,4 +36,4 @@ namespace ElectronNET.API.Entities
|
||||
/// </summary>
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class FileFilter
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class FileIconOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the size.
|
||||
/// The requested icon size string passed to app.getFileIcon:
|
||||
/// "small" (16x16), "normal" (32x32), or "large" (48x48 on Linux, 32x32 on Windows; unsupported on macOS).
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The size.
|
||||
/// </value>
|
||||
public string Size { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public enum FileIconSize
|
||||
{
|
||||
/// <summary>
|
||||
/// The small
|
||||
/// small - 16x16 (per app.getFileIcon size mapping).
|
||||
/// </summary>
|
||||
small,
|
||||
|
||||
/// <summary>
|
||||
/// The normal
|
||||
/// normal - 32x32 (per app.getFileIcon size mapping).
|
||||
/// </summary>
|
||||
normal,
|
||||
|
||||
/// <summary>
|
||||
/// The large
|
||||
/// large - 48x48 on Linux, 32x32 on Windows, unsupported on macOS (per app.getFileIcon size mapping).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("Linux")]
|
||||
[SupportedOSPlatform("Windows")]
|
||||
large
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,18 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Controls the behavior of <see cref="App.Focus(FocusOptions)"/>.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class FocusOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Make the receiver the active app even if another app is currently active.
|
||||
/// <para/>
|
||||
/// You should seek to use the <see cref="Steal"/> option as sparingly as possible.
|
||||
/// You should seek to use the steal option as sparingly as possible.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macOS")]
|
||||
public bool Steal { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,84 +1,99 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Graphics Feature Status from chrome://gpu/ as returned by app.getGPUFeatureStatus().
|
||||
/// Each field reflects the status of a GPU capability reported by Chromium.
|
||||
///
|
||||
/// Possible values for all fields:
|
||||
/// - disabled_software: Software only. Hardware acceleration disabled (yellow)
|
||||
/// - disabled_off: Disabled (red)
|
||||
/// - disabled_off_ok: Disabled (yellow)
|
||||
/// - unavailable_software: Software only, hardware acceleration unavailable (yellow)
|
||||
/// - unavailable_off: Unavailable (red)
|
||||
/// - unavailable_off_ok: Unavailable (yellow)
|
||||
/// - enabled_readback: Hardware accelerated but at reduced performance (yellow)
|
||||
/// - enabled_force: Hardware accelerated on all pages (green)
|
||||
/// - enabled: Hardware accelerated (green)
|
||||
/// - enabled_on: Enabled (green)
|
||||
/// - enabled_force_on: Force enabled (green)
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class GPUFeatureStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Canvas.
|
||||
/// Gets or sets the status for Canvas.
|
||||
/// </summary>
|
||||
[JsonProperty("2d_canvas")]
|
||||
[JsonPropertyName("2d_canvas")]
|
||||
public string Canvas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash.
|
||||
/// Gets or sets the status for Flash.
|
||||
/// </summary>
|
||||
[JsonProperty("flash_3d")]
|
||||
[JsonPropertyName("flash_3d")]
|
||||
public string Flash3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash Stage3D.
|
||||
/// Gets or sets the status for Flash Stage3D.
|
||||
/// </summary>
|
||||
[JsonProperty("flash_stage3d")]
|
||||
[JsonPropertyName("flash_stage3d")]
|
||||
public string FlashStage3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flash Stage3D Baseline profile.
|
||||
/// Gets or sets the status for Flash Stage3D Baseline profile.
|
||||
/// </summary>
|
||||
[JsonProperty("flash_stage3d_baseline")]
|
||||
[JsonPropertyName("flash_stage3d_baseline")]
|
||||
public string FlashStage3dBaseline { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compositing.
|
||||
/// Gets or sets the status for Compositing.
|
||||
/// </summary>
|
||||
[JsonProperty("gpu_compositing")]
|
||||
[JsonPropertyName("gpu_compositing")]
|
||||
public string GpuCompositing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Multiple Raster Threads.
|
||||
/// Gets or sets the status for Multiple Raster Threads.
|
||||
/// </summary>
|
||||
[JsonProperty("multiple_raster_threads")]
|
||||
[JsonPropertyName("multiple_raster_threads")]
|
||||
public string MultipleRasterThreads { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Native GpuMemoryBuffers.
|
||||
/// Gets or sets the status for Native GpuMemoryBuffers.
|
||||
/// </summary>
|
||||
[JsonProperty("native_gpu_memory_buffers")]
|
||||
[JsonPropertyName("native_gpu_memory_buffers")]
|
||||
public string NativeGpuMemoryBuffers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Rasterization.
|
||||
/// Gets or sets the status for Rasterization.
|
||||
/// </summary>
|
||||
public string Rasterization { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Video Decode.
|
||||
/// Gets or sets the status for Video Decode.
|
||||
/// </summary>
|
||||
[JsonProperty("video_decode")]
|
||||
[JsonPropertyName("video_decode")]
|
||||
public string VideoDecode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Video Encode.
|
||||
/// Gets or sets the status for Video Encode.
|
||||
/// </summary>
|
||||
[JsonProperty("video_encode")]
|
||||
[JsonPropertyName("video_encode")]
|
||||
public string VideoEncode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// VPx Video Decode.
|
||||
/// Gets or sets the status for VPx Video Decode.
|
||||
/// </summary>
|
||||
[JsonProperty("vpx_decode")]
|
||||
[JsonPropertyName("vpx_decode")]
|
||||
public string VpxDecode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// WebGL.
|
||||
/// Gets or sets the status for WebGL.
|
||||
/// </summary>
|
||||
public string Webgl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// WebGL2.
|
||||
/// Gets or sets the status for WebGL2.
|
||||
/// </summary>
|
||||
public string Webgl2 { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface to use Electrons PostData Object
|
||||
/// Represents a postData item for loadURL/webContents.loadURL options.
|
||||
/// Valid types per Electron docs: 'rawData' and 'file'.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public interface IPostData
|
||||
{
|
||||
/// <summary>
|
||||
/// One of the following:
|
||||
/// rawData - <see cref="UploadRawData"/> The data is available as a Buffer, in the rawData field.
|
||||
/// file - <see cref="UploadFile"/> The object represents a file. The filePath, offset, length and modificationTime fields will be used to describe the file.
|
||||
/// blob - <see cref="Blob"/> The object represents a Blob. The blobUUID field will be used to describe the Blob.
|
||||
/// rawData - <see cref="UploadRawData"/>.
|
||||
/// file - <see cref="UploadFile"/>.
|
||||
/// Based on Electron postData definitions.
|
||||
/// </summary>
|
||||
public string Type { get; }
|
||||
}
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Options for app.importCertificate(options) on Linux.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("linux")]
|
||||
public class ImportCertificateOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Path for the pkcs12 file.
|
||||
/// </summary>
|
||||
public string Certificate { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Passphrase for the certificate.
|
||||
/// </summary>
|
||||
public string Password {get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
using ElectronNET.Converter;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Input event payload as used by webContents 'input-event' and 'before-input-event'.
|
||||
/// Fields map to KeyboardEvent properties where noted, and type/modifiers follow Electron's InputEvent structure.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class InputEvent
|
||||
{
|
||||
/// <summary>
|
||||
@@ -58,15 +59,95 @@ namespace ElectronNET.API.Entities
|
||||
|
||||
/// <summary>
|
||||
/// An array of modifiers of the event, can be `shift`, `control`, `ctrl`, `alt`,
|
||||
/// `meta`, `command`, `cmd`, `isKeypad`, `isAutoRepeat`, `leftButtonDown`,
|
||||
/// `middleButtonDown`, `rightButtonDown`, `capsLock`, `numLock`, `left`, `right`
|
||||
/// `meta`, `command`, `cmd`, `iskeypad`, `isautorepeat`, `leftbuttondown`,
|
||||
/// `middlebuttondown`, `rightbuttondown`, `capslock`, `numlock`, `left`, `right`.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ModifierTypeListConverter))]
|
||||
public List<ModifierType> Modifiers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseInputEvent: The x-coordinate of the event (Integer).
|
||||
/// </summary>
|
||||
public int? X { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseInputEvent: The y-coordinate of the event (Integer).
|
||||
/// </summary>
|
||||
public int? Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseInputEvent: The button pressed, can be 'left', 'middle', or 'right' (optional).
|
||||
/// </summary>
|
||||
public string Button { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseInputEvent: Global x in screen coordinates (Integer, optional).
|
||||
/// </summary>
|
||||
public int? GlobalX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseInputEvent: Global y in screen coordinates (Integer, optional).
|
||||
/// </summary>
|
||||
public int? GlobalY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseInputEvent: Movement delta on x-axis since last event (Integer, optional).
|
||||
/// </summary>
|
||||
public int? MovementX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseInputEvent: Movement delta on y-axis since last event (Integer, optional).
|
||||
/// </summary>
|
||||
public int? MovementY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseInputEvent: Click count (Integer, optional).
|
||||
/// </summary>
|
||||
public int? ClickCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseWheelInputEvent: Horizontal scroll delta (Integer, optional).
|
||||
/// </summary>
|
||||
public int? DeltaX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseWheelInputEvent: Vertical scroll delta (Integer, optional).
|
||||
/// </summary>
|
||||
public int? DeltaY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseWheelInputEvent: Horizontal wheel ticks (Integer, optional).
|
||||
/// </summary>
|
||||
public int? WheelTicksX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseWheelInputEvent: Vertical wheel ticks (Integer, optional).
|
||||
/// </summary>
|
||||
public int? WheelTicksY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseWheelInputEvent: Horizontal acceleration ratio (Integer, optional).
|
||||
/// </summary>
|
||||
public int? AccelerationRatioX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseWheelInputEvent: Vertical acceleration ratio (Integer, optional).
|
||||
/// </summary>
|
||||
public int? AccelerationRatioY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseWheelInputEvent: True if wheel deltas are precise (optional).
|
||||
/// </summary>
|
||||
public bool? HasPreciseScrollingDeltas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For MouseWheelInputEvent: True if the target can scroll (optional).
|
||||
/// </summary>
|
||||
public bool? CanScroll { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Can be `undefined`, `mouseDown`, `mouseUp`, `mouseMove`, `mouseEnter`,
|
||||
/// `mouseLeave`, `contextMenu`, `mouseWheel`, `rawKeyDown`, `keyDown`, `keyUp`,
|
||||
/// `mouseLeave`, `contextMenu`, `mouseWheel`, `rawKeyDown`, `keyDown`, `keyUp`, `char`,
|
||||
/// `gestureScrollBegin`, `gestureScrollEnd`, `gestureScrollUpdate`,
|
||||
/// `gestureFlingStart`, `gestureFlingCancel`, `gesturePinchBegin`,
|
||||
/// `gesturePinchEnd`, `gesturePinchUpdate`, `gestureTapDown`, `gestureShowPress`,
|
||||
@@ -76,7 +157,6 @@ namespace ElectronNET.API.Entities
|
||||
/// `touchScrollStarted`, `pointerDown`, `pointerUp`, `pointerMove`,
|
||||
/// `pointerRawUpdate`, `pointerCancel` or `pointerCausedUaAction`.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public InputEventType Type { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,26 +9,32 @@ public enum InputEventType
|
||||
///
|
||||
/// </summary>
|
||||
undefined,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
mouseDown,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
mouseUp,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
mouseMove,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
mouseEnter,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
mouseLeave,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -54,6 +60,11 @@ public enum InputEventType
|
||||
/// </summary>
|
||||
keyUp,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@char,
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Jump List category definition used with app.setJumpList(categories).
|
||||
/// Matches Electron's JumpListCategory structure.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class JumpListCategory
|
||||
{
|
||||
/// <summary>
|
||||
/// Must be set if type is custom, otherwise it should be omitted.
|
||||
/// Gets or sets the name; must be set if <c>type</c> is <c>custom</c>, otherwise it should be omitted.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Array of objects if type is tasks or custom, otherwise it should be omitted.
|
||||
/// Gets or sets the array of <see cref="JumpListItem"/> objects if <c>type</c> is <c>tasks</c> or <c>custom</c>; otherwise it should be omitted.
|
||||
/// </summary>
|
||||
public JumpListItem[] Items { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// One of the following: "tasks" | "frequent" | "recent" | "custom"
|
||||
/// Gets or sets the category type. One of: <c>tasks</c> | <c>frequent</c> | <c>recent</c> | <c>custom</c>.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public JumpListCategoryType Type { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Jump list category kinds for app.setJumpList (Windows).
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("Windows")]
|
||||
public enum JumpListCategoryType
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,58 +1,65 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Jump List item used in app.setJumpList(categories) on Windows.
|
||||
/// Matches Electron's JumpListItem structure.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class JumpListItem
|
||||
{
|
||||
/// <summary>
|
||||
/// The command line arguments when program is executed. Should only be set if type is task.
|
||||
/// Gets or sets the command line arguments when <c>program</c> is executed. Should only be set if <c>type</c> is <c>task</c>.
|
||||
/// </summary>
|
||||
public string Args { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Description of the task (displayed in a tooltip). Should only be set if type is task.
|
||||
/// Gets or sets the description of the task (displayed in a tooltip). Should only be set if <c>type</c> is <c>task</c>. Maximum length 260 characters.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The index of the icon in the resource file. If a resource file contains multiple
|
||||
/// Gets or sets the index of the icon in the resource file. If a resource file contains multiple
|
||||
/// icons this value can be used to specify the zero-based index of the icon that
|
||||
/// should be displayed for this task.If a resource file contains only one icon,
|
||||
/// should be displayed for this task. If a resource file contains only one icon,
|
||||
/// this property should be set to zero.
|
||||
/// </summary>
|
||||
public int IconIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The absolute path to an icon to be displayed in a Jump List, which can be an
|
||||
/// Gets or sets the absolute path to an icon to be displayed in a Jump List, which can be an
|
||||
/// arbitrary resource file that contains an icon(e.g. .ico, .exe, .dll). You can
|
||||
/// usually specify process.execPath to show the program icon.
|
||||
/// </summary>
|
||||
public string IconPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Path of the file to open, should only be set if type is file.
|
||||
/// Gets or sets the path of the file to open; should only be set if <c>type</c> is <c>file</c>.
|
||||
/// </summary>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Path of the program to execute, usually you should specify process.execPath
|
||||
/// which opens the current program.Should only be set if type is task.
|
||||
/// Gets or sets the path of the program to execute, usually specify process.execPath
|
||||
/// which opens the current program. Should only be set if <c>type</c> is <c>task</c>.
|
||||
/// </summary>
|
||||
public string Program { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The text to be displayed for the item in the Jump List. Should only be set if type is task.
|
||||
/// Gets or sets the text to be displayed for the item in the Jump List. Should only be set if <c>type</c> is <c>task</c>.
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// One of the following: "task" | "separator" | "file"
|
||||
/// Gets or sets the item type. One of: <c>task</c> | <c>separator</c> | <c>file</c>.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public JumpListItemType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the working directory. Default is empty.
|
||||
/// </summary>
|
||||
public string WorkingDirectory { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Jump list item kinds for app.setJumpList (Windows).
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("Windows")]
|
||||
public enum JumpListItemType
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Settings returned by app.getJumpListSettings() on Windows.
|
||||
/// Matches Electron's JumpListSettings object.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class JumpListSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// The minimum number of items that will be shown in the Jump List (for a more detailed description of this value see the
|
||||
/// <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd378398(v=vs.85).aspx">MSDN</see> docs).
|
||||
/// The minimum number of items that will be shown in the Jump List.
|
||||
/// </summary>
|
||||
public int MinItems { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Array of JumpListItem objects that correspond to items that the user has explicitly removed from custom categories
|
||||
/// in the Jump List. These items must not be re-added to the Jump List in the next call to <see cref="App.SetJumpList"/>, Windows will
|
||||
/// not display any custom category that contains any of the removed items.
|
||||
/// in the Jump List. These items must not be re-added to the Jump List in the next call to app.setJumpList(categories);
|
||||
/// Windows will not display any custom category that contains any of the removed items.
|
||||
/// </summary>
|
||||
public JumpListItem[] RemovedItems { get; set; } = new JumpListItem[0];
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Options for BrowserWindow.loadURL(url, options) / webContents.loadURL(url, options).
|
||||
/// Matches Electron's loadURL options.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class LoadURLOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// A HTTP Referrer url.
|
||||
/// An HTTP Referrer URL. In Electron this may be a string or a Referrer object.
|
||||
/// </summary>
|
||||
public string HttpReferrer { get; set; }
|
||||
|
||||
@@ -16,20 +18,18 @@
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Base url (with trailing path separator) for files to be loaded by the data url.
|
||||
/// This is needed only if the specified url is a data url and needs to load other
|
||||
/// files.
|
||||
/// Base URL (with trailing path separator) for files to be loaded by the data URL.
|
||||
/// Needed only if the specified URL is a data URL and needs to load other files.
|
||||
/// </summary>
|
||||
public string BaseURLForDataURL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Extra headers for the request.
|
||||
/// Extra headers separated by "\n".
|
||||
/// </summary>
|
||||
public string ExtraHeaders { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PostData Object for the request.
|
||||
/// Can be <see cref="UploadRawData"/>, <see cref="UploadFile"/> or <see cref="Blob"/>
|
||||
/// Post data for the request. Matches Electron's postData: (UploadRawData | UploadFile)[]
|
||||
/// </summary>
|
||||
public IPostData[] PostData { get; set; }
|
||||
}
|
||||
|
||||
37
src/ElectronNET.API/API/Entities/LoginItemLaunchItem.cs
Normal file
37
src/ElectronNET.API/API/Entities/LoginItemLaunchItem.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Windows launch entry as returned by app.getLoginItemSettings().launchItems.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class LoginItemLaunchItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Name value of a registry entry.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The executable to an app that corresponds to a registry entry.
|
||||
/// </summary>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The command-line arguments to pass to the executable.
|
||||
/// </summary>
|
||||
public string[] Args { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// One of <c>user</c> or <c>machine</c>. Indicates whether the registry entry is under HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE.
|
||||
/// </summary>
|
||||
public string Scope { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// True if the app registry key is startup approved and therefore shows as enabled in Task Manager and Windows settings.
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Return object for app.getLoginItemSettings() on macOS and Windows.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class LoginItemSettings
|
||||
{
|
||||
/// <summary>
|
||||
@@ -11,29 +14,52 @@
|
||||
public bool OpenAtLogin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <see langword="true"/> if the app is set to open as hidden at login. This setting is not available
|
||||
/// <see langword="true"/> if the app is set to open as hidden at login. Deprecated on macOS 13 and up; not available
|
||||
/// on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool OpenAsHidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <see langword="true"/> if the app was opened at login automatically. This setting is not available
|
||||
/// on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool WasOpenedAtLogin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <see langword="true"/> if the app was opened as a hidden login item. This indicates that the app should not
|
||||
/// open any windows at startup. This setting is not available on
|
||||
/// open any windows at startup. Deprecated on macOS 13 and up; not available on
|
||||
/// <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool WasOpenedAsHidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <see langword="true"/> if the app was opened as a login item that should restore the state from the previous
|
||||
/// session. This indicates that the app should restore the windows that were open the last time the app was closed.
|
||||
/// This setting is not available on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
|
||||
/// Deprecated on macOS 13 and up; not available on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool RestoreState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// macOS status: one of <c>not-registered</c>, <c>enabled</c>, <c>requires-approval</c>, or <c>not-found</c>.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Windows: true if app is set to open at login and its run key is not deactivated.
|
||||
/// Differs from <c>OpenAtLogin</c> as it ignores the <c>args</c> option; this is true if the given executable would be launched at login with any arguments.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public bool ExecutableWillLaunchAtLogin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Windows launch entries found in registry.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public LoginItemLaunchItem[] LaunchItems { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
@@ -8,11 +10,25 @@
|
||||
/// <summary>
|
||||
/// The executable path to compare against. Defaults to process.execPath.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The command-line arguments to compare against. Defaults to an empty array.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string[] Args { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of service to query on macOS 13+. Defaults to 'mainAppService'. Only available on macOS 13 and up.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the service. Required if type is non-default. Only available on macOS 13 and up.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string ServiceName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Settings object for app.setLoginItemSettings() on macOS and Windows.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class LoginSettings
|
||||
{
|
||||
/// <summary>
|
||||
@@ -14,19 +17,46 @@
|
||||
/// <summary>
|
||||
/// <see langword="true"/> to open the app as hidden. Defaults to <see langword="false"/>. The user can edit this
|
||||
/// setting from the System Preferences so app.getLoginItemSettings().wasOpenedAsHidden should be checked when the app is
|
||||
/// opened to know the current value. This setting is not available on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see>.
|
||||
/// opened to know the current value. This setting is not available on <see href="https://www.electronjs.org/docs/tutorial/mac-app-store-submission-guide">MAS builds</see> and does not work on macOS 13 and up.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool OpenAsHidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The executable to launch at login. Defaults to process.execPath.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The command-line arguments to pass to the executable. Defaults to an empty
|
||||
/// array.Take care to wrap paths in quotes.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string[] Args { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of service to add as a login item. Defaults to 'mainAppService'. Only available on macOS 13 and up.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the service. Required if <c>Type</c> is non-default. Only available on macOS 13 and up.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string ServiceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Change the startup approved registry key and enable/disable the app in Task Manager and Windows Settings. Defaults to true.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Value name to write into registry. Defaults to the app's AppUserModelId().
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,42 @@
|
||||
namespace ElectronNET.API.Entities;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Margins object used by webContents.print options and webContents.printToPDF.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class Margins
|
||||
{
|
||||
/// <summary>
|
||||
/// Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen,
|
||||
/// Gets or sets the margin type. Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen,
|
||||
/// you will also need to specify `top`, `bottom`, `left`, and `right`.
|
||||
/// </summary>
|
||||
public string MarginType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The top margin of the printed web page, in pixels.
|
||||
/// Gets or sets the top margin of the printed web page. Units depend on API:
|
||||
/// - webContents.print: pixels
|
||||
/// - webContents.printToPDF: inches
|
||||
/// </summary>
|
||||
public int Top { get; set; }
|
||||
public double Top { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The bottom margin of the printed web page, in pixels.
|
||||
/// Gets or sets the bottom margin of the printed web page. Units depend on API:
|
||||
/// - webContents.print: pixels
|
||||
/// - webContents.printToPDF: inches
|
||||
/// </summary>
|
||||
public int Bottom { get; set; }
|
||||
public double Bottom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The left margin of the printed web page, in pixels.
|
||||
/// Gets or sets the left margin of the printed web page. Units depend on API:
|
||||
/// - webContents.print: pixels
|
||||
/// - webContents.printToPDF: inches
|
||||
/// </summary>
|
||||
public int Left { get; set; }
|
||||
public double Left { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The right margin of the printed web page, in pixels.
|
||||
/// Gets or sets the right margin of the printed web page. Units depend on API:
|
||||
/// - webContents.print: pixels
|
||||
/// - webContents.printToPDF: inches
|
||||
/// </summary>
|
||||
public int Right { get; set; }
|
||||
public double Right { get; set; }
|
||||
}
|
||||
@@ -1,24 +1,28 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Process memory info as returned by process.getProcessMemoryInfo().
|
||||
/// Values are reported in Kilobytes.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class MemoryInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of memory currently pinned to actual physical RAM.
|
||||
/// Gets or sets the amount of memory currently pinned to actual physical RAM.
|
||||
/// </summary>
|
||||
public int WorkingSetSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The maximum amount of memory that has ever been pinned to actual physical RAM.
|
||||
/// Gets or sets the maximum amount of memory that has ever been pinned to actual physical RAM.
|
||||
/// </summary>
|
||||
public int PeakWorkingSetSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of memory not shared by other processes, such as JS heap or HTML
|
||||
/// content.
|
||||
/// Gets or sets the amount of memory not shared by other processes, such as JS heap or HTML content. Windows only.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public int PrivateBytes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,30 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class MenuItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Will be called with click(menuItem, browserWindow, event) when the menu item is
|
||||
/// Will be called with click(menuItem, browserWindow, event) when the menu item is
|
||||
/// clicked.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Action Click { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Define the action of the menu item, when specified the click property will be
|
||||
/// ignored.
|
||||
/// Gets or sets the action (role) of the menu item. When specified, the click property will be ignored.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public MenuRole Role { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Can be normal, separator, submenu, checkbox or radio.
|
||||
/// Gets or sets the menu item type. Can be normal, separator, submenu, checkbox, radio, header (macOS 14+), or palette (macOS 14+).
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public MenuType Type { get; set; }
|
||||
|
||||
|
||||
@@ -46,8 +43,15 @@ namespace ElectronNET.API.Entities
|
||||
/// <value>
|
||||
/// The sublabel.
|
||||
/// </value>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string Sublabel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hover text for this menu item (macOS).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string ToolTip { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the accelerator.
|
||||
@@ -67,17 +71,31 @@ namespace ElectronNET.API.Entities
|
||||
public string Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If false, the menu item will be greyed out and unclickable.
|
||||
/// Gets or sets a value indicating whether the item is enabled. If false, the menu item will be greyed out and unclickable.
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// If false, the menu item will be entirely hidden.
|
||||
/// Gets or sets a value indicating whether the item is visible. If false, the menu item will be entirely hidden.
|
||||
/// </summary>
|
||||
public bool Visible { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Should only be specified for checkbox or radio type menu items.
|
||||
/// Gets or sets a value indicating whether the accelerator should work when the item is hidden. Default is true (macOS).
|
||||
/// When false, prevents the accelerator from triggering the item if the item is not visible.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool? AcceleratorWorksWhenHidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the accelerator should be registered with the system or only displayed (Linux/Windows). Defaults to true.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
[SupportedOSPlatform("linux")]
|
||||
public bool? RegisterAccelerator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the item is checked. Should only be specified for checkbox or radio items.
|
||||
/// </summary>
|
||||
public bool Checked { get; set; }
|
||||
|
||||
@@ -89,15 +107,44 @@ namespace ElectronNET.API.Entities
|
||||
public MenuItem[] Submenu { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unique within a single menu. If defined then it can be used as a reference to
|
||||
/// this item by the position attribute.
|
||||
/// The item to share when the role is shareMenu (macOS).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public SharingItem SharingItem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a unique id within a single menu. If defined then it can be used as a reference for placement.
|
||||
/// </summary>
|
||||
public string Id { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// This field allows fine-grained definition of the specific location within a
|
||||
/// given menu.
|
||||
/// This field allows fine-grained definition of the specific location within a given menu.
|
||||
/// </summary>
|
||||
public string Position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of item ids. Inserts this item before the item(s) with the specified id(s).
|
||||
/// If the referenced item doesn't exist the item will be inserted at the end of the menu.
|
||||
/// Also implies that this item should be placed in the same group as the referenced item(s).
|
||||
/// </summary>
|
||||
public string[] Before { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of item ids. Inserts this item after the item(s) with the specified id(s).
|
||||
/// If the referenced item doesn't exist the item will be inserted at the end of the menu.
|
||||
/// </summary>
|
||||
public string[] After { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of item ids. Places this item's containing group before the containing group
|
||||
/// of the item(s) with the specified id(s).
|
||||
/// </summary>
|
||||
public string[] BeforeGroupContaining { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of item ids. Places this item's containing group after the containing group
|
||||
/// of the item(s) with the specified id(s).
|
||||
/// </summary>
|
||||
public string[] AfterGroupContaining { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,14 +31,14 @@
|
||||
paste,
|
||||
|
||||
/// <summary>
|
||||
/// The pasteandmatchstyle
|
||||
/// The pasteAndMatchStyle
|
||||
/// </summary>
|
||||
pasteandmatchstyle,
|
||||
pasteAndMatchStyle,
|
||||
|
||||
/// <summary>
|
||||
/// The selectall
|
||||
/// The selectAll
|
||||
/// </summary>
|
||||
selectall,
|
||||
selectAll,
|
||||
|
||||
/// <summary>
|
||||
/// The delete
|
||||
@@ -68,12 +68,12 @@
|
||||
/// <summary>
|
||||
/// Reload the current window ignoring the cache.
|
||||
/// </summary>
|
||||
forcereload,
|
||||
forceReload,
|
||||
|
||||
/// <summary>
|
||||
/// Toggle developer tools in the current window
|
||||
/// </summary>
|
||||
toggledevtools,
|
||||
toggleDevTools,
|
||||
|
||||
/// <summary>
|
||||
/// Toggle full screen mode on the current window
|
||||
@@ -83,17 +83,17 @@
|
||||
/// <summary>
|
||||
/// Reset the focused page’s zoom level to the original size
|
||||
/// </summary>
|
||||
resetzoom,
|
||||
resetZoom,
|
||||
|
||||
/// <summary>
|
||||
/// Zoom in the focused page by 10%
|
||||
/// </summary>
|
||||
zoomin,
|
||||
zoomIn,
|
||||
|
||||
/// <summary>
|
||||
/// Zoom out the focused page by 10%
|
||||
/// </summary>
|
||||
zoomout,
|
||||
zoomOut,
|
||||
|
||||
/// <summary>
|
||||
/// Whole default “Edit” menu (Undo, Copy, etc.)
|
||||
@@ -118,7 +118,7 @@
|
||||
/// <summary>
|
||||
/// Only macOS: Map to the hideOtherApplications action
|
||||
/// </summary>
|
||||
hideothers,
|
||||
hideOthers,
|
||||
|
||||
/// <summary>
|
||||
/// Only macOS: Map to the unhideAllApplications action
|
||||
@@ -128,12 +128,12 @@
|
||||
/// <summary>
|
||||
/// Only macOS: Map to the startSpeaking action
|
||||
/// </summary>
|
||||
startspeaking,
|
||||
startSpeaking,
|
||||
|
||||
/// <summary>
|
||||
/// Only macOS: Map to the stopSpeaking action
|
||||
/// </summary>
|
||||
stopspeaking,
|
||||
stopSpeaking,
|
||||
|
||||
/// <summary>
|
||||
/// Only macOS: Map to the arrangeInFront action
|
||||
@@ -158,6 +158,108 @@
|
||||
/// <summary>
|
||||
/// Only macOS: The submenu is a “Services” menu
|
||||
/// </summary>
|
||||
services
|
||||
services,
|
||||
|
||||
/// <summary>
|
||||
/// Toggle built-in spellchecker.
|
||||
/// </summary>
|
||||
toggleSpellChecker,
|
||||
|
||||
/// <summary>
|
||||
/// The submenu is a "File" menu.
|
||||
/// </summary>
|
||||
fileMenu,
|
||||
|
||||
/// <summary>
|
||||
/// The submenu is a "View" menu.
|
||||
/// </summary>
|
||||
viewMenu,
|
||||
|
||||
/// <summary>
|
||||
/// The application menu.
|
||||
/// </summary>
|
||||
appMenu,
|
||||
|
||||
/// <summary>
|
||||
/// The submenu is a "Share" menu.
|
||||
/// </summary>
|
||||
shareMenu,
|
||||
|
||||
/// <summary>
|
||||
/// Displays a list of files recently opened by the app.
|
||||
/// </summary>
|
||||
recentDocuments,
|
||||
|
||||
/// <summary>
|
||||
/// Clear the recent documents list.
|
||||
/// </summary>
|
||||
clearRecentDocuments,
|
||||
|
||||
/// <summary>
|
||||
/// Toggle the tab bar (macOS).
|
||||
/// </summary>
|
||||
toggleTabBar,
|
||||
|
||||
/// <summary>
|
||||
/// Select the next tab (macOS).
|
||||
/// </summary>
|
||||
selectNextTab,
|
||||
|
||||
/// <summary>
|
||||
/// Select the previous tab (macOS).
|
||||
/// </summary>
|
||||
selectPreviousTab,
|
||||
|
||||
/// <summary>
|
||||
/// Show all tabs (macOS).
|
||||
/// </summary>
|
||||
showAllTabs,
|
||||
|
||||
/// <summary>
|
||||
/// Merge all windows (macOS).
|
||||
/// </summary>
|
||||
mergeAllWindows,
|
||||
|
||||
/// <summary>
|
||||
/// Move the current tab to a new window (macOS).
|
||||
/// </summary>
|
||||
moveTabToNewWindow,
|
||||
|
||||
/// <summary>
|
||||
/// Show substitutions panel (macOS).
|
||||
/// </summary>
|
||||
showSubstitutions,
|
||||
|
||||
/// <summary>
|
||||
/// Toggle smart quotes (macOS).
|
||||
/// </summary>
|
||||
toggleSmartQuotes,
|
||||
|
||||
/// <summary>
|
||||
/// Toggle smart dashes (macOS).
|
||||
/// </summary>
|
||||
toggleSmartDashes,
|
||||
|
||||
/// <summary>
|
||||
/// Toggle text replacement (macOS).
|
||||
/// </summary>
|
||||
toggleTextReplacement,
|
||||
|
||||
// Backwards-compatibility aliases (old identifiers) to avoid breaking existing code.
|
||||
// These map to the same enum values as their official values.
|
||||
pasteandmatchstyle = pasteAndMatchStyle,
|
||||
selectall = selectAll,
|
||||
forcereload = forceReload,
|
||||
toggledevtools = toggleDevTools,
|
||||
resetzoom = resetZoom,
|
||||
zoomin = zoomIn,
|
||||
zoomout = zoomOut,
|
||||
hideothers = hideOthers,
|
||||
startspeaking = startSpeaking,
|
||||
stopspeaking = stopSpeaking,
|
||||
togglespellchecker = toggleSpellChecker,
|
||||
togglesmartquotes = toggleSmartQuotes,
|
||||
togglesmartdashes = toggleSmartDashes,
|
||||
toggletextreplacement = toggleTextReplacement
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,48 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Menu item types matching Electron's MenuItem.type values.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public enum MenuType
|
||||
{
|
||||
/// <summary>
|
||||
/// The normal
|
||||
/// Normal menu item.
|
||||
/// </summary>
|
||||
normal,
|
||||
|
||||
/// <summary>
|
||||
/// The separator
|
||||
/// Separator between items.
|
||||
/// </summary>
|
||||
separator,
|
||||
|
||||
/// <summary>
|
||||
/// The submenu
|
||||
/// Submenu container.
|
||||
/// </summary>
|
||||
submenu,
|
||||
|
||||
/// <summary>
|
||||
/// The checkbox
|
||||
/// Checkbox item.
|
||||
/// </summary>
|
||||
checkbox,
|
||||
|
||||
/// <summary>
|
||||
/// The radio
|
||||
/// Radio item.
|
||||
/// </summary>
|
||||
radio
|
||||
radio,
|
||||
|
||||
/// <summary>
|
||||
/// Header item (macOS 14+).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
header,
|
||||
|
||||
/// <summary>
|
||||
/// Palette item (macOS 14+).
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
palette
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,82 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Options for dialog.showMessageBox / dialog.showMessageBoxSync.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class MessageBoxOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Can be "none", "info", "error", "question" or "warning". On Windows, "question"
|
||||
/// displays the same icon as "info", unless you set an icon using the "icon"
|
||||
/// option. On macOS, both "warning" and "error" display the same warning icon.
|
||||
/// Gets or sets the type. Can be "none", "info", "error", "question" or "warning". On Windows, "question" displays the same icon as "info", unless you set an icon using the "icon" option. On macOS, both "warning" and "error" display the same warning icon.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public MessageBoxType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Array of texts for buttons. On Windows, an empty array will result in one button
|
||||
/// labeled "OK".
|
||||
/// Gets or sets the array of texts for buttons. On Windows, an empty array will result in one button labeled "OK".
|
||||
/// </summary>
|
||||
public string[] Buttons { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Index of the button in the buttons array which will be selected by default when
|
||||
/// the message box opens.
|
||||
/// Gets or sets the index of the button in the buttons array which will be selected by default when the message box opens.
|
||||
/// </summary>
|
||||
public int DefaultId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Title of the message box, some platforms will not show it.
|
||||
/// Gets or sets the title of the message box; some platforms will not show it.
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Content of the message box.
|
||||
/// Gets or sets the content of the message box.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Extra information of the message.
|
||||
/// Gets or sets the extra information of the message.
|
||||
/// </summary>
|
||||
public string Detail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If provided, the message box will include a checkbox with the given label. The
|
||||
/// checkbox state can be inspected only when using callback.
|
||||
/// Gets or sets the checkbox label. If provided, the message box will include a checkbox with the given label.
|
||||
/// </summary>
|
||||
public string CheckboxLabel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initial checked state of the checkbox. false by default.
|
||||
/// Gets or sets the initial checked state of the checkbox. Defaults to false.
|
||||
/// </summary>
|
||||
public bool CheckboxChecked { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the icon.
|
||||
/// Gets or sets the icon for the message box.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The icon.
|
||||
/// </value>
|
||||
public string Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The index of the button to be used to cancel the dialog, via the Esc key. By
|
||||
/// default this is assigned to the first button with "cancel" or "no" as the label.
|
||||
/// If no such labeled buttons exist and this option is not set, 0 will be used as
|
||||
/// the return value or callback response. This option is ignored on Windows.
|
||||
/// Gets or sets the custom width of the text in the message box.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public int? TextWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the index of the button to be used to cancel the dialog via the Esc key. By default this is assigned to the first button with "cancel" or "no" as the label. If no such labeled buttons exist and this option is not set, 0 will be used.
|
||||
/// </summary>
|
||||
public int CancelId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// On Windows Electron will try to figure out which one of the buttons are common
|
||||
/// buttons(like "Cancel" or "Yes"), and show the others as command links in the
|
||||
/// dialog.This can make the dialog appear in the style of modern Windows apps. If
|
||||
/// you don't like this behavior, you can set noLink to true.
|
||||
/// Gets or sets a value indicating whether to disable Windows command-links behavior (noLink).
|
||||
/// On Windows Electron will try to figure out which one of the buttons are common buttons (like "Cancel" or "Yes"), and show the others as command links in the dialog. Set to true to disable this behavior.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public bool NoLink { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Normalize the keyboard access keys across platforms. Default is false. Enabling
|
||||
/// this assumes AND character is used in the button labels for the placement of the keyboard
|
||||
/// Gets or sets a value indicating whether to normalize the keyboard access keys across platforms. Default is false. Enabling this assumes '&' is used in the button labels for the placement of the keyboard
|
||||
/// shortcut access key and labels will be converted so they work correctly on each
|
||||
/// platform, AND characters are removed on macOS, converted to _ on Linux, and left
|
||||
/// untouched on Windows.For example, a button label of VieANDw will be converted to
|
||||
/// Vie_w on Linux and View on macOS and can be selected via Alt-W on Windows and
|
||||
/// platform, '&' characters are removed on macOS, converted to '_' on Linux, and left
|
||||
/// untouched on Windows. For example, a button label of "View" will be converted to "Vie_w" on Linux and "View" on macOS and can be selected via Alt-W on Windows and
|
||||
/// Linux.
|
||||
/// </summary>
|
||||
public bool NormalizeAccessKeys { get; set; }
|
||||
@@ -98,4 +90,4 @@ namespace ElectronNET.API.Entities
|
||||
Message = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,19 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Result returned by dialog.showMessageBox / dialog.showMessageBoxSync.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class MessageBoxResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the response.
|
||||
/// The index of the clicked button.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The response.
|
||||
/// </value>
|
||||
public int Response { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [checkbox checked].
|
||||
/// The checked state of the checkbox if CheckboxLabel was set; otherwise false.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if [checkbox checked]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool CheckboxChecked { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Message box type for dialog.showMessageBox/showMessageBoxSync.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public enum MessageBoxType
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
namespace ElectronNET.API.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the possible modifier keys for a keyboard input.
|
||||
/// Specifies the possible modifier keys for a keyboard input (maps to InputEvent.modifiers).
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public enum ModifierType
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
@@ -21,9 +22,9 @@ namespace ElectronNET.API.Entities
|
||||
|
||||
private static readonly Dictionary<string, float> ScaleFactorPairs = new Dictionary<string, float>
|
||||
{
|
||||
{"@2x", 2.0f}, {"@3x", 3.0f}, {"@1x", 1.0f}, {"@4x", 4.0f},
|
||||
{"@5x", 5.0f}, {"@1.25x", 1.25f}, {"@1.33x", 1.33f}, {"@1.4x", 1.4f},
|
||||
{"@1.5x", 1.5f}, {"@1.8x", 1.8f}, {"@2.5x", 2.5f}
|
||||
{ "@2x", 2.0f }, { "@3x", 3.0f }, { "@1x", 1.0f }, { "@4x", 4.0f },
|
||||
{ "@5x", 5.0f }, { "@1.25x", 1.25f }, { "@1.33x", 1.33f }, { "@1.4x", 1.4f },
|
||||
{ "@1.5x", 1.5f }, { "@1.8x", 1.8f }, { "@2.5x", 2.5f }
|
||||
};
|
||||
|
||||
private static float? ExtractDpiFromFilePath(string filePath)
|
||||
@@ -34,6 +35,7 @@ namespace ElectronNET.API.Entities
|
||||
.Select(p => p.Value)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
private static Image BytesToImage(byte[] bytes)
|
||||
{
|
||||
var ms = new MemoryStream(bytes);
|
||||
@@ -83,7 +85,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <param name="dataUrl">A data URL with a base64 encoded image.</param>
|
||||
public static NativeImage CreateFromDataURL(string dataUrl)
|
||||
{
|
||||
var images = new Dictionary<float,Image>();
|
||||
var images = new Dictionary<float, Image>();
|
||||
var parsedDataUrl = Regex.Match(dataUrl, @"data:image/(?<type>.+?),(?<data>.+)");
|
||||
var actualData = parsedDataUrl.Groups["data"].Value;
|
||||
var binData = Convert.FromBase64String(actualData);
|
||||
@@ -101,7 +103,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <param name="path">The path of the image</param>
|
||||
public static NativeImage CreateFromPath(string path)
|
||||
{
|
||||
var images = new Dictionary<float,Image>();
|
||||
var images = new Dictionary<float, Image>();
|
||||
if (Regex.IsMatch(path, "(@.+?x)"))
|
||||
{
|
||||
var dpi = ExtractDpiFromFilePath(path);
|
||||
@@ -164,7 +166,7 @@ namespace ElectronNET.API.Entities
|
||||
/// </summary>
|
||||
public NativeImage Crop(Rectangle rect)
|
||||
{
|
||||
var images = new Dictionary<float,Image>();
|
||||
var images = new Dictionary<float, Image>();
|
||||
foreach (var image in _images)
|
||||
{
|
||||
images.Add(image.Key, Crop(rect.X, rect.Y, rect.Width, rect.Height, image.Key));
|
||||
@@ -196,7 +198,7 @@ namespace ElectronNET.API.Entities
|
||||
if (options.Buffer.Length > 0)
|
||||
{
|
||||
_images[options.ScaleFactor] =
|
||||
CreateFromBuffer(options.Buffer, new CreateFromBufferOptions {ScaleFactor = options.ScaleFactor})
|
||||
CreateFromBuffer(options.Buffer, new CreateFromBufferOptions { ScaleFactor = options.ScaleFactor })
|
||||
.GetScale(options.ScaleFactor);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(options.DataUrl))
|
||||
@@ -225,7 +227,7 @@ namespace ElectronNET.API.Entities
|
||||
/// </summary>
|
||||
public byte[] GetBitmap(BitmapOptions options)
|
||||
{
|
||||
return ToBitmap(new ToBitmapOptions{ ScaleFactor = options.ScaleFactor });
|
||||
return ToBitmap(new ToBitmapOptions { ScaleFactor = options.ScaleFactor });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -267,6 +269,12 @@ namespace ElectronNET.API.Entities
|
||||
/// </summary>
|
||||
public bool IsTemplateImage => _isTemplateImage;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the image is considered a macOS template image.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool IsMacTemplateImage => _isTemplateImage;
|
||||
|
||||
/// <summary>
|
||||
/// Deprecated. Marks the image as a template image.
|
||||
/// </summary>
|
||||
@@ -419,12 +427,13 @@ namespace ElectronNET.API.Entities
|
||||
return codec;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
internal Dictionary<float,string> GetAllScaledImages()
|
||||
internal Dictionary<float, string> GetAllScaledImages()
|
||||
{
|
||||
var dict = new Dictionary<float,string>();
|
||||
var dict = new Dictionary<float, string>();
|
||||
try
|
||||
{
|
||||
foreach (var (scale, image) in _images)
|
||||
@@ -436,7 +445,7 @@ namespace ElectronNET.API.Entities
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
@@ -450,4 +459,4 @@ namespace ElectronNET.API.Entities
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,39 @@
|
||||
using System;
|
||||
using ElectronNET.API.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
internal class NativeImageJsonConverter : JsonConverter
|
||||
/// <yremarks>Project-specific: JSON converter for NativeImage; no MCP structure equivalent.</yremarks>
|
||||
internal class NativeImageJsonConverter : JsonConverter<NativeImage>
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
public override void Write(Utf8JsonWriter writer, NativeImage value, JsonSerializerOptions options)
|
||||
{
|
||||
if (value is NativeImage nativeImage)
|
||||
if (value is null)
|
||||
{
|
||||
var scaledImages = nativeImage.GetAllScaledImages();
|
||||
serializer.Serialize(writer, scaledImages);
|
||||
writer.WriteNullValue();
|
||||
return;
|
||||
}
|
||||
|
||||
var scaledImages = value.GetAllScaledImages();
|
||||
JsonSerializer.Serialize(writer, scaledImages, ElectronJson.Options);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
public override NativeImage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
var dict = serializer.Deserialize<Dictionary<float, string>>(reader);
|
||||
var dict = JsonSerializer.Deserialize<Dictionary<float, string>>(ref reader, ElectronJson.Options);
|
||||
var newDictionary = new Dictionary<float, Image>();
|
||||
foreach (var item in dict)
|
||||
{
|
||||
var bytes = Convert.FromBase64String(item.Value);
|
||||
newDictionary.Add(item.Key, Image.FromStream(new MemoryStream(bytes)));
|
||||
}
|
||||
|
||||
return new NativeImage(newDictionary);
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(NativeImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,21 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public class NotificationAction
|
||||
{
|
||||
/// <summary>
|
||||
/// The label for the given action.
|
||||
/// Gets or sets the label for the action.
|
||||
/// </summary>
|
||||
public string Text { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of action, can be button.
|
||||
/// Gets or sets the type of action; can be 'button'.
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,77 +1,91 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class NotificationOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// A title for the notification, which will be shown at the top of the notification
|
||||
/// window when it is shown.
|
||||
/// Gets or sets the title for the notification, which will be shown at the top of the notification window when it is shown.
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A subtitle for the notification, which will be displayed below the title.
|
||||
/// Gets or sets the subtitle for the notification, which will be displayed below the title.
|
||||
/// </summary>
|
||||
public string SubTitle { get; set; }
|
||||
[SupportedOSPlatform("macos")]
|
||||
[JsonPropertyName("subtitle")]
|
||||
public string Subtitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The body text of the notification, which will be displayed below the title or
|
||||
/// subtitle.
|
||||
/// Gets or sets the body text of the notification, which will be displayed below the title or subtitle.
|
||||
/// </summary>
|
||||
public string Body { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to emit an OS notification noise when showing the notification.
|
||||
/// Gets or sets a value indicating whether to suppress the OS notification noise when showing the notification.
|
||||
/// </summary>
|
||||
public bool Silent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// An icon to use in the notification.
|
||||
/// Gets or sets an icon to use in the notification. Can be a string path or a NativeImage. If a string is passed, it must be a valid path to a local icon file.
|
||||
/// </summary>
|
||||
public string Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to add an inline reply option to the notification.
|
||||
/// Gets or sets a value indicating whether to add an inline reply option to the notification.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public bool HasReply { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The timeout duration of the notification. Can be 'default' or 'never'.
|
||||
/// Gets or sets the timeout duration of the notification. Can be 'default' or 'never'.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("linux")]
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string TimeoutType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The placeholder to write in the inline reply input field.
|
||||
/// Gets or sets the placeholder to write in the inline reply input field.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string ReplyPlaceholder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the sound file to play when the notification is shown.
|
||||
/// Gets or sets the name of the sound file to play when the notification is shown.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string Sound { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The urgency level of the notification. Can be 'normal', 'critical', or 'low'.
|
||||
/// Gets or sets the urgency level of the notification. Can be 'normal', 'critical', or 'low'.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("linux")]
|
||||
public string Urgency { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Actions to add to the notification. Please read the available actions and
|
||||
/// limitations in the NotificationAction documentation.
|
||||
/// Gets or sets the actions to add to the notification. Please read the available actions and limitations in the NotificationAction documentation.
|
||||
/// </summary>
|
||||
public NotificationAction Actions { get; set; }
|
||||
[SupportedOSPlatform("macos")]
|
||||
public NotificationAction[] Actions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A custom title for the close button of an alert. An empty string will cause the
|
||||
/// default localized text to be used.
|
||||
/// Gets or sets a custom title for the close button of an alert. An empty string will cause the default localized text to be used.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public string CloseButtonText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a custom description of the Notification on Windows superseding all properties above. Provides full customization of design and behavior of the notification.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string ToastXml { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when the notification is shown to the user, note this could be fired
|
||||
/// multiple times as a notification can be shown multiple times through the Show()
|
||||
@@ -86,7 +100,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <value>
|
||||
/// The show identifier.
|
||||
/// </value>
|
||||
[JsonProperty]
|
||||
[JsonInclude]
|
||||
internal string ShowID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -101,7 +115,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <value>
|
||||
/// The click identifier.
|
||||
/// </value>
|
||||
[JsonProperty]
|
||||
[JsonInclude]
|
||||
internal string ClickID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -118,7 +132,7 @@ namespace ElectronNET.API.Entities
|
||||
/// <value>
|
||||
/// The close identifier.
|
||||
/// </value>
|
||||
[JsonProperty]
|
||||
[JsonInclude]
|
||||
internal string CloseID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -127,6 +141,7 @@ namespace ElectronNET.API.Entities
|
||||
/// The string the user entered into the inline reply field
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[SupportedOSPlatform("macos")]
|
||||
public Action<string> OnReply { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -135,14 +150,15 @@ namespace ElectronNET.API.Entities
|
||||
/// <value>
|
||||
/// The reply identifier.
|
||||
/// </value>
|
||||
[JsonProperty]
|
||||
[JsonInclude]
|
||||
internal string ReplyID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// macOS only - The index of the action that was activated
|
||||
/// macOS only - The index of the action that was activated.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Action<string> OnAction { get; set; }
|
||||
[SupportedOSPlatform("macos")]
|
||||
public Action<int> OnAction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the action identifier.
|
||||
@@ -150,9 +166,17 @@ namespace ElectronNET.API.Entities
|
||||
/// <value>
|
||||
/// The action identifier.
|
||||
/// </value>
|
||||
[JsonProperty]
|
||||
[JsonInclude]
|
||||
internal string ActionID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Windows only: Emitted when an error is encountered while creating and showing the native notification.
|
||||
/// Corresponds to the 'failed' event on Notification.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[SupportedOSPlatform("windows")]
|
||||
public Action<string> OnFailed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NotificationOptions"/> class.
|
||||
/// </summary>
|
||||
|
||||
@@ -15,4 +15,24 @@ public class OnDidFailLoadInfo
|
||||
/// Validated URL.
|
||||
/// </summary>
|
||||
public string ValidatedUrl { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Error description string.
|
||||
/// </summary>
|
||||
public string ErrorDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// True if the event pertains to the main frame.
|
||||
/// </summary>
|
||||
public bool IsMainFrame { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The process id for the frame.
|
||||
/// </summary>
|
||||
public int FrameProcessId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The routing id for the frame.
|
||||
/// </summary>
|
||||
public int FrameRoutingId { get; set; }
|
||||
}
|
||||
@@ -1,17 +1,23 @@
|
||||
namespace ElectronNET.API.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 'OnDidNavigate' event details.
|
||||
/// 'did-navigate' event details for main frame navigation.
|
||||
/// </summary>
|
||||
/// <remarks>Up-to-date with Electron API 39.2</remarks>
|
||||
public class OnDidNavigateInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Navigated URL.
|
||||
/// The URL navigated to.
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// HTTP response code.
|
||||
/// HTTP response code (-1 for non-HTTP navigations).
|
||||
/// </summary>
|
||||
public int HttpResponseCode { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HTTP status text (empty for non-HTTP navigations).
|
||||
/// </summary>
|
||||
public string HttpStatusText { get; set; }
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user