@mpgd/platform 0.3.2 → 0.4.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 +64 -2
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export type PlatformTarget = 'browser' | 'android' | 'ios' | 'ait' | 'reddit' | 'telegram' | 'tauri';
2
- export type LogicalProductId = 'COINS_100' | 'COINS_500' | 'REMOVE_ADS';
3
- export type LogicalAdPlacementId = 'CONTINUE_AFTER_FAIL' | 'STAGE_END_INTERSTITIAL';
2
+ export type StarterLogicalProductId = 'COINS_100' | 'COINS_500' | 'REMOVE_ADS';
3
+ export type LogicalProductId = StarterLogicalProductId | (string & Record<never, never>);
4
+ export type StarterLogicalAdPlacementId = 'CONTINUE_AFTER_FAIL' | 'STAGE_END_INTERSTITIAL';
5
+ export type LogicalAdPlacementId = StarterLogicalAdPlacementId | (string & Record<never, never>);
4
6
  export type ProductType = 'consumable' | 'non_consumable' | 'subscription';
5
7
  export interface ProductInfo {
6
8
  readonly id: LogicalProductId;
@@ -89,8 +91,65 @@ export interface PlayerIdentity {
89
91
  readonly displayName?: string;
90
92
  readonly avatarUrl?: string;
91
93
  }
94
+ export type IdentityLevel = 'guest' | 'platform-anonymous' | 'authenticated';
95
+ export type IdentityTrustLevel = 'local' | 'platform-asserted' | 'server-verified';
96
+ export interface IdentitySession {
97
+ readonly identityLevel: IdentityLevel;
98
+ readonly playerId?: string;
99
+ readonly trustLevel: IdentityTrustLevel;
100
+ }
101
+ export type IdentityUpgradeReason = 'save' | 'leaderboard' | 'share' | 'notifications';
102
+ export interface IdentityUpgradeResult {
103
+ readonly status: 'completed' | 'cancelled' | 'unavailable';
104
+ readonly reloadExpected: boolean;
105
+ }
92
106
  export interface IdentityAdapter {
93
107
  getPlayer(): Promise<PlayerIdentity | null>;
108
+ getSession?(): Promise<IdentitySession>;
109
+ requestUpgrade?(input: {
110
+ readonly reason: IdentityUpgradeReason;
111
+ }): Promise<IdentityUpgradeResult>;
112
+ }
113
+ export type LaunchEntry = 'home' | 'daily' | 'practice' | 'free-play' | 'continue' | 'leaderboard' | 'friend-challenge';
114
+ export interface LaunchIntent {
115
+ readonly entry: LaunchEntry;
116
+ readonly puzzleId?: string;
117
+ readonly referralToken?: string;
118
+ }
119
+ export type PresentationResult = 'opened' | 'already-fullscreen' | 'unavailable';
120
+ export interface PresentationAdapter {
121
+ getLaunchIntent(): Promise<LaunchIntent>;
122
+ requestGameSurface(intent: LaunchIntent): Promise<PresentationResult>;
123
+ }
124
+ export interface SharePayload {
125
+ readonly puzzleId?: string;
126
+ readonly challengeToken?: string;
127
+ }
128
+ export interface ShareIntent {
129
+ readonly kind: 'daily-result' | 'friend-challenge' | 'invite';
130
+ readonly title: string;
131
+ readonly text: string;
132
+ readonly deepLink: string;
133
+ readonly payload?: SharePayload;
134
+ readonly previewImageUrl?: string;
135
+ }
136
+ export interface ShareResult {
137
+ readonly status: 'shared' | 'cancelled' | 'unavailable';
138
+ }
139
+ export interface InboundShare {
140
+ readonly puzzleId?: string;
141
+ readonly challengeToken?: string;
142
+ }
143
+ export interface ShareAdapter {
144
+ share?(intent: ShareIntent): Promise<ShareResult>;
145
+ readInboundShare?(): Promise<InboundShare | null>;
146
+ }
147
+ export type NotificationTopic = 'daily-ready' | 'streak-at-risk' | 'friend-challenge';
148
+ export type NotificationSubscriptionStatus = 'subscribed' | 'not-subscribed' | 'approval-required' | 'configuration-required' | 'unsupported';
149
+ export type NotificationSubscriptionResult = 'subscribed' | 'rejected' | 'unavailable';
150
+ export interface NotificationSubscriptionAdapter {
151
+ getStatus(topic: NotificationTopic): Promise<NotificationSubscriptionStatus>;
152
+ requestSubscription(topic: NotificationTopic): Promise<NotificationSubscriptionResult>;
94
153
  }
95
154
  export interface LifecycleAdapter {
96
155
  onPause(callback: () => void): () => void;
@@ -117,5 +176,8 @@ export interface PlatformGateway {
117
176
  readonly leaderboard: LeaderboardAdapter;
118
177
  readonly lifecycle: LifecycleAdapter;
119
178
  readonly storage: StorageAdapter;
179
+ readonly presentation?: PresentationAdapter;
180
+ readonly sharing?: ShareAdapter;
181
+ readonly notifications?: NotificationSubscriptionAdapter;
120
182
  }
121
183
  export declare function createUnsupportedCapabilities(): PlatformCapabilities;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpgd/platform",
3
- "version": "0.3.2",
3
+ "version": "0.4.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": {