@viewfly/core 1.0.0-alpha.7 → 1.0.0-alpha.8
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AbstractType, ExtractValueType, InjectFlags, InjectionToken, Injector, Provider, ReflectiveInjector, Type } from '../di/_api';
|
|
2
2
|
import { Key, Props } from './jsx-element';
|
|
3
|
-
import { ComponentView } from './_utils';
|
|
4
3
|
/**
|
|
5
4
|
* Viewfly 组件管理类,用于管理组件的生命周期,上下文等
|
|
6
5
|
*/
|
|
@@ -14,7 +13,6 @@ export declare class Component extends ReflectiveInjector {
|
|
|
14
13
|
changedSubComponents: Set<Component>;
|
|
15
14
|
get dirty(): boolean;
|
|
16
15
|
get changed(): boolean;
|
|
17
|
-
$$view: ComponentView;
|
|
18
16
|
unmountedCallbacks?: LifeCycleCallback[] | null;
|
|
19
17
|
mountCallbacks?: LifeCycleCallback[] | null;
|
|
20
18
|
propsChangedCallbacks?: PropsChangedCallback<any>[] | null;
|
package/bundles/index.esm.js
CHANGED
|
@@ -1283,6 +1283,7 @@ function withMemo(canUseMemo, render) {
|
|
|
1283
1283
|
};
|
|
1284
1284
|
}
|
|
1285
1285
|
|
|
1286
|
+
const componentViewCache = new WeakMap();
|
|
1286
1287
|
const listenerReg = /^on(?=[A-Z])/;
|
|
1287
1288
|
function createRenderer(component, nativeRenderer) {
|
|
1288
1289
|
let isInit = true;
|
|
@@ -1361,7 +1362,7 @@ function updateView(nativeRenderer, component) {
|
|
|
1361
1362
|
}
|
|
1362
1363
|
}
|
|
1363
1364
|
function applyChanges(nativeRenderer, component) {
|
|
1364
|
-
const { atom, host, isParent, rootHost } = component
|
|
1365
|
+
const { atom, host, isParent, rootHost } = componentViewCache.get(component);
|
|
1365
1366
|
const diffAtom = atom.child;
|
|
1366
1367
|
const template = component.update(component.props, true);
|
|
1367
1368
|
atom.child = createChildChain(template, atom.isSvg);
|
|
@@ -1373,8 +1374,9 @@ function applyChanges(nativeRenderer, component) {
|
|
|
1373
1374
|
diff(nativeRenderer, component, atom.child, diffAtom, context);
|
|
1374
1375
|
const next = atom.sibling;
|
|
1375
1376
|
if (next && next.jsxNode instanceof Component) {
|
|
1376
|
-
|
|
1377
|
-
|
|
1377
|
+
const view = componentViewCache.get(next.jsxNode);
|
|
1378
|
+
view.host = context.host;
|
|
1379
|
+
view.isParent = context.isParent;
|
|
1378
1380
|
}
|
|
1379
1381
|
}
|
|
1380
1382
|
function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context) {
|
|
@@ -1497,7 +1499,7 @@ function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRende
|
|
|
1497
1499
|
const newTemplate = component.update(newProps);
|
|
1498
1500
|
const portalHost = component.instance.$portalHost;
|
|
1499
1501
|
context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
|
|
1500
|
-
component
|
|
1502
|
+
componentViewCache.set(component, Object.assign({ atom: newAtom }, context));
|
|
1501
1503
|
newAtom.jsxNode = component;
|
|
1502
1504
|
if (newTemplate === oldTemplate) {
|
|
1503
1505
|
reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, expectIndex - offset !== oldIndex);
|
|
@@ -1571,7 +1573,7 @@ function componentRender(nativeRenderer, component, from, context) {
|
|
|
1571
1573
|
const { template, portalHost } = component.render();
|
|
1572
1574
|
from.child = createChildChain(template, from.isSvg);
|
|
1573
1575
|
context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
|
|
1574
|
-
component
|
|
1576
|
+
componentViewCache.set(component, Object.assign({ atom: from }, context));
|
|
1575
1577
|
let child = from.child;
|
|
1576
1578
|
while (child) {
|
|
1577
1579
|
buildView(nativeRenderer, component, child, context);
|
|
@@ -1618,7 +1620,6 @@ function createChainByJSXElement(element, prevAtom, isSvg) {
|
|
|
1618
1620
|
};
|
|
1619
1621
|
prevAtom.sibling = atom;
|
|
1620
1622
|
atom.child = createChildChain(element.props.children, isSvg);
|
|
1621
|
-
element.props.children = null;
|
|
1622
1623
|
return atom;
|
|
1623
1624
|
}
|
|
1624
1625
|
function createChainByNode(jsxNode, prevAtom, isSvg) {
|
package/bundles/index.js
CHANGED
|
@@ -1285,6 +1285,7 @@ function withMemo(canUseMemo, render) {
|
|
|
1285
1285
|
};
|
|
1286
1286
|
}
|
|
1287
1287
|
|
|
1288
|
+
const componentViewCache = new WeakMap();
|
|
1288
1289
|
const listenerReg = /^on(?=[A-Z])/;
|
|
1289
1290
|
function createRenderer(component, nativeRenderer) {
|
|
1290
1291
|
let isInit = true;
|
|
@@ -1363,7 +1364,7 @@ function updateView(nativeRenderer, component) {
|
|
|
1363
1364
|
}
|
|
1364
1365
|
}
|
|
1365
1366
|
function applyChanges(nativeRenderer, component) {
|
|
1366
|
-
const { atom, host, isParent, rootHost } = component
|
|
1367
|
+
const { atom, host, isParent, rootHost } = componentViewCache.get(component);
|
|
1367
1368
|
const diffAtom = atom.child;
|
|
1368
1369
|
const template = component.update(component.props, true);
|
|
1369
1370
|
atom.child = createChildChain(template, atom.isSvg);
|
|
@@ -1375,8 +1376,9 @@ function applyChanges(nativeRenderer, component) {
|
|
|
1375
1376
|
diff(nativeRenderer, component, atom.child, diffAtom, context);
|
|
1376
1377
|
const next = atom.sibling;
|
|
1377
1378
|
if (next && next.jsxNode instanceof Component) {
|
|
1378
|
-
|
|
1379
|
-
|
|
1379
|
+
const view = componentViewCache.get(next.jsxNode);
|
|
1380
|
+
view.host = context.host;
|
|
1381
|
+
view.isParent = context.isParent;
|
|
1380
1382
|
}
|
|
1381
1383
|
}
|
|
1382
1384
|
function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context) {
|
|
@@ -1499,7 +1501,7 @@ function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRende
|
|
|
1499
1501
|
const newTemplate = component.update(newProps);
|
|
1500
1502
|
const portalHost = component.instance.$portalHost;
|
|
1501
1503
|
context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
|
|
1502
|
-
component
|
|
1504
|
+
componentViewCache.set(component, Object.assign({ atom: newAtom }, context));
|
|
1503
1505
|
newAtom.jsxNode = component;
|
|
1504
1506
|
if (newTemplate === oldTemplate) {
|
|
1505
1507
|
reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, expectIndex - offset !== oldIndex);
|
|
@@ -1573,7 +1575,7 @@ function componentRender(nativeRenderer, component, from, context) {
|
|
|
1573
1575
|
const { template, portalHost } = component.render();
|
|
1574
1576
|
from.child = createChildChain(template, from.isSvg);
|
|
1575
1577
|
context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
|
|
1576
|
-
component
|
|
1578
|
+
componentViewCache.set(component, Object.assign({ atom: from }, context));
|
|
1577
1579
|
let child = from.child;
|
|
1578
1580
|
while (child) {
|
|
1579
1581
|
buildView(nativeRenderer, component, child, context);
|
|
@@ -1620,7 +1622,6 @@ function createChainByJSXElement(element, prevAtom, isSvg) {
|
|
|
1620
1622
|
};
|
|
1621
1623
|
prevAtom.sibling = atom;
|
|
1622
1624
|
atom.child = createChildChain(element.props.children, isSvg);
|
|
1623
|
-
element.props.children = null;
|
|
1624
1625
|
return atom;
|
|
1625
1626
|
}
|
|
1626
1627
|
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.8",
|
|
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": "95538a571b0d2e8a96dbfdc940959605ea06c252",
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"reflect-metadata": "^0.2.2"
|
|
53
53
|
}
|