@faiwer/react 0.8.4 → 19.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/README.md +43 -21
  2. package/dist/core/actions/applyAction.d.ts.map +1 -1
  3. package/dist/core/actions/applyAction.js +6 -0
  4. package/dist/core/actions/applyAction.js.map +1 -1
  5. package/dist/core/actions/catchError.action.d.ts +10 -0
  6. package/dist/core/actions/catchError.action.d.ts.map +1 -0
  7. package/dist/core/actions/catchError.action.js +51 -0
  8. package/dist/core/actions/catchError.action.js.map +1 -0
  9. package/dist/core/actions/createComment.action.d.ts +2 -2
  10. package/dist/core/actions/createComment.action.d.ts.map +1 -1
  11. package/dist/core/actions/createComment.action.js +1 -8
  12. package/dist/core/actions/createComment.action.js.map +1 -1
  13. package/dist/core/actions/createContainer.action.d.ts +7 -0
  14. package/dist/core/actions/createContainer.action.d.ts.map +1 -0
  15. package/dist/core/actions/createContainer.action.js +28 -0
  16. package/dist/core/actions/createContainer.action.js.map +1 -0
  17. package/dist/core/actions/createTag.action.d.ts +2 -1
  18. package/dist/core/actions/createTag.action.d.ts.map +1 -1
  19. package/dist/core/actions/createTag.action.js +22 -4
  20. package/dist/core/actions/createTag.action.js.map +1 -1
  21. package/dist/core/actions/createText.action.d.ts.map +1 -1
  22. package/dist/core/actions/createText.action.js +2 -5
  23. package/dist/core/actions/createText.action.js.map +1 -1
  24. package/dist/core/actions/dom/attributes.d.ts.map +1 -1
  25. package/dist/core/actions/dom/attributes.js +4 -1
  26. package/dist/core/actions/dom/attributes.js.map +1 -1
  27. package/dist/core/actions/dom/css.d.ts.map +1 -1
  28. package/dist/core/actions/dom/css.js +2 -1
  29. package/dist/core/actions/dom/css.js.map +1 -1
  30. package/dist/core/actions/dom/events.d.ts.map +1 -1
  31. package/dist/core/actions/dom/events.js +15 -3
  32. package/dist/core/actions/dom/events.js.map +1 -1
  33. package/dist/core/actions/dom/value.d.ts +18 -0
  34. package/dist/core/actions/dom/value.d.ts.map +1 -0
  35. package/dist/core/actions/dom/value.js +211 -0
  36. package/dist/core/actions/dom/value.js.map +1 -0
  37. package/dist/core/actions/helpers.d.ts +17 -10
  38. package/dist/core/actions/helpers.d.ts.map +1 -1
  39. package/dist/core/actions/helpers.js +64 -70
  40. package/dist/core/actions/helpers.js.map +1 -1
  41. package/dist/core/actions/relayout.action.d.ts +2 -1
  42. package/dist/core/actions/relayout.action.d.ts.map +1 -1
  43. package/dist/core/actions/relayout.action.js +119 -30
  44. package/dist/core/actions/relayout.action.js.map +1 -1
  45. package/dist/core/actions/remove.action.d.ts +2 -2
  46. package/dist/core/actions/remove.action.d.ts.map +1 -1
  47. package/dist/core/actions/remove.action.js +20 -17
  48. package/dist/core/actions/remove.action.js.map +1 -1
  49. package/dist/core/actions/replace.action.d.ts +1 -1
  50. package/dist/core/actions/replace.action.d.ts.map +1 -1
  51. package/dist/core/actions/replace.action.js +34 -23
  52. package/dist/core/actions/replace.action.js.map +1 -1
  53. package/dist/core/actions/scheduleEffect.action.d.ts +7 -0
  54. package/dist/core/actions/scheduleEffect.action.d.ts.map +1 -0
  55. package/dist/core/actions/scheduleEffect.action.js +8 -0
  56. package/dist/core/actions/scheduleEffect.action.js.map +1 -0
  57. package/dist/core/actions/setAttr.action.d.ts +1 -1
  58. package/dist/core/actions/setAttr.action.d.ts.map +1 -1
  59. package/dist/core/actions/setAttr.action.js +47 -6
  60. package/dist/core/actions/setAttr.action.js.map +1 -1
  61. package/dist/core/actions/setProps.action.d.ts.map +1 -1
  62. package/dist/core/actions/setProps.action.js +2 -1
  63. package/dist/core/actions/setProps.action.js.map +1 -1
  64. package/dist/core/actions/setRef.action.d.ts +1 -1
  65. package/dist/core/actions/setRef.action.d.ts.map +1 -1
  66. package/dist/core/actions/setRef.action.js +5 -6
  67. package/dist/core/actions/setRef.action.js.map +1 -1
  68. package/dist/core/actions/setText.action.d.ts.map +1 -1
  69. package/dist/core/actions/setText.action.js +3 -3
  70. package/dist/core/actions/setText.action.js.map +1 -1
  71. package/dist/core/classComponent.d.ts +2 -1
  72. package/dist/core/classComponent.d.ts.map +1 -1
  73. package/dist/core/classComponent.js +20 -12
  74. package/dist/core/classComponent.js.map +1 -1
  75. package/dist/core/compact.d.ts +10 -29
  76. package/dist/core/compact.d.ts.map +1 -1
  77. package/dist/core/compact.js +12 -100
  78. package/dist/core/compact.js.map +1 -1
  79. package/dist/core/components.d.ts +6 -4
  80. package/dist/core/components.d.ts.map +1 -1
  81. package/dist/core/components.js +26 -8
  82. package/dist/core/components.js.map +1 -1
  83. package/dist/core/createElement.d.ts +2 -8
  84. package/dist/core/createElement.d.ts.map +1 -1
  85. package/dist/core/createElement.js +3 -1
  86. package/dist/core/createElement.js.map +1 -1
  87. package/dist/core/reactNodeToFiberNode.d.ts +3 -1
  88. package/dist/core/reactNodeToFiberNode.d.ts.map +1 -1
  89. package/dist/core/reactNodeToFiberNode.js +80 -17
  90. package/dist/core/reactNodeToFiberNode.js.map +1 -1
  91. package/dist/core/reconciliation/app.js +3 -3
  92. package/dist/core/reconciliation/app.js.map +1 -1
  93. package/dist/core/reconciliation/collect/fromApp.d.ts +2 -1
  94. package/dist/core/reconciliation/collect/fromApp.d.ts.map +1 -1
  95. package/dist/core/reconciliation/collect/fromApp.js +7 -26
  96. package/dist/core/reconciliation/collect/fromApp.js.map +1 -1
  97. package/dist/core/reconciliation/collect/fromChildrenPair.d.ts +2 -1
  98. package/dist/core/reconciliation/collect/fromChildrenPair.d.ts.map +1 -1
  99. package/dist/core/reconciliation/collect/fromChildrenPair.js +37 -10
  100. package/dist/core/reconciliation/collect/fromChildrenPair.js.map +1 -1
  101. package/dist/core/reconciliation/collect/fromComponent.d.ts +3 -2
  102. package/dist/core/reconciliation/collect/fromComponent.d.ts.map +1 -1
  103. package/dist/core/reconciliation/collect/fromComponent.js +27 -9
  104. package/dist/core/reconciliation/collect/fromComponent.js.map +1 -1
  105. package/dist/core/reconciliation/collect/fromFiberPair.d.ts +2 -1
  106. package/dist/core/reconciliation/collect/fromFiberPair.d.ts.map +1 -1
  107. package/dist/core/reconciliation/collect/fromFiberPair.js +8 -5
  108. package/dist/core/reconciliation/collect/fromFiberPair.js.map +1 -1
  109. package/dist/core/reconciliation/collect/fromNewFiber.d.ts.map +1 -1
  110. package/dist/core/reconciliation/collect/fromNewFiber.js +7 -15
  111. package/dist/core/reconciliation/collect/fromNewFiber.js.map +1 -1
  112. package/dist/core/reconciliation/effects.d.ts +2 -2
  113. package/dist/core/reconciliation/effects.d.ts.map +1 -1
  114. package/dist/core/reconciliation/effects.js +52 -4
  115. package/dist/core/reconciliation/effects.js.map +1 -1
  116. package/dist/core/reconciliation/errors/ReactError.d.ts +15 -0
  117. package/dist/core/reconciliation/errors/ReactError.d.ts.map +1 -0
  118. package/dist/core/reconciliation/errors/ReactError.js +56 -0
  119. package/dist/core/reconciliation/errors/ReactError.js.map +1 -0
  120. package/dist/core/reconciliation/errors/stack.d.ts +8 -2
  121. package/dist/core/reconciliation/errors/stack.d.ts.map +1 -1
  122. package/dist/core/reconciliation/errors/stack.js +65 -8
  123. package/dist/core/reconciliation/errors/stack.js.map +1 -1
  124. package/dist/core/reconciliation/fibers.d.ts +1 -0
  125. package/dist/core/reconciliation/fibers.d.ts.map +1 -1
  126. package/dist/core/reconciliation/fibers.js +3 -2
  127. package/dist/core/reconciliation/fibers.js.map +1 -1
  128. package/dist/core/reconciliation/heap.d.ts +18 -0
  129. package/dist/core/reconciliation/heap.d.ts.map +1 -0
  130. package/dist/core/reconciliation/heap.js +81 -0
  131. package/dist/core/reconciliation/heap.js.map +1 -0
  132. package/dist/core/reconciliation/invalidateFiber.d.ts.map +1 -1
  133. package/dist/core/reconciliation/invalidateFiber.js +6 -5
  134. package/dist/core/reconciliation/invalidateFiber.js.map +1 -1
  135. package/dist/core/reconciliation/mount.d.ts.map +1 -1
  136. package/dist/core/reconciliation/mount.js +24 -6
  137. package/dist/core/reconciliation/mount.js.map +1 -1
  138. package/dist/core/reconciliation/postCommit.d.ts +1 -1
  139. package/dist/core/reconciliation/postCommit.d.ts.map +1 -1
  140. package/dist/core/reconciliation/postCommit.js +17 -4
  141. package/dist/core/reconciliation/postCommit.js.map +1 -1
  142. package/dist/core/reconciliation/queue.d.ts +21 -0
  143. package/dist/core/reconciliation/queue.d.ts.map +1 -0
  144. package/dist/core/reconciliation/queue.js +55 -0
  145. package/dist/core/reconciliation/queue.js.map +1 -0
  146. package/dist/core/reconciliation/render.d.ts.map +1 -1
  147. package/dist/core/reconciliation/render.js +9 -3
  148. package/dist/core/reconciliation/render.js.map +1 -1
  149. package/dist/core/reconciliation/runFiberComponents.d.ts +3 -1
  150. package/dist/core/reconciliation/runFiberComponents.d.ts.map +1 -1
  151. package/dist/core/reconciliation/runFiberComponents.js +33 -5
  152. package/dist/core/reconciliation/runFiberComponents.js.map +1 -1
  153. package/dist/core/reconciliation/typeGuards.d.ts +3 -0
  154. package/dist/core/reconciliation/typeGuards.d.ts.map +1 -1
  155. package/dist/core/reconciliation/typeGuards.js +13 -0
  156. package/dist/core/reconciliation/typeGuards.js.map +1 -1
  157. package/dist/core/reconciliation/validateApp.d.ts +1 -1
  158. package/dist/core/reconciliation/validateApp.d.ts.map +1 -1
  159. package/dist/core/reconciliation/validateApp.js +28 -21
  160. package/dist/core/reconciliation/validateApp.js.map +1 -1
  161. package/dist/hooks/helpers.d.ts +3 -3
  162. package/dist/hooks/helpers.d.ts.map +1 -1
  163. package/dist/hooks/helpers.js +3 -2
  164. package/dist/hooks/helpers.js.map +1 -1
  165. package/dist/hooks/index.d.ts +2 -1
  166. package/dist/hooks/index.d.ts.map +1 -1
  167. package/dist/hooks/index.js +2 -1
  168. package/dist/hooks/index.js.map +1 -1
  169. package/dist/hooks/useContext.d.ts.map +1 -1
  170. package/dist/hooks/useContext.js +6 -6
  171. package/dist/hooks/useContext.js.map +1 -1
  172. package/dist/hooks/useEffect.d.ts +2 -1
  173. package/dist/hooks/useEffect.d.ts.map +1 -1
  174. package/dist/hooks/useEffect.js +21 -7
  175. package/dist/hooks/useEffect.js.map +1 -1
  176. package/dist/hooks/useError.d.ts +5 -0
  177. package/dist/hooks/useError.d.ts.map +1 -0
  178. package/dist/hooks/useError.js +19 -0
  179. package/dist/hooks/useError.js.map +1 -0
  180. package/dist/hooks/useReducer.d.ts +7 -0
  181. package/dist/hooks/useReducer.d.ts.map +1 -0
  182. package/dist/hooks/useReducer.js +10 -0
  183. package/dist/hooks/useReducer.js.map +1 -0
  184. package/dist/hooks/useRef.d.ts +8 -3
  185. package/dist/hooks/useRef.d.ts.map +1 -1
  186. package/dist/hooks/useRef.js +27 -0
  187. package/dist/hooks/useRef.js.map +1 -1
  188. package/dist/hooks/useState.d.ts +1 -1
  189. package/dist/hooks/useState.d.ts.map +1 -1
  190. package/dist/hooks/useState.js +3 -6
  191. package/dist/hooks/useState.js.map +1 -1
  192. package/dist/index.d.ts +3 -0
  193. package/dist/index.d.ts.map +1 -1
  194. package/dist/index.js +1 -0
  195. package/dist/index.js.map +1 -1
  196. package/dist/jsx.d.ts +159 -44
  197. package/dist/mocks.d.ts +0 -7
  198. package/dist/mocks.d.ts.map +1 -1
  199. package/dist/mocks.js +0 -6
  200. package/dist/mocks.js.map +1 -1
  201. package/dist/react.d.ts +46 -0
  202. package/dist/types/actions.d.ts +23 -5
  203. package/dist/types/actions.d.ts.map +1 -1
  204. package/dist/types/app.d.ts +17 -3
  205. package/dist/types/app.d.ts.map +1 -1
  206. package/dist/types/attributes.d.ts +42 -0
  207. package/dist/types/attributes.d.ts.map +1 -0
  208. package/dist/types/attributes.js +2 -0
  209. package/dist/types/attributes.js.map +1 -0
  210. package/dist/types/common.d.ts +10 -1
  211. package/dist/types/common.d.ts.map +1 -1
  212. package/dist/types/component.d.ts +11 -2
  213. package/dist/types/component.d.ts.map +1 -1
  214. package/dist/types/context.d.ts +3 -2
  215. package/dist/types/context.d.ts.map +1 -1
  216. package/dist/types/core.d.ts +17 -13
  217. package/dist/types/core.d.ts.map +1 -1
  218. package/dist/types/dom.d.ts +23 -22
  219. package/dist/types/dom.d.ts.map +1 -1
  220. package/dist/types/events.d.ts +18 -11
  221. package/dist/types/events.d.ts.map +1 -1
  222. package/dist/types/fiber.d.ts +30 -12
  223. package/dist/types/fiber.d.ts.map +1 -1
  224. package/dist/types/fiber.js +5 -1
  225. package/dist/types/fiber.js.map +1 -1
  226. package/dist/types/hooks.d.ts +16 -6
  227. package/dist/types/hooks.d.ts.map +1 -1
  228. package/dist/types/react.d.ts +31 -0
  229. package/dist/types/react.d.ts.map +1 -0
  230. package/dist/types/react.js +2 -0
  231. package/dist/types/react.js.map +1 -0
  232. package/dist/types/refs.d.ts +5 -8
  233. package/dist/types/refs.d.ts.map +1 -1
  234. package/package.json +11 -3
@@ -1,7 +1,6 @@
1
- import { nullthrows } from '../../utils';
2
1
  import { unsetRef } from './helpers';
3
2
  import { scheduleEffect } from '../reconciliation/effects';
4
- import { getAppByFiber } from '../reconciliation/app';
3
+ import { nullthrowsForFiber, ReactError, } from '../reconciliation/errors/ReactError';
5
4
  /**
6
5
  * A ref or ref handler for the given node was:
7
6
  * - set up
@@ -11,7 +10,7 @@ import { getAppByFiber } from '../reconciliation/app';
11
10
  */
12
11
  export function setRefAction(fiber, { ref, dontUnsetRef }) {
13
12
  if (fiber.type !== 'tag') {
14
- throw new Error(`setRefAction is not compatible with ${fiber.type} nodes`);
13
+ throw new ReactError(fiber, `setRefAction is not compatible with ${fiber.type} nodes`);
15
14
  }
16
15
  if (fiber.ref &&
17
16
  // It's `true` on the first render of the tag. We shouldn't run `onRef(null)`
@@ -20,8 +19,8 @@ export function setRefAction(fiber, { ref, dontUnsetRef }) {
20
19
  unsetRef(fiber, false);
21
20
  }
22
21
  // Run effects only when the DOM node is already mounted to a real DOM node.
23
- scheduleEffect(getAppByFiber(fiber), () => {
24
- const element = nullthrows(fiber.element);
22
+ scheduleEffect(fiber, () => {
23
+ const element = nullthrowsForFiber(fiber, fiber.element);
25
24
  if (typeof ref === 'function') {
26
25
  ref(element);
27
26
  }
@@ -30,7 +29,7 @@ export function setRefAction(fiber, { ref, dontUnsetRef }) {
30
29
  }
31
30
  },
32
31
  // React calls ref handlers even before it runs layout effects.
33
- 'refs');
32
+ 'refsMount');
34
33
  fiber.ref = ref;
35
34
  return;
36
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setRef.action.js","sourceRoot":"","sources":["../../../src/core/actions/setRef.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAgB,EAChB,EAAE,GAAG,EAAE,YAAY,EAAgB,EACnC;IACA,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,uCAAuC,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC;IAC7E,CAAC;IAED,IACE,KAAK,CAAC,GAAG;QACT,6EAA6E;QAC7E,kBAAkB;QAClB,CAAC,YAAY,EACb,CAAC;QACD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,4EAA4E;IAC5E,cAAc,CACZ,aAAa,CAAC,KAAK,CAAC,EACpB,GAAG,EAAE,CAAC;QACJ,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAgB,CAAC;QACzD,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;YAC9B,GAAG,CAAC,OAAO,CAAC,CAAC;QACf,CAAC;aAAM,IAAI,GAAG,EAAE,CAAC;YACf,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACxB,CAAC;IAAA,CACF;IACD,+DAA+D;IAC/D,MAAM,CACP,CAAC;IAEF,KAAK,CAAC,GAAG,GAAG,GAAuB,CAAC;IACpC,OAAO;AAAA,CACR"}
1
+ {"version":3,"file":"setRef.action.js","sourceRoot":"","sources":["../../../src/core/actions/setRef.action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAClB,UAAU,GACX,MAAM,qCAAqC,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAgB,EAChB,EAAE,GAAG,EAAE,YAAY,EAA8C,EACjE;IACA,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,UAAU,CAClB,KAAK,EACL,uCAAuC,KAAK,CAAC,IAAI,QAAQ,CAC1D,CAAC;IACJ,CAAC;IAED,IACE,KAAK,CAAC,GAAG;QACT,6EAA6E;QAC7E,kBAAkB;QAClB,CAAC,YAAY,EACb,CAAC;QACD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,4EAA4E;IAC5E,cAAc,CACZ,KAAK,EACL,GAAG,EAAE,CAAC;QACJ,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAgB,CAAC;QACxE,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;YAC9B,GAAG,CAAC,OAAO,CAAC,CAAC;QACf,CAAC;aAAM,IAAI,GAAG,EAAE,CAAC;YACf,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACxB,CAAC;IAAA,CACF;IACD,+DAA+D;IAC/D,WAAW,CACZ,CAAC;IAEF,KAAK,CAAC,GAAG,GAAG,GAAuB,CAAC;IACpC,OAAO;AAAA,CACR"}
@@ -1 +1 @@
1
- {"version":3,"file":"setText.action.d.ts","sourceRoot":"","sources":["../../../src/core/actions/setText.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAGhE;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,EAAE,aAAa,QAMtE"}
1
+ {"version":3,"file":"setText.action.d.ts","sourceRoot":"","sources":["../../../src/core/actions/setText.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAMhE;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,EAAE,aAAa,QAMtE"}
@@ -1,12 +1,12 @@
1
- import { nullthrows } from '../../utils';
1
+ import { nullthrowsForFiber, ReactError, } from '../reconciliation/errors/ReactError';
2
2
  /**
3
3
  * Replaces the text content within a Text DOM node.
4
4
  */
5
5
  export function setTextAction(fiber, { text }) {
6
6
  if (fiber.type !== 'text') {
7
- throw new Error(`Can't apply setText action to non-text node`);
7
+ throw new ReactError(fiber, `Can't apply setText action to non-text node`);
8
8
  }
9
9
  fiber.props = { text };
10
- nullthrows(fiber.element).textContent = text;
10
+ nullthrowsForFiber(fiber, fiber.element).textContent = text;
11
11
  }
12
12
  //# sourceMappingURL=setText.action.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setText.action.js","sourceRoot":"","sources":["../../../src/core/actions/setText.action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAgB,EAAE,EAAE,IAAI,EAAiB,EAAE;IACvE,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IACD,KAAK,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC;IACvB,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC;AAAA,CAC9C"}
1
+ {"version":3,"file":"setText.action.js","sourceRoot":"","sources":["../../../src/core/actions/setText.action.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAClB,UAAU,GACX,MAAM,qCAAqC,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAgB,EAAE,EAAE,IAAI,EAAiB,EAAE;IACvE,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,UAAU,CAAC,KAAK,EAAE,6CAA6C,CAAC,CAAC;IAC7E,CAAC;IACD,KAAK,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC;IACvB,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC;AAAA,CAC7D"}
@@ -11,6 +11,8 @@ export declare class Component<Props extends UnknownProps = UnknownProps, State
11
11
  context: unknown;
12
12
  static defaultProps?: object;
13
13
  static contextType?: ReactContext<any>;
14
+ static getDerivedStateFromError?: (error: unknown) => object;
15
+ static getDerivedStateFromProps?: (_props: any, _state: any) => object;
14
16
  constructor(props: Props);
15
17
  setState(_update: Partial<State>): void;
16
18
  componentDidMount(): void;
@@ -21,7 +23,6 @@ export declare class Component<Props extends UnknownProps = UnknownProps, State
21
23
  render(): JSX.Element;
22
24
  componentDidCatch(_error: unknown, _info: unknown): void;
23
25
  getSnapshotBeforeUpdate(_prevProps: unknown, _prevState: unknown): unknown;
24
- static getDerivedStateFromProps(_props: any, _state: any): Partial<any>;
25
26
  }
26
27
  /**
27
28
  * Since I'm too lazy to implement a proper support for this legacy stuff, but
@@ -1 +1 @@
1
- {"version":3,"file":"classComponent.d.ts","sour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ACjB,UAAU,EAAE,KAAK,EACjB,YAAY,CAAC,EAAE,OAAO,WAGvB;IAED,MAAM,IAAI,GAAG,CAAC,OAAO,CAKpB;IAED,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAG;IAE3D,uBAAuB,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAEzE;CACF;AAWD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GACpC,KAAK,uBACL,KAAK,uGA4GN,CAAC;AAEF,MAAM,MAAM,cAAc,CACxB,KAAK,SAAS,YAAY,GAAG,YAAY,EACzC,KAAK,SAAS,YAAY,GAAG,YAAY,IACvC,KAAK,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import { useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, } from '../hooks';
2
2
  import { getCurrentComponentFiber } from './components';
3
+ import { ReactError } from './reconciliation/errors/ReactError';
4
+ import { useError } from '../hooks/useError';
3
5
  export const isComponentClass = (value) => {
4
6
  return (value != null &&
5
7
  typeof value === 'function' &&
@@ -17,6 +19,8 @@ export class Component {
17
19
  context;
18
20
  static defaultProps;
19
21
  static contextType;
22
+ static getDerivedStateFromError;
23
+ static getDerivedStateFromProps;
20
24
  constructor(props) {
21
25
  this.props = props;
22
26
  }
@@ -36,18 +40,14 @@ export class Component {
36
40
  return true;
37
41
  }
38
42
  render() {
39
- throw new Error(`Render method must be overridden`);
40
- }
41
- componentDidCatch(_error, _info) {
42
- throw new Error(`Not implemented`);
43
+ throw new ReactError(getCurrentComponentFiber(), `Render method must be overridden`);
43
44
  }
45
+ componentDidCatch(_error, _info) { }
44
46
  getSnapshotBeforeUpdate(_prevProps, _prevState) {
45
- throw new Error(`Not implemented`);
46
- }
47
- static getDerivedStateFromProps(_props, _state) {
48
- return {};
47
+ throw new ReactError(getCurrentComponentFiber(), `Not implemented`);
49
48
  }
50
49
  }
50
+ const ComponentPrototype = Component.prototype;
51
51
  /**
52
52
  * Since we're running `convertClassComponentToFC` for the same component each
53
53
  * time its JSX.Element was created we need to cache the output wrapper
@@ -63,11 +63,10 @@ export const convertClassComponentToFC = (Component) => {
63
63
  if (cache.has(Component)) {
64
64
  return cache.get(Component);
65
65
  }
66
- let { defaultProps, contextType, getDerivedStateFromProps } = Component;
67
- if (getDerivedStateFromProps === Component.prototype.getDerivedStateFromProps) {
68
- getDerivedStateFromProps = undefined;
69
- }
66
+ let { defaultProps, contextType, getDerivedStateFromProps, getDerivedStateFromError, } = Component;
70
67
  function FromClassComponent(props) {
68
+ // Use the component class name as the component name to simplify debugging.
69
+ FromClassComponent.displayName = Component.name;
71
70
  const { current: ref } = useRef({
72
71
  mounted: false,
73
72
  rendered: 0,
@@ -114,6 +113,15 @@ export const convertClassComponentToFC = (Component) => {
114
113
  ...props,
115
114
  };
116
115
  instance.state = state;
116
+ if (instance.componentDidCatch !== ComponentPrototype.componentDidCatch ||
117
+ getDerivedStateFromError) {
118
+ useError((error, info) => {
119
+ instance.componentDidCatch(error, info);
120
+ if (getDerivedStateFromError) {
121
+ setState(getDerivedStateFromError(error));
122
+ }
123
+ });
124
+ }
117
125
  if (!ref.mounted || instance.shouldComponentUpdate(props, instance.state)) {
118
126
  ref.prevOutput = instance.render();
119
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"classComponent.js","sourceRoot":"","sources":["../../src/core/classComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAA2B,EAAE,CAAC;IAC3E,OAAO,CACL,KAAK,IAAI,IAAI;QACb,OAAO,KAAK,KAAK,U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,CAAC,UAAU,CAAC;IAAA,CACvB;IAED,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,kBAAyB,CAAC,CAAC;IAChD,OAAO,kBAAkB,CAAC;AAAA,CAC3B,CAAC"}
@@ -1,38 +1,19 @@
1
- import { type DomNode, type FiberNode } from '../types';
2
- /**
3
- * Returns true if domNode is <!--r:begin:ID--> where ID is fiber.id
4
- */
5
- export declare const isBeginOf: (domNode: ChildNode, fiber: FiberNode) => domNode is Comment;
1
+ import { containerSym, type DomNode, type FiberNode } from '../types';
2
+ export declare const isAutoContainer: (fiber: FiberNode) => fiber is FiberNode & {
3
+ element: typeof containerSym;
4
+ };
6
5
  /**
7
- * Returns true if the given `fiber` is in solo compact mode. This means it
8
- * doesn't have its own direct DOM element. Instead, its `element` refers to its
9
- * only child's `element`, avoiding the need for <!--brackets-->.
6
+ * Returns true if the given `fiber` is in the single-child mode. This means it
7
+ * its `element` refers to its only child's DOM element.
10
8
  */
11
- export declare const isCompactSingleChild: (fiber: FiberNode) => fiber is FiberNode & {
9
+ export declare const isSingleChildContainer: (fiber: FiberNode) => fiber is FiberNode & {
12
10
  element: DomNode;
13
11
  };
14
12
  /**
15
- * Returns true if the given `fiber` is in none compact mode. This means it
16
- * has no fiber children, and its element is <!--r:empty:id-->
13
+ * Returns true if the given `fiber` is in the empty mode. This means it has no
14
+ * fiber children, and its element is <!--r:empty:id-->
17
15
  */
18
- export declare const isCompactNone: (fiber: FiberNode) => fiber is FiberNode & {
16
+ export declare const isEmptyContainer: (fiber: FiberNode) => fiber is FiberNode & {
19
17
  element: DomNode;
20
18
  };
21
- /**
22
- * If the given fiber node has <!--brackets-->, this function tries to apply one
23
- * of the "compact" optimizations:
24
- *
25
- * - If the node has no children, it replaces the brackets with
26
- * <!--r:empty:id-->
27
- * - If the node has only one child, it removes the brackets and sets
28
- * `fiber.element` to reference its only direct DOM child
29
- *
30
- * It also tries to recursively compact parent nodes when possible.
31
- */
32
- export declare function tryToCompactNode(fiber: FiberNode): void;
33
- /**
34
- * Converts <!--empty--> or the single compact container node into:
35
- * <!--begin-->...children...<!--end-->
36
- */
37
- export declare const unwrapCompactFiber: (fiber: FiberNode) => void;
38
19
  //# sourceMappingURL=compact.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../src/core/compact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAGxD;;GAEG;AACH,eAAO,MAAM,SAAS,8DAKuC,CAAC;AAgB9D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;CAOE,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,aAAa;;CAMQ,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAiCvD;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,4BAuC9B,CAAC"}
1
+ {"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../src/core/compact.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,KAAK,OAAO,EACZ,KAAK,SAAS,EACf,MAAM,UAAU,CAAC;AAelB,eAAO,MAAM,eAAe;;CAGI,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;CAOA,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;CAMK,CAAC"}
@@ -1,112 +1,24 @@
1
- import { buildComment, buildCommentText } from './reconciliation/comments';
2
- /**
3
- * Returns true if domNode is <!--r:begin:ID--> where ID is fiber.id
4
- */
5
- export const isBeginOf = (domNode, fiber) => domNode instanceof Comment &&
6
- domNode.textContent === buildCommentText('begin', fiber.id);
7
- /**
8
- * Returns true if domNode is <!--r:end:ID--> where ID is fiber.id
9
- */
10
- const isEndOf = (domNode, fiber) => domNode instanceof Comment &&
11
- domNode.textContent === buildCommentText('end', fiber.id);
1
+ import { containerSym, } from '../types';
2
+ import { buildCommentText } from './reconciliation/comments';
12
3
  /**
13
4
  * Returns true if domNode is <!--r:empty:ID--> where ID is fiber.id
14
5
  */
15
6
  const isEmptyOf = (domNode, fiber) => domNode instanceof Comment &&
16
7
  domNode.textContent === buildCommentText('empty', fiber.id);
8
+ // Returns true when the given fiber is a component or a fragment that contains
9
+ // more than one direct DOM-nodes.
10
+ export const isAutoContainer = (fiber) => fiber.element === containerSym;
17
11
  /**
18
- * Returns true if the given `fiber` is in solo compact mode. This means it
19
- * doesn't have its own direct DOM element. Instead, its `element` refers to its
20
- * only child's `element`, avoiding the need for <!--brackets-->.
12
+ * Returns true if the given `fiber` is in the single-child mode. This means it
13
+ * its `element` refers to its only child's DOM element.
21
14
  */
22
- export const isCompactSingleChild = (fiber) => (fiber.type === 'fragment' || fiber.type === 'component') &&
23
- !isEndOf(fiber.element, fiber) &&
15
+ export const isSingleChildContainer = (fiber) => (fiber.type === 'fragment' || fiber.type === 'component') &&
16
+ fiber.element !== containerSym &&
24
17
  !isEmptyOf(fiber.element, fiber);
25
18
  /**
26
- * Returns true if the given `fiber` is in none compact mode. This means it
27
- * has no fiber children, and its element is <!--r:empty:id-->
19
+ * Returns true if the given `fiber` is in the empty mode. This means it has no
20
+ * fiber children, and its element is <!--r:empty:id-->
28
21
  */
29
- export const isCompactNone = (fiber) => (fiber.type === 'fragment' || fiber.type === 'component') &&
22
+ export const isEmptyContainer = (fiber) => (fiber.type === 'fragment' || fiber.type === 'component') &&
30
23
  isEmptyOf(fiber.element, fiber);
31
- /**
32
- * If the given fiber node has <!--brackets-->, this function tries to apply one
33
- * of the "compact" optimizations:
34
- *
35
- * - If the node has no children, it replaces the brackets with
36
- * <!--r:empty:id-->
37
- * - If the node has only one child, it removes the brackets and sets
38
- * `fiber.element` to reference its only direct DOM child
39
- *
40
- * It also tries to recursively compact parent nodes when possible.
41
- */
42
- export function tryToCompactNode(fiber) {
43
- if (!isEndOf(fiber.element, fiber)) {
44
- return; // Node is not a !--container or is already compact.
45
- }
46
- // By default each fragment or component is rendered with 3+ nodes:
47
- // <!--r:begin:id--> + …children + <!--r:end:id-->
48
- // This approach supports 0 or 2+ nodes without overly complex logic.
49
- // However, most cases have only one child or none. For these scenarios,
50
- // we support two different compact modes.
51
- const prev1 = fiber.element.previousSibling;
52
- // Scenario 1: 0 children.
53
- if (prev1 && isBeginOf(prev1, fiber)) {
54
- const emptyNode = buildComment('empty', fiber.id);
55
- prev1.parentElement.insertBefore(emptyNode, prev1);
56
- prev1.remove(); // !--begin
57
- fiber.element.remove(); // !--end
58
- fiber.element = emptyNode;
59
- return;
60
- // <!--begin--><--end--> are replaced with <!--empty-->
61
- }
62
- const prev2 = prev1?.previousSibling;
63
- // Scenario 2: 1 children
64
- if (prev2 && isBeginOf(prev2, fiber)) {
65
- prev2.remove(); // !--begin
66
- fiber.element.remove(); // !--end
67
- fiber.element = fiber.children[0].element;
68
- // <!--begin--><!--end--> are removed. Now `fiber.element` refers to its
69
- // only child node.
70
- tryToCompactNode(fiber.parent);
71
- }
72
- }
73
- /**
74
- * Converts <!--empty--> or the single compact container node into:
75
- * <!--begin-->...children...<!--end-->
76
- */
77
- export const unwrapCompactFiber = (fiber) => {
78
- const container = fiber.element.parentElement;
79
- let begin = buildComment('begin', fiber.id);
80
- let end = buildComment('end', fiber.id);
81
- if (isCompactSingleChild(fiber)) {
82
- // before: <container><child/></container>
83
- // after: <container><!--begin--><child/><!--end--></container>
84
- container.insertBefore(begin, fiber.element);
85
- container.insertBefore(end, fiber.element.nextSibling);
86
- fiber.element = end;
87
- // Repeat the same with every single-compact ancestor:
88
- let parent = fiber.parent;
89
- while (isCompactSingleChild(parent)) {
90
- const pBegin = buildComment('begin', parent.id);
91
- const pEnd = buildComment('end', parent.id);
92
- container.insertBefore(pBegin, begin);
93
- container.insertBefore(pEnd, end.nextSibling);
94
- parent.element = pEnd;
95
- begin = pBegin;
96
- end = pEnd;
97
- parent = parent.parent;
98
- }
99
- return;
100
- }
101
- if (isCompactNone(fiber)) {
102
- // before: <container><!--empty--></container>
103
- // after: <container><!--begin--><!--end--></container>
104
- container.insertBefore(begin, fiber.element);
105
- container.insertBefore(end, fiber.element.nextSibling);
106
- fiber.element.remove();
107
- fiber.element = end;
108
- return;
109
- }
110
- throw new Error(`Unsupported format of compact node`);
111
- };
112
24
  //# sourceMappingURL=compact.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compact.js","sourceRoot":"","sources":["../../src/core/compact.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE3E;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,OAAkB,EAClB,KAAgB,EACI,EAAE,CACtB,OAAO,YAAY,OAAO;IAC1B,OAAO,CAAC,WAAW,KAAK,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,OAAO,GAAG,CAAC,OAAkB,EAAE,KAAgB,EAAsB,EAAE,CAC3E,OAAO,YAAY,OAAO;IAC1B,OAAO,CAAC,WAAW,KAAK,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,SAAS,GAAG,CAAC,OAAkB,EAAE,KAAgB,EAAsB,EAAE,CAC7E,OAAO,YAAY,OAAO;IAC1B,OAAO,CAAC,WAAW,KAAK,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,KAAgB,EAGhB,EAAE,CACF,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;IACzD,CAAC,OAAO,CAAC,KAAK,CAAC,OAAQ,EAAE,KAAK,CAAC;IAC/B,CAAC,SAAS,CAAC,KAAK,CAAC,OAAQ,EAAE,KAAK,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AAY;IAC9B,CAAC,SAAS,CAAC,KAAK,CAAC,OAAQ,EAAE,KAAK,CAAC,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAAgB,EAGhB,EAAE,CACF,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;IACzD,SAAS,CAAC,KAAK,CAAC,OAAQ,EAAE,KAAK,CAAC,CAAC"}
@@ -1,4 +1,6 @@
1
- import { type HookStateItem, type FiberNode, type App, type ComponentFiberNode } from '../types';
1
+ import { type HookStateItem, type FiberNode, type App, type ComponentFiberNode, type UnknownProps } from '../types';
2
+ import { ReactError } from './reconciliation/errors/ReactError';
3
+ import type { Action } from '../types/actions';
2
4
  /**
3
5
  * Returns the fiber of the component that is being rendered right now. Don't
4
6
  * run this function outside of the render phase.
@@ -16,9 +18,9 @@ export declare const isFirstFiberRender: () => boolean;
16
18
  /**
17
19
  * Runs the functional component. Before running, it prepares everything that
18
20
  * is required to make hooks work. The result is JSX returned from the component
19
- * function.
21
+ * function & the list of actions that must be applied in the commit phase.
20
22
  */
21
- export declare const runComponent: (fiber: FiberNode, propsSource: FiberNode | null) => import("../index.js").JsxElement;
23
+ export declare const runComponent: (fiber: FiberNode, props: UnknownProps | null) => ReactError | [import("../index.js").JsxElement, Action[]];
22
24
  /**
23
25
  * Switches to the next hook and returns its state.
24
26
  */
@@ -27,6 +29,6 @@ export declare const getNextFiberState: () => HookStateItem;
27
29
  * Adds a new item to the current component's hook store
28
30
  */
29
31
  export declare const registerStateItem: (item: {
30
- type: "context" | "effect" | "memo" | "ref" | "state";
32
+ type: "context" | "effect" | "error" | "memo" | "ref" | "state";
31
33
  }) => void;
32
34
  //# sourceMappingURL=components.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/core/components.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EAEd,KAAK,GAAG,EACR,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AAOlB;;;GAGG;AACH,eAAO,MAAM,wBAAwB,0BACX,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,aAAa,WAC6B,CAAC;AAIxD;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAkC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,YAAY,wFAyBxB,CAAC;AAYF;;GAEG;AACH,eAAO,MAAM,iBAAiB,qBACgC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,iBAAiB;;UAI7B,CAAC"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/core/components.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EAEd,KAAK,GAAG,EACR,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAEL,UAAU,EACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAKzD;;;GAGG;AACH,eAAO,MAAM,wBAAwB,0BACX,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,aAAa,WAGzB,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAkC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,YAAY,8GA2CxB,CAAC;AAYF;;GAEG;AACH,eAAO,MAAM,iBAAiB,qBACgC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,iBAAiB;;UAI7B,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { nullthrows } from '../utils';
2
2
  import { getAppByFiber } from './reconciliation/app';
3
3
  import { isFiberDead } from './reconciliation/fibers';
4
+ import { nullthrowsForFiber, ReactError, } from './reconciliation/errors/ReactError';
4
5
  /** Component that is rendered right now. */
5
6
  let currentFiber;
6
7
  /**
@@ -12,7 +13,10 @@ export const getCurrentComponentFiber = () => nullthrows(currentFiber);
12
13
  * The app of the component that is being rendered right now. Don't run this
13
14
  * function outside of the render phase.
14
15
  */
15
- export const getCurrentApp = () => nullthrows(getAppByFiber(getCurrentComponentFiber()));
16
+ export const getCurrentApp = () => {
17
+ const fiber = getCurrentComponentFiber();
18
+ return nullthrowsForFiber(fiber, getAppByFiber(fiber));
19
+ };
16
20
  let firstFiberRender = false;
17
21
  /**
18
22
  * Returns true when it's the 1st render of currentFiber's component.
@@ -21,30 +25,44 @@ export const isFirstFiberRender = () => firstFiberRender;
21
25
  /**
22
26
  * Runs the functional component. Before running, it prepares everything that
23
27
  * is required to make hooks work. The result is JSX returned from the component
24
- * function.
28
+ * function & the list of actions that must be applied in the commit phase.
25
29
  */
26
30
  export const runComponent = (fiber,
27
31
  /** Source of `.props`. If not given `fiber.props` are used. */
28
- propsSource) => {
32
+ props) => {
29
33
  if (fiber.type !== 'component') {
30
- throw new Error(`Can't run ${fiber.type} as a component`);
34
+ throw new ReactError(fiber, `Can't run ${fiber.type} as a component`);
31
35
  }
32
36
  if (isFiberDead(fiber)) {
33
- throw new Error(`Can't run a dead component`);
37
+ throw new ReactError(fiber, `Can't run a dead component`);
34
38
  }
35
39
  currentFiber = fiber;
36
40
  firstFiberRender = !fiber.data.hooks;
37
41
  fiber.data.hooks ??= [];
38
42
  hookIdx = -1;
39
- let jsxElement = fiber.component(propsSource?.props ?? fiber.props);
43
+ let jsxElement;
44
+ let actions = [];
45
+ try {
46
+ jsxElement = fiber.component(props ?? fiber.props);
47
+ actions.push(...fiber.data.actions);
48
+ }
49
+ catch (error) {
50
+ return new ReactError(fiber, error, `Error during rendering a component: %fiber%`);
51
+ }
52
+ finally {
53
+ fiber.data.actions = [];
54
+ }
55
+ if (!firstFiberRender && hookIdx !== fiber.data.hooks.length - 1) {
56
+ throw new ReactError(fiber, `The hook order is violated. There were ${fiber.data.hooks.length} hooks in the previous render. Now only ${hookIdx + 1}`);
57
+ }
40
58
  currentFiber = null;
41
59
  firstFiberRender = false;
42
- return jsxElement;
60
+ return [jsxElement, actions];
43
61
  };
44
62
  let hookIdx = -1;
45
63
  const getComponentHookStore = (fiberNode) => {
46
64
  if (!fiberNode.data.hooks) {
47
- throw new Error(`HookStore is empty.`);
65
+ throw new ReactError(fiberNode, `HookStore is empty.`);
48
66
  }
49
67
  return fiberNode.data.hooks;
50
68
  };
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/core/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAQrC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,4CAA4C;AAC5C,IAAI,YAAuC,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAuB,EAAE,CAC/D,UAAU,CAAC,YAAY,CAAC,CAAC;AAE3B;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAQ,EAAE,CACrC,UAAU,CAAC,aAAa,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC;AAExD,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAY,EAAE,CAAC,gBAAgB,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAgB;AAChB,+DAA+D;AAC/D,WAA6B,EAChB,EAAE,CAAC;IAChB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,aAAa,KAAK,CAAC,IAAI,iBAAiB,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;I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CAAC,wBAAwB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAqB,CAAC,CAAC;AAAA,CAC/E,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ElementNode, ElementType, ReactContextProvider, ReactKey } from '../types';
1
+ import type { ElementNode, ElementType, JsxSource, ReactContextProvider, ReactKey } from '../types';
2
2
  import { type ComponentClass } from './classComponent';
3
3
  /**
4
4
  * This method is used as the JSX resolver. Every <tag/> or <Component/> is a
@@ -23,12 +23,7 @@ export declare function createElementNew(
23
23
  * What to render. Can be a tag (string), a component (function),
24
24
  * or a portal target (HTMLElement).
25
25
  */
26
- type: ReactContextProvider | ElementType | HTMLElement | ComponentClass, propsRaw: Record<PropertyKey, unknown>, key: ReactKey | null | undefined, _isStaticChildren?: boolean, _source?: Source, _self?: unknown): ElementNode;
27
- type Source = {
28
- fileName: string;
29
- lineNumber: number;
30
- columnNumber: number;
31
- };
26
+ type: ReactContextProvider | ElementType | HTMLElement | ComponentClass, propsRaw: Record<PropertyKey, unknown>, key: ReactKey | null | undefined, _isStaticChildren?: boolean, source?: JsxSource | null, _self?: unknown): ElementNode;
32
27
  /**
33
28
  * Renders content into an external HTML node. Unlike React, this version
34
29
  * doesn't support interdimensional event bubbling.
@@ -49,5 +44,4 @@ key?: string): ElementNode;
49
44
  * built with this signature.
50
45
  */
51
46
  export declare function createElement(type: ReactContextProvider | ElementType | HTMLElement, propsRaw: Record<PropertyKey, unknown>, ...children: JSX.Element[]): ElementNode;
52
- export {};
53
47
  //# sourceMappingURL=createElement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createElement.d.ts","sourceRoot":"","sources":["../../src/core/createElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,QAAQ,EAET,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBA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AAE,OAAO,CAAC,EACtC,GAAG,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EAGhC,iBAAiB,CAAC,EAAE,OAAO,EAC3B,MAAM,GAAE,SAAS,GAAG,IAAW,EAC/B,KAAK,CAAC,EAAE,OAAO,GACd,WAAW,CAsCb;AAMD;;;;;;;GAOG;AACH,wBAAgB,YAAY;AAC1B,sBAAsB;AACtB,QAAQ,EAAE,GAAG,CAAC,OAAO;AACrB,uBAAuB;AACvB,OAAO,EAAE,WAAW;AACpB,gEAAgE;AAChE,GAAG,CAAC,EAAE,MAAM,eAGb;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAE3B,IAAI,EACA,oBAAoB,GAEpB,WAAW,GAEX,WAAW,EACf,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EACtC,GAAG,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,GACzB,WAAW,CAOb"}
@@ -26,7 +26,7 @@ export function createElementNew(
26
26
  type, propsRaw, key,
27
27
  // The following arguments are provided only in the development mode.
28
28
  // TODO: Support them to show more informative warnings and errors.
29
- _isStaticChildren, _source, _self) {
29
+ _isStaticChildren, source = null, _self) {
30
30
  key ??= null; // Narrow the type for simplicity.
31
31
  if (isComponentClass(type)) {
32
32
  type = convertClassComponentToFC(type);
@@ -41,6 +41,7 @@ _isStaticChildren, _source, _self) {
41
41
  // what's inside until the component runs. Children are passed via `props`
42
42
  // instead.
43
43
  children: [],
44
+ source,
44
45
  };
45
46
  }
46
47
  // Any tag instance (<div/>).
@@ -55,6 +56,7 @@ _isStaticChildren, _source, _self) {
55
56
  props: propsWithoutChildren,
56
57
  key,
57
58
  children,
59
+ source,
58
60
  };
59
61
  }
60
62
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"createElement.js","sourceRoot":"","sources":["../../src/core/createElement.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,yBAAyB,EACzB,gBAAgB,GAEjB,MAAM,kBAAkB,CAAC;AAE1B;;;;;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,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,oBAAoB;QAC3B,GAAG;QACH,QAAQ;QACR,MAAM;KACP,CAAC;AAAA,CACH;AAMD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY;AAC1B,sBAAsB;AACtB,QAAqB;AACrB,uBAAuB;AACvB,OAAoB;AACpB,gEAAgE;AAChE,GAAY,EACZ;IACA,OAAO,gBAAgB,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;AAAA,CACrD;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;AAC3B,kBAAkB;AAClB,IAKe,EACf,QAAsC,EACtC,GAAG,QAAuB,EACb;IACb,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,QAAQ,IAAI,EAAE,CAAC;IACzC,OAAO,gBAAgB,CACrB,IAAI,EACJ,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,QAAQ,EAAE,EAClD,GAA2B,CAC5B,CAAC;AAAA,CACH"}
@@ -1,8 +1,10 @@
1
+ import type { Action } from '../types/actions';
1
2
  import { type FiberNode } from '../types';
3
+ import { ReactError } from './reconciliation/errors/ReactError';
2
4
  /**
3
5
  * Converts any possible JSX.Element to a FiberNode, that is used by the engine
4
6
  * everywhere. We don't use JSX.Elements outside of this function.
5
7
  * <div/> -> FiberNode.
6
8
  */
7
- export declare const jsxElementToFiberNode: (jsxElement: import("../index.js").JsxElement, parent: FiberNode, unwrapComponents: boolean) => FiberNode;
9
+ export declare const jsxElementToFiberNode: (jsxElement: import("../index.js").JsxElement, parent: FiberNode, unwrapComponents: boolean) => ReactError | [FiberNode, Action[]];
8
10
  //# sourceMappingURL=reactNodeToFiberNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactNodeToFiberNode.d.ts","sourceRoot":"","sources":["../../src/core/reactNodeToFiberNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EASf,MAAM,UAAU,CAAC;AASlB;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,4GA+HjC,CAAC"}
1
+ {"version":3,"file":"reactNodeToFiberNode.d.ts","sourceRoot":"","sources":["../../src/core/reactNodeToFiberNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAGL,KAAK,SAAS,EAUf,MAAM,UAAU,CAAC;AAQlB,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAGhE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,qIAuLjC,CAAC"}