foxact 0.2.14 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,7 +26,7 @@ Written in TypeScript. Unlocking strong typing benefits with TypeScript 4.8+.
26
26
 
27
27
  #### Super Lightweight
28
28
 
29
- The entire **foxact** library has zero dependencies and is **less than 5 KiB gzipped in sum**, ensuring a lean and efficient solution. And what's more...
29
+ The entire **foxact** library has zero dependencies and is **about 5 KiB gzipped in sum**, ensuring a lean and efficient solution. And what's more...
30
30
 
31
31
  #### Fully Tree Shakable
32
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxact",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "React Hooks/Utils done right. For browser, SSR, and React Server Components.",
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -74,15 +74,6 @@
74
74
  "require": "./noop/index.cjs",
75
75
  "default": "./noop/index.js"
76
76
  },
77
- "./request-idle-callback": {
78
- "types": "./request-idle-callback/index.d.ts",
79
- "import": {
80
- "types": "./request-idle-callback/index.d.ts",
81
- "default": "./request-idle-callback/index.mjs"
82
- },
83
- "require": "./request-idle-callback/index.cjs",
84
- "default": "./request-idle-callback/index.js"
85
- },
86
77
  "./typescript-happy-forward-ref": {
87
78
  "types": "./typescript-happy-forward-ref/index.d.ts",
88
79
  "import": {
@@ -119,6 +110,15 @@
119
110
  "require": "./use-clipboard/index.cjs",
120
111
  "default": "./use-clipboard/index.js"
121
112
  },
113
+ "./request-idle-callback": {
114
+ "types": "./request-idle-callback/index.d.ts",
115
+ "import": {
116
+ "types": "./request-idle-callback/index.d.ts",
117
+ "default": "./request-idle-callback/index.mjs"
118
+ },
119
+ "require": "./request-idle-callback/index.cjs",
120
+ "default": "./request-idle-callback/index.js"
121
+ },
122
122
  "./use-composition-input": {
123
123
  "types": "./use-composition-input/index.d.ts",
124
124
  "import": {
@@ -164,6 +164,15 @@
164
164
  "require": "./use-intersection/index.cjs",
165
165
  "default": "./use-intersection/index.js"
166
166
  },
167
+ "./use-is-client": {
168
+ "types": "./use-is-client/index.d.ts",
169
+ "import": {
170
+ "types": "./use-is-client/index.d.ts",
171
+ "default": "./use-is-client/index.mjs"
172
+ },
173
+ "require": "./use-is-client/index.cjs",
174
+ "default": "./use-is-client/index.js"
175
+ },
167
176
  "./use-isomorphic-layout-effect": {
168
177
  "types": "./use-isomorphic-layout-effect/index.d.ts",
169
178
  "import": {
@@ -191,6 +200,15 @@
191
200
  "require": "./use-react-router-enable-concurrent-navigation/index.cjs",
192
201
  "default": "./use-react-router-enable-concurrent-navigation/index.js"
193
202
  },
203
+ "./use-next-pathname": {
204
+ "types": "./use-next-pathname/index.d.ts",
205
+ "import": {
206
+ "types": "./use-next-pathname/index.d.ts",
207
+ "default": "./use-next-pathname/index.mjs"
208
+ },
209
+ "require": "./use-next-pathname/index.cjs",
210
+ "default": "./use-next-pathname/index.js"
211
+ },
194
212
  "./use-react-router-is-match": {
195
213
  "types": "./use-react-router-is-match/index.d.ts",
196
214
  "import": {
package/sizes.json CHANGED
@@ -1 +1 @@
1
- {"total":{"raw":8657,"gzip":5557,"br":0},"exports":{"create-context-state":{"raw":146,"gzip":116,"br":102},"context-state":{"raw":371,"gzip":240,"br":204},"typescript-happy-forward-ref":{"raw":118,"gzip":102,"br":87},"use":{"raw":279,"gzip":175,"br":151},"noop":{"raw":32,"gzip":52,"br":36},"request-idle-callback":{"raw":407,"gzip":231,"br":180},"use-debounced-state":{"raw":380,"gzip":275,"br":231},"use-clipboard":{"raw":1071,"gzip":614,"br":527},"use-array":{"raw":329,"gzip":242,"br":201},"use-error-boundary":{"raw":172,"gzip":157,"br":148},"use-intersection":{"raw":1214,"gzip":652,"br":592},"use-composition-input":{"raw":420,"gzip":262,"br":230},"use-map":{"raw":348,"gzip":243,"br":210},"use-isomorphic-layout-effect":{"raw":177,"gzip":143,"br":120},"use-retimer":{"raw":197,"gzip":165,"br":125},"use-set":{"raw":349,"gzip":242,"br":203},"use-react-router-is-match":{"raw":562,"gzip":369,"br":309},"use-debounced-value":{"raw":370,"gzip":263,"br":214},"use-uncontrolled":{"raw":304,"gzip":236,"br":201},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":461,"gzip":325,"br":256},"use-react-router-enable-concurrent-navigation":{"raw":950,"gzip":453,"br":373}}}
1
+ {"total":{"raw":9181,"gzip":5971,"br":0},"exports":{"context-state":{"raw":371,"gzip":240,"br":204},"typescript-happy-forward-ref":{"raw":118,"gzip":102,"br":87},"create-context-state":{"raw":146,"gzip":116,"br":102},"noop":{"raw":32,"gzip":52,"br":36},"use":{"raw":279,"gzip":175,"br":151},"use-array":{"raw":329,"gzip":242,"br":201},"request-idle-callback":{"raw":407,"gzip":231,"br":180},"use-clipboard":{"raw":1071,"gzip":614,"br":527},"use-composition-input":{"raw":420,"gzip":262,"br":230},"use-debounced-value":{"raw":370,"gzip":263,"br":214},"use-debounced-state":{"raw":380,"gzip":275,"br":231},"use-error-boundary":{"raw":238,"gzip":194,"br":158},"use-is-client":{"raw":148,"gzip":143,"br":115},"use-isomorphic-layout-effect":{"raw":177,"gzip":143,"br":120},"use-intersection":{"raw":1214,"gzip":652,"br":592},"use-map":{"raw":348,"gzip":243,"br":210},"use-next-pathname":{"raw":310,"gzip":234,"br":195},"use-retimer":{"raw":197,"gzip":165,"br":125},"use-react-router-is-match":{"raw":562,"gzip":369,"br":309},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":461,"gzip":325,"br":256},"use-react-router-enable-concurrent-navigation":{"raw":950,"gzip":453,"br":373},"use-set":{"raw":349,"gzip":242,"br":203},"use-uncontrolled":{"raw":304,"gzip":236,"br":201}}}
@@ -1 +1 @@
1
- "use strict";require("client-only");var r=require("react");const e=r=>!1!==r&&null!=r;exports.useErrorBoundary=t=>{let[u,o]=r.useState(!1);if(e(t))throw t;if(e(u))throw u;return o};
1
+ "use strict";require("client-only");var r=require("react");const e=r=>!1!==r&&null!=r;exports.useErrorBoundary=function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],[n,o]=r.useState(!1);if(e(t))throw t;if(e(n))throw n;return o};
@@ -2,6 +2,6 @@ import * as react from 'react';
2
2
 
3
3
  type ErrorLike = Error | undefined | null | boolean;
4
4
  /** @see https://foxact.skk.moe/use-error-boundary */
5
- declare const useErrorBoundary: (givenError: ErrorLike) => react.Dispatch<react.SetStateAction<ErrorLike>>;
5
+ declare const useErrorBoundary: (givenError?: ErrorLike) => react.Dispatch<react.SetStateAction<ErrorLike>>;
6
6
 
7
7
  export { useErrorBoundary };
@@ -1 +1 @@
1
- "use strict";require("client-only");var r=require("react");const e=r=>!1!==r&&null!=r;exports.useErrorBoundary=t=>{let[u,o]=r.useState(!1);if(e(t))throw t;if(e(u))throw u;return o};
1
+ "use strict";require("client-only");var r=require("react");const e=r=>!1!==r&&null!=r;exports.useErrorBoundary=function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],[n,o]=r.useState(!1);if(e(t))throw t;if(e(n))throw n;return o};
@@ -1 +1 @@
1
- import"client-only";import{useState as r}from"react";let t=r=>!1!==r&&null!=r,o=o=>{let[e,l]=r(!1);if(t(o))throw o;if(t(e))throw e;return l};export{o as useErrorBoundary};
1
+ import"client-only";import{useState as r}from"react";let t=r=>!1!==r&&null!=r,o=function(){let o=arguments.length>0&&void 0!==arguments[0]&&arguments[0],[e,n]=r(!1);if(t(o))throw o;if(t(e))throw e;return n};export{o as useErrorBoundary};
@@ -0,0 +1 @@
1
+ "use strict";require("client-only");var e=require("react");exports.useIsClient=()=>{let[t,r]=e.useState(!1);return e.useEffect(()=>{r(!0)},[]),t};
@@ -0,0 +1,4 @@
1
+ /** @see https://foxact.skk.moe/use-is-client */
2
+ declare const useIsClient: () => boolean;
3
+
4
+ export { useIsClient };
@@ -0,0 +1 @@
1
+ "use strict";require("client-only");var e=require("react");exports.useIsClient=()=>{let[t,r]=e.useState(!1);return e.useEffect(()=>{r(!0)},[]),t};
@@ -0,0 +1 @@
1
+ import"client-only";import{useState as t,useEffect as e}from"react";let r=()=>{let[r,l]=t(!1);return e(()=>{l(!0)},[]),r};export{r as useIsClient};
@@ -0,0 +1 @@
1
+ "use strict";require("client-only");var e=require("next/router"),t=require("react");exports.useNextPathname=function(){let r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],{asPath:u}=e.useRouter();return t.useMemo(()=>{let e=u.split(/[?#]/)[0];return r?e.endsWith("/")?e:"".concat(e,"/"):e},[r,u])};
@@ -0,0 +1,4 @@
1
+ /** @see https://foxact.skk.moe/use-next-pathname */
2
+ declare const useNextPathname: (ensureTrailingSlash?: boolean) => string;
3
+
4
+ export { useNextPathname };
@@ -0,0 +1 @@
1
+ "use strict";require("client-only");var e=require("next/router"),t=require("react");exports.useNextPathname=function(){let r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],{asPath:u}=e.useRouter();return t.useMemo(()=>{let e=u.split(/[?#]/)[0];return r?e.endsWith("/")?e:"".concat(e,"/"):e},[r,u])};
@@ -0,0 +1 @@
1
+ import"client-only";import{useRouter as t}from"next/router";import{useMemo as e}from"react";let r=function(){let r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],{asPath:n}=t();return e(()=>{let t=n.split(/[?#]/)[0];return r?t.endsWith("/")?t:"".concat(t,"/"):t},[r,n])};export{r as useNextPathname};