@su-labs/theme 19.3.1 → 20.3.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.
package/README.md CHANGED
@@ -100,24 +100,24 @@ that share one saved theme (see `storage`) can offer different sets.
100
100
  You can install this library via npm:
101
101
 
102
102
  ```sh
103
- npm install @su-labs/theme@ng19
103
+ npm install @su-labs/theme@ng20
104
104
  ```
105
105
 
106
- This is the Angular 19 version. For the newest Angular, install `@su-labs/theme` without a tag.
106
+ This is the Angular 20 version. For the newest Angular, install `@su-labs/theme` without a tag.
107
107
 
108
108
  ## Peer Dependencies
109
109
 
110
110
  This library requires the following peer dependencies:
111
111
 
112
112
  ```sh
113
- npm install @angular/common@^19 @angular/core@^19
113
+ npm install @angular/common@^20 @angular/core@^20
114
114
  ```
115
115
 
116
116
  ## Quick Start
117
117
 
118
118
  ```typescript
119
119
  // 1. Install
120
- npm install @su-labs/theme@ng19
120
+ npm install @su-labs/theme@ng20
121
121
 
122
122
  // 2. Initialize in app.config.ts
123
123
  import { provideAppInitializer, inject } from '@angular/core';
@@ -289,7 +289,7 @@ Works in all modern browsers that support:
289
289
  - CSS Custom Properties
290
290
  - localStorage API
291
291
  - matchMedia (for system theme)
292
- - Angular 19
292
+ - Angular 20
293
293
  - ES2022+
294
294
 
295
295
  | Browser | Version |
@@ -324,7 +324,7 @@ Check that your OS has a theme preference set and your browser supports `prefers
324
324
 
325
325
  ### TypeScript errors?
326
326
 
327
- Ensure you have Angular 19 and TypeScript 5.5+ installed.
327
+ Ensure you have Angular 20 and TypeScript 5.8+ installed.
328
328
 
329
329
  ## Support
330
330
 
@@ -13,7 +13,7 @@ class SuThemeService {
13
13
  /** Framework-agnostic theme logic */
14
14
  controller = new SuThemeController();
15
15
  /** Current resolved theme signal, kept in sync with the controller */
16
- currentThemeSignal = signal(this.controller.getTheme());
16
+ currentThemeSignal = signal(this.controller.getTheme(), ...(ngDevMode ? [{ debugName: "currentThemeSignal" }] : []));
17
17
  /** Read-only access to the resolved theme signal */
18
18
  theme = this.currentThemeSignal.asReadonly();
19
19
  /** Stops syncing the controller's theme into the signal */
@@ -64,10 +64,10 @@ class SuThemeService {
64
64
  this.unsubscribe();
65
65
  this.controller.destroy();
66
66
  }
67
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SuThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
68
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SuThemeService, providedIn: 'root' });
67
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
68
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuThemeService, providedIn: 'root' });
69
69
  }
70
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SuThemeService, decorators: [{
70
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuThemeService, decorators: [{
71
71
  type: Injectable,
72
72
  args: [{
73
73
  providedIn: 'root',
@@ -1 +1 @@
1
- {"version":3,"file":"su-labs-theme.mjs","sources":["../../../../compat/angular-19/build/theme/src/lib/theme.service.ts","../../../../compat/angular-19/build/theme/src/su-labs-theme.ts"],"sourcesContent":["import { Injectable, OnDestroy, signal } from '@angular/core';\nimport { SuThemeConfig, SuThemeController, SuThemeName } from '@su-labs/core/theme';\n\n/**\n * Angular service for managing application themes.\n *\n * Thin wrapper around the framework-agnostic `SuThemeController` from `@su-labs/core/theme`\n * that exposes the resolved theme as an Angular signal.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class SuThemeService implements OnDestroy {\n /** Framework-agnostic theme logic */\n private readonly controller = new SuThemeController();\n\n /** Current resolved theme signal, kept in sync with the controller */\n private readonly currentThemeSignal = signal<SuThemeName>(this.controller.getTheme());\n\n /** Read-only access to the resolved theme signal */\n readonly theme = this.currentThemeSignal.asReadonly();\n\n /** Stops syncing the controller's theme into the signal */\n private readonly unsubscribe = this.controller.theme.subscribe((theme) => this.currentThemeSignal.set(theme));\n\n /**\n * Initialize the service with optional configuration.\n * Should be called from an app initializer for default setup.\n * @param config Optional configuration object.\n */\n public init(config?: SuThemeConfig): void {\n this.controller.init(config);\n }\n\n /**\n * Get the currently active, resolved theme.\n * @returns The resolved theme name ('light', 'dark', 'contrast', 'custom').\n */\n public getTheme(): SuThemeName {\n return this.currentThemeSignal();\n }\n\n /**\n * Get the user's theme preference (may be 'system').\n * @returns The user preference ('light', 'dark', 'contrast', 'custom', 'system').\n */\n public getUserPreference(): SuThemeName {\n return this.controller.getUserPreference();\n }\n\n /** The themes this site offers: the base themes, then the palettes listed in the config's `palettes` */\n public availableThemes(): SuThemeName[] {\n return this.controller.availableThemes();\n }\n\n /**\n * Whether a theme can be set here: a base theme, or a listed palette.\n * @param theme Any theme name.\n */\n public isAvailable(theme: string): theme is SuThemeName {\n return this.controller.isAvailable(theme);\n }\n\n /**\n * Set a new theme. A palette the config doesn't list is ignored.\n * @param theme The theme to set ('light', 'dark', 'contrast', 'custom', 'system', or a listed palette).\n * @param persist Whether to store the preference in localStorage (default: true).\n */\n public setTheme(theme: SuThemeName, persist: boolean = true): void {\n this.controller.setTheme(theme, persist);\n }\n\n /** Angular lifecycle hook for service destruction */\n ngOnDestroy(): void {\n this.unsubscribe();\n this.controller.destroy();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAGA;;;;;AAKG;MAIU,cAAc,CAAA;;AAER,IAAA,UAAU,GAAG,IAAI,iBAAiB,EAAE;;IAGpC,kBAAkB,GAAG,MAAM,CAAc,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;;AAG5E,IAAA,KAA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,EAAA,UAAA,EAAA,CAAA;kBAH1B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACXD;;AAEG;;;;"}
1
+ {"version":3,"file":"su-labs-theme.mjs","sources":["../../../../compat/angular-20/build/theme/src/lib/theme.service.ts","../../../../compat/angular-20/build/theme/src/su-labs-theme.ts"],"sourcesContent":["import { Injectable, OnDestroy, signal } from '@angular/core';\nimport { SuThemeConfig, SuThemeController, SuThemeName } from '@su-labs/core/theme';\n\n/**\n * Angular service for managing application themes.\n *\n * Thin wrapper around the framework-agnostic `SuThemeController` from `@su-labs/core/theme`\n * that exposes the resolved theme as an Angular signal.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class SuThemeService implements OnDestroy {\n /** Framework-agnostic theme logic */\n private readonly controller = new SuThemeController();\n\n /** Current resolved theme signal, kept in sync with the controller */\n private readonly currentThemeSignal = signal<SuThemeName>(this.controller.getTheme());\n\n /** Read-only access to the resolved theme signal */\n readonly theme = this.currentThemeSignal.asReadonly();\n\n /** Stops syncing the controller's theme into the signal */\n private readonly unsubscribe = this.controller.theme.subscribe((theme) => this.currentThemeSignal.set(theme));\n\n /**\n * Initialize the service with optional configuration.\n * Should be called from an app initializer for default setup.\n * @param config Optional configuration object.\n */\n public init(config?: SuThemeConfig): void {\n this.controller.init(config);\n }\n\n /**\n * Get the currently active, resolved theme.\n * @returns The resolved theme name ('light', 'dark', 'contrast', 'custom').\n */\n public getTheme(): SuThemeName {\n return this.currentThemeSignal();\n }\n\n /**\n * Get the user's theme preference (may be 'system').\n * @returns The user preference ('light', 'dark', 'contrast', 'custom', 'system').\n */\n public getUserPreference(): SuThemeName {\n return this.controller.getUserPreference();\n }\n\n /** The themes this site offers: the base themes, then the palettes listed in the config's `palettes` */\n public availableThemes(): SuThemeName[] {\n return this.controller.availableThemes();\n }\n\n /**\n * Whether a theme can be set here: a base theme, or a listed palette.\n * @param theme Any theme name.\n */\n public isAvailable(theme: string): theme is SuThemeName {\n return this.controller.isAvailable(theme);\n }\n\n /**\n * Set a new theme. A palette the config doesn't list is ignored.\n * @param theme The theme to set ('light', 'dark', 'contrast', 'custom', 'system', or a listed palette).\n * @param persist Whether to store the preference in localStorage (default: true).\n */\n public setTheme(theme: SuThemeName, persist: boolean = true): void {\n this.controller.setTheme(theme, persist);\n }\n\n /** Angular lifecycle hook for service destruction */\n ngOnDestroy(): void {\n this.unsubscribe();\n this.controller.destroy();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAGA;;;;;AAKG;MAIU,cAAc,CAAA;;AAER,IAAA,UAAU,GAAG,IAAI,iBAAiB,EAAE;;IAGpC,kBAAkB,GAAG,MAAM,CAAc,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,oBAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAC;;AAG5E,IAAA,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAAE;;IAGpC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAE7G;;;;AAIG;AACI,IAAA,IAAI,CAAC,MAAsB,EAAA;AAChC,QAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9B;AAEA;;;AAGG;IACI,QAAQ,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,kBAAkB,EAAE;IAClC;AAEA;;;AAGG;IACI,iBAAiB,GAAA;AACtB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE;IAC5C;;IAGO,eAAe,GAAA;AACpB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE;IAC1C;AAEA;;;AAGG;AACI,IAAA,WAAW,CAAC,KAAa,EAAA;QAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC;IAC3C;AAEA;;;;AAIG;AACI,IAAA,QAAQ,CAAC,KAAkB,EAAE,OAAA,GAAmB,IAAI,EAAA;QACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAC1C;;IAGA,WAAW,GAAA;QACT,IAAI,CAAC,WAAW,EAAE;AAClB,QAAA,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;IAC3B;wGAhEW,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAd,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,cAFb,MAAM,EAAA,CAAA;;4FAEP,cAAc,EAAA,UAAA,EAAA,CAAA;kBAH1B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACXD;;AAEG;;;;"}
package/index.d.ts CHANGED
@@ -1,5 +1,56 @@
1
+ import * as i0 from '@angular/core';
2
+ import { OnDestroy } from '@angular/core';
3
+ import { SuThemeName, SuThemeConfig } from '@su-labs/core/theme';
4
+ export { SU_BASE_THEME_NAMES, SU_PALETTE_NAMES, SU_THEME_PALETTES, SuBaseThemeName, SuPaletteName, SuThemeConfig, SuThemeName, SuThemePalette, SuThemeScheme, ThemeCssVariables, isSuBaseThemeName } from '@su-labs/core/theme';
5
+
1
6
  /**
2
- * Generated bundle index. Do not edit.
7
+ * Angular service for managing application themes.
8
+ *
9
+ * Thin wrapper around the framework-agnostic `SuThemeController` from `@su-labs/core/theme`
10
+ * that exposes the resolved theme as an Angular signal.
3
11
  */
4
- /// <amd-module name="@su-labs/theme" />
5
- export * from './public-api';
12
+ declare class SuThemeService implements OnDestroy {
13
+ /** Framework-agnostic theme logic */
14
+ private readonly controller;
15
+ /** Current resolved theme signal, kept in sync with the controller */
16
+ private readonly currentThemeSignal;
17
+ /** Read-only access to the resolved theme signal */
18
+ readonly theme: i0.Signal<SuThemeName>;
19
+ /** Stops syncing the controller's theme into the signal */
20
+ private readonly unsubscribe;
21
+ /**
22
+ * Initialize the service with optional configuration.
23
+ * Should be called from an app initializer for default setup.
24
+ * @param config Optional configuration object.
25
+ */
26
+ init(config?: SuThemeConfig): void;
27
+ /**
28
+ * Get the currently active, resolved theme.
29
+ * @returns The resolved theme name ('light', 'dark', 'contrast', 'custom').
30
+ */
31
+ getTheme(): SuThemeName;
32
+ /**
33
+ * Get the user's theme preference (may be 'system').
34
+ * @returns The user preference ('light', 'dark', 'contrast', 'custom', 'system').
35
+ */
36
+ getUserPreference(): SuThemeName;
37
+ /** The themes this site offers: the base themes, then the palettes listed in the config's `palettes` */
38
+ availableThemes(): SuThemeName[];
39
+ /**
40
+ * Whether a theme can be set here: a base theme, or a listed palette.
41
+ * @param theme Any theme name.
42
+ */
43
+ isAvailable(theme: string): theme is SuThemeName;
44
+ /**
45
+ * Set a new theme. A palette the config doesn't list is ignored.
46
+ * @param theme The theme to set ('light', 'dark', 'contrast', 'custom', 'system', or a listed palette).
47
+ * @param persist Whether to store the preference in localStorage (default: true).
48
+ */
49
+ setTheme(theme: SuThemeName, persist?: boolean): void;
50
+ /** Angular lifecycle hook for service destruction */
51
+ ngOnDestroy(): void;
52
+ static ɵfac: i0.ɵɵFactoryDeclaration<SuThemeService, never>;
53
+ static ɵprov: i0.ɵɵInjectableDeclaration<SuThemeService>;
54
+ }
55
+
56
+ export { SuThemeService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@su-labs/theme",
3
- "version": "19.3.1",
3
+ "version": "20.3.1",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "theme",
@@ -33,8 +33,8 @@
33
33
  "url": "https://github.com/Greezaaa/settings-utils-lib/issues"
34
34
  },
35
35
  "peerDependencies": {
36
- "@angular/common": "^19.0.0",
37
- "@angular/core": "^19.0.0"
36
+ "@angular/common": "^20.0.0",
37
+ "@angular/core": "^20.0.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "@su-labs/core": "1.9.0",
@@ -1,52 +0,0 @@
1
- import { OnDestroy } from '@angular/core';
2
- import { SuThemeConfig, SuThemeName } from '@su-labs/core/theme';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * Angular service for managing application themes.
6
- *
7
- * Thin wrapper around the framework-agnostic `SuThemeController` from `@su-labs/core/theme`
8
- * that exposes the resolved theme as an Angular signal.
9
- */
10
- export declare class SuThemeService implements OnDestroy {
11
- /** Framework-agnostic theme logic */
12
- private readonly controller;
13
- /** Current resolved theme signal, kept in sync with the controller */
14
- private readonly currentThemeSignal;
15
- /** Read-only access to the resolved theme signal */
16
- readonly theme: import("@angular/core").Signal<SuThemeName>;
17
- /** Stops syncing the controller's theme into the signal */
18
- private readonly unsubscribe;
19
- /**
20
- * Initialize the service with optional configuration.
21
- * Should be called from an app initializer for default setup.
22
- * @param config Optional configuration object.
23
- */
24
- init(config?: SuThemeConfig): void;
25
- /**
26
- * Get the currently active, resolved theme.
27
- * @returns The resolved theme name ('light', 'dark', 'contrast', 'custom').
28
- */
29
- getTheme(): SuThemeName;
30
- /**
31
- * Get the user's theme preference (may be 'system').
32
- * @returns The user preference ('light', 'dark', 'contrast', 'custom', 'system').
33
- */
34
- getUserPreference(): SuThemeName;
35
- /** The themes this site offers: the base themes, then the palettes listed in the config's `palettes` */
36
- availableThemes(): SuThemeName[];
37
- /**
38
- * Whether a theme can be set here: a base theme, or a listed palette.
39
- * @param theme Any theme name.
40
- */
41
- isAvailable(theme: string): theme is SuThemeName;
42
- /**
43
- * Set a new theme. A palette the config doesn't list is ignored.
44
- * @param theme The theme to set ('light', 'dark', 'contrast', 'custom', 'system', or a listed palette).
45
- * @param persist Whether to store the preference in localStorage (default: true).
46
- */
47
- setTheme(theme: SuThemeName, persist?: boolean): void;
48
- /** Angular lifecycle hook for service destruction */
49
- ngOnDestroy(): void;
50
- static ɵfac: i0.ɵɵFactoryDeclaration<SuThemeService, never>;
51
- static ɵprov: i0.ɵɵInjectableDeclaration<SuThemeService>;
52
- }
package/public-api.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './lib/theme.service';
2
- export type { SuBaseThemeName, SuPaletteName, SuThemePalette, SuThemeScheme, SuThemeConfig, SuThemeName, ThemeCssVariables, } from '@su-labs/core/theme';
3
- export { isSuBaseThemeName, SU_BASE_THEME_NAMES, SU_PALETTE_NAMES, SU_THEME_PALETTES } from '@su-labs/core/theme';