vona-core 5.0.52 → 5.0.54

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
  }
@@ -3,5 +3,5 @@ import type { VonaApplication } from '../core/application.ts';
3
3
  export declare class BeanSimple {
4
4
  protected app: VonaApplication;
5
5
  protected get ctx(): VonaContext;
6
- protected get bean(): import("vona").BeanContainer;
6
+ protected get bean(): import("./beanContainer.ts").BeanContainer;
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import type { ILocaleInfos } from './type.ts';
2
2
  import { BeanSimple } from '../../beanSimple.ts';
3
3
  export declare class AppLocale extends BeanSimple {
4
- get locale(): keyof ILocaleInfos;
5
- set locale(value: keyof ILocaleInfos);
4
+ get current(): keyof ILocaleInfos;
5
+ set current(value: keyof ILocaleInfos);
6
6
  getText<T extends keyof ILocaleInfos>(supportCustomMessage: boolean, moduleScope: string | undefined, locale: T | undefined, key: string, ...args: any[]): string;
7
7
  }
@@ -2,10 +2,10 @@ import * as localeutil from '@cabloy/localeutil';
2
2
  import { BeanSimple } from "../../beanSimple.js";
3
3
  import { LocaleModuleNameSeparator } from "./type.js";
4
4
  export class AppLocale extends BeanSimple {
5
- get locale() {
5
+ get current() {
6
6
  return this.ctx.locale;
7
7
  }
8
- set locale(value) {
8
+ set current(value) {
9
9
  this.ctx.locale = value;
10
10
  }
11
11
  /** @internal */
@@ -40,6 +40,6 @@ export class AppLocale extends BeanSimple {
40
40
  moduleScope = key.substring(0, pos);
41
41
  key = key.substring(pos + LocaleModuleNameSeparator.length);
42
42
  }
43
- return localeutil.getLocaleText(supportCustomMessage, moduleScope ? this.app.meta.localeModules[moduleScope] : undefined, this.app.meta.locales, locale || this.locale, key, ...args);
43
+ return localeutil.getLocaleText(supportCustomMessage, moduleScope ? this.app.meta.localeModules[moduleScope] : undefined, this.app.meta.locales, locale || this.current, key, ...args);
44
44
  }
45
45
  }
@@ -1,5 +1,5 @@
1
- import type { ILocaleInfos } from 'vona';
2
1
  import type z from 'zod';
2
+ import type { ILocaleInfos } from '../bean/resource/locale/type.ts';
3
3
  import type { VonaApplication } from '../core/application.ts';
4
4
  export type ZodLocaleError = () => {
5
5
  localeError: z.core.$ZodErrorMap;
@@ -9,6 +9,6 @@ export function zodEnhance(app) {
9
9
  }
10
10
  export function zodSetLocaleErrors(app, localeErrors, localeDefault) {
11
11
  setLocaleErrors(() => {
12
- return app.meta.locale.locale;
12
+ return app.meta.locale.current;
13
13
  }, localeErrors, localeDefault);
14
14
  }
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.54",
5
5
  "description": "vona",
6
6
  "publishConfig": {
7
7
  "access": "public"