@viewfly/core 0.2.5 → 0.3.0
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.
|
@@ -212,9 +212,13 @@ export declare function useEffect<T = any>(deps: Signal<any>[], effect: EffectCa
|
|
|
212
212
|
* 通过 IoC 容器当前组件提供上下文共享数据的方法
|
|
213
213
|
* @param provider
|
|
214
214
|
*/
|
|
215
|
-
export declare function provide(provider: Provider | Provider[]):
|
|
215
|
+
export declare function provide(provider: Provider | Provider[]): void;
|
|
216
216
|
/**
|
|
217
217
|
* 通过组件上下文获取 IoC 容器内数据的勾子方法
|
|
218
218
|
*/
|
|
219
219
|
export declare function inject<T>(token: Type<T> | AbstractType<T> | InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
|
|
220
|
+
/**
|
|
221
|
+
* 获取当前组件实例
|
|
222
|
+
*/
|
|
223
|
+
export declare function getCurrentInstance(): Component;
|
|
220
224
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Key } from './jsx-element';
|
|
2
2
|
import { ExtractInstanceType, Ref } from './component';
|
|
3
|
+
import { Scope } from '../di/injectable';
|
|
3
4
|
export type JSXNode = JSXInternal.JSXNode;
|
|
4
5
|
export declare namespace JSXInternal {
|
|
5
6
|
type ClassNames = string | Record<string, unknown> | false | null | undefined | ClassNames[];
|
|
@@ -8,7 +9,10 @@ export declare namespace JSXInternal {
|
|
|
8
9
|
$useMemo?(currentProps: P, prevProps: P): boolean;
|
|
9
10
|
}
|
|
10
11
|
type JSXNode = Element | JSXInternal.ElementClass | string | number | boolean | null | undefined | JSXNode[];
|
|
11
|
-
|
|
12
|
+
interface ComponentSetup<P = any> {
|
|
13
|
+
(props: P): (() => Element) | ComponentInstance<P>;
|
|
14
|
+
scope?: Scope;
|
|
15
|
+
}
|
|
12
16
|
type Element<P = any, C extends string | ComponentSetup<P> = string | ComponentSetup<P>> = C extends string ? IntrinsicElements[C] : (() => Element) | ComponentInstance<P>;
|
|
13
17
|
interface IntrinsicAttributes {
|
|
14
18
|
key?: Key;
|
package/bundles/index.esm.js
CHANGED
|
@@ -657,7 +657,7 @@ class Component extends ReflectiveInjector {
|
|
|
657
657
|
super(parentComponent, [{
|
|
658
658
|
provide: Injector,
|
|
659
659
|
useFactory: () => this
|
|
660
|
-
}]);
|
|
660
|
+
}], type.scope);
|
|
661
661
|
this.parentComponent = parentComponent;
|
|
662
662
|
this.type = type;
|
|
663
663
|
this.props = props;
|
|
@@ -1140,7 +1140,6 @@ function useEffect(deps, effect) {
|
|
|
1140
1140
|
function provide(provider) {
|
|
1141
1141
|
const component = getSetupContext();
|
|
1142
1142
|
component.provide(provider);
|
|
1143
|
-
return component;
|
|
1144
1143
|
}
|
|
1145
1144
|
/**
|
|
1146
1145
|
* 通过组件上下文获取 IoC 容器内数据的勾子方法
|
|
@@ -1149,6 +1148,12 @@ function inject(token, notFoundValue = THROW_IF_NOT_FOUND, flags = InjectFlags.S
|
|
|
1149
1148
|
const component = getSetupContext();
|
|
1150
1149
|
return component.get(token, notFoundValue, flags);
|
|
1151
1150
|
}
|
|
1151
|
+
/**
|
|
1152
|
+
* 获取当前组件实例
|
|
1153
|
+
*/
|
|
1154
|
+
function getCurrentInstance() {
|
|
1155
|
+
return getSetupContext();
|
|
1156
|
+
}
|
|
1152
1157
|
|
|
1153
1158
|
class NativeRenderer {
|
|
1154
1159
|
}
|
|
@@ -1808,7 +1813,7 @@ class RootComponent extends Component {
|
|
|
1808
1813
|
}
|
|
1809
1814
|
|
|
1810
1815
|
const viewflyErrorFn = makeError('Viewfly');
|
|
1811
|
-
const VERSION = "0.
|
|
1816
|
+
const VERSION = "0.3.0";
|
|
1812
1817
|
function viewfly(config) {
|
|
1813
1818
|
const { context, nativeRenderer, autoUpdate, root } = Object.assign({ autoUpdate: true }, config);
|
|
1814
1819
|
const appProviders = [];
|
|
@@ -1899,4 +1904,4 @@ function viewfly(config) {
|
|
|
1899
1904
|
return app;
|
|
1900
1905
|
}
|
|
1901
1906
|
|
|
1902
|
-
export { Component, ForwardRef, Fragment, Inject, InjectFlags, Injectable, InjectionToken, Injector, JSXComponent, JSXElement, JSXText, NativeRenderer, NullInjector, Optional, Prop, Ref, ReflectiveInjector, RootComponent, Scope, Self, SkipSelf, THROW_IF_NOT_FOUND, Type, VERSION, createRenderer, forwardRef, inject, jsx, jsxs, makeError, normalizeProvider, onMounted, onPropsChanged, onUnmounted, onUpdated, provide, useDerived, useEffect, useRef, useSignal, viewfly, withMemo };
|
|
1907
|
+
export { Component, ForwardRef, Fragment, Inject, InjectFlags, Injectable, InjectionToken, Injector, JSXComponent, JSXElement, JSXText, NativeRenderer, NullInjector, Optional, Prop, Ref, ReflectiveInjector, RootComponent, Scope, Self, SkipSelf, THROW_IF_NOT_FOUND, Type, VERSION, createRenderer, forwardRef, getCurrentInstance, inject, jsx, jsxs, makeError, normalizeProvider, onMounted, onPropsChanged, onUnmounted, onUpdated, provide, useDerived, useEffect, useRef, useSignal, viewfly, withMemo };
|
package/bundles/index.js
CHANGED
|
@@ -659,7 +659,7 @@ class Component extends ReflectiveInjector {
|
|
|
659
659
|
super(parentComponent, [{
|
|
660
660
|
provide: Injector,
|
|
661
661
|
useFactory: () => this
|
|
662
|
-
}]);
|
|
662
|
+
}], type.scope);
|
|
663
663
|
this.parentComponent = parentComponent;
|
|
664
664
|
this.type = type;
|
|
665
665
|
this.props = props;
|
|
@@ -1142,7 +1142,6 @@ function useEffect(deps, effect) {
|
|
|
1142
1142
|
function provide(provider) {
|
|
1143
1143
|
const component = getSetupContext();
|
|
1144
1144
|
component.provide(provider);
|
|
1145
|
-
return component;
|
|
1146
1145
|
}
|
|
1147
1146
|
/**
|
|
1148
1147
|
* 通过组件上下文获取 IoC 容器内数据的勾子方法
|
|
@@ -1151,6 +1150,12 @@ function inject(token, notFoundValue = THROW_IF_NOT_FOUND, flags = exports.Injec
|
|
|
1151
1150
|
const component = getSetupContext();
|
|
1152
1151
|
return component.get(token, notFoundValue, flags);
|
|
1153
1152
|
}
|
|
1153
|
+
/**
|
|
1154
|
+
* 获取当前组件实例
|
|
1155
|
+
*/
|
|
1156
|
+
function getCurrentInstance() {
|
|
1157
|
+
return getSetupContext();
|
|
1158
|
+
}
|
|
1154
1159
|
|
|
1155
1160
|
class NativeRenderer {
|
|
1156
1161
|
}
|
|
@@ -1810,7 +1815,7 @@ class RootComponent extends Component {
|
|
|
1810
1815
|
}
|
|
1811
1816
|
|
|
1812
1817
|
const viewflyErrorFn = makeError('Viewfly');
|
|
1813
|
-
const VERSION = "0.
|
|
1818
|
+
const VERSION = "0.3.0";
|
|
1814
1819
|
function viewfly(config) {
|
|
1815
1820
|
const { context, nativeRenderer, autoUpdate, root } = Object.assign({ autoUpdate: true }, config);
|
|
1816
1821
|
const appProviders = [];
|
|
@@ -1926,6 +1931,7 @@ exports.Type = Type;
|
|
|
1926
1931
|
exports.VERSION = VERSION;
|
|
1927
1932
|
exports.createRenderer = createRenderer;
|
|
1928
1933
|
exports.forwardRef = forwardRef;
|
|
1934
|
+
exports.getCurrentInstance = getCurrentInstance;
|
|
1929
1935
|
exports.inject = inject;
|
|
1930
1936
|
exports.jsx = jsx;
|
|
1931
1937
|
exports.jsxs = jsxs;
|
package/package.json
CHANGED