foxact 0.2.29 → 0.2.31

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.
@@ -1 +1 @@
1
- "use strict";var e=require("react");exports.ComposeContextProvider=r=>{let{contexts:t,children:o}=r;return t.reduceRight((r,t)=>e.cloneElement(t,{children:r}),o)};
1
+ "use strict";var e=require("react");const r=e.memo(r=>{let{contexts:t,children:o}=r;return t.reduceRight((r,t)=>e.cloneElement(t,{children:r}),o)});exports.ComposeContextProvider=r;
@@ -3,6 +3,7 @@ import * as react from 'react';
3
3
  interface ContextComposeProviderProps extends React.PropsWithChildren {
4
4
  contexts: React.ReactElement[];
5
5
  }
6
- declare const ComposeContextProvider: ({ contexts, children }: ContextComposeProviderProps) => react.ReactNode;
6
+ /** @see https://foxact.skk.moe/compose-context-provider */
7
+ declare const ComposeContextProvider: react.MemoExoticComponent<({ contexts, children }: ContextComposeProviderProps) => react.ReactNode>;
7
8
 
8
9
  export { ComposeContextProvider, type ContextComposeProviderProps };
@@ -1 +1 @@
1
- "use strict";var e=require("react");exports.ComposeContextProvider=r=>{let{contexts:t,children:o}=r;return t.reduceRight((r,t)=>e.cloneElement(t,{children:r}),o)};
1
+ "use strict";var e=require("react");const r=e.memo(r=>{let{contexts:t,children:o}=r;return t.reduceRight((r,t)=>e.cloneElement(t,{children:r}),o)});exports.ComposeContextProvider=r;
@@ -1 +1 @@
1
- import{cloneElement as e}from"react";const r=r=>{let{contexts:t,children:o}=r;return t.reduceRight((r,t)=>e(t,{children:r}),o)};export{r as ComposeContextProvider};
1
+ import{memo as e,cloneElement as r}from"react";const t=e(e=>{let{contexts:t,children:o}=e;return t.reduceRight((e,t)=>r(t,{children:e}),o)});export{t as ComposeContextProvider};
@@ -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");const r=e=>"function"==typeof e,a=e=>e,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",c="localStorage"===n?"foxact/use-local-storage":"foxact/use-session-storage",s="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))}:o.noop,u="undefined"!=typeof window?(e,o)=>{try{window[n].setItem(e,o)}catch(e){console.warn("[".concat(c,"] Failed to set value to ").concat(n,", it might be blocked"))}finally{s(e)}}:o.noop,d="undefined"!=typeof window?e=>{try{window[n].removeItem(e)}catch(e){console.warn("[".concat(c,"] Failed to remove value from ").concat(n,", it might be blocked"))}finally{s(e)}}:o.noop,w=e=>{if("undefined"==typeof window)return null;try{return window[n].getItem(e)}catch(e){return console.warn("[".concat(c,"] Failed to get value from ").concat(n,", it might be blocked")),null}};return{useStorage:function(n,c){var s;let f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const v=e.useCallback(e=>{if("undefined"==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]),y=f.raw?a:f.serializer,g=f.raw?a:f.deserializer,m=void 0!==c?()=>y(c):i,p=e.useSyncExternalStore(v,()=>w(n),m),h=e.useMemo(()=>null===p?null:g(p),[p,g]),S=e.useCallback(e=>{try{const o=r(e)?e(null!=h?h:null):e;null===o?d(n):u(n,y(o))}catch(e){console.warn(e)}},[n,y,h]);return t.useIsomorphicLayoutEffect(()=>{null===w(n)&&void 0!==c&&u(n,y(c))},[g,n,y,c]),[(s=null!=h?h:c)!==null&&void 0!==s?s:null,S]},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"),o=require("../noop/index.cjs"),t=require("../use-isomorphic-layout-effect/index.cjs"),n=require("../no-ssr/index.cjs");const r=e=>"function"==typeof e,a=e=>e,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",c="localStorage"===n?"foxact/use-local-storage":"foxact/use-session-storage",s="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))}:o.noop,u="undefined"!=typeof window?(e,o)=>{try{window[n].setItem(e,o)}catch(e){console.warn("[".concat(c,"] Failed to set value to ").concat(n,", it might be blocked"))}finally{s(e)}}:o.noop,d="undefined"!=typeof window?e=>{try{window[n].removeItem(e)}catch(e){console.warn("[".concat(c,"] Failed to remove value from ").concat(n,", it might be blocked"))}finally{s(e)}}:o.noop,w=e=>{if("undefined"==typeof window)return null;try{return window[n].getItem(e)}catch(e){return console.warn("[".concat(c,"] Failed to get value from ").concat(n,", it might be blocked")),null}};return{useStorage:function(n,c){var s;let f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const v=e.useCallback(e=>{if("undefined"==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]),y=f.raw?a:f.serializer,g=f.raw?a:f.deserializer,m=void 0!==c?()=>y(c):i,p=e.useSyncExternalStore(v,()=>w(n),m),h=e.useMemo(()=>null===p?null:g(p),[p,g]),S=e.useCallback(e=>{try{const o=r(e)?e(null!=h?h:null):e;null===o?d(n):u(n,y(o))}catch(e){console.warn(e)}},[n,y,h]);return t.useIsomorphicLayoutEffect(()=>{null===w(n)&&void 0!==c&&u(n,y(c))},[g,n,y,c]),[null!==(s=null!=h?h:c)&&void 0!==s?s:null,S]},useSetStorage:(o,t)=>e.useCallback(e=>{try{null===e?d(o):u(o,t(e))}catch(e){console.warn(e)}},[o,t])}};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),o=require("../noop/index.js"),t=require("../use-isomorphic-layout-effect/index.js"),n=require("../no-ssr/index.js");const r=e=>"function"==typeof e,a=e=>e,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="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))}:o.noop,u="undefined"!=typeof window?(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)}}:o.noop,d="undefined"!=typeof window?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)}}:o.noop,w=e=>{if("undefined"==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){var c;let f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const v=e.useCallback(e=>{if("undefined"==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]),y=f.raw?a:f.serializer,g=f.raw?a:f.deserializer,m=void 0!==s?()=>y(s):i,p=e.useSyncExternalStore(v,()=>w(n),m),h=e.useMemo(()=>null===p?null:g(p),[p,g]),S=e.useCallback(e=>{try{const o=r(e)?e(null!=h?h:null):e;null===o?d(n):u(n,y(o))}catch(e){console.warn(e)}},[n,y,h]);return t.useIsomorphicLayoutEffect(()=>{null===w(n)&&void 0!==s&&u(n,y(s))},[g,n,y,s]),[(c=null!=h?h:s)!==null&&void 0!==c?c:null,S]},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"),o=require("../noop/index.js"),t=require("../use-isomorphic-layout-effect/index.js"),n=require("../no-ssr/index.js");const r=e=>"function"==typeof e,a=e=>e,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="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))}:o.noop,u="undefined"!=typeof window?(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)}}:o.noop,d="undefined"!=typeof window?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)}}:o.noop,w=e=>{if("undefined"==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){var c;let f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const v=e.useCallback(e=>{if("undefined"==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]),y=f.raw?a:f.serializer,g=f.raw?a:f.deserializer,m=void 0!==s?()=>y(s):i,p=e.useSyncExternalStore(v,()=>w(n),m),h=e.useMemo(()=>null===p?null:g(p),[p,g]),S=e.useCallback(e=>{try{const o=r(e)?e(null!=h?h:null):e;null===o?d(n):u(n,y(o))}catch(e){console.warn(e)}},[n,y,h]);return t.useIsomorphicLayoutEffect(()=>{null===w(n)&&void 0!==s&&u(n,y(s))},[g,n,y,s]),[null!==(c=null!=h?h:s)&&void 0!==c?c:null,S]},useSetStorage:(o,t)=>e.useCallback(e=>{try{null===e?d(o):u(o,t(e))}catch(e){console.warn(e)}},[o,t])}};
@@ -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{useIsomorphicLayoutEffect as r}from"../use-isomorphic-layout-effect/index.mjs";import{noSSRError as i}from"../no-ssr/index.mjs";const a=e=>"function"==typeof e,l=e=>e,c=()=>{throw i("useLocalStorage cannot be used on the server without a serverValue")};function s(i){const s="localStorage"===i?"foxact-use-local-storage":"foxact-use-session-storage",d="localStorage"===i?"foxact/use-local-storage":"foxact/use-session-storage",u="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(s,{detail:e}))}:n,w="undefined"!=typeof window?(e,o)=>{try{window[i].setItem(e,o)}catch(e){console.warn("[".concat(d,"] Failed to set value to ").concat(i,", it might be blocked"))}finally{u(e)}}:n,f="undefined"!=typeof window?e=>{try{window[i].removeItem(e)}catch(e){console.warn("[".concat(d,"] Failed to remove value from ").concat(i,", it might be blocked"))}finally{u(e)}}:n,m=e=>{if("undefined"==typeof window)return null;try{return window[i].getItem(e)}catch(e){return console.warn("[".concat(d,"] Failed to get value from ").concat(i,", it might be blocked")),null}};return{useStorage:function(i,d){var u;let v=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const g=e(e=>{if("undefined"==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(s,t),()=>{window.removeEventListener("storage",o),window.removeEventListener(s,t)}},[i]),y=v.raw?l:v.serializer,p=v.raw?l:v.deserializer,h=o(g,()=>m(i),void 0!==d?()=>y(d):c),S=t(()=>null===h?null:p(h),[h,p]),x=e(e=>{try{const o=a(e)?e(null!=S?S:null):e;null===o?f(i):w(i,y(o))}catch(e){console.warn(e)}},[i,y,S]);return r(()=>{null===m(i)&&void 0!==d&&w(i,y(d))},[p,i,y,d]),[(u=null!=S?S:d)!==null&&void 0!==u?u:null,x]},useSetStorage:(o,t)=>e(e=>{try{null===e?f(o):w(o,t(e))}catch(e){console.warn(e)}},[o,t])}}export{s as createStorage};
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{useIsomorphicLayoutEffect as r}from"../use-isomorphic-layout-effect/index.mjs";import{noSSRError as i}from"../no-ssr/index.mjs";const a=e=>"function"==typeof e,l=e=>e,c=()=>{throw i("useLocalStorage cannot be used on the server without a serverValue")};function s(i){const s="localStorage"===i?"foxact-use-local-storage":"foxact-use-session-storage",d="localStorage"===i?"foxact/use-local-storage":"foxact/use-session-storage",u="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(s,{detail:e}))}:n,w="undefined"!=typeof window?(e,o)=>{try{window[i].setItem(e,o)}catch(e){console.warn("[".concat(d,"] Failed to set value to ").concat(i,", it might be blocked"))}finally{u(e)}}:n,f="undefined"!=typeof window?e=>{try{window[i].removeItem(e)}catch(e){console.warn("[".concat(d,"] Failed to remove value from ").concat(i,", it might be blocked"))}finally{u(e)}}:n,m=e=>{if("undefined"==typeof window)return null;try{return window[i].getItem(e)}catch(e){return console.warn("[".concat(d,"] Failed to get value from ").concat(i,", it might be blocked")),null}};return{useStorage:function(i,d){var u;let v=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const g=e(e=>{if("undefined"==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(s,t),()=>{window.removeEventListener("storage",o),window.removeEventListener(s,t)}},[i]),y=v.raw?l:v.serializer,p=v.raw?l:v.deserializer,h=o(g,()=>m(i),void 0!==d?()=>y(d):c),S=t(()=>null===h?null:p(h),[h,p]),x=e(e=>{try{const o=a(e)?e(null!=S?S:null):e;null===o?f(i):w(i,y(o))}catch(e){console.warn(e)}},[i,y,S]);return r(()=>{null===m(i)&&void 0!==d&&w(i,y(d))},[p,i,y,d]),[null!==(u=null!=S?S:d)&&void 0!==u?u:null,x]},useSetStorage:(o,t)=>e(e=>{try{null===e?f(o):w(o,t(e))}catch(e){console.warn(e)}},[o,t])}}export{s as createStorage};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../use-isomorphic-layout-effect/index.cjs");require("client-only");var i=r.memo(function(i){let{defaultYear:n,...u}=i;"undefined"==typeof window&&void 0===n&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[o,a]=r.useState(n||new Date().getFullYear());return t.useIsomorphicLayoutEffect(()=>{a(new Date().getFullYear())},[]),e.jsx("span",{...u,children:o})});module.exports=i;
2
+ "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../use-isomorphic-layout-effect/index.cjs");require("client-only");const n=r.memo(n=>{let{defaultYear:i,...u}=n;"undefined"==typeof window&&void 0===i&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[s,a]=r.useState(i||new Date().getFullYear());return t.useIsomorphicLayoutEffect(()=>{a(new Date().getFullYear())},[]),e.jsx("span",{...u,children:s})});"production"!==process.env.NODE_ENV&&(n.displayName="CurrentYear"),exports.CurrentYear=n;
@@ -4,7 +4,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  interface CurrentYearProps extends React.ComponentProps<'span'> {
5
5
  defaultYear?: number;
6
6
  }
7
- declare function CopyrightYear({ defaultYear, ...restProps }: CurrentYearProps): react_jsx_runtime.JSX.Element;
8
- declare const _default: react.MemoExoticComponent<typeof CopyrightYear>;
7
+ /** @see https://foxact.skk.moe/current-year */
8
+ declare const CurrentYear: react.MemoExoticComponent<({ defaultYear, ...restProps }: CurrentYearProps) => react_jsx_runtime.JSX.Element>;
9
9
 
10
- export { _default as default };
10
+ export { CurrentYear };
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../use-isomorphic-layout-effect/index.js");require("client-only");var i=r.memo(function(i){let{defaultYear:n,...u}=i;"undefined"==typeof window&&void 0===n&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[o,a]=r.useState(n||new Date().getFullYear());return t.useIsomorphicLayoutEffect(()=>{a(new Date().getFullYear())},[]),e.jsx("span",{...u,children:o})});module.exports=i;
2
+ "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../use-isomorphic-layout-effect/index.js");require("client-only");const n=r.memo(n=>{let{defaultYear:i,...u}=n;"undefined"==typeof window&&void 0===i&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[s,a]=r.useState(i||new Date().getFullYear());return t.useIsomorphicLayoutEffect(()=>{a(new Date().getFullYear())},[]),e.jsx("span",{...u,children:s})});"production"!==process.env.NODE_ENV&&(n.displayName="CurrentYear"),exports.CurrentYear=n;
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsx as e}from"react/jsx-runtime";import{memo as r,useState as t}from"react";import{useIsomorphicLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";import"client-only";var i=r(function(r){let{defaultYear:i,...o}=r;"undefined"==typeof window&&void 0===i&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[a,d]=t(i||new Date().getFullYear());return n(()=>{d(new Date().getFullYear())},[]),e("span",{...o,children:a})});export{i as default};
2
+ import{jsx as e}from"react/jsx-runtime";import{memo as r,useState as t}from"react";import{useIsomorphicLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";import"client-only";const o=r(r=>{let{defaultYear:o,...i}=r;"undefined"==typeof window&&void 0===o&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[a,s]=t(o||new Date().getFullYear());return n(()=>{s(new Date().getFullYear())},[]),e("span",{...i,children:a})});"production"!==process.env.NODE_ENV&&(o.displayName="CurrentYear");export{o as CurrentYear};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxact",
3
- "version": "0.2.29",
3
+ "version": "0.2.31",
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": {
@@ -22,7 +22,6 @@
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
24
  "client-only": "^0.0.1",
25
- "rollup-preserve-directives": "^1.1.0",
26
25
  "server-only": "^0.0.1"
27
26
  },
28
27
  "peerDependencies": {
@@ -67,6 +66,15 @@
67
66
  "exports": {
68
67
  "./package.json": "./package.json",
69
68
  "./sizes.json": "./sizes.json",
69
+ "./use-uncontrolled": {
70
+ "types": "./use-uncontrolled/index.d.ts",
71
+ "import": {
72
+ "types": "./use-uncontrolled/index.d.ts",
73
+ "default": "./use-uncontrolled/index.mjs"
74
+ },
75
+ "require": "./use-uncontrolled/index.cjs",
76
+ "default": "./use-uncontrolled/index.js"
77
+ },
70
78
  "./nullthrow": {
71
79
  "types": "./nullthrow/index.d.ts",
72
80
  "import": {
@@ -76,14 +84,14 @@
76
84
  "require": "./nullthrow/index.cjs",
77
85
  "default": "./nullthrow/index.js"
78
86
  },
79
- "./use-uncontrolled": {
80
- "types": "./use-uncontrolled/index.d.ts",
87
+ "./use-retimer": {
88
+ "types": "./use-retimer/index.d.ts",
81
89
  "import": {
82
- "types": "./use-uncontrolled/index.d.ts",
83
- "default": "./use-uncontrolled/index.mjs"
90
+ "types": "./use-retimer/index.d.ts",
91
+ "default": "./use-retimer/index.mjs"
84
92
  },
85
- "require": "./use-uncontrolled/index.cjs",
86
- "default": "./use-uncontrolled/index.js"
93
+ "require": "./use-retimer/index.cjs",
94
+ "default": "./use-retimer/index.js"
87
95
  },
88
96
  "./use-error-boundary": {
89
97
  "types": "./use-error-boundary/index.d.ts",
@@ -103,15 +111,6 @@
103
111
  "require": "./rem/index.cjs",
104
112
  "default": "./rem/index.js"
105
113
  },
106
- "./use-retimer": {
107
- "types": "./use-retimer/index.d.ts",
108
- "import": {
109
- "types": "./use-retimer/index.d.ts",
110
- "default": "./use-retimer/index.mjs"
111
- },
112
- "require": "./use-retimer/index.cjs",
113
- "default": "./use-retimer/index.js"
114
- },
115
114
  "./use-url-hash-state": {
116
115
  "types": "./use-url-hash-state/index.d.ts",
117
116
  "import": {
@@ -157,15 +156,6 @@
157
156
  "require": "./use-set/index.cjs",
158
157
  "default": "./use-set/index.js"
159
158
  },
160
- "./use-map": {
161
- "types": "./use-map/index.d.ts",
162
- "import": {
163
- "types": "./use-map/index.d.ts",
164
- "default": "./use-map/index.mjs"
165
- },
166
- "require": "./use-map/index.cjs",
167
- "default": "./use-map/index.js"
168
- },
169
159
  "./use": {
170
160
  "types": "./use/index.d.ts",
171
161
  "import": {
@@ -184,6 +174,15 @@
184
174
  "require": "./typescript-happy-forward-ref/index.cjs",
185
175
  "default": "./typescript-happy-forward-ref/index.js"
186
176
  },
177
+ "./use-map": {
178
+ "types": "./use-map/index.d.ts",
179
+ "import": {
180
+ "types": "./use-map/index.d.ts",
181
+ "default": "./use-map/index.mjs"
182
+ },
183
+ "require": "./use-map/index.cjs",
184
+ "default": "./use-map/index.js"
185
+ },
187
186
  "./compose-context-provider": {
188
187
  "types": "./compose-context-provider/index.d.ts",
189
188
  "import": {
@@ -193,15 +192,6 @@
193
192
  "require": "./compose-context-provider/index.cjs",
194
193
  "default": "./compose-context-provider/index.js"
195
194
  },
196
- "./use-react-router-is-match": {
197
- "types": "./use-react-router-is-match/index.d.ts",
198
- "import": {
199
- "types": "./use-react-router-is-match/index.d.ts",
200
- "default": "./use-react-router-is-match/index.mjs"
201
- },
202
- "require": "./use-react-router-is-match/index.cjs",
203
- "default": "./use-react-router-is-match/index.js"
204
- },
205
195
  "./request-idle-callback": {
206
196
  "types": "./request-idle-callback/index.d.ts",
207
197
  "import": {
@@ -211,14 +201,14 @@
211
201
  "require": "./request-idle-callback/index.cjs",
212
202
  "default": "./request-idle-callback/index.js"
213
203
  },
214
- "./use-singleton": {
215
- "types": "./use-singleton/index.d.ts",
204
+ "./use-react-router-is-match": {
205
+ "types": "./use-react-router-is-match/index.d.ts",
216
206
  "import": {
217
- "types": "./use-singleton/index.d.ts",
218
- "default": "./use-singleton/index.mjs"
207
+ "types": "./use-react-router-is-match/index.d.ts",
208
+ "default": "./use-react-router-is-match/index.mjs"
219
209
  },
220
- "require": "./use-singleton/index.cjs",
221
- "default": "./use-singleton/index.js"
210
+ "require": "./use-react-router-is-match/index.cjs",
211
+ "default": "./use-react-router-is-match/index.js"
222
212
  },
223
213
  "./use-intersection": {
224
214
  "types": "./use-intersection/index.d.ts",
@@ -229,15 +219,6 @@
229
219
  "require": "./use-intersection/index.cjs",
230
220
  "default": "./use-intersection/index.js"
231
221
  },
232
- "./no-ssr": {
233
- "types": "./no-ssr/index.d.ts",
234
- "import": {
235
- "types": "./no-ssr/index.d.ts",
236
- "default": "./no-ssr/index.mjs"
237
- },
238
- "require": "./no-ssr/index.cjs",
239
- "default": "./no-ssr/index.js"
240
- },
241
222
  "./current-year": {
242
223
  "types": "./current-year/index.d.ts",
243
224
  "import": {
@@ -247,14 +228,14 @@
247
228
  "require": "./current-year/index.cjs",
248
229
  "default": "./current-year/index.js"
249
230
  },
250
- "./create-fixed-array": {
251
- "types": "./create-fixed-array/index.d.ts",
231
+ "./no-ssr": {
232
+ "types": "./no-ssr/index.d.ts",
252
233
  "import": {
253
- "types": "./create-fixed-array/index.d.ts",
254
- "default": "./create-fixed-array/index.mjs"
234
+ "types": "./no-ssr/index.d.ts",
235
+ "default": "./no-ssr/index.mjs"
255
236
  },
256
- "require": "./create-fixed-array/index.cjs",
257
- "default": "./create-fixed-array/index.js"
237
+ "require": "./no-ssr/index.cjs",
238
+ "default": "./no-ssr/index.js"
258
239
  },
259
240
  "./use-clipboard": {
260
241
  "types": "./use-clipboard/index.d.ts",
@@ -265,32 +246,23 @@
265
246
  "require": "./use-clipboard/index.cjs",
266
247
  "default": "./use-clipboard/index.js"
267
248
  },
268
- "./use-react-router-enable-concurrent-navigation": {
269
- "types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
270
- "import": {
271
- "types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
272
- "default": "./use-react-router-enable-concurrent-navigation/index.mjs"
273
- },
274
- "require": "./use-react-router-enable-concurrent-navigation/index.cjs",
275
- "default": "./use-react-router-enable-concurrent-navigation/index.js"
276
- },
277
- "./use-next-pathname": {
278
- "types": "./use-next-pathname/index.d.ts",
249
+ "./create-fixed-array": {
250
+ "types": "./create-fixed-array/index.d.ts",
279
251
  "import": {
280
- "types": "./use-next-pathname/index.d.ts",
281
- "default": "./use-next-pathname/index.mjs"
252
+ "types": "./create-fixed-array/index.d.ts",
253
+ "default": "./create-fixed-array/index.mjs"
282
254
  },
283
- "require": "./use-next-pathname/index.cjs",
284
- "default": "./use-next-pathname/index.js"
255
+ "require": "./create-fixed-array/index.cjs",
256
+ "default": "./create-fixed-array/index.js"
285
257
  },
286
- "./use-composition-input": {
287
- "types": "./use-composition-input/index.d.ts",
258
+ "./use-singleton": {
259
+ "types": "./use-singleton/index.d.ts",
288
260
  "import": {
289
- "types": "./use-composition-input/index.d.ts",
290
- "default": "./use-composition-input/index.mjs"
261
+ "types": "./use-singleton/index.d.ts",
262
+ "default": "./use-singleton/index.mjs"
291
263
  },
292
- "require": "./use-composition-input/index.cjs",
293
- "default": "./use-composition-input/index.js"
264
+ "require": "./use-singleton/index.cjs",
265
+ "default": "./use-singleton/index.js"
294
266
  },
295
267
  "./use-session-storage": {
296
268
  "types": "./use-session-storage/index.d.ts",
@@ -301,6 +273,15 @@
301
273
  "require": "./use-session-storage/index.cjs",
302
274
  "default": "./use-session-storage/index.js"
303
275
  },
276
+ "./use-next-pathname": {
277
+ "types": "./use-next-pathname/index.d.ts",
278
+ "import": {
279
+ "types": "./use-next-pathname/index.d.ts",
280
+ "default": "./use-next-pathname/index.mjs"
281
+ },
282
+ "require": "./use-next-pathname/index.cjs",
283
+ "default": "./use-next-pathname/index.js"
284
+ },
304
285
  "./invariant": {
305
286
  "types": "./invariant/index.d.ts",
306
287
  "import": {
@@ -319,15 +300,6 @@
319
300
  "require": "./use-debounced-value/index.cjs",
320
301
  "default": "./use-debounced-value/index.js"
321
302
  },
322
- "./create-storage-hook": {
323
- "types": "./create-storage-hook/index.d.ts",
324
- "import": {
325
- "types": "./create-storage-hook/index.d.ts",
326
- "default": "./create-storage-hook/index.mjs"
327
- },
328
- "require": "./create-storage-hook/index.cjs",
329
- "default": "./create-storage-hook/index.js"
330
- },
331
303
  "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired": {
332
304
  "types": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.d.ts",
333
305
  "import": {
@@ -355,6 +327,15 @@
355
327
  "require": "./use-local-storage/index.cjs",
356
328
  "default": "./use-local-storage/index.js"
357
329
  },
330
+ "./use-next-link": {
331
+ "types": "./use-next-link/index.d.ts",
332
+ "import": {
333
+ "types": "./use-next-link/index.d.ts",
334
+ "default": "./use-next-link/index.mjs"
335
+ },
336
+ "require": "./use-next-link/index.cjs",
337
+ "default": "./use-next-link/index.js"
338
+ },
358
339
  "./use-isomorphic-layout-effect": {
359
340
  "types": "./use-isomorphic-layout-effect/index.d.ts",
360
341
  "import": {
@@ -381,6 +362,33 @@
381
362
  },
382
363
  "require": "./use-array/index.cjs",
383
364
  "default": "./use-array/index.js"
365
+ },
366
+ "./use-react-router-enable-concurrent-navigation": {
367
+ "types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
368
+ "import": {
369
+ "types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
370
+ "default": "./use-react-router-enable-concurrent-navigation/index.mjs"
371
+ },
372
+ "require": "./use-react-router-enable-concurrent-navigation/index.cjs",
373
+ "default": "./use-react-router-enable-concurrent-navigation/index.js"
374
+ },
375
+ "./use-composition-input": {
376
+ "types": "./use-composition-input/index.d.ts",
377
+ "import": {
378
+ "types": "./use-composition-input/index.d.ts",
379
+ "default": "./use-composition-input/index.mjs"
380
+ },
381
+ "require": "./use-composition-input/index.cjs",
382
+ "default": "./use-composition-input/index.js"
383
+ },
384
+ "./create-storage-hook": {
385
+ "types": "./create-storage-hook/index.d.ts",
386
+ "import": {
387
+ "types": "./create-storage-hook/index.d.ts",
388
+ "default": "./create-storage-hook/index.mjs"
389
+ },
390
+ "require": "./create-storage-hook/index.cjs",
391
+ "default": "./create-storage-hook/index.js"
384
392
  }
385
393
  }
386
394
  }
package/sizes.json CHANGED
@@ -1 +1 @@
1
- {"total":{"raw":15590,"gzip":9630,"br":0},"exports":{"use-error-boundary":{"raw":244,"gzip":196,"br":159},"nullthrow":{"raw":194,"gzip":167,"br":128},"use-uncontrolled":{"raw":296,"gzip":227,"br":193},"use-retimer":{"raw":200,"gzip":165,"br":123},"use-is-client":{"raw":151,"gzip":142,"br":118},"rem":{"raw":734,"gzip":380,"br":333},"noop":{"raw":33,"gzip":53,"br":37},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-url-hash-state":{"raw":1069,"gzip":613,"br":534},"use-set":{"raw":347,"gzip":240,"br":203},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"use-map":{"raw":346,"gzip":244,"br":210},"use":{"raw":276,"gzip":182,"br":150},"compose-context-provider":{"raw":164,"gzip":148,"br":114},"use-singleton":{"raw":138,"gzip":129,"br":109},"use-react-router-is-match":{"raw":568,"gzip":371,"br":309},"request-idle-callback":{"raw":410,"gzip":229,"br":175},"no-ssr":{"raw":389,"gzip":269,"br":228},"use-intersection":{"raw":1230,"gzip":649,"br":597},"create-fixed-array":{"raw":100,"gzip":104,"br":89},"current-year":{"raw":527,"gzip":358,"br":290},"use-next-pathname":{"raw":321,"gzip":236,"br":199},"use-clipboard":{"raw":1067,"gzip":611,"br":524},"use-composition-input":{"raw":454,"gzip":281,"br":238},"invariant":{"raw":178,"gzip":156,"br":118},"use-react-router-enable-concurrent-navigation":{"raw":960,"gzip":470,"br":387},"use-session-storage":{"raw":316,"gzip":181,"br":152},"use-debounced-value":{"raw":470,"gzip":309,"br":252},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":459,"gzip":325,"br":254},"context-state":{"raw":377,"gzip":241,"br":207},"create-context-state":{"raw":145,"gzip":116,"br":96},"use-local-storage":{"raw":310,"gzip":184,"br":157},"use-isomorphic-layout-effect":{"raw":178,"gzip":142,"br":113},"create-storage-hook":{"raw":2090,"gzip":891,"br":775},"use-array":{"raw":329,"gzip":238,"br":199}}}
1
+ {"total":{"raw":17256,"gzip":10522,"br":0},"exports":{"use-uncontrolled":{"raw":296,"gzip":227,"br":193},"nullthrow":{"raw":194,"gzip":167,"br":128},"use-retimer":{"raw":200,"gzip":165,"br":123},"use-error-boundary":{"raw":244,"gzip":196,"br":159},"rem":{"raw":734,"gzip":380,"br":333},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-url-hash-state":{"raw":1069,"gzip":612,"br":534},"use-is-client":{"raw":151,"gzip":142,"br":118},"noop":{"raw":33,"gzip":53,"br":37},"use":{"raw":276,"gzip":182,"br":150},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"use-set":{"raw":347,"gzip":240,"br":203},"use-map":{"raw":346,"gzip":244,"br":210},"compose-context-provider":{"raw":177,"gzip":155,"br":122},"request-idle-callback":{"raw":410,"gzip":229,"br":175},"use-react-router-is-match":{"raw":568,"gzip":371,"br":309},"current-year":{"raw":592,"gzip":400,"br":326},"use-intersection":{"raw":1230,"gzip":649,"br":597},"create-fixed-array":{"raw":100,"gzip":104,"br":89},"no-ssr":{"raw":389,"gzip":269,"br":228},"use-singleton":{"raw":138,"gzip":129,"br":109},"use-clipboard":{"raw":1067,"gzip":611,"br":524},"use-next-pathname":{"raw":321,"gzip":236,"br":199},"use-session-storage":{"raw":316,"gzip":181,"br":152},"invariant":{"raw":178,"gzip":156,"br":118},"use-debounced-value":{"raw":470,"gzip":309,"br":252},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":459,"gzip":325,"br":254},"context-state":{"raw":377,"gzip":241,"br":207},"use-local-storage":{"raw":310,"gzip":184,"br":157},"create-context-state":{"raw":145,"gzip":116,"br":96},"use-isomorphic-layout-effect":{"raw":178,"gzip":142,"br":113},"use-array":{"raw":329,"gzip":238,"br":199},"use-next-link":{"raw":1588,"gzip":845,"br":728},"use-composition-input":{"raw":454,"gzip":281,"br":238},"use-react-router-enable-concurrent-navigation":{"raw":960,"gzip":470,"br":387},"create-storage-hook":{"raw":2090,"gzip":890,"br":773}}}
@@ -0,0 +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");require("../request-idle-callback/index.cjs");const o=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},s=(e,t,r)=>{"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,r)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})};exports.unstable_useNextLink=(u,i)=>{let{prefetch:c,ref:l,onClick:a,onMouseEnter:f,onTouchStart:p,scroll:d=!0,replace:v=!1,...E}=i;process.env.NODE_ENV;const y=null==c?"auto":"full",N=!1!==c,h=t.useRouter(),[k,b]=e.useTransition(),[g,m,q]=n.useIntersection({rootMargin:"200px"}),x=e.useMemo(()=>"string"==typeof u?u:r.formatUrl(u),[u]),[_,C]=e.useState(x);return _!==x&&(C(x),q()),e.useEffect(()=>{"production"===process.env.NODE_ENV&&m&&N&&s(h,x,{kind:y})},[y,m,N,x,h]),[k,{ref:e.useCallback(e=>{g(e),"function"==typeof l?l(e):l&&e&&(l.current=e)},[l,g]),onClick:e.useCallback(e=>{if("function"==typeof a&&a(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;!("A"===t.toUpperCase()&&o(e))&&(e.preventDefault(),b(()=>{h[v?"replace":"push"](x,{scroll:d})}))},[a,v,x,h,d]),onMouseEnter:e.useCallback(e=>{"function"==typeof f&&f(e),"development"!==process.env.NODE_ENV&&N&&s(h,x,{kind:y})},[y,f,N,x,h]),onTouchStart:e.useCallback(e=>{"function"==typeof p&&p(e),"development"!==process.env.NODE_ENV&&N&&s(h,x,{kind:y})},[y,p,N,x,h]),...E}]};
@@ -0,0 +1,16 @@
1
+ import { UrlObject } from 'url';
2
+ import { LinkProps } from 'next/link';
3
+
4
+ interface UseNextLinkOptions extends Omit<LinkProps, 'as' | 'href' | 'legacyBehavior' | 'shallow' | 'passHref' | 'locale'> {
5
+ ref?: React.RefObject<HTMLAnchorElement> | React.RefCallback<HTMLAnchorElement> | null;
6
+ }
7
+ interface UseNextLinkReturnProps extends Partial<JSX.IntrinsicElements['a']> {
8
+ ref: React.RefCallback<HTMLAnchorElement>;
9
+ onTouchStart: React.TouchEventHandler<HTMLAnchorElement>;
10
+ onMouseEnter: React.MouseEventHandler<HTMLAnchorElement>;
11
+ onClick: React.MouseEventHandler<HTMLAnchorElement>;
12
+ href?: string;
13
+ }
14
+ declare const unstable_useNextLink: (hrefProp: string | UrlObject, { prefetch: prefetchProp, ref, onClick, onMouseEnter, onTouchStart, scroll: routerScroll, replace, ...restProps }: UseNextLinkOptions) => [isPending: boolean, linkProps: UseNextLinkReturnProps];
15
+
16
+ export { type UseNextLinkOptions, type UseNextLinkReturnProps, unstable_useNextLink };
@@ -0,0 +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");require("../request-idle-callback/index.js");const o=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},s=(e,t,r)=>{"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,r)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})};exports.unstable_useNextLink=(u,i)=>{let{prefetch:c,ref:l,onClick:a,onMouseEnter:f,onTouchStart:p,scroll:d=!0,replace:v=!1,...E}=i;process.env.NODE_ENV;const y=null==c?"auto":"full",N=!1!==c,h=t.useRouter(),[k,b]=e.useTransition(),[g,m,q]=n.useIntersection({rootMargin:"200px"}),x=e.useMemo(()=>"string"==typeof u?u:r.formatUrl(u),[u]),[_,C]=e.useState(x);return _!==x&&(C(x),q()),e.useEffect(()=>{"production"===process.env.NODE_ENV&&m&&N&&s(h,x,{kind:y})},[y,m,N,x,h]),[k,{ref:e.useCallback(e=>{g(e),"function"==typeof l?l(e):l&&e&&(l.current=e)},[l,g]),onClick:e.useCallback(e=>{if("function"==typeof a&&a(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;!("A"===t.toUpperCase()&&o(e))&&(e.preventDefault(),b(()=>{h[v?"replace":"push"](x,{scroll:d})}))},[a,v,x,h,d]),onMouseEnter:e.useCallback(e=>{"function"==typeof f&&f(e),"development"!==process.env.NODE_ENV&&N&&s(h,x,{kind:y})},[y,f,N,x,h]),onTouchStart:e.useCallback(e=>{"function"==typeof p&&p(e),"development"!==process.env.NODE_ENV&&N&&s(h,x,{kind:y})},[y,p,N,x,h]),...E}]};
@@ -0,0 +1 @@
1
+ import"client-only";import{useTransition as e,useMemo as t,useState as r,useEffect as n,useCallback as o}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";const p=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},l=(e,t,r)=>{"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,r)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})},u=(u,f)=>{let{prefetch:a,ref:d,onClick:m,onMouseEnter:v,onTouchStart:E,scroll:y=!0,replace:N=!1,...h}=f;process.env.NODE_ENV;const g=null==a?"auto":"full",x=!1!==a,_=i(),[k,D]=e(),[w,O,V]=s({rootMargin:"200px"}),b=t(()=>"string"==typeof u?u:c(u),[u]),[K,T]=r(b);return K!==b&&(T(b),V()),n(()=>{"production"===process.env.NODE_ENV&&O&&x&&l(_,b,{kind:g})},[g,O,x,b,_]),[k,{ref:o(e=>{w(e),"function"==typeof d?d(e):d&&e&&(d.current=e)},[d,w]),onClick:o(e=>{if("function"==typeof m&&m(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;!("A"===t.toUpperCase()&&p(e))&&(e.preventDefault(),D(()=>{_[N?"replace":"push"](b,{scroll:y})}))},[m,N,b,_,y]),onMouseEnter:o(e=>{"function"==typeof v&&v(e),"development"!==process.env.NODE_ENV&&x&&l(_,b,{kind:g})},[g,v,x,b,_]),onTouchStart:o(e=>{"function"==typeof E&&E(e),"development"!==process.env.NODE_ENV&&x&&l(_,b,{kind:g})},[g,E,x,b,_]),...h}]};export{u as unstable_useNextLink};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),r=require("../noop/index.cjs"),n=require("../no-ssr/index.cjs");const t=e=>e,a=(()=>{if("undefined"==typeof window)return e=>r.noop;let e=!1;const n=new Set,t=()=>{n.forEach(e=>e())};return r=>(n.add(r),e||(e=!0,window.addEventListener("hashchange",t)),()=>{n.delete(r)})})(),l=e=>"function"==typeof e,o=()=>{throw n.noSSRError("useUrlHashState cannot be used on the server without a serverValue")};exports.unstable_useUrlHashState=function(r,n){var s;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:t,deserializer:t};const u=i.raw?t:i.serializer,c=i.raw?t:i.deserializer,d=void 0!==n?()=>u(n):o,h=e.useSyncExternalStore(a,()=>new URLSearchParams(location.hash.slice(1)).get(r),d),w=e.useMemo(()=>null===h?null!=n?n:null:c(h),[n,c,h]),S=e.useCallback(e=>{const t=location.hash,a=new URLSearchParams(t.slice(1)),o=l(e)?e(w):e;o===n||null===o?a.delete(r):a.set(r,u(o));const s=a.toString();t!==s&&(location.hash=s)},[n,w,r,u]);return[(s=null!=w?w:n)!==null&&void 0!==s?s:null,S]};
1
+ "use strict";require("client-only");var e=require("react"),r=require("../noop/index.cjs"),n=require("../no-ssr/index.cjs");const t=e=>e,a=(()=>{if("undefined"==typeof window)return e=>r.noop;let e=!1;const n=new Set,t=()=>{n.forEach(e=>e())};return r=>(n.add(r),e||(e=!0,window.addEventListener("hashchange",t)),()=>{n.delete(r)})})(),l=e=>"function"==typeof e,o=()=>{throw n.noSSRError("useUrlHashState cannot be used on the server without a serverValue")};exports.unstable_useUrlHashState=function(r,n){var s;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:t,deserializer:t};const u=i.raw?t:i.serializer,c=i.raw?t:i.deserializer,d=void 0!==n?()=>u(n):o,h=e.useSyncExternalStore(a,()=>new URLSearchParams(location.hash.slice(1)).get(r),d),w=e.useMemo(()=>null===h?null!=n?n:null:c(h),[n,c,h]),S=e.useCallback(e=>{const t=location.hash,a=new URLSearchParams(t.slice(1)),o=l(e)?e(w):e;o===n||null===o?a.delete(r):a.set(r,u(o));const s=a.toString();t!==s&&(location.hash=s)},[n,w,r,u]);return[null!==(s=null!=w?w:n)&&void 0!==s?s:null,S]};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),r=require("../noop/index.js"),n=require("../no-ssr/index.js");const t=e=>e,a=(()=>{if("undefined"==typeof window)return e=>r.noop;let e=!1;const n=new Set,t=()=>{n.forEach(e=>e())};return r=>(n.add(r),e||(e=!0,window.addEventListener("hashchange",t)),()=>{n.delete(r)})})(),l=e=>"function"==typeof e,o=()=>{throw n.noSSRError("useUrlHashState cannot be used on the server without a serverValue")};exports.unstable_useUrlHashState=function(r,n){var s;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:t,deserializer:t};const u=i.raw?t:i.serializer,c=i.raw?t:i.deserializer,d=void 0!==n?()=>u(n):o,h=e.useSyncExternalStore(a,()=>new URLSearchParams(location.hash.slice(1)).get(r),d),w=e.useMemo(()=>null===h?null!=n?n:null:c(h),[n,c,h]),S=e.useCallback(e=>{const t=location.hash,a=new URLSearchParams(t.slice(1)),o=l(e)?e(w):e;o===n||null===o?a.delete(r):a.set(r,u(o));const s=a.toString();t!==s&&(location.hash=s)},[n,w,r,u]);return[(s=null!=w?w:n)!==null&&void 0!==s?s:null,S]};
1
+ "use strict";require("client-only");var e=require("react"),r=require("../noop/index.js"),n=require("../no-ssr/index.js");const t=e=>e,a=(()=>{if("undefined"==typeof window)return e=>r.noop;let e=!1;const n=new Set,t=()=>{n.forEach(e=>e())};return r=>(n.add(r),e||(e=!0,window.addEventListener("hashchange",t)),()=>{n.delete(r)})})(),l=e=>"function"==typeof e,o=()=>{throw n.noSSRError("useUrlHashState cannot be used on the server without a serverValue")};exports.unstable_useUrlHashState=function(r,n){var s;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:t,deserializer:t};const u=i.raw?t:i.serializer,c=i.raw?t:i.deserializer,d=void 0!==n?()=>u(n):o,h=e.useSyncExternalStore(a,()=>new URLSearchParams(location.hash.slice(1)).get(r),d),w=e.useMemo(()=>null===h?null!=n?n:null:c(h),[n,c,h]),S=e.useCallback(e=>{const t=location.hash,a=new URLSearchParams(t.slice(1)),o=l(e)?e(w):e;o===n||null===o?a.delete(r):a.set(r,u(o));const s=a.toString();t!==s&&(location.hash=s)},[n,w,r,u]);return[null!==(s=null!=w?w:n)&&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,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]:{serializer:a,deserializer:a};const h=c.raw?a:c.serializer,d=c.raw?a:c.deserializer,m=e(l,()=>new URLSearchParams(location.hash.slice(1)).get(r),void 0!==o?()=>h(o):i),w=t(()=>null===m?null!=o?o:null:d(m),[o,d,m]),f=n(e=>{const t=location.hash,n=new URLSearchParams(t.slice(1)),a=s(e)?e(w):e;a===o||null===a?n.delete(r):n.set(r,h(a));const l=n.toString();t!==l&&(location.hash=l)},[o,w,r,h]);return[(u=null!=w?w:o)!==null&&void 0!==u?u:null,f]}export{u as unstable_useUrlHashState};
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,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]:{serializer:a,deserializer:a};const h=c.raw?a:c.serializer,d=c.raw?a:c.deserializer,m=e(l,()=>new URLSearchParams(location.hash.slice(1)).get(r),void 0!==o?()=>h(o):i),w=t(()=>null===m?null!=o?o:null:d(m),[o,d,m]),f=n(e=>{const t=location.hash,n=new URLSearchParams(t.slice(1)),a=s(e)?e(w):e;a===o||null===a?n.delete(r):n.set(r,h(a));const l=n.toString();t!==l&&(location.hash=l)},[o,w,r,h]);return[null!==(u=null!=w?w:o)&&void 0!==u?u:null,f]}export{u as unstable_useUrlHashState};