webview-ffi 0.1.1
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 +7 -0
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +10 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/ext/webview/extconf.rb +8 -0
- data/ext/webview/webview.cc +3 -0
- data/ext/webview/webview.h +1348 -0
- data/lib/webview.rb +3 -0
- data/lib/webview/version.rb +5 -0
- data/lib/webview/webview.rb +64 -0
- data/webview.gemspec +40 -0
- metadata +92 -0
data/lib/webview.rb
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ffi"
|
|
4
|
+
require_relative "version"
|
|
5
|
+
|
|
6
|
+
class WebView
|
|
7
|
+
def initialize(title: "WebView", width: 320, height: 240, debug: false)
|
|
8
|
+
@title = title
|
|
9
|
+
@width = width
|
|
10
|
+
@height = height
|
|
11
|
+
|
|
12
|
+
@handle = webview_create(debug ? 1 : 0, nil)
|
|
13
|
+
ObjectSpace.define_finalizer(self, proc { webview_destroy(@handle); })
|
|
14
|
+
|
|
15
|
+
webview_set_title(@handle, @title)
|
|
16
|
+
webview_set_size(@handle, @width, @height, 0)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def navigate(page:)
|
|
20
|
+
webview_navigate(@handle, page)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def run
|
|
24
|
+
webview_run(@handle)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def terminate
|
|
28
|
+
webview_terminate(@handle)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def bind(fn_name:, fn_proc:)
|
|
32
|
+
f = FFI::Function.new(:void, [:string, :string, :pointer]) do |seq, req, arg|
|
|
33
|
+
fn_proc.call(req)
|
|
34
|
+
end
|
|
35
|
+
webview_bind(@handle, fn_name, f, nil)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def init(js:)
|
|
39
|
+
webview_init(@handle, js)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def evaluate(js:)
|
|
43
|
+
webview_eval(@handle, js)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
extend FFI::Library
|
|
49
|
+
ffi_lib ["so", "dll", "bundle"].map{|ext| File.dirname(__FILE__) + "/webview.#{ext}"}
|
|
50
|
+
|
|
51
|
+
attach_function :webview_create, [:int, :pointer], :pointer
|
|
52
|
+
attach_function :webview_destroy, [:pointer], :void
|
|
53
|
+
|
|
54
|
+
attach_function :webview_set_title, [:pointer, :string], :void
|
|
55
|
+
attach_function :webview_set_size, [:pointer, :int, :int, :int], :void
|
|
56
|
+
attach_function :webview_navigate, [:pointer, :string], :void
|
|
57
|
+
|
|
58
|
+
attach_function :webview_init, [:pointer, :string], :void
|
|
59
|
+
attach_function :webview_eval, [:pointer, :string], :void
|
|
60
|
+
attach_function :webview_bind, [:pointer, :string, :pointer, :pointer], :void
|
|
61
|
+
|
|
62
|
+
attach_function :webview_run, [:pointer], :void
|
|
63
|
+
attach_function :webview_terminate, [:pointer], :void
|
|
64
|
+
end
|
data/webview.gemspec
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/webview/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "webview-ffi"
|
|
7
|
+
spec.version = Webview::VERSION
|
|
8
|
+
spec.authors = ["Mohamed Anwer"]
|
|
9
|
+
spec.email = ["mohammed.ahmed.anwer@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Ruby FFI Binding to https://github.com/webview/webview."
|
|
12
|
+
spec.description = "Ruby FFI Binding to https://github.com/webview/webview Library."
|
|
13
|
+
spec.homepage = "https://github.com/tootis/webview-ffi"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
|
16
|
+
|
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
18
|
+
|
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/tootis/webview-ffi"
|
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/tootis/webview-ffi/README.md"
|
|
22
|
+
|
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
27
|
+
end
|
|
28
|
+
spec.bindir = "exe"
|
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
30
|
+
spec.require_paths = ["lib"]
|
|
31
|
+
|
|
32
|
+
spec.extensions = ["ext/webview/extconf.rb"]
|
|
33
|
+
|
|
34
|
+
# Uncomment to register a new dependency of your gem
|
|
35
|
+
spec.add_dependency "ffi", '~> 1.15'
|
|
36
|
+
spec.add_dependency "rake-compiler", '~> 1.0'
|
|
37
|
+
|
|
38
|
+
# For more information and examples about making a new gem, checkout our
|
|
39
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
40
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: webview-ffi
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mohamed Anwer
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-03-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: ffi
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.15'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.15'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake-compiler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.0'
|
|
41
|
+
description: Ruby FFI Binding to https://github.com/webview/webview Library.
|
|
42
|
+
email:
|
|
43
|
+
- mohammed.ahmed.anwer@gmail.com
|
|
44
|
+
executables: []
|
|
45
|
+
extensions:
|
|
46
|
+
- ext/webview/extconf.rb
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- ".github/workflows/main.yml"
|
|
50
|
+
- ".gitignore"
|
|
51
|
+
- ".rubocop.yml"
|
|
52
|
+
- CODE_OF_CONDUCT.md
|
|
53
|
+
- Gemfile
|
|
54
|
+
- LICENSE.txt
|
|
55
|
+
- README.md
|
|
56
|
+
- Rakefile
|
|
57
|
+
- bin/console
|
|
58
|
+
- bin/setup
|
|
59
|
+
- ext/webview/extconf.rb
|
|
60
|
+
- ext/webview/webview.cc
|
|
61
|
+
- ext/webview/webview.h
|
|
62
|
+
- lib/webview.rb
|
|
63
|
+
- lib/webview/version.rb
|
|
64
|
+
- lib/webview/webview.rb
|
|
65
|
+
- webview.gemspec
|
|
66
|
+
homepage: https://github.com/tootis/webview-ffi
|
|
67
|
+
licenses:
|
|
68
|
+
- MIT
|
|
69
|
+
metadata:
|
|
70
|
+
homepage_uri: https://github.com/tootis/webview-ffi
|
|
71
|
+
source_code_uri: https://github.com/tootis/webview-ffi
|
|
72
|
+
changelog_uri: https://github.com/tootis/webview-ffi/README.md
|
|
73
|
+
post_install_message:
|
|
74
|
+
rdoc_options: []
|
|
75
|
+
require_paths:
|
|
76
|
+
- lib
|
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: 2.3.0
|
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
|
+
requirements:
|
|
84
|
+
- - ">="
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: '0'
|
|
87
|
+
requirements: []
|
|
88
|
+
rubygems_version: 3.2.3
|
|
89
|
+
signing_key:
|
|
90
|
+
specification_version: 4
|
|
91
|
+
summary: Ruby FFI Binding to https://github.com/webview/webview.
|
|
92
|
+
test_files: []
|