@sixbell-telco/sdk 1.4.0 → 1.5.0

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +410 -472
  3. package/fesm2022/sixbell-telco-sdk-utils-logger.mjs +578 -0
  4. package/fesm2022/sixbell-telco-sdk-utils-logger.mjs.map +1 -0
  5. package/fesm2022/sixbell-telco-sdk-utils-resource-loader.mjs +1222 -0
  6. package/fesm2022/sixbell-telco-sdk-utils-resource-loader.mjs.map +1 -0
  7. package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +1434 -180
  8. package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -1
  9. package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +734 -182
  10. package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -1
  11. package/package.json +64 -56
  12. package/utils/logger/README.md +539 -0
  13. package/utils/logger/index.d.ts +5 -0
  14. package/utils/logger/public-api.d.ts +3 -0
  15. package/utils/logger/src/constants.d.ts +15 -0
  16. package/utils/logger/src/logger.service.d.ts +123 -0
  17. package/utils/logger/src/models/logger.d.ts +25 -0
  18. package/utils/logger/src/providers/logger.provider.d.ts +3 -0
  19. package/utils/resource-loader/README.md +460 -0
  20. package/utils/resource-loader/index.d.ts +5 -0
  21. package/utils/resource-loader/public-api.d.ts +1 -0
  22. package/utils/resource-loader/src/cache/index.d.ts +2 -0
  23. package/utils/resource-loader/src/cache/layers/factory.d.ts +38 -0
  24. package/utils/resource-loader/src/cache/layers/index.d.ts +3 -0
  25. package/utils/resource-loader/src/cache/layers/indexed-db-cache.d.ts +118 -0
  26. package/utils/resource-loader/src/cache/layers/local-storage-cache.d.ts +86 -0
  27. package/utils/resource-loader/src/cache/layers/memory-cache.d.ts +76 -0
  28. package/utils/resource-loader/src/cache/types.d.ts +107 -0
  29. package/utils/resource-loader/src/config/index.d.ts +1 -0
  30. package/utils/resource-loader/src/config/load-config.d.ts +32 -0
  31. package/utils/resource-loader/src/constants.d.ts +38 -0
  32. package/utils/resource-loader/src/http/index.d.ts +1 -0
  33. package/utils/resource-loader/src/http/retryable-client.d.ts +43 -0
  34. package/utils/resource-loader/src/index.d.ts +1 -0
  35. package/utils/resource-loader/src/resource-loader.d.ts +67 -0
  36. package/utils/resource-loader/src/types.d.ts +152 -0
  37. package/utils/resource-loader/src/utils/cache-validator.d.ts +72 -0
  38. package/utils/resource-loader/src/utils/helpers.d.ts +15 -0
  39. package/utils/resource-loader/src/utils/index.d.ts +2 -0
  40. package/utils/theme/README.md +1054 -109
  41. package/utils/theme/public-api.d.ts +9 -1
  42. package/utils/theme/src/constants.d.ts +74 -0
  43. package/utils/theme/src/models/theme.d.ts +288 -0
  44. package/utils/theme/src/providers/constants.d.ts +7 -0
  45. package/utils/theme/src/providers/theme.provider.d.ts +13 -0
  46. package/utils/theme/src/providers/theme.provider.types.d.ts +29 -0
  47. package/utils/theme/src/theme-assets/theme-assets.service.d.ts +214 -0
  48. package/utils/theme/src/theme-assets/theme-assets.types.d.ts +10 -0
  49. package/utils/theme/src/theme-dom/theme-dom.service.d.ts +87 -0
  50. package/utils/theme/src/theme-scheme/theme-scheme.service.d.ts +44 -0
  51. package/utils/theme/src/theme-storage/theme-storage.service.d.ts +47 -0
  52. package/utils/theme/src/theme.service.d.ts +40 -186
  53. package/utils/theme/src/utils/utils.d.ts +86 -0
  54. package/utils/translation/README.md +1414 -176
  55. package/utils/translation/public-api.d.ts +6 -0
  56. package/utils/translation/src/constants.d.ts +52 -0
  57. package/utils/translation/src/models/translation.d.ts +59 -0
  58. package/utils/translation/src/providers/constants.d.ts +11 -0
  59. package/utils/translation/src/providers/translation.provider.d.ts +73 -0
  60. package/utils/translation/src/providers/translation.provider.types.d.ts +26 -0
  61. package/utils/translation/src/translation-dom/translation-dom.service.d.ts +26 -0
  62. package/utils/translation/src/translation-storage/translation-storage.service.d.ts +34 -0
  63. package/utils/translation/src/translation.service.d.ts +19 -166
@@ -1 +1,9 @@
1
- export * from './src/theme.service';
1
+ export * from './src/constants';
2
+ export * from './src/models/theme';
3
+ export * from './src/providers/theme.provider';
4
+ export { ThemeAssetsService } from './src/theme-assets/theme-assets.service';
5
+ export { ThemeDomService } from './src/theme-dom/theme-dom.service';
6
+ export { ThemeSchemeService } from './src/theme-scheme/theme-scheme.service';
7
+ export { ThemeStorageService } from './src/theme-storage/theme-storage.service';
8
+ export { ThemeService } from './src/theme.service';
9
+ export * from './src/utils/utils';
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Theme Constants and Injection Tokens
3
+ * Centralized configuration values and DI tokens following Single Responsibility Principle
4
+ */
5
+ import { InjectionToken } from '@angular/core';
6
+ import { RuntimeThemeConfig, ThemeConfig } from './models/theme';
7
+ /**
8
+ * Default base theme - always available unless explicitly excluded
9
+ * This is the foundational theme that comes with the SDK
10
+ */
11
+ export declare const DEFAULT_BASE_THEME: "sixbell_telco";
12
+ /**
13
+ * List of default themes available out of the box
14
+ */
15
+ export declare const DEFAULT_THEMES: readonly ["sixbell_telco"];
16
+ /**
17
+ * Type-safe default theme codes for IDE IntelliSense
18
+ */
19
+ export declare const DEFAULT_THEME_CODES: readonly ["sixbell_telco"];
20
+ /**
21
+ * Type representing valid default theme codes
22
+ */
23
+ export type DefaultThemeCode = (typeof DEFAULT_THEME_CODES)[number];
24
+ /**
25
+ * LocalStorage key for persisting selected theme
26
+ */
27
+ export declare const THEME_STORAGE_THEME_KEY: "selectedTheme";
28
+ /**
29
+ * LocalStorage key for persisting selected scheme
30
+ */
31
+ export declare const THEME_STORAGE_SCHEME_KEY: "selectedScheme";
32
+ /**
33
+ * Namespace for storage keys to prevent collisions with other apps
34
+ */
35
+ export declare const THEME_STORAGE_NAMESPACE: "theme:";
36
+ /**
37
+ * HTML attribute name for setting the active theme on document body
38
+ */
39
+ export declare const THEME_ATTRIBUTE_NAME: "data-theme";
40
+ /**
41
+ * Separator used when combining theme name and scheme into a theme identifier
42
+ * @example "sixbell_telco__light" (theme__scheme format)
43
+ */
44
+ export declare const THEME_SCHEME_SEPARATOR: "__";
45
+ /**
46
+ * Default theme scheme preference
47
+ */
48
+ export declare const DEFAULT_SCHEME: "system";
49
+ /**
50
+ * All valid scheme values
51
+ */
52
+ export declare const VALID_SCHEMES: readonly ["system", "light", "dark"];
53
+ /**
54
+ * Minimal runtime configuration used as a resilient fallback when remote loading fails
55
+ */
56
+ export declare const FALLBACK_RUNTIME_THEME_CONFIG: RuntimeThemeConfig;
57
+ /**
58
+ * CSS class name applied to document when dark theme is detected
59
+ */
60
+ export declare const DARK_THEME_CLASS: "dark";
61
+ /**
62
+ * Media query for detecting system dark mode preference
63
+ */
64
+ export declare const DARK_MODE_MEDIA_QUERY: "(prefers-color-scheme: dark)";
65
+ /**
66
+ * Injection token for theme configuration
67
+ * Used to provide static theme configuration at bootstrap
68
+ */
69
+ export declare const THEME_CONFIG_TOKEN: InjectionToken<ThemeConfig>;
70
+ /**
71
+ * Injection token for runtime theme configuration
72
+ * Used to provide dynamic runtime theme configuration loaded from JSON file
73
+ */
74
+ export declare const RUNTIME_THEME_CONFIG_TOKEN: InjectionToken<RuntimeThemeConfig>;
@@ -0,0 +1,288 @@
1
+ /**
2
+ * Supported color schemes for theme selection
3
+ */
4
+ export type ThemeScheme = 'system' | 'light' | 'dark';
5
+ /**
6
+ * Resolved scheme - always either 'light' or 'dark', never 'system'
7
+ * Used for actual rendering decisions where system preference has been resolved
8
+ */
9
+ export type ResolvedThemeScheme = 'light' | 'dark';
10
+ /**
11
+ * Font face style options
12
+ */
13
+ export type FontStyle = 'normal' | 'italic';
14
+ /**
15
+ * Asset (image) type for scheme-specific assets (logos, banners, illustrations)
16
+ * Maps light and dark variants for a single asset
17
+ * Supports partial assets (e.g., only light defined) with automatic fallback strategy
18
+ * @example { light: '/assets/logos/logo_light.svg', dark: '/assets/logos/logo_dark.svg' }
19
+ * @example { light: '/assets/logos/logo_light.svg' } - dark will fall back to light
20
+ */
21
+ export interface ThemeAsset {
22
+ /**
23
+ * Asset URL for light theme variant
24
+ * @example "/assets/logos/logo_light.svg"
25
+ */
26
+ light?: string;
27
+ /**
28
+ * Asset URL for dark theme variant
29
+ * @example "/assets/logos/logo_dark.svg"
30
+ */
31
+ dark?: string;
32
+ }
33
+ /**
34
+ * Asset definitions for a theme
35
+ * Contains all images, logos, banners, and illustrations used across the app
36
+ */
37
+ export interface ThemeAssets {
38
+ /**
39
+ * Logo(s) for the application or brand
40
+ * Can be a single asset or an object with multiple named logos
41
+ * @example
42
+ * Single: { light: '/assets/logo_light.svg', dark: '/assets/logo_dark.svg' }
43
+ * Multiple: { main: {...}, secondary: {...} }
44
+ */
45
+ logo?: ThemeAsset | Record<string, ThemeAsset>;
46
+ /**
47
+ * Navigation bar or header related images
48
+ * @example { light: '/assets/navbar_bg_light.svg', dark: '/assets/navbar_bg_dark.svg' }
49
+ */
50
+ navbar?: ThemeAsset | Record<string, ThemeAsset>;
51
+ /**
52
+ * Banner images used across the application
53
+ * @example { hero: {...}, section: {...} }
54
+ */
55
+ banners?: Record<string, ThemeAsset>;
56
+ /**
57
+ * Illustrations for empty states, errors, etc.
58
+ * @example { empty: {...}, error: {...}, notFound: {...} }
59
+ */
60
+ illustrations?: Record<string, ThemeAsset>;
61
+ /**
62
+ * Icons (can be used for animated or scheme-specific icons)
63
+ * @example { success: {...}, warning: {...} }
64
+ */
65
+ icons?: Record<string, ThemeAsset>;
66
+ /**
67
+ * Background images for different sections
68
+ * @example { header: {...}, footer: {...} }
69
+ */
70
+ backgrounds?: Record<string, ThemeAsset>;
71
+ /**
72
+ * Any other custom assets
73
+ */
74
+ [key: string]: ThemeAsset | Record<string, ThemeAsset> | undefined;
75
+ }
76
+ /**
77
+ * Font definition for runtime configuration
78
+ * Defines font family and font-face declarations
79
+ */
80
+ export interface FontDefinition {
81
+ /**
82
+ * Font family name
83
+ * @example "Poppins"
84
+ */
85
+ family: string;
86
+ /**
87
+ * Font display name
88
+ * @example "Poppins Sans-Serif"
89
+ */
90
+ displayName?: string;
91
+ /**
92
+ * Font faces (font-weight variants)
93
+ */
94
+ faces: FontFaceDefinition[];
95
+ }
96
+ /**
97
+ * Individual font face declaration
98
+ */
99
+ export interface FontFaceDefinition {
100
+ /**
101
+ * Font weight (400, 500, 600, 700, 800, 900)
102
+ */
103
+ weight: number;
104
+ /**
105
+ * Font style (normal or italic)
106
+ */
107
+ style: FontStyle;
108
+ /**
109
+ * URL to font file
110
+ * @example "./assets/fonts/Poppins-Regular.ttf"
111
+ */
112
+ src: string;
113
+ }
114
+ /**
115
+ * Theme style definition for runtime configuration
116
+ * Defines all CSS custom properties for a specific theme variant
117
+ */
118
+ export interface ThemeStyleDefinition {
119
+ /**
120
+ * Theme display name for UI
121
+ * @example "Sixbell Telco Light"
122
+ */
123
+ displayName?: string;
124
+ /**
125
+ * DaisyUI theme name (matches name in @plugin "daisyui/theme")
126
+ * @example "sixbell_telco__light"
127
+ */
128
+ daisyuiName: string;
129
+ /**
130
+ * Prefers dark mode for system scheme detection
131
+ * @example true for dark themes
132
+ */
133
+ prefersDark?: boolean;
134
+ /**
135
+ * CSS custom properties (variables) for this theme variant
136
+ * Maps CSS variable names to their values
137
+ * @example { "--color-primary": "oklch(...)", "--color-base-100": "oklch(...)" }
138
+ */
139
+ variables: Record<string, string>;
140
+ }
141
+ /**
142
+ * Theme variants container
143
+ * Maps 'light' and 'dark' variants for a single theme
144
+ */
145
+ export interface ThemeVariants {
146
+ light: ThemeStyleDefinition;
147
+ dark: ThemeStyleDefinition;
148
+ }
149
+ /**
150
+ * Runtime theme configuration loaded from JSON file
151
+ * Allows dynamic theme management without recompiling the application
152
+ * Includes all CSS variables, fonts, and theme definitions
153
+ */
154
+ export interface RuntimeThemeConfig {
155
+ /**
156
+ * Global CSS custom properties applied to all themes
157
+ * @example { "--border-radius": "0.25rem" }
158
+ */
159
+ globalVariables?: Record<string, string>;
160
+ /**
161
+ * Font definitions to load at runtime
162
+ * @example [{ family: "Poppins", faces: [...] }]
163
+ */
164
+ fonts?: FontDefinition[];
165
+ /**
166
+ * Theme definitions mapped by theme code
167
+ * Each theme should have light and dark variants
168
+ * @example { "sixbell_telco": { "light": {...}, "dark": {...} } }
169
+ */
170
+ themes: Record<string, ThemeVariants>;
171
+ /**
172
+ * Assets (images, logos, banners) for each theme
173
+ * Supports scheme-based variants and custom assets
174
+ * @example {
175
+ * "sixbell_telco": { logo: {...}, illustrations: {...} },
176
+ * "wom": { logo: {...}, illustrations: {...} }
177
+ * }
178
+ */
179
+ assets?: Record<string, ThemeAssets>;
180
+ /**
181
+ * List of all available theme codes (OPTIONAL - auto-derived from themes keys)
182
+ * If not provided, will be automatically extracted from the `themes` object keys
183
+ * @example ["sixbell_telco", "wom", "custom_dark"]
184
+ * @deprecated Prefer omitting this and letting it be auto-derived from themes keys
185
+ */
186
+ availableThemes?: string[];
187
+ /**
188
+ * Default theme to use on first load (OPTIONAL - defaults to first available theme)
189
+ * If not provided, the first theme in availableThemes will be used
190
+ * User's saved preference in localStorage takes precedence
191
+ * @example "sixbell_telco"
192
+ */
193
+ defaultTheme?: string;
194
+ /**
195
+ * Default color scheme preference (OPTIONAL - defaults to 'system')
196
+ * User's saved preference in localStorage takes precedence
197
+ * @example "system" | "light" | "dark"
198
+ */
199
+ defaultScheme?: ThemeScheme;
200
+ /**
201
+ * Themes to exclude from the available set (optional)
202
+ * @example ["custom_dark"]
203
+ */
204
+ excludeThemes?: string[];
205
+ }
206
+ /**
207
+ * Static theme configuration (compile-time)
208
+ * Base interface without additional themes
209
+ */
210
+ export interface ThemeConfigWithoutAdditionalThemes {
211
+ /**
212
+ * Default theme code (base theme: sixbell_telco)
213
+ * @example 'sixbell_telco'
214
+ */
215
+ defaultTheme?: string;
216
+ /**
217
+ * Themes to exclude from the available set
218
+ * @example ['sixbell_telco'] to exclude the default theme
219
+ */
220
+ excludeThemes?: readonly string[];
221
+ /**
222
+ * Default color scheme preference
223
+ * @example 'system' | 'light' | 'dark'
224
+ */
225
+ defaultScheme?: ThemeScheme;
226
+ }
227
+ /**
228
+ * Static theme configuration (compile-time)
229
+ * Interface with additional themes providing IntelliSense
230
+ */
231
+ export interface ThemeConfigWithAdditionalThemes<T extends readonly string[]> {
232
+ /**
233
+ * Additional themes to make available beyond the default base theme (sixbell_telco)
234
+ */
235
+ additionalThemes: T;
236
+ /**
237
+ * Default theme code
238
+ */
239
+ defaultTheme?: string;
240
+ /**
241
+ * Themes to exclude from the available set
242
+ */
243
+ excludeThemes?: readonly string[];
244
+ /**
245
+ * Default color scheme preference
246
+ */
247
+ defaultScheme?: ThemeScheme;
248
+ }
249
+ /**
250
+ * Main theme configuration interface
251
+ * Generic configuration supporting both static and runtime configurations
252
+ */
253
+ export interface ThemeConfig {
254
+ /**
255
+ * Additional themes to make available beyond the default base theme
256
+ */
257
+ additionalThemes?: readonly string[];
258
+ /**
259
+ * Default theme code
260
+ */
261
+ defaultTheme?: string;
262
+ /**
263
+ * Themes to exclude from the available set
264
+ */
265
+ excludeThemes?: readonly string[];
266
+ /**
267
+ * Default color scheme preference
268
+ */
269
+ defaultScheme?: ThemeScheme;
270
+ }
271
+ /**
272
+ * Internal theme state configuration
273
+ * Used internally by the service to track resolved configuration
274
+ */
275
+ export interface ThemeStateConfig {
276
+ /**
277
+ * All available themes after applying inclusions/exclusions
278
+ */
279
+ availableThemes: string[];
280
+ /**
281
+ * Currently selected default theme
282
+ */
283
+ defaultTheme: string;
284
+ /**
285
+ * Currently selected default scheme
286
+ */
287
+ defaultScheme: ThemeScheme;
288
+ }
@@ -0,0 +1,7 @@
1
+ import { ResourceLoaderRequestOptions } from '@sixbell-telco/sdk/utils/resource-loader';
2
+ import { RuntimeThemeConfig } from '../theme.service';
3
+ /**
4
+ * Theme-specific IndexedDB database name for resource caching
5
+ */
6
+ export declare const THEME_INDEXED_DB_NAME: "sixbell-theme";
7
+ export declare const RUNTIME_THEME_LOADER_DEFAULTS: ResourceLoaderRequestOptions<RuntimeThemeConfig>;
@@ -0,0 +1,13 @@
1
+ import { EnvironmentProviders } from '@angular/core';
2
+ import { ThemeScheme } from '../models/theme';
3
+ import { RuntimeThemeProviderOptions } from './theme.provider.types';
4
+ /**
5
+ * @deprecated Use provideRuntimeTheme instead.
6
+ */
7
+ export declare function provideTheme<const T extends readonly string[] = []>(config?: {
8
+ additionalThemes?: T;
9
+ defaultTheme?: string;
10
+ excludeThemes?: T extends readonly [string, ...string[]] ? readonly string[] : readonly string[];
11
+ defaultScheme?: ThemeScheme;
12
+ }): EnvironmentProviders;
13
+ export declare function provideRuntimeTheme(configPath: string, options?: RuntimeThemeProviderOptions): EnvironmentProviders;
@@ -0,0 +1,29 @@
1
+ import { ResourceLoader, ResourceLoaderRequestOptions } from '@sixbell-telco/sdk/utils/resource-loader';
2
+ import { RuntimeThemeConfig } from '../theme.service';
3
+ /**
4
+ * Configuration options for the runtime theme provider.
5
+ *
6
+ * @property loader - Custom loader instance (optional; uses default if not provided)
7
+ * @property loaderOptions - Loader configuration options (cache TTL, retries, storage, etc.)
8
+ * By default, `freshOnNavigation: true` (ResourceLoader default: always fetch fresh with
9
+ * fallback to cache). This ensures themes are always up-to-date and prevents stale data issues.
10
+ * Set `freshOnNavigation: false` in loaderOptions to disable and use aggressive caching (rare cases).
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Default mode: Always fetch fresh theme with fallback to cache on error
15
+ * provideRuntimeTheme('assets/themes/config.json')
16
+ *
17
+ * // Aggressive caching mode: Use cached data, only refetch if cache is stale
18
+ * provideRuntimeTheme('assets/themes/config.json', {
19
+ * loaderOptions: {
20
+ * freshOnNavigation: false, // Use cache first (rare, only for high-latency cases)
21
+ * retries: 3,
22
+ * },
23
+ * })
24
+ * ```
25
+ */
26
+ export interface RuntimeThemeProviderOptions {
27
+ loader?: ResourceLoader;
28
+ loaderOptions?: ResourceLoaderRequestOptions<RuntimeThemeConfig>;
29
+ }
@@ -0,0 +1,214 @@
1
+ import { ResolvedThemeScheme, RuntimeThemeConfig, ThemeAsset, ThemeAssets } from '../models/theme';
2
+ import * as i0 from "@angular/core";
3
+ export declare class ThemeAssetsService {
4
+ /**
5
+ * Signal holding current runtime configuration reference
6
+ * Used to look up asset definitions for the active theme
7
+ */
8
+ private config;
9
+ /**
10
+ * Layer 1: In-memory cache of resolved assets
11
+ * Maps "themeName:assetKey" to CachedAsset for fast retrieval
12
+ * Cleared when setConfig() is called to force re-resolution from new config
13
+ */
14
+ private assetCache;
15
+ /**
16
+ * Layer 2: Last working config storage (memory-based)
17
+ * Stores the most recent RuntimeThemeConfig that successfully resolved assets
18
+ * Persists across config updates as a complete fallback mechanism
19
+ * Similar to ThemeService's multi-layer config persistence
20
+ *
21
+ * When current config fails to provide an asset:
22
+ * - Falls back to the last complete working config
23
+ * - Handles asset removal, name changes, path changes
24
+ * - Automatically restores working state on config resets
25
+ * - No individual URL tracking - entire config stored once per successful load
26
+ */
27
+ private lastWorkingConfigLayer;
28
+ private logger;
29
+ constructor();
30
+ /**
31
+ * Initialize service with runtime configuration
32
+ * Called by ThemeService after loading configuration
33
+ *
34
+ * If new config successfully resolves assets, it becomes the new fallback layer.
35
+ * Otherwise, previous working config persists.
36
+ *
37
+ * Only updates Layer 2 if:
38
+ * - Config has no PARTIAL/BROKEN assets (missing variants)
39
+ * - Themes can be removed entirely (that's intentional)
40
+ * - But existing assets must be COMPLETE (both light and dark)
41
+ *
42
+ * This ensures that accidental removals of variants trigger fallback
43
+ * while intentional complete removals are allowed.
44
+ *
45
+ * @param config - Runtime configuration containing asset definitions
46
+ */
47
+ setConfig(config: RuntimeThemeConfig): void;
48
+ /**
49
+ * Internal: Check if config has any PARTIAL/BROKEN assets
50
+ * Returns true if ANY asset is incomplete (missing light or dark variant)
51
+ *
52
+ * A partial asset is invalid:
53
+ * - logo: { light: "..." } ← missing dark
54
+ * - logo: { dark: "..." } ← missing light
55
+ * - logo: {} ← missing both
56
+ *
57
+ * Complete removals are OK:
58
+ * - {} ← no assets at all (intentional)
59
+ * - theme: {} ← theme removed (intentional)
60
+ *
61
+ * @private
62
+ * @param config - Config to check
63
+ * @returns True if config has partial/broken assets, false if all complete or intentionally removed
64
+ */
65
+ private hasPartialAssets;
66
+ /**
67
+ * Internal: Check if a theme/asset object has ANY problematic assets
68
+ * Problematic assets are:
69
+ * - Partial assets: { light: "..." } or { dark: "..." } (missing variant)
70
+ * - Empty asset objects: { "logo": {} } (asset key exists but has no variants)
71
+ * - Broken nested assets at any level
72
+ *
73
+ * NOT problematic:
74
+ * - Completely empty themes: {} (all assets intentionally removed - OK to accept)
75
+ * - Missing themes (not in config at all)
76
+ *
77
+ * @private
78
+ * @param obj - Theme's asset object to check
79
+ * @returns True if object has problematic assets
80
+ */
81
+ private themeHasProblematicAssets;
82
+ /**
83
+ * Internal: Check if object is a PARTIAL asset (incomplete)
84
+ * Partial means it LOOKS LIKE an asset (has some scheme keys) but is missing variants
85
+ *
86
+ * @private
87
+ * @param obj - Object to check
88
+ * @returns True if object is a partial/incomplete asset
89
+ */
90
+ private isPartialAsset;
91
+ /**
92
+ * Get asset URL for the specified scheme
93
+ * Retrieves a specific asset variant (light or dark) with config-based fallback
94
+ *
95
+ * Resolution Strategy (in order):
96
+ * 1. Try to get the requested scheme variant from current config
97
+ * 2. If not available, use last working config from memory layer
98
+ * 3. If no last working config, return null
99
+ *
100
+ * This ensures:
101
+ * - Graceful degradation when assets are removed from config
102
+ * - Support for asset name changes, path changes, config resets
103
+ * - Automatic restoration when config is fixed
104
+ * - No automatic scheme switching (stays on requested scheme)
105
+ * - Similar to ThemeService's config persistence pattern
106
+ *
107
+ * @param themeName - Name of the theme (e.g., 'sixbell_telco', 'wom')
108
+ * @param assetKey - Asset identifier path (e.g., 'logo', 'banners.hero', 'illustrations.empty')
109
+ * @param scheme - Color scheme ('light' or 'dark')
110
+ * @returns Asset URL for the specified scheme, or from last working config, or null if not found
111
+ *
112
+ * @example
113
+ * // Current config has dark - returns requested variant
114
+ * getAssetUrl('wom', 'logo', 'dark')
115
+ * // Returns: '/assets/logos/logo_wom_dark.svg'
116
+ *
117
+ * // Current config missing dark - returns from last working config
118
+ * getAssetUrl('wom', 'logo', 'dark')
119
+ * // Returns: '/assets/logos/logo_wom_dark.svg' (from last working config layer)
120
+ *
121
+ * // Never existed - no working config
122
+ * getAssetUrl('wom', 'nonexistent', 'dark')
123
+ * // Returns: null
124
+ */
125
+ getAssetUrl(themeName: string, assetKey: string, scheme: ResolvedThemeScheme): string | null;
126
+ /**
127
+ * Internal: Resolve asset URL from a specific config
128
+ * Helper method to resolve URL from current or last working config
129
+ *
130
+ * Returns null if:
131
+ * - Asset not found
132
+ * - Asset is incomplete (missing either light or dark variant)
133
+ * - Requested scheme variant not available
134
+ *
135
+ * @private
136
+ * @param themeName - Theme name
137
+ * @param assetKey - Asset key path
138
+ * @param scheme - Scheme variant
139
+ * @param configToUse - Config to resolve from (current or lastWorking)
140
+ * @returns URL if found and complete, null otherwise
141
+ */
142
+ private resolveAssetUrl;
143
+ /**
144
+ * Get both light and dark variants of an asset
145
+ * Returns an object with both scheme variants for easy access
146
+ *
147
+ * @param themeName - Name of the theme
148
+ * @param assetKey - Asset identifier path
149
+ * @returns Object with light and dark URLs, or null if asset not found
150
+ *
151
+ * @example
152
+ * getAsset('wom', 'logo')
153
+ * // Returns: { light: '/assets/logos/logo_wom_light.svg', dark: '/assets/logos/logo_wom_dark.svg' }
154
+ */
155
+ getAsset(themeName: string, assetKey: string): ThemeAsset | null;
156
+ /**
157
+ * Check if an asset exists in the specified theme
158
+ * Useful for conditional rendering or fallback handling
159
+ *
160
+ * @param themeName - Name of the theme
161
+ * @param assetKey - Asset identifier path
162
+ * @returns True if the asset exists, false otherwise
163
+ *
164
+ * @example
165
+ * hasAsset('wom', 'logo') // true
166
+ * hasAsset('wom', 'nonexistent') // false
167
+ */
168
+ hasAsset(themeName: string, assetKey: string): boolean;
169
+ /**
170
+ * Get all assets for a specific theme
171
+ * Returns the complete asset set for further processing
172
+ *
173
+ * @param themeName - Name of the theme
174
+ * @returns All assets for the theme, or null if theme has no assets
175
+ */
176
+ getThemeAssets(themeName: string): ThemeAssets | null;
177
+ /**
178
+ * Manually clear the asset cache
179
+ * Typically called automatically by setConfig(), but can be used for:
180
+ * - Testing and debugging
181
+ * - Force cache refresh in special scenarios
182
+ *
183
+ * Note: The last-working-config layer is NOT cleared - only the config cache
184
+ * This allows the fallback mechanism to persist across manual cache clears
185
+ *
186
+ * @example
187
+ * // In tests
188
+ * assetsService.clearCache();
189
+ *
190
+ * @example
191
+ * // Force refresh (if config doesn't change but images do)
192
+ * assetsService.clearCache();
193
+ * assetsService.setConfig(currentConfig);
194
+ */
195
+ clearCache(): void;
196
+ /**
197
+ * Internal: Type guard to validate ThemeAsset structure
198
+ * Requires BOTH light and dark variants to be present
199
+ * Partial assets (missing either variant) are considered incomplete/broken
200
+ *
201
+ * Why both required:
202
+ * - Assets are designed to work with both light and dark themes
203
+ * - Missing variant indicates incomplete config (likely accidental removal)
204
+ * - Triggers fallback to last complete working config
205
+ * - Prevents partially broken configs from overwriting good state
206
+ *
207
+ * @private
208
+ * @param obj - Object to validate
209
+ * @returns True if object is a valid ThemeAsset (has BOTH light and dark)
210
+ */
211
+ private isThemeAsset;
212
+ static ɵfac: i0.ɵɵFactoryDeclaration<ThemeAssetsService, never>;
213
+ static ɵprov: i0.ɵɵInjectableDeclaration<ThemeAssetsService>;
214
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Cached asset entry
3
+ * Stores resolved asset URLs with optional scheme variants
4
+ */
5
+ export interface CachedAsset {
6
+ themeName: string;
7
+ assetKey: string;
8
+ light: string | null;
9
+ dark: string | null;
10
+ }