foxact 0.2.51 → 0.2.52
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/context-reducer/index.cjs +1 -0
- package/context-reducer/index.d.ts +55 -0
- package/context-reducer/index.mjs +1 -0
- package/create-context-reducer/index.cjs +1 -0
- package/create-context-reducer/index.d.ts +1 -0
- package/create-context-reducer/index.mjs +1 -0
- package/create-storage-hook/index.cjs +1 -1
- package/create-storage-hook/index.mjs +1 -1
- package/current-year/index.cjs +1 -1
- package/current-year/index.mjs +1 -1
- package/fetch-jsonp/index.cjs +1 -1
- package/fetch-jsonp/index.mjs +1 -1
- package/is-safari/index.cjs +1 -1
- package/is-safari/index.mjs +1 -1
- package/magic-portal/index.cjs +1 -1
- package/magic-portal/index.mjs +1 -1
- package/no-ssr/index.cjs +1 -1
- package/no-ssr/index.mjs +1 -1
- package/open-new-tab/index.cjs +1 -1
- package/open-new-tab/index.mjs +1 -1
- package/package.json +51 -29
- package/request-idle-callback/index.cjs +1 -1
- package/request-idle-callback/index.mjs +1 -1
- package/sizes.json +1 -1
- package/use-is-online/index.cjs +1 -1
- package/use-is-online/index.mjs +1 -1
- package/use-isomorphic-layout-effect/index.cjs +1 -1
- package/use-isomorphic-layout-effect/index.mjs +1 -1
- package/use-media-query/index.cjs +1 -1
- package/use-media-query/index.mjs +1 -1
- package/use-next-link/index.cjs +1 -1
- package/use-next-link/index.mjs +1 -1
- package/use-page-visibility/index.cjs +1 -1
- package/use-page-visibility/index.mjs +1 -1
- package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs +1 -1
- package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs +1 -1
- package/use-url-hash-state/index.cjs +1 -1
- package/use-url-hash-state/index.mjs +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime");require("client-only");var r=require("react"),t=require("../noop/index.cjs"),n=require("../chunks/index.b9dLwVor.cjs"),u=require("../chunks/index.BtiK5_Nn.cjs");exports.createContextReducer=function(i,c,o){let s;s=u.n(o)?o(c):c;const l=r.createContext(s),x=r.createContext(t.noop);return[t=>{var u;let{children:s,initialArg:a,init:d}=t;const v=null!=a?a:c,j=null!=(u=null!=d?d:o)?u:n.t,[q,C]=r.useReducer(i,v,j);return e.jsx(l.Provider,{value:q,children:e.jsx(x.Provider,{value:C,children:s})})},()=>r.useContext(l),()=>r.useContext(x),l]};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://foxact.skk.moe/context-reducer
|
|
3
|
+
*
|
|
4
|
+
* Option 1:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* createContextReducer<S, A, I = S>(reducer, initialArg: I, init?: (arg: I) => S)
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
declare function createContextReducer<S, A, I = S>(reducer: (state: S, action: A) => S, initialArg: I, init?: (arg: I) => S): [
|
|
11
|
+
Provider: React.ComponentType<React.PropsWithChildren>,
|
|
12
|
+
useValue: () => S,
|
|
13
|
+
useDispatch: () => React.Dispatch<A>,
|
|
14
|
+
StateContext: React.Context<S>
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* @see https://foxact.skk.moe/context-reducer
|
|
18
|
+
*
|
|
19
|
+
* Option 2:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* createContextReducer<S, A, I = S>(reducer, initialArg?: I, init?: (arg: I) => S)
|
|
23
|
+
* ```
|
|
24
|
+
* Call `initialArg`/`init` in `<Provider>` is optional
|
|
25
|
+
*/
|
|
26
|
+
declare function createContextReducer<S, A, I = S>(reducer: (state: S, action: A) => S, initialArg?: I, init?: (arg: I) => S): [
|
|
27
|
+
Provider: React.ComponentType<React.PropsWithChildren<{
|
|
28
|
+
initialArg?: I;
|
|
29
|
+
init?: (arg: I) => S;
|
|
30
|
+
}>>,
|
|
31
|
+
useValue: () => S,
|
|
32
|
+
useDispatch: () => React.Dispatch<A>,
|
|
33
|
+
StateContext: React.Context<S>
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* @see https://foxact.skk.moe/context-reducer
|
|
37
|
+
*
|
|
38
|
+
* Option 3:
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* createContextReducer<S, A, I = S>(reducer)
|
|
42
|
+
* ```
|
|
43
|
+
* Provide `initialArg` and/or `init` via `<Provider initialArg={...} init={...}>`
|
|
44
|
+
*/
|
|
45
|
+
declare function createContextReducer<S, A, I = S>(reducer: (state: S, action: A) => S): [
|
|
46
|
+
Provider: React.ComponentType<React.PropsWithChildren<Required<{
|
|
47
|
+
initialArg?: I;
|
|
48
|
+
init?: (arg: I) => S;
|
|
49
|
+
}>>>,
|
|
50
|
+
useValue: () => S,
|
|
51
|
+
useDispatch: () => React.Dispatch<A>,
|
|
52
|
+
StateContext: React.Context<S>
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
export { createContextReducer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import"client-only";import{useContext as n,createContext as e,useReducer as t}from"react";import{noop as i}from"../noop/index.mjs";import{t as o}from"../chunks/index.D0KaUCcV.mjs";import{n as m}from"../chunks/index.C9-3oDdv.mjs";function l(l,c,u){const d=e(m(u)?u(c):c),p=e(i);return[n=>{var e;let{children:i,initialArg:m,init:s}=n;const[a,f]=t(l,null!=m?m:c,null!=(e=null!=s?s:u)?e:o);return r(d.Provider,{value:a,children:r(p.Provider,{value:f,children:i})})},()=>n(d),()=>n(p),d]}export{l as createContextReducer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../context-reducer/index.cjs");require("react/jsx-runtime"),require("client-only"),require("react"),require("../noop/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs"),exports.createContextReducer=e.createContextReducer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createContextReducer } from '../context-reducer/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{createContextReducer}from"../context-reducer/index.mjs";import"react/jsx-runtime";import"client-only";import"react";import"../noop/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),o=require("../noop/index.cjs"),t=require("../use-isomorphic-layout-effect/index.cjs"),n=require("../no-ssr/index.cjs"),r=require("../chunks/index.b9dLwVor.cjs"),a=require("../chunks/index.BtiK5_Nn.cjs");function i(){throw n.noSSRError("useLocalStorage cannot be used on the server without a serverValue")}exports.createStorage=function(n){const l="localStorage"===n?"foxact-use-local-storage":"foxact-use-session-storage",s="localStorage"===n?"foxact/use-local-storage":"foxact/use-session-storage",c="u"<typeof window?o.noop:e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))},u="u"<typeof window?o.noop:(e,o)=>{try{window[n].setItem(e,o)}catch(e){console.warn("[".concat(s,"] Failed to set value to ").concat(n,", it might be blocked"))}finally{c(e)}},d="u"<typeof window?o.noop:e=>{try{window[n].removeItem(e)}catch(e){console.warn("[".concat(s,"] Failed to remove value from ").concat(n,", it might be blocked"))}finally{c(e)}},w=e=>{if("u"<typeof window)return null;try{return window[n].getItem(e)}catch(e){return console.warn("[".concat(s,"] Failed to get value from ").concat(n,", it might be blocked")),null}};return{useStorage:function(n,s){let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const f=e.useCallback(e=>{if("u"<typeof window)return o.noop;const t=o=>{"key"in o&&o.key!==n||e()},r=o=>{o.detail===n&&e()};return window.addEventListener("storage",t),window.addEventListener(l,r),()=>{window.removeEventListener("storage",t),window.removeEventListener(l,r)}},[n]),v=c.raw?r.t:c.serializer,g=c.raw?r.t:c.deserializer,y=void 0===s?i:()=>v(s),h=e.useSyncExternalStore(f,()=>w(n),y),m=e.useMemo(()=>null===h?null:g(h),[h,g]),p=e.useCallback(e=>{try{const o=a.n(e)?e(null!=m?m:null):e;null===o?d(n):u(n,v(o))}catch(e){console.warn(e)}},[n,v,m]);return t.useLayoutEffect(()=>{null===w(n)&&void 0!==s&&u(n,v(s))},[g,n,v,s]),[null===m?void 0===s?null:s:m,p]},useSetStorage:(o,t)=>e.useCallback(e=>{try{null===e?d(o):u(o,t(e))}catch(e){console.warn(e)}},[o,t])}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useCallback as e,useSyncExternalStore as o,useMemo as t}from"react";import{noop as n}from"../noop/index.mjs";import{useLayoutEffect as r}from"../use-isomorphic-layout-effect/index.mjs";import{noSSRError as i}from"../no-ssr/index.mjs";import{t as a}from"../chunks/index.D0KaUCcV.mjs";import{n as l}from"../chunks/index.C9-3oDdv.mjs";function s(){throw i("useLocalStorage cannot be used on the server without a serverValue")}function c(i){const c="localStorage"===i?"foxact-use-local-storage":"foxact-use-session-storage",
|
|
1
|
+
import"client-only";import{useCallback as e,useSyncExternalStore as o,useMemo as t}from"react";import{noop as n}from"../noop/index.mjs";import{useLayoutEffect as r}from"../use-isomorphic-layout-effect/index.mjs";import{noSSRError as i}from"../no-ssr/index.mjs";import{t as a}from"../chunks/index.D0KaUCcV.mjs";import{n as l}from"../chunks/index.C9-3oDdv.mjs";function s(){throw i("useLocalStorage cannot be used on the server without a serverValue")}function c(i){const c="localStorage"===i?"foxact-use-local-storage":"foxact-use-session-storage",u="localStorage"===i?"foxact/use-local-storage":"foxact/use-session-storage",d="u"<typeof window?n:e=>{window.dispatchEvent(new CustomEvent(c,{detail:e}))},w="u"<typeof window?n:(e,o)=>{try{window[i].setItem(e,o)}catch(e){console.warn("[".concat(u,"] Failed to set value to ").concat(i,", it might be blocked"))}finally{d(e)}},m="u"<typeof window?n:e=>{try{window[i].removeItem(e)}catch(e){console.warn("[".concat(u,"] Failed to remove value from ").concat(i,", it might be blocked"))}finally{d(e)}},f=e=>{if("u"<typeof window)return null;try{return window[i].getItem(e)}catch(e){return console.warn("[".concat(u,"] Failed to get value from ").concat(i,", it might be blocked")),null}};return{useStorage:function(i,u){let d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const g=e(e=>{if("u"<typeof window)return n;const o=o=>{"key"in o&&o.key!==i||e()},t=o=>{o.detail===i&&e()};return window.addEventListener("storage",o),window.addEventListener(c,t),()=>{window.removeEventListener("storage",o),window.removeEventListener(c,t)}},[i]),v=d.raw?a:d.serializer,p=d.raw?a:d.deserializer,y=o(g,()=>f(i),void 0===u?s:()=>v(u)),h=t(()=>null===y?null:p(y),[y,p]),x=e(e=>{try{const o=l(e)?e(null!=h?h:null):e;null===o?m(i):w(i,v(o))}catch(e){console.warn(e)}},[i,v,h]);return r(()=>{null===f(i)&&void 0!==u&&w(i,v(u))},[p,i,v,u]),[null===h?void 0===u?null:u:h,x]},useSetStorage:(o,t)=>e(e=>{try{null===e?m(o):w(o,t(e))}catch(e){console.warn(e)}},[o,t])}}export{c as createStorage};
|
package/current-year/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../use-isomorphic-layout-effect/index.cjs");require("client-only");const n=r.memo(n=>{let{defaultYear:i
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../use-isomorphic-layout-effect/index.cjs");require("client-only");const n=r.memo(n=>{let{defaultYear:u,...i}=n;"u"<typeof window&&void 0===u&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[s,a]=r.useState(u||new Date().getFullYear());return t.useIsomorphicLayoutEffect(()=>{a(new Date().getFullYear())},[]),e.jsx("span",{...i,children:s})});"production"!==process.env.NODE_ENV&&(n.displayName="CurrentYear"),exports.CurrentYear=n;
|
package/current-year/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import{memo as r,useState as t}from"react";import{useIsomorphicLayoutEffect as
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import{memo as r,useState as t}from"react";import{useIsomorphicLayoutEffect as o}from"../use-isomorphic-layout-effect/index.mjs";import"client-only";const n=r(r=>{let{defaultYear:n,...i}=r;"u"<typeof window&&void 0===n&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[a,s]=t(n||new Date().getFullYear());return o(()=>{s(new Date().getFullYear())},[]),e("span",{...i,children:a})});"production"!==process.env.NODE_ENV&&(n.displayName="CurrentYear");export{n as CurrentYear};
|
package/fetch-jsonp/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e="__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";exports.fetchJsonp=function(o,n){if("
|
|
1
|
+
"use strict";const e="__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";exports.fetchJsonp=function(o,n){if("u"<typeof window)throw TypeError("fetchJsonp is only available in the browser");window[e]||Object.defineProperty(window,e,{value:{},writable:!0,configurable:!0,enumerable:!1});const t="__".concat(Date.now(),"_").concat(Math.random().toString().slice(2),"__"),r="window.".concat(e,".").concat(t);if(Object.prototype.hasOwnProperty.call(window[e],t))throw TypeError("Callback name conflict: ".concat(t));const c=o(r);return new Promise((o,r)=>{const a=document.createElement("script");a.src=c,a.async=!0,n&&Object.assign(a,n);const i=()=>{a.removeEventListener("error",s),a.remove(),window[e][t]&&delete window[e][t]};function s(){i(),r(Error("Failed to load script: ".concat(c)))}a.addEventListener("error",s),window[e][t]=e=>{i(),o(e)},document.body.append(a)})};
|
package/fetch-jsonp/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const o="__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";function e(e,n){if("u"<typeof window)throw TypeError("fetchJsonp is only available in the browser");window[o]||Object.defineProperty(window,o,{value:{},writable:!0,configurable:!0,enumerable:!1});const t="__".concat(Date.now(),"_").concat(Math.random().toString().slice(2),"__"),r="window.".concat(o,".").concat(t);if(Object.prototype.hasOwnProperty.call(window[o],t))throw TypeError("Callback name conflict: ".concat(t));const c=e(r);return new Promise((e,r)=>{const a=document.createElement("script");a.src=c,a.async=!0,n&&Object.assign(a,n);const i=()=>{a.removeEventListener("error",w),a.remove(),window[o][t]&&delete window[o][t]};function w(){i(),r(Error("Failed to load script: ".concat(c)))}a.addEventListener("error",w),window[o][t]=o=>{i(),e(o)},document.body.append(a)})}export{e as fetchJsonp};
|
package/is-safari/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.isSafari=function(){return"
|
|
1
|
+
"use strict";exports.isSafari=function(){return!("u"<typeof window||"u"<typeof navigator)&&"string"==typeof navigator.userAgent&&!!(/version\/[\d._].*?safari/i.test(navigator.userAgent)||/mobile safari [\d._]+/i.test(navigator.userAgent))};
|
package/is-safari/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function t(){return!("u"<typeof window||"u"<typeof navigator)&&"string"==typeof navigator.userAgent&&!!(/version\/[\d._].*?safari/i.test(navigator.userAgent)||/mobile safari [\d._]+/i.test(navigator.userAgent))}export{t as isSafari};
|
package/magic-portal/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime");require("client-only");var r=require("react-dom"),t=require("../context-state/index.cjs"),n=require("../no-ssr/index.cjs"),o=require("react");require("../noop/index.cjs"),exports.createMagicPortal=function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[i,l,a]=t.createContextState(null);function s(r){let{as:t,ssrFallback:o=null,...i}=r;null!=o&&n.noSSR();const l=a();return e.jsx(t||"div",{...c?{"data-foxact-magic-portal-target":c}:{},ref:l,...i})}function u(r){const{ssrFallback:t=null}=r;return null!=t?e.jsx(o.Suspense,{fallback:t,children:e.jsx(s,{...r})}):e.jsx(s,{...r})}function d(e){let{children:t}=e;const n=l();return"
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime");require("client-only");var r=require("react-dom"),t=require("../context-state/index.cjs"),n=require("../no-ssr/index.cjs"),o=require("react");require("../noop/index.cjs"),exports.createMagicPortal=function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[i,l,a]=t.createContextState(null);function s(r){let{as:t,ssrFallback:o=null,...i}=r;null!=o&&n.noSSR();const l=a();return e.jsx(t||"div",{...c?{"data-foxact-magic-portal-target":c}:{},ref:l,...i})}function u(r){const{ssrFallback:t=null}=r;return null!=t?e.jsx(o.Suspense,{fallback:t,children:e.jsx(s,{...r})}):e.jsx(s,{...r})}function d(e){let{children:t}=e;const n=l();return"u"<typeof window||!n?null:r.createPortal(t,n)}function p(r){let{children:t}=r;return e.jsx(i,{children:t})}return"production"!==process.env.NODE_ENV&&(u.displayName=c+".PortalTarget"),"production"!==process.env.NODE_ENV&&(d.displayName=c+".PortalContent"),"production"!==process.env.NODE_ENV&&(p.displayName=c+".PortalProvider"),[p,u,d]};
|
package/magic-portal/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import"client-only";import{createPortal as o}from"react-dom";import{createContextState as n}from"../context-state/index.mjs";import{noSSR as r}from"../no-ssr/index.mjs";import{Suspense as e}from"react";import"../noop/index.mjs";function i(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[l,c,a]=n(null);function m(o){let{as:n,ssrFallback:e=null,...l}=o;null!=e&&r();const c=a();return t(n||"div",{...i?{"data-foxact-magic-portal-target":i}:{},ref:c,...l})}function u(o){const{ssrFallback:n=null}=o;return null!=n?t(e,{fallback:n,children:t(m,{...o})}):t(m,{...o})}function s(t){let{children:n}=t;const r=c();return"
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import"client-only";import{createPortal as o}from"react-dom";import{createContextState as n}from"../context-state/index.mjs";import{noSSR as r}from"../no-ssr/index.mjs";import{Suspense as e}from"react";import"../noop/index.mjs";function i(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[l,c,a]=n(null);function m(o){let{as:n,ssrFallback:e=null,...l}=o;null!=e&&r();const c=a();return t(n||"div",{...i?{"data-foxact-magic-portal-target":i}:{},ref:c,...l})}function u(o){const{ssrFallback:n=null}=o;return null!=n?t(e,{fallback:n,children:t(m,{...o})}):t(m,{...o})}function s(t){let{children:n}=t;const r=c();return"u"<typeof window||!r?null:o(n,r)}function p(o){let{children:n}=o;return t(l,{children:n})}return"production"!==process.env.NODE_ENV&&(u.displayName=i+".PortalTarget"),"production"!==process.env.NODE_ENV&&(s.displayName=i+".PortalContent"),"production"!==process.env.NODE_ENV&&(p.displayName=i+".PortalProvider"),[p,u,s]}export{i as createMagicPortal};
|
package/no-ssr/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit"),t=(null==r?void 0:r.writable)&&"number"==typeof r.value;function
|
|
1
|
+
"use strict";const r=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit"),t=(null==r?void 0:r.writable)&&"number"==typeof r.value;function o(r){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING";const e=Error.stackTraceLimit;t&&(Error.stackTraceLimit=0);const i=Error(r);return t&&(Error.stackTraceLimit=e),i.digest=o,i.recoverableError="NO_SSR",i}exports.noSSR=function(r){if("u"<typeof window)throw o(r)},exports.noSSRError=o;
|
package/no-ssr/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const r=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit"),t=(null==r?void 0:r.writable)&&"number"==typeof r.value;function o(r){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING";const e=Error.stackTraceLimit;t&&(Error.stackTraceLimit=0);const i=Error(r);return t&&(Error.stackTraceLimit=e),i.digest=o,i.recoverableError="NO_SSR",i}function e(r){if("
|
|
1
|
+
const r=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit"),t=(null==r?void 0:r.writable)&&"number"==typeof r.value;function o(r){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING";const e=Error.stackTraceLimit;t&&(Error.stackTraceLimit=0);const i=Error(r);return t&&(Error.stackTraceLimit=e),i.digest=o,i.recoverableError="NO_SSR",i}function e(r){if("u"<typeof window)throw o(r)}export{e as noSSR,o as noSSRError};
|
package/open-new-tab/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../is-safari/index.cjs");exports.openInNewTab=function(
|
|
1
|
+
"use strict";var e=require("../is-safari/index.cjs");exports.openInNewTab=function(r){if("u"<typeof window)return;if(e.isSafari())return void window.open(r,"_blank");const n=document.createElement("a");n.href=r,n.target="_blank",n.rel="noopener noreferrer",document.body.appendChild(n),n.click(),Promise.resolve().finally(()=>{n.remove()})};
|
package/open-new-tab/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isSafari as e}from"../is-safari/index.mjs";function n(n){if("
|
|
1
|
+
import{isSafari as e}from"../is-safari/index.mjs";function n(n){if("u"<typeof window)return;if(e())return void window.open(n,"_blank");const o=document.createElement("a");o.href=n,o.target="_blank",o.rel="noopener noreferrer",document.body.appendChild(o),o.click(),Promise.resolve().finally(()=>{o.remove()})}export{n as openInNewTab};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.52",
|
|
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": {
|
|
@@ -25,11 +25,15 @@
|
|
|
25
25
|
"server-only": "^0.0.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"react": "*"
|
|
28
|
+
"react": "*",
|
|
29
|
+
"react-dom": "*"
|
|
29
30
|
},
|
|
30
31
|
"peerDependenciesMeta": {
|
|
31
32
|
"react": {
|
|
32
33
|
"optional": true
|
|
34
|
+
},
|
|
35
|
+
"react-dom": {
|
|
36
|
+
"optional": true
|
|
33
37
|
}
|
|
34
38
|
},
|
|
35
39
|
"typeVersions": {
|
|
@@ -56,6 +60,24 @@
|
|
|
56
60
|
"require": "./compose-context-provider/index.cjs",
|
|
57
61
|
"default": "./compose-context-provider/index.cjs"
|
|
58
62
|
},
|
|
63
|
+
"./context-reducer": {
|
|
64
|
+
"types": "./context-reducer/index.d.ts",
|
|
65
|
+
"import": {
|
|
66
|
+
"types": "./context-reducer/index.d.ts",
|
|
67
|
+
"default": "./context-reducer/index.mjs"
|
|
68
|
+
},
|
|
69
|
+
"require": "./context-reducer/index.cjs",
|
|
70
|
+
"default": "./context-reducer/index.cjs"
|
|
71
|
+
},
|
|
72
|
+
"./create-context-reducer": {
|
|
73
|
+
"types": "./create-context-reducer/index.d.ts",
|
|
74
|
+
"import": {
|
|
75
|
+
"types": "./create-context-reducer/index.d.ts",
|
|
76
|
+
"default": "./create-context-reducer/index.mjs"
|
|
77
|
+
},
|
|
78
|
+
"require": "./create-context-reducer/index.cjs",
|
|
79
|
+
"default": "./create-context-reducer/index.cjs"
|
|
80
|
+
},
|
|
59
81
|
"./context-state": {
|
|
60
82
|
"types": "./context-state/index.d.ts",
|
|
61
83
|
"import": {
|
|
@@ -65,15 +87,6 @@
|
|
|
65
87
|
"require": "./context-state/index.cjs",
|
|
66
88
|
"default": "./context-state/index.cjs"
|
|
67
89
|
},
|
|
68
|
-
"./create-context-state": {
|
|
69
|
-
"types": "./create-context-state/index.d.ts",
|
|
70
|
-
"import": {
|
|
71
|
-
"types": "./create-context-state/index.d.ts",
|
|
72
|
-
"default": "./create-context-state/index.mjs"
|
|
73
|
-
},
|
|
74
|
-
"require": "./create-context-state/index.cjs",
|
|
75
|
-
"default": "./create-context-state/index.cjs"
|
|
76
|
-
},
|
|
77
90
|
"./create-fixed-array": {
|
|
78
91
|
"types": "./create-fixed-array/index.d.ts",
|
|
79
92
|
"import": {
|
|
@@ -92,6 +105,15 @@
|
|
|
92
105
|
"require": "./create-local-storage-state/index.cjs",
|
|
93
106
|
"default": "./create-local-storage-state/index.cjs"
|
|
94
107
|
},
|
|
108
|
+
"./create-context-state": {
|
|
109
|
+
"types": "./create-context-state/index.d.ts",
|
|
110
|
+
"import": {
|
|
111
|
+
"types": "./create-context-state/index.d.ts",
|
|
112
|
+
"default": "./create-context-state/index.mjs"
|
|
113
|
+
},
|
|
114
|
+
"require": "./create-context-state/index.cjs",
|
|
115
|
+
"default": "./create-context-state/index.cjs"
|
|
116
|
+
},
|
|
95
117
|
"./create-magic-portal": {
|
|
96
118
|
"types": "./create-magic-portal/index.d.ts",
|
|
97
119
|
"import": {
|
|
@@ -119,15 +141,6 @@
|
|
|
119
141
|
"require": "./create-storage-hook/index.cjs",
|
|
120
142
|
"default": "./create-storage-hook/index.cjs"
|
|
121
143
|
},
|
|
122
|
-
"./current-year": {
|
|
123
|
-
"types": "./current-year/index.d.ts",
|
|
124
|
-
"import": {
|
|
125
|
-
"types": "./current-year/index.d.ts",
|
|
126
|
-
"default": "./current-year/index.mjs"
|
|
127
|
-
},
|
|
128
|
-
"require": "./current-year/index.cjs",
|
|
129
|
-
"default": "./current-year/index.cjs"
|
|
130
|
-
},
|
|
131
144
|
"./create-storage-state-factory": {
|
|
132
145
|
"types": "./create-storage-state-factory/index.d.ts",
|
|
133
146
|
"import": {
|
|
@@ -137,6 +150,15 @@
|
|
|
137
150
|
"require": "./create-storage-state-factory/index.cjs",
|
|
138
151
|
"default": "./create-storage-state-factory/index.cjs"
|
|
139
152
|
},
|
|
153
|
+
"./current-year": {
|
|
154
|
+
"types": "./current-year/index.d.ts",
|
|
155
|
+
"import": {
|
|
156
|
+
"types": "./current-year/index.d.ts",
|
|
157
|
+
"default": "./current-year/index.mjs"
|
|
158
|
+
},
|
|
159
|
+
"require": "./current-year/index.cjs",
|
|
160
|
+
"default": "./current-year/index.cjs"
|
|
161
|
+
},
|
|
140
162
|
"./email-protection": {
|
|
141
163
|
"types": "./email-protection/index.d.ts",
|
|
142
164
|
"import": {
|
|
@@ -164,15 +186,6 @@
|
|
|
164
186
|
"require": "./invariant/index.cjs",
|
|
165
187
|
"default": "./invariant/index.cjs"
|
|
166
188
|
},
|
|
167
|
-
"./is-safari": {
|
|
168
|
-
"types": "./is-safari/index.d.ts",
|
|
169
|
-
"import": {
|
|
170
|
-
"types": "./is-safari/index.d.ts",
|
|
171
|
-
"default": "./is-safari/index.mjs"
|
|
172
|
-
},
|
|
173
|
-
"require": "./is-safari/index.cjs",
|
|
174
|
-
"default": "./is-safari/index.cjs"
|
|
175
|
-
},
|
|
176
189
|
"./magic-portal": {
|
|
177
190
|
"types": "./magic-portal/index.d.ts",
|
|
178
191
|
"import": {
|
|
@@ -182,6 +195,15 @@
|
|
|
182
195
|
"require": "./magic-portal/index.cjs",
|
|
183
196
|
"default": "./magic-portal/index.cjs"
|
|
184
197
|
},
|
|
198
|
+
"./is-safari": {
|
|
199
|
+
"types": "./is-safari/index.d.ts",
|
|
200
|
+
"import": {
|
|
201
|
+
"types": "./is-safari/index.d.ts",
|
|
202
|
+
"default": "./is-safari/index.mjs"
|
|
203
|
+
},
|
|
204
|
+
"require": "./is-safari/index.cjs",
|
|
205
|
+
"default": "./is-safari/index.cjs"
|
|
206
|
+
},
|
|
185
207
|
"./no-ssr": {
|
|
186
208
|
"types": "./no-ssr/index.d.ts",
|
|
187
209
|
"import": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e="
|
|
1
|
+
"use strict";const e="u">typeof self&&self.requestIdleCallback&&self.requestIdleCallback.bind(self)||function(e){const l=Date.now();return self.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-l))})},1)},l="u">typeof self&&self.cancelIdleCallback&&self.cancelIdleCallback.bind(self)||function(e){return clearTimeout(e)};exports.cancelIdleCallback=l,exports.requestIdleCallback=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="
|
|
1
|
+
const e="u">typeof self&&self.requestIdleCallback&&self.requestIdleCallback.bind(self)||function(e){const l=Date.now();return self.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-l))})},1)},l="u">typeof self&&self.cancelIdleCallback&&self.cancelIdleCallback.bind(self)||function(e){return clearTimeout(e)};export{l as cancelIdleCallback,e as requestIdleCallback};
|
package/sizes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"total":{"raw":
|
|
1
|
+
{"total":{"raw":26128,"gzip":15892,"br":0},"exports":{"compose-context-provider":{"raw":177,"gzip":155,"br":122},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"context-reducer":{"raw":557,"gzip":331,"br":299},"context-state":{"raw":402,"gzip":259,"br":221},"create-magic-portal":{"raw":224,"gzip":136,"br":112},"create-local-storage-state":{"raw":402,"gzip":216,"br":189},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-context-state":{"raw":145,"gzip":116,"br":96},"current-year":{"raw":583,"gzip":395,"br":323},"create-storage-state-factory":{"raw":592,"gzip":338,"br":304},"create-session-storage-state":{"raw":406,"gzip":215,"br":188},"invariant":{"raw":178,"gzip":156,"br":118},"email-protection":{"raw":426,"gzip":321,"br":272},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"is-safari":{"raw":233,"gzip":164,"br":119},"noop":{"raw":33,"gzip":53,"br":37},"create-storage-hook":{"raw":2087,"gzip":897,"br":789},"nullthrow":{"raw":187,"gzip":163,"br":121},"no-ssr":{"raw":465,"gzip":313,"br":260},"magic-portal":{"raw":1039,"gzip":521,"br":463},"request-idle-callback":{"raw":392,"gzip":221,"br":171},"rem":{"raw":823,"gzip":395,"br":350},"open-new-tab":{"raw":335,"gzip":255,"br":187},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"types":{"raw":0,"gzip":20,"br":1},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"use":{"raw":298,"gzip":197,"br":160},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-array":{"raw":322,"gzip":236,"br":202},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-clipboard":{"raw":1177,"gzip":650,"br":552},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110},"use-fast-click":{"raw":553,"gzip":364,"br":297},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-local-storage":{"raw":384,"gzip":215,"br":201},"use-map":{"raw":339,"gzip":243,"br":208},"use-is-online":{"raw":350,"gzip":209,"br":162},"use-page-visibility":{"raw":284,"gzip":203,"br":150},"use-media-query":{"raw":702,"gzip":404,"br":331},"use-next-link":{"raw":1647,"gzip":875,"br":742},"use-next-pathname":{"raw":314,"gzip":235,"br":203},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-react-router-is-match":{"raw":594,"gzip":395,"br":337},"use-react-router-enable-concurrent-navigation":{"raw":966,"gzip":470,"br":397},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-set":{"raw":340,"gzip":238,"br":203},"use-session-storage":{"raw":390,"gzip":210,"br":201},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-uncontrolled":{"raw":388,"gzip":273,"br":230},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":450,"gzip":318,"br":249},"use-url-hash-state":{"raw":1124,"gzip":637,"br":559}}}
|
package/use-is-online/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("react");function n(e){return window.addEventListener("online",e),window.addEventListener("offline",e),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",e)}}function
|
|
2
|
+
"use strict";var e=require("react");function n(e){return window.addEventListener("online",e),window.addEventListener("offline",e),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",e)}}function t(){return!("u"<typeof window)&&navigator.onLine}exports.useIsOnline=function(){return e.useSyncExternalStore(n,t,t)};
|
package/use-is-online/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{useSyncExternalStore as n}from"react";function e(n){return window.addEventListener("online",n),window.addEventListener("offline",n),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",n)}}function i(){return"
|
|
2
|
+
import{useSyncExternalStore as n}from"react";function e(n){return window.addEventListener("online",n),window.addEventListener("offline",n),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",n)}}function i(){return!("u"<typeof window)&&navigator.onLine}function o(){return n(e,i,i)}export{o as useIsOnline};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");const t="
|
|
1
|
+
"use strict";require("client-only");var e=require("react");const t="u"<typeof window?e.useEffect:e.useLayoutEffect;exports.useIsomorphicLayoutEffect=t,exports.useLayoutEffect=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useEffect as o,useLayoutEffect as t}from"react";const e="
|
|
1
|
+
import"client-only";import{useEffect as o,useLayoutEffect as t}from"react";const e="u"<typeof window?o:t,f=e;export{e as useIsomorphicLayoutEffect,f as useLayoutEffect};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),t=require("react");const r=new Map;function o(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,
|
|
2
|
+
"use strict";var e=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),t=require("react");const r=new Map;function o(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,a){"u">typeof window&&!r.has(e)&&r.set(e,window.matchMedia(e).matches);const i=t.useCallback(t=>(function(e,t){if("u"<typeof window)return n.noop;const o=window.matchMedia(e),a=()=>{r.set(e,o.matches),t()};return o.addEventListener("change",a),()=>{o.removeEventListener("change",a)}})(e,t),[e]);return t.useSyncExternalStore(i,()=>{var n;return!("u"<typeof window)&&(null!=(n=r.get(e))?n:window.matchMedia(e).matches)},void 0===a?o:()=>a)};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as
|
|
2
|
+
import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as t}from"../noop/index.mjs";import{useCallback as n,useSyncExternalStore as o}from"react";const r=new Map;function i(){throw e("useMediaQuery cannot be used on the server without a serverValue")}function a(e,a){return"u">typeof window&&!r.has(e)&&r.set(e,window.matchMedia(e).matches),o(n(n=>(function(e,n){if("u"<typeof window)return t;const o=window.matchMedia(e),i=()=>{r.set(e,o.matches),n()};return o.addEventListener("change",i),()=>{o.removeEventListener("change",i)}})(e,n),[e]),()=>{var t;return!("u"<typeof window)&&(null!=(t=r.get(e))?t:window.matchMedia(e).matches)},void 0===a?i:()=>a)}export{a as useMediaQuery};
|
package/use-next-link/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),t=require("next/navigation"),
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),t=require("next/navigation"),r=require("next/dist/shared/lib/router/utils/format-url"),n=require("../use-intersection/index.cjs"),o=require("../use-component-will-receive-update/index.cjs");function u(e,t,r){"u">typeof window&&Promise.resolve(e.prefetch(t,r)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}require("../request-idle-callback/index.cjs");const i={rootMargin:"200px"};exports.unstable_useNextLink=function(c,s){let{prefetch:l,ref:a,onClick:f,onMouseEnter:p,onTouchStart:d,scroll:v=!0,replace:y=!1,...E}=s;const h=null==l?"auto":"full",k=!1!==l,m=t.useRouter(),[N,b]=e.useTransition(),[q,x,g]=n.useIntersection(i),C=e.useMemo(()=>"string"==typeof c?c:r.formatUrl(c),[c]);return o.useComponentWillReceiveUpdate(g,[C]),e.useEffect(()=>{"production"!==process.env.NODE_ENV||x&&k&&u(m,C,{kind:h})},[h,x,k,C,m]),[N,{ref:e.useCallback(e=>{q(e),"function"==typeof a?a(e):a&&e&&(a.current=e)},[a,q]),onClick:e.useCallback(e=>{if("function"==typeof f&&f(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;"A"===t.toUpperCase()&&function(e){var t;const r=e.currentTarget,n=r.getAttribute("target");return n&&"_self"!==n||r.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(null==(t=e.nativeEvent)?void 0:t.which)===2}(e)||(e.preventDefault(),b(()=>{m[y?"replace":"push"](C,{scroll:v})}))},[f,y,C,m,v]),onMouseEnter:e.useCallback(e=>{"function"==typeof p&&p(e),"development"===process.env.NODE_ENV||k&&u(m,C,{kind:h})},[h,p,k,C,m]),onTouchStart:e.useCallback(e=>{"function"==typeof d&&d(e),"development"===process.env.NODE_ENV||k&&u(m,C,{kind:h})},[h,d,k,C,m]),...E}]};
|
package/use-next-link/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useTransition as e,useMemo as t,useEffect as
|
|
1
|
+
import"client-only";import{useTransition as e,useMemo as t,useEffect as o,useCallback as n}from"react";import{useRouter as r}from"next/navigation";import{formatUrl as i}from"next/dist/shared/lib/router/utils/format-url";import{useIntersection as c}from"../use-intersection/index.mjs";import{useComponentWillReceiveUpdate as u}from"../use-component-will-receive-update/index.mjs";import"../request-idle-callback/index.mjs";function s(e,t,o){"u">typeof window&&Promise.resolve(e.prefetch(t,o)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}const l={rootMargin:"200px"},p=function(p,f){let{prefetch:a,ref:m,onClick:d,onMouseEnter:v,onTouchStart:y,scroll:h=!0,replace:E=!1,...N}=f;const x=null==a?"auto":"full",g=!1!==a,k=r(),[w,_]=e(),[D,b,K]=c(l),O=t(()=>"string"==typeof p?p:i(p),[p]);return u(K,[O]),o(()=>{"production"!==process.env.NODE_ENV||b&&g&&s(k,O,{kind:x})},[x,b,g,O,k]),[w,{ref:n(e=>{D(e),"function"==typeof m?m(e):m&&e&&(m.current=e)},[m,D]),onClick:n(e=>{if("function"==typeof d&&d(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;"A"===t.toUpperCase()&&function(e){var t;const o=e.currentTarget,n=o.getAttribute("target");return n&&"_self"!==n||o.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(null==(t=e.nativeEvent)?void 0:t.which)===2}(e)||(e.preventDefault(),_(()=>{k[E?"replace":"push"](O,{scroll:h})}))},[d,E,O,k,h]),onMouseEnter:n(e=>{"function"==typeof v&&v(e),"development"===process.env.NODE_ENV||g&&s(k,O,{kind:x})},[x,v,g,O,k]),onTouchStart:n(e=>{"function"==typeof y&&y(e),"development"===process.env.NODE_ENV||g&&s(k,O,{kind:x})},[x,y,g,O,k]),...N}]};export{p as unstable_useNextLink};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("react");const t=e=>(document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}),i=()
|
|
2
|
+
"use strict";var e=require("react");const t=e=>(document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}),i=()=>!("u"<typeof document)&&!document.hidden;exports.usePageVisibility=function(){return e.useSyncExternalStore(t,i,i)};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{useSyncExternalStore as e}from"react";const
|
|
2
|
+
import{useSyncExternalStore as e}from"react";const t=e=>(document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}),i=()=>!("u"<typeof document)&&!document.hidden;function n(){return e(t,i,i)}export{n as usePageVisibility};
|
package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react");const t="
|
|
1
|
+
"use strict";var e=require("react");const t="u"<typeof window?e.useEffect:e.useInsertionEffect||e.useLayoutEffect;function r(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}exports.useStableHandler=function(n){const o=e.useRef(r);return t(()=>{o.current=n},[n]),e.useCallback(function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,o.current)(...t)},[])};
|
package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t,{useEffect as e,useLayoutEffect as n,useRef as r,useCallback as o}from"react";const c="u"<typeof window?e:t.useInsertionEffect||n;function u(t){const e=r(a);return c(()=>{e.current=t},[t]),o(function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return(0,e.current)(...n)},[])}function a(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}export{u as useStableHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),r=require("../noop/index.cjs"),n=require("../no-ssr/index.cjs"),t=require("../chunks/index.b9dLwVor.cjs"),s=require("../chunks/index.BtiK5_Nn.cjs");const a=(()=>{if("
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),r=require("../noop/index.cjs"),n=require("../no-ssr/index.cjs"),t=require("../chunks/index.b9dLwVor.cjs"),s=require("../chunks/index.BtiK5_Nn.cjs");const a=(()=>{if("u"<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)})})();function l(){throw n.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(r,n){var i;let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t.t,deserializer:t.t};const u=o.raw?t.t:o.serializer,c=o.raw?t.t:o.deserializer,h=void 0===n?l:()=>u(n),d=e.useSyncExternalStore(a,()=>new URLSearchParams(location.hash.slice(1)).get(r),h),w=e.useMemo(()=>null===d?null!=n?n:null:c(d),[n,c,d]),S=e.useCallback(e=>{const t=location.hash,a=new URLSearchParams(t.slice(1)),l=s.n(e)?e(w):e;l===n||null===l?a.delete(r):a.set(r,u(l));const i=a.toString();t!==i&&(location.hash=i)},[n,w,r,u]);return[null!=(i=null!=w?w:n)?i:null,S]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useSyncExternalStore as e,useMemo as
|
|
1
|
+
import"client-only";import{useSyncExternalStore as e,useMemo as r,useCallback as t}from"react";import{noop as n}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";import{t as s}from"../chunks/index.D0KaUCcV.mjs";import{n as a}from"../chunks/index.C9-3oDdv.mjs";const l=(()=>{if("u"<typeof window)return e=>n;let e=!1;const r=new Set,t=()=>{r.forEach(e=>e())};return n=>(r.add(n),e||(e=!0,window.addEventListener("hashchange",t)),()=>{r.delete(n)})})();function i(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function u(n,o){var u;let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:s,deserializer:s};const h=c.raw?s:c.serializer,d=c.raw?s:c.deserializer,m=e(l,()=>new URLSearchParams(location.hash.slice(1)).get(n),void 0===o?i:()=>h(o)),w=r(()=>null===m?null!=o?o:null:d(m),[o,d,m]),f=t(e=>{const r=location.hash,t=new URLSearchParams(r.slice(1)),s=a(e)?e(w):e;s===o||null===s?t.delete(n):t.set(n,h(s));const l=t.toString();r!==l&&(location.hash=l)},[o,w,n,h]);return[null!=(u=null!=w?w:o)?u:null,f]}export{u as unstable_useUrlHashState};
|