foxact 0.2.55 → 0.3.0
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/package.json +1 -37
- package/sizes.json +1 -1
- package/use-next-link/index.cjs +0 -1
- package/use-next-link/index.d.ts +0 -31
- package/use-next-link/index.mjs +0 -1
- package/use-next-pathname/index.cjs +0 -1
- package/use-next-pathname/index.d.ts +0 -4
- package/use-next-pathname/index.mjs +0 -1
- package/use-react-router-enable-concurrent-navigation/index.cjs +0 -2
- package/use-react-router-enable-concurrent-navigation/index.d.ts +0 -8
- package/use-react-router-enable-concurrent-navigation/index.mjs +0 -2
- package/use-react-router-is-match/index.cjs +0 -1
- package/use-react-router-is-match/index.d.ts +0 -11
- package/use-react-router-is-match/index.mjs +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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": {
|
|
@@ -439,24 +439,6 @@
|
|
|
439
439
|
"require": "./use-media-query/index.cjs",
|
|
440
440
|
"default": "./use-media-query/index.cjs"
|
|
441
441
|
},
|
|
442
|
-
"./use-next-link": {
|
|
443
|
-
"types": "./use-next-link/index.d.ts",
|
|
444
|
-
"import": {
|
|
445
|
-
"types": "./use-next-link/index.d.ts",
|
|
446
|
-
"default": "./use-next-link/index.mjs"
|
|
447
|
-
},
|
|
448
|
-
"require": "./use-next-link/index.cjs",
|
|
449
|
-
"default": "./use-next-link/index.cjs"
|
|
450
|
-
},
|
|
451
|
-
"./use-next-pathname": {
|
|
452
|
-
"types": "./use-next-pathname/index.d.ts",
|
|
453
|
-
"import": {
|
|
454
|
-
"types": "./use-next-pathname/index.d.ts",
|
|
455
|
-
"default": "./use-next-pathname/index.mjs"
|
|
456
|
-
},
|
|
457
|
-
"require": "./use-next-pathname/index.cjs",
|
|
458
|
-
"default": "./use-next-pathname/index.cjs"
|
|
459
|
-
},
|
|
460
442
|
"./use-page-visibility": {
|
|
461
443
|
"types": "./use-page-visibility/index.d.ts",
|
|
462
444
|
"import": {
|
|
@@ -466,24 +448,6 @@
|
|
|
466
448
|
"require": "./use-page-visibility/index.cjs",
|
|
467
449
|
"default": "./use-page-visibility/index.cjs"
|
|
468
450
|
},
|
|
469
|
-
"./use-react-router-enable-concurrent-navigation": {
|
|
470
|
-
"types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
|
|
471
|
-
"import": {
|
|
472
|
-
"types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
|
|
473
|
-
"default": "./use-react-router-enable-concurrent-navigation/index.mjs"
|
|
474
|
-
},
|
|
475
|
-
"require": "./use-react-router-enable-concurrent-navigation/index.cjs",
|
|
476
|
-
"default": "./use-react-router-enable-concurrent-navigation/index.cjs"
|
|
477
|
-
},
|
|
478
|
-
"./use-react-router-is-match": {
|
|
479
|
-
"types": "./use-react-router-is-match/index.d.ts",
|
|
480
|
-
"import": {
|
|
481
|
-
"types": "./use-react-router-is-match/index.d.ts",
|
|
482
|
-
"default": "./use-react-router-is-match/index.mjs"
|
|
483
|
-
},
|
|
484
|
-
"require": "./use-react-router-is-match/index.cjs",
|
|
485
|
-
"default": "./use-react-router-is-match/index.cjs"
|
|
486
|
-
},
|
|
487
451
|
"./use-readonly-search-params": {
|
|
488
452
|
"types": "./use-readonly-search-params/index.d.ts",
|
|
489
453
|
"import": {
|
package/sizes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"total":{"raw":
|
|
1
|
+
{"total":{"raw":24632,"gzip":15124,"br":0},"exports":{"compose-context-provider":{"raw":177,"gzip":155,"br":122},"context-reducer":{"raw":557,"gzip":332,"br":319},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"create-context-state":{"raw":145,"gzip":116,"br":96},"create-local-storage-state":{"raw":402,"gzip":216,"br":189},"create-magic-portal":{"raw":224,"gzip":136,"br":112},"context-state":{"raw":402,"gzip":259,"br":218},"create-storage-state-factory":{"raw":592,"gzip":338,"br":304},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-session-storage-state":{"raw":406,"gzip":215,"br":188},"create-storage-hook":{"raw":2087,"gzip":897,"br":789},"email-protection":{"raw":426,"gzip":321,"br":272},"is-safari":{"raw":233,"gzip":164,"br":119},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"current-year":{"raw":524,"gzip":355,"br":293},"invariant":{"raw":178,"gzip":156,"br":118},"noop":{"raw":33,"gzip":53,"br":37},"no-ssr":{"raw":465,"gzip":313,"br":260},"merge-refs":{"raw":525,"gzip":280,"br":235},"nullthrow":{"raw":187,"gzip":163,"br":121},"magic-portal":{"raw":1039,"gzip":521,"br":463},"types":{"raw":0,"gzip":20,"br":1},"open-new-tab":{"raw":335,"gzip":255,"br":187},"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},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-composition-input":{"raw":470,"gzip":286,"br":241},"rem":{"raw":823,"gzip":395,"br":350},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-array":{"raw":322,"gzip":236,"br":202},"use-clipboard":{"raw":1177,"gzip":650,"br":552},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110},"use-is-online":{"raw":370,"gzip":258,"br":220},"use-fast-click":{"raw":578,"gzip":377,"br":304},"use-map":{"raw":339,"gzip":243,"br":208},"use-local-storage":{"raw":384,"gzip":215,"br":201},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-page-visibility":{"raw":359,"gzip":263,"br":210},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-media-query":{"raw":604,"gzip":380,"br":315},"use-session-storage":{"raw":390,"gzip":210,"br":201},"use-set":{"raw":340,"gzip":238,"br":203},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-readonly-search-params":{"raw":1120,"gzip":573,"br":477},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-state-with-deps":{"raw":464,"gzip":321,"br":295},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":450,"gzip":318,"br":249},"use-uncontrolled":{"raw":388,"gzip":273,"br":230},"use-url-hash-state":{"raw":1077,"gzip":611,"br":536}}}
|
package/use-next-link/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { LinkProps } from 'next/link';
|
|
2
|
-
|
|
3
|
-
interface UrlObject {
|
|
4
|
-
auth?: string | null | undefined;
|
|
5
|
-
hash?: string | null | undefined;
|
|
6
|
-
host?: string | null | undefined;
|
|
7
|
-
hostname?: string | null | undefined;
|
|
8
|
-
href?: string | null | undefined;
|
|
9
|
-
pathname?: string | null | undefined;
|
|
10
|
-
protocol?: string | null | undefined;
|
|
11
|
-
search?: string | null | undefined;
|
|
12
|
-
slashes?: boolean | null | undefined;
|
|
13
|
-
port?: string | number | null | undefined;
|
|
14
|
-
query?: any;
|
|
15
|
-
}
|
|
16
|
-
interface UseNextLinkOptions extends Omit<LinkProps, 'as' | 'href' | 'legacyBehavior' | 'shallow' | 'passHref' | 'locale'> {
|
|
17
|
-
ref?: React.RefObject<HTMLAnchorElement> | React.RefCallback<HTMLAnchorElement> | null;
|
|
18
|
-
}
|
|
19
|
-
interface UseNextLinkReturnProps extends Partial<React.JSX.IntrinsicElements['a']> {
|
|
20
|
-
ref: React.RefCallback<HTMLAnchorElement>;
|
|
21
|
-
onTouchStart: React.TouchEventHandler<HTMLAnchorElement>;
|
|
22
|
-
onMouseEnter: React.MouseEventHandler<HTMLAnchorElement>;
|
|
23
|
-
onClick: React.MouseEventHandler<HTMLAnchorElement>;
|
|
24
|
-
href?: string;
|
|
25
|
-
}
|
|
26
|
-
/** @see https://foxact.skk.moe/use-next-link */
|
|
27
|
-
declare function useNextLink(hrefProp: string | UrlObject, { prefetch: prefetchProp, ref, onClick, onMouseEnter, onTouchStart, scroll: routerScroll, replace, ...restProps }: UseNextLinkOptions): [isPending: boolean, linkProps: UseNextLinkReturnProps];
|
|
28
|
-
declare const unstable_useNextLink: typeof useNextLink;
|
|
29
|
-
|
|
30
|
-
export { unstable_useNextLink };
|
|
31
|
-
export type { UseNextLinkOptions, UseNextLinkReturnProps };
|
package/use-next-link/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("next/router.js"),t=require("react");exports.useNextPathname=function(){let r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{asPath:n}=e.useRouter();return t.useMemo(()=>{const e=n.split(/[#?]/)[0];return r?e.endsWith("/")?e:"".concat(e,"/"):e},[r,n])};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"client-only";import{useRouter as t}from"next/router.js";import{useMemo as e}from"react";function n(){let n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{asPath:o}=t();return e(()=>{const t=o.split(/[#?]/)[0];return n?t.endsWith("/")?t:"".concat(t,"/"):t},[n,o])}export{n as useNextPathname};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
"use strict";require("client-only");var r=require("react"),e=require("react-router-dom");function t(){const{navigator:t}=r.useContext(e.UNSAFE_NavigationContext);if(!t)throw TypeError("[foxact/use-react-router-enable-concurrent-navigation] must be used under <RouterProvider /> or a Router component (e.g. <BrowserRouter />)");r.useEffect(()=>{const e=t.go.bind(t),n=t.push.bind(t),o=t.replace.bind(t);return t.go=function(){for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];return r.startTransition(()=>e.apply(t,o))},t.push=function(){for(var e=arguments.length,o=Array(e),a=0;a<e;a++)o[a]=arguments[a];return r.startTransition(()=>n.apply(t,o))},t.replace=function(){for(var e=arguments.length,n=Array(e),a=0;a<e;a++)n[a]=arguments[a];return r.startTransition(()=>o.apply(t,n))},()=>{t.go=e,t.push=n,t.replace=o}},[t])}exports.ReactRouterConcurrentNavigationProvider=function(r){let{children:e}=r;return t(),e},exports.useReactRouterEnableConcurrentNavigation=t;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { Foxact } from '../types/index.js';
|
|
3
|
-
|
|
4
|
-
/** @see https://foxact.skk.moe/use-react-router-enable-concurrent-navigation */
|
|
5
|
-
declare function useReactRouterEnableConcurrentNavigation(): void;
|
|
6
|
-
declare function ReactRouterConcurrentNavigationProvider({ children }: Foxact.PropsWithChildren): react.ReactNode;
|
|
7
|
-
|
|
8
|
-
export { ReactRouterConcurrentNavigationProvider, useReactRouterEnableConcurrentNavigation };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import"client-only";import{useContext as r,useEffect as e,startTransition as o}from"react";import{UNSAFE_NavigationContext as t}from"react-router-dom";function n(){const{navigator:n}=r(t);if(!n)throw TypeError("[foxact/use-react-router-enable-concurrent-navigation] must be used under <RouterProvider /> or a Router component (e.g. <BrowserRouter />)");e(()=>{const r=n.go.bind(n),e=n.push.bind(n),t=n.replace.bind(n);return n.go=function(){for(var e=arguments.length,t=Array(e),u=0;u<e;u++)t[u]=arguments[u];return o(()=>r.apply(n,t))},n.push=function(){for(var r=arguments.length,t=Array(r),u=0;u<r;u++)t[u]=arguments[u];return o(()=>e.apply(n,t))},n.replace=function(){for(var r=arguments.length,e=Array(r),u=0;u<r;u++)e[u]=arguments[u];return o(()=>t.apply(n,e))},()=>{n.go=r,n.push=e,n.replace=t}},[n])}function u(r){let{children:e}=r;return n(),e}export{u as ReactRouterConcurrentNavigationProvider,n as useReactRouterEnableConcurrentNavigation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("../chunks/index.b9dLwVor.cjs"),t=require("react"),r=require("react-router-dom");exports.useReactRouterIsMatch=function(o){let{relative:a,caseSensitive:n=!1,end:s=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{pathname:u}=r.useLocation(),{navigator:{encodeLocation:i=e.t}}=t.useContext(r.UNSAFE_NavigationContext),c=r.useResolvedPath(o,{relative:a});return t.useMemo(()=>{let e=u,t=i(c).pathname;return n||(e=e.toLowerCase(),t=t.toLowerCase()),e===t||!s&&e.startsWith(t)&&"/"===e.charAt(t.length)},[i,c,u,n,s])};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { To, RelativeRoutingType } from 'react-router-dom';
|
|
2
|
-
|
|
3
|
-
interface UseReactRouterIsMatchOption {
|
|
4
|
-
relative?: RelativeRoutingType;
|
|
5
|
-
caseSensitive?: boolean;
|
|
6
|
-
end?: boolean;
|
|
7
|
-
}
|
|
8
|
-
/** @see https://foxact.skk.moe/use-react-router-is-match */
|
|
9
|
-
declare function useReactRouterIsMatch(to: To, { relative, caseSensitive, end }?: UseReactRouterIsMatchOption): any;
|
|
10
|
-
|
|
11
|
-
export { useReactRouterIsMatch };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"client-only";import{t}from"../chunks/index.D0KaUCcV.mjs";import{useContext as r,useMemo as e}from"react";import{useLocation as o,UNSAFE_NavigationContext as a,useResolvedPath as n}from"react-router-dom";function m(m){let{relative:i,caseSensitive:c=!1,end:s=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{pathname:h}=o(),{navigator:{encodeLocation:p=t}}=r(a),u=n(m,{relative:i});return e(()=>{let t=h,r=p(u).pathname;return c||(t=t.toLowerCase(),r=r.toLowerCase()),t===r||!s&&t.startsWith(r)&&"/"===t.charAt(r.length)},[p,u,h,c,s])}export{m as useReactRouterIsMatch};
|