@hadoku/watchparty-ui 0.45.107 → 0.45.109

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/dist/index.d.ts CHANGED
@@ -1,1256 +1,5 @@
1
1
  import { Root } from 'react-dom/client';
2
2
 
3
- /**
4
- * An augmentable interface users can modify in their app-code to opt into
5
- * future-flag-specific types
6
- */
7
- interface Future {
8
- }
9
- type MiddlewareEnabled = Future extends {
10
- v8_middleware: infer T extends boolean;
11
- } ? T : false;
12
-
13
- /**
14
- * Actions represent the type of change to a location value.
15
- */
16
- declare enum Action {
17
- /**
18
- * A POP indicates a change to an arbitrary index in the history stack, such
19
- * as a back or forward navigation. It does not describe the direction of the
20
- * navigation, only that the current index changed.
21
- *
22
- * Note: This is the default action for newly created history objects.
23
- */
24
- Pop = "POP",
25
- /**
26
- * A PUSH indicates a new entry being added to the history stack, such as when
27
- * a link is clicked and a new page loads. When this happens, all subsequent
28
- * entries in the stack are lost.
29
- */
30
- Push = "PUSH",
31
- /**
32
- * A REPLACE indicates the entry at the current index in the history stack
33
- * being replaced by a new one.
34
- */
35
- Replace = "REPLACE"
36
- }
37
- /**
38
- * The pathname, search, and hash values of a URL.
39
- */
40
- interface Path {
41
- /**
42
- * A URL pathname, beginning with a /.
43
- */
44
- pathname: string;
45
- /**
46
- * A URL search string, beginning with a ?.
47
- */
48
- search: string;
49
- /**
50
- * A URL fragment identifier, beginning with a #.
51
- */
52
- hash: string;
53
- }
54
- /**
55
- * An entry in a history stack. A location contains information about the
56
- * URL path, as well as possibly some arbitrary state and a key.
57
- */
58
- interface Location<State = any> extends Path {
59
- /**
60
- * A value of arbitrary data associated with this location.
61
- */
62
- state: State;
63
- /**
64
- * A unique string associated with this location. May be used to safely store
65
- * and retrieve data in some other storage API, like `localStorage`.
66
- *
67
- * Note: This value is always "default" on the initial location.
68
- */
69
- key: string;
70
- }
71
- /**
72
- * A change to the current location.
73
- */
74
- interface Update {
75
- /**
76
- * The action that triggered the change.
77
- */
78
- action: Action;
79
- /**
80
- * The new location.
81
- */
82
- location: Location;
83
- /**
84
- * The delta between this location and the former location in the history stack
85
- */
86
- delta: number | null;
87
- }
88
- /**
89
- * A function that receives notifications about location changes.
90
- */
91
- interface Listener {
92
- (update: Update): void;
93
- }
94
- /**
95
- * Describes a location that is the destination of some navigation used in
96
- * {@link Link}, {@link useNavigate}, etc.
97
- */
98
- type To = string | Partial<Path>;
99
- /**
100
- * A history is an interface to the navigation stack. The history serves as the
101
- * source of truth for the current location, as well as provides a set of
102
- * methods that may be used to change it.
103
- *
104
- * It is similar to the DOM's `window.history` object, but with a smaller, more
105
- * focused API.
106
- */
107
- interface History {
108
- /**
109
- * The last action that modified the current location. This will always be
110
- * Action.Pop when a history instance is first created. This value is mutable.
111
- */
112
- readonly action: Action;
113
- /**
114
- * The current location. This value is mutable.
115
- */
116
- readonly location: Location;
117
- /**
118
- * Returns a valid href for the given `to` value that may be used as
119
- * the value of an <a href> attribute.
120
- *
121
- * @param to - The destination URL
122
- */
123
- createHref(to: To): string;
124
- /**
125
- * Returns a URL for the given `to` value
126
- *
127
- * @param to - The destination URL
128
- */
129
- createURL(to: To): URL;
130
- /**
131
- * Encode a location the same way window.history would do (no-op for memory
132
- * history) so we ensure our PUSH/REPLACE navigations for data routers
133
- * behave the same as POP
134
- *
135
- * @param to Unencoded path
136
- */
137
- encodeLocation(to: To): Path;
138
- /**
139
- * Pushes a new location onto the history stack, increasing its length by one.
140
- * If there were any entries in the stack after the current one, they are
141
- * lost.
142
- *
143
- * @param to - The new URL
144
- * @param state - Data to associate with the new location
145
- */
146
- push(to: To, state?: any): void;
147
- /**
148
- * Replaces the current location in the history stack with a new one. The
149
- * location that was replaced will no longer be available.
150
- *
151
- * @param to - The new URL
152
- * @param state - Data to associate with the new location
153
- */
154
- replace(to: To, state?: any): void;
155
- /**
156
- * Navigates `n` entries backward/forward in the history stack relative to the
157
- * current index. For example, a "back" navigation would use go(-1).
158
- *
159
- * @param delta - The delta in the stack index
160
- */
161
- go(delta: number): void;
162
- /**
163
- * Sets up a listener that will be called whenever the current location
164
- * changes.
165
- *
166
- * @param listener - A function that will be called when the location changes
167
- * @returns unlisten - A function that may be used to stop listening
168
- */
169
- listen(listener: Listener): () => void;
170
- }
171
-
172
- type MaybePromise<T> = T | Promise<T>;
173
- /**
174
- * Map of routeId -> data returned from a loader/action/error
175
- */
176
- interface RouteData {
177
- [routeId: string]: any;
178
- }
179
- type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
180
- type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
181
- /**
182
- * Users can specify either lowercase or uppercase form methods on `<Form>`,
183
- * useSubmit(), `<fetcher.Form>`, etc.
184
- */
185
- type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
186
- /**
187
- * Active navigation/fetcher form methods are exposed in uppercase on the
188
- * RouterState. This is to align with the normalization done via fetch().
189
- */
190
- type FormMethod = UpperCaseFormMethod;
191
- type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
192
- type JsonObject = {
193
- [Key in string]: JsonValue;
194
- } & {
195
- [Key in string]?: JsonValue | undefined;
196
- };
197
- type JsonArray = JsonValue[] | readonly JsonValue[];
198
- type JsonPrimitive = string | number | boolean | null;
199
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
200
- /**
201
- * @private
202
- * Internal interface to pass around for action submissions, not intended for
203
- * external consumption
204
- */
205
- type Submission = {
206
- formMethod: FormMethod;
207
- formAction: string;
208
- formEncType: FormEncType;
209
- formData: FormData;
210
- json: undefined;
211
- text: undefined;
212
- } | {
213
- formMethod: FormMethod;
214
- formAction: string;
215
- formEncType: FormEncType;
216
- formData: undefined;
217
- json: JsonValue;
218
- text: undefined;
219
- } | {
220
- formMethod: FormMethod;
221
- formAction: string;
222
- formEncType: FormEncType;
223
- formData: undefined;
224
- json: undefined;
225
- text: string;
226
- };
227
- /**
228
- * A context instance used as the key for the `get`/`set` methods of a
229
- * {@link RouterContextProvider}. Accepts an optional default
230
- * value to be returned if no value has been set.
231
- */
232
- interface RouterContext<T = unknown> {
233
- defaultValue?: T;
234
- }
235
- /**
236
- * Provides methods for writing/reading values in application context in a
237
- * type-safe way. Primarily for usage with [middleware](../../how-to/middleware).
238
- *
239
- * @example
240
- * import {
241
- * createContext,
242
- * RouterContextProvider
243
- * } from "react-router";
244
- *
245
- * const userContext = createContext<User | null>(null);
246
- * const contextProvider = new RouterContextProvider();
247
- * contextProvider.set(userContext, getUser());
248
- * // ^ Type-safe
249
- * const user = contextProvider.get(userContext);
250
- * // ^ User
251
- *
252
- * @public
253
- * @category Utils
254
- * @mode framework
255
- * @mode data
256
- */
257
- declare class RouterContextProvider {
258
- #private;
259
- /**
260
- * Create a new `RouterContextProvider` instance
261
- * @param init An optional initial context map to populate the provider with
262
- */
263
- constructor(init?: Map<RouterContext, unknown>);
264
- /**
265
- * Access a value from the context. If no value has been set for the context,
266
- * it will return the context's `defaultValue` if provided, or throw an error
267
- * if no `defaultValue` was set.
268
- * @param context The context to get the value for
269
- * @returns The value for the context, or the context's `defaultValue` if no
270
- * value was set
271
- */
272
- get<T>(context: RouterContext<T>): T;
273
- /**
274
- * Set a value for the context. If the context already has a value set, this
275
- * will overwrite it.
276
- *
277
- * @param context The context to set the value for
278
- * @param value The value to set for the context
279
- * @returns {void}
280
- */
281
- set<C extends RouterContext>(context: C, value: C extends RouterContext<infer T> ? T : never): void;
282
- }
283
- type DefaultContext = MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : any;
284
- /**
285
- * @private
286
- * Arguments passed to route loader/action functions. Same for now but we keep
287
- * this as a private implementation detail in case they diverge in the future.
288
- */
289
- interface DataFunctionArgs<Context> {
290
- /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read headers (like cookies, and {@link https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams URLSearchParams} from the request. */
291
- request: Request;
292
- /**
293
- * Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
294
- * Mostly useful as a identifier to aggregate on for logging/tracing/etc.
295
- */
296
- unstable_pattern: string;
297
- /**
298
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
299
- * @example
300
- * // app/routes.ts
301
- * route("teams/:teamId", "./team.tsx"),
302
- *
303
- * // app/team.tsx
304
- * export function loader({
305
- * params,
306
- * }: Route.LoaderArgs) {
307
- * params.teamId;
308
- * // ^ string
309
- * }
310
- */
311
- params: Params;
312
- /**
313
- * This is the context passed in to your server adapter's getLoadContext() function.
314
- * It's a way to bridge the gap between the adapter's request/response API with your React Router app.
315
- * It is only applicable if you are using a custom server adapter.
316
- */
317
- context: Context;
318
- }
319
- /**
320
- * Route middleware `next` function to call downstream handlers and then complete
321
- * middlewares from the bottom-up
322
- */
323
- interface MiddlewareNextFunction<Result = unknown> {
324
- (): Promise<Result>;
325
- }
326
- /**
327
- * Route middleware function signature. Receives the same "data" arguments as a
328
- * `loader`/`action` (`request`, `params`, `context`) as the first parameter and
329
- * a `next` function as the second parameter which will call downstream handlers
330
- * and then complete middlewares from the bottom-up
331
- */
332
- type MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<RouterContextProvider>>, next: MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
333
- /**
334
- * Arguments passed to loader functions
335
- */
336
- interface LoaderFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
337
- }
338
- /**
339
- * Arguments passed to action functions
340
- */
341
- interface ActionFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
342
- }
343
- /**
344
- * Loaders and actions can return anything
345
- */
346
- type DataFunctionValue = unknown;
347
- type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
348
- /**
349
- * Route loader function signature
350
- */
351
- type LoaderFunction<Context = DefaultContext> = {
352
- (args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
353
- } & {
354
- hydrate?: boolean;
355
- };
356
- /**
357
- * Route action function signature
358
- */
359
- interface ActionFunction<Context = DefaultContext> {
360
- (args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
361
- }
362
- /**
363
- * Arguments passed to shouldRevalidate function
364
- */
365
- interface ShouldRevalidateFunctionArgs {
366
- /** This is the url the navigation started from. You can compare it with `nextUrl` to decide if you need to revalidate this route's data. */
367
- currentUrl: URL;
368
- /** These are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the URL that can be compared to the `nextParams` to decide if you need to reload or not. Perhaps you're using only a partial piece of the param for data loading, you don't need to revalidate if a superfluous part of the param changed. */
369
- currentParams: AgnosticDataRouteMatch["params"];
370
- /** In the case of navigation, this the URL the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentUrl. */
371
- nextUrl: URL;
372
- /** In the case of navigation, these are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the next location the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentParams. */
373
- nextParams: AgnosticDataRouteMatch["params"];
374
- /** The method (probably `"GET"` or `"POST"`) used in the form submission that triggered the revalidation. */
375
- formMethod?: Submission["formMethod"];
376
- /** The form action (`<Form action="/somewhere">`) that triggered the revalidation. */
377
- formAction?: Submission["formAction"];
378
- /** The form encType (`<Form encType="application/x-www-form-urlencoded">) used in the form submission that triggered the revalidation*/
379
- formEncType?: Submission["formEncType"];
380
- /** The form submission data when the form's encType is `text/plain` */
381
- text?: Submission["text"];
382
- /** The form submission data when the form's encType is `application/x-www-form-urlencoded` or `multipart/form-data` */
383
- formData?: Submission["formData"];
384
- /** The form submission data when the form's encType is `application/json` */
385
- json?: Submission["json"];
386
- /** The status code of the action response */
387
- actionStatus?: number;
388
- /**
389
- * When a submission causes the revalidation this will be the result of the action—either action data or an error if the action failed. It's common to include some information in the action result to instruct shouldRevalidate to revalidate or not.
390
- *
391
- * @example
392
- * export async function action() {
393
- * await saveSomeStuff();
394
- * return { ok: true };
395
- * }
396
- *
397
- * export function shouldRevalidate({
398
- * actionResult,
399
- * }) {
400
- * if (actionResult?.ok) {
401
- * return false;
402
- * }
403
- * return true;
404
- * }
405
- */
406
- actionResult?: any;
407
- /**
408
- * By default, React Router doesn't call every loader all the time. There are reliable optimizations it can make by default. For example, only loaders with changing params are called. Consider navigating from the following URL to the one below it:
409
- *
410
- * /projects/123/tasks/abc
411
- * /projects/123/tasks/def
412
- * React Router will only call the loader for tasks/def because the param for projects/123 didn't change.
413
- *
414
- * It's safest to always return defaultShouldRevalidate after you've done your specific optimizations that return false, otherwise your UI might get out of sync with your data on the server.
415
- */
416
- defaultShouldRevalidate: boolean;
417
- }
418
- /**
419
- * Route shouldRevalidate function signature. This runs after any submission
420
- * (navigation or fetcher), so we flatten the navigation/fetcher submission
421
- * onto the arguments. It shouldn't matter whether it came from a navigation
422
- * or a fetcher, what really matters is the URLs and the formData since loaders
423
- * have to re-run based on the data models that were potentially mutated.
424
- */
425
- interface ShouldRevalidateFunction {
426
- (args: ShouldRevalidateFunctionArgs): boolean;
427
- }
428
- interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
429
- /**
430
- * @private
431
- */
432
- _lazyPromises?: {
433
- middleware: Promise<void> | undefined;
434
- handler: Promise<void> | undefined;
435
- route: Promise<void> | undefined;
436
- };
437
- /**
438
- * @deprecated Deprecated in favor of `shouldCallHandler`
439
- *
440
- * A boolean value indicating whether this route handler should be called in
441
- * this pass.
442
- *
443
- * The `matches` array always includes _all_ matched routes even when only
444
- * _some_ route handlers need to be called so that things like middleware can
445
- * be implemented.
446
- *
447
- * `shouldLoad` is usually only interesting if you are skipping the route
448
- * handler entirely and implementing custom handler logic - since it lets you
449
- * determine if that custom logic should run for this route or not.
450
- *
451
- * For example:
452
- * - If you are on `/parent/child/a` and you navigate to `/parent/child/b` -
453
- * you'll get an array of three matches (`[parent, child, b]`), but only `b`
454
- * will have `shouldLoad=true` because the data for `parent` and `child` is
455
- * already loaded
456
- * - If you are on `/parent/child/a` and you submit to `a`'s [`action`](https://reactrouter.com/docs/start/data/route-object#action),
457
- * then only `a` will have `shouldLoad=true` for the action execution of
458
- * `dataStrategy`
459
- * - After the [`action`](https://reactrouter.com/docs/start/data/route-object#action),
460
- * `dataStrategy` will be called again for the [`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
461
- * revalidation, and all matches will have `shouldLoad=true` (assuming no
462
- * custom `shouldRevalidate` implementations)
463
- */
464
- shouldLoad: boolean;
465
- /**
466
- * Arguments passed to the `shouldRevalidate` function for this `loader` execution.
467
- * Will be `null` if this is not a revalidating loader {@link DataStrategyMatch}.
468
- */
469
- shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
470
- /**
471
- * Determine if this route's handler should be called during this `dataStrategy`
472
- * execution. Calling it with no arguments will leverage the default revalidation
473
- * behavior. You can pass your own `defaultShouldRevalidate` value if you wish
474
- * to change the default revalidation behavior with your `dataStrategy`.
475
- *
476
- * @param defaultShouldRevalidate `defaultShouldRevalidate` override value (optional)
477
- */
478
- shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
479
- /**
480
- * An async function that will resolve any `route.lazy` implementations and
481
- * execute the route's handler (if necessary), returning a {@link DataStrategyResult}
482
- *
483
- * - Calling `match.resolve` does not mean you're calling the
484
- * [`action`](https://reactrouter.com/docs/start/data/route-object#action)/[`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
485
- * (the "handler") - `resolve` will only call the `handler` internally if
486
- * needed _and_ if you don't pass your own `handlerOverride` function parameter
487
- * - It is safe to call `match.resolve` for all matches, even if they have
488
- * `shouldLoad=false`, and it will no-op if no loading is required
489
- * - You should generally always call `match.resolve()` for `shouldLoad:true`
490
- * routes to ensure that any `route.lazy` implementations are processed
491
- * - See the examples below for how to implement custom handler execution via
492
- * `match.resolve`
493
- */
494
- resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
495
- }
496
- interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
497
- /**
498
- * Matches for this route extended with Data strategy APIs
499
- */
500
- matches: DataStrategyMatch[];
501
- runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
502
- /**
503
- * The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
504
- * for navigational executions
505
- */
506
- fetcherKey: string | null;
507
- }
508
- /**
509
- * Result from a loader or action called via dataStrategy
510
- */
511
- interface DataStrategyResult {
512
- type: "data" | "error";
513
- result: unknown;
514
- }
515
- interface DataStrategyFunction<Context = DefaultContext> {
516
- (args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
517
- }
518
- type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = {
519
- signal: AbortSignal;
520
- path: string;
521
- matches: M[];
522
- fetcherKey: string | undefined;
523
- patch: (routeId: string | null, children: O[]) => void;
524
- };
525
- type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => MaybePromise<void>;
526
- /**
527
- * Function provided by the framework-aware layers to set any framework-specific
528
- * properties from framework-agnostic properties
529
- */
530
- interface MapRoutePropertiesFunction {
531
- (route: AgnosticDataRouteObject): {
532
- hasErrorBoundary: boolean;
533
- } & Record<string, any>;
534
- }
535
- /**
536
- * Keys we cannot change from within a lazy object. We spread all other keys
537
- * onto the route. Either they're meaningful to the router, or they'll get
538
- * ignored.
539
- */
540
- type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
541
- /**
542
- * Keys we cannot change from within a lazy() function. We spread all other keys
543
- * onto the route. Either they're meaningful to the router, or they'll get
544
- * ignored.
545
- */
546
- type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "middleware";
547
- /**
548
- * lazy object to load route properties, which can add non-matching
549
- * related properties to a route
550
- */
551
- type LazyRouteObject<R extends AgnosticRouteObject> = {
552
- [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
553
- };
554
- /**
555
- * lazy() function to load a route definition, which can add non-matching
556
- * related properties to a route
557
- */
558
- interface LazyRouteFunction<R extends AgnosticRouteObject> {
559
- (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
560
- }
561
- type LazyRouteDefinition<R extends AgnosticRouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
562
- /**
563
- * Base RouteObject with common props shared by all types of routes
564
- */
565
- type AgnosticBaseRouteObject = {
566
- caseSensitive?: boolean;
567
- path?: string;
568
- id?: string;
569
- middleware?: MiddlewareFunction[];
570
- loader?: LoaderFunction | boolean;
571
- action?: ActionFunction | boolean;
572
- hasErrorBoundary?: boolean;
573
- shouldRevalidate?: ShouldRevalidateFunction;
574
- handle?: any;
575
- lazy?: LazyRouteDefinition<AgnosticBaseRouteObject>;
576
- };
577
- /**
578
- * Index routes must not have children
579
- */
580
- type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
581
- children?: undefined;
582
- index: true;
583
- };
584
- /**
585
- * Non-index routes may have children, but cannot have index
586
- */
587
- type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
588
- children?: AgnosticRouteObject[];
589
- index?: false;
590
- };
591
- /**
592
- * A route object represents a logical route, with (optionally) its child
593
- * routes organized in a tree-like structure.
594
- */
595
- type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
596
- type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
597
- id: string;
598
- };
599
- type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
600
- children?: AgnosticDataRouteObject[];
601
- id: string;
602
- };
603
- /**
604
- * A data route object, which is just a RouteObject with a required unique ID
605
- */
606
- type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
607
- /**
608
- * The parameters that were parsed from the URL path.
609
- */
610
- type Params<Key extends string = string> = {
611
- readonly [key in Key]: string | undefined;
612
- };
613
- /**
614
- * A RouteMatch contains info about how a route matched a URL.
615
- */
616
- interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
617
- /**
618
- * The names and values of dynamic parameters in the URL.
619
- */
620
- params: Params<ParamKey>;
621
- /**
622
- * The portion of the URL pathname that was matched.
623
- */
624
- pathname: string;
625
- /**
626
- * The portion of the URL pathname that was matched before child routes.
627
- */
628
- pathnameBase: string;
629
- /**
630
- * The route object that was used to match.
631
- */
632
- route: RouteObjectType;
633
- }
634
- interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
635
- }
636
- interface UIMatch<Data = unknown, Handle = unknown> {
637
- id: string;
638
- pathname: string;
639
- /**
640
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
641
- */
642
- params: AgnosticRouteMatch["params"];
643
- /**
644
- * The return value from the matched route's loader or clientLoader. This might
645
- * be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
646
- * an error and we're currently displaying an `ErrorBoundary`.
647
- *
648
- * @deprecated Use `UIMatch.loaderData` instead
649
- */
650
- data: Data | undefined;
651
- /**
652
- * The return value from the matched route's loader or clientLoader. This might
653
- * be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
654
- * an error and we're currently displaying an `ErrorBoundary`.
655
- */
656
- loaderData: Data | undefined;
657
- /**
658
- * The {@link https://reactrouter.com/start/framework/route-module#handle handle object}
659
- * exported from the matched route module
660
- */
661
- handle: Handle;
662
- }
663
-
664
- /**
665
- * An object of unknown type for route loaders and actions provided by the
666
- * server's `getLoadContext()` function. This is defined as an empty interface
667
- * specifically so apps can leverage declaration merging to augment this type
668
- * globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
669
- */
670
- interface AppLoadContext {
671
- [key: string]: unknown;
672
- }
673
-
674
- /**
675
- * A Router instance manages all navigation and data loading/mutations
676
- */
677
- interface Router$1 {
678
- /**
679
- * @private
680
- * PRIVATE - DO NOT USE
681
- *
682
- * Return the basename for the router
683
- */
684
- get basename(): RouterInit["basename"];
685
- /**
686
- * @private
687
- * PRIVATE - DO NOT USE
688
- *
689
- * Return the future config for the router
690
- */
691
- get future(): FutureConfig;
692
- /**
693
- * @private
694
- * PRIVATE - DO NOT USE
695
- *
696
- * Return the current state of the router
697
- */
698
- get state(): RouterState;
699
- /**
700
- * @private
701
- * PRIVATE - DO NOT USE
702
- *
703
- * Return the routes for this router instance
704
- */
705
- get routes(): AgnosticDataRouteObject[];
706
- /**
707
- * @private
708
- * PRIVATE - DO NOT USE
709
- *
710
- * Return the window associated with the router
711
- */
712
- get window(): RouterInit["window"];
713
- /**
714
- * @private
715
- * PRIVATE - DO NOT USE
716
- *
717
- * Initialize the router, including adding history listeners and kicking off
718
- * initial data fetches. Returns a function to cleanup listeners and abort
719
- * any in-progress loads
720
- */
721
- initialize(): Router$1;
722
- /**
723
- * @private
724
- * PRIVATE - DO NOT USE
725
- *
726
- * Subscribe to router.state updates
727
- *
728
- * @param fn function to call with the new state
729
- */
730
- subscribe(fn: RouterSubscriber): () => void;
731
- /**
732
- * @private
733
- * PRIVATE - DO NOT USE
734
- *
735
- * Enable scroll restoration behavior in the router
736
- *
737
- * @param savedScrollPositions Object that will manage positions, in case
738
- * it's being restored from sessionStorage
739
- * @param getScrollPosition Function to get the active Y scroll position
740
- * @param getKey Function to get the key to use for restoration
741
- */
742
- enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
743
- /**
744
- * @private
745
- * PRIVATE - DO NOT USE
746
- *
747
- * Navigate forward/backward in the history stack
748
- * @param to Delta to move in the history stack
749
- */
750
- navigate(to: number): Promise<void>;
751
- /**
752
- * Navigate to the given path
753
- * @param to Path to navigate to
754
- * @param opts Navigation options (method, submission, etc.)
755
- */
756
- navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
757
- /**
758
- * @private
759
- * PRIVATE - DO NOT USE
760
- *
761
- * Trigger a fetcher load/submission
762
- *
763
- * @param key Fetcher key
764
- * @param routeId Route that owns the fetcher
765
- * @param href href to fetch
766
- * @param opts Fetcher options, (method, submission, etc.)
767
- */
768
- fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
769
- /**
770
- * @private
771
- * PRIVATE - DO NOT USE
772
- *
773
- * Trigger a revalidation of all current route loaders and fetcher loads
774
- */
775
- revalidate(): Promise<void>;
776
- /**
777
- * @private
778
- * PRIVATE - DO NOT USE
779
- *
780
- * Utility function to create an href for the given location
781
- * @param location
782
- */
783
- createHref(location: Location | URL): string;
784
- /**
785
- * @private
786
- * PRIVATE - DO NOT USE
787
- *
788
- * Utility function to URL encode a destination path according to the internal
789
- * history implementation
790
- * @param to
791
- */
792
- encodeLocation(to: To): Path;
793
- /**
794
- * @private
795
- * PRIVATE - DO NOT USE
796
- *
797
- * Get/create a fetcher for the given key
798
- * @param key
799
- */
800
- getFetcher<TData = any>(key: string): Fetcher<TData>;
801
- /**
802
- * @internal
803
- * PRIVATE - DO NOT USE
804
- *
805
- * Reset the fetcher for a given key
806
- * @param key
807
- */
808
- resetFetcher(key: string, opts?: {
809
- reason?: unknown;
810
- }): void;
811
- /**
812
- * @private
813
- * PRIVATE - DO NOT USE
814
- *
815
- * Delete the fetcher for a given key
816
- * @param key
817
- */
818
- deleteFetcher(key: string): void;
819
- /**
820
- * @private
821
- * PRIVATE - DO NOT USE
822
- *
823
- * Cleanup listeners and abort any in-progress loads
824
- */
825
- dispose(): void;
826
- /**
827
- * @private
828
- * PRIVATE - DO NOT USE
829
- *
830
- * Get a navigation blocker
831
- * @param key The identifier for the blocker
832
- * @param fn The blocker function implementation
833
- */
834
- getBlocker(key: string, fn: BlockerFunction): Blocker;
835
- /**
836
- * @private
837
- * PRIVATE - DO NOT USE
838
- *
839
- * Delete a navigation blocker
840
- * @param key The identifier for the blocker
841
- */
842
- deleteBlocker(key: string): void;
843
- /**
844
- * @private
845
- * PRIVATE DO NOT USE
846
- *
847
- * Patch additional children routes into an existing parent route
848
- * @param routeId The parent route id or a callback function accepting `patch`
849
- * to perform batch patching
850
- * @param children The additional children routes
851
- * @param unstable_allowElementMutations Allow mutation or route elements on
852
- * existing routes. Intended for RSC-usage
853
- * only.
854
- */
855
- patchRoutes(routeId: string | null, children: AgnosticRouteObject[], unstable_allowElementMutations?: boolean): void;
856
- /**
857
- * @private
858
- * PRIVATE - DO NOT USE
859
- *
860
- * HMR needs to pass in-flight route updates to React Router
861
- * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
862
- */
863
- _internalSetRoutes(routes: AgnosticRouteObject[]): void;
864
- /**
865
- * @private
866
- * PRIVATE - DO NOT USE
867
- *
868
- * Cause subscribers to re-render. This is used to force a re-render.
869
- */
870
- _internalSetStateDoNotUseOrYouWillBreakYourApp(state: Partial<RouterState>): void;
871
- /**
872
- * @private
873
- * PRIVATE - DO NOT USE
874
- *
875
- * Internal fetch AbortControllers accessed by unit tests
876
- */
877
- _internalFetchControllers: Map<string, AbortController>;
878
- }
879
- /**
880
- * State maintained internally by the router. During a navigation, all states
881
- * reflect the "old" location unless otherwise noted.
882
- */
883
- interface RouterState {
884
- /**
885
- * The action of the most recent navigation
886
- */
887
- historyAction: Action;
888
- /**
889
- * The current location reflected by the router
890
- */
891
- location: Location;
892
- /**
893
- * The current set of route matches
894
- */
895
- matches: AgnosticDataRouteMatch[];
896
- /**
897
- * Tracks whether we've completed our initial data load
898
- */
899
- initialized: boolean;
900
- /**
901
- * Current scroll position we should start at for a new view
902
- * - number -> scroll position to restore to
903
- * - false -> do not restore scroll at all (used during submissions/revalidations)
904
- * - null -> don't have a saved position, scroll to hash or top of page
905
- */
906
- restoreScrollPosition: number | false | null;
907
- /**
908
- * Indicate whether this navigation should skip resetting the scroll position
909
- * if we are unable to restore the scroll position
910
- */
911
- preventScrollReset: boolean;
912
- /**
913
- * Tracks the state of the current navigation
914
- */
915
- navigation: Navigation;
916
- /**
917
- * Tracks any in-progress revalidations
918
- */
919
- revalidation: RevalidationState;
920
- /**
921
- * Data from the loaders for the current matches
922
- */
923
- loaderData: RouteData;
924
- /**
925
- * Data from the action for the current matches
926
- */
927
- actionData: RouteData | null;
928
- /**
929
- * Errors caught from loaders for the current matches
930
- */
931
- errors: RouteData | null;
932
- /**
933
- * Map of current fetchers
934
- */
935
- fetchers: Map<string, Fetcher>;
936
- /**
937
- * Map of current blockers
938
- */
939
- blockers: Map<string, Blocker>;
940
- }
941
- /**
942
- * Data that can be passed into hydrate a Router from SSR
943
- */
944
- type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
945
- /**
946
- * Future flags to toggle new feature behavior
947
- */
948
- interface FutureConfig {
949
- }
950
- /**
951
- * Initialization options for createRouter
952
- */
953
- interface RouterInit {
954
- routes: AgnosticRouteObject[];
955
- history: History;
956
- basename?: string;
957
- getContext?: () => MaybePromise<RouterContextProvider>;
958
- unstable_instrumentations?: unstable_ClientInstrumentation[];
959
- mapRouteProperties?: MapRoutePropertiesFunction;
960
- future?: Partial<FutureConfig>;
961
- hydrationRouteProperties?: string[];
962
- hydrationData?: HydrationState;
963
- window?: Window;
964
- dataStrategy?: DataStrategyFunction;
965
- patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction;
966
- }
967
- type ViewTransitionOpts = {
968
- currentLocation: Location;
969
- nextLocation: Location;
970
- };
971
- /**
972
- * Subscriber function signature for changes to router state
973
- */
974
- interface RouterSubscriber {
975
- (state: RouterState, opts: {
976
- deletedFetchers: string[];
977
- newErrors: RouteData | null;
978
- viewTransitionOpts?: ViewTransitionOpts;
979
- flushSync: boolean;
980
- }): void;
981
- }
982
- /**
983
- * Function signature for determining the key to be used in scroll restoration
984
- * for a given location
985
- */
986
- interface GetScrollRestorationKeyFunction {
987
- (location: Location, matches: UIMatch[]): string | null;
988
- }
989
- /**
990
- * Function signature for determining the current scroll position
991
- */
992
- interface GetScrollPositionFunction {
993
- (): number;
994
- }
995
- /**
996
- * - "route": relative to the route hierarchy so `..` means remove all segments
997
- * of the current route even if it has many. For example, a `route("posts/:id")`
998
- * would have both `:id` and `posts` removed from the url.
999
- * - "path": relative to the pathname so `..` means remove one segment of the
1000
- * pathname. For example, a `route("posts/:id")` would have only `:id` removed
1001
- * from the url.
1002
- */
1003
- type RelativeRoutingType = "route" | "path";
1004
- type BaseNavigateOrFetchOptions = {
1005
- preventScrollReset?: boolean;
1006
- relative?: RelativeRoutingType;
1007
- flushSync?: boolean;
1008
- unstable_defaultShouldRevalidate?: boolean;
1009
- };
1010
- type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
1011
- replace?: boolean;
1012
- state?: any;
1013
- fromRouteId?: string;
1014
- viewTransition?: boolean;
1015
- };
1016
- type BaseSubmissionOptions = {
1017
- formMethod?: HTMLFormMethod;
1018
- formEncType?: FormEncType;
1019
- } & ({
1020
- formData: FormData;
1021
- body?: undefined;
1022
- } | {
1023
- formData?: undefined;
1024
- body: any;
1025
- });
1026
- /**
1027
- * Options for a navigate() call for a normal (non-submission) navigation
1028
- */
1029
- type LinkNavigateOptions = BaseNavigateOptions;
1030
- /**
1031
- * Options for a navigate() call for a submission navigation
1032
- */
1033
- type SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;
1034
- /**
1035
- * Options to pass to navigate() for a navigation
1036
- */
1037
- type RouterNavigateOptions = LinkNavigateOptions | SubmissionNavigateOptions;
1038
- /**
1039
- * Options for a fetch() load
1040
- */
1041
- type LoadFetchOptions = BaseNavigateOrFetchOptions;
1042
- /**
1043
- * Options for a fetch() submission
1044
- */
1045
- type SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;
1046
- /**
1047
- * Options to pass to fetch()
1048
- */
1049
- type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
1050
- /**
1051
- * Potential states for state.navigation
1052
- */
1053
- type NavigationStates = {
1054
- Idle: {
1055
- state: "idle";
1056
- location: undefined;
1057
- formMethod: undefined;
1058
- formAction: undefined;
1059
- formEncType: undefined;
1060
- formData: undefined;
1061
- json: undefined;
1062
- text: undefined;
1063
- };
1064
- Loading: {
1065
- state: "loading";
1066
- location: Location;
1067
- formMethod: Submission["formMethod"] | undefined;
1068
- formAction: Submission["formAction"] | undefined;
1069
- formEncType: Submission["formEncType"] | undefined;
1070
- formData: Submission["formData"] | undefined;
1071
- json: Submission["json"] | undefined;
1072
- text: Submission["text"] | undefined;
1073
- };
1074
- Submitting: {
1075
- state: "submitting";
1076
- location: Location;
1077
- formMethod: Submission["formMethod"];
1078
- formAction: Submission["formAction"];
1079
- formEncType: Submission["formEncType"];
1080
- formData: Submission["formData"];
1081
- json: Submission["json"];
1082
- text: Submission["text"];
1083
- };
1084
- };
1085
- type Navigation = NavigationStates[keyof NavigationStates];
1086
- type RevalidationState = "idle" | "loading";
1087
- /**
1088
- * Potential states for fetchers
1089
- */
1090
- type FetcherStates<TData = any> = {
1091
- /**
1092
- * The fetcher is not calling a loader or action
1093
- *
1094
- * ```tsx
1095
- * fetcher.state === "idle"
1096
- * ```
1097
- */
1098
- Idle: {
1099
- state: "idle";
1100
- formMethod: undefined;
1101
- formAction: undefined;
1102
- formEncType: undefined;
1103
- text: undefined;
1104
- formData: undefined;
1105
- json: undefined;
1106
- /**
1107
- * If the fetcher has never been called, this will be undefined.
1108
- */
1109
- data: TData | undefined;
1110
- };
1111
- /**
1112
- * The fetcher is loading data from a {@link LoaderFunction | loader} from a
1113
- * call to {@link FetcherWithComponents.load | `fetcher.load`}.
1114
- *
1115
- * ```tsx
1116
- * // somewhere
1117
- * <button onClick={() => fetcher.load("/some/route") }>Load</button>
1118
- *
1119
- * // the state will update
1120
- * fetcher.state === "loading"
1121
- * ```
1122
- */
1123
- Loading: {
1124
- state: "loading";
1125
- formMethod: Submission["formMethod"] | undefined;
1126
- formAction: Submission["formAction"] | undefined;
1127
- formEncType: Submission["formEncType"] | undefined;
1128
- text: Submission["text"] | undefined;
1129
- formData: Submission["formData"] | undefined;
1130
- json: Submission["json"] | undefined;
1131
- data: TData | undefined;
1132
- };
1133
- /**
1134
- The fetcher is submitting to a {@link LoaderFunction} (GET) or {@link ActionFunction} (POST) from a {@link FetcherWithComponents.Form | `fetcher.Form`} or {@link FetcherWithComponents.submit | `fetcher.submit`}.
1135
-
1136
- ```tsx
1137
- // somewhere
1138
- <input
1139
- onChange={e => {
1140
- fetcher.submit(event.currentTarget.form, { method: "post" });
1141
- }}
1142
- />
1143
-
1144
- // the state will update
1145
- fetcher.state === "submitting"
1146
-
1147
- // and formData will be available
1148
- fetcher.formData
1149
- ```
1150
- */
1151
- Submitting: {
1152
- state: "submitting";
1153
- formMethod: Submission["formMethod"];
1154
- formAction: Submission["formAction"];
1155
- formEncType: Submission["formEncType"];
1156
- text: Submission["text"];
1157
- formData: Submission["formData"];
1158
- json: Submission["json"];
1159
- data: TData | undefined;
1160
- };
1161
- };
1162
- type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
1163
- interface BlockerBlocked {
1164
- state: "blocked";
1165
- reset: () => void;
1166
- proceed: () => void;
1167
- location: Location;
1168
- }
1169
- interface BlockerUnblocked {
1170
- state: "unblocked";
1171
- reset: undefined;
1172
- proceed: undefined;
1173
- location: undefined;
1174
- }
1175
- interface BlockerProceeding {
1176
- state: "proceeding";
1177
- reset: undefined;
1178
- proceed: undefined;
1179
- location: Location;
1180
- }
1181
- type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
1182
- type BlockerFunction = (args: {
1183
- currentLocation: Location;
1184
- nextLocation: Location;
1185
- historyAction: Action;
1186
- }) => boolean;
1187
- type unstable_ClientInstrumentation = {
1188
- router?: unstable_InstrumentRouterFunction;
1189
- route?: unstable_InstrumentRouteFunction;
1190
- };
1191
- type unstable_InstrumentRouterFunction = (router: InstrumentableRouter) => void;
1192
- type unstable_InstrumentRouteFunction = (route: InstrumentableRoute) => void;
1193
- type unstable_InstrumentationHandlerResult = {
1194
- status: "success";
1195
- error: undefined;
1196
- } | {
1197
- status: "error";
1198
- error: Error;
1199
- };
1200
- type InstrumentFunction<T> = (handler: () => Promise<unstable_InstrumentationHandlerResult>, info: T) => Promise<void>;
1201
- type ReadonlyRequest = {
1202
- method: string;
1203
- url: string;
1204
- headers: Pick<Headers, "get">;
1205
- };
1206
- type ReadonlyContext = MiddlewareEnabled extends true ? Pick<RouterContextProvider, "get"> : Readonly<AppLoadContext>;
1207
- type InstrumentableRoute = {
1208
- id: string;
1209
- index: boolean | undefined;
1210
- path: string | undefined;
1211
- instrument(instrumentations: RouteInstrumentations): void;
1212
- };
1213
- type RouteInstrumentations = {
1214
- lazy?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1215
- "lazy.loader"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1216
- "lazy.action"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1217
- "lazy.middleware"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1218
- middleware?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1219
- loader?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1220
- action?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1221
- };
1222
- type RouteLazyInstrumentationInfo = undefined;
1223
- type RouteHandlerInstrumentationInfo = Readonly<{
1224
- request: ReadonlyRequest;
1225
- params: LoaderFunctionArgs["params"];
1226
- unstable_pattern: string;
1227
- context: ReadonlyContext;
1228
- }>;
1229
- type InstrumentableRouter = {
1230
- instrument(instrumentations: RouterInstrumentations): void;
1231
- };
1232
- type RouterInstrumentations = {
1233
- navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>;
1234
- fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>;
1235
- };
1236
- type RouterNavigationInstrumentationInfo = Readonly<{
1237
- to: string | number;
1238
- currentUrl: string;
1239
- formMethod?: HTMLFormMethod;
1240
- formEncType?: FormEncType;
1241
- formData?: FormData;
1242
- body?: any;
1243
- }>;
1244
- type RouterFetchInstrumentationInfo = Readonly<{
1245
- href: string;
1246
- currentUrl: string;
1247
- fetcherKey: string;
1248
- formMethod?: HTMLFormMethod;
1249
- formEncType?: FormEncType;
1250
- formData?: FormData;
1251
- body?: any;
1252
- }>;
1253
-
1254
3
  type AppProps = {
1255
4
  serverOrigin?: string;
1256
5
  defaultRoomKey?: string;
@@ -1265,12 +14,6 @@ type AppProps = {
1265
14
  cdnBase?: string;
1266
15
  };
1267
16
 
1268
- interface CreateWatchpartyRouterOptions {
1269
- basename?: string;
1270
- appProps?: AppProps;
1271
- }
1272
- declare function createWatchpartyRouter({ basename, appProps }?: CreateWatchpartyRouterOptions): Router$1;
1273
-
1274
17
  type WatchpartyMountProps = AppProps & {
1275
18
  basename?: string;
1276
19
  strictMode?: boolean;
@@ -1282,7 +25,7 @@ type MountedInstance = {
1282
25
  type MountTarget = HTMLElement & {
1283
26
  __watchparty?: MountedInstance;
1284
27
  };
1285
- declare function mount(el: MountTarget, props?: WatchpartyMountProps): Router$1;
28
+ declare function mount(el: MountTarget, props?: WatchpartyMountProps): void;
1286
29
  /**
1287
30
  * Tear down a `mount()`: the React root, the room, the socket and the
1288
31
  * page-wide listener. Unmounting the React root alone left the socket
@@ -1291,5 +34,5 @@ declare function mount(el: MountTarget, props?: WatchpartyMountProps): Router$1;
1291
34
  */
1292
35
  declare function unmount(el: MountTarget): void;
1293
36
 
1294
- export { createWatchpartyRouter, mount, unmount };
1295
- export type { AppProps, CreateWatchpartyRouterOptions, WatchpartyMountProps };
37
+ export { mount, unmount };
38
+ export type { AppProps, WatchpartyMountProps };