fix(CssManager): Make CssManager a singleton and export the shared instance via getSingleton; update tests and dependencies
This commit is contained in:
@@ -1,5 +1,14 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-11-16 - 2.1.3 - fix(CssManager)
|
||||||
|
Make CssManager a singleton and export the shared instance via getSingleton; update tests and dependencies
|
||||||
|
|
||||||
|
- Convert CssManager to a singleton by adding a private static instance and a public static getSingleton() method.
|
||||||
|
- Use CssManager.getSingleton() for the exported cssManager in ts/index.ts to ensure a single shared instance across the app.
|
||||||
|
- Add a Chromium-focused test (test.chromium.ts) and remove the browser-specific test file.
|
||||||
|
- Bump devDependencies (@git.zone/tsbuild, @git.zone/tsbundle, @git.zone/tstest) and update lit to ^3.3.1.
|
||||||
|
- Add readme.hints.md documenting the CssManager singleton pattern and supported access patterns.
|
||||||
|
|
||||||
## 2025-07-06 - 2.1.2 - fix(build)
|
## 2025-07-06 - 2.1.2 - fix(build)
|
||||||
Update build script in package.json to include 'tsfolders' in tsbuild command
|
Update build script in package.json to include 'tsfolders' in tsbuild command
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.6.4",
|
"@git.zone/tsbuild": "^2.7.1",
|
||||||
"@git.zone/tsbundle": "^2.4.0",
|
"@git.zone/tsbundle": "^2.5.1",
|
||||||
"@git.zone/tstest": "^2.3.1",
|
"@git.zone/tstest": "^2.7.0",
|
||||||
"@push.rocks/tapbundle": "^6.0.3",
|
"@push.rocks/tapbundle": "^6.0.3",
|
||||||
"@types/node": "^22.14.1"
|
"@types/node": "^22.14.1"
|
||||||
},
|
},
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"@design.estate/dees-domtools": "^2.3.3",
|
"@design.estate/dees-domtools": "^2.3.3",
|
||||||
"@push.rocks/isounique": "^1.0.5",
|
"@push.rocks/isounique": "^1.0.5",
|
||||||
"@push.rocks/smartrx": "^3.0.10",
|
"@push.rocks/smartrx": "^3.0.10",
|
||||||
"lit": "^3.3.0"
|
"lit": "^3.3.1"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
|
|||||||
3849
pnpm-lock.yaml
generated
3849
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1 +1,15 @@
|
|||||||
|
# Project Hints
|
||||||
|
|
||||||
|
## CssManager Singleton Pattern
|
||||||
|
|
||||||
|
**Location:** `ts/classes.cssmanager.ts`
|
||||||
|
|
||||||
|
The `CssManager` class uses a singleton pattern:
|
||||||
|
- **Static method:** `CssManager.getSingleton()` - Returns the singleton instance
|
||||||
|
- **Exported instance:** `cssManager` (from `ts/index.ts`) - Uses `getSingleton()` internally
|
||||||
|
|
||||||
|
Both access patterns are supported for backward compatibility:
|
||||||
|
- `cssManager.method()` - Legacy pattern (still works)
|
||||||
|
- `CssManager.getSingleton().method()` - Preferred pattern
|
||||||
|
|
||||||
|
The singleton ensures only one instance manages CSS variables and theme changes throughout the application.
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@design.estate/dees-element',
|
name: '@design.estate/dees-element',
|
||||||
version: '2.1.2',
|
version: '2.1.3',
|
||||||
description: 'A library for creating custom elements extending the lit element class with additional functionalities.'
|
description: 'A library for creating custom elements extending the lit element class with additional functionalities.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,21 @@ export interface IBdVarTriplet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class CssManager {
|
export class CssManager {
|
||||||
|
// STATIC
|
||||||
|
private static instance: CssManager | null = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the singleton instance of CssManager
|
||||||
|
*/
|
||||||
|
public static getSingleton(): CssManager {
|
||||||
|
if (!CssManager.instance) {
|
||||||
|
CssManager.instance = new CssManager();
|
||||||
|
}
|
||||||
|
return CssManager.instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
public domtoolsPromise = domtools.DomTools.setupDomTools();
|
public domtoolsPromise = domtools.DomTools.setupDomTools();
|
||||||
public goBright: boolean = false;
|
public goBright: boolean = false;
|
||||||
public bdVarTripletStore: IBdVarTriplet[] = [];
|
public bdVarTripletStore: IBdVarTriplet[] = [];
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export { directives };
|
|||||||
/**
|
/**
|
||||||
* a singleton instance of CssManager
|
* a singleton instance of CssManager
|
||||||
*/
|
*/
|
||||||
export const cssManager = new CssManager();
|
export const cssManager = CssManager.getSingleton();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user