taro-bluetooth-print 2.9.1 → 2.9.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.
|
@@ -80,5 +80,5 @@ export declare class Container {
|
|
|
80
80
|
private createInstance;
|
|
81
81
|
}
|
|
82
82
|
export declare const rootContainer: Container;
|
|
83
|
-
export declare function injectable<T extends Constructor
|
|
83
|
+
export declare function injectable<T extends Constructor<object>>(constructor: T): T;
|
|
84
84
|
export declare function inject(token: string | symbol): (target: any, _propertyKey: string | symbol, parameterIndex: number) => any;
|
package/package.json
CHANGED
package/src/core/di/Container.ts
CHANGED
|
@@ -73,15 +73,17 @@ export class Container {
|
|
|
73
73
|
const config = provider as ServiceProviderConfig<T>;
|
|
74
74
|
|
|
75
75
|
// 如果是对象语法(Angular 风格)
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
if (
|
|
77
|
+
config &&
|
|
78
|
+
typeof config === 'object' &&
|
|
79
|
+
(config.useClass || config.useFactory || config.useValue !== undefined)
|
|
80
|
+
) {
|
|
81
|
+
let actualProvider: Provider<T>;
|
|
79
82
|
|
|
80
83
|
if (config.useClass) {
|
|
81
84
|
// 使用类 - 创建工厂函数来解析依赖
|
|
82
85
|
const Cls = config.useClass;
|
|
83
86
|
actualProvider = (container: Container) => {
|
|
84
|
-
// 简化:直接实例化(实际应该解析依赖)
|
|
85
87
|
return container.createInstance(Cls);
|
|
86
88
|
};
|
|
87
89
|
} else if (config.useFactory) {
|
|
@@ -91,6 +93,7 @@ export class Container {
|
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
const registration: Registration<T> = {
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
94
97
|
provider: actualProvider,
|
|
95
98
|
options: {
|
|
96
99
|
lifecycle: config.lifecycle || 'transient',
|
|
@@ -305,11 +308,10 @@ export class Container {
|
|
|
305
308
|
export const rootContainer = new Container();
|
|
306
309
|
|
|
307
310
|
// 装饰器辅助函数
|
|
308
|
-
|
|
309
|
-
export function injectable<T extends Constructor>(constructor: T): T {
|
|
311
|
+
export function injectable<T extends Constructor<object>>(constructor: T): T {
|
|
310
312
|
// 标记类为可注入
|
|
311
313
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
312
|
-
(constructor as
|
|
314
|
+
(constructor as unknown as { __injectable: boolean }).__injectable = true;
|
|
313
315
|
return constructor;
|
|
314
316
|
}
|
|
315
317
|
|