foxact 0.3.11-beta.1 → 0.3.12
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
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": {
|
|
@@ -52,6 +52,15 @@
|
|
|
52
52
|
"exports": {
|
|
53
53
|
"./package.json": "./package.json",
|
|
54
54
|
"./sizes.json": "./sizes.json",
|
|
55
|
+
"./compose-context-provider": {
|
|
56
|
+
"types": "./compose-context-provider/index.d.ts",
|
|
57
|
+
"import": {
|
|
58
|
+
"types": "./compose-context-provider/index.d.ts",
|
|
59
|
+
"default": "./compose-context-provider/index.mjs"
|
|
60
|
+
},
|
|
61
|
+
"require": "./compose-context-provider/index.cjs",
|
|
62
|
+
"default": "./compose-context-provider/index.cjs"
|
|
63
|
+
},
|
|
55
64
|
"./context-reducer": {
|
|
56
65
|
"types": "./context-reducer/index.d.ts",
|
|
57
66
|
"import": {
|
|
@@ -79,6 +88,24 @@
|
|
|
79
88
|
"require": "./create-breadcrumbs/index.cjs",
|
|
80
89
|
"default": "./create-breadcrumbs/index.cjs"
|
|
81
90
|
},
|
|
91
|
+
"./browser": {
|
|
92
|
+
"types": "./browser/index.d.ts",
|
|
93
|
+
"import": {
|
|
94
|
+
"types": "./browser/index.d.ts",
|
|
95
|
+
"default": "./browser/index.mjs"
|
|
96
|
+
},
|
|
97
|
+
"require": "./browser/index.cjs",
|
|
98
|
+
"default": "./browser/index.cjs"
|
|
99
|
+
},
|
|
100
|
+
"./breadcrumbs": {
|
|
101
|
+
"types": "./breadcrumbs/index.d.ts",
|
|
102
|
+
"import": {
|
|
103
|
+
"types": "./breadcrumbs/index.d.ts",
|
|
104
|
+
"default": "./breadcrumbs/index.mjs"
|
|
105
|
+
},
|
|
106
|
+
"require": "./breadcrumbs/index.cjs",
|
|
107
|
+
"default": "./breadcrumbs/index.cjs"
|
|
108
|
+
},
|
|
82
109
|
"./create-context-reducer": {
|
|
83
110
|
"types": "./create-context-reducer/index.d.ts",
|
|
84
111
|
"import": {
|
|
@@ -124,15 +151,6 @@
|
|
|
124
151
|
"require": "./create-magic-portal/index.cjs",
|
|
125
152
|
"default": "./create-magic-portal/index.cjs"
|
|
126
153
|
},
|
|
127
|
-
"./create-session-storage-state": {
|
|
128
|
-
"types": "./create-session-storage-state/index.d.ts",
|
|
129
|
-
"import": {
|
|
130
|
-
"types": "./create-session-storage-state/index.d.ts",
|
|
131
|
-
"default": "./create-session-storage-state/index.mjs"
|
|
132
|
-
},
|
|
133
|
-
"require": "./create-session-storage-state/index.cjs",
|
|
134
|
-
"default": "./create-session-storage-state/index.cjs"
|
|
135
|
-
},
|
|
136
154
|
"./create-stackless-error": {
|
|
137
155
|
"types": "./create-stackless-error/index.d.ts",
|
|
138
156
|
"import": {
|
|
@@ -151,6 +169,15 @@
|
|
|
151
169
|
"require": "./create-storage-hook/index.cjs",
|
|
152
170
|
"default": "./create-storage-hook/index.cjs"
|
|
153
171
|
},
|
|
172
|
+
"./create-session-storage-state": {
|
|
173
|
+
"types": "./create-session-storage-state/index.d.ts",
|
|
174
|
+
"import": {
|
|
175
|
+
"types": "./create-session-storage-state/index.d.ts",
|
|
176
|
+
"default": "./create-session-storage-state/index.mjs"
|
|
177
|
+
},
|
|
178
|
+
"require": "./create-session-storage-state/index.cjs",
|
|
179
|
+
"default": "./create-session-storage-state/index.cjs"
|
|
180
|
+
},
|
|
154
181
|
"./create-storage-state-factory": {
|
|
155
182
|
"types": "./create-storage-state-factory/index.d.ts",
|
|
156
183
|
"import": {
|
|
@@ -214,15 +241,6 @@
|
|
|
214
241
|
"require": "./is-safari/index.cjs",
|
|
215
242
|
"default": "./is-safari/index.cjs"
|
|
216
243
|
},
|
|
217
|
-
"./magic-portal": {
|
|
218
|
-
"types": "./magic-portal/index.d.ts",
|
|
219
|
-
"import": {
|
|
220
|
-
"types": "./magic-portal/index.d.ts",
|
|
221
|
-
"default": "./magic-portal/index.mjs"
|
|
222
|
-
},
|
|
223
|
-
"require": "./magic-portal/index.cjs",
|
|
224
|
-
"default": "./magic-portal/index.cjs"
|
|
225
|
-
},
|
|
226
244
|
"./merge-props": {
|
|
227
245
|
"types": "./merge-props/index.d.ts",
|
|
228
246
|
"import": {
|
|
@@ -232,6 +250,15 @@
|
|
|
232
250
|
"require": "./merge-props/index.cjs",
|
|
233
251
|
"default": "./merge-props/index.cjs"
|
|
234
252
|
},
|
|
253
|
+
"./magic-portal": {
|
|
254
|
+
"types": "./magic-portal/index.d.ts",
|
|
255
|
+
"import": {
|
|
256
|
+
"types": "./magic-portal/index.d.ts",
|
|
257
|
+
"default": "./magic-portal/index.mjs"
|
|
258
|
+
},
|
|
259
|
+
"require": "./magic-portal/index.cjs",
|
|
260
|
+
"default": "./magic-portal/index.cjs"
|
|
261
|
+
},
|
|
235
262
|
"./merge-refs": {
|
|
236
263
|
"types": "./merge-refs/index.d.ts",
|
|
237
264
|
"import": {
|
|
@@ -394,15 +421,6 @@
|
|
|
394
421
|
"require": "./use-debounced-state/index.cjs",
|
|
395
422
|
"default": "./use-debounced-state/index.cjs"
|
|
396
423
|
},
|
|
397
|
-
"./use-debounced-value": {
|
|
398
|
-
"types": "./use-debounced-value/index.d.ts",
|
|
399
|
-
"import": {
|
|
400
|
-
"types": "./use-debounced-value/index.d.ts",
|
|
401
|
-
"default": "./use-debounced-value/index.mjs"
|
|
402
|
-
},
|
|
403
|
-
"require": "./use-debounced-value/index.cjs",
|
|
404
|
-
"default": "./use-debounced-value/index.cjs"
|
|
405
|
-
},
|
|
406
424
|
"./use-error-boundary": {
|
|
407
425
|
"types": "./use-error-boundary/index.d.ts",
|
|
408
426
|
"import": {
|
|
@@ -412,14 +430,14 @@
|
|
|
412
430
|
"require": "./use-error-boundary/index.cjs",
|
|
413
431
|
"default": "./use-error-boundary/index.cjs"
|
|
414
432
|
},
|
|
415
|
-
"./use-
|
|
416
|
-
"types": "./use-
|
|
433
|
+
"./use-debounced-value": {
|
|
434
|
+
"types": "./use-debounced-value/index.d.ts",
|
|
417
435
|
"import": {
|
|
418
|
-
"types": "./use-
|
|
419
|
-
"default": "./use-
|
|
436
|
+
"types": "./use-debounced-value/index.d.ts",
|
|
437
|
+
"default": "./use-debounced-value/index.mjs"
|
|
420
438
|
},
|
|
421
|
-
"require": "./use-
|
|
422
|
-
"default": "./use-
|
|
439
|
+
"require": "./use-debounced-value/index.cjs",
|
|
440
|
+
"default": "./use-debounced-value/index.cjs"
|
|
423
441
|
},
|
|
424
442
|
"./use-intersection": {
|
|
425
443
|
"types": "./use-intersection/index.d.ts",
|
|
@@ -430,6 +448,15 @@
|
|
|
430
448
|
"require": "./use-intersection/index.cjs",
|
|
431
449
|
"default": "./use-intersection/index.cjs"
|
|
432
450
|
},
|
|
451
|
+
"./use-fast-click": {
|
|
452
|
+
"types": "./use-fast-click/index.d.ts",
|
|
453
|
+
"import": {
|
|
454
|
+
"types": "./use-fast-click/index.d.ts",
|
|
455
|
+
"default": "./use-fast-click/index.mjs"
|
|
456
|
+
},
|
|
457
|
+
"require": "./use-fast-click/index.cjs",
|
|
458
|
+
"default": "./use-fast-click/index.cjs"
|
|
459
|
+
},
|
|
433
460
|
"./use-is-client": {
|
|
434
461
|
"types": "./use-is-client/index.d.ts",
|
|
435
462
|
"import": {
|
|
@@ -457,24 +484,6 @@
|
|
|
457
484
|
"require": "./use-isomorphic-layout-effect/index.cjs",
|
|
458
485
|
"default": "./use-isomorphic-layout-effect/index.cjs"
|
|
459
486
|
},
|
|
460
|
-
"./use-local-storage": {
|
|
461
|
-
"types": "./use-local-storage/index.d.ts",
|
|
462
|
-
"import": {
|
|
463
|
-
"types": "./use-local-storage/index.d.ts",
|
|
464
|
-
"default": "./use-local-storage/index.mjs"
|
|
465
|
-
},
|
|
466
|
-
"require": "./use-local-storage/index.cjs",
|
|
467
|
-
"default": "./use-local-storage/index.cjs"
|
|
468
|
-
},
|
|
469
|
-
"./use-map": {
|
|
470
|
-
"types": "./use-map/index.d.ts",
|
|
471
|
-
"import": {
|
|
472
|
-
"types": "./use-map/index.d.ts",
|
|
473
|
-
"default": "./use-map/index.mjs"
|
|
474
|
-
},
|
|
475
|
-
"require": "./use-map/index.cjs",
|
|
476
|
-
"default": "./use-map/index.cjs"
|
|
477
|
-
},
|
|
478
487
|
"./use-media-query": {
|
|
479
488
|
"types": "./use-media-query/index.d.ts",
|
|
480
489
|
"import": {
|
|
@@ -511,15 +520,6 @@
|
|
|
511
520
|
"require": "./use-resizing/index.cjs",
|
|
512
521
|
"default": "./use-resizing/index.cjs"
|
|
513
522
|
},
|
|
514
|
-
"./use-retimer": {
|
|
515
|
-
"types": "./use-retimer/index.d.ts",
|
|
516
|
-
"import": {
|
|
517
|
-
"types": "./use-retimer/index.d.ts",
|
|
518
|
-
"default": "./use-retimer/index.mjs"
|
|
519
|
-
},
|
|
520
|
-
"require": "./use-retimer/index.cjs",
|
|
521
|
-
"default": "./use-retimer/index.cjs"
|
|
522
|
-
},
|
|
523
523
|
"./use-session-storage": {
|
|
524
524
|
"types": "./use-session-storage/index.d.ts",
|
|
525
525
|
"import": {
|
|
@@ -529,6 +529,24 @@
|
|
|
529
529
|
"require": "./use-session-storage/index.cjs",
|
|
530
530
|
"default": "./use-session-storage/index.cjs"
|
|
531
531
|
},
|
|
532
|
+
"./use-local-storage": {
|
|
533
|
+
"types": "./use-local-storage/index.d.ts",
|
|
534
|
+
"import": {
|
|
535
|
+
"types": "./use-local-storage/index.d.ts",
|
|
536
|
+
"default": "./use-local-storage/index.mjs"
|
|
537
|
+
},
|
|
538
|
+
"require": "./use-local-storage/index.cjs",
|
|
539
|
+
"default": "./use-local-storage/index.cjs"
|
|
540
|
+
},
|
|
541
|
+
"./use-retimer": {
|
|
542
|
+
"types": "./use-retimer/index.d.ts",
|
|
543
|
+
"import": {
|
|
544
|
+
"types": "./use-retimer/index.d.ts",
|
|
545
|
+
"default": "./use-retimer/index.mjs"
|
|
546
|
+
},
|
|
547
|
+
"require": "./use-retimer/index.cjs",
|
|
548
|
+
"default": "./use-retimer/index.cjs"
|
|
549
|
+
},
|
|
532
550
|
"./use-set": {
|
|
533
551
|
"types": "./use-set/index.d.ts",
|
|
534
552
|
"import": {
|
|
@@ -538,15 +556,6 @@
|
|
|
538
556
|
"require": "./use-set/index.cjs",
|
|
539
557
|
"default": "./use-set/index.cjs"
|
|
540
558
|
},
|
|
541
|
-
"./use-singleton": {
|
|
542
|
-
"types": "./use-singleton/index.d.ts",
|
|
543
|
-
"import": {
|
|
544
|
-
"types": "./use-singleton/index.d.ts",
|
|
545
|
-
"default": "./use-singleton/index.mjs"
|
|
546
|
-
},
|
|
547
|
-
"require": "./use-singleton/index.cjs",
|
|
548
|
-
"default": "./use-singleton/index.cjs"
|
|
549
|
-
},
|
|
550
559
|
"./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired": {
|
|
551
560
|
"types": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.d.ts",
|
|
552
561
|
"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-singleton": {
|
|
569
|
+
"types": "./use-singleton/index.d.ts",
|
|
570
|
+
"import": {
|
|
571
|
+
"types": "./use-singleton/index.d.ts",
|
|
572
|
+
"default": "./use-singleton/index.mjs"
|
|
573
|
+
},
|
|
574
|
+
"require": "./use-singleton/index.cjs",
|
|
575
|
+
"default": "./use-singleton/index.cjs"
|
|
576
|
+
},
|
|
559
577
|
"./use-state-with-deps": {
|
|
560
578
|
"types": "./use-state-with-deps/index.d.ts",
|
|
561
579
|
"import": {
|
|
@@ -574,15 +592,6 @@
|
|
|
574
592
|
"require": "./use-typescript-happy-callback/index.cjs",
|
|
575
593
|
"default": "./use-typescript-happy-callback/index.cjs"
|
|
576
594
|
},
|
|
577
|
-
"./use-uncontrolled": {
|
|
578
|
-
"types": "./use-uncontrolled/index.d.ts",
|
|
579
|
-
"import": {
|
|
580
|
-
"types": "./use-uncontrolled/index.d.ts",
|
|
581
|
-
"default": "./use-uncontrolled/index.mjs"
|
|
582
|
-
},
|
|
583
|
-
"require": "./use-uncontrolled/index.cjs",
|
|
584
|
-
"default": "./use-uncontrolled/index.cjs"
|
|
585
|
-
},
|
|
586
595
|
"./use-url-hash-state": {
|
|
587
596
|
"types": "./use-url-hash-state/index.d.ts",
|
|
588
597
|
"import": {
|
|
@@ -592,32 +601,23 @@
|
|
|
592
601
|
"require": "./use-url-hash-state/index.cjs",
|
|
593
602
|
"default": "./use-url-hash-state/index.cjs"
|
|
594
603
|
},
|
|
595
|
-
"./
|
|
596
|
-
"types": "./
|
|
597
|
-
"import": {
|
|
598
|
-
"types": "./breadcrumbs/index.d.ts",
|
|
599
|
-
"default": "./breadcrumbs/index.mjs"
|
|
600
|
-
},
|
|
601
|
-
"require": "./breadcrumbs/index.cjs",
|
|
602
|
-
"default": "./breadcrumbs/index.cjs"
|
|
603
|
-
},
|
|
604
|
-
"./compose-context-provider": {
|
|
605
|
-
"types": "./compose-context-provider/index.d.ts",
|
|
604
|
+
"./use-uncontrolled": {
|
|
605
|
+
"types": "./use-uncontrolled/index.d.ts",
|
|
606
606
|
"import": {
|
|
607
|
-
"types": "./
|
|
608
|
-
"default": "./
|
|
607
|
+
"types": "./use-uncontrolled/index.d.ts",
|
|
608
|
+
"default": "./use-uncontrolled/index.mjs"
|
|
609
609
|
},
|
|
610
|
-
"require": "./
|
|
611
|
-
"default": "./
|
|
610
|
+
"require": "./use-uncontrolled/index.cjs",
|
|
611
|
+
"default": "./use-uncontrolled/index.cjs"
|
|
612
612
|
},
|
|
613
|
-
"./
|
|
614
|
-
"types": "./
|
|
613
|
+
"./use-map": {
|
|
614
|
+
"types": "./use-map/index.d.ts",
|
|
615
615
|
"import": {
|
|
616
|
-
"types": "./
|
|
617
|
-
"default": "./
|
|
616
|
+
"types": "./use-map/index.d.ts",
|
|
617
|
+
"default": "./use-map/index.mjs"
|
|
618
618
|
},
|
|
619
|
-
"require": "./
|
|
620
|
-
"default": "./
|
|
619
|
+
"require": "./use-map/index.cjs",
|
|
620
|
+
"default": "./use-map/index.cjs"
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
}
|
package/sizes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"total":{"raw":
|
|
1
|
+
{"total":{"raw":30280,"gzip":18325,"br":15436,"zstd":18372},"exports":{"context-state":{"raw":402,"gzip":259,"br":218,"zstd":259},"context-reducer":{"raw":557,"gzip":332,"br":319,"zstd":336},"create-breadcrumbs":{"raw":56,"gzip":68,"br":52,"zstd":65},"browser":{"raw":686,"gzip":402,"br":333,"zstd":413},"compose-context-provider":{"raw":177,"gzip":155,"br":122,"zstd":144},"create-context-state":{"raw":59,"gzip":72,"br":59,"zstd":68},"create-fixed-array":{"raw":452,"gzip":282,"br":248,"zstd":282},"create-local-storage-state":{"raw":169,"gzip":138,"br":111,"zstd":130},"create-context-reducer":{"raw":63,"gzip":74,"br":64,"zstd":72},"create-magic-portal":{"raw":57,"gzip":71,"br":53,"zstd":66},"breadcrumbs":{"raw":879,"gzip":467,"br":395,"zstd":472},"create-stackless-error":{"raw":278,"gzip":198,"br":162,"zstd":188},"current-year":{"raw":508,"gzip":348,"br":283,"zstd":349},"create-session-storage-state":{"raw":173,"gzip":138,"br":108,"zstd":129},"create-storage-hook":{"raw":2418,"gzip":957,"br":835,"zstd":1000},"get-single-react-children":{"raw":68,"gzip":80,"br":70,"zstd":77},"create-storage-state-factory":{"raw":364,"gzip":248,"br":197,"zstd":243},"fetch-jsonp":{"raw":924,"gzip":570,"br":446,"zstd":576},"invariant":{"raw":178,"gzip":156,"br":118,"zstd":149},"merge-props":{"raw":1030,"gzip":559,"br":501,"zstd":577},"is-safari":{"raw":247,"gzip":175,"br":133,"zstd":169},"no-ssr":{"raw":381,"gzip":281,"br":236,"zstd":285},"merge-refs":{"raw":525,"gzip":280,"br":235,"zstd":278},"noop":{"raw":33,"gzip":53,"br":37,"zstd":42},"noop-component":{"raw":142,"gzip":130,"br":111,"zstd":119},"magic-portal":{"raw":1013,"gzip":517,"br":445,"zstd":526},"nullthrow":{"raw":187,"gzip":163,"br":121,"zstd":156},"open-new-tab":{"raw":335,"gzip":255,"br":187,"zstd":255},"polymorphic":{"raw":284,"gzip":212,"br":180,"zstd":199},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80,"zstd":91},"request-idle-callback":{"raw":392,"gzip":221,"br":171,"zstd":213},"rem":{"raw":823,"gzip":395,"br":350,"zstd":402},"use":{"raw":301,"gzip":200,"br":177,"zstd":193},"get-react-children":{"raw":568,"gzip":354,"br":284,"zstd":355},"use-abortable-effect":{"raw":215,"gzip":170,"br":144,"zstd":166},"use-array":{"raw":334,"gzip":243,"br":206,"zstd":236},"use-composition-input":{"raw":470,"gzip":286,"br":241,"zstd":296},"use-debounced-state":{"raw":401,"gzip":282,"br":244,"zstd":288},"use-component-will-receive-update":{"raw":220,"gzip":190,"br":157,"zstd":179},"use-error-boundary":{"raw":252,"gzip":195,"br":165,"zstd":187},"use-debounced-value":{"raw":553,"gzip":358,"br":320,"zstd":360},"use-clipboard":{"raw":2718,"gzip":1332,"br":1139,"zstd":1396},"use-intersection":{"raw":1363,"gzip":716,"br":654,"zstd":750},"types":{"raw":0,"gzip":20,"br":1,"zstd":9},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110,"zstd":127},"use-is-online":{"raw":288,"gzip":216,"br":196,"zstd":205},"use-is-client":{"raw":184,"gzip":158,"br":130,"zstd":149},"use-page-visibility":{"raw":283,"gzip":211,"br":162,"zstd":203},"use-media-query":{"raw":483,"gzip":322,"br":256,"zstd":325},"use-resizing":{"raw":511,"gzip":334,"br":294,"zstd":342},"use-session-storage":{"raw":198,"gzip":141,"br":118,"zstd":137},"use-retimer":{"raw":194,"gzip":166,"br":127,"zstd":154},"use-local-storage":{"raw":192,"gzip":143,"br":114,"zstd":137},"use-set":{"raw":368,"gzip":247,"br":211,"zstd":255},"use-singleton":{"raw":149,"gzip":135,"br":116,"zstd":123},"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-readonly-search-params":{"raw":2318,"gzip":1058,"br":914,"zstd":1092},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77,"zstd":94},"use-state-with-deps":{"raw":747,"gzip":479,"br":418,"zstd":488},"use-fast-click":{"raw":499,"gzip":350,"br":284,"zstd":355},"use-uncontrolled":{"raw":388,"gzip":273,"br":230,"zstd":277},"use-map":{"raw":384,"gzip":256,"br":220,"zstd":262},"use-url-hash-state":{"raw":1001,"gzip":572,"br":495,"zstd":582}}}
|
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.
|
|
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.ariaHidden="true",d.style.all="unset",d.style.whiteSpace="pre",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(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.
|
|
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.ariaHidden="true",d.style.all="unset",d.style.whiteSpace="pre",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,2 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
"use strict";var e=require("react/jsx-runtime"),r=require("event-target-bus/react"),t=require("../no-ssr/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}}const s=r.createSyncExternalStoreSubscribe(()=>window,"popstate"),c=n.createContext({hasProvider:!1,subscribe:s});let u=0,i=null,l=null;function h(){return"u"<typeof window?new o:null!==l&&window.location.search===i?l:l=new o(i=window.location.search)}function d(){throw t.noSSRError('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}exports.ReadonlySearchParamsProvider=function(r){let{children:t}=r;const a=n.useContext(c),o=n.useMemo(()=>(function(){const e=new Set;return{contextValue:{hasProvider:!0,subscribe:r=>{const t=s(r);return e.add(r),()=>{t(),e.delete(r)}}},notify:()=>e.forEach(e=>e())}})(),[]);return n.useEffect(()=>{if(a.hasProvider)return;if("production"!==process.env.NODE_ENV&&u>0)throw Error("[foxact/use-readonly-search-params] Multiple non-nested ReadonlySearchParamsProvider instances are mounted. Use a single top-level provider or nest them.");const e=function(e){const r=window.history,t=r.pushState,n=r.replaceState,a=function(){for(var r=arguments.length,n=Array(r),a=0;a<r;a++)n[a]=arguments[a];t.apply(this,n),e()},o=function(){for(var r=arguments.length,t=Array(r),a=0;a<r;a++)t[a]=arguments[a];n.apply(this,t),e()};return r.pushState=a,r.replaceState=o,()=>{r.pushState===a&&(r.pushState=t),r.replaceState===o&&(r.replaceState=n)}}(o.notify);return"production"!==process.env.NODE_ENV&&(u+=1),()=>{e(),"production"!==process.env.NODE_ENV&&(u-=1)}},[o,a.hasProvider]),e.jsx(c.Provider,{value:a.hasProvider?a:o.contextValue,children:t})},exports.ReadonlyURLSearchParams=o,exports.useReadonlySearchParams=function(e){const{subscribe:r}=n.useContext(c);return n.useSyncExternalStore(r,h,null==e?d:()=>{const r=e();return r instanceof o?r:new o(r)})};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import{jsx as e}from"react/jsx-runtime";import{createSyncExternalStoreSubscribe as r}from"event-target-bus/react";import{noSSRError as t}from"../no-ssr/index.mjs";import{useContext as n,useMemo as a,useEffect as o,useSyncExternalStore as s,createContext as c}from"react";class i 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 u extends URLSearchParams{append(){throw new i}delete(){throw new i}set(){throw new i}sort(){throw new i}}const l=r(()=>window,"popstate"),h=c({hasProvider:!1,subscribe:l});let d=0;function p(r){let{children:t}=r;const s=n(h),c=a(()=>(function(){const e=new Set;return{contextValue:{hasProvider:!0,subscribe:r=>{const t=l(r);return e.add(r),()=>{t(),e.delete(r)}}},notify:()=>e.forEach(e=>e())}})(),[]);return o(()=>{if(s.hasProvider)return;if("production"!==process.env.NODE_ENV&&d>0)throw Error("[foxact/use-readonly-search-params] Multiple non-nested ReadonlySearchParamsProvider instances are mounted. Use a single top-level provider or nest them.");const e=function(e){const r=window.history,t=r.pushState,n=r.replaceState,a=function(){for(var r=arguments.length,n=Array(r),a=0;a<r;a++)n[a]=arguments[a];t.apply(this,n),e()},o=function(){for(var r=arguments.length,t=Array(r),a=0;a<r;a++)t[a]=arguments[a];n.apply(this,t),e()};return r.pushState=a,r.replaceState=o,()=>{r.pushState===a&&(r.pushState=t),r.replaceState===o&&(r.replaceState=n)}}(c.notify);return"production"!==process.env.NODE_ENV&&(d+=1),()=>{e(),"production"!==process.env.NODE_ENV&&(d-=1)}},[c,s.hasProvider]),e(h.Provider,{value:s.hasProvider?s:c.contextValue,children:t})}let f=null,w=null;function m(){return"u"<typeof window?new u:null!==w&&window.location.search===f?w:w=new u(f=window.location.search)}function v(){throw t('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}function y(e){const{subscribe:r}=n(h);return s(r,m,null==e?v:()=>{const r=e();return r instanceof u?r:new u(r)})}export{p as ReadonlySearchParamsProvider,u as ReadonlyURLSearchParams,y as useReadonlySearchParams};
|