foxact 0.2.22 → 0.2.24
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/no-ssr/index.cjs +1 -0
- package/no-ssr/index.d.ts +6 -0
- package/no-ssr/index.js +1 -0
- package/no-ssr/index.mjs +1 -0
- package/package.json +38 -11
- package/sizes.json +1 -1
- package/use-local-storage/index.cjs +1 -0
- package/use-local-storage/index.d.ts +6 -0
- package/use-local-storage/index.js +1 -0
- package/use-local-storage/index.mjs +1 -0
- package/use-url-hash-state/index.cjs +1 -0
- package/use-url-hash-state/index.d.ts +5 -0
- package/use-url-hash-state/index.js +1 -0
- package/use-url-hash-state/index.mjs +1 -0
package/no-ssr/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=r=>{const o=Error(r);return o.digest="NEXT_DYNAMIC_NO_SSR_CODE",o.recoverableError="NO_SSR",o};exports.noSSR=o=>{if("undefined"==typeof window)throw r(o)},exports.noSSRError=r;
|
package/no-ssr/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=r=>{const o=Error(r);return o.digest="NEXT_DYNAMIC_NO_SSR_CODE",o.recoverableError="NO_SSR",o};exports.noSSR=o=>{if("undefined"==typeof window)throw r(o)},exports.noSSRError=r;
|
package/no-ssr/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=r=>{const o=Error(r);return o.digest="NEXT_DYNAMIC_NO_SSR_CODE",o.recoverableError="NO_SSR",o},o=o=>{if("undefined"==typeof window)throw r(o)};export{o as noSSR,r as noSSRError};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.24",
|
|
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": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/SukkaW/foxact"
|
|
8
|
+
"url": "git+https://github.com/SukkaW/foxact.git"
|
|
9
9
|
},
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/SukkaW/foxact/issues"
|
|
@@ -101,6 +101,15 @@
|
|
|
101
101
|
"require": "./create-fixed-array/index.cjs",
|
|
102
102
|
"default": "./create-fixed-array/index.js"
|
|
103
103
|
},
|
|
104
|
+
"./no-ssr": {
|
|
105
|
+
"types": "./no-ssr/index.d.ts",
|
|
106
|
+
"import": {
|
|
107
|
+
"types": "./no-ssr/index.d.ts",
|
|
108
|
+
"default": "./no-ssr/index.mjs"
|
|
109
|
+
},
|
|
110
|
+
"require": "./no-ssr/index.cjs",
|
|
111
|
+
"default": "./no-ssr/index.js"
|
|
112
|
+
},
|
|
104
113
|
"./noop": {
|
|
105
114
|
"types": "./noop/index.d.ts",
|
|
106
115
|
"import": {
|
|
@@ -218,15 +227,6 @@
|
|
|
218
227
|
"require": "./use-is-client/index.cjs",
|
|
219
228
|
"default": "./use-is-client/index.js"
|
|
220
229
|
},
|
|
221
|
-
"./use-map": {
|
|
222
|
-
"types": "./use-map/index.d.ts",
|
|
223
|
-
"import": {
|
|
224
|
-
"types": "./use-map/index.d.ts",
|
|
225
|
-
"default": "./use-map/index.mjs"
|
|
226
|
-
},
|
|
227
|
-
"require": "./use-map/index.cjs",
|
|
228
|
-
"default": "./use-map/index.js"
|
|
229
|
-
},
|
|
230
230
|
"./use-isomorphic-layout-effect": {
|
|
231
231
|
"types": "./use-isomorphic-layout-effect/index.d.ts",
|
|
232
232
|
"import": {
|
|
@@ -236,6 +236,24 @@
|
|
|
236
236
|
"require": "./use-isomorphic-layout-effect/index.cjs",
|
|
237
237
|
"default": "./use-isomorphic-layout-effect/index.js"
|
|
238
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-map": {
|
|
249
|
+
"types": "./use-map/index.d.ts",
|
|
250
|
+
"import": {
|
|
251
|
+
"types": "./use-map/index.d.ts",
|
|
252
|
+
"default": "./use-map/index.mjs"
|
|
253
|
+
},
|
|
254
|
+
"require": "./use-map/index.cjs",
|
|
255
|
+
"default": "./use-map/index.js"
|
|
256
|
+
},
|
|
239
257
|
"./use-next-pathname": {
|
|
240
258
|
"types": "./use-next-pathname/index.d.ts",
|
|
241
259
|
"import": {
|
|
@@ -307,6 +325,15 @@
|
|
|
307
325
|
},
|
|
308
326
|
"require": "./use-uncontrolled/index.cjs",
|
|
309
327
|
"default": "./use-uncontrolled/index.js"
|
|
328
|
+
},
|
|
329
|
+
"./use-url-hash-state": {
|
|
330
|
+
"types": "./use-url-hash-state/index.d.ts",
|
|
331
|
+
"import": {
|
|
332
|
+
"types": "./use-url-hash-state/index.d.ts",
|
|
333
|
+
"default": "./use-url-hash-state/index.mjs"
|
|
334
|
+
},
|
|
335
|
+
"require": "./use-url-hash-state/index.cjs",
|
|
336
|
+
"default": "./use-url-hash-state/index.js"
|
|
310
337
|
}
|
|
311
338
|
}
|
|
312
339
|
}
|
package/sizes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"total":{"raw":
|
|
1
|
+
{"total":{"raw":12922,"gzip":8186,"br":0},"exports":{"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},"create-fixed-array":{"raw":101,"gzip":105,"br":89},"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},"use-array":{"raw":338,"gzip":247,"br":207},"use-clipboard":{"raw":1076,"gzip":617,"br":533},"use-debounced-state":{"raw":410,"gzip":291,"br":247},"use-debounced-value":{"raw":471,"gzip":313,"br":254},"use-intersection":{"raw":1239,"gzip":659,"br":605},"use-isomorphic-layout-effect":{"raw":179,"gzip":145,"br":115},"use-local-storage":{"raw":1322,"gzip":617,"br":537},"use-is-client":{"raw":152,"gzip":144,"br":122},"use-error-boundary":{"raw":245,"gzip":197,"br":173},"use-next-pathname":{"raw":322,"gzip":242,"br":202},"use-react-router-enable-concurrent-navigation":{"raw":956,"gzip":455,"br":382},"use-react-router-is-match":{"raw":569,"gzip":371,"br":313},"use-retimer":{"raw":201,"gzip":168,"br":127},"use-composition-input":{"raw":455,"gzip":282,"br":240},"use-map":{"raw":355,"gzip":249,"br":213},"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-set":{"raw":356,"gzip":243,"br":208},"use-url-hash-state":{"raw":961,"gzip":565,"br":487},"use-singleton":{"raw":139,"gzip":131,"br":104}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("react"),n=require("../noop/index.cjs"),o=require("../use-isomorphic-layout-effect/index.cjs"),t=require("../no-ssr/index.cjs");function r(e,n){"undefined"!=typeof window&&window.dispatchEvent(new StorageEvent("storage",{key:e,newValue:n}))}require("client-only");const i=(e,n)=>{if("undefined"!=typeof window){const o=JSON.stringify(n);try{window.localStorage.setItem(e,o)}catch(e){console.error(e)}finally{r(e,o)}}},l=e=>{if("undefined"!=typeof window)try{window.localStorage.removeItem(e)}catch(e){console.error(e)}finally{r(e,null)}},c=e=>{if("undefined"!=typeof window)try{const n=window.localStorage.getItem(e);if(n)return JSON.parse(n);return n}catch(e){console.warn(e)}return null},u=e=>"undefined"!=typeof window?(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)):n.noop,s=()=>{throw t.noSSRError("useLocalStorage cannot be used on the server without a serverValue")},a=e=>"function"==typeof e;exports.useLocalStorage=function(n,t){var r;const d=void 0!==t?()=>t:s,w=e.useSyncExternalStore(u,()=>c(n),d),f=e.useCallback(e=>{try{const o=a(e)?e(null!=w?w:null):e;null==o?l(n):i(n,o)}catch(e){console.warn(e)}},[n,w]);return o.useIsomorphicLayoutEffect(()=>{null===c(n)&&void 0!==t&&i(n,t)},[n,t]),[null!==(r=null!=w?w:t)&&void 0!==r?r:null,f]};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
/** @see https://foxact.skk.moe/use-local-storage */
|
|
4
|
+
declare function useLocalStorage<T extends string | number>(key: string, serverValue?: T): readonly [T | null, react.Dispatch<react.SetStateAction<T | null>>];
|
|
5
|
+
|
|
6
|
+
export { useLocalStorage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("react"),n=require("../noop/index.js"),o=require("../use-isomorphic-layout-effect/index.js"),t=require("../no-ssr/index.js");function r(e,n){"undefined"!=typeof window&&window.dispatchEvent(new StorageEvent("storage",{key:e,newValue:n}))}require("client-only");const i=(e,n)=>{if("undefined"!=typeof window){const o=JSON.stringify(n);try{window.localStorage.setItem(e,o)}catch(e){console.error(e)}finally{r(e,o)}}},l=e=>{if("undefined"!=typeof window)try{window.localStorage.removeItem(e)}catch(e){console.error(e)}finally{r(e,null)}},u=e=>{if("undefined"!=typeof window)try{const n=window.localStorage.getItem(e);if(n)return JSON.parse(n);return n}catch(e){console.warn(e)}return null},s=e=>"undefined"!=typeof window?(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)):n.noop,a=()=>{throw t.noSSRError("useLocalStorage cannot be used on the server without a serverValue")},c=e=>"function"==typeof e;exports.useLocalStorage=function(n,t){var r;const d=void 0!==t?()=>t:a,w=e.useSyncExternalStore(s,()=>u(n),d),f=e.useCallback(e=>{try{const o=c(e)?e(null!=w?w:null):e;null==o?l(n):i(n,o)}catch(e){console.warn(e)}},[n,w]);return o.useIsomorphicLayoutEffect(()=>{null===u(n)&&void 0!==t&&i(n,t)},[n,t]),[null!==(r=null!=w?w:t)&&void 0!==r?r:null,f]};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSyncExternalStore as o,useCallback as e}from"react";import{noop as n}from"../noop/index.mjs";import{useIsomorphicLayoutEffect as t}from"../use-isomorphic-layout-effect/index.mjs";import{noSSRError as r}from"../no-ssr/index.mjs";import"client-only";function i(o,e){"undefined"!=typeof window&&window.dispatchEvent(new StorageEvent("storage",{key:o,newValue:e}))}const l=(o,e)=>{if("undefined"!=typeof window){const n=JSON.stringify(e);try{window.localStorage.setItem(o,n)}catch(o){console.error(o)}finally{i(o,n)}}},a=o=>{if("undefined"!=typeof window)try{window.localStorage.removeItem(o)}catch(o){console.error(o)}finally{i(o,null)}},c=o=>{if("undefined"!=typeof window)try{const e=window.localStorage.getItem(o);if(e)return JSON.parse(e);return e}catch(o){console.warn(o)}return null},d=o=>"undefined"!=typeof window?(window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)):n,s=()=>{throw r("useLocalStorage cannot be used on the server without a serverValue")},u=o=>"function"==typeof o;function f(n,r){var i;const f=void 0!==r?()=>r:s,w=o(d,()=>c(n),f),m=e(o=>{try{const e=u(o)?o(null!=w?w:null):o;null==e?a(n):l(n,e)}catch(o){console.warn(o)}},[n,w]);return t(()=>{null===c(n)&&void 0!==r&&l(n,r)},[n,r]),[null!==(i=null!=w?w:r)&&void 0!==i?i:null,m]}export{f as useLocalStorage};
|
|
@@ -0,0 +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])]};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** @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>>];
|
|
4
|
+
|
|
5
|
+
export { useUrlHashState as unstable_useUrlHashState };
|
|
@@ -0,0 +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])]};
|
|
@@ -0,0 +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};
|