@faiwer/react 0.8.3 → 0.9.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 (239) hide show
  1. package/README.md +20 -14
  2. package/dist/core/Children.d.ts +11 -0
  3. package/dist/core/Children.d.ts.map +1 -0
  4. package/dist/core/Children.js +35 -0
  5. package/dist/core/Children.js.map +1 -0
  6. package/dist/core/actions/applyAction.d.ts.map +1 -1
  7. package/dist/core/actions/applyAction.js +2 -0
  8. package/dist/core/actions/applyAction.js.map +1 -1
  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 +107 -5
  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 +4 -0
  25. package/dist/core/actions/dom/attributes.d.ts.map +1 -0
  26. package/dist/core/actions/dom/attributes.js +56 -0
  27. package/dist/core/actions/dom/attributes.js.map +1 -0
  28. package/dist/core/actions/dom/css.d.ts +6 -0
  29. package/dist/core/actions/dom/css.d.ts.map +1 -0
  30. package/dist/core/actions/dom/css.js +54 -0
  31. package/dist/core/actions/dom/css.js.map +1 -0
  32. package/dist/core/actions/dom/events.d.ts +3 -0
  33. package/dist/core/actions/dom/events.d.ts.map +1 -0
  34. package/dist/core/actions/dom/events.js +45 -0
  35. package/dist/core/actions/dom/events.js.map +1 -0
  36. package/dist/core/actions/dom/svg.d.ts +7 -0
  37. package/dist/core/actions/dom/svg.d.ts.map +1 -0
  38. package/dist/core/actions/dom/svg.js +76 -0
  39. package/dist/core/actions/dom/svg.js.map +1 -0
  40. package/dist/core/actions/dom/value.d.ts +17 -0
  41. package/dist/core/actions/dom/value.d.ts.map +1 -0
  42. package/dist/core/actions/dom/value.js +204 -0
  43. package/dist/core/actions/dom/value.js.map +1 -0
  44. package/dist/core/actions/helpers.d.ts +18 -11
  45. package/dist/core/actions/helpers.d.ts.map +1 -1
  46. package/dist/core/actions/helpers.js +78 -68
  47. package/dist/core/actions/helpers.js.map +1 -1
  48. package/dist/core/actions/relayout.action.d.ts +2 -1
  49. package/dist/core/actions/relayout.action.d.ts.map +1 -1
  50. package/dist/core/actions/relayout.action.js +119 -30
  51. package/dist/core/actions/relayout.action.js.map +1 -1
  52. package/dist/core/actions/remove.action.d.ts +3 -2
  53. package/dist/core/actions/remove.action.d.ts.map +1 -1
  54. package/dist/core/actions/remove.action.js +22 -18
  55. package/dist/core/actions/remove.action.js.map +1 -1
  56. package/dist/core/actions/replace.action.d.ts +1 -1
  57. package/dist/core/actions/replace.action.d.ts.map +1 -1
  58. package/dist/core/actions/replace.action.js +36 -11
  59. package/dist/core/actions/replace.action.js.map +1 -1
  60. package/dist/core/actions/setAttr.action.d.ts +1 -1
  61. package/dist/core/actions/setAttr.action.d.ts.map +1 -1
  62. package/dist/core/actions/setAttr.action.js +55 -87
  63. package/dist/core/actions/setAttr.action.js.map +1 -1
  64. package/dist/core/actions/setProps.action.d.ts.map +1 -1
  65. package/dist/core/actions/setProps.action.js +2 -1
  66. package/dist/core/actions/setProps.action.js.map +1 -1
  67. package/dist/core/actions/setRef.action.d.ts +1 -1
  68. package/dist/core/actions/setRef.action.d.ts.map +1 -1
  69. package/dist/core/actions/setRef.action.js +5 -6
  70. package/dist/core/actions/setRef.action.js.map +1 -1
  71. package/dist/core/actions/setText.action.d.ts.map +1 -1
  72. package/dist/core/actions/setText.action.js +3 -3
  73. package/dist/core/actions/setText.action.js.map +1 -1
  74. package/dist/core/classComponent.d.ts +33 -0
  75. package/dist/core/classComponent.d.ts.map +1 -0
  76. package/dist/core/classComponent.js +127 -0
  77. package/dist/core/classComponent.js.map +1 -0
  78. package/dist/core/compact.d.ts +10 -29
  79. package/dist/core/compact.d.ts.map +1 -1
  80. package/dist/core/compact.js +12 -100
  81. package/dist/core/compact.js.map +1 -1
  82. package/dist/core/components.d.ts +2 -2
  83. package/dist/core/components.d.ts.map +1 -1
  84. package/dist/core/components.js +22 -5
  85. package/dist/core/components.js.map +1 -1
  86. package/dist/core/createElement.d.ts +9 -9
  87. package/dist/core/createElement.d.ts.map +1 -1
  88. package/dist/core/createElement.js +19 -3
  89. package/dist/core/createElement.js.map +1 -1
  90. package/dist/core/createRoot.js.map +1 -1
  91. package/dist/core/reactNodeToFiberNode.d.ts.map +1 -1
  92. package/dist/core/reactNodeToFiberNode.js +6 -1
  93. package/dist/core/reactNodeToFiberNode.js.map +1 -1
  94. package/dist/core/reconciliation/app.js +3 -3
  95. package/dist/core/reconciliation/app.js.map +1 -1
  96. package/dist/core/reconciliation/collect/fromApp.d.ts.map +1 -1
  97. package/dist/core/reconciliation/collect/fromApp.js +3 -27
  98. package/dist/core/reconciliation/collect/fromApp.js.map +1 -1
  99. package/dist/core/reconciliation/collect/fromChildrenPair.d.ts.map +1 -1
  100. package/dist/core/reconciliation/collect/fromChildrenPair.js +24 -15
  101. package/dist/core/reconciliation/collect/fromChildrenPair.js.map +1 -1
  102. package/dist/core/reconciliation/collect/fromComponent.d.ts +2 -2
  103. package/dist/core/reconciliation/collect/fromComponent.d.ts.map +1 -1
  104. package/dist/core/reconciliation/collect/fromComponent.js +4 -8
  105. package/dist/core/reconciliation/collect/fromComponent.js.map +1 -1
  106. package/dist/core/reconciliation/collect/fromFiberPair.d.ts.map +1 -1
  107. package/dist/core/reconciliation/collect/fromFiberPair.js +6 -4
  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.map +1 -1
  113. package/dist/core/reconciliation/effects.js +0 -5
  114. package/dist/core/reconciliation/effects.js.map +1 -1
  115. package/dist/core/reconciliation/errors/ReactError.d.ts +7 -0
  116. package/dist/core/reconciliation/errors/ReactError.d.ts.map +1 -0
  117. package/dist/core/reconciliation/errors/ReactError.js +26 -0
  118. package/dist/core/reconciliation/errors/ReactError.js.map +1 -0
  119. package/dist/core/reconciliation/errors/stack.d.ts +9 -0
  120. package/dist/core/reconciliation/errors/stack.d.ts.map +1 -0
  121. package/dist/core/reconciliation/errors/stack.js +80 -0
  122. package/dist/core/reconciliation/errors/stack.js.map +1 -0
  123. package/dist/core/reconciliation/fibers.d.ts +7 -0
  124. package/dist/core/reconciliation/fibers.d.ts.map +1 -1
  125. package/dist/core/reconciliation/fibers.js +9 -2
  126. package/dist/core/reconciliation/fibers.js.map +1 -1
  127. package/dist/core/reconciliation/heap.d.ts +18 -0
  128. package/dist/core/reconciliation/heap.d.ts.map +1 -0
  129. package/dist/core/reconciliation/heap.js +81 -0
  130. package/dist/core/reconciliation/heap.js.map +1 -0
  131. package/dist/core/reconciliation/invalidateFiber.d.ts.map +1 -1
  132. package/dist/core/reconciliation/invalidateFiber.js +10 -4
  133. package/dist/core/reconciliation/invalidateFiber.js.map +1 -1
  134. package/dist/core/reconciliation/mount.d.ts.map +1 -1
  135. package/dist/core/reconciliation/mount.js +17 -7
  136. package/dist/core/reconciliation/mount.js.map +1 -1
  137. package/dist/core/reconciliation/postCommit.d.ts +1 -1
  138. package/dist/core/reconciliation/postCommit.d.ts.map +1 -1
  139. package/dist/core/reconciliation/postCommit.js +19 -4
  140. package/dist/core/reconciliation/postCommit.js.map +1 -1
  141. package/dist/core/reconciliation/queue.d.ts +21 -0
  142. package/dist/core/reconciliation/queue.d.ts.map +1 -0
  143. package/dist/core/reconciliation/queue.js +55 -0
  144. package/dist/core/reconciliation/queue.js.map +1 -0
  145. package/dist/core/reconciliation/render.js +5 -5
  146. package/dist/core/reconciliation/render.js.map +1 -1
  147. package/dist/core/reconciliation/runFiberComponents.d.ts.map +1 -1
  148. package/dist/core/reconciliation/runFiberComponents.js +2 -1
  149. package/dist/core/reconciliation/runFiberComponents.js.map +1 -1
  150. package/dist/core/reconciliation/typeGuards.d.ts +9 -1
  151. package/dist/core/reconciliation/typeGuards.d.ts.map +1 -1
  152. package/dist/core/reconciliation/typeGuards.js +25 -0
  153. package/dist/core/reconciliation/typeGuards.js.map +1 -1
  154. package/dist/core/reconciliation/validateApp.d.ts +3 -0
  155. package/dist/core/reconciliation/validateApp.d.ts.map +1 -0
  156. package/dist/core/reconciliation/validateApp.js +74 -0
  157. package/dist/core/reconciliation/validateApp.js.map +1 -0
  158. package/dist/hooks/helpers.d.ts +2 -2
  159. package/dist/hooks/helpers.d.ts.map +1 -1
  160. package/dist/hooks/helpers.js +3 -2
  161. package/dist/hooks/helpers.js.map +1 -1
  162. package/dist/hooks/index.d.ts +1 -1
  163. package/dist/hooks/index.d.ts.map +1 -1
  164. package/dist/hooks/index.js +1 -1
  165. package/dist/hooks/index.js.map +1 -1
  166. package/dist/hooks/useContext.d.ts.map +1 -1
  167. package/dist/hooks/useContext.js +16 -0
  168. package/dist/hooks/useContext.js.map +1 -1
  169. package/dist/hooks/useEffect.d.ts +2 -1
  170. package/dist/hooks/useEffect.d.ts.map +1 -1
  171. package/dist/hooks/useEffect.js +1 -1
  172. package/dist/hooks/useEffect.js.map +1 -1
  173. package/dist/hooks/useRef.d.ts +8 -3
  174. package/dist/hooks/useRef.d.ts.map +1 -1
  175. package/dist/hooks/useRef.js +27 -0
  176. package/dist/hooks/useRef.js.map +1 -1
  177. package/dist/hooks/useState.d.ts +1 -1
  178. package/dist/hooks/useState.d.ts.map +1 -1
  179. package/dist/hooks/useState.js +24 -1
  180. package/dist/hooks/useState.js.map +1 -1
  181. package/dist/index.d.ts +8 -1
  182. package/dist/index.d.ts.map +1 -1
  183. package/dist/index.js +5 -0
  184. package/dist/index.js.map +1 -1
  185. package/dist/jsx-dev-runtime.d.ts +4 -4
  186. package/dist/jsx-dev-runtime.d.ts.map +1 -1
  187. package/dist/jsx-dev-runtime.js +4 -4
  188. package/dist/jsx-dev-runtime.js.map +1 -1
  189. package/dist/jsx-runtime.d.ts +3 -3
  190. package/dist/jsx-runtime.d.ts.map +1 -1
  191. package/dist/jsx-runtime.js +3 -3
  192. package/dist/jsx-runtime.js.map +1 -1
  193. package/dist/jsx.d.ts +176 -36
  194. package/dist/mocks.d.ts +21 -0
  195. package/dist/mocks.d.ts.map +1 -0
  196. package/dist/mocks.js +27 -0
  197. package/dist/mocks.js.map +1 -0
  198. package/dist/react.d.ts +46 -0
  199. package/dist/types/actions.d.ts +12 -4
  200. package/dist/types/actions.d.ts.map +1 -1
  201. package/dist/types/app.d.ts +17 -2
  202. package/dist/types/app.d.ts.map +1 -1
  203. package/dist/types/attributes.d.ts +42 -0
  204. package/dist/types/attributes.d.ts.map +1 -0
  205. package/dist/types/attributes.js +2 -0
  206. package/dist/types/attributes.js.map +1 -0
  207. package/dist/types/common.d.ts +13 -0
  208. package/dist/types/common.d.ts.map +1 -0
  209. package/dist/types/common.js +2 -0
  210. package/dist/types/common.js.map +1 -0
  211. package/dist/types/component.d.ts +5 -1
  212. package/dist/types/component.d.ts.map +1 -1
  213. package/dist/types/context.d.ts +3 -2
  214. package/dist/types/context.d.ts.map +1 -1
  215. package/dist/types/core.d.ts +17 -13
  216. package/dist/types/core.d.ts.map +1 -1
  217. package/dist/types/dom.d.ts +23 -27
  218. package/dist/types/dom.d.ts.map +1 -1
  219. package/dist/types/events.d.ts +31 -0
  220. package/dist/types/events.d.ts.map +1 -0
  221. package/dist/types/events.js +2 -0
  222. package/dist/types/events.js.map +1 -0
  223. package/dist/types/fiber.d.ts +31 -11
  224. package/dist/types/fiber.d.ts.map +1 -1
  225. package/dist/types/fiber.js +5 -1
  226. package/dist/types/fiber.js.map +1 -1
  227. package/dist/types/hooks.d.ts +8 -5
  228. package/dist/types/hooks.d.ts.map +1 -1
  229. package/dist/types/react.d.ts +35 -0
  230. package/dist/types/react.d.ts.map +1 -0
  231. package/dist/types/react.js +2 -0
  232. package/dist/types/react.js.map +1 -0
  233. package/dist/types/refs.d.ts +5 -8
  234. package/dist/types/refs.d.ts.map +1 -1
  235. package/package.json +15 -3
  236. package/dist/core/reconciliation/validateTree.d.ts +0 -6
  237. package/dist/core/reconciliation/validateTree.d.ts.map +0 -1
  238. package/dist/core/reconciliation/validateTree.js +0 -48
  239. package/dist/core/reconciliation/validateTree.js.map +0 -1
package/README.md CHANGED
@@ -6,6 +6,7 @@ A naive React implementation. Why? What's wrong with the existing one? Nothing.
6
6
 
7
7
  - JSX
8
8
  - Functional components
9
+ - Class components (limited)
9
10
  - Hooks:
10
11
  - `useState`
11
12
  - `useRef`
@@ -14,21 +15,30 @@ A naive React implementation. Why? What's wrong with the existing one? Nothing.
14
15
  - `useLayoutEffect`, `useEffect` (improved versions)
15
16
  - `useId`
16
17
  - `useContext`
17
- - Tag-based refs
18
+ - Refs
18
19
  - Context
19
20
  - Portals
20
21
  - Fragments
21
22
 
22
23
  ## Installation
23
24
 
24
- - `npm i --save @faiwer/react`
25
- - Update your `tsconfig.json`:
25
+ - `npm uninstall react react-dom @types/react @types/react-dom`
26
+ - `npm i --save react@npm:@faiwer/react`
27
+ - `npm i --save --force react-dom@npm:@faiwer/react-dom`
28
+ - You might need to update your `tsconfig.json` (no necessarily):
26
29
  ```json
27
30
  "compilerOptions": {
28
31
  "jsx": "react-jsx",
29
- "jsxImportSource": "@faiwer/react"
30
32
  }
31
33
  ```
34
+ Or use `"jsx": "preserve"`
35
+ - If you're using `eslint-plugin-react` than configure this in your .eslintrc:
36
+ ```json
37
+ "settings": {
38
+ "react": { "version": "19" } // not 'detect'
39
+ },
40
+ ```
41
+ - Good luck. If your project is big enough, I'm pretty sure you got a ton of type errors. Sorry :-)
32
42
 
33
43
  ### Usage
34
44
 
@@ -42,23 +52,19 @@ createRoot(container).render(<App />);
42
52
  ## TODO
43
53
 
44
54
  - 1st line
45
- - Events:
46
- - "capture"-kind of events
47
- - camelCase events
48
- - custom `onChange` like in ReactDOM
49
55
  - Error handling
50
- - Direct component refs, `forwardRef`, `useImperativeHandle`
51
- - 2nd line
52
- - prepare an NPM-package
53
- - 3rd line
54
- - `RunComponent` is not pure. Some hooks change the state during the rendering phase. Fix it.
55
56
  - `useReducer`
57
+ - 2rd line
58
+ - HMR
59
+ - Resolve "TODO: add a test" comments
60
+ - `runComponent` is not pure. Some hooks change the state during the rendering phase. Fix it.
61
+ - leverage `isStaticChildren` in `jsx()`
56
62
 
57
63
  ## It does NOT support
58
64
 
59
65
  … and probably never will:
60
66
 
61
- - Class Components
67
+ - Class Components: `getSnapshotBeforeUpdate`
62
68
  - Synthetic events
63
69
  - Portals:
64
70
  - Event bubbling from portals
@@ -0,0 +1,11 @@
1
+ import type { ElementNode, ScalarNode } from '../types';
2
+ type Children = {
3
+ count: (children: JSX.Element[]) => number;
4
+ only: (children: JSX.Element) => asserts children is ElementNode | ScalarNode;
5
+ forEach: (children: JSX.Element[], fn: (child: ElementNode | ScalarNode) => void, objThis?: unknown) => void;
6
+ map: <T>(chidlren: JSX.Element[], fn: (child: ElementNode | ScalarNode) => T, objThis?: unknown) => T[];
7
+ toArray: (children: JSX.Element[]) => Array<ElementNode | ScalarNode>;
8
+ };
9
+ export declare const Children: Children;
10
+ export {};
11
+ //# sourceMappingURL=Children.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Children.d.ts","sourceRoot":"","sources":["../../src/core/Children.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAElE,KAAK,QAAQ,GAAG;IACd,KAAK,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,MAAM,CAAC;IAC3C,IAAI,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,QAAQ,IAAI,WAAW,GAAG,UAAU,CAAC;IAC9E,OAAO,EAAE,CACP,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,EACvB,EAAE,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,KAAK,IAAI,EAC7C,OAAO,CAAC,EAAE,OAAO,KACd,IAAI,CAAC;IACV,GAAG,EAAE,CAAC,CAAC,EACL,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,EACvB,EAAE,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,KAAK,CAAC,EAC1C,OAAO,CAAC,EAAE,OAAO,KACd,CAAC,EAAE,CAAC;IACT,OAAO,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC;CACvE,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,QA6CtB,CAAC"}
@@ -0,0 +1,35 @@
1
+ export const Children = {
2
+ count: (children) => {
3
+ return Children.toArray(children).length;
4
+ },
5
+ forEach: (children, fn, objThis) => {
6
+ for (const child of children) {
7
+ if (Array.isArray(child)) {
8
+ Children.forEach(child, fn, objThis);
9
+ }
10
+ else {
11
+ fn.call(objThis, child);
12
+ }
13
+ }
14
+ },
15
+ map: (chidlren, fn, objThis) => {
16
+ const result = [];
17
+ Children.forEach(chidlren, (child) => {
18
+ result.push(fn.call(objThis, child));
19
+ }, objThis);
20
+ return result;
21
+ },
22
+ only(children) {
23
+ if (!Array.isArray(children)) {
24
+ children = [children];
25
+ }
26
+ const items = Children.toArray(children);
27
+ if (items.length !== 1) {
28
+ throw new Error(`Found ${items.length} children. Expected only one`);
29
+ }
30
+ },
31
+ toArray: (children) => {
32
+ return Children.map(children, (child) => child);
33
+ },
34
+ };
35
+ //# sourceMappingURL=Children.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Children.js","sourceRoot":"","sources":["../../src/core/Children.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,KAAK,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;QACnB,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;IAAA,CAC1C;IAED,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAQ,EAAE,CAAC;QACxC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YACvC,CAAC;iBAAM,CAAC;gBACN,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;IAAA,CACF;IAED,GAAG,EAAE,CACH,QAAuB,EACvB,EAA0C,EAC1C,OAAiB,EACZ,EAAE,CAAC;QACR,MAAM,MAAM,GAAQ,EAAE,CAAC;QACvB,QAAQ,CAAC,OAAO,CACd,QAAQ,EACR,CAAC,KAAK,EAAE,EAAE,CAAC;YACT,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QAAA,CACtC,EACD,OAAO,CACR,CAAC;QACF,OAAO,MAAM,CAAC;IAAA,CACf;IAED,IAAI,CAAC,QAAQ,EAAE;QACb,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,QAAQ,GAAG,CAAC,QAAQ,CAAC,CAAC;QACxB,CAAC;QAED,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACzC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,CAAC,MAAM,8BAA8B,CAAC,CAAC;QACvE,CAAC;IAAA,CACF;IAED,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;QACrB,OAAO,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;IAAA,CACjD;CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"applyAction.d.ts","sourceRoot":"","sources":["../../../src/core/actions/applyAction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAYzD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,0BAGvB,CAAC"}
1
+ {"version":3,"file":"applyAction.d.ts","sourceRoot":"","sources":["../../../src/core/actions/applyAction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAazD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,0BAGvB,CAAC"}
@@ -8,6 +8,7 @@ import { setTextAction } from './setText.action';
8
8
  import { removeAction } from './remove.action';
9
9
  import { replaceAction } from './replace.action';
10
10
  import { relayoutAction } from './relayout.action';
11
+ import { createContainerAction } from './createContainer.action';
11
12
  /**
12
13
  * The commit phase of the rendering process contains two parts:
13
14
  * - Applying DOM changes
@@ -24,6 +25,7 @@ const actionHandlers = {
24
25
  CreateTag: createTagAction,
25
26
  CreateText: createTextAction,
26
27
  CreateComment: createCommentAction,
28
+ CreateContainer: createContainerAction,
27
29
  SetProps: setPropsAction,
28
30
  SetRef: setRefAction,
29
31
  SetAttr: setAttrAction,
@@ -1 +1 @@
1
- {"version":3,"file":"applyAction.js","sourceRoot":"","sources":["../../../src/core/actions/applyAction.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AAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAc,EAAQ,EAAE,CAAC;IACnD,kCAAkC;IAClC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAa,CAAC,CAAC;AAAA,CAC1D,CAAC;AAEF,MAAM,cAAc,GAKhB;IACF,SAAS,EAAE,eAAe;IAC1B,UAAU,EAAE,gBAAgB;IAC5B,aAAa,EAAE,mBAAmB;IAClC,eAAe,EAAE,qBAAqB;IACtC,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,aAAa;IACtB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,cAAc;CACzB,CAAC"}
@@ -1,7 +1,7 @@
1
- import type { FiberNode } from '../../types';
1
+ import { type FiberNode } from '../../types';
2
2
  import type { CreateCommentAction } from '../../types/actions';
3
3
  /**
4
4
  * Creates a new comment DOM node (<!--r:${mode}:${fiber.id}-->).
5
5
  */
6
- export declare function createCommentAction(fiber: FiberNode, { mode }: CreateCommentAction): void;
6
+ export declare function createCommentAction(fiber: FiberNode, { mode }: Pick<CreateCommentAction, 'mode'>): void;
7
7
  //# sourceMappingURL=createComment.action.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createComment.action.d.ts","sourceRoot":"","sources":["../../../src/core/actions/createComment.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKtE;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,EAChB,EAAE,IAAI,EAAE,EAAE,mBAAmB,QAc9B"}
1
+ {"version":3,"file":"createComment.action.d.ts","sourceRoot":"","sources":["../../../src/core/actions/createComment.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAItE;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,EAChB,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,QAO5C"}
@@ -1,20 +1,13 @@
1
1
  import { getParentElement } from './helpers';
2
- import { tryToCompactNode } from '../compact';
3
2
  import { buildComment } from '../reconciliation/comments';
4
3
  /**
5
4
  * Creates a new comment DOM node (<!--r:${mode}:${fiber.id}-->).
6
5
  */
7
6
  export function createCommentAction(fiber, { mode }) {
8
7
  // Only two scenarios lead here:
9
- // - First render of a fragment or component. The parent's element is a
10
- // comment `r:begin:{id}`
8
+ // - Render a component or a fragment without children
11
9
  // - Render of a portal. The parent element is the portal target node.
12
10
  fiber.element = buildComment(mode, fiber.id);
13
11
  getParentElement(fiber).appendChild(fiber.element);
14
- if (mode === 'end') {
15
- // All children are added. If the current fiber is the only child, we can
16
- // compact the parent node: "<!--begin-->child<!--end-->" -> "child".
17
- tryToCompactNode(fiber);
18
- }
19
12
  }
20
13
  //# sourceMappingURL=createComment.action.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createComment.action.js","sourceRoot":"","sources":["../../../src/core/actions/createComment.action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAgB,EAChB,EAAE,IAAI,EAAuB,EAC7B;IACA,gCAAgC;IAChC,uEAAuE;IACvE,2BAA2B;IAC3B,sEAAsE;IACtE,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;IAC7C,gBAAgB,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEnD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,yEAAyE;QACzE,qEAAqE;QACrE,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;AAAA,CACF"}
1
+ {"version":3,"file":"createComment.action.js","sourceRoot":"","sources":["../../../src/core/actions/createComment.action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAgB,EAChB,EAAE,IAAI,EAAqC,EAC3C;IACA,gCAAgC;IAChC,sDAAsD;IACtD,sEAAsE;IACtE,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;IAC7C,gBAAgB,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAAA,CACpD"}
@@ -0,0 +1,7 @@
1
+ import { type FiberNode } from '../../types';
2
+ /**
3
+ * Once all component- or fragment-fiber's nodes are mounted we can finalize
4
+ * their fragment-like container.
5
+ */
6
+ export declare function createContainerAction(fiber: FiberNode): void;
7
+ //# sourceMappingURL=createContainer.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createContainer.action.d.ts","sourceRoot":"","sources":["../../../src/core/actions/createContainer.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIlE;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,SAAS,QAiBrD"}
@@ -0,0 +1,28 @@
1
+ import { containerSym } from '../../types';
2
+ import { getParentElement } from './helpers';
3
+ import { buildComment } from '../reconciliation/comments';
4
+ /**
5
+ * Once all component- or fragment-fiber's nodes are mounted we can finalize
6
+ * their fragment-like container.
7
+ */
8
+ export function createContainerAction(fiber) {
9
+ if (fiber.children.length === 0) {
10
+ // Case 1: We have no child nodes, so create an !--empty comment.
11
+ const container = getParentElement(fiber);
12
+ const empty = buildComment('empty', fiber.id);
13
+ container.appendChild(empty);
14
+ fiber.element = empty;
15
+ }
16
+ else if (fiber.children.length === 1) {
17
+ // Case 2: We have only one child. Let's refer to it. It's slightly faster
18
+ // than the `containerSym` approach.
19
+ fiber.element = fiber.children[0].element;
20
+ }
21
+ else {
22
+ // Case 3: We have more then one DOM children. Resort to the slow path:
23
+ // containerSym. In such a mode to get the fiber's domNodes we need to
24
+ // traverse through some of its children.
25
+ fiber.element = containerSym;
26
+ }
27
+ }
28
+ //# sourceMappingURL=createContainer.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createContainer.action.js","sourceRoot":"","sources":["../../../src/core/actions/createContainer.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAgB,EAAE;IACtD,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,iEAAiE;QACjE,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;QAC9C,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC7B,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;IACxB,CAAC;SAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvC,0EAA0E;QAC1E,oCAAoC;QACpC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,uEAAuE;QACvE,sEAAsE;QACtE,yCAAyC;QACzC,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC;IAC/B,CAAC;AAAA,CACF"}
@@ -1,4 +1,5 @@
1
1
  import type { FiberNode } from '../../types';
2
+ import type { CreateTagAction } from '../../types/actions';
2
3
  /**
3
4
  * Handles two scenarios:
4
5
  * - Creates a <!--r:portal:id--> comment for portal fibers
@@ -6,5 +7,5 @@ import type { FiberNode } from '../../types';
6
7
  *
7
8
  * This doesn't create child nodes or set attributes/event handlers.
8
9
  */
9
- export declare function createTagAction(fiber: FiberNode): void;
10
+ export declare function createTagAction(fiber: FiberNode, { attrs, ref }: CreateTagAction): void;
10
11
  //# sourceMappingURL=createTag.action.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createTag.action.d.ts","sourceRoot":"","sources":["../../../src/core/actions/createTag.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAgBtD"}
1
+ {"version":3,"file":"createTag.action.d.ts","sourceRoot":"","sources":["../../../src/core/actions/createTag.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAIlE;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,EAChB,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,eAAe,GAC9B,IAAI,CAsCN"}
@@ -1,5 +1,8 @@
1
1
  import { getParentElement } from './helpers';
2
- import { applyAction } from './applyAction';
2
+ import { createCommentAction } from './createComment.action';
3
+ import { setAttrAction } from './setAttr.action';
4
+ import { setRefAction } from './setRef.action';
5
+ import { ReactError } from '../reconciliation/errors/ReactError';
3
6
  /**
4
7
  * Handles two scenarios:
5
8
  * - Creates a <!--r:portal:id--> comment for portal fibers
@@ -7,21 +10,120 @@ import { applyAction } from './applyAction';
7
10
  *
8
11
  * This doesn't create child nodes or set attributes/event handlers.
9
12
  */
10
- export function createTagAction(fiber) {
13
+ export function createTagAction(fiber, { attrs, ref }) {
11
14
  if (fiber.type !== 'tag') {
12
- throw new Error(`createTagAction supports only tag-fiber-nodes.`);
15
+ throw new ReactError(fiber, `createTagAction supports only tag-fiber-nodes.`);
13
16
  }
14
17
  if (fiber.data instanceof HTMLElement) {
15
18
  // This is a portal, not a regular tag. We shouldn't create it since it
16
19
  // already exists outside the app's DOM subtree. Instead, create a
17
20
  // <!--r:portal:id--> comment node.
18
- applyAction({ type: 'CreateComment', fiber, mode: 'portal' });
21
+ createCommentAction(fiber, { mode: 'portal' });
19
22
  }
20
23
  else if (fiber.tag !== 'root') {
21
24
  // 'root' is a special case - it's the node where the app is mounted.
22
- const tag = document.createElement(fiber.tag);
25
+ const tag = SVG_TAGS.has(fiber.tag)
26
+ ? document.createElementNS('http://www.w3.org/2000/svg', fiber.tag)
27
+ : document.createElement(fiber.tag);
23
28
  fiber.element = tag;
24
29
  getParentElement(fiber).appendChild(fiber.element);
30
+ if (fiber.element instanceof HTMLInputElement) {
31
+ if (attrs?.type === 'radio') {
32
+ attrs.checked ??= undefined;
33
+ }
34
+ if (typeof attrs?.type === 'string') {
35
+ fiber.element.type = attrs.type;
36
+ }
37
+ }
38
+ for (const [name, value] of Object.entries(attrs ?? EMPTY)) {
39
+ setAttrAction(fiber, { name, value, creation: true });
40
+ }
41
+ if (ref) {
42
+ setRefAction(fiber, { ref, dontUnsetRef: true });
43
+ }
25
44
  }
26
45
  }
46
+ const EMPTY = {};
47
+ const SVG_TAGS = new Set([
48
+ // Core SVG Elements:
49
+ 'svg',
50
+ 'g',
51
+ 'defs',
52
+ 'symbol',
53
+ 'use',
54
+ 'image',
55
+ 'switch',
56
+ 'style',
57
+ // Basic Shapes:
58
+ 'rect',
59
+ 'circle',
60
+ 'ellipse',
61
+ 'line',
62
+ 'polyline',
63
+ 'polygon',
64
+ 'path',
65
+ // Text Elements:
66
+ 'text',
67
+ 'tspan',
68
+ 'tref',
69
+ 'textPath',
70
+ 'altGlyph',
71
+ 'glyphRef',
72
+ // Descriptive & Metadata:
73
+ 'title',
74
+ 'desc',
75
+ 'metadata',
76
+ // Container Elements:
77
+ 'foreignObject',
78
+ 'marker',
79
+ 'pattern',
80
+ 'mask',
81
+ 'clipPath',
82
+ 'filter',
83
+ // Gradient & Painting Elements:
84
+ 'linearGradient',
85
+ 'radialGradient',
86
+ 'stop',
87
+ // Animation Elements:
88
+ 'animate',
89
+ 'animateMotion',
90
+ 'animateTransform',
91
+ 'set',
92
+ // Filter Primitive Elements:
93
+ 'feBlend',
94
+ 'feColorMatrix',
95
+ 'feComponentTransfer',
96
+ 'feComposite',
97
+ 'feConvolveMatrix',
98
+ 'feDiffuseLighting',
99
+ 'feDisplacementMap',
100
+ 'feDropShadow',
101
+ 'feFlood',
102
+ 'feFuncA',
103
+ 'feFuncB',
104
+ 'feFuncG',
105
+ 'feFuncR',
106
+ 'feGaussianBlur',
107
+ 'feImage',
108
+ 'feMerge',
109
+ 'feMergeNode',
110
+ 'feMorphology',
111
+ 'feOffset',
112
+ 'fePointLight',
113
+ 'feSpecularLighting',
114
+ 'feSpotLight',
115
+ 'feTile',
116
+ 'feTurbulence',
117
+ // Font Elements:
118
+ 'font',
119
+ 'glyph',
120
+ 'hkern',
121
+ 'vkern',
122
+ 'font-face',
123
+ 'font-face-src',
124
+ 'font-face-uri',
125
+ 'font-face-format',
126
+ 'font-face-name',
127
+ 'missing-glyph',
128
+ ]);
27
129
  //# sourceMappingURL=createTag.action.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createTag.action.js","sourceRoot":"","sources":["../../../src/core/actions/createTag.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAgB,EAAQ;IACtD,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,YAAY,WAAW,EAAE,CAAC;QACtC,uEAAuE;QACvE,kEAAkE;QAClE,mCAAmC;QACnC,WAAW,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChE,CAAC;SAAM,IAAI,KAAK,CAAC,GAAG,KAAK,MAAM,EAAE,CAAC;QAChC,qEAAqE;QACrE,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9C,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;QACpB,gBAAgB,CAAC,KAAK,CAAC,CAAC,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;IACN,sBAAsB;IACtB,SAAS;IACT,eAAe;IACf,kBAAkB;IAClB,KAAK;IACL,6BAA6B;IAC7B,SAAS;IACT,eAAe;IACf,qBAAqB;IACrB,aAAa;IACb,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,cAAc;IACd,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,SAAS;IACT,SAAS;IACT,aAAa;IACb,cAAc;IACd,UAAU;IACV,cAAc;IACd,oBAAoB;IACpB,aAAa;IACb,QAAQ;IACR,cAAc;IACd,iBAAiB;IACjB,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,WAAW;IACX,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,gBAAgB;IAChB,eAAe;CAChB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createText.action.d.ts","sourceRoot":"","sources":["../../../src/core/actions/createText.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,QAWhD"}
1
+ {"version":3,"file":"createText.action.d.ts","sourceRoot":"","sources":["../../../src/core/actions/createText.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,QAUhD"}
@@ -1,15 +1,12 @@
1
1
  import { getParentElement } from './helpers';
2
+ import { ReactError } from '../reconciliation/errors/ReactError';
2
3
  /**
3
4
  * Creates a new text DOM node.
4
5
  */
5
6
  export function createTextAction(fiber) {
6
7
  if (fiber.type !== 'text') {
7
- throw new Error(`Can't apply CreateText for a ${fiber.type} node`);
8
+ throw new ReactError(fiber, `Can't apply CreateText for a ${fiber.type} node`);
8
9
  }
9
- // Only two scenarios lead here:
10
- // - First render of a fragment or component. The parent's element is
11
- // a comment `r:begin:{id}`
12
- // - Render of a portal. The parent element is the portal target node.
13
10
  fiber.element = new Text(fiber.props.text);
14
11
  getParentElement(fiber).appendChild(fiber.element);
15
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createText.action.js","sourceRoot":"","sources":["../../../src/core/actions/createText.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAgB,EAAE;IACjD,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,gCAAgC;IAChC,qEAAqE;IACrE,6BAA6B;IAC7B,sEAAsE;IACtE,KAAK,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3C,gBAAgB,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAAA,CACpD"}
1
+ {"version":3,"file":"createText.action.js","sourceRoot":"","sources":["../../../src/core/actions/createText.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAgB,EAAE;IACjD,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,UAAU,CAClB,KAAK,EACL,gCAAgC,KAAK,CAAC,IAAI,OAAO,CAClD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3C,gBAAgB,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAAA,CACpD"}
@@ -0,0 +1,4 @@
1
+ import type { TagAttrValue } from '../../../types';
2
+ export declare const setHtmlAttribute: (element: HTMLElement, name: string, value: TagAttrValue) => void;
3
+ export declare const BOOL_ATTRS: Set<string>;
4
+ //# sourceMappingURL=attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../../src/core/actions/dom/attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,gBAAgB,mEAoB5B,CAAC;AAEF,eAAO,MAAM,UAAU,aAsCrB,CAAC"}
@@ -0,0 +1,56 @@
1
+ export const setHtmlAttribute = (element, name, value) => {
2
+ if (BOOL_ATTRS.has(name)) {
3
+ if (value) {
4
+ element.setAttribute(name, '');
5
+ }
6
+ else {
7
+ element.removeAttribute(name);
8
+ }
9
+ return;
10
+ }
11
+ if (name === 'value') {
12
+ element.value = value == null ? '' : String(value);
13
+ return;
14
+ }
15
+ element.setAttribute(name === 'className' ? 'class' : name, String(value));
16
+ };
17
+ export const BOOL_ATTRS = new Set([
18
+ 'autoFocus',
19
+ 'checked',
20
+ 'multiple',
21
+ 'muted',
22
+ 'selected',
23
+ 'contentEditable',
24
+ 'spellCheck',
25
+ 'draggable',
26
+ 'autoReverse',
27
+ 'externalResourcesRequired',
28
+ 'focusable',
29
+ 'preserveAlpha',
30
+ 'allowFullScreen',
31
+ 'async',
32
+ 'autoPlay',
33
+ 'controls',
34
+ 'default',
35
+ 'defer',
36
+ 'disabled',
37
+ 'disablePictureInPicture',
38
+ 'disableRemotePlayback',
39
+ 'formNoValidate',
40
+ 'hidden',
41
+ 'loop',
42
+ 'noModule',
43
+ 'noValidate',
44
+ 'open',
45
+ 'playsInline',
46
+ 'readOnly',
47
+ 'required',
48
+ 'reversed',
49
+ 'scoped',
50
+ 'seamless',
51
+ 'itemScope',
52
+ 'capture',
53
+ 'download',
54
+ 'inert',
55
+ ]);
56
+ //# sourceMappingURL=attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../../../src/core/actions/dom/attributes.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAoB,EACpB,IAAY,EACZ,KAAmB,EACnB,EAAE,CAAC;IACH,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QACD,OAAO;IACT,CAAC;IAED,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACpB,OAA4B,CAAC,KAAK,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzE,OAAO;IACT,CAAC;IAED,OAAO,CAAC,YAAY,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAAA,CAC5E,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IAChC,WAAW;IACX,SAAS;IACT,UAAU;IACV,OAAO;IACP,UAAU;IACV,iBAAiB;IACjB,YAAY;IACZ,WAAW;IACX,aAAa;IACb,2BAA2B;IAC3B,WAAW;IACX,eAAe;IACf,iBAAiB;IACjB,OAAO;IACP,UAAU;IACV,UAAU;IACV,SAAS;IACT,OAAO;IACP,UAAU;IACV,yBAAyB;IACzB,uBAAuB;IACvB,gBAAgB;IAChB,QAAQ;IACR,MAAM;IACN,UAAU;IACV,YAAY;IACZ,MAAM;IACN,aAAa;IACb,UAAU;IACV,UAAU;IACV,UAAU;IACV,QAAQ;IACR,UAAU;IACV,WAAW;IACX,SAAS;IACT,UAAU;IACV,OAAO;CACR,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { TagAttrValue, TagFiberNode } from '../../../types';
2
+ /**
3
+ * Handles removing, toggling and adding tag styles.
4
+ */
5
+ export declare const setTagStyles: (fiber: TagFiberNode, stylesRaw: TagAttrValue) => void;
6
+ //# sourceMappingURL=css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../../../src/core/actions/dom/css.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAa,MAAM,oBAAoB,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,YAAY,wDA0CxB,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { ReactError } from '../../../core/reconciliation/errors/ReactError';
2
+ /**
3
+ * Handles removing, toggling and adding tag styles.
4
+ */
5
+ export const setTagStyles = (fiber,
6
+ /** Should be a CSS-string (hyphens) or a CSS map (camelCase) */
7
+ stylesRaw) => {
8
+ if (typeof stylesRaw !== 'string' &&
9
+ stylesRaw != null &&
10
+ typeof stylesRaw !== 'object') {
11
+ throw new ReactError(fiber, `Unsupported format of styles`);
12
+ }
13
+ const elementStyle = fiber.element.style;
14
+ const newStyles = typeof stylesRaw === 'string' ? strToStyles(stylesRaw) : (stylesRaw ?? {});
15
+ if (Object.keys(newStyles).length > 0) {
16
+ for (const key of Object.keys(fiber.data.styles ?? {})) {
17
+ if (!(key in newStyles)) {
18
+ if (key.includes('-')) {
19
+ elementStyle.removeProperty(key);
20
+ }
21
+ else if (key in elementStyle) {
22
+ // @ts-ignore It's wrongly typed as read-only.
23
+ elementStyle[key] = '';
24
+ }
25
+ }
26
+ }
27
+ for (const [key, value] of Object.entries(newStyles)) {
28
+ if (key.includes('-')) {
29
+ elementStyle.setProperty(key, value);
30
+ }
31
+ else if (key in elementStyle) {
32
+ // @ts-ignore It's wrongly typed as read-only.
33
+ elementStyle[key] = value;
34
+ }
35
+ }
36
+ }
37
+ else {
38
+ fiber.element.removeAttribute('style');
39
+ }
40
+ fiber.data.styles = newStyles;
41
+ };
42
+ /**
43
+ * Converts a string like "color: red; font-size: 12px" to
44
+ * { color: 'red', ['font-size']: '12px' }
45
+ */
46
+ const strToStyles = (css) => {
47
+ cssDummy.style.cssText = css;
48
+ return Object.fromEntries(Array.from(cssDummy.style).map((k) => [
49
+ k,
50
+ cssDummy.style.getPropertyValue(k),
51
+ ]));
52
+ };
53
+ const cssDummy = document.createElement('x-css-dummy');
54
+ //# sourceMappingURL=css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.js","sourceRoot":"","sources":["../../../../src/core/actions/dom/css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AAGhF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAmB;AACnB,gEAAgE;AAChE,SAAuB,EACjB,EAAE,CAAC;IACT,IACE,OAAO,SAAS,KAAK,QAAQ;QAC7B,SAAS,IAAI,IAAI;QACjB,OAAO,SAAS,KAAK,QAAQ,EAC7B,CAAC;QACD,MAAM,IAAI,UAAU,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,YAAY,GAAI,KAAK,CAAC,OAAuB,CAAC,KAAK,CAAC;IAC1D,MAAM,SAAS,GACb,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IAE7E,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAA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BAAgB,CAAC,CAAC,CAAC;KACnC,CAAC,CACH,CAAC;AAAA,CACH,CAAC;AAEF,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { TagAttrValue, TagFiberNode } from '../../../types';
2
+ export declare const setEventHandler: (fiber: TagFiberNode, element: Element, name: string, value: TagAttrValue) => void;
3
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/core/actions/dom/events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAErE,eAAO,MAAM,eAAe,oFAwD3B,CAAC"}