foxact 0.3.8 → 0.3.10
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/get-react-children/index.cjs +1 -0
- package/get-react-children/index.d.ts +19 -0
- package/get-react-children/index.mjs +1 -0
- package/get-single-react-children/index.cjs +1 -0
- package/get-single-react-children/index.d.ts +2 -0
- package/get-single-react-children/index.mjs +1 -0
- package/is-safari/index.cjs +1 -1
- package/is-safari/index.mjs +1 -1
- package/merge-props/index.cjs +1 -1
- package/merge-props/index.mjs +1 -1
- 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 +137 -110
- 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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("react");function t(t,r){void 0!==r&&function(e){if(!Number.isSafeInteger(e)||e<0)throw TypeError('[foxact/get-react-children] "count" must be a non-negative safe integer.')}(r);const n=e.isValidElement(t)?[t]:e.Children.toArray(t).filter(e.isValidElement);return void 0!==r&&function(e,t){if(t!==e)throw TypeError("[foxact/get-react-children] Expected exactly ".concat(e," valid React ").concat(1===e?"element":"elements",", but received ").concat(t,"."))}(r,e.Children.count(n)),n}exports.getReactChildren=t,exports.getSingleReactChildren=function(e){return t(e,1)[0]};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns every valid React element in children, unwrapping the lazy wrapper
|
|
5
|
+
* that React Flight can place around children crossing a React Server
|
|
6
|
+
* Components boundary.
|
|
7
|
+
*
|
|
8
|
+
* @see https://foxact.skk.moe/get-react-children
|
|
9
|
+
* @see https://github.com/react/react/issues/32392
|
|
10
|
+
*/
|
|
11
|
+
declare function getReactChildren(children: React.ReactNode, count?: number): react.ReactElement<Record<string, unknown>, string | react.JSXElementConstructor<any>>[];
|
|
12
|
+
/**
|
|
13
|
+
* Returns exactly one valid React element from children.
|
|
14
|
+
*
|
|
15
|
+
* @see https://foxact.skk.moe/get-single-react-children
|
|
16
|
+
*/
|
|
17
|
+
declare function getSingleReactChildren(children: React.ReactNode): react.ReactElement<Record<string, unknown>, string | react.JSXElementConstructor<any>>;
|
|
18
|
+
|
|
19
|
+
export { getReactChildren, getSingleReactChildren };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isValidElement as e,Children as t}from"react";function r(r,n){void 0!==n&&function(e){if(!Number.isSafeInteger(e)||e<0)throw TypeError('[foxact/get-react-children] "count" must be a non-negative safe integer.')}(n);const c=e(r)?[r]:t.toArray(r).filter(e);return void 0!==n&&function(e,t){if(t!==e)throw TypeError("[foxact/get-react-children] Expected exactly ".concat(e," valid React ").concat(1===e?"element":"elements",", but received ").concat(t,"."))}(n,t.count(c)),c}function n(e){return r(e,1)[0]}export{r as getReactChildren,n as getSingleReactChildren};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../get-react-children/index.cjs");exports.getSingleReactChildren=e.getSingleReactChildren;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{getSingleReactChildren}from"../get-react-children/index.mjs";
|
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};
|
package/merge-props/index.cjs
CHANGED
|
@@ -1 +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
|
|
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};
|
package/merge-props/index.mjs
CHANGED
|
@@ -1 +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
|
|
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.10",
|
|
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,33 @@
|
|
|
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
|
+
},
|
|
73
|
+
"./context-state": {
|
|
74
|
+
"types": "./context-state/index.d.ts",
|
|
75
|
+
"import": {
|
|
76
|
+
"types": "./context-state/index.d.ts",
|
|
77
|
+
"default": "./context-state/index.mjs"
|
|
78
|
+
},
|
|
79
|
+
"require": "./context-state/index.cjs",
|
|
80
|
+
"default": "./context-state/index.cjs"
|
|
81
|
+
},
|
|
82
|
+
"./context-reducer": {
|
|
83
|
+
"types": "./context-reducer/index.d.ts",
|
|
84
|
+
"import": {
|
|
85
|
+
"types": "./context-reducer/index.d.ts",
|
|
86
|
+
"default": "./context-reducer/index.mjs"
|
|
87
|
+
},
|
|
88
|
+
"require": "./context-reducer/index.cjs",
|
|
89
|
+
"default": "./context-reducer/index.cjs"
|
|
90
|
+
},
|
|
64
91
|
"./compose-context-provider": {
|
|
65
92
|
"types": "./compose-context-provider/index.d.ts",
|
|
66
93
|
"import": {
|
|
@@ -70,6 +97,15 @@
|
|
|
70
97
|
"require": "./compose-context-provider/index.cjs",
|
|
71
98
|
"default": "./compose-context-provider/index.cjs"
|
|
72
99
|
},
|
|
100
|
+
"./create-breadcrumbs": {
|
|
101
|
+
"types": "./create-breadcrumbs/index.d.ts",
|
|
102
|
+
"import": {
|
|
103
|
+
"types": "./create-breadcrumbs/index.d.ts",
|
|
104
|
+
"default": "./create-breadcrumbs/index.mjs"
|
|
105
|
+
},
|
|
106
|
+
"require": "./create-breadcrumbs/index.cjs",
|
|
107
|
+
"default": "./create-breadcrumbs/index.cjs"
|
|
108
|
+
},
|
|
73
109
|
"./create-context-reducer": {
|
|
74
110
|
"types": "./create-context-reducer/index.d.ts",
|
|
75
111
|
"import": {
|
|
@@ -79,15 +115,6 @@
|
|
|
79
115
|
"require": "./create-context-reducer/index.cjs",
|
|
80
116
|
"default": "./create-context-reducer/index.cjs"
|
|
81
117
|
},
|
|
82
|
-
"./context-reducer": {
|
|
83
|
-
"types": "./context-reducer/index.d.ts",
|
|
84
|
-
"import": {
|
|
85
|
-
"types": "./context-reducer/index.d.ts",
|
|
86
|
-
"default": "./context-reducer/index.mjs"
|
|
87
|
-
},
|
|
88
|
-
"require": "./context-reducer/index.cjs",
|
|
89
|
-
"default": "./context-reducer/index.cjs"
|
|
90
|
-
},
|
|
91
118
|
"./create-context-state": {
|
|
92
119
|
"types": "./create-context-state/index.d.ts",
|
|
93
120
|
"import": {
|
|
@@ -97,15 +124,6 @@
|
|
|
97
124
|
"require": "./create-context-state/index.cjs",
|
|
98
125
|
"default": "./create-context-state/index.cjs"
|
|
99
126
|
},
|
|
100
|
-
"./context-state": {
|
|
101
|
-
"types": "./context-state/index.d.ts",
|
|
102
|
-
"import": {
|
|
103
|
-
"types": "./context-state/index.d.ts",
|
|
104
|
-
"default": "./context-state/index.mjs"
|
|
105
|
-
},
|
|
106
|
-
"require": "./context-state/index.cjs",
|
|
107
|
-
"default": "./context-state/index.cjs"
|
|
108
|
-
},
|
|
109
127
|
"./create-fixed-array": {
|
|
110
128
|
"types": "./create-fixed-array/index.d.ts",
|
|
111
129
|
"import": {
|
|
@@ -124,33 +142,6 @@
|
|
|
124
142
|
"require": "./create-local-storage-state/index.cjs",
|
|
125
143
|
"default": "./create-local-storage-state/index.cjs"
|
|
126
144
|
},
|
|
127
|
-
"./create-magic-portal": {
|
|
128
|
-
"types": "./create-magic-portal/index.d.ts",
|
|
129
|
-
"import": {
|
|
130
|
-
"types": "./create-magic-portal/index.d.ts",
|
|
131
|
-
"default": "./create-magic-portal/index.mjs"
|
|
132
|
-
},
|
|
133
|
-
"require": "./create-magic-portal/index.cjs",
|
|
134
|
-
"default": "./create-magic-portal/index.cjs"
|
|
135
|
-
},
|
|
136
|
-
"./create-breadcrumbs": {
|
|
137
|
-
"types": "./create-breadcrumbs/index.d.ts",
|
|
138
|
-
"import": {
|
|
139
|
-
"types": "./create-breadcrumbs/index.d.ts",
|
|
140
|
-
"default": "./create-breadcrumbs/index.mjs"
|
|
141
|
-
},
|
|
142
|
-
"require": "./create-breadcrumbs/index.cjs",
|
|
143
|
-
"default": "./create-breadcrumbs/index.cjs"
|
|
144
|
-
},
|
|
145
|
-
"./create-session-storage-state": {
|
|
146
|
-
"types": "./create-session-storage-state/index.d.ts",
|
|
147
|
-
"import": {
|
|
148
|
-
"types": "./create-session-storage-state/index.d.ts",
|
|
149
|
-
"default": "./create-session-storage-state/index.mjs"
|
|
150
|
-
},
|
|
151
|
-
"require": "./create-session-storage-state/index.cjs",
|
|
152
|
-
"default": "./create-session-storage-state/index.cjs"
|
|
153
|
-
},
|
|
154
145
|
"./create-stackless-error": {
|
|
155
146
|
"types": "./create-stackless-error/index.d.ts",
|
|
156
147
|
"import": {
|
|
@@ -187,6 +178,15 @@
|
|
|
187
178
|
"require": "./current-year/index.cjs",
|
|
188
179
|
"default": "./current-year/index.cjs"
|
|
189
180
|
},
|
|
181
|
+
"./create-session-storage-state": {
|
|
182
|
+
"types": "./create-session-storage-state/index.d.ts",
|
|
183
|
+
"import": {
|
|
184
|
+
"types": "./create-session-storage-state/index.d.ts",
|
|
185
|
+
"default": "./create-session-storage-state/index.mjs"
|
|
186
|
+
},
|
|
187
|
+
"require": "./create-session-storage-state/index.cjs",
|
|
188
|
+
"default": "./create-session-storage-state/index.cjs"
|
|
189
|
+
},
|
|
190
190
|
"./fetch-jsonp": {
|
|
191
191
|
"types": "./fetch-jsonp/index.d.ts",
|
|
192
192
|
"import": {
|
|
@@ -196,23 +196,23 @@
|
|
|
196
196
|
"require": "./fetch-jsonp/index.cjs",
|
|
197
197
|
"default": "./fetch-jsonp/index.cjs"
|
|
198
198
|
},
|
|
199
|
-
"./
|
|
200
|
-
"types": "./
|
|
199
|
+
"./get-react-children": {
|
|
200
|
+
"types": "./get-react-children/index.d.ts",
|
|
201
201
|
"import": {
|
|
202
|
-
"types": "./
|
|
203
|
-
"default": "./
|
|
202
|
+
"types": "./get-react-children/index.d.ts",
|
|
203
|
+
"default": "./get-react-children/index.mjs"
|
|
204
204
|
},
|
|
205
|
-
"require": "./
|
|
206
|
-
"default": "./
|
|
205
|
+
"require": "./get-react-children/index.cjs",
|
|
206
|
+
"default": "./get-react-children/index.cjs"
|
|
207
207
|
},
|
|
208
|
-
"./
|
|
209
|
-
"types": "./
|
|
208
|
+
"./get-single-react-children": {
|
|
209
|
+
"types": "./get-single-react-children/index.d.ts",
|
|
210
210
|
"import": {
|
|
211
|
-
"types": "./
|
|
212
|
-
"default": "./
|
|
211
|
+
"types": "./get-single-react-children/index.d.ts",
|
|
212
|
+
"default": "./get-single-react-children/index.mjs"
|
|
213
213
|
},
|
|
214
|
-
"require": "./
|
|
215
|
-
"default": "./
|
|
214
|
+
"require": "./get-single-react-children/index.cjs",
|
|
215
|
+
"default": "./get-single-react-children/index.cjs"
|
|
216
216
|
},
|
|
217
217
|
"./is-safari": {
|
|
218
218
|
"types": "./is-safari/index.d.ts",
|
|
@@ -223,6 +223,24 @@
|
|
|
223
223
|
"require": "./is-safari/index.cjs",
|
|
224
224
|
"default": "./is-safari/index.cjs"
|
|
225
225
|
},
|
|
226
|
+
"./magic-portal": {
|
|
227
|
+
"types": "./magic-portal/index.d.ts",
|
|
228
|
+
"import": {
|
|
229
|
+
"types": "./magic-portal/index.d.ts",
|
|
230
|
+
"default": "./magic-portal/index.mjs"
|
|
231
|
+
},
|
|
232
|
+
"require": "./magic-portal/index.cjs",
|
|
233
|
+
"default": "./magic-portal/index.cjs"
|
|
234
|
+
},
|
|
235
|
+
"./invariant": {
|
|
236
|
+
"types": "./invariant/index.d.ts",
|
|
237
|
+
"import": {
|
|
238
|
+
"types": "./invariant/index.d.ts",
|
|
239
|
+
"default": "./invariant/index.mjs"
|
|
240
|
+
},
|
|
241
|
+
"require": "./invariant/index.cjs",
|
|
242
|
+
"default": "./invariant/index.cjs"
|
|
243
|
+
},
|
|
226
244
|
"./merge-props": {
|
|
227
245
|
"types": "./merge-props/index.d.ts",
|
|
228
246
|
"import": {
|
|
@@ -241,15 +259,6 @@
|
|
|
241
259
|
"require": "./merge-refs/index.cjs",
|
|
242
260
|
"default": "./merge-refs/index.cjs"
|
|
243
261
|
},
|
|
244
|
-
"./noop": {
|
|
245
|
-
"types": "./noop/index.d.ts",
|
|
246
|
-
"import": {
|
|
247
|
-
"types": "./noop/index.d.ts",
|
|
248
|
-
"default": "./noop/index.mjs"
|
|
249
|
-
},
|
|
250
|
-
"require": "./noop/index.cjs",
|
|
251
|
-
"default": "./noop/index.cjs"
|
|
252
|
-
},
|
|
253
262
|
"./no-ssr": {
|
|
254
263
|
"types": "./no-ssr/index.d.ts",
|
|
255
264
|
"import": {
|
|
@@ -259,14 +268,14 @@
|
|
|
259
268
|
"require": "./no-ssr/index.cjs",
|
|
260
269
|
"default": "./no-ssr/index.cjs"
|
|
261
270
|
},
|
|
262
|
-
"./
|
|
263
|
-
"types": "./
|
|
271
|
+
"./noop": {
|
|
272
|
+
"types": "./noop/index.d.ts",
|
|
264
273
|
"import": {
|
|
265
|
-
"types": "./
|
|
266
|
-
"default": "./
|
|
274
|
+
"types": "./noop/index.d.ts",
|
|
275
|
+
"default": "./noop/index.mjs"
|
|
267
276
|
},
|
|
268
|
-
"require": "./
|
|
269
|
-
"default": "./
|
|
277
|
+
"require": "./noop/index.cjs",
|
|
278
|
+
"default": "./noop/index.cjs"
|
|
270
279
|
},
|
|
271
280
|
"./noop-component": {
|
|
272
281
|
"types": "./noop-component/index.d.ts",
|
|
@@ -277,6 +286,15 @@
|
|
|
277
286
|
"require": "./noop-component/index.cjs",
|
|
278
287
|
"default": "./noop-component/index.cjs"
|
|
279
288
|
},
|
|
289
|
+
"./nullthrow": {
|
|
290
|
+
"types": "./nullthrow/index.d.ts",
|
|
291
|
+
"import": {
|
|
292
|
+
"types": "./nullthrow/index.d.ts",
|
|
293
|
+
"default": "./nullthrow/index.mjs"
|
|
294
|
+
},
|
|
295
|
+
"require": "./nullthrow/index.cjs",
|
|
296
|
+
"default": "./nullthrow/index.cjs"
|
|
297
|
+
},
|
|
280
298
|
"./open-new-tab": {
|
|
281
299
|
"types": "./open-new-tab/index.d.ts",
|
|
282
300
|
"import": {
|
|
@@ -349,15 +367,6 @@
|
|
|
349
367
|
"require": "./use-abortable-effect/index.cjs",
|
|
350
368
|
"default": "./use-abortable-effect/index.cjs"
|
|
351
369
|
},
|
|
352
|
-
"./use-clipboard": {
|
|
353
|
-
"types": "./use-clipboard/index.d.ts",
|
|
354
|
-
"import": {
|
|
355
|
-
"types": "./use-clipboard/index.d.ts",
|
|
356
|
-
"default": "./use-clipboard/index.mjs"
|
|
357
|
-
},
|
|
358
|
-
"require": "./use-clipboard/index.cjs",
|
|
359
|
-
"default": "./use-clipboard/index.cjs"
|
|
360
|
-
},
|
|
361
370
|
"./use-array": {
|
|
362
371
|
"types": "./use-array/index.d.ts",
|
|
363
372
|
"import": {
|
|
@@ -367,6 +376,15 @@
|
|
|
367
376
|
"require": "./use-array/index.cjs",
|
|
368
377
|
"default": "./use-array/index.cjs"
|
|
369
378
|
},
|
|
379
|
+
"./use-clipboard": {
|
|
380
|
+
"types": "./use-clipboard/index.d.ts",
|
|
381
|
+
"import": {
|
|
382
|
+
"types": "./use-clipboard/index.d.ts",
|
|
383
|
+
"default": "./use-clipboard/index.mjs"
|
|
384
|
+
},
|
|
385
|
+
"require": "./use-clipboard/index.cjs",
|
|
386
|
+
"default": "./use-clipboard/index.cjs"
|
|
387
|
+
},
|
|
370
388
|
"./use-component-will-receive-update": {
|
|
371
389
|
"types": "./use-component-will-receive-update/index.d.ts",
|
|
372
390
|
"import": {
|
|
@@ -412,6 +430,15 @@
|
|
|
412
430
|
"require": "./use-error-boundary/index.cjs",
|
|
413
431
|
"default": "./use-error-boundary/index.cjs"
|
|
414
432
|
},
|
|
433
|
+
"./use-intersection": {
|
|
434
|
+
"types": "./use-intersection/index.d.ts",
|
|
435
|
+
"import": {
|
|
436
|
+
"types": "./use-intersection/index.d.ts",
|
|
437
|
+
"default": "./use-intersection/index.mjs"
|
|
438
|
+
},
|
|
439
|
+
"require": "./use-intersection/index.cjs",
|
|
440
|
+
"default": "./use-intersection/index.cjs"
|
|
441
|
+
},
|
|
415
442
|
"./use-fast-click": {
|
|
416
443
|
"types": "./use-fast-click/index.d.ts",
|
|
417
444
|
"import": {
|
|
@@ -430,15 +457,6 @@
|
|
|
430
457
|
"require": "./use-is-client/index.cjs",
|
|
431
458
|
"default": "./use-is-client/index.cjs"
|
|
432
459
|
},
|
|
433
|
-
"./use-intersection": {
|
|
434
|
-
"types": "./use-intersection/index.d.ts",
|
|
435
|
-
"import": {
|
|
436
|
-
"types": "./use-intersection/index.d.ts",
|
|
437
|
-
"default": "./use-intersection/index.mjs"
|
|
438
|
-
},
|
|
439
|
-
"require": "./use-intersection/index.cjs",
|
|
440
|
-
"default": "./use-intersection/index.cjs"
|
|
441
|
-
},
|
|
442
460
|
"./use-is-online": {
|
|
443
461
|
"types": "./use-is-online/index.d.ts",
|
|
444
462
|
"import": {
|
|
@@ -466,15 +484,6 @@
|
|
|
466
484
|
"require": "./use-local-storage/index.cjs",
|
|
467
485
|
"default": "./use-local-storage/index.cjs"
|
|
468
486
|
},
|
|
469
|
-
"./use-media-query": {
|
|
470
|
-
"types": "./use-media-query/index.d.ts",
|
|
471
|
-
"import": {
|
|
472
|
-
"types": "./use-media-query/index.d.ts",
|
|
473
|
-
"default": "./use-media-query/index.mjs"
|
|
474
|
-
},
|
|
475
|
-
"require": "./use-media-query/index.cjs",
|
|
476
|
-
"default": "./use-media-query/index.cjs"
|
|
477
|
-
},
|
|
478
487
|
"./use-map": {
|
|
479
488
|
"types": "./use-map/index.d.ts",
|
|
480
489
|
"import": {
|
|
@@ -484,6 +493,15 @@
|
|
|
484
493
|
"require": "./use-map/index.cjs",
|
|
485
494
|
"default": "./use-map/index.cjs"
|
|
486
495
|
},
|
|
496
|
+
"./use-media-query": {
|
|
497
|
+
"types": "./use-media-query/index.d.ts",
|
|
498
|
+
"import": {
|
|
499
|
+
"types": "./use-media-query/index.d.ts",
|
|
500
|
+
"default": "./use-media-query/index.mjs"
|
|
501
|
+
},
|
|
502
|
+
"require": "./use-media-query/index.cjs",
|
|
503
|
+
"default": "./use-media-query/index.cjs"
|
|
504
|
+
},
|
|
487
505
|
"./use-page-visibility": {
|
|
488
506
|
"types": "./use-page-visibility/index.d.ts",
|
|
489
507
|
"import": {
|
|
@@ -529,15 +547,6 @@
|
|
|
529
547
|
"require": "./use-session-storage/index.cjs",
|
|
530
548
|
"default": "./use-session-storage/index.cjs"
|
|
531
549
|
},
|
|
532
|
-
"./use-set": {
|
|
533
|
-
"types": "./use-set/index.d.ts",
|
|
534
|
-
"import": {
|
|
535
|
-
"types": "./use-set/index.d.ts",
|
|
536
|
-
"default": "./use-set/index.mjs"
|
|
537
|
-
},
|
|
538
|
-
"require": "./use-set/index.cjs",
|
|
539
|
-
"default": "./use-set/index.cjs"
|
|
540
|
-
},
|
|
541
550
|
"./use-singleton": {
|
|
542
551
|
"types": "./use-singleton/index.d.ts",
|
|
543
552
|
"import": {
|
|
@@ -556,6 +565,15 @@
|
|
|
556
565
|
"require": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs",
|
|
557
566
|
"default": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs"
|
|
558
567
|
},
|
|
568
|
+
"./use-set": {
|
|
569
|
+
"types": "./use-set/index.d.ts",
|
|
570
|
+
"import": {
|
|
571
|
+
"types": "./use-set/index.d.ts",
|
|
572
|
+
"default": "./use-set/index.mjs"
|
|
573
|
+
},
|
|
574
|
+
"require": "./use-set/index.cjs",
|
|
575
|
+
"default": "./use-set/index.cjs"
|
|
576
|
+
},
|
|
559
577
|
"./use-state-with-deps": {
|
|
560
578
|
"types": "./use-state-with-deps/index.d.ts",
|
|
561
579
|
"import": {
|
|
@@ -591,6 +609,15 @@
|
|
|
591
609
|
},
|
|
592
610
|
"require": "./use-url-hash-state/index.cjs",
|
|
593
611
|
"default": "./use-url-hash-state/index.cjs"
|
|
612
|
+
},
|
|
613
|
+
"./create-magic-portal": {
|
|
614
|
+
"types": "./create-magic-portal/index.d.ts",
|
|
615
|
+
"import": {
|
|
616
|
+
"types": "./create-magic-portal/index.d.ts",
|
|
617
|
+
"default": "./create-magic-portal/index.mjs"
|
|
618
|
+
},
|
|
619
|
+
"require": "./create-magic-portal/index.cjs",
|
|
620
|
+
"default": "./create-magic-portal/index.cjs"
|
|
594
621
|
}
|
|
595
622
|
}
|
|
596
623
|
}
|
package/sizes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"total":{"raw":
|
|
1
|
+
{"total":{"raw":28997,"gzip":17815,"br":14973,"zstd":17840},"exports":{"context-reducer":{"raw":557,"gzip":332,"br":319,"zstd":336},"browser":{"raw":686,"gzip":402,"br":333,"zstd":413},"create-context-reducer":{"raw":63,"gzip":74,"br":64,"zstd":72},"create-breadcrumbs":{"raw":56,"gzip":68,"br":52,"zstd":65},"create-context-state":{"raw":59,"gzip":72,"br":59,"zstd":68},"create-fixed-array":{"raw":452,"gzip":282,"br":248,"zstd":282},"compose-context-provider":{"raw":177,"gzip":155,"br":122,"zstd":144},"create-local-storage-state":{"raw":169,"gzip":138,"br":111,"zstd":130},"create-stackless-error":{"raw":278,"gzip":198,"br":162,"zstd":188},"create-storage-state-factory":{"raw":364,"gzip":248,"br":197,"zstd":243},"create-storage-hook":{"raw":2418,"gzip":957,"br":835,"zstd":1000},"breadcrumbs":{"raw":879,"gzip":467,"br":395,"zstd":472},"create-session-storage-state":{"raw":173,"gzip":138,"br":108,"zstd":129},"current-year":{"raw":508,"gzip":348,"br":283,"zstd":349},"get-react-children":{"raw":568,"gzip":354,"br":284,"zstd":355},"is-safari":{"raw":247,"gzip":175,"br":133,"zstd":169},"context-state":{"raw":402,"gzip":259,"br":218,"zstd":259},"get-single-react-children":{"raw":68,"gzip":80,"br":70,"zstd":77},"fetch-jsonp":{"raw":924,"gzip":570,"br":446,"zstd":576},"magic-portal":{"raw":1013,"gzip":517,"br":445,"zstd":526},"merge-refs":{"raw":525,"gzip":280,"br":235,"zstd":278},"invariant":{"raw":178,"gzip":156,"br":118,"zstd":149},"no-ssr":{"raw":381,"gzip":281,"br":236,"zstd":285},"noop-component":{"raw":142,"gzip":130,"br":111,"zstd":119},"noop":{"raw":33,"gzip":53,"br":37,"zstd":42},"open-new-tab":{"raw":335,"gzip":255,"br":187,"zstd":255},"polymorphic":{"raw":284,"gzip":212,"br":180,"zstd":199},"nullthrow":{"raw":187,"gzip":163,"br":121,"zstd":156},"types":{"raw":0,"gzip":20,"br":1,"zstd":9},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80,"zstd":91},"merge-props":{"raw":1030,"gzip":559,"br":501,"zstd":577},"use":{"raw":301,"gzip":200,"br":177,"zstd":193},"use-abortable-effect":{"raw":215,"gzip":170,"br":144,"zstd":166},"use-array":{"raw":334,"gzip":243,"br":206,"zstd":236},"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-error-boundary":{"raw":252,"gzip":195,"br":165,"zstd":187},"use-fast-click":{"raw":499,"gzip":350,"br":284,"zstd":355},"use-is-client":{"raw":184,"gzip":158,"br":130,"zstd":149},"use-debounced-value":{"raw":553,"gzip":358,"br":320,"zstd":360},"use-clipboard":{"raw":2718,"gzip":1333,"br":1141,"zstd":1398},"use-is-online":{"raw":288,"gzip":216,"br":196,"zstd":205},"use-intersection":{"raw":1363,"gzip":716,"br":654,"zstd":750},"use-local-storage":{"raw":192,"gzip":143,"br":114,"zstd":137},"request-idle-callback":{"raw":392,"gzip":221,"br":171,"zstd":213},"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-resizing":{"raw":511,"gzip":334,"br":294,"zstd":342},"use-session-storage":{"raw":198,"gzip":141,"br":118,"zstd":137},"use-readonly-search-params":{"raw":1035,"gzip":547,"br":449,"zstd":558},"use-singleton":{"raw":149,"gzip":135,"br":116,"zstd":123},"use-retimer":{"raw":194,"gzip":166,"br":127,"zstd":154},"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-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110,"zstd":127},"use-set":{"raw":368,"gzip":247,"br":211,"zstd":255},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77,"zstd":94},"create-magic-portal":{"raw":57,"gzip":71,"br":53,"zstd":66},"use-state-with-deps":{"raw":747,"gzip":479,"br":418,"zstd":488},"use-uncontrolled":{"raw":388,"gzip":273,"br":230,"zstd":277},"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};
|