foxact 0.3.0 → 0.3.2

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 (41) hide show
  1. package/create-local-storage-state/index.cjs +1 -1
  2. package/create-local-storage-state/index.d.ts +2 -1
  3. package/create-local-storage-state/index.mjs +1 -1
  4. package/create-magic-portal/index.cjs +1 -1
  5. package/create-magic-portal/index.mjs +1 -1
  6. package/create-session-storage-state/index.cjs +1 -1
  7. package/create-session-storage-state/index.d.ts +2 -1
  8. package/create-session-storage-state/index.mjs +1 -1
  9. package/create-stackless-error/index.cjs +1 -0
  10. package/create-stackless-error/index.d.ts +3 -0
  11. package/create-stackless-error/index.mjs +1 -0
  12. package/create-storage-hook/index.cjs +1 -1
  13. package/create-storage-hook/index.d.ts +5 -1
  14. package/create-storage-hook/index.mjs +1 -1
  15. package/create-storage-state-factory/index.cjs +1 -1
  16. package/create-storage-state-factory/index.d.ts +1 -1
  17. package/create-storage-state-factory/index.mjs +1 -1
  18. package/current-year/index.d.ts +2 -1
  19. package/magic-portal/index.cjs +1 -1
  20. package/magic-portal/index.mjs +1 -1
  21. package/no-ssr/index.cjs +1 -1
  22. package/no-ssr/index.mjs +1 -1
  23. package/noop-component/index.cjs +1 -0
  24. package/noop-component/index.d.ts +3 -0
  25. package/noop-component/index.mjs +1 -0
  26. package/package.json +91 -73
  27. package/sizes.json +1 -1
  28. package/use-fast-click/index.cjs +1 -1
  29. package/use-fast-click/index.mjs +1 -1
  30. package/use-local-storage/index.cjs +1 -1
  31. package/use-local-storage/index.d.ts +4 -4
  32. package/use-local-storage/index.mjs +1 -1
  33. package/use-media-query/index.cjs +1 -1
  34. package/use-media-query/index.mjs +1 -1
  35. package/use-readonly-search-params/index.cjs +1 -1
  36. package/use-readonly-search-params/index.mjs +1 -1
  37. package/use-session-storage/index.cjs +1 -1
  38. package/use-session-storage/index.d.ts +4 -4
  39. package/use-session-storage/index.mjs +1 -1
  40. package/use-url-hash-state/index.cjs +1 -1
  41. package/use-url-hash-state/index.mjs +1 -1
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-state-factory/index.cjs");require("../chunks/index.b9dLwVor.cjs"),require("../create-storage-hook/index.cjs"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const r=e.createStorageStateFactory("localStorage");exports.createLocalStorageState=r;
1
+ "use strict";require("client-only");var e=require("../create-storage-state-factory/index.cjs");require("../create-storage-hook/index.cjs"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const r=e.createStorageStateFactory("localStorage");exports.createLocalStorageState=r;
@@ -6,7 +6,7 @@ import { NotUndefined, UseStorageRawOption, UseStorageParserOption } from '../cr
6
6
  *
7
7
  * @example
8
8
  * ```ts
9
- * const [useOpenState, useOpen] = createLocalStorageState(
9
+ * const [useOpenState, useOpen, useSetOpen] = createLocalStorageState(
10
10
  * 'open', // storage key
11
11
  * false, // server default value
12
12
  * { raw: false } // options
@@ -14,6 +14,7 @@ import { NotUndefined, UseStorageRawOption, UseStorageParserOption } from '../cr
14
14
  *
15
15
  * const [open, setOpen] = useOpenState();
16
16
  * const open = useOpen();
17
+ * const setOpen = useSetOpen();
17
18
  * ```
18
19
  */
19
20
  declare const createLocalStorageState: {
@@ -1 +1 @@
1
- import"client-only";import{createStorageStateFactory as o}from"../create-storage-state-factory/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../chunks/index.C9-3oDdv.mjs";const t=o("localStorage");export{t as createLocalStorageState};
1
+ import"client-only";import{createStorageStateFactory as e}from"../create-storage-state-factory/index.mjs";import"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const o=e("localStorage");export{o as createLocalStorageState};
@@ -1 +1 @@
1
- "use strict";var e=require("../magic-portal/index.cjs");require("react/jsx-runtime"),require("client-only"),require("react-dom"),require("../context-state/index.cjs"),require("react"),require("../noop/index.cjs"),require("../no-ssr/index.cjs"),exports.createMagicPortal=e.createMagicPortal;
1
+ "use strict";var e=require("../magic-portal/index.cjs");require("react/jsx-runtime"),require("client-only"),require("react-dom"),require("../context-state/index.cjs"),require("react"),require("../noop/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),exports.createMagicPortal=e.createMagicPortal;
@@ -1 +1 @@
1
- export{createMagicPortal}from"../magic-portal/index.mjs";import"react/jsx-runtime";import"client-only";import"react-dom";import"../context-state/index.mjs";import"react";import"../noop/index.mjs";import"../no-ssr/index.mjs";
1
+ export{createMagicPortal}from"../magic-portal/index.mjs";import"react/jsx-runtime";import"client-only";import"react-dom";import"../context-state/index.mjs";import"react";import"../noop/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-state-factory/index.cjs");require("../chunks/index.b9dLwVor.cjs"),require("../create-storage-hook/index.cjs"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const r=e.createStorageStateFactory("sessionStorage");exports.createSessionStorageState=r;
1
+ "use strict";require("client-only");var e=require("../create-storage-state-factory/index.cjs");require("../create-storage-hook/index.cjs"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const r=e.createStorageStateFactory("sessionStorage");exports.createSessionStorageState=r;
@@ -7,7 +7,7 @@ import { NotUndefined, UseStorageRawOption, UseStorageParserOption } from '../cr
7
7
  * @example
8
8
  * ```ts
9
9
  * ```ts
10
- * const [useOpenState, useOpen] = createSessionStorageState(
10
+ * const [useOpenState, useOpen, useSetOpen] = createSessionStorageState(
11
11
  * 'open', // storage key
12
12
  * false, // server default value
13
13
  * { raw: false } // options
@@ -15,6 +15,7 @@ import { NotUndefined, UseStorageRawOption, UseStorageParserOption } from '../cr
15
15
  *
16
16
  * const [open, setOpen] = useOpenState();
17
17
  * const open = useOpen();
18
+ * const setOpen = useSetOpen();
18
19
  * ```
19
20
  */
20
21
  declare const createSessionStorageState: {
@@ -1 +1 @@
1
- import"client-only";import{createStorageStateFactory as o}from"../create-storage-state-factory/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../chunks/index.C9-3oDdv.mjs";const e=o("sessionStorage");export{e as createSessionStorageState};
1
+ import"client-only";import{createStorageStateFactory as e}from"../create-storage-state-factory/index.mjs";import"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const o=e("sessionStorage");export{o as createSessionStorageState};
@@ -0,0 +1 @@
1
+ "use strict";const r=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit"),t=(null==r?void 0:r.writable)&&"number"==typeof r.value;exports.createStacklessError=function(r){const e=Error.stackTraceLimit;t&&(Error.stackTraceLimit=0);const c=r();return t&&(Error.stackTraceLimit=e),c};
@@ -0,0 +1,3 @@
1
+ declare function createStacklessError<T = Error>(errorFacrory: () => T): T;
2
+
3
+ export { createStacklessError };
@@ -0,0 +1 @@
1
+ const r=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit"),t=(null==r?void 0:r.writable)&&"number"==typeof r.value;function e(r){const e=Error.stackTraceLimit;t&&(Error.stackTraceLimit=0);const c=r();return t&&(Error.stackTraceLimit=e),c}export{e as createStacklessError};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),o=require("../noop/index.cjs"),t=require("../use-isomorphic-layout-effect/index.cjs"),n=require("../no-ssr/index.cjs"),r=require("../chunks/index.b9dLwVor.cjs"),a=require("../chunks/index.BtiK5_Nn.cjs");function i(){throw n.noSSRError("useLocalStorage cannot be used on the server without a serverValue")}exports.createStorage=function(n){const l="localStorage"===n?"foxact-use-local-storage":"foxact-use-session-storage",s="localStorage"===n?"foxact/use-local-storage":"foxact/use-session-storage",c="u"<typeof window?o.noop:e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))},u="u"<typeof window?o.noop:(e,o)=>{try{window[n].setItem(e,o)}catch(e){console.warn("[".concat(s,"] Failed to set value to ").concat(n,", it might be blocked"))}finally{c(e)}},d="u"<typeof window?o.noop:e=>{try{window[n].removeItem(e)}catch(e){console.warn("[".concat(s,"] Failed to remove value from ").concat(n,", it might be blocked"))}finally{c(e)}},w=e=>{if("u"<typeof window)return null;try{return window[n].getItem(e)}catch(e){return console.warn("[".concat(s,"] Failed to get value from ").concat(n,", it might be blocked")),null}};return{useStorage:function(n,s){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const f=e.useCallback(e=>{if("u"<typeof window)return o.noop;const t=o=>{"key"in o&&o.key!==n||e()},r=o=>{o.detail===n&&e()};return window.addEventListener("storage",t),window.addEventListener(l,r),()=>{window.removeEventListener("storage",t),window.removeEventListener(l,r)}},[n]),v=c.raw?r.t:c.serializer,g=c.raw?r.t:c.deserializer,y=void 0===s?i:()=>v(s),h=e.useSyncExternalStore(f,()=>w(n),y),m=e.useMemo(()=>null===h?null:g(h),[h,g]),p=e.useCallback(e=>{try{const o=a.n(e)?e(null!=m?m:null):e;null===o?d(n):u(n,v(o))}catch(e){console.warn(e)}},[n,v,m]);return t.useLayoutEffect(()=>{null===w(n)&&void 0!==s&&u(n,v(s))},[g,n,v,s]),[null===m?void 0===s?null:s:m,p]},useSetStorage:(o,t)=>e.useCallback(e=>{try{null===e?d(o):u(o,t(e))}catch(e){console.warn(e)}},[o,t])}};
1
+ "use strict";require("client-only");var e=require("react"),t=require("../noop/index.cjs"),r=require("../use-isomorphic-layout-effect/index.cjs"),n=require("../no-ssr/index.cjs"),o=require("../chunks/index.b9dLwVor.cjs"),i=require("../chunks/index.BtiK5_Nn.cjs");require("../create-stackless-error/index.cjs"),exports.createStorage=function(a){const s="localStorage"===a?"foxact-use-local-storage":"foxact-use-session-storage",l="localStorage"===a?"foxact/use-local-storage":"foxact/use-session-storage";function c(){throw n.noSSRError("[".concat(l,"] cannot be used on the server without a serverValue"))}const u="u"<typeof window?t.noop:e=>{window.dispatchEvent(new CustomEvent(s,{detail:e}))},d="u"<typeof window?t.noop:(e,t)=>{try{window[a].setItem(e,t)}catch(e){console.warn("[".concat(l,"] Failed to set value to ").concat(a,", it might be blocked"))}finally{u(e)}},w="u"<typeof window?t.noop:e=>{try{window[a].removeItem(e)}catch(e){console.warn("[".concat(l,"] Failed to remove value from ").concat(a,", it might be blocked"))}finally{u(e)}},f=e=>{if("u"<typeof window)return null;try{return window[a].getItem(e)}catch(e){return console.warn("[".concat(l,"] Failed to get value from ").concat(a,", it might be blocked")),null}},v=function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const n=r.raw?o.t:r.serializer,a=r.raw?o.t:r.deserializer;return e.useCallback(e=>{try{let r;if(i.n(e)){const n=f(t),o=null===n?null:a(n);r=e(o)}else r=e;null===r?w(t):d(t,n(r))}catch(e){console.warn(e)}},[t,n,a])};function g(n,i){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const l=e.useCallback(e=>{if("u"<typeof window)return t.noop;const r=t=>{"key"in t&&t.key!==n||e()},o=t=>{t.detail===n&&e()};return window.addEventListener("storage",r),window.addEventListener(s,o),()=>{window.removeEventListener("storage",r),window.removeEventListener(s,o)}},[n]),u=a.raw?o.t:a.serializer,w=a.raw?o.t:a.deserializer,v=void 0===i?c:()=>u(i),g=e.useSyncExternalStore(l,()=>f(n),v),y=e.useMemo(()=>null===g?null:w(g),[g,w]);return r.useLayoutEffect(()=>{null===f(n)&&void 0!==i&&d(n,u(i))},[n,u,i]),null===y?void 0===i?null:i:y}return{useStorageValue:g,useSetStorage:v,useStorage:function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};return[g(e,t,r),v(e,r)]}}};
@@ -19,11 +19,15 @@ interface UseStorageParserOption<T> {
19
19
  deserializer: Deserializer<T>;
20
20
  }
21
21
  declare function createStorage(type: StorageType): {
22
+ useStorageValue: {
23
+ <T>(key: string, serverValue: NotUndefined<T>, options?: UseStorageRawOption | UseStorageParserOption<T>): T;
24
+ <T>(key: string, serverValue?: undefined, options?: UseStorageRawOption | UseStorageParserOption<T>): T | null;
25
+ };
26
+ useSetStorage: <T>(key: string, options?: UseStorageRawOption | UseStorageParserOption<T>) => (v: React.SetStateAction<T | null>) => void;
22
27
  useStorage: {
23
28
  <T>(key: string, serverValue: NotUndefined<T>, options?: UseStorageRawOption | UseStorageParserOption<T>): StateHookTuple<T>;
24
29
  <T>(key: string, serverValue?: undefined, options?: UseStorageRawOption | UseStorageParserOption<T>): StateHookTuple<T | null>;
25
30
  };
26
- useSetStorage: <T>(key: string, serializer: Serializer<T>) => (v: T | null) => void;
27
31
  };
28
32
 
29
33
  export { createStorage };
@@ -1 +1 @@
1
- import"client-only";import{useCallback as e,useSyncExternalStore as o,useMemo as t}from"react";import{noop as n}from"../noop/index.mjs";import{useLayoutEffect as r}from"../use-isomorphic-layout-effect/index.mjs";import{noSSRError as i}from"../no-ssr/index.mjs";import{t as a}from"../chunks/index.D0KaUCcV.mjs";import{n as l}from"../chunks/index.C9-3oDdv.mjs";function s(){throw i("useLocalStorage cannot be used on the server without a serverValue")}function c(i){const c="localStorage"===i?"foxact-use-local-storage":"foxact-use-session-storage",u="localStorage"===i?"foxact/use-local-storage":"foxact/use-session-storage",d="u"<typeof window?n:e=>{window.dispatchEvent(new CustomEvent(c,{detail:e}))},w="u"<typeof window?n:(e,o)=>{try{window[i].setItem(e,o)}catch(e){console.warn("[".concat(u,"] Failed to set value to ").concat(i,", it might be blocked"))}finally{d(e)}},m="u"<typeof window?n:e=>{try{window[i].removeItem(e)}catch(e){console.warn("[".concat(u,"] Failed to remove value from ").concat(i,", it might be blocked"))}finally{d(e)}},f=e=>{if("u"<typeof window)return null;try{return window[i].getItem(e)}catch(e){return console.warn("[".concat(u,"] Failed to get value from ").concat(i,", it might be blocked")),null}};return{useStorage:function(i,u){let d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const g=e(e=>{if("u"<typeof window)return n;const o=o=>{"key"in o&&o.key!==i||e()},t=o=>{o.detail===i&&e()};return window.addEventListener("storage",o),window.addEventListener(c,t),()=>{window.removeEventListener("storage",o),window.removeEventListener(c,t)}},[i]),v=d.raw?a:d.serializer,p=d.raw?a:d.deserializer,y=o(g,()=>f(i),void 0===u?s:()=>v(u)),h=t(()=>null===y?null:p(y),[y,p]),x=e(e=>{try{const o=l(e)?e(null!=h?h:null):e;null===o?m(i):w(i,v(o))}catch(e){console.warn(e)}},[i,v,h]);return r(()=>{null===f(i)&&void 0!==u&&w(i,v(u))},[p,i,v,u]),[null===h?void 0===u?null:u:h,x]},useSetStorage:(o,t)=>e(e=>{try{null===e?m(o):w(o,t(e))}catch(e){console.warn(e)}},[o,t])}}export{c as createStorage};
1
+ import"client-only";import{useCallback as e,useSyncExternalStore as t,useMemo as o}from"react";import{noop as r}from"../noop/index.mjs";import{useLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";import{noSSRError as i}from"../no-ssr/index.mjs";import{t as a}from"../chunks/index.D0KaUCcV.mjs";import{n as s}from"../chunks/index.C9-3oDdv.mjs";import"../create-stackless-error/index.mjs";function l(l){const c="localStorage"===l?"foxact-use-local-storage":"foxact-use-session-storage",u="localStorage"===l?"foxact/use-local-storage":"foxact/use-session-storage";function d(){throw i("[".concat(u,"] cannot be used on the server without a serverValue"))}const w="u"<typeof window?r:e=>{window.dispatchEvent(new CustomEvent(c,{detail:e}))},m="u"<typeof window?r:(e,t)=>{try{window[l].setItem(e,t)}catch(e){console.warn("[".concat(u,"] Failed to set value to ").concat(l,", it might be blocked"))}finally{w(e)}},f="u"<typeof window?r:e=>{try{window[l].removeItem(e)}catch(e){console.warn("[".concat(u,"] Failed to remove value from ").concat(l,", it might be blocked"))}finally{w(e)}},g=e=>{if("u"<typeof window)return null;try{return window[l].getItem(e)}catch(e){return console.warn("[".concat(u,"] Failed to get value from ").concat(l,", it might be blocked")),null}},v=function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const r=o.raw?a:o.serializer,n=o.raw?a:o.deserializer;return e(e=>{try{let o;if(s(e)){const r=g(t),i=null===r?null:n(r);o=e(i)}else o=e;null===o?f(t):m(t,r(o))}catch(e){console.warn(e)}},[t,r,n])};function p(i,s){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const u=e(e=>{if("u"<typeof window)return r;const t=t=>{"key"in t&&t.key!==i||e()},o=t=>{t.detail===i&&e()};return window.addEventListener("storage",t),window.addEventListener(c,o),()=>{window.removeEventListener("storage",t),window.removeEventListener(c,o)}},[i]),w=l.raw?a:l.serializer,f=l.raw?a:l.deserializer,v=t(u,()=>g(i),void 0===s?d:()=>w(s)),p=o(()=>null===v?null:f(v),[v,f]);return n(()=>{null===g(i)&&void 0!==s&&m(i,w(s))},[i,w,s]),null===p?void 0===s?null:s:p}return{useStorageValue:p,useSetStorage:v,useStorage:function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};return[p(e,t,o),v(e,o)]}}}export{l as createStorage};
@@ -1 +1 @@
1
- "use strict";var e=require("../chunks/index.b9dLwVor.cjs"),r=require("../create-storage-hook/index.cjs");require("client-only"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../chunks/index.BtiK5_Nn.cjs"),exports.createStorageStateFactory=function(i){return function(t,s){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:c,useSetStorage:o}=r.createStorage(i);return[()=>c(t,s,n),()=>c(t,s,n)[0],()=>o(t,n.raw?e.t:n.serializer)]}};
1
+ "use strict";var e=require("../create-storage-hook/index.cjs");require("client-only"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs"),exports.createStorageStateFactory=function(r){return function(t,i){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:c,useStorageValue:n,useSetStorage:o}=e.createStorage(r);return[()=>c(t,i,s),()=>n(t,i,s),()=>o(t,s)]}};
@@ -1,7 +1,7 @@
1
1
  import { StateHookTuple, StorageType, NotUndefined, UseStorageRawOption, UseStorageParserOption } from '../create-storage-hook/index.js';
2
2
 
3
3
  type ValueHook<T> = () => T;
4
- type SetValueHook<T> = () => (value: T) => void;
4
+ type SetValueHook<T> = () => React.Dispatch<React.SetStateAction<T>>;
5
5
  type StateHook<T> = () => StateHookTuple<T>;
6
6
  declare function createStorageStateFactory(type: StorageType): {
7
7
  <T>(key: string, serverValue: NotUndefined<T>, options?: UseStorageRawOption | UseStorageParserOption<T>): readonly [StateHook<T>, ValueHook<T>, SetValueHook<T | null>];
@@ -1 +1 @@
1
- import{t as e}from"../chunks/index.D0KaUCcV.mjs";import{createStorage as r}from"../create-storage-hook/index.mjs";import"client-only";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../chunks/index.C9-3oDdv.mjs";function t(t){return function(o,i){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:s,useSetStorage:m}=r(t);return[()=>s(o,i,n),()=>s(o,i,n)[0],()=>m(o,n.raw?e:n.serializer)]}}export{t as createStorageStateFactory};
1
+ import{createStorage as e}from"../create-storage-hook/index.mjs";import"client-only";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";function r(r){return function(t,o){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:s,useStorageValue:n,useSetStorage:a}=e(r);return[()=>s(t,o,i),()=>n(t,o,i),()=>a(t,i)]}}export{r as createStorageStateFactory};
@@ -1,9 +1,10 @@
1
1
  import * as react from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
 
3
4
  interface CurrentYearProps extends React.ComponentProps<'span'> {
4
5
  defaultYear?: number;
5
6
  }
6
7
  /** @see https://foxact.skk.moe/current-year */
7
- declare const CurrentYear: react.NamedExoticComponent<CurrentYearProps>;
8
+ declare const CurrentYear: react.MemoExoticComponent<({ defaultYear, ...restProps }: CurrentYearProps) => react_jsx_runtime.JSX.Element>;
8
9
 
9
10
  export { CurrentYear };
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime");require("client-only");var r=require("react-dom"),t=require("../context-state/index.cjs"),n=require("../no-ssr/index.cjs"),o=require("react");require("../noop/index.cjs"),exports.createMagicPortal=function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[i,l,a]=t.createContextState(null);function s(r){let{as:t,ssrFallback:o=null,...i}=r;null!=o&&n.noSSR();const l=a();return e.jsx(t||"div",{...c?{"data-foxact-magic-portal-target":c}:{},ref:l,...i})}function u(r){const{ssrFallback:t=null}=r;return null!=t?e.jsx(o.Suspense,{fallback:t,children:e.jsx(s,{...r})}):e.jsx(s,{...r})}function d(e){let{children:t}=e;const n=l();return"u"<typeof window||!n?null:r.createPortal(t,n)}function p(r){let{children:t}=r;return e.jsx(i,{children:t})}return"production"!==process.env.NODE_ENV&&(u.displayName=c+".PortalTarget"),"production"!==process.env.NODE_ENV&&(d.displayName=c+".PortalContent"),"production"!==process.env.NODE_ENV&&(p.displayName=c+".PortalProvider"),[p,u,d]};
1
+ "use strict";var e=require("react/jsx-runtime");require("client-only");var r=require("react-dom"),t=require("../context-state/index.cjs"),n=require("../no-ssr/index.cjs"),o=require("react");require("../noop/index.cjs"),require("../create-stackless-error/index.cjs"),exports.createMagicPortal=function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[s,i,a]=t.createContextState(null);function l(r){let{as:t,ssrFallback:o=null,...s}=r;null!=o&&n.noSSR();const i=a();return e.jsx(t||"div",{...c?{"data-foxact-magic-portal-target":c}:{},ref:i,...s})}function u(r){const{ssrFallback:t=null}=r;return null!=t?e.jsx(o.Suspense,{fallback:t,children:e.jsx(l,{...r})}):e.jsx(l,{...r})}function d(e){let{children:t}=e;const n=i();return"u"<typeof window||!n?null:r.createPortal(t,n)}function p(r){let{children:t}=r;return e.jsx(s,{children:t})}return"production"!==process.env.NODE_ENV&&(u.displayName=c+".PortalTarget"),"production"!==process.env.NODE_ENV&&(d.displayName=c+".PortalContent"),"production"!==process.env.NODE_ENV&&(p.displayName=c+".PortalProvider"),[p,u,d]};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import"client-only";import{createPortal as o}from"react-dom";import{createContextState as n}from"../context-state/index.mjs";import{noSSR as r}from"../no-ssr/index.mjs";import{Suspense as e}from"react";import"../noop/index.mjs";function i(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[l,c,a]=n(null);function m(o){let{as:n,ssrFallback:e=null,...l}=o;null!=e&&r();const c=a();return t(n||"div",{...i?{"data-foxact-magic-portal-target":i}:{},ref:c,...l})}function u(o){const{ssrFallback:n=null}=o;return null!=n?t(e,{fallback:n,children:t(m,{...o})}):t(m,{...o})}function s(t){let{children:n}=t;const r=c();return"u"<typeof window||!r?null:o(n,r)}function p(o){let{children:n}=o;return t(l,{children:n})}return"production"!==process.env.NODE_ENV&&(u.displayName=i+".PortalTarget"),"production"!==process.env.NODE_ENV&&(s.displayName=i+".PortalContent"),"production"!==process.env.NODE_ENV&&(p.displayName=i+".PortalProvider"),[p,u,s]}export{i as createMagicPortal};
1
+ import{jsx as t}from"react/jsx-runtime";import"client-only";import{createPortal as o}from"react-dom";import{createContextState as r}from"../context-state/index.mjs";import{noSSR as n}from"../no-ssr/index.mjs";import{Suspense as e}from"react";import"../noop/index.mjs";import"../create-stackless-error/index.mjs";function i(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[l,c,a]=r(null);function s(o){let{as:r,ssrFallback:e=null,...l}=o;null!=e&&n();const c=a();return t(r||"div",{...i?{"data-foxact-magic-portal-target":i}:{},ref:c,...l})}function m(o){const{ssrFallback:r=null}=o;return null!=r?t(e,{fallback:r,children:t(s,{...o})}):t(s,{...o})}function u(t){let{children:r}=t;const n=c();return"u"<typeof window||!n?null:o(r,n)}function p(o){let{children:r}=o;return t(l,{children:r})}return"production"!==process.env.NODE_ENV&&(m.displayName=i+".PortalTarget"),"production"!==process.env.NODE_ENV&&(u.displayName=i+".PortalContent"),"production"!==process.env.NODE_ENV&&(p.displayName=i+".PortalProvider"),[p,m,u]}export{i as createMagicPortal};
package/no-ssr/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const r=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit"),t=(null==r?void 0:r.writable)&&"number"==typeof r.value;function o(r){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING";const e=Error.stackTraceLimit;t&&(Error.stackTraceLimit=0);const i=Error(r);return t&&(Error.stackTraceLimit=e),i.digest=o,i.recoverableError="NO_SSR",i}exports.noSSR=function(r){if("u"<typeof window)throw o(r)},exports.noSSRError=o;
1
+ "use strict";var r=require("../create-stackless-error/index.cjs");function e(e){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING";const t=r.createStacklessError(()=>Error(e));return t.digest=o,t.recoverableError="NO_SSR",t}exports.noSSR=function(r){if("u"<typeof window)throw e(r)},exports.noSSRError=e;
package/no-ssr/index.mjs CHANGED
@@ -1 +1 @@
1
- const r=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit"),t=(null==r?void 0:r.writable)&&"number"==typeof r.value;function o(r){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING";const e=Error.stackTraceLimit;t&&(Error.stackTraceLimit=0);const i=Error(r);return t&&(Error.stackTraceLimit=e),i.digest=o,i.recoverableError="NO_SSR",i}function e(r){if("u"<typeof window)throw o(r)}export{e as noSSR,o as noSSRError};
1
+ import{createStacklessError as r}from"../create-stackless-error/index.mjs";function o(o){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING";const t=r(()=>Error(o));return t.digest=e,t.recoverableError="NO_SSR",t}function e(r){if("u"<typeof window)throw o(r)}export{e as noSSR,o as noSSRError};
@@ -0,0 +1 @@
1
+ "use strict";var r=require("react/jsx-runtime"),e=require("react");exports.NoopComponent=function(){return r.jsx(e.Fragment,{})};
@@ -0,0 +1,3 @@
1
+ declare function NoopComponent(): React.ReactElement;
2
+
3
+ export { NoopComponent };
@@ -0,0 +1 @@
1
+ import{jsx as o}from"react/jsx-runtime";import{Fragment as r}from"react";function t(){return o(r,{})}export{t as NoopComponent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxact",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "React Hooks/Utils done right. For browser, SSR, and React Server Components.",
5
5
  "homepage": "https://foxact.skk.moe",
6
6
  "repository": {
@@ -61,15 +61,6 @@
61
61
  "require": "./compose-context-provider/index.cjs",
62
62
  "default": "./compose-context-provider/index.cjs"
63
63
  },
64
- "./context-reducer": {
65
- "types": "./context-reducer/index.d.ts",
66
- "import": {
67
- "types": "./context-reducer/index.d.ts",
68
- "default": "./context-reducer/index.mjs"
69
- },
70
- "require": "./context-reducer/index.cjs",
71
- "default": "./context-reducer/index.cjs"
72
- },
73
64
  "./context-state": {
74
65
  "types": "./context-state/index.d.ts",
75
66
  "import": {
@@ -97,6 +88,15 @@
97
88
  "require": "./create-context-state/index.cjs",
98
89
  "default": "./create-context-state/index.cjs"
99
90
  },
91
+ "./context-reducer": {
92
+ "types": "./context-reducer/index.d.ts",
93
+ "import": {
94
+ "types": "./context-reducer/index.d.ts",
95
+ "default": "./context-reducer/index.mjs"
96
+ },
97
+ "require": "./context-reducer/index.cjs",
98
+ "default": "./context-reducer/index.cjs"
99
+ },
100
100
  "./create-fixed-array": {
101
101
  "types": "./create-fixed-array/index.d.ts",
102
102
  "import": {
@@ -124,14 +124,14 @@
124
124
  "require": "./create-magic-portal/index.cjs",
125
125
  "default": "./create-magic-portal/index.cjs"
126
126
  },
127
- "./create-session-storage-state": {
128
- "types": "./create-session-storage-state/index.d.ts",
127
+ "./create-stackless-error": {
128
+ "types": "./create-stackless-error/index.d.ts",
129
129
  "import": {
130
- "types": "./create-session-storage-state/index.d.ts",
131
- "default": "./create-session-storage-state/index.mjs"
130
+ "types": "./create-stackless-error/index.d.ts",
131
+ "default": "./create-stackless-error/index.mjs"
132
132
  },
133
- "require": "./create-session-storage-state/index.cjs",
134
- "default": "./create-session-storage-state/index.cjs"
133
+ "require": "./create-stackless-error/index.cjs",
134
+ "default": "./create-stackless-error/index.cjs"
135
135
  },
136
136
  "./create-storage-hook": {
137
137
  "types": "./create-storage-hook/index.d.ts",
@@ -151,6 +151,15 @@
151
151
  "require": "./create-storage-state-factory/index.cjs",
152
152
  "default": "./create-storage-state-factory/index.cjs"
153
153
  },
154
+ "./create-session-storage-state": {
155
+ "types": "./create-session-storage-state/index.d.ts",
156
+ "import": {
157
+ "types": "./create-session-storage-state/index.d.ts",
158
+ "default": "./create-session-storage-state/index.mjs"
159
+ },
160
+ "require": "./create-session-storage-state/index.cjs",
161
+ "default": "./create-session-storage-state/index.cjs"
162
+ },
154
163
  "./current-year": {
155
164
  "types": "./current-year/index.d.ts",
156
165
  "import": {
@@ -160,15 +169,6 @@
160
169
  "require": "./current-year/index.cjs",
161
170
  "default": "./current-year/index.cjs"
162
171
  },
163
- "./email-protection": {
164
- "types": "./email-protection/index.d.ts",
165
- "import": {
166
- "types": "./email-protection/index.d.ts",
167
- "default": "./email-protection/index.mjs"
168
- },
169
- "require": "./email-protection/index.cjs",
170
- "default": "./email-protection/index.cjs"
171
- },
172
172
  "./fetch-jsonp": {
173
173
  "types": "./fetch-jsonp/index.d.ts",
174
174
  "import": {
@@ -178,14 +178,14 @@
178
178
  "require": "./fetch-jsonp/index.cjs",
179
179
  "default": "./fetch-jsonp/index.cjs"
180
180
  },
181
- "./invariant": {
182
- "types": "./invariant/index.d.ts",
181
+ "./email-protection": {
182
+ "types": "./email-protection/index.d.ts",
183
183
  "import": {
184
- "types": "./invariant/index.d.ts",
185
- "default": "./invariant/index.mjs"
184
+ "types": "./email-protection/index.d.ts",
185
+ "default": "./email-protection/index.mjs"
186
186
  },
187
- "require": "./invariant/index.cjs",
188
- "default": "./invariant/index.cjs"
187
+ "require": "./email-protection/index.cjs",
188
+ "default": "./email-protection/index.cjs"
189
189
  },
190
190
  "./is-safari": {
191
191
  "types": "./is-safari/index.d.ts",
@@ -196,14 +196,14 @@
196
196
  "require": "./is-safari/index.cjs",
197
197
  "default": "./is-safari/index.cjs"
198
198
  },
199
- "./magic-portal": {
200
- "types": "./magic-portal/index.d.ts",
199
+ "./invariant": {
200
+ "types": "./invariant/index.d.ts",
201
201
  "import": {
202
- "types": "./magic-portal/index.d.ts",
203
- "default": "./magic-portal/index.mjs"
202
+ "types": "./invariant/index.d.ts",
203
+ "default": "./invariant/index.mjs"
204
204
  },
205
- "require": "./magic-portal/index.cjs",
206
- "default": "./magic-portal/index.cjs"
205
+ "require": "./invariant/index.cjs",
206
+ "default": "./invariant/index.cjs"
207
207
  },
208
208
  "./merge-refs": {
209
209
  "types": "./merge-refs/index.d.ts",
@@ -214,6 +214,15 @@
214
214
  "require": "./merge-refs/index.cjs",
215
215
  "default": "./merge-refs/index.cjs"
216
216
  },
217
+ "./magic-portal": {
218
+ "types": "./magic-portal/index.d.ts",
219
+ "import": {
220
+ "types": "./magic-portal/index.d.ts",
221
+ "default": "./magic-portal/index.mjs"
222
+ },
223
+ "require": "./magic-portal/index.cjs",
224
+ "default": "./magic-portal/index.cjs"
225
+ },
217
226
  "./no-ssr": {
218
227
  "types": "./no-ssr/index.d.ts",
219
228
  "import": {
@@ -232,6 +241,15 @@
232
241
  "require": "./noop/index.cjs",
233
242
  "default": "./noop/index.cjs"
234
243
  },
244
+ "./noop-component": {
245
+ "types": "./noop-component/index.d.ts",
246
+ "import": {
247
+ "types": "./noop-component/index.d.ts",
248
+ "default": "./noop-component/index.mjs"
249
+ },
250
+ "require": "./noop-component/index.cjs",
251
+ "default": "./noop-component/index.cjs"
252
+ },
235
253
  "./nullthrow": {
236
254
  "types": "./nullthrow/index.d.ts",
237
255
  "import": {
@@ -268,15 +286,6 @@
268
286
  "require": "./request-idle-callback/index.cjs",
269
287
  "default": "./request-idle-callback/index.cjs"
270
288
  },
271
- "./types": {
272
- "types": "./types/index.d.ts",
273
- "import": {
274
- "types": "./types/index.d.ts",
275
- "default": "./types/index.mjs"
276
- },
277
- "require": "./types/index.cjs",
278
- "default": "./types/index.cjs"
279
- },
280
289
  "./typescript-happy-forward-ref": {
281
290
  "types": "./typescript-happy-forward-ref/index.d.ts",
282
291
  "import": {
@@ -286,6 +295,15 @@
286
295
  "require": "./typescript-happy-forward-ref/index.cjs",
287
296
  "default": "./typescript-happy-forward-ref/index.cjs"
288
297
  },
298
+ "./types": {
299
+ "types": "./types/index.d.ts",
300
+ "import": {
301
+ "types": "./types/index.d.ts",
302
+ "default": "./types/index.mjs"
303
+ },
304
+ "require": "./types/index.cjs",
305
+ "default": "./types/index.cjs"
306
+ },
289
307
  "./use": {
290
308
  "types": "./use/index.d.ts",
291
309
  "import": {
@@ -331,15 +349,6 @@
331
349
  "require": "./use-component-will-receive-update/index.cjs",
332
350
  "default": "./use-component-will-receive-update/index.cjs"
333
351
  },
334
- "./use-composition-input": {
335
- "types": "./use-composition-input/index.d.ts",
336
- "import": {
337
- "types": "./use-composition-input/index.d.ts",
338
- "default": "./use-composition-input/index.mjs"
339
- },
340
- "require": "./use-composition-input/index.cjs",
341
- "default": "./use-composition-input/index.cjs"
342
- },
343
352
  "./use-debounced-state": {
344
353
  "types": "./use-debounced-state/index.d.ts",
345
354
  "import": {
@@ -349,6 +358,15 @@
349
358
  "require": "./use-debounced-state/index.cjs",
350
359
  "default": "./use-debounced-state/index.cjs"
351
360
  },
361
+ "./use-composition-input": {
362
+ "types": "./use-composition-input/index.d.ts",
363
+ "import": {
364
+ "types": "./use-composition-input/index.d.ts",
365
+ "default": "./use-composition-input/index.mjs"
366
+ },
367
+ "require": "./use-composition-input/index.cjs",
368
+ "default": "./use-composition-input/index.cjs"
369
+ },
352
370
  "./use-debounced-value": {
353
371
  "types": "./use-debounced-value/index.d.ts",
354
372
  "import": {
@@ -430,15 +448,6 @@
430
448
  "require": "./use-map/index.cjs",
431
449
  "default": "./use-map/index.cjs"
432
450
  },
433
- "./use-media-query": {
434
- "types": "./use-media-query/index.d.ts",
435
- "import": {
436
- "types": "./use-media-query/index.d.ts",
437
- "default": "./use-media-query/index.mjs"
438
- },
439
- "require": "./use-media-query/index.cjs",
440
- "default": "./use-media-query/index.cjs"
441
- },
442
451
  "./use-page-visibility": {
443
452
  "types": "./use-page-visibility/index.d.ts",
444
453
  "import": {
@@ -448,6 +457,15 @@
448
457
  "require": "./use-page-visibility/index.cjs",
449
458
  "default": "./use-page-visibility/index.cjs"
450
459
  },
460
+ "./use-media-query": {
461
+ "types": "./use-media-query/index.d.ts",
462
+ "import": {
463
+ "types": "./use-media-query/index.d.ts",
464
+ "default": "./use-media-query/index.mjs"
465
+ },
466
+ "require": "./use-media-query/index.cjs",
467
+ "default": "./use-media-query/index.cjs"
468
+ },
451
469
  "./use-readonly-search-params": {
452
470
  "types": "./use-readonly-search-params/index.d.ts",
453
471
  "import": {
@@ -511,15 +529,6 @@
511
529
  "require": "./use-state-with-deps/index.cjs",
512
530
  "default": "./use-state-with-deps/index.cjs"
513
531
  },
514
- "./use-typescript-happy-callback": {
515
- "types": "./use-typescript-happy-callback/index.d.ts",
516
- "import": {
517
- "types": "./use-typescript-happy-callback/index.d.ts",
518
- "default": "./use-typescript-happy-callback/index.mjs"
519
- },
520
- "require": "./use-typescript-happy-callback/index.cjs",
521
- "default": "./use-typescript-happy-callback/index.cjs"
522
- },
523
532
  "./use-uncontrolled": {
524
533
  "types": "./use-uncontrolled/index.d.ts",
525
534
  "import": {
@@ -529,6 +538,15 @@
529
538
  "require": "./use-uncontrolled/index.cjs",
530
539
  "default": "./use-uncontrolled/index.cjs"
531
540
  },
541
+ "./use-typescript-happy-callback": {
542
+ "types": "./use-typescript-happy-callback/index.d.ts",
543
+ "import": {
544
+ "types": "./use-typescript-happy-callback/index.d.ts",
545
+ "default": "./use-typescript-happy-callback/index.mjs"
546
+ },
547
+ "require": "./use-typescript-happy-callback/index.cjs",
548
+ "default": "./use-typescript-happy-callback/index.cjs"
549
+ },
532
550
  "./use-url-hash-state": {
533
551
  "types": "./use-url-hash-state/index.d.ts",
534
552
  "import": {
package/sizes.json CHANGED
@@ -1 +1 @@
1
- {"total":{"raw":24632,"gzip":15124,"br":0},"exports":{"compose-context-provider":{"raw":177,"gzip":155,"br":122},"context-reducer":{"raw":557,"gzip":332,"br":319},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"create-context-state":{"raw":145,"gzip":116,"br":96},"create-local-storage-state":{"raw":402,"gzip":216,"br":189},"create-magic-portal":{"raw":224,"gzip":136,"br":112},"context-state":{"raw":402,"gzip":259,"br":218},"create-storage-state-factory":{"raw":592,"gzip":338,"br":304},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-session-storage-state":{"raw":406,"gzip":215,"br":188},"create-storage-hook":{"raw":2087,"gzip":897,"br":789},"email-protection":{"raw":426,"gzip":321,"br":272},"is-safari":{"raw":233,"gzip":164,"br":119},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"current-year":{"raw":524,"gzip":355,"br":293},"invariant":{"raw":178,"gzip":156,"br":118},"noop":{"raw":33,"gzip":53,"br":37},"no-ssr":{"raw":465,"gzip":313,"br":260},"merge-refs":{"raw":525,"gzip":280,"br":235},"nullthrow":{"raw":187,"gzip":163,"br":121},"magic-portal":{"raw":1039,"gzip":521,"br":463},"types":{"raw":0,"gzip":20,"br":1},"open-new-tab":{"raw":335,"gzip":255,"br":187},"use":{"raw":298,"gzip":197,"br":160},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"request-idle-callback":{"raw":392,"gzip":221,"br":171},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-composition-input":{"raw":470,"gzip":286,"br":241},"rem":{"raw":823,"gzip":395,"br":350},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-array":{"raw":322,"gzip":236,"br":202},"use-clipboard":{"raw":1177,"gzip":650,"br":552},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110},"use-is-online":{"raw":370,"gzip":258,"br":220},"use-fast-click":{"raw":578,"gzip":377,"br":304},"use-map":{"raw":339,"gzip":243,"br":208},"use-local-storage":{"raw":384,"gzip":215,"br":201},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-page-visibility":{"raw":359,"gzip":263,"br":210},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-media-query":{"raw":604,"gzip":380,"br":315},"use-session-storage":{"raw":390,"gzip":210,"br":201},"use-set":{"raw":340,"gzip":238,"br":203},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-readonly-search-params":{"raw":1120,"gzip":573,"br":477},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-state-with-deps":{"raw":464,"gzip":321,"br":295},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":450,"gzip":318,"br":249},"use-uncontrolled":{"raw":388,"gzip":273,"br":230},"use-url-hash-state":{"raw":1077,"gzip":611,"br":536}}}
1
+ {"total":{"raw":25754,"gzip":15606,"br":0},"exports":{"compose-context-provider":{"raw":177,"gzip":155,"br":122},"context-state":{"raw":402,"gzip":259,"br":218},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"context-reducer":{"raw":557,"gzip":332,"br":319},"create-local-storage-state":{"raw":446,"gzip":222,"br":209},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-magic-portal":{"raw":268,"gzip":148,"br":121},"create-context-state":{"raw":145,"gzip":116,"br":96},"create-storage-state-factory":{"raw":620,"gzip":341,"br":290},"create-session-storage-state":{"raw":450,"gzip":223,"br":206},"create-stackless-error":{"raw":278,"gzip":198,"br":162},"current-year":{"raw":524,"gzip":355,"br":293},"create-storage-hook":{"raw":2462,"gzip":972,"br":852},"is-safari":{"raw":233,"gzip":164,"br":119},"invariant":{"raw":178,"gzip":156,"br":118},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"merge-refs":{"raw":525,"gzip":280,"br":235},"email-protection":{"raw":426,"gzip":321,"br":272},"noop":{"raw":33,"gzip":53,"br":37},"magic-portal":{"raw":1083,"gzip":536,"br":472},"noop-component":{"raw":128,"gzip":120,"br":100},"nullthrow":{"raw":187,"gzip":163,"br":121},"open-new-tab":{"raw":335,"gzip":255,"br":187},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"types":{"raw":0,"gzip":20,"br":1},"no-ssr":{"raw":338,"gzip":267,"br":219},"use":{"raw":298,"gzip":197,"br":160},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"rem":{"raw":823,"gzip":395,"br":350},"use-array":{"raw":322,"gzip":236,"br":202},"request-idle-callback":{"raw":392,"gzip":221,"br":171},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-fast-click":{"raw":622,"gzip":392,"br":317},"use-is-online":{"raw":370,"gzip":258,"br":220},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-map":{"raw":339,"gzip":243,"br":208},"use-clipboard":{"raw":1177,"gzip":650,"br":552},"use-local-storage":{"raw":428,"gzip":226,"br":198},"use-page-visibility":{"raw":359,"gzip":263,"br":210},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-session-storage":{"raw":434,"gzip":225,"br":210},"use-readonly-search-params":{"raw":1164,"gzip":589,"br":496},"use-set":{"raw":340,"gzip":238,"br":203},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-state-with-deps":{"raw":464,"gzip":321,"br":295},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":450,"gzip":318,"br":249},"use-media-query":{"raw":648,"gzip":397,"br":332},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-uncontrolled":{"raw":388,"gzip":273,"br":230},"use-url-hash-state":{"raw":1121,"gzip":628,"br":556}}}
@@ -1 +1 @@
1
- "use strict";var e=require("react"),n=require("../use-media-query/index.cjs");require("../no-ssr/index.cjs"),require("../noop/index.cjs"),require("event-target-bus"),exports.useFastClick=function(t){const r=e.useCallback(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),t(e))},[t]);return n.useMediaQuery("(pointer: coarse)",!1)?{onClick:r}:{onMouseDown:r}};
1
+ "use strict";var e=require("react"),r=require("../use-media-query/index.cjs");require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../noop/index.cjs"),require("event-target-bus"),exports.useFastClick=function(n){const s=e.useCallback(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),n(e))},[n]);return r.useMediaQuery("(pointer: coarse)",!1)?{onClick:s}:{onMouseDown:s}};
@@ -1 +1 @@
1
- import{useCallback as e}from"react";import{useMediaQuery as o}from"../use-media-query/index.mjs";import"../no-ssr/index.mjs";import"../noop/index.mjs";import"event-target-bus";function t(t){const n=e(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),t(e))},[t]);return o("(pointer: coarse)",!1)?{onClick:n}:{onMouseDown:n}}export{t as useFastClick};
1
+ import{useCallback as e}from"react";import{useMediaQuery as o}from"../use-media-query/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../noop/index.mjs";import"event-target-bus";function t(t){const n=e(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),t(e))},[t]);return o("(pointer: coarse)",!1)?{onClick:n}:{onMouseDown:n}}export{t as useFastClick};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-hook/index.cjs");require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const{useStorage:r,useSetStorage:o}=e.createStorage("localStorage");exports.useLocalStorage=r,exports.useSetLocalStorage=o;
1
+ "use strict";require("client-only");var e=require("../create-storage-hook/index.cjs");require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const{useStorage:r,useSetStorage:s}=e.createStorage("localStorage");exports.useLocalStorage=r,exports.useSetLocalStorage=s;
@@ -1,10 +1,10 @@
1
- import { NotUndefined, UseStorageRawOption, UseStorageParserOption, StateHookTuple, Serializer } from '../create-storage-hook/index.js';
2
- export { Deserializer } from '../create-storage-hook/index.js';
1
+ import { NotUndefined, UseStorageRawOption, UseStorageParserOption, StateHookTuple } from '../create-storage-hook/index.js';
2
+ export { Deserializer, Serializer } from '../create-storage-hook/index.js';
3
3
 
4
4
  declare const useLocalStorage: {
5
5
  <T>(key: string, serverValue: NotUndefined<T>, options?: UseStorageRawOption | UseStorageParserOption<T>): StateHookTuple<T>;
6
6
  <T>(key: string, serverValue?: undefined, options?: UseStorageRawOption | UseStorageParserOption<T>): StateHookTuple<T | null>;
7
7
  };
8
- declare const useSetLocalStorage: <T>(key: string, serializer: Serializer<T>) => (v: T | null) => void;
8
+ declare const useSetLocalStorage: <T>(key: string, options?: UseStorageRawOption | UseStorageParserOption<T>) => (v: React.SetStateAction<T | null>) => void;
9
9
 
10
- export { Serializer, UseStorageParserOption as UseLocalStorageParserOption, UseStorageRawOption as UseLocalStorageRawOption, useLocalStorage, useSetLocalStorage };
10
+ export { UseStorageParserOption as UseLocalStorageParserOption, UseStorageRawOption as UseLocalStorageRawOption, useLocalStorage, useSetLocalStorage };
@@ -1 +1 @@
1
- import"client-only";import{createStorage as o}from"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const{useStorage:e,useSetStorage:t}=o("localStorage");export{e as useLocalStorage,t as useSetLocalStorage};
1
+ import"client-only";import{createStorage as e}from"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const{useStorage:o,useSetStorage:t}=e("localStorage");export{o as useLocalStorage,t as useSetLocalStorage};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";var e=require("../no-ssr/index.cjs"),r=require("../noop/index.cjs"),t=require("react"),n=require("event-target-bus");const o=new Map;function u(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,i){const a=t.useCallback(t=>(function(e,t){if("u"<typeof window)return r.noop;let u=o.get(e);return u||(u=n.createEventTargetBus(window.matchMedia(e),"change"),o.set(e,u)),u.on(t)})(e,t),[e]);return t.useSyncExternalStore(a,()=>"u"<typeof window?null!=i&&i:window.matchMedia(e).matches,void 0===i?u:()=>i)};
2
+ "use strict";var e=require("../no-ssr/index.cjs"),r=require("../noop/index.cjs"),t=require("react"),n=require("event-target-bus");require("../create-stackless-error/index.cjs");const o=new Map;function u(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,s){const i=t.useCallback(t=>(function(e,t){if("u"<typeof window)return r.noop;let u=o.get(e);return u||(u=n.createEventTargetBus(window.matchMedia(e),"change"),o.set(e,u)),u.on(t)})(e,t),[e]);return t.useSyncExternalStore(i,()=>"u"<typeof window?null!=s&&s:window.matchMedia(e).matches,void 0===s?u:()=>s)};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as t}from"../noop/index.mjs";import{useCallback as o,useSyncExternalStore as n}from"react";import{createEventTargetBus as r}from"event-target-bus";const i=new Map;function u(){throw e("useMediaQuery cannot be used on the server without a serverValue")}function a(e,a){return n(o(o=>(function(e,o){if("u"<typeof window)return t;let n=i.get(e);return n||(n=r(window.matchMedia(e),"change"),i.set(e,n)),n.on(o)})(e,o),[e]),()=>"u"<typeof window?null!=a&&a:window.matchMedia(e).matches,void 0===a?u:()=>a)}export{a as useMediaQuery};
2
+ import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as t}from"../noop/index.mjs";import{useCallback as o,useSyncExternalStore as r}from"react";import{createEventTargetBus as n}from"event-target-bus";import"../create-stackless-error/index.mjs";const i=new Map;function s(){throw e("useMediaQuery cannot be used on the server without a serverValue")}function u(e,u){return r(o(o=>(function(e,o){if("u"<typeof window)return t;let r=i.get(e);return r||(r=n(window.matchMedia(e),"change"),i.set(e,r)),r.on(o)})(e,o),[e]),()=>"u"<typeof window?null!=u&&u:window.matchMedia(e).matches,void 0===u?s:()=>u)}export{u as useMediaQuery};
@@ -1 +1 @@
1
- "use strict";var e=require("event-target-bus"),r=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),a=require("react");class t extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class o extends URLSearchParams{append(){throw new t}delete(){throw new t}set(){throw new t}sort(){throw new t}}let s=null;function u(r){return"u"<typeof window?n.noop:(null!=s||(s=e.createEventTargetBus(window,"popstate")),s.on(r))}let l=null,c=null;function i(){return"u"<typeof window?new o:window.location.search===l&&null!==c?c:c=new o(l=window.location.search)}function w(){throw r.noSSRError('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}exports.ReadonlyURLSearchParams=o,exports.useReadonlySearchParams=function(e){return a.useSyncExternalStore(u,i,null==e?w:()=>{const r=e();return r instanceof o?r:new o(r)})};
1
+ "use strict";var e=require("event-target-bus"),r=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),a=require("react");require("../create-stackless-error/index.cjs");class t extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class o extends URLSearchParams{append(){throw new t}delete(){throw new t}set(){throw new t}sort(){throw new t}}let s=null;function u(r){return"u"<typeof window?n.noop:(null!=s||(s=e.createEventTargetBus(window,"popstate")),s.on(r))}let c=null,l=null;function i(){return"u"<typeof window?new o:window.location.search===c&&null!==l?l:l=new o(c=window.location.search)}function w(){throw r.noSSRError('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}exports.ReadonlyURLSearchParams=o,exports.useReadonlySearchParams=function(e){return a.useSyncExternalStore(u,i,null==e?w:()=>{const r=e();return r instanceof o?r:new o(r)})};
@@ -1 +1 @@
1
- import{createEventTargetBus as e}from"event-target-bus";import{noSSRError as r}from"../no-ssr/index.mjs";import{noop as n}from"../noop/index.mjs";import{useSyncExternalStore as o}from"react";class a extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class t extends URLSearchParams{append(){throw new a}delete(){throw new a}set(){throw new a}sort(){throw new a}}let s=null;function l(r){return"u"<typeof window?n:(null!=s||(s=e(window,"popstate")),s.on(r))}let u=null,c=null;function i(){return"u"<typeof window?new t:window.location.search===u&&null!==c?c:c=new t(u=window.location.search)}function w(){throw r('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}function d(e){return o(l,i,null==e?w:()=>{const r=e();return r instanceof t?r:new t(r)})}export{t as ReadonlyURLSearchParams,d as useReadonlySearchParams};
1
+ import{createEventTargetBus as e}from"event-target-bus";import{noSSRError as r}from"../no-ssr/index.mjs";import{noop as n}from"../noop/index.mjs";import{useSyncExternalStore as o}from"react";import"../create-stackless-error/index.mjs";class a extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class t extends URLSearchParams{append(){throw new a}delete(){throw new a}set(){throw new a}sort(){throw new a}}let s=null;function l(r){return"u"<typeof window?n:(null!=s||(s=e(window,"popstate")),s.on(r))}let c=null,u=null;function i(){return"u"<typeof window?new t:window.location.search===c&&null!==u?u:u=new t(c=window.location.search)}function w(){throw r('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}function d(e){return o(l,i,null==e?w:()=>{const r=e();return r instanceof t?r:new t(r)})}export{t as ReadonlyURLSearchParams,d as useReadonlySearchParams};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-hook/index.cjs");require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const{useStorage:r,useSetStorage:s}=e.createStorage("sessionStorage");exports.useSessionStorage=r,exports.useSetSessionStorage=s;
1
+ "use strict";require("client-only");var e=require("../create-storage-hook/index.cjs");require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const{useStorage:r,useSetStorage:s}=e.createStorage("sessionStorage");exports.useSessionStorage=r,exports.useSetSessionStorage=s;
@@ -1,10 +1,10 @@
1
- import { NotUndefined, UseStorageRawOption, UseStorageParserOption, StateHookTuple, Serializer } from '../create-storage-hook/index.js';
2
- export { Deserializer } from '../create-storage-hook/index.js';
1
+ import { NotUndefined, UseStorageRawOption, UseStorageParserOption, StateHookTuple } from '../create-storage-hook/index.js';
2
+ export { Deserializer, Serializer } from '../create-storage-hook/index.js';
3
3
 
4
4
  declare const useSessionStorage: {
5
5
  <T>(key: string, serverValue: NotUndefined<T>, options?: UseStorageRawOption | UseStorageParserOption<T>): StateHookTuple<T>;
6
6
  <T>(key: string, serverValue?: undefined, options?: UseStorageRawOption | UseStorageParserOption<T>): StateHookTuple<T | null>;
7
7
  };
8
- declare const useSetSessionStorage: <T>(key: string, serializer: Serializer<T>) => (v: T | null) => void;
8
+ declare const useSetSessionStorage: <T>(key: string, options?: UseStorageRawOption | UseStorageParserOption<T>) => (v: React.SetStateAction<T | null>) => void;
9
9
 
10
- export { Serializer, UseStorageParserOption as UseSessionStorageParserOption, UseStorageRawOption as UseSessionStorageRawOption, useSessionStorage, useSetSessionStorage };
10
+ export { UseStorageParserOption as UseSessionStorageParserOption, UseStorageRawOption as UseSessionStorageRawOption, useSessionStorage, useSetSessionStorage };
@@ -1 +1 @@
1
- import"client-only";import{createStorage as e}from"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const{useStorage:o,useSetStorage:s}=e("sessionStorage");export{o as useSessionStorage,s as useSetSessionStorage};
1
+ import"client-only";import{createStorage as e}from"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const{useStorage:o,useSetStorage:s}=e("sessionStorage");export{o as useSessionStorage,s as useSetSessionStorage};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),r=require("../noop/index.cjs"),n=require("../no-ssr/index.cjs"),t=require("../chunks/index.b9dLwVor.cjs"),s=require("../chunks/index.BtiK5_Nn.cjs"),l=require("event-target-bus");let a=null;const i=e=>"u"<typeof window?r.noop:(null!=a||(a=l.createEventTargetBus(window,"hashchange")),a.on(e));function o(){throw n.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(r,n){var l;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t.t,deserializer:t.t};const u=a.raw?t.t:a.serializer,c=a.raw?t.t:a.deserializer,h=void 0===n?o:()=>u(n),d=e.useSyncExternalStore(i,()=>new URLSearchParams(location.hash.slice(1)).get(r),h),w=e.useMemo(()=>null===d?null!=n?n:null:c(d),[n,c,d]),S=e.useCallback(e=>{const t=location.hash,l=new URLSearchParams(t.slice(1)),a=s.n(e)?e(w):e;a===n||null===a?l.delete(r):l.set(r,u(a));const i=l.toString();t!==i&&(location.hash=i)},[n,w,r,u]);return[null!=(l=null!=w?w:n)?l:null,S]};
1
+ "use strict";require("client-only");var e=require("react"),r=require("../noop/index.cjs"),n=require("../no-ssr/index.cjs"),t=require("../chunks/index.b9dLwVor.cjs"),s=require("../chunks/index.BtiK5_Nn.cjs"),l=require("event-target-bus");require("../create-stackless-error/index.cjs");let a=null;const i=e=>"u"<typeof window?r.noop:(null!=a||(a=l.createEventTargetBus(window,"hashchange")),a.on(e));function o(){throw n.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(r,n){var l;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t.t,deserializer:t.t};const u=a.raw?t.t:a.serializer,c=a.raw?t.t:a.deserializer,h=void 0===n?o:()=>u(n),d=e.useSyncExternalStore(i,()=>new URLSearchParams(location.hash.slice(1)).get(r),h),w=e.useMemo(()=>null===d?null!=n?n:null:c(d),[n,c,d]),S=e.useCallback(e=>{const t=location.hash,l=new URLSearchParams(t.slice(1)),a=s.n(e)?e(w):e;a===n||null===a?l.delete(r):l.set(r,u(a));const i=l.toString();t!==i&&(location.hash=i)},[n,w,r,u]);return[null!=(l=null!=w?w:n)?l:null,S]};
@@ -1 +1 @@
1
- import"client-only";import{useSyncExternalStore as e,useMemo as n,useCallback as r}from"react";import{noop as t}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";import{t as l}from"../chunks/index.D0KaUCcV.mjs";import{n as s}from"../chunks/index.C9-3oDdv.mjs";import{createEventTargetBus as a}from"event-target-bus";let i=null;const u=e=>"u"<typeof window?t:(null!=i||(i=a(window,"hashchange")),i.on(e));function h(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function c(t,o){var a;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:l,deserializer:l};const c=i.raw?l:i.serializer,m=i.raw?l:i.deserializer,d=e(u,()=>new URLSearchParams(location.hash.slice(1)).get(t),void 0===o?h:()=>c(o)),w=n(()=>null===d?null!=o?o:null:m(d),[o,m,d]),p=r(e=>{const n=location.hash,r=new URLSearchParams(n.slice(1)),l=s(e)?e(w):e;l===o||null===l?r.delete(t):r.set(t,c(l));const a=r.toString();n!==a&&(location.hash=a)},[o,w,t,c]);return[null!=(a=null!=w?w:o)?a:null,p]}export{c as unstable_useUrlHashState};
1
+ import"client-only";import{useSyncExternalStore as e,useMemo as r,useCallback as t}from"react";import{noop as n}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";import{t as s}from"../chunks/index.D0KaUCcV.mjs";import{n as l}from"../chunks/index.C9-3oDdv.mjs";import{createEventTargetBus as a}from"event-target-bus";import"../create-stackless-error/index.mjs";let i=null;const u=e=>"u"<typeof window?n:(null!=i||(i=a(window,"hashchange")),i.on(e));function c(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function m(n,o){var a;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:s,deserializer:s};const m=i.raw?s:i.serializer,h=i.raw?s:i.deserializer,d=e(u,()=>new URLSearchParams(location.hash.slice(1)).get(n),void 0===o?c:()=>m(o)),p=r(()=>null===d?null!=o?o:null:h(d),[o,h,d]),w=t(e=>{const r=location.hash,t=new URLSearchParams(r.slice(1)),s=l(e)?e(p):e;s===o||null===s?t.delete(n):t.set(n,m(s));const a=t.toString();r!==a&&(location.hash=a)},[o,p,n,m]);return[null!=(a=null!=p?p:o)?a:null,w]}export{m as unstable_useUrlHashState};