vona-core 5.0.52 → 5.0.53

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.
@@ -1,13 +1,16 @@
1
1
  import type { IDecoratorBeanOptionsBase } from '../decorator/interface/beanOptions.ts';
2
2
  import { BeanSimple } from './beanSimple.ts';
3
3
  export declare const SymbolBeanFullName: unique symbol;
4
+ export declare const SymbolBeanInstanceKey: unique symbol;
4
5
  export declare const SymbolModuleBelong: unique symbol;
5
6
  export declare const SymbolModuleName: unique symbol;
6
7
  export declare class BeanBaseSimple extends BeanSimple {
7
8
  private [SymbolBeanFullName];
9
+ private [SymbolBeanInstanceKey];
8
10
  protected get [SymbolModuleBelong](): string;
9
11
  protected get [SymbolModuleName](): string | undefined;
10
12
  get $beanFullName(): string;
13
+ get $beanInstanceKey(): string;
11
14
  protected get $beanOptions(): IDecoratorBeanOptionsBase;
12
15
  get $onionName(): string;
13
16
  protected get $onionOptions(): unknown | undefined;
@@ -1,10 +1,12 @@
1
1
  import { appResource } from "../core/resource.js";
2
2
  import { BeanSimple } from "./beanSimple.js";
3
3
  export const SymbolBeanFullName = Symbol('SymbolBeanFullName');
4
+ export const SymbolBeanInstanceKey = Symbol('SymbolBeanInstanceKey');
4
5
  export const SymbolModuleBelong = Symbol('SymbolModuleBelong');
5
6
  export const SymbolModuleName = Symbol('SymbolModuleName');
6
7
  export class BeanBaseSimple extends BeanSimple {
7
8
  [SymbolBeanFullName];
9
+ [SymbolBeanInstanceKey];
8
10
  get [SymbolModuleBelong]() {
9
11
  return appResource._getModuleBelong(this[SymbolBeanFullName]);
10
12
  }
@@ -14,6 +16,9 @@ export class BeanBaseSimple extends BeanSimple {
14
16
  get $beanFullName() {
15
17
  return this[SymbolBeanFullName];
16
18
  }
19
+ get $beanInstanceKey() {
20
+ return this[SymbolBeanInstanceKey];
21
+ }
17
22
  get $beanOptions() {
18
23
  return appResource.getBean(this[SymbolBeanFullName]);
19
24
  }
@@ -11,6 +11,7 @@ export declare class BeanContainer {
11
11
  private [SymbolBeanContainerInstances];
12
12
  static create(app: VonaApplication, ctx: VonaContext | undefined): BeanContainer;
13
13
  protected constructor(app: VonaApplication, ctx: VonaContext | undefined);
14
+ disposeInstance(beanInstanceKey: string): Promise<void>;
14
15
  /** get specific module's scope */
15
16
  scope<K extends TypeBeanScopeRecordKeys>(moduleScope: K): IBeanScopeRecord[K];
16
17
  _getBean<T>(A: Constructable<T>, ...args: any[]): T;
@@ -6,7 +6,7 @@ import { __prepareInjectSelectorInfo } from "../decorator/index.js";
6
6
  import { compose } from "../utils/util.js";
7
7
  import { BeanAopBase } from "./beanAopBase.js";
8
8
  import { BeanBase } from "./beanBase.js";
9
- import { SymbolBeanFullName } from "./beanBaseSimple.js";
9
+ import { SymbolBeanFullName, SymbolBeanInstanceKey } from "./beanBaseSimple.js";
10
10
  import { BeanSimple } from "./beanSimple.js";
11
11
  const SymbolProxyMagic = Symbol('SymbolProxyMagic');
12
12
  const SymbolProxyAopMethod = Symbol('SymbolProxyAopMethod');
@@ -45,6 +45,15 @@ export class BeanContainer {
45
45
  }
46
46
  this[SymbolBeanContainerInstances] = {};
47
47
  }
48
+ async disposeInstance(beanInstanceKey) {
49
+ const beanInstance = this[SymbolBeanContainerInstances][beanInstanceKey];
50
+ if (beanInstance) {
51
+ if (!(beanInstance instanceof BeanAopBase) && beanInstance.__dispose__) {
52
+ await beanInstance.__dispose__();
53
+ }
54
+ delete this[SymbolBeanContainerInstances][beanInstanceKey];
55
+ }
56
+ }
48
57
  // scope<T>(moduleScope: string): T;
49
58
  scope(moduleScope) {
50
59
  return this._getBean(`${moduleScope}.scope.module`);
@@ -103,6 +112,7 @@ export class BeanContainer {
103
112
  const fullName = appResource.getBeanFullName(beanFullName);
104
113
  if (fullName) {
105
114
  const key = __getSelectorKey(fullName, withSelector, args[0]);
115
+ __setPropertyValue(beanInstance, SymbolBeanInstanceKey, key);
106
116
  this[SymbolBeanContainerInstances][key] = beanInstance;
107
117
  }
108
118
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-core",
3
3
  "type": "module",
4
- "version": "5.0.52",
4
+ "version": "5.0.53",
5
5
  "description": "vona",
6
6
  "publishConfig": {
7
7
  "access": "public"