foxact 0.2.27 → 0.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/create-storage-hook/index.cjs +1 -1
  2. package/create-storage-hook/index.js +1 -1
  3. package/create-storage-hook/index.mjs +1 -1
  4. package/invariant/index.cjs +1 -0
  5. package/invariant/index.d.ts +4 -0
  6. package/invariant/index.js +1 -0
  7. package/invariant/index.mjs +1 -0
  8. package/nullthrow/index.cjs +1 -0
  9. package/nullthrow/index.d.ts +4 -0
  10. package/nullthrow/index.js +1 -0
  11. package/nullthrow/index.mjs +1 -0
  12. package/package.json +191 -172
  13. package/sizes.json +1 -1
  14. package/use/index.cjs +1 -1
  15. package/use/index.js +1 -1
  16. package/use-array/index.cjs +1 -1
  17. package/use-array/index.js +1 -1
  18. package/use-array/index.mjs +1 -1
  19. package/use-clipboard/index.cjs +1 -1
  20. package/use-clipboard/index.js +1 -1
  21. package/use-clipboard/index.mjs +1 -1
  22. package/use-debounced-state/index.cjs +1 -1
  23. package/use-debounced-state/index.js +1 -1
  24. package/use-debounced-state/index.mjs +1 -1
  25. package/use-intersection/index.cjs +1 -1
  26. package/use-intersection/index.js +1 -1
  27. package/use-intersection/index.mjs +1 -1
  28. package/use-isomorphic-layout-effect/index.d.ts +3 -3
  29. package/use-map/index.cjs +1 -1
  30. package/use-map/index.js +1 -1
  31. package/use-map/index.mjs +1 -1
  32. package/use-set/index.cjs +1 -1
  33. package/use-set/index.js +1 -1
  34. package/use-set/index.mjs +1 -1
  35. package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs +1 -1
  36. package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.js +1 -1
  37. package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs +1 -1
  38. package/use-uncontrolled/index.cjs +1 -1
  39. package/use-uncontrolled/index.js +1 -1
  40. package/use-uncontrolled/index.mjs +1 -1
  41. package/use-url-hash-state/index.cjs +1 -1
  42. package/use-url-hash-state/index.d.ts +13 -3
  43. package/use-url-hash-state/index.js +1 -1
  44. 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"),n=require("../use-isomorphic-layout-effect/index.cjs"),t=require("../no-ssr/index.cjs");const r=e=>"function"==typeof e,i=e=>e,a=()=>{throw t.noSSRError("useLocalStorage cannot be used on the server without a serverValue")};exports.createStorage=function(t){const l="localStorage"===t?"foxact-local-storage":"foxact-session-storage",c="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))}:o.noop,s="undefined"!=typeof window?(e,o)=>{try{window[t].setItem(e,o)}catch(e){console.warn("[foxact] Failed to set value to ".concat(t,", it might be blocked"))}finally{c(e)}}:o.noop,u="undefined"!=typeof window?e=>{try{window[t].removeItem(e)}catch(e){console.warn("[foxact] Failed to remove value from ".concat(t,", it might be blocked"))}finally{c(e)}}:o.noop,d=e=>{if("undefined"==typeof window)return null;try{return window[t].getItem(e)}catch(e){return console.warn("[foxact] Failed to get value from ".concat(t,", it might be blocked")),null}};return{useStorage:function(t,c){var w;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 n=o=>{"key"in o&&o.key!==t||e()},r=o=>{o.detail===t&&e()};return window.addEventListener("storage",n),window.addEventListener(l,r),()=>{window.removeEventListener("storage",n),window.removeEventListener(l,r)}},[t]),y=f.raw?i:f.serializer,g=f.raw?i:f.deserializer,m=void 0!==c?()=>y(c):a,p=e.useSyncExternalStore(v,()=>d(t),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?u(t):s(t,y(o))}catch(e){console.warn(e)}},[t,y,h]);return n.useIsomorphicLayoutEffect(()=>{null===d(t)&&void 0!==c&&s(t,y(c))},[g,t,y,c]),[null!==(w=null!=h?h:c)&&void 0!==w?w:null,S]},useSetStorage:(o,n)=>e.useCallback(e=>{try{null===e?u(o):s(o,n(e))}catch(e){console.warn(e)}},[o,n])}};
1
+ "use strict";require("client-only");var e=require("react"),o=require("../noop/index.cjs"),n=require("../use-isomorphic-layout-effect/index.cjs"),t=require("../no-ssr/index.cjs");const r=e=>"function"==typeof e,i=e=>e,a=()=>{throw t.noSSRError("useLocalStorage cannot be used on the server without a serverValue")};exports.createStorage=function(t){const l="localStorage"===t?"foxact-local-storage":"foxact-session-storage",c="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))}:o.noop,s="undefined"!=typeof window?(e,o)=>{try{window[t].setItem(e,o)}catch(e){console.warn("[foxact] Failed to set value to ".concat(t,", it might be blocked"))}finally{c(e)}}:o.noop,u="undefined"!=typeof window?e=>{try{window[t].removeItem(e)}catch(e){console.warn("[foxact] Failed to remove value from ".concat(t,", it might be blocked"))}finally{c(e)}}:o.noop,d=e=>{if("undefined"==typeof window)return null;try{return window[t].getItem(e)}catch(e){return console.warn("[foxact] Failed to get value from ".concat(t,", it might be blocked")),null}};return{useStorage:function(t,c){var w;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 n=o=>{"key"in o&&o.key!==t||e()},r=o=>{o.detail===t&&e()};return window.addEventListener("storage",n),window.addEventListener(l,r),()=>{window.removeEventListener("storage",n),window.removeEventListener(l,r)}},[t]),y=f.raw?i:f.serializer,g=f.raw?i:f.deserializer,m=void 0!==c?()=>y(c):a,p=e.useSyncExternalStore(v,()=>d(t),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?u(t):s(t,y(o))}catch(e){console.warn(e)}},[t,y,h]);return n.useIsomorphicLayoutEffect(()=>{null===d(t)&&void 0!==c&&s(t,y(c))},[g,t,y,c]),[(w=null!=h?h:c)!==null&&void 0!==w?w:null,S]},useSetStorage:(o,n)=>e.useCallback(e=>{try{null===e?u(o):s(o,n(e))}catch(e){console.warn(e)}},[o,n])}};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),o=require("../noop/index.js"),n=require("../use-isomorphic-layout-effect/index.js"),t=require("../no-ssr/index.js");const r=e=>"function"==typeof e,i=e=>e,a=()=>{throw t.noSSRError("useLocalStorage cannot be used on the server without a serverValue")};exports.createStorage=function(t){const l="localStorage"===t?"foxact-local-storage":"foxact-session-storage",c="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))}:o.noop,s="undefined"!=typeof window?(e,o)=>{try{window[t].setItem(e,o)}catch(e){console.warn("[foxact] Failed to set value to ".concat(t,", it might be blocked"))}finally{c(e)}}:o.noop,u="undefined"!=typeof window?e=>{try{window[t].removeItem(e)}catch(e){console.warn("[foxact] Failed to remove value from ".concat(t,", it might be blocked"))}finally{c(e)}}:o.noop,d=e=>{if("undefined"==typeof window)return null;try{return window[t].getItem(e)}catch(e){return console.warn("[foxact] Failed to get value from ".concat(t,", it might be blocked")),null}};return{useStorage:function(t,c){var w;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 n=o=>{"key"in o&&o.key!==t||e()},r=o=>{o.detail===t&&e()};return window.addEventListener("storage",n),window.addEventListener(l,r),()=>{window.removeEventListener("storage",n),window.removeEventListener(l,r)}},[t]),y=f.raw?i:f.serializer,g=f.raw?i:f.deserializer,m=void 0!==c?()=>y(c):a,p=e.useSyncExternalStore(v,()=>d(t),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?u(t):s(t,y(o))}catch(e){console.warn(e)}},[t,y,h]);return n.useIsomorphicLayoutEffect(()=>{null===d(t)&&void 0!==c&&s(t,y(c))},[g,t,y,c]),[null!==(w=null!=h?h:c)&&void 0!==w?w:null,S]},useSetStorage:(o,n)=>e.useCallback(e=>{try{null===e?u(o):s(o,n(e))}catch(e){console.warn(e)}},[o,n])}};
1
+ "use strict";require("client-only");var e=require("react"),o=require("../noop/index.js"),n=require("../use-isomorphic-layout-effect/index.js"),t=require("../no-ssr/index.js");const r=e=>"function"==typeof e,i=e=>e,a=()=>{throw t.noSSRError("useLocalStorage cannot be used on the server without a serverValue")};exports.createStorage=function(t){const l="localStorage"===t?"foxact-local-storage":"foxact-session-storage",c="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))}:o.noop,s="undefined"!=typeof window?(e,o)=>{try{window[t].setItem(e,o)}catch(e){console.warn("[foxact] Failed to set value to ".concat(t,", it might be blocked"))}finally{c(e)}}:o.noop,u="undefined"!=typeof window?e=>{try{window[t].removeItem(e)}catch(e){console.warn("[foxact] Failed to remove value from ".concat(t,", it might be blocked"))}finally{c(e)}}:o.noop,d=e=>{if("undefined"==typeof window)return null;try{return window[t].getItem(e)}catch(e){return console.warn("[foxact] Failed to get value from ".concat(t,", it might be blocked")),null}};return{useStorage:function(t,c){var w;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 n=o=>{"key"in o&&o.key!==t||e()},r=o=>{o.detail===t&&e()};return window.addEventListener("storage",n),window.addEventListener(l,r),()=>{window.removeEventListener("storage",n),window.removeEventListener(l,r)}},[t]),y=f.raw?i:f.serializer,g=f.raw?i:f.deserializer,m=void 0!==c?()=>y(c):a,p=e.useSyncExternalStore(v,()=>d(t),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?u(t):s(t,y(o))}catch(e){console.warn(e)}},[t,y,h]);return n.useIsomorphicLayoutEffect(()=>{null===d(t)&&void 0!==c&&s(t,y(c))},[g,t,y,c]),[(w=null!=h?h:c)!==null&&void 0!==w?w:null,S]},useSetStorage:(o,n)=>e.useCallback(e=>{try{null===e?u(o):s(o,n(e))}catch(e){console.warn(e)}},[o,n])}};
@@ -1 +1 @@
1
- import"client-only";import{useCallback as e,useSyncExternalStore as t,useMemo as o}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 l=e=>"function"==typeof e,a=e=>e,c=()=>{throw i("useLocalStorage cannot be used on the server without a serverValue")};function d(i){const d="localStorage"===i?"foxact-local-storage":"foxact-session-storage",s="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(d,{detail:e}))}:n,u="undefined"!=typeof window?(e,t)=>{try{window[i].setItem(e,t)}catch(e){console.warn("[foxact] Failed to set value to ".concat(i,", it might be blocked"))}finally{s(e)}}:n,w="undefined"!=typeof window?e=>{try{window[i].removeItem(e)}catch(e){console.warn("[foxact] Failed to remove value from ".concat(i,", it might be blocked"))}finally{s(e)}}:n,f=e=>{if("undefined"==typeof window)return null;try{return window[i].getItem(e)}catch(e){return console.warn("[foxact] Failed to get value from ".concat(i,", it might be blocked")),null}};return{useStorage:function(i,s){var m;let v=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const y=e(e=>{if("undefined"==typeof window)return n;const t=t=>{"key"in t&&t.key!==i||e()},o=t=>{t.detail===i&&e()};return window.addEventListener("storage",t),window.addEventListener(d,o),()=>{window.removeEventListener("storage",t),window.removeEventListener(d,o)}},[i]),g=v.raw?a:v.serializer,p=v.raw?a:v.deserializer,h=void 0!==s?()=>g(s):c,x=t(y,()=>f(i),h),S=o(()=>null===x?null:p(x),[x,p]),b=e(e=>{try{const t=l(e)?e(null!=S?S:null):e;null===t?w(i):u(i,g(t))}catch(e){console.warn(e)}},[i,g,S]);return r(()=>{null===f(i)&&void 0!==s&&u(i,g(s))},[p,i,g,s]),[null!==(m=null!=S?S:s)&&void 0!==m?m:null,b]},useSetStorage:(t,o)=>e(e=>{try{null===e?w(t):u(t,o(e))}catch(e){console.warn(e)}},[t,o])}}export{d as createStorage};
1
+ import"client-only";import{useCallback as e,useSyncExternalStore as t,useMemo as o}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 l=e=>"function"==typeof e,a=e=>e,c=()=>{throw i("useLocalStorage cannot be used on the server without a serverValue")};function d(i){const d="localStorage"===i?"foxact-local-storage":"foxact-session-storage",s="undefined"!=typeof window?e=>{window.dispatchEvent(new CustomEvent(d,{detail:e}))}:n,u="undefined"!=typeof window?(e,t)=>{try{window[i].setItem(e,t)}catch(e){console.warn("[foxact] Failed to set value to ".concat(i,", it might be blocked"))}finally{s(e)}}:n,w="undefined"!=typeof window?e=>{try{window[i].removeItem(e)}catch(e){console.warn("[foxact] Failed to remove value from ".concat(i,", it might be blocked"))}finally{s(e)}}:n,f=e=>{if("undefined"==typeof window)return null;try{return window[i].getItem(e)}catch(e){return console.warn("[foxact] Failed to get value from ".concat(i,", it might be blocked")),null}};return{useStorage:function(i,s){var m;let v=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const y=e(e=>{if("undefined"==typeof window)return n;const t=t=>{"key"in t&&t.key!==i||e()},o=t=>{t.detail===i&&e()};return window.addEventListener("storage",t),window.addEventListener(d,o),()=>{window.removeEventListener("storage",t),window.removeEventListener(d,o)}},[i]),g=v.raw?a:v.serializer,p=v.raw?a:v.deserializer,h=t(y,()=>f(i),void 0!==s?()=>g(s):c),x=o(()=>null===h?null:p(h),[h,p]),S=e(e=>{try{const t=l(e)?e(null!=x?x:null):e;null===t?w(i):u(i,g(t))}catch(e){console.warn(e)}},[i,g,x]);return r(()=>{null===f(i)&&void 0!==s&&u(i,g(s))},[p,i,g,s]),[(m=null!=x?x:s)!==null&&void 0!==m?m:null,S]},useSetStorage:(t,o)=>e(e=>{try{null===e?w(t):u(t,o(e))}catch(e){console.warn(e)}},[t,o])}}export{d as createStorage};
@@ -0,0 +1 @@
1
+ "use strict";exports.invariant=function(n){if(null==n)throw Error("Value is null or undefined")};
@@ -0,0 +1,4 @@
1
+ /** @see https://foxact.skk.moe/invariant-nullthrow */
2
+ declare function invariant<T>(value: T): asserts value is NonNullable<T>;
3
+
4
+ export { invariant };
@@ -0,0 +1 @@
1
+ "use strict";exports.invariant=function(n){if(null==n)throw Error("Value is null or undefined")};
@@ -0,0 +1 @@
1
+ function n(n){if(null==n)throw Error("Value is null or undefined")}export{n as invariant};
@@ -0,0 +1 @@
1
+ "use strict";exports.nullthrow=function(r){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Value is null or undefined";if(null==r)throw Error(l);return r};
@@ -0,0 +1,4 @@
1
+ /** @see https://foxact.skk.moe/invariant-nullthrow */
2
+ declare const nullthrow: <T>(value: T, message?: string) => NonNullable<T>;
3
+
4
+ export { nullthrow };
@@ -0,0 +1 @@
1
+ "use strict";exports.nullthrow=function(r){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Value is null or undefined";if(null==r)throw Error(l);return r};
@@ -0,0 +1 @@
1
+ const n=function(n){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Value is null or undefined";if(null==n)throw Error(l);return n};export{n as nullthrow};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxact",
3
- "version": "0.2.27",
3
+ "version": "0.2.28",
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,6 +22,7 @@
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
24
  "client-only": "^0.0.1",
25
+ "rollup-preserve-directives": "^1.1.0",
25
26
  "server-only": "^0.0.1"
26
27
  },
27
28
  "peerDependencies": {
@@ -65,59 +66,41 @@
65
66
  "exports": {
66
67
  "./package.json": "./package.json",
67
68
  "./sizes.json": "./sizes.json",
68
- "./compose-context-provider": {
69
- "types": "./compose-context-provider/index.d.ts",
70
- "import": {
71
- "types": "./compose-context-provider/index.d.ts",
72
- "default": "./compose-context-provider/index.mjs"
73
- },
74
- "require": "./compose-context-provider/index.cjs",
75
- "default": "./compose-context-provider/index.js"
76
- },
77
- "./context-state": {
78
- "types": "./context-state/index.d.ts",
69
+ "./nullthrow": {
70
+ "types": "./nullthrow/index.d.ts",
79
71
  "import": {
80
- "types": "./context-state/index.d.ts",
81
- "default": "./context-state/index.mjs"
82
- },
83
- "require": "./context-state/index.cjs",
84
- "default": "./context-state/index.js"
85
- },
86
- "./create-fixed-array": {
87
- "types": "./create-fixed-array/index.d.ts",
88
- "import": {
89
- "types": "./create-fixed-array/index.d.ts",
90
- "default": "./create-fixed-array/index.mjs"
72
+ "types": "./nullthrow/index.d.ts",
73
+ "default": "./nullthrow/index.mjs"
91
74
  },
92
- "require": "./create-fixed-array/index.cjs",
93
- "default": "./create-fixed-array/index.js"
75
+ "require": "./nullthrow/index.cjs",
76
+ "default": "./nullthrow/index.js"
94
77
  },
95
- "./create-context-state": {
96
- "types": "./create-context-state/index.d.ts",
78
+ "./use-uncontrolled": {
79
+ "types": "./use-uncontrolled/index.d.ts",
97
80
  "import": {
98
- "types": "./create-context-state/index.d.ts",
99
- "default": "./create-context-state/index.mjs"
81
+ "types": "./use-uncontrolled/index.d.ts",
82
+ "default": "./use-uncontrolled/index.mjs"
100
83
  },
101
- "require": "./create-context-state/index.cjs",
102
- "default": "./create-context-state/index.js"
84
+ "require": "./use-uncontrolled/index.cjs",
85
+ "default": "./use-uncontrolled/index.js"
103
86
  },
104
- "./create-storage-hook": {
105
- "types": "./create-storage-hook/index.d.ts",
87
+ "./use-retimer": {
88
+ "types": "./use-retimer/index.d.ts",
106
89
  "import": {
107
- "types": "./create-storage-hook/index.d.ts",
108
- "default": "./create-storage-hook/index.mjs"
90
+ "types": "./use-retimer/index.d.ts",
91
+ "default": "./use-retimer/index.mjs"
109
92
  },
110
- "require": "./create-storage-hook/index.cjs",
111
- "default": "./create-storage-hook/index.js"
93
+ "require": "./use-retimer/index.cjs",
94
+ "default": "./use-retimer/index.js"
112
95
  },
113
- "./noop": {
114
- "types": "./noop/index.d.ts",
96
+ "./use-error-boundary": {
97
+ "types": "./use-error-boundary/index.d.ts",
115
98
  "import": {
116
- "types": "./noop/index.d.ts",
117
- "default": "./noop/index.mjs"
99
+ "types": "./use-error-boundary/index.d.ts",
100
+ "default": "./use-error-boundary/index.mjs"
118
101
  },
119
- "require": "./noop/index.cjs",
120
- "default": "./noop/index.js"
102
+ "require": "./use-error-boundary/index.cjs",
103
+ "default": "./use-error-boundary/index.js"
121
104
  },
122
105
  "./rem": {
123
106
  "types": "./rem/index.d.ts",
@@ -128,32 +111,59 @@
128
111
  "require": "./rem/index.cjs",
129
112
  "default": "./rem/index.js"
130
113
  },
131
- "./no-ssr": {
132
- "types": "./no-ssr/index.d.ts",
114
+ "./use-url-hash-state": {
115
+ "types": "./use-url-hash-state/index.d.ts",
133
116
  "import": {
134
- "types": "./no-ssr/index.d.ts",
135
- "default": "./no-ssr/index.mjs"
117
+ "types": "./use-url-hash-state/index.d.ts",
118
+ "default": "./use-url-hash-state/index.mjs"
136
119
  },
137
- "require": "./no-ssr/index.cjs",
138
- "default": "./no-ssr/index.js"
120
+ "require": "./use-url-hash-state/index.cjs",
121
+ "default": "./use-url-hash-state/index.js"
139
122
  },
140
- "./request-idle-callback": {
141
- "types": "./request-idle-callback/index.d.ts",
123
+ "./use-is-client": {
124
+ "types": "./use-is-client/index.d.ts",
142
125
  "import": {
143
- "types": "./request-idle-callback/index.d.ts",
144
- "default": "./request-idle-callback/index.mjs"
126
+ "types": "./use-is-client/index.d.ts",
127
+ "default": "./use-is-client/index.mjs"
145
128
  },
146
- "require": "./request-idle-callback/index.cjs",
147
- "default": "./request-idle-callback/index.js"
129
+ "require": "./use-is-client/index.cjs",
130
+ "default": "./use-is-client/index.js"
148
131
  },
149
- "./typescript-happy-forward-ref": {
150
- "types": "./typescript-happy-forward-ref/index.d.ts",
132
+ "./use-debounced-state": {
133
+ "types": "./use-debounced-state/index.d.ts",
151
134
  "import": {
152
- "types": "./typescript-happy-forward-ref/index.d.ts",
153
- "default": "./typescript-happy-forward-ref/index.mjs"
135
+ "types": "./use-debounced-state/index.d.ts",
136
+ "default": "./use-debounced-state/index.mjs"
154
137
  },
155
- "require": "./typescript-happy-forward-ref/index.cjs",
156
- "default": "./typescript-happy-forward-ref/index.js"
138
+ "require": "./use-debounced-state/index.cjs",
139
+ "default": "./use-debounced-state/index.js"
140
+ },
141
+ "./noop": {
142
+ "types": "./noop/index.d.ts",
143
+ "import": {
144
+ "types": "./noop/index.d.ts",
145
+ "default": "./noop/index.mjs"
146
+ },
147
+ "require": "./noop/index.cjs",
148
+ "default": "./noop/index.js"
149
+ },
150
+ "./use-set": {
151
+ "types": "./use-set/index.d.ts",
152
+ "import": {
153
+ "types": "./use-set/index.d.ts",
154
+ "default": "./use-set/index.mjs"
155
+ },
156
+ "require": "./use-set/index.cjs",
157
+ "default": "./use-set/index.js"
158
+ },
159
+ "./use-map": {
160
+ "types": "./use-map/index.d.ts",
161
+ "import": {
162
+ "types": "./use-map/index.d.ts",
163
+ "default": "./use-map/index.mjs"
164
+ },
165
+ "require": "./use-map/index.cjs",
166
+ "default": "./use-map/index.js"
157
167
  },
158
168
  "./use": {
159
169
  "types": "./use/index.d.ts",
@@ -164,59 +174,50 @@
164
174
  "require": "./use/index.cjs",
165
175
  "default": "./use/index.js"
166
176
  },
167
- "./use-array": {
168
- "types": "./use-array/index.d.ts",
169
- "import": {
170
- "types": "./use-array/index.d.ts",
171
- "default": "./use-array/index.mjs"
172
- },
173
- "require": "./use-array/index.cjs",
174
- "default": "./use-array/index.js"
175
- },
176
- "./use-clipboard": {
177
- "types": "./use-clipboard/index.d.ts",
177
+ "./typescript-happy-forward-ref": {
178
+ "types": "./typescript-happy-forward-ref/index.d.ts",
178
179
  "import": {
179
- "types": "./use-clipboard/index.d.ts",
180
- "default": "./use-clipboard/index.mjs"
180
+ "types": "./typescript-happy-forward-ref/index.d.ts",
181
+ "default": "./typescript-happy-forward-ref/index.mjs"
181
182
  },
182
- "require": "./use-clipboard/index.cjs",
183
- "default": "./use-clipboard/index.js"
183
+ "require": "./typescript-happy-forward-ref/index.cjs",
184
+ "default": "./typescript-happy-forward-ref/index.js"
184
185
  },
185
- "./use-composition-input": {
186
- "types": "./use-composition-input/index.d.ts",
186
+ "./compose-context-provider": {
187
+ "types": "./compose-context-provider/index.d.ts",
187
188
  "import": {
188
- "types": "./use-composition-input/index.d.ts",
189
- "default": "./use-composition-input/index.mjs"
189
+ "types": "./compose-context-provider/index.d.ts",
190
+ "default": "./compose-context-provider/index.mjs"
190
191
  },
191
- "require": "./use-composition-input/index.cjs",
192
- "default": "./use-composition-input/index.js"
192
+ "require": "./compose-context-provider/index.cjs",
193
+ "default": "./compose-context-provider/index.js"
193
194
  },
194
- "./use-debounced-state": {
195
- "types": "./use-debounced-state/index.d.ts",
195
+ "./use-react-router-is-match": {
196
+ "types": "./use-react-router-is-match/index.d.ts",
196
197
  "import": {
197
- "types": "./use-debounced-state/index.d.ts",
198
- "default": "./use-debounced-state/index.mjs"
198
+ "types": "./use-react-router-is-match/index.d.ts",
199
+ "default": "./use-react-router-is-match/index.mjs"
199
200
  },
200
- "require": "./use-debounced-state/index.cjs",
201
- "default": "./use-debounced-state/index.js"
201
+ "require": "./use-react-router-is-match/index.cjs",
202
+ "default": "./use-react-router-is-match/index.js"
202
203
  },
203
- "./use-debounced-value": {
204
- "types": "./use-debounced-value/index.d.ts",
204
+ "./request-idle-callback": {
205
+ "types": "./request-idle-callback/index.d.ts",
205
206
  "import": {
206
- "types": "./use-debounced-value/index.d.ts",
207
- "default": "./use-debounced-value/index.mjs"
207
+ "types": "./request-idle-callback/index.d.ts",
208
+ "default": "./request-idle-callback/index.mjs"
208
209
  },
209
- "require": "./use-debounced-value/index.cjs",
210
- "default": "./use-debounced-value/index.js"
210
+ "require": "./request-idle-callback/index.cjs",
211
+ "default": "./request-idle-callback/index.js"
211
212
  },
212
- "./use-error-boundary": {
213
- "types": "./use-error-boundary/index.d.ts",
213
+ "./use-singleton": {
214
+ "types": "./use-singleton/index.d.ts",
214
215
  "import": {
215
- "types": "./use-error-boundary/index.d.ts",
216
- "default": "./use-error-boundary/index.mjs"
216
+ "types": "./use-singleton/index.d.ts",
217
+ "default": "./use-singleton/index.mjs"
217
218
  },
218
- "require": "./use-error-boundary/index.cjs",
219
- "default": "./use-error-boundary/index.js"
219
+ "require": "./use-singleton/index.cjs",
220
+ "default": "./use-singleton/index.js"
220
221
  },
221
222
  "./use-intersection": {
222
223
  "types": "./use-intersection/index.d.ts",
@@ -227,50 +228,32 @@
227
228
  "require": "./use-intersection/index.cjs",
228
229
  "default": "./use-intersection/index.js"
229
230
  },
230
- "./use-is-client": {
231
- "types": "./use-is-client/index.d.ts",
232
- "import": {
233
- "types": "./use-is-client/index.d.ts",
234
- "default": "./use-is-client/index.mjs"
235
- },
236
- "require": "./use-is-client/index.cjs",
237
- "default": "./use-is-client/index.js"
238
- },
239
- "./use-local-storage": {
240
- "types": "./use-local-storage/index.d.ts",
241
- "import": {
242
- "types": "./use-local-storage/index.d.ts",
243
- "default": "./use-local-storage/index.mjs"
244
- },
245
- "require": "./use-local-storage/index.cjs",
246
- "default": "./use-local-storage/index.js"
247
- },
248
- "./use-isomorphic-layout-effect": {
249
- "types": "./use-isomorphic-layout-effect/index.d.ts",
231
+ "./no-ssr": {
232
+ "types": "./no-ssr/index.d.ts",
250
233
  "import": {
251
- "types": "./use-isomorphic-layout-effect/index.d.ts",
252
- "default": "./use-isomorphic-layout-effect/index.mjs"
234
+ "types": "./no-ssr/index.d.ts",
235
+ "default": "./no-ssr/index.mjs"
253
236
  },
254
- "require": "./use-isomorphic-layout-effect/index.cjs",
255
- "default": "./use-isomorphic-layout-effect/index.js"
237
+ "require": "./no-ssr/index.cjs",
238
+ "default": "./no-ssr/index.js"
256
239
  },
257
- "./use-map": {
258
- "types": "./use-map/index.d.ts",
240
+ "./create-fixed-array": {
241
+ "types": "./create-fixed-array/index.d.ts",
259
242
  "import": {
260
- "types": "./use-map/index.d.ts",
261
- "default": "./use-map/index.mjs"
243
+ "types": "./create-fixed-array/index.d.ts",
244
+ "default": "./create-fixed-array/index.mjs"
262
245
  },
263
- "require": "./use-map/index.cjs",
264
- "default": "./use-map/index.js"
246
+ "require": "./create-fixed-array/index.cjs",
247
+ "default": "./create-fixed-array/index.js"
265
248
  },
266
- "./use-next-pathname": {
267
- "types": "./use-next-pathname/index.d.ts",
249
+ "./use-clipboard": {
250
+ "types": "./use-clipboard/index.d.ts",
268
251
  "import": {
269
- "types": "./use-next-pathname/index.d.ts",
270
- "default": "./use-next-pathname/index.mjs"
252
+ "types": "./use-clipboard/index.d.ts",
253
+ "default": "./use-clipboard/index.mjs"
271
254
  },
272
- "require": "./use-next-pathname/index.cjs",
273
- "default": "./use-next-pathname/index.js"
255
+ "require": "./use-clipboard/index.cjs",
256
+ "default": "./use-clipboard/index.js"
274
257
  },
275
258
  "./use-react-router-enable-concurrent-navigation": {
276
259
  "types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
@@ -281,23 +264,23 @@
281
264
  "require": "./use-react-router-enable-concurrent-navigation/index.cjs",
282
265
  "default": "./use-react-router-enable-concurrent-navigation/index.js"
283
266
  },
284
- "./use-react-router-is-match": {
285
- "types": "./use-react-router-is-match/index.d.ts",
267
+ "./use-composition-input": {
268
+ "types": "./use-composition-input/index.d.ts",
286
269
  "import": {
287
- "types": "./use-react-router-is-match/index.d.ts",
288
- "default": "./use-react-router-is-match/index.mjs"
270
+ "types": "./use-composition-input/index.d.ts",
271
+ "default": "./use-composition-input/index.mjs"
289
272
  },
290
- "require": "./use-react-router-is-match/index.cjs",
291
- "default": "./use-react-router-is-match/index.js"
273
+ "require": "./use-composition-input/index.cjs",
274
+ "default": "./use-composition-input/index.js"
292
275
  },
293
- "./use-retimer": {
294
- "types": "./use-retimer/index.d.ts",
276
+ "./use-next-pathname": {
277
+ "types": "./use-next-pathname/index.d.ts",
295
278
  "import": {
296
- "types": "./use-retimer/index.d.ts",
297
- "default": "./use-retimer/index.mjs"
279
+ "types": "./use-next-pathname/index.d.ts",
280
+ "default": "./use-next-pathname/index.mjs"
298
281
  },
299
- "require": "./use-retimer/index.cjs",
300
- "default": "./use-retimer/index.js"
282
+ "require": "./use-next-pathname/index.cjs",
283
+ "default": "./use-next-pathname/index.js"
301
284
  },
302
285
  "./use-session-storage": {
303
286
  "types": "./use-session-storage/index.d.ts",
@@ -308,23 +291,32 @@
308
291
  "require": "./use-session-storage/index.cjs",
309
292
  "default": "./use-session-storage/index.js"
310
293
  },
311
- "./use-set": {
312
- "types": "./use-set/index.d.ts",
294
+ "./invariant": {
295
+ "types": "./invariant/index.d.ts",
313
296
  "import": {
314
- "types": "./use-set/index.d.ts",
315
- "default": "./use-set/index.mjs"
297
+ "types": "./invariant/index.d.ts",
298
+ "default": "./invariant/index.mjs"
316
299
  },
317
- "require": "./use-set/index.cjs",
318
- "default": "./use-set/index.js"
300
+ "require": "./invariant/index.cjs",
301
+ "default": "./invariant/index.js"
319
302
  },
320
- "./use-singleton": {
321
- "types": "./use-singleton/index.d.ts",
303
+ "./use-debounced-value": {
304
+ "types": "./use-debounced-value/index.d.ts",
322
305
  "import": {
323
- "types": "./use-singleton/index.d.ts",
324
- "default": "./use-singleton/index.mjs"
306
+ "types": "./use-debounced-value/index.d.ts",
307
+ "default": "./use-debounced-value/index.mjs"
325
308
  },
326
- "require": "./use-singleton/index.cjs",
327
- "default": "./use-singleton/index.js"
309
+ "require": "./use-debounced-value/index.cjs",
310
+ "default": "./use-debounced-value/index.js"
311
+ },
312
+ "./create-storage-hook": {
313
+ "types": "./create-storage-hook/index.d.ts",
314
+ "import": {
315
+ "types": "./create-storage-hook/index.d.ts",
316
+ "default": "./create-storage-hook/index.mjs"
317
+ },
318
+ "require": "./create-storage-hook/index.cjs",
319
+ "default": "./create-storage-hook/index.js"
328
320
  },
329
321
  "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired": {
330
322
  "types": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.d.ts",
@@ -335,23 +327,50 @@
335
327
  "require": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs",
336
328
  "default": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.js"
337
329
  },
338
- "./use-uncontrolled": {
339
- "types": "./use-uncontrolled/index.d.ts",
330
+ "./context-state": {
331
+ "types": "./context-state/index.d.ts",
340
332
  "import": {
341
- "types": "./use-uncontrolled/index.d.ts",
342
- "default": "./use-uncontrolled/index.mjs"
333
+ "types": "./context-state/index.d.ts",
334
+ "default": "./context-state/index.mjs"
343
335
  },
344
- "require": "./use-uncontrolled/index.cjs",
345
- "default": "./use-uncontrolled/index.js"
336
+ "require": "./context-state/index.cjs",
337
+ "default": "./context-state/index.js"
346
338
  },
347
- "./use-url-hash-state": {
348
- "types": "./use-url-hash-state/index.d.ts",
339
+ "./use-local-storage": {
340
+ "types": "./use-local-storage/index.d.ts",
349
341
  "import": {
350
- "types": "./use-url-hash-state/index.d.ts",
351
- "default": "./use-url-hash-state/index.mjs"
342
+ "types": "./use-local-storage/index.d.ts",
343
+ "default": "./use-local-storage/index.mjs"
352
344
  },
353
- "require": "./use-url-hash-state/index.cjs",
354
- "default": "./use-url-hash-state/index.js"
345
+ "require": "./use-local-storage/index.cjs",
346
+ "default": "./use-local-storage/index.js"
347
+ },
348
+ "./use-isomorphic-layout-effect": {
349
+ "types": "./use-isomorphic-layout-effect/index.d.ts",
350
+ "import": {
351
+ "types": "./use-isomorphic-layout-effect/index.d.ts",
352
+ "default": "./use-isomorphic-layout-effect/index.mjs"
353
+ },
354
+ "require": "./use-isomorphic-layout-effect/index.cjs",
355
+ "default": "./use-isomorphic-layout-effect/index.js"
356
+ },
357
+ "./create-context-state": {
358
+ "types": "./create-context-state/index.d.ts",
359
+ "import": {
360
+ "types": "./create-context-state/index.d.ts",
361
+ "default": "./create-context-state/index.mjs"
362
+ },
363
+ "require": "./create-context-state/index.cjs",
364
+ "default": "./create-context-state/index.js"
365
+ },
366
+ "./use-array": {
367
+ "types": "./use-array/index.d.ts",
368
+ "import": {
369
+ "types": "./use-array/index.d.ts",
370
+ "default": "./use-array/index.mjs"
371
+ },
372
+ "require": "./use-array/index.cjs",
373
+ "default": "./use-array/index.js"
355
374
  }
356
375
  }
357
376
  }
package/sizes.json CHANGED
@@ -1 +1 @@
1
- {"total":{"raw":14388,"gzip":8850,"br":0},"exports":{"compose-context-provider":{"raw":164,"gzip":148,"br":114},"create-fixed-array":{"raw":100,"gzip":104,"br":89},"create-context-state":{"raw":145,"gzip":116,"br":96},"context-state":{"raw":377,"gzip":241,"br":207},"noop":{"raw":33,"gzip":53,"br":37},"rem":{"raw":588,"gzip":330,"br":282},"no-ssr":{"raw":389,"gzip":269,"br":228},"request-idle-callback":{"raw":410,"gzip":229,"br":175},"use":{"raw":276,"gzip":182,"br":150},"use-array":{"raw":337,"gzip":244,"br":204},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"create-storage-hook":{"raw":1988,"gzip":877,"br":766},"use-composition-input":{"raw":454,"gzip":281,"br":238},"use-debounced-state":{"raw":409,"gzip":285,"br":245},"use-debounced-value":{"raw":470,"gzip":309,"br":252},"use-clipboard":{"raw":1075,"gzip":616,"br":533},"use-error-boundary":{"raw":244,"gzip":196,"br":159},"use-isomorphic-layout-effect":{"raw":178,"gzip":142,"br":113},"use-is-client":{"raw":151,"gzip":142,"br":118},"use-local-storage":{"raw":310,"gzip":184,"br":157},"use-map":{"raw":354,"gzip":248,"br":211},"use-intersection":{"raw":1238,"gzip":654,"br":604},"use-next-pathname":{"raw":321,"gzip":236,"br":199},"use-react-router-is-match":{"raw":568,"gzip":371,"br":309},"use-retimer":{"raw":200,"gzip":165,"br":123},"use-session-storage":{"raw":316,"gzip":181,"br":152},"use-singleton":{"raw":138,"gzip":129,"br":109},"use-set":{"raw":355,"gzip":243,"br":205},"use-react-router-enable-concurrent-navigation":{"raw":955,"gzip":457,"br":375},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":466,"gzip":325,"br":254},"use-uncontrolled":{"raw":300,"gzip":229,"br":194},"use-url-hash-state":{"raw":960,"gzip":561,"br":486}}}
1
+ {"total":{"raw":14693,"gzip":9118,"br":0},"exports":{"nullthrow":{"raw":169,"gzip":149,"br":109},"use-error-boundary":{"raw":244,"gzip":196,"br":159},"use-retimer":{"raw":200,"gzip":165,"br":123},"use-uncontrolled":{"raw":296,"gzip":227,"br":193},"use-is-client":{"raw":151,"gzip":142,"br":118},"rem":{"raw":588,"gzip":330,"br":282},"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":{"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":164,"gzip":148,"br":114},"use-singleton":{"raw":138,"gzip":129,"br":109},"request-idle-callback":{"raw":410,"gzip":229,"br":175},"use-react-router-is-match":{"raw":568,"gzip":371,"br":309},"create-fixed-array":{"raw":100,"gzip":104,"br":89},"no-ssr":{"raw":389,"gzip":269,"br":228},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-composition-input":{"raw":454,"gzip":281,"br":238},"use-react-router-enable-concurrent-navigation":{"raw":955,"gzip":457,"br":375},"use-next-pathname":{"raw":321,"gzip":236,"br":199},"use-session-storage":{"raw":316,"gzip":181,"br":152},"invariant":{"raw":90,"gzip":100,"br":71},"use-clipboard":{"raw":1067,"gzip":611,"br":525},"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-isomorphic-layout-effect":{"raw":178,"gzip":142,"br":113},"create-context-state":{"raw":145,"gzip":116,"br":96},"use-local-storage":{"raw":310,"gzip":184,"br":157},"use-array":{"raw":329,"gzip":238,"br":199},"create-storage-hook":{"raw":1984,"gzip":874,"br":760}}}
package/use/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("react");const t=e.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}});exports.use=t;
1
+ "use strict";const e=require("react").use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}});exports.use=e;
package/use/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("react");const t=e.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}});exports.use=t;
1
+ "use strict";const e=require("react").use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}});exports.use=e;
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react");exports.useArray=function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>[];const[t,c]=e.useState(r),l=e.useCallback(e=>c(r=>r.concat(e)),[]),s=e.useCallback(()=>c([]),[]),u=e.useCallback(e=>c(r=>{if(e>-1){const t=r.slice();return t.splice(e,1),t}return r}),[]);return[t,l,s,u]};
1
+ "use strict";require("client-only");var e=require("react");exports.useArray=function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>[];const[t,c]=e.useState(r),l=e.useCallback(e=>c(r=>r.concat(e)),[]);return[t,l,e.useCallback(()=>c([]),[]),e.useCallback(e=>c(r=>{if(e>-1){const t=r.slice();return t.splice(e,1),t}return r}),[])]};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react");exports.useArray=function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>[];const[t,c]=e.useState(r),l=e.useCallback(e=>c(r=>r.concat(e)),[]),s=e.useCallback(()=>c([]),[]),u=e.useCallback(e=>c(r=>{if(e>-1){const t=r.slice();return t.splice(e,1),t}return r}),[]);return[t,l,s,u]};
1
+ "use strict";require("client-only");var e=require("react");exports.useArray=function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>[];const[t,c]=e.useState(r),l=e.useCallback(e=>c(r=>r.concat(e)),[]);return[t,l,e.useCallback(()=>c([]),[]),e.useCallback(e=>c(r=>{if(e>-1){const t=r.slice();return t.splice(e,1),t}return r}),[])]};
@@ -1 +1 @@
1
- import"client-only";import{useState as t,useCallback as r}from"react";const n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>[];const[e,o]=t(n),c=r(t=>o(r=>r.concat(t)),[]),i=r(()=>o([]),[]),l=r(t=>o(r=>{if(t>-1){const n=r.slice();return n.splice(t,1),n}return r}),[]);return[e,c,i,l]};export{n as useArray};
1
+ import"client-only";import{useState as t,useCallback as r}from"react";const n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>[];const[e,o]=t(n),c=r(t=>o(r=>r.concat(t)),[]);return[e,c,r(()=>o([]),[]),r(t=>o(r=>{if(t>-1){const n=r.slice();return n.splice(t,1),n}return r}),[])]};export{n as useArray};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),r=require("../noop/index.cjs"),t=require("../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs");class a extends Error{}exports.UseClipboardError=a,exports.useClipboard=function(){let{timeout:o=1e3,usePromptAsFallback:l=!1,promptFallbackText:i="Failed to copy to clipboard automatically, please manually copy the text below.",onCopyError:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[u,c]=e.useState(null),[s,d]=e.useState(!1),p=e.useRef(null),b=t.useStableHandler(n||r.noop),w=e.useCallback(e=>{p.current&&clearTimeout(p.current),e&&(p.current=window.setTimeout(()=>d(!1),o)),d(e)},[o]),y=e.useCallback(e=>{c(e),b(e)},[b]),h=e.useCallback(async e=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(e),w(!0);else throw new a("[foxact] useClipboard: navigator.clipboard is not supported")}catch(r){if(l)try{window.prompt(i,e)}catch(e){y(e)}else y(r)}},[w,i,y,l]),x=e.useCallback(()=>{d(!1),c(null),p.current&&clearTimeout(p.current)},[]);return{copy:h,reset:x,error:u,copied:s}};
1
+ "use strict";require("client-only");var e=require("react"),r=require("../noop/index.cjs"),t=require("../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs");class a extends Error{}exports.UseClipboardError=a,exports.useClipboard=function(){let{timeout:o=1e3,usePromptAsFallback:l=!1,promptFallbackText:i="Failed to copy to clipboard automatically, please manually copy the text below.",onCopyError:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[u,c]=e.useState(null),[s,d]=e.useState(!1),p=e.useRef(null),b=t.useStableHandler(n||r.noop),w=e.useCallback(e=>{p.current&&clearTimeout(p.current),e&&(p.current=window.setTimeout(()=>d(!1),o)),d(e)},[o]),y=e.useCallback(e=>{c(e),b(e)},[b]);return{copy:e.useCallback(async e=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(e),w(!0);else throw new a("[foxact] useClipboard: navigator.clipboard is not supported")}catch(r){if(l)try{window.prompt(i,e)}catch(e){y(e)}else y(r)}},[w,i,y,l]),reset:e.useCallback(()=>{d(!1),c(null),p.current&&clearTimeout(p.current)},[]),error:u,copied:s}};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),r=require("../noop/index.js"),t=require("../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.js");class a extends Error{}exports.UseClipboardError=a,exports.useClipboard=function(){let{timeout:o=1e3,usePromptAsFallback:l=!1,promptFallbackText:i="Failed to copy to clipboard automatically, please manually copy the text below.",onCopyError:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[u,c]=e.useState(null),[s,d]=e.useState(!1),p=e.useRef(null),b=t.useStableHandler(n||r.noop),w=e.useCallback(e=>{p.current&&clearTimeout(p.current),e&&(p.current=window.setTimeout(()=>d(!1),o)),d(e)},[o]),y=e.useCallback(e=>{c(e),b(e)},[b]),h=e.useCallback(async e=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(e),w(!0);else throw new a("[foxact] useClipboard: navigator.clipboard is not supported")}catch(r){if(l)try{window.prompt(i,e)}catch(e){y(e)}else y(r)}},[w,i,y,l]),x=e.useCallback(()=>{d(!1),c(null),p.current&&clearTimeout(p.current)},[]);return{copy:h,reset:x,error:u,copied:s}};
1
+ "use strict";require("client-only");var e=require("react"),r=require("../noop/index.js"),t=require("../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.js");class a extends Error{}exports.UseClipboardError=a,exports.useClipboard=function(){let{timeout:o=1e3,usePromptAsFallback:l=!1,promptFallbackText:i="Failed to copy to clipboard automatically, please manually copy the text below.",onCopyError:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[u,c]=e.useState(null),[s,d]=e.useState(!1),p=e.useRef(null),b=t.useStableHandler(n||r.noop),w=e.useCallback(e=>{p.current&&clearTimeout(p.current),e&&(p.current=window.setTimeout(()=>d(!1),o)),d(e)},[o]),y=e.useCallback(e=>{c(e),b(e)},[b]);return{copy:e.useCallback(async e=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(e),w(!0);else throw new a("[foxact] useClipboard: navigator.clipboard is not supported")}catch(r){if(l)try{window.prompt(i,e)}catch(e){y(e)}else y(r)}},[w,i,y,l]),reset:e.useCallback(()=>{d(!1),c(null),p.current&&clearTimeout(p.current)},[]),error:u,copied:s}};
@@ -1 +1 @@
1
- import"client-only";import{useState as o,useRef as r,useCallback as e}from"react";import{noop as t}from"../noop/index.mjs";import{useStableHandler as i}from"../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs";class a extends Error{}function l(){let{timeout:l=1e3,usePromptAsFallback:n=!1,promptFallbackText:c="Failed to copy to clipboard automatically, please manually copy the text below.",onCopyError:u}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[p,d]=o(null),[s,m]=o(!1),w=r(null),y=i(u||t),b=e(o=>{w.current&&clearTimeout(w.current),o&&(w.current=window.setTimeout(()=>m(!1),l)),m(o)},[l]),f=e(o=>{d(o),y(o)},[y]),h=e(async o=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(o),b(!0);else throw new a("[foxact] useClipboard: navigator.clipboard is not supported")}catch(r){if(n)try{window.prompt(c,o)}catch(o){f(o)}else f(r)}},[b,c,f,n]),x=e(()=>{m(!1),d(null),w.current&&clearTimeout(w.current)},[]);return{copy:h,reset:x,error:p,copied:s}}export{a as UseClipboardError,l as useClipboard};
1
+ import"client-only";import{useState as o,useRef as r,useCallback as e}from"react";import{noop as t}from"../noop/index.mjs";import{useStableHandler as i}from"../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs";class a extends Error{}function l(){let{timeout:l=1e3,usePromptAsFallback:n=!1,promptFallbackText:c="Failed to copy to clipboard automatically, please manually copy the text below.",onCopyError:u}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[p,s]=o(null),[d,m]=o(!1),w=r(null),y=i(u||t),b=e(o=>{w.current&&clearTimeout(w.current),o&&(w.current=window.setTimeout(()=>m(!1),l)),m(o)},[l]),f=e(o=>{s(o),y(o)},[y]);return{copy:e(async o=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(o),b(!0);else throw new a("[foxact] useClipboard: navigator.clipboard is not supported")}catch(r){if(n)try{window.prompt(c,o)}catch(o){f(o)}else f(r)}},[b,c,f,n]),reset:e(()=>{m(!1),s(null),w.current&&clearTimeout(w.current)},[]),error:p,copied:d}}export{a as UseClipboardError,l as useClipboard};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),r=require("../use-retimer/index.cjs");exports.useDebouncedState=function(t,u){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const[s,c]=e.useState(t),i=e.useRef(!0),a=r.useRetimer(),l=e.useCallback(e=>{i.current&&n?c(e):a(window.setTimeout(()=>{i.current=!0,c(e)},u)),i.current=!1},[n,a,u]),o=e.useCallback(e=>{a(),c(e)},[a]);return[s,l,o]};
1
+ "use strict";require("client-only");var e=require("react"),r=require("../use-retimer/index.cjs");exports.useDebouncedState=function(t,u){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const[s,c]=e.useState(t),i=e.useRef(!0),a=r.useRetimer();return[s,e.useCallback(e=>{i.current&&n?c(e):a(window.setTimeout(()=>{i.current=!0,c(e)},u)),i.current=!1},[n,a,u]),e.useCallback(e=>{a(),c(e)},[a])]};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),r=require("../use-retimer/index.js");exports.useDebouncedState=function(t,u){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const[s,i]=e.useState(t),c=e.useRef(!0),a=r.useRetimer(),l=e.useCallback(e=>{c.current&&n?i(e):a(window.setTimeout(()=>{c.current=!0,i(e)},u)),c.current=!1},[n,a,u]),o=e.useCallback(e=>{a(),i(e)},[a]);return[s,l,o]};
1
+ "use strict";require("client-only");var e=require("react"),r=require("../use-retimer/index.js");exports.useDebouncedState=function(t,u){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const[s,i]=e.useState(t),c=e.useRef(!0),a=r.useRetimer();return[s,e.useCallback(e=>{c.current&&n?i(e):a(window.setTimeout(()=>{c.current=!0,i(e)},u)),c.current=!1},[n,a,u]),e.useCallback(e=>{a(),i(e)},[a])]};
@@ -1 +1 @@
1
- import"client-only";import{useState as e,useRef as t,useCallback as r}from"react";import{useRetimer as n}from"../use-retimer/index.mjs";function o(o,i){let u=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const[c,m]=e(o),s=t(!0),d=n(),l=r(e=>{s.current&&u?m(e):d(window.setTimeout(()=>{s.current=!0,m(e)},i)),s.current=!1},[u,d,i]),p=r(e=>{d(),m(e)},[d]);return[c,l,p]}export{o as useDebouncedState};
1
+ import"client-only";import{useState as e,useRef as t,useCallback as r}from"react";import{useRetimer as n}from"../use-retimer/index.mjs";function o(o,i){let u=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const[c,m]=e(o),s=t(!0),d=n();return[c,r(e=>{s.current&&u?m(e):d(window.setTimeout(()=>{s.current=!0,m(e)},i)),s.current=!1},[u,d,i]),r(e=>{d(),m(e)},[d])]}export{o as useDebouncedState};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),t=require("../request-idle-callback/index.cjs");const n="function"==typeof IntersectionObserver,r=new Map,o=[];exports.useIntersection=function(c){let{rootRef:i,rootMargin:s,disabled:u}=c;const[l,a]=e.useState(!1),f=e.useRef(null);e.useEffect(()=>{if(n){if(u||l)return;const e=f.current;if(null==e?void 0:e.tagName)return function(e,t,n){const{id:c,observer:i,elements:s}=function(e){let t;const n={root:e.root||null,margin:e.rootMargin||""},c=o.find(e=>e.root===n.root&&e.margin===n.margin);if(c&&(t=r.get(c)))return t;const i=new Map,s=new IntersectionObserver(e=>{e.forEach(e=>{const t=i.get(e.target),n=e.isIntersecting||e.intersectionRatio>0;t&&n&&t(n)})},e);return t={id:n,observer:s,elements:i},o.push(n),r.set(n,t),t}(n);return s.set(e,t),i.observe(e),function(){if(s.delete(e),i.unobserve(e),0===s.size){i.disconnect(),r.delete(c);const e=o.findIndex(e=>e.root===c.root&&e.margin===c.margin);e>-1&&o.splice(e,1)}}}(e,e=>e&&a(!0),{root:null==i?void 0:i.current,rootMargin:s})}if(!l){const e=t.requestIdleCallback(()=>a(!0));return()=>t.cancelIdleCallback(e)}},[u,s,i,l]);const d=e.useCallback(()=>{a(!1)},[]),g=e.useCallback(e=>{f.current=e},[]);return[g,l,d]};
1
+ "use strict";require("client-only");var e=require("react"),t=require("../request-idle-callback/index.cjs");const n="function"==typeof IntersectionObserver,r=new Map,o=[];exports.useIntersection=function(c){let{rootRef:i,rootMargin:s,disabled:u}=c;const[l,a]=e.useState(!1),f=e.useRef(null);e.useEffect(()=>{if(n){if(u||l)return;const e=f.current;if(null==e?void 0:e.tagName)return function(e,t,n){const{id:c,observer:i,elements:s}=function(e){let t;const n={root:e.root||null,margin:e.rootMargin||""},c=o.find(e=>e.root===n.root&&e.margin===n.margin);if(c&&(t=r.get(c)))return t;const i=new Map;return t={id:n,observer:new IntersectionObserver(e=>{e.forEach(e=>{const t=i.get(e.target),n=e.isIntersecting||e.intersectionRatio>0;t&&n&&t(n)})},e),elements:i},o.push(n),r.set(n,t),t}(n);return s.set(e,t),i.observe(e),function(){if(s.delete(e),i.unobserve(e),0===s.size){i.disconnect(),r.delete(c);const e=o.findIndex(e=>e.root===c.root&&e.margin===c.margin);e>-1&&o.splice(e,1)}}}(e,e=>e&&a(!0),{root:null==i?void 0:i.current,rootMargin:s})}if(!l){const e=t.requestIdleCallback(()=>a(!0));return()=>t.cancelIdleCallback(e)}},[u,s,i,l]);const d=e.useCallback(()=>{a(!1)},[]);return[e.useCallback(e=>{f.current=e},[]),l,d]};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),t=require("../request-idle-callback/index.js");const n="function"==typeof IntersectionObserver,r=new Map,o=[];exports.useIntersection=function(c){let{rootRef:i,rootMargin:s,disabled:u}=c;const[l,a]=e.useState(!1),f=e.useRef(null);e.useEffect(()=>{if(n){if(u||l)return;const e=f.current;if(null==e?void 0:e.tagName)return function(e,t,n){const{id:c,observer:i,elements:s}=function(e){let t;const n={root:e.root||null,margin:e.rootMargin||""},c=o.find(e=>e.root===n.root&&e.margin===n.margin);if(c&&(t=r.get(c)))return t;const i=new Map,s=new IntersectionObserver(e=>{e.forEach(e=>{const t=i.get(e.target),n=e.isIntersecting||e.intersectionRatio>0;t&&n&&t(n)})},e);return t={id:n,observer:s,elements:i},o.push(n),r.set(n,t),t}(n);return s.set(e,t),i.observe(e),function(){if(s.delete(e),i.unobserve(e),0===s.size){i.disconnect(),r.delete(c);const e=o.findIndex(e=>e.root===c.root&&e.margin===c.margin);e>-1&&o.splice(e,1)}}}(e,e=>e&&a(!0),{root:null==i?void 0:i.current,rootMargin:s})}if(!l){const e=t.requestIdleCallback(()=>a(!0));return()=>t.cancelIdleCallback(e)}},[u,s,i,l]);const d=e.useCallback(()=>{a(!1)},[]),g=e.useCallback(e=>{f.current=e},[]);return[g,l,d]};
1
+ "use strict";require("client-only");var e=require("react"),t=require("../request-idle-callback/index.js");const n="function"==typeof IntersectionObserver,r=new Map,o=[];exports.useIntersection=function(c){let{rootRef:i,rootMargin:s,disabled:u}=c;const[l,a]=e.useState(!1),f=e.useRef(null);e.useEffect(()=>{if(n){if(u||l)return;const e=f.current;if(null==e?void 0:e.tagName)return function(e,t,n){const{id:c,observer:i,elements:s}=function(e){let t;const n={root:e.root||null,margin:e.rootMargin||""},c=o.find(e=>e.root===n.root&&e.margin===n.margin);if(c&&(t=r.get(c)))return t;const i=new Map;return t={id:n,observer:new IntersectionObserver(e=>{e.forEach(e=>{const t=i.get(e.target),n=e.isIntersecting||e.intersectionRatio>0;t&&n&&t(n)})},e),elements:i},o.push(n),r.set(n,t),t}(n);return s.set(e,t),i.observe(e),function(){if(s.delete(e),i.unobserve(e),0===s.size){i.disconnect(),r.delete(c);const e=o.findIndex(e=>e.root===c.root&&e.margin===c.margin);e>-1&&o.splice(e,1)}}}(e,e=>e&&a(!0),{root:null==i?void 0:i.current,rootMargin:s})}if(!l){const e=t.requestIdleCallback(()=>a(!0));return()=>t.cancelIdleCallback(e)}},[u,s,i,l]);const d=e.useCallback(()=>{a(!1)},[]);return[e.useCallback(e=>{f.current=e},[]),l,d]};
@@ -1 +1 @@
1
- import"client-only";import{useState as t,useRef as n,useEffect as e,useCallback as r}from"react";import{requestIdleCallback as o,cancelIdleCallback as i}from"../request-idle-callback/index.mjs";const c="function"==typeof IntersectionObserver;function s(s){let{rootRef:f,rootMargin:a,disabled:m}=s;const[g,d]=t(!1),p=n(null);e(()=>{if(c){if(m||g)return;const t=p.current;if(null==t?void 0:t.tagName)return function(t,n,e){const{id:r,observer:o,elements:i}=function(t){let n;const e={root:t.root||null,margin:t.rootMargin||""},r=l.find(t=>t.root===e.root&&t.margin===e.margin);if(r&&(n=u.get(r)))return n;const o=new Map,i=new IntersectionObserver(t=>{t.forEach(t=>{const n=o.get(t.target),e=t.isIntersecting||t.intersectionRatio>0;n&&e&&n(e)})},t);return n={id:e,observer:i,elements:o},l.push(e),u.set(e,n),n}(e);return i.set(t,n),o.observe(t),function(){if(i.delete(t),o.unobserve(t),0===i.size){o.disconnect(),u.delete(r);const t=l.findIndex(t=>t.root===r.root&&t.margin===r.margin);t>-1&&l.splice(t,1)}}}(t,t=>t&&d(!0),{root:null==f?void 0:f.current,rootMargin:a})}if(!g){const t=o(()=>d(!0));return()=>i(t)}},[m,a,f,g]);const v=r(()=>{d(!1)},[]),b=r(t=>{p.current=t},[]);return[b,g,v]}const u=new Map,l=[];export{s as useIntersection};
1
+ import"client-only";import{useState as t,useRef as n,useEffect as e,useCallback as r}from"react";import{requestIdleCallback as o,cancelIdleCallback as i}from"../request-idle-callback/index.mjs";const c="function"==typeof IntersectionObserver;function s(s){let{rootRef:f,rootMargin:a,disabled:m}=s;const[g,d]=t(!1),p=n(null);e(()=>{if(c){if(m||g)return;const t=p.current;if(null==t?void 0:t.tagName)return function(t,n,e){const{id:r,observer:o,elements:i}=function(t){let n;const e={root:t.root||null,margin:t.rootMargin||""},r=l.find(t=>t.root===e.root&&t.margin===e.margin);if(r&&(n=u.get(r)))return n;const o=new Map;return n={id:e,observer:new IntersectionObserver(t=>{t.forEach(t=>{const n=o.get(t.target),e=t.isIntersecting||t.intersectionRatio>0;n&&e&&n(e)})},t),elements:o},l.push(e),u.set(e,n),n}(e);return i.set(t,n),o.observe(t),function(){if(i.delete(t),o.unobserve(t),0===i.size){o.disconnect(),u.delete(r);const t=l.findIndex(t=>t.root===r.root&&t.margin===r.margin);t>-1&&l.splice(t,1)}}}(t,t=>t&&d(!0),{root:null==f?void 0:f.current,rootMargin:a})}if(!g){const t=o(()=>d(!0));return()=>i(t)}},[m,a,f,g]);const v=r(()=>{d(!1)},[]);return[r(t=>{p.current=t},[]),g,v]}const u=new Map,l=[];export{s as useIntersection};
@@ -1,8 +1,8 @@
1
- import { useLayoutEffect as useLayoutEffect$1 } from 'react';
1
+ import { useEffect } from 'react';
2
2
 
3
3
  /** @see https://foxact.skk.moe/use-isomorphic-layout-effect */
4
- declare const useIsomorphicLayoutEffect: typeof useLayoutEffect$1;
4
+ declare const useIsomorphicLayoutEffect: typeof useEffect;
5
5
  /** @see https://foxact.skk.moe/use-isomorphic-layout-effect */
6
- declare const useLayoutEffect: typeof useLayoutEffect$1;
6
+ declare const useLayoutEffect: typeof useEffect;
7
7
 
8
8
  export { useIsomorphicLayoutEffect, useLayoutEffect };
package/use-map/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react");exports.useMap=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map;const[t,l]=e.useState(a),s=e.useCallback((e,a)=>l(t=>(t.set(e,a),new Map(t))),[]),n=e.useCallback(e=>l(a=>a.has(e)?(a.delete(e),new Map(a)):a),[]),u=e.useCallback(()=>l(new Map),[]),r=e.useCallback(e=>l(e),[]);return[t,s,n,u,r]};
1
+ "use strict";require("client-only");var e=require("react");exports.useMap=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map;const[t,l]=e.useState(a),s=e.useCallback((e,a)=>l(t=>(t.set(e,a),new Map(t))),[]),n=e.useCallback(e=>l(a=>a.has(e)?(a.delete(e),new Map(a)):a),[]);return[t,s,n,e.useCallback(()=>l(new Map),[]),e.useCallback(e=>l(e),[])]};
package/use-map/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react");exports.useMap=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map;const[t,l]=e.useState(a),s=e.useCallback((e,a)=>l(t=>(t.set(e,a),new Map(t))),[]),n=e.useCallback(e=>l(a=>a.has(e)?(a.delete(e),new Map(a)):a),[]),u=e.useCallback(()=>l(new Map),[]),r=e.useCallback(e=>l(e),[]);return[t,s,n,u,r]};
1
+ "use strict";require("client-only");var e=require("react");exports.useMap=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map;const[t,l]=e.useState(a),s=e.useCallback((e,a)=>l(t=>(t.set(e,a),new Map(t))),[]),n=e.useCallback(e=>l(a=>a.has(e)?(a.delete(e),new Map(a)):a),[]);return[t,s,n,e.useCallback(()=>l(new Map),[]),e.useCallback(e=>l(e),[])]};
package/use-map/index.mjs CHANGED
@@ -1 +1 @@
1
- import"client-only";import{useState as e,useCallback as t}from"react";const n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map;const[o,p]=e(n),a=t((e,t)=>p(n=>(n.set(e,t),new Map(n))),[]),r=t(e=>p(t=>t.has(e)?(t.delete(e),new Map(t)):t),[]),c=t(()=>p(new Map),[]),i=t(e=>p(e),[]);return[o,a,r,c,i]};export{n as useMap};
1
+ import"client-only";import{useState as e,useCallback as t}from"react";const n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map;const[o,p]=e(n),a=t((e,t)=>p(n=>(n.set(e,t),new Map(n))),[]),r=t(e=>p(t=>t.has(e)?(t.delete(e),new Map(t)):t),[]);return[o,a,r,t(()=>p(new Map),[]),t(e=>p(e),[])]};export{n as useMap};
package/use-set/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react");exports.useSet=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set;const[a,l]=e.useState(t),s=e.useCallback(e=>l(t=>t.has(e)?t:new Set([...t,e])),[]),n=e.useCallback(e=>l(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]),u=e.useCallback(()=>l(new Set),[]),r=e.useCallback(e=>l(e),[]);return[a,s,n,u,r]};
1
+ "use strict";require("client-only");var e=require("react");exports.useSet=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set;const[a,l]=e.useState(t),s=e.useCallback(e=>l(t=>t.has(e)?t:new Set([...t,e])),[]),n=e.useCallback(e=>l(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]);return[a,s,n,e.useCallback(()=>l(new Set),[]),e.useCallback(e=>l(e),[])]};
package/use-set/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react");exports.useSet=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set;const[a,l]=e.useState(t),s=e.useCallback(e=>l(t=>t.has(e)?t:new Set([...t,e])),[]),n=e.useCallback(e=>l(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]),u=e.useCallback(()=>l(new Set),[]),r=e.useCallback(e=>l(e),[]);return[a,s,n,u,r]};
1
+ "use strict";require("client-only");var e=require("react");exports.useSet=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set;const[a,l]=e.useState(t),s=e.useCallback(e=>l(t=>t.has(e)?t:new Set([...t,e])),[]),n=e.useCallback(e=>l(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]);return[a,s,n,e.useCallback(()=>l(new Set),[]),e.useCallback(e=>l(e),[])]};
package/use-set/index.mjs CHANGED
@@ -1 +1 @@
1
- import"client-only";import{useState as e,useCallback as t}from"react";const n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set;const[o,r]=e(n),c=t(e=>r(t=>t.has(e)?t:new Set([...t,e])),[]),i=t(e=>r(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]),l=t(()=>r(new Set),[]),s=t(e=>r(e),[]);return[o,c,i,l,s]};export{n as useSet};
1
+ import"client-only";import{useState as e,useCallback as t}from"react";const n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set;const[o,r]=e(n),c=t(e=>r(t=>t.has(e)?t:new Set([...t,e])),[]),i=t(e=>r(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]);return[o,c,i,t(()=>r(new Set),[]),t(e=>r(e),[])]};export{n as useSet};
@@ -1 +1 @@
1
- "use strict";var e=require("react");const t="undefined"!=typeof window?e.useInsertionEffect||e.useLayoutEffect:e.useEffect;function n(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}exports.useStableHandler=function(r){const o=e.useRef(n);return t(()=>{o.current=r},[r]),e.useCallback(function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];const r=o.current;return r(...t)},[])};
1
+ "use strict";var e=require("react");const t="undefined"!=typeof window?e.useInsertionEffect||e.useLayoutEffect:e.useEffect;function n(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}exports.useStableHandler=function(r){const o=e.useRef(n);return t(()=>{o.current=r},[r]),e.useCallback(function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,o.current)(...t)},[])};
@@ -1 +1 @@
1
- "use strict";var e=require("react");const t="undefined"!=typeof window?e.useInsertionEffect||e.useLayoutEffect:e.useEffect;function n(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}exports.useStableHandler=function(r){const o=e.useRef(n);return t(()=>{o.current=r},[r]),e.useCallback(function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];const r=o.current;return r(...t)},[])};
1
+ "use strict";var e=require("react");const t="undefined"!=typeof window?e.useInsertionEffect||e.useLayoutEffect:e.useEffect;function n(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}exports.useStableHandler=function(r){const o=e.useRef(n);return t(()=>{o.current=r},[r]),e.useCallback(function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,o.current)(...t)},[])};
@@ -1 +1 @@
1
- import n,{useLayoutEffect as e,useEffect as t,useRef as r,useCallback as o}from"react";const c="undefined"!=typeof window?n.useInsertionEffect||e:t;function f(n){const e=r(u);return c(()=>{e.current=n},[n]),o(function(){for(var n=arguments.length,t=Array(n),r=0;r<n;r++)t[r]=arguments[r];const o=e.current;return o(...t)},[])}function u(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}export{f as useStableHandler};
1
+ import e,{useLayoutEffect as n,useEffect as t,useRef as r,useCallback as o}from"react";const c="undefined"!=typeof window?e.useInsertionEffect||n:t;function f(e){const n=r(u);return c(()=>{n.current=e},[e]),o(function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,n.current)(...t)},[])}function u(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}export{f as useStableHandler};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react");const r=e=>e;exports.useUncontrolled=function(t){let u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r;const n=e.useRef(null),[c,l]=e.useReducer((e,r)=>u(r),t),s=e.useCallback(()=>{n.current&&l(n.current.value)},[]);return[c,s,n]};
1
+ "use strict";require("client-only");var e=require("react");const r=e=>e;exports.useUncontrolled=function(t){let u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r;const n=e.useRef(null),[c,l]=e.useReducer((e,r)=>u(r),t);return[c,e.useCallback(()=>{n.current&&l(n.current.value)},[]),n]};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react");const r=e=>e;exports.useUncontrolled=function(t){let u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r;const n=e.useRef(null),[c,l]=e.useReducer((e,r)=>u(r),t),s=e.useCallback(()=>{n.current&&l(n.current.value)},[]);return[c,s,n]};
1
+ "use strict";require("client-only");var e=require("react");const r=e=>e;exports.useUncontrolled=function(t){let u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r;const n=e.useRef(null),[c,l]=e.useReducer((e,r)=>u(r),t);return[c,e.useCallback(()=>{n.current&&l(n.current.value)},[]),n]};
@@ -1 +1 @@
1
- import"client-only";import{useRef as t,useReducer as n,useCallback as r}from"react";const e=t=>t;function o(o){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;const c=t(null),[u,i]=n((t,n)=>l(n),o),m=r(()=>{c.current&&i(c.current.value)},[]);return[u,m,c]}export{o as useUncontrolled};
1
+ import"client-only";import{useRef as t,useReducer as n,useCallback as r}from"react";const e=t=>t;function o(o){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;const c=t(null),[u,i]=n((t,n)=>l(n),o);return[u,r(()=>{c.current&&i(c.current.value)},[]),c]}export{o as useUncontrolled};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),n=require("../noop/index.cjs"),t=require("../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs");const o=e=>e,r=(()=>{if("undefined"==typeof window)return e=>n.noop;let e=!1;const t=new Set,o=()=>{t.forEach(e=>e())};return n=>(t.add(n),e||(e=!0,window.addEventListener("hashchange",o)),()=>{t.delete(n)})})(),s=e=>"function"==typeof e;exports.unstable_useUrlHashState=function(n,a){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;const i=t.useStableHandler(l);return[e.useSyncExternalStore(r,()=>{const e=new URLSearchParams(location.hash.slice(1)),t=e.get(n);return null!==t?l(t):a},()=>a),e.useCallback(e=>{let t;const o=location.hash,r=new URLSearchParams(o.slice(1));if(s(e)){const o=r.get(n);t=e(null!==o?i(o):a)}else t=e;t===a||void 0===t?r.delete(n):r.set(n,JSON.stringify(t));const l=r.toString();o!==l&&(location.hash=l)},[a,n,i])]};
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,5 +1,15 @@
1
+ type NotUndefined<T> = T extends undefined ? never : T;
2
+ type Serializer<T> = (value: T) => string;
3
+ type Deserializer<T> = (value: string) => T;
4
+ interface UseUrlHashStateRawOption {
5
+ raw: true;
6
+ }
7
+ interface UseUrlHashStateParserOption<T> {
8
+ raw?: false;
9
+ serializer: Serializer<T>;
10
+ deserializer: Deserializer<T>;
11
+ }
1
12
  /** @see https://foxact.skk.moe/use-url-hash-state */
2
- declare function useUrlHashState<T>(key: string, defaultValue?: undefined): readonly [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>];
3
- declare function useUrlHashState<T>(key: string, defaultValue: T, transform?: (value: string) => T): readonly [T, React.Dispatch<React.SetStateAction<T>>];
13
+ declare function useUrlHashState<T>(key: string, defaultValue?: NotUndefined<T> | undefined, options?: UseUrlHashStateRawOption | UseUrlHashStateParserOption<T>): readonly [NonNullable<T> | null, (v: React.SetStateAction<T | null>) => void];
4
14
 
5
- export { useUrlHashState as unstable_useUrlHashState };
15
+ export { type Deserializer, type Serializer, type UseUrlHashStateParserOption, type UseUrlHashStateRawOption, useUrlHashState as unstable_useUrlHashState };
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),n=require("../noop/index.js"),t=require("../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.js");const o=e=>e,r=(()=>{if("undefined"==typeof window)return e=>n.noop;let e=!1;const t=new Set,o=()=>{t.forEach(e=>e())};return n=>(t.add(n),e||(e=!0,window.addEventListener("hashchange",o)),()=>{t.delete(n)})})(),s=e=>"function"==typeof e;exports.unstable_useUrlHashState=function(n,a){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;const i=t.useStableHandler(l);return[e.useSyncExternalStore(r,()=>{const e=new URLSearchParams(location.hash.slice(1)),t=e.get(n);return null!==t?l(t):a},()=>a),e.useCallback(e=>{let t;const o=location.hash,r=new URLSearchParams(o.slice(1));if(s(e)){const o=r.get(n);t=e(null!==o?i(o):a)}else t=e;t===a||void 0===t?r.delete(n):r.set(n,JSON.stringify(t));const l=r.toString();o!==l&&(location.hash=l)},[a,n,i])]};
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 +1 @@
1
- import"client-only";import{useSyncExternalStore as e,useCallback as t}from"react";import{noop as n}from"../noop/index.mjs";import{useStableHandler as o}from"../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs";const r=e=>e,s=(()=>{if("undefined"==typeof window)return e=>n;let e=!1;const t=new Set,o=()=>{t.forEach(e=>e())};return n=>(t.add(n),e||(e=!0,window.addEventListener("hashchange",o)),()=>{t.delete(n)})})(),a=e=>"function"==typeof e;function i(n,i){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r;const c=o(l);return[e(s,()=>{const e=new URLSearchParams(location.hash.slice(1)),t=e.get(n);return null!==t?l(t):i},()=>i),t(e=>{let t;const o=location.hash,r=new URLSearchParams(o.slice(1));if(a(e)){const o=r.get(n);t=e(null!==o?c(o):i)}else t=e;t===i||void 0===t?r.delete(n):r.set(n,JSON.stringify(t));const s=r.toString();o!==s&&(location.hash=s)},[i,n,c])]}export{i 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[(u=null!=w?w:o)!==null&&void 0!==u?u:null,f]}export{u as unstable_useUrlHashState};