@unsetsoft/ryunixjs 0.4.9 → 0.4.10
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/README.md +1 -2
- package/dist/Ryunix.js +239 -229
- package/package.json +1 -1
- package/src/lib/commits.js +27 -27
- package/src/lib/components.js +13 -13
- package/src/lib/createElement.js +12 -14
- package/src/lib/dom.js +30 -30
- package/src/lib/effects.js +13 -13
- package/src/lib/hooks.js +33 -34
- package/src/lib/index.js +11 -11
- package/src/lib/navigation.js +34 -34
- package/src/lib/reconciler.js +18 -18
- package/src/lib/render.js +9 -9
- package/src/lib/workers.js +19 -19
- package/src/main.js +4 -4
- package/src/utils/index.js +14 -14
package/src/lib/render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { vars } from
|
|
1
|
+
import { vars } from '../utils/index'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The function renders an element into a container using a work-in-progress root.
|
|
@@ -14,10 +14,10 @@ const render = (element, container) => {
|
|
|
14
14
|
children: [element],
|
|
15
15
|
},
|
|
16
16
|
alternate: vars.currentRoot,
|
|
17
|
-
}
|
|
18
|
-
vars.deletions = []
|
|
19
|
-
vars.nextUnitOfWork = vars.wipRoot
|
|
20
|
-
}
|
|
17
|
+
}
|
|
18
|
+
vars.deletions = []
|
|
19
|
+
vars.nextUnitOfWork = vars.wipRoot
|
|
20
|
+
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @description The function creates a reference to a DOM element with the specified ID. This will be used to initialize the app.
|
|
@@ -26,8 +26,8 @@ const render = (element, container) => {
|
|
|
26
26
|
* for the root element.
|
|
27
27
|
*/
|
|
28
28
|
const init = (root) => {
|
|
29
|
-
const rootElement = root ||
|
|
30
|
-
vars.containerRoot = document.getElementById(rootElement)
|
|
31
|
-
}
|
|
29
|
+
const rootElement = root || '__ryunix'
|
|
30
|
+
vars.containerRoot = document.getElementById(rootElement)
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
export { render, init }
|
|
33
|
+
export { render, init }
|
package/src/lib/workers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { commitRoot } from
|
|
2
|
-
import { updateFunctionComponent, updateHostComponent } from
|
|
3
|
-
import { vars } from
|
|
1
|
+
import { commitRoot } from './commits'
|
|
2
|
+
import { updateFunctionComponent, updateHostComponent } from './components'
|
|
3
|
+
import { vars } from '../utils/index'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This function uses requestIdleCallback to perform work on a fiber tree until it is complete or the
|
|
@@ -11,20 +11,20 @@ import { vars } from "../utils/index";
|
|
|
11
11
|
* is used to determine
|
|
12
12
|
*/
|
|
13
13
|
const workLoop = (deadline) => {
|
|
14
|
-
let shouldYield = false
|
|
14
|
+
let shouldYield = false
|
|
15
15
|
while (vars.nextUnitOfWork && !shouldYield) {
|
|
16
|
-
vars.nextUnitOfWork = performUnitOfWork(vars.nextUnitOfWork)
|
|
17
|
-
shouldYield = deadline.timeRemaining() < 1
|
|
16
|
+
vars.nextUnitOfWork = performUnitOfWork(vars.nextUnitOfWork)
|
|
17
|
+
shouldYield = deadline.timeRemaining() < 1
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
if (!vars.nextUnitOfWork && vars.wipRoot) {
|
|
21
|
-
commitRoot()
|
|
21
|
+
commitRoot()
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
requestIdleCallback(workLoop)
|
|
25
|
-
}
|
|
24
|
+
requestIdleCallback(workLoop)
|
|
25
|
+
}
|
|
26
26
|
|
|
27
|
-
requestIdleCallback(workLoop)
|
|
27
|
+
requestIdleCallback(workLoop)
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* The function performs a unit of work by updating either a function component or a host component and
|
|
@@ -39,22 +39,22 @@ requestIdleCallback(workLoop);
|
|
|
39
39
|
* sibling of the parent. The function returns `null` if there are no more fibers to process.
|
|
40
40
|
*/
|
|
41
41
|
const performUnitOfWork = (fiber) => {
|
|
42
|
-
const isFunctionComponent = fiber.type instanceof Function
|
|
42
|
+
const isFunctionComponent = fiber.type instanceof Function
|
|
43
43
|
if (isFunctionComponent) {
|
|
44
|
-
updateFunctionComponent(fiber)
|
|
44
|
+
updateFunctionComponent(fiber)
|
|
45
45
|
} else {
|
|
46
|
-
updateHostComponent(fiber)
|
|
46
|
+
updateHostComponent(fiber)
|
|
47
47
|
}
|
|
48
48
|
if (fiber.child) {
|
|
49
|
-
return fiber.child
|
|
49
|
+
return fiber.child
|
|
50
50
|
}
|
|
51
|
-
let nextFiber = fiber
|
|
51
|
+
let nextFiber = fiber
|
|
52
52
|
while (nextFiber) {
|
|
53
53
|
if (nextFiber.sibling) {
|
|
54
|
-
return nextFiber.sibling
|
|
54
|
+
return nextFiber.sibling
|
|
55
55
|
}
|
|
56
|
-
nextFiber = nextFiber.parent
|
|
56
|
+
nextFiber = nextFiber.parent
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
}
|
|
59
59
|
|
|
60
|
-
export { performUnitOfWork, workLoop }
|
|
60
|
+
export { performUnitOfWork, workLoop }
|
package/src/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Ryunix from
|
|
1
|
+
import Ryunix from './lib/index.js'
|
|
2
2
|
export {
|
|
3
3
|
useStore,
|
|
4
4
|
useEffect,
|
|
@@ -6,8 +6,8 @@ export {
|
|
|
6
6
|
Fragments,
|
|
7
7
|
Navigate,
|
|
8
8
|
Router,
|
|
9
|
-
} from
|
|
9
|
+
} from './lib/index.js'
|
|
10
10
|
|
|
11
|
-
window.Ryunix = Ryunix
|
|
11
|
+
window.Ryunix = Ryunix
|
|
12
12
|
|
|
13
|
-
export default Ryunix
|
|
13
|
+
export default Ryunix
|
package/src/utils/index.js
CHANGED
|
@@ -6,28 +6,28 @@ const vars = {
|
|
|
6
6
|
deletions: null,
|
|
7
7
|
wipFiber: null,
|
|
8
8
|
hookIndex: null,
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
const reg = /[A-Z]/g
|
|
11
|
+
const reg = /[A-Z]/g
|
|
12
12
|
|
|
13
13
|
const RYUNIX_TYPES = Object.freeze({
|
|
14
|
-
TEXT_ELEMENT: Symbol(
|
|
15
|
-
RYUNIX_EFFECT: Symbol(
|
|
16
|
-
RYUNIX_CONTEXT: Symbol(
|
|
17
|
-
})
|
|
14
|
+
TEXT_ELEMENT: Symbol('text.element'),
|
|
15
|
+
RYUNIX_EFFECT: Symbol('ryunix.effect'),
|
|
16
|
+
RYUNIX_CONTEXT: Symbol('ryunix.context'),
|
|
17
|
+
})
|
|
18
18
|
|
|
19
19
|
const STRINGS = Object.freeze({
|
|
20
|
-
object:
|
|
21
|
-
function:
|
|
22
|
-
style:
|
|
23
|
-
className:
|
|
24
|
-
children:
|
|
25
|
-
})
|
|
20
|
+
object: 'object',
|
|
21
|
+
function: 'function',
|
|
22
|
+
style: 'style',
|
|
23
|
+
className: 'className',
|
|
24
|
+
children: 'children',
|
|
25
|
+
})
|
|
26
26
|
|
|
27
27
|
const EFFECT_TAGS = Object.freeze({
|
|
28
28
|
PLACEMENT: Symbol(),
|
|
29
29
|
UPDATE: Symbol(),
|
|
30
30
|
DELETION: Symbol(),
|
|
31
|
-
})
|
|
31
|
+
})
|
|
32
32
|
|
|
33
|
-
export { vars, reg, RYUNIX_TYPES, EFFECT_TAGS, STRINGS }
|
|
33
|
+
export { vars, reg, RYUNIX_TYPES, EFFECT_TAGS, STRINGS }
|