diff options
| author | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
|---|---|---|
| committer | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
| commit | bce557cc2dc767628bed6aac87301a1be7c5431b (patch) | |
| tree | b51a051228d01fe3306cd7626d4a96768aadb944 /src/jet/intents/route-url/route-url-intent.ts | |
init commit
Diffstat (limited to 'src/jet/intents/route-url/route-url-intent.ts')
| -rw-r--r-- | src/jet/intents/route-url/route-url-intent.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/jet/intents/route-url/route-url-intent.ts b/src/jet/intents/route-url/route-url-intent.ts new file mode 100644 index 0000000..841bd25 --- /dev/null +++ b/src/jet/intents/route-url/route-url-intent.ts @@ -0,0 +1,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 }; +} |
