isomorfeus-preact 10.9.0 → 22.9.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) 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. metadata +42 -309
  39. data/lib/isomorfeus/preact/memcached_component_cache.rb +0 -19
  40. data/lib/isomorfeus/preact/redis_component_cache.rb +0 -19
  41. data/lib/isomorfeus/preact/ssr/history.rb +0 -23
  42. data/lib/isomorfeus/preact/ssr/render_core.rb +0 -117
  43. data/lib/isomorfeus/preact/ssr/top_level.rb +0 -37
  44. data/lib/isomorfeus/preact_view_helper.rb +0 -129
  45. data/lib/isomorfeus_preact/lucid_app/api.rb +0 -38
  46. data/lib/isomorfeus_preact/lucid_app/base.rb +0 -7
  47. data/lib/isomorfeus_preact/lucid_app/mixin.rb +0 -14
  48. data/lib/isomorfeus_preact/lucid_app/native_component_constructor.rb +0 -101
  49. data/lib/isomorfeus_preact/lucid_component/api.rb +0 -123
  50. data/lib/isomorfeus_preact/lucid_component/app_store_proxy.rb +0 -32
  51. data/lib/isomorfeus_preact/lucid_component/base.rb +0 -7
  52. data/lib/isomorfeus_preact/lucid_component/class_store_proxy.rb +0 -37
  53. data/lib/isomorfeus_preact/lucid_component/initializer.rb +0 -9
  54. data/lib/isomorfeus_preact/lucid_component/mixin.rb +0 -13
  55. data/lib/isomorfeus_preact/lucid_component/native_component_constructor.rb +0 -87
  56. data/lib/isomorfeus_preact/lucid_component/styles_wrapper.rb +0 -40
  57. data/lib/isomorfeus_preact/lucid_func/base.rb +0 -7
  58. data/lib/isomorfeus_preact/lucid_func/initializer.rb +0 -8
  59. data/lib/isomorfeus_preact/lucid_func/mixin.rb +0 -10
  60. data/lib/isomorfeus_preact/lucid_func/native_component_constructor.rb +0 -56
  61. data/lib/isomorfeus_preact/preact/function_component/api.rb +0 -164
  62. data/lib/isomorfeus_preact/preact/function_component/base.rb +0 -7
  63. data/lib/isomorfeus_preact/preact/function_component/initializer.rb +0 -6
  64. data/lib/isomorfeus_preact/preact/function_component/mixin.rb +0 -8
  65. data/lib/isomorfeus_preact/preact/function_component/native_component_constructor.rb +0 -47
  66. data/lib/lucid_app/context.rb +0 -24
  67. data/lib/lucid_prop_declaration/mixin.rb +0 -126
  68. data/lib/preact/component/api.rb +0 -137
  69. data/lib/preact/component/base.rb +0 -7
  70. data/lib/preact/component/callbacks.rb +0 -111
  71. data/lib/preact/component/initializer.rb +0 -7
  72. data/lib/preact/component/mixin.rb +0 -11
  73. data/lib/preact/component/native_component_constructor.rb +0 -77
  74. data/lib/preact/context_wrapper.rb +0 -48
  75. data/lib/preact/native_constant_wrapper.rb +0 -29
  76. data/lib/preact/option_hooks.rb +0 -98
  77. data/lib/preact/params.rb +0 -16
  78. data/lib/preact/props.rb +0 -69
  79. data/lib/preact/ref.rb +0 -17
  80. data/lib/preact/state.rb +0 -87
  81. data/lib/preact/version.rb +0 -3
  82. data/node_modules/.package-lock.json +0 -38
  83. data/node_modules/preact/LICENSE +0 -21
  84. data/node_modules/preact/README.md +0 -188
  85. data/node_modules/preact/compat/LICENSE +0 -21
  86. data/node_modules/preact/compat/client.js +0 -19
  87. data/node_modules/preact/compat/client.mjs +0 -17
  88. data/node_modules/preact/compat/dist/compat.js +0 -2
  89. data/node_modules/preact/compat/dist/compat.js.map +0 -1
  90. data/node_modules/preact/compat/dist/compat.mjs +0 -2
  91. data/node_modules/preact/compat/dist/compat.module.js +0 -2
  92. data/node_modules/preact/compat/dist/compat.module.js.map +0 -1
  93. data/node_modules/preact/compat/dist/compat.umd.js +0 -2
  94. data/node_modules/preact/compat/dist/compat.umd.js.map +0 -1
  95. data/node_modules/preact/compat/jsx-dev-runtime.js +0 -3
  96. data/node_modules/preact/compat/jsx-dev-runtime.mjs +0 -3
  97. data/node_modules/preact/compat/jsx-runtime.js +0 -3
  98. data/node_modules/preact/compat/jsx-runtime.mjs +0 -3
  99. data/node_modules/preact/compat/package.json +0 -49
  100. data/node_modules/preact/compat/scheduler.js +0 -15
  101. data/node_modules/preact/compat/scheduler.mjs +0 -23
  102. data/node_modules/preact/compat/server.browser.js +0 -4
  103. data/node_modules/preact/compat/server.js +0 -15
  104. data/node_modules/preact/compat/server.mjs +0 -4
  105. data/node_modules/preact/compat/src/Children.js +0 -21
  106. data/node_modules/preact/compat/src/PureComponent.js +0 -15
  107. data/node_modules/preact/compat/src/forwardRef.js +0 -44
  108. data/node_modules/preact/compat/src/index.d.ts +0 -164
  109. data/node_modules/preact/compat/src/index.js +0 -223
  110. data/node_modules/preact/compat/src/internal.d.ts +0 -47
  111. data/node_modules/preact/compat/src/memo.js +0 -34
  112. data/node_modules/preact/compat/src/portals.js +0 -82
  113. data/node_modules/preact/compat/src/render.js +0 -238
  114. data/node_modules/preact/compat/src/suspense-list.d.ts +0 -14
  115. data/node_modules/preact/compat/src/suspense-list.js +0 -126
  116. data/node_modules/preact/compat/src/suspense.d.ts +0 -15
  117. data/node_modules/preact/compat/src/suspense.js +0 -270
  118. data/node_modules/preact/compat/src/util.js +0 -28
  119. data/node_modules/preact/compat/test-utils.js +0 -1
  120. data/node_modules/preact/debug/LICENSE +0 -21
  121. data/node_modules/preact/debug/dist/debug.js +0 -2
  122. data/node_modules/preact/debug/dist/debug.js.map +0 -1
  123. data/node_modules/preact/debug/dist/debug.mjs +0 -2
  124. data/node_modules/preact/debug/dist/debug.module.js +0 -2
  125. data/node_modules/preact/debug/dist/debug.module.js.map +0 -1
  126. data/node_modules/preact/debug/dist/debug.umd.js +0 -2
  127. data/node_modules/preact/debug/dist/debug.umd.js.map +0 -1
  128. data/node_modules/preact/debug/package.json +0 -26
  129. data/node_modules/preact/debug/src/check-props.js +0 -54
  130. data/node_modules/preact/debug/src/component-stack.js +0 -146
  131. data/node_modules/preact/debug/src/constants.js +0 -3
  132. data/node_modules/preact/debug/src/debug.js +0 -437
  133. data/node_modules/preact/debug/src/index.js +0 -6
  134. data/node_modules/preact/debug/src/internal.d.ts +0 -82
  135. data/node_modules/preact/debug/src/util.js +0 -11
  136. data/node_modules/preact/devtools/LICENSE +0 -21
  137. data/node_modules/preact/devtools/dist/devtools.js +0 -2
  138. data/node_modules/preact/devtools/dist/devtools.js.map +0 -1
  139. data/node_modules/preact/devtools/dist/devtools.mjs +0 -2
  140. data/node_modules/preact/devtools/dist/devtools.module.js +0 -2
  141. data/node_modules/preact/devtools/dist/devtools.module.js.map +0 -1
  142. data/node_modules/preact/devtools/dist/devtools.umd.js +0 -2
  143. data/node_modules/preact/devtools/dist/devtools.umd.js.map +0 -1
  144. data/node_modules/preact/devtools/package.json +0 -25
  145. data/node_modules/preact/devtools/src/devtools.js +0 -10
  146. data/node_modules/preact/devtools/src/index.d.ts +0 -8
  147. data/node_modules/preact/devtools/src/index.js +0 -15
  148. data/node_modules/preact/dist/preact.js +0 -2
  149. data/node_modules/preact/dist/preact.js.map +0 -1
  150. data/node_modules/preact/dist/preact.min.js +0 -2
  151. data/node_modules/preact/dist/preact.min.js.map +0 -1
  152. data/node_modules/preact/dist/preact.mjs +0 -2
  153. data/node_modules/preact/dist/preact.module.js +0 -2
  154. data/node_modules/preact/dist/preact.module.js.map +0 -1
  155. data/node_modules/preact/dist/preact.umd.js +0 -2
  156. data/node_modules/preact/dist/preact.umd.js.map +0 -1
  157. data/node_modules/preact/hooks/LICENSE +0 -21
  158. data/node_modules/preact/hooks/dist/hooks.js +0 -2
  159. data/node_modules/preact/hooks/dist/hooks.js.map +0 -1
  160. data/node_modules/preact/hooks/dist/hooks.mjs +0 -2
  161. data/node_modules/preact/hooks/dist/hooks.module.js +0 -2
  162. data/node_modules/preact/hooks/dist/hooks.module.js.map +0 -1
  163. data/node_modules/preact/hooks/dist/hooks.umd.js +0 -2
  164. data/node_modules/preact/hooks/dist/hooks.umd.js.map +0 -1
  165. data/node_modules/preact/hooks/package.json +0 -35
  166. data/node_modules/preact/hooks/src/index.d.ts +0 -139
  167. data/node_modules/preact/hooks/src/index.js +0 -417
  168. data/node_modules/preact/hooks/src/internal.d.ts +0 -78
  169. data/node_modules/preact/jsx-runtime/LICENSE +0 -21
  170. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js +0 -2
  171. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +0 -1
  172. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs +0 -2
  173. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js +0 -2
  174. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +0 -1
  175. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js +0 -2
  176. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +0 -1
  177. data/node_modules/preact/jsx-runtime/package.json +0 -28
  178. data/node_modules/preact/jsx-runtime/src/index.d.ts +0 -50
  179. data/node_modules/preact/jsx-runtime/src/index.js +0 -77
  180. data/node_modules/preact/package.json +0 -304
  181. data/node_modules/preact/src/cjs.js +0 -3
  182. data/node_modules/preact/src/clone-element.js +0 -34
  183. data/node_modules/preact/src/component.js +0 -225
  184. data/node_modules/preact/src/constants.js +0 -3
  185. data/node_modules/preact/src/create-context.js +0 -68
  186. data/node_modules/preact/src/create-element.js +0 -98
  187. data/node_modules/preact/src/diff/catch-error.js +0 -40
  188. data/node_modules/preact/src/diff/children.js +0 -335
  189. data/node_modules/preact/src/diff/index.js +0 -533
  190. data/node_modules/preact/src/diff/props.js +0 -158
  191. data/node_modules/preact/src/index.d.ts +0 -317
  192. data/node_modules/preact/src/index.js +0 -13
  193. data/node_modules/preact/src/internal.d.ts +0 -155
  194. data/node_modules/preact/src/jsx.d.ts +0 -1014
  195. data/node_modules/preact/src/options.js +0 -16
  196. data/node_modules/preact/src/render.js +0 -75
  197. data/node_modules/preact/src/util.js +0 -27
  198. data/node_modules/preact/test-utils/dist/testUtils.js +0 -2
  199. data/node_modules/preact/test-utils/dist/testUtils.js.map +0 -1
  200. data/node_modules/preact/test-utils/dist/testUtils.mjs +0 -2
  201. data/node_modules/preact/test-utils/dist/testUtils.module.js +0 -2
  202. data/node_modules/preact/test-utils/dist/testUtils.module.js.map +0 -1
  203. data/node_modules/preact/test-utils/dist/testUtils.umd.js +0 -2
  204. data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +0 -1
  205. data/node_modules/preact/test-utils/package.json +0 -28
  206. data/node_modules/preact/test-utils/src/index.d.ts +0 -3
  207. data/node_modules/preact/test-utils/src/index.js +0 -118
  208. data/node_modules/preact-render-to-string/LICENSE +0 -21
  209. data/node_modules/preact-render-to-string/README.md +0 -102
  210. data/node_modules/preact-render-to-string/dist/commonjs.js +0 -2
  211. data/node_modules/preact-render-to-string/dist/commonjs.js.map +0 -1
  212. data/node_modules/preact-render-to-string/dist/index.d.ts +0 -16
  213. data/node_modules/preact-render-to-string/dist/index.js +0 -1
  214. data/node_modules/preact-render-to-string/dist/index.js.map +0 -1
  215. data/node_modules/preact-render-to-string/dist/index.mjs +0 -2
  216. data/node_modules/preact-render-to-string/dist/index.module.js +0 -2
  217. data/node_modules/preact-render-to-string/dist/index.module.js.map +0 -1
  218. data/node_modules/preact-render-to-string/dist/jsx-entry.js +0 -2
  219. data/node_modules/preact-render-to-string/dist/jsx-entry.js.map +0 -1
  220. data/node_modules/preact-render-to-string/dist/jsx.d.ts +0 -13
  221. data/node_modules/preact-render-to-string/dist/jsx.js +0 -1
  222. data/node_modules/preact-render-to-string/dist/jsx.js.map +0 -1
  223. data/node_modules/preact-render-to-string/dist/jsx.mjs +0 -2
  224. data/node_modules/preact-render-to-string/dist/jsx.modern.js +0 -2
  225. data/node_modules/preact-render-to-string/dist/jsx.modern.js.map +0 -1
  226. data/node_modules/preact-render-to-string/dist/jsx.module.js +0 -2
  227. data/node_modules/preact-render-to-string/dist/jsx.module.js.map +0 -1
  228. data/node_modules/preact-render-to-string/dist/preact-render-to-string-tests.d.ts +0 -1
  229. data/node_modules/preact-render-to-string/jsx.js +0 -1
  230. data/node_modules/preact-render-to-string/package.json +0 -142
  231. data/node_modules/preact-render-to-string/src/index.d.ts +0 -16
  232. data/node_modules/preact-render-to-string/src/index.js +0 -462
  233. data/node_modules/preact-render-to-string/src/jsx.d.ts +0 -13
  234. data/node_modules/preact-render-to-string/src/jsx.js +0 -76
  235. data/node_modules/preact-render-to-string/src/polyfills.js +0 -8
  236. data/node_modules/preact-render-to-string/src/preact-render-to-string-tests.d.ts +0 -1
  237. data/node_modules/preact-render-to-string/src/util.js +0 -78
  238. data/node_modules/preact-render-to-string/typings.json +0 -5
  239. data/node_modules/pretty-format/.npmignore +0 -3
  240. data/node_modules/pretty-format/LICENSE.md +0 -15
  241. data/node_modules/pretty-format/README.md +0 -94
  242. data/node_modules/pretty-format/index.js +0 -343
  243. data/node_modules/pretty-format/package.json +0 -26
  244. data/node_modules/pretty-format/plugins/ReactElement.js +0 -74
  245. data/node_modules/pretty-format/plugins/ReactTestComponent.js +0 -58
  246. data/node_modules/pretty-format/printString.js +0 -7
  247. data/node_modules/wouter-preact/cjs/index.js +0 -180
  248. data/node_modules/wouter-preact/cjs/matcher.js +0 -72
  249. data/node_modules/wouter-preact/cjs/package.json +0 -1
  250. data/node_modules/wouter-preact/cjs/react-deps.js +0 -75
  251. data/node_modules/wouter-preact/cjs/static-location.js +0 -21
  252. data/node_modules/wouter-preact/cjs/use-location.js +0 -94
  253. data/node_modules/wouter-preact/index.d.ts +0 -110
  254. data/node_modules/wouter-preact/index.js +0 -178
  255. data/node_modules/wouter-preact/matcher.d.ts +0 -30
  256. data/node_modules/wouter-preact/matcher.js +0 -66
  257. data/node_modules/wouter-preact/package.json +0 -33
  258. data/node_modules/wouter-preact/react-deps.js +0 -15
  259. data/node_modules/wouter-preact/static-location.d.ts +0 -16
  260. data/node_modules/wouter-preact/static-location.js +0 -17
  261. data/node_modules/wouter-preact/use-location.d.ts +0 -43
  262. data/node_modules/wouter-preact/use-location.js +0 -86
  263. data/package.json +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fd60ca53a616be371c66eb5cf584563df83c595dcab068a393db00e0f47d921
4
- data.tar.gz: 36943fe176fd85721fa2fe2c13a13a630c3fd963d3d5a4b63a0105b8fecd54ee
3
+ metadata.gz: f03a9caab0b34f6c66cc1b321a6b7ab89a42af5b5ffb58f775ed5ac2d5bf2a14
4
+ data.tar.gz: f31916a7ca1e982c0f24f7fde58b0ae09aa834e14a3d872086842f802ffe0c45
5
5
  SHA512:
6
- metadata.gz: 7628277342dbd37726bb660c0583cc295230d4b9b1078fa7615a1b5983a62f5b202e6aee99caa44b70cb807107008dfc948f78bab154b83c8c39eac99748e940
7
- data.tar.gz: 72731c0e8f8355730492e35d23d60affd906141578338c49c64042fdb3713418c403293f28aab560b6e47d68a3ac130c8424ef0eecf1ff239d8db85c0d433b3d
6
+ metadata.gz: d301859c505f127332372ab4c5ace3eb01d8357d581baa38c2f187e5564c41dbee9cef90cb4fc1d1ad47c3665bf6b415bf2f76adce43b9490dcfaae02da3e443
7
+ data.tar.gz: aa70516de11b90de247423429e78def56967e780cb13bcd761d8d4de653310d7247d2ebd2ed87e66143ea31e3851136694df6effc9379d2f87738369ef55e518
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018-2019 Jan Biedermann
3
+ Copyright (c) 2018-present Jan Biedermann
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -20,7 +20,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
22
 
23
- Files in lib/browser directory originally taken from https://github.com/clearwater-rb/bowser, version 1.1.0:
23
+
24
+ Files in lib/browser directory originally taken from https://github.com/clearwater-rb/bowser:
24
25
 
25
26
  MIT License
26
27
 
@@ -28,7 +29,17 @@ Copyright (c) 2015 Jamie Gaskins
28
29
 
29
30
  (as above)
30
31
 
31
- Javascript in file lib/nano_css.rb taken from https://github.com/streamich/nano-css:
32
+
33
+ Javascript in file lib/preact.rb originally taken from https://github.com/preactjs/preact:
34
+
35
+ MIT License
36
+
37
+ Copyright (c) 2015-present Jason Miller
38
+
39
+ (as above)
40
+
41
+
42
+ Javascript in file lib/nano_css.rb originally taken from https://github.com/streamich/nano-css:
32
43
 
33
44
  This is free and unencumbered software released into the public domain.
34
45
 
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <h1 align="center">
2
- <img src="https://github.com/isomorfeus/isomorfeus-preact/blob/master/Logo.png?raw=true" align="center" width="234" height="125" />
2
+ <img src="https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/Logo.png?raw=true" align="center" width="234" height="125" />
3
3
  <br/>
4
4
  Isomorfeus Preact<br/>
5
5
  </h1>
@@ -10,52 +10,36 @@ Develop Preact components for Opal Ruby along with very easy to use and advanced
10
10
  At the [Isomorfeus Framework Project](https://isomorfeus.com)
11
11
 
12
12
  ## Versioning and Compatibility
13
- isomorfeus-preact version follows the Preact version which features and API it implements.
13
+ As of version 22.8 isomorfeus-preact implements its own preact and preact-render-to-string versions, adapted to work directly with ruby classes or ported to ruby.
14
14
 
15
15
  ### Preact
16
- Isomorfeus-preact 10.5.x implements features and the API of Preact 10.5.y and should be used with Preact 10.5.y
16
+
17
+ Isomorfeus-preact implements a Preact Class Components API in Ruby.
17
18
 
18
19
  ## Documentation
19
20
 
20
21
  Because isomorfeus-preact follows closely the Preact principles/implementation/API and Documentation, most things of the official Preact documentation
21
- apply, but in the Ruby way, see:
22
- - [https://preactjs.com/guide/v10/getting-started](https://preactjs.com/guide/v10/getting-started)
23
-
24
- Component Types:
25
- - [Class Component](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/class_component.md)
26
- - [Function and Memo Component](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/function_component.md)
27
- - [Lucid App, Lucid Component](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/lucid_component.md)
28
- - [Lucid Func (for use with Hooks)](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/lucid_func_component.md)
29
- - [Preact Javascript Components and Preact Elements](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/javascript_component.md)
30
-
31
- Which component to use?
32
- - Usually LucidApp and LucidComponent.
33
-
34
- Specific to Class, Lucid and LucidMaterial Components:
35
- - [Events](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/events.md)
36
- - [Lifecycle Callbacks](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/lifecycle_callbacks.md)
37
- - [Props](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/props.md)
38
- - [State](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/state.md)
39
-
40
- For all Components:
41
- - [Accessibility](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/accessibility.md)
42
- - [Render Blocks](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/render_blocks.md)
43
- - [Rendering HTML or SVG Elements](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/rendering_elements.md)
44
-
45
- Special Preact Features:
46
- - [Context](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/context.md)
47
- - [Fragments](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/fragments.md)
48
- - [Refs](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/refs.md)
22
+ apply, but in the Ruby way. (Except for Function components and Hooks, which are not supported). See the Preact Class Component documentation:
23
+ - [https://preactjs.com/guide/v10/components#class-components](https://preactjs.com/guide/v10/components#class-components)
24
+ - The base class in Ruby to inherit from and implement components is `Preact::Component`
25
+
26
+ Components:
27
+ - [Lucid App, Lucid Component](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/lucid_component.md)
28
+ - [Events](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/events.md)
29
+ - [Props](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/props.md)
30
+ - [State](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/state.md)
31
+ - [Accessibility](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/accessibility.md)
32
+ - [Render Blocks](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/render_blocks.md)
33
+ - [Rendering HTML or SVG Elements](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/rendering_elements.md)
34
+ - [Context](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/context.md)
35
+ - [Fragments](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/fragments.md)
36
+ - [Refs](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/refs.md)
49
37
 
50
38
  Other Features:
51
- - [Hot Module Reloading](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/hot_module_reloading.md)
52
- - [Server Side Rendering](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/server_side_rendering.md)
53
- - [Using Wouter as Router](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/wouter.md)
54
- - [Isomorfeus Helpers](https://github.com/isomorfeus/isomorfeus-preact/blob/master/docs/isomorfeus_helpers.md)
55
-
56
- ### Development Tools
57
- The Preact Devtools allow for analyzing, debugging and profiling components. A very helpful toolset and working very nice with isomorfeus-preact:
58
- [https://preactjs.github.io/preact-devtools/](https://preactjs.github.io/preact-devtools/)
39
+ - [Hot Module Reloading](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/hot_module_reloading.md)
40
+ - [Server Side Rendering](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/server_side_rendering.md)
41
+ - [Using Router](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/router.md)
42
+ - [Isomorfeus Helpers](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-preact/docs/isomorfeus_helpers.md)
59
43
 
60
44
  ### Specs and Benchmarks
61
45
  - clone repo
@@ -1,72 +1,94 @@
1
- module Browser
2
- module DelegateNative
3
- # Provides a default initializer. This should be overridden in all but the
4
- # simplest cases.
5
- def initialize native
6
- @native = native
7
- end
8
-
9
- # Fall back to native properties. If the message sent to this element is not
10
- # recognized, it checks to see if it is a property of the native element. It
11
- # also checks for variations of the message name, such as:
12
- #
13
- # :supported? => [:supported, :isSupported]
14
- #
15
- # If a property with the specified message name is found and it is a
16
- # function, that function is invoked with `args`. Otherwise, the property
17
- # is returned as is.
18
- def method_missing message, *args, &block
19
- if message.end_with? '='
20
- message = message.chop
21
- property_name = property_for_message(message)
22
- return `#@native[#{property_name}] = args[0]`
23
- else
24
- property_name = property_for_message(message)
25
-
26
- %x{
27
- let value = #@native[#{property_name}];
28
- let type = typeof(value);
29
- try {
30
- if (type === 'function') {
31
- return value.apply(#@native, args);
32
- } else if (type === 'object' && (value instanceof HTMLCollection)) {
33
- let a = [];
34
- for(let i=0; i<value.length; i++) {
35
- a[i] = #{Browser::Element.new(`value.item(i)`)};
36
- }
37
- value = a;
38
- } else if (type === 'object' && (value instanceof HTMLElement)) {
39
- value = #{Browser::Element.new(`value`)};
40
- } else if (value === null || type === 'undefined' || (type === 'number' && isNaN(value))) {
41
- return nil;
42
- }
43
- return value;
44
- } catch { return value; }
45
- }
46
- end
47
- end
48
-
49
- def respond_to_missing? message, include_all
50
- message = message.chop if message.end_with? '='
51
- property_name = property_for_message(message)
52
- return true unless `#{property_name} in #@native`
53
- false
54
- end
55
-
56
- def property_for_message(message)
57
- %x{
58
- let camel_cased_message;
59
- if (typeof(#@native[message]) !== 'undefined') { camel_cased_message = message; }
60
- else { camel_cased_message = Opal.Preact.lower_camelize(message) }
61
-
62
- if (camel_cased_message.endsWith('?')) {
63
- camel_cased_message = camel_cased_message.substring(0, camel_cased_message.length - 2);
64
- if (typeof(#@native[camel_cased_message]) === 'undefined') {
65
- camel_cased_message = 'is' + camel_cased_message[0].toUpperCase() + camel_cased_message.substring(0, camel_cased_message.length - 1);
66
- }
67
- }
68
- return camel_cased_message
69
- }
70
- end
71
- end
72
- end
1
+ module Browser
2
+ module DelegateNative
3
+ # Provides a default initializer. This should be overridden in all but the
4
+ # simplest cases.
5
+ def initialize native
6
+ @native = native
7
+ end
8
+
9
+ def [](property)
10
+ method_missing(property)
11
+ end
12
+
13
+ # Fall back to native properties. If the message sent to this element is not
14
+ # recognized, it checks to see if it is a property of the native element. It
15
+ # also checks for variations of the message name, such as:
16
+ #
17
+ # :supported? => [:supported, :isSupported]
18
+ #
19
+ # If a property with the specified message name is found and it is a
20
+ # function, that function is invoked with `args`. Otherwise, the property
21
+ # is returned as is.
22
+ def method_missing message, *args, &block
23
+ if message.end_with? '='
24
+ message = message.chop
25
+ property_name = property_for_message(message)
26
+ arg = args[0]
27
+ arg = if `arg && typeof arg.$to_n === 'function'`
28
+ arg.to_n
29
+ else
30
+ arg
31
+ end
32
+ return `#@native[#{property_name}] = args[0]`
33
+ else
34
+ property_name = property_for_message(message)
35
+
36
+ %x{
37
+ let value = #@native[#{property_name}];
38
+ let type = typeof(value);
39
+ try {
40
+ if (type === 'function') {
41
+ #{
42
+ args.map! do |arg|
43
+ if `arg && typeof arg.$to_n === 'function'`
44
+ arg.to_n
45
+ else
46
+ arg
47
+ end
48
+ end
49
+ }
50
+ value = value.apply(#@native, args);
51
+ }
52
+ if (value instanceof HTMLCollection || value instanceof NodeList) {
53
+ let a = [];
54
+ for(let i=0; i<value.length; i++) {
55
+ a[i] = #{Browser::Element.new(`value.item(i)`)};
56
+ }
57
+ value = a;
58
+ } else if (value instanceof HTMLElement || value instanceof SVGElement) {
59
+ value = #{Browser::Element.new(`value`)};
60
+ } else if (value instanceof Event) {
61
+ value = #{Browser::Event.new(`value`)};
62
+ } else if (value === null || type === 'undefined' || (type === 'number' && isNaN(value))) {
63
+ value = nil;
64
+ }
65
+ return value;
66
+ } catch { return value; }
67
+ }
68
+ end
69
+ end
70
+
71
+ def respond_to_missing? message, include_all
72
+ message = message.chop if message.end_with? '='
73
+ property_name = property_for_message(message)
74
+ return true unless `#{property_name} in #@native`
75
+ false
76
+ end
77
+
78
+ def property_for_message(message)
79
+ %x{
80
+ let camel_cased_message;
81
+ if (typeof(#@native[message]) !== 'undefined') { camel_cased_message = message; }
82
+ else { camel_cased_message = #{message.camelize(:lower)} }
83
+
84
+ if (camel_cased_message.endsWith('?')) {
85
+ camel_cased_message = camel_cased_message.substring(0, camel_cased_message.length - 2);
86
+ if (typeof(#@native[camel_cased_message]) === 'undefined') {
87
+ camel_cased_message = 'is' + camel_cased_message[0].toUpperCase() + camel_cased_message.substring(0, camel_cased_message.length - 1);
88
+ }
89
+ }
90
+ return camel_cased_message
91
+ }
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,38 @@
1
+ module Browser
2
+ module Document
3
+ extend DelegateNative
4
+ extend EventTarget
5
+
6
+ @native = `document`
7
+
8
+ module_function
9
+
10
+ # @return [Browser::Element] the head element of the current document
11
+ def head
12
+ @head ||= Element.new(`#@native.head`)
13
+ end
14
+
15
+ # @return [Browser::Element] the body element of the current document
16
+ def body
17
+ @body ||= Element.new(`#@native.body`)
18
+ end
19
+
20
+ # @return [Browser::Element?] the first element that matches the given CSS
21
+ # selector or `nil` if no elements match
22
+ def [] css
23
+ native = `#@native.querySelector(css)`
24
+ if `#{native} === null`
25
+ nil
26
+ else
27
+ Element.new(native)
28
+ end
29
+ end
30
+ end
31
+
32
+ module_function
33
+
34
+ # @return [Document] the browser's document object
35
+ def document
36
+ Document
37
+ end
38
+ end