@mpgd/platform 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.d.ts +39 -1
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { AdProvider } from './ads.js';
2
- export type PlatformTarget = 'browser' | 'microsoft-store' | 'android' | 'ios' | 'ait' | 'reddit' | 'verse8' | 'crazygames' | 'telegram' | 'tauri' | 'wechat' | 'tiktok';
2
+ export type PlatformTarget = 'browser' | 'microsoft-store' | 'android' | 'ios' | 'ait' | 'reddit' | 'verse8' | 'crazygames' | 'oneplay' | 'telegram' | 'tauri' | 'wechat' | 'tiktok';
3
3
  export type StarterLogicalProductId = 'COINS_100' | 'COINS_500' | 'REMOVE_ADS';
4
4
  export type LogicalProductId = StarterLogicalProductId | (string & Record<never, never>);
5
5
  export type StarterLogicalAdPlacementId = 'CONTINUE_AFTER_FAIL' | 'STAGE_END_INTERSTITIAL';
@@ -47,6 +47,15 @@ export declare class PlatformOperationError extends Error implements PlatformOpe
47
47
  }>);
48
48
  }
49
49
  export declare function readPlatformOperationFailure(error: unknown): PlatformOperationFailure | null;
50
+ /**
51
+ * Stable, non-sensitive reason attached to a commerce outcome that did not
52
+ * fully complete. It is diagnostic only: it never grants or revokes anything.
53
+ * Games may use it for UI copy, retry decisions and support logs.
54
+ */
55
+ export interface CommerceDiagnostic extends PlatformOperationFailure {
56
+ /** Provider SDK error code, passed through only when it is a safe identifier. */
57
+ readonly providerCode?: string;
58
+ }
50
59
  export interface PurchaseResult {
51
60
  readonly status: 'completed' | 'cancelled' | 'pending' | 'failed';
52
61
  readonly transactionId?: string;
@@ -57,11 +66,15 @@ export interface PurchaseResult {
57
66
  readonly ledgerEntryId: string;
58
67
  readonly alreadyProcessed?: boolean;
59
68
  }>;
69
+ /** Optional reason for a cancelled, pending or failed result. */
70
+ readonly diagnostic?: CommerceDiagnostic;
60
71
  }
61
72
  export interface PurchaseRestoreResult {
62
73
  readonly restoredEntitlements: readonly Entitlement[];
63
74
  /** Server-confirmed consumable outcomes; native order visibility alone is not a grant. */
64
75
  readonly settledPurchases?: readonly PurchaseSettlement[];
76
+ /** Present when restore finished only partially, for example with orders still unresolved. */
77
+ readonly diagnostic?: CommerceDiagnostic;
65
78
  }
66
79
  export interface PurchaseSettlement {
67
80
  readonly transactionId: string;
@@ -69,6 +82,8 @@ export interface PurchaseSettlement {
69
82
  readonly status: 'granted' | 'refunded';
70
83
  readonly ledgerEntryId?: string;
71
84
  readonly alreadyProcessed?: boolean;
85
+ /** Client purchase idempotency key the order was started with, when the adapter can link it. */
86
+ readonly idempotencyKey?: string;
72
87
  }
73
88
  /**
74
89
  * Resolve a specific purchase from authoritative checkout or restore evidence.
@@ -102,7 +117,16 @@ export interface InterstitialAdResult {
102
117
  export interface BannerAdMountResult {
103
118
  readonly status: 'mounted' | 'unavailable' | 'failed';
104
119
  }
120
+ export interface PlatformPurchasePresentationEvent {
121
+ readonly idempotencyKey: string;
122
+ readonly sequence: number;
123
+ readonly state: 'open' | 'closed' | 'not-started' | 'unknown';
124
+ }
105
125
  export interface CommerceAdapter {
126
+ /** Trusted native presentation facts, independent of the purchase grant result. */
127
+ readonly presentation?: {
128
+ subscribe(listener: (event: PlatformPurchasePresentationEvent) => void): () => void;
129
+ };
106
130
  getProducts(): Promise<readonly ProductInfo[]>;
107
131
  purchase(input: {
108
132
  readonly productId: LogicalProductId;
@@ -333,6 +357,8 @@ export interface ViewportAdapter {
333
357
  export interface LifecycleAdapter {
334
358
  onPause(callback: () => void): () => void;
335
359
  onResume(callback: () => void): () => void;
360
+ /** Synchronous checkpoint only. The host may destroy the document immediately afterward. */
361
+ onExit?(callback: () => void): () => void;
336
362
  /**
337
363
  * Android handlers run last-registered-first until one returns true. If none
338
364
  * consumes the event, Capacitor navigates WebView history when possible or
@@ -367,6 +393,16 @@ export interface StorageAdapter {
367
393
  readonly key: string;
368
394
  readonly value: unknown;
369
395
  }): Promise<void>;
396
+ /** Optional synchronous checkpoint for hosts whose exit event cannot await promises. */
397
+ saveSync?(input: {
398
+ readonly key: string;
399
+ readonly value: unknown;
400
+ }): void;
401
+ }
402
+ /** Host loading UI. Completion is an acknowledgement, not progress reaching 100%. */
403
+ export interface GameLoadingAdapter {
404
+ setProgress(progress: number): void;
405
+ complete(): Promise<void>;
370
406
  }
371
407
  /** Device-protected opaque credentials; never backed by ordinary game storage. */
372
408
  export interface SecureCredentialStore {
@@ -392,9 +428,11 @@ export interface GameActivityAdapter {
392
428
  export interface GameSettingsAdapter {
393
429
  getAudioMuted(): boolean;
394
430
  onAudioMuteChange(callback: (muted: boolean) => void): () => void;
431
+ getLocale?(): string;
395
432
  }
396
433
  export interface PlatformGateway {
397
434
  readonly target: PlatformTarget;
435
+ readonly gameLoading?: GameLoadingAdapter;
398
436
  getCapabilities(): Promise<PlatformCapabilities>;
399
437
  readonly identity: IdentityAdapter;
400
438
  readonly commerce: CommerceAdapter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpgd/platform",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "Shared platform gateway, monetization, ads, leaderboard, identity, lifecycle, and storage contracts for mpgd games.",
5
5
  "license": "MIT",
6
6
  "repository": {