@faiwer/react 0.8.0

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 (246) hide show
  1. package/README.md +90 -0
  2. package/dist/core/actions/applyAction.d.ts +11 -0
  3. package/dist/core/actions/applyAction.d.ts.map +1 -0
  4. package/dist/core/actions/applyAction.js +35 -0
  5. package/dist/core/actions/applyAction.js.map +1 -0
  6. package/dist/core/actions/createComment.action.d.ts +7 -0
  7. package/dist/core/actions/createComment.action.d.ts.map +1 -0
  8. package/dist/core/actions/createComment.action.js +20 -0
  9. package/dist/core/actions/createComment.action.js.map +1 -0
  10. package/dist/core/actions/createTag.action.d.ts +10 -0
  11. package/dist/core/actions/createTag.action.d.ts.map +1 -0
  12. package/dist/core/actions/createTag.action.js +27 -0
  13. package/dist/core/actions/createTag.action.js.map +1 -0
  14. package/dist/core/actions/createText.action.d.ts +6 -0
  15. package/dist/core/actions/createText.action.d.ts.map +1 -0
  16. package/dist/core/actions/createText.action.js +16 -0
  17. package/dist/core/actions/createText.action.js.map +1 -0
  18. package/dist/core/actions/helpers.d.ts +43 -0
  19. package/dist/core/actions/helpers.d.ts.map +1 -0
  20. package/dist/core/actions/helpers.js +141 -0
  21. package/dist/core/actions/helpers.js.map +1 -0
  22. package/dist/core/actions/relayout.action.d.ts +20 -0
  23. package/dist/core/actions/relayout.action.d.ts.map +1 -0
  24. package/dist/core/actions/relayout.action.js +113 -0
  25. package/dist/core/actions/relayout.action.js.map +1 -0
  26. package/dist/core/actions/remove.action.d.ts +7 -0
  27. package/dist/core/actions/remove.action.d.ts.map +1 -0
  28. package/dist/core/actions/remove.action.js +64 -0
  29. package/dist/core/actions/remove.action.js.map +1 -0
  30. package/dist/core/actions/replace.action.d.ts +18 -0
  31. package/dist/core/actions/replace.action.d.ts.map +1 -0
  32. package/dist/core/actions/replace.action.js +57 -0
  33. package/dist/core/actions/replace.action.js.map +1 -0
  34. package/dist/core/actions/setAttr.action.d.ts +9 -0
  35. package/dist/core/actions/setAttr.action.d.ts.map +1 -0
  36. package/dist/core/actions/setAttr.action.js +62 -0
  37. package/dist/core/actions/setAttr.action.js.map +1 -0
  38. package/dist/core/actions/setProps.action.d.ts +8 -0
  39. package/dist/core/actions/setProps.action.d.ts.map +1 -0
  40. package/dist/core/actions/setProps.action.js +13 -0
  41. package/dist/core/actions/setProps.action.js.map +1 -0
  42. package/dist/core/actions/setRef.action.d.ts +11 -0
  43. package/dist/core/actions/setRef.action.d.ts.map +1 -0
  44. package/dist/core/actions/setRef.action.js +38 -0
  45. package/dist/core/actions/setRef.action.js.map +1 -0
  46. package/dist/core/actions/setText.action.d.ts +7 -0
  47. package/dist/core/actions/setText.action.d.ts.map +1 -0
  48. package/dist/core/actions/setText.action.js +12 -0
  49. package/dist/core/actions/setText.action.js.map +1 -0
  50. package/dist/core/compact.d.ts +38 -0
  51. package/dist/core/compact.d.ts.map +1 -0
  52. package/dist/core/compact.js +112 -0
  53. package/dist/core/compact.js.map +1 -0
  54. package/dist/core/components.d.ts +32 -0
  55. package/dist/core/components.d.ts.map +1 -0
  56. package/dist/core/components.js +57 -0
  57. package/dist/core/components.js.map +1 -0
  58. package/dist/core/createElement.d.ts +47 -0
  59. package/dist/core/createElement.d.ts.map +1 -0
  60. package/dist/core/createElement.js +73 -0
  61. package/dist/core/createElement.js.map +1 -0
  62. package/dist/core/createRoot.d.ts +13 -0
  63. package/dist/core/createRoot.d.ts.map +1 -0
  64. package/dist/core/createRoot.js +33 -0
  65. package/dist/core/createRoot.js.map +1 -0
  66. package/dist/core/reactNodeToFiberNode.d.ts +8 -0
  67. package/dist/core/reactNodeToFiberNode.d.ts.map +1 -0
  68. package/dist/core/reactNodeToFiberNode.js +132 -0
  69. package/dist/core/reactNodeToFiberNode.js.map +1 -0
  70. package/dist/core/reconciliation/app.d.ts +5 -0
  71. package/dist/core/reconciliation/app.d.ts.map +1 -0
  72. package/dist/core/reconciliation/app.js +20 -0
  73. package/dist/core/reconciliation/app.js.map +1 -0
  74. package/dist/core/reconciliation/applyActions.d.ts +8 -0
  75. package/dist/core/reconciliation/applyActions.d.ts.map +1 -0
  76. package/dist/core/reconciliation/applyActions.js +12 -0
  77. package/dist/core/reconciliation/applyActions.js.map +1 -0
  78. package/dist/core/reconciliation/collect/fromApp.d.ts +9 -0
  79. package/dist/core/reconciliation/collect/fromApp.d.ts.map +1 -0
  80. package/dist/core/reconciliation/collect/fromApp.js +39 -0
  81. package/dist/core/reconciliation/collect/fromApp.js.map +1 -0
  82. package/dist/core/reconciliation/collect/fromChildrenPair.d.ts +9 -0
  83. package/dist/core/reconciliation/collect/fromChildrenPair.d.ts.map +1 -0
  84. package/dist/core/reconciliation/collect/fromChildrenPair.js +127 -0
  85. package/dist/core/reconciliation/collect/fromChildrenPair.js.map +1 -0
  86. package/dist/core/reconciliation/collect/fromComponent.d.ts +10 -0
  87. package/dist/core/reconciliation/collect/fromComponent.d.ts.map +1 -0
  88. package/dist/core/reconciliation/collect/fromComponent.js +22 -0
  89. package/dist/core/reconciliation/collect/fromComponent.js.map +1 -0
  90. package/dist/core/reconciliation/collect/fromFiberPair.d.ts +9 -0
  91. package/dist/core/reconciliation/collect/fromFiberPair.d.ts.map +1 -0
  92. package/dist/core/reconciliation/collect/fromFiberPair.js +125 -0
  93. package/dist/core/reconciliation/collect/fromFiberPair.js.map +1 -0
  94. package/dist/core/reconciliation/collect/fromNewFiber.d.ts +7 -0
  95. package/dist/core/reconciliation/collect/fromNewFiber.d.ts.map +1 -0
  96. package/dist/core/reconciliation/collect/fromNewFiber.js +45 -0
  97. package/dist/core/reconciliation/collect/fromNewFiber.js.map +1 -0
  98. package/dist/core/reconciliation/comments.d.ts +3 -0
  99. package/dist/core/reconciliation/comments.d.ts.map +1 -0
  100. package/dist/core/reconciliation/comments.js +3 -0
  101. package/dist/core/reconciliation/comments.js.map +1 -0
  102. package/dist/core/reconciliation/compare/areFiberNodesEq.d.ts +7 -0
  103. package/dist/core/reconciliation/compare/areFiberNodesEq.d.ts.map +1 -0
  104. package/dist/core/reconciliation/compare/areFiberNodesEq.js +14 -0
  105. package/dist/core/reconciliation/compare/areFiberNodesEq.js.map +1 -0
  106. package/dist/core/reconciliation/compare/areFiberPropsEq.d.ts +7 -0
  107. package/dist/core/reconciliation/compare/areFiberPropsEq.d.ts.map +1 -0
  108. package/dist/core/reconciliation/compare/areFiberPropsEq.js +18 -0
  109. package/dist/core/reconciliation/compare/areFiberPropsEq.js.map +1 -0
  110. package/dist/core/reconciliation/effects.d.ts +14 -0
  111. package/dist/core/reconciliation/effects.d.ts.map +1 -0
  112. package/dist/core/reconciliation/effects.js +26 -0
  113. package/dist/core/reconciliation/effects.js.map +1 -0
  114. package/dist/core/reconciliation/fibers.d.ts +35 -0
  115. package/dist/core/reconciliation/fibers.d.ts.map +1 -0
  116. package/dist/core/reconciliation/fibers.js +51 -0
  117. package/dist/core/reconciliation/fibers.js.map +1 -0
  118. package/dist/core/reconciliation/invalidateFiber.d.ts +8 -0
  119. package/dist/core/reconciliation/invalidateFiber.d.ts.map +1 -0
  120. package/dist/core/reconciliation/invalidateFiber.js +28 -0
  121. package/dist/core/reconciliation/invalidateFiber.js.map +1 -0
  122. package/dist/core/reconciliation/mount.d.ts +7 -0
  123. package/dist/core/reconciliation/mount.d.ts.map +1 -0
  124. package/dist/core/reconciliation/mount.js +53 -0
  125. package/dist/core/reconciliation/mount.js.map +1 -0
  126. package/dist/core/reconciliation/postCommit.d.ts +11 -0
  127. package/dist/core/reconciliation/postCommit.d.ts.map +1 -0
  128. package/dist/core/reconciliation/postCommit.js +47 -0
  129. package/dist/core/reconciliation/postCommit.js.map +1 -0
  130. package/dist/core/reconciliation/render.d.ts +11 -0
  131. package/dist/core/reconciliation/render.d.ts.map +1 -0
  132. package/dist/core/reconciliation/render.js +35 -0
  133. package/dist/core/reconciliation/render.js.map +1 -0
  134. package/dist/core/reconciliation/runFiberComponents.d.ts +10 -0
  135. package/dist/core/reconciliation/runFiberComponents.d.ts.map +1 -0
  136. package/dist/core/reconciliation/runFiberComponents.js +37 -0
  137. package/dist/core/reconciliation/runFiberComponents.js.map +1 -0
  138. package/dist/core/reconciliation/typeGuards.d.ts +12 -0
  139. package/dist/core/reconciliation/typeGuards.d.ts.map +1 -0
  140. package/dist/core/reconciliation/typeGuards.js +32 -0
  141. package/dist/core/reconciliation/typeGuards.js.map +1 -0
  142. package/dist/core/reconciliation/validateTree.d.ts +6 -0
  143. package/dist/core/reconciliation/validateTree.d.ts.map +1 -0
  144. package/dist/core/reconciliation/validateTree.js +48 -0
  145. package/dist/core/reconciliation/validateTree.js.map +1 -0
  146. package/dist/hooks/helpers.d.ts +19 -0
  147. package/dist/hooks/helpers.d.ts.map +1 -0
  148. package/dist/hooks/helpers.js +40 -0
  149. package/dist/hooks/helpers.js.map +1 -0
  150. package/dist/hooks/index.d.ts +9 -0
  151. package/dist/hooks/index.d.ts.map +1 -0
  152. package/dist/hooks/index.js +9 -0
  153. package/dist/hooks/index.js.map +1 -0
  154. package/dist/hooks/useCallback.d.ts +2 -0
  155. package/dist/hooks/useCallback.d.ts.map +1 -0
  156. package/dist/hooks/useCallback.js +5 -0
  157. package/dist/hooks/useCallback.js.map +1 -0
  158. package/dist/hooks/useContext.d.ts +37 -0
  159. package/dist/hooks/useContext.d.ts.map +1 -0
  160. package/dist/hooks/useContext.js +101 -0
  161. package/dist/hooks/useContext.js.map +1 -0
  162. package/dist/hooks/useEffect.d.ts +48 -0
  163. package/dist/hooks/useEffect.d.ts.map +1 -0
  164. package/dist/hooks/useEffect.js +100 -0
  165. package/dist/hooks/useEffect.js.map +1 -0
  166. package/dist/hooks/useId.d.ts +2 -0
  167. package/dist/hooks/useId.d.ts.map +1 -0
  168. package/dist/hooks/useId.js +10 -0
  169. package/dist/hooks/useId.js.map +1 -0
  170. package/dist/hooks/useMemo.d.ts +20 -0
  171. package/dist/hooks/useMemo.d.ts.map +1 -0
  172. package/dist/hooks/useMemo.js +33 -0
  173. package/dist/hooks/useMemo.js.map +1 -0
  174. package/dist/hooks/useRef.d.ts +4 -0
  175. package/dist/hooks/useRef.d.ts.map +1 -0
  176. package/dist/hooks/useRef.js +9 -0
  177. package/dist/hooks/useRef.js.map +1 -0
  178. package/dist/hooks/useStableCallback.d.ts +45 -0
  179. package/dist/hooks/useStableCallback.d.ts.map +1 -0
  180. package/dist/hooks/useStableCallback.js +66 -0
  181. package/dist/hooks/useStableCallback.js.map +1 -0
  182. package/dist/hooks/useState.d.ts +15 -0
  183. package/dist/hooks/useState.d.ts.map +1 -0
  184. package/dist/hooks/useState.js +39 -0
  185. package/dist/hooks/useState.js.map +1 -0
  186. package/dist/index.d.ts +8 -0
  187. package/dist/index.d.ts.map +1 -0
  188. package/dist/index.js +13 -0
  189. package/dist/index.js.map +1 -0
  190. package/dist/jsx-dev-runtime.d.ts +6 -0
  191. package/dist/jsx-dev-runtime.d.ts.map +1 -0
  192. package/dist/jsx-dev-runtime.js +7 -0
  193. package/dist/jsx-dev-runtime.js.map +1 -0
  194. package/dist/jsx-runtime.d.ts +31 -0
  195. package/dist/jsx-runtime.d.ts.map +1 -0
  196. package/dist/jsx-runtime.js +32 -0
  197. package/dist/jsx-runtime.js.map +1 -0
  198. package/dist/testing.d.ts +8 -0
  199. package/dist/testing.d.ts.map +1 -0
  200. package/dist/testing.js +10 -0
  201. package/dist/testing.js.map +1 -0
  202. package/dist/types/actions.d.ts +53 -0
  203. package/dist/types/actions.d.ts.map +1 -0
  204. package/dist/types/actions.js +2 -0
  205. package/dist/types/actions.js.map +1 -0
  206. package/dist/types/app.d.ts +74 -0
  207. package/dist/types/app.d.ts.map +1 -0
  208. package/dist/types/app.js +2 -0
  209. package/dist/types/app.js.map +1 -0
  210. package/dist/types/component.d.ts +11 -0
  211. package/dist/types/component.d.ts.map +1 -0
  212. package/dist/types/component.js +2 -0
  213. package/dist/types/component.js.map +1 -0
  214. package/dist/types/context.d.ts +28 -0
  215. package/dist/types/context.d.ts.map +1 -0
  216. package/dist/types/context.js +2 -0
  217. package/dist/types/context.js.map +1 -0
  218. package/dist/types/core.d.ts +51 -0
  219. package/dist/types/core.d.ts.map +1 -0
  220. package/dist/types/core.js +2 -0
  221. package/dist/types/core.js.map +1 -0
  222. package/dist/types/dom.d.ts +48 -0
  223. package/dist/types/dom.d.ts.map +1 -0
  224. package/dist/types/dom.js +2 -0
  225. package/dist/types/dom.js.map +1 -0
  226. package/dist/types/fiber.d.ts +169 -0
  227. package/dist/types/fiber.d.ts.map +1 -0
  228. package/dist/types/fiber.js +2 -0
  229. package/dist/types/fiber.js.map +1 -0
  230. package/dist/types/hooks.d.ts +47 -0
  231. package/dist/types/hooks.d.ts.map +1 -0
  232. package/dist/types/hooks.js +2 -0
  233. package/dist/types/hooks.js.map +1 -0
  234. package/dist/types/index.d.ts +9 -0
  235. package/dist/types/index.d.ts.map +1 -0
  236. package/dist/types/index.js +9 -0
  237. package/dist/types/index.js.map +1 -0
  238. package/dist/types/refs.d.ts +19 -0
  239. package/dist/types/refs.d.ts.map +1 -0
  240. package/dist/types/refs.js +2 -0
  241. package/dist/types/refs.js.map +1 -0
  242. package/dist/utils.d.ts +2 -0
  243. package/dist/utils.d.ts.map +1 -0
  244. package/dist/utils.js +7 -0
  245. package/dist/utils.js.map +1 -0
  246. package/package.json +67 -0
@@ -0,0 +1,47 @@
1
+ import { reactRender } from './render';
2
+ import { runEffects } from './effects';
3
+ /**
4
+ * A stage that happens after we've applied all necessary DOM and fiber changes
5
+ * in applyActions (the "commit" phase). In this stage we:
6
+ * - run all kinds of effects
7
+ * - when needed, schedule another render cycle (if effects updated component
8
+ * state)
9
+ * - or move the app to the idle stage
10
+ */
11
+ export function postCommit(app, depth) {
12
+ app.tempContext.clear();
13
+ // Run "ref" and "layout" effects. They must be run in the same microtask
14
+ // queue as the commit phase.
15
+ if (app.effects.layout.length > 0 || app.effects.refs.length > 0) {
16
+ app.state = 'layoutEffects';
17
+ runEffects(app, 'layout'); // It will also run "ref" effects
18
+ if (app.invalidatedComponents.size > 0) {
19
+ // 1+ component was invalidated in an effect
20
+ if (app.effects.normal.length > 0) {
21
+ // Layout effect component invalidations should be applied within the
22
+ // same microtask queue, so we need to run the scheduled normal effects
23
+ // right away.
24
+ app.state = 'effects';
25
+ runEffects(app, 'normal');
26
+ }
27
+ app.state = 'scheduled';
28
+ queueMicrotask(() => reactRender(app, depth + 1));
29
+ return;
30
+ }
31
+ }
32
+ if (app.effects.normal.length === 0) {
33
+ app.state = 'idle';
34
+ return;
35
+ }
36
+ app.state = 'effects';
37
+ setTimeout(() => {
38
+ runEffects(app, 'normal');
39
+ if (app.invalidatedComponents.size > 0) {
40
+ app.state = 'scheduled';
41
+ setTimeout(() => reactRender(app), 0);
42
+ return;
43
+ }
44
+ app.state = 'idle';
45
+ }, 0);
46
+ }
47
+ //# sourceMappingURL=postCommit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postCommit.js","sourceRoot":"","sources":["../../../src/core/reconciliation/postCommit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,GAAQ,EAAE,KAAa,EAAE;IAClD,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAExB,yEAAyE;IACzE,6BAA6B;IAC7B,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjE,GAAG,CAAC,KAAK,GAAG,eAAe,CAAC;QAC5B,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,iCAAiC;QAE5D,IAAI,GAAG,CAAC,qBAAqB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACvC,4CAA4C;YAC5C,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClC,qEAAqE;gBACrE,uEAAuE;gBACvE,cAAc;gBACd,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;gBACtB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAC5B,CAAC;YAED,GAAG,CAAC,KAAK,GAAG,WAAW,CAAC;YACxB,cAAc,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;YAClD,OAAO;QACT,CAAC;IACH,CAAC;IAED,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC;QACnB,OAAO;IACT,CAAC;IAED,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;IACtB,UAAU,CAAC,GAAG,EAAE,CAAC;QACf,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAE1B,IAAI,GAAG,CAAC,qBAAqB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACvC,GAAG,CAAC,KAAK,GAAG,WAAW,CAAC;YACxB,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACtC,OAAO;QACT,CAAC;QAED,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC;IAAA,CACpB,EAAE,CAAC,CAAC,CAAC;AAAA,CACP"}
@@ -0,0 +1,11 @@
1
+ import type { App } from '../../types';
2
+ /**
3
+ * Performs another rendering round. Once anything changes a component's state
4
+ * (invalidates it), a new render cycle is scheduled. The render consists of:
5
+ *
6
+ * 1. running components, collecting needed changes (actions), scheduling effects
7
+ * 2. applying actions to the DOM and fiber trees
8
+ * 3. running scheduled effects, updating ref handlers (postCommit)
9
+ */
10
+ export declare function reactRender(app: App, depth?: number): void;
11
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAM9C;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,SAAI,QAuB9C"}
@@ -0,0 +1,35 @@
1
+ import { validateTree } from './validateTree';
2
+ import { collectActionsFromApp } from './collect/fromApp';
3
+ import { postCommit } from './postCommit';
4
+ import { applyActions } from './applyActions';
5
+ /**
6
+ * Performs another rendering round. Once anything changes a component's state
7
+ * (invalidates it), a new render cycle is scheduled. The render consists of:
8
+ *
9
+ * 1. running components, collecting needed changes (actions), scheduling effects
10
+ * 2. applying actions to the DOM and fiber trees
11
+ * 3. running scheduled effects, updating ref handlers (postCommit)
12
+ */
13
+ export function reactRender(app, depth = 0) {
14
+ if (depth > MAX_DEPTH) {
15
+ throw new Error(`Maximum update depth exceeded`);
16
+ }
17
+ if (app.testMode && app.invalidatedComponents.size === 0) {
18
+ throw new Error(`Unnecessary react render`);
19
+ }
20
+ if (app.state === 'killed') {
21
+ return;
22
+ }
23
+ if (app.testMode)
24
+ validateTree(app.root);
25
+ app.state = 'render';
26
+ const actions = collectActionsFromApp(app);
27
+ if (app.testMode)
28
+ validateTree(app.root);
29
+ applyActions(app, actions);
30
+ if (app.testMode)
31
+ validateTree(app.root);
32
+ postCommit(app, depth);
33
+ }
34
+ const MAX_DEPTH = 50; // Like in React.
35
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/reconciliation/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,GAAQ,EAAE,KAAK,GAAG,CAAC,EAAE;IAC/C,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,qBAAqB,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,GAAG,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,IAAI,GAAG,CAAC,QAAQ;QAAE,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEzC,GAAG,CAAC,KAAK,GAAG,QAAQ,CAAC;IACrB,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,GAAG,CAAC,QAAQ;QAAE,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEzC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3B,IAAI,GAAG,CAAC,QAAQ;QAAE,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEzC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAAA,CACxB;AAED,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,iBAAiB"}
@@ -0,0 +1,10 @@
1
+ import type { App, FiberNode } from '../../types';
2
+ /**
3
+ * By default we don't run all components. We run only those that were manually
4
+ * invalidated, as if they were all wrapped with `memo()`. So the `.children`
5
+ * node of such fibers is empty. This method recursively goes through all of the
6
+ * given fiber DOM subtree nodes and runs all found components to fill their
7
+ * `.children`. Should be used only for not-yet-mounted component fiber nodes.
8
+ */
9
+ export declare const runFiberComponents: (app: App, fiber: FiberNode) => void;
10
+ //# sourceMappingURL=runFiberComponents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runFiberComponents.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/runFiberComponents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAKzD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,sCAsB9B,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { runComponent } from '../components';
2
+ import { jsxElementToFiberNode } from '../reactNodeToFiberNode';
3
+ import { FAKE_CONTAINER_TAG, toFiberChildren } from './fibers';
4
+ /**
5
+ * By default we don't run all components. We run only those that were manually
6
+ * invalidated, as if they were all wrapped with `memo()`. So the `.children`
7
+ * node of such fibers is empty. This method recursively goes through all of the
8
+ * given fiber DOM subtree nodes and runs all found components to fill their
9
+ * `.children`. Should be used only for not-yet-mounted component fiber nodes.
10
+ */
11
+ export const runFiberComponents = (app, fiber) => {
12
+ if (app.testMode)
13
+ checkParents(fiber);
14
+ switch (fiber.type) {
15
+ case 'fragment':
16
+ case 'tag':
17
+ for (const child of fiber.children) {
18
+ runFiberComponents(app, child);
19
+ }
20
+ break;
21
+ case 'component': {
22
+ const newChildren = runComponent(fiber, null);
23
+ const child = jsxElementToFiberNode(newChildren, fiber, true /* run children-components recursively */);
24
+ fiber.children = toFiberChildren(child);
25
+ break;
26
+ }
27
+ }
28
+ };
29
+ const checkParents = (fiber) => {
30
+ let parent = fiber.parent;
31
+ while (parent && parent.tag !== FAKE_CONTAINER_TAG)
32
+ parent = parent.parent;
33
+ if (!parent) {
34
+ throw new Error(`runFiberComponents shouldn't be called for already mounted fiber nodes`);
35
+ }
36
+ };
37
+ //# sourceMappingURL=runFiberComponents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runFiberComponents.js","sourceRoot":"","sources":["../../../src/core/reconciliation/runFiberComponents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAA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 * Returns true if the given fiber can contain children fiber nodes.
4
+ */
5
+ export declare const isContainerFiber: (fiber: FiberNode) => boolean;
6
+ export declare const isContextProvider: (node: ElementType | import("../../index.js").ReactContextProvider<unknown>) => node is import("../../index.js").ReactContextProvider<unknown>;
7
+ /**
8
+ * Validates that the given value can be used as an event handler or a tag
9
+ * attribute value. Throws if not.
10
+ */
11
+ export declare function assertsTagAttrValue(v: unknown): asserts v is TagAttrValue;
12
+ //# sourceMappingURL=typeGuards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/typeGuards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EAET,YAAY,EACb,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,eAAO,MAAM,gBAAgB,+BAGP,CAAC;AAGvB,eAAO,MAAM,iBAAiB,4IAM7B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,YAAY,CAkBzE"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Returns true if the given fiber can contain children fiber nodes.
3
+ */
4
+ export const isContainerFiber = (fiber) => fiber.type === 'component' ||
5
+ fiber.type === 'fragment' ||
6
+ fiber.type === 'tag';
7
+ // The rest of them: tag, null, text
8
+ export const isContextProvider = (node) => {
9
+ const ctx = typeof node === 'object' && node && '__ctx' in node ? node : null;
10
+ return ctx !== null;
11
+ };
12
+ /**
13
+ * Validates that the given value can be used as an event handler or a tag
14
+ * attribute value. Throws if not.
15
+ */
16
+ export function assertsTagAttrValue(v) {
17
+ switch (typeof v) {
18
+ case 'undefined':
19
+ case 'string':
20
+ case 'boolean':
21
+ case 'number':
22
+ case 'function':
23
+ return;
24
+ case 'object':
25
+ if (v === null)
26
+ return;
27
+ case 'bigint':
28
+ case 'symbol':
29
+ throw new Error(`Unsupported format of tag attribute value (${String(v)})`);
30
+ }
31
+ }
32
+ //# sourceMappingURL=typeGuards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/core/reconciliation/typeGuards.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAgB,EAAW,EAAE,CAC5D,KAAK,CAAC,IAAI,KAAK,WAAW;IAC1B,KAAK,CAAC,IAAI,KAAK,UAAU;IACzB,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC;AACvB,oCAAoC;AAEpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAA4C,EACV,EAAE,CAAC;IACrC,MAAM,GAAG,GACP,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,OAAO,GAAG,KAAK,IAAI,CAAC;AAAA,CACrB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,CAAU,EAA6B;IACzE,QAAQ,OAAO,CAAC,EAAE,CAAC;QACjB,KAAK,WAAW,CAAC;QACjB,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,UAAU;YACb,OAAO;QAET,KAAK,QAAQ;YACX,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO;QAEzB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACX,MAAM,IAAI,KAAK,CACb,8CAA8C,MAAM,CAAC,CAAC,CAAC,GAAG,CAC3D,CAAC;IACN,CAAC;AAAA,CACF"}
@@ -0,0 +1,6 @@
1
+ import type { FiberNode } from '../../types';
2
+ /**
3
+ * Validates the given fiber node and its subnodes. In case of error it throws.
4
+ */
5
+ export declare const validateTree: (node: FiberNode, path?: string) => void;
6
+ //# sourceMappingURL=validateTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateTree.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/validateTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;GAEG;AACH,eAAO,MAAM,YAAY,0CA+BxB,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { nullthrows } from '../../utils';
2
+ /**
3
+ * Validates the given fiber node and its subnodes. In case of error it throws.
4
+ */
5
+ export const validateTree = (node, path = '') => {
6
+ // Each rendered node must be associated with at least one real DOM node.
7
+ nullthrows(node.element, `${path}.element`);
8
+ if (node.type === 'tag') {
9
+ if (!node.tag) {
10
+ throw new Error(`${path} has empty "tag" field `);
11
+ }
12
+ const domNode = node.role === 'portal' ? node.data : node.element;
13
+ if (!(domNode instanceof Element)) {
14
+ throw new Error(`${path} doesn't have element`);
15
+ }
16
+ }
17
+ else if (node.type === 'component' && !node.component) {
18
+ throw new Error(`${path} has empty "component" field `);
19
+ }
20
+ else if (node.role === 'context' && !node.data.ctx) {
21
+ throw new Error(`${path} has no context`);
22
+ }
23
+ else if (node.type === 'text' && !(node.element instanceof Text)) {
24
+ throw new Error(`${path}'s element is not a Text`);
25
+ }
26
+ for (const [idx, child] of node.children.entries()) {
27
+ const label = getFiberPathLabel(child);
28
+ const key = (child.key ?? idx) + `^${label}`;
29
+ if (child.parent !== node) {
30
+ throw new Error(`${path}.${key}.parent is ${child.parent ? 'wrong' : 'empty'}`);
31
+ }
32
+ validateTree(child, `${path}.${key}`);
33
+ }
34
+ };
35
+ const getFiberPathLabel = (node) => {
36
+ return node.type === 'text' || node.type === 'null'
37
+ ? node.type
38
+ : node.type === 'tag'
39
+ ? `<${nullthrows(node.tag)}/>`
40
+ : node.type === 'fragment'
41
+ ? node.role === 'context'
42
+ ? '<ctx/>'
43
+ : '[]'
44
+ : node.type === 'component'
45
+ ? `<${node.component.name || 'Comp'}/>`
46
+ : 'unknown';
47
+ };
48
+ //# sourceMappingURL=validateTree.js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;AAAA,CACrB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type FiberNode, type HookDeps } from '../types';
2
+ /**
3
+ * We could save the given deps as is, but this version allows to avoid memory
4
+ * leaks by means of using WeakRefs for object-based dependencies.
5
+ */
6
+ export declare const saveDeps: (deps: unknown[]) => HookDeps;
7
+ /**
8
+ * Returns `false` if some of the deps were changed.
9
+ * Note: it compares deps shallowly.
10
+ */
11
+ export declare const checkDeps: (saved: unknown[], deps: unknown[]) => boolean;
12
+ /**
13
+ * Returns the current hook state for 2nd+ renders and runs the given fn to
14
+ * create the initial hook state during the 1st render.
15
+ */
16
+ export declare const getNextHookOrCreate: <T extends {
17
+ type: "context" | "effect" | "memo" | "ref" | "state";
18
+ }>(type: "context" | "effect" | "memo" | "ref" | "state", fn: (fiber: FiberNode) => T) => T;
19
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/hooks/helpers.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,SAAS,EAAsB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,QAAQ,+BAIpB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,gDASrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC;;2FAyBpC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { getCurrentComponentFiber, getNextFiberState, isFirstFiberRender, registerStateItem, } from '../core/components';
2
+ /**
3
+ * We could save the given deps as is, but this version allows to avoid memory
4
+ * leaks by means of using WeakRefs for object-based dependencies.
5
+ */
6
+ export const saveDeps = (deps) => {
7
+ return deps.map((dep) => typeof dep === 'object' && dep ? new WeakRef(dep) : dep);
8
+ };
9
+ /**
10
+ * Returns `false` if some of the deps were changed.
11
+ * Note: it compares deps shallowly.
12
+ */
13
+ export const checkDeps = (saved, deps) => {
14
+ return (saved.length === deps.length &&
15
+ saved.every((s, idx) => s instanceof WeakRef
16
+ ? !!deps[idx] && s.deref() === deps[idx]
17
+ : s === deps[idx]));
18
+ };
19
+ /**
20
+ * Returns the current hook state for 2nd+ renders and runs the given fn to
21
+ * create the initial hook state during the 1st render.
22
+ */
23
+ export const getNextHookOrCreate = (type, fn) => {
24
+ const firstRender = isFirstFiberRender();
25
+ const fiber = getCurrentComponentFiber();
26
+ if (!Array.isArray(fiber.data.hooks)) {
27
+ throw new Error(`Hooks cannot be used outside of components`);
28
+ }
29
+ if (firstRender) {
30
+ const item = fn(fiber);
31
+ registerStateItem(item);
32
+ return item;
33
+ }
34
+ const item = firstRender ? fiber.data.hooks.at(-1) : getNextFiberState();
35
+ if (item.type !== type) {
36
+ throw new Error(`The order of the hooks is violated. Expected: ${type}, got: ${item.type}`);
37
+ }
38
+ return item;
39
+ };
40
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/hooks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAG3B;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAe,EAAY,EAAE,CAAC;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACtB,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CACxD,CAAC;AAAA,CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAgB,EAAE,IAAe,EAAW,EAAE,CAAC;IACvE,OAAO,CACL,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;QAC5B,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CACrB,CAAC,YAAY,OAAO;YAClB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC;YACxC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,CACpB,CACF,CAAC;AAAA,CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,IAA2B,EAC3B,EAA2B,EACxB,EAAE,CAAC;IACN,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,wBAAwB,EAAE,CAAC;IAEzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,IAAI,GAAM,EAAE,CAAC,KAAK,CAAC,CAAC;QAC1B,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC1E,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,iDAAiD,IAAI,UAAU,IAAI,CAAC,IAAI,EAAE,CAC3E,CAAC;IACJ,CAAC;IAED,OAAO,IAAoB,CAAC;AAAA,CAC7B,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { useCallback } from './useCallback';
2
+ export { createContext, useContext } from './useContext';
3
+ export { useEffect, useLayoutEffect } from './useEffect';
4
+ export { useStableCallback } from './useStableCallback';
5
+ export { useId } from './useId';
6
+ export { useMemo } from './useMemo';
7
+ export { useRef } from './useRef';
8
+ export { useState } from './useState';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { useCallback } from './useCallback';
2
+ export { createContext, useContext } from './useContext';
3
+ export { useEffect, useLayoutEffect } from './useEffect';
4
+ export { useStableCallback } from './useStableCallback';
5
+ export { useId } from './useId';
6
+ export { useMemo } from './useMemo';
7
+ export { useRef } from './useRef';
8
+ export { useState } from './useState';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function useCallback<TArgs extends unknown[], TRes>(fn: (...args: TArgs) => TRes, deps: unknown[]): (...args: TArgs) => TRes;
2
+ //# sourceMappingURL=useCallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCallback.d.ts","sourceRoot":"","sources":["../../src/hooks/useCallback.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,IAAI,EACvD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,IAAI,EAC5B,IAAI,EAAE,OAAO,EAAE,4BAGhB"}
@@ -0,0 +1,5 @@
1
+ import { useMemo } from './useMemo';
2
+ export function useCallback(fn, deps) {
3
+ return useMemo(() => fn, deps);
4
+ }
5
+ //# sourceMappingURL=useCallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCallback.js","sourceRoot":"","sources":["../../src/hooks/useCallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,UAAU,WAAW,CACzB,EAA4B,EAC5B,IAAe,EACf;IACA,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AAAA,CAChC"}
@@ -0,0 +1,37 @@
1
+ import { type ReactContext } from '../types';
2
+ /**
3
+ * Creates a React context object that can be used to pass data through the
4
+ * component tree without having to pass props down manually at every level.
5
+ *
6
+ * @example
7
+ * // Create a theme context
8
+ * const ThemeContext = createContext('light');
9
+ *
10
+ * // Use in a component tree
11
+ * const App = () => (
12
+ * <ThemeContext.Provider value="dark">
13
+ * <UserInterface />
14
+ * </ThemeContext.Provider>
15
+ * );
16
+ *
17
+ * const UserInterface = () => {
18
+ * const theme = useContext(ThemeContext); // 'dark'
19
+ * return <div className={theme}>Content</div>;
20
+ * };
21
+ */
22
+ export declare const createContext: <T>(defaultValue: T) => ReactContext<T>;
23
+ /**
24
+ * A hook that allows you to consume context values from the nearest Provider up
25
+ * the component tree. The component will re-render when the context value
26
+ * changes. If no context provider is found, the default context value is used.
27
+ *
28
+ * @example
29
+ * const ThemeContext = createContext('light');
30
+ *
31
+ * const ThemedButton = () => {
32
+ * const theme = useContext(ThemeContext);
33
+ * return <button className={`btn-${theme}`}>Click me</button>
34
+ * };
35
+ */
36
+ export declare const useContext: <T>(ctx: ReactContext<T>) => T;
37
+ //# sourceMappingURL=useContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContext.d.ts","sourceRoot":"","sources":["../../src/hooks/useContext.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,YAAY,EAIlB,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,qCAmB9B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,4BAqC3B,CAAC"}
@@ -0,0 +1,101 @@
1
+ import { getAppByFiber } from '../core/reconciliation/app';
2
+ import { getNextHookOrCreate } from './helpers';
3
+ /**
4
+ * Creates a React context object that can be used to pass data through the
5
+ * component tree without having to pass props down manually at every level.
6
+ *
7
+ * @example
8
+ * // Create a theme context
9
+ * const ThemeContext = createContext('light');
10
+ *
11
+ * // Use in a component tree
12
+ * const App = () => (
13
+ * <ThemeContext.Provider value="dark">
14
+ * <UserInterface />
15
+ * </ThemeContext.Provider>
16
+ * );
17
+ *
18
+ * const UserInterface = () => {
19
+ * const theme = useContext(ThemeContext); // 'dark'
20
+ * return <div className={theme}>Content</div>;
21
+ * };
22
+ */
23
+ export const createContext = (
24
+ /** The default value that will be used when a component consumes the context
25
+ * but is not wrapped by a Provider */
26
+ defaultValue) => {
27
+ const id = ++idx; // Unique ID.
28
+ const ctx = {
29
+ __id: id,
30
+ __default: defaultValue,
31
+ // @ts-ignore the real type is very different. But it's React way of typing.
32
+ Provider: { __ctx: null },
33
+ Consumer: null,
34
+ };
35
+ ctx.Provider.__ctx = ctx;
36
+ ctx.Consumer = function ContextConsumer({ children }) {
37
+ return children(useContext(ctx));
38
+ };
39
+ return ctx;
40
+ };
41
+ /**
42
+ * A hook that allows you to consume context values from the nearest Provider up
43
+ * the component tree. The component will re-render when the context value
44
+ * changes. If no context provider is found, the default context value is used.
45
+ *
46
+ * @example
47
+ * const ThemeContext = createContext('light');
48
+ *
49
+ * const ThemedButton = () => {
50
+ * const theme = useContext(ThemeContext);
51
+ * return <button className={`btn-${theme}`}>Click me</button>
52
+ * };
53
+ */
54
+ export const useContext = (
55
+ /** The context object created by createContext. */
56
+ ctx) => {
57
+ const item = getNextHookOrCreate('context', (fiber) => {
58
+ const providerFiber = findProvider(fiber, ctx.__id);
59
+ if (providerFiber) {
60
+ // We can assume that the found provider never changes, because when it
61
+ // changes, all its children die (including this component).
62
+ providerFiber.data.consumers.add(fiber);
63
+ }
64
+ return {
65
+ type: 'context',
66
+ ctx,
67
+ providerFiber,
68
+ destructor: () => {
69
+ providerFiber?.data.consumers.delete(fiber);
70
+ },
71
+ };
72
+ });
73
+ if (item.providerFiber) {
74
+ const { tempContext } = getAppByFiber(item.providerFiber);
75
+ const { id } = item.providerFiber;
76
+ if (tempContext.has(id)) {
77
+ // When we're here it means the provider's value was invalidated during
78
+ // the active render.
79
+ return tempContext.get(id);
80
+ }
81
+ // Provider is given, its value wasn't updated in this cycle.
82
+ return item.providerFiber.props.value;
83
+ }
84
+ // Provider not found. Use the default value.
85
+ return ctx.__default;
86
+ };
87
+ /**
88
+ * Traverse through the given fiber's parent nodes and search for the provider
89
+ * <ctx.Provider/>. Returns `null` if it is not found.
90
+ */
91
+ const findProvider = (fiber, id) => {
92
+ while (fiber.role !== 'context' || fiber.data.ctx.__id !== id) {
93
+ fiber = fiber.parent;
94
+ if (!fiber.parent) {
95
+ return null;
96
+ }
97
+ }
98
+ return fiber;
99
+ };
100
+ let idx = 0;
101
+ //# sourceMappingURL=useContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContext.js","sourceRoot":"","sources":["../../src/hooks/useContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAQrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;AAC3B;sCACsC;AACtC,YAAe,EACE,EAAE,CAAC;IACpB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,aAAa;IAC/B,MAAM,GAAG,GAAoB;QAC3B,IAAI,EAAE,EAAE;QACR,SAAS,EAAE,YAAY;QACvB,4EAA4E;QAC5E,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAkC,EAAE;QACvD,QAAQ,EAAE,IAA0C;KACrD,CAAC;IACF,GAAG,CAAC,QAAQ,CAAC,KAAK,GAAG,GAAG,CAAC;IACzB,GAAG,CAAC,QAAQ,GAAG,SAAS,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE;QACpD,OAAO,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAClC,CAAC;IAEF,OAAO,GAAG,CAAC;AAAA,CACZ,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;AACxB,mDAAmD;AACnD,GAAoB,EACjB,EAAE,CAAC;IACN,MAAM,IAAI,GAAG,mBAAmB,CAAoB,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;QACxE,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,aAAa,EAAE,CAAC;YAClB,uEAAuE;YACvE,4DAA4D;YAC5D,aAAa,CAAC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**
3
+ * A hook that performs side effects in functional components. This enhanced
4
+ * version supports async functions and provides an AbortSignal for cleanup.
5
+ *
6
+ * Effects run after the render is committed to the screen, making them suitable
7
+ * for data fetching, subscriptions, or manually changing the DOM.
8
+ *
9
+ * @example
10
+ * // Basic effect with cleanup
11
+ * useEffect(() => {
12
+ * const timer = setInterval(() => console.log('tick'), 1000);
13
+ * return () => clearInterval(timer);
14
+ * }, []);
15
+ *
16
+ * // Async effect with abort signal
17
+ * useEffect(async (signal) => {
18
+ * try {
19
+ * const response = await fetch('/api/data', { signal });
20
+ * const data = await response.json();
21
+ * setData(data);
22
+ * } catch (error) {
23
+ * if (!signal.aborted) {
24
+ * console.error('Fetch failed:', error);
25
+ * }
26
+ * }
27
+ * }, [userId]);
28
+ */
29
+ export declare const useEffect: (fn: EffectHandler, deps?: unknown[] | undefined) => void;
30
+ /**
31
+ * A hook that performs side effects synchronously after all DOM mutations but
32
+ * before the browser paints. This enhanced version supports async functions
33
+ * and provides an AbortSignal for cleanup.
34
+ *
35
+ * Use this for DOM measurements, synchronous DOM mutations, or when you need
36
+ * to read layout properties before the browser paints.
37
+ *
38
+ * @example
39
+ * // Measuring DOM elements before paint
40
+ * useLayoutEffect(() => {
41
+ * const rect = elementRef.current?.getBoundingClientRect();
42
+ * if (rect) {
43
+ * setDimensions({ width: rect.width, height: rect.height });
44
+ * }
45
+ * }, []);
46
+ */
47
+ export declare const useLayoutEffect: (fn: EffectHandler, deps?: unknown[] | undefined) => void;
48
+ //# sourceMappingURL=useEffect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEffect.d.ts","sourceRoot":"","sources":["../../src/hooks/useEffect.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,UAAU,CAAC;AAyBlB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,SAAS,2DAWrB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,2DAW3B,CAAC"}