foxact 0.2.39 → 0.2.40
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-fixed-array/index.cjs +1 -1
- package/create-fixed-array/index.d.ts +3 -3
- package/create-fixed-array/index.js +1 -1
- package/create-fixed-array/index.mjs +1 -1
- package/create-local-storage-state/index.cjs +1 -0
- package/create-local-storage-state/index.d.ts +24 -0
- package/create-local-storage-state/index.js +1 -0
- package/create-local-storage-state/index.mjs +1 -0
- package/create-session-storage-state/index.cjs +1 -0
- package/create-session-storage-state/index.d.ts +25 -0
- package/create-session-storage-state/index.js +1 -0
- package/create-session-storage-state/index.mjs +1 -0
- package/create-storage-hook/index.cjs +1 -1
- package/create-storage-hook/index.d.ts +4 -3
- package/create-storage-hook/index.js +1 -1
- package/create-storage-hook/index.mjs +1 -1
- package/create-storage-state-factory/index.cjs +1 -0
- package/create-storage-state-factory/index.d.ts +11 -0
- package/create-storage-state-factory/index.js +1 -0
- package/create-storage-state-factory/index.mjs +1 -0
- package/no-ssr/index.cjs +1 -1
- package/no-ssr/index.d.ts +2 -2
- package/no-ssr/index.js +1 -1
- package/no-ssr/index.mjs +1 -1
- package/nullthrow/index.d.ts +1 -1
- package/nullthrow/index.mjs +1 -1
- package/package.json +148 -121
- package/rem/index.cjs +1 -1
- package/rem/index.js +1 -1
- package/rem/index.mjs +1 -1
- package/sizes.json +1 -1
- package/use-abortable-effect/index.cjs +1 -1
- package/use-abortable-effect/index.d.ts +2 -2
- package/use-abortable-effect/index.js +1 -1
- package/use-abortable-effect/index.mjs +1 -1
- package/use-array/index.d.ts +1 -1
- package/use-array/index.mjs +1 -1
- package/use-composition-input/index.cjs +1 -1
- package/use-composition-input/index.d.ts +1 -1
- package/use-composition-input/index.js +1 -1
- package/use-composition-input/index.mjs +1 -1
- package/use-error-boundary/index.cjs +1 -1
- package/use-error-boundary/index.d.ts +1 -1
- package/use-error-boundary/index.js +1 -1
- package/use-error-boundary/index.mjs +1 -1
- package/use-is-client/index.cjs +1 -1
- package/use-is-client/index.d.ts +1 -1
- package/use-is-client/index.js +1 -1
- package/use-is-client/index.mjs +1 -1
- package/use-local-storage/index.d.ts +3 -3
- package/use-map/index.d.ts +1 -1
- package/use-map/index.mjs +1 -1
- package/use-media-query/index.cjs +1 -1
- package/use-media-query/index.d.ts +1 -1
- package/use-media-query/index.js +1 -1
- package/use-media-query/index.mjs +1 -1
- package/use-next-link/index.cjs +1 -1
- package/use-next-link/index.d.ts +3 -1
- package/use-next-link/index.js +1 -1
- package/use-next-link/index.mjs +1 -1
- package/use-next-pathname/index.d.ts +1 -1
- package/use-next-pathname/index.mjs +1 -1
- package/use-react-router-enable-concurrent-navigation/index.cjs +1 -1
- package/use-react-router-enable-concurrent-navigation/index.d.ts +2 -2
- package/use-react-router-enable-concurrent-navigation/index.js +1 -1
- package/use-react-router-enable-concurrent-navigation/index.mjs +1 -1
- package/use-react-router-is-match/index.d.ts +1 -1
- package/use-react-router-is-match/index.mjs +1 -1
- package/use-retimer/index.cjs +1 -1
- package/use-retimer/index.d.ts +1 -1
- package/use-retimer/index.js +1 -1
- package/use-retimer/index.mjs +1 -1
- package/use-session-storage/index.d.ts +3 -3
- package/use-set/index.d.ts +1 -1
- package/use-set/index.mjs +1 -1
- package/use-singleton/index.cjs +1 -1
- package/use-singleton/index.d.ts +1 -1
- package/use-singleton/index.js +1 -1
- package/use-singleton/index.mjs +1 -1
- package/use-url-hash-state/index.cjs +1 -1
- package/use-url-hash-state/index.js +1 -1
- package/use-url-hash-state/index.mjs +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),
|
|
2
|
+
"use strict";var e=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),t=require("react");const r=new Map;function o(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,i){"undefined"==typeof window||r.has(e)||r.set(e,window.matchMedia(e).matches);const a=t.useCallback(t=>(function(e,t){if("undefined"==typeof window)return n.noop;const o=window.matchMedia(e),i=()=>{r.set(e,o.matches),t()};return o.addEventListener("change",i),()=>{o.removeEventListener("change",i)}})(e,t),[e]);return t.useSyncExternalStore(a,()=>{var n;return"undefined"!=typeof window&&(null!==(n=r.get(e))&&void 0!==n?n:window.matchMedia(e).matches)},void 0===i?o:()=>i)};
|
package/use-media-query/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("../no-ssr/index.js"),n=require("../noop/index.js"),
|
|
2
|
+
"use strict";var e=require("../no-ssr/index.js"),n=require("../noop/index.js"),t=require("react");const r=new Map;function o(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,i){"undefined"==typeof window||r.has(e)||r.set(e,window.matchMedia(e).matches);const a=t.useCallback(t=>(function(e,t){if("undefined"==typeof window)return n.noop;const o=window.matchMedia(e),i=()=>{r.set(e,o.matches),t()};return o.addEventListener("change",i),()=>{o.removeEventListener("change",i)}})(e,t),[e]);return t.useSyncExternalStore(a,()=>{var n;return"undefined"!=typeof window&&(null!==(n=r.get(e))&&void 0!==n?n:window.matchMedia(e).matches)},void 0===i?o:()=>i)};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as n}from"../noop/index.mjs";import{useCallback as t,useSyncExternalStore as o}from"react";const
|
|
2
|
+
import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as n}from"../noop/index.mjs";import{useCallback as t,useSyncExternalStore as o}from"react";const i=new Map;function r(){throw e("useMediaQuery cannot be used on the server without a serverValue")}function d(e,d){return"undefined"==typeof window||i.has(e)||i.set(e,window.matchMedia(e).matches),o(t(t=>(function(e,t){if("undefined"==typeof window)return n;const o=window.matchMedia(e),r=()=>{i.set(e,o.matches),t()};return o.addEventListener("change",r),()=>{o.removeEventListener("change",r)}})(e,t),[e]),()=>{var n;return"undefined"!=typeof window&&(null!==(n=i.get(e))&&void 0!==n?n:window.matchMedia(e).matches)},void 0===d?r:()=>d)}export{d as useMediaQuery};
|
package/use-next-link/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),t=require("next/navigation"),r=require("next/dist/shared/lib/router/utils/format-url"),n=require("../use-intersection/index.cjs");
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),t=require("next/navigation"),r=require("next/dist/shared/lib/router/utils/format-url"),n=require("../use-intersection/index.cjs");function o(e,t,r){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,r)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}require("../request-idle-callback/index.cjs"),exports.unstable_useNextLink=function(u,s){let{prefetch:i,ref:c,onClick:l,onMouseEnter:a,onTouchStart:f,scroll:p=!0,replace:d=!1,...v}=s;process.env.NODE_ENV;const E=null==i?"auto":"full",y=!1!==i,N=t.useRouter(),[h,k]=e.useTransition(),[b,m,g]=n.useIntersection(e.useMemo(()=>({rootMargin:"200px"}),[])),q=e.useMemo(()=>"string"==typeof u?u:r.formatUrl(u),[u]),[x,_]=e.useState(q);return x!==q&&(_(q),g()),e.useEffect(()=>{"production"===process.env.NODE_ENV&&m&&y&&o(N,q,{kind:E})},[E,m,y,q,N]),[h,{ref:e.useCallback(e=>{b(e),"function"==typeof c?c(e):c&&e&&(c.current=e)},[c,b]),onClick:e.useCallback(e=>{if("function"==typeof l&&l(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;!("A"===t.toUpperCase()&&function(e){const t=e.currentTarget,r=t.getAttribute("target");return r&&"_self"!==r||t.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e))&&(e.preventDefault(),k(()=>{N[d?"replace":"push"](q,{scroll:p})}))},[l,d,q,N,p]),onMouseEnter:e.useCallback(e=>{"function"==typeof a&&a(e),"development"!==process.env.NODE_ENV&&y&&o(N,q,{kind:E})},[E,a,y,q,N]),onTouchStart:e.useCallback(e=>{"function"==typeof f&&f(e),"development"!==process.env.NODE_ENV&&y&&o(N,q,{kind:E})},[E,f,y,q,N]),...v}]};
|
package/use-next-link/index.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ interface UseNextLinkReturnProps extends Partial<React.JSX.IntrinsicElements['a'
|
|
|
23
23
|
onClick: React.MouseEventHandler<HTMLAnchorElement>;
|
|
24
24
|
href?: string;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
/** @see https://foxact.skk.moe/use-next-link */
|
|
27
|
+
declare function useNextLink(hrefProp: string | UrlObject, { prefetch: prefetchProp, ref, onClick, onMouseEnter, onTouchStart, scroll: routerScroll, replace, ...restProps }: UseNextLinkOptions): [isPending: boolean, linkProps: UseNextLinkReturnProps];
|
|
28
|
+
declare const unstable_useNextLink: typeof useNextLink;
|
|
27
29
|
|
|
28
30
|
export { type UseNextLinkOptions, type UseNextLinkReturnProps, unstable_useNextLink };
|
package/use-next-link/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),t=require("next/navigation"),r=require("next/dist/shared/lib/router/utils/format-url"),n=require("../use-intersection/index.js");
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),t=require("next/navigation"),r=require("next/dist/shared/lib/router/utils/format-url"),n=require("../use-intersection/index.js");function o(e,t,r){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,r)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}require("../request-idle-callback/index.js"),exports.unstable_useNextLink=function(u,s){let{prefetch:i,ref:c,onClick:l,onMouseEnter:a,onTouchStart:f,scroll:p=!0,replace:d=!1,...v}=s;process.env.NODE_ENV;const E=null==i?"auto":"full",y=!1!==i,N=t.useRouter(),[h,k]=e.useTransition(),[b,m,g]=n.useIntersection(e.useMemo(()=>({rootMargin:"200px"}),[])),q=e.useMemo(()=>"string"==typeof u?u:r.formatUrl(u),[u]),[x,_]=e.useState(q);return x!==q&&(_(q),g()),e.useEffect(()=>{"production"===process.env.NODE_ENV&&m&&y&&o(N,q,{kind:E})},[E,m,y,q,N]),[h,{ref:e.useCallback(e=>{b(e),"function"==typeof c?c(e):c&&e&&(c.current=e)},[c,b]),onClick:e.useCallback(e=>{if("function"==typeof l&&l(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;!("A"===t.toUpperCase()&&function(e){const t=e.currentTarget,r=t.getAttribute("target");return r&&"_self"!==r||t.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e))&&(e.preventDefault(),k(()=>{N[d?"replace":"push"](q,{scroll:p})}))},[l,d,q,N,p]),onMouseEnter:e.useCallback(e=>{"function"==typeof a&&a(e),"development"!==process.env.NODE_ENV&&y&&o(N,q,{kind:E})},[E,a,y,q,N]),onTouchStart:e.useCallback(e=>{"function"==typeof f&&f(e),"development"!==process.env.NODE_ENV&&y&&o(N,q,{kind:E})},[E,f,y,q,N]),...v}]};
|
package/use-next-link/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useTransition as e,useMemo as t,useState as
|
|
1
|
+
import"client-only";import{useTransition as e,useMemo as t,useState as n,useEffect as o,useCallback as r}from"react";import{useRouter as i}from"next/navigation";import{formatUrl as c}from"next/dist/shared/lib/router/utils/format-url";import{useIntersection as s}from"../use-intersection/index.mjs";import"../request-idle-callback/index.mjs";function u(e,t,n){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,n)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}const p=function(p,f){let{prefetch:l,ref:a,onClick:d,onMouseEnter:m,onTouchStart:v,scroll:E=!0,replace:y=!1,...N}=f;process.env.NODE_ENV;const h=null==l?"auto":"full",g=!1!==l,x=i(),[_,k]=e(),[D,w,O]=s(t(()=>({rootMargin:"200px"}),[])),V=t(()=>"string"==typeof p?p:c(p),[p]),[b,K]=n(V);return b!==V&&(K(V),O()),o(()=>{"production"===process.env.NODE_ENV&&w&&g&&u(x,V,{kind:h})},[h,w,g,V,x]),[_,{ref:r(e=>{D(e),"function"==typeof a?a(e):a&&e&&(a.current=e)},[a,D]),onClick:r(e=>{if("function"==typeof d&&d(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;!("A"===t.toUpperCase()&&function(e){const t=e.currentTarget,n=t.getAttribute("target");return n&&"_self"!==n||t.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e))&&(e.preventDefault(),k(()=>{x[y?"replace":"push"](V,{scroll:E})}))},[d,y,V,x,E]),onMouseEnter:r(e=>{"function"==typeof m&&m(e),"development"!==process.env.NODE_ENV&&g&&u(x,V,{kind:h})},[h,m,g,V,x]),onTouchStart:r(e=>{"function"==typeof v&&v(e),"development"!==process.env.NODE_ENV&&g&&u(x,V,{kind:h})},[h,v,g,V,x]),...N}]};export{p as unstable_useNextLink};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useRouter as t}from"next/router.js";import{useMemo as
|
|
1
|
+
import"client-only";import{useRouter as t}from"next/router.js";import{useMemo as e}from"react";function n(){let n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{asPath:o}=t();return e(()=>{const t=o.split(/[#?]/)[0];return n?t.endsWith("/")?t:"".concat(t,"/"):t},[n,o])}export{n as useNextPathname};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";require("client-only");var r=require("react"),e=require("react-router-dom");
|
|
2
|
+
"use strict";require("client-only");var r=require("react"),e=require("react-router-dom");function t(){const{navigator:t}=r.useContext(e.UNSAFE_NavigationContext);if(!t)throw TypeError("[foxact/use-react-router-enable-concurrent-navigation] must be used under <RouterProvider /> or a Router component (e.g. <BrowserRouter />)");r.useEffect(()=>{const e=t.go.bind(t),n=t.push.bind(t),o=t.replace.bind(t);return t.go=function(){for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];return r.startTransition(()=>e.apply(t,o))},t.push=function(){for(var e=arguments.length,o=Array(e),a=0;a<e;a++)o[a]=arguments[a];return r.startTransition(()=>n.apply(t,o))},t.replace=function(){for(var e=arguments.length,n=Array(e),a=0;a<e;a++)n[a]=arguments[a];return r.startTransition(()=>o.apply(t,n))},()=>{t.go=e,t.push=n,t.replace=o}},[t])}exports.ReactRouterConcurrentNavigationProvider=function(r){let{children:e}=r;return t(),e},exports.useReactRouterEnableConcurrentNavigation=t;
|
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { Foxact } from '../types/index.js';
|
|
3
3
|
|
|
4
4
|
/** @see https://foxact.skk.moe/use-react-router-enable-concurrent-navigation */
|
|
5
|
-
declare
|
|
6
|
-
declare
|
|
5
|
+
declare function useReactRouterEnableConcurrentNavigation(): void;
|
|
6
|
+
declare function ReactRouterConcurrentNavigationProvider({ children }: Foxact.PropsWithChildren): react.ReactNode;
|
|
7
7
|
|
|
8
8
|
export { ReactRouterConcurrentNavigationProvider, useReactRouterEnableConcurrentNavigation };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";require("client-only");var r=require("react"),e=require("react-router-dom");
|
|
2
|
+
"use strict";require("client-only");var r=require("react"),e=require("react-router-dom");function t(){const{navigator:t}=r.useContext(e.UNSAFE_NavigationContext);if(!t)throw TypeError("[foxact/use-react-router-enable-concurrent-navigation] must be used under <RouterProvider /> or a Router component (e.g. <BrowserRouter />)");r.useEffect(()=>{const e=t.go.bind(t),n=t.push.bind(t),o=t.replace.bind(t);return t.go=function(){for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];return r.startTransition(()=>e.apply(t,o))},t.push=function(){for(var e=arguments.length,o=Array(e),a=0;a<e;a++)o[a]=arguments[a];return r.startTransition(()=>n.apply(t,o))},t.replace=function(){for(var e=arguments.length,n=Array(e),a=0;a<e;a++)n[a]=arguments[a];return r.startTransition(()=>o.apply(t,n))},()=>{t.go=e,t.push=n,t.replace=o}},[t])}exports.ReactRouterConcurrentNavigationProvider=function(r){let{children:e}=r;return t(),e},exports.useReactRouterEnableConcurrentNavigation=t;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import"client-only";import{useContext as r,useEffect as e,startTransition as o}from"react";import{UNSAFE_NavigationContext as t}from"react-router-dom";
|
|
2
|
+
import"client-only";import{useContext as r,useEffect as e,startTransition as o}from"react";import{UNSAFE_NavigationContext as t}from"react-router-dom";function n(){const{navigator:n}=r(t);if(!n)throw TypeError("[foxact/use-react-router-enable-concurrent-navigation] must be used under <RouterProvider /> or a Router component (e.g. <BrowserRouter />)");e(()=>{const r=n.go.bind(n),e=n.push.bind(n),t=n.replace.bind(n);return n.go=function(){for(var e=arguments.length,t=Array(e),u=0;u<e;u++)t[u]=arguments[u];return o(()=>r.apply(n,t))},n.push=function(){for(var r=arguments.length,t=Array(r),u=0;u<r;u++)t[u]=arguments[u];return o(()=>e.apply(n,t))},n.replace=function(){for(var r=arguments.length,e=Array(r),u=0;u<r;u++)e[u]=arguments[u];return o(()=>t.apply(n,e))},()=>{n.go=r,n.push=e,n.replace=t}},[n])}function u(r){let{children:e}=r;return n(),e}export{u as ReactRouterConcurrentNavigationProvider,n as useReactRouterEnableConcurrentNavigation};
|
|
@@ -6,6 +6,6 @@ interface UseReactRouterIsMatchOption {
|
|
|
6
6
|
end?: boolean;
|
|
7
7
|
}
|
|
8
8
|
/** @see https://foxact.skk.moe/use-react-router-is-match */
|
|
9
|
-
declare
|
|
9
|
+
declare function useReactRouterIsMatch(to: To, { relative, caseSensitive, end }?: UseReactRouterIsMatchOption): any;
|
|
10
10
|
|
|
11
11
|
export { useReactRouterIsMatch };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useContext as t,useMemo as e}from"react";import{useLocation as r,UNSAFE_NavigationContext as o,useResolvedPath as a}from"react-router-dom";const n=t=>t
|
|
1
|
+
import"client-only";import{useContext as t,useMemo as e}from"react";import{useLocation as r,UNSAFE_NavigationContext as o,useResolvedPath as a}from"react-router-dom";const n=t=>t;function c(c){let{relative:i,caseSensitive:m=!1,end:s=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{pathname:h}=r(),{navigator:{encodeLocation:l=n}}=t(o),p=a(c,{relative:i});return e(()=>{let t=h,e=l(p).pathname;return m||(t=t.toLowerCase(),e=e.toLowerCase()),t===e||!s&&t.startsWith(e)&&"/"===t.charAt(e.length)},[l,p,h,m,s])}export{c as useReactRouterIsMatch};
|
package/use-retimer/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");exports.useRetimer=()
|
|
1
|
+
"use strict";require("client-only");var e=require("react");exports.useRetimer=function(){const r=e.useRef();return e.useCallback(e=>{"number"==typeof r.current&&clearTimeout(r.current),r.current=e},[])};
|
package/use-retimer/index.d.ts
CHANGED
package/use-retimer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");exports.useRetimer=()
|
|
1
|
+
"use strict";require("client-only");var e=require("react");exports.useRetimer=function(){const r=e.useRef();return e.useCallback(e=>{"number"==typeof r.current&&clearTimeout(r.current),r.current=e},[])};
|
package/use-retimer/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useRef as r,useCallback as e}from"react";
|
|
1
|
+
import"client-only";import{useRef as r,useCallback as e}from"react";function t(){const t=r();return e(r=>{"number"==typeof t.current&&clearTimeout(t.current),t.current=r},[])}export{t as useRetimer};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { UseStorageRawOption, UseStorageParserOption, Serializer } from '../create-storage-hook/index.js';
|
|
1
|
+
import { NotUndefined, UseStorageRawOption, UseStorageParserOption, StateHookTuple, Serializer } from '../create-storage-hook/index.js';
|
|
2
2
|
export { Deserializer } from '../create-storage-hook/index.js';
|
|
3
3
|
|
|
4
4
|
declare const useSessionStorage: {
|
|
5
|
-
<T>(key: string, serverValue: T
|
|
6
|
-
<T>(key: string, serverValue?: undefined, options?: UseStorageRawOption | UseStorageParserOption<T>):
|
|
5
|
+
<T>(key: string, serverValue: NotUndefined<T>, options?: UseStorageRawOption | UseStorageParserOption<T>): StateHookTuple<T>;
|
|
6
|
+
<T>(key: string, serverValue?: undefined, options?: UseStorageRawOption | UseStorageParserOption<T>): StateHookTuple<T | null>;
|
|
7
7
|
};
|
|
8
8
|
declare const useSetSessionStorage: <T>(key: string, serializer: Serializer<T>) => (v: T | null) => void;
|
|
9
9
|
|
package/use-set/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare function useSet<T>(initialState?: Set<T> | (() => Set<T>)): readonly [Set<T>, (item: T) => void, (item: T) => void, () => void, (s: Set<T>) => void];
|
|
2
2
|
|
|
3
3
|
export { useSet };
|
package/use-set/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useState as e,useCallback as t}from"react";
|
|
1
|
+
import"client-only";import{useState as e,useCallback as t}from"react";function n(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set;const[o,r]=e(n),i=t(e=>r(t=>t.has(e)?t:new Set([...t,e])),[]),l=t(e=>r(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]);return[o,i,l,t(()=>r(new Set),[]),t(e=>r(e),[])]}export{n as useSet};
|
package/use-singleton/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");exports.useSingleton=r
|
|
1
|
+
"use strict";require("client-only");var e=require("react");exports.useSingleton=function(r){const t=e.useRef();return t.current||(t.current=r()),t};
|
package/use-singleton/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ interface SingletonRefObject<T> {
|
|
|
2
2
|
readonly current: T;
|
|
3
3
|
}
|
|
4
4
|
/** @see https://foxact.skk.moe/use-singleton */
|
|
5
|
-
declare
|
|
5
|
+
declare function useSingleton<T>(initializor: () => T): SingletonRefObject<T>;
|
|
6
6
|
|
|
7
7
|
export { type SingletonRefObject, useSingleton };
|
package/use-singleton/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");exports.useSingleton=r
|
|
1
|
+
"use strict";require("client-only");var e=require("react");exports.useSingleton=function(r){const t=e.useRef();return t.current||(t.current=r()),t};
|
package/use-singleton/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useRef as r}from"react";
|
|
1
|
+
import"client-only";import{useRef as r}from"react";function t(t){const n=r();return n.current||(n.current=t()),n}export{t as useSingleton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),n=require("../noop/index.cjs"),r=require("../no-ssr/index.cjs");const t=e=>e,a=(()=>{if("undefined"==typeof window)return e=>n.noop;let e=!1;const r=new Set,t=()=>{r.forEach(e=>e())};return n=>(r.add(n),e||(e=!0,window.addEventListener("hashchange",t)),()=>{r.delete(n)})})(),o=e=>"function"==typeof e;function l(){throw r.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(n,r){var s;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t,deserializer:t};const u=i.raw?t:i.serializer,c=i.raw?t:i.deserializer,d=void 0===r?l:()=>u(r),h=e.useSyncExternalStore(a,()=>new URLSearchParams(location.hash.slice(1)).get(n),d),w=e.useMemo(()=>null===h?null!=r?r:null:c(h),[r,c,h]),S=e.useCallback(e=>{const t=location.hash,a=new URLSearchParams(t.slice(1)),l=o(e)?e(w):e;l===r||null===l?a.delete(n):a.set(n,u(l));const s=a.toString();t!==s&&(location.hash=s)},[r,w,n,u]);return[null!==(s=null!=w?w:r)&&void 0!==s?s:null,S]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),n=require("../noop/index.js"),r=require("../no-ssr/index.js");const t=e=>e,a=(()=>{if("undefined"==typeof window)return e=>n.noop;let e=!1;const r=new Set,t=()=>{r.forEach(e=>e())};return n=>(r.add(n),e||(e=!0,window.addEventListener("hashchange",t)),()=>{r.delete(n)})})(),o=e=>"function"==typeof e;function l(){throw r.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(n,r){var s;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t,deserializer:t};const u=i.raw?t:i.serializer,c=i.raw?t:i.deserializer,d=void 0===r?l:()=>u(r),h=e.useSyncExternalStore(a,()=>new URLSearchParams(location.hash.slice(1)).get(n),d),w=e.useMemo(()=>null===h?null!=r?r:null:c(h),[r,c,h]),S=e.useCallback(e=>{const t=location.hash,a=new URLSearchParams(t.slice(1)),l=o(e)?e(w):e;l===r||null===l?a.delete(n):a.set(n,u(l));const s=a.toString();t!==s&&(location.hash=s)},[r,w,n,u]);return[null!==(s=null!=w?w:r)&&void 0!==s?s:null,S]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useSyncExternalStore as e,useMemo as t,useCallback as n}from"react";import{noop as r}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";const a=e=>e,l=(()=>{if("undefined"==typeof window)return e=>r;let e=!1;const t=new Set,n=()=>{t.forEach(e=>e())};return r=>(t.add(r),e||(e=!0,window.addEventListener("hashchange",n)),()=>{t.delete(r)})})(),s=e=>"function"==typeof e
|
|
1
|
+
import"client-only";import{useSyncExternalStore as e,useMemo as t,useCallback as n}from"react";import{noop as r}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";const a=e=>e,l=(()=>{if("undefined"==typeof window)return e=>r;let e=!1;const t=new Set,n=()=>{t.forEach(e=>e())};return r=>(t.add(r),e||(e=!0,window.addEventListener("hashchange",n)),()=>{t.delete(r)})})(),s=e=>"function"==typeof e;function i(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function u(r,o){var u;let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:a,deserializer:a};const h=c.raw?a:c.serializer,d=c.raw?a:c.deserializer,w=e(l,()=>new URLSearchParams(location.hash.slice(1)).get(r),void 0===o?i:()=>h(o)),f=t(()=>null===w?null!=o?o:null:d(w),[o,d,w]),m=n(e=>{const t=location.hash,n=new URLSearchParams(t.slice(1)),a=s(e)?e(f):e;a===o||null===a?n.delete(r):n.set(r,h(a));const l=n.toString();t!==l&&(location.hash=l)},[o,f,r,h]);return[null!==(u=null!=f?f:o)&&void 0!==u?u:null,m]}export{u as unstable_useUrlHashState};
|