@viewfly/core 0.0.19 → 0.0.21
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/di/_api.d.ts +10 -0
- package/bundles/di/forward-ref.d.ts +10 -0
- package/bundles/di/injectable.d.ts +20 -0
- package/bundles/di/injection-token.d.ts +8 -0
- package/bundles/di/injector.d.ts +22 -0
- package/bundles/di/metadata.d.ts +43 -0
- package/bundles/di/null-injector.d.ts +6 -0
- package/bundles/di/provider.d.ts +30 -0
- package/bundles/di/reflective-injector.d.ts +32 -0
- package/bundles/di/reflective-provider.d.ts +20 -0
- package/bundles/di/type.d.ts +7 -0
- package/bundles/di/utils/_api.d.ts +3 -0
- package/bundles/di/utils/annotations.d.ts +33 -0
- package/bundles/di/utils/decorators.d.ts +17 -0
- package/bundles/di/utils/stringify.d.ts +1 -0
- package/bundles/foundation/_api.d.ts +5 -0
- package/bundles/foundation/_utils.d.ts +4 -0
- package/bundles/{model → foundation}/component.d.ts +1 -1
- package/bundles/{model → foundation}/jsx-element.d.ts +1 -4
- package/bundles/foundation/renderer.d.ts +1 -1
- package/bundles/{model → foundation}/root.component.d.ts +3 -3
- package/bundles/{model → foundation}/types.d.ts +2 -1
- package/bundles/index.esm.js +588 -42
- package/bundles/index.js +611 -54
- package/bundles/public-api.d.ts +1 -2
- package/bundles/viewfly.d.ts +4 -4
- package/package.json +2 -4
- package/bundles/model/_api.d.ts +0 -5
- package/jsx-runtime/node_modules/.bin/rimraf +0 -17
- package/jsx-runtime/node_modules/.bin/rollup +0 -17
- /package/bundles/{model → foundation}/memo.d.ts +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './forward-ref';
|
|
2
|
+
export * from './injectable';
|
|
3
|
+
export * from './injection-token';
|
|
4
|
+
export * from './injector';
|
|
5
|
+
export * from './metadata';
|
|
6
|
+
export * from './null-injector';
|
|
7
|
+
export * from './provider';
|
|
8
|
+
export * from './reflective-injector';
|
|
9
|
+
export * from './reflective-provider';
|
|
10
|
+
export * from './type';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class Scope {
|
|
2
|
+
name: string;
|
|
3
|
+
constructor(name: string);
|
|
4
|
+
toString(): string;
|
|
5
|
+
}
|
|
6
|
+
export type ProvideScope = 'root' | Scope;
|
|
7
|
+
export interface InjectableOptions {
|
|
8
|
+
provideIn: ProvideScope;
|
|
9
|
+
}
|
|
10
|
+
export interface Injectable {
|
|
11
|
+
provideIn?: ProvideScope;
|
|
12
|
+
}
|
|
13
|
+
export interface InjectableDecorator {
|
|
14
|
+
(options?: InjectableOptions): ClassDecorator;
|
|
15
|
+
new (options?: InjectableOptions): Injectable;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 可注入类的装饰器
|
|
19
|
+
*/
|
|
20
|
+
export declare const Injectable: InjectableDecorator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AbstractType, Type } from './type';
|
|
2
|
+
import { InjectionToken } from './injection-token';
|
|
3
|
+
/**
|
|
4
|
+
* 查找规则
|
|
5
|
+
*/
|
|
6
|
+
export declare enum InjectFlags {
|
|
7
|
+
/** 默认查找规则 */
|
|
8
|
+
Default = "Default",
|
|
9
|
+
/** 锁定当前容器 */
|
|
10
|
+
Self = "Self",
|
|
11
|
+
/** 跳过当前容器 */
|
|
12
|
+
SkipSelf = "SkipSelf",
|
|
13
|
+
/** 可选查找 */
|
|
14
|
+
Optional = "Optional"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* DI 容器抽象基类
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class Injector {
|
|
20
|
+
abstract parentInjector: Injector | null;
|
|
21
|
+
abstract get<T>(token: Type<T> | AbstractType<T> | InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
|
|
22
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AbstractType, Type } from './type';
|
|
2
|
+
import { InjectFlags } from './injector';
|
|
3
|
+
import { InjectionToken } from './injection-token';
|
|
4
|
+
import { ForwardRef } from './forward-ref';
|
|
5
|
+
export interface Inject {
|
|
6
|
+
token: InjectionToken<any> | Type<any> | ForwardRef<InjectionToken<any> | Type<any>>;
|
|
7
|
+
}
|
|
8
|
+
export interface InjectDecorator {
|
|
9
|
+
(token: InjectionToken<any> | Type<any> | ForwardRef<InjectionToken<any> | Type<any>>): ParameterDecorator;
|
|
10
|
+
new (token: InjectionToken<any> | Type<any> | ForwardRef<InjectionToken<any> | Type<any>>): Inject;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 构造函数参数装饰器,用于改变注入 token
|
|
14
|
+
*/
|
|
15
|
+
export declare const Inject: InjectDecorator;
|
|
16
|
+
export interface Self {
|
|
17
|
+
}
|
|
18
|
+
export interface SelfDecorator {
|
|
19
|
+
(): ParameterDecorator;
|
|
20
|
+
new (): Self;
|
|
21
|
+
}
|
|
22
|
+
export declare const Self: SelfDecorator;
|
|
23
|
+
export interface SkipSelf {
|
|
24
|
+
}
|
|
25
|
+
export interface SkipSelfDecorator {
|
|
26
|
+
(): ParameterDecorator;
|
|
27
|
+
new (): SkipSelf;
|
|
28
|
+
}
|
|
29
|
+
export declare const SkipSelf: SkipSelfDecorator;
|
|
30
|
+
export interface Optional {
|
|
31
|
+
}
|
|
32
|
+
export interface OptionalDecorator {
|
|
33
|
+
(): ParameterDecorator;
|
|
34
|
+
new (): Optional;
|
|
35
|
+
}
|
|
36
|
+
export declare const Optional: OptionalDecorator;
|
|
37
|
+
export interface Prop {
|
|
38
|
+
}
|
|
39
|
+
export interface PropDecorator {
|
|
40
|
+
<T>(token?: Type<T> | AbstractType<T> | InjectionToken<T> | ForwardRef<T>, notFoundValue?: T, flags?: InjectFlags): PropertyDecorator;
|
|
41
|
+
new (token: any): Prop;
|
|
42
|
+
}
|
|
43
|
+
export declare const Prop: PropDecorator;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AbstractType, Type } from './type';
|
|
2
|
+
import { InjectionToken } from './injection-token';
|
|
3
|
+
export interface ClassProvider<T = any> {
|
|
4
|
+
provide: Type<T> | AbstractType<T> | InjectionToken<T>;
|
|
5
|
+
useClass: Type<T>;
|
|
6
|
+
deps?: any[];
|
|
7
|
+
}
|
|
8
|
+
export interface FactoryProvider<T = any> {
|
|
9
|
+
provide: Type<T> | AbstractType<T> | InjectionToken<T>;
|
|
10
|
+
useFactory: (...args: any[]) => T;
|
|
11
|
+
deps?: any[];
|
|
12
|
+
}
|
|
13
|
+
export interface ValueProvider<T = any> {
|
|
14
|
+
provide: Type<T> | AbstractType<T> | InjectionToken<T>;
|
|
15
|
+
useValue: T;
|
|
16
|
+
}
|
|
17
|
+
export interface ExistingProvider<T = any> {
|
|
18
|
+
provide: Type<T> | AbstractType<T> | InjectionToken<T>;
|
|
19
|
+
useExisting: T;
|
|
20
|
+
}
|
|
21
|
+
export interface ConstructorProvider<T = any> {
|
|
22
|
+
provide: Type<T>;
|
|
23
|
+
deps?: [];
|
|
24
|
+
}
|
|
25
|
+
export interface TypeProvider<T = any> extends Type<T> {
|
|
26
|
+
}
|
|
27
|
+
export interface AbstractProvider<T = any> extends AbstractType<T> {
|
|
28
|
+
}
|
|
29
|
+
export type StaticProvider<T = any> = ClassProvider<T> | FactoryProvider<T> | ValueProvider<T> | ExistingProvider<T> | ConstructorProvider<T>;
|
|
30
|
+
export type Provider<T = any> = TypeProvider<T> | AbstractProvider<T> | StaticProvider<T>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Provider } from './provider';
|
|
2
|
+
import { InjectFlags, Injector } from './injector';
|
|
3
|
+
import { NormalizedProvider } from './reflective-provider';
|
|
4
|
+
import { AbstractType, Type } from './type';
|
|
5
|
+
import { InjectionToken } from './injection-token';
|
|
6
|
+
import { Scope } from './injectable';
|
|
7
|
+
/**
|
|
8
|
+
* 反射注入器
|
|
9
|
+
*/
|
|
10
|
+
export declare class ReflectiveInjector extends Injector {
|
|
11
|
+
parentInjector: Injector | null;
|
|
12
|
+
protected staticProviders: Provider[];
|
|
13
|
+
protected scope?: Scope | undefined;
|
|
14
|
+
protected normalizedProviders: NormalizedProvider[];
|
|
15
|
+
protected recordValues: Map<InjectionToken<any> | Type<any> | AbstractType<any>, any>;
|
|
16
|
+
constructor(parentInjector: Injector | null, staticProviders: Provider[], scope?: Scope | undefined);
|
|
17
|
+
/**
|
|
18
|
+
* 用于获取当前注入器上下文内的实例、对象或数据
|
|
19
|
+
* @param token 访问 token
|
|
20
|
+
* @param notFoundValue 如未查找到的返回值
|
|
21
|
+
* @param flags 查询规则
|
|
22
|
+
*/
|
|
23
|
+
get<T>(token: Type<T> | AbstractType<T> | InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
|
|
24
|
+
private getValue;
|
|
25
|
+
/**
|
|
26
|
+
* 解决并获取依赖参数
|
|
27
|
+
* @param deps 依赖规则
|
|
28
|
+
* @param notFoundValue 未查找到时的返回值
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
private resolveDeps;
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Provider } from './provider';
|
|
2
|
+
import { Injector } from './injector';
|
|
3
|
+
import { Self, SkipSelf } from './metadata';
|
|
4
|
+
import { ProvideScope } from './injectable';
|
|
5
|
+
export interface ReflectiveDependency {
|
|
6
|
+
injectKey: any;
|
|
7
|
+
visibility: SkipSelf | Self | null;
|
|
8
|
+
optional: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface NormalizedProvider {
|
|
11
|
+
provide: any;
|
|
12
|
+
generateFactory: (injector: Injector, cacheFn: (token: any, value: any) => void) => (...args: any[]) => any;
|
|
13
|
+
deps: ReflectiveDependency[];
|
|
14
|
+
scope: ProvideScope | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 标准化 provide,并返回统一数据结构
|
|
18
|
+
* @param provider
|
|
19
|
+
*/
|
|
20
|
+
export declare function normalizeProvider(provider: Provider): NormalizedProvider;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Injector } from '../injector';
|
|
2
|
+
export interface ClassAnnotation {
|
|
3
|
+
paramTypes: any[];
|
|
4
|
+
metadata: any;
|
|
5
|
+
}
|
|
6
|
+
export interface ParamAnnotation {
|
|
7
|
+
propertyKey: string | symbol;
|
|
8
|
+
parameterIndex: number;
|
|
9
|
+
metadata: any;
|
|
10
|
+
}
|
|
11
|
+
export interface PropertyDecoratorContextCallback {
|
|
12
|
+
(instance: any, propertyName: string | symbol, token: any, injector: Injector): void;
|
|
13
|
+
}
|
|
14
|
+
export interface PropertyAnnotation {
|
|
15
|
+
injectToken: any;
|
|
16
|
+
propertyKey: string | symbol;
|
|
17
|
+
contextCallback: PropertyDecoratorContextCallback;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 用于保存 class 的元数据
|
|
21
|
+
*/
|
|
22
|
+
export declare class Annotations {
|
|
23
|
+
private classes;
|
|
24
|
+
private props;
|
|
25
|
+
private params;
|
|
26
|
+
setClassMetadata(token: any, params: ClassAnnotation): void;
|
|
27
|
+
getClassMetadata(token: any): ClassAnnotation | undefined;
|
|
28
|
+
pushParamMetadata(token: any, params: ParamAnnotation): void;
|
|
29
|
+
getParamMetadata(token: any): ParamAnnotation[] | undefined;
|
|
30
|
+
getPropMetadataKeys(): any[];
|
|
31
|
+
pushPropMetadata(token: any, params: PropertyAnnotation): void;
|
|
32
|
+
getPropMetadata(token: any): PropertyAnnotation[] | undefined;
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Annotations, PropertyDecoratorContextCallback } from './annotations';
|
|
2
|
+
/**
|
|
3
|
+
* 创建参数装饰器的工厂函数
|
|
4
|
+
*/
|
|
5
|
+
export declare function makeParamDecorator(token: any, metadata: any): ParameterDecorator;
|
|
6
|
+
/**
|
|
7
|
+
* 创建属性装饰器的工厂函数
|
|
8
|
+
*/
|
|
9
|
+
export declare function makePropertyDecorator(token: any, injectToken: any, contextCallback: PropertyDecoratorContextCallback): PropertyDecorator;
|
|
10
|
+
/**
|
|
11
|
+
* 创建类装饰器的工厂函数
|
|
12
|
+
*/
|
|
13
|
+
export declare function makeClassDecorator(token: any, metadata: any): ClassDecorator;
|
|
14
|
+
/**
|
|
15
|
+
* 获取类注解的工具函数
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAnnotations(target: any): Annotations;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stringify(token: any): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractType, InjectFlags, InjectionToken, Injector, Provider, ReflectiveInjector, Type } from '
|
|
1
|
+
import { AbstractType, InjectFlags, InjectionToken, Injector, Provider, ReflectiveInjector, Type } from '../di/_api';
|
|
2
2
|
import { JSXTypeof, Key, Props } from './jsx-element';
|
|
3
3
|
import { JSXInternal } from './types';
|
|
4
4
|
export declare class JSXComponent {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JSXComponent } from './component';
|
|
2
2
|
import { JSXInternal } from './types';
|
|
3
|
+
import { ListenDelegate } from './_utils';
|
|
3
4
|
export interface Props {
|
|
4
5
|
children?: JSXInternal.JSXNode | JSXInternal.JSXNode[];
|
|
5
6
|
[key: string]: any;
|
|
@@ -20,10 +21,6 @@ export declare class JSXText implements JSXTypeof {
|
|
|
20
21
|
constructor(text: string);
|
|
21
22
|
is(target: JSXTypeof): boolean;
|
|
22
23
|
}
|
|
23
|
-
export interface ListenDelegate {
|
|
24
|
-
delegate: () => any;
|
|
25
|
-
listenFn: ((...args: any[]) => any) | void;
|
|
26
|
-
}
|
|
27
24
|
export declare class JSXElement implements JSXTypeof {
|
|
28
25
|
type: string;
|
|
29
26
|
props: Props;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Subject } from '@tanbo/stream';
|
|
2
1
|
import { Component } from './component';
|
|
3
2
|
import { JSXInternal } from './types';
|
|
3
|
+
import { Injector } from '../di/_api';
|
|
4
4
|
/**
|
|
5
5
|
* Viewfly 根组件,用于实现组件状态更新事件通知
|
|
6
6
|
*/
|
|
7
7
|
export declare class RootComponent extends Component {
|
|
8
|
-
|
|
9
|
-
constructor(factory: JSXInternal.ElementClass, parentInjector:
|
|
8
|
+
onChange: (() => void) | null;
|
|
9
|
+
constructor(factory: JSXInternal.ElementClass, parentInjector: Injector);
|
|
10
10
|
markAsChanged(): void;
|
|
11
11
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Key
|
|
1
|
+
import { Key } from './jsx-element';
|
|
2
|
+
import { ExtractInstanceType, Ref } from './component';
|
|
2
3
|
export type JSXNode = JSXInternal.JSXNode;
|
|
3
4
|
export declare namespace JSXInternal {
|
|
4
5
|
type ClassNames = string | Record<string, unknown> | ClassNames[];
|