@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,22 @@
1
+ import { runComponent } from '../../components';
2
+ import { jsxElementToFiberNode } from '../../reactNodeToFiberNode';
3
+ import { collectActionsFromChildrenPair } from './fromChildrenPair';
4
+ import { toFiberChildren } from '../fibers';
5
+ /**
6
+ * 1. Runs a component
7
+ * 2. Collects and returns a list of actions needed to actualize it
8
+ *
9
+ * Throws when the given component is not invalidated.
10
+ */
11
+ export const collectActionsFromComponent = (app, fiber,
12
+ /** When given this node's props are used to run the component. */
13
+ updated) => {
14
+ if (!app.invalidatedComponents.has(fiber)) {
15
+ throw new Error(`Component is not scheduled to update`);
16
+ }
17
+ app.invalidatedComponents.delete(fiber);
18
+ const newReactChildren = runComponent(fiber, updated);
19
+ const newFiber = jsxElementToFiberNode(newReactChildren, fiber, false);
20
+ return collectActionsFromChildrenPair(fiber, toFiberChildren(newFiber));
21
+ };
22
+ //# sourceMappingURL=fromComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fromComponent.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,GAAQ,EACR,KAAgB;AAChB,kEAAkE;AAClE,OAAyB,EACf,EAAE,CAAC;IACb,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,gBAAgB,GAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAc,qBAAqB,CAC/C,gBAAgB,EAChB,KAAK,EACL,KAAK,CACN,CAAC;IACF,OAAO,8BAA8B,CAAC,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;AAAA,CACzE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { App, FiberNode } from '../../../types';
2
+ import type { Action } from '../../../types/actions';
3
+ /**
4
+ * `l` and `r` are the same node, but `r` may have some updates. This method
5
+ * collects a list of actions that must be applied to convert `l` to `r`.
6
+ * This doesn't include removing or replacing the existing `l` node.
7
+ */
8
+ export declare const collectActionsFromFiberPair: (app: App, l: FiberNode, r: FiberNode) => Action[];
9
+ //# sourceMappingURL=fromFiberPair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fromFiberPair.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromFiberPair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EAEH,SAAS,EAIV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAgB,MAAM,4BAA4B,CAAC;AAKvE;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,oDAsFvC,CAAC"}
@@ -0,0 +1,125 @@
1
+ import { collectActionsFromChildrenPair } from './fromChildrenPair';
2
+ import { collectActionsFromComponent } from './fromComponent';
3
+ import { areFiberPropsEq } from '../compare/areFiberPropsEq';
4
+ /**
5
+ * `l` and `r` are the same node, but `r` may have some updates. This method
6
+ * collects a list of actions that must be applied to convert `l` to `r`.
7
+ * This doesn't include removing or replacing the existing `l` node.
8
+ */
9
+ export const collectActionsFromFiberPair = (app, l, r) => {
10
+ const actions = [];
11
+ const eqProps = areFiberPropsEq(l, r);
12
+ // Check if <context.Provider/>.value changed
13
+ if (l.role === 'context') {
14
+ const rr = r;
15
+ if (l.props.value !== rr.props.value) {
16
+ invalidateContextValue(app, l, rr);
17
+ }
18
+ }
19
+ if (l.type === 'tag' || l.type === 'fragment') {
20
+ actions.push(...collectActionsFromChildrenPair(l, r.children));
21
+ }
22
+ if (eqProps &&
23
+ // Component may have the same props, but changed internal state
24
+ !app.invalidatedComponents.has(l)) {
25
+ return actions; // No updates needed.
26
+ }
27
+ // Everything below assume changes in props
28
+ switch (r.type) {
29
+ case 'text':
30
+ actions.push({
31
+ type: 'SetText',
32
+ fiber: l,
33
+ text: r.props.text, // It's the only TextFiberNode props
34
+ });
35
+ break;
36
+ case 'tag':
37
+ actions.push({
38
+ type: 'SetProps', // just l.props = r.props
39
+ fiber: l,
40
+ props: r.props,
41
+ });
42
+ actions.push(...collectActionsFromTagAttrs(l, r));
43
+ break;
44
+ case 'component':
45
+ // One of the l-component props was updated -> run the component.
46
+ app.invalidatedComponents.add(l);
47
+ if (!eqProps) {
48
+ actions.push({
49
+ type: 'SetProps', // just l.props = r.props
50
+ fiber: l,
51
+ props: r.props,
52
+ });
53
+ }
54
+ actions.push(...collectActionsFromComponent(app, l, r));
55
+ break;
56
+ case 'fragment': {
57
+ if (r.role === 'context') {
58
+ actions.push({
59
+ type: 'SetProps',
60
+ fiber: l,
61
+ props: r.props,
62
+ });
63
+ break;
64
+ }
65
+ throw new Error(`Unsupported fragment props format. Role: ${l.role}`);
66
+ }
67
+ default:
68
+ throw new Error(`${l.type} is not supported in updateActions`);
69
+ }
70
+ return actions;
71
+ };
72
+ /**
73
+ * Returns a list of actions needed to sync `r` & `l` tag attributes, refs, and
74
+ * event handlers.
75
+ */
76
+ const collectActionsFromTagAttrs = (l, r) => {
77
+ const actions = [];
78
+ const lProps = l.props;
79
+ const rProps = r.props;
80
+ for (const [k, rv] of Object.entries(rProps)) {
81
+ const lv = lProps[k];
82
+ if (lv !== rv) {
83
+ actions.push({
84
+ type: 'SetAttr',
85
+ fiber: l,
86
+ name: k,
87
+ value: rv,
88
+ });
89
+ }
90
+ }
91
+ for (const k of Object.keys(lProps)) {
92
+ if (!(k in rProps)) {
93
+ actions.push({
94
+ type: 'SetAttr',
95
+ fiber: l,
96
+ name: k,
97
+ value: undefined,
98
+ });
99
+ }
100
+ }
101
+ if (l.ref !== r.ref) {
102
+ actions.push({
103
+ type: 'SetRef',
104
+ fiber: l,
105
+ ref: r.ref,
106
+ });
107
+ }
108
+ return actions;
109
+ };
110
+ /**
111
+ * The given context provider got an update for its `value` prop. We have to
112
+ * traverse through all of its context consumers and invalidate them.
113
+ */
114
+ const invalidateContextValue = (app, l, r) => {
115
+ // When we render child components we can't reach `r.fiber.props`, while
116
+ // `l.fiber.props` are obsolete until we call `SetProps` later in
117
+ // `applyActions`. Therefore, save it in temporary storage.
118
+ app.tempContext.set(l.id, r.props.value);
119
+ // Since we can't guarantee that all provider-consumers will be invalidated
120
+ // naturally, we must invalidate them manually:
121
+ for (const childCompFiber of l.data.consumers) {
122
+ app.invalidatedComponents.add(childCompFiber);
123
+ }
124
+ };
125
+ //# sourceMappingURL=fromFiberPair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fromFiberPair.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromFiberPair.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,GAAQ,EACR,CAAY,EACZ,CAAY,EACF,EAAE,CAAC;IACb,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEtC,6CAA6C;IAC7C,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,EAAE,GAAG,CAAqB,CAAC;QACjC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACrC,sBAAsB,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,IAAI,CAAC,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,GAAG,8BAA8B,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,IACE,OAAO;QACP,gEAAgE;QAChE,CAAC,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,EACjC,CAAC;QACD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SAClC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AAAA,CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,sBAAsB,GAAG,CAC7B,GAAQ,EACR,CAAmB,EACnB,CAAmB,EACnB,EAAE,CAAC;IACH,wEAAwE;IACxE,iEAAiE;IACjE,2DAA2D;IAC3D,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzC,2EAA2E;IAC3E,+CAA+C;IAC/C,KAAK,MAAM,cAAc,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QAC9C,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC;AAAA,CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Action } from '../../../types/actions';
2
+ import { type FiberNode } from '../../../types';
3
+ /**
4
+ * Prepares a list of actions allowing to create the given fiber node in DOM.
5
+ */
6
+ export declare const collectActionsFromNewFiber: (fiber: FiberNode) => Action[];
7
+ //# sourceMappingURL=fromNewFiber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fromNewFiber.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromNewFiber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAgB,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;GAEG;AACH,eAAO,MAAM,0BAA0B,gCA6CtC,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { assertsTagAttrValue } from '../typeGuards';
2
+ /**
3
+ * Prepares a list of actions allowing to create the given fiber node in DOM.
4
+ */
5
+ export const collectActionsFromNewFiber = (fiber) => {
6
+ switch (fiber.type) {
7
+ case 'component':
8
+ case 'fragment':
9
+ return [
10
+ { type: 'CreateComment', fiber, mode: 'begin' },
11
+ ...fiber.children.map((f) => collectActionsFromNewFiber(f)).flat(),
12
+ { type: 'CreateComment', fiber, mode: 'end' },
13
+ ];
14
+ case 'text':
15
+ return [{ type: 'CreateText', fiber }];
16
+ case 'null':
17
+ return [{ type: 'CreateComment', fiber, mode: 'null' }];
18
+ case 'tag': {
19
+ const actions = [{ type: 'CreateTag', fiber }];
20
+ for (const [k, v] of Object.entries(fiber.props ?? EMPTY)) {
21
+ assertsTagAttrValue(v);
22
+ actions.push({
23
+ type: 'SetAttr',
24
+ fiber,
25
+ name: k,
26
+ value: v,
27
+ });
28
+ }
29
+ if (fiber.ref) {
30
+ actions.push({
31
+ type: 'SetRef',
32
+ fiber,
33
+ ref: fiber.ref,
34
+ dontUnsetRef: true,
35
+ });
36
+ }
37
+ for (const child of fiber.children) {
38
+ actions.push(...collectActionsFromNewFiber(child));
39
+ }
40
+ return actions;
41
+ }
42
+ }
43
+ };
44
+ const EMPTY = {};
45
+ //# sourceMappingURL=fromNewFiber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fromNewFiber.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromNewFiber.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAAgB,EAAY,EAAE,CAAC;IACxE,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,WAAW,CAAC;QACjB,KAAK,UAAU;YACb,OAAO;gBACL,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE;gBAC/C,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBAClE,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;aAC9C,CAAC;QAEJ,KAAK,MAAM;YACT,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;QAEzC,KAAK,MAAM;YACT,OAAO,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAE1D,KAAK,KAAK,EAAE,CAAC;YACX,MAAM,OAAO,GAAa,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;YAEzD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,EAAE,CAAC;gBAC1D,mBAAmB,CAAC,CAAC,CAAC,CAAC;gBACvB,OAAO,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,SAAS;oBACf,KAAK;oBACL,IAAI,EAAE,CAAC;oBACP,KAAK,EAAE,CAAC;iBACT,CAAC,CAAC;YACL,CAAC;YAED,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,QAAQ;oBACd,KAAK;oBACL,GAAG,EAAE,KAAK,CAAC,GAA0B;oBACrC,YAAY,EAAE,IAAI;iBACnB,CAAC,CAAC;YACL,CAAC;YAED,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACnC,OAAO,CAAC,IAAI,CAAC,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC;YACrD,CAAC;YAED,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;AAAA,CACF,CAAC;AAEF,MAAM,KAAK,GAAG,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const buildCommentText: (mode: string, id: number) => string;
2
+ export declare const buildComment: (mode: string, id: number) => Comment;
3
+ //# sourceMappingURL=comments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/comments.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,sCACV,CAAC;AAEpB,eAAO,MAAM,YAAY,uCACgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export const buildCommentText = (mode, id) => `r:${mode}:${id}`;
2
+ export const buildComment = (mode, id) => new Comment(buildCommentText(mode, id));
3
+ //# sourceMappingURL=comments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments.js","sourceRoot":"","sources":["../../../src/core/reconciliation/comments.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,EAAU,EAAU,EAAE,CACnE,KAAK,IAAI,IAAI,EAAE,EAAE,CAAC;AAEpB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAU,EAAW,EAAE,CAChE,IAAI,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { FiberNode } from '../../../types';
2
+ /**
3
+ * Returns true when the `left` node can be reused to reflect the `right` node.
4
+ * It means they must share their `type`, `key`, `role`, `tag` and `component` fields.
5
+ */
6
+ export declare const areFiberNodesEq: (left: FiberNode | null, right: FiberNode | null) => boolean;
7
+ //# sourceMappingURL=areFiberNodesEq.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"areFiberNodesEq.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/compare/areFiberNodesEq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,eAAe,8DAY3B,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Returns true when the `left` node can be reused to reflect the `right` node.
3
+ * It means they must share their `type`, `key`, `role`, `tag` and `component` fields.
4
+ */
5
+ export const areFiberNodesEq = (left, right) => {
6
+ if (!left || !right)
7
+ return left === right;
8
+ if (left.type !== right.type || left.role !== right.role)
9
+ return false;
10
+ const lNode = left.tag ?? left.component;
11
+ const rNode = right.tag ?? right.component;
12
+ return lNode === rNode;
13
+ };
14
+ //# sourceMappingURL=areFiberNodesEq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"areFiberNodesEq.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/compare/areFiberNodesEq.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,IAAsB,EACtB,KAAuB,EACd,EAAE,CAAC;IACZ,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,KAAK,KAAK,CAAC;IAE3C,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAEvE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC;IACzC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC;IAE3C,OAAO,KAAK,KAAK,KAAK,CAAC;AAAA,CACxB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { FiberNode } from '../../../types';
2
+ /**
3
+ * Returns false when `r` !== `l` and requires updating. This doesn't involve
4
+ * any `children` checks.
5
+ */
6
+ export declare const areFiberPropsEq: (l: FiberNode, r: FiberNode) => boolean;
7
+ //# sourceMappingURL=areFiberPropsEq.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"areFiberPropsEq.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/compare/areFiberPropsEq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,oBAAoB,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,eAAe,yCAa3B,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Returns false when `r` !== `l` and requires updating. This doesn't involve
3
+ * any `children` checks.
4
+ */
5
+ export const areFiberPropsEq = (l, r) => {
6
+ if (l.ref !== r.ref) {
7
+ return false;
8
+ }
9
+ const lProps = (l.props ?? EMPTY);
10
+ const rProps = (r.props ?? EMPTY);
11
+ const lPropKeys = Object.keys(lProps);
12
+ if (lPropKeys.length !== Object.keys(rProps).length) {
13
+ return false;
14
+ }
15
+ return lPropKeys.every((k) => lProps[k] === rProps[k]);
16
+ };
17
+ const EMPTY = {};
18
+ //# sourceMappingURL=areFiberPropsEq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"areFiberPropsEq.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/compare/areFiberPropsEq.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAY,EAAE,CAAY,EAAW,EAAE,CAAC;IACtE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAiB,CAAC;IAClD,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAiB,CAAC;IAClD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,SAAS,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;QACpD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAAA,CACxD,CAAC;AAEF,MAAM,KAAK,GAAG,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { App, EffectMode } from '../../types';
2
+ /**
3
+ * Adds to a planner the given effect.
4
+ * - `refs` & `layout` effects are run in the same microtask queue
5
+ * - `normal` effects are normally run in the next microtask, but sometimes can
6
+ * be run in the same microtask queue (when one of the ref or layout effects
7
+ * invalidates a component).
8
+ */
9
+ export declare const scheduleEffect: (app: App, effect: () => void, mode: EffectMode) => void;
10
+ /**
11
+ * Run scheduled effects one-by-one from the given queue.
12
+ */
13
+ export declare const runEffects: (app: App, mode: EffectMode) => void;
14
+ //# sourceMappingURL=effects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/effects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,0DAM1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,sCAatB,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Adds to a planner the given effect.
3
+ * - `refs` & `layout` effects are run in the same microtask queue
4
+ * - `normal` effects are normally run in the next microtask, but sometimes can
5
+ * be run in the same microtask queue (when one of the ref or layout effects
6
+ * invalidates a component).
7
+ */
8
+ export const scheduleEffect = (app, effect, mode) => {
9
+ app.effects[mode].push(effect);
10
+ };
11
+ /**
12
+ * Run scheduled effects one-by-one from the given queue.
13
+ */
14
+ export const runEffects = (app, mode) => {
15
+ if (mode === 'layout') {
16
+ // "refs" effects are essentially layout effects that should be started
17
+ // before user-defined layout effects.
18
+ runEffects(app, 'refs');
19
+ }
20
+ const effects = app.effects[mode];
21
+ app.effects[mode] = [];
22
+ for (const fn of effects) {
23
+ fn();
24
+ }
25
+ };
26
+ //# sourceMappingURL=effects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects.js","sourceRoot":"","sources":["../../../src/core/reconciliation/effects.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,GAAQ,EACR,MAAkB,EAClB,IAAgB,EACV,EAAE,CAAC;IACT,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAAA,CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,IAAgB,EAAE,EAAE,CAAC;IACxD,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,uEAAuE;QACvE,sCAAsC;QACtC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IAEvB,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;QACzB,EAAE,EAAE,CAAC;IACP,CAAC;AAAA,CACF,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { FiberNode } from '../../types';
2
+ /**
3
+ * Theoretically, fiber can't change its level. So this function linearly
4
+ * calculates the fiber's level and caches the result in fiber.level.
5
+ */
6
+ export declare const getFiberLevel: (fiber: FiberNode) => number;
7
+ /** To avoid mess and havoc, we keep new DOM nodes in a temporary
8
+ * <x-container/> DOM node until the Relayout action comes into play. */
9
+ export declare const FAKE_CONTAINER_TAG = "x-container";
10
+ /** Pseudo tagName for fragment JSX.Elements. Not used anywhere but in
11
+ * jsxElementToFiberNode to differentiate fragments from tags. */
12
+ export declare const FRAGMENT_TAG = "x-fragment";
13
+ export declare const createFiberNode: (parent: FiberNode) => {
14
+ id: number;
15
+ appId: number;
16
+ type: null;
17
+ role: null;
18
+ parent: FiberNode;
19
+ level: null;
20
+ key: null;
21
+ ref: null;
22
+ component: null;
23
+ element: null;
24
+ props: null;
25
+ tag: null;
26
+ children: never[];
27
+ data: null;
28
+ };
29
+ export declare const NULL_FIBER: FiberNode;
30
+ /**
31
+ * A small optimization. To avoid having `children: [[node]]`, we may flatten
32
+ * it. But this can only be done with non-keyed regular fragments.
33
+ */
34
+ export declare const toFiberChildren: (fiber: FiberNode) => FiberNode[];
35
+ //# sourceMappingURL=fibers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fibers.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/fibers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;;GAGG;AACH,eAAO,MAAM,aAAa,8BAOzB,CAAC;AAEF;wEACwE;AACxE,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD;iEACiE;AACjE,eAAO,MAAM,YAAY,eAAe,CAAC;AAGzC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;CAgBmB,CAAC;AAEhD,eAAO,MAAM,UAAU,WAA+B,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,eAAe,mCAU3B,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { nullthrows } from '../../utils';
2
+ /**
3
+ * Theoretically, fiber can't change its level. So this function linearly
4
+ * calculates the fiber's level and caches the result in fiber.level.
5
+ */
6
+ export const getFiberLevel = (fiber) => {
7
+ if (fiber.level !== null) {
8
+ return fiber.level;
9
+ }
10
+ fiber.level = getFiberLevel(fiber.parent) + 1;
11
+ return fiber.level;
12
+ };
13
+ /** To avoid mess and havoc, we keep new DOM nodes in a temporary
14
+ * <x-container/> DOM node until the Relayout action comes into play. */
15
+ export const FAKE_CONTAINER_TAG = 'x-container';
16
+ /** Pseudo tagName for fragment JSX.Elements. Not used anywhere but in
17
+ * jsxElementToFiberNode to differentiate fragments from tags. */
18
+ export const FRAGMENT_TAG = 'x-fragment';
19
+ let fiberIdx = 0;
20
+ export const createFiberNode = (parent) => ({
21
+ id: ++fiberIdx,
22
+ appId: parent.appId,
23
+ type: null,
24
+ role: null,
25
+ parent,
26
+ level: null,
27
+ key: null,
28
+ ref: null,
29
+ component: null,
30
+ element: null,
31
+ props: null,
32
+ tag: null,
33
+ children: [],
34
+ data: null,
35
+ });
36
+ export const NULL_FIBER = null;
37
+ /**
38
+ * A small optimization. To avoid having `children: [[node]]`, we may flatten
39
+ * it. But this can only be done with non-keyed regular fragments.
40
+ */
41
+ export const toFiberChildren = (fiber) => {
42
+ if (fiber.type === 'fragment' && fiber.role === null && fiber.key === null) {
43
+ for (const child of fiber.children) {
44
+ // Fix the parent, since we moved them 1 level up.
45
+ child.parent = nullthrows(child.parent.parent);
46
+ }
47
+ return fiber.children;
48
+ }
49
+ return [fiber];
50
+ };
51
+ //# sourceMappingURL=fibers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fibers.js","sourceRoot":"","sources":["../../../src/core/reconciliation/fibers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAgB,EAAU,EAAE,CAAC;IACzD,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9C,OAAO,KAAK,CAAC,KAAK,CAAC;AAAA,CACpB,CAAC;AAEF;wEACwE;AACxE,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAEhD;iEACiE;AACjE,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC;AAEzC,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAiB,EAAE,EAAE,CACnD,CAAC;IACC,EAAE,EAAE,EAAE,QAAQ;IACd,KAAK,EAAE,MAAM,CAAC,KAAK;IACnB,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,MAAM;IACN,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,IAAI;IACT,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,IAAI;CACX,CAA4C,CAAC;AAEhD,MAAM,CAAC,MAAM,UAAU,GAAG,IAA4B,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAgB,EAAe,EAAE,CAAC;IAChE,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;QAC3E,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnC,kDAAkD;YAClD,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,CAAC;AAAA,CAChB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { FiberNode } from '../../types';
2
+ /**
3
+ * Adds the given component to the update queue (`invalidatedComponents`).
4
+ * Schedules a new render cycle if one isn't scheduled already. Throws an error
5
+ * if invalidation is happening in the wrong app state.
6
+ */
7
+ export declare const invalidateFiber: (fiber: FiberNode) => void;
8
+ //# sourceMappingURL=invalidateFiber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalidateFiber.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/invalidateFiber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD;;;;GAIG;AACH,eAAO,MAAM,eAAe,4BAuB3B,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { getAppByFiber } from './app';
2
+ import { reactRender } from './render';
3
+ /**
4
+ * Adds the given component to the update queue (`invalidatedComponents`).
5
+ * Schedules a new render cycle if one isn't scheduled already. Throws an error
6
+ * if invalidation is happening in the wrong app state.
7
+ */
8
+ export const invalidateFiber = (fiber) => {
9
+ if (fiber.type !== 'component') {
10
+ throw new Error(`Cannot invalidate a non-component fiber (${fiber.type})`);
11
+ }
12
+ const app = getAppByFiber(fiber);
13
+ switch (app.state) {
14
+ case 'idle':
15
+ app.invalidatedComponents.add(fiber);
16
+ app.state = 'scheduled';
17
+ queueMicrotask(() => reactRender(app));
18
+ break;
19
+ case 'scheduled':
20
+ case 'effects':
21
+ case 'layoutEffects':
22
+ app.invalidatedComponents.add(fiber);
23
+ break;
24
+ case 'render':
25
+ throw new Error(`Don't update state during the render phase`);
26
+ }
27
+ };
28
+ //# sourceMappingURL=invalidateFiber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalidateFiber.js","sourceRoot":"","sources":["../../../src/core/reconciliation/invalidateFiber.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAgB,EAAQ,EAAE,CAAC;IACzD,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,4CAA4C,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAEjC,QAAQ,GAAG,CAAC,KAAK,EAAE,CAAC;QAClB,KAAK,MAAM;YACT,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACrC,GAAG,CAAC,KAAK,GAAG,WAAW,CAAC;YACxB,cAAc,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;YACvC,MAAM;QAER,KAAK,WAAW,CAAC;QACjB,KAAK,SAAS,CAAC;QACf,KAAK,eAAe;YAClB,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACrC,MAAM;QAER,KAAK,QAAQ;YACX,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAClE,CAAC;AAAA,CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { AppOptions } from '../../types';
2
+ /**
3
+ * Mounts an app (`jsxElement`) to the given DOM node (`container`). Returns
4
+ * a function that destroys the app and removes all of its DOM nodes.
5
+ */
6
+ export declare const mount: (container: HTMLElement, jsxElement: import("../../index.js").JsxElement, options: AppOptions) => () => void;
7
+ //# sourceMappingURL=mount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EAGX,MAAM,oBAAoB,CAAC;AAU5B;;;GAGG;AACH,eAAO,MAAM,KAAK,4GAsCjB,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { jsxElementToFiberNode } from '../reactNodeToFiberNode';
2
+ import { collectActionsFromNewFiber } from './collect/fromNewFiber';
3
+ import { validateTree } from './validateTree';
4
+ import { applyActions } from './applyActions';
5
+ import { postCommit } from './postCommit';
6
+ import { removeApp, registerApp } from './app';
7
+ import { createFiberNode, toFiberChildren } from './fibers';
8
+ /**
9
+ * Mounts an app (`jsxElement`) to the given DOM node (`container`). Returns
10
+ * a function that destroys the app and removes all of its DOM nodes.
11
+ */
12
+ export const mount = (container, jsxElement, options) => {
13
+ container.innerHTML = '';
14
+ const app = registerApp((appId) => ({
15
+ id: appId,
16
+ root: createRootFiber(appId),
17
+ effects: { refs: [], layout: [], normal: [] },
18
+ invalidatedComponents: new Set(),
19
+ state: 'render',
20
+ testMode: !!options.testMode,
21
+ tempContext: new Map(),
22
+ }));
23
+ const content = jsxElementToFiberNode(jsxElement, app.root, true);
24
+ app.root.children = toFiberChildren(content);
25
+ app.root.element = container;
26
+ const actions = collectActionsFromNewFiber(app.root).flat();
27
+ applyActions(app, actions);
28
+ if (app.testMode)
29
+ validateTree(app.root);
30
+ postCommit(app, 0);
31
+ return function destroyApp() {
32
+ app.invalidatedComponents.clear();
33
+ app.effects.refs = [];
34
+ app.effects.layout = [];
35
+ app.effects.normal = [];
36
+ applyActions(app, [{ type: 'Remove', fiber: app.root }]); // add a test?
37
+ app.state = 'killed';
38
+ removeApp(app.id);
39
+ };
40
+ };
41
+ /**
42
+ * A special fiber node - the only one that doesn't have a real parent fiber.
43
+ * Used as the root of the fiber tree.
44
+ */
45
+ const createRootFiber = (appId) => ({
46
+ ...createFiberNode({ appId }),
47
+ type: 'tag',
48
+ tag: 'root',
49
+ level: 0,
50
+ data: { events: {} },
51
+ props: {},
52
+ });
53
+ //# sourceMappingURL=mount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount.js","sourceRoot":"","sources":["../../../src/core/reconciliation/mount.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,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AG,EAAE,CAAC;QAExB,YAAY,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc;QACxE,GAAG,CAAC,KAAK,GAAG,QAAQ,CAAC;QACrB,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAAA,CACnB,CAAC;AAAA,CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,eAAe,GAAG,CAAC,KAAa,EAAgB,EAAE,CAAC,CAAC;IACxD,GAAG,eAAe,CAAC,EAAE,KAAK,EAA0B,CAAC;IACrD,IAAI,EAAE,KAAK;IACX,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACpB,KAAK,EAAE,EAAE;CACV,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { App } from '../../types';
2
+ /**
3
+ * A stage that happens after we've applied all necessary DOM and fiber changes
4
+ * in applyActions (the "commit" phase). In this stage we:
5
+ * - run all kinds of effects
6
+ * - when needed, schedule another render cycle (if effects updated component
7
+ * state)
8
+ * - or move the app to the idle stage
9
+ */
10
+ export declare function postCommit(app: App, depth: number): void;
11
+ //# sourceMappingURL=postCommit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postCommit.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/postCommit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAI9C;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,QA0CjD"}