@codeleap/styles 6.2.3 → 6.8.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 (138) hide show
  1. package/dist/classes/Cacher.d.ts +87 -0
  2. package/dist/classes/Cacher.d.ts.map +1 -0
  3. package/dist/classes/StaleControl.d.ts +65 -0
  4. package/dist/classes/StaleControl.d.ts.map +1 -0
  5. package/dist/classes/StyleCache.d.ts +63 -0
  6. package/dist/classes/StyleCache.d.ts.map +1 -0
  7. package/dist/classes/StylePersistor.d.ts +52 -0
  8. package/dist/classes/StylePersistor.d.ts.map +1 -0
  9. package/dist/classes/StyleRegistry.d.ts +108 -0
  10. package/dist/classes/StyleRegistry.d.ts.map +1 -0
  11. package/dist/classes/index.d.ts +3 -0
  12. package/dist/classes/index.d.ts.map +1 -0
  13. package/dist/constants.d.ts +22 -0
  14. package/dist/constants.d.ts.map +1 -0
  15. package/dist/hooks/index.d.ts +5 -0
  16. package/dist/hooks/index.d.ts.map +1 -0
  17. package/dist/hooks/useCompositionStyles.d.ts +12 -0
  18. package/dist/hooks/useCompositionStyles.d.ts.map +1 -0
  19. package/dist/hooks/useNestedStylesByKey.d.ts +11 -0
  20. package/dist/hooks/useNestedStylesByKey.d.ts.map +1 -0
  21. package/dist/hooks/useStyleObserver.d.ts +9 -0
  22. package/dist/hooks/useStyleObserver.d.ts.map +1 -0
  23. package/dist/hooks/useTheme.d.ts +19 -0
  24. package/dist/hooks/useTheme.d.ts.map +1 -0
  25. package/dist/index.d.ts +12 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/lib/calc.d.ts +27 -0
  28. package/dist/lib/calc.d.ts.map +1 -0
  29. package/dist/lib/createStyles.d.ts +30 -0
  30. package/dist/lib/createStyles.d.ts.map +1 -0
  31. package/dist/lib/createTheme.d.ts +28 -0
  32. package/dist/lib/createTheme.d.ts.map +1 -0
  33. package/dist/lib/cssVariables.d.ts +35 -0
  34. package/dist/lib/cssVariables.d.ts.map +1 -0
  35. package/dist/lib/index.d.ts +5 -0
  36. package/dist/lib/index.d.ts.map +1 -0
  37. package/dist/theme/generateColorScheme.d.ts +22 -0
  38. package/dist/theme/generateColorScheme.d.ts.map +1 -0
  39. package/dist/theme/index.d.ts +4 -0
  40. package/dist/theme/index.d.ts.map +1 -0
  41. package/dist/theme/themeStore.d.ts +106 -0
  42. package/dist/theme/themeStore.d.ts.map +1 -0
  43. package/dist/theme/validateTheme.d.ts +19 -0
  44. package/dist/theme/validateTheme.d.ts.map +1 -0
  45. package/dist/tools/colors.d.ts +70 -0
  46. package/dist/tools/colors.d.ts.map +1 -0
  47. package/dist/tools/deepClone.d.ts +7 -0
  48. package/dist/tools/deepClone.d.ts.map +1 -0
  49. package/dist/tools/deepmerge.d.ts +13 -0
  50. package/dist/tools/deepmerge.d.ts.map +1 -0
  51. package/dist/tools/hashKey.d.ts +8 -0
  52. package/dist/tools/hashKey.d.ts.map +1 -0
  53. package/dist/tools/index.d.ts +7 -0
  54. package/dist/tools/index.d.ts.map +1 -0
  55. package/dist/tools/minifier.d.ts +24 -0
  56. package/dist/tools/minifier.d.ts.map +1 -0
  57. package/dist/tools/multiplierProperty.d.ts +4 -0
  58. package/dist/tools/multiplierProperty.d.ts.map +1 -0
  59. package/dist/types/cache.d.ts +12 -0
  60. package/dist/types/cache.d.ts.map +1 -0
  61. package/dist/types/component.d.ts +58 -0
  62. package/dist/types/component.d.ts.map +1 -0
  63. package/dist/types/core.d.ts +77 -0
  64. package/dist/types/core.d.ts.map +1 -0
  65. package/dist/types/icon.d.ts +15 -0
  66. package/dist/types/icon.d.ts.map +1 -0
  67. package/dist/types/index.d.ts +6 -0
  68. package/dist/types/index.d.ts.map +1 -0
  69. package/dist/types/spacing.d.ts +28 -0
  70. package/dist/types/spacing.d.ts.map +1 -0
  71. package/dist/types/store.d.ts +12 -0
  72. package/dist/types/store.d.ts.map +1 -0
  73. package/dist/types/style.d.ts +42 -0
  74. package/dist/types/style.d.ts.map +1 -0
  75. package/dist/types/theme.d.ts +109 -0
  76. package/dist/types/theme.d.ts.map +1 -0
  77. package/dist/utils.d.ts +40 -0
  78. package/dist/utils.d.ts.map +1 -0
  79. package/dist/variants/borderCreator.d.ts +22 -0
  80. package/dist/variants/borderCreator.d.ts.map +1 -0
  81. package/dist/variants/createAppVariants.d.ts +18 -0
  82. package/dist/variants/createAppVariants.d.ts.map +1 -0
  83. package/dist/variants/defaultVariants.d.ts +140 -0
  84. package/dist/variants/defaultVariants.d.ts.map +1 -0
  85. package/dist/variants/dynamicVariants.d.ts +43 -0
  86. package/dist/variants/dynamicVariants.d.ts.map +1 -0
  87. package/dist/variants/index.d.ts +7 -0
  88. package/dist/variants/index.d.ts.map +1 -0
  89. package/dist/variants/mediaQuery.d.ts +30 -0
  90. package/dist/variants/mediaQuery.d.ts.map +1 -0
  91. package/dist/variants/spacing.d.ts +26 -0
  92. package/dist/variants/spacing.d.ts.map +1 -0
  93. package/package.json +19 -5
  94. package/src/classes/Cacher.ts +9 -9
  95. package/src/classes/StaleControl.ts +1 -1
  96. package/src/classes/StyleCache.ts +9 -3
  97. package/src/classes/StylePersistor.ts +11 -0
  98. package/src/classes/StyleRegistry.ts +124 -43
  99. package/src/classes/tests/StyleRegistry.spec.ts +169 -0
  100. package/src/constants.ts +14 -0
  101. package/src/hooks/useCompositionStyles.ts +9 -7
  102. package/src/hooks/useNestedStylesByKey.ts +8 -0
  103. package/src/hooks/useStyleObserver.ts +6 -5
  104. package/src/hooks/useTheme.ts +14 -0
  105. package/src/lib/calc.ts +13 -0
  106. package/src/lib/createStyles.ts +35 -4
  107. package/src/lib/createTheme.ts +74 -25
  108. package/src/lib/cssVariables.ts +74 -0
  109. package/src/lib/index.ts +2 -1
  110. package/src/lib/tests/createStyles.spec.ts +80 -23
  111. package/src/lib/tests/createStylesWithContext.spec.ts +108 -0
  112. package/src/tests/theme.ts +6 -2
  113. package/src/theme/generateColorScheme.ts +13 -10
  114. package/src/theme/tests/themeStore.spec.ts +72 -71
  115. package/src/theme/themeStore.ts +10 -7
  116. package/src/theme/validateTheme.ts +1 -1
  117. package/src/tools/colors.ts +24 -36
  118. package/src/tools/deepClone.ts +3 -5
  119. package/src/tools/deepmerge.ts +8 -6
  120. package/src/tools/hashKey.ts +4 -5
  121. package/src/tools/minifier.ts +11 -12
  122. package/src/tools/tests/deepClone.spec.ts +2 -2
  123. package/src/types/cache.ts +10 -0
  124. package/src/types/component.ts +41 -5
  125. package/src/types/core.ts +66 -6
  126. package/src/types/icon.ts +11 -0
  127. package/src/types/spacing.ts +21 -0
  128. package/src/types/store.ts +6 -0
  129. package/src/types/style.ts +37 -10
  130. package/src/types/theme.ts +37 -1
  131. package/src/utils.ts +34 -4
  132. package/src/variants/borderCreator.ts +14 -5
  133. package/src/variants/createAppVariants.ts +11 -0
  134. package/src/variants/defaultVariants.ts +28 -8
  135. package/src/variants/dynamicVariants.ts +76 -18
  136. package/src/variants/mediaQuery.ts +18 -0
  137. package/src/variants/spacing.ts +15 -1
  138. package/package.json.bak +0 -30
@@ -0,0 +1,87 @@
1
+ import { CacheType } from '../types/cache';
2
+ import { StateStorage } from '../types/store';
3
+ /**
4
+ * Generic cache implementation with persistence and stale time management
5
+ * @template T - The type of values stored in the cache
6
+ */
7
+ export declare class Cache<T extends any = any> {
8
+ registryName: CacheType;
9
+ private storage;
10
+ persistCache: boolean;
11
+ /** In-memory cache storage */
12
+ cache: Record<string, T>;
13
+ /** Debounce timer for batch persistence */
14
+ private persistTimer;
15
+ /** Debounce delay in milliseconds */
16
+ private persistDelay;
17
+ /**
18
+ * Gets the persistence key for cache data
19
+ * @returns {string} The storage key for cache data
20
+ */
21
+ get persistKeyCache(): string;
22
+ /**
23
+ * Gets the persistence key for stale time
24
+ * @returns {string} The storage key for stale time
25
+ */
26
+ get persistKeyStaleTime(): string;
27
+ /**
28
+ * Creates a new Cache instance
29
+ * @param {CacheType} registryName - The name/type of the cache registry
30
+ * @param {StateStorage} [storage=null] - The storage implementation for persistence
31
+ * @param {boolean} [persistCache=!!storage] - Whether to persist cache to storage
32
+ */
33
+ constructor(registryName: CacheType, storage?: StateStorage | null | undefined, persistCache?: boolean);
34
+ /**
35
+ * Generates a cache key and retrieves the cached value
36
+ * @param {string} cacheBaseKey - The base key for cache generation
37
+ * @param {Array<any> | any} data - The data to use for key generation
38
+ * @returns {{ key: string, value: T | null }} Object containing the cache key and value
39
+ */
40
+ keyFor(cacheBaseKey: string, data: Array<any> | any): {
41
+ key: string;
42
+ value: NonNullable<T> | null;
43
+ };
44
+ /**
45
+ * Stores a value in the cache and optionally persists it
46
+ * @param {string} key - The cache key
47
+ * @param {T} cache - The value to cache
48
+ * @returns {T} The cached value
49
+ */
50
+ cacheFor(key: string, cache: T): T;
51
+ /**
52
+ * Replaces the entire cache with new data
53
+ * @param {Record<string, T>} cache - The new cache data
54
+ */
55
+ setCache(cache: Record<string, T>): void;
56
+ /**
57
+ * Clears both in-memory and persistent cache
58
+ */
59
+ clear(): void;
60
+ /**
61
+ * Schedules cache persistence with debounce
62
+ */
63
+ private schedulePersist;
64
+ /**
65
+ * Loads cache data and stale time from persistent storage
66
+ * @returns {{ persistedStaleTime: Date, persistedCache: any }} Loaded data from storage
67
+ */
68
+ loadStorage(): {
69
+ persistedStaleTime: Date;
70
+ persistedCache: any;
71
+ };
72
+ /**
73
+ * Clears cache data from persistent storage
74
+ */
75
+ clearStorage(): void;
76
+ /**
77
+ * Stores cache data to persistent storage
78
+ * @param {Record<string, T>} [cache=null] - Cache data to store (uses current cache if not provided)
79
+ */
80
+ storeCache(cache?: Record<string, T> | undefined): void;
81
+ /**
82
+ * Stores stale time to persistent storage
83
+ * @param {Date} staleTime - The stale time to store
84
+ */
85
+ storeStaleTime(staleTime: Date): void;
86
+ }
87
+ //# sourceMappingURL=Cacher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cacher.d.ts","sourceRoot":"","sources":["../../src/classes/Cacher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS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* @description This implementation is complete but not currently being used.
6
+ * Developed for potential future need of time-based cache invalidation.
7
+ */
8
+ export declare class StaleControl {
9
+ private staleTime;
10
+ private staleTimeIdentifier;
11
+ private wiperInterval;
12
+ private wiperId;
13
+ /**
14
+ * @param staleTime - Expiration time in minutes (default: 60 minutes)
15
+ * @param staleTimeIdentifier - Separator to identify timestamp in value (default: '//:')
16
+ * @param wiperInterval - Expired data check interval in milliseconds (default: 30 minutes)
17
+ */
18
+ constructor(staleTime?: number, // minutes
19
+ staleTimeIdentifier?: string, wiperInterval?: number);
20
+ /**
21
+ * Checks if a value is expired based on embedded timestamp
22
+ * @param value - Value with embedded timestamp
23
+ * @returns boolean indicating if value is expired
24
+ */
25
+ isStaled(value: string): boolean;
26
+ /**
27
+ * Inserts expiration timestamp into a value
28
+ * @param value - Original value without timestamp
29
+ * @returns Value with expiration timestamp embedded
30
+ */
31
+ insertStaleTime(value: string): string;
32
+ /**
33
+ * Refreshes the expiration timestamp of a value
34
+ * @param value - Value with existing timestamp
35
+ * @returns Value with refreshed expiration timestamp
36
+ */
37
+ refreshStaleTime(value: string): string;
38
+ /**
39
+ * Extracts expiration timestamp and original value
40
+ * @param value - Value with embedded timestamp
41
+ * @returns Object containing expiration date and original value
42
+ */
43
+ extractStaleTime(value: string): {
44
+ staleTime: Date;
45
+ value: string;
46
+ };
47
+ /**
48
+ * Wipes expired cache; verifies isStaled values and removes them
49
+ * @throws Error indicating method is not implemented
50
+ */
51
+ cacheWiper(): void;
52
+ /**
53
+ * Registers periodic cache cleaning interval
54
+ */
55
+ registerCacheWiper(): void;
56
+ /**
57
+ * Unregisters periodic cache cleaning interval
58
+ */
59
+ unregisterCacheWiper(): void;
60
+ /**
61
+ * Cleanup method to clear intervals when instance is no longer needed
62
+ */
63
+ destroy(): void;
64
+ }
65
+ //# sourceMappingURL=StaleControl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StaleControl.d.ts","sourceRoot":"","sources":["../../src/classes/StaleControl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACF,qBAAa,YAAY;IAStB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,aAAa;IAVvB,OAAO,CAAC,OAAO,CAA8C;IAE7D;;;;OAIG;gBAEO,SAAS,GAAE,MAAW,EAAE,UAAU;IAClC,mBAAmB,GAAE,MAAc,EACnC,aAAa,GAAE,MAAuB;IAGhD;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAUhC;;;;OAIG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAUtC;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAOvC;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,SAAS,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAUnE;;;OAGG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAU1B;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAO5B;;OAEG;IACH,OAAO,IAAI,IAAI;CAGhB"}
@@ -0,0 +1,63 @@
1
+ import { Cache } from './Cacher';
2
+ import { CacheType } from '../types/cache';
3
+ import { StateStorage } from '../types/store';
4
+ /**
5
+ * Aggregates the six typed `Cache` buckets used by the style registry.
6
+ * Three buckets (`styles`, `compositions`, `responsive`) are in-memory only.
7
+ * Three buckets (`variants`, `common`, `components`) are backed by the
8
+ * provided `StateStorage` and survive page reloads until the stale window expires.
9
+ *
10
+ * All keys are derived from a `baseKey` that encodes the active color scheme,
11
+ * theme snapshot, and common variants — so switching color scheme automatically
12
+ * invalidates all cached values without an explicit `wipeCache` call.
13
+ */
14
+ export declare class StyleCache {
15
+ /** Base key used for cache key generation */
16
+ baseKey: string;
17
+ /** Cache for style data */
18
+ styles: Cache<any>;
19
+ /** Cache for style compositions */
20
+ compositions: Cache<any>;
21
+ /** Cache for responsive styles */
22
+ responsive: Cache<any>;
23
+ /** Cache for style variants with persistent storage */
24
+ variants: Cache;
25
+ /** Cache for common styles with persistent storage */
26
+ common: Cache;
27
+ /** Cache for component styles with persistent storage */
28
+ components: Cache;
29
+ /**
30
+ * Creates a new StyleCache instance
31
+ * @param storage - State storage instance for persistent caches
32
+ */
33
+ constructor(storage: StateStorage);
34
+ /**
35
+ * Registers and generates a base key for cache operations
36
+ * @param keys - Array of values to include in base key generation
37
+ * @returns The generated base key hash
38
+ */
39
+ registerBaseKey(keys: Array<any>): string;
40
+ /**
41
+ * Clears all cache instances
42
+ */
43
+ wipeCache(): void;
44
+ /**
45
+ * Generates a cache key and retrieves cached value if exists
46
+ * @param type - The cache type to use
47
+ * @param keyData - Data to use for key generation (array or object)
48
+ * @returns Object containing the generated key and cached value (if any)
49
+ */
50
+ keyFor(type: CacheType, keyData: Array<any> | any): {
51
+ key: string;
52
+ value: any;
53
+ };
54
+ /**
55
+ * Stores a value in the specified cache with compression
56
+ * @param type - The cache type to use
57
+ * @param key - Cache key
58
+ * @param value - Value to cache
59
+ * @returns The cached value (compressed if caching is enabled)
60
+ */
61
+ cacheFor(type: CacheType, key: string, value: any): any;
62
+ }
63
+ //# sourceMappingURL=StyleCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StyleCache.d.ts","sourceRoot":"","sources":["../../src/classes/StyleCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAGhC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C;;;;;;;;;GASG;AACH,qBAAa,UAAU;IACrB,6CAA6C;IAC7C,OAAO,EAAG,MAAM,CAAA;IAEhB,2BAA2B;IAC3B,MAAM,aAAsB;IAE5B,mCAAmC;IACnC,YAAY,aAA4B;IAExC,kCAAkC;IAClC,UAAU,aAA0B;IAEpC,uDAAuD;IACvD,QAAQ,EAAE,KAAK,CAAA;IAEf,sDAAsD;IACtD,MAAM,EAAE,KAAK,CAAA;IAEb,yDAAyD;IACzD,UAAU,EAAE,KAAK,CAAA;IAEjB;;;OAGG;gBACS,OAAO,EAAE,YAAY;IAMjC;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM;IAUzC;;OAEG;IACH,SAAS,IAAI,IAAI;IASjB;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE;IAsB/E;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG;CAWxD"}
@@ -0,0 +1,52 @@
1
+ import { StateStorage } from '../types/store';
2
+ /**
3
+ * Platform-specific storage adapter required by `StylePersistor`.
4
+ * Implementations exist for MMKV (mobile) and localStorage (web).
5
+ * Note the method names (`set`/`get`/`del`) differ from the `StateStorage` interface
6
+ * (`setItem`/`getItem`/`removeItem`) — `StylePersistor` bridges the two.
7
+ */
8
+ export type StoragePersistor = {
9
+ set: (key: string, value: any) => void;
10
+ get: (key: string) => any;
11
+ del: (key: string) => void;
12
+ };
13
+ /**
14
+ * Adapts a platform `StoragePersistor` to the `StateStorage` interface expected by
15
+ * `StyleCache`. All values are LZ-compressed on write and decompressed on read,
16
+ * substantially reducing storage footprint for large serialised style caches.
17
+ */
18
+ export declare class StylePersistor implements StateStorage {
19
+ private storage;
20
+ /**
21
+ * Creates a new StylePersistor instance with compression capabilities
22
+ * @param {StoragePersistor} storage - The underlying storage implementation
23
+ */
24
+ constructor(storage: StoragePersistor);
25
+ /**
26
+ * Stores a value in the underlying storage with compression
27
+ *
28
+ * @param {string} name - Storage key identifier
29
+ * @param {string} value - Value to store (will be compressed)
30
+ * @returns {void}
31
+ * @throws {Error} If the underlying storage fails to set the value
32
+ */
33
+ setItem(name: string, value: string): void;
34
+ /**
35
+ * Retrieves and decompresses a value from storage
36
+ * Returns null if key doesn't exist, value is null/undefined, or decompression fails
37
+ *
38
+ * @param {string} name - Storage key identifier
39
+ * @returns {string | null} Decompressed value or null if not found/invalid
40
+ * @throws {Error} If the underlying storage fails to get the value
41
+ */
42
+ getItem(name: string): string | null;
43
+ /**
44
+ * Removes an item from storage
45
+ *
46
+ * @param {string} name - Storage key identifier
47
+ * @returns {void}
48
+ * @throws {Error} If the underlying storage fails to delete the value
49
+ */
50
+ removeItem(name: string): void;
51
+ }
52
+ //# sourceMappingURL=StylePersistor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StylePersistor.d.ts","sourceRoot":"","sources":["../../src/classes/StylePersistor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAI7C;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IACtC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAA;IACzB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAC3B,CAAA;AAED;;;;GAIG;AACH,qBAAa,cAAe,YAAW,YAAY;IAM/C,OAAO,CAAC,OAAO;IALjB;;;OAGG;gBAEO,OAAO,EAAE,gBAAgB;IAGnC;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAM1C;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAUpC;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAG/B"}
@@ -0,0 +1,108 @@
1
+ import type { AnyStyledComponent, ComponentContext, ICSS, ITheme, StyleAggregator, StyleProp, VariantStyleSheet } from '../types';
2
+ import type { StateStorage } from '../types/store';
3
+ import type { MultiplierFunction } from '../variants';
4
+ /**
5
+ * Central style resolution engine for the `@codeleap/styles` system.
6
+ *
7
+ * Responsibilities:
8
+ * - Stores compressed variant stylesheets per component (`stylesheets`).
9
+ * - Maintains the merged common-variant map (`defaultVariants + appVariants + dynamicVariants + spacing`).
10
+ * - Resolves `StyleProp` values into flat `ICSS` objects for each composition element.
11
+ * - Caches every resolution step in the six `StyleCache` buckets for performance.
12
+ * - Provides `createStyle` as an abstract hook for platform-specific style flattening
13
+ * (web passes through; RN uses `StyleSheet.flatten`).
14
+ *
15
+ * Instantiated once per platform registry (not per component). Platform packages
16
+ * subclass or configure this to provide the appropriate `createStyle` implementation.
17
+ */
18
+ export declare class CodeleapStyleRegistry {
19
+ stylesheets: Record<string, VariantStyleSheet>;
20
+ commonVariants: Record<string, ICSS | MultiplierFunction>;
21
+ aggregators: Record<string, StyleAggregator>;
22
+ components: Record<string, AnyStyledComponent>;
23
+ /** Per-component map of variant names to context-aware factory functions. Populated during `registerVariants`. */
24
+ variantFactories: Record<string, Record<string, (theme: ITheme, context: ComponentContext) => any>>;
25
+ private styleCache;
26
+ constructor(storage: StateStorage);
27
+ /**
28
+ * Resolves a single common-variant string (e.g., `"flex"`, `"padding:2"`, `"xl:flex"`)
29
+ * into a composition-keyed style object. Handles breakpoint-prefixed variants by wrapping
30
+ * the result in a `@media` key. Returns `null` if the variant is not found in `commonVariants`.
31
+ */
32
+ computeCommonVariantStyle(componentName: string, variant: string, component?: string | undefined): {
33
+ [x: string]: ICSS;
34
+ } | null;
35
+ /**
36
+ * Resolves an array of variant strings for a component into a single merged `ICSS`.
37
+ * Checks component-level variant stylesheet first, then falls back to common variants.
38
+ * Context-aware factories (registered via `CONTEXT_FACTORY_SYMBOL`) are called with
39
+ * the current theme and the provided `context` object.
40
+ */
41
+ computeVariantStyle(componentName: string, variants: string[], _component?: string | undefined, context?: ComponentContext): ICSS;
42
+ /**
43
+ * Determines whether a style object contains composition keys for a given component.
44
+ * A key is a composition key if it starts with one of the component's `elements` strings
45
+ * and is not in `ignoredStyleKeys`. Returns both a boolean flag and the extracted
46
+ * composition sub-record so callers can avoid a second pass.
47
+ */
48
+ isCompositionStyle(component: AnyStyledComponent, style: any): {
49
+ isComposition: boolean;
50
+ composition: Record<string, any>;
51
+ };
52
+ /**
53
+ * Checks whether a style object contains a `breakpoints` key, indicating it uses
54
+ * the responsive style API. Returns the key name alongside the boolean so the caller
55
+ * can use it to read and delete the breakpoints entry without a repeated `'breakpoints'`
56
+ * string literal.
57
+ */
58
+ isResponsiveStyle(style: any): {
59
+ responsiveStyleKey: string;
60
+ isResponsive: boolean;
61
+ };
62
+ getDefaultVariantStyle(componentName: string, defaultVariantStyleName?: string): any;
63
+ mergeStylesWithCache<T = unknown>(styles: ICSS[], key: string): T;
64
+ getRegisteredComponent(componentName: string): {
65
+ rootElement: string;
66
+ registeredComponent: AnyStyledComponent;
67
+ };
68
+ getResponsiveStyle(componentName: string, responsiveStyleKey: string, style: Record<string, any>): any;
69
+ getStyles(componentName: string, _style: any, component?: any, predicateObj?: (style: any) => any): {};
70
+ private getMediaQuery;
71
+ getStyleWithResponsive(componentName: string, style: any, component?: any): any;
72
+ getCompositionStyle(componentName: string, composition: Record<string, any>, style: any): any;
73
+ styleFor<T = unknown>(componentName: string, componentStyle: StyleProp<T & string>, mergeWithDefaultStyle?: boolean, context?: ComponentContext): T;
74
+ /**
75
+ * Rebuilds `commonVariants` by merging (in ascending priority order):
76
+ * `defaultVariants` → `appVariants` → `dynamicVariants` → `spacingVariants` → `insetVariants`.
77
+ * Called once in the constructor; must be re-called (via `update`) if app variants change.
78
+ */
79
+ registerCommonVariants(): void;
80
+ /**
81
+ * Registers a component's variant stylesheet. No-ops if the component is already
82
+ * registered (variants are immutable after first registration). Extracts any
83
+ * `CONTEXT_FACTORY_SYMBOL`-tagged entries into `variantFactories` for context-aware
84
+ * resolution, then compresses and stores the remaining variants.
85
+ */
86
+ registerVariants<Composition extends string = any>(componentName: string, variants: VariantStyleSheet, aggregator?: StyleAggregator<Composition>): void;
87
+ /**
88
+ * Records the minimal component metadata (`styleRegistryName`, `elements`,
89
+ * `rootElement`) needed for composition and style resolution. Only the metadata
90
+ * is stored — the component function itself is not retained.
91
+ */
92
+ registerComponent(component: AnyStyledComponent): void;
93
+ /**
94
+ * These should be overwritten by the end-user to support
95
+ * custom style merging logic, such as StyleSheet.flatten
96
+ */
97
+ createStyle(css: ICSS): ICSS;
98
+ /**
99
+ * Must be called after the active color scheme changes so that the `StyleCache`
100
+ * base key is regenerated. Without this call, cached values from the previous
101
+ * scheme would be returned for the new scheme.
102
+ */
103
+ update(): void;
104
+ private copyStyle;
105
+ createStyles<K extends string = string>(styles: Record<K, StyleProp<string, ''>> | ((theme: ITheme) => Record<K, StyleProp<string, ''>>)): Record<K, ICSS>;
106
+ prefixStyle(prefix: string, style: any): any;
107
+ }
108
+ //# sourceMappingURL=StyleRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StyleRegistry.d.ts","sourceRoot":"","sources":["../../src/classes/StyleRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjI,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAQrD;;;;;;;;;;;;;GAaG;AACH,qBAAa,qBAAqB;IAChC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAK;IAEnD,cAAc,EAAE,MAAM,CAAC,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}
@@ -0,0 +1,3 @@
1
+ export * from './StyleRegistry';
2
+ export * from './StylePersistor';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Package-wide feature flags and runtime constants. These are read once at module
3
+ * load time and are not reactive.
4
+ *
5
+ * - `STORES_PERSIST_VERSION` — bumping this value invalidates all persisted caches
6
+ * on the next load (because it is included in every `hashKey` call via `registerBaseKey`).
7
+ * - `STORE_CACHE_ENABLED` — when `false`, the persistent `Cache` instances skip
8
+ * loading from and writing to `StateStorage`.
9
+ * - `CACHE_ENABLED` — when `false`, `StyleCache.cacheFor` returns values without
10
+ * writing to any cache bucket, effectively disabling all in-memory caching.
11
+ * - `IS_BROWSER` — sniffed at load time via `typeof document`; used as a fast guard
12
+ * before any DOM access.
13
+ * - `LOG` — enables verbose `console.log` tracing inside `Cache` and `StylePersistor`.
14
+ */
15
+ export declare const StyleConstants: {
16
+ STORES_PERSIST_VERSION: number;
17
+ STORE_CACHE_ENABLED: boolean;
18
+ CACHE_ENABLED: boolean;
19
+ IS_BROWSER: boolean;
20
+ LOG: boolean;
21
+ };
22
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc;;;;gBAIE,OAAO;;CAEnC,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from './useCompositionStyles';
2
+ export * from './useNestedStylesByKey';
3
+ export * from './useStyleObserver';
4
+ export * from './useTheme';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { ICSS } from '../types';
2
+ /**
3
+ * Slices a flat component-style record into per-element sub-records, memoised to
4
+ * avoid unnecessary re-renders. For each element name in `composition`, it calls
5
+ * `getNestedStylesByKey(element, componentStyles)` to collect all keys that start
6
+ * with that element name. Accepts either a single element string or an array.
7
+ *
8
+ * Useful when a parent component receives a merged `componentStyles` object and
9
+ * needs to distribute the correct slice to each child element.
10
+ */
11
+ export declare function useCompositionStyles<T extends string, C extends string>(composition: (T | Array<T>), componentStyles: Partial<Record<C, ICSS>>): Partial<Record<T, ICSS>>;
12
+ //# sourceMappingURL=useCompositionStyles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCompositionStyles.d.ts","sourceRoot":"","sources":["../../src/hooks/useCompositionStyles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAG/B;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EACrE,WAAW,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAC3B,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GACxC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAkB1B"}
@@ -0,0 +1,11 @@
1
+ import { ICSS } from '../types';
2
+ /**
3
+ * Memoised wrapper around `getNestedStylesByKey`. Returns the sub-record of
4
+ * `componentStyles` whose keys start with `match`, with the prefix stripped and the
5
+ * remainder lowercased. Re-computes only when `componentStyles` changes by reference.
6
+ *
7
+ * Use instead of `useCompositionStyles` when you need the slice for a single element
8
+ * and don't want the overhead of iterating over an array.
9
+ */
10
+ export declare function useNestedStylesByKey<T extends string>(match: string, componentStyles: Partial<Record<T, ICSS>>): Record<string, any>;
11
+ //# sourceMappingURL=useNestedStylesByKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNestedStylesByKey.d.ts","sourceRoot":"","sources":["../../src/hooks/useNestedStylesByKey.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAG/B;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,uBAQ9G"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Produces a stable string that changes only when the style value changes, suitable
3
+ * for use as a `useEffect`/`useMemo` dependency when the style prop is an object or
4
+ * array (which would otherwise trigger on every render due to referential inequality).
5
+ * Falsy entries are stripped from arrays before serialisation, so `[null, style]` and
6
+ * `[style]` yield the same string.
7
+ */
8
+ export declare const useStyleObserver: (style: any) => any;
9
+ //# sourceMappingURL=useStyleObserver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStyleObserver.d.ts","sourceRoot":"","sources":["../../src/hooks/useStyleObserver.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,GAAG,QAU1C,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { ThemeState } from '../theme';
2
+ type ThemeSelector<T> = (state: ThemeState) => T;
3
+ /**
4
+ * Subscribes to the global theme state and returns either the full `ThemeState`
5
+ * (when called without arguments) or a derived value (when called with a selector).
6
+ * Uses nanostores' `useStore` under the hood, so re-renders are triggered only when
7
+ * the selected slice changes by reference.
8
+ *
9
+ * @example
10
+ * // Full state
11
+ * const { theme, colorScheme } = useTheme()
12
+ *
13
+ * @example
14
+ * // Derived slice — component only re-renders when colorScheme changes
15
+ * const colorScheme = useTheme(s => s.colorScheme)
16
+ */
17
+ export declare const useTheme: <T = ThemeState>(selector?: ThemeSelector<T>) => T;
18
+ export {};
19
+ //# sourceMappingURL=useTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,UAAU,CAAA;AAGzD,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,KAAK,CAAC,CAAA;AAEhD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,GAAG,UAAU,EACrC,WAAW,aAAa,CAAC,CAAC,CAAC,KAC1B,CAQF,CAAA"}
@@ -0,0 +1,12 @@
1
+ import './constants';
2
+ import './utils';
3
+ export * from './classes';
4
+ export * from './hooks';
5
+ export * from './lib';
6
+ export * from './theme';
7
+ export * from './tools';
8
+ export * from './types';
9
+ export * from './variants';
10
+ export * from './constants';
11
+ export * from './utils';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,SAAS,CAAA;AAEhB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA"}
@@ -0,0 +1,27 @@
1
+ type Unit = 'px' | 'vh' | 'dvh' | 'vw' | 'dvw' | '%' | 'lvh' | 'svh';
2
+ /**
3
+ * Chainable builder for CSS `calc()` expressions. Each arithmetic method appends
4
+ * to the expression and returns `this`, so calls can be chained. Call `build()`
5
+ * at the end to get the final `calc(...)` string.
6
+ *
7
+ * @example
8
+ * calc(100, '%').sub(16).build() // → 'calc((100%) - (16px))'
9
+ */
10
+ declare class CalcBuilder {
11
+ private expression;
12
+ constructor(initial: number, unit?: Unit);
13
+ private wrap;
14
+ sub(value: number, unit?: Unit): this;
15
+ add(value: number, unit?: Unit): this;
16
+ mult(value: number): this;
17
+ div(value: number): this;
18
+ build(): string;
19
+ }
20
+ /**
21
+ * Entry point for building CSS `calc()` expressions. Pass an initial numeric value
22
+ * and optional unit (default `'px'`), then chain `.add()`, `.sub()`, `.mult()`, `.div()`,
23
+ * and finally call `.build()` to get the complete string.
24
+ */
25
+ export declare const calc: (base: number, unit?: Unit) => CalcBuilder;
26
+ export {};
27
+ //# sourceMappingURL=calc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calc.d.ts","sourceRoot":"","sources":["../../src/lib/calc.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,GAAG,GAAG,KAAK,GAAG,KAAK,CAAA;AAEpE;;;;;;;GAOG;AACH,cAAM,WAAW;IACf,OAAO,CAAC,UAAU,CAAQ;gBAEd,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,IAAW;IAI9C,OAAO,CAAC,IAAI;IAIZ,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,IAAW;IAMpC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,IAAW;IAMpC,IAAI,CAAC,KAAK,EAAE,MAAM;IAKlB,GAAG,CAAC,KAAK,EAAE,MAAM;IAKjB,KAAK;CAGN;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,EAAE,OAAM,IAAW,gBAAgC,CAAA"}
@@ -0,0 +1,30 @@
1
+ import { AnyRecord, ComponentContext, ICSS, ITheme } from '../types';
2
+ type Value = AnyRecord;
3
+ type StylesShape<K extends string, V extends Value> = Partial<Record<K, ICSS & Partial<Omit<V, keyof ICSS>>>>;
4
+ /**
5
+ * Symbol used to attach a context-aware factory function to a styles proxy.
6
+ * `CodeleapStyleRegistry.registerVariants` reads this symbol from each entry to
7
+ * identify which variants require a `ComponentContext` at resolution time.
8
+ * Not intended for direct use by consumers.
9
+ */
10
+ export declare const CONTEXT_FACTORY_SYMBOL: unique symbol;
11
+ /**
12
+ * Creates a reactive styles object that automatically updates when theme changes.
13
+ * Uses a proxy to re-compute styles on each access, ensuring theme changes are reflected.
14
+ *
15
+ * @template K - Style keys (extends string)
16
+ * @template V - Additional value type (extends AnyRecord)
17
+ * @param {StylesShape<K, V> | ((theme: ITheme) => StylesShape<K, V>)} styles - Static styles object or function that receives theme
18
+ * @returns {StylesShape<K, V>} Proxied styles object that recomputes on theme changes
19
+ */
20
+ export declare function createStyles<K extends string, V extends Value = {}>(styles: StylesShape<K, V> | ((theme: ITheme) => StylesShape<K, V>)): Partial<Record<K, ICSS & Partial<Omit<V, never>>>>;
21
+ /**
22
+ * Like `createStyles`, but the factory also receives a `ComponentContext` so that
23
+ * individual style values can vary based on runtime boolean/numeric state (e.g.,
24
+ * `isDisabled`, `isSelected`). The resulting proxy exposes a `CONTEXT_FACTORY_SYMBOL`
25
+ * getter so the registry can invoke the factory with the actual context at render time.
26
+ * Use this instead of `createStyles` when variant styles depend on component state.
27
+ */
28
+ export declare function createStylesWithContext<K extends string, V extends Value = {}, C extends ComponentContext = {}>(styles: (theme: ITheme, context: C) => StylesShape<K, V>): Partial<Record<K, ICSS & Partial<Omit<V, never>>>>;
29
+ export {};
30
+ //# sourceMappingURL=createStyles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStyles.d.ts","sourceRoot":"","sources":["../../src/lib/createStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGpE,KAAK,KAAK,GAAG,SAAS,CAAA;AAEtB,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AAE7G;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,eAA2B,CAAA;AAE9D;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,KAAK,GAAG,EAAE,EACjE,MAAM,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,sDAqBnE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,KAAK,GAAG,EAAE,EAAE,CAAC,SAAS,gBAAgB,GAAG,EAAE,EAC7G,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,sDAazD"}
@@ -0,0 +1,28 @@
1
+ import { AppTheme, Theme } from '../types';
2
+ type ThemePersistor = {
3
+ get: (name: string) => any;
4
+ set: (name: string, value: any) => void;
5
+ getNoCompress?: (name: string) => any;
6
+ setNoCompress?: (name: string, value: any) => void;
7
+ getSystemColorScheme?: () => string | null;
8
+ };
9
+ /**
10
+ * Builds and registers the runtime `AppTheme<T>` object from a raw `Theme` definition.
11
+ *
12
+ * Key behaviours:
13
+ * - On web (`theme.isBrowser = true`), `theme.colors` is replaced with a CSS-var proxy
14
+ * so all color references become `var(--cl-<token>)` strings. The active scheme's
15
+ * real values are still accessible via `theme.currentSchemeColors`.
16
+ * - Persists the selected color scheme to storage and restores it on next load.
17
+ * Falls back to `getSystemColorScheme()` if no persisted value exists.
18
+ * - `alternateColors` from storage are merged with those in the theme definition
19
+ * (runtime-injected schemes take priority).
20
+ * - The constructed theme is immediately set on `themeStore` so hooks and the registry
21
+ * can read it synchronously during the same render pass.
22
+ *
23
+ * @param theme - Raw theme object (output of `validateTheme` or a compliant literal).
24
+ * @param themePersistor - Storage adapter for persisting color-scheme selection and injected schemes.
25
+ */
26
+ export declare const createTheme: <T extends Theme>(theme: T, themePersistor: ThemePersistor) => AppTheme<T>;
27
+ export {};
28
+ //# sourceMappingURL=createTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../../src/lib/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAU,MAAM,UAAU,CAAA;AAMlD,KAAK,cAAc,GAAG;IACpB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,CAAA;IAC1B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IACvC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,CAAA;IACrC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IAClD,oBAAoB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;CAC3C,CAAA;AAKD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,KAAK,EAAE,OAAO,CAAC,EAAE,gBAAgB,cAAc,KAAG,QAAQ,CAAC,CAAC,CA6LjG,CAAA"}