mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-22 06:54:44 +00:00
Merge branch 'master' into switch-to-new-socket-lib
This commit is contained in:
@@ -492,20 +492,7 @@ namespace ElectronNET.API
|
||||
/// should usually also specify a productName field, which is your application's full capitalized name, and
|
||||
/// which will be preferred over name by Electron.
|
||||
/// </summary>
|
||||
public Task<string> GetNameAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<string>("appGetNameCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetNameCompleted");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetName");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string> GetNameAsync() => BridgeConnector.OnResult<string>("appGetName", "appGetNameCompleted");
|
||||
|
||||
|
||||
internal App()
|
||||
@@ -543,11 +530,6 @@ namespace ElectronNET.API
|
||||
private static App _app;
|
||||
private static object _syncRoot = new object();
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Try to close all windows. The <see cref="BeforeQuit"/> event will be emitted first. If all windows are successfully
|
||||
/// closed, the <see cref="WillQuit"/> event will be emitted and by default the application will terminate. This method
|
||||
@@ -599,7 +581,7 @@ namespace ElectronNET.API
|
||||
/// <param name="relaunchOptions">Options for the relaunch.</param>
|
||||
public void Relaunch(RelaunchOptions relaunchOptions)
|
||||
{
|
||||
BridgeConnector.EmitSync("appRelaunch", JObject.FromObject(relaunchOptions, _jsonSerializer));
|
||||
BridgeConnector.EmitSync("appRelaunch", relaunchOptions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -619,7 +601,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
public void Focus(FocusOptions focusOptions)
|
||||
{
|
||||
BridgeConnector.Emit("appFocus", JObject.FromObject(focusOptions, _jsonSerializer));
|
||||
BridgeConnector.Emit("appFocus", focusOptions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -641,25 +623,7 @@ namespace ElectronNET.API
|
||||
/// <summary>
|
||||
/// The current application directory.
|
||||
/// </summary>
|
||||
public async Task<string> GetAppPathAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using(cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<string>("appGetAppPathCompleted", (path) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetAppPathCompleted");
|
||||
taskCompletionSource.SetResult(path);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetAppPath");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<string> GetAppPathAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<string>("appGetAppPath", "appGetAppPathCompleted", cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sets or creates a directory your app's logs which can then be manipulated with <see cref="GetPathAsync"/>
|
||||
@@ -682,25 +646,8 @@ namespace ElectronNET.API
|
||||
/// <param name="pathName">Special directory.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A path to a special directory or file associated with name.</returns>
|
||||
public async Task<string> GetPathAsync(PathName pathName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
public Task<string> GetPathAsync(PathName pathName, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<string>("appGetPath", "appGetPathCompleted", cancellationToken, pathName.GetDescription());
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using(cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<string>("appGetPathCompleted", (path) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetPathCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(path);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetPath", pathName.GetDescription());
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the path to a special directory or file associated with name. If the path specifies a directory
|
||||
@@ -724,25 +671,7 @@ namespace ElectronNET.API
|
||||
/// the version of the current bundle or executable is returned.
|
||||
/// </summary>
|
||||
/// <returns>The version of the loaded application.</returns>
|
||||
public async Task<string> GetVersionAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using(cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<string>("appGetVersionCompleted", (version) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetVersionCompleted");
|
||||
taskCompletionSource.SetResult(version);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetVersion");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<string> GetVersionAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<string>("appGetVersion", "appGetVersionCompleted", cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// The current application locale. Possible return values are documented <see href="https://www.electronjs.org/docs/api/locales">here</see>.
|
||||
@@ -752,25 +681,7 @@ namespace ElectronNET.API
|
||||
/// Note: On Windows, you have to call it after the <see cref="Ready"/> events gets emitted.
|
||||
/// </summary>
|
||||
/// <returns>The current application locale.</returns>
|
||||
public async Task<string> GetLocaleAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<string>("appGetLocaleCompleted", (local) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetLocaleCompleted");
|
||||
taskCompletionSource.SetResult(local);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetLocale");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<string> GetLocaleAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<string>("appGetLocale", "appGetLocaleCompleted", cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Adds path to the recent documents list. This list is managed by the OS. On Windows you can visit the
|
||||
@@ -878,25 +789,7 @@ namespace ElectronNET.API
|
||||
/// <param name="args">Arguments passed to the executable. Defaults to an empty array.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Whether the call succeeded.</returns>
|
||||
public async Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<bool>("appSetAsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Off("appSetAsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult(success);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appSetAsDefaultProtocolClient", protocol, path, args);
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<bool> SetAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appSetAsDefaultProtocolClient", "appSetAsDefaultProtocolClientCompleted", cancellationToken, protocol, path, args);
|
||||
|
||||
/// <summary>
|
||||
/// This method checks if the current executable as the default handler for a protocol (aka URI scheme).
|
||||
@@ -932,25 +825,8 @@ namespace ElectronNET.API
|
||||
/// <param name="args">Defaults to an empty array.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Whether the call succeeded.</returns>
|
||||
public async Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
public Task<bool> RemoveAsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appRemoveAsDefaultProtocolClient", "appRemoveAsDefaultProtocolClientCompleted", cancellationToken, protocol, path, args);
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<bool>("appRemoveAsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Off("appRemoveAsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult(success);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appRemoveAsDefaultProtocolClient", protocol, path, args);
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method checks if the current executable is the default handler for a protocol (aka URI scheme).
|
||||
@@ -1004,25 +880,8 @@ namespace ElectronNET.API
|
||||
/// <param name="args">Defaults to an empty array.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Whether the current executable is the default handler for a protocol (aka URI scheme).</returns>
|
||||
public async Task<bool> IsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
public Task<bool> IsDefaultProtocolClientAsync(string protocol, string path, string[] args, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appIsDefaultProtocolClient", "appIsDefaultProtocolClientCompleted", cancellationToken, protocol, path, args);
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<bool>("appIsDefaultProtocolClientCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Off("appIsDefaultProtocolClientCompleted");
|
||||
taskCompletionSource.SetResult(success);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appIsDefaultProtocolClient", protocol, path, args);
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds tasks to the <see cref="UserTask"/> category of the JumpList on Windows.
|
||||
@@ -1032,50 +891,14 @@ namespace ElectronNET.API
|
||||
/// <param name="userTasks">Array of <see cref="UserTask"/> objects.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Whether the call succeeded.</returns>
|
||||
public async Task<bool> SetUserTasksAsync(UserTask[] userTasks, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<bool>("appSetUserTasksCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Off("appSetUserTasksCompleted");
|
||||
taskCompletionSource.SetResult(success);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appSetUserTasks", JArray.FromObject(userTasks, _jsonSerializer));
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<bool> SetUserTasksAsync(UserTask[] userTasks, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appSetUserTasks", "appSetUserTasksCompleted", cancellationToken, userTasks);
|
||||
|
||||
/// <summary>
|
||||
/// Jump List settings for the application.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Jump List settings.</returns>
|
||||
public async Task<JumpListSettings> GetJumpListSettingsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<JumpListSettings>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<JumpListSettings>("appGetJumpListSettingsCompleted", (jumpListSettings) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetJumpListSettingsCompleted");
|
||||
taskCompletionSource.SetResult(jumpListSettings);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetJumpListSettings");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<JumpListSettings> GetJumpListSettingsAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<JumpListSettings>("appGetJumpListSettings", "appGetJumpListSettingsCompleted", cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sets or removes a custom Jump List for the application. If categories is null the previously set custom
|
||||
@@ -1095,7 +918,7 @@ namespace ElectronNET.API
|
||||
/// <param name="categories">Array of <see cref="JumpListCategory"/> objects.</param>
|
||||
public void SetJumpList(JumpListCategory[] categories)
|
||||
{
|
||||
BridgeConnector.Emit("appSetJumpList", JArray.FromObject(categories, _jsonSerializer));
|
||||
BridgeConnector.Emit("appSetJumpList", categories);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1119,7 +942,7 @@ namespace ElectronNET.API
|
||||
/// should continue loading. And returns true if your process has sent its parameters to another instance, and
|
||||
/// you should immediately quit.
|
||||
/// </returns>
|
||||
public async Task<bool> RequestSingleInstanceLockAsync(Action<string[], string> newInstanceOpened, CancellationToken cancellationToken = default)
|
||||
public async Task<bool> RequestSingleInstanceLockAsync(Action<string[], string> newInstanceOpened, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -1140,8 +963,7 @@ namespace ElectronNET.API
|
||||
|
||||
BridgeConnector.Emit("appRequestSingleInstanceLock");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1160,24 +982,7 @@ namespace ElectronNET.API
|
||||
/// <see cref="ReleaseSingleInstanceLock"/>.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
public async Task<bool> HasSingleInstanceLockAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<bool>("appHasSingleInstanceLockCompleted", (hasLock) =>
|
||||
{
|
||||
BridgeConnector.Off("appHasSingleInstanceLockCompleted");
|
||||
taskCompletionSource.SetResult(hasLock);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appHasSingleInstanceLock");
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<bool> HasSingleInstanceLockAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appHasSingleInstanceLock", "appHasSingleInstanceLockCompleted", cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Creates an NSUserActivity and sets it as the current activity. The activity is
|
||||
@@ -1212,24 +1017,8 @@ namespace ElectronNET.API
|
||||
/// The type of the currently running activity.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
public async Task<string> GetCurrentActivityTypeAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
public Task<string> GetCurrentActivityTypeAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<string>("appGetCurrentActivityType", "appGetCurrentActivityTypeCompleted", cancellationToken);
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<string>("appGetCurrentActivityTypeCompleted", (activityType) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetCurrentActivityTypeCompleted");
|
||||
taskCompletionSource.SetResult(activityType);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetCurrentActivityType");
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invalidates the current <see href="https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html">Handoff</see> user activity.
|
||||
@@ -1265,25 +1054,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Result of import. Value of 0 indicates success.</returns>
|
||||
public async Task<int> ImportCertificateAsync(ImportCertificateOptions options, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<int>("appImportCertificateCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("appImportCertificateCompleted");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appImportCertificate", JObject.FromObject(options, _jsonSerializer));
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<int> ImportCertificateAsync(ImportCertificateOptions options, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<int>("appImportCertificate", "appImportCertificateCompleted", cancellationToken, options);
|
||||
|
||||
/// <summary>
|
||||
/// Memory and cpu usage statistics of all the processes associated with the app.
|
||||
@@ -1293,25 +1064,7 @@ namespace ElectronNET.API
|
||||
/// statistics of all the processes associated with the app.
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// </returns>
|
||||
public async Task<ProcessMetric[]> GetAppMetricsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<ProcessMetric[]>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<ProcessMetric[]>("appGetAppMetricsCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetAppMetricsCompleted");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetAppMetrics");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<ProcessMetric[]> GetAppMetricsAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<ProcessMetric[]>("appGetAppMetrics", "appGetAppMetricsCompleted", cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// The Graphics Feature Status from chrome://gpu/.
|
||||
@@ -1319,25 +1072,7 @@ namespace ElectronNET.API
|
||||
/// Note: This information is only usable after the gpu-info-update event is emitted.
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// </summary>
|
||||
public async Task<GPUFeatureStatus> GetGpuFeatureStatusAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<GPUFeatureStatus>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<GPUFeatureStatus>("appGetGpuFeatureStatusCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetGpuFeatureStatusCompleted");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetGpuFeatureStatus");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<GPUFeatureStatus> GetGpuFeatureStatusAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<GPUFeatureStatus>("appGetGpuFeatureStatus", "appGetGpuFeatureStatusCompleted", cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the counter badge for current app. Setting the count to 0 will hide the badge.
|
||||
@@ -1349,49 +1084,13 @@ namespace ElectronNET.API
|
||||
/// <param name="count">Counter badge.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Whether the call succeeded.</returns>
|
||||
public async Task<bool> SetBadgeCountAsync(int count, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<bool>("appSetBadgeCountCompleted", (success) =>
|
||||
{
|
||||
BridgeConnector.Off("appSetBadgeCountCompleted");
|
||||
taskCompletionSource.SetResult(success);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appSetBadgeCount", count);
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<bool> SetBadgeCountAsync(int count, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appSetBadgeCount", "appSetBadgeCountCompleted", cancellationToken, count);
|
||||
|
||||
/// <summary>
|
||||
/// The current value displayed in the counter badge.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
public async Task<int> GetBadgeCountAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<int>("appGetBadgeCountCompleted", (count) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetBadgeCountCompleted");
|
||||
taskCompletionSource.SetResult(count);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetBadgeCount");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<int> GetBadgeCountAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<int>("appGetBadgeCount", "appGetBadgeCountCompleted", cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="CommandLine"/> object that allows you to read and manipulate the command line arguments that Chromium uses.
|
||||
@@ -1402,25 +1101,7 @@ namespace ElectronNET.API
|
||||
/// Whether the current desktop environment is Unity launcher.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
public async Task<bool> IsUnityRunningAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<bool>("appIsUnityRunningCompleted", (isUnityRunning) =>
|
||||
{
|
||||
BridgeConnector.Off("appIsUnityRunningCompleted");
|
||||
taskCompletionSource.SetResult(isUnityRunning);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appIsUnityRunning");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<bool> IsUnityRunningAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appIsUnityRunning", "appIsUnityRunningCompleted", cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// If you provided path and args options to <see cref="SetLoginItemSettings"/> then you need to pass the same
|
||||
@@ -1437,32 +1118,9 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
public async Task<LoginItemSettings> GetLoginItemSettingsAsync(LoginItemSettingsOptions options, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<LoginItemSettings>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<LoginItemSettings>("appGetLoginItemSettingsCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetLoginItemSettingsCompleted");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
if (options == null)
|
||||
{
|
||||
BridgeConnector.Emit("appGetLoginItemSettings");
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Emit("appGetLoginItemSettings", JObject.FromObject(options, _jsonSerializer));
|
||||
}
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<LoginItemSettings> GetLoginItemSettingsAsync(LoginItemSettingsOptions options, CancellationToken cancellationToken = default) =>
|
||||
options is null ? BridgeConnector.OnResult<LoginItemSettings>("appGetLoginItemSettings", "appGetLoginItemSettingsCompleted", cancellationToken)
|
||||
: BridgeConnector.OnResult<LoginItemSettings>("appGetLoginItemSettings", "appGetLoginItemSettingsCompleted", cancellationToken, options);
|
||||
|
||||
/// <summary>
|
||||
/// Set the app's login item settings.
|
||||
@@ -1472,7 +1130,7 @@ namespace ElectronNET.API
|
||||
/// <param name="loginSettings"></param>
|
||||
public void SetLoginItemSettings(LoginSettings loginSettings)
|
||||
{
|
||||
BridgeConnector.Emit("appSetLoginItemSettings", JObject.FromObject(loginSettings, _jsonSerializer));
|
||||
BridgeConnector.Emit("appSetLoginItemSettings", loginSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1481,25 +1139,8 @@ namespace ElectronNET.API
|
||||
/// See <see href="chromium.org/developers/design-documents/accessibility">Chromium's accessibility docs</see> for more details.
|
||||
/// </summary>
|
||||
/// <returns><see langword="true"/> if Chrome’s accessibility support is enabled, <see langword="false"/> otherwise.</returns>
|
||||
public async Task<bool> IsAccessibilitySupportEnabledAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
public Task<bool> IsAccessibilitySupportEnabledAsync(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appIsAccessibilitySupportEnabled", "appIsAccessibilitySupportEnabledCompleted", cancellationToken);
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<bool>("appIsAccessibilitySupportEnabledCompleted", (isAccessibilitySupportEnabled) =>
|
||||
{
|
||||
BridgeConnector.Off("appIsAccessibilitySupportEnabledCompleted");
|
||||
taskCompletionSource.SetResult(isAccessibilitySupportEnabled);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appIsAccessibilitySupportEnabled");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manually enables Chrome's accessibility support, allowing to expose accessibility switch to users in application settings.
|
||||
@@ -1538,7 +1179,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options">About panel options.</param>
|
||||
public void SetAboutPanelOptions(AboutPanelOptions options)
|
||||
{
|
||||
BridgeConnector.Emit("appSetAboutPanelOptions", JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Emit("appSetAboutPanelOptions", options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1565,20 +1206,7 @@ namespace ElectronNET.API
|
||||
/// custom value as early as possible in your app's initialization to ensure that your overridden value
|
||||
/// is used.
|
||||
/// </summary>
|
||||
public Task<string> GetUserAgentFallbackAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<string>("appGetUserAgentFallbackCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("appGetUserAgentFallbackCompleted");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appGetUserAgentFallback");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string> GetUserAgentFallbackAsync() => BridgeConnector.OnResult<string>("appGetUserAgentFallback", "appGetUserAgentFallbackCompleted");
|
||||
|
||||
internal void PreventQuit()
|
||||
{
|
||||
@@ -1593,27 +1221,27 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="eventName">The event name</param>
|
||||
/// <param name="fn">The handler</param>
|
||||
public void On(string eventName, Action fn)
|
||||
=> Events.Instance.On(ModuleName, eventName, fn);
|
||||
public void On(string eventName, Action fn) => Events.Instance.On(ModuleName, eventName, fn);
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe to an unmapped event on the <see cref="App"/> module.
|
||||
/// </summary>
|
||||
/// <param name="eventName">The event name</param>
|
||||
/// <param name="fn">The handler</param>
|
||||
public void On(string eventName, Action<object> fn) => Events.Instance.On(ModuleName, eventName, fn);
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe to an unmapped event on the <see cref="App"/> module once.
|
||||
/// </summary>
|
||||
/// <param name="eventName">The event name</param>
|
||||
/// <param name="fn">The handler</param>
|
||||
public void Once(string eventName, Action fn)
|
||||
=> Events.Instance.Once(ModuleName, eventName, fn);
|
||||
public void Once(string eventName, Action fn) => Events.Instance.Once(ModuleName, eventName, fn);
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe to an unmapped event on the <see cref="App"/> module once.
|
||||
/// </summary>
|
||||
/// <param name="eventName">The event name</param>
|
||||
/// <param name="fn">The handler</param>
|
||||
public void Once(string eventName, Action<object> fn)
|
||||
=> Events.Instance.Once(ModuleName, eventName, fn);
|
||||
public void Once(string eventName, Action<object> fn) => Events.Instance.Once(ModuleName, eventName, fn);
|
||||
}
|
||||
}
|
||||
@@ -16,40 +16,14 @@ namespace ElectronNET.API
|
||||
/// <summary>
|
||||
/// Whether to automatically download an update when it is found. (Default is true)
|
||||
/// </summary>
|
||||
public Task<bool> IsAutoDownloadEnabledAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<bool>("autoUpdater-autoDownload-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("autoUpdater-autoDownload-get-reply");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("autoUpdater-autoDownload-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<bool> IsAutoDownloadEnabledAsync() => BridgeConnector.OnResult<bool>("autoUpdater-autoDownload-get", "autoUpdater-autoDownload-get-reply");
|
||||
|
||||
/// <summary>
|
||||
/// Whether to automatically install a downloaded update on app quit (if `QuitAndInstall` was not called before).
|
||||
///
|
||||
/// Applicable only on Windows and Linux.
|
||||
/// </summary>
|
||||
public Task<bool> IsAutoInstallOnAppQuitEnabledAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<bool>("autoUpdater-autoInstallOnAppQuit-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("autoUpdater-autoInstallOnAppQuit-get-reply");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("autoUpdater-autoInstallOnAppQuit-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<bool> IsAutoInstallOnAppQuitEnabledAsync() => BridgeConnector.OnResult<bool>("autoUpdater-autoInstallOnAppQuit-get", "autoUpdater-autoInstallOnAppQuit-get-reply");
|
||||
|
||||
/// <summary>
|
||||
/// *GitHub provider only.* Whether to allow update to pre-release versions.
|
||||
@@ -57,54 +31,16 @@ namespace ElectronNET.API
|
||||
///
|
||||
/// If "true", downgrade will be allowed("allowDowngrade" will be set to "true").
|
||||
/// </summary>
|
||||
public Task<bool> IsAllowPrereleaseEnabledAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<bool>("autoUpdater-allowPrerelease-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("autoUpdater-allowPrerelease-get-reply");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("autoUpdater-allowPrerelease-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<bool> IsAllowPrereleaseEnabledAsync() => BridgeConnector.OnResult<bool>("autoUpdater-allowPrerelease-get", "autoUpdater-allowPrerelease-get-reply");
|
||||
|
||||
/// <summary>
|
||||
/// *GitHub provider only.*
|
||||
/// Get all release notes (from current version to latest), not just the latest (Default is false).
|
||||
/// </summary>
|
||||
public Task<bool> IsFullChangeLogEnabledAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
public Task<bool> IsFullChangeLogEnabledAsync() => BridgeConnector.OnResult<bool>("autoUpdater-fullChangelog-get", "autoUpdater-fullChangelog-get-reply");
|
||||
|
||||
BridgeConnector.On<bool>("autoUpdater-fullChangelog-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("autoUpdater-fullChangelog-get-reply");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("autoUpdater-fullChangelog-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
public Task<bool> IsAllowDowngradeEnabledAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<bool>("autoUpdater-allowDowngrade-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("autoUpdater-allowDowngrade-get-reply");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("autoUpdater-allowDowngrade-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<bool> IsAllowDowngradeEnabledAsync() => BridgeConnector.OnResult<bool>("autoUpdater-allowDowngrade-get", "autoUpdater-allowDowngrade-get-reply");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Whether to automatically download an update when it is found. (Default is true)
|
||||
@@ -172,72 +108,23 @@ namespace ElectronNET.API
|
||||
/// <summary>
|
||||
/// For test only.
|
||||
/// </summary>
|
||||
public Task<string> GetUpdateConfigPathAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<string>("autoUpdater-updateConfigPath-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("autoUpdater-updateConfigPath-get-reply");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("autoUpdater-updateConfigPath-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string> GetUpdateConfigPathAsync() => BridgeConnector.OnResult<string>("autoUpdater-updateConfigPath-get", "autoUpdater-updateConfigPath-get-reply");
|
||||
|
||||
/// <summary>
|
||||
/// The current application version
|
||||
/// </summary>
|
||||
public Task<SemVer> GetCurrentVersionAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<SemVer>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<SemVer>("autoUpdater-currentVersion-get-reply", (version) =>
|
||||
{
|
||||
BridgeConnector.Off("autoUpdater-currentVersion-get-reply");
|
||||
taskCompletionSource.SetResult(version);
|
||||
});
|
||||
BridgeConnector.Emit("autoUpdater-currentVersion-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<SemVer> GetCurrentVersionAsync() => BridgeConnector.OnResult<SemVer>("autoUpdater-updateConcurrentVersionfigPath-get", "autoUpdater-currentVersion-get-reply");
|
||||
|
||||
/// <summary>
|
||||
/// Get the update channel. Not applicable for GitHub.
|
||||
/// Doesn’t return channel from the update configuration, only if was previously set.
|
||||
/// </summary>
|
||||
public Task<string> GetChannelAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<string>("autoUpdater-channel-get-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("autoUpdater-channel-get-reply");
|
||||
taskCompletionSource.SetResult(result.ToString());
|
||||
});
|
||||
BridgeConnector.Emit("autoUpdater-channel-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
|
||||
public Task<string> GetChannelAsync() => BridgeConnector.OnResult<string>("autoUpdater-channel-get", "autoUpdater-channel-get-reply");
|
||||
|
||||
/// <summary>
|
||||
/// The request headers.
|
||||
/// </summary>
|
||||
public Task<Dictionary<string, string>> GetRequestHeadersAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Dictionary<string, string>>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
BridgeConnector.On<Dictionary<string, string>>("autoUpdater-requestHeaders-get-reply", (headers) =>
|
||||
{
|
||||
BridgeConnector.Off("autoUpdater-requestHeaders-get-reply");
|
||||
taskCompletionSource.SetResult(headers);
|
||||
});
|
||||
BridgeConnector.Emit("autoUpdater-requestHeaders-get");
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<Dictionary<string, string>> GetRequestHeadersAsync() => BridgeConnector.OnResult<Dictionary<string, string>>("autoUpdater-requestHeaders-get", "autoUpdater-requestHeaders-get-reply");
|
||||
|
||||
/// <summary>
|
||||
/// The request headers.
|
||||
@@ -246,7 +133,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
set
|
||||
{
|
||||
BridgeConnector.Emit("autoUpdater-requestHeaders-set", JObject.FromObject(value, _jsonSerializer));
|
||||
BridgeConnector.Emit("autoUpdater-requestHeaders-set", value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,10 +468,5 @@ namespace ElectronNET.API
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using SocketIOClient;
|
||||
using SocketIOClient.JsonSerializer;
|
||||
using SocketIOClient.Newtonsoft.Json;
|
||||
|
||||
namespace ElectronNET.API
|
||||
@@ -149,7 +153,7 @@ namespace ElectronNET.API
|
||||
|
||||
public static async Task<T> OnResult<T>(string triggerEvent, string completedEvent, params object[] args)
|
||||
{
|
||||
string eventKey = triggerEvent;
|
||||
string eventKey = completedEvent;
|
||||
|
||||
if (args is object && args.Length > 0) // If there are arguments passed, we generate a unique event key with the arguments
|
||||
// this allow us to wait for previous events first before registering new ones
|
||||
@@ -162,7 +166,7 @@ namespace ElectronNET.API
|
||||
eventKey = $"{eventKey}-{(uint)hash.ToHashCode()}";
|
||||
}
|
||||
|
||||
if (EventTasks<T>.TryGetOrAdd(triggerEvent, eventKey, out var taskCompletionSource, out var waitThisFirstAndThenTryAgain))
|
||||
if (EventTasks<T>.TryGetOrAdd(completedEvent, eventKey, out var taskCompletionSource, out var waitThisFirstAndThenTryAgain))
|
||||
{
|
||||
if (waitThisFirstAndThenTryAgain is object)
|
||||
{
|
||||
@@ -188,7 +192,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
Off(completedEvent);
|
||||
taskCompletionSource.SetResult(result);
|
||||
EventTasks<T>.DoneWith(triggerEvent, eventKey, taskCompletionSource);
|
||||
EventTasks<T>.DoneWith(completedEvent, eventKey, taskCompletionSource);
|
||||
});
|
||||
|
||||
Emit(triggerEvent, args);
|
||||
@@ -201,21 +205,56 @@ namespace ElectronNET.API
|
||||
|
||||
public static async Task<T> OnResult<T>(string triggerEvent, string completedEvent, CancellationToken cancellationToken, params object[] args)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
string eventKey = completedEvent;
|
||||
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
if (args is object && args.Length > 0) // If there are arguments passed, we generate a unique event key with the arguments
|
||||
// this allow us to wait for previous events first before registering new ones
|
||||
{
|
||||
|
||||
On<T>(completedEvent, (result) =>
|
||||
var hash = new HashCode();
|
||||
foreach (var obj in args)
|
||||
{
|
||||
Off(completedEvent);
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
Emit(triggerEvent, args);
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
hash.Add(obj);
|
||||
}
|
||||
eventKey = $"{eventKey}-{(uint)hash.ToHashCode()}";
|
||||
}
|
||||
|
||||
if (EventTasks<T>.TryGetOrAdd(completedEvent, eventKey, out var taskCompletionSource, out var waitThisFirstAndThenTryAgain))
|
||||
{
|
||||
if (waitThisFirstAndThenTryAgain is object)
|
||||
{
|
||||
//There was a pending call with different parameters, so we need to wait that first and then call here again
|
||||
try
|
||||
{
|
||||
await Task.Run(() => waitThisFirstAndThenTryAgain, cancellationToken);
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Ignore any exceptions here so we can set a new event below
|
||||
//The exception will also be visible to the original first caller due to taskCompletionSource.Task
|
||||
}
|
||||
|
||||
//Try again to set the event
|
||||
return await OnResult<T>(triggerEvent, completedEvent, cancellationToken, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
//A new TaskCompletionSource was added, so we need to register the completed event here
|
||||
|
||||
On<T>(completedEvent, (result) =>
|
||||
{
|
||||
Off(completedEvent);
|
||||
taskCompletionSource.SetResult(result);
|
||||
EventTasks<T>.DoneWith(completedEvent, eventKey, taskCompletionSource);
|
||||
});
|
||||
|
||||
Emit(triggerEvent, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return await taskCompletionSource.Task;
|
||||
}
|
||||
private static SocketIO Socket
|
||||
{
|
||||
@@ -235,7 +274,7 @@ namespace ElectronNET.API
|
||||
EIO = 3
|
||||
});
|
||||
|
||||
socket.JsonSerializer = new NewtonsoftJsonSerializer(socket.Options.EIO);
|
||||
socket.JsonSerializer = new CamelCaseNewtonsoftJsonSerializer(socket.Options.EIO);
|
||||
|
||||
|
||||
socket.OnConnected += (_, __) =>
|
||||
@@ -258,5 +297,22 @@ namespace ElectronNET.API
|
||||
return _socket;
|
||||
}
|
||||
}
|
||||
|
||||
private class CamelCaseNewtonsoftJsonSerializer : NewtonsoftJsonSerializer
|
||||
{
|
||||
public CamelCaseNewtonsoftJsonSerializer(int eio) : base(eio)
|
||||
{
|
||||
}
|
||||
|
||||
public override JsonSerializerSettings CreateOptions()
|
||||
{
|
||||
return new JsonSerializerSettings()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,24 +31,11 @@ namespace ElectronNET.API
|
||||
///
|
||||
/// (experimental)
|
||||
/// </summary>
|
||||
public Task<Rectangle> GetBoundsAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Rectangle>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<Rectangle>("browserView-getBounds-reply", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("browserView-getBounds-reply");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("browserView-getBounds", Id);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<Rectangle> GetBoundsAsync() => BridgeConnector.OnResult<Rectangle>("browserView-getBounds", "browserView-getBounds-reply" + Id, Id);
|
||||
|
||||
public void SetBounds(Rectangle value)
|
||||
{
|
||||
BridgeConnector.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserView-setBounds", Id, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,7 +56,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public void SetAutoResize(AutoResizeOptions options)
|
||||
{
|
||||
BridgeConnector.Emit("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserView-setAutoResize", Id, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,11 +69,5 @@ namespace ElectronNET.API
|
||||
{
|
||||
BridgeConnector.Emit("browserView-setBackgroundColor", Id, color);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,19 +949,13 @@ namespace ElectronNET.API
|
||||
/// Whether the window is focused.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsFocusedAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsFocused", "browserWindow-isFocused-completed", Id);
|
||||
}
|
||||
public Task<bool> IsFocusedAsync() => BridgeConnector.OnResult<bool>("browserWindowIsFocused", "browserWindow-isFocused-completed" + Id, Id);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the window is destroyed.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsDestroyedAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsDestroyed", "browserWindow-isDestroyed-completed", Id);
|
||||
}
|
||||
public Task<bool> IsDestroyedAsync() => BridgeConnector.OnResult<bool>("browserWindowIsDestroyed", "browserWindow-isDestroyed-completed" + Id, Id);
|
||||
|
||||
/// <summary>
|
||||
/// Shows and gives focus to the window.
|
||||
@@ -993,7 +987,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsVisibleAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsVisible", "browserWindow-isVisible-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsVisible", "browserWindow-isVisible-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1002,7 +996,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsModalAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsModal", "browserWindow-isModal-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsModal", "browserWindow-isModal-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1027,7 +1021,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMaximizedAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMaximized", "browserWindow-isMaximized-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMaximized", "browserWindow-isMaximized-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1052,7 +1046,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMinimizedAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMinimized", "browserWindow-isMinimized-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMinimized", "browserWindow-isMinimized-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1069,7 +1063,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsFullScreenAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsFullScreen", "browserWindow-isFullScreen-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsFullScreen", "browserWindow-isFullScreen-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1088,7 +1082,7 @@ namespace ElectronNET.API
|
||||
/// <param name="extraSize">The extra size not to be included while maintaining the aspect ratio.</param>
|
||||
public void SetAspectRatio(int aspectRatio, Size extraSize)
|
||||
{
|
||||
BridgeConnector.Emit("browserWindowSetAspectRatio", Id, aspectRatio, JObject.FromObject(extraSize, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserWindowSetAspectRatio", Id, aspectRatio, extraSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1129,7 +1123,7 @@ namespace ElectronNET.API
|
||||
/// <param name="bounds"></param>
|
||||
public void SetBounds(Rectangle bounds)
|
||||
{
|
||||
BridgeConnector.Emit("browserWindowSetBounds", Id, JObject.FromObject(bounds, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserWindowSetBounds", Id, bounds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1139,7 +1133,7 @@ namespace ElectronNET.API
|
||||
/// <param name="animate"></param>
|
||||
public void SetBounds(Rectangle bounds, bool animate)
|
||||
{
|
||||
BridgeConnector.Emit("browserWindowSetBounds", Id, JObject.FromObject(bounds, _jsonSerializer), animate);
|
||||
BridgeConnector.Emit("browserWindowSetBounds", Id, bounds, animate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1148,7 +1142,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<Rectangle> GetBoundsAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<Rectangle>("browserWindowGetBounds", "browserWindow-getBounds-completed", Id);
|
||||
return BridgeConnector.OnResult<Rectangle>("browserWindowGetBounds", "browserWindow-getBounds-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1157,7 +1151,7 @@ namespace ElectronNET.API
|
||||
/// <param name="bounds"></param>
|
||||
public void SetContentBounds(Rectangle bounds)
|
||||
{
|
||||
BridgeConnector.Emit("browserWindowSetContentBounds", Id, JObject.FromObject(bounds, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserWindowSetContentBounds", Id, bounds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1167,7 +1161,7 @@ namespace ElectronNET.API
|
||||
/// <param name="animate"></param>
|
||||
public void SetContentBounds(Rectangle bounds, bool animate)
|
||||
{
|
||||
BridgeConnector.Emit("browserWindowSetContentBounds", Id, JObject.FromObject(bounds, _jsonSerializer), animate);
|
||||
BridgeConnector.Emit("browserWindowSetContentBounds", Id, bounds, animate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1176,7 +1170,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<Rectangle> GetContentBoundsAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<Rectangle>("browserWindowGetContentBounds", "browserWindow-getContentBounds-completed", Id);
|
||||
return BridgeConnector.OnResult<Rectangle>("browserWindowGetContentBounds", "browserWindow-getContentBounds-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1206,7 +1200,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetSizeAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetSize", "browserWindow-getSize-completed", Id);
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetSize", "browserWindow-getSize-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1236,7 +1230,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetContentSizeAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetContentSize", "browserWindow-getContentSize-completed", Id);
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetContentSize", "browserWindow-getContentSize-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1255,7 +1249,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetMinimumSizeAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetMinimumSize", "browserWindow-getMinimumSize-completed", Id);
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetMinimumSize", "browserWindow-getMinimumSize-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1274,7 +1268,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetMaximumSizeAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetMaximumSize", "browserWindow-getMaximumSize-completed", Id);
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetMaximumSize", "browserWindow-getMaximumSize-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1292,7 +1286,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsResizableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsResizable", "browserWindow-isResizable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsResizable", "browserWindow-isResizable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1312,7 +1306,7 @@ namespace ElectronNET.API
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsMovableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMovable", "browserWindow-isMovable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMovable", "browserWindow-isMovable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1332,7 +1326,7 @@ namespace ElectronNET.API
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsMinimizableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMinimizable", "browserWindow-isMinimizable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMinimizable", "browserWindow-isMinimizable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1352,7 +1346,7 @@ namespace ElectronNET.API
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsMaximizableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMaximizable", "browserWindow-isMaximizable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMaximizable", "browserWindow-isMaximizable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1370,7 +1364,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsFullScreenableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsFullScreenable", "browserWindow-isFullScreenable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsFullScreenable", "browserWindow-isFullScreenable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1390,7 +1384,7 @@ namespace ElectronNET.API
|
||||
/// <returns>On Linux always returns true.</returns>
|
||||
public Task<bool> IsClosableAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsClosable", "browserWindow-isClosable-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsClosable", "browserWindow-isClosable-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1440,7 +1434,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsAlwaysOnTopAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsAlwaysOnTop", "browserWindow-isAlwaysOnTop-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsAlwaysOnTop", "browserWindow-isAlwaysOnTop-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1497,7 +1491,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<int[]> GetPositionAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetPosition", "browserWindow-getPosition-completed", Id);
|
||||
return BridgeConnector.OnResult<int[]>("browserWindowGetPosition", "browserWindow-getPosition-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1517,7 +1511,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<string> GetTitleAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetTitle", "browserWindow-getTitle-completed", Id);
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetTitle", "browserWindow-getTitle-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1576,7 +1570,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsKioskAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsKiosk", "browserWindow-isKiosk-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsKiosk", "browserWindow-isKiosk-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1585,7 +1579,7 @@ namespace ElectronNET.API
|
||||
/// <returns>string of the native handle obtained, HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.</returns>
|
||||
public Task<string> GetNativeWindowHandle()
|
||||
{
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetNativeWindowHandle", "browserWindow-getNativeWindowHandle-completed", Id);
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetNativeWindowHandle", "browserWindow-getNativeWindowHandle-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1604,7 +1598,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<string> GetRepresentedFilenameAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetRepresentedFilename", "browserWindow-getRepresentedFilename-completed", Id);
|
||||
return BridgeConnector.OnResult<string>("browserWindowGetRepresentedFilename", "browserWindow-getRepresentedFilename-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1623,7 +1617,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsDocumentEditedAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsDocumentEdited", "browserWindow-isDocumentEdited-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsDocumentEdited", "browserWindow-isDocumentEdited-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1660,7 +1654,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public void LoadURL(string url, LoadURLOptions options)
|
||||
{
|
||||
BridgeConnector.Emit("browserWindowLoadURL", Id, url, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserWindowLoadURL", Id, url, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1688,7 +1682,7 @@ namespace ElectronNET.API
|
||||
public void SetMenu(MenuItem[] menuItems)
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
BridgeConnector.Emit("browserWindowSetMenu", Id, JArray.FromObject(menuItems, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserWindowSetMenu", Id, menuItems);
|
||||
_items.AddRange(menuItems);
|
||||
|
||||
BridgeConnector.Off("windowMenuItemClicked");
|
||||
@@ -1737,7 +1731,7 @@ namespace ElectronNET.API
|
||||
/// <param name="progressBarOptions"></param>
|
||||
public void SetProgressBar(double progress, ProgressBarOptions progressBarOptions)
|
||||
{
|
||||
BridgeConnector.Emit("browserWindowSetProgressBar", Id, progress, JObject.FromObject(progressBarOptions, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserWindowSetProgressBar", Id, progress, progressBarOptions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1757,7 +1751,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> HasShadowAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowHasShadow", "browserWindow-hasShadow-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowHasShadow", "browserWindow-hasShadow-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1786,15 +1780,15 @@ namespace ElectronNET.API
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<bool>("browserWindowSetThumbarButtons-completed", (success) =>
|
||||
BridgeConnector.On<bool>("browserWindowSetThumbarButtons-completed" + Id, (success) =>
|
||||
{
|
||||
BridgeConnector.Off("browserWindowSetThumbarButtons-completed");
|
||||
BridgeConnector.Off("browserWindowSetThumbarButtons-completed" + Id);
|
||||
|
||||
taskCompletionSource.SetResult(success);
|
||||
});
|
||||
|
||||
thumbarButtons.AddThumbarButtonsId();
|
||||
BridgeConnector.Emit("browserWindowSetThumbarButtons", Id, JArray.FromObject(thumbarButtons, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserWindowSetThumbarButtons", Id, thumbarButtons);
|
||||
_thumbarButtons.Clear();
|
||||
_thumbarButtons.AddRange(thumbarButtons);
|
||||
|
||||
@@ -1837,7 +1831,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public void SetAppDetails(AppDetailsOptions options)
|
||||
{
|
||||
BridgeConnector.Emit("browserWindowSetAppDetails", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserWindowSetAppDetails", Id, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1866,7 +1860,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMenuBarAutoHideAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarAutoHide", "browserWindow-isMenuBarAutoHide-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarAutoHide", "browserWindow-isMenuBarAutoHide-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1885,7 +1879,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsMenuBarVisibleAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarVisible", "browserWindow-isMenuBarVisible-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsMenuBarVisible", "browserWindow-isMenuBarVisible-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1907,7 +1901,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsVisibleOnAllWorkspacesAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsVisibleOnAllWorkspaces", "browserWindow-isVisibleOnAllWorkspaces-completed", Id);
|
||||
return BridgeConnector.OnResult<bool>("browserWindowIsVisibleOnAllWorkspaces", "browserWindow-isVisibleOnAllWorkspaces-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1950,7 +1944,7 @@ namespace ElectronNET.API
|
||||
/// <param name="parent"></param>
|
||||
public void SetParentWindow(BrowserWindow parent)
|
||||
{
|
||||
BridgeConnector.Emit("browserWindowSetParentWindow", Id, JObject.FromObject(parent, _jsonSerializer));
|
||||
BridgeConnector.Emit("browserWindowSetParentWindow", Id, parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1959,7 +1953,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public async Task<BrowserWindow> GetParentWindowAsync()
|
||||
{
|
||||
var windowID = await BridgeConnector.OnResult<int>("browserWindowGetParentWindow", "browserWindow-getParentWindow-completed", Id);
|
||||
var windowID = await BridgeConnector.OnResult<int>("browserWindowGetParentWindow", "browserWindow-getParentWindow-completed" + Id, Id);
|
||||
return Electron.WindowManager.BrowserWindows.Where(w => w.Id == windowID).Single();
|
||||
}
|
||||
|
||||
@@ -1969,7 +1963,7 @@ namespace ElectronNET.API
|
||||
/// <returns></returns>
|
||||
public async Task<List<BrowserWindow>> GetChildWindowsAsync()
|
||||
{
|
||||
var windowIDs = new HashSet<int>(await BridgeConnector.OnResult<int[]>("browserWindowGetChildWindows", "browserWindow-getChildWindows-completed", Id));
|
||||
var windowIDs = new HashSet<int>(await BridgeConnector.OnResult<int[]>("browserWindowGetChildWindows", "browserWindow-getChildWindows-completed" + Id, Id));
|
||||
return Electron.WindowManager.BrowserWindows.Where(w => windowIDs.Contains(w.Id)).ToList();
|
||||
}
|
||||
|
||||
@@ -2009,11 +2003,5 @@ namespace ElectronNET.API
|
||||
{
|
||||
BridgeConnector.Emit("browserWindow-setBrowserView", Id, browserView.Id);
|
||||
}
|
||||
|
||||
private static readonly JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,21 +40,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns>The content in the clipboard as plain text.</returns>
|
||||
public Task<string> ReadTextAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<string>("clipboard-readText-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Off("clipboard-readText-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("clipboard-readText", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string> ReadTextAsync(string type = "") => BridgeConnector.OnResult<string>("clipboard-readText", "clipboard-readText-Completed", type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text into the clipboard as plain text.
|
||||
@@ -71,21 +57,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> ReadHTMLAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<string>("clipboard-readHTML-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Off("clipboard-readHTML-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("clipboard-readHTML", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string> ReadHTMLAsync(string type = "") => BridgeConnector.OnResult<string>("clipboard-readHTML", "clipboard-readHTML-Completed", type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes markup to the clipboard.
|
||||
@@ -102,21 +74,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> ReadRTFAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
public Task<string> ReadRTFAsync(string type = "") => BridgeConnector.OnResult<string>("clipboard-readRTF", "clipboard-readRTF-Completed", type);
|
||||
|
||||
BridgeConnector.On<string>("clipboard-readRTF-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Off("clipboard-readRTF-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("clipboard-readRTF", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the text into the clipboard in RTF.
|
||||
@@ -134,21 +93,7 @@ namespace ElectronNET.API
|
||||
/// be empty strings when the bookmark is unavailable.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<ReadBookmark> ReadBookmarkAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<ReadBookmark>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<ReadBookmark>("clipboard-readBookmark-Completed", (bookmark) =>
|
||||
{
|
||||
BridgeConnector.Off("clipboard-readBookmark-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(bookmark);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("clipboard-readBookmark");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<ReadBookmark> ReadBookmarkAsync() => BridgeConnector.OnResult<ReadBookmark>("clipboard-readBookmark", "clipboard-readBookmark-Completed");
|
||||
|
||||
/// <summary>
|
||||
/// Writes the title and url into the clipboard as a bookmark.
|
||||
@@ -171,21 +116,7 @@ namespace ElectronNET.API
|
||||
/// find pasteboard whenever the application is activated.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<string> ReadFindTextAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<string>("clipboard-readFindText-Completed", (text) =>
|
||||
{
|
||||
BridgeConnector.Off("clipboard-readFindText-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(text);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("clipboard-readFindText");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string> ReadFindTextAsync() => BridgeConnector.OnResult<string>("clipboard-readFindText", "clipboard-readFindText-Completed");
|
||||
|
||||
/// <summary>
|
||||
/// macOS: Writes the text into the find pasteboard as plain text. This method uses
|
||||
@@ -211,21 +142,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string[]> AvailableFormatsAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<string[]>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<string[]>("clipboard-availableFormats-Completed", (formats) =>
|
||||
{
|
||||
BridgeConnector.Off("clipboard-availableFormats-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(formats);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("clipboard-availableFormats", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<string[]> AvailableFormatsAsync(string type = "") => BridgeConnector.OnResult<string[]>("clipboard-availableFormats", "clipboard-availableFormats-Completed", type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes data to the clipboard.
|
||||
@@ -234,7 +151,7 @@ namespace ElectronNET.API
|
||||
/// <param name="type"></param>
|
||||
public void Write(Data data, string type = "")
|
||||
{
|
||||
BridgeConnector.Emit("clipboard-write", JObject.FromObject(data, _jsonSerializer), type);
|
||||
BridgeConnector.Emit("clipboard-write", data, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -242,21 +159,7 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Task<NativeImage> ReadImageAsync(string type = "")
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<NativeImage>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<NativeImage>("clipboard-readImage-Completed", (image) =>
|
||||
{
|
||||
BridgeConnector.Off("clipboard-readImage-Completed");
|
||||
|
||||
taskCompletionSource.SetResult(image);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("clipboard-readImage", type);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<NativeImage> ReadImageAsync(string type = "") => BridgeConnector.OnResult<NativeImage>("clipboard-readImage", "clipboard-readImage-Completed", type);
|
||||
|
||||
/// <summary>
|
||||
/// Writes an image to the clipboard.
|
||||
@@ -267,12 +170,5 @@ namespace ElectronNET.API
|
||||
{
|
||||
BridgeConnector.Emit("clipboard-writeImage", JsonConvert.SerializeObject(image), type);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -66,24 +66,7 @@ namespace ElectronNET.API
|
||||
/// <param name="switchName">A command-line switch</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>Whether the command-line switch is present.</returns>
|
||||
public async Task<bool> HasSwitchAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<bool>("appCommandLineHasSwitchCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("appCommandLineHasSwitchCompleted");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appCommandLineHasSwitch", switchName);
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<bool> HasSwitchAsync(string switchName, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<bool>("appCommandLineHasSwitch", "appCommandLineHasSwitchCompleted", cancellationToken, switchName);
|
||||
|
||||
/// <summary>
|
||||
/// The command-line switch value.
|
||||
@@ -94,23 +77,6 @@ namespace ElectronNET.API
|
||||
/// <remarks>
|
||||
/// Note: When the switch is not present or has no value, it returns empty string.
|
||||
/// </remarks>
|
||||
public async Task<string> GetSwitchValueAsync(string switchName, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<string>("appCommandLineGetSwitchValueCompleted", (result) =>
|
||||
{
|
||||
BridgeConnector.Off("appCommandLineGetSwitchValueCompleted");
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("appCommandLineGetSwitchValue", switchName);
|
||||
|
||||
return await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<string> GetSwitchValueAsync(string switchName, CancellationToken cancellationToken = default) => BridgeConnector.OnResult<string>("appCommandLineGetSwitchValue", "appCommandLineGetSwitchValueCompleted", cancellationToken, switchName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(cookies);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("webContents-session-cookies-get", Id, JObject.FromObject(filter, _jsonSerializer), guid);
|
||||
BridgeConnector.Emit("webContents-session-cookies-get", Id, filter, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("webContents-session-cookies-set", Id, JObject.FromObject(details, _jsonSerializer), guid);
|
||||
BridgeConnector.Emit("webContents-session-cookies-set", Id, details, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -138,12 +138,5 @@ namespace ElectronNET.API
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ namespace ElectronNET.API
|
||||
BridgeConnector.Off("showOpenDialogComplete" + guid);
|
||||
|
||||
var list = new List<string>();
|
||||
|
||||
foreach (var item in filePaths)
|
||||
{
|
||||
list.Add(HttpUtility.UrlDecode(item));
|
||||
@@ -63,10 +64,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(list.ToArray());
|
||||
});
|
||||
|
||||
|
||||
BridgeConnector.Emit("showOpenDialog",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(options, _jsonSerializer), guid);
|
||||
BridgeConnector.Emit("showOpenDialog", browserWindow, options, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -89,10 +87,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(filename);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("showSaveDialog",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(options, _jsonSerializer),
|
||||
guid);
|
||||
BridgeConnector.Emit("showSaveDialog", browserWindow, options, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -165,13 +160,10 @@ namespace ElectronNET.API
|
||||
|
||||
if (browserWindow == null)
|
||||
{
|
||||
BridgeConnector.Emit("showMessageBox", JObject.FromObject(messageBoxOptions, _jsonSerializer), guid);
|
||||
BridgeConnector.Emit("showMessageBox", messageBoxOptions, guid);
|
||||
} else
|
||||
{
|
||||
BridgeConnector.Emit("showMessageBox",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(messageBoxOptions, _jsonSerializer),
|
||||
guid);
|
||||
BridgeConnector.Emit("showMessageBox", browserWindow , messageBoxOptions, guid);
|
||||
}
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
@@ -223,19 +215,9 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("showCertificateTrustDialog",
|
||||
JObject.FromObject(browserWindow, _jsonSerializer),
|
||||
JObject.FromObject(options, _jsonSerializer),
|
||||
guid);
|
||||
BridgeConnector.Emit("showCertificateTrustDialog", browserWindow, options, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace ElectronNET.API
|
||||
public void SetMenu(MenuItem[] menuItems)
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
BridgeConnector.Emit("dock-setMenu", JArray.FromObject(menuItems, _jsonSerializer));
|
||||
BridgeConnector.Emit("dock-setMenu", menuItems);
|
||||
_items.AddRange(menuItems);
|
||||
|
||||
BridgeConnector.Off("dockMenuItemClicked");
|
||||
@@ -153,25 +153,7 @@ namespace ElectronNET.API
|
||||
/// TODO: Menu (macOS) still to be implemented
|
||||
/// Gets the application's dock menu.
|
||||
/// </summary>
|
||||
public async Task<Menu> GetMenu(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<Menu>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using (cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()))
|
||||
{
|
||||
BridgeConnector.On<Menu>("dock-getMenu-completed", (menu) =>
|
||||
{
|
||||
BridgeConnector.Off("dock-getMenu-completed");
|
||||
taskCompletionSource.SetResult(menu);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("dock-getMenu");
|
||||
|
||||
return await taskCompletionSource.Task
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public Task<Menu> GetMenu(CancellationToken cancellationToken = default) => BridgeConnector.OnResult<Menu>("dock-getMenu", "dock-getMenu-completed", cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the image associated with this dock icon.
|
||||
@@ -181,11 +163,5 @@ namespace ElectronNET.API
|
||||
{
|
||||
BridgeConnector.Emit("dock-setIcon", image);
|
||||
}
|
||||
|
||||
private static readonly JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,8 @@ This package contains the API to access the "native" electron API.</Description>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="SocketIOClient" Version="2.2.4" />
|
||||
<PackageReference Include="SocketIOClient.Newtonsoft.Json" Version="2.2.1" />
|
||||
<PackageReference Include="SocketIOClient" Version="2.3.1" />
|
||||
<PackageReference Include="SocketIOClient.Newtonsoft.Json" Version="2.3.1" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -68,21 +68,8 @@ namespace ElectronNET.API
|
||||
/// since they don’t want applications to fight for global shortcuts.
|
||||
/// </summary>
|
||||
/// <returns>Whether this application has registered accelerator.</returns>
|
||||
public Task<bool> IsRegisteredAsync(string accelerator)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<bool>("globalShortcut-isRegisteredCompleted" + accelerator.GetHashCode(), (isRegistered) =>
|
||||
{
|
||||
BridgeConnector.Off("globalShortcut-isRegisteredCompleted" + accelerator.GetHashCode());
|
||||
public Task<bool> IsRegisteredAsync(string accelerator) => BridgeConnector.OnResult<bool>("globalShortcut-isRegistered", "globalShortcut-isRegisteredCompleted", accelerator);
|
||||
|
||||
taskCompletionSource.SetResult(isRegistered);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("globalShortcut-isRegistered", accelerator);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregisters the global shortcut of accelerator.
|
||||
|
||||
@@ -86,12 +86,5 @@ namespace ElectronNET.API
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace ElectronNET.API
|
||||
menuItems.AddMenuItemsId();
|
||||
menuItems.AddSubmenuTypes();
|
||||
|
||||
BridgeConnector.Emit("menu-setApplicationMenu", JArray.FromObject(menuItems, _jsonSerializer));
|
||||
BridgeConnector.Emit("menu-setApplicationMenu", menuItems);
|
||||
_menuItems.AddRange(menuItems);
|
||||
|
||||
BridgeConnector.Off("menuItemClicked");
|
||||
@@ -87,7 +87,7 @@ namespace ElectronNET.API
|
||||
menuItems.AddMenuItemsId();
|
||||
menuItems.AddSubmenuTypes();
|
||||
|
||||
BridgeConnector.Emit("menu-setContextMenu", browserWindow.Id, JArray.FromObject(menuItems, _jsonSerializer));
|
||||
BridgeConnector.Emit("menu-setContextMenu", browserWindow.Id, menuItems);
|
||||
|
||||
if (!_contextMenuItems.ContainsKey(browserWindow.Id))
|
||||
{
|
||||
@@ -112,11 +112,5 @@ namespace ElectronNET.API
|
||||
{
|
||||
BridgeConnector.Emit("menu-contextMenuPopup", browserWindow.Id);
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,51 +101,26 @@ namespace ElectronNET.API
|
||||
/// A <see cref="ThemeSourceMode"/> property that can be <see cref="ThemeSourceMode.System"/>, <see cref="ThemeSourceMode.Light"/> or <see cref="ThemeSourceMode.Dark"/>. It is used to override (<seealso cref="SetThemeSource"/>) and
|
||||
/// supercede the value that Chromium has chosen to use internally.
|
||||
/// </summary>
|
||||
public Task<ThemeSourceMode> GetThemeSourceAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<ThemeSourceMode>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<string>("nativeTheme-themeSource-getCompleted", (themeSource) =>
|
||||
{
|
||||
BridgeConnector.Off("nativeTheme-themeSource-getCompleted");
|
||||
|
||||
var themeSourceValue = Enum.Parse<ThemeSourceMode>(themeSource, true);
|
||||
|
||||
taskCompletionSource.SetResult(themeSourceValue);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("nativeTheme-themeSource-get");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public async Task<ThemeSourceMode> GetThemeSourceAsync() => Enum.Parse<ThemeSourceMode>(await BridgeConnector.OnResult<string>("nativeTheme-themeSource-get", "nativeTheme-themeSource-getCompleted"), true);
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="bool"/> for if the OS / Chromium currently has a dark mode enabled or is
|
||||
/// being instructed to show a dark-style UI. If you want to modify this value you
|
||||
/// should use <see cref="SetThemeSource"/>.
|
||||
/// </summary>
|
||||
public Task<bool> ShouldUseDarkColorsAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("nativeTheme-shouldUseDarkColors", "nativeTheme-shouldUseDarkColors-completed");
|
||||
}
|
||||
public Task<bool> ShouldUseDarkColorsAsync() => BridgeConnector.OnResult<bool>("nativeTheme-shouldUseDarkColors", "nativeTheme-shouldUseDarkColors-completed");
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="bool"/> for if the OS / Chromium currently has high-contrast mode enabled or is
|
||||
/// being instructed to show a high-contrast UI.
|
||||
/// </summary>
|
||||
public Task<bool> ShouldUseHighContrastColorsAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("nativeTheme-shouldUseHighContrastColors", "nativeTheme-shouldUseHighContrastColors-completed");
|
||||
}
|
||||
public Task<bool> ShouldUseHighContrastColorsAsync() => BridgeConnector.OnResult<bool>("nativeTheme-shouldUseHighContrastColors", "nativeTheme-shouldUseHighContrastColors-completed");
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="bool"/> for if the OS / Chromium currently has an inverted color scheme or is
|
||||
/// being instructed to use an inverted color scheme.
|
||||
/// </summary>
|
||||
public Task<bool> ShouldUseInvertedColorSchemeAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("nativeTheme-shouldUseInvertedColorScheme", "nativeTheme-shouldUseInvertedColorScheme-completed");
|
||||
}
|
||||
public Task<bool> ShouldUseInvertedColorSchemeAsync() => BridgeConnector.OnResult<bool>("nativeTheme-shouldUseInvertedColorScheme", "nativeTheme-shouldUseInvertedColorScheme-completed");
|
||||
|
||||
/// <summary>
|
||||
/// Emitted when something in the underlying NativeTheme has changed. This normally means that either the value of <see cref="ShouldUseDarkColorsAsync"/>,
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace ElectronNET.API
|
||||
{
|
||||
GenerateIDsForDefinedActions(notificationOptions);
|
||||
|
||||
BridgeConnector.Emit("createNotification", JObject.FromObject(notificationOptions, _jsonSerializer));
|
||||
BridgeConnector.Emit("createNotification", notificationOptions);
|
||||
}
|
||||
|
||||
private static void GenerateIDsForDefinedActions(NotificationOptions notificationOptions)
|
||||
@@ -134,12 +134,5 @@ namespace ElectronNET.API
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,128 +129,38 @@ namespace ElectronNET.API
|
||||
/// The current absolute position of the mouse pointer.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<Point> GetCursorScreenPointAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Point>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<Point>("screen-getCursorScreenPointCompleted", (point) =>
|
||||
{
|
||||
BridgeConnector.Off("screen-getCursorScreenPointCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(point);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("screen-getCursorScreenPoint");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<Point> GetCursorScreenPointAsync() => BridgeConnector.OnResult<Point>("screen-getCursorScreenPoint", "screen-getCursorScreenPointCompleted");
|
||||
|
||||
/// <summary>
|
||||
/// macOS: The height of the menu bar in pixels.
|
||||
/// </summary>
|
||||
/// <returns>The height of the menu bar in pixels.</returns>
|
||||
public Task<int> GetMenuBarHeightAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<int>("screen-getMenuBarHeightCompleted", (height) =>
|
||||
{
|
||||
BridgeConnector.Off("screen-getMenuBarHeightCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(height);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("screen-getMenuBarHeight");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<int> GetMenuBarHeightAsync() => BridgeConnector.OnResult<int>("screen-getMenuBarHeight", "screen-getMenuBarHeightCompleted");
|
||||
|
||||
/// <summary>
|
||||
/// The primary display.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<Display> GetPrimaryDisplayAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Display>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
public Task<Display> GetPrimaryDisplayAsync() => BridgeConnector.OnResult<Display>("screen-getPrimaryDisplay", "screen-getPrimaryDisplayCompleted");
|
||||
|
||||
BridgeConnector.On<Display>("screen-getPrimaryDisplayCompleted", (display) =>
|
||||
{
|
||||
BridgeConnector.Off("screen-getPrimaryDisplayCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(display);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("screen-getPrimaryDisplay");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An array of displays that are currently available.
|
||||
/// </summary>
|
||||
/// <returns>An array of displays that are currently available.</returns>
|
||||
public Task<Display[]> GetAllDisplaysAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Display[]>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<Display[]>("screen-getAllDisplaysCompleted", (displays) =>
|
||||
{
|
||||
BridgeConnector.Off("screen-getAllDisplaysCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(displays);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("screen-getAllDisplays");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<Display[]> GetAllDisplaysAsync() => BridgeConnector.OnResult<Display[]>("screen-getAllDisplays", "screen-getAllDisplaysCompleted");
|
||||
|
||||
/// <summary>
|
||||
/// The display nearest the specified point.
|
||||
/// </summary>
|
||||
/// <returns>The display nearest the specified point.</returns>
|
||||
public Task<Display> GetDisplayNearestPointAsync(Point point)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Display>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<Display>("screen-getDisplayNearestPointCompleted", (display) =>
|
||||
{
|
||||
BridgeConnector.Off("screen-getDisplayNearestPointCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(display);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("screen-getDisplayNearestPoint", JObject.FromObject(point, _jsonSerializer));
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
public Task<Display> GetDisplayNearestPointAsync(Point point) => BridgeConnector.OnResult<Display>("screen-getDisplayNearestPoint", "screen-getDisplayNearestPointCompleted", point);
|
||||
|
||||
/// <summary>
|
||||
/// The display that most closely intersects the provided bounds.
|
||||
/// </summary>
|
||||
/// <param name="rectangle"></param>
|
||||
/// <returns>The display that most closely intersects the provided bounds.</returns>
|
||||
public Task<Display> GetDisplayMatchingAsync(Rectangle rectangle)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<Display>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<Display>("screen-getDisplayMatching", (display) =>
|
||||
{
|
||||
BridgeConnector.Off("screen-getDisplayMatching");
|
||||
|
||||
taskCompletionSource.SetResult(display);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("screen-getDisplayMatching", JObject.FromObject(rectangle, _jsonSerializer));
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
public Task<Display> GetDisplayMatchingAsync(Rectangle rectangle) => BridgeConnector.OnResult<Display>("screen-getDisplayMatching", "screen-getDisplayMatchingCompleted", rectangle);
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("webContents-session-clearAuthCache", Id, JObject.FromObject(options, _jsonSerializer), guid);
|
||||
BridgeConnector.Emit("webContents-session-clearAuthCache", Id, options, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("webContents-session-clearStorageData-options", Id, JObject.FromObject(options, _jsonSerializer), guid);
|
||||
BridgeConnector.Emit("webContents-session-clearStorageData-options", Id, options, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public void CreateInterruptedDownload(CreateInterruptedDownloadOptions options)
|
||||
{
|
||||
BridgeConnector.Emit("webContents-session-createInterruptedDownload", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Emit("webContents-session-createInterruptedDownload", Id, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -189,7 +189,7 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public void EnableNetworkEmulation(EnableNetworkEmulationOptions options)
|
||||
{
|
||||
BridgeConnector.Emit("webContents-session-enableNetworkEmulation", Id, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Emit("webContents-session-enableNetworkEmulation", Id, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -340,7 +340,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(null);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("webContents-session-setProxy", Id, JObject.FromObject(config, _jsonSerializer), guid);
|
||||
BridgeConnector.Emit("webContents-session-setProxy", Id, config, guid);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -444,12 +444,5 @@ namespace ElectronNET.API
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace ElectronNET.API
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Emit("shell-openExternal", url, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Emit("shell-openExternal", url, options);
|
||||
}
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
@@ -143,7 +143,7 @@ namespace ElectronNET.API
|
||||
/// <returns>Whether the shortcut was created successfully.</returns>
|
||||
public Task<bool> WriteShortcutLinkAsync(string shortcutPath, ShortcutLinkOperation operation, ShortcutDetails options)
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("shell-writeShortcutLink", "shell-writeShortcutLinkCompleted", shortcutPath, operation.GetDescription(), JObject.FromObject(options, _jsonSerializer));
|
||||
return BridgeConnector.OnResult<bool>("shell-writeShortcutLink", "shell-writeShortcutLinkCompleted", shortcutPath, operation.GetDescription(), options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -156,12 +156,5 @@ namespace ElectronNET.API
|
||||
{
|
||||
return BridgeConnector.OnResult<ShortcutDetails>("shell-readShortcutLink", "shell-readShortcutLinkCompleted", shortcutPath);
|
||||
}
|
||||
|
||||
private readonly JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace ElectronNET.API
|
||||
public void Show(string image, MenuItem[] menuItems)
|
||||
{
|
||||
menuItems.AddMenuItemsId();
|
||||
BridgeConnector.Emit("create-tray", image, JArray.FromObject(menuItems, _jsonSerializer));
|
||||
BridgeConnector.Emit("create-tray", image, menuItems);
|
||||
_items.Clear();
|
||||
_items.AddRange(menuItems);
|
||||
|
||||
@@ -314,34 +314,14 @@ namespace ElectronNET.API
|
||||
/// <param name="options"></param>
|
||||
public void DisplayBalloon(DisplayBalloonOptions options)
|
||||
{
|
||||
BridgeConnector.Emit("tray-displayBalloon", JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Emit("tray-displayBalloon", options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the tray icon is destroyed.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> IsDestroyedAsync()
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
BridgeConnector.On<bool>("tray-isDestroyedCompleted", (isDestroyed) =>
|
||||
{
|
||||
BridgeConnector.Off("tray-isDestroyedCompleted");
|
||||
|
||||
taskCompletionSource.SetResult(isDestroyed);
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("tray-isDestroyed");
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
public Task<bool> IsDestroyedAsync() => BridgeConnector.OnResult<bool>("tray-isDestroyed", "tray-isDestroyedCompleted");
|
||||
|
||||
private const string ModuleName = "tray";
|
||||
/// <summary>
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace ElectronNET.API
|
||||
/// <param name="openDevToolsOptions"></param>
|
||||
public void OpenDevTools(OpenDevToolsOptions openDevToolsOptions)
|
||||
{
|
||||
BridgeConnector.Emit("webContentsOpenDevTools", Id, JObject.FromObject(openDevToolsOptions, _jsonSerializer));
|
||||
BridgeConnector.Emit("webContentsOpenDevTools", Id, openDevToolsOptions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -113,7 +113,7 @@ namespace ElectronNET.API
|
||||
/// <returns>printers</returns>
|
||||
public Task<PrinterInfo[]> GetPrintersAsync()
|
||||
{
|
||||
return BridgeConnector.OnResult<PrinterInfo[]>("webContents-getPrinters", "webContents-getPrinters-completed", Id);
|
||||
return BridgeConnector.OnResult<PrinterInfo[]>("webContents-getPrinters", "webContents-getPrinters-completed" + Id, Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -121,10 +121,8 @@ namespace ElectronNET.API
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns>success</returns>
|
||||
public Task<bool> PrintAsync(PrintOptions options = null)
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("webContents-print", "webContents-print-completed", Id, options is null ? (object)"" : JObject.FromObject(options, _jsonSerializer));
|
||||
}
|
||||
public Task<bool> PrintAsync(PrintOptions options = null) => options is null ? BridgeConnector.OnResult<bool>("webContents-print", "webContents-print-completed" + Id, Id, "")
|
||||
: BridgeConnector.OnResult<bool>("webContents-print", "webContents-print-completed" + Id, Id, options);
|
||||
|
||||
/// <summary>
|
||||
/// Prints window's web page as PDF with Chromium's preview printing custom
|
||||
@@ -135,10 +133,8 @@ namespace ElectronNET.API
|
||||
/// <param name="path"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns>success</returns>
|
||||
public Task<bool> PrintToPDFAsync(string path, PrintToPDFOptions options = null)
|
||||
{
|
||||
return BridgeConnector.OnResult<bool>("webContents-printToPDF", "webContents-printToPDF-completed", Id, options is null ? (object)"" : JObject.FromObject(options, _jsonSerializer), path);
|
||||
}
|
||||
public Task<bool> PrintToPDFAsync(string path, PrintToPDFOptions options = null) => options is null ? BridgeConnector.OnResult<bool>("webContents-printToPDF", "webContents-printToPDF-completed" + Id, Id, "", path)
|
||||
: BridgeConnector.OnResult<bool>("webContents-printToPDF", "webContents-printToPDF-completed" + Id, Id, options, path);
|
||||
|
||||
/// <summary>
|
||||
/// Is used to get the Url of the loaded page.
|
||||
@@ -198,7 +194,7 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetException(new InvalidOperationException(error.ToString()));
|
||||
});
|
||||
|
||||
BridgeConnector.Emit("webContents-loadURL", Id, url, JObject.FromObject(options, _jsonSerializer));
|
||||
BridgeConnector.Emit("webContents-loadURL", Id, url, options);
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
@@ -214,12 +210,5 @@ namespace ElectronNET.API
|
||||
{
|
||||
BridgeConnector.Emit("webContents-insertCSS", Id, isBrowserWindow, path);
|
||||
}
|
||||
|
||||
private static readonly JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ namespace ElectronNET.API
|
||||
options.X = 0;
|
||||
options.Y = 0;
|
||||
|
||||
BridgeConnector.Emit("createBrowserWindow", JObject.FromObject(options, _jsonSerializer), loadUrl);
|
||||
BridgeConnector.Emit("createBrowserWindow", options, loadUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -194,21 +194,15 @@ namespace ElectronNET.API
|
||||
taskCompletionSource.SetResult(browserView);
|
||||
});
|
||||
|
||||
var ownjsonSerializer = new JsonSerializer()
|
||||
var keepDefaultValuesSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Include
|
||||
};
|
||||
BridgeConnector.Emit("createBrowserView", JObject.FromObject(options, ownjsonSerializer));
|
||||
BridgeConnector.Emit("createBrowserView", JObject.FromObject(options, keepDefaultValuesSerializer));
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
}
|
||||
|
||||
private JsonSerializer _jsonSerializer = new JsonSerializer()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ const browserViewApi = (socket) => {
|
||||
});
|
||||
socket.on('browserView-getBounds', (id) => {
|
||||
const bounds = getBrowserViewById(id).getBounds();
|
||||
electronSocket.emit('browserView-getBounds-reply', bounds);
|
||||
electronSocket.emit('browserView-getBounds-reply' + id, bounds);
|
||||
});
|
||||
socket.on('browserView-setBounds', (id, bounds) => {
|
||||
getBrowserViewById(id).setBounds(bounds);
|
||||
|
||||
@@ -31,7 +31,7 @@ const browserViewApi = (socket: Socket) => {
|
||||
socket.on('browserView-getBounds', (id) => {
|
||||
const bounds = getBrowserViewById(id).getBounds();
|
||||
|
||||
electronSocket.emit('browserView-getBounds-reply', bounds);
|
||||
electronSocket.emit('browserView-getBounds-reply' + id, bounds);
|
||||
});
|
||||
|
||||
socket.on('browserView-setBounds', (id, bounds) => {
|
||||
|
||||
@@ -25,153 +25,153 @@ module.exports = (socket, app) => {
|
||||
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== id);
|
||||
electronSocket.emit('browserWindow-ready-to-show' + id);
|
||||
}
|
||||
getWindowById(id).on('ready-to-show', () => {
|
||||
getWindowById(id)?.on('ready-to-show', () => {
|
||||
readyToShowWindowsIds.push(id);
|
||||
electronSocket.emit('browserWindow-ready-to-show' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-page-title-updated', (id) => {
|
||||
getWindowById(id).on('page-title-updated', (event, title) => {
|
||||
getWindowById(id)?.on('page-title-updated', (event, title) => {
|
||||
electronSocket.emit('browserWindow-page-title-updated' + id, title);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-close', (id) => {
|
||||
getWindowById(id).on('close', () => {
|
||||
getWindowById(id)?.on('close', () => {
|
||||
electronSocket.emit('browserWindow-close' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-closed', (id) => {
|
||||
getWindowById(id).on('closed', () => {
|
||||
getWindowById(id)?.on('closed', () => {
|
||||
electronSocket.emit('browserWindow-closed' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-session-end', (id) => {
|
||||
getWindowById(id).on('session-end', () => {
|
||||
getWindowById(id)?.on('session-end', () => {
|
||||
electronSocket.emit('browserWindow-session-end' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-unresponsive', (id) => {
|
||||
getWindowById(id).on('unresponsive', () => {
|
||||
getWindowById(id)?.on('unresponsive', () => {
|
||||
electronSocket.emit('browserWindow-unresponsive' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-responsive', (id) => {
|
||||
getWindowById(id).on('responsive', () => {
|
||||
getWindowById(id)?.on('responsive', () => {
|
||||
electronSocket.emit('browserWindow-responsive' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-blur', (id) => {
|
||||
getWindowById(id).on('blur', () => {
|
||||
getWindowById(id)?.on('blur', () => {
|
||||
electronSocket.emit('browserWindow-blur' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-focus', (id) => {
|
||||
getWindowById(id).on('focus', () => {
|
||||
getWindowById(id)?.on('focus', () => {
|
||||
electronSocket.emit('browserWindow-focus' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-show', (id) => {
|
||||
getWindowById(id).on('show', () => {
|
||||
getWindowById(id)?.on('show', () => {
|
||||
electronSocket.emit('browserWindow-show' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-hide', (id) => {
|
||||
getWindowById(id).on('hide', () => {
|
||||
getWindowById(id)?.on('hide', () => {
|
||||
electronSocket.emit('browserWindow-hide' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-maximize', (id) => {
|
||||
getWindowById(id).on('maximize', () => {
|
||||
getWindowById(id)?.on('maximize', () => {
|
||||
electronSocket.emit('browserWindow-maximize' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-unmaximize', (id) => {
|
||||
getWindowById(id).on('unmaximize', () => {
|
||||
getWindowById(id)?.on('unmaximize', () => {
|
||||
electronSocket.emit('browserWindow-unmaximize' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-minimize', (id) => {
|
||||
getWindowById(id).on('minimize', () => {
|
||||
getWindowById(id)?.on('minimize', () => {
|
||||
electronSocket.emit('browserWindow-minimize' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-restore', (id) => {
|
||||
getWindowById(id).on('restore', () => {
|
||||
getWindowById(id)?.on('restore', () => {
|
||||
electronSocket.emit('browserWindow-restore' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-resize', (id) => {
|
||||
getWindowById(id).on('resize', () => {
|
||||
getWindowById(id)?.on('resize', () => {
|
||||
electronSocket.emit('browserWindow-resize' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-move', (id) => {
|
||||
getWindowById(id).on('move', () => {
|
||||
getWindowById(id)?.on('move', () => {
|
||||
electronSocket.emit('browserWindow-move' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-moved', (id) => {
|
||||
getWindowById(id).on('moved', () => {
|
||||
getWindowById(id)?.on('moved', () => {
|
||||
electronSocket.emit('browserWindow-moved' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-enter-full-screen', (id) => {
|
||||
getWindowById(id).on('enter-full-screen', () => {
|
||||
getWindowById(id)?.on('enter-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-enter-full-screen' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-leave-full-screen', (id) => {
|
||||
getWindowById(id).on('leave-full-screen', () => {
|
||||
getWindowById(id)?.on('leave-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-leave-full-screen' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-enter-html-full-screen', (id) => {
|
||||
getWindowById(id).on('enter-html-full-screen', () => {
|
||||
getWindowById(id)?.on('enter-html-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-enter-html-full-screen' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-leave-html-full-screen', (id) => {
|
||||
getWindowById(id).on('leave-html-full-screen', () => {
|
||||
getWindowById(id)?.on('leave-html-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-leave-html-full-screen' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-app-command', (id) => {
|
||||
getWindowById(id).on('app-command', (event, command) => {
|
||||
getWindowById(id)?.on('app-command', (event, command) => {
|
||||
electronSocket.emit('browserWindow-app-command' + id, command);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-scroll-touch-begin', (id) => {
|
||||
getWindowById(id).on('scroll-touch-begin', () => {
|
||||
getWindowById(id)?.on('scroll-touch-begin', () => {
|
||||
electronSocket.emit('browserWindow-scroll-touch-begin' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-scroll-touch-end', (id) => {
|
||||
getWindowById(id).on('scroll-touch-end', () => {
|
||||
getWindowById(id)?.on('scroll-touch-end', () => {
|
||||
electronSocket.emit('browserWindow-scroll-touch-end' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-scroll-touch-edge', (id) => {
|
||||
getWindowById(id).on('scroll-touch-edge', () => {
|
||||
getWindowById(id)?.on('scroll-touch-edge', () => {
|
||||
electronSocket.emit('browserWindow-scroll-touch-edge' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-swipe', (id) => {
|
||||
getWindowById(id).on('swipe', (event, direction) => {
|
||||
getWindowById(id)?.on('swipe', (event, direction) => {
|
||||
electronSocket.emit('browserWindow-swipe' + id, direction);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-sheet-begin', (id) => {
|
||||
getWindowById(id).on('sheet-begin', () => {
|
||||
getWindowById(id)?.on('sheet-begin', () => {
|
||||
electronSocket.emit('browserWindow-sheet-begin' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-sheet-end', (id) => {
|
||||
getWindowById(id).on('sheet-end', () => {
|
||||
getWindowById(id)?.on('sheet-end', () => {
|
||||
electronSocket.emit('browserWindow-sheet-end' + id);
|
||||
});
|
||||
});
|
||||
socket.on('register-browserWindow-new-window-for-tab', (id) => {
|
||||
getWindowById(id).on('new-window-for-tab', () => {
|
||||
getWindowById(id)?.on('new-window-for-tab', () => {
|
||||
electronSocket.emit('browserWindow-new-window-for-tab' + id);
|
||||
});
|
||||
});
|
||||
@@ -202,6 +202,15 @@ module.exports = (socket, app) => {
|
||||
proxyToCredentialsMap[options.proxy] = options.proxyCredentials;
|
||||
}
|
||||
window.on('ready-to-show', () => {
|
||||
try {
|
||||
window.id;
|
||||
}
|
||||
catch (error) {
|
||||
if (error.message === 'Object has been destroyed') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (readyToShowWindowsIds.includes(window.id)) {
|
||||
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== window.id);
|
||||
}
|
||||
@@ -250,239 +259,244 @@ module.exports = (socket, app) => {
|
||||
electronSocket.emit('BrowserWindowCreated', window.id);
|
||||
});
|
||||
socket.on('browserWindowDestroy', (id) => {
|
||||
getWindowById(id).destroy();
|
||||
getWindowById(id)?.destroy();
|
||||
});
|
||||
socket.on('browserWindowClose', (id) => {
|
||||
getWindowById(id).close();
|
||||
getWindowById(id)?.close();
|
||||
});
|
||||
socket.on('browserWindowFocus', (id) => {
|
||||
getWindowById(id).focus();
|
||||
getWindowById(id)?.focus();
|
||||
});
|
||||
socket.on('browserWindowBlur', (id) => {
|
||||
getWindowById(id).blur();
|
||||
getWindowById(id)?.blur();
|
||||
});
|
||||
socket.on('browserWindowIsFocused', (id) => {
|
||||
const isFocused = getWindowById(id).isFocused();
|
||||
electronSocket.emit('browserWindow-isFocused-completed', isFocused);
|
||||
const isFocused = getWindowById(id)?.isFocused() ?? null;
|
||||
electronSocket.emit('browserWindow-isFocused-completed' + id, isFocused);
|
||||
});
|
||||
socket.on('browserWindowIsDestroyed', (id) => {
|
||||
const isDestroyed = getWindowById(id).isDestroyed();
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed', isDestroyed);
|
||||
const w = getWindowById(id);
|
||||
if (w) {
|
||||
const isDestroyed = w.isDestroyed();
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed' + id, isDestroyed);
|
||||
} else {
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed' + id, true);
|
||||
}
|
||||
});
|
||||
socket.on('browserWindowShow', (id) => {
|
||||
getWindowById(id).show();
|
||||
getWindowById(id)?.show();
|
||||
});
|
||||
socket.on('browserWindowShowInactive', (id) => {
|
||||
getWindowById(id).showInactive();
|
||||
getWindowById(id)?.showInactive();
|
||||
});
|
||||
socket.on('browserWindowHide', (id) => {
|
||||
getWindowById(id).hide();
|
||||
getWindowById(id)?.hide();
|
||||
});
|
||||
socket.on('browserWindowIsVisible', (id) => {
|
||||
const isVisible = getWindowById(id).isVisible();
|
||||
electronSocket.emit('browserWindow-isVisible-completed', isVisible);
|
||||
const isVisible = getWindowById(id)?.isVisible() ?? null;
|
||||
electronSocket.emit('browserWindow-isVisible-completed' + id, isVisible);
|
||||
});
|
||||
socket.on('browserWindowIsModal', (id) => {
|
||||
const isModal = getWindowById(id).isModal();
|
||||
electronSocket.emit('browserWindow-isModal-completed', isModal);
|
||||
const isModal = getWindowById(id)?.isModal() ?? null;
|
||||
electronSocket.emit('browserWindow-isModal-completed' + id, isModal);
|
||||
});
|
||||
socket.on('browserWindowMaximize', (id) => {
|
||||
getWindowById(id).maximize();
|
||||
getWindowById(id)?.maximize();
|
||||
});
|
||||
socket.on('browserWindowUnmaximize', (id) => {
|
||||
getWindowById(id).unmaximize();
|
||||
getWindowById(id)?.unmaximize();
|
||||
});
|
||||
socket.on('browserWindowIsMaximized', (id) => {
|
||||
const isMaximized = getWindowById(id).isMaximized();
|
||||
electronSocket.emit('browserWindow-isMaximized-completed', isMaximized);
|
||||
const isMaximized = getWindowById(id)?.isMaximized() ?? null;
|
||||
electronSocket.emit('browserWindow-isMaximized-completed' + id, isMaximized);
|
||||
});
|
||||
socket.on('browserWindowMinimize', (id) => {
|
||||
getWindowById(id).minimize();
|
||||
getWindowById(id)?.minimize();
|
||||
});
|
||||
socket.on('browserWindowRestore', (id) => {
|
||||
getWindowById(id).restore();
|
||||
getWindowById(id)?.restore();
|
||||
});
|
||||
socket.on('browserWindowIsMinimized', (id) => {
|
||||
const isMinimized = getWindowById(id).isMinimized();
|
||||
electronSocket.emit('browserWindow-isMinimized-completed', isMinimized);
|
||||
const isMinimized = getWindowById(id)?.isMinimized() ?? null;
|
||||
electronSocket.emit('browserWindow-isMinimized-completed' + id, isMinimized);
|
||||
});
|
||||
socket.on('browserWindowSetFullScreen', (id, fullscreen) => {
|
||||
getWindowById(id).setFullScreen(fullscreen);
|
||||
getWindowById(id)?.setFullScreen(fullscreen);
|
||||
});
|
||||
socket.on('browserWindowIsFullScreen', (id) => {
|
||||
const isFullScreen = getWindowById(id).isFullScreen();
|
||||
electronSocket.emit('browserWindow-isFullScreen-completed', isFullScreen);
|
||||
const isFullScreen = getWindowById(id)?.isFullScreen() ?? null;
|
||||
electronSocket.emit('browserWindow-isFullScreen-completed' + id, isFullScreen);
|
||||
});
|
||||
socket.on('browserWindowSetAspectRatio', (id, aspectRatio, extraSize) => {
|
||||
getWindowById(id).setAspectRatio(aspectRatio, extraSize);
|
||||
getWindowById(id)?.setAspectRatio(aspectRatio, extraSize);
|
||||
});
|
||||
socket.on('browserWindowPreviewFile', (id, path, displayname) => {
|
||||
getWindowById(id).previewFile(path, displayname);
|
||||
getWindowById(id)?.previewFile(path, displayname);
|
||||
});
|
||||
socket.on('browserWindowCloseFilePreview', (id) => {
|
||||
getWindowById(id).closeFilePreview();
|
||||
getWindowById(id)?.closeFilePreview();
|
||||
});
|
||||
socket.on('browserWindowSetBounds', (id, bounds, animate) => {
|
||||
getWindowById(id).setBounds(bounds, animate);
|
||||
getWindowById(id)?.setBounds(bounds, animate);
|
||||
});
|
||||
socket.on('browserWindowGetBounds', (id) => {
|
||||
const rectangle = getWindowById(id).getBounds();
|
||||
electronSocket.emit('browserWindow-getBounds-completed', rectangle);
|
||||
const rectangle = getWindowById(id)?.getBounds() ?? null;
|
||||
electronSocket.emit('browserWindow-getBounds-completed' + id, rectangle);
|
||||
});
|
||||
socket.on('browserWindowSetContentBounds', (id, bounds, animate) => {
|
||||
getWindowById(id).setContentBounds(bounds, animate);
|
||||
getWindowById(id)?.setContentBounds(bounds, animate);
|
||||
});
|
||||
socket.on('browserWindowGetContentBounds', (id) => {
|
||||
const rectangle = getWindowById(id).getContentBounds();
|
||||
electronSocket.emit('browserWindow-getContentBounds-completed', rectangle);
|
||||
const rectangle = getWindowById(id)?.getContentBounds() ?? null;
|
||||
electronSocket.emit('browserWindow-getContentBounds-completed' + id, rectangle);
|
||||
});
|
||||
socket.on('browserWindowSetSize', (id, width, height, animate) => {
|
||||
getWindowById(id).setSize(width, height, animate);
|
||||
getWindowById(id)?.setSize(width, height, animate);
|
||||
});
|
||||
socket.on('browserWindowGetSize', (id) => {
|
||||
const size = getWindowById(id).getSize();
|
||||
electronSocket.emit('browserWindow-getSize-completed', size);
|
||||
const size = getWindowById(id)?.getSize() ?? null;
|
||||
electronSocket.emit('browserWindow-getSize-completed' + id, size);
|
||||
});
|
||||
socket.on('browserWindowSetContentSize', (id, width, height, animate) => {
|
||||
getWindowById(id).setContentSize(width, height, animate);
|
||||
getWindowById(id)?.setContentSize(width, height, animate);
|
||||
});
|
||||
socket.on('browserWindowGetContentSize', (id) => {
|
||||
const size = getWindowById(id).getContentSize();
|
||||
electronSocket.emit('browserWindow-getContentSize-completed', size);
|
||||
const size = getWindowById(id)?.getContentSize() ?? null;
|
||||
electronSocket.emit('browserWindow-getContentSize-completed' + id, size);
|
||||
});
|
||||
socket.on('browserWindowSetMinimumSize', (id, width, height) => {
|
||||
getWindowById(id).setMinimumSize(width, height);
|
||||
getWindowById(id)?.setMinimumSize(width, height);
|
||||
});
|
||||
socket.on('browserWindowGetMinimumSize', (id) => {
|
||||
const size = getWindowById(id).getMinimumSize();
|
||||
electronSocket.emit('browserWindow-getMinimumSize-completed', size);
|
||||
const size = getWindowById(id)?.getMinimumSize() ?? null;
|
||||
electronSocket.emit('browserWindow-getMinimumSize-completed' + id, size);
|
||||
});
|
||||
socket.on('browserWindowSetMaximumSize', (id, width, height) => {
|
||||
getWindowById(id).setMaximumSize(width, height);
|
||||
getWindowById(id)?.setMaximumSize(width, height);
|
||||
});
|
||||
socket.on('browserWindowGetMaximumSize', (id) => {
|
||||
const size = getWindowById(id).getMaximumSize();
|
||||
electronSocket.emit('browserWindow-getMaximumSize-completed', size);
|
||||
const size = getWindowById(id)?.getMaximumSize() ?? null;
|
||||
electronSocket.emit('browserWindow-getMaximumSize-completed' + id, size);
|
||||
});
|
||||
socket.on('browserWindowSetResizable', (id, resizable) => {
|
||||
getWindowById(id).setResizable(resizable);
|
||||
getWindowById(id)?.setResizable(resizable);
|
||||
});
|
||||
socket.on('browserWindowIsResizable', (id) => {
|
||||
const resizable = getWindowById(id).isResizable();
|
||||
electronSocket.emit('browserWindow-isResizable-completed', resizable);
|
||||
const resizable = getWindowById(id)?.isResizable() ?? null;
|
||||
electronSocket.emit('browserWindow-isResizable-completed' + id, resizable);
|
||||
});
|
||||
socket.on('browserWindowSetMovable', (id, movable) => {
|
||||
getWindowById(id).setMovable(movable);
|
||||
getWindowById(id)?.setMovable(movable);
|
||||
});
|
||||
socket.on('browserWindowIsMovable', (id) => {
|
||||
const movable = getWindowById(id).isMovable();
|
||||
electronSocket.emit('browserWindow-isMovable-completed', movable);
|
||||
const movable = getWindowById(id)?.isMovable() ?? null;
|
||||
electronSocket.emit('browserWindow-isMovable-completed' + id, movable);
|
||||
});
|
||||
socket.on('browserWindowSetMinimizable', (id, minimizable) => {
|
||||
getWindowById(id).setMinimizable(minimizable);
|
||||
getWindowById(id)?.setMinimizable(minimizable);
|
||||
});
|
||||
socket.on('browserWindowIsMinimizable', (id) => {
|
||||
const minimizable = getWindowById(id).isMinimizable();
|
||||
electronSocket.emit('browserWindow-isMinimizable-completed', minimizable);
|
||||
const minimizable = getWindowById(id)?.isMinimizable() ?? null;
|
||||
electronSocket.emit('browserWindow-isMinimizable-completed' + id, minimizable);
|
||||
});
|
||||
socket.on('browserWindowSetMaximizable', (id, maximizable) => {
|
||||
getWindowById(id).setMaximizable(maximizable);
|
||||
getWindowById(id)?.setMaximizable(maximizable);
|
||||
});
|
||||
socket.on('browserWindowIsMaximizable', (id) => {
|
||||
const maximizable = getWindowById(id).isMaximizable();
|
||||
electronSocket.emit('browserWindow-isMaximizable-completed', maximizable);
|
||||
const maximizable = getWindowById(id)?.isMaximizable() ?? null;
|
||||
electronSocket.emit('browserWindow-isMaximizable-completed' + id, maximizable);
|
||||
});
|
||||
socket.on('browserWindowSetFullScreenable', (id, fullscreenable) => {
|
||||
getWindowById(id).setFullScreenable(fullscreenable);
|
||||
getWindowById(id)?.setFullScreenable(fullscreenable);
|
||||
});
|
||||
socket.on('browserWindowIsFullScreenable', (id) => {
|
||||
const fullscreenable = getWindowById(id).isFullScreenable();
|
||||
electronSocket.emit('browserWindow-isFullScreenable-completed', fullscreenable);
|
||||
const fullscreenable = getWindowById(id)?.isFullScreenable() ?? null;
|
||||
electronSocket.emit('browserWindow-isFullScreenable-completed' + id, fullscreenable);
|
||||
});
|
||||
socket.on('browserWindowSetClosable', (id, closable) => {
|
||||
getWindowById(id).setClosable(closable);
|
||||
getWindowById(id)?.setClosable(closable);
|
||||
});
|
||||
socket.on('browserWindowIsClosable', (id) => {
|
||||
const closable = getWindowById(id).isClosable();
|
||||
electronSocket.emit('browserWindow-isClosable-completed', closable);
|
||||
const closable = getWindowById(id)?.isClosable() ?? null;
|
||||
electronSocket.emit('browserWindow-isClosable-completed' + id, closable);
|
||||
});
|
||||
socket.on('browserWindowSetAlwaysOnTop', (id, flag, level, relativeLevel) => {
|
||||
getWindowById(id).setAlwaysOnTop(flag, level, relativeLevel);
|
||||
getWindowById(id)?.setAlwaysOnTop(flag, level, relativeLevel);
|
||||
});
|
||||
socket.on('browserWindowIsAlwaysOnTop', (id) => {
|
||||
const isAlwaysOnTop = getWindowById(id).isAlwaysOnTop();
|
||||
electronSocket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop);
|
||||
const isAlwaysOnTop = getWindowById(id)?.isAlwaysOnTop() ?? null;
|
||||
electronSocket.emit('browserWindow-isAlwaysOnTop-completed' + id, isAlwaysOnTop);
|
||||
});
|
||||
socket.on('browserWindowCenter', (id) => {
|
||||
getWindowById(id).center();
|
||||
getWindowById(id)?.center();
|
||||
});
|
||||
socket.on('browserWindowSetPosition', (id, x, y, animate) => {
|
||||
getWindowById(id).setPosition(x, y, animate);
|
||||
getWindowById(id)?.setPosition(x, y, animate);
|
||||
});
|
||||
socket.on('browserWindowGetPosition', (id) => {
|
||||
const position = getWindowById(id).getPosition();
|
||||
electronSocket.emit('browserWindow-getPosition-completed', position);
|
||||
const position = getWindowById(id)?.getPosition() ?? null;
|
||||
electronSocket.emit('browserWindow-getPosition-completed' + id, position);
|
||||
});
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
getWindowById(id).setTitle(title);
|
||||
getWindowById(id)?.setTitle(title);
|
||||
});
|
||||
socket.on('browserWindowGetTitle', (id) => {
|
||||
const title = getWindowById(id).getTitle();
|
||||
electronSocket.emit('browserWindow-getTitle-completed', title);
|
||||
const title = getWindowById(id)?.getTitle() ?? null;
|
||||
electronSocket.emit('browserWindow-getTitle-completed' + id, title);
|
||||
});
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
getWindowById(id).setTitle(title);
|
||||
getWindowById(id)?.setTitle(title);
|
||||
});
|
||||
socket.on('browserWindowSetSheetOffset', (id, offsetY, offsetX) => {
|
||||
if (offsetX) {
|
||||
getWindowById(id).setSheetOffset(offsetY, offsetX);
|
||||
getWindowById(id)?.setSheetOffset(offsetY, offsetX);
|
||||
}
|
||||
else {
|
||||
getWindowById(id).setSheetOffset(offsetY);
|
||||
getWindowById(id)?.setSheetOffset(offsetY);
|
||||
}
|
||||
});
|
||||
socket.on('browserWindowFlashFrame', (id, flag) => {
|
||||
getWindowById(id).flashFrame(flag);
|
||||
getWindowById(id)?.flashFrame(flag);
|
||||
});
|
||||
socket.on('browserWindowSetSkipTaskbar', (id, skip) => {
|
||||
getWindowById(id).setSkipTaskbar(skip);
|
||||
getWindowById(id)?.setSkipTaskbar(skip);
|
||||
});
|
||||
socket.on('browserWindowSetKiosk', (id, flag) => {
|
||||
getWindowById(id).setKiosk(flag);
|
||||
getWindowById(id)?.setKiosk(flag);
|
||||
});
|
||||
socket.on('browserWindowIsKiosk', (id) => {
|
||||
const isKiosk = getWindowById(id).isKiosk();
|
||||
electronSocket.emit('browserWindow-isKiosk-completed', isKiosk);
|
||||
const isKiosk = getWindowById(id)?.isKiosk() ?? null;
|
||||
electronSocket.emit('browserWindow-isKiosk-completed' + id, isKiosk);
|
||||
});
|
||||
socket.on('browserWindowGetNativeWindowHandle', (id) => {
|
||||
const nativeWindowHandle = getWindowById(id).getNativeWindowHandle().readInt32LE(0).toString(16);
|
||||
electronSocket.emit('browserWindow-getNativeWindowHandle-completed', nativeWindowHandle);
|
||||
const nativeWindowHandle = getWindowById(id)?.getNativeWindowHandle()?.readInt32LE(0)?.toString(16) ?? null;
|
||||
electronSocket.emit('browserWindow-getNativeWindowHandle-completed' + id, nativeWindowHandle);
|
||||
});
|
||||
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
|
||||
getWindowById(id).setRepresentedFilename(filename);
|
||||
getWindowById(id)?.setRepresentedFilename(filename);
|
||||
});
|
||||
socket.on('browserWindowGetRepresentedFilename', (id) => {
|
||||
const pathname = getWindowById(id).getRepresentedFilename();
|
||||
electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname);
|
||||
const pathname = getWindowById(id)?.getRepresentedFilename() ?? null;
|
||||
electronSocket.emit('browserWindow-getRepresentedFilename-completed' + id, pathname);
|
||||
});
|
||||
socket.on('browserWindowSetDocumentEdited', (id, edited) => {
|
||||
getWindowById(id).setDocumentEdited(edited);
|
||||
getWindowById(id)?.setDocumentEdited(edited);
|
||||
});
|
||||
socket.on('browserWindowIsDocumentEdited', (id) => {
|
||||
const edited = getWindowById(id).isDocumentEdited();
|
||||
electronSocket.emit('browserWindow-isDocumentEdited-completed', edited);
|
||||
const edited = getWindowById(id)?.isDocumentEdited() ?? null;
|
||||
electronSocket.emit('browserWindow-isDocumentEdited-completed' + id, edited);
|
||||
});
|
||||
socket.on('browserWindowFocusOnWebView', (id) => {
|
||||
getWindowById(id).focusOnWebView();
|
||||
getWindowById(id)?.focusOnWebView();
|
||||
});
|
||||
socket.on('browserWindowBlurWebView', (id) => {
|
||||
getWindowById(id).blurWebView();
|
||||
getWindowById(id)?.blurWebView();
|
||||
});
|
||||
socket.on('browserWindowLoadURL', (id, url, options) => {
|
||||
getWindowById(id).loadURL(url, options);
|
||||
getWindowById(id)?.loadURL(url, options);
|
||||
});
|
||||
socket.on('browserWindowReload', (id) => {
|
||||
getWindowById(id).reload();
|
||||
getWindowById(id)?.reload();
|
||||
});
|
||||
socket.on('browserWindowSetMenu', (id, menuItems) => {
|
||||
let menu = null;
|
||||
@@ -492,10 +506,10 @@ module.exports = (socket, app) => {
|
||||
electronSocket.emit('windowMenuItemClicked', id);
|
||||
});
|
||||
}
|
||||
getWindowById(id).setMenu(menu);
|
||||
getWindowById(id)?.setMenu(menu);
|
||||
});
|
||||
socket.on('browserWindowRemoveMenu', (id) => {
|
||||
getWindowById(id).removeMenu();
|
||||
getWindowById(id)?.removeMenu();
|
||||
});
|
||||
function addMenuItemClickConnector(menuItems, callback) {
|
||||
menuItems.forEach((item) => {
|
||||
@@ -508,17 +522,17 @@ module.exports = (socket, app) => {
|
||||
});
|
||||
}
|
||||
socket.on('browserWindowSetProgressBar', (id, progress) => {
|
||||
getWindowById(id).setProgressBar(progress);
|
||||
getWindowById(id)?.setProgressBar(progress);
|
||||
});
|
||||
socket.on('browserWindowSetProgressBar', (id, progress, options) => {
|
||||
getWindowById(id).setProgressBar(progress, options);
|
||||
getWindowById(id)?.setProgressBar(progress, options);
|
||||
});
|
||||
socket.on('browserWindowSetHasShadow', (id, hasShadow) => {
|
||||
getWindowById(id).setHasShadow(hasShadow);
|
||||
getWindowById(id)?.setHasShadow(hasShadow);
|
||||
});
|
||||
socket.on('browserWindowHasShadow', (id) => {
|
||||
const hasShadow = getWindowById(id).hasShadow();
|
||||
electronSocket.emit('browserWindow-hasShadow-completed', hasShadow);
|
||||
const hasShadow = getWindowById(id)?.hasShadow() ?? null;
|
||||
electronSocket.emit('browserWindow-hasShadow-completed' + id, hasShadow);
|
||||
});
|
||||
socket.on('browserWindowSetThumbarButtons', (id, thumbarButtons) => {
|
||||
thumbarButtons.forEach(thumbarButton => {
|
||||
@@ -528,75 +542,75 @@ module.exports = (socket, app) => {
|
||||
electronSocket.emit('thumbarButtonClicked', thumbarButton['id']);
|
||||
};
|
||||
});
|
||||
const success = getWindowById(id).setThumbarButtons(thumbarButtons);
|
||||
electronSocket.emit('browserWindowSetThumbarButtons-completed', success);
|
||||
const success = getWindowById(id)?.setThumbarButtons(thumbarButtons) ?? null;
|
||||
electronSocket.emit('browserWindowSetThumbarButtons-completed' + id, success);
|
||||
});
|
||||
socket.on('browserWindowSetThumbnailClip', (id, rectangle) => {
|
||||
getWindowById(id).setThumbnailClip(rectangle);
|
||||
getWindowById(id)?.setThumbnailClip(rectangle);
|
||||
});
|
||||
socket.on('browserWindowSetThumbnailToolTip', (id, toolTip) => {
|
||||
getWindowById(id).setThumbnailToolTip(toolTip);
|
||||
getWindowById(id)?.setThumbnailToolTip(toolTip);
|
||||
});
|
||||
socket.on('browserWindowSetAppDetails', (id, options) => {
|
||||
getWindowById(id).setAppDetails(options);
|
||||
getWindowById(id)?.setAppDetails(options);
|
||||
});
|
||||
socket.on('browserWindowShowDefinitionForSelection', (id) => {
|
||||
getWindowById(id).showDefinitionForSelection();
|
||||
getWindowById(id)?.showDefinitionForSelection();
|
||||
});
|
||||
socket.on('browserWindowSetAutoHideMenuBar', (id, hide) => {
|
||||
getWindowById(id).setAutoHideMenuBar(hide);
|
||||
getWindowById(id)?.setAutoHideMenuBar(hide);
|
||||
});
|
||||
socket.on('browserWindowIsMenuBarAutoHide', (id) => {
|
||||
const isMenuBarAutoHide = getWindowById(id).isMenuBarAutoHide();
|
||||
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide);
|
||||
const isMenuBarAutoHide = getWindowById(id)?.isMenuBarAutoHide() ?? null;
|
||||
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed' + id, isMenuBarAutoHide);
|
||||
});
|
||||
socket.on('browserWindowSetMenuBarVisibility', (id, visible) => {
|
||||
getWindowById(id).setMenuBarVisibility(visible);
|
||||
getWindowById(id)?.setMenuBarVisibility(visible);
|
||||
});
|
||||
socket.on('browserWindowIsMenuBarVisible', (id) => {
|
||||
const isMenuBarVisible = getWindowById(id).isMenuBarVisible();
|
||||
electronSocket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible);
|
||||
const isMenuBarVisible = getWindowById(id)?.isMenuBarVisible() ?? null;
|
||||
electronSocket.emit('browserWindow-isMenuBarVisible-completed' + id, isMenuBarVisible);
|
||||
});
|
||||
socket.on('browserWindowSetVisibleOnAllWorkspaces', (id, visible) => {
|
||||
getWindowById(id).setVisibleOnAllWorkspaces(visible);
|
||||
getWindowById(id)?.setVisibleOnAllWorkspaces(visible);
|
||||
});
|
||||
socket.on('browserWindowIsVisibleOnAllWorkspaces', (id) => {
|
||||
const isVisibleOnAllWorkspaces = getWindowById(id).isVisibleOnAllWorkspaces();
|
||||
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces);
|
||||
const isVisibleOnAllWorkspaces = getWindowById(id)?.isVisibleOnAllWorkspaces() ?? null;
|
||||
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed' + id, isVisibleOnAllWorkspaces);
|
||||
});
|
||||
socket.on('browserWindowSetIgnoreMouseEvents', (id, ignore) => {
|
||||
getWindowById(id).setIgnoreMouseEvents(ignore);
|
||||
getWindowById(id)?.setIgnoreMouseEvents(ignore);
|
||||
});
|
||||
socket.on('browserWindowSetContentProtection', (id, enable) => {
|
||||
getWindowById(id).setContentProtection(enable);
|
||||
getWindowById(id)?.setContentProtection(enable);
|
||||
});
|
||||
socket.on('browserWindowSetFocusable', (id, focusable) => {
|
||||
getWindowById(id).setFocusable(focusable);
|
||||
getWindowById(id)?.setFocusable(focusable);
|
||||
});
|
||||
socket.on('browserWindowSetParentWindow', (id, parent) => {
|
||||
const browserWindow = electron_1.BrowserWindow.fromId(parent.id);
|
||||
getWindowById(id).setParentWindow(browserWindow);
|
||||
getWindowById(id)?.setParentWindow(browserWindow);
|
||||
});
|
||||
socket.on('browserWindowGetParentWindow', (id) => {
|
||||
const browserWindow = getWindowById(id).getParentWindow();
|
||||
electronSocket.emit('browserWindow-getParentWindow-completed', browserWindow.id);
|
||||
const browserWindow = getWindowById(id)?.getParentWindow() ?? null;
|
||||
electronSocket.emit('browserWindow-getParentWindow-completed' + id, browserWindow.id);
|
||||
});
|
||||
socket.on('browserWindowGetChildWindows', (id) => {
|
||||
const browserWindows = getWindowById(id).getChildWindows();
|
||||
const browserWindows = getWindowById(id)?.getChildWindows() ?? null;
|
||||
const ids = [];
|
||||
browserWindows.forEach(x => {
|
||||
ids.push(x.id);
|
||||
});
|
||||
electronSocket.emit('browserWindow-getChildWindows-completed', ids);
|
||||
electronSocket.emit('browserWindow-getChildWindows-completed' + id, ids);
|
||||
});
|
||||
socket.on('browserWindowSetAutoHideCursor', (id, autoHide) => {
|
||||
getWindowById(id).setAutoHideCursor(autoHide);
|
||||
getWindowById(id)?.setAutoHideCursor(autoHide);
|
||||
});
|
||||
socket.on('browserWindowSetVibrancy', (id, type) => {
|
||||
getWindowById(id).setVibrancy(type);
|
||||
getWindowById(id)?.setVibrancy(type);
|
||||
});
|
||||
socket.on('browserWindow-setBrowserView', (id, browserViewId) => {
|
||||
getWindowById(id).setBrowserView(browserView_1.browserViewMediateService(browserViewId));
|
||||
getWindowById(id)?.setBrowserView(browserView_1.browserViewMediateService(browserViewId));
|
||||
});
|
||||
function getWindowById(id) {
|
||||
for (let index = 0; index < windows.length; index++) {
|
||||
@@ -605,6 +619,7 @@ module.exports = (socket, app) => {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=browserWindows.js.map
|
||||
@@ -29,182 +29,182 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
electronSocket.emit('browserWindow-ready-to-show' + id);
|
||||
}
|
||||
|
||||
getWindowById(id).on('ready-to-show', () => {
|
||||
getWindowById(id)?.on('ready-to-show', () => {
|
||||
readyToShowWindowsIds.push(id);
|
||||
electronSocket.emit('browserWindow-ready-to-show' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-page-title-updated', (id) => {
|
||||
getWindowById(id).on('page-title-updated', (event, title) => {
|
||||
getWindowById(id)?.on('page-title-updated', (event, title) => {
|
||||
electronSocket.emit('browserWindow-page-title-updated' + id, title);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-close', (id) => {
|
||||
getWindowById(id).on('close', () => {
|
||||
getWindowById(id)?.on('close', () => {
|
||||
electronSocket.emit('browserWindow-close' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-closed', (id) => {
|
||||
getWindowById(id).on('closed', () => {
|
||||
getWindowById(id)?.on('closed', () => {
|
||||
electronSocket.emit('browserWindow-closed' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-session-end', (id) => {
|
||||
getWindowById(id).on('session-end', () => {
|
||||
getWindowById(id)?.on('session-end', () => {
|
||||
electronSocket.emit('browserWindow-session-end' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-unresponsive', (id) => {
|
||||
getWindowById(id).on('unresponsive', () => {
|
||||
getWindowById(id)?.on('unresponsive', () => {
|
||||
electronSocket.emit('browserWindow-unresponsive' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-responsive', (id) => {
|
||||
getWindowById(id).on('responsive', () => {
|
||||
getWindowById(id)?.on('responsive', () => {
|
||||
electronSocket.emit('browserWindow-responsive' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-blur', (id) => {
|
||||
getWindowById(id).on('blur', () => {
|
||||
getWindowById(id)?.on('blur', () => {
|
||||
electronSocket.emit('browserWindow-blur' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-focus', (id) => {
|
||||
getWindowById(id).on('focus', () => {
|
||||
getWindowById(id)?.on('focus', () => {
|
||||
electronSocket.emit('browserWindow-focus' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-show', (id) => {
|
||||
getWindowById(id).on('show', () => {
|
||||
getWindowById(id)?.on('show', () => {
|
||||
electronSocket.emit('browserWindow-show' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-hide', (id) => {
|
||||
getWindowById(id).on('hide', () => {
|
||||
getWindowById(id)?.on('hide', () => {
|
||||
electronSocket.emit('browserWindow-hide' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-maximize', (id) => {
|
||||
getWindowById(id).on('maximize', () => {
|
||||
getWindowById(id)?.on('maximize', () => {
|
||||
electronSocket.emit('browserWindow-maximize' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-unmaximize', (id) => {
|
||||
getWindowById(id).on('unmaximize', () => {
|
||||
getWindowById(id)?.on('unmaximize', () => {
|
||||
electronSocket.emit('browserWindow-unmaximize' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-minimize', (id) => {
|
||||
getWindowById(id).on('minimize', () => {
|
||||
getWindowById(id)?.on('minimize', () => {
|
||||
electronSocket.emit('browserWindow-minimize' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-restore', (id) => {
|
||||
getWindowById(id).on('restore', () => {
|
||||
getWindowById(id)?.on('restore', () => {
|
||||
electronSocket.emit('browserWindow-restore' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-resize', (id) => {
|
||||
getWindowById(id).on('resize', () => {
|
||||
getWindowById(id)?.on('resize', () => {
|
||||
electronSocket.emit('browserWindow-resize' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-move', (id) => {
|
||||
getWindowById(id).on('move', () => {
|
||||
getWindowById(id)?.on('move', () => {
|
||||
electronSocket.emit('browserWindow-move' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-moved', (id) => {
|
||||
getWindowById(id).on('moved', () => {
|
||||
getWindowById(id)?.on('moved', () => {
|
||||
electronSocket.emit('browserWindow-moved' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-enter-full-screen', (id) => {
|
||||
getWindowById(id).on('enter-full-screen', () => {
|
||||
getWindowById(id)?.on('enter-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-enter-full-screen' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-leave-full-screen', (id) => {
|
||||
getWindowById(id).on('leave-full-screen', () => {
|
||||
getWindowById(id)?.on('leave-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-leave-full-screen' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-enter-html-full-screen', (id) => {
|
||||
getWindowById(id).on('enter-html-full-screen', () => {
|
||||
getWindowById(id)?.on('enter-html-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-enter-html-full-screen' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-leave-html-full-screen', (id) => {
|
||||
getWindowById(id).on('leave-html-full-screen', () => {
|
||||
getWindowById(id)?.on('leave-html-full-screen', () => {
|
||||
electronSocket.emit('browserWindow-leave-html-full-screen' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-app-command', (id) => {
|
||||
getWindowById(id).on('app-command', (event, command) => {
|
||||
getWindowById(id)?.on('app-command', (event, command) => {
|
||||
electronSocket.emit('browserWindow-app-command' + id, command);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-scroll-touch-begin', (id) => {
|
||||
getWindowById(id).on('scroll-touch-begin', () => {
|
||||
getWindowById(id)?.on('scroll-touch-begin', () => {
|
||||
electronSocket.emit('browserWindow-scroll-touch-begin' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-scroll-touch-end', (id) => {
|
||||
getWindowById(id).on('scroll-touch-end', () => {
|
||||
getWindowById(id)?.on('scroll-touch-end', () => {
|
||||
electronSocket.emit('browserWindow-scroll-touch-end' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-scroll-touch-edge', (id) => {
|
||||
getWindowById(id).on('scroll-touch-edge', () => {
|
||||
getWindowById(id)?.on('scroll-touch-edge', () => {
|
||||
electronSocket.emit('browserWindow-scroll-touch-edge' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-swipe', (id) => {
|
||||
getWindowById(id).on('swipe', (event, direction) => {
|
||||
getWindowById(id)?.on('swipe', (event, direction) => {
|
||||
electronSocket.emit('browserWindow-swipe' + id, direction);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-sheet-begin', (id) => {
|
||||
getWindowById(id).on('sheet-begin', () => {
|
||||
getWindowById(id)?.on('sheet-begin', () => {
|
||||
electronSocket.emit('browserWindow-sheet-begin' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-sheet-end', (id) => {
|
||||
getWindowById(id).on('sheet-end', () => {
|
||||
getWindowById(id)?.on('sheet-end', () => {
|
||||
electronSocket.emit('browserWindow-sheet-end' + id);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('register-browserWindow-new-window-for-tab', (id) => {
|
||||
getWindowById(id).on('new-window-for-tab', () => {
|
||||
getWindowById(id)?.on('new-window-for-tab', () => {
|
||||
electronSocket.emit('browserWindow-new-window-for-tab' + id);
|
||||
});
|
||||
});
|
||||
@@ -293,330 +293,334 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
});
|
||||
|
||||
socket.on('browserWindowDestroy', (id) => {
|
||||
getWindowById(id).destroy();
|
||||
getWindowById(id)?.destroy();
|
||||
});
|
||||
|
||||
socket.on('browserWindowClose', (id) => {
|
||||
getWindowById(id).close();
|
||||
getWindowById(id)?.close();
|
||||
});
|
||||
|
||||
socket.on('browserWindowFocus', (id) => {
|
||||
getWindowById(id).focus();
|
||||
getWindowById(id)?.focus();
|
||||
});
|
||||
|
||||
socket.on('browserWindowBlur', (id) => {
|
||||
getWindowById(id).blur();
|
||||
getWindowById(id)?.blur();
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsFocused', (id) => {
|
||||
const isFocused = getWindowById(id).isFocused();
|
||||
const isFocused = getWindowById(id)?.isFocused() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isFocused-completed', isFocused);
|
||||
electronSocket.emit('browserWindow-isFocused-completed' + id, isFocused);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsDestroyed', (id) => {
|
||||
const isDestroyed = getWindowById(id).isDestroyed();
|
||||
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed', isDestroyed);
|
||||
const w = getWindowById(id);
|
||||
if (w) {
|
||||
const isDestroyed = w.isDestroyed();
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed' + id, isDestroyed);
|
||||
} else {
|
||||
electronSocket.emit('browserWindow-isDestroyed-completed' + id, true);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('browserWindowShow', (id) => {
|
||||
getWindowById(id).show();
|
||||
getWindowById(id)?.show();
|
||||
});
|
||||
|
||||
socket.on('browserWindowShowInactive', (id) => {
|
||||
getWindowById(id).showInactive();
|
||||
getWindowById(id)?.showInactive();
|
||||
});
|
||||
|
||||
socket.on('browserWindowHide', (id) => {
|
||||
getWindowById(id).hide();
|
||||
getWindowById(id)?.hide();
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsVisible', (id) => {
|
||||
const isVisible = getWindowById(id).isVisible();
|
||||
const isVisible = getWindowById(id)?.isVisible() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isVisible-completed', isVisible);
|
||||
electronSocket.emit('browserWindow-isVisible-completed' + id, isVisible);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsModal', (id) => {
|
||||
const isModal = getWindowById(id).isModal();
|
||||
const isModal = getWindowById(id)?.isModal() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isModal-completed', isModal);
|
||||
electronSocket.emit('browserWindow-isModal-completed' + id, isModal);
|
||||
});
|
||||
|
||||
socket.on('browserWindowMaximize', (id) => {
|
||||
getWindowById(id).maximize();
|
||||
getWindowById(id)?.maximize();
|
||||
});
|
||||
|
||||
socket.on('browserWindowUnmaximize', (id) => {
|
||||
getWindowById(id).unmaximize();
|
||||
getWindowById(id)?.unmaximize();
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsMaximized', (id) => {
|
||||
const isMaximized = getWindowById(id).isMaximized();
|
||||
const isMaximized = getWindowById(id)?.isMaximized() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMaximized-completed', isMaximized);
|
||||
electronSocket.emit('browserWindow-isMaximized-completed' + id, isMaximized);
|
||||
});
|
||||
|
||||
socket.on('browserWindowMinimize', (id) => {
|
||||
getWindowById(id).minimize();
|
||||
getWindowById(id)?.minimize();
|
||||
});
|
||||
|
||||
socket.on('browserWindowRestore', (id) => {
|
||||
getWindowById(id).restore();
|
||||
getWindowById(id)?.restore();
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsMinimized', (id) => {
|
||||
const isMinimized = getWindowById(id).isMinimized();
|
||||
const isMinimized = getWindowById(id)?.isMinimized() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMinimized-completed', isMinimized);
|
||||
electronSocket.emit('browserWindow-isMinimized-completed' + id, isMinimized);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetFullScreen', (id, fullscreen) => {
|
||||
getWindowById(id).setFullScreen(fullscreen);
|
||||
getWindowById(id)?.setFullScreen(fullscreen);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsFullScreen', (id) => {
|
||||
const isFullScreen = getWindowById(id).isFullScreen();
|
||||
const isFullScreen = getWindowById(id)?.isFullScreen() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isFullScreen-completed', isFullScreen);
|
||||
electronSocket.emit('browserWindow-isFullScreen-completed' + id, isFullScreen);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAspectRatio', (id, aspectRatio, extraSize) => {
|
||||
getWindowById(id).setAspectRatio(aspectRatio, extraSize);
|
||||
getWindowById(id)?.setAspectRatio(aspectRatio, extraSize);
|
||||
});
|
||||
|
||||
socket.on('browserWindowPreviewFile', (id, path, displayname) => {
|
||||
getWindowById(id).previewFile(path, displayname);
|
||||
getWindowById(id)?.previewFile(path, displayname);
|
||||
});
|
||||
|
||||
socket.on('browserWindowCloseFilePreview', (id) => {
|
||||
getWindowById(id).closeFilePreview();
|
||||
getWindowById(id)?.closeFilePreview();
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetBounds', (id, bounds, animate) => {
|
||||
getWindowById(id).setBounds(bounds, animate);
|
||||
getWindowById(id)?.setBounds(bounds, animate);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetBounds', (id) => {
|
||||
const rectangle = getWindowById(id).getBounds();
|
||||
const rectangle = getWindowById(id)?.getBounds() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getBounds-completed', rectangle);
|
||||
electronSocket.emit('browserWindow-getBounds-completed' + id, rectangle);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetContentBounds', (id, bounds, animate) => {
|
||||
getWindowById(id).setContentBounds(bounds, animate);
|
||||
getWindowById(id)?.setContentBounds(bounds, animate);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetContentBounds', (id) => {
|
||||
const rectangle = getWindowById(id).getContentBounds();
|
||||
const rectangle = getWindowById(id)?.getContentBounds() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getContentBounds-completed', rectangle);
|
||||
electronSocket.emit('browserWindow-getContentBounds-completed' + id, rectangle);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetSize', (id, width, height, animate) => {
|
||||
getWindowById(id).setSize(width, height, animate);
|
||||
getWindowById(id)?.setSize(width, height, animate);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetSize', (id) => {
|
||||
const size = getWindowById(id).getSize();
|
||||
const size = getWindowById(id)?.getSize() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getSize-completed' + id, size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetContentSize', (id, width, height, animate) => {
|
||||
getWindowById(id).setContentSize(width, height, animate);
|
||||
getWindowById(id)?.setContentSize(width, height, animate);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetContentSize', (id) => {
|
||||
const size = getWindowById(id).getContentSize();
|
||||
const size = getWindowById(id)?.getContentSize() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getContentSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getContentSize-completed' + id, size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMinimumSize', (id, width, height) => {
|
||||
getWindowById(id).setMinimumSize(width, height);
|
||||
getWindowById(id)?.setMinimumSize(width, height);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetMinimumSize', (id) => {
|
||||
const size = getWindowById(id).getMinimumSize();
|
||||
const size = getWindowById(id)?.getMinimumSize() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getMinimumSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getMinimumSize-completed' + id, size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMaximumSize', (id, width, height) => {
|
||||
getWindowById(id).setMaximumSize(width, height);
|
||||
getWindowById(id)?.setMaximumSize(width, height);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetMaximumSize', (id) => {
|
||||
const size = getWindowById(id).getMaximumSize();
|
||||
const size = getWindowById(id)?.getMaximumSize() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getMaximumSize-completed', size);
|
||||
electronSocket.emit('browserWindow-getMaximumSize-completed' + id, size);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetResizable', (id, resizable) => {
|
||||
getWindowById(id).setResizable(resizable);
|
||||
getWindowById(id)?.setResizable(resizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsResizable', (id) => {
|
||||
const resizable = getWindowById(id).isResizable();
|
||||
const resizable = getWindowById(id)?.isResizable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isResizable-completed', resizable);
|
||||
electronSocket.emit('browserWindow-isResizable-completed' + id, resizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMovable', (id, movable) => {
|
||||
getWindowById(id).setMovable(movable);
|
||||
getWindowById(id)?.setMovable(movable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsMovable', (id) => {
|
||||
const movable = getWindowById(id).isMovable();
|
||||
const movable = getWindowById(id)?.isMovable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMovable-completed', movable);
|
||||
electronSocket.emit('browserWindow-isMovable-completed' + id, movable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMinimizable', (id, minimizable) => {
|
||||
getWindowById(id).setMinimizable(minimizable);
|
||||
getWindowById(id)?.setMinimizable(minimizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsMinimizable', (id) => {
|
||||
const minimizable = getWindowById(id).isMinimizable();
|
||||
const minimizable = getWindowById(id)?.isMinimizable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMinimizable-completed', minimizable);
|
||||
electronSocket.emit('browserWindow-isMinimizable-completed' + id, minimizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMaximizable', (id, maximizable) => {
|
||||
getWindowById(id).setMaximizable(maximizable);
|
||||
getWindowById(id)?.setMaximizable(maximizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsMaximizable', (id) => {
|
||||
const maximizable = getWindowById(id).isMaximizable();
|
||||
const maximizable = getWindowById(id)?.isMaximizable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMaximizable-completed', maximizable);
|
||||
electronSocket.emit('browserWindow-isMaximizable-completed' + id, maximizable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetFullScreenable', (id, fullscreenable) => {
|
||||
getWindowById(id).setFullScreenable(fullscreenable);
|
||||
getWindowById(id)?.setFullScreenable(fullscreenable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsFullScreenable', (id) => {
|
||||
const fullscreenable = getWindowById(id).isFullScreenable();
|
||||
const fullscreenable = getWindowById(id)?.isFullScreenable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isFullScreenable-completed', fullscreenable);
|
||||
electronSocket.emit('browserWindow-isFullScreenable-completed' + id, fullscreenable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetClosable', (id, closable) => {
|
||||
getWindowById(id).setClosable(closable);
|
||||
getWindowById(id)?.setClosable(closable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsClosable', (id) => {
|
||||
const closable = getWindowById(id).isClosable();
|
||||
const closable = getWindowById(id)?.isClosable() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isClosable-completed', closable);
|
||||
electronSocket.emit('browserWindow-isClosable-completed' + id, closable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAlwaysOnTop', (id, flag, level, relativeLevel) => {
|
||||
getWindowById(id).setAlwaysOnTop(flag, level, relativeLevel);
|
||||
getWindowById(id)?.setAlwaysOnTop(flag, level, relativeLevel);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsAlwaysOnTop', (id) => {
|
||||
const isAlwaysOnTop = getWindowById(id).isAlwaysOnTop();
|
||||
const isAlwaysOnTop = getWindowById(id)?.isAlwaysOnTop() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop);
|
||||
electronSocket.emit('browserWindow-isAlwaysOnTop-completed' + id, isAlwaysOnTop);
|
||||
});
|
||||
|
||||
socket.on('browserWindowCenter', (id) => {
|
||||
getWindowById(id).center();
|
||||
getWindowById(id)?.center();
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetPosition', (id, x, y, animate) => {
|
||||
getWindowById(id).setPosition(x, y, animate);
|
||||
getWindowById(id)?.setPosition(x, y, animate);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetPosition', (id) => {
|
||||
const position = getWindowById(id).getPosition();
|
||||
const position = getWindowById(id)?.getPosition() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getPosition-completed', position);
|
||||
electronSocket.emit('browserWindow-getPosition-completed' + id, position);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
getWindowById(id).setTitle(title);
|
||||
getWindowById(id)?.setTitle(title);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetTitle', (id) => {
|
||||
const title = getWindowById(id).getTitle();
|
||||
const title = getWindowById(id)?.getTitle() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getTitle-completed', title);
|
||||
electronSocket.emit('browserWindow-getTitle-completed' + id, title);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetTitle', (id, title) => {
|
||||
getWindowById(id).setTitle(title);
|
||||
getWindowById(id)?.setTitle(title);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetSheetOffset', (id, offsetY, offsetX) => {
|
||||
if (offsetX) {
|
||||
getWindowById(id).setSheetOffset(offsetY, offsetX);
|
||||
getWindowById(id)?.setSheetOffset(offsetY, offsetX);
|
||||
} else {
|
||||
getWindowById(id).setSheetOffset(offsetY);
|
||||
getWindowById(id)?.setSheetOffset(offsetY);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('browserWindowFlashFrame', (id, flag) => {
|
||||
getWindowById(id).flashFrame(flag);
|
||||
getWindowById(id)?.flashFrame(flag);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetSkipTaskbar', (id, skip) => {
|
||||
getWindowById(id).setSkipTaskbar(skip);
|
||||
getWindowById(id)?.setSkipTaskbar(skip);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetKiosk', (id, flag) => {
|
||||
getWindowById(id).setKiosk(flag);
|
||||
getWindowById(id)?.setKiosk(flag);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsKiosk', (id) => {
|
||||
const isKiosk = getWindowById(id).isKiosk();
|
||||
const isKiosk = getWindowById(id)?.isKiosk() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isKiosk-completed', isKiosk);
|
||||
electronSocket.emit('browserWindow-isKiosk-completed' + id, isKiosk);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetNativeWindowHandle', (id) => {
|
||||
const nativeWindowHandle = getWindowById(id).getNativeWindowHandle().readInt32LE(0).toString(16);
|
||||
electronSocket.emit('browserWindow-getNativeWindowHandle-completed', nativeWindowHandle);
|
||||
const nativeWindowHandle = getWindowById(id)?.getNativeWindowHandle()?.readInt32LE(0)?.toString(16) ?? null;
|
||||
electronSocket.emit('browserWindow-getNativeWindowHandle-completed' + id, nativeWindowHandle);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
|
||||
getWindowById(id).setRepresentedFilename(filename);
|
||||
getWindowById(id)?.setRepresentedFilename(filename);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetRepresentedFilename', (id) => {
|
||||
const pathname = getWindowById(id).getRepresentedFilename();
|
||||
const pathname = getWindowById(id)?.getRepresentedFilename() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname);
|
||||
electronSocket.emit('browserWindow-getRepresentedFilename-completed' + id, pathname);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetDocumentEdited', (id, edited) => {
|
||||
getWindowById(id).setDocumentEdited(edited);
|
||||
getWindowById(id)?.setDocumentEdited(edited);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsDocumentEdited', (id) => {
|
||||
const edited = getWindowById(id).isDocumentEdited();
|
||||
const edited = getWindowById(id)?.isDocumentEdited() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isDocumentEdited-completed', edited);
|
||||
electronSocket.emit('browserWindow-isDocumentEdited-completed' + id, edited);
|
||||
});
|
||||
|
||||
socket.on('browserWindowFocusOnWebView', (id) => {
|
||||
getWindowById(id).focusOnWebView();
|
||||
getWindowById(id)?.focusOnWebView();
|
||||
});
|
||||
|
||||
socket.on('browserWindowBlurWebView', (id) => {
|
||||
getWindowById(id).blurWebView();
|
||||
getWindowById(id)?.blurWebView();
|
||||
});
|
||||
|
||||
socket.on('browserWindowLoadURL', (id, url, options) => {
|
||||
getWindowById(id).loadURL(url, options);
|
||||
getWindowById(id)?.loadURL(url, options);
|
||||
});
|
||||
|
||||
socket.on('browserWindowReload', (id) => {
|
||||
getWindowById(id).reload();
|
||||
getWindowById(id)?.reload();
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMenu', (id, menuItems) => {
|
||||
@@ -630,11 +634,11 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
});
|
||||
}
|
||||
|
||||
getWindowById(id).setMenu(menu);
|
||||
getWindowById(id)?.setMenu(menu);
|
||||
});
|
||||
|
||||
socket.on('browserWindowRemoveMenu', (id) => {
|
||||
getWindowById(id).removeMenu();
|
||||
getWindowById(id)?.removeMenu();
|
||||
});
|
||||
|
||||
function addMenuItemClickConnector(menuItems, callback) {
|
||||
@@ -650,21 +654,21 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
}
|
||||
|
||||
socket.on('browserWindowSetProgressBar', (id, progress) => {
|
||||
getWindowById(id).setProgressBar(progress);
|
||||
getWindowById(id)?.setProgressBar(progress);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetProgressBar', (id, progress, options) => {
|
||||
getWindowById(id).setProgressBar(progress, options);
|
||||
getWindowById(id)?.setProgressBar(progress, options);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetHasShadow', (id, hasShadow) => {
|
||||
getWindowById(id).setHasShadow(hasShadow);
|
||||
getWindowById(id)?.setHasShadow(hasShadow);
|
||||
});
|
||||
|
||||
socket.on('browserWindowHasShadow', (id) => {
|
||||
const hasShadow = getWindowById(id).hasShadow();
|
||||
const hasShadow = getWindowById(id)?.hasShadow() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-hasShadow-completed', hasShadow);
|
||||
electronSocket.emit('browserWindow-hasShadow-completed' + id, hasShadow);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetThumbarButtons', (id, thumbarButtons: Electron.ThumbarButton[]) => {
|
||||
@@ -676,82 +680,82 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
};
|
||||
});
|
||||
|
||||
const success = getWindowById(id).setThumbarButtons(thumbarButtons);
|
||||
electronSocket.emit('browserWindowSetThumbarButtons-completed', success);
|
||||
const success = getWindowById(id)?.setThumbarButtons(thumbarButtons) ?? null;
|
||||
electronSocket.emit('browserWindowSetThumbarButtons-completed' + id, success);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetThumbnailClip', (id, rectangle) => {
|
||||
getWindowById(id).setThumbnailClip(rectangle);
|
||||
getWindowById(id)?.setThumbnailClip(rectangle);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetThumbnailToolTip', (id, toolTip) => {
|
||||
getWindowById(id).setThumbnailToolTip(toolTip);
|
||||
getWindowById(id)?.setThumbnailToolTip(toolTip);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAppDetails', (id, options) => {
|
||||
getWindowById(id).setAppDetails(options);
|
||||
getWindowById(id)?.setAppDetails(options);
|
||||
});
|
||||
|
||||
socket.on('browserWindowShowDefinitionForSelection', (id) => {
|
||||
getWindowById(id).showDefinitionForSelection();
|
||||
getWindowById(id)?.showDefinitionForSelection();
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAutoHideMenuBar', (id, hide) => {
|
||||
getWindowById(id).setAutoHideMenuBar(hide);
|
||||
getWindowById(id)?.setAutoHideMenuBar(hide);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsMenuBarAutoHide', (id) => {
|
||||
const isMenuBarAutoHide = getWindowById(id).isMenuBarAutoHide();
|
||||
const isMenuBarAutoHide = getWindowById(id)?.isMenuBarAutoHide() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide);
|
||||
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed' + id, isMenuBarAutoHide);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetMenuBarVisibility', (id, visible) => {
|
||||
getWindowById(id).setMenuBarVisibility(visible);
|
||||
getWindowById(id)?.setMenuBarVisibility(visible);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsMenuBarVisible', (id) => {
|
||||
const isMenuBarVisible = getWindowById(id).isMenuBarVisible();
|
||||
const isMenuBarVisible = getWindowById(id)?.isMenuBarVisible() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible);
|
||||
electronSocket.emit('browserWindow-isMenuBarVisible-completed' + id, isMenuBarVisible);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetVisibleOnAllWorkspaces', (id, visible) => {
|
||||
getWindowById(id).setVisibleOnAllWorkspaces(visible);
|
||||
getWindowById(id)?.setVisibleOnAllWorkspaces(visible);
|
||||
});
|
||||
|
||||
socket.on('browserWindowIsVisibleOnAllWorkspaces', (id) => {
|
||||
const isVisibleOnAllWorkspaces = getWindowById(id).isVisibleOnAllWorkspaces();
|
||||
const isVisibleOnAllWorkspaces = getWindowById(id)?.isVisibleOnAllWorkspaces() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces);
|
||||
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed' + id, isVisibleOnAllWorkspaces);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetIgnoreMouseEvents', (id, ignore) => {
|
||||
getWindowById(id).setIgnoreMouseEvents(ignore);
|
||||
getWindowById(id)?.setIgnoreMouseEvents(ignore);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetContentProtection', (id, enable) => {
|
||||
getWindowById(id).setContentProtection(enable);
|
||||
getWindowById(id)?.setContentProtection(enable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetFocusable', (id, focusable) => {
|
||||
getWindowById(id).setFocusable(focusable);
|
||||
getWindowById(id)?.setFocusable(focusable);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetParentWindow', (id, parent) => {
|
||||
const browserWindow = BrowserWindow.fromId(parent.id);
|
||||
|
||||
getWindowById(id).setParentWindow(browserWindow);
|
||||
getWindowById(id)?.setParentWindow(browserWindow);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetParentWindow', (id) => {
|
||||
const browserWindow = getWindowById(id).getParentWindow();
|
||||
const browserWindow = getWindowById(id)?.getParentWindow() ?? null;
|
||||
|
||||
electronSocket.emit('browserWindow-getParentWindow-completed', browserWindow.id);
|
||||
electronSocket.emit('browserWindow-getParentWindow-completed' + id, browserWindow.id);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetChildWindows', (id) => {
|
||||
const browserWindows = getWindowById(id).getChildWindows();
|
||||
const browserWindows = getWindowById(id)?.getChildWindows() ?? null;
|
||||
|
||||
const ids = [];
|
||||
|
||||
@@ -759,19 +763,19 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
ids.push(x.id);
|
||||
});
|
||||
|
||||
electronSocket.emit('browserWindow-getChildWindows-completed', ids);
|
||||
electronSocket.emit('browserWindow-getChildWindows-completed' + id, ids);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetAutoHideCursor', (id, autoHide) => {
|
||||
getWindowById(id).setAutoHideCursor(autoHide);
|
||||
getWindowById(id)?.setAutoHideCursor(autoHide);
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetVibrancy', (id, type) => {
|
||||
getWindowById(id).setVibrancy(type);
|
||||
getWindowById(id)?.setVibrancy(type);
|
||||
});
|
||||
|
||||
socket.on('browserWindow-setBrowserView', (id, browserViewId) => {
|
||||
getWindowById(id).setBrowserView(browserViewMediateService(browserViewId));
|
||||
getWindowById(id)?.setBrowserView(browserViewMediateService(browserViewId));
|
||||
});
|
||||
|
||||
function getWindowById(id: number): Electron.BrowserWindow {
|
||||
@@ -781,5 +785,6 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,20 +29,20 @@ module.exports = (socket) => {
|
||||
});
|
||||
socket.on('webContents-getPrinters', async (id) => {
|
||||
const printers = await getWindowById(id).webContents.getPrinters();
|
||||
electronSocket.emit('webContents-getPrinters-completed', printers);
|
||||
electronSocket.emit('webContents-getPrinters-completed' + Id, printers);
|
||||
});
|
||||
socket.on('webContents-print', async (id, options = {}) => {
|
||||
await getWindowById(id).webContents.print(options);
|
||||
electronSocket.emit('webContents-print-completed', true);
|
||||
electronSocket.emit('webContents-print-completed' + Id, true);
|
||||
});
|
||||
socket.on('webContents-printToPDF', async (id, options = {}, path) => {
|
||||
const buffer = await getWindowById(id).webContents.printToPDF(options);
|
||||
fs.writeFile(path, buffer, (error) => {
|
||||
if (error) {
|
||||
electronSocket.emit('webContents-printToPDF-completed', false);
|
||||
electronSocket.emit('webContents-printToPDF-completed' + Id, false);
|
||||
}
|
||||
else {
|
||||
electronSocket.emit('webContents-printToPDF-completed', true);
|
||||
electronSocket.emit('webContents-printToPDF-completed' + Id, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -201,7 +201,7 @@ module.exports = (socket) => {
|
||||
Object.keys(extensionsList).forEach(key => {
|
||||
chromeExtensionInfo.push(extensionsList[key]);
|
||||
});
|
||||
electronSocket.emit('webContents-session-getAllExtensions-completed', chromeExtensionInfo);
|
||||
electronSocket.emit('webContents-session-getAllExtensions-completed' + Id, chromeExtensionInfo);
|
||||
});
|
||||
socket.on('webContents-session-removeExtension', (id, name) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
@@ -210,7 +210,7 @@ module.exports = (socket) => {
|
||||
socket.on('webContents-session-loadExtension', async (id, path, allowFileAccess = false) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
const extension = await browserWindow.webContents.session.loadExtension(path, { allowFileAccess: allowFileAccess });
|
||||
electronSocket.emit('webContents-session-loadExtension-completed', extension);
|
||||
electronSocket.emit('webContents-session-loadExtension-completed' + Id, extension);
|
||||
});
|
||||
function getWindowById(id) {
|
||||
if (id >= 1000) {
|
||||
|
||||
@@ -34,12 +34,12 @@ export = (socket: Socket) => {
|
||||
|
||||
socket.on('webContents-getPrinters', async (id) => {
|
||||
const printers = await getWindowById(id).webContents.getPrinters();
|
||||
electronSocket.emit('webContents-getPrinters-completed', printers);
|
||||
electronSocket.emit('webContents-getPrinters-completed' + Id, printers);
|
||||
});
|
||||
|
||||
socket.on('webContents-print', async (id, options = {}) => {
|
||||
await getWindowById(id).webContents.print(options);
|
||||
electronSocket.emit('webContents-print-completed', true);
|
||||
electronSocket.emit('webContents-print-completed' + Id, true);
|
||||
});
|
||||
|
||||
socket.on('webContents-printToPDF', async (id, options = {}, path) => {
|
||||
@@ -47,9 +47,9 @@ export = (socket: Socket) => {
|
||||
|
||||
fs.writeFile(path, buffer, (error) => {
|
||||
if (error) {
|
||||
electronSocket.emit('webContents-printToPDF-completed', false);
|
||||
electronSocket.emit('webContents-printToPDF-completed' + Id, false);
|
||||
} else {
|
||||
electronSocket.emit('webContents-printToPDF-completed', true);
|
||||
electronSocket.emit('webContents-printToPDF-completed' + Id, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -253,7 +253,7 @@ export = (socket: Socket) => {
|
||||
chromeExtensionInfo.push(extensionsList[key]);
|
||||
});
|
||||
|
||||
electronSocket.emit('webContents-session-getAllExtensions-completed', chromeExtensionInfo);
|
||||
electronSocket.emit('webContents-session-getAllExtensions-completed' + Id, chromeExtensionInfo);
|
||||
});
|
||||
|
||||
socket.on('webContents-session-removeExtension', (id, name) => {
|
||||
@@ -265,7 +265,7 @@ export = (socket: Socket) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
const extension = await browserWindow.webContents.session.loadExtension(path, { allowFileAccess: allowFileAccess });
|
||||
|
||||
electronSocket.emit('webContents-session-loadExtension-completed', extension);
|
||||
electronSocket.emit('webContents-session-loadExtension-completed' + Id, extension);
|
||||
});
|
||||
|
||||
function getWindowById(id: number): Electron.BrowserWindow | Electron.BrowserView {
|
||||
|
||||
Reference in New Issue
Block a user