funicular 0.2.0 → 0.3.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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -0
  3. data/README.md +5 -5
  4. data/Rakefile +23 -15
  5. data/demo/test_chartjs.html +17 -17
  6. data/demo/test_component.html +15 -15
  7. data/demo/test_error_boundary.html +41 -41
  8. data/demo/test_router.html +57 -57
  9. data/demo/tic-tac-toe.html +29 -29
  10. data/docs/architecture.md +43 -30
  11. data/lib/funicular/compiler.rb +15 -16
  12. data/lib/funicular/helpers/picoruby_helper.rb +24 -1
  13. data/lib/funicular/ssr/runtime.rb +2 -0
  14. data/lib/funicular/ssr.rb +2 -1
  15. data/lib/funicular/testing/node_runner.rb +1 -1
  16. data/lib/funicular/vendor/mrbc/VERSION +1 -0
  17. data/lib/funicular/vendor/{picorbc/picorbc.js → mrbc/mrbc.js} +14 -1
  18. data/lib/funicular/vendor/mrbc/mrbc.wasm +0 -0
  19. data/lib/funicular/vendor/picoruby/VERSION +1 -1
  20. data/lib/funicular/vendor/picoruby/debug/init.iife.js +19 -4
  21. data/lib/funicular/vendor/picoruby/debug/picoruby.js +38 -23
  22. data/lib/funicular/vendor/picoruby/debug/picoruby.wasm +0 -0
  23. data/lib/funicular/vendor/picoruby/dist/init.iife.js +19 -4
  24. data/lib/funicular/vendor/picoruby/dist/picoruby.js +1 -1
  25. data/lib/funicular/vendor/picoruby/dist/picoruby.wasm +0 -0
  26. data/lib/funicular/vendor/picoruby-test-node/VERSION +1 -1
  27. data/lib/funicular/vendor/picoruby-test-node/picoruby.js +47 -23
  28. data/lib/funicular/vendor/picoruby-test-node/picoruby.wasm +0 -0
  29. data/lib/funicular/vendor/picoruby-test-node/picoruby.wasm.map +1 -1
  30. data/lib/funicular/version.rb +1 -1
  31. data/lib/generators/funicular/chat/templates/funicular_chat_component.rb.tt +47 -46
  32. data/lib/tasks/funicular.rake +1 -1
  33. data/minitest/commands_routes_test.rb +97 -0
  34. data/minitest/compiler_test.rb +195 -0
  35. data/minitest/configuration_test.rb +64 -0
  36. data/minitest/fixtures/funicular_app/components/greeting_component.rb +6 -6
  37. data/minitest/form_for_test.rb +106 -0
  38. data/minitest/funicular_test.rb +28 -2
  39. data/minitest/hydration_test.rb +2 -2
  40. data/minitest/middleware_test.rb +154 -0
  41. data/minitest/picoruby_helper_test.rb +139 -0
  42. data/minitest/route_parser_test.rb +139 -0
  43. data/minitest/schema_test.rb +23 -0
  44. data/minitest/ssr_test.rb +57 -0
  45. data/minitest/support/rails_stub.rb +59 -0
  46. data/minitest/test_helper.rb +20 -0
  47. data/minitest/testing_test.rb +267 -0
  48. data/minitest/view_context_test.rb +101 -0
  49. data/mrblib/component.rb +210 -229
  50. data/mrblib/debug.rb +7 -6
  51. data/mrblib/differ.rb +3 -1
  52. data/mrblib/error_boundary.rb +19 -27
  53. data/mrblib/form_builder.rb +34 -24
  54. data/mrblib/funicular.rb +2 -1
  55. data/mrblib/html_serializer.rb +14 -13
  56. data/mrblib/http.rb +12 -1
  57. data/mrblib/patcher.rb +16 -9
  58. data/mrblib/router.rb +9 -5
  59. data/mrblib/runtime.rb +28 -0
  60. data/mrblib/styles.rb +13 -17
  61. data/mrblib/vdom.rb +92 -9
  62. data/mrblib/view_context.rb +135 -0
  63. data/sig/component.rbs +34 -85
  64. data/sig/error_boundary.rbs +4 -4
  65. data/sig/form_builder.rbs +2 -1
  66. data/sig/html_serializer.rbs +2 -1
  67. data/sig/http.rbs +1 -0
  68. data/sig/patcher.rbs +1 -1
  69. data/sig/router.rbs +2 -13
  70. data/sig/runtime.rbs +13 -0
  71. data/sig/styles.rbs +3 -4
  72. data/sig/vdom.rbs +11 -2
  73. data/sig/view_context.rbs +47 -0
  74. metadata +19 -5
  75. data/lib/funicular/vendor/picorbc/VERSION +0 -1
  76. data/lib/funicular/vendor/picorbc/picorbc.wasm +0 -0
@@ -0,0 +1,47 @@
1
+ module Funicular
2
+ class ViewContext
3
+ HTML_TAGS: Array[String]
4
+
5
+ def initialize: (Component component) -> void
6
+ def state: () -> Component::StateAccessor
7
+ def props: () -> Hash[Symbol, untyped]
8
+ def resources: () -> Component::ResourceAccessor
9
+ def styles: () -> StyleAccessor
10
+ def routes: () -> untyped
11
+ def tag: (Symbol | String name, ?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
12
+ def component: (singleton(Component) component_class, ?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Component
13
+ def form_for: (Symbol model_key, ?Hash[Symbol, untyped] options) { (FormBuilder) -> void } -> VDOM::Element
14
+ def suspense: (Symbol name, fallback: untyped, ?error: untyped) { (ViewContext, Component::ResourceAccessor) -> untyped } -> untyped
15
+ def link_to: (String path, **untyped options) ?{ -> untyped } -> VDOM::Element
16
+ def button_to: (String path, ?method: Symbol, **untyped options) ?{ -> untyped } -> VDOM::Element
17
+ def capture: () { (ViewContext) -> untyped } -> Array[VDOM::child_t]
18
+ def add_child: (untyped child) -> void
19
+ private def build_element: (Symbol | String tag_name, ?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
20
+ private def normalize_props: (Hash[Symbol, untyped] props) -> Hash[Symbol, untyped]
21
+
22
+ def div: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
23
+ def span: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
24
+ def p: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
25
+ def a: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
26
+ def data: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
27
+ def h1: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
28
+ def h2: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
29
+ def h3: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
30
+ def h4: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
31
+ def h5: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
32
+ def h6: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
33
+ def ul: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
34
+ def ol: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
35
+ def li: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
36
+ def table: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
37
+ def form: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
38
+ def input: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
39
+ def textarea: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
40
+ def button: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
41
+ def select: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
42
+ def option: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
43
+ def label: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
44
+ def nav: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
45
+ def canvas: (?Hash[Symbol, untyped] props) ?{ (ViewContext) -> untyped } -> VDOM::Element
46
+ end
47
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funicular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - HASUMI Hitoshi
@@ -67,9 +67,9 @@ files:
67
67
  - lib/funicular/testing.rb
68
68
  - lib/funicular/testing/node_runner.mjs
69
69
  - lib/funicular/testing/node_runner.rb
70
- - lib/funicular/vendor/picorbc/VERSION
71
- - lib/funicular/vendor/picorbc/picorbc.js
72
- - lib/funicular/vendor/picorbc/picorbc.wasm
70
+ - lib/funicular/vendor/mrbc/VERSION
71
+ - lib/funicular/vendor/mrbc/mrbc.js
72
+ - lib/funicular/vendor/mrbc/mrbc.wasm
73
73
  - lib/funicular/vendor/picoruby-test-node/VERSION
74
74
  - lib/funicular/vendor/picoruby-test-node/picoruby.js
75
75
  - lib/funicular/vendor/picoruby-test-node/picoruby.wasm
@@ -96,15 +96,25 @@ files:
96
96
  - lib/generators/funicular/chat/templates/initializer.rb.tt
97
97
  - lib/generators/funicular/chat/templates/show.html.erb.tt
98
98
  - lib/tasks/funicular.rake
99
+ - minitest/commands_routes_test.rb
100
+ - minitest/compiler_test.rb
101
+ - minitest/configuration_test.rb
99
102
  - minitest/fixtures/funicular_app/components/greeting_component.rb
100
103
  - minitest/fixtures/funicular_app/initializer.rb
104
+ - minitest/form_for_test.rb
101
105
  - minitest/funicular_test.rb
102
106
  - minitest/hydration_test.rb
107
+ - minitest/middleware_test.rb
108
+ - minitest/picoruby_helper_test.rb
103
109
  - minitest/plugin_test.rb
110
+ - minitest/route_parser_test.rb
104
111
  - minitest/schema_test.rb
105
112
  - minitest/ssr_test.rb
113
+ - minitest/support/rails_stub.rb
106
114
  - minitest/test_helper.rb
115
+ - minitest/testing_test.rb
107
116
  - minitest/validations_test.rb
117
+ - minitest/view_context_test.rb
108
118
  - mrbgem.rake
109
119
  - mrblib/0_validations.rb
110
120
  - mrblib/1_validators.rb
@@ -122,11 +132,13 @@ files:
122
132
  - mrblib/model.rb
123
133
  - mrblib/patcher.rb
124
134
  - mrblib/router.rb
135
+ - mrblib/runtime.rb
125
136
  - mrblib/store.rb
126
137
  - mrblib/store_collection.rb
127
138
  - mrblib/store_singleton.rb
128
139
  - mrblib/styles.rb
129
140
  - mrblib/vdom.rb
141
+ - mrblib/view_context.rb
130
142
  - sig/cable.rbs
131
143
  - sig/component.rbs
132
144
  - sig/debug.rbs
@@ -141,12 +153,14 @@ files:
141
153
  - sig/model.rbs
142
154
  - sig/patcher.rbs
143
155
  - sig/router.rbs
156
+ - sig/runtime.rbs
144
157
  - sig/store.rbs
145
158
  - sig/store_collection.rbs
146
159
  - sig/store_singleton.rbs
147
160
  - sig/styles.rbs
148
161
  - sig/validations.rbs
149
162
  - sig/vdom.rbs
163
+ - sig/view_context.rbs
150
164
  homepage: https://github.com/picoruby/funicular
151
165
  licenses:
152
166
  - MIT
@@ -158,7 +172,7 @@ post_install_message: |2+
158
172
 
159
173
  Thank you for installing Funicular!
160
174
 
161
- Funicular bundles a WebAssembly build of picorbc, which compiles your
175
+ Funicular bundles a WebAssembly build of mrbc, which compiles your
162
176
  Ruby code to .mrb bytecode. Make sure Node.js is installed on machines
163
177
  that run the compilation.
164
178
 
@@ -1 +0,0 @@
1
- 4.0.0