init commit

This commit is contained in:
rxliuli
2025-11-04 05:03:50 +08:00
commit bce557cc2d
1396 changed files with 172991 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import { isSome } from '@jet/environment/types/optional';
import type { IntentController } from '@jet/environment/dispatching';
import type { AppStoreObjectGraph } from '@jet-app/app-store/foundation/runtime/app-store-object-graph';
import { isRoutableIntent } from '@jet-app/app-store/api/intents/routable-intent';
import type { RouteUrlIntent } from '~/jet/intents';
import { makeFlowAction } from '~/jet/models';
export const RouteUrlIntentController: IntentController<RouteUrlIntent> = {
$intentKind: 'RouteUrlIntent',
async perform(intent: RouteUrlIntent, objectGraph: AppStoreObjectGraph) {
const targetIntent = objectGraph.router.intentFor(intent.url);
if (isSome(targetIntent) && isRoutableIntent(targetIntent)) {
return {
// intent needed for SSR
intent: targetIntent,
// only ever used by client; only clients have actions
action: makeFlowAction(targetIntent),
storefront: targetIntent.storefront,
language: targetIntent.language,
};
}
return null;
},
};

View File

@@ -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 };
}