refactor(native): keep the Android bridge additions apart from the iOS ones in trekShell.ts

The new methods sit at the end of the interface and the restore's Android
answer has a type of its own, so the watch and large-screen branches, which
add their methods after storeRestore, merge without a conflict.
This commit is contained in:
Maurice
2026-11-07 14:20:33 +01:00
parent 1e4f1922e8
commit da05ba1121
2 changed files with 19 additions and 10 deletions
+5 -2
View File
@@ -1,5 +1,5 @@
import { isNativeAndroid, isNativeIos } from './platform';
import { TrekShell } from './trekShell';
import { TrekShell, type StoreRestoreResult } from './trekShell';
/**
* In-app purchase, from the app's side. A seam, like {@link TrekShell}: the
@@ -162,7 +162,10 @@ export const nativeIapClient: IapClient = {
},
async restore() {
try {
const { jws, purchaseToken, productId, transactionId } = await TrekShell.storeRestore({ prefix: PRODUCT_PREFIX });
// Google Play answers with a purchase token where the App Store answers with a signed transaction.
const { jws, purchaseToken, productId, transactionId }: StoreRestoreResult = await TrekShell.storeRestore({
prefix: PRODUCT_PREFIX,
});
if (purchaseToken && transactionId) {
return { platform: 'google', productId: productId ?? '', receipt: purchaseToken, transactionId };
}
+14 -8
View File
@@ -96,10 +96,12 @@ export interface TrekShellPlugin {
storeFinish(options: { transactionId: string }): Promise<void>;
/** iOS, feature wallet: adds a .pkpass (base64) to Apple Wallet, or opens it there when it is already in. */
addToWallet(options: { data: string }): Promise<{ result: 'added' | 'opened' | 'cancelled' }>;
/** The newest active subscription under `prefix` on this Apple ID or Google account, if any. */
storeRestore(options: {
prefix: string;
}): Promise<{ jws?: string; purchaseToken?: string; productId?: string; transactionId?: string }>;
/** iOS, feature storeKit: the newest active subscription under `prefix` on this Apple ID, if any. */
storeRestore(options: { prefix: string }): Promise<{ jws?: string; transactionId?: string }>;
addListener(
event: 'pushOpened',
listener: (payload: { url: string }) => void
): Promise<{ remove: () => Promise<void> }>;
/** Android, feature googleWallet: opens a Google Wallet save link (https://pay.google.com/gp/v/save/...). */
addToGoogleWallet(options: { url: string }): Promise<{ result: 'opened' }>;
/** Android, feature windowLayout: the window's size classes and a foldable's posture and hinge. */
@@ -108,10 +110,14 @@ export interface TrekShellPlugin {
event: 'windowLayout',
listener: (payload: NativeWindowLayout) => void
): Promise<{ remove: () => Promise<void> }>;
addListener(
event: 'pushOpened',
listener: (payload: { url: string }) => void
): Promise<{ remove: () => Promise<void> }>;
}
/** What Google Play Billing answers a restore with (Android, feature playBilling), beside iOS's `jws`. */
export interface StoreRestoreResult {
jws?: string;
purchaseToken?: string;
productId?: string;
transactionId?: string;
}
/** A document shared to TREK, as the native side reads it. */