SciterSharpJS 3.0.3
dotnet add package SciterSharpJS --version 3.0.3
NuGet\Install-Package SciterSharpJS -Version 3.0.3
<PackageReference Include="SciterSharpJS" Version="3.0.3" />
<PackageVersion Include="SciterSharpJS" Version="3.0.3" />
<PackageReference Include="SciterSharpJS" />
paket add SciterSharpJS --version 3.0.3
#r "nuget: SciterSharpJS, 3.0.3"
#:package SciterSharpJS@3.0.3
#addin nuget:?package=SciterSharpJS&version=3.0.3
#tool nuget:?package=SciterSharpJS&version=3.0.3
SciterSharp — Sciter.JS bindings for .NET
C# bindings for the Sciter C/C++ API. Build native desktop apps for Windows and Linux with a UI written in HTML, CSS and JavaScript, rendered by Sciter.JS, and drive it from C#.
Sciter is a small embeddable HTML/CSS engine. It is not a browser, so your app ships without Chromium or Electron, and the native library is only a few MB.
Install
NuGet
dotnet add package SciterSharpJS
The SciterSharpJS package has 2 targets:
net8.0— Windows and Linux. The library picks the platform code at runtime.net8.0-windows— the same, plus the WinFormsSciterControland theSystem.Drawinghelpers.
The package includes the Sciter native libraries under runtimes/:
| RID | Native library |
|---|---|
win-x64 |
sciter.dll |
win-x86 |
sciter.dll |
linux-x64 |
libsciter.so |
linux-arm64 |
libsciter.so |
SciterSharpJS replaces the old SciterSharpWindows, SciterSharpGTK and SciterSharpOSX packages, which are no longer updated.
From source
git clone https://github.com/ramon-mendes/SciterSharp.git
Open SciterSharpJS.sln in Visual Studio 2022 (or later) and build. Then add a project reference to SciterSharp/SciterSharp.csproj.
Quick start
A minimal app has 3 parts: a window, a host, and an HTML page.
Program.cs
using SciterSharp;
using SciterSharp.Interop;
class Program
{
[STAThread]
static void Main()
{
// Required for drag and drop support on Windows
if (OperatingSystem.IsWindows())
PInvokeWindows.OleInitialize(IntPtr.Zero);
var wnd = new SciterMixinWindow();
wnd.CreateTopLevelWindow(new PInvokeUtils.RECT(800, 600));
wnd.CenterTopLevelWindow();
var host = new AppHost();
host.SetupWindow(wnd);
host.AttachEvh(new AppEventHandler());
wnd.LoadPage("file://" + Path.GetFullPath("res/index.html"));
wnd.Show();
wnd.Title = "My App";
PInvokeUtils.RunMsgLoop();
}
}
class AppHost : SciterHost
{
}
class AppEventHandler : SciterEventHandler
{
// Called from JavaScript with Window.this.xcall("Host_HelloWorld", ...)
public bool Host_HelloWorld(SciterElement el, SciterValue[] args, out SciterValue result)
{
result = new SciterValue("Hello from C#");
return true;
}
}
res/index.html
<html>
<head>
<script>
document.on("click", "button", () => {
const msg = Window.this.xcall("Host_HelloWorld");
document.$("#out").innerText = msg;
});
</script>
</head>
<body>
<button>Call C#</button>
<p id="out"></p>
</body>
</html>
For a complete sample, including how to pack the res/ folder into the executable with SciterArchive, see Tests/TestCoreApp.
Requirements
- .NET 8 SDK
- Windows 7 or later (x64 or x86), or Linux (x64 or arm64) with GTK 3
- Visual Studio 2022 or later, if you build from source on Windows
Linux support is new and has not been fully tested yet. macOS is not supported yet.
Your app must find the Sciter native library (sciter.dll on Windows, libsciter.so on Linux) at runtime. The NuGet package and a project reference both copy it to your output under runtimes/<rid>/native/, and SciterSharp loads it from there. You can also put the library next to your executable, or get it from the Sciter.JS SDK.
To see Sciter error messages in the Visual Studio Output window, enable native debugging: Project Properties > Debug > Enable native code debugging. You can also subclass SciterDebugOutputHandler to route the messages yourself.
API overview
The library has 2 namespaces:
SciterSharp— the public classes you use in your app.SciterSharp.Interop— P/Invoke definitions, the Sciter ABI, and low-level helpers.
Main classes and their mapping to the Sciter SDK:
| Class | Purpose |
|---|---|
SciterWindow / SciterMixinWindow |
Create a top-level, child or popup window (SciterCreateWindow), load HTML (SciterLoadPage), process window messages |
SciterHost |
Handle host notifications (SciterSetCallback), attach event handlers, register behaviors, call functions and evaluate script |
SciterEventHandler |
Base class for native event handlers. Public methods can be called from JavaScript with Window.this.xcall() |
SciterValue |
Sciter VALUE API. Convert data between C# and JavaScript (SciterValue.FromObject, JSON) |
SciterElement |
DOM element API (HELEMENT) |
SciterArchive |
Read files from a packed resource archive (SciterOpenArchive, SciterGetArchiveItem) |
SciterDebugOutputHandler |
Receive Sciter debug and console output |
SciterRequest |
Request API |
SciterGraphics, SciterImage, SciterPath, SciterText |
Graphics API (incomplete) |
SciterSharp.WinForms.SciterControl |
WinForms control that hosts a Sciter child window (net8.0-windows only) |
Contributing
Pull requests are welcome. Help is most useful for:
- WinForms and WPF integration on Sciter.JS
- Completing the Graphics API
- Adding XML documentation from the comments in the official Sciter SDK headers
Support
I do not have much time to maintain this project. For commercial support or specific help, contact me by email.
License
SciterSharp is licensed under the GNU General Public License v3.0.
Sciter itself is a separate product with its own license. Check the Sciter license terms before you ship your app.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
-
net8.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.