@unsetsoft/ryunixjs 1.2.5-canary.3 → 1.2.5-canary.5
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.es.md +120 -0
- package/README.md +62 -31
- package/dist/Ryunix.esm.js +21 -14
- package/dist/Ryunix.esm.js.map +1 -1
- package/dist/Ryunix.umd.js +21 -14
- package/dist/Ryunix.umd.js.map +1 -1
- package/dist/Ryunix.umd.min.js +1 -1
- package/dist/Ryunix.umd.min.js.map +1 -1
- package/package.json +1 -1
package/README.es.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 MD013 -->
|
|
2
|
+
|
|
3
|
+
> **Language / Idioma:** [English](./README.md) · [Español](./README.es.md)
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://raw.githubusercontent.com/UnSetSoft/Ryunixjs/canary/assets/logo.png" width="200" height="200" alt="RyunixJS Logo" />
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<h1 align="center">@unsetsoft/ryunixjs</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@unsetsoft/ryunixjs">
|
|
13
|
+
<img src="https://img.shields.io/npm/v/@unsetsoft/ryunixjs.svg?style=flat-square" alt="versión npm" />
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/@unsetsoft/ryunixjs/v/canary">
|
|
16
|
+
<img src="https://img.shields.io/npm/v/@unsetsoft/ryunixjs/canary.svg?style=flat-square&label=canary" alt="versión canary" />
|
|
17
|
+
</a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
## <!-- markdownlint-enable MD013 -->
|
|
21
|
+
|
|
22
|
+
## 🧠 ¿Qué es el Core?
|
|
23
|
+
|
|
24
|
+
`@unsetsoft/ryunixjs` es el **motor fundamental** del framework RyunixJS.
|
|
25
|
+
Es una biblioteca ligera y de alto rendimiento responsable de:
|
|
26
|
+
|
|
27
|
+
- **Reconciliación y arquitectura Fiber**: actualiza el DOM de forma eficiente
|
|
28
|
+
|
|
29
|
+
comparando árboles de Virtual DOM.
|
|
30
|
+
|
|
31
|
+
- **Sistema de hooks**: gestión de estado y ciclo de vida (p. ej.
|
|
32
|
+
|
|
33
|
+
`useStore`, `useEffect`).
|
|
34
|
+
|
|
35
|
+
- **Renderizado concurrente**: soporte para actualizaciones priorizadas y transiciones.
|
|
36
|
+
- **SSR e hidratación**: motores de renderizado en servidor para Node.js y entornos
|
|
37
|
+
|
|
38
|
+
Edge.
|
|
39
|
+
|
|
40
|
+
Aunque puedes usarlo de forma independiente en integraciones personalizadas, lo habitual
|
|
41
|
+
es consumirlo mediante `@unsetsoft/ryunix-presets` y el CLI oficial.
|
|
42
|
+
|
|
43
|
+
## 🚀 Instalación
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install @unsetsoft/ryunixjs
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 🛠️ Referencia de API
|
|
50
|
+
|
|
51
|
+
### Funciones principales
|
|
52
|
+
|
|
53
|
+
- `createElement(type, props, ...children)`: crea un elemento de Virtual DOM.
|
|
54
|
+
- `render(element, container)`: renderiza un elemento Ryunix en el DOM.
|
|
55
|
+
- `hydrate(element, container)`: hidrata HTML generado en servidor.
|
|
56
|
+
- `init()`: inicializa el estado de Ryunix.
|
|
57
|
+
|
|
58
|
+
### Hooks
|
|
59
|
+
|
|
60
|
+
| Hook | Descripción |
|
|
61
|
+
| :----------------------------- | :------------------------------------------------------- |
|
|
62
|
+
| `useStore(initial)` | Gestión de estado (equivalente Ryunix de `useState`). |
|
|
63
|
+
| `useReducer(reducer, initial)` | Estado avanzado con reducers. |
|
|
64
|
+
| `useEffect(cb, deps)` | Efectos secundarios. |
|
|
65
|
+
| `useLayoutEffect(cb, deps)` | Efectos síncronos antes del pintado del navegador. |
|
|
66
|
+
| `useRef(initial)` | Referencia persistente entre renders. |
|
|
67
|
+
| `useMemo(cb, deps)` | Valores memorizados. |
|
|
68
|
+
| `useCallback(cb, deps)` | Funciones memorizadas. |
|
|
69
|
+
| `useContext(id)` | Consume un valor de contexto. |
|
|
70
|
+
| `useId()` | Genera IDs únicos y estables para SSR. |
|
|
71
|
+
|
|
72
|
+
### Hooks especializados
|
|
73
|
+
|
|
74
|
+
- `usePersistentStore(key, initial)`: sincroniza el estado con
|
|
75
|
+
|
|
76
|
+
`localStorage` automáticamente.
|
|
77
|
+
|
|
78
|
+
- `useSwitch(initial)`: hook optimizado para estado booleano.
|
|
79
|
+
- `useDebounce(value, delay)`: aplaza actualizaciones de un valor.
|
|
80
|
+
- `useThrottle(value, interval)`: limita la frecuencia de actualizaciones.
|
|
81
|
+
- `useQuery()` / `useHash()`: parámetros de URL y hash reactivos.
|
|
82
|
+
|
|
83
|
+
### Concurrencia y servidor
|
|
84
|
+
|
|
85
|
+
- **Actualizaciones priorizadas**: usa `useTransition` y `useDeferredValue` para
|
|
86
|
+
|
|
87
|
+
actualizaciones de UI no urgentes.
|
|
88
|
+
|
|
89
|
+
- **Motor SSR**: `renderToString` y `renderToReadableStream` para renderizado
|
|
90
|
+
|
|
91
|
+
flexible en servidor.
|
|
92
|
+
|
|
93
|
+
- **Límites**: `ServerBoundary` y `ErrorBoundary` para aplicaciones resilientes.
|
|
94
|
+
|
|
95
|
+
## 🏗️ Ejemplo de uso
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
import { render, useStore, createElement } from '@unsetsoft/ryunixjs'
|
|
99
|
+
|
|
100
|
+
function App() {
|
|
101
|
+
const [count, setCount] = useStore(0)
|
|
102
|
+
|
|
103
|
+
return createElement(
|
|
104
|
+
'div',
|
|
105
|
+
null,
|
|
106
|
+
createElement('h1', null, `Count: ${count}`),
|
|
107
|
+
createElement(
|
|
108
|
+
'button',
|
|
109
|
+
{ onClick: () => setCount(count + 1) },
|
|
110
|
+
'Increment',
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
render(createElement(App), document.getElementById('root'))
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## 📄 Licencia
|
|
119
|
+
|
|
120
|
+
RyunixJS tiene [licencia MIT](../../LICENSE).
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 MD013 -->
|
|
2
|
+
|
|
3
|
+
> **Language / Idioma:** [English](./README.md) · [Español](./README.es.md)
|
|
4
|
+
|
|
1
5
|
<p align="center">
|
|
2
6
|
<img src="https://raw.githubusercontent.com/UnSetSoft/Ryunixjs/canary/assets/logo.png" width="200" height="200" alt="RyunixJS Logo" />
|
|
3
7
|
</p>
|
|
@@ -13,18 +17,28 @@
|
|
|
13
17
|
</a>
|
|
14
18
|
</p>
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
## <!-- markdownlint-enable MD013 -->
|
|
17
21
|
|
|
18
22
|
## 🧠 What is the Core?
|
|
19
23
|
|
|
20
|
-
`@unsetsoft/ryunixjs` is the **foundational engine** of the RyunixJS framework.
|
|
24
|
+
`@unsetsoft/ryunixjs` is the **foundational engine** of the RyunixJS framework.
|
|
25
|
+
It's a lightweight, high-performance library responsible for:
|
|
26
|
+
|
|
27
|
+
- **Reconciliation & Fiber Architecture**: Efficiently updating the DOM by
|
|
28
|
+
|
|
29
|
+
comparing Virtual DOM trees.
|
|
30
|
+
|
|
31
|
+
- **Hooks System**: Providing the core state and lifecycle management (e.g.,
|
|
32
|
+
|
|
33
|
+
`useStore`, `useEffect`).
|
|
21
34
|
|
|
22
|
-
- **Reconciliation & Fiber Architecture**: Efficiently updating the DOM by comparing Virtual DOM trees.
|
|
23
|
-
- **Hooks System**: Providing the core state and lifecycle management (e.g., `useStore`, `useEffect`).
|
|
24
35
|
- **Concurrent Rendering**: Support for prioritized updates and transitions.
|
|
25
|
-
- **SSR & Hydration**: Server-Side Rendering engines for both Node.js and Edge
|
|
36
|
+
- **SSR & Hydration**: Server-Side Rendering engines for both Node.js and Edge
|
|
26
37
|
|
|
27
|
-
|
|
38
|
+
environments.
|
|
39
|
+
|
|
40
|
+
While you can use it standalone for custom integrations, it is typically used
|
|
41
|
+
via `@unsetsoft/ryunix-presets` and our official CLI.
|
|
28
42
|
|
|
29
43
|
## 🚀 Installation
|
|
30
44
|
|
|
@@ -36,28 +50,31 @@ npm install @unsetsoft/ryunixjs
|
|
|
36
50
|
|
|
37
51
|
### Core Functions
|
|
38
52
|
|
|
39
|
-
- `createElement(type, props, ...children)`: Creates a
|
|
53
|
+
- `createElement(type, props, ...children)`: Creates a Virtual DOM element.
|
|
40
54
|
- `render(element, container)`: Renders a Ryunix element into the DOM.
|
|
41
55
|
- `hydrate(element, container)`: Hydrates server-rendered HTML.
|
|
42
56
|
- `init()`: Initializes the Ryunix state.
|
|
43
57
|
|
|
44
58
|
### Hooks
|
|
45
59
|
|
|
46
|
-
| Hook
|
|
47
|
-
|
|
|
48
|
-
| `useStore(initial)`
|
|
49
|
-
| `useReducer(reducer, initial)` | Advanced state management with reducers.
|
|
50
|
-
| `useEffect(cb, deps)`
|
|
51
|
-
| `useLayoutEffect(cb, deps)`
|
|
52
|
-
| `useRef(initial)`
|
|
53
|
-
| `useMemo(cb, deps)`
|
|
54
|
-
| `useCallback(cb, deps)`
|
|
55
|
-
| `useContext(id)`
|
|
56
|
-
| `useId()`
|
|
60
|
+
| Hook | Description |
|
|
61
|
+
| :----------------------------- | :-------------------------------------------------- |
|
|
62
|
+
| `useStore(initial)` | State management (Ryunix equivalent of `useState`). |
|
|
63
|
+
| `useReducer(reducer, initial)` | Advanced state management with reducers. |
|
|
64
|
+
| `useEffect(cb, deps)` | Side effects management. |
|
|
65
|
+
| `useLayoutEffect(cb, deps)` | Synchronous side effects before browser paint. |
|
|
66
|
+
| `useRef(initial)` | Persistent reference across renders. |
|
|
67
|
+
| `useMemo(cb, deps)` | Memoized values. |
|
|
68
|
+
| `useCallback(cb, deps)` | Memoized functions. |
|
|
69
|
+
| `useContext(id)` | Consumes a context value. |
|
|
70
|
+
| `useId()` | Generates unique, stable IDs for SSR. |
|
|
57
71
|
|
|
58
72
|
### Specialized Hooks
|
|
59
73
|
|
|
60
|
-
- `usePersistentStore(key, initial)`: Automatically syncs state with
|
|
74
|
+
- `usePersistentStore(key, initial)`: Automatically syncs state with
|
|
75
|
+
|
|
76
|
+
`localStorage`.
|
|
77
|
+
|
|
61
78
|
- `useSwitch(initial)`: Optimized toggle state hook.
|
|
62
79
|
- `useDebounce(value, delay)`: Debounces a value update.
|
|
63
80
|
- `useThrottle(value, interval)`: Throttles value updates.
|
|
@@ -65,27 +82,41 @@ npm install @unsetsoft/ryunixjs
|
|
|
65
82
|
|
|
66
83
|
### Concurrency & Server-Side
|
|
67
84
|
|
|
68
|
-
- **Prioritized Updates**: Use `useTransition` and `useDeferredValue` to manage
|
|
69
|
-
|
|
70
|
-
-
|
|
85
|
+
- **Prioritized Updates**: Use `useTransition` and `useDeferredValue` to manage
|
|
86
|
+
|
|
87
|
+
non-urgent UI updates.
|
|
88
|
+
|
|
89
|
+
- **SSR Engine**: `renderToString` and `renderToReadableStream` for flexible
|
|
90
|
+
|
|
91
|
+
server rendering.
|
|
92
|
+
|
|
93
|
+
- **Boundaries**: `ServerBoundary` and `ErrorBoundary` for resilient
|
|
94
|
+
|
|
95
|
+
applications.
|
|
71
96
|
|
|
72
97
|
## 🏗️ Example Usage
|
|
73
98
|
|
|
74
99
|
```javascript
|
|
75
|
-
import { render, useStore, createElement } from
|
|
100
|
+
import { render, useStore, createElement } from '@unsetsoft/ryunixjs'
|
|
76
101
|
|
|
77
102
|
function App() {
|
|
78
|
-
const [count, setCount] = useStore(0)
|
|
79
|
-
|
|
80
|
-
return createElement(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
103
|
+
const [count, setCount] = useStore(0)
|
|
104
|
+
|
|
105
|
+
return createElement(
|
|
106
|
+
'div',
|
|
107
|
+
null,
|
|
108
|
+
createElement('h1', null, `Count: ${count}`),
|
|
109
|
+
createElement(
|
|
110
|
+
'button',
|
|
111
|
+
{ onClick: () => setCount(count + 1) },
|
|
112
|
+
'Increment',
|
|
113
|
+
),
|
|
114
|
+
)
|
|
84
115
|
}
|
|
85
116
|
|
|
86
|
-
render(createElement(App), document.getElementById(
|
|
117
|
+
render(createElement(App), document.getElementById('root'))
|
|
87
118
|
```
|
|
88
119
|
|
|
89
120
|
## 📄 License
|
|
90
121
|
|
|
91
|
-
RyunixJS is [MIT Licensed](
|
|
122
|
+
RyunixJS is [MIT Licensed](../../LICENSE).
|
package/dist/Ryunix.esm.js
CHANGED
|
@@ -1288,14 +1288,12 @@ const useReducer = (reducer, initialState, init, defaultPriority = getCurrentPri
|
|
|
1288
1288
|
|
|
1289
1289
|
if (!activeRoot) return
|
|
1290
1290
|
|
|
1291
|
-
|
|
1291
|
+
const newRoot = {
|
|
1292
1292
|
dom: activeRoot.dom,
|
|
1293
1293
|
props: activeRoot.props,
|
|
1294
1294
|
alternate: currentState.currentRoot || null,
|
|
1295
1295
|
};
|
|
1296
|
-
|
|
1297
|
-
currentState.hookIndex = 0;
|
|
1298
|
-
queueUpdate(() => scheduleWork$1(currentState.wipRoot, priority));
|
|
1296
|
+
queueUpdate(() => scheduleWork$1(newRoot, priority));
|
|
1299
1297
|
};
|
|
1300
1298
|
|
|
1301
1299
|
wipFiber.hooks[hookIndex] = hook;
|
|
@@ -2174,6 +2172,21 @@ const updateFunctionComponent = (fiber) => {
|
|
|
2174
2172
|
fiber.effectTag = EFFECT_TAGS.HYDRATE;
|
|
2175
2173
|
}
|
|
2176
2174
|
|
|
2175
|
+
// Memo bailout: skip re-render if props haven't changed
|
|
2176
|
+
if (fiber.type._isMemo && fiber.alternate) {
|
|
2177
|
+
const { children: _pc, ...prevRest } = fiber.alternate.props || {};
|
|
2178
|
+
const { children: _nc, ...nextRest } = fiber.props || {};
|
|
2179
|
+
if (fiber.type._arePropsEqual(prevRest, nextRest)) {
|
|
2180
|
+
fiber.hooks = fiber.alternate.hooks;
|
|
2181
|
+
const oldChild = fiber.alternate.child;
|
|
2182
|
+
if (oldChild) {
|
|
2183
|
+
oldChild.parent = fiber;
|
|
2184
|
+
fiber.child = oldChild;
|
|
2185
|
+
}
|
|
2186
|
+
return
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2177
2190
|
let children = [fiber.type(fiber.props)];
|
|
2178
2191
|
|
|
2179
2192
|
if (fiber.type._contextId && fiber.props.value !== undefined) {
|
|
@@ -3140,18 +3153,12 @@ const renderToStringAsync = async (element, options = {}) => {
|
|
|
3140
3153
|
* @returns {Function} Memoized component
|
|
3141
3154
|
*/
|
|
3142
3155
|
const memo = (Component, arePropsEqual = shallowEqual) => {
|
|
3143
|
-
let prevProps = null;
|
|
3144
|
-
let prevResult = null;
|
|
3145
|
-
|
|
3146
3156
|
const MemoizedComponent = (props) => {
|
|
3147
|
-
|
|
3148
|
-
return prevResult
|
|
3149
|
-
}
|
|
3150
|
-
prevProps = props;
|
|
3151
|
-
prevResult = Component(props);
|
|
3152
|
-
return prevResult
|
|
3157
|
+
return Component(props)
|
|
3153
3158
|
};
|
|
3154
|
-
|
|
3159
|
+
MemoizedComponent._isMemo = true;
|
|
3160
|
+
MemoizedComponent._wrappedComponent = Component;
|
|
3161
|
+
MemoizedComponent._arePropsEqual = arePropsEqual;
|
|
3155
3162
|
MemoizedComponent.displayName = `Memo(${Component.displayName || Component.name || 'Component'})`;
|
|
3156
3163
|
return MemoizedComponent
|
|
3157
3164
|
};
|