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,437 +0,0 @@
1
- import { checkPropTypes } from './check-props';
2
- import { options, Component } from 'preact';
3
- import {
4
- ELEMENT_NODE,
5
- DOCUMENT_NODE,
6
- DOCUMENT_FRAGMENT_NODE
7
- } from './constants';
8
- import {
9
- getOwnerStack,
10
- setupComponentStack,
11
- getCurrentVNode,
12
- getDisplayName
13
- } from './component-stack';
14
- import { assign } from './util';
15
-
16
- const isWeakMapSupported = typeof WeakMap == 'function';
17
-
18
- function getClosestDomNodeParent(parent) {
19
- if (!parent) return {};
20
- if (typeof parent.type == 'function') {
21
- return getClosestDomNodeParent(parent._parent);
22
- }
23
- return parent;
24
- }
25
-
26
- export function initDebug() {
27
- setupComponentStack();
28
-
29
- let hooksAllowed = false;
30
-
31
- /* eslint-disable no-console */
32
- let oldBeforeDiff = options._diff;
33
- let oldDiffed = options.diffed;
34
- let oldVnode = options.vnode;
35
- let oldCatchError = options._catchError;
36
- let oldRoot = options._root;
37
- let oldHook = options._hook;
38
- const warnedComponents = !isWeakMapSupported
39
- ? null
40
- : {
41
- useEffect: new WeakMap(),
42
- useLayoutEffect: new WeakMap(),
43
- lazyPropTypes: new WeakMap()
44
- };
45
- const deprecations = [];
46
-
47
- options._catchError = (error, vnode, oldVNode, errorInfo) => {
48
- let component = vnode && vnode._component;
49
- if (component && typeof error.then == 'function') {
50
- const promise = error;
51
- error = new Error(
52
- `Missing Suspense. The throwing component was: ${getDisplayName(vnode)}`
53
- );
54
-
55
- let parent = vnode;
56
- for (; parent; parent = parent._parent) {
57
- if (parent._component && parent._component._childDidSuspend) {
58
- error = promise;
59
- break;
60
- }
61
- }
62
-
63
- // We haven't recovered and we know at this point that there is no
64
- // Suspense component higher up in the tree
65
- if (error instanceof Error) {
66
- throw error;
67
- }
68
- }
69
-
70
- try {
71
- errorInfo = errorInfo || {};
72
- errorInfo.componentStack = getOwnerStack(vnode);
73
- oldCatchError(error, vnode, oldVNode, errorInfo);
74
-
75
- // when an error was handled by an ErrorBoundary we will nontheless emit an error
76
- // event on the window object. This is to make up for react compatibility in dev mode
77
- // and thus make the Next.js dev overlay work.
78
- if (typeof error.then != 'function') {
79
- setTimeout(() => {
80
- throw error;
81
- });
82
- }
83
- } catch (e) {
84
- throw e;
85
- }
86
- };
87
-
88
- options._root = (vnode, parentNode) => {
89
- if (!parentNode) {
90
- throw new Error(
91
- 'Undefined parent passed to render(), this is the second argument.\n' +
92
- 'Check if the element is available in the DOM/has the correct id.'
93
- );
94
- }
95
-
96
- let isValid;
97
- switch (parentNode.nodeType) {
98
- case ELEMENT_NODE:
99
- case DOCUMENT_FRAGMENT_NODE:
100
- case DOCUMENT_NODE:
101
- isValid = true;
102
- break;
103
- default:
104
- isValid = false;
105
- }
106
-
107
- if (!isValid) {
108
- let componentName = getDisplayName(vnode);
109
- throw new Error(
110
- `Expected a valid HTML node as a second argument to render. Received ${parentNode} instead: render(<${componentName} />, ${parentNode});`
111
- );
112
- }
113
-
114
- if (oldRoot) oldRoot(vnode, parentNode);
115
- };
116
-
117
- options._diff = vnode => {
118
- let { type, _parent: parent } = vnode;
119
- let parentVNode = getClosestDomNodeParent(parent);
120
-
121
- hooksAllowed = true;
122
-
123
- if (type === undefined) {
124
- throw new Error(
125
- 'Undefined component passed to createElement()\n\n' +
126
- 'You likely forgot to export your component or might have mixed up default and named imports' +
127
- serializeVNode(vnode) +
128
- `\n\n${getOwnerStack(vnode)}`
129
- );
130
- } else if (type != null && typeof type == 'object') {
131
- if (type._children !== undefined && type._dom !== undefined) {
132
- throw new Error(
133
- `Invalid type passed to createElement(): ${type}\n\n` +
134
- 'Did you accidentally pass a JSX literal as JSX twice?\n\n' +
135
- ` let My${getDisplayName(vnode)} = ${serializeVNode(type)};\n` +
136
- ` let vnode = <My${getDisplayName(vnode)} />;\n\n` +
137
- 'This usually happens when you export a JSX literal and not the component.' +
138
- `\n\n${getOwnerStack(vnode)}`
139
- );
140
- }
141
-
142
- throw new Error(
143
- 'Invalid type passed to createElement(): ' +
144
- (Array.isArray(type) ? 'array' : type)
145
- );
146
- }
147
-
148
- if (
149
- (type === 'thead' || type === 'tfoot' || type === 'tbody') &&
150
- parentVNode.type !== 'table'
151
- ) {
152
- console.error(
153
- 'Improper nesting of table. Your <thead/tbody/tfoot> should have a <table> parent.' +
154
- serializeVNode(vnode) +
155
- `\n\n${getOwnerStack(vnode)}`
156
- );
157
- } else if (
158
- type === 'tr' &&
159
- parentVNode.type !== 'thead' &&
160
- parentVNode.type !== 'tfoot' &&
161
- parentVNode.type !== 'tbody' &&
162
- parentVNode.type !== 'table'
163
- ) {
164
- console.error(
165
- 'Improper nesting of table. Your <tr> should have a <thead/tbody/tfoot/table> parent.' +
166
- serializeVNode(vnode) +
167
- `\n\n${getOwnerStack(vnode)}`
168
- );
169
- } else if (type === 'td' && parentVNode.type !== 'tr') {
170
- console.error(
171
- 'Improper nesting of table. Your <td> should have a <tr> parent.' +
172
- serializeVNode(vnode) +
173
- `\n\n${getOwnerStack(vnode)}`
174
- );
175
- } else if (type === 'th' && parentVNode.type !== 'tr') {
176
- console.error(
177
- 'Improper nesting of table. Your <th> should have a <tr>.' +
178
- serializeVNode(vnode) +
179
- `\n\n${getOwnerStack(vnode)}`
180
- );
181
- }
182
-
183
- if (
184
- vnode.ref !== undefined &&
185
- typeof vnode.ref != 'function' &&
186
- typeof vnode.ref != 'object' &&
187
- !('$$typeof' in vnode) // allow string refs when preact-compat is installed
188
- ) {
189
- throw new Error(
190
- `Component's "ref" property should be a function, or an object created ` +
191
- `by createRef(), but got [${typeof vnode.ref}] instead\n` +
192
- serializeVNode(vnode) +
193
- `\n\n${getOwnerStack(vnode)}`
194
- );
195
- }
196
-
197
- if (typeof vnode.type == 'string') {
198
- for (const key in vnode.props) {
199
- if (
200
- key[0] === 'o' &&
201
- key[1] === 'n' &&
202
- typeof vnode.props[key] != 'function' &&
203
- vnode.props[key] != null
204
- ) {
205
- throw new Error(
206
- `Component's "${key}" property should be a function, ` +
207
- `but got [${typeof vnode.props[key]}] instead\n` +
208
- serializeVNode(vnode) +
209
- `\n\n${getOwnerStack(vnode)}`
210
- );
211
- }
212
- }
213
- }
214
-
215
- // Check prop-types if available
216
- if (typeof vnode.type == 'function' && vnode.type.propTypes) {
217
- if (
218
- vnode.type.displayName === 'Lazy' &&
219
- warnedComponents &&
220
- !warnedComponents.lazyPropTypes.has(vnode.type)
221
- ) {
222
- const m =
223
- 'PropTypes are not supported on lazy(). Use propTypes on the wrapped component itself. ';
224
- try {
225
- const lazyVNode = vnode.type();
226
- warnedComponents.lazyPropTypes.set(vnode.type, true);
227
- console.warn(
228
- m + `Component wrapped in lazy() is ${getDisplayName(lazyVNode)}`
229
- );
230
- } catch (promise) {
231
- console.warn(
232
- m + "We will log the wrapped component's name once it is loaded."
233
- );
234
- }
235
- }
236
-
237
- let values = vnode.props;
238
- if (vnode.type._forwarded) {
239
- values = assign({}, values);
240
- delete values.ref;
241
- }
242
-
243
- checkPropTypes(
244
- vnode.type.propTypes,
245
- values,
246
- 'prop',
247
- getDisplayName(vnode),
248
- () => getOwnerStack(vnode)
249
- );
250
- }
251
-
252
- if (oldBeforeDiff) oldBeforeDiff(vnode);
253
- };
254
-
255
- options._hook = (comp, index, type) => {
256
- if (!comp || !hooksAllowed) {
257
- throw new Error('Hook can only be invoked from render methods.');
258
- }
259
-
260
- if (oldHook) oldHook(comp, index, type);
261
- };
262
-
263
- // Ideally we'd want to print a warning once per component, but we
264
- // don't have access to the vnode that triggered it here. As a
265
- // compromise and to avoid flooding the console with warnings we
266
- // print each deprecation warning only once.
267
- const warn = (property, message) => ({
268
- get() {
269
- const key = 'get' + property + message;
270
- if (deprecations && deprecations.indexOf(key) < 0) {
271
- deprecations.push(key);
272
- console.warn(`getting vnode.${property} is deprecated, ${message}`);
273
- }
274
- },
275
- set() {
276
- const key = 'set' + property + message;
277
- if (deprecations && deprecations.indexOf(key) < 0) {
278
- deprecations.push(key);
279
- console.warn(`setting vnode.${property} is not allowed, ${message}`);
280
- }
281
- }
282
- });
283
-
284
- const deprecatedAttributes = {
285
- nodeName: warn('nodeName', 'use vnode.type'),
286
- attributes: warn('attributes', 'use vnode.props'),
287
- children: warn('children', 'use vnode.props.children')
288
- };
289
-
290
- const deprecatedProto = Object.create({}, deprecatedAttributes);
291
-
292
- options.vnode = vnode => {
293
- const props = vnode.props;
294
- if (
295
- vnode.type !== null &&
296
- props != null &&
297
- ('__source' in props || '__self' in props)
298
- ) {
299
- const newProps = (vnode.props = {});
300
- for (let i in props) {
301
- const v = props[i];
302
- if (i === '__source') vnode.__source = v;
303
- else if (i === '__self') vnode.__self = v;
304
- else newProps[i] = v;
305
- }
306
- }
307
-
308
- // eslint-disable-next-line
309
- vnode.__proto__ = deprecatedProto;
310
- if (oldVnode) oldVnode(vnode);
311
- };
312
-
313
- options.diffed = vnode => {
314
- // Check if the user passed plain objects as children. Note that we cannot
315
- // move this check into `options.vnode` because components can receive
316
- // children in any shape they want (e.g.
317
- // `<MyJSONFormatter>{{ foo: 123, bar: "abc" }}</MyJSONFormatter>`).
318
- // Putting this check in `options.diffed` ensures that
319
- // `vnode._children` is set and that we only validate the children
320
- // that were actually rendered.
321
- if (vnode._children) {
322
- vnode._children.forEach(child => {
323
- if (child && child.type === undefined) {
324
- // Remove internal vnode keys that will always be patched
325
- delete child._parent;
326
- delete child._depth;
327
- const keys = Object.keys(child).join(',');
328
- throw new Error(
329
- `Objects are not valid as a child. Encountered an object with the keys {${keys}}.` +
330
- `\n\n${getOwnerStack(vnode)}`
331
- );
332
- }
333
- });
334
- }
335
-
336
- hooksAllowed = false;
337
-
338
- if (oldDiffed) oldDiffed(vnode);
339
-
340
- if (vnode._children != null) {
341
- const keys = [];
342
- for (let i = 0; i < vnode._children.length; i++) {
343
- const child = vnode._children[i];
344
- if (!child || child.key == null) continue;
345
-
346
- const key = child.key;
347
- if (keys.indexOf(key) !== -1) {
348
- console.error(
349
- 'Following component has two or more children with the ' +
350
- `same key attribute: "${key}". This may cause glitches and misbehavior ` +
351
- 'in rendering process. Component: \n\n' +
352
- serializeVNode(vnode) +
353
- `\n\n${getOwnerStack(vnode)}`
354
- );
355
-
356
- // Break early to not spam the console
357
- break;
358
- }
359
-
360
- keys.push(key);
361
- }
362
- }
363
- };
364
- }
365
-
366
- const setState = Component.prototype.setState;
367
- Component.prototype.setState = function(update, callback) {
368
- if (this._vnode == null) {
369
- // `this._vnode` will be `null` during componentWillMount. But it
370
- // is perfectly valid to call `setState` during cWM. So we
371
- // need an additional check to verify that we are dealing with a
372
- // call inside constructor.
373
- if (this.state == null) {
374
- console.warn(
375
- `Calling "this.setState" inside the constructor of a component is a ` +
376
- `no-op and might be a bug in your application. Instead, set ` +
377
- `"this.state = {}" directly.\n\n${getOwnerStack(getCurrentVNode())}`
378
- );
379
- }
380
- }
381
-
382
- return setState.call(this, update, callback);
383
- };
384
-
385
- const forceUpdate = Component.prototype.forceUpdate;
386
- Component.prototype.forceUpdate = function(callback) {
387
- if (this._vnode == null) {
388
- console.warn(
389
- `Calling "this.forceUpdate" inside the constructor of a component is a ` +
390
- `no-op and might be a bug in your application.\n\n${getOwnerStack(
391
- getCurrentVNode()
392
- )}`
393
- );
394
- } else if (this._parentDom == null) {
395
- console.warn(
396
- `Can't call "this.forceUpdate" on an unmounted component. This is a no-op, ` +
397
- `but it indicates a memory leak in your application. To fix, cancel all ` +
398
- `subscriptions and asynchronous tasks in the componentWillUnmount method.` +
399
- `\n\n${getOwnerStack(this._vnode)}`
400
- );
401
- }
402
- return forceUpdate.call(this, callback);
403
- };
404
-
405
- /**
406
- * Serialize a vnode tree to a string
407
- * @param {import('./internal').VNode} vnode
408
- * @returns {string}
409
- */
410
- export function serializeVNode(vnode) {
411
- let { props } = vnode;
412
- let name = getDisplayName(vnode);
413
-
414
- let attrs = '';
415
- for (let prop in props) {
416
- if (props.hasOwnProperty(prop) && prop !== 'children') {
417
- let value = props[prop];
418
-
419
- // If it is an object but doesn't have toString(), use Object.toString
420
- if (typeof value == 'function') {
421
- value = `function ${value.displayName || value.name}() {}`;
422
- }
423
-
424
- value =
425
- Object(value) === value && !value.toString
426
- ? Object.prototype.toString.call(value)
427
- : value + '';
428
-
429
- attrs += ` ${prop}=${JSON.stringify(value)}`;
430
- }
431
- }
432
-
433
- let children = props.children;
434
- return `<${name}${attrs}${
435
- children && children.length ? '>..</' + name + '>' : ' />'
436
- }`;
437
- }
@@ -1,6 +0,0 @@
1
- import { initDebug } from './debug';
2
- import 'preact/devtools';
3
-
4
- initDebug();
5
-
6
- export { resetPropWarnings } from './check-props';
@@ -1,82 +0,0 @@
1
- import { Component, PreactElement, VNode, Options } from '../../src/internal';
2
-
3
- export { Component, PreactElement, VNode, Options };
4
-
5
- export interface DevtoolsInjectOptions {
6
- /** 1 = DEV, 0 = production */
7
- bundleType: 1 | 0;
8
- /** The devtools enable different features for different versions of react */
9
- version: string;
10
- /** Informative string, currently unused in the devtools */
11
- rendererPackageName: string;
12
- /** Find the root dom node of a vnode */
13
- findHostInstanceByFiber(vnode: VNode): HTMLElement | null;
14
- /** Find the closest vnode given a dom node */
15
- findFiberByHostInstance(instance: HTMLElement): VNode | null;
16
- }
17
-
18
- export interface DevtoolsUpdater {
19
- setState(objOrFn: any): void;
20
- forceUpdate(): void;
21
- setInState(path: Array<string | number>, value: any): void;
22
- setInProps(path: Array<string | number>, value: any): void;
23
- setInContext(): void;
24
- }
25
-
26
- export type NodeType = 'Composite' | 'Native' | 'Wrapper' | 'Text';
27
-
28
- export interface DevtoolData {
29
- nodeType: NodeType;
30
- // Component type
31
- type: any;
32
- name: string;
33
- ref: any;
34
- key: string | number;
35
- updater: DevtoolsUpdater | null;
36
- text: string | number | null;
37
- state: any;
38
- props: any;
39
- children: VNode[] | string | number | null;
40
- publicInstance: PreactElement | Text | Component;
41
- memoizedInteractions: any[];
42
-
43
- actualDuration: number;
44
- actualStartTime: number;
45
- treeBaseDuration: number;
46
- }
47
-
48
- export type EventType =
49
- | 'unmount'
50
- | 'rootCommitted'
51
- | 'root'
52
- | 'mount'
53
- | 'update'
54
- | 'updateProfileTimes';
55
-
56
- export interface DevtoolsEvent {
57
- data?: DevtoolData;
58
- internalInstance: VNode;
59
- renderer: string;
60
- type: EventType;
61
- }
62
-
63
- export interface DevtoolsHook {
64
- _renderers: Record<string, any>;
65
- _roots: Set<VNode>;
66
- on(ev: string, listener: () => void): void;
67
- emit(ev: string, data?: object): void;
68
- helpers: Record<string, any>;
69
- getFiberRoots(rendererId: string): Set<any>;
70
- inject(config: DevtoolsInjectOptions): string;
71
- onCommitFiberRoot(rendererId: string, root: VNode): void;
72
- onCommitFiberUnmount(rendererId: string, vnode: VNode): void;
73
- }
74
-
75
- export interface DevtoolsWindow extends Window {
76
- /**
77
- * If the devtools extension is installed it will inject this object into
78
- * the dom. This hook handles all communications between preact and the
79
- * devtools panel.
80
- */
81
- __REACT_DEVTOOLS_GLOBAL_HOOK__?: DevtoolsHook;
82
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Assign properties from `props` to `obj`
3
- * @template O, P The obj and props types
4
- * @param {O} obj The object to copy properties to
5
- * @param {P} props The object to copy properties from
6
- * @returns {O & P}
7
- */
8
- export function assign(obj, props) {
9
- for (let i in props) obj[i] = props[i];
10
- return /** @type {O & P} */ (obj);
11
- }
@@ -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.
@@ -1,2 +0,0 @@
1
- var n=require("preact");"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.9.0",n.options,{Fragment:n.Fragment,Component:n.Component}),exports.addHookName=function(e,o){return n.options.__a&&n.options.__a(o),e};
2
- //# sourceMappingURL=devtools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtools.js","sources":["../src/devtools.js","../src/index.js"],"sourcesContent":["import { options, Fragment, Component } from 'preact';\n\nexport function initDevTools() {\n\tif (typeof window != 'undefined' && window.__PREACT_DEVTOOLS__) {\n\t\twindow.__PREACT_DEVTOOLS__.attachPreact('10.9.0', options, {\n\t\t\tFragment,\n\t\t\tComponent\n\t\t});\n\t}\n}\n","import { options } from 'preact';\nimport { initDevTools } from './devtools';\n\ninitDevTools();\n\n/**\n * Display a custom label for a custom hook for the devtools panel\n * @type {<T>(value: T, name: string) => T}\n */\nexport function addHookName(value, name) {\n\tif (options._addHookName) {\n\t\toptions._addHookName(name);\n\t}\n\treturn value;\n}\n"],"names":["window","__PREACT_DEVTOOLS__","attachPreact","options","Fragment","Component","value","name"],"mappings":"wBAGsB,oBAAVA,QAAyBA,OAAOC,qBAC1CD,OAAOC,oBAAoBC,aAAa,SAAUC,UAAS,CAC1DC,SAAAA,WACAC,UAAAA,kCCGI,SAAqBC,EAAOC,UAC9BJ,eACHA,cAAqBI,GAEfD"}
@@ -1,2 +0,0 @@
1
- import{options as n,Fragment as o,Component as e}from"preact";function t(o,e){return n.__a&&n.__a(e),o}"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.9.0",n,{Fragment:o,Component:e});export{t as addHookName};
2
- //# sourceMappingURL=devtools.module.js.map
@@ -1,2 +0,0 @@
1
- import{options as n,Fragment as o,Component as e}from"preact";function t(o,e){return n.__a&&n.__a(e),o}"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.9.0",n,{Fragment:o,Component:e});export{t as addHookName};
2
- //# sourceMappingURL=devtools.module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtools.module.js","sources":["../src/index.js","../src/devtools.js"],"sourcesContent":["import { options } from 'preact';\nimport { initDevTools } from './devtools';\n\ninitDevTools();\n\n/**\n * Display a custom label for a custom hook for the devtools panel\n * @type {<T>(value: T, name: string) => T}\n */\nexport function addHookName(value, name) {\n\tif (options._addHookName) {\n\t\toptions._addHookName(name);\n\t}\n\treturn value;\n}\n","import { options, Fragment, Component } from 'preact';\n\nexport function initDevTools() {\n\tif (typeof window != 'undefined' && window.__PREACT_DEVTOOLS__) {\n\t\twindow.__PREACT_DEVTOOLS__.attachPreact('10.9.0', options, {\n\t\t\tFragment,\n\t\t\tComponent\n\t\t});\n\t}\n}\n"],"names":["addHookName","value","name","options","window","__PREACT_DEVTOOLS__","attachPreact","Fragment","Component"],"mappings":"8DASO,SAASA,EAAYC,EAAOC,UAC9BC,OACHA,MAAqBD,GAEfD,ECVc,oBAAVG,QAAyBA,OAAOC,qBAC1CD,OAAOC,oBAAoBC,aAAa,SAAUH,EAAS,CAC1DI,SAAAA,EACAC,UAAAA"}
@@ -1,2 +0,0 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],n):n(e.preactDevtools={},e.preact)}(this,function(e,n){"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.9.0",n.options,{Fragment:n.Fragment,Component:n.Component}),e.addHookName=function(e,o){return n.options.__a&&n.options.__a(o),e}});
2
- //# sourceMappingURL=devtools.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtools.umd.js","sources":["../src/devtools.js","../src/index.js"],"sourcesContent":["import { options, Fragment, Component } from 'preact';\n\nexport function initDevTools() {\n\tif (typeof window != 'undefined' && window.__PREACT_DEVTOOLS__) {\n\t\twindow.__PREACT_DEVTOOLS__.attachPreact('10.9.0', options, {\n\t\t\tFragment,\n\t\t\tComponent\n\t\t});\n\t}\n}\n","import { options } from 'preact';\nimport { initDevTools } from './devtools';\n\ninitDevTools();\n\n/**\n * Display a custom label for a custom hook for the devtools panel\n * @type {<T>(value: T, name: string) => T}\n */\nexport function addHookName(value, name) {\n\tif (options._addHookName) {\n\t\toptions._addHookName(name);\n\t}\n\treturn value;\n}\n"],"names":["window","__PREACT_DEVTOOLS__","attachPreact","options","Fragment","Component","value","name"],"mappings":"0NAGsB,oBAAVA,QAAyBA,OAAOC,qBAC1CD,OAAOC,oBAAoBC,aAAa,SAAUC,UAAS,CAC1DC,SAAAA,WACAC,UAAAA,4BCGI,SAAqBC,EAAOC,UAC9BJ,eACHA,cAAqBI,GAEfD"}
@@ -1,25 +0,0 @@
1
- {
2
- "name": "preact-devtools",
3
- "amdName": "preactDevtools",
4
- "version": "1.0.0",
5
- "private": true,
6
- "description": "Preact bridge for Preact devtools",
7
- "main": "dist/devtools.js",
8
- "module": "dist/devtools.module.js",
9
- "umd:main": "dist/devtools.umd.js",
10
- "source": "src/index.js",
11
- "license": "MIT",
12
- "types": "src/index.d.ts",
13
- "peerDependencies": {
14
- "preact": "^10.0.0"
15
- },
16
- "exports": {
17
- ".": {
18
- "types": "./src/index.d.ts",
19
- "browser": "./dist/devtools.module.js",
20
- "umd": "./dist/devtools.umd.js",
21
- "import": "./dist/devtools.mjs",
22
- "require": "./dist/devtools.js"
23
- }
24
- }
25
- }
@@ -1,10 +0,0 @@
1
- import { options, Fragment, Component } from 'preact';
2
-
3
- export function initDevTools() {
4
- if (typeof window != 'undefined' && window.__PREACT_DEVTOOLS__) {
5
- window.__PREACT_DEVTOOLS__.attachPreact('10.9.0', options, {
6
- Fragment,
7
- Component
8
- });
9
- }
10
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Customize the displayed name of a useState, useReducer or useRef hook
3
- * in the devtools panel.
4
- *
5
- * @param value Wrapped native hook.
6
- * @param name Custom name
7
- */
8
- export function addHookName<T>(value: T, name: string): T;
@@ -1,15 +0,0 @@
1
- import { options } from 'preact';
2
- import { initDevTools } from './devtools';
3
-
4
- initDevTools();
5
-
6
- /**
7
- * Display a custom label for a custom hook for the devtools panel
8
- * @type {<T>(value: T, name: string) => T}
9
- */
10
- export function addHookName(value, name) {
11
- if (options._addHookName) {
12
- options._addHookName(name);
13
- }
14
- return value;
15
- }