ruflet 0.0.6 → 0.0.7
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_ui/ruflet/page.rb +47 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50d9722e6751b03441e1b205a2c52c7dd2e24d3a20c9b65aa75bd18e0b07b99d
|
|
4
|
+
data.tar.gz: b4cf12770851ef43aee2331aabb1a57f0bf521ed6fbc769fe61d6beb0378eaef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d35da0d4a41493d8a6dced4aac0a6ab8491aef7588c2ef69dd42e12255921fbf9d62008a9c31f717a1eac7e4b44ce73b6e4d01769a07775803a60c58f6b96530
|
|
7
|
+
data.tar.gz: dbaff1a82f3dcdb9a4d5fbb1a06e9620282560a52ec3032b08ef8008809592656dcae0fa0dede4fc0f7a37b8b9e742066304b7713df85cbb2dfc41be856696e1
|
data/lib/ruflet/version.rb
CHANGED
|
@@ -8,6 +8,8 @@ require_relative "icons/material_icon_lookup"
|
|
|
8
8
|
require_relative "icons/cupertino_icon_lookup"
|
|
9
9
|
require "set"
|
|
10
10
|
require "cgi"
|
|
11
|
+
require "thread"
|
|
12
|
+
require "timeout"
|
|
11
13
|
|
|
12
14
|
module Ruflet
|
|
13
15
|
class Page
|
|
@@ -51,13 +53,16 @@ module Ruflet
|
|
|
51
53
|
@services_container = Ruflet::Control.new(
|
|
52
54
|
type: "service_registry",
|
|
53
55
|
id: "_services",
|
|
54
|
-
"_services": []
|
|
56
|
+
"_services": [],
|
|
57
|
+
"_internals": { "uid" => Ruflet::Control.generate_id }
|
|
55
58
|
)
|
|
56
59
|
@dialogs_container = Ruflet::Control.new(
|
|
57
60
|
type: "dialogs",
|
|
58
61
|
id: "_dialogs",
|
|
59
62
|
controls: []
|
|
60
63
|
)
|
|
64
|
+
@invoke_waiters = {}
|
|
65
|
+
@invoke_waiters_mutex = Mutex.new
|
|
61
66
|
refresh_overlay_container!
|
|
62
67
|
refresh_services_container!
|
|
63
68
|
refresh_dialogs_container!
|
|
@@ -295,6 +300,15 @@ module Ruflet
|
|
|
295
300
|
invoke(clipboard, "get_image", timeout: timeout)
|
|
296
301
|
end
|
|
297
302
|
|
|
303
|
+
def handle_invoke_method_result(payload)
|
|
304
|
+
call_id = payload["call_id"].to_s
|
|
305
|
+
waiter = @invoke_waiters_mutex.synchronize { @invoke_waiters[call_id] }
|
|
306
|
+
return false unless waiter
|
|
307
|
+
|
|
308
|
+
waiter << payload
|
|
309
|
+
true
|
|
310
|
+
end
|
|
311
|
+
|
|
298
312
|
def pop_dialog
|
|
299
313
|
dialog_control = latest_open_dialog
|
|
300
314
|
return nil unless dialog_control
|
|
@@ -325,6 +339,12 @@ module Ruflet
|
|
|
325
339
|
patch["content"] = patch.delete("text")
|
|
326
340
|
end
|
|
327
341
|
|
|
342
|
+
# Keep runtime control tree aligned with incremental patches.
|
|
343
|
+
if patch.key?("controls")
|
|
344
|
+
control.children.clear
|
|
345
|
+
Array(patch["controls"]).each { |child| control.children << child if child.is_a?(Control) }
|
|
346
|
+
end
|
|
347
|
+
|
|
328
348
|
visited = Set.new
|
|
329
349
|
patch.each_value { |value| register_embedded_value(value, visited) }
|
|
330
350
|
|
|
@@ -416,6 +436,31 @@ module Ruflet
|
|
|
416
436
|
|
|
417
437
|
private
|
|
418
438
|
|
|
439
|
+
def invoke_and_wait(control_or_id, method_name, args: nil, timeout: 10)
|
|
440
|
+
control = resolve_control(control_or_id)
|
|
441
|
+
return nil unless control
|
|
442
|
+
|
|
443
|
+
call_id = "call_#{Ruflet::Control.generate_id}"
|
|
444
|
+
waiter = Queue.new
|
|
445
|
+
@invoke_waiters_mutex.synchronize { @invoke_waiters[call_id] = waiter }
|
|
446
|
+
|
|
447
|
+
send_message(Protocol::ACTIONS[:invoke_control_method], {
|
|
448
|
+
"control_id" => control.wire_id,
|
|
449
|
+
"call_id" => call_id,
|
|
450
|
+
"name" => method_name.to_s,
|
|
451
|
+
"args" => args,
|
|
452
|
+
"timeout" => timeout
|
|
453
|
+
})
|
|
454
|
+
|
|
455
|
+
response = Timeout.timeout(timeout.to_f) { waiter.pop }
|
|
456
|
+
error = response["error"]
|
|
457
|
+
raise RuntimeError, error if error && !error.to_s.empty?
|
|
458
|
+
|
|
459
|
+
response["result"]
|
|
460
|
+
ensure
|
|
461
|
+
@invoke_waiters_mutex.synchronize { @invoke_waiters.delete(call_id) } if call_id
|
|
462
|
+
end
|
|
463
|
+
|
|
419
464
|
def build_widget(type, **props, &block) = WidgetBuilder.new.control(type, **props, &block)
|
|
420
465
|
|
|
421
466
|
def split_props(props)
|
|
@@ -515,6 +560,7 @@ module Ruflet
|
|
|
515
560
|
def normalize_props(hash)
|
|
516
561
|
hash.each_with_object({}) do |(k, v), result|
|
|
517
562
|
key = k.to_s
|
|
563
|
+
key = "controls" if key == "children"
|
|
518
564
|
result[key] = normalize_value(key, v)
|
|
519
565
|
end
|
|
520
566
|
end
|