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,223 +0,0 @@
1
- import {
2
- createElement,
3
- render as preactRender,
4
- cloneElement as preactCloneElement,
5
- createRef,
6
- Component,
7
- createContext,
8
- Fragment
9
- } from 'preact';
10
- import {
11
- useState,
12
- useReducer,
13
- useEffect,
14
- useLayoutEffect,
15
- useRef,
16
- useImperativeHandle,
17
- useMemo,
18
- useCallback,
19
- useContext,
20
- useDebugValue
21
- } from 'preact/hooks';
22
- import { PureComponent } from './PureComponent';
23
- import { memo } from './memo';
24
- import { forwardRef } from './forwardRef';
25
- import { Children } from './Children';
26
- import { Suspense, lazy } from './suspense';
27
- import { SuspenseList } from './suspense-list';
28
- import { createPortal } from './portals';
29
- import {
30
- hydrate,
31
- render,
32
- REACT_ELEMENT_TYPE,
33
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
34
- } from './render';
35
-
36
- const version = '17.0.2'; // trick libraries to think we are react
37
-
38
- /**
39
- * Legacy version of createElement.
40
- * @param {import('./internal').VNode["type"]} type The node name or Component constructor
41
- */
42
- function createFactory(type) {
43
- return createElement.bind(null, type);
44
- }
45
-
46
- /**
47
- * Check if the passed element is a valid (p)react node.
48
- * @param {*} element The element to check
49
- * @returns {boolean}
50
- */
51
- function isValidElement(element) {
52
- return !!element && element.$$typeof === REACT_ELEMENT_TYPE;
53
- }
54
-
55
- /**
56
- * Wrap `cloneElement` to abort if the passed element is not a valid element and apply
57
- * all vnode normalizations.
58
- * @param {import('./internal').VNode} element The vnode to clone
59
- * @param {object} props Props to add when cloning
60
- * @param {Array<import('./internal').ComponentChildren>} rest Optional component children
61
- */
62
- function cloneElement(element) {
63
- if (!isValidElement(element)) return element;
64
- return preactCloneElement.apply(null, arguments);
65
- }
66
-
67
- /**
68
- * Remove a component tree from the DOM, including state and event handlers.
69
- * @param {import('./internal').PreactElement} container
70
- * @returns {boolean}
71
- */
72
- function unmountComponentAtNode(container) {
73
- if (container._children) {
74
- preactRender(null, container);
75
- return true;
76
- }
77
- return false;
78
- }
79
-
80
- /**
81
- * Get the matching DOM node for a component
82
- * @param {import('./internal').Component} component
83
- * @returns {import('./internal').PreactElement | null}
84
- */
85
- function findDOMNode(component) {
86
- return (
87
- (component &&
88
- (component.base || (component.nodeType === 1 && component))) ||
89
- null
90
- );
91
- }
92
-
93
- /**
94
- * Deprecated way to control batched rendering inside the reconciler, but we
95
- * already schedule in batches inside our rendering code
96
- * @template Arg
97
- * @param {(arg: Arg) => void} callback function that triggers the updated
98
- * @param {Arg} [arg] Optional argument that can be passed to the callback
99
- */
100
- // eslint-disable-next-line camelcase
101
- const unstable_batchedUpdates = (callback, arg) => callback(arg);
102
-
103
- /**
104
- * In React, `flushSync` flushes the entire tree and forces a rerender. It's
105
- * implmented here as a no-op.
106
- * @template Arg
107
- * @template Result
108
- * @param {(arg: Arg) => Result} callback function that runs before the flush
109
- * @param {Arg} [arg] Optional arugment that can be passed to the callback
110
- * @returns
111
- */
112
- const flushSync = (callback, arg) => callback(arg);
113
-
114
- /**
115
- * Strict Mode is not implemented in Preact, so we provide a stand-in for it
116
- * that just renders its children without imposing any restrictions.
117
- */
118
- const StrictMode = Fragment;
119
-
120
- export function startTransition(cb) {
121
- cb();
122
- }
123
-
124
- export function useDeferredValue(val) {
125
- return val;
126
- }
127
-
128
- export function useTransition() {
129
- return [false, startTransition];
130
- }
131
-
132
- // TODO: in theory this should be done after a VNode is diffed as we want to insert
133
- // styles/... before it attaches
134
- export const useInsertionEffect = useLayoutEffect;
135
-
136
- export function useSyncExternalStore(subscribe, getSnapshot) {
137
- const [state, setState] = useState(getSnapshot);
138
-
139
- // TODO: in suspense for data we could have a discrepancy here because Preact won't re-init the "useState"
140
- // when this unsuspends which could lead to stale state as the subscription is torn down.
141
-
142
- useEffect(() => {
143
- return subscribe(() => {
144
- setState(getSnapshot());
145
- });
146
- }, [subscribe, getSnapshot]);
147
-
148
- return state;
149
- }
150
-
151
- export * from 'preact/hooks';
152
- export {
153
- version,
154
- Children,
155
- render,
156
- hydrate,
157
- unmountComponentAtNode,
158
- createPortal,
159
- createElement,
160
- createContext,
161
- createFactory,
162
- cloneElement,
163
- createRef,
164
- Fragment,
165
- isValidElement,
166
- findDOMNode,
167
- Component,
168
- PureComponent,
169
- memo,
170
- forwardRef,
171
- flushSync,
172
- // eslint-disable-next-line camelcase
173
- unstable_batchedUpdates,
174
- StrictMode,
175
- Suspense,
176
- SuspenseList,
177
- lazy,
178
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
179
- };
180
-
181
- // React copies the named exports to the default one.
182
- export default {
183
- useState,
184
- useReducer,
185
- useEffect,
186
- useLayoutEffect,
187
- useInsertionEffect,
188
- useTransition,
189
- useDeferredValue,
190
- useSyncExternalStore,
191
- startTransition,
192
- useRef,
193
- useImperativeHandle,
194
- useMemo,
195
- useCallback,
196
- useContext,
197
- useDebugValue,
198
- version,
199
- Children,
200
- render,
201
- hydrate,
202
- unmountComponentAtNode,
203
- createPortal,
204
- createElement,
205
- createContext,
206
- createFactory,
207
- cloneElement,
208
- createRef,
209
- Fragment,
210
- isValidElement,
211
- findDOMNode,
212
- Component,
213
- PureComponent,
214
- memo,
215
- forwardRef,
216
- flushSync,
217
- unstable_batchedUpdates,
218
- StrictMode,
219
- Suspense,
220
- SuspenseList,
221
- lazy,
222
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
223
- };
@@ -1,47 +0,0 @@
1
- import {
2
- Component as PreactComponent,
3
- VNode as PreactVNode,
4
- FunctionComponent as PreactFunctionComponent
5
- } from '../../src/internal';
6
- import { SuspenseProps } from './suspense';
7
-
8
- export { ComponentChildren } from '../..';
9
-
10
- export { PreactElement } from '../../src/internal';
11
-
12
- export interface Component<P = {}, S = {}> extends PreactComponent<P, S> {
13
- isReactComponent?: object;
14
- isPureReactComponent?: true;
15
- _patchedLifecycles?: true;
16
-
17
- // Suspense internal properties
18
- _childDidSuspend?(error: Promise<void>, suspendingVNode: VNode): void;
19
- _suspended: (vnode: VNode) => (unsuspend: () => void) => void;
20
- _onResolve?(): void;
21
-
22
- // Portal internal properties
23
- _temp: any;
24
- _container: PreactElement;
25
- }
26
-
27
- export interface FunctionComponent<P = {}> extends PreactFunctionComponent<P> {
28
- shouldComponentUpdate?(nextProps: Readonly<P>): boolean;
29
- _forwarded?: boolean;
30
- _patchedLifecycles?: true;
31
- }
32
-
33
- export interface VNode<T = any> extends PreactVNode<T> {
34
- $$typeof?: symbol | string;
35
- preactCompatNormalized?: boolean;
36
- }
37
-
38
- export interface SuspenseState {
39
- _suspended?: null | VNode<any>;
40
- }
41
-
42
- export interface SuspenseComponent
43
- extends PreactComponent<SuspenseProps, SuspenseState> {
44
- _pendingSuspensionCount: number;
45
- _suspenders: Component[];
46
- _detachOnNextRender: null | VNode<any>;
47
- }
@@ -1,34 +0,0 @@
1
- import { createElement } from 'preact';
2
- import { shallowDiffers } from './util';
3
-
4
- /**
5
- * Memoize a component, so that it only updates when the props actually have
6
- * changed. This was previously known as `React.pure`.
7
- * @param {import('./internal').FunctionComponent} c functional component
8
- * @param {(prev: object, next: object) => boolean} [comparer] Custom equality function
9
- * @returns {import('./internal').FunctionComponent}
10
- */
11
- export function memo(c, comparer) {
12
- function shouldUpdate(nextProps) {
13
- let ref = this.props.ref;
14
- let updateRef = ref == nextProps.ref;
15
- if (!updateRef && ref) {
16
- ref.call ? ref(null) : (ref.current = null);
17
- }
18
-
19
- if (!comparer) {
20
- return shallowDiffers(this.props, nextProps);
21
- }
22
-
23
- return !comparer(this.props, nextProps) || !updateRef;
24
- }
25
-
26
- function Memoed(props) {
27
- this.shouldComponentUpdate = shouldUpdate;
28
- return createElement(c, props);
29
- }
30
- Memoed.displayName = 'Memo(' + (c.displayName || c.name) + ')';
31
- Memoed.prototype.isReactComponent = true;
32
- Memoed._forwarded = true;
33
- return Memoed;
34
- }
@@ -1,82 +0,0 @@
1
- import { createElement, render } from 'preact';
2
-
3
- /**
4
- * @param {import('../../src/index').RenderableProps<{ context: any }>} props
5
- */
6
- function ContextProvider(props) {
7
- this.getChildContext = () => props.context;
8
- return props.children;
9
- }
10
-
11
- /**
12
- * Portal component
13
- * @this {import('./internal').Component}
14
- * @param {object | null | undefined} props
15
- *
16
- * TODO: use createRoot() instead of fake root
17
- */
18
- function Portal(props) {
19
- const _this = this;
20
- let container = props._container;
21
-
22
- _this.componentWillUnmount = function() {
23
- render(null, _this._temp);
24
- _this._temp = null;
25
- _this._container = null;
26
- };
27
-
28
- // When we change container we should clear our old container and
29
- // indicate a new mount.
30
- if (_this._container && _this._container !== container) {
31
- _this.componentWillUnmount();
32
- }
33
-
34
- // When props.vnode is undefined/false/null we are dealing with some kind of
35
- // conditional vnode. This should not trigger a render.
36
- if (props._vnode) {
37
- if (!_this._temp) {
38
- _this._container = container;
39
-
40
- // Create a fake DOM parent node that manages a subset of `container`'s children:
41
- _this._temp = {
42
- nodeType: 1,
43
- parentNode: container,
44
- childNodes: [],
45
- appendChild(child) {
46
- this.childNodes.push(child);
47
- _this._container.appendChild(child);
48
- },
49
- insertBefore(child, before) {
50
- this.childNodes.push(child);
51
- _this._container.appendChild(child);
52
- },
53
- removeChild(child) {
54
- this.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1);
55
- _this._container.removeChild(child);
56
- }
57
- };
58
- }
59
-
60
- // Render our wrapping element into temp.
61
- render(
62
- createElement(ContextProvider, { context: _this.context }, props._vnode),
63
- _this._temp
64
- );
65
- }
66
- // When we come from a conditional render, on a mounted
67
- // portal we should clear the DOM.
68
- else if (_this._temp) {
69
- _this.componentWillUnmount();
70
- }
71
- }
72
-
73
- /**
74
- * Create a `Portal` to continue rendering the vnode tree at a different DOM node
75
- * @param {import('./internal').VNode} vnode The vnode to render
76
- * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
77
- */
78
- export function createPortal(vnode, container) {
79
- const el = createElement(Portal, { _vnode: vnode, _container: container });
80
- el.containerInfo = container;
81
- return el;
82
- }
@@ -1,238 +0,0 @@
1
- import {
2
- render as preactRender,
3
- hydrate as preactHydrate,
4
- options,
5
- toChildArray,
6
- Component
7
- } from 'preact';
8
-
9
- export const REACT_ELEMENT_TYPE =
10
- (typeof Symbol != 'undefined' && Symbol.for && Symbol.for('react.element')) ||
11
- 0xeac7;
12
-
13
- const CAMEL_PROPS = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|shape|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
14
-
15
- const IS_DOM = typeof document !== 'undefined';
16
-
17
- // Input types for which onchange should not be converted to oninput.
18
- // type="file|checkbox|radio", plus "range" in IE11.
19
- // (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
20
- const onChangeInputType = type =>
21
- (typeof Symbol != 'undefined' && typeof Symbol() == 'symbol'
22
- ? /fil|che|rad/i
23
- : /fil|che|ra/i
24
- ).test(type);
25
-
26
- // Some libraries like `react-virtualized` explicitly check for this.
27
- Component.prototype.isReactComponent = {};
28
-
29
- // `UNSAFE_*` lifecycle hooks
30
- // Preact only ever invokes the unprefixed methods.
31
- // Here we provide a base "fallback" implementation that calls any defined UNSAFE_ prefixed method.
32
- // - If a component defines its own `componentDidMount()` (including via defineProperty), use that.
33
- // - If a component defines `UNSAFE_componentDidMount()`, `componentDidMount` is the alias getter/setter.
34
- // - If anything assigns to an `UNSAFE_*` property, the assignment is forwarded to the unprefixed property.
35
- // See https://github.com/preactjs/preact/issues/1941
36
- [
37
- 'componentWillMount',
38
- 'componentWillReceiveProps',
39
- 'componentWillUpdate'
40
- ].forEach(key => {
41
- Object.defineProperty(Component.prototype, key, {
42
- configurable: true,
43
- get() {
44
- return this['UNSAFE_' + key];
45
- },
46
- set(v) {
47
- Object.defineProperty(this, key, {
48
- configurable: true,
49
- writable: true,
50
- value: v
51
- });
52
- }
53
- });
54
- });
55
-
56
- /**
57
- * Proxy render() since React returns a Component reference.
58
- * @param {import('./internal').VNode} vnode VNode tree to render
59
- * @param {import('./internal').PreactElement} parent DOM node to render vnode tree into
60
- * @param {() => void} [callback] Optional callback that will be called after rendering
61
- * @returns {import('./internal').Component | null} The root component reference or null
62
- */
63
- export function render(vnode, parent, callback) {
64
- // React destroys any existing DOM nodes, see #1727
65
- // ...but only on the first render, see #1828
66
- if (parent._children == null) {
67
- parent.textContent = '';
68
- }
69
-
70
- preactRender(vnode, parent);
71
- if (typeof callback == 'function') callback();
72
-
73
- return vnode ? vnode._component : null;
74
- }
75
-
76
- export function hydrate(vnode, parent, callback) {
77
- preactHydrate(vnode, parent);
78
- if (typeof callback == 'function') callback();
79
-
80
- return vnode ? vnode._component : null;
81
- }
82
-
83
- let oldEventHook = options.event;
84
- options.event = e => {
85
- if (oldEventHook) e = oldEventHook(e);
86
- e.persist = empty;
87
- e.isPropagationStopped = isPropagationStopped;
88
- e.isDefaultPrevented = isDefaultPrevented;
89
- return (e.nativeEvent = e);
90
- };
91
-
92
- function empty() {}
93
-
94
- function isPropagationStopped() {
95
- return this.cancelBubble;
96
- }
97
-
98
- function isDefaultPrevented() {
99
- return this.defaultPrevented;
100
- }
101
-
102
- let classNameDescriptor = {
103
- configurable: true,
104
- get() {
105
- return this.class;
106
- }
107
- };
108
-
109
- let oldVNodeHook = options.vnode;
110
- options.vnode = vnode => {
111
- let type = vnode.type;
112
- let props = vnode.props;
113
- let normalizedProps = props;
114
-
115
- // only normalize props on Element nodes
116
- if (typeof type === 'string') {
117
- const nonCustomElement = type.indexOf('-') === -1;
118
- normalizedProps = {};
119
-
120
- for (let i in props) {
121
- let value = props[i];
122
-
123
- if (IS_DOM && i === 'children' && type === 'noscript') {
124
- // Emulate React's behavior of not rendering the contents of noscript tags on the client.
125
- continue;
126
- } else if (i === 'value' && 'defaultValue' in props && value == null) {
127
- // Skip applying value if it is null/undefined and we already set
128
- // a default value
129
- continue;
130
- } else if (
131
- i === 'defaultValue' &&
132
- 'value' in props &&
133
- props.value == null
134
- ) {
135
- // `defaultValue` is treated as a fallback `value` when a value prop is present but null/undefined.
136
- // `defaultValue` for Elements with no value prop is the same as the DOM defaultValue property.
137
- i = 'value';
138
- } else if (i === 'download' && value === true) {
139
- // Calling `setAttribute` with a truthy value will lead to it being
140
- // passed as a stringified value, e.g. `download="true"`. React
141
- // converts it to an empty string instead, otherwise the attribute
142
- // value will be used as the file name and the file will be called
143
- // "true" upon downloading it.
144
- value = '';
145
- } else if (/ondoubleclick/i.test(i)) {
146
- i = 'ondblclick';
147
- } else if (
148
- /^onchange(textarea|input)/i.test(i + type) &&
149
- !onChangeInputType(props.type)
150
- ) {
151
- i = 'oninput';
152
- } else if (/^onfocus$/i.test(i)) {
153
- i = 'onfocusin';
154
- } else if (/^onblur$/i.test(i)) {
155
- i = 'onfocusout';
156
- } else if (/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(i)) {
157
- i = i.toLowerCase();
158
- } else if (nonCustomElement && CAMEL_PROPS.test(i)) {
159
- i = i.replace(/[A-Z0-9]/, '-$&').toLowerCase();
160
- } else if (value === null) {
161
- value = undefined;
162
- }
163
-
164
- // Add support for onInput and onChange, see #3561
165
- // if we have an oninput prop already change it to oninputCapture
166
- if (/^oninput$/i.test(i)) {
167
- i = i.toLowerCase();
168
- if (normalizedProps[i]) {
169
- i = 'oninputCapture';
170
- }
171
- }
172
-
173
- normalizedProps[i] = value;
174
- }
175
-
176
- // Add support for array select values: <select multiple value={[]} />
177
- if (
178
- type == 'select' &&
179
- normalizedProps.multiple &&
180
- Array.isArray(normalizedProps.value)
181
- ) {
182
- // forEach() always returns undefined, which we abuse here to unset the value prop.
183
- normalizedProps.value = toChildArray(props.children).forEach(child => {
184
- child.props.selected =
185
- normalizedProps.value.indexOf(child.props.value) != -1;
186
- });
187
- }
188
-
189
- // Adding support for defaultValue in select tag
190
- if (type == 'select' && normalizedProps.defaultValue != null) {
191
- normalizedProps.value = toChildArray(props.children).forEach(child => {
192
- if (normalizedProps.multiple) {
193
- child.props.selected =
194
- normalizedProps.defaultValue.indexOf(child.props.value) != -1;
195
- } else {
196
- child.props.selected =
197
- normalizedProps.defaultValue == child.props.value;
198
- }
199
- });
200
- }
201
-
202
- vnode.props = normalizedProps;
203
-
204
- if (props.class != props.className) {
205
- classNameDescriptor.enumerable = 'className' in props;
206
- if (props.className != null) normalizedProps.class = props.className;
207
- Object.defineProperty(normalizedProps, 'className', classNameDescriptor);
208
- }
209
- }
210
-
211
- vnode.$$typeof = REACT_ELEMENT_TYPE;
212
-
213
- if (oldVNodeHook) oldVNodeHook(vnode);
214
- };
215
-
216
- // Only needed for react-relay
217
- let currentComponent;
218
- const oldBeforeRender = options._render;
219
- options._render = function(vnode) {
220
- if (oldBeforeRender) {
221
- oldBeforeRender(vnode);
222
- }
223
- currentComponent = vnode._component;
224
- };
225
-
226
- // This is a very very private internal function for React it
227
- // is used to sort-of do runtime dependency injection. So far
228
- // only `react-relay` makes use of it. It uses it to read the
229
- // context value.
230
- export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
231
- ReactCurrentDispatcher: {
232
- current: {
233
- readContext(context) {
234
- return currentComponent._globalContext[context._id].props.value;
235
- }
236
- }
237
- }
238
- };
@@ -1,14 +0,0 @@
1
- import { Component, ComponentChild, ComponentChildren } from '../../src';
2
-
3
- //
4
- // SuspenseList
5
- // -----------------------------------
6
-
7
- export interface SuspenseListProps {
8
- children?: ComponentChildren;
9
- revealOrder?: 'forwards' | 'backwards' | 'together';
10
- }
11
-
12
- export class SuspenseList extends Component<SuspenseListProps> {
13
- render(): ComponentChild;
14
- }