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