@just-web/toolkits 1.0.0 → 2.1.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.
- package/dist/attributes/get-attribute.cjs +1 -1
- package/dist/attributes/get-attribute.cjs.map +1 -1
- package/dist/attributes/get-attribute.d.cts +2 -2
- package/dist/attributes/get-attribute.d.cts.map +1 -1
- package/dist/attributes/get-attribute.d.mts +2 -2
- package/dist/attributes/get-attribute.d.mts.map +1 -1
- package/dist/attributes/get-attribute.mjs +1 -1
- package/dist/attributes/get-attribute.mjs.map +1 -1
- package/dist/attributes/get-data-attribute.cjs +1 -1
- package/dist/attributes/get-data-attribute.cjs.map +1 -1
- package/dist/attributes/get-data-attribute.d.cts +2 -2
- package/dist/attributes/get-data-attribute.d.cts.map +1 -1
- package/dist/attributes/get-data-attribute.d.mts +2 -2
- package/dist/attributes/get-data-attribute.d.mts.map +1 -1
- package/dist/attributes/get-data-attribute.mjs +1 -1
- package/dist/attributes/get-data-attribute.mjs.map +1 -1
- package/dist/attributes/observe-attribute.cjs +1 -1
- package/dist/attributes/observe-attribute.cjs.map +1 -1
- package/dist/attributes/observe-attribute.d.cts +2 -2
- package/dist/attributes/observe-attribute.d.cts.map +1 -1
- package/dist/attributes/observe-attribute.d.mts +2 -2
- package/dist/attributes/observe-attribute.d.mts.map +1 -1
- package/dist/attributes/observe-attribute.mjs +1 -1
- package/dist/attributes/observe-attribute.mjs.map +1 -1
- package/dist/attributes/observe-data-attribute.cjs +1 -1
- package/dist/attributes/observe-data-attribute.cjs.map +1 -1
- package/dist/attributes/observe-data-attribute.d.cts +2 -2
- package/dist/attributes/observe-data-attribute.d.cts.map +1 -1
- package/dist/attributes/observe-data-attribute.d.mts +2 -2
- package/dist/attributes/observe-data-attribute.d.mts.map +1 -1
- package/dist/attributes/observe-data-attribute.mjs +1 -1
- package/dist/attributes/observe-data-attribute.mjs.map +1 -1
- package/dist/color-scheme/color-scheme.types.d.cts +11 -0
- package/dist/color-scheme/color-scheme.types.d.cts.map +1 -0
- package/dist/color-scheme/color-scheme.types.d.mts +11 -0
- package/dist/color-scheme/color-scheme.types.d.mts.map +1 -0
- package/dist/color-scheme/get-prefers-color-scheme.cjs +3 -1
- package/dist/color-scheme/get-prefers-color-scheme.cjs.map +1 -1
- package/dist/color-scheme/get-prefers-color-scheme.d.cts +7 -2
- package/dist/color-scheme/get-prefers-color-scheme.d.cts.map +1 -1
- package/dist/color-scheme/get-prefers-color-scheme.d.mts +7 -2
- package/dist/color-scheme/get-prefers-color-scheme.d.mts.map +1 -1
- package/dist/color-scheme/get-prefers-color-scheme.mjs +3 -1
- package/dist/color-scheme/get-prefers-color-scheme.mjs.map +1 -1
- package/dist/color-scheme/observe-prefers-color-scheme.cjs.map +1 -1
- package/dist/color-scheme/observe-prefers-color-scheme.d.cts +4 -1
- package/dist/color-scheme/observe-prefers-color-scheme.d.cts.map +1 -1
- package/dist/color-scheme/observe-prefers-color-scheme.d.mts +4 -1
- package/dist/color-scheme/observe-prefers-color-scheme.d.mts.map +1 -1
- package/dist/color-scheme/observe-prefers-color-scheme.mjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/react/hooks/use-attribute.cjs +7 -7
- package/dist/react/hooks/use-attribute.cjs.map +1 -1
- package/dist/react/hooks/use-attribute.d.cts +4 -4
- package/dist/react/hooks/use-attribute.d.mts +4 -4
- package/dist/react/hooks/use-attribute.mjs +7 -7
- package/dist/react/hooks/use-attribute.mjs.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.cjs +2 -6
- package/dist/react/hooks/use-theme-by-class-name.cjs.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.d.cts +2 -2
- package/dist/react/hooks/use-theme-by-class-name.d.cts.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.d.mts +2 -2
- package/dist/react/hooks/use-theme-by-class-name.d.mts.map +1 -1
- package/dist/react/hooks/use-theme-by-class-name.mjs +2 -6
- package/dist/react/hooks/use-theme-by-class-name.mjs.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.cjs +2 -7
- package/dist/react/hooks/use-theme-by-data-attribute.cjs.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.d.cts +2 -2
- package/dist/react/hooks/use-theme-by-data-attribute.d.cts.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.d.mts +2 -2
- package/dist/react/hooks/use-theme-by-data-attribute.d.mts.map +1 -1
- package/dist/react/hooks/use-theme-by-data-attribute.mjs +2 -7
- package/dist/react/hooks/use-theme-by-data-attribute.mjs.map +1 -1
- package/dist/react/hooks/use-theme-by-local-storage.cjs +1 -5
- package/dist/react/hooks/use-theme-by-local-storage.cjs.map +1 -1
- package/dist/react/hooks/use-theme-by-local-storage.d.cts.map +1 -1
- package/dist/react/hooks/use-theme-by-local-storage.d.mts.map +1 -1
- package/dist/react/hooks/use-theme-by-local-storage.mjs +1 -5
- package/dist/react/hooks/use-theme-by-local-storage.mjs.map +1 -1
- package/dist/react/theme/create-theme-hook.cjs.map +1 -1
- package/dist/react/theme/create-theme-hook.mjs.map +1 -1
- package/dist/theme/_utils/match-attribute-value-to-theme.cjs +29 -0
- package/dist/theme/_utils/match-attribute-value-to-theme.cjs.map +1 -0
- package/dist/theme/_utils/match-attribute-value-to-theme.mjs +28 -0
- package/dist/theme/_utils/match-attribute-value-to-theme.mjs.map +1 -0
- package/dist/theme/_utils/parse-stored-theme.cjs +61 -7
- package/dist/theme/_utils/parse-stored-theme.cjs.map +1 -1
- package/dist/theme/_utils/parse-stored-theme.mjs +61 -7
- package/dist/theme/_utils/parse-stored-theme.mjs.map +1 -1
- package/dist/theme/_utils/resolve-theme-map-value.cjs +19 -0
- package/dist/theme/_utils/resolve-theme-map-value.cjs.map +1 -0
- package/dist/theme/_utils/resolve-theme-map-value.mjs +17 -0
- package/dist/theme/_utils/resolve-theme-map-value.mjs.map +1 -0
- package/dist/theme/_utils/set-theme-to-stores.cjs +1 -1
- package/dist/theme/_utils/set-theme-to-stores.cjs.map +1 -1
- package/dist/theme/_utils/set-theme-to-stores.mjs +1 -1
- package/dist/theme/_utils/set-theme-to-stores.mjs.map +1 -1
- package/dist/theme/class-name/parse-class-name.cjs +32 -0
- package/dist/theme/class-name/parse-class-name.cjs.map +1 -0
- package/dist/theme/class-name/parse-class-name.d.cts +20 -0
- package/dist/theme/class-name/parse-class-name.d.cts.map +1 -0
- package/dist/theme/class-name/parse-class-name.d.mts +20 -0
- package/dist/theme/class-name/parse-class-name.d.mts.map +1 -0
- package/dist/theme/class-name/parse-class-name.mjs +31 -0
- package/dist/theme/class-name/parse-class-name.mjs.map +1 -0
- package/dist/theme/class-name/read-class-name.cjs +20 -0
- package/dist/theme/class-name/read-class-name.cjs.map +1 -0
- package/dist/theme/class-name/read-class-name.d.cts +20 -0
- package/dist/theme/class-name/read-class-name.d.cts.map +1 -0
- package/dist/theme/class-name/read-class-name.d.mts +20 -0
- package/dist/theme/class-name/read-class-name.d.mts.map +1 -0
- package/dist/theme/class-name/read-class-name.mjs +20 -0
- package/dist/theme/class-name/read-class-name.mjs.map +1 -0
- package/dist/theme/class-name/stringify-class-name.cjs +31 -0
- package/dist/theme/class-name/stringify-class-name.cjs.map +1 -0
- package/dist/theme/class-name/stringify-class-name.d.cts +21 -0
- package/dist/theme/class-name/stringify-class-name.d.cts.map +1 -0
- package/dist/theme/class-name/stringify-class-name.d.mts +21 -0
- package/dist/theme/class-name/stringify-class-name.d.mts.map +1 -0
- package/dist/theme/class-name/stringify-class-name.mjs +31 -0
- package/dist/theme/class-name/stringify-class-name.mjs.map +1 -0
- package/dist/theme/class-name/subscribe-class-name.cjs +31 -0
- package/dist/theme/class-name/subscribe-class-name.cjs.map +1 -0
- package/dist/theme/class-name/subscribe-class-name.d.cts +21 -0
- package/dist/theme/class-name/subscribe-class-name.d.cts.map +1 -0
- package/dist/theme/class-name/subscribe-class-name.d.mts +21 -0
- package/dist/theme/class-name/subscribe-class-name.d.mts.map +1 -0
- package/dist/theme/class-name/subscribe-class-name.mjs +31 -0
- package/dist/theme/class-name/subscribe-class-name.mjs.map +1 -0
- package/dist/theme/class-name/write-class-name.cjs +20 -0
- package/dist/theme/class-name/write-class-name.cjs.map +1 -0
- package/dist/theme/class-name/write-class-name.d.cts +20 -0
- package/dist/theme/class-name/write-class-name.d.cts.map +1 -0
- package/dist/theme/class-name/write-class-name.d.mts +20 -0
- package/dist/theme/class-name/write-class-name.d.mts.map +1 -0
- package/dist/theme/class-name/write-class-name.mjs +20 -0
- package/dist/theme/class-name/write-class-name.mjs.map +1 -0
- package/dist/theme/compose-theme-stores.cjs.map +1 -1
- package/dist/theme/compose-theme-stores.mjs.map +1 -1
- package/dist/theme/cookie/_cookie-utils.cjs +37 -0
- package/dist/theme/cookie/_cookie-utils.cjs.map +1 -0
- package/dist/theme/cookie/_cookie-utils.mjs +33 -0
- package/dist/theme/cookie/_cookie-utils.mjs.map +1 -0
- package/dist/theme/cookie/read-cookie-theme.cjs +22 -0
- package/dist/theme/cookie/read-cookie-theme.cjs.map +1 -0
- package/dist/theme/cookie/read-cookie-theme.d.cts +22 -0
- package/dist/theme/cookie/read-cookie-theme.d.cts.map +1 -0
- package/dist/theme/cookie/read-cookie-theme.d.mts +22 -0
- package/dist/theme/cookie/read-cookie-theme.d.mts.map +1 -0
- package/dist/theme/cookie/read-cookie-theme.mjs +22 -0
- package/dist/theme/cookie/read-cookie-theme.mjs.map +1 -0
- package/dist/theme/cookie/write-cookie-theme.cjs +29 -0
- package/dist/theme/cookie/write-cookie-theme.cjs.map +1 -0
- package/dist/theme/cookie/write-cookie-theme.d.cts +24 -0
- package/dist/theme/cookie/write-cookie-theme.d.cts.map +1 -0
- package/dist/theme/cookie/write-cookie-theme.d.mts +24 -0
- package/dist/theme/cookie/write-cookie-theme.d.mts.map +1 -0
- package/dist/theme/cookie/write-cookie-theme.mjs +29 -0
- package/dist/theme/cookie/write-cookie-theme.mjs.map +1 -0
- package/dist/theme/data-attribute/_constant.cjs +7 -0
- package/dist/theme/data-attribute/_constant.cjs.map +1 -0
- package/dist/theme/data-attribute/_constant.mjs +6 -0
- package/dist/theme/data-attribute/_constant.mjs.map +1 -0
- package/dist/theme/data-attribute/parse-data-attribute.cjs +24 -0
- package/dist/theme/data-attribute/parse-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/parse-data-attribute.d.cts +21 -0
- package/dist/theme/data-attribute/parse-data-attribute.d.cts.map +1 -0
- package/dist/theme/data-attribute/parse-data-attribute.d.mts +21 -0
- package/dist/theme/data-attribute/parse-data-attribute.d.mts.map +1 -0
- package/dist/theme/data-attribute/parse-data-attribute.mjs +24 -0
- package/dist/theme/data-attribute/parse-data-attribute.mjs.map +1 -0
- package/dist/theme/data-attribute/read-data-attribute.cjs +23 -0
- package/dist/theme/data-attribute/read-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/read-data-attribute.d.cts +21 -0
- package/dist/theme/data-attribute/read-data-attribute.d.cts.map +1 -0
- package/dist/theme/data-attribute/read-data-attribute.d.mts +21 -0
- package/dist/theme/data-attribute/read-data-attribute.d.mts.map +1 -0
- package/dist/theme/data-attribute/read-data-attribute.mjs +23 -0
- package/dist/theme/data-attribute/read-data-attribute.mjs.map +1 -0
- package/dist/theme/data-attribute/stringify-data-attribute.cjs +33 -0
- package/dist/theme/data-attribute/stringify-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/stringify-data-attribute.d.cts +23 -0
- package/dist/theme/data-attribute/stringify-data-attribute.d.cts.map +1 -0
- package/dist/theme/data-attribute/stringify-data-attribute.d.mts +23 -0
- package/dist/theme/data-attribute/stringify-data-attribute.d.mts.map +1 -0
- package/dist/theme/data-attribute/stringify-data-attribute.mjs +33 -0
- package/dist/theme/data-attribute/stringify-data-attribute.mjs.map +1 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.cjs +28 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.d.cts +22 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.d.cts.map +1 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.d.mts +22 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.d.mts.map +1 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.mjs +28 -0
- package/dist/theme/data-attribute/subscribe-data-attribute.mjs.map +1 -0
- package/dist/theme/data-attribute/write-data-attribute.cjs +30 -0
- package/dist/theme/data-attribute/write-data-attribute.cjs.map +1 -0
- package/dist/theme/data-attribute/write-data-attribute.d.cts +21 -0
- package/dist/theme/data-attribute/write-data-attribute.d.cts.map +1 -0
- package/dist/theme/data-attribute/write-data-attribute.d.mts +21 -0
- package/dist/theme/data-attribute/write-data-attribute.d.mts.map +1 -0
- package/dist/theme/data-attribute/write-data-attribute.mjs +30 -0
- package/dist/theme/data-attribute/write-data-attribute.mjs.map +1 -0
- package/dist/theme/local-storage/read-local-storage.cjs +22 -0
- package/dist/theme/local-storage/read-local-storage.cjs.map +1 -0
- package/dist/theme/local-storage/read-local-storage.d.cts +19 -0
- package/dist/theme/local-storage/read-local-storage.d.cts.map +1 -0
- package/dist/theme/local-storage/read-local-storage.d.mts +19 -0
- package/dist/theme/local-storage/read-local-storage.d.mts.map +1 -0
- package/dist/theme/local-storage/read-local-storage.mjs +22 -0
- package/dist/theme/local-storage/read-local-storage.mjs.map +1 -0
- package/dist/theme/local-storage/write-local-storage.cjs +26 -0
- package/dist/theme/local-storage/write-local-storage.cjs.map +1 -0
- package/dist/theme/local-storage/write-local-storage.d.cts +23 -0
- package/dist/theme/local-storage/write-local-storage.d.cts.map +1 -0
- package/dist/theme/local-storage/write-local-storage.d.mts +23 -0
- package/dist/theme/local-storage/write-local-storage.d.mts.map +1 -0
- package/dist/theme/local-storage/write-local-storage.mjs +26 -0
- package/dist/theme/local-storage/write-local-storage.mjs.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.cjs +20 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.cjs.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.cts +23 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.cts.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.mts +23 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.d.mts.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.mjs +20 -0
- package/dist/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.mjs.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.cjs +20 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.cjs.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.cts +20 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.cts.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.mts +20 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.d.mts.map +1 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.mjs +20 -0
- package/dist/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.mjs.map +1 -0
- package/dist/theme/session-storage/read-session-storage.cjs +22 -0
- package/dist/theme/session-storage/read-session-storage.cjs.map +1 -0
- package/dist/theme/session-storage/read-session-storage.d.cts +19 -0
- package/dist/theme/session-storage/read-session-storage.d.cts.map +1 -0
- package/dist/theme/session-storage/read-session-storage.d.mts +19 -0
- package/dist/theme/session-storage/read-session-storage.d.mts.map +1 -0
- package/dist/theme/session-storage/read-session-storage.mjs +22 -0
- package/dist/theme/session-storage/read-session-storage.mjs.map +1 -0
- package/dist/theme/session-storage/write-session-storage.cjs +26 -0
- package/dist/theme/session-storage/write-session-storage.cjs.map +1 -0
- package/dist/theme/session-storage/write-session-storage.d.cts +23 -0
- package/dist/theme/session-storage/write-session-storage.d.cts.map +1 -0
- package/dist/theme/session-storage/write-session-storage.d.mts +23 -0
- package/dist/theme/session-storage/write-session-storage.d.mts.map +1 -0
- package/dist/theme/session-storage/write-session-storage.mjs +26 -0
- package/dist/theme/session-storage/write-session-storage.mjs.map +1 -0
- package/dist/theme/theme-entry.types.d.cts +13 -1
- package/dist/theme/theme-entry.types.d.cts.map +1 -1
- package/dist/theme/theme-entry.types.d.mts +13 -1
- package/dist/theme/theme-entry.types.d.mts.map +1 -1
- package/dist/theme/theme-map.types.d.cts +11 -3
- package/dist/theme/theme-map.types.d.cts.map +1 -1
- package/dist/theme/theme-map.types.d.mts +11 -3
- package/dist/theme/theme-map.types.d.mts.map +1 -1
- package/dist/theme/theme-store/async-theme-store.types.d.cts +1 -1
- package/dist/theme/theme-store/async-theme-store.types.d.cts.map +1 -1
- package/dist/theme/theme-store/async-theme-store.types.d.mts +1 -1
- package/dist/theme/theme-store/async-theme-store.types.d.mts.map +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.cjs +22 -19
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.cts +7 -2
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.mts +7 -2
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.mjs +22 -19
- package/dist/theme/theme-store/class-name-theme-store/class-name-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.cjs +18 -36
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.cts +5 -3
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.mts +5 -3
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.mjs +18 -36
- package/dist/theme/theme-store/cookie-theme-store/cookie-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs +40 -20
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.cts +30 -7
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.mts +30 -7
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs +40 -20
- package/dist/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.cjs +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.d.cts +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.d.mts +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.mjs +1 -1
- package/dist/theme/theme-store/in-memory-theme-store/in-memory-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs +13 -12
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.cts +8 -2
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.mts +8 -2
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs +13 -12
- package/dist/theme/theme-store/local-storage-theme-store/local-storage-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.cjs +4 -5
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs +4 -5
- package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.cjs +13 -12
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.cjs.map +1 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts +8 -2
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts.map +1 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts +8 -2
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts.map +1 -1
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs +13 -12
- package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs.map +1 -1
- package/dist/theme/theme-store/theme-store.types.d.cts +1 -1
- package/dist/theme/theme-store/theme-store.types.d.cts.map +1 -1
- package/dist/theme/theme-store/theme-store.types.d.mts +1 -1
- package/dist/theme/theme-store/theme-store.types.d.mts.map +1 -1
- package/dist/theme/web-storage/read-web-storage.cjs +20 -0
- package/dist/theme/web-storage/read-web-storage.cjs.map +1 -0
- package/dist/theme/web-storage/read-web-storage.d.cts +21 -0
- package/dist/theme/web-storage/read-web-storage.d.cts.map +1 -0
- package/dist/theme/web-storage/read-web-storage.d.mts +21 -0
- package/dist/theme/web-storage/read-web-storage.d.mts.map +1 -0
- package/dist/theme/web-storage/read-web-storage.mjs +20 -0
- package/dist/theme/web-storage/read-web-storage.mjs.map +1 -0
- package/dist/theme/web-storage/write-web-storage.cjs +33 -0
- package/dist/theme/web-storage/write-web-storage.cjs.map +1 -0
- package/dist/theme/web-storage/write-web-storage.d.cts +25 -0
- package/dist/theme/web-storage/write-web-storage.d.cts.map +1 -0
- package/dist/theme/web-storage/write-web-storage.d.mts +25 -0
- package/dist/theme/web-storage/write-web-storage.d.mts.map +1 -0
- package/dist/theme/web-storage/write-web-storage.mjs +32 -0
- package/dist/theme/web-storage/write-web-storage.mjs.map +1 -0
- package/dist/theme.cjs +41 -1
- package/dist/theme.d.cts +23 -3
- package/dist/theme.d.mts +23 -3
- package/dist/theme.mjs +21 -1
- package/dist/utils/append-id.cjs +2 -2
- package/dist/utils/append-id.cjs.map +1 -1
- package/dist/utils/append-id.d.cts +3 -3
- package/dist/utils/append-id.d.mts +3 -3
- package/dist/utils/append-id.mjs +2 -2
- package/dist/utils/append-id.mjs.map +1 -1
- package/package.json +1 -1
- package/src/attributes/get-attribute.ts +5 -2
- package/src/attributes/get-data-attribute.ts +5 -2
- package/src/attributes/observe-attribute.ts +2 -2
- package/src/attributes/observe-data-attribute.ts +2 -2
- package/src/color-scheme/color-scheme.types.ts +7 -0
- package/src/color-scheme/get-prefers-color-scheme.ts +6 -4
- package/src/color-scheme/observe-prefers-color-scheme.ts +3 -1
- package/src/index.ts +1 -0
- package/src/react/hooks/use-attribute.ts +11 -11
- package/src/react/hooks/use-theme-by-class-name.ts +5 -10
- package/src/react/hooks/use-theme-by-data-attribute.ts +5 -12
- package/src/react/hooks/use-theme-by-local-storage.ts +3 -9
- package/src/react/theme/create-theme-hook.ts +4 -6
- package/src/testing/theme/theme-result-card.tsx +1 -0
- package/src/theme/_utils/match-attribute-value-to-theme.ts +36 -0
- package/src/theme/_utils/parse-stored-theme.ts +51 -11
- package/src/theme/_utils/resolve-theme-map-value.ts +15 -0
- package/src/theme/_utils/set-theme-to-stores.ts +3 -3
- package/src/theme/class-name/parse-class-name.ts +31 -0
- package/src/theme/class-name/read-class-name.ts +24 -0
- package/src/theme/class-name/stringify-class-name.ts +36 -0
- package/src/theme/class-name/subscribe-class-name.ts +39 -0
- package/src/theme/class-name/write-class-name.ts +24 -0
- package/src/theme/compose-theme-stores.ts +1 -1
- package/src/theme/cookie/_cookie-utils.ts +45 -0
- package/src/theme/cookie/read-cookie-theme.ts +33 -0
- package/src/theme/cookie/write-cookie-theme.ts +48 -0
- package/src/theme/data-attribute/_constant.ts +1 -0
- package/src/theme/data-attribute/parse-data-attribute.ts +25 -0
- package/src/theme/data-attribute/read-data-attribute.ts +29 -0
- package/src/theme/data-attribute/stringify-data-attribute.ts +39 -0
- package/src/theme/data-attribute/subscribe-data-attribute.ts +39 -0
- package/src/theme/data-attribute/write-data-attribute.ts +40 -0
- package/src/theme/local-storage/read-local-storage.ts +23 -0
- package/src/theme/local-storage/write-local-storage.ts +31 -0
- package/src/theme/prefers-color-scheme-theme/read-prefers-color-scheme-theme.ts +30 -0
- package/src/theme/prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.ts +24 -0
- package/src/theme/session-storage/read-session-storage.ts +23 -0
- package/src/theme/session-storage/write-session-storage.ts +31 -0
- package/src/theme/theme-entry.types.ts +21 -0
- package/src/theme/theme-map.types.ts +9 -2
- package/src/theme/theme-store/async-theme-store.types.ts +1 -3
- package/src/theme/theme-store/class-name-theme-store/class-name-theme-store.ts +20 -26
- package/src/theme/theme-store/cookie-theme-store/cookie-theme-store.ts +18 -63
- package/src/theme/theme-store/data-attribute-theme-store/data-attribute-theme-store.ts +42 -29
- package/src/theme/theme-store/in-memory-theme-store/in-memory-theme-store.ts +1 -1
- package/src/theme/theme-store/local-storage-theme-store/local-storage-theme-store.ts +17 -20
- package/src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts +4 -5
- package/src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts +17 -20
- package/src/theme/theme-store/theme-store.types.ts +1 -3
- package/src/theme/web-storage/read-web-storage.ts +22 -0
- package/src/theme/web-storage/write-web-storage.ts +46 -0
- package/src/theme.ts +20 -0
- package/src/utils/append-id.ts +3 -3
- package/dist/theme/class-name/apply-theme-to-class-name.cjs +0 -23
- package/dist/theme/class-name/apply-theme-to-class-name.cjs.map +0 -1
- package/dist/theme/class-name/apply-theme-to-class-name.mjs +0 -22
- package/dist/theme/class-name/apply-theme-to-class-name.mjs.map +0 -1
- package/dist/theme/class-name/resolve-theme-from-class-name.cjs +0 -23
- package/dist/theme/class-name/resolve-theme-from-class-name.cjs.map +0 -1
- package/dist/theme/class-name/resolve-theme-from-class-name.mjs +0 -22
- package/dist/theme/class-name/resolve-theme-from-class-name.mjs.map +0 -1
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.cjs +0 -23
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.cjs.map +0 -1
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.mjs +0 -22
- package/dist/theme/data-attribute/apply-theme-to-data-attribute.mjs.map +0 -1
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.cjs +0 -23
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.cjs.map +0 -1
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.mjs +0 -22
- package/dist/theme/data-attribute/resolve-theme-from-data-attribute.mjs.map +0 -1
- package/src/theme/class-name/apply-theme-to-class-name.ts +0 -26
- package/src/theme/class-name/resolve-theme-from-class-name.ts +0 -22
- package/src/theme/data-attribute/apply-theme-to-data-attribute.ts +0 -27
- package/src/theme/data-attribute/resolve-theme-from-data-attribute.ts +0 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefers-color-scheme-theme-store.cjs","names":["
|
|
1
|
+
{"version":3,"file":"prefers-color-scheme-theme-store.cjs","names":["readPrefersColorSchemeTheme","subscribePrefersColorSchemeTheme"],"sources":["../../../../src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts"],"sourcesContent":["import type { RequiredPick } from 'type-plus'\nimport { readPrefersColorSchemeTheme } from '../../prefers-color-scheme-theme/read-prefers-color-scheme-theme.ts'\nimport { subscribePrefersColorSchemeTheme } from '../../prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.ts'\nimport type { ThemeStore } from '../theme-store.types.ts'\n\ntype PrefersColorSchemeThemes = {\n\tlight: string | readonly string[]\n\tdark: string | readonly string[]\n}\n\n/**\n * Creates a read-only theme store that reads from `prefers-color-scheme`.\n *\n * **Color-scheme specific:** Themes must only include `light` and `dark` keys—this store\n * mirrors the system preference which is always one of these.\n *\n * Returns `ThemeEntry` for `light` or `dark` based on system preference.\n * No write method—the value is controlled by the system.\n *\n * @param themes - Record with `light` and `dark` keys mapping to theme values\n * @returns ThemeStore with read and subscribe only\n *\n * @example\n * ```ts\n * const themes = { light: 'theme-light', dark: 'theme-dark' }\n * const store = prefersColorSchemeThemeStore(themes)\n * store.read() // ThemeEntry for current system preference\n * store.subscribe((entry) => {})\n * ```\n */\nexport function prefersColorSchemeThemeStore<Themes extends PrefersColorSchemeThemes>(\n\tthemes: Themes\n): RequiredPick<ThemeStore<Themes>, 'read' | 'subscribe'> {\n\treturn {\n\t\tread() {\n\t\t\treturn readPrefersColorSchemeTheme(themes)\n\t\t},\n\t\tsubscribe(handler) {\n\t\t\treturn subscribePrefersColorSchemeTheme(themes, handler)\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,6BACf,QACyD;AACzD,QAAO;EACN,OAAO;AACN,UAAOA,oEAA4B,OAAO;;EAE3C,UAAU,SAAS;AAClB,UAAOC,8EAAiC,QAAQ,QAAQ;;EAEzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefers-color-scheme-theme-store.d.cts","names":[],"sources":["../../../../src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"prefers-color-scheme-theme-store.d.cts","names":[],"sources":["../../../../src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts"],"sourcesContent":[],"mappings":";;;;KAKK,wBAAA;;EAAA,IAAA,EAAA,MAAA,GAAA,SAAA,MAAwB,EAAA;AAyB7B,CAAA;;;;;;;;;;;;;;;;;;;;;iBAAgB,4CAA4C,kCACnD,SACN,aAAa,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefers-color-scheme-theme-store.d.mts","names":[],"sources":["../../../../src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"prefers-color-scheme-theme-store.d.mts","names":[],"sources":["../../../../src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts"],"sourcesContent":[],"mappings":";;;;KAKK,wBAAA;;EAAA,IAAA,EAAA,MAAA,GAAA,SAAA,MAAwB,EAAA;AAyB7B,CAAA;;;;;;;;;;;;;;;;;;;;;iBAAgB,4CAA4C,kCACnD,SACN,aAAa,WAAW"}
|
package/dist/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { themeEntry } from "../../theme-entry.mjs";
|
|
1
|
+
import { readPrefersColorSchemeTheme } from "../../prefers-color-scheme-theme/read-prefers-color-scheme-theme.mjs";
|
|
2
|
+
import { subscribePrefersColorSchemeTheme } from "../../prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.mjs";
|
|
4
3
|
|
|
5
4
|
//#region src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts
|
|
6
5
|
/**
|
|
@@ -26,10 +25,10 @@ import { themeEntry } from "../../theme-entry.mjs";
|
|
|
26
25
|
function prefersColorSchemeThemeStore(themes) {
|
|
27
26
|
return {
|
|
28
27
|
read() {
|
|
29
|
-
return
|
|
28
|
+
return readPrefersColorSchemeTheme(themes);
|
|
30
29
|
},
|
|
31
30
|
subscribe(handler) {
|
|
32
|
-
return
|
|
31
|
+
return subscribePrefersColorSchemeTheme(themes, handler);
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefers-color-scheme-theme-store.mjs","names":[],"sources":["../../../../src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts"],"sourcesContent":["import type { RequiredPick } from 'type-plus'\nimport {
|
|
1
|
+
{"version":3,"file":"prefers-color-scheme-theme-store.mjs","names":[],"sources":["../../../../src/theme/theme-store/prefers-color-scheme-theme-store/prefers-color-scheme-theme-store.ts"],"sourcesContent":["import type { RequiredPick } from 'type-plus'\nimport { readPrefersColorSchemeTheme } from '../../prefers-color-scheme-theme/read-prefers-color-scheme-theme.ts'\nimport { subscribePrefersColorSchemeTheme } from '../../prefers-color-scheme-theme/subscribe-prefers-color-scheme-theme.ts'\nimport type { ThemeStore } from '../theme-store.types.ts'\n\ntype PrefersColorSchemeThemes = {\n\tlight: string | readonly string[]\n\tdark: string | readonly string[]\n}\n\n/**\n * Creates a read-only theme store that reads from `prefers-color-scheme`.\n *\n * **Color-scheme specific:** Themes must only include `light` and `dark` keys—this store\n * mirrors the system preference which is always one of these.\n *\n * Returns `ThemeEntry` for `light` or `dark` based on system preference.\n * No write method—the value is controlled by the system.\n *\n * @param themes - Record with `light` and `dark` keys mapping to theme values\n * @returns ThemeStore with read and subscribe only\n *\n * @example\n * ```ts\n * const themes = { light: 'theme-light', dark: 'theme-dark' }\n * const store = prefersColorSchemeThemeStore(themes)\n * store.read() // ThemeEntry for current system preference\n * store.subscribe((entry) => {})\n * ```\n */\nexport function prefersColorSchemeThemeStore<Themes extends PrefersColorSchemeThemes>(\n\tthemes: Themes\n): RequiredPick<ThemeStore<Themes>, 'read' | 'subscribe'> {\n\treturn {\n\t\tread() {\n\t\t\treturn readPrefersColorSchemeTheme(themes)\n\t\t},\n\t\tsubscribe(handler) {\n\t\t\treturn subscribePrefersColorSchemeTheme(themes, handler)\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,6BACf,QACyD;AACzD,QAAO;EACN,OAAO;AACN,UAAO,4BAA4B,OAAO;;EAE3C,UAAU,SAAS;AAClB,UAAO,iCAAiC,QAAQ,QAAQ;;EAEzD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_theme_entry = require('../../theme-entry.cjs');
|
|
2
1
|
const require_dummy_theme_store = require('../../../testing/theme/dummy-theme-store.cjs');
|
|
3
|
-
const
|
|
2
|
+
const require_read_session_storage = require('../../session-storage/read-session-storage.cjs');
|
|
3
|
+
const require_write_session_storage = require('../../session-storage/write-session-storage.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts
|
|
6
6
|
/**
|
|
@@ -11,6 +11,9 @@ const require_parse_stored_theme = require('../../_utils/parse-stored-theme.cjs'
|
|
|
11
11
|
*
|
|
12
12
|
* @param themes - Record mapping theme keys to values (for validation)
|
|
13
13
|
* @param options.storageKey - sessionStorage key
|
|
14
|
+
* @param options.parse - Optional custom parser for stored string (default: parseStoredTheme)
|
|
15
|
+
* @param options.stringify - Optional custom serializer (default: JSON.stringify)
|
|
16
|
+
* @param options.onError - Optional callback invoked when storage write throws
|
|
14
17
|
* @returns ThemeStore
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
@@ -23,14 +26,12 @@ const require_parse_stored_theme = require('../../_utils/parse-stored-theme.cjs'
|
|
|
23
26
|
* ```
|
|
24
27
|
*/
|
|
25
28
|
function sessionStorageThemeStore(themes, options) {
|
|
26
|
-
const { storageKey } = options;
|
|
27
|
-
if (
|
|
29
|
+
const { storageKey, parse, stringify, onError } = options;
|
|
30
|
+
if (!window?.sessionStorage) return require_dummy_theme_store.dummyThemeStore;
|
|
28
31
|
const handlers = /* @__PURE__ */ new Set();
|
|
29
32
|
let lastNotifiedKey = read()?.theme ?? void 0;
|
|
30
33
|
function read() {
|
|
31
|
-
|
|
32
|
-
if (theme === void 0) return void 0;
|
|
33
|
-
return require_theme_entry.themeEntry(themes, theme);
|
|
34
|
+
return require_read_session_storage.readSessionStorage(themes, storageKey, { parse });
|
|
34
35
|
}
|
|
35
36
|
function notify() {
|
|
36
37
|
const result = read();
|
|
@@ -42,11 +43,11 @@ function sessionStorageThemeStore(themes, options) {
|
|
|
42
43
|
return {
|
|
43
44
|
read,
|
|
44
45
|
write(entry) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
require_write_session_storage.writeSessionStorage(themes, storageKey, entry, {
|
|
47
|
+
stringify,
|
|
48
|
+
onError
|
|
49
|
+
});
|
|
50
|
+
notify();
|
|
50
51
|
},
|
|
51
52
|
subscribe(handler) {
|
|
52
53
|
handlers.add(handler);
|
package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-storage-theme-store.cjs","names":["dummyThemeStore","lastNotifiedKey: keyof Themes | undefined","
|
|
1
|
+
{"version":3,"file":"session-storage-theme-store.cjs","names":["dummyThemeStore","lastNotifiedKey: keyof Themes | undefined","readSessionStorage"],"sources":["../../../../src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts"],"sourcesContent":["import { dummyThemeStore } from '../../../testing/theme/dummy-theme-store.ts'\nimport { readSessionStorage } from '../../session-storage/read-session-storage.ts'\nimport { writeSessionStorage } from '../../session-storage/write-session-storage.ts'\nimport type { ParseStoredTheme, StringifyStoredTheme, ThemeEntry } from '../../theme-entry.types.ts'\nimport type { ThemeMap } from '../../theme-map.types.ts'\nimport type { ThemeStore } from '../theme-store.types.ts'\n\n/**\n * Creates a theme store backed by sessionStorage.\n *\n * Persists per tab; cross-tab sync via StorageEvent when available.\n * Same-tab writes trigger manual notify (StorageEvent does not fire for same tab).\n *\n * @param themes - Record mapping theme keys to values (for validation)\n * @param options.storageKey - sessionStorage key\n * @param options.parse - Optional custom parser for stored string (default: parseStoredTheme)\n * @param options.stringify - Optional custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n * @returns ThemeStore\n *\n * @example\n * ```ts\n * const themes = { current: 'theme-current', grayscale: 'theme-grayscale' }\n * const store = sessionStorageThemeStore(themes, { storageKey: 'theme' })\n * store.read() // returns themeResult from sessionStorage\n * store.write(themeEntry(themes, 'grayscale'))\n * store.subscribe((themeResult) => {})\n * ```\n */\nexport function sessionStorageThemeStore<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions: {\n\t\tstorageKey: string\n\t\tparse?: ParseStoredTheme<Themes> | undefined\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n) {\n\tconst { storageKey, parse, stringify, onError } = options\n\n\tif (!window?.sessionStorage) {\n\t\treturn dummyThemeStore satisfies ThemeStore<Themes>\n\t}\n\n\tconst handlers = new Set<(theme: ThemeEntry<Themes> | undefined) => void>()\n\tlet lastNotifiedKey: keyof Themes | undefined = read()?.theme ?? undefined\n\n\tfunction read() {\n\t\treturn readSessionStorage(themes, storageKey, { parse })\n\t}\n\n\tfunction notify() {\n\t\tconst result = read()\n\t\tconst key = result?.theme ?? undefined\n\t\tif (key === lastNotifiedKey) return\n\t\tlastNotifiedKey = key\n\t\tfor (const h of handlers) h(result)\n\t}\n\n\treturn {\n\t\tread,\n\t\twrite(entry) {\n\t\t\twriteSessionStorage(themes, storageKey, entry, { stringify, onError })\n\t\t\tnotify()\n\t\t},\n\t\tsubscribe(handler) {\n\t\t\thandlers.add(handler)\n\n\t\t\tconst onStorage = (e: StorageEvent) => {\n\t\t\t\tif (e.key === storageKey && e.storageArea === window.sessionStorage) notify()\n\t\t\t}\n\t\t\twindow.addEventListener('storage', onStorage)\n\n\t\t\treturn () => {\n\t\t\t\thandlers.delete(handler)\n\t\t\t\twindow.removeEventListener('storage', onStorage)\n\t\t\t}\n\t\t}\n\t} satisfies ThemeStore<Themes>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,yBACf,QACA,SAMC;CACD,MAAM,EAAE,YAAY,OAAO,WAAW,YAAY;AAElD,KAAI,CAAC,QAAQ,eACZ,QAAOA;CAGR,MAAM,2BAAW,IAAI,KAAsD;CAC3E,IAAIC,kBAA4C,MAAM,EAAE,SAAS;CAEjE,SAAS,OAAO;AACf,SAAOC,gDAAmB,QAAQ,YAAY,EAAE,OAAO,CAAC;;CAGzD,SAAS,SAAS;EACjB,MAAM,SAAS,MAAM;EACrB,MAAM,MAAM,QAAQ,SAAS;AAC7B,MAAI,QAAQ,gBAAiB;AAC7B,oBAAkB;AAClB,OAAK,MAAM,KAAK,SAAU,GAAE,OAAO;;AAGpC,QAAO;EACN;EACA,MAAM,OAAO;AACZ,qDAAoB,QAAQ,YAAY,OAAO;IAAE;IAAW;IAAS,CAAC;AACtE,WAAQ;;EAET,UAAU,SAAS;AAClB,YAAS,IAAI,QAAQ;GAErB,MAAM,aAAa,MAAoB;AACtC,QAAI,EAAE,QAAQ,cAAc,EAAE,gBAAgB,OAAO,eAAgB,SAAQ;;AAE9E,UAAO,iBAAiB,WAAW,UAAU;AAE7C,gBAAa;AACZ,aAAS,OAAO,QAAQ;AACxB,WAAO,oBAAoB,WAAW,UAAU;;;EAGlD"}
|
package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThemeMap } from "../../theme-map.types.cjs";
|
|
2
|
-
import { ThemeEntry } from "../../theme-entry.types.cjs";
|
|
2
|
+
import { ParseStoredTheme, StringifyStoredTheme, ThemeEntry } from "../../theme-entry.types.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.ts
|
|
5
5
|
|
|
@@ -11,6 +11,9 @@ import { ThemeEntry } from "../../theme-entry.types.cjs";
|
|
|
11
11
|
*
|
|
12
12
|
* @param themes - Record mapping theme keys to values (for validation)
|
|
13
13
|
* @param options.storageKey - sessionStorage key
|
|
14
|
+
* @param options.parse - Optional custom parser for stored string (default: parseStoredTheme)
|
|
15
|
+
* @param options.stringify - Optional custom serializer (default: JSON.stringify)
|
|
16
|
+
* @param options.onError - Optional callback invoked when storage write throws
|
|
14
17
|
* @returns ThemeStore
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
@@ -24,10 +27,13 @@ import { ThemeEntry } from "../../theme-entry.types.cjs";
|
|
|
24
27
|
*/
|
|
25
28
|
declare function sessionStorageThemeStore<Themes extends ThemeMap>(themes: Themes, options: {
|
|
26
29
|
storageKey: string;
|
|
30
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
31
|
+
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
32
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
27
33
|
}): {
|
|
28
34
|
read: () => ThemeEntry<Themes> | undefined;
|
|
29
35
|
write(entry: ThemeEntry<Themes> | undefined): void;
|
|
30
|
-
subscribe(handler: (theme: ThemeEntry<Themes> |
|
|
36
|
+
subscribe(handler: (theme: ThemeEntry<Themes> | undefined) => void): () => void;
|
|
31
37
|
};
|
|
32
38
|
//#endregion
|
|
33
39
|
export { sessionStorageThemeStore };
|
package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-storage-theme-store.d.cts","names":[],"sources":["../../../../src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"session-storage-theme-store.d.cts","names":[],"sources":["../../../../src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts"],"sourcesContent":[],"mappings":";;;;;;;AA6BA;;;;;;;;;;;;;;;;;;;;iBAAgB,wCAAwC,kBAC/C;;UAGC,iBAAiB;cACb,qBAAqB"}
|
package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThemeMap } from "../../theme-map.types.mjs";
|
|
2
|
-
import { ThemeEntry } from "../../theme-entry.types.mjs";
|
|
2
|
+
import { ParseStoredTheme, StringifyStoredTheme, ThemeEntry } from "../../theme-entry.types.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.ts
|
|
5
5
|
|
|
@@ -11,6 +11,9 @@ import { ThemeEntry } from "../../theme-entry.types.mjs";
|
|
|
11
11
|
*
|
|
12
12
|
* @param themes - Record mapping theme keys to values (for validation)
|
|
13
13
|
* @param options.storageKey - sessionStorage key
|
|
14
|
+
* @param options.parse - Optional custom parser for stored string (default: parseStoredTheme)
|
|
15
|
+
* @param options.stringify - Optional custom serializer (default: JSON.stringify)
|
|
16
|
+
* @param options.onError - Optional callback invoked when storage write throws
|
|
14
17
|
* @returns ThemeStore
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
@@ -24,10 +27,13 @@ import { ThemeEntry } from "../../theme-entry.types.mjs";
|
|
|
24
27
|
*/
|
|
25
28
|
declare function sessionStorageThemeStore<Themes extends ThemeMap>(themes: Themes, options: {
|
|
26
29
|
storageKey: string;
|
|
30
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
31
|
+
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
32
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
27
33
|
}): {
|
|
28
34
|
read: () => ThemeEntry<Themes> | undefined;
|
|
29
35
|
write(entry: ThemeEntry<Themes> | undefined): void;
|
|
30
|
-
subscribe(handler: (theme: ThemeEntry<Themes> |
|
|
36
|
+
subscribe(handler: (theme: ThemeEntry<Themes> | undefined) => void): () => void;
|
|
31
37
|
};
|
|
32
38
|
//#endregion
|
|
33
39
|
export { sessionStorageThemeStore };
|
package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-storage-theme-store.d.mts","names":[],"sources":["../../../../src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"session-storage-theme-store.d.mts","names":[],"sources":["../../../../src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts"],"sourcesContent":[],"mappings":";;;;;;;AA6BA;;;;;;;;;;;;;;;;;;;;iBAAgB,wCAAwC,kBAC/C;;UAGC,iBAAiB;cACb,qBAAqB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { themeEntry } from "../../theme-entry.mjs";
|
|
2
1
|
import { dummyThemeStore } from "../../../testing/theme/dummy-theme-store.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { readSessionStorage } from "../../session-storage/read-session-storage.mjs";
|
|
3
|
+
import { writeSessionStorage } from "../../session-storage/write-session-storage.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts
|
|
6
6
|
/**
|
|
@@ -11,6 +11,9 @@ import { parseStoredTheme } from "../../_utils/parse-stored-theme.mjs";
|
|
|
11
11
|
*
|
|
12
12
|
* @param themes - Record mapping theme keys to values (for validation)
|
|
13
13
|
* @param options.storageKey - sessionStorage key
|
|
14
|
+
* @param options.parse - Optional custom parser for stored string (default: parseStoredTheme)
|
|
15
|
+
* @param options.stringify - Optional custom serializer (default: JSON.stringify)
|
|
16
|
+
* @param options.onError - Optional callback invoked when storage write throws
|
|
14
17
|
* @returns ThemeStore
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
@@ -23,14 +26,12 @@ import { parseStoredTheme } from "../../_utils/parse-stored-theme.mjs";
|
|
|
23
26
|
* ```
|
|
24
27
|
*/
|
|
25
28
|
function sessionStorageThemeStore(themes, options) {
|
|
26
|
-
const { storageKey } = options;
|
|
27
|
-
if (
|
|
29
|
+
const { storageKey, parse, stringify, onError } = options;
|
|
30
|
+
if (!window?.sessionStorage) return dummyThemeStore;
|
|
28
31
|
const handlers = /* @__PURE__ */ new Set();
|
|
29
32
|
let lastNotifiedKey = read()?.theme ?? void 0;
|
|
30
33
|
function read() {
|
|
31
|
-
|
|
32
|
-
if (theme === void 0) return void 0;
|
|
33
|
-
return themeEntry(themes, theme);
|
|
34
|
+
return readSessionStorage(themes, storageKey, { parse });
|
|
34
35
|
}
|
|
35
36
|
function notify() {
|
|
36
37
|
const result = read();
|
|
@@ -42,11 +43,11 @@ function sessionStorageThemeStore(themes, options) {
|
|
|
42
43
|
return {
|
|
43
44
|
read,
|
|
44
45
|
write(entry) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
writeSessionStorage(themes, storageKey, entry, {
|
|
47
|
+
stringify,
|
|
48
|
+
onError
|
|
49
|
+
});
|
|
50
|
+
notify();
|
|
50
51
|
},
|
|
51
52
|
subscribe(handler) {
|
|
52
53
|
handlers.add(handler);
|
package/dist/theme/theme-store/session-storage-theme-store/session-storage-theme-store.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-storage-theme-store.mjs","names":["lastNotifiedKey: keyof Themes | undefined"],"sources":["../../../../src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts"],"sourcesContent":["import { dummyThemeStore } from '../../../testing/theme/dummy-theme-store.ts'\nimport {
|
|
1
|
+
{"version":3,"file":"session-storage-theme-store.mjs","names":["lastNotifiedKey: keyof Themes | undefined"],"sources":["../../../../src/theme/theme-store/session-storage-theme-store/session-storage-theme-store.ts"],"sourcesContent":["import { dummyThemeStore } from '../../../testing/theme/dummy-theme-store.ts'\nimport { readSessionStorage } from '../../session-storage/read-session-storage.ts'\nimport { writeSessionStorage } from '../../session-storage/write-session-storage.ts'\nimport type { ParseStoredTheme, StringifyStoredTheme, ThemeEntry } from '../../theme-entry.types.ts'\nimport type { ThemeMap } from '../../theme-map.types.ts'\nimport type { ThemeStore } from '../theme-store.types.ts'\n\n/**\n * Creates a theme store backed by sessionStorage.\n *\n * Persists per tab; cross-tab sync via StorageEvent when available.\n * Same-tab writes trigger manual notify (StorageEvent does not fire for same tab).\n *\n * @param themes - Record mapping theme keys to values (for validation)\n * @param options.storageKey - sessionStorage key\n * @param options.parse - Optional custom parser for stored string (default: parseStoredTheme)\n * @param options.stringify - Optional custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when storage write throws\n * @returns ThemeStore\n *\n * @example\n * ```ts\n * const themes = { current: 'theme-current', grayscale: 'theme-grayscale' }\n * const store = sessionStorageThemeStore(themes, { storageKey: 'theme' })\n * store.read() // returns themeResult from sessionStorage\n * store.write(themeEntry(themes, 'grayscale'))\n * store.subscribe((themeResult) => {})\n * ```\n */\nexport function sessionStorageThemeStore<Themes extends ThemeMap>(\n\tthemes: Themes,\n\toptions: {\n\t\tstorageKey: string\n\t\tparse?: ParseStoredTheme<Themes> | undefined\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n) {\n\tconst { storageKey, parse, stringify, onError } = options\n\n\tif (!window?.sessionStorage) {\n\t\treturn dummyThemeStore satisfies ThemeStore<Themes>\n\t}\n\n\tconst handlers = new Set<(theme: ThemeEntry<Themes> | undefined) => void>()\n\tlet lastNotifiedKey: keyof Themes | undefined = read()?.theme ?? undefined\n\n\tfunction read() {\n\t\treturn readSessionStorage(themes, storageKey, { parse })\n\t}\n\n\tfunction notify() {\n\t\tconst result = read()\n\t\tconst key = result?.theme ?? undefined\n\t\tif (key === lastNotifiedKey) return\n\t\tlastNotifiedKey = key\n\t\tfor (const h of handlers) h(result)\n\t}\n\n\treturn {\n\t\tread,\n\t\twrite(entry) {\n\t\t\twriteSessionStorage(themes, storageKey, entry, { stringify, onError })\n\t\t\tnotify()\n\t\t},\n\t\tsubscribe(handler) {\n\t\t\thandlers.add(handler)\n\n\t\t\tconst onStorage = (e: StorageEvent) => {\n\t\t\t\tif (e.key === storageKey && e.storageArea === window.sessionStorage) notify()\n\t\t\t}\n\t\t\twindow.addEventListener('storage', onStorage)\n\n\t\t\treturn () => {\n\t\t\t\thandlers.delete(handler)\n\t\t\t\twindow.removeEventListener('storage', onStorage)\n\t\t\t}\n\t\t}\n\t} satisfies ThemeStore<Themes>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,yBACf,QACA,SAMC;CACD,MAAM,EAAE,YAAY,OAAO,WAAW,YAAY;AAElD,KAAI,CAAC,QAAQ,eACZ,QAAO;CAGR,MAAM,2BAAW,IAAI,KAAsD;CAC3E,IAAIA,kBAA4C,MAAM,EAAE,SAAS;CAEjE,SAAS,OAAO;AACf,SAAO,mBAAmB,QAAQ,YAAY,EAAE,OAAO,CAAC;;CAGzD,SAAS,SAAS;EACjB,MAAM,SAAS,MAAM;EACrB,MAAM,MAAM,QAAQ,SAAS;AAC7B,MAAI,QAAQ,gBAAiB;AAC7B,oBAAkB;AAClB,OAAK,MAAM,KAAK,SAAU,GAAE,OAAO;;AAGpC,QAAO;EACN;EACA,MAAM,OAAO;AACZ,uBAAoB,QAAQ,YAAY,OAAO;IAAE;IAAW;IAAS,CAAC;AACtE,WAAQ;;EAET,UAAU,SAAS;AAClB,YAAS,IAAI,QAAQ;GAErB,MAAM,aAAa,MAAoB;AACtC,QAAI,EAAE,QAAQ,cAAc,EAAE,gBAAgB,OAAO,eAAgB,SAAQ;;AAE9E,UAAO,iBAAiB,WAAW,UAAU;AAE7C,gBAAa;AACZ,aAAS,OAAO,QAAQ;AACxB,WAAO,oBAAoB,WAAW,UAAU;;;EAGlD"}
|
|
@@ -26,7 +26,7 @@ import { ThemeEntry } from "../theme-entry.types.cjs";
|
|
|
26
26
|
interface ThemeStore<Themes extends ThemeMap = ThemeMap> {
|
|
27
27
|
read?: (() => ThemeEntry<Themes> | undefined) | undefined;
|
|
28
28
|
write?: ((entry: ThemeEntry<Themes> | undefined) => void) | undefined;
|
|
29
|
-
subscribe?: ((handler: (theme: ThemeEntry<Themes> | undefined
|
|
29
|
+
subscribe?: ((handler: (theme: ThemeEntry<Themes> | undefined) => void) => () => void) | undefined;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
export { ThemeStore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-store.types.d.cts","names":[],"sources":["../../../src/theme/theme-store/theme-store.types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuBA;;;;;;;;;;;;;;;;;;UAAiB,0BAA0B,WAAW;gBACvC,WAAW;mBACR,WAAW;
|
|
1
|
+
{"version":3,"file":"theme-store.types.d.cts","names":[],"sources":["../../../src/theme/theme-store/theme-store.types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuBA;;;;;;;;;;;;;;;;;;UAAiB,0BAA0B,WAAW;gBACvC,WAAW;mBACR,WAAW;iCACG,WAAW"}
|
|
@@ -26,7 +26,7 @@ import { ThemeEntry } from "../theme-entry.types.mjs";
|
|
|
26
26
|
interface ThemeStore<Themes extends ThemeMap = ThemeMap> {
|
|
27
27
|
read?: (() => ThemeEntry<Themes> | undefined) | undefined;
|
|
28
28
|
write?: ((entry: ThemeEntry<Themes> | undefined) => void) | undefined;
|
|
29
|
-
subscribe?: ((handler: (theme: ThemeEntry<Themes> | undefined
|
|
29
|
+
subscribe?: ((handler: (theme: ThemeEntry<Themes> | undefined) => void) => () => void) | undefined;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
export { ThemeStore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-store.types.d.mts","names":[],"sources":["../../../src/theme/theme-store/theme-store.types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuBA;;;;;;;;;;;;;;;;;;UAAiB,0BAA0B,WAAW;gBACvC,WAAW;mBACR,WAAW;
|
|
1
|
+
{"version":3,"file":"theme-store.types.d.mts","names":[],"sources":["../../../src/theme/theme-store/theme-store.types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuBA;;;;;;;;;;;;;;;;;;UAAiB,0BAA0B,WAAW;gBACvC,WAAW;mBACR,WAAW;iCACG,WAAW"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_parse_stored_theme = require('../_utils/parse-stored-theme.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/theme/web-storage/read-web-storage.ts
|
|
4
|
+
/**
|
|
5
|
+
* Reads a theme entry from a web storage (localStorage or sessionStorage).
|
|
6
|
+
*
|
|
7
|
+
* @param themes - Record mapping theme keys to values (for validation)
|
|
8
|
+
* @param storageKey - Storage key to read from
|
|
9
|
+
* @param options.storage - Storage object (localStorage or sessionStorage)
|
|
10
|
+
* @param options.parse - Custom parser (default: parseStoredTheme)
|
|
11
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when storage is unavailable (e.g. SSR).
|
|
12
|
+
*/
|
|
13
|
+
function readWebStorage(themes, storageKey, options) {
|
|
14
|
+
const { storage, parse = require_parse_stored_theme.parseStoredTheme } = options;
|
|
15
|
+
return parse(themes, storage.getItem(storageKey) ?? void 0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.readWebStorage = readWebStorage;
|
|
20
|
+
//# sourceMappingURL=read-web-storage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-web-storage.cjs","names":["parseStoredTheme"],"sources":["../../../src/theme/web-storage/read-web-storage.ts"],"sourcesContent":["import { parseStoredTheme } from '../_utils/parse-stored-theme.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\n\n/**\n * Reads a theme entry from a web storage (localStorage or sessionStorage).\n *\n * @param themes - Record mapping theme keys to values (for validation)\n * @param storageKey - Storage key to read from\n * @param options.storage - Storage object (localStorage or sessionStorage)\n * @param options.parse - Custom parser (default: parseStoredTheme)\n * @returns ThemeEntry if found, undefined otherwise. Returns undefined when storage is unavailable (e.g. SSR).\n */\nexport function readWebStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\toptions: { storage: Storage; parse?: ParseStoredTheme<Themes> | undefined }\n): ThemeEntry<Themes> | undefined {\n\tconst { storage, parse = parseStoredTheme } = options\n\tconst stored = storage.getItem(storageKey)\n\treturn parse(themes, stored ?? undefined)\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,eACf,QACA,YACA,SACiC;CACjC,MAAM,EAAE,SAAS,QAAQA,gDAAqB;AAE9C,QAAO,MAAM,QADE,QAAQ,QAAQ,WAAW,IACX,OAAU"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.cjs";
|
|
2
|
+
import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/web-storage/read-web-storage.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reads a theme entry from a web storage (localStorage or sessionStorage).
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to values (for validation)
|
|
10
|
+
* @param storageKey - Storage key to read from
|
|
11
|
+
* @param options.storage - Storage object (localStorage or sessionStorage)
|
|
12
|
+
* @param options.parse - Custom parser (default: parseStoredTheme)
|
|
13
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when storage is unavailable (e.g. SSR).
|
|
14
|
+
*/
|
|
15
|
+
declare function readWebStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, options: {
|
|
16
|
+
storage: Storage;
|
|
17
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
18
|
+
}): ThemeEntry<Themes> | undefined;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { readWebStorage };
|
|
21
|
+
//# sourceMappingURL=read-web-storage.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-web-storage.d.cts","names":[],"sources":["../../../src/theme/web-storage/read-web-storage.ts"],"sourcesContent":[],"mappings":";;;;;;;AAaA;;;;;;;AAIG,iBAJa,cAIb,CAAA,eAJ2C,QAI3C,CAAA,CAAA,MAAA,EAHM,MAGN,EAAA,UAAA,EAAA,MAAA,EAAA,OAAA,EAAA;EAAU,OAAA,EADQ,OACR;UADyB,iBAAiB;IACpD,WAAW"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.mjs";
|
|
2
|
+
import { ParseStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/web-storage/read-web-storage.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reads a theme entry from a web storage (localStorage or sessionStorage).
|
|
8
|
+
*
|
|
9
|
+
* @param themes - Record mapping theme keys to values (for validation)
|
|
10
|
+
* @param storageKey - Storage key to read from
|
|
11
|
+
* @param options.storage - Storage object (localStorage or sessionStorage)
|
|
12
|
+
* @param options.parse - Custom parser (default: parseStoredTheme)
|
|
13
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when storage is unavailable (e.g. SSR).
|
|
14
|
+
*/
|
|
15
|
+
declare function readWebStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, options: {
|
|
16
|
+
storage: Storage;
|
|
17
|
+
parse?: ParseStoredTheme<Themes> | undefined;
|
|
18
|
+
}): ThemeEntry<Themes> | undefined;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { readWebStorage };
|
|
21
|
+
//# sourceMappingURL=read-web-storage.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-web-storage.d.mts","names":[],"sources":["../../../src/theme/web-storage/read-web-storage.ts"],"sourcesContent":[],"mappings":";;;;;;;AAaA;;;;;;;AAIG,iBAJa,cAIb,CAAA,eAJ2C,QAI3C,CAAA,CAAA,MAAA,EAHM,MAGN,EAAA,UAAA,EAAA,MAAA,EAAA,OAAA,EAAA;EAAU,OAAA,EADQ,OACR;UADyB,iBAAiB;IACpD,WAAW"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseStoredTheme } from "../_utils/parse-stored-theme.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/theme/web-storage/read-web-storage.ts
|
|
4
|
+
/**
|
|
5
|
+
* Reads a theme entry from a web storage (localStorage or sessionStorage).
|
|
6
|
+
*
|
|
7
|
+
* @param themes - Record mapping theme keys to values (for validation)
|
|
8
|
+
* @param storageKey - Storage key to read from
|
|
9
|
+
* @param options.storage - Storage object (localStorage or sessionStorage)
|
|
10
|
+
* @param options.parse - Custom parser (default: parseStoredTheme)
|
|
11
|
+
* @returns ThemeEntry if found, undefined otherwise. Returns undefined when storage is unavailable (e.g. SSR).
|
|
12
|
+
*/
|
|
13
|
+
function readWebStorage(themes, storageKey, options) {
|
|
14
|
+
const { storage, parse = parseStoredTheme } = options;
|
|
15
|
+
return parse(themes, storage.getItem(storageKey) ?? void 0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { readWebStorage };
|
|
20
|
+
//# sourceMappingURL=read-web-storage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-web-storage.mjs","names":[],"sources":["../../../src/theme/web-storage/read-web-storage.ts"],"sourcesContent":["import { parseStoredTheme } from '../_utils/parse-stored-theme.ts'\nimport type { ParseStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\n\n/**\n * Reads a theme entry from a web storage (localStorage or sessionStorage).\n *\n * @param themes - Record mapping theme keys to values (for validation)\n * @param storageKey - Storage key to read from\n * @param options.storage - Storage object (localStorage or sessionStorage)\n * @param options.parse - Custom parser (default: parseStoredTheme)\n * @returns ThemeEntry if found, undefined otherwise. Returns undefined when storage is unavailable (e.g. SSR).\n */\nexport function readWebStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\toptions: { storage: Storage; parse?: ParseStoredTheme<Themes> | undefined }\n): ThemeEntry<Themes> | undefined {\n\tconst { storage, parse = parseStoredTheme } = options\n\tconst stored = storage.getItem(storageKey)\n\treturn parse(themes, stored ?? undefined)\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,eACf,QACA,YACA,SACiC;CACjC,MAAM,EAAE,SAAS,QAAQ,qBAAqB;AAE9C,QAAO,MAAM,QADE,QAAQ,QAAQ,WAAW,IACX,OAAU"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/theme/web-storage/write-web-storage.ts
|
|
3
|
+
function defaultStringify(_themes, _existing, entry) {
|
|
4
|
+
return entry == null ? "" : JSON.stringify(entry);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Writes a theme entry to a web storage (localStorage or sessionStorage).
|
|
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 - Storage key to write to
|
|
13
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
14
|
+
* @param options.storage - Storage object (localStorage or sessionStorage)
|
|
15
|
+
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
16
|
+
* @param options.onError - Optional callback invoked when setItem/removeItem throws
|
|
17
|
+
*/
|
|
18
|
+
function writeWebStorage(themes, storageKey, entry, options) {
|
|
19
|
+
const { storage, stringify = defaultStringify, onError } = options;
|
|
20
|
+
try {
|
|
21
|
+
if (entry == null) storage.removeItem(storageKey);
|
|
22
|
+
else {
|
|
23
|
+
const value = stringify(themes, storage.getItem(storageKey) ?? void 0, entry);
|
|
24
|
+
storage.setItem(storageKey, value);
|
|
25
|
+
}
|
|
26
|
+
} catch (error) {
|
|
27
|
+
onError?.(error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.writeWebStorage = writeWebStorage;
|
|
33
|
+
//# sourceMappingURL=write-web-storage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-web-storage.cjs","names":[],"sources":["../../../src/theme/web-storage/write-web-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\n\nfunction defaultStringify<Themes extends ThemeMap>(\n\t_themes: Themes,\n\t_existing: string | undefined,\n\tentry: ThemeEntry<Themes> | null | undefined\n): string {\n\treturn entry == null ? '' : JSON.stringify(entry)\n}\n\n/**\n * Writes a theme entry to a web storage (localStorage or sessionStorage).\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 - Storage key to write to\n * @param entry - Theme entry to write, or null/undefined to remove\n * @param options.storage - Storage object (localStorage or sessionStorage)\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when setItem/removeItem throws\n */\nexport function writeWebStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions: {\n\t\tstorage: Storage\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tconst { storage, stringify = defaultStringify, onError } = options\n\ttry {\n\t\tif (entry == null) {\n\t\t\tstorage.removeItem(storageKey)\n\t\t} else {\n\t\t\tconst existing = storage.getItem(storageKey) ?? undefined\n\t\t\tconst value = stringify(themes, existing, entry)\n\t\t\tstorage.setItem(storageKey, value)\n\t\t}\n\t} catch (error) {\n\t\tonError?.(error)\n\t}\n}\n"],"mappings":";;AAGA,SAAS,iBACR,SACA,WACA,OACS;AACT,QAAO,SAAS,OAAO,KAAK,KAAK,UAAU,MAAM;;;;;;;;;;;;;;AAelD,SAAgB,gBACf,QACA,YACA,OACA,SAKO;CACP,MAAM,EAAE,SAAS,YAAY,kBAAkB,YAAY;AAC3D,KAAI;AACH,MAAI,SAAS,KACZ,SAAQ,WAAW,WAAW;OACxB;GAEN,MAAM,QAAQ,UAAU,QADP,QAAQ,QAAQ,WAAW,IAAI,QACN,MAAM;AAChD,WAAQ,QAAQ,YAAY,MAAM;;UAE3B,OAAO;AACf,YAAU,MAAM"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.cjs";
|
|
2
|
+
import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/web-storage/write-web-storage.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Writes a theme entry to a web storage (localStorage or sessionStorage).
|
|
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 - Storage key to write to
|
|
13
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
14
|
+
* @param options.storage - Storage object (localStorage or sessionStorage)
|
|
15
|
+
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
16
|
+
* @param options.onError - Optional callback invoked when setItem/removeItem throws
|
|
17
|
+
*/
|
|
18
|
+
declare function writeWebStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | null | undefined, options: {
|
|
19
|
+
storage: Storage;
|
|
20
|
+
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
21
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
22
|
+
}): void;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { writeWebStorage };
|
|
25
|
+
//# sourceMappingURL=write-web-storage.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-web-storage.d.cts","names":[],"sources":["../../../src/theme/web-storage/write-web-storage.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuBA;;;;;;;;;;iBAAgB,+BAA+B,kBACtC,mCAED,WAAW;WAER;cACG,qBAAqB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ThemeMap } from "../theme-map.types.mjs";
|
|
2
|
+
import { StringifyStoredTheme, ThemeEntry } from "../theme-entry.types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/web-storage/write-web-storage.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Writes a theme entry to a web storage (localStorage or sessionStorage).
|
|
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 - Storage key to write to
|
|
13
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
14
|
+
* @param options.storage - Storage object (localStorage or sessionStorage)
|
|
15
|
+
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
16
|
+
* @param options.onError - Optional callback invoked when setItem/removeItem throws
|
|
17
|
+
*/
|
|
18
|
+
declare function writeWebStorage<Themes extends ThemeMap>(themes: Themes, storageKey: string, entry: ThemeEntry<Themes> | null | undefined, options: {
|
|
19
|
+
storage: Storage;
|
|
20
|
+
stringify?: StringifyStoredTheme<Themes> | undefined;
|
|
21
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
22
|
+
}): void;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { writeWebStorage };
|
|
25
|
+
//# sourceMappingURL=write-web-storage.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-web-storage.d.mts","names":[],"sources":["../../../src/theme/web-storage/write-web-storage.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuBA;;;;;;;;;;iBAAgB,+BAA+B,kBACtC,mCAED,WAAW;WAER;cACG,qBAAqB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/theme/web-storage/write-web-storage.ts
|
|
2
|
+
function defaultStringify(_themes, _existing, entry) {
|
|
3
|
+
return entry == null ? "" : JSON.stringify(entry);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Writes a theme entry to a web storage (localStorage or sessionStorage).
|
|
7
|
+
*
|
|
8
|
+
* Performs setItem/removeItem only. Does not notify subscribers; the store must call notify() after this.
|
|
9
|
+
*
|
|
10
|
+
* @param themes - Record mapping theme keys to values (used by stringify)
|
|
11
|
+
* @param storageKey - Storage key to write to
|
|
12
|
+
* @param entry - Theme entry to write, or null/undefined to remove
|
|
13
|
+
* @param options.storage - Storage object (localStorage or sessionStorage)
|
|
14
|
+
* @param options.stringify - Custom serializer (default: JSON.stringify)
|
|
15
|
+
* @param options.onError - Optional callback invoked when setItem/removeItem throws
|
|
16
|
+
*/
|
|
17
|
+
function writeWebStorage(themes, storageKey, entry, options) {
|
|
18
|
+
const { storage, stringify = defaultStringify, onError } = options;
|
|
19
|
+
try {
|
|
20
|
+
if (entry == null) storage.removeItem(storageKey);
|
|
21
|
+
else {
|
|
22
|
+
const value = stringify(themes, storage.getItem(storageKey) ?? void 0, entry);
|
|
23
|
+
storage.setItem(storageKey, value);
|
|
24
|
+
}
|
|
25
|
+
} catch (error) {
|
|
26
|
+
onError?.(error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { writeWebStorage };
|
|
32
|
+
//# sourceMappingURL=write-web-storage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-web-storage.mjs","names":[],"sources":["../../../src/theme/web-storage/write-web-storage.ts"],"sourcesContent":["import type { StringifyStoredTheme, ThemeEntry } from '../theme-entry.types.ts'\nimport type { ThemeMap } from '../theme-map.types.ts'\n\nfunction defaultStringify<Themes extends ThemeMap>(\n\t_themes: Themes,\n\t_existing: string | undefined,\n\tentry: ThemeEntry<Themes> | null | undefined\n): string {\n\treturn entry == null ? '' : JSON.stringify(entry)\n}\n\n/**\n * Writes a theme entry to a web storage (localStorage or sessionStorage).\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 - Storage key to write to\n * @param entry - Theme entry to write, or null/undefined to remove\n * @param options.storage - Storage object (localStorage or sessionStorage)\n * @param options.stringify - Custom serializer (default: JSON.stringify)\n * @param options.onError - Optional callback invoked when setItem/removeItem throws\n */\nexport function writeWebStorage<Themes extends ThemeMap>(\n\tthemes: Themes,\n\tstorageKey: string,\n\tentry: ThemeEntry<Themes> | null | undefined,\n\toptions: {\n\t\tstorage: Storage\n\t\tstringify?: StringifyStoredTheme<Themes> | undefined\n\t\tonError?: ((error: unknown) => void) | undefined\n\t}\n): void {\n\tconst { storage, stringify = defaultStringify, onError } = options\n\ttry {\n\t\tif (entry == null) {\n\t\t\tstorage.removeItem(storageKey)\n\t\t} else {\n\t\t\tconst existing = storage.getItem(storageKey) ?? undefined\n\t\t\tconst value = stringify(themes, existing, entry)\n\t\t\tstorage.setItem(storageKey, value)\n\t\t}\n\t} catch (error) {\n\t\tonError?.(error)\n\t}\n}\n"],"mappings":";AAGA,SAAS,iBACR,SACA,WACA,OACS;AACT,QAAO,SAAS,OAAO,KAAK,KAAK,UAAU,MAAM;;;;;;;;;;;;;;AAelD,SAAgB,gBACf,QACA,YACA,OACA,SAKO;CACP,MAAM,EAAE,SAAS,YAAY,kBAAkB,YAAY;AAC3D,KAAI;AACH,MAAI,SAAS,KACZ,SAAQ,WAAW,WAAW;OACxB;GAEN,MAAM,QAAQ,UAAU,QADP,QAAQ,QAAQ,WAAW,IAAI,QACN,MAAM;AAChD,WAAQ,QAAQ,YAAY,MAAM;;UAE3B,OAAO;AACf,YAAU,MAAM"}
|