foxact 0.2.52 → 0.2.54

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, ensuring a lean and efficient solution. And what's more...
29
+ The entire **foxact** library has very few dependencies, ensuring a lean and efficient solution. And what's more...
30
30
 
31
31
  #### Fully Tree Shakable
32
32
 
@@ -1 +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};
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};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import"client-only";import{useContext as r,createContext as e,useState as o}from"react";import{noop as n}from"../noop/index.mjs";function i(i){const l=e(i),c=e(n);return[r=>{let{children:e,initialState:n}=r;const[m,a]=o(null!=n?n:i);return t(l.Provider,{value:m,children:t(c.Provider,{value:a,children:e})})},()=>r(l),()=>r(c),l]}export{i as createContextState};
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};
@@ -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: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;
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;
@@ -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 Foxact.ComponentProps<'span'> {
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.MemoExoticComponent<({ defaultYear, ...restProps }: Readonly<CurrentYearProps>) => react_jsx_runtime.JSX.Element>;
7
+ declare const CurrentYear: react.NamedExoticComponent<CurrentYearProps>;
10
8
 
11
9
  export { CurrentYear };
@@ -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 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};
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxact",
3
- "version": "0.2.52",
3
+ "version": "0.2.54",
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": {
@@ -22,6 +22,7 @@
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
24
  "client-only": "^0.0.1",
25
+ "event-target-bus": "^1.0.0",
25
26
  "server-only": "^0.0.1"
26
27
  },
27
28
  "peerDependencies": {
@@ -60,14 +61,14 @@
60
61
  "require": "./compose-context-provider/index.cjs",
61
62
  "default": "./compose-context-provider/index.cjs"
62
63
  },
63
- "./context-reducer": {
64
- "types": "./context-reducer/index.d.ts",
64
+ "./context-state": {
65
+ "types": "./context-state/index.d.ts",
65
66
  "import": {
66
- "types": "./context-reducer/index.d.ts",
67
- "default": "./context-reducer/index.mjs"
67
+ "types": "./context-state/index.d.ts",
68
+ "default": "./context-state/index.mjs"
68
69
  },
69
- "require": "./context-reducer/index.cjs",
70
- "default": "./context-reducer/index.cjs"
70
+ "require": "./context-state/index.cjs",
71
+ "default": "./context-state/index.cjs"
71
72
  },
72
73
  "./create-context-reducer": {
73
74
  "types": "./create-context-reducer/index.d.ts",
@@ -78,14 +79,23 @@
78
79
  "require": "./create-context-reducer/index.cjs",
79
80
  "default": "./create-context-reducer/index.cjs"
80
81
  },
81
- "./context-state": {
82
- "types": "./context-state/index.d.ts",
82
+ "./context-reducer": {
83
+ "types": "./context-reducer/index.d.ts",
83
84
  "import": {
84
- "types": "./context-state/index.d.ts",
85
- "default": "./context-state/index.mjs"
85
+ "types": "./context-reducer/index.d.ts",
86
+ "default": "./context-reducer/index.mjs"
86
87
  },
87
- "require": "./context-state/index.cjs",
88
- "default": "./context-state/index.cjs"
88
+ "require": "./context-reducer/index.cjs",
89
+ "default": "./context-reducer/index.cjs"
90
+ },
91
+ "./create-context-state": {
92
+ "types": "./create-context-state/index.d.ts",
93
+ "import": {
94
+ "types": "./create-context-state/index.d.ts",
95
+ "default": "./create-context-state/index.mjs"
96
+ },
97
+ "require": "./create-context-state/index.cjs",
98
+ "default": "./create-context-state/index.cjs"
89
99
  },
90
100
  "./create-fixed-array": {
91
101
  "types": "./create-fixed-array/index.d.ts",
@@ -105,15 +115,6 @@
105
115
  "require": "./create-local-storage-state/index.cjs",
106
116
  "default": "./create-local-storage-state/index.cjs"
107
117
  },
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
- },
117
118
  "./create-magic-portal": {
118
119
  "types": "./create-magic-portal/index.d.ts",
119
120
  "import": {
@@ -195,15 +196,6 @@
195
196
  "require": "./magic-portal/index.cjs",
196
197
  "default": "./magic-portal/index.cjs"
197
198
  },
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
- },
207
199
  "./no-ssr": {
208
200
  "types": "./no-ssr/index.d.ts",
209
201
  "import": {
@@ -213,6 +205,15 @@
213
205
  "require": "./no-ssr/index.cjs",
214
206
  "default": "./no-ssr/index.cjs"
215
207
  },
208
+ "./is-safari": {
209
+ "types": "./is-safari/index.d.ts",
210
+ "import": {
211
+ "types": "./is-safari/index.d.ts",
212
+ "default": "./is-safari/index.mjs"
213
+ },
214
+ "require": "./is-safari/index.cjs",
215
+ "default": "./is-safari/index.cjs"
216
+ },
216
217
  "./noop": {
217
218
  "types": "./noop/index.d.ts",
218
219
  "import": {
@@ -240,15 +241,6 @@
240
241
  "require": "./open-new-tab/index.cjs",
241
242
  "default": "./open-new-tab/index.cjs"
242
243
  },
243
- "./rem": {
244
- "types": "./rem/index.d.ts",
245
- "import": {
246
- "types": "./rem/index.d.ts",
247
- "default": "./rem/index.mjs"
248
- },
249
- "require": "./rem/index.cjs",
250
- "default": "./rem/index.cjs"
251
- },
252
244
  "./request-idle-callback": {
253
245
  "types": "./request-idle-callback/index.d.ts",
254
246
  "import": {
@@ -258,6 +250,15 @@
258
250
  "require": "./request-idle-callback/index.cjs",
259
251
  "default": "./request-idle-callback/index.cjs"
260
252
  },
253
+ "./rem": {
254
+ "types": "./rem/index.d.ts",
255
+ "import": {
256
+ "types": "./rem/index.d.ts",
257
+ "default": "./rem/index.mjs"
258
+ },
259
+ "require": "./rem/index.cjs",
260
+ "default": "./rem/index.cjs"
261
+ },
261
262
  "./types": {
262
263
  "types": "./types/index.d.ts",
263
264
  "import": {
@@ -474,6 +475,15 @@
474
475
  "require": "./use-react-router-is-match/index.cjs",
475
476
  "default": "./use-react-router-is-match/index.cjs"
476
477
  },
478
+ "./use-readonly-search-params": {
479
+ "types": "./use-readonly-search-params/index.d.ts",
480
+ "import": {
481
+ "types": "./use-readonly-search-params/index.d.ts",
482
+ "default": "./use-readonly-search-params/index.mjs"
483
+ },
484
+ "require": "./use-readonly-search-params/index.cjs",
485
+ "default": "./use-readonly-search-params/index.cjs"
486
+ },
477
487
  "./use-retimer": {
478
488
  "types": "./use-retimer/index.d.ts",
479
489
  "import": {
@@ -519,6 +529,15 @@
519
529
  "require": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs",
520
530
  "default": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs"
521
531
  },
532
+ "./use-state-with-deps": {
533
+ "types": "./use-state-with-deps/index.d.ts",
534
+ "import": {
535
+ "types": "./use-state-with-deps/index.d.ts",
536
+ "default": "./use-state-with-deps/index.mjs"
537
+ },
538
+ "require": "./use-state-with-deps/index.cjs",
539
+ "default": "./use-state-with-deps/index.cjs"
540
+ },
522
541
  "./use-typescript-happy-callback": {
523
542
  "types": "./use-typescript-happy-callback/index.d.ts",
524
543
  "import": {
package/sizes.json CHANGED
@@ -1 +1 @@
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}}}
1
+ {"total":{"raw":27628,"gzip":16819,"br":0},"exports":{"compose-context-provider":{"raw":177,"gzip":155,"br":122},"create-context-state":{"raw":145,"gzip":116,"br":96},"context-reducer":{"raw":557,"gzip":332,"br":319},"context-state":{"raw":402,"gzip":259,"br":218},"create-magic-portal":{"raw":224,"gzip":136,"br":112},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"create-local-storage-state":{"raw":402,"gzip":216,"br":189},"create-storage-state-factory":{"raw":592,"gzip":338,"br":304},"create-session-storage-state":{"raw":406,"gzip":215,"br":188},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"current-year":{"raw":524,"gzip":355,"br":293},"invariant":{"raw":178,"gzip":156,"br":118},"create-storage-hook":{"raw":2087,"gzip":897,"br":789},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"is-safari":{"raw":233,"gzip":164,"br":119},"noop":{"raw":33,"gzip":53,"br":37},"email-protection":{"raw":426,"gzip":321,"br":272},"open-new-tab":{"raw":335,"gzip":255,"br":187},"magic-portal":{"raw":1039,"gzip":521,"br":463},"nullthrow":{"raw":187,"gzip":163,"br":121},"types":{"raw":0,"gzip":20,"br":1},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"use":{"raw":298,"gzip":197,"br":160},"no-ssr":{"raw":465,"gzip":313,"br":260},"rem":{"raw":823,"gzip":395,"br":350},"request-idle-callback":{"raw":392,"gzip":221,"br":171},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"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-fast-click":{"raw":578,"gzip":377,"br":304},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110},"use-is-online":{"raw":370,"gzip":258,"br":220},"use-local-storage":{"raw":384,"gzip":215,"br":201},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-media-query":{"raw":604,"gzip":380,"br":315},"use-map":{"raw":339,"gzip":243,"br":208},"use-next-pathname":{"raw":314,"gzip":235,"br":203},"use-page-visibility":{"raw":359,"gzip":263,"br":210},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-react-router-is-match":{"raw":594,"gzip":395,"br":337},"use-react-router-enable-concurrent-navigation":{"raw":966,"gzip":470,"br":397},"use-readonly-search-params":{"raw":1120,"gzip":573,"br":477},"use-session-storage":{"raw":390,"gzip":210,"br":201},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-set":{"raw":340,"gzip":238,"br":203},"use-next-link":{"raw":1647,"gzip":875,"br":742},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-uncontrolled":{"raw":388,"gzip":273,"br":230},"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-url-hash-state":{"raw":1077,"gzip":611,"br":536}}}
@@ -1 +1 @@
1
- "use strict";var e=require("react"),n=require("../use-media-query/index.cjs");require("../no-ssr/index.cjs"),require("../noop/index.cjs"),exports.useFastClick=function(o){const s=e.useCallback(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),o(e))},[o]);return n.useMediaQuery("(pointer: coarse)",!1)?{onClick:s}:{onMouseDown:s}};
1
+ "use strict";var e=require("react"),n=require("../use-media-query/index.cjs");require("../no-ssr/index.cjs"),require("../noop/index.cjs"),require("event-target-bus"),exports.useFastClick=function(t){const r=e.useCallback(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),t(e))},[t]);return n.useMediaQuery("(pointer: coarse)",!1)?{onClick:r}:{onMouseDown:r}};
@@ -1 +1 @@
1
- import{useCallback as e}from"react";import{useMediaQuery as o}from"../use-media-query/index.mjs";import"../no-ssr/index.mjs";import"../noop/index.mjs";function n(n){const t=e(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),n(e))},[n]);return o("(pointer: coarse)",!1)?{onClick:t}:{onMouseDown:t}}export{n as useFastClick};
1
+ import{useCallback as e}from"react";import{useMediaQuery as o}from"../use-media-query/index.mjs";import"../no-ssr/index.mjs";import"../noop/index.mjs";import"event-target-bus";function t(t){const n=e(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),t(e))},[t]);return o("(pointer: coarse)",!1)?{onClick:n}:{onMouseDown:n}}export{t as useFastClick};
@@ -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 t(){return!("u"<typeof window)&&navigator.onLine}exports.useIsOnline=function(){return e.useSyncExternalStore(n,t,t)};
2
+ "use strict";var n=require("react"),e=require("event-target-bus");let t=null,r=null;function u(n){null!=t||(t=e.createEventTargetBus(window,"online")),null!=r||(r=e.createEventTargetBus(window,"offline"));const u=t.on(n),o=r.on(n);return()=>{u(),o()}}function o(){return!("u"<typeof window)&&navigator.onLine}exports.useIsOnline=function(){return n.useSyncExternalStore(u,o,o)};
@@ -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!("u"<typeof window)&&navigator.onLine}function o(){return n(e,i,i)}export{o as useIsOnline};
2
+ import{useSyncExternalStore as n}from"react";import{createEventTargetBus as o}from"event-target-bus";let t=null,e=null;function r(n){null!=t||(t=o(window,"online")),null!=e||(e=o(window,"offline"));const r=t.on(n),i=e.on(n);return()=>{r(),i()}}function i(){return!("u"<typeof window)&&navigator.onLine}function u(){return n(r,i,i)}export{u as useIsOnline};
@@ -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,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)};
2
+ "use strict";var e=require("../no-ssr/index.cjs"),r=require("../noop/index.cjs"),t=require("react"),n=require("event-target-bus");const o=new Map;function u(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,i){const a=t.useCallback(t=>(function(e,t){if("u"<typeof window)return r.noop;let u=o.get(e);return u||(u=n.createEventTargetBus(window.matchMedia(e),"change"),o.set(e,u)),u.on(t)})(e,t),[e]);return t.useSyncExternalStore(a,()=>"u"<typeof window?null!=i&&i:window.matchMedia(e).matches,void 0===i?u:()=>i)};
@@ -1,2 +1,2 @@
1
1
  'use client';
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};
2
+ import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as t}from"../noop/index.mjs";import{useCallback as o,useSyncExternalStore as n}from"react";import{createEventTargetBus as r}from"event-target-bus";const i=new Map;function u(){throw e("useMediaQuery cannot be used on the server without a serverValue")}function a(e,a){return n(o(o=>(function(e,o){if("u"<typeof window)return t;let n=i.get(e);return n||(n=r(window.matchMedia(e),"change"),i.set(e,n)),n.on(o)})(e,o),[e]),()=>"u"<typeof window?null!=a&&a:window.matchMedia(e).matches,void 0===a?u:()=>a)}export{a as useMediaQuery};
@@ -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=()=>!("u"<typeof document)&&!document.hidden;exports.usePageVisibility=function(){return e.useSyncExternalStore(t,i,i)};
2
+ "use strict";var e=require("react"),t=require("event-target-bus"),n=require("../noop/index.cjs");let r=null;const u=e=>"u"<typeof window?n.noop:(null!=r||(r=t.createEventTargetBus(document,"visibilitychange")),r.on(e)),i=()=>!("u"<typeof document)&&!document.hidden;exports.usePageVisibility=function(){return e.useSyncExternalStore(u,i,i)};
@@ -1,2 +1,2 @@
1
1
  'use client';
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};
2
+ import{useSyncExternalStore as t}from"react";import{createEventTargetBus as o}from"event-target-bus";import{noop as e}from"../noop/index.mjs";let n=null;const i=t=>"u"<typeof window?e:(null!=n||(n=o(document,"visibilitychange")),n.on(t)),r=()=>!("u"<typeof document)&&!document.hidden;function u(){return t(i,r,r)}export{u as usePageVisibility};
@@ -0,0 +1 @@
1
+ "use strict";var e=require("event-target-bus"),r=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),a=require("react");class t 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 t}delete(){throw new t}set(){throw new t}sort(){throw new t}}let s=null;function u(r){return"u"<typeof window?n.noop:(null!=s||(s=e.createEventTargetBus(window,"popstate")),s.on(r))}let l=null,c=null;function i(){return"u"<typeof window?new o:window.location.search===l&&null!==c?c:c=new o(l=window.location.search)}function w(){throw r.noSSRError('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}exports.ReadonlyURLSearchParams=o,exports.useReadonlySearchParams=function(e){return a.useSyncExternalStore(u,i,null==e?w:()=>{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{createEventTargetBus as e}from"event-target-bus";import{noSSRError as r}from"../no-ssr/index.mjs";import{noop as n}from"../noop/index.mjs";import{useSyncExternalStore as o}from"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 t extends URLSearchParams{append(){throw new a}delete(){throw new a}set(){throw new a}sort(){throw new a}}let s=null;function l(r){return"u"<typeof window?n:(null!=s||(s=e(window,"popstate")),s.on(r))}let u=null,c=null;function i(){return"u"<typeof window?new t:window.location.search===u&&null!==c?c:c=new t(u=window.location.search)}function w(){throw r('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}function d(e){return o(l,i,null==e?w:()=>{const r=e();return r instanceof t?r:new t(r)})}export{t as ReadonlyURLSearchParams,d as useReadonlySearchParams};
@@ -0,0 +1 @@
1
+ "use strict";var e=require("react"),t=require("../use-isomorphic-layout-effect/index.cjs");require("client-only"),exports.useStateWithDeps=function(r){const[,u]=e.useState({}),c=e.useRef(!1),s=e.useRef(r),n=e.useRef({}),o=e.useCallback(e=>{let t=!1;const r=s.current;for(const u in e)Object.prototype.hasOwnProperty.call(e,u)&&r[u]!==e[u]&&(r[u]=e[u],n.current[u]&&(t=!0));t&&!c.current&&u({})},[]);return t.useLayoutEffect(()=>(c.current=!1,()=>{c.current=!0})),[s,n,o]};
@@ -0,0 +1,9 @@
1
+ import { RefObject } from 'react';
2
+
3
+ declare function useStateWithDeps<S extends Record<string, any> = Record<string, any>>(initialState: S): [
4
+ stateRef: RefObject<S>,
5
+ stateDependenciesRef: RefObject<Partial<Record<keyof S, boolean>>>,
6
+ setState: (payload: Partial<S>) => void
7
+ ];
8
+
9
+ export { useStateWithDeps };
@@ -0,0 +1 @@
1
+ import{useState as t,useRef as r,useCallback as e}from"react";import{useLayoutEffect as o}from"../use-isomorphic-layout-effect/index.mjs";import"client-only";function n(n){const[,c]=t({}),i=r(!1),u=r(n),p=r({}),s=e(t=>{let r=!1;const e=u.current;for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&e[o]!==t[o]&&(e[o]=t[o],p.current[o]&&(r=!0));r&&!i.current&&c({})},[]);return o(()=>(i.current=!1,()=>{i.current=!0})),[u,p,s]}export{n as useStateWithDeps};
@@ -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("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
+ "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"),l=require("event-target-bus");let a=null;const i=e=>"u"<typeof window?r.noop:(null!=a||(a=l.createEventTargetBus(window,"hashchange")),a.on(e));function o(){throw n.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(r,n){var l;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t.t,deserializer:t.t};const u=a.raw?t.t:a.serializer,c=a.raw?t.t:a.deserializer,h=void 0===n?o:()=>u(n),d=e.useSyncExternalStore(i,()=>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,l=new URLSearchParams(t.slice(1)),a=s.n(e)?e(w):e;a===n||null===a?l.delete(r):l.set(r,u(a));const i=l.toString();t!==i&&(location.hash=i)},[n,w,r,u]);return[null!=(l=null!=w?w:n)?l:null,S]};
@@ -1 +1 @@
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};
1
+ import"client-only";import{useSyncExternalStore as e,useMemo as n,useCallback as r}from"react";import{noop as t}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";import{t as l}from"../chunks/index.D0KaUCcV.mjs";import{n as s}from"../chunks/index.C9-3oDdv.mjs";import{createEventTargetBus as a}from"event-target-bus";let i=null;const u=e=>"u"<typeof window?t:(null!=i||(i=a(window,"hashchange")),i.on(e));function h(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function c(t,o){var a;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:l,deserializer:l};const c=i.raw?l:i.serializer,m=i.raw?l:i.deserializer,d=e(u,()=>new URLSearchParams(location.hash.slice(1)).get(t),void 0===o?h:()=>c(o)),w=n(()=>null===d?null!=o?o:null:m(d),[o,m,d]),p=r(e=>{const n=location.hash,r=new URLSearchParams(n.slice(1)),l=s(e)?e(w):e;l===o||null===l?r.delete(t):r.set(t,c(l));const a=r.toString();n!==a&&(location.hash=a)},[o,w,t,c]);return[null!=(a=null!=w?w:o)?a:null,p]}export{c as unstable_useUrlHashState};