import './adapters'; import { Nami as CoreNami, NamiPaywallManager, logger } from '@namiml/sdk-core'; import { backfill, collectSkuRefIds, reset as resetProductStore } from './products/productStore'; type ResettableCoreNami = typeof CoreNami & { reset?: () => Promise; }; /** * Prefetch StoreKit/Play product details for every configured paywall's SKUs so that * prices are available before any paywall mounts (mirrors the Apple SDK startup load). * Fire-and-forget and error-safe: a failure here never blocks configure. */ export async function prefetchProducts(): Promise { try { const ids = collectSkuRefIds(NamiPaywallManager.allPaywalls()); if (ids.length) await backfill(ids); } catch (error) { logger.warn('[NamiExpo] Product prefetch skipped.', error); } } export class Nami { static get sdkVersion(): string { return CoreNami.sdkVersion(); } static sdkPackageVersion(): string { return CoreNami.sdkPackageVersion(); } static async configure(config: Parameters[0]) { const result = await CoreNami.configure(config); void prefetchProducts(); return result; } static async reset(): Promise { resetProductStore(); await (CoreNami as ResettableCoreNami).reset?.(); } }