@viewfly/core 1.0.0-alpha.6 → 1.0.0-alpha.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/bundles/index.esm.js +35 -32
- package/bundles/index.js +35 -32
- package/package.json +2 -2
package/bundles/index.esm.js
CHANGED
|
@@ -591,13 +591,13 @@ function getArrayChanges(left, right) {
|
|
|
591
591
|
return changes;
|
|
592
592
|
}
|
|
593
593
|
function classToString(config) {
|
|
594
|
-
if (!config) {
|
|
595
|
-
return '';
|
|
596
|
-
}
|
|
597
594
|
if (typeof config === 'string') {
|
|
598
595
|
return config;
|
|
599
596
|
}
|
|
600
|
-
|
|
597
|
+
if (!config) {
|
|
598
|
+
return '';
|
|
599
|
+
}
|
|
600
|
+
if (Array.isArray(config)) {
|
|
601
601
|
const classes = [];
|
|
602
602
|
for (const i of config) {
|
|
603
603
|
const v = classToString(i);
|
|
@@ -607,7 +607,7 @@ function classToString(config) {
|
|
|
607
607
|
}
|
|
608
608
|
return classes.join(' ');
|
|
609
609
|
}
|
|
610
|
-
|
|
610
|
+
if (typeof config === 'object') {
|
|
611
611
|
if (config.toString !== Object.prototype.toString && !config.toString.toString().includes('[native code]')) {
|
|
612
612
|
return config.toString();
|
|
613
613
|
}
|
|
@@ -741,30 +741,32 @@ class Component extends ReflectiveInjector {
|
|
|
741
741
|
};
|
|
742
742
|
}
|
|
743
743
|
update(newProps, forceUpdate = false) {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
744
|
+
if (!forceUpdate) {
|
|
745
|
+
const { add, remove, replace } = getObjectChanges(newProps, this.props);
|
|
746
|
+
if (add.length || remove.length || replace.length) {
|
|
747
|
+
this.invokePropsChangedHooks(newProps);
|
|
748
|
+
}
|
|
749
|
+
else if (!this.dirty) {
|
|
750
|
+
this.props = newProps;
|
|
751
|
+
return this.template;
|
|
752
|
+
}
|
|
753
|
+
const newRefs = toRefs(newProps.ref);
|
|
754
|
+
if (this.refs) {
|
|
755
|
+
for (const oldRef of this.refs) {
|
|
756
|
+
if (!newRefs.includes(oldRef)) {
|
|
757
|
+
oldRef.unBind(this.instance);
|
|
758
|
+
}
|
|
757
759
|
}
|
|
758
760
|
}
|
|
761
|
+
for (const newRef of newRefs) {
|
|
762
|
+
newRef.bind(this.instance);
|
|
763
|
+
}
|
|
764
|
+
if (newRefs.length) {
|
|
765
|
+
this.refs = newRefs;
|
|
766
|
+
}
|
|
759
767
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}
|
|
763
|
-
if (newRefs.length) {
|
|
764
|
-
this.refs = newRefs;
|
|
765
|
-
}
|
|
766
|
-
if (!forceUpdate && typeof this.instance.$useMemo === 'function') {
|
|
767
|
-
if (this.instance.$useMemo(newProps, oldProps)) {
|
|
768
|
+
if (typeof this.instance.$useMemo === 'function') {
|
|
769
|
+
if (this.instance.$useMemo(newProps, this.props)) {
|
|
768
770
|
return this.template;
|
|
769
771
|
}
|
|
770
772
|
}
|
|
@@ -1386,7 +1388,7 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context) {
|
|
|
1386
1388
|
}
|
|
1387
1389
|
let dirtyDiffAtom = oldAtom;
|
|
1388
1390
|
while (dirtyDiffAtom) {
|
|
1389
|
-
cleanView(nativeRenderer, dirtyDiffAtom,
|
|
1391
|
+
cleanView(nativeRenderer, dirtyDiffAtom, true);
|
|
1390
1392
|
dirtyDiffAtom = dirtyDiffAtom.sibling;
|
|
1391
1393
|
}
|
|
1392
1394
|
let offset = 0;
|
|
@@ -1480,7 +1482,7 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
|
|
|
1480
1482
|
let atom = oldAtom.child;
|
|
1481
1483
|
nativeRenderer.cleanChildren(oldAtom.nativeNode, oldAtom.isSvg);
|
|
1482
1484
|
while (atom) {
|
|
1483
|
-
cleanView(nativeRenderer, atom,
|
|
1485
|
+
cleanView(nativeRenderer, atom, false);
|
|
1484
1486
|
atom = atom.sibling;
|
|
1485
1487
|
}
|
|
1486
1488
|
}
|
|
@@ -1511,7 +1513,7 @@ function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRende
|
|
|
1511
1513
|
else if (reusedAtom.child) {
|
|
1512
1514
|
let atom = reusedAtom.child;
|
|
1513
1515
|
while (atom) {
|
|
1514
|
-
cleanView(nativeRenderer, atom,
|
|
1516
|
+
cleanView(nativeRenderer, atom, true);
|
|
1515
1517
|
atom = atom.sibling;
|
|
1516
1518
|
}
|
|
1517
1519
|
}
|
|
@@ -1544,9 +1546,9 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
|
|
|
1544
1546
|
}
|
|
1545
1547
|
function cleanView(nativeRenderer, atom, needClean) {
|
|
1546
1548
|
if (atom.nativeNode) {
|
|
1547
|
-
if (
|
|
1549
|
+
if (needClean) {
|
|
1548
1550
|
nativeRenderer.remove(atom.nativeNode, atom.isSvg);
|
|
1549
|
-
needClean =
|
|
1551
|
+
needClean = false;
|
|
1550
1552
|
}
|
|
1551
1553
|
if (atom.type === 'element') {
|
|
1552
1554
|
const ref = atom.jsxNode.props[refKey];
|
|
@@ -1556,7 +1558,7 @@ function cleanView(nativeRenderer, atom, needClean) {
|
|
|
1556
1558
|
let child = atom.child;
|
|
1557
1559
|
while (child) {
|
|
1558
1560
|
if (child.jsxNode instanceof Component && child.jsxNode.instance.$portalHost) {
|
|
1559
|
-
needClean =
|
|
1561
|
+
needClean = true;
|
|
1560
1562
|
}
|
|
1561
1563
|
cleanView(nativeRenderer, child, needClean);
|
|
1562
1564
|
child = child.sibling;
|
|
@@ -1616,6 +1618,7 @@ function createChainByJSXElement(element, prevAtom, isSvg) {
|
|
|
1616
1618
|
};
|
|
1617
1619
|
prevAtom.sibling = atom;
|
|
1618
1620
|
atom.child = createChildChain(element.props.children, isSvg);
|
|
1621
|
+
element.props.children = null;
|
|
1619
1622
|
return atom;
|
|
1620
1623
|
}
|
|
1621
1624
|
function createChainByNode(jsxNode, prevAtom, isSvg) {
|
package/bundles/index.js
CHANGED
|
@@ -593,13 +593,13 @@ function getArrayChanges(left, right) {
|
|
|
593
593
|
return changes;
|
|
594
594
|
}
|
|
595
595
|
function classToString(config) {
|
|
596
|
-
if (!config) {
|
|
597
|
-
return '';
|
|
598
|
-
}
|
|
599
596
|
if (typeof config === 'string') {
|
|
600
597
|
return config;
|
|
601
598
|
}
|
|
602
|
-
|
|
599
|
+
if (!config) {
|
|
600
|
+
return '';
|
|
601
|
+
}
|
|
602
|
+
if (Array.isArray(config)) {
|
|
603
603
|
const classes = [];
|
|
604
604
|
for (const i of config) {
|
|
605
605
|
const v = classToString(i);
|
|
@@ -609,7 +609,7 @@ function classToString(config) {
|
|
|
609
609
|
}
|
|
610
610
|
return classes.join(' ');
|
|
611
611
|
}
|
|
612
|
-
|
|
612
|
+
if (typeof config === 'object') {
|
|
613
613
|
if (config.toString !== Object.prototype.toString && !config.toString.toString().includes('[native code]')) {
|
|
614
614
|
return config.toString();
|
|
615
615
|
}
|
|
@@ -743,30 +743,32 @@ class Component extends ReflectiveInjector {
|
|
|
743
743
|
};
|
|
744
744
|
}
|
|
745
745
|
update(newProps, forceUpdate = false) {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
746
|
+
if (!forceUpdate) {
|
|
747
|
+
const { add, remove, replace } = getObjectChanges(newProps, this.props);
|
|
748
|
+
if (add.length || remove.length || replace.length) {
|
|
749
|
+
this.invokePropsChangedHooks(newProps);
|
|
750
|
+
}
|
|
751
|
+
else if (!this.dirty) {
|
|
752
|
+
this.props = newProps;
|
|
753
|
+
return this.template;
|
|
754
|
+
}
|
|
755
|
+
const newRefs = toRefs(newProps.ref);
|
|
756
|
+
if (this.refs) {
|
|
757
|
+
for (const oldRef of this.refs) {
|
|
758
|
+
if (!newRefs.includes(oldRef)) {
|
|
759
|
+
oldRef.unBind(this.instance);
|
|
760
|
+
}
|
|
759
761
|
}
|
|
760
762
|
}
|
|
763
|
+
for (const newRef of newRefs) {
|
|
764
|
+
newRef.bind(this.instance);
|
|
765
|
+
}
|
|
766
|
+
if (newRefs.length) {
|
|
767
|
+
this.refs = newRefs;
|
|
768
|
+
}
|
|
761
769
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
}
|
|
765
|
-
if (newRefs.length) {
|
|
766
|
-
this.refs = newRefs;
|
|
767
|
-
}
|
|
768
|
-
if (!forceUpdate && typeof this.instance.$useMemo === 'function') {
|
|
769
|
-
if (this.instance.$useMemo(newProps, oldProps)) {
|
|
770
|
+
if (typeof this.instance.$useMemo === 'function') {
|
|
771
|
+
if (this.instance.$useMemo(newProps, this.props)) {
|
|
770
772
|
return this.template;
|
|
771
773
|
}
|
|
772
774
|
}
|
|
@@ -1388,7 +1390,7 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context) {
|
|
|
1388
1390
|
}
|
|
1389
1391
|
let dirtyDiffAtom = oldAtom;
|
|
1390
1392
|
while (dirtyDiffAtom) {
|
|
1391
|
-
cleanView(nativeRenderer, dirtyDiffAtom,
|
|
1393
|
+
cleanView(nativeRenderer, dirtyDiffAtom, true);
|
|
1392
1394
|
dirtyDiffAtom = dirtyDiffAtom.sibling;
|
|
1393
1395
|
}
|
|
1394
1396
|
let offset = 0;
|
|
@@ -1482,7 +1484,7 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
|
|
|
1482
1484
|
let atom = oldAtom.child;
|
|
1483
1485
|
nativeRenderer.cleanChildren(oldAtom.nativeNode, oldAtom.isSvg);
|
|
1484
1486
|
while (atom) {
|
|
1485
|
-
cleanView(nativeRenderer, atom,
|
|
1487
|
+
cleanView(nativeRenderer, atom, false);
|
|
1486
1488
|
atom = atom.sibling;
|
|
1487
1489
|
}
|
|
1488
1490
|
}
|
|
@@ -1513,7 +1515,7 @@ function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRende
|
|
|
1513
1515
|
else if (reusedAtom.child) {
|
|
1514
1516
|
let atom = reusedAtom.child;
|
|
1515
1517
|
while (atom) {
|
|
1516
|
-
cleanView(nativeRenderer, atom,
|
|
1518
|
+
cleanView(nativeRenderer, atom, true);
|
|
1517
1519
|
atom = atom.sibling;
|
|
1518
1520
|
}
|
|
1519
1521
|
}
|
|
@@ -1546,9 +1548,9 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
|
|
|
1546
1548
|
}
|
|
1547
1549
|
function cleanView(nativeRenderer, atom, needClean) {
|
|
1548
1550
|
if (atom.nativeNode) {
|
|
1549
|
-
if (
|
|
1551
|
+
if (needClean) {
|
|
1550
1552
|
nativeRenderer.remove(atom.nativeNode, atom.isSvg);
|
|
1551
|
-
needClean =
|
|
1553
|
+
needClean = false;
|
|
1552
1554
|
}
|
|
1553
1555
|
if (atom.type === 'element') {
|
|
1554
1556
|
const ref = atom.jsxNode.props[refKey];
|
|
@@ -1558,7 +1560,7 @@ function cleanView(nativeRenderer, atom, needClean) {
|
|
|
1558
1560
|
let child = atom.child;
|
|
1559
1561
|
while (child) {
|
|
1560
1562
|
if (child.jsxNode instanceof Component && child.jsxNode.instance.$portalHost) {
|
|
1561
|
-
needClean =
|
|
1563
|
+
needClean = true;
|
|
1562
1564
|
}
|
|
1563
1565
|
cleanView(nativeRenderer, child, needClean);
|
|
1564
1566
|
child = child.sibling;
|
|
@@ -1618,6 +1620,7 @@ function createChainByJSXElement(element, prevAtom, isSvg) {
|
|
|
1618
1620
|
};
|
|
1619
1621
|
prevAtom.sibling = atom;
|
|
1620
1622
|
atom.child = createChildChain(element.props.children, isSvg);
|
|
1623
|
+
element.props.children = null;
|
|
1621
1624
|
return atom;
|
|
1622
1625
|
}
|
|
1623
1626
|
function createChainByNode(jsxNode, prevAtom, isSvg) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"description": "Viewfly is a simple and easy-to-use JavaScript framework with an intuitive development experience.",
|
|
5
5
|
"main": "./bundles/index.js",
|
|
6
6
|
"module": "./bundles/index.esm.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"bugs": {
|
|
48
48
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "092e986d74477afb6246001ca58962172f926e73",
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"reflect-metadata": "^0.2.2"
|
|
53
53
|
}
|