@series-inc/venus-sdk 2.4.1 → 2.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 +264 -204
- package/dist/{AdsApi-Cz0XgLM8.d.mts → AdsApi-C_GcWmfO.d.mts} +178 -84
- package/dist/{AdsApi-Cz0XgLM8.d.ts → AdsApi-C_GcWmfO.d.ts} +178 -84
- package/dist/{chunk-MWUS3A7C.mjs → chunk-W7IPHM67.mjs} +22 -3
- package/dist/chunk-W7IPHM67.mjs.map +1 -0
- package/dist/{chunk-KQZIPQLJ.mjs → chunk-YDXFZ2A2.mjs} +363 -49
- package/dist/chunk-YDXFZ2A2.mjs.map +1 -0
- package/dist/core-R3FHW62G.mjs +3 -0
- package/dist/{core-RDMPQV6U.mjs.map → core-R3FHW62G.mjs.map} +1 -1
- package/dist/index.cjs +343 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +110 -9
- package/dist/index.d.ts +110 -9
- package/dist/index.mjs +6 -2
- package/dist/index.mjs.map +1 -1
- package/dist/venus-api/index.cjs +579 -1366
- package/dist/venus-api/index.cjs.map +1 -1
- package/dist/venus-api/index.d.mts +2 -2
- package/dist/venus-api/index.d.ts +2 -2
- package/dist/venus-api/index.mjs +159 -1270
- package/dist/venus-api/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-KQZIPQLJ.mjs.map +0 -1
- package/dist/chunk-MWUS3A7C.mjs.map +0 -1
- package/dist/core-RDMPQV6U.mjs +0 -3
package/README.md
CHANGED
|
@@ -17,21 +17,203 @@ The Venus SDK is built on a client-server RPC architecture:
|
|
|
17
17
|
- **Mock Implementations** - Complete mock APIs for local development
|
|
18
18
|
- **Venus API** - Low-level platform interface
|
|
19
19
|
|
|
20
|
-
###
|
|
20
|
+
### Usage
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
import {
|
|
23
|
+
import { default as VenusAPI } from '@series-inc/venus-sdk/api'
|
|
24
24
|
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// Initialize the API
|
|
26
|
+
await VenusAPI.initializeAsync()
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## API Overview
|
|
30
|
+
|
|
31
|
+
### Profile API
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// Get current user profile
|
|
35
|
+
const profile = await VenusAPI.profile.getCurrentProfile()
|
|
36
|
+
console.log(profile.name, profile.username)
|
|
37
|
+
```
|
|
38
|
+
---
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
### Safe Area & HUD Insets
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// Static safe area from initialization (baseline padding)
|
|
44
|
+
const safeArea = VenusAPI.config.ui.safeArea
|
|
45
|
+
layout.style.paddingTop = `${safeArea.top}px`
|
|
46
|
+
layout.style.paddingBottom = `${safeArea.bottom}px`
|
|
47
|
+
|
|
48
|
+
// Dynamic HUD insets arrive with lifecycle events
|
|
49
|
+
VenusAPI.lifecycle.onShow(({ hudInsets }) => {
|
|
50
|
+
applyInsets(hudInsets, 'preview')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
VenusAPI.lifecycle.onPlay(({ hudInsets }) => {
|
|
54
|
+
applyInsets(hudInsets, 'fullscreen')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
function applyInsets(insets, mode) {
|
|
58
|
+
// Use whichever inset is larger to avoid overlap with host UI
|
|
59
|
+
const top = Math.max(VenusAPI.config.ui.safeArea.top, insets.top)
|
|
60
|
+
canvas.style.paddingTop = `${top}px`
|
|
61
|
+
canvas.dataset.mode = mode
|
|
62
|
+
}
|
|
32
63
|
```
|
|
33
64
|
|
|
34
|
-
|
|
65
|
+
`safeArea` provides a static baseline defined at initialization. `hudInsets` reflect the live host UI chrome and differ between preview (`onShow`) and fullscreen (`onPlay`) contexts.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
### Ads API
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
// Check if rewarded ad is ready
|
|
73
|
+
const rewardedReady = await VenusAPI.ads.isRewardedAdReadyAsync()
|
|
74
|
+
|
|
75
|
+
// Show interstitial ad
|
|
76
|
+
const interstitialShown = await VenusAPI.ads.showInterstitialAd()
|
|
77
|
+
if (interstitialShown) {
|
|
78
|
+
// Interstitial ad was displayed
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Show rewarded video ad
|
|
82
|
+
const rewardEarned = await VenusAPI.ads.showRewardedAdAsync()
|
|
83
|
+
if (rewardEarned) {
|
|
84
|
+
// User watched the full video and earned reward
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### Haptics API
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// Trigger haptic feedback
|
|
93
|
+
await VenusAPI.haptics.trigger('success')
|
|
94
|
+
await VenusAPI.haptics.trigger('warning')
|
|
95
|
+
await VenusApi.haptics.trigger('light')
|
|
96
|
+
await VenusApi.haptics.trigger('medium')
|
|
97
|
+
await VenusAPI.haptics.trigger('heavy')
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### Local Notifications API
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
// Schedule a delayed notification
|
|
106
|
+
const id = await VenusApi.notifications.scheduleAsync({
|
|
107
|
+
title: 'Notification Title',
|
|
108
|
+
body: 'Notification Body',
|
|
109
|
+
trigger: {
|
|
110
|
+
type: 'timeInterval',
|
|
111
|
+
seconds: 60 // Delay in seconds (required)
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
// Cancel a notification
|
|
116
|
+
await VenusApi.notifications.cancelNotification(notificationId)
|
|
117
|
+
|
|
118
|
+
// Get all scheduled notifications
|
|
119
|
+
await VenusApi.notifications.getAllScheduledLocalNotifications()
|
|
120
|
+
```
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### Loader API
|
|
124
|
+
|
|
125
|
+
The preloader is opt-in by default. In order to opt in, you must add
|
|
126
|
+
```typescript
|
|
127
|
+
await VenusAPI.initializeAsync({ usePreloader: true })
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
// Activating and dismissing the preloader
|
|
132
|
+
await VenusApi.preloader.showLoadScreen()
|
|
133
|
+
await VenusApi.preloader.hideLoadScreen()
|
|
134
|
+
```
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### Custom Funnel Events API
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// Record a custom analytics event
|
|
141
|
+
await VenusApi.analytics.recordCustomEvent('level_completed', {
|
|
142
|
+
level: 5,
|
|
143
|
+
score: 1250,
|
|
144
|
+
time: 45.2
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
// Track funnel step with optional funnel name
|
|
148
|
+
await VenusApi.analytics.trackFunnelStep(1, 'tutorial_started', 'onboarding')
|
|
149
|
+
await VenusApi.analytics.trackFunnelStep(2, 'tutorial_completed', 'onboarding')
|
|
150
|
+
```
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### IAP API
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// get VBucks/Hard Currency balance
|
|
157
|
+
await VenusApi.iap.getHardCurrencyBalance()
|
|
158
|
+
// Spend VBucks/Hard Currency
|
|
159
|
+
await VenusApi.iap.spendCurrency({
|
|
160
|
+
productId: 'yourProductID',
|
|
161
|
+
amount: '3',
|
|
162
|
+
options?: {
|
|
163
|
+
screenname: 'yourScreenName'
|
|
164
|
+
},
|
|
165
|
+
})
|
|
166
|
+
// Open Venus Store
|
|
167
|
+
await VenusApi.iap.openStore()
|
|
168
|
+
// Get Currency Icon
|
|
169
|
+
await VenusApi.iap.getCurrencyIcon()
|
|
170
|
+
```
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
### Saves API
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
// Get an item from storage
|
|
177
|
+
await VenusApi.storage.getItem('playerData')
|
|
178
|
+
// Set an item in storage
|
|
179
|
+
await VenusApi.storage.setItem('playerData', JSON.stringify({ level: 10 }))
|
|
180
|
+
// Remove an item from storage
|
|
181
|
+
await VenusApi.storage.removeItem('playerData')
|
|
182
|
+
// Get storage length
|
|
183
|
+
await VenusApi.storage.length()
|
|
184
|
+
// Get key at specific index
|
|
185
|
+
await VenusApi.storage.key(0)
|
|
186
|
+
// Clear all items from storage
|
|
187
|
+
await VenusApi.storage.clear()
|
|
188
|
+
// Set multiple items at once
|
|
189
|
+
await VenusApi.storage.setMultipleItems([
|
|
190
|
+
{ key: 'playerData', value: JSON.stringify({ level: 10 }) },
|
|
191
|
+
{ key: 'settings', value: JSON.stringify({ sound: true }) }
|
|
192
|
+
])
|
|
193
|
+
// Remove multiple items at once
|
|
194
|
+
await VenusApi.storage.removeMultipleItems(['playerData', 'settings'])
|
|
195
|
+
// Get all items from storage
|
|
196
|
+
await VenusApi.storage.getAllItems()
|
|
197
|
+
```
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### LLM API
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
// Request chat completion from AI model
|
|
204
|
+
const response = await VenusApi.ai.requestChatCompletionAsync({
|
|
205
|
+
model: 'chatGPT',
|
|
206
|
+
messages: [
|
|
207
|
+
{
|
|
208
|
+
role: 'user',
|
|
209
|
+
content: 'What is the best strategy for this level?'
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
// Get available completion models
|
|
215
|
+
const models = await VenusApi.ai.getAvailableCompletionModels()
|
|
216
|
+
```
|
|
35
217
|
|
|
36
218
|
### Simulation API
|
|
37
219
|
|
|
@@ -41,11 +223,11 @@ The Simulation API manages game state, recipe execution, and slot systems.
|
|
|
41
223
|
|
|
42
224
|
```typescript
|
|
43
225
|
// Get current simulation state
|
|
44
|
-
const state = await
|
|
226
|
+
const state = await VenusAPI.simulation.getStateAsync(roomId?)
|
|
45
227
|
// Returns: { entities, inventory, currencies, timers, etc. }
|
|
46
228
|
|
|
47
229
|
// Get simulation configuration
|
|
48
|
-
const config = await
|
|
230
|
+
const config = await VenusAPI.simulation.getConfigAsync(roomId?)
|
|
49
231
|
```
|
|
50
232
|
|
|
51
233
|
#### Recipe Execution
|
|
@@ -54,34 +236,34 @@ Recipes are server-authoritative game actions (crafting, battles, upgrades, etc.
|
|
|
54
236
|
|
|
55
237
|
```typescript
|
|
56
238
|
// Execute a recipe
|
|
57
|
-
const result = await
|
|
239
|
+
const result = await VenusAPI.simulation.executeRecipeAsync(
|
|
58
240
|
'craft_sword',
|
|
59
241
|
{ materials: ['iron', 'wood'] },
|
|
60
242
|
{ skipNotification: false }
|
|
61
243
|
)
|
|
62
244
|
|
|
63
245
|
// Execute a scoped recipe (entity-specific)
|
|
64
|
-
const result = await
|
|
246
|
+
const result = await VenusAPI.simulation.executeScopedRecipeAsync(
|
|
65
247
|
'upgrade_weapon',
|
|
66
248
|
'sword_123',
|
|
67
249
|
{ level: 5 }
|
|
68
250
|
)
|
|
69
251
|
|
|
70
252
|
// Get active recipe runs (for time-based recipes)
|
|
71
|
-
const runs = await
|
|
253
|
+
const runs = await VenusAPI.simulation.getActiveRunsAsync()
|
|
72
254
|
|
|
73
255
|
// Collect completed recipe
|
|
74
|
-
const result = await
|
|
256
|
+
const result = await VenusAPI.simulation.collectRecipeAsync(runId)
|
|
75
257
|
|
|
76
258
|
// Trigger recipe chain
|
|
77
|
-
await
|
|
259
|
+
await VenusAPI.simulation.triggerRecipeChainAsync('battle_complete')
|
|
78
260
|
```
|
|
79
261
|
|
|
80
262
|
#### Recipe Requirements
|
|
81
263
|
|
|
82
264
|
```typescript
|
|
83
265
|
// Check requirements for a single recipe
|
|
84
|
-
const requirements = await
|
|
266
|
+
const requirements = await VenusAPI.simulation.getRecipeRequirementsAsync({
|
|
85
267
|
recipeId: 'craft_sword',
|
|
86
268
|
entity: 'player',
|
|
87
269
|
amount: 1
|
|
@@ -89,13 +271,13 @@ const requirements = await host.simulation.getRecipeRequirementsAsync({
|
|
|
89
271
|
// Returns: { canAfford, costs, rewards }
|
|
90
272
|
|
|
91
273
|
// Batch check multiple recipes
|
|
92
|
-
const results = await
|
|
274
|
+
const results = await VenusAPI.simulation.getBatchRecipeRequirementsAsync([
|
|
93
275
|
{ recipeId: 'craft_sword', amount: 1 },
|
|
94
276
|
{ recipeId: 'craft_shield', amount: 2 }
|
|
95
277
|
])
|
|
96
278
|
|
|
97
279
|
// Get available recipes
|
|
98
|
-
const recipes = await
|
|
280
|
+
const recipes = await VenusAPI.simulation.getAvailableRecipesAsync({
|
|
99
281
|
roomId: 'room_123',
|
|
100
282
|
includeActorRecipes: true
|
|
101
283
|
})
|
|
@@ -107,24 +289,24 @@ Slots represent equipment, loadouts, teams, or any item container system:
|
|
|
107
289
|
|
|
108
290
|
```typescript
|
|
109
291
|
// Get all slot containers
|
|
110
|
-
const containers = await
|
|
292
|
+
const containers = await VenusAPI.simulation.getSlotContainersAsync()
|
|
111
293
|
// Returns: [{ id: 'equipment', slots: [...] }, { id: 'team', slots: [...] }]
|
|
112
294
|
|
|
113
295
|
// Get slot assignments for a container
|
|
114
|
-
const assignments = await
|
|
296
|
+
const assignments = await VenusAPI.simulation.getSlotAssignmentsAsync('equipment')
|
|
115
297
|
// Returns: [{ slotId: 'weapon', itemId: 'sword_123' }, ...]
|
|
116
298
|
|
|
117
299
|
// Assign item to slot
|
|
118
|
-
await
|
|
300
|
+
await VenusAPI.simulation.assignItemToSlotAsync('equipment', 'weapon', 'sword_123')
|
|
119
301
|
|
|
120
302
|
// Remove item from slot
|
|
121
|
-
await
|
|
303
|
+
await VenusAPI.simulation.removeItemFromSlotAsync('equipment', 'weapon')
|
|
122
304
|
|
|
123
305
|
// Get available items for a slot
|
|
124
|
-
const items = await
|
|
306
|
+
const items = await VenusAPI.simulation.getAvailableItemsAsync('equipment', 'weapon')
|
|
125
307
|
|
|
126
308
|
// Preview power calculation before assignment
|
|
127
|
-
const preview = await
|
|
309
|
+
const preview = await VenusAPI.simulation.calculatePowerPreviewAsync(
|
|
128
310
|
'equipment',
|
|
129
311
|
'weapon',
|
|
130
312
|
'sword_456'
|
|
@@ -132,7 +314,7 @@ const preview = await host.simulation.calculatePowerPreviewAsync(
|
|
|
132
314
|
// Returns: { currentPower: 100, newPower: 150, delta: +50 }
|
|
133
315
|
|
|
134
316
|
// Validate slot assignment
|
|
135
|
-
const valid = await
|
|
317
|
+
const valid = await VenusAPI.simulation.validateSlotAssignmentAsync(
|
|
136
318
|
'equipment',
|
|
137
319
|
'weapon',
|
|
138
320
|
'shield_123' // Wrong type
|
|
@@ -140,7 +322,7 @@ const valid = await host.simulation.validateSlotAssignmentAsync(
|
|
|
140
322
|
// Returns: { valid: false, reason: 'Type mismatch' }
|
|
141
323
|
|
|
142
324
|
// Batch operations (atomic)
|
|
143
|
-
await
|
|
325
|
+
await VenusAPI.simulation.executeBatchOperationsAsync([
|
|
144
326
|
{ type: 'assign', containerId: 'equipment', slotId: 'weapon', itemId: 'sword' },
|
|
145
327
|
{ type: 'assign', containerId: 'equipment', slotId: 'armor', itemId: 'plate' },
|
|
146
328
|
{ type: 'remove', containerId: 'equipment', slotId: 'boots' }
|
|
@@ -151,21 +333,22 @@ await host.simulation.executeBatchOperationsAsync([
|
|
|
151
333
|
|
|
152
334
|
```typescript
|
|
153
335
|
// Resolve dynamic field values
|
|
154
|
-
const value = await
|
|
336
|
+
const value = await VenusAPI.simulation.resolveFieldValueAsync(
|
|
155
337
|
'player_123',
|
|
156
338
|
'stats.power',
|
|
157
339
|
'player'
|
|
158
340
|
)
|
|
159
341
|
|
|
160
342
|
// Get entity metadata
|
|
161
|
-
const metadata = await
|
|
343
|
+
const metadata = await VenusAPI.simulation.getEntityMetadataAsync('sword_123')
|
|
162
344
|
```
|
|
345
|
+
---
|
|
163
346
|
|
|
164
347
|
#### Utility Methods
|
|
165
348
|
|
|
166
349
|
```typescript
|
|
167
350
|
// Sum stat contributions
|
|
168
|
-
const totalPower =
|
|
351
|
+
const totalPower = VenusAPI.simulation.sumContributions(
|
|
169
352
|
[{ power: 10 }, { power: 20 }, { power: 15 }],
|
|
170
353
|
'power'
|
|
171
354
|
)
|
|
@@ -180,15 +363,15 @@ Three-tier storage system with different data scopes:
|
|
|
180
363
|
|
|
181
364
|
```typescript
|
|
182
365
|
// Device Cache - persists across all apps for the device
|
|
183
|
-
await
|
|
184
|
-
const userId = await
|
|
366
|
+
await VenusAPI.deviceCache.set('lastUserId', '12345')
|
|
367
|
+
const userId = await VenusAPI.deviceCache.get('lastUserId')
|
|
185
368
|
|
|
186
369
|
// App Storage - app-specific persistent storage
|
|
187
|
-
await
|
|
188
|
-
await
|
|
370
|
+
await VenusAPI.appStorage.set('highScore', 1000)
|
|
371
|
+
await VenusAPI.appStorage.set('playerData', { level: 5, gold: 1000 })
|
|
189
372
|
|
|
190
373
|
// Global Storage - shared across all apps for the user
|
|
191
|
-
await
|
|
374
|
+
await VenusAPI.globalStorage.set('preferences', { theme: 'dark' })
|
|
192
375
|
|
|
193
376
|
// All storage APIs support:
|
|
194
377
|
const value = await storage.get(key, defaultValue?)
|
|
@@ -201,47 +384,6 @@ const keyName = await storage.key(index)
|
|
|
201
384
|
|
|
202
385
|
---
|
|
203
386
|
|
|
204
|
-
### Profile API
|
|
205
|
-
|
|
206
|
-
```typescript
|
|
207
|
-
// Get current user profile
|
|
208
|
-
const profile = await host.profile.getCurrentProfile()
|
|
209
|
-
// Returns: { id, name, username }
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
---
|
|
213
|
-
|
|
214
|
-
### Ads API
|
|
215
|
-
|
|
216
|
-
```typescript
|
|
217
|
-
// Check ad readiness
|
|
218
|
-
const interstitialReady = await host.ads.isInterstitialReady()
|
|
219
|
-
const rewardedReady = await host.ads.isRewardedReady()
|
|
220
|
-
|
|
221
|
-
// Show interstitial ad
|
|
222
|
-
await host.ads.showInterstitial()
|
|
223
|
-
|
|
224
|
-
// Show rewarded video ad
|
|
225
|
-
const watched = await host.ads.showRewarded()
|
|
226
|
-
if (watched) {
|
|
227
|
-
// User watched the full video, grant reward
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
### Haptics API
|
|
234
|
-
|
|
235
|
-
Trigger haptic feedback on supported devices:
|
|
236
|
-
|
|
237
|
-
```typescript
|
|
238
|
-
// Available haptic types: 'light', 'medium', 'heavy', 'success', 'warning', 'error'
|
|
239
|
-
await host.haptics.trigger('success')
|
|
240
|
-
await host.haptics.trigger('warning')
|
|
241
|
-
await host.haptics.trigger('heavy')
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
---
|
|
245
387
|
|
|
246
388
|
### Popups API
|
|
247
389
|
|
|
@@ -249,21 +391,21 @@ Display native-style UI popups:
|
|
|
249
391
|
|
|
250
392
|
```typescript
|
|
251
393
|
// Toast messages
|
|
252
|
-
await
|
|
394
|
+
await VenusAPI.popups.showToast('Game saved!', {
|
|
253
395
|
duration: 3000,
|
|
254
396
|
variant: 'success',
|
|
255
397
|
action: { label: 'Undo' }
|
|
256
398
|
})
|
|
257
399
|
|
|
258
400
|
// Alert dialog
|
|
259
|
-
await
|
|
401
|
+
await VenusAPI.popups.showAlert({
|
|
260
402
|
title: 'Warning',
|
|
261
403
|
message: 'This action cannot be undone',
|
|
262
404
|
buttonText: 'OK'
|
|
263
405
|
})
|
|
264
406
|
|
|
265
407
|
// Confirm dialog
|
|
266
|
-
const confirmed = await
|
|
408
|
+
const confirmed = await VenusAPI.popups.showConfirm({
|
|
267
409
|
title: 'Delete Item',
|
|
268
410
|
message: 'Are you sure you want to delete this item?',
|
|
269
411
|
confirmText: 'Delete',
|
|
@@ -275,7 +417,7 @@ if (confirmed) {
|
|
|
275
417
|
}
|
|
276
418
|
|
|
277
419
|
// Action sheet
|
|
278
|
-
const selected = await
|
|
420
|
+
const selected = await VenusAPI.popups.showActionSheet({
|
|
279
421
|
title: 'Choose Action',
|
|
280
422
|
options: [
|
|
281
423
|
{ id: 'edit', label: 'Edit', variant: 'default' },
|
|
@@ -298,17 +440,17 @@ Stack-based navigation system:
|
|
|
298
440
|
|
|
299
441
|
```typescript
|
|
300
442
|
// Get current stack information
|
|
301
|
-
const stack = await
|
|
443
|
+
const stack = await VenusAPI.navigation.getStackInfo()
|
|
302
444
|
// Returns: { depth, currentApp, history }
|
|
303
445
|
|
|
304
446
|
// Push new app to stack
|
|
305
|
-
await
|
|
447
|
+
await VenusAPI.navigation.push({
|
|
306
448
|
appId: 'bird-flap',
|
|
307
449
|
context: { level: 5, difficulty: 'hard' }
|
|
308
450
|
})
|
|
309
451
|
|
|
310
452
|
// Pop from stack (returns to previous app)
|
|
311
|
-
await
|
|
453
|
+
await VenusAPI.navigation.pop()
|
|
312
454
|
```
|
|
313
455
|
|
|
314
456
|
---
|
|
@@ -319,20 +461,20 @@ Social interaction APIs for posts:
|
|
|
319
461
|
|
|
320
462
|
```typescript
|
|
321
463
|
// Get post interaction data
|
|
322
|
-
const interactions = await
|
|
464
|
+
const interactions = await VenusAPI.post.getInteractions()
|
|
323
465
|
// Returns: { postId, isLiked, isFollowing, likeCount, commentCount }
|
|
324
466
|
|
|
325
467
|
// Toggle like
|
|
326
|
-
await
|
|
468
|
+
await VenusAPI.post.toggleLike()
|
|
327
469
|
|
|
328
470
|
// Toggle follow
|
|
329
|
-
await
|
|
471
|
+
await VenusAPI.post.toggleFollow()
|
|
330
472
|
|
|
331
473
|
// Open comments UI
|
|
332
|
-
await
|
|
474
|
+
await VenusAPI.post.openComments()
|
|
333
475
|
|
|
334
476
|
// Share post
|
|
335
|
-
await
|
|
477
|
+
await VenusAPI.post.share({
|
|
336
478
|
message: 'Check this out!',
|
|
337
479
|
recipientIds: ['user1', 'user2']
|
|
338
480
|
})
|
|
@@ -340,43 +482,18 @@ await host.post.share({
|
|
|
340
482
|
|
|
341
483
|
---
|
|
342
484
|
|
|
343
|
-
### AI API
|
|
344
|
-
|
|
345
|
-
LLM integration for chat completions:
|
|
346
|
-
|
|
347
|
-
```typescript
|
|
348
|
-
// Get available models
|
|
349
|
-
const models = await host.ai.getAvailableModels()
|
|
350
|
-
// Returns: ['gpt-4', 'gpt-3.5-turbo', 'claude-3-opus', ...]
|
|
351
|
-
|
|
352
|
-
// Chat completion
|
|
353
|
-
const response = await host.ai.chatCompletion({
|
|
354
|
-
messages: [
|
|
355
|
-
{ role: 'system', content: 'You are a helpful game assistant' },
|
|
356
|
-
{ role: 'user', content: 'What is the best strategy for this level?' }
|
|
357
|
-
],
|
|
358
|
-
model: 'gpt-4',
|
|
359
|
-
temperature: 0.7,
|
|
360
|
-
max_tokens: 500
|
|
361
|
-
})
|
|
362
|
-
|
|
363
|
-
console.log(response.choices[0].message.content)
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
---
|
|
367
|
-
|
|
368
485
|
### Analytics API
|
|
369
486
|
|
|
370
487
|
```typescript
|
|
371
488
|
// Log custom event
|
|
372
|
-
await
|
|
489
|
+
await VenusAPI.analytics.logEvent('level_complete', {
|
|
373
490
|
level: 5,
|
|
374
491
|
score: 1000,
|
|
375
492
|
timeElapsed: 120
|
|
376
493
|
})
|
|
377
494
|
|
|
378
495
|
// Set user properties
|
|
379
|
-
await
|
|
496
|
+
await VenusAPI.analytics.setUserProperty('vip_status', 'gold')
|
|
380
497
|
```
|
|
381
498
|
|
|
382
499
|
---
|
|
@@ -385,10 +502,10 @@ await host.analytics.setUserProperty('vip_status', 'gold')
|
|
|
385
502
|
|
|
386
503
|
```typescript
|
|
387
504
|
// Get current avatar configuration
|
|
388
|
-
const avatar = await
|
|
505
|
+
const avatar = await VenusAPI.avatar3d.get()
|
|
389
506
|
|
|
390
507
|
// Show avatar editor
|
|
391
|
-
const result = await
|
|
508
|
+
const result = await VenusAPI.avatar3d.showEditor({
|
|
392
509
|
allowSave: true,
|
|
393
510
|
enableSharing: true
|
|
394
511
|
})
|
|
@@ -398,13 +515,13 @@ if (result.saved) {
|
|
|
398
515
|
}
|
|
399
516
|
|
|
400
517
|
// Delete avatar
|
|
401
|
-
await
|
|
518
|
+
await VenusAPI.avatar3d.delete()
|
|
402
519
|
|
|
403
520
|
// Get shared avatar
|
|
404
|
-
const sharedAvatar = await
|
|
521
|
+
const sharedAvatar = await VenusAPI.avatar3d.getSharedAvatar('avatar_123')
|
|
405
522
|
|
|
406
523
|
// Download avatar manifest
|
|
407
|
-
const manifest = await
|
|
524
|
+
const manifest = await VenusAPI.avatar3d.downloadManifest('avatar_123')
|
|
408
525
|
```
|
|
409
526
|
|
|
410
527
|
---
|
|
@@ -415,17 +532,17 @@ Multi-user room management:
|
|
|
415
532
|
|
|
416
533
|
```typescript
|
|
417
534
|
// Get current room
|
|
418
|
-
const room = await
|
|
535
|
+
const room = await VenusAPI.rooms.getCurrentRoom()
|
|
419
536
|
// Returns: { id, name, participants, metadata }
|
|
420
537
|
|
|
421
538
|
// Join room
|
|
422
|
-
await
|
|
539
|
+
await VenusAPI.rooms.join('room_123')
|
|
423
540
|
|
|
424
541
|
// Leave room
|
|
425
|
-
await
|
|
542
|
+
await VenusAPI.rooms.leave()
|
|
426
543
|
|
|
427
544
|
// Send room message
|
|
428
|
-
await
|
|
545
|
+
await VenusAPI.rooms.sendMessage({
|
|
429
546
|
type: 'game_action',
|
|
430
547
|
data: { action: 'move', x: 10, y: 20 }
|
|
431
548
|
})
|
|
@@ -433,51 +550,23 @@ await host.rooms.sendMessage({
|
|
|
433
550
|
|
|
434
551
|
---
|
|
435
552
|
|
|
436
|
-
### Notifications API
|
|
437
|
-
|
|
438
|
-
Local push notifications:
|
|
439
|
-
|
|
440
|
-
```typescript
|
|
441
|
-
// Schedule notification
|
|
442
|
-
await host.notifications.schedule({
|
|
443
|
-
id: 'energy_full',
|
|
444
|
-
title: 'Energy Restored!',
|
|
445
|
-
body: 'Your energy is now full. Come back to play!',
|
|
446
|
-
trigger: { type: 'time', seconds: 3600 } // 1 hour
|
|
447
|
-
})
|
|
448
|
-
|
|
449
|
-
// Cancel notification
|
|
450
|
-
await host.notifications.cancel('energy_full')
|
|
451
|
-
|
|
452
|
-
// Get all scheduled notifications
|
|
453
|
-
const scheduled = await host.notifications.getAllScheduled()
|
|
454
|
-
|
|
455
|
-
// Check if notifications are enabled
|
|
456
|
-
const enabled = await host.notifications.isEnabled()
|
|
457
|
-
|
|
458
|
-
// Enable/disable notifications
|
|
459
|
-
await host.notifications.setEnabled(true)
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
---
|
|
463
|
-
|
|
464
553
|
### Time API
|
|
465
554
|
|
|
466
555
|
Server time synchronization and formatting:
|
|
467
556
|
|
|
468
557
|
```typescript
|
|
469
558
|
// Get server time
|
|
470
|
-
const serverTime = await
|
|
559
|
+
const serverTime = await VenusAPI.time.getServerTime()
|
|
471
560
|
// Returns: { timestamp, timezone, formatted }
|
|
472
561
|
|
|
473
562
|
// Format time with locale
|
|
474
|
-
const formatted =
|
|
563
|
+
const formatted = VenusAPI.time.format(Date.now(), {
|
|
475
564
|
locale: 'en-US',
|
|
476
565
|
format: 'full' // 'full', 'long', 'medium', 'short'
|
|
477
566
|
})
|
|
478
567
|
|
|
479
568
|
// Format number with locale
|
|
480
|
-
const formatted =
|
|
569
|
+
const formatted = VenusAPI.time.formatNumber(1234567.89, {
|
|
481
570
|
locale: 'en-US',
|
|
482
571
|
style: 'currency',
|
|
483
572
|
currency: 'USD'
|
|
@@ -490,10 +579,10 @@ const formatted = host.time.formatNumber(1234567.89, {
|
|
|
490
579
|
|
|
491
580
|
```typescript
|
|
492
581
|
// Get CDN URL for an asset
|
|
493
|
-
const url = await
|
|
582
|
+
const url = await VenusAPI.cdn.getAssetUrl('images/logo.png')
|
|
494
583
|
|
|
495
584
|
// Upload to CDN
|
|
496
|
-
const uploadUrl = await
|
|
585
|
+
const uploadUrl = await VenusAPI.cdn.upload(file)
|
|
497
586
|
```
|
|
498
587
|
|
|
499
588
|
---
|
|
@@ -504,77 +593,52 @@ Feature flags, experiments, and A/B testing:
|
|
|
504
593
|
|
|
505
594
|
```typescript
|
|
506
595
|
// Get feature flag value
|
|
507
|
-
const enabled = await
|
|
596
|
+
const enabled = await VenusAPI.features.getFeatureFlag('new_ui_enabled')
|
|
508
597
|
|
|
509
598
|
// Get feature gate (boolean flag)
|
|
510
|
-
const canAccess = await
|
|
599
|
+
const canAccess = await VenusAPI.features.getFeatureGate('beta_features')
|
|
511
600
|
|
|
512
601
|
// Get experiment variant
|
|
513
|
-
const experiment = await
|
|
602
|
+
const experiment = await VenusAPI.features.getExperiment('checkout_flow')
|
|
514
603
|
// Returns: { variant: 'control' | 'variant_a' | 'variant_b', ... }
|
|
515
604
|
```
|
|
516
605
|
|
|
517
|
-
---
|
|
518
|
-
|
|
519
|
-
### IAP API
|
|
520
|
-
|
|
521
|
-
In-app purchases and virtual currency:
|
|
522
|
-
|
|
523
|
-
```typescript
|
|
524
|
-
// Get wallet balance
|
|
525
|
-
const wallet = await host.iap.getWallet()
|
|
526
|
-
// Returns: { coins: 1000, gems: 50 }
|
|
527
|
-
|
|
528
|
-
// Spend currency
|
|
529
|
-
const result = await host.iap.spendCurrency('coins', 100)
|
|
530
|
-
if (result.success) {
|
|
531
|
-
console.log('Purchase successful')
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
// Listen for wallet updates
|
|
535
|
-
host.iap.onWalletUpdate((wallet) => {
|
|
536
|
-
console.log('Wallet updated:', wallet)
|
|
537
|
-
})
|
|
538
|
-
```
|
|
539
|
-
|
|
540
|
-
---
|
|
541
|
-
|
|
542
606
|
### Lifecycle API
|
|
543
607
|
|
|
544
608
|
App lifecycle event handlers:
|
|
545
609
|
|
|
546
610
|
```typescript
|
|
547
611
|
// Register lifecycle callbacks
|
|
548
|
-
|
|
612
|
+
VenusAPI.lifecycle.onReady(() => {
|
|
549
613
|
console.log('App ready')
|
|
550
614
|
})
|
|
551
615
|
|
|
552
|
-
|
|
616
|
+
VenusAPI.lifecycle.onShow((context) => {
|
|
553
617
|
console.log('App shown', context.hudInsets)
|
|
554
618
|
})
|
|
555
619
|
|
|
556
|
-
|
|
620
|
+
VenusAPI.lifecycle.onPlay((context) => {
|
|
557
621
|
console.log('App playing', context.hudInsets)
|
|
558
622
|
})
|
|
559
623
|
|
|
560
|
-
|
|
624
|
+
VenusAPI.lifecycle.onPause(() => {
|
|
561
625
|
console.log('App paused')
|
|
562
626
|
})
|
|
563
627
|
|
|
564
|
-
|
|
628
|
+
VenusAPI.lifecycle.onResume(() => {
|
|
565
629
|
console.log('App resumed')
|
|
566
630
|
})
|
|
567
631
|
|
|
568
|
-
|
|
632
|
+
VenusAPI.lifecycle.onHidden(() => {
|
|
569
633
|
console.log('App hidden')
|
|
570
634
|
})
|
|
571
635
|
|
|
572
|
-
|
|
636
|
+
VenusAPI.lifecycle.onQuit(() => {
|
|
573
637
|
console.log('App quitting')
|
|
574
638
|
})
|
|
575
639
|
|
|
576
640
|
// Quit the app
|
|
577
|
-
await
|
|
641
|
+
await VenusAPI.lifecycle.quit()
|
|
578
642
|
```
|
|
579
643
|
|
|
580
644
|
---
|
|
@@ -583,9 +647,9 @@ await host.lifecycle.quit()
|
|
|
583
647
|
|
|
584
648
|
```typescript
|
|
585
649
|
// Log messages
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
650
|
+
VenusAPI.logging.log('Info message', { data: 'value' })
|
|
651
|
+
VenusAPI.logging.error('Error message', error)
|
|
652
|
+
VenusAPI.logging.debug('Debug info')
|
|
589
653
|
```
|
|
590
654
|
|
|
591
655
|
---
|
|
@@ -595,22 +659,18 @@ host.logging.debug('Debug info')
|
|
|
595
659
|
All APIs have complete mock implementations for local development:
|
|
596
660
|
|
|
597
661
|
```typescript
|
|
598
|
-
import {
|
|
599
|
-
|
|
600
|
-
const venusApi = new VenusAPI()
|
|
601
|
-
await venusApi.initializeAsync({ mock: true })
|
|
662
|
+
import { default as VenusAPI } from '@series-inc/venus-sdk/api'
|
|
602
663
|
|
|
603
|
-
|
|
604
|
-
await host.initialize()
|
|
664
|
+
await VenusAPI.initializeAsync({ mock: true })
|
|
605
665
|
|
|
606
666
|
// All APIs work the same, but with simulated responses
|
|
607
|
-
const state = await
|
|
667
|
+
const state = await VenusAPI.simulation.getStateAsync()
|
|
608
668
|
```
|
|
609
669
|
|
|
610
670
|
### Custom Mock Data
|
|
611
671
|
|
|
612
672
|
```typescript
|
|
613
|
-
await
|
|
673
|
+
await VenusAPI.initializeAsync({
|
|
614
674
|
mock: {
|
|
615
675
|
simulation: {
|
|
616
676
|
state: { customData: 'value' }
|