@zk-tech/bedrock 0.1.1 → 0.1.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/dist/container-factory/index.cjs +254 -0
- package/dist/container-factory/index.cjs.map +1 -0
- package/dist/container-factory/index.d.cts +32 -0
- package/dist/container-factory/index.d.ts +32 -0
- package/dist/container-factory/index.js +232 -0
- package/dist/container-factory/index.js.map +1 -0
- package/dist/di/index.d.cts +7 -95
- package/dist/di/index.d.ts +7 -95
- package/dist/dynamic-dependency-service.interface-BrwqELkH.d.ts +40 -0
- package/dist/dynamic-dependency-service.interface-OUOyz9BD.d.cts +40 -0
- package/dist/instantiation-service-DjBf8Dy1.d.cts +59 -0
- package/dist/instantiation-service-V9JO6Ljg.d.ts +59 -0
- package/dist/{instantiation-service.interface-CVFMBUUD.d.cts → instantiation-service.interface-bshqO0aS.d.cts} +1 -1
- package/dist/{instantiation-service.interface-CVFMBUUD.d.ts → instantiation-service.interface-bshqO0aS.d.ts} +1 -1
- package/dist/launch/index.d.cts +1 -1
- package/dist/launch/index.d.ts +1 -1
- package/dist/services/dynamic-dependency/index.cjs +1583 -0
- package/dist/services/dynamic-dependency/index.cjs.map +1 -0
- package/dist/services/dynamic-dependency/index.d.cts +17 -0
- package/dist/services/dynamic-dependency/index.d.ts +17 -0
- package/dist/services/dynamic-dependency/index.js +1581 -0
- package/dist/services/dynamic-dependency/index.js.map +1 -0
- package/dist/type-BsqwDzaj.d.cts +39 -0
- package/dist/type-Bya55PZP.d.ts +39 -0
- package/package.json +1 -1
package/dist/di/index.d.cts
CHANGED
|
@@ -1,101 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { h as IServiceCollection, g as createDecorator, r as refineServiceDecorator } from '../instantiation-service.interface-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { B as BrandedService, I as IInstantiationService, a as SyncDescriptor, S as ServiceIdentifier } from '../instantiation-service.interface-bshqO0aS.cjs';
|
|
2
|
+
export { G as GetLeadingNonServiceArgs, h as IServiceCollection, b as ServiceCollection, f as ServiceOwnership, c as ServicesAccessor, g as createDecorator, r as refineServiceDecorator } from '../instantiation-service.interface-bshqO0aS.cjs';
|
|
3
|
+
export { I as ContainerService, a as InstantiationErrorType, I as InstantiationService, g as getService } from '../instantiation-service-DjBf8Dy1.cjs';
|
|
4
|
+
export { L as LazyService, S as ServiceRegistry } from '../type-BsqwDzaj.cjs';
|
|
5
5
|
import { ReactElement } from 'react';
|
|
6
|
+
import '../graph-BGbNOniY.cjs';
|
|
7
|
+
import '../emitter-CAfCtSTg.cjs';
|
|
6
8
|
import '../dispose-base-CAeXDpjg.cjs';
|
|
7
9
|
import '../linked-list-CUkue5DZ.cjs';
|
|
8
10
|
|
|
9
|
-
type DepGraph = Graph<string, any>;
|
|
10
|
-
declare enum InstantiationErrorType {
|
|
11
|
-
UnknownDependency = "UnknownDependency"
|
|
12
|
-
}
|
|
13
|
-
interface IBaseErrorEvent {
|
|
14
|
-
errorType: InstantiationErrorType;
|
|
15
|
-
message: string;
|
|
16
|
-
}
|
|
17
|
-
interface IUnknownDependencyErrorEvent extends IBaseErrorEvent {
|
|
18
|
-
errorType: InstantiationErrorType.UnknownDependency;
|
|
19
|
-
dependencyId: string;
|
|
20
|
-
issuer: string;
|
|
21
|
-
}
|
|
22
|
-
type ErrorDataType = IUnknownDependencyErrorEvent;
|
|
23
|
-
/**
|
|
24
|
-
* 从容器中获取对应的service
|
|
25
|
-
* @param instantiationService
|
|
26
|
-
* @param id
|
|
27
|
-
* @returns Service<T>
|
|
28
|
-
*
|
|
29
|
-
* @remarks 减少使用该方法,尽量将业务函数作为invokeFunction的参数,从accessor中获取你所期望的service
|
|
30
|
-
*/
|
|
31
|
-
declare function getService<T>(instantiationService: IInstantiationService, id: ServiceIdentifier<T>): T;
|
|
32
|
-
declare class InstantiationService implements IInstantiationService {
|
|
33
|
-
readonly _serviceBrand: undefined;
|
|
34
|
-
readonly _globalGraph?: DepGraph;
|
|
35
|
-
private readonly _services;
|
|
36
|
-
private readonly _parent?;
|
|
37
|
-
private readonly _childs;
|
|
38
|
-
private readonly _enableTracing;
|
|
39
|
-
private _globalGraphImplicitDependency?;
|
|
40
|
-
private readonly _activeInstantiations;
|
|
41
|
-
private _emitter;
|
|
42
|
-
constructor(services?: ServiceCollection, parent?: InstantiationService, enableTracing?: boolean);
|
|
43
|
-
get services(): ServiceCollection;
|
|
44
|
-
get onError(): Event<[ErrorDataType]>;
|
|
45
|
-
createChild(services: ServiceCollection): IInstantiationService;
|
|
46
|
-
invokeFunction<R, TS extends any[] = []>(fn: (accessor: ServicesAccessor, ...args: TS) => R, ...args: TS): R;
|
|
47
|
-
createInstance<T>(descriptor: SyncDescriptor0<T>): T;
|
|
48
|
-
createInstance<Ctor extends new (...args: any[]) => any, R extends InstanceType<Ctor>>(ctor: Ctor, ...args: GetLeadingNonServiceArgs<ConstructorParameters<Ctor>>): R;
|
|
49
|
-
createInstance<T, Ctor extends new (...args: any[]) => any, R extends InstanceType<Ctor>>(descriptor: SyncDescriptor<T>, ...args: GetLeadingNonServiceArgs<ConstructorParameters<Ctor>>): R;
|
|
50
|
-
dispose(): void;
|
|
51
|
-
private _createInstance;
|
|
52
|
-
private _setServiceInstance;
|
|
53
|
-
private _getServiceInstanceOrDescriptor;
|
|
54
|
-
private _getOrCreateServiceInstance;
|
|
55
|
-
private _safeCreateAndCacheServiceInstance;
|
|
56
|
-
private _createAndCacheServiceInstance;
|
|
57
|
-
private _createServiceInstanceWithOwner;
|
|
58
|
-
private _createServiceInstance;
|
|
59
|
-
private _createService;
|
|
60
|
-
private _handleError;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
declare enum InstantiationType {
|
|
64
|
-
Eager = 0,
|
|
65
|
-
Delayed = 1
|
|
66
|
-
}
|
|
67
|
-
interface IServiceRegistryConfig {
|
|
68
|
-
checkDuplicate?: boolean;
|
|
69
|
-
}
|
|
70
|
-
declare class ServiceRegistry {
|
|
71
|
-
protected readonly _registry: [ServiceIdentifier<any>, SyncDescriptor<any> | BrandedService][];
|
|
72
|
-
protected readonly _serviceOwnership: ServiceOwnershipCollection;
|
|
73
|
-
private readonly _ids;
|
|
74
|
-
private readonly _checkDuplicate;
|
|
75
|
-
constructor(config?: IServiceRegistryConfig);
|
|
76
|
-
get registry(): [ServiceIdentifier<any>, BrandedService | SyncDescriptor<any>][];
|
|
77
|
-
/**
|
|
78
|
-
* 注册服务,通过传入构造函数或者描述符
|
|
79
|
-
*/
|
|
80
|
-
register<T, Services extends BrandedService[]>(id: ServiceIdentifier<T>, ctor: new (...services: Services) => T, supportsDelayedInstantiation?: boolean | InstantiationType): void;
|
|
81
|
-
register<T, Services extends BrandedService[]>(id: ServiceIdentifier<T>, descriptor: SyncDescriptor<any>): void;
|
|
82
|
-
/**
|
|
83
|
-
* 直接注册一个服务的实例
|
|
84
|
-
*
|
|
85
|
-
* 注意:谨慎使用,优先使用register
|
|
86
|
-
* 一般用于特殊场景:需要先于DI之前就构造了某个service
|
|
87
|
-
*/
|
|
88
|
-
registerInstance<T extends BrandedService>(id: ServiceIdentifier<T>, instance: T, options?: {
|
|
89
|
-
ownership: ServiceOwnership;
|
|
90
|
-
}): void;
|
|
91
|
-
makeCollection(): ServiceCollection;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
type LazyService<T> = {
|
|
95
|
-
readonly _serviceBrand: undefined;
|
|
96
|
-
getInstance: () => Promise<T>;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
11
|
interface ILazyServiceLoader<T> {
|
|
100
12
|
readonly _serviceBrand: undefined;
|
|
101
13
|
getInstance: (...rest: any[]) => Promise<T>;
|
|
@@ -137,4 +49,4 @@ declare const InstantiationContext: (props: IProps) => ReactElement<any, any>;
|
|
|
137
49
|
*/
|
|
138
50
|
declare function useService<T>(identifier: ServiceIdentifier<T>): T;
|
|
139
51
|
|
|
140
|
-
export { BrandedService,
|
|
52
|
+
export { BrandedService, IInstantiationService as IContainerService, IInstantiationService, type ILazyServiceLoader, InstantiationContext, LazyServiceLoader, ServiceIdentifier, SyncDescriptor, makeLazyServiceIdleLoad, useService };
|
package/dist/di/index.d.ts
CHANGED
|
@@ -1,101 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { h as IServiceCollection, g as createDecorator, r as refineServiceDecorator } from '../instantiation-service.interface-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { B as BrandedService, I as IInstantiationService, a as SyncDescriptor, S as ServiceIdentifier } from '../instantiation-service.interface-bshqO0aS.js';
|
|
2
|
+
export { G as GetLeadingNonServiceArgs, h as IServiceCollection, b as ServiceCollection, f as ServiceOwnership, c as ServicesAccessor, g as createDecorator, r as refineServiceDecorator } from '../instantiation-service.interface-bshqO0aS.js';
|
|
3
|
+
export { I as ContainerService, a as InstantiationErrorType, I as InstantiationService, g as getService } from '../instantiation-service-V9JO6Ljg.js';
|
|
4
|
+
export { L as LazyService, S as ServiceRegistry } from '../type-Bya55PZP.js';
|
|
5
5
|
import { ReactElement } from 'react';
|
|
6
|
+
import '../graph-BGbNOniY.js';
|
|
7
|
+
import '../emitter-DeM5mlEm.js';
|
|
6
8
|
import '../dispose-base-CAeXDpjg.js';
|
|
7
9
|
import '../linked-list-CUkue5DZ.js';
|
|
8
10
|
|
|
9
|
-
type DepGraph = Graph<string, any>;
|
|
10
|
-
declare enum InstantiationErrorType {
|
|
11
|
-
UnknownDependency = "UnknownDependency"
|
|
12
|
-
}
|
|
13
|
-
interface IBaseErrorEvent {
|
|
14
|
-
errorType: InstantiationErrorType;
|
|
15
|
-
message: string;
|
|
16
|
-
}
|
|
17
|
-
interface IUnknownDependencyErrorEvent extends IBaseErrorEvent {
|
|
18
|
-
errorType: InstantiationErrorType.UnknownDependency;
|
|
19
|
-
dependencyId: string;
|
|
20
|
-
issuer: string;
|
|
21
|
-
}
|
|
22
|
-
type ErrorDataType = IUnknownDependencyErrorEvent;
|
|
23
|
-
/**
|
|
24
|
-
* 从容器中获取对应的service
|
|
25
|
-
* @param instantiationService
|
|
26
|
-
* @param id
|
|
27
|
-
* @returns Service<T>
|
|
28
|
-
*
|
|
29
|
-
* @remarks 减少使用该方法,尽量将业务函数作为invokeFunction的参数,从accessor中获取你所期望的service
|
|
30
|
-
*/
|
|
31
|
-
declare function getService<T>(instantiationService: IInstantiationService, id: ServiceIdentifier<T>): T;
|
|
32
|
-
declare class InstantiationService implements IInstantiationService {
|
|
33
|
-
readonly _serviceBrand: undefined;
|
|
34
|
-
readonly _globalGraph?: DepGraph;
|
|
35
|
-
private readonly _services;
|
|
36
|
-
private readonly _parent?;
|
|
37
|
-
private readonly _childs;
|
|
38
|
-
private readonly _enableTracing;
|
|
39
|
-
private _globalGraphImplicitDependency?;
|
|
40
|
-
private readonly _activeInstantiations;
|
|
41
|
-
private _emitter;
|
|
42
|
-
constructor(services?: ServiceCollection, parent?: InstantiationService, enableTracing?: boolean);
|
|
43
|
-
get services(): ServiceCollection;
|
|
44
|
-
get onError(): Event<[ErrorDataType]>;
|
|
45
|
-
createChild(services: ServiceCollection): IInstantiationService;
|
|
46
|
-
invokeFunction<R, TS extends any[] = []>(fn: (accessor: ServicesAccessor, ...args: TS) => R, ...args: TS): R;
|
|
47
|
-
createInstance<T>(descriptor: SyncDescriptor0<T>): T;
|
|
48
|
-
createInstance<Ctor extends new (...args: any[]) => any, R extends InstanceType<Ctor>>(ctor: Ctor, ...args: GetLeadingNonServiceArgs<ConstructorParameters<Ctor>>): R;
|
|
49
|
-
createInstance<T, Ctor extends new (...args: any[]) => any, R extends InstanceType<Ctor>>(descriptor: SyncDescriptor<T>, ...args: GetLeadingNonServiceArgs<ConstructorParameters<Ctor>>): R;
|
|
50
|
-
dispose(): void;
|
|
51
|
-
private _createInstance;
|
|
52
|
-
private _setServiceInstance;
|
|
53
|
-
private _getServiceInstanceOrDescriptor;
|
|
54
|
-
private _getOrCreateServiceInstance;
|
|
55
|
-
private _safeCreateAndCacheServiceInstance;
|
|
56
|
-
private _createAndCacheServiceInstance;
|
|
57
|
-
private _createServiceInstanceWithOwner;
|
|
58
|
-
private _createServiceInstance;
|
|
59
|
-
private _createService;
|
|
60
|
-
private _handleError;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
declare enum InstantiationType {
|
|
64
|
-
Eager = 0,
|
|
65
|
-
Delayed = 1
|
|
66
|
-
}
|
|
67
|
-
interface IServiceRegistryConfig {
|
|
68
|
-
checkDuplicate?: boolean;
|
|
69
|
-
}
|
|
70
|
-
declare class ServiceRegistry {
|
|
71
|
-
protected readonly _registry: [ServiceIdentifier<any>, SyncDescriptor<any> | BrandedService][];
|
|
72
|
-
protected readonly _serviceOwnership: ServiceOwnershipCollection;
|
|
73
|
-
private readonly _ids;
|
|
74
|
-
private readonly _checkDuplicate;
|
|
75
|
-
constructor(config?: IServiceRegistryConfig);
|
|
76
|
-
get registry(): [ServiceIdentifier<any>, BrandedService | SyncDescriptor<any>][];
|
|
77
|
-
/**
|
|
78
|
-
* 注册服务,通过传入构造函数或者描述符
|
|
79
|
-
*/
|
|
80
|
-
register<T, Services extends BrandedService[]>(id: ServiceIdentifier<T>, ctor: new (...services: Services) => T, supportsDelayedInstantiation?: boolean | InstantiationType): void;
|
|
81
|
-
register<T, Services extends BrandedService[]>(id: ServiceIdentifier<T>, descriptor: SyncDescriptor<any>): void;
|
|
82
|
-
/**
|
|
83
|
-
* 直接注册一个服务的实例
|
|
84
|
-
*
|
|
85
|
-
* 注意:谨慎使用,优先使用register
|
|
86
|
-
* 一般用于特殊场景:需要先于DI之前就构造了某个service
|
|
87
|
-
*/
|
|
88
|
-
registerInstance<T extends BrandedService>(id: ServiceIdentifier<T>, instance: T, options?: {
|
|
89
|
-
ownership: ServiceOwnership;
|
|
90
|
-
}): void;
|
|
91
|
-
makeCollection(): ServiceCollection;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
type LazyService<T> = {
|
|
95
|
-
readonly _serviceBrand: undefined;
|
|
96
|
-
getInstance: () => Promise<T>;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
11
|
interface ILazyServiceLoader<T> {
|
|
100
12
|
readonly _serviceBrand: undefined;
|
|
101
13
|
getInstance: (...rest: any[]) => Promise<T>;
|
|
@@ -137,4 +49,4 @@ declare const InstantiationContext: (props: IProps) => ReactElement<any, any>;
|
|
|
137
49
|
*/
|
|
138
50
|
declare function useService<T>(identifier: ServiceIdentifier<T>): T;
|
|
139
51
|
|
|
140
|
-
export { BrandedService,
|
|
52
|
+
export { BrandedService, IInstantiationService as IContainerService, IInstantiationService, type ILazyServiceLoader, InstantiationContext, LazyServiceLoader, ServiceIdentifier, SyncDescriptor, makeLazyServiceIdleLoad, useService };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { I as IInstantiationService, b as ServiceCollection, B as BrandedService, S as ServiceIdentifier, a as SyncDescriptor } from './instantiation-service.interface-bshqO0aS.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
【动态依赖服务】
|
|
5
|
+
支持为子容器创建一块动态依赖的构建空间.
|
|
6
|
+
动态创建出来的服务可以依赖到自身的静态依赖服务, 反之不被允许。
|
|
7
|
+
子容器可以借助动态层完成一些【多容器间公共依赖】的抽离.可以理解为为了减少静态依赖图在多层设计应用时过于繁琐的一种简化手段.
|
|
8
|
+
-----------------------------
|
|
9
|
+
| InstantiationService |
|
|
10
|
+
-----------------------------
|
|
11
|
+
↑ lookup service ↑
|
|
12
|
+
-----------------------------
|
|
13
|
+
| DynamicDependencyService |
|
|
14
|
+
-----------------------------
|
|
15
|
+
↑ lookup service ↑
|
|
16
|
+
-----------------------------
|
|
17
|
+
| ChildContainerService |
|
|
18
|
+
-----------------------------
|
|
19
|
+
*/
|
|
20
|
+
interface IDynamicDependencyService extends IInstantiationService {
|
|
21
|
+
readonly _serviceBrand: undefined;
|
|
22
|
+
/**
|
|
23
|
+
* 创建子容器
|
|
24
|
+
*/
|
|
25
|
+
createChild: (services: ServiceCollection) => IInstantiationService;
|
|
26
|
+
/**
|
|
27
|
+
* 动态注册 service
|
|
28
|
+
* 重复注册会抛弃后面的服务
|
|
29
|
+
* */
|
|
30
|
+
register: <T, Services extends BrandedService[]>(id: ServiceIdentifier<T>, ctorOrDescriptor: {
|
|
31
|
+
new (...services: Services): T;
|
|
32
|
+
} | SyncDescriptor<any>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* containerService支持销毁,子containerService都会进行dispose
|
|
35
|
+
*/
|
|
36
|
+
dispose: () => void;
|
|
37
|
+
}
|
|
38
|
+
declare const IDynamicDependencyService: ServiceIdentifier<IDynamicDependencyService>;
|
|
39
|
+
|
|
40
|
+
export { IDynamicDependencyService as I };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { I as IInstantiationService, b as ServiceCollection, B as BrandedService, S as ServiceIdentifier, a as SyncDescriptor } from './instantiation-service.interface-bshqO0aS.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
【动态依赖服务】
|
|
5
|
+
支持为子容器创建一块动态依赖的构建空间.
|
|
6
|
+
动态创建出来的服务可以依赖到自身的静态依赖服务, 反之不被允许。
|
|
7
|
+
子容器可以借助动态层完成一些【多容器间公共依赖】的抽离.可以理解为为了减少静态依赖图在多层设计应用时过于繁琐的一种简化手段.
|
|
8
|
+
-----------------------------
|
|
9
|
+
| InstantiationService |
|
|
10
|
+
-----------------------------
|
|
11
|
+
↑ lookup service ↑
|
|
12
|
+
-----------------------------
|
|
13
|
+
| DynamicDependencyService |
|
|
14
|
+
-----------------------------
|
|
15
|
+
↑ lookup service ↑
|
|
16
|
+
-----------------------------
|
|
17
|
+
| ChildContainerService |
|
|
18
|
+
-----------------------------
|
|
19
|
+
*/
|
|
20
|
+
interface IDynamicDependencyService extends IInstantiationService {
|
|
21
|
+
readonly _serviceBrand: undefined;
|
|
22
|
+
/**
|
|
23
|
+
* 创建子容器
|
|
24
|
+
*/
|
|
25
|
+
createChild: (services: ServiceCollection) => IInstantiationService;
|
|
26
|
+
/**
|
|
27
|
+
* 动态注册 service
|
|
28
|
+
* 重复注册会抛弃后面的服务
|
|
29
|
+
* */
|
|
30
|
+
register: <T, Services extends BrandedService[]>(id: ServiceIdentifier<T>, ctorOrDescriptor: {
|
|
31
|
+
new (...services: Services): T;
|
|
32
|
+
} | SyncDescriptor<any>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* containerService支持销毁,子containerService都会进行dispose
|
|
35
|
+
*/
|
|
36
|
+
dispose: () => void;
|
|
37
|
+
}
|
|
38
|
+
declare const IDynamicDependencyService: ServiceIdentifier<IDynamicDependencyService>;
|
|
39
|
+
|
|
40
|
+
export { IDynamicDependencyService as I };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { I as IInstantiationService, b as ServiceCollection, c as ServicesAccessor, d as SyncDescriptor0, G as GetLeadingNonServiceArgs, a as SyncDescriptor, S as ServiceIdentifier } from './instantiation-service.interface-bshqO0aS.cjs';
|
|
2
|
+
import { G as Graph } from './graph-BGbNOniY.cjs';
|
|
3
|
+
import { E as Event } from './emitter-CAfCtSTg.cjs';
|
|
4
|
+
|
|
5
|
+
type DepGraph = Graph<string, any>;
|
|
6
|
+
declare enum InstantiationErrorType {
|
|
7
|
+
UnknownDependency = "UnknownDependency"
|
|
8
|
+
}
|
|
9
|
+
interface IBaseErrorEvent {
|
|
10
|
+
errorType: InstantiationErrorType;
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
interface IUnknownDependencyErrorEvent extends IBaseErrorEvent {
|
|
14
|
+
errorType: InstantiationErrorType.UnknownDependency;
|
|
15
|
+
dependencyId: string;
|
|
16
|
+
issuer: string;
|
|
17
|
+
}
|
|
18
|
+
type ErrorDataType = IUnknownDependencyErrorEvent;
|
|
19
|
+
/**
|
|
20
|
+
* 从容器中获取对应的service
|
|
21
|
+
* @param instantiationService
|
|
22
|
+
* @param id
|
|
23
|
+
* @returns Service<T>
|
|
24
|
+
*
|
|
25
|
+
* @remarks 减少使用该方法,尽量将业务函数作为invokeFunction的参数,从accessor中获取你所期望的service
|
|
26
|
+
*/
|
|
27
|
+
declare function getService<T>(instantiationService: IInstantiationService, id: ServiceIdentifier<T>): T;
|
|
28
|
+
declare class InstantiationService implements IInstantiationService {
|
|
29
|
+
readonly _serviceBrand: undefined;
|
|
30
|
+
readonly _globalGraph?: DepGraph;
|
|
31
|
+
private readonly _services;
|
|
32
|
+
private readonly _parent?;
|
|
33
|
+
private readonly _childs;
|
|
34
|
+
private readonly _enableTracing;
|
|
35
|
+
private _globalGraphImplicitDependency?;
|
|
36
|
+
private readonly _activeInstantiations;
|
|
37
|
+
private _emitter;
|
|
38
|
+
constructor(services?: ServiceCollection, parent?: InstantiationService, enableTracing?: boolean);
|
|
39
|
+
get services(): ServiceCollection;
|
|
40
|
+
get onError(): Event<[ErrorDataType]>;
|
|
41
|
+
createChild(services: ServiceCollection): IInstantiationService;
|
|
42
|
+
invokeFunction<R, TS extends any[] = []>(fn: (accessor: ServicesAccessor, ...args: TS) => R, ...args: TS): R;
|
|
43
|
+
createInstance<T>(descriptor: SyncDescriptor0<T>): T;
|
|
44
|
+
createInstance<Ctor extends new (...args: any[]) => any, R extends InstanceType<Ctor>>(ctor: Ctor, ...args: GetLeadingNonServiceArgs<ConstructorParameters<Ctor>>): R;
|
|
45
|
+
createInstance<T, Ctor extends new (...args: any[]) => any, R extends InstanceType<Ctor>>(descriptor: SyncDescriptor<T>, ...args: GetLeadingNonServiceArgs<ConstructorParameters<Ctor>>): R;
|
|
46
|
+
dispose(): void;
|
|
47
|
+
private _createInstance;
|
|
48
|
+
private _setServiceInstance;
|
|
49
|
+
private _getServiceInstanceOrDescriptor;
|
|
50
|
+
private _getOrCreateServiceInstance;
|
|
51
|
+
private _safeCreateAndCacheServiceInstance;
|
|
52
|
+
private _createAndCacheServiceInstance;
|
|
53
|
+
private _createServiceInstanceWithOwner;
|
|
54
|
+
private _createServiceInstance;
|
|
55
|
+
private _createService;
|
|
56
|
+
private _handleError;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { InstantiationService as I, InstantiationErrorType as a, getService as g };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { I as IInstantiationService, b as ServiceCollection, c as ServicesAccessor, d as SyncDescriptor0, G as GetLeadingNonServiceArgs, a as SyncDescriptor, S as ServiceIdentifier } from './instantiation-service.interface-bshqO0aS.js';
|
|
2
|
+
import { G as Graph } from './graph-BGbNOniY.js';
|
|
3
|
+
import { E as Event } from './emitter-DeM5mlEm.js';
|
|
4
|
+
|
|
5
|
+
type DepGraph = Graph<string, any>;
|
|
6
|
+
declare enum InstantiationErrorType {
|
|
7
|
+
UnknownDependency = "UnknownDependency"
|
|
8
|
+
}
|
|
9
|
+
interface IBaseErrorEvent {
|
|
10
|
+
errorType: InstantiationErrorType;
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
interface IUnknownDependencyErrorEvent extends IBaseErrorEvent {
|
|
14
|
+
errorType: InstantiationErrorType.UnknownDependency;
|
|
15
|
+
dependencyId: string;
|
|
16
|
+
issuer: string;
|
|
17
|
+
}
|
|
18
|
+
type ErrorDataType = IUnknownDependencyErrorEvent;
|
|
19
|
+
/**
|
|
20
|
+
* 从容器中获取对应的service
|
|
21
|
+
* @param instantiationService
|
|
22
|
+
* @param id
|
|
23
|
+
* @returns Service<T>
|
|
24
|
+
*
|
|
25
|
+
* @remarks 减少使用该方法,尽量将业务函数作为invokeFunction的参数,从accessor中获取你所期望的service
|
|
26
|
+
*/
|
|
27
|
+
declare function getService<T>(instantiationService: IInstantiationService, id: ServiceIdentifier<T>): T;
|
|
28
|
+
declare class InstantiationService implements IInstantiationService {
|
|
29
|
+
readonly _serviceBrand: undefined;
|
|
30
|
+
readonly _globalGraph?: DepGraph;
|
|
31
|
+
private readonly _services;
|
|
32
|
+
private readonly _parent?;
|
|
33
|
+
private readonly _childs;
|
|
34
|
+
private readonly _enableTracing;
|
|
35
|
+
private _globalGraphImplicitDependency?;
|
|
36
|
+
private readonly _activeInstantiations;
|
|
37
|
+
private _emitter;
|
|
38
|
+
constructor(services?: ServiceCollection, parent?: InstantiationService, enableTracing?: boolean);
|
|
39
|
+
get services(): ServiceCollection;
|
|
40
|
+
get onError(): Event<[ErrorDataType]>;
|
|
41
|
+
createChild(services: ServiceCollection): IInstantiationService;
|
|
42
|
+
invokeFunction<R, TS extends any[] = []>(fn: (accessor: ServicesAccessor, ...args: TS) => R, ...args: TS): R;
|
|
43
|
+
createInstance<T>(descriptor: SyncDescriptor0<T>): T;
|
|
44
|
+
createInstance<Ctor extends new (...args: any[]) => any, R extends InstanceType<Ctor>>(ctor: Ctor, ...args: GetLeadingNonServiceArgs<ConstructorParameters<Ctor>>): R;
|
|
45
|
+
createInstance<T, Ctor extends new (...args: any[]) => any, R extends InstanceType<Ctor>>(descriptor: SyncDescriptor<T>, ...args: GetLeadingNonServiceArgs<ConstructorParameters<Ctor>>): R;
|
|
46
|
+
dispose(): void;
|
|
47
|
+
private _createInstance;
|
|
48
|
+
private _setServiceInstance;
|
|
49
|
+
private _getServiceInstanceOrDescriptor;
|
|
50
|
+
private _getOrCreateServiceInstance;
|
|
51
|
+
private _safeCreateAndCacheServiceInstance;
|
|
52
|
+
private _createAndCacheServiceInstance;
|
|
53
|
+
private _createServiceInstanceWithOwner;
|
|
54
|
+
private _createServiceInstance;
|
|
55
|
+
private _createService;
|
|
56
|
+
private _handleError;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { InstantiationService as I, InstantiationErrorType as a, getService as g };
|
|
@@ -75,4 +75,4 @@ interface IInstantiationService {
|
|
|
75
75
|
}
|
|
76
76
|
declare const IInstantiationService: ServiceIdentifier<IInstantiationService>;
|
|
77
77
|
|
|
78
|
-
export { type BrandedService as B, type GetLeadingNonServiceArgs as G, IInstantiationService as I,
|
|
78
|
+
export { type BrandedService as B, type GetLeadingNonServiceArgs as G, IInstantiationService as I, type ServiceIdentifier as S, SyncDescriptor as a, ServiceCollection as b, type ServicesAccessor as c, type SyncDescriptor0 as d, ServiceOwnershipCollection as e, ServiceOwnership as f, createDecorator as g, type IServiceCollection as h, refineServiceDecorator as r };
|
|
@@ -75,4 +75,4 @@ interface IInstantiationService {
|
|
|
75
75
|
}
|
|
76
76
|
declare const IInstantiationService: ServiceIdentifier<IInstantiationService>;
|
|
77
77
|
|
|
78
|
-
export { type BrandedService as B, type GetLeadingNonServiceArgs as G, IInstantiationService as I,
|
|
78
|
+
export { type BrandedService as B, type GetLeadingNonServiceArgs as G, IInstantiationService as I, type ServiceIdentifier as S, SyncDescriptor as a, ServiceCollection as b, type ServicesAccessor as c, type SyncDescriptor0 as d, ServiceOwnershipCollection as e, ServiceOwnership as f, createDecorator as g, type IServiceCollection as h, refineServiceDecorator as r };
|
package/dist/launch/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { B as Barrier } from '../barrier-316Xonfd.cjs';
|
|
2
|
-
import { I as IInstantiationService, G as GetLeadingNonServiceArgs } from '../instantiation-service.interface-
|
|
2
|
+
import { I as IInstantiationService, G as GetLeadingNonServiceArgs } from '../instantiation-service.interface-bshqO0aS.cjs';
|
|
3
3
|
|
|
4
4
|
declare abstract class AbstractJob<T, K extends T = T> {
|
|
5
5
|
protected abstract _name: string;
|
package/dist/launch/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { B as Barrier } from '../barrier-316Xonfd.js';
|
|
2
|
-
import { I as IInstantiationService, G as GetLeadingNonServiceArgs } from '../instantiation-service.interface-
|
|
2
|
+
import { I as IInstantiationService, G as GetLeadingNonServiceArgs } from '../instantiation-service.interface-bshqO0aS.js';
|
|
3
3
|
|
|
4
4
|
declare abstract class AbstractJob<T, K extends T = T> {
|
|
5
5
|
protected abstract _name: string;
|