@oasiz/sdk 1.0.2 → 1.2.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.
- package/README.md +20 -1
- package/dist/index.cjs +17 -2
- package/dist/index.d.cts +17 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.js +16 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -260,10 +260,12 @@ offLeave();
|
|
|
260
260
|
|
|
261
261
|
## Multiplayer
|
|
262
262
|
|
|
263
|
-
### `oasiz.shareRoomCode(code: string | null)`
|
|
263
|
+
### `oasiz.shareRoomCode(code: string | null, options?: { inviteOverride?: boolean })`
|
|
264
264
|
|
|
265
265
|
Notify the platform of the active multiplayer room so friends can join via the invite system. Pass `null` when leaving a room.
|
|
266
266
|
|
|
267
|
+
Set `inviteOverride: true` when your game wants to hide the platform invite pill and render its own invite button/UI. The platform still tracks the room code, but your game owns the invite entry point.
|
|
268
|
+
|
|
267
269
|
```ts
|
|
268
270
|
import { insertCoin, getRoomCode } from "playroomkit";
|
|
269
271
|
import { oasiz } from "@oasiz/sdk";
|
|
@@ -275,6 +277,23 @@ oasiz.shareRoomCode(getRoomCode());
|
|
|
275
277
|
oasiz.shareRoomCode(null);
|
|
276
278
|
```
|
|
277
279
|
|
|
280
|
+
```ts
|
|
281
|
+
// Game-owned invite UI: hide the platform pill, keep room tracking
|
|
282
|
+
oasiz.shareRoomCode(getRoomCode(), { inviteOverride: true });
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
If you still want to use the platform invite sheet from your own in-game button, combine it with `openInviteModal()`:
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
import { openInviteModal, shareRoomCode } from "@oasiz/sdk";
|
|
289
|
+
|
|
290
|
+
shareRoomCode("ABCD", { inviteOverride: true });
|
|
291
|
+
|
|
292
|
+
inviteButton.addEventListener("click", () => {
|
|
293
|
+
openInviteModal();
|
|
294
|
+
});
|
|
295
|
+
```
|
|
296
|
+
|
|
278
297
|
### Read-only injected values
|
|
279
298
|
|
|
280
299
|
These are populated by the platform before the game loads. Always check for `undefined` before using.
|
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
onLeaveGame: () => onLeaveGame,
|
|
34
34
|
onPause: () => onPause,
|
|
35
35
|
onResume: () => onResume,
|
|
36
|
+
openInviteModal: () => openInviteModal,
|
|
36
37
|
saveGameState: () => saveGameState,
|
|
37
38
|
shareRoomCode: () => shareRoomCode,
|
|
38
39
|
submitScore: () => submitScore,
|
|
@@ -75,10 +76,10 @@ function getBridgeWindow2() {
|
|
|
75
76
|
}
|
|
76
77
|
return window;
|
|
77
78
|
}
|
|
78
|
-
function shareRoomCode(roomCode) {
|
|
79
|
+
function shareRoomCode(roomCode, options) {
|
|
79
80
|
const bridge = getBridgeWindow2();
|
|
80
81
|
if (typeof bridge?.shareRoomCode === "function") {
|
|
81
|
-
bridge.shareRoomCode(roomCode);
|
|
82
|
+
bridge.shareRoomCode(roomCode, options);
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
85
|
if (isDevelopment2()) {
|
|
@@ -87,6 +88,18 @@ function shareRoomCode(roomCode) {
|
|
|
87
88
|
);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
91
|
+
function openInviteModal() {
|
|
92
|
+
const bridge = getBridgeWindow2();
|
|
93
|
+
if (typeof bridge?.openInviteModal === "function") {
|
|
94
|
+
bridge.openInviteModal();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (isDevelopment2()) {
|
|
98
|
+
console.warn(
|
|
99
|
+
"[oasiz/sdk] openInviteModal bridge is unavailable. This is expected in local development."
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
90
103
|
function getGameId() {
|
|
91
104
|
const bridge = getBridgeWindow2();
|
|
92
105
|
return bridge?.__GAME_ID__;
|
|
@@ -315,6 +328,7 @@ var oasiz = {
|
|
|
315
328
|
saveGameState,
|
|
316
329
|
flushGameState,
|
|
317
330
|
shareRoomCode,
|
|
331
|
+
openInviteModal,
|
|
318
332
|
onPause,
|
|
319
333
|
onResume,
|
|
320
334
|
onBackButton,
|
|
@@ -348,6 +362,7 @@ var oasiz = {
|
|
|
348
362
|
onLeaveGame,
|
|
349
363
|
onPause,
|
|
350
364
|
onResume,
|
|
365
|
+
openInviteModal,
|
|
351
366
|
saveGameState,
|
|
352
367
|
shareRoomCode,
|
|
353
368
|
submitScore,
|
package/dist/index.d.cts
CHANGED
|
@@ -10,7 +10,21 @@ type GameState = Record<string, unknown>;
|
|
|
10
10
|
|
|
11
11
|
declare function triggerHaptic(type: HapticType): void;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
interface ShareRoomCodeOptions {
|
|
14
|
+
inviteOverride?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Notify the platform of the active multiplayer room so friends can join.
|
|
18
|
+
* Pass `{ inviteOverride: true }` when the game wants to hide the platform
|
|
19
|
+
* invite pill and own the invite UI itself.
|
|
20
|
+
*/
|
|
21
|
+
declare function shareRoomCode(roomCode: string | null, options?: ShareRoomCodeOptions): void;
|
|
22
|
+
/**
|
|
23
|
+
* Ask the platform to open the invite-friends modal for the current game room.
|
|
24
|
+
* Only has effect when the platform has a room code (game has called shareRoomCode).
|
|
25
|
+
* No-op when the bridge is unavailable (e.g. local development).
|
|
26
|
+
*/
|
|
27
|
+
declare function openInviteModal(): void;
|
|
14
28
|
declare function getGameId(): string | undefined;
|
|
15
29
|
declare function getRoomCode(): string | undefined;
|
|
16
30
|
declare function getPlayerName(): string | undefined;
|
|
@@ -39,6 +53,7 @@ declare const oasiz: {
|
|
|
39
53
|
saveGameState: typeof saveGameState;
|
|
40
54
|
flushGameState: typeof flushGameState;
|
|
41
55
|
shareRoomCode: typeof shareRoomCode;
|
|
56
|
+
openInviteModal: typeof openInviteModal;
|
|
42
57
|
onPause: typeof onPause;
|
|
43
58
|
onResume: typeof onResume;
|
|
44
59
|
onBackButton: typeof onBackButton;
|
|
@@ -50,4 +65,4 @@ declare const oasiz: {
|
|
|
50
65
|
readonly playerAvatar: string | undefined;
|
|
51
66
|
};
|
|
52
67
|
|
|
53
|
-
export { type GameState, type HapticType, type ScoreAnchor, type ScoreConfig, type Unsubscribe, emitScoreConfig, flushGameState, getGameId, getPlayerAvatar, getPlayerName, getRoomCode, leaveGame, loadGameState, oasiz, onBackButton, onLeaveGame, onPause, onResume, saveGameState, shareRoomCode, submitScore, triggerHaptic };
|
|
68
|
+
export { type GameState, type HapticType, type ScoreAnchor, type ScoreConfig, type ShareRoomCodeOptions, type Unsubscribe, emitScoreConfig, flushGameState, getGameId, getPlayerAvatar, getPlayerName, getRoomCode, leaveGame, loadGameState, oasiz, onBackButton, onLeaveGame, onPause, onResume, openInviteModal, saveGameState, shareRoomCode, submitScore, triggerHaptic };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,21 @@ type GameState = Record<string, unknown>;
|
|
|
10
10
|
|
|
11
11
|
declare function triggerHaptic(type: HapticType): void;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
interface ShareRoomCodeOptions {
|
|
14
|
+
inviteOverride?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Notify the platform of the active multiplayer room so friends can join.
|
|
18
|
+
* Pass `{ inviteOverride: true }` when the game wants to hide the platform
|
|
19
|
+
* invite pill and own the invite UI itself.
|
|
20
|
+
*/
|
|
21
|
+
declare function shareRoomCode(roomCode: string | null, options?: ShareRoomCodeOptions): void;
|
|
22
|
+
/**
|
|
23
|
+
* Ask the platform to open the invite-friends modal for the current game room.
|
|
24
|
+
* Only has effect when the platform has a room code (game has called shareRoomCode).
|
|
25
|
+
* No-op when the bridge is unavailable (e.g. local development).
|
|
26
|
+
*/
|
|
27
|
+
declare function openInviteModal(): void;
|
|
14
28
|
declare function getGameId(): string | undefined;
|
|
15
29
|
declare function getRoomCode(): string | undefined;
|
|
16
30
|
declare function getPlayerName(): string | undefined;
|
|
@@ -39,6 +53,7 @@ declare const oasiz: {
|
|
|
39
53
|
saveGameState: typeof saveGameState;
|
|
40
54
|
flushGameState: typeof flushGameState;
|
|
41
55
|
shareRoomCode: typeof shareRoomCode;
|
|
56
|
+
openInviteModal: typeof openInviteModal;
|
|
42
57
|
onPause: typeof onPause;
|
|
43
58
|
onResume: typeof onResume;
|
|
44
59
|
onBackButton: typeof onBackButton;
|
|
@@ -50,4 +65,4 @@ declare const oasiz: {
|
|
|
50
65
|
readonly playerAvatar: string | undefined;
|
|
51
66
|
};
|
|
52
67
|
|
|
53
|
-
export { type GameState, type HapticType, type ScoreAnchor, type ScoreConfig, type Unsubscribe, emitScoreConfig, flushGameState, getGameId, getPlayerAvatar, getPlayerName, getRoomCode, leaveGame, loadGameState, oasiz, onBackButton, onLeaveGame, onPause, onResume, saveGameState, shareRoomCode, submitScore, triggerHaptic };
|
|
68
|
+
export { type GameState, type HapticType, type ScoreAnchor, type ScoreConfig, type ShareRoomCodeOptions, type Unsubscribe, emitScoreConfig, flushGameState, getGameId, getPlayerAvatar, getPlayerName, getRoomCode, leaveGame, loadGameState, oasiz, onBackButton, onLeaveGame, onPause, onResume, openInviteModal, saveGameState, shareRoomCode, submitScore, triggerHaptic };
|
package/dist/index.js
CHANGED
|
@@ -33,10 +33,10 @@ function getBridgeWindow2() {
|
|
|
33
33
|
}
|
|
34
34
|
return window;
|
|
35
35
|
}
|
|
36
|
-
function shareRoomCode(roomCode) {
|
|
36
|
+
function shareRoomCode(roomCode, options) {
|
|
37
37
|
const bridge = getBridgeWindow2();
|
|
38
38
|
if (typeof bridge?.shareRoomCode === "function") {
|
|
39
|
-
bridge.shareRoomCode(roomCode);
|
|
39
|
+
bridge.shareRoomCode(roomCode, options);
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
if (isDevelopment2()) {
|
|
@@ -45,6 +45,18 @@ function shareRoomCode(roomCode) {
|
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
function openInviteModal() {
|
|
49
|
+
const bridge = getBridgeWindow2();
|
|
50
|
+
if (typeof bridge?.openInviteModal === "function") {
|
|
51
|
+
bridge.openInviteModal();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (isDevelopment2()) {
|
|
55
|
+
console.warn(
|
|
56
|
+
"[oasiz/sdk] openInviteModal bridge is unavailable. This is expected in local development."
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
48
60
|
function getGameId() {
|
|
49
61
|
const bridge = getBridgeWindow2();
|
|
50
62
|
return bridge?.__GAME_ID__;
|
|
@@ -273,6 +285,7 @@ var oasiz = {
|
|
|
273
285
|
saveGameState,
|
|
274
286
|
flushGameState,
|
|
275
287
|
shareRoomCode,
|
|
288
|
+
openInviteModal,
|
|
276
289
|
onPause,
|
|
277
290
|
onResume,
|
|
278
291
|
onBackButton,
|
|
@@ -305,6 +318,7 @@ export {
|
|
|
305
318
|
onLeaveGame,
|
|
306
319
|
onPause,
|
|
307
320
|
onResume,
|
|
321
|
+
openInviteModal,
|
|
308
322
|
saveGameState,
|
|
309
323
|
shareRoomCode,
|
|
310
324
|
submitScore,
|