@viewfly/core 0.5.1 → 0.5.3
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/foundation/component.d.ts +4 -1
- package/bundles/foundation/types.d.ts +2 -0
- package/bundles/index.esm.js +16 -10
- package/bundles/index.js +16 -10
- package/package.json +2 -2
|
@@ -31,7 +31,10 @@ export declare class Component extends ReflectiveInjector implements JSXTypeof<J
|
|
|
31
31
|
constructor(parentComponent: Injector | null, type: JSXInternal.ComponentSetup, props: Props, key?: Key | undefined);
|
|
32
32
|
markAsDirtied(): void;
|
|
33
33
|
markAsChanged(changedComponent?: Component): void;
|
|
34
|
-
render():
|
|
34
|
+
render(): {
|
|
35
|
+
template: any;
|
|
36
|
+
portalHost: import("./injection-tokens").NativeNode | undefined;
|
|
37
|
+
};
|
|
35
38
|
update(newProps: Props, forceUpdate?: boolean): any;
|
|
36
39
|
provide<T>(providers: Provider<T> | Provider<T>[]): void;
|
|
37
40
|
rendered(): void;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Key } from './jsx-element';
|
|
2
2
|
import { ExtractInstanceType, DynamicRef } from './component';
|
|
3
3
|
import { Scope } from '../di/injectable';
|
|
4
|
+
import { NativeNode } from './injection-tokens';
|
|
4
5
|
export type JSXNode = JSXInternal.JSXNode;
|
|
5
6
|
export declare namespace JSXInternal {
|
|
6
7
|
type ClassNames = string | Record<string, unknown> | false | null | undefined | ClassNames[];
|
|
7
8
|
interface ComponentInstance<P> {
|
|
9
|
+
$portalHost?: NativeNode;
|
|
8
10
|
$render(): JSXNode;
|
|
9
11
|
$useMemo?(currentProps: P, prevProps: P): boolean;
|
|
10
12
|
}
|
package/bundles/index.esm.js
CHANGED
|
@@ -732,7 +732,10 @@ class Component extends ReflectiveInjector {
|
|
|
732
732
|
this.markAsDirtied();
|
|
733
733
|
});
|
|
734
734
|
this.template = template;
|
|
735
|
-
return
|
|
735
|
+
return {
|
|
736
|
+
template: template,
|
|
737
|
+
portalHost: this.instance.$portalHost
|
|
738
|
+
};
|
|
736
739
|
}
|
|
737
740
|
update(newProps, forceUpdate = false) {
|
|
738
741
|
const oldProps = this.props;
|
|
@@ -1505,22 +1508,24 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
|
|
|
1505
1508
|
}
|
|
1506
1509
|
function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRenderer, context) {
|
|
1507
1510
|
return function (offset) {
|
|
1508
|
-
const
|
|
1511
|
+
const component = reusedAtom.jsxNode;
|
|
1509
1512
|
const newProps = newAtom.jsxNode.props;
|
|
1510
|
-
const oldTemplate =
|
|
1511
|
-
const newTemplate =
|
|
1512
|
-
|
|
1513
|
-
|
|
1513
|
+
const oldTemplate = component.template;
|
|
1514
|
+
const newTemplate = component.update(newProps);
|
|
1515
|
+
const portalHost = component.instance.$portalHost;
|
|
1516
|
+
context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
|
|
1517
|
+
component.$$view = Object.assign({ atom: newAtom }, context);
|
|
1518
|
+
newAtom.jsxNode = component;
|
|
1514
1519
|
if (newTemplate === oldTemplate) {
|
|
1515
1520
|
reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, expectIndex - offset !== oldIndex);
|
|
1516
|
-
updateView(nativeRenderer,
|
|
1521
|
+
updateView(nativeRenderer, component);
|
|
1517
1522
|
return;
|
|
1518
1523
|
}
|
|
1519
1524
|
if (newTemplate) {
|
|
1520
1525
|
linkTemplate(newTemplate, newAtom.jsxNode, newAtom);
|
|
1521
1526
|
}
|
|
1522
1527
|
if (newAtom.child) {
|
|
1523
|
-
diff(nativeRenderer,
|
|
1528
|
+
diff(nativeRenderer, component, newAtom.child, reusedAtom.child, context, expectIndex, oldIndex);
|
|
1524
1529
|
}
|
|
1525
1530
|
else if (reusedAtom.child) {
|
|
1526
1531
|
let atom = reusedAtom.child;
|
|
@@ -1529,7 +1534,7 @@ function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRende
|
|
|
1529
1534
|
atom = atom.sibling;
|
|
1530
1535
|
}
|
|
1531
1536
|
}
|
|
1532
|
-
|
|
1537
|
+
component.rendered();
|
|
1533
1538
|
};
|
|
1534
1539
|
}
|
|
1535
1540
|
function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveView) {
|
|
@@ -1592,10 +1597,11 @@ function cleanView(nativeRenderer, atom, isClean) {
|
|
|
1592
1597
|
}
|
|
1593
1598
|
}
|
|
1594
1599
|
function componentRender(nativeRenderer, component, from, context) {
|
|
1595
|
-
const template = component.render();
|
|
1600
|
+
const { template, portalHost } = component.render();
|
|
1596
1601
|
if (template) {
|
|
1597
1602
|
linkTemplate(template, component, from);
|
|
1598
1603
|
}
|
|
1604
|
+
context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
|
|
1599
1605
|
component.$$view = Object.assign({ atom: from }, context);
|
|
1600
1606
|
let child = from.child;
|
|
1601
1607
|
while (child) {
|
package/bundles/index.js
CHANGED
|
@@ -734,7 +734,10 @@ class Component extends ReflectiveInjector {
|
|
|
734
734
|
this.markAsDirtied();
|
|
735
735
|
});
|
|
736
736
|
this.template = template;
|
|
737
|
-
return
|
|
737
|
+
return {
|
|
738
|
+
template: template,
|
|
739
|
+
portalHost: this.instance.$portalHost
|
|
740
|
+
};
|
|
738
741
|
}
|
|
739
742
|
update(newProps, forceUpdate = false) {
|
|
740
743
|
const oldProps = this.props;
|
|
@@ -1507,22 +1510,24 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
|
|
|
1507
1510
|
}
|
|
1508
1511
|
function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRenderer, context) {
|
|
1509
1512
|
return function (offset) {
|
|
1510
|
-
const
|
|
1513
|
+
const component = reusedAtom.jsxNode;
|
|
1511
1514
|
const newProps = newAtom.jsxNode.props;
|
|
1512
|
-
const oldTemplate =
|
|
1513
|
-
const newTemplate =
|
|
1514
|
-
|
|
1515
|
-
|
|
1515
|
+
const oldTemplate = component.template;
|
|
1516
|
+
const newTemplate = component.update(newProps);
|
|
1517
|
+
const portalHost = component.instance.$portalHost;
|
|
1518
|
+
context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
|
|
1519
|
+
component.$$view = Object.assign({ atom: newAtom }, context);
|
|
1520
|
+
newAtom.jsxNode = component;
|
|
1516
1521
|
if (newTemplate === oldTemplate) {
|
|
1517
1522
|
reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, expectIndex - offset !== oldIndex);
|
|
1518
|
-
updateView(nativeRenderer,
|
|
1523
|
+
updateView(nativeRenderer, component);
|
|
1519
1524
|
return;
|
|
1520
1525
|
}
|
|
1521
1526
|
if (newTemplate) {
|
|
1522
1527
|
linkTemplate(newTemplate, newAtom.jsxNode, newAtom);
|
|
1523
1528
|
}
|
|
1524
1529
|
if (newAtom.child) {
|
|
1525
|
-
diff(nativeRenderer,
|
|
1530
|
+
diff(nativeRenderer, component, newAtom.child, reusedAtom.child, context, expectIndex, oldIndex);
|
|
1526
1531
|
}
|
|
1527
1532
|
else if (reusedAtom.child) {
|
|
1528
1533
|
let atom = reusedAtom.child;
|
|
@@ -1531,7 +1536,7 @@ function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRende
|
|
|
1531
1536
|
atom = atom.sibling;
|
|
1532
1537
|
}
|
|
1533
1538
|
}
|
|
1534
|
-
|
|
1539
|
+
component.rendered();
|
|
1535
1540
|
};
|
|
1536
1541
|
}
|
|
1537
1542
|
function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveView) {
|
|
@@ -1594,10 +1599,11 @@ function cleanView(nativeRenderer, atom, isClean) {
|
|
|
1594
1599
|
}
|
|
1595
1600
|
}
|
|
1596
1601
|
function componentRender(nativeRenderer, component, from, context) {
|
|
1597
|
-
const template = component.render();
|
|
1602
|
+
const { template, portalHost } = component.render();
|
|
1598
1603
|
if (template) {
|
|
1599
1604
|
linkTemplate(template, component, from);
|
|
1600
1605
|
}
|
|
1606
|
+
context = portalHost ? { isParent: true, host: portalHost, rootHost: portalHost } : context;
|
|
1601
1607
|
component.$$view = Object.assign({ atom: from }, context);
|
|
1602
1608
|
let child = from.child;
|
|
1603
1609
|
while (child) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
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": "7dadc17107c6fc4b8db6e620e9b95141db09e042",
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"reflect-metadata": "^0.1.13"
|
|
53
53
|
}
|