foxact 0.3.0 → 0.3.1
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/create-local-storage-state/index.cjs +1 -1
- package/create-local-storage-state/index.d.ts +2 -1
- package/create-local-storage-state/index.mjs +1 -1
- package/create-magic-portal/index.cjs +1 -1
- package/create-magic-portal/index.mjs +1 -1
- package/create-session-storage-state/index.cjs +1 -1
- package/create-session-storage-state/index.d.ts +2 -1
- package/create-session-storage-state/index.mjs +1 -1
- package/create-stackless-error/index.cjs +1 -0
- package/create-stackless-error/index.d.ts +3 -0
- package/create-stackless-error/index.mjs +1 -0
- package/create-storage-hook/index.cjs +1 -1
- package/create-storage-hook/index.d.ts +5 -1
- package/create-storage-hook/index.mjs +1 -1
- package/create-storage-state-factory/index.cjs +1 -1
- package/create-storage-state-factory/index.d.ts +1 -1
- package/create-storage-state-factory/index.mjs +1 -1
- package/current-year/index.d.ts +2 -1
- package/magic-portal/index.cjs +1 -1
- package/magic-portal/index.mjs +1 -1
- package/no-ssr/index.cjs +1 -1
- package/no-ssr/index.mjs +1 -1
- package/package.json +37 -28
- package/sizes.json +1 -1
- package/use-fast-click/index.cjs +1 -1
- package/use-fast-click/index.mjs +1 -1
- package/use-local-storage/index.cjs +1 -1
- package/use-local-storage/index.d.ts +4 -4
- package/use-local-storage/index.mjs +1 -1
- package/use-media-query/index.cjs +1 -1
- package/use-media-query/index.mjs +1 -1
- package/use-readonly-search-params/index.cjs +1 -1
- package/use-readonly-search-params/index.mjs +1 -1
- package/use-session-storage/index.cjs +1 -1
- package/use-session-storage/index.d.ts +4 -4
- package/use-session-storage/index.mjs +1 -1
- package/use-url-hash-state/index.cjs +1 -1
- 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("../
|
|
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
|
|
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("../
|
|
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
|
|
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 @@
|
|
|
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"),
|
|
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
|
|
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("../
|
|
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> = () =>
|
|
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{
|
|
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};
|
package/current-year/index.d.ts
CHANGED
|
@@ -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.
|
|
8
|
+
declare const CurrentYear: react.MemoExoticComponent<({ defaultYear, ...restProps }: CurrentYearProps) => react_jsx_runtime.JSX.Element>;
|
|
8
9
|
|
|
9
10
|
export { CurrentYear };
|
package/magic-portal/index.cjs
CHANGED
|
@@ -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,
|
|
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]};
|
package/magic-portal/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import"client-only";import{createPortal as o}from"react-dom";import{createContextState as
|
|
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";
|
|
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
|
-
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
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": {
|
|
@@ -88,6 +79,15 @@
|
|
|
88
79
|
"require": "./create-context-reducer/index.cjs",
|
|
89
80
|
"default": "./create-context-reducer/index.cjs"
|
|
90
81
|
},
|
|
82
|
+
"./context-reducer": {
|
|
83
|
+
"types": "./context-reducer/index.d.ts",
|
|
84
|
+
"import": {
|
|
85
|
+
"types": "./context-reducer/index.d.ts",
|
|
86
|
+
"default": "./context-reducer/index.mjs"
|
|
87
|
+
},
|
|
88
|
+
"require": "./context-reducer/index.cjs",
|
|
89
|
+
"default": "./context-reducer/index.cjs"
|
|
90
|
+
},
|
|
91
91
|
"./create-context-state": {
|
|
92
92
|
"types": "./create-context-state/index.d.ts",
|
|
93
93
|
"import": {
|
|
@@ -133,6 +133,15 @@
|
|
|
133
133
|
"require": "./create-session-storage-state/index.cjs",
|
|
134
134
|
"default": "./create-session-storage-state/index.cjs"
|
|
135
135
|
},
|
|
136
|
+
"./create-stackless-error": {
|
|
137
|
+
"types": "./create-stackless-error/index.d.ts",
|
|
138
|
+
"import": {
|
|
139
|
+
"types": "./create-stackless-error/index.d.ts",
|
|
140
|
+
"default": "./create-stackless-error/index.mjs"
|
|
141
|
+
},
|
|
142
|
+
"require": "./create-stackless-error/index.cjs",
|
|
143
|
+
"default": "./create-stackless-error/index.cjs"
|
|
144
|
+
},
|
|
136
145
|
"./create-storage-hook": {
|
|
137
146
|
"types": "./create-storage-hook/index.d.ts",
|
|
138
147
|
"import": {
|
|
@@ -196,15 +205,6 @@
|
|
|
196
205
|
"require": "./is-safari/index.cjs",
|
|
197
206
|
"default": "./is-safari/index.cjs"
|
|
198
207
|
},
|
|
199
|
-
"./magic-portal": {
|
|
200
|
-
"types": "./magic-portal/index.d.ts",
|
|
201
|
-
"import": {
|
|
202
|
-
"types": "./magic-portal/index.d.ts",
|
|
203
|
-
"default": "./magic-portal/index.mjs"
|
|
204
|
-
},
|
|
205
|
-
"require": "./magic-portal/index.cjs",
|
|
206
|
-
"default": "./magic-portal/index.cjs"
|
|
207
|
-
},
|
|
208
208
|
"./merge-refs": {
|
|
209
209
|
"types": "./merge-refs/index.d.ts",
|
|
210
210
|
"import": {
|
|
@@ -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": {
|
|
@@ -466,15 +475,6 @@
|
|
|
466
475
|
"require": "./use-retimer/index.cjs",
|
|
467
476
|
"default": "./use-retimer/index.cjs"
|
|
468
477
|
},
|
|
469
|
-
"./use-session-storage": {
|
|
470
|
-
"types": "./use-session-storage/index.d.ts",
|
|
471
|
-
"import": {
|
|
472
|
-
"types": "./use-session-storage/index.d.ts",
|
|
473
|
-
"default": "./use-session-storage/index.mjs"
|
|
474
|
-
},
|
|
475
|
-
"require": "./use-session-storage/index.cjs",
|
|
476
|
-
"default": "./use-session-storage/index.cjs"
|
|
477
|
-
},
|
|
478
478
|
"./use-set": {
|
|
479
479
|
"types": "./use-set/index.d.ts",
|
|
480
480
|
"import": {
|
|
@@ -484,6 +484,15 @@
|
|
|
484
484
|
"require": "./use-set/index.cjs",
|
|
485
485
|
"default": "./use-set/index.cjs"
|
|
486
486
|
},
|
|
487
|
+
"./use-session-storage": {
|
|
488
|
+
"types": "./use-session-storage/index.d.ts",
|
|
489
|
+
"import": {
|
|
490
|
+
"types": "./use-session-storage/index.d.ts",
|
|
491
|
+
"default": "./use-session-storage/index.mjs"
|
|
492
|
+
},
|
|
493
|
+
"require": "./use-session-storage/index.cjs",
|
|
494
|
+
"default": "./use-session-storage/index.cjs"
|
|
495
|
+
},
|
|
487
496
|
"./use-singleton": {
|
|
488
497
|
"types": "./use-singleton/index.d.ts",
|
|
489
498
|
"import": {
|
package/sizes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"total":{"raw":
|
|
1
|
+
{"total":{"raw":25626,"gzip":15486,"br":0},"exports":{"context-state":{"raw":402,"gzip":259,"br":218},"create-context-state":{"raw":145,"gzip":116,"br":96},"compose-context-provider":{"raw":177,"gzip":155,"br":122},"create-local-storage-state":{"raw":446,"gzip":222,"br":209},"create-magic-portal":{"raw":268,"gzip":148,"br":121},"context-reducer":{"raw":557,"gzip":332,"br":319},"create-stackless-error":{"raw":278,"gzip":198,"br":162},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"create-storage-state-factory":{"raw":620,"gzip":341,"br":290},"email-protection":{"raw":426,"gzip":321,"br":272},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"create-session-storage-state":{"raw":450,"gzip":223,"br":206},"create-storage-hook":{"raw":2462,"gzip":972,"br":852},"invariant":{"raw":178,"gzip":156,"br":118},"is-safari":{"raw":233,"gzip":164,"br":119},"no-ssr":{"raw":338,"gzip":267,"br":219},"current-year":{"raw":524,"gzip":355,"br":293},"merge-refs":{"raw":525,"gzip":280,"br":235},"nullthrow":{"raw":187,"gzip":163,"br":121},"open-new-tab":{"raw":335,"gzip":255,"br":187},"magic-portal":{"raw":1083,"gzip":536,"br":472},"types":{"raw":0,"gzip":20,"br":1},"rem":{"raw":823,"gzip":395,"br":350},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"use":{"raw":298,"gzip":197,"br":160},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"use-array":{"raw":322,"gzip":236,"br":202},"noop":{"raw":33,"gzip":53,"br":37},"request-idle-callback":{"raw":392,"gzip":221,"br":171},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-clipboard":{"raw":1177,"gzip":650,"br":552},"use-fast-click":{"raw":622,"gzip":392,"br":317},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110},"use-is-online":{"raw":370,"gzip":258,"br":220},"use-local-storage":{"raw":428,"gzip":226,"br":198},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-page-visibility":{"raw":359,"gzip":263,"br":210},"use-map":{"raw":339,"gzip":243,"br":208},"use-set":{"raw":340,"gzip":238,"br":203},"use-media-query":{"raw":648,"gzip":397,"br":332},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-readonly-search-params":{"raw":1164,"gzip":589,"br":496},"use-state-with-deps":{"raw":464,"gzip":321,"br":295},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-session-storage":{"raw":434,"gzip":225,"br":210},"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":1121,"gzip":628,"br":556}}}
|
package/use-fast-click/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),
|
|
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}};
|
package/use-fast-click/index.mjs
CHANGED
|
@@ -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:
|
|
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
|
|
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,
|
|
8
|
+
declare const useSetLocalStorage: <T>(key: string, options?: UseStorageRawOption | UseStorageParserOption<T>) => (v: React.SetStateAction<T | null>) => void;
|
|
9
9
|
|
|
10
|
-
export {
|
|
10
|
+
export { UseStorageParserOption as UseLocalStorageParserOption, UseStorageRawOption as UseLocalStorageRawOption, useLocalStorage, useSetLocalStorage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{createStorage as
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
8
|
+
declare const useSetSessionStorage: <T>(key: string, options?: UseStorageRawOption | UseStorageParserOption<T>) => (v: React.SetStateAction<T | null>) => void;
|
|
9
9
|
|
|
10
|
-
export {
|
|
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
|
|
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};
|