foxact 0.2.30 → 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.
- package/create-storage-hook/index.cjs +1 -1
- package/create-storage-hook/index.js +1 -1
- package/create-storage-hook/index.mjs +1 -1
- package/package.json +94 -86
- package/sizes.json +1 -1
- package/use-next-link/index.cjs +1 -0
- package/use-next-link/index.d.ts +16 -0
- package/use-next-link/index.js +1 -0
- package/use-next-link/index.mjs +1 -0
- 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 +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)
|
|
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)
|
|
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)
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.2.
|
|
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": {
|
|
@@ -157,14 +156,14 @@
|
|
|
157
156
|
"require": "./use-set/index.cjs",
|
|
158
157
|
"default": "./use-set/index.js"
|
|
159
158
|
},
|
|
160
|
-
"./use
|
|
161
|
-
"types": "./use
|
|
159
|
+
"./use": {
|
|
160
|
+
"types": "./use/index.d.ts",
|
|
162
161
|
"import": {
|
|
163
|
-
"types": "./use
|
|
164
|
-
"default": "./use
|
|
162
|
+
"types": "./use/index.d.ts",
|
|
163
|
+
"default": "./use/index.mjs"
|
|
165
164
|
},
|
|
166
|
-
"require": "./use
|
|
167
|
-
"default": "./use
|
|
165
|
+
"require": "./use/index.cjs",
|
|
166
|
+
"default": "./use/index.js"
|
|
168
167
|
},
|
|
169
168
|
"./typescript-happy-forward-ref": {
|
|
170
169
|
"types": "./typescript-happy-forward-ref/index.d.ts",
|
|
@@ -175,14 +174,14 @@
|
|
|
175
174
|
"require": "./typescript-happy-forward-ref/index.cjs",
|
|
176
175
|
"default": "./typescript-happy-forward-ref/index.js"
|
|
177
176
|
},
|
|
178
|
-
"./use": {
|
|
179
|
-
"types": "./use/index.d.ts",
|
|
177
|
+
"./use-map": {
|
|
178
|
+
"types": "./use-map/index.d.ts",
|
|
180
179
|
"import": {
|
|
181
|
-
"types": "./use/index.d.ts",
|
|
182
|
-
"default": "./use/index.mjs"
|
|
180
|
+
"types": "./use-map/index.d.ts",
|
|
181
|
+
"default": "./use-map/index.mjs"
|
|
183
182
|
},
|
|
184
|
-
"require": "./use/index.cjs",
|
|
185
|
-
"default": "./use/index.js"
|
|
183
|
+
"require": "./use-map/index.cjs",
|
|
184
|
+
"default": "./use-map/index.js"
|
|
186
185
|
},
|
|
187
186
|
"./compose-context-provider": {
|
|
188
187
|
"types": "./compose-context-provider/index.d.ts",
|
|
@@ -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,23 +201,14 @@
|
|
|
211
201
|
"require": "./request-idle-callback/index.cjs",
|
|
212
202
|
"default": "./request-idle-callback/index.js"
|
|
213
203
|
},
|
|
214
|
-
"./use-
|
|
215
|
-
"types": "./use-
|
|
216
|
-
"import": {
|
|
217
|
-
"types": "./use-singleton/index.d.ts",
|
|
218
|
-
"default": "./use-singleton/index.mjs"
|
|
219
|
-
},
|
|
220
|
-
"require": "./use-singleton/index.cjs",
|
|
221
|
-
"default": "./use-singleton/index.js"
|
|
222
|
-
},
|
|
223
|
-
"./no-ssr": {
|
|
224
|
-
"types": "./no-ssr/index.d.ts",
|
|
204
|
+
"./use-react-router-is-match": {
|
|
205
|
+
"types": "./use-react-router-is-match/index.d.ts",
|
|
225
206
|
"import": {
|
|
226
|
-
"types": "./
|
|
227
|
-
"default": "./
|
|
207
|
+
"types": "./use-react-router-is-match/index.d.ts",
|
|
208
|
+
"default": "./use-react-router-is-match/index.mjs"
|
|
228
209
|
},
|
|
229
|
-
"require": "./
|
|
230
|
-
"default": "./
|
|
210
|
+
"require": "./use-react-router-is-match/index.cjs",
|
|
211
|
+
"default": "./use-react-router-is-match/index.js"
|
|
231
212
|
},
|
|
232
213
|
"./use-intersection": {
|
|
233
214
|
"types": "./use-intersection/index.d.ts",
|
|
@@ -247,14 +228,14 @@
|
|
|
247
228
|
"require": "./current-year/index.cjs",
|
|
248
229
|
"default": "./current-year/index.js"
|
|
249
230
|
},
|
|
250
|
-
"./
|
|
251
|
-
"types": "./
|
|
231
|
+
"./no-ssr": {
|
|
232
|
+
"types": "./no-ssr/index.d.ts",
|
|
252
233
|
"import": {
|
|
253
|
-
"types": "./
|
|
254
|
-
"default": "./
|
|
234
|
+
"types": "./no-ssr/index.d.ts",
|
|
235
|
+
"default": "./no-ssr/index.mjs"
|
|
255
236
|
},
|
|
256
|
-
"require": "./
|
|
257
|
-
"default": "./
|
|
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
|
-
"./
|
|
269
|
-
"types": "./
|
|
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-composition-input": {
|
|
278
|
-
"types": "./use-composition-input/index.d.ts",
|
|
249
|
+
"./create-fixed-array": {
|
|
250
|
+
"types": "./create-fixed-array/index.d.ts",
|
|
279
251
|
"import": {
|
|
280
|
-
"types": "./
|
|
281
|
-
"default": "./
|
|
252
|
+
"types": "./create-fixed-array/index.d.ts",
|
|
253
|
+
"default": "./create-fixed-array/index.mjs"
|
|
282
254
|
},
|
|
283
|
-
"require": "./
|
|
284
|
-
"default": "./
|
|
255
|
+
"require": "./create-fixed-array/index.cjs",
|
|
256
|
+
"default": "./create-fixed-array/index.js"
|
|
285
257
|
},
|
|
286
|
-
"./use-
|
|
287
|
-
"types": "./use-
|
|
258
|
+
"./use-singleton": {
|
|
259
|
+
"types": "./use-singleton/index.d.ts",
|
|
288
260
|
"import": {
|
|
289
|
-
"types": "./use-
|
|
290
|
-
"default": "./use-
|
|
261
|
+
"types": "./use-singleton/index.d.ts",
|
|
262
|
+
"default": "./use-singleton/index.mjs"
|
|
291
263
|
},
|
|
292
|
-
"require": "./use-
|
|
293
|
-
"default": "./use-
|
|
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": {
|
|
@@ -310,15 +291,6 @@
|
|
|
310
291
|
"require": "./invariant/index.cjs",
|
|
311
292
|
"default": "./invariant/index.js"
|
|
312
293
|
},
|
|
313
|
-
"./create-storage-hook": {
|
|
314
|
-
"types": "./create-storage-hook/index.d.ts",
|
|
315
|
-
"import": {
|
|
316
|
-
"types": "./create-storage-hook/index.d.ts",
|
|
317
|
-
"default": "./create-storage-hook/index.mjs"
|
|
318
|
-
},
|
|
319
|
-
"require": "./create-storage-hook/index.cjs",
|
|
320
|
-
"default": "./create-storage-hook/index.js"
|
|
321
|
-
},
|
|
322
294
|
"./use-debounced-value": {
|
|
323
295
|
"types": "./use-debounced-value/index.d.ts",
|
|
324
296
|
"import": {
|
|
@@ -337,6 +309,15 @@
|
|
|
337
309
|
"require": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs",
|
|
338
310
|
"default": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.js"
|
|
339
311
|
},
|
|
312
|
+
"./context-state": {
|
|
313
|
+
"types": "./context-state/index.d.ts",
|
|
314
|
+
"import": {
|
|
315
|
+
"types": "./context-state/index.d.ts",
|
|
316
|
+
"default": "./context-state/index.mjs"
|
|
317
|
+
},
|
|
318
|
+
"require": "./context-state/index.cjs",
|
|
319
|
+
"default": "./context-state/index.js"
|
|
320
|
+
},
|
|
340
321
|
"./use-local-storage": {
|
|
341
322
|
"types": "./use-local-storage/index.d.ts",
|
|
342
323
|
"import": {
|
|
@@ -346,14 +327,23 @@
|
|
|
346
327
|
"require": "./use-local-storage/index.cjs",
|
|
347
328
|
"default": "./use-local-storage/index.js"
|
|
348
329
|
},
|
|
349
|
-
"./
|
|
350
|
-
"types": "./
|
|
330
|
+
"./use-next-link": {
|
|
331
|
+
"types": "./use-next-link/index.d.ts",
|
|
351
332
|
"import": {
|
|
352
|
-
"types": "./
|
|
353
|
-
"default": "./
|
|
333
|
+
"types": "./use-next-link/index.d.ts",
|
|
334
|
+
"default": "./use-next-link/index.mjs"
|
|
354
335
|
},
|
|
355
|
-
"require": "./
|
|
356
|
-
"default": "./
|
|
336
|
+
"require": "./use-next-link/index.cjs",
|
|
337
|
+
"default": "./use-next-link/index.js"
|
|
338
|
+
},
|
|
339
|
+
"./use-isomorphic-layout-effect": {
|
|
340
|
+
"types": "./use-isomorphic-layout-effect/index.d.ts",
|
|
341
|
+
"import": {
|
|
342
|
+
"types": "./use-isomorphic-layout-effect/index.d.ts",
|
|
343
|
+
"default": "./use-isomorphic-layout-effect/index.mjs"
|
|
344
|
+
},
|
|
345
|
+
"require": "./use-isomorphic-layout-effect/index.cjs",
|
|
346
|
+
"default": "./use-isomorphic-layout-effect/index.js"
|
|
357
347
|
},
|
|
358
348
|
"./create-context-state": {
|
|
359
349
|
"types": "./create-context-state/index.d.ts",
|
|
@@ -373,14 +363,32 @@
|
|
|
373
363
|
"require": "./use-array/index.cjs",
|
|
374
364
|
"default": "./use-array/index.js"
|
|
375
365
|
},
|
|
376
|
-
"./use-
|
|
377
|
-
"types": "./use-
|
|
366
|
+
"./use-react-router-enable-concurrent-navigation": {
|
|
367
|
+
"types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
|
|
378
368
|
"import": {
|
|
379
|
-
"types": "./use-
|
|
380
|
-
"default": "./use-
|
|
369
|
+
"types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
|
|
370
|
+
"default": "./use-react-router-enable-concurrent-navigation/index.mjs"
|
|
381
371
|
},
|
|
382
|
-
"require": "./use-
|
|
383
|
-
"default": "./use-
|
|
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":
|
|
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)
|
|
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)
|
|
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)
|
|
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};
|