blob: 841bd25e48f564971753052c37f095d9244cf422 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import type { Optional } from '@jet/environment/types/optional';
import type { Intent } from '@jet/environment/dispatching';
import type { FlowAction } from '@jet-app/app-store/api/models';
import type {
NormalizedStorefront,
NormalizedLanguage,
} from '@jet-app/app-store/api/locale';
/**
* A response from the router given an incoming (deeplink) URL.
*/
export interface RouterResponse {
/**
* The intent to dispatch to get the view model for this URL.
*/
intent: Intent<unknown>;
/**
* action to navigate to a new page of the app.
*/
action: FlowAction;
storefront: NormalizedStorefront;
language: NormalizedLanguage;
}
export interface RouteUrlIntent extends Intent<Optional<RouterResponse>> {
$kind: 'RouteUrlIntent';
/**
* The URL to route (ex. "https://podcasts.apple.com/us/show/serial/id123").
*/
url: string;
}
export function isRouteUrlIntent(
intent: Intent<unknown>,
): intent is RouteUrlIntent {
return intent.$kind === 'RouteUrlIntent';
}
export function makeRouteUrlIntent(
options: Omit<RouteUrlIntent, '$kind'>,
): RouteUrlIntent {
return { $kind: 'RouteUrlIntent', ...options };
}
|