Compare commits

...

111 Commits

Author SHA1 Message Date
Florian Rappl
b107244eb5 Review corrections 2026-03-05 01:52:29 +01:00
Florian Rappl
14cba046a7 Start with correct port 2026-03-04 09:52:15 +01:00
Florian Rappl
633f4ae224 Respect auth token from Node.js start 2026-03-04 00:02:18 +01:00
Florian Rappl
14ecbb65a3 Compute auth token in Node 2026-03-03 23:54:14 +01:00
Florian Rappl
cf5938450f Use dynamic port by default 2026-03-03 11:11:54 +01:00
Florian Rappl
087b0e22f0 Avoid setting authorization if not present 2026-03-03 01:09:45 +01:00
Florian Rappl
29498b0017 Wait for the port to be read 2026-03-02 22:33:48 +01:00
Florian Rappl
49a24d3fc9 Fixed trailing whitespace 2026-03-02 22:01:33 +01:00
Florian Rappl
4450d629f1 Merge branch 'feature/secure-connection' of https://github.com/ElectronNET/Electron.NET into feature/secure-connection 2026-03-02 21:59:19 +01:00
Florian Rappl
248c64d6dd Auto-determine used port 2026-03-02 21:21:19 +01:00
Florian Rappl
d1e858465c Removed SignalR 2026-03-02 18:03:03 +01:00
Florian Rappl
7837b69999 Always set to info 2026-03-02 16:42:58 +01:00
Florian Rappl
834c22aaa1 Merge branch 'main' of https://github.com/ElectronNET/Electron.NET into feature/secure-connection 2026-02-27 00:37:39 +01:00
Florian Rappl
c8268fae0e Merge pull request #1034 from ElectronNET/develop
Release 0.4.1
2026-02-26 07:00:49 +01:00
Florian Rappl
8eead56cbc removed trailing whitespace 2026-02-25 16:02:34 +01:00
Florian Rappl
e28eadc32d Merge branch 'develop' of https://github.com/ElectronNET/Electron.NET into develop 2026-02-25 15:57:42 +01:00
Florian Rappl
9a935c009e Updated changelog for release 2026-02-25 15:57:26 +01:00
Florian Rappl
c22c248f0b Merge pull request #1031 from AeonSake/1028-preload-override
Add Documentation for Preload Script
2026-02-25 14:55:48 +01:00
softworkz
842e8700ef Add overload for GetAllDisplaysAsync() with timout parameter 2026-02-25 04:11:13 +01:00
Florian Rappl
92e5a6f862 Removed logger 2026-02-23 00:05:33 +01:00
Florian Rappl
16925f401b Renamed facades 2026-02-22 23:56:06 +01:00
Florian Rappl
7e7bc21f2d Merge branch 'develop' of https://github.com/ElectronNET/Electron.NET into feature/secure-connection 2026-02-22 21:51:05 +01:00
Aeon
3850a71579 Revert "Add check for existing preload script path before overriding"
This reverts commit 497e6aa423.
2026-02-17 23:33:13 +01:00
Aeon
d5df30718b Update documentation to reflect current approach 2026-02-17 23:32:55 +01:00
Florian Rappl
77ca79acc9 Merge pull request #1027 from softworkz/submit_housekeeping
Fix global.json link in solution, add missing json file
2026-02-17 23:25:13 +01:00
Florian Rappl
05fb9e5a29 Merge pull request #1026 from softworkz/submit_disposed_exceptions
SocketIoFacade: Improve disposal, avoid exception on tear-down
2026-02-17 23:23:57 +01:00
Aeon
850d8f6902 Add documentation for preload script and warning for Blazor 2026-02-17 19:48:12 +01:00
Aeon
497e6aa423 Add check for existing preload script path before overriding 2026-02-17 19:31:06 +01:00
softworkz
41c5b5af62 Relax test timings 2026-02-14 21:54:45 +01:00
softworkz
10679029e8 Add missing electron-builder.json in sample project 2026-02-14 21:26:46 +01:00
softworkz
a451e3a599 Fix global.json link in solution 2026-02-14 21:26:31 +01:00
softworkz
09c735a10f SocketIoFacade: Improve disposal, avoid exception on tear-down 2026-02-14 21:25:25 +01:00
Florian Rappl
5eb49b0e54 Removed unnecessary debugger helper 2026-02-05 15:54:23 +01:00
Florian Rappl
2390ba7b2f Removed misleading comment 2026-02-05 15:53:50 +01:00
Florian Rappl
564ec7b191 Added forgotten debug helper 2026-02-05 15:51:48 +01:00
Florian Rappl
32bcfa95ab Restore logging 2026-02-04 11:44:27 +01:00
Florian Rappl
cf735fab4c Original formatting 2026-02-04 11:33:15 +01:00
Florian Rappl
cf1cb18d7a Merge branch 'develop' of https://github.com/ElectronNET/Electron.NET into feature/secure-connection 2026-02-04 11:29:01 +01:00
Florian Rappl
8009348941 Update transformed files 2026-02-04 11:26:06 +01:00
Florian Rappl
b3b124bde1 Updated TS formatting to match prettier 2026-02-04 11:25:30 +01:00
Florian Rappl
21226e1ef0 Updated deps 2026-02-04 11:18:55 +01:00
Florian Rappl
7174118a3e Merge pull request #1019 from DYH1319/feat/submit_new_event_for_ipc
feat: submit new events for ipcMain
2026-02-03 00:32:04 +01:00
Florian Rappl
931aec8cd9 Updated lodash 2026-02-02 16:15:19 +01:00
Florian Rappl
bbd1065a05 Merge branch 'epsitec-improvements' into feature/secure-connection 2026-02-02 16:13:18 +01:00
Florian Rappl
0fa0abd093 Merge branch 'develop' of https://github.com/ElectronNET/Electron.NET into feature/secure-connection 2026-02-02 16:01:30 +01:00
Pierre Arnaud
bfd51e64f7 Fix dead-lock on shutdown 2026-01-31 15:37:52 +01:00
Pierre Arnaud
bb4337a31c Cosmetic 2026-01-31 15:37:35 +01:00
Pierre Arnaud
57753eb632 Replace Console.WriteLine with ILogger for startup time
Changed startup time measurement to use structured logging via ILogger
instead of Console.WriteLine. This provides:
- Consistent logging format with other app messages
- Proper log level (Information)
- Structured data (ElapsedMilliseconds as named parameter)
- Better integration with logging infrastructure

Output now appears as:
info: Electron.Startup[0]
      App startup time until Electron launch: 1284 ms
2026-01-31 14:37:32 +01:00
Pierre Arnaud
614673605a Add explicit BrowserRefresh logging filter
Added 'Microsoft.AspNetCore.Watch.BrowserRefresh' to Warning level
to suppress the 'Middleware loaded' and 'Script injected' debug messages
that appear when running with dotnet watch or Ctrl+F5 from Visual Studio.
2026-01-31 14:30:07 +01:00
Pierre Arnaud
52744a1922 Final cleanup: Suppress remaining debug output
- Removed '|| ' prefix from ProcessRunner stdout/stderr redirection
  * Changed to Debug.WriteLine (only visible when debugger attached)
- Suppressed [Startup] timing messages in StartupManager
  * Moved to Debug.WriteLine for diagnostic purposes
- Suppressed 'No testhost detected' messages
- Added logging configuration to suppress ASP.NET Watch debug messages
  * Microsoft.AspNetCore.Watch set to Warning level

Result: Clean console output in development with only meaningful messages.
Timing and debug traces still available when debugger is attached.
2026-01-31 14:27:34 +01:00
Pierre Arnaud
03da5cd7cb Phase 4: Replace Console output with Debug.WriteLine in diagnostic code
- Replaced Console.WriteLine with System.Diagnostics.Debug.WriteLine in:
  * LaunchOrderDetector (probe scoring)
  * UnpackagedDetector (probe scoring)
  * ElectronProcessActive (StartInternal traces)
- Removed '[StartInternal]: after run:' trace
- Debug.WriteLine only outputs when debugger is attached

These were the noisiest debugging traces. Other Console.WriteLine usage
in StartupManager, ProcessRunner, etc. would require ILogger injection
which is a larger architectural change deferred for now.
2026-01-31 11:19:28 +01:00
Pierre Arnaud
805d942b11 Phase 3: Configure SignalR logging to reduce verbosity
- Updated SafeLogger to support minimum log level threshold
- Configure SignalR log level based on environment:
  * Debug mode: Info level (connection events only)
  * Development/Production: Warning level (errors/warnings only)
- Eliminates verbose packet-level logging
- Connection lifecycle events still visible in debug mode

This dramatically reduces console noise while preserving important events.
2026-01-31 11:17:26 +01:00
Pierre Arnaud
29b1f088ce Phase 2: Clean up debugging traces and use environment-aware logging
- Removed 'Entry!!!:' debugging leftover from main.js
- Replaced all console.log/warn/error with logger methods
- Preserved console.time/timeEnd for performance measurements
- Updated browserWindows.js and webContents.js to use logger
- Changed debug traces to DEBUG level (won't show in production)
- Changed info messages to INFO level (show in development)
- All errors use ERROR level (always shown)

Socket.IO connection messages now respect log levels based on environment.
2026-01-31 11:16:11 +01:00
Pierre Arnaud
4a62103749 Phase 1: Add environment-aware logging infrastructure
- Created logger.js with log levels (DEBUG, INFO, WARN, ERROR)
- Implemented environment detection (debug/development/production)
- Auto-detect based on flags, NODE_ENV, and debugger
- Preserve console.time/timeEnd for performance measurements
- Updated SignalR bridge to use new logger system
- Replaced safeConsole calls with environment-aware logger

Default log levels:
- Debug mode: DEBUG and above
- Development: INFO and above
- Production: WARN and above
2026-01-31 11:09:25 +01:00
Pierre Arnaud
38ee6fabb4 Only enable SignalR detailed errors in development
Changed EnableDetailedErrors to be conditional based on:
- Debugger attached (DebuggerHelper.IsAttached)
- context.HostingEnvironment.IsDevelopment()

Updated ConfigureServices to accept WebHostBuilderContext to properly
access the hosting environment instead of directly reading environment
variables. This prevents detailed error messages from being exposed in
production builds, which is important for security.
2026-01-31 10:04:29 +01:00
Pierre Arnaud
0ee2bbe31c Refactor debugger detection to use shared DebuggerHelper
Created a new DebuggerHelper class with Lazy<bool> initialization that is
shared by both LaunchOrderDetector and UnpackagedDetector. This eliminates
code duplication and provides a cleaner, more maintainable solution.

- Added DebuggerHelper.cs with lazy-initialized IsAttached property
- Refactored LaunchOrderDetector to use DebuggerHelper
- Refactored UnpackagedDetector to use DebuggerHelper
- Removed nullable bool pattern in favor of Lazy<bool>
2026-01-31 09:38:26 +01:00
Pierre Arnaud
a88e10bbf2 Measure total startup time 2026-01-31 09:18:24 +01:00
Pierre Arnaud
39c7e61ae5 Auto-quit Electron when pipe to .NET process breaks
When an EPIPE error is detected (indicating the .NET process has terminated),
Electron now automatically quits gracefully instead of just suppressing the error.
This ensures the Electron window doesn't remain open after the backend dies.

Uses setImmediate to allow any pending operations to complete before quitting,
and includes a flag to prevent multiple quit attempts.
2026-01-31 09:17:09 +01:00
Pierre Arnaud
96c454aedb Add process-level EPIPE error handlers
The previous fix using try-catch wasn't sufficient because EPIPE errors
are thrown asynchronously at the socket level when writing to stdout/stderr.
Added error event handlers to process.stdout and process.stderr to catch
and suppress EPIPE errors at the source, preventing the error dialog entirely.
2026-01-31 09:10:48 +01:00
Pierre Arnaud
5a77284610 Fix EPIPE error when .NET process terminates before Electron
- Added SafeLogger class to wrap SignalR logging and prevent EPIPE errors
- Enhanced safeConsole wrapper to include warn method
- Replaced all console calls in SignalRBridge with safeConsole
- Configured SignalR to use custom SafeLogger instead of default ConsoleLogger

This prevents the 'broken pipe, write' error dialog when the .NET process
is killed before the Electron process can cleanly shut down.
2026-01-31 09:04:58 +01:00
Pierre Arnaud
0a23659196 Phase 1b: Optimize startup detection for faster .NET initialization
Performance optimizations to startup detection:
- Reduced GatherBuildInfo: >1000ms → 7ms (99% faster!)
- Reduced CollectProcessData: →  86ms
- Reduced DetectAppTypeAndStartup: → 91ms
- Total StartupManager.Initialize: → 91ms (down from >1 second)

Electron startup also improved significantly:
- Module loading: 719ms → 108ms (85% faster!)
- SignalR connection: 884ms → 403ms (54% faster!)
- Total Electron startup: 2.3s → 700ms (70% faster!)

Optimizations applied:

1. Directory checks (UnpackagedDetector):
   - Changed GetDirectories().Any() to direct Directory.Exists()
   - Avoids expensive directory enumeration
   - Saves ~200-500ms on slow disks

2. Debugger state caching:
   - Cache Debugger.IsAttached result in static field
   - Avoids multiple expensive debugger checks
   - Used by both UnpackagedDetector and LaunchOrderDetector
   - Saves ~50-100ms per check

3. Added timing measurements:
   - Added Stopwatch to StartupManager.Initialize()
   - Detailed timing for each initialization phase
   - Visibility into startup performance

Results:
- .NET startup detection: >1000ms → 91ms
- Electron module loading: 719ms → 108ms
- SignalR connection: 884ms → 403ms
- **Total improvement: ~70% faster startup**

The combination of faster directory checks, cached debugger state,
and parallel module loading (from previous commit) results in
sub-second startup times in development mode.
2026-01-30 23:02:13 +01:00
Pierre Arnaud
5d224568d0 Phase 1: Implement parallel module loading for faster startup
Performance optimization:
- Refactored 18 sequential require() calls to load in parallel
- Use Promise.all() to load all API modules simultaneously
- Added comprehensive startup timing measurements

Timing breakdown (before → after):
- Module loading: ~900-1200ms → 719ms (20-40% faster)
- Total Electron startup: Measured at 2.3 seconds
- SignalR connection: 884ms
- Host ready signal: 33ms

Implementation:
- Load all modules in parallel using Promise.resolve().then()
- Organize modules by priority (critical, secondary, utility)
- Maintain backward compatibility with global variable assignments
- Add console.time() measurements for each phase

Benefits:
- Faster perceived startup time
- Non-blocking module initialization
- Clear visibility into startup bottlenecks
- Foundation for future lazy loading optimizations

This is the first phase of startup optimization, targeting the
biggest bottleneck (sequential module loading) with the least effort.
2026-01-30 22:56:37 +01:00
Pierre Arnaud
1c0b9378d2 Phase 6: Add comprehensive authentication documentation
Created new authentication guide:
- docs/SignalR-Authentication-Guide.md (500+ lines)
- Complete threat model and security architecture
- Flow diagrams and implementation details
- Troubleshooting guide with common issues
- FAQ covering design decisions and usage

Updated SignalR implementation summary:
- Added authentication & security section
- Documented token flow and cookie management
- Security properties and protection scope
- Logging & monitoring guidelines
- Multi-user testing procedures
- Updated file changes summary and success metrics

Documentation includes:
- Architecture diagrams (ASCII art)
- Code examples for all components
- Step-by-step authentication flow
- Security considerations and rationale
- Common troubleshooting scenarios
- Testing recommendations
2026-01-30 22:39:45 +01:00
Pierre Arnaud
c12a706289 Phase 5.2: Add comprehensive logging and error handling for authentication
Middleware logging:
- Log successful authentication with cookie setting
- Log failed authentication attempts with path and remote IP
- Log token prefix (first 8 chars) for invalid tokens, never full token
- Added structured logging with ILogger<T>

Electron error handling:
- Detect 401 authentication errors in SignalR connection
- Provide helpful error message about --authtoken parameter
- Differentiate auth errors from other connection failures

Documentation:
- Added XML comments explaining security model
- Documented token generation rationale (128-bit entropy)
- Clarified middleware validation flow in comments

Security:
- Never log full token values
- Generic error messages to prevent information leakage
- Failed auth attempts logged for security monitoring
2026-01-30 22:37:37 +01:00
Pierre Arnaud
8cc3fe4fd7 Phase 5.1: Fix quit handler to support both Socket.IO and SignalR modes
- Added checks for undefined variables before cleanup
- Socket.IO resources (server, apiProcess, io) only cleaned up in legacy mode
- SignalR connection properly stopped in SignalR mode
- Improved error messages to identify which cleanup failed
- Prevents 'Cannot read properties of undefined' error on app quit
2026-01-30 22:36:18 +01:00
Pierre Arnaud
893de1510d Phase 3: Pass authentication token to SignalR connection URL
- Modified main.js to pass authToken to SignalRBridge constructor
- Updated signalr-bridge.js to append token to hub URL
- Removed skip logic for negotiate endpoint in middleware
- SignalR negotiate request now includes token for authentication
- Cookie is set after successful negotiate for subsequent requests

This enables SignalR connections to authenticate using the same
token-based mechanism as HTTP requests, completing the authentication
flow for both Blazor pages and SignalR hub communication.
2026-01-30 22:35:39 +01:00
Pierre Arnaud
6f49a663ea Phase 4: Inject authentication service into RuntimeController and set token 2026-01-30 19:20:03 +01:00
Pierre Arnaud
5b9e2b8b3b Phase 2.1: Register authentication services and middleware in Program.cs 2026-01-30 19:19:23 +01:00
Pierre Arnaud
dee640c526 Phase 1.2: Extract token in Electron and append to URL
- Extract authtoken from command-line in main.js

- Store token in global.authToken for access by API modules

- Append token to initial window URL as query parameter

- Update both JS and TS versions of browserWindows

- First request will be: http://localhost:PORT/?token=GUID
2026-01-30 19:14:09 +01:00
Pierre Arnaud
f598fbf5ce Phase 1.1: Generate authentication token in RuntimeController
- Add authenticationToken field to store GUID

- Generate secure token using Guid.NewGuid().ToString('N')

- Pass token to Electron via --authtoken command-line parameter

- Token is 32 hex characters with 128 bits of entropy
2026-01-30 19:13:12 +01:00
Pierre Arnaud
6847520ea8 Remove HSTS and HTTPS redirection for Electron apps
HSTS and HTTPS redirection are designed for public web servers, not
desktop applications:

- ASP.NET Core only listens on http://localhost (local-only)
- No man-in-the-middle risk for same-machine communication
- HTTPS would require certificate setup with no security benefit
- HTTPS overhead slows down local IPC unnecessarily

Electron apps should use plain HTTP for localhost communication.
2026-01-30 17:30:07 +01:00
Pierre Arnaud
75151282ff Remove unnecessary UseWebSockets() call
SignalR's MapHub<T>() automatically enables WebSocket support, making
explicit UseWebSockets() redundant. SignalR also supports fallback
transports (Server-Sent Events, Long Polling) if WebSockets are unavailable.

Updated documentation to reflect this and clarify that WebSockets are
enabled automatically by MapHub().
2026-01-30 17:28:40 +01:00
Pierre Arnaud
17ef6853ab Fix ASP0014 warning: Use top-level route registration for ElectronHub
Changed from app.UseEndpoints() pattern to direct app.MapHub() call,
following modern ASP.NET Core conventions. This removes the analyzer
warning while maintaining the same functionality.
2026-01-30 17:14:14 +01:00
Pierre Arnaud
12f011bc33 Add comprehensive SignalR implementation documentation
Created detailed summary document incorporating:
- All 6 implementation phases (complete)
- Usage examples with code snippets
- Architecture decisions and rationale
- Critical fixes and their solutions
- Blazor Server integration considerations
- Backward compatibility guarantees
- Known limitations and future enhancements
- Success metrics and validation

Document serves as both implementation reference and user guide.
2026-01-30 17:11:57 +01:00
Pierre Arnaud
217fe83334 Add documentation comments to SignalR implementation
Added comprehensive code comments explaining:
- RuntimeControllerAspNetDotnetFirstSignalR: .NET-first startup flow and key differences from Socket.IO
- SignalRFacade: Type conversion handling and event propagation details
- signalr-bridge.js: Socket.IO compatibility layer and arg handling
- main.js: Keep-alive window pattern and SignalR startup sequence

Comments focus on explaining WHY decisions were made, not just WHAT the code does.
2026-01-30 17:08:37 +01:00
Pierre Arnaud
1fc881674d Clean up debug logging from SignalR implementation
Remove excessive console logging that was added during debugging:
- Removed verbose logging from Program.cs (app ready callback steps)
- Removed HTTP request logging middleware
- Cleaned up RuntimeControllerAspNetDotnetFirstSignalR lifecycle logging
- Streamlined ElectronHub connection/event logging
- Simplified SignalRFacade event handling logging
- Reduced JavaScript logging in main.js and signalr-bridge.js
- Reset log levels to Warning for SignalR components in appsettings

Kept only essential error logging and critical state transitions.
Production-ready logging levels maintained.
2026-01-30 17:07:24 +01:00
Pierre Arnaud
6e369aabef Fix static files and CSS asset reference for SignalR sample
- Fix middleware order: UseAntiforgery must be between UseRouting and UseEndpoints
- Add UseStaticFiles() to serve wwwroot content
- Fix scoped CSS bundle reference: use lowercase 'electronnet-samples-blazorsignalr.styles.css' to match generated asset name
- Add HTTP request logging for debugging
- Enable detailed logging for routing and static files in development
2026-01-30 16:58:29 +01:00
Pierre Arnaud
06a332827b Fix window shutdown and URL port for SignalR mode
- Destroy keep-alive window when first real window is created (enables proper window-all-closed behavior)
- Update ElectronNetRuntime.AspNetWebPort with actual port after Kestrel starts (fixes http://localhost:0 issue)
2026-01-30 16:43:53 +01:00
Pierre Arnaud
23f79244ae Fix SignalR event args spreading for Electron handlers
- Changed event handler to receive args as single array parameter
- Spread array elements as individual arguments to match Socket.IO behavior
2026-01-30 16:40:20 +01:00
Pierre Arnaud
6b9187cf6e Fix SignalR bridge communication issues
- Fix duplicate SignalR connection in main.js (removed redundant connect block)
- Fix race condition: Electron now signals 'electron-host-ready' after loading API modules
- Fix type conversion in SignalRFacade for event handlers (handle JsonElement and numeric types)
- Fix SignalR argument mismatch: pass args as array instead of spread, use object[] instead of params
- .NET now waits for electron-host-ready before calling app ready callback
2026-01-30 16:36:27 +01:00
Pierre Arnaud
108ef19a3b CRITICAL FIX: Prevent Electron from quitting in SignalR mode
ROOT CAUSE: Electron quits when app.on('ready') completes with 0 windows.
In SignalR mode, no windows are created immediately, so Electron exits,
triggering ElectronProcess_Stopped and shutting down ASP.NET.

SOLUTION: Create an invisible 1x1 keep-alive window in SignalR mode to
prevent Electron from quitting while waiting for SignalR connection.

Also:
- Make app.on('ready') async and await startSignalRApiBridge()
- Add window-all-closed handler for SignalR mode
- Add extensive debug logging to track lifecycle
- Don't subscribe to electronProcess.Ready in SignalR controller

This fixes the premature shutdown that prevented SignalR connection.
2026-01-30 15:29:48 +01:00
Pierre Arnaud
8c6020e35b WIP: Debugging SignalR connection timeout
- Add WebSockets middleware to ASP.NET pipeline
- Move HTTPS redirect to production only
- Add extensive debug logging in startSignalRApiBridge
- Enable Warning level logging in SignalR client

Issue: signalRBridge.connect() hangs and never resolves
- Connection starts but never completes
- No error messages from SignalR client
- ASP.NET shuts down after timeout
- ElectronHub.OnConnectedAsync never called

Next: Investigate why WebSocket connection doesn't establish
2026-01-30 13:27:03 +01:00
Pierre Arnaud
547e9f1196 Fix: Add safe console wrapper to prevent EPIPE errors
- Wrap all console.log/error calls in try-catch to handle EPIPE
- Disable SignalR client logging (LogLevel.None)
- Prevents Electron crash when console pipes are closed

This fixes the 'EPIPE: broken pipe, write' error that was preventing
the Electron window from displaying.
2026-01-30 13:22:35 +01:00
Pierre Arnaud
4b971af119 Fix: Execute app ready callback in SignalR mode
- Add RunReadyCallback execution when SignalR connects
- This triggers window creation and other app initialization
- Fixes missing variables in main.js (desktopCapturer, electronHostHook, touchBar, shellApi)
- Window now opens successfully in SignalR mode

Known issue: EPIPE console error when logging to closed pipe (to be fixed)
2026-01-30 13:19:49 +01:00
Pierre Arnaud
da8216b292 Implement bidirectional event routing for SignalR mode
- Update signalr-bridge.js to handle .NET→Electron events via 'event' channel
- Add socket.io-compatible .on() and .emit() methods to SignalRBridge
- Update main.js to load all Electron API modules with SignalR bridge
- Update SignalRFacade.Emit() to send events via 'event' channel
- Add ElectronHub.ElectronEvent() to receive Electron→.NET events
- Add SignalRFacade.TriggerEvent() to invoke .NET event handlers
- Remove duplicate ElectronEvent method from hub

This enables full bidirectional communication:
- .NET can call Electron APIs via Emit (e.g., createBrowserWindow)
- Electron can send events back to .NET (e.g., BrowserWindowCreated)
- Event handlers registered via On/Once now work with SignalR
2026-01-30 13:09:55 +01:00
Pierre Arnaud
be609a513e Refactor: Introduce IFacade interface for SocketIO and SignalR facades
- Create IFacade interface defining common API for SocketIO and SignalR
- Update SocketIoFacade to implement IFacade
- Update SignalRFacade to implement IFacade (add Connect no-op)
- Update RuntimeControllerBase.Socket to return IFacade
- Update RuntimeControllerAspNetBase.Socket to return IFacade
- Update RuntimeControllerDotNetFirst.Socket to return IFacade
- Update ElectronNetRuntime.GetSocket() to return IFacade
- Update BridgeConnector.Socket to return IFacade

This enables polymorphic usage of both facades throughout the codebase
and prepares for full Electron API integration with SignalR mode.
2026-01-30 13:03:19 +01:00
Pierre Arnaud
c4a8de6c4e Fix psl dist folder issue by copying from source after npm install 2026-01-30 12:52:40 +01:00
Pierre Arnaud
5b3d5e07ee Add @microsoft/signalr to package.template.json for npm install during build 2026-01-30 12:46:57 +01:00
Pierre Arnaud
9135aff855 Fix electronurl parameter case sensitivity for Electron command line 2026-01-30 12:39:32 +01:00
Pierre Arnaud
e9efb26dff Fix main.js to check SignalR flags first before legacy mode flags 2026-01-30 12:37:12 +01:00
Pierre Arnaud
e29a3bc27a Fix IsUnpackaged extension to include UnpackedDotnetFirstSignalR 2026-01-30 12:34:42 +01:00
Pierre Arnaud
f55abb357c Fix Electron launch: subscribe to ASP.NET Ready event in SignalR controller 2026-01-30 12:26:17 +01:00
Pierre Arnaud
0b92336de2 Fix dynamic port binding: use 127.0.0.1 instead of localhost for port 0 2026-01-30 12:22:07 +01:00
Pierre Arnaud
4c17027039 Add BlazorSignalR sample to solution file 2026-01-30 12:20:08 +01:00
Pierre Arnaud
5d04ab686a Add ElectronNET.Samples.BlazorSignalR - complete sample app for SignalR mode 2026-01-30 12:17:20 +01:00
Pierre Arnaud
de0c02c503 Add comprehensive documentation for SignalR-based startup mode 2026-01-30 12:11:48 +01:00
Pierre Arnaud
054f5b1c4c Complete Phase 5: Add SignalR startup detection and port 0 configuration 2026-01-30 12:10:49 +01:00
Pierre Arnaud
04ec52208a Fix compilation errors - Phase 4 complete (basic structure) 2026-01-30 12:08:43 +01:00
Pierre Arnaud
268b9c90ce Update RuntimeControllerAspNetDotnetFirstSignalR to use SignalRFacade 2026-01-30 12:06:29 +01:00
Pierre Arnaud
cb7d721b7d Add SignalRFacade for SignalR-based API communication 2026-01-30 12:04:33 +01:00
Pierre Arnaud
c1740b53fc Add SignalR client support to Electron Host for new startup modes 2026-01-30 12:02:46 +01:00
Pierre Arnaud
40aed60c7d Add RuntimeControllerAspNetDotnetFirstSignalR for SignalR-based startup 2026-01-30 12:00:27 +01:00
Pierre Arnaud
8ee81f6abd Add ElectronHub and SignalR infrastructure for new startup modes 2026-01-30 11:58:31 +01:00
Pierre Arnaud
7f2ea4839e Add PackagedDotnetFirstSignalR and UnpackedDotnetFirstSignalR startup methods 2026-01-30 11:57:40 +01:00
DYH1319
092789a5ec feat: Add overloaded methods in IpcMain that supports listeners with a return type of Task<object>. 2026-01-25 00:47:35 +08:00
DYH1319
bff3fffcbd feat: Add the Handle, HandleOnce, and RemoveHandler events to IpcMain 2026-01-24 23:18:16 +08:00
Florian Rappl
456135a562 Merge pull request #1015 from hillin/main
Update Migration Guide
2026-01-21 12:18:25 +01:00
lucas
300f52510c Update Migration Guide with details on electron-builder.json location and launch settings 2026-01-21 15:30:44 +08:00
Florian Rappl
7e6760a428 Merge pull request #998 from ElectronNET/develop
Release 0.4.0
2025-12-19 00:09:34 +01:00
Florian Rappl
cb20fbad25 Merge pull request #991 from ElectronNET/develop
Release 0.3.1
2025-12-16 19:00:07 +01:00
Florian Rappl
bdfbcd5b77 Merge pull request #986 from ElectronNET/develop
Release 0.3.0
2025-12-14 22:13:10 +01:00
162 changed files with 64803 additions and 4002 deletions

View File

@@ -2,8 +2,16 @@
## ElectronNET.Core
- Updated documentation for preload scripts (#1031) @AeonSake
- Updated timeout for electron-builder (#1013) @softworkz
- Updated disposal avoiding exceptions on teardown (#1026) @softworkz
- Updated migration guide (#1015) @hilin
- Fixed handling of `Center` property for windows (#1001)
- Fixed false alarm for `ELECTRON001`, `ELECTRON008`, and `ELECTRON009` (#1012) @softworkz
- Added missing methods on `Cookies` (#1000)
- Added overload for `GetAllDisplaysAsync` with timeout (#1033) @softworkz
- Added `OnBoundsChanged` event (#1014) @softworkz
- Added new events for `ipcMain` (#1019) @DYH1319
# 0.4.0

View File

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

583
docs/Dev/Authentication.md Normal file
View File

@@ -0,0 +1,583 @@
# Electron.NET SignalR Authentication Guide
This guide explains the token-based authentication system implemented for SignalR mode in Electron.NET, designed to protect applications in multi-user environments.
## Table of Contents
1. [Overview](#overview)
2. [Threat Model](#threat-model)
3. [Authentication Architecture](#authentication-architecture)
4. [Implementation Details](#implementation-details)
5. [Security Properties](#security-properties)
6. [Troubleshooting](#troubleshooting)
7. [FAQ](#faq)
## Overview
Electron.NET's SignalR mode includes built-in authentication to ensure that only the Electron process spawned by a specific .NET instance can connect to that instance's HTTP and SignalR endpoints.
**When is this important?**
- Multi-user Windows Server environments (Terminal Services, RDP)
- Shared development machines with multiple users
- Any scenario where multiple users run the same application simultaneously
**What does it protect against?**
- User A's Electron process connecting to User B's .NET backend
- Unauthorized port scanning and connection attempts from other users
- Accidental misconfigurations causing cross-user connections
## Threat Model
### The Problem
When multiple users run the same Electron.NET application on a shared server:
1. Each .NET process binds to a TCP port (e.g., `http://localhost:58971`)
2. TCP ports are visible to **all users** on the machine
3. Without authentication, User A's Electron could connect to User B's backend
```
┌─────────────────────────────────────────────────┐
│ Windows Server (Terminal Services) │
├─────────────────────────────────────────────────┤
│ User A Session │
│ ├─ .NET Process (localhost:58971) │
│ └─ Electron Process │
│ │
│ User B Session │
│ ├─ .NET Process (localhost:61234) │
│ └─ Electron Process (could connect to 58971) │ ❌ Prevent this!
└─────────────────────────────────────────────────┘
```
### The Solution
Each .NET process generates a unique authentication token when launching Electron. Only requests with the correct token are allowed to connect.
```
┌─────────────────────────────────────────────────┐
│ User A Session │
│ ├─ .NET (token: abc123...) │
│ └─ Electron (has token abc123...) │ ✅ Authenticated
│ │
│ User B Session │
│ ├─ .NET (token: xyz789...) │
│ └─ Electron (has token xyz789...) │ ✅ Authenticated
│ │
│ ❌ User B's Electron → User A's .NET │
│ (lacks token abc123...) │ ❌ Rejected (401)
└─────────────────────────────────────────────────┘
```
## Authentication Architecture
### Flow Diagram
```
┌──────────────┐ ┌─────────────────┐
│ .NET Process │ │ Electron Process│
└──────┬───────┘ └────────┬────────┘
│ │
│ 1. Generate Token (GUID) │
│ Token: a3f8b2c1d4e5... │
│ │
│ 2. Launch Electron │
│ --authtoken=a3f8b2c1d4e5... │
│────────────────────────────────────────────────────>│
│ │
│ │ 3. Extract Token
│ │ global.authToken = ...
│ │
│ │ 4. Initial Page Load
│<────────────────────────────────────────────────────│
│ GET /?token=a3f8b2c1d4e5... │
│ │
│ 5. Validate Token │
│ ✓ Valid → Set Cookie │
│────────────────────────────────────────────────────>│
│ HTTP 200 + Set-Cookie: ElectronAuth=... │
│ │
│ │ 6. SignalR Connection
│<────────────────────────────────────────────────────│
│ GET /electron-hub?token=a3f8b2c1d4e5... │
│ │
│ 7. Validate Token, Set Cookie │
│────────────────────────────────────────────────────>│
│ HTTP 200 + Set-Cookie │
│ │
│ │ 8. Subsequent Requests
│<────────────────────────────────────────────────────│
│ GET /api/data │
│ Cookie: ElectronAuth=a3f8b2c1d4e5... │
│ │
│ 9. Validate Cookie │
│────────────────────────────────────────────────────>│
│ HTTP 200 (authenticated) │
│ │
```
### Key Steps
1. **Token Generation**: .NET generates 128-bit cryptographic random GUID
2. **Command-Line Passing**: Token passed to Electron via `--authtoken` parameter
3. **Token Extraction**: Electron stores token in `global.authToken`
4. **URL Appending**: Token appended to initial page and SignalR connection URLs
5. **Middleware Validation**: Every HTTP request validated by middleware
6. **Cookie Setting**: Valid token results in secure HttpOnly cookie
7. **Cookie-Based Requests**: Subsequent requests use cookie (no token in URL)
## Implementation Details
### 1. Token Generation (.NET)
**File**: `src/ElectronNET.AspNet/Runtime/Controllers/RuntimeControllerAspNetDotnetFirstSignalR.cs`
```csharp
private void LaunchElectron()
{
// Generate secure authentication token (128-bit cryptographic random GUID)
this.authenticationToken = Guid.NewGuid().ToString("N"); // 32 hex chars
// Register token with authentication service
this.authenticationService.SetExpectedToken(this.authenticationToken);
// Launch Electron with token
var args = $"--unpackeddotnetsignalr --electronurl={this.actualUrl} --authtoken={this.authenticationToken}";
this.electronProcess = new ElectronProcessActive(isUnPacked, ElectronNetRuntime.ElectronExecutable, args, this.port.Value);
_ = this.electronProcess.Start();
}
```
**Token Format**: 32-character hexadecimal string (e.g., `a3f8b2c1d4e5f6a7b8c9d0e1f2a3b4c5`)
### 2. Authentication Service (.NET)
**File**: `src/ElectronNET.AspNet/Services/ElectronAuthenticationService.cs`
```csharp
public class ElectronAuthenticationService : IElectronAuthenticationService
{
private string _expectedToken;
private readonly object _lock = new object();
public void SetExpectedToken(string token)
{
lock (_lock)
{
_expectedToken = token;
}
}
public bool ValidateToken(string token)
{
if (string.IsNullOrEmpty(token))
return false;
lock (_lock)
{
if (string.IsNullOrEmpty(_expectedToken))
return false;
// Constant-time comparison prevents timing attacks
return ConstantTimeEquals(token, _expectedToken);
}
}
private static bool ConstantTimeEquals(string a, string b)
{
if (a == null || b == null || a.Length != b.Length)
return false;
var result = 0;
for (int i = 0; i < a.Length; i++)
{
result |= a[i] ^ b[i];
}
return result == 0;
}
}
```
**Key Features**:
- Thread-safe with lock
- Constant-time comparison (prevents timing attacks)
- Singleton lifetime (one per .NET instance)
### 3. Authentication Middleware (.NET)
**File**: `src/ElectronNET.AspNet/Middleware/ElectronAuthenticationMiddleware.cs`
```csharp
public async Task InvokeAsync(HttpContext context)
{
// Check if authentication cookie exists
var authCookie = context.Request.Cookies["ElectronAuth"];
if (!string.IsNullOrEmpty(authCookie))
{
if (_authService.ValidateToken(authCookie))
{
await _next(context);
return;
}
else
{
_logger.LogWarning("Invalid cookie for path {Path}", context.Request.Path);
context.Response.StatusCode = 401;
await context.Response.WriteAsync("Unauthorized: Invalid authentication");
return;
}
}
// No cookie - check for token in query string
var token = context.Request.Query["token"].ToString();
if (!string.IsNullOrEmpty(token) && _authService.ValidateToken(token))
{
// Valid token - set cookie for future requests
context.Response.Cookies.Append("ElectronAuth", token, new CookieOptions
{
HttpOnly = true,
SameSite = SameSiteMode.Strict,
Path = "/",
Secure = false, // localhost is HTTP
IsEssential = true
});
await _next(context);
return;
}
// Reject - no valid cookie or token
context.Response.StatusCode = 401;
await context.Response.WriteAsync("Unauthorized: Authentication required");
}
```
**Middleware Order** (IMPORTANT):
```csharp
app.UseMiddleware<ElectronAuthenticationMiddleware>(); // ← FIRST
app.UseRouting();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapHub<ElectronHub>("/electron-hub");
app.MapRazorComponents<App>();
```
### 4. Token Extraction (Electron)
**File**: `src/ElectronNET.Host/main.js`
```javascript
// Extract authentication token from command-line
if (app.commandLine.hasSwitch('authtoken')) {
global.authToken = app.commandLine.getSwitchValue('authtoken');
}
```
### 5. Token in URLs (Electron)
**Initial Page Load** (`src/ElectronNET.Host/api/browserWindows.js`):
```javascript
// Append token to window URL
if (global.authToken) {
const separator = electronUrl.includes('?') ? '&' : '?';
electronUrl = `${electronUrl}${separator}token=${global.authToken}`;
}
window.loadURL(electronUrl);
```
**SignalR Connection** (`src/ElectronNET.Host/api/signalr-bridge.js`):
```javascript
async connect() {
// Append token to SignalR hub URL
const connectionUrl = this.authToken ?
`${this.hubUrl}?token=${this.authToken}` :
this.hubUrl;
this.connection = new signalR.HubConnectionBuilder()
.withUrl(connectionUrl)
.build();
await this.connection.start();
}
```
### 6. Service Registration (Application)
**File**: Your application's `Program.cs`
```csharp
var builder = WebApplication.CreateBuilder(args);
// Register authentication service as singleton
builder.Services.AddSingleton<IElectronAuthenticationService, ElectronAuthenticationService>();
builder.Services.AddElectron();
var app = builder.Build();
// Register middleware BEFORE UseRouting()
app.UseMiddleware<ElectronAuthenticationMiddleware>();
app.UseRouting();
app.MapHub<ElectronHub>("/electron-hub");
app.Run();
```
## Security Properties
### Cookie Configuration
| Property | Value | Purpose |
|----------|-------|---------|
| `HttpOnly` | `true` | Prevents JavaScript access (XSS protection) |
| `SameSite` | `Strict` | Prevents CSRF attacks |
| `Path` | `/` | Cookie sent with all requests |
| `Secure` | `false` | Cannot use on localhost HTTP |
| `IsEssential` | `true` | Required for app to function |
| **Lifetime** | Session | Expires when Electron closes |
### Token Properties
- **Entropy**: 128 bits (2^128 possible values)
- **Format**: 32 hexadecimal characters (GUID without hyphens)
- **Generation**: `Guid.NewGuid()` uses cryptographically secure RNG
- **Lifetime**: Entire application session
- **Uniqueness**: Each .NET instance generates unique token
### What's Protected
**All HTTP endpoints**:
- Blazor Server pages (`/`, `/counter`, etc.)
- Static files (`/css/app.css`, `/js/script.js`)
- API endpoints (custom controllers)
- SignalR hub (`/electron-hub`)
**Both transport modes**:
- Initial token-based authentication (query parameter)
- Cookie-based subsequent requests
**Cross-user isolation**:
- Different users = different tokens
- Invalid token = 401 Unauthorized
### What's NOT Protected Against
**Same-user attacks** (by design):
- Process memory inspection
- Debugger attachment
- Command-line parameter visibility
**Rationale**: A malicious process running as the same user already has full access to:
- Process memory (can read token from RAM)
- Cookies (stored in Electron's data directory)
- All files owned by the user
Token-based authentication focuses on **cross-user isolation**, not same-user security.
## Troubleshooting
### Problem: 401 Unauthorized on Initial Load
**Symptoms**:
```
GET / HTTP/1.1
Response: 401 Unauthorized
```
**Possible Causes**:
1. Token not passed to Electron
2. Token not appended to URL
3. Middleware rejecting valid token
**Debugging Steps**:
1. Check Electron command-line:
```javascript
console.log('Auth Token:', global.authToken);
```
Should print 32-character hex string.
2. Check URL in browser window:
```javascript
console.log('Loading URL:', electronUrl);
```
Should include `?token=<guid>` parameter.
3. Check .NET logs:
```
[Warning] Authentication failed: Invalid token (prefix: a3f8b2c1...)
```
4. Verify middleware registration:
```csharp
app.UseMiddleware<ElectronAuthenticationMiddleware>(); // Before UseRouting()
```
### Problem: SignalR Connection Fails
**Symptoms**:
```
[SignalRBridge] Authentication failed: The authentication token is invalid or missing.
```
**Possible Causes**:
1. Token not passed to `SignalRBridge` constructor
2. Token not appended to hub URL
3. Cookie not being sent
**Debugging Steps**:
1. Check token passed to SignalRBridge:
```javascript
console.log('SignalRBridge token:', this.authToken);
```
2. Check connection URL:
```javascript
console.log('Hub URL:', connectionUrl);
```
Should be `http://localhost:PORT/electron-hub?token=<guid>`.
3. Enable verbose logging:
```javascript
.configureLogging(signalR.LogLevel.Debug)
```
### Problem: Cookie Not Persisting
**Symptoms**: Every request includes token in URL, cookie never set.
**Possible Causes**:
1. Cookie settings incompatible with browser
2. Middleware not setting cookie
3. Response headers not sent
**Debugging Steps**:
1. Check response headers:
```
Set-Cookie: ElectronAuth=a3f8b2c1...; Path=/; HttpOnly; SameSite=Strict
```
2. Check subsequent requests:
```
Cookie: ElectronAuth=a3f8b2c1...
```
3. Enable middleware logging:
```csharp
_logger.LogInformation("Setting cookie for path {Path}", path);
```
### Problem: Token Visible in Process List
**Observation**:
```powershell
wmic process where "name='electron.exe'" get commandline
...--authtoken=a3f8b2c1d4e5f6a7b8c9d0e1f2a3b4c5...
```
**Is this a problem?** No, by design.
**Explanation**:
- Command-line parameters are visible to same-user processes
- This is acceptable because:
- Same user already has access to process memory
- Same user can read cookies from Electron's data directory
- Token-based auth protects against **other users**, not same-user processes
**If you need same-user protection**: Use OS-level access controls (file permissions, process isolation) or consider named pipes with ACLs.
## FAQ
### Q: Why use tokens instead of Process ID validation?
**A**: PIDs can be recycled and reused, making validation unreliable. Additionally:
- PIDs don't provide cryptographic security
- Parent-child validation is platform-specific
- Adds complexity without meaningful security benefit
Token-based authentication provides:
- Cryptographic randomness (128-bit entropy)
- Simple cross-platform implementation
- No race conditions or PID recycling issues
### Q: Why not use HTTPS with certificates?
**A**: Localhost doesn't support HTTPS certificates easily:
- Self-signed certificates trigger browser warnings
- Certificate management adds complexity
- Token-based auth provides equivalent security for localhost IPC
### Q: Can I disable authentication?
**A**: Not recommended, but possible by removing middleware registration:
```csharp
// Remove this line:
// app.UseMiddleware<ElectronAuthenticationMiddleware>();
```
**Warning**: Only do this if:
- Application runs on single-user machines only
- No Terminal Services / RDP access
- You understand the security implications
### Q: Does this work with hot reload?
**A**: Yes, cookie persists across hot reload as long as Electron process keeps running.
### Q: What about multiple Electron windows?
**A**: All windows in the same Electron process share cookies automatically. Authentication works seamlessly across multiple windows.
### Q: How do I test authentication?
**Test 1 - Happy Path**:
1. Run application normally
2. Check logs for "Authentication successful"
3. Verify cookie is set (DevTools → Application → Cookies)
4. Subsequent requests should not include token in URL
**Test 2 - Invalid Token**:
1. Modify token in browser URL: `?token=invalid`
2. Should receive 401 Unauthorized
3. Check logs for "Authentication failed: Invalid token"
**Test 3 - No Token**:
1. Open browser manually to `http://localhost:PORT/`
2. Should receive 401 Unauthorized
3. Check logs for "Authentication failed: No cookie or token"
**Test 4 - Multi-User** (Windows Server/Terminal Services):
1. Launch app as User A
2. In User B session, try to connect to User A's port
3. Should receive 401 Unauthorized
### Q: What about packaged applications?
**A**: Authentication works identically in packaged mode. The `--authtoken` parameter is included in the packaged Electron executable.
### Q: Can I customize the cookie name?
**A**: Yes, modify `AuthCookieName` constant in `ElectronAuthenticationMiddleware.cs`:
```csharp
private const string AuthCookieName = "MyCustomCookieName";
```
## Summary
Electron.NET's token-based authentication provides:
**Security**: 128-bit entropy, constant-time comparison, secure cookies
**Simplicity**: Automatic token generation and validation
**Compatibility**: Works with Blazor, SignalR, and static files
**Monitoring**: Structured logging for security events
**Multi-User**: Cross-user isolation on shared servers
The authentication system is **enabled by default** in SignalR mode and requires minimal configuration. For most applications, simply register the services and middleware - everything else happens automatically.
For additional help or questions, see the [SignalR Implementation Summary](SignalR-Implementation-Summary.md) or open an issue on GitHub.

View File

@@ -85,6 +85,26 @@ BrowserWindowOptions browserWindowOptions = new BrowserWindowOptions
```
### Preload Script
If you require the use of a [preload script](https://www.electronjs.org/docs/latest/tutorial/tutorial-preload), you can specify the file path of the script when creating a new window like so:
```csharp
WebPreferences wp = new WebPreferences();
wp.Preload = "path/to/preload.js";
BrowserWindowOptions browserWindowOptions = new BrowserWindowOptions
{
WebPreferences = wp
};
```
> [!IMPORTANT]
> When using a preload script _AND_ running a Blazor app, `IsRunningBlazor` must be set to `false` (or removed) and the following lines must be added to the preload script:
> ```js
> global.process = undefined;
> global.module = undefined;
> ```
## 🚀 Next Steps

View File

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

View File

@@ -63,7 +63,7 @@ namespace ElectronNET.API
private event Action<Cookie, CookieChangedCause, bool> _changed;
/// <summary>
/// Sends a request to get all cookies matching filter, and resolves a callack with the response.

View File

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

View File

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

View File

@@ -2,9 +2,11 @@
// ReSharper disable once CheckNamespace
namespace ElectronNET.API
{
using ElectronNET.API.Bridge;
internal static class BridgeConnector
{
public static SocketIoFacade Socket
public static ISocketConnection Socket
{
get
{

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,7 @@
namespace ElectronNET
{
using ElectronNET.API;
using ElectronNET.API.Bridge;
using ElectronNET.Runtime;
using ElectronNET.Runtime.Controllers;
using ElectronNET.Runtime.Data;
@@ -16,6 +17,7 @@
internal const int DefaultWebPort = 8001;
internal const string ElectronPortArgumentName = "electronPort";
internal const string ElectronPidArgumentName = "electronPID";
internal const string ElectronAuthTokenArgumentName = "electronAuthToken";
/// <summary>Initializes the <see cref="ElectronNetRuntime"/> class.</summary>
static ElectronNetRuntime()
@@ -26,6 +28,8 @@
public static string ElectronExtraArguments { get; set; }
public static string ElectronAuthToken { get; internal set; }
public static int? ElectronSocketPort { get; internal set; }
public static int? AspNetWebPort { get; internal set; }
@@ -49,7 +53,7 @@
internal static Func<Task> OnAppReadyCallback { get; set; }
internal static SocketIoFacade GetSocket()
internal static ISocketConnection GetSocket()
{
return RuntimeControllerCore?.Socket;
}

View File

@@ -1,6 +1,7 @@
namespace ElectronNET.Runtime.Controllers
{
using ElectronNET.API;
using ElectronNET.API.Bridge;
using ElectronNET.Runtime.Services;
using ElectronNET.Runtime.Services.ElectronProcess;
using ElectronNET.Runtime.Services.SocketBridge;
@@ -12,7 +13,7 @@
{
}
internal abstract SocketIoFacade Socket { get; }
internal abstract ISocketConnection Socket { get; }
internal abstract ElectronProcessBase ElectronProcess { get; }

View File

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

View File

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

View File

@@ -63,13 +63,15 @@
private static bool? CheckUnpackaged2()
{
var dir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
var dir = new DirectoryInfo(baseDir);
if (dir.Name == "bin" && dir.Parent?.Name == "resources")
{
return false;
}
if (dir.GetDirectories().Any(e => e.Name == ".electron"))
if (Directory.Exists(Path.Combine(baseDir, ".electron")))
{
return true;
}
@@ -84,7 +86,6 @@
return true;
}
return null;
}

View File

@@ -2,9 +2,11 @@
{
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using ElectronNET.Common;
using ElectronNET.Runtime.Data;
@@ -15,6 +17,7 @@
[Localizable(false)]
internal class ElectronProcessActive : ElectronProcessBase
{
private readonly Regex extractor = new Regex("^Electron Socket: listening on port (\\d+) at .* using ([a-f0-9]+)$");
private readonly bool isUnpackaged;
private readonly string electronBinaryName;
private readonly string extraArguments;
@@ -157,18 +160,36 @@
private async Task StartInternal(string startCmd, string args, string directoriy)
{
var tcs = new TaskCompletionSource();
void Read_SocketIO_Parameters(object sender, string line)
{
// Look for "Electron Socket: listening on port %s at ..."
var match = extractor.Match(line);
if (match?.Success ?? false)
{
var port = int.Parse(match.Groups[1].Value);
var token = match.Groups[2].Value;
this.process.LineReceived -= Read_SocketIO_Parameters;
ElectronNetRuntime.ElectronAuthToken = token;
ElectronNetRuntime.ElectronSocketPort = port;
tcs.SetResult();
}
}
try
{
await Task.Delay(10.ms()).ConfigureAwait(false);
Console.Error.WriteLine("[StartInternal]: startCmd: {0}", startCmd);
Console.Error.WriteLine("[StartInternal]: args: {0}", args);
this.process = new ProcessRunner("ElectronRunner");
this.process.ProcessExited += this.Process_Exited;
this.process.LineReceived += Read_SocketIO_Parameters;
this.process.Run(startCmd, args, directoriy);
await Task.Delay(500.ms()).ConfigureAwait(false);
await tcs.Task.ConfigureAwait(false);
Console.Error.WriteLine("[StartInternal]: after run:");

View File

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

View File

@@ -25,7 +25,6 @@
this.CollectProcessData();
this.SetElectronExecutable();
ElectronNetRuntime.StartupMethod = this.DetectAppTypeAndStartup();
Console.WriteLine((string)("Evaluated StartupMethod: " + ElectronNetRuntime.StartupMethod));
@@ -57,21 +56,11 @@
if (isLaunchedByDotNet)
{
if (isUnPackaged)
{
return StartupMethod.UnpackedDotnetFirst;
}
return StartupMethod.PackagedDotnetFirst;
return isUnPackaged ? StartupMethod.UnpackedDotnetFirst: StartupMethod.PackagedDotnetFirst;
}
else
{
if (isUnPackaged)
{
return StartupMethod.UnpackedElectronFirst;
}
return StartupMethod.PackagedElectronFirst;
return isUnPackaged ? StartupMethod.UnpackedElectronFirst: StartupMethod.PackagedElectronFirst;
}
}
@@ -86,10 +75,10 @@
if (portArg != null)
{
var parts = portArg.Split('=', StringSplitOptions.TrimEntries);
if (parts.Length > 1 && int.TryParse(parts[1], NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out var result))
{
ElectronNetRuntime.ElectronSocketPort = result;
Console.WriteLine("Use Electron Port: " + result);
}
}
@@ -99,18 +88,33 @@
if (pidArg != null)
{
var parts = pidArg.Split('=', StringSplitOptions.TrimEntries);
if (parts.Length > 1 && int.TryParse(parts[1], NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out var result))
{
ElectronNetRuntime.ElectronProcessId = result;
Console.WriteLine("Electron Process ID: " + result);
}
}
var authTokenArg = argsList.FirstOrDefault(e => e.Contains(ElectronNetRuntime.ElectronAuthTokenArgumentName, StringComparison.OrdinalIgnoreCase));
if (authTokenArg != null)
{
var parts = authTokenArg.Split('=', StringSplitOptions.TrimEntries);
if (parts.Length > 1 && !string.IsNullOrWhiteSpace(parts[1]))
{
var result = parts[1];
ElectronNetRuntime.ElectronAuthToken = result;
Console.WriteLine("Use Auth Token: " + result);
}
}
}
private void SetElectronExecutable()
{
string executable = ElectronNetRuntime.BuildInfo.ElectronExecutable;
var executable = ElectronNetRuntime.BuildInfo.ElectronExecutable;
if (string.IsNullOrEmpty(executable))
{
throw new Exception("AssemblyMetadataAttribute 'ElectronExecutable' could not be found!");

View File

@@ -1,6 +1,7 @@
namespace ElectronNET.API
{
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using ElectronNET.AspNet;
@@ -10,6 +11,7 @@
using ElectronNET.Runtime.Helpers;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
/// <summary>
/// Provides extension methods for <see cref="IWebHostBuilder"/> to enable Electron.NET
@@ -66,23 +68,26 @@
// work as expected, see issue #952
Environment.SetEnvironmentVariable("ELECTRON_RUN_AS_NODE", null);
var webPort = PortHelper.GetFreePort(ElectronNetRuntime.AspNetWebPort ?? ElectronNetRuntime.DefaultWebPort);
ElectronNetRuntime.AspNetWebPort = webPort;
var webPort = ElectronNetRuntime.AspNetWebPort ?? 0;
// check for the content folder if its exists in base director otherwise no need to include
// It was used before because we are publishing the project which copies everything to bin folder and contentroot wwwroot was folder there.
// now we have implemented the live reload if app is run using /watch then we need to use the default project path.
// For port 0 (dynamic port assignment), Kestrel requires binding to specific IP (127.0.0.1) not localhost
var host = webPort == 0? "127.0.0.1" : "localhost";
if (Directory.Exists($"{AppDomain.CurrentDomain.BaseDirectory}\\wwwroot"))
{
builder = builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory)
.UseUrls("http://localhost:" + webPort);
.UseUrls($"http://{host}:{webPort}");
}
else
{
builder = builder.UseUrls("http://localhost:" + webPort);
builder = builder.UseUrls($"http://{host}:{webPort}");
}
builder = builder.ConfigureServices(services =>
builder = builder.ConfigureServices((context, services) =>
{
services.AddTransient<IStartupFilter, ServerReadyStartupFilter>();
services.AddSingleton<AspNetLifetimeAdapter>();

View File

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

View File

@@ -1,8 +1,14 @@
namespace ElectronNET.AspNet.Runtime
{
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.Extensions.DependencyInjection;
using ElectronNET.API;
using ElectronNET.API.Bridge;
using ElectronNET.AspNet.Services;
using ElectronNET.Common;
using ElectronNET.Runtime.Controllers;
using ElectronNET.Runtime.Data;
@@ -10,12 +16,16 @@
internal abstract class RuntimeControllerAspNetBase : RuntimeControllerBase
{
private readonly IServer server;
private readonly AspNetLifetimeAdapter aspNetLifetimeAdapter;
private readonly IElectronAuthenticationService authenticationService;
private SocketBridgeService socketBridge;
protected RuntimeControllerAspNetBase(AspNetLifetimeAdapter aspNetLifetimeAdapter)
protected RuntimeControllerAspNetBase(IServer server, AspNetLifetimeAdapter aspNetLifetimeAdapter, IElectronAuthenticationService authenticationService = null)
{
this.server = server;
this.aspNetLifetimeAdapter = aspNetLifetimeAdapter;
this.authenticationService = authenticationService;
this.aspNetLifetimeAdapter.Ready += this.AspNetLifetimeAdapter_Ready;
this.aspNetLifetimeAdapter.Stopping += this.AspNetLifetimeAdapter_Stopping;
this.aspNetLifetimeAdapter.Stopped += this.AspNetLifetimeAdapter_Stopped;
@@ -25,7 +35,7 @@
internal override SocketBridgeService SocketBridge => this.socketBridge;
internal override SocketIoFacade Socket
internal override ISocketConnection Socket
{
get
{
@@ -38,9 +48,9 @@
}
}
protected void CreateSocketBridge(int port)
protected void CreateSocketBridge(int port, string authorization)
{
this.socketBridge = new SocketBridgeService(port);
this.socketBridge = new SocketBridgeService(port, authorization);
this.socketBridge.Ready += this.SocketBridge_Ready;
this.socketBridge.Stopped += this.SocketBridge_Stopped;
this.socketBridge.Start();
@@ -52,6 +62,15 @@
this.ElectronProcess.IsReady() &&
this.aspNetLifetimeAdapter.IsReady())
{
var token = ElectronNetRuntime.ElectronAuthToken;
var serverAddressesFeature = this.server.Features.Get<IServerAddressesFeature>();
var address = serverAddressesFeature.Addresses.First();
var uri = new Uri(address);
// Only if somebody registered an IElectronAuthenticationService service - otherwise we do not care
this.authenticationService?.SetExpectedToken(token);
ElectronNetRuntime.AspNetWebPort = uri.Port;
this.TransitionState(LifetimeState.Ready);
Task.Run(this.RunReadyCallback);
}

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"autoUpdater.js","sourceRoot":"","sources":["autoUpdater.ts"],"names":[],"mappings":";AACA,uDAA+C;AAC/C,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,CAAC,EAAE,EAAE,EAAE;QAC3C,8BAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE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MAAM,OAAO,GAAG,MAAM,8BAAW,CAAC,UAAU,EAAE,CAAC;QAC/C,cAAc,CAAC,IAAI,CACjB,kCAAkC,GAAG,IAAI,EACzC,OAAO,IAAI,EAAE,CACd,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

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

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"browserView.js","sourceRoot":"","sources":["browserView.ts"],"names":[],"mappings":";;;AACA,uCAAuC;AACvC,MAAM,YAAY,GAAkB,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,CAAkB,CAAC;AAC7G,IAAI,WAAwB,EAAE,cAAc,CAAC;AAC7C,MAAM,qBAAqB,GAAgC,CAAC,MAAM,CAAC,uBAAuB,CAAC,GAAG,MAAM,CAAC,uBAAuB,CAAC,IAAI,EAAE,CAAgC,CAAC;AAEpK,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,EAAE;IACtC,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,OAAO,EAAE,EAAE;QACvC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,EAAE,CAAC;YACjE,OAAO,GAAG,EA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,kBAAkB,CAAC,aAAa,CAAC,CAAC;AAC3C,CAAC,CAAC;AAWuB,8DAAyB;AATlD,SAAS,kBAAkB,CAAC,EAAU;IACpC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,MAAM,eAAe,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YACjC,OAAO,eAAe,CAAC;QACzB,CAAC;IACH,CAAC;AACH,CAAC"}

View File

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

View File

@@ -1,12 +1,46 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
const path = __importStar(require("path"));
const electron_1 = require("electron");
const browserView_1 = require("./browserView");
const path = require("path");
const windows = (global["browserWindows"] =
global["browserWindows"] || []);
let readyToShowWindowsIds = [];
let window, lastOptions, electronSocket;
let mainWindowURL;
let window;
let lastOptions;
let electronSocket;
const proxyToCredentialsMap = (global["proxyToCredentialsMap"] = global["proxyToCredentialsMap"] || []);
module.exports = (socket, app) => {
electronSocket = socket;
@@ -243,7 +277,15 @@ module.exports = (socket, app) => {
}
});
if (loadUrl) {
window.loadURL(loadUrl);
// Append authentication token to initial URL if available
const token = global["authToken"];
if (token) {
const separator = loadUrl.includes("?") ? "&" : "?";
window.loadURL(`${loadUrl}${separator}token=${token}`);
}
else {
window.loadURL(loadUrl);
}
}
if (app.commandLine.hasSwitch("clear-cache") &&
app.commandLine.getSwitchValue("clear-cache")) {

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,18 @@
import { Socket } from "net";
import { BrowserWindow, Menu, nativeImage } from "electron";
import * as path from "path";
import type { Socket } from "net";
import { BrowserWindow, Menu } from "electron";
import { browserViewMediateService } from "./browserView";
const path = require("path");
const windows: Electron.BrowserWindow[] = (global["browserWindows"] =
global["browserWindows"] || []) as Electron.BrowserWindow[];
let readyToShowWindowsIds: number[] = [];
let window, lastOptions, electronSocket;
let mainWindowURL;
let window;
let lastOptions;
let electronSocket;
const proxyToCredentialsMap: { [proxy: string]: string } = (global[
"proxyToCredentialsMap"
] = global["proxyToCredentialsMap"] || []) as { [proxy: string]: string };
@@ -32,7 +38,7 @@ export = (socket: Socket, app: Electron.App) => {
socket.on("register-browserWindow-ready-to-show", (id) => {
if (readyToShowWindowsIds.includes(id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(
(value) => value !== id
(value) => value !== id,
);
electronSocket.emit("browserWindow-ready-to-show" + id);
}
@@ -141,7 +147,11 @@ export = (socket: Socket, app: Electron.App) => {
socket.on("register-browserWindow-bounds-changed", (id) => {
const window = getWindowById(id);
const cb = () => electronSocket.emit("browserWindow-bounds-changed" + id, window.getBounds());
const cb = () =>
electronSocket.emit(
"browserWindow-bounds-changed" + id,
window.getBounds(),
);
window.on("resize", cb);
window.on("move", cb);
});
@@ -231,7 +241,7 @@ export = (socket: Socket, app: Electron.App) => {
__dirname,
"..",
"scripts",
"blazor-preload.js"
"blazor-preload.js",
);
}
@@ -264,7 +274,7 @@ export = (socket: Socket, app: Electron.App) => {
window.on("ready-to-show", () => {
if (readyToShowWindowsIds.includes(window.id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(
(value) => value !== window.id
(value) => value !== window.id,
);
} else {
readyToShowWindowsIds.push(window.id);
@@ -299,7 +309,15 @@ export = (socket: Socket, app: Electron.App) => {
});
if (loadUrl) {
window.loadURL(loadUrl);
// Append authentication token to initial URL if available
const token = global["authToken"];
if (token) {
const separator = loadUrl.includes("?") ? "&" : "?";
window.loadURL(`${loadUrl}${separator}token=${token}`);
} else {
window.loadURL(loadUrl);
}
}
if (
@@ -531,7 +549,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit(
"browserWindow-isFullScreenable-completed",
fullscreenable
fullscreenable,
);
});
@@ -616,7 +634,7 @@ export = (socket: Socket, app: Electron.App) => {
.toString(16);
electronSocket.emit(
"browserWindow-getNativeWindowHandle-completed",
nativeWindowHandle
nativeWindowHandle,
);
});
@@ -629,7 +647,7 @@ export = (socket: Socket, app: Electron.App) => {
} catch (e) {
console.warn(
"setRepresentedFilename failed (likely unsupported platform):",
e
e,
);
}
});
@@ -644,12 +662,12 @@ export = (socket: Socket, app: Electron.App) => {
} catch (e) {
console.warn(
"getRepresentedFilename failed (likely unsupported platform):",
e
e,
);
}
electronSocket.emit(
"browserWindow-getRepresentedFilename-completed",
pathname
pathname,
);
});
@@ -741,7 +759,7 @@ export = (socket: Socket, app: Electron.App) => {
imagePath = path.join(
__dirname.replace("api", ""),
"bin",
originalIconPath
originalIconPath,
);
}
const { nativeImage } = require("electron");
@@ -758,7 +776,7 @@ export = (socket: Socket, app: Electron.App) => {
const success = getWindowById(id).setThumbarButtons(thumbarButtons);
electronSocket.emit("browserWindowSetThumbarButtons-completed", success);
}
},
);
socket.on("browserWindowSetThumbnailClip", (id, rectangle) => {
@@ -786,7 +804,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit(
"browserWindow-isMenuBarAutoHide-completed",
isMenuBarAutoHide
isMenuBarAutoHide,
);
});
@@ -799,7 +817,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit(
"browserWindow-isMenuBarVisible-completed",
isMenuBarVisible
isMenuBarVisible,
);
});
@@ -813,7 +831,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit(
"browserWindow-isVisibleOnAllWorkspaces-completed",
isVisibleOnAllWorkspaces
isVisibleOnAllWorkspaces,
);
});
@@ -845,7 +863,7 @@ export = (socket: Socket, app: Electron.App) => {
electronSocket.emit(
"browserWindow-getParentWindow-completed",
browserWindow.id
browserWindow.id,
);
});

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"clipboard.js","sourceRoot":"","sources":["clipboard.ts"],"names":[],"mappings":";AACA,uCAAkD;AAClD,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,oBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtC,cAAc,CAAC,IAAI,CAAC,8BAA8B,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,qBAAq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,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,KAAK,GAAG,sBAAW,CAAC,WAAW,EAAE,CAAC;QAExC,kCAAkC;QAClC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,MAAM,WAAW,GAAG,GAAG,CAAC;YACxB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACxB,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC5C,KAAK,CAAC,iBAAiB,CAAC,EAAE,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,oBAAS,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

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

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"commandLine.js","sourceRoot":"","sources":["commandLine.ts"],"names":[],"mappings":";AACA,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,GAAiB,EAAE,EAAE;IAC3C,cAAc,G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C,KAAa,EAAE,EAAE;QAC1D,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,KAAa,EAAE,EAAE;QACrD,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnD,cAAc,CAAC,IAAI,CAAC,kCAAkC,EAAE,SAAS,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,CAAC,UAAkB,EAAE,EAAE;QAC/D,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACzD,cAAc,CAAC,IAAI,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

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

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["dialog.ts"],"names":[],"mappings":";AACA,uCAAiD;AACjD,IAAI,cAAsB,CAAC;AAE3B,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAC/D,IAAI,IAAI,IAAI,aAAa,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAEtD,MAAM,qBAAqB,GAAG,MAAM,iBAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC3E,cAAc,CAAC,IAAI,CAAC,wBAAwB,GAAG,IAAI,EAAE,CAAC,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;QAClI,CAAC;aAAM,CAAC;YACJ,MAAM,EAAE,GAAG,IAAI,IAAI,OAAO,CAAC;YAC3B,MAAM,qBAAqB,GAAG,MAAM,iBAAM,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YAEzE,cAAc,CAAC,IAAI,CAAC,wBAAwB,GAAG,EAAE,EAAE,CAAC,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,CA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CAAC;QACtD,MAAM,qBAAqB,GAAG,MAAM,iBAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE3E,cAAc,CAAC,IAAI,CACjB,wBAAwB,GAAG,IAAI,EAC/B,qBAAqB,CAAC,SAAS,IAAI,EAAE,CACtC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACjE,MAAM,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACtD,MAAM,qBAAqB,GAAG,MAAM,iBAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE3E,cAAc,CAAC,IAAI,CACjB,wBAAwB,GAAG,IAAI,EAC/B,qBAAqB,CAAC,QAAQ,IAAI,EAAE,CACrC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC3C,iBAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CACP,4BAA4B,EAC5B,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACtD,MAAM,iBAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAEzD,cAAc,CAAC,IAAI,CAAC,oCAAoC,GAAG,IAAI,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}

View File

@@ -1,45 +1,64 @@
import { Socket } from 'net';
import { BrowserWindow, dialog } from 'electron';
import type { Socket } from "net";
import { BrowserWindow, dialog } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
socket.on('showMessageBox', async (browserWindow, options, guid) => {
if ('id' in browserWindow) {
const window = BrowserWindow.fromId(browserWindow.id);
electronSocket = socket;
socket.on("showMessageBox", async (browserWindow, options, guid) => {
if ("id" in browserWindow) {
const window = BrowserWindow.fromId(browserWindow.id);
const messageBoxReturnValue = await dialog.showMessageBox(window, options);
electronSocket.emit('showMessageBoxComplete' + guid, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
} else {
const id = guid || options;
const messageBoxReturnValue = await dialog.showMessageBox(browserWindow);
const messageBoxReturnValue = await dialog.showMessageBox(
window,
options,
);
electronSocket.emit("showMessageBoxComplete" + guid, [
messageBoxReturnValue.response,
messageBoxReturnValue.checkboxChecked,
]);
} else {
const id = guid || options;
const messageBoxReturnValue = await dialog.showMessageBox(browserWindow);
electronSocket.emit('showMessageBoxComplete' + id, [messageBoxReturnValue.response, messageBoxReturnValue.checkboxChecked]);
}
});
electronSocket.emit("showMessageBoxComplete" + id, [
messageBoxReturnValue.response,
messageBoxReturnValue.checkboxChecked,
]);
}
});
socket.on('showOpenDialog', async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
const openDialogReturnValue = await dialog.showOpenDialog(window, options);
socket.on("showOpenDialog", async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
const openDialogReturnValue = await dialog.showOpenDialog(window, options);
electronSocket.emit('showOpenDialogComplete' + guid, openDialogReturnValue.filePaths || []);
});
electronSocket.emit(
"showOpenDialogComplete" + guid,
openDialogReturnValue.filePaths || [],
);
});
socket.on('showSaveDialog', async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
const saveDialogReturnValue = await dialog.showSaveDialog(window, options);
socket.on("showSaveDialog", async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
const saveDialogReturnValue = await dialog.showSaveDialog(window, options);
electronSocket.emit('showSaveDialogComplete' + guid, saveDialogReturnValue.filePath || '');
});
electronSocket.emit(
"showSaveDialogComplete" + guid,
saveDialogReturnValue.filePath || "",
);
});
socket.on('showErrorBox', (title, content) => {
dialog.showErrorBox(title, content);
});
socket.on("showErrorBox", (title, content) => {
dialog.showErrorBox(title, content);
});
socket.on('showCertificateTrustDialog', async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
await dialog.showCertificateTrustDialog(window, options);
socket.on(
"showCertificateTrustDialog",
async (browserWindow, options, guid) => {
const window = BrowserWindow.fromId(browserWindow.id);
await dialog.showCertificateTrustDialog(window, options);
electronSocket.emit('showCertificateTrustDialogComplete' + guid);
});
electronSocket.emit("showCertificateTrustDialogComplete" + guid);
},
);
};

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"dock.js","sourceRoot":"","sources":["dock.ts"],"names":[],"mappings":";AACA,uCAAqC;AACrC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE;QAC9B,MAAM,EAAE,GAAG,cAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,cAAc,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE,EAAE;QAClC,cAAG,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,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CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC1D,CAAC;YAED,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;gBAC5B,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE;oBAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACpB,CAAC,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}

View File

@@ -1,78 +1,81 @@
import { Socket } from 'net';
import { app, Menu } from 'electron';
let electronSocket;
import type { Socket } from "net";
import { app, Menu } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
electronSocket = socket;
socket.on('dock-bounce', (type) => {
const id = app.dock.bounce(type);
electronSocket.emit('dock-bounce-completed', id);
});
socket.on("dock-bounce", (type) => {
const id = app.dock.bounce(type);
electronSocket.emit("dock-bounce-completed", id);
});
socket.on('dock-cancelBounce', (id) => {
app.dock.cancelBounce(id);
});
socket.on("dock-cancelBounce", (id) => {
app.dock.cancelBounce(id);
});
socket.on('dock-downloadFinished', (filePath) => {
app.dock.downloadFinished(filePath);
});
socket.on("dock-downloadFinished", (filePath) => {
app.dock.downloadFinished(filePath);
});
socket.on('dock-setBadge', (text) => {
app.dock.setBadge(text);
});
socket.on("dock-setBadge", (text) => {
app.dock.setBadge(text);
});
socket.on('dock-getBadge', () => {
const text = app.dock.getBadge();
electronSocket.emit('dock-getBadge-completed', text);
});
socket.on("dock-getBadge", () => {
const text = app.dock.getBadge();
electronSocket.emit("dock-getBadge-completed", text);
});
socket.on('dock-hide', () => {
app.dock.hide();
});
socket.on("dock-hide", () => {
app.dock.hide();
});
socket.on('dock-show', () => {
app.dock.show();
});
socket.on("dock-show", () => {
app.dock.show();
});
socket.on('dock-isVisible', () => {
const isVisible = app.dock.isVisible();
electronSocket.emit('dock-isVisible-completed', isVisible);
});
socket.on("dock-isVisible", () => {
const isVisible = app.dock.isVisible();
electronSocket.emit("dock-isVisible-completed", isVisible);
});
socket.on('dock-setMenu', (menuItems) => {
let menu = null;
socket.on("dock-setMenu", (menuItems) => {
let menu = null;
if (menuItems) {
menu = Menu.buildFromTemplate(menuItems);
if (menuItems) {
menu = Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('dockMenuItemClicked', id);
});
}
app.dock.setMenu(menu);
});
// TODO: Menu (macOS) still to be implemented
socket.on('dock-getMenu', () => {
const menu = app.dock.getMenu();
electronSocket.emit('dock-getMenu-completed', menu);
});
socket.on('dock-setIcon', (image) => {
app.dock.setIcon(image);
});
function addMenuItemClickConnector(menuItems, callback) {
menuItems.forEach((item) => {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
if ('id' in item && item.id) {
item.click = () => { callback(item.id); };
}
});
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit("dockMenuItemClicked", id);
});
}
app.dock.setMenu(menu);
});
// TODO: Menu (macOS) still to be implemented
socket.on("dock-getMenu", () => {
const menu = app.dock.getMenu();
electronSocket.emit("dock-getMenu-completed", menu);
});
socket.on("dock-setIcon", (image) => {
app.dock.setIcon(image);
});
function addMenuItemClickConnector(menuItems, callback) {
menuItems.forEach((item) => {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
if ("id" in item && item.id) {
item.click = () => {
callback(item.id);
};
}
});
}
};

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"globalShortcut.js","sourceRoot":"","sources":["globalShortcut.ts"],"names":[],"mappings":";AAAA,uCAA0C;AAE1C,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,WAAW,EAAE,EAAE;QACjD,yBAAc,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;YACtC,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,6BAA6B,EAAE,CAAC,WAAW,EAAE,EAAE;QACrD,MAAM,YAAY,GAAG,yBAAc,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QAE9D,cAAc,CAAC,IAAI,CAAC,sCAAsC,EAAE,YAAY,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2BAA2B,EAAE,CAAC,WAAW,EAAE,EAAE;QACnD,yBAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QAC3C,IAAI,CAAC;YACD,yBAAc,CAAC,aAAa,EAAE,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
{"version":3,"file":"globalShortcut.js","sourceRoot":"","sources":["globalShortcut.ts"],"names":[],"mappings":";AACA,uCAA0C;AAE1C,IAAI,cAAsB,CAAC;AAE3B,iBAAS,CAAC,MAAc,EAAE,EAAE;IAC1B,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,WAAW,EAAE,EAAE;QACnD,yBAAc,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;YACxC,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,6BAA6B,EAAE,CAAC,WAAW,EAAE,EAAE;QACvD,MAAM,YAAY,GAAG,yBAAc,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QAE9D,cAAc,CAAC,IAAI,CAAC,sCAAsC,EAAE,YAAY,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2BAA2B,EAAE,CAAC,WAAW,EAAE,EAAE;QACrD,yBAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QAC7C,IAAI,CAAC;YACH,yBAAc,CAAC,aAAa,EAAE,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC,CAAA,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.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AC;QAE/C,yBAAyB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE;YAC3C,cAAc,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,eAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,SAAS,yBAAyB,CAAC,SAAS,EAAE,QAAQ;QACpD,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClD,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC1D,CAAC;YAED,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;gBAC5B,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE;oBAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACpB,CAAC,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}

View File

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

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"nativeTheme.js","sourceRoot":"","sources":["nativeTheme.ts"],"names":[],"mappings":";AACA,uCAAuC;AACvC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IAExB,MAAM,CAAC,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QAC9C,MAAM,mBAAmB,GAAG,sBAAW,CAAC,mBAAmB,CAAC;QAE5D,cAAc,CAAC,IAAI,CAAC,2CAA2C,EAAE,mBAAmB,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACtD,MAAM,2BAA2B,GAAG,sBAAW,CAAC,2BAA2B,CAAC;QAE5E,cAAc,CAAC,IAAI,CAAC,mDAAmD,EAAE,2BAA2B,CAAC,CAAC;IAC1G,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QACvD,MAAM,4BAA4B,GAAG,sBAAW,CAAC,4BAA4B,CAAC;QAE9E,cAAc,CAAC,IAAI,CAAC,oDAAoD,EAAE,4BAA4B,CAAC,CAAC;IAC5G,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACzC,MAAM,WAAW,GAAG,sBA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EACpD,4BAA4B,CAC7B,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC3C,MAAM,WAAW,GAAG,sBAAW,CAAC,WAAW,CAAC;QAE5C,cAAc,CAAC,IAAI,CAAC,sCAAsC,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,WAAW,EAAE,EAAE;QACnD,sBAAW,CAAC,WAAW,GAAG,WAAW,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,CAAC,EAAE,EAAE,EAAE;QAC/C,sBAAW,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YAC7B,cAAc,CAAC,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

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

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"notification.js","sourceRoot":"","sources":["notification.ts"],"names":[],"mappings":";AACA,uCAAwC;AACxC,MAAM,aAAa,GAA4B,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,CAA4B,CAAC;AACpI,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE;QACxC,MAAM,YAAY,GAAG,IAAI,uBAAY,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACjB,SAAS,GAAG,IAAI,CAAC;YACjB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,G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electron.Notification[] = (global['notifications'] = global['notifications'] || []) as Electron.Notification[];
let electronSocket;
import type { Socket } from "net";
import { Notification } from "electron";
const notifications: Electron.Notification[] = (global["notifications"] =
global["notifications"] || []) as Electron.Notification[];
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
socket.on('createNotification', (options) => {
const notification = new Notification(options);
let haveEvent = false;
electronSocket = socket;
socket.on("createNotification", (options) => {
const notification = new Notification(options);
let haveEvent = false;
if (options.showID) {
haveEvent = true;
notification.on('show', () => {
electronSocket.emit('NotificationEventShow', options.showID);
});
}
if (options.showID) {
haveEvent = true;
notification.on("show", () => {
electronSocket.emit("NotificationEventShow", options.showID);
});
}
if (options.clickID) {
haveEvent = true;
notification.on('click', () => {
electronSocket.emit('NotificationEventClick', options.clickID);
});
}
if (options.clickID) {
haveEvent = true;
notification.on("click", () => {
electronSocket.emit("NotificationEventClick", options.clickID);
});
}
if (options.closeID) {
haveEvent = true;
notification.on('close', () => {
electronSocket.emit('NotificationEventClose', options.closeID);
});
}
if (options.closeID) {
haveEvent = true;
notification.on("close", () => {
electronSocket.emit("NotificationEventClose", options.closeID);
});
}
if (options.replyID) {
haveEvent = true;
notification.on('reply', (event, value) => {
electronSocket.emit('NotificationEventReply', [options.replyID, value]);
});
}
if (options.replyID) {
haveEvent = true;
notification.on("reply", (event, value) => {
electronSocket.emit("NotificationEventReply", [options.replyID, value]);
});
}
if (options.actionID) {
haveEvent = true;
notification.on('action', (event, value) => {
electronSocket.emit('NotificationEventAction', [options.actionID, value]);
});
}
if (options.actionID) {
haveEvent = true;
notification.on("action", (event, value) => {
electronSocket.emit("NotificationEventAction", [
options.actionID,
value,
]);
});
}
if (haveEvent) {
notifications.push(notification);
}
if (haveEvent) {
notifications.push(notification);
}
notification.show();
});
notification.show();
});
socket.on('notificationIsSupported', () => {
const isSupported = Notification.isSupported();
electronSocket.emit('notificationIsSupportedCompleted', isSupported);
});
socket.on("notificationIsSupported", () => {
const isSupported = Notification.isSupported();
electronSocket.emit("notificationIsSupportedCompleted", isSupported);
});
};

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"powerMonitor.js","sourceRoot":"","sources":["powerMonitor.ts"],"names":[],"mappings":";AACA,uCAAwC;AACxC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAChD,uBAAY,CAAC,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE;YAChC,cAAc,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAClD,uBAAY,CAAC,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAC5C,uBAAY,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YAC5B,cAAc,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QAC3C,uBAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YAC3B,cAAc,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACvC,uBAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAC1B,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC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CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QAC7C,uBAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YAC7B,cAAc,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACzC,uBAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAC5B,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAC9C,uBAAY,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;YACjC,cAAc,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QAC/C,uBAAY,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE;YAC/B,cAAc,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

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

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"process.js","sourceRoot":"","sources":["process.ts"],"names":[],"mappings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CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QAC3B,cAAc,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC;QAC/B,cAAc,CAAC,IAAI,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

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

View File

@@ -3,44 +3,47 @@ const electron_1 = require("electron");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on('register-screen-display-added', (id) => {
electron_1.screen.on('display-added', (event, display) => {
electronSocket.emit('screen-display-added' + id, display);
socket.on("register-screen-display-added", (id) => {
electron_1.screen.on("display-added", (event, display) => {
electronSocket.emit("screen-display-added" + id, display);
});
});
socket.on('register-screen-display-removed', (id) => {
electron_1.screen.on('display-removed', (event, display) => {
electronSocket.emit('screen-display-removed' + id, display);
socket.on("register-screen-display-removed", (id) => {
electron_1.screen.on("display-removed", (event, display) => {
electronSocket.emit("screen-display-removed" + id, display);
});
});
socket.on('register-screen-display-metrics-changed', (id) => {
electron_1.screen.on('display-metrics-changed', (event, display, changedMetrics) => {
electronSocket.emit('screen-display-metrics-changed' + id, [display, changedMetrics]);
socket.on("register-screen-display-metrics-changed", (id) => {
electron_1.screen.on("display-metrics-changed", (event, display, changedMetrics) => {
electronSocket.emit("screen-display-metrics-changed" + id, [
display,
changedMetrics,
]);
});
});
socket.on('screen-getCursorScreenPoint', () => {
socket.on("screen-getCursorScreenPoint", () => {
const point = electron_1.screen.getCursorScreenPoint();
electronSocket.emit('screen-getCursorScreenPoint-completed', point);
electronSocket.emit("screen-getCursorScreenPoint-completed", point);
});
socket.on('screen-getMenuBarWorkArea', () => {
socket.on("screen-getMenuBarWorkArea", () => {
const height = electron_1.screen.getPrimaryDisplay().workArea;
electronSocket.emit('screen-getMenuBarWorkArea-completed', height);
electronSocket.emit("screen-getMenuBarWorkArea-completed", height);
});
socket.on('screen-getPrimaryDisplay', () => {
socket.on("screen-getPrimaryDisplay", () => {
const display = electron_1.screen.getPrimaryDisplay();
electronSocket.emit('screen-getPrimaryDisplay-completed', display);
electronSocket.emit("screen-getPrimaryDisplay-completed", display);
});
socket.on('screen-getAllDisplays', () => {
socket.on("screen-getAllDisplays", () => {
const display = electron_1.screen.getAllDisplays();
electronSocket.emit('screen-getAllDisplays-completed', display);
electronSocket.emit("screen-getAllDisplays-completed", display);
});
socket.on('screen-getDisplayNearestPoint', (point) => {
socket.on("screen-getDisplayNearestPoint", (point) => {
const display = electron_1.screen.getDisplayNearestPoint(point);
electronSocket.emit('screen-getDisplayNearestPoint-completed', display);
electronSocket.emit("screen-getDisplayNearestPoint-completed", display);
});
socket.on('screen-getDisplayMatching', (rectangle) => {
socket.on("screen-getDisplayMatching", (rectangle) => {
const display = electron_1.screen.getDisplayMatching(rectangle);
electronSocket.emit('screen-getDisplayMatching-completed', display);
electronSocket.emit("screen-getDisplayMatching-completed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,CAAC;QACnD,cAAc,CAAC,IAAI,CAAC,qCAAqC,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACzC,MAAM,OAAO,GAAG,iBAAM,CAAC,iBAAiB,EAAE,CAAC;QAC3C,cAAc,CAAC,IAAI,CAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QACtC,MAAM,OAAO,GAAG,iBAAM,CAAC,cAAc,EAAE,CAAC;QACxC,cAAc,CAAC,IAAI,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,+BAA+B,EAAE,CAAC,KAAK,EAAE,EAAE;QACnD,MAAM,OAAO,GAAG,iBAAM,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACrD,cAAc,CAAC,IAAI,CAAC,yCAAyC,EAAE,OAAO,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,2BAA2B,EAAE,CAAC,SAAS,EAAE,EAAE;QACnD,MAAM,OAAO,GAAG,iBAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACrD,cAAc,CAAC,IAAI,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

@@ -1,55 +1,59 @@
import { Socket } from 'net';
import { screen } from 'electron';
let electronSocket;
import type { Socket } from "net";
import { screen } from "electron";
let electronSocket: Socket;
export = (socket: Socket) => {
electronSocket = socket;
electronSocket = socket;
socket.on('register-screen-display-added', (id) => {
screen.on('display-added', (event, display) => {
electronSocket.emit('screen-display-added' + id, display);
});
socket.on("register-screen-display-added", (id) => {
screen.on("display-added", (event, display) => {
electronSocket.emit("screen-display-added" + id, display);
});
});
socket.on('register-screen-display-removed', (id) => {
screen.on('display-removed', (event, display) => {
electronSocket.emit('screen-display-removed' + id, display);
});
socket.on("register-screen-display-removed", (id) => {
screen.on("display-removed", (event, display) => {
electronSocket.emit("screen-display-removed" + id, display);
});
});
socket.on('register-screen-display-metrics-changed', (id) => {
screen.on('display-metrics-changed', (event, display, changedMetrics) => {
electronSocket.emit('screen-display-metrics-changed' + id, [display, changedMetrics]);
});
socket.on("register-screen-display-metrics-changed", (id) => {
screen.on("display-metrics-changed", (event, display, changedMetrics) => {
electronSocket.emit("screen-display-metrics-changed" + id, [
display,
changedMetrics,
]);
});
});
socket.on('screen-getCursorScreenPoint', () => {
const point = screen.getCursorScreenPoint();
electronSocket.emit('screen-getCursorScreenPoint-completed', point);
});
socket.on("screen-getCursorScreenPoint", () => {
const point = screen.getCursorScreenPoint();
electronSocket.emit("screen-getCursorScreenPoint-completed", point);
});
socket.on('screen-getMenuBarWorkArea', () => {
const height = screen.getPrimaryDisplay().workArea;
electronSocket.emit('screen-getMenuBarWorkArea-completed', height);
});
socket.on("screen-getMenuBarWorkArea", () => {
const height = screen.getPrimaryDisplay().workArea;
electronSocket.emit("screen-getMenuBarWorkArea-completed", height);
});
socket.on('screen-getPrimaryDisplay', () => {
const display = screen.getPrimaryDisplay();
electronSocket.emit('screen-getPrimaryDisplay-completed', display);
});
socket.on("screen-getPrimaryDisplay", () => {
const display = screen.getPrimaryDisplay();
electronSocket.emit("screen-getPrimaryDisplay-completed", display);
});
socket.on('screen-getAllDisplays', () => {
const display = screen.getAllDisplays();
electronSocket.emit('screen-getAllDisplays-completed', display);
});
socket.on("screen-getAllDisplays", () => {
const display = screen.getAllDisplays();
electronSocket.emit("screen-getAllDisplays-completed", display);
});
socket.on('screen-getDisplayNearestPoint', (point) => {
const display = screen.getDisplayNearestPoint(point);
electronSocket.emit('screen-getDisplayNearestPoint-completed', display);
});
socket.on("screen-getDisplayNearestPoint", (point) => {
const display = screen.getDisplayNearestPoint(point);
electronSocket.emit("screen-getDisplayNearestPoint-completed", display);
});
socket.on('screen-getDisplayMatching', (rectangle) => {
const display = screen.getDisplayMatching(rectangle);
electronSocket.emit('screen-getDisplayMatching-completed', display);
});
socket.on("screen-getDisplayMatching", (rectangle) => {
const display = screen.getDisplayMatching(rectangle);
electronSocket.emit("screen-getDisplayMatching-completed", display);
});
};

View File

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

View File

@@ -1 +1 @@
{"version":3,"file":"shell.js","sourceRoot":"","sources":["shell.ts"],"names":[],"mappings":";AACA,uCAAiC;AACjC,IAAI,cAAc,CAAC;AAEnB,iBAAS,CAAC,MAAc,EAAE,EAAE;IACxB,cAAc,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC,QAAQ,EAAE,EAAE;QAC7C,gBAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAEjC,cAAc,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,YAAY,GAAG,MAAM,gBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEhD,cAAc,CAAC,IAAI,CAAC,yBAAyB,EAAE,YAAY,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;QACnD,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,IAAI,OAAO,EAAE,CAAC;YACV,MAAM,gBAAK,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;gBAC7C,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC;YACvB,CAAC,CAA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,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,iBAAiB,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE;QAC5D,IAAI,OAAO,GAAG,KAAK,CAAC;QAEpB,IAAI,CAAC;YACH,MAAM,gBAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAChC,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC;QAED,cAAc,CAAC,IAAI,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;QAC3B,gBAAK,CAAC,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;QACxE,MAAM,OAAO,GAAG,gBAAK,CAAC,iBAAiB,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAE1E,cAAc,CAAC,IAAI,CAAC,kCAAkC,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC,YAAY,EAAE,EAAE;QACnD,MAAM,eAAe,GAAG,gBAAK,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QAE7D,cAAc,CAAC,IAAI,CAAC,iCAAiC,EAAE,eAAe,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -1,7 +1,40 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
const fs = __importStar(require("fs"));
const electron_1 = require("electron");
const browserView_1 = require("./browserView");
const fs = require("fs");
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
@@ -315,28 +348,28 @@ module.exports = (socket) => {
const extension = await browserWindow.webContents.session.loadExtension(path, { allowFileAccess: allowFileAccess });
electronSocket.emit("webContents-session-loadExtension-completed", extension);
});
socket.on('webContents-getZoomFactor', (id) => {
socket.on("webContents-getZoomFactor", (id) => {
const browserWindow = getWindowById(id);
const text = browserWindow.webContents.getZoomFactor();
electronSocket.emit('webContents-getZoomFactor-completed', text);
electronSocket.emit("webContents-getZoomFactor-completed", text);
});
socket.on('webContents-setZoomFactor', (id, factor) => {
socket.on("webContents-setZoomFactor", (id, factor) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.setZoomFactor(factor);
});
socket.on('webContents-getZoomLevel', (id) => {
socket.on("webContents-getZoomLevel", (id) => {
const browserWindow = getWindowById(id);
const content = browserWindow.webContents.getZoomLevel();
electronSocket.emit('webContents-getZoomLevel-completed', content);
electronSocket.emit("webContents-getZoomLevel-completed", content);
});
socket.on('webContents-setZoomLevel', (id, level) => {
socket.on("webContents-setZoomLevel", (id, level) => {
const browserWindow = getWindowById(id);
browserWindow.webContents.setZoomLevel(level);
});
socket.on('webContents-setVisualZoomLevelLimits', async (id, minimumLevel, maximumLevel) => {
socket.on("webContents-setVisualZoomLevelLimits", async (id, minimumLevel, maximumLevel) => {
const browserWindow = getWindowById(id);
await browserWindow.webContents.setVisualZoomLevelLimits(minimumLevel, maximumLevel);
electronSocket.emit('webContents-setVisualZoomLevelLimits-completed');
electronSocket.emit("webContents-setVisualZoomLevelLimits-completed");
});
socket.on("webContents-toggleDevTools", (id) => {
getWindowById(id).webContents.toggleDevTools();
@@ -346,26 +379,26 @@ module.exports = (socket) => {
});
socket.on("webContents-isDevToolsOpened", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isDevToolsOpened-completed', browserWindow.webContents.isDevToolsOpened());
electronSocket.emit("webContents-isDevToolsOpened-completed", browserWindow.webContents.isDevToolsOpened());
});
socket.on("webContents-isDevToolsFocused", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isDevToolsFocused-completed', browserWindow.webContents.isDevToolsFocused());
electronSocket.emit("webContents-isDevToolsFocused-completed", browserWindow.webContents.isDevToolsFocused());
});
socket.on("webContents-setAudioMuted", (id, muted) => {
getWindowById(id).webContents.setAudioMuted(muted);
});
socket.on("webContents-isAudioMuted", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isAudioMuted-completed', browserWindow.webContents.isAudioMuted());
electronSocket.emit("webContents-isAudioMuted-completed", browserWindow.webContents.isAudioMuted());
});
socket.on("webContents-isCurrentlyAudible", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-isCurrentlyAudible-completed', browserWindow.webContents.isCurrentlyAudible());
electronSocket.emit("webContents-isCurrentlyAudible-completed", browserWindow.webContents.isCurrentlyAudible());
});
socket.on("webContents-getUserAgent", function (id) {
const browserWindow = getWindowById(id);
electronSocket.emit('webContents-getUserAgent-completed', browserWindow.webContents.getUserAgent());
electronSocket.emit("webContents-getUserAgent-completed", browserWindow.webContents.getUserAgent());
});
socket.on("webContents-setUserAgent", (id, userAgent) => {
getWindowById(id).webContents.setUserAgent(userAgent);

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -1,10 +1,14 @@
const { app } = require('electron');
const { BrowserWindow } = require('electron');
const { protocol } = require('electron');
const { createServer } = require('http');
const { randomUUID } = require('crypto');
const { Server } = require('socket.io');
const { platform } = require('os');
const path = require('path');
const fs = require('fs');
const cProcess = require('child_process').spawn;
const portscanner = require('portscanner');
const { imageSize } = require('image-size');
let io, server, browserWindows, ipc, apiProcess, loadURL;
let appApi, menu, dialogApi, notification, tray, webContents;
let globalShortcut, shellApi, screen, clipboard, autoUpdater;
@@ -16,20 +20,19 @@ let nativeTheme;
let dock;
let launchFile;
let launchUrl;
let processApi;
let manifestJsonFileName = 'package.json';
let unpackedelectron = false;
let unpackeddotnet = false;
let dotnetpacked = false;
let electronforcedport;
let electronUrl;
let authToken = randomUUID().split('-').join('');
if (app.commandLine.hasSwitch('manifest')) {
manifestJsonFileName = app.commandLine.getSwitchValue('manifest');
}
console.log('Entry!!!: ');
if (app.commandLine.hasSwitch('unpackedelectron')) {
unpackedelectron = true;
}
@@ -41,13 +44,19 @@ else if (app.commandLine.hasSwitch('dotnetpacked')) {
}
if (app.commandLine.hasSwitch('electronforcedport')) {
electronforcedport = app.commandLine.getSwitchValue('electronforcedport');
electronforcedport = +app.commandLine.getSwitchValue('electronforcedport');
}
// Store in global for access by browser windows
global.authToken = authToken;
if (app.commandLine.hasSwitch('electronurl')) {
electronUrl = app.commandLine.getSwitchValue('electronurl');
}
// Custom startup hook: look for custom_main.js and invoke its onStartup(host) if present.
// If the hook returns false, abort Electron startup.
try {
const fs = require('fs');
const customMainPath = path.join(__dirname, 'custom_main.js');
if (fs.existsSync(customMainPath)) {
const customMain = require(customMainPath);
@@ -73,7 +82,7 @@ let manifestJsonFilePath = path.join(currentPath, manifestJsonFileName);
// if running unpackedelectron, lets change the path
if (unpackedelectron || unpackeddotnet) {
console.log('unpackedelectron! dir: ' + currentPath);
console.debug('Running in unpacked mode, dir: ' + currentPath);
manifestJsonFilePath = path.join(currentPath, manifestJsonFileName);
currentBinPath = path.join(currentPath, '../'); // go to project directory
@@ -140,7 +149,7 @@ function getForwardedArgs() {
const forwardedArgs = getForwardedArgs();
app.on('ready', () => {
app.on('ready', () => {
// Fix ERR_UNKNOWN_URL_SCHEME using file protocol
// https://github.com/electron/electron/issues/23757
////protocol.registerFileProtocol('file', (request, callback) => {
@@ -153,44 +162,41 @@ app.on('ready', () => {
}
if (electronforcedport) {
console.log('Electron Socket IO (forced) Port: ' + electronforcedport);
console.info('Electron Socket IO (forced) Port: ' + electronforcedport);
startSocketApiBridge(electronforcedport);
return;
} else {
console.info('Electron Socket dynamic IO Port');
startSocketApiBridge(0);
}
// Added default port as configurable for port restricted environments.
let defaultElectronPort = 8000;
if (manifestJsonFile.electronPort) {
defaultElectronPort = manifestJsonFile.electronPort;
}
// hostname needs to be localhost, otherwise Windows Firewall will be triggered.
portscanner.findAPortNotInUse(defaultElectronPort, 65535, 'localhost', function (error, port) {
console.log('Electron Socket IO Port: ' + port);
startSocketApiBridge(port);
});
});
app.on('quit', async (event, exitCode) => {
try {
server.close();
server.closeAllConnections();
} catch (e) {
console.error(e);
}
try {
apiProcess?.kill();
} catch (e) {
console.error(e);
}
try {
if (io && typeof io.close === 'function') {
io.close();
// Clean up Socket.IO resources (legacy mode only)
if (server) {
try {
server.close();
server.closeAllConnections();
} catch (e) {
console.error('Error closing Socket.IO server:', e);
}
}
// Clean up API process (Socket.IO mode only)
if (typeof apiProcess !== 'undefined' && apiProcess) {
try {
apiProcess.kill();
} catch (e) {
console.error('Error killing API process:', e);
}
}
// Clean up Socket.IO connection
if (typeof io !== 'undefined' && io && typeof io.close === 'function') {
try {
io.close();
} catch (e) {
console.error('Error closing Socket.IO connection:', e);
}
} catch (e) {
console.error(e);
}
});
@@ -246,9 +252,7 @@ function startSplashScreen() {
// it's an image, so we can compute the desired splash screen size
imageSize(imageFile, (error, dimensions) => {
if (error) {
console.log(`load splashscreen error:`);
console.error(error);
console.error(`load splashscreen error:`, error);
throw new Error(error.message);
}
@@ -259,9 +263,9 @@ function startSplashScreen() {
function startSocketApiBridge(port) {
// instead of 'require('socket.io')(port);' we need to use this workaround
// otherwise the Windows Firewall will be triggered
console.log('Electron Socket: starting...');
server = require('http').createServer();
const { Server } = require('socket.io');
console.debug('Electron Socket: starting...');
server = createServer();
const host = !port ? '127.0.0.1' : 'localhost';
let hostHook;
io = new Server({
pingTimeout: 60000, // in ms, default is 5000
@@ -269,14 +273,16 @@ function startSocketApiBridge(port) {
});
io.attach(server);
server.listen(port, 'localhost');
server.listen(port, host);
server.on('listening', function () {
console.log('Electron Socket: listening on port %s at %s', server.address().port, server.address().address);
const addr = server.address();
console.info(`Electron Socket: listening on port ${addr.port} at ${addr.address} using ${authToken}`);
// Now that socket connection is established, we can guarantee port will not be open for portscanner
if (unpackedelectron) {
startAspCoreBackendUnpackaged(port);
startAspCoreBackendUnpackaged(addr.port);
} else if (!unpackeddotnet && !dotnetpacked) {
startAspCoreBackend(port);
startAspCoreBackend(addr.port);
}
});
@@ -286,9 +292,16 @@ function startSocketApiBridge(port) {
// @ts-ignore
io.on('connection', (socket) => {
console.log('Electron Socket: connected!');
console.info('Electron Socket: connected!');
if (authToken && socket.request.headers.authorization !== authToken) {
console.warn('Electron Socket authentication failed!');
socket.disconnect(true);
return;
}
socket.on('disconnect', function (reason) {
console.log('Got disconnect! Reason: ' + reason);
console.debug('Got disconnect! Reason: ' + reason);
try {
////console.log('requireCache');
////console.log(require.cache['electron-host-hook']);
@@ -308,7 +321,7 @@ function startSocketApiBridge(port) {
global['electronsocket'].setMaxListeners(0);
}
console.log('Electron Socket: loading components...');
console.debug('Electron Socket: loading components...');
if (appApi === undefined) appApi = require('./api/app')(socket, app);
if (browserWindows === undefined) browserWindows = require('./api/browserWindows')(socket, app);
@@ -369,7 +382,7 @@ function startSocketApiBridge(port) {
console.error(error.message);
}
console.log('Electron Socket: startup complete.');
console.info('Electron Socket: startup complete.');
});
}
@@ -383,23 +396,23 @@ function startAspCoreBackend(electronPort) {
envParam,
`/electronPort=${electronPort}`,
`/electronPID=${process.pid}`,
`/electronAuthToken=${authToken}`,
// forward user supplied args (avoid duplicate environment)
...forwardedArgs.filter(a => !(envParam && a.startsWith('--environment=')))
].filter(p => p);
let binaryFile = manifestJsonFile.executable;
const os = require('os');
if (os.platform() === 'win32') {
if (platform() === 'win32') {
binaryFile = binaryFile + '.exe';
}
let binFilePath = path.join(currentBinPath, binaryFile);
var options = { cwd: currentBinPath };
console.log('Starting backend with parameters:', parameters.join(' '));
console.debug('Starting backend with parameters:', parameters.join(' '));
apiProcess = cProcess(binFilePath, parameters, options);
apiProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data.toString()}`);
console.debug(`stdout: ${data.toString()}`);
});
}
}
@@ -414,22 +427,22 @@ function startAspCoreBackendUnpackaged(electronPort) {
envParam,
`/electronPort=${electronPort}`,
`/electronPID=${process.pid}`,
`/electronAuthToken=${authToken}`,
...forwardedArgs.filter(a => !(envParam && a.startsWith('--environment=')))
].filter(p => p);
let binaryFile = manifestJsonFile.executable;
const os = require('os');
if (os.platform() === 'win32') {
if (platform() === 'win32') {
binaryFile = binaryFile + '.exe';
}
let binFilePath = path.join(currentBinPath, binaryFile);
var options = { cwd: currentBinPath };
console.log('Starting backend (unpackaged) with parameters:', parameters.join(' '));
console.debug('Starting backend (unpackaged) with parameters:', parameters.join(' '));
apiProcess = cProcess(binFilePath, parameters, options);
apiProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data.toString()}`);
console.debug(`stdout: ${data.toString()}`);
});
}
}

View File

@@ -9,6 +9,7 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@microsoft/signalr": "^8.0.7",
"dasherize": "^2.0.0",
"electron-host-hook": "file:./ElectronHostHook",
"electron-updater": "^6.6.2",
@@ -57,9 +58,9 @@
}
},
"node_modules/@eslint-community/eslint-utils": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz",
"integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==",
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz",
"integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -140,20 +141,20 @@
}
},
"node_modules/@eslint/eslintrc": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz",
"integrity": "sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==",
"version": "3.3.4",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.4.tgz",
"integrity": "sha512-4h4MVF8pmBsncB60r0wSJiIeUKTSD4m7FmTFThG8RHlsg9ajqckLm9OraguFGZE4vVdpiI1Q4+hFnisopmG6gQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"ajv": "^6.12.4",
"ajv": "^6.14.0",
"debug": "^4.3.2",
"espree": "^10.0.1",
"globals": "^14.0.0",
"ignore": "^5.2.0",
"import-fresh": "^3.2.1",
"js-yaml": "^4.1.0",
"minimatch": "^3.1.2",
"js-yaml": "^4.1.1",
"minimatch": "^3.1.3",
"strip-json-comments": "^3.1.1"
},
"engines": {
@@ -164,9 +165,9 @@
}
},
"node_modules/@eslint/js": {
"version": "9.39.1",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.1.tgz",
"integrity": "sha512-S26Stp4zCy88tH94QbBv3XCuzRQiZ9yXofEILmglYTh/Ug/a9/umqvgFtYBAo3Lp0nsI/5/qH1CCrbdK3AP1Tw==",
"version": "9.39.3",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.3.tgz",
"integrity": "sha512-1B1VkCq6FuUNlQvlBYb+1jDu/gV297TIs/OeiaSR9l1H27SVW55ONE1e1Vp16NqP683+xEGzxYtv4XCiDPaQiw==",
"dev": true,
"license": "MIT",
"engines": {
@@ -252,6 +253,40 @@
"url": "https://github.com/sponsors/nzakas"
}
},
"node_modules/@microsoft/signalr": {
"version": "8.0.17",
"resolved": "https://registry.npmjs.org/@microsoft/signalr/-/signalr-8.0.17.tgz",
"integrity": "sha512-5pM6xPtKZNJLO0Tq5nQasVyPFwi/WBY3QB5uc/v3dIPTpS1JXQbaXAQAPxFoQ5rTBFE094w8bbqkp17F9ReQvA==",
"license": "MIT",
"dependencies": {
"abort-controller": "^3.0.0",
"eventsource": "^2.0.2",
"fetch-cookie": "^2.0.3",
"node-fetch": "^2.6.7",
"ws": "^7.5.10"
}
},
"node_modules/@microsoft/signalr/node_modules/ws": {
"version": "7.5.10",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
"license": "MIT",
"engines": {
"node": ">=8.3.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/@sindresorhus/is": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz",
@@ -314,9 +349,9 @@
"license": "MIT"
},
"node_modules/@types/http-cache-semantics": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz",
"integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz",
"integrity": "sha512-L3LgimLHXtGkWikKnsPg0/VFx9OGZaC+eN1u4r+OB1XRqH3meBIAVC2zr1WdMH+RHmnRkqliQAOHNJ/E0j/e0Q==",
"dev": true,
"license": "MIT"
},
@@ -338,9 +373,9 @@
}
},
"node_modules/@types/node": {
"version": "22.19.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.1.tgz",
"integrity": "sha512-LCCV0HdSZZZb34qifBsyWlUmok6W7ouER+oQIGBScS8EsZsQbrtFTUrDX4hOl+CS6p7cnNC4td+qrSVGSCTUfQ==",
"version": "22.19.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.11.tgz",
"integrity": "sha512-BH7YwL6rA93ReqeQS1c4bsPpcfOmJasG+Fkr6Y59q83f9M1WcBRHR2vM+P9eOisYRcN3ujQoiZY8uk5W+1WL8w==",
"license": "MIT",
"dependencies": {
"undici-types": "~6.21.0"
@@ -367,6 +402,18 @@
"@types/node": "*"
}
},
"node_modules/abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"license": "MIT",
"dependencies": {
"event-target-shim": "^5.0.0"
},
"engines": {
"node": ">=6.5"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
@@ -381,9 +428,9 @@
}
},
"node_modules/acorn": {
"version": "8.15.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"version": "8.16.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
"dev": true,
"license": "MIT",
"bin": {
@@ -404,9 +451,9 @@
}
},
"node_modules/ajv": {
"version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"version": "6.14.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz",
"integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -498,9 +545,9 @@
}
},
"node_modules/builder-util-runtime": {
"version": "9.3.1",
"resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.3.1.tgz",
"integrity": "sha512-2/egrNDDnRaxVwK3A+cJq6UOlqOdedGA7JPqCeJjN2Zjk1/QB/6QUi3b714ScIGS7HafFXTyzJEOr5b44I3kvQ==",
"version": "9.5.1",
"resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.5.1.tgz",
"integrity": "sha512-qt41tMfgHTllhResqM5DcnHyDIWNgzHvuY2jDcYP9iaGpkWxTUzV6GQjDeLnlR1/DtdlcsWQbA7sByMpmJFTLQ==",
"license": "MIT",
"dependencies": {
"debug": "^4.3.4",
@@ -616,9 +663,9 @@
}
},
"node_modules/cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"version": "2.8.6",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz",
"integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==",
"license": "MIT",
"dependencies": {
"object-assign": "^4",
@@ -626,6 +673,10 @@
},
"engines": {
"node": ">= 0.10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/cross-spawn": {
@@ -782,18 +833,18 @@
"link": true
},
"node_modules/electron-updater": {
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.6.2.tgz",
"integrity": "sha512-Cr4GDOkbAUqRHP5/oeOmH/L2Bn6+FQPxVLZtPbcmKZC63a1F3uu5EefYOssgZXG3u/zBlubbJ5PJdITdMVggbw==",
"version": "6.8.3",
"resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.8.3.tgz",
"integrity": "sha512-Z6sgw3jgbikWKXei1ENdqFOxBP0WlXg3TtKfz0rgw2vIZFJUyI4pD7ZN7jrkm7EoMK+tcm/qTnPUdqfZukBlBQ==",
"license": "MIT",
"dependencies": {
"builder-util-runtime": "9.3.1",
"builder-util-runtime": "9.5.1",
"fs-extra": "^10.1.0",
"js-yaml": "^4.1.0",
"lazy-val": "^1.0.5",
"lodash.escaperegexp": "^4.1.2",
"lodash.isequal": "^4.5.0",
"semver": "^7.6.3",
"semver": "~7.7.3",
"tiny-typed-emitter": "^2.1.0"
}
},
@@ -824,9 +875,9 @@
}
},
"node_modules/electron-updater/node_modules/semver": {
"version": "7.7.3",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
"version": "7.7.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
@@ -845,9 +896,9 @@
}
},
"node_modules/electron/node_modules/@types/node": {
"version": "20.19.25",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.25.tgz",
"integrity": "sha512-ZsJzA5thDQMSQO788d7IocwwQbI8B5OPzmqNvpf3NY/+MHDAS759Wo0gd2WQeXYt5AAAQjzcrTVC6SKCuYgoCQ==",
"version": "20.19.33",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.33.tgz",
"integrity": "sha512-Rs1bVAIdBs5gbTIKza/tgpMuG1k3U/UMJLWecIMxNdJFDMzcM5LOiLVRYh3PilWEYDIeUDv7bpiHPLPsbydGcw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -865,9 +916,9 @@
}
},
"node_modules/engine.io": {
"version": "6.6.4",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.4.tgz",
"integrity": "sha512-ZCkIjSYNDyGn0R6ewHDtXgns/Zre/NT6Agvq1/WobF7JXgFff4SeDroKiCO3fNJreU9YG429Sc81o4w5ok/W5g==",
"version": "6.6.5",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.5.tgz",
"integrity": "sha512-2RZdgEbXmp5+dVbRm0P7HQUImZpICccJy7rN7Tv+SFa55pH+lxnuw6/K1ZxxBfHoYpSkHLAO92oa8O4SwFXA2A==",
"license": "MIT",
"dependencies": {
"@types/cors": "^2.8.12",
@@ -876,9 +927,9 @@
"base64id": "2.0.0",
"cookie": "~0.7.2",
"cors": "~2.8.5",
"debug": "~4.3.1",
"debug": "~4.4.1",
"engine.io-parser": "~5.2.1",
"ws": "~8.17.1"
"ws": "~8.18.3"
},
"engines": {
"node": ">=10.2.0"
@@ -893,23 +944,6 @@
"node": ">=10.0.0"
}
},
"node_modules/engine.io/node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/env-paths": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
@@ -964,9 +998,9 @@
}
},
"node_modules/eslint": {
"version": "9.39.1",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.1.tgz",
"integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==",
"version": "9.39.3",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.3.tgz",
"integrity": "sha512-VmQ+sifHUbI/IcSopBCF/HO3YiHQx/AVd3UVyYL6weuwW+HvON9VYn5l6Zl1WZzPWXPNZrSQpxwkkZ/VuvJZzg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -976,7 +1010,7 @@
"@eslint/config-helpers": "^0.4.2",
"@eslint/core": "^0.17.0",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "9.39.1",
"@eslint/js": "9.39.3",
"@eslint/plugin-kit": "^0.4.1",
"@humanfs/node": "^0.16.6",
"@humanwhocodes/module-importer": "^1.0.1",
@@ -1072,9 +1106,9 @@
}
},
"node_modules/esquery": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz",
"integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==",
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz",
"integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
@@ -1117,6 +1151,24 @@
"node": ">=0.10.0"
}
},
"node_modules/event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/eventsource": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-2.0.2.tgz",
"integrity": "sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==",
"license": "MIT",
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/extract-zip": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz",
@@ -1169,6 +1221,16 @@
"pend": "~1.2.0"
}
},
"node_modules/fetch-cookie": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-2.2.0.tgz",
"integrity": "sha512-h9AgfjURuCgA2+2ISl8GbavpUdR+WGAM2McW/ovn4tVccegp8ZqCKWSBR8uRdM8dDNlx5WdKRWxBYUwteLDCNQ==",
"license": "Unlicense",
"dependencies": {
"set-cookie-parser": "^2.4.8",
"tough-cookie": "^4.0.0"
}
},
"node_modules/file-entry-cache": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
@@ -1284,9 +1346,9 @@
}
},
"node_modules/global-agent/node_modules/semver": {
"version": "7.7.3",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
"version": "7.7.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
"dev": true,
"license": "ISC",
"optional": true,
@@ -1614,9 +1676,9 @@
}
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"version": "4.17.23",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
"license": "MIT"
},
"node_modules/lodash.escaperegexp": {
@@ -1701,9 +1763,9 @@
}
},
"node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.4.tgz",
"integrity": "sha512-twmL+S8+7yIsE9wsqgzU3E8/LumN3M3QELrBZ20OdmQ9jB2JvW5oZtBEmft84k/Gs5CG9mqtWc6Y9vW+JEzGxw==",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -1735,6 +1797,26 @@
"node": ">= 0.6"
}
},
"node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"license": "MIT",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/normalize-url": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz",
@@ -1912,6 +1994,18 @@
"node": ">=0.4.0"
}
},
"node_modules/psl": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.15.0.tgz",
"integrity": "sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==",
"license": "MIT",
"dependencies": {
"punycode": "^2.3.1"
},
"funding": {
"url": "https://github.com/sponsors/lupomontero"
}
},
"node_modules/pump": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz",
@@ -1927,12 +2021,17 @@
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/querystringify": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",
"license": "MIT"
},
"node_modules/queue": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/queue/-/queue-6.0.2.tgz",
@@ -1955,6 +2054,12 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
"license": "MIT"
},
"node_modules/resolve-alpn": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz",
@@ -2005,10 +2110,13 @@
}
},
"node_modules/sax": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.4.3.tgz",
"integrity": "sha512-yqYn1JhPczigF94DMS+shiDMjDowYO6y9+wB/4WgO0Y19jWYk0lQ4tuG5KI7kj4FTp1wxPj5IFfcrz/s1c3jjQ==",
"license": "BlueOak-1.0.0"
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.4.4.tgz",
"integrity": "sha512-1n3r/tGXO6b6VXMdFT54SHzT9ytu9yr7TaELowdYpMqY/Ao7EnlQGmAQ1+RatX7Tkkdm6hONI2owqNx2aZj5Sw==",
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=11.0.0"
}
},
"node_modules/semver": {
"version": "6.3.1",
@@ -2045,6 +2153,12 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/set-cookie-parser": {
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.2.tgz",
"integrity": "sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==",
"license": "MIT"
},
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
@@ -2069,15 +2183,15 @@
}
},
"node_modules/socket.io": {
"version": "4.8.1",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.1.tgz",
"integrity": "sha512-oZ7iUCxph8WYRHHcjBEc9unw3adt5CmSNlppj/5Q4k2RIrhl8Z5yY2Xr4j9zj0+wzVZ0bxmYoGSzKJnRl6A4yg==",
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.3.tgz",
"integrity": "sha512-2Dd78bqzzjE6KPkD5fHZmDAKRNe3J15q+YHDrIsy9WEkqttc7GY+kT9OBLSMaPbQaEd0x1BjcmtMtXkfpc+T5A==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.4",
"base64id": "~2.0.0",
"cors": "~2.8.5",
"debug": "~4.3.2",
"debug": "~4.4.1",
"engine.io": "~6.6.0",
"socket.io-adapter": "~2.5.2",
"socket.io-parser": "~4.2.4"
@@ -2087,79 +2201,28 @@
}
},
"node_modules/socket.io-adapter": {
"version": "2.5.5",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.5.tgz",
"integrity": "sha512-eLDQas5dzPgOWCk9GuuJC2lBqItuhKI4uxGgo9aIV7MYbk2h9Q6uULEh8WBzThoI7l+qU9Ast9fVUmkqPP9wYg==",
"version": "2.5.6",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.6.tgz",
"integrity": "sha512-DkkO/dz7MGln0dHn5bmN3pPy+JmywNICWrJqVWiVOyvXjWQFIv9c2h24JrQLLFJ2aQVQf/Cvl1vblnd4r2apLQ==",
"license": "MIT",
"dependencies": {
"debug": "~4.3.4",
"ws": "~8.17.1"
}
},
"node_modules/socket.io-adapter/node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
"debug": "~4.4.1",
"ws": "~8.18.3"
}
},
"node_modules/socket.io-parser": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz",
"integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==",
"version": "4.2.5",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.5.tgz",
"integrity": "sha512-bPMmpy/5WWKHea5Y/jYAP6k74A+hvmRCQaJuJB6I/ML5JZq/KfNieUVo/3Mh7SAqn7TyFdIo6wqYHInG1MU1bQ==",
"license": "MIT",
"dependencies": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.1"
"debug": "~4.4.1"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/socket.io-parser/node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/socket.io/node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/sprintf-js": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
@@ -2213,6 +2276,36 @@
"integrity": "sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==",
"license": "MIT"
},
"node_modules/tough-cookie": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz",
"integrity": "sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==",
"license": "BSD-3-Clause",
"dependencies": {
"psl": "^1.1.33",
"punycode": "^2.1.1",
"universalify": "^0.2.0",
"url-parse": "^1.5.3"
},
"engines": {
"node": ">=6"
}
},
"node_modules/tough-cookie/node_modules/universalify": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
"license": "MIT",
"engines": {
"node": ">= 4.0.0"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"license": "MIT"
},
"node_modules/type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@@ -2280,6 +2373,16 @@
"punycode": "^2.1.0"
}
},
"node_modules/url-parse": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
"integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
"license": "MIT",
"dependencies": {
"querystringify": "^2.1.1",
"requires-port": "^1.0.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
@@ -2289,6 +2392,22 @@
"node": ">= 0.8"
}
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"license": "BSD-2-Clause"
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@@ -2323,9 +2442,9 @@
"license": "ISC"
},
"node_modules/ws": {
"version": "8.17.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
"version": "8.18.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"

View File

@@ -19,7 +19,6 @@
"dasherize": "^2.0.0",
"electron-host-hook": "file:./ElectronHostHook",
"image-size": "^1.2.1",
"portscanner": "^2.2.0",
"electron-updater": "^6.6.2",
"socket.io": "^4.8.1"
},

View File

@@ -266,9 +266,11 @@ namespace ElectronNET.IntegrationTests.Tests
try
{
window = await Electron.WindowManager.CreateWindowAsync(
new BrowserWindowOptions { Show = false, Width = 300, Height = 200 },
new BrowserWindowOptions { Show = true, Width = 300, Height = 200 },
"about:blank");
await Task.Delay(5.seconds());
var tcs = new TaskCompletionSource<Rectangle>(TaskCreationOptions.RunContinuationsAsynchronously);
window.OnBoundsChanged += bounds => tcs.TrySetResult(bounds);

View File

@@ -174,13 +174,15 @@ namespace ElectronNET.IntegrationTests.Tests
try
{
await Task.Delay(1.seconds());
window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = true }, "about:blank");
await Task.Delay(3.seconds());
await Task.Delay(5.seconds());
window.WebContents.SetUserAgent("MyUserAgent/1.0");
await Task.Delay(1.seconds());
await Task.Delay(2.seconds());
var ok = await window.WebContents.GetUserAgentAsync();
ok.Should().Be("MyUserAgent/1.0");

View File

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<ResourcePreloader />
<link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]" />
<link rel="stylesheet" href="@Assets["app.css"]" />
<link rel="stylesheet" href="@Assets["electronnet-samples-blazorsignalr.styles.css"]" />
<ImportMap />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet />
</head>
<body>
<Routes />
<ReconnectModal />
<script src="@Assets["_framework/blazor.web.js"]"></script>
</body>
</html>

View File

@@ -0,0 +1,23 @@
@inherits LayoutComponentBase
<div class="page">
<div class="sidebar">
<NavMenu />
</div>
<main>
<div class="top-row px-4">
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
</div>
<article class="content px-4">
@Body
</article>
</main>
</div>
<div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>

View File

@@ -0,0 +1,98 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}
main {
flex: 1;
}
.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}
.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}
.top-row ::deep a, .top-row ::deep .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
text-decoration: none;
}
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}
.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}
@media (max-width: 640.98px) {
.top-row {
justify-content: space-between;
}
.top-row ::deep a, .top-row ::deep .btn-link {
margin-left: 0;
}
}
@media (min-width: 641px) {
.page {
flex-direction: row;
}
.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}
.top-row {
position: sticky;
top: 0;
z-index: 1;
}
.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}
.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
#blazor-error-ui {
color-scheme: light only;
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}
#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}

View File

@@ -0,0 +1,30 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">ElectronNET.Samples.BlazorSignalR</a>
</div>
</div>
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
<nav class="nav flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="weather">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
</NavLink>
</div>
</nav>
</div>

View File

@@ -0,0 +1,105 @@
.navbar-toggler {
appearance: none;
cursor: pointer;
width: 3.5rem;
height: 2.5rem;
color: white;
position: absolute;
top: 0.5rem;
right: 1rem;
border: 1px solid rgba(255, 255, 255, 0.1);
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
}
.navbar-toggler:checked {
background-color: rgba(255, 255, 255, 0.5);
}
.top-row {
min-height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}
.navbar-brand {
font-size: 1.1rem;
}
.bi {
display: inline-block;
position: relative;
width: 1.25rem;
height: 1.25rem;
margin-right: 0.75rem;
top: -1px;
background-size: cover;
}
.bi-house-door-fill-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
}
.bi-plus-square-fill-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
}
.bi-list-nested-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
}
.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}
.nav-item:first-of-type {
padding-top: 1rem;
}
.nav-item:last-of-type {
padding-bottom: 1rem;
}
.nav-item ::deep .nav-link {
color: #d7d7d7;
background: none;
border: none;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
width: 100%;
}
.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.37);
color: white;
}
.nav-item ::deep .nav-link:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}
.nav-scrollable {
display: none;
}
.navbar-toggler:checked ~ .nav-scrollable {
display: block;
}
@media (min-width: 641px) {
.navbar-toggler {
display: none;
}
.nav-scrollable {
/* Never collapse the sidebar for wide screens */
display: block;
/* Allow sidebar to scroll for tall menus */
height: calc(100vh - 3.5rem);
overflow-y: auto;
}
}

View File

@@ -0,0 +1,31 @@
<script type="module" src="@Assets["Components/Layout/ReconnectModal.razor.js"]"></script>
<dialog id="components-reconnect-modal" data-nosnippet>
<div class="components-reconnect-container">
<div class="components-rejoining-animation" aria-hidden="true">
<div></div>
<div></div>
</div>
<p class="components-reconnect-first-attempt-visible">
Rejoining the server...
</p>
<p class="components-reconnect-repeated-attempt-visible">
Rejoin failed... trying again in <span id="components-seconds-to-next-attempt"></span> seconds.
</p>
<p class="components-reconnect-failed-visible">
Failed to rejoin.<br />Please retry or reload the page.
</p>
<button id="components-reconnect-button" class="components-reconnect-failed-visible">
Retry
</button>
<p class="components-pause-visible">
The session has been paused by the server.
</p>
<button id="components-resume-button" class="components-pause-visible">
Resume
</button>
<p class="components-resume-failed-visible">
Failed to resume the session.<br />Please reload the page.
</p>
</div>
</dialog>

View File

@@ -0,0 +1,157 @@
.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible,
.components-rejoining-animation {
display: none;
}
#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
display: block;
}
#components-reconnect-modal {
background-color: white;
width: 20rem;
margin: 20vh auto;
padding: 2rem;
border: 0;
border-radius: 0.5rem;
box-shadow: 0 3px 6px 2px rgba(0, 0, 0, 0.3);
opacity: 0;
transition: display 0.5s allow-discrete, overlay 0.5s allow-discrete;
animation: components-reconnect-modal-fadeOutOpacity 0.5s both;
&[open]
{
animation: components-reconnect-modal-slideUp 1.5s cubic-bezier(.05, .89, .25, 1.02) 0.3s, components-reconnect-modal-fadeInOpacity 0.5s ease-in-out 0.3s;
animation-fill-mode: both;
}
}
#components-reconnect-modal::backdrop {
background-color: rgba(0, 0, 0, 0.4);
animation: components-reconnect-modal-fadeInOpacity 0.5s ease-in-out;
opacity: 1;
}
@keyframes components-reconnect-modal-slideUp {
0% {
transform: translateY(30px) scale(0.95);
}
100% {
transform: translateY(0);
}
}
@keyframes components-reconnect-modal-fadeInOpacity {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes components-reconnect-modal-fadeOutOpacity {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
.components-reconnect-container {
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
}
#components-reconnect-modal p {
margin: 0;
text-align: center;
}
#components-reconnect-modal button {
border: 0;
background-color: #6b9ed2;
color: white;
padding: 4px 24px;
border-radius: 4px;
}
#components-reconnect-modal button:hover {
background-color: #3b6ea2;
}
#components-reconnect-modal button:active {
background-color: #6b9ed2;
}
.components-rejoining-animation {
position: relative;
width: 80px;
height: 80px;
}
.components-rejoining-animation div {
position: absolute;
border: 3px solid #0087ff;
opacity: 1;
border-radius: 50%;
animation: components-rejoining-animation 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
.components-rejoining-animation div:nth-child(2) {
animation-delay: -0.5s;
}
@keyframes components-rejoining-animation {
0% {
top: 40px;
left: 40px;
width: 0;
height: 0;
opacity: 0;
}
4.9% {
top: 40px;
left: 40px;
width: 0;
height: 0;
opacity: 0;
}
5% {
top: 40px;
left: 40px;
width: 0;
height: 0;
opacity: 1;
}
100% {
top: 0px;
left: 0px;
width: 80px;
height: 80px;
opacity: 0;
}
}

View File

@@ -0,0 +1,63 @@
// Set up event handlers
const reconnectModal = document.getElementById("components-reconnect-modal");
reconnectModal.addEventListener("components-reconnect-state-changed", handleReconnectStateChanged);
const retryButton = document.getElementById("components-reconnect-button");
retryButton.addEventListener("click", retry);
const resumeButton = document.getElementById("components-resume-button");
resumeButton.addEventListener("click", resume);
function handleReconnectStateChanged(event) {
if (event.detail.state === "show") {
reconnectModal.showModal();
} else if (event.detail.state === "hide") {
reconnectModal.close();
} else if (event.detail.state === "failed") {
document.addEventListener("visibilitychange", retryWhenDocumentBecomesVisible);
} else if (event.detail.state === "rejected") {
location.reload();
}
}
async function retry() {
document.removeEventListener("visibilitychange", retryWhenDocumentBecomesVisible);
try {
// Reconnect will asynchronously return:
// - true to mean success
// - false to mean we reached the server, but it rejected the connection (e.g., unknown circuit ID)
// - exception to mean we didn't reach the server (this can be sync or async)
const successful = await Blazor.reconnect();
if (!successful) {
// We have been able to reach the server, but the circuit is no longer available.
// We'll reload the page so the user can continue using the app as quickly as possible.
const resumeSuccessful = await Blazor.resumeCircuit();
if (!resumeSuccessful) {
location.reload();
} else {
reconnectModal.close();
}
}
} catch (err) {
// We got an exception, server is currently unavailable
document.addEventListener("visibilitychange", retryWhenDocumentBecomesVisible);
}
}
async function resume() {
try {
const successful = await Blazor.resumeCircuit();
if (!successful) {
location.reload();
}
} catch {
location.reload();
}
}
async function retryWhenDocumentBecomesVisible() {
if (document.visibilityState === "visible") {
await retry();
}
}

View File

@@ -0,0 +1,19 @@
@page "/counter"
@rendermode InteractiveServer
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}

View File

@@ -0,0 +1,36 @@
@page "/Error"
@using System.Diagnostics
<PageTitle>Error</PageTitle>
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
@code{
[CascadingParameter]
private HttpContext? HttpContext { get; set; }
private string? RequestId { get; set; }
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
protected override void OnInitialized() =>
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
}

View File

@@ -0,0 +1,7 @@
@page "/"
<PageTitle>Home</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new app.

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