isomorfeus-preact 10.8.2 → 22.9.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +14 -3
- data/README.md +23 -39
- data/lib/browser/delegate_native.rb +94 -72
- data/lib/browser/document.rb +38 -0
- data/lib/browser/element.rb +160 -176
- data/lib/browser/event.rb +99 -94
- data/lib/browser/history.rb +40 -20
- data/lib/browser/location.rb +59 -0
- data/lib/browser/window.rb +58 -0
- data/lib/data_uri/open_uri.rb +18 -0
- data/lib/data_uri/uri.rb +61 -0
- data/lib/data_uri.rb +4 -0
- data/lib/isomorfeus/preact/config.rb +42 -54
- data/lib/isomorfeus/preact/imports.rb +5 -20
- data/lib/isomorfeus/preact/ssr.rb +34 -0
- data/lib/isomorfeus/preact/thread_local_component_cache.rb +9 -11
- data/lib/isomorfeus/preact/version.rb +5 -0
- data/lib/isomorfeus/preact/view_helper.rb +72 -0
- data/lib/isomorfeus/props/validator.rb +19 -11
- data/lib/isomorfeus/top_level.rb +55 -33
- data/lib/isomorfeus-preact.rb +78 -103
- data/lib/link.rb +52 -0
- data/lib/lucid_app.rb +117 -0
- data/lib/lucid_component.rb +154 -0
- data/lib/nano_css.rb +282 -465
- data/lib/preact/component.rb +222 -0
- data/lib/preact/component_resolution.rb +49 -83
- data/lib/preact/context.rb +68 -0
- data/lib/preact/elements.rb +2 -9
- data/lib/preact/module_component_resolution.rb +50 -0
- data/lib/preact/prop_declaration_mixin.rb +73 -0
- data/lib/preact.rb +1548 -257
- data/lib/redirect.rb +34 -0
- data/lib/route.rb +15 -0
- data/lib/router.rb +145 -0
- data/lib/switch.rb +70 -0
- metadata +42 -309
- data/lib/isomorfeus/preact/memcached_component_cache.rb +0 -19
- data/lib/isomorfeus/preact/redis_component_cache.rb +0 -19
- data/lib/isomorfeus/preact/ssr/history.rb +0 -23
- data/lib/isomorfeus/preact/ssr/render_core.rb +0 -117
- data/lib/isomorfeus/preact/ssr/top_level.rb +0 -37
- data/lib/isomorfeus/preact_view_helper.rb +0 -129
- data/lib/isomorfeus_preact/lucid_app/api.rb +0 -38
- data/lib/isomorfeus_preact/lucid_app/base.rb +0 -7
- data/lib/isomorfeus_preact/lucid_app/mixin.rb +0 -14
- data/lib/isomorfeus_preact/lucid_app/native_component_constructor.rb +0 -101
- data/lib/isomorfeus_preact/lucid_component/api.rb +0 -123
- data/lib/isomorfeus_preact/lucid_component/app_store_proxy.rb +0 -32
- data/lib/isomorfeus_preact/lucid_component/base.rb +0 -7
- data/lib/isomorfeus_preact/lucid_component/class_store_proxy.rb +0 -37
- data/lib/isomorfeus_preact/lucid_component/initializer.rb +0 -9
- data/lib/isomorfeus_preact/lucid_component/mixin.rb +0 -13
- data/lib/isomorfeus_preact/lucid_component/native_component_constructor.rb +0 -87
- data/lib/isomorfeus_preact/lucid_component/styles_wrapper.rb +0 -40
- data/lib/isomorfeus_preact/lucid_func/base.rb +0 -7
- data/lib/isomorfeus_preact/lucid_func/initializer.rb +0 -8
- data/lib/isomorfeus_preact/lucid_func/mixin.rb +0 -10
- data/lib/isomorfeus_preact/lucid_func/native_component_constructor.rb +0 -56
- data/lib/isomorfeus_preact/preact/function_component/api.rb +0 -140
- data/lib/isomorfeus_preact/preact/function_component/base.rb +0 -7
- data/lib/isomorfeus_preact/preact/function_component/initializer.rb +0 -6
- data/lib/isomorfeus_preact/preact/function_component/mixin.rb +0 -8
- data/lib/isomorfeus_preact/preact/function_component/native_component_constructor.rb +0 -47
- data/lib/lucid_app/context.rb +0 -24
- data/lib/lucid_prop_declaration/mixin.rb +0 -126
- data/lib/preact/component/api.rb +0 -137
- data/lib/preact/component/base.rb +0 -7
- data/lib/preact/component/callbacks.rb +0 -111
- data/lib/preact/component/initializer.rb +0 -7
- data/lib/preact/component/mixin.rb +0 -11
- data/lib/preact/component/native_component_constructor.rb +0 -77
- data/lib/preact/context_wrapper.rb +0 -48
- data/lib/preact/native_constant_wrapper.rb +0 -29
- data/lib/preact/option_hooks.rb +0 -98
- data/lib/preact/params.rb +0 -16
- data/lib/preact/props.rb +0 -69
- data/lib/preact/ref.rb +0 -17
- data/lib/preact/state.rb +0 -87
- data/lib/preact/version.rb +0 -3
- data/node_modules/.package-lock.json +0 -38
- data/node_modules/preact/LICENSE +0 -21
- data/node_modules/preact/README.md +0 -188
- data/node_modules/preact/compat/LICENSE +0 -21
- data/node_modules/preact/compat/client.js +0 -19
- data/node_modules/preact/compat/client.mjs +0 -17
- data/node_modules/preact/compat/dist/compat.js +0 -2
- data/node_modules/preact/compat/dist/compat.js.map +0 -1
- data/node_modules/preact/compat/dist/compat.mjs +0 -2
- data/node_modules/preact/compat/dist/compat.module.js +0 -2
- data/node_modules/preact/compat/dist/compat.module.js.map +0 -1
- data/node_modules/preact/compat/dist/compat.umd.js +0 -2
- data/node_modules/preact/compat/dist/compat.umd.js.map +0 -1
- data/node_modules/preact/compat/jsx-dev-runtime.js +0 -3
- data/node_modules/preact/compat/jsx-dev-runtime.mjs +0 -3
- data/node_modules/preact/compat/jsx-runtime.js +0 -3
- data/node_modules/preact/compat/jsx-runtime.mjs +0 -3
- data/node_modules/preact/compat/package.json +0 -49
- data/node_modules/preact/compat/scheduler.js +0 -15
- data/node_modules/preact/compat/scheduler.mjs +0 -23
- data/node_modules/preact/compat/server.browser.js +0 -4
- data/node_modules/preact/compat/server.js +0 -15
- data/node_modules/preact/compat/server.mjs +0 -4
- data/node_modules/preact/compat/src/Children.js +0 -21
- data/node_modules/preact/compat/src/PureComponent.js +0 -15
- data/node_modules/preact/compat/src/forwardRef.js +0 -44
- data/node_modules/preact/compat/src/index.d.ts +0 -155
- data/node_modules/preact/compat/src/index.js +0 -187
- data/node_modules/preact/compat/src/internal.d.ts +0 -47
- data/node_modules/preact/compat/src/memo.js +0 -34
- data/node_modules/preact/compat/src/portals.js +0 -82
- data/node_modules/preact/compat/src/render.js +0 -238
- data/node_modules/preact/compat/src/suspense-list.d.ts +0 -14
- data/node_modules/preact/compat/src/suspense-list.js +0 -126
- data/node_modules/preact/compat/src/suspense.d.ts +0 -15
- data/node_modules/preact/compat/src/suspense.js +0 -270
- data/node_modules/preact/compat/src/util.js +0 -28
- data/node_modules/preact/compat/test-utils.js +0 -1
- data/node_modules/preact/debug/LICENSE +0 -21
- data/node_modules/preact/debug/dist/debug.js +0 -2
- data/node_modules/preact/debug/dist/debug.js.map +0 -1
- data/node_modules/preact/debug/dist/debug.mjs +0 -2
- data/node_modules/preact/debug/dist/debug.module.js +0 -2
- data/node_modules/preact/debug/dist/debug.module.js.map +0 -1
- data/node_modules/preact/debug/dist/debug.umd.js +0 -2
- data/node_modules/preact/debug/dist/debug.umd.js.map +0 -1
- data/node_modules/preact/debug/package.json +0 -26
- data/node_modules/preact/debug/src/check-props.js +0 -54
- data/node_modules/preact/debug/src/component-stack.js +0 -146
- data/node_modules/preact/debug/src/constants.js +0 -3
- data/node_modules/preact/debug/src/debug.js +0 -437
- data/node_modules/preact/debug/src/index.js +0 -6
- data/node_modules/preact/debug/src/internal.d.ts +0 -82
- data/node_modules/preact/debug/src/util.js +0 -11
- data/node_modules/preact/devtools/LICENSE +0 -21
- data/node_modules/preact/devtools/dist/devtools.js +0 -2
- data/node_modules/preact/devtools/dist/devtools.js.map +0 -1
- data/node_modules/preact/devtools/dist/devtools.mjs +0 -2
- data/node_modules/preact/devtools/dist/devtools.module.js +0 -2
- data/node_modules/preact/devtools/dist/devtools.module.js.map +0 -1
- data/node_modules/preact/devtools/dist/devtools.umd.js +0 -2
- data/node_modules/preact/devtools/dist/devtools.umd.js.map +0 -1
- data/node_modules/preact/devtools/package.json +0 -25
- data/node_modules/preact/devtools/src/devtools.js +0 -10
- data/node_modules/preact/devtools/src/index.d.ts +0 -8
- data/node_modules/preact/devtools/src/index.js +0 -15
- data/node_modules/preact/dist/preact.js +0 -2
- data/node_modules/preact/dist/preact.js.map +0 -1
- data/node_modules/preact/dist/preact.min.js +0 -2
- data/node_modules/preact/dist/preact.min.js.map +0 -1
- data/node_modules/preact/dist/preact.mjs +0 -2
- data/node_modules/preact/dist/preact.module.js +0 -2
- data/node_modules/preact/dist/preact.module.js.map +0 -1
- data/node_modules/preact/dist/preact.umd.js +0 -2
- data/node_modules/preact/dist/preact.umd.js.map +0 -1
- data/node_modules/preact/hooks/LICENSE +0 -21
- data/node_modules/preact/hooks/dist/hooks.js +0 -2
- data/node_modules/preact/hooks/dist/hooks.js.map +0 -1
- data/node_modules/preact/hooks/dist/hooks.mjs +0 -2
- data/node_modules/preact/hooks/dist/hooks.module.js +0 -2
- data/node_modules/preact/hooks/dist/hooks.module.js.map +0 -1
- data/node_modules/preact/hooks/dist/hooks.umd.js +0 -2
- data/node_modules/preact/hooks/dist/hooks.umd.js.map +0 -1
- data/node_modules/preact/hooks/package.json +0 -35
- data/node_modules/preact/hooks/src/index.d.ts +0 -139
- data/node_modules/preact/hooks/src/index.js +0 -417
- data/node_modules/preact/hooks/src/internal.d.ts +0 -78
- data/node_modules/preact/jsx-runtime/LICENSE +0 -21
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +0 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +0 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +0 -1
- data/node_modules/preact/jsx-runtime/package.json +0 -28
- data/node_modules/preact/jsx-runtime/src/index.d.ts +0 -50
- data/node_modules/preact/jsx-runtime/src/index.js +0 -77
- data/node_modules/preact/package.json +0 -304
- data/node_modules/preact/src/cjs.js +0 -3
- data/node_modules/preact/src/clone-element.js +0 -34
- data/node_modules/preact/src/component.js +0 -225
- data/node_modules/preact/src/constants.js +0 -3
- data/node_modules/preact/src/create-context.js +0 -68
- data/node_modules/preact/src/create-element.js +0 -98
- data/node_modules/preact/src/diff/catch-error.js +0 -40
- data/node_modules/preact/src/diff/children.js +0 -335
- data/node_modules/preact/src/diff/index.js +0 -533
- data/node_modules/preact/src/diff/props.js +0 -158
- data/node_modules/preact/src/index.d.ts +0 -317
- data/node_modules/preact/src/index.js +0 -13
- data/node_modules/preact/src/internal.d.ts +0 -155
- data/node_modules/preact/src/jsx.d.ts +0 -1013
- data/node_modules/preact/src/options.js +0 -16
- data/node_modules/preact/src/render.js +0 -75
- data/node_modules/preact/src/util.js +0 -27
- data/node_modules/preact/test-utils/dist/testUtils.js +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.js.map +0 -1
- data/node_modules/preact/test-utils/dist/testUtils.mjs +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.module.js +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.module.js.map +0 -1
- data/node_modules/preact/test-utils/dist/testUtils.umd.js +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +0 -1
- data/node_modules/preact/test-utils/package.json +0 -28
- data/node_modules/preact/test-utils/src/index.d.ts +0 -3
- data/node_modules/preact/test-utils/src/index.js +0 -118
- data/node_modules/preact-render-to-string/LICENSE +0 -21
- data/node_modules/preact-render-to-string/README.md +0 -102
- data/node_modules/preact-render-to-string/dist/commonjs.js +0 -2
- data/node_modules/preact-render-to-string/dist/commonjs.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/index.d.ts +0 -16
- data/node_modules/preact-render-to-string/dist/index.js +0 -1
- data/node_modules/preact-render-to-string/dist/index.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/index.mjs +0 -2
- data/node_modules/preact-render-to-string/dist/index.module.js +0 -2
- data/node_modules/preact-render-to-string/dist/index.module.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx-entry.js +0 -2
- data/node_modules/preact-render-to-string/dist/jsx-entry.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.d.ts +0 -13
- data/node_modules/preact-render-to-string/dist/jsx.js +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.mjs +0 -2
- data/node_modules/preact-render-to-string/dist/jsx.modern.js +0 -2
- data/node_modules/preact-render-to-string/dist/jsx.modern.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.module.js +0 -2
- data/node_modules/preact-render-to-string/dist/jsx.module.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/preact-render-to-string-tests.d.ts +0 -1
- data/node_modules/preact-render-to-string/jsx.js +0 -1
- data/node_modules/preact-render-to-string/package.json +0 -142
- data/node_modules/preact-render-to-string/src/index.d.ts +0 -16
- data/node_modules/preact-render-to-string/src/index.js +0 -462
- data/node_modules/preact-render-to-string/src/jsx.d.ts +0 -13
- data/node_modules/preact-render-to-string/src/jsx.js +0 -76
- data/node_modules/preact-render-to-string/src/polyfills.js +0 -8
- data/node_modules/preact-render-to-string/src/preact-render-to-string-tests.d.ts +0 -1
- data/node_modules/preact-render-to-string/src/util.js +0 -78
- data/node_modules/preact-render-to-string/typings.json +0 -5
- data/node_modules/pretty-format/.npmignore +0 -3
- data/node_modules/pretty-format/LICENSE.md +0 -15
- data/node_modules/pretty-format/README.md +0 -94
- data/node_modules/pretty-format/index.js +0 -343
- data/node_modules/pretty-format/package.json +0 -26
- data/node_modules/pretty-format/plugins/ReactElement.js +0 -74
- data/node_modules/pretty-format/plugins/ReactTestComponent.js +0 -58
- data/node_modules/pretty-format/printString.js +0 -7
- data/node_modules/wouter-preact/cjs/index.js +0 -180
- data/node_modules/wouter-preact/cjs/matcher.js +0 -72
- data/node_modules/wouter-preact/cjs/package.json +0 -1
- data/node_modules/wouter-preact/cjs/react-deps.js +0 -75
- data/node_modules/wouter-preact/cjs/static-location.js +0 -21
- data/node_modules/wouter-preact/cjs/use-location.js +0 -94
- data/node_modules/wouter-preact/index.d.ts +0 -110
- data/node_modules/wouter-preact/index.js +0 -178
- data/node_modules/wouter-preact/matcher.d.ts +0 -30
- data/node_modules/wouter-preact/matcher.js +0 -66
- data/node_modules/wouter-preact/package.json +0 -33
- data/node_modules/wouter-preact/react-deps.js +0 -15
- data/node_modules/wouter-preact/static-location.d.ts +0 -16
- data/node_modules/wouter-preact/static-location.js +0 -17
- data/node_modules/wouter-preact/use-location.d.ts +0 -43
- data/node_modules/wouter-preact/use-location.js +0 -86
- data/package.json +0 -8
@@ -1,129 +0,0 @@
|
|
1
|
-
module Isomorfeus
|
2
|
-
module PreactViewHelper
|
3
|
-
def self.included(base)
|
4
|
-
base.include Isomorfeus::AssetManager::ViewHelper
|
5
|
-
end
|
6
|
-
|
7
|
-
def cached_mount_component(component_name, props = {}, asset_key = 'ssr.js', skip_ssr: false, use_ssr: false, max_passes: 4, refresh: false)
|
8
|
-
key = "#{component_name}#{props}#{asset}"
|
9
|
-
if !Isomorfeus.development? && !refresh
|
10
|
-
render_result, @ssr_response_status, @ssr_styles = component_cache.fetch(key)
|
11
|
-
return render_result if render_result
|
12
|
-
end
|
13
|
-
render_result = mount_component(component_name, props, asset_key, skip_ssr: skip_ssr, use_ssr: use_ssr, max_passes: max_passes)
|
14
|
-
status = ssr_response_status
|
15
|
-
component_cache.store(key, render_result, status, ssr_styles) if status >= 200 && status < 300
|
16
|
-
render_result
|
17
|
-
end
|
18
|
-
|
19
|
-
def mount_component(component_name, props = {}, asset_key = 'ssr.js', skip_ssr: false, use_ssr: false, max_passes: 4)
|
20
|
-
ssr_start_time = Time.now if Isomorfeus.development?
|
21
|
-
@ssr_response_status = nil
|
22
|
-
@ssr_styles = nil
|
23
|
-
render_result = "<div data-iso-env=\"#{Isomorfeus.env}\" data-iso-root=\"#{component_name}\" data-iso-props='#{Oj.dump(props, mode: :strict)}'"
|
24
|
-
if !skip_ssr && (Isomorfeus.server_side_rendering || use_ssr)
|
25
|
-
thread_id_asset = "#{Thread.current.object_id}|#{asset_key}"
|
26
|
-
begin
|
27
|
-
init_speednode_context(asset_key, thread_id_asset) if Isomorfeus.development? || !Isomorfeus.ssr_contexts.key?(thread_id_asset)
|
28
|
-
rescue Exception => e
|
29
|
-
Isomorfeus.raise_error(message: "Server Side Rendering: Failed creating context for #{asset_key}. Error: #{e.message}", stack: e.backtrace)
|
30
|
-
end
|
31
|
-
|
32
|
-
ctx = Isomorfeus.ssr_contexts[thread_id_asset]
|
33
|
-
pass = 0
|
34
|
-
# if location_host and scheme are given and if Transport is loaded, connect and then render
|
35
|
-
ws_scheme = props[:location_scheme] == 'https:' ? 'wss:' : 'ws:'
|
36
|
-
location_host = props[:location_host] ? props[:location_host] : 'localhost'
|
37
|
-
api_ws_path = Isomorfeus.respond_to?(:api_websocket_path) ? Isomorfeus.api_websocket_path : ''
|
38
|
-
transport_ws_url = ws_scheme + location_host + api_ws_path
|
39
|
-
|
40
|
-
# build javascript for rendering first pass
|
41
|
-
# it will initialize buffers to guard against leaks, maybe caused by previous exceptions
|
42
|
-
javascript = <<~JAVASCRIPT
|
43
|
-
return Opal.Isomorfeus.SSR.mount_component('#{Thread.current[:isomorfeus_session_id]}', '#{Isomorfeus.env}', '#{props[:locale]}', '#{transport_ws_url}', '#{component_name}', #{Oj.dump(props, mode: :strict)}, #{max_passes})
|
44
|
-
JAVASCRIPT
|
45
|
-
|
46
|
-
begin
|
47
|
-
ctx.exec(javascript)
|
48
|
-
rescue Exception => e
|
49
|
-
Isomorfeus.raise_error(error: e)
|
50
|
-
end
|
51
|
-
|
52
|
-
sleep 0.001 # give other threads that would respond to a request from node/SSR a chance to run
|
53
|
-
rendering = ctx.eval_script(key: :rendering)
|
54
|
-
if rendering
|
55
|
-
start_time = Time.now
|
56
|
-
while rendering
|
57
|
-
break if (Time.now - start_time) > 10
|
58
|
-
sleep 0.005
|
59
|
-
rendering = ctx.eval_script(key: :rendering)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
rendered_tree, application_state, @ssr_styles, @ssr_response_status, passes, exception = ctx.eval_script(key: :get_result)
|
64
|
-
Isomorfeus.raise_error(message: "Server Side Rendering: #{exception['message']}", stack: exception['stack']) if exception
|
65
|
-
|
66
|
-
render_result << " data-iso-hydrated='true'" if rendered_tree
|
67
|
-
if Isomorfeus.respond_to?(:current_user) && Isomorfeus.current_user && !Isomorfeus.current_user.anonymous?
|
68
|
-
render_result << " data-iso-usid=#{Oj.dump(Isomorfeus.current_user.sid, mode: :strict)}"
|
69
|
-
end
|
70
|
-
render_result << " data-iso-nloc='#{props[:locale]}'>"
|
71
|
-
render_result << (rendered_tree ? rendered_tree : "SSR didn't work")
|
72
|
-
else
|
73
|
-
if Isomorfeus.respond_to?(:current_user) && Isomorfeus.current_user && !Isomorfeus.current_user.anonymous?
|
74
|
-
render_result << " data-iso-usid=#{Oj.dump(Isomorfeus.current_user.sid, mode: :strict)}"
|
75
|
-
end
|
76
|
-
render_result << " data-iso-nloc='#{props[:locale]}'>"
|
77
|
-
end
|
78
|
-
render_result << '</div>'
|
79
|
-
if Isomorfeus.server_side_rendering && !skip_ssr
|
80
|
-
render_result = "<script type='application/javascript'>\nServerSideRenderingStateJSON = #{Oj.dump(application_state, mode: :strict)}\n</script>\n" << render_result
|
81
|
-
puts "PreactViewHelper Server Side Rendering rendered #{passes} passes and took ~#{((Time.now - ssr_start_time)*1000).to_i}ms" if Isomorfeus.development?
|
82
|
-
end
|
83
|
-
render_result
|
84
|
-
end
|
85
|
-
|
86
|
-
def ssr_response_status
|
87
|
-
@ssr_response_status || 200
|
88
|
-
end
|
89
|
-
|
90
|
-
def ssr_styles
|
91
|
-
@ssr_styles || ''
|
92
|
-
end
|
93
|
-
|
94
|
-
private
|
95
|
-
|
96
|
-
def asset_manager
|
97
|
-
@_asset_manager ||= Isomorfeus::AssetManager.new
|
98
|
-
end
|
99
|
-
|
100
|
-
def component_cache
|
101
|
-
@_component_cache ||= Isomorfeus.component_cache_init_block.call
|
102
|
-
end
|
103
|
-
|
104
|
-
def init_speednode_context(asset_key, thread_id_asset)
|
105
|
-
asset = Isomorfeus.assets[asset_key]
|
106
|
-
raise "#{self.class.name}: Asset not found: #{asset_key}" unless asset
|
107
|
-
if !Isomorfeus.ssr_contexts.key?(thread_id_asset) || !asset.bundled?
|
108
|
-
if Isomorfeus.ssr_contexts.key?(thread_id_asset)
|
109
|
-
uuid = Isomorfeus.ssr_contexts[thread_id_asset].instance_variable_get(:@uuid)
|
110
|
-
runtime = Isomorfeus.ssr_contexts[thread_id_asset].instance_variable_get(:@runtime)
|
111
|
-
runtime.vm.delete_context(uuid)
|
112
|
-
end
|
113
|
-
asset_manager.transition(asset_key, asset)
|
114
|
-
Isomorfeus.ssr_contexts[thread_id_asset] = ExecJS.permissive_compile(asset.bundle)
|
115
|
-
ctx = Isomorfeus.ssr_contexts[thread_id_asset]
|
116
|
-
ctx.add_script(key: :get_result, source: 'Opal.Isomorfeus.SSR.get_result()')
|
117
|
-
ctx.add_script(key: :rendering, source: 'global.Rendering')
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def ssr_mod
|
122
|
-
@_ssr_mod ||= Opal.compile(File.read(File.expand_path(File.join(File.dirname(__FILE__), 'ssr.rb'))), { use_strict: true })
|
123
|
-
end
|
124
|
-
|
125
|
-
def top_level_mod
|
126
|
-
@_top_level_mod ||= Opal.compile(File.read(File.expand_path(File.join(File.dirname(__FILE__), 'top_level_ssr.rb'))), { use_strict: true })
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module LucidApp::Api
|
2
|
-
def self.included(base)
|
3
|
-
base.instance_exec do
|
4
|
-
def theme(theme_hash = nil, &block)
|
5
|
-
theme_hash = block.call if block_given?
|
6
|
-
if theme_hash
|
7
|
-
component_name = self.to_s
|
8
|
-
%x{
|
9
|
-
let rule_name = component_name.replace(/:/g, '_');
|
10
|
-
let ogni = Opal.global.NanoCSSInstance;
|
11
|
-
if (base.css_theme && #{Isomorfeus.production?}) { return base.css_theme; }
|
12
|
-
else if(#{Isomorfeus.development?}) {
|
13
|
-
if (#{on_browser?}) {
|
14
|
-
ogni.delete_from_sheet(rule_name);
|
15
|
-
ogni.delete_from_rule_blocks(rule_name);
|
16
|
-
ogni.hydrate_force_put = true;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
if (typeof theme_hash.$is_wrapped_style !== 'undefined') {
|
20
|
-
base.css_theme = theme_hash;
|
21
|
-
} else {
|
22
|
-
let css;
|
23
|
-
if (typeof theme_hash.$to_n === 'function') { css = theme_hash.$to_n(); }
|
24
|
-
else { css = theme_hash; }
|
25
|
-
let nano_styles = ogni.sheet(css, rule_name);
|
26
|
-
base.css_theme = #{::LucidComponent::StylesWrapper.new(`nano_styles`)};
|
27
|
-
}
|
28
|
-
}
|
29
|
-
end
|
30
|
-
%x{
|
31
|
-
if (!base.css_theme) { return nil; }
|
32
|
-
return base.css_theme;
|
33
|
-
}
|
34
|
-
end
|
35
|
-
alias_method :theme=, :theme
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module LucidApp::Mixin
|
2
|
-
def self.included(base)
|
3
|
-
base.include(::Native::Wrapper)
|
4
|
-
base.extend(::LucidApp::NativeComponentConstructor)
|
5
|
-
base.include(::Preact::Elements)
|
6
|
-
base.extend(::LucidPropDeclaration::Mixin)
|
7
|
-
base.include(::Preact::Component::Api)
|
8
|
-
base.include(::Preact::Component::Callbacks)
|
9
|
-
base.include(::LucidComponent::Api)
|
10
|
-
base.include(::LucidApp::Api)
|
11
|
-
base.include(::LucidComponent::Initializer)
|
12
|
-
base.include(::LucidI18n::Mixin) if `(Opal.modules.hasOwnProperty("lucid_i18n/mixin"))`
|
13
|
-
end
|
14
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
module LucidApp::NativeComponentConstructor
|
2
|
-
# for should_component_update we apply ruby semantics for comparing props
|
3
|
-
# to do so, we convert the props to ruby hashes and then compare
|
4
|
-
# this makes sure, that for example rubys Nil object gets handled properly
|
5
|
-
def self.extended(base)
|
6
|
-
component_name = base.to_s
|
7
|
-
%x{
|
8
|
-
base.css_styles = null;
|
9
|
-
base.css_theme = null;
|
10
|
-
base.preload_block = null;
|
11
|
-
base.preload_did_mount_proc = null;
|
12
|
-
base.while_loading_block = null;
|
13
|
-
|
14
|
-
base.preact_component = class extends Opal.global.Preact.Component {
|
15
|
-
constructor(props) {
|
16
|
-
super(props);
|
17
|
-
const oper = Opal.Preact;
|
18
|
-
if (base.$default_state_defined()) {
|
19
|
-
this.state = base.$state().$to_n();
|
20
|
-
} else {
|
21
|
-
this.state = {};
|
22
|
-
};
|
23
|
-
this.state.isomorfeus_store_state = Opal.Isomorfeus.store.native.getState();
|
24
|
-
var current_store_state = this.state.isomorfeus_store_state;
|
25
|
-
if (typeof current_store_state.class_state[#{component_name}] !== "undefined") {
|
26
|
-
this.state.class_state = {};
|
27
|
-
this.state.class_state[#{component_name}] = current_store_state.class_state[#{component_name}];
|
28
|
-
} else {
|
29
|
-
this.state.class_state = {};
|
30
|
-
this.state.class_state[#{component_name}] = {};
|
31
|
-
};
|
32
|
-
this.__ruby_instance = base.$new(this);
|
33
|
-
var defined_refs = #{base.defined_refs};
|
34
|
-
for (var ref in defined_refs) {
|
35
|
-
if (defined_refs[ref] != null) {
|
36
|
-
let r = ref; // to ensure closure for function below gets correct ref name
|
37
|
-
this[ref] = function(element) {
|
38
|
-
element = oper.native_element_or_component_to_ruby(element);
|
39
|
-
oper.register_active_component(this);
|
40
|
-
try {
|
41
|
-
#{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
|
42
|
-
} catch (e) { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
|
43
|
-
oper.unregister_active_component(this);
|
44
|
-
}
|
45
|
-
this[ref] = this[ref].bind(this);
|
46
|
-
} else {
|
47
|
-
this[ref] = Opal.global.Preact.createRef();
|
48
|
-
}
|
49
|
-
}
|
50
|
-
if (base.preload_block) {
|
51
|
-
oper.register_active_component(this);
|
52
|
-
this.state.preloaded = this.__ruby_instance.$execute_preload_block(); // caught in execute_preload_block itself
|
53
|
-
oper.unregister_active_component(this);
|
54
|
-
}
|
55
|
-
this.listener = this.listener.bind(this);
|
56
|
-
this.unsubscriber = Opal.Isomorfeus.store.native.subscribe(this.listener);
|
57
|
-
}
|
58
|
-
static get displayName() {
|
59
|
-
return #{component_name};
|
60
|
-
}
|
61
|
-
render(props, state) {
|
62
|
-
const oper = Opal.Preact;
|
63
|
-
oper.render_buffer.push([]);
|
64
|
-
oper.register_active_component(this);
|
65
|
-
let block_result;
|
66
|
-
try {
|
67
|
-
if (base.while_loading_block && !state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
|
68
|
-
else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
|
69
|
-
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
70
|
-
} catch (e) {
|
71
|
-
if (oper.using_did_catch) { throw e; }
|
72
|
-
else { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
|
73
|
-
}
|
74
|
-
oper.unregister_active_component(this);
|
75
|
-
let children = oper.render_buffer.pop();
|
76
|
-
return Opal.global.Preact.createElement(Opal.global.LucidApplicationContext.Provider, { value: { iso_store: this.state.isomorfeus_store_state, iso_theme: base.css_theme }}, children);
|
77
|
-
}
|
78
|
-
data_access() {
|
79
|
-
return this.state.isomorfeus_store_state;
|
80
|
-
}
|
81
|
-
listener() {
|
82
|
-
let next_state = Opal.Isomorfeus.store.native.getState();
|
83
|
-
this.setState({ isomorfeus_store_state: next_state });
|
84
|
-
}
|
85
|
-
componentWillUnmount() {
|
86
|
-
if (typeof this.unsubscriber === "function") { this.unsubscriber(); }
|
87
|
-
}
|
88
|
-
shouldComponentUpdate(next_props, next_state) {
|
89
|
-
if (!Opal.Preact.props_are_equal(this.props, next_props)) { return true; }
|
90
|
-
if (Opal.Preact.state_is_not_equal(this.state, next_state)) { return true; }
|
91
|
-
return false;
|
92
|
-
}
|
93
|
-
validateProp(props, propName, componentName) {
|
94
|
-
try { base.$validate_prop(propName, props[propName]) }
|
95
|
-
catch (e) { return new Error(componentName + ": Error: prop validation failed: " + e.message); }
|
96
|
-
return null;
|
97
|
-
}
|
98
|
-
}
|
99
|
-
}
|
100
|
-
end
|
101
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
module LucidComponent::Api
|
2
|
-
def self.included(base)
|
3
|
-
base.instance_exec do
|
4
|
-
# stores
|
5
|
-
attr_accessor :app_store
|
6
|
-
attr_accessor :class_store
|
7
|
-
|
8
|
-
def class_store
|
9
|
-
@class_store ||= ::LucidComponent::ClassStoreProxy.new(self.to_s)
|
10
|
-
end
|
11
|
-
|
12
|
-
# preloading
|
13
|
-
def preload(&block)
|
14
|
-
pdm_proc = proc do
|
15
|
-
if !self.state.preloaded && @_preload_promise
|
16
|
-
@_preload_promise.then { self.state.preloaded = true }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
%x{
|
20
|
-
base.preload_block = block;
|
21
|
-
base.preload_did_mount_proc = pdm_proc;
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
def while_loading(option = nil, &block)
|
26
|
-
wl_block = proc do
|
27
|
-
if @_preload_promise && @_preload_promise.resolved?
|
28
|
-
instance_exec(&`base.render_block`)
|
29
|
-
else
|
30
|
-
instance_exec(@_preload_promise, &block)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
`base.while_loading_block = wl_block`
|
34
|
-
end
|
35
|
-
|
36
|
-
# styles
|
37
|
-
def styles(styles_hash = nil, &block)
|
38
|
-
styles_hash = block.call if block_given?
|
39
|
-
if styles_hash
|
40
|
-
component_name = self.to_s
|
41
|
-
%x{
|
42
|
-
let rule_name = component_name.replace(/:/g, '_');
|
43
|
-
let ogni = Opal.global.NanoCSSInstance;
|
44
|
-
if (base.css_styles && #{Isomorfeus.production?}) { return base.css_styles; }
|
45
|
-
else if(#{Isomorfeus.development?}) {
|
46
|
-
if (#{on_browser?}) {
|
47
|
-
ogni.delete_from_sheet(rule_name);
|
48
|
-
ogni.delete_from_rule_blocks(rule_name);
|
49
|
-
ogni.hydrate_force_put = true;
|
50
|
-
}
|
51
|
-
}
|
52
|
-
if (typeof styles_hash.$is_wrapped_style !== 'undefined') {
|
53
|
-
base.css_styles = styles_hash;
|
54
|
-
} else {
|
55
|
-
let css;
|
56
|
-
if (typeof styles_hash.$to_n === 'function') { css = styles_hash.$to_n(); }
|
57
|
-
else { css = styles_hash; }
|
58
|
-
let nano_styles = ogni.sheet(css, rule_name);
|
59
|
-
base.css_styles = #{::LucidComponent::StylesWrapper.new(`nano_styles`)};
|
60
|
-
}
|
61
|
-
}
|
62
|
-
end
|
63
|
-
%x{
|
64
|
-
if (!base.css_styles) { return nil; }
|
65
|
-
return base.css_styles;
|
66
|
-
}
|
67
|
-
end
|
68
|
-
alias_method :styles=, :styles
|
69
|
-
end
|
70
|
-
|
71
|
-
# stores
|
72
|
-
def local_store
|
73
|
-
LocalStore
|
74
|
-
end
|
75
|
-
|
76
|
-
def session_store
|
77
|
-
SessionStore
|
78
|
-
end
|
79
|
-
|
80
|
-
def theme
|
81
|
-
props.theme
|
82
|
-
end
|
83
|
-
|
84
|
-
# preloading
|
85
|
-
def execute_preload_block
|
86
|
-
begin
|
87
|
-
@_preload_promise = instance_exec(&self.class.JS[:preload_block])
|
88
|
-
rescue => e
|
89
|
-
%x{
|
90
|
-
console.error(e.message);
|
91
|
-
console.error(e.stack);
|
92
|
-
}
|
93
|
-
end
|
94
|
-
if @_preload_promise
|
95
|
-
@_preload_promise.fail do |result|
|
96
|
-
err_text = "#{self.class.name}: preloading failed, last result: #{result.nil? ? 'nil' : result}!"
|
97
|
-
`console.error(err_text)`
|
98
|
-
end
|
99
|
-
@_preload_promise.resolved?
|
100
|
-
else
|
101
|
-
false
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def preloaded?
|
106
|
-
!!state.preloaded
|
107
|
-
end
|
108
|
-
|
109
|
-
# styles
|
110
|
-
def styles
|
111
|
-
%x{
|
112
|
-
let c = self.$class()
|
113
|
-
if (typeof(c.css_styles) === 'undefined') { return nil; }
|
114
|
-
return c.css_styles;
|
115
|
-
}
|
116
|
-
end
|
117
|
-
|
118
|
-
# requires transport
|
119
|
-
def current_user
|
120
|
-
Isomorfeus.current_user
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module LucidComponent
|
2
|
-
class AppStoreProxy
|
3
|
-
def initialize(native)
|
4
|
-
@native = native
|
5
|
-
end
|
6
|
-
|
7
|
-
def [](key)
|
8
|
-
method_missing(key)
|
9
|
-
end
|
10
|
-
|
11
|
-
def []=(key, value)
|
12
|
-
method_missing(key, value)
|
13
|
-
end
|
14
|
-
|
15
|
-
def method_missing(key, *args, &block)
|
16
|
-
if `args.length > 0`
|
17
|
-
# set class state, simply a dispatch
|
18
|
-
action = { type: 'APPLICATION_STATE', name: (`key.endsWith('=')` ? key.chop : key), value: args[0] }
|
19
|
-
Isomorfeus.store.collect_and_defer_dispatch(action)
|
20
|
-
else
|
21
|
-
# check if we have a component local state value
|
22
|
-
if `#@native?.props?.iso_store?.application_state?.hasOwnProperty?.(key)`
|
23
|
-
return `#@native.props.iso_store.application_state[key]`
|
24
|
-
else
|
25
|
-
return AppStore[key]
|
26
|
-
end
|
27
|
-
# otherwise return nil
|
28
|
-
return nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module LucidComponent
|
2
|
-
class ClassStoreProxy
|
3
|
-
def initialize(component_name, native = nil)
|
4
|
-
@component_name = component_name
|
5
|
-
@native = native
|
6
|
-
end
|
7
|
-
|
8
|
-
def [](key)
|
9
|
-
method_missing(key)
|
10
|
-
end
|
11
|
-
|
12
|
-
def []=(key, value)
|
13
|
-
method_missing(key, value)
|
14
|
-
end
|
15
|
-
|
16
|
-
def method_missing(key, *args, &block)
|
17
|
-
if `args.length > 0`
|
18
|
-
# set class state, simply a dispatch
|
19
|
-
action = { type: 'CLASS_STATE', class: @component_name, name: (`key.endsWith('=')` ? key.chop : key), value: args[0] }
|
20
|
-
Isomorfeus.store.collect_and_defer_dispatch(action)
|
21
|
-
else
|
22
|
-
# get class state
|
23
|
-
# check if we have a component local state value
|
24
|
-
if `#@native?.props?.iso_store?.class_state?.[#@component_name]?.hasOwnProperty?.(key)`
|
25
|
-
return `#@native.props.iso_store.class_state[#@component_name][key]`
|
26
|
-
else
|
27
|
-
a_state = Isomorfeus.store.get_state
|
28
|
-
if a_state.key?(:class_state) && a_state[:class_state].key?(@component_name) && a_state[:class_state][@component_name].key?(key)
|
29
|
-
return a_state[:class_state][@component_name][key]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
# otherwise return nil
|
33
|
-
return nil
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
module LucidComponent::Initializer
|
2
|
-
def initialize(native_component)
|
3
|
-
@native = native_component
|
4
|
-
@app_store = LucidComponent::AppStoreProxy.new(@native)
|
5
|
-
@class_store = LucidComponent::ClassStoreProxy.new(self.class.to_s, @native)
|
6
|
-
@props = `Opal.Preact.Props.$new(#@native)`
|
7
|
-
@state = `Opal.Preact.State.$new(#@native)`
|
8
|
-
end
|
9
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module LucidComponent::Mixin
|
2
|
-
def self.included(base)
|
3
|
-
base.include(::Native::Wrapper)
|
4
|
-
base.extend(::LucidComponent::NativeComponentConstructor)
|
5
|
-
base.include(::Preact::Elements)
|
6
|
-
base.extend(::LucidPropDeclaration::Mixin)
|
7
|
-
base.include(::Preact::Component::Api)
|
8
|
-
base.include(::Preact::Component::Callbacks)
|
9
|
-
base.include(::LucidComponent::Api)
|
10
|
-
base.include(::LucidComponent::Initializer)
|
11
|
-
base.include(::LucidI18n::Mixin) if `(Opal.modules.hasOwnProperty("lucid_i18n/mixin"))`
|
12
|
-
end
|
13
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module LucidComponent::NativeComponentConstructor
|
2
|
-
# for should_component_update we apply ruby semantics for comparing props
|
3
|
-
# to do so, we convert the props to ruby hashes and then compare
|
4
|
-
# this makes sure, that for example rubys Nil object gets handled properly
|
5
|
-
def self.extended(base)
|
6
|
-
component_name = base.to_s
|
7
|
-
wrapper_name = component_name + 'Wrapper'
|
8
|
-
%x{
|
9
|
-
base.css_styles = null;
|
10
|
-
base.preload_block = null;
|
11
|
-
base.while_loading_block = null;
|
12
|
-
|
13
|
-
base.preact_component = function(props) {
|
14
|
-
let value = Opal.global.PreactHooks.useContext(Opal.global.LucidApplicationContext);
|
15
|
-
return Opal.global.Preact.createElement(base.lucid_preact_component, Object.assign({}, props, value));
|
16
|
-
};
|
17
|
-
base.preact_component.displayName = #{wrapper_name};
|
18
|
-
base.lucid_preact_component = class extends Opal.global.Preact.Component {
|
19
|
-
constructor(props) {
|
20
|
-
super(props);
|
21
|
-
const oper = Opal.Preact;
|
22
|
-
if (base.$default_state_defined()) {
|
23
|
-
this.state = base.$state().$to_n();
|
24
|
-
} else {
|
25
|
-
this.state = {};
|
26
|
-
};
|
27
|
-
this.__ruby_instance = base.$new(this);
|
28
|
-
var defined_refs = base.$defined_refs();
|
29
|
-
for (var ref in defined_refs) {
|
30
|
-
if (defined_refs[ref] != null) {
|
31
|
-
let r = ref; // to ensure closure for function below gets correct ref name
|
32
|
-
this[ref] = function(element) {
|
33
|
-
element = oper.native_element_or_component_to_ruby(element);
|
34
|
-
oper.register_active_component(this);
|
35
|
-
try {
|
36
|
-
#{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
|
37
|
-
} catch (e) { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
|
38
|
-
oper.unregister_active_component(this);
|
39
|
-
}
|
40
|
-
this[ref] = this[ref].bind(this);
|
41
|
-
} else {
|
42
|
-
this[ref] = Opal.global.Preact.createRef();
|
43
|
-
}
|
44
|
-
}
|
45
|
-
if (base.preload_block) {
|
46
|
-
oper.register_active_component(this);
|
47
|
-
this.state.preloaded = this.__ruby_instance.$execute_preload_block(); // caught in execute_preload_block itself
|
48
|
-
oper.unregister_active_component(this);
|
49
|
-
}
|
50
|
-
}
|
51
|
-
static get displayName() {
|
52
|
-
return #{component_name};
|
53
|
-
}
|
54
|
-
render(props, state) {
|
55
|
-
const oper = Opal.Preact;
|
56
|
-
oper.render_buffer.push([]);
|
57
|
-
oper.register_active_component(this);
|
58
|
-
let block_result;
|
59
|
-
try {
|
60
|
-
if (base.while_loading_block && !state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
|
61
|
-
else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
|
62
|
-
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
63
|
-
} catch (e) {
|
64
|
-
if (oper.using_did_catch) { throw e; }
|
65
|
-
else { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
|
66
|
-
}
|
67
|
-
oper.unregister_active_component(this);
|
68
|
-
let result = oper.render_buffer.pop();
|
69
|
-
return (result.length === 1) ? result[0] : result;
|
70
|
-
}
|
71
|
-
data_access() {
|
72
|
-
return this.props.iso_store;
|
73
|
-
}
|
74
|
-
shouldComponentUpdate(next_props, next_state) {
|
75
|
-
if (!Opal.Preact.props_are_equal(this.props, next_props)) { return true; }
|
76
|
-
if (Opal.Preact.state_is_not_equal(this.state, next_state)) { return true; }
|
77
|
-
return false;
|
78
|
-
}
|
79
|
-
validateProp(props, propName, componentName) {
|
80
|
-
try { base.$validate_prop(propName, props[propName]) }
|
81
|
-
catch (e) { return new Error(componentName + " Error: prop validation failed: " + e.message); }
|
82
|
-
return null;
|
83
|
-
}
|
84
|
-
};
|
85
|
-
}
|
86
|
-
end
|
87
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module LucidComponent
|
2
|
-
class StylesWrapper
|
3
|
-
include ::Native::Wrapper
|
4
|
-
|
5
|
-
def is_wrapped_style
|
6
|
-
true
|
7
|
-
end
|
8
|
-
|
9
|
-
def fade_in
|
10
|
-
'fadeIn'
|
11
|
-
end
|
12
|
-
|
13
|
-
def fade_out
|
14
|
-
'fadeOut'
|
15
|
-
end
|
16
|
-
|
17
|
-
def [](prop)
|
18
|
-
method_missing(prop)
|
19
|
-
end
|
20
|
-
|
21
|
-
def method_missing(prop, *args, &block)
|
22
|
-
%x{
|
23
|
-
let value;
|
24
|
-
value = #@native[prop];
|
25
|
-
if (value) { return value; }
|
26
|
-
else {
|
27
|
-
console.warn("Style/Theme key '" + prop + "' returning nil!");
|
28
|
-
return #{nil};
|
29
|
-
}
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_h
|
34
|
-
%x{
|
35
|
-
if (#@props_prop) { return Opal.Hash.$new(#@native.props[#@props_prop]); }
|
36
|
-
else { return Opal.Hash.$new(#@native); }
|
37
|
-
}
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
module LucidFunc::Initializer
|
2
|
-
def initialize
|
3
|
-
self.JS[:native_props] = `{ props: null }`
|
4
|
-
@native_props = `Opal.Preact.Props.$new(#{self})`
|
5
|
-
@app_store = LucidComponent::AppStoreProxy.new(self)
|
6
|
-
@class_store = LucidComponent::ClassStoreProxy.new(self.class.to_s, self)
|
7
|
-
end
|
8
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module LucidFunc::Mixin
|
2
|
-
def self.included(base)
|
3
|
-
base.include(::LucidFunc::Initializer)
|
4
|
-
base.include(::Preact::FunctionComponent::Api)
|
5
|
-
base.extend(::LucidFunc::NativeComponentConstructor)
|
6
|
-
base.include(::Preact::Elements)
|
7
|
-
base.include(::LucidComponent::Api)
|
8
|
-
base.include(::LucidI18n::Mixin) if `(Opal.modules.hasOwnProperty("lucid_i18n/mixin"))`
|
9
|
-
end
|
10
|
-
end
|