foxact 0.2.49 → 0.2.51

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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/chunks/index.BtiK5_Nn.cjs +1 -0
  3. package/chunks/index.C9-3oDdv.mjs +1 -0
  4. package/chunks/index.D0KaUCcV.mjs +1 -0
  5. package/chunks/index.b9dLwVor.cjs +1 -0
  6. package/create-local-storage-state/index.cjs +1 -1
  7. package/create-local-storage-state/index.mjs +1 -1
  8. package/create-magic-portal/index.cjs +1 -0
  9. package/create-magic-portal/index.d.ts +1 -0
  10. package/create-magic-portal/index.mjs +1 -0
  11. package/create-session-storage-state/index.cjs +1 -1
  12. package/create-session-storage-state/index.mjs +1 -1
  13. package/create-storage-hook/index.cjs +1 -1
  14. package/create-storage-hook/index.mjs +1 -1
  15. package/create-storage-state-factory/index.cjs +1 -1
  16. package/create-storage-state-factory/index.mjs +1 -1
  17. package/fetch-jsonp/index.cjs +1 -1
  18. package/fetch-jsonp/index.d.ts +1 -1
  19. package/fetch-jsonp/index.mjs +1 -1
  20. package/magic-portal/index.cjs +1 -0
  21. package/magic-portal/index.d.ts +18 -0
  22. package/magic-portal/index.mjs +1 -0
  23. package/package.json +34 -16
  24. package/sizes.json +1 -1
  25. package/use/index.cjs +1 -1
  26. package/use/index.d.ts +5 -1
  27. package/use/index.mjs +1 -1
  28. package/use-clipboard/index.mjs +1 -1
  29. package/use-intersection/index.d.ts +1 -0
  30. package/use-is-client/index.cjs +1 -1
  31. package/use-is-client/index.mjs +1 -1
  32. package/use-local-storage/index.cjs +1 -1
  33. package/use-local-storage/index.mjs +1 -1
  34. package/use-next-link/index.cjs +1 -1
  35. package/use-next-link/index.mjs +1 -1
  36. package/use-react-router-is-match/index.cjs +1 -1
  37. package/use-react-router-is-match/index.mjs +1 -1
  38. package/use-session-storage/index.cjs +1 -1
  39. package/use-session-storage/index.mjs +1 -1
  40. package/use-singleton/index.cjs +1 -1
  41. package/use-singleton/index.mjs +1 -1
  42. package/use-uncontrolled/index.cjs +1 -1
  43. package/use-uncontrolled/index.mjs +1 -1
  44. package/use-url-hash-state/index.cjs +1 -1
  45. package/use-url-hash-state/index.mjs +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <img src="https://pic.skk.moe/gh/foxact.gif" alt="foxact logo" width="128" height="128" align="right" />
1
+ <img src="https://img.skk.moe/gh/foxact.gif" alt="foxact logo" width="128" height="128" align="right" />
2
2
 
3
3
  # foxact
4
4
 
@@ -0,0 +1 @@
1
+ "use strict";exports.n=t=>"function"==typeof t;
@@ -0,0 +1 @@
1
+ const n=n=>"function"==typeof n;export{n};
@@ -0,0 +1 @@
1
+ function t(t){return t}export{t};
@@ -0,0 +1 @@
1
+ "use strict";exports.t=function(t){return t};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-state-factory/index.cjs");require("../create-storage-hook/index.cjs"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs");const r=e.createStorageStateFactory("localStorage");exports.createLocalStorageState=r;
1
+ "use strict";require("client-only");var e=require("../create-storage-state-factory/index.cjs");require("../chunks/index.b9dLwVor.cjs"),require("../create-storage-hook/index.cjs"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const r=e.createStorageStateFactory("localStorage");exports.createLocalStorageState=r;
@@ -1 +1 @@
1
- import"client-only";import{createStorageStateFactory as o}from"../create-storage-state-factory/index.mjs";import"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";const t=o("localStorage");export{t as createLocalStorageState};
1
+ import"client-only";import{createStorageStateFactory as o}from"../create-storage-state-factory/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../chunks/index.C9-3oDdv.mjs";const t=o("localStorage");export{t as createLocalStorageState};
@@ -0,0 +1 @@
1
+ "use strict";var e=require("../magic-portal/index.cjs");require("react/jsx-runtime"),require("client-only"),require("react-dom"),require("../context-state/index.cjs"),require("react"),require("../noop/index.cjs"),require("../no-ssr/index.cjs"),exports.createMagicPortal=e.createMagicPortal;
@@ -0,0 +1 @@
1
+ export { createMagicPortal } from '../magic-portal/index.js';
@@ -0,0 +1 @@
1
+ export{createMagicPortal}from"../magic-portal/index.mjs";import"react/jsx-runtime";import"client-only";import"react-dom";import"../context-state/index.mjs";import"react";import"../noop/index.mjs";import"../no-ssr/index.mjs";
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-state-factory/index.cjs");require("../create-storage-hook/index.cjs"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs");const r=e.createStorageStateFactory("sessionStorage");exports.createSessionStorageState=r;
1
+ "use strict";require("client-only");var e=require("../create-storage-state-factory/index.cjs");require("../chunks/index.b9dLwVor.cjs"),require("../create-storage-hook/index.cjs"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const r=e.createStorageStateFactory("sessionStorage");exports.createSessionStorageState=r;
@@ -1 +1 @@
1
- import"client-only";import{createStorageStateFactory as o}from"../create-storage-state-factory/index.mjs";import"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";const e=o("sessionStorage");export{e as createSessionStorageState};
1
+ import"client-only";import{createStorageStateFactory as o}from"../create-storage-state-factory/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../chunks/index.C9-3oDdv.mjs";const e=o("sessionStorage");export{e as createSessionStorageState};
@@ -1 +1 @@
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");const r=e=>"function"==typeof e,a=e=>e;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",c="localStorage"===n?"foxact/use-local-storage":"foxact/use-session-storage",s="undefined"==typeof window?o.noop:e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))},u="undefined"==typeof window?o.noop:(e,o)=>{try{window[n].setItem(e,o)}catch(e){console.warn("[".concat(c,"] Failed to set value to ").concat(n,", it might be blocked"))}finally{s(e)}},d="undefined"==typeof window?o.noop:e=>{try{window[n].removeItem(e)}catch(e){console.warn("[".concat(c,"] Failed to remove value from ").concat(n,", it might be blocked"))}finally{s(e)}},w=e=>{if("undefined"==typeof window)return null;try{return window[n].getItem(e)}catch(e){return console.warn("[".concat(c,"] Failed to get value from ").concat(n,", it might be blocked")),null}};return{useStorage:function(n,c){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const f=e.useCallback(e=>{if("undefined"==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=s.raw?a:s.serializer,y=s.raw?a:s.deserializer,g=void 0===c?i:()=>v(c),m=e.useSyncExternalStore(f,()=>w(n),g),p=e.useMemo(()=>null===m?null:y(m),[m,y]),h=e.useCallback(e=>{try{const o=r(e)?e(null!=p?p:null):e;null===o?d(n):u(n,v(o))}catch(e){console.warn(e)}},[n,v,p]);return t.useLayoutEffect(()=>{null===w(n)&&void 0!==c&&u(n,v(c))},[y,n,v,c]),[null===p?void 0===c?null:c:p,h]},useSetStorage:(o,t)=>e.useCallback(e=>{try{null===e?d(o):u(o,t(e))}catch(e){console.warn(e)}},[o,t])}};
1
+ "use strict";require("client-only");var e=require("react"),n=require("../noop/index.cjs"),o=require("../use-isomorphic-layout-effect/index.cjs"),t=require("../no-ssr/index.cjs"),r=require("../chunks/index.b9dLwVor.cjs"),i=require("../chunks/index.BtiK5_Nn.cjs");function a(){throw t.noSSRError("useLocalStorage cannot be used on the server without a serverValue")}exports.createStorage=function(t){const l="localStorage"===t?"foxact-use-local-storage":"foxact-use-session-storage",c="localStorage"===t?"foxact/use-local-storage":"foxact/use-session-storage",s="undefined"==typeof window?n.noop:e=>{window.dispatchEvent(new CustomEvent(l,{detail:e}))},u="undefined"==typeof window?n.noop:(e,n)=>{try{window[t].setItem(e,n)}catch(e){console.warn("[".concat(c,"] Failed to set value to ").concat(t,", it might be blocked"))}finally{s(e)}},d="undefined"==typeof window?n.noop:e=>{try{window[t].removeItem(e)}catch(e){console.warn("[".concat(c,"] Failed to remove value from ").concat(t,", it might be blocked"))}finally{s(e)}},w=e=>{if("undefined"==typeof window)return null;try{return window[t].getItem(e)}catch(e){return console.warn("[".concat(c,"] Failed to get value from ").concat(t,", it might be blocked")),null}};return{useStorage:function(t,c){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const f=e.useCallback(e=>{if("undefined"==typeof window)return n.noop;const o=n=>{"key"in n&&n.key!==t||e()},r=n=>{n.detail===t&&e()};return window.addEventListener("storage",o),window.addEventListener(l,r),()=>{window.removeEventListener("storage",o),window.removeEventListener(l,r)}},[t]),v=s.raw?r.t:s.serializer,g=s.raw?r.t:s.deserializer,y=void 0===c?a:()=>v(c),h=e.useSyncExternalStore(f,()=>w(t),y),m=e.useMemo(()=>null===h?null:g(h),[h,g]),p=e.useCallback(e=>{try{const n=i.n(e)?e(null!=m?m:null):e;null===n?d(t):u(t,v(n))}catch(e){console.warn(e)}},[t,v,m]);return o.useLayoutEffect(()=>{null===w(t)&&void 0!==c&&u(t,v(c))},[g,t,v,c]),[null===m?void 0===c?null:c:m,p]},useSetStorage:(n,o)=>e.useCallback(e=>{try{null===e?d(n):u(n,o(e))}catch(e){console.warn(e)}},[n,o])}};
@@ -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";const a=e=>"function"==typeof e,l=e=>e;function c(){throw i("useLocalStorage cannot be used on the server without a serverValue")}function s(i){const s="localStorage"===i?"foxact-use-local-storage":"foxact-use-session-storage",d="localStorage"===i?"foxact/use-local-storage":"foxact/use-session-storage",u="undefined"==typeof window?n:e=>{window.dispatchEvent(new CustomEvent(s,{detail:e}))},w="undefined"==typeof window?n:(e,o)=>{try{window[i].setItem(e,o)}catch(e){console.warn("[".concat(d,"] Failed to set value to ").concat(i,", it might be blocked"))}finally{u(e)}},f="undefined"==typeof window?n:e=>{try{window[i].removeItem(e)}catch(e){console.warn("[".concat(d,"] Failed to remove value from ").concat(i,", it might be blocked"))}finally{u(e)}},m=e=>{if("undefined"==typeof window)return null;try{return window[i].getItem(e)}catch(e){return console.warn("[".concat(d,"] Failed to get value from ").concat(i,", it might be blocked")),null}};return{useStorage:function(i,d){let u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const g=e(e=>{if("undefined"==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(s,t),()=>{window.removeEventListener("storage",o),window.removeEventListener(s,t)}},[i]),v=u.raw?l:u.serializer,y=u.raw?l:u.deserializer,p=o(g,()=>m(i),void 0===d?c:()=>v(d)),h=t(()=>null===p?null:y(p),[p,y]),S=e(e=>{try{const o=a(e)?e(null!=h?h:null):e;null===o?f(i):w(i,v(o))}catch(e){console.warn(e)}},[i,v,h]);return r(()=>{null===m(i)&&void 0!==d&&w(i,v(d))},[y,i,v,d]),[null===h?void 0===d?null:d:h,S]},useSetStorage:(o,t)=>e(e=>{try{null===e?f(o):w(o,t(e))}catch(e){console.warn(e)}},[o,t])}}export{s as createStorage};
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",d="localStorage"===i?"foxact/use-local-storage":"foxact/use-session-storage",u="undefined"==typeof window?n:e=>{window.dispatchEvent(new CustomEvent(c,{detail:e}))},w="undefined"==typeof window?n:(e,o)=>{try{window[i].setItem(e,o)}catch(e){console.warn("[".concat(d,"] Failed to set value to ").concat(i,", it might be blocked"))}finally{u(e)}},f="undefined"==typeof window?n:e=>{try{window[i].removeItem(e)}catch(e){console.warn("[".concat(d,"] Failed to remove value from ").concat(i,", it might be blocked"))}finally{u(e)}},m=e=>{if("undefined"==typeof window)return null;try{return window[i].getItem(e)}catch(e){return console.warn("[".concat(d,"] Failed to get value from ").concat(i,", it might be blocked")),null}};return{useStorage:function(i,d){let u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const g=e(e=>{if("undefined"==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=u.raw?a:u.serializer,p=u.raw?a:u.deserializer,y=o(g,()=>m(i),void 0===d?s:()=>v(d)),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?f(i):w(i,v(o))}catch(e){console.warn(e)}},[i,v,h]);return r(()=>{null===m(i)&&void 0!==d&&w(i,v(d))},[p,i,v,d]),[null===h?void 0===d?null:d:h,x]},useSetStorage:(o,t)=>e(e=>{try{null===e?f(o):w(o,t(e))}catch(e){console.warn(e)}},[o,t])}}export{c as createStorage};
@@ -1 +1 @@
1
- "use strict";var e=require("../create-storage-hook/index.cjs");require("client-only"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs");const r=e=>e;exports.createStorageStateFactory=function(t){return function(i,o){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:a,useSetStorage:n}=e.createStorage(t);return[()=>a(i,o,s),()=>a(i,o,s)[0],()=>n(i,s.raw?r:s.serializer)]}};
1
+ "use strict";var e=require("../chunks/index.b9dLwVor.cjs"),r=require("../create-storage-hook/index.cjs");require("client-only"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../chunks/index.BtiK5_Nn.cjs"),exports.createStorageStateFactory=function(i){return function(t,s){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:c,useSetStorage:o}=r.createStorage(i);return[()=>c(t,s,n),()=>c(t,s,n)[0],()=>o(t,n.raw?e.t:n.serializer)]}};
@@ -1 +1 @@
1
- import{createStorage as e}from"../create-storage-hook/index.mjs";import"client-only";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";const r=e=>e;function t(t){return function(o,i){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:s,useSetStorage:a}=e(t);return[()=>s(o,i,n),()=>s(o,i,n)[0],()=>a(o,n.raw?r:n.serializer)]}}export{t as createStorageStateFactory};
1
+ import{t as e}from"../chunks/index.D0KaUCcV.mjs";import{createStorage as r}from"../create-storage-hook/index.mjs";import"client-only";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../chunks/index.C9-3oDdv.mjs";function t(t){return function(o,i){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:s,useSetStorage:m}=r(t);return[()=>s(o,i,n),()=>s(o,i,n)[0],()=>m(o,n.raw?e:n.serializer)]}}export{t as createStorageStateFactory};
@@ -1 +1 @@
1
- "use strict";const e="__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";exports.fetchJsonp=function(o){if("undefined"==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 n="__".concat(Date.now(),"_").concat(Math.random().toString().slice(2),"__"),t="window.".concat(e,".").concat(n);if(Object.prototype.hasOwnProperty.call(window[e],n))throw TypeError("Callback name conflict: ".concat(n));const r=o(t);return new Promise((o,t)=>{const c=document.createElement("script");c.src=r,c.async=!0;const a=()=>{c.removeEventListener("error",i),c.remove(),window[e][n]&&delete window[e][n]};function i(){a(),t(Error("Failed to load script: ".concat(r)))}c.addEventListener("error",i),window[e][n]=e=>{a(),o(e)},document.body.append(c)})};
1
+ "use strict";const e="__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";exports.fetchJsonp=function(o,n){if("undefined"==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)})};
@@ -4,6 +4,6 @@ declare global {
4
4
  }
5
5
  }
6
6
  /** @see https://foxact.skk.moe/fetch-jsonp */
7
- declare function fetchJsonp<T>(getUrl: (callbackName: string) => string): Promise<T>;
7
+ declare function fetchJsonp<T>(getUrl: (callbackName: string) => string, scriptElOptions?: Partial<HTMLScriptElement>): Promise<T>;
8
8
 
9
9
  export { fetchJsonp };
@@ -1 +1 @@
1
- const e="__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";function o(o){if("undefined"==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 n="__".concat(Date.now(),"_").concat(Math.random().toString().slice(2),"__"),t="window.".concat(e,".").concat(n);if(Object.prototype.hasOwnProperty.call(window[e],n))throw TypeError("Callback name conflict: ".concat(n));const r=o(t);return new Promise((o,t)=>{const c=document.createElement("script");c.src=r,c.async=!0;const a=()=>{c.removeEventListener("error",i),c.remove(),window[e][n]&&delete window[e][n]};function i(){a(),t(Error("Failed to load script: ".concat(r)))}c.addEventListener("error",i),window[e][n]=e=>{a(),o(e)},document.body.append(c)})}export{o as fetchJsonp};
1
+ const e="__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";function o(o,n){if("undefined"==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",w),a.remove(),window[e][t]&&delete window[e][t]};function w(){i(),r(Error("Failed to load script: ".concat(c)))}a.addEventListener("error",w),window[e][t]=e=>{i(),o(e)},document.body.append(a)})}export{o as fetchJsonp};
@@ -0,0 +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"undefined"!=typeof window&&n?r.createPortal(t,n):null}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]};
@@ -0,0 +1,18 @@
1
+ type MagicPortalTargetProps<T extends React.ElementType = 'div'> = Omit<React.ComponentPropsWithoutRef<T>, 'children' | 'ref'> & {
2
+ as?: T | null;
3
+ /**
4
+ * MagicPortal do not support server-side rendering. By default, it will render nothing on the server.
5
+ *
6
+ * However, you can use `ssrFallback` to emit a fallback (e.g. skeleton) into server-rendered HTML.
7
+ */
8
+ ssrFallback?: React.ReactNode | null;
9
+ };
10
+ /** @see https://foxact.skk.moe/magic-portal */
11
+ declare function createMagicPortal(name?: string): [
12
+ PortalProvider: React.ComponentType<React.PropsWithChildren>,
13
+ PortalTarget: <T extends React.ElementType = 'div'>(props: MagicPortalTargetProps<T>) => React.ReactElement,
14
+ PortalContent: (props: React.PropsWithChildren) => React.ReactPortal | null
15
+ ];
16
+
17
+ export { createMagicPortal };
18
+ export type { MagicPortalTargetProps };
@@ -0,0 +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"undefined"!=typeof window&&r?o(n,r):null}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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxact",
3
- "version": "0.2.49",
3
+ "version": "0.2.51",
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": {
@@ -92,6 +92,15 @@
92
92
  "require": "./create-local-storage-state/index.cjs",
93
93
  "default": "./create-local-storage-state/index.cjs"
94
94
  },
95
+ "./create-magic-portal": {
96
+ "types": "./create-magic-portal/index.d.ts",
97
+ "import": {
98
+ "types": "./create-magic-portal/index.d.ts",
99
+ "default": "./create-magic-portal/index.mjs"
100
+ },
101
+ "require": "./create-magic-portal/index.cjs",
102
+ "default": "./create-magic-portal/index.cjs"
103
+ },
95
104
  "./create-session-storage-state": {
96
105
  "types": "./create-session-storage-state/index.d.ts",
97
106
  "import": {
@@ -110,6 +119,15 @@
110
119
  "require": "./create-storage-hook/index.cjs",
111
120
  "default": "./create-storage-hook/index.cjs"
112
121
  },
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
+ },
113
131
  "./create-storage-state-factory": {
114
132
  "types": "./create-storage-state-factory/index.d.ts",
115
133
  "import": {
@@ -119,14 +137,14 @@
119
137
  "require": "./create-storage-state-factory/index.cjs",
120
138
  "default": "./create-storage-state-factory/index.cjs"
121
139
  },
122
- "./current-year": {
123
- "types": "./current-year/index.d.ts",
140
+ "./email-protection": {
141
+ "types": "./email-protection/index.d.ts",
124
142
  "import": {
125
- "types": "./current-year/index.d.ts",
126
- "default": "./current-year/index.mjs"
143
+ "types": "./email-protection/index.d.ts",
144
+ "default": "./email-protection/index.mjs"
127
145
  },
128
- "require": "./current-year/index.cjs",
129
- "default": "./current-year/index.cjs"
146
+ "require": "./email-protection/index.cjs",
147
+ "default": "./email-protection/index.cjs"
130
148
  },
131
149
  "./fetch-jsonp": {
132
150
  "types": "./fetch-jsonp/index.d.ts",
@@ -155,6 +173,15 @@
155
173
  "require": "./is-safari/index.cjs",
156
174
  "default": "./is-safari/index.cjs"
157
175
  },
176
+ "./magic-portal": {
177
+ "types": "./magic-portal/index.d.ts",
178
+ "import": {
179
+ "types": "./magic-portal/index.d.ts",
180
+ "default": "./magic-portal/index.mjs"
181
+ },
182
+ "require": "./magic-portal/index.cjs",
183
+ "default": "./magic-portal/index.cjs"
184
+ },
158
185
  "./no-ssr": {
159
186
  "types": "./no-ssr/index.d.ts",
160
187
  "import": {
@@ -496,15 +523,6 @@
496
523
  },
497
524
  "require": "./use-url-hash-state/index.cjs",
498
525
  "default": "./use-url-hash-state/index.cjs"
499
- },
500
- "./email-protection": {
501
- "types": "./email-protection/index.d.ts",
502
- "import": {
503
- "types": "./email-protection/index.d.ts",
504
- "default": "./email-protection/index.mjs"
505
- },
506
- "require": "./email-protection/index.cjs",
507
- "default": "./email-protection/index.cjs"
508
526
  }
509
527
  }
510
528
  }
package/sizes.json CHANGED
@@ -1 +1 @@
1
- {"total":{"raw":23624,"gzip":14527,"br":0},"exports":{"create-context-state":{"raw":145,"gzip":116,"br":96},"context-state":{"raw":402,"gzip":259,"br":221},"create-local-storage-state":{"raw":328,"gzip":183,"br":154},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-session-storage-state":{"raw":332,"gzip":182,"br":152},"create-storage-state-factory":{"raw":519,"gzip":309,"br":263},"current-year":{"raw":592,"gzip":400,"br":326},"fetch-jsonp":{"raw":875,"gzip":533,"br":418},"is-safari":{"raw":248,"gzip":164,"br":117},"noop":{"raw":33,"gzip":53,"br":37},"no-ssr":{"raw":474,"gzip":316,"br":260},"nullthrow":{"raw":187,"gzip":163,"br":121},"open-new-tab":{"raw":344,"gzip":260,"br":190},"invariant":{"raw":178,"gzip":156,"br":118},"types":{"raw":0,"gzip":20,"br":1},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"request-idle-callback":{"raw":410,"gzip":229,"br":175},"rem":{"raw":823,"gzip":395,"br":350},"use":{"raw":283,"gzip":185,"br":154},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-array":{"raw":322,"gzip":236,"br":202},"create-storage-hook":{"raw":2073,"gzip":880,"br":764},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-fast-click":{"raw":553,"gzip":364,"br":297},"use-is-client":{"raw":150,"gzip":145,"br":115},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-isomorphic-layout-effect":{"raw":178,"gzip":142,"br":112},"use-is-online":{"raw":356,"gzip":212,"br":158},"use-local-storage":{"raw":310,"gzip":184,"br":157},"use-clipboard":{"raw":1177,"gzip":651,"br":552},"use-media-query":{"raw":725,"gzip":406,"br":332},"use-next-pathname":{"raw":314,"gzip":235,"br":203},"use-page-visibility":{"raw":290,"gzip":206,"br":154},"use-map":{"raw":339,"gzip":243,"br":208},"use-next-link":{"raw":1673,"gzip":871,"br":744},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-session-storage":{"raw":316,"gzip":181,"br":152},"use-react-router-is-match":{"raw":563,"gzip":372,"br":314},"use-singleton":{"raw":139,"gzip":130,"br":104},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":459,"gzip":325,"br":249},"use-react-router-enable-concurrent-navigation":{"raw":966,"gzip":470,"br":397},"use-uncontrolled":{"raw":352,"gzip":258,"br":216},"compose-context-provider":{"raw":177,"gzip":155,"br":122},"use-set":{"raw":340,"gzip":238,"br":203},"email-protection":{"raw":426,"gzip":321,"br":272},"use-url-hash-state":{"raw":1068,"gzip":616,"br":539}}}
1
+ {"total":{"raw":25541,"gzip":15476,"br":0},"exports":{"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-context-state":{"raw":145,"gzip":116,"br":96},"context-state":{"raw":402,"gzip":259,"br":221},"create-magic-portal":{"raw":224,"gzip":136,"br":112},"compose-context-provider":{"raw":177,"gzip":155,"br":122},"create-session-storage-state":{"raw":406,"gzip":215,"br":188},"create-local-storage-state":{"raw":402,"gzip":216,"br":189},"create-storage-state-factory":{"raw":592,"gzip":338,"br":304},"email-protection":{"raw":426,"gzip":321,"br":272},"current-year":{"raw":592,"gzip":400,"br":326},"invariant":{"raw":178,"gzip":156,"br":118},"fetch-jsonp":{"raw":899,"gzip":547,"br":430},"create-storage-hook":{"raw":2132,"gzip":903,"br":789},"is-safari":{"raw":248,"gzip":164,"br":117},"noop":{"raw":33,"gzip":53,"br":37},"no-ssr":{"raw":474,"gzip":316,"br":260},"nullthrow":{"raw":187,"gzip":163,"br":121},"magic-portal":{"raw":1047,"gzip":525,"br":451},"types":{"raw":0,"gzip":20,"br":1},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"rem":{"raw":823,"gzip":395,"br":350},"request-idle-callback":{"raw":410,"gzip":229,"br":175},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"open-new-tab":{"raw":344,"gzip":260,"br":190},"use":{"raw":298,"gzip":197,"br":160},"use-array":{"raw":322,"gzip":236,"br":202},"use-clipboard":{"raw":1177,"gzip":650,"br":552},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-isomorphic-layout-effect":{"raw":178,"gzip":142,"br":112},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-is-online":{"raw":356,"gzip":212,"br":158},"use-fast-click":{"raw":553,"gzip":364,"br":297},"use-local-storage":{"raw":384,"gzip":215,"br":201},"use-map":{"raw":339,"gzip":243,"br":208},"use-next-pathname":{"raw":314,"gzip":235,"br":203},"use-page-visibility":{"raw":290,"gzip":206,"br":154},"use-media-query":{"raw":725,"gzip":406,"br":332},"use-next-link":{"raw":1656,"gzip":880,"br":743},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-react-router-is-match":{"raw":594,"gzip":395,"br":337},"use-set":{"raw":340,"gzip":238,"br":203},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":459,"gzip":325,"br":249},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-session-storage":{"raw":390,"gzip":210,"br":201},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-react-router-enable-concurrent-navigation":{"raw":966,"gzip":470,"br":397},"use-uncontrolled":{"raw":388,"gzip":273,"br":230},"use-url-hash-state":{"raw":1133,"gzip":641,"br":554}}}
package/use/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const e=require("react").use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.catch(t=>{e.status="rejected",e.reason=t}).then(t=>{e.status="fulfilled",e.value=t}),e}});exports.use=e;
1
+ "use strict";var e=require("react");const t="function"==typeof e.use?e.use:e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}};exports.use=t;
package/use/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import react__default from 'react';
2
2
 
3
- declare const use: typeof react__default.use;
3
+ declare const use: typeof react__default.use | (<T>(promise: Promise<T> & {
4
+ status?: "pending" | "fulfilled" | "rejected";
5
+ value?: T;
6
+ reason?: unknown;
7
+ }) => T);
4
8
 
5
9
  export { use };
package/use/index.mjs CHANGED
@@ -1 +1 @@
1
- import e from"react";const t=e.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.catch(t=>{e.status="rejected",e.reason=t}).then(t=>{e.status="fulfilled",e.value=t}),e}});export{t as use};
1
+ import e from"react";const t="function"==typeof e.use?e.use:e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}};export{t as use};
@@ -1 +1 @@
1
- import"client-only";import{useState as r,useRef as o}from"react";import{noop as e}from"../noop/index.mjs";import{useStableHandler as t}from"../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs";import{useCallback as i}from"../use-typescript-happy-callback/index.mjs";class a extends Error{constructor(r){super(r),this.name="UseClipboardError"}}function l(){let{timeout:l=1e3,usePromptAsFallback:n=!1,promptFallbackText:c="Failed to copy to clipboard automatically, please manually copy the text below.",onCopyError:p}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[s,u]=r(null),[d,m]=r(!1),y=o(null),w=t(p||e),b=i(r=>{y.current&&clearTimeout(y.current),r&&(y.current=window.setTimeout(()=>m(!1),l)),m(r)},[l]),h=i(r=>{u(r),w(r)},[w]);return{copy:i(async r=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(r),b(!0);else throw new a("[foxact/use-clipboard] navigator.clipboard is not supported")}catch(o){if(n)try{window.prompt(c,r)}catch(r){h(r)}else h(o)}},[b,c,h,n]),reset:i(()=>{m(!1),u(null),y.current&&clearTimeout(y.current)},[]),error:s,copied:d}}export{a as UseClipboardError,l as useClipboard};
1
+ import"client-only";import{useState as r,useRef as e}from"react";import{noop as o}from"../noop/index.mjs";import{useStableHandler as t}from"../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs";import{useCallback as i}from"../use-typescript-happy-callback/index.mjs";class a extends Error{constructor(r){super(r),this.name="UseClipboardError"}}function l(){let{timeout:l=1e3,usePromptAsFallback:n=!1,promptFallbackText:c="Failed to copy to clipboard automatically, please manually copy the text below.",onCopyError:p}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[s,u]=r(null),[d,m]=r(!1),y=e(null),w=t(p||o),b=i(r=>{y.current&&clearTimeout(y.current),r&&(y.current=window.setTimeout(()=>m(!1),l)),m(r)},[l]),h=i(r=>{u(r),w(r)},[w]);return{copy:i(async r=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(r),b(!0);else throw new a("[foxact/use-clipboard] navigator.clipboard is not supported")}catch(e){if(n)try{window.prompt(c,r)}catch(r){h(r)}else h(e)}},[b,c,h,n]),reset:i(()=>{m(!1),u(null),y.current&&clearTimeout(y.current)},[]),error:s,copied:d}}export{a as UseClipboardError,l as useClipboard};
@@ -8,3 +8,4 @@ type UseIntersectionArgs = {
8
8
  declare function useIntersection<T extends Element>({ rootRef, rootMargin, disabled }: UseIntersectionArgs): [(element: T | null) => void, boolean, () => void];
9
9
 
10
10
  export { useIntersection };
11
+ export type { UseIntersectionArgs };
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react");exports.useIsClient=function(){const[t,r]=e.useState(!1);return e.useEffect(()=>{r(!0)},[]),t};
1
+ "use strict";require("client-only");var e=require("../noop/index.cjs"),r=require("react");function n(){return!0}function t(){return!1}exports.useIsClient=function(){return r.useSyncExternalStore(e.noop,n,t)};
@@ -1 +1 @@
1
- import"client-only";import{useState as t,useEffect as n}from"react";function o(){const[o,r]=t(!1);return n(()=>{r(!0)},[]),o}export{o as useIsClient};
1
+ import"client-only";import{noop as n}from"../noop/index.mjs";import{useSyncExternalStore as r}from"react";function t(){return!0}function o(){return!1}function e(){return r(n,t,o)}export{e as useIsClient};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-hook/index.cjs");require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs");const{useStorage:r,useSetStorage:o}=e.createStorage("localStorage");exports.useLocalStorage=r,exports.useSetLocalStorage=o;
1
+ "use strict";require("client-only");var e=require("../create-storage-hook/index.cjs");require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const{useStorage:r,useSetStorage:o}=e.createStorage("localStorage");exports.useLocalStorage=r,exports.useSetLocalStorage=o;
@@ -1 +1 @@
1
- import"client-only";import{createStorage as o}from"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";const{useStorage:e,useSetStorage:t}=o("localStorage");export{e as useLocalStorage,t as useSetLocalStorage};
1
+ import"client-only";import{createStorage as o}from"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const{useStorage:e,useSetStorage:t}=o("localStorage");export{e as useLocalStorage,t as useSetLocalStorage};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),t=require("next/navigation"),n=require("next/dist/shared/lib/router/utils/format-url"),r=require("../use-intersection/index.cjs"),o=require("../use-component-will-receive-update/index.cjs");function u(e,t,n){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,n)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}require("../request-idle-callback/index.cjs"),exports.unstable_useNextLink=function(i,s){let{prefetch:c,ref:l,onClick:a,onMouseEnter:f,onTouchStart:p,scroll:d=!0,replace:v=!1,...E}=s;process.env.NODE_ENV;const y=null==c?"auto":"full",N=!1!==c,h=t.useRouter(),[k,m]=e.useTransition(),[b,q,x]=r.useIntersection(e.useMemo(()=>({rootMargin:"200px"}),[])),g=e.useMemo(()=>"string"==typeof i?i:n.formatUrl(i),[i]);return o.useComponentWillReceiveUpdate(x,[g]),e.useEffect(()=>{"production"===process.env.NODE_ENV&&q&&N&&u(h,g,{kind:y})},[y,q,N,g,h]),[k,{ref:e.useCallback(e=>{b(e),"function"==typeof l?l(e):l&&e&&(l.current=e)},[l,b]),onClick:e.useCallback(e=>{if("function"==typeof a&&a(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;"A"===t.toUpperCase()&&function(e){const t=e.currentTarget,n=t.getAttribute("target");return n&&"_self"!==n||t.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e)||(e.preventDefault(),m(()=>{h[v?"replace":"push"](g,{scroll:d})}))},[a,v,g,h,d]),onMouseEnter:e.useCallback(e=>{"function"==typeof f&&f(e),"development"!==process.env.NODE_ENV&&N&&u(h,g,{kind:y})},[y,f,N,g,h]),onTouchStart:e.useCallback(e=>{"function"==typeof p&&p(e),"development"!==process.env.NODE_ENV&&N&&u(h,g,{kind:y})},[y,p,N,g,h]),...E}]};
1
+ "use strict";require("client-only");var e=require("react"),t=require("next/navigation"),n=require("next/dist/shared/lib/router/utils/format-url"),r=require("../use-intersection/index.cjs"),o=require("../use-component-will-receive-update/index.cjs");function u(e,t,n){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,n)).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]=r.useIntersection(i),C=e.useMemo(()=>"string"==typeof c?c:n.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 n=e.currentTarget,r=n.getAttribute("target");return r&&"_self"!==r||n.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}]};
@@ -1 +1 @@
1
- import"client-only";import{useTransition as e,useMemo as t,useEffect as n,useCallback as o}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 s}from"../use-component-will-receive-update/index.mjs";import"../request-idle-callback/index.mjs";function u(e,t,n){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,n)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}const p=function(p,l){let{prefetch:f,ref:a,onClick:d,onMouseEnter:m,onTouchStart:v,scroll:E=!0,replace:y=!1,...N}=l;process.env.NODE_ENV;const h=null==f?"auto":"full",x=!1!==f,g=r(),[_,k]=e(),[w,D,O]=c(t(()=>({rootMargin:"200px"}),[])),V=t(()=>"string"==typeof p?p:i(p),[p]);return s(O,[V]),n(()=>{"production"===process.env.NODE_ENV&&D&&x&&u(g,V,{kind:h})},[h,D,x,V,g]),[_,{ref:o(e=>{w(e),"function"==typeof a?a(e):a&&e&&(a.current=e)},[a,w]),onClick:o(e=>{if("function"==typeof d&&d(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;"A"===t.toUpperCase()&&function(e){const t=e.currentTarget,n=t.getAttribute("target");return n&&"_self"!==n||t.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e)||(e.preventDefault(),k(()=>{g[y?"replace":"push"](V,{scroll:E})}))},[d,y,V,g,E]),onMouseEnter:o(e=>{"function"==typeof m&&m(e),"development"!==process.env.NODE_ENV&&x&&u(g,V,{kind:h})},[h,m,x,V,g]),onTouchStart:o(e=>{"function"==typeof v&&v(e),"development"!==process.env.NODE_ENV&&x&&u(g,V,{kind:h})},[h,v,x,V,g]),...N}]};export{p as unstable_useNextLink};
1
+ import"client-only";import{useTransition as e,useMemo as t,useEffect as n,useCallback as o}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,n){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,n)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}const l={rootMargin:"200px"},p=function(p,f){let{prefetch:a,ref:d,onClick:m,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]),n(()=>{"production"!==process.env.NODE_ENV||b&&g&&s(k,O,{kind:x})},[x,b,g,O,k]),[w,{ref:o(e=>{D(e),"function"==typeof d?d(e):d&&e&&(d.current=e)},[d,D]),onClick:o(e=>{if("function"==typeof m&&m(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;"A"===t.toUpperCase()&&function(e){var t;const n=e.currentTarget,o=n.getAttribute("target");return o&&"_self"!==o||n.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})}))},[m,E,O,k,h]),onMouseEnter:o(e=>{"function"==typeof v&&v(e),"development"===process.env.NODE_ENV||g&&s(k,O,{kind:x})},[x,v,g,O,k]),onTouchStart:o(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 +1 @@
1
- "use strict";require("client-only");var e=require("react"),t=require("react-router-dom");const r=e=>e;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}=t.useLocation(),{navigator:{encodeLocation:i=r}}=e.useContext(t.UNSAFE_NavigationContext),c=t.useResolvedPath(o,{relative:a});return e.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
+ "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 +1 @@
1
- import"client-only";import{useContext as t,useMemo as e}from"react";import{useLocation as r,UNSAFE_NavigationContext as o,useResolvedPath as a}from"react-router-dom";const n=t=>t;function c(c){let{relative:i,caseSensitive:m=!1,end:s=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{pathname:h}=r(),{navigator:{encodeLocation:l=n}}=t(o),p=a(c,{relative:i});return e(()=>{let t=h,e=l(p).pathname;return m||(t=t.toLowerCase(),e=e.toLowerCase()),t===e||!s&&t.startsWith(e)&&"/"===t.charAt(e.length)},[l,p,h,m,s])}export{c as useReactRouterIsMatch};
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};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-hook/index.cjs");require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs");const{useStorage:r,useSetStorage:s}=e.createStorage("sessionStorage");exports.useSessionStorage=r,exports.useSetSessionStorage=s;
1
+ "use strict";require("client-only");var e=require("../create-storage-hook/index.cjs");require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const{useStorage:r,useSetStorage:s}=e.createStorage("sessionStorage");exports.useSessionStorage=r,exports.useSetSessionStorage=s;
@@ -1 +1 @@
1
- import"client-only";import{createStorage as e}from"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";const{useStorage:o,useSetStorage:s}=e("sessionStorage");export{o as useSessionStorage,s as useSetSessionStorage};
1
+ import"client-only";import{createStorage as e}from"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const{useStorage:o,useSetStorage:s}=e("sessionStorage");export{o as useSessionStorage,s as useSetSessionStorage};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react");exports.useSingleton=function(r){const t=e.useRef();return t.current||(t.current=r()),t};
1
+ "use strict";require("client-only");var e=require("react");exports.useSingleton=function(r){const n=e.useRef(null);return null==n.current&&(n.current=r()),n};
@@ -1 +1 @@
1
- import"client-only";import{useRef as r}from"react";function t(t){const n=r();return n.current||(n.current=t()),n}export{t as useSingleton};
1
+ import"client-only";import{useRef as n}from"react";function r(r){const t=n(null);return null==t.current&&(t.current=r()),t}export{r as useSingleton};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),r=require("../use-typescript-happy-callback/index.cjs");const t=e=>e;exports.useUncontrolled=function(u){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;const n=e.useRef(null),[l,s]=e.useReducer((e,r)=>c(r),u);return[l,r.useCallback(()=>{n.current&&s(n.current.value)},[]),n]};
1
+ "use strict";require("client-only");var e=require("react"),r=require("../use-typescript-happy-callback/index.cjs"),u=require("../chunks/index.b9dLwVor.cjs");exports.useUncontrolled=function(c){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.t;const n=e.useRef(null),[l,s]=e.useReducer((e,r)=>t(r),c);return[l,r.useCallback(()=>{n.current&&s(n.current.value)},[]),n]};
@@ -1 +1 @@
1
- import"client-only";import{useRef as t,useReducer as r}from"react";import{useCallback as e}from"../use-typescript-happy-callback/index.mjs";const n=t=>t;function o(o){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n;const l=t(null),[i,p]=r((t,r)=>c(r),o);return[i,e(()=>{l.current&&p(l.current.value)},[]),l]}export{o as useUncontrolled};
1
+ import"client-only";import{useRef as r,useReducer as t}from"react";import{useCallback as e}from"../use-typescript-happy-callback/index.mjs";import{t as n}from"../chunks/index.D0KaUCcV.mjs";function o(o){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n;const l=r(null),[i,m]=t((r,t)=>c(t),o);return[i,e(()=>{l.current&&m(l.current.value)},[]),l]}export{o as useUncontrolled};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),n=require("../noop/index.cjs"),r=require("../no-ssr/index.cjs");const t=e=>e,a=(()=>{if("undefined"==typeof window)return e=>n.noop;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)})})(),l=e=>"function"==typeof e;function o(){throw r.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(n,r){var s;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t,deserializer:t};const u=i.raw?t:i.serializer,c=i.raw?t:i.deserializer,h=void 0===r?o:()=>u(r),d=e.useSyncExternalStore(a,()=>new URLSearchParams(location.hash.slice(1)).get(n),h),w=e.useMemo(()=>null===d?null!=r?r:null:c(d),[r,c,d]),S=e.useCallback(e=>{const t=location.hash,a=new URLSearchParams(t.slice(1)),o=l(e)?e(w):e;o===r||null===o?a.delete(n):a.set(n,u(o));const s=a.toString();t!==s&&(location.hash=s)},[r,w,n,u]);return[null!=(s=null!=w?w:r)?s: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");const a=(()=>{if("undefined"==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 t,useCallback as n}from"react";import{noop as r}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";const a=e=>e,l=(()=>{if("undefined"==typeof window)return e=>r;let e=!1;const t=new Set,n=()=>{t.forEach(e=>e())};return r=>(t.add(r),e||(e=!0,window.addEventListener("hashchange",n)),()=>{t.delete(r)})})(),s=e=>"function"==typeof e;function i(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function u(r,o){var u;let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:a,deserializer:a};const h=c.raw?a:c.serializer,d=c.raw?a:c.deserializer,w=e(l,()=>new URLSearchParams(location.hash.slice(1)).get(r),void 0===o?i:()=>h(o)),f=t(()=>null===w?null!=o?o:null:d(w),[o,d,w]),m=n(e=>{const t=location.hash,n=new URLSearchParams(t.slice(1)),a=s(e)?e(f):e;a===o||null===a?n.delete(r):n.set(r,h(a));const l=n.toString();t!==l&&(location.hash=l)},[o,f,r,h]);return[null!=(u=null!=f?f:o)?u:null,m]}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 s}from"../chunks/index.D0KaUCcV.mjs";import{n as a}from"../chunks/index.C9-3oDdv.mjs";const i=(()=>{if("undefined"==typeof window)return e=>t;let e=!1;const n=new Set,r=()=>{n.forEach(e=>e())};return t=>(n.add(t),e||(e=!0,window.addEventListener("hashchange",r)),()=>{n.delete(t)})})();function l(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function u(t,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(i,()=>new URLSearchParams(location.hash.slice(1)).get(t),void 0===o?l:()=>h(o)),w=n(()=>null===m?null!=o?o:null:d(m),[o,d,m]),f=r(e=>{const n=location.hash,r=new URLSearchParams(n.slice(1)),s=a(e)?e(w):e;s===o||null===s?r.delete(t):r.set(t,h(s));const i=r.toString();n!==i&&(location.hash=i)},[o,w,t,h]);return[null!=(u=null!=w?w:o)?u:null,f]}export{u as unstable_useUrlHashState};