foxact 0.3.7 → 0.3.9
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/browser/index.cjs +1 -0
- package/browser/index.d.ts +21 -0
- package/browser/index.mjs +1 -0
- package/create-storage-hook/index.cjs +1 -1
- package/create-storage-hook/index.mjs +1 -1
- package/fetch-jsonp/index.cjs +1 -1
- package/fetch-jsonp/index.mjs +1 -1
- package/is-safari/index.cjs +1 -1
- package/is-safari/index.mjs +1 -1
- package/merge-props/index.cjs +1 -0
- package/merge-props/index.d.ts +7 -0
- package/merge-props/index.mjs +1 -0
- package/no-ssr/index.cjs +1 -1
- package/no-ssr/index.d.ts +3 -1
- package/no-ssr/index.mjs +1 -1
- package/package.json +155 -128
- package/polymorphic/index.cjs +1 -0
- package/polymorphic/index.d.ts +19 -0
- package/polymorphic/index.mjs +1 -0
- package/sizes.json +1 -1
- package/use/index.cjs +1 -1
- package/use/index.d.ts +21 -7
- package/use/index.mjs +1 -1
- package/use-abortable-effect/index.d.ts +1 -3
- package/use-clipboard/index.cjs +1 -1
- package/use-clipboard/index.mjs +1 -1
- package/use-component-will-receive-update/index.cjs +1 -1
- package/use-component-will-receive-update/index.mjs +1 -1
- package/use-debounced-state/index.cjs +1 -1
- package/use-debounced-state/index.mjs +1 -1
- package/use-is-client/index.cjs +1 -1
- package/use-is-client/index.mjs +1 -1
- package/use-is-online/index.cjs +1 -1
- package/use-is-online/index.mjs +1 -1
- package/use-media-query/index.cjs +1 -1
- package/use-media-query/index.mjs +1 -1
- package/use-page-visibility/index.cjs +1 -1
- package/use-page-visibility/index.mjs +1 -1
- package/use-readonly-search-params/index.cjs +1 -1
- package/use-readonly-search-params/index.mjs +1 -1
- package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs +1 -1
- package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs +1 -1
- package/use-url-hash-state/index.cjs +1 -1
- package/use-url-hash-state/index.mjs +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,r=require("react-dom"),t=require("../no-ssr/index.cjs"),o=(e=Object.create(null),r&&Object.keys(r).forEach(function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:function(){return r[t]}})}}),e.default=r,Object.freeze(e));const n="Browser-only rendering was requested by `browser()`.";function s(e){let r;if(void 0===e)return t.noSSRError(n);if("function"==typeof e)try{r=e()}catch(e){r="The reason for browser-only rendering could not be determined because its initializer threw."}else r=e;return t.noSSRError(n,void 0,{cause:r})}const i={status:"fulfilled",value:void 0,then:(e,r)=>Promise.resolve(void 0).then(e,r)},u="browser"in o&&"function"==typeof o.browser?o.browser:function(e){if("u"<typeof window){const r=s(e);return{status:"rejected",reason:r,then:(e,t)=>Promise.reject(r).then(e,t)}}return i};exports.browser=u,exports.browserBailoutError=s;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FulfilledReactPromise, RejectedReactPromise } from '../use/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Explains why the content has to render in the browser. It becomes the `cause`
|
|
5
|
+
* of the error reported by the server renderer. A function is only invoked by
|
|
6
|
+
* the server renderer and never in the browser, so pass one (e.g. `() => new
|
|
7
|
+
* Error('...')`) when creating the reason is expensive.
|
|
8
|
+
*/
|
|
9
|
+
type BrowserReason = string | (() => unknown);
|
|
10
|
+
/**
|
|
11
|
+
* The opaque value returned by `browser()`. Pass it to `use()`, do not read
|
|
12
|
+
* it, await it, or throw it yourself.
|
|
13
|
+
*/
|
|
14
|
+
type BrowserUsable = FulfilledReactPromise<undefined> | RejectedReactPromise<undefined>;
|
|
15
|
+
/** @private */
|
|
16
|
+
declare function browserBailoutError(reason?: BrowserReason): Error;
|
|
17
|
+
/** @see https://foxact.skk.moe/browser */
|
|
18
|
+
declare const browser: (reason?: BrowserReason) => BrowserUsable;
|
|
19
|
+
|
|
20
|
+
export { browser, browserBailoutError };
|
|
21
|
+
export type { BrowserReason, BrowserUsable };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react-dom";import{noSSRError as r}from"../no-ssr/index.mjs";const o="Browser-only rendering was requested by `browser()`.";function t(e){let t;if(void 0===e)return r(o);if("function"==typeof e)try{t=e()}catch(e){t="The reason for browser-only rendering could not be determined because its initializer threw."}else t=e;return r(o,void 0,{cause:t})}const n={status:"fulfilled",value:void 0,then:(e,r)=>Promise.resolve(void 0).then(e,r)},s="browser"in e&&"function"==typeof e.browser?e.browser:function(e){if("u"<typeof window){const r=t(e);return{status:"rejected",reason:r,then:(e,o)=>Promise.reject(r).then(e,o)}}return n};export{s as browser,t as browserBailoutError};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),t=require("../noop/index.cjs"),n=require("../use-isomorphic-layout-effect/index.cjs"),r=require("../no-ssr/index.cjs"),o=require("../chunks/index.b9dLwVor.cjs"),i=require("../chunks/index.BtiK5_Nn.cjs");exports.createStorage=function(a){const s="localStorage"===a?"foxact-use-local-storage":"foxact-use-session-storage",l="localStorage"===a?"foxact/use-local-storage":"foxact/use-session-storage";function c(){throw r.noSSRError("[".concat(l,"] cannot be used on the server without a serverValue"))}const u="u"<typeof window?t.noop:e=>{window.dispatchEvent(new CustomEvent(s,{detail:e}))},d="u"<typeof window?t.noop:(e,t)=>{try{window[a].setItem(e,t)}catch(e){console.warn("[".concat(l,"] Failed to set value to ").concat(a,", it might be blocked"))}finally{u(e)}},w="u"<typeof window?t.noop:e=>{try{window[a].removeItem(e)}catch(e){console.warn("[".concat(l,"] Failed to remove value from ").concat(a,", it might be blocked"))}finally{u(e)}},f=e=>{if("u"<typeof window)return null;try{return window[a].getItem(e)}catch(e){return console.warn("[".concat(l,"] Failed to get value from ").concat(a,", it might be blocked")),null}},v=function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const r=n.raw?o.t:n.serializer,a=n.raw?o.t:n.deserializer;return e.useCallback(e=>{try{let n;if(i.n(e)){const r=f(t),o=null===r?null:a(r);n=e(o)}else n=e;null===n?w(t):d(t,r(n))}catch(e){console.warn(e)}},[t,r,a])};function g(r,i){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const l=e.useCallback(e=>{if("u"<typeof window)return t.noop;const n=t=>{"key"in t&&t.key!==r||e()},o=t=>{t.detail===r&&e()};return window.addEventListener("storage",n),window.addEventListener(s,o),()=>{window.removeEventListener("storage",n),window.removeEventListener(s,o)}},[r]),u=a.raw?o.t:a.serializer,w=a.raw?o.t:a.deserializer,v=void 0===i?c:()=>u(i),g=e.useSyncExternalStore(l,()=>f(r),v),y=e.useMemo(()=>null===g?null:w(g),[g,w]);return n.useLayoutEffect(()=>{null===f(r)&&
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),t=require("../noop/index.cjs"),n=require("../use-isomorphic-layout-effect/index.cjs"),r=require("../no-ssr/index.cjs"),o=require("../chunks/index.b9dLwVor.cjs"),i=require("../chunks/index.BtiK5_Nn.cjs");exports.createStorage=function(a){const s="localStorage"===a?"foxact-use-local-storage":"foxact-use-session-storage",l="localStorage"===a?"foxact/use-local-storage":"foxact/use-session-storage";function c(){throw r.noSSRError("[".concat(l,"] cannot be used on the server without a serverValue"))}const u="u"<typeof window?t.noop:e=>{window.dispatchEvent(new CustomEvent(s,{detail:e}))},d="u"<typeof window?t.noop:(e,t)=>{try{window[a].setItem(e,t)}catch(e){console.warn("[".concat(l,"] Failed to set value to ").concat(a,", it might be blocked"))}finally{u(e)}},w="u"<typeof window?t.noop:e=>{try{window[a].removeItem(e)}catch(e){console.warn("[".concat(l,"] Failed to remove value from ").concat(a,", it might be blocked"))}finally{u(e)}},f=e=>{if("u"<typeof window)return null;try{return window[a].getItem(e)}catch(e){return console.warn("[".concat(l,"] Failed to get value from ").concat(a,", it might be blocked")),null}},v=function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const r=n.raw?o.t:n.serializer,a=n.raw?o.t:n.deserializer;return e.useCallback(e=>{try{let n;if(i.n(e)){const r=f(t),o=null===r?null:a(r);n=e(o)}else n=e;null===n?w(t):d(t,r(n))}catch(e){console.warn(e)}},[t,r,a])};function g(r,i){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const l=e.useCallback(e=>{if("u"<typeof window)return t.noop;const n=t=>{"key"in t&&t.key!==r||e()},o=t=>{t.detail===r&&e()};return window.addEventListener("storage",n),window.addEventListener(s,o),()=>{window.removeEventListener("storage",n),window.removeEventListener(s,o)}},[r]),u=a.raw?o.t:a.serializer,w=a.raw?o.t:a.deserializer,v=void 0===i?c:()=>u(i),g=e.useSyncExternalStore(l,()=>f(r),v),y=e.useMemo(()=>null===g?null:w(g),[g,w]);return n.useLayoutEffect(()=>{void 0!==i&&null===f(r)&&d(r,u(i))},[r,u,i]),null===y?void 0===i?null:i:y}return{useStorageValue:g,useSetStorage:v,useStorage:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};return[g(e,t,n),v(e,n)]}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useCallback as e,useSyncExternalStore as t,useMemo as o}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(s){const c="localStorage"===s?"foxact-use-local-storage":"foxact-use-session-storage",u="localStorage"===s?"foxact/use-local-storage":"foxact/use-session-storage";function d(){throw i("[".concat(u,"] cannot be used on the server without a serverValue"))}const w="u"<typeof window?n:e=>{window.dispatchEvent(new CustomEvent(c,{detail:e}))},f="u"<typeof window?n:(e,t)=>{try{window[s].setItem(e,t)}catch(e){console.warn("[".concat(u,"] Failed to set value to ").concat(s,", it might be blocked"))}finally{w(e)}},m="u"<typeof window?n:e=>{try{window[s].removeItem(e)}catch(e){console.warn("[".concat(u,"] Failed to remove value from ").concat(s,", it might be blocked"))}finally{w(e)}},g=e=>{if("u"<typeof window)return null;try{return window[s].getItem(e)}catch(e){return console.warn("[".concat(u,"] Failed to get value from ").concat(s,", it might be blocked")),null}},v=function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const n=o.raw?a:o.serializer,r=o.raw?a:o.deserializer;return e(e=>{try{let o;if(l(e)){const n=g(t),i=null===n?null:r(n);o=e(i)}else o=e;null===o?m(t):f(t,n(o))}catch(e){console.warn(e)}},[t,n,r])};function p(i,l){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const u=e(e=>{if("u"<typeof window)return n;const t=t=>{"key"in t&&t.key!==i||e()},o=t=>{t.detail===i&&e()};return window.addEventListener("storage",t),window.addEventListener(c,o),()=>{window.removeEventListener("storage",t),window.removeEventListener(c,o)}},[i]),w=s.raw?a:s.serializer,m=s.raw?a:s.deserializer,v=t(u,()=>g(i),void 0===l?d:()=>w(l)),p=o(()=>null===v?null:m(v),[v,m]);return r(()=>{null===g(i)&&
|
|
1
|
+
import"client-only";import{useCallback as e,useSyncExternalStore as t,useMemo as o}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(s){const c="localStorage"===s?"foxact-use-local-storage":"foxact-use-session-storage",u="localStorage"===s?"foxact/use-local-storage":"foxact/use-session-storage";function d(){throw i("[".concat(u,"] cannot be used on the server without a serverValue"))}const w="u"<typeof window?n:e=>{window.dispatchEvent(new CustomEvent(c,{detail:e}))},f="u"<typeof window?n:(e,t)=>{try{window[s].setItem(e,t)}catch(e){console.warn("[".concat(u,"] Failed to set value to ").concat(s,", it might be blocked"))}finally{w(e)}},m="u"<typeof window?n:e=>{try{window[s].removeItem(e)}catch(e){console.warn("[".concat(u,"] Failed to remove value from ").concat(s,", it might be blocked"))}finally{w(e)}},g=e=>{if("u"<typeof window)return null;try{return window[s].getItem(e)}catch(e){return console.warn("[".concat(u,"] Failed to get value from ").concat(s,", it might be blocked")),null}},v=function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const n=o.raw?a:o.serializer,r=o.raw?a:o.deserializer;return e(e=>{try{let o;if(l(e)){const n=g(t),i=null===n?null:r(n);o=e(i)}else o=e;null===o?m(t):f(t,n(o))}catch(e){console.warn(e)}},[t,n,r])};function p(i,l){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const u=e(e=>{if("u"<typeof window)return n;const t=t=>{"key"in t&&t.key!==i||e()},o=t=>{t.detail===i&&e()};return window.addEventListener("storage",t),window.addEventListener(c,o),()=>{window.removeEventListener("storage",t),window.removeEventListener(c,o)}},[i]),w=s.raw?a:s.serializer,m=s.raw?a:s.deserializer,v=t(u,()=>g(i),void 0===l?d:()=>w(l)),p=o(()=>null===v?null:m(v),[v,m]);return r(()=>{void 0!==l&&null===g(i)&&f(i,w(l))},[i,w,l]),null===p?void 0===l?null:l:p}return{useStorageValue:p,useSetStorage:v,useStorage:function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};return[p(e,t,o),v(e,o)]}}}export{s as createStorage};
|
package/fetch-jsonp/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";var e=require("../invariant/index.cjs");const n="__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";exports.fetchJsonp=function(o,t){e.invariant("u">typeof window,"fetchJsonp is only available in the browser"),window[n]||Object.defineProperty(window,n,{value:{},writable:!0,configurable:!0,enumerable:!1});const r="__".concat(Date.now(),"_").concat(Math.random().toString().slice(2),"__"),c="window.".concat(n,".").concat(r);if(Object.prototype.hasOwnProperty.call(window[n],r))throw TypeError("Callback name conflict: ".concat(r));const a=o(c);return new Promise((e,o)=>{const c=document.createElement("script");c.src=a,c.async=!0,t&&Object.assign(c,t);const i=()=>{c.removeEventListener("error",s),c.remove(),window[n][r]&&delete window[n][r]};function s(){i(),o(Error("Failed to load script: ".concat(a)))}c.addEventListener("error",s),window[n][r]=n=>{i(),e(n)},document.body.append(c)})};
|
package/fetch-jsonp/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{invariant as o}from"../invariant/index.mjs";const e="__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";function n(n,t){o("u">typeof window,"fetchJsonp is only available in the browser"),window[e]||Object.defineProperty(window,e,{value:{},writable:!0,configurable:!0,enumerable:!1});const c="__".concat(Date.now(),"_").concat(Math.random().toString().slice(2),"__"),r="window.".concat(e,".").concat(c);if(Object.prototype.hasOwnProperty.call(window[e],c))throw TypeError("Callback name conflict: ".concat(c));const a=n(r);return new Promise((o,n)=>{const r=document.createElement("script");r.src=a,r.async=!0,t&&Object.assign(r,t);const i=()=>{r.removeEventListener("error",s),r.remove(),window[e][c]&&delete window[e][c]};function s(){i(),n(Error("Failed to load script: ".concat(a)))}r.addEventListener("error",s),window[e][c]=e=>{i(),o(e)},document.body.append(r)})}export{n as fetchJsonp};
|
package/is-safari/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.isSafari=function(){return!("u"<typeof window||"u"<typeof navigator)&&"string"==typeof navigator.userAgent&&!!(
|
|
1
|
+
"use strict";const t=/version\/[\d._].*?safari/i,e=/mobile safari [\d._]+/i;exports.isSafari=function(){return!("u"<typeof window||"u"<typeof navigator)&&"string"==typeof navigator.userAgent&&!!(t.test(navigator.userAgent)||e.test(navigator.userAgent))};
|
package/is-safari/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const t=/version\/[\d._].*?safari/i,e=/mobile safari [\d._]+/i;function i(){return!("u"<typeof window||"u"<typeof navigator)&&"string"==typeof navigator.userAgent&&!!(t.test(navigator.userAgent)||e.test(navigator.userAgent))}export{i as isSafari};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t={};function r(t){return"function"==typeof t}function n(n,e){return r(n)?n(e):null!=n?n:t}exports.mergeProps=function(){for(var e,o,c,s=arguments.length,u=Array(s),a=0;a<s;a++)u[a]=arguments[a];const f=1===u.length&&Array.isArray(u[0])?u[0]:u;if(0===f.length)return t;let l=r(e=f[0])?{...n(e,t)}:{...e};if(1===f.length)return l;for(let t=1,e=f.length;t<e;t+=1){f[t]&&(o=l,l=r(c=f[t])?n(c,o):function(t,r){if(!r)return t;const n=Object.keys(r);for(let c=0,s=n.length;c<s;c++){const s=n[c],u=r[s];switch(s){case"style":{const r=t.style;r&&!u?t[s]=r:!r&&u?t[s]=u:(r||u)&&(t[s]={...r,...u});break}case"className":var e,o;t[s]=(e=t.className,(o=u)?e?o+" "+e:o:e);break;default:!function(t,r){const n=t.charCodeAt(0),e=t.charCodeAt(1),o=t.charCodeAt(2);return 111===n&&110===e&&o>=65&&o<=90&&("function"==typeof r||void 0===r)}(s,u)?t[s]=u:t[s]=function(t,r){return r?t?function(){for(var n=arguments.length,e=Array(n),o=0;o<n;o++)e[o]=arguments[o];const c=r(...e);return t(...e),c}:r:t}(t[s],u)}}return t}(o,c))}return l};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type PropsOf<T extends React.ElementType> = React.ComponentPropsWithRef<T>;
|
|
2
|
+
type InputProps<T extends React.ElementType> = PropsOf<T> | ((otherProps: PropsOf<T>) => PropsOf<T>) | undefined;
|
|
3
|
+
/** @see https://foxact.skk.moe/merge-props */
|
|
4
|
+
declare function mergeProps<T extends React.ElementType>(propsArray: Array<InputProps<T>>): PropsOf<T>;
|
|
5
|
+
declare function mergeProps<T extends React.ElementType>(...props: Array<InputProps<T>>): PropsOf<T>;
|
|
6
|
+
|
|
7
|
+
export { mergeProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t={};function n(){for(var n,o,c,u=arguments.length,a=Array(u),f=0;f<u;f++)a[f]=arguments[f];const s=1===a.length&&Array.isArray(a[0])?a[0]:a;if(0===s.length)return t;let l=r(n=s[0])?{...e(n,t)}:{...n};if(1===s.length)return l;for(let t=1,n=s.length;t<n;t+=1){s[t]&&(o=l,l=r(c=s[t])?e(c,o):function(t,n){if(!n)return t;const r=Object.keys(n);for(let c=0,u=r.length;c<u;c++){const u=r[c],a=n[u];switch(u){case"style":{const n=t.style;n&&!a?t[u]=n:!n&&a?t[u]=a:(n||a)&&(t[u]={...n,...a});break}case"className":var e,o;t[u]=(e=t.className,(o=a)?e?o+" "+e:o:e);break;default:!function(t,n){const r=t.charCodeAt(0),e=t.charCodeAt(1),o=t.charCodeAt(2);return 111===r&&110===e&&o>=65&&o<=90&&("function"==typeof n||void 0===n)}(u,a)?t[u]=a:t[u]=function(t,n){return n?t?function(){for(var r=arguments.length,e=Array(r),o=0;o<r;o++)e[o]=arguments[o];const c=n(...e);return t(...e),c}:n:t}(t[u],a)}}return t}(o,c))}return l}function r(t){return"function"==typeof t}function e(n,e){return r(n)?n(e):null!=n?n:t}export{n as mergeProps};
|
package/no-ssr/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var r=require("../create-stackless-error/index.cjs");function e(e){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING";const
|
|
1
|
+
"use strict";var r=require("../create-stackless-error/index.cjs");function e(e){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING",t=arguments.length>2?arguments[2]:void 0;const n=r.createStacklessError(()=>Error(e,t));return n.digest=o,n.recoverableError="NO_SSR",n}exports.noSSR=function(r){if("u"<typeof window)throw e(r)},exports.noSSRError=e;
|
package/no-ssr/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** @private */
|
|
2
|
-
declare function noSSRError(errorMessage?: string, nextjsDigest?: string
|
|
2
|
+
declare function noSSRError(errorMessage?: string, nextjsDigest?: string, errorOptions?: {
|
|
3
|
+
cause?: unknown;
|
|
4
|
+
}): Error;
|
|
3
5
|
/** @see https://foxact.skk.moe/no-ssr */
|
|
4
6
|
declare function noSSR(extraMessage?: string): void;
|
|
5
7
|
|
package/no-ssr/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createStacklessError as r}from"../create-stackless-error/index.mjs";function o(o){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING";const
|
|
1
|
+
import{createStacklessError as r}from"../create-stackless-error/index.mjs";function o(o){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"BAILOUT_TO_CLIENT_SIDE_RENDERING",t=arguments.length>2?arguments[2]:void 0;const n=r(()=>Error(o,t));return n.digest=e,n.recoverableError="NO_SSR",n}function e(r){if("u"<typeof window)throw o(r)}export{e as noSSR,o as noSSRError};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
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,7 +22,7 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"client-only": "^0.0.1",
|
|
25
|
-
"event-target-bus": "^1.
|
|
25
|
+
"event-target-bus": "^1.1.0",
|
|
26
26
|
"server-only": "^0.0.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -61,6 +61,15 @@
|
|
|
61
61
|
"require": "./breadcrumbs/index.cjs",
|
|
62
62
|
"default": "./breadcrumbs/index.cjs"
|
|
63
63
|
},
|
|
64
|
+
"./browser": {
|
|
65
|
+
"types": "./browser/index.d.ts",
|
|
66
|
+
"import": {
|
|
67
|
+
"types": "./browser/index.d.ts",
|
|
68
|
+
"default": "./browser/index.mjs"
|
|
69
|
+
},
|
|
70
|
+
"require": "./browser/index.cjs",
|
|
71
|
+
"default": "./browser/index.cjs"
|
|
72
|
+
},
|
|
64
73
|
"./context-reducer": {
|
|
65
74
|
"types": "./context-reducer/index.d.ts",
|
|
66
75
|
"import": {
|
|
@@ -88,14 +97,14 @@
|
|
|
88
97
|
"require": "./create-context-reducer/index.cjs",
|
|
89
98
|
"default": "./create-context-reducer/index.cjs"
|
|
90
99
|
},
|
|
91
|
-
"./create-
|
|
92
|
-
"types": "./create-
|
|
100
|
+
"./create-breadcrumbs": {
|
|
101
|
+
"types": "./create-breadcrumbs/index.d.ts",
|
|
93
102
|
"import": {
|
|
94
|
-
"types": "./create-
|
|
95
|
-
"default": "./create-
|
|
103
|
+
"types": "./create-breadcrumbs/index.d.ts",
|
|
104
|
+
"default": "./create-breadcrumbs/index.mjs"
|
|
96
105
|
},
|
|
97
|
-
"require": "./create-
|
|
98
|
-
"default": "./create-
|
|
106
|
+
"require": "./create-breadcrumbs/index.cjs",
|
|
107
|
+
"default": "./create-breadcrumbs/index.cjs"
|
|
99
108
|
},
|
|
100
109
|
"./compose-context-provider": {
|
|
101
110
|
"types": "./compose-context-provider/index.d.ts",
|
|
@@ -106,14 +115,14 @@
|
|
|
106
115
|
"require": "./compose-context-provider/index.cjs",
|
|
107
116
|
"default": "./compose-context-provider/index.cjs"
|
|
108
117
|
},
|
|
109
|
-
"./create-
|
|
110
|
-
"types": "./create-
|
|
118
|
+
"./create-context-state": {
|
|
119
|
+
"types": "./create-context-state/index.d.ts",
|
|
111
120
|
"import": {
|
|
112
|
-
"types": "./create-
|
|
113
|
-
"default": "./create-
|
|
121
|
+
"types": "./create-context-state/index.d.ts",
|
|
122
|
+
"default": "./create-context-state/index.mjs"
|
|
114
123
|
},
|
|
115
|
-
"require": "./create-
|
|
116
|
-
"default": "./create-
|
|
124
|
+
"require": "./create-context-state/index.cjs",
|
|
125
|
+
"default": "./create-context-state/index.cjs"
|
|
117
126
|
},
|
|
118
127
|
"./create-fixed-array": {
|
|
119
128
|
"types": "./create-fixed-array/index.d.ts",
|
|
@@ -124,6 +133,15 @@
|
|
|
124
133
|
"require": "./create-fixed-array/index.cjs",
|
|
125
134
|
"default": "./create-fixed-array/index.cjs"
|
|
126
135
|
},
|
|
136
|
+
"./create-local-storage-state": {
|
|
137
|
+
"types": "./create-local-storage-state/index.d.ts",
|
|
138
|
+
"import": {
|
|
139
|
+
"types": "./create-local-storage-state/index.d.ts",
|
|
140
|
+
"default": "./create-local-storage-state/index.mjs"
|
|
141
|
+
},
|
|
142
|
+
"require": "./create-local-storage-state/index.cjs",
|
|
143
|
+
"default": "./create-local-storage-state/index.cjs"
|
|
144
|
+
},
|
|
127
145
|
"./create-magic-portal": {
|
|
128
146
|
"types": "./create-magic-portal/index.d.ts",
|
|
129
147
|
"import": {
|
|
@@ -133,15 +151,6 @@
|
|
|
133
151
|
"require": "./create-magic-portal/index.cjs",
|
|
134
152
|
"default": "./create-magic-portal/index.cjs"
|
|
135
153
|
},
|
|
136
|
-
"./create-stackless-error": {
|
|
137
|
-
"types": "./create-stackless-error/index.d.ts",
|
|
138
|
-
"import": {
|
|
139
|
-
"types": "./create-stackless-error/index.d.ts",
|
|
140
|
-
"default": "./create-stackless-error/index.mjs"
|
|
141
|
-
},
|
|
142
|
-
"require": "./create-stackless-error/index.cjs",
|
|
143
|
-
"default": "./create-stackless-error/index.cjs"
|
|
144
|
-
},
|
|
145
154
|
"./create-session-storage-state": {
|
|
146
155
|
"types": "./create-session-storage-state/index.d.ts",
|
|
147
156
|
"import": {
|
|
@@ -151,6 +160,15 @@
|
|
|
151
160
|
"require": "./create-session-storage-state/index.cjs",
|
|
152
161
|
"default": "./create-session-storage-state/index.cjs"
|
|
153
162
|
},
|
|
163
|
+
"./create-stackless-error": {
|
|
164
|
+
"types": "./create-stackless-error/index.d.ts",
|
|
165
|
+
"import": {
|
|
166
|
+
"types": "./create-stackless-error/index.d.ts",
|
|
167
|
+
"default": "./create-stackless-error/index.mjs"
|
|
168
|
+
},
|
|
169
|
+
"require": "./create-stackless-error/index.cjs",
|
|
170
|
+
"default": "./create-stackless-error/index.cjs"
|
|
171
|
+
},
|
|
154
172
|
"./create-storage-hook": {
|
|
155
173
|
"types": "./create-storage-hook/index.d.ts",
|
|
156
174
|
"import": {
|
|
@@ -160,14 +178,14 @@
|
|
|
160
178
|
"require": "./create-storage-hook/index.cjs",
|
|
161
179
|
"default": "./create-storage-hook/index.cjs"
|
|
162
180
|
},
|
|
163
|
-
"./
|
|
164
|
-
"types": "./
|
|
181
|
+
"./current-year": {
|
|
182
|
+
"types": "./current-year/index.d.ts",
|
|
165
183
|
"import": {
|
|
166
|
-
"types": "./
|
|
167
|
-
"default": "./
|
|
184
|
+
"types": "./current-year/index.d.ts",
|
|
185
|
+
"default": "./current-year/index.mjs"
|
|
168
186
|
},
|
|
169
|
-
"require": "./
|
|
170
|
-
"default": "./
|
|
187
|
+
"require": "./current-year/index.cjs",
|
|
188
|
+
"default": "./current-year/index.cjs"
|
|
171
189
|
},
|
|
172
190
|
"./fetch-jsonp": {
|
|
173
191
|
"types": "./fetch-jsonp/index.d.ts",
|
|
@@ -178,23 +196,14 @@
|
|
|
178
196
|
"require": "./fetch-jsonp/index.cjs",
|
|
179
197
|
"default": "./fetch-jsonp/index.cjs"
|
|
180
198
|
},
|
|
181
|
-
"./
|
|
182
|
-
"types": "./
|
|
183
|
-
"import": {
|
|
184
|
-
"types": "./current-year/index.d.ts",
|
|
185
|
-
"default": "./current-year/index.mjs"
|
|
186
|
-
},
|
|
187
|
-
"require": "./current-year/index.cjs",
|
|
188
|
-
"default": "./current-year/index.cjs"
|
|
189
|
-
},
|
|
190
|
-
"./create-local-storage-state": {
|
|
191
|
-
"types": "./create-local-storage-state/index.d.ts",
|
|
199
|
+
"./invariant": {
|
|
200
|
+
"types": "./invariant/index.d.ts",
|
|
192
201
|
"import": {
|
|
193
|
-
"types": "./
|
|
194
|
-
"default": "./
|
|
202
|
+
"types": "./invariant/index.d.ts",
|
|
203
|
+
"default": "./invariant/index.mjs"
|
|
195
204
|
},
|
|
196
|
-
"require": "./
|
|
197
|
-
"default": "./
|
|
205
|
+
"require": "./invariant/index.cjs",
|
|
206
|
+
"default": "./invariant/index.cjs"
|
|
198
207
|
},
|
|
199
208
|
"./is-safari": {
|
|
200
209
|
"types": "./is-safari/index.d.ts",
|
|
@@ -205,15 +214,6 @@
|
|
|
205
214
|
"require": "./is-safari/index.cjs",
|
|
206
215
|
"default": "./is-safari/index.cjs"
|
|
207
216
|
},
|
|
208
|
-
"./invariant": {
|
|
209
|
-
"types": "./invariant/index.d.ts",
|
|
210
|
-
"import": {
|
|
211
|
-
"types": "./invariant/index.d.ts",
|
|
212
|
-
"default": "./invariant/index.mjs"
|
|
213
|
-
},
|
|
214
|
-
"require": "./invariant/index.cjs",
|
|
215
|
-
"default": "./invariant/index.cjs"
|
|
216
|
-
},
|
|
217
217
|
"./magic-portal": {
|
|
218
218
|
"types": "./magic-portal/index.d.ts",
|
|
219
219
|
"import": {
|
|
@@ -223,14 +223,14 @@
|
|
|
223
223
|
"require": "./magic-portal/index.cjs",
|
|
224
224
|
"default": "./magic-portal/index.cjs"
|
|
225
225
|
},
|
|
226
|
-
"./
|
|
227
|
-
"types": "./
|
|
226
|
+
"./merge-props": {
|
|
227
|
+
"types": "./merge-props/index.d.ts",
|
|
228
228
|
"import": {
|
|
229
|
-
"types": "./
|
|
230
|
-
"default": "./
|
|
229
|
+
"types": "./merge-props/index.d.ts",
|
|
230
|
+
"default": "./merge-props/index.mjs"
|
|
231
231
|
},
|
|
232
|
-
"require": "./
|
|
233
|
-
"default": "./
|
|
232
|
+
"require": "./merge-props/index.cjs",
|
|
233
|
+
"default": "./merge-props/index.cjs"
|
|
234
234
|
},
|
|
235
235
|
"./merge-refs": {
|
|
236
236
|
"types": "./merge-refs/index.d.ts",
|
|
@@ -241,14 +241,14 @@
|
|
|
241
241
|
"require": "./merge-refs/index.cjs",
|
|
242
242
|
"default": "./merge-refs/index.cjs"
|
|
243
243
|
},
|
|
244
|
-
"./
|
|
245
|
-
"types": "./
|
|
244
|
+
"./no-ssr": {
|
|
245
|
+
"types": "./no-ssr/index.d.ts",
|
|
246
246
|
"import": {
|
|
247
|
-
"types": "./
|
|
248
|
-
"default": "./
|
|
247
|
+
"types": "./no-ssr/index.d.ts",
|
|
248
|
+
"default": "./no-ssr/index.mjs"
|
|
249
249
|
},
|
|
250
|
-
"require": "./
|
|
251
|
-
"default": "./
|
|
250
|
+
"require": "./no-ssr/index.cjs",
|
|
251
|
+
"default": "./no-ssr/index.cjs"
|
|
252
252
|
},
|
|
253
253
|
"./noop": {
|
|
254
254
|
"types": "./noop/index.d.ts",
|
|
@@ -259,14 +259,14 @@
|
|
|
259
259
|
"require": "./noop/index.cjs",
|
|
260
260
|
"default": "./noop/index.cjs"
|
|
261
261
|
},
|
|
262
|
-
"./
|
|
263
|
-
"types": "./
|
|
262
|
+
"./noop-component": {
|
|
263
|
+
"types": "./noop-component/index.d.ts",
|
|
264
264
|
"import": {
|
|
265
|
-
"types": "./
|
|
266
|
-
"default": "./
|
|
265
|
+
"types": "./noop-component/index.d.ts",
|
|
266
|
+
"default": "./noop-component/index.mjs"
|
|
267
267
|
},
|
|
268
|
-
"require": "./
|
|
269
|
-
"default": "./
|
|
268
|
+
"require": "./noop-component/index.cjs",
|
|
269
|
+
"default": "./noop-component/index.cjs"
|
|
270
270
|
},
|
|
271
271
|
"./open-new-tab": {
|
|
272
272
|
"types": "./open-new-tab/index.d.ts",
|
|
@@ -277,14 +277,32 @@
|
|
|
277
277
|
"require": "./open-new-tab/index.cjs",
|
|
278
278
|
"default": "./open-new-tab/index.cjs"
|
|
279
279
|
},
|
|
280
|
-
"./
|
|
281
|
-
"types": "./
|
|
280
|
+
"./nullthrow": {
|
|
281
|
+
"types": "./nullthrow/index.d.ts",
|
|
282
282
|
"import": {
|
|
283
|
-
"types": "./
|
|
284
|
-
"default": "./
|
|
283
|
+
"types": "./nullthrow/index.d.ts",
|
|
284
|
+
"default": "./nullthrow/index.mjs"
|
|
285
285
|
},
|
|
286
|
-
"require": "./
|
|
287
|
-
"default": "./
|
|
286
|
+
"require": "./nullthrow/index.cjs",
|
|
287
|
+
"default": "./nullthrow/index.cjs"
|
|
288
|
+
},
|
|
289
|
+
"./create-storage-state-factory": {
|
|
290
|
+
"types": "./create-storage-state-factory/index.d.ts",
|
|
291
|
+
"import": {
|
|
292
|
+
"types": "./create-storage-state-factory/index.d.ts",
|
|
293
|
+
"default": "./create-storage-state-factory/index.mjs"
|
|
294
|
+
},
|
|
295
|
+
"require": "./create-storage-state-factory/index.cjs",
|
|
296
|
+
"default": "./create-storage-state-factory/index.cjs"
|
|
297
|
+
},
|
|
298
|
+
"./polymorphic": {
|
|
299
|
+
"types": "./polymorphic/index.d.ts",
|
|
300
|
+
"import": {
|
|
301
|
+
"types": "./polymorphic/index.d.ts",
|
|
302
|
+
"default": "./polymorphic/index.mjs"
|
|
303
|
+
},
|
|
304
|
+
"require": "./polymorphic/index.cjs",
|
|
305
|
+
"default": "./polymorphic/index.cjs"
|
|
288
306
|
},
|
|
289
307
|
"./rem": {
|
|
290
308
|
"types": "./rem/index.d.ts",
|
|
@@ -295,6 +313,15 @@
|
|
|
295
313
|
"require": "./rem/index.cjs",
|
|
296
314
|
"default": "./rem/index.cjs"
|
|
297
315
|
},
|
|
316
|
+
"./request-idle-callback": {
|
|
317
|
+
"types": "./request-idle-callback/index.d.ts",
|
|
318
|
+
"import": {
|
|
319
|
+
"types": "./request-idle-callback/index.d.ts",
|
|
320
|
+
"default": "./request-idle-callback/index.mjs"
|
|
321
|
+
},
|
|
322
|
+
"require": "./request-idle-callback/index.cjs",
|
|
323
|
+
"default": "./request-idle-callback/index.cjs"
|
|
324
|
+
},
|
|
298
325
|
"./types": {
|
|
299
326
|
"types": "./types/index.d.ts",
|
|
300
327
|
"import": {
|
|
@@ -322,15 +349,6 @@
|
|
|
322
349
|
"require": "./use/index.cjs",
|
|
323
350
|
"default": "./use/index.cjs"
|
|
324
351
|
},
|
|
325
|
-
"./use-abortable-effect": {
|
|
326
|
-
"types": "./use-abortable-effect/index.d.ts",
|
|
327
|
-
"import": {
|
|
328
|
-
"types": "./use-abortable-effect/index.d.ts",
|
|
329
|
-
"default": "./use-abortable-effect/index.mjs"
|
|
330
|
-
},
|
|
331
|
-
"require": "./use-abortable-effect/index.cjs",
|
|
332
|
-
"default": "./use-abortable-effect/index.cjs"
|
|
333
|
-
},
|
|
334
352
|
"./use-array": {
|
|
335
353
|
"types": "./use-array/index.d.ts",
|
|
336
354
|
"import": {
|
|
@@ -340,6 +358,15 @@
|
|
|
340
358
|
"require": "./use-array/index.cjs",
|
|
341
359
|
"default": "./use-array/index.cjs"
|
|
342
360
|
},
|
|
361
|
+
"./use-abortable-effect": {
|
|
362
|
+
"types": "./use-abortable-effect/index.d.ts",
|
|
363
|
+
"import": {
|
|
364
|
+
"types": "./use-abortable-effect/index.d.ts",
|
|
365
|
+
"default": "./use-abortable-effect/index.mjs"
|
|
366
|
+
},
|
|
367
|
+
"require": "./use-abortable-effect/index.cjs",
|
|
368
|
+
"default": "./use-abortable-effect/index.cjs"
|
|
369
|
+
},
|
|
343
370
|
"./use-clipboard": {
|
|
344
371
|
"types": "./use-clipboard/index.d.ts",
|
|
345
372
|
"import": {
|
|
@@ -349,15 +376,6 @@
|
|
|
349
376
|
"require": "./use-clipboard/index.cjs",
|
|
350
377
|
"default": "./use-clipboard/index.cjs"
|
|
351
378
|
},
|
|
352
|
-
"./use-composition-input": {
|
|
353
|
-
"types": "./use-composition-input/index.d.ts",
|
|
354
|
-
"import": {
|
|
355
|
-
"types": "./use-composition-input/index.d.ts",
|
|
356
|
-
"default": "./use-composition-input/index.mjs"
|
|
357
|
-
},
|
|
358
|
-
"require": "./use-composition-input/index.cjs",
|
|
359
|
-
"default": "./use-composition-input/index.cjs"
|
|
360
|
-
},
|
|
361
379
|
"./use-component-will-receive-update": {
|
|
362
380
|
"types": "./use-component-will-receive-update/index.d.ts",
|
|
363
381
|
"import": {
|
|
@@ -367,6 +385,15 @@
|
|
|
367
385
|
"require": "./use-component-will-receive-update/index.cjs",
|
|
368
386
|
"default": "./use-component-will-receive-update/index.cjs"
|
|
369
387
|
},
|
|
388
|
+
"./use-composition-input": {
|
|
389
|
+
"types": "./use-composition-input/index.d.ts",
|
|
390
|
+
"import": {
|
|
391
|
+
"types": "./use-composition-input/index.d.ts",
|
|
392
|
+
"default": "./use-composition-input/index.mjs"
|
|
393
|
+
},
|
|
394
|
+
"require": "./use-composition-input/index.cjs",
|
|
395
|
+
"default": "./use-composition-input/index.cjs"
|
|
396
|
+
},
|
|
370
397
|
"./use-debounced-state": {
|
|
371
398
|
"types": "./use-debounced-state/index.d.ts",
|
|
372
399
|
"import": {
|
|
@@ -403,15 +430,6 @@
|
|
|
403
430
|
"require": "./use-is-client/index.cjs",
|
|
404
431
|
"default": "./use-is-client/index.cjs"
|
|
405
432
|
},
|
|
406
|
-
"./use-fast-click": {
|
|
407
|
-
"types": "./use-fast-click/index.d.ts",
|
|
408
|
-
"import": {
|
|
409
|
-
"types": "./use-fast-click/index.d.ts",
|
|
410
|
-
"default": "./use-fast-click/index.mjs"
|
|
411
|
-
},
|
|
412
|
-
"require": "./use-fast-click/index.cjs",
|
|
413
|
-
"default": "./use-fast-click/index.cjs"
|
|
414
|
-
},
|
|
415
433
|
"./use-intersection": {
|
|
416
434
|
"types": "./use-intersection/index.d.ts",
|
|
417
435
|
"import": {
|
|
@@ -421,14 +439,14 @@
|
|
|
421
439
|
"require": "./use-intersection/index.cjs",
|
|
422
440
|
"default": "./use-intersection/index.cjs"
|
|
423
441
|
},
|
|
424
|
-
"./use-
|
|
425
|
-
"types": "./use-
|
|
442
|
+
"./use-fast-click": {
|
|
443
|
+
"types": "./use-fast-click/index.d.ts",
|
|
426
444
|
"import": {
|
|
427
|
-
"types": "./use-
|
|
428
|
-
"default": "./use-
|
|
445
|
+
"types": "./use-fast-click/index.d.ts",
|
|
446
|
+
"default": "./use-fast-click/index.mjs"
|
|
429
447
|
},
|
|
430
|
-
"require": "./use-
|
|
431
|
-
"default": "./use-
|
|
448
|
+
"require": "./use-fast-click/index.cjs",
|
|
449
|
+
"default": "./use-fast-click/index.cjs"
|
|
432
450
|
},
|
|
433
451
|
"./use-is-online": {
|
|
434
452
|
"types": "./use-is-online/index.d.ts",
|
|
@@ -448,14 +466,14 @@
|
|
|
448
466
|
"require": "./use-local-storage/index.cjs",
|
|
449
467
|
"default": "./use-local-storage/index.cjs"
|
|
450
468
|
},
|
|
451
|
-
"./use-
|
|
452
|
-
"types": "./use-
|
|
469
|
+
"./use-isomorphic-layout-effect": {
|
|
470
|
+
"types": "./use-isomorphic-layout-effect/index.d.ts",
|
|
453
471
|
"import": {
|
|
454
|
-
"types": "./use-
|
|
455
|
-
"default": "./use-
|
|
472
|
+
"types": "./use-isomorphic-layout-effect/index.d.ts",
|
|
473
|
+
"default": "./use-isomorphic-layout-effect/index.mjs"
|
|
456
474
|
},
|
|
457
|
-
"require": "./use-
|
|
458
|
-
"default": "./use-
|
|
475
|
+
"require": "./use-isomorphic-layout-effect/index.cjs",
|
|
476
|
+
"default": "./use-isomorphic-layout-effect/index.cjs"
|
|
459
477
|
},
|
|
460
478
|
"./use-media-query": {
|
|
461
479
|
"types": "./use-media-query/index.d.ts",
|
|
@@ -466,6 +484,15 @@
|
|
|
466
484
|
"require": "./use-media-query/index.cjs",
|
|
467
485
|
"default": "./use-media-query/index.cjs"
|
|
468
486
|
},
|
|
487
|
+
"./use-map": {
|
|
488
|
+
"types": "./use-map/index.d.ts",
|
|
489
|
+
"import": {
|
|
490
|
+
"types": "./use-map/index.d.ts",
|
|
491
|
+
"default": "./use-map/index.mjs"
|
|
492
|
+
},
|
|
493
|
+
"require": "./use-map/index.cjs",
|
|
494
|
+
"default": "./use-map/index.cjs"
|
|
495
|
+
},
|
|
469
496
|
"./use-page-visibility": {
|
|
470
497
|
"types": "./use-page-visibility/index.d.ts",
|
|
471
498
|
"import": {
|
|
@@ -493,14 +520,14 @@
|
|
|
493
520
|
"require": "./use-resizing/index.cjs",
|
|
494
521
|
"default": "./use-resizing/index.cjs"
|
|
495
522
|
},
|
|
496
|
-
"./use-
|
|
497
|
-
"types": "./use-
|
|
523
|
+
"./use-set": {
|
|
524
|
+
"types": "./use-set/index.d.ts",
|
|
498
525
|
"import": {
|
|
499
|
-
"types": "./use-
|
|
500
|
-
"default": "./use-
|
|
526
|
+
"types": "./use-set/index.d.ts",
|
|
527
|
+
"default": "./use-set/index.mjs"
|
|
501
528
|
},
|
|
502
|
-
"require": "./use-
|
|
503
|
-
"default": "./use-
|
|
529
|
+
"require": "./use-set/index.cjs",
|
|
530
|
+
"default": "./use-set/index.cjs"
|
|
504
531
|
},
|
|
505
532
|
"./use-session-storage": {
|
|
506
533
|
"types": "./use-session-storage/index.d.ts",
|
|
@@ -511,14 +538,14 @@
|
|
|
511
538
|
"require": "./use-session-storage/index.cjs",
|
|
512
539
|
"default": "./use-session-storage/index.cjs"
|
|
513
540
|
},
|
|
514
|
-
"./use-
|
|
515
|
-
"types": "./use-
|
|
541
|
+
"./use-retimer": {
|
|
542
|
+
"types": "./use-retimer/index.d.ts",
|
|
516
543
|
"import": {
|
|
517
|
-
"types": "./use-
|
|
518
|
-
"default": "./use-
|
|
544
|
+
"types": "./use-retimer/index.d.ts",
|
|
545
|
+
"default": "./use-retimer/index.mjs"
|
|
519
546
|
},
|
|
520
|
-
"require": "./use-
|
|
521
|
-
"default": "./use-
|
|
547
|
+
"require": "./use-retimer/index.cjs",
|
|
548
|
+
"default": "./use-retimer/index.cjs"
|
|
522
549
|
},
|
|
523
550
|
"./use-singleton": {
|
|
524
551
|
"types": "./use-singleton/index.d.ts",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("react");exports.createPolymorphic=function(r){return{propName:r,renderPolymorphic:function(n){const{props:t,defaultComponent:l,ref:c}=n,{[r]:o,...i}=t;return(null!=c&&(i.ref=c),e.isValidElement(o))?e.cloneElement(o,i):e.createElement(null!=o?o:l,i)}}};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @see https://foxact.skk.moe/polymorphic */
|
|
2
|
+
type PolymorphicComponentProps<PropName extends string, Component extends React.ElementType, OwnProps extends Record<string, any> = object> = OwnProps & {
|
|
3
|
+
[K in PropName]?: Component | React.ReactElement;
|
|
4
|
+
} & Omit<React.ComponentPropsWithRef<Component>, keyof OwnProps | PropName>;
|
|
5
|
+
/** @see https://foxact.skk.moe/polymorphic */
|
|
6
|
+
type PolymorphicRef<Component extends React.ElementType> = React.ComponentPropsWithRef<Component>['ref'];
|
|
7
|
+
interface RenderPolymorphicOptions {
|
|
8
|
+
props: Record<string, any>;
|
|
9
|
+
defaultComponent: React.ElementType;
|
|
10
|
+
ref?: React.Ref<any>;
|
|
11
|
+
}
|
|
12
|
+
/** @see https://foxact.skk.moe/polymorphic */
|
|
13
|
+
declare function createPolymorphic<PropName extends string>(propName: PropName): {
|
|
14
|
+
readonly propName: PropName;
|
|
15
|
+
readonly renderPolymorphic: (options: RenderPolymorphicOptions) => React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { createPolymorphic };
|
|
19
|
+
export type { PolymorphicComponentProps, PolymorphicRef };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isValidElement as r,cloneElement as n,createElement as o}from"react";function e(e){return{propName:e,renderPolymorphic:function(t){const{props:c,defaultComponent:l,ref:u}=t,{[e]:i,...f}=c;return(null!=u&&(f.ref=u),r(i))?n(i,f):o(null!=i?i:l,f)}}}export{e as createPolymorphic};
|
package/sizes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"total":{"raw":
|
|
1
|
+
{"total":{"raw":28361,"gzip":17381,"br":14619,"zstd":17408},"exports":{"browser":{"raw":686,"gzip":402,"br":333,"zstd":413},"context-state":{"raw":402,"gzip":259,"br":218,"zstd":259},"create-context-reducer":{"raw":63,"gzip":74,"br":64,"zstd":72},"compose-context-provider":{"raw":177,"gzip":155,"br":122,"zstd":144},"create-breadcrumbs":{"raw":56,"gzip":68,"br":52,"zstd":65},"breadcrumbs":{"raw":879,"gzip":467,"br":395,"zstd":472},"create-context-state":{"raw":59,"gzip":72,"br":59,"zstd":68},"create-local-storage-state":{"raw":169,"gzip":138,"br":111,"zstd":130},"create-fixed-array":{"raw":452,"gzip":282,"br":248,"zstd":282},"create-magic-portal":{"raw":57,"gzip":71,"br":53,"zstd":66},"context-reducer":{"raw":557,"gzip":332,"br":319,"zstd":336},"create-session-storage-state":{"raw":173,"gzip":138,"br":108,"zstd":129},"create-stackless-error":{"raw":278,"gzip":198,"br":162,"zstd":188},"create-storage-hook":{"raw":2418,"gzip":957,"br":835,"zstd":1000},"current-year":{"raw":508,"gzip":348,"br":283,"zstd":349},"fetch-jsonp":{"raw":924,"gzip":570,"br":446,"zstd":576},"is-safari":{"raw":247,"gzip":175,"br":133,"zstd":169},"invariant":{"raw":178,"gzip":156,"br":118,"zstd":149},"merge-props":{"raw":1030,"gzip":559,"br":501,"zstd":577},"no-ssr":{"raw":381,"gzip":281,"br":236,"zstd":285},"merge-refs":{"raw":525,"gzip":280,"br":235,"zstd":278},"noop-component":{"raw":142,"gzip":130,"br":111,"zstd":119},"create-storage-state-factory":{"raw":364,"gzip":248,"br":197,"zstd":243},"nullthrow":{"raw":187,"gzip":163,"br":121,"zstd":156},"open-new-tab":{"raw":335,"gzip":255,"br":187,"zstd":255},"polymorphic":{"raw":284,"gzip":212,"br":180,"zstd":199},"noop":{"raw":33,"gzip":53,"br":37,"zstd":42},"types":{"raw":0,"gzip":20,"br":1,"zstd":9},"request-idle-callback":{"raw":392,"gzip":221,"br":171,"zstd":213},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80,"zstd":91},"magic-portal":{"raw":1013,"gzip":517,"br":445,"zstd":526},"use-array":{"raw":334,"gzip":243,"br":206,"zstd":236},"use":{"raw":301,"gzip":200,"br":177,"zstd":193},"use-component-will-receive-update":{"raw":220,"gzip":190,"br":157,"zstd":179},"rem":{"raw":823,"gzip":395,"br":350,"zstd":402},"use-composition-input":{"raw":470,"gzip":286,"br":241,"zstd":296},"use-debounced-state":{"raw":401,"gzip":282,"br":244,"zstd":288},"use-debounced-value":{"raw":553,"gzip":358,"br":320,"zstd":360},"use-clipboard":{"raw":2718,"gzip":1333,"br":1141,"zstd":1398},"use-is-client":{"raw":184,"gzip":158,"br":130,"zstd":149},"use-error-boundary":{"raw":252,"gzip":195,"br":165,"zstd":187},"use-local-storage":{"raw":192,"gzip":143,"br":114,"zstd":137},"use-fast-click":{"raw":499,"gzip":350,"br":284,"zstd":355},"use-is-online":{"raw":288,"gzip":216,"br":196,"zstd":205},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110,"zstd":127},"use-intersection":{"raw":1363,"gzip":716,"br":654,"zstd":750},"use-map":{"raw":384,"gzip":256,"br":220,"zstd":262},"use-media-query":{"raw":483,"gzip":322,"br":256,"zstd":325},"use-page-visibility":{"raw":283,"gzip":211,"br":162,"zstd":203},"use-set":{"raw":368,"gzip":247,"br":211,"zstd":255},"use-resizing":{"raw":511,"gzip":334,"br":294,"zstd":342},"use-abortable-effect":{"raw":215,"gzip":170,"br":144,"zstd":166},"use-retimer":{"raw":194,"gzip":166,"br":127,"zstd":154},"use-singleton":{"raw":149,"gzip":135,"br":116,"zstd":123},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77,"zstd":94},"use-uncontrolled":{"raw":388,"gzip":273,"br":230,"zstd":277},"use-state-with-deps":{"raw":747,"gzip":479,"br":418,"zstd":488},"use-readonly-search-params":{"raw":1035,"gzip":547,"br":449,"zstd":558},"use-session-storage":{"raw":198,"gzip":141,"br":118,"zstd":137},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":443,"gzip":320,"br":252,"zstd":320},"use-url-hash-state":{"raw":1001,"gzip":572,"br":495,"zstd":582}}}
|
package/use/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react");
|
|
1
|
+
"use strict";var e,t=require("react"),r=(e=Object.create(null),t&&Object.keys(t).forEach(function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e));const s="function"==typeof r.use?r.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=s;
|
package/use/index.d.ts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
interface UntrackedReactPromise<T> extends PromiseLike<T> {
|
|
2
|
+
status?: undefined;
|
|
3
|
+
}
|
|
4
|
+
interface PendingReactPromise<T> extends PromiseLike<T> {
|
|
5
|
+
status: 'pending';
|
|
6
|
+
}
|
|
7
|
+
interface FulfilledReactPromise<T> extends PromiseLike<T> {
|
|
8
|
+
status: 'fulfilled';
|
|
9
|
+
value: T;
|
|
10
|
+
}
|
|
11
|
+
interface RejectedReactPromise<T> extends PromiseLike<T> {
|
|
12
|
+
status: 'rejected';
|
|
13
|
+
reason: unknown;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A thenable whose settled state React's `use()` reads synchronously, off the
|
|
17
|
+
* `status` / `value` / `reason` properties React attaches while tracking it.
|
|
18
|
+
*/
|
|
19
|
+
type ReactPromise<T> = UntrackedReactPromise<T> | PendingReactPromise<T> | FulfilledReactPromise<T> | RejectedReactPromise<T>;
|
|
20
|
+
declare const use: <T>(usable: ReactPromise<T>) => T;
|
|
8
21
|
|
|
9
22
|
export { use };
|
|
23
|
+
export type { FulfilledReactPromise, PendingReactPromise, ReactPromise, RejectedReactPromise, UntrackedReactPromise };
|
package/use/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
+
import*as 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,7 +1,5 @@
|
|
|
1
|
-
import { EffectCallback, DependencyList } from 'react';
|
|
2
|
-
|
|
3
1
|
/** @see https://foxact.skk.moe/use-abortable-effect */
|
|
4
|
-
declare function useAbortableEffect(callback: (signal: AbortSignal) => ReturnType<EffectCallback>, deps: DependencyList): void;
|
|
2
|
+
declare function useAbortableEffect(callback: (signal: AbortSignal) => ReturnType<React.EffectCallback>, deps: React.DependencyList): void;
|
|
5
3
|
declare const useEffect: typeof useAbortableEffect;
|
|
6
4
|
|
|
7
5
|
export { useAbortableEffect, useEffect };
|
package/use-clipboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),t=require("../noop/index.cjs"),r=require("../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs"),l=require("../use-typescript-happy-callback/index.cjs");class a extends Error{constructor(...e){var t;super(...e),(t="name")in this?Object.defineProperty(this,t,{value:"UseClipboardError",enumerable:!0,configurable:!0,writable:!0}):this[t]="UseClipboardError"}}async function o(e,t,r,l){let o;if("clipboard"in navigator)try{return await navigator.clipboard.writeText(e),!0}catch(e){(o=new a("[foxact/use-clipboard] Failed to copy using navigator.clipboard")).cause=e}else o=new a("[foxact/use-clipboard] navigator.clipboard is not supported");if(t){var n;let t;const r=document.activeElement,l=[],c=document.getSelection();let s=null,i=null!=(n=document.fullscreenElement)?n:document.body,u=r;for(;u;){if("DIALOG"===u.tagName&&u.open){i=u;break}u=u.parentElement}let d=null;try{if(c.rangeCount){for(let e=0;e<c.rangeCount;e++)l.push(c.getRangeAt(e));c.removeAllRanges()}((null==r?void 0:r.tagName)==="INPUT"||(null==r?void 0:r.tagName)==="TEXTAREA")&&(s=r).blur();const a=document.createRange();(d=document.createElement("span")).textContent=e,d.style.whiteSpace="pre",d.ariaHidden="true",d.style.all="unset",d.style.position="fixed",d.style.top="0",d.style.clip="rect(0, 0, 0, 0)",d.style.borderWidth="0",d.style.overflow="hidden",d.style.userSelect="text",d.style.webkitUserSelect="text",d.style.MozUserSelect="text",d.style.msUserSelect="text",d.addEventListener("copy",e=>{e.stopPropagation()}),i.appendChild(d),a.selectNodeContents(d),c.removeAllRanges(),c.addRange(a),t=document.execCommand("copy")}catch(e){(o=new a("[foxact/use-clipboard] Failed to copy using execCommand fallback")).cause=e,t=!1}finally{c.removeAllRanges(),d&&i.removeChild(d),"Caret"===c.type&&c.removeAllRanges(),c.rangeCount||l.forEach(e=>c.addRange(e)),null==s||s.focus()}if(t)return!0}return r?(window.prompt(l,e),!1):o}exports.UseClipboardError=a,exports.useClipboard=function(){let{timeout:a=1e3,useExecCommandAsFallback:n=!0,usePromptAsFallback:c=!1,promptFallbackText:s="Failed to copy to clipboard, please manually copy the text below.",onCopyError:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[u,d]=e.useState(null),[p,y]=e.useState(!1),b=e.useRef(null),m=r.useStableHandler(i||t.noop),g=l.useCallback(e=>{b.current&&clearTimeout(b.current),e&&(b.current=window.setTimeout(
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),t=require("../noop/index.cjs"),r=require("../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs"),l=require("../use-typescript-happy-callback/index.cjs");class a extends Error{constructor(...e){var t;super(...e),(t="name")in this?Object.defineProperty(this,t,{value:"UseClipboardError",enumerable:!0,configurable:!0,writable:!0}):this[t]="UseClipboardError"}}async function o(e,t,r,l){let o;if("clipboard"in navigator)try{return await navigator.clipboard.writeText(e),!0}catch(e){(o=new a("[foxact/use-clipboard] Failed to copy using navigator.clipboard")).cause=e}else o=new a("[foxact/use-clipboard] navigator.clipboard is not supported");if(t){var n;let t;const r=document.activeElement,l=[],c=document.getSelection();let s=null,i=null!=(n=document.fullscreenElement)?n:document.body,u=r;for(;u;){if("DIALOG"===u.tagName&&u.open){i=u;break}u=u.parentElement}let d=null;try{if(c.rangeCount){for(let e=0;e<c.rangeCount;e++)l.push(c.getRangeAt(e));c.removeAllRanges()}((null==r?void 0:r.tagName)==="INPUT"||(null==r?void 0:r.tagName)==="TEXTAREA")&&(s=r).blur();const a=document.createRange();(d=document.createElement("span")).textContent=e,d.style.whiteSpace="pre",d.ariaHidden="true",d.style.all="unset",d.style.position="fixed",d.style.top="0",d.style.clip="rect(0, 0, 0, 0)",d.style.borderWidth="0",d.style.overflow="hidden",d.style.userSelect="text",d.style.webkitUserSelect="text",d.style.MozUserSelect="text",d.style.msUserSelect="text",d.addEventListener("copy",e=>{e.stopPropagation()}),i.appendChild(d),a.selectNodeContents(d),c.removeAllRanges(),c.addRange(a),t=document.execCommand("copy")}catch(e){(o=new a("[foxact/use-clipboard] Failed to copy using execCommand fallback")).cause=e,t=!1}finally{c.removeAllRanges(),d&&i.removeChild(d),"Caret"===c.type&&c.removeAllRanges(),c.rangeCount||l.forEach(e=>c.addRange(e)),null==s||s.focus()}if(t)return!0}return r?(window.prompt(l,e),!1):o}exports.UseClipboardError=a,exports.useClipboard=function(){let{timeout:a=1e3,useExecCommandAsFallback:n=!0,usePromptAsFallback:c=!1,promptFallbackText:s="Failed to copy to clipboard, please manually copy the text below.",onCopyError:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[u,d]=e.useState(null),[p,y]=e.useState(!1),b=e.useRef(null),m=r.useStableHandler(i||t.noop),g=l.useCallback(e=>{b.current&&clearTimeout(b.current),e&&(b.current=window.setTimeout(y,a,!1)),y(e)},[a]),f=l.useCallback(e=>{d(e),m(e)},[m]);return{copy:l.useCallback(async e=>{try{const t=await o(e,n,c,s);"boolean"==typeof t?t&&g(!0):f(t)}catch(e){f(e)}},[g,s,f,n,c]),reset:l.useCallback(()=>{y(!1),d(null),b.current&&clearTimeout(b.current)},[]),error:u,copied:p}};
|
package/use-clipboard/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useState as e,useRef as t}from"react";import{noop as o}from"../noop/index.mjs";import{useStableHandler as r}from"../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs";import{useCallback as n}from"../use-typescript-happy-callback/index.mjs";class l extends Error{constructor(...e){var t;super(...e),(t="name")in this?Object.defineProperty(this,t,{value:"UseClipboardError",enumerable:!0,configurable:!0,writable:!0}):this[t]="UseClipboardError"}}function a(){let{timeout:l=1e3,useExecCommandAsFallback:a=!0,usePromptAsFallback:c=!1,promptFallbackText:s="Failed to copy to clipboard, please manually copy the text below.",onCopyError:u}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[d,p]=e(null),[m,y]=e(!1),b=t(null),f=r(u||o),g=n(e=>{b.current&&clearTimeout(b.current),e&&(b.current=window.setTimeout(
|
|
1
|
+
import"client-only";import{useState as e,useRef as t}from"react";import{noop as o}from"../noop/index.mjs";import{useStableHandler as r}from"../use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs";import{useCallback as n}from"../use-typescript-happy-callback/index.mjs";class l extends Error{constructor(...e){var t;super(...e),(t="name")in this?Object.defineProperty(this,t,{value:"UseClipboardError",enumerable:!0,configurable:!0,writable:!0}):this[t]="UseClipboardError"}}function a(){let{timeout:l=1e3,useExecCommandAsFallback:a=!0,usePromptAsFallback:c=!1,promptFallbackText:s="Failed to copy to clipboard, please manually copy the text below.",onCopyError:u}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[d,p]=e(null),[m,y]=e(!1),b=t(null),f=r(u||o),g=n(e=>{b.current&&clearTimeout(b.current),e&&(b.current=window.setTimeout(y,l,!1)),y(e)},[l]),h=n(e=>{p(e),f(e)},[f]);return{copy:n(async e=>{try{const t=await i(e,a,c,s);"boolean"==typeof t?t&&g(!0):h(t)}catch(e){h(e)}},[g,s,h,a,c]),reset:n(()=>{y(!1),p(null),b.current&&clearTimeout(b.current)},[]),error:d,copied:m}}async function i(e,t,o,r){let n;if("clipboard"in navigator)try{return await navigator.clipboard.writeText(e),!0}catch(e){(n=new l("[foxact/use-clipboard] Failed to copy using navigator.clipboard")).cause=e}else n=new l("[foxact/use-clipboard] navigator.clipboard is not supported");if(t){var a;let t;const o=document.activeElement,r=[],i=document.getSelection();let c=null,s=null!=(a=document.fullscreenElement)?a:document.body,u=o;for(;u;){if("DIALOG"===u.tagName&&u.open){s=u;break}u=u.parentElement}let d=null;try{if(i.rangeCount){for(let e=0;e<i.rangeCount;e++)r.push(i.getRangeAt(e));i.removeAllRanges()}((null==o?void 0:o.tagName)==="INPUT"||(null==o?void 0:o.tagName)==="TEXTAREA")&&(c=o).blur();const n=document.createRange();(d=document.createElement("span")).textContent=e,d.style.whiteSpace="pre",d.ariaHidden="true",d.style.all="unset",d.style.position="fixed",d.style.top="0",d.style.clip="rect(0, 0, 0, 0)",d.style.borderWidth="0",d.style.overflow="hidden",d.style.userSelect="text",d.style.webkitUserSelect="text",d.style.MozUserSelect="text",d.style.msUserSelect="text",d.addEventListener("copy",e=>{e.stopPropagation()}),s.appendChild(d),n.selectNodeContents(d),i.removeAllRanges(),i.addRange(n),t=document.execCommand("copy")}catch(e){(n=new l("[foxact/use-clipboard] Failed to copy using execCommand fallback")).cause=e,t=!1}finally{i.removeAllRanges(),d&&s.removeChild(d),"Caret"===i.type&&i.removeAllRanges(),i.rangeCount||r.forEach(e=>i.addRange(e)),null==c||c.focus()}if(t)return!0}return o?(window.prompt(r,e),!1):n}export{l as UseClipboardError,a as useClipboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react");exports.useComponentWillReceiveUpdate=function(t,n){n=[...n];const[r,l]=e.useState(n);let o=n.length!==r.length;for(let e=0;e<
|
|
1
|
+
"use strict";var e=require("react");exports.useComponentWillReceiveUpdate=function(t,n){n=[...n];const[r,l]=e.useState(n);let o=n.length!==r.length;for(let e=0,t=n.length;e<t&&!o;e+=1)r[e]!==n[e]&&(o=!0);return o&&(l(n),t()),o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as e}from"react";function t(t,n){const[o,l]=e(n=[...n]);let r=n.length!==o.length;for(let e=0;e<
|
|
1
|
+
import{useState as e}from"react";function t(t,n){const[o,l]=e(n=[...n]);let r=n.length!==o.length;for(let e=0,t=n.length;e<t&&!r;e+=1)o[e]!==n[e]&&(r=!0);return r&&(l(n),t()),r}export{t as useComponentWillReceiveUpdate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),r=require("../use-retimer/index.cjs");exports.useDebouncedState=function(t,u){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const[s,c]=e.useState(t),i=e.useRef(!0),a=r.useRetimer();return[s,e.useCallback(e=>{i.current
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),r=require("../use-retimer/index.cjs");exports.useDebouncedState=function(t,u){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const[s,c]=e.useState(t),i=e.useRef(!0),a=r.useRetimer();return[s,e.useCallback(e=>{n&&i.current?c(e):a(window.setTimeout(()=>{i.current=!0,c(e)},u)),i.current=!1},[n,a,u]),e.useCallback(e=>{a(),c(e)},[a])]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useState as e,useRef as t,useCallback as r}from"react";import{useRetimer as n}from"../use-retimer/index.mjs";function o(o,i){let u=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const[c,m]=e(o),s=t(!0),d=n();return[c,r(e=>{s.current
|
|
1
|
+
import"client-only";import{useState as e,useRef as t,useCallback as r}from"react";import{useRetimer as n}from"../use-retimer/index.mjs";function o(o,i){let u=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const[c,m]=e(o),s=t(!0),d=n();return[c,r(e=>{u&&s.current?m(e):d(window.setTimeout(()=>{s.current=!0,m(e)},i)),s.current=!1},[u,d,i]),r(e=>{d(),m(e)},[d])]}export{o as useDebouncedState};
|
package/use-is-client/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("../noop/index.cjs"),r=require("react");
|
|
1
|
+
"use strict";require("client-only");var e=require("../noop/index.cjs"),r=require("react");const n=()=>!0,t=()=>!1;exports.useIsClient=function(){return r.useSyncExternalStore(e.noop,n,t)};
|
package/use-is-client/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{noop as
|
|
1
|
+
import"client-only";import{noop as o}from"../noop/index.mjs";import{useSyncExternalStore as t}from"react";const n=()=>!0,r=()=>!1;function e(){return t(o,n,r)}export{e as useIsClient};
|
package/use-is-online/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var e=require("react");const n=require("event-target-bus/react").createSyncExternalStoreSubscribe(()=>window,["online","offline"]);function r(){return!("u"<typeof window)&&navigator.onLine}exports.useIsOnline=function(){return e.useSyncExternalStore(n,r,r)};
|
package/use-is-online/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{useSyncExternalStore as n}from"react";import{
|
|
2
|
+
import{useSyncExternalStore as n}from"react";import{createSyncExternalStoreSubscribe as o}from"event-target-bus/react";const t=o(()=>window,["online","offline"]);function e(){return!("u"<typeof window)&&navigator.onLine}function r(){return n(t,e,e)}export{r as useIsOnline};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("../no-ssr/index.cjs"),r=require("
|
|
2
|
+
"use strict";var e=require("../no-ssr/index.cjs"),r=require("react");const t=require("event-target-bus/react").createKeyedSyncExternalStoreSubscribe(e=>window.matchMedia(e),"change");function n(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,o){const u=r.useMemo(()=>t(e),[e]);return r.useSyncExternalStore(u,()=>"u"<typeof window?null!=o&&o:window.matchMedia(e).matches,void 0===o?n:()=>o)};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{noSSRError as e}from"../no-ssr/index.mjs";import{
|
|
2
|
+
import{noSSRError as e}from"../no-ssr/index.mjs";import{useMemo as t,useSyncExternalStore as o}from"react";import{createKeyedSyncExternalStoreSubscribe as r}from"event-target-bus/react";const n=r(e=>window.matchMedia(e),"change");function i(){throw e("useMediaQuery cannot be used on the server without a serverValue")}function a(e,r){return o(t(()=>n(e),[e]),()=>"u"<typeof window?null!=r&&r:window.matchMedia(e).matches,void 0===r?i:()=>r)}export{a as useMediaQuery};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("react")
|
|
2
|
+
"use strict";var e=require("react");const t=require("event-target-bus/react").createSyncExternalStoreSubscribe(()=>document,"visibilitychange"),r=()=>!("u"<typeof document)&&!document.hidden;exports.usePageVisibility=function(){return e.useSyncExternalStore(t,r,r)};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{useSyncExternalStore as t}from"react";import{
|
|
2
|
+
import{useSyncExternalStore as t}from"react";import{createSyncExternalStoreSubscribe as e}from"event-target-bus/react";const i=e(()=>document,"visibilitychange"),o=()=>!("u"<typeof document)&&!document.hidden;function n(){return t(i,o,o)}export{n as usePageVisibility};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("event-target-bus"),r=require("../no-ssr/index.cjs"),
|
|
1
|
+
"use strict";var e=require("event-target-bus/react"),r=require("../no-ssr/index.cjs"),a=require("react");class n 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 n}delete(){throw new n}set(){throw new n}sort(){throw new n}}const o=e.createSyncExternalStoreSubscribe(()=>window,"popstate");let s=null,c=null;function u(){return"u"<typeof window?new t:null!==c&&window.location.search===s?c:c=new t(s=window.location.search)}function l(){throw r.noSSRError('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}exports.ReadonlyURLSearchParams=t,exports.useReadonlySearchParams=function(e){return a.useSyncExternalStore(o,u,null==e?l:()=>{const r=e();return r instanceof t?r:new t(r)})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createSyncExternalStoreSubscribe as e}from"event-target-bus/react";import{noSSRError as r}from"../no-ssr/index.mjs";import{useSyncExternalStore as a}from"react";class n 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 n}delete(){throw new n}set(){throw new n}sort(){throw new n}}const t=e(()=>window,"popstate");let s=null,c=null;function l(){return"u"<typeof window?new o:null!==c&&window.location.search===s?c:c=new o(s=window.location.search)}function u(){throw r('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}function i(e){return a(t,l,null==e?u:()=>{const r=e();return r instanceof o?r:new o(r)})}export{o as ReadonlyURLSearchParams,i as useReadonlySearchParams};
|
package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react");
|
|
1
|
+
"use strict";var e,t=require("react"),r=(e=Object.create(null),t&&Object.keys(t).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e));const{useCallback:n,useEffect:o,useLayoutEffect:c,useRef:u}=r,a="u"<typeof window?o:r.useInsertionEffect||c;function f(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}exports.useStableHandler=function(e){const t=u(f);return a(()=>{t.current=e},[e]),n(function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return(0,t.current)(...r)},[])};
|
package/use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import t
|
|
1
|
+
import*as t from"react";const{useCallback:e,useEffect:n,useLayoutEffect:r,useRef:o}=t,c="u"<typeof window?n:t.useInsertionEffect||r;function a(t){const n=o(u);return c(()=>{n.current=t},[t]),e(function(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];return(0,n.current)(...e)},[])}function u(){throw Error("foxact: the stablized handler cannot be invoked before the component has mounted.")}export{a as useStableHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),r=require("../
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),r=require("../no-ssr/index.cjs"),t=require("../chunks/index.b9dLwVor.cjs"),n=require("../chunks/index.BtiK5_Nn.cjs");const s=require("event-target-bus/react").createSyncExternalStoreSubscribe(()=>window,"hashchange");function a(){throw r.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(r,l){var i;let u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t.t,deserializer:t.t};const c=u.raw?t.t:u.serializer,o=u.raw?t.t:u.deserializer,h=void 0===l?a:()=>c(l),S=e.useSyncExternalStore(s,()=>new URLSearchParams(location.hash.slice(1)).get(r),h),d=e.useMemo(()=>null===S?null!=l?l:null:o(S),[l,o,S]),w=e.useCallback(e=>{const t=location.hash,s=new URLSearchParams(t.slice(1)),a=n.n(e)?e(d):e;a===l||null===a?s.delete(r):s.set(r,c(a));const i=s.toString();t!==i&&(location.hash=i)},[l,d,r,c]);return[null!=(i=null!=d?d:l)?i:null,w]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useSyncExternalStore as e,useMemo as
|
|
1
|
+
import"client-only";import{useSyncExternalStore as e,useMemo as r,useCallback as t}from"react";import{noSSRError as n}from"../no-ssr/index.mjs";import{t as a}from"../chunks/index.D0KaUCcV.mjs";import{n as s}from"../chunks/index.C9-3oDdv.mjs";import{createSyncExternalStoreSubscribe as o}from"event-target-bus/react";const l=o(()=>window,"hashchange");function i(){throw n("useUrlHashState cannot be used on the server without a serverValue")}function c(n,o){var c;let h=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:a,deserializer:a};const u=h.raw?a:h.serializer,m=h.raw?a:h.deserializer,d=e(l,()=>new URLSearchParams(location.hash.slice(1)).get(n),void 0===o?i:()=>u(o)),w=r(()=>null===d?null!=o?o:null:m(d),[o,m,d]),f=t(e=>{const r=location.hash,t=new URLSearchParams(r.slice(1)),a=s(e)?e(w):e;a===o||null===a?t.delete(n):t.set(n,u(a));const l=t.toString();r!==l&&(location.hash=l)},[o,w,n,u]);return[null!=(c=null!=w?w:o)?c:null,f]}export{c as unstable_useUrlHashState};
|