@asor-studio/asor-core 1.0.9 → 1.0.11

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/index.d.ts CHANGED
@@ -191,7 +191,7 @@ declare abstract class ConfigConst {
191
191
  * }
192
192
  * }
193
193
  */
194
- declare abstract class BaseMolecule implements IComp, IConsoleLoggable {
194
+ declare abstract class BaseMolecule implements IBaseMolecule, IConsoleLoggable, OnInit, OnDestroy {
195
195
  static readonly className: string;
196
196
  /**
197
197
  * Injected ActivatedRoute for accessing route data and parameters.
@@ -263,6 +263,36 @@ declare abstract class BaseMolecule implements IComp, IConsoleLoggable {
263
263
  * }
264
264
  */
265
265
  baseCompViewLeave(): void;
266
+ /**
267
+ * Lifecycle hook called when the component view is about to enter.
268
+ * Must be implemented by derived classes to define component-specific initialization logic.
269
+ *
270
+ * @throws Error if not implemented by the extending class
271
+ *
272
+ * @example
273
+ * export class MyMolecule extends BaseMolecule {
274
+ * baseCompViewWillEnter(): void {
275
+ * console.log('Component is entering view');
276
+ * this.loadData();
277
+ * }
278
+ * }
279
+ */
280
+ baseMoleculeViewWillEnter(): void;
281
+ /**
282
+ * Lifecycle hook called when the component view is about to leave.
283
+ * Must be implemented by derived classes to define component-specific cleanup logic.
284
+ *
285
+ * @throws Error if not implemented by the extending class
286
+ *
287
+ * @example
288
+ * export class MyMolecule extends BaseMolecule {
289
+ * baseCompViewWillLeave(): void {
290
+ * console.log('Component is leaving view');
291
+ * this.cleanup();
292
+ * }
293
+ * }
294
+ */
295
+ baseMoleculeViewWillLeave(): void;
266
296
  /**
267
297
  * Returns the name of the current component class.
268
298
  * Used internally to match the component with its configuration in route data.
@@ -274,6 +304,28 @@ declare abstract class BaseMolecule implements IComp, IConsoleLoggable {
274
304
  * console.log(this.getClassName()); // Outputs: "UserCardComponent"
275
305
  */
276
306
  getClassName(): string;
307
+ /**
308
+ * Lifecycle hook called when the component is initialized.
309
+ * Calls the baseMoleculeViewWillEnter() method.
310
+ */
311
+ ngOnInit(): void;
312
+ /**
313
+ * Lifecycle hook called when the component is destroyed.
314
+ * Calls the baseMoleculeViewWillLeave() method.
315
+ */
316
+ ngOnDestroy(): void;
317
+ /**
318
+ * Ionic lifecycle hook called when the view is about to enter and become the active view.
319
+ * This is called regardless of whether it is the first load or cached view.
320
+ * Delegates to baseCompViewWillEnter() for consistency across Angular and Ionic.
321
+ */
322
+ ionViewWillEnter(): void;
323
+ /**
324
+ * Ionic lifecycle hook called when the view is about to leave and no longer be the active view.
325
+ * This is called when navigating away from the current view.
326
+ * Delegates to baseCompViewWillLeave() for consistency across Angular and Ionic.
327
+ */
328
+ ionViewWillLeave(): void;
277
329
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseMolecule, never>;
278
330
  static ɵdir: i0.ɵɵDirectiveDeclaration<BaseMolecule, never, never, {}, {}, never, never, true, never>;
279
331
  }
@@ -592,6 +644,13 @@ interface DataElement {
592
644
  interface RegistryEntry<T = any> {
593
645
  propsIsUpdated: (props: T) => void;
594
646
  }
647
+ /**
648
+ * Registry element structure for component registrations
649
+ */
650
+ interface RegistryElement {
651
+ componentName: string;
652
+ destroy: () => void;
653
+ }
595
654
 
596
655
  /**
597
656
  * Base abstract class for Page/Component-level components following the Atomic Design pattern.
@@ -863,6 +922,9 @@ interface IComponent {
863
922
  interface ICompStatic {
864
923
  readonly className: string;
865
924
  }
925
+ /**
926
+ * Interface for BaseComponent
927
+ */
866
928
  interface IComp {
867
929
  /** Array of i18n translation paths for this component */
868
930
  I18nPath: string[];
@@ -871,6 +933,19 @@ interface IComp {
871
933
  /** Called when the component view is about to leave/destroy */
872
934
  baseCompViewLeave(): void;
873
935
  }
936
+ /**
937
+ * Interface for BaseMolecule
938
+ */
939
+ interface IBaseMolecule extends IComp {
940
+ /**
941
+ * Called when the molecule view is about to enter/initialize
942
+ */
943
+ baseMoleculeViewWillEnter(): void;
944
+ /**
945
+ * Called when the molecule view is about to leave/destroy
946
+ */
947
+ baseMoleculeViewWillLeave(): void;
948
+ }
874
949
  /**
875
950
  * Interface for authorization response from the backend API.
876
951
  * Contains the authorization status indicating if the user is allowed to perform an action.
@@ -1980,6 +2055,7 @@ type Constructor<T = {}> = abstract new (...args: any[]) => T;
1980
2055
  */
1981
2056
  interface IStorageHandler<T = any> {
1982
2057
  propsStore: T;
2058
+ registryElement?: RegistryElement;
1983
2059
  storageHandlerDataChanges(prev: any, curr: any): void;
1984
2060
  }
1985
2061
  /**
@@ -2014,6 +2090,7 @@ interface IStorageHandler<T = any> {
2014
2090
  */
2015
2091
  declare function BaseHandlerMixin<T extends object = any, TBase extends Constructor = Constructor>(Base: TBase): Constructor<IStorageHandler<T> & {
2016
2092
  propsStore: T;
2093
+ registryElement: RegistryElement;
2017
2094
  storageHandlerDataChanges(prev: T, curr: T): void;
2018
2095
  }> & TBase;
2019
2096
  /**
@@ -2034,6 +2111,7 @@ declare function createFlattenedReactiveProxy<T>(propsStore: Record<string, any>
2034
2111
 
2035
2112
  declare const BaseStorageComponent_base: _asor_studio_asor_core.Constructor<IStorageHandler<any> & {
2036
2113
  propsStore: any;
2114
+ registryElement: _asor_studio_asor_core.RegistryElement;
2037
2115
  storageHandlerDataChanges(prev: any, curr: any): void;
2038
2116
  }> & typeof BaseComponent;
2039
2117
  /**
@@ -2101,6 +2179,10 @@ declare abstract class BaseStorageComponent<T extends object = Record<string, an
2101
2179
  * are forwarded through the reactive proxy, triggering state updates.
2102
2180
  */
2103
2181
  get props(): T;
2182
+ /**
2183
+ * Override baseCompViewLeave to unregister from store
2184
+ */
2185
+ baseCompViewLeave(): void;
2104
2186
  constructor();
2105
2187
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseStorageComponent<any>, never>;
2106
2188
  static ɵdir: i0.ɵɵDirectiveDeclaration<BaseStorageComponent<any>, never, never, {}, {}, never, never, true, never>;
@@ -2108,6 +2190,7 @@ declare abstract class BaseStorageComponent<T extends object = Record<string, an
2108
2190
 
2109
2191
  declare const BaseStorageMolecule_base: _asor_studio_asor_core.Constructor<IStorageHandler<any> & {
2110
2192
  propsStore: any;
2193
+ registryElement: _asor_studio_asor_core.RegistryElement;
2111
2194
  storageHandlerDataChanges(prev: any, curr: any): void;
2112
2195
  }> & typeof BaseMolecule;
2113
2196
  /**
@@ -2189,6 +2272,14 @@ declare abstract class BaseStorageMolecule<T extends object = Record<string, any
2189
2272
  * are forwarded through the reactive proxy, triggering state updates.
2190
2273
  */
2191
2274
  get props(): T;
2275
+ /**
2276
+ * Override baseCompViewLeave to unregister from store
2277
+ */
2278
+ baseCompViewLeave(): void;
2279
+ /**
2280
+ * Override baseMoleculeViewWillLeave to unregister from store
2281
+ */
2282
+ baseMoleculeViewWillLeave(): void;
2192
2283
  constructor();
2193
2284
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseStorageMolecule<any>, never>;
2194
2285
  static ɵdir: i0.ɵɵDirectiveDeclaration<BaseStorageMolecule<any>, never, never, {}, {}, never, never, true, never>;
@@ -2450,7 +2541,7 @@ declare class StateService implements IConsoleLoggable {
2450
2541
  */
2451
2542
  registry<T = any>(componentName: string, propStructure: {
2452
2543
  [key: string]: string;
2453
- }, callback: (props: T) => void): void;
2544
+ }, callback: (props: T) => void): RegistryElement;
2454
2545
  /**
2455
2546
  * Resolve properties from state based on mapping structure
2456
2547
  * @param propStructure Object mapping property names to state paths
@@ -2550,4 +2641,4 @@ declare class AsorWidgetComponent {
2550
2641
  }
2551
2642
 
2552
2643
  export { GlobalEnum_d as AsorGlobalEnum, StateConstants_d as AsorStorage, AsorWidgetComponent, AuthGuard, AuthUtility, BaseComponent, BaseHandlerMixin, BaseMolecule, BaseStorageComponent, BaseStorageMolecule, CacheInterceptor, CachePathUtility, CacheUtility, CollectionUtils, ConfigCache, ConfigConst, ConsoleLogsConfig, ConsoleLogsUtility, CookieUtils, ErrorInterceptor, HttpRequestHandler, NotifyErrorService, ObjectUtils, RandomUtils, RoutingUtility, StateConst, StateService, StringUtils, TranslatePipe, TranslateUtility, createFlattenedReactiveProxy };
2553
- export type { AsorWidgetMode, Constructor, CreateDataSetOption, DataElement, DataMethod, EncryptType, GenerateType, IAsorRoute, IAuth, IComp, ICompStatic, IComponent, IConnectDataSet, IConsoleLoggable, ICreateDataSet, IHttpAuthSubscribe, IHttpFormError, IHttpRequest, IHttpRequestHandlerConfig, IHttpResponseError, IHttpSubscribe, IMolecule, IPath, IStorageHandler, LogClassConfig, LogEntry, LogLevel, RegistryEntry, StateHandlerConfig, StoreType, UpdateDataSetOption };
2644
+ export type { AsorWidgetMode, Constructor, CreateDataSetOption, DataElement, DataMethod, EncryptType, GenerateType, IAsorRoute, IAuth, IBaseMolecule, IComp, ICompStatic, IComponent, IConnectDataSet, IConsoleLoggable, ICreateDataSet, IHttpAuthSubscribe, IHttpFormError, IHttpRequest, IHttpRequestHandlerConfig, IHttpResponseError, IHttpSubscribe, IMolecule, IPath, IStorageHandler, LogClassConfig, LogEntry, LogLevel, RegistryElement, RegistryEntry, StateHandlerConfig, StoreType, UpdateDataSetOption };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asor-studio/asor-core",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^20.3.0 || ^21.0.0",
6
6
  "@angular/core": "^20.3.0 || ^21.0.0",