foxact 0.2.25 → 0.2.26

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/README.md CHANGED
@@ -26,7 +26,7 @@ Written in TypeScript. Unlocking strong typing benefits with TypeScript 4.8+.
26
26
 
27
27
  #### Super Lightweight
28
28
 
29
- The entire **foxact** library has zero dependencies and is **about 5 KiB gzipped in sum**, ensuring a lean and efficient solution. And what's more...
29
+ The entire **foxact** library has zero dependencies, ensuring a lean and efficient solution. And what's more...
30
30
 
31
31
  #### Fully Tree Shakable
32
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxact",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
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": {
@@ -83,15 +83,6 @@
83
83
  "require": "./context-state/index.cjs",
84
84
  "default": "./context-state/index.js"
85
85
  },
86
- "./create-context-state": {
87
- "types": "./create-context-state/index.d.ts",
88
- "import": {
89
- "types": "./create-context-state/index.d.ts",
90
- "default": "./create-context-state/index.mjs"
91
- },
92
- "require": "./create-context-state/index.cjs",
93
- "default": "./create-context-state/index.js"
94
- },
95
86
  "./no-ssr": {
96
87
  "types": "./no-ssr/index.d.ts",
97
88
  "import": {
@@ -101,15 +92,6 @@
101
92
  "require": "./no-ssr/index.cjs",
102
93
  "default": "./no-ssr/index.js"
103
94
  },
104
- "./rem": {
105
- "types": "./rem/index.d.ts",
106
- "import": {
107
- "types": "./rem/index.d.ts",
108
- "default": "./rem/index.mjs"
109
- },
110
- "require": "./rem/index.cjs",
111
- "default": "./rem/index.js"
112
- },
113
95
  "./noop": {
114
96
  "types": "./noop/index.d.ts",
115
97
  "import": {
@@ -119,14 +101,23 @@
119
101
  "require": "./noop/index.cjs",
120
102
  "default": "./noop/index.js"
121
103
  },
122
- "./request-idle-callback": {
123
- "types": "./request-idle-callback/index.d.ts",
104
+ "./rem": {
105
+ "types": "./rem/index.d.ts",
124
106
  "import": {
125
- "types": "./request-idle-callback/index.d.ts",
126
- "default": "./request-idle-callback/index.mjs"
107
+ "types": "./rem/index.d.ts",
108
+ "default": "./rem/index.mjs"
127
109
  },
128
- "require": "./request-idle-callback/index.cjs",
129
- "default": "./request-idle-callback/index.js"
110
+ "require": "./rem/index.cjs",
111
+ "default": "./rem/index.js"
112
+ },
113
+ "./create-context-state": {
114
+ "types": "./create-context-state/index.d.ts",
115
+ "import": {
116
+ "types": "./create-context-state/index.d.ts",
117
+ "default": "./create-context-state/index.mjs"
118
+ },
119
+ "require": "./create-context-state/index.cjs",
120
+ "default": "./create-context-state/index.js"
130
121
  },
131
122
  "./create-fixed-array": {
132
123
  "types": "./create-fixed-array/index.d.ts",
@@ -137,6 +128,15 @@
137
128
  "require": "./create-fixed-array/index.cjs",
138
129
  "default": "./create-fixed-array/index.js"
139
130
  },
131
+ "./request-idle-callback": {
132
+ "types": "./request-idle-callback/index.d.ts",
133
+ "import": {
134
+ "types": "./request-idle-callback/index.d.ts",
135
+ "default": "./request-idle-callback/index.mjs"
136
+ },
137
+ "require": "./request-idle-callback/index.cjs",
138
+ "default": "./request-idle-callback/index.js"
139
+ },
140
140
  "./typescript-happy-forward-ref": {
141
141
  "types": "./typescript-happy-forward-ref/index.d.ts",
142
142
  "import": {
@@ -191,6 +191,15 @@
191
191
  "require": "./use-debounced-state/index.cjs",
192
192
  "default": "./use-debounced-state/index.js"
193
193
  },
194
+ "./use-debounced-value": {
195
+ "types": "./use-debounced-value/index.d.ts",
196
+ "import": {
197
+ "types": "./use-debounced-value/index.d.ts",
198
+ "default": "./use-debounced-value/index.mjs"
199
+ },
200
+ "require": "./use-debounced-value/index.cjs",
201
+ "default": "./use-debounced-value/index.js"
202
+ },
194
203
  "./use-error-boundary": {
195
204
  "types": "./use-error-boundary/index.d.ts",
196
205
  "import": {
@@ -209,14 +218,14 @@
209
218
  "require": "./use-intersection/index.cjs",
210
219
  "default": "./use-intersection/index.js"
211
220
  },
212
- "./use-debounced-value": {
213
- "types": "./use-debounced-value/index.d.ts",
221
+ "./use-is-client": {
222
+ "types": "./use-is-client/index.d.ts",
214
223
  "import": {
215
- "types": "./use-debounced-value/index.d.ts",
216
- "default": "./use-debounced-value/index.mjs"
224
+ "types": "./use-is-client/index.d.ts",
225
+ "default": "./use-is-client/index.mjs"
217
226
  },
218
- "require": "./use-debounced-value/index.cjs",
219
- "default": "./use-debounced-value/index.js"
227
+ "require": "./use-is-client/index.cjs",
228
+ "default": "./use-is-client/index.js"
220
229
  },
221
230
  "./use-isomorphic-layout-effect": {
222
231
  "types": "./use-isomorphic-layout-effect/index.d.ts",
@@ -254,15 +263,6 @@
254
263
  "require": "./use-next-pathname/index.cjs",
255
264
  "default": "./use-next-pathname/index.js"
256
265
  },
257
- "./use-is-client": {
258
- "types": "./use-is-client/index.d.ts",
259
- "import": {
260
- "types": "./use-is-client/index.d.ts",
261
- "default": "./use-is-client/index.mjs"
262
- },
263
- "require": "./use-is-client/index.cjs",
264
- "default": "./use-is-client/index.js"
265
- },
266
266
  "./use-react-router-enable-concurrent-navigation": {
267
267
  "types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
268
268
  "import": {
package/sizes.json CHANGED
@@ -1 +1 @@
1
- {"total":{"raw":13233,"gzip":8322,"br":0},"exports":{"compose-context-provider":{"raw":165,"gzip":150,"br":118},"context-state":{"raw":378,"gzip":243,"br":210},"no-ssr":{"raw":187,"gzip":172,"br":143},"noop":{"raw":34,"gzip":54,"br":38},"rem":{"raw":589,"gzip":331,"br":285},"request-idle-callback":{"raw":411,"gzip":232,"br":179},"typescript-happy-forward-ref":{"raw":120,"gzip":104,"br":95},"use":{"raw":277,"gzip":185,"br":155},"create-fixed-array":{"raw":101,"gzip":105,"br":89},"use-array":{"raw":338,"gzip":247,"br":207},"use-composition-input":{"raw":455,"gzip":282,"br":240},"create-context-state":{"raw":146,"gzip":116,"br":102},"use-error-boundary":{"raw":245,"gzip":197,"br":173},"use-debounced-state":{"raw":410,"gzip":291,"br":247},"use-debounced-value":{"raw":471,"gzip":313,"br":254},"use-isomorphic-layout-effect":{"raw":179,"gzip":145,"br":115},"use-clipboard":{"raw":1076,"gzip":617,"br":533},"use-map":{"raw":355,"gzip":249,"br":213},"use-is-client":{"raw":152,"gzip":144,"br":122},"use-next-pathname":{"raw":322,"gzip":242,"br":202},"use-react-router-is-match":{"raw":569,"gzip":371,"br":313},"use-react-router-enable-concurrent-navigation":{"raw":956,"gzip":455,"br":382},"use-retimer":{"raw":201,"gzip":168,"br":127},"use-set":{"raw":356,"gzip":243,"br":208},"use-singleton":{"raw":139,"gzip":131,"br":104},"use-intersection":{"raw":1239,"gzip":659,"br":605},"use-uncontrolled":{"raw":301,"gzip":232,"br":197},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":467,"gzip":326,"br":257},"use-local-storage":{"raw":1633,"gzip":753,"br":660},"use-url-hash-state":{"raw":961,"gzip":565,"br":487}}}
1
+ {"total":{"raw":13245,"gzip":8332,"br":0},"exports":{"noop":{"raw":34,"gzip":54,"br":38},"compose-context-provider":{"raw":165,"gzip":150,"br":118},"context-state":{"raw":378,"gzip":243,"br":210},"create-context-state":{"raw":146,"gzip":116,"br":102},"no-ssr":{"raw":187,"gzip":172,"br":143},"create-fixed-array":{"raw":101,"gzip":105,"br":89},"rem":{"raw":589,"gzip":331,"br":285},"use":{"raw":277,"gzip":185,"br":155},"request-idle-callback":{"raw":411,"gzip":232,"br":179},"use-array":{"raw":338,"gzip":247,"br":207},"typescript-happy-forward-ref":{"raw":120,"gzip":104,"br":95},"use-composition-input":{"raw":455,"gzip":282,"br":240},"use-debounced-state":{"raw":410,"gzip":291,"br":247},"use-debounced-value":{"raw":471,"gzip":313,"br":254},"use-clipboard":{"raw":1076,"gzip":617,"br":533},"use-error-boundary":{"raw":245,"gzip":197,"br":173},"use-is-client":{"raw":152,"gzip":144,"br":122},"use-isomorphic-layout-effect":{"raw":179,"gzip":145,"br":115},"use-map":{"raw":355,"gzip":249,"br":213},"use-next-pathname":{"raw":322,"gzip":242,"br":202},"use-intersection":{"raw":1239,"gzip":659,"br":605},"use-local-storage":{"raw":1645,"gzip":763,"br":665},"use-retimer":{"raw":201,"gzip":168,"br":127},"use-react-router-is-match":{"raw":569,"gzip":371,"br":313},"use-react-router-enable-concurrent-navigation":{"raw":956,"gzip":455,"br":382},"use-singleton":{"raw":139,"gzip":131,"br":104},"use-set":{"raw":356,"gzip":243,"br":208},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":467,"gzip":326,"br":257},"use-uncontrolled":{"raw":301,"gzip":232,"br":197},"use-url-hash-state":{"raw":961,"gzip":565,"br":487}}}
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),n=require("../noop/index.cjs"),o=require("../use-isomorphic-layout-effect/index.cjs"),r=require("../no-ssr/index.cjs");const t="foxact-local-storage",i=e=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(t,{detail:e}))},l=(e,n,o)=>{if("undefined"!=typeof window)try{window.localStorage.setItem(e,o(n))}catch(e){console.error(e)}finally{i(e)}},a=e=>{if("undefined"!=typeof window)try{window.localStorage.removeItem(e)}catch(e){console.error(e)}finally{i(e)}},s=(e,n)=>{if("undefined"==typeof window)return null;try{const o=window.localStorage.getItem(e);return null===o?null:n(o)}catch(e){return console.warn(e),null}},u=()=>{throw r.noSSRError("useLocalStorage cannot be used on the server without a serverValue")},c=e=>"function"==typeof e,d=e=>e;exports.useLocalStorage=function(r,i){var w;let f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const y=e.useCallback(e=>{if("undefined"==typeof window)return n.noop;const o=n=>{"key"in n&&n.key!==r||e()},i=n=>{n.detail===r&&e()};return window.addEventListener("storage",o),window.addEventListener(t,i),()=>{window.removeEventListener("storage",o),window.removeEventListener(t,i)}},[r]),v=f.raw?d:f.serializer,p=f.raw?d:f.deserializer,g=void 0!==i?()=>i:u,h=e.useSyncExternalStore(y,()=>s(r,p),g),S=e.useCallback(e=>{try{const n=c(e)?e(null!=h?h:null):e;null===n?a(r):l(r,n,v)}catch(e){console.warn(e)}},[r,v,h]);return o.useIsomorphicLayoutEffect(()=>{null===s(r,p)&&void 0!==i&&l(r,i,v)},[p,r,v,i]),[null!==(w=null!=h?h:i)&&void 0!==w?w:null,S]};
1
+ "use strict";require("client-only");var e=require("react"),n=require("../noop/index.cjs"),o=require("../use-isomorphic-layout-effect/index.cjs"),r=require("../no-ssr/index.cjs");const t="foxact-local-storage",i=e=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(t,{detail:e}))},l=(e,n)=>{if("undefined"!=typeof window)try{window.localStorage.setItem(e,n)}catch(e){console.error(e)}finally{i(e)}},a=e=>{if("undefined"!=typeof window)try{window.localStorage.removeItem(e)}catch(e){console.error(e)}finally{i(e)}},s=e=>{if("undefined"==typeof window)return null;try{return window.localStorage.getItem(e)}catch(e){return console.warn(e),null}},u=()=>{throw r.noSSRError("useLocalStorage cannot be used on the server without a serverValue")},c=e=>"function"==typeof e,d=e=>e;exports.useLocalStorage=function(r,i){var w;let f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const y=e.useCallback(e=>{if("undefined"==typeof window)return n.noop;const o=n=>{"key"in n&&n.key!==r||e()},i=n=>{n.detail===r&&e()};return window.addEventListener("storage",o),window.addEventListener(t,i),()=>{window.removeEventListener("storage",o),window.removeEventListener(t,i)}},[r]),v=f.raw?d:f.serializer,p=f.raw?d:f.deserializer,g=void 0!==i?()=>v(i):u,h=e.useSyncExternalStore(y,()=>s(r),g),S=e.useMemo(()=>null===h?null:p(h),[h,p]),m=e.useCallback(e=>{try{const n=c(e)?e(null!=S?S:null):e;null===n?a(r):l(r,v(n))}catch(e){console.warn(e)}},[r,v,S]);return o.useIsomorphicLayoutEffect(()=>{null===s(r)&&void 0!==i&&l(r,v(i))},[p,r,v,i]),[null!==(w=null!=S?S:i)&&void 0!==w?w:null,m]};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),n=require("../noop/index.js"),o=require("../use-isomorphic-layout-effect/index.js"),r=require("../no-ssr/index.js");const t="foxact-local-storage",i=e=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(t,{detail:e}))},l=(e,n,o)=>{if("undefined"!=typeof window)try{window.localStorage.setItem(e,o(n))}catch(e){console.error(e)}finally{i(e)}},a=e=>{if("undefined"!=typeof window)try{window.localStorage.removeItem(e)}catch(e){console.error(e)}finally{i(e)}},s=(e,n)=>{if("undefined"==typeof window)return null;try{const o=window.localStorage.getItem(e);return null===o?null:n(o)}catch(e){return console.warn(e),null}},u=()=>{throw r.noSSRError("useLocalStorage cannot be used on the server without a serverValue")},d=e=>"function"==typeof e,c=e=>e;exports.useLocalStorage=function(r,i){var w;let f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const y=e.useCallback(e=>{if("undefined"==typeof window)return n.noop;const o=n=>{"key"in n&&n.key!==r||e()},i=n=>{n.detail===r&&e()};return window.addEventListener("storage",o),window.addEventListener(t,i),()=>{window.removeEventListener("storage",o),window.removeEventListener(t,i)}},[r]),v=f.raw?c:f.serializer,p=f.raw?c:f.deserializer,g=void 0!==i?()=>i:u,h=e.useSyncExternalStore(y,()=>s(r,p),g),S=e.useCallback(e=>{try{const n=d(e)?e(null!=h?h:null):e;null===n?a(r):l(r,n,v)}catch(e){console.warn(e)}},[r,v,h]);return o.useIsomorphicLayoutEffect(()=>{null===s(r,p)&&void 0!==i&&l(r,i,v)},[p,r,v,i]),[null!==(w=null!=h?h:i)&&void 0!==w?w:null,S]};
1
+ "use strict";require("client-only");var e=require("react"),n=require("../noop/index.js"),o=require("../use-isomorphic-layout-effect/index.js"),r=require("../no-ssr/index.js");const t="foxact-local-storage",i=e=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(t,{detail:e}))},l=(e,n)=>{if("undefined"!=typeof window)try{window.localStorage.setItem(e,n)}catch(e){console.error(e)}finally{i(e)}},a=e=>{if("undefined"!=typeof window)try{window.localStorage.removeItem(e)}catch(e){console.error(e)}finally{i(e)}},s=e=>{if("undefined"==typeof window)return null;try{return window.localStorage.getItem(e)}catch(e){return console.warn(e),null}},u=()=>{throw r.noSSRError("useLocalStorage cannot be used on the server without a serverValue")},d=e=>"function"==typeof e,c=e=>e;exports.useLocalStorage=function(r,i){var w;let f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const y=e.useCallback(e=>{if("undefined"==typeof window)return n.noop;const o=n=>{"key"in n&&n.key!==r||e()},i=n=>{n.detail===r&&e()};return window.addEventListener("storage",o),window.addEventListener(t,i),()=>{window.removeEventListener("storage",o),window.removeEventListener(t,i)}},[r]),v=f.raw?c:f.serializer,p=f.raw?c:f.deserializer,g=void 0!==i?()=>v(i):u,h=e.useSyncExternalStore(y,()=>s(r),g),S=e.useMemo(()=>null===h?null:p(h),[h,p]),m=e.useCallback(e=>{try{const n=d(e)?e(null!=S?S:null):e;null===n?a(r):l(r,v(n))}catch(e){console.warn(e)}},[r,v,S]);return o.useIsomorphicLayoutEffect(()=>{null===s(r)&&void 0!==i&&l(r,v(i))},[p,r,v,i]),[null!==(w=null!=S?S:i)&&void 0!==w?w:null,m]};
@@ -1 +1 @@
1
- import"client-only";import{useCallback as e,useSyncExternalStore as n}from"react";import{noop as o}from"../noop/index.mjs";import{useIsomorphicLayoutEffect as t}from"../use-isomorphic-layout-effect/index.mjs";import{noSSRError as r}from"../no-ssr/index.mjs";const i="foxact-local-storage",l=e=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:e}))},a=(e,n,o)=>{if("undefined"!=typeof window)try{window.localStorage.setItem(e,o(n))}catch(e){console.error(e)}finally{l(e)}},d=e=>{if("undefined"!=typeof window)try{window.localStorage.removeItem(e)}catch(e){console.error(e)}finally{l(e)}},s=(e,n)=>{if("undefined"==typeof window)return null;try{const o=window.localStorage.getItem(e);return null===o?null:n(o)}catch(e){return console.warn(e),null}},w=()=>{throw r("useLocalStorage cannot be used on the server without a serverValue")},c=e=>"function"==typeof e,u=e=>e;function f(r,l){var f;let m=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const y=e(e=>{if("undefined"==typeof window)return o;const n=n=>{"key"in n&&n.key!==r||e()},t=n=>{n.detail===r&&e()};return window.addEventListener("storage",n),window.addEventListener(i,t),()=>{window.removeEventListener("storage",n),window.removeEventListener(i,t)}},[r]),p=m.raw?u:m.serializer,v=m.raw?u:m.deserializer,g=void 0!==l?()=>l:w,h=n(y,()=>s(r,v),g),S=e(e=>{try{const n=c(e)?e(null!=h?h:null):e;null===n?d(r):a(r,n,p)}catch(e){console.warn(e)}},[r,p,h]);return t(()=>{null===s(r,v)&&void 0!==l&&a(r,l,p)},[v,r,p,l]),[null!==(f=null!=h?h:l)&&void 0!==f?f:null,S]}export{f as useLocalStorage};
1
+ import"client-only";import{useCallback as e,useSyncExternalStore as n,useMemo as o}from"react";import{noop as t}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="foxact-local-storage",a=e=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(l,{detail:e}))},d=(e,n)=>{if("undefined"!=typeof window)try{window.localStorage.setItem(e,n)}catch(e){console.error(e)}finally{a(e)}},s=e=>{if("undefined"!=typeof window)try{window.localStorage.removeItem(e)}catch(e){console.error(e)}finally{a(e)}},w=e=>{if("undefined"==typeof window)return null;try{return window.localStorage.getItem(e)}catch(e){return console.warn(e),null}},u=()=>{throw i("useLocalStorage cannot be used on the server without a serverValue")},c=e=>"function"==typeof e,f=e=>e;function m(i,a){var m;let y=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{serializer:JSON.stringify,deserializer:JSON.parse};const p=e(e=>{if("undefined"==typeof window)return t;const n=n=>{"key"in n&&n.key!==i||e()},o=n=>{n.detail===i&&e()};return window.addEventListener("storage",n),window.addEventListener(l,o),()=>{window.removeEventListener("storage",n),window.removeEventListener(l,o)}},[i]),v=y.raw?f:y.serializer,g=y.raw?f:y.deserializer,h=void 0!==a?()=>v(a):u,S=n(p,()=>w(i),h),E=o(()=>null===S?null:g(S),[S,g]),L=e(e=>{try{const n=c(e)?e(null!=E?E:null):e;null===n?s(i):d(i,v(n))}catch(e){console.warn(e)}},[i,v,E]);return r(()=>{null===w(i)&&void 0!==a&&d(i,v(a))},[g,i,v,a]),[null!==(m=null!=E?E:a)&&void 0!==m?m:null,L]}export{m as useLocalStorage};