Rust bindings for Sciter

this page for other language bindings (Delphi / D / Go /

Rust bindings for Sciter

Check this page for other language bindings (Delphi / D / Go / .NET / Python / Rust).


Introduction

Sciter is an embeddable multiplatform HTML/CSS/script engine with GPU accelerated rendering designed to render modern desktop application UI. It's a compact, single dll/dylib/so file (4-8 mb) engine without any additional dependencies.

Screenshots

Check the screenshot gallery of desktop UI examples and DirectX UI integration via Rust GFX.

Description

Physically Sciter is a mono library which contains:

  • HTML and CSS rendering engine based on the H-SMILE core used in HTMLayout,
  • JavaScript in Sciter.JS,
  • JavaScript alike Scripting engine – core of TIScript which by itself is based on c-smile engine,
  • Persistent Database (a.k.a. JSON DB) based on excellent DB products of Konstantin Knizhnik.
  • Graphics module that uses native graphics primitives provided by supported platforms: Direct2D on Windows 7 and above, GDI+ on Windows XP, CoreGraphics on MacOS, Cairo on Linux/GTK. Yet there is an option to use built-in Skia/OpenGL backend on each platform.
  • Network communication module, it relies on platform HTTP client primitives and/or Libcurl.

Internally it contains the following modules:

  • CSS – CSS parser and the collection of parsed CSS rules, etc.
  • HTML DOM – HTML parser and DOM tree implementation.
  • layout managers – collection of various layout managers – text layout, default block layout, flex layouts. Support of positioned floating elements is also here. This module does the layout calculations heavy lifting. This module is also responsible for the rendering of layouts.
  • input behaviors – a collection of built-in behaviors – code behind "active" DOM elements: <input>, <select>, <textarea>, etc.
  • script module – source-to-bytecode compiler and virtual machine (VM) with compacting garbage collector (GC). This module also contains runtime implementation of standard classes and objects: Array, Object, Function and others.
  • script DOM – runtime classes that expose DOM and DOM view (a.k.a. window) to the script.
  • graphics abstraction layer – abstract graphics implementation that isolates the modules mentioned above from the particular platform details:
    • Direct2D/DirectWrite graphics backend (Windows);
    • GDI+ graphics backend (Windows);
    • CoreGraphics backend (Mac OS X);
    • Cairo backend (GTK on all Linux platforms);
    • Skia/OpenGL backend (all platforms)
  • core primitives – set of common primitives: string, arrays, hash maps and so on.

Sciter supports all standard elements defined in HTML5 specification with some additions. CSS is extended to better support the Desktop UI development, e.g. flow and flex units, vertical and horizontal alignment, OS theming.

Sciter SDK comes with a demo "browser" with a builtin DOM inspector, script debugger and documentation viewer:

Check https://sciter.com website and its documentation resources for engine principles, architecture and more.

Getting started:

  1. Download the Sciter.TIS or Sciter.JS SDK and extract it somewhere.
  2. Add the corresponding target platform binaries to PATH (bin.win, bin.osx or bin.lnx).
  3. If you do not already have it installed, you need GTK 3 development tools installed to continue: sudo apt-get install libgtk-3-dev
  4. Build the crate and run a minimal sciter sample: cargo run --example minimal.
  5. For your apps add the following dependency to the Cargo.toml: sciter-rs = "*".

Brief look:

Here is a minimal sciter app:

It looks similar to this:

Interoperability

In respect of tiscript or JavaScript functions calling:

Calling Rust from script can be implemented as following:

And we can access this function from TIScript:

or from JavaScript: `

Check rust-sciter/examples folder for more complex usage.

Library documentation.

What is supported right now:

  • sciter::window which brings together window creation, host and event handlers.
  • sciter::host with basic event handling, needs to be redesigned.
  • sciter::event_handler with event handling and auto dispatching script calls to native code.
  • sciter::dom for HTML DOM access and manipulation methods.
  • sciter::value Rust wrapper.
  • sciter::behavior_factory - global factory for native behaviors.
  • sciter::graphics - platform independent graphics native interface (can be used in native behaviors).
  • sciter::request - resource request object, used for custom resource downloading and handling.
  • sciter::video - custom video rendering.
  • sciter::archive - Sciter's compressed archive produced by sdk/bin/packfolder tool.
  • sciter::msg - backend-independent input event processing.
  • sciter::om - Sciter Object Model, extending Sciter by native code.
  • NSE - native Sciter extensions.

Platforms:

  • Windows
  • OSX
  • Linux
  • Raspberry Pi

License

Bindings library licensed under MIT license. Sciter Engine has the own license terms and end used license agreement for SDK usage.

Issues

Collection of the latest Issues

WesleiRamos

WesleiRamos

sciter-engine
8

I'm making an application where the user can create windows using their own html files, but it would require the windows to have a default behavior, so I developed a simple code that could be manually added by the user, but if there was a way to inject that code would make it a lot easier, I searched and found RuntimeOptions::InitScript, I tried calling a native function and nothing happened.

albertoVieiraNeto

albertoVieiraNeto

enhancement
4

hi, i have a license for sciter and already generated the sciter.static.lib, how should i proceed to embed the static library to my final executable? can you just give me a direction?

dclong

dclong

question
1

Tauri is a similar project which is also based on Rust and frontend technologies. I wonder what are the advantages and disadvantages of rust-sciter compared to tauri?

xq-tec

xq-tec

bug
2

There's a serious bug in the sciter::value::Value implementation related to std::ops::Index:

let mut v = sciter::value::Value::array(2);
v.set(0, 5);
v.set(1, 6);
let v_0 = &v[0];
let v_1 = &v[1];
dbg!(v_0);
dbg!(v_1);

This will print something like this, which is obviously incorrect:

[src/main.rs:176] v_0 = int:6
[src/main.rs:177] v_1 = int:6

The culprit is this code, which reuses the tmp field in a &self method:

#[allow(clippy::mut_from_ref)]
fn ensure_tmp_mut(&self) -> &mut Value {
    let cp = self as *const Value;
    let mp = cp as *mut Value;
    let me = unsafe { &mut *mp };
    return me.ensure_tmp();
}

fn ensure_tmp(&mut self) -> &mut Value { if self.tmp.is_null() { let tmp = Box::new(Value::new()); self.tmp = Box::into_raw(tmp); } return unsafe { &mut *self.tmp }; }

This isn't just a bug, it's also straight up Undefined Behavior. The Clippy mut_from_ref lint is there for a reason...

GirkovArpa

GirkovArpa

question
5

JavaScript cannot be called when using the Sciter.JS library. Nothing happens, except it returns Ok(undefined).

GirkovArpa

GirkovArpa

17

I'm on Windows 10 64bit.

I used sciter::Window::attach() to "attach" it to the GameMaker window.

Then called frame.load_html() and frame.run_app().

But the HTML isn't displayed. The GameMaker window freezes until I click the close button, then the game proceeds without the window being closed. It's as if the close button closes the attached (invisible) Sciter window the first time it's clicked.

If I use sciter::Window::create() instead, it works as expected, simply running the sciter application alongside the GameMaker game as 2 distinct programs.

But I want to embed the Sciter one as a transparent overlay.

regular-dev

regular-dev

3

Hello !

I've just build DOM example (https://github.com/sciter-sdk/rust-sciter/blob/master/examples/dom.rs) and run it, but all i see is blank white window.

I also tried to change from load_file to load_html to load site from memory( i've coppied html-code of site to minimal.htm) :

And it worked fine. So it seems like rust-sciter cannot load internet web page. Site is available, PC has internet connection. OS : ArchLinux

I also tried to run as root but no success.

domexample

Alovchin91

Alovchin91

5

Hi,

I'm trying out Sciter as a UI engine for my Rust app that runs on macOS.

I need a system menu, so I use cocoa crate to create a NSApplication and a NSWindow.

Unfortunately, I can't make sciter::Window::attach to work: it crashes every time I call it.

The code is pretty much as follows (menu creation is omitted):

It doesn't matter if I try to pass window itself or window.contentView() - it still crashes on sciter::Window::attach line with the following message:

Could you please help me to make it work? Thanks!

ngirard

ngirard

bug
3

This segfault can be easily reproduced by unzipping the minimal project I'm attaching, and typing cargo run.

This minimal application will display

and the main.css file is send to Sciter using on_data_load in the main.rs file.

Oddly enough:

  • when both

    lines are present, the segfault occurs ; but

  • when either one is present, the program runs fine.

segfault.zip

chris-morgan

chris-morgan

enhancement
6

I don’t know exactly where the fault may be, but when I run the examples they’re all low DPI on my 200% scaling factor Windows device. I know that Sciter itself must be capable of running high-DPI, because I tried out the HTML Notepad app and it’s scaled properly.

chris-morgan

chris-morgan

enhancement
5

The package name should be sciter, not sciter-rs. Package and crate names should not include a rust- prefix or -rs suffix, because we already know it’s Rust.

(The crate name is already sciter, which is correct; but you should basically never specify lib.name in Cargo.toml; it’s almost always the wrong thing to do.)

pravic

pravic

enhancement
0
  • sciter::Value: remove indexing (works via a hack now)
  • sciter::Value::isolate should be unsafe
  • s2w : return a single value only, s2wn returns value and length
  • window::with_size and K°: use window::Builder instead.
  • window size as array instead of tuple: [width, height] (why? totally forgot now)
  • window creation as result
  • proper error type (probably will break return types) - though our return types are compatible with std::error::Error now
  • Window::load_html and Window::load_file should return bool (even better - a proper Result)
  • Window::load_html and Window::load_file should return a proper Result
  • Window::load_file should accept AsPath trait
  • dom::Element:: get_value, get_hwnd, attribute, get_style_attribute should return result
  • dom::Element:: from_window, from_point, from_focus, from_highlighted should return Result<Option<Element>>
  • dom::Element:: get_tag, get_text should return a proper result
  • replace enums with associated constants #92
pravic

pravic

bug
3

So, here is a story.

Intro

Travis has only Precise and Trusty LTS versions (12 & 14) and Sciter does not work in there by default.

$ ./usciter ./usciter: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version CXXABI_1.3.8 not found ./usciter: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version GLIBCXX_3.4.21 not found

Dive

Let's check (click to expand)

$ ls /usr/lib/x86_64-linux-gnu/libstdc++.so.* /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19

$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep CXXABI CXXABI_1.3 CXXABI_1.3.1 CXXABI_1.3.2 CXXABI_1.3.3 CXXABI_1.3.4 CXXABI_1.3.5 CXXABI_1.3.6 CXXABI_1.3.7 CXXABI_TM_1

So, Ubuntu 14 contains libstdc++ 6.0.19 by default, while Ubuntu 16 or higher 6.0.24:

Click to expand

$ ls /usr/lib/x86_64-linux-gnu/libstdc++.so.* /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24

**$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep CXXABI CXXABI_1.3 CXXABI_1.3.1 CXXABI_1.3.2 CXXABI_1.3.3 CXXABI_1.3.4 CXXABI_1.3.5 CXXABI_1.3.6 CXXABI_1.3.7 CXXABI_1.3.8 CXXABI_1.3.9 CXXABI_1.3.10 CXXABI_1.3.11 CXXABI_TM_1 CXXABI_FLOAT128

It looks like we need a newer libstdc++ version. Right? Partly.

Fix?

Let's try to install it:

Now we have 6.0.24 and Sciter works: ./usciter shows its fancy window.

Nope

But: the rust-sciter still can't be compiled:

$ cargo build --example first ... error: linking with cc failed: exit code: 1 = note: ./libsciter-gtk-64.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_create(unsigned long&, unsigned collect2: error: ld returned 1 exit status

Whereas libstdc++ does contain the required GLIBCXX:

Click to expand

$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX GLIBCXX_3.4 GLIBCXX_3.4.1 GLIBCXX_3.4.2 GLIBCXX_3.4.3 GLIBCXX_3.4.4 GLIBCXX_3.4.5 GLIBCXX_3.4.6 GLIBCXX_3.4.7 GLIBCXX_3.4.8 GLIBCXX_3.4.9 GLIBCXX_3.4.10 GLIBCXX_3.4.11 GLIBCXX_3.4.12 GLIBCXX_3.4.13 GLIBCXX_3.4.14 GLIBCXX_3.4.15 GLIBCXX_3.4.16 GLIBCXX_3.4.17 GLIBCXX_3.4.18 GLIBCXX_3.4.19 GLIBCXX_3.4.20 GLIBCXX_3.4.21 GLIBCXX_3.4.22 GLIBCXX_3.4.23 GLIBCXX_3.4.24 GLIBCXX_DEBUG_MESSAGE_LENGTH

Summary

And now I am out of ideas.

I am still able to compile rust-sciter with a trick with RUSTFLAGS (export RUSTFLAGS='-C link-arg=-Wl,--unresolved-symbols=ignore-in-shared-libs'), but it will crash eventually during cargo test.

References

Apparently, GCC has introduced a so-called Dual ABI in 5.1: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html and most of issues with GLIBCXX are pointed to that story with advice to update GCC / update libstdc++ / recompile with -D_GLIBCXX_USE_CXX11_ABI=0 and so on.

Nothing helps here, of course, we don't have C++ code to recompile.

The only thing I have noticed in differences between Ubuntu 14 and 16: if I update GCC, it will show a suspicious flag in its configuration: --disable-libstdcxx-dual-abi (gcc version 7.2.0 (Ubuntu 7.2.0-1ubuntu1~14.04)) while GCC 7 on 16 does not have it (gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2) ).

harryfei

harryfei

enhancement
13

I think the native sciter sdk(c++ library) is multiple thread friendly. However, it sucks when I use this rust binding in a multiple thead situation.
Currently both sciter::Window and sciter::Host are not Sync or Send. Do you have any plan to change this?

Versions

Find the latest versions by id

0.5.56 - Apr 28, 2021

In 4.4.7.0 (Sciter and Sciter.JS) ISciterAPI was unified to have the same structure on all platforms and variants.

https://github.com/c-smile/sciter-js-sdk/blob/main/logfile.md#4470

0.5.53 - Jul 29, 2020

Changes since 0.5.39:

0.5.39 - Apr 16, 2018

More Sciter features:

And window::Builder for configurable window creation.

0.5.32 - Mar 19, 2018

See the sciter_serde::{from_value, to_value} functions at docs.rs.

0.4.10 - Feb 06, 2017

Support for Sciter 4.x versions.

Windows / Linux / OSX support. Published on crates.io.

0.4.2 - Feb 06, 2017

Latest release for Sciter 3.x versions.

Windows / Linux / OSX support.

v0.4.0 - Apr 12, 2016

Windows / Linux / OSX support.

Stable version.

Information - Updated Jan 12, 2022

Stars: 653
Forks: 51
Issues: 29

Rust bindings for libinjection

Add libinjection to dependencies of Cargo

Rust bindings for libinjection

Rust bindings for the shaderc library

Rust bindings for the Compiler interface to compile GLSL/HLSL

Rust bindings for the shaderc library

Rust bindings for the C++ api of PyTorch

LIghtweight wrapper for pytorch eg libtorch in rust

Rust bindings for the C++ api of PyTorch

Rust bindings to *nix APIs

wrapping the libc functionality with types/abstractions that enforce legal/safe

Rust bindings to *nix APIs

Rust bindings for the FLTK Graphical User Interface library

The fltk crate is a crossplatform lightweight gui library which can be statically linked to produce small, self-contained and fast gui applications

Rust bindings for the FLTK Graphical User Interface library

Rust bindings to bgfx, a cross-platform, graphics API agnostic, &quot;Bring Your Own Engine/Framework&quot; style rendering...

Rust bindings to wrapper for Rust exists, the code here takes a different approach and generate high-level bindings from the BGFX API examples an how...

Rust bindings to bgfx, a cross-platform, graphics API agnostic, &quot;Bring Your Own Engine/Framework&quot; style rendering...
Cargo

1.5K

Rust bindings for the python interpreter

Copyright (c) 2015-2021 Daniel Grunwald

Rust bindings for the python interpreter

Rust bindings for the NumPy C-API

Basically, our MSRV follows the one of ndarray for rust-side matrix library

Rust bindings for the NumPy C-API

Rust Bindings to AVX2-optimized SIP-like hash functions

bindings to three hash functions implemented in C++

Rust Bindings to AVX2-optimized SIP-like hash functions

Rust bindings for Torch

rs (torturous) is a set of Rust bindings for torch intended

Rust bindings for Torch

Rust bindings to libdeflate, a high-performance

Rust bindings to libdeflate

Rust bindings to libdeflate, a high-performance
Facebook Instagram Twitter GitHub Dribbble
Privacy