funicular 0.0.1 → 0.1.0

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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +56 -1
  3. data/README.md +58 -20
  4. data/Rakefile +74 -2
  5. data/demo/keymap_editor.html +582 -0
  6. data/demo/test_cable.html +179 -0
  7. data/demo/test_chartjs.html +235 -0
  8. data/demo/test_component.html +201 -0
  9. data/demo/test_diff_patch.html +146 -0
  10. data/demo/test_error_boundary.html +284 -0
  11. data/demo/test_router.html +257 -0
  12. data/demo/test_vdom.html +100 -0
  13. data/demo/tic-tac-toe.html +201 -0
  14. data/docs/README.md +419 -0
  15. data/docs/advanced-features.md +632 -0
  16. data/docs/architecture.md +409 -0
  17. data/docs/components-and-state.md +539 -0
  18. data/docs/data-fetching.md +528 -0
  19. data/docs/forms.md +446 -0
  20. data/docs/rails-integration.md +426 -0
  21. data/docs/realtime.md +543 -0
  22. data/docs/routing-and-navigation.md +427 -0
  23. data/docs/styling.md +285 -0
  24. data/exe/funicular +32 -0
  25. data/lib/funicular/assets/funicular.rb +21 -0
  26. data/lib/funicular/assets/funicular_debug.css +73 -0
  27. data/lib/funicular/assets/funicular_debug.js +183 -0
  28. data/lib/funicular/commands/routes.rb +69 -0
  29. data/lib/funicular/compiler.rb +135 -0
  30. data/lib/funicular/configuration.rb +76 -0
  31. data/lib/funicular/helpers/picoruby_helper.rb +50 -0
  32. data/lib/funicular/middleware.rb +98 -0
  33. data/lib/funicular/railtie.rb +26 -0
  34. data/lib/funicular/route_parser.rb +137 -0
  35. data/lib/funicular/vendor/picorbc/VERSION +1 -0
  36. data/lib/funicular/vendor/picorbc/picorbc.js +5283 -0
  37. data/lib/funicular/vendor/picorbc/picorbc.wasm +0 -0
  38. data/lib/funicular/vendor/picoruby/VERSION +1 -0
  39. data/lib/funicular/vendor/picoruby/debug/init.iife.js +130 -0
  40. data/lib/funicular/vendor/picoruby/debug/picoruby.js +6404 -0
  41. data/lib/funicular/vendor/picoruby/debug/picoruby.wasm +0 -0
  42. data/lib/funicular/vendor/picoruby/dist/init.iife.js +130 -0
  43. data/lib/funicular/vendor/picoruby/dist/picoruby.js +2 -0
  44. data/lib/funicular/vendor/picoruby/dist/picoruby.wasm +0 -0
  45. data/lib/funicular/version.rb +1 -1
  46. data/lib/funicular.rb +29 -1
  47. data/lib/tasks/funicular.rake +135 -0
  48. data/minitest/funicular_test.rb +13 -0
  49. data/minitest/test_helper.rb +7 -0
  50. data/mrbgem.rake +15 -0
  51. data/mrblib/cable.rb +417 -0
  52. data/mrblib/component.rb +911 -0
  53. data/mrblib/debug.rb +205 -0
  54. data/mrblib/differ.rb +244 -0
  55. data/mrblib/environment_inquirer.rb +34 -0
  56. data/mrblib/error_boundary.rb +125 -0
  57. data/mrblib/file_upload.rb +184 -0
  58. data/mrblib/form_builder.rb +284 -0
  59. data/mrblib/funicular.rb +156 -0
  60. data/mrblib/http.rb +89 -0
  61. data/mrblib/model.rb +146 -0
  62. data/mrblib/patcher.rb +203 -0
  63. data/mrblib/router.rb +229 -0
  64. data/mrblib/styles.rb +83 -0
  65. data/mrblib/vdom.rb +273 -0
  66. data/sig/cable.rbs +65 -0
  67. data/sig/component.rbs +141 -0
  68. data/sig/debug.rbs +28 -0
  69. data/sig/differ.rbs +18 -0
  70. data/sig/environment_iquirer.rbs +10 -0
  71. data/sig/error_boundary.rbs +14 -0
  72. data/sig/file_upload.rbs +18 -0
  73. data/sig/form_builder.rbs +29 -0
  74. data/sig/funicular.rbs +11 -1
  75. data/sig/http.rbs +22 -0
  76. data/sig/model.rbs +23 -0
  77. data/sig/patcher.rbs +15 -0
  78. data/sig/router.rbs +43 -0
  79. data/sig/styles.rbs +25 -0
  80. data/sig/vdom.rbs +59 -0
  81. metadata +119 -8
data/sig/patcher.rbs ADDED
@@ -0,0 +1,15 @@
1
+ module Funicular
2
+ module VDOM
3
+ BOOLEAN_ATTRIBUTES: Array[String]
4
+
5
+ class Patcher
6
+ def initialize: (?JS::Object? doc) -> void
7
+ def apply: (JS::Object element, Array[patch_t] patches) -> JS::Object
8
+
9
+ private def update_props: (JS::Object element, Hash[Symbol, String?] props_patch) -> void
10
+ private def create_element: (untyped vnode) -> JS::Object
11
+ private def unmount_component: (VDOM::VNode vnode) -> void
12
+ end
13
+
14
+ end
15
+ end
data/sig/router.rbs ADDED
@@ -0,0 +1,43 @@
1
+ module Funicular
2
+ type route_constraints_t = Hash[Symbol, Regexp]
3
+ type route_definition_t = { method: Symbol, path: String, component: singleton(Component), name: String?, pattern_segments: Array[String], constraints: route_constraints_t }
4
+
5
+ # URL helper methods are dynamically generated based on route definitions
6
+ # Example: router.get('/users/:id', to: UserComponent, as: 'user')
7
+ # generates: user_path(id) -> String
8
+ module RouteHelpers
9
+ # Dynamic methods are generated at runtime by Router#generate_url_helper
10
+ # Method signatures depend on route parameters:
11
+ # - No parameters: def helper_name_path: () -> String
12
+ # - With parameters: def helper_name_path: (Integer | String | untyped) -> String
13
+ def method_missing: (Symbol method, *untyped args) -> String
14
+ def respond_to_missing?: (Symbol method, ?bool include_private) -> bool
15
+ end
16
+
17
+ class Router
18
+ attr_reader routes: Array[route_definition_t]
19
+ attr_reader current_component: Component?
20
+ attr_reader current_path: String?
21
+
22
+ def initialize: (JS::Object container) -> void
23
+ def get: (String path, to: singleton(Component), ?as: String?, ?constraints: route_constraints_t?) -> void
24
+ def post: (String path, to: singleton(Component), ?as: String?, ?constraints: route_constraints_t?) -> void
25
+ def put: (String path, to: singleton(Component), ?as: String?, ?constraints: route_constraints_t?) -> void
26
+ def patch: (String path, to: singleton(Component), ?as: String?, ?constraints: route_constraints_t?) -> void
27
+ def delete: (String path, to: singleton(Component), ?as: String?, ?constraints: route_constraints_t?) -> void
28
+ def add_route: (String path, singleton(Component) component_class, ?as: String?, ?constraints: route_constraints_t?) -> void
29
+ def set_default: (String path) -> void
30
+ def start: () -> void
31
+ def stop: () -> void
32
+ def navigate: (String path) -> void
33
+ def current_hash_path: () -> String
34
+ def current_location_path: () -> String
35
+
36
+ private def add_route_with_method: (Symbol method, String path, singleton(Component) component_class, String? name, ?route_constraints_t? constraints) -> void
37
+ private def generate_url_helper: (String name, String path_pattern) -> void
38
+ private def extract_param_names: (String path_pattern) -> Array[Symbol]
39
+ private def handle_route_change: () -> void
40
+ private def unmount_current_component: () -> void
41
+ private def find_route: (String path) -> [singleton(Component) | nil, Hash[Symbol, untyped]]
42
+ end
43
+ end
data/sig/styles.rbs ADDED
@@ -0,0 +1,25 @@
1
+ module Funicular
2
+ # StyleValue represents a CSS class string that can be combined with other styles
3
+ class StyleValue
4
+ attr_reader value: String
5
+ def initialize: (String | untyped value) -> void
6
+ def |: (StyleValue | String | nil other) -> StyleValue
7
+ def to_s: () -> String
8
+ end
9
+
10
+ # StyleAccessor provides access to defined styles via method calls
11
+ class StyleAccessor
12
+ def initialize: (Hash[Symbol, Hash[Symbol, untyped]] definitions) -> void
13
+ private def method_missing: (Symbol name, *untyped args) -> StyleValue
14
+ private def respond_to_missing?: (Symbol name, ?bool include_private) -> bool
15
+ end
16
+
17
+ # StyleBuilder is used to define styles within the styles {} block
18
+ class StyleBuilder
19
+ @definitions: Hash[Symbol, Hash[Symbol, untyped]]
20
+
21
+ def initialize: () -> void
22
+ def to_definitions: () -> Hash[Symbol, Hash[Symbol, untyped]]
23
+ private def method_missing: (Symbol name, *untyped args) -> void
24
+ end
25
+ end
data/sig/vdom.rbs ADDED
@@ -0,0 +1,59 @@
1
+ module Funicular
2
+ module VDOM
3
+ type patch_t = Array[untyped]
4
+ type child_t = Element | Text | Component | String | Array[Element | Text | Component | String]
5
+
6
+ URL_ATTRIBUTES: Array[String]
7
+
8
+ class VNode
9
+ attr_reader type: Symbol
10
+ attr_reader key: untyped
11
+
12
+ def initialize: (Symbol type) -> void
13
+ end
14
+
15
+ class Element < VNode
16
+ attr_reader tag: String
17
+ attr_reader props: Hash[Symbol, untyped]
18
+ attr_reader children: Array[child_t]
19
+
20
+ def initialize: (String tag, ?Hash[Symbol, untyped] props, ?Array[child_t] children) -> void
21
+ def ==: (untyped other) -> bool
22
+ private def normalize_children: (Array[child_t] children) -> Array[child_t]
23
+ end
24
+
25
+ class Text < VNode
26
+ attr_reader content: String
27
+
28
+ def initialize: (String content) -> void
29
+ def ==: (untyped other) -> bool
30
+ end
31
+
32
+ class Renderer
33
+ @error_boundary_stack: Array[Funicular::ErrorBoundary]
34
+
35
+ def initialize: (?JS::Object? doc) -> void
36
+ def render: (VDOM::VNode | VDOM::Text | nil vnode, ?JS::Object? parent) -> JS::Object
37
+
38
+ private def current_error_boundary: () -> ErrorBoundary?
39
+ private def render_element: (Element element, JS::Object? parent) -> JS::Object
40
+ private def render_text: (VDOM::Text text, JS::Object? parent) -> JS::Object
41
+ private def render_component: (VDOM::Component component_vnode, JS::Object? parent) -> JS::Object
42
+ end
43
+
44
+ def self.create_element: (String tag, ?Hash[Symbol, untyped] props, *child_t children) -> Element
45
+ def self.create_text: (String content) -> Text
46
+ def self.render: (VNode vnode, JS::Object container) -> void
47
+ def self.diff: (VNode? old_vnode, VNode? new_vnode) -> Array[patch_t]
48
+ def self.patch: (JS::Object element, Array[patch_t] patches) -> JS::Object
49
+
50
+ class Component < VNode
51
+ attr_reader component_class: untyped
52
+ attr_reader props: Hash[Symbol, untyped]
53
+ attr_accessor instance: untyped
54
+
55
+ def initialize: (untyped component_class, ?Hash[Symbol, untyped] props) -> void
56
+ def ==: (untyped other) -> bool
57
+ end
58
+ end
59
+ end
metadata CHANGED
@@ -1,18 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funicular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - HASUMI Hitoshi
8
8
  bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies: []
12
- description: Funicular is a tool
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rails
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '8.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '8.0'
26
+ description: Funicular enables you to write client-side UI components in Ruby, powered
27
+ by PicoRuby.wasm
13
28
  email:
14
29
  - hasumikin@gmail.com
15
- executables: []
30
+ executables:
31
+ - funicular
16
32
  extensions: []
17
33
  extra_rdoc_files: []
18
34
  files:
@@ -21,14 +37,108 @@ files:
21
37
  - LICENSE.txt
22
38
  - README.md
23
39
  - Rakefile
40
+ - demo/keymap_editor.html
41
+ - demo/test_cable.html
42
+ - demo/test_chartjs.html
43
+ - demo/test_component.html
44
+ - demo/test_diff_patch.html
45
+ - demo/test_error_boundary.html
46
+ - demo/test_router.html
47
+ - demo/test_vdom.html
48
+ - demo/tic-tac-toe.html
49
+ - docs/README.md
50
+ - docs/advanced-features.md
51
+ - docs/architecture.md
52
+ - docs/components-and-state.md
53
+ - docs/data-fetching.md
54
+ - docs/forms.md
55
+ - docs/rails-integration.md
56
+ - docs/realtime.md
57
+ - docs/routing-and-navigation.md
58
+ - docs/styling.md
59
+ - exe/funicular
24
60
  - lib/funicular.rb
61
+ - lib/funicular/assets/funicular.rb
62
+ - lib/funicular/assets/funicular_debug.css
63
+ - lib/funicular/assets/funicular_debug.js
64
+ - lib/funicular/commands/routes.rb
65
+ - lib/funicular/compiler.rb
66
+ - lib/funicular/configuration.rb
67
+ - lib/funicular/helpers/picoruby_helper.rb
68
+ - lib/funicular/middleware.rb
69
+ - lib/funicular/railtie.rb
70
+ - lib/funicular/route_parser.rb
71
+ - lib/funicular/vendor/picorbc/VERSION
72
+ - lib/funicular/vendor/picorbc/picorbc.js
73
+ - lib/funicular/vendor/picorbc/picorbc.wasm
74
+ - lib/funicular/vendor/picoruby/VERSION
75
+ - lib/funicular/vendor/picoruby/debug/init.iife.js
76
+ - lib/funicular/vendor/picoruby/debug/picoruby.js
77
+ - lib/funicular/vendor/picoruby/debug/picoruby.wasm
78
+ - lib/funicular/vendor/picoruby/dist/init.iife.js
79
+ - lib/funicular/vendor/picoruby/dist/picoruby.js
80
+ - lib/funicular/vendor/picoruby/dist/picoruby.wasm
25
81
  - lib/funicular/version.rb
82
+ - lib/tasks/funicular.rake
83
+ - minitest/funicular_test.rb
84
+ - minitest/test_helper.rb
85
+ - mrbgem.rake
86
+ - mrblib/cable.rb
87
+ - mrblib/component.rb
88
+ - mrblib/debug.rb
89
+ - mrblib/differ.rb
90
+ - mrblib/environment_inquirer.rb
91
+ - mrblib/error_boundary.rb
92
+ - mrblib/file_upload.rb
93
+ - mrblib/form_builder.rb
94
+ - mrblib/funicular.rb
95
+ - mrblib/http.rb
96
+ - mrblib/model.rb
97
+ - mrblib/patcher.rb
98
+ - mrblib/router.rb
99
+ - mrblib/styles.rb
100
+ - mrblib/vdom.rb
101
+ - sig/cable.rbs
102
+ - sig/component.rbs
103
+ - sig/debug.rbs
104
+ - sig/differ.rbs
105
+ - sig/environment_iquirer.rbs
106
+ - sig/error_boundary.rbs
107
+ - sig/file_upload.rbs
108
+ - sig/form_builder.rbs
26
109
  - sig/funicular.rbs
27
- homepage: https://github.com/hasumikin/funicular
110
+ - sig/http.rbs
111
+ - sig/model.rbs
112
+ - sig/patcher.rbs
113
+ - sig/router.rbs
114
+ - sig/styles.rbs
115
+ - sig/vdom.rbs
116
+ homepage: https://github.com/picoruby/funicular
28
117
  licenses:
29
118
  - MIT
30
119
  metadata:
31
- homepage_uri: https://github.com/hasumikin/funicular
120
+ homepage_uri: https://picoruby.org/funicular-getting-started
121
+ source_code_uri: https://github.com/picoruby/funicular
122
+ changelog_uri: https://github.com/picoruby/funicular/blob/master/CHANGELOG.md
123
+ post_install_message: |2+
124
+
125
+ Thank you for installing Funicular!
126
+
127
+ Funicular bundles a WebAssembly build of picorbc, which compiles your
128
+ Ruby code to .mrb bytecode. Make sure Node.js is installed on machines
129
+ that run the compilation.
130
+
131
+ Funicular works in two modes:
132
+
133
+ Standalone: include PicoRuby.wasm directly in any HTML page using the
134
+ bundled WASM artifacts. No server framework required.
135
+
136
+ Rails integration: use the Railtie, middleware, and view helpers for
137
+ seamless asset pipeline support.
138
+ bin/rails funicular:install
139
+
140
+ For more information: https://github.com/picoruby/funicular
141
+
32
142
  rdoc_options: []
33
143
  require_paths:
34
144
  - lib
@@ -43,7 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
153
  - !ruby/object:Gem::Version
44
154
  version: '0'
45
155
  requirements: []
46
- rubygems_version: 3.7.0.dev
156
+ rubygems_version: 4.0.4
47
157
  specification_version: 4
48
- summary: Funicular
158
+ summary: Rails plugin for client-side Ruby development with mruby
49
159
  test_files: []
160
+ ...