foxact 0.2.45 → 0.2.46
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/compose-context-provider/index.d.ts +1 -3
- package/context-state/index.d.ts +7 -6
- package/create-context-state/index.d.ts +0 -2
- package/create-storage-state-factory/index.d.ts +1 -11
- package/current-year/index.d.ts +1 -3
- package/open-new-tab/index.cjs +1 -1
- package/open-new-tab/index.mjs +1 -1
- package/package.json +52 -77
- package/sizes.json +1 -1
- package/use/index.cjs +1 -1
- package/use/index.mjs +1 -1
- package/use-abortable-effect/index.d.ts +1 -5
- package/use-local-storage/index.d.ts +3 -9
- package/use-media-query/index.cjs +1 -1
- package/use-media-query/index.mjs +1 -1
- package/use-next-link/index.cjs +1 -1
- package/use-next-link/index.d.ts +1 -3
- package/use-next-link/index.mjs +1 -1
- package/use-react-router-enable-concurrent-navigation/index.d.ts +1 -3
- package/use-react-router-is-match/index.d.ts +1 -5
- package/use-session-storage/index.d.ts +3 -9
- package/use-url-hash-state/index.cjs +1 -1
- package/use-url-hash-state/index.mjs +1 -1
package/context-state/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import type { Foxact } from '../types/index.js';
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Foxact } from '../types/index.js';
|
|
6
2
|
|
|
7
3
|
/** @see https://foxact.skk.moe/context-state */
|
|
8
|
-
declare function createContextState<T>(initialState: T):
|
|
4
|
+
declare function createContextState<T>(initialState: T): [
|
|
5
|
+
Provider: React.ComponentType<Foxact.PropsWithChildren>,
|
|
6
|
+
useValue: () => T,
|
|
7
|
+
useSetValue: () => React.Dispatch<React.SetStateAction<T>>,
|
|
8
|
+
StateContext: React.Context<T>
|
|
9
|
+
];
|
|
9
10
|
|
|
10
11
|
export { createContextState };
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { StateHookTuple, StorageType, NotUndefined, UseStorageRawOption, UseStorageParserOption } from '../create-storage-hook/index.js';
|
|
12
2
|
|
|
13
3
|
type ValueHook<T> = () => T;
|
|
14
4
|
type SetValueHook<T> = () => (value: T) => void;
|
package/current-year/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { Foxact } from '../types/index.js';
|
|
6
4
|
|
|
7
5
|
interface CurrentYearProps extends Foxact.ComponentProps<'span'> {
|
|
8
6
|
defaultYear?: number;
|
package/open-new-tab/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../is-safari/index.cjs");exports.openInNewTab=function(n){if("undefined"==typeof window)return;if(e.isSafari())
|
|
1
|
+
"use strict";var e=require("../is-safari/index.cjs");exports.openInNewTab=function(n){if("undefined"==typeof window)return;if(e.isSafari())return void window.open(n,"_blank");const r=document.createElement("a");r.href=n,r.target="_blank",r.rel="noopener noreferrer",document.body.appendChild(r),r.click(),Promise.resolve().finally(()=>{r.remove()})};
|
package/open-new-tab/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isSafari as e}from"../is-safari/index.mjs";function n(n){if("undefined"==typeof window)return;if(e())
|
|
1
|
+
import{isSafari as e}from"../is-safari/index.mjs";function n(n){if("undefined"==typeof window)return;if(e())return void window.open(n,"_blank");const o=document.createElement("a");o.href=n,o.target="_blank",o.rel="noopener noreferrer",document.body.appendChild(o),o.click(),Promise.resolve().finally(()=>{o.remove()})}export{n as openInNewTab};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.46",
|
|
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": {
|
|
@@ -32,31 +32,6 @@
|
|
|
32
32
|
"optional": true
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
-
"packageManager": "pnpm@10.6.4",
|
|
36
|
-
"pnpm": {
|
|
37
|
-
"overrides": {
|
|
38
|
-
"array-includes": "npm:@nolyfill/array-includes@latest",
|
|
39
|
-
"array.prototype.findlastindex": "npm:@nolyfill/array.prototype.findlastindex@latest",
|
|
40
|
-
"array.prototype.flat": "npm:@nolyfill/array.prototype.flat@latest",
|
|
41
|
-
"array.prototype.flatmap": "npm:@nolyfill/array.prototype.flatmap@latest",
|
|
42
|
-
"array.prototype.tosorted": "npm:@nolyfill/array.prototype.tosorted@latest",
|
|
43
|
-
"es-iterator-helpers": "npm:@nolyfill/es-iterator-helpers@latest",
|
|
44
|
-
"function-bind": "npm:@nolyfill/function-bind@latest",
|
|
45
|
-
"has": "npm:@nolyfill/has@latest",
|
|
46
|
-
"hasown": "npm:@nolyfill/hasown@latest",
|
|
47
|
-
"object.assign": "npm:@nolyfill/object.assign@latest",
|
|
48
|
-
"object.entries": "npm:@nolyfill/object.entries@latest",
|
|
49
|
-
"object.fromentries": "npm:@nolyfill/object.fromentries@latest",
|
|
50
|
-
"object.groupby": "npm:@nolyfill/object.groupby@latest",
|
|
51
|
-
"object.hasown": "npm:@nolyfill/object.hasown@latest",
|
|
52
|
-
"object.values": "npm:@nolyfill/object.values@latest",
|
|
53
|
-
"rollup": "$rollup",
|
|
54
|
-
"string.prototype.matchall": "npm:@nolyfill/string.prototype.matchall@latest"
|
|
55
|
-
},
|
|
56
|
-
"onlyBuiltDependencies": [
|
|
57
|
-
"@swc/core"
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
35
|
"typeVersions": {
|
|
61
36
|
">=4.8": {
|
|
62
37
|
"*": [
|
|
@@ -81,15 +56,6 @@
|
|
|
81
56
|
"require": "./compose-context-provider/index.cjs",
|
|
82
57
|
"default": "./compose-context-provider/index.cjs"
|
|
83
58
|
},
|
|
84
|
-
"./context-state": {
|
|
85
|
-
"types": "./context-state/index.d.ts",
|
|
86
|
-
"import": {
|
|
87
|
-
"types": "./context-state/index.d.ts",
|
|
88
|
-
"default": "./context-state/index.mjs"
|
|
89
|
-
},
|
|
90
|
-
"require": "./context-state/index.cjs",
|
|
91
|
-
"default": "./context-state/index.cjs"
|
|
92
|
-
},
|
|
93
59
|
"./create-context-state": {
|
|
94
60
|
"types": "./create-context-state/index.d.ts",
|
|
95
61
|
"import": {
|
|
@@ -126,15 +92,6 @@
|
|
|
126
92
|
"require": "./create-session-storage-state/index.cjs",
|
|
127
93
|
"default": "./create-session-storage-state/index.cjs"
|
|
128
94
|
},
|
|
129
|
-
"./create-storage-state-factory": {
|
|
130
|
-
"types": "./create-storage-state-factory/index.d.ts",
|
|
131
|
-
"import": {
|
|
132
|
-
"types": "./create-storage-state-factory/index.d.ts",
|
|
133
|
-
"default": "./create-storage-state-factory/index.mjs"
|
|
134
|
-
},
|
|
135
|
-
"require": "./create-storage-state-factory/index.cjs",
|
|
136
|
-
"default": "./create-storage-state-factory/index.cjs"
|
|
137
|
-
},
|
|
138
95
|
"./create-storage-hook": {
|
|
139
96
|
"types": "./create-storage-hook/index.d.ts",
|
|
140
97
|
"import": {
|
|
@@ -144,14 +101,23 @@
|
|
|
144
101
|
"require": "./create-storage-hook/index.cjs",
|
|
145
102
|
"default": "./create-storage-hook/index.cjs"
|
|
146
103
|
},
|
|
147
|
-
"./
|
|
148
|
-
"types": "./
|
|
104
|
+
"./context-state": {
|
|
105
|
+
"types": "./context-state/index.d.ts",
|
|
149
106
|
"import": {
|
|
150
|
-
"types": "./
|
|
151
|
-
"default": "./
|
|
107
|
+
"types": "./context-state/index.d.ts",
|
|
108
|
+
"default": "./context-state/index.mjs"
|
|
152
109
|
},
|
|
153
|
-
"require": "./
|
|
154
|
-
"default": "./
|
|
110
|
+
"require": "./context-state/index.cjs",
|
|
111
|
+
"default": "./context-state/index.cjs"
|
|
112
|
+
},
|
|
113
|
+
"./create-storage-state-factory": {
|
|
114
|
+
"types": "./create-storage-state-factory/index.d.ts",
|
|
115
|
+
"import": {
|
|
116
|
+
"types": "./create-storage-state-factory/index.d.ts",
|
|
117
|
+
"default": "./create-storage-state-factory/index.mjs"
|
|
118
|
+
},
|
|
119
|
+
"require": "./create-storage-state-factory/index.cjs",
|
|
120
|
+
"default": "./create-storage-state-factory/index.cjs"
|
|
155
121
|
},
|
|
156
122
|
"./email-protection": {
|
|
157
123
|
"types": "./email-protection/index.d.ts",
|
|
@@ -162,6 +128,15 @@
|
|
|
162
128
|
"require": "./email-protection/index.cjs",
|
|
163
129
|
"default": "./email-protection/index.cjs"
|
|
164
130
|
},
|
|
131
|
+
"./current-year": {
|
|
132
|
+
"types": "./current-year/index.d.ts",
|
|
133
|
+
"import": {
|
|
134
|
+
"types": "./current-year/index.d.ts",
|
|
135
|
+
"default": "./current-year/index.mjs"
|
|
136
|
+
},
|
|
137
|
+
"require": "./current-year/index.cjs",
|
|
138
|
+
"default": "./current-year/index.cjs"
|
|
139
|
+
},
|
|
165
140
|
"./fetch-jsonp": {
|
|
166
141
|
"types": "./fetch-jsonp/index.d.ts",
|
|
167
142
|
"import": {
|
|
@@ -171,6 +146,15 @@
|
|
|
171
146
|
"require": "./fetch-jsonp/index.cjs",
|
|
172
147
|
"default": "./fetch-jsonp/index.cjs"
|
|
173
148
|
},
|
|
149
|
+
"./invariant": {
|
|
150
|
+
"types": "./invariant/index.d.ts",
|
|
151
|
+
"import": {
|
|
152
|
+
"types": "./invariant/index.d.ts",
|
|
153
|
+
"default": "./invariant/index.mjs"
|
|
154
|
+
},
|
|
155
|
+
"require": "./invariant/index.cjs",
|
|
156
|
+
"default": "./invariant/index.cjs"
|
|
157
|
+
},
|
|
174
158
|
"./is-safari": {
|
|
175
159
|
"types": "./is-safari/index.d.ts",
|
|
176
160
|
"import": {
|
|
@@ -189,15 +173,6 @@
|
|
|
189
173
|
"require": "./no-ssr/index.cjs",
|
|
190
174
|
"default": "./no-ssr/index.cjs"
|
|
191
175
|
},
|
|
192
|
-
"./invariant": {
|
|
193
|
-
"types": "./invariant/index.d.ts",
|
|
194
|
-
"import": {
|
|
195
|
-
"types": "./invariant/index.d.ts",
|
|
196
|
-
"default": "./invariant/index.mjs"
|
|
197
|
-
},
|
|
198
|
-
"require": "./invariant/index.cjs",
|
|
199
|
-
"default": "./invariant/index.cjs"
|
|
200
|
-
},
|
|
201
176
|
"./noop": {
|
|
202
177
|
"types": "./noop/index.d.ts",
|
|
203
178
|
"import": {
|
|
@@ -288,15 +263,6 @@
|
|
|
288
263
|
"require": "./use-array/index.cjs",
|
|
289
264
|
"default": "./use-array/index.cjs"
|
|
290
265
|
},
|
|
291
|
-
"./use-component-will-receive-update": {
|
|
292
|
-
"types": "./use-component-will-receive-update/index.d.ts",
|
|
293
|
-
"import": {
|
|
294
|
-
"types": "./use-component-will-receive-update/index.d.ts",
|
|
295
|
-
"default": "./use-component-will-receive-update/index.mjs"
|
|
296
|
-
},
|
|
297
|
-
"require": "./use-component-will-receive-update/index.cjs",
|
|
298
|
-
"default": "./use-component-will-receive-update/index.cjs"
|
|
299
|
-
},
|
|
300
266
|
"./use-clipboard": {
|
|
301
267
|
"types": "./use-clipboard/index.d.ts",
|
|
302
268
|
"import": {
|
|
@@ -306,6 +272,15 @@
|
|
|
306
272
|
"require": "./use-clipboard/index.cjs",
|
|
307
273
|
"default": "./use-clipboard/index.cjs"
|
|
308
274
|
},
|
|
275
|
+
"./use-component-will-receive-update": {
|
|
276
|
+
"types": "./use-component-will-receive-update/index.d.ts",
|
|
277
|
+
"import": {
|
|
278
|
+
"types": "./use-component-will-receive-update/index.d.ts",
|
|
279
|
+
"default": "./use-component-will-receive-update/index.mjs"
|
|
280
|
+
},
|
|
281
|
+
"require": "./use-component-will-receive-update/index.cjs",
|
|
282
|
+
"default": "./use-component-will-receive-update/index.cjs"
|
|
283
|
+
},
|
|
309
284
|
"./use-composition-input": {
|
|
310
285
|
"types": "./use-composition-input/index.d.ts",
|
|
311
286
|
"import": {
|
|
@@ -468,15 +443,6 @@
|
|
|
468
443
|
"require": "./use-retimer/index.cjs",
|
|
469
444
|
"default": "./use-retimer/index.cjs"
|
|
470
445
|
},
|
|
471
|
-
"./use-set": {
|
|
472
|
-
"types": "./use-set/index.d.ts",
|
|
473
|
-
"import": {
|
|
474
|
-
"types": "./use-set/index.d.ts",
|
|
475
|
-
"default": "./use-set/index.mjs"
|
|
476
|
-
},
|
|
477
|
-
"require": "./use-set/index.cjs",
|
|
478
|
-
"default": "./use-set/index.cjs"
|
|
479
|
-
},
|
|
480
446
|
"./use-session-storage": {
|
|
481
447
|
"types": "./use-session-storage/index.d.ts",
|
|
482
448
|
"import": {
|
|
@@ -486,6 +452,15 @@
|
|
|
486
452
|
"require": "./use-session-storage/index.cjs",
|
|
487
453
|
"default": "./use-session-storage/index.cjs"
|
|
488
454
|
},
|
|
455
|
+
"./use-set": {
|
|
456
|
+
"types": "./use-set/index.d.ts",
|
|
457
|
+
"import": {
|
|
458
|
+
"types": "./use-set/index.d.ts",
|
|
459
|
+
"default": "./use-set/index.mjs"
|
|
460
|
+
},
|
|
461
|
+
"require": "./use-set/index.cjs",
|
|
462
|
+
"default": "./use-set/index.cjs"
|
|
463
|
+
},
|
|
489
464
|
"./use-singleton": {
|
|
490
465
|
"types": "./use-singleton/index.d.ts",
|
|
491
466
|
"import": {
|
package/sizes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"total":{"raw":
|
|
1
|
+
{"total":{"raw":23599,"gzip":14509,"br":0},"exports":{"compose-context-provider":{"raw":177,"gzip":155,"br":122},"create-context-state":{"raw":145,"gzip":116,"br":96},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-session-storage-state":{"raw":332,"gzip":182,"br":152},"context-state":{"raw":377,"gzip":241,"br":207},"email-protection":{"raw":426,"gzip":321,"br":272},"create-storage-state-factory":{"raw":519,"gzip":309,"br":263},"create-local-storage-state":{"raw":328,"gzip":183,"br":154},"invariant":{"raw":178,"gzip":156,"br":118},"is-safari":{"raw":248,"gzip":164,"br":117},"current-year":{"raw":592,"gzip":400,"br":326},"noop":{"raw":33,"gzip":53,"br":37},"create-storage-hook":{"raw":2073,"gzip":880,"br":764},"nullthrow":{"raw":187,"gzip":163,"br":121},"no-ssr":{"raw":474,"gzip":316,"br":260},"fetch-jsonp":{"raw":875,"gzip":533,"br":418},"types":{"raw":0,"gzip":20,"br":1},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"request-idle-callback":{"raw":410,"gzip":229,"br":175},"open-new-tab":{"raw":344,"gzip":260,"br":190},"rem":{"raw":823,"gzip":395,"br":350},"use":{"raw":283,"gzip":185,"br":154},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"use-array":{"raw":322,"gzip":236,"br":202},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-clipboard":{"raw":1177,"gzip":651,"br":552},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-fast-click":{"raw":553,"gzip":364,"br":297},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-is-client":{"raw":150,"gzip":145,"br":115},"use-isomorphic-layout-effect":{"raw":178,"gzip":142,"br":112},"use-is-online":{"raw":356,"gzip":212,"br":158},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-local-storage":{"raw":310,"gzip":184,"br":157},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-media-query":{"raw":725,"gzip":406,"br":332},"use-map":{"raw":339,"gzip":243,"br":208},"use-next-link":{"raw":1673,"gzip":871,"br":744},"use-page-visibility":{"raw":290,"gzip":206,"br":154},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-react-router-is-match":{"raw":563,"gzip":372,"br":314},"use-session-storage":{"raw":316,"gzip":181,"br":152},"use-next-pathname":{"raw":314,"gzip":235,"br":203},"use-set":{"raw":340,"gzip":238,"br":203},"use-singleton":{"raw":139,"gzip":130,"br":104},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":459,"gzip":325,"br":249},"use-react-router-enable-concurrent-navigation":{"raw":966,"gzip":470,"br":397},"use-uncontrolled":{"raw":352,"gzip":258,"br":216},"use-url-hash-state":{"raw":1068,"gzip":616,"br":539}}}
|
package/use/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react").use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.
|
|
1
|
+
"use strict";const e=require("react").use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.catch(t=>{e.status="rejected",e.reason=t}).then(t=>{e.status="fulfilled",e.value=t}),e}});exports.use=e;
|
package/use/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";const t=e.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.
|
|
1
|
+
import e from"react";const t=e.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.catch(t=>{e.status="rejected",e.reason=t}).then(t=>{e.status="fulfilled",e.value=t}),e}});export{t as use};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { EffectCallback, DependencyList } from 'react';
|
|
6
2
|
|
|
7
3
|
/** @see https://foxact.skk.moe/use-abortable-effect */
|
|
8
4
|
declare function useAbortableEffect(callback: (signal: AbortSignal) => ReturnType<EffectCallback>, deps: DependencyList): void;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { NotUndefined, StateHookTuple } from '../create-storage-hook/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { NotUndefined, UseStorageRawOption, UseStorageParserOption, StateHookTuple, Serializer } from '../create-storage-hook/index.js';
|
|
2
|
+
export { Deserializer } from '../create-storage-hook/index.js';
|
|
8
3
|
|
|
9
4
|
declare const useLocalStorage: {
|
|
10
5
|
<T>(key: string, serverValue: NotUndefined<T>, options?: UseStorageRawOption | UseStorageParserOption<T>): StateHookTuple<T>;
|
|
@@ -12,5 +7,4 @@ declare const useLocalStorage: {
|
|
|
12
7
|
};
|
|
13
8
|
declare const useSetLocalStorage: <T>(key: string, serializer: Serializer<T>) => (v: T | null) => void;
|
|
14
9
|
|
|
15
|
-
export { useLocalStorage, useSetLocalStorage };
|
|
16
|
-
export type { Deserializer, Serializer, UseStorageParserOption as UseLocalStorageParserOption, UseStorageRawOption as UseLocalStorageRawOption };
|
|
10
|
+
export { Serializer, UseStorageParserOption as UseLocalStorageParserOption, UseStorageRawOption as UseLocalStorageRawOption, useLocalStorage, useSetLocalStorage };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var e=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),t=require("react");const r=new Map;function o(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,i){"undefined"==typeof window||r.has(e)||r.set(e,window.matchMedia(e).matches);const a=t.useCallback(t=>(function(e,t){if("undefined"==typeof window)return n.noop;const o=window.matchMedia(e),i=()=>{r.set(e,o.matches),t()};return o.addEventListener("change",i),()=>{o.removeEventListener("change",i)}})(e,t),[e]);return t.useSyncExternalStore(a,()=>{var n;return"undefined"!=typeof window&&(null
|
|
2
|
+
"use strict";var e=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),t=require("react");const r=new Map;function o(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,i){"undefined"==typeof window||r.has(e)||r.set(e,window.matchMedia(e).matches);const a=t.useCallback(t=>(function(e,t){if("undefined"==typeof window)return n.noop;const o=window.matchMedia(e),i=()=>{r.set(e,o.matches),t()};return o.addEventListener("change",i),()=>{o.removeEventListener("change",i)}})(e,t),[e]);return t.useSyncExternalStore(a,()=>{var n;return"undefined"!=typeof window&&(null!=(n=r.get(e))?n:window.matchMedia(e).matches)},void 0===i?o:()=>i)};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as n}from"../noop/index.mjs";import{useCallback as t,useSyncExternalStore as o}from"react";const
|
|
2
|
+
import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as n}from"../noop/index.mjs";import{useCallback as t,useSyncExternalStore as o}from"react";const r=new Map;function i(){throw e("useMediaQuery cannot be used on the server without a serverValue")}function d(e,d){return"undefined"==typeof window||r.has(e)||r.set(e,window.matchMedia(e).matches),o(t(t=>(function(e,t){if("undefined"==typeof window)return n;const o=window.matchMedia(e),i=()=>{r.set(e,o.matches),t()};return o.addEventListener("change",i),()=>{o.removeEventListener("change",i)}})(e,t),[e]),()=>{var n;return"undefined"!=typeof window&&(null!=(n=r.get(e))?n:window.matchMedia(e).matches)},void 0===d?i:()=>d)}export{d as useMediaQuery};
|
package/use-next-link/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),t=require("next/navigation"),n=require("next/dist/shared/lib/router/utils/format-url"),r=require("../use-intersection/index.cjs"),o=require("../use-component-will-receive-update/index.cjs");function u(e,t,n){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,n)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}require("../request-idle-callback/index.cjs"),exports.unstable_useNextLink=function(i,s){let{prefetch:c,ref:l,onClick:a,onMouseEnter:f,onTouchStart:p,scroll:d=!0,replace:v=!1,...E}=s;process.env.NODE_ENV;const y=null==c?"auto":"full",N=!1!==c,h=t.useRouter(),[k,m]=e.useTransition(),[b,q,x]=r.useIntersection(e.useMemo(()=>({rootMargin:"200px"}),[])),g=e.useMemo(()=>"string"==typeof i?i:n.formatUrl(i),[i]);return o.useComponentWillReceiveUpdate(x,[g]),e.useEffect(()=>{"production"===process.env.NODE_ENV&&q&&N&&u(h,g,{kind:y})},[y,q,N,g,h]),[k,{ref:e.useCallback(e=>{b(e),"function"==typeof l?l(e):l&&e&&(l.current=e)},[l,b]),onClick:e.useCallback(e=>{if("function"==typeof a&&a(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),t=require("next/navigation"),n=require("next/dist/shared/lib/router/utils/format-url"),r=require("../use-intersection/index.cjs"),o=require("../use-component-will-receive-update/index.cjs");function u(e,t,n){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,n)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}require("../request-idle-callback/index.cjs"),exports.unstable_useNextLink=function(i,s){let{prefetch:c,ref:l,onClick:a,onMouseEnter:f,onTouchStart:p,scroll:d=!0,replace:v=!1,...E}=s;process.env.NODE_ENV;const y=null==c?"auto":"full",N=!1!==c,h=t.useRouter(),[k,m]=e.useTransition(),[b,q,x]=r.useIntersection(e.useMemo(()=>({rootMargin:"200px"}),[])),g=e.useMemo(()=>"string"==typeof i?i:n.formatUrl(i),[i]);return o.useComponentWillReceiveUpdate(x,[g]),e.useEffect(()=>{"production"===process.env.NODE_ENV&&q&&N&&u(h,g,{kind:y})},[y,q,N,g,h]),[k,{ref:e.useCallback(e=>{b(e),"function"==typeof l?l(e):l&&e&&(l.current=e)},[l,b]),onClick:e.useCallback(e=>{if("function"==typeof a&&a(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;"A"===t.toUpperCase()&&function(e){const t=e.currentTarget,n=t.getAttribute("target");return n&&"_self"!==n||t.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e)||(e.preventDefault(),m(()=>{h[v?"replace":"push"](g,{scroll:d})}))},[a,v,g,h,d]),onMouseEnter:e.useCallback(e=>{"function"==typeof f&&f(e),"development"!==process.env.NODE_ENV&&N&&u(h,g,{kind:y})},[y,f,N,g,h]),onTouchStart:e.useCallback(e=>{"function"==typeof p&&p(e),"development"!==process.env.NODE_ENV&&N&&u(h,g,{kind:y})},[y,p,N,g,h]),...E}]};
|
package/use-next-link/index.d.ts
CHANGED
package/use-next-link/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useTransition as e,useMemo as t,useEffect as n,useCallback as o}from"react";import{useRouter as r}from"next/navigation";import{formatUrl as i}from"next/dist/shared/lib/router/utils/format-url";import{useIntersection as c}from"../use-intersection/index.mjs";import{useComponentWillReceiveUpdate as s}from"../use-component-will-receive-update/index.mjs";import"../request-idle-callback/index.mjs";function u(e,t,n){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,n)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}const p=function(p,l){let{prefetch:f,ref:a,onClick:d,onMouseEnter:m,onTouchStart:v,scroll:E=!0,replace:y=!1,...N}=l;process.env.NODE_ENV;const h=null==f?"auto":"full",x=!1!==f,g=r(),[_,k]=e(),[w,D,O]=c(t(()=>({rootMargin:"200px"}),[])),V=t(()=>"string"==typeof p?p:i(p),[p]);return s(O,[V]),n(()=>{"production"===process.env.NODE_ENV&&D&&x&&u(g,V,{kind:h})},[h,D,x,V,g]),[_,{ref:o(e=>{w(e),"function"==typeof a?a(e):a&&e&&(a.current=e)},[a,w]),onClick:o(e=>{if("function"==typeof d&&d(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget
|
|
1
|
+
import"client-only";import{useTransition as e,useMemo as t,useEffect as n,useCallback as o}from"react";import{useRouter as r}from"next/navigation";import{formatUrl as i}from"next/dist/shared/lib/router/utils/format-url";import{useIntersection as c}from"../use-intersection/index.mjs";import{useComponentWillReceiveUpdate as s}from"../use-component-will-receive-update/index.mjs";import"../request-idle-callback/index.mjs";function u(e,t,n){"undefined"!=typeof window&&Promise.resolve(e.prefetch(t,n)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}const p=function(p,l){let{prefetch:f,ref:a,onClick:d,onMouseEnter:m,onTouchStart:v,scroll:E=!0,replace:y=!1,...N}=l;process.env.NODE_ENV;const h=null==f?"auto":"full",x=!1!==f,g=r(),[_,k]=e(),[w,D,O]=c(t(()=>({rootMargin:"200px"}),[])),V=t(()=>"string"==typeof p?p:i(p),[p]);return s(O,[V]),n(()=>{"production"===process.env.NODE_ENV&&D&&x&&u(g,V,{kind:h})},[h,D,x,V,g]),[_,{ref:o(e=>{w(e),"function"==typeof a?a(e):a&&e&&(a.current=e)},[a,w]),onClick:o(e=>{if("function"==typeof d&&d(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;"A"===t.toUpperCase()&&function(e){const t=e.currentTarget,n=t.getAttribute("target");return n&&"_self"!==n||t.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e)||(e.preventDefault(),k(()=>{g[y?"replace":"push"](V,{scroll:E})}))},[d,y,V,g,E]),onMouseEnter:o(e=>{"function"==typeof m&&m(e),"development"!==process.env.NODE_ENV&&x&&u(g,V,{kind:h})},[h,m,x,V,g]),onTouchStart:o(e=>{"function"==typeof v&&v(e),"development"!==process.env.NODE_ENV&&x&&u(g,V,{kind:h})},[h,v,x,V,g]),...N}]};export{p as unstable_useNextLink};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { Foxact } from '../types/index.js';
|
|
5
3
|
|
|
6
4
|
/** @see https://foxact.skk.moe/use-react-router-enable-concurrent-navigation */
|
|
7
5
|
declare function useReactRouterEnableConcurrentNavigation(): void;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { NotUndefined, StateHookTuple } from '../create-storage-hook/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { NotUndefined, UseStorageRawOption, UseStorageParserOption, StateHookTuple, Serializer } from '../create-storage-hook/index.js';
|
|
2
|
+
export { Deserializer } from '../create-storage-hook/index.js';
|
|
8
3
|
|
|
9
4
|
declare const useSessionStorage: {
|
|
10
5
|
<T>(key: string, serverValue: NotUndefined<T>, options?: UseStorageRawOption | UseStorageParserOption<T>): StateHookTuple<T>;
|
|
@@ -12,5 +7,4 @@ declare const useSessionStorage: {
|
|
|
12
7
|
};
|
|
13
8
|
declare const useSetSessionStorage: <T>(key: string, serializer: Serializer<T>) => (v: T | null) => void;
|
|
14
9
|
|
|
15
|
-
export { useSessionStorage, useSetSessionStorage };
|
|
16
|
-
export type { Deserializer, Serializer, UseStorageParserOption as UseSessionStorageParserOption, UseStorageRawOption as UseSessionStorageRawOption };
|
|
10
|
+
export { Serializer, UseStorageParserOption as UseSessionStorageParserOption, UseStorageRawOption as UseSessionStorageRawOption, useSessionStorage, useSetSessionStorage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react"),n=require("../noop/index.cjs"),r=require("../no-ssr/index.cjs");const t=e=>e,a=(()=>{if("undefined"==typeof window)return e=>n.noop;let e=!1;const r=new Set,t=()=>{r.forEach(e=>e())};return n=>(r.add(n),e||(e=!0,window.addEventListener("hashchange",t)),()=>{r.delete(n)})})(),
|
|
1
|
+
"use strict";require("client-only");var e=require("react"),n=require("../noop/index.cjs"),r=require("../no-ssr/index.cjs");const t=e=>e,a=(()=>{if("undefined"==typeof window)return e=>n.noop;let e=!1;const r=new Set,t=()=>{r.forEach(e=>e())};return n=>(r.add(n),e||(e=!0,window.addEventListener("hashchange",t)),()=>{r.delete(n)})})(),l=e=>"function"==typeof e;function o(){throw r.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(n,r){var s;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t,deserializer:t};const u=i.raw?t:i.serializer,c=i.raw?t:i.deserializer,h=void 0===r?o:()=>u(r),d=e.useSyncExternalStore(a,()=>new URLSearchParams(location.hash.slice(1)).get(n),h),w=e.useMemo(()=>null===d?null!=r?r:null:c(d),[r,c,d]),S=e.useCallback(e=>{const t=location.hash,a=new URLSearchParams(t.slice(1)),o=l(e)?e(w):e;o===r||null===o?a.delete(n):a.set(n,u(o));const s=a.toString();t!==s&&(location.hash=s)},[r,w,n,u]);return[null!=(s=null!=w?w:r)?s:null,S]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useSyncExternalStore as e,useMemo as t,useCallback as n}from"react";import{noop as r}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";const a=e=>e,l=(()=>{if("undefined"==typeof window)return e=>r;let e=!1;const t=new Set,n=()=>{t.forEach(e=>e())};return r=>(t.add(r),e||(e=!0,window.addEventListener("hashchange",n)),()=>{t.delete(r)})})(),s=e=>"function"==typeof e;function i(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function u(r,o){var u;let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:a,deserializer:a};const h=c.raw?a:c.serializer,d=c.raw?a:c.deserializer,w=e(l,()=>new URLSearchParams(location.hash.slice(1)).get(r),void 0===o?i:()=>h(o)),f=t(()=>null===w?null!=o?o:null:d(w),[o,d,w]),m=n(e=>{const t=location.hash,n=new URLSearchParams(t.slice(1)),a=s(e)?e(f):e;a===o||null===a?n.delete(r):n.set(r,h(a));const l=n.toString();t!==l&&(location.hash=l)},[o,f,r,h]);return[null
|
|
1
|
+
import"client-only";import{useSyncExternalStore as e,useMemo as t,useCallback as n}from"react";import{noop as r}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";const a=e=>e,l=(()=>{if("undefined"==typeof window)return e=>r;let e=!1;const t=new Set,n=()=>{t.forEach(e=>e())};return r=>(t.add(r),e||(e=!0,window.addEventListener("hashchange",n)),()=>{t.delete(r)})})(),s=e=>"function"==typeof e;function i(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function u(r,o){var u;let c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:a,deserializer:a};const h=c.raw?a:c.serializer,d=c.raw?a:c.deserializer,w=e(l,()=>new URLSearchParams(location.hash.slice(1)).get(r),void 0===o?i:()=>h(o)),f=t(()=>null===w?null!=o?o:null:d(w),[o,d,w]),m=n(e=>{const t=location.hash,n=new URLSearchParams(t.slice(1)),a=s(e)?e(f):e;a===o||null===a?n.delete(r):n.set(r,h(a));const l=n.toString();t!==l&&(location.hash=l)},[o,f,r,h]);return[null!=(u=null!=f?f:o)?u:null,m]}export{u as unstable_useUrlHashState};
|