@viewfly/core 1.2.0 → 1.2.2
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.d.ts +8 -1
- package/bundles/index.esm.js +19 -4
- package/bundles/index.js +19 -4
- package/package.json +2 -2
package/bundles/index.d.ts
CHANGED
|
@@ -487,11 +487,18 @@ declare function withAnnotation<T extends ComponentSetup>(annotation: ComponentA
|
|
|
487
487
|
interface ContextProps extends Props {
|
|
488
488
|
providers: Provider[];
|
|
489
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* @deprecated
|
|
492
|
+
* @param props
|
|
493
|
+
*/
|
|
490
494
|
declare function Context(props: ContextProps): () => ViewFlyNode<string | ComponentSetup<any>>;
|
|
491
495
|
|
|
492
496
|
declare function withMemo<T extends Props = Props>(canUseMemo: ComponentInstance<T>['$useMemo'], render: () => JSXNode): ComponentInstance<T>;
|
|
493
497
|
|
|
494
|
-
declare const ElementNamespaceMap:
|
|
498
|
+
declare const ElementNamespaceMap: {
|
|
499
|
+
readonly svg: "svg";
|
|
500
|
+
readonly math: "mathml";
|
|
501
|
+
};
|
|
495
502
|
declare function createRenderer(component: Component, nativeRenderer: NativeRenderer, namespace: ElementNamespace): (host: NativeNode) => void;
|
|
496
503
|
|
|
497
504
|
/**
|
package/bundles/index.esm.js
CHANGED
|
@@ -1301,11 +1301,20 @@ function withAnnotation(annotation, componentSetup) {
|
|
|
1301
1301
|
return function (props) {
|
|
1302
1302
|
const instance = getCurrentInstance();
|
|
1303
1303
|
const parentInjector = injectMap.get(instance) || getInjector(instance.parentComponent);
|
|
1304
|
-
const injector = new ReflectiveInjector(parentInjector,
|
|
1304
|
+
const injector = new ReflectiveInjector(parentInjector, [{
|
|
1305
|
+
provide: Injector,
|
|
1306
|
+
useFactory() {
|
|
1307
|
+
return injector;
|
|
1308
|
+
}
|
|
1309
|
+
}, ...(annotation.providers || [])], annotation.scope);
|
|
1305
1310
|
injectMap.set(instance, injector);
|
|
1306
1311
|
return componentSetup(props);
|
|
1307
1312
|
};
|
|
1308
1313
|
}
|
|
1314
|
+
/**
|
|
1315
|
+
* @deprecated
|
|
1316
|
+
* @param props
|
|
1317
|
+
*/
|
|
1309
1318
|
function Context(props) {
|
|
1310
1319
|
function createContextComponent(providers) {
|
|
1311
1320
|
return withAnnotation({
|
|
@@ -1693,6 +1702,12 @@ function insertNode(nativeRenderer, atom, context) {
|
|
|
1693
1702
|
nativeRenderer.insertAfter(atom.nativeNode, context.host, atom.namespace);
|
|
1694
1703
|
}
|
|
1695
1704
|
}
|
|
1705
|
+
function createElementChildren(type, children, namespace) {
|
|
1706
|
+
if (type === 'foreignObject' && namespace === ElementNamespaceMap.svg) {
|
|
1707
|
+
return createChildChain(children, void 0);
|
|
1708
|
+
}
|
|
1709
|
+
return createChildChain(children, namespace);
|
|
1710
|
+
}
|
|
1696
1711
|
function createElement(nativeRenderer, atom, parentComponent, context) {
|
|
1697
1712
|
const { namespace, jsxNode } = atom;
|
|
1698
1713
|
const nativeNode = nativeRenderer.createElement(jsxNode.type, namespace);
|
|
@@ -1700,7 +1715,7 @@ function createElement(nativeRenderer, atom, parentComponent, context) {
|
|
|
1700
1715
|
let bindingRefs;
|
|
1701
1716
|
for (const key in props) {
|
|
1702
1717
|
if (key === 'children') {
|
|
1703
|
-
atom.child =
|
|
1718
|
+
atom.child = createElementChildren(jsxNode.type, props.children, namespace);
|
|
1704
1719
|
continue;
|
|
1705
1720
|
}
|
|
1706
1721
|
if (key === 'class') {
|
|
@@ -1797,7 +1812,7 @@ function updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComp
|
|
|
1797
1812
|
const [key, newValue, oldValue] = changes.replace[i];
|
|
1798
1813
|
if (key === 'children') {
|
|
1799
1814
|
updatedChildren = true;
|
|
1800
|
-
newAtom.child =
|
|
1815
|
+
newAtom.child = createElementChildren(newVNode.type, newValue, isSvg);
|
|
1801
1816
|
if (!newAtom.child) {
|
|
1802
1817
|
cleanElementChildren(oldAtom, nativeRenderer);
|
|
1803
1818
|
}
|
|
@@ -1844,7 +1859,7 @@ function updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComp
|
|
|
1844
1859
|
const [key, value] = changes.add[i];
|
|
1845
1860
|
if (key === 'children') {
|
|
1846
1861
|
updatedChildren = true;
|
|
1847
|
-
newAtom.child =
|
|
1862
|
+
newAtom.child = createElementChildren(newVNode.type, value, isSvg);
|
|
1848
1863
|
buildElementChildren(newAtom, nativeRenderer, parentComponent, context);
|
|
1849
1864
|
continue;
|
|
1850
1865
|
}
|
package/bundles/index.js
CHANGED
|
@@ -1303,11 +1303,20 @@ function withAnnotation(annotation, componentSetup) {
|
|
|
1303
1303
|
return function (props) {
|
|
1304
1304
|
const instance = getCurrentInstance();
|
|
1305
1305
|
const parentInjector = injectMap.get(instance) || getInjector(instance.parentComponent);
|
|
1306
|
-
const injector = new ReflectiveInjector(parentInjector,
|
|
1306
|
+
const injector = new ReflectiveInjector(parentInjector, [{
|
|
1307
|
+
provide: Injector,
|
|
1308
|
+
useFactory() {
|
|
1309
|
+
return injector;
|
|
1310
|
+
}
|
|
1311
|
+
}, ...(annotation.providers || [])], annotation.scope);
|
|
1307
1312
|
injectMap.set(instance, injector);
|
|
1308
1313
|
return componentSetup(props);
|
|
1309
1314
|
};
|
|
1310
1315
|
}
|
|
1316
|
+
/**
|
|
1317
|
+
* @deprecated
|
|
1318
|
+
* @param props
|
|
1319
|
+
*/
|
|
1311
1320
|
function Context(props) {
|
|
1312
1321
|
function createContextComponent(providers) {
|
|
1313
1322
|
return withAnnotation({
|
|
@@ -1695,6 +1704,12 @@ function insertNode(nativeRenderer, atom, context) {
|
|
|
1695
1704
|
nativeRenderer.insertAfter(atom.nativeNode, context.host, atom.namespace);
|
|
1696
1705
|
}
|
|
1697
1706
|
}
|
|
1707
|
+
function createElementChildren(type, children, namespace) {
|
|
1708
|
+
if (type === 'foreignObject' && namespace === ElementNamespaceMap.svg) {
|
|
1709
|
+
return createChildChain(children, void 0);
|
|
1710
|
+
}
|
|
1711
|
+
return createChildChain(children, namespace);
|
|
1712
|
+
}
|
|
1698
1713
|
function createElement(nativeRenderer, atom, parentComponent, context) {
|
|
1699
1714
|
const { namespace, jsxNode } = atom;
|
|
1700
1715
|
const nativeNode = nativeRenderer.createElement(jsxNode.type, namespace);
|
|
@@ -1702,7 +1717,7 @@ function createElement(nativeRenderer, atom, parentComponent, context) {
|
|
|
1702
1717
|
let bindingRefs;
|
|
1703
1718
|
for (const key in props) {
|
|
1704
1719
|
if (key === 'children') {
|
|
1705
|
-
atom.child =
|
|
1720
|
+
atom.child = createElementChildren(jsxNode.type, props.children, namespace);
|
|
1706
1721
|
continue;
|
|
1707
1722
|
}
|
|
1708
1723
|
if (key === 'class') {
|
|
@@ -1799,7 +1814,7 @@ function updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComp
|
|
|
1799
1814
|
const [key, newValue, oldValue] = changes.replace[i];
|
|
1800
1815
|
if (key === 'children') {
|
|
1801
1816
|
updatedChildren = true;
|
|
1802
|
-
newAtom.child =
|
|
1817
|
+
newAtom.child = createElementChildren(newVNode.type, newValue, isSvg);
|
|
1803
1818
|
if (!newAtom.child) {
|
|
1804
1819
|
cleanElementChildren(oldAtom, nativeRenderer);
|
|
1805
1820
|
}
|
|
@@ -1846,7 +1861,7 @@ function updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComp
|
|
|
1846
1861
|
const [key, value] = changes.add[i];
|
|
1847
1862
|
if (key === 'children') {
|
|
1848
1863
|
updatedChildren = true;
|
|
1849
|
-
newAtom.child =
|
|
1864
|
+
newAtom.child = createElementChildren(newVNode.type, value, isSvg);
|
|
1850
1865
|
buildElementChildren(newAtom, nativeRenderer, parentComponent, context);
|
|
1851
1866
|
continue;
|
|
1852
1867
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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": "84f994ca1bd19c075d9a142bbedfc10db14e7e93",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"reflect-metadata": "^0.2.2"
|
|
56
56
|
}
|