Skip to content

Commit

Permalink
feat: Add contract for to allow user interaction in IDE from the dev-…
Browse files Browse the repository at this point in the history
…server
  • Loading branch information
dr1rrb committed Oct 8, 2024
1 parent 8904cbd commit fc7312c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#nullable enable
using System;
using Uno.UI.RemoteControl.Messaging.IdeChannel;

namespace Uno.UI.RemoteControl.Messaging.IDEChannel;

/// <summary>
/// A message sent by the IDE to the dev-server when a command is issued (like a menuitem invoked).
/// </summary>
/// <param name="Command">The name/id of the command (e.g. uno.hotreload.open_hotreload_window).</param>
/// <param name="CommandParameter">A json serialized parameter to execute the command.</param>
public record CommandRequestIdeMessage(string Command, string? CommandParameter = null) : IdeMessage(WellKnownScopes.Ide)
{
/// <summary>
/// A unique identifier of this command execution request that could be used to track the response (if any produced by the remote handler).
/// </summary>
public Guid Id {get; } = Guid.NewGuid();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@

namespace Uno.UI.RemoteControl.Messaging.IdeChannel;

/// <summary>
/// A message sent by the IDE to the dev-server to confirm a <see cref="ForceHotReloadIdeMessage"/> request has been processed.
/// </summary>
/// <param name="RequestId"><see cref="ForceHotReloadIdeMessage.CorrelationId"/> of the request.</param>
/// <param name="Result">Result of the request.</param>
public record HotReloadRequestedIdeMessage(long RequestId, Result Result) : IdeMessage(WellKnownScopes.HotReload);
3 changes: 3 additions & 0 deletions src/Uno.UI.RemoteControl.Messaging/IDEChannel/IdeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

namespace Uno.UI.RemoteControl.Messaging.IdeChannel;

/// <summary>
/// Base class to message exchanged between the IDE and teh dev-server.
/// </summary>
public record IdeMessage(string Scope);
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#nullable enable
using System;
using System.Linq;
using Uno.UI.RemoteControl.Messaging.IdeChannel;

namespace Uno.UI.RemoteControl.Messaging.IDEChannel;

/// <summary>
/// A message sent by the sev-server to the IDE to notify the user.
/// </summary>
/// <param name="Title">Title of the notification.</param>
/// <param name="Message">The message of the notification.</param>
/// <param name="Commands">For call-to-action notification, set of commands to show with the notification.</param>
public record NotificationIdeMessage(string Title, string Message, Command[] Commands) : IdeMessage(WellKnownScopes.Ide);

/// <summary>
/// Description of a command to execute.
/// </summary>
/// <param name="Text">Text content to display to the user.</param>
/// <param name="Name">The name/id of the command (e.g. uno.hotreload.open_hotreload_window).</param>
/// <param name="Parameter">A json serialized parameter to execute the command.</param>
public record Command(string Text, string Name, string? Parameter = null);
5 changes: 5 additions & 0 deletions src/Uno.UI.RemoteControl.Messaging/WellKnownScopes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public static class WellKnownScopes
/// For messages used for testing purpose (e.g. UpdateFile)
/// </summary>
public const string Testing = "UnoRuntimeTests";

/// <summary>
/// For generic messages initiated by the IDE (like a command)
/// </summary>
public const string Ide = "IDE";
}

0 comments on commit fc7312c

Please sign in to comment.