foxact 0.2.51 → 0.2.53
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/context-state/index.mjs +1 -1
- 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.d.ts +2 -4
- 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 +42 -11
- 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-readonly-search-params/index.cjs +1 -0
- package/use-readonly-search-params/index.d.ts +14 -0
- package/use-readonly-search-params/index.mjs +1 -0
- 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{useReducer as n,useContext as e,createContext 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=t(m(u)?u(c):c),p=t(i);return[e=>{var t;let{children:i,initialArg:m,init:s}=e;const[a,f]=n(l,null!=m?m:c,null!=(t=null!=s?s:u)?t:o);return r(d.Provider,{value:a,children:r(p.Provider,{value:f,children:i})})},()=>e(d),()=>e(p),d]}export{l as createContextReducer};
|
package/context-state/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import"client-only";import{
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import"client-only";import{useState as r,useContext as e,createContext as o}from"react";import{noop as n}from"../noop/index.mjs";function i(i){const l=o(i),c=o(n);return[e=>{let{children:o,initialState:n}=e;const[m,a]=r(null!=n?n:i);return t(l.Provider,{value:m,children:t(c.Provider,{value:a,children:o})})},()=>e(l),()=>e(c),l]}export{i as createContextState};
|
|
@@ -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
|
|
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(function(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[o,s]=r.useState(u||new Date().getFullYear());return t.useIsomorphicLayoutEffect(()=>{s(new Date().getFullYear())},[]),e.jsx("span",{...i,children:o})});exports.CurrentYear=n;
|
package/current-year/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { Foxact } from '../types/index.js';
|
|
4
2
|
|
|
5
|
-
interface CurrentYearProps extends
|
|
3
|
+
interface CurrentYearProps extends React.ComponentProps<'span'> {
|
|
6
4
|
defaultYear?: number;
|
|
7
5
|
}
|
|
8
6
|
/** @see https://foxact.skk.moe/current-year */
|
|
9
|
-
declare const CurrentYear: react.
|
|
7
|
+
declare const CurrentYear: react.NamedExoticComponent<CurrentYearProps>;
|
|
10
8
|
|
|
11
9
|
export { CurrentYear };
|
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 n}from"../use-isomorphic-layout-effect/index.mjs";import"client-only";const o=r(r
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import{memo as r,useState as t}from"react";import{useIsomorphicLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";import"client-only";const o=r(function(r){let{defaultYear:o,...i}=r;"u"<typeof window&&void 0===o&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[a,u]=t(o||new Date().getFullYear());return n(()=>{u(new Date().getFullYear())},[]),e("span",{...i,children:a})});export{o 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.53",
|
|
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,15 @@
|
|
|
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
|
+
},
|
|
59
72
|
"./context-state": {
|
|
60
73
|
"types": "./context-state/index.d.ts",
|
|
61
74
|
"import": {
|
|
@@ -65,6 +78,15 @@
|
|
|
65
78
|
"require": "./context-state/index.cjs",
|
|
66
79
|
"default": "./context-state/index.cjs"
|
|
67
80
|
},
|
|
81
|
+
"./create-context-reducer": {
|
|
82
|
+
"types": "./create-context-reducer/index.d.ts",
|
|
83
|
+
"import": {
|
|
84
|
+
"types": "./create-context-reducer/index.d.ts",
|
|
85
|
+
"default": "./create-context-reducer/index.mjs"
|
|
86
|
+
},
|
|
87
|
+
"require": "./create-context-reducer/index.cjs",
|
|
88
|
+
"default": "./create-context-reducer/index.cjs"
|
|
89
|
+
},
|
|
68
90
|
"./create-context-state": {
|
|
69
91
|
"types": "./create-context-state/index.d.ts",
|
|
70
92
|
"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": {
|
|
@@ -452,6 +474,15 @@
|
|
|
452
474
|
"require": "./use-react-router-is-match/index.cjs",
|
|
453
475
|
"default": "./use-react-router-is-match/index.cjs"
|
|
454
476
|
},
|
|
477
|
+
"./use-readonly-search-params": {
|
|
478
|
+
"types": "./use-readonly-search-params/index.d.ts",
|
|
479
|
+
"import": {
|
|
480
|
+
"types": "./use-readonly-search-params/index.d.ts",
|
|
481
|
+
"default": "./use-readonly-search-params/index.mjs"
|
|
482
|
+
},
|
|
483
|
+
"require": "./use-readonly-search-params/index.cjs",
|
|
484
|
+
"default": "./use-readonly-search-params/index.cjs"
|
|
485
|
+
},
|
|
455
486
|
"./use-retimer": {
|
|
456
487
|
"types": "./use-retimer/index.d.ts",
|
|
457
488
|
"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":27165,"gzip":16404,"br":0},"exports":{"context-reducer":{"raw":557,"gzip":332,"br":319},"create-context-state":{"raw":145,"gzip":116,"br":96},"context-state":{"raw":402,"gzip":259,"br":218},"create-local-storage-state":{"raw":402,"gzip":216,"br":189},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"create-session-storage-state":{"raw":406,"gzip":215,"br":188},"compose-context-provider":{"raw":177,"gzip":155,"br":122},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-magic-portal":{"raw":224,"gzip":136,"br":112},"create-storage-state-factory":{"raw":592,"gzip":338,"br":304},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"current-year":{"raw":524,"gzip":355,"br":293},"email-protection":{"raw":426,"gzip":321,"br":272},"is-safari":{"raw":233,"gzip":164,"br":119},"create-storage-hook":{"raw":2087,"gzip":897,"br":789},"noop":{"raw":33,"gzip":53,"br":37},"invariant":{"raw":178,"gzip":156,"br":118},"open-new-tab":{"raw":335,"gzip":255,"br":187},"nullthrow":{"raw":187,"gzip":163,"br":121},"magic-portal":{"raw":1039,"gzip":521,"br":463},"types":{"raw":0,"gzip":20,"br":1},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"no-ssr":{"raw":465,"gzip":313,"br":260},"use":{"raw":298,"gzip":197,"br":160},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"request-idle-callback":{"raw":392,"gzip":221,"br":171},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"rem":{"raw":823,"gzip":395,"br":350},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-array":{"raw":322,"gzip":236,"br":202},"use-clipboard":{"raw":1177,"gzip":650,"br":552},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-fast-click":{"raw":553,"gzip":364,"br":297},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"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-local-storage":{"raw":384,"gzip":215,"br":201},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-is-online":{"raw":350,"gzip":209,"br":162},"use-next-pathname":{"raw":314,"gzip":235,"br":203},"use-page-visibility":{"raw":284,"gzip":203,"br":150},"use-media-query":{"raw":702,"gzip":404,"br":331},"use-map":{"raw":339,"gzip":243,"br":208},"use-readonly-search-params":{"raw":1096,"gzip":551,"br":443},"use-next-link":{"raw":1647,"gzip":875,"br":742},"use-react-router-enable-concurrent-navigation":{"raw":966,"gzip":470,"br":397},"use-react-router-is-match":{"raw":594,"gzip":395,"br":337},"use-set":{"raw":340,"gzip":238,"br":203},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-uncontrolled":{"raw":388,"gzip":273,"br":230},"use-session-storage":{"raw":390,"gzip":210,"br":201},"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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../no-ssr/index.cjs"),r=require("../noop/index.cjs"),n=require("react");class a extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class o extends URLSearchParams{append(){throw new a}delete(){throw new a}set(){throw new a}sort(){throw new a}}function t(e){return"u"<typeof window?r.noop:(window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)})}let s=null,c=null;function u(){return"u"<typeof window?new o:window.location.search===s&&null!==c?c:c=new o(s=window.location.search)}function i(){throw e.noSSRError('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}exports.ReadonlyURLSearchParams=o,exports.useReadonlySearchParams=function(e){return n.useSyncExternalStore(t,u,null==e?i:()=>{const r=e();return r instanceof o?r:new o(r)})};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class ReadonlyURLSearchParams extends URLSearchParams {
|
|
2
|
+
/** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://foxact.skk.moe/use-readonly-search-params */
|
|
3
|
+
append(): never;
|
|
4
|
+
/** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://foxact.skk.moe/use-readonly-search-params */
|
|
5
|
+
delete(): never;
|
|
6
|
+
/** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://foxact.skk.moe/use-readonly-search-params */
|
|
7
|
+
set(): never;
|
|
8
|
+
/** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://foxact.skk.moe/use-readonly-search-params */
|
|
9
|
+
sort(): never;
|
|
10
|
+
}
|
|
11
|
+
/** @see https://foxact.skk.moe/use-readonly-search-params */
|
|
12
|
+
declare function useReadonlySearchParams(getServerDefaultValue?: () => URLSearchParams | ReadonlyURLSearchParams): ReadonlyURLSearchParams;
|
|
13
|
+
|
|
14
|
+
export { ReadonlyURLSearchParams, useReadonlySearchParams };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as r}from"../noop/index.mjs";import{useSyncExternalStore as n}from"react";class o extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class a extends URLSearchParams{append(){throw new o}delete(){throw new o}set(){throw new o}sort(){throw new o}}function t(e){return"u"<typeof window?r:(window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)})}let s=null,i=null;function c(){return"u"<typeof window?new a:window.location.search===s&&null!==i?i:i=new a(s=window.location.search)}function l(){throw e('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}function u(e){return n(t,c,null==e?l:()=>{const r=e();return r instanceof a?r:new a(r)})}export{a as ReadonlyURLSearchParams,u as useReadonlySearchParams};
|
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};
|