Skip to content

Commit

Permalink
Fix winui-fluid example (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin authored Jul 1, 2024
1 parent cb32c25 commit dcf6c5f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
7 changes: 3 additions & 4 deletions examples/winui-fluid/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ public App()
// Node.js require() searches for modules/packages relative to the CWD.
Environment.CurrentDirectory = Path.GetDirectoryName(typeof(App).Assembly.Location)!;

string libnodePath = Path.Combine(
Path.GetDirectoryName(typeof(App).Assembly.Location)!,
"libnode.dll");
string appDir = Path.GetDirectoryName(typeof(App).Assembly.Location)!;
string libnodePath = Path.Combine(appDir, "libnode.dll");
NodejsPlatform nodejsPlatform = new(libnodePath);

Nodejs = nodejsPlatform.CreateEnvironment();
Nodejs = nodejsPlatform.CreateEnvironment(appDir);
if (Debugger.IsAttached)
{
int pid = Process.GetCurrentProcess().Id;
Expand Down
12 changes: 6 additions & 6 deletions examples/winui-fluid/CollabEditBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void LoadFluidClient(string fluidServiceUri)
{
JSValue logFunction = JSValue.CreateFunction("send", (args) =>
{
var e = this.marshaller.To<TelemetryBaseEvent>(args[0]);
var e = this.marshaller.FromJS<TelemetryBaseEvent>(args[0]);
Debug.WriteLine($"[fluid:{e.Category}] {e.EventName}");
return JSValue.Undefined;
});
Expand All @@ -89,8 +89,8 @@ private void LoadFluidClient(string fluidServiceUri)

JSValue tinyliciousClient =
this.nodejs.Import("@fluidframework/tinylicious-client", "TinyliciousClient")
.CallAsConstructor(this.marshaller.From(clientProps));
this.fluidClient = this.marshaller.To<ITinyliciousClient>(tinyliciousClient);
.CallAsConstructor(this.marshaller.ToJS(clientProps));
this.fluidClient = this.marshaller.FromJS<ITinyliciousClient>(tinyliciousClient);
});
}

Expand Down Expand Up @@ -124,7 +124,7 @@ private ISharedString GetSharedDocument()
"sequenceDelta",
JSValue.CreateFunction("sequenceDelta", OnSharedStringDelta));

return this.marshaller.To<ISharedString>(sharedString);
return this.marshaller.FromJS<ISharedString>(sharedString);
}

private IDictionary<string, (int, int)> GetSharedSelections()
Expand Down Expand Up @@ -431,7 +431,7 @@ private void OnTextChanged(int index, int length, string text)

private JSValue OnSharedStringDelta(JSCallbackArgs args)
{
var deltaEvent = this.marshaller.To<SequenceDeltaEvent>(args[0]);
var deltaEvent = this.marshaller.FromJS<SequenceDeltaEvent>(args[0]);

Debug.WriteLine(
$"SequenceDelta(IsLocal={deltaEvent.IsLocal}, ClientId={deltaEvent.ClientId})");
Expand Down Expand Up @@ -527,7 +527,7 @@ private void OnRemoteEdit(MergeTreeOp op)

private JSValue OnSharedMapValueChanged(JSCallbackArgs args)
{
var changedEvent = this.marshaller.To<SharedMapValueChangedEvent>(args[0]);
var changedEvent = this.marshaller.FromJS<SharedMapValueChangedEvent>(args[0]);
bool isLocal = (bool)args[1];

if (!isLocal)
Expand Down
6 changes: 0 additions & 6 deletions examples/winui-fluid/Directory.Build.props

This file was deleted.

2 changes: 1 addition & 1 deletion examples/winui-fluid/winui-fluid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="$(NodeApiDotnetPackageVersion)" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.DotNetHost" Version="$(NodeApiDotnetPackageVersion)" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.*" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down

0 comments on commit dcf6c5f

Please sign in to comment.