webview / webview_rust Goto Github PK
View Code? Open in Web Editor NEW[wip] Rust Bindings to webview
License: MIT License
[wip] Rust Bindings to webview
License: MIT License
Introduce builder pattern to instantiate the Webview
instance which is the common and idiomatic approach in Rust.
Is your feature request related to a problem? Please describe.
I need to
I want to
<div data-tauri-drag />
)Describe the solution you'd like
I want to create window using "winit" attach webview on it.
This might solve "drop file" issue https://github.com/tauri-apps/tauri/issues/993.
Describe alternatives you've considered
What I wanna do is,
<div data-tauri-drag />
)We need to revise this CI to avoid using the stuff from the old Tauri CI.
When creating FFI bindings, we usually will create another *-sys
crate for the raw binding (which is what ffi module does right now). But I tend to know that it might be tedious to maintain two crates even it's not really necessary. Maybe it's also idiomatic to move it to a standalone file as sys
module?
Describe the bug
When trying to build webview rust on MacOS with Apple Silicon/ARM the build script fails.
To Reproduce
Steps to reproduce the behavior:
cargo build
or cargo test
error: failed to run custom build command for `webview-official-sys v0.1.0 (/Users/byron/dev/webview_rust/webview-official-sys)`
Caused by:
process didn't exit successfully: `/Users/byron/dev/webview_rust/target/debug/build/webview-official-sys-c458bcfd287ba625/build-script-build` (exit code: 1)
--- stdout
cargo:rustc-link-lib=framework=Cocoa
cargo:rustc-link-lib=framework=WebKit
cargo:rerun-if-changed=webview-official/webview.h
cargo:rerun-if-changed=webview-official/webview.cc
TARGET = Some("aarch64-apple-darwin")
OPT_LEVEL = Some("0")
HOST = Some("aarch64-apple-darwin")
CXX_aarch64-apple-darwin = None
CXX_aarch64_apple_darwin = None
HOST_CXX = None
CXX = None
CXXFLAGS_aarch64-apple-darwin = None
CXXFLAGS_aarch64_apple_darwin = None
HOST_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = None
CXX_aarch64-apple-darwin = None
CXX_aarch64_apple_darwin = None
HOST_CXX = None
CXX = None
CXXFLAGS_aarch64-apple-darwin = None
CXXFLAGS_aarch64_apple_darwin = None
HOST_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = None
CXX_aarch64-apple-darwin = None
CXX_aarch64_apple_darwin = None
HOST_CXX = None
CXX = None
CXXFLAGS_aarch64-apple-darwin = None
CXXFLAGS_aarch64_apple_darwin = None
HOST_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = None
running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-arch" "arm64" "-I" "webview-official/webview.h" "-Wall" "-Wextra" "-std=c++11" "-w" "-o" "/Users/byron/dev/webview_rust/target/debug/build/webview-official-sys-2a67ef4fc041c24f/out/webview-official/webview.o" "-c" "webview-official/webview.cc"
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:576:10: error: no matching function for call to 'objc_msgSend'
cargo:warning= return objc_msgSend("NSString"_cls, "stringWithUTF8String:"_sel, s);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 3 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:583:14: error: no matching function for call to 'objc_msgSend'
cargo:warning= id app = objc_msgSend("NSApplication"_cls, "sharedApplication"_sel);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 2 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:584:5: error: no matching function for call to 'objc_msgSend'
cargo:warning= objc_msgSend(app, "setActivationPolicy:"_sel,
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 3 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:599:27: error: no matching function for call to 'objc_msgSend'
cargo:warning= objc_msgSend(msg, "body"_sel), "UTF8String"_sel));
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 2 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:604:21: error: no matching function for call to 'objc_msgSend'
cargo:warning= auto delegate = objc_msgSend((id)cls, "new"_sel);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 2 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:611:18: error: no matching function for call to 'objc_msgSend'
cargo:warning= m_window = objc_msgSend("NSWindow"_cls, "alloc"_sel);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 2 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:612:18: error: no matching function for call to 'objc_msgSend'
cargo:warning= m_window = objc_msgSend(
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 6 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:620:19: error: no matching function for call to 'objc_msgSend'
cargo:warning= auto config = objc_msgSend("WKWebViewConfiguration"_cls, "new"_sel);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 2 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:622:17: error: no matching function for call to 'objc_msgSend'
cargo:warning= m_webview = objc_msgSend("WKWebView"_cls, "alloc"_sel);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 2 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:626:20: error: no matching function for call to 'objc_msgSend'
cargo:warning= objc_msgSend("NSNumber"_cls, "numberWithBool:"_sel, 1),
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 3 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:640:5: error: no matching function for call to 'objc_msgSend'
cargo:warning= objc_msgSend(m_window, "setContentView:"_sel, m_webview);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 3 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:641:5: error: no matching function for call to 'objc_msgSend'
cargo:warning= objc_msgSend(m_window, "makeKeyAndOrderFront:"_sel, nullptr);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 3 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:647:5: error: no matching function for call to 'objc_msgSend'
cargo:warning= objc_msgSend("NSApp"_cls, "terminate:"_sel, nullptr);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 3 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:650:14: error: no matching function for call to 'objc_msgSend'
cargo:warning= id app = objc_msgSend("NSApplication"_cls, "sharedApplication"_sel);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 2 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:651:22: error: no matching function for call to 'objc_msgSend'
cargo:warning= dispatch([&]() { objc_msgSend(app, "activateIgnoringOtherApps:"_sel, 1); });
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 3 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:652:5: error: no matching function for call to 'objc_msgSend'
cargo:warning= objc_msgSend(app, "run"_sel);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 2 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:664:18: error: no matching function for call to 'objc_msgSend'
cargo:warning= objc_msgSend("NSString"_cls, "stringWithUTF8String:"_sel,
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 3 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:673:5: error: no matching function for call to 'objc_msgSend'
cargo:warning= objc_msgSend(m_window, "setStyleMask:"_sel, style);
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 3 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=In file included from webview-official/webview.cc:3:
cargo:warning=webview-official/webview.h:676:7: error: no matching function for call to 'objc_msgSend'
cargo:warning= objc_msgSend(m_window, "setContentMinSize:"_sel,
cargo:warning= ^~~~~~~~~~~~
cargo:warning=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/message.h:63:1: note: candidate function not viable: requires 0 arguments, but 3 were provided
cargo:warning=objc_msgSend(void /* id self, SEL op, ... */ )
cargo:warning=^
cargo:warning=fatal error: too many errors emitted, stopping now [-ferror-limit=]
cargo:warning=20 errors generated.
exit code: 1
--- stderr
Expected behavior
The build should succeed.
If applicable, add screenshots to help explain your problem.
Platform and Versions (please complete the following information):
OS: MacOS 11.1 on Apple Silicon (M1)
Rustc: rustc 1.49.0-beta.4 (877c7cbe1 2020-12-10)
Additional context
In the file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/objc-api.h
line 99 there is the following:
/* The arm64 ABI requires proper casting to ensure arguments are passed
* * correctly. */
#if defined(__arm64__) && !__swift__
# undef OBJC_OLD_DISPATCH_PROTOTYPES
# define OBJC_OLD_DISPATCH_PROTOTYPES 0
#endif
It explains why explicitly setting the directive isn't effective there.
Maybe it's possible to use the actual signature, even though I can't tell what these are supposed to be by looking at the header :/.
Follow-up of webview/webview#54
In short, on Windows 10 (maybe 8 and 7, can't check), there is an option to use fractional resolutions for the interface (and all application), meaning that you can pick 100%, 125%, 150% 175%, 200% and so on.
The thing is, fractional pixels doesn't exists, where 100% and 200% are simple to implement since you just have to double the pixel's size (2x2 instead of 1x1), in-between values are more tricky.
Windows seems to rely on two different tricks to support those :
Tauri, per default, is using the 2nd trick, resulting in blurry applications :
Screenshot of the issue, with a top window which is Firefox displaying the application properly, and the bottom window a Tauri app being blurred
Steps to reproduce this behaviour:
Thankfully, thanks to @Ciantic works, it seems to be pretty trivial to fix this issue, here is the solution provided by them : webview/webview#54 (comment)
Add lint attributes #![warn(missing_doc)]
to enforce all public interfaces have documentations.
Describe the bug
Titles in the webview window are not showing up in macOS when running examples in this repo.
To Reproduce
Run the examples in a macOS machine.
Expected behavior
The title "TEST" should appear in the top of this window.
Screenshots
Screenshot of window opened with the sample
example:
Platform and Versions (please complete the following information):
OS: 64bit Mac OS X 10.15.6 19G73
Rustc: rustc 1.45.0 (5c1f21c3b 2020-07-13)
Is your feature request related to a problem? Please describe.
We are encountering some issues handling Webview rust wrapper types in a multithreaded environment while creating webview bindings for webview/webview_deno. We would like to have more control over the actual c_void pointers that currently are not exposed by the crate.
Describe the solution you'd like
sys
bindings should be exported from the crate, or be made available in a separate crate.
Describe alternatives you've considered
Taking the code that we need directly for this repository, removing the dependency from webview_official (this crate). This approach is feasible but we think that the correct approach is to expose the bindings directly.
Is your feature request related to a problem? Please describe.
I prefer to build applications in Linux Docker containers for maximum automation, reproducibility, and build portability. That said, I still need to be able to build applications for Windows and Mac and I have since done that by cross compiling the application using MingW for windows and OSX Cross for Mac. Without being able to cross compile from Linux, you have to use a CI service that provides all three operating systems. While these exist, and they are free for Open Source projects, I prefer to be able to host these builds myself when necessary and the most cost effective and simple way to do that is by cross compiling from Linux.
Describe the solution you'd like
I would like to work out the required build steps and tools necessary to cross-compile for Windows and Mac from Linux.
Describe alternatives you've considered
Going with GitHub Actions for automated builds is definitely a decent option, but again, I prefer to be able to produce these same builds on my local machine and using Linux Docker containers is the most productive way to do that.
Additional context
If we get this working I am going to be building my Tauri application with Drone and could easily derive a template build that could be used for other's Tauri applications, allowing people to build for all three platforms using only Linux servers on either the public Drone cloud, or their own build farm.
To implement RFC#0001, there's two necessary changes, and one change that would shift more power to our side of the interop.
This would take the form of a single Rust trait. Said trait will have the following properties:
Option<&'static str>
for target_os
and target_family
, for build assertion purposes.This trait should be exposed via another crate, so bindings can be specified as a crate name or git repo. The bundler should then load the implementations appropriately. Tauri should provide a generic function. The bundler should worry about which implementation to pick for the target, the generated binary code should be target-specific.
As per the RFC, we are moving away from Boscop. Boscop doesn't allow us to control the window, so this is a necessary step in this set of changes.
Currently, there are functionalities of Electron that we can't copy without controlling the window itself. Therefore, it's imperative that we have control, and I would have us use Winit to this end. Winit can provide a pointer to the raw Window Handle, and can handle most, if not all, of our window management needs. This would have the lovely side effect of providing more power to our Rust users, rather than letting responsibilities get moved into the web view's space.
Provide an internal function to convert callback in Rust to C pointers. And since the trait bound of this generic would probably be Fn
-series. It could also support closures (which is common case in Tauri).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.