isomorfeus-preact 10.9.0 → 22.9.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +14 -3
  3. data/README.md +23 -39
  4. data/lib/browser/delegate_native.rb +94 -72
  5. data/lib/browser/document.rb +38 -0
  6. data/lib/browser/element.rb +160 -176
  7. data/lib/browser/event.rb +99 -94
  8. data/lib/browser/history.rb +40 -20
  9. data/lib/browser/location.rb +59 -0
  10. data/lib/browser/window.rb +58 -0
  11. data/lib/data_uri/open_uri.rb +18 -0
  12. data/lib/data_uri/uri.rb +61 -0
  13. data/lib/data_uri.rb +4 -0
  14. data/lib/isomorfeus/preact/config.rb +42 -54
  15. data/lib/isomorfeus/preact/imports.rb +5 -20
  16. data/lib/isomorfeus/preact/ssr.rb +34 -0
  17. data/lib/isomorfeus/preact/thread_local_component_cache.rb +9 -11
  18. data/lib/isomorfeus/preact/version.rb +5 -0
  19. data/lib/isomorfeus/preact/view_helper.rb +72 -0
  20. data/lib/isomorfeus/props/validator.rb +19 -11
  21. data/lib/isomorfeus/top_level.rb +55 -33
  22. data/lib/isomorfeus-preact.rb +78 -103
  23. data/lib/link.rb +52 -0
  24. data/lib/lucid_app.rb +117 -0
  25. data/lib/lucid_component.rb +154 -0
  26. data/lib/nano_css.rb +282 -465
  27. data/lib/preact/component.rb +222 -0
  28. data/lib/preact/component_resolution.rb +49 -83
  29. data/lib/preact/context.rb +68 -0
  30. data/lib/preact/elements.rb +2 -9
  31. data/lib/preact/module_component_resolution.rb +50 -0
  32. data/lib/preact/prop_declaration_mixin.rb +73 -0
  33. data/lib/preact.rb +1548 -257
  34. data/lib/redirect.rb +34 -0
  35. data/lib/route.rb +15 -0
  36. data/lib/router.rb +145 -0
  37. data/lib/switch.rb +70 -0
  38. data/opal/iso_uri.rb +29 -0
  39. data/opal/uri/common.rb +18 -0
  40. data/opal/uri/generic.rb +47 -0
  41. metadata +45 -309
  42. data/lib/isomorfeus/preact/memcached_component_cache.rb +0 -19
  43. data/lib/isomorfeus/preact/redis_component_cache.rb +0 -19
  44. data/lib/isomorfeus/preact/ssr/history.rb +0 -23
  45. data/lib/isomorfeus/preact/ssr/render_core.rb +0 -117
  46. data/lib/isomorfeus/preact/ssr/top_level.rb +0 -37
  47. data/lib/isomorfeus/preact_view_helper.rb +0 -129
  48. data/lib/isomorfeus_preact/lucid_app/api.rb +0 -38
  49. data/lib/isomorfeus_preact/lucid_app/base.rb +0 -7
  50. data/lib/isomorfeus_preact/lucid_app/mixin.rb +0 -14
  51. data/lib/isomorfeus_preact/lucid_app/native_component_constructor.rb +0 -101
  52. data/lib/isomorfeus_preact/lucid_component/api.rb +0 -123
  53. data/lib/isomorfeus_preact/lucid_component/app_store_proxy.rb +0 -32
  54. data/lib/isomorfeus_preact/lucid_component/base.rb +0 -7
  55. data/lib/isomorfeus_preact/lucid_component/class_store_proxy.rb +0 -37
  56. data/lib/isomorfeus_preact/lucid_component/initializer.rb +0 -9
  57. data/lib/isomorfeus_preact/lucid_component/mixin.rb +0 -13
  58. data/lib/isomorfeus_preact/lucid_component/native_component_constructor.rb +0 -87
  59. data/lib/isomorfeus_preact/lucid_component/styles_wrapper.rb +0 -40
  60. data/lib/isomorfeus_preact/lucid_func/base.rb +0 -7
  61. data/lib/isomorfeus_preact/lucid_func/initializer.rb +0 -8
  62. data/lib/isomorfeus_preact/lucid_func/mixin.rb +0 -10
  63. data/lib/isomorfeus_preact/lucid_func/native_component_constructor.rb +0 -56
  64. data/lib/isomorfeus_preact/preact/function_component/api.rb +0 -164
  65. data/lib/isomorfeus_preact/preact/function_component/base.rb +0 -7
  66. data/lib/isomorfeus_preact/preact/function_component/initializer.rb +0 -6
  67. data/lib/isomorfeus_preact/preact/function_component/mixin.rb +0 -8
  68. data/lib/isomorfeus_preact/preact/function_component/native_component_constructor.rb +0 -47
  69. data/lib/lucid_app/context.rb +0 -24
  70. data/lib/lucid_prop_declaration/mixin.rb +0 -126
  71. data/lib/preact/component/api.rb +0 -137
  72. data/lib/preact/component/base.rb +0 -7
  73. data/lib/preact/component/callbacks.rb +0 -111
  74. data/lib/preact/component/initializer.rb +0 -7
  75. data/lib/preact/component/mixin.rb +0 -11
  76. data/lib/preact/component/native_component_constructor.rb +0 -77
  77. data/lib/preact/context_wrapper.rb +0 -48
  78. data/lib/preact/native_constant_wrapper.rb +0 -29
  79. data/lib/preact/option_hooks.rb +0 -98
  80. data/lib/preact/params.rb +0 -16
  81. data/lib/preact/props.rb +0 -69
  82. data/lib/preact/ref.rb +0 -17
  83. data/lib/preact/state.rb +0 -87
  84. data/lib/preact/version.rb +0 -3
  85. data/node_modules/.package-lock.json +0 -38
  86. data/node_modules/preact/LICENSE +0 -21
  87. data/node_modules/preact/README.md +0 -188
  88. data/node_modules/preact/compat/LICENSE +0 -21
  89. data/node_modules/preact/compat/client.js +0 -19
  90. data/node_modules/preact/compat/client.mjs +0 -17
  91. data/node_modules/preact/compat/dist/compat.js +0 -2
  92. data/node_modules/preact/compat/dist/compat.js.map +0 -1
  93. data/node_modules/preact/compat/dist/compat.mjs +0 -2
  94. data/node_modules/preact/compat/dist/compat.module.js +0 -2
  95. data/node_modules/preact/compat/dist/compat.module.js.map +0 -1
  96. data/node_modules/preact/compat/dist/compat.umd.js +0 -2
  97. data/node_modules/preact/compat/dist/compat.umd.js.map +0 -1
  98. data/node_modules/preact/compat/jsx-dev-runtime.js +0 -3
  99. data/node_modules/preact/compat/jsx-dev-runtime.mjs +0 -3
  100. data/node_modules/preact/compat/jsx-runtime.js +0 -3
  101. data/node_modules/preact/compat/jsx-runtime.mjs +0 -3
  102. data/node_modules/preact/compat/package.json +0 -49
  103. data/node_modules/preact/compat/scheduler.js +0 -15
  104. data/node_modules/preact/compat/scheduler.mjs +0 -23
  105. data/node_modules/preact/compat/server.browser.js +0 -4
  106. data/node_modules/preact/compat/server.js +0 -15
  107. data/node_modules/preact/compat/server.mjs +0 -4
  108. data/node_modules/preact/compat/src/Children.js +0 -21
  109. data/node_modules/preact/compat/src/PureComponent.js +0 -15
  110. data/node_modules/preact/compat/src/forwardRef.js +0 -44
  111. data/node_modules/preact/compat/src/index.d.ts +0 -164
  112. data/node_modules/preact/compat/src/index.js +0 -223
  113. data/node_modules/preact/compat/src/internal.d.ts +0 -47
  114. data/node_modules/preact/compat/src/memo.js +0 -34
  115. data/node_modules/preact/compat/src/portals.js +0 -82
  116. data/node_modules/preact/compat/src/render.js +0 -238
  117. data/node_modules/preact/compat/src/suspense-list.d.ts +0 -14
  118. data/node_modules/preact/compat/src/suspense-list.js +0 -126
  119. data/node_modules/preact/compat/src/suspense.d.ts +0 -15
  120. data/node_modules/preact/compat/src/suspense.js +0 -270
  121. data/node_modules/preact/compat/src/util.js +0 -28
  122. data/node_modules/preact/compat/test-utils.js +0 -1
  123. data/node_modules/preact/debug/LICENSE +0 -21
  124. data/node_modules/preact/debug/dist/debug.js +0 -2
  125. data/node_modules/preact/debug/dist/debug.js.map +0 -1
  126. data/node_modules/preact/debug/dist/debug.mjs +0 -2
  127. data/node_modules/preact/debug/dist/debug.module.js +0 -2
  128. data/node_modules/preact/debug/dist/debug.module.js.map +0 -1
  129. data/node_modules/preact/debug/dist/debug.umd.js +0 -2
  130. data/node_modules/preact/debug/dist/debug.umd.js.map +0 -1
  131. data/node_modules/preact/debug/package.json +0 -26
  132. data/node_modules/preact/debug/src/check-props.js +0 -54
  133. data/node_modules/preact/debug/src/component-stack.js +0 -146
  134. data/node_modules/preact/debug/src/constants.js +0 -3
  135. data/node_modules/preact/debug/src/debug.js +0 -437
  136. data/node_modules/preact/debug/src/index.js +0 -6
  137. data/node_modules/preact/debug/src/internal.d.ts +0 -82
  138. data/node_modules/preact/debug/src/util.js +0 -11
  139. data/node_modules/preact/devtools/LICENSE +0 -21
  140. data/node_modules/preact/devtools/dist/devtools.js +0 -2
  141. data/node_modules/preact/devtools/dist/devtools.js.map +0 -1
  142. data/node_modules/preact/devtools/dist/devtools.mjs +0 -2
  143. data/node_modules/preact/devtools/dist/devtools.module.js +0 -2
  144. data/node_modules/preact/devtools/dist/devtools.module.js.map +0 -1
  145. data/node_modules/preact/devtools/dist/devtools.umd.js +0 -2
  146. data/node_modules/preact/devtools/dist/devtools.umd.js.map +0 -1
  147. data/node_modules/preact/devtools/package.json +0 -25
  148. data/node_modules/preact/devtools/src/devtools.js +0 -10
  149. data/node_modules/preact/devtools/src/index.d.ts +0 -8
  150. data/node_modules/preact/devtools/src/index.js +0 -15
  151. data/node_modules/preact/dist/preact.js +0 -2
  152. data/node_modules/preact/dist/preact.js.map +0 -1
  153. data/node_modules/preact/dist/preact.min.js +0 -2
  154. data/node_modules/preact/dist/preact.min.js.map +0 -1
  155. data/node_modules/preact/dist/preact.mjs +0 -2
  156. data/node_modules/preact/dist/preact.module.js +0 -2
  157. data/node_modules/preact/dist/preact.module.js.map +0 -1
  158. data/node_modules/preact/dist/preact.umd.js +0 -2
  159. data/node_modules/preact/dist/preact.umd.js.map +0 -1
  160. data/node_modules/preact/hooks/LICENSE +0 -21
  161. data/node_modules/preact/hooks/dist/hooks.js +0 -2
  162. data/node_modules/preact/hooks/dist/hooks.js.map +0 -1
  163. data/node_modules/preact/hooks/dist/hooks.mjs +0 -2
  164. data/node_modules/preact/hooks/dist/hooks.module.js +0 -2
  165. data/node_modules/preact/hooks/dist/hooks.module.js.map +0 -1
  166. data/node_modules/preact/hooks/dist/hooks.umd.js +0 -2
  167. data/node_modules/preact/hooks/dist/hooks.umd.js.map +0 -1
  168. data/node_modules/preact/hooks/package.json +0 -35
  169. data/node_modules/preact/hooks/src/index.d.ts +0 -139
  170. data/node_modules/preact/hooks/src/index.js +0 -417
  171. data/node_modules/preact/hooks/src/internal.d.ts +0 -78
  172. data/node_modules/preact/jsx-runtime/LICENSE +0 -21
  173. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js +0 -2
  174. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +0 -1
  175. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs +0 -2
  176. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js +0 -2
  177. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +0 -1
  178. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js +0 -2
  179. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +0 -1
  180. data/node_modules/preact/jsx-runtime/package.json +0 -28
  181. data/node_modules/preact/jsx-runtime/src/index.d.ts +0 -50
  182. data/node_modules/preact/jsx-runtime/src/index.js +0 -77
  183. data/node_modules/preact/package.json +0 -304
  184. data/node_modules/preact/src/cjs.js +0 -3
  185. data/node_modules/preact/src/clone-element.js +0 -34
  186. data/node_modules/preact/src/component.js +0 -225
  187. data/node_modules/preact/src/constants.js +0 -3
  188. data/node_modules/preact/src/create-context.js +0 -68
  189. data/node_modules/preact/src/create-element.js +0 -98
  190. data/node_modules/preact/src/diff/catch-error.js +0 -40
  191. data/node_modules/preact/src/diff/children.js +0 -335
  192. data/node_modules/preact/src/diff/index.js +0 -533
  193. data/node_modules/preact/src/diff/props.js +0 -158
  194. data/node_modules/preact/src/index.d.ts +0 -317
  195. data/node_modules/preact/src/index.js +0 -13
  196. data/node_modules/preact/src/internal.d.ts +0 -155
  197. data/node_modules/preact/src/jsx.d.ts +0 -1014
  198. data/node_modules/preact/src/options.js +0 -16
  199. data/node_modules/preact/src/render.js +0 -75
  200. data/node_modules/preact/src/util.js +0 -27
  201. data/node_modules/preact/test-utils/dist/testUtils.js +0 -2
  202. data/node_modules/preact/test-utils/dist/testUtils.js.map +0 -1
  203. data/node_modules/preact/test-utils/dist/testUtils.mjs +0 -2
  204. data/node_modules/preact/test-utils/dist/testUtils.module.js +0 -2
  205. data/node_modules/preact/test-utils/dist/testUtils.module.js.map +0 -1
  206. data/node_modules/preact/test-utils/dist/testUtils.umd.js +0 -2
  207. data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +0 -1
  208. data/node_modules/preact/test-utils/package.json +0 -28
  209. data/node_modules/preact/test-utils/src/index.d.ts +0 -3
  210. data/node_modules/preact/test-utils/src/index.js +0 -118
  211. data/node_modules/preact-render-to-string/LICENSE +0 -21
  212. data/node_modules/preact-render-to-string/README.md +0 -102
  213. data/node_modules/preact-render-to-string/dist/commonjs.js +0 -2
  214. data/node_modules/preact-render-to-string/dist/commonjs.js.map +0 -1
  215. data/node_modules/preact-render-to-string/dist/index.d.ts +0 -16
  216. data/node_modules/preact-render-to-string/dist/index.js +0 -1
  217. data/node_modules/preact-render-to-string/dist/index.js.map +0 -1
  218. data/node_modules/preact-render-to-string/dist/index.mjs +0 -2
  219. data/node_modules/preact-render-to-string/dist/index.module.js +0 -2
  220. data/node_modules/preact-render-to-string/dist/index.module.js.map +0 -1
  221. data/node_modules/preact-render-to-string/dist/jsx-entry.js +0 -2
  222. data/node_modules/preact-render-to-string/dist/jsx-entry.js.map +0 -1
  223. data/node_modules/preact-render-to-string/dist/jsx.d.ts +0 -13
  224. data/node_modules/preact-render-to-string/dist/jsx.js +0 -1
  225. data/node_modules/preact-render-to-string/dist/jsx.js.map +0 -1
  226. data/node_modules/preact-render-to-string/dist/jsx.mjs +0 -2
  227. data/node_modules/preact-render-to-string/dist/jsx.modern.js +0 -2
  228. data/node_modules/preact-render-to-string/dist/jsx.modern.js.map +0 -1
  229. data/node_modules/preact-render-to-string/dist/jsx.module.js +0 -2
  230. data/node_modules/preact-render-to-string/dist/jsx.module.js.map +0 -1
  231. data/node_modules/preact-render-to-string/dist/preact-render-to-string-tests.d.ts +0 -1
  232. data/node_modules/preact-render-to-string/jsx.js +0 -1
  233. data/node_modules/preact-render-to-string/package.json +0 -142
  234. data/node_modules/preact-render-to-string/src/index.d.ts +0 -16
  235. data/node_modules/preact-render-to-string/src/index.js +0 -462
  236. data/node_modules/preact-render-to-string/src/jsx.d.ts +0 -13
  237. data/node_modules/preact-render-to-string/src/jsx.js +0 -76
  238. data/node_modules/preact-render-to-string/src/polyfills.js +0 -8
  239. data/node_modules/preact-render-to-string/src/preact-render-to-string-tests.d.ts +0 -1
  240. data/node_modules/preact-render-to-string/src/util.js +0 -78
  241. data/node_modules/preact-render-to-string/typings.json +0 -5
  242. data/node_modules/pretty-format/.npmignore +0 -3
  243. data/node_modules/pretty-format/LICENSE.md +0 -15
  244. data/node_modules/pretty-format/README.md +0 -94
  245. data/node_modules/pretty-format/index.js +0 -343
  246. data/node_modules/pretty-format/package.json +0 -26
  247. data/node_modules/pretty-format/plugins/ReactElement.js +0 -74
  248. data/node_modules/pretty-format/plugins/ReactTestComponent.js +0 -58
  249. data/node_modules/pretty-format/printString.js +0 -7
  250. data/node_modules/wouter-preact/cjs/index.js +0 -180
  251. data/node_modules/wouter-preact/cjs/matcher.js +0 -72
  252. data/node_modules/wouter-preact/cjs/package.json +0 -1
  253. data/node_modules/wouter-preact/cjs/react-deps.js +0 -75
  254. data/node_modules/wouter-preact/cjs/static-location.js +0 -21
  255. data/node_modules/wouter-preact/cjs/use-location.js +0 -94
  256. data/node_modules/wouter-preact/index.d.ts +0 -110
  257. data/node_modules/wouter-preact/index.js +0 -178
  258. data/node_modules/wouter-preact/matcher.d.ts +0 -30
  259. data/node_modules/wouter-preact/matcher.js +0 -66
  260. data/node_modules/wouter-preact/package.json +0 -33
  261. data/node_modules/wouter-preact/react-deps.js +0 -15
  262. data/node_modules/wouter-preact/static-location.d.ts +0 -16
  263. data/node_modules/wouter-preact/static-location.js +0 -17
  264. data/node_modules/wouter-preact/use-location.d.ts +0 -43
  265. data/node_modules/wouter-preact/use-location.js +0 -86
  266. data/package.json +0 -8
@@ -1,111 +0,0 @@
1
- module Preact::Component::Callbacks
2
- def self.included(base)
3
- base.instance_exec do
4
- def component_did_catch(&block)
5
- # TODO convert error
6
- %x{
7
- var fun = function(error, newVNode, oldVNode, errorInfo) {
8
- const oper = Opal.Preact;
9
- oper.register_active_component(this);
10
- try {
11
- #{`this.__ruby_instance`.instance_exec(`error`, `newVNode`, `oldVNode`, `errorInfo`, &block)};
12
- } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
13
- oper.unregister_active_component(this);
14
- }
15
- if (self.lucid_preact_component) { self.lucid_preact_component.prototype.componentDidCatch = fun; }
16
- else { self.preact_component.prototype.componentDidCatch = fun; }
17
- Opal.Preact.using_did_catch = true;
18
- }
19
- end
20
-
21
- def component_did_mount(&block)
22
- %x{
23
- let fun = function() {
24
- const oper = Opal.Preact;
25
- oper.register_active_component(this);
26
- try { #{`this.__ruby_instance`.instance_exec(&block)}; }
27
- catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
28
- if (self.preload_did_mount_proc) { #{`this.__ruby_instance`.instance_exec { self.class.JS[:preload_did_mount_proc].call } } }
29
- oper.unregister_active_component(this);
30
- }
31
- if (self.lucid_preact_component) {
32
- self.lucid_preact_component.prototype.componentDidMount = fun;
33
- } else {
34
- self.preact_component.prototype.componentDidMount = fun;
35
- }
36
- }
37
- end
38
-
39
- def component_did_update(&block)
40
- %x{
41
- var fun = function(prev_props, prev_state, snapshot) {
42
- const oper = Opal.Preact;
43
- oper.register_active_component(this);
44
- try {
45
- #{`this.__ruby_instance`.instance_exec(`oper.Props.$new({props: prev_props})`,
46
- `oper.State.$new({state: prev_state})`,
47
- `snapshot`, &block)};
48
- } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
49
- oper.unregister_active_component(this);
50
- }
51
- if (self.lucid_preact_component) { self.lucid_preact_component.prototype.componentDidUpdate = fun; }
52
- else { self.preact_component.prototype.componentDidUpdate = fun; }
53
- }
54
- end
55
-
56
- def component_will_unmount(&block)
57
- %x{
58
- var fun = function() {
59
- const oper = Opal.Preact;
60
- if (typeof this.unsubscriber === "function") { this.unsubscriber(); };
61
- oper.register_active_component(this);
62
- try {
63
- #{`this.__ruby_instance`.instance_exec(&block)};
64
- } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
65
- oper.unregister_active_component(this);
66
- }
67
- if (self.lucid_preact_component) { self.lucid_preact_component.prototype.componentWillUnmount = fun; }
68
- else { self.preact_component.prototype.componentWillUnmount = fun; }
69
- }
70
- end
71
-
72
-
73
- def get_derived_state_from_props(&block)
74
- %x{
75
- var fun = function(props, state) {
76
- const oper = Opal.Preact;
77
- oper.register_active_component(this);
78
- try {
79
- var result = #{`this.__ruby_instance`.instance_exec(`oper.Props.$new({props: props})`,
80
- `oper.State.$new({state: state})`, &block)};
81
- } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
82
- oper.unregister_active_component(this);
83
- if (typeof result.$to_n === 'function') { result = result.$to_n() }
84
- if (result === nil) { return null; }
85
- return result;
86
- }
87
- if (self.lucid_preact_component) { self.lucid_preact_component.prototype.getDerivedStateFromProps = fun; }
88
- else { self.preact_component.prototype.getDerivedStateFromProps = fun; }
89
- }
90
- end
91
-
92
- def get_snapshot_before_update(&block)
93
- %x{
94
- var fun = function(prev_props, prev_state) {
95
- const oper = Opal.Preact;
96
- oper.register_active_component(this);
97
- try {
98
- var result = #{`this.__ruby_instance`.instance_exec(`oper.Props.$new({props: prev_props})`,
99
- `oper.State.$new({state: prev_state})`, &block)};
100
- } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
101
- oper.unregister_active_component(this);
102
- if (result === nil) { return null; }
103
- return result;
104
- }
105
- if (self.lucid_preact_component) { self.lucid_preact_component.prototype.getSnapshotBeforeUpdate = fun; }
106
- else { self.preact_component.prototype.getSnapshotBeforeUpdate = fun; }
107
- }
108
- end
109
- end
110
- end
111
- end
@@ -1,7 +0,0 @@
1
- module Preact::Component::Initializer
2
- def initialize(native_component)
3
- @native = native_component
4
- @props = `Opal.Preact.Props.$new(#@native)`
5
- @state = `Opal.Preact.State.$new(#@native)`
6
- end
7
- end
@@ -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
@@ -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
@@ -1,3 +0,0 @@
1
- module Preact
2
- VERSION = '10.9.0'
3
- end
@@ -1,38 +0,0 @@
1
- {
2
- "name": "isomorfeus-preact",
3
- "lockfileVersion": 2,
4
- "requires": true,
5
- "packages": {
6
- "node_modules/preact": {
7
- "version": "10.9.0",
8
- "resolved": "https://registry.npmjs.org/preact/-/preact-10.9.0.tgz",
9
- "integrity": "sha512-jO6/OvCRL+OT8gst/+Q2ir7dMybZAX8ioP02Zmzh3BkQMHLyqZSujvxbUriXvHi8qmhcHKC2Gwbog6Kt+YTh+Q==",
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
- }
@@ -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.