@memberjunction/ng-base-application 5.33.0 → 5.34.1

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.
@@ -20,6 +20,7 @@ export interface UserAppConfig {
20
20
  * Orders applications by UserApplication.Sequence.
21
21
  */
22
22
  export declare class ApplicationManager {
23
+ private static _recoveryAttempted;
23
24
  private applications$;
24
25
  private allApplications$;
25
26
  private userAppConfigs$;
@@ -134,6 +135,13 @@ export declare class ApplicationManager {
134
135
  * Delegates to UserInfoEngine for the actual creation.
135
136
  */
136
137
  private createDefaultUserApplications;
138
+ /**
139
+ * One-shot recovery attempt when the initial load produces zero apps despite
140
+ * Active applications existing in metadata. Force-refreshes UserInfoEngine
141
+ * to bypass any corrupted cache, then re-runs the user app configuration
142
+ * (which includes the self-healing path for new users).
143
+ */
144
+ private attemptRecovery;
137
145
  /**
138
146
  * Set the active application by ID
139
147
  */
@@ -1 +1 @@
1
- {"version":3,"file":"application-manager.d.ts","sourceRoot":"","sources":["../../src/lib/application-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;AAEnD,OAAO,EAAkE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzH,OAAO,EAAE,uBAAuB,EAAkB,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;;AAErD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,eAAe,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,qBAGa,kBAAkB;IAC7B,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,gBAAgB,CAA8C;IACtE,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,UAAU,CAAqD;IACvE,OAAO,CAAC,QAAQ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;IAChB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
1
+ {"version":3,"file":"application-manager.d.ts","sourceRoot":"","sources":["../../src/lib/application-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;AAEnD,OAAO,EAAkE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzH,OAAO,EAAE,uBAAuB,EAAkB,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;;AAErD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,eAAe,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,qBAGa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAS;IAC1C,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,gBAAgB,CAA8C;IACtE,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,UAAU,CAAqD;IACvE,OAAO,CAAC,QAAQ,CAAuC;IACvD,OAAO,CAAC,WAAW,CAAS;IAE5B,kEAAkE;IAClE,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,aAAa,CAAmE;IAExF;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1B;;OAEG;IACH,IAAI,YAAY,IAAI,UAAU,CAAC,eAAe,EAAE,CAAC,CAEhD;IAED;;OAEG;IACH,IAAI,eAAe,IAAI,UAAU,CAAC,eAAe,EAAE,CAAC,CAEnD;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,UAAU,CAAC,aAAa,EAAE,CAAC,C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OxF;;OAEG;IACH,kBAAkB,IAAI,eAAe,EAAE;IAMvC;;;OAGG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAkB7D;;;OAGG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAMpC;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAsE7C;;;;OAIG;IACG,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IAO/E;;;;OAIG;IACG,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMvD;;;;OAIG;IACG,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMxD;;;;OAIG;IACG,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;yCAzmB/C,kBAAkB;6CAAlB,kBAAkB;CA8mB9B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,MAAM,EAAE,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,eAAe,GAAG,UAAU,GAAG,gBAAgB,CAAC;IAClG,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
@@ -13,6 +13,7 @@ import * as i0 from "@angular/core";
13
13
  * Orders applications by UserApplication.Sequence.
14
14
  */
15
15
  export class ApplicationManager {
16
+ static _recoveryAttempted = false;
16
17
  applications$ = new BehaviorSubject([]);
17
18
  allApplications$ = new BehaviorSubject([]);
18
19
  userAppConfigs$ = new BehaviorSubject([]);
@@ -249,6 +250,21 @@ export class ApplicationManager {
249
250
  this.allApplications$.next(allApps);
250
251
  // Load and apply user's app configuration
251
252
  await this.loadUserApplicationConfig();
253
+ // Recovery check: if no active apps but metadata has Active applications,
254
+ // the engine may have failed to load UserApplications (e.g., cache corruption).
255
+ // Attempt one recovery by force-refreshing UserInfoEngine before giving up.
256
+ const activeApps = this.applications$.value;
257
+ const hasMetadataApps = md.Applications.some(a => a.Status === 'Active');
258
+ if (activeApps.length === 0 && hasMetadataApps && !ApplicationManager._recoveryAttempted) {
259
+ ApplicationManager._recoveryAttempted = true;
260
+ const activeAppCount = md.Applications.filter(a => a.Status === 'Active').length;
261
+ const engineHealthy = UserInfoEngine.Instance.AllPropertiesLoadedSuccessfully;
262
+ const userAppCount = UserInfoEngine.Instance.UserApplications?.length ?? 0;
263
+ LogStatus(`ApplicationManager: Recovery triggered — ` +
264
+ `activeApps=0, metadataActiveApps=${activeAppCount}, ` +
265
+ `engineHealthy=${engineHealthy}, userAppRecords=${userAppCount}`);
266
+ await this.attemptRecovery();
267
+ }
252
268
  this.initialized = true;
253
269
  this._readyResolve();
254
270
  }
@@ -309,6 +325,30 @@ export class ApplicationManager {
309
325
  const engine = UserInfoEngine.Instance;
310
326
  return await engine.CreateDefaultApplications();
311
327
  }
328
+ /**
329
+ * One-shot recovery attempt when the initial load produces zero apps despite
330
+ * Active applications existing in metadata. Force-refreshes UserInfoEngine
331
+ * to bypass any corrupted cache, then re-runs the user app configuration
332
+ * (which includes the self-healing path for new users).
333
+ */
334
+ async attemptRecovery() {
335
+ try {
336
+ const engine = UserInfoEngine.Instance;
337
+ await engine.Config(true);
338
+ await this.loadUserApplicationConfig();
339
+ const recoveredCount = this.applications$.value.length;
340
+ const engineHealthy = engine.AllPropertiesLoadedSuccessfully;
341
+ if (recoveredCount > 0) {
342
+ LogStatus(`ApplicationManager: Recovery succeeded — ${recoveredCount} apps loaded, engineHealthy=${engineHealthy}`);
343
+ }
344
+ else {
345
+ LogError(`ApplicationManager: Recovery completed but still 0 apps — engineHealthy=${engineHealthy}`);
346
+ }
347
+ }
348
+ catch (error) {
349
+ LogError('ApplicationManager: Recovery attempt failed:', undefined, error instanceof Error ? error.message : String(error));
350
+ }
351
+ }
312
352
  /**
313
353
  * Set the active application by ID
314
354
  */
@@ -1 +1 @@
1
- {"version":3,"file":"application-manager.js","sourceRoot":"","sources":["../../src/lib/application-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAc,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAmB,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAqB,MAAM,sBAAsB,CAAC;AACzH,OAAO,EAA2B,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;;AAYrD;;;;;;GAMG;AAIH,MAAM,OAAO,kBAAkB;IACrB,aAAa,GAAG,IAAI,eAAe,CAAoB,EAAE,CAAC,CAAC;IAC3D,gBAAgB,GAAG,IAAI,eAAe,CAAoB,EAAE,CAAC,CAAC;IAC9D,eAAe,GAAG,IAAI,eAAe,CAAkB,EAAE,CAAC,CAAC;IAC3D,UAAU,GAAG,IAAI,eAAe,CAAyB,IAAI,CAAC,CAAC;IAC/D,QAAQ,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC,CAAC;IAC/C,WAAW,GAAG,KAAK,CAAC;IAE5B,kEAAkE;IAC1D,aAAa,CAAc;IAC3B,aAAa,GAAG,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAExF;;;OAGG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B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AAgB,CAAC,KAAa;QAClC,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC;QACvC,4EAA4E;QAC5E,OAAO,MAAM,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB,CAAC,KAAa;QACnC,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC;QACvC,4EAA4E;QAC5E,OAAO,MAAM,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,mBAAmB,CAAC,KAAa;QACrC,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC;QACvC,8EAA8E;QAC9E,OAAO,MAAM,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;4GAlkBU,kBAAkB;gEAAlB,kBAAkB,WAAlB,kBAAkB,mBAFjB,MAAM;;iFAEP,kBAAkB;cAH9B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { MJGlobal, MJEventType, UUIDsEqual } from '@memberjunction/global';\nimport { Metadata, ApplicationInfo, LogError, LogStatus, StartupManager, IMetadataProvider } from '@memberjunction/core';\nimport { MJUserApplicationEntity, UserInfoEngine } from '@memberjunction/core-entities';\nimport { BaseApplication } from './base-application';\n\n/**\n * Represents a user's application configuration including visibility and order\n */\nexport interface UserAppConfig {\n app: BaseApplication;\n userAppId: string;\n sequence: number;\n isActive: boolean;\n}\n\n/**\n * Manages application instances and active application state.\n *\n * Loads applications filtered by the user's UserApplication records.\n * If user has no UserApplication records, auto-creates them from DefaultForNewUser apps.\n * Orders applications by UserApplication.Sequence.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class ApplicationManager {\n private applications$ = new BehaviorSubject<BaseApplication[]>([]);\n private allApplications$ = new BehaviorSubject<BaseApplication[]>([]);\n private userAppConfigs$ = new BehaviorSubject<UserAppConfig[]>([]);\n private activeApp$ = new BehaviorSubject<BaseApplication | null>(null);\n private loading$ = new BehaviorSubject<boolean>(false);\n private initialized = false;\n\n /** Resolves when loadApplications() has completed successfully */\n private _readyResolve!: () => void;\n private _readyPromise = new Promise<void>(resolve => { this._readyResolve = resolve; });\n\n /**\n * Returns a promise that resolves when applications have been loaded and the manager is ready.\n * Safe to call multiple times — returns the same promise.\n */\n WhenReady(): Promise<void> {\n return this._readyPromise;\n }\n\n /**\n * Observable of user's active applications (filtered and ordered by UserApplication)\n */\n get Applications(): Observable<BaseApplication[]> {\n return this.applications$.asObservable();\n }\n\n /**\n * Observable of ALL applications in the system (unfiltered)\n */\n get AllApplications(): Observable<BaseApplication[]> {\n return this.allApplications$.asObservable();\n }\n\n /**\n * Observable of user's application configurations (includes sequence, isActive)\n */\n get UserAppConfigs(): Observable<UserAppConfig[]> {\n return this.userAppConfigs$.asObservable();\n }\n\n /**\n * Observable of the currently active application\n */\n get ActiveApp(): Observable<BaseApplication | null> {\n return this.activeApp$.asObservable();\n }\n\n /**\n * Observable of loading state\n */\n get Loading(): Observable<boolean> {\n return this.loading$.asObservable();\n }\n\n /**\n * Get user's active applications synchronously (filtered and ordered)\n */\n GetAllApps(): BaseApplication[] {\n return this.applications$.value;\n }\n\n /**\n * Get ALL applications synchronously (unfiltered)\n */\n GetAllSystemApps(): BaseApplication[] {\n return this.allApplications$.value;\n }\n\n /**\n * Get all applications the current user's roles grant access to.\n * Filters out apps where ApplicationRole records exist but the user's roles lack CanAccess.\n */\n GetAuthorizedSystemApps(): BaseApplication[] {\n const engine = UserInfoEngine.Instance;\n return this.allApplications$.value.filter(app => engine.UserHasApplicationAccess(app.ID));\n }\n\n /**\n * Get user's application configurations synchronously\n */\n GetUserAppConfigs(): UserAppConfig[] {\n return this.userAppConfigs$.value;\n }\n\n /**\n * Get active application synchronously\n */\n GetActiveApp(): BaseApplication | null {\n return this.activeApp$.value;\n }\n\n /**\n * Optional explicit metadata provider. When set, all provider lookups\n * use this instead of falling back to `Metadata.Provider`. This is the\n * threading point for multi-provider Angular apps — the shell calls\n * `setProvider(this.ProviderToUse)` after the manager is acquired from DI.\n */\n private _provider: IMetadataProvider | null = null;\n\n public set Provider(value: IMetadataProvider | null) {\n this._provider = value;\n }\n\n public get Provider(): IMetadataProvider {\n return this._provider ?? Metadata.Provider;\n }\n\n constructor() {\n this.Initialize();\n }\n\n /**\n * Initialize the application manager by subscribing to the LoggedIn event.\n * Applications are loaded when the event fires, ensuring metadata is ready.\n * Also subscribes to UserInfoEngine data changes to auto-sync when user apps change.\n */\n Initialize(): void {\n if (this.initialized) {\n return;\n }\n\n // Subscribe with replay (true) to catch the event even if it already fired\n MJGlobal.Instance.GetEventListener(true).subscribe(async (event) => {\n if (event.event === MJEventType.LoggedIn) {\n await StartupManager.Instance.Startup() // make sure this is done\n this.loadApplications();\n this.subscribeToEngineChanges();\n }\n });\n }\n\n /**\n * Subscribe to UserInfoEngine data changes to automatically sync our observables\n * when UserApplication records are modified.\n *\n * Match on EntityName (the stable public identifier) rather than PropertyName —\n * PropertyName is the engine's internal backing-field name (e.g. `_UserApplications`\n * with an underscore prefix), which is an implementation detail that has bitten\n * consumers before. EntityName is the documented contract on every config and\n * never changes shape.\n */\n private subscribeToEngineChanges(): void {\n const engine = UserInfoEngine.Instance;\n engine.DataChange$.subscribe(event => {\n // When UserApplications data changes in the engine, sync our observables\n if (event.config.EntityName?.trim().toLowerCase() === 'mj: user applications') {\n this.syncFromEngine();\n }\n });\n }\n\n /**\n * Sync our BehaviorSubjects with the current data from UserInfoEngine.\n * Called when the engine emits a data change event for UserApplications.\n */\n private syncFromEngine(): void {\n const allApps = this.allApplications$.value;\n const engine = UserInfoEngine.Instance;\n const userApps = engine.UserApplications;\n\n // Build a map for quick lookup\n const appMap = new Map<string, BaseApplication>();\n for (const app of allApps) {\n appMap.set(app.ID, app);\n }\n\n // Build user's filtered and ordered app list\n const userAppConfigs: UserAppConfig[] = [];\n const activeApps: BaseApplication[] = [];\n\n for (const userApp of userApps) {\n const app = appMap.get(userApp.ApplicationID);\n if (app && userApp.IsActive && engine.UserHasApplicationAccess(userApp.ApplicationID)) {\n userAppConfigs.push({\n app,\n userAppId: userApp.ID,\n sequence: userApp.Sequence,\n isActive: userApp.IsActive\n });\n activeApps.push(app);\n }\n }\n\n this.userAppConfigs$.next(userAppConfigs);\n this.applications$.next(activeApps);\n }\n\n /**\n * Reload the user's application configuration.\n * Call this after changes to UserApplication records to refresh the app list.\n *\n * Reads engine.UserApplications and rebuilds our derived observables. The engine's\n * own event-driven refresh (via subscribeToEngineChanges + the UserApplications\n * config's short DebounceTime) keeps the underlying data fresh — we no longer need\n * a synchronous force-refresh here, which previously triggered NG0100 in callers\n * with `@if`/`@for` bindings whose values mutate during their save loop.\n */\n async ReloadUserApplications(): Promise<void> {\n this.loading$.next(true);\n\n try {\n await this.loadUserApplicationConfig();\n } finally {\n this.loading$.next(false);\n }\n }\n\n /**\n * Load applications from metadata, filtered and ordered by user's UserApplication records.\n * If user has no UserApplication records, auto-creates them from DefaultForNewUser apps.\n */\n private async loadApplications(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n this.loading$.next(true);\n\n try {\n const md = this.Provider;\n const appInfoList: ApplicationInfo[] = md.Applications;\n\n // First, create BaseApplication instances for ALL apps\n const allApps: BaseApplication[] = [];\n\n for (const appInfo of appInfoList) {\n // Only create instances for Active applications\n if (appInfo.Status !== 'Active') {\n continue;\n }\n\n const args = {\n ID: appInfo.ID,\n Name: appInfo.Name,\n Description: appInfo.Description || '',\n Icon: appInfo.Icon || '',\n Color: appInfo.Color,\n DefaultNavItems: appInfo.DefaultNavItems,\n ClassName: appInfo.ClassName,\n DefaultSequence: appInfo.DefaultSequence,\n Status: appInfo.Status,\n NavigationStyle: appInfo.NavigationStyle,\n TopNavLocation: appInfo.TopNavLocation,\n HideNavBarIconWhenActive: appInfo.HideNavBarIconWhenActive,\n Path: appInfo.Path || '',\n AutoUpdatePath: appInfo.AutoUpdatePath\n };\n\n let app: BaseApplication | null;\n if (appInfo.ClassName && appInfo.ClassName.trim().length > 0) {\n app = await MJGlobal.Instance.ClassFactory.CreateInstanceAsync<BaseApplication>(\n BaseApplication,\n appInfo.ClassName,\n args\n );\n }\n else {\n // no class provided in app definition.\n app = new BaseApplication(args)\n }\n\n if (app) {\n // should always get here unless failure to load registered sub-class but CreateInstance has\n // fallback to base class anyway so should always get here\n if (this._provider) {\n app.Provider = this._provider;\n }\n allApps.push(app);\n }\n }\n\n this.allApplications$.next(allApps);\n\n // Load and apply user's app configuration\n await this.loadUserApplicationConfig();\n\n this.initialized = true;\n this._readyResolve();\n\n } catch (error) {\n // Resolve even on failure so waiters don't hang forever — they'll see initialized=false\n this._readyResolve();\n LogError('Failed to load applications:', undefined, error instanceof Error ? error.message : String(error));\n throw error;\n } finally {\n this.loading$.next(false);\n }\n }\n\n /**\n * Load user's UserApplication records and update the filtered/ordered app list.\n * This can be called to refresh after configuration changes.\n */\n private async loadUserApplicationConfig(): Promise<void> {\n const md = this.Provider;\n const allApps = this.allApplications$.value;\n\n // Build a map for quick lookup\n const appMap = new Map<string, BaseApplication>();\n for (const app of allApps) {\n appMap.set(app.ID, app);\n }\n\n // Load user's UserApplication records using UserInfoEngine for caching\n const engine = UserInfoEngine.Instance;\n\n let userApps: MJUserApplicationEntity[] = engine.UserApplications;\n\n // Self-healing: If user has no UserApplication records, create from DefaultForNewUser apps\n if (userApps.length === 0) {\n LogStatus(`User ${md.CurrentUser.Name} has no UserApplication records, creating from DefaultForNewUser apps`);\n userApps = await this.createDefaultUserApplications();\n }\n\n // Build user's filtered and ordered app list\n const userAppConfigs: UserAppConfig[] = [];\n const activeApps: BaseApplication[] = [];\n\n for (const userApp of userApps) {\n const app = appMap.get(userApp.ApplicationID);\n if (app && userApp.IsActive && engine.UserHasApplicationAccess(userApp.ApplicationID)) {\n userAppConfigs.push({\n app,\n userAppId: userApp.ID,\n sequence: userApp.Sequence,\n isActive: userApp.IsActive\n });\n activeApps.push(app);\n }\n }\n\n this.userAppConfigs$.next(userAppConfigs);\n this.applications$.next(activeApps);\n }\n\n /**\n * Creates UserApplication records for apps with DefaultForNewUser=true and Status='Active'.\n * Called when a user has no existing UserApplication records (self-healing).\n * Delegates to UserInfoEngine for the actual creation.\n */\n private async createDefaultUserApplications(): Promise<MJUserApplicationEntity[]> {\n const engine = UserInfoEngine.Instance;\n return await engine.CreateDefaultApplications();\n }\n\n /**\n * Set the active application by ID\n */\n async SetActiveApp(appId: string): Promise<void> {\n const currentApp = this.activeApp$.value;\n const newApp = this.applications$.value.find(a => UUIDsEqual(a.ID, appId));\n\n if (!newApp) {\n return;\n }\n\n if (UUIDsEqual(currentApp?.ID, appId)) {\n return; // Already active\n }\n\n // Deactivate current app\n if (currentApp) {\n await currentApp.OnDeactivate();\n }\n\n // Activate new app\n await newApp.OnActivate();\n this.activeApp$.next(newApp);\n }\n\n /**\n * Get application by ID\n */\n GetAppById(appId: string): BaseApplication | undefined {\n return this.applications$.value.find(a => UUIDsEqual(a.ID, appId));\n }\n\n /**\n * Get application by name\n */\n GetAppByName(name: string): BaseApplication | undefined {\n return this.applications$.value.find(a => a.Name === name);\n }\n\n /**\n * Get application by URL path slug.\n * Matches case-insensitively against the app's Path property.\n * Falls back to Name match if Path is not found (for backwards compatibility).\n */\n GetAppByPath(path: string): BaseApplication | undefined {\n const normalizedPath = path.trim().toLowerCase();\n\n // First try exact path match\n const pathMatch = this.applications$.value.find(a =>\n a.Path?.toLowerCase() === normalizedPath\n );\n\n if (pathMatch) {\n return pathMatch;\n }\n\n // Fallback: try matching by name (for backwards compatibility with old URLs)\n return this.applications$.value.find(a =>\n a.Name.trim().toLowerCase() === normalizedPath\n );\n }\n\n /**\n * Get applications that should appear in the Nav Bar (NavigationStyle = 'Nav Bar' or 'Both')\n * filtered by TopNavLocation.\n */\n GetNavBarApps(location: 'Left of App Switcher' | 'Left of User Menu'): BaseApplication[] {\n return this.applications$.value.filter(app =>\n (app.NavigationStyle === 'Nav Bar' || app.NavigationStyle === 'Both') &&\n app.TopNavLocation === location\n );\n }\n\n /**\n * Get applications that should appear in the App Switcher (NavigationStyle = 'App Switcher' or 'Both')\n */\n GetAppSwitcherApps(): BaseApplication[] {\n return this.applications$.value.filter(app =>\n app.NavigationStyle === 'App Switcher' || app.NavigationStyle === 'Both'\n );\n }\n\n /**\n * Check if an app exists in the system by path or name (case-insensitive).\n * Returns the app from allApplications$ if found, regardless of user access.\n */\n GetSystemAppByPath(path: string): BaseApplication | undefined {\n const normalizedPath = path.trim().toLowerCase();\n\n // First try exact path match\n const pathMatch = this.allApplications$.value.find(a =>\n a.Path?.toLowerCase() === normalizedPath\n );\n\n if (pathMatch) {\n return pathMatch;\n }\n\n // Fallback: try matching by name\n return this.allApplications$.value.find(a =>\n a.Name.trim().toLowerCase() === normalizedPath\n );\n }\n\n /**\n * Check if a system app is inactive (Status !== 'Active').\n * Delegates to UserInfoEngine for the metadata lookup.\n */\n IsAppInactive(path: string): boolean {\n const engine = UserInfoEngine.Instance;\n const appInfo = engine.FindApplicationByPathOrName(path);\n return appInfo != null && engine.IsApplicationInactive(appInfo.ID);\n }\n\n /**\n * Determine why a user cannot access an app by its URL path.\n * Uses UserInfoEngine for core access checking logic.\n * Returns detailed access information for error handling.\n */\n CheckAppAccess(path: string): AppAccessResult {\n const engine = UserInfoEngine.Instance;\n\n // Step 1: Check if app exists in metadata at all\n const appInfo = engine.FindApplicationByPathOrName(path);\n\n if (!appInfo) {\n return {\n status: 'not_found',\n message: `The application \"${path}\" does not exist.`,\n appName: path\n };\n }\n\n // Step 2: Check if app is inactive\n if (engine.IsApplicationInactive(appInfo.ID)) {\n return {\n status: 'inactive',\n message: `The application \"${appInfo.Name}\" is currently inactive.`,\n appName: appInfo.Name,\n appId: appInfo.ID\n };\n }\n\n // Step 3: Check user's access status via engine\n const accessStatus = engine.CheckUserApplicationAccess(appInfo.ID);\n\n switch (accessStatus) {\n case 'installed_active': {\n // User has access - find the BaseApplication instance\n const baseApp = this.applications$.value.find(a => UUIDsEqual(a.ID, appInfo.ID));\n return {\n status: 'accessible',\n message: 'User has access to this app',\n appName: appInfo.Name,\n appId: appInfo.ID,\n app: baseApp\n };\n }\n\n case 'not_authorized':\n return {\n status: 'not_authorized',\n message: `You do not have the required role to access \"${appInfo.Name}\".`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: false\n };\n\n case 'installed_inactive':\n return {\n status: 'disabled',\n message: `You have disabled \"${appInfo.Name}\" in your app configuration.`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: true\n };\n\n case 'not_installed':\n default:\n return {\n status: 'not_installed',\n message: `You don't have \"${appInfo.Name}\" installed.`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: true\n };\n }\n }\n\n /**\n * Install an application for the current user by creating a UserApplication record.\n * Delegates to UserInfoEngine for the actual installation.\n * Returns the newly created UserApplication entity.\n */\n async InstallAppForUser(appId: string): Promise<MJUserApplicationEntity | null> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh,\n // which our subscribeToEngineChanges() handler will pick up and call syncFromEngine()\n return await engine.InstallApplication(appId);\n }\n\n /**\n * Enable an existing but disabled UserApplication record.\n * Delegates to UserInfoEngine for the actual enabling.\n * Sync happens automatically via DataChange$ subscription.\n */\n async EnableAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh\n return await engine.EnableApplication(appId);\n }\n\n /**\n * Disable an application for the current user.\n * Delegates to UserInfoEngine for the actual disabling.\n * Sync happens automatically via DataChange$ subscription.\n */\n async DisableAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh\n return await engine.DisableApplication(appId);\n }\n\n /**\n * Uninstall an application for the current user.\n * Delegates to UserInfoEngine for the actual uninstallation.\n * Sync happens automatically via DataChange$ subscription.\n */\n async UninstallAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity delete triggers a refresh\n return await engine.UninstallApplication(appId);\n }\n}\n\n/**\n * Result of checking a user's access to an application\n */\nexport interface AppAccessResult {\n /** Status of the access check */\n status: 'accessible' | 'not_found' | 'inactive' | 'not_installed' | 'disabled' | 'not_authorized';\n /** Human-readable message describing the access status */\n message: string;\n /** Name of the application (if found) */\n appName: string;\n /** ID of the application (if found) */\n appId?: string;\n /** The BaseApplication instance (if accessible) */\n app?: BaseApplication;\n /** Whether the user can install/enable this app */\n canInstall?: boolean;\n}\n"]}
1
+ {"version":3,"file":"application-manager.js","sourceRoot":"","sources":["../../src/lib/application-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAc,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAmB,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAqB,MAAM,sBAAsB,CAAC;AACzH,OAAO,EAA2B,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;;AAYrD;;;;;;GAMG;AAIH,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAC,kBAAkB,GAAG,KAAK,CAAC;IAClC,aAAa,GAAG,IAAI,eAAe,CAAoB,EAAE,CAAC,CAAC;IAC3D,gBAAgB,GAAG,IAAI,eAAe,CAAoB,EAAE,CAAC,CAAC;IAC9D,eAAe,GAAG,IAAI,eAAe,CAAkB,EAAE,CAAC,CAAC;IAC3D,UAAU,GAAG,IAAI,eAAe,CAAyB,IAAI,CAAC,CAAC;IAC/D,QAAQ,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC,CAA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BAAkB;cAH9B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { MJGlobal, MJEventType, UUIDsEqual } from '@memberjunction/global';\nimport { Metadata, ApplicationInfo, LogError, LogStatus, StartupManager, IMetadataProvider } from '@memberjunction/core';\nimport { MJUserApplicationEntity, UserInfoEngine } from '@memberjunction/core-entities';\nimport { BaseApplication } from './base-application';\n\n/**\n * Represents a user's application configuration including visibility and order\n */\nexport interface UserAppConfig {\n app: BaseApplication;\n userAppId: string;\n sequence: number;\n isActive: boolean;\n}\n\n/**\n * Manages application instances and active application state.\n *\n * Loads applications filtered by the user's UserApplication records.\n * If user has no UserApplication records, auto-creates them from DefaultForNewUser apps.\n * Orders applications by UserApplication.Sequence.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class ApplicationManager {\n private static _recoveryAttempted = false;\n private applications$ = new BehaviorSubject<BaseApplication[]>([]);\n private allApplications$ = new BehaviorSubject<BaseApplication[]>([]);\n private userAppConfigs$ = new BehaviorSubject<UserAppConfig[]>([]);\n private activeApp$ = new BehaviorSubject<BaseApplication | null>(null);\n private loading$ = new BehaviorSubject<boolean>(false);\n private initialized = false;\n\n /** Resolves when loadApplications() has completed successfully */\n private _readyResolve!: () => void;\n private _readyPromise = new Promise<void>(resolve => { this._readyResolve = resolve; });\n\n /**\n * Returns a promise that resolves when applications have been loaded and the manager is ready.\n * Safe to call multiple times — returns the same promise.\n */\n WhenReady(): Promise<void> {\n return this._readyPromise;\n }\n\n /**\n * Observable of user's active applications (filtered and ordered by UserApplication)\n */\n get Applications(): Observable<BaseApplication[]> {\n return this.applications$.asObservable();\n }\n\n /**\n * Observable of ALL applications in the system (unfiltered)\n */\n get AllApplications(): Observable<BaseApplication[]> {\n return this.allApplications$.asObservable();\n }\n\n /**\n * Observable of user's application configurations (includes sequence, isActive)\n */\n get UserAppConfigs(): Observable<UserAppConfig[]> {\n return this.userAppConfigs$.asObservable();\n }\n\n /**\n * Observable of the currently active application\n */\n get ActiveApp(): Observable<BaseApplication | null> {\n return this.activeApp$.asObservable();\n }\n\n /**\n * Observable of loading state\n */\n get Loading(): Observable<boolean> {\n return this.loading$.asObservable();\n }\n\n /**\n * Get user's active applications synchronously (filtered and ordered)\n */\n GetAllApps(): BaseApplication[] {\n return this.applications$.value;\n }\n\n /**\n * Get ALL applications synchronously (unfiltered)\n */\n GetAllSystemApps(): BaseApplication[] {\n return this.allApplications$.value;\n }\n\n /**\n * Get all applications the current user's roles grant access to.\n * Filters out apps where ApplicationRole records exist but the user's roles lack CanAccess.\n */\n GetAuthorizedSystemApps(): BaseApplication[] {\n const engine = UserInfoEngine.Instance;\n return this.allApplications$.value.filter(app => engine.UserHasApplicationAccess(app.ID));\n }\n\n /**\n * Get user's application configurations synchronously\n */\n GetUserAppConfigs(): UserAppConfig[] {\n return this.userAppConfigs$.value;\n }\n\n /**\n * Get active application synchronously\n */\n GetActiveApp(): BaseApplication | null {\n return this.activeApp$.value;\n }\n\n /**\n * Optional explicit metadata provider. When set, all provider lookups\n * use this instead of falling back to `Metadata.Provider`. This is the\n * threading point for multi-provider Angular apps — the shell calls\n * `setProvider(this.ProviderToUse)` after the manager is acquired from DI.\n */\n private _provider: IMetadataProvider | null = null;\n\n public set Provider(value: IMetadataProvider | null) {\n this._provider = value;\n }\n\n public get Provider(): IMetadataProvider {\n return this._provider ?? Metadata.Provider;\n }\n\n constructor() {\n this.Initialize();\n }\n\n /**\n * Initialize the application manager by subscribing to the LoggedIn event.\n * Applications are loaded when the event fires, ensuring metadata is ready.\n * Also subscribes to UserInfoEngine data changes to auto-sync when user apps change.\n */\n Initialize(): void {\n if (this.initialized) {\n return;\n }\n\n // Subscribe with replay (true) to catch the event even if it already fired\n MJGlobal.Instance.GetEventListener(true).subscribe(async (event) => {\n if (event.event === MJEventType.LoggedIn) {\n await StartupManager.Instance.Startup() // make sure this is done\n this.loadApplications();\n this.subscribeToEngineChanges();\n }\n });\n }\n\n /**\n * Subscribe to UserInfoEngine data changes to automatically sync our observables\n * when UserApplication records are modified.\n *\n * Match on EntityName (the stable public identifier) rather than PropertyName —\n * PropertyName is the engine's internal backing-field name (e.g. `_UserApplications`\n * with an underscore prefix), which is an implementation detail that has bitten\n * consumers before. EntityName is the documented contract on every config and\n * never changes shape.\n */\n private subscribeToEngineChanges(): void {\n const engine = UserInfoEngine.Instance;\n engine.DataChange$.subscribe(event => {\n // When UserApplications data changes in the engine, sync our observables\n if (event.config.EntityName?.trim().toLowerCase() === 'mj: user applications') {\n this.syncFromEngine();\n }\n });\n }\n\n /**\n * Sync our BehaviorSubjects with the current data from UserInfoEngine.\n * Called when the engine emits a data change event for UserApplications.\n */\n private syncFromEngine(): void {\n const allApps = this.allApplications$.value;\n const engine = UserInfoEngine.Instance;\n const userApps = engine.UserApplications;\n\n // Build a map for quick lookup\n const appMap = new Map<string, BaseApplication>();\n for (const app of allApps) {\n appMap.set(app.ID, app);\n }\n\n // Build user's filtered and ordered app list\n const userAppConfigs: UserAppConfig[] = [];\n const activeApps: BaseApplication[] = [];\n\n for (const userApp of userApps) {\n const app = appMap.get(userApp.ApplicationID);\n if (app && userApp.IsActive && engine.UserHasApplicationAccess(userApp.ApplicationID)) {\n userAppConfigs.push({\n app,\n userAppId: userApp.ID,\n sequence: userApp.Sequence,\n isActive: userApp.IsActive\n });\n activeApps.push(app);\n }\n }\n\n this.userAppConfigs$.next(userAppConfigs);\n this.applications$.next(activeApps);\n }\n\n /**\n * Reload the user's application configuration.\n * Call this after changes to UserApplication records to refresh the app list.\n *\n * Reads engine.UserApplications and rebuilds our derived observables. The engine's\n * own event-driven refresh (via subscribeToEngineChanges + the UserApplications\n * config's short DebounceTime) keeps the underlying data fresh — we no longer need\n * a synchronous force-refresh here, which previously triggered NG0100 in callers\n * with `@if`/`@for` bindings whose values mutate during their save loop.\n */\n async ReloadUserApplications(): Promise<void> {\n this.loading$.next(true);\n\n try {\n await this.loadUserApplicationConfig();\n } finally {\n this.loading$.next(false);\n }\n }\n\n /**\n * Load applications from metadata, filtered and ordered by user's UserApplication records.\n * If user has no UserApplication records, auto-creates them from DefaultForNewUser apps.\n */\n private async loadApplications(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n this.loading$.next(true);\n\n try {\n const md = this.Provider;\n const appInfoList: ApplicationInfo[] = md.Applications;\n\n // First, create BaseApplication instances for ALL apps\n const allApps: BaseApplication[] = [];\n\n for (const appInfo of appInfoList) {\n // Only create instances for Active applications\n if (appInfo.Status !== 'Active') {\n continue;\n }\n\n const args = {\n ID: appInfo.ID,\n Name: appInfo.Name,\n Description: appInfo.Description || '',\n Icon: appInfo.Icon || '',\n Color: appInfo.Color,\n DefaultNavItems: appInfo.DefaultNavItems,\n ClassName: appInfo.ClassName,\n DefaultSequence: appInfo.DefaultSequence,\n Status: appInfo.Status,\n NavigationStyle: appInfo.NavigationStyle,\n TopNavLocation: appInfo.TopNavLocation,\n HideNavBarIconWhenActive: appInfo.HideNavBarIconWhenActive,\n Path: appInfo.Path || '',\n AutoUpdatePath: appInfo.AutoUpdatePath\n };\n\n let app: BaseApplication | null;\n if (appInfo.ClassName && appInfo.ClassName.trim().length > 0) {\n app = await MJGlobal.Instance.ClassFactory.CreateInstanceAsync<BaseApplication>(\n BaseApplication,\n appInfo.ClassName,\n args\n );\n }\n else {\n // no class provided in app definition.\n app = new BaseApplication(args)\n }\n\n if (app) {\n // should always get here unless failure to load registered sub-class but CreateInstance has\n // fallback to base class anyway so should always get here\n if (this._provider) {\n app.Provider = this._provider;\n }\n allApps.push(app);\n }\n }\n\n this.allApplications$.next(allApps);\n\n // Load and apply user's app configuration\n await this.loadUserApplicationConfig();\n\n // Recovery check: if no active apps but metadata has Active applications,\n // the engine may have failed to load UserApplications (e.g., cache corruption).\n // Attempt one recovery by force-refreshing UserInfoEngine before giving up.\n const activeApps = this.applications$.value;\n const hasMetadataApps = md.Applications.some(a => a.Status === 'Active');\n if (activeApps.length === 0 && hasMetadataApps && !ApplicationManager._recoveryAttempted) {\n ApplicationManager._recoveryAttempted = true;\n const activeAppCount = md.Applications.filter(a => a.Status === 'Active').length;\n const engineHealthy = UserInfoEngine.Instance.AllPropertiesLoadedSuccessfully;\n const userAppCount = UserInfoEngine.Instance.UserApplications?.length ?? 0;\n LogStatus(\n `ApplicationManager: Recovery triggered — ` +\n `activeApps=0, metadataActiveApps=${activeAppCount}, ` +\n `engineHealthy=${engineHealthy}, userAppRecords=${userAppCount}`\n );\n await this.attemptRecovery();\n }\n\n this.initialized = true;\n this._readyResolve();\n\n } catch (error) {\n // Resolve even on failure so waiters don't hang forever — they'll see initialized=false\n this._readyResolve();\n LogError('Failed to load applications:', undefined, error instanceof Error ? error.message : String(error));\n throw error;\n } finally {\n this.loading$.next(false);\n }\n }\n\n /**\n * Load user's UserApplication records and update the filtered/ordered app list.\n * This can be called to refresh after configuration changes.\n */\n private async loadUserApplicationConfig(): Promise<void> {\n const md = this.Provider;\n const allApps = this.allApplications$.value;\n\n // Build a map for quick lookup\n const appMap = new Map<string, BaseApplication>();\n for (const app of allApps) {\n appMap.set(app.ID, app);\n }\n\n // Load user's UserApplication records using UserInfoEngine for caching\n const engine = UserInfoEngine.Instance;\n\n let userApps: MJUserApplicationEntity[] = engine.UserApplications;\n\n // Self-healing: If user has no UserApplication records, create from DefaultForNewUser apps\n if (userApps.length === 0) {\n LogStatus(`User ${md.CurrentUser.Name} has no UserApplication records, creating from DefaultForNewUser apps`);\n userApps = await this.createDefaultUserApplications();\n }\n\n // Build user's filtered and ordered app list\n const userAppConfigs: UserAppConfig[] = [];\n const activeApps: BaseApplication[] = [];\n\n for (const userApp of userApps) {\n const app = appMap.get(userApp.ApplicationID);\n if (app && userApp.IsActive && engine.UserHasApplicationAccess(userApp.ApplicationID)) {\n userAppConfigs.push({\n app,\n userAppId: userApp.ID,\n sequence: userApp.Sequence,\n isActive: userApp.IsActive\n });\n activeApps.push(app);\n }\n }\n\n this.userAppConfigs$.next(userAppConfigs);\n this.applications$.next(activeApps);\n }\n\n /**\n * Creates UserApplication records for apps with DefaultForNewUser=true and Status='Active'.\n * Called when a user has no existing UserApplication records (self-healing).\n * Delegates to UserInfoEngine for the actual creation.\n */\n private async createDefaultUserApplications(): Promise<MJUserApplicationEntity[]> {\n const engine = UserInfoEngine.Instance;\n return await engine.CreateDefaultApplications();\n }\n\n /**\n * One-shot recovery attempt when the initial load produces zero apps despite\n * Active applications existing in metadata. Force-refreshes UserInfoEngine\n * to bypass any corrupted cache, then re-runs the user app configuration\n * (which includes the self-healing path for new users).\n */\n private async attemptRecovery(): Promise<void> {\n try {\n const engine = UserInfoEngine.Instance;\n await engine.Config(true);\n await this.loadUserApplicationConfig();\n\n const recoveredCount = this.applications$.value.length;\n const engineHealthy = engine.AllPropertiesLoadedSuccessfully;\n if (recoveredCount > 0) {\n LogStatus(`ApplicationManager: Recovery succeeded — ${recoveredCount} apps loaded, engineHealthy=${engineHealthy}`);\n } else {\n LogError(`ApplicationManager: Recovery completed but still 0 apps — engineHealthy=${engineHealthy}`);\n }\n } catch (error) {\n LogError('ApplicationManager: Recovery attempt failed:', undefined, error instanceof Error ? error.message : String(error));\n }\n }\n\n /**\n * Set the active application by ID\n */\n async SetActiveApp(appId: string): Promise<void> {\n const currentApp = this.activeApp$.value;\n const newApp = this.applications$.value.find(a => UUIDsEqual(a.ID, appId));\n\n if (!newApp) {\n return;\n }\n\n if (UUIDsEqual(currentApp?.ID, appId)) {\n return; // Already active\n }\n\n // Deactivate current app\n if (currentApp) {\n await currentApp.OnDeactivate();\n }\n\n // Activate new app\n await newApp.OnActivate();\n this.activeApp$.next(newApp);\n }\n\n /**\n * Get application by ID\n */\n GetAppById(appId: string): BaseApplication | undefined {\n return this.applications$.value.find(a => UUIDsEqual(a.ID, appId));\n }\n\n /**\n * Get application by name\n */\n GetAppByName(name: string): BaseApplication | undefined {\n return this.applications$.value.find(a => a.Name === name);\n }\n\n /**\n * Get application by URL path slug.\n * Matches case-insensitively against the app's Path property.\n * Falls back to Name match if Path is not found (for backwards compatibility).\n */\n GetAppByPath(path: string): BaseApplication | undefined {\n const normalizedPath = path.trim().toLowerCase();\n\n // First try exact path match\n const pathMatch = this.applications$.value.find(a =>\n a.Path?.toLowerCase() === normalizedPath\n );\n\n if (pathMatch) {\n return pathMatch;\n }\n\n // Fallback: try matching by name (for backwards compatibility with old URLs)\n return this.applications$.value.find(a =>\n a.Name.trim().toLowerCase() === normalizedPath\n );\n }\n\n /**\n * Get applications that should appear in the Nav Bar (NavigationStyle = 'Nav Bar' or 'Both')\n * filtered by TopNavLocation.\n */\n GetNavBarApps(location: 'Left of App Switcher' | 'Left of User Menu'): BaseApplication[] {\n return this.applications$.value.filter(app =>\n (app.NavigationStyle === 'Nav Bar' || app.NavigationStyle === 'Both') &&\n app.TopNavLocation === location\n );\n }\n\n /**\n * Get applications that should appear in the App Switcher (NavigationStyle = 'App Switcher' or 'Both')\n */\n GetAppSwitcherApps(): BaseApplication[] {\n return this.applications$.value.filter(app =>\n app.NavigationStyle === 'App Switcher' || app.NavigationStyle === 'Both'\n );\n }\n\n /**\n * Check if an app exists in the system by path or name (case-insensitive).\n * Returns the app from allApplications$ if found, regardless of user access.\n */\n GetSystemAppByPath(path: string): BaseApplication | undefined {\n const normalizedPath = path.trim().toLowerCase();\n\n // First try exact path match\n const pathMatch = this.allApplications$.value.find(a =>\n a.Path?.toLowerCase() === normalizedPath\n );\n\n if (pathMatch) {\n return pathMatch;\n }\n\n // Fallback: try matching by name\n return this.allApplications$.value.find(a =>\n a.Name.trim().toLowerCase() === normalizedPath\n );\n }\n\n /**\n * Check if a system app is inactive (Status !== 'Active').\n * Delegates to UserInfoEngine for the metadata lookup.\n */\n IsAppInactive(path: string): boolean {\n const engine = UserInfoEngine.Instance;\n const appInfo = engine.FindApplicationByPathOrName(path);\n return appInfo != null && engine.IsApplicationInactive(appInfo.ID);\n }\n\n /**\n * Determine why a user cannot access an app by its URL path.\n * Uses UserInfoEngine for core access checking logic.\n * Returns detailed access information for error handling.\n */\n CheckAppAccess(path: string): AppAccessResult {\n const engine = UserInfoEngine.Instance;\n\n // Step 1: Check if app exists in metadata at all\n const appInfo = engine.FindApplicationByPathOrName(path);\n\n if (!appInfo) {\n return {\n status: 'not_found',\n message: `The application \"${path}\" does not exist.`,\n appName: path\n };\n }\n\n // Step 2: Check if app is inactive\n if (engine.IsApplicationInactive(appInfo.ID)) {\n return {\n status: 'inactive',\n message: `The application \"${appInfo.Name}\" is currently inactive.`,\n appName: appInfo.Name,\n appId: appInfo.ID\n };\n }\n\n // Step 3: Check user's access status via engine\n const accessStatus = engine.CheckUserApplicationAccess(appInfo.ID);\n\n switch (accessStatus) {\n case 'installed_active': {\n // User has access - find the BaseApplication instance\n const baseApp = this.applications$.value.find(a => UUIDsEqual(a.ID, appInfo.ID));\n return {\n status: 'accessible',\n message: 'User has access to this app',\n appName: appInfo.Name,\n appId: appInfo.ID,\n app: baseApp\n };\n }\n\n case 'not_authorized':\n return {\n status: 'not_authorized',\n message: `You do not have the required role to access \"${appInfo.Name}\".`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: false\n };\n\n case 'installed_inactive':\n return {\n status: 'disabled',\n message: `You have disabled \"${appInfo.Name}\" in your app configuration.`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: true\n };\n\n case 'not_installed':\n default:\n return {\n status: 'not_installed',\n message: `You don't have \"${appInfo.Name}\" installed.`,\n appName: appInfo.Name,\n appId: appInfo.ID,\n canInstall: true\n };\n }\n }\n\n /**\n * Install an application for the current user by creating a UserApplication record.\n * Delegates to UserInfoEngine for the actual installation.\n * Returns the newly created UserApplication entity.\n */\n async InstallAppForUser(appId: string): Promise<MJUserApplicationEntity | null> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh,\n // which our subscribeToEngineChanges() handler will pick up and call syncFromEngine()\n return await engine.InstallApplication(appId);\n }\n\n /**\n * Enable an existing but disabled UserApplication record.\n * Delegates to UserInfoEngine for the actual enabling.\n * Sync happens automatically via DataChange$ subscription.\n */\n async EnableAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh\n return await engine.EnableApplication(appId);\n }\n\n /**\n * Disable an application for the current user.\n * Delegates to UserInfoEngine for the actual disabling.\n * Sync happens automatically via DataChange$ subscription.\n */\n async DisableAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity save triggers a refresh\n return await engine.DisableApplication(appId);\n }\n\n /**\n * Uninstall an application for the current user.\n * Delegates to UserInfoEngine for the actual uninstallation.\n * Sync happens automatically via DataChange$ subscription.\n */\n async UninstallAppForUser(appId: string): Promise<boolean> {\n const engine = UserInfoEngine.Instance;\n // The engine will emit DataChange$ after the entity delete triggers a refresh\n return await engine.UninstallApplication(appId);\n }\n}\n\n/**\n * Result of checking a user's access to an application\n */\nexport interface AppAccessResult {\n /** Status of the access check */\n status: 'accessible' | 'not_found' | 'inactive' | 'not_installed' | 'disabled' | 'not_authorized';\n /** Human-readable message describing the access status */\n message: string;\n /** Name of the application (if found) */\n appName: string;\n /** ID of the application (if found) */\n appId?: string;\n /** The BaseApplication instance (if accessible) */\n app?: BaseApplication;\n /** Whether the user can install/enable this app */\n canInstall?: boolean;\n}\n"]}
@@ -63,6 +63,12 @@ export interface LayoutChangedEvent {
63
63
  export declare class GoldenLayoutManager {
64
64
  private layout;
65
65
  private containerElement;
66
+ /**
67
+ * True when Golden Layout has been initialized and not yet destroyed.
68
+ * Use this from external callers (e.g. tab-container) to avoid issuing
69
+ * AddTab/RemoveTab against a torn-down layout.
70
+ */
71
+ get IsInitialized(): boolean;
66
72
  private tabShown$;
67
73
  private tabClosed$;
68
74
  private layoutChanged$;
@@ -1 +1 @@
1
- {"version":3,"file":"golden-layout-manager.d.ts","sourceRoot":"","sources":["../../src/lib/golden-layout-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,UAAU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AI;IAiBtE;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO;IAqBlD;;OAEG;IACH,UAAU,IAAI,qBAAqB;IASnC;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAI7D;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAInC;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIlC;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACH,YAAY,IAAI,MAAM,EAAE;IAIxB;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAqDlC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAIpC;;OAEG;IACH,OAAO,CAAC,cAAc;IA0EtB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAW3B;;OAEG;IACH,OAAO,CAAC,cAAc;IAmBtB;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAenC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA4C1B;;OAEG;IACH,OAAO,CAAC,6BAA6B;yCA/iB1B,mBAAmB;6CAAnB,mBAAmB;CAojB/B"}
@@ -16,6 +16,14 @@ import * as i0 from "@angular/core";
16
16
  export class GoldenLayoutManager {
17
17
  layout = null;
18
18
  containerElement = null;
19
+ /**
20
+ * True when Golden Layout has been initialized and not yet destroyed.
21
+ * Use this from external callers (e.g. tab-container) to avoid issuing
22
+ * AddTab/RemoveTab against a torn-down layout.
23
+ */
24
+ get IsInitialized() {
25
+ return this.layout !== null;
26
+ }
19
27
  // Event subjects
20
28
  tabShown$ = new Subject();
21
29
  tabClosed$ = new Subject();
@@ -1 +1 @@
1
- {"version":3,"file":"golden-layout-manager.js","sourceRoot":"","sources":["../../src/lib/golden-layout-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3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IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YACtB,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrF,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACK,6BAA6B,CAAC,QAAgC;QACpE,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAA6B;SAC7C,CAAC;IACJ,CAAC;6GA1iBU,mBAAmB;gEAAnB,mBAAmB,WAAnB,mBAAmB,mBAFlB,MAAM;;iFAEP,mBAAmB;cAH/B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { BehaviorSubject, Observable, Subject } from 'rxjs';\nimport { LogError } from '@memberjunction/core';\nimport { VirtualLayout } from 'golden-layout';\nimport { WorkspaceConfiguration, LayoutConfig as WorkspaceLayoutConfig, LayoutNode } from './interfaces/workspace-configuration.interface';\n\n// Golden Layout interfaces - defined here to avoid compile-time dependency\n// These match the Golden Layout 2.6.0 API\ninterface GLComponentContainer {\n state: Record<string, unknown>;\n tab?: { element: HTMLElement };\n on(event: string, callback: () => void): void;\n close(): void;\n focus(): void;\n setTitle(title: string): void;\n}\n\ninterface GLVirtualLayout {\n rootItem: GLLayoutItem | null;\n on(event: string, callback: (item?: unknown) => void): void;\n destroy(): void;\n loadLayout(config: GLLayoutConfig): void;\n saveLayout(): GLResolvedLayoutConfig;\n addItemAtLocation(config: GLComponentItemConfig, location: Array<{ typeId: number }>): void;\n addComponent(componentType: string, componentState: Record<string, unknown>, title: string): void;\n setSize(width: number, height: number): void;\n}\n\ninterface GLLayoutItem {\n type: string;\n contentItems?: GLLayoutItem[];\n container?: GLComponentContainer;\n addItem(config: GLComponentItemConfig): void;\n}\n\ninterface GLLayoutConfig {\n root: GLLayoutNode;\n header?: {\n show: string;\n popout: boolean;\n maximise: boolean;\n close: string;\n };\n}\n\ninterface GLResolvedLayoutConfig {\n root: GLLayoutNode;\n}\n\ninterface GLLayoutNode {\n type: string;\n content?: GLLayoutNode[];\n componentType?: string;\n componentState?: Record<string, unknown>;\n width?: number;\n height?: number;\n isClosable?: boolean;\n title?: string;\n}\n\ninterface GLComponentItemConfig {\n type: 'component';\n componentType: string;\n componentState: Record<string, unknown>;\n title: string;\n}\n\n/**\n * State stored in each Golden Layout component\n */\nexport interface TabComponentState {\n tabId: string;\n appId: string;\n appColor: string;\n title: string;\n route: string;\n isPinned: boolean;\n isLoaded: boolean;\n}\n\n/**\n * Event emitted when a tab is shown\n */\nexport interface TabShownEvent {\n tabId: string;\n container: GLComponentContainer;\n isFirstShow: boolean;\n}\n\n/**\n * Event emitted when layout changes\n */\nexport interface LayoutChangedEvent {\n layout: GLResolvedLayoutConfig;\n}\n\n/**\n * Manages Golden Layout instance and provides Angular integration.\n *\n * Handles:\n * - Layout initialization and destruction\n * - Tab creation with app-specific styling\n * - Lazy loading of tab content\n * - Layout serialization/deserialization\n * - Tab events (show, hide, close)\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class GoldenLayoutManager {\n private layout: GLVirtualLayout | null = null;\n private containerElement: HTMLElement | null = null;\n\n // Event subjects\n private tabShown$ = new Subject<TabShownEvent>();\n private tabClosed$ = new Subject<string>();\n private layoutChanged$ = new Subject<LayoutChangedEvent>();\n private activeTab$ = new BehaviorSubject<string | null>(null);\n private tabDoubleClicked = new Subject<string>();\n private tabRightClicked = new Subject<{ tabId: string; x: number; y: number }>();\n\n // Track loaded tabs for lazy loading\n private loadedTabs = new Set<string>();\n\n // Track component containers by tab ID\n private containerMap = new Map<string, GLComponentContainer>();\n\n /**\n * Observable for tab shown events (for lazy loading)\n */\n get TabShown(): Observable<TabShownEvent> {\n return this.tabShown$.asObservable();\n }\n\n /**\n * Observable for tab closed events\n */\n get TabClosed(): Observable<string> {\n return this.tabClosed$.asObservable();\n }\n\n /**\n * Observable for layout changed events\n */\n get LayoutChanged(): Observable<LayoutChangedEvent> {\n return this.layoutChanged$.asObservable();\n }\n\n /**\n * Observable for active tab changes\n */\n get ActiveTab(): Observable<string | null> {\n return this.activeTab$.asObservable();\n }\n\n /**\n * Observable for tab double-click events (to toggle pin status)\n */\n get TabDoubleClicked(): Observable<string> {\n return this.tabDoubleClicked.asObservable();\n }\n\n /**\n * Observable for tab right-click events (to show context menu)\n */\n get TabRightClicked(): Observable<{ tabId: string; x: number; y: number }> {\n return this.tabRightClicked.asObservable();\n }\n\n /**\n * Initialize Golden Layout in the specified container element\n */\n Initialize(element: HTMLElement): void {\n this.containerElement = element;\n\n // Create layout with empty config\n const config: GLLayoutConfig = {\n root: {\n type: 'row',\n content: []\n },\n header: {\n show: 'top',\n popout: false,\n maximise: false,\n close: 'tab'\n }\n };\n\n this.layout = new VirtualLayout(\n this.containerElement,\n this.bindComponentEventListener.bind(this) as VirtualLayout.BindComponentEventHandler,\n this.unbindComponentEventListener.bind(this) as VirtualLayout.UnbindComponentEventHandler\n ) as unknown as GLVirtualLayout;\n\n // Enable automatic resize when container size changes\n // This uses Golden Layout's built-in ResizeObserver (default is false for non-body containers)\n (this.layout as unknown as { resizeWithContainerAutomatically: boolean }).resizeWithContainerAutomatically = true;\n\n // Subscribe to state changes\n this.layout.on('stateChanged', () => {\n if (this.layout) {\n this.layoutChanged$.next({\n layout: this.layout.saveLayout()\n });\n this.refreshAllTabStyles();\n }\n });\n\n this.layout.on('activeContentItemChanged', (item: unknown) => {\n const typedItem = item as { container?: { state?: TabComponentState } };\n const state = typedItem?.container?.state;\n if (state?.tabId) {\n this.activeTab$.next(state.tabId);\n }\n });\n\n // Load the empty config to establish root structure\n // This MUST be done before adding any components\n this.layout.loadLayout(config);\n\n // Configure debounce settings for faster resize response\n // Default resizeDebounceInterval is 100ms, reduce to 50ms for snappier feel\n (this.layout as unknown as { resizeDebounceInterval: number }).resizeDebounceInterval = 50;\n // Disable extended debounce - we want layout to resize during drag, not just after\n (this.layout as unknown as { resizeDebounceExtendedWhenPossible: boolean }).resizeDebounceExtendedWhenPossible = false;\n\n // CRITICAL: Set the size of Golden Layout to match the container\n // Without this, all internal elements will have height: 0\n const rect = this.containerElement.getBoundingClientRect();\n this.layout.setSize(rect.width, rect.height);\n\n // Retry setSize after delays to handle timing issues with flexbox layout\n // Initial page load can take time for container to have final dimensions\n // Use increasing delays to catch both fast and slow layout calculations\n setTimeout(() => this.updateSize(), 50);\n setTimeout(() => this.updateSize(), 150);\n setTimeout(() => this.updateSize(), 300);\n }\n\n /**\n * Update layout size to match container.\n * Call this if the layout appears incorrectly sized.\n * This is useful for handling flexbox timing issues on page load\n * or when the container size changes due to external factors.\n */\n updateSize(): void {\n if (this.layout && this.containerElement) {\n const rect = this.containerElement.getBoundingClientRect();\n if (rect.width > 0 && rect.height > 0) {\n this.layout.setSize(rect.width, rect.height);\n }\n }\n }\n\n /**\n * Destroy the Golden Layout instance\n */\n Destroy(): void {\n if (this.layout) {\n this.layout.destroy();\n this.layout = null;\n }\n this.containerMap.clear();\n this.loadedTabs.clear();\n }\n\n /**\n * Add a new tab to the layout\n * Adds to existing stack if one exists, otherwise creates new stack\n */\n AddTab(state: TabComponentState): void {\n if (!this.layout) {\n LogError('GoldenLayoutManager: Layout not initialized');\n return;\n }\n\n try {\n // First, check if there's an existing stack to add to\n const existingStack = this.findFirstStack();\n\n if (existingStack) {\n // Add to existing stack (creates tabbed interface)\n const componentConfig: GLComponentItemConfig = {\n type: 'component',\n componentType: 'tab-content',\n componentState: state as unknown as Record<string, unknown>,\n title: state.title\n };\n existingStack.addItem(componentConfig);\n } else {\n // No existing stack - use addComponent which will create one\n this.layout.addComponent(\n 'tab-content', // componentType\n state as unknown as Record<string, unknown>, // componentState\n state.title // title\n );\n }\n } catch (error) {\n LogError('GoldenLayoutManager: Failed to add tab - ' + (error as Error).message);\n }\n }\n\n /**\n * Remove a tab from the layout\n */\n RemoveTab(tabId: string): void {\n const container = this.containerMap.get(tabId);\n if (container) {\n container.close();\n }\n }\n\n /**\n * Focus a tab by ID\n */\n FocusTab(tabId: string): void {\n const container = this.containerMap.get(tabId);\n if (container) {\n container.focus();\n }\n }\n\n /**\n * Update tab style (pin state, title, etc.)\n */\n UpdateTabStyle(tabId: string, state: Partial<TabComponentState>): void {\n const container = this.containerMap.get(tabId);\n if (!container) return;\n\n // Update state\n const currentState = container.state as unknown as TabComponentState;\n Object.assign(currentState, state);\n\n // Update title if changed\n if (state.title) {\n container.setTitle(state.title);\n }\n\n // Apply visual styles\n this.applyTabStyles(container, currentState);\n }\n\n /**\n * Load layout from configuration\n * @returns true if layout was loaded successfully, false if it failed\n */\n LoadLayout(config: WorkspaceLayoutConfig): boolean {\n if (!this.layout) {\n LogError('GoldenLayoutManager: Layout not initialized');\n return false;\n }\n\n // Don't load empty or invalid layouts - Golden Layout doesn't handle them well\n if (!config || !config.root || !config.root.content || config.root.content.length === 0) {\n return false;\n }\n\n try {\n const glConfig = this.convertToGoldenLayoutConfig(config);\n this.layout.loadLayout(glConfig);\n return true;\n } catch (error) {\n LogError('GoldenLayoutManager: Failed to load layout - ' + (error as Error).message);\n return false;\n }\n }\n\n /**\n * Save current layout to configuration format\n */\n SaveLayout(): WorkspaceLayoutConfig {\n if (!this.layout) {\n return { root: { type: 'row', content: [] } };\n }\n\n const resolved = this.layout.saveLayout();\n return this.convertFromGoldenLayoutConfig(resolved);\n }\n\n /**\n * Get container for a tab\n */\n GetContainer(tabId: string): GLComponentContainer | undefined {\n return this.containerMap.get(tabId);\n }\n\n /**\n * Check if tab content has been loaded\n */\n IsTabLoaded(tabId: string): boolean {\n return this.loadedTabs.has(tabId);\n }\n\n /**\n * Mark tab as loaded\n */\n MarkTabLoaded(tabId: string): void {\n this.loadedTabs.add(tabId);\n }\n\n /**\n * Mark tab as not loaded (forces reload on next show)\n */\n MarkTabNotLoaded(tabId: string): void {\n this.loadedTabs.delete(tabId);\n }\n\n /**\n * Get all tab IDs currently in the layout\n */\n GetAllTabIds(): string[] {\n return Array.from(this.containerMap.keys());\n }\n\n /**\n * Bind component event listener (called by Golden Layout)\n */\n private bindComponentEventListener(\n container: GLComponentContainer,\n itemConfig: { componentState: Record<string, unknown> }\n ): { component: HTMLElement; virtual: boolean } {\n const state = container.state as unknown as TabComponentState;\n\n // Create a simple div element for tab content\n const element = document.createElement('div');\n element.className = 'tab-content-container';\n element.style.width = '100%';\n element.style.height = '100%';\n element.style.overflow = 'hidden';\n element.style.padding = '0';\n\n // Temporary placeholder content\n element.innerHTML = `\n <h2>${state?.title || 'Tab Content'}</h2>\n <p>Tab ID: ${state?.tabId || 'unknown'}</p>\n <p>Route: ${state?.route || 'none'}</p>\n <p>App ID: ${state?.appId || 'none'}</p>\n `;\n\n if (state?.tabId) {\n this.containerMap.set(state.tabId, container);\n\n // Apply initial styles\n this.applyTabStyles(container, state);\n\n // Listen for show events\n container.on('show', () => {\n const isFirstShow = !this.loadedTabs.has(state.tabId);\n this.tabShown$.next({\n tabId: state.tabId,\n container,\n isFirstShow\n });\n });\n\n // Listen for close events\n container.on('beforeComponentRelease', () => {\n this.containerMap.delete(state.tabId);\n this.loadedTabs.delete(state.tabId);\n this.tabClosed$.next(state.tabId);\n });\n }\n\n // CRITICAL: Return the bindable component object\n return {\n component: element,\n virtual: false // false means actual DOM content\n };\n }\n\n /**\n * Unbind component event listener (called by Golden Layout)\n */\n private unbindComponentEventListener(container: GLComponentContainer): void {\n // Cleanup handled in beforeComponentRelease\n }\n\n /**\n * Apply visual styles to a tab\n */\n private applyTabStyles(container: GLComponentContainer, state: TabComponentState): void {\n const tabElement = container.tab?.element;\n if (!tabElement) return;\n\n // Set app color CSS variable\n tabElement.style.setProperty('--app-color', state.appColor);\n\n // Add/remove pinned class\n if (state.isPinned) {\n tabElement.classList.add('pinned');\n } else {\n tabElement.classList.remove('pinned');\n }\n\n // Set italic font for temporary tabs\n const titleElement = tabElement.querySelector('.lm_title') as HTMLElement;\n if (titleElement) {\n titleElement.style.fontStyle = state.isPinned ? 'normal' : 'italic';\n }\n\n // Add event listeners if not already added (use data attribute to track)\n if (!tabElement.hasAttribute('data-events-attached')) {\n tabElement.setAttribute('data-events-attached', 'true');\n\n // Double-click to toggle pin\n tabElement.addEventListener('dblclick', (e: Event) => {\n e.stopPropagation();\n this.tabDoubleClicked.next(state.tabId);\n });\n\n // Right-click for context menu\n tabElement.addEventListener('contextmenu', (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n this.tabRightClicked.next({ tabId: state.tabId, x: e.clientX, y: e.clientY });\n });\n }\n\n // Handle pin icon\n if (state.isPinned) {\n // Add pin icon if not present\n if (!tabElement.querySelector('.pin-icon')) {\n const pinIcon = document.createElement('i');\n pinIcon.className = 'fa-solid fa-thumbtack pin-icon';\n pinIcon.style.cssText = `\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%) rotate(45deg);\n font-size: 9px;\n color: var(--mj-text-muted);\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n `;\n // Click on pin to unpin\n pinIcon.addEventListener('click', (e) => {\n e.stopPropagation();\n this.tabDoubleClicked.next(state.tabId);\n });\n tabElement.appendChild(pinIcon);\n }\n } else {\n // Remove pin icon if present\n const pinIcon = tabElement.querySelector('.pin-icon');\n if (pinIcon) {\n pinIcon.remove();\n }\n }\n }\n\n /**\n * Refresh styles for all tabs (after drag/drop)\n */\n private refreshAllTabStyles(): void {\n setTimeout(() => {\n this.containerMap.forEach((container, tabId) => {\n const state = container.state as unknown as TabComponentState;\n if (state) {\n this.applyTabStyles(container, state);\n }\n });\n }, 50);\n }\n\n /**\n * Find first stack in layout\n */\n private findFirstStack(): GLLayoutItem | null {\n if (!this.layout || !this.layout.rootItem) return null;\n\n const findStack = (item: GLLayoutItem): GLLayoutItem | null => {\n if (item.type === 'stack') {\n return item;\n }\n if (item.contentItems) {\n for (const child of item.contentItems) {\n const found = findStack(child);\n if (found) return found;\n }\n }\n return null;\n };\n\n return findStack(this.layout.rootItem);\n }\n\n /**\n * Convert workspace layout config to Golden Layout config\n */\n private convertToGoldenLayoutConfig(config: WorkspaceLayoutConfig): GLLayoutConfig {\n // Sanitize the root node to ensure size values are valid\n const sanitizedRoot = this.sanitizeLayoutNode(config.root);\n\n return {\n root: sanitizedRoot as GLLayoutNode,\n header: {\n show: 'top',\n popout: false,\n maximise: false,\n close: 'tab'\n }\n };\n }\n\n /**\n * Sanitize a layout node to ensure all values are Golden Layout compatible\n */\n private sanitizeLayoutNode(node: LayoutNode): LayoutNode {\n const sanitized: LayoutNode = {\n ...node\n };\n\n // Cast to any to work with dynamic properties\n const sanitizedAny = sanitized as any;\n\n // Convert size from number + sizeUnit to Golden Layout format\n // Golden Layout expects strings like \"100%\" or \"1fr\", not separate fields\n if (sanitizedAny.size !== undefined && sanitizedAny.sizeUnit !== undefined) {\n if (typeof sanitizedAny.size === 'number') {\n // Combine size and sizeUnit into a single string\n sanitizedAny.size = `${sanitizedAny.size}${sanitizedAny.sizeUnit}`;\n // Remove sizeUnit as it's now part of size\n delete sanitizedAny.sizeUnit;\n }\n }\n\n // Remove width/height if they exist and are not valid\n // Golden Layout expects strings like \"50%\" or numbers (pixels)\n // But JSON parsing might give us non-string objects\n if (sanitized.width !== undefined) {\n if (typeof sanitized.width !== 'number' && typeof sanitized.width !== 'string') {\n delete sanitized.width;\n }\n }\n if (sanitized.height !== undefined) {\n if (typeof sanitized.height !== 'number' && typeof sanitized.height !== 'string') {\n delete sanitized.height;\n }\n }\n\n // Remove other Golden Layout internal fields that shouldn't be in saved config\n delete sanitizedAny.minSizeUnit;\n\n // Recursively sanitize child nodes\n if (sanitized.content) {\n sanitized.content = sanitized.content.map(child => this.sanitizeLayoutNode(child));\n }\n\n return sanitized;\n }\n\n /**\n * Convert Golden Layout config to workspace layout config\n */\n private convertFromGoldenLayoutConfig(resolved: GLResolvedLayoutConfig): WorkspaceLayoutConfig {\n return {\n root: resolved.root as unknown as LayoutNode\n };\n }\n}\n"]}
1
+ {"version":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AAS,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,SAAS,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACjF,OAAO,SAAS,CAAC,MAAM,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,+EAA+E;QAC/E,OAAO,YAAY,CAAC,WAAW,CAAC;QAEhC,mCAAmC;QACnC,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YACtB,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrF,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACK,6BAA6B,CAAC,QAAgC;QACpE,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAA6B;SAC7C,CAAC;IACJ,CAAC;6GAnjBU,mBAAmB;gEAAnB,mBAAmB,WAAnB,mBAAmB,mBAFlB,MAAM;;iFAEP,mBAAmB;cAH/B,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { BehaviorSubject, Observable, Subject } from 'rxjs';\nimport { LogError } from '@memberjunction/core';\nimport { VirtualLayout } from 'golden-layout';\nimport { WorkspaceConfiguration, LayoutConfig as WorkspaceLayoutConfig, LayoutNode } from './interfaces/workspace-configuration.interface';\n\n// Golden Layout interfaces - defined here to avoid compile-time dependency\n// These match the Golden Layout 2.6.0 API\ninterface GLComponentContainer {\n state: Record<string, unknown>;\n tab?: { element: HTMLElement };\n on(event: string, callback: () => void): void;\n close(): void;\n focus(): void;\n setTitle(title: string): void;\n}\n\ninterface GLVirtualLayout {\n rootItem: GLLayoutItem | null;\n on(event: string, callback: (item?: unknown) => void): void;\n destroy(): void;\n loadLayout(config: GLLayoutConfig): void;\n saveLayout(): GLResolvedLayoutConfig;\n addItemAtLocation(config: GLComponentItemConfig, location: Array<{ typeId: number }>): void;\n addComponent(componentType: string, componentState: Record<string, unknown>, title: string): void;\n setSize(width: number, height: number): void;\n}\n\ninterface GLLayoutItem {\n type: string;\n contentItems?: GLLayoutItem[];\n container?: GLComponentContainer;\n addItem(config: GLComponentItemConfig): void;\n}\n\ninterface GLLayoutConfig {\n root: GLLayoutNode;\n header?: {\n show: string;\n popout: boolean;\n maximise: boolean;\n close: string;\n };\n}\n\ninterface GLResolvedLayoutConfig {\n root: GLLayoutNode;\n}\n\ninterface GLLayoutNode {\n type: string;\n content?: GLLayoutNode[];\n componentType?: string;\n componentState?: Record<string, unknown>;\n width?: number;\n height?: number;\n isClosable?: boolean;\n title?: string;\n}\n\ninterface GLComponentItemConfig {\n type: 'component';\n componentType: string;\n componentState: Record<string, unknown>;\n title: string;\n}\n\n/**\n * State stored in each Golden Layout component\n */\nexport interface TabComponentState {\n tabId: string;\n appId: string;\n appColor: string;\n title: string;\n route: string;\n isPinned: boolean;\n isLoaded: boolean;\n}\n\n/**\n * Event emitted when a tab is shown\n */\nexport interface TabShownEvent {\n tabId: string;\n container: GLComponentContainer;\n isFirstShow: boolean;\n}\n\n/**\n * Event emitted when layout changes\n */\nexport interface LayoutChangedEvent {\n layout: GLResolvedLayoutConfig;\n}\n\n/**\n * Manages Golden Layout instance and provides Angular integration.\n *\n * Handles:\n * - Layout initialization and destruction\n * - Tab creation with app-specific styling\n * - Lazy loading of tab content\n * - Layout serialization/deserialization\n * - Tab events (show, hide, close)\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class GoldenLayoutManager {\n private layout: GLVirtualLayout | null = null;\n private containerElement: HTMLElement | null = null;\n\n /**\n * True when Golden Layout has been initialized and not yet destroyed.\n * Use this from external callers (e.g. tab-container) to avoid issuing\n * AddTab/RemoveTab against a torn-down layout.\n */\n public get IsInitialized(): boolean {\n return this.layout !== null;\n }\n\n // Event subjects\n private tabShown$ = new Subject<TabShownEvent>();\n private tabClosed$ = new Subject<string>();\n private layoutChanged$ = new Subject<LayoutChangedEvent>();\n private activeTab$ = new BehaviorSubject<string | null>(null);\n private tabDoubleClicked = new Subject<string>();\n private tabRightClicked = new Subject<{ tabId: string; x: number; y: number }>();\n\n // Track loaded tabs for lazy loading\n private loadedTabs = new Set<string>();\n\n // Track component containers by tab ID\n private containerMap = new Map<string, GLComponentContainer>();\n\n /**\n * Observable for tab shown events (for lazy loading)\n */\n get TabShown(): Observable<TabShownEvent> {\n return this.tabShown$.asObservable();\n }\n\n /**\n * Observable for tab closed events\n */\n get TabClosed(): Observable<string> {\n return this.tabClosed$.asObservable();\n }\n\n /**\n * Observable for layout changed events\n */\n get LayoutChanged(): Observable<LayoutChangedEvent> {\n return this.layoutChanged$.asObservable();\n }\n\n /**\n * Observable for active tab changes\n */\n get ActiveTab(): Observable<string | null> {\n return this.activeTab$.asObservable();\n }\n\n /**\n * Observable for tab double-click events (to toggle pin status)\n */\n get TabDoubleClicked(): Observable<string> {\n return this.tabDoubleClicked.asObservable();\n }\n\n /**\n * Observable for tab right-click events (to show context menu)\n */\n get TabRightClicked(): Observable<{ tabId: string; x: number; y: number }> {\n return this.tabRightClicked.asObservable();\n }\n\n /**\n * Initialize Golden Layout in the specified container element\n */\n Initialize(element: HTMLElement): void {\n this.containerElement = element;\n\n // Create layout with empty config\n const config: GLLayoutConfig = {\n root: {\n type: 'row',\n content: []\n },\n header: {\n show: 'top',\n popout: false,\n maximise: false,\n close: 'tab'\n }\n };\n\n this.layout = new VirtualLayout(\n this.containerElement,\n this.bindComponentEventListener.bind(this) as VirtualLayout.BindComponentEventHandler,\n this.unbindComponentEventListener.bind(this) as VirtualLayout.UnbindComponentEventHandler\n ) as unknown as GLVirtualLayout;\n\n // Enable automatic resize when container size changes\n // This uses Golden Layout's built-in ResizeObserver (default is false for non-body containers)\n (this.layout as unknown as { resizeWithContainerAutomatically: boolean }).resizeWithContainerAutomatically = true;\n\n // Subscribe to state changes\n this.layout.on('stateChanged', () => {\n if (this.layout) {\n this.layoutChanged$.next({\n layout: this.layout.saveLayout()\n });\n this.refreshAllTabStyles();\n }\n });\n\n this.layout.on('activeContentItemChanged', (item: unknown) => {\n const typedItem = item as { container?: { state?: TabComponentState } };\n const state = typedItem?.container?.state;\n if (state?.tabId) {\n this.activeTab$.next(state.tabId);\n }\n });\n\n // Load the empty config to establish root structure\n // This MUST be done before adding any components\n this.layout.loadLayout(config);\n\n // Configure debounce settings for faster resize response\n // Default resizeDebounceInterval is 100ms, reduce to 50ms for snappier feel\n (this.layout as unknown as { resizeDebounceInterval: number }).resizeDebounceInterval = 50;\n // Disable extended debounce - we want layout to resize during drag, not just after\n (this.layout as unknown as { resizeDebounceExtendedWhenPossible: boolean }).resizeDebounceExtendedWhenPossible = false;\n\n // CRITICAL: Set the size of Golden Layout to match the container\n // Without this, all internal elements will have height: 0\n const rect = this.containerElement.getBoundingClientRect();\n this.layout.setSize(rect.width, rect.height);\n\n // Retry setSize after delays to handle timing issues with flexbox layout\n // Initial page load can take time for container to have final dimensions\n // Use increasing delays to catch both fast and slow layout calculations\n setTimeout(() => this.updateSize(), 50);\n setTimeout(() => this.updateSize(), 150);\n setTimeout(() => this.updateSize(), 300);\n }\n\n /**\n * Update layout size to match container.\n * Call this if the layout appears incorrectly sized.\n * This is useful for handling flexbox timing issues on page load\n * or when the container size changes due to external factors.\n */\n updateSize(): void {\n if (this.layout && this.containerElement) {\n const rect = this.containerElement.getBoundingClientRect();\n if (rect.width > 0 && rect.height > 0) {\n this.layout.setSize(rect.width, rect.height);\n }\n }\n }\n\n /**\n * Destroy the Golden Layout instance\n */\n Destroy(): void {\n if (this.layout) {\n this.layout.destroy();\n this.layout = null;\n }\n this.containerMap.clear();\n this.loadedTabs.clear();\n }\n\n /**\n * Add a new tab to the layout\n * Adds to existing stack if one exists, otherwise creates new stack\n */\n AddTab(state: TabComponentState): void {\n if (!this.layout) {\n LogError('GoldenLayoutManager: Layout not initialized');\n return;\n }\n\n try {\n // First, check if there's an existing stack to add to\n const existingStack = this.findFirstStack();\n\n if (existingStack) {\n // Add to existing stack (creates tabbed interface)\n const componentConfig: GLComponentItemConfig = {\n type: 'component',\n componentType: 'tab-content',\n componentState: state as unknown as Record<string, unknown>,\n title: state.title\n };\n existingStack.addItem(componentConfig);\n } else {\n // No existing stack - use addComponent which will create one\n this.layout.addComponent(\n 'tab-content', // componentType\n state as unknown as Record<string, unknown>, // componentState\n state.title // title\n );\n }\n } catch (error) {\n LogError('GoldenLayoutManager: Failed to add tab - ' + (error as Error).message);\n }\n }\n\n /**\n * Remove a tab from the layout\n */\n RemoveTab(tabId: string): void {\n const container = this.containerMap.get(tabId);\n if (container) {\n container.close();\n }\n }\n\n /**\n * Focus a tab by ID\n */\n FocusTab(tabId: string): void {\n const container = this.containerMap.get(tabId);\n if (container) {\n container.focus();\n }\n }\n\n /**\n * Update tab style (pin state, title, etc.)\n */\n UpdateTabStyle(tabId: string, state: Partial<TabComponentState>): void {\n const container = this.containerMap.get(tabId);\n if (!container) return;\n\n // Update state\n const currentState = container.state as unknown as TabComponentState;\n Object.assign(currentState, state);\n\n // Update title if changed\n if (state.title) {\n container.setTitle(state.title);\n }\n\n // Apply visual styles\n this.applyTabStyles(container, currentState);\n }\n\n /**\n * Load layout from configuration\n * @returns true if layout was loaded successfully, false if it failed\n */\n LoadLayout(config: WorkspaceLayoutConfig): boolean {\n if (!this.layout) {\n LogError('GoldenLayoutManager: Layout not initialized');\n return false;\n }\n\n // Don't load empty or invalid layouts - Golden Layout doesn't handle them well\n if (!config || !config.root || !config.root.content || config.root.content.length === 0) {\n return false;\n }\n\n try {\n const glConfig = this.convertToGoldenLayoutConfig(config);\n this.layout.loadLayout(glConfig);\n return true;\n } catch (error) {\n LogError('GoldenLayoutManager: Failed to load layout - ' + (error as Error).message);\n return false;\n }\n }\n\n /**\n * Save current layout to configuration format\n */\n SaveLayout(): WorkspaceLayoutConfig {\n if (!this.layout) {\n return { root: { type: 'row', content: [] } };\n }\n\n const resolved = this.layout.saveLayout();\n return this.convertFromGoldenLayoutConfig(resolved);\n }\n\n /**\n * Get container for a tab\n */\n GetContainer(tabId: string): GLComponentContainer | undefined {\n return this.containerMap.get(tabId);\n }\n\n /**\n * Check if tab content has been loaded\n */\n IsTabLoaded(tabId: string): boolean {\n return this.loadedTabs.has(tabId);\n }\n\n /**\n * Mark tab as loaded\n */\n MarkTabLoaded(tabId: string): void {\n this.loadedTabs.add(tabId);\n }\n\n /**\n * Mark tab as not loaded (forces reload on next show)\n */\n MarkTabNotLoaded(tabId: string): void {\n this.loadedTabs.delete(tabId);\n }\n\n /**\n * Get all tab IDs currently in the layout\n */\n GetAllTabIds(): string[] {\n return Array.from(this.containerMap.keys());\n }\n\n /**\n * Bind component event listener (called by Golden Layout)\n */\n private bindComponentEventListener(\n container: GLComponentContainer,\n itemConfig: { componentState: Record<string, unknown> }\n ): { component: HTMLElement; virtual: boolean } {\n const state = container.state as unknown as TabComponentState;\n\n // Create a simple div element for tab content\n const element = document.createElement('div');\n element.className = 'tab-content-container';\n element.style.width = '100%';\n element.style.height = '100%';\n element.style.overflow = 'hidden';\n element.style.padding = '0';\n\n // Temporary placeholder content\n element.innerHTML = `\n <h2>${state?.title || 'Tab Content'}</h2>\n <p>Tab ID: ${state?.tabId || 'unknown'}</p>\n <p>Route: ${state?.route || 'none'}</p>\n <p>App ID: ${state?.appId || 'none'}</p>\n `;\n\n if (state?.tabId) {\n this.containerMap.set(state.tabId, container);\n\n // Apply initial styles\n this.applyTabStyles(container, state);\n\n // Listen for show events\n container.on('show', () => {\n const isFirstShow = !this.loadedTabs.has(state.tabId);\n this.tabShown$.next({\n tabId: state.tabId,\n container,\n isFirstShow\n });\n });\n\n // Listen for close events\n container.on('beforeComponentRelease', () => {\n this.containerMap.delete(state.tabId);\n this.loadedTabs.delete(state.tabId);\n this.tabClosed$.next(state.tabId);\n });\n }\n\n // CRITICAL: Return the bindable component object\n return {\n component: element,\n virtual: false // false means actual DOM content\n };\n }\n\n /**\n * Unbind component event listener (called by Golden Layout)\n */\n private unbindComponentEventListener(container: GLComponentContainer): void {\n // Cleanup handled in beforeComponentRelease\n }\n\n /**\n * Apply visual styles to a tab\n */\n private applyTabStyles(container: GLComponentContainer, state: TabComponentState): void {\n const tabElement = container.tab?.element;\n if (!tabElement) return;\n\n // Set app color CSS variable\n tabElement.style.setProperty('--app-color', state.appColor);\n\n // Add/remove pinned class\n if (state.isPinned) {\n tabElement.classList.add('pinned');\n } else {\n tabElement.classList.remove('pinned');\n }\n\n // Set italic font for temporary tabs\n const titleElement = tabElement.querySelector('.lm_title') as HTMLElement;\n if (titleElement) {\n titleElement.style.fontStyle = state.isPinned ? 'normal' : 'italic';\n }\n\n // Add event listeners if not already added (use data attribute to track)\n if (!tabElement.hasAttribute('data-events-attached')) {\n tabElement.setAttribute('data-events-attached', 'true');\n\n // Double-click to toggle pin\n tabElement.addEventListener('dblclick', (e: Event) => {\n e.stopPropagation();\n this.tabDoubleClicked.next(state.tabId);\n });\n\n // Right-click for context menu\n tabElement.addEventListener('contextmenu', (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n this.tabRightClicked.next({ tabId: state.tabId, x: e.clientX, y: e.clientY });\n });\n }\n\n // Handle pin icon\n if (state.isPinned) {\n // Add pin icon if not present\n if (!tabElement.querySelector('.pin-icon')) {\n const pinIcon = document.createElement('i');\n pinIcon.className = 'fa-solid fa-thumbtack pin-icon';\n pinIcon.style.cssText = `\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%) rotate(45deg);\n font-size: 9px;\n color: var(--mj-text-muted);\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n `;\n // Click on pin to unpin\n pinIcon.addEventListener('click', (e) => {\n e.stopPropagation();\n this.tabDoubleClicked.next(state.tabId);\n });\n tabElement.appendChild(pinIcon);\n }\n } else {\n // Remove pin icon if present\n const pinIcon = tabElement.querySelector('.pin-icon');\n if (pinIcon) {\n pinIcon.remove();\n }\n }\n }\n\n /**\n * Refresh styles for all tabs (after drag/drop)\n */\n private refreshAllTabStyles(): void {\n setTimeout(() => {\n this.containerMap.forEach((container, tabId) => {\n const state = container.state as unknown as TabComponentState;\n if (state) {\n this.applyTabStyles(container, state);\n }\n });\n }, 50);\n }\n\n /**\n * Find first stack in layout\n */\n private findFirstStack(): GLLayoutItem | null {\n if (!this.layout || !this.layout.rootItem) return null;\n\n const findStack = (item: GLLayoutItem): GLLayoutItem | null => {\n if (item.type === 'stack') {\n return item;\n }\n if (item.contentItems) {\n for (const child of item.contentItems) {\n const found = findStack(child);\n if (found) return found;\n }\n }\n return null;\n };\n\n return findStack(this.layout.rootItem);\n }\n\n /**\n * Convert workspace layout config to Golden Layout config\n */\n private convertToGoldenLayoutConfig(config: WorkspaceLayoutConfig): GLLayoutConfig {\n // Sanitize the root node to ensure size values are valid\n const sanitizedRoot = this.sanitizeLayoutNode(config.root);\n\n return {\n root: sanitizedRoot as GLLayoutNode,\n header: {\n show: 'top',\n popout: false,\n maximise: false,\n close: 'tab'\n }\n };\n }\n\n /**\n * Sanitize a layout node to ensure all values are Golden Layout compatible\n */\n private sanitizeLayoutNode(node: LayoutNode): LayoutNode {\n const sanitized: LayoutNode = {\n ...node\n };\n\n // Cast to any to work with dynamic properties\n const sanitizedAny = sanitized as any;\n\n // Convert size from number + sizeUnit to Golden Layout format\n // Golden Layout expects strings like \"100%\" or \"1fr\", not separate fields\n if (sanitizedAny.size !== undefined && sanitizedAny.sizeUnit !== undefined) {\n if (typeof sanitizedAny.size === 'number') {\n // Combine size and sizeUnit into a single string\n sanitizedAny.size = `${sanitizedAny.size}${sanitizedAny.sizeUnit}`;\n // Remove sizeUnit as it's now part of size\n delete sanitizedAny.sizeUnit;\n }\n }\n\n // Remove width/height if they exist and are not valid\n // Golden Layout expects strings like \"50%\" or numbers (pixels)\n // But JSON parsing might give us non-string objects\n if (sanitized.width !== undefined) {\n if (typeof sanitized.width !== 'number' && typeof sanitized.width !== 'string') {\n delete sanitized.width;\n }\n }\n if (sanitized.height !== undefined) {\n if (typeof sanitized.height !== 'number' && typeof sanitized.height !== 'string') {\n delete sanitized.height;\n }\n }\n\n // Remove other Golden Layout internal fields that shouldn't be in saved config\n delete sanitizedAny.minSizeUnit;\n\n // Recursively sanitize child nodes\n if (sanitized.content) {\n sanitized.content = sanitized.content.map(child => this.sanitizeLayoutNode(child));\n }\n\n return sanitized;\n }\n\n /**\n * Convert Golden Layout config to workspace layout config\n */\n private convertFromGoldenLayoutConfig(resolved: GLResolvedLayoutConfig): WorkspaceLayoutConfig {\n return {\n root: resolved.root as unknown as LayoutNode\n };\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-base-application",
3
- "version": "5.33.0",
3
+ "version": "5.34.1",
4
4
  "description": "MemberJunction Explorer: BaseApplication class system for app-centric navigation",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",
@@ -30,9 +30,9 @@
30
30
  "@angular/core": "21.1.3"
31
31
  },
32
32
  "dependencies": {
33
- "@memberjunction/global": "5.33.0",
34
- "@memberjunction/core": "5.33.0",
35
- "@memberjunction/core-entities": "5.33.0",
33
+ "@memberjunction/global": "5.34.1",
34
+ "@memberjunction/core": "5.34.1",
35
+ "@memberjunction/core-entities": "5.34.1",
36
36
  "golden-layout": "^2.6.0",
37
37
  "rxjs": "~7.8.2",
38
38
  "tslib": "^2.8.1"