@oasiz/sdk 1.3.0 → 1.4.1
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.
- package/README.md +15 -63
- package/dist/index.cjs +235 -936
- package/dist/index.d.cts +104 -40
- package/dist/index.d.ts +104 -40
- package/dist/index.js +224 -934
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,24 +1,4 @@
|
|
|
1
1
|
type HapticType = "light" | "medium" | "heavy" | "success" | "error";
|
|
2
|
-
type LogOverlayLevel = "debug" | "log" | "info" | "warn" | "error";
|
|
3
|
-
interface LogOverlayEntry {
|
|
4
|
-
id: number;
|
|
5
|
-
level: LogOverlayLevel;
|
|
6
|
-
message: string;
|
|
7
|
-
timestamp: number;
|
|
8
|
-
}
|
|
9
|
-
interface LogOverlayOptions {
|
|
10
|
-
collapsed?: boolean;
|
|
11
|
-
enabled?: boolean;
|
|
12
|
-
maxEntries?: number;
|
|
13
|
-
title?: string;
|
|
14
|
-
}
|
|
15
|
-
interface LogOverlayHandle {
|
|
16
|
-
clear: () => void;
|
|
17
|
-
destroy: () => void;
|
|
18
|
-
hide: () => void;
|
|
19
|
-
isVisible: () => boolean;
|
|
20
|
-
show: () => void;
|
|
21
|
-
}
|
|
22
2
|
interface ScoreAnchor {
|
|
23
3
|
raw: number;
|
|
24
4
|
normalized: 100 | 300 | 600 | 950;
|
|
@@ -27,26 +7,86 @@ interface ScoreConfig {
|
|
|
27
7
|
anchors: [ScoreAnchor, ScoreAnchor, ScoreAnchor, ScoreAnchor];
|
|
28
8
|
}
|
|
29
9
|
type GameState = Record<string, unknown>;
|
|
10
|
+
interface ShareRequest {
|
|
11
|
+
image?: string;
|
|
12
|
+
score?: number;
|
|
13
|
+
text?: string;
|
|
14
|
+
}
|
|
15
|
+
type StoreProductType = "non-consumable" | "consumable";
|
|
16
|
+
type StoreProductStatus = "active" | "disabled" | "archived";
|
|
17
|
+
type StoreEntitlementStatus = "active" | "consumed" | "revoked" | "refunded";
|
|
18
|
+
interface StoreManifestProduct {
|
|
19
|
+
description?: string | null;
|
|
20
|
+
jemPrice: number;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
productId: string;
|
|
23
|
+
title: string;
|
|
24
|
+
type: StoreProductType;
|
|
25
|
+
}
|
|
26
|
+
interface StoreProduct {
|
|
27
|
+
description: string | null;
|
|
28
|
+
gameId: string;
|
|
29
|
+
jemPrice: number;
|
|
30
|
+
metadata: Record<string, unknown>;
|
|
31
|
+
productId: string;
|
|
32
|
+
status: StoreProductStatus;
|
|
33
|
+
title: string;
|
|
34
|
+
type: StoreProductType;
|
|
35
|
+
version: number;
|
|
36
|
+
}
|
|
37
|
+
interface StoreEntitlement {
|
|
38
|
+
gameId: string;
|
|
39
|
+
grantedAt: string | null;
|
|
40
|
+
lastEventId: string | null;
|
|
41
|
+
owned: boolean;
|
|
42
|
+
productId: string;
|
|
43
|
+
quantity: number;
|
|
44
|
+
status: StoreEntitlementStatus;
|
|
45
|
+
updatedAt: string;
|
|
46
|
+
}
|
|
47
|
+
interface StoreStateSnapshot {
|
|
48
|
+
catalogVersion: number;
|
|
49
|
+
entitlements: StoreEntitlement[];
|
|
50
|
+
gameId: string;
|
|
51
|
+
jemBalance: number;
|
|
52
|
+
products: StoreProduct[];
|
|
53
|
+
}
|
|
54
|
+
interface StorePurchaseSuccess {
|
|
55
|
+
attemptId: string;
|
|
56
|
+
entitlement: StoreEntitlement;
|
|
57
|
+
jemBalance: number;
|
|
58
|
+
ok: true;
|
|
59
|
+
state: StoreStateSnapshot;
|
|
60
|
+
transactionId: string;
|
|
61
|
+
}
|
|
62
|
+
interface StorePurchaseFailure {
|
|
63
|
+
attemptId: string;
|
|
64
|
+
code: "ALREADY_OWNED" | "INSUFFICIENT_JEMS" | "INVALID_PRODUCT" | "PRODUCT_DISABLED" | "INVALID_QUANTITY" | "ENTITLEMENT_EXHAUSTED" | "STALE_CATALOG_VERSION" | "UNAUTHORIZED";
|
|
65
|
+
jemBalance: number;
|
|
66
|
+
message: string;
|
|
67
|
+
ok: false;
|
|
68
|
+
state?: StoreStateSnapshot;
|
|
69
|
+
topUpIntentId?: string;
|
|
70
|
+
topUpRedirectUrl?: string;
|
|
71
|
+
}
|
|
72
|
+
type StorePurchaseResult = StorePurchaseSuccess | StorePurchaseFailure;
|
|
73
|
+
interface StoreConsumeSuccess {
|
|
74
|
+
entitlement: StoreEntitlement;
|
|
75
|
+
ok: true;
|
|
76
|
+
state: StoreStateSnapshot;
|
|
77
|
+
}
|
|
78
|
+
interface StoreConsumeFailure {
|
|
79
|
+
code: "INVALID_PRODUCT" | "INVALID_QUANTITY" | "NOT_CONSUMABLE" | "ENTITLEMENT_EXHAUSTED";
|
|
80
|
+
jemBalance: number;
|
|
81
|
+
message: string;
|
|
82
|
+
ok: false;
|
|
83
|
+
state?: StoreStateSnapshot;
|
|
84
|
+
}
|
|
85
|
+
type StoreConsumeResult = StoreConsumeSuccess | StoreConsumeFailure;
|
|
30
86
|
|
|
31
87
|
declare function triggerHaptic(type: HapticType): void;
|
|
32
88
|
|
|
33
|
-
declare function
|
|
34
|
-
|
|
35
|
-
interface ShareRoomCodeOptions {
|
|
36
|
-
inviteOverride?: boolean;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Notify the platform of the active multiplayer room so friends can join.
|
|
40
|
-
* Pass `{ inviteOverride: true }` when the game wants to hide the platform
|
|
41
|
-
* invite pill and own the invite UI itself.
|
|
42
|
-
*/
|
|
43
|
-
declare function shareRoomCode(roomCode: string | null, options?: ShareRoomCodeOptions): void;
|
|
44
|
-
/**
|
|
45
|
-
* Ask the platform to open the invite-friends modal for the current game room.
|
|
46
|
-
* Only has effect when the platform has a room code (game has called shareRoomCode).
|
|
47
|
-
* No-op when the bridge is unavailable (e.g. local development).
|
|
48
|
-
*/
|
|
49
|
-
declare function openInviteModal(): void;
|
|
89
|
+
declare function shareRoomCode(roomCode: string | null): void;
|
|
50
90
|
declare function getGameId(): string | undefined;
|
|
51
91
|
declare function getRoomCode(): string | undefined;
|
|
52
92
|
declare function getPlayerName(): string | undefined;
|
|
@@ -55,6 +95,8 @@ declare function getPlayerAvatar(): string | undefined;
|
|
|
55
95
|
declare function submitScore(score: number): void;
|
|
56
96
|
declare function emitScoreConfig(config: ScoreConfig): void;
|
|
57
97
|
|
|
98
|
+
declare function share(options: ShareRequest): Promise<void>;
|
|
99
|
+
|
|
58
100
|
declare function loadGameState(): GameState;
|
|
59
101
|
declare function saveGameState(state: GameState): void;
|
|
60
102
|
declare function flushGameState(): void;
|
|
@@ -67,25 +109,47 @@ declare function onBackButton(callback: () => void): Unsubscribe;
|
|
|
67
109
|
declare function onLeaveGame(callback: () => void): Unsubscribe;
|
|
68
110
|
declare function leaveGame(): void;
|
|
69
111
|
|
|
112
|
+
declare function syncProducts(products: StoreManifestProduct[], expectedVersion?: number | null): Promise<StoreStateSnapshot>;
|
|
113
|
+
declare function getProducts(): Promise<StoreProduct[]>;
|
|
114
|
+
declare function getEntitlements(): Promise<StoreEntitlement[]>;
|
|
115
|
+
declare function hasEntitlement(productId: string): Promise<boolean>;
|
|
116
|
+
declare function getQuantity(productId: string): Promise<number>;
|
|
117
|
+
declare function purchase(productId: string, quantity?: number): Promise<StorePurchaseResult>;
|
|
118
|
+
declare function consume(productId: string, quantity?: number): Promise<StoreConsumeResult>;
|
|
119
|
+
declare function getJemBalance(): Promise<number>;
|
|
120
|
+
declare function onEntitlementsChanged(callback: (entitlements: StoreEntitlement[]) => void): () => void;
|
|
121
|
+
declare function onJemBalanceChanged(callback: (jemBalance: number) => void): () => void;
|
|
122
|
+
|
|
70
123
|
declare const oasiz: {
|
|
71
124
|
submitScore: typeof submitScore;
|
|
72
125
|
emitScoreConfig: typeof emitScoreConfig;
|
|
126
|
+
share: typeof share;
|
|
73
127
|
triggerHaptic: typeof triggerHaptic;
|
|
74
|
-
enableLogOverlay: typeof enableLogOverlay;
|
|
75
128
|
loadGameState: typeof loadGameState;
|
|
76
129
|
saveGameState: typeof saveGameState;
|
|
77
130
|
flushGameState: typeof flushGameState;
|
|
78
131
|
shareRoomCode: typeof shareRoomCode;
|
|
79
|
-
openInviteModal: typeof openInviteModal;
|
|
80
132
|
onPause: typeof onPause;
|
|
81
133
|
onResume: typeof onResume;
|
|
82
134
|
onBackButton: typeof onBackButton;
|
|
83
135
|
onLeaveGame: typeof onLeaveGame;
|
|
84
136
|
leaveGame: typeof leaveGame;
|
|
137
|
+
store: {
|
|
138
|
+
syncProducts: typeof syncProducts;
|
|
139
|
+
getProducts: typeof getProducts;
|
|
140
|
+
getEntitlements: typeof getEntitlements;
|
|
141
|
+
hasEntitlement: typeof hasEntitlement;
|
|
142
|
+
getQuantity: typeof getQuantity;
|
|
143
|
+
purchase: typeof purchase;
|
|
144
|
+
consume: typeof consume;
|
|
145
|
+
getJemBalance: typeof getJemBalance;
|
|
146
|
+
onEntitlementsChanged: typeof onEntitlementsChanged;
|
|
147
|
+
onJemBalanceChanged: typeof onJemBalanceChanged;
|
|
148
|
+
};
|
|
85
149
|
readonly gameId: string | undefined;
|
|
86
150
|
readonly roomCode: string | undefined;
|
|
87
151
|
readonly playerName: string | undefined;
|
|
88
152
|
readonly playerAvatar: string | undefined;
|
|
89
153
|
};
|
|
90
154
|
|
|
91
|
-
export { type GameState, type HapticType, type
|
|
155
|
+
export { type GameState, type HapticType, type ScoreAnchor, type ScoreConfig, type ShareRequest, type StoreConsumeFailure, type StoreConsumeResult, type StoreConsumeSuccess, type StoreEntitlement, type StoreEntitlementStatus, type StoreManifestProduct, type StoreProduct, type StoreProductStatus, type StoreProductType, type StorePurchaseFailure, type StorePurchaseResult, type StorePurchaseSuccess, type StoreStateSnapshot, type Unsubscribe, consume, emitScoreConfig, flushGameState, getEntitlements, getGameId, getJemBalance, getPlayerAvatar, getPlayerName, getProducts, getQuantity, getRoomCode, hasEntitlement, leaveGame, loadGameState, oasiz, onBackButton, onEntitlementsChanged, onJemBalanceChanged, onLeaveGame, onPause, onResume, purchase, saveGameState, share, shareRoomCode, submitScore, syncProducts, triggerHaptic };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,4 @@
|
|
|
1
1
|
type HapticType = "light" | "medium" | "heavy" | "success" | "error";
|
|
2
|
-
type LogOverlayLevel = "debug" | "log" | "info" | "warn" | "error";
|
|
3
|
-
interface LogOverlayEntry {
|
|
4
|
-
id: number;
|
|
5
|
-
level: LogOverlayLevel;
|
|
6
|
-
message: string;
|
|
7
|
-
timestamp: number;
|
|
8
|
-
}
|
|
9
|
-
interface LogOverlayOptions {
|
|
10
|
-
collapsed?: boolean;
|
|
11
|
-
enabled?: boolean;
|
|
12
|
-
maxEntries?: number;
|
|
13
|
-
title?: string;
|
|
14
|
-
}
|
|
15
|
-
interface LogOverlayHandle {
|
|
16
|
-
clear: () => void;
|
|
17
|
-
destroy: () => void;
|
|
18
|
-
hide: () => void;
|
|
19
|
-
isVisible: () => boolean;
|
|
20
|
-
show: () => void;
|
|
21
|
-
}
|
|
22
2
|
interface ScoreAnchor {
|
|
23
3
|
raw: number;
|
|
24
4
|
normalized: 100 | 300 | 600 | 950;
|
|
@@ -27,26 +7,86 @@ interface ScoreConfig {
|
|
|
27
7
|
anchors: [ScoreAnchor, ScoreAnchor, ScoreAnchor, ScoreAnchor];
|
|
28
8
|
}
|
|
29
9
|
type GameState = Record<string, unknown>;
|
|
10
|
+
interface ShareRequest {
|
|
11
|
+
image?: string;
|
|
12
|
+
score?: number;
|
|
13
|
+
text?: string;
|
|
14
|
+
}
|
|
15
|
+
type StoreProductType = "non-consumable" | "consumable";
|
|
16
|
+
type StoreProductStatus = "active" | "disabled" | "archived";
|
|
17
|
+
type StoreEntitlementStatus = "active" | "consumed" | "revoked" | "refunded";
|
|
18
|
+
interface StoreManifestProduct {
|
|
19
|
+
description?: string | null;
|
|
20
|
+
jemPrice: number;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
productId: string;
|
|
23
|
+
title: string;
|
|
24
|
+
type: StoreProductType;
|
|
25
|
+
}
|
|
26
|
+
interface StoreProduct {
|
|
27
|
+
description: string | null;
|
|
28
|
+
gameId: string;
|
|
29
|
+
jemPrice: number;
|
|
30
|
+
metadata: Record<string, unknown>;
|
|
31
|
+
productId: string;
|
|
32
|
+
status: StoreProductStatus;
|
|
33
|
+
title: string;
|
|
34
|
+
type: StoreProductType;
|
|
35
|
+
version: number;
|
|
36
|
+
}
|
|
37
|
+
interface StoreEntitlement {
|
|
38
|
+
gameId: string;
|
|
39
|
+
grantedAt: string | null;
|
|
40
|
+
lastEventId: string | null;
|
|
41
|
+
owned: boolean;
|
|
42
|
+
productId: string;
|
|
43
|
+
quantity: number;
|
|
44
|
+
status: StoreEntitlementStatus;
|
|
45
|
+
updatedAt: string;
|
|
46
|
+
}
|
|
47
|
+
interface StoreStateSnapshot {
|
|
48
|
+
catalogVersion: number;
|
|
49
|
+
entitlements: StoreEntitlement[];
|
|
50
|
+
gameId: string;
|
|
51
|
+
jemBalance: number;
|
|
52
|
+
products: StoreProduct[];
|
|
53
|
+
}
|
|
54
|
+
interface StorePurchaseSuccess {
|
|
55
|
+
attemptId: string;
|
|
56
|
+
entitlement: StoreEntitlement;
|
|
57
|
+
jemBalance: number;
|
|
58
|
+
ok: true;
|
|
59
|
+
state: StoreStateSnapshot;
|
|
60
|
+
transactionId: string;
|
|
61
|
+
}
|
|
62
|
+
interface StorePurchaseFailure {
|
|
63
|
+
attemptId: string;
|
|
64
|
+
code: "ALREADY_OWNED" | "INSUFFICIENT_JEMS" | "INVALID_PRODUCT" | "PRODUCT_DISABLED" | "INVALID_QUANTITY" | "ENTITLEMENT_EXHAUSTED" | "STALE_CATALOG_VERSION" | "UNAUTHORIZED";
|
|
65
|
+
jemBalance: number;
|
|
66
|
+
message: string;
|
|
67
|
+
ok: false;
|
|
68
|
+
state?: StoreStateSnapshot;
|
|
69
|
+
topUpIntentId?: string;
|
|
70
|
+
topUpRedirectUrl?: string;
|
|
71
|
+
}
|
|
72
|
+
type StorePurchaseResult = StorePurchaseSuccess | StorePurchaseFailure;
|
|
73
|
+
interface StoreConsumeSuccess {
|
|
74
|
+
entitlement: StoreEntitlement;
|
|
75
|
+
ok: true;
|
|
76
|
+
state: StoreStateSnapshot;
|
|
77
|
+
}
|
|
78
|
+
interface StoreConsumeFailure {
|
|
79
|
+
code: "INVALID_PRODUCT" | "INVALID_QUANTITY" | "NOT_CONSUMABLE" | "ENTITLEMENT_EXHAUSTED";
|
|
80
|
+
jemBalance: number;
|
|
81
|
+
message: string;
|
|
82
|
+
ok: false;
|
|
83
|
+
state?: StoreStateSnapshot;
|
|
84
|
+
}
|
|
85
|
+
type StoreConsumeResult = StoreConsumeSuccess | StoreConsumeFailure;
|
|
30
86
|
|
|
31
87
|
declare function triggerHaptic(type: HapticType): void;
|
|
32
88
|
|
|
33
|
-
declare function
|
|
34
|
-
|
|
35
|
-
interface ShareRoomCodeOptions {
|
|
36
|
-
inviteOverride?: boolean;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Notify the platform of the active multiplayer room so friends can join.
|
|
40
|
-
* Pass `{ inviteOverride: true }` when the game wants to hide the platform
|
|
41
|
-
* invite pill and own the invite UI itself.
|
|
42
|
-
*/
|
|
43
|
-
declare function shareRoomCode(roomCode: string | null, options?: ShareRoomCodeOptions): void;
|
|
44
|
-
/**
|
|
45
|
-
* Ask the platform to open the invite-friends modal for the current game room.
|
|
46
|
-
* Only has effect when the platform has a room code (game has called shareRoomCode).
|
|
47
|
-
* No-op when the bridge is unavailable (e.g. local development).
|
|
48
|
-
*/
|
|
49
|
-
declare function openInviteModal(): void;
|
|
89
|
+
declare function shareRoomCode(roomCode: string | null): void;
|
|
50
90
|
declare function getGameId(): string | undefined;
|
|
51
91
|
declare function getRoomCode(): string | undefined;
|
|
52
92
|
declare function getPlayerName(): string | undefined;
|
|
@@ -55,6 +95,8 @@ declare function getPlayerAvatar(): string | undefined;
|
|
|
55
95
|
declare function submitScore(score: number): void;
|
|
56
96
|
declare function emitScoreConfig(config: ScoreConfig): void;
|
|
57
97
|
|
|
98
|
+
declare function share(options: ShareRequest): Promise<void>;
|
|
99
|
+
|
|
58
100
|
declare function loadGameState(): GameState;
|
|
59
101
|
declare function saveGameState(state: GameState): void;
|
|
60
102
|
declare function flushGameState(): void;
|
|
@@ -67,25 +109,47 @@ declare function onBackButton(callback: () => void): Unsubscribe;
|
|
|
67
109
|
declare function onLeaveGame(callback: () => void): Unsubscribe;
|
|
68
110
|
declare function leaveGame(): void;
|
|
69
111
|
|
|
112
|
+
declare function syncProducts(products: StoreManifestProduct[], expectedVersion?: number | null): Promise<StoreStateSnapshot>;
|
|
113
|
+
declare function getProducts(): Promise<StoreProduct[]>;
|
|
114
|
+
declare function getEntitlements(): Promise<StoreEntitlement[]>;
|
|
115
|
+
declare function hasEntitlement(productId: string): Promise<boolean>;
|
|
116
|
+
declare function getQuantity(productId: string): Promise<number>;
|
|
117
|
+
declare function purchase(productId: string, quantity?: number): Promise<StorePurchaseResult>;
|
|
118
|
+
declare function consume(productId: string, quantity?: number): Promise<StoreConsumeResult>;
|
|
119
|
+
declare function getJemBalance(): Promise<number>;
|
|
120
|
+
declare function onEntitlementsChanged(callback: (entitlements: StoreEntitlement[]) => void): () => void;
|
|
121
|
+
declare function onJemBalanceChanged(callback: (jemBalance: number) => void): () => void;
|
|
122
|
+
|
|
70
123
|
declare const oasiz: {
|
|
71
124
|
submitScore: typeof submitScore;
|
|
72
125
|
emitScoreConfig: typeof emitScoreConfig;
|
|
126
|
+
share: typeof share;
|
|
73
127
|
triggerHaptic: typeof triggerHaptic;
|
|
74
|
-
enableLogOverlay: typeof enableLogOverlay;
|
|
75
128
|
loadGameState: typeof loadGameState;
|
|
76
129
|
saveGameState: typeof saveGameState;
|
|
77
130
|
flushGameState: typeof flushGameState;
|
|
78
131
|
shareRoomCode: typeof shareRoomCode;
|
|
79
|
-
openInviteModal: typeof openInviteModal;
|
|
80
132
|
onPause: typeof onPause;
|
|
81
133
|
onResume: typeof onResume;
|
|
82
134
|
onBackButton: typeof onBackButton;
|
|
83
135
|
onLeaveGame: typeof onLeaveGame;
|
|
84
136
|
leaveGame: typeof leaveGame;
|
|
137
|
+
store: {
|
|
138
|
+
syncProducts: typeof syncProducts;
|
|
139
|
+
getProducts: typeof getProducts;
|
|
140
|
+
getEntitlements: typeof getEntitlements;
|
|
141
|
+
hasEntitlement: typeof hasEntitlement;
|
|
142
|
+
getQuantity: typeof getQuantity;
|
|
143
|
+
purchase: typeof purchase;
|
|
144
|
+
consume: typeof consume;
|
|
145
|
+
getJemBalance: typeof getJemBalance;
|
|
146
|
+
onEntitlementsChanged: typeof onEntitlementsChanged;
|
|
147
|
+
onJemBalanceChanged: typeof onJemBalanceChanged;
|
|
148
|
+
};
|
|
85
149
|
readonly gameId: string | undefined;
|
|
86
150
|
readonly roomCode: string | undefined;
|
|
87
151
|
readonly playerName: string | undefined;
|
|
88
152
|
readonly playerAvatar: string | undefined;
|
|
89
153
|
};
|
|
90
154
|
|
|
91
|
-
export { type GameState, type HapticType, type
|
|
155
|
+
export { type GameState, type HapticType, type ScoreAnchor, type ScoreConfig, type ShareRequest, type StoreConsumeFailure, type StoreConsumeResult, type StoreConsumeSuccess, type StoreEntitlement, type StoreEntitlementStatus, type StoreManifestProduct, type StoreProduct, type StoreProductStatus, type StoreProductType, type StorePurchaseFailure, type StorePurchaseResult, type StorePurchaseSuccess, type StoreStateSnapshot, type Unsubscribe, consume, emitScoreConfig, flushGameState, getEntitlements, getGameId, getJemBalance, getPlayerAvatar, getPlayerName, getProducts, getQuantity, getRoomCode, hasEntitlement, leaveGame, loadGameState, oasiz, onBackButton, onEntitlementsChanged, onJemBalanceChanged, onLeaveGame, onPause, onResume, purchase, saveGameState, share, shareRoomCode, submitScore, syncProducts, triggerHaptic };
|