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,11 +0,0 @@
|
|
1
|
-
module Preact::Component::Mixin
|
2
|
-
def self.included(base)
|
3
|
-
base.include(::Native::Wrapper)
|
4
|
-
base.extend(::Preact::Component::NativeComponentConstructor)
|
5
|
-
base.extend(::LucidPropDeclaration::Mixin)
|
6
|
-
base.include(::Preact::Elements)
|
7
|
-
base.include(::Preact::Component::Api)
|
8
|
-
base.include(::Preact::Component::Callbacks)
|
9
|
-
base.include(::Preact::Component::Initializer)
|
10
|
-
end
|
11
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
module Preact::Component::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.preact_component = class extends Opal.global.Preact.Component {
|
9
|
-
constructor(props) {
|
10
|
-
super(props);
|
11
|
-
if (base.$default_state_defined()) {
|
12
|
-
this.state = base.$state().$to_n();
|
13
|
-
} else {
|
14
|
-
this.state = {};
|
15
|
-
};
|
16
|
-
this.__ruby_instance = base.$new(this);
|
17
|
-
var defined_refs = #{base.defined_refs};
|
18
|
-
for (var ref in defined_refs) {
|
19
|
-
if (defined_refs[ref] != null) {
|
20
|
-
let r = ref; // to ensure closure for function below gets correct ref name
|
21
|
-
this[ref] = function(element) {
|
22
|
-
const oper = Opal.Preact;
|
23
|
-
element = oper.native_element_or_component_to_ruby(element);
|
24
|
-
oper.register_active_component(this);
|
25
|
-
try {
|
26
|
-
#{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
|
27
|
-
} catch (e) { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
|
28
|
-
oper.unregister_active_component(this);
|
29
|
-
}
|
30
|
-
this[ref] = this[ref].bind(this);
|
31
|
-
} else {
|
32
|
-
this[ref] = Opal.global.Preact.createRef();
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
static get displayName() {
|
37
|
-
return #{component_name};
|
38
|
-
}
|
39
|
-
render(props, state) {
|
40
|
-
const oper = Opal.Preact;
|
41
|
-
oper.render_buffer.push([]);
|
42
|
-
oper.register_active_component(this);
|
43
|
-
try {
|
44
|
-
let block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)};
|
45
|
-
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
46
|
-
} catch (e) {
|
47
|
-
if (oper.using_did_catch) { throw e; }
|
48
|
-
else { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
|
49
|
-
}
|
50
|
-
oper.unregister_active_component(this);
|
51
|
-
let result = oper.render_buffer.pop();
|
52
|
-
return (result.length === 1) ? result[0] : result;
|
53
|
-
}
|
54
|
-
shouldComponentUpdate(next_props, next_state) {
|
55
|
-
const oper = Opal.Preact;
|
56
|
-
if (base.should_component_update_block) {
|
57
|
-
oper.register_active_component(this);
|
58
|
-
let result;
|
59
|
-
try {
|
60
|
-
result = #{!!`this.__ruby_instance`.instance_exec(`oper.Props.$new({props: next_props})`, `oper.State.$new({state: next_state })`, &`base.should_component_update_block`)};
|
61
|
-
} catch (e) { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
|
62
|
-
oper.unregister_active_component(this);
|
63
|
-
return result;
|
64
|
-
}
|
65
|
-
if (!oper.props_are_equal(this.props, next_props)) { return true; }
|
66
|
-
if (oper.state_is_not_equal(this.state, next_state)) { return true; }
|
67
|
-
return false;
|
68
|
-
}
|
69
|
-
validateProp(props, propName, componentName) {
|
70
|
-
try { base.$validate_prop(propName, props[propName]) }
|
71
|
-
catch (e) { return new Error(componentName + " Error: prop validation failed: " + e.message); }
|
72
|
-
return null;
|
73
|
-
}
|
74
|
-
}
|
75
|
-
}
|
76
|
-
end
|
77
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Preact
|
2
|
-
class ContextWrapper
|
3
|
-
include ::Native::Wrapper
|
4
|
-
|
5
|
-
def initialize(native)
|
6
|
-
@native = native
|
7
|
-
end
|
8
|
-
|
9
|
-
def is_wrapped_context
|
10
|
-
true
|
11
|
-
end
|
12
|
-
|
13
|
-
def Consumer(*args, &block)
|
14
|
-
%x{
|
15
|
-
let operabu = Opal.Preact.render_buffer;
|
16
|
-
let props = null;
|
17
|
-
|
18
|
-
if (args.length > 0) { props = Opal.Preact.to_native_preact_props(args[0]); }
|
19
|
-
|
20
|
-
let preact_element = Opal.global.Preact.createElement(this.native.Consumer, props, function(value) {
|
21
|
-
let children = null;
|
22
|
-
if (block !== nil) {
|
23
|
-
operabu.push([]);
|
24
|
-
// console.log("consumer pushed", operabu, operabu.toString());
|
25
|
-
try {
|
26
|
-
let block_result = block.$call(value);
|
27
|
-
if (block_result && block_result !== nil) { Opal.Preact.render_block_result(block_result); }
|
28
|
-
} catch (e) { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
|
29
|
-
// console.log("consumer popping", operabu, operabu.toString());
|
30
|
-
children = operabu.pop();
|
31
|
-
if (children.length === 1) { children = children[0]; }
|
32
|
-
else if (children.length === 0) { children = null; }
|
33
|
-
}
|
34
|
-
return children;
|
35
|
-
});
|
36
|
-
operabu[operabu.length - 1].push(preact_element);
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
def Provider(*args, &block)
|
41
|
-
%x{
|
42
|
-
var props = null;
|
43
|
-
if (args.length > 0) { props = Opal.Preact.to_native_preact_props(args[0]); }
|
44
|
-
Opal.Preact.internal_render(this.native.Provider, props, null, block);
|
45
|
-
}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Preact
|
2
|
-
class NativeConstantWrapper
|
3
|
-
include ::Native::Wrapper
|
4
|
-
|
5
|
-
def initialize(native, const_name)
|
6
|
-
@native = native
|
7
|
-
@const_name = const_name
|
8
|
-
end
|
9
|
-
|
10
|
-
def method_missing(name, *args, &block)
|
11
|
-
%x{
|
12
|
-
if (name[0] === 'u' && name[1] === 's' && name[2] === 'e') {
|
13
|
-
if (name.indexOf('_') > 0) { name = Opal.Preact.lower_camelize(name); }
|
14
|
-
return #@native[name].call(this, args);
|
15
|
-
}
|
16
|
-
var component = null;
|
17
|
-
var component_type = typeof #@native[name];
|
18
|
-
if (component_type === "function" || component_type === "object") {
|
19
|
-
component = #@native[name];
|
20
|
-
}
|
21
|
-
if (component) {
|
22
|
-
return Opal.Preact.internal_prepare_args_and_render(component, args, block);
|
23
|
-
} else {
|
24
|
-
#{Isomorfeus.raise_error(error_class: NameError, message: "No such native Component #@const_name.#{name}")};
|
25
|
-
}
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/preact/option_hooks.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
module Preact
|
2
|
-
class OptionHooks
|
3
|
-
class << self
|
4
|
-
def debounce_rendering(&block)
|
5
|
-
%x{
|
6
|
-
const old_hook = Opal.global.Preact.options.debounceRendering;
|
7
|
-
Opal.global.Preact.options.debounceRendering = function(callback) {
|
8
|
-
#{block.call};
|
9
|
-
if (old_hook) {
|
10
|
-
old_hook(callback);
|
11
|
-
}
|
12
|
-
}
|
13
|
-
}
|
14
|
-
nil
|
15
|
-
end
|
16
|
-
|
17
|
-
def diffed(&block)
|
18
|
-
# TODO wrap vnode
|
19
|
-
%x{
|
20
|
-
const old_hook = Opal.global.Preact.options.diffed;
|
21
|
-
Opal.global.Preact.options.diffed = function(vnode) {
|
22
|
-
#{block.call(`vnode`)};
|
23
|
-
if (old_hook) {
|
24
|
-
old_hook(vnode);
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
nil
|
29
|
-
end
|
30
|
-
|
31
|
-
def event(&block)
|
32
|
-
%x{
|
33
|
-
const old_hook = Opal.global.Preact.options.event;
|
34
|
-
Opal.global.Preact.options.event = function(event) {
|
35
|
-
ruby_event = #{Browser::Event.new(`event`)}
|
36
|
-
ruby_event = #{block.call(`ruby_event`)};
|
37
|
-
return ruby_event.native;
|
38
|
-
}
|
39
|
-
}
|
40
|
-
nil
|
41
|
-
end
|
42
|
-
|
43
|
-
def request_animation_frame(&block)
|
44
|
-
%x{
|
45
|
-
const old_hook = Opal.global.Preact.options.requestAnimationFrame;
|
46
|
-
Opal.global.Preact.options.requestAnimationFrame = function(callback) {
|
47
|
-
#{block.call};
|
48
|
-
if (old_hook) {
|
49
|
-
old_hook(callback);
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
53
|
-
nil
|
54
|
-
end
|
55
|
-
|
56
|
-
def unmount(&block)
|
57
|
-
# TODO wrap vnode
|
58
|
-
%x{
|
59
|
-
const old_hook = Opal.global.Preact.options.unmount;
|
60
|
-
Opal.global.Preact.options.unmount = function(vnode) {
|
61
|
-
#{block.call(`vnode`)};
|
62
|
-
if (old_hook) {
|
63
|
-
old_hook(vnode);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
67
|
-
nil
|
68
|
-
end
|
69
|
-
|
70
|
-
def use_debug_value(&block)
|
71
|
-
%x{
|
72
|
-
const old_hook = Opal.global.Preact.options.useDebugValue;
|
73
|
-
Opal.global.Preact.options.useDebugValue = function(value) {
|
74
|
-
#{block.call(`value`)};
|
75
|
-
if (old_hook) {
|
76
|
-
old_hook(value);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
}
|
80
|
-
nil
|
81
|
-
end
|
82
|
-
|
83
|
-
def vnode(&block)
|
84
|
-
%x{
|
85
|
-
const old_hook = Opal.global.Preact.options.unmount;
|
86
|
-
Opal.global.Preact.options.unmount = function(vnode) {
|
87
|
-
#{block.call(`vnode`)};
|
88
|
-
if (old_hook) {
|
89
|
-
old_hook(vnode);
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
nil
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
data/lib/preact/params.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Preact
|
2
|
-
class Params
|
3
|
-
include Native::Wrapper
|
4
|
-
|
5
|
-
def method_missing(prop, *args, &block)
|
6
|
-
%x{
|
7
|
-
const p = #@native;
|
8
|
-
if (typeof p[prop] === 'undefined') {
|
9
|
-
prop = Opal.Preact.lower_camelize(prop);
|
10
|
-
if (typeof p[prop] === 'undefined') { return nil; }
|
11
|
-
}
|
12
|
-
return p[prop];
|
13
|
-
}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/lib/preact/props.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
module Preact
|
2
|
-
class Props
|
3
|
-
def initialize(native)
|
4
|
-
@native = native
|
5
|
-
end
|
6
|
-
|
7
|
-
def ==(other_props)
|
8
|
-
%x{
|
9
|
-
if (Opal.Preact.props_are_equal(#@native.props, #{other_props.to_n})) { return true; }
|
10
|
-
return false;
|
11
|
-
}
|
12
|
-
end
|
13
|
-
|
14
|
-
def [](prop)
|
15
|
-
%x{
|
16
|
-
const p = #@native.props;
|
17
|
-
if (typeof p[prop] === 'undefined') {
|
18
|
-
prop = Opal.Preact.lower_camelize(prop);
|
19
|
-
if (typeof p[prop] === 'undefined') { return nil; }
|
20
|
-
}
|
21
|
-
return p[prop];
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
def key?(k)
|
26
|
-
%x{
|
27
|
-
if (typeof #@native.props[k] !== 'undefined') { return true; }
|
28
|
-
return false;
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
def method_missing(prop, *args, &block)
|
33
|
-
%x{
|
34
|
-
const p = #@native.props;
|
35
|
-
if (typeof p[prop] === 'undefined') {
|
36
|
-
prop = Opal.Preact.lower_camelize(prop);
|
37
|
-
if (typeof p[prop] === 'undefined') { return nil; }
|
38
|
-
}
|
39
|
-
return p[prop];
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def theme
|
44
|
-
`#@native.props.iso_theme`
|
45
|
-
end
|
46
|
-
|
47
|
-
def params
|
48
|
-
return @params if @params
|
49
|
-
return nil if `typeof #@native.props.params === 'undefined'`
|
50
|
-
@params = `Opal.Preact.Params.$new(#@native.props.params)`
|
51
|
-
end
|
52
|
-
|
53
|
-
def to_h
|
54
|
-
`Opal.Hash.$new(#@native.props)`.transform_keys!(&:underscore)
|
55
|
-
end
|
56
|
-
|
57
|
-
def to_json
|
58
|
-
JSON.dump(to_transport)
|
59
|
-
end
|
60
|
-
|
61
|
-
def to_n
|
62
|
-
`#@native.props`
|
63
|
-
end
|
64
|
-
|
65
|
-
def to_transport
|
66
|
-
{}.merge(to_h)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
data/lib/preact/ref.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module Preact
|
2
|
-
class Ref
|
3
|
-
include ::Native::Wrapper
|
4
|
-
|
5
|
-
def initialize(native)
|
6
|
-
@native = native
|
7
|
-
end
|
8
|
-
|
9
|
-
def is_wrapped_ref
|
10
|
-
true
|
11
|
-
end
|
12
|
-
|
13
|
-
def current
|
14
|
-
`Opal.Preact.native_element_or_component_to_ruby(#@native.current)`
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/preact/state.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
module Preact
|
2
|
-
class State
|
3
|
-
include ::Native::Wrapper
|
4
|
-
|
5
|
-
def initialize(native)
|
6
|
-
@native = native
|
7
|
-
end
|
8
|
-
|
9
|
-
def ==(other_state)
|
10
|
-
%x{
|
11
|
-
if (Opal.Preact.state_is_not_equal(#@native.state, #{other_state.to_raw_n})) { return false; }
|
12
|
-
return true;
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
def [](key)
|
17
|
-
%x{
|
18
|
-
if (typeof #@native.state[key] === 'undefined') { return nil; }
|
19
|
-
return #@native.state[key];
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
def []=(key)
|
24
|
-
new_state = `{}`
|
25
|
-
new_state.JS[(`key.endsWith('=')` ? key.chop : key)] = args[0]
|
26
|
-
@native.JS.setState(new_state, `null`)
|
27
|
-
end
|
28
|
-
|
29
|
-
def key?(k)
|
30
|
-
%x{
|
31
|
-
if (typeof #@native.state[k] !== 'undefined') { return true; }
|
32
|
-
return false;
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
def method_missing(key, *args, &block)
|
37
|
-
if `args.length > 0`
|
38
|
-
new_state = `{}`
|
39
|
-
new_state.JS[(`key.endsWith('=')` ? key.chop : key)] = args[0]
|
40
|
-
if block_given?
|
41
|
-
@native.JS.setState(new_state, `function() { block.$call(); }`)
|
42
|
-
else
|
43
|
-
@native.JS.setState(new_state, `null`)
|
44
|
-
end
|
45
|
-
else
|
46
|
-
%x{
|
47
|
-
if (typeof #@native.state[key] === 'undefined') { return nil; }
|
48
|
-
return #@native.state[key];
|
49
|
-
}
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def set_state(updater, &block)
|
54
|
-
new_state = `{}`
|
55
|
-
updater.each do |key, value|
|
56
|
-
new_state.JS[key] = value
|
57
|
-
end
|
58
|
-
if block_given?
|
59
|
-
@native.JS.setState(new_state, `function() { block.$call(); }`)
|
60
|
-
else
|
61
|
-
@native.JS.setState(new_state, `null`)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def size
|
66
|
-
`Object.keys(#@native.state).length`;
|
67
|
-
end
|
68
|
-
|
69
|
-
def to_n
|
70
|
-
%x{
|
71
|
-
var new_native = {};
|
72
|
-
for (var key in #@native.state) {
|
73
|
-
if (typeof #@native.state[key].$to_n !== "undefined") {
|
74
|
-
new_native[key] = #@native.state[key].$to_n();
|
75
|
-
} else {
|
76
|
-
new_native[key] = #@native.state[key];
|
77
|
-
}
|
78
|
-
}
|
79
|
-
return new_native;
|
80
|
-
}
|
81
|
-
end
|
82
|
-
|
83
|
-
def to_raw_n
|
84
|
-
`#@native.state`
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
data/lib/preact/version.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "isomorfeus-preact",
|
3
|
-
"lockfileVersion": 2,
|
4
|
-
"requires": true,
|
5
|
-
"packages": {
|
6
|
-
"node_modules/preact": {
|
7
|
-
"version": "10.8.2",
|
8
|
-
"resolved": "https://registry.npmjs.org/preact/-/preact-10.8.2.tgz",
|
9
|
-
"integrity": "sha512-AKGt0BsDSiAYzVS78jZ9qRwuorY2CoSZtf1iOC6gLb/3QyZt+fLT09aYJBjRc/BEcRc4j+j3ggERMdNE43i1LQ==",
|
10
|
-
"funding": {
|
11
|
-
"type": "opencollective",
|
12
|
-
"url": "https://opencollective.com/preact"
|
13
|
-
}
|
14
|
-
},
|
15
|
-
"node_modules/preact-render-to-string": {
|
16
|
-
"version": "5.2.0",
|
17
|
-
"resolved": "https://registry.npmjs.org/preact-render-to-string/-/preact-render-to-string-5.2.0.tgz",
|
18
|
-
"integrity": "sha512-+RGwSW78Cl+NsZRUbFW1MGB++didsfqRk+IyRVTaqy+3OjtpKK/6HgBtfszUX0YXMfo41k2iaQSseAHGKEwrbg==",
|
19
|
-
"dependencies": {
|
20
|
-
"pretty-format": "^3.8.0"
|
21
|
-
},
|
22
|
-
"peerDependencies": {
|
23
|
-
"preact": ">=10"
|
24
|
-
}
|
25
|
-
},
|
26
|
-
"node_modules/pretty-format": {
|
27
|
-
"version": "3.8.0",
|
28
|
-
"license": "MIT"
|
29
|
-
},
|
30
|
-
"node_modules/wouter-preact": {
|
31
|
-
"version": "2.7.5",
|
32
|
-
"license": "ISC",
|
33
|
-
"peerDependencies": {
|
34
|
-
"preact": "^10.0.0"
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
data/node_modules/preact/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015-present Jason Miller
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|