@memberjunction/ng-shared-generic 5.3.1 → 5.4.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.
@@ -1 +1 @@
1
- {"version":3,"file":"recent-access.service.js","sourceRoot":"","sources":["../../src/lib/recent-access.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAyB,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAE,eAAe,EAAc,MAAM,MAAM,CAAC;;AAiBnD;;;GAGG;AAIH,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAAC,SAAS,CAAsB;IACtC,aAAa,GAAG,IAAI,eAAe,CAAqB,EAAE,CAAC,CAAC;IAC5D,WAAW,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC,CAAC;IAClD,SAAS,GAAG,KAAK,CAAC;IAE1B;QACE,IAAI,mBAAmB,CAAC,SAAS,EAAE,CAAC;YAClC,OAAO,mBAAmB,CAAC,SAAS,CAAC;QACvC,CAAC;QACD,mBAAmB,CAAC,SAAS,GAAG,IAAI,CAAC;IACvC,CAAC;IAEM,MAAM,KAAK,QAAQ;QACxB,OAAO,mBAAmB,CAAC,SAAS,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;IACzC,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,SAAS,CACpB,UAAk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ACjC,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,UAAU;QACf,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;6GA3QU,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 { Metadata, RunView, CompositeKey, LogError, EntityRecordNameInput } from '@memberjunction/core';\nimport { MJUserRecordLogEntity, UserInfoEngine } from '@memberjunction/core-entities';\nimport { BehaviorSubject, Observable } from 'rxjs';\n\n/**\n * Represents a recently accessed resource\n */\nexport interface RecentAccessItem {\n id: string;\n entityId: string;\n entityName: string;\n recordId: string;\n recordName?: string;\n latestAt: Date;\n totalCount: number;\n /** Resource type for special handling (record, view, dashboard, artifact) */\n resourceType: 'record' | 'view' | 'dashboard' | 'artifact' | 'report';\n}\n\n/**\n * Service for tracking and retrieving recently accessed resources.\n * Uses the User Record Logs entity to persist access history.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class RecentAccessService {\n private static _instance: RecentAccessService;\n private _recentItems$ = new BehaviorSubject<RecentAccessItem[]>([]);\n private _isLoading$ = new BehaviorSubject<boolean>(false);\n private _isLoaded = false;\n\n constructor() {\n if (RecentAccessService._instance) {\n return RecentAccessService._instance;\n }\n RecentAccessService._instance = this;\n }\n\n public static get Instance(): RecentAccessService {\n return RecentAccessService._instance;\n }\n\n /**\n * Observable of recent access items, sorted by most recent first\n */\n public get RecentItems(): Observable<RecentAccessItem[]> {\n return this._recentItems$.asObservable();\n }\n\n /**\n * Current value of recent items\n */\n public get RecentItemsValue(): RecentAccessItem[] {\n return this._recentItems$.value;\n }\n\n /**\n * Observable loading state\n */\n public get IsLoading(): Observable<boolean> {\n return this._isLoading$.asObservable();\n }\n\n /**\n * Logs access to a record. Creates or updates the User Record Log entry.\n * This is a fire-and-forget operation - errors are logged but don't interrupt the user.\n *\n * @param entityName - The name of the entity being accessed\n * @param recordId - The record ID (single value or CompositeKey string)\n * @param resourceType - The type of resource being accessed\n */\n public async logAccess(\n entityName: string,\n recordId: string | CompositeKey,\n resourceType: 'record' | 'view' | 'dashboard' | 'artifact' | 'report' = 'record'\n ): Promise<void> {\n try {\n const md = new Metadata();\n const entityInfo = md.Entities.find(e => e.Name === entityName);\n if (!entityInfo) {\n console.warn(`RecentAccessService: Entity \"${entityName}\" not found in metadata`);\n return;\n }\n\n // Convert CompositeKey to string if needed\n const recordIdString = recordId instanceof CompositeKey\n ? recordId.Values(',') // Values() returns joined string with specified delimiter\n : recordId;\n\n // Check if we already have a log entry for this user/entity/record combination\n const rv = new RunView();\n const existingResult = await rv.RunView<MJUserRecordLogEntity>({\n EntityName: 'MJ: User Record Logs',\n ExtraFilter: `UserID='${md.CurrentUser.ID}' AND EntityID='${entityInfo.ID}' AND RecordID='${recordIdString}'`,\n ResultType: 'entity_object',\n MaxRows: 1\n });\n\n if (!existingResult.Success) {\n console.error('RecentAccessService: Failed to check existing log', existingResult.ErrorMessage);\n return;\n }\n\n if (existingResult.Results && existingResult.Results.length > 0) {\n // Update existing entry\n const existing = existingResult.Results[0];\n existing.LatestAt = new Date();\n existing.TotalCount = (existing.TotalCount || 0) + 1;\n\n const saveResult = await existing.Save();\n if (!saveResult) {\n console.error('RecentAccessService: Failed to update log entry');\n }\n } else {\n // Create new entry\n const newLog = await md.GetEntityObject<MJUserRecordLogEntity>('MJ: User Record Logs');\n newLog.UserID = md.CurrentUser.ID;\n newLog.EntityID = entityInfo.ID;\n newLog.RecordID = recordIdString;\n // EarliestAt and LatestAt have default values of getdate() in the DB\n // TotalCount defaults to 0, so we set it to 1\n newLog.TotalCount = 1;\n\n const saveResult = await newLog.Save();\n if (!saveResult) {\n console.error('RecentAccessService: Failed to create log entry');\n }\n }\n\n // Refresh the recent items list in background\n this.refreshRecentItems();\n } catch (error) {\n // Don't throw - this is non-critical functionality\n console.error('RecentAccessService: Error logging access', error);\n }\n }\n\n /**\n * Loads recent access items for the current user using UserInfoEngine (cached).\n * @param maxItems - Maximum number of items to return (default 15)\n * @param forceRefresh - Force refresh even if already loaded\n */\n public async loadRecentItems(maxItems: number = 15, forceRefresh: boolean = false): Promise<RecentAccessItem[]> {\n if (this._isLoaded && !forceRefresh) {\n return this._recentItems$.value;\n }\n\n try {\n this._isLoading$.next(true);\n\n const md = new Metadata();\n\n // Get recent records, limited to maxItems (already ordered by LatestAt DESC in engine)\n const userRecordLogs = UserInfoEngine.Instance.UserRecordLogs.slice(0, maxItems);\n\n const items: RecentAccessItem[] = [];\n\n for (const log of userRecordLogs) {\n const entityInfo = md.Entities.find(e => e.ID === log.EntityID);\n if (!entityInfo) continue;\n\n // Determine resource type based on entity name\n const resourceType = this.determineResourceType(entityInfo.Name);\n\n items.push({\n id: log.ID,\n entityId: log.EntityID,\n entityName: entityInfo.Name,\n recordId: log.RecordID,\n latestAt: log.LatestAt,\n totalCount: log.TotalCount,\n resourceType\n });\n }\n\n // Batch-resolve record names for all items\n await this.resolveRecordNames(items, md);\n\n this._recentItems$.next(items);\n this._isLoaded = true;\n\n return items;\n } catch (error) {\n LogError('RecentAccessService: Error loading recent items', undefined, error);\n return [];\n } finally {\n this._isLoading$.next(false);\n }\n }\n\n /**\n * Refresh recent items in background\n */\n public async refreshRecentItems(): Promise<void> {\n await this.loadRecentItems(15, true);\n }\n\n /**\n * Batch-resolve record names for a list of recent access items using GetEntityRecordNames().\n * Mutates the items in-place to set recordName where resolved.\n */\n private async resolveRecordNames(items: RecentAccessItem[], md: Metadata): Promise<void> {\n const nameInputs: EntityRecordNameInput[] = [];\n const indexMap = new Map<string, number>();\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const compositeKey = this.buildCompositeKeyForRecord(item.entityName, item.recordId, md);\n if (!compositeKey) continue;\n\n nameInputs.push({ EntityName: item.entityName, CompositeKey: compositeKey });\n indexMap.set(`${item.entityName}||${compositeKey.ToConcatenatedString()}`, i);\n }\n\n if (nameInputs.length === 0) return;\n\n try {\n const nameResults = await md.GetEntityRecordNames(nameInputs);\n for (const result of nameResults) {\n if (result.Success && result.RecordName) {\n const key = `${result.EntityName}||${result.CompositeKey.ToConcatenatedString()}`;\n const index = indexMap.get(key);\n if (index !== undefined) {\n items[index].recordName = result.RecordName;\n }\n }\n }\n } catch (error) {\n console.warn('RecentAccessService: Failed to resolve record names', error);\n }\n }\n\n /**\n * Build a CompositeKey for a record. RecordID may be stored as either:\n * - Concatenated format: \"FieldName|Value\" or \"Field1|Val1||Field2|Val2\"\n * - Plain value: just the raw value (e.g. a GUID)\n * Detects the format and constructs the key accordingly.\n */\n private buildCompositeKeyForRecord(entityName: string, recordId: string, md: Metadata): CompositeKey | null {\n if (!recordId) return null;\n\n // If recordId contains '|', it's in concatenated format\n if (recordId.includes('|')) {\n try {\n const compositeKey = new CompositeKey();\n compositeKey.LoadFromConcatenatedString(recordId);\n if (compositeKey.KeyValuePairs.length > 0) return compositeKey;\n } catch {\n // Fall through to entity-based lookup\n }\n }\n\n // Plain value — look up entity primary key field(s) to construct the key\n const entityInfo = md.Entities.find(e => e.Name === entityName);\n if (!entityInfo) return null;\n\n const pkField = entityInfo.FirstPrimaryKey;\n if (!pkField) return null;\n\n const compositeKey = new CompositeKey();\n compositeKey.KeyValuePairs = [{ FieldName: pkField.Name, Value: recordId }];\n return compositeKey;\n }\n\n /**\n * Determines the resource type based on entity name\n */\n private determineResourceType(entityName: string): 'record' | 'view' | 'dashboard' | 'artifact' | 'report' {\n const normalizedName = entityName.toLowerCase();\n\n if (normalizedName === 'user views') {\n return 'view';\n }\n if (normalizedName === 'dashboards') {\n return 'dashboard';\n }\n if (normalizedName === 'mj: conversation artifacts' || normalizedName === 'conversation artifacts') {\n return 'artifact';\n }\n if (normalizedName === 'reports') {\n return 'report';\n }\n\n return 'record';\n }\n\n /**\n * Clears the cached recent items (useful for logout)\n */\n public clearCache(): void {\n this._recentItems$.next([]);\n this._isLoaded = false;\n }\n}\n"]}
@@ -0,0 +1,161 @@
1
+ import { Observable } from 'rxjs';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Defines a theme available in the application.
5
+ * Built-in themes (light/dark) have no CssUrl.
6
+ * Custom themes specify a BaseTheme to inherit from and a CssUrl with overrides.
7
+ */
8
+ export interface ThemeDefinition {
9
+ /** Unique identifier (e.g. 'light', 'dark', 'izzy-dark') */
10
+ Id: string;
11
+ /** Human-readable display name (e.g. 'Light', 'Dark', 'Izzy Dark') */
12
+ Name: string;
13
+ /** Which built-in theme this inherits from */
14
+ BaseTheme: 'light' | 'dark';
15
+ /** URL to the CSS file with token overrides (omit for built-in themes) */
16
+ CssUrl?: string;
17
+ /** Whether this is a built-in theme (light/dark) */
18
+ IsBuiltIn: boolean;
19
+ /** Optional description shown in theme picker */
20
+ Description?: string;
21
+ /** Optional preview swatch colors for a future theme picker UI */
22
+ PreviewColors?: string[];
23
+ }
24
+ /**
25
+ * Service to manage application themes with pluggable custom theme support.
26
+ *
27
+ * Built-in themes (light/dark) work identically to before. Custom themes
28
+ * inherit from a base theme and overlay additional CSS token overrides via
29
+ * a dynamically loaded stylesheet.
30
+ *
31
+ * CSS resolution for custom themes (e.g. "Izzy Dark" extending dark):
32
+ * 1. `:root` light defaults (from _tokens.scss in this package)
33
+ * 2. `[data-theme="dark"]` dark overrides (from _tokens.scss in this package)
34
+ * 3. `[data-theme-overlay="izzy-dark"]` custom overrides (loaded dynamically)
35
+ *
36
+ * Follows the DeveloperModeService pattern:
37
+ * - Settings persisted via UserInfoEngine
38
+ * - BehaviorSubject for reactive state
39
+ * - Initialize after login, Reset on logout
40
+ */
41
+ export declare class ThemeService {
42
+ private _preference$;
43
+ private _appliedTheme$;
44
+ private _initialized;
45
+ private systemMediaQuery;
46
+ private boundSystemThemeHandler;
47
+ /** Registry of available themes, seeded with built-in light and dark */
48
+ private themeRegistry;
49
+ /** Cache of loaded <link> elements by theme ID to avoid re-downloading */
50
+ private loadedCssLinks;
51
+ /**
52
+ * Observable for user's theme preference (theme ID or 'system')
53
+ */
54
+ get Preference$(): Observable<string>;
55
+ /**
56
+ * Observable for the actually applied theme (resolved theme ID)
57
+ */
58
+ get AppliedTheme$(): Observable<string>;
59
+ /**
60
+ * Current theme preference (synchronous access)
61
+ */
62
+ get Preference(): string;
63
+ /**
64
+ * Currently applied theme ID (synchronous access)
65
+ */
66
+ get AppliedTheme(): string;
67
+ /**
68
+ * Whether the service has been initialized
69
+ */
70
+ get IsInitialized(): boolean;
71
+ /**
72
+ * All registered themes, for UI consumption (e.g. theme picker menus)
73
+ */
74
+ get AvailableThemes(): ThemeDefinition[];
75
+ /**
76
+ * Look up a theme definition by ID.
77
+ * Returns undefined if the theme ID is not registered.
78
+ */
79
+ GetThemeDefinition(id: string): ThemeDefinition | undefined;
80
+ /**
81
+ * Register a custom theme. If a theme with the same ID already exists,
82
+ * it is replaced (allowing override of built-in themes if desired).
83
+ */
84
+ RegisterTheme(theme: ThemeDefinition): void;
85
+ /**
86
+ * Register multiple custom themes at once.
87
+ */
88
+ RegisterThemes(themes: ThemeDefinition[]): void;
89
+ /**
90
+ * Initialize the theme service.
91
+ * Call after login when UserInfoEngine is available.
92
+ */
93
+ Initialize(): Promise<void>;
94
+ /**
95
+ * Set the theme preference and apply it.
96
+ * @param preference - A registered theme ID or 'system'
97
+ */
98
+ SetTheme(preference: string): Promise<void>;
99
+ /**
100
+ * Reset the service (call on logout)
101
+ */
102
+ Reset(): void;
103
+ /**
104
+ * Apply a resolved theme ID to the DOM.
105
+ * Sets `data-theme` based on BaseTheme and `data-theme-overlay` for custom themes.
106
+ * Loads custom CSS if needed, disables previous custom CSS.
107
+ */
108
+ private applyTheme;
109
+ /**
110
+ * Apply the base theme attribute to <html>.
111
+ * 'dark' sets data-theme="dark"; 'light' removes it (matching existing convention).
112
+ */
113
+ private applyBaseThemeAttribute;
114
+ /**
115
+ * Shorthand for built-in theme application (no custom CSS)
116
+ */
117
+ private applyBuiltInTheme;
118
+ /**
119
+ * Load (or re-enable) a custom theme's CSS file.
120
+ * Injects a <link> element into <head> with a data-mj-theme attribute.
121
+ * Caches the link element to avoid re-downloading on theme switches.
122
+ * Returns a Promise that resolves once the stylesheet is loaded.
123
+ */
124
+ private loadThemeCss;
125
+ /**
126
+ * Disable (not remove) all custom theme CSS <link> elements.
127
+ * Disabling rather than removing avoids re-downloading when switching back.
128
+ */
129
+ private disableAllCustomCss;
130
+ /**
131
+ * Resolve a preference string to an actual theme ID.
132
+ * 'system' resolves to 'light' or 'dark' based on OS preference.
133
+ * Unrecognized IDs fall back to 'light'.
134
+ */
135
+ private resolveTheme;
136
+ /**
137
+ * Get system theme preference from OS
138
+ */
139
+ private getSystemTheme;
140
+ /**
141
+ * Setup listener for system theme changes
142
+ */
143
+ private setupSystemThemeListener;
144
+ /**
145
+ * Handle system theme change (only applies if in 'system' mode)
146
+ */
147
+ private onSystemThemeChange;
148
+ /**
149
+ * Load theme preference from User Settings.
150
+ * Accepts any registered theme ID or 'system'.
151
+ * Falls back to 'system' if saved value is not recognized.
152
+ */
153
+ private loadSetting;
154
+ /**
155
+ * Save theme preference to User Settings
156
+ */
157
+ private saveSetting;
158
+ static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, never>;
159
+ static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>;
160
+ }
161
+ //# sourceMappingURL=theme.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.service.d.ts","sourceRoot":"","sources":["../../src/lib/theme.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;;AAGnD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B,4DAA4D;IAC5D,EAAE,EAAE,MAAM,CAAC;IACX,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,8C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IAAI,CAAC;IAaxD;;OAEG;IACI,KAAK,IAAI,IAAI;IAuBpB;;;;OAIG;YACW,UAAU;IA0BxB;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAQ/B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAkCpB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAcpB;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAUhC;;OAEG;YACW,mBAAmB;IAWjC;;;;OAIG;YACW,WAAW;IAsBzB;;OAEG;YACW,WAAW;yCA9VhB,YAAY;6CAAZ,YAAY;CAsWxB"}
@@ -0,0 +1,359 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { BehaviorSubject } from 'rxjs';
3
+ import { UserInfoEngine } from '@memberjunction/core-entities';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Setting key for theme preference in MJ: User Settings entity
7
+ */
8
+ const THEME_SETTING_KEY = 'Explorer.Theme';
9
+ /**
10
+ * Built-in light theme definition
11
+ */
12
+ const LIGHT_THEME = {
13
+ Id: 'light',
14
+ Name: 'Light',
15
+ BaseTheme: 'light',
16
+ IsBuiltIn: true,
17
+ Description: 'Default light theme'
18
+ };
19
+ /**
20
+ * Built-in dark theme definition
21
+ */
22
+ const DARK_THEME = {
23
+ Id: 'dark',
24
+ Name: 'Dark',
25
+ BaseTheme: 'dark',
26
+ IsBuiltIn: true,
27
+ Description: 'Default dark theme'
28
+ };
29
+ /**
30
+ * Service to manage application themes with pluggable custom theme support.
31
+ *
32
+ * Built-in themes (light/dark) work identically to before. Custom themes
33
+ * inherit from a base theme and overlay additional CSS token overrides via
34
+ * a dynamically loaded stylesheet.
35
+ *
36
+ * CSS resolution for custom themes (e.g. "Izzy Dark" extending dark):
37
+ * 1. `:root` light defaults (from _tokens.scss in this package)
38
+ * 2. `[data-theme="dark"]` dark overrides (from _tokens.scss in this package)
39
+ * 3. `[data-theme-overlay="izzy-dark"]` custom overrides (loaded dynamically)
40
+ *
41
+ * Follows the DeveloperModeService pattern:
42
+ * - Settings persisted via UserInfoEngine
43
+ * - BehaviorSubject for reactive state
44
+ * - Initialize after login, Reset on logout
45
+ */
46
+ export class ThemeService {
47
+ _preference$ = new BehaviorSubject('system');
48
+ _appliedTheme$ = new BehaviorSubject('light');
49
+ _initialized = false;
50
+ systemMediaQuery = null;
51
+ boundSystemThemeHandler = null;
52
+ /** Registry of available themes, seeded with built-in light and dark */
53
+ themeRegistry = new Map([
54
+ ['light', LIGHT_THEME],
55
+ ['dark', DARK_THEME]
56
+ ]);
57
+ /** Cache of loaded <link> elements by theme ID to avoid re-downloading */
58
+ loadedCssLinks = new Map();
59
+ /**
60
+ * Observable for user's theme preference (theme ID or 'system')
61
+ */
62
+ get Preference$() {
63
+ return this._preference$.asObservable();
64
+ }
65
+ /**
66
+ * Observable for the actually applied theme (resolved theme ID)
67
+ */
68
+ get AppliedTheme$() {
69
+ return this._appliedTheme$.asObservable();
70
+ }
71
+ /**
72
+ * Current theme preference (synchronous access)
73
+ */
74
+ get Preference() {
75
+ return this._preference$.value;
76
+ }
77
+ /**
78
+ * Currently applied theme ID (synchronous access)
79
+ */
80
+ get AppliedTheme() {
81
+ return this._appliedTheme$.value;
82
+ }
83
+ /**
84
+ * Whether the service has been initialized
85
+ */
86
+ get IsInitialized() {
87
+ return this._initialized;
88
+ }
89
+ /**
90
+ * All registered themes, for UI consumption (e.g. theme picker menus)
91
+ */
92
+ get AvailableThemes() {
93
+ return Array.from(this.themeRegistry.values());
94
+ }
95
+ /**
96
+ * Look up a theme definition by ID.
97
+ * Returns undefined if the theme ID is not registered.
98
+ */
99
+ GetThemeDefinition(id) {
100
+ return this.themeRegistry.get(id);
101
+ }
102
+ // ========================================
103
+ // THEME REGISTRATION
104
+ // ========================================
105
+ /**
106
+ * Register a custom theme. If a theme with the same ID already exists,
107
+ * it is replaced (allowing override of built-in themes if desired).
108
+ */
109
+ RegisterTheme(theme) {
110
+ this.themeRegistry.set(theme.Id, theme);
111
+ }
112
+ /**
113
+ * Register multiple custom themes at once.
114
+ */
115
+ RegisterThemes(themes) {
116
+ for (const theme of themes) {
117
+ this.RegisterTheme(theme);
118
+ }
119
+ }
120
+ // ========================================
121
+ // LIFECYCLE
122
+ // ========================================
123
+ /**
124
+ * Initialize the theme service.
125
+ * Call after login when UserInfoEngine is available.
126
+ */
127
+ async Initialize() {
128
+ if (this._initialized) {
129
+ return;
130
+ }
131
+ this.setupSystemThemeListener();
132
+ const savedPreference = await this.loadSetting();
133
+ this._preference$.next(savedPreference);
134
+ const resolvedThemeId = this.resolveTheme(savedPreference);
135
+ await this.applyTheme(resolvedThemeId);
136
+ this._initialized = true;
137
+ }
138
+ /**
139
+ * Set the theme preference and apply it.
140
+ * @param preference - A registered theme ID or 'system'
141
+ */
142
+ async SetTheme(preference) {
143
+ if (preference === this._preference$.value) {
144
+ return;
145
+ }
146
+ this._preference$.next(preference);
147
+ const resolvedThemeId = this.resolveTheme(preference);
148
+ await this.applyTheme(resolvedThemeId);
149
+ await this.saveSetting(preference);
150
+ }
151
+ /**
152
+ * Reset the service (call on logout)
153
+ */
154
+ Reset() {
155
+ if (this.systemMediaQuery && this.boundSystemThemeHandler) {
156
+ this.systemMediaQuery.removeEventListener('change', this.boundSystemThemeHandler);
157
+ }
158
+ this.systemMediaQuery = null;
159
+ this.boundSystemThemeHandler = null;
160
+ this._preference$.next('system');
161
+ this._appliedTheme$.next('light');
162
+ this._initialized = false;
163
+ // Remove theme attributes
164
+ document.documentElement.removeAttribute('data-theme');
165
+ document.documentElement.removeAttribute('data-theme-overlay');
166
+ // Disable all custom CSS links
167
+ this.disableAllCustomCss();
168
+ }
169
+ // ========================================
170
+ // THEME APPLICATION
171
+ // ========================================
172
+ /**
173
+ * Apply a resolved theme ID to the DOM.
174
+ * Sets `data-theme` based on BaseTheme and `data-theme-overlay` for custom themes.
175
+ * Loads custom CSS if needed, disables previous custom CSS.
176
+ */
177
+ async applyTheme(themeId) {
178
+ const themeDef = this.themeRegistry.get(themeId);
179
+ // Fall back to 'light' if the theme ID isn't recognized
180
+ if (!themeDef) {
181
+ this.applyBuiltInTheme('light');
182
+ this._appliedTheme$.next('light');
183
+ return;
184
+ }
185
+ // Set the base theme attribute (drives existing [data-theme="dark"] selectors)
186
+ this.applyBaseThemeAttribute(themeDef.BaseTheme);
187
+ if (themeDef.IsBuiltIn) {
188
+ // Built-in theme: remove overlay, disable custom CSS
189
+ document.documentElement.removeAttribute('data-theme-overlay');
190
+ this.disableAllCustomCss();
191
+ }
192
+ else if (themeDef.CssUrl) {
193
+ // Custom theme: load/enable CSS and set overlay attribute
194
+ await this.loadThemeCss(themeDef);
195
+ document.documentElement.setAttribute('data-theme-overlay', themeDef.Id);
196
+ }
197
+ this._appliedTheme$.next(themeId);
198
+ }
199
+ /**
200
+ * Apply the base theme attribute to <html>.
201
+ * 'dark' sets data-theme="dark"; 'light' removes it (matching existing convention).
202
+ */
203
+ applyBaseThemeAttribute(baseTheme) {
204
+ if (baseTheme === 'dark') {
205
+ document.documentElement.setAttribute('data-theme', 'dark');
206
+ }
207
+ else {
208
+ document.documentElement.removeAttribute('data-theme');
209
+ }
210
+ }
211
+ /**
212
+ * Shorthand for built-in theme application (no custom CSS)
213
+ */
214
+ applyBuiltInTheme(baseTheme) {
215
+ this.applyBaseThemeAttribute(baseTheme);
216
+ document.documentElement.removeAttribute('data-theme-overlay');
217
+ this.disableAllCustomCss();
218
+ }
219
+ // ========================================
220
+ // DYNAMIC CSS LOADING
221
+ // ========================================
222
+ /**
223
+ * Load (or re-enable) a custom theme's CSS file.
224
+ * Injects a <link> element into <head> with a data-mj-theme attribute.
225
+ * Caches the link element to avoid re-downloading on theme switches.
226
+ * Returns a Promise that resolves once the stylesheet is loaded.
227
+ */
228
+ loadThemeCss(theme) {
229
+ if (!theme.CssUrl) {
230
+ return Promise.resolve();
231
+ }
232
+ // Disable all other custom CSS first
233
+ this.disableAllCustomCss();
234
+ // Check cache — if already loaded, just re-enable
235
+ const existingLink = this.loadedCssLinks.get(theme.Id);
236
+ if (existingLink) {
237
+ existingLink.disabled = false;
238
+ return Promise.resolve();
239
+ }
240
+ // Create and inject new <link> element
241
+ return new Promise((resolve, reject) => {
242
+ const link = document.createElement('link');
243
+ link.rel = 'stylesheet';
244
+ link.href = theme.CssUrl;
245
+ link.setAttribute('data-mj-theme', theme.Id);
246
+ link.onload = () => resolve();
247
+ link.onerror = () => {
248
+ console.warn(`Failed to load theme CSS: ${theme.CssUrl}`);
249
+ // Still resolve so the theme switch isn't blocked
250
+ resolve();
251
+ };
252
+ document.head.appendChild(link);
253
+ this.loadedCssLinks.set(theme.Id, link);
254
+ });
255
+ }
256
+ /**
257
+ * Disable (not remove) all custom theme CSS <link> elements.
258
+ * Disabling rather than removing avoids re-downloading when switching back.
259
+ */
260
+ disableAllCustomCss() {
261
+ for (const link of this.loadedCssLinks.values()) {
262
+ link.disabled = true;
263
+ }
264
+ }
265
+ // ========================================
266
+ // THEME RESOLUTION
267
+ // ========================================
268
+ /**
269
+ * Resolve a preference string to an actual theme ID.
270
+ * 'system' resolves to 'light' or 'dark' based on OS preference.
271
+ * Unrecognized IDs fall back to 'light'.
272
+ */
273
+ resolveTheme(preference) {
274
+ if (preference === 'system') {
275
+ return this.getSystemTheme();
276
+ }
277
+ // If the preference is a registered theme, use it directly
278
+ if (this.themeRegistry.has(preference)) {
279
+ return preference;
280
+ }
281
+ // Unrecognized theme ID — fall back to light
282
+ return 'light';
283
+ }
284
+ /**
285
+ * Get system theme preference from OS
286
+ */
287
+ getSystemTheme() {
288
+ if (typeof window === 'undefined') {
289
+ return 'light';
290
+ }
291
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
292
+ }
293
+ /**
294
+ * Setup listener for system theme changes
295
+ */
296
+ setupSystemThemeListener() {
297
+ if (typeof window === 'undefined') {
298
+ return;
299
+ }
300
+ this.systemMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
301
+ this.boundSystemThemeHandler = () => this.onSystemThemeChange();
302
+ this.systemMediaQuery.addEventListener('change', this.boundSystemThemeHandler);
303
+ }
304
+ /**
305
+ * Handle system theme change (only applies if in 'system' mode)
306
+ */
307
+ async onSystemThemeChange() {
308
+ if (this._preference$.value === 'system') {
309
+ const newThemeId = this.getSystemTheme();
310
+ await this.applyTheme(newThemeId);
311
+ }
312
+ }
313
+ // ========================================
314
+ // PERSISTENCE
315
+ // ========================================
316
+ /**
317
+ * Load theme preference from User Settings.
318
+ * Accepts any registered theme ID or 'system'.
319
+ * Falls back to 'system' if saved value is not recognized.
320
+ */
321
+ async loadSetting() {
322
+ try {
323
+ const engine = UserInfoEngine.Instance;
324
+ const settingValue = engine.GetSetting(THEME_SETTING_KEY);
325
+ if (!settingValue) {
326
+ return 'system';
327
+ }
328
+ // Accept 'system' or any registered theme ID
329
+ if (settingValue === 'system' || this.themeRegistry.has(settingValue)) {
330
+ return settingValue;
331
+ }
332
+ // Saved theme no longer registered — fall back
333
+ return 'system';
334
+ }
335
+ catch (error) {
336
+ console.warn('Failed to load theme setting:', error);
337
+ return 'system';
338
+ }
339
+ }
340
+ /**
341
+ * Save theme preference to User Settings
342
+ */
343
+ async saveSetting(preference) {
344
+ try {
345
+ const engine = UserInfoEngine.Instance;
346
+ await engine.SetSetting(THEME_SETTING_KEY, preference);
347
+ }
348
+ catch (error) {
349
+ console.warn('Failed to save theme setting:', error);
350
+ }
351
+ }
352
+ static ɵfac = function ThemeService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ThemeService)(); };
353
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ThemeService, factory: ThemeService.ɵfac, providedIn: 'root' });
354
+ }
355
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ThemeService, [{
356
+ type: Injectable,
357
+ args: [{ providedIn: 'root' }]
358
+ }], null, null); })();
359
+ //# sourceMappingURL=theme.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.service.js","sourceRoot":"","sources":["../../src/lib/theme.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAc,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;;AAwB/D;;GAEG;AACH,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,GAAoB;IACjC,EAAE,EAAE,OAAO;IACX,IAAI,EAAE,OAAO;IACb,SAAS,EAAE,OAAO;IAClB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,qBAAqB;CACrC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,GAAoB;IAChC,EAAE,EAAE,MAAM;IACV,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,oBAAoB;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,OAAO,YAAY;IACb,YAAY,GAAG,IAAI,eAAe,CAAS,QAAQ,CAAC,CAAC;IACrD,cAAc,GAAG,IAAI,eAAe,CAAS,OAAO,CAAC,CAAC;IACtD,YAAY,GAAG,KAAK,CAAC;IACrB,gBAAgB,GAA0B,IAAI,CAAC;IAC/C,uBAAuB,GAAwB,IAAI,CAAC;IAE5D,wEAAwE;IAChE,aAAa,GAAG,IAAI,GAAG,CAA0B;QACrD,CAAC,OAAO,EAAE,WAAW,CAAC;QACtB,CAAC,MAAM,EAAE,UAAU,CAAC;KACvB,CAAC,CAAC;IAEH,0EAA0E;IAClE,cAAc,GAAG,IAAI,GAAG,EAA2B,CAAC;IAE5D;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;IAC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AAY,WAAZ,YAAY,mBADC,MAAM;;iFACnB,YAAY;cADxB,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { Injectable } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { UserInfoEngine } from '@memberjunction/core-entities';\n\n/**\n * Defines a theme available in the application.\n * Built-in themes (light/dark) have no CssUrl.\n * Custom themes specify a BaseTheme to inherit from and a CssUrl with overrides.\n */\nexport interface ThemeDefinition {\n /** Unique identifier (e.g. 'light', 'dark', 'izzy-dark') */\n Id: string;\n /** Human-readable display name (e.g. 'Light', 'Dark', 'Izzy Dark') */\n Name: string;\n /** Which built-in theme this inherits from */\n BaseTheme: 'light' | 'dark';\n /** URL to the CSS file with token overrides (omit for built-in themes) */\n CssUrl?: string;\n /** Whether this is a built-in theme (light/dark) */\n IsBuiltIn: boolean;\n /** Optional description shown in theme picker */\n Description?: string;\n /** Optional preview swatch colors for a future theme picker UI */\n PreviewColors?: string[];\n}\n\n/**\n * Setting key for theme preference in MJ: User Settings entity\n */\nconst THEME_SETTING_KEY = 'Explorer.Theme';\n\n/**\n * Built-in light theme definition\n */\nconst LIGHT_THEME: ThemeDefinition = {\n Id: 'light',\n Name: 'Light',\n BaseTheme: 'light',\n IsBuiltIn: true,\n Description: 'Default light theme'\n};\n\n/**\n * Built-in dark theme definition\n */\nconst DARK_THEME: ThemeDefinition = {\n Id: 'dark',\n Name: 'Dark',\n BaseTheme: 'dark',\n IsBuiltIn: true,\n Description: 'Default dark theme'\n};\n\n/**\n * Service to manage application themes with pluggable custom theme support.\n *\n * Built-in themes (light/dark) work identically to before. Custom themes\n * inherit from a base theme and overlay additional CSS token overrides via\n * a dynamically loaded stylesheet.\n *\n * CSS resolution for custom themes (e.g. \"Izzy Dark\" extending dark):\n * 1. `:root` light defaults (from _tokens.scss in this package)\n * 2. `[data-theme=\"dark\"]` dark overrides (from _tokens.scss in this package)\n * 3. `[data-theme-overlay=\"izzy-dark\"]` custom overrides (loaded dynamically)\n *\n * Follows the DeveloperModeService pattern:\n * - Settings persisted via UserInfoEngine\n * - BehaviorSubject for reactive state\n * - Initialize after login, Reset on logout\n */\n@Injectable({ providedIn: 'root' })\nexport class ThemeService {\n private _preference$ = new BehaviorSubject<string>('system');\n private _appliedTheme$ = new BehaviorSubject<string>('light');\n private _initialized = false;\n private systemMediaQuery: MediaQueryList | null = null;\n private boundSystemThemeHandler: (() => void) | null = null;\n\n /** Registry of available themes, seeded with built-in light and dark */\n private themeRegistry = new Map<string, ThemeDefinition>([\n ['light', LIGHT_THEME],\n ['dark', DARK_THEME]\n ]);\n\n /** Cache of loaded <link> elements by theme ID to avoid re-downloading */\n private loadedCssLinks = new Map<string, HTMLLinkElement>();\n\n /**\n * Observable for user's theme preference (theme ID or 'system')\n */\n public get Preference$(): Observable<string> {\n return this._preference$.asObservable();\n }\n\n /**\n * Observable for the actually applied theme (resolved theme ID)\n */\n public get AppliedTheme$(): Observable<string> {\n return this._appliedTheme$.asObservable();\n }\n\n /**\n * Current theme preference (synchronous access)\n */\n public get Preference(): string {\n return this._preference$.value;\n }\n\n /**\n * Currently applied theme ID (synchronous access)\n */\n public get AppliedTheme(): string {\n return this._appliedTheme$.value;\n }\n\n /**\n * Whether the service has been initialized\n */\n public get IsInitialized(): boolean {\n return this._initialized;\n }\n\n /**\n * All registered themes, for UI consumption (e.g. theme picker menus)\n */\n public get AvailableThemes(): ThemeDefinition[] {\n return Array.from(this.themeRegistry.values());\n }\n\n /**\n * Look up a theme definition by ID.\n * Returns undefined if the theme ID is not registered.\n */\n public GetThemeDefinition(id: string): ThemeDefinition | undefined {\n return this.themeRegistry.get(id);\n }\n\n // ========================================\n // THEME REGISTRATION\n // ========================================\n\n /**\n * Register a custom theme. If a theme with the same ID already exists,\n * it is replaced (allowing override of built-in themes if desired).\n */\n public RegisterTheme(theme: ThemeDefinition): void {\n this.themeRegistry.set(theme.Id, theme);\n }\n\n /**\n * Register multiple custom themes at once.\n */\n public RegisterThemes(themes: ThemeDefinition[]): void {\n for (const theme of themes) {\n this.RegisterTheme(theme);\n }\n }\n\n // ========================================\n // LIFECYCLE\n // ========================================\n\n /**\n * Initialize the theme service.\n * Call after login when UserInfoEngine is available.\n */\n public async Initialize(): Promise<void> {\n if (this._initialized) {\n return;\n }\n\n this.setupSystemThemeListener();\n\n const savedPreference = await this.loadSetting();\n this._preference$.next(savedPreference);\n\n const resolvedThemeId = this.resolveTheme(savedPreference);\n await this.applyTheme(resolvedThemeId);\n\n this._initialized = true;\n }\n\n /**\n * Set the theme preference and apply it.\n * @param preference - A registered theme ID or 'system'\n */\n public async SetTheme(preference: string): Promise<void> {\n if (preference === this._preference$.value) {\n return;\n }\n\n this._preference$.next(preference);\n\n const resolvedThemeId = this.resolveTheme(preference);\n await this.applyTheme(resolvedThemeId);\n\n await this.saveSetting(preference);\n }\n\n /**\n * Reset the service (call on logout)\n */\n public Reset(): void {\n if (this.systemMediaQuery && this.boundSystemThemeHandler) {\n this.systemMediaQuery.removeEventListener('change', this.boundSystemThemeHandler);\n }\n this.systemMediaQuery = null;\n this.boundSystemThemeHandler = null;\n\n this._preference$.next('system');\n this._appliedTheme$.next('light');\n this._initialized = false;\n\n // Remove theme attributes\n document.documentElement.removeAttribute('data-theme');\n document.documentElement.removeAttribute('data-theme-overlay');\n\n // Disable all custom CSS links\n this.disableAllCustomCss();\n }\n\n // ========================================\n // THEME APPLICATION\n // ========================================\n\n /**\n * Apply a resolved theme ID to the DOM.\n * Sets `data-theme` based on BaseTheme and `data-theme-overlay` for custom themes.\n * Loads custom CSS if needed, disables previous custom CSS.\n */\n private async applyTheme(themeId: string): Promise<void> {\n const themeDef = this.themeRegistry.get(themeId);\n\n // Fall back to 'light' if the theme ID isn't recognized\n if (!themeDef) {\n this.applyBuiltInTheme('light');\n this._appliedTheme$.next('light');\n return;\n }\n\n // Set the base theme attribute (drives existing [data-theme=\"dark\"] selectors)\n this.applyBaseThemeAttribute(themeDef.BaseTheme);\n\n if (themeDef.IsBuiltIn) {\n // Built-in theme: remove overlay, disable custom CSS\n document.documentElement.removeAttribute('data-theme-overlay');\n this.disableAllCustomCss();\n } else if (themeDef.CssUrl) {\n // Custom theme: load/enable CSS and set overlay attribute\n await this.loadThemeCss(themeDef);\n document.documentElement.setAttribute('data-theme-overlay', themeDef.Id);\n }\n\n this._appliedTheme$.next(themeId);\n }\n\n /**\n * Apply the base theme attribute to <html>.\n * 'dark' sets data-theme=\"dark\"; 'light' removes it (matching existing convention).\n */\n private applyBaseThemeAttribute(baseTheme: 'light' | 'dark'): void {\n if (baseTheme === 'dark') {\n document.documentElement.setAttribute('data-theme', 'dark');\n } else {\n document.documentElement.removeAttribute('data-theme');\n }\n }\n\n /**\n * Shorthand for built-in theme application (no custom CSS)\n */\n private applyBuiltInTheme(baseTheme: 'light' | 'dark'): void {\n this.applyBaseThemeAttribute(baseTheme);\n document.documentElement.removeAttribute('data-theme-overlay');\n this.disableAllCustomCss();\n }\n\n // ========================================\n // DYNAMIC CSS LOADING\n // ========================================\n\n /**\n * Load (or re-enable) a custom theme's CSS file.\n * Injects a <link> element into <head> with a data-mj-theme attribute.\n * Caches the link element to avoid re-downloading on theme switches.\n * Returns a Promise that resolves once the stylesheet is loaded.\n */\n private loadThemeCss(theme: ThemeDefinition): Promise<void> {\n if (!theme.CssUrl) {\n return Promise.resolve();\n }\n\n // Disable all other custom CSS first\n this.disableAllCustomCss();\n\n // Check cache — if already loaded, just re-enable\n const existingLink = this.loadedCssLinks.get(theme.Id);\n if (existingLink) {\n existingLink.disabled = false;\n return Promise.resolve();\n }\n\n // Create and inject new <link> element\n return new Promise<void>((resolve, reject) => {\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = theme.CssUrl!;\n link.setAttribute('data-mj-theme', theme.Id);\n\n link.onload = () => resolve();\n link.onerror = () => {\n console.warn(`Failed to load theme CSS: ${theme.CssUrl}`);\n // Still resolve so the theme switch isn't blocked\n resolve();\n };\n\n document.head.appendChild(link);\n this.loadedCssLinks.set(theme.Id, link);\n });\n }\n\n /**\n * Disable (not remove) all custom theme CSS <link> elements.\n * Disabling rather than removing avoids re-downloading when switching back.\n */\n private disableAllCustomCss(): void {\n for (const link of this.loadedCssLinks.values()) {\n link.disabled = true;\n }\n }\n\n // ========================================\n // THEME RESOLUTION\n // ========================================\n\n /**\n * Resolve a preference string to an actual theme ID.\n * 'system' resolves to 'light' or 'dark' based on OS preference.\n * Unrecognized IDs fall back to 'light'.\n */\n private resolveTheme(preference: string): string {\n if (preference === 'system') {\n return this.getSystemTheme();\n }\n\n // If the preference is a registered theme, use it directly\n if (this.themeRegistry.has(preference)) {\n return preference;\n }\n\n // Unrecognized theme ID — fall back to light\n return 'light';\n }\n\n /**\n * Get system theme preference from OS\n */\n private getSystemTheme(): 'light' | 'dark' {\n if (typeof window === 'undefined') {\n return 'light';\n }\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n }\n\n /**\n * Setup listener for system theme changes\n */\n private setupSystemThemeListener(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n this.systemMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n this.boundSystemThemeHandler = () => this.onSystemThemeChange();\n this.systemMediaQuery.addEventListener('change', this.boundSystemThemeHandler);\n }\n\n /**\n * Handle system theme change (only applies if in 'system' mode)\n */\n private async onSystemThemeChange(): Promise<void> {\n if (this._preference$.value === 'system') {\n const newThemeId = this.getSystemTheme();\n await this.applyTheme(newThemeId);\n }\n }\n\n // ========================================\n // PERSISTENCE\n // ========================================\n\n /**\n * Load theme preference from User Settings.\n * Accepts any registered theme ID or 'system'.\n * Falls back to 'system' if saved value is not recognized.\n */\n private async loadSetting(): Promise<string> {\n try {\n const engine = UserInfoEngine.Instance;\n const settingValue = engine.GetSetting(THEME_SETTING_KEY);\n\n if (!settingValue) {\n return 'system';\n }\n\n // Accept 'system' or any registered theme ID\n if (settingValue === 'system' || this.themeRegistry.has(settingValue)) {\n return settingValue;\n }\n\n // Saved theme no longer registered — fall back\n return 'system';\n } catch (error) {\n console.warn('Failed to load theme setting:', error);\n return 'system';\n }\n }\n\n /**\n * Save theme preference to User Settings\n */\n private async saveSetting(preference: string): Promise<void> {\n try {\n const engine = UserInfoEngine.Instance;\n await engine.SetSetting(THEME_SETTING_KEY, preference);\n } catch (error) {\n console.warn('Failed to save theme setting:', error);\n }\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export * from './lib/module';
2
2
  export * from './lib/recent-access.service';
3
+ export * from './lib/theme.service';
3
4
  export * from './lib/loading/loading.component';
4
5
  //# sourceMappingURL=public-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAC;AAG7B,cAAc,6BAA6B,CAAC;AAG5C,cAAc,iCAAiC,CAAC"}
1
+ {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAC;AAG7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AAGpC,cAAc,iCAAiC,CAAC"}
@@ -5,6 +5,7 @@
5
5
  export * from './lib/module';
6
6
  // Services
7
7
  export * from './lib/recent-access.service';
8
+ export * from './lib/theme.service';
8
9
  // Components
9
10
  export * from './lib/loading/loading.component';
10
11
  //# sourceMappingURL=public-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,SAAS;AACT,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,6BAA6B,CAAC;AAE5C,aAAa;AACb,cAAc,iCAAiC,CAAC"}
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,SAAS;AACT,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AAEpC,aAAa;AACb,cAAc,iCAAiC,CAAC","sourcesContent":["/*\n * Public API Surface for @memberjunction/ng-shared-generic\n */\n\n// Module\nexport * from './lib/module';\n\n// Services\nexport * from './lib/recent-access.service';\nexport * from './lib/theme.service';\n\n// Components\nexport * from './lib/loading/loading.component';\n"]}