webview_util 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +5 -2
- data/README.md +63 -53
- data/Rakefile +15 -15
- data/lib/webview_util/version.rb +1 -1
- metadata +5 -6
- data/CODE_OF_CONDUCT.md +0 -84
- data/Gemfile.lock +0 -50
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8784de795995e7fbbbff8554aad802774a712703c60957e4ce6650dfd7106845
|
|
4
|
+
data.tar.gz: bf53956d123d6e5fe8720144d8d5e8cae8913a22d5336c3976efd21cd8896527
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8776f21f98f1660e28d6abcaaed6f9e9e9edf976cf3b2112c22801cdf94a49ccd60f91df50189635970ea9d8d6db3c848c4c6210a73cbdbe3426f64f1a12bf31
|
|
7
|
+
data.tar.gz: 2cc70b46c74fb76de8a129835ec7fe7bea16518c726d41a1b9698509e6214b06ed0b522d7268cec2926a29a8e5b4b0763efe65ad10e6c770c08fbb53f78922d9
|
data/.rspec
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
# Specify your gem's dependencies in
|
|
5
|
+
# Specify your gem's dependencies in webview_util.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
+
gem "irb"
|
|
8
9
|
gem "rake", "~> 13.0"
|
|
9
10
|
|
|
10
|
-
gem "
|
|
11
|
+
gem "rspec", "~> 3.0"
|
|
11
12
|
|
|
12
13
|
gem "rubocop", "~> 1.21"
|
|
14
|
+
|
|
15
|
+
gem "simplecov", "~> 0.22"
|
data/README.md
CHANGED
|
@@ -1,108 +1,118 @@
|
|
|
1
|
-
#
|
|
1
|
+
# WebviewUtil
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
WebviewUtil provides Ruby bindings for [webview/webview](https://github.com/webview/webview), a small cross-platform library for building native desktop windows backed by a webview.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The gem exposes a compact `WebviewUtil::Window` wrapper around the native webview lifecycle: create a window, navigate it to a page, bind Ruby callbacks for JavaScript, evaluate JavaScript, and run the native event loop.
|
|
6
|
+
|
|
7
|
+
WebviewUtil continues Marco Concetto Rudilosso's earlier [`webview_ruby`](https://github.com/Maaarcocr/webview_ruby) gem under the rbutils namespace with the `WebviewUtil::Window` API.
|
|
8
|
+
|
|
9
|
+
The API is still evolving and should be considered unstable until version 1.0.
|
|
6
10
|
|
|
7
11
|
## Installation
|
|
8
12
|
|
|
9
13
|
Add this line to your application's Gemfile:
|
|
10
14
|
|
|
11
15
|
```ruby
|
|
12
|
-
gem
|
|
16
|
+
gem "webview_util"
|
|
13
17
|
```
|
|
14
18
|
|
|
15
19
|
And then execute:
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
```sh
|
|
22
|
+
bundle install
|
|
23
|
+
```
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
If you want the gem installed directly:
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
```sh
|
|
28
|
+
gem install webview_util
|
|
29
|
+
```
|
|
22
30
|
|
|
23
31
|
## Usage
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
```ruby
|
|
34
|
+
require "webview_util"
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
window = WebviewUtil::Window.new(
|
|
37
|
+
title: "Example",
|
|
38
|
+
width: 480,
|
|
39
|
+
height: 360,
|
|
40
|
+
debug: false
|
|
41
|
+
)
|
|
28
42
|
|
|
29
|
-
|
|
30
|
-
|
|
43
|
+
window.navigate("https://example.com")
|
|
44
|
+
window.run
|
|
31
45
|
```
|
|
32
46
|
|
|
33
|
-
|
|
47
|
+
`Window#run` blocks until the native window closes and destroys the webview before returning.
|
|
34
48
|
|
|
35
|
-
|
|
36
|
-
webview.set_title("Example")
|
|
37
|
-
webview.set_size(480, 360)
|
|
38
|
-
```
|
|
49
|
+
## JavaScript Integration
|
|
39
50
|
|
|
40
|
-
|
|
51
|
+
Bind a Ruby block so page JavaScript can call it by name:
|
|
41
52
|
|
|
42
53
|
```ruby
|
|
43
|
-
|
|
54
|
+
window = WebviewUtil::Window.new(title: "Bridge Example")
|
|
55
|
+
|
|
56
|
+
window.bind("exampleFunc") do |first, second|
|
|
57
|
+
puts "called from JavaScript with #{first.inspect} and #{second.inspect}"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
window.navigate("data:text/html,<script>exampleFunc('hello', 'ruby')</script>")
|
|
61
|
+
window.run
|
|
44
62
|
```
|
|
45
63
|
|
|
46
|
-
|
|
64
|
+
Run JavaScript from Ruby:
|
|
47
65
|
|
|
48
66
|
```ruby
|
|
49
|
-
|
|
50
|
-
webview.destroy
|
|
67
|
+
window.eval("console.log('Called from Ruby')")
|
|
51
68
|
```
|
|
52
69
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
You can bind a ruby function to a JavaScript one before the webview is in running state. To do so use the `bind` method like:
|
|
70
|
+
Inject JavaScript before page scripts run:
|
|
56
71
|
|
|
57
72
|
```ruby
|
|
58
|
-
|
|
59
|
-
print("got called by js")
|
|
60
|
-
end
|
|
73
|
+
window.init("console.log('running before page scripts')")
|
|
61
74
|
```
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
from the html. If you want to make a function take some parameters, just add parameters to the `do` block like so:
|
|
76
|
+
Close the window programmatically:
|
|
65
77
|
|
|
66
78
|
```ruby
|
|
67
|
-
|
|
68
|
-
print("got called by js with #{arg1} and #{arg2}")
|
|
69
|
-
end
|
|
79
|
+
window.terminate
|
|
70
80
|
```
|
|
71
81
|
|
|
72
|
-
|
|
82
|
+
## API
|
|
73
83
|
|
|
74
|
-
|
|
84
|
+
- `WebviewUtil::Window.new(title:, width:, height:, debug:)` creates a native webview window.
|
|
85
|
+
- `Window#navigate(url)` loads a URL or supported webview URI.
|
|
86
|
+
- `Window#run` enters the native event loop and destroys the webview on exit.
|
|
87
|
+
- `Window#terminate` requests event-loop termination.
|
|
88
|
+
- `Window#eval(js)` evaluates JavaScript asynchronously in the current page.
|
|
89
|
+
- `Window#init(js)` injects JavaScript before page scripts execute.
|
|
90
|
+
- `Window#bind(name, &block)` exposes a Ruby block as a JavaScript function and passes parsed JSON arguments to the block.
|
|
75
91
|
|
|
76
|
-
|
|
92
|
+
## Native Dependencies
|
|
77
93
|
|
|
78
|
-
|
|
79
|
-
webview.eval("console.log('Called from ruby')")
|
|
80
|
-
```
|
|
94
|
+
Webview uses platform webview components: Cocoa/WebKit on macOS, WebKitGTK on Linux, and WebView2 on Windows. Native headers and libraries must be available when the extension is compiled.
|
|
81
95
|
|
|
82
|
-
|
|
96
|
+
## Development
|
|
83
97
|
|
|
84
|
-
|
|
85
|
-
webview.terminate
|
|
86
|
-
```
|
|
98
|
+
After checking out the repo, install dependencies:
|
|
87
99
|
|
|
88
|
-
|
|
100
|
+
```sh
|
|
101
|
+
bundle install
|
|
102
|
+
```
|
|
89
103
|
|
|
90
|
-
|
|
104
|
+
Run the default checks:
|
|
91
105
|
|
|
92
|
-
```
|
|
93
|
-
|
|
106
|
+
```sh
|
|
107
|
+
bundle exec rake
|
|
94
108
|
```
|
|
95
109
|
|
|
96
|
-
|
|
110
|
+
The default Rake task compiles the native extension, runs the test task, and runs RuboCop.
|
|
97
111
|
|
|
98
112
|
## Contributing
|
|
99
113
|
|
|
100
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
114
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rbutils/webview_util.
|
|
101
115
|
|
|
102
116
|
## License
|
|
103
117
|
|
|
104
|
-
The gem is available as open source under the terms of the [MIT License](
|
|
105
|
-
|
|
106
|
-
## Code of Conduct
|
|
107
|
-
|
|
108
|
-
Everyone interacting in the WebviewRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/webview_ruby/blob/master/CODE_OF_CONDUCT.md).
|
|
118
|
+
The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
|
data/Rakefile
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "bundler/gem_tasks"
|
|
4
|
-
require "
|
|
5
|
-
require
|
|
4
|
+
require "ffi-compiler/compile_task"
|
|
5
|
+
require "rbconfig"
|
|
6
|
+
require "rspec/core/rake_task"
|
|
7
|
+
require "rubocop/rake_task"
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
FFI::Compiler::CompileTask.new("webview-ext") do |c|
|
|
10
|
+
if RbConfig::CONFIG["host_os"] =~ /darwin/
|
|
9
11
|
c.cxxflags << "-std=c++11"
|
|
10
12
|
c.ldflags << "-framework WebKit"
|
|
13
|
+
elsif RbConfig::CONFIG["host_os"] =~ /linux/
|
|
14
|
+
webkit = `pkg-config --exists webkit2gtk-4.1 2>/dev/null && echo 4.1 || echo 4.0`.strip
|
|
15
|
+
c.cxxflags << "-DWEBVIEW_GTK #{`pkg-config --cflags gtk+-3.0 webkit2gtk-#{webkit}`.strip}"
|
|
16
|
+
c.ldflags << `pkg-config --libs gtk+-3.0 webkit2gtk-#{webkit}`.strip
|
|
17
|
+
else
|
|
18
|
+
warn "Unsupported operating system; update the compile flags for this platform before building."
|
|
11
19
|
end
|
|
12
20
|
end
|
|
13
21
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
t.libs << "test"
|
|
17
|
-
t.libs << "lib"
|
|
18
|
-
t.test_files = FileList["test/**/test_*.rb"]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
task :test => :compile
|
|
22
|
-
|
|
23
|
-
require "rubocop/rake_task"
|
|
22
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
23
|
+
task spec: "#{RbConfig::CONFIG['arch']}/libwebview-ext.#{RbConfig::CONFIG['DLEXT']}"
|
|
24
24
|
|
|
25
25
|
RuboCop::RakeTask.new
|
|
26
26
|
|
|
27
|
-
task default: %i[
|
|
27
|
+
task default: %i[spec rubocop]
|
data/lib/webview_util/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: webview_util
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Concetto Rudilosso
|
|
@@ -45,11 +45,10 @@ extensions:
|
|
|
45
45
|
- ext/Rakefile
|
|
46
46
|
extra_rdoc_files: []
|
|
47
47
|
files:
|
|
48
|
+
- ".rspec"
|
|
48
49
|
- ".rubocop.yml"
|
|
49
50
|
- CHANGELOG.md
|
|
50
|
-
- CODE_OF_CONDUCT.md
|
|
51
51
|
- Gemfile
|
|
52
|
-
- Gemfile.lock
|
|
53
52
|
- LICENSE.txt
|
|
54
53
|
- README.md
|
|
55
54
|
- Rakefile
|
|
@@ -60,12 +59,12 @@ files:
|
|
|
60
59
|
- ext/webview/webview.h
|
|
61
60
|
- lib/webview_util.rb
|
|
62
61
|
- lib/webview_util/version.rb
|
|
63
|
-
homepage: https://github.com/rbutils/
|
|
62
|
+
homepage: https://github.com/rbutils/webview_util
|
|
64
63
|
licenses:
|
|
65
64
|
- MIT
|
|
66
65
|
metadata:
|
|
67
|
-
homepage_uri: https://github.com/rbutils/
|
|
68
|
-
source_code_uri: https://github.com/rbutils/
|
|
66
|
+
homepage_uri: https://github.com/rbutils/webview_util
|
|
67
|
+
source_code_uri: https://github.com/rbutils/webview_util
|
|
69
68
|
rdoc_options: []
|
|
70
69
|
require_paths:
|
|
71
70
|
- lib
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
-
|
|
7
|
-
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
-
|
|
9
|
-
## Our Standards
|
|
10
|
-
|
|
11
|
-
Examples of behavior that contributes to a positive environment for our community include:
|
|
12
|
-
|
|
13
|
-
* Demonstrating empathy and kindness toward other people
|
|
14
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
|
15
|
-
* Giving and gracefully accepting constructive feedback
|
|
16
|
-
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
17
|
-
* Focusing on what is best not just for us as individuals, but for the overall community
|
|
18
|
-
|
|
19
|
-
Examples of unacceptable behavior include:
|
|
20
|
-
|
|
21
|
-
* The use of sexualized language or imagery, and sexual attention or
|
|
22
|
-
advances of any kind
|
|
23
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
24
|
-
* Public or private harassment
|
|
25
|
-
* Publishing others' private information, such as a physical or email
|
|
26
|
-
address, without their explicit permission
|
|
27
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
28
|
-
professional setting
|
|
29
|
-
|
|
30
|
-
## Enforcement Responsibilities
|
|
31
|
-
|
|
32
|
-
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
33
|
-
|
|
34
|
-
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
35
|
-
|
|
36
|
-
## Scope
|
|
37
|
-
|
|
38
|
-
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
39
|
-
|
|
40
|
-
## Enforcement
|
|
41
|
-
|
|
42
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
|
|
43
|
-
|
|
44
|
-
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
45
|
-
|
|
46
|
-
## Enforcement Guidelines
|
|
47
|
-
|
|
48
|
-
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
49
|
-
|
|
50
|
-
### 1. Correction
|
|
51
|
-
|
|
52
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
|
53
|
-
|
|
54
|
-
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
55
|
-
|
|
56
|
-
### 2. Warning
|
|
57
|
-
|
|
58
|
-
**Community Impact**: A violation through a single incident or series of actions.
|
|
59
|
-
|
|
60
|
-
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
|
61
|
-
|
|
62
|
-
### 3. Temporary Ban
|
|
63
|
-
|
|
64
|
-
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
65
|
-
|
|
66
|
-
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
67
|
-
|
|
68
|
-
### 4. Permanent Ban
|
|
69
|
-
|
|
70
|
-
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
71
|
-
|
|
72
|
-
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
73
|
-
|
|
74
|
-
## Attribution
|
|
75
|
-
|
|
76
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
|
77
|
-
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
78
|
-
|
|
79
|
-
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
|
80
|
-
|
|
81
|
-
[homepage]: https://www.contributor-covenant.org
|
|
82
|
-
|
|
83
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
|
84
|
-
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile.lock
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
webview_ruby (0.1.0)
|
|
5
|
-
ffi
|
|
6
|
-
ffi-compiler
|
|
7
|
-
rake
|
|
8
|
-
|
|
9
|
-
GEM
|
|
10
|
-
remote: https://rubygems.org/
|
|
11
|
-
specs:
|
|
12
|
-
ast (2.4.2)
|
|
13
|
-
ffi (1.15.5)
|
|
14
|
-
ffi-compiler (1.0.1)
|
|
15
|
-
ffi (>= 1.0.0)
|
|
16
|
-
rake
|
|
17
|
-
minitest (5.15.0)
|
|
18
|
-
parallel (1.21.0)
|
|
19
|
-
parser (3.1.0.0)
|
|
20
|
-
ast (~> 2.4.1)
|
|
21
|
-
rainbow (3.1.1)
|
|
22
|
-
rake (13.0.6)
|
|
23
|
-
regexp_parser (2.2.0)
|
|
24
|
-
rexml (3.2.5)
|
|
25
|
-
rubocop (1.25.1)
|
|
26
|
-
parallel (~> 1.10)
|
|
27
|
-
parser (>= 3.1.0.0)
|
|
28
|
-
rainbow (>= 2.2.2, < 4.0)
|
|
29
|
-
regexp_parser (>= 1.8, < 3.0)
|
|
30
|
-
rexml
|
|
31
|
-
rubocop-ast (>= 1.15.1, < 2.0)
|
|
32
|
-
ruby-progressbar (~> 1.7)
|
|
33
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
|
34
|
-
rubocop-ast (1.15.1)
|
|
35
|
-
parser (>= 3.0.1.1)
|
|
36
|
-
ruby-progressbar (1.11.0)
|
|
37
|
-
unicode-display_width (2.1.0)
|
|
38
|
-
|
|
39
|
-
PLATFORMS
|
|
40
|
-
arm64-darwin-20
|
|
41
|
-
arm64-darwin-21
|
|
42
|
-
|
|
43
|
-
DEPENDENCIES
|
|
44
|
-
minitest (~> 5.0)
|
|
45
|
-
rake (~> 13.0)
|
|
46
|
-
rubocop (~> 1.21)
|
|
47
|
-
webview_ruby!
|
|
48
|
-
|
|
49
|
-
BUNDLED WITH
|
|
50
|
-
2.3.3
|