foxact 0.3.10 → 0.3.11-beta.1

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.10",
3
+ "version": "0.3.11-beta.1",
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,33 +52,6 @@
52
52
  "exports": {
53
53
  "./package.json": "./package.json",
54
54
  "./sizes.json": "./sizes.json",
55
- "./breadcrumbs": {
56
- "types": "./breadcrumbs/index.d.ts",
57
- "import": {
58
- "types": "./breadcrumbs/index.d.ts",
59
- "default": "./breadcrumbs/index.mjs"
60
- },
61
- "require": "./breadcrumbs/index.cjs",
62
- "default": "./breadcrumbs/index.cjs"
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
55
  "./context-reducer": {
83
56
  "types": "./context-reducer/index.d.ts",
84
57
  "import": {
@@ -88,14 +61,14 @@
88
61
  "require": "./context-reducer/index.cjs",
89
62
  "default": "./context-reducer/index.cjs"
90
63
  },
91
- "./compose-context-provider": {
92
- "types": "./compose-context-provider/index.d.ts",
64
+ "./context-state": {
65
+ "types": "./context-state/index.d.ts",
93
66
  "import": {
94
- "types": "./compose-context-provider/index.d.ts",
95
- "default": "./compose-context-provider/index.mjs"
67
+ "types": "./context-state/index.d.ts",
68
+ "default": "./context-state/index.mjs"
96
69
  },
97
- "require": "./compose-context-provider/index.cjs",
98
- "default": "./compose-context-provider/index.cjs"
70
+ "require": "./context-state/index.cjs",
71
+ "default": "./context-state/index.cjs"
99
72
  },
100
73
  "./create-breadcrumbs": {
101
74
  "types": "./create-breadcrumbs/index.d.ts",
@@ -142,6 +115,24 @@
142
115
  "require": "./create-local-storage-state/index.cjs",
143
116
  "default": "./create-local-storage-state/index.cjs"
144
117
  },
118
+ "./create-magic-portal": {
119
+ "types": "./create-magic-portal/index.d.ts",
120
+ "import": {
121
+ "types": "./create-magic-portal/index.d.ts",
122
+ "default": "./create-magic-portal/index.mjs"
123
+ },
124
+ "require": "./create-magic-portal/index.cjs",
125
+ "default": "./create-magic-portal/index.cjs"
126
+ },
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
+ },
145
136
  "./create-stackless-error": {
146
137
  "types": "./create-stackless-error/index.d.ts",
147
138
  "import": {
@@ -178,15 +169,6 @@
178
169
  "require": "./current-year/index.cjs",
179
170
  "default": "./current-year/index.cjs"
180
171
  },
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
172
  "./fetch-jsonp": {
191
173
  "types": "./fetch-jsonp/index.d.ts",
192
174
  "import": {
@@ -214,6 +196,15 @@
214
196
  "require": "./get-single-react-children/index.cjs",
215
197
  "default": "./get-single-react-children/index.cjs"
216
198
  },
199
+ "./invariant": {
200
+ "types": "./invariant/index.d.ts",
201
+ "import": {
202
+ "types": "./invariant/index.d.ts",
203
+ "default": "./invariant/index.mjs"
204
+ },
205
+ "require": "./invariant/index.cjs",
206
+ "default": "./invariant/index.cjs"
207
+ },
217
208
  "./is-safari": {
218
209
  "types": "./is-safari/index.d.ts",
219
210
  "import": {
@@ -232,15 +223,6 @@
232
223
  "require": "./magic-portal/index.cjs",
233
224
  "default": "./magic-portal/index.cjs"
234
225
  },
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
- },
244
226
  "./merge-props": {
245
227
  "types": "./merge-props/index.d.ts",
246
228
  "import": {
@@ -340,15 +322,6 @@
340
322
  "require": "./types/index.cjs",
341
323
  "default": "./types/index.cjs"
342
324
  },
343
- "./use": {
344
- "types": "./use/index.d.ts",
345
- "import": {
346
- "types": "./use/index.d.ts",
347
- "default": "./use/index.mjs"
348
- },
349
- "require": "./use/index.cjs",
350
- "default": "./use/index.cjs"
351
- },
352
325
  "./typescript-happy-forward-ref": {
353
326
  "types": "./typescript-happy-forward-ref/index.d.ts",
354
327
  "import": {
@@ -358,6 +331,15 @@
358
331
  "require": "./typescript-happy-forward-ref/index.cjs",
359
332
  "default": "./typescript-happy-forward-ref/index.cjs"
360
333
  },
334
+ "./use": {
335
+ "types": "./use/index.d.ts",
336
+ "import": {
337
+ "types": "./use/index.d.ts",
338
+ "default": "./use/index.mjs"
339
+ },
340
+ "require": "./use/index.cjs",
341
+ "default": "./use/index.cjs"
342
+ },
361
343
  "./use-abortable-effect": {
362
344
  "types": "./use-abortable-effect/index.d.ts",
363
345
  "import": {
@@ -430,15 +412,6 @@
430
412
  "require": "./use-error-boundary/index.cjs",
431
413
  "default": "./use-error-boundary/index.cjs"
432
414
  },
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
415
  "./use-fast-click": {
443
416
  "types": "./use-fast-click/index.d.ts",
444
417
  "import": {
@@ -448,6 +421,15 @@
448
421
  "require": "./use-fast-click/index.cjs",
449
422
  "default": "./use-fast-click/index.cjs"
450
423
  },
424
+ "./use-intersection": {
425
+ "types": "./use-intersection/index.d.ts",
426
+ "import": {
427
+ "types": "./use-intersection/index.d.ts",
428
+ "default": "./use-intersection/index.mjs"
429
+ },
430
+ "require": "./use-intersection/index.cjs",
431
+ "default": "./use-intersection/index.cjs"
432
+ },
451
433
  "./use-is-client": {
452
434
  "types": "./use-is-client/index.d.ts",
453
435
  "import": {
@@ -547,6 +529,15 @@
547
529
  "require": "./use-session-storage/index.cjs",
548
530
  "default": "./use-session-storage/index.cjs"
549
531
  },
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
+ },
550
541
  "./use-singleton": {
551
542
  "types": "./use-singleton/index.d.ts",
552
543
  "import": {
@@ -565,15 +556,6 @@
565
556
  "require": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs",
566
557
  "default": "./use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired/index.cjs"
567
558
  },
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
- },
577
559
  "./use-state-with-deps": {
578
560
  "types": "./use-state-with-deps/index.d.ts",
579
561
  "import": {
@@ -610,14 +592,32 @@
610
592
  "require": "./use-url-hash-state/index.cjs",
611
593
  "default": "./use-url-hash-state/index.cjs"
612
594
  },
613
- "./create-magic-portal": {
614
- "types": "./create-magic-portal/index.d.ts",
595
+ "./breadcrumbs": {
596
+ "types": "./breadcrumbs/index.d.ts",
615
597
  "import": {
616
- "types": "./create-magic-portal/index.d.ts",
617
- "default": "./create-magic-portal/index.mjs"
598
+ "types": "./breadcrumbs/index.d.ts",
599
+ "default": "./breadcrumbs/index.mjs"
618
600
  },
619
- "require": "./create-magic-portal/index.cjs",
620
- "default": "./create-magic-portal/index.cjs"
601
+ "require": "./breadcrumbs/index.cjs",
602
+ "default": "./breadcrumbs/index.cjs"
603
+ },
604
+ "./compose-context-provider": {
605
+ "types": "./compose-context-provider/index.d.ts",
606
+ "import": {
607
+ "types": "./compose-context-provider/index.d.ts",
608
+ "default": "./compose-context-provider/index.mjs"
609
+ },
610
+ "require": "./compose-context-provider/index.cjs",
611
+ "default": "./compose-context-provider/index.cjs"
612
+ },
613
+ "./browser": {
614
+ "types": "./browser/index.d.ts",
615
+ "import": {
616
+ "types": "./browser/index.d.ts",
617
+ "default": "./browser/index.mjs"
618
+ },
619
+ "require": "./browser/index.cjs",
620
+ "default": "./browser/index.cjs"
621
621
  }
622
622
  }
623
623
  }
package/sizes.json CHANGED
@@ -1 +1 @@
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}}}
1
+ {"total":{"raw":30266,"gzip":18315,"br":15425,"zstd":18362},"exports":{"create-context-state":{"raw":59,"gzip":72,"br":59,"zstd":68},"create-breadcrumbs":{"raw":56,"gzip":68,"br":52,"zstd":65},"create-context-reducer":{"raw":63,"gzip":74,"br":64,"zstd":72},"create-magic-portal":{"raw":57,"gzip":71,"br":53,"zstd":66},"create-fixed-array":{"raw":452,"gzip":282,"br":248,"zstd":282},"create-local-storage-state":{"raw":169,"gzip":138,"br":111,"zstd":130},"create-stackless-error":{"raw":278,"gzip":198,"br":162,"zstd":188},"create-session-storage-state":{"raw":173,"gzip":138,"br":108,"zstd":129},"context-state":{"raw":402,"gzip":259,"br":218,"zstd":259},"create-storage-state-factory":{"raw":364,"gzip":248,"br":197,"zstd":243},"fetch-jsonp":{"raw":924,"gzip":570,"br":446,"zstd":576},"create-storage-hook":{"raw":2418,"gzip":957,"br":835,"zstd":1000},"current-year":{"raw":508,"gzip":348,"br":283,"zstd":349},"context-reducer":{"raw":557,"gzip":332,"br":319,"zstd":336},"get-single-react-children":{"raw":68,"gzip":80,"br":70,"zstd":77},"is-safari":{"raw":247,"gzip":175,"br":133,"zstd":169},"invariant":{"raw":178,"gzip":156,"br":118,"zstd":149},"magic-portal":{"raw":1013,"gzip":517,"br":445,"zstd":526},"no-ssr":{"raw":381,"gzip":281,"br":236,"zstd":285},"merge-props":{"raw":1030,"gzip":559,"br":501,"zstd":577},"noop":{"raw":33,"gzip":53,"br":37,"zstd":42},"merge-refs":{"raw":525,"gzip":280,"br":235,"zstd":278},"noop-component":{"raw":142,"gzip":130,"br":111,"zstd":119},"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},"request-idle-callback":{"raw":392,"gzip":221,"br":171,"zstd":213},"types":{"raw":0,"gzip":20,"br":1,"zstd":9},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80,"zstd":91},"rem":{"raw":823,"gzip":395,"br":350,"zstd":402},"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-value":{"raw":553,"gzip":358,"br":320,"zstd":360},"use-error-boundary":{"raw":252,"gzip":195,"br":165,"zstd":187},"use-component-will-receive-update":{"raw":220,"gzip":190,"br":157,"zstd":179},"use-fast-click":{"raw":499,"gzip":350,"br":284,"zstd":355},"use-is-client":{"raw":184,"gzip":158,"br":130,"zstd":149},"use-is-online":{"raw":288,"gzip":216,"br":196,"zstd":205},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110,"zstd":127},"use-clipboard":{"raw":2718,"gzip":1333,"br":1141,"zstd":1398},"use-intersection":{"raw":1363,"gzip":716,"br":654,"zstd":750},"use-local-storage":{"raw":192,"gzip":143,"br":114,"zstd":137},"use-map":{"raw":384,"gzip":256,"br":220,"zstd":262},"use-page-visibility":{"raw":283,"gzip":211,"br":162,"zstd":203},"use-debounced-state":{"raw":401,"gzip":282,"br":244,"zstd":288},"use-resizing":{"raw":511,"gzip":334,"br":294,"zstd":342},"use-media-query":{"raw":483,"gzip":322,"br":256,"zstd":325},"use-session-storage":{"raw":198,"gzip":141,"br":118,"zstd":137},"use-set":{"raw":368,"gzip":247,"br":211,"zstd":255},"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-typescript-happy-callback":{"raw":107,"gzip":102,"br":77,"zstd":94},"use-retimer":{"raw":194,"gzip":166,"br":127,"zstd":154},"use-readonly-search-params":{"raw":2304,"gzip":1047,"br":901,"zstd":1080},"use-state-with-deps":{"raw":747,"gzip":479,"br":418,"zstd":488},"use-uncontrolled":{"raw":388,"gzip":273,"br":230,"zstd":277},"compose-context-provider":{"raw":177,"gzip":155,"br":122,"zstd":144},"use-singleton":{"raw":149,"gzip":135,"br":116,"zstd":123},"use":{"raw":301,"gzip":200,"br":177,"zstd":193},"use-url-hash-state":{"raw":1001,"gzip":572,"br":495,"zstd":582},"breadcrumbs":{"raw":879,"gzip":467,"br":395,"zstd":472},"browser":{"raw":686,"gzip":402,"br":333,"zstd":413}}}
@@ -1 +1 @@
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
+ "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)})};
@@ -8,7 +8,14 @@ declare class ReadonlyURLSearchParams extends URLSearchParams {
8
8
  /** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://foxact.skk.moe/use-readonly-search-params */
9
9
  sort(): never;
10
10
  }
11
+ /**
12
+ * Opts descendant `useReadonlySearchParams` hooks into updates made through
13
+ * `history.pushState` and `history.replaceState`.
14
+ *
15
+ * @see https://foxact.skk.moe/use-readonly-search-params
16
+ */
17
+ declare function ReadonlySearchParamsProvider({ children }: React.PropsWithChildren): React.ReactNode;
11
18
  /** @see https://foxact.skk.moe/use-readonly-search-params */
12
19
  declare function useReadonlySearchParams(getServerDefaultValue?: () => URLSearchParams | ReadonlyURLSearchParams): ReadonlyURLSearchParams;
13
20
 
14
- export { ReadonlyURLSearchParams, useReadonlySearchParams };
21
+ export { ReadonlySearchParamsProvider, ReadonlyURLSearchParams, useReadonlySearchParams };
@@ -1 +1 @@
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};
1
+ 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};