diff --git a/src/Live/Sucrose.Live.CefSharp/App.xaml.cs b/src/Live/Sucrose.Live.CefSharp/App.xaml.cs
index 8162ed56c..cb350daa7 100644
--- a/src/Live/Sucrose.Live.CefSharp/App.xaml.cs
+++ b/src/Live/Sucrose.Live.CefSharp/App.xaml.cs
@@ -34,6 +34,7 @@
using SSECSVV = Sucrose.Shared.Engine.CefSharp.View.Video;
using SSECSVW = Sucrose.Shared.Engine.CefSharp.View.Web;
using SSECSVYT = Sucrose.Shared.Engine.CefSharp.View.YouTube;
+using SSEELHS = Sucrose.Shared.Engine.Extension.LocalHttpServer;
using SSEHC = Sucrose.Shared.Engine.Helper.Cycyling;
using SSEHP = Sucrose.Shared.Engine.Helper.Properties;
using SSEHR = Sucrose.Shared.Engine.Helper.Run;
@@ -59,6 +60,7 @@ namespace Sucrose.Live.CefSharp
public partial class App : Application
{
private static bool HasError { get; set; } = true;
+ private static SSEELHS LocalServer { get; set; }
public App()
{
@@ -123,6 +125,7 @@ public App()
protected void Close()
{
+ Task.Run(LocalServer.Stop);
Environment.Exit(0);
Current.Shutdown();
Shutdown();
@@ -270,8 +273,10 @@ protected void Configure()
CefSettings Settings = new()
{
+ Locale = SMMG.Culture,
UserAgent = SMMG.UserAgent,
PersistSessionCookies = true,
+ WindowlessRenderingEnabled = true,
CachePath = Path.Combine(SMMRP.ApplicationData, SMMRG.AppName, SMMRF.Cache, SMMRF.CefSharp)
};
@@ -302,7 +307,7 @@ protected void Configure()
//Example of checking if a call to Cef.Initialize has already been made, we require this for
//our .Net 5.0 Single File Publish example, you don't typically need to perform this check
//if you call Cef.Initialze within your WPF App constructor.
- if (!Cef.IsInitialized)
+ if (Cef.IsInitialized is null or false)
{
//Perform dependency check to make sure all relevant resources are in our output directory.
Cef.Initialize(Settings, performDependencyCheck: true, browserProcessHandler: null);
@@ -373,26 +378,32 @@ protected void Configure()
SSEMI.Compatible.State = true;
}
+ LocalServer = new(Path.Combine(SSEMI.LibraryLocation, SSEMI.LibrarySelected));
+
+ Task.Run(() => LocalServer.StartAsync());
+
+ SSEMI.Host = LocalServer.GetUrl();
+
switch (SSEMI.Info.Type)
{
case SSDEWT.Gif:
- SSECSVG Gif = new(Source);
+ SSECSVG Gif = new();
Gif.Show();
break;
case SSDEWT.Url:
- SSECSVU Url = new(Source);
+ SSECSVU Url = new();
Url.Show();
break;
case SSDEWT.Web:
- SSECSVW Web = new(Source);
+ SSECSVW Web = new();
Web.Show();
break;
case SSDEWT.Video:
- SSECSVV Video = new(Source);
+ SSECSVV Video = new();
Video.Show();
break;
case SSDEWT.YouTube:
- SSECSVYT YouTube = new(Source);
+ SSECSVYT YouTube = new();
YouTube.Show();
break;
default:
diff --git a/src/Live/Sucrose.Live.CefSharp/Sucrose.Live.CefSharp.csproj b/src/Live/Sucrose.Live.CefSharp/Sucrose.Live.CefSharp.csproj
index fc79de74a..c7804372a 100644
--- a/src/Live/Sucrose.Live.CefSharp/Sucrose.Live.CefSharp.csproj
+++ b/src/Live/Sucrose.Live.CefSharp/Sucrose.Live.CefSharp.csproj
@@ -75,7 +75,7 @@
-
+
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Gif.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Gif.cs
index 15b71adc3..250a96783 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Gif.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Gif.cs
@@ -12,7 +12,7 @@ internal static class Gif
{
public static void CefEngineLoaded(object sender, RoutedEventArgs e)
{
- Uri Gif = SSEHS.GetSource(SSECSMI.Gif);
+ Uri Gif = SSEHS.GetSource(SSEMI.Info.Source, SSEMI.Host);
string Path = SSEHS.GetGifContentPath();
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Url.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Url.cs
index 3c828f664..79aadb734 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Url.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Url.cs
@@ -19,7 +19,7 @@ public static void CefEngineInitialized(object sender, EventArgs e)
public static void CefEngineLoaded(object sender, RoutedEventArgs e)
{
- SSECSMI.CefEngine.Address = SSECSMI.Url;
+ SSECSMI.CefEngine.Address = SSEMI.Info.Source;
}
public static void CefEngineInitializedChanged(object sender, EventArgs e)
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Video.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Video.cs
index e081df49b..a6cd58bc7 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Video.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Video.cs
@@ -3,6 +3,7 @@
using SMME = Sucrose.Manager.Manage.Engine;
using SSECSHV = Sucrose.Shared.Engine.CefSharp.Helper.Video;
using SSECSMI = Sucrose.Shared.Engine.CefSharp.Manage.Internal;
+using SSEHS = Sucrose.Shared.Engine.Helper.Source;
using SSEMI = Sucrose.Shared.Engine.Manage.Internal;
namespace Sucrose.Shared.Engine.CefSharp.Event
@@ -11,7 +12,7 @@ internal static class Video
{
public static void CefEngineLoaded(object sender, RoutedEventArgs e)
{
- //
+ SSECSMI.CefEngine.Address = SSEHS.GetSource(SSEMI.Info.Source, SSEMI.Host).ToString();
}
public static void CefEngineInitializedChanged(object sender, EventArgs e)
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Web.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Web.cs
index 0bfb2c3cb..ee384ae0d 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Web.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/Web.cs
@@ -1,6 +1,7 @@
using CefSharp;
using System.IO;
using System.Windows;
+using Application = System.Windows.Application;
using SEIT = Skylark.Enum.InputType;
using SMME = Sucrose.Manager.Manage.Engine;
using SSECSEI = Sucrose.Shared.Engine.CefSharp.Extension.Interaction;
@@ -19,7 +20,7 @@ internal static class Web
{
public static void CefEngineLoaded(object sender, RoutedEventArgs e)
{
- SSECSMI.CefEngine.Address = SSEHS.GetSource(SSECSMI.Web).ToString();
+ SSECSMI.CefEngine.Address = SSEHS.GetSource(SSEMI.Info.Source, SSEMI.Host).ToString();
}
public static void CefEngineInitializedChanged(object sender, EventArgs e)
@@ -66,7 +67,7 @@ public static void CefEngineFrameLoadEnd(object sender, FrameLoadEndEventArgs e)
private static async void PropertiesWatcher(object sender, FileSystemEventArgs e)
{
- await System.Windows.Application.Current.Dispatcher.InvokeAsync(async () =>
+ await Application.Current.Dispatcher.InvokeAsync(async () =>
{
try
{
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/YouTube.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/YouTube.cs
index 6f19aff4e..14da8b113 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/YouTube.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Event/YouTube.cs
@@ -1,6 +1,7 @@
using CefSharp;
using System.Windows;
using SMME = Sucrose.Manager.Manage.Engine;
+using SMMRC = Sucrose.Memory.Manage.Readonly.Content;
using SSECSHYT = Sucrose.Shared.Engine.CefSharp.Helper.YouTube;
using SSECSMI = Sucrose.Shared.Engine.CefSharp.Manage.Internal;
using SSEHS = Sucrose.Shared.Engine.Helper.Source;
@@ -13,14 +14,14 @@ internal static class YouTube
{
public static void CefEngineLoaded(object sender, RoutedEventArgs e)
{
- string Video = SSTHV.GetYouTubeVideoId(SSECSMI.YouTube);
- string Playlist = SSTHV.GetYouTubePlaylistId(SSECSMI.YouTube);
+ string Video = SSTHV.GetYouTubeVideoId(SSEMI.Info.Source);
+ string Playlist = SSTHV.GetYouTubePlaylistId(SSEMI.Info.Source);
string Path = SSEHS.GetYouTubeContentPath();
SSEHS.WriteYouTubeContent(Path, Video, Playlist);
- SSECSMI.CefEngine.Address = SSEHS.GetSource(Path).ToString();
+ SSECSMI.CefEngine.Address = SSEHS.GetSource(SMMRC.YouTube, SSEMI.Host).ToString();
}
public static void CefEngineInitializedChanged(object sender, EventArgs e)
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Input.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Handle.cs
similarity index 80%
rename from src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Input.cs
rename to src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Handle.cs
index 79ef33b22..86a3563b9 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Input.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Handle.cs
@@ -15,10 +15,12 @@ public static void GetInputHandle()
IntPtr InputHandle = SWNM.FindWindowEx(SSECSMI.CefHandle, IntPtr.Zero, "Chrome_WidgetWin_0", null);
- if (!InputHandle.Equals(IntPtr.Zero))
+ if (InputHandle.Equals(IntPtr.Zero))
{
- SSECSMI.CefHandle = InputHandle;
+ InputHandle = SWNM.FindWindowEx(SSECSMI.CefHandle, IntPtr.Zero, "Chrome_WidgetWin_1", null);
}
+
+ SSECSMI.CefHandle = InputHandle;
}
public static void GetIntermediateHandle()
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Web.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Web.cs
index 10a51cdf4..015fc3c1c 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Web.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Web.cs
@@ -1,4 +1,5 @@
using CefSharp;
+using Application = System.Windows.Application;
using SMMCB = Sucrose.Memory.Manage.Constant.Backgroundog;
using SMMI = Sucrose.Manager.Manage.Internal;
using SPMI = Sucrose.Pipe.Manage.Internal;
@@ -89,7 +90,7 @@ public static void StartCompatible()
{
SSPSBSS.Handler(e);
- await System.Windows.Application.Current.Dispatcher.InvokeAsync(async () =>
+ await Application.Current.Dispatcher.InvokeAsync(async () =>
{
try
{
@@ -118,7 +119,7 @@ await System.Windows.Application.Current.Dispatcher.InvokeAsync(async () =>
{
SSSSBSS.Handler(s, e);
- await System.Windows.Application.Current.Dispatcher.InvokeAsync(async () =>
+ await Application.Current.Dispatcher.InvokeAsync(async () =>
{
try
{
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Manage/Internal.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Manage/Internal.cs
index fd5673b84..11f4a8843 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Manage/Internal.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Manage/Internal.cs
@@ -9,18 +9,10 @@ internal static class Internal
public static bool State = true;
- public static string Gif = string.Empty;
-
- public static string Url = string.Empty;
-
- public static string Web = string.Empty;
-
public static CefEngine CefEngine = new();
public static IBrowserHost CefHost = null;
- public static string YouTube = string.Empty;
-
public static IntPtr CefHandle = IntPtr.Zero;
public static BrowserSettings CefSettings => new()
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Sucrose.Shared.Engine.CefSharp.projitems b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Sucrose.Shared.Engine.CefSharp.projitems
index e0e44db85..c56edae76 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Sucrose.Shared.Engine.CefSharp.projitems
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Sucrose.Shared.Engine.CefSharp.projitems
@@ -19,7 +19,7 @@
-
+
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Gif.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Gif.xaml.cs
index 6254329b6..0acd26090 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Gif.xaml.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Gif.xaml.cs
@@ -17,7 +17,7 @@ namespace Sucrose.Shared.Engine.CefSharp.View
///
public sealed partial class Gif : Window, IDisposable
{
- public Gif(string Gif)
+ public Gif()
{
InitializeComponent();
@@ -29,8 +29,6 @@ public Gif(string Gif)
Content = SSECSMI.CefEngine;
- SSECSMI.Gif = Gif;
-
SSECSMI.CefEngine.BrowserSettings = SSECSMI.CefSettings;
SSEMI.GeneralTimer.Tick += new EventHandler(GeneralTimer_Tick);
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Url.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Url.xaml.cs
index 42acd0328..670ee57e7 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Url.xaml.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Url.xaml.cs
@@ -18,7 +18,7 @@ namespace Sucrose.Shared.Engine.CefSharp.View
///
public sealed partial class Url : Window, IDisposable
{
- public Url(string Url)
+ public Url()
{
InitializeComponent();
@@ -30,8 +30,6 @@ public Url(string Url)
Content = SSECSMI.CefEngine;
- SSECSMI.Url = Url;
-
SSECSMI.CefEngine.BrowserSettings = SSECSMI.CefSettings;
SSEMI.GeneralTimer.Tick += new EventHandler(GeneralTimer_Tick);
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Video.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Video.xaml.cs
index 8974f23f1..958cfa43b 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Video.xaml.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Video.xaml.cs
@@ -8,7 +8,6 @@
using SSEEH = Sucrose.Shared.Engine.Event.Handler;
using SSEHD = Sucrose.Shared.Engine.Helper.Data;
using SSEHR = Sucrose.Shared.Engine.Helper.Run;
-using SSEHS = Sucrose.Shared.Engine.Helper.Source;
using SSEHV = Sucrose.Shared.Engine.Helper.Volume;
using SSEMI = Sucrose.Shared.Engine.Manage.Internal;
@@ -19,7 +18,7 @@ namespace Sucrose.Shared.Engine.CefSharp.View
///
public sealed partial class Video : Window, IDisposable
{
- public Video(string Video)
+ public Video()
{
InitializeComponent();
@@ -31,8 +30,6 @@ public Video(string Video)
Content = SSECSMI.CefEngine;
- SSECSMI.CefEngine.Address = SSEHS.GetSource(Video).ToString();
-
SSECSMI.CefEngine.BrowserSettings = SSECSMI.CefSettings;
SSEMI.GeneralTimer.Tick += new EventHandler(GeneralTimer_Tick);
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Web.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Web.xaml.cs
index 7ee201367..ebe9444a8 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Web.xaml.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Web.xaml.cs
@@ -18,7 +18,7 @@ namespace Sucrose.Shared.Engine.CefSharp.View
///
public sealed partial class Web : Window, IDisposable
{
- public Web(string Web)
+ public Web()
{
InitializeComponent();
@@ -30,8 +30,6 @@ public Web(string Web)
Content = SSECSMI.CefEngine;
- SSECSMI.Web = Web;
-
SSECSMI.CefEngine.BrowserSettings = SSECSMI.CefSettings;
SSEMI.GeneralTimer.Tick += new EventHandler(GeneralTimer_Tick);
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/YouTube.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/YouTube.xaml.cs
index 0fd7e3226..c9d0c2236 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/YouTube.xaml.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/YouTube.xaml.cs
@@ -18,7 +18,7 @@ namespace Sucrose.Shared.Engine.CefSharp.View
///
public sealed partial class YouTube : Window, IDisposable
{
- public YouTube(string YouTube)
+ public YouTube()
{
InitializeComponent();
@@ -30,8 +30,6 @@ public YouTube(string YouTube)
Content = SSECSMI.CefEngine;
- SSECSMI.YouTube = YouTube;
-
SSECSMI.CefEngine.BrowserSettings = SSECSMI.CefSettings;
SSEMI.GeneralTimer.Tick += new EventHandler(GeneralTimer_Tick);
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Event/Web.cs b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Event/Web.cs
index c63324291..99d378f58 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Event/Web.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Event/Web.cs
@@ -1,6 +1,7 @@
using Microsoft.Web.WebView2.Core;
using System.Collections;
using System.IO;
+using Application = System.Windows.Application;
using SEIT = Skylark.Enum.InputType;
using SELLT = Skylark.Enum.LevelLogType;
using SMME = Sucrose.Manager.Manage.Engine;
@@ -23,7 +24,7 @@ internal static class Web
{
private static async void PropertiesWatcher(object sender, FileSystemEventArgs e)
{
- await System.Windows.Application.Current.Dispatcher.InvokeAsync(async () =>
+ await Application.Current.Dispatcher.InvokeAsync(async () =>
{
try
{
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Input.cs b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Handle.cs
similarity index 100%
rename from src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Input.cs
rename to src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Handle.cs
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Web.cs b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Web.cs
index 08c49f1a9..5b544b04f 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Web.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Web.cs
@@ -1,4 +1,5 @@
-using SMMCB = Sucrose.Memory.Manage.Constant.Backgroundog;
+using Application = System.Windows.Application;
+using SMMCB = Sucrose.Memory.Manage.Constant.Backgroundog;
using SMMI = Sucrose.Manager.Manage.Internal;
using SPMI = Sucrose.Pipe.Manage.Internal;
using SSDECT = Sucrose.Shared.Dependency.Enum.CommunicationType;
@@ -72,7 +73,7 @@ public static void StartCompatible()
{
SSPSBSS.Handler(e);
- await System.Windows.Application.Current.Dispatcher.InvokeAsync(async () =>
+ await Application.Current.Dispatcher.InvokeAsync(async () =>
{
try
{
@@ -101,7 +102,7 @@ await System.Windows.Application.Current.Dispatcher.InvokeAsync(async () =>
{
SSSSBSS.Handler(s, e);
- await System.Windows.Application.Current.Dispatcher.InvokeAsync(async () =>
+ await Application.Current.Dispatcher.InvokeAsync(async () =>
{
try
{
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Sucrose.Shared.Engine.WebView.projitems b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Sucrose.Shared.Engine.WebView.projitems
index 68acfd2f1..8bba27e20 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Sucrose.Shared.Engine.WebView.projitems
+++ b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Sucrose.Shared.Engine.WebView.projitems
@@ -38,7 +38,7 @@
-
+
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Extension/LocalHttpServer.cs b/src/Shared/Engine/Sucrose.Shared.Engine/Extension/LocalHttpServer.cs
new file mode 100644
index 000000000..97e13c492
--- /dev/null
+++ b/src/Shared/Engine/Sucrose.Shared.Engine/Extension/LocalHttpServer.cs
@@ -0,0 +1,188 @@
+using System.IO;
+using System.Net;
+using SEET = Skylark.Enum.EncodeType;
+using SHE = Skylark.Helper.Encode;
+using SMMRF = Sucrose.Memory.Manage.Readonly.Folder;
+using SMMRG = Sucrose.Memory.Manage.Readonly.General;
+using SMMRP = Sucrose.Memory.Manage.Readonly.Path;
+using SSEMI = Sucrose.Shared.Engine.Manage.Internal;
+using SSSHP = Sucrose.Shared.Space.Helper.Port;
+
+namespace Sucrose.Shared.Engine.Extension
+{
+ internal class LocalHttpServer(string themeFolder, string customFolder = null)
+ {
+ private readonly int Port = SSSHP.Available(SSEMI.Loopback);
+ private readonly string Host = $"{SSEMI.Loopback}";
+ private readonly HttpListener Listener = new();
+
+ public string GetUrl()
+ {
+ return $"http://{Host}:{Port}/";
+ }
+
+ public async void StartAsync()
+ {
+ Listener.Prefixes.Add($"http://localhost:{Port}/");
+ Listener.Prefixes.Add($"http://{SSEMI.Loopback}:{Port}/");
+
+ if (string.IsNullOrEmpty(customFolder))
+ {
+ customFolder = Path.Combine(SMMRP.ApplicationData, SMMRG.AppName, SMMRF.Cache, SMMRF.Content);
+ }
+
+ if (Listener != null && !Listener.IsListening)
+ {
+ Listener.Start();
+
+ await Task.Run(async () =>
+ {
+ while (Listener.IsListening)
+ {
+ await Task.Run(async () =>
+ {
+ await HandleRequest(await Listener.GetContextAsync());
+ });
+ }
+ });
+ }
+ }
+
+ private string GetContentType(string filename)
+ {
+ string extension = Path.GetExtension(filename).ToLower();
+
+ return extension switch
+ {
+ ".rar" => "application/x-rar-compressed",
+ ".js" => "application/javascript",
+ ".hdr" => "image/vnd.radiance",
+ ".tar" => "application/x-tar",
+ ".json" => "application/json",
+ ".glb" => "model/gltf-binary",
+ ".gltf" => "model/gltf+json",
+ ".zip" => "application/zip",
+ ".xml" => "application/xml",
+ ".svg" => "image/svg+xml",
+ ".woff2" => "font/woff2",
+ ".md" => "text/markdown",
+ ".ico" => "image/x-icon",
+ ".webp" => "image/webp",
+ ".webm" => "video/webm",
+ ".tiff" => "image/tiff",
+ ".jpeg" => "image/jpeg",
+ ".woff" => "font/woff",
+ ".txt" => "text/plain",
+ ".jpg" => "image/jpeg",
+ ".mp3" => "audio/mpeg",
+ ".html" => "text/html",
+ ".wav" => "audio/wav",
+ ".png" => "image/png",
+ ".ogg" => "audio/ogg",
+ ".mp4" => "video/mp4",
+ ".htm" => "text/html",
+ ".gif" => "image/gif",
+ ".bmp" => "image/bmp",
+ ".ttf" => "font/ttf",
+ ".otf" => "font/otf",
+ ".csv" => "text/csv",
+ ".css" => "text/css",
+ _ => "application/octet-stream",
+ };
+ }
+
+ private async Task WriteFile(HttpListenerContext context, string path)
+ {
+ HttpListenerResponse response = context.Response;
+
+ try
+ {
+ using FileStream fs = File.OpenRead(path);
+
+ string filename = Path.GetFileName(path);
+
+ response.ContentLength64 = fs.Length;
+
+ response.SendChunked = true;
+ response.ContentType = GetContentType(path);
+ response.StatusCode = (int)HttpStatusCode.OK;
+ response.AddHeader("Content-Disposition", "inline; filename=\"" + filename + "\"");
+
+ byte[] buffer = new byte[64 * 1024];
+ int read;
+
+ using Stream outputStream = response.OutputStream;
+
+ while ((read = await fs.ReadAsync(buffer, 0, buffer.Length)) > 0)
+ {
+#if NET48_OR_GREATER
+ await outputStream.WriteAsync(buffer, 0, read);
+#else
+ await outputStream.WriteAsync(buffer.AsMemory(0, read));
+#endif
+
+ await outputStream.FlushAsync();
+ }
+ }
+ catch { }
+ }
+
+ private async Task HandleRequest(HttpListenerContext context)
+ {
+ HttpListenerResponse response = context.Response;
+
+ response.Headers.Add("Access-Control-Allow-Origin", "*");
+ response.Headers.Add("Access-Control-Allow-Headers", "Content-Type");
+ response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH");
+
+ string customPath = Path.Combine(customFolder, context.Request.Url.LocalPath.TrimStart('/'));
+ string themePath = Path.Combine(themeFolder, context.Request.Url.LocalPath.TrimStart('/'));
+
+ if (File.Exists(themePath) || File.Exists(customPath))
+ {
+ string path = string.Empty;
+
+ if (File.Exists(themePath))
+ {
+ path = themePath;
+ }
+ else
+ {
+ path = customPath;
+ }
+
+ await WriteFile(context, path);
+
+ //string filename = Path.GetFileName(path);
+ //byte[] content = File.ReadAllBytes(path);
+
+ //response.ContentLength64 = content.Length;
+ //response.StatusCode = (int)HttpStatusCode.NotModified;
+ //response.ContentType = GetContentType(path);
+
+ //await response.OutputStream.WriteAsync(content, 0, content.Length);
+ }
+ else
+ {
+ byte[] message = SHE.GetBytes("File not found", SEET.UTF8);
+
+ response.StatusCode = (int)HttpStatusCode.NotFound;
+
+ await response.OutputStream.WriteAsync(message, 0, message.Length);
+ }
+
+ response.OutputStream.Close();
+
+ response.Close();
+ }
+
+ public void Stop()
+ {
+ if (Listener != null && !Listener.IsListening)
+ {
+ Listener.Stop();
+ Listener.Close();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Source.cs b/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Source.cs
index 970d8d2da..1af7ef294 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Source.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Source.cs
@@ -172,22 +172,50 @@ public static void WriteVideoContent(string VideoContentPath, string Content)
public static string GetGifContentPath()
{
- return Path.Combine(SMMRP.ApplicationData, SMMRG.AppName, SMMRF.Cache, SMMRF.Content, SMMRC.Gif);
+ string GifPath = Path.Combine(SMMRP.ApplicationData, SMMRG.AppName, SMMRF.Cache, SMMRF.Content, SMMRC.Gif);
+
+ if (!Directory.Exists(Path.GetDirectoryName(GifPath)))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(GifPath));
+ }
+
+ return GifPath;
}
public static string GetImageContentPath()
{
- return Path.Combine(SMMRP.ApplicationData, SMMRG.AppName, SMMRF.Cache, SMMRF.Content, SMMRC.Image);
+ string ImagePath = Path.Combine(SMMRP.ApplicationData, SMMRG.AppName, SMMRF.Cache, SMMRF.Content, SMMRC.Image);
+
+ if (!Directory.Exists(Path.GetDirectoryName(ImagePath)))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(ImagePath));
+ }
+
+ return ImagePath;
}
public static string GetVideoContentPath()
{
- return Path.Combine(SMMRP.ApplicationData, SMMRG.AppName, SMMRF.Cache, SMMRF.Content, SMMRC.Video);
+ string VideoPath = Path.Combine(SMMRP.ApplicationData, SMMRG.AppName, SMMRF.Cache, SMMRF.Content, SMMRC.Video);
+
+ if (!Directory.Exists(Path.GetDirectoryName(VideoPath)))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(VideoPath));
+ }
+
+ return VideoPath;
}
public static string GetYouTubeContentPath()
{
- return Path.Combine(SMMRP.ApplicationData, SMMRG.AppName, SMMRF.Cache, SMMRF.Content, SMMRC.YouTube);
+ string YouTubePath = Path.Combine(SMMRP.ApplicationData, SMMRG.AppName, SMMRF.Cache, SMMRF.Content, SMMRC.YouTube);
+
+ if (!Directory.Exists(Path.GetDirectoryName(YouTubePath)))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(YouTubePath));
+ }
+
+ return YouTubePath;
}
public static Uri GetSource(Uri Source)
@@ -239,5 +267,17 @@ public static Uri GetSource(string Source, UriKind Kind = UriKind.RelativeOrAbso
return new Uri(Source, Kind);
}
}
+
+ public static Uri GetSource(string Source, string Host, UriKind Kind = UriKind.RelativeOrAbsolute)
+ {
+ if (SSTHV.IsUrl(Source))
+ {
+ return new Uri(Source, Kind);
+ }
+ else
+ {
+ return new Uri($"{Host}{Source}", Kind);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Manage/Internal.cs b/src/Shared/Engine/Sucrose.Shared.Engine/Manage/Internal.cs
index c75a025f5..241555bde 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine/Manage/Internal.cs
+++ b/src/Shared/Engine/Sucrose.Shared.Engine/Manage/Internal.cs
@@ -1,4 +1,5 @@
-using System.Windows.Threading;
+using System.Net;
+using System.Windows.Threading;
using SSDSHS = Sucrose.Shared.Dependency.Struct.HandleStruct;
using SSESB = Sucrose.Shared.Engine.Setting.Browser;
using SSTHC = Sucrose.Shared.Theme.Helper.Compatible;
@@ -23,6 +24,8 @@ internal static class Internal
public static SSTHP Properties = new();
+ public static string Host = string.Empty;
+
public static List Processes = new();
public static int IntermediateD3DWindow = 0;
@@ -71,6 +74,8 @@ internal static class Internal
public static string PropertiesCache = string.Empty;
+ public static IPAddress Loopback = IPAddress.Loopback;
+
public delegate Task ExecuteTask(string script);
public static CancellationTokenSource Displaying = new();
@@ -85,9 +90,10 @@ internal static class Internal
public static List WebArguments = new()
{
- "--enable-gpu",
- "--enable-gpu-vsync",
- "--disable-gpu-compositing",
+ //"--enable-gpu",
+ //"--enable-gpu-vsync",
+ //"--disable-gpu-compositing",
+
"--disable-direct-write",
//"--disable-frame-rate-limit",
"--enable-begin-frame-scheduling",
@@ -127,14 +133,17 @@ internal static class Internal
"--allow-file-access-from-file-urls",
"--allow-universal-access-from-files",
+ "--unsafely-disable-devtools-self-xss-warnings",
+
"--disable-features=MediaEngagementBypassAutoplayPolicies,BlockInsecurePrivateNetworkRequests,PreloadMediaEngagementData,OutOfBlinkCors,IsolateOrigins"
};
public static Dictionary CefArguments = new()
{
- { "enable-gpu", "1" },
- { "enable-gpu-vsync", "1" },
- { "disable-gpu-compositing", "1" },
+ //{ "enable-gpu", "1" },
+ //{ "enable-gpu-vsync", "1" },
+ //{ "disable-gpu-compositing", "1" },
+
{ "disable-direct-write", "1" },
//{ "disable-frame-rate-limit", "1" },
{ "enable-begin-frame-scheduling", "1" },
@@ -175,6 +184,8 @@ internal static class Internal
{ "allow-file-access-from-file-urls", "1" },
{ "allow-universal-access-from-files", "1" },
+ { "unsafely-disable-devtools-self-xss-warnings", "1" },
+
{ "disable-features", "MediaEngagementBypassAutoplayPolicies,BlockInsecurePrivateNetworkRequests,PreloadMediaEngagementData,OutOfBlinkCors,IsolateOrigins" }
};
}
diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems b/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems
index 61c4a4538..f155f2c8f 100644
--- a/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems
+++ b/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems
@@ -10,6 +10,7 @@
+
diff --git a/src/Shared/Sucrose.Shared.Space/Helper/Port.cs b/src/Shared/Sucrose.Shared.Space/Helper/Port.cs
new file mode 100644
index 000000000..30ce2f8da
--- /dev/null
+++ b/src/Shared/Sucrose.Shared.Space/Helper/Port.cs
@@ -0,0 +1,28 @@
+using System.Net;
+using System.Net.Sockets;
+
+namespace Sucrose.Shared.Space.Helper
+{
+ internal static class Port
+ {
+ public static int Available(IPAddress Host, int Default = 65432)
+ {
+ try
+ {
+ TcpListener Listener = new(Host, 0);
+
+ Listener.Start();
+
+ int Port = ((IPEndPoint)Listener.LocalEndpoint).Port;
+
+ Listener.Stop();
+
+ return Port;
+ }
+ catch
+ {
+ return Default;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Shared/Sucrose.Shared.Space/Sucrose.Shared.Space.projitems b/src/Shared/Sucrose.Shared.Space/Sucrose.Shared.Space.projitems
index 7eabb400c..db5fed2e9 100644
--- a/src/Shared/Sucrose.Shared.Space/Sucrose.Shared.Space.projitems
+++ b/src/Shared/Sucrose.Shared.Space/Sucrose.Shared.Space.projitems
@@ -20,6 +20,7 @@
+