@oasiz/sdk 1.6.1 → 1.6.2
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 +79 -0
- package/dist/index.cjs +1479 -330
- package/dist/index.d.cts +79 -31
- package/dist/index.d.ts +79 -31
- package/dist/index.js +1478 -330
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,11 @@ The published package includes ESM, CommonJS, and TypeScript declarations.
|
|
|
28
28
|
```ts
|
|
29
29
|
import { oasiz } from "@oasiz/sdk";
|
|
30
30
|
|
|
31
|
+
// 0. Optional local app preview for web development
|
|
32
|
+
if (import.meta.env.DEV) {
|
|
33
|
+
oasiz.enableAppSimulator();
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
// 1. Load persisted state at the start of each session
|
|
32
37
|
const state = oasiz.loadGameState();
|
|
33
38
|
let level = typeof state.level === "number" ? state.level : 1;
|
|
@@ -61,6 +66,74 @@ oasiz.enableLogOverlay({
|
|
|
61
66
|
});
|
|
62
67
|
```
|
|
63
68
|
|
|
69
|
+
### Local app simulator
|
|
70
|
+
|
|
71
|
+
#### `oasiz.enableAppSimulator(options?: AppSimulatorOptions): AppSimulatorHandle`
|
|
72
|
+
|
|
73
|
+
Opt-in local web helper for previewing a game inside Oasiz-style mobile chrome. It simulates the app back button, leaderboard pill, like/comment hub, comments modal, and leaderboard modal while also injecting local safe-area and viewport-inset bridge values.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
if (import.meta.env.DEV) {
|
|
77
|
+
oasiz.enableAppSimulator();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
oasiz.onBackButton(() => {
|
|
81
|
+
togglePauseMenu();
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
By default, the game is placed inside a centered phone-sized box so developers can resize their browser around the same shape the app uses. The default device is `iphone-17-pro-max` (`440 × 956` CSS pixels). You can change the preview:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
const appPreview = oasiz.enableAppSimulator({
|
|
89
|
+
device: "iphone-17-pro-max",
|
|
90
|
+
likes: 2400,
|
|
91
|
+
comments: 18,
|
|
92
|
+
score: 12400,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
debugCommentsButton.onclick = () => appPreview.openComments();
|
|
96
|
+
debugLeaderboardButton.onclick = () => appPreview.openLeaderboard();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Set `frame: false` if your own dev harness already renders the game in a phone frame.
|
|
100
|
+
|
|
101
|
+
The simulator includes the back-button test bridge, so Escape, browser Back, and the simulated app back button all route through the same `oasiz.onBackButton(...)` handler when back override is active. Use `enableBackButtonTesting()` directly only when you want back simulation without app chrome.
|
|
102
|
+
|
|
103
|
+
Supported `device` presets:
|
|
104
|
+
|
|
105
|
+
| Device option | CSS viewport |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `iphone-11` | `414 × 896` |
|
|
108
|
+
| `iphone-11-pro` | `375 × 812` |
|
|
109
|
+
| `iphone-11-pro-max` | `414 × 896` |
|
|
110
|
+
| `iphone-12-mini` | `375 × 812` |
|
|
111
|
+
| `iphone-12` | `390 × 844` |
|
|
112
|
+
| `iphone-12-pro` | `390 × 844` |
|
|
113
|
+
| `iphone-12-pro-max` | `428 × 926` |
|
|
114
|
+
| `iphone-13-mini` | `375 × 812` |
|
|
115
|
+
| `iphone-13` | `390 × 844` |
|
|
116
|
+
| `iphone-13-pro` | `390 × 844` |
|
|
117
|
+
| `iphone-13-pro-max` | `428 × 926` |
|
|
118
|
+
| `iphone-14` | `390 × 844` |
|
|
119
|
+
| `iphone-14-plus` | `428 × 926` |
|
|
120
|
+
| `iphone-14-pro` | `393 × 852` |
|
|
121
|
+
| `iphone-14-pro-max` | `430 × 932` |
|
|
122
|
+
| `iphone-15` | `393 × 852` |
|
|
123
|
+
| `iphone-15-plus` | `430 × 932` |
|
|
124
|
+
| `iphone-15-pro` | `393 × 852` |
|
|
125
|
+
| `iphone-15-pro-max` | `430 × 932` |
|
|
126
|
+
| `iphone-16` | `393 × 852` |
|
|
127
|
+
| `iphone-16-plus` | `430 × 932` |
|
|
128
|
+
| `iphone-16-pro` | `402 × 874` |
|
|
129
|
+
| `iphone-16-pro-max` | `440 × 956` |
|
|
130
|
+
| `iphone-16e` | `390 × 844` |
|
|
131
|
+
| `iphone-17` | `402 × 874` |
|
|
132
|
+
| `iphone-17-pro` | `402 × 874` |
|
|
133
|
+
| `iphone-17-pro-max` | `440 × 956` |
|
|
134
|
+
| `iphone-17e` | `390 × 844` |
|
|
135
|
+
| `iphone-air` | `420 × 912` |
|
|
136
|
+
|
|
64
137
|
### Score
|
|
65
138
|
|
|
66
139
|
#### `oasiz.submitScore(score: number)`
|
|
@@ -481,6 +554,7 @@ import {
|
|
|
481
554
|
flushGameState,
|
|
482
555
|
shareRoomCode,
|
|
483
556
|
openInviteModal,
|
|
557
|
+
enableAppSimulator,
|
|
484
558
|
enableLogOverlay,
|
|
485
559
|
enableBackButtonTesting,
|
|
486
560
|
getGraphicsPerformance,
|
|
@@ -503,6 +577,11 @@ import {
|
|
|
503
577
|
|
|
504
578
|
```ts
|
|
505
579
|
import type {
|
|
580
|
+
AppSimulatorDevice,
|
|
581
|
+
AppSimulatorDeviceName,
|
|
582
|
+
AppSimulatorHandle,
|
|
583
|
+
AppSimulatorOptions,
|
|
584
|
+
AppSimulatorOrientation,
|
|
506
585
|
BackButtonTestingHandle,
|
|
507
586
|
BackButtonTestingOptions,
|
|
508
587
|
GameState,
|