mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Wire up browser display, fix all the STA Thread crap
This commit is contained in:
parent
72f0b43928
commit
f2c6241742
BIN
Wabbajack.CLI/Assets/wabbajack.ico
Normal file
BIN
Wabbajack.CLI/Assets/wabbajack.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 139 KiB |
@ -1,11 +1,6 @@
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Wabbajack.Networking.Browser"
|
||||
x:Class="Wabbajack.Networking.Browser.App">
|
||||
<Application.DataTemplates>
|
||||
<local:ViewLocator/>
|
||||
</Application.DataTemplates>
|
||||
|
||||
x:Class="Wabbajack.CLI.Browser.BrowserApp">
|
||||
<Application.Styles>
|
||||
<FluentTheme Mode="Dark"/>
|
||||
</Application.Styles>
|
87
Wabbajack.CLI/Browser/App.axaml.cs
Normal file
87
Wabbajack.CLI/Browser/App.axaml.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using CefNet;
|
||||
using Wabbajack.Paths.IO;
|
||||
|
||||
namespace Wabbajack.CLI.Browser
|
||||
{
|
||||
public partial class BrowserApp : Application
|
||||
{
|
||||
private const int messagePumpDelay = 10;
|
||||
|
||||
|
||||
private static CefAppImpl app;
|
||||
private static Timer messagePump;
|
||||
|
||||
private CefAppImpl _cefAppImpl;
|
||||
public TaskCompletionSource OnComplete { get; init; }
|
||||
public IServiceProvider Provider { get; init; }
|
||||
public static Window? MainWindow { get; set; }
|
||||
|
||||
public static event EventHandler FrameworkInitialized;
|
||||
public static event EventHandler FrameworkShutdown;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
var resources = KnownFolders.EntryPoint;
|
||||
var settings = new CefSettings
|
||||
{
|
||||
NoSandbox = true,
|
||||
PersistSessionCookies = true,
|
||||
MultiThreadedMessageLoop = false,
|
||||
WindowlessRenderingEnabled = true,
|
||||
ExternalMessagePump = true,
|
||||
LocalesDirPath = resources.Combine("locales").ToString(),
|
||||
ResourcesDirPath = resources.ToString(),
|
||||
UserAgent = "",
|
||||
CachePath = KnownFolders.WabbajackAppLocal.Combine("cef_cache").ToString()
|
||||
};
|
||||
|
||||
var app = new CefAppImpl();
|
||||
app.ScheduleMessagePumpWorkCallback = OnScheduleMessagePumpWork;
|
||||
|
||||
app.CefProcessMessageReceived += App_CefProcessMessageReceived;
|
||||
app.Initialize(resources.ToString(), settings);
|
||||
|
||||
Dispatcher.UIThread.Post(() => Thread.CurrentThread.Name = "UIThread");
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private static async void OnScheduleMessagePumpWork(long delayMs)
|
||||
{
|
||||
await Task.Delay((int) delayMs);
|
||||
Dispatcher.UIThread.Post(CefApi.DoMessageLoopWork);
|
||||
}
|
||||
|
||||
private static void App_CefProcessMessageReceived(object? sender, CefProcessMessageReceivedEventArgs e)
|
||||
{
|
||||
var msg = e.Name;
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
if (CefNetApplication.Instance.UsesExternalMessageLoop)
|
||||
messagePump = new Timer(_ => Dispatcher.UIThread.Post(CefApi.DoMessageLoopWork), null, messagePumpDelay,
|
||||
messagePumpDelay);
|
||||
OnComplete.SetResult();
|
||||
|
||||
}
|
||||
|
||||
private void Startup(object sender, ControlledApplicationLifetimeStartupEventArgs e)
|
||||
{
|
||||
FrameworkInitialized?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void Exit(object sender, ControlledApplicationLifetimeExitEventArgs e)
|
||||
{
|
||||
FrameworkShutdown?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ using CefNet.Avalonia;
|
||||
using HtmlAgilityPack;
|
||||
using Wabbajack.DTOs.Logins;
|
||||
|
||||
namespace Wabbajack.Networking.Browser;
|
||||
namespace Wabbajack.CLI.Browser;
|
||||
|
||||
public static class BrowserExtensions
|
||||
{
|
70
Wabbajack.CLI/Browser/BrowserHost.cs
Normal file
70
Wabbajack.CLI/Browser/BrowserHost.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
using CefNet;
|
||||
using CefNet.Avalonia;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Wabbajack.CLI.Browser
|
||||
{
|
||||
public class BrowserHost
|
||||
{
|
||||
private TaskCompletionSource _startupTask = new();
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public BrowserHost(IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
var th = new Thread(() =>
|
||||
{
|
||||
BuildAvaloniaApp()
|
||||
.StartWithCefNetApplicationLifetime(Array.Empty<string>(), ShutdownMode.OnExplicitShutdown);
|
||||
});
|
||||
th.SetApartmentState(ApartmentState.STA);
|
||||
th.Start();
|
||||
}
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure(() => new BrowserApp
|
||||
{
|
||||
Provider = _serviceProvider,
|
||||
OnComplete = _startupTask
|
||||
})
|
||||
.UsePlatformDetect()
|
||||
.LogToTrace()
|
||||
.UseReactiveUI();
|
||||
|
||||
public async Task<BrowserState> CreateBrowser()
|
||||
{
|
||||
await _startupTask.Task;
|
||||
var tcs = new TaskCompletionSource<BrowserState>();
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
var window = _serviceProvider.GetRequiredService<MainWindow>();
|
||||
window.ViewModel = _serviceProvider.GetRequiredService<MainWindowViewModel>();
|
||||
window.Show();
|
||||
tcs.SetResult(new BrowserState(window, window.ViewModel, window.Browser));
|
||||
});
|
||||
return await tcs.Task;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrowserState
|
||||
{
|
||||
private MainWindow _mainWindow;
|
||||
private MainWindowViewModel _mainWindowViewModel;
|
||||
private readonly CustomWebView _browser;
|
||||
|
||||
public BrowserState(MainWindow mainWindow, MainWindowViewModel vm, CustomWebView browser)
|
||||
{
|
||||
_mainWindow = mainWindow;
|
||||
_mainWindowViewModel = vm;
|
||||
_browser = browser;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@ using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using CefNet;
|
||||
|
||||
namespace Wabbajack.Networking.Browser;
|
||||
namespace Wabbajack.CLI.Browser;
|
||||
|
||||
internal class CefAppImpl : CefNetApplication
|
||||
public class CefAppImpl : CefNetApplication
|
||||
{
|
||||
public Action<long> ScheduleMessagePumpWorkCallback { get; set; }
|
||||
|
@ -4,24 +4,20 @@ using CefNet.Avalonia;
|
||||
using CefNet.Internal;
|
||||
using Wabbajack.Paths;
|
||||
|
||||
namespace Wabbajack.Networking.Browser;
|
||||
namespace Wabbajack.CLI.Browser;
|
||||
|
||||
public class CustomWebView : WebView
|
||||
{
|
||||
private CustomGlue Glue { get; }
|
||||
|
||||
public CustomWebView() : base()
|
||||
{
|
||||
Glue = new CustomGlue(this);
|
||||
}
|
||||
public CustomGlue Glue { get; private set; }
|
||||
|
||||
protected override WebViewGlue CreateWebViewGlue()
|
||||
{
|
||||
Glue = new CustomGlue(this);
|
||||
return Glue;
|
||||
}
|
||||
}
|
||||
|
||||
class CustomGlue : AvaloniaWebViewGlue
|
||||
public class CustomGlue : AvaloniaWebViewGlue
|
||||
{
|
||||
private readonly CustomWebView _view;
|
||||
public Func<Uri, AbsolutePath>? RedirectDownloadsFn { get; set; }
|
@ -1,15 +1,15 @@
|
||||
<reactiveUi:ReactiveWindow x:TypeArguments="vm:MainWindowViewModel"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Wabbajack.Networking.Browser.ViewModels"
|
||||
xmlns:vm="using:Wabbajack.CLI.Browser"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:avalonia="clr-namespace:CefNet.Avalonia;assembly=CefNet.Avalonia"
|
||||
xmlns:reactiveUi="http://reactiveui.net"
|
||||
xmlns:browser="clr-namespace:Wabbajack.Networking.Browser"
|
||||
xmlns:browser="clr-namespace:Wabbajack.CLI.Browser"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
|
||||
x:Class="Wabbajack.Networking.Browser.Views.MainWindow"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
x:Class="Wabbajack.CLI.Browser.MainWindow"
|
||||
Icon="/Assets/wabbajack.ico"
|
||||
Title="Wabbajack.Networking.Browser.Host"
|
||||
Width="800"
|
||||
Height="600"
|
||||
@ -19,10 +19,6 @@
|
||||
|
||||
ExtendClientAreaToDecorationsHint="True">
|
||||
|
||||
<Design.DataContext>
|
||||
<vm:MainWindowViewModel/>
|
||||
</Design.DataContext>
|
||||
|
||||
<Grid RowDefinitions="Auto, *"
|
||||
ColumnDefinitions="Auto, *">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Margin="8" x:Name="Instructions" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
|
@ -3,9 +3,8 @@ using Avalonia;
|
||||
using Avalonia.Controls.Mixins;
|
||||
using Avalonia.ReactiveUI;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Networking.Browser.ViewModels;
|
||||
|
||||
namespace Wabbajack.Networking.Browser.Views
|
||||
namespace Wabbajack.CLI.Browser
|
||||
{
|
||||
public partial class MainWindow
|
||||
: ReactiveWindow<MainWindowViewModel>
|
@ -1,6 +1,6 @@
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
|
||||
namespace Wabbajack.Networking.Browser.ViewModels
|
||||
namespace Wabbajack.CLI.Browser
|
||||
{
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Wabbajack.Networking.Browser.ViewModels
|
||||
namespace Wabbajack.CLI.Browser
|
||||
{
|
||||
public class ViewModelBase : ReactiveObject, IActivatableViewModel
|
||||
{
|
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Octokit;
|
||||
using Wabbajack.CLI.Browser;
|
||||
using Wabbajack.CLI.TypeConverters;
|
||||
using Wabbajack.CLI.Verbs;
|
||||
using Wabbajack.DTOs.GitHub;
|
||||
@ -25,6 +26,7 @@ namespace Wabbajack.CLI;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
[STAThread]
|
||||
private static async Task<int> Main(string[] args)
|
||||
{
|
||||
TypeDescriptor.AddAttributes(typeof(AbsolutePath),
|
||||
@ -52,6 +54,10 @@ internal class Program
|
||||
services.AddOSIntegrated();
|
||||
services.AddServerLib();
|
||||
|
||||
services.AddSingleton<MainWindow>();
|
||||
services.AddSingleton<MainWindowViewModel>();
|
||||
|
||||
services.AddSingleton<BrowserHost>();
|
||||
|
||||
services.AddTransient<Context>();
|
||||
|
||||
@ -62,6 +68,7 @@ internal class Program
|
||||
services.AddSingleton<DownloadUrl>();
|
||||
services.AddSingleton<ForceHeal>();
|
||||
services.AddSingleton<MirrorFile>();
|
||||
services.AddSingleton<NexusLogin>();
|
||||
services.AddSingleton<SteamDownloadFile>();
|
||||
services.AddSingleton<SteamLogin>();
|
||||
services.AddSingleton<UploadToNexus>();
|
||||
@ -88,6 +95,7 @@ internal class Program
|
||||
reg.Register<UploadToNexus>(UploadToNexus.MakeCommand);
|
||||
reg.Register<ValidateLists>(ValidateLists.MakeCommand);
|
||||
reg.Register<VfsIndexFolder>(VfsIndexFolder.MakeCommand);
|
||||
reg.Register<NexusLogin>(NexusLogin.MakeCommand);
|
||||
|
||||
return await service!.Run(args);
|
||||
}
|
||||
|
@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Wabbajack.Networking.Browser;
|
||||
using Wabbajack.Paths;
|
||||
using Wabbajack.RateLimiter;
|
||||
|
||||
namespace Wabbajack.CLI.Verbs;
|
||||
|
||||
public class ManualDownload
|
||||
{
|
||||
private readonly ILogger<ManualDownload> _logger;
|
||||
private readonly Client _client;
|
||||
private readonly IResource<HttpClient> _limiter;
|
||||
|
||||
public ManualDownload(ILogger<ManualDownload> logger, Client client, IResource<HttpClient> limiter)
|
||||
{
|
||||
_logger = logger;
|
||||
_client = client;
|
||||
_limiter = limiter;
|
||||
}
|
||||
public Command MakeCommand()
|
||||
{
|
||||
var command = new Command("manual-download");
|
||||
command.Add(new Option<AbsolutePath>(new[] {"-p", "-prompt"}, "Text prompt to show the user"));
|
||||
command.Add(new Option<AbsolutePath>(new[] {"-u", "-url"}, "Uri to show the user"));
|
||||
command.Add(new Option<AbsolutePath>(new[] {"-o", "-outputPath"}, "Output Path for the downloaded file"));
|
||||
command.Description = "Shows a browser and instructs the user to download a file, exist when the file is downloaded";
|
||||
command.Handler = CommandHandler.Create(Run);
|
||||
return command;
|
||||
}
|
||||
|
||||
public async Task<int> Run(string prompt, Uri url, AbsolutePath outputPath, CancellationToken token)
|
||||
{
|
||||
_logger.LogInformation("Opening browser");
|
||||
using var job = await _limiter.Begin($"Downloading {url}", 0, token);
|
||||
await _client.ManualDownload(prompt, url, outputPath, token, job);
|
||||
return 0;
|
||||
}
|
||||
}
|
39
Wabbajack.CLI/Verbs/NexusLogin.cs
Normal file
39
Wabbajack.CLI/Verbs/NexusLogin.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Wabbajack.CLI.Browser;
|
||||
|
||||
namespace Wabbajack.CLI.Verbs;
|
||||
|
||||
public class NexusLogin : AVerb
|
||||
{
|
||||
private readonly ILogger<NexusLogin> _logger;
|
||||
private readonly BrowserHost _host;
|
||||
|
||||
public NexusLogin(ILogger<NexusLogin> logger, BrowserHost host)
|
||||
{
|
||||
_logger = logger;
|
||||
_host = host;
|
||||
}
|
||||
|
||||
public static Command MakeCommand()
|
||||
{
|
||||
var command = new Command("nexus-login");
|
||||
command.Description = "Prompt the user to log into the nexus";
|
||||
return command;
|
||||
}
|
||||
|
||||
public async Task<int> Run(CancellationToken token)
|
||||
{
|
||||
var browser = await _host.CreateBrowser();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected override ICommandHandler GetHandler()
|
||||
{
|
||||
return CommandHandler.Create(Run);
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
<AssemblyName>wabbajack-cli</AssemblyName>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<TimeMode>linked</TimeMode>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -19,6 +20,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.2-mauipre.1.22054.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2-mauipre.1.22054.8" />
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21561.1" />
|
||||
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -33,4 +35,20 @@
|
||||
<ProjectReference Include="..\Wabbajack.VFS\Wabbajack.VFS.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Browser\App.axaml.cs">
|
||||
<DependentUpon>App.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Browser\MainWindow.axaml.cs">
|
||||
<DependentUpon>MainWindow.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\wabbajack.ico" />
|
||||
<AvaloniaResource Include="Assets\wabbajack.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
454
Wabbajack.Networking.Browser.Host/.gitignore
vendored
454
Wabbajack.Networking.Browser.Host/.gitignore
vendored
@ -1,454 +0,0 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# Tye
|
||||
.tye/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
##
|
||||
## Visual studio for Mac
|
||||
##
|
||||
|
||||
|
||||
# globs
|
||||
Makefile.in
|
||||
*.userprefs
|
||||
*.usertasks
|
||||
config.make
|
||||
config.status
|
||||
aclocal.m4
|
||||
install-sh
|
||||
autom4te.cache/
|
||||
*.tar.gz
|
||||
tarballs/
|
||||
test-results/
|
||||
|
||||
# Mac bundle stuff
|
||||
*.dmg
|
||||
*.app
|
||||
|
||||
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
##
|
||||
## Visual Studio Code
|
||||
##
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
@ -1,87 +0,0 @@
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReactiveUI;
|
||||
using Splat;
|
||||
using Wabbajack.DTOs.BrowserMessages;
|
||||
using Wabbajack.DTOs.JsonConverters;
|
||||
using Wabbajack.Networking.Browser.ViewModels;
|
||||
using Wabbajack.Networking.Browser.Views;
|
||||
|
||||
namespace Wabbajack.Networking.Browser
|
||||
{
|
||||
public class App : Application
|
||||
{
|
||||
public static IServiceProvider Services { get; private set; } = null!;
|
||||
public static Window? MainWindow { get; set; }
|
||||
|
||||
public static event EventHandler FrameworkInitialized;
|
||||
public static event EventHandler FrameworkShutdown;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
Dispatcher.UIThread.Post(() => Thread.CurrentThread.Name = "UIThread");
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
var host = Host.CreateDefaultBuilder(Array.Empty<string>())
|
||||
.ConfigureLogging(c => { c.ClearProviders(); })
|
||||
.ConfigureServices((host, services) => { services.AddAppServices(); }).Build();
|
||||
Services = host.Services;
|
||||
|
||||
|
||||
// Need to startup the message bus;
|
||||
var app = Services.GetService<CefAppImpl>();
|
||||
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
Program.MainWindow = Services.GetRequiredService<MainWindow>();
|
||||
Program.MainWindowVM = Services.GetRequiredService<MainWindowViewModel>();
|
||||
Program.MainWindow.ViewModel = Program.MainWindowVM;
|
||||
desktop.MainWindow = Program.MainWindow;
|
||||
desktop.Startup += Startup;
|
||||
desktop.Exit += Exit;
|
||||
MainWindow = desktop.MainWindow;
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
|
||||
|
||||
var dtos = Services.GetRequiredService<DTOSerializer>();
|
||||
var msgProcessor = Task.Run(async () =>
|
||||
{
|
||||
await using var input = Console.OpenStandardInput();
|
||||
while (true)
|
||||
{
|
||||
var msg = await JsonSerializer.DeserializeAsync<IMessage>(input);
|
||||
switch (msg)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void Startup(object sender, ControlledApplicationLifetimeStartupEventArgs e)
|
||||
{
|
||||
FrameworkInitialized?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void Exit(object sender, ControlledApplicationLifetimeExitEventArgs e)
|
||||
{
|
||||
FrameworkShutdown?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 172 KiB |
@ -1,3 +0,0 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<ReactiveUI />
|
||||
</Weavers>
|
@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.ReactiveUI;
|
||||
using CefNet;
|
||||
using Wabbajack.Networking.Browser.ViewModels;
|
||||
using Wabbajack.Networking.Browser.Views;
|
||||
|
||||
namespace Wabbajack.Networking.Browser
|
||||
{
|
||||
class Program
|
||||
{
|
||||
public static MainWindowViewModel MainWindowVM { get; set; }
|
||||
public static string[] Args { get; set; }
|
||||
|
||||
public static Views.MainWindow MainWindow { get; set; }
|
||||
|
||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||
// yet and stuff might break.
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Args = args;
|
||||
BuildAvaloniaApp()
|
||||
.StartWithCefNetApplicationLifetime(args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.LogToTrace()
|
||||
.UseReactiveUI();
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Threading;
|
||||
using CefNet;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Wabbajack.CLI.TypeConverters;
|
||||
using Wabbajack.Networking.Browser.ViewModels;
|
||||
using Wabbajack.Networking.Browser.Views;
|
||||
using Wabbajack.Paths;
|
||||
using Wabbajack.Paths.IO;
|
||||
using Wabbajack.Services.OSIntegrated;
|
||||
|
||||
namespace Wabbajack.Networking.Browser;
|
||||
|
||||
public static class ServiceExtensions
|
||||
{
|
||||
private const int messagePumpDelay = 10;
|
||||
|
||||
|
||||
private static CefAppImpl app;
|
||||
private static Timer messagePump;
|
||||
|
||||
public static IServiceCollection AddAppServices(this IServiceCollection services)
|
||||
{
|
||||
|
||||
TypeDescriptor.AddAttributes(typeof(AbsolutePath),
|
||||
new TypeConverterAttribute(typeof(AbsolutePathTypeConverter)));
|
||||
|
||||
var resources = KnownFolders.EntryPoint;
|
||||
services.AddSingleton<MainWindow>();
|
||||
services.AddSingleton<MainWindowViewModel>();
|
||||
|
||||
services.AddOSIntegrated();
|
||||
|
||||
services.AddSingleton(s => new CefSettings
|
||||
{
|
||||
NoSandbox = true,
|
||||
PersistSessionCookies = true,
|
||||
MultiThreadedMessageLoop = false,
|
||||
WindowlessRenderingEnabled = true,
|
||||
ExternalMessagePump = true,
|
||||
LocalesDirPath = resources.Combine("locales").ToString(),
|
||||
ResourcesDirPath = resources.ToString(),
|
||||
UserAgent = "",
|
||||
CachePath = KnownFolders.WabbajackAppLocal.Combine("cef_cache").ToString()
|
||||
});
|
||||
|
||||
services.AddSingleton(s =>
|
||||
{
|
||||
App.FrameworkInitialized += App_FrameworkInitialized;
|
||||
|
||||
var app = new CefAppImpl();
|
||||
app.ScheduleMessagePumpWorkCallback = OnScheduleMessagePumpWork;
|
||||
|
||||
app.CefProcessMessageReceived += App_CefProcessMessageReceived;
|
||||
app.Initialize(resources.ToString(), s.GetService<CefSettings>());
|
||||
|
||||
|
||||
return app;
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
private static async void OnScheduleMessagePumpWork(long delayMs)
|
||||
{
|
||||
await Task.Delay((int) delayMs);
|
||||
Dispatcher.UIThread.Post(CefApi.DoMessageLoopWork);
|
||||
}
|
||||
|
||||
private static void App_CefProcessMessageReceived(object? sender, CefProcessMessageReceivedEventArgs e)
|
||||
{
|
||||
var msg = e.Name;
|
||||
}
|
||||
|
||||
private static void App_FrameworkInitialized(object? sender, EventArgs e)
|
||||
{
|
||||
if (CefNetApplication.Instance.UsesExternalMessageLoop)
|
||||
messagePump = new Timer(_ => Dispatcher.UIThread.Post(CefApi.DoMessageLoopWork), null, messagePumpDelay,
|
||||
messagePumpDelay);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using Wabbajack.Paths;
|
||||
|
||||
namespace Wabbajack.CLI.TypeConverters;
|
||||
|
||||
public class AbsolutePathTypeConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value,
|
||||
Type destinationType)
|
||||
{
|
||||
return (AbsolutePath) (string) value;
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
return (AbsolutePath) (string) value;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using Wabbajack.DTOs.GitHub;
|
||||
|
||||
namespace Wabbajack.Networking.Browser.TypeConverters;
|
||||
|
||||
public class ModListCategoryConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value,
|
||||
Type destinationType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
return Enum.Parse<List>((string) value);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Wabbajack.Networking.Browser.ViewModels;
|
||||
|
||||
namespace Wabbajack.Networking.Browser
|
||||
{
|
||||
public class ViewLocator : IDataTemplate
|
||||
{
|
||||
public IControl Build(object data)
|
||||
{
|
||||
var name = data.GetType().FullName!.Replace("ViewModel", "View");
|
||||
var type = Type.GetType(name);
|
||||
|
||||
if (type != null)
|
||||
{
|
||||
return (Control)Activator.CreateInstance(type)!;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TextBlock { Text = "Not Found: " + name };
|
||||
}
|
||||
}
|
||||
|
||||
public bool Match(object data)
|
||||
{
|
||||
return data is ViewModelBase;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>10</LangVersion>
|
||||
<RootNamespace>Wabbajack.Networking.Browser</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
<None Remove=".gitignore" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.10.10" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.10.10" />
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.10" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.10" />
|
||||
<PackageReference Include="CefNet.Avalonia" Version="97.1.22018.1433" />
|
||||
<PackageReference Include="Fizzler.Systems.HtmlAgilityPack" Version="1.2.1" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.40" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.2-mauipre.1.22054.8" />
|
||||
<PackageReference Include="ReactiveUI.Fody" Version="17.1.17" />
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21561.1" />
|
||||
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Wabbajack.Common\Wabbajack.Common.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Paths.IO\Wabbajack.Paths.IO.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Services.OSIntegrated\Wabbajack.Services.OSIntegrated.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,65 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using Wabbajack.DTOs.BrowserMessages;
|
||||
using Wabbajack.DTOs.JsonConverters;
|
||||
using Wabbajack.Paths;
|
||||
using Wabbajack.RateLimiter;
|
||||
|
||||
namespace Wabbajack.Networking.Browser;
|
||||
|
||||
|
||||
public class Client
|
||||
{
|
||||
private readonly Configuration _config;
|
||||
private readonly DTOSerializer _dtos;
|
||||
|
||||
public Client(Configuration config, DTOSerializer dtos)
|
||||
{
|
||||
_config = config;
|
||||
_dtos = dtos;
|
||||
}
|
||||
|
||||
public async Task ManualDownload(string prompt, Uri uri, AbsolutePath dest, CancellationToken token, IJob job)
|
||||
{
|
||||
var process = new Process()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
FileName = _config.HostExecutable.ToString(),
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true
|
||||
}
|
||||
};
|
||||
|
||||
var ptask = process.Start();
|
||||
|
||||
var reader = Task.Run(async () =>
|
||||
{
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
var msg = await JsonSerializer.DeserializeAsync<IMessage>(process.StandardOutput.BaseStream,
|
||||
_dtos.Options, token);
|
||||
if (msg is DownloadProgress dp)
|
||||
{
|
||||
job.ReportNoWait((int) dp.BytesCompleted);
|
||||
job.Size = dp.ExpectedSize;
|
||||
if (dp.IsDone)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, token);
|
||||
|
||||
await process.StandardInput.WriteAsync(JsonSerializer.Serialize(new DTOs.BrowserMessages.ManualDownload()
|
||||
{
|
||||
Prompt = prompt,
|
||||
Url = uri,
|
||||
Path = dest
|
||||
}));
|
||||
|
||||
await process.WaitForExitAsync(token);
|
||||
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
using Wabbajack.Paths;
|
||||
using Wabbajack.Paths.IO;
|
||||
|
||||
namespace Wabbajack.Networking.Browser;
|
||||
|
||||
public class Configuration
|
||||
{
|
||||
public AbsolutePath HostExecutable { get; set; } =
|
||||
KnownFolders.EntryPoint.Combine("Wabbajack.Networking.Browser.Host.exe");
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>Wabbajack.Networking.Browser.Client</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Wabbajack.Common\Wabbajack.Common.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Networking.Browser.Host\Wabbajack.Networking.Browser.Host.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Paths.IO\Wabbajack.Paths.IO.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Paths\Wabbajack.Paths.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -125,10 +125,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wabbajack.App.Blazor", "Wab
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{18E36813-CB53-4172-8FF3-EFE3B9B30A5F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.Networking.Browser.Host", "Wabbajack.Networking.Browser.Host\Wabbajack.Networking.Browser.Host.csproj", "{44860A8E-C3E4-4BF0-8EAB-BFA2D6DA217A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.Networking.Browser", "Wabbajack.Networking.Browser\Wabbajack.Networking.Browser.csproj", "{860A06B3-AE35-4C69-95E5-EC9E8D6630CF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -343,14 +339,6 @@ Global
|
||||
{C6E9B15D-510F-4074-AB1C-069F36BA4622}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C6E9B15D-510F-4074-AB1C-069F36BA4622}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C6E9B15D-510F-4074-AB1C-069F36BA4622}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{44860A8E-C3E4-4BF0-8EAB-BFA2D6DA217A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{44860A8E-C3E4-4BF0-8EAB-BFA2D6DA217A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{44860A8E-C3E4-4BF0-8EAB-BFA2D6DA217A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{44860A8E-C3E4-4BF0-8EAB-BFA2D6DA217A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{860A06B3-AE35-4C69-95E5-EC9E8D6630CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{860A06B3-AE35-4C69-95E5-EC9E8D6630CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{860A06B3-AE35-4C69-95E5-EC9E8D6630CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{860A06B3-AE35-4C69-95E5-EC9E8D6630CF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -392,8 +380,6 @@ Global
|
||||
{4F252332-CA77-41DE-95A8-9DF38A81D675} = {98B731EE-4FC0-4482-A069-BCBA25497871}
|
||||
{AB9A5C22-10CC-4EE0-A808-FB1DC9E24247} = {F01F8595-5FD7-4506-8469-F4A5522DACC1}
|
||||
{D6351587-CAF6-4CB6-A2BD-5368E69F297C} = {F01F8595-5FD7-4506-8469-F4A5522DACC1}
|
||||
{44860A8E-C3E4-4BF0-8EAB-BFA2D6DA217A} = {F01F8595-5FD7-4506-8469-F4A5522DACC1}
|
||||
{860A06B3-AE35-4C69-95E5-EC9E8D6630CF} = {F01F8595-5FD7-4506-8469-F4A5522DACC1}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0AA30275-0F38-4A7D-B645-F5505178DDE8}
|
||||
|
Loading…
Reference in New Issue
Block a user