@viewfly/core 1.2.3 → 1.2.6
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 +36 -47
- package/bundles/index.js +36 -47
- package/package.json +2 -2
package/bundles/index.esm.js
CHANGED
|
@@ -1349,11 +1349,8 @@ function deepUpdateByComponentDirtyTree(nativeRenderer, component, needMove) {
|
|
|
1349
1349
|
}
|
|
1350
1350
|
function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, needMove) {
|
|
1351
1351
|
const commits = [];
|
|
1352
|
-
function changeOffset() {
|
|
1353
|
-
offset++;
|
|
1354
|
-
}
|
|
1355
1352
|
while (newAtom) {
|
|
1356
|
-
oldAtom = createChanges(newAtom, oldAtom,
|
|
1353
|
+
oldAtom = createChanges(newAtom, oldAtom, commits);
|
|
1357
1354
|
newAtom = newAtom.sibling;
|
|
1358
1355
|
}
|
|
1359
1356
|
let dirtyDiffAtom = oldAtom;
|
|
@@ -1364,7 +1361,6 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, needMo
|
|
|
1364
1361
|
let offset = 0;
|
|
1365
1362
|
const len = commits.length;
|
|
1366
1363
|
for (let i = 0; i < len; i++) {
|
|
1367
|
-
const commit = commits[i];
|
|
1368
1364
|
while (oldAtom) {
|
|
1369
1365
|
if (oldAtom.index <= i) {
|
|
1370
1366
|
offset--;
|
|
@@ -1373,27 +1369,34 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, needMo
|
|
|
1373
1369
|
}
|
|
1374
1370
|
break;
|
|
1375
1371
|
}
|
|
1376
|
-
|
|
1372
|
+
const { dirtyAtom, newAtom } = commits[i];
|
|
1373
|
+
if (dirtyAtom) {
|
|
1374
|
+
switch (dirtyAtom.type) {
|
|
1375
|
+
case ElementAtomType:
|
|
1376
|
+
updateElement(nativeRenderer, context, parentComponent, offset, needMove, newAtom, dirtyAtom);
|
|
1377
|
+
break;
|
|
1378
|
+
case TextAtomType:
|
|
1379
|
+
updateText(nativeRenderer, context, offset, needMove, newAtom, dirtyAtom);
|
|
1380
|
+
break;
|
|
1381
|
+
case ComponentAtomType:
|
|
1382
|
+
updateComponent(nativeRenderer, context, offset, needMove, newAtom, dirtyAtom);
|
|
1383
|
+
break;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
else {
|
|
1387
|
+
buildView(nativeRenderer, parentComponent, newAtom, context);
|
|
1388
|
+
offset++;
|
|
1389
|
+
}
|
|
1377
1390
|
}
|
|
1378
1391
|
}
|
|
1379
|
-
function createChanges(newAtom, oldAtom,
|
|
1392
|
+
function createChanges(newAtom, oldAtom, commits) {
|
|
1380
1393
|
const startDiffAtom = oldAtom;
|
|
1381
1394
|
let prev = null;
|
|
1382
1395
|
while (oldAtom) {
|
|
1383
|
-
|
|
1384
|
-
if (oldAtom.type === newAtomType && oldAtom.nodeType === newAtom.nodeType && oldAtom.key === newAtom.key) {
|
|
1396
|
+
if (oldAtom.type === newAtom.type && oldAtom.nodeType === newAtom.nodeType && oldAtom.key === newAtom.key) {
|
|
1385
1397
|
commits.push({
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
updateElement,
|
|
1389
|
-
params: {
|
|
1390
|
-
oldAtom,
|
|
1391
|
-
newAtom,
|
|
1392
|
-
nativeRenderer,
|
|
1393
|
-
context,
|
|
1394
|
-
effect,
|
|
1395
|
-
parentComponent
|
|
1396
|
-
}
|
|
1398
|
+
dirtyAtom: oldAtom,
|
|
1399
|
+
newAtom
|
|
1397
1400
|
});
|
|
1398
1401
|
const next = oldAtom.sibling;
|
|
1399
1402
|
if (!prev) {
|
|
@@ -1406,25 +1409,12 @@ function createChanges(newAtom, oldAtom, nativeRenderer, commits, context, paren
|
|
|
1406
1409
|
oldAtom = oldAtom.sibling;
|
|
1407
1410
|
}
|
|
1408
1411
|
commits.push({
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
oldAtom: oldAtom,
|
|
1412
|
-
newAtom,
|
|
1413
|
-
nativeRenderer,
|
|
1414
|
-
context,
|
|
1415
|
-
effect,
|
|
1416
|
-
parentComponent
|
|
1417
|
-
}
|
|
1412
|
+
dirtyAtom: null,
|
|
1413
|
+
newAtom
|
|
1418
1414
|
});
|
|
1419
1415
|
return startDiffAtom;
|
|
1420
1416
|
}
|
|
1421
|
-
function
|
|
1422
|
-
const { nativeRenderer, parentComponent, newAtom, context, effect } = params;
|
|
1423
|
-
buildView(nativeRenderer, parentComponent, newAtom, context);
|
|
1424
|
-
effect();
|
|
1425
|
-
}
|
|
1426
|
-
function updateText(params, offset, needMove) {
|
|
1427
|
-
const { oldAtom, newAtom, nativeRenderer, context } = params;
|
|
1417
|
+
function updateText(nativeRenderer, context, offset, needMove, newAtom, oldAtom) {
|
|
1428
1418
|
const nativeNode = oldAtom.nativeNode;
|
|
1429
1419
|
newAtom.nativeNode = nativeNode;
|
|
1430
1420
|
if (needMove || newAtom.index - offset !== oldAtom.index) {
|
|
@@ -1433,23 +1423,21 @@ function updateText(params, offset, needMove) {
|
|
|
1433
1423
|
context.host = nativeNode;
|
|
1434
1424
|
context.isParent = false;
|
|
1435
1425
|
}
|
|
1436
|
-
function updateElement(
|
|
1437
|
-
const
|
|
1438
|
-
newAtom.nativeNode =
|
|
1426
|
+
function updateElement(nativeRenderer, context, parentComponent, offset, needMove, newAtom, oldAtom) {
|
|
1427
|
+
const nativeNode = oldAtom.nativeNode;
|
|
1428
|
+
newAtom.nativeNode = nativeNode;
|
|
1439
1429
|
if (needMove || newAtom.index - offset !== oldAtom.index) {
|
|
1440
1430
|
insertNode(nativeRenderer, newAtom, context);
|
|
1441
1431
|
}
|
|
1442
|
-
context.host =
|
|
1432
|
+
context.host = nativeNode;
|
|
1443
1433
|
context.isParent = false;
|
|
1444
1434
|
updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComponent, {
|
|
1445
|
-
host:
|
|
1435
|
+
host: nativeNode,
|
|
1446
1436
|
isParent: true,
|
|
1447
1437
|
rootHost: context.rootHost
|
|
1448
1438
|
});
|
|
1449
1439
|
}
|
|
1450
|
-
function updateComponent(
|
|
1451
|
-
const { oldAtom, newAtom, nativeRenderer } = params;
|
|
1452
|
-
let context = params.context;
|
|
1440
|
+
function updateComponent(nativeRenderer, context, offset, needMove, newAtom, oldAtom) {
|
|
1453
1441
|
const component = oldAtom.jsxNode;
|
|
1454
1442
|
const portalHost = component.instance.$portalHost;
|
|
1455
1443
|
context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
|
|
@@ -1473,16 +1461,17 @@ function updateComponent(params, offset, needMove) {
|
|
|
1473
1461
|
}
|
|
1474
1462
|
else {
|
|
1475
1463
|
newAtom.child = oldAtom.child;
|
|
1476
|
-
reuseComponentView(nativeRenderer, newAtom.child, context, needMove,
|
|
1464
|
+
reuseComponentView(nativeRenderer, newAtom.child, context, needMove, !canUpdate);
|
|
1477
1465
|
}
|
|
1478
1466
|
component.rendered();
|
|
1479
1467
|
}
|
|
1480
1468
|
function reuseComponentView(nativeRenderer, child, context, moveView, skipSubComponentDiff) {
|
|
1481
1469
|
const updateContext = (atom) => {
|
|
1482
|
-
|
|
1470
|
+
const jsxNode = atom.jsxNode;
|
|
1471
|
+
if (jsxNode instanceof Component) {
|
|
1483
1472
|
reuseComponentView(nativeRenderer, atom.child, context, moveView, skipSubComponentDiff);
|
|
1484
1473
|
if (!skipSubComponentDiff) {
|
|
1485
|
-
deepUpdateByComponentDirtyTree(nativeRenderer,
|
|
1474
|
+
deepUpdateByComponentDirtyTree(nativeRenderer, jsxNode, moveView);
|
|
1486
1475
|
}
|
|
1487
1476
|
}
|
|
1488
1477
|
else {
|
package/bundles/index.js
CHANGED
|
@@ -1351,11 +1351,8 @@ function deepUpdateByComponentDirtyTree(nativeRenderer, component, needMove) {
|
|
|
1351
1351
|
}
|
|
1352
1352
|
function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, needMove) {
|
|
1353
1353
|
const commits = [];
|
|
1354
|
-
function changeOffset() {
|
|
1355
|
-
offset++;
|
|
1356
|
-
}
|
|
1357
1354
|
while (newAtom) {
|
|
1358
|
-
oldAtom = createChanges(newAtom, oldAtom,
|
|
1355
|
+
oldAtom = createChanges(newAtom, oldAtom, commits);
|
|
1359
1356
|
newAtom = newAtom.sibling;
|
|
1360
1357
|
}
|
|
1361
1358
|
let dirtyDiffAtom = oldAtom;
|
|
@@ -1366,7 +1363,6 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, needMo
|
|
|
1366
1363
|
let offset = 0;
|
|
1367
1364
|
const len = commits.length;
|
|
1368
1365
|
for (let i = 0; i < len; i++) {
|
|
1369
|
-
const commit = commits[i];
|
|
1370
1366
|
while (oldAtom) {
|
|
1371
1367
|
if (oldAtom.index <= i) {
|
|
1372
1368
|
offset--;
|
|
@@ -1375,27 +1371,34 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, needMo
|
|
|
1375
1371
|
}
|
|
1376
1372
|
break;
|
|
1377
1373
|
}
|
|
1378
|
-
|
|
1374
|
+
const { dirtyAtom, newAtom } = commits[i];
|
|
1375
|
+
if (dirtyAtom) {
|
|
1376
|
+
switch (dirtyAtom.type) {
|
|
1377
|
+
case ElementAtomType:
|
|
1378
|
+
updateElement(nativeRenderer, context, parentComponent, offset, needMove, newAtom, dirtyAtom);
|
|
1379
|
+
break;
|
|
1380
|
+
case TextAtomType:
|
|
1381
|
+
updateText(nativeRenderer, context, offset, needMove, newAtom, dirtyAtom);
|
|
1382
|
+
break;
|
|
1383
|
+
case ComponentAtomType:
|
|
1384
|
+
updateComponent(nativeRenderer, context, offset, needMove, newAtom, dirtyAtom);
|
|
1385
|
+
break;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
else {
|
|
1389
|
+
buildView(nativeRenderer, parentComponent, newAtom, context);
|
|
1390
|
+
offset++;
|
|
1391
|
+
}
|
|
1379
1392
|
}
|
|
1380
1393
|
}
|
|
1381
|
-
function createChanges(newAtom, oldAtom,
|
|
1394
|
+
function createChanges(newAtom, oldAtom, commits) {
|
|
1382
1395
|
const startDiffAtom = oldAtom;
|
|
1383
1396
|
let prev = null;
|
|
1384
1397
|
while (oldAtom) {
|
|
1385
|
-
|
|
1386
|
-
if (oldAtom.type === newAtomType && oldAtom.nodeType === newAtom.nodeType && oldAtom.key === newAtom.key) {
|
|
1398
|
+
if (oldAtom.type === newAtom.type && oldAtom.nodeType === newAtom.nodeType && oldAtom.key === newAtom.key) {
|
|
1387
1399
|
commits.push({
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
updateElement,
|
|
1391
|
-
params: {
|
|
1392
|
-
oldAtom,
|
|
1393
|
-
newAtom,
|
|
1394
|
-
nativeRenderer,
|
|
1395
|
-
context,
|
|
1396
|
-
effect,
|
|
1397
|
-
parentComponent
|
|
1398
|
-
}
|
|
1400
|
+
dirtyAtom: oldAtom,
|
|
1401
|
+
newAtom
|
|
1399
1402
|
});
|
|
1400
1403
|
const next = oldAtom.sibling;
|
|
1401
1404
|
if (!prev) {
|
|
@@ -1408,25 +1411,12 @@ function createChanges(newAtom, oldAtom, nativeRenderer, commits, context, paren
|
|
|
1408
1411
|
oldAtom = oldAtom.sibling;
|
|
1409
1412
|
}
|
|
1410
1413
|
commits.push({
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
oldAtom: oldAtom,
|
|
1414
|
-
newAtom,
|
|
1415
|
-
nativeRenderer,
|
|
1416
|
-
context,
|
|
1417
|
-
effect,
|
|
1418
|
-
parentComponent
|
|
1419
|
-
}
|
|
1414
|
+
dirtyAtom: null,
|
|
1415
|
+
newAtom
|
|
1420
1416
|
});
|
|
1421
1417
|
return startDiffAtom;
|
|
1422
1418
|
}
|
|
1423
|
-
function
|
|
1424
|
-
const { nativeRenderer, parentComponent, newAtom, context, effect } = params;
|
|
1425
|
-
buildView(nativeRenderer, parentComponent, newAtom, context);
|
|
1426
|
-
effect();
|
|
1427
|
-
}
|
|
1428
|
-
function updateText(params, offset, needMove) {
|
|
1429
|
-
const { oldAtom, newAtom, nativeRenderer, context } = params;
|
|
1419
|
+
function updateText(nativeRenderer, context, offset, needMove, newAtom, oldAtom) {
|
|
1430
1420
|
const nativeNode = oldAtom.nativeNode;
|
|
1431
1421
|
newAtom.nativeNode = nativeNode;
|
|
1432
1422
|
if (needMove || newAtom.index - offset !== oldAtom.index) {
|
|
@@ -1435,23 +1425,21 @@ function updateText(params, offset, needMove) {
|
|
|
1435
1425
|
context.host = nativeNode;
|
|
1436
1426
|
context.isParent = false;
|
|
1437
1427
|
}
|
|
1438
|
-
function updateElement(
|
|
1439
|
-
const
|
|
1440
|
-
newAtom.nativeNode =
|
|
1428
|
+
function updateElement(nativeRenderer, context, parentComponent, offset, needMove, newAtom, oldAtom) {
|
|
1429
|
+
const nativeNode = oldAtom.nativeNode;
|
|
1430
|
+
newAtom.nativeNode = nativeNode;
|
|
1441
1431
|
if (needMove || newAtom.index - offset !== oldAtom.index) {
|
|
1442
1432
|
insertNode(nativeRenderer, newAtom, context);
|
|
1443
1433
|
}
|
|
1444
|
-
context.host =
|
|
1434
|
+
context.host = nativeNode;
|
|
1445
1435
|
context.isParent = false;
|
|
1446
1436
|
updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComponent, {
|
|
1447
|
-
host:
|
|
1437
|
+
host: nativeNode,
|
|
1448
1438
|
isParent: true,
|
|
1449
1439
|
rootHost: context.rootHost
|
|
1450
1440
|
});
|
|
1451
1441
|
}
|
|
1452
|
-
function updateComponent(
|
|
1453
|
-
const { oldAtom, newAtom, nativeRenderer } = params;
|
|
1454
|
-
let context = params.context;
|
|
1442
|
+
function updateComponent(nativeRenderer, context, offset, needMove, newAtom, oldAtom) {
|
|
1455
1443
|
const component = oldAtom.jsxNode;
|
|
1456
1444
|
const portalHost = component.instance.$portalHost;
|
|
1457
1445
|
context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
|
|
@@ -1475,16 +1463,17 @@ function updateComponent(params, offset, needMove) {
|
|
|
1475
1463
|
}
|
|
1476
1464
|
else {
|
|
1477
1465
|
newAtom.child = oldAtom.child;
|
|
1478
|
-
reuseComponentView(nativeRenderer, newAtom.child, context, needMove,
|
|
1466
|
+
reuseComponentView(nativeRenderer, newAtom.child, context, needMove, !canUpdate);
|
|
1479
1467
|
}
|
|
1480
1468
|
component.rendered();
|
|
1481
1469
|
}
|
|
1482
1470
|
function reuseComponentView(nativeRenderer, child, context, moveView, skipSubComponentDiff) {
|
|
1483
1471
|
const updateContext = (atom) => {
|
|
1484
|
-
|
|
1472
|
+
const jsxNode = atom.jsxNode;
|
|
1473
|
+
if (jsxNode instanceof Component) {
|
|
1485
1474
|
reuseComponentView(nativeRenderer, atom.child, context, moveView, skipSubComponentDiff);
|
|
1486
1475
|
if (!skipSubComponentDiff) {
|
|
1487
|
-
deepUpdateByComponentDirtyTree(nativeRenderer,
|
|
1476
|
+
deepUpdateByComponentDirtyTree(nativeRenderer, jsxNode, moveView);
|
|
1488
1477
|
}
|
|
1489
1478
|
}
|
|
1490
1479
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
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",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"bugs": {
|
|
51
51
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "74a32054799e20584e3c9eb12c5bf28f7e20efc3",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"reflect-metadata": "^0.2.2"
|
|
56
56
|
}
|