diff --git a/platforms/market/src/app/manifest/build-manifest.ts b/platforms/market/src/app/manifest/build-manifest.ts
new file mode 100644
index 0000000..76353e1
--- /dev/null
+++ b/platforms/market/src/app/manifest/build-manifest.ts
@@ -0,0 +1,37 @@
+import type { MetadataRoute } from 'next';
+
+import { ROUTES } from '../navigation/navigation';
+import {
+ MANIFEST_BACKGROUND_COLOR,
+ MANIFEST_ICONS,
+ MANIFEST_THEME_COLOR,
+} from './constants';
+import type { ManifestArgs } from './types';
+
+/**
+ * The web app manifest for each app's `app/manifest.ts`. Both apps serve one origin, so they serve
+ * this same manifest (0053). The installed app opens on خانه, which sends a guest to login and a
+ * creator to their channel, so it never flashes the landing; `id` keeps the installed app's
+ * identity if `start_url` changes.
+ */
+export function buildManifest({
+ name,
+ description,
+ lang,
+ dir,
+}: ManifestArgs): MetadataRoute.Manifest {
+ return {
+ id: '/',
+ name,
+ short_name: name,
+ description,
+ lang,
+ dir,
+ start_url: ROUTES.home,
+ scope: '/',
+ display: 'standalone',
+ background_color: MANIFEST_BACKGROUND_COLOR,
+ theme_color: MANIFEST_THEME_COLOR,
+ icons: [...MANIFEST_ICONS],
+ };
+}
diff --git a/platforms/market/src/app/manifest/constants.ts b/platforms/market/src/app/manifest/constants.ts
new file mode 100644
index 0000000..f38c896
--- /dev/null
+++ b/platforms/market/src/app/manifest/constants.ts
@@ -0,0 +1,18 @@
+/**
+ * The light theme's `--bg-page` and `--action-primary` in island `theme.css`. The manifest can't
+ * read CSS variables, so a change there changes these too.
+ */
+export const MANIFEST_BACKGROUND_COLOR = '#f4f6f9';
+export const MANIFEST_THEME_COLOR = '#533afd';
+
+/** Placeholders until the brand mark exists; each app's `apple-icon.png` covers iOS. */
+export const MANIFEST_ICONS = [
+ { src: '/pwa/icon-192.png', sizes: '192x192', type: 'image/png' },
+ { src: '/pwa/icon-512.png', sizes: '512x512', type: 'image/png' },
+ {
+ src: '/pwa/icon-maskable-512.png',
+ sizes: '512x512',
+ type: 'image/png',
+ purpose: 'maskable',
+ },
+] as const;
diff --git a/platforms/market/src/app/manifest/server.ts b/platforms/market/src/app/manifest/server.ts
new file mode 100644
index 0000000..f834304
--- /dev/null
+++ b/platforms/market/src/app/manifest/server.ts
@@ -0,0 +1,4 @@
+import 'server-only';
+
+export { buildManifest } from './build-manifest';
+export type { ManifestArgs } from './types';
diff --git a/platforms/market/src/app/manifest/types.ts b/platforms/market/src/app/manifest/types.ts
new file mode 100644
index 0000000..d89dadd
--- /dev/null
+++ b/platforms/market/src/app/manifest/types.ts
@@ -0,0 +1,8 @@
+/** The manifest's text, in the app's one locale. */
+export type ManifestArgs = {
+ /** «لومینا»: the name and the short name. */
+ name: string;
+ description: string;
+ lang: string;
+ dir: 'rtl' | 'ltr';
+};
diff --git a/platforms/market/src/app/navigation/back-target.ts b/platforms/market/src/app/navigation/back-target.ts
index b32673f..3e4bb97 100644
--- a/platforms/market/src/app/navigation/back-target.ts
+++ b/platforms/market/src/app/navigation/back-target.ts
@@ -13,11 +13,33 @@ export const backTargetStore = createStore<{ target: BackTarget | null }>()(
);
/**
- * Whether the page has a page of this site behind it in the tab's history. The Navigation API
- * lists only this site's entries in a row, so a page opened from a link, a notification, another
- * site or the bank has none; without it, any history counts.
+ * The key of the previous history entry when back should return to it (0057): `parentHref` itself,
+ * or, with `toPrevious`, any page of this site. The Navigation API lists only this site's entries,
+ * so a page opened from a link, a notification, another site or the bank has none; without the
+ * API there is none either, and back opens `parentHref`.
*/
-export function hasInAppHistory(): boolean {
- const { navigation } = window as { navigation?: { canGoBack: boolean } };
- return navigation ? navigation.canGoBack : window.history.length > 1;
+export function previousEntryKey(
+ parentHref: string,
+ toPrevious: boolean,
+): string | undefined {
+ if (!('navigation' in window)) return undefined;
+ const current = navigation.currentEntry;
+ if (!current || current.index < 1) return undefined;
+ const previous = navigation.entries()[current.index - 1];
+ if (!previous?.url) return undefined;
+ if (toPrevious) return previous.key;
+ const from = new URL(previous.url).pathname;
+ const to = new URL(parentHref, window.location.href).pathname;
+ return from === to ? previous.key : undefined;
+}
+
+/**
+ * Goes back to the entry `previousEntryKey` found. By key, so a second press before the first lands
+ * goes to the same page, never further or out of the site.
+ */
+export function traverseTo(key: string): void {
+ const { committed, finished } = navigation.traverseTo(key);
+ // A newer navigation interrupts it, which is no error.
+ committed?.catch(() => undefined);
+ finished?.catch(() => undefined);
}
diff --git a/platforms/market/src/app/navigation/components/desk-back/DeskBack.tsx b/platforms/market/src/app/navigation/components/desk-back/DeskBack.tsx
index 06c7abb..f1ef3e5 100644
--- a/platforms/market/src/app/navigation/components/desk-back/DeskBack.tsx
+++ b/platforms/market/src/app/navigation/components/desk-back/DeskBack.tsx
@@ -17,8 +17,9 @@ const DESK_BACK_CLASS =
/**
* «بازگشت» on desktop (R14): its own row at the top of a pushed page's column, above the page's
* title. Every page opened from another page has it (an installed app has no browser back); tab
- * roots don't. Back goes to the page behind it on this site, or the page's `parentHref` when it was
- * opened on its own; a fixed `href` (an auth step, the payment result's channel) is a link.
+ * roots don't. It links to the page's parent and goes back through history when the parent is the
+ * page behind (0057); a fixed `href` (an auth step, the payment result's subscriptions) is a plain
+ * link.
*/
export function DeskBack({ label, ...options }: DeskBackProps) {
const { t } = useTranslation();
@@ -41,6 +42,7 @@ export function DeskBack({ label, ...options }: DeskBackProps) {
)}
diff --git a/platforms/market/src/app/navigation/components/mobile-top-bar/components/BackButton.tsx b/platforms/market/src/app/navigation/components/mobile-top-bar/components/BackButton.tsx
index 4568bcd..5892606 100644
--- a/platforms/market/src/app/navigation/components/mobile-top-bar/components/BackButton.tsx
+++ b/platforms/market/src/app/navigation/components/mobile-top-bar/components/BackButton.tsx
@@ -6,9 +6,9 @@ import { useBack } from '../../../hooks/use-back';
import type { BackButtonProps } from '../types';
/**
- * The bar's back (R14): to the page behind it on this site, or the page's parent when it was
- * opened on its own (a link, a notification). A fixed `href` is a link; a page that may lose work
- * passes `onBack` and asks first.
+ * The bar's back (R14, 0057): a link to the page's parent that goes back through history when the
+ * parent is the page behind. A fixed `href` is a plain link; a page that may lose work passes
+ * `onBack` and asks first.
*/
export function BackButton({ label, ...options }: BackButtonProps) {
const action = useBack(options);
@@ -18,6 +18,7 @@ export function BackButton({ label, ...options }: BackButtonProps) {
icon="chevron-right"
label={label}
href={action.href}
+ onNavigate={action.onNavigate}
/>
) : (