@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/README.md
CHANGED
|
@@ -35,12 +35,6 @@ oasiz.triggerHaptic("medium");
|
|
|
35
35
|
|
|
36
36
|
// 5. Submit score when the game ends
|
|
37
37
|
oasiz.submitScore(score);
|
|
38
|
-
|
|
39
|
-
// 6. Optionally surface console logs in-game while debugging
|
|
40
|
-
oasiz.enableLogOverlay({
|
|
41
|
-
enabled: new URLSearchParams(window.location.search).has("oasizLogs"),
|
|
42
|
-
collapsed: true,
|
|
43
|
-
});
|
|
44
38
|
```
|
|
45
39
|
|
|
46
40
|
---
|
|
@@ -134,34 +128,6 @@ Haptics are throttled internally (50ms cooldown) to prevent spam.
|
|
|
134
128
|
|
|
135
129
|
---
|
|
136
130
|
|
|
137
|
-
## Debugging
|
|
138
|
-
|
|
139
|
-
### `oasiz.enableLogOverlay(options?: LogOverlayOptions)`
|
|
140
|
-
|
|
141
|
-
Mount an opt-in in-game console viewer for local debugging, QA sessions, or creator support. It mirrors `console.log`, `console.info`, `console.warn`, `console.error`, and `console.debug` into a floating overlay inside the game iframe. The overlay can be collapsed, repositioned by dragging the top bar, and resized from the bottom-right corner while the action buttons remain clickable.
|
|
142
|
-
|
|
143
|
-
```ts
|
|
144
|
-
const logOverlay = oasiz.enableLogOverlay({
|
|
145
|
-
enabled: new URLSearchParams(window.location.search).has("oasizLogs"),
|
|
146
|
-
collapsed: true,
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
console.log("[Boot] Scene ready");
|
|
150
|
-
|
|
151
|
-
// Optional cleanup if your game tears down and remounts
|
|
152
|
-
logOverlay.destroy();
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Options:
|
|
156
|
-
- `enabled`: defaults to `true`. Pass your own flag or query-param check here.
|
|
157
|
-
- `collapsed`: start with only the toggle pill visible.
|
|
158
|
-
- `maxEntries`: cap retained log lines. Defaults to `200`.
|
|
159
|
-
- `title`: optional label shown at the top of the panel. Defaults to `SDK Logs`.
|
|
160
|
-
|
|
161
|
-
The returned handle supports `show()`, `hide()`, `clear()`, `isVisible()`, and `destroy()`.
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
131
|
## Game state persistence
|
|
166
132
|
|
|
167
133
|
Persist cross-session data such as unlocked levels, inventory, or lifetime stats. State is stored per-user per-game in the Oasiz backend — available across devices and app reinstalls.
|
|
@@ -253,6 +219,8 @@ Registers a callback for platform back actions. While at least one back listener
|
|
|
253
219
|
|
|
254
220
|
Use this for pause menus, in-game overlays, or custom back-stack behavior.
|
|
255
221
|
|
|
222
|
+
If your callback throws, Oasiz falls back to closing the game and returning the player to Oasiz home before rethrowing the error for debugging/reporting.
|
|
223
|
+
|
|
256
224
|
```ts
|
|
257
225
|
const offBack = oasiz.onBackButton(() => {
|
|
258
226
|
if (this.isPauseMenuOpen) {
|
|
@@ -276,6 +244,17 @@ quitButton.addEventListener("click", () => {
|
|
|
276
244
|
});
|
|
277
245
|
```
|
|
278
246
|
|
|
247
|
+
### `oasiz.share(options: { text?: string; score?: number; image?: string }): Promise<void>`
|
|
248
|
+
|
|
249
|
+
Ask the host to open the same share flow Oasiz already uses today. Use `text` to customize the share message, `score` to trigger a challenge-style share, and `image` to share an `http(s)` URL or `data:image/...` payload.
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
await oasiz.share({
|
|
253
|
+
text: "I made it to level 9!",
|
|
254
|
+
score: 4200,
|
|
255
|
+
});
|
|
256
|
+
```
|
|
257
|
+
|
|
279
258
|
### `oasiz.onLeaveGame(callback: () => void): Unsubscribe`
|
|
280
259
|
|
|
281
260
|
Registers a callback fired when the host initiates closing the game (for example, close button, gesture, or host navigation). Use this for lightweight cleanup.
|
|
@@ -294,12 +273,10 @@ offLeave();
|
|
|
294
273
|
|
|
295
274
|
## Multiplayer
|
|
296
275
|
|
|
297
|
-
### `oasiz.shareRoomCode(code: string | null
|
|
276
|
+
### `oasiz.shareRoomCode(code: string | null)`
|
|
298
277
|
|
|
299
278
|
Notify the platform of the active multiplayer room so friends can join via the invite system. Pass `null` when leaving a room.
|
|
300
279
|
|
|
301
|
-
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.
|
|
302
|
-
|
|
303
280
|
```ts
|
|
304
281
|
import { insertCoin, getRoomCode } from "playroomkit";
|
|
305
282
|
import { oasiz } from "@oasiz/sdk";
|
|
@@ -311,23 +288,6 @@ oasiz.shareRoomCode(getRoomCode());
|
|
|
311
288
|
oasiz.shareRoomCode(null);
|
|
312
289
|
```
|
|
313
290
|
|
|
314
|
-
```ts
|
|
315
|
-
// Game-owned invite UI: hide the platform pill, keep room tracking
|
|
316
|
-
oasiz.shareRoomCode(getRoomCode(), { inviteOverride: true });
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
If you still want to use the platform invite sheet from your own in-game button, combine it with `openInviteModal()`:
|
|
320
|
-
|
|
321
|
-
```ts
|
|
322
|
-
import { openInviteModal, shareRoomCode } from "@oasiz/sdk";
|
|
323
|
-
|
|
324
|
-
shareRoomCode("ABCD", { inviteOverride: true });
|
|
325
|
-
|
|
326
|
-
inviteButton.addEventListener("click", () => {
|
|
327
|
-
openInviteModal();
|
|
328
|
-
});
|
|
329
|
-
```
|
|
330
|
-
|
|
331
291
|
### Read-only injected values
|
|
332
292
|
|
|
333
293
|
These are populated by the platform before the game loads. Always check for `undefined` before using.
|
|
@@ -361,7 +321,6 @@ import {
|
|
|
361
321
|
saveGameState,
|
|
362
322
|
flushGameState,
|
|
363
323
|
shareRoomCode,
|
|
364
|
-
enableLogOverlay,
|
|
365
324
|
onPause,
|
|
366
325
|
onResume,
|
|
367
326
|
onBackButton,
|
|
@@ -379,14 +338,7 @@ import {
|
|
|
379
338
|
## TypeScript types
|
|
380
339
|
|
|
381
340
|
```ts
|
|
382
|
-
import type {
|
|
383
|
-
GameState,
|
|
384
|
-
HapticType,
|
|
385
|
-
LogOverlayHandle,
|
|
386
|
-
LogOverlayOptions,
|
|
387
|
-
ScoreAnchor,
|
|
388
|
-
ScoreConfig,
|
|
389
|
-
} from "@oasiz/sdk";
|
|
341
|
+
import type { HapticType, ScoreConfig, ScoreAnchor, GameState } from "@oasiz/sdk";
|
|
390
342
|
```
|
|
391
343
|
|
|
392
344
|
---
|