de003e862a
Make the web SPA behave correctly inside the Capacitor native shell, where the bundle loads from a local origin: - New lib/origin.ts gatewayOrigin(): absolute URLs resolve to VITE_GATEWAY_URL on native (the finished-game export/share URL in Game.svelte and the Wallet site-root link), falling back to the page origin on web. transport.ts already resolved via VITE_GATEWAY_URL and is left as-is. - Skip the PWA service worker on the native channel (the assets are already local; a worker would risk serving stale content across store updates). - Hide the money-purchase UI in the MVP: new distribution.purchasesHidden() folds VITE_PAYMENTS_DISABLED and the Google Play flag. The Wallet "buy" tab shows a neutral, pointer-free note (wallet.purchasesSoon) for the RuStore MVP and keeps the RuStore stub Google-Play-only. A ?nopay mock force mirrors ?gp for the e2e. - Native env types in vite-env.d.ts. Client-only, contour-safe: no wire/proto/schema change; web/VK/Telegram unchanged. Tests: origin + purchasesHidden unit tests, a ?nopay wallet e2e. svelte-check clean, vitest green, web + native vite build clean.
43 lines
2.1 KiB
TypeScript
43 lines
2.1 KiB
TypeScript
// Distribution flags for the native builds. Two independent build-time flags hide the in-app-currency
|
|
// purchase actions: VITE_GP_BUILD marks the Google Play build (Google forbids selling in-app currency
|
|
// through an external gate — it hides the actions and shows a stub pointing at the RuStore build), and
|
|
// VITE_PAYMENTS_DISABLED marks the thin native MVP that defers store billing (it hides the actions with
|
|
// no store pointer). Every other build (web, VK, Telegram, a billing-enabled RuStore native build) sells
|
|
// normally. purchasesHidden() folds both; isGooglePlayBuild() stays separate for the RuStore-pointer stub.
|
|
|
|
/**
|
|
* isGooglePlayBuild reports whether this is the Google Play native build, where in-app-currency
|
|
* purchases are hidden. It reads the build-time flag VITE_GP_BUILD (set to "1" only by the Google
|
|
* Play build); every other build reads false. Under the mock e2e it can be forced on with a `?gp`
|
|
* query parameter so the stub path is exercisable without a separate build.
|
|
*/
|
|
export function isGooglePlayBuild(): boolean {
|
|
if (
|
|
import.meta.env.MODE === 'mock' &&
|
|
typeof window !== 'undefined' &&
|
|
new URLSearchParams(window.location.search).has('gp')
|
|
) {
|
|
return true;
|
|
}
|
|
return (import.meta.env as Record<string, string | undefined>).VITE_GP_BUILD === '1';
|
|
}
|
|
|
|
/**
|
|
* purchasesHidden reports whether this build hides the in-app-currency purchase actions. It is true
|
|
* for the Google Play build (external-payment policy — see isGooglePlayBuild) and for the thin native
|
|
* MVP that defers store billing (the build-time flag VITE_PAYMENTS_DISABLED set to "1"). Every other
|
|
* build sells normally. Under the mock e2e it can be forced on with a `?nopay` query parameter so the
|
|
* hidden-purchases state is exercisable without a separate build.
|
|
*/
|
|
export function purchasesHidden(): boolean {
|
|
if (isGooglePlayBuild()) return true;
|
|
if (
|
|
import.meta.env.MODE === 'mock' &&
|
|
typeof window !== 'undefined' &&
|
|
new URLSearchParams(window.location.search).has('nopay')
|
|
) {
|
|
return true;
|
|
}
|
|
return (import.meta.env as Record<string, string | undefined>).VITE_PAYMENTS_DISABLED === '1';
|
|
}
|