funicular 0.2.1 → 0.4.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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +111 -0
  3. data/README.md +2 -2
  4. data/Rakefile +23 -15
  5. data/demo/test_chartjs.html +8 -8
  6. data/demo/test_component.html +8 -8
  7. data/demo/test_error_boundary.html +8 -5
  8. data/demo/test_router.html +11 -11
  9. data/demo/tic-tac-toe.html +4 -4
  10. data/docs/architecture.md +80 -30
  11. data/lib/funicular/compiler.rb +13 -13
  12. data/lib/funicular/helpers/picoruby_helper.rb +24 -1
  13. data/lib/funicular/ssr/runtime.rb +3 -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} +626 -486
  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 +675 -449
  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 +2 -2
  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 +860 -567
  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 +25 -25
  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/dsl_test.rb +237 -0
  37. data/minitest/fixtures/funicular_app/components/greeting_component.rb +2 -2
  38. data/minitest/funicular_test.rb +28 -2
  39. data/minitest/middleware_test.rb +154 -0
  40. data/minitest/picoruby_helper_test.rb +139 -0
  41. data/minitest/route_parser_test.rb +139 -0
  42. data/minitest/schema_test.rb +23 -0
  43. data/minitest/sig_tags_test.rb +30 -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/0_tags.rb +62 -0
  50. data/mrblib/component.rb +255 -244
  51. data/mrblib/debug.rb +7 -6
  52. data/mrblib/differ.rb +3 -1
  53. data/mrblib/error_boundary.rb +11 -13
  54. data/mrblib/form_builder.rb +28 -24
  55. data/mrblib/funicular.rb +2 -1
  56. data/mrblib/html_serializer.rb +14 -13
  57. data/mrblib/http.rb +12 -1
  58. data/mrblib/patcher.rb +12 -9
  59. data/mrblib/router.rb +9 -5
  60. data/mrblib/runtime.rb +28 -0
  61. data/mrblib/styles.rb +107 -21
  62. data/mrblib/vdom.rb +90 -9
  63. data/mrblib/view_context.rb +106 -0
  64. data/sig/component.rbs +47 -84
  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 +19 -7
  72. data/sig/tags.rbs +54 -0
  73. data/sig/vdom.rbs +11 -2
  74. data/sig/view_context.rbs +60 -0
  75. metadata +22 -5
  76. data/lib/funicular/vendor/picorbc/VERSION +0 -1
  77. data/lib/funicular/vendor/picorbc/picorbc.wasm +0 -0
data/sig/vdom.rbs CHANGED
@@ -4,6 +4,13 @@ module Funicular
4
4
  type child_t = Element | Text | Component | String | Array[Element | Text | Component | String]
5
5
 
6
6
  URL_ATTRIBUTES: Array[String]
7
+ SCRIPTING_ELEMENTS: Array[String]
8
+
9
+ def self.valid_tag_name?: (untyped name) -> bool
10
+ def self.valid_attribute_name?: (untyped name) -> bool
11
+ def self.event_attribute?: (untyped name) -> bool
12
+ def self.unsafe_url?: (untyped name, untyped value) -> bool
13
+ def self.blocked_attribute?: (untyped name, untyped value) -> bool
7
14
 
8
15
  class VNode
9
16
  attr_reader type: Symbol
@@ -32,7 +39,7 @@ module Funicular
32
39
  class Renderer
33
40
  @error_boundary_stack: Array[Funicular::ErrorBoundary]
34
41
 
35
- def initialize: (?JS::Element? doc) -> void
42
+ def initialize: (?JS::Element? doc, ?Runtime? runtime) -> void
36
43
  def render: (VDOM::VNode | VDOM::Text | nil vnode, ?JS::Element? parent) -> JS::Element
37
44
 
38
45
  private def current_error_boundary: () -> ErrorBoundary?
@@ -50,9 +57,11 @@ module Funicular
50
57
  class Component < VNode
51
58
  attr_reader component_class: untyped
52
59
  attr_reader props: Hash[Symbol, untyped]
60
+ attr_reader children: Array[child_t]
53
61
  attr_accessor instance: untyped
62
+ attr_accessor runtime: Runtime?
54
63
 
55
- def initialize: (untyped component_class, ?Hash[Symbol, untyped] props) -> void
64
+ def initialize: (untyped component_class, ?Hash[Symbol, untyped] props, ?Array[child_t] children) -> void
56
65
  def ==: (untyped other) -> bool
57
66
  end
58
67
  end
@@ -0,0 +1,60 @@
1
+ module Funicular
2
+ # Internal element factory. Application code uses the bareword tag DSL
3
+ # on Component (see sig/tags.rbs); ViewContext is what FormBuilder, the
4
+ # framework helpers, and ErrorBoundary fallback procs build through.
5
+ class ViewContext
6
+ HTML_TAGS: Array[String]
7
+
8
+ def initialize: (Component component) -> void
9
+ def tag: (Symbol | String name, ?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
10
+ def component: (singleton(Component) component_class, ?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Component
11
+ def form_for: (Symbol model_key, ?Hash[Symbol, untyped] options) { (FormBuilder) -> void } -> VDOM::Element
12
+ def suspense: (Symbol name, fallback: untyped, ?error: untyped) { (Component::ResourceAccessor) -> untyped } -> untyped
13
+ def link_to: (String path, **untyped options) ?{ -> untyped } -> VDOM::Element
14
+ def button_to: (String path, ?method: Symbol, **untyped options) ?{ -> untyped } -> VDOM::Element
15
+ def capture: () { () -> untyped } -> Array[VDOM::child_t]
16
+ def add_child: (untyped child) -> void
17
+ private def build_element: (Symbol | String tag_name, ?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
18
+ private def normalize_props: (Hash[Symbol, untyped] props) -> Hash[Symbol, untyped]
19
+
20
+ def div: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
21
+ def span: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
22
+ def p: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
23
+ def a: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
24
+ def data: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
25
+ def h1: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
26
+ def h2: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
27
+ def h3: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
28
+ def h4: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
29
+ def h5: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
30
+ def h6: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
31
+ def ul: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
32
+ def ol: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
33
+ def li: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
34
+ def table: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
35
+ def thead: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
36
+ def tbody: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
37
+ def tr: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
38
+ def th: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
39
+ def td: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
40
+ def form: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
41
+ def input: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
42
+ def textarea: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
43
+ def button: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
44
+ def select: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
45
+ def option: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
46
+ def label: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
47
+ def header: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
48
+ def footer: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
49
+ def nav: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
50
+ def section: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
51
+ def article: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
52
+ def aside: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
53
+ def img: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
54
+ def video: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
55
+ def audio: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
56
+ def canvas: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
57
+ def br: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
58
+ def hr: (?Hash[Symbol, untyped] props) ?{ () -> untyped } -> VDOM::Element
59
+ end
60
+ 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.1
4
+ version: 0.4.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,17 +96,29 @@ 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
102
+ - minitest/dsl_test.rb
99
103
  - minitest/fixtures/funicular_app/components/greeting_component.rb
100
104
  - minitest/fixtures/funicular_app/initializer.rb
101
105
  - minitest/form_for_test.rb
102
106
  - minitest/funicular_test.rb
103
107
  - minitest/hydration_test.rb
108
+ - minitest/middleware_test.rb
109
+ - minitest/picoruby_helper_test.rb
104
110
  - minitest/plugin_test.rb
111
+ - minitest/route_parser_test.rb
105
112
  - minitest/schema_test.rb
113
+ - minitest/sig_tags_test.rb
106
114
  - minitest/ssr_test.rb
115
+ - minitest/support/rails_stub.rb
107
116
  - minitest/test_helper.rb
117
+ - minitest/testing_test.rb
108
118
  - minitest/validations_test.rb
119
+ - minitest/view_context_test.rb
109
120
  - mrbgem.rake
121
+ - mrblib/0_tags.rb
110
122
  - mrblib/0_validations.rb
111
123
  - mrblib/1_validators.rb
112
124
  - mrblib/cable.rb
@@ -123,11 +135,13 @@ files:
123
135
  - mrblib/model.rb
124
136
  - mrblib/patcher.rb
125
137
  - mrblib/router.rb
138
+ - mrblib/runtime.rb
126
139
  - mrblib/store.rb
127
140
  - mrblib/store_collection.rb
128
141
  - mrblib/store_singleton.rb
129
142
  - mrblib/styles.rb
130
143
  - mrblib/vdom.rb
144
+ - mrblib/view_context.rb
131
145
  - sig/cable.rbs
132
146
  - sig/component.rbs
133
147
  - sig/debug.rbs
@@ -142,12 +156,15 @@ files:
142
156
  - sig/model.rbs
143
157
  - sig/patcher.rbs
144
158
  - sig/router.rbs
159
+ - sig/runtime.rbs
145
160
  - sig/store.rbs
146
161
  - sig/store_collection.rbs
147
162
  - sig/store_singleton.rbs
148
163
  - sig/styles.rbs
164
+ - sig/tags.rbs
149
165
  - sig/validations.rbs
150
166
  - sig/vdom.rbs
167
+ - sig/view_context.rbs
151
168
  homepage: https://github.com/picoruby/funicular
152
169
  licenses:
153
170
  - MIT
@@ -159,7 +176,7 @@ post_install_message: |2+
159
176
 
160
177
  Thank you for installing Funicular!
161
178
 
162
- Funicular bundles a WebAssembly build of picorbc, which compiles your
179
+ Funicular bundles a WebAssembly build of mrbc, which compiles your
163
180
  Ruby code to .mrb bytecode. Make sure Node.js is installed on machines
164
181
  that run the compilation.
165
182
 
@@ -1 +0,0 @@
1
- 4.0.0