@just-web/toolkits 1.0.0 → 2.0.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 (315) hide show
  1. package/dist/react/hooks/use-theme-by-class-name.cjs +1 -5
  2. package/dist/react/hooks/use-theme-by-class-name.cjs.map +1 -1
  3. package/dist/react/hooks/use-theme-by-class-name.d.cts.map +1 -1
  4. package/dist/react/hooks/use-theme-by-class-name.d.mts.map +1 -1
  5. package/dist/react/hooks/use-theme-by-class-name.mjs +1 -5
  6. package/dist/react/hooks/use-theme-by-class-name.mjs.map +1 -1
  7. package/dist/react/hooks/use-theme-by-data-attribute.cjs +1 -6
  8. package/dist/react/hooks/use-theme-by-data-attribute.cjs.map +1 -1
  9. package/dist/react/hooks/use-theme-by-data-attribute.d.cts.map +1 -1
  10. package/dist/react/hooks/use-theme-by-data-attribute.d.mts.map +1 -1
  11. package/dist/react/hooks/use-theme-by-data-attribute.mjs +1 -6
  12. package/dist/react/hooks/use-theme-by-data-attribute.mjs.map +1 -1
  13. package/dist/react/hooks/use-theme-by-local-storage.cjs +1 -5
  14. package/dist/react/hooks/use-theme-by-local-storage.cjs.map +1 -1
  15. package/dist/react/hooks/use-theme-by-local-storage.d.cts.map +1 -1
  16. package/dist/react/hooks/use-theme-by-local-storage.d.mts.map +1 -1
  17. package/dist/react/hooks/use-theme-by-local-storage.mjs +1 -5
  18. package/dist/react/hooks/use-theme-by-local-storage.mjs.map +1 -1
  19. package/dist/theme/_utils/match-attribute-value-to-theme.cjs +29 -0
  20. package/dist/theme/_utils/match-attribute-value-to-theme.cjs.map +1 -0
  21. package/dist/theme/_utils/match-attribute-value-to-theme.mjs +28 -0
  22. package/dist/theme/_utils/match-attribute-value-to-theme.mjs.map +1 -0
  23. package/dist/theme/_utils/parse-stored-theme.cjs +61 -7
  24. package/dist/theme/_utils/parse-stored-theme.cjs.map +1 -1
  25. package/dist/theme/_utils/parse-stored-theme.mjs +61 -7
  26. package/dist/theme/_utils/parse-stored-theme.mjs.map +1 -1
  27. package/dist/theme/_utils/resolve-theme-map-value.cjs +19 -0
  28. package/dist/theme/_utils/resolve-theme-map-value.cjs.map +1 -0
  29. package/dist/theme/_utils/resolve-theme-map-value.mjs +17 -0
  30. package/dist/theme/_utils/resolve-theme-map-value.mjs.map +1 -0
  31. package/dist/theme/class-name/parse-class-name.cjs +32 -0
  32. package/dist/theme/class-name/parse-class-name.cjs.map +1 -0
  33. package/dist/theme/class-name/parse-class-name.d.cts +20 -0
  34. package/dist/theme/class-name/parse-class-name.d.cts.map +1 -0
  35. package/dist/theme/class-name/parse-class-name.d.mts +20 -0
  36. package/dist/theme/class-name/parse-class-name.d.mts.map +1 -0
  37. package/dist/theme/class-name/parse-class-name.mjs +31 -0
  38. package/dist/theme/class-name/parse-class-name.mjs.map +1 -0
  39. package/dist/theme/class-name/read-class-name.cjs +20 -0
  40. package/dist/theme/class-name/read-class-name.cjs.map +1 -0
  41. package/dist/theme/class-name/read-class-name.d.cts +20 -0
  42. package/dist/theme/class-name/read-class-name.d.cts.map +1 -0
  43. package/dist/theme/class-name/read-class-name.d.mts +20 -0
  44. package/dist/theme/class-name/read-class-name.d.mts.map +1 -0
  45. package/dist/theme/class-name/read-class-name.mjs +20 -0
  46. package/dist/theme/class-name/read-class-name.mjs.map +1 -0
  47. package/dist/theme/class-name/stringify-class-name.cjs +31 -0
  48. package/dist/theme/class-name/stringify-class-name.cjs.map +1 -0
  49. package/dist/theme/class-name/stringify-class-name.d.cts +21 -0
  50. package/dist/theme/class-name/stringify-class-name.d.cts.map +1 -0
  51. package/dist/theme/class-name/stringify-class-name.d.mts +21 -0
  52. package/dist/theme/class-name/stringify-class-name.d.mts.map +1 -0
  53. package/dist/theme/class-name/stringify-class-name.mjs +31 -0
  54. package/dist/theme/class-name/stringify-class-name.mjs.map +1 -0
  55. package/dist/theme/class-name/subscribe-class-name.cjs +31 -0
  56. package/dist/theme/class-name/subscribe-class-name.cjs.map +1 -0
  57. package/dist/theme/class-name/subscribe-class-name.d.cts +21 -0
  58. package/dist/theme/class-name/subscribe-class-name.d.cts.map +1 -0
  59. package/dist/theme/class-name/subscribe-class-name.d.mts +21 -0
  60. package/dist/theme/class-name/subscribe-class-name.d.mts.map +1 -0
  61. package/dist/theme/class-name/subscribe-class-name.mjs +31 -0
  62. package/dist/theme/class-name/subscribe-class-name.mjs.map +1 -0
  63. package/dist/theme/class-name/write-class-name.cjs +20 -0
  64. package/dist/theme/class-name/write-class-name.cjs.map +1 -0
  65. package/dist/theme/class-name/write-class-name.d.cts +20 -0
  66. package/dist/theme/class-name/write-class-name.d.cts.map +1 -0
  67. package/dist/theme/class-name/write-class-name.d.mts +20 -0
  68. package/dist/theme/class-name/write-class-name.d.mts.map +1 -0
  69. package/dist/theme/class-name/write-class-name.mjs +20 -0
  70. package/dist/theme/class-name/write-class-name.mjs.map +1 -0
  71. package/dist/theme/cookie/_cookie-utils.cjs +37 -0
  72. package/dist/theme/cookie/_cookie-utils.cjs.map +1 -0
  73. package/dist/theme/cookie/_cookie-utils.mjs +33 -0
  74. package/dist/theme/cookie/_cookie-utils.mjs.map +1 -0
  75. package/dist/theme/cookie/read-cookie-theme.cjs +22 -0
  76. package/dist/theme/cookie/read-cookie-theme.cjs.map +1 -0
  77. package/dist/theme/cookie/read-cookie-theme.d.cts +22 -0
  78. package/dist/theme/cookie/read-cookie-theme.d.cts.map +1 -0
  79. package/dist/theme/cookie/read-cookie-theme.d.mts +22 -0
  80. package/dist/theme/cookie/read-cookie-theme.d.mts.map +1 -0
  81. package/dist/theme/cookie/read-cookie-theme.mjs +22 -0
  82. package/dist/theme/cookie/read-cookie-theme.mjs.map +1 -0
  83. package/dist/theme/cookie/write-cookie-theme.cjs +29 -0
  84. package/dist/theme/cookie/write-cookie-theme.cjs.map +1 -0
  85. package/dist/theme/cookie/write-cookie-theme.d.cts +24 -0
  86. package/dist/theme/cookie/write-cookie-theme.d.cts.map +1 -0
  87. package/dist/theme/cookie/write-cookie-theme.d.mts +24 -0
  88. package/dist/theme/cookie/write-cookie-theme.d.mts.map +1 -0
  89. package/dist/theme/cookie/write-cookie-theme.mjs +29 -0
  90. package/dist/theme/cookie/write-cookie-theme.mjs.map +1 -0
  91. package/dist/theme/data-attribute/_constant.cjs +7 -0
  92. package/dist/theme/data-attribute/_constant.cjs.map +1 -0
  93. package/dist/theme/data-attribute/_constant.mjs +6 -0
  94. package/dist/theme/data-attribute/_constant.mjs.map +1 -0
  95. package/dist/theme/data-attribute/parse-data-attribute.cjs +24 -0
  96. package/dist/theme/data-attribute/parse-data-attribute.cjs.map +1 -0
  97. package/dist/theme/data-attribute/parse-data-attribute.d.cts +21 -0
  98. package/dist/theme/data-attribute/parse-data-attribute.d.cts.map +1 -0
  99. package/dist/theme/data-attribute/parse-data-attribute.d.mts +21 -0
  100. package/dist/theme/data-attribute/parse-data-attribute.d.mts.map +1 -0
  101. package/dist/theme/data-attribute/parse-data-attribute.mjs +24 -0
  102. package/dist/theme/data-attribute/parse-data-attribute.mjs.map +1 -0
  103. package/dist/theme/data-attribute/read-data-attribute.cjs +23 -0
  104. package/dist/theme/data-attribute/read-data-attribute.cjs.map +1 -0
  105. package/dist/theme/data-attribute/read-data-attribute.d.cts +21 -0
  106. package/dist/theme/data-attribute/read-data-attribute.d.cts.map +1 -0
  107. package/dist/theme/data-attribute/read-data-attribute.d.mts +21 -0
  108. package/dist/theme/data-attribute/read-data-attribute.d.mts.map +1 -0
  109. package/dist/theme/data-attribute/read-data-attribute.mjs +23 -0
  110. package/dist/theme/data-attribute/read-data-attribute.mjs.map +1 -0
  111. package/dist/theme/data-attribute/stringify-data-attribute.cjs +33 -0
  112. package/dist/theme/data-attribute/stringify-data-attribute.cjs.map +1 -0
  113. package/dist/theme/data-attribute/stringify-data-attribute.d.cts +23 -0
  114. package/dist/theme/data-attribute/stringify-data-attribute.d.cts.map +1 -0
  115. package/dist/theme/data-attribute/stringify-data-attribute.d.mts +23 -0
  116. package/dist/theme/data-attribute/stringify-data-attribute.d.mts.map +1 -0
  117. package/dist/theme/data-attribute/stringify-data-attribute.mjs +33 -0
  118. package/dist/theme/data-attribute/stringify-data-attribute.mjs.map +1 -0
  119. package/dist/theme/data-attribute/subscribe-data-attribute.cjs +28 -0
  120. package/dist/theme/data-attribute/subscribe-data-attribute.cjs.map +1 -0
  121. package/dist/theme/data-attribute/subscribe-data-attribute.d.cts +22 -0
  122. package/dist/theme/data-attribute/subscribe-data-attribute.d.cts.map +1 -0
  123. package/dist/theme/data-attribute/subscribe-data-attribute.d.mts +22 -0
  124. package/dist/theme/data-attribute/subscribe-data-attribute.d.mts.map +1 -0
  125. package/dist/theme/data-attribute/subscribe-data-attribute.mjs +28 -0
  126. package/dist/theme/data-attribute/subscribe-data-attribute.mjs.map +1 -0
  127. package/dist/theme/data-attribute/write-data-attribute.cjs +30 -0
  128. package/dist/theme/data-attribute/write-data-attribute.cjs.map +1 -0
  129. package/dist/theme/data-attribute/write-data-attribute.d.cts +21 -0
  130. package/dist/theme/data-attribute/write-data-attribute.d.cts.map +1 -0
  131. package/dist/theme/data-attribute/write-data-attribute.d.mts +21 -0
  132. package/dist/theme/data-attribute/write-data-attribute.d.mts.map +1 -0
  133. package/dist/theme/data-attribute/write-data-attribute.mjs +30 -0
  134. package/dist/theme/data-attribute/write-data-attribute.mjs.map +1 -0
  135. package/dist/theme/local-storage/read-local-storage.cjs +22 -0
  136. package/dist/theme/local-storage/read-local-storage.cjs.map +1 -0
  137. package/dist/theme/local-storage/read-local-storage.d.cts +19 -0
  138. package/dist/theme/local-storage/read-local-storage.d.cts.map +1 -0
  139. package/dist/theme/local-storage/read-local-storage.d.mts +19 -0
  140. package/dist/theme/local-storage/read-local-storage.d.mts.map +1 -0
  141. package/dist/theme/local-storage/read-local-storage.mjs +22 -0
  142. package/dist/theme/local-storage/read-local-storage.mjs.map +1 -0
  143. package/dist/theme/local-storage/write-local-storage.cjs +26 -0
  144. package/dist/theme/local-storage/write-local-storage.cjs.map +1 -0
  145. package/dist/theme/local-storage/write-local-storage.d.cts +23 -0
  146. package/dist/theme/local-storage/write-local-storage.d.cts.map +1 -0
  147. package/dist/theme/local-storage/write-local-storage.d.mts +23 -0
  148. package/dist/theme/local-storage/write-local-storage.d.mts.map +1 -0
  149. package/dist/theme/local-storage/write-local-storage.mjs +26 -0
  150. package/dist/theme/local-storage/write-local-storage.mjs.map +1 -0
  151. package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.cjs +20 -0
  152. package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.cjs.map +1 -0
  153. package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.cts +23 -0
  154. package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.cts.map +1 -0
  155. package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.mts +23 -0
  156. package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.mts.map +1 -0
  157. package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.mjs +20 -0
  158. package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.mjs.map +1 -0
  159. package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.cjs +20 -0
  160. package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.cjs.map +1 -0
  161. package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.cts +20 -0
  162. package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.cts.map +1 -0
  163. package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.mts +20 -0
  164. package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.mts.map +1 -0
  165. package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.mjs +20 -0
  166. package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.mjs.map +1 -0
  167. package/dist/theme/session-storage/read-session-storage.cjs +22 -0
  168. package/dist/theme/session-storage/read-session-storage.cjs.map +1 -0
  169. package/dist/theme/session-storage/read-session-storage.d.cts +19 -0
  170. package/dist/theme/session-storage/read-session-storage.d.cts.map +1 -0
  171. package/dist/theme/session-storage/read-session-storage.d.mts +19 -0
  172. package/dist/theme/session-storage/read-session-storage.d.mts.map +1 -0
  173. package/dist/theme/session-storage/read-session-storage.mjs +22 -0
  174. package/dist/theme/session-storage/read-session-storage.mjs.map +1 -0
  175. package/dist/theme/session-storage/write-session-storage.cjs +26 -0
  176. package/dist/theme/session-storage/write-session-storage.cjs.map +1 -0
  177. package/dist/theme/session-storage/write-session-storage.d.cts +23 -0
  178. package/dist/theme/session-storage/write-session-storage.d.cts.map +1 -0
  179. package/dist/theme/session-storage/write-session-storage.d.mts +23 -0
  180. package/dist/theme/session-storage/write-session-storage.d.mts.map +1 -0
  181. package/dist/theme/session-storage/write-session-storage.mjs +26 -0
  182. package/dist/theme/session-storage/write-session-storage.mjs.map +1 -0
  183. package/dist/theme/theme-entry.types.d.cts +11 -1
  184. package/dist/theme/theme-entry.types.d.cts.map +1 -1
  185. package/dist/theme/theme-entry.types.d.mts +11 -1
  186. package/dist/theme/theme-entry.types.d.mts.map +1 -1
  187. package/dist/theme/theme-map.types.d.cts +11 -3
  188. package/dist/theme/theme-map.types.d.cts.map +1 -1
  189. package/dist/theme/theme-map.types.d.mts +11 -3
  190. package/dist/theme/theme-map.types.d.mts.map +1 -1
  191. package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.cjs +21 -18
  192. package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.cjs.map +1 -1
  193. package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.cts +5 -0
  194. package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.cts.map +1 -1
  195. package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.mts +5 -0
  196. package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.mts.map +1 -1
  197. package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.mjs +21 -18
  198. package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.mjs.map +1 -1
  199. package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.cjs +18 -36
  200. package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.cjs.map +1 -1
  201. package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.cts +5 -3
  202. package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.cts.map +1 -1
  203. package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.mts +5 -3
  204. package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.mts.map +1 -1
  205. package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.mjs +18 -36
  206. package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.mjs.map +1 -1
  207. package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs +39 -19
  208. package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs.map +1 -1
  209. package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.cts +28 -5
  210. package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.cts.map +1 -1
  211. package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.mts +28 -5
  212. package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.mts.map +1 -1
  213. package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs +39 -19
  214. package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs.map +1 -1
  215. package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs +13 -12
  216. package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs.map +1 -1
  217. package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.cts +7 -1
  218. package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.cts.map +1 -1
  219. package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.mts +7 -1
  220. package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.mts.map +1 -1
  221. package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs +13 -12
  222. package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs.map +1 -1
  223. package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.cjs +4 -5
  224. package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.cjs.map +1 -1
  225. package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.d.cts.map +1 -1
  226. package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.d.mts.map +1 -1
  227. package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs +4 -5
  228. package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs.map +1 -1
  229. package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.cjs +13 -12
  230. package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.cjs.map +1 -1
  231. package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts +7 -1
  232. package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts.map +1 -1
  233. package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts +7 -1
  234. package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts.map +1 -1
  235. package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs +13 -12
  236. package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs.map +1 -1
  237. package/dist/theme/web-storage/read-web-storage.cjs +20 -0
  238. package/dist/theme/web-storage/read-web-storage.cjs.map +1 -0
  239. package/dist/theme/web-storage/read-web-storage.d.cts +21 -0
  240. package/dist/theme/web-storage/read-web-storage.d.cts.map +1 -0
  241. package/dist/theme/web-storage/read-web-storage.d.mts +21 -0
  242. package/dist/theme/web-storage/read-web-storage.d.mts.map +1 -0
  243. package/dist/theme/web-storage/read-web-storage.mjs +20 -0
  244. package/dist/theme/web-storage/read-web-storage.mjs.map +1 -0
  245. package/dist/theme/web-storage/write-web-storage.cjs +33 -0
  246. package/dist/theme/web-storage/write-web-storage.cjs.map +1 -0
  247. package/dist/theme/web-storage/write-web-storage.d.cts +25 -0
  248. package/dist/theme/web-storage/write-web-storage.d.cts.map +1 -0
  249. package/dist/theme/web-storage/write-web-storage.d.mts +25 -0
  250. package/dist/theme/web-storage/write-web-storage.d.mts.map +1 -0
  251. package/dist/theme/web-storage/write-web-storage.mjs +32 -0
  252. package/dist/theme/web-storage/write-web-storage.mjs.map +1 -0
  253. package/dist/theme.cjs +41 -1
  254. package/dist/theme.d.cts +23 -3
  255. package/dist/theme.d.mts +23 -3
  256. package/dist/theme.mjs +21 -1
  257. package/package.json +1 -1
  258. package/src/react/hooks/use-theme-by-class-name.ts +3 -8
  259. package/src/react/hooks/use-theme-by-data-attribute.ts +3 -10
  260. package/src/react/hooks/use-theme-by-local-storage.ts +3 -9
  261. package/src/testing/theme/theme-result-card.tsx +1 -0
  262. package/src/theme/_utils/match-attribute-value-to-theme.ts +36 -0
  263. package/src/theme/_utils/parse-stored-theme.ts +52 -12
  264. package/src/theme/_utils/resolve-theme-map-value.ts +15 -0
  265. package/src/theme/class-name/parse-class-name.ts +31 -0
  266. package/src/theme/class-name/read-class-name.ts +24 -0
  267. package/src/theme/class-name/stringify-class-name.ts +36 -0
  268. package/src/theme/class-name/subscribe-class-name.ts +39 -0
  269. package/src/theme/class-name/write-class-name.ts +24 -0
  270. package/src/theme/cookie/_cookie-utils.ts +45 -0
  271. package/src/theme/cookie/read-cookie-theme.ts +33 -0
  272. package/src/theme/cookie/write-cookie-theme.ts +48 -0
  273. package/src/theme/data-attribute/_constant.ts +1 -0
  274. package/src/theme/data-attribute/parse-data-attribute.ts +25 -0
  275. package/src/theme/data-attribute/read-data-attribute.ts +29 -0
  276. package/src/theme/data-attribute/stringify-data-attribute.ts +39 -0
  277. package/src/theme/data-attribute/subscribe-data-attribute.ts +39 -0
  278. package/src/theme/data-attribute/write-data-attribute.ts +40 -0
  279. package/src/theme/local-storage/read-local-storage.ts +23 -0
  280. package/src/theme/local-storage/write-local-storage.ts +31 -0
  281. package/src/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.ts +30 -0
  282. package/src/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.ts +24 -0
  283. package/src/theme/session-storage/read-session-storage.ts +23 -0
  284. package/src/theme/session-storage/write-session-storage.ts +31 -0
  285. package/src/theme/theme-entry.types.ts +19 -0
  286. package/src/theme/theme-map.types.ts +9 -2
  287. package/src/theme/theme-store/class-name-theme-store/class-name-theme-store.ts +19 -25
  288. package/src/theme/theme-store/cookie-theme-store/cookie-theme-store.ts +18 -63
  289. package/src/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.ts +41 -28
  290. package/src/theme/theme-store/local-storage-theme-store/local-storage-theme-store.ts +17 -20
  291. package/src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts +4 -5
  292. package/src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts +17 -20
  293. package/src/theme/web-storage/read-web-storage.ts +22 -0
  294. package/src/theme/web-storage/write-web-storage.ts +46 -0
  295. package/src/theme.ts +20 -0
  296. package/dist/theme/class-name/apply-theme-to-class-name.cjs +0 -23
  297. package/dist/theme/class-name/apply-theme-to-class-name.cjs.map +0 -1
  298. package/dist/theme/class-name/apply-theme-to-class-name.mjs +0 -22
  299. package/dist/theme/class-name/apply-theme-to-class-name.mjs.map +0 -1
  300. package/dist/theme/class-name/resolve-theme-from-class-name.cjs +0 -23
  301. package/dist/theme/class-name/resolve-theme-from-class-name.cjs.map +0 -1
  302. package/dist/theme/class-name/resolve-theme-from-class-name.mjs +0 -22
  303. package/dist/theme/class-name/resolve-theme-from-class-name.mjs.map +0 -1
  304. package/dist/theme/data-attribute/apply-theme-to-data-attribute.cjs +0 -23
  305. package/dist/theme/data-attribute/apply-theme-to-data-attribute.cjs.map +0 -1
  306. package/dist/theme/data-attribute/apply-theme-to-data-attribute.mjs +0 -22
  307. package/dist/theme/data-attribute/apply-theme-to-data-attribute.mjs.map +0 -1
  308. package/dist/theme/data-attribute/resolve-theme-from-data-attribute.cjs +0 -23
  309. package/dist/theme/data-attribute/resolve-theme-from-data-attribute.cjs.map +0 -1
  310. package/dist/theme/data-attribute/resolve-theme-from-data-attribute.mjs +0 -22
  311. package/dist/theme/data-attribute/resolve-theme-from-data-attribute.mjs.map +0 -1
  312. package/src/theme/class-name/apply-theme-to-class-name.ts +0 -26
  313. package/src/theme/class-name/resolve-theme-from-class-name.ts +0 -22
  314. package/src/theme/data-attribute/apply-theme-to-data-attribute.ts +0 -27
  315. package/src/theme/data-attribute/resolve-theme-from-data-attribute.ts +0 -23
@@ -0,0 +1,33 @@
1
+ const require_resolve_theme_map_value = require('../_utils/resolve-theme-map-value.cjs');
2
+ const require__constant = require('./_constant.cjs');
3
+
4
+ //#region src/theme/data-attribute/stringify-data-attribute.ts
5
+ /**
6
+ * Stringifies a ThemeEntry for a data attribute value.
7
+ *
8
+ * Pure function: no DOM access. Removes all theme values from existing, then adds entry's value(s).
9
+ * Aligns with stringifyClassName logic.
10
+ *
11
+ * @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)
12
+ * @param existing - Current attribute value string
13
+ * @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)
14
+ * @param options.separator - Token separator (default: space)
15
+ * @returns Attribute value string
16
+ */
17
+ function stringifyDataAttribute(themes, existing, entry, options) {
18
+ const separator = options?.separator ?? require__constant.SEPARATOR_SPACE;
19
+ const allThemeValues = Object.values(themes).flatMap((v) => {
20
+ const resolved = require_resolve_theme_map_value.resolveThemeMapValue(v);
21
+ return Array.isArray(resolved) ? [...resolved] : [resolved];
22
+ });
23
+ const withoutThemeValues = (existing?.trim() ? existing.trim().split(separator) : []).filter((t) => !allThemeValues.includes(t.trim()));
24
+ const newTokens = entry !== void 0 ? (() => {
25
+ const resolved = require_resolve_theme_map_value.resolveThemeMapValue(entry.value);
26
+ return Array.isArray(resolved) ? [resolved[0]] : [resolved];
27
+ })() : [];
28
+ return [...withoutThemeValues, ...newTokens].filter(Boolean).join(separator);
29
+ }
30
+
31
+ //#endregion
32
+ exports.stringifyDataAttribute = stringifyDataAttribute;
33
+ //# sourceMappingURL=stringify-data-attribute.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-data-attribute.cjs","names":["SEPARATOR_SPACE","resolveThemeMapValue"],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":["import { resolveThemeMapValue } from '../_utils/resolve-theme-map-value.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\n\n/**\n * Stringifies a ThemeEntry for a data attribute value.\n *\n * Pure function: no DOM access. Removes all theme values from existing, then adds entry's value(s).\n * Aligns with stringifyClassName logic.\n *\n * @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)\n * @param existing - Current attribute value string\n * @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)\n * @param options.separator - Token separator (default: space)\n * @returns Attribute value string\n */\nexport function stringifyDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\texisting: string | undefined,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?: { separator?: string | undefined } | undefined\n): string {\n\tconst separator = options?.separator ?? SEPARATOR_SPACE\n\tconst allThemeValues = Object.values(themes).flatMap((v) => {\n\t\tconst resolved = resolveThemeMapValue(v)\n\t\treturn Array.isArray(resolved) ? [...resolved] : [resolved]\n\t})\n\tconst existingTokens = existing?.trim() ? existing.trim().split(separator) : []\n\tconst withoutThemeValues = existingTokens.filter((t) => !allThemeValues.includes(t.trim()))\n\tconst newTokens =\n\t\tentry !== undefined\n\t\t\t? (() => {\n\t\t\t\t\tconst resolved = resolveThemeMapValue(entry.value)\n\t\t\t\t\treturn Array.isArray(resolved) ? [resolved[0]] : [resolved]\n\t\t\t\t})()\n\t\t\t: []\n\treturn [...withoutThemeValues, ...newTokens].filter(Boolean).join(separator)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,uBACf,QACA,UACA,OACA,SACS;CACT,MAAM,YAAY,SAAS,aAAaA;CACxC,MAAM,iBAAiB,OAAO,OAAO,OAAO,CAAC,SAAS,MAAM;EAC3D,MAAM,WAAWC,qDAAqB,EAAE;AACxC,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,SAAS;GAC1D;CAEF,MAAM,sBADiB,UAAU,MAAM,GAAG,SAAS,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,EACrC,QAAQ,MAAM,CAAC,eAAe,SAAS,EAAE,MAAM,CAAC,CAAC;CAC3F,MAAM,YACL,UAAU,gBACA;EACP,MAAM,WAAWA,qDAAqB,MAAM,MAAM;AAClD,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS;KACxD,GACH,EAAE;AACN,QAAO,CAAC,GAAG,oBAAoB,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,UAAU"}
@@ -0,0 +1,23 @@
1
+ import { ThemeMap } from "../theme-map.types.cjs";
2
+ import { ThemeEntry } from "../theme-entry.types.cjs";
3
+
4
+ //#region src/theme/data-attribute/stringify-data-attribute.d.ts
5
+
6
+ /**
7
+ * Stringifies a ThemeEntry for a data attribute value.
8
+ *
9
+ * Pure function: no DOM access. Removes all theme values from existing, then adds entry's value(s).
10
+ * Aligns with stringifyClassName logic.
11
+ *
12
+ * @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)
13
+ * @param existing - Current attribute value string
14
+ * @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)
15
+ * @param options.separator - Token separator (default: space)
16
+ * @returns Attribute value string
17
+ */
18
+ declare function stringifyDataAttribute<Themes extends ThemeMap>(themes: Themes, existing: string | undefined, entry: ThemeEntry<Themes> | undefined, options?: {
19
+ separator?: string | undefined;
20
+ } | undefined): string;
21
+ //#endregion
22
+ export { stringifyDataAttribute };
23
+ //# sourceMappingURL=stringify-data-attribute.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiBA;;;;;;;;;;iBAAgB,sCAAsC,kBAC7C,6CAED,WAAW"}
@@ -0,0 +1,23 @@
1
+ import { ThemeMap } from "../theme-map.types.mjs";
2
+ import { ThemeEntry } from "../theme-entry.types.mjs";
3
+
4
+ //#region src/theme/data-attribute/stringify-data-attribute.d.ts
5
+
6
+ /**
7
+ * Stringifies a ThemeEntry for a data attribute value.
8
+ *
9
+ * Pure function: no DOM access. Removes all theme values from existing, then adds entry's value(s).
10
+ * Aligns with stringifyClassName logic.
11
+ *
12
+ * @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)
13
+ * @param existing - Current attribute value string
14
+ * @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)
15
+ * @param options.separator - Token separator (default: space)
16
+ * @returns Attribute value string
17
+ */
18
+ declare function stringifyDataAttribute<Themes extends ThemeMap>(themes: Themes, existing: string | undefined, entry: ThemeEntry<Themes> | undefined, options?: {
19
+ separator?: string | undefined;
20
+ } | undefined): string;
21
+ //#endregion
22
+ export { stringifyDataAttribute };
23
+ //# sourceMappingURL=stringify-data-attribute.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiBA;;;;;;;;;;iBAAgB,sCAAsC,kBAC7C,6CAED,WAAW"}
@@ -0,0 +1,33 @@
1
+ import { resolveThemeMapValue } from "../_utils/resolve-theme-map-value.mjs";
2
+ import { SEPARATOR_SPACE } from "./_constant.mjs";
3
+
4
+ //#region src/theme/data-attribute/stringify-data-attribute.ts
5
+ /**
6
+ * Stringifies a ThemeEntry for a data attribute value.
7
+ *
8
+ * Pure function: no DOM access. Removes all theme values from existing, then adds entry's value(s).
9
+ * Aligns with stringifyClassName logic.
10
+ *
11
+ * @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)
12
+ * @param existing - Current attribute value string
13
+ * @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)
14
+ * @param options.separator - Token separator (default: space)
15
+ * @returns Attribute value string
16
+ */
17
+ function stringifyDataAttribute(themes, existing, entry, options) {
18
+ const separator = options?.separator ?? SEPARATOR_SPACE;
19
+ const allThemeValues = Object.values(themes).flatMap((v) => {
20
+ const resolved = resolveThemeMapValue(v);
21
+ return Array.isArray(resolved) ? [...resolved] : [resolved];
22
+ });
23
+ const withoutThemeValues = (existing?.trim() ? existing.trim().split(separator) : []).filter((t) => !allThemeValues.includes(t.trim()));
24
+ const newTokens = entry !== void 0 ? (() => {
25
+ const resolved = resolveThemeMapValue(entry.value);
26
+ return Array.isArray(resolved) ? [resolved[0]] : [resolved];
27
+ })() : [];
28
+ return [...withoutThemeValues, ...newTokens].filter(Boolean).join(separator);
29
+ }
30
+
31
+ //#endregion
32
+ export { stringifyDataAttribute };
33
+ //# sourceMappingURL=stringify-data-attribute.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/stringify-data-attribute.ts"],"sourcesContent":["import { resolveThemeMapValue } from '../_utils/resolve-theme-map-value.ts'\nimport type { ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\n\n/**\n * Stringifies a ThemeEntry for a data attribute value.\n *\n * Pure function: no DOM access. Removes all theme values from existing, then adds entry's value(s).\n * Aligns with stringifyClassName logic.\n *\n * @param themes - Record mapping theme keys to attribute values (used to identify theme tokens)\n * @param existing - Current attribute value string\n * @param entry - Theme entry to stringify, or undefined to clear theme (keeps non-theme tokens)\n * @param options.separator - Token separator (default: space)\n * @returns Attribute value string\n */\nexport function stringifyDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\texisting: string | undefined,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?: { separator?: string | undefined } | undefined\n): string {\n\tconst separator = options?.separator ?? SEPARATOR_SPACE\n\tconst allThemeValues = Object.values(themes).flatMap((v) => {\n\t\tconst resolved = resolveThemeMapValue(v)\n\t\treturn Array.isArray(resolved) ? [...resolved] : [resolved]\n\t})\n\tconst existingTokens = existing?.trim() ? existing.trim().split(separator) : []\n\tconst withoutThemeValues = existingTokens.filter((t) => !allThemeValues.includes(t.trim()))\n\tconst newTokens =\n\t\tentry !== undefined\n\t\t\t? (() => {\n\t\t\t\t\tconst resolved = resolveThemeMapValue(entry.value)\n\t\t\t\t\treturn Array.isArray(resolved) ? [resolved[0]] : [resolved]\n\t\t\t\t})()\n\t\t\t: []\n\treturn [...withoutThemeValues, ...newTokens].filter(Boolean).join(separator)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,uBACf,QACA,UACA,OACA,SACS;CACT,MAAM,YAAY,SAAS,aAAa;CACxC,MAAM,iBAAiB,OAAO,OAAO,OAAO,CAAC,SAAS,MAAM;EAC3D,MAAM,WAAW,qBAAqB,EAAE;AACxC,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,SAAS;GAC1D;CAEF,MAAM,sBADiB,UAAU,MAAM,GAAG,SAAS,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,EACrC,QAAQ,MAAM,CAAC,eAAe,SAAS,EAAE,MAAM,CAAC,CAAC;CAC3F,MAAM,YACL,UAAU,gBACA;EACP,MAAM,WAAW,qBAAqB,MAAM,MAAM;AAClD,SAAO,MAAM,QAAQ,SAAS,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS;KACxD,GACH,EAAE;AACN,QAAO,CAAC,GAAG,oBAAoB,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,UAAU"}
@@ -0,0 +1,28 @@
1
+ const require_observe_data_attribute = require('../../attributes/observe-data-attribute.cjs');
2
+ const require__constant = require('./_constant.cjs');
3
+ const require_parse_data_attribute = require('./parse-data-attribute.cjs');
4
+
5
+ //#region src/theme/data-attribute/subscribe-data-attribute.ts
6
+ /**
7
+ * Subscribes to changes on a data attribute and invokes the handler with parsed theme entries.
8
+ *
9
+ * @param themes - Record mapping theme keys to attribute values
10
+ * @param attributeName - Data attribute name (e.g. `data-theme`)
11
+ * @param handler - Callback invoked when the attribute changes
12
+ * @param options.element - Element to observe (defaults to document.documentElement)
13
+ * @param options.parse - Custom parser (default: parseDataAttribute with space separator)
14
+ * @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
15
+ */
16
+ function subscribeDataAttribute(themes, attributeName, handler, options) {
17
+ const element = options?.element ?? document?.documentElement;
18
+ if (!element) return () => {};
19
+ const parse = options?.parse ?? ((t, v) => require_parse_data_attribute.parseDataAttribute(t, v, { separator: require__constant.SEPARATOR_SPACE }));
20
+ const observer = require_observe_data_attribute.observeDataAttributes({ [attributeName]: (value) => {
21
+ handler(parse(themes, value ?? void 0));
22
+ } }, element);
23
+ return () => observer.disconnect();
24
+ }
25
+
26
+ //#endregion
27
+ exports.subscribeDataAttribute = subscribeDataAttribute;
28
+ //# sourceMappingURL=subscribe-data-attribute.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribe-data-attribute.cjs","names":["parseDataAttribute","SEPARATOR_SPACE","observeDataAttributes"],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":["import { observeDataAttributes } from '../../attributes/observe-data-attribute.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { parseDataAttribute } from './parse-data-attribute.ts'\n\n/**\n * Subscribes to changes on a data attribute and invokes the handler with parsed theme entries.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param handler - Callback invoked when the attribute changes\n * @param options.element - Element to observe (defaults to document.documentElement)\n * @param options.parse - Custom parser (default: parseDataAttribute with space separator)\n * @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).\n */\nexport function subscribeDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tattributeName: `data-${string}`,\n\thandler: (entry: ThemeEntry<Themes> | undefined) => void,\n\toptions?:\n\t\t| { element?: Element | undefined; parse?: ParseStoredTheme<Themes> | undefined }\n\t\t| undefined\n): () => void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return () => {}\n\tconst parse =\n\t\toptions?.parse ?? ((t, v) => parseDataAttribute(t, v, { separator: SEPARATOR_SPACE }))\n\tconst observer = observeDataAttributes<string, `data-${string}`>(\n\t\t{\n\t\t\t[attributeName]: (value) => {\n\t\t\t\tconst entry = parse(themes, value ?? undefined)\n\t\t\t\thandler(entry)\n\t\t\t}\n\t\t},\n\t\telement\n\t)\n\treturn () => observer.disconnect()\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,uBACf,QACA,eACA,SACA,SAGa;CACb,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS,cAAa;CAC3B,MAAM,QACL,SAAS,WAAW,GAAG,MAAMA,gDAAmB,GAAG,GAAG,EAAE,WAAWC,mCAAiB,CAAC;CACtF,MAAM,WAAWC,qDAChB,GACE,iBAAiB,UAAU;AAE3B,UADc,MAAM,QAAQ,SAAS,OAAU,CACjC;IAEf,EACD,QACA;AACD,cAAa,SAAS,YAAY"}
@@ -0,0 +1,22 @@
1
+ import { ThemeMap } from "../theme-map.types.cjs";
2
+ import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
3
+
4
+ //#region src/theme/data-attribute/subscribe-data-attribute.d.ts
5
+
6
+ /**
7
+ * Subscribes to changes on a data attribute and invokes the handler with parsed theme entries.
8
+ *
9
+ * @param themes - Record mapping theme keys to attribute values
10
+ * @param attributeName - Data attribute name (e.g. `data-theme`)
11
+ * @param handler - Callback invoked when the attribute changes
12
+ * @param options.element - Element to observe (defaults to document.documentElement)
13
+ * @param options.parse - Custom parser (default: parseDataAttribute with space separator)
14
+ * @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
15
+ */
16
+ declare function subscribeDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, handler: (entry: ThemeEntry<Themes> | undefined) => void, options?: {
17
+ element?: Element | undefined;
18
+ parse?: ParseStoredTheme<Themes> | undefined;
19
+ } | undefined): () => void;
20
+ //#endregion
21
+ export { subscribeDataAttribute };
22
+ //# sourceMappingURL=subscribe-data-attribute.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribe-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;;AAK6D,iBAL7C,sBAK6C,CAAA,eALP,QAKO,CAAA,CAAA,MAAA,EAJpD,MAIoD,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,OAAA,EAAA,CAAA,KAAA,EAF3C,UAE2C,CAFhC,MAEgC,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA,EAAA,QAAA,EAAA;YAA7C;UAA6B,iBAAiB"}
@@ -0,0 +1,22 @@
1
+ import { ThemeMap } from "../theme-map.types.mjs";
2
+ import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
3
+
4
+ //#region src/theme/data-attribute/subscribe-data-attribute.d.ts
5
+
6
+ /**
7
+ * Subscribes to changes on a data attribute and invokes the handler with parsed theme entries.
8
+ *
9
+ * @param themes - Record mapping theme keys to attribute values
10
+ * @param attributeName - Data attribute name (e.g. `data-theme`)
11
+ * @param handler - Callback invoked when the attribute changes
12
+ * @param options.element - Element to observe (defaults to document.documentElement)
13
+ * @param options.parse - Custom parser (default: parseDataAttribute with space separator)
14
+ * @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
15
+ */
16
+ declare function subscribeDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, handler: (entry: ThemeEntry<Themes> | undefined) => void, options?: {
17
+ element?: Element | undefined;
18
+ parse?: ParseStoredTheme<Themes> | undefined;
19
+ } | undefined): () => void;
20
+ //#endregion
21
+ export { subscribeDataAttribute };
22
+ //# sourceMappingURL=subscribe-data-attribute.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribe-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;;AAK6D,iBAL7C,sBAK6C,CAAA,eALP,QAKO,CAAA,CAAA,MAAA,EAJpD,MAIoD,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,OAAA,EAAA,CAAA,KAAA,EAF3C,UAE2C,CAFhC,MAEgC,CAAA,GAAA,SAAA,EAAA,GAAA,IAAA,EAAA,QAAA,EAAA;YAA7C;UAA6B,iBAAiB"}
@@ -0,0 +1,28 @@
1
+ import { observeDataAttributes } from "../../attributes/observe-data-attribute.mjs";
2
+ import { SEPARATOR_SPACE } from "./_constant.mjs";
3
+ import { parseDataAttribute } from "./parse-data-attribute.mjs";
4
+
5
+ //#region src/theme/data-attribute/subscribe-data-attribute.ts
6
+ /**
7
+ * Subscribes to changes on a data attribute and invokes the handler with parsed theme entries.
8
+ *
9
+ * @param themes - Record mapping theme keys to attribute values
10
+ * @param attributeName - Data attribute name (e.g. `data-theme`)
11
+ * @param handler - Callback invoked when the attribute changes
12
+ * @param options.element - Element to observe (defaults to document.documentElement)
13
+ * @param options.parse - Custom parser (default: parseDataAttribute with space separator)
14
+ * @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).
15
+ */
16
+ function subscribeDataAttribute(themes, attributeName, handler, options) {
17
+ const element = options?.element ?? document?.documentElement;
18
+ if (!element) return () => {};
19
+ const parse = options?.parse ?? ((t, v) => parseDataAttribute(t, v, { separator: SEPARATOR_SPACE }));
20
+ const observer = observeDataAttributes({ [attributeName]: (value) => {
21
+ handler(parse(themes, value ?? void 0));
22
+ } }, element);
23
+ return () => observer.disconnect();
24
+ }
25
+
26
+ //#endregion
27
+ export { subscribeDataAttribute };
28
+ //# sourceMappingURL=subscribe-data-attribute.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribe-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/subscribe-data-attribute.ts"],"sourcesContent":["import { observeDataAttributes } from '../../attributes/observe-data-attribute.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { parseDataAttribute } from './parse-data-attribute.ts'\n\n/**\n * Subscribes to changes on a data attribute and invokes the handler with parsed theme entries.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param handler - Callback invoked when the attribute changes\n * @param options.element - Element to observe (defaults to document.documentElement)\n * @param options.parse - Custom parser (default: parseDataAttribute with space separator)\n * @returns Unsubscribe function. Returns a no-op function when element is not available (e.g. SSR).\n */\nexport function subscribeDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tattributeName: `data-${string}`,\n\thandler: (entry: ThemeEntry<Themes> | undefined) => void,\n\toptions?:\n\t\t| { element?: Element | undefined; parse?: ParseStoredTheme<Themes> | undefined }\n\t\t| undefined\n): () => void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return () => {}\n\tconst parse =\n\t\toptions?.parse ?? ((t, v) => parseDataAttribute(t, v, { separator: SEPARATOR_SPACE }))\n\tconst observer = observeDataAttributes<string, `data-${string}`>(\n\t\t{\n\t\t\t[attributeName]: (value) => {\n\t\t\t\tconst entry = parse(themes, value ?? undefined)\n\t\t\t\thandler(entry)\n\t\t\t}\n\t\t},\n\t\telement\n\t)\n\treturn () => observer.disconnect()\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,uBACf,QACA,eACA,SACA,SAGa;CACb,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS,cAAa;CAC3B,MAAM,QACL,SAAS,WAAW,GAAG,MAAM,mBAAmB,GAAG,GAAG,EAAE,WAAW,iBAAiB,CAAC;CACtF,MAAM,WAAW,sBAChB,GACE,iBAAiB,UAAU;AAE3B,UADc,MAAM,QAAQ,SAAS,OAAU,CACjC;IAEf,EACD,QACA;AACD,cAAa,SAAS,YAAY"}
@@ -0,0 +1,30 @@
1
+ const require_get_data_attribute = require('../../attributes/get-data-attribute.cjs');
2
+ const require__constant = require('./_constant.cjs');
3
+ const require_stringify_data_attribute = require('./stringify-data-attribute.cjs');
4
+
5
+ //#region src/theme/data-attribute/write-data-attribute.ts
6
+ /**
7
+ * Writes a theme entry to a data attribute on an element.
8
+ *
9
+ * @param themes - Record mapping theme keys to attribute values
10
+ * @param attributeName - Data attribute name (e.g. `data-theme`)
11
+ * @param entry - Theme entry to write, or undefined to remove the theme
12
+ * @param options.element - Element to write to (defaults to document.documentElement)
13
+ * @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)
14
+ */
15
+ function writeDataAttribute(themes, attributeName, entry, options) {
16
+ const element = options?.element ?? document?.documentElement;
17
+ if (!element) return;
18
+ const stringify = options?.stringify ?? ((t, x, e) => require_stringify_data_attribute.stringifyDataAttribute(t, x, e, { separator: require__constant.SEPARATOR_SPACE }));
19
+ if (entry === void 0) {
20
+ element.removeAttribute(attributeName);
21
+ return;
22
+ }
23
+ const result = stringify(themes, require_get_data_attribute.getDataAttribute(attributeName, element) ?? void 0, entry);
24
+ if (result === "") element.removeAttribute(attributeName);
25
+ else element.setAttribute(attributeName, result);
26
+ }
27
+
28
+ //#endregion
29
+ exports.writeDataAttribute = writeDataAttribute;
30
+ //# sourceMappingURL=write-data-attribute.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-data-attribute.cjs","names":["stringifyDataAttribute","SEPARATOR_SPACE","getDataAttribute"],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":["import { getDataAttribute } from '../../attributes/get-data-attribute.ts'\nimport type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { stringifyDataAttribute } from './stringify-data-attribute.ts'\n\n/**\n * Writes a theme entry to a data attribute on an element.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param entry - Theme entry to write, or undefined to remove the theme\n * @param options.element - Element to write to (defaults to document.documentElement)\n * @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)\n */\nexport function writeDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tattributeName: `data-${string}`,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?:\n\t\t| { element?: Element | undefined; stringify?: StringifyStoredTheme<Themes> | undefined }\n\t\t| undefined\n): void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return\n\tconst stringify =\n\t\toptions?.stringify ??\n\t\t((t, x, e) => stringifyDataAttribute(t, x, e, { separator: SEPARATOR_SPACE }))\n\tif (entry === undefined) {\n\t\telement.removeAttribute(attributeName)\n\t\treturn\n\t}\n\tconst existing = getDataAttribute(attributeName, element) ?? undefined\n\tconst result = stringify(themes, existing, entry)\n\tif (result === '') {\n\t\telement.removeAttribute(attributeName)\n\t} else {\n\t\telement.setAttribute(attributeName, result)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,mBACf,QACA,eACA,OACA,SAGO;CACP,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS;CACd,MAAM,YACL,SAAS,eACP,GAAG,GAAG,MAAMA,wDAAuB,GAAG,GAAG,GAAG,EAAE,WAAWC,mCAAiB,CAAC;AAC9E,KAAI,UAAU,QAAW;AACxB,UAAQ,gBAAgB,cAAc;AACtC;;CAGD,MAAM,SAAS,UAAU,QADRC,4CAAiB,eAAe,QAAQ,IAAI,QAClB,MAAM;AACjD,KAAI,WAAW,GACd,SAAQ,gBAAgB,cAAc;KAEtC,SAAQ,aAAa,eAAe,OAAO"}
@@ -0,0 +1,21 @@
1
+ import { ThemeMap } from "../theme-map.types.cjs";
2
+ import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
3
+
4
+ //#region src/theme/data-attribute/write-data-attribute.d.ts
5
+
6
+ /**
7
+ * Writes a theme entry to a data attribute on an element.
8
+ *
9
+ * @param themes - Record mapping theme keys to attribute values
10
+ * @param attributeName - Data attribute name (e.g. `data-theme`)
11
+ * @param entry - Theme entry to write, or undefined to remove the theme
12
+ * @param options.element - Element to write to (defaults to document.documentElement)
13
+ * @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)
14
+ */
15
+ declare function writeDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, entry: ThemeEntry<Themes> | undefined, options?: {
16
+ element?: Element | undefined;
17
+ stringify?: StringifyStoredTheme<Themes> | undefined;
18
+ } | undefined): void;
19
+ //#endregion
20
+ export { writeDataAttribute };
21
+ //# sourceMappingURL=write-data-attribute.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-data-attribute.d.cts","names":[],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;AAKiD,iBALjC,kBAKiC,CAAA,eALC,QAKD,CAAA,CAAA,MAAA,EAJxC,MAIwC,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,KAAA,EAFzC,UAEyC,CAF9B,MAE8B,CAAA,GAAA,SAAA,EAAA,QAAA,EAAA;EAAoB,OAAA,CAAA,EAArD,OAAqD,GAAA,SAAA;cAApB,qBAAqB"}
@@ -0,0 +1,21 @@
1
+ import { ThemeMap } from "../theme-map.types.mjs";
2
+ import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
3
+
4
+ //#region src/theme/data-attribute/write-data-attribute.d.ts
5
+
6
+ /**
7
+ * Writes a theme entry to a data attribute on an element.
8
+ *
9
+ * @param themes - Record mapping theme keys to attribute values
10
+ * @param attributeName - Data attribute name (e.g. `data-theme`)
11
+ * @param entry - Theme entry to write, or undefined to remove the theme
12
+ * @param options.element - Element to write to (defaults to document.documentElement)
13
+ * @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)
14
+ */
15
+ declare function writeDataAttribute<Themes extends ThemeMap>(themes: Themes, attributeName: `data-${string}`, entry: ThemeEntry<Themes> | undefined, options?: {
16
+ element?: Element | undefined;
17
+ stringify?: StringifyStoredTheme<Themes> | undefined;
18
+ } | undefined): void;
19
+ //#endregion
20
+ export { writeDataAttribute };
21
+ //# sourceMappingURL=write-data-attribute.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-data-attribute.d.mts","names":[],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;AAKiD,iBALjC,kBAKiC,CAAA,eALC,QAKD,CAAA,CAAA,MAAA,EAJxC,MAIwC,EAAA,aAAA,EAAA,QAAA,MAAA,EAAA,EAAA,KAAA,EAFzC,UAEyC,CAF9B,MAE8B,CAAA,GAAA,SAAA,EAAA,QAAA,EAAA;EAAoB,OAAA,CAAA,EAArD,OAAqD,GAAA,SAAA;cAApB,qBAAqB"}
@@ -0,0 +1,30 @@
1
+ import { getDataAttribute } from "../../attributes/get-data-attribute.mjs";
2
+ import { SEPARATOR_SPACE } from "./_constant.mjs";
3
+ import { stringifyDataAttribute } from "./stringify-data-attribute.mjs";
4
+
5
+ //#region src/theme/data-attribute/write-data-attribute.ts
6
+ /**
7
+ * Writes a theme entry to a data attribute on an element.
8
+ *
9
+ * @param themes - Record mapping theme keys to attribute values
10
+ * @param attributeName - Data attribute name (e.g. `data-theme`)
11
+ * @param entry - Theme entry to write, or undefined to remove the theme
12
+ * @param options.element - Element to write to (defaults to document.documentElement)
13
+ * @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)
14
+ */
15
+ function writeDataAttribute(themes, attributeName, entry, options) {
16
+ const element = options?.element ?? document?.documentElement;
17
+ if (!element) return;
18
+ const stringify = options?.stringify ?? ((t, x, e) => stringifyDataAttribute(t, x, e, { separator: SEPARATOR_SPACE }));
19
+ if (entry === void 0) {
20
+ element.removeAttribute(attributeName);
21
+ return;
22
+ }
23
+ const result = stringify(themes, getDataAttribute(attributeName, element) ?? void 0, entry);
24
+ if (result === "") element.removeAttribute(attributeName);
25
+ else element.setAttribute(attributeName, result);
26
+ }
27
+
28
+ //#endregion
29
+ export { writeDataAttribute };
30
+ //# sourceMappingURL=write-data-attribute.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-data-attribute.mjs","names":[],"sources":["../../../src/theme/data-attribute/write-data-attribute.ts"],"sourcesContent":["import { getDataAttribute } from '../../attributes/get-data-attribute.ts'\nimport type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { SEPARATOR_SPACE } from './_constant.ts'\nimport { stringifyDataAttribute } from './stringify-data-attribute.ts'\n\n/**\n * Writes a theme entry to a data attribute on an element.\n *\n * @param themes - Record mapping theme keys to attribute values\n * @param attributeName - Data attribute name (e.g. `data-theme`)\n * @param entry - Theme entry to write, or undefined to remove the theme\n * @param options.element - Element to write to (defaults to document.documentElement)\n * @param options.stringify - Custom serializer (default: stringifyDataAttribute with space separator)\n */\nexport function writeDataAttribute<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tattributeName: `data-${string}`,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?:\n\t\t| { element?: Element | undefined; stringify?: StringifyStoredTheme<Themes> | undefined }\n\t\t| undefined\n): void {\n\tconst element = options?.element ?? document?.documentElement\n\tif (!element) return\n\tconst stringify =\n\t\toptions?.stringify ??\n\t\t((t, x, e) => stringifyDataAttribute(t, x, e, { separator: SEPARATOR_SPACE }))\n\tif (entry === undefined) {\n\t\telement.removeAttribute(attributeName)\n\t\treturn\n\t}\n\tconst existing = getDataAttribute(attributeName, element) ?? undefined\n\tconst result = stringify(themes, existing, entry)\n\tif (result === '') {\n\t\telement.removeAttribute(attributeName)\n\t} else {\n\t\telement.setAttribute(attributeName, result)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,mBACf,QACA,eACA,OACA,SAGO;CACP,MAAM,UAAU,SAAS,WAAW,UAAU;AAC9C,KAAI,CAAC,QAAS;CACd,MAAM,YACL,SAAS,eACP,GAAG,GAAG,MAAM,uBAAuB,GAAG,GAAG,GAAG,EAAE,WAAW,iBAAiB,CAAC;AAC9E,KAAI,UAAU,QAAW;AACxB,UAAQ,gBAAgB,cAAc;AACtC;;CAGD,MAAM,SAAS,UAAU,QADR,iBAAiB,eAAe,QAAQ,IAAI,QAClB,MAAM;AACjD,KAAI,WAAW,GACd,SAAQ,gBAAgB,cAAc;KAEtC,SAAQ,aAAa,eAAe,OAAO"}
@@ -0,0 +1,22 @@
1
+ const require_read_web_storage = require('../web-storage/read-web-storage.cjs');
2
+
3
+ //#region src/theme/local-storage/read-local-storage.ts
4
+ /**
5
+ * Reads a theme entry from localStorage.
6
+ *
7
+ * @param themes - Record mapping theme keys to values (for validation)
8
+ * @param storageKey - localStorage key to read from
9
+ * @param options.parse - Custom parser (default: parseStoredTheme)
10
+ * @returns ThemeEntry if found, undefined otherwise. Returns undefined when localStorage is unavailable (e.g. SSR).
11
+ */
12
+ function readLocalStorage(themes, storageKey, options) {
13
+ if (!window?.localStorage) return void 0;
14
+ return require_read_web_storage.readWebStorage(themes, storageKey, {
15
+ storage: window.localStorage,
16
+ parse: options?.parse
17
+ });
18
+ }
19
+
20
+ //#endregion
21
+ exports.readLocalStorage = readLocalStorage;
22
+ //# sourceMappingURL=read-local-storage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-local-storage.cjs","names":["readWebStorage"],"sources":["../../../src/theme/local-storage/read-local-storage.ts"],"sourcesContent":["import type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { readWebStorage } from '../web-storage/read-web-storage.ts'\n\n/**\n * Reads a theme entry from localStorage.\n *\n * @param themes - Record mapping theme keys to values (for validation)\n * @param storageKey - localStorage key to read from\n * @param options.parse - Custom parser (default: parseStoredTheme)\n * @returns ThemeEntry if found, undefined otherwise. Returns undefined when localStorage is unavailable (e.g. SSR).\n */\nexport function readLocalStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\toptions?: { parse?: ParseStoredTheme<Themes> | undefined }\n): ThemeEntry<Themes> | undefined {\n\tif (!window?.localStorage) return undefined\n\treturn readWebStorage(themes, storageKey, {\n\t\tstorage: window.localStorage,\n\t\tparse: options?.parse\n\t})\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,iBACf,QACA,YACA,SACiC;AACjC,KAAI,CAAC,QAAQ,aAAc,QAAO;AAClC,QAAOA,wCAAe,QAAQ,YAAY;EACzC,SAAS,OAAO;EAChB,OAAO,SAAS;EAChB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { ThemeMap } from "../theme-map.types.cjs";
2
+ import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
3
+
4
+ //#region src/theme/local-storage/read-local-storage.d.ts
5
+
6
+ /**
7
+ * Reads a theme entry from localStorage.
8
+ *
9
+ * @param themes - Record mapping theme keys to values (for validation)
10
+ * @param storageKey - localStorage key to read from
11
+ * @param options.parse - Custom parser (default: parseStoredTheme)
12
+ * @returns ThemeEntry if found, undefined otherwise. Returns undefined when localStorage is unavailable (e.g. SSR).
13
+ */
14
+ declare function readLocalStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, options?: {
15
+ parse?: ParseStoredTheme<Themes> | undefined;
16
+ }): ThemeEntry<Themes> | undefined;
17
+ //#endregion
18
+ export { readLocalStorage };
19
+ //# sourceMappingURL=read-local-storage.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-local-storage.d.cts","names":[],"sources":["../../../src/theme/local-storage/read-local-storage.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;;;;;;AAIG,iBAJa,gBAIb,CAAA,eAJ6C,QAI7C,CAAA,CAAA,MAAA,EAHM,MAGN,EAAA,UAAA,EAAA,MAAA,EAAA,QAAA,EAAA;EAAU,KAAA,CAAA,EADQ,gBACR,CADyB,MACzB,CAAA,GAAA,SAAA;IAAV,WAAW"}
@@ -0,0 +1,19 @@
1
+ import { ThemeMap } from "../theme-map.types.mjs";
2
+ import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
3
+
4
+ //#region src/theme/local-storage/read-local-storage.d.ts
5
+
6
+ /**
7
+ * Reads a theme entry from localStorage.
8
+ *
9
+ * @param themes - Record mapping theme keys to values (for validation)
10
+ * @param storageKey - localStorage key to read from
11
+ * @param options.parse - Custom parser (default: parseStoredTheme)
12
+ * @returns ThemeEntry if found, undefined otherwise. Returns undefined when localStorage is unavailable (e.g. SSR).
13
+ */
14
+ declare function readLocalStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, options?: {
15
+ parse?: ParseStoredTheme<Themes> | undefined;
16
+ }): ThemeEntry<Themes> | undefined;
17
+ //#endregion
18
+ export { readLocalStorage };
19
+ //# sourceMappingURL=read-local-storage.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-local-storage.d.mts","names":[],"sources":["../../../src/theme/local-storage/read-local-storage.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;;;;;;AAIG,iBAJa,gBAIb,CAAA,eAJ6C,QAI7C,CAAA,CAAA,MAAA,EAHM,MAGN,EAAA,UAAA,EAAA,MAAA,EAAA,QAAA,EAAA;EAAU,KAAA,CAAA,EADQ,gBACR,CADyB,MACzB,CAAA,GAAA,SAAA;IAAV,WAAW"}
@@ -0,0 +1,22 @@
1
+ import { readWebStorage } from "../web-storage/read-web-storage.mjs";
2
+
3
+ //#region src/theme/local-storage/read-local-storage.ts
4
+ /**
5
+ * Reads a theme entry from localStorage.
6
+ *
7
+ * @param themes - Record mapping theme keys to values (for validation)
8
+ * @param storageKey - localStorage key to read from
9
+ * @param options.parse - Custom parser (default: parseStoredTheme)
10
+ * @returns ThemeEntry if found, undefined otherwise. Returns undefined when localStorage is unavailable (e.g. SSR).
11
+ */
12
+ function readLocalStorage(themes, storageKey, options) {
13
+ if (!window?.localStorage) return void 0;
14
+ return readWebStorage(themes, storageKey, {
15
+ storage: window.localStorage,
16
+ parse: options?.parse
17
+ });
18
+ }
19
+
20
+ //#endregion
21
+ export { readLocalStorage };
22
+ //# sourceMappingURL=read-local-storage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-local-storage.mjs","names":[],"sources":["../../../src/theme/local-storage/read-local-storage.ts"],"sourcesContent":["import type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { readWebStorage } from '../web-storage/read-web-storage.ts'\n\n/**\n * Reads a theme entry from localStorage.\n *\n * @param themes - Record mapping theme keys to values (for validation)\n * @param storageKey - localStorage key to read from\n * @param options.parse - Custom parser (default: parseStoredTheme)\n * @returns ThemeEntry if found, undefined otherwise. Returns undefined when localStorage is unavailable (e.g. SSR).\n */\nexport function readLocalStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\toptions?: { parse?: ParseStoredTheme<Themes> | undefined }\n): ThemeEntry<Themes> | undefined {\n\tif (!window?.localStorage) return undefined\n\treturn readWebStorage(themes, storageKey, {\n\t\tstorage: window.localStorage,\n\t\tparse: options?.parse\n\t})\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,iBACf,QACA,YACA,SACiC;AACjC,KAAI,CAAC,QAAQ,aAAc,QAAO;AAClC,QAAO,eAAe,QAAQ,YAAY;EACzC,SAAS,OAAO;EAChB,OAAO,SAAS;EAChB,CAAC"}
@@ -0,0 +1,26 @@
1
+ const require_write_web_storage = require('../web-storage/write-web-storage.cjs');
2
+
3
+ //#region src/theme/local-storage/write-local-storage.ts
4
+ /**
5
+ * Writes a theme entry to localStorage.
6
+ *
7
+ * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.
8
+ *
9
+ * @param themes - Record mapping theme keys to values (used by stringify)
10
+ * @param storageKey - localStorage key to write to
11
+ * @param entry - Theme entry to write, or undefined to remove
12
+ * @param options.stringify - Custom serializer (default: JSON.stringify)
13
+ * @param options.onError - Optional callback invoked when storage write throws
14
+ */
15
+ function writeLocalStorage(themes, storageKey, entry, options) {
16
+ if (!window?.localStorage) return;
17
+ require_write_web_storage.writeWebStorage(themes, storageKey, entry, {
18
+ storage: window.localStorage,
19
+ stringify: options?.stringify,
20
+ onError: options?.onError
21
+ });
22
+ }
23
+
24
+ //#endregion
25
+ exports.writeLocalStorage = writeLocalStorage;
26
+ //# sourceMappingURL=write-local-storage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-local-storage.cjs","names":[],"sources":["../../../src/theme/local-storage/write-local-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\nimport { writeWebStorage } from '../web-storage/write-web-storage.ts'\n\n/**\n * Writes a theme entry to localStorage.\n *\n * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.\n *\n * @param themes - Record mapping theme keys to values (used by stringify)\n * @param storageKey - localStorage key to write to\n * @param entry - Theme entry to write, or undefined to remove\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n */\nexport function writeLocalStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | undefined,\n\toptions?: {\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tif (!window?.localStorage) return\n\twriteWebStorage(themes, storageKey, entry, {\n\t\tstorage: window.localStorage,\n\t\tstringify: options?.stringify,\n\t\tonError: options?.onError\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,kBACf,QACA,YACA,OACA,SAIO;AACP,KAAI,CAAC,QAAQ,aAAc;AAC3B,2CAAgB,QAAQ,YAAY,OAAO;EAC1C,SAAS,OAAO;EAChB,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { ThemeMap } from "../theme-map.types.cjs";
2
+ import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
3
+
4
+ //#region src/theme/local-storage/write-local-storage.d.ts
5
+
6
+ /**
7
+ * Writes a theme entry to localStorage.
8
+ *
9
+ * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.
10
+ *
11
+ * @param themes - Record mapping theme keys to values (used by stringify)
12
+ * @param storageKey - localStorage key to write to
13
+ * @param entry - Theme entry to write, or undefined to remove
14
+ * @param options.stringify - Custom serializer (default: JSON.stringify)
15
+ * @param options.onError - Optional callback invoked when storage write throws
16
+ */
17
+ declare function writeLocalStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | undefined, options?: {
18
+ stringify?: StringifyStoredTheme<Themes> | undefined;
19
+ onError?: ((error: unknown) => void) | undefined;
20
+ }): void;
21
+ //#endregion
22
+ export { writeLocalStorage };
23
+ //# sourceMappingURL=write-local-storage.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-local-storage.d.cts","names":[],"sources":["../../../src/theme/local-storage/write-local-storage.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;;;iBAAgB,iCAAiC,kBACxC,mCAED,WAAW;cAEL,qBAAqB"}
@@ -0,0 +1,23 @@
1
+ import { ThemeMap } from "../theme-map.types.mjs";
2
+ import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
3
+
4
+ //#region src/theme/local-storage/write-local-storage.d.ts
5
+
6
+ /**
7
+ * Writes a theme entry to localStorage.
8
+ *
9
+ * Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.
10
+ *
11
+ * @param themes - Record mapping theme keys to values (used by stringify)
12
+ * @param storageKey - localStorage key to write to
13
+ * @param entry - Theme entry to write, or undefined to remove
14
+ * @param options.stringify - Custom serializer (default: JSON.stringify)
15
+ * @param options.onError - Optional callback invoked when storage write throws
16
+ */
17
+ declare function writeLocalStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | undefined, options?: {
18
+ stringify?: StringifyStoredTheme<Themes> | undefined;
19
+ onError?: ((error: unknown) => void) | undefined;
20
+ }): void;
21
+ //#endregion
22
+ export { writeLocalStorage };
23
+ //# sourceMappingURL=write-local-storage.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-local-storage.d.mts","names":[],"sources":["../../../src/theme/local-storage/write-local-storage.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;;;iBAAgB,iCAAiC,kBACxC,mCAED,WAAW;cAEL,qBAAqB"}