@viewfly/core 0.5.0 → 0.5.1
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.
|
@@ -3,6 +3,7 @@ export declare abstract class NativeRenderer<ElementNode = NativeNode, TextNode
|
|
|
3
3
|
abstract createElement(name: string, isSvg: boolean): ElementNode;
|
|
4
4
|
abstract createTextNode(textContent: string, isSvg: boolean): TextNode;
|
|
5
5
|
abstract setProperty(node: ElementNode, key: string, value: any, isSvg: boolean): void;
|
|
6
|
+
abstract appendChild(parent: ElementNode, newChild: ElementNode | TextNode, isSvg: boolean): void;
|
|
6
7
|
abstract prependChild(parent: ElementNode, newChild: ElementNode | TextNode, isSvg: boolean): void;
|
|
7
8
|
abstract removeProperty(node: ElementNode, key: string, isSvg: boolean): void;
|
|
8
9
|
abstract setStyle(target: ElementNode, key: string, value: any, isSvg: boolean): void;
|
package/bundles/index.esm.js
CHANGED
|
@@ -1258,7 +1258,8 @@ function createRenderer(component, nativeRenderer) {
|
|
|
1258
1258
|
};
|
|
1259
1259
|
componentRender(nativeRenderer, component, atom, {
|
|
1260
1260
|
isParent: true,
|
|
1261
|
-
host
|
|
1261
|
+
host,
|
|
1262
|
+
rootHost: host
|
|
1262
1263
|
});
|
|
1263
1264
|
}
|
|
1264
1265
|
else {
|
|
@@ -1285,7 +1286,12 @@ function buildView(nativeRenderer, parentComponent, atom, context) {
|
|
|
1285
1286
|
}
|
|
1286
1287
|
atom.nativeNode = nativeNode;
|
|
1287
1288
|
if (context.isParent) {
|
|
1288
|
-
|
|
1289
|
+
if (context.host === context.rootHost) {
|
|
1290
|
+
nativeRenderer.appendChild(context.host, nativeNode, atom.isSvg);
|
|
1291
|
+
}
|
|
1292
|
+
else {
|
|
1293
|
+
nativeRenderer.prependChild(context.host, nativeNode, atom.isSvg);
|
|
1294
|
+
}
|
|
1289
1295
|
}
|
|
1290
1296
|
else {
|
|
1291
1297
|
nativeRenderer.insertAfter(nativeNode, context.host, atom.isSvg);
|
|
@@ -1293,7 +1299,8 @@ function buildView(nativeRenderer, parentComponent, atom, context) {
|
|
|
1293
1299
|
if (atom.jsxNode instanceof JSXElement) {
|
|
1294
1300
|
const childContext = {
|
|
1295
1301
|
isParent: true,
|
|
1296
|
-
host: nativeNode
|
|
1302
|
+
host: nativeNode,
|
|
1303
|
+
rootHost: context.rootHost
|
|
1297
1304
|
};
|
|
1298
1305
|
let child = atom.child;
|
|
1299
1306
|
while (child) {
|
|
@@ -1321,7 +1328,7 @@ function updateView(nativeRenderer, component) {
|
|
|
1321
1328
|
}
|
|
1322
1329
|
}
|
|
1323
1330
|
function applyChanges(nativeRenderer, component) {
|
|
1324
|
-
const { atom, host, isParent } = component.$$view;
|
|
1331
|
+
const { atom, host, isParent, rootHost } = component.$$view;
|
|
1325
1332
|
const diffAtom = atom.child;
|
|
1326
1333
|
const template = component.update(component.props, true);
|
|
1327
1334
|
if (template) {
|
|
@@ -1332,7 +1339,8 @@ function applyChanges(nativeRenderer, component) {
|
|
|
1332
1339
|
}
|
|
1333
1340
|
const context = {
|
|
1334
1341
|
host,
|
|
1335
|
-
isParent
|
|
1342
|
+
isParent,
|
|
1343
|
+
rootHost
|
|
1336
1344
|
};
|
|
1337
1345
|
diff(nativeRenderer, component, atom.child, diffAtom, context, 0, 0);
|
|
1338
1346
|
const next = atom.sibling;
|
|
@@ -1464,7 +1472,12 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
|
|
|
1464
1472
|
const host = context.host;
|
|
1465
1473
|
if (expectIndex - offset !== oldIndex) {
|
|
1466
1474
|
if (context.isParent) {
|
|
1467
|
-
|
|
1475
|
+
if (host === context.rootHost) {
|
|
1476
|
+
nativeRenderer.appendChild(host, newAtom.nativeNode, newAtom.isSvg);
|
|
1477
|
+
}
|
|
1478
|
+
else {
|
|
1479
|
+
nativeRenderer.prependChild(host, newAtom.nativeNode, newAtom.isSvg);
|
|
1480
|
+
}
|
|
1468
1481
|
}
|
|
1469
1482
|
else {
|
|
1470
1483
|
nativeRenderer.insertAfter(newAtom.nativeNode, host, newAtom.isSvg);
|
|
@@ -1476,7 +1489,8 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
|
|
|
1476
1489
|
if (newAtom.child) {
|
|
1477
1490
|
diff(nativeRenderer, parentComponent, newAtom.child, oldAtom.child, {
|
|
1478
1491
|
host: newAtom.nativeNode,
|
|
1479
|
-
isParent: true
|
|
1492
|
+
isParent: true,
|
|
1493
|
+
rootHost: context.rootHost
|
|
1480
1494
|
}, 0, 0);
|
|
1481
1495
|
}
|
|
1482
1496
|
else if (oldAtom.child) {
|
|
@@ -1538,7 +1552,12 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
|
|
|
1538
1552
|
else {
|
|
1539
1553
|
if (moveView) {
|
|
1540
1554
|
if (context.isParent) {
|
|
1541
|
-
|
|
1555
|
+
if (context.host === context.rootHost) {
|
|
1556
|
+
nativeRenderer.appendChild(context.host, atom.nativeNode, atom.isSvg);
|
|
1557
|
+
}
|
|
1558
|
+
else {
|
|
1559
|
+
nativeRenderer.prependChild(context.host, atom.nativeNode, atom.isSvg);
|
|
1560
|
+
}
|
|
1542
1561
|
}
|
|
1543
1562
|
else {
|
|
1544
1563
|
nativeRenderer.insertAfter(atom.nativeNode, context.host, atom.isSvg);
|
|
@@ -1838,7 +1857,10 @@ class RootComponent extends Component {
|
|
|
1838
1857
|
const viewflyErrorFn = makeError('Viewfly');
|
|
1839
1858
|
function viewfly(config) {
|
|
1840
1859
|
const { context, nativeRenderer, autoUpdate, root } = Object.assign({ autoUpdate: true }, config);
|
|
1841
|
-
const appProviders = [
|
|
1860
|
+
const appProviders = [{
|
|
1861
|
+
provide: NativeRenderer,
|
|
1862
|
+
useValue: nativeRenderer
|
|
1863
|
+
}];
|
|
1842
1864
|
const modules = [];
|
|
1843
1865
|
let destroyed = false;
|
|
1844
1866
|
let appHost = null;
|
package/bundles/index.js
CHANGED
|
@@ -1260,7 +1260,8 @@ function createRenderer(component, nativeRenderer) {
|
|
|
1260
1260
|
};
|
|
1261
1261
|
componentRender(nativeRenderer, component, atom, {
|
|
1262
1262
|
isParent: true,
|
|
1263
|
-
host
|
|
1263
|
+
host,
|
|
1264
|
+
rootHost: host
|
|
1264
1265
|
});
|
|
1265
1266
|
}
|
|
1266
1267
|
else {
|
|
@@ -1287,7 +1288,12 @@ function buildView(nativeRenderer, parentComponent, atom, context) {
|
|
|
1287
1288
|
}
|
|
1288
1289
|
atom.nativeNode = nativeNode;
|
|
1289
1290
|
if (context.isParent) {
|
|
1290
|
-
|
|
1291
|
+
if (context.host === context.rootHost) {
|
|
1292
|
+
nativeRenderer.appendChild(context.host, nativeNode, atom.isSvg);
|
|
1293
|
+
}
|
|
1294
|
+
else {
|
|
1295
|
+
nativeRenderer.prependChild(context.host, nativeNode, atom.isSvg);
|
|
1296
|
+
}
|
|
1291
1297
|
}
|
|
1292
1298
|
else {
|
|
1293
1299
|
nativeRenderer.insertAfter(nativeNode, context.host, atom.isSvg);
|
|
@@ -1295,7 +1301,8 @@ function buildView(nativeRenderer, parentComponent, atom, context) {
|
|
|
1295
1301
|
if (atom.jsxNode instanceof JSXElement) {
|
|
1296
1302
|
const childContext = {
|
|
1297
1303
|
isParent: true,
|
|
1298
|
-
host: nativeNode
|
|
1304
|
+
host: nativeNode,
|
|
1305
|
+
rootHost: context.rootHost
|
|
1299
1306
|
};
|
|
1300
1307
|
let child = atom.child;
|
|
1301
1308
|
while (child) {
|
|
@@ -1323,7 +1330,7 @@ function updateView(nativeRenderer, component) {
|
|
|
1323
1330
|
}
|
|
1324
1331
|
}
|
|
1325
1332
|
function applyChanges(nativeRenderer, component) {
|
|
1326
|
-
const { atom, host, isParent } = component.$$view;
|
|
1333
|
+
const { atom, host, isParent, rootHost } = component.$$view;
|
|
1327
1334
|
const diffAtom = atom.child;
|
|
1328
1335
|
const template = component.update(component.props, true);
|
|
1329
1336
|
if (template) {
|
|
@@ -1334,7 +1341,8 @@ function applyChanges(nativeRenderer, component) {
|
|
|
1334
1341
|
}
|
|
1335
1342
|
const context = {
|
|
1336
1343
|
host,
|
|
1337
|
-
isParent
|
|
1344
|
+
isParent,
|
|
1345
|
+
rootHost
|
|
1338
1346
|
};
|
|
1339
1347
|
diff(nativeRenderer, component, atom.child, diffAtom, context, 0, 0);
|
|
1340
1348
|
const next = atom.sibling;
|
|
@@ -1466,7 +1474,12 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
|
|
|
1466
1474
|
const host = context.host;
|
|
1467
1475
|
if (expectIndex - offset !== oldIndex) {
|
|
1468
1476
|
if (context.isParent) {
|
|
1469
|
-
|
|
1477
|
+
if (host === context.rootHost) {
|
|
1478
|
+
nativeRenderer.appendChild(host, newAtom.nativeNode, newAtom.isSvg);
|
|
1479
|
+
}
|
|
1480
|
+
else {
|
|
1481
|
+
nativeRenderer.prependChild(host, newAtom.nativeNode, newAtom.isSvg);
|
|
1482
|
+
}
|
|
1470
1483
|
}
|
|
1471
1484
|
else {
|
|
1472
1485
|
nativeRenderer.insertAfter(newAtom.nativeNode, host, newAtom.isSvg);
|
|
@@ -1478,7 +1491,8 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
|
|
|
1478
1491
|
if (newAtom.child) {
|
|
1479
1492
|
diff(nativeRenderer, parentComponent, newAtom.child, oldAtom.child, {
|
|
1480
1493
|
host: newAtom.nativeNode,
|
|
1481
|
-
isParent: true
|
|
1494
|
+
isParent: true,
|
|
1495
|
+
rootHost: context.rootHost
|
|
1482
1496
|
}, 0, 0);
|
|
1483
1497
|
}
|
|
1484
1498
|
else if (oldAtom.child) {
|
|
@@ -1540,7 +1554,12 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
|
|
|
1540
1554
|
else {
|
|
1541
1555
|
if (moveView) {
|
|
1542
1556
|
if (context.isParent) {
|
|
1543
|
-
|
|
1557
|
+
if (context.host === context.rootHost) {
|
|
1558
|
+
nativeRenderer.appendChild(context.host, atom.nativeNode, atom.isSvg);
|
|
1559
|
+
}
|
|
1560
|
+
else {
|
|
1561
|
+
nativeRenderer.prependChild(context.host, atom.nativeNode, atom.isSvg);
|
|
1562
|
+
}
|
|
1544
1563
|
}
|
|
1545
1564
|
else {
|
|
1546
1565
|
nativeRenderer.insertAfter(atom.nativeNode, context.host, atom.isSvg);
|
|
@@ -1840,7 +1859,10 @@ class RootComponent extends Component {
|
|
|
1840
1859
|
const viewflyErrorFn = makeError('Viewfly');
|
|
1841
1860
|
function viewfly(config) {
|
|
1842
1861
|
const { context, nativeRenderer, autoUpdate, root } = Object.assign({ autoUpdate: true }, config);
|
|
1843
|
-
const appProviders = [
|
|
1862
|
+
const appProviders = [{
|
|
1863
|
+
provide: NativeRenderer,
|
|
1864
|
+
useValue: nativeRenderer
|
|
1865
|
+
}];
|
|
1844
1866
|
const modules = [];
|
|
1845
1867
|
let destroyed = false;
|
|
1846
1868
|
let appHost = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
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": "343b1bff988837e5e0a2acee63c18c3f4a3e8721",
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"reflect-metadata": "^0.1.13"
|
|
53
53
|
}
|