@hadoku/watchparty-ui 0.0.0-stage → 0.43.16

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