ruflet_core 0.0.12 → 0.0.13
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/lib/ruflet/version.rb +1 -1
- data/lib/ruflet_protocol/ruflet/protocol.rb +50 -4
- data/lib/ruflet_ui/ruflet/control.rb +11 -4
- data/lib/ruflet_ui/ruflet/dsl.rb +229 -37
- data/lib/ruflet_ui/ruflet/events/gesture_events.rb +113 -9
- data/lib/ruflet_ui/ruflet/page.rb +820 -145
- data/lib/ruflet_ui/ruflet/types/animation.rb +110 -0
- data/lib/ruflet_ui/ruflet/ui/control_registry.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactionsheet_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactionsheetaction_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactivityindicator_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoalertdialog_control.rb +17 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoappbar_control.rb +3 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinobottomsheet_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinobutton_control.rb +9 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocheckbox_control.rb +6 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocontextmenu_control.rb +11 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocontextmenuaction_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinodatepicker_control.rb +14 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinodialogaction_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinofilledbutton_control.rb +9 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinolisttile_control.rb +12 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinonavigationbar_control.rb +11 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinopicker_control.rb +18 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoradio_control.rb +6 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinosegmentedbutton_control.rb +2 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoslider_control.rb +7 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoslidingsegmentedbutton_control.rb +3 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoswitch_control.rb +7 -1
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotextfield_control.rb +7 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotimerpicker_control.rb +18 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotintedbutton_control.rb +9 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/alertdialog_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/appbar_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/audio_control.rb +35 -1
- data/lib/ruflet_ui/ruflet/ui/controls/materials/autocomplete_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/autocompletesuggestion_control.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/badge_control.rb +7 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/banner_control.rb +11 -1
- data/lib/ruflet_ui/ruflet/ui/controls/materials/bottomappbar_control.rb +2 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/bottomsheet_control.rb +5 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/button_control.rb +2 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/card_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/chip_control.rb +11 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/circleavatar_control.rb +12 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/contextmenu_control.rb +19 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datacell_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datacolumn_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datatable_control.rb +34 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datepicker_control.rb +18 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/daterangepicker_control.rb +20 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/divider_control.rb +9 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdown_control.rb +11 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdownoption_control.rb +5 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/expansionpanel_control.rb +8 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/expansionpanellist_control.rb +6 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/expansiontile_control.rb +6 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/filledbutton_control.rb +5 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/fillediconbutton_control.rb +8 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/filledtonalbutton_control.rb +5 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/filledtonaliconbutton_control.rb +8 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/floatingactionbutton_control.rb +20 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/iconbutton_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/listtile_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/map_controls.rb +240 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/menubar_control.rb +2 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/menuitembutton_control.rb +6 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationbar_control.rb +11 -1
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationbardestination_control.rb +2 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationdrawer_control.rb +12 -1
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationdrawerdestination_control.rb +2 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationrail_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationraildestination_control.rb +2 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/outlinedbutton_control.rb +5 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/outlinediconbutton_control.rb +8 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/popupmenubutton_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/popupmenuitem_control.rb +6 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/progressbar_control.rb +9 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/progressring_control.rb +8 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/rangeslider_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/ruflet_controls.rb +24 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/searchbar_control.rb +28 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/segment_control.rb +5 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/segmentedbutton_control.rb +19 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/selectionarea_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/snackbar_control.rb +5 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/submenubutton_control.rb +8 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tab_control.rb +7 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tabbar_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tabbarview_control.rb +7 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tabs_control.rb +6 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/textbutton_control.rb +5 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/verticaldivider_control.rb +9 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/video_control.rb +86 -1
- data/lib/ruflet_ui/ruflet/ui/controls/ruflet_controls.rb +24 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/animatedswitcher_control.rb +10 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/browsercontextmenu_control.rb +12 -1
- data/lib/ruflet_ui/ruflet/ui/controls/shared/canvas_control.rb +14 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/dismissible_control.rb +19 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/draggable_control.rb +9 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/dragtarget_control.rb +6 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/gridview_control.rb +20 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/image_control.rb +19 -1
- data/lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb +37 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/listview_control.rb +17 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/pageview_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/placeholder_control.rb +12 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/reorderabledraghandle_control.rb +4 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/responsiverow_control.rb +22 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/safearea_control.rb +11 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/semantics_control.rb +2 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/stack_control.rb +3 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/text_control.rb +20 -1
- data/lib/ruflet_ui/ruflet/ui/controls/shared/view_control.rb +8 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/window_control.rb +16 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/windowdragarea_control.rb +6 -0
- data/lib/ruflet_ui/ruflet/ui/cupertino_control_methods.rb +83 -6
- data/lib/ruflet_ui/ruflet/ui/material_control_methods.rb +513 -33
- data/lib/ruflet_ui/ruflet/ui/material_control_registry.rb +2 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/audio_recorder_control.rb +87 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/geolocator_control.rb +85 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/permissionhandler_control.rb +53 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/securestorage_control.rb +89 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/semanticsservice_control.rb +28 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/tester_control.rb +126 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet_services.rb +16 -0
- data/lib/ruflet_ui/ruflet/ui/shared_control_forwarders.rb +230 -38
- data/lib/ruflet_ui.rb +4 -0
- metadata +9 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ruflet
|
|
4
|
+
module UI
|
|
5
|
+
module Services
|
|
6
|
+
module RufletServicesComponents
|
|
7
|
+
class AudioRecorderControl < Ruflet::Control
|
|
8
|
+
TYPE = "audiorecorder".freeze
|
|
9
|
+
WIRE = "AudioRecorder".freeze
|
|
10
|
+
|
|
11
|
+
def initialize(id: nil, configuration: nil, data: nil, key: nil, on_state_change: nil, on_stream: nil, on_upload: nil)
|
|
12
|
+
props = {}
|
|
13
|
+
props[:configuration] = configuration unless configuration.nil?
|
|
14
|
+
props[:data] = data unless data.nil?
|
|
15
|
+
props[:key] = key unless key.nil?
|
|
16
|
+
props[:on_state_change] = on_state_change unless on_state_change.nil?
|
|
17
|
+
props[:on_stream] = on_stream unless on_stream.nil?
|
|
18
|
+
props[:on_upload] = on_upload unless on_upload.nil?
|
|
19
|
+
super(type: TYPE, id: id, **props)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
%w[
|
|
23
|
+
cancel_recording
|
|
24
|
+
get_input_devices
|
|
25
|
+
has_permission
|
|
26
|
+
is_paused
|
|
27
|
+
is_recording
|
|
28
|
+
pause_recording
|
|
29
|
+
resume_recording
|
|
30
|
+
stop_recording
|
|
31
|
+
].each do |method_name|
|
|
32
|
+
define_method(method_name) do |timeout: 10, on_result: nil|
|
|
33
|
+
invoke_audio_recorder(method_name, timeout: timeout, on_result: on_result)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def is_supported_encoder(encoder, timeout: 10, on_result: nil)
|
|
38
|
+
invoke_audio_recorder(
|
|
39
|
+
"is_supported_encoder",
|
|
40
|
+
args: { "encoder" => normalize_service_value(encoder) },
|
|
41
|
+
timeout: timeout,
|
|
42
|
+
on_result: on_result
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def start_recording(output_path: nil, configuration: nil, upload: nil, timeout: 10, on_result: nil)
|
|
47
|
+
invoke_audio_recorder(
|
|
48
|
+
"start_recording",
|
|
49
|
+
args: compact_args(
|
|
50
|
+
"output_path" => output_path,
|
|
51
|
+
"configuration" => configuration,
|
|
52
|
+
"upload" => upload
|
|
53
|
+
),
|
|
54
|
+
timeout: timeout,
|
|
55
|
+
on_result: on_result
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
def invoke_audio_recorder(method_name, args: nil, timeout:, on_result:)
|
|
62
|
+
runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def compact_args(hash)
|
|
66
|
+
hash.each_with_object({}) do |(key, value), result|
|
|
67
|
+
result[key] = normalize_service_value(value) unless value.nil?
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def normalize_service_value(value)
|
|
72
|
+
case value
|
|
73
|
+
when Array
|
|
74
|
+
value.map { |item| normalize_service_value(item) }
|
|
75
|
+
when Hash
|
|
76
|
+
value.transform_keys(&:to_s).each_with_object({}) do |(key, item), result|
|
|
77
|
+
result[key] = normalize_service_value(item) unless item.nil?
|
|
78
|
+
end
|
|
79
|
+
else
|
|
80
|
+
value.respond_to?(:to_h) ? normalize_service_value(value.to_h) : value
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ruflet
|
|
4
|
+
module UI
|
|
5
|
+
module Services
|
|
6
|
+
module RufletServicesComponents
|
|
7
|
+
class GeolocatorControl < Ruflet::Control
|
|
8
|
+
TYPE = "geolocator".freeze
|
|
9
|
+
WIRE = "Geolocator".freeze
|
|
10
|
+
|
|
11
|
+
def initialize(id: nil, configuration: nil, data: nil, key: nil, on_error: nil, on_position_change: nil)
|
|
12
|
+
props = {}
|
|
13
|
+
props[:configuration] = configuration unless configuration.nil?
|
|
14
|
+
props[:data] = data unless data.nil?
|
|
15
|
+
props[:key] = key unless key.nil?
|
|
16
|
+
props[:on_error] = on_error unless on_error.nil?
|
|
17
|
+
props[:on_position_change] = on_position_change unless on_position_change.nil?
|
|
18
|
+
super(type: TYPE, id: id, **props)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
%w[
|
|
22
|
+
get_last_known_position
|
|
23
|
+
get_permission_status
|
|
24
|
+
is_location_service_enabled
|
|
25
|
+
open_app_settings
|
|
26
|
+
open_location_settings
|
|
27
|
+
request_permission
|
|
28
|
+
].each do |method_name|
|
|
29
|
+
define_method(method_name) do |timeout: 10, on_result: nil|
|
|
30
|
+
invoke_geolocator(method_name, timeout: timeout, on_result: on_result)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def distance_between(start_latitude, start_longitude, end_latitude, end_longitude, timeout: 10, on_result: nil)
|
|
35
|
+
invoke_geolocator(
|
|
36
|
+
"distance_between",
|
|
37
|
+
args: {
|
|
38
|
+
"start_latitude" => start_latitude,
|
|
39
|
+
"start_longitude" => start_longitude,
|
|
40
|
+
"end_latitude" => end_latitude,
|
|
41
|
+
"end_longitude" => end_longitude
|
|
42
|
+
},
|
|
43
|
+
timeout: timeout,
|
|
44
|
+
on_result: on_result
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def get_current_position(configuration: nil, timeout: 10, on_result: nil)
|
|
49
|
+
invoke_geolocator(
|
|
50
|
+
"get_current_position",
|
|
51
|
+
args: compact_args("configuration" => configuration),
|
|
52
|
+
timeout: timeout,
|
|
53
|
+
on_result: on_result
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
def invoke_geolocator(method_name, args: nil, timeout:, on_result:)
|
|
60
|
+
runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def compact_args(hash)
|
|
64
|
+
hash.each_with_object({}) do |(key, value), result|
|
|
65
|
+
result[key] = normalize_service_value(value) unless value.nil?
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def normalize_service_value(value)
|
|
70
|
+
case value
|
|
71
|
+
when Array
|
|
72
|
+
value.map { |item| normalize_service_value(item) }
|
|
73
|
+
when Hash
|
|
74
|
+
value.transform_keys(&:to_s).each_with_object({}) do |(key, item), result|
|
|
75
|
+
result[key] = normalize_service_value(item) unless item.nil?
|
|
76
|
+
end
|
|
77
|
+
else
|
|
78
|
+
value.respond_to?(:to_h) ? normalize_service_value(value.to_h) : value
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ruflet
|
|
4
|
+
module UI
|
|
5
|
+
module Services
|
|
6
|
+
module RufletServicesComponents
|
|
7
|
+
class PermissionHandlerControl < Ruflet::Control
|
|
8
|
+
TYPE = "permissionhandler".freeze
|
|
9
|
+
WIRE = "PermissionHandler".freeze
|
|
10
|
+
|
|
11
|
+
def initialize(id: nil, data: nil, key: nil)
|
|
12
|
+
props = {}
|
|
13
|
+
props[:data] = data unless data.nil?
|
|
14
|
+
props[:key] = key unless key.nil?
|
|
15
|
+
super(type: TYPE, id: id, **props)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_status(permission, timeout: 10, on_result: nil)
|
|
19
|
+
invoke_permission_handler(
|
|
20
|
+
"get_status",
|
|
21
|
+
args: { "permission" => normalize_service_value(permission) },
|
|
22
|
+
timeout: timeout,
|
|
23
|
+
on_result: on_result
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def request(permission, timeout: 10, on_result: nil)
|
|
28
|
+
invoke_permission_handler(
|
|
29
|
+
"request",
|
|
30
|
+
args: { "permission" => normalize_service_value(permission) },
|
|
31
|
+
timeout: timeout,
|
|
32
|
+
on_result: on_result
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def open_app_settings(timeout: 10, on_result: nil)
|
|
37
|
+
invoke_permission_handler("open_app_settings", timeout: timeout, on_result: on_result)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def invoke_permission_handler(method_name, args: nil, timeout:, on_result:)
|
|
43
|
+
runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def normalize_service_value(value)
|
|
47
|
+
value.respond_to?(:to_h) ? value.to_h.transform_keys(&:to_s) : value
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ruflet
|
|
4
|
+
module UI
|
|
5
|
+
module Services
|
|
6
|
+
module RufletServicesComponents
|
|
7
|
+
class SecureStorageControl < Ruflet::Control
|
|
8
|
+
TYPE = "securestorage".freeze
|
|
9
|
+
WIRE = "SecureStorage".freeze
|
|
10
|
+
OPTION_KEYS = %w[web ios macos android windows].freeze
|
|
11
|
+
|
|
12
|
+
def initialize(id: nil, android_options: nil, data: nil, ios_options: nil, key: nil, macos_options: nil, web_options: nil, windows_options: nil, on_change: nil)
|
|
13
|
+
props = {}
|
|
14
|
+
props[:android_options] = android_options unless android_options.nil?
|
|
15
|
+
props[:data] = data unless data.nil?
|
|
16
|
+
props[:ios_options] = ios_options unless ios_options.nil?
|
|
17
|
+
props[:key] = key unless key.nil?
|
|
18
|
+
props[:macos_options] = macos_options unless macos_options.nil?
|
|
19
|
+
props[:web_options] = web_options unless web_options.nil?
|
|
20
|
+
props[:windows_options] = windows_options unless windows_options.nil?
|
|
21
|
+
props[:on_change] = on_change unless on_change.nil?
|
|
22
|
+
super(type: TYPE, id: id, **props)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def set(key, value, **options)
|
|
26
|
+
invoke_secure_storage("set", args: option_args(options).merge("key" => key, "value" => value), **invoke_options(options))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def get(key, **options)
|
|
30
|
+
invoke_secure_storage("get", args: option_args(options).merge("key" => key), **invoke_options(options))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def contains_key(key, **options)
|
|
34
|
+
invoke_secure_storage("contains_key", args: option_args(options).merge("key" => key), **invoke_options(options))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def get_all(**options)
|
|
38
|
+
invoke_secure_storage("get_all", args: option_args(options), **invoke_options(options))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def remove(key, **options)
|
|
42
|
+
invoke_secure_storage("remove", args: option_args(options).merge("key" => key), **invoke_options(options))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def clear(**options)
|
|
46
|
+
invoke_secure_storage("clear", args: option_args(options), **invoke_options(options))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_availability(timeout: 10, on_result: nil)
|
|
50
|
+
invoke_secure_storage("get_availability", timeout: timeout, on_result: on_result)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def invoke_secure_storage(method_name, args: nil, timeout:, on_result:)
|
|
56
|
+
runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def invoke_options(options)
|
|
60
|
+
{
|
|
61
|
+
timeout: options.fetch(:timeout, 10),
|
|
62
|
+
on_result: options[:on_result]
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def option_args(options)
|
|
67
|
+
OPTION_KEYS.each_with_object({}) do |key, result|
|
|
68
|
+
value = options[key.to_sym] || options[key]
|
|
69
|
+
result[key] = normalize_service_value(value) unless value.nil?
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def normalize_service_value(value)
|
|
74
|
+
case value
|
|
75
|
+
when Array
|
|
76
|
+
value.map { |item| normalize_service_value(item) }
|
|
77
|
+
when Hash
|
|
78
|
+
value.transform_keys(&:to_s).each_with_object({}) do |(key, item), result|
|
|
79
|
+
result[key] = normalize_service_value(item) unless item.nil?
|
|
80
|
+
end
|
|
81
|
+
else
|
|
82
|
+
value.respond_to?(:to_h) ? normalize_service_value(value.to_h) : value
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -14,6 +14,34 @@ module Ruflet
|
|
|
14
14
|
props[:key] = key unless key.nil?
|
|
15
15
|
super(type: TYPE, id: id, **props)
|
|
16
16
|
end
|
|
17
|
+
|
|
18
|
+
def announce_message(message, rtl: false, assertiveness: "polite", timeout: 10, on_result: nil)
|
|
19
|
+
runtime_page&.invoke(
|
|
20
|
+
self,
|
|
21
|
+
"announce_message",
|
|
22
|
+
args: {
|
|
23
|
+
"message" => message,
|
|
24
|
+
"rtl" => rtl,
|
|
25
|
+
"assertiveness" => assertiveness
|
|
26
|
+
},
|
|
27
|
+
timeout: timeout,
|
|
28
|
+
on_result: on_result
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def announce_tooltip(message, timeout: 10, on_result: nil)
|
|
33
|
+
runtime_page&.invoke(
|
|
34
|
+
self,
|
|
35
|
+
"announce_tooltip",
|
|
36
|
+
args: { "message" => message },
|
|
37
|
+
timeout: timeout,
|
|
38
|
+
on_result: on_result
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def get_accessibility_features(timeout: 10, on_result: nil)
|
|
43
|
+
runtime_page&.invoke(self, "get_accessibility_features", timeout: timeout, on_result: on_result)
|
|
44
|
+
end
|
|
17
45
|
end
|
|
18
46
|
end
|
|
19
47
|
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ruflet
|
|
4
|
+
module UI
|
|
5
|
+
module Services
|
|
6
|
+
module RufletServicesComponents
|
|
7
|
+
class TesterControl < Ruflet::Control
|
|
8
|
+
TYPE = "tester".freeze
|
|
9
|
+
WIRE = "Tester".freeze
|
|
10
|
+
|
|
11
|
+
def initialize(id: nil, data: nil, key: nil)
|
|
12
|
+
props = {}
|
|
13
|
+
props[:data] = data unless data.nil?
|
|
14
|
+
props[:key] = key unless key.nil?
|
|
15
|
+
super(type: TYPE, id: id, **props)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def pump(duration: nil, timeout: 10, on_result: nil)
|
|
19
|
+
invoke_tester("pump", args: compact_args("duration" => duration), timeout: timeout, on_result: on_result)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def pump_and_settle(duration: nil, timeout: 10, on_result: nil)
|
|
23
|
+
invoke_tester("pump_and_settle", args: compact_args("duration" => duration), timeout: timeout, on_result: on_result)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def find_by_text(text, timeout: 10, on_result: nil)
|
|
27
|
+
invoke_tester("find_by_text", args: { "text" => text }, timeout: timeout, on_result: on_result)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def find_by_text_containing(pattern, timeout: 10, on_result: nil)
|
|
31
|
+
invoke_tester("find_by_text_containing", args: { "pattern" => pattern }, timeout: timeout, on_result: on_result)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def find_by_key(key, timeout: 10, on_result: nil)
|
|
35
|
+
invoke_tester("find_by_key", args: { "key" => key }, timeout: timeout, on_result: on_result)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def find_by_tooltip(value, timeout: 10, on_result: nil)
|
|
39
|
+
invoke_tester("find_by_tooltip", args: { "value" => value }, timeout: timeout, on_result: on_result)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def find_by_icon(icon, timeout: 10, on_result: nil)
|
|
43
|
+
invoke_tester("find_by_icon", args: { "icon" => normalize_service_value(icon) }, timeout: timeout, on_result: on_result)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def take_screenshot(name, timeout: 10, on_result: nil)
|
|
47
|
+
invoke_tester("take_screenshot", args: { "name" => name }, timeout: timeout, on_result: on_result)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
%w[tap mouse_click mouse_double_click right_mouse_click long_press mouse_hover].each do |method_name|
|
|
51
|
+
define_method(method_name) do |finder_id = nil, finder_index: nil, timeout: 10, on_result: nil|
|
|
52
|
+
invoke_tester(
|
|
53
|
+
method_name,
|
|
54
|
+
args: compact_args("finder_id" => finder_id, "finder_index" => finder_index),
|
|
55
|
+
timeout: timeout,
|
|
56
|
+
on_result: on_result
|
|
57
|
+
)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
%w[tap_at mouse_click_at mouse_double_click_at right_mouse_click_at].each do |method_name|
|
|
62
|
+
define_method(method_name) do |offset = nil, timeout: 10, on_result: nil|
|
|
63
|
+
invoke_tester(method_name, args: compact_args("offset" => offset), timeout: timeout, on_result: on_result)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def drag(finder_id, offset, finder_index: nil, timeout: 10, on_result: nil)
|
|
68
|
+
invoke_tester(
|
|
69
|
+
"drag",
|
|
70
|
+
args: compact_args("finder_id" => finder_id, "finder_index" => finder_index, "offset" => offset),
|
|
71
|
+
timeout: timeout,
|
|
72
|
+
on_result: on_result
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def drag_from(start, offset, timeout: 10, on_result: nil)
|
|
77
|
+
invoke_tester(
|
|
78
|
+
"drag_from",
|
|
79
|
+
args: compact_args("start" => start, "offset" => offset),
|
|
80
|
+
timeout: timeout,
|
|
81
|
+
on_result: on_result
|
|
82
|
+
)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def enter_text(finder_id, text, finder_index: nil, timeout: 10, on_result: nil)
|
|
86
|
+
invoke_tester(
|
|
87
|
+
"enter_text",
|
|
88
|
+
args: compact_args("finder_id" => finder_id, "finder_index" => finder_index, "text" => text),
|
|
89
|
+
timeout: timeout,
|
|
90
|
+
on_result: on_result
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def teardown(timeout: 10, on_result: nil)
|
|
95
|
+
invoke_tester("teardown", timeout: timeout, on_result: on_result)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
def invoke_tester(method_name, args: nil, timeout:, on_result:)
|
|
101
|
+
runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def compact_args(hash)
|
|
105
|
+
hash.each_with_object({}) do |(key, value), result|
|
|
106
|
+
result[key] = normalize_service_value(value) unless value.nil?
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def normalize_service_value(value)
|
|
111
|
+
case value
|
|
112
|
+
when Array
|
|
113
|
+
value.map { |item| normalize_service_value(item) }
|
|
114
|
+
when Hash
|
|
115
|
+
value.transform_keys(&:to_s).each_with_object({}) do |(key, item), result|
|
|
116
|
+
result[key] = normalize_service_value(item) unless item.nil?
|
|
117
|
+
end
|
|
118
|
+
else
|
|
119
|
+
value.respond_to?(:to_h) ? normalize_service_value(value.to_h) : value
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "ruflet/accelerometer_control"
|
|
4
|
+
require_relative "ruflet/audio_recorder_control"
|
|
4
5
|
require_relative "ruflet/barometer_control"
|
|
5
6
|
require_relative "ruflet/battery_control"
|
|
6
7
|
require_relative "ruflet/camera_control"
|
|
@@ -8,16 +9,20 @@ require_relative "ruflet/clipboard_control"
|
|
|
8
9
|
require_relative "ruflet/connectivity_control"
|
|
9
10
|
require_relative "ruflet/filepicker_control"
|
|
10
11
|
require_relative "ruflet/flashlight_control"
|
|
12
|
+
require_relative "ruflet/geolocator_control"
|
|
11
13
|
require_relative "ruflet/gyroscope_control"
|
|
12
14
|
require_relative "ruflet/hapticfeedback_control"
|
|
13
15
|
require_relative "ruflet/magnetometer_control"
|
|
16
|
+
require_relative "ruflet/permissionhandler_control"
|
|
14
17
|
require_relative "ruflet/screenbrightness_control"
|
|
15
18
|
require_relative "ruflet/screenshot_control"
|
|
19
|
+
require_relative "ruflet/securestorage_control"
|
|
16
20
|
require_relative "ruflet/semanticsservice_control"
|
|
17
21
|
require_relative "ruflet/shakedetector_control"
|
|
18
22
|
require_relative "ruflet/share_control"
|
|
19
23
|
require_relative "ruflet/sharedpreferences_control"
|
|
20
24
|
require_relative "ruflet/storagepaths_control"
|
|
25
|
+
require_relative "ruflet/tester_control"
|
|
21
26
|
require_relative "ruflet/urllauncher_control"
|
|
22
27
|
require_relative "ruflet/useraccelerometer_control"
|
|
23
28
|
require_relative "ruflet/wakelock_control"
|
|
@@ -30,21 +35,30 @@ module Ruflet
|
|
|
30
35
|
|
|
31
36
|
CLASS_MAP = {
|
|
32
37
|
"accelerometer" => RufletServicesComponents::AccelerometerControl,
|
|
38
|
+
"audio_recorder" => RufletServicesComponents::AudioRecorderControl,
|
|
39
|
+
"audiorecorder" => RufletServicesComponents::AudioRecorderControl,
|
|
33
40
|
"barometer" => RufletServicesComponents::BarometerControl,
|
|
34
41
|
"battery" => RufletServicesComponents::BatteryControl,
|
|
42
|
+
"browser_context_menu" => Ruflet::UI::Controls::RufletComponents::BrowserContextMenuControl,
|
|
43
|
+
"browsercontextmenu" => Ruflet::UI::Controls::RufletComponents::BrowserContextMenuControl,
|
|
35
44
|
"camera" => RufletServicesComponents::CameraControl,
|
|
36
45
|
"clipboard" => RufletServicesComponents::ClipboardControl,
|
|
37
46
|
"connectivity" => RufletServicesComponents::ConnectivityControl,
|
|
38
47
|
"file_picker" => RufletServicesComponents::FilePickerControl,
|
|
39
48
|
"filepicker" => RufletServicesComponents::FilePickerControl,
|
|
40
49
|
"flashlight" => RufletServicesComponents::FlashlightControl,
|
|
50
|
+
"geolocator" => RufletServicesComponents::GeolocatorControl,
|
|
41
51
|
"gyroscope" => RufletServicesComponents::GyroscopeControl,
|
|
42
52
|
"haptic_feedback" => RufletServicesComponents::HapticFeedbackControl,
|
|
43
53
|
"hapticfeedback" => RufletServicesComponents::HapticFeedbackControl,
|
|
44
54
|
"magnetometer" => RufletServicesComponents::MagnetometerControl,
|
|
55
|
+
"permission_handler" => RufletServicesComponents::PermissionHandlerControl,
|
|
56
|
+
"permissionhandler" => RufletServicesComponents::PermissionHandlerControl,
|
|
45
57
|
"screen_brightness" => RufletServicesComponents::ScreenBrightnessControl,
|
|
46
58
|
"screenbrightness" => RufletServicesComponents::ScreenBrightnessControl,
|
|
47
59
|
"screenshot" => RufletServicesComponents::ScreenshotControl,
|
|
60
|
+
"secure_storage" => RufletServicesComponents::SecureStorageControl,
|
|
61
|
+
"securestorage" => RufletServicesComponents::SecureStorageControl,
|
|
48
62
|
"semantics_service" => RufletServicesComponents::SemanticsServiceControl,
|
|
49
63
|
"semanticsservice" => RufletServicesComponents::SemanticsServiceControl,
|
|
50
64
|
"shake_detector" => RufletServicesComponents::ShakeDetectorControl,
|
|
@@ -54,11 +68,13 @@ module Ruflet
|
|
|
54
68
|
"sharedpreferences" => RufletServicesComponents::SharedPreferencesControl,
|
|
55
69
|
"storage_paths" => RufletServicesComponents::StoragePathsControl,
|
|
56
70
|
"storagepaths" => RufletServicesComponents::StoragePathsControl,
|
|
71
|
+
"tester" => RufletServicesComponents::TesterControl,
|
|
57
72
|
"url_launcher" => RufletServicesComponents::UrlLauncherControl,
|
|
58
73
|
"urllauncher" => RufletServicesComponents::UrlLauncherControl,
|
|
59
74
|
"user_accelerometer" => RufletServicesComponents::UserAccelerometerControl,
|
|
60
75
|
"useraccelerometer" => RufletServicesComponents::UserAccelerometerControl,
|
|
61
76
|
"wakelock" => RufletServicesComponents::WakelockControl,
|
|
77
|
+
"window" => Ruflet::UI::Controls::RufletComponents::WindowControl,
|
|
62
78
|
}.freeze
|
|
63
79
|
end
|
|
64
80
|
end
|