foxact 0.2.52 → 0.2.53
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/context-reducer/index.mjs +1 -1
- package/context-state/index.mjs +1 -1
- package/current-year/index.cjs +1 -1
- package/current-year/index.d.ts +2 -4
- package/current-year/index.mjs +1 -1
- package/package.json +34 -25
- package/sizes.json +1 -1
- package/use-readonly-search-params/index.cjs +1 -0
- package/use-readonly-search-params/index.d.ts +14 -0
- package/use-readonly-search-params/index.mjs +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import"client-only";import{
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import"client-only";import{useReducer as n,useContext as e,createContext as t}from"react";import{noop as i}from"../noop/index.mjs";import{t as o}from"../chunks/index.D0KaUCcV.mjs";import{n as m}from"../chunks/index.C9-3oDdv.mjs";function l(l,c,u){const d=t(m(u)?u(c):c),p=t(i);return[e=>{var t;let{children:i,initialArg:m,init:s}=e;const[a,f]=n(l,null!=m?m:c,null!=(t=null!=s?s:u)?t:o);return r(d.Provider,{value:a,children:r(p.Provider,{value:f,children:i})})},()=>e(d),()=>e(p),d]}export{l as createContextReducer};
|
package/context-state/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import"client-only";import{
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import"client-only";import{useState as r,useContext as e,createContext as o}from"react";import{noop as n}from"../noop/index.mjs";function i(i){const l=o(i),c=o(n);return[e=>{let{children:o,initialState:n}=e;const[m,a]=r(null!=n?n:i);return t(l.Provider,{value:m,children:t(c.Provider,{value:a,children:o})})},()=>e(l),()=>e(c),l]}export{i as createContextState};
|
package/current-year/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../use-isomorphic-layout-effect/index.cjs");require("client-only");const n=r.memo(n
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../use-isomorphic-layout-effect/index.cjs");require("client-only");const n=r.memo(function(n){let{defaultYear:u,...i}=n;"u"<typeof window&&void 0===u&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[o,s]=r.useState(u||new Date().getFullYear());return t.useIsomorphicLayoutEffect(()=>{s(new Date().getFullYear())},[]),e.jsx("span",{...i,children:o})});exports.CurrentYear=n;
|
package/current-year/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { Foxact } from '../types/index.js';
|
|
4
2
|
|
|
5
|
-
interface CurrentYearProps extends
|
|
3
|
+
interface CurrentYearProps extends React.ComponentProps<'span'> {
|
|
6
4
|
defaultYear?: number;
|
|
7
5
|
}
|
|
8
6
|
/** @see https://foxact.skk.moe/current-year */
|
|
9
|
-
declare const CurrentYear: react.
|
|
7
|
+
declare const CurrentYear: react.NamedExoticComponent<CurrentYearProps>;
|
|
10
8
|
|
|
11
9
|
export { CurrentYear };
|
package/current-year/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import{memo as r,useState as t}from"react";import{useIsomorphicLayoutEffect as
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import{memo as r,useState as t}from"react";import{useIsomorphicLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";import"client-only";const o=r(function(r){let{defaultYear:o,...i}=r;"u"<typeof window&&void 0===o&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[a,u]=t(o||new Date().getFullYear());return n(()=>{u(new Date().getFullYear())},[]),e("span",{...i,children:a})});export{o as CurrentYear};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.53",
|
|
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": {
|
|
@@ -69,6 +69,15 @@
|
|
|
69
69
|
"require": "./context-reducer/index.cjs",
|
|
70
70
|
"default": "./context-reducer/index.cjs"
|
|
71
71
|
},
|
|
72
|
+
"./context-state": {
|
|
73
|
+
"types": "./context-state/index.d.ts",
|
|
74
|
+
"import": {
|
|
75
|
+
"types": "./context-state/index.d.ts",
|
|
76
|
+
"default": "./context-state/index.mjs"
|
|
77
|
+
},
|
|
78
|
+
"require": "./context-state/index.cjs",
|
|
79
|
+
"default": "./context-state/index.cjs"
|
|
80
|
+
},
|
|
72
81
|
"./create-context-reducer": {
|
|
73
82
|
"types": "./create-context-reducer/index.d.ts",
|
|
74
83
|
"import": {
|
|
@@ -78,14 +87,14 @@
|
|
|
78
87
|
"require": "./create-context-reducer/index.cjs",
|
|
79
88
|
"default": "./create-context-reducer/index.cjs"
|
|
80
89
|
},
|
|
81
|
-
"./context-state": {
|
|
82
|
-
"types": "./context-state/index.d.ts",
|
|
90
|
+
"./create-context-state": {
|
|
91
|
+
"types": "./create-context-state/index.d.ts",
|
|
83
92
|
"import": {
|
|
84
|
-
"types": "./context-state/index.d.ts",
|
|
85
|
-
"default": "./context-state/index.mjs"
|
|
93
|
+
"types": "./create-context-state/index.d.ts",
|
|
94
|
+
"default": "./create-context-state/index.mjs"
|
|
86
95
|
},
|
|
87
|
-
"require": "./context-state/index.cjs",
|
|
88
|
-
"default": "./context-state/index.cjs"
|
|
96
|
+
"require": "./create-context-state/index.cjs",
|
|
97
|
+
"default": "./create-context-state/index.cjs"
|
|
89
98
|
},
|
|
90
99
|
"./create-fixed-array": {
|
|
91
100
|
"types": "./create-fixed-array/index.d.ts",
|
|
@@ -105,15 +114,6 @@
|
|
|
105
114
|
"require": "./create-local-storage-state/index.cjs",
|
|
106
115
|
"default": "./create-local-storage-state/index.cjs"
|
|
107
116
|
},
|
|
108
|
-
"./create-context-state": {
|
|
109
|
-
"types": "./create-context-state/index.d.ts",
|
|
110
|
-
"import": {
|
|
111
|
-
"types": "./create-context-state/index.d.ts",
|
|
112
|
-
"default": "./create-context-state/index.mjs"
|
|
113
|
-
},
|
|
114
|
-
"require": "./create-context-state/index.cjs",
|
|
115
|
-
"default": "./create-context-state/index.cjs"
|
|
116
|
-
},
|
|
117
117
|
"./create-magic-portal": {
|
|
118
118
|
"types": "./create-magic-portal/index.d.ts",
|
|
119
119
|
"import": {
|
|
@@ -186,15 +186,6 @@
|
|
|
186
186
|
"require": "./invariant/index.cjs",
|
|
187
187
|
"default": "./invariant/index.cjs"
|
|
188
188
|
},
|
|
189
|
-
"./magic-portal": {
|
|
190
|
-
"types": "./magic-portal/index.d.ts",
|
|
191
|
-
"import": {
|
|
192
|
-
"types": "./magic-portal/index.d.ts",
|
|
193
|
-
"default": "./magic-portal/index.mjs"
|
|
194
|
-
},
|
|
195
|
-
"require": "./magic-portal/index.cjs",
|
|
196
|
-
"default": "./magic-portal/index.cjs"
|
|
197
|
-
},
|
|
198
189
|
"./is-safari": {
|
|
199
190
|
"types": "./is-safari/index.d.ts",
|
|
200
191
|
"import": {
|
|
@@ -204,6 +195,15 @@
|
|
|
204
195
|
"require": "./is-safari/index.cjs",
|
|
205
196
|
"default": "./is-safari/index.cjs"
|
|
206
197
|
},
|
|
198
|
+
"./magic-portal": {
|
|
199
|
+
"types": "./magic-portal/index.d.ts",
|
|
200
|
+
"import": {
|
|
201
|
+
"types": "./magic-portal/index.d.ts",
|
|
202
|
+
"default": "./magic-portal/index.mjs"
|
|
203
|
+
},
|
|
204
|
+
"require": "./magic-portal/index.cjs",
|
|
205
|
+
"default": "./magic-portal/index.cjs"
|
|
206
|
+
},
|
|
207
207
|
"./no-ssr": {
|
|
208
208
|
"types": "./no-ssr/index.d.ts",
|
|
209
209
|
"import": {
|
|
@@ -474,6 +474,15 @@
|
|
|
474
474
|
"require": "./use-react-router-is-match/index.cjs",
|
|
475
475
|
"default": "./use-react-router-is-match/index.cjs"
|
|
476
476
|
},
|
|
477
|
+
"./use-readonly-search-params": {
|
|
478
|
+
"types": "./use-readonly-search-params/index.d.ts",
|
|
479
|
+
"import": {
|
|
480
|
+
"types": "./use-readonly-search-params/index.d.ts",
|
|
481
|
+
"default": "./use-readonly-search-params/index.mjs"
|
|
482
|
+
},
|
|
483
|
+
"require": "./use-readonly-search-params/index.cjs",
|
|
484
|
+
"default": "./use-readonly-search-params/index.cjs"
|
|
485
|
+
},
|
|
477
486
|
"./use-retimer": {
|
|
478
487
|
"types": "./use-retimer/index.d.ts",
|
|
479
488
|
"import": {
|
package/sizes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"total":{"raw":
|
|
1
|
+
{"total":{"raw":27165,"gzip":16404,"br":0},"exports":{"context-reducer":{"raw":557,"gzip":332,"br":319},"create-context-state":{"raw":145,"gzip":116,"br":96},"context-state":{"raw":402,"gzip":259,"br":218},"create-local-storage-state":{"raw":402,"gzip":216,"br":189},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"create-session-storage-state":{"raw":406,"gzip":215,"br":188},"compose-context-provider":{"raw":177,"gzip":155,"br":122},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-magic-portal":{"raw":224,"gzip":136,"br":112},"create-storage-state-factory":{"raw":592,"gzip":338,"br":304},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"current-year":{"raw":524,"gzip":355,"br":293},"email-protection":{"raw":426,"gzip":321,"br":272},"is-safari":{"raw":233,"gzip":164,"br":119},"create-storage-hook":{"raw":2087,"gzip":897,"br":789},"noop":{"raw":33,"gzip":53,"br":37},"invariant":{"raw":178,"gzip":156,"br":118},"open-new-tab":{"raw":335,"gzip":255,"br":187},"nullthrow":{"raw":187,"gzip":163,"br":121},"magic-portal":{"raw":1039,"gzip":521,"br":463},"types":{"raw":0,"gzip":20,"br":1},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"no-ssr":{"raw":465,"gzip":313,"br":260},"use":{"raw":298,"gzip":197,"br":160},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"request-idle-callback":{"raw":392,"gzip":221,"br":171},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"rem":{"raw":823,"gzip":395,"br":350},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-array":{"raw":322,"gzip":236,"br":202},"use-clipboard":{"raw":1177,"gzip":650,"br":552},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-fast-click":{"raw":553,"gzip":364,"br":297},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110},"use-local-storage":{"raw":384,"gzip":215,"br":201},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-is-online":{"raw":350,"gzip":209,"br":162},"use-next-pathname":{"raw":314,"gzip":235,"br":203},"use-page-visibility":{"raw":284,"gzip":203,"br":150},"use-media-query":{"raw":702,"gzip":404,"br":331},"use-map":{"raw":339,"gzip":243,"br":208},"use-readonly-search-params":{"raw":1096,"gzip":551,"br":443},"use-next-link":{"raw":1647,"gzip":875,"br":742},"use-react-router-enable-concurrent-navigation":{"raw":966,"gzip":470,"br":397},"use-react-router-is-match":{"raw":594,"gzip":395,"br":337},"use-set":{"raw":340,"gzip":238,"br":203},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-uncontrolled":{"raw":388,"gzip":273,"br":230},"use-session-storage":{"raw":390,"gzip":210,"br":201},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":450,"gzip":318,"br":249},"use-url-hash-state":{"raw":1124,"gzip":637,"br":559}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../no-ssr/index.cjs"),r=require("../noop/index.cjs"),n=require("react");class a extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class o extends URLSearchParams{append(){throw new a}delete(){throw new a}set(){throw new a}sort(){throw new a}}function t(e){return"u"<typeof window?r.noop:(window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)})}let s=null,c=null;function u(){return"u"<typeof window?new o:window.location.search===s&&null!==c?c:c=new o(s=window.location.search)}function i(){throw e.noSSRError('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}exports.ReadonlyURLSearchParams=o,exports.useReadonlySearchParams=function(e){return n.useSyncExternalStore(t,u,null==e?i:()=>{const r=e();return r instanceof o?r:new o(r)})};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class ReadonlyURLSearchParams extends URLSearchParams {
|
|
2
|
+
/** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://foxact.skk.moe/use-readonly-search-params */
|
|
3
|
+
append(): never;
|
|
4
|
+
/** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://foxact.skk.moe/use-readonly-search-params */
|
|
5
|
+
delete(): never;
|
|
6
|
+
/** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://foxact.skk.moe/use-readonly-search-params */
|
|
7
|
+
set(): never;
|
|
8
|
+
/** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://foxact.skk.moe/use-readonly-search-params */
|
|
9
|
+
sort(): never;
|
|
10
|
+
}
|
|
11
|
+
/** @see https://foxact.skk.moe/use-readonly-search-params */
|
|
12
|
+
declare function useReadonlySearchParams(getServerDefaultValue?: () => URLSearchParams | ReadonlyURLSearchParams): ReadonlyURLSearchParams;
|
|
13
|
+
|
|
14
|
+
export { ReadonlyURLSearchParams, useReadonlySearchParams };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as r}from"../noop/index.mjs";import{useSyncExternalStore as n}from"react";class o 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 a extends URLSearchParams{append(){throw new o}delete(){throw new o}set(){throw new o}sort(){throw new o}}function t(e){return"u"<typeof window?r:(window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)})}let s=null,i=null;function c(){return"u"<typeof window?new a:window.location.search===s&&null!==i?i:i=new a(s=window.location.search)}function l(){throw e('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}function u(e){return n(t,c,null==e?l:()=>{const r=e();return r instanceof a?r:new a(r)})}export{a as ReadonlyURLSearchParams,u as useReadonlySearchParams};
|