@unsetsoft/ryunixjs 1.0.3-nightly.5 → 1.0.3-nightly.7

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.
package/dist/Ryunix.js CHANGED
@@ -165,12 +165,16 @@
165
165
  * @returns A newly created DOM element based on the fiber object.
166
166
  */
167
167
  const createDom = (fiber) => {
168
+ // Log to verify fiber type before creating DOM
169
+ console.log('Creating DOM for fiber:', fiber);
170
+
171
+ // Check if the fiber is a text element or a regular element
168
172
  const dom =
169
173
  fiber.type === RYUNIX_TYPES.TEXT_ELEMENT
170
- ? document.createTextNode('')
174
+ ? document.createTextNode(fiber.props.nodeValue || '')
171
175
  : document.createElement(fiber.type);
172
176
 
173
- // Update the newly created DOM element with initial props
177
+ // Update the newly created DOM element with its initial props
174
178
  updateDom(dom, {}, fiber.props);
175
179
 
176
180
  return dom
@@ -278,8 +282,10 @@
278
282
  * The function commits changes made to the virtual DOM to the actual DOM.
279
283
  */
280
284
  const commitRoot = () => {
285
+ console.log('Committing root...');
281
286
  vars.deletions.forEach(commitWork);
282
287
  if (vars.wipRoot && vars.wipRoot.child) {
288
+ console.log('Committing child...');
283
289
  commitWork(vars.wipRoot.child);
284
290
  vars.currentRoot = vars.wipRoot;
285
291
  }
@@ -350,6 +356,9 @@
350
356
  [EFFECT_TAGS.PLACEMENT]: (fiber, domParent) => {
351
357
  if (fiber.dom != undefined) {
352
358
  domParent.appendChild(fiber.dom);
359
+ console.log('Appending child DOM node:', fiber.dom);
360
+ } else {
361
+ console.error('Failed to append DOM. Fiber has no DOM:', fiber);
353
362
  }
354
363
  runEffects(fiber);
355
364
  },
@@ -483,10 +492,13 @@
483
492
  * @param fiber - A fiber node representing the host component (e.g., a DOM node like div, span, etc.).
484
493
  */
485
494
  const updateHostComponent = (fiber) => {
495
+ // If the fiber doesn't already have a DOM node, create one
486
496
  if (!fiber.dom) {
487
497
  fiber.dom = createDom(fiber);
498
+ console.log('DOM node created:', fiber.dom);
488
499
  }
489
500
 
501
+ // Reconcile the fiber's children with its new or updated props
490
502
  reconcileChildren(fiber, fiber.props.children);
491
503
  };
492
504
 
@@ -526,6 +538,7 @@
526
538
  * @returns {null} The next fiber to process, or undefined if there are no more.
527
539
  */
528
540
  const performUnitOfWork = (fiber) => {
541
+ console.log('Performing unit of work for fiber:', fiber);
529
542
  const isFunctionComponent = fiber.type instanceof Function;
530
543
  isFunctionComponent
531
544
  ? updateFunctionComponent(fiber)
@@ -573,6 +586,7 @@
573
586
  console.error(`Root element with ID '${rootId}' not found.`);
574
587
  return null
575
588
  }
589
+ console.log('Container initialized:', vars.containerRoot);
576
590
 
577
591
  vars.containerRoot = rootElement;
578
592
  return undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unsetsoft/ryunixjs",
3
- "version": "1.0.3-nightly.5",
3
+ "version": "1.0.3-nightly.7",
4
4
  "license": "MIT",
5
5
  "main": "./dist/Ryunix.js",
6
6
  "types": "./dist/Ryunix.d.ts",
@@ -6,8 +6,10 @@ import { EFFECT_TAGS, vars } from '../utils/index'
6
6
  * The function commits changes made to the virtual DOM to the actual DOM.
7
7
  */
8
8
  const commitRoot = () => {
9
+ console.log('Committing root...')
9
10
  vars.deletions.forEach(commitWork)
10
11
  if (vars.wipRoot && vars.wipRoot.child) {
12
+ console.log('Committing child...')
11
13
  commitWork(vars.wipRoot.child)
12
14
  vars.currentRoot = vars.wipRoot
13
15
  }
@@ -78,6 +80,9 @@ const effectHandlers = {
78
80
  [EFFECT_TAGS.PLACEMENT]: (fiber, domParent) => {
79
81
  if (fiber.dom != undefined) {
80
82
  domParent.appendChild(fiber.dom)
83
+ console.log('Appending child DOM node:', fiber.dom)
84
+ } else {
85
+ console.error('Failed to append DOM. Fiber has no DOM:', fiber)
81
86
  }
82
87
  runEffects(fiber)
83
88
  },
@@ -26,10 +26,13 @@ const updateFunctionComponent = (fiber) => {
26
26
  * @param fiber - A fiber node representing the host component (e.g., a DOM node like div, span, etc.).
27
27
  */
28
28
  const updateHostComponent = (fiber) => {
29
+ // If the fiber doesn't already have a DOM node, create one
29
30
  if (!fiber.dom) {
30
31
  fiber.dom = createDom(fiber)
32
+ console.log('DOM node created:', fiber.dom)
31
33
  }
32
34
 
35
+ // Reconcile the fiber's children with its new or updated props
33
36
  reconcileChildren(fiber, fiber.props.children)
34
37
  }
35
38
 
package/src/lib/dom.js CHANGED
@@ -14,12 +14,16 @@ import {
14
14
  * @returns A newly created DOM element based on the fiber object.
15
15
  */
16
16
  const createDom = (fiber) => {
17
+ // Log to verify fiber type before creating DOM
18
+ console.log('Creating DOM for fiber:', fiber)
19
+
20
+ // Check if the fiber is a text element or a regular element
17
21
  const dom =
18
22
  fiber.type === RYUNIX_TYPES.TEXT_ELEMENT
19
- ? document.createTextNode('')
23
+ ? document.createTextNode(fiber.props.nodeValue || '')
20
24
  : document.createElement(fiber.type)
21
25
 
22
- // Update the newly created DOM element with initial props
26
+ // Update the newly created DOM element with its initial props
23
27
  updateDom(dom, {}, fiber.props)
24
28
 
25
29
  return dom
package/src/lib/render.js CHANGED
@@ -28,6 +28,7 @@ const init = (rootId = '__ryunix') => {
28
28
  console.error(`Root element with ID '${rootId}' not found.`)
29
29
  return null
30
30
  }
31
+ console.log('Container initialized:', vars.containerRoot)
31
32
 
32
33
  vars.containerRoot = rootElement
33
34
  return this
@@ -32,6 +32,7 @@ requestIdleCallback(workLoop)
32
32
  * @returns {null} The next fiber to process, or undefined if there are no more.
33
33
  */
34
34
  const performUnitOfWork = (fiber) => {
35
+ console.log('Performing unit of work for fiber:', fiber)
35
36
  const isFunctionComponent = fiber.type instanceof Function
36
37
  isFunctionComponent
37
38
  ? updateFunctionComponent(fiber)