ruflet 0.0.7 → 0.0.9

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ruflet +6 -0
  3. data/lib/ruflet/cli/build_command.rb +372 -0
  4. data/lib/ruflet/cli/extra_command.rb +146 -0
  5. data/lib/ruflet/cli/flutter_sdk.rb +359 -0
  6. data/lib/ruflet/cli/new_command.rb +221 -0
  7. data/lib/ruflet/cli/run_command.rb +699 -0
  8. data/lib/ruflet/cli/templates.rb +68 -0
  9. data/lib/ruflet/cli/update_command.rb +111 -0
  10. data/lib/ruflet/cli.rb +85 -0
  11. data/lib/ruflet/version.rb +1 -1
  12. data/lib/ruflet_cli.rb +3 -0
  13. metadata +59 -75
  14. data/lib/ruflet/manifest_compiler.rb +0 -62
  15. data/lib/ruflet.rb +0 -40
  16. data/lib/ruflet_protocol/ruflet/protocol.rb +0 -62
  17. data/lib/ruflet_protocol.rb +0 -4
  18. data/lib/ruflet_ui/ruflet/app.rb +0 -31
  19. data/lib/ruflet_ui/ruflet/colors.rb +0 -234
  20. data/lib/ruflet_ui/ruflet/control.rb +0 -168
  21. data/lib/ruflet_ui/ruflet/dsl.rb +0 -227
  22. data/lib/ruflet_ui/ruflet/event.rb +0 -28
  23. data/lib/ruflet_ui/ruflet/icon_data.rb +0 -62
  24. data/lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb +0 -54
  25. data/lib/ruflet_ui/ruflet/icons/cupertino_icon_lookup.rb +0 -112
  26. data/lib/ruflet_ui/ruflet/icons/material_icon_lookup.rb +0 -112
  27. data/lib/ruflet_ui/ruflet/icons/material_icons.rb +0 -55
  28. data/lib/ruflet_ui/ruflet/page.rb +0 -741
  29. data/lib/ruflet_ui/ruflet/ui/control_factory.rb +0 -23
  30. data/lib/ruflet_ui/ruflet/ui/control_methods.rb +0 -16
  31. data/lib/ruflet_ui/ruflet/ui/control_registry.rb +0 -13
  32. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_action_sheet_control.rb +0 -13
  33. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_alert_dialog_control.rb +0 -13
  34. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_button_control.rb +0 -13
  35. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_dialog_action_control.rb +0 -24
  36. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_filled_button_control.rb +0 -13
  37. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_navigation_bar_control.rb +0 -13
  38. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_slider_control.rb +0 -13
  39. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_switch_control.rb +0 -13
  40. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_text_field_control.rb +0 -13
  41. data/lib/ruflet_ui/ruflet/ui/controls/material/alert_dialog_control.rb +0 -13
  42. data/lib/ruflet_ui/ruflet/ui/controls/material/app_bar_control.rb +0 -13
  43. data/lib/ruflet_ui/ruflet/ui/controls/material/bottom_sheet_control.rb +0 -13
  44. data/lib/ruflet_ui/ruflet/ui/controls/material/button_control.rb +0 -24
  45. data/lib/ruflet_ui/ruflet/ui/controls/material/checkbox_control.rb +0 -13
  46. data/lib/ruflet_ui/ruflet/ui/controls/material/column_control.rb +0 -13
  47. data/lib/ruflet_ui/ruflet/ui/controls/material/container_control.rb +0 -13
  48. data/lib/ruflet_ui/ruflet/ui/controls/material/drag_target_control.rb +0 -13
  49. data/lib/ruflet_ui/ruflet/ui/controls/material/draggable_control.rb +0 -13
  50. data/lib/ruflet_ui/ruflet/ui/controls/material/elevated_button_control.rb +0 -13
  51. data/lib/ruflet_ui/ruflet/ui/controls/material/filled_button_control.rb +0 -13
  52. data/lib/ruflet_ui/ruflet/ui/controls/material/floating_action_button_control.rb +0 -28
  53. data/lib/ruflet_ui/ruflet/ui/controls/material/gesture_detector_control.rb +0 -13
  54. data/lib/ruflet_ui/ruflet/ui/controls/material/grid_view_control.rb +0 -13
  55. data/lib/ruflet_ui/ruflet/ui/controls/material/icon_button_control.rb +0 -13
  56. data/lib/ruflet_ui/ruflet/ui/controls/material/icon_control.rb +0 -24
  57. data/lib/ruflet_ui/ruflet/ui/controls/material/image_control.rb +0 -13
  58. data/lib/ruflet_ui/ruflet/ui/controls/material/markdown_control.rb +0 -13
  59. data/lib/ruflet_ui/ruflet/ui/controls/material/navigation_bar_control.rb +0 -13
  60. data/lib/ruflet_ui/ruflet/ui/controls/material/navigation_bar_destination_control.rb +0 -13
  61. data/lib/ruflet_ui/ruflet/ui/controls/material/radio_control.rb +0 -13
  62. data/lib/ruflet_ui/ruflet/ui/controls/material/radio_group_control.rb +0 -13
  63. data/lib/ruflet_ui/ruflet/ui/controls/material/row_control.rb +0 -13
  64. data/lib/ruflet_ui/ruflet/ui/controls/material/snack_bar_control.rb +0 -68
  65. data/lib/ruflet_ui/ruflet/ui/controls/material/stack_control.rb +0 -13
  66. data/lib/ruflet_ui/ruflet/ui/controls/material/tab_bar_control.rb +0 -13
  67. data/lib/ruflet_ui/ruflet/ui/controls/material/tab_bar_view_control.rb +0 -13
  68. data/lib/ruflet_ui/ruflet/ui/controls/material/tab_control.rb +0 -13
  69. data/lib/ruflet_ui/ruflet/ui/controls/material/tabs_control.rb +0 -63
  70. data/lib/ruflet_ui/ruflet/ui/controls/material/text_button_control.rb +0 -13
  71. data/lib/ruflet_ui/ruflet/ui/controls/material/text_control.rb +0 -13
  72. data/lib/ruflet_ui/ruflet/ui/controls/material/text_field_control.rb +0 -13
  73. data/lib/ruflet_ui/ruflet/ui/controls/material/view_control.rb +0 -13
  74. data/lib/ruflet_ui/ruflet/ui/cupertino_control_factory.rb +0 -40
  75. data/lib/ruflet_ui/ruflet/ui/cupertino_control_methods.rb +0 -26
  76. data/lib/ruflet_ui/ruflet/ui/cupertino_control_registry.rb +0 -49
  77. data/lib/ruflet_ui/ruflet/ui/material_control_factory.rb +0 -97
  78. data/lib/ruflet_ui/ruflet/ui/material_control_methods.rb +0 -128
  79. data/lib/ruflet_ui/ruflet/ui/material_control_registry.rb +0 -154
  80. data/lib/ruflet_ui/ruflet/ui/shared_control_forwarders.rb +0 -89
  81. data/lib/ruflet_ui/ruflet/ui/widget_builder.rb +0 -55
  82. data/lib/ruflet_ui.rb +0 -111
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ruflet
4
+ module CLI
5
+ MAIN_TEMPLATE = <<~RUBY
6
+ require "ruflet"
7
+ Ruflet.run do |page|
8
+ page.title = "Counter Demo"
9
+ count = 0
10
+ count_text = text(count.to_s, size: 40)
11
+ page.add(
12
+ container(
13
+ expand: true,
14
+ alignment: Ruflet::MainAxisAlignment::CENTER,
15
+ content: column(
16
+ alignment: Ruflet::MainAxisAlignment::CENTER,
17
+ horizontal_alignment: Ruflet::CrossAxisAlignment::CENTER,
18
+ children: [
19
+ text("You have pushed the button this many times:"),
20
+ count_text
21
+ ]
22
+ )
23
+ ),
24
+ floating_action_button: fab(
25
+ icon: Ruflet::MaterialIcons::ADD,
26
+ on_click: ->(_e) do
27
+ count += 1
28
+ page.update(count_text, value: count.to_s)
29
+ end
30
+ )
31
+ )
32
+ end
33
+
34
+ RUBY
35
+
36
+ GEMFILE_TEMPLATE = <<~GEMFILE
37
+ source "https://rubygems.org"
38
+
39
+ gem "ruflet_core", ">= 0.0.9"
40
+ gem "ruflet_server", ">= 0.0.9"
41
+ GEMFILE
42
+
43
+ README_TEMPLATE = <<~MD
44
+ # %<app_name>s
45
+
46
+ Ruflet app.
47
+
48
+ ## Setup
49
+
50
+ ```bash
51
+ bundle install
52
+ ```
53
+
54
+ ## Run
55
+
56
+ ```bash
57
+ bundle exec ruflet run main
58
+ ```
59
+
60
+ ## Build
61
+
62
+ ```bash
63
+ bundle exec ruflet build apk
64
+ bundle exec ruflet build ios
65
+ ```
66
+ MD
67
+ end
68
+ end
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+
5
+ module Ruflet
6
+ module CLI
7
+ module UpdateCommand
8
+ include RunCommand
9
+
10
+ VALID_UPDATE_PLATFORMS = %w[macos linux windows].freeze
11
+
12
+ def command_update(args)
13
+ options = {
14
+ web: false,
15
+ desktop: false,
16
+ check: false,
17
+ force: false,
18
+ platform: nil
19
+ }
20
+
21
+ parser = OptionParser.new do |o|
22
+ o.on("--web") { options[:web] = true }
23
+ o.on("--desktop") { options[:desktop] = true }
24
+ o.on("--check") { options[:check] = true }
25
+ o.on("--force") { options[:force] = true }
26
+ o.on("--platform PLATFORM") { |value| options[:platform] = value.to_s.downcase }
27
+ end
28
+ parser.parse!(args)
29
+
30
+ args.each do |arg|
31
+ case arg.to_s.downcase
32
+ when "web"
33
+ options[:web] = true
34
+ when "desktop"
35
+ options[:desktop] = true
36
+ when "all"
37
+ options[:web] = true
38
+ options[:desktop] = true
39
+ when "check"
40
+ options[:check] = true
41
+ else
42
+ warn "Unknown update target: #{arg}"
43
+ return 1
44
+ end
45
+ end
46
+
47
+ platform = options[:platform] || host_platform_name
48
+ if platform.nil? || !VALID_UPDATE_PLATFORMS.include?(platform)
49
+ warn "Unsupported or missing platform. Use --platform macos|linux|windows."
50
+ return 1
51
+ end
52
+
53
+ if !options[:web] && !options[:desktop]
54
+ options[:web] = true
55
+ options[:desktop] = true
56
+ end
57
+
58
+ targets = []
59
+ targets << :web if options[:web]
60
+ targets << :desktop if options[:desktop]
61
+
62
+ return check_client_updates(targets, platform: platform) if options[:check]
63
+
64
+ targets.each do |target|
65
+ root =
66
+ if target == :web
67
+ ensure_prebuilt_client(web: true, platform: platform, force: options[:force])
68
+ else
69
+ ensure_prebuilt_client(desktop: true, platform: platform, force: options[:force])
70
+ end
71
+ unless root
72
+ warn "Failed to update #{target} client for #{platform}"
73
+ return 1
74
+ end
75
+
76
+ manifest = read_client_manifest(root)
77
+ release_label = manifest && manifest["release_tag"] ? manifest["release_tag"] : "unknown release"
78
+ puts "Updated #{target} client for #{platform} at #{root} (#{release_label})"
79
+ end
80
+
81
+ 0
82
+ end
83
+
84
+ private
85
+
86
+ def check_client_updates(targets, platform:)
87
+ root = client_cache_root_for(platform)
88
+ manifest = read_client_manifest(root)
89
+
90
+ puts "Ruflet client cache: #{root}"
91
+ puts "Platform: #{platform}"
92
+ puts "Ruflet version: #{ruflet_version}"
93
+ puts "Release tag: #{manifest && manifest['release_tag'] ? manifest['release_tag'] : 'not installed'}"
94
+
95
+ installed = true
96
+ targets.each do |target|
97
+ present =
98
+ if target == :web
99
+ File.file?(File.join(root, "web", "index.html"))
100
+ else
101
+ prebuilt_desktop_present?(root, platform: platform)
102
+ end
103
+ installed &&= present
104
+ puts "#{target}: #{present ? 'installed' : 'missing'}"
105
+ end
106
+
107
+ installed ? 0 : 1
108
+ end
109
+ end
110
+ end
111
+ end
data/lib/ruflet/cli.rb ADDED
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+
5
+ require_relative "cli/templates"
6
+ require_relative "cli/new_command"
7
+ require_relative "cli/flutter_sdk"
8
+ require_relative "cli/run_command"
9
+ require_relative "cli/update_command"
10
+ require_relative "cli/build_command"
11
+ require_relative "cli/extra_command"
12
+ require_relative "version"
13
+
14
+ module Ruflet
15
+ module CLI
16
+ extend self
17
+ extend NewCommand
18
+ extend RunCommand
19
+ extend UpdateCommand
20
+ extend BuildCommand
21
+ extend ExtraCommand
22
+
23
+ def run(argv = ARGV)
24
+ command = (argv.shift || "help").downcase
25
+
26
+ case command
27
+ when "version", "-v", "--version"
28
+ puts version_string
29
+ 0
30
+ when "create"
31
+ command_create(argv)
32
+ when "new", "bootstrap", "init"
33
+ command_new(argv)
34
+ when "run"
35
+ command_run(argv)
36
+ when "update"
37
+ command_update(argv)
38
+ when "debug"
39
+ command_debug(argv)
40
+ when "build"
41
+ command_build(argv)
42
+ when "devices"
43
+ command_devices(argv)
44
+ when "emulators"
45
+ command_emulators(argv)
46
+ when "doctor"
47
+ command_doctor(argv)
48
+ when "help", "-h", "--help"
49
+ print_help
50
+ 0
51
+ else
52
+ warn "Unknown command: #{command}"
53
+ print_help
54
+ 1
55
+ end
56
+ end
57
+
58
+ def print_help
59
+ puts <<~HELP
60
+ Ruflet CLI
61
+
62
+ Commands:
63
+ ruflet --version
64
+ ruflet create <appname>
65
+ ruflet new <appname>
66
+ ruflet run [scriptname|path] [--web|--desktop] [--port PORT]
67
+ ruflet update [web|desktop|all] [--check] [--force] [--platform PLATFORM]
68
+ ruflet debug [scriptname|path]
69
+ ruflet build <apk|android|ios|aab|web|macos|windows|linux>
70
+ ruflet devices
71
+ ruflet emulators
72
+ ruflet doctor
73
+ HELP
74
+ end
75
+
76
+ def bootstrap(path)
77
+ command_new([path || Dir.pwd])
78
+ 0
79
+ end
80
+
81
+ def version_string
82
+ "ruflet #{Ruflet::VERSION}"
83
+ end
84
+ end
85
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ruflet
4
- VERSION = "0.0.7" unless const_defined?(:VERSION)
4
+ VERSION = "0.0.9" unless const_defined?(:VERSION)
5
5
  end
data/lib/ruflet_cli.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ruflet/cli"
metadata CHANGED
@@ -1,93 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruflet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - AdamMusa
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies: []
12
- description: Ruflet is a library that allows building web, desktop and mobile applications
13
- in Ruby without prior experience in frontend development.
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rqrcode
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.2'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.2'
26
+ - !ruby/object:Gem::Dependency
27
+ name: ruflet_core
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.9
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '='
38
+ - !ruby/object:Gem::Version
39
+ version: 0.0.9
40
+ - !ruby/object:Gem::Dependency
41
+ name: ruflet_server
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '='
45
+ - !ruby/object:Gem::Version
46
+ version: 0.0.9
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.9
54
+ description: Ruflet command line interface for creating, updating, building, and running
55
+ Ruflet apps.
14
56
  email:
15
57
  - adammusa2222@gmail.com
16
- executables: []
58
+ executables:
59
+ - ruflet
17
60
  extensions: []
18
61
  extra_rdoc_files: []
19
62
  files:
20
63
  - README.md
21
- - lib/ruflet.rb
22
- - lib/ruflet/manifest_compiler.rb
64
+ - bin/ruflet
65
+ - lib/ruflet/cli.rb
66
+ - lib/ruflet/cli/build_command.rb
67
+ - lib/ruflet/cli/extra_command.rb
68
+ - lib/ruflet/cli/flutter_sdk.rb
69
+ - lib/ruflet/cli/new_command.rb
70
+ - lib/ruflet/cli/run_command.rb
71
+ - lib/ruflet/cli/templates.rb
72
+ - lib/ruflet/cli/update_command.rb
23
73
  - lib/ruflet/version.rb
24
- - lib/ruflet_protocol.rb
25
- - lib/ruflet_protocol/ruflet/protocol.rb
26
- - lib/ruflet_ui.rb
27
- - lib/ruflet_ui/ruflet/app.rb
28
- - lib/ruflet_ui/ruflet/colors.rb
29
- - lib/ruflet_ui/ruflet/control.rb
30
- - lib/ruflet_ui/ruflet/dsl.rb
31
- - lib/ruflet_ui/ruflet/event.rb
32
- - lib/ruflet_ui/ruflet/icon_data.rb
33
- - lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb
34
- - lib/ruflet_ui/ruflet/icons/cupertino_icon_lookup.rb
35
- - lib/ruflet_ui/ruflet/icons/material_icon_lookup.rb
36
- - lib/ruflet_ui/ruflet/icons/material_icons.rb
37
- - lib/ruflet_ui/ruflet/page.rb
38
- - lib/ruflet_ui/ruflet/ui/control_factory.rb
39
- - lib/ruflet_ui/ruflet/ui/control_methods.rb
40
- - lib/ruflet_ui/ruflet/ui/control_registry.rb
41
- - lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_action_sheet_control.rb
42
- - lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_alert_dialog_control.rb
43
- - lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_button_control.rb
44
- - lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_dialog_action_control.rb
45
- - lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_filled_button_control.rb
46
- - lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_navigation_bar_control.rb
47
- - lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_slider_control.rb
48
- - lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_switch_control.rb
49
- - lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_text_field_control.rb
50
- - lib/ruflet_ui/ruflet/ui/controls/material/alert_dialog_control.rb
51
- - lib/ruflet_ui/ruflet/ui/controls/material/app_bar_control.rb
52
- - lib/ruflet_ui/ruflet/ui/controls/material/bottom_sheet_control.rb
53
- - lib/ruflet_ui/ruflet/ui/controls/material/button_control.rb
54
- - lib/ruflet_ui/ruflet/ui/controls/material/checkbox_control.rb
55
- - lib/ruflet_ui/ruflet/ui/controls/material/column_control.rb
56
- - lib/ruflet_ui/ruflet/ui/controls/material/container_control.rb
57
- - lib/ruflet_ui/ruflet/ui/controls/material/drag_target_control.rb
58
- - lib/ruflet_ui/ruflet/ui/controls/material/draggable_control.rb
59
- - lib/ruflet_ui/ruflet/ui/controls/material/elevated_button_control.rb
60
- - lib/ruflet_ui/ruflet/ui/controls/material/filled_button_control.rb
61
- - lib/ruflet_ui/ruflet/ui/controls/material/floating_action_button_control.rb
62
- - lib/ruflet_ui/ruflet/ui/controls/material/gesture_detector_control.rb
63
- - lib/ruflet_ui/ruflet/ui/controls/material/grid_view_control.rb
64
- - lib/ruflet_ui/ruflet/ui/controls/material/icon_button_control.rb
65
- - lib/ruflet_ui/ruflet/ui/controls/material/icon_control.rb
66
- - lib/ruflet_ui/ruflet/ui/controls/material/image_control.rb
67
- - lib/ruflet_ui/ruflet/ui/controls/material/markdown_control.rb
68
- - lib/ruflet_ui/ruflet/ui/controls/material/navigation_bar_control.rb
69
- - lib/ruflet_ui/ruflet/ui/controls/material/navigation_bar_destination_control.rb
70
- - lib/ruflet_ui/ruflet/ui/controls/material/radio_control.rb
71
- - lib/ruflet_ui/ruflet/ui/controls/material/radio_group_control.rb
72
- - lib/ruflet_ui/ruflet/ui/controls/material/row_control.rb
73
- - lib/ruflet_ui/ruflet/ui/controls/material/snack_bar_control.rb
74
- - lib/ruflet_ui/ruflet/ui/controls/material/stack_control.rb
75
- - lib/ruflet_ui/ruflet/ui/controls/material/tab_bar_control.rb
76
- - lib/ruflet_ui/ruflet/ui/controls/material/tab_bar_view_control.rb
77
- - lib/ruflet_ui/ruflet/ui/controls/material/tab_control.rb
78
- - lib/ruflet_ui/ruflet/ui/controls/material/tabs_control.rb
79
- - lib/ruflet_ui/ruflet/ui/controls/material/text_button_control.rb
80
- - lib/ruflet_ui/ruflet/ui/controls/material/text_control.rb
81
- - lib/ruflet_ui/ruflet/ui/controls/material/text_field_control.rb
82
- - lib/ruflet_ui/ruflet/ui/controls/material/view_control.rb
83
- - lib/ruflet_ui/ruflet/ui/cupertino_control_factory.rb
84
- - lib/ruflet_ui/ruflet/ui/cupertino_control_methods.rb
85
- - lib/ruflet_ui/ruflet/ui/cupertino_control_registry.rb
86
- - lib/ruflet_ui/ruflet/ui/material_control_factory.rb
87
- - lib/ruflet_ui/ruflet/ui/material_control_methods.rb
88
- - lib/ruflet_ui/ruflet/ui/material_control_registry.rb
89
- - lib/ruflet_ui/ruflet/ui/shared_control_forwarders.rb
90
- - lib/ruflet_ui/ruflet/ui/widget_builder.rb
74
+ - lib/ruflet_cli.rb
91
75
  homepage: https://github.com/AdamMusa/Ruflet
92
76
  licenses: []
93
77
  metadata: {}
@@ -107,5 +91,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
91
  requirements: []
108
92
  rubygems_version: 3.7.2
109
93
  specification_version: 4
110
- summary: Ruflet umbrella package.
94
+ summary: Ruflet command line interface package.
111
95
  test_files: []
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "json"
4
- require "time"
5
-
6
- module Ruflet
7
- module ManifestCompiler
8
- module_function
9
-
10
- def compile_app(app, route: "/")
11
- messages = []
12
- sender = lambda do |action, payload|
13
- messages << { "action" => action, "payload" => payload }
14
- end
15
-
16
- page = Ruflet::Page.new(
17
- session_id: "manifest",
18
- client_details: { "route" => route.to_s.empty? ? "/" : route.to_s },
19
- sender: sender
20
- )
21
-
22
- app.view(page)
23
- page.update
24
-
25
- compacted = compact_messages(messages)
26
-
27
- {
28
- "schema" => "ruflet_manifest/v1",
29
- "generated_at" => Time.now.utc.iso8601,
30
- "route" => page.route || "/",
31
- "messages" => compacted
32
- }
33
- end
34
-
35
- def write_file(path, manifest)
36
- File.write(path, JSON.pretty_generate(manifest))
37
- path
38
- end
39
-
40
- def read_file(path)
41
- JSON.parse(File.read(path.to_s))
42
- end
43
-
44
- def compact_messages(messages)
45
- full_patch_index = nil
46
- messages.each_with_index do |message, idx|
47
- next unless message["action"] == Ruflet::Protocol::ACTIONS[:patch_control]
48
-
49
- payload = message["payload"] || {}
50
- next unless payload["id"] == 1
51
-
52
- patch = payload["patch"]
53
- next unless patch.is_a?(Array) && patch.any? { |op| op.is_a?(Array) && op[2] == "views" }
54
-
55
- full_patch_index = idx
56
- end
57
- return messages if full_patch_index.nil?
58
-
59
- [messages[full_patch_index]]
60
- end
61
- end
62
- end
data/lib/ruflet.rb DELETED
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "thread"
4
- require "ruflet_protocol"
5
- require "ruflet_ui"
6
-
7
- module Ruflet
8
- @run_interceptors = []
9
- @run_interceptors_mutex = Mutex.new
10
-
11
- module_function
12
-
13
- def run(entrypoint = nil, host: "0.0.0.0", port: 8550, &block)
14
- callback = entrypoint || block
15
- raise ArgumentError, "Ruflet.run requires a callable entrypoint or block" unless callback.respond_to?(:call)
16
-
17
- interceptor = @run_interceptors_mutex.synchronize { @run_interceptors.last }
18
- if interceptor
19
- result = interceptor.call(entrypoint: callback, host: host, port: port)
20
- return result unless result == :pass
21
- end
22
-
23
- begin
24
- require "ruflet_server"
25
- rescue LoadError => e
26
- raise LoadError, "Ruflet.run requires the 'ruflet_server' gem unless a run interceptor handles execution.", e.backtrace
27
- end
28
-
29
- Server.new(host: host, port: port) do |page|
30
- callback.call(page)
31
- end.start
32
- end
33
-
34
- def with_run_interceptor(interceptor)
35
- @run_interceptors_mutex.synchronize { @run_interceptors << interceptor }
36
- yield
37
- ensure
38
- @run_interceptors_mutex.synchronize { @run_interceptors.delete(interceptor) }
39
- end
40
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module Protocol
5
- ACTIONS = {
6
- register_client: 1,
7
- patch_control: 2,
8
- control_event: 3,
9
- update_control: 4,
10
- invoke_control_method: 5,
11
- session_crashed: 6,
12
-
13
- # Legacy JSON protocol aliases kept for compatibility.
14
- register_web_client: "registerWebClient",
15
- page_event_from_web: "pageEventFromWeb",
16
- update_control_props: "updateControlProps"
17
- }.freeze
18
-
19
- module_function
20
-
21
- def pack_message(action:, payload:)
22
- [action, payload]
23
- end
24
-
25
- def normalize_register_payload(payload)
26
- page = payload["page"] || {}
27
- {
28
- "session_id" => payload["session_id"],
29
- "page_name" => payload["page_name"] || "",
30
- "route" => page["route"] || "/",
31
- "width" => page["width"],
32
- "height" => page["height"],
33
- "platform" => page["platform"],
34
- "platform_brightness" => page["platform_brightness"],
35
- "media" => page["media"] || {}
36
- }
37
- end
38
-
39
- def normalize_control_event_payload(payload)
40
- {
41
- "target" => payload["target"] || payload["eventTarget"],
42
- "name" => payload["name"] || payload["eventName"],
43
- "data" => payload["data"] || payload["eventData"]
44
- }
45
- end
46
-
47
- def normalize_update_control_payload(payload)
48
- {
49
- "id" => payload["id"] || payload["target"] || payload["eventTarget"],
50
- "props" => payload["props"].is_a?(Hash) ? payload["props"] : {}
51
- }
52
- end
53
-
54
- def register_response(session_id:)
55
- {
56
- "session_id" => session_id,
57
- "page_patch" => {},
58
- "error" => nil
59
- }
60
- end
61
- end
62
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "ruflet/version"
4
- require_relative "ruflet_protocol/ruflet/protocol"
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
- require_relative "../../ruflet/manifest_compiler"
3
-
4
- module Ruflet
5
- class App
6
- def initialize(host: "0.0.0.0", port: 8550)
7
- @host = host
8
- @port = port
9
- end
10
-
11
- def run
12
- manifest_out = ENV["RUFLET_MANIFEST_OUT"].to_s
13
- unless manifest_out.empty?
14
- route = ENV["RUFLET_MANIFEST_ROUTE"].to_s
15
- route = "/" if route.empty?
16
- manifest = Ruflet::ManifestCompiler.compile_app(self, route: route)
17
- Ruflet::ManifestCompiler.write_file(manifest_out, manifest)
18
- puts manifest_out
19
- return manifest_out
20
- end
21
-
22
- Ruflet.run(host: @host, port: @port) do |page|
23
- view(page)
24
- end
25
- end
26
-
27
- def view(_page)
28
- raise NotImplementedError, "#{self.class} must implement #view(page)"
29
- end
30
- end
31
- end