Giter Club home page Giter Club logo

webview_rust's Issues

Builder Pattern

Introduce builder pattern to instantiate the Webview instance which is the common and idiomatic approach in Rust.

Get events from window

Is your feature request related to a problem? Please describe.
I need to

  • get real file path when "drop file"

I want to

  • use custom drop area (e.g.: <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,

  1. get real file path when "drop file"
  2. use custom drop area (e.g.: <div data-tauri-drag />)

CI

We need to revise this CI to avoid using the stuff from the old Tauri CI.

Seperate ffi module to a file or even become another `*-sys`

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?

Support for Apple Silicon/ARM on MacOS Big Sur

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:

  1. Go to '.' (the project root)
  2. Run cargo build or cargo test
  3. See the error below
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 :/.

Fractional / HIDPI support (Windows)

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 :

  1. Displaying properly "fractional" pixels using (unknown to me) wizardry .
  2. A fallback that render the software at a "normal" scaling (100%) and then upscale the output to the desired scaling (125%) resulting in blurry renders.

Tauri, per default, is using the 2nd trick, resulting in blurry applications :
Screenshot of the issue, with a top Windows which is Firefox displaying the application properly, and Tauri being blurred
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:

  1. In the Windows 10's system settings, set the scaling to a fractional one.
  2. Start a Tauri project
  3. Build / Run dev
  4. See the blurriness

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)

Documentation

Add lint attributes #![warn(missing_doc)] to enforce all public interfaces have documentations.

bug: window titles are not showing up in macOS

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:

Screenshot 2020-07-31 at 22 38 48

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)

Expose webview-official-sys crate

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.

CC @eliassjogreen

[Feature/Docs] Ability to Cross Compile From Linux to Windows & Mac

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.

WebView Abstraction Layer and Winit

To implement RFC#0001, there's two necessary changes, and one change that would shift more power to our side of the interop.

Bindings abstraction

This would take the form of a single Rust trait. Said trait will have the following properties:

  • Functions for all possible operations, including target-specific.
  • Associated constants Option<&'static str> for target_os and target_family, for build assertion purposes.
  • An initialization function that would take a Window Handle (and more?), and return Self.

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.

Switch to zserge's Web View for Defaults

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.

Winit

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.