isomorfeus-react 16.13.11 → 16.13.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/lib/isomorfeus/react/config.rb +189 -189
  4. data/lib/isomorfeus/react/memcached_component_cache.rb +19 -19
  5. data/lib/isomorfeus/react/redis_component_cache.rb +19 -19
  6. data/lib/isomorfeus/react/thread_local_component_cache.rb +15 -15
  7. data/lib/isomorfeus/react_view_helper.rb +231 -231
  8. data/lib/isomorfeus/top_level.rb +103 -103
  9. data/lib/isomorfeus/top_level_ssr.rb +42 -42
  10. data/lib/isomorfeus-react-material-ui.rb +4 -4
  11. data/lib/isomorfeus-react-native.rb +5 -5
  12. data/lib/isomorfeus-react-paper.rb +4 -4
  13. data/lib/isomorfeus-react.rb +120 -120
  14. data/lib/isomorfeus_react/lucid_app/api.rb +26 -26
  15. data/lib/isomorfeus_react/lucid_app/base.rb +7 -7
  16. data/lib/isomorfeus_react/lucid_app/mixin.rb +23 -23
  17. data/lib/isomorfeus_react/lucid_app/native_component_constructor.rb +48 -48
  18. data/lib/isomorfeus_react/lucid_app/native_lucid_component_constructor.rb +94 -95
  19. data/lib/isomorfeus_react/lucid_component/api.rb +75 -75
  20. data/lib/isomorfeus_react/lucid_component/app_store_proxy.rb +37 -37
  21. data/lib/isomorfeus_react/lucid_component/base.rb +7 -7
  22. data/lib/isomorfeus_react/lucid_component/class_store_proxy.rb +44 -44
  23. data/lib/isomorfeus_react/lucid_component/initializer.rb +14 -14
  24. data/lib/isomorfeus_react/lucid_component/instance_store_proxy.rb +44 -44
  25. data/lib/isomorfeus_react/lucid_component/mixin.rb +22 -22
  26. data/lib/isomorfeus_react/lucid_component/native_component_constructor.rb +35 -35
  27. data/lib/isomorfeus_react/lucid_component/native_lucid_component_constructor.rb +82 -83
  28. data/lib/isomorfeus_react/lucid_component/styles_api.rb +34 -34
  29. data/lib/isomorfeus_react/lucid_func/base.rb +7 -7
  30. data/lib/isomorfeus_react/lucid_func/initializer.rb +11 -11
  31. data/lib/isomorfeus_react/lucid_func/mixin.rb +18 -18
  32. data/lib/isomorfeus_react/lucid_func/native_component_constructor.rb +81 -81
  33. data/lib/isomorfeus_react/react/function_component/api.rb +105 -105
  34. data/lib/isomorfeus_react/react/function_component/base.rb +8 -8
  35. data/lib/isomorfeus_react/react/function_component/initializer.rb +10 -10
  36. data/lib/isomorfeus_react/react/function_component/mixin.rb +17 -17
  37. data/lib/isomorfeus_react/react/function_component/native_component_constructor.rb +48 -48
  38. data/lib/isomorfeus_react/react/memo_component/base.rb +8 -8
  39. data/lib/isomorfeus_react/react/memo_component/mixin.rb +17 -17
  40. data/lib/isomorfeus_react/react/memo_component/native_component_constructor.rb +49 -49
  41. data/lib/isomorfeus_react_material/lucid_material/app/base.rb +8 -8
  42. data/lib/isomorfeus_react_material/lucid_material/app/mixin.rb +20 -20
  43. data/lib/isomorfeus_react_material/lucid_material/app/native_component_constructor.rb +50 -50
  44. data/lib/isomorfeus_react_material/lucid_material/component/base.rb +9 -9
  45. data/lib/isomorfeus_react_material/lucid_material/component/mixin.rb +19 -19
  46. data/lib/isomorfeus_react_material/lucid_material/component/native_component_constructor.rb +36 -36
  47. data/lib/isomorfeus_react_material/lucid_material/func/base.rb +9 -9
  48. data/lib/isomorfeus_react_material/lucid_material/func/mixin.rb +15 -15
  49. data/lib/isomorfeus_react_material/lucid_material/func/native_component_constructor.rb +83 -83
  50. data/lib/isomorfeus_react_paper/lucid_paper/app/base.rb +9 -9
  51. data/lib/isomorfeus_react_paper/lucid_paper/app/mixin.rb +19 -19
  52. data/lib/isomorfeus_react_paper/lucid_paper/app/native_component_constructor.rb +32 -32
  53. data/lib/isomorfeus_react_paper/lucid_paper/component/base.rb +9 -9
  54. data/lib/isomorfeus_react_paper/lucid_paper/component/mixin.rb +18 -18
  55. data/lib/isomorfeus_react_paper/lucid_paper/component/native_component_constructor.rb +25 -25
  56. data/lib/isomorfeus_react_paper/lucid_paper/func/base.rb +9 -9
  57. data/lib/isomorfeus_react_paper/lucid_paper/func/mixin.rb +14 -14
  58. data/lib/isomorfeus_react_paper/lucid_paper/func/native_component_constructor.rb +71 -71
  59. data/lib/lucid_app/context.rb +7 -7
  60. data/lib/lucid_prop_declaration/mixin.rb +126 -126
  61. data/lib/react/children.rb +34 -34
  62. data/lib/react/component/api.rb +134 -134
  63. data/lib/react/component/base.rb +8 -8
  64. data/lib/react/component/callbacks.rb +115 -115
  65. data/lib/react/component/elements.rb +60 -60
  66. data/lib/react/component/features.rb +48 -48
  67. data/lib/react/component/history.rb +69 -65
  68. data/lib/react/component/initializer.rb +11 -11
  69. data/lib/react/component/location.rb +19 -15
  70. data/lib/react/component/match.rb +35 -31
  71. data/lib/react/component/mixin.rb +20 -20
  72. data/lib/react/component/native_component_constructor.rb +69 -70
  73. data/lib/react/component/props.rb +83 -83
  74. data/lib/react/component/resolution.rb +97 -97
  75. data/lib/react/component/state.rb +58 -54
  76. data/lib/react/component/styles.rb +66 -66
  77. data/lib/react/context_wrapper.rb +48 -44
  78. data/lib/react/native_constant_wrapper.rb +29 -29
  79. data/lib/react/ref.rb +16 -12
  80. data/lib/react/synthetic_event.rb +52 -52
  81. data/lib/react/version.rb +3 -3
  82. data/lib/react.rb +296 -296
  83. data/lib/react_dom.rb +41 -41
  84. data/lib/react_dom_server.rb +18 -18
  85. data/lib/react_native/component/elements.rb +203 -203
  86. data/lib/react_native/lucid_app/react_native_component_constructor.rb +51 -51
  87. data/lib/react_native/lucid_component/react_native_component_constructor.rb +37 -37
  88. data/lib/react_native/lucid_func/react_native_component_constructor.rb +82 -82
  89. data/lib/react_native/react.rb +120 -120
  90. metadata +23 -17
@@ -1,103 +1,103 @@
1
- module Isomorfeus
2
- class TopLevel
3
- class << self
4
- def mount!
5
- Isomorfeus.init
6
- Isomorfeus::TopLevel.on_ready do
7
- root_element = `document.querySelector('div[data-iso-root]')`
8
- Isomorfeus.raise_error(message: "Isomorfeus root element not found!") unless root_element
9
- component_name = root_element.JS.getAttribute('data-iso-root')
10
- Isomorfeus.env = root_element.JS.getAttribute('data-iso-env')
11
- user_sid = root_element.JS.getAttribute('data-iso-usid')
12
- Isomorfeus.current_user_sid =`JSON.parse(user_sid)` if user_sid
13
- component = nil
14
- begin
15
- component = component_name.constantize
16
- rescue Exception => e
17
- `console.warn("Deferring mount: " + #{e.message})`
18
- @timeout_start = Time.now unless @timeout_start
19
- if (Time.now - @timeout_start) < 10
20
- `setTimeout(Opal.Isomorfeus.TopLevel['$mount!'], 100)`
21
- else
22
- `console.error("Unable to mount '" + #{component_name} + "'!")`
23
- end
24
- end
25
- if component
26
- props_json = root_element.JS.getAttribute('data-iso-props')
27
- props = `Opal.Hash.$new(JSON.parse(props_json))`
28
- raw_hydrated = root_element.JS.getAttribute('data-iso-hydrated')
29
- hydrated = (raw_hydrated && raw_hydrated == "true")
30
- #state_json = root_element.JS.getAttribute('data-iso-state')
31
- #if state_json
32
- %x{
33
- if (global.ServerSideRenderingStateJSON) {
34
- var state = global.ServerSideRenderingStateJSON;
35
- var keys = Object.keys(state);
36
- for(var i=0; i < keys.length; i++) {
37
- if (Object.keys(state[keys[i]]).length > 0) {
38
- global.Opal.Isomorfeus.store.native.dispatch({ type: keys[i].toUpperCase(), set_state: state[keys[i]] });
39
- }
40
- }
41
- }
42
- }
43
- #end
44
- Isomorfeus.execute_init_after_store_classes
45
- begin
46
- result = Isomorfeus::TopLevel.mount_component(component, props, root_element, hydrated)
47
- @tried_another_time = false
48
- result
49
- rescue Exception => e
50
- if !@tried_another_time
51
- @tried_another_time = true
52
- `console.warn("Deferring mount: " + #{e.message})`
53
- `setTimeout(Opal.Isomorfeus.TopLevel['$mount!'], 250)`
54
- else
55
- `console.error("Unable to mount '" + #{component_name} + "'! Error: " + #{e.message} + "!")`
56
- `console.error(#{e.backtrace.join("\n")})`
57
- end
58
- end
59
- end
60
- end
61
- end
62
-
63
- def on_ready(&block)
64
- %x{
65
- function run() { block.$call() };
66
- function ready_fun(fn) {
67
- if (document.readyState === "complete" || document.readyState === "interactive") {
68
- setTimeout(fn, 1);
69
- } else {
70
- document.addEventListener("DOMContentLoaded", fn);
71
- }
72
- }
73
- ready_fun(run);
74
- }
75
- end
76
-
77
- def on_ready_mount(component, props = nil, element_query = nil)
78
- # init in case it hasn't been run yet
79
- Isomorfeus.init
80
- on_ready do
81
- Isomorfeus::TopLevel.mount_component(component, props, element_query)
82
- end
83
- end
84
-
85
- def mount_component(component, props, element_or_query, hydrated = false)
86
- if `(typeof element_or_query === 'string')` || (`(typeof element_or_query.$class === 'function')` && element_or_query.class == String)
87
- element = `document.body.querySelector(element_or_query)`
88
- elsif `(typeof element_or_query.$is_a === 'function')` && element_or_query.is_a?(Browser::Element)
89
- element = element_or_query.to_n
90
- else
91
- element = element_or_query
92
- end
93
-
94
- top = if hydrated
95
- ReactDOM.hydrate(React.create_element(component, props), element)
96
- else
97
- ReactDOM.render(React.create_element(component, props), element)
98
- end
99
- Isomorfeus.top_component = top if top
100
- end
101
- end
102
- end
103
- end
1
+ module Isomorfeus
2
+ class TopLevel
3
+ class << self
4
+ def mount!
5
+ Isomorfeus.init
6
+ Isomorfeus::TopLevel.on_ready do
7
+ root_element = `document.querySelector('div[data-iso-root]')`
8
+ Isomorfeus.raise_error(message: "Isomorfeus root element not found!") unless root_element
9
+ component_name = root_element.JS.getAttribute('data-iso-root')
10
+ Isomorfeus.env = root_element.JS.getAttribute('data-iso-env')
11
+ user_sid = root_element.JS.getAttribute('data-iso-usid')
12
+ Isomorfeus.current_user_sid =`JSON.parse(user_sid)` if user_sid
13
+ component = nil
14
+ begin
15
+ component = component_name.constantize
16
+ rescue Exception => e
17
+ `console.warn("Deferring mount: " + #{e.message})`
18
+ @timeout_start = Time.now unless @timeout_start
19
+ if (Time.now - @timeout_start) < 10
20
+ `setTimeout(Opal.Isomorfeus.TopLevel['$mount!'], 100)`
21
+ else
22
+ `console.error("Unable to mount '" + #{component_name} + "'!")`
23
+ end
24
+ end
25
+ if component
26
+ props_json = root_element.JS.getAttribute('data-iso-props')
27
+ props = `Opal.Hash.$new(JSON.parse(props_json))`
28
+ raw_hydrated = root_element.JS.getAttribute('data-iso-hydrated')
29
+ hydrated = (raw_hydrated && raw_hydrated == "true")
30
+ #state_json = root_element.JS.getAttribute('data-iso-state')
31
+ #if state_json
32
+ %x{
33
+ if (global.ServerSideRenderingStateJSON) {
34
+ var state = global.ServerSideRenderingStateJSON;
35
+ var keys = Object.keys(state);
36
+ for(var i=0; i < keys.length; i++) {
37
+ if (Object.keys(state[keys[i]]).length > 0) {
38
+ global.Opal.Isomorfeus.store.native.dispatch({ type: keys[i].toUpperCase(), set_state: state[keys[i]] });
39
+ }
40
+ }
41
+ }
42
+ }
43
+ #end
44
+ Isomorfeus.execute_init_after_store_classes
45
+ begin
46
+ result = Isomorfeus::TopLevel.mount_component(component, props, root_element, hydrated)
47
+ @tried_another_time = false
48
+ result
49
+ rescue Exception => e
50
+ if !@tried_another_time
51
+ @tried_another_time = true
52
+ `console.warn("Deferring mount: " + #{e.message})`
53
+ `setTimeout(Opal.Isomorfeus.TopLevel['$mount!'], 250)`
54
+ else
55
+ `console.error("Unable to mount '" + #{component_name} + "'! Error: " + #{e.message} + "!")`
56
+ `console.error(#{e.backtrace.join("\n")})`
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ def on_ready(&block)
64
+ %x{
65
+ function run() { block.$call() };
66
+ function ready_fun(fn) {
67
+ if (document.readyState === "complete" || document.readyState === "interactive") {
68
+ setTimeout(fn, 1);
69
+ } else {
70
+ document.addEventListener("DOMContentLoaded", fn);
71
+ }
72
+ }
73
+ ready_fun(run);
74
+ }
75
+ end
76
+
77
+ def on_ready_mount(component, props = nil, element_query = nil)
78
+ # init in case it hasn't been run yet
79
+ Isomorfeus.init
80
+ on_ready do
81
+ Isomorfeus::TopLevel.mount_component(component, props, element_query)
82
+ end
83
+ end
84
+
85
+ def mount_component(component, props, element_or_query, hydrated = false)
86
+ if `(typeof element_or_query === 'string')` || (`(typeof element_or_query.$class === 'function')` && element_or_query.class == String)
87
+ element = `document.body.querySelector(element_or_query)`
88
+ elsif `(typeof element_or_query.$is_a === 'function')` && element_or_query.is_a?(Browser::Element)
89
+ element = element_or_query.to_n
90
+ else
91
+ element = element_or_query
92
+ end
93
+
94
+ top = if hydrated
95
+ ReactDOM.hydrate(React.create_element(component, props), element)
96
+ else
97
+ ReactDOM.render(React.create_element(component, props), element)
98
+ end
99
+ Isomorfeus.top_component = top if top
100
+ end
101
+ end
102
+ end
103
+ end
@@ -1,42 +1,42 @@
1
- module Isomorfeus
2
- class TopLevel
3
- class << self
4
- attr_accessor :ssr_route_path
5
- attr_accessor :transport_ws_url
6
-
7
- def mount!
8
- # nothing, but keep it for compatibility with browser
9
- end
10
-
11
- def render_component_to_static_markup(component_name, props)
12
- component = nil
13
- %x{
14
- if (typeof component_name === 'string' || component_name instanceof String) {
15
- component = component_name.split(".").reduce(function(o, x) {
16
- return (o !== null && typeof o[x] !== "undefined" && o[x] !== null) ? o[x] : null;
17
- }, Opal.global)
18
- } else {
19
- component = component_name;
20
- }
21
- }
22
- component = Isomorfeus.cached_component_class(component_name) unless component
23
- ReactDOMServer.render_to_static_markup(React.create_element(component, `Opal.Hash.$new(props)`))
24
- end
25
-
26
- def render_component_to_string(component_name, props)
27
- component = nil
28
- %x{
29
- if (typeof component_name === 'string' || component_name instanceof String) {
30
- component = component_name.split(".").reduce(function(o, x) {
31
- return (o !== null && typeof o[x] !== "undefined" && o[x] !== null) ? o[x] : null;
32
- }, Opal.global)
33
- } else {
34
- component = component_name;
35
- }
36
- }
37
- component = Isomorfeus.cached_component_class(component_name) unless component
38
- ReactDOMServer.render_to_string(React.create_element(component, `Opal.Hash.$new(props)`))
39
- end
40
- end
41
- end
42
- end
1
+ module Isomorfeus
2
+ class TopLevel
3
+ class << self
4
+ attr_accessor :ssr_route_path
5
+ attr_accessor :transport_ws_url
6
+
7
+ def mount!
8
+ # nothing, but keep it for compatibility with browser
9
+ end
10
+
11
+ def render_component_to_static_markup(component_name, props)
12
+ component = nil
13
+ %x{
14
+ if (typeof component_name === 'string' || component_name instanceof String) {
15
+ component = component_name.split(".").reduce(function(o, x) {
16
+ return (o !== null && typeof o[x] !== "undefined" && o[x] !== null) ? o[x] : null;
17
+ }, Opal.global)
18
+ } else {
19
+ component = component_name;
20
+ }
21
+ }
22
+ component = Isomorfeus.cached_component_class(component_name) unless component
23
+ ReactDOMServer.render_to_static_markup(React.create_element(component, `Opal.Hash.$new(props)`))
24
+ end
25
+
26
+ def render_component_to_string(component_name, props)
27
+ component = nil
28
+ %x{
29
+ if (typeof component_name === 'string' || component_name instanceof String) {
30
+ component = component_name.split(".").reduce(function(o, x) {
31
+ return (o !== null && typeof o[x] !== "undefined" && o[x] !== null) ? o[x] : null;
32
+ }, Opal.global)
33
+ } else {
34
+ component = component_name;
35
+ }
36
+ }
37
+ component = Isomorfeus.cached_component_class(component_name) unless component
38
+ ReactDOMServer.render_to_string(React.create_element(component, `Opal.Hash.$new(props)`))
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,4 +1,4 @@
1
- require 'isomorfeus-react'
2
-
3
- Isomorfeus.zeitwerk.push_dir('isomorfeus_react_material')
4
- require_tree 'isomorfeus_react_material', :autoload
1
+ require 'isomorfeus-react'
2
+
3
+ Isomorfeus.zeitwerk.push_dir('isomorfeus_react_material')
4
+ require_tree 'isomorfeus_react_material', :autoload
@@ -1,5 +1,5 @@
1
- require 'react_native/react'
2
- require 'react_native/component/elements'
3
- require 'react_native/lucid_app/react_native_component_constructor'
4
- require 'react_native/lucid_component/react_native_component_constructor'
5
- require 'react_native/lucid_func/react_native_component_constructor'
1
+ require 'react_native/react'
2
+ require 'react_native/component/elements'
3
+ require 'react_native/lucid_app/react_native_component_constructor'
4
+ require 'react_native/lucid_component/react_native_component_constructor'
5
+ require 'react_native/lucid_func/react_native_component_constructor'
@@ -1,4 +1,4 @@
1
- require 'isomorfeus-react'
2
-
3
- Isomorfeus.zeitwerk.push_dir('isomorfeus_react_paper')
4
- require_tree 'isomorfeus_react_paper', :autoload
1
+ require 'isomorfeus-react'
2
+
3
+ Isomorfeus.zeitwerk.push_dir('isomorfeus_react_paper')
4
+ require_tree 'isomorfeus_react_paper', :autoload
@@ -1,120 +1,120 @@
1
- if RUBY_ENGINE == 'opal'
2
- require 'isomorfeus-redux'
3
- require 'active_support/core_ext/string'
4
- require 'zeitwerk'
5
-
6
- if on_browser?
7
- require 'browser/event'
8
- require 'browser/event_target'
9
- require 'browser/delegate_native'
10
- require 'browser/element'
11
- end
12
-
13
- require 'isomorfeus/react/config'
14
-
15
- # allow mounting of components
16
- if on_browser?
17
- require 'isomorfeus/top_level'
18
- else
19
- require 'isomorfeus/top_level_ssr'
20
- end
21
-
22
- # react
23
- require 'react/version'
24
- require 'react'
25
- require 'react/synthetic_event'
26
- require 'react/ref'
27
- require 'react/children'
28
- if on_browser?
29
- require 'react_dom'
30
- else
31
- require 'react_dom_server'
32
- end
33
-
34
- # props
35
- require 'isomorfeus/props/validate_hash_proxy'
36
- require 'isomorfeus/props/validator'
37
- require 'lucid_prop_declaration/mixin'
38
- require 'react/component/props'
39
-
40
- # HTML Elements support
41
- require 'react/component/elements'
42
-
43
- # React Features
44
- require 'react/component/features'
45
- require 'react/context_wrapper'
46
- require 'react/native_constant_wrapper'
47
-
48
- # React::Component
49
- require 'react/component/api'
50
- require 'react/component/callbacks'
51
- require 'react/component/initializer'
52
- require 'react/component/native_component_constructor'
53
- require 'react/component/state'
54
- require 'react/component/match'
55
- require 'react/component/location'
56
- require 'react/component/history'
57
- require 'react/component/resolution'
58
- require 'react/component/styles'
59
- require 'react/component/mixin'
60
- require 'react/component/base'
61
-
62
- # init LucidApplicationContext (Store Provider and Consumer)
63
- require 'lucid_app/context'
64
- LucidApp::Context.create_application_context
65
-
66
- class Object
67
- include React::Component::Resolution
68
- end
69
-
70
- Isomorfeus.zeitwerk = Zeitwerk::Loader.new
71
-
72
- Isomorfeus.zeitwerk.push_dir('isomorfeus_react')
73
- require_tree 'isomorfeus_react', :autoload
74
-
75
- Isomorfeus.zeitwerk.push_dir('components')
76
- else
77
- require 'uri'
78
- require 'oj'
79
- require 'opal'
80
- require 'opal-activesupport'
81
- require 'opal-zeitwerk'
82
- require 'opal-webpack-loader'
83
- require 'isomorfeus-redux'
84
- require 'isomorfeus-speednode'
85
- require 'react/version'
86
- require 'isomorfeus/react/config'
87
-
88
- # props
89
- require 'isomorfeus/props/validate_hash_proxy'
90
- require 'isomorfeus/props/validator'
91
- require 'lucid_prop_declaration/mixin'
92
-
93
- Isomorfeus.env = ENV['RACK_ENV']
94
-
95
- if Isomorfeus.development?
96
- require 'net/http'
97
- Isomorfeus.ssr_hot_asset_url = 'http://localhost:3036/assets/'
98
- end
99
-
100
- Isomorfeus.server_side_rendering = true
101
-
102
- # caches
103
- require 'isomorfeus/react/thread_local_component_cache'
104
- require 'isomorfeus/react/memcached_component_cache'
105
- require 'isomorfeus/react/redis_component_cache'
106
- require 'isomorfeus/react_view_helper'
107
-
108
- Isomorfeus.component_cache_init do
109
- Isomorfeus::ThreadLocalComponentCache.new
110
- end
111
-
112
- Opal.append_path(__dir__.untaint)
113
-
114
- require 'concurrent'
115
- require 'zeitwerk'
116
-
117
- Isomorfeus.zeitwerk = Zeitwerk::Loader.new
118
- Isomorfeus.zeitwerk_lock = Concurrent::ReentrantReadWriteLock.new if Isomorfeus.development?
119
- # nothing to push_dir to zeitwerk here, as components are available only within browser/SSR
120
- end
1
+ if RUBY_ENGINE == 'opal'
2
+ require 'isomorfeus-redux'
3
+ require 'active_support/core_ext/string'
4
+ require 'zeitwerk'
5
+
6
+ if on_browser?
7
+ require 'browser/event'
8
+ require 'browser/event_target'
9
+ require 'browser/delegate_native'
10
+ require 'browser/element'
11
+ end
12
+
13
+ require 'isomorfeus/react/config'
14
+
15
+ # allow mounting of components
16
+ if on_browser?
17
+ require 'isomorfeus/top_level'
18
+ else
19
+ require 'isomorfeus/top_level_ssr'
20
+ end
21
+
22
+ # react
23
+ require 'react/version'
24
+ require 'react'
25
+ require 'react/synthetic_event'
26
+ require 'react/ref'
27
+ require 'react/children'
28
+ if on_browser?
29
+ require 'react_dom'
30
+ else
31
+ require 'react_dom_server'
32
+ end
33
+
34
+ # props
35
+ require 'isomorfeus/props/validate_hash_proxy'
36
+ require 'isomorfeus/props/validator'
37
+ require 'lucid_prop_declaration/mixin'
38
+ require 'react/component/props'
39
+
40
+ # HTML Elements support
41
+ require 'react/component/elements'
42
+
43
+ # React Features
44
+ require 'react/component/features'
45
+ require 'react/context_wrapper'
46
+ require 'react/native_constant_wrapper'
47
+
48
+ # React::Component
49
+ require 'react/component/api'
50
+ require 'react/component/callbacks'
51
+ require 'react/component/initializer'
52
+ require 'react/component/native_component_constructor'
53
+ require 'react/component/state'
54
+ require 'react/component/match'
55
+ require 'react/component/location'
56
+ require 'react/component/history'
57
+ require 'react/component/resolution'
58
+ require 'react/component/styles'
59
+ require 'react/component/mixin'
60
+ require 'react/component/base'
61
+
62
+ # init LucidApplicationContext (Store Provider and Consumer)
63
+ require 'lucid_app/context'
64
+ LucidApp::Context.create_application_context
65
+
66
+ class Object
67
+ include React::Component::Resolution
68
+ end
69
+
70
+ Isomorfeus.zeitwerk = Zeitwerk::Loader.new
71
+
72
+ Isomorfeus.zeitwerk.push_dir('isomorfeus_react')
73
+ require_tree 'isomorfeus_react', :autoload
74
+
75
+ Isomorfeus.zeitwerk.push_dir('components')
76
+ else
77
+ require 'uri'
78
+ require 'oj'
79
+ require 'opal'
80
+ require 'opal-activesupport'
81
+ require 'opal-zeitwerk'
82
+ require 'opal-webpack-loader'
83
+ require 'isomorfeus-redux'
84
+ require 'isomorfeus-speednode'
85
+ require 'react/version'
86
+ require 'isomorfeus/react/config'
87
+
88
+ # props
89
+ require 'isomorfeus/props/validate_hash_proxy'
90
+ require 'isomorfeus/props/validator'
91
+ require 'lucid_prop_declaration/mixin'
92
+
93
+ Isomorfeus.env = ENV['RACK_ENV']
94
+
95
+ if Isomorfeus.development?
96
+ require 'net/http'
97
+ Isomorfeus.ssr_hot_asset_url = 'http://localhost:3036/assets/'
98
+ end
99
+
100
+ Isomorfeus.server_side_rendering = true
101
+
102
+ # caches
103
+ require 'isomorfeus/react/thread_local_component_cache'
104
+ require 'isomorfeus/react/memcached_component_cache'
105
+ require 'isomorfeus/react/redis_component_cache'
106
+ require 'isomorfeus/react_view_helper'
107
+
108
+ Isomorfeus.component_cache_init do
109
+ Isomorfeus::ThreadLocalComponentCache.new
110
+ end
111
+
112
+ Opal.append_path(__dir__.untaint)
113
+
114
+ require 'concurrent'
115
+ require 'zeitwerk'
116
+
117
+ Isomorfeus.zeitwerk = Zeitwerk::Loader.new
118
+ Isomorfeus.zeitwerk_lock = Concurrent::ReentrantReadWriteLock.new if Isomorfeus.development?
119
+ # nothing to push_dir to zeitwerk here, as components are available only within browser/SSR
120
+ end
@@ -1,26 +1,26 @@
1
- module LucidApp
2
- module Api
3
- def self.included(base)
4
- base.instance_exec do
5
- def theme(theme_hash = nil, &block)
6
- if block_given?
7
- result = block.call(React::Component::Styles.new(`base.jss_theme`))
8
- %x{
9
- if (typeof result.$to_n === 'function') { base.jss_theme = result.$to_n(); }
10
- else { base.jss_theme = result; }
11
- return result;
12
- }
13
- elsif theme_hash
14
- `base.jss_theme = #{theme_hash.to_n}` if theme_hash
15
- theme_hash
16
- elsif `typeof base.jss_theme === 'object'`
17
- `Opal.Hash.$new(base.jss_theme)`
18
- else
19
- nil
20
- end
21
- end
22
- alias_method :theme=, :theme
23
- end
24
- end
25
- end
26
- end
1
+ module LucidApp
2
+ module Api
3
+ def self.included(base)
4
+ base.instance_exec do
5
+ def theme(theme_hash = nil, &block)
6
+ if block_given?
7
+ result = block.call(React::Component::Styles.new(`base.jss_theme`))
8
+ %x{
9
+ if (typeof result.$to_n === 'function') { base.jss_theme = result.$to_n(); }
10
+ else { base.jss_theme = result; }
11
+ return result;
12
+ }
13
+ elsif theme_hash
14
+ `base.jss_theme = #{theme_hash.to_n}` if theme_hash
15
+ theme_hash
16
+ elsif `typeof base.jss_theme === 'object'`
17
+ `Opal.Hash.$new(base.jss_theme)`
18
+ else
19
+ nil
20
+ end
21
+ end
22
+ alias_method :theme=, :theme
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,7 +1,7 @@
1
- module LucidApp
2
- class Base
3
- def self.inherited(base)
4
- base.include(::LucidApp::Mixin)
5
- end
6
- end
7
- end
1
+ module LucidApp
2
+ class Base
3
+ def self.inherited(base)
4
+ base.include(::LucidApp::Mixin)
5
+ end
6
+ end
7
+ end