@unsetsoft/ryunixjs 0.1.3-alpha.1 → 0.1.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 ADDED
@@ -0,0 +1,25 @@
1
+ # RyunixJS
2
+
3
+ ## What is RyunixJS?
4
+
5
+ Is a ReactJS Clone! Even lighter, however, at a very early stage for production use.
6
+
7
+ ## Install & Usage
8
+
9
+ `npm install @unsetsoft/create-ryunix-app -g`
10
+
11
+ ### Obtain and download the template
12
+
13
+ `create-ryunix-app get`
14
+
15
+ ### Rename your final folder
16
+
17
+ `create-ryunix-app get --dirname awasome-ryunix-app`
18
+
19
+ ## Bugs?
20
+
21
+ You can create an issue on GitHub.
22
+
23
+ ## Do you want to contribute?
24
+
25
+ Fork a send a pull request!
package/lib/component.js CHANGED
@@ -2,15 +2,5 @@ import { reconcile } from "./reconciler";
2
2
  export class Component {
3
3
  constructor(props) {
4
4
  this.props = props;
5
- this.state = this.state || {};
6
- }
7
- setState(partialState) {
8
- this.state = Object.assign({}, this.state, partialState);
9
- updateInstance(this.__internalInstance);
10
5
  }
11
6
  }
12
- function updateInstance(internalInstance) {
13
- const parentDom = internalInstance.dom.parentNode;
14
- const element = internalInstance.element;
15
- reconcile(parentDom, internalInstance, element);
16
- }
package/lib/reconciler.js CHANGED
@@ -12,28 +12,36 @@ export function reconcile(parentDom, instance, element) {
12
12
  const newInstance = instantiate(element);
13
13
  parentDom.appendChild(newInstance.dom);
14
14
  return newInstance;
15
- } else if (element == null) {
15
+ }
16
+
17
+ if (element == null) {
16
18
  parentDom.removeChild(instance.dom);
17
19
  return null;
18
- } else if (instance.element.type !== element.type) {
20
+ }
21
+
22
+ if (instance.element.type !== element.type) {
19
23
  const newInstance = instantiate(element);
20
- parentDom.replaceChild(newInstance.dom, instance.dom);
24
+ parentDom.replaceChild(instance.dom, newInstance.dom);
21
25
  return newInstance;
22
- } else if (typeof element.type === "string") {
26
+ }
27
+
28
+ if (typeof element.type === "string") {
23
29
  instance.childInstances = reconcileChildren(instance, element);
24
30
  instance.element = element;
25
31
  return instance;
26
- } else {
27
- instance.publicInstance.props = element.props;
28
- const childElement = instance.publicInstance.render();
29
- const oldChildInstance = instance.childInstance;
30
- const childInstance = reconcile(parentDom, oldChildInstance, childElement);
31
- instance.dom = childInstance.dom;
32
- instance.childInstance = childInstance;
33
- instance.element = element;
34
- return instance;
35
32
  }
33
+
34
+ // Si no es una cadena, asumimos que es un componente personalizado
35
+ instance.publicInstance.props = element.props;
36
+ const childElement = instance.publicInstance.render();
37
+ const oldChildInstance = instance.childInstance;
38
+ const childInstance = reconcile(parentDom, oldChildInstance, childElement);
39
+ instance.dom = childInstance.dom;
40
+ instance.childInstance = childInstance;
41
+ instance.element = element;
42
+ return instance;
36
43
  }
44
+
37
45
  function instantiate(element) {
38
46
  const { type, props } = element;
39
47
  const isDomElement = typeof type === "string";
@@ -74,17 +82,21 @@ function createPublicInstance(element, internalInstance) {
74
82
  publicInstance.__internalInstance = internalInstance;
75
83
  return publicInstance;
76
84
  }
85
+
77
86
  function reconcileChildren(instance, element) {
78
- const dom = instance.dom;
79
- const childInstances = instance.childInstances;
87
+ const { dom, childInstances } = instance;
80
88
  const nextChildElements = element.props.children || [];
89
+
81
90
  const newChildInstances = [];
91
+
82
92
  const count = Math.max(childInstances.length, nextChildElements.length);
93
+
83
94
  for (let i = 0; i < count; i++) {
84
95
  const childInstance = childInstances[i];
85
96
  const childElement = nextChildElements[i];
86
97
  const newChildInstance = reconcile(dom, childInstance, childElement);
87
98
  newChildInstances.push(newChildInstance);
88
99
  }
89
- return newChildInstances.filter((instance) => instance != null);
90
- }
100
+
101
+ return newChildInstances.filter(Boolean);
102
+ }
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "@unsetsoft/ryunixjs",
3
- "version": "0.1.3-alpha.1",
3
+ "version": "0.1.10",
4
4
  "license": "MIT",
5
5
  "main": "./dist/Ryunix.js",
6
6
  "private": false,
7
+ "bugs": {
8
+ "url": "https://github.com/UnSetSoft/Ryunixjs/issues"
9
+ },
10
+ "homepage": "https://github.com/UnSetSoft/Ryunixjs#readme",
7
11
  "scripts": {
8
12
  "build": "rollup ./lib/ryunix.js --file ./dist/Ryunix.js --format umd --name Ryunix",
9
13
  "prepublishOnly": "yarn build"
10
14
  },
11
15
  "devDependencies": {
12
16
  "rollup": "3.24.0"
17
+ },
18
+ "engines": {
19
+ "node": ">=18.16.0"
13
20
  }
14
21
  }